Class Geo


  • public class Geo
    extends Object
    Geometry utility functions.
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static double areaOf​(org.locationtech.jts.geom.Geometry geom)
      Calculate the approximate area of an arbitrary geometry.
      static double areaOf​(org.locationtech.jts.geom.GeometryCollection geometryCollection)
      Calculate the approximate area of a geometry collection.
      static double areaOf​(org.locationtech.jts.geom.MultiPolygon multipoly)
      Calculate the approximate area of a multi polygon.
      static double areaOf​(org.locationtech.jts.geom.Polygon poly)
      Calculate the approximate area of an arbitrary geometry.
      static org.locationtech.jts.geom.Geometry clip​(org.locationtech.jts.geom.Geometry obj, OSHDBBoundingBox bbox)  
      static <P extends org.locationtech.jts.geom.Geometry & org.locationtech.jts.geom.Polygonal>
      org.locationtech.jts.geom.Geometry
      clip​(org.locationtech.jts.geom.Geometry obj, P poly)  
      static double lengthOf​(org.locationtech.jts.geom.Geometry geom)
      Calculate the approximate length of an arbitrary geometry.
      static double lengthOf​(org.locationtech.jts.geom.GeometryCollection geometryCollection)
      Calculate the approximate length of a multi geometry.
      static double lengthOf​(org.locationtech.jts.geom.LineString line)
      Calculate the approximate length of a line string.
      static double lengthOf​(org.locationtech.jts.geom.MultiLineString multiline)
      Calculate the approximate length of a multi line string.
    • Method Detail

      • lengthOf

        public static double lengthOf​(org.locationtech.jts.geom.LineString line)
        Calculate the approximate length of a line string.

        Uses an equirectangular distance approximation, which works well assuming segments are short.

        Adjusted to partially account for the spheroidal shape of the earth (WGS84 coordinates). See https://gis.stackexchange.com/a/63047/41632

        For typical features present in OpenStreetMap data, the relative error introduced by this approximation is below 0.1%

        Parameters:
        line - the coordinates of the line. coordinates must be in WGS84
        Returns:
        The approximate geodesic length of the line string in meters.
      • lengthOf

        public static double lengthOf​(org.locationtech.jts.geom.MultiLineString multiline)
        Calculate the approximate length of a multi line string.

        See lengthOf(LineString) for further details.

        Parameters:
        multiline - the geometry of the multi line. coordinates must be in WGS84
        Returns:
        The approximate geodesic length of the line string in meters.
      • lengthOf

        public static double lengthOf​(org.locationtech.jts.geom.GeometryCollection geometryCollection)
        Calculate the approximate length of a multi geometry.

        See lengthOf(LineString) for further details.

        Parameters:
        geometryCollection - the geometries to get the length of. coordinates must be in WGS84
        Returns:
        The approximate geodesic length of the linear geometries of this collection in meters.
      • lengthOf

        public static double lengthOf​(org.locationtech.jts.geom.Geometry geom)
        Calculate the approximate length of an arbitrary geometry.

        Returns zero for non-linear features such as points or polygons.

        See lengthOf(LineString) for further details.

        Parameters:
        geom - the geometry to get the length of. coordinates must be in WGS84
        Returns:
        The approximate geodesic length of the geometry in meters.
      • areaOf

        public static double areaOf​(org.locationtech.jts.geom.Polygon poly)
        Calculate the approximate area of an arbitrary geometry.

        This uses approximation formulas for the area of small polygons on a sphere, but partially accounts for the spheroidal shape of the earth (geometry coordinates given in WGS84).

        For typical features present in OpenStreetMap data, the relative error introduced by this approximation is below 0.1%

        Reference: Robert. G. Chamberlain and William H. Duquette, "Some Algorithms for Polygons on a Sphere", JPL Publication 07-03, Jet Propulsion Laboratory, Pasadena, CA, June 2007 https://trs.jpl.nasa.gov/handle/2014/40409

        Parameters:
        poly - the polygon for which the area should be calculated. coordinates must be in WGS84
        Returns:
        The approximate signed geodesic area of the polygon in square meters.
      • areaOf

        public static double areaOf​(org.locationtech.jts.geom.MultiPolygon multipoly)
        Calculate the approximate area of a multi polygon.

        See areaOf(Polygon) for further details.

        Parameters:
        multipoly - the multipolygon for which the area should be calculated. coordinates must be in WGS84
        Returns:
        The approximate signed geodesic area of the multipolygon in square meters.
      • areaOf

        public static double areaOf​(org.locationtech.jts.geom.GeometryCollection geometryCollection)
        Calculate the approximate area of a geometry collection.

        See areaOf(Polygon) for further details.

        Parameters:
        geometryCollection - the geometry collection for which the area should be calculated. coordinates must be in WGS84
        Returns:
        The approximate signed geodesic area of the geometry collection in square meters.
      • areaOf

        public static double areaOf​(org.locationtech.jts.geom.Geometry geom)
        Calculate the approximate area of an arbitrary geometry.

        Returns zero for non-polygonal features such as points or lines.

        See areaOf(Polygon) for further details.

        Parameters:
        geom - the geometry for which the area should be calculated. coordinates must be in WGS84
        Returns:
        The approximate signed geodesic area of the geometry in square meters.
      • clip

        public static org.locationtech.jts.geom.Geometry clip​(org.locationtech.jts.geom.Geometry obj,
                                                              OSHDBBoundingBox bbox)
      • clip

        public static <P extends org.locationtech.jts.geom.Geometry & org.locationtech.jts.geom.Polygonal> org.locationtech.jts.geom.Geometry clip​(org.locationtech.jts.geom.Geometry obj,
                                                                                                                                                   P poly)