#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;
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();
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
}
+// 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 )
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 );
// 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!!