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++
40 #include <simgear/compiler.h>
48 * A class to manage waypoints.
57 * <li> WGS84 requests all bearing and distance math be done assuming a
58 * WGS84 ellipsoid world. This is the most expensive computationally,
59 * but also the most accurate.
60 * <li> SPHERICAL requests all bearing and distance math be done assuming
61 * the world is a perfect sphere. This is less compuntationally
62 * expensive than using wgs84 math and still a fairly good
63 * approximation of the real world, especially over shorter distances.
64 * <li> CARTESIAN requests all math be done assuming the coordinates specify
65 * position in a Z = up world.
86 /** Default constructor */
90 * Construct a waypoint
91 * @param lon destination longitude
92 * @param lat destination latitude
93 * @param alt target altitude
94 * @param mode type of coordinates/math to use
95 * @param s waypoint identifier
97 SGWayPoint( const double lon, const double lat, const double alt,
98 const modetype m = WGS84, const string s = "" );
104 * Calculate course and distances. For WGS84 and SPHERICAL
105 * coordinates lat, lon, and course are in degrees, alt and
106 * distance are in meters. For CARTESIAN coordinates x = lon, y =
107 * lat. Course is in degrees and distance is in what ever units x
109 * @param cur_lon (in) current longitude
110 * @param cur_lat (in) current latitude
111 * @param cur_alt (in) current altitude
112 * @param course (out) heading from current location to this waypoint
113 * @param distance (out) distance from current location to this waypoint
115 void CourseAndDistance( const double cur_lon, const double cur_lat,
116 const double cur_alt,
117 double *course, double *distance ) const;
120 * Calculate course and distances between a specified starting waypoint
122 * @param wp (in) original waypoint
123 * @param course (out) heading from current location to this waypoint
124 * @param distance (out) distance from current location to this waypoint
126 void CourseAndDistance( const SGWayPoint &wp,
127 double *course, double *distance ) const;
129 /** @return waypoint mode */
130 inline modetype get_mode() const { return mode; }
132 /** @return waypoint longitude */
133 inline double get_target_lon() const { return target_lon; }
135 /** @return waypoint latitude */
136 inline double get_target_lat() const { return target_lat; }
138 /** @return waypoint altitude */
139 inline double get_target_alt() const { return target_alt; }
142 * This value is not calculated by this class. It is simply a
143 * placeholder for the user to stash a distance value. This is useful
144 * when you stack waypoints together into a route. You can calculate the
145 * distance from the previous waypoint once and save it here. Adding up
146 * all the distances here plus the distance to the first waypoint gives you
147 * the total route length. Note, you must update this value yourself, this
148 * is for your convenience only.
149 * @return waypoint distance holder (what ever the user has stashed here)
151 inline double get_distance() const { return distance; }
154 * Set the waypoint distance value to a value of our choice.
157 inline void set_distance( double d ) { distance = d; }
159 /** @return waypoint id */
160 inline string get_id() const { return id; }
165 #endif // _WAYPOINT_HXX