1 #include <simgear/compiler.h>
2 #include <simgear/constants.h>
7 #include "waypoint.hxx"
12 void dump_route(const SGRoute& route, const char* message)
14 cout << "Route dump: " << message << endl;
15 for (int i = 0; i < route.size(); i++) {
16 const SGWayPoint wp = route.get_waypoint(i);
17 cout << "\t#" << i << " " << wp.get_id() << " (" << wp.get_target_lat()
18 << ", " << wp.get_target_lon() << ") @" << wp.get_target_alt()
19 << " dist: " << wp.get_distance() << endl;
27 route.add_waypoint( SGWayPoint(0, 0, 0, SGWayPoint::CARTESIAN, "Start") );
28 route.add_waypoint( SGWayPoint(1, 0, 0, SGWayPoint::CARTESIAN, "1") );
29 route.add_waypoint( SGWayPoint(2, 0, 0, SGWayPoint::CARTESIAN, "2") );
30 route.add_waypoint( SGWayPoint(2, 2, 0, SGWayPoint::CARTESIAN, "3") );
31 route.add_waypoint( SGWayPoint(4, 2, 0, SGWayPoint::CARTESIAN, "4") );
33 dump_route(route, "Init");
34 route.set_current( 1 );
36 cout << "( 0.5, 0 ) = " << route.distance_off_route( 0.5, 0 ) << endl;
37 cout << "( 0.5, 1 ) = " << route.distance_off_route( 0.5, 1 ) << endl;
38 cout << "( 0.5, -1 ) = " << route.distance_off_route( 0.5, 1 ) << endl;
40 route.set_current( 3 );
42 cout << "( 2, 4 ) = " << route.distance_off_route( 2, 4 ) << endl;
43 cout << "( 2.5, 4 ) = " << route.distance_off_route( 2.5, 4 ) << endl;
45 SGWayPoint wp2 = route.get_waypoint(2);
46 route.delete_waypoint(2);
47 dump_route(route, "removed WP2");
49 route.add_waypoint(wp2, 3);
50 dump_route(route, "added back WP2 after WP3");