1 /**
2 * \file NETGeographicLib/AzimuthalEquidistant.cpp
3 * \brief Implementation for NETGeographicLib::AzimuthalEquidistant class
4 *
5 * NETGeographicLib is copyright (c) Scott Heiman (2013)
6 * GeographicLib is Copyright (c) Charles Karney (2010-2012)
7 * <charles@karney.com> and licensed under the MIT/X11 License.
8 * For more information, see
9 * https://geographiclib.sourceforge.io/
10 **********************************************************************/
11 #include "stdafx.h"
12 #include "GeographicLib/AzimuthalEquidistant.hpp"
13 #include "AzimuthalEquidistant.h"
14 #include "NETGeographicLib.h"
15
16 using namespace NETGeographicLib;
17
18 const char BADALLOC[] = "Failed to allocate memory for a GeographicLib::AzimuthalEquidistant";
19
20 //*****************************************************************************
21 AzimuthalEquidistant::!AzimuthalEquidistant()
22 {
23 if ( m_pAzimuthalEquidistant != NULL )
24 {
25 delete m_pAzimuthalEquidistant;
26 m_pAzimuthalEquidistant = NULL;
27 }
28 }
29
30 //*****************************************************************************
AzimuthalEquidistant(void)31 AzimuthalEquidistant::AzimuthalEquidistant(void)
32 {
33 try
34 {
35 m_pAzimuthalEquidistant = new GeographicLib::AzimuthalEquidistant( GeographicLib::Geodesic::WGS84() );
36 }
37 catch ( std::bad_alloc )
38 {
39 throw gcnew GeographicErr( BADALLOC );
40 }
41 }
42
43 //*****************************************************************************
44 AzimuthalEquidistant::AzimuthalEquidistant( Geodesic^ g )
45 {
46 try
47 {
48 const GeographicLib::Geodesic* pGeodesic =
49 reinterpret_cast<const GeographicLib::Geodesic*>(
50 g->GetUnmanaged()->ToPointer() );
51 m_pAzimuthalEquidistant = new GeographicLib::AzimuthalEquidistant( *pGeodesic );
52 }
53 catch ( std::bad_alloc )
54 {
55 throw gcnew GeographicErr( BADALLOC );
56 }
57 }
58
59 //*****************************************************************************
60 void AzimuthalEquidistant::Forward(double lat0, double lon0, double lat, double lon,
61 double% x, double% y, double% azi, double% rk)
62 {
63 double lx, ly, lazi, lrk;
64 m_pAzimuthalEquidistant->Forward( lat0, lon0, lat, lon,
65 lx, ly, lazi, lrk );
66 x = lx;
67 y = ly;
68 azi = lazi;
69 rk = lrk;
70 }
71
72 //*****************************************************************************
73 void AzimuthalEquidistant::Reverse(double lat0, double lon0, double x, double y,
74 double% lat, double% lon, double% azi, double% rk)
75 {
76 double llat, llon, lazi, lrk;
77 m_pAzimuthalEquidistant->Reverse(lat0, lon0, x, y,
78 llat, llon, lazi, lrk);
79 lat = llat;
80 lon = llon;
81 azi = lazi;
82 rk = lrk;
83 }
84 //*****************************************************************************
85 void AzimuthalEquidistant::Forward(double lat0, double lon0, double lat, double lon,
86 double% x, double% y)
87 {
88 double azi, rk, lx, ly;
89 m_pAzimuthalEquidistant->Forward(lat0, lon0, lat, lon, lx, ly, azi, rk);
90 x = lx;
91 y = ly;
92 }
93
94 //*****************************************************************************
95 void AzimuthalEquidistant::Reverse(double lat0, double lon0, double x, double y,
96 double% lat, double% lon)
97 {
98 double azi, rk, llat, llon;
99 m_pAzimuthalEquidistant->Reverse(lat0, lon0, x, y, llat, llon, azi, rk);
100 lat = llat;
101 lon = llon;
102 }
103
104 //*****************************************************************************
get()105 double AzimuthalEquidistant::EquatorialRadius::get()
106 { return m_pAzimuthalEquidistant->EquatorialRadius(); }
107
108 //*****************************************************************************
get()109 double AzimuthalEquidistant::Flattening::get()
110 { return m_pAzimuthalEquidistant->Flattening(); }
111