26#include <simgear/structure/exception.hxx>
27#include <simgear/misc/strutils.hxx>
52 if (!aProp->hasChild(
"lon") || !aProp->hasChild(
"lat")) {
53 SG_LOG(SG_AUTOPILOT, SG_WARN,
"missing lon/lat properties");
60 _pos = SGGeod::fromDeg(aProp->getDoubleValue(
"lon"),
61 aProp->getDoubleValue(
"lat"));
62 _ident = aProp->getStringValue(
"ident");
70 aProp->setStringValue(
"ident",
_ident);
71 aProp->setDoubleValue(
"lon",
_pos.getLongitudeDeg());
72 aProp->setDoubleValue(
"lat",
_pos.getLatitudeDeg());
77 return simgear::strutils::formatGeodAsString(
_pos, simgear::strutils::LatLonFormat::ICAO_ROUTE_DEGREES);
87 SG_LOG(SG_NAVAID, SG_WARN,
"sure you don't want to be building a runway waypt here?");
109 if (!aProp->hasChild(
"ident")) {
110 SG_LOG(SG_AUTOPILOT, SG_WARN,
"missing navaid ident");
117 std::string idn(aProp->getStringValue(
"ident"));
119 if (aProp->hasChild(
"lon")) {
120 p = SGGeod::fromDeg(aProp->getDoubleValue(
"lon"), aProp->getDoubleValue(
"lat"));
127 SG_LOG(SG_AUTOPILOT, SG_WARN,
"unknown navdaid ident:" << idn);
131 if (
p.isValid() && (SGGeodesy::distanceM(nav->geod(),
p) > 4000)) {
136 SG_LOG(SG_AUTOPILOT, SG_WARN,
"Waypoint navaid for ident:" << idn <<
" is too far from the specified lat/lon");
148 aProp->setStringValue(
"ident",
_navaid->ident());
150 aProp->setDoubleValue(
"lon",
_navaid->geod().getLongitudeDeg());
151 aProp->setDoubleValue(
"lat",
_navaid->geod().getLatitudeDeg());
155 double aRadial,
double aDistNm) :
168void OffsetNavaidWaypoint::init()
172 SGGeodesy::direct(
_navaid->geod(), _radial, _distanceNm * SG_NM_TO_METER, offset, az2);
178 if (!aProp->hasChild(
"radial-deg") || !aProp->hasChild(
"distance-nm")) {
179 SG_LOG(SG_AUTOPILOT, SG_WARN,
"missing radial/offset distance creating offset waypoint");
186 _radial = aProp->getDoubleValue(
"radial-deg");
187 _distanceNm = aProp->getDoubleValue(
"distance-nm");
195 aProp->setDoubleValue(
"radial-deg", _radial);
196 aProp->setDoubleValue(
"distance-nm", _distanceNm);
205 assert(aPos !=
nullptr);
215 return _runway->threshold();
220 return _runway->airport()->ident() +
"-" + _runway->ident();
230 return _runway->headingDeg();
235 if (!aProp->hasChild(
"icao") || !aProp->hasChild(
"ident")) {
236 SG_LOG(SG_AUTOPILOT, SG_WARN,
"missing ICAO/ident on runway waypoint");
243 std::string idn(aProp->getStringValue(
"ident"));
246 SG_LOG(SG_AUTOPILOT, SG_WARN,
"Unknown airport:" << aProp->getStringValue(
"icao"));
250 const std::string
ident = aProp->getStringValue(
"ident");
252 SG_LOG(SG_AUTOPILOT, SG_WARN,
"Unknown runway " <<
ident <<
" at " << aProp->getStringValue(
"icao"));
263 aProp->setStringValue(
"ident", _runway->ident());
264 aProp->setStringValue(
"icao", _runway->airport()->ident());
285 _bearing = aInboundRadial;
291 _holdTD = aDistanceNm;
307 _righthanded =
false;
315 _righthanded = aProp->getBoolValue(
"right-handed");
316 _isDistance = aProp->getBoolValue(
"is-distance");
317 _bearing = aProp->getDoubleValue(
"inbound-radial-deg");
318 _holdTD = aProp->getDoubleValue(
"td");
327 aProp->setBoolValue(
"right-handed", _righthanded);
328 aProp->setBoolValue(
"is-distance", _isDistance);
329 aProp->setDoubleValue(
"inbound-radial-deg", _bearing);
330 aProp->setDoubleValue(
"td", _holdTD);
351 if (!aProp->hasChild(
"heading-deg")) {
352 SG_LOG(SG_AUTOPILOT, SG_WARN,
"Missing heading property creating HdgToAlt waypoint");
359 _magHeading = aProp->getDoubleValue(
"heading-deg");
360 _ident = aProp->getStringValue(
"ident");
367 aProp->setStringValue(
"ident", _ident);
368 aProp->setDoubleValue(
"heading-deg", _magHeading);
374 double aCourseDeg,
double aDistanceNm) :
378 _magCourse(aCourseDeg),
379 _dmeDistanceNm(aDistanceNm)
391 if (!aProp->hasChild(
"lon") || !aProp->hasChild(
"lat")) {
392 SG_LOG(SG_AUTOPILOT, SG_WARN,
"Missing lat/lom properties creating DMEIntc waypoint");
399 _pos = SGGeod::fromDeg(aProp->getDoubleValue(
"lon"), aProp->getDoubleValue(
"lat"));
400 _ident = aProp->getStringValue(
"ident");
402 _magCourse = aProp->getDoubleValue(
"course-deg");
403 _dmeDistanceNm = aProp->getDoubleValue(
"dme-distance-nm");
412 aProp->setStringValue(
"ident", _ident);
413 aProp->setDoubleValue(
"lon", _pos.getLongitudeDeg());
414 aProp->setDoubleValue(
"lat", _pos.getLatitudeDeg());
415 aProp->setDoubleValue(
"course-deg", _magCourse);
416 aProp->setDoubleValue(
"dme-distance-nm", _dmeDistanceNm);
422 double aCourseDeg,
double aRadial) :
426 _magCourse(aCourseDeg),
439 if (!aProp->hasChild(
"lon") || !aProp->hasChild(
"lat")) {
440 SG_LOG(SG_AUTOPILOT, SG_WARN,
"Missing lat/lom properties creating RadialIntercept waypoint");
447 _pos = SGGeod::fromDeg(aProp->getDoubleValue(
"lon"), aProp->getDoubleValue(
"lat"));
448 _ident = aProp->getStringValue(
"ident");
450 _magCourse = aProp->getDoubleValue(
"course-deg");
451 _radial = aProp->getDoubleValue(
"radial-deg");
460 aProp->setStringValue(
"ident", _ident);
461 aProp->setDoubleValue(
"lon", _pos.getLongitudeDeg());
462 aProp->setDoubleValue(
"lat", _pos.getLatitudeDeg());
463 aProp->setDoubleValue(
"course-deg", _magCourse);
464 aProp->setDoubleValue(
"radial-deg", _radial);
487 return _facility->geod();
492 return "VECTORS-" + _facility->ident();
508 aProp->setStringValue(
"icao", _facility->ident());
532 return "DISCONTINUITY";
554 return "VIA " + _airway->ident() +
" TO " + _to->ident();
575 if (!aProp->hasChild(
"airway") || !aProp->hasChild(
"to")) {
576 SG_LOG(SG_AUTOPILOT, SG_WARN,
"Missingairway/to properties on Via wp");
583 const std::string
ident = aProp->getStringValue(
"airway");
587 SG_LOG(SG_AUTOPILOT, SG_WARN,
"VIA: unknown airway:" <<
ident);
591 std::string idn(aProp->getStringValue(
"to"));
593 if (aProp->hasChild(
"lon")) {
594 p = SGGeod::fromDeg(aProp->getDoubleValue(
"lon"),
595 aProp->getDoubleValue(
"lat"));
600 SG_LOG(SG_AUTOPILOT, SG_WARN,
"VIA TO navaid: " << idn <<
" not found");
604 if (!_airway->containsNavaid(nav)) {
606 SG_LOG(SG_AUTOPILOT, SG_WARN,
"VIA TO navaid: " << idn <<
" not found on airway " << _airway);
616 aProp->setStringValue(
"airway", _airway->ident());
617 aProp->setIntValue(
"level", _airway->level());
619 aProp->setStringValue(
"to", _to->ident());
621 aProp->setDoubleValue(
"lon", _to->geod().getLongitudeDeg());
622 aProp->setDoubleValue(
"lat", _to->geod().getLatitudeDeg());
628 throw sg_exception(
"invalid preceeding waypoint");
634 return _airway->via(aPreceeding, toWp);
FGRunwayRef getRunwayByIdent(const std::string &aIdent) const
bool hasRunwayWithIdent(const std::string &aIdent) const
static FGAirportRef getByIdent(const std::string &aIdent)
Helper to look up an FGAirport instance by unique ident.
static FGPositionedRef findClosestWithIdent(const std::string &aIdent, const SGGeod &aPos, Filter *aFilter=NULL)
ATCVectors(RouteBase *aOwner, FGAirport *aFacility)
virtual SGGeod position() const
bool initFromProperties(SGPropertyNode_ptr aProp) override
Persistence helper - read node properties from a file.
void writeToProperties(SGPropertyNode_ptr aProp) const override
Persistence helper - save this element to a node.
virtual std::string ident() const
Identifier assoicated with the waypoint.
static AirwayRef findByIdent(const std::string &aIdent, Level level)
void writeToProperties(SGPropertyNode_ptr aProp) const override
Persistence helper - save this element to a node.
bool initFromProperties(SGPropertyNode_ptr aProp) override
Persistence helper - read node properties from a file.
BasicWaypt(const SGGeod &aPos, const std::string &aIdent, RouteBase *aOwner)
std::string icaoDescription() const override
icaoDescription - description of the waypoint in ICAO route plan format
bool initFromProperties(SGPropertyNode_ptr aProp) override
Persistence helper - read node properties from a file.
DMEIntercept(RouteBase *aOwner, const std::string &aIdent, const SGGeod &aPos, double aCourseDeg, double aDistanceNm)
void writeToProperties(SGPropertyNode_ptr aProp) const override
Persistence helper - save this element to a node.
Discontinuity(RouteBase *aOwner)
void writeToProperties(SGPropertyNode_ptr aProp) const override
Persistence helper - save this element to a node.
virtual std::string ident() const
Identifier assoicated with the waypoint.
bool initFromProperties(SGPropertyNode_ptr aProp) override
Persistence helper - read node properties from a file.
virtual SGGeod position() const
HeadingToAltitude(RouteBase *aOwner, const std::string &aIdent, double aMagHdg)
void writeToProperties(SGPropertyNode_ptr aProp) const override
Persistence helper - save this element to a node.
bool initFromProperties(SGPropertyNode_ptr aProp) override
Persistence helper - read node properties from a file.
void writeToProperties(SGPropertyNode_ptr aProp) const override
Persistence helper - save this element to a node.
void setHoldRadial(double aInboundRadial)
bool initFromProperties(SGPropertyNode_ptr aProp) override
Persistence helper - read node properties from a file.
Hold(const SGGeod &aPos, const std::string &aIdent, RouteBase *aOwner)
void setHoldDistance(double aDistanceNm)
void setHoldTime(double aTimeSec)
Waypoint based upon a navaid.
void writeToProperties(SGPropertyNode_ptr aProp) const override
Persistence helper - save this element to a node.
bool initFromProperties(SGPropertyNode_ptr aProp) override
Persistence helper - read node properties from a file.
virtual std::string ident() const
Identifier assoicated with the waypoint.
virtual SGGeod position() const
NavaidWaypoint(FGPositioned *aPos, RouteBase *aOwner)
void writeToProperties(SGPropertyNode_ptr aProp) const override
Persistence helper - save this element to a node.
bool initFromProperties(SGPropertyNode_ptr aProp) override
Persistence helper - read node properties from a file.
OffsetNavaidWaypoint(FGPositioned *aPos, RouteBase *aOwner, double aRadial, double aDistNm)
bool initFromProperties(SGPropertyNode_ptr aProp) override
Persistence helper - read node properties from a file.
void writeToProperties(SGPropertyNode_ptr aProp) const override
Persistence helper - save this element to a node.
RadialIntercept(RouteBase *aOwner, const std::string &aIdent, const SGGeod &aPos, double aCourseDeg, double aRadialDeg)
void writeToProperties(SGPropertyNode_ptr aProp) const override
Persistence helper - save this element to a node.
RunwayWaypt(FGRunway *aPos, RouteBase *aOwner)
virtual double headingRadialDeg() const
return the assoicated heading or radial for this waypoint.
virtual SGGeod position() const
virtual std::string ident() const
Identifier assoicated with the waypoint.
bool initFromProperties(SGPropertyNode_ptr aProp) override
Persistence helper - read node properties from a file.
virtual FGPositioned * source() const
The Positioned associated with this element, if one exists.
WayptVec expandToWaypoints(WayptRef aPreceeding) const
void writeToProperties(SGPropertyNode_ptr aProp) const override
Persistence helper - save this element to a node.
SGGeod position() const override
std::string ident() const override
Identifier assoicated with the waypoint.
bool initFromProperties(SGPropertyNode_ptr aProp) override
Persistence helper - read node properties from a file.
Abstract base class for waypoints (and things that are treated similarly by navigation systems).
double altitudeFt() const
void setFlag(WayptFlag aFlag, bool aV=true)
virtual bool initFromProperties(SGPropertyNode_ptr aProp)
Persistence helper - read node properties from a file.
virtual void writeToProperties(SGPropertyNode_ptr aProp) const
Persistence helper - save this element to a node.
FlightPlan.hxx - defines a full flight-plan object, including departure, cruise, arrival information ...
SGSharedPtr< FGPositioned > FGPositionedRef
SGSharedPtr< Waypt > WayptRef
SGSharedPtr< Airway > AirwayRef
@ WPT_DYNAMIC
waypoint position is dynamic, i.e moves based on other criteria, such as altitude,...
@ WPT_GENERATED
waypoint was created automatically (not manually entered/loaded) for example waypoints from airway ro...
std::vector< WayptRef > WayptVec