dotnet/NETGeographicLib/LocalCartesian.cpp
Go to the documentation of this file.
1 
11 #include "stdafx.h"
13 #include "LocalCartesian.h"
14 #include "Geocentric.h"
15 #include "NETGeographicLib.h"
16 
17 using namespace NETGeographicLib;
18 
19 const char BADALLOC[] = "Failed to allocate memory for a GeographicLib::LocalCartesian";
20 
21 //*****************************************************************************
23 {
24  if ( m_pLocalCartesian != NULL )
25  {
26  delete m_pLocalCartesian;
27  m_pLocalCartesian = NULL;
28  }
29 }
30 
31 //*****************************************************************************
32 LocalCartesian::LocalCartesian(double lat0, double lon0, double h0,
33  Geocentric^ earth )
34 {
35  try
36  {
37  const GeographicLib::Geocentric* pGeocentric =
38  reinterpret_cast<const GeographicLib::Geocentric*>(
39  earth->GetUnmanaged()->ToPointer() );
40  m_pLocalCartesian = new GeographicLib::LocalCartesian( lat0, lon0, h0, *pGeocentric );
41  }
42  catch ( std::bad_alloc )
43  {
44  throw gcnew GeographicErr( BADALLOC );
45  }
46 }
47 
48 //*****************************************************************************
49 LocalCartesian::LocalCartesian(double lat0, double lon0, double h0 )
50 {
51  try
52  {
55  }
56  catch ( std::bad_alloc )
57  {
58  throw gcnew GeographicErr( BADALLOC );
59  }
60 }
61 
62 //*****************************************************************************
64 {
65  try
66  {
67  const GeographicLib::Geocentric* pGeocentric =
68  reinterpret_cast<const GeographicLib::Geocentric*>(
69  earth->GetUnmanaged()->ToPointer() );
71  }
72  catch ( std::bad_alloc )
73  {
74  throw gcnew GeographicErr( BADALLOC );
75  }
76 }
77 
78 //*****************************************************************************
80 {
81  try
82  {
85  }
86  catch ( std::bad_alloc )
87  {
88  throw gcnew GeographicErr( BADALLOC );
89  }
90 }
91 
92 //*****************************************************************************
93 void LocalCartesian::Reset(double lat0, double lon0, double h0 )
94 {
95  m_pLocalCartesian->Reset( lat0, lon0, h0 );
96 }
97 
98 //*****************************************************************************
99 void LocalCartesian::Forward(double lat, double lon, double h,
100  [System::Runtime::InteropServices::Out] double% x,
101  [System::Runtime::InteropServices::Out] double% y,
102  [System::Runtime::InteropServices::Out] double% z)
103 {
104  double lx, ly, lz;
105  m_pLocalCartesian->Forward( lat, lon, h, lx, ly, lz );
106  x = lx;
107  y = ly;
108  z = lz;
109 }
110 
111 //*****************************************************************************
112 void LocalCartesian::Forward(double lat, double lon, double h,
113  [System::Runtime::InteropServices::Out] double% x,
114  [System::Runtime::InteropServices::Out] double% y,
115  [System::Runtime::InteropServices::Out] double% z,
116  [System::Runtime::InteropServices::Out] array<double,2>^% M)
117 {
118  double lx, ly, lz;
119  std::vector<double> lM(9);
120  m_pLocalCartesian->Forward( lat, lon, h, lx, ly, lz, lM );
121  x = lx;
122  y = ly;
123  z = lz;
124  M = gcnew array<double,2>(3,3);
125  for ( int i = 0; i < 3; i++ )
126  for ( int j = 0; j < 3; j++ )
127  M[i,j] = lM[3*i+j];
128 }
129 
130 //*****************************************************************************
131 void LocalCartesian::Reverse(double x, double y, double z,
132  [System::Runtime::InteropServices::Out] double% lat,
133  [System::Runtime::InteropServices::Out] double% lon,
134  [System::Runtime::InteropServices::Out] double% h)
135 {
136  double llat, llon, lh;
137  m_pLocalCartesian->Reverse( x, y, z, llat, llon, lh );
138  lat = llat;
139  lon = llon;
140  h = lh;
141 }
142 
143 //*****************************************************************************
144 void LocalCartesian::Reverse(double x, double y, double z,
145  [System::Runtime::InteropServices::Out] double% lat,
146  [System::Runtime::InteropServices::Out] double% lon,
147  [System::Runtime::InteropServices::Out] double% h,
148  [System::Runtime::InteropServices::Out] array<double,2>^% M)
149 {
150  double llat, llon, lh;
151  std::vector<double> lM(9);
152  m_pLocalCartesian->Reverse( x, y, z, llat, llon, lh, lM );
153  lat = llat;
154  lon = llon;
155  h = lh;
156  M = gcnew array<double,2>(3,3);
157  for ( int i = 0; i < 3; i++ )
158  for ( int j = 0; j < 3; j++ )
159  M[i,j] = lM[3*i+j];
160 }
161 
162 //*****************************************************************************
164 { return m_pLocalCartesian->LatitudeOrigin(); }
165 
166 //*****************************************************************************
168 { return m_pLocalCartesian->LongitudeOrigin(); }
169 
170 //*****************************************************************************
172 { return m_pLocalCartesian->HeightOrigin(); }
173 
174 //*****************************************************************************
176 { return m_pLocalCartesian->MajorRadius(); }
177 
178 //*****************************************************************************
180 { return m_pLocalCartesian->Flattening(); }
void Reset(real lat0, real lon0, real h0=0)
Math::real LongitudeOrigin() const
Matrix< RealScalar, Dynamic, Dynamic > M
Definition: bench_gemm.cpp:51
Header for NETGeographicLib::NETGeographicLib objects.
Scalar * y
Header for GeographicLib::LocalCartesian class.
static const double lat
Exception class for NETGeographicLib.
void Reverse(double x, double y, double z, [System::Runtime::InteropServices::Out] double% lat, [System::Runtime::InteropServices::Out] double% lon, [System::Runtime::InteropServices::Out] double% h)
Definition: numpy.h:680
const double h0
.NET wrapper for GeographicLib::Geocentric.
Definition: Geocentric.h:68
void Forward(double lat, double lon, double h, [System::Runtime::InteropServices::Out] double% x, [System::Runtime::InteropServices::Out] double% y, [System::Runtime::InteropServices::Out] double% z)
Geocentric coordinates
Definition: Geocentric.hpp:67
Header for NETGeographicLib::LocalCartesian class.
.NET wrapper for GeographicLib::LocalCartesian.
const double lat0
Header for NETGeographicLib::Geocentric class.
static const Geocentric & WGS84()
void Reset(double lat0, double lon0, double h0)
const double lon0
#define NULL
Definition: ccolamd.c:609
Math::real LatitudeOrigin() const
Local cartesian coordinates.
void Forward(real lat, real lon, real h, real &x, real &y, real &z) const
const double h
void Reverse(real x, real y, real z, real &lat, real &lon, real &h) const
static const double lon
Container::iterator get(Container &c, Position position)
GeographicLib::LocalCartesian * m_pLocalCartesian
set noclip points set clip one set noclip two set bar set border lt lw set xdata set ydata set zdata set x2data set y2data set boxwidth set dummy x
std::ptrdiff_t j


gtsam
Author(s):
autogenerated on Tue Jul 4 2023 02:34:33