]> git.mxchange.org Git - simgear.git/blob - simgear/route/waytest.cxx
Patch from Melchior Franz:
[simgear.git] / simgear / route / waytest.cxx
1 #include <simgear/compiler.h>
2 #include <simgear/constants.h>
3
4 #include STL_IOSTREAM
5
6 #include "waypoint.hxx"
7
8 #if !defined(SG_HAVE_NATIVE_SGI_COMPILERS)
9 SG_USING_STD(cout);
10 SG_USING_STD(endl);
11 #endif
12
13
14 int main() {
15     SGWayPoint a1(-93.216923, 44.880547, 0.0, SGWayPoint::WGS84, "KMSP");
16     SGWayPoint a2(-93.216923, 44.880547, 0.0, SGWayPoint::SPHERICAL, "KMSP");
17
18     // KMSN (Madison)
19     double cur_lon = -89.336939;
20     double cur_lat = 43.139541;
21     double cur_alt = 0.0;
22
23     double course, distance;
24
25     a1.CourseAndDistance( cur_lon, cur_lat, cur_alt, &course, &distance );
26     cout << "Course to " << a1.get_id() << " is " << course << endl;
27     cout << "Distance to " << a1.get_id() << " is " << distance * SG_METER_TO_NM
28          << endl;
29
30     a2.CourseAndDistance( cur_lon, cur_lat, cur_alt, &course, &distance );
31     cout << "Course to " << a2.get_id() << " is " << course << endl;
32     cout << "Distance to " << a2.get_id() << " is " << distance * SG_METER_TO_NM
33          << endl;
34     cout << endl;
35
36     SGWayPoint b1(-88.237037, 43.041038, 0.0, SGWayPoint::WGS84, "KUES");
37     SGWayPoint b2(-88.237037, 43.041038, 0.0, SGWayPoint::SPHERICAL, "KUES");
38
39     b1.CourseAndDistance( cur_lon, cur_lat, cur_alt, &course, &distance );
40     cout << "Course to " << b1.get_id() << " is " << course << endl;
41     cout << "Distance to " << b1.get_id() << " is " << distance * SG_METER_TO_NM
42          << endl;
43
44     b2.CourseAndDistance( cur_lon, cur_lat, cur_alt, &course, &distance );
45     cout << "Course to " << b2.get_id() << " is " << course << endl;
46     cout << "Distance to " << b2.get_id() << " is " << distance * SG_METER_TO_NM
47          << endl;
48     cout << endl;
49
50     cur_lon = 10;
51     cur_lat = 10;
52
53     SGWayPoint c1(-20, 10, 0, SGWayPoint::CARTESIAN, "Due East");
54     c1.CourseAndDistance( cur_lon, cur_lat, cur_alt, &course, &distance );
55     cout << "Course to " << c1.get_id() << " is " << course << endl;
56     cout << "Distance to " << c1.get_id() << " is " << distance << endl;
57    
58     SGWayPoint c2(20, 20, 0, SGWayPoint::CARTESIAN, "Due SW");
59     c2.CourseAndDistance( cur_lon, cur_lat, cur_alt, &course, &distance );
60     cout << "Course to " << c2.get_id() << " is " << course << endl;
61     cout << "Distance to " << c2.get_id() << " is " << distance << endl;
62    
63     SGWayPoint c3(20, 0, 0, SGWayPoint::CARTESIAN, "Due NW");
64     c3.CourseAndDistance( cur_lon, cur_lat, cur_alt, &course, &distance );
65     cout << "Course to " << c3.get_id() << " is " << course << endl;
66     cout << "Distance to " << c3.get_id() << " is " << distance << endl;
67    
68     return 0;
69 }