dotnet/NETGeographicLib/PolygonArea.cpp
Go to the documentation of this file.
1 
11 #include "stdafx.h"
13 #include "PolygonArea.h"
14 #include "Geodesic.h"
15 #include "GeodesicExact.h"
16 #include "Rhumb.h"
17 #include "NETGeographicLib.h"
18 
19 using namespace NETGeographicLib;
20 
21 const char BADALLOC[] = "Failed to allocate memory for a GeographicLib::PolygonArea";
22 
23 //*****************************************************************************
25 {
26  if ( m_pPolygonArea != NULL )
27  {
28  delete m_pPolygonArea;
29  m_pPolygonArea = NULL;
30  }
31 }
32 
33 //*****************************************************************************
34 PolygonArea::PolygonArea(Geodesic^ earth, bool polyline )
35 {
36  try
37  {
38  const GeographicLib::Geodesic* pGeodesic =
39  reinterpret_cast<const GeographicLib::Geodesic*>(
40  earth->GetUnmanaged()->ToPointer() );
41  m_pPolygonArea = new GeographicLib::PolygonArea( *pGeodesic, polyline );
42  }
43  catch (std::bad_alloc)
44  {
45  throw gcnew GeographicErr( BADALLOC );
46  }
47 }
48 
49 //*****************************************************************************
50 PolygonArea::PolygonArea(const bool polyline )
51 {
52  try
53  {
54  m_pPolygonArea = new GeographicLib::PolygonArea(
55  GeographicLib::Geodesic::WGS84(), polyline );
56  }
57  catch (std::bad_alloc)
58  {
59  throw gcnew GeographicErr( BADALLOC );
60  }
61 }
62 
63 //*****************************************************************************
64 void PolygonArea::Clear() { m_pPolygonArea->Clear(); }
65 
66 //*****************************************************************************
67 void PolygonArea::AddPoint(double lat, double lon)
68 {
69  m_pPolygonArea->AddPoint( lat, lon );
70 }
71 
72 //*****************************************************************************
73 void PolygonArea::AddEdge(double azi, double s)
74 {
75  m_pPolygonArea->AddEdge( azi, s );
76 }
77 
78 //*****************************************************************************
79 unsigned PolygonArea::Compute(bool reverse, bool sign,
80  [System::Runtime::InteropServices::Out] double% perimeter,
81  [System::Runtime::InteropServices::Out] double% area)
82 {
83  double lperimeter, larea;
84  unsigned out = m_pPolygonArea->Compute( reverse, sign, lperimeter, larea );
85  perimeter = lperimeter;
86  area = larea;
87  return out;
88 }
89 
90 //*****************************************************************************
91 unsigned PolygonArea::TestPoint(double lat, double lon, bool reverse, bool sign,
92  [System::Runtime::InteropServices::Out] double% perimeter,
93  [System::Runtime::InteropServices::Out] double% area)
94 {
95  double lperimeter, larea;
96  unsigned out = m_pPolygonArea->TestPoint( lat, lon, reverse, sign, lperimeter, larea );
97  perimeter = lperimeter;
98  area = larea;
99  return out;
100 }
101 
102 //*****************************************************************************
103 unsigned PolygonArea::TestEdge(double azi, double s, bool reverse, bool sign,
104  [System::Runtime::InteropServices::Out] double% perimeter,
105  [System::Runtime::InteropServices::Out] double% area)
106 {
107  double lperimeter, larea;
108  unsigned out = m_pPolygonArea->TestEdge( azi, s, reverse, sign, lperimeter, larea );
109  perimeter = lperimeter;
110  area = larea;
111  return out;
112 }
113 
114 //*****************************************************************************
116  [System::Runtime::InteropServices::Out] double% lat,
117  [System::Runtime::InteropServices::Out] double% lon)
118 {
119  double llat, llon;
120  m_pPolygonArea->CurrentPoint( llat, llon );
121  lat = llat;
122  lon = llon;
123 }
124 
125 //*****************************************************************************
127 { return m_pPolygonArea->MajorRadius(); }
128 
129 //*****************************************************************************
130 double PolygonArea::Flattening::get() { return m_pPolygonArea->Flattening(); }
131 
132 //*****************************************************************************
133 // PolygonAreaExact
134 //*****************************************************************************
136 {
137  if ( m_pPolygonArea != NULL )
138  {
139  delete m_pPolygonArea;
141  }
142 }
143 
144 //*****************************************************************************
146 {
147  try
148  {
149  const GeographicLib::GeodesicExact* pGeodesic =
150  reinterpret_cast<const GeographicLib::GeodesicExact*>(
151  earth->GetUnmanaged()->ToPointer() );
152  m_pPolygonArea = new GeographicLib::PolygonAreaExact( *pGeodesic, polyline );
153  }
154  catch (std::bad_alloc)
155  {
156  throw gcnew GeographicErr( BADALLOC );
157  }
158 }
159 
160 //*****************************************************************************
162 {
163  try
164  {
165  m_pPolygonArea = new GeographicLib::PolygonAreaExact(
167  }
168  catch (std::bad_alloc)
169  {
170  throw gcnew GeographicErr( BADALLOC );
171  }
172 }
173 
174 //*****************************************************************************
176 
177 //*****************************************************************************
178 void PolygonAreaExact::AddPoint(double lat, double lon)
179 {
180  m_pPolygonArea->AddPoint( lat, lon );
181 }
182 
183 //*****************************************************************************
184 void PolygonAreaExact::AddEdge(double azi, double s)
185 {
186  m_pPolygonArea->AddEdge( azi, s );
187 }
188 
189 //*****************************************************************************
191  [System::Runtime::InteropServices::Out] double% perimeter,
192  [System::Runtime::InteropServices::Out] double% area)
193 {
194  double lperimeter, larea;
195  unsigned out = m_pPolygonArea->Compute( reverse, sign, lperimeter, larea );
196  perimeter = lperimeter;
197  area = larea;
198  return out;
199 }
200 
201 //*****************************************************************************
202 unsigned PolygonAreaExact::TestPoint(double lat, double lon, bool reverse, bool sign,
203  [System::Runtime::InteropServices::Out] double% perimeter,
204  [System::Runtime::InteropServices::Out] double% area)
205 {
206  double lperimeter, larea;
207  unsigned out = m_pPolygonArea->TestPoint( lat, lon, reverse, sign, lperimeter, larea );
208  perimeter = lperimeter;
209  area = larea;
210  return out;
211 }
212 
213 //*****************************************************************************
214 unsigned PolygonAreaExact::TestEdge(double azi, double s, bool reverse, bool sign,
215  [System::Runtime::InteropServices::Out] double% perimeter,
216  [System::Runtime::InteropServices::Out] double% area)
217 {
218  double lperimeter, larea;
219  unsigned out = m_pPolygonArea->TestEdge( azi, s, reverse, sign, lperimeter, larea );
220  perimeter = lperimeter;
221  area = larea;
222  return out;
223 }
224 
225 //*****************************************************************************
227  [System::Runtime::InteropServices::Out] double% lat,
228  [System::Runtime::InteropServices::Out] double% lon)
229 {
230  double llat, llon;
231  m_pPolygonArea->CurrentPoint( llat, llon );
232  lat = llat;
233  lon = llon;
234 }
235 
236 //*****************************************************************************
238 { return m_pPolygonArea->MajorRadius(); }
239 
240 //*****************************************************************************
242 { return m_pPolygonArea->Flattening(); }
243 
244 //*****************************************************************************
245 // PolygonAreaRhumb
246 //*****************************************************************************
248 {
249  if ( m_pPolygonArea != NULL )
250  {
251  delete m_pPolygonArea;
253  }
254 }
255 
256 //*****************************************************************************
258 {
259  try
260  {
261  const GeographicLib::Rhumb* pGeodesic =
262  reinterpret_cast<const GeographicLib::Rhumb*>(
263  earth->GetUnmanaged()->ToPointer() );
264  m_pPolygonArea = new GeographicLib::PolygonAreaRhumb( *pGeodesic, polyline );
265  }
266  catch (std::bad_alloc)
267  {
268  throw gcnew GeographicErr( BADALLOC );
269  }
270 }
271 
272 //*****************************************************************************
274 {
275  try
276  {
277  m_pPolygonArea = new GeographicLib::PolygonAreaRhumb(
278  GeographicLib::Rhumb::WGS84(), polyline );
279  }
280  catch (std::bad_alloc)
281  {
282  throw gcnew GeographicErr( BADALLOC );
283  }
284 }
285 
286 //*****************************************************************************
288 
289 //*****************************************************************************
290 void PolygonAreaRhumb::AddPoint(double lat, double lon)
291 {
292  m_pPolygonArea->AddPoint( lat, lon );
293 }
294 
295 //*****************************************************************************
296 void PolygonAreaRhumb::AddEdge(double azi, double s)
297 {
298  m_pPolygonArea->AddEdge( azi, s );
299 }
300 
301 //*****************************************************************************
303  [System::Runtime::InteropServices::Out] double% perimeter,
304  [System::Runtime::InteropServices::Out] double% area)
305 {
306  double lperimeter, larea;
307  unsigned out = m_pPolygonArea->Compute( reverse, sign, lperimeter, larea );
308  perimeter = lperimeter;
309  area = larea;
310  return out;
311 }
312 
313 //*****************************************************************************
314 unsigned PolygonAreaRhumb::TestPoint(double lat, double lon, bool reverse, bool sign,
315  [System::Runtime::InteropServices::Out] double% perimeter,
316  [System::Runtime::InteropServices::Out] double% area)
317 {
318  double lperimeter, larea;
319  unsigned out = m_pPolygonArea->TestPoint( lat, lon, reverse, sign, lperimeter, larea );
320  perimeter = lperimeter;
321  area = larea;
322  return out;
323 }
324 
325 //*****************************************************************************
326 unsigned PolygonAreaRhumb::TestEdge(double azi, double s, bool reverse, bool sign,
327  [System::Runtime::InteropServices::Out] double% perimeter,
328  [System::Runtime::InteropServices::Out] double% area)
329 {
330  double lperimeter, larea;
331  unsigned out = m_pPolygonArea->TestEdge( azi, s, reverse, sign, lperimeter, larea );
332  perimeter = lperimeter;
333  area = larea;
334  return out;
335 }
336 
337 //*****************************************************************************
339  [System::Runtime::InteropServices::Out] double% lat,
340  [System::Runtime::InteropServices::Out] double% lon)
341 {
342  double llat, llon;
343  m_pPolygonArea->CurrentPoint( llat, llon );
344  lat = llat;
345  lon = llon;
346 }
347 
348 //*****************************************************************************
350 { return m_pPolygonArea->MajorRadius(); }
351 
352 //*****************************************************************************
354 { return m_pPolygonArea->Flattening(); }
unsigned TestPoint(double lat, double lon, bool reverse, bool sign, [System::Runtime::InteropServices::Out] double% perimeter, [System::Runtime::InteropServices::Out] double% area)
Header for NETGeographicLib::NETGeographicLib objects.
static const double lat
static const Geodesic & WGS84()
Exception class for NETGeographicLib.
std::ofstream out("Result.txt")
void CurrentPoint([System::Runtime::InteropServices::Out] double% lat, [System::Runtime::InteropServices::Out] double% lon)
.NET wrapper for GeographicLib::PolygonArea and PolygonAreaExact.
Definition: PolygonArea.h:49
PolygonAreaExact(GeodesicExact^ earth, bool polyline)
void CurrentPoint([System::Runtime::InteropServices::Out] double% lat, [System::Runtime::InteropServices::Out] double% lon)
void CurrentPoint([System::Runtime::InteropServices::Out] double% lat, [System::Runtime::InteropServices::Out] double% lon)
unsigned TestEdge(double azi, double s, bool reverse, bool sign, [System::Runtime::InteropServices::Out] double% perimeter, [System::Runtime::InteropServices::Out] double% area)
Header for NETGeographicLib::PolygonArea class.
static const Rhumb & WGS84()
Definition: src/Rhumb.cpp:142
.NET wrapper for GeographicLib::Geodesic.
Definition: Geodesic.h:170
EIGEN_DEVICE_FUNC const SignReturnType sign() const
unsigned TestEdge(double azi, double s, bool reverse, bool sign, [System::Runtime::InteropServices::Out] double% perimeter, [System::Runtime::InteropServices::Out] double% area)
RealScalar s
Header for NETGeographicLib::Rhumb and NETGeographicLib::RhumbLine classes.
#define NULL
Definition: ccolamd.c:609
unsigned Compute(bool reverse, bool sign, [System::Runtime::InteropServices::Out] double% perimeter, [System::Runtime::InteropServices::Out] double% area)
unsigned TestPoint(double lat, double lon, bool reverse, bool sign, [System::Runtime::InteropServices::Out] double% perimeter, [System::Runtime::InteropServices::Out] double% area)
GeographicLib::PolygonArea * m_pPolygonArea
Definition: PolygonArea.h:53
Exact geodesic calculations.
unsigned Compute(bool reverse, bool sign, [System::Runtime::InteropServices::Out] double% perimeter, [System::Runtime::InteropServices::Out] double% area)
Header for GeographicLib::PolygonAreaT class.
void reverse(const MatrixType &m)
Solve of the direct and inverse rhumb problems.
Definition: Rhumb.hpp:66
.NET wrapper for GeographicLib::Rhumb.
Definition: Rhumb.h:65
.NET wrapper for GeographicLib::GeodesicExact.
Definition: GeodesicExact.h:86
static const double lon
Header for NETGeographicLib::GeodesicExact class.
Container::iterator get(Container &c, Position position)
Header for NETGeographicLib::Geodesic class.
Geodesic calculations
Definition: Geodesic.hpp:172
unsigned TestPoint(double lat, double lon, bool reverse, bool sign, [System::Runtime::InteropServices::Out] double% perimeter, [System::Runtime::InteropServices::Out] double% area)
unsigned Compute(bool reverse, bool sign, [System::Runtime::InteropServices::Out] double% perimeter, [System::Runtime::InteropServices::Out] double% area)
static const GeodesicExact & WGS84()
unsigned TestEdge(double azi, double s, bool reverse, bool sign, [System::Runtime::InteropServices::Out] double% perimeter, [System::Runtime::InteropServices::Out] double% area)


gtsam
Author(s):
autogenerated on Tue Jul 4 2023 02:35:14