Class GeoPointUtils

java.lang.Object
org.oscim.utils.GeoPointUtils

public final class GeoPointUtils extends Object
The coordinate validation functions come from Mapsforge LatLongUtils class.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final double
    Maximum possible latitude coordinate.
    static final double
    Minimum possible latitude coordinate.
    static final double
    Maximum possible longitude coordinate.
    static final double
    Minimum possible longitude coordinate.
  • Method Summary

    Modifier and Type
    Method
    Description
    static boolean
    contains(GeoPoint[] geoPoints, GeoPoint geoPoint)
    Find if the given point lies within this polygon.
    static double
    distanceSegmentPoint(double startX, double startY, double endX, double endY, double pointX, double pointY)
    Returns the distance between the given segment and point.
    static boolean
    isClosedWay(GeoPoint[] geoPoints)
    Find if this way is closed.
    static Point
    nearestSegmentPoint(double startX, double startY, double endX, double endY, double pointX, double pointY)
    Returns a point on the segment nearest to the specified point.
    static double
    scaleForBounds(BoundingBox bbox, int viewWidth, int viewHeight)
    Calculates the scale that allows to display the BoundingBox on a view with width and height.
    static double
    validateLatitude(double latitude)
     
    static double
    validateLongitude(double longitude)
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • LATITUDE_MAX

      public static final double LATITUDE_MAX
      Maximum possible latitude coordinate.
      See Also:
    • LATITUDE_MIN

      public static final double LATITUDE_MIN
      Minimum possible latitude coordinate.
      See Also:
    • LONGITUDE_MAX

      public static final double LONGITUDE_MAX
      Maximum possible longitude coordinate.
      See Also:
    • LONGITUDE_MIN

      public static final double LONGITUDE_MIN
      Minimum possible longitude coordinate.
      See Also:
  • Method Details

    • contains

      public static boolean contains(GeoPoint[] geoPoints, GeoPoint geoPoint)
      Find if the given point lies within this polygon.

      http://www.ecse.rpi.edu/Homepages/wrf/Research/Short_Notes/pnpoly.html

      Returns:
      true if this polygon contains the given point, false otherwise.
    • distanceSegmentPoint

      public static double distanceSegmentPoint(double startX, double startY, double endX, double endY, double pointX, double pointY)
      Returns the distance between the given segment and point.

      libGDX (Apache 2.0)

    • isClosedWay

      public static boolean isClosedWay(GeoPoint[] geoPoints)
      Find if this way is closed.
      Returns:
      true if this way is closed, false otherwise.
    • nearestSegmentPoint

      public static Point nearestSegmentPoint(double startX, double startY, double endX, double endY, double pointX, double pointY)
      Returns a point on the segment nearest to the specified point.

      libGDX (Apache 2.0)

    • scaleForBounds

      public static double scaleForBounds(BoundingBox bbox, int viewWidth, int viewHeight)
      Calculates the scale that allows to display the BoundingBox on a view with width and height.
      Parameters:
      bbox - the BoundingBox to display.
      viewWidth - the width of the view.
      viewHeight - the height of the view.
      Returns:
      the scale that allows to display the BoundingBox on a view with width and height.
    • validateLatitude

      public static double validateLatitude(double latitude)
      Parameters:
      latitude - the latitude coordinate in degrees which should be validated.
      Returns:
      the latitude value
      Throws:
      IllegalArgumentException - if the latitude coordinate is invalid or Double.NaN.
    • validateLongitude

      public static double validateLongitude(double longitude)
      Parameters:
      longitude - the longitude coordinate in degrees which should be validated.
      Returns:
      the longitude value
      Throws:
      IllegalArgumentException - if the longitude coordinate is invalid or Double.NaN.