Class 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.
    • 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 box
        deltaLat - 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 corner
        right - right corner
      • 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 ucar.unidata.geoloc.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 ucar.unidata.geoloc.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 ucar.unidata.geoloc.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 ucar.unidata.geoloc.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
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object
      • nearlyEquals

        public boolean nearlyEquals​(LatLonRect other,
                                    double maxRelDiff)
        Returns true if this rectangle is nearly equal to other. The "near equality" of corners is determined using LatLonPoint.nearlyEquals(LatLonPoint, double), with the specified maxRelDiff.
        Parameters:
        other - the other rectangle to check.
        maxRelDiff - the maximum relative difference that two corners may have.
        Returns:
        true if this rectangle is nearly equal to other.
      • 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 point
        lon - 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,
                                        LatLonRect other)
        Extend the bounding box to contain another bounding box. Return new LatLonRect.
      • 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
         
        Overrides:
        toString in class Object
        Returns:
        a String representation of this object.
      • 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.