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:
  • 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

      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 point
      lon - 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 Details

    • getArea

      public double getArea()
      Specified by:
      getArea in class LatLonPolygon2D
    • 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:
      lineTo in class LatLonPolygon2D
      Parameters:
      lat - the latitude of the point to add
      lon - the longitude of the point to add
    • lineTo

      public void lineTo(LatLonPoint2D point)
      Adds the LatLonPoint2D to the end of the polygon
      Overrides:
      lineTo in class LatLonPolygon2D
    • getVertices

      public List<LatLonPoint2D> getVertices()
      Gets a list of LatLonPoint2D vertices in this polygon
      Specified by:
      getVertices in class LatLonPolygon2D
      Returns:
      the vertices
    • getVertexCount

      public int getVertexCount()
      Specified by:
      getVertexCount in class LatLonPolygon2D
    • getLonCoords

      public double[] getLonCoords()
      Specified by:
      getLonCoords in class LatLonPolygon2D
    • getLatCoords

      public double[] getLatCoords()
      Specified by:
      getLatCoords in class LatLonPolygon2D
    • getCentroid

      public LatLonPoint2D getCentroid()
      Calculates the geometric center of this LatLonPolygon2D
      Specified by:
      getCentroid in class LatLonPolygon2D
      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:
      contains in class LatLonPolygon2D
      Parameters:
      lat - the latitude (y) of the point to test
      lon - 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 this LatLonPolygon2D and returns the coordinates as a double array 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 of double[] {lly, llx, ury, urx}.
      Specified by:
      getBoundingLatLonValues in class LatLonPolygon2D
      Returns:
      a double array with a length of 4 containing the lat/lon points of the bounding box of this LatLonPolygon2D. If this object contains no vertices null is returned.
    • getBouningLatLonRectangle2D

      public LatLonRectangle2D getBouningLatLonRectangle2D()
      Specified by:
      getBouningLatLonRectangle2D in class LatLonPolygon2D
    • intersects

      public boolean intersects(LatLonPolygon2D poly)
      Specified by:
      intersects in class LatLonPolygon2D
    • intersects

      public boolean intersects(LatLonPoint2D point, boolean crossesDateline)
      Specified by:
      intersects in class LatLonPolygon2D
    • intersects

      public boolean intersects(LatLonPoint2D e0, LatLonPoint2D e1, boolean crossesDateline)
      Specified by:
      intersects in class LatLonPolygon2D
    • distanceSq

      public double distanceSq(LatLonPoint2D p)
      Specified by:
      distanceSq in class LatLonPolygon2D