1 using namespace System;
2 using namespace NETGeographicLib;
3 
4 int main(array<System::String ^> ^/*args*/)
5 {
6     try {
7         // Print waypoints between JFK and SIN
8         GeodesicExact^ geod = gcnew GeodesicExact(); // WGS84
9         double
10             lat1 = 40.640, lon1 = -73.779, // JFK
11             lat2 =  1.359, lon2 = 103.989; // SIN
12         double s12, azi1, azi2,
13             a12 = geod->Inverse(lat1, lon1, lat2, lon2, s12, azi1, azi2);
14         GeodesicLineExact^ line = gcnew GeodesicLineExact(geod, lat1, lon1, azi1, Mask::ALL);
15         // Alternatively
16         // const GeographicLib::GeodesicLine line = geod.Line(lat1, lon1, azi1);
17         double ds0 = 500e3;     // Nominal distance between points = 500 km
18         int num = int(Math::Ceiling(s12 / ds0)); // The number of intervals
19         {
20             // Use intervals of equal length
21             double ds = s12 / num;
22             for (int i = 0; i <= num; ++i) {
23                 double lat, lon;
24                 line->Position(i * ds, lat, lon);
25                 Console::WriteLine( String::Format( "i: {0} Latitude: {1} Longitude: {2}", i, lat, lon ));
26             }
27         }
28         {
29             // Slightly faster, use intervals of equal arc length
30             double da = a12 / num;
31             for (int i = 0; i <= num; ++i) {
32                 double lat, lon;
33                 line->ArcPosition(i * da, lat, lon);
34                 Console::WriteLine( String::Format( "i: {0} Latitude: {1} Longitude: {2}", i, lat, lon ));
35             }
36         }
37     }
38     catch (GeographicErr^ e) {
39         Console::WriteLine(String::Format("Caught exception: {0}", e->Message));
40         return -1;
41     }
42     return 0;
43 }
44