From f0bf3ed8416b629bb197e5cea8f32a1ff774468a Mon Sep 17 00:00:00 2001 From: James Turner Date: Tue, 27 Mar 2012 21:54:38 +0100 Subject: [PATCH] Fix total-distance computation in the route-manager, and expose some additional values - departure and arrival field elevation, and total distance along the route of a waypoint. (Addresses some feature requests) --- src/Autopilot/route_mgr.cxx | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/Autopilot/route_mgr.cxx b/src/Autopilot/route_mgr.cxx index 4abd9286f..160fa7bd0 100644 --- a/src/Autopilot/route_mgr.cxx +++ b/src/Autopilot/route_mgr.cxx @@ -992,6 +992,8 @@ void FGRouteMgr::update_mirror() mirror->removeChildren("wp"); int num = numWaypts(); + double totalDistanceEnroute = 0.0; + for (int i = 0; i < num; i++) { Waypt* wp = _route[i]; SGPropertyNode *prop = mirror->getChild("wp", i, 1); @@ -1008,6 +1010,8 @@ void FGRouteMgr::update_mirror() next->courseAndDistanceFrom(pos); prop->setDoubleValue("leg-bearing-true-deg", crsDist.first); prop->setDoubleValue("leg-distance-nm", crsDist.second * SG_METER_TO_NM); + prop->setDoubleValue("distance-along-route-nm", totalDistanceEnroute); + totalDistanceEnroute += crsDist.second * SG_METER_TO_NM; } if (wp->altitudeRestriction() != RESTRICT_NONE) { @@ -1049,6 +1053,16 @@ void FGRouteMgr::update_mirror() if (rmDlg) { rmDlg->updateValues(); } + + if (_departure) { + departure->setDoubleValue("field-elevation-ft", _departure->getElevation()); + } + + if (_destination) { + destination->setDoubleValue("field-elevation-ft", _destination->getElevation()); + } + + totalDistance->setDoubleValue(totalDistanceEnroute); } // command interface /autopilot/route-manager/input: