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
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class ucar.nc2.dt.ugrid.geom.LatLonPolygon2D
LatLonPolygon2D.Double -
Field Summary
FieldsFields inherited from class ucar.nc2.dt.ugrid.geom.LatLonPolygon2D
crossesDateline -
Constructor Summary
ConstructorsConstructorDescriptionDouble()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) -
Method Summary
Modifier and TypeMethodDescriptionbooleancontains(double lat, double lon) Determines if the point represented by lat, lon is within this polygondoubledoublegetArea()double[]Calculates the bounding box of thisLatLonPolygon2Dand returns the coordinates as adoublearray with a length of 4.Calculates the geometric center of this LatLonPolygon2Ddouble[]double[]intGets 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 polygonMethods inherited from class ucar.nc2.dt.ugrid.geom.LatLonPolygon2D
calculateLLArrayArea, contains, contains, contains, copy, crossesDateline, distance, intersects, lineIntersectsPoint, linesIntersect, lineTo, toString
-
Field Details
-
westLon
public double westLon -
eastLon
public double eastLon -
northLat
public double northLat -
southLat
public double southLat
-
-
Constructor Details
-
Double
public Double()Create an empty polygon with no vertices -
Double
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
Create a new polygon from the provided vertices. The resulting polygon is NOT closed- Parameters:
vertices- the vertices of the polygon
-
Double
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
-
Double
-
-
Method Details
-
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
Adds the LatLonPoint2D to the end of the polygon- Overrides:
lineToin classLatLonPolygon2D
-
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
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
- Specified by:
getBouningLatLonRectangle2Din classLatLonPolygon2D
-
intersects
- Specified by:
intersectsin classLatLonPolygon2D
-
intersects
- Specified by:
intersectsin classLatLonPolygon2D
-
intersects
- Specified by:
intersectsin classLatLonPolygon2D
-
distanceSq
- Specified by:
distanceSqin classLatLonPolygon2D
-