Added FindByCode (airport ICAO code) to commlist. This is basically a wrapper around Flightgear's airport lookup and FindByPos
This commit is contained in:
parent
c70faa4c0d
commit
1154a0dae2
2 changed files with 36 additions and 7 deletions
|
@ -29,9 +29,11 @@
|
||||||
#include <simgear/math/sg_geodesy.hxx>
|
#include <simgear/math/sg_geodesy.hxx>
|
||||||
#include <simgear/math/sg_random.h>
|
#include <simgear/math/sg_random.h>
|
||||||
#include <simgear/bucket/newbucket.hxx>
|
#include <simgear/bucket/newbucket.hxx>
|
||||||
|
#include <Airports/simple.hxx>
|
||||||
|
|
||||||
#include "commlist.hxx"
|
#include "commlist.hxx"
|
||||||
//#include "atislist.hxx"
|
//#include "atislist.hxx"
|
||||||
|
#include "ATCutils.hxx"
|
||||||
|
|
||||||
|
|
||||||
FGCommList *current_commlist;
|
FGCommList *current_commlist;
|
||||||
|
@ -86,13 +88,13 @@ bool FGCommList::LoadComms(SGPath path) {
|
||||||
ATCData a;
|
ATCData a;
|
||||||
fin >> a;
|
fin >> a;
|
||||||
if(a.type == INVALID) {
|
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 {
|
} else {
|
||||||
// Push all stations onto frequency map
|
// Push all stations onto frequency map
|
||||||
commlist_freq[a.freq].push_back(a);
|
commlist_freq[a.freq].push_back(a);
|
||||||
|
|
||||||
// Push approach stations onto bucket map as well
|
// Push non-atis stations onto bucket map as well
|
||||||
if(a.type == APPROACH) {
|
if(a.type != ATIS) {
|
||||||
// get bucket number
|
// get bucket number
|
||||||
SGBucket bucket(a.lon, a.lat);
|
SGBucket bucket(a.lon, a.lat);
|
||||||
int bucknum = bucket.gen_index();
|
int bucknum = bucket.gen_index();
|
||||||
|
@ -154,7 +156,6 @@ bool FGCommList::FindByFreq( double lon, double lat, double elev, double freq,
|
||||||
return false;
|
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, comm_list_type* stations, atc_type tp)
|
||||||
{
|
{
|
||||||
// number of relevant stations found within range
|
// 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!
|
// TODO - this function should move somewhere else eventually!
|
||||||
// Return an appropriate call-sign for an ATIS transmission.
|
// Return an appropriate call-sign for an ATIS transmission.
|
||||||
int FGCommList::GetCallSign( string apt_id, int hours, int mins )
|
int FGCommList::GetCallSign( string apt_id, int hours, int mins )
|
||||||
|
|
|
@ -70,9 +70,10 @@ public:
|
||||||
bool init( SGPath path );
|
bool init( SGPath path );
|
||||||
|
|
||||||
// query the database for the specified frequency, lon and lat are
|
// query the database for the specified frequency, lon and lat are
|
||||||
// in degrees, elev is in meters
|
// in degrees, elev is in meters.
|
||||||
// If no atc_type is specified, it returns true if any non-invalid type is found
|
// 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
|
// 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.
|
// 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 );
|
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
|
// If atc_type is specifed, returns the number of all stations in range, and pushes them into stations
|
||||||
// ** stations is erased before use **
|
// ** 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, 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 airpord id
|
||||||
// This maybe should get moved somewhere else!!
|
// This maybe should get moved somewhere else!!
|
||||||
|
|
Loading…
Reference in a new issue