2004-01-31 19:47:45 +00:00
|
|
|
// route_mgr.hxx - manage a route (i.e. a collection of waypoints)
|
|
|
|
//
|
|
|
|
// Written by Curtis Olson, started January 2004.
|
|
|
|
//
|
2004-11-19 22:10:41 +00:00
|
|
|
// Copyright (C) 2004 Curtis L. Olson - http://www.flightgear.org/~curt
|
2004-01-31 19:47:45 +00:00
|
|
|
//
|
|
|
|
// This program is free software; you can redistribute it and/or
|
|
|
|
// modify it under the terms of the GNU General Public License as
|
|
|
|
// published by the Free Software Foundation; either version 2 of the
|
|
|
|
// License, or (at your option) any later version.
|
|
|
|
//
|
|
|
|
// This program is distributed in the hope that it will be useful, but
|
|
|
|
// WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
// General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU General Public License
|
|
|
|
// along with this program; if not, write to the Free Software
|
2006-02-21 01:16:04 +00:00
|
|
|
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2004-01-31 19:47:45 +00:00
|
|
|
//
|
|
|
|
// $Id$
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef _ROUTE_MGR_HXX
|
|
|
|
#define _ROUTE_MGR_HXX 1
|
|
|
|
|
|
|
|
#include <simgear/props/props.hxx>
|
2009-10-05 21:09:20 +00:00
|
|
|
#include <simgear/route/waypoint.hxx>
|
2004-01-31 19:47:45 +00:00
|
|
|
#include <simgear/structure/subsystem_mgr.hxx>
|
|
|
|
|
2009-10-05 21:09:20 +00:00
|
|
|
// forward decls
|
|
|
|
class SGRoute;
|
|
|
|
class SGPath;
|
2004-01-31 19:47:45 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Top level route manager class
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
class FGRouteMgr : public SGSubsystem
|
|
|
|
{
|
|
|
|
|
|
|
|
private:
|
2009-10-05 21:09:20 +00:00
|
|
|
SGRoute* _route;
|
|
|
|
time_t _takeoffTime;
|
|
|
|
time_t _touchdownTime;
|
2009-10-14 06:50:06 +00:00
|
|
|
|
2004-01-31 19:47:45 +00:00
|
|
|
// automatic inputs
|
2006-04-27 15:49:47 +00:00
|
|
|
SGPropertyNode_ptr lon;
|
|
|
|
SGPropertyNode_ptr lat;
|
|
|
|
SGPropertyNode_ptr alt;
|
2009-10-05 21:09:20 +00:00
|
|
|
SGPropertyNode_ptr magvar;
|
|
|
|
|
2009-10-14 06:50:06 +00:00
|
|
|
// automatic outputs
|
2009-10-05 21:09:20 +00:00
|
|
|
SGPropertyNode_ptr departure; ///< departure airport information
|
|
|
|
SGPropertyNode_ptr destination; ///< destination airport information
|
|
|
|
SGPropertyNode_ptr alternate; ///< alternate airport information
|
|
|
|
SGPropertyNode_ptr cruise; ///< cruise information
|
|
|
|
|
|
|
|
SGPropertyNode_ptr totalDistance;
|
|
|
|
SGPropertyNode_ptr ete;
|
|
|
|
SGPropertyNode_ptr elapsedFlightTime;
|
|
|
|
|
|
|
|
SGPropertyNode_ptr active;
|
|
|
|
SGPropertyNode_ptr airborne;
|
|
|
|
SGPropertyNode_ptr currentWp;
|
|
|
|
|
|
|
|
SGPropertyNode_ptr wp0;
|
|
|
|
SGPropertyNode_ptr wp1;
|
|
|
|
SGPropertyNode_ptr wpn;
|
|
|
|
|
|
|
|
|
|
|
|
SGPropertyNode_ptr _pathNode;
|
|
|
|
|
|
|
|
void setETAPropertyFromDistance(SGPropertyNode_ptr aProp, double aDistance);
|
|
|
|
|
|
|
|
class InputListener : public SGPropertyChangeListener {
|
2006-05-08 14:35:29 +00:00
|
|
|
public:
|
2009-10-05 21:09:20 +00:00
|
|
|
InputListener(FGRouteMgr *m) : mgr(m) {}
|
2006-05-08 14:35:29 +00:00
|
|
|
virtual void valueChanged (SGPropertyNode * prop);
|
|
|
|
private:
|
|
|
|
FGRouteMgr *mgr;
|
|
|
|
};
|
|
|
|
|
|
|
|
SGPropertyNode_ptr input;
|
2009-10-05 21:09:20 +00:00
|
|
|
SGPropertyNode_ptr weightOnWheels;
|
|
|
|
|
|
|
|
InputListener *listener;
|
2006-05-08 14:35:29 +00:00
|
|
|
SGPropertyNode_ptr mirror;
|
2006-05-09 21:01:01 +00:00
|
|
|
|
2009-10-05 21:09:20 +00:00
|
|
|
/**
|
|
|
|
* Create a SGWayPoint from a string in the following format:
|
|
|
|
* - simple identifier
|
|
|
|
* - decimal-lon,decimal-lat
|
|
|
|
* - airport-id/runway-id
|
|
|
|
* - navaid/radial-deg/offset-nm
|
|
|
|
*/
|
James Turner:
Attached patch updates the route-manager to use FGPositioned to search
for waypoints, instead of a manual airport / fix / navaid search. This
is good because it's now using the 'strictly closest' match, rather
than arbitrarily picking a distant fix over a nearby navaid. In my
case, the TLA VOR is significant to several EGPH procedures, but also
happens to be the ident of a fix a long, long way away.
Also updates the FGPositioned class to stop using Point3D, partly
because it's deprecated and partly because I had misunderstood the
interface and was using it wrong. For now, all FGPositioned distance
checks use SGGeodesy::inverse, which is accurate but inefficient. Once
FGPositioned queries are used for something on a hot path, I'll
probably store the cartesian position as well as the geodetic, to make
these checks fast.
2008-12-03 20:03:46 +00:00
|
|
|
SGWayPoint* make_waypoint(const string& target);
|
2009-10-05 21:09:20 +00:00
|
|
|
|
|
|
|
|
2006-05-09 21:01:01 +00:00
|
|
|
void update_mirror();
|
2006-05-12 09:36:21 +00:00
|
|
|
bool near_ground();
|
2009-10-05 21:09:20 +00:00
|
|
|
|
|
|
|
void currentWaypointChanged();
|
2008-12-04 08:29:36 +00:00
|
|
|
|
2009-10-05 21:09:20 +00:00
|
|
|
/**
|
|
|
|
* Parse a route/wp node (from a saved, property-lsit formatted route)
|
|
|
|
*/
|
|
|
|
void parseRouteWaypoint(SGPropertyNode* aWP);
|
2004-01-31 19:47:45 +00:00
|
|
|
public:
|
|
|
|
|
|
|
|
FGRouteMgr();
|
|
|
|
~FGRouteMgr();
|
|
|
|
|
|
|
|
void init ();
|
2006-04-27 15:30:42 +00:00
|
|
|
void postinit ();
|
2004-01-31 19:47:45 +00:00
|
|
|
void bind ();
|
|
|
|
void unbind ();
|
|
|
|
void update (double dt);
|
|
|
|
|
|
|
|
bool build ();
|
|
|
|
|
James Turner:
Attached patch updates the route-manager to use FGPositioned to search
for waypoints, instead of a manual airport / fix / navaid search. This
is good because it's now using the 'strictly closest' match, rather
than arbitrarily picking a distant fix over a nearby navaid. In my
case, the TLA VOR is significant to several EGPH procedures, but also
happens to be the ident of a fix a long, long way away.
Also updates the FGPositioned class to stop using Point3D, partly
because it's deprecated and partly because I had misunderstood the
interface and was using it wrong. For now, all FGPositioned distance
checks use SGGeodesy::inverse, which is accurate but inefficient. Once
FGPositioned queries are used for something on a hot path, I'll
probably store the cartesian position as well as the geodetic, to make
these checks fast.
2008-12-03 20:03:46 +00:00
|
|
|
void new_waypoint( const string& tgt_alt, int n = -1 );
|
2006-05-08 14:35:29 +00:00
|
|
|
void add_waypoint( const SGWayPoint& wp, int n = -1 );
|
|
|
|
SGWayPoint pop_waypoint( int i = 0 );
|
2004-01-31 19:47:45 +00:00
|
|
|
|
2009-10-05 21:09:20 +00:00
|
|
|
SGWayPoint get_waypoint( int i ) const;
|
|
|
|
int size() const;
|
|
|
|
|
|
|
|
bool isRouteActive() const;
|
|
|
|
|
|
|
|
int currentWaypoint() const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Find a waypoint in the route, by position, and return its index, or
|
|
|
|
* -1 if no matching waypoint was found in the route.
|
|
|
|
*/
|
|
|
|
int findWaypoint(const SGGeod& aPos) const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Activate a built route. This checks for various mandatory pieces of
|
|
|
|
* data, such as departure and destination airports, and creates waypoints
|
|
|
|
* for them on the route structure.
|
|
|
|
*
|
|
|
|
* returns true if the route was activated successfully, or false if the
|
|
|
|
* route could not be activated for some reason
|
|
|
|
*/
|
|
|
|
bool activate();
|
2006-05-08 14:35:29 +00:00
|
|
|
|
2009-10-05 21:09:20 +00:00
|
|
|
/**
|
|
|
|
* Step to the next waypoint on the active route
|
|
|
|
*/
|
|
|
|
void sequence();
|
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
void jumpToIndex(int index);
|
|
|
|
|
|
|
|
void saveRoute();
|
|
|
|
void loadRoute();
|
2004-01-31 19:47:45 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
#endif // _ROUTE_MGR_HXX
|