Class Geo


  • public class Geo
    extends Object
    A collection of geometric operating on geometry with coordinates in the WGS84 coordinate system.
    • Constructor Summary

      Constructors 
      Constructor Description
      Geo()  
      Geo​(org.locationtech.jts.geom.GeometryFactory geometryFactory)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      org.locationtech.jts.geom.Polygon approximateCircle​(org.locationtech.jts.geom.Coordinate center, double radius)
      Create a polygon geometry that approximates a circle.
      org.locationtech.jts.geom.Polygon approximateCircle​(org.locationtech.jts.geom.Coordinate center, double radius, int numberOfPoints)
      Create a polygon geometry that approximates a circle.
      double calculateBearing​(org.locationtech.jts.geom.Coordinate from, org.locationtech.jts.geom.Coordinate to)
      Calculate the bearing angle between a pair of coordinates.
      double calculateBearing​(org.locationtech.jts.geom.Point from, org.locationtech.jts.geom.Point to)
      Calculate the bearing angle between a pair of points.
      double calculateBearingDifference​(double bearingA, double bearingB)
      Calculate the absolute angle difference in degrees between a pair of bearing angles.
      org.locationtech.jts.geom.Coordinate calculateCoordinateAlongLineString​(org.locationtech.jts.geom.LineString lineString, double fraction)
      Calculate the coordinate along a line string at a certain fraction of the line string's length.
      double calculateDistance​(org.locationtech.jts.geom.Coordinate coordinateA, org.locationtech.jts.geom.Coordinate coordinateB)
      Calculate the distance in meters between a pair of coordinates.
      double calculateDistance​(org.locationtech.jts.geom.Point pointA, org.locationtech.jts.geom.Point pointB)
      Calculate the distance in meters between a pair of points.
      org.locationtech.jts.geom.Point calculatePointAlongLineString​(org.locationtech.jts.geom.LineString lineString, double fraction)
      Calculate the point along a line string at a certain fraction of the line string's length.
      org.locationtech.jts.geom.LineString joinLineStrings​(List<org.locationtech.jts.geom.LineString> lineStrings)
      Join a sequence of line strings together to form a single line string.
      double projectOnLineString​(org.locationtech.jts.geom.Coordinate coordinate, org.locationtech.jts.geom.LineString lineString)
      Project a coordinate onto a line string and return fraction along the line string from the start where the projection point is found.
      org.locationtech.jts.geom.LineString sliceLineString​(org.locationtech.jts.geom.LineString lineString, double startFraction, double stopFraction)
      Create a slice of a line string that begins at a start fraction and ends at a stop fraction of the line string's length.
    • Constructor Detail

      • Geo

        public Geo​(org.locationtech.jts.geom.GeometryFactory geometryFactory)
      • Geo

        public Geo()
    • Method Detail

      • calculateDistance

        public double calculateDistance​(org.locationtech.jts.geom.Coordinate coordinateA,
                                        org.locationtech.jts.geom.Coordinate coordinateB)
        Calculate the distance in meters between a pair of coordinates.
        Parameters:
        coordinateA - the first coordinate
        coordinateB - the second coordinate
        Returns:
        the distance in meters between the coordinate pair
      • calculateDistance

        public double calculateDistance​(org.locationtech.jts.geom.Point pointA,
                                        org.locationtech.jts.geom.Point pointB)
        Calculate the distance in meters between a pair of points.
        Parameters:
        pointA - the first point
        pointB - the second point
        Returns:
        the distance in meters between the point pair
      • calculateBearing

        public double calculateBearing​(org.locationtech.jts.geom.Coordinate from,
                                       org.locationtech.jts.geom.Coordinate to)
        Calculate the bearing angle between a pair of coordinates. The angle is returned in degrees 0° >= angle < 360° and is the angle in a clockwise direction relative to due north.
        Parameters:
        from - the origin coordinate
        to - the destination coordinate
        Returns:
        the bearing angle from origin to destination
      • calculateBearing

        public double calculateBearing​(org.locationtech.jts.geom.Point from,
                                       org.locationtech.jts.geom.Point to)
        Calculate the bearing angle between a pair of points. The angle is returned in degrees 0° >= angle < 360° and is the angle in a clockwise direction relative to due north.
        Parameters:
        from - the origin point
        to - the destination point
        Returns:
        the bearing angle from origin to destination
      • calculateBearingDifference

        public double calculateBearingDifference​(double bearingA,
                                                 double bearingB)
        Calculate the absolute angle difference in degrees between a pair of bearing angles. The angle is returned in degrees 0° >= angle < 180°.
        Parameters:
        bearingA - the first bearing angle
        bearingB - the second bearing angle
        Returns:
        the difference between the pair of angles
      • projectOnLineString

        public double projectOnLineString​(org.locationtech.jts.geom.Coordinate coordinate,
                                          org.locationtech.jts.geom.LineString lineString)
        Project a coordinate onto a line string and return fraction along the line string from the start where the projection point is found.
        Parameters:
        coordinate - the coordinate to project
        lineString - the line string to project onto
        Returns:
        the fraction along the line string where the projection point is found
      • calculateCoordinateAlongLineString

        public org.locationtech.jts.geom.Coordinate calculateCoordinateAlongLineString​(org.locationtech.jts.geom.LineString lineString,
                                                                                       double fraction)
        Calculate the coordinate along a line string at a certain fraction of the line string's length.
        Parameters:
        lineString - the line string
        fraction - the fraction along the line string
        Returns:
        the coordinate at this fraction
      • calculatePointAlongLineString

        public org.locationtech.jts.geom.Point calculatePointAlongLineString​(org.locationtech.jts.geom.LineString lineString,
                                                                             double fraction)
        Calculate the point along a line string at a certain fraction of the line string's length.
        Parameters:
        lineString - the line string
        fraction - the fraction along the line string
        Returns:
        the point at this fraction
      • joinLineStrings

        public org.locationtech.jts.geom.LineString joinLineStrings​(List<org.locationtech.jts.geom.LineString> lineStrings)
        Join a sequence of line strings together to form a single line string. The line strings must be connected ie. the start point of any line string must be the same as the end point of the preceding line string.
        Parameters:
        lineStrings - a sequence of line strings
        Returns:
        the concatenation of the line strings
      • sliceLineString

        public org.locationtech.jts.geom.LineString sliceLineString​(org.locationtech.jts.geom.LineString lineString,
                                                                    double startFraction,
                                                                    double stopFraction)
        Create a slice of a line string that begins at a start fraction and ends at a stop fraction of the line string's length.
        Parameters:
        lineString - the line string to slice
        startFraction - the fraction along the line string where the slice begins
        stopFraction - the fraction along the line string where the slice ends
        Returns:
        the slice of the line string
      • approximateCircle

        public org.locationtech.jts.geom.Polygon approximateCircle​(org.locationtech.jts.geom.Coordinate center,
                                                                   double radius)
        Create a polygon geometry that approximates a circle.
        Parameters:
        center - the center point of the circle
        radius - the radius of the circle in meters
        Returns:
        a polygon that approximates the circle geometry
      • approximateCircle

        public org.locationtech.jts.geom.Polygon approximateCircle​(org.locationtech.jts.geom.Coordinate center,
                                                                   double radius,
                                                                   int numberOfPoints)
        Create a polygon geometry that approximates a circle. The number of points in the resulting polygon shell is provided. This controls the accuracy of the approximation.
        Parameters:
        center - the center point of the circle
        radius - the radius of the circle in meters
        numberOfPoints - the number of points in the polygon shell
        Returns:
        a polygon that approximates the circle geometry