Package org.h2gis.utilities.jts_utils
Class CoordinateUtils
- java.lang.Object
-
- org.h2gis.utilities.jts_utils.CoordinateUtils
-
public final class CoordinateUtils extends Object
Useful methods for JTSCoordinates.- Author:
- Erwan Bocher
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static booleancontains2D(org.locationtech.jts.geom.Coordinate[] coords, org.locationtech.jts.geom.Coordinate coord)Checks if a coordinate array contains a specific coordinate.static 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 org.locationtech.jts.geom.Coordinate[]removeDuplicatedCoordinates(org.locationtech.jts.geom.Coordinate[] coords, boolean closeRing)Remove dupliacted coordinates Note : This method doesn't preserve the topology of geometrystatic org.locationtech.jts.geom.Coordinate[]removeRepeatedCoordinates(org.locationtech.jts.geom.Coordinate[] coords, double tolerance, boolean duplicateFirstLast)Remove repeated coordinates according a given tolerancestatic doubleround(double value, int places)Round a double value according a number of decimal placesstatic org.locationtech.jts.geom.CoordinatevectorIntersection(org.locationtech.jts.geom.Coordinate p1, org.locationtech.jts.math.Vector3D v1, org.locationtech.jts.geom.Coordinate p2, org.locationtech.jts.math.Vector3D v2)Compute intersection point of two vectorsstatic double[]zMinMax(org.locationtech.jts.geom.Coordinate[] cs)Determine the min and max "z" values in an array of Coordinates.
-
-
-
Method Detail
-
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.
-
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:
-
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:
-
vectorIntersection
public static org.locationtech.jts.geom.Coordinate vectorIntersection(org.locationtech.jts.geom.Coordinate p1, org.locationtech.jts.math.Vector3D v1, org.locationtech.jts.geom.Coordinate p2, org.locationtech.jts.math.Vector3D v2)Compute intersection point of two vectors- Parameters:
p1- Origin pointv1- Direction from p1p2- Origin point 2v2- Direction of p2- Returns:
- Null if vectors are collinear or if intersection is done behind one of origin point
-
removeDuplicatedCoordinates
public static org.locationtech.jts.geom.Coordinate[] removeDuplicatedCoordinates(org.locationtech.jts.geom.Coordinate[] coords, boolean closeRing)Remove dupliacted coordinates Note : This method doesn't preserve the topology of geometry- Parameters:
coords- the input coordinatescloseRing- is true the first coordinate is added at the end to close the array- Returns:
-
removeRepeatedCoordinates
public static org.locationtech.jts.geom.Coordinate[] removeRepeatedCoordinates(org.locationtech.jts.geom.Coordinate[] coords, double tolerance, boolean duplicateFirstLast)Remove repeated coordinates according a given tolerance- Parameters:
coords- the input coordinatestolerance- to delete the coordinatesduplicateFirstLast- false to delete the last coordinate if there are equals- Returns:
-
round
public static double round(double value, int places)Round a double value according a number of decimal places- Parameters:
value- the double valueplaces- the number of decimal places- Returns:
-
-