X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=simgear%2Froute%2Fwaypoint.cxx;h=73669037e0f82d7d2fdb730ef1c5d54663e052c5;hb=7bdb530440d1dadc991f305edb1b70ec85f27451;hp=231b862c0a7e3d79fe820f58d4e10bfa4900d7b7;hpb=135e137921db5d87ed9c5f2aef7dc9ead00fdfda;p=simgear.git diff --git a/simgear/route/waypoint.cxx b/simgear/route/waypoint.cxx index 231b862c..73669037 100644 --- a/simgear/route/waypoint.cxx +++ b/simgear/route/waypoint.cxx @@ -16,33 +16,64 @@ // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software -// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. // // $Id$ +#ifdef HAVE_CONFIG_H +# include +#endif + +#include #include "waypoint.hxx" +using std::string; // Constructor -SGWayPoint::SGWayPoint( const double _lon, const double _lat, - const modetype _mode ) { - lon = _lon; - lat = _lat; - mode = _mode; +SGWayPoint::SGWayPoint( const double lon, const double lat, const double alt, + const modetype, const string& s, const string& n ) : + pos(SGGeod::fromDegM(lon, lat, alt)), + id(s), + name(n), + _distance(0.0), + _track(0.0), + _speed(0.0) +{ } - -SGWayPoint::SGWayPoint( const double _lon, const double _lat ) { - SGWayPoint( _lon, _lat, LATLON ); +SGWayPoint::SGWayPoint(const SGGeod& geod, const string& s, const string& n ) : + pos(geod), + id(s), + name(n), + _distance(0.0), + _track(0.0), + _speed(0.0) +{ } +// Destructor +SGWayPoint::~SGWayPoint() { +} -SGWayPoint::SGWayPoint() { - SGWayPoint( 0.0, 0.0, LATLON ); +void SGWayPoint::CourseAndDistance(const SGGeod& cur, double& course, double& dist ) const { + double reverse; + SGGeodesy::inverse(cur, pos, course, reverse, dist); } +// Calculate course and distances. For WGS84 and SPHERICAL +// coordinates lat, lon, and course are in degrees, alt and distance +// are in meters. For CARTESIAN coordinates x = lon, y = lat. Course +// is in degrees and distance is in what ever units x and y are in. +void SGWayPoint::CourseAndDistance( const double cur_lon, + const double cur_lat, + const double cur_alt, + double *course, double *dist ) const { + CourseAndDistance(SGGeod::fromDegM(cur_lon, cur_lat, cur_alt), *course, *dist); +} -// Destructor -SGWayPoint::~SGWayPoint() { +// Calculate course and distances between two waypoints +void SGWayPoint::CourseAndDistance( const SGWayPoint &wp, + double *course, double *dist ) const { + CourseAndDistance( wp.get_target(), *course, *dist ); }