3 * Provides a class to manage waypoints
6 // Written by Curtis Olson, started September 2000.
8 // Copyright (C) 2000 Curtis L. Olson - curt@hfrl.umn.edu
10 // This program is free software; you can redistribute it and/or
11 // modify it under the terms of the GNU General Public License as
12 // published by the Free Software Foundation; either version 2 of the
13 // License, or (at your option) any later version.
15 // This program is distributed in the hope that it will be useful, but
16 // WITHOUT ANY WARRANTY; without even the implied warranty of
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 // General Public License for more details.
20 // You should have received a copy of the GNU General Public License
21 // along with this program; if not, write to the Free Software
22 // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
32 # error This library requires C++
36 #include <simgear/compiler.h>
44 * A class to manage waypoints.
53 * <li> WGS84 requests all bearing and distance math be done assuming a
54 * WGS84 ellipsoid world. This is the most expensive computationally,
55 * but also the most accurate.
56 * <li> SPHERICAL requests all bearing and distance math be done assuming
57 * the world is a perfect sphere. This is less compuntationally
58 * expensive than using wgs84 math and still a fairly good
59 * approximation of the real world, especially over shorter distances.
60 * <li> CARTESIAN requests all math be done assuming the coordinates specify
61 * position in a Z = up world.
82 /** Default constructor */
86 * Construct a waypoint
87 * @param lon destination longitude
88 * @param lat destination latitude
89 * @param alt target altitude
90 * @param mode type of coordinates/math to use
91 * @param s waypoint identifier
93 SGWayPoint( const double lon, const double lat, const double alt,
94 const modetype m = WGS84, const string s = "" );
100 * Calculate course and distances. For WGS84 and SPHERICAL
101 * coordinates lat, lon, and course are in degrees, alt and
102 * distance are in meters. For CARTESIAN coordinates x = lon, y =
103 * lat. Course is in degrees and distance is in what ever units x
105 * @param cur_lon (in) current longitude
106 * @param cur_lat (in) current latitude
107 * @param cur_alt (in) current altitude
108 * @param course (out) heading from current location to this waypoint
109 * @param distance (out) distance from current location to this waypoint
111 void CourseAndDistance( const double cur_lon, const double cur_lat,
112 const double cur_alt,
113 double *course, double *distance ) const;
116 * Calculate course and distances between a specified starting waypoint
118 * @param wp (in) original waypoint
119 * @param course (out) heading from current location to this waypoint
120 * @param distance (out) distance from current location to this waypoint
122 void CourseAndDistance( const SGWayPoint &wp,
123 double *course, double *distance ) const;
125 /** @return waypoint mode */
126 inline modetype get_mode() const { return mode; }
128 /** @return waypoint longitude */
129 inline double get_target_lon() const { return target_lon; }
131 /** @return waypoint latitude */
132 inline double get_target_lat() const { return target_lat; }
134 /** @return waypoint altitude */
135 inline double get_target_alt() const { return target_alt; }
138 * This value is not calculated by this class. It is simply a
139 * placeholder for the user to stash a distance value. This is useful
140 * when you stack waypoints together into a route. You can calculate the
141 * distance from the previous waypoint once and save it here. Adding up
142 * all the distances here plus the distance to the first waypoint gives you
143 * the total route length. Note, you must update this value yourself, this
144 * is for your convenience only.
145 * @return waypoint distance holder (what ever the user has stashed here)
147 inline double get_distance() const { return distance; }
150 * Set the waypoint distance value to a value of our choice.
153 inline void set_distance( double d ) { distance = d; }
155 /** @return waypoint id */
156 inline string get_id() const { return id; }
161 #endif // _WAYPOINT_HXX