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;
140  m_pPolygonArea = NULL;
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;
252  m_pPolygonArea = NULL;
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(); }
NETGeographicLib::PolygonAreaRhumb::Compute
unsigned Compute(bool reverse, bool sign, [System::Runtime::InteropServices::Out] double% perimeter, [System::Runtime::InteropServices::Out] double% area)
Definition: dotnet/NETGeographicLib/PolygonArea.cpp:302
NETGeographicLib::PolygonAreaExact::AddEdge
void AddEdge(double azi, double s)
Definition: dotnet/NETGeographicLib/PolygonArea.cpp:184
NETGeographicLib::PolygonArea::CurrentPoint
void CurrentPoint([System::Runtime::InteropServices::Out] double% lat, [System::Runtime::InteropServices::Out] double% lon)
Definition: dotnet/NETGeographicLib/PolygonArea.cpp:115
NETGeographicLib::GeodesicExact::GetUnmanaged
System::IntPtr GetUnmanaged()
Definition: dotnet/NETGeographicLib/GeodesicExact.cpp:467
GeographicLib::GeodesicExact
Exact geodesic calculations.
Definition: GeodesicExact.hpp:80
s
RealScalar s
Definition: level1_cplx_impl.h:126
NETGeographicLib::PolygonAreaRhumb
Definition: PolygonArea.h:385
Geodesic.h
Header for NETGeographicLib::Geodesic class.
NETGeographicLib::Rhumb::GetUnmanaged
System::IntPtr GetUnmanaged()
Definition: dotnet/NETGeographicLib/Rhumb.cpp:146
GeographicLib::Geodesic::WGS84
static const Geodesic & WGS84()
Definition: src/Geodesic.cpp:89
GeographicLib::Rhumb
Solve of the direct and inverse rhumb problems.
Definition: Rhumb.hpp:66
sign
const EIGEN_DEVICE_FUNC SignReturnType sign() const
Definition: ArrayCwiseUnaryOps.h:219
NETGeographicLib::PolygonAreaRhumb::CurrentPoint
void CurrentPoint([System::Runtime::InteropServices::Out] double% lat, [System::Runtime::InteropServices::Out] double% lon)
Definition: dotnet/NETGeographicLib/PolygonArea.cpp:338
NETGeographicLib::PolygonAreaExact
Definition: PolygonArea.h:217
NETGeographicLib::PolygonAreaRhumb::TestPoint
unsigned TestPoint(double lat, double lon, bool reverse, bool sign, [System::Runtime::InteropServices::Out] double% perimeter, [System::Runtime::InteropServices::Out] double% area)
Definition: dotnet/NETGeographicLib/PolygonArea.cpp:314
NETGeographicLib::PolygonAreaExact::CurrentPoint
void CurrentPoint([System::Runtime::InteropServices::Out] double% lat, [System::Runtime::InteropServices::Out] double% lon)
Definition: dotnet/NETGeographicLib/PolygonArea.cpp:226
BADALLOC
const char BADALLOC[]
Definition: dotnet/NETGeographicLib/PolygonArea.cpp:21
NETGeographicLib::PolygonArea::TestEdge
unsigned TestEdge(double azi, double s, bool reverse, bool sign, [System::Runtime::InteropServices::Out] double% perimeter, [System::Runtime::InteropServices::Out] double% area)
Definition: dotnet/NETGeographicLib/PolygonArea.cpp:103
NETGeographicLib::GeographicErr
Exception class for NETGeographicLib.
Definition: NETGeographicLib.h:132
NETGeographicLib::PolygonAreaRhumb::PolygonAreaRhumb
PolygonAreaRhumb(Rhumb^ earth, bool polyline)
Definition: dotnet/NETGeographicLib/PolygonArea.cpp:257
NETGeographicLib::PolygonAreaExact::PolygonAreaExact
PolygonAreaExact(GeodesicExact^ earth, bool polyline)
Definition: dotnet/NETGeographicLib/PolygonArea.cpp:145
NETGeographicLib::PolygonArea::TestPoint
unsigned TestPoint(double lat, double lon, bool reverse, bool sign, [System::Runtime::InteropServices::Out] double% perimeter, [System::Runtime::InteropServices::Out] double% area)
Definition: dotnet/NETGeographicLib/PolygonArea.cpp:91
NETGeographicLib::PolygonArea::m_pPolygonArea
GeographicLib::PolygonArea * m_pPolygonArea
Definition: PolygonArea.h:53
PolygonArea.h
Header for NETGeographicLib::PolygonArea class.
NETGeographicLib::PolygonAreaExact::AddPoint
void AddPoint(double lat, double lon)
Definition: dotnet/NETGeographicLib/PolygonArea.cpp:178
NETGeographicLib::PolygonArea
.NET wrapper for GeographicLib::PolygonArea and PolygonAreaExact.
Definition: PolygonArea.h:49
NETGeographicLib::PolygonAreaRhumb::m_pPolygonArea
GeographicLib::PolygonAreaRhumb * m_pPolygonArea
Definition: PolygonArea.h:389
NETGeographicLib::Geodesic
.NET wrapper for GeographicLib::Geodesic.
Definition: Geodesic.h:170
NETGeographicLib::GeodesicExact
.NET wrapper for GeographicLib::GeodesicExact.
Definition: GeodesicExact.h:86
stdafx.h
NETGeographicLib::PolygonAreaExact::Compute
unsigned Compute(bool reverse, bool sign, [System::Runtime::InteropServices::Out] double% perimeter, [System::Runtime::InteropServices::Out] double% area)
Definition: dotnet/NETGeographicLib/PolygonArea.cpp:190
PolygonArea.hpp
Header for GeographicLib::PolygonAreaT class.
GeographicLib::GeodesicExact::WGS84
static const GeodesicExact & WGS84()
Definition: src/GeodesicExact.cpp:93
NETGeographicLib::PolygonArea::AddPoint
void AddPoint(double lat, double lon)
Definition: dotnet/NETGeographicLib/PolygonArea.cpp:67
NETGeographicLib::PolygonArea::PolygonArea
PolygonArea(Geodesic^ earth, bool polyline)
Definition: dotnet/NETGeographicLib/PolygonArea.cpp:34
NETGeographicLib::PolygonAreaExact::m_pPolygonArea
GeographicLib::PolygonAreaExact * m_pPolygonArea
Definition: PolygonArea.h:221
NETGeographicLib::PolygonAreaExact::TestEdge
unsigned TestEdge(double azi, double s, bool reverse, bool sign, [System::Runtime::InteropServices::Out] double% perimeter, [System::Runtime::InteropServices::Out] double% area)
Definition: dotnet/NETGeographicLib/PolygonArea.cpp:214
NETGeographicLib.h
Header for NETGeographicLib::NETGeographicLib objects.
NETGeographicLib::PolygonAreaRhumb::Clear
void Clear()
Definition: dotnet/NETGeographicLib/PolygonArea.cpp:287
out
std::ofstream out("Result.txt")
NETGeographicLib::PolygonAreaExact::Clear
void Clear()
Definition: dotnet/NETGeographicLib/PolygonArea.cpp:175
NETGeographicLib::PolygonAreaRhumb::AddEdge
void AddEdge(double azi, double s)
Definition: dotnet/NETGeographicLib/PolygonArea.cpp:296
NETGeographicLib::Rhumb
.NET wrapper for GeographicLib::Rhumb.
Definition: Rhumb.h:65
NETGeographicLib::PolygonArea::Clear
void Clear()
Definition: dotnet/NETGeographicLib/PolygonArea.cpp:64
Rhumb.h
Header for NETGeographicLib::Rhumb and NETGeographicLib::RhumbLine classes.
NETGeographicLib::PolygonArea::AddEdge
void AddEdge(double azi, double s)
Definition: dotnet/NETGeographicLib/PolygonArea.cpp:73
GeographicLib::Rhumb::WGS84
static const Rhumb & WGS84()
Definition: src/Rhumb.cpp:142
NETGeographicLib::PolygonAreaExact::TestPoint
unsigned TestPoint(double lat, double lon, bool reverse, bool sign, [System::Runtime::InteropServices::Out] double% perimeter, [System::Runtime::InteropServices::Out] double% area)
Definition: dotnet/NETGeographicLib/PolygonArea.cpp:202
reverse
void reverse(const MatrixType &m)
Definition: array_reverse.cpp:16
lon
static const double lon
Definition: testGeographicLib.cpp:34
NULL
#define NULL
Definition: ccolamd.c:609
NETGeographicLib::PolygonAreaRhumb::AddPoint
void AddPoint(double lat, double lon)
Definition: dotnet/NETGeographicLib/PolygonArea.cpp:290
get
Container::iterator get(Container &c, Position position)
Definition: stdlist_overload.cpp:29
NETGeographicLib
Definition: Accumulator.h:13
NETGeographicLib::PolygonAreaRhumb::TestEdge
unsigned TestEdge(double azi, double s, bool reverse, bool sign, [System::Runtime::InteropServices::Out] double% perimeter, [System::Runtime::InteropServices::Out] double% area)
Definition: dotnet/NETGeographicLib/PolygonArea.cpp:326
GeodesicExact.h
Header for NETGeographicLib::GeodesicExact class.
GeographicLib::Geodesic
Geodesic calculations
Definition: Geodesic.hpp:172
NETGeographicLib::PolygonArea::Compute
unsigned Compute(bool reverse, bool sign, [System::Runtime::InteropServices::Out] double% perimeter, [System::Runtime::InteropServices::Out] double% area)
Definition: dotnet/NETGeographicLib/PolygonArea.cpp:79
lat
static const double lat
Definition: testGeographicLib.cpp:34
NETGeographicLib::Geodesic::GetUnmanaged
System::IntPtr GetUnmanaged()
Definition: dotnet/NETGeographicLib/Geodesic.cpp:465


gtsam
Author(s):
autogenerated on Sat Nov 16 2024 04:03:36