X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=simgear%2Froute%2Froute.hxx;h=6c5c5c876d8901cb334738a8e007c94e18b0dfcc;hb=f3c131ffaf04d8e04595c1271f8a70c8a9d89f5f;hp=0b3701f1bef66ae2eccef6e5f66507663c283d64;hpb=d4c7e950927b1e19a7a7622a7919f32233a6b7a8;p=simgear.git diff --git a/simgear/route/route.hxx b/simgear/route/route.hxx index 0b3701f1..6c5c5c87 100644 --- a/simgear/route/route.hxx +++ b/simgear/route/route.hxx @@ -52,7 +52,7 @@ private: route_list route; int current_wp; - void update_distance(int index); + void update_distance_and_track(int index); public: @@ -102,6 +102,22 @@ public: return SGWayPoint( 0.0, 0.0, 0.0, SGWayPoint::WGS84, "invalid" ); } } + + inline SGWayPoint get_previous() const { + if ( (current_wp > 0) && (current_wp < (int)route.size()) ) { + return route[current_wp - 1]; + } else { + return SGWayPoint( 0.0, 0.0, 0.0, SGWayPoint::WGS84, "invalid" ); + } + } + + inline SGWayPoint get_next() const { + if ( (current_wp + 1) < (int)route.size() ) { + return route[current_wp+1]; + } else { + return SGWayPoint( 0.0, 0.0, 0.0, SGWayPoint::WGS84, "invalid" ); + } + } /** * Set the current waypoint @@ -113,6 +129,10 @@ public: } } + inline int current_index() const { + return current_wp; + } + /** Increment the current waypoint pointer. */ inline void increment_current() { if ( current_wp < (int)route.size() - 1 ) { @@ -138,14 +158,11 @@ public: /** Delete waypoint waypoint with index n (last one if n < 0) */ void delete_waypoint( int n = 0 ); - + /** - * Calculate perpendicular distance from the current route segment - * This routine assumes all points are laying on a flat plane and - * ignores the altitude (or Z) dimension. For most accurate - * results, use with CARTESIAN way points. + * Helper, sum the distance members of each waypoint */ - double distance_off_route( double x, double y ) const; + double total_distance() const; };