X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=simgear%2Froute%2Froute.hxx;h=6e6c5805e76ffa2b267370388aa0c29fd2f940e2;hb=3b21e9434f08326bd2bb3e683938b59c68496705;hp=1eb57375a1b0f2bbd0909390844fe2c473a40294;hpb=ea47a2973cd4b84017755841a167b86dd0d2ee5d;p=simgear.git diff --git a/simgear/route/route.hxx b/simgear/route/route.hxx index 1eb57375..6e6c5805 100644 --- a/simgear/route/route.hxx +++ b/simgear/route/route.hxx @@ -32,13 +32,10 @@ # error This library requires C++ #endif - #include -#include STL_STRING #include -SG_USING_STD(string); SG_USING_STD(vector); #include @@ -55,6 +52,8 @@ private: route_list route; int current_wp; + void update_distance(int index); + public: /** Constructor */ @@ -70,21 +69,10 @@ public: } /** - * Add a waypoint. + * Add waypoint (default), or insert waypoint at position n. * @param wp a waypoint */ - inline void add_waypoint( const SGWayPoint &wp ) { - route.push_back( wp ); - - int size = route.size(); - if ( size > 1 ) { - SGWayPoint next_to_last = route[ size - 2 ]; - double tmpd, tmpc; - wp.CourseAndDistance( next_to_last, &tmpc, &tmpd ); - route[size - 1].set_distance( tmpd ); - } - } - + void add_waypoint( const SGWayPoint &wp, int n = -1 ); /** * Get the number of waypoints (i.e. route length ) * @return route length @@ -149,14 +137,7 @@ public: inline void delete_first() { delete_waypoint(0); } /** Delete waypoint waypoint with index n (last one if n < 0) */ - void delete_waypoint( int n = 0 ) { - if ( !route.size() ) - return; - if ( n < 0 || n > (int)route.size() - 1 ) - n = route.size() - 1; - - route.erase( route.begin() + n ); - } + void delete_waypoint( int n = 0 ); /** * Calculate perpendicular distance from the current route segment