Package ucar.nc2.dt.ugrid.geom
Class LatLonPolygon2D
java.lang.Object
ucar.nc2.dt.ugrid.geom.LatLonPolygon2D
- All Implemented Interfaces:
Serializable
- Direct Known Subclasses:
LatLonPolygon2D.Double
- See Also:
-
Nested Class Summary
Nested Classes -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic doublecalculateLLArrayArea(double[] latLonValues) Calculates the area of a polygon bounding box for an array of doubles in the orientation of: LLy, LLx, URy, URxabstract booleancontains(double lat, double lon) Determines if the point represented by lat, lon is within this polygonbooleancontains(LatLonPoint2D point) Determines if the LatLonPoint2D is within this polygonbooleancontains(LatLonPolygon2D poly) Determines if the specified LatLonPolygon2D is COMPLETELY contained within this LatLonPolygon2Dbooleancontains(LatLonRectangle2D rect) Determines if the specified LatLonRectangle2D is COMPLETELY contained within this LatLonPolygon2Dcopy()Copies this LatLonPolygon2D to a new LatLonPolygon2Dbooleandoubleabstract doubleabstract doublegetArea()abstract double[]Calculates the bounding box of thisLatLonPolygon2Dand returns the coordinates as adoublearray with a length of 4.abstract LatLonRectangle2Dabstract LatLonPoint2DCalculates the geometric center of this LatLonPolygon2Dabstract double[]abstract double[]abstract intabstract List<LatLonPoint2D>Gets a list of LatLonPoint2D vertices in this polygonbooleanintersects(LatLonPoint2D point) abstract booleanintersects(LatLonPoint2D point, boolean crossesDateline) abstract booleanintersects(LatLonPoint2D p1, LatLonPoint2D p2, boolean crossesDateline) abstract booleanintersects(LatLonPolygon2D poly) static booleanlineIntersectsPoint(double e0x, double e0y, double e1x, double e1y, double p1x, double p1y) Checks if the point given by p1x, p1y is intersected by the line segment given by e0, e1static booleanlinesIntersect(double p0x, double p0y, double p1x, double p1y, double p2x, double p2y, double p3x, double p3y) Checks if the line segment drawn from p0 to p1 intersects the line drawn from p2 to p3.abstract voidlineTo(double lat, double lon) Adds the point specified by the provided lat and lon to the end of the polygonvoidvoidlineTo(LatLonPoint2D point) Adds the LatLonPoint2D to the end of the polygontoString()Return a string representation of the polygon.
-
Field Details
-
crossesDateline
protected boolean crossesDateline
-
-
Constructor Details
-
LatLonPolygon2D
public LatLonPolygon2D()
-
-
Method Details
-
lineTo
Adds the LatLonPoint2D to the end of the polygon- Parameters:
point-
-
lineTo
-
getArea
public abstract double getArea() -
lineTo
public abstract void lineTo(double lat, double lon) Adds the point specified by the provided lat and lon to the end of the polygon- Parameters:
lat- the latitude of the point to addlon- the longitude of the point to add
-
getCentroid
Calculates the geometric center of this LatLonPolygon2D- Returns:
- the center point
-
contains
Determines if the LatLonPoint2D is within this polygon- Parameters:
point- the point to test- Returns:
- true if the point is contained within this polygon; false otherwise
-
contains
public abstract boolean contains(double lat, double lon) Determines if the point represented by lat, lon is within this polygon- Parameters:
lat- the latitude (y) of the point to testlon- the longitude (x) of the point to test- Returns:
- true if the point is contained within this polygon; false otherwise
-
contains
Determines if the specified LatLonRectangle2D is COMPLETELY contained within this LatLonPolygon2D- Parameters:
rect- the LatLonRectangle2D to check- Returns:
- true if the LatLonRectangle2D is COMPLETELY contained in this polygon; false otherwise
-
contains
Determines if the specified LatLonPolygon2D is COMPLETELY contained within this LatLonPolygon2D- Parameters:
poly- the LatLonPolygon2D to check- Returns:
- true if the LatLonPolygon2D is COMPLETELY contained in this polygon; false otherwise
-
intersects
-
intersects
-
intersects
-
intersects
-
distanceSq
-
distance
-
getVertices
Gets a list of LatLonPoint2D vertices in this polygon- Returns:
- the vertices
-
getVertexCount
public abstract int getVertexCount() -
getLonCoords
public abstract double[] getLonCoords() -
getLatCoords
public abstract double[] getLatCoords() -
getBouningLatLonRectangle2D
-
getBoundingLatLonValues
public abstract double[] getBoundingLatLonValues()Calculates the bounding box of thisLatLonPolygon2Dand returns the coordinates as adoublearray with a length of 4. The coordinates are arranged in the order of western lon, southern lat, eastern lon, and northern lat.
In terms of points where LL = lower left and UR = upper right, this is equivalent to the arrangement ofdouble[] {lly, llx, ury, urx}.- Returns:
- a
doublearray with a length of 4 containing the lat/lon points of the bounding box of thisLatLonPolygon2D. If this object contains no verticesnullis returned.
-
crossesDateline
public boolean crossesDateline() -
copy
Copies this LatLonPolygon2D to a new LatLonPolygon2D- Returns:
- a copy of this polygon
-
toString
Return a string representation of the polygon. -
calculateLLArrayArea
public static double calculateLLArrayArea(double[] latLonValues) Calculates the area of a polygon bounding box for an array of doubles in the orientation of: LLy, LLx, URy, URx- Parameters:
latLonValues- an array of doubles in the orientation of: LLy, LLx, URy, URx- Returns:
- the area of the given bounding box
-
linesIntersect
public static boolean linesIntersect(double p0x, double p0y, double p1x, double p1y, double p2x, double p2y, double p3x, double p3y) Checks if the line segment drawn from p0 to p1 intersects the line drawn from p2 to p3. This is an optimized variation ofLine2D.linesIntersect(double, double, double, double, double, double, double, double)- Parameters:
p0x- the first points x valuep0y- the first points y valuep1x- the second points x valuep1y- the second point's y valuep2x- the third point's x valuep2y- the third point's y valuep3x- the fourth point's x valuep3y- the fourth point's y value- Returns:
trueif the lines created from the given points intersect, otherwisefalse
-
lineIntersectsPoint
public static boolean lineIntersectsPoint(double e0x, double e0y, double e1x, double e1y, double p1x, double p1y) Checks if the point given by p1x, p1y is intersected by the line segment given by e0, e1- Parameters:
e0x- the line segment's first endpoint's x valuee0y- the line segment's first endpoint's y valuee1x- the line segment's second endpoint's x valuee1y- the line segment's second endpoint's y valuep1x- the point's x valuep1y- the point's y value- Returns:
trueif the point is intersected by the given line segment, otherwisefalse
-