Public Member Functions | Private Member Functions | Private Attributes | List of all members
NETGeographicLib::PolygonArea Class Reference

.NET wrapper for GeographicLib::PolygonArea and PolygonAreaExact. More...

#include <PolygonArea.h>

Public Member Functions

void AddEdge (double azi, double s)
 
void AddPoint (double lat, double lon)
 
void Clear ()
 
unsigned Compute (bool reverse, bool sign, [System::Runtime::InteropServices::Out] double%perimeter, [System::Runtime::InteropServices::Out] double%area)
 
 PolygonArea (Geodesic^earth, bool polyline)
 
 PolygonArea (const bool polyline)
 
unsigned TestEdge (double azi, double s, 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)
 
 ~PolygonArea ()
 

Private Member Functions

 !PolygonArea (void)
 

Private Attributes

GeographicLib::PolygonArea * m_pPolygonArea
 

Inspector functions

property double MajorRadius { double get()
 
property double Flattening { double get()
 
void CurrentPoint ([System::Runtime::InteropServices::Out] double%lat, [System::Runtime::InteropServices::Out] double%lon)
 

Detailed Description

.NET wrapper for GeographicLib::PolygonArea and PolygonAreaExact.

This class allows .NET applications to access GeographicLib::PolygonArea.

This computes the area of a geodesic polygon using the method given Section 6 of

This class lets you add vertices one at a time to the polygon. The area and perimeter are accumulated in two times the standard floating point precision to guard against the loss of accuracy with many-sided polygons. At any point you can ask for the perimeter and area so far. There's an option to treat the points as defining a polyline instead of a polygon; in that case, only the perimeter is computed.

C# Example:

using System;
namespace example_PolygonArea
{
class Program
{
static void Main(string[] args)
{
try {
Geodesic geod = new Geodesic(); // WGS84
PolygonArea poly = new PolygonArea(geod, true);
poly.AddPoint( 52, 0); // London
poly.AddPoint( 41,-74); // New York
poly.AddPoint(-23,-43); // Rio de Janeiro
poly.AddPoint(-26, 28); // Johannesburg
double perimeter, area;
uint n = poly.Compute(false, true, out perimeter, out area);
Console.WriteLine(String.Format("{0} {1} {2}", n, perimeter, area));
}
catch (GeographicErr e) {
Console.WriteLine(String.Format("Caught exception: {0}", e.Message));
}
}
}
}

Managed C++ Example:

// Example of using the GeographicLib::PolygonArea class
#include <iostream>
#include <exception>
using namespace std;
using namespace GeographicLib;
int main() {
try {
Geodesic geod(Constants::WGS84_a(), Constants::WGS84_f());
// Alternatively: const Geodesic& geod = Geodesic::WGS84();
PolygonArea poly(geod);
poly.AddPoint( 52, 0); // London
poly.AddPoint( 41,-74); // New York
poly.AddPoint(-23,-43); // Rio de Janeiro
poly.AddPoint(-26, 28); // Johannesburg
double perimeter, area;
unsigned n = poly.Compute(false, true, perimeter, area);
cout << n << " " << perimeter << " " << area << "\n";
}
catch (const exception& e) {
cerr << "Caught exception: " << e.what() << "\n";
return 1;
}
}

Visual Basic Example:

Imports NETGeographicLib
Module example_PolygonArea
Sub Main()
Try
Dim geod As Geodesic = New Geodesic() ' WGS84
Dim poly As PolygonArea = New PolygonArea(geod, True)
poly.AddPoint(52, 0) ' London
poly.AddPoint(41, -74) ' New York
poly.AddPoint(-23, -43) ' Rio de Janeiro
poly.AddPoint(-26, 28) ' Johannesburg
Dim perimeter, area As Double
Dim n As UInteger = poly.Compute(False, True, perimeter, area)
Console.WriteLine(String.Format("{0} {1} {2}", n, perimeter, area))
Catch ex As GeographicErr
Console.WriteLine(String.Format("Caught exception: {0}", ex.Message))
End Try
End Sub
End Module

INTERFACE DIFFERENCES:
The MajorRadius and Flattening functions are implemented as properties.

Definition at line 49 of file PolygonArea.h.

Constructor & Destructor Documentation

PolygonArea::!PolygonArea ( void  )
private

Definition at line 24 of file dotnet/NETGeographicLib/PolygonArea.cpp.

PolygonArea::PolygonArea ( Geodesic earth,
bool  polyline 
)

Constructor for PolygonArea.

Parameters
[in]earththe Geodesic object to use for geodesic calculations.
[in]polylineif true that treat the points as defining a polyline instead of a polygon.

Definition at line 34 of file dotnet/NETGeographicLib/PolygonArea.cpp.

PolygonArea::PolygonArea ( const bool  polyline)

Constructor for PolygonArea that assumes a WGS84 ellipsoid.

Parameters
[in]polylineif true that treat the points as defining a polyline instead of a polygon.

Definition at line 50 of file dotnet/NETGeographicLib/PolygonArea.cpp.

NETGeographicLib::PolygonArea::~PolygonArea ( )
inline

The destructor calls the finalizer.

Definition at line 79 of file PolygonArea.h.

Member Function Documentation

void PolygonArea::AddEdge ( double  azi,
double  s 
)

Add an edge to the polygon or polyline.

Parameters
[in]aziazimuth at current point (degrees).
[in]sdistance from current point to next point (meters).

This does nothing if no points have been added yet. Use PolygonArea::CurrentPoint to determine the position of the new vertex.

Definition at line 73 of file dotnet/NETGeographicLib/PolygonArea.cpp.

void PolygonArea::AddPoint ( double  lat,
double  lon 
)

Add a point to the polygon or polyline.

Parameters
[in]latthe latitude of the point (degrees).
[in]lonthe longitude of the point (degrees).

lat should be in the range [−90°, 90°].

Definition at line 67 of file dotnet/NETGeographicLib/PolygonArea.cpp.

void PolygonArea::Clear ( )

Clear PolygonArea, allowing a new polygon to be started.

Definition at line 64 of file dotnet/NETGeographicLib/PolygonArea.cpp.

unsigned PolygonArea::Compute ( bool  reverse,
bool  sign,
[System::Runtime::InteropServices::Out] double%  perimeter,
[System::Runtime::InteropServices::Out] double%  area 
)

Return the results so far.

Parameters
[in]reverseif true then clockwise (instead of counter-clockwise) traversal counts as a positive area.
[in]signif true then return a signed result for the area if the polygon is traversed in the "wrong" direction instead of returning the area for the rest of the earth.
[out]perimeterthe perimeter of the polygon or length of the polyline (meters).
[out]areathe area of the polygon (meters2); only set if polyline is false in the constructor.
Returns
the number of points.

Definition at line 79 of file dotnet/NETGeographicLib/PolygonArea.cpp.

void PolygonArea::CurrentPoint ( [System::Runtime::InteropServices::Out] double%  lat,
[System::Runtime::InteropServices::Out] double%  lon 
)

Report the previous vertex added to the polygon or polyline.

Parameters
[out]latthe latitude of the point (degrees).
[out]lonthe longitude of the point (degrees).

If no points have been added, then NaNs are returned. Otherwise, lon will be in the range [−180°, 180°).

Definition at line 115 of file dotnet/NETGeographicLib/PolygonArea.cpp.

unsigned PolygonArea::TestEdge ( double  azi,
double  s,
bool  reverse,
bool  sign,
[System::Runtime::InteropServices::Out] double%  perimeter,
[System::Runtime::InteropServices::Out] double%  area 
)

Return the results assuming a tentative final test point is added via an azimuth and distance; however, the data for the test point is not saved. This lets you report a running result for the perimeter and area as the user moves the mouse cursor. Ordinary floating point arithmetic is used to accumulate the data for the test point; thus the area and perimeter returned are less accurate than if PolygonArea::AddEdge and PolygonArea::Compute are used.

Parameters
[in]aziazimuth at current point (degrees).
[in]sdistance from current point to final test point (meters).
[in]reverseif true then clockwise (instead of counter-clockwise) traversal counts as a positive area.
[in]signif true then return a signed result for the area if the polygon is traversed in the "wrong" direction instead of returning the area for the rest of the earth.
[out]perimeterthe approximate perimeter of the polygon or length of the polyline (meters).
[out]areathe approximate area of the polygon (meters2); only set if polyline is false in the constructor.
Returns
the number of points.

Definition at line 103 of file dotnet/NETGeographicLib/PolygonArea.cpp.

unsigned PolygonArea::TestPoint ( double  lat,
double  lon,
bool  reverse,
bool  sign,
[System::Runtime::InteropServices::Out] double%  perimeter,
[System::Runtime::InteropServices::Out] double%  area 
)

Return the results assuming a tentative final test point is added; however, the data for the test point is not saved. This lets you report a running result for the perimeter and area as the user moves the mouse cursor. Ordinary floating point arithmetic is used to accumulate the data for the test point; thus the area and perimeter returned are less accurate than if PolygonArea::AddPoint and PolygonArea::Compute are used.

Parameters
[in]latthe latitude of the test point (degrees).
[in]lonthe longitude of the test point (degrees).
[in]reverseif true then clockwise (instead of counter-clockwise) traversal counts as a positive area.
[in]signif true then return a signed result for the area if the polygon is traversed in the "wrong" direction instead of returning the area for the rest of the earth.
[out]perimeterthe approximate perimeter of the polygon or length of the polyline (meters).
[out]areathe approximate area of the polygon (meters2); only set if polyline is false in the constructor.
Returns
the number of points.

lat should be in the range [−90°, 90°].

Definition at line 91 of file dotnet/NETGeographicLib/PolygonArea.cpp.

Member Data Documentation

property double NETGeographicLib::PolygonArea::Flattening { double get()
Returns
f the flattening of the ellipsoid. This is the value inherited from the Geodesic object used in the constructor.

Definition at line 196 of file PolygonArea.h.

GeographicLib::PolygonArea* NETGeographicLib::PolygonArea::m_pPolygonArea
private

Definition at line 53 of file PolygonArea.h.

property double NETGeographicLib::PolygonArea::MajorRadius { double get()
Returns
a the equatorial radius of the ellipsoid (meters). This is the value inherited from the Geodesic object used in the constructor.

Definition at line 190 of file PolygonArea.h.


The documentation for this class was generated from the following files:


gtsam
Author(s):
autogenerated on Sat May 8 2021 02:59:11