Package org.h2gis.functions.io.utility

## Class CoordinatesUtils

- java.lang.Object
- - org.h2gis.functions.io.utility.CoordinatesUtils

    public final class CoordinatesUtils
    extends Object

This utility class provides some useful methods related to JTS `Coordinate` objects.

Author:
  Erwan Bocher

### Method Summary

All Methods Static Methods Concrete Methods
`static boolean` `contains​(org.locationtech.jts.geom.Coordinate[] coords, org.locationtech.jts.geom.Coordinate coord)`
`static boolean` `contains2D​(org.locationtech.jts.geom.Coordinate[] coords, org.locationtech.jts.geom.Coordinate coord)` Checks if a coordinate array contains a specific coordinate.
`static boolean` `contains3D​(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 coordinate
`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.
`static double` `length3D​(org.locationtech.jts.geom.CoordinateSequence pts)` Computes the length of a linestring specified by a sequence of points.
`static double` `length3D​(org.locationtech.jts.geom.Geometry geom)` Returns the 3D length of the geometry
`static double` `length3D​(org.locationtech.jts.geom.LineString lineString)` Returns the 3D perimeter of a line string.
`static double` `length3D​(org.locationtech.jts.geom.Polygon polygon)` Returns the 3D perimeter of a polygon
`static double[]` `zMinMax​(org.locationtech.jts.geom.Coordinate[] cs)` Determine the min and max "z" values in an array of Coordinates.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Method Detail

#### 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` - first coordinate
  `lastCoordinate` - last coordinate
  `toBeInterpolated` - coordinate to interpolate
Returns:
  z value

#### 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` - coordinate array
  `coord` - coordinate to check
Returns:
  true if the coordinate is found

#### 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` - coordinate array
  `coord` - coordinate
Returns:
  true if the coordinate is found

#### 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` - `Coordinate`
  `coords` - `Coordinate`
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` - `Geometry`
Returns:
  length in 3D

#### length3D

    public static double length3D​(org.locationtech.jts.geom.LineString lineString)

Returns the 3D perimeter of a line string.

Parameters:
  `lineString` - `LineString`
Returns:
  length in 3D

#### length3D

    public static double length3D​(org.locationtech.jts.geom.Polygon polygon)

Returns the 3D perimeter of a polygon

Parameters:
  `polygon` - `Polygon`
Returns:
  length in 3D