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 |
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.*;try {Scanner in = new Scanner(System.in);while (true) {p.AddPoint(lat, lon);}}catch (Exception e) {}PolygonResult r = p.Compute();}}
Definition at line 60 of file PolygonArea.java.
|
inline |
Constructor for PolygonArea.
earth | the Geodesic object to use for geodesic calculations. |
polyline | if true that treat the points as defining a polyline instead of a polygon. |
Definition at line 101 of file PolygonArea.java.
|
inline |
Add an edge to the polygon or polyline.
azi | azimuth at current point (degrees). |
s | distance 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.
|
inline |
Add a point to the polygon or polyline.
lat | the latitude of the point (degrees). |
lon | the latitude of the point (degrees). |
lat should be in the range [−90°, 90°].
Definition at line 134 of file PolygonArea.java.
|
inline |
Clear PolygonArea, allowing a new polygon to be started.
Definition at line 118 of file PolygonArea.java.
|
inline |
Return the results so far.
Counter-clockwise traversal counts as a positive area.
Definition at line 184 of file PolygonArea.java.
|
inline |
Return the results so far.
reverse | if true then clockwise (instead of counter-clockwise) traversal counts as a positive area. |
sign | if 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. |
More points can be added to the polygon after this call.
Definition at line 201 of file PolygonArea.java.
|
inline |
Report the previous vertex added to the polygon or polyline.
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.
|
inline |
Definition at line 380 of file PolygonArea.java.
|
inline |
Definition at line 374 of file PolygonArea.java.
|
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.
azi | azimuth at current point (degrees). |
s | distance from current point to final test point (meters). |
reverse | if true then clockwise (instead of counter-clockwise) traversal counts as a positive area. |
sign | if 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. |
Definition at line 323 of file PolygonArea.java.
|
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.
lat | the latitude of the test point (degrees). |
lon | the longitude of the test point (degrees). |
reverse | if true then clockwise (instead of counter-clockwise) traversal counts as a positive area. |
sign | if 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. |
lat should be in the range [−90°, 90°].
Definition at line 256 of file PolygonArea.java.
|
inlinestaticprivate |
Definition at line 70 of file PolygonArea.java.
|
inlinestaticprivate |
Definition at line 84 of file PolygonArea.java.
|
private |
Definition at line 63 of file PolygonArea.java.
|
private |
Definition at line 68 of file PolygonArea.java.
|
private |
Definition at line 67 of file PolygonArea.java.
|
private |
Definition at line 62 of file PolygonArea.java.
|
private |
Definition at line 69 of file PolygonArea.java.
|
private |
Definition at line 65 of file PolygonArea.java.
|
private |
Definition at line 66 of file PolygonArea.java.
|
private |
Definition at line 64 of file PolygonArea.java.