Package org.h2gis.functions.io.utility
Class CoordinatesUtils
java.lang.Object
org.h2gis.functions.io.utility.CoordinatesUtils
This utility class provides some useful methods related to JTS
Coordinate objects.- Author:
- Erwan Bocher
-
Method Summary
Modifier and TypeMethodDescriptionstatic booleancontains(org.locationtech.jts.geom.Coordinate[] coords, org.locationtech.jts.geom.Coordinate coord) static booleancontains2D(org.locationtech.jts.geom.Coordinate[] coords, org.locationtech.jts.geom.Coordinate coord) Checks if a coordinate array contains a specific coordinate.static booleancontains3D(org.locationtech.jts.geom.Coordinate[] coords, org.locationtech.jts.geom.Coordinate coord) Check if a coordinate array contains a specific coordinate.static org.locationtech.jts.geom.Coordinate[]getFurthestCoordinate(org.locationtech.jts.geom.Coordinate base, org.locationtech.jts.geom.Coordinate[] coords) Find the furthest coordinate in a geometry from a base coordinatestatic doubleinterpolate(org.locationtech.jts.geom.Coordinate firstCoordinate, org.locationtech.jts.geom.Coordinate lastCoordinate, org.locationtech.jts.geom.Coordinate toBeInterpolated) Interpolates a z value (linearly) between the two coordinates.static doublelength3D(org.locationtech.jts.geom.CoordinateSequence pts) Computes the length of a linestring specified by a sequence of points.static doublelength3D(org.locationtech.jts.geom.Geometry geom) Returns the 3D length of the geometrystatic doublelength3D(org.locationtech.jts.geom.LineString lineString) Returns the 3D perimeter of a line string.static doublelength3D(org.locationtech.jts.geom.Polygon polygon) Returns the 3D perimeter of a polygonstatic double[]zMinMax(org.locationtech.jts.geom.Coordinate[] cs) Determine the min and max "z" values in an array of Coordinates.
-
Method Details
-
interpolate
public static double interpolate(org.locationtech.jts.geom.Coordinate firstCoordinate, org.locationtech.jts.geom.Coordinate lastCoordinate, org.locationtech.jts.geom.Coordinate toBeInterpolated) Interpolates a z value (linearly) between the two coordinates.- Parameters:
firstCoordinate-lastCoordinate-toBeInterpolated-- Returns:
-
contains
public static boolean contains(org.locationtech.jts.geom.Coordinate[] coords, org.locationtech.jts.geom.Coordinate coord) -
contains2D
public static boolean contains2D(org.locationtech.jts.geom.Coordinate[] coords, org.locationtech.jts.geom.Coordinate coord) Checks if a coordinate array contains a specific coordinate. The equality is done only in 2D (z values are not checked).- Parameters:
coords-coord-- Returns:
-
contains3D
public static boolean contains3D(org.locationtech.jts.geom.Coordinate[] coords, org.locationtech.jts.geom.Coordinate coord) Check if a coordinate array contains a specific coordinate. The equality is done in 3D (z values ARE checked).- Parameters:
coords-coord-- Returns:
-
zMinMax
public static double[] zMinMax(org.locationtech.jts.geom.Coordinate[] cs) Determine the min and max "z" values in an array of Coordinates.- Parameters:
cs- The array to search.- Returns:
- An array of size 2, index 0 is min, index 1 is max.
-
getFurthestCoordinate
public static org.locationtech.jts.geom.Coordinate[] getFurthestCoordinate(org.locationtech.jts.geom.Coordinate base, org.locationtech.jts.geom.Coordinate[] coords) Find the furthest coordinate in a geometry from a base coordinate- Parameters:
base-coords-- Returns:
- the base coordinate and the target coordinate
-
length3D
public static double length3D(org.locationtech.jts.geom.CoordinateSequence pts) Computes the length of a linestring specified by a sequence of points. if a coordinate has a NaN z return 0.- Parameters:
pts- the points specifying the linestring- Returns:
- the length of the linestring
-
length3D
public static double length3D(org.locationtech.jts.geom.Geometry geom) Returns the 3D length of the geometry- Parameters:
geom-- Returns:
-
length3D
public static double length3D(org.locationtech.jts.geom.LineString lineString) Returns the 3D perimeter of a line string.- Parameters:
lineString-- Returns:
-
length3D
public static double length3D(org.locationtech.jts.geom.Polygon polygon) Returns the 3D perimeter of a polygon- Parameters:
polygon-- Returns:
-