Class BBox

java.lang.Object
com.graphhopper.util.shapes.BBox
All Implemented Interfaces:
Shape, Cloneable

public class BBox extends Object implements Shape, Cloneable
A simple bounding box defined as follows: minLon, maxLon followed by minLat which is south(!) and maxLat. Equally to EX_GeographicBoundingBox in the ISO 19115 standard see http://osgeo-org.1560.n6.nabble.com/Boundingbox-issue-for-discussion-td3875533.html

Nice German overview: http://www.geoinf.uni-jena.de/fileadmin/Geoinformatik/Lehre/Diplomarbeiten/DA_Andres.pdf

Author:
Peter Karich
  • Field Details

    • minLon

      public double minLon
    • maxLon

      public double maxLon
    • minLat

      public double minLat
    • maxLat

      public double maxLat
    • minEle

      public double minEle
    • maxEle

      public double maxEle
  • Constructor Details

    • BBox

      public BBox(double[] coords)
    • BBox

      public BBox(double minLon, double maxLon, double minLat, double maxLat)
    • BBox

      public BBox(double minLon, double maxLon, double minLat, double maxLat, double minEle, double maxEle)
    • BBox

      public BBox(double minLon, double maxLon, double minLat, double maxLat, double minEle, double maxEle, boolean elevation)
  • Method Details

    • createInverse

      public static BBox createInverse(boolean elevation)
      Prefills BBox with minimum values so that it can increase.
    • hasElevation

      public boolean hasElevation()
    • update

      public void update(double lat, double lon)
    • update

      public void update(double lat, double lon, double elev)
    • calculateIntersection

      public BBox calculateIntersection(BBox bBox)
      Calculates the intersecting BBox between this and the specified BBox
      Returns:
      the intersecting BBox or null if not intersecting
    • clone

      public BBox clone()
      Overrides:
      clone in class Object
    • intersects

      public static boolean intersects(org.locationtech.jts.algorithm.RectangleLineIntersector intersector, PointList pointList)
    • intersects

      public boolean intersects(PointList pointList)
      Specified by:
      intersects in interface Shape
    • intersects

      public boolean intersects(double minLon, double maxLon, double minLat, double maxLat)
      This method calculates if this BBox intersects with the specified BBox
    • intersects

      public boolean intersects(BBox o)
      This method calculates if this BBox intersects with the specified BBox
    • contains

      public boolean contains(double lat, double lon)
      Specified by:
      contains in interface Shape
      Returns:
      true only if lat and lon are inside (or on the edge) of this shape
    • contains

      public boolean contains(BBox b)
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • toLessPrecisionString

      public String toLessPrecisionString()
    • getBounds

      public BBox getBounds()
      Specified by:
      getBounds in interface Shape
      Returns:
      the minimal rectangular bounding box of this shape
    • equals

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

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

      public boolean isValid()
    • toGeoJson

      public List<Double> toGeoJson()
      Returns:
      array containing this bounding box. Attention: GeoJson is lon,lat! If 3D is gets even worse: lon,lat,ele
    • fromEnvelope

      public static BBox fromEnvelope(org.locationtech.jts.geom.Envelope envelope)
    • toEnvelope

      public static org.locationtech.jts.geom.Envelope toEnvelope(BBox bbox)
    • parseTwoPoints

      public static BBox parseTwoPoints(String objectAsString)
      This method creates a BBox out of a string in format lat1,lon1,lat2,lon2
    • fromPoints

      public static BBox fromPoints(double lat1, double lon1, double lat2, double lon2)
    • parseBBoxString

      public static BBox parseBBoxString(String objectAsString)
      This method creates a BBox out of a string in format lon1,lon2,lat1,lat2