X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=simgear%2Froute%2Fwaypoint.hxx;h=275d648e6811b822ed4941dd92d74eb1e3ebbe32;hb=7bdb530440d1dadc991f305edb1b70ec85f27451;hp=6f37fa566c65e733a9e1b1fe461c2f66710b9df2;hpb=733e6fa14ff507a1022ecab8d55cc9bf587bee40;p=simgear.git diff --git a/simgear/route/waypoint.hxx b/simgear/route/waypoint.hxx index 6f37fa56..275d648e 100644 --- a/simgear/route/waypoint.hxx +++ b/simgear/route/waypoint.hxx @@ -27,17 +27,12 @@ #ifndef _WAYPOINT_HXX #define _WAYPOINT_HXX - -#ifndef __cplusplus -# error This library requires C++ -#endif - - #include -#include +#include +#include -SG_USING_STD(string); +#include /** @@ -57,27 +52,21 @@ public: * the world is a perfect sphere. This is less compuntationally * expensive than using wgs84 math and still a fairly good * approximation of the real world, especially over shorter distances. - *
  • CARTESIAN requests all math be done assuming the coordinates specify - * position in a Z = up world. */ enum modetype { WGS84 = 0, - SPHERICAL = 1, - CARTESIAN = 2 }; private: - - modetype mode; - - double target_lon; - double target_lat; - double target_alt; - double distance; - - string id; - string name; - + SGGeod pos; + std::string id; + std::string name; + + // route data associated with the waypoint + double _distance; + double _track; + double _speed; + public: /** @@ -91,7 +80,12 @@ public: */ SGWayPoint( const double lon = 0.0, const double lat = 0.0, const double alt = 0.0, const modetype m = WGS84, - const string& s = "", const string& n = "" ); + const std::string& s = "", const std::string& n = "" ); + + /** + * Construct from a geodetic position, in WGS84 coordinates + */ + SGWayPoint(const SGGeod& pos, const std::string& s, const std::string& n); /** Destructor */ ~SGWayPoint(); @@ -112,6 +106,9 @@ public: const double cur_alt, double *course, double *dist ) const; + void CourseAndDistance(const SGGeod& current, + double& course, double& dist ) const; + /** * Calculate course and distances between a specified starting waypoint * and this waypoint. @@ -122,17 +119,22 @@ public: void CourseAndDistance( const SGWayPoint &wp, double *course, double *dist ) const; - /** @return waypoint mode */ - inline modetype get_mode() const { return mode; } - /** @return waypoint longitude */ - inline double get_target_lon() const { return target_lon; } + inline double get_target_lon() const { return pos.getLongitudeDeg(); } /** @return waypoint latitude */ - inline double get_target_lat() const { return target_lat; } + inline double get_target_lat() const { return pos.getLatitudeDeg(); } /** @return waypoint altitude */ - inline double get_target_alt() const { return target_alt; } + inline double get_target_alt() const { return pos.getElevationM(); } + + inline const SGGeod& get_target() const { return pos; } + + /** + * + */ + inline void setTargetAltFt(double elev) + { pos.setElevationFt(elev); } /** * This value is not calculated by this class. It is simply a @@ -144,19 +146,25 @@ public: * is for your convenience only. * @return waypoint distance holder (what ever the user has stashed here) */ - inline double get_distance() const { return distance; } + inline double get_distance() const { return _distance; } /** * Set the waypoint distance value to a value of our choice. * @param d distance */ - inline void set_distance( double d ) { distance = d; } + inline void set_distance( double d ) { _distance = d; } + + inline double get_track() const { return _track; } + inline void set_track(double t) { _track = t; } + inline double get_speed() const { return _speed; } + inline void set_speed(double v) { _speed = v; } + /** @return waypoint id */ - inline const string& get_id() const { return id; } + inline const std::string& get_id() const { return id; } /** @return waypoint name */ - inline const string& get_name() const { return name; } + inline const std::string& get_name() const { return name; } };