Package ucar.unidata.geoloc
Class LatLonRect
- java.lang.Object
-
- ucar.unidata.geoloc.LatLonRect
-
public class LatLonRect extends Object
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 Modifier and Type Field Description static LatLonRect
INVALID
-
Constructor Summary
Constructors Constructor Description LatLonRect()
Create 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.LatLonRect(LatLonRect r)
Copy Constructor
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description boolean
containedIn(LatLonRect b)
Determine if this bounding box is contained in another LatLonRect.boolean
contains(double lat, double lon)
Determine if the given lat/lon point is contined inside this rectangle.boolean
contains(LatLonPoint p)
Determine if a specified LatLonPoint is contained in this bounding box.boolean
containsAllLongitude()
return does this rectangle contain all longitudesboolean
crossDateline()
Get whether the bounding box crosses the +/- 180 seamboolean
equals(Object o)
void
extend(LatLonPoint p)
Deprecated.use LatLonRect.extend()void
extend(LatLonRect r)
Deprecated.use LatLonRect.extend()static LatLonRect
extend(LatLonRect rect, LatLonPoint p)
Extend the bounding box to contain this point.static LatLonRect
extend(LatLonRect rect, LatLonRect other)
Extend the bounding box to contain another bounding box.double
getCenterLon()
return center Longitude, always in the range +/-180double
getHeight()
return height of bounding box, always between 0 and 180 degrees.double
getLatMax()
Get maximum latitude, aka "north" edgedouble
getLatMin()
Get minimum latitude, aka "south" edgedouble
getLonMax()
Get maximum longitude, aka "east" edgedouble
getLonMin()
Get minimum longitude, aka "west" edgeLatLonPointImpl
getLowerLeftPoint()
Get the lower left corner of the bounding box.LatLonPointImpl
getLowerRightPoint()
Get the lower left corner of the bounding box.LatLonPointImpl
getUpperLeftPoint()
Get the upper left corner of the bounding box.LatLonPointImpl
getUpperRightPoint()
Get the upper right corner of the bounding box.double
getWidth()
return width of bounding box, always between 0 and 360 degrees.int
hashCode()
LatLonRect
intersect(LatLonRect clip)
Create the instersection of this LatLon with the given oneboolean
nearlyEquals(LatLonRect other)
Returns the result ofnearlyEquals(LatLonRect, double)
, withMisc.defaultMaxRelativeDiffFloat
.boolean
nearlyEquals(LatLonRect other, double maxRelDiff)
Returnstrue
if this rectangle is nearly equal toother
.String
toString()
Return a String representation of this object.String
toString2()
Return a String representation of this object.
-
-
-
Field Detail
-
INVALID
public static LatLonRect INVALID
-
-
Constructor Detail
-
LatLonRect
public LatLonRect(LatLonPoint p1, double deltaLat, double deltaLon)
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
public LatLonRect(LatLonPoint left, LatLonPoint right)
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
public LatLonRect(String spec)
Construct a lat/lon bounding box from a string.- Parameters:
spec
- "lat, lon, deltaLat, deltaLon"- See Also:
LatLonRect(LatLonPoint p1, double deltaLat, double deltaLon)
-
LatLonRect
public LatLonRect(LatLonRect r)
Copy Constructor- Parameters:
r
- rectangle to copy
-
LatLonRect
public LatLonRect()
Create a LatLonRect that covers the whole world.
-
-
Method Detail
-
getUpperRightPoint
public LatLonPointImpl 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
public LatLonPointImpl 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
public LatLonPointImpl 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
public LatLonPointImpl 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
-
nearlyEquals
public boolean nearlyEquals(LatLonRect other)
Returns the result ofnearlyEquals(LatLonRect, double)
, withMisc.defaultMaxRelativeDiffFloat
.
-
nearlyEquals
public boolean nearlyEquals(LatLonRect other, double maxRelDiff)
Returnstrue
if 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 difference
that two corners may have.- Returns:
true
if 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
public boolean contains(LatLonPoint p)
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
public boolean containedIn(LatLonRect b)
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
public static LatLonRect extend(LatLonRect rect, LatLonPoint p)
Extend the bounding box to contain this point. Return new LatLonRect.
-
extend
public static LatLonRect extend(LatLonRect rect, LatLonRect other)
Extend the bounding box to contain another bounding box. Return new LatLonRect.
-
extend
@Deprecated public void extend(LatLonPoint p)
Deprecated.use LatLonRect.extend()Extend the bounding box to contain this point- Parameters:
p
- point to include
-
extend
@Deprecated public void extend(LatLonRect r)
Deprecated.use LatLonRect.extend()Extend the bounding box to contain the given rectangle- Parameters:
r
- rectangle to include
-
intersect
public LatLonRect intersect(LatLonRect clip)
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
public String toString()
Return a String representation of this object.eg: ll: 90.0S .0E+ ur: 90.0N .0E
-
toString2
public String 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.
-
-