24#ifndef FG_FLIGHTPLAN_HXX
25#define FG_FLIGHTPLAN_HXX
72 virtual std::string
ident()
const;
88 {
return _aircraftType; }
92 FlightPlanRef clone(
const std::string& newIdent = {},
bool convertToFlightPlan =
false)
const;
104 class Leg :
public SGReferenced
131 unsigned int index()
const;
163 void writeToProperties(SGPropertyNode* node)
const;
169 double _altitude = 0.0;
181 mutable double _pathDistance = -1.0;
182 mutable double _courseDeg = -1.0;
184 mutable double _distanceAlongPath = 11.0;
237 {
return _currentIndex; }
254 {
return static_cast<int>(_legs.size()); }
266 bool load(
const SGPath&
p);
267 bool save(
const SGPath&
p)
const;
269 bool save(std::ostream& stream)
const;
270 bool load(std::istream& stream);
273 {
return _departure; }
276 {
return _destination; }
279 {
return _departureRunway; }
282 {
return _destinationRunway; }
285 {
return _approach; }
297 void setSID(
SID*
sid,
const std::string& transition = std::string());
327 void setSTAR(
STAR*
star,
const std::string& transition = std::string());
334 {
return _totalDistance; }
337 {
return _estimatedDuration; }
398 {
return _callsign; }
447 int findLegIndex(
const Leg* l)
const;
449 void lockDelegates();
450 void unlockDelegates();
452 void notifyCleared();
454 unsigned int _delegateLock = 0;
455 bool _arrivalChanged =
false,
456 _departureChanged =
false,
457 _waypointsChanged =
false,
458 _currentWaypointChanged =
false,
459 _cruiseDataChanged =
false;
460 bool _didLoadFP =
false;
462 void saveToProperties(SGPropertyNode* d)
const;
464 bool loadXmlFormat(
const SGPath& path);
465 bool loadGpxFormat(
const SGPath& path);
466 bool loadPlainTextFormat(
const SGPath& path);
468 bool loadVersion1XMLRoute(SGPropertyNode_ptr routeData);
469 bool loadVersion2XMLRoute(SGPropertyNode_ptr routeData);
470 void loadXMLRouteHeader(SGPropertyNode_ptr routeData);
471 WayptRef parseVersion1XMLWaypt(SGPropertyNode* aWP);
473 double magvarDegAt(
const SGGeod& pos)
const;
474 bool parseICAOLatLon(
const std::string &s, SGGeod &
p);
482 std::string _callsign;
483 std::string _remarks;
484 std::string _aircraftType;
488 bool _followLegTrackToFix;
489 char _aircraftCategory;
492 int _cruiseAirspeedKnots = 0;
493 double _cruiseAirspeedMach = 0.0;
494 int _cruiseAirspeedKph = 0;
495 int _cruiseFlightLevel = 0;
496 int _cruiseAltitudeFt = 0;
497 int _cruiseAltitudeM = 0;
498 int _estimatedDuration = 0;
499 double _maxFlyByTurnAngle = 90.0;
503 FGRunway *_departureRunway, *_destinationRunway;
504 SGSharedPtr<SID> _sid;
505 SGSharedPtr<STAR> _star;
506 SGSharedPtr<Approach> _approach;
507 std::string _sidTransition, _starTransition, _approachTransition;
509 double _totalDistance;
510 void rebuildLegData();
512 using LegVec = std::vector<LegRef>;
515 std::vector<Delegate*> _delegates;
SGSharedPtr< FGAirport > FGAirportRef
Describe an approach procedure, including the missed approach segment.
abstract interface for creating delegates automatically when a flight-plan is created or loaded
virtual Delegate * createFlightPlanDelegate(FlightPlan *fp)=0
virtual void destroyFlightPlanDelegate(FlightPlan *fp, Delegate *d)
virtual void waypointsChanged()
virtual void currentWaypointChanged()
virtual void departureChanged()
virtual void cruiseChanged()
virtual void endOfFlightPlan()
virtual void sequence()
Invoked when the C++ code determines the active leg is done / next leg should be sequenced.
virtual void arrivalChanged()
flight-plan leg encapsulation
bool convertWaypointToHold()
double speed(RouteUnits units=DEFAULT_UNITS) const
double distanceAlongRoute() const
RouteRestriction altitudeRestriction() const
void setSpeed(RouteRestriction ty, double speed, RouteUnits units=DEFAULT_UNITS)
RouteRestriction speedRestriction() const
bool setHoldCount(int count)
requesting holding at the waypoint upon reaching it.
double distanceNm() const
void markWaypointDirty()
helper function, if the waypoint is modified in some way, to notify the flightplan owning this leg,...
unsigned int index() const
FlightPlan * owner() const
void setAltitude(RouteRestriction ty, double alt, RouteUnits units=DEFAULT_UNITS)
ICAOFlightType flightType() const
int cruiseSpeedKnots() const
void setCruiseSpeedMach(double mach)
int cruiseAltitudeM() const
std::string icaoAircraftCategory() const
SGSharedPtr< Leg > LegRef
void setAlternate(FGAirportRef alt)
void deleteIndex(int index)
Approach * approach() const
std::shared_ptr< DelegateFactory > DelegateFactoryRef
FGAirportRef departureAirport() const
double maxFlyByTurnAngle() const
int indexOfFirstNonDepartureWaypoint() const
int indexOfFirstApproachWaypoint() const
std::string remarks() const
SGGeod vicinityForInsertIndex(int aIndex) const
given an index to insert a waypoint into the plan, find the geographical vicinity.
int clearWayptsWithFlag(WayptFlag flag)
LegRef currentLeg() const
bool parseICAORouteString(const std::string &routeData)
attempt to replace the route waypoints (and potentially the SID and STAR) based on an ICAO standard r...
void setSID(SID *sid, const std::string &transition=std::string())
int indexOfFirstArrivalWaypoint() const
void insertWayptsAtIndex(const WayptVec &wps, int aIndex)
FlightPlanRef clone(const std::string &newIdent={}, bool convertToFlightPlan=false) const
void setCruiseSpeedKPH(int kmh)
static void unregisterDelegateFactory(DelegateFactoryRef df)
void setSTAR(STAR *star, const std::string &transition=std::string())
std::string callsign() const
bool isRoute() const
is this flight-pan a route (for planning) or an active flight-plan (which can be flown?...
static FlightPlanRef create()
create a FlightPlan with isRoute not set
void setEstimatedDurationMinutes(int minutes)
void forEachLeg(const LegVisitor &lv)
void setCruiseFlightLevel(int flightLevel)
void setDeparture(FGAirport *apt)
double totalDistanceNm() const
FGRunway * destinationRunway() const
std::string asICAORouteString() const
void setCruiseAltitudeFt(int altFt)
FGAirportRef alternate() const
void setFlightRules(ICAOFlightRules rules)
double cruiseSpeedMach() const
int cruiseSpeedKPH() const
void setIcaoAircraftType(const std::string &ty)
LegRef insertWayptAtIndex(Waypt *aWpt, int aIndex)
FGRunway * departureRunway() const
void setRemarks(const std::string &remarks)
void setApproach(Approach *app, const std::string &transition={})
note setting an approach will implicitly update the destination airport and runway to match
int estimatedDurationMinutes() const
LegRef previousLeg() const
int cruiseFlightLevel() const
void addDelegate(Delegate *d)
bool followLegTrackToFixes() const
void setDestination(FGAirport *apt)
void setCallsign(const std::string &callsign)
void setFlightType(ICAOFlightType type)
Transition * approachTransition() const
int cruiseAltitudeFt() const
virtual std::string ident() const
int findWayptIndex(const SGGeod &aPos) const
void setIdent(const std::string &s)
void setCurrentIndex(int index)
LegRef legAtIndex(int index) const
void setCruiseSpeedKnots(int kts)
bool load(const SGPath &p)
void setFollowLegTrackToFixes(bool tf)
FGAirportRef destinationAirport() const
WayptRef waypointFromString(const std::string &target, const SGGeod &vicinity=SGGeod::invalid())
Create a WayPoint from a string in the following format:'vicinity' specifies the search area,...
bool save(const SGPath &p) const
void setMaxFlyByTurnAngle(double deg)
static void registerDelegateFactory(DelegateFactoryRef df)
Transition * sidTransition() const
SGGeod pointAlongRoute(int aIndex, double aOffsetNm) const
given a waypoint index, and an offset in NM, find the geodetic position on the route path.
void removeDelegate(Delegate *d)
std::string icaoAircraftType() const
SGGeod pointAlongRouteNorm(int aIndex, double aOffsetNorm) const
given a waypoint index, find a point at a normalised offset, which must be [-1 .
std::function< void(Leg *)> LegVisitor
void setIcaoAircraftCategory(const std::string &cat)
int indexOfDestinationRunwayWaypoint() const
void computeDurationMinutes()
computeDurationMinutes - use performance data and cruise data to estimate enroute time
static FlightPlanRef createRoute()
@factory to create a FlightPlan with isRoute=true
void setCruiseAltitudeM(int altM)
ICAOFlightRules flightRules() const
Transition * starTransition() const
Encapsulate a transition segment.
Abstract base class for waypoints (and things that are treated similarly by navigation systems).
FlightPlan.hxx - defines a full flight-plan object, including departure, cruise, arrival information ...
SGSharedPtr< FlightPlan > FlightPlanRef
SGSharedPtr< FGPositioned > FGPositionedRef
SGSharedPtr< Waypt > WayptRef
std::vector< WayptRef > WayptVec