Class GeomUtils

java.lang.Object
org.apache.sedona.common.utils.GeomUtils

public class GeomUtils extends Object
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static org.locationtech.jts.geom.Geometry
    addMeasure(org.locationtech.jts.geom.Geometry geom, double measure_start, double measure_end)
     
    static void
    affineGeom(org.locationtech.jts.geom.Geometry geometry, Double a, Double b, Double c, Double d, Double e, Double f, Double g, Double h, Double i, Double xOff, Double yOff, Double zOff)
     
    static org.locationtech.jts.geom.Geometry
    antiMeridianSafeGeom(org.locationtech.jts.geom.Geometry geom)
    Returns a geometry that does not cross the anti meridian.
    static org.locationtech.jts.geom.Geometry
    buildArea(org.locationtech.jts.geom.Geometry geom)
     
    static double
    calcAngle(org.locationtech.jts.geom.Coordinate start1, org.locationtech.jts.geom.Coordinate end1, org.locationtech.jts.geom.Coordinate start2, org.locationtech.jts.geom.Coordinate end2)
     
    static org.locationtech.jts.io.WKBWriter
    createWKBWriter(int dimension)
     
    static org.locationtech.jts.io.WKBWriter
    createWKBWriter(int dimension, boolean includeSRID)
     
    static boolean
    equalsExactGeom(org.locationtech.jts.geom.Geometry geom1, Object geom2)
     
    static boolean
    equalsExactGeomUnsortedUserData(org.locationtech.jts.geom.Geometry geom1, Object geom2)
    This is for verifying the correctness of two geometries loaded from geojson
    static boolean
    equalsTopoGeom(org.locationtech.jts.geom.Geometry geom1, org.locationtech.jts.geom.Geometry geom2)
     
    static boolean
    equalsUserData(Object userData1, Object userData2)
    Use for check if two user data attributes are equal This is mainly used for GeoJSON parser as the column order is uncertain each time
    static List<org.locationtech.jts.geom.Geometry>
    extractGeometryCollection(org.locationtech.jts.geom.Geometry geom)
     
    static <T extends org.locationtech.jts.geom.Geometry>
    List<org.locationtech.jts.geom.Geometry>
    extractGeometryCollection(org.locationtech.jts.geom.Geometry geom, Class<T> geomType)
     
    static void
    flipCoordinates(org.locationtech.jts.geom.Geometry g)
    Swaps the XY coordinates of a geometry.
    static boolean
    geometryIsHomogeneous(org.locationtech.jts.geom.Geometry geometry)
    Checks if the geometry only contains geometry of the same dimension.
    static boolean
    geometryIsLineal(org.locationtech.jts.geom.Geometry geometry)
    Checks if either the geometry is, or contains, only line geometry.
    static boolean
    geometryIsPolygonal(org.locationtech.jts.geom.Geometry geometry)
    Checks if either the geometry is, or contains, only polygon geometry.
    static boolean
    geometryIsPuntal(org.locationtech.jts.geom.Geometry geometry)
    Checks if either the geometry is, or contains, only point geometry.
    static org.locationtech.jts.geom.Geometry
    get2dGeom(org.locationtech.jts.geom.Geometry geom)
     
    static int
    getDimension(org.locationtech.jts.geom.Geometry geometry)
     
    static byte[]
    getEWKB(org.locationtech.jts.geom.Geometry geometry)
     
    static String
    getEWKT(org.locationtech.jts.geom.Geometry geometry)
     
    static org.locationtech.jts.geom.Geometry
    getExteriorRing(org.locationtech.jts.geom.Geometry geometry)
     
    static double
    getFrechetDistance(org.locationtech.jts.geom.Geometry g1, org.locationtech.jts.geom.Geometry g2)
     
    static Double
    getHausdorffDistance(org.locationtech.jts.geom.Geometry g1, org.locationtech.jts.geom.Geometry g2, double densityFrac)
     
    static String
    getHexEWKB(org.locationtech.jts.geom.Geometry geometry, int endian)
     
    static org.locationtech.jts.geom.Geometry
    getInteriorPoint(org.locationtech.jts.geom.Geometry geometry)
     
    static org.locationtech.jts.geom.Geometry
    getNthPoint(org.locationtech.jts.geom.LineString lineString, int n)
    Return the nth point from the given geometry (which could be a linestring or a circular linestring) If the value of n is negative, return a point backwards E.g.
    static int
    getPolygonNumRings(org.locationtech.jts.geom.Polygon polygon)
     
    static org.locationtech.jts.geom.Coordinate[]
    getStartEndCoordinates(org.locationtech.jts.geom.Geometry line)
     
    static org.locationtech.jts.geom.Geometry[]
    getSubGeometries(org.locationtech.jts.geom.Geometry geom)
     
    static byte[]
    getWKB(org.locationtech.jts.geom.Geometry geometry)
     
    static String
    getWKT(org.locationtech.jts.geom.Geometry geometry)
     
    static int
    hashCode(org.locationtech.jts.geom.Geometry geom)
     
    static boolean
    isAnyGeomEmpty(org.locationtech.jts.geom.Geometry... geometries)
     
    static boolean
    isDuplicate(org.locationtech.jts.geom.Geometry left, org.locationtech.jts.geom.Geometry right, HalfOpenRectangle extent)
    Checks if the geometry pair - left and right - should be handled be the current partition - extent.
    static Boolean
    isMeasuredGeometry(org.locationtech.jts.geom.Geometry geom)
     
    static String
     
    static String
    printGeom(org.locationtech.jts.geom.Geometry geom)
     
    static double
    toDegrees(double angleInRadian)
     
    static void
    translateGeom(org.locationtech.jts.geom.Geometry geometry, double deltaX, double deltaY, double deltaZ)
     

    Methods inherited from class java.lang.Object

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

    • GeomUtils

      public GeomUtils()
  • Method Details

    • printGeom

      public static String printGeom(org.locationtech.jts.geom.Geometry geom)
    • printGeom

      public static String printGeom(Object geom)
    • hashCode

      public static int hashCode(org.locationtech.jts.geom.Geometry geom)
    • equalsTopoGeom

      public static boolean equalsTopoGeom(org.locationtech.jts.geom.Geometry geom1, org.locationtech.jts.geom.Geometry geom2)
    • equalsExactGeom

      public static boolean equalsExactGeom(org.locationtech.jts.geom.Geometry geom1, Object geom2)
    • equalsExactGeomUnsortedUserData

      public static boolean equalsExactGeomUnsortedUserData(org.locationtech.jts.geom.Geometry geom1, Object geom2)
      This is for verifying the correctness of two geometries loaded from geojson
      Parameters:
      geom1 -
      geom2 -
      Returns:
    • equalsUserData

      public static boolean equalsUserData(Object userData1, Object userData2)
      Use for check if two user data attributes are equal This is mainly used for GeoJSON parser as the column order is uncertain each time
      Parameters:
      userData1 -
      userData2 -
      Returns:
    • flipCoordinates

      public static void flipCoordinates(org.locationtech.jts.geom.Geometry g)
      Swaps the XY coordinates of a geometry.
    • getInteriorPoint

      public static org.locationtech.jts.geom.Geometry getInteriorPoint(org.locationtech.jts.geom.Geometry geometry)
    • getNthPoint

      public static org.locationtech.jts.geom.Geometry getNthPoint(org.locationtech.jts.geom.LineString lineString, int n)
      Return the nth point from the given geometry (which could be a linestring or a circular linestring) If the value of n is negative, return a point backwards E.g. if n = 1, return 1st point, if n = -1, return last point
      Parameters:
      lineString - from which the nth point is to be returned
      n - is the position of the point in the geometry
      Returns:
      a point
    • getExteriorRing

      public static org.locationtech.jts.geom.Geometry getExteriorRing(org.locationtech.jts.geom.Geometry geometry)
    • getEWKT

      public static String getEWKT(org.locationtech.jts.geom.Geometry geometry)
    • getWKT

      public static String getWKT(org.locationtech.jts.geom.Geometry geometry)
    • getHexEWKB

      public static String getHexEWKB(org.locationtech.jts.geom.Geometry geometry, int endian)
    • getEWKB

      public static byte[] getEWKB(org.locationtech.jts.geom.Geometry geometry)
    • getWKB

      public static byte[] getWKB(org.locationtech.jts.geom.Geometry geometry)
    • createWKBWriter

      public static org.locationtech.jts.io.WKBWriter createWKBWriter(int dimension, boolean includeSRID)
    • createWKBWriter

      public static org.locationtech.jts.io.WKBWriter createWKBWriter(int dimension)
    • get2dGeom

      public static org.locationtech.jts.geom.Geometry get2dGeom(org.locationtech.jts.geom.Geometry geom)
    • buildArea

      public static org.locationtech.jts.geom.Geometry buildArea(org.locationtech.jts.geom.Geometry geom)
    • getDimension

      public static int getDimension(org.locationtech.jts.geom.Geometry geometry)
    • geometryIsHomogeneous

      public static boolean geometryIsHomogeneous(org.locationtech.jts.geom.Geometry geometry)
      Checks if the geometry only contains geometry of the same dimension. By dimension this refers to whether the geometries are all, for example, lines (1D).
      Parameters:
      geometry - geometry to check
      Returns:
      true iff geometry is homogeneous
    • geometryIsPuntal

      public static boolean geometryIsPuntal(org.locationtech.jts.geom.Geometry geometry)
      Checks if either the geometry is, or contains, only point geometry. GeometryCollections that only contain points will return true.
      Parameters:
      geometry - geometry to check
      Returns:
      true iff geometry is puntal
    • geometryIsLineal

      public static boolean geometryIsLineal(org.locationtech.jts.geom.Geometry geometry)
      Checks if either the geometry is, or contains, only line geometry. GeometryCollections that only contain lines will return true.
      Parameters:
      geometry - geometry to check
      Returns:
      true iff geometry is lineal
    • geometryIsPolygonal

      public static boolean geometryIsPolygonal(org.locationtech.jts.geom.Geometry geometry)
      Checks if either the geometry is, or contains, only polygon geometry. GeometryCollections that only contain polygons will return true.
      Parameters:
      geometry - geometry to check
      Returns:
      true iff geometry is polygonal
    • isDuplicate

      public static boolean isDuplicate(org.locationtech.jts.geom.Geometry left, org.locationtech.jts.geom.Geometry right, HalfOpenRectangle extent)
      Checks if the geometry pair - left and right - should be handled be the current partition - extent.
      Parameters:
      left -
      right -
      extent -
      Returns:
    • extractGeometryCollection

      public static <T extends org.locationtech.jts.geom.Geometry> List<org.locationtech.jts.geom.Geometry> extractGeometryCollection(org.locationtech.jts.geom.Geometry geom, Class<T> geomType)
    • extractGeometryCollection

      public static List<org.locationtech.jts.geom.Geometry> extractGeometryCollection(org.locationtech.jts.geom.Geometry geom)
    • getSubGeometries

      public static org.locationtech.jts.geom.Geometry[] getSubGeometries(org.locationtech.jts.geom.Geometry geom)
    • getPolygonNumRings

      public static int getPolygonNumRings(org.locationtech.jts.geom.Polygon polygon)
    • translateGeom

      public static void translateGeom(org.locationtech.jts.geom.Geometry geometry, double deltaX, double deltaY, double deltaZ)
    • isAnyGeomEmpty

      public static boolean isAnyGeomEmpty(org.locationtech.jts.geom.Geometry... geometries)
    • getStartEndCoordinates

      public static org.locationtech.jts.geom.Coordinate[] getStartEndCoordinates(org.locationtech.jts.geom.Geometry line)
    • calcAngle

      public static double calcAngle(org.locationtech.jts.geom.Coordinate start1, org.locationtech.jts.geom.Coordinate end1, org.locationtech.jts.geom.Coordinate start2, org.locationtech.jts.geom.Coordinate end2)
    • toDegrees

      public static double toDegrees(double angleInRadian)
    • affineGeom

      public static void affineGeom(org.locationtech.jts.geom.Geometry geometry, Double a, Double b, Double c, Double d, Double e, Double f, Double g, Double h, Double i, Double xOff, Double yOff, Double zOff)
    • getFrechetDistance

      public static double getFrechetDistance(org.locationtech.jts.geom.Geometry g1, org.locationtech.jts.geom.Geometry g2)
    • getHausdorffDistance

      public static Double getHausdorffDistance(org.locationtech.jts.geom.Geometry g1, org.locationtech.jts.geom.Geometry g2, double densityFrac)
    • addMeasure

      public static org.locationtech.jts.geom.Geometry addMeasure(org.locationtech.jts.geom.Geometry geom, double measure_start, double measure_end)
    • isMeasuredGeometry

      public static Boolean isMeasuredGeometry(org.locationtech.jts.geom.Geometry geom)
    • antiMeridianSafeGeom

      public static org.locationtech.jts.geom.Geometry antiMeridianSafeGeom(org.locationtech.jts.geom.Geometry geom)
      Returns a geometry that does not cross the anti meridian. If the given geometry crosses the anti-meridian, it will be split up into multiple geometries.
      Parameters:
      geom - the geometry to convert
      Returns:
      a geometry that does not cross the anti meridian