Package llnl.gnem.core.polygon
Class BasePolygon
java.lang.Object
llnl.gnem.core.polygon.BasePolygon
- All Implemented Interfaces:
Serializable
- Direct Known Subclasses:
Polygon
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 Summary
ConstructorDescriptionBasePolygon
(String polygonFileName) BasePolygon
(Vertex[] P) Constructor for the Polygon objectBasePolygon
(Vertex[] P, boolean isSpansDateline) -
Method Summary
Modifier and TypeMethodDescriptionboolean
contains
(double x, double y) Determine whether a point (given as a lat and a lon is inside the BasePolygon.boolean
Determine whether a point (given as a Vertex object) is inside the BasePolygon.double
Gets the latitude of the most Northerly Vertex in the BasePolygon.double
Gets the latitude of the most Easterly Vertex in the BasePolygon.double
Gets the latitude of the most Southerly Vertex in the BasePolygon.double
Gets the latitude of the most Westerly Vertex in the BasePolygon.Vertex[]
Gets the vertices of the BasePolygon objectstatic BasePolygon
makeCirclePolygon
(Vertex center, double kmRadius, int npts) Make a BasePolygon that approximates a circle.static BasePolygon
makeCirclePolygon_Deg
(Vertex center, double DegDistance, int npts) void
scale
(double factor)
-
Constructor Details
-
BasePolygon
Constructor for the Polygon object- Parameters:
P
- A Vector of Vertex objects describing the polygon's perimeter.
-
BasePolygon
-
BasePolygon
- Throws:
IOException
-
-
Method Details
-
scale
public void scale(double factor) -
contains
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 testedy
- 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
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 BasePolygonkmRadius
- The radius of the BasePolygon in kmnpts
- The number of points in the polygon.- Returns:
- The generated BasePolygon
-
makeCirclePolygon_Deg
-
getVertices
Gets the vertices of the BasePolygon object- Returns:
- The array of Vertex objects
-