]> git.mxchange.org Git - flightgear.git/blobdiff - src/Navaids/navlist.cxx
don't destroy iterated map entries; delete _menubar; restore closed
[flightgear.git] / src / Navaids / navlist.cxx
index 7f8cb72bbb6860e54551bad347bdb38951048803..4b058e7252a39270da97d73a3587debec4756b35 100644 (file)
 FGNavList::FGNavList( void ) {
 }
 
+FGTACANList::FGTACANList( void ){
+}
+
 
 // Destructor
 FGNavList::~FGNavList( void ) {
 }
 
+FGTACANList::~FGTACANList( void ){
+}
 
 // load the navaids and build the map
 bool FGNavList::init() {
@@ -53,6 +58,10 @@ bool FGNavList::init() {
     return true;
 }
 
+bool FGTACANList::init() {
+    
+    return true;      
+}
 
 // real add a marker beacon
 static void real_add( nav_map_type &navmap, const int master_index,
@@ -128,15 +137,17 @@ bool FGNavList::add( FGNavRecord *n ) {
     return true;
 }
 
+// add an entry to the lists
+bool FGTACANList::add( FGTACANRecord *c ) {
+    ident_channels[c->get_channel()].push_back(c);
+    return true;
+}
 
-// Query the database for the specified frequency.  It is assumed that
-// there will be multiple stations with matching frequencies so a
-// position must be specified.  Lon and lat are in degrees, elev is in
-// meters.
 FGNavRecord *FGNavList::findByFreq( double freq, double lon, double lat, double elev )
 {
     nav_list_type stations = navaids[(int)(freq*100.0 + 0.5)];
     Point3D aircraft = sgGeodToCart( Point3D(lon, lat, elev) );
+    SG_LOG( SG_INSTR, SG_DEBUG, "findbyFreq " << freq << " size " << stations.size()  );
 
     return findNavFromList( aircraft, stations );
 }
@@ -157,7 +168,7 @@ FGNavRecord *FGNavList::findByIdent( const char* ident,
 FGNavRecord *FGNavList::findByIdentAndFreq( const char* ident, const double freq )
 {
     nav_list_type stations = ident_navaids[ident];
-
+    SG_LOG( SG_INSTR, SG_DEBUG, "findByIdent " << ident<< " size " << stations.size()  );
     if ( freq > 0.0 ) {
         // sometimes there can be duplicated idents.  If a freq is
         // specified, use it to refine the search.
@@ -167,7 +178,7 @@ FGNavRecord *FGNavList::findByIdentAndFreq( const char* ident, const double freq
                 return stations[i];
             }
         }
-    } else {
+    } else if (stations.size()) {
         return stations[0];
     }
 
@@ -285,8 +296,8 @@ FGNavRecord *FGNavList::findClosest( double lon_rad, double lat_rad,
     // cout << "Master index = " << master_index << endl;
     // cout << "beacon search length = " << beacons.size() << endl;
 
-    nav_list_iterator current = navs.begin();
-    nav_list_iterator last = navs.end();
+    nav_list_const_iterator current = navs.begin();
+    nav_list_const_iterator last = navs.end();
 
     Point3D aircraft = sgGeodToCart( Point3D(lon_rad,
                                              lat_rad,
@@ -321,3 +332,28 @@ FGNavRecord *FGNavList::findClosest( double lon_rad, double lat_rad,
 
     return result;
 }
+
+// Given a TACAN Channel return the first matching frequency
+FGTACANRecord *FGTACANList::findByChannel( const string& channel )
+{
+    tacan_list_type stations = ident_channels[channel];
+    SG_LOG( SG_INSTR, SG_DEBUG, "findByChannel " << channel<< " size " << stations.size()  );
+    
+    if (stations.size()) {
+        return stations[0];
+    }    
+    return NULL;
+}
+
+// Given a frequency, return the first matching station.
+FGNavRecord *FGNavList::findStationByFreq( double freq )
+{
+    nav_list_type stations = navaids[(int)(freq*100.0 + 0.5)];
+   
+    SG_LOG( SG_INSTR, SG_DEBUG, "findStationByFreq " << freq << " size " << stations.size()  );
+    
+    if (stations.size()) {
+        return stations[0];
+    }    
+    return NULL;
+}