X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=simgear%2Froute%2Froute.cxx;h=d0da1804035ba40b4a6038be5feaa9e7748288e1;hb=7bdb530440d1dadc991f305edb1b70ec85f27451;hp=431ceea124d80f99d2560f7989e0ab3654500fa4;hpb=03a7d72a62eb3f2a15242146b7b43ac54ab1fa44;p=simgear.git diff --git a/simgear/route/route.cxx b/simgear/route/route.cxx index 431ceea1..d0da1804 100644 --- a/simgear/route/route.cxx +++ b/simgear/route/route.cxx @@ -20,10 +20,9 @@ // // $Id$ - -#include - -#include +#ifdef HAVE_CONFIG_H +# include +#endif #include "route.hxx" @@ -39,19 +38,21 @@ SGRoute::~SGRoute() { } /** Update the length of the leg ending at waypoint index */ -void SGRoute::update_distance(int index) +void SGRoute::update_distance_and_track(int index) { - SGWayPoint& curr = route[ index ]; - double course, dist; + SGWayPoint& curr = route[ index ]; + double course, dist; - if ( index == 0 ) { - dist = 0; - } else { - const SGWayPoint& prev = route[ index - 1 ]; - curr.CourseAndDistance( prev, &course, &dist ); - } + if ( index == 0 ) { + dist = 0; + course = 0.0; + } else { + const SGWayPoint& prev = route[index - 1]; + curr.CourseAndDistance( prev, &course, &dist ); + } - curr.set_distance( dist ); + curr.set_distance(dist); + curr.set_track(course); } /** @@ -66,9 +67,9 @@ void SGRoute::add_waypoint( const SGWayPoint &wp, int n ) { } else { route.insert( route.begin() + n, 1, wp ); // update distance of next leg if not at end of route - update_distance( n + 1 ); + update_distance_and_track( n + 1 ); } - update_distance( n ); + update_distance_and_track( n ); } /** Delete waypoint with index n (last one if n < 0) */ @@ -82,7 +83,7 @@ void SGRoute::delete_waypoint( int n ) { route.erase( route.begin() + n ); // update distance of next leg if not at end of route if ( n < size - 1 ) - update_distance( n ); + update_distance_and_track( n ); } double SGRoute::total_distance() const {