Package ucar.nc2.dt.ugrid.geom
Class LatLonPolygon2D.Double
- java.lang.Object
-
- ucar.nc2.dt.ugrid.geom.LatLonPolygon2D
-
- ucar.nc2.dt.ugrid.geom.LatLonPolygon2D.Double
-
- All Implemented Interfaces:
Serializable
- Enclosing class:
- LatLonPolygon2D
public static class LatLonPolygon2D.Double extends LatLonPolygon2D
- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class ucar.nc2.dt.ugrid.geom.LatLonPolygon2D
LatLonPolygon2D.Double
-
-
Field Summary
Fields Modifier and Type Field Description doubleeastLondoublenorthLatdoublesouthLatdoublewestLon-
Fields inherited from class ucar.nc2.dt.ugrid.geom.LatLonPolygon2D
crossesDateline
-
-
Constructor Summary
Constructors Constructor Description Double()Create an empty polygon with no verticesDouble(double[] lats, double[] lons)Create a new polygon from the provided arrays.Double(double lat, double lon)Create a new polygon with a single starting point.Double(List<LatLonPoint2D> vertices)Create a new polygon from the provided vertices.Double(LatLonPoint2D point)Create a new polygon with a single starting point.Double(LatLonPoint2D[] vertices)Create a new polygon from the provided vertices.Double(LatLonRectangle2D rect)Double(Polygon2D poly)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleancontains(double lat, double lon)Determines if the point represented by lat, lon is within this polygondoubledistanceSq(LatLonPoint2D p)doublegetArea()double[]getBoundingLatLonValues()Calculates the bounding box of thisLatLonPolygon2Dand returns the coordinates as adoublearray with a length of 4.LatLonRectangle2DgetBouningLatLonRectangle2D()LatLonPoint2DgetCentroid()Calculates the geometric center of this LatLonPolygon2Ddouble[]getLatCoords()double[]getLonCoords()intgetVertexCount()List<LatLonPoint2D>getVertices()Gets a list of LatLonPoint2D vertices in this polygonbooleanintersects(LatLonPoint2D point, boolean crossesDateline)booleanintersects(LatLonPoint2D e0, LatLonPoint2D e1, boolean crossesDateline)booleanintersects(LatLonPolygon2D poly)voidlineTo(double lat, double lon)Adds the point specified by the provided lat and lon to the end of the polygonvoidlineTo(LatLonPoint2D point)Adds the LatLonPoint2D to the end of the polygon-
Methods inherited from class ucar.nc2.dt.ugrid.geom.LatLonPolygon2D
calculateLLArrayArea, contains, contains, contains, copy, crossesDateline, distance, intersects, lineIntersectsPoint, linesIntersect, lineTo, toString
-
-
-
-
Constructor Detail
-
Double
public Double()
Create an empty polygon with no vertices
-
Double
public Double(LatLonPoint2D point)
Create a new polygon with a single starting point.- Parameters:
point- the starting point for the polygon
-
Double
public Double(double lat, double lon)Create a new polygon with a single starting point.- Parameters:
lat- the latitude of the starting pointlon- the longitude of the starting point
-
Double
public Double(List<LatLonPoint2D> vertices)
Create a new polygon from the provided vertices. The resulting polygon is NOT closed- Parameters:
vertices- the vertices of the polygon
-
Double
public Double(LatLonPoint2D[] vertices)
Create a new polygon from the provided vertices. The resulting polygon is NOT closed- Parameters:
vertices- the vertices of the polygon
-
Double
public Double(double[] lats, double[] lons)Create a new polygon from the provided arrays. If the arrays are not the same length, the resulting polygon is empty. The resulting polygon is NOT closed- Parameters:
lats-lons-
-
Double
public Double(LatLonRectangle2D rect)
-
Double
public Double(Polygon2D poly)
-
-
Method Detail
-
getArea
public double getArea()
- Specified by:
getAreain classLatLonPolygon2D
-
lineTo
public void lineTo(double lat, double lon)Adds the point specified by the provided lat and lon to the end of the polygon- Specified by:
lineToin classLatLonPolygon2D- Parameters:
lat- the latitude of the point to addlon- the longitude of the point to add
-
lineTo
public void lineTo(LatLonPoint2D point)
Adds the LatLonPoint2D to the end of the polygon- Overrides:
lineToin classLatLonPolygon2D
-
getVertices
public List<LatLonPoint2D> getVertices()
Gets a list of LatLonPoint2D vertices in this polygon- Specified by:
getVerticesin classLatLonPolygon2D- Returns:
- the vertices
-
getVertexCount
public int getVertexCount()
- Specified by:
getVertexCountin classLatLonPolygon2D
-
getLonCoords
public double[] getLonCoords()
- Specified by:
getLonCoordsin classLatLonPolygon2D
-
getLatCoords
public double[] getLatCoords()
- Specified by:
getLatCoordsin classLatLonPolygon2D
-
getCentroid
public LatLonPoint2D getCentroid()
Calculates the geometric center of this LatLonPolygon2D- Specified by:
getCentroidin classLatLonPolygon2D- Returns:
- the center point
-
contains
public boolean contains(double lat, double lon)Determines if the point represented by lat, lon is within this polygon- Specified by:
containsin classLatLonPolygon2D- 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
-
getBoundingLatLonValues
public 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 southern lat, western lon, northern lat, and eastern lon
In terms of points where LL = lower left and UR = upper right, this is equivalent to the arrangement ofdouble[] {lly, llx, ury, urx}.- Specified by:
getBoundingLatLonValuesin classLatLonPolygon2D- 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.
-
getBouningLatLonRectangle2D
public LatLonRectangle2D getBouningLatLonRectangle2D()
- Specified by:
getBouningLatLonRectangle2Din classLatLonPolygon2D
-
intersects
public boolean intersects(LatLonPolygon2D poly)
- Specified by:
intersectsin classLatLonPolygon2D
-
intersects
public boolean intersects(LatLonPoint2D point, boolean crossesDateline)
- Specified by:
intersectsin classLatLonPolygon2D
-
intersects
public boolean intersects(LatLonPoint2D e0, LatLonPoint2D e1, boolean crossesDateline)
- Specified by:
intersectsin classLatLonPolygon2D
-
distanceSq
public double distanceSq(LatLonPoint2D p)
- Specified by:
distanceSqin classLatLonPolygon2D
-
-