Package ucar.unidata.geoloc
Class LatLonRect
java.lang.Object
ucar.unidata.geoloc.LatLonRect
Bounding box for latitude/longitude points.
This is a rectangle in lat/lon coordinates.
This class handles the longitude wrapping problem.
The Rectangle always starts from lowerLeft, goes east width degrees until upperRight
For latitude, lower < upper.
Since the longitude must be in the range +/-180., right may be less or greater than left.
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionCreate a LatLonRect that covers the whole world.LatLonRect(String spec) Construct a lat/lon bounding box from a string.LatLonRect(LatLonPoint p1, double deltaLat, double deltaLon) Construct a lat/lon bounding box from a point, and a delta lat, lon.LatLonRect(LatLonPoint left, LatLonPoint right) Construct a lat/lon bounding box from two points.Copy Constructor -
Method Summary
Modifier and TypeMethodDescriptionbooleanDetermine if this bounding box is contained in another LatLonRect.booleancontains(double lat, double lon) Determine if the given lat/lon point is contined inside this rectangle.booleanDetermine if a specified LatLonPoint is contained in this bounding box.booleanreturn does this rectangle contain all longitudesbooleanGet whether the bounding box crosses the +/- 180 seambooleanvoidDeprecated.use LatLonRect.extend()voidextend(LatLonRect r) Deprecated.use LatLonRect.extend()static LatLonRectextend(LatLonRect rect, LatLonPoint p) Extend the bounding box to contain this point.static LatLonRectextend(LatLonRect rect, LatLonRect other) Extend the bounding box to contain another bounding box.doublereturn center Longitude, always in the range +/-180doublereturn height of bounding box, always between 0 and 180 degrees.doubleGet maximum latitude, aka "north" edgedoubleGet minimum latitude, aka "south" edgedoubleGet maximum longitude, aka "east" edgedoubleGet minimum longitude, aka "west" edgeGet the lower left corner of the bounding box.Get the lower left corner of the bounding box.Get the upper left corner of the bounding box.Get the upper right corner of the bounding box.doublegetWidth()return width of bounding box, always between 0 and 360 degrees.inthashCode()intersect(LatLonRect clip) Create the instersection of this LatLon with the given onebooleannearlyEquals(LatLonRect other) Returns the result ofnearlyEquals(LatLonRect, double), withMisc.defaultMaxRelativeDiffFloat.booleannearlyEquals(LatLonRect other, double maxRelDiff) Returnstrueif this rectangle is nearly equal toother.toString()Return a String representation of this object.Return a String representation of this object.
-
Field Details
-
INVALID
-
-
Constructor Details
-
LatLonRect
Construct a lat/lon bounding box from a point, and a delta lat, lon. This disambiguates which way the box wraps around the globe.- Parameters:
p1- one corner of the boxdeltaLat- delta lat from p1. (may be positive or negetive)deltaLon- delta lon from p1. (may be positive or negetive)
-
LatLonRect
Construct a lat/lon bounding box from two points. The order of longitude coord of the two points matters: pt1.lon is always the "left" point, then points contained within the box increase (unless crossing the Dateline, in which case they jump to -180, but then start increasing again) until pt2.lon The order of lat doesnt matter: smaller will go to "lower" point (further south)- Parameters:
left- left cornerright- right corner
-
LatLonRect
Construct a lat/lon bounding box from a string.- Parameters:
spec- "lat, lon, deltaLat, deltaLon"- See Also:
-
LatLonRect
Copy Constructor- Parameters:
r- rectangle to copy
-
LatLonRect
public LatLonRect()Create a LatLonRect that covers the whole world.
-
-
Method Details
-
getUpperRightPoint
Get the upper right corner of the bounding box.- Returns:
- upper right corner of the bounding box LOOK will return LatLonPoint in ver6
-
getLowerLeftPoint
Get the lower left corner of the bounding box.- Returns:
- lower left corner of the bounding box LOOK will return LatLonPoint in ver6
-
getUpperLeftPoint
Get the upper left corner of the bounding box.- Returns:
- upper left corner of the bounding box LOOK will return LatLonPoint in ver6
-
getLowerRightPoint
Get the lower left corner of the bounding box.- Returns:
- lower left corner of the bounding box LOOK will return LatLonPoint in ver6
-
crossDateline
public boolean crossDateline()Get whether the bounding box crosses the +/- 180 seam- Returns:
- true if the bounding box crosses the +/- 180 seam
-
equals
-
hashCode
public int hashCode() -
nearlyEquals
Returns the result ofnearlyEquals(LatLonRect, double), withMisc.defaultMaxRelativeDiffFloat. -
nearlyEquals
Returnstrueif this rectangle is nearly equal toother. The "near equality" of corners is determined usingLatLonPoint.nearlyEquals(LatLonPoint, double), with the specified maxRelDiff.- Parameters:
other- the other rectangle to check.maxRelDiff- the maximumrelative differencethat two corners may have.- Returns:
trueif this rectangle is nearly equal toother.
-
containsAllLongitude
public boolean containsAllLongitude()return does this rectangle contain all longitudes- Returns:
- true if all longitudes are contained (width is >= 360) else false
-
getWidth
public double getWidth()return width of bounding box, always between 0 and 360 degrees.- Returns:
- width of bounding box in degrees longitude
-
getHeight
public double getHeight()return height of bounding box, always between 0 and 180 degrees.- Returns:
- height of bounding box in degrees latitude
-
getCenterLon
public double getCenterLon()return center Longitude, always in the range +/-180- Returns:
- center Longitude
-
getLonMin
public double getLonMin()Get minimum longitude, aka "west" edge- Returns:
- minimum longitude
-
getLonMax
public double getLonMax()Get maximum longitude, aka "east" edge- Returns:
- maximum longitude
-
getLatMin
public double getLatMin()Get minimum latitude, aka "south" edge- Returns:
- minimum latitude
-
getLatMax
public double getLatMax()Get maximum latitude, aka "north" edge- Returns:
- maximum latitude
-
contains
Determine if a specified LatLonPoint is contained in this bounding box.- Parameters:
p- the specified point to be tested- Returns:
- true if point is contained in this bounding box
-
contains
public boolean contains(double lat, double lon) Determine if the given lat/lon point is contined inside this rectangle.- Parameters:
lat- lat of pointlon- lon of point- Returns:
- true if the given lat/lon point is contined inside this rectangle
-
containedIn
Determine if this bounding box is contained in another LatLonRect.- Parameters:
b- the other box to see if it contains this one- Returns:
- true if b contained in this bounding box
-
extend
Extend the bounding box to contain this point. Return new LatLonRect. -
extend
Extend the bounding box to contain another bounding box. Return new LatLonRect. -
extend
Deprecated.use LatLonRect.extend()Extend the bounding box to contain this point- Parameters:
p- point to include
-
extend
Deprecated.use LatLonRect.extend()Extend the bounding box to contain the given rectangle- Parameters:
r- rectangle to include
-
intersect
Create the instersection of this LatLon with the given one- Parameters:
clip- intersect with this- Returns:
- intersection, or null if there is no intersection
-
toString
Return a String representation of this object.eg: ll: 90.0S .0E+ ur: 90.0N .0E
-
toString2
Return a String representation of this object.lat= [-90.00,90.00] lon= [0.00,360.00
- Returns:
- a String representation of this object.
-