-bool FGAIFlightPlan::loadSID(const string& filename)
-{
- SGPropertyNode root;
- try {
- readProperties(filename, &root);
- } catch (const sg_exception &e) {
- SG_LOG(SG_GENERAL, SG_ALERT,
- "Error reading AI flight plan: " << filename);
- // cout << path.str() << endl;
- return false;
- }
-
- SGPropertyNode * node = root.getNode("flightplan");
- for (int i = 0; i < node->nChildren(); i++) {
- //cout << "Reading waypoint " << i << endl;
- waypoint* wpt = new waypoint;
- SGPropertyNode * wpt_node = node->getChild(i);
- wpt->name = wpt_node->getStringValue("name", "END");
- wpt->latitude = wpt_node->getDoubleValue("lat", 0);
- wpt->longitude = wpt_node->getDoubleValue("lon", 0);
- wpt->altitude = wpt_node->getDoubleValue("alt", 0);
- wpt->speed = wpt_node->getDoubleValue("ktas", 0);
- wpt->crossat = wpt_node->getDoubleValue("crossat", -10000);
- wpt->gear_down = wpt_node->getBoolValue("gear-down", false);
- wpt->flaps_down= wpt_node->getBoolValue("flaps-down", false);
- wpt->on_ground = wpt_node->getBoolValue("on-ground", false);
- wpt->time_sec = wpt_node->getDoubleValue("time-sec", 0);
- wpt->time = wpt_node->getStringValue("time", "");
-
- if (wpt->name == "END") wpt->finished = true;
- else wpt->finished = false;
-
- waypoints.push_back( wpt );
- }
-
- //wpt_iterator = waypoints.begin();
- //cout << waypoints.size() << " waypoints read." << endl;
- return true;
-}
-
-// NOTE: This is just copied from Airports/readXML.
-string FGAIFlightPlan::expandICAODirs(const string in){
- //cerr << "Expanding " << in << endl;
- if (in.size() == 4) {
- char buffer[11];
- snprintf(buffer, 11, "%c/%c/%c", in[0], in[1], in[2]);
- //cerr << "result: " << buffer << endl;
- return string(buffer);
- } else {
- return in;
- }
- //exit(1);
-}