00001 #include <simgear/compiler.h> 00002 #include <simgear/constants.h> 00003 00004 #include <iostream> 00005 00006 #include "route.hxx" 00007 #include "waypoint.hxx" 00008 00009 using std::cout; 00010 using std::endl; 00011 00012 void dump_route(const SGRoute& route, const char* message) 00013 { 00014 cout << "Route dump: " << message << endl; 00015 for (int i = 0; i < route.size(); i++) { 00016 const SGWayPoint wp = route.get_waypoint(i); 00017 cout << "\t#" << i << " " << wp.get_id() << " (" << wp.get_target_lat() 00018 << ", " << wp.get_target_lon() << ") @" << wp.get_target_alt() 00019 << " dist: " << wp.get_distance() << endl; 00020 } 00021 } 00022 00023 int main() 00024 { 00025 SGRoute route; 00026 /* 00027 route.add_waypoint( SGWayPoint(0, 0, 0, SGWayPoint::CARTESIAN, "Start") ); 00028 route.add_waypoint( SGWayPoint(1, 0, 0, SGWayPoint::CARTESIAN, "1") ); 00029 route.add_waypoint( SGWayPoint(2, 0, 0, SGWayPoint::CARTESIAN, "2") ); 00030 route.add_waypoint( SGWayPoint(2, 2, 0, SGWayPoint::CARTESIAN, "3") ); 00031 route.add_waypoint( SGWayPoint(4, 2, 0, SGWayPoint::CARTESIAN, "4") ); 00032 00033 dump_route(route, "Init"); 00034 route.set_current( 1 ); 00035 00036 cout << "( 0.5, 0 ) = " << route.distance_off_route( 0.5, 0 ) << endl; 00037 cout << "( 0.5, 1 ) = " << route.distance_off_route( 0.5, 1 ) << endl; 00038 cout << "( 0.5, -1 ) = " << route.distance_off_route( 0.5, 1 ) << endl; 00039 00040 route.set_current( 3 ); 00041 00042 cout << "( 2, 4 ) = " << route.distance_off_route( 2, 4 ) << endl; 00043 cout << "( 2.5, 4 ) = " << route.distance_off_route( 2.5, 4 ) << endl; 00044 00045 SGWayPoint wp2 = route.get_waypoint(2); 00046 route.delete_waypoint(2); 00047 dump_route(route, "removed WP2"); 00048 00049 route.add_waypoint(wp2, 3); 00050 dump_route(route, "added back WP2 after WP3"); 00051 */ 00052 return 0; 00053 }