X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=simgear%2Froute%2Froutetest.cxx;h=3d59e0de6668faa06fa03dadccfd6e4d6b72906a;hb=7fe40bce86ebd460d06ae8e76d3c64a6c9d58379;hp=313ed528b764615e3de6831e68608b27b9b36f30;hpb=30a14741c9d433abbb3986200e235db2edb93f36;p=simgear.git diff --git a/simgear/route/routetest.cxx b/simgear/route/routetest.cxx index 313ed528..3d59e0de 100644 --- a/simgear/route/routetest.cxx +++ b/simgear/route/routetest.cxx @@ -1,25 +1,36 @@ #include #include -#include STL_IOSTREAM +#include #include "route.hxx" #include "waypoint.hxx" -#if !defined(SG_HAVE_NATIVE_SGI_COMPILERS) -SG_USING_STD(cout); -SG_USING_STD(endl); -#endif - -int main() { - SGRoute route; +using std::cout; +using std::endl; + +void dump_route(const SGRoute& route, const char* message) +{ + cout << "Route dump: " << message << endl; + for (int i = 0; i < route.size(); i++) { + const SGWayPoint wp = route.get_waypoint(i); + cout << "\t#" << i << " " << wp.get_id() << " (" << wp.get_target_lat() + << ", " << wp.get_target_lon() << ") @" << wp.get_target_alt() + << " dist: " << wp.get_distance() << endl; + } +} +int main() +{ + SGRoute route; +/* route.add_waypoint( SGWayPoint(0, 0, 0, SGWayPoint::CARTESIAN, "Start") ); route.add_waypoint( SGWayPoint(1, 0, 0, SGWayPoint::CARTESIAN, "1") ); route.add_waypoint( SGWayPoint(2, 0, 0, SGWayPoint::CARTESIAN, "2") ); route.add_waypoint( SGWayPoint(2, 2, 0, SGWayPoint::CARTESIAN, "3") ); route.add_waypoint( SGWayPoint(4, 2, 0, SGWayPoint::CARTESIAN, "4") ); - + + dump_route(route, "Init"); route.set_current( 1 ); cout << "( 0.5, 0 ) = " << route.distance_off_route( 0.5, 0 ) << endl; @@ -31,5 +42,12 @@ int main() { cout << "( 2, 4 ) = " << route.distance_off_route( 2, 4 ) << endl; cout << "( 2.5, 4 ) = " << route.distance_off_route( 2.5, 4 ) << endl; + SGWayPoint wp2 = route.get_waypoint(2); + route.delete_waypoint(2); + dump_route(route, "removed WP2"); + + route.add_waypoint(wp2, 3); + dump_route(route, "added back WP2 after WP3"); +*/ return 0; }