1 // route.hxx -- Class to manage a list of waypoints (route)
3 // Written by Curtis Olson, started October 2000.
5 // Copyright (C) 2000 Curtis L. Olson - curt@hfrl.umn.edu
7 // This program is free software; you can redistribute it and/or
8 // modify it under the terms of the GNU General Public License as
9 // published by the Free Software Foundation; either version 2 of the
10 // License, or (at your option) any later version.
12 // This program is distributed in the hope that it will be useful, but
13 // WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 // General Public License for more details.
17 // You should have received a copy of the GNU General Public License
18 // along with this program; if not, write to the Free Software
19 // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
29 # error This library requires C++
37 #include <simgear/compiler.h>
45 #include "waypoint.hxx"
52 typedef vector < SGWayPoint > route_list;
61 // clear the entire route
68 inline void add_waypoint( const SGWayPoint &wp ) {
69 route.push_back( wp );
72 // get the number of waypoints
73 inline int size() const { return route.size(); }
75 // get the front waypoint
76 inline SGWayPoint get_first() const {
80 return SGWayPoint( 0.0, 0.0, 0.0, SGWayPoint::WGS84, "invalid" );
84 // get the current waypoint
85 inline SGWayPoint get_current() const {
86 if ( current_wp < (int)route.size() ) {
87 return route[current_wp];
89 return SGWayPoint( 0.0, 0.0, 0.0, SGWayPoint::WGS84, "invalid" );
93 // set the current waypoint
94 inline void set_current( int n ) {
95 if ( n >= 0 && n < (int)route.size() ) {
100 // increment the current waypoint
101 inline void increment_current() {
102 if ( current_wp < (int)route.size() - 1 ) {
107 // get the nth waypoint
108 inline SGWayPoint get_waypoint( const int n ) const {
109 if ( n < (int)route.size() ) {
112 return SGWayPoint( 0.0, 0.0, 0.0, SGWayPoint::WGS84, "invalid" );
116 // delete the front waypoint
117 inline void delete_first() {
118 if ( route.size() ) {
119 route.erase( route.begin() );