string acfile = fgGetString("/sim/aircraft") + string(".xml");
acData.append(acfile);
SGPropertyNode root;
- readProperties(acData.str(), &root);
+ readProperties(acData, &root);
SGPropertyNode * node = root.getNode("sim");
fltType = node->getStringValue("aircraft-class", "NONE" );
acOperator = node->getStringValue("aircraft-operator", "NONE" );
} catch (const sg_exception &) {
SG_LOG(SG_GENERAL, SG_INFO,
- "Could not load aircraft aircrat type and operator information from: " << acData.str() << ". Using defaults");
+ "Could not load aircraft aircrat type and operator information from: " << acData << ". Using defaults");
// cout << path.str() << endl;
}
if (fltType.empty() || fltType == "NONE") {
SG_LOG(SG_GENERAL, SG_INFO,
- "Aircraft type information not found in: " << acData.str() << ". Using default value");
+ "Aircraft type information not found in: " << acData << ". Using default value");
fltType = fgGetString("/sim/aircraft-class" );
}
if (acOperator.empty() || fltType == "NONE") {
SG_LOG(SG_GENERAL, SG_INFO,
- "Aircraft operator information not found in: " << acData.str() << ". Using default value");
+ "Aircraft operator information not found in: " << acData << ". Using default value");
acOperator = fgGetString("/sim/aircraft-operator" );
}
}
if ( !set_pos ) {
- // No lon/lat specified, no airport specified, default to
- // middle of KSFO field.
- fgSetDouble("/sim/presets/longitude-deg", -122.374843);
- fgSetDouble("/sim/presets/latitude-deg", 37.619002);
+ // No lon/lat specified, no airport specified, use the default airport
+ // TODO: don't hardcode this
+ const FGAirport* airport = fgFindAirportID("LEBL");
+ if( airport ) {
+ const SGGeod & airportGeod = airport->geod();
+ fgSetDouble("/sim/presets/longitude-deg", airportGeod.getLongitudeDeg());
+ fgSetDouble("/sim/presets/latitude-deg", airportGeod.getLatitudeDeg());
+ } else {
+ // So, the default airport is unknown? We are in serious trouble.
+ // Let's hope KSFO still exists somehow
+ fgSetDouble("/sim/presets/longitude-deg", -122.374843);
+ fgSetDouble("/sim/presets/latitude-deg", 37.619002);
+ SG_LOG(SG_GENERAL, SG_ALERT, "Sorry, the default airport seems to be unknown.");
+ }
}
fgSetDouble( "/position/longitude-deg",