]> git.mxchange.org Git - flightgear.git/commitdiff
Added FindByCode (airport ICAO code) to commlist. This is basically a wrapper around...
authordaveluff <daveluff>
Thu, 6 Mar 2003 14:06:34 +0000 (14:06 +0000)
committerdaveluff <daveluff>
Thu, 6 Mar 2003 14:06:34 +0000 (14:06 +0000)
src/ATC/commlist.cxx
src/ATC/commlist.hxx

index 5494088a1d238c69f85405de160764130a5a432c..509b095c3771fc6da322c61c66be3c02bcb095b2 100644 (file)
 #include <simgear/math/sg_geodesy.hxx>
 #include <simgear/math/sg_random.h>
 #include <simgear/bucket/newbucket.hxx>
+#include <Airports/simple.hxx>
 
 #include "commlist.hxx"
 //#include "atislist.hxx"
+#include "ATCutils.hxx"
 
 
 FGCommList *current_commlist;
@@ -86,13 +88,13 @@ bool FGCommList::LoadComms(SGPath path) {
         ATCData a;
                fin >> a;
                if(a.type == INVALID) {
-                       cout << "WARNING - INVALID type found in " << path.str() << '\n';
+                       SG_LOG(SG_GENERAL, SG_ALERT, "WARNING - INVALID type found in " << path.str() << '\n');
                } else {                
                        // Push all stations onto frequency map
                        commlist_freq[a.freq].push_back(a);
                        
-                       // Push approach stations onto bucket map as well
-                       if(a.type == APPROACH) {
+                       // Push non-atis stations onto bucket map as well
+                       if(a.type != ATIS) {
                                // get bucket number
                                SGBucket bucket(a.lon, a.lat);
                                int bucknum = bucket.gen_index();
@@ -154,7 +156,6 @@ 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)
 {
        // number of relevant stations found within range
@@ -202,6 +203,30 @@ int FGCommList::FindByPos(double lon, double lat, double elev, comm_list_type* s
 }
 
 
+// Find by Airport code.
+// This is basically a wrapper for a call to the airport database to get the airport
+// position followed by a call to FindByPos(...)
+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);
+               if(found) {
+                       comm_list_iterator itr = stations.begin();
+                       while(itr != stations.end()) {
+                               if(((*itr).ident == ICAO) && ((*itr).type == tp)) {
+                                       ad = *itr;
+                                       return true;
+                               }
+                       }
+               }
+    } else {
+        return false;
+    }
+       return false;
+}
+
+
 // TODO - this function should move somewhere else eventually!
 // Return an appropriate call-sign for an ATIS transmission.
 int FGCommList::GetCallSign( string apt_id, int hours, int mins )
index 482ad6adf5051f19f38b004b4546d1cf0b346e4d..033b90afa7a7e6ff50b10ee41e1f31bdc84a7a38 100644 (file)
@@ -70,9 +70,10 @@ public:
     bool init( SGPath path );
 
     // query the database for the specified frequency, lon and lat are
-    // in degrees, elev is in meters
-       // If no atc_type is specified, it returns true if any non-invalid type is found
-       // If atc_type is specifed, returns true only if the specified type is found
+    // in degrees, elev is in meters.
+       // If no atc_type is specified, it returns true if any non-invalid type is found.
+       // If atc_type is specifed, returns true only if the specified type is found.
+       // Returns the station closest to the supplied position.
        // The data found is written into the passed-in ATCData structure.
     bool FindByFreq( double lon, double lat, double elev, double freq, ATCData* ad, atc_type tp = INVALID );
        
@@ -82,6 +83,9 @@ public:
        // If 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 );
+       
+       // 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
        // This maybe should get moved somewhere else!!