]> git.mxchange.org Git - flightgear.git/commitdiff
Added a range parameter to the FindByPos search function, also fixed a bug whereby...
authordaveluff <daveluff>
Sun, 9 Mar 2003 17:35:16 +0000 (17:35 +0000)
committerdaveluff <daveluff>
Sun, 9 Mar 2003 17:35:16 +0000 (17:35 +0000)
src/ATC/ATCmgr.cxx
src/ATC/commlist.cxx
src/ATC/commlist.hxx

index b2532db33a3d1cc0f7ab9ef1ad9a5530e7539696..f32c7ef6a60d7f9989fa4ef9cc9ee276b0f08801 100644 (file)
 
 #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;
                
index eb0201e9213a7ecade8eefc5ba6c06152931e9d6..8f282ea3bac8fd8cfd2f2cab40be5b2540c35fc4 100644 (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()) {
index 033b90afa7a7e6ff50b10ee41e1f31bdc84a7a38..873d870be6d0b45dc329791f95a6e2196e14cc38 100644 (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 );