X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=simgear%2Froute%2Froute.cxx;h=d0da1804035ba40b4a6038be5feaa9e7748288e1;hb=f3c131ffaf04d8e04595c1271f8a70c8a9d89f5f;hp=b3b0dfb75dadfdab5da4bda1cfb392707400f80f;hpb=030d044d03ed57d94b85c121b1ed95ee6c8a09bf;p=simgear.git diff --git a/simgear/route/route.cxx b/simgear/route/route.cxx index b3b0dfb7..d0da1804 100644 --- a/simgear/route/route.cxx +++ b/simgear/route/route.cxx @@ -24,10 +24,6 @@ # include #endif -#include - -#include - #include "route.hxx" @@ -42,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); } /** @@ -69,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) */ @@ -85,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 {