Class BasePolygon

java.lang.Object
llnl.gnem.core.polygon.BasePolygon
All Implemented Interfaces:
Serializable
Direct Known Subclasses:
Polygon

public class BasePolygon extends Object implements Serializable
Encapsulates a Vector of Vertices describing a polygon and provides operations to rapidly determine whether a point is inside the polygon.
Author:
Doug Dodge
See Also:
  • Constructor Details

    • BasePolygon

      public BasePolygon(Vertex[] P)
      Constructor for the Polygon object
      Parameters:
      P - A Vector of Vertex objects describing the polygon's perimeter.
    • BasePolygon

      public BasePolygon(Vertex[] P, boolean isSpansDateline)
    • BasePolygon

      public BasePolygon(String polygonFileName) throws IOException
      Throws:
      IOException
  • Method Details

    • scale

      public void scale(double factor)
    • contains

      public boolean contains(Vertex t)
      Determine whether a point (given as a Vertex object) is inside the BasePolygon. Uses a method by Sedgewick, "Algorithms in C"
      Parameters:
      t - The point to be tested
      Returns:
      true if the point is inside the BasePolygon
    • contains

      public boolean contains(double x, double y)
      Determine whether a point (given as a lat and a lon is inside the BasePolygon. Uses a method by Sedgewick, "Algorithms in C"
      Parameters:
      x - The latitude of the point to be tested
      y - The longitude of the point to be tested
      Returns:
      true if the point is inside the BasePolygon
    • getMinLat

      public double getMinLat()
      Gets the latitude of the most Southerly Vertex in the BasePolygon. For rapid selection of candidate points from the database, it is convenient to get the lat and lon extrema of the BasePolygon to form a query that returns all the points within the smallest box that encloses the BasePolygon.
      Returns:
      The minLat value
    • getMaxLat

      public double getMaxLat()
      Gets the latitude of the most Northerly Vertex in the BasePolygon. For rapid selection of candidate points from the database, it is convenient to get the lat and lon extrema of the BasePolygon to form a query that returns all the points within the smallest box that encloses the BasePolygon.
      Returns:
      The maxLat value
    • getMinLon

      public double getMinLon()
      Gets the latitude of the most Westerly Vertex in the BasePolygon. For rapid selection of candidate points from the database, it is convenient to get the lat and lon extrema of the BasePolygon to form a query that returns all the points within the smallest box that encloses the BasePolygon.
      Returns:
      The minLon value
    • getMaxLon

      public double getMaxLon()
      Gets the latitude of the most Easterly Vertex in the BasePolygon. For rapid selection of candidate points from the database, it is convenient to get the lat and lon extrema of the BasePolygon to form a query that returns all the points within the smallest box that encloses the BasePolygon.
      Returns:
      The maxLon value
    • makeCirclePolygon

      public static BasePolygon makeCirclePolygon(Vertex center, double kmRadius, int npts)
      Make a BasePolygon that approximates a circle. The approximation will be good for small radii near the Equator and poor near the poles.
      Parameters:
      center - The center of the BasePolygon
      kmRadius - The radius of the BasePolygon in km
      npts - The number of points in the polygon.
      Returns:
      The generated BasePolygon
    • makeCirclePolygon_Deg

      public static BasePolygon makeCirclePolygon_Deg(Vertex center, double DegDistance, int npts)
    • getVertices

      public Vertex[] getVertices()
      Gets the vertices of the BasePolygon object
      Returns:
      The array of Vertex objects