Class BoundingBox

java.lang.Object
org.oscim.core.BoundingBox

public class BoundingBox extends Object
A BoundingBox represents an immutable set of two latitude and two longitude coordinates.
  • Field Details

    • maxLatitudeE6

      public int maxLatitudeE6
      The maximum latitude value of this BoundingBox in microdegrees (degrees * 10^6).
    • maxLongitudeE6

      public int maxLongitudeE6
      The maximum longitude value of this BoundingBox in microdegrees (degrees * 10^6).
    • minLatitudeE6

      public int minLatitudeE6
      The minimum latitude value of this BoundingBox in microdegrees (degrees * 10^6).
    • minLongitudeE6

      public int minLongitudeE6
      The minimum longitude value of this BoundingBox in microdegrees (degrees * 10^6).
  • Constructor Details

    • BoundingBox

      public BoundingBox(int minLatitudeE6, int minLongitudeE6, int maxLatitudeE6, int maxLongitudeE6)
      Parameters:
      minLatitudeE6 - the minimum latitude in microdegrees (degrees * 10^6).
      minLongitudeE6 - the minimum longitude in microdegrees (degrees * 10^6).
      maxLatitudeE6 - the maximum latitude in microdegrees (degrees * 10^6).
      maxLongitudeE6 - the maximum longitude in microdegrees (degrees * 10^6).
    • BoundingBox

      public BoundingBox(double minLatitude, double minLongitude, double maxLatitude, double maxLongitude)
      Parameters:
      minLatitude - the minimum latitude coordinate in degrees.
      minLongitude - the minimum longitude coordinate in degrees.
      maxLatitude - the maximum latitude coordinate in degrees.
      maxLongitude - the maximum longitude coordinate in degrees.
    • BoundingBox

      public BoundingBox(List<GeoPoint> geoPoints)
      Parameters:
      geoPoints - the coordinates list.
  • Method Details

    • contains

      public boolean contains(GeoPoint geoPoint)
      Parameters:
      geoPoint - the point whose coordinates should be checked.
      Returns:
      true if this BoundingBox contains the given GeoPoint, false otherwise.
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • extendBoundingBox

      public BoundingBox extendBoundingBox(BoundingBox boundingBox)
      Parameters:
      boundingBox - the BoundingBox which this BoundingBox should be extended if it is larger
      Returns:
      a BoundingBox that covers this BoundingBox and the given BoundingBox.
    • extendCoordinates

      public BoundingBox extendCoordinates(GeoPoint geoPoint)
      Creates a BoundingBox extended up to GeoPoint (but does not cross date line/poles).
      Parameters:
      geoPoint - coordinates up to the extension
      Returns:
      an extended BoundingBox or this (if contains coordinates)
    • extendDegrees

      public BoundingBox extendDegrees(double verticalExpansion, double horizontalExpansion)
      Creates a BoundingBox that is a fixed degree amount larger on all sides (but does not cross date line/poles).
      Parameters:
      verticalExpansion - degree extension (must be >= 0)
      horizontalExpansion - degree extension (must be >= 0)
      Returns:
      an extended BoundingBox or this (if degrees == 0)
    • extendMargin

      public BoundingBox extendMargin(float margin)
      Creates a BoundingBox that is a fixed margin factor larger on all sides (but does not cross date line/poles).
      Parameters:
      margin - extension (must be > 0)
      Returns:
      an extended BoundingBox or this (if margin == 1)
    • extendMeters

      public BoundingBox extendMeters(int meters)
      Creates a BoundingBox that is a fixed meter amount larger on all sides (but does not cross date line/poles).
      Parameters:
      meters - extension (must be >= 0)
      Returns:
      an extended BoundingBox or this (if meters == 0)
    • format

      public String format()
    • getCenterPoint

      public GeoPoint getCenterPoint()
      Returns:
      the GeoPoint at the horizontal and vertical center of this BoundingBox.
    • getLatitudeSpan

      public double getLatitudeSpan()
      Returns:
      the latitude span of this BoundingBox in degrees.
    • getLongitudeSpan

      public double getLongitudeSpan()
      Returns:
      the longitude span of this BoundingBox in degrees.
    • getMaxLatitude

      public double getMaxLatitude()
      Returns:
      the maximum latitude value of this BoundingBox in degrees.
    • getMaxLongitude

      public double getMaxLongitude()
      Returns:
      the maximum longitude value of this BoundingBox in degrees.
    • getMinLatitude

      public double getMinLatitude()
      Returns:
      the minimum latitude value of this BoundingBox in degrees.
    • getMinLongitude

      public double getMinLongitude()
      Returns:
      the minimum longitude value of this BoundingBox in degrees.
    • hashCode

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

      public boolean intersects(BoundingBox boundingBox)
      Parameters:
      boundingBox - the BoundingBox which should be checked for intersection with this BoundingBox.
      Returns:
      true if this BoundingBox intersects with the given BoundingBox, false otherwise.
    • intersectsArea

      public boolean intersectsArea(GeoPoint[][] geoPoints)
      Returns if an area built from the geoPoints intersects with a bias towards returning true. The method returns fast if any of the points lie within the bbox. If none of the points lie inside the box, it constructs the outer bbox for all the points and tests for intersection (so it is possible that the area defined by the points does not actually intersect)
      Parameters:
      geoPoints - the points that define an area
      Returns:
      false if there is no intersection, true if there could be an intersection
    • toString

      public String toString()
      Overrides:
      toString in class Object