Class MapBounds

java.lang.Object
com.massifmaps.core.MapBounds

public class MapBounds extends Object
A container class that defines an axis aligned cuboid on the map using minimum and maximum map positions.
Valid ranges for map bounds depend on the projection used.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Constructs an empty MapBounds object.
    MapBounds(MapPos min, MapPos max)
    Constructs a MapBounds object from a minimum and maximum map position.
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    Tests whether this map bounds object contains a another map bounds object.
    boolean
    Tests whether this map bounds object contains a map position.
    boolean
    Checks if this object is equal to the specified object.
    Calculates the center map position of this map envelope object.
    Calculates the difference vector between the maximum and minimum map positions of this map bounds object.
    Returns the maximum (north east) map position of this map envelope object.
    Returns the minimum (south west) map position of this map envelope object.
    int
    Returns the hash value of this object.
    boolean
    Tests whether this map bounds object intersects with a another map bounds object.
    void
    Shrinks this map bounds object to the intersection of this bounds and given bounds object.
    Creates a string representation of this map bounds object, useful for logging.

    Methods inherited from class java.lang.Object

    clone, getClass, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • MapBounds

      public MapBounds()
      Constructs an empty MapBounds object. The coordinates of the minimum map position will be
      set to positive infinity and the coordinates of the maximum map position will be
      set to negative infinity.
    • MapBounds

      public MapBounds(MapPos min, MapPos max)
      Constructs a MapBounds object from a minimum and maximum map position. If a coordinate of the
      minimum map positon is larger than the same coordinate of the maximum map position then those
      coordinates will be swapped.
      Parameters:
      min - The minimum map position (south-west).
      max - The maximum map position (north-east).
  • Method Details

    • equals

      public boolean equals(Object obj)
      Checks if this object is equal to the specified object.
      Overrides:
      equals in class Object
      Parameters:
      obj - The reference object.
      Returns:
      True when objects are equal, false otherwise.
    • hashCode

      public int hashCode()
      Returns the hash value of this object.
      Overrides:
      hashCode in class Object
      Returns:
      The hash value of this object.
    • getCenter

      public MapPos getCenter()
      Calculates the center map position of this map envelope object.
      Returns:
      The center postion if this map envelope object.
    • getDelta

      public MapVec getDelta()
      Calculates the difference vector between the maximum and minimum map positions of this map bounds object.
      Returns:
      The difference vector between maximum and minimum map positions of this map bounds object.
    • getMin

      public MapPos getMin()
      Returns the minimum (south west) map position of this map envelope object.
      Returns:
      The minimum (south west) map position of this map envelope object.
    • getMax

      public MapPos getMax()
      Returns the maximum (north east) map position of this map envelope object.
      Returns:
      The maximum (north east) map position of this map envelope object.
    • contains

      public boolean contains(MapPos pos)
      Tests whether this map bounds object contains a map position.
      Parameters:
      pos - The map position.
      Returns:
      True if this map bounds object contains the map position.
    • contains

      public boolean contains(MapBounds bounds)
      Tests whether this map bounds object contains a another map bounds object.
      Parameters:
      bounds - The other map bounds object.
      Returns:
      True if this map bounds object contains the other map bounds object.
    • intersects

      public boolean intersects(MapBounds bounds)
      Tests whether this map bounds object intersects with a another map bounds object.
      Parameters:
      bounds - The other map bounds object.
      Returns:
      True if this map bounds object intersects with the other map bounds object.
    • shrinkToIntersection

      public void shrinkToIntersection(MapBounds bounds)
      Shrinks this map bounds object to the intersection of this bounds and given bounds object.
      Parameters:
      bounds - The other map bounds object.
    • toString

      public String toString()
      Creates a string representation of this map bounds object, useful for logging.
      Overrides:
      toString in class Object
      Returns:
      The string representation of this map bounds object.