1 // gps.cxx - distance-measuring equipment.
2 // Written by David Megginson, started 2003.
4 // This file is in the Public Domain and comes with no warranty.
12 #include <boost/tuple/tuple.hpp>
19 #include "Main/fg_props.hxx"
20 #include "Main/globals.hxx" // for get_subsystem
21 #include "Main/util.hxx" // for fgLowPass
22 #include "Navaids/positioned.hxx"
23 #include <Navaids/waypoint.hxx>
24 #include "Navaids/navrecord.hxx"
25 #include "Navaids/FlightPlan.hxx"
26 #include <Navaids/routePath.hxx>
28 #include "Airports/airport.hxx"
29 #include "Airports/runways.hxx"
30 #include "Autopilot/route_mgr.hxx"
32 #include <simgear/math/sg_random.h>
33 #include <simgear/sg_inlines.h>
34 #include <simgear/math/sg_geodesy.hxx>
35 #include <simgear/structure/exception.hxx>
39 using namespace flightgear;
42 static const char* makeTTWString(double TTW)
44 if ((TTW <= 0.0) || (TTW >= 356400.5)) { // 99 hours
48 unsigned int TTW_seconds = (int) (TTW + 0.5);
49 unsigned int TTW_minutes = 0;
50 unsigned int TTW_hours = 0;
51 static char TTW_str[9];
52 TTW_hours = TTW_seconds / 3600;
53 TTW_minutes = (TTW_seconds / 60) % 60;
54 TTW_seconds = TTW_seconds % 60;
55 snprintf(TTW_str, 9, "%02d:%02d:%02d",
56 TTW_hours, TTW_minutes, TTW_seconds);
60 ////////////////////////////////////////////////////////////////////////////
61 // configuration helper object
63 GPS::Config::Config() :
64 _enableTurnAnticipation(true),
65 _turnRate(3.0), // degrees-per-second, so 180 degree turn takes 60 seconds
66 _overflightDistance(0.0),
67 _overflightArmDistance(1.0),
68 _overflightArmAngle(90.0),
69 _waypointAlertTime(30.0),
70 _requireHardSurface(true),
71 _cdiMaxDeflectionNm(3.0), // linear mode, 3nm at the peg
72 _driveAutopilot(true),
73 _courseSelectable(false),
74 _followLegTrackToFix(true)
76 _enableTurnAnticipation = false;
79 void GPS::Config::bind(GPS* aOwner, SGPropertyNode* aCfg)
81 aOwner->tie(aCfg, "turn-rate-deg-sec", SGRawValuePointer<double>(&_turnRate));
82 aOwner->tie(aCfg, "turn-anticipation", SGRawValuePointer<bool>(&_enableTurnAnticipation));
83 aOwner->tie(aCfg, "wpt-alert-time", SGRawValuePointer<double>(&_waypointAlertTime));
84 aOwner->tie(aCfg, "hard-surface-runways-only", SGRawValuePointer<bool>(&_requireHardSurface));
85 aOwner->tie(aCfg, "cdi-max-deflection-nm", SGRawValuePointer<double>(&_cdiMaxDeflectionNm));
86 aOwner->tie(aCfg, "drive-autopilot", SGRawValuePointer<bool>(&_driveAutopilot));
87 aOwner->tie(aCfg, "course-selectable", SGRawValuePointer<bool>(&_courseSelectable));
88 aOwner->tie(aCfg, "follow-leg-track-to-fix", SGRawValuePointer<bool>(&_followLegTrackToFix));
89 aOwner->tie(aCfg, "over-flight-distance-nm", SGRawValuePointer<double>(&_overflightDistance));
90 aOwner->tie(aCfg, "over-flight-arm-distance-nm", SGRawValuePointer<double>(&_overflightArmDistance));
91 aOwner->tie(aCfg, "over-flight-arm-angle-deg", SGRawValuePointer<double>(&_overflightArmAngle));
94 ////////////////////////////////////////////////////////////////////////////
96 GPS::GPS ( SGPropertyNode *node, bool defaultGPSMode) :
100 _lastPosValid(false),
101 _defaultGPSMode(defaultGPSMode),
103 _name(node->getStringValue("name", "gps")),
104 _num(node->getIntValue("number", 0)),
105 _computeTurnData(false),
106 _anticipateTurn(false),
108 _callbackFlightPlanChanged(SGPropertyChangeCallback<GPS>(this,&GPS::routeManagerFlightPlanChanged,
109 fgGetNode("/autopilot/route-manager/signals/flightplan-changed", true))),
110 _callbackRouteActivated(SGPropertyChangeCallback<GPS>(this,&GPS::routeActivated,
111 fgGetNode("/autopilot/route-manager/active", true)))
113 string branch = "/instrumentation/" + _name;
114 _gpsNode = fgGetNode(branch.c_str(), _num, true );
115 _scratchNode = _gpsNode->getChild("scratch", 0, true);
117 SGPropertyNode *wp_node = _gpsNode->getChild("wp", 0, true);
118 _currentWayptNode = wp_node->getChild("wp", 1, true);
121 _searchIsRoute = false;
122 _searchHasNext = false;
123 _searchType = FGPositioned::INVALID;
134 _magvar_node = fgGetNode("/environment/magnetic-variation-deg", true);
135 _serviceable_node = _gpsNode->getChild("serviceable", 0, true);
136 _serviceable_node->setBoolValue(true);
137 _electrical_node = fgGetNode("/systems/electrical/outputs/gps", true);
140 _raim_node = _gpsNode->getChild("raim", 0, true);
141 _odometer_node = _gpsNode->getChild("odometer", 0, true);
142 _trip_odometer_node = _gpsNode->getChild("trip-odometer", 0, true);
143 _true_bug_error_node = _gpsNode->getChild("true-bug-error-deg", 0, true);
144 _magnetic_bug_error_node = _gpsNode->getChild("magnetic-bug-error-deg", 0, true);
145 _eastWestVelocity = _gpsNode->getChild("ew-velocity-msec", 0, true);
146 _northSouthVelocity = _gpsNode->getChild("ns-velocity-msec", 0, true);
149 // for compatibility, alias selected course down to wp/wp[1]/desired-course-deg
150 SGPropertyNode* wp1Crs = _currentWayptNode->getChild("desired-course-deg", 0, true);
151 wp1Crs->alias(_gpsNode->getChild("desired-course-deg", 0, true));
153 _tracking_bug_node = _gpsNode->getChild("tracking-bug", 0, true);
156 // should these move to the route manager?
157 _routeDistanceNm = _gpsNode->getChild("route-distance-nm", 0, true);
158 _routeETE = _gpsNode->getChild("ETE", 0, true);
161 // navradio slaving properties
162 SGPropertyNode* toFlag = _gpsNode->getChild("to-flag", 0, true);
163 toFlag->alias(_currentWayptNode->getChild("to-flag"));
165 SGPropertyNode* fromFlag = _gpsNode->getChild("from-flag", 0, true);
166 fromFlag->alias(_currentWayptNode->getChild("from-flag"));
168 // autopilot drive properties
169 _apDrivingFlag = fgGetNode("/autopilot/settings/gps-driving-true-heading", true);
170 _apTrueHeading = fgGetNode("/autopilot/settings/true-heading-deg",true);
185 _config.bind(this, _gpsNode->getChild("config", 0, true));
188 tie(_gpsNode, "selected-course-deg", SGRawValueMethods<GPS, double>
189 (*this, &GPS::getSelectedCourse, &GPS::setSelectedCourse));
191 tie(_gpsNode, "desired-course-deg", SGRawValueMethods<GPS, double>
192 (*this, &GPS::getDesiredCourse, NULL));
193 _desiredCourseNode = _gpsNode->getChild("desired-course-deg", 0, true);
195 tieSGGeodReadOnly(_gpsNode, _indicated_pos, "indicated-longitude-deg",
196 "indicated-latitude-deg", "indicated-altitude-ft");
198 tie(_gpsNode, "indicated-vertical-speed", SGRawValueMethods<GPS, double>
199 (*this, &GPS::getVerticalSpeed, NULL));
200 tie(_gpsNode, "indicated-track-true-deg", SGRawValueMethods<GPS, double>
201 (*this, &GPS::getTrueTrack, NULL));
202 tie(_gpsNode, "indicated-track-magnetic-deg", SGRawValueMethods<GPS, double>
203 (*this, &GPS::getMagTrack, NULL));
204 tie(_gpsNode, "indicated-ground-speed-kt", SGRawValueMethods<GPS, double>
205 (*this, &GPS::getGroundspeedKts, NULL));
208 tie(_gpsNode, "mode", SGRawValueMethods<GPS, const char*>(*this, &GPS::getMode, NULL));
209 tie(_gpsNode, "command", SGRawValueMethods<GPS, const char*>(*this, &GPS::getCommand, &GPS::setCommand));
210 tieSGGeod(_scratchNode, _scratchPos, "longitude-deg", "latitude-deg", "altitude-ft");
213 tie(_scratchNode, "valid", SGRawValueMethods<GPS, bool>(*this, &GPS::getScratchValid, NULL));
214 tie(_scratchNode, "distance-nm", SGRawValueMethods<GPS, double>(*this, &GPS::getScratchDistance, NULL));
215 tie(_scratchNode, "true-bearing-deg", SGRawValueMethods<GPS, double>(*this, &GPS::getScratchTrueBearing, NULL));
216 tie(_scratchNode, "mag-bearing-deg", SGRawValueMethods<GPS, double>(*this, &GPS::getScratchMagBearing, NULL));
217 tie(_scratchNode, "has-next", SGRawValueMethods<GPS, bool>(*this, &GPS::getScratchHasNext, NULL));
218 _scratchValid = false;
220 _scratchNode->setStringValue("type", "");
221 _scratchNode->setStringValue("query", "");
224 SGPropertyNode *wp_node = _gpsNode->getChild("wp", 0, true);
225 SGPropertyNode* wp0_node = wp_node->getChild("wp", 0, true);
226 tieSGGeodReadOnly(wp0_node, _wp0_position, "longitude-deg", "latitude-deg", "altitude-ft");
227 tie(wp0_node, "ID", SGRawValueMethods<GPS, const char*>
228 (*this, &GPS::getWP0Ident, NULL));
229 tie(wp0_node, "name", SGRawValueMethods<GPS, const char*>
230 (*this, &GPS::getWP0Name, NULL));
232 tie(_currentWayptNode, "valid", SGRawValueMethods<GPS, bool>
233 (*this, &GPS::getWP1IValid, NULL));
235 tie(_currentWayptNode, "ID", SGRawValueMethods<GPS, const char*>
236 (*this, &GPS::getWP1Ident, NULL));
237 tie(_currentWayptNode, "name", SGRawValueMethods<GPS, const char*>
238 (*this, &GPS::getWP1Name, NULL));
240 tie(_currentWayptNode, "distance-nm", SGRawValueMethods<GPS, double>
241 (*this, &GPS::getWP1Distance, NULL));
242 tie(_currentWayptNode, "bearing-true-deg", SGRawValueMethods<GPS, double>
243 (*this, &GPS::getWP1Bearing, NULL));
244 tie(_currentWayptNode, "bearing-mag-deg", SGRawValueMethods<GPS, double>
245 (*this, &GPS::getWP1MagBearing, NULL));
246 tie(_currentWayptNode, "TTW-sec", SGRawValueMethods<GPS, double>
247 (*this, &GPS::getWP1TTW, NULL));
248 tie(_currentWayptNode, "TTW", SGRawValueMethods<GPS, const char*>
249 (*this, &GPS::getWP1TTWString, NULL));
251 tie(_currentWayptNode, "course-deviation-deg", SGRawValueMethods<GPS, double>
252 (*this, &GPS::getWP1CourseDeviation, NULL));
253 tie(_currentWayptNode, "course-error-nm", SGRawValueMethods<GPS, double>
254 (*this, &GPS::getWP1CourseErrorNm, NULL));
255 tie(_currentWayptNode, "to-flag", SGRawValueMethods<GPS, bool>
256 (*this, &GPS::getWP1ToFlag, NULL));
257 tie(_currentWayptNode, "from-flag", SGRawValueMethods<GPS, bool>
258 (*this, &GPS::getWP1FromFlag, NULL));
260 // leg properties (only valid in DTO/LEG modes, not OBS)
261 tie(wp_node, "leg-distance-nm", SGRawValueMethods<GPS, double>(*this, &GPS::getLegDistance, NULL));
262 tie(wp_node, "leg-true-course-deg", SGRawValueMethods<GPS, double>(*this, &GPS::getLegCourse, NULL));
263 tie(wp_node, "leg-mag-course-deg", SGRawValueMethods<GPS, double>(*this, &GPS::getLegMagCourse, NULL));
265 // navradio slaving properties
266 tie(_gpsNode, "cdi-deflection", SGRawValueMethods<GPS,double>
267 (*this, &GPS::getCDIDeflection));
273 _tiedProperties.Untie();
280 _last_speed_kts = 0.0;
281 _last_pos = SGGeod();
282 _lastPosValid = false;
283 _indicated_pos = SGGeod();
284 _last_vertical_speed = 0.0;
285 _last_true_track = 0.0;
286 _lastEWVelocity = _lastNSVelocity = 0.0;
287 _currentWaypt = _prevWaypt = NULL;
288 _legDistanceNm = -1.0;
290 _raim_node->setDoubleValue(0.0);
291 _indicated_pos = SGGeod();
292 _odometer_node->setDoubleValue(0);
293 _trip_odometer_node->setDoubleValue(0);
294 _tracking_bug_node->setDoubleValue(0);
295 _true_bug_error_node->setDoubleValue(0);
296 _magnetic_bug_error_node->setDoubleValue(0);
297 _northSouthVelocity->setDoubleValue(0.0);
298 _eastWestVelocity->setDoubleValue(0.0);
302 GPS::update (double delta_time_sec)
304 if (!_defaultGPSMode) {
305 // If it's off, don't bother.
306 // check if value is defined, since many aircraft don't define an output
307 // for the GPS, but expect the default one to work.
308 bool elecOn = !_electrical_node->hasValue() || _electrical_node->getBoolValue();
309 if (!_serviceable_node->getBoolValue() || !elecOn) {
315 if (delta_time_sec <= 0.0) {
316 return; // paused, don't bother
319 _raim_node->setDoubleValue(1.0);
320 _indicated_pos = globals->get_aircraft_position();
321 updateBasicData(delta_time_sec);
324 if (_wayptController.get()) {
325 _wayptController->update(delta_time_sec);
326 SGGeod p(_wayptController->position());
327 _currentWayptNode->setDoubleValue("longitude-deg", p.getLongitudeDeg());
328 _currentWayptNode->setDoubleValue("latitude-deg", p.getLatitudeDeg());
329 _currentWayptNode->setDoubleValue("altitude-ft", p.getElevationFt());
331 _desiredCourse = getLegMagCourse();
342 if (_dataValid && (_mode == "init")) {
343 // will select LEG mode if the route is active
344 routeManagerFlightPlanChanged(NULL);
346 FGRouteMgr* routeMgr = static_cast<FGRouteMgr*>(globals->get_subsystem("route-manager"));
347 if (!routeMgr->isRouteActive()) {
348 // initialise in OBS mode, with waypt set to the nearest airport.
349 // keep in mind at this point, _dataValid is not set
350 auto_ptr<FGPositioned::Filter> f(new FGAirport::HardSurfaceFilter());
351 FGPositionedRef apt = FGPositioned::findClosest(_indicated_pos, 20.0, f.get());
353 selectOBSMode(new flightgear::NavaidWaypoint(apt, NULL));
363 // allow a realistic delay in the future, here
365 } // of init mode check
367 _last_pos = _indicated_pos;
368 _lastPosValid = !(_last_pos == SGGeod());
371 void GPS::routeManagerFlightPlanChanged(SGPropertyNode*)
374 _route->removeDelegate(this);
377 SG_LOG(SG_INSTR, SG_INFO, "GPS saw route-manager flight-plan replaced.");
378 FGRouteMgr* routeMgr = static_cast<FGRouteMgr*>(globals->get_subsystem("route-manager"));
379 _route = routeMgr->flightPlan();
381 _route->addDelegate(this);
384 if (routeMgr->isRouteActive()) {
387 selectOBSMode(_currentWaypt); // revert to OBS on current waypoint
391 void GPS::routeActivated(SGPropertyNode* aNode)
393 bool isActive = aNode->getBoolValue();
395 SG_LOG(SG_INSTR, SG_INFO, "GPS::route activated, switching to LEG mode");
398 // if we've already passed the current waypoint, sequence.
399 if (_dataValid && getWP1FromFlag()) {
400 SG_LOG(SG_INSTR, SG_INFO, "GPS::route activated, FROM wp1, sequencing");
403 } else if (_mode == "leg") {
404 SG_LOG(SG_INSTR, SG_INFO, "GPS::route deactivated, switching to OBS mode");
405 selectOBSMode(_currentWaypt);
409 ///////////////////////////////////////////////////////////////////////////
410 // implement the RNAV interface
411 SGGeod GPS::position()
417 return _indicated_pos;
420 double GPS::trackDeg()
422 return _last_true_track;
425 double GPS::groundSpeedKts()
427 return _last_speed_kts;
430 double GPS::vspeedFPM()
432 return _last_vertical_speed;
435 double GPS::magvarDeg()
437 return _magvar_node->getDoubleValue();
440 double GPS::overflightDistanceM()
442 return _config.overflightDistanceNm() * SG_NM_TO_METER;
445 double GPS::overflightArmDistanceM()
447 return _config.overflightArmDistanceNm() * SG_NM_TO_METER;
450 double GPS::overflightArmAngleDeg()
452 return _config.overflightArmAngleDeg();
455 double GPS::selectedMagCourse()
457 return _selectedCourse;
460 SGGeod GPS::previousLegWaypointPosition(bool& isValid)
462 FlightPlan::Leg* leg = _route->previousLeg();
464 Waypt* waypt = leg->waypoint();
467 // ensure computations use runway end, not threshold
468 if (waypt->type() == "runway") {
469 RunwayWaypt* rwpt = static_cast<RunwayWaypt*>(waypt);
470 return rwpt->runway()->end();
473 return waypt->position();
480 ///////////////////////////////////////////////////////////////////////////
483 GPS::updateBasicData(double dt)
485 if (!_lastPosValid) {
491 SGGeodesy::inverse(_last_pos, _indicated_pos, _last_true_track, track2_deg, distance_m );
493 double speed_kt = ((distance_m * SG_METER_TO_NM) * ((1 / dt) * 3600.0));
494 double vertical_speed_mpm = ((_indicated_pos.getElevationM() - _last_pos.getElevationM()) * 60 / dt);
495 _last_vertical_speed = vertical_speed_mpm * SG_METER_TO_FEET;
497 speed_kt = fgGetLowPass(_last_speed_kts, speed_kt, dt/10.0);
498 _last_speed_kts = speed_kt;
500 SGGeod g = _indicated_pos;
501 g.setLongitudeDeg(_last_pos.getLongitudeDeg());
502 double northSouthM = dist(SGVec3d::fromGeod(_last_pos), SGVec3d::fromGeod(g));
503 northSouthM = copysign(northSouthM, _indicated_pos.getLatitudeDeg() - _last_pos.getLatitudeDeg());
505 double nsMSec = fgGetLowPass(_lastNSVelocity, northSouthM / dt, dt/2.0);
506 _lastNSVelocity = nsMSec;
507 _northSouthVelocity->setDoubleValue(nsMSec);
510 g.setLatitudeDeg(_last_pos.getLatitudeDeg());
511 double eastWestM = dist(SGVec3d::fromGeod(_last_pos), SGVec3d::fromGeod(g));
512 eastWestM = copysign(eastWestM, _indicated_pos.getLongitudeDeg() - _last_pos.getLongitudeDeg());
514 double ewMSec = fgGetLowPass(_lastEWVelocity, eastWestM / dt, dt/2.0);
515 _lastEWVelocity = ewMSec;
516 _eastWestVelocity->setDoubleValue(ewMSec);
518 double odometer = _odometer_node->getDoubleValue();
519 _odometer_node->setDoubleValue(odometer + distance_m * SG_METER_TO_NM);
520 odometer = _trip_odometer_node->getDoubleValue();
521 _trip_odometer_node->setDoubleValue(odometer + distance_m * SG_METER_TO_NM);
529 GPS::updateTrackingBug()
531 double tracking_bug = _tracking_bug_node->getDoubleValue();
532 double true_bug_error = tracking_bug - getTrueTrack();
533 double magnetic_bug_error = tracking_bug - getMagTrack();
535 // Get the errors into the (-180,180) range.
536 SG_NORMALIZE_RANGE(true_bug_error, -180.0, 180.0);
537 SG_NORMALIZE_RANGE(magnetic_bug_error, -180.0, 180.0);
539 _true_bug_error_node->setDoubleValue(true_bug_error);
540 _magnetic_bug_error_node->setDoubleValue(magnetic_bug_error);
543 void GPS::endOfFlightPlan()
545 selectOBSMode(_currentWaypt);
548 void GPS::currentWaypointChanged()
554 int index = _route->currentIndex(),
555 count = _route->numLegs();
556 if ((index < 0) || (index >= count)) {
559 // no active leg on the route
564 _prevWaypt = _route->previousLeg()->waypoint();
565 if (_prevWaypt->flag(WPT_DYNAMIC)) {
566 _wp0_position = _indicated_pos;
568 _wp0_position = _prevWaypt->position();
572 _currentWaypt = _route->currentLeg()->waypoint();
573 wp1Changed(); // rebuild the active controller
574 _desiredCourse = getLegMagCourse();
575 _desiredCourseNode->fireValueChanged();
579 void GPS::waypointsChanged()
581 if (_mode != "leg") {
585 SG_LOG(SG_INSTR, SG_INFO, "GPS route edited while in LEG mode, updating waypoints");
586 currentWaypointChanged();
591 if (_mode != "leg") {
595 selectOBSMode(_currentWaypt);
604 int nextIndex = _route->currentIndex() + 1;
605 if (nextIndex >= _route->numLegs()) {
606 SG_LOG(SG_INSTR, SG_INFO, "sequenced final leg, end of route");
608 selectOBSMode(_currentWaypt);
612 // will callback into currentWaypointChanged
613 _route->setCurrentIndex(nextIndex);
616 void GPS::updateTurn()
618 bool printProgress = false;
620 if (_computeTurnData) {
621 if (_last_speed_kts < 10) {
622 // need valid leg course and sensible ground speed to compute the turn
627 printProgress = true;
630 if (!_anticipateTurn) {
636 // find bearing to turn centre
637 double bearing, az2, distanceM;
638 SGGeodesy::inverse(_indicated_pos, _turnCentre, bearing, az2, distanceM);
639 double progress = computeTurnProgress(bearing);
642 SG_LOG(SG_INSTR, SG_INFO,"turn progress=" << progress);
645 if (!_inTurn && (progress > 0.0)) {
649 if (_inTurn && !_turnSequenced && (progress > 0.5)) {
650 _turnSequenced = true;
651 SG_LOG(SG_INSTR, SG_INFO, "turn passed midpoint, sequencing");
655 if (_inTurn && (progress >= 1.0)) {
660 // drive deviation and desired course
661 double desiredCourse = bearing - copysign(90, _turnAngle);
662 SG_NORMALIZE_RANGE(desiredCourse, 0.0, 360.0);
663 double deviationNm = (distanceM * SG_METER_TO_NM) - _turnRadius;
664 double deviationDeg = desiredCourse - getMagTrack();
665 deviationNm = copysign(deviationNm, deviationDeg);
667 //_wp1_course_deviation_node->setDoubleValue(deviationDeg);
668 //_wp1_course_error_nm_node->setDoubleValue(deviationNm);
669 //_cdiDeflectionNode->setDoubleValue(deviationDeg);
673 void GPS::updateOverflight()
675 if (!_wayptController->isDone()) {
679 if (_mode == "dto") {
680 SG_LOG(SG_INSTR, SG_INFO, "GPS DTO reached destination point");
682 // check for wp1 being on active route - resume leg mode
684 int index = _route->findWayptIndex(_currentWaypt->position());
686 SG_LOG(SG_INSTR, SG_INFO, "GPS DTO, resuming LEG mode at wp:" << index);
688 _route->setCurrentIndex(index);
689 sequence(); // and sequence to the next point
693 if (_mode == "dto") {
694 // if we didn't enter leg mode, drop back to OBS mode
695 // select OBS mode, but keep current waypoint-as is
699 } else if (_mode == "leg") {
700 SG_LOG(SG_INSTR, SG_DEBUG, "GPS doing overflight sequencing");
702 } else if (_mode == "obs") {
703 // nothing to do here, TO/FROM will update but that's fine
705 _computeTurnData = true;
708 void GPS::beginTurn()
711 _turnSequenced = false;
712 SG_LOG(SG_INSTR, SG_INFO, "beginning turn");
718 SG_LOG(SG_INSTR, SG_INFO, "ending turn");
719 _computeTurnData = true;
722 double GPS::computeTurnProgress(double aBearing) const
724 double startBearing = _turnStartBearing + copysign(90, _turnAngle);
725 return (aBearing - startBearing) / _turnAngle;
728 void GPS::computeTurnData()
730 _computeTurnData = false;
731 if ((_mode != "leg") || !_route->nextLeg()) {
732 _anticipateTurn = false;
736 WayptRef next = _route->nextLeg()->waypoint();
737 if (next->flag(WPT_DYNAMIC) ||
738 !_config.turnAnticipationEnabled() ||
739 next->flag(WPT_OVERFLIGHT))
741 _anticipateTurn = false;
745 _turnStartBearing = _desiredCourse;
746 // compute next leg course
747 RoutePath path(_route);
748 double crs = path.trackForIndex(_route->currentIndex() + 1);
750 // compute offset bearing
751 _turnAngle = crs - _turnStartBearing;
752 SG_NORMALIZE_RANGE(_turnAngle, -180.0, 180.0);
753 double median = _turnStartBearing + (_turnAngle * 0.5);
754 double offsetBearing = median + copysign(90, _turnAngle);
755 SG_NORMALIZE_RANGE(offsetBearing, 0.0, 360.0);
757 SG_LOG(SG_INSTR, SG_INFO, "GPS computeTurnData: in=" << _turnStartBearing <<
758 ", out=" << crs << "; turnAngle=" << _turnAngle << ", median=" << median
759 << ", offset=" << offsetBearing);
761 SG_LOG(SG_INSTR, SG_INFO, "next leg is now:" << _currentWaypt->ident() << "->" << next->ident());
763 _turnPt = _currentWaypt->position();
764 _anticipateTurn = true;
767 void GPS::updateTurnData()
769 // depends on ground speed, so needs to be updated per-frame
770 _turnRadius = computeTurnRadiusNm(_last_speed_kts);
772 // compute the turn centre, based on the turn radius.
773 // key thing is to understand that we're working a right-angle triangle,
774 // where the right-angle is the point we start the turn. From that point,
775 // one side is the inbound course to the turn pt, and the other is the
776 // perpendicular line, of length 'r', to the turn centre.
777 // the triangle's hypotenuse, which we need to find, is the distance from the
778 // turn pt to the turn center (in the direction of the offset bearing)
779 // note that d - _turnRadius tell us how much we're 'cutting' the corner.
781 double halfTurnAngle = fabs(_turnAngle * 0.5) * SG_DEGREES_TO_RADIANS;
782 double d = _turnRadius / cos(halfTurnAngle);
784 // SG_LOG(SG_INSTR, SG_INFO, "turnRadius=" << _turnRadius << ", d=" << d
785 // << " (cut distance=" << d - _turnRadius << ")");
787 double median = _turnStartBearing + (_turnAngle * 0.5);
788 double offsetBearing = median + copysign(90, _turnAngle);
789 SG_NORMALIZE_RANGE(offsetBearing, 0.0, 360.0);
792 SGGeodesy::direct(_turnPt, offsetBearing, d * SG_NM_TO_METER, _turnCentre, az2);
795 double GPS::computeTurnRadiusNm(double aGroundSpeedKts) const
797 // turn time is seconds to execute a 360 turn.
798 double turnTime = 360.0 / _config.turnRateDegSec();
800 // c is ground distance covered in that time (circumference of the circle)
801 double c = turnTime * (aGroundSpeedKts / 3600.0); // convert knts to nm/sec
803 // divide by 2PI to go from circumference -> radius
804 return c / (2 * M_PI);
807 void GPS::updateRouteData()
809 double totalDistance = _wayptController->distanceToWayptM() * SG_METER_TO_NM;
810 // walk all waypoints from wp2 to route end, and sum
811 for (int i=_route->currentIndex()+1; i<_route->numLegs(); ++i) {
812 FlightPlan::Leg* leg = _route->legAtIndex(i);
813 // omit missed-approach waypoints in distance calculation
814 if (leg->waypoint()->flag(WPT_MISS))
817 totalDistance += leg->distanceNm();
820 _routeDistanceNm->setDoubleValue(totalDistance * SG_METER_TO_NM);
821 if (_last_speed_kts > 1.0) {
822 double TTW = ((totalDistance * SG_METER_TO_NM) / _last_speed_kts) * 3600.0;
823 _routeETE->setStringValue(makeTTWString(TTW));
827 void GPS::driveAutopilot()
829 if (!_config.driveAutopilot() || !_defaultGPSMode) {
830 _apDrivingFlag->setBoolValue(false);
834 // compatibility feature - allow the route-manager / GPS to drive the
835 // generic autopilot heading hold *in leg mode only*
837 bool drive = _mode == "leg";
838 _apDrivingFlag->setBoolValue(drive);
841 // FIXME: we want to set desired track, not heading, here
842 _apTrueHeading->setDoubleValue(getWP1Bearing());
846 void GPS::wp1Changed()
850 if (_mode == "leg") {
851 _wayptController.reset(WayptController::createForWaypt(this, _currentWaypt));
852 } else if (_mode == "obs") {
853 _wayptController.reset(new OBSController(this, _currentWaypt));
854 } else if (_mode == "dto") {
855 _wayptController.reset(new DirectToController(this, _currentWaypt, _wp0_position));
858 _wayptController->init();
860 if (_mode == "obs") {
861 _legDistanceNm = -1.0;
863 _wayptController->update(0.0);
864 _legDistanceNm = _wayptController->distanceToWayptM() * SG_METER_TO_NM;
868 /////////////////////////////////////////////////////////////////////////////
869 // property getter/setters
871 void GPS::setSelectedCourse(double crs)
873 if (_selectedCourse == crs) {
877 _selectedCourse = crs;
878 if ((_mode == "obs") || _config.courseSelectable()) {
879 _desiredCourse = _selectedCourse;
880 _desiredCourseNode->fireValueChanged();
884 double GPS::getLegDistance() const
886 if (!_dataValid || (_mode == "obs")) {
890 return _legDistanceNm;
893 double GPS::getLegCourse() const
895 if (!_dataValid || !_wayptController.get()) {
899 return _wayptController->targetTrackDeg();
902 double GPS::getLegMagCourse() const
908 double m = getLegCourse() - _magvar_node->getDoubleValue();
909 SG_NORMALIZE_RANGE(m, 0.0, 360.0);
913 double GPS::getMagTrack() const
919 double m = getTrueTrack() - _magvar_node->getDoubleValue();
920 SG_NORMALIZE_RANGE(m, 0.0, 360.0);
924 double GPS::getCDIDeflection() const
931 if (_config.cdiDeflectionIsAngular()) {
932 defl = getWP1CourseDeviation();
933 SG_CLAMP_RANGE(defl, -10.0, 10.0); // as in navradio.cxx
935 double fullScale = _config.cdiDeflectionLinearPeg();
936 double normError = getWP1CourseErrorNm() / fullScale;
937 SG_CLAMP_RANGE(normError, -1.0, 1.0);
938 defl = normError * 10.0; // re-scale to navradio limits, i.e [-10.0 .. 10.0]
944 const char* GPS::getWP0Ident() const
946 if (!_dataValid || (_mode != "leg") || !_prevWaypt) {
950 // work around std::string::c_str() storage lifetime with libc++
951 // real fix is to allow tie-ing with std::string instead of char*
952 static char identBuf[8];
953 strncpy(identBuf, _prevWaypt->ident().c_str(), 8);
958 const char* GPS::getWP0Name() const
960 if (!_dataValid || !_prevWaypt || !_prevWaypt->source()) {
964 return _prevWaypt->source()->name().c_str();
967 bool GPS::getWP1IValid() const
969 return _dataValid && _currentWaypt.get();
972 const char* GPS::getWP1Ident() const
974 if (!_dataValid || !_currentWaypt) {
978 // work around std::string::c_str() storage lifetime with libc++
979 // real fix is to allow tie-ing with std::string instead of char*
980 static char identBuf[8];
981 strncpy(identBuf, _currentWaypt->ident().c_str(), 8);
986 const char* GPS::getWP1Name() const
988 if (!_dataValid || !_currentWaypt || !_currentWaypt->source()) {
992 return _currentWaypt->source()->name().c_str();
995 double GPS::getWP1Distance() const
997 if (!_dataValid || !_wayptController.get()) {
1001 return _wayptController->distanceToWayptM() * SG_METER_TO_NM;
1004 double GPS::getWP1TTW() const
1006 if (!_dataValid || !_wayptController.get()) {
1010 return _wayptController->timeToWaypt();
1013 const char* GPS::getWP1TTWString() const
1015 double t = getWP1TTW();
1020 return makeTTWString(t);
1023 double GPS::getWP1Bearing() const
1025 if (!_dataValid || !_wayptController.get()) {
1029 return _wayptController->trueBearingDeg();
1032 double GPS::getWP1MagBearing() const
1034 if (!_dataValid || !_wayptController.get()) {
1038 double magBearing = _wayptController->trueBearingDeg() - _magvar_node->getDoubleValue();
1039 SG_NORMALIZE_RANGE(magBearing, 0.0, 360.0);
1043 double GPS::getWP1CourseDeviation() const
1045 if (!_dataValid || !_wayptController.get()) {
1049 return _wayptController->courseDeviationDeg();
1052 double GPS::getWP1CourseErrorNm() const
1054 if (!_dataValid || !_wayptController.get()) {
1058 return _wayptController->xtrackErrorNm();
1061 bool GPS::getWP1ToFlag() const
1063 if (!_dataValid || !_wayptController.get()) {
1067 return _wayptController->toFlag();
1070 bool GPS::getWP1FromFlag() const
1072 if (!_dataValid || !_wayptController.get()) {
1076 return !getWP1ToFlag();
1080 double GPS::getScratchDistance() const
1082 if (!_scratchValid) {
1086 return SGGeodesy::distanceNm(_indicated_pos, _scratchPos);
1089 double GPS::getScratchTrueBearing() const
1091 if (!_scratchValid) {
1095 return SGGeodesy::courseDeg(_indicated_pos, _scratchPos);
1098 double GPS::getScratchMagBearing() const
1100 if (!_scratchValid) {
1104 double crs = getScratchTrueBearing() - _magvar_node->getDoubleValue();
1105 SG_NORMALIZE_RANGE(crs, 0.0, 360.0);
1111 /////////////////////////////////////////////////////////////////////////////
1114 void GPS::setCommand(const char* aCmd)
1116 SG_LOG(SG_INSTR, SG_DEBUG, "GPS command:" << aCmd);
1118 if (!strcmp(aCmd, "direct")) {
1120 } else if (!strcmp(aCmd, "obs")) {
1121 selectOBSMode(NULL);
1122 } else if (!strcmp(aCmd, "leg")) {
1125 } else if (!strcmp(aCmd, "load-route-wpt")) {
1126 loadRouteWaypoint();
1127 } else if (!strcmp(aCmd, "nearest")) {
1129 } else if (!strcmp(aCmd, "search")) {
1130 _searchNames = false;
1132 } else if (!strcmp(aCmd, "search-names")) {
1133 _searchNames = true;
1135 } else if (!strcmp(aCmd, "next")) {
1137 } else if (!strcmp(aCmd, "previous")) {
1139 } else if (!strcmp(aCmd, "define-user-wpt")) {
1141 } else if (!strcmp(aCmd, "route-insert-before")) {
1142 int index = _scratchNode->getIntValue("index");
1143 if (index < 0 || (_route->numLegs() == 0)) {
1144 index = _route->numLegs();
1145 } else if (index >= _route->numLegs()) {
1146 SG_LOG(SG_INSTR, SG_WARN, "GPS:route-insert-before, bad index:" << index);
1150 insertWaypointAtIndex(index);
1151 } else if (!strcmp(aCmd, "route-insert-after")) {
1152 int index = _scratchNode->getIntValue("index");
1153 if (index < 0 || (_route->numLegs() == 0)) {
1154 index = _route->numLegs();
1155 } else if (index >= _route->numLegs()) {
1156 SG_LOG(SG_INSTR, SG_WARN, "GPS:route-insert-after, bad index:" << index);
1162 insertWaypointAtIndex(index);
1163 } else if (!strcmp(aCmd, "route-delete")) {
1164 int index = _scratchNode->getIntValue("index");
1166 index = _route->numLegs();
1167 } else if (index >= _route->numLegs()) {
1168 SG_LOG(SG_INSTR, SG_WARN, "GPS:route-delete, bad index:" << index);
1172 removeWaypointAtIndex(index);
1175 SG_LOG(SG_INSTR, SG_WARN, "GPS:unrecognized command:" << aCmd);
1179 void GPS::clearScratch()
1181 _scratchPos = SGGeod::fromDegFt(-9999.0, -9999.0, -9999.0);
1182 _scratchNode->setBoolValue("valid", false);
1184 _scratchNode->setStringValue("type", "");
1185 _scratchNode->setStringValue("query", "");
1189 bool GPS::isScratchPositionValid() const
1191 if ((_scratchPos.getLongitudeDeg() < -9990.0) ||
1192 (_scratchPos.getLatitudeDeg() < -9990.0)) {
1199 FGPositionedRef GPS::positionedFromScratch() const
1201 if (!isScratchPositionValid()) {
1205 std::string ident(_scratchNode->getStringValue("ident"));
1206 return FGPositioned::findClosestWithIdent(ident, _scratchPos);
1209 void GPS::directTo()
1211 if (!isScratchPositionValid()) {
1216 _wp0_position = _indicated_pos;
1218 FGPositionedRef pos = positionedFromScratch();
1220 _currentWaypt = new NavaidWaypoint(pos, NULL);
1222 _currentWaypt = new BasicWaypt(_scratchPos, _scratchNode->getStringValue("ident"), NULL);
1229 void GPS::selectOBSMode(flightgear::Waypt* waypt)
1231 if (!waypt && isScratchPositionValid()) {
1232 FGPositionedRef pos = positionedFromScratch();
1234 waypt = new NavaidWaypoint(pos, NULL);
1236 waypt = new BasicWaypt(_scratchPos, _scratchNode->getStringValue("ident"), NULL);
1242 _wp0_position = _indicated_pos;
1243 _currentWaypt = waypt;
1247 void GPS::selectLegMode()
1249 if (_mode == "leg") {
1254 SG_LOG(SG_INSTR, SG_WARN, "GPS:selectLegMode: no active route");
1260 // depending on the situation, this will either get over-written
1261 // in routeManagerSequenced or not; either way it does no harm to
1263 _wp0_position = _indicated_pos;
1265 // not really sequenced, but does all the work of updating wp0/1
1266 currentWaypointChanged();
1271 void GPS::loadRouteWaypoint()
1273 _scratchValid = false;
1274 int index = _scratchNode->getIntValue("index", -9999);
1277 if ((index < 0) || (index >= _route->numLegs())) { // no index supplied, use current wp
1278 index = _route->currentIndex();
1281 _searchIsRoute = true;
1282 setScratchFromRouteWaypoint(index);
1285 void GPS::setScratchFromRouteWaypoint(int aIndex)
1287 assert(_searchIsRoute);
1288 if ((aIndex < 0) || (aIndex >= _route->numLegs())) {
1289 SG_LOG(SG_INSTR, SG_WARN, "GPS:setScratchFromRouteWaypoint: route-index out of bounds");
1293 _searchResultIndex = aIndex;
1294 WayptRef wp = _route->legAtIndex(aIndex)->waypoint();
1295 _scratchNode->setStringValue("ident", wp->ident());
1296 _scratchPos = wp->position();
1297 _scratchValid = true;
1298 _scratchNode->setIntValue("index", aIndex);
1301 void GPS::loadNearest()
1303 string sty(_scratchNode->getStringValue("type"));
1304 FGPositioned::Type ty = FGPositioned::typeFromName(sty);
1305 if (ty == FGPositioned::INVALID) {
1306 SG_LOG(SG_INSTR, SG_WARN, "GPS:loadNearest: request type is invalid:" << sty);
1310 auto_ptr<FGPositioned::Filter> f(createFilter(ty));
1311 int limitCount = _scratchNode->getIntValue("max-results", 1);
1312 double cutoffDistance = _scratchNode->getDoubleValue("cutoff-nm", 400.0);
1314 SGGeod searchPos = _indicated_pos;
1315 if (isScratchPositionValid()) {
1316 searchPos = _scratchPos;
1319 clearScratch(); // clear now, regardless of whether we find a match or not
1322 FGPositioned::findClosestN(searchPos, limitCount, cutoffDistance, f.get());
1323 _searchResultIndex = 0;
1324 _searchIsRoute = false;
1326 if (_searchResults.empty()) {
1330 setScratchFromCachedSearchResult();
1333 bool GPS::SearchFilter::pass(FGPositioned* aPos) const
1335 switch (aPos->type()) {
1336 case FGPositioned::AIRPORT:
1337 // heliport and seaport too?
1338 case FGPositioned::VOR:
1339 case FGPositioned::NDB:
1340 case FGPositioned::FIX:
1341 case FGPositioned::TACAN:
1342 case FGPositioned::WAYPOINT:
1349 FGPositioned::Type GPS::SearchFilter::minType() const
1351 return FGPositioned::AIRPORT;
1354 FGPositioned::Type GPS::SearchFilter::maxType() const
1356 return FGPositioned::VOR;
1359 FGPositioned::Filter* GPS::createFilter(FGPositioned::Type aTy)
1361 if (aTy == FGPositioned::AIRPORT) {
1362 return new FGAirport::HardSurfaceFilter();
1365 // if we were passed INVALID, assume it means 'all types interesting to a GPS'
1366 if (aTy == FGPositioned::INVALID) {
1367 return new SearchFilter;
1370 return new FGPositioned::TypeFilter(aTy);
1375 // parse search terms into local members, and exec the first search
1376 string sty(_scratchNode->getStringValue("type"));
1377 _searchType = FGPositioned::typeFromName(sty);
1378 _searchQuery = _scratchNode->getStringValue("query");
1379 if (_searchQuery.empty()) {
1380 SG_LOG(SG_INSTR, SG_WARN, "empty GPS search query");
1385 _searchExact = _scratchNode->getBoolValue("exact", true);
1386 _searchResultIndex = 0;
1387 _searchIsRoute = false;
1389 auto_ptr<FGPositioned::Filter> f(createFilter(_searchType));
1391 _searchResults = FGPositioned::findAllWithName(_searchQuery, f.get(), _searchExact);
1393 _searchResults = FGPositioned::findAllWithIdent(_searchQuery, f.get(), _searchExact);
1396 bool orderByRange = _scratchNode->getBoolValue("order-by-distance", true);
1398 FGPositioned::sortByRange(_searchResults, _indicated_pos);
1401 if (_searchResults.empty()) {
1406 setScratchFromCachedSearchResult();
1409 bool GPS::getScratchHasNext() const
1412 if (_searchIsRoute) {
1413 lastResult = _route->numLegs() - 1;
1415 lastResult = (int) _searchResults.size() - 1;
1418 if (lastResult < 0) { // search array might be empty
1422 return (_searchResultIndex < lastResult);
1425 void GPS::setScratchFromCachedSearchResult()
1427 int index = _searchResultIndex;
1429 if ((index < 0) || (index >= (int) _searchResults.size())) {
1430 SG_LOG(SG_INSTR, SG_WARN, "GPS:setScratchFromCachedSearchResult: index out of bounds:" << index);
1434 setScratchFromPositioned(_searchResults[index], index);
1437 void GPS::setScratchFromPositioned(FGPositioned* aPos, int aIndex)
1442 _scratchPos = aPos->geod();
1443 _scratchNode->setStringValue("name", aPos->name());
1444 _scratchNode->setStringValue("ident", aPos->ident());
1445 _scratchNode->setStringValue("type", FGPositioned::nameForType(aPos->type()));
1448 _scratchNode->setIntValue("index", aIndex);
1451 _scratchValid = true;
1452 _scratchNode->setIntValue("result-count", _searchResults.size());
1454 switch (aPos->type()) {
1455 case FGPositioned::VOR:
1456 _scratchNode->setDoubleValue("frequency-mhz", static_cast<FGNavRecord*>(aPos)->get_freq() / 100.0);
1459 case FGPositioned::NDB:
1460 _scratchNode->setDoubleValue("frequency-khz", static_cast<FGNavRecord*>(aPos)->get_freq() / 100.0);
1463 case FGPositioned::AIRPORT:
1464 addAirportToScratch((FGAirport*)aPos);
1472 // look for being on the route and set?
1475 void GPS::addAirportToScratch(FGAirport* aAirport)
1477 for (unsigned int r=0; r<aAirport->numRunways(); ++r) {
1478 SGPropertyNode* rwyNd = _scratchNode->getChild("runways", r, true);
1479 FGRunway* rwy = aAirport->getRunwayByIndex(r);
1480 // TODO - filter out unsuitable runways in the future
1481 // based on config again
1483 rwyNd->setStringValue("id", rwy->ident().c_str());
1484 rwyNd->setIntValue("length-ft", rwy->lengthFt());
1485 rwyNd->setIntValue("width-ft", rwy->widthFt());
1486 rwyNd->setIntValue("heading-deg", rwy->headingDeg());
1487 // map surface code to a string
1488 // TODO - lighting information
1491 rwyNd->setDoubleValue("ils-frequency-mhz", rwy->ILS()->get_freq() / 100.0);
1493 } // of runways iteration
1496 void GPS::nextResult()
1498 if (!getScratchHasNext()) {
1503 if (_searchIsRoute) {
1504 setScratchFromRouteWaypoint(++_searchResultIndex);
1506 ++_searchResultIndex;
1507 setScratchFromCachedSearchResult();
1511 void GPS::previousResult()
1513 if (_searchResultIndex <= 0) {
1518 --_searchResultIndex;
1520 if (_searchIsRoute) {
1521 setScratchFromRouteWaypoint(_searchResultIndex);
1523 setScratchFromCachedSearchResult();
1527 void GPS::defineWaypoint()
1529 if (!isScratchPositionValid()) {
1530 SG_LOG(SG_INSTR, SG_WARN, "GPS:defineWaypoint: invalid lat/lon");
1534 string ident = _scratchNode->getStringValue("ident");
1535 if (ident.size() < 2) {
1536 SG_LOG(SG_INSTR, SG_WARN, "GPS:defineWaypoint: waypoint identifier must be at least two characters");
1540 // check for duplicate idents
1541 FGPositioned::TypeFilter f(FGPositioned::WAYPOINT);
1542 FGPositionedList dups = FGPositioned::findAllWithIdent(ident, &f);
1543 if (!dups.empty()) {
1544 SG_LOG(SG_INSTR, SG_WARN, "GPS:defineWaypoint: non-unique waypoint identifier, ho-hum");
1547 SG_LOG(SG_INSTR, SG_INFO, "GPS:defineWaypoint: creating waypoint:" << ident);
1548 FGPositionedRef wpt = FGPositioned::createUserWaypoint(ident, _scratchPos);
1549 _searchResults.clear();
1550 _searchResults.push_back(wpt);
1551 setScratchFromPositioned(wpt.get(), -1);
1554 void GPS::insertWaypointAtIndex(int aIndex)
1556 // note we do allow index = routeMgr->size(), that's an append
1557 if ((aIndex < 0) || (aIndex > _route->numLegs())) {
1558 throw sg_range_exception("GPS::insertWaypointAtIndex: index out of bounds");
1561 if (!isScratchPositionValid()) {
1562 SG_LOG(SG_INSTR, SG_WARN, "GPS:insertWaypointAtIndex: invalid lat/lon");
1566 string ident = _scratchNode->getStringValue("ident");
1568 WayptRef wpt = new BasicWaypt(_scratchPos, ident, NULL);
1569 _route->insertWayptAtIndex(wpt, aIndex);
1572 void GPS::removeWaypointAtIndex(int aIndex)
1574 if ((aIndex < 0) || (aIndex >= _route->numLegs())) {
1575 throw sg_range_exception("GPS::removeWaypointAtIndex: index out of bounds");
1578 _route->deleteIndex(aIndex);
1582 #endif // of FG_210_COMPAT
1584 void GPS::tieSGGeod(SGPropertyNode* aNode, SGGeod& aRef,
1585 const char* lonStr, const char* latStr, const char* altStr)
1587 tie(aNode, lonStr, SGRawValueMethods<SGGeod, double>(aRef, &SGGeod::getLongitudeDeg, &SGGeod::setLongitudeDeg));
1588 tie(aNode, latStr, SGRawValueMethods<SGGeod, double>(aRef, &SGGeod::getLatitudeDeg, &SGGeod::setLatitudeDeg));
1591 tie(aNode, altStr, SGRawValueMethods<SGGeod, double>(aRef, &SGGeod::getElevationFt, &SGGeod::setElevationFt));
1595 void GPS::tieSGGeodReadOnly(SGPropertyNode* aNode, SGGeod& aRef,
1596 const char* lonStr, const char* latStr, const char* altStr)
1598 tie(aNode, lonStr, SGRawValueMethods<SGGeod, double>(aRef, &SGGeod::getLongitudeDeg, NULL));
1599 tie(aNode, latStr, SGRawValueMethods<SGGeod, double>(aRef, &SGGeod::getLatitudeDeg, NULL));
1602 tie(aNode, altStr, SGRawValueMethods<SGGeod, double>(aRef, &SGGeod::getElevationFt, NULL));