]> git.mxchange.org Git - simgear.git/blob - simgear/route/routetest.cxx
Merge branch 'maint'
[simgear.git] / simgear / route / routetest.cxx
1 #include <simgear/compiler.h>
2 #include <simgear/constants.h>
3
4 #include <iostream>
5
6 #include "route.hxx"
7 #include "waypoint.hxx"
8
9 using std::cout;
10 using std::endl;
11
12 void dump_route(const SGRoute& route, const char* message)
13 {
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;
20     }
21 }
22
23 int main()
24 {
25     SGRoute route;
26 /*
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") );
32
33     dump_route(route, "Init");
34     route.set_current( 1 );
35
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;
39
40     route.set_current( 3 );
41
42     cout << "( 2, 4 ) = " << route.distance_off_route( 2, 4 ) << endl;
43     cout << "( 2.5, 4 ) = " << route.distance_off_route( 2.5, 4 ) << endl;
44
45     SGWayPoint wp2 = route.get_waypoint(2);
46     route.delete_waypoint(2);
47     dump_route(route, "removed WP2");
48
49     route.add_waypoint(wp2, 3);
50     dump_route(route, "added back WP2 after WP3");
51 */
52     return 0;
53 }