1
0
Fork 0

Added a range parameter to the FindByPos search function, also fixed a bug whereby one too few buckets in the North and East direction were searched - hence when only one bucket should have been searched none were

This commit is contained in:
daveluff 2003-03-09 17:35:16 +00:00
parent 2c20e61b4b
commit a9463a8399
3 changed files with 11 additions and 16 deletions

View file

@ -26,10 +26,6 @@
#include "ATCmgr.hxx"
#include "commlist.hxx"
//#include "atislist.hxx"
//#include "groundlist.hxx"
//#include "towerlist.hxx"
//#include "approachlist.hxx"
#include "ATCdisplay.hxx"
#include "ATCDialog.hxx"
#include "ATCutils.hxx"
@ -501,7 +497,7 @@ void FGATCMgr::AreaSearch() {
elev = elev_node->getDoubleValue() * SG_FEET_TO_METER;
// search stations in range
int num_app = current_commlist->FindByPos(lon, lat, elev, &approaches, APPROACH);
int num_app = current_commlist->FindByPos(lon, lat, elev, 100.0, &approaches, APPROACH);
if (num_app != 0) {
//cout << num_app << " approaches found in radiostack search !!!!" << endl;

View file

@ -163,7 +163,7 @@ bool FGCommList::FindByFreq( double lon, double lat, double elev, double freq,
return false;
}
int FGCommList::FindByPos(double lon, double lat, double elev, comm_list_type* stations, atc_type tp)
int FGCommList::FindByPos(double lon, double lat, double elev, double range, comm_list_type* stations, atc_type tp)
{
// number of relevant stations found within range
int found = 0;
@ -173,13 +173,12 @@ int FGCommList::FindByPos(double lon, double lat, double elev, comm_list_type* s
SGBucket buck(lon, lat);
// get neigboring buckets
int max_range = 100;
int bx = (int)( max_range*SG_NM_TO_METER / buck.get_width_m() / 2);
int by = (int)( max_range*SG_NM_TO_METER / buck.get_height_m() / 2 );
int bx = (int)( range*SG_NM_TO_METER / buck.get_width_m() / 2);
int by = (int)( range*SG_NM_TO_METER / buck.get_height_m() / 2 );
// loop over bucket range
for ( int i=-bx; i<bx; i++) {
for ( int j=-by; j<by; j++) {
for ( int i=-bx; i<=bx; i++) {
for ( int j=-by; j<=by; j++) {
buck = sgBucketOffset(lon, lat, i, j);
long int bucket = buck.gen_index();
comm_list_type Fstations = commlist_bck[bucket];
@ -217,7 +216,7 @@ bool FGCommList::FindByCode( string ICAO, ATCData& ad, atc_type tp ) {
FGAirport a;
if ( dclFindAirportID( ICAO, &a ) ) {
comm_list_type stations;
int found = FindByPos(a.longitude, a.latitude, a.elevation, &stations, tp);
int found = FindByPos(a.longitude, a.latitude, a.elevation, 10.0, &stations, tp);
if(found) {
comm_list_iterator itr = stations.begin();
while(itr != stations.end()) {

View file

@ -78,16 +78,16 @@ public:
bool FindByFreq( double lon, double lat, double elev, double freq, ATCData* ad, atc_type tp = INVALID );
// query the database by location, lon and lat are
// in degrees, elev is in meters
// in degrees, elev is in meters, range is in nautical miles.
// Returns the number of stations of the specified type that are in range, and pushes them into stations
// If atc_type is specifed, returns the number of all stations in range, and pushes them into stations
// If no atc_type is specifed, returns the number of all stations in range, and pushes them into stations
// ** stations is erased before use **
int FindByPos( double lon, double lat, double elev, comm_list_type* stations, atc_type tp = INVALID );
int FindByPos( double lon, double lat, double elev, double range, comm_list_type* stations, atc_type tp = INVALID );
// Find by Airport code.
bool FindByCode( string ICAO, ATCData& ad, atc_type tp = INVALID );
// Return the callsign for an ATIS transmission given transmission time and airpord id
// Return the callsign for an ATIS transmission given transmission time and airport id
// This maybe should get moved somewhere else!!
int GetCallSign( string apt_id, int hours, int mins );