Class Position

java.lang.Object
ch.tocco.nice2.optional.geolocation.api.Position
All Implemented Interfaces:
Serializable

public class Position extends Object implements Serializable
A geographical position specified by a pair of latitude and longitude coordinates.

The walkXxx and getBoundingBox methods calculate good results for small distances only! Feel free to improve this to support e.g. travelling around the earth multiple times etc.

See Also:
  • Field Details

    • RADIUS_EARTH_KM

      public static final BigDecimal RADIUS_EARTH_KM
  • Constructor Details

  • Method Details

    • getLatitude

      public Latitude getLatitude()
    • getLongitude

      public Longitude getLongitude()
    • distanceTo

      public Distance distanceTo(Position position)
    • walkNorth

      public Position walkNorth(Distance dst)
      Returns the position located dst northern from this.
      Parameters:
      dst - the travelling distance
      Returns:
      the new position dst northern from this
    • walkSouth

      public Position walkSouth(Distance dst)
      Returns the position located dst southern from this.
      Parameters:
      dst - the travelling distance
      Returns:
      the new position dst southern from this
    • walkEast

      public Position walkEast(Distance dst)
      Returns the position located dst eastern from this.
      Parameters:
      dst - the travelling distance
      Returns:
      the new position dst eastern from this
    • walkWest

      public Position walkWest(Distance dst)
      Returns the position located dst western from this.
      Parameters:
      dst - the travelling distance
      Returns:
      the new position dst western from this
    • getBoundingBox

      public Position[] getBoundingBox(Distance dst)
      Returns a bounding square around this position where this is the center of the square. Note, the result is the unexacter the larger the distance gets!
      Parameters:
      dst - the distance from this position to an edge of the square (so the total width of one side of the bounding box is 2 * dist).
      Returns:
      two positions in an array where the fist element is the upper-left corner and the second element is the lower-right corner
    • equals

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

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

      public String toString()
      Overrides:
      toString in class Object