]> git.mxchange.org Git - flightgear.git/blobdiff - src/Navaids/navlist.cxx
Vivian Meazza:
[flightgear.git] / src / Navaids / navlist.cxx
index 691431889f1b8e59570bb7f8fe24ea111f3f694a..84c3b430c763b9f9bf7e0fd1d0d571ff4bcd79e9 100644 (file)
@@ -2,7 +2,7 @@
 //
 // Written by Curtis Olson, started April 2000.
 //
-// Copyright (C) 2000  Curtis L. Olson - curt@flightgear.org
+// Copyright (C) 2000  Curtis L. Olson - http://www.flightgear.org/~curt
 //
 // This program is free software; you can redistribute it and/or
 // modify it under the terms of the GNU General Public License as
 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,6 +137,11 @@ 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
@@ -137,6 +151,7 @@ FGNavRecord *FGNavList::findByFreq( double freq, double lon, double lat, double
 {
     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 +172,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 +182,7 @@ FGNavRecord *FGNavList::findByIdentAndFreq( const char* ident, const double freq
                 return stations[i];
             }
         }
-    } else {
+    } else if (stations.size()) {
         return stations[0];
     }
 
@@ -241,7 +256,8 @@ FGNavRecord *FGNavList::findNavFromList( const Point3D &aircraft,
             // (squared) which is further than matching stations would
             // ever be placed from each other.
             if ( fabs(az1) > 90.0 ) {
-                d2 += 5000*5000;
+                double dist = sqrt(d2);
+                d2 = (dist + 5000) * (dist + 5000);
             }
         }
 
@@ -320,3 +336,28 @@ FGNavRecord *FGNavList::findClosest( double lon_rad, double lat_rad,
 
     return result;
 }
+
+// Given a TACAN Channel return the first matching frequency
+FGTACANRecord *FGTACANList::findByChannel( 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;
+}