- FGNavList::TypeFilter filter(type);
- const nav_list_type navlist = FGNavList::findByIdentAndFreq( id.c_str(), freq, &filter );
-
- if (navlist.size() == 0 ) {
- SG_LOG( SG_GENERAL, SG_ALERT, "Failed to locate NAV = "
- << id << ":" << freq );
- return false;
- }
-
- if( navlist.size() > 1 ) {
- std::ostringstream buf;
- buf << "Ambigous NAV-ID: '" << id << "'. Specify id and frequency. Available stations:" << endl;
- for( nav_list_type::const_iterator it = navlist.begin(); it != navlist.end(); ++it ) {
- // NDB stored in kHz, VOR stored in MHz * 100 :-P
- double factor = (*it)->type() == FGPositioned::NDB ? 1.0 : 1/100.0;
- string unit = (*it)->type() == FGPositioned::NDB ? "kHz" : "MHz";
- buf << (*it)->ident() << " "
- << std::setprecision(5) << (double)((*it)->get_freq() * factor) << " "
- << (*it)->get_lat() << "/" << (*it)->get_lon()
- << endl;
+ FGNavRecord* nav = 0;
+
+
+ if (guid != 0) {
+ nav = FGPositioned::loadById<FGNavRecord>(guid);
+ if (!nav)
+ return false;
+ } else {
+ FGNavList::TypeFilter filter(type);
+ const nav_list_type navlist = FGNavList::findByIdentAndFreq( id.c_str(), freq, &filter );
+
+ if (navlist.empty()) {
+ SG_LOG( SG_GENERAL, SG_ALERT, "Failed to locate NAV = "
+ << id << ":" << freq );
+ return false;
+ }
+
+ if( navlist.size() > 1 ) {
+ std::ostringstream buf;
+ buf << "Ambigous NAV-ID: '" << id << "'. Specify id and frequency. Available stations:" << endl;
+ for( nav_list_type::const_iterator it = navlist.begin(); it != navlist.end(); ++it ) {
+ // NDB stored in kHz, VOR stored in MHz * 100 :-P
+ double factor = (*it)->type() == FGPositioned::NDB ? 1.0 : 1/100.0;
+ string unit = (*it)->type() == FGPositioned::NDB ? "kHz" : "MHz";
+ buf << (*it)->ident() << " "
+ << std::setprecision(5) << (double)((*it)->get_freq() * factor) << " "
+ << (*it)->get_lat() << "/" << (*it)->get_lon()
+ << endl;
+ }
+
+ SG_LOG( SG_GENERAL, SG_ALERT, buf.str() );
+ return false;
+ }
+
+ // nav list must be of length 1
+ nav = navlist[0];