head 1.4; access; symbols; locks; strict; comment @# @; 1.4 date 2002.09.07.01.50.39; author curt; state Exp; branches; next 1.3; 1.3 date 2002.08.31.19.01.56; author curt; state Exp; branches; next 1.2; 1.2 date 2002.08.31.18.54.03; author curt; state Exp; branches; next 1.1; 1.1 date 2002.02.15.17.21.59; author curt; state Exp; branches; next ; desc @@ 1.4 log @Updated doxygen docs. @ text @
Main Page Class Hierarchy Compound List File List Compound Members File Members

# route.hxx

Go to the documentation of this file.

    00001
    00006 // Written by Curtis Olson, started October 2000.
    00007 //
    00008 // Copyright (C) 2000  Curtis L. Olson  - curt@@hfrl.umn.edu
    00009 //
    00010 // This program is free software; you can redistribute it and/or
    00011 // modify it under the terms of the GNU General Public License as
    00012 // published by the Free Software Foundation; either version 2 of the
    00013 // License, or (at your option) any later version.
    00014 //
    00015 // This program is distributed in the hope that it will be useful, but
    00016 // WITHOUT ANY WARRANTY; without even the implied warranty of
    00017 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    00018 // General Public License for more details.
    00019 //
    00020 // You should have received a copy of the GNU General Public License
    00021 // along with this program; if not, write to the Free Software
    00022 // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
    00023 //
    00024 // $Id: route.hxx,v 1.7 2001/05/15 19:26:24 curt Exp $
    00025
    00026
    00027 #ifndef _ROUTE_HXX
    00028 #define _ROUTE_HXX
    00029
    00030
    00031 #ifndef __cplusplus
    00032 # error This library requires C++
    00033 #endif
    00034
    00035
    00036 #include <simgear/compiler.h>
    00037
    00038 #include STL_STRING
    00039 #include <vector>
    00040
    00041 SG_USING_STD(string);
    00042 SG_USING_STD(vector);
    00043
    00044 #include <simgear/route/waypoint.hxx>
    00045
    00050 class SGRoute {
    00051
    00052 private:
    00053
    00054     typedef vector < SGWayPoint > route_list;
    00055     route_list route;
    00056     int current_wp;
    00057
    00058 public:
    00059
    00061     SGRoute();
    00062
    00064     ~SGRoute();
    00065
    00067     inline void clear() {
    00068         route.clear();
    00069         current_wp = 0;
    00070     }
    00071
    00076     inline void add_waypoint( const SGWayPoint &wp ) {
    00077         route.push_back( wp );
    00078
    00079         int size = route.size();
    00080         if ( size > 1 ) {
    00081             SGWayPoint next_to_last = route[ size - 2 ];
    00082             double tmpd, tmpc;
    00083             wp.CourseAndDistance( next_to_last, &tmpc, &tmpd );
    00084             route[size - 1].set_distance( tmpd );
    00085         }
    00086     }
    00087
    00092     inline int size() const { return route.size(); }
    00093
    00098     inline SGWayPoint get_first() const {
    00099         if ( route.size() ) {
    00100             return route[0];
    00101         } else {
    00102             return SGWayPoint( 0.0, 0.0, 0.0, SGWayPoint::WGS84, "invalid" );
    00103         }
    00104     }
    00105
    00110     inline SGWayPoint get_current() const {
    00111         if ( current_wp < (int)route.size() ) {
    00112             return route[current_wp];
    00113         } else {
    00114             return SGWayPoint( 0.0, 0.0, 0.0, SGWayPoint::WGS84, "invalid" );
    00115         }
    00116     }
    00117
    00122     inline void set_current( int n ) {
    00123         if ( n >= 0 && n < (int)route.size() ) {
    00124             current_wp = n;
    00125         }
    00126     }
    00127
    00129     inline void increment_current() {
    00130         if ( current_wp < (int)route.size() - 1 ) {
    00131             ++current_wp;
    00132         }
    00133     }
    00134
    00140     inline SGWayPoint get_waypoint( const int n ) const {
    00141         if ( n < (int)route.size() ) {
    00142             return route[n];
    00143         } else {
    00144             return SGWayPoint( 0.0, 0.0, 0.0, SGWayPoint::WGS84, "invalid" );
    00145         }
    00146     }
    00147
    00149     inline void delete_first() {
    00150         if ( route.size() ) {
    00151             route.erase( route.begin() );
    00152         }
    00153     }
    00154
    00161     double distance_off_route( double x, double y ) const;
    00162 };
    00163
    00164
    00165 #endif // _ROUTE_HXX

@ 1.3 log @Oops, try again. @ text @d130 1 a130 1