Public Member Functions | Static Private Member Functions | Private Attributes | List of all members
net.sf.geographiclib.PolygonArea Class Reference

Public Member Functions

void AddEdge (double azi, double s)
 
void AddPoint (double lat, double lon)
 
void Clear ()
 
PolygonResult Compute ()
 
PolygonResult Compute (boolean reverse, boolean sign)
 
Pair CurrentPoint ()
 
double Flattening ()
 
double MajorRadius ()
 
 PolygonArea (Geodesic earth, boolean polyline)
 
PolygonResult TestEdge (double azi, double s, boolean reverse, boolean sign)
 
PolygonResult TestPoint (double lat, double lon, boolean reverse, boolean sign)
 

Static Private Member Functions

static int transit (double lon1, double lon2)
 
static int transitdirect (double lon1, double lon2)
 

Private Attributes

double _area0
 
Accumulator _areasum
 
int _crossings
 
Geodesic _earth
 
double _lat0
 
int _mask
 
int _num
 
boolean _polyline
 

Detailed Description

Polygon areas.

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 at 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.

Example of use:

// Compute the area of a geodesic polygon.
// This program reads lines with lat, lon for each vertex of a polygon.
// At the end of input, the program prints the number of vertices,
// the perimeter of the polygon and its area (for the WGS84 ellipsoid).
import java.util.*;
import net.sf.geographiclib.*;
public class Planimeter {
public static void main(String[] args) {
PolygonArea p = new PolygonArea(Geodesic.WGS84, false);
try {
Scanner in = new Scanner(System.in);
while (true) {
double lat = in.nextDouble(), lon = in.nextDouble();
p.AddPoint(lat, lon);
}
}
catch (Exception e) {}
PolygonResult r = p.Compute();
System.out.println(r.num + " " + r.perimeter + " " + r.area);
}
}

Definition at line 60 of file PolygonArea.java.

Constructor & Destructor Documentation

◆ PolygonArea()

net.sf.geographiclib.PolygonArea.PolygonArea ( Geodesic  earth,
boolean  polyline 
)
inline

Constructor for PolygonArea.

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

Definition at line 101 of file PolygonArea.java.

Member Function Documentation

◆ AddEdge()

void net.sf.geographiclib.PolygonArea.AddEdge ( double  azi,
double  s 
)
inline

Add an edge to the polygon or polyline.

Parameters
aziazimuth at current point (degrees).
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 160 of file PolygonArea.java.

◆ AddPoint()

void net.sf.geographiclib.PolygonArea.AddPoint ( double  lat,
double  lon 
)
inline

Add a point to the polygon or polyline.

Parameters
latthe latitude of the point (degrees).
lonthe latitude of the point (degrees).

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

Definition at line 134 of file PolygonArea.java.

◆ Clear()

void net.sf.geographiclib.PolygonArea.Clear ( )
inline

Clear PolygonArea, allowing a new polygon to be started.

Definition at line 118 of file PolygonArea.java.

◆ Compute() [1/2]

PolygonResult net.sf.geographiclib.PolygonArea.Compute ( )
inline

Return the results so far.

Returns
PolygonResult(num, perimeter, area) where num is the number of vertices, perimeter is the perimeter of the polygon or the length of the polyline (meters), and area is the area of the polygon (meters2) or Double.NaN of polyline is true in the constructor.

Counter-clockwise traversal counts as a positive area.

Definition at line 184 of file PolygonArea.java.

◆ Compute() [2/2]

PolygonResult net.sf.geographiclib.PolygonArea.Compute ( boolean  reverse,
boolean  sign 
)
inline

Return the results so far.

Parameters
reverseif true then clockwise (instead of counter-clockwise) traversal counts as a positive area.
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.
Returns
PolygonResult(num, perimeter, area) where num is the number of vertices, perimeter is the perimeter of the polygon or the length of the polyline (meters), and area is the area of the polygon (meters2) or Double.NaN of polyline is true in the constructor.

More points can be added to the polygon after this call.

Definition at line 201 of file PolygonArea.java.

◆ CurrentPoint()

Pair net.sf.geographiclib.PolygonArea.CurrentPoint ( )
inline

Report the previous vertex added to the polygon or polyline.

Returns
Pair(lat, lon), the current latitude and longitude.

If no points have been added, then Double.NaN is returned. Otherwise, lon will be in the range [−180°, 180°].

Definition at line 390 of file PolygonArea.java.

◆ Flattening()

double net.sf.geographiclib.PolygonArea.Flattening ( )
inline
Returns
f the flattening of the ellipsoid. This is the value inherited from the Geodesic object used in the constructor.

Definition at line 380 of file PolygonArea.java.

◆ MajorRadius()

double net.sf.geographiclib.PolygonArea.MajorRadius ( )
inline
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 374 of file PolygonArea.java.

◆ TestEdge()

PolygonResult net.sf.geographiclib.PolygonArea.TestEdge ( double  azi,
double  s,
boolean  reverse,
boolean  sign 
)
inline

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 AddPoint and Compute are used.

Parameters
aziazimuth at current point (degrees).
sdistance from current point to final test point (meters).
reverseif true then clockwise (instead of counter-clockwise) traversal counts as a positive area.
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.
Returns
PolygonResult(num, perimeter, area) where num is the number of vertices, perimeter is the perimeter of the polygon or the length of the polyline (meters), and area is the area of the polygon (meters2) or Double.NaN of polyline is true in the constructor.

Definition at line 323 of file PolygonArea.java.

◆ TestPoint()

PolygonResult net.sf.geographiclib.PolygonArea.TestPoint ( double  lat,
double  lon,
boolean  reverse,
boolean  sign 
)
inline

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 AddPoint and Compute are used.

Parameters
latthe latitude of the test point (degrees).
lonthe longitude of the test point (degrees).
reverseif true then clockwise (instead of counter-clockwise) traversal counts as a positive area.
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.
Returns
PolygonResult(num, perimeter, area) where num is the number of vertices, perimeter is the perimeter of the polygon or the length of the polyline (meters), and area is the area of the polygon (meters2) or Double.NaN of polyline is true in the constructor.

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

Definition at line 256 of file PolygonArea.java.

◆ transit()

static int net.sf.geographiclib.PolygonArea.transit ( double  lon1,
double  lon2 
)
inlinestaticprivate

Definition at line 70 of file PolygonArea.java.

◆ transitdirect()

static int net.sf.geographiclib.PolygonArea.transitdirect ( double  lon1,
double  lon2 
)
inlinestaticprivate

Definition at line 84 of file PolygonArea.java.

Member Data Documentation

◆ _area0

double net.sf.geographiclib.PolygonArea._area0
private

Definition at line 63 of file PolygonArea.java.

◆ _areasum

Accumulator net.sf.geographiclib.PolygonArea._areasum
private

Definition at line 68 of file PolygonArea.java.

◆ _crossings

int net.sf.geographiclib.PolygonArea._crossings
private

Definition at line 67 of file PolygonArea.java.

◆ _earth

Geodesic net.sf.geographiclib.PolygonArea._earth
private

Definition at line 62 of file PolygonArea.java.

◆ _lat0

double net.sf.geographiclib.PolygonArea._lat0
private

Definition at line 69 of file PolygonArea.java.

◆ _mask

int net.sf.geographiclib.PolygonArea._mask
private

Definition at line 65 of file PolygonArea.java.

◆ _num

int net.sf.geographiclib.PolygonArea._num
private

Definition at line 66 of file PolygonArea.java.

◆ _polyline

boolean net.sf.geographiclib.PolygonArea._polyline
private

Definition at line 64 of file PolygonArea.java.


The documentation for this class was generated from the following file:
e
Array< double, 1, 3 > e(1./3., 0.5, 2.)
net.sf
net.sf.geographiclib.PolygonArea.PolygonArea
PolygonArea(Geodesic earth, boolean polyline)
Definition: PolygonArea.java:101
main
int main(int argc, char **argv)
Definition: cmake/example_cmake_find_gtsam/main.cpp:63
net
Planimeter
Definition: Planimeter.java:14
net.sf.geographiclib
Definition: Accumulator.java:8
args
Definition: pytypes.h:2210
p
float * p
Definition: Tutorial_Map_using.cpp:9
lon
static const double lon
Definition: testGeographicLib.cpp:34
lat
static const double lat
Definition: testGeographicLib.cpp:34


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