]> git.mxchange.org Git - simgear.git/blobdiff - simgear/route/route.hxx
Doxygen ...
[simgear.git] / simgear / route / route.hxx
index 7ba4601063869faf257c2a30b9912fd00368ff56..6d2da1f765f03c357a2033cf46a89ba242387d47 100644 (file)
 #include STL_STRING
 #include <vector>
 
-FG_USING_STD(string);
-FG_USING_STD(vector);
+SG_USING_STD(string);
+SG_USING_STD(vector);
 
-#include "waypoint.hxx"
+#include <simgear/route/waypoint.hxx>
 
 
 class SGRoute {
@@ -67,6 +67,14 @@ public:
     // add 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 );
+       }
     }
 
     // get the number of waypoints
@@ -119,6 +127,12 @@ public:
            route.erase( route.begin() );
        }
     }
+
+    // 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 best results, use
+    // with CARTESIAN way points.
+    double distance_off_route( double x, double y ) const;
 };