1 // route_mgr.cxx - manage a route (i.e. a collection of waypoints)
3 // Written by Curtis Olson, started January 2004.
7 // Copyright (C) 2004 Curtis L. Olson - http://www.flightgear.org/~curt
9 // This program is free software; you can redistribute it and/or
10 // modify it under the terms of the GNU General Public License as
11 // published by the Free Software Foundation; either version 2 of the
12 // License, or (at your option) any later version.
14 // This program is distributed in the hope that it will be useful, but
15 // WITHOUT ANY WARRANTY; without even the implied warranty of
16 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 // General Public License for more details.
19 // You should have received a copy of the GNU General Public License
20 // along with this program; if not, write to the Free Software
21 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
34 #include <simgear/compiler.h>
36 #include "route_mgr.hxx"
38 #include <boost/algorithm/string/case_conv.hpp>
40 #include <simgear/misc/strutils.hxx>
41 #include <simgear/structure/exception.hxx>
43 #include <simgear/props/props_io.hxx>
44 #include <simgear/misc/sg_path.hxx>
45 #include <simgear/route/route.hxx>
46 #include <simgear/sg_inlines.h>
48 #include "Main/fg_props.hxx"
49 #include "Navaids/positioned.hxx"
50 #include "Airports/simple.hxx"
51 #include "Airports/runways.hxx"
53 #include "FDM/flight.hxx" // for getting ground speed
55 #define RM "/autopilot/route-manager/"
57 static double get_ground_speed() {
58 // starts in ft/s so we convert to kts
59 static const SGPropertyNode * speedup_node = fgGetNode("/sim/speed-up");
61 double ft_s = cur_fdm_state->get_V_ground_speed()
62 * speedup_node->getIntValue();
63 double kts = ft_s * SG_FEET_TO_METER * 3600 * SG_METER_TO_NM;
67 FGRouteMgr::FGRouteMgr() :
68 _route( new SGRoute ),
69 input(fgGetNode( RM "input", true )),
70 mirror(fgGetNode( RM "route", true ))
72 listener = new InputListener(this);
73 input->setStringValue("");
74 input->addChangeListener(listener);
78 FGRouteMgr::~FGRouteMgr() {
79 input->removeChangeListener(listener);
86 void FGRouteMgr::init() {
87 SGPropertyNode_ptr rm(fgGetNode(RM));
89 lon = fgGetNode( "/position/longitude-deg", true );
90 lat = fgGetNode( "/position/latitude-deg", true );
91 alt = fgGetNode( "/position/altitude-ft", true );
92 magvar = fgGetNode("/environment/magnetic-variation-deg", true);
94 departure = fgGetNode(RM "departure", true);
95 departure->tie("airport", SGRawValueMethods<FGRouteMgr, const char*>(*this,
96 &FGRouteMgr::getDepartureICAO, &FGRouteMgr::setDepartureICAO));
97 departure->tie("name", SGRawValueMethods<FGRouteMgr, const char*>(*this,
98 &FGRouteMgr::getDepartureName, NULL));
100 // init departure information from current location
101 SGGeod pos = SGGeod::fromDegFt(lon->getDoubleValue(), lat->getDoubleValue(), alt->getDoubleValue());
102 _departure = FGAirport::findClosest(pos, 20.0);
104 FGRunway* active = _departure->getActiveRunwayForUsage();
105 departure->setStringValue("runway", active->ident().c_str());
107 departure->setStringValue("runway", "");
110 departure->getChild("etd", 0, true);
111 departure->getChild("takeoff-time", 0, true);
113 destination = fgGetNode(RM "destination", true);
114 destination->getChild("airport", 0, true);
116 destination->tie("airport", SGRawValueMethods<FGRouteMgr, const char*>(*this,
117 &FGRouteMgr::getDestinationICAO, &FGRouteMgr::setDestinationICAO));
118 destination->tie("name", SGRawValueMethods<FGRouteMgr, const char*>(*this,
119 &FGRouteMgr::getDestinationName, NULL));
121 destination->getChild("runway", 0, true);
122 destination->getChild("eta", 0, true);
123 destination->getChild("touchdown-time", 0, true);
125 alternate = fgGetNode(RM "alternate", true);
126 alternate->getChild("airport", 0, true);
127 alternate->getChild("runway", 0, true);
129 cruise = fgGetNode(RM "cruise", true);
130 cruise->getChild("altitude-ft", 0, true);
131 cruise->setDoubleValue("altitude-ft", 10000.0);
132 cruise->getChild("flight-level", 0, true);
133 cruise->getChild("speed-kts", 0, true);
134 cruise->setDoubleValue("speed-kts", 160.0);
136 totalDistance = fgGetNode(RM "total-distance", true);
137 totalDistance->setDoubleValue(0.0);
139 ete = fgGetNode(RM "ete", true);
140 ete->setDoubleValue(0.0);
142 elapsedFlightTime = fgGetNode(RM "flight-time", true);
143 elapsedFlightTime->setDoubleValue(0.0);
145 active = fgGetNode(RM "active", true);
146 active->setBoolValue(false);
148 airborne = fgGetNode(RM "airborne", true);
149 airborne->setBoolValue(false);
151 _edited = fgGetNode(RM "signals/edited", true);
152 _finished = fgGetNode(RM "signals/finished", true);
154 _currentWpt = fgGetNode(RM "current-wp", true);
155 _currentWpt->tie(SGRawValueMethods<FGRouteMgr, int>
156 (*this, &FGRouteMgr::currentWaypoint, &FGRouteMgr::jumpToIndex));
158 // temporary distance / eta calculations, for backward-compatability
159 wp0 = fgGetNode(RM "wp", 0, true);
160 wp0->getChild("id", 0, true);
161 wp0->getChild("dist", 0, true);
162 wp0->getChild("eta", 0, true);
163 wp0->getChild("bearing-deg", 0, true);
165 wp1 = fgGetNode(RM "wp", 1, true);
166 wp1->getChild("id", 0, true);
167 wp1->getChild("dist", 0, true);
168 wp1->getChild("eta", 0, true);
170 wpn = fgGetNode(RM "wp-last", 0, true);
171 wpn->getChild("dist", 0, true);
172 wpn->getChild("eta", 0, true);
177 _pathNode = fgGetNode(RM "file-path", 0, true);
181 void FGRouteMgr::postinit() {
182 string_list *waypoints = globals->get_initial_waypoints();
184 vector<string>::iterator it;
185 for (it = waypoints->begin(); it != waypoints->end(); ++it)
189 weightOnWheels = fgGetNode("/gear/gear[0]/wow", false);
190 // check airbone flag agrees with presets
195 void FGRouteMgr::bind() { }
196 void FGRouteMgr::unbind() { }
198 bool FGRouteMgr::isRouteActive() const
200 return active->getBoolValue();
203 void FGRouteMgr::update( double dt ) {
205 // paused, nothing to do here
209 if (!active->getBoolValue()) {
213 double groundSpeed = get_ground_speed();
214 if (airborne->getBoolValue()) {
215 time_t now = time(NULL);
216 elapsedFlightTime->setDoubleValue(difftime(now, _takeoffTime));
217 } else { // not airborne
218 if (weightOnWheels->getBoolValue() || (groundSpeed < 40)) {
222 airborne->setBoolValue(true);
223 _takeoffTime = time(NULL); // start the clock
224 departure->setIntValue("takeoff-time", _takeoffTime);
227 // basic course/distance information
228 double wp_course, wp_distance;
229 SGWayPoint wp = _route->get_current();
230 wp.CourseAndDistance( lon->getDoubleValue(), lat->getDoubleValue(),
231 alt->getDoubleValue(), &wp_course, &wp_distance );
233 // update wp0 / wp1 / wp-last for legacy users
234 wp0->setDoubleValue("dist", wp_distance * SG_METER_TO_NM);
235 wp_course -= magvar->getDoubleValue(); // expose magnetic bearing
236 wp0->setDoubleValue("bearing-deg", wp_course);
237 setETAPropertyFromDistance(wp0->getChild("eta"), wp_distance);
239 if ((_route->current_index() + 1) < _route->size()) {
240 wp = _route->get_waypoint(_route->current_index() + 1);
241 double wp1_course, wp1_distance;
242 wp.CourseAndDistance(lon->getDoubleValue(), lat->getDoubleValue(),
243 alt->getDoubleValue(), &wp1_course, &wp1_distance);
245 wp1->setDoubleValue("dist", wp1_distance * SG_METER_TO_NM);
246 setETAPropertyFromDistance(wp1->getChild("eta"), wp1_distance);
249 double totalDistanceRemaining = wp_distance; // distance to current waypoint
250 for (int i=_route->current_index() + 1; i<_route->size(); ++i) {
251 totalDistanceRemaining += _route->get_waypoint(i).get_distance();
254 wpn->setDoubleValue("dist", totalDistanceRemaining * SG_METER_TO_NM);
255 ete->setDoubleValue(totalDistanceRemaining * SG_METER_TO_NM / groundSpeed * 3600.0);
256 setETAPropertyFromDistance(wpn->getChild("eta"), totalDistanceRemaining);
258 // get time now at destination tz as tm struct
260 // convert to string ... and stash in property
261 //destination->setDoubleValue("eta", eta);
265 void FGRouteMgr::setETAPropertyFromDistance(SGPropertyNode_ptr aProp, double aDistance) {
266 double speed = get_ground_speed();
268 aProp->setStringValue("--:--");
273 double eta = aDistance * SG_METER_TO_NM / get_ground_speed();
274 if ( eta >= 100.0 ) {
275 eta = 99.999; // clamp
278 if ( eta < (1.0/6.0) ) {
279 eta *= 60.0; // within 10 minutes, bump up to min/secs
282 int major = (int)eta,
283 minor = (int)((eta - (int)eta) * 60.0);
284 snprintf( eta_str, 64, "%d:%02d", major, minor );
285 aProp->setStringValue( eta_str );
288 void FGRouteMgr::add_waypoint( const SGWayPoint& wp, int n ) {
289 _route->add_waypoint( wp, n );
291 if (_route->current_index() > n) {
292 _route->set_current(_route->current_index() + 1);
296 _edited->fireValueChanged();
300 SGWayPoint FGRouteMgr::pop_waypoint( int n ) {
301 if ( _route->size() <= 0 ) {
306 n = _route->size() - 1;
309 if (_route->current_index() > n) {
310 _route->set_current(_route->current_index() - 1);
313 SGWayPoint wp = _route->get_waypoint(n);
314 _route->delete_waypoint(n);
317 _edited->fireValueChanged();
324 bool FGRouteMgr::build() {
329 void FGRouteMgr::new_waypoint( const string& target, int n ) {
330 SGWayPoint* wp = make_waypoint( target );
335 add_waypoint( *wp, n );
340 SGWayPoint* FGRouteMgr::make_waypoint(const string& tgt ) {
341 string target(boost::to_upper_copy(tgt));
344 double alt = -9999.0;
346 size_t pos = target.find( '@' );
347 if ( pos != string::npos ) {
348 alt = atof( target.c_str() + pos + 1 );
349 target = target.substr( 0, pos );
350 if ( !strcmp(fgGetString("/sim/startup/units"), "feet") )
351 alt *= SG_FEET_TO_METER;
355 pos = target.find( ',' );
356 if ( pos != string::npos ) {
357 double lon = atof( target.substr(0, pos).c_str());
358 double lat = atof( target.c_str() + pos + 1);
360 char ew = (lon < 0.0) ? 'W' : 'E';
361 char ns = (lat < 0.0) ? 'S' : 'N';
362 snprintf(buf, 32, "%c%03d%c%03d", ew, (int) fabs(lon), ns, (int)fabs(lat));
363 return new SGWayPoint( lon, lat, alt, SGWayPoint::WGS84, buf);
367 if (_route->size() > 0) {
368 SGWayPoint wp = get_waypoint(_route->size()-1);
369 basePosition = wp.get_target();
371 // route is empty, use current position
372 basePosition = SGGeod::fromDeg(
373 fgGetNode("/position/longitude-deg")->getDoubleValue(),
374 fgGetNode("/position/latitude-deg")->getDoubleValue());
377 vector<string> pieces(simgear::strutils::split(target, "/"));
380 FGPositionedRef p = FGPositioned::findClosestWithIdent(pieces.front(), basePosition);
382 SG_LOG( SG_AUTOPILOT, SG_INFO, "Unable to find FGPositioned with ident:" << pieces.front());
386 SGGeod geod = SGGeod::fromGeodM(p->geod(), alt);
387 if (pieces.size() == 1) {
389 return new SGWayPoint(geod, target, p->name());
392 if (pieces.size() == 3) {
393 // navaid/radial/distance-nm notation
394 double radial = atof(pieces[1].c_str()),
395 distanceNm = atof(pieces[2].c_str()),
397 radial += magvar->getDoubleValue(); // convert to true bearing
399 SGGeodesy::direct(geod, radial, distanceNm * SG_NM_TO_METER, offsetPos, az2);
400 offsetPos.setElevationM(alt);
402 SG_LOG(SG_AUTOPILOT, SG_INFO, "final offset radial is " << radial);
403 return new SGWayPoint(offsetPos, p->ident() + pieces[2], target);
406 if (pieces.size() == 2) {
407 FGAirport* apt = dynamic_cast<FGAirport*>(p.ptr());
409 SG_LOG(SG_AUTOPILOT, SG_INFO, "Waypoint is not an airport:" << pieces.front());
413 if (!apt->hasRunwayWithIdent(pieces[1])) {
414 SG_LOG(SG_AUTOPILOT, SG_INFO, "No runway: " << pieces[1] << " at " << pieces[0]);
418 FGRunway* runway = apt->getRunwayByIdent(pieces[1]);
419 SGGeod t = runway->threshold();
420 return new SGWayPoint(t.getLongitudeDeg(), t.getLatitudeDeg(), alt, SGWayPoint::WGS84, pieces[1]);
423 SG_LOG(SG_AUTOPILOT, SG_INFO, "Unable to parse waypoint:" << target);
428 // mirror internal route to the property system for inspection by other subsystems
429 void FGRouteMgr::update_mirror() {
430 mirror->removeChildren("wp");
431 for (int i = 0; i < _route->size(); i++) {
432 SGWayPoint wp = _route->get_waypoint(i);
433 SGPropertyNode *prop = mirror->getChild("wp", i, 1);
435 const SGGeod& pos(wp.get_target());
436 prop->setStringValue("id", wp.get_id().c_str());
437 prop->setStringValue("name", wp.get_name().c_str());
438 prop->setDoubleValue("longitude-deg", pos.getLongitudeDeg());
439 prop->setDoubleValue("latitude-deg",pos.getLatitudeDeg());
440 prop->setDoubleValue("altitude-m", pos.getElevationM());
441 prop->setDoubleValue("altitude-ft", pos.getElevationFt());
443 // set number as listener attachment point
444 mirror->setIntValue("num", _route->size());
447 // command interface /autopilot/route-manager/input:
449 // @CLEAR ... clear route
450 // @POP ... remove first entry
451 // @DELETE3 ... delete 4th entry
452 // @INSERT2:KSFO@900 ... insert "KSFO@900" as 3rd entry
453 // KSFO@900 ... append "KSFO@900"
455 void FGRouteMgr::InputListener::valueChanged(SGPropertyNode *prop)
457 const char *s = prop->getStringValue();
458 if (strlen(s) == 0) {
462 if (!strcmp(s, "@CLEAR"))
464 else if (!strcmp(s, "@ACTIVATE"))
466 else if (!strcmp(s, "@LOAD")) {
468 } else if (!strcmp(s, "@SAVE")) {
470 } else if (!strcmp(s, "@POP"))
471 mgr->pop_waypoint(0);
472 else if (!strncmp(s, "@DELETE", 7))
473 mgr->pop_waypoint(atoi(s + 7));
474 else if (!strncmp(s, "@INSERT", 7)) {
476 int pos = strtol(s + 7, &r, 10);
482 mgr->new_waypoint(r, pos);
484 mgr->new_waypoint(s);
487 // SGWayPoint( const double lon = 0.0, const double lat = 0.0,
488 // const double alt = 0.0, const modetype m = WGS84,
489 // const string& s = "", const string& n = "" );
491 bool FGRouteMgr::activate()
493 if (isRouteActive()) {
494 SG_LOG(SG_AUTOPILOT, SG_WARN, "duplicate route-activation, no-op");
498 // only add departure waypoint if we're not airborne, so that
499 // in-air route activation doesn't confuse matters.
500 if (weightOnWheels->getBoolValue() && _departure) {
501 string runwayId(departure->getStringValue("runway"));
502 FGRunway* runway = NULL;
503 if (_departure->hasRunwayWithIdent(runwayId)) {
504 runway = _departure->getRunwayByIdent(runwayId);
506 SG_LOG(SG_AUTOPILOT, SG_INFO,
507 "route-manager, departure runway not found:" << runwayId);
508 runway = _departure->getActiveRunwayForUsage();
511 SGWayPoint swp(runway->threshold(),
512 _departure->ident() + "-" + runway->ident(), runway->name());
513 add_waypoint(swp, 0);
517 string runwayId = (destination->getStringValue("runway"));
518 if (_destination->hasRunwayWithIdent(runwayId)) {
519 FGRunway* runway = _destination->getRunwayByIdent(runwayId);
520 SGWayPoint swp(runway->end(),
521 _destination->ident() + "-" + runway->ident(), runway->name());
524 // quite likely, since destination runway may not be known until enroute
525 // probably want a listener on the 'destination' node to allow an enroute
527 add_waypoint(SGWayPoint(_destination->geod(), _destination->ident(), _destination->name()));
531 _route->set_current(0);
533 double routeDistanceNm = _route->total_distance() * SG_METER_TO_NM;
534 totalDistance->setDoubleValue(routeDistanceNm);
535 double cruiseSpeedKts = cruise->getDoubleValue("speed", 0.0);
536 if (cruiseSpeedKts > 1.0) {
537 // very very crude approximation, doesn't allow for climb / descent
538 // performance or anything else at all
539 ete->setDoubleValue(routeDistanceNm / cruiseSpeedKts * (60.0 * 60.0));
542 active->setBoolValue(true);
543 SG_LOG(SG_AUTOPILOT, SG_INFO, "route-manager, activate route ok");
548 void FGRouteMgr::sequence()
550 if (!active->getBoolValue()) {
551 SG_LOG(SG_AUTOPILOT, SG_ALERT, "trying to sequence waypoints with no active route");
555 if (checkFinished()) {
559 _route->increment_current();
560 currentWaypointChanged();
561 _currentWpt->fireValueChanged();
564 bool FGRouteMgr::checkFinished()
566 int lastWayptIndex = _route->size() - 1;
567 if (_route->current_index() < lastWayptIndex) {
571 SG_LOG(SG_AUTOPILOT, SG_INFO, "reached end of active route");
572 _finished->fireValueChanged();
573 active->setBoolValue(false);
577 void FGRouteMgr::jumpToIndex(int index)
579 if (!active->getBoolValue()) {
580 SG_LOG(SG_AUTOPILOT, SG_ALERT, "trying to sequence waypoints with no active route");
584 if ((index < 0) || (index >= _route->size())) {
585 SG_LOG(SG_AUTOPILOT, SG_ALERT, "passed invalid index (" <<
586 index << ") to FGRouteMgr::jumpToIndex");
590 if (_route->current_index() == index) {
594 _route->set_current(index);
595 currentWaypointChanged();
598 void FGRouteMgr::currentWaypointChanged()
600 SGWayPoint previous = _route->get_previous();
601 SGWayPoint cur = _route->get_current();
603 wp0->getChild("id")->setStringValue(cur.get_id());
604 if ((_route->current_index() + 1) < _route->size()) {
605 wp1->getChild("id")->setStringValue(_route->get_next().get_id());
607 wp1->getChild("id")->setStringValue("");
610 SG_LOG(SG_AUTOPILOT, SG_INFO, "route manager, current-wp is now " << _route->current_index());
613 int FGRouteMgr::findWaypoint(const SGGeod& aPos) const
615 for (int i=0; i<_route->size(); ++i) {
616 double d = SGGeodesy::distanceM(aPos, _route->get_waypoint(i).get_target());
617 if (d < 200.0) { // 200 metres seems close enough
625 SGWayPoint FGRouteMgr::get_waypoint( int i ) const
627 return _route->get_waypoint(i);
630 int FGRouteMgr::size() const
632 return _route->size();
635 int FGRouteMgr::currentWaypoint() const
637 return _route->current_index();
640 void FGRouteMgr::saveRoute()
642 SGPath path(_pathNode->getStringValue());
643 SG_LOG(SG_IO, SG_INFO, "Saving route to " << path.str());
645 writeProperties(path.str(), mirror, false, SGPropertyNode::ARCHIVE);
646 } catch (const sg_exception &e) {
647 SG_LOG(SG_IO, SG_WARN, "Error saving route:" << e.getMessage());
648 //guiErrorMessage("Error writing autosave.xml: ", e);
652 void FGRouteMgr::loadRoute()
655 // deactivate route first
656 active->setBoolValue(false);
658 SGPropertyNode_ptr routeData(new SGPropertyNode);
659 SGPath path(_pathNode->getStringValue());
661 SG_LOG(SG_IO, SG_INFO, "going to read flight-plan from:" << path.str());
662 readProperties(path.str(), routeData);
665 SGPropertyNode* dep = routeData->getChild("departure");
667 throw sg_io_exception("malformed route file, no departure node");
670 string depIdent = dep->getStringValue("airport");
671 _departure = (FGAirport*) fgFindAirportID(depIdent);
675 SGPropertyNode* dst = routeData->getChild("destination");
677 throw sg_io_exception("malformed route file, no destination node");
680 _destination = (FGAirport*) fgFindAirportID(dst->getStringValue("airport"));
681 destination->setStringValue("runway", dst->getStringValue("runway"));
684 SGPropertyNode* alt = routeData->getChild("alternate");
686 alternate->setStringValue(alt->getStringValue("airport"));
687 } // of cruise data loading
690 SGPropertyNode* crs = routeData->getChild("cruise");
692 cruise->setDoubleValue(crs->getDoubleValue("speed"));
693 } // of cruise data loading
697 SGPropertyNode_ptr _route = routeData->getChild("route", 0);
698 SGGeod lastPos = (_departure ? _departure->geod() : SGGeod());
700 for (int i=0; i<_route->nChildren(); ++i) {
701 SGPropertyNode_ptr wp = _route->getChild("wp", i);
702 parseRouteWaypoint(wp);
703 } // of route iteration
704 } catch (sg_exception& e) {
705 SG_LOG(SG_IO, SG_WARN, "failed to load flight-plan (from '" << e.getOrigin()
706 << "'):" << e.getMessage());
710 void FGRouteMgr::parseRouteWaypoint(SGPropertyNode* aWP)
713 if (_route->size() > 0) {
714 lastPos = get_waypoint(_route->size()-1).get_target();
716 // route is empty, use departure airport position
717 const FGAirport* apt = fgFindAirportID(departure->getStringValue("airport"));
718 assert(apt); // shouldn't have got this far with an invalid airport
719 lastPos = apt->geod();
722 SGPropertyNode_ptr altProp = aWP->getChild("altitude-ft");
723 double altM = cruise->getDoubleValue("altitude-ft") * SG_FEET_TO_METER;
725 altM = altProp->getDoubleValue() * SG_FEET_TO_METER;
728 string ident(aWP->getStringValue("ident"));
729 if (aWP->hasChild("longitude-deg")) {
730 // explicit longitude/latitude
731 SGWayPoint swp(aWP->getDoubleValue("longitude-deg"),
732 aWP->getDoubleValue("latitude-deg"), altM,
733 SGWayPoint::WGS84, ident, aWP->getStringValue("name"));
735 } else if (aWP->hasChild("navid")) {
736 // lookup by navid (possibly with offset)
737 string nid(aWP->getStringValue("navid"));
738 FGPositionedRef p = FGPositioned::findClosestWithIdent(nid, lastPos);
740 throw sg_io_exception("bad route file, unknown navid:" + nid);
743 SGGeod pos(p->geod());
744 if (aWP->hasChild("offset-nm") && aWP->hasChild("offset-radial")) {
745 double radialDeg = aWP->getDoubleValue("offset-radial");
746 // convert magnetic radial to a true radial!
747 radialDeg += magvar->getDoubleValue();
748 double offsetNm = aWP->getDoubleValue("offset-nm");
750 SGGeodesy::direct(p->geod(), radialDeg, offsetNm * SG_NM_TO_METER, pos, az2);
753 SGWayPoint swp(pos.getLongitudeDeg(), pos.getLatitudeDeg(), altM,
754 SGWayPoint::WGS84, ident, "");
757 // lookup by ident (symbolic waypoint)
758 FGPositionedRef p = FGPositioned::findClosestWithIdent(ident, lastPos);
760 throw sg_io_exception("bad route file, unknown waypoint:" + ident);
763 SGWayPoint swp(p->longitude(), p->latitude(), altM,
764 SGWayPoint::WGS84, p->ident(), p->name());
769 const char* FGRouteMgr::getDepartureICAO() const
775 return _departure->ident().c_str();
778 const char* FGRouteMgr::getDepartureName() const
784 return _departure->name().c_str();
787 void FGRouteMgr::setDepartureICAO(const char* aIdent)
789 if ((aIdent == NULL) || (strlen(aIdent) < 4)) {
792 _departure = FGAirport::findByIdent(aIdent);
796 const char* FGRouteMgr::getDestinationICAO() const
802 return _destination->ident().c_str();
805 const char* FGRouteMgr::getDestinationName() const
811 return _destination->name().c_str();
814 void FGRouteMgr::setDestinationICAO(const char* aIdent)
816 if ((aIdent == NULL) || (strlen(aIdent) < 4)) {
819 _destination = FGAirport::findByIdent(aIdent);