Package org.apache.sedona.common.utils
Class GeomUtils
java.lang.Object
org.apache.sedona.common.utils.GeomUtils
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic org.locationtech.jts.geom.GeometryaddMeasure(org.locationtech.jts.geom.Geometry geom, double measure_start, double measure_end) static voidaffineGeom(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.GeometryantiMeridianSafeGeom(org.locationtech.jts.geom.Geometry geom) Returns a geometry that does not cross the anti meridian.static org.locationtech.jts.geom.GeometrybuildArea(org.locationtech.jts.geom.Geometry geom) static doublecalcAngle(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.WKBWritercreateWKBWriter(int dimension) static org.locationtech.jts.io.WKBWritercreateWKBWriter(int dimension, boolean includeSRID) static booleanequalsExactGeom(org.locationtech.jts.geom.Geometry geom1, Object geom2) static booleanequalsExactGeomUnsortedUserData(org.locationtech.jts.geom.Geometry geom1, Object geom2) This is for verifying the correctness of two geometries loaded from geojsonstatic booleanequalsTopoGeom(org.locationtech.jts.geom.Geometry geom1, org.locationtech.jts.geom.Geometry geom2) static booleanequalsUserData(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 timestatic 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 voidflipCoordinates(org.locationtech.jts.geom.Geometry g) Swaps the XY coordinates of a geometry.static booleangeometryIsHomogeneous(org.locationtech.jts.geom.Geometry geometry) Checks if the geometry only contains geometry of the same dimension.static booleangeometryIsLineal(org.locationtech.jts.geom.Geometry geometry) Checks if either the geometry is, or contains, only line geometry.static booleangeometryIsPolygonal(org.locationtech.jts.geom.Geometry geometry) Checks if either the geometry is, or contains, only polygon geometry.static booleangeometryIsPuntal(org.locationtech.jts.geom.Geometry geometry) Checks if either the geometry is, or contains, only point geometry.static org.locationtech.jts.geom.Geometryget2dGeom(org.locationtech.jts.geom.Geometry geom) static intgetDimension(org.locationtech.jts.geom.Geometry geometry) static byte[]getEWKB(org.locationtech.jts.geom.Geometry geometry) static StringgetEWKT(org.locationtech.jts.geom.Geometry geometry) static org.locationtech.jts.geom.GeometrygetExteriorRing(org.locationtech.jts.geom.Geometry geometry) static doublegetFrechetDistance(org.locationtech.jts.geom.Geometry g1, org.locationtech.jts.geom.Geometry g2) static DoublegetHausdorffDistance(org.locationtech.jts.geom.Geometry g1, org.locationtech.jts.geom.Geometry g2, double densityFrac) static StringgetHexEWKB(org.locationtech.jts.geom.Geometry geometry, int endian) static org.locationtech.jts.geom.GeometrygetInteriorPoint(org.locationtech.jts.geom.Geometry geometry) static org.locationtech.jts.geom.GeometrygetNthPoint(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 intgetPolygonNumRings(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 StringgetWKT(org.locationtech.jts.geom.Geometry geometry) static inthashCode(org.locationtech.jts.geom.Geometry geom) static booleanisAnyGeomEmpty(org.locationtech.jts.geom.Geometry... geometries) static booleanisDuplicate(org.locationtech.jts.geom.Geometry left, org.locationtech.jts.geom.Geometry right, HalfOpenRectangle extent) Checks if the geometry pair -leftandright- should be handled be the current partition -extent.static BooleanisMeasuredGeometry(org.locationtech.jts.geom.Geometry geom) static Stringstatic StringprintGeom(org.locationtech.jts.geom.Geometry geom) static doubletoDegrees(double angleInRadian) static voidtranslateGeom(org.locationtech.jts.geom.Geometry geometry, double deltaX, double deltaY, double deltaZ)
-
Constructor Details
-
GeomUtils
public GeomUtils()
-
-
Method Details
-
printGeom
-
printGeom
-
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
-
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
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 returnedn- 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
-
getWKT
-
getHexEWKB
-
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 -leftandright- should be handled be the current partition -extent.- Parameters:
left-right-extent-- Returns:
-
extractGeometryCollection
-
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
-
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
-
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
-