+FGNav *FGNavList::findByIdent( const char* ident,
+ const double lon, const double lat )
+{
+ nav_list_type stations = ident_navaids[ident];
+ Point3D aircraft = sgGeodToCart( Point3D(lon, lat, 0.0) );
+
+ return findNavFromList( aircraft, stations );
+}
+
+
+// Given an Ident and optional freqency, return the first matching
+// station.
+FGNav *FGNavList::findByIdentAndFreq( const char* ident, const double freq )
+{
+ nav_list_type stations = ident_navaids[ident];
+
+ if ( freq > 0.0 ) {
+ // sometimes there can be duplicated idents. If a freq is
+ // specified, use it to refine the search.
+ int f = (int)(freq*100.0 + 0.5);
+ for ( unsigned int i = 0; i < stations.size(); ++i ) {
+ if ( f == stations[i]->get_freq() ) {
+ return stations[i];
+ }
+ }
+ } else {
+ return stations[0];
+ }
+
+ return NULL;
+}
+
+
+// Given a point and a list of stations, return the closest one to the
+// specified point.
+FGNav *FGNavList::findNavFromList( const Point3D &aircraft,
+ const nav_list_type &stations )
+{
+ FGNav *nav = NULL;