Class Distance3DOp
- java.lang.Object
-
- org.locationtech.jts.operation.distance3d.Distance3DOp
-
public class Distance3DOp extends java.lang.Object
Find two points on two 3DGeometry
s which lie within a given distance, or else are the nearest points on the geometries (in which case this also provides the distance between the geometries).3D geometries have vertex Z ordinates defined. 3D
Polygon
s are assumed to lie in a single plane (which is enforced if not actually the case). 3DLineString
s andPoint
s may have any configuration.The distance computation also finds a pair of points in the input geometries which have the minimum distance between them. If a point lies in the interior of a line segment, the coordinate computed is a close approximation to the exact point for X and Y ordinates. Z ordinate is not interpolated.
The algorithms used are straightforward O(n^2) comparisons. This worst-case performance could be improved on by using Voronoi techniques or spatial indexes.
- Version:
- 1.7
-
-
Constructor Summary
Constructors Constructor Description Distance3DOp(Geometry g0, Geometry g1)
Constructs a DistanceOp that computes the distance and nearest points between the two specified geometries.Distance3DOp(Geometry g0, Geometry g1, double terminateDistance)
Constructs a DistanceOp that computes the distance and nearest points between the two specified geometries.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description double
distance()
Report the distance between the nearest points on the input geometries.static double
distance(Geometry g0, Geometry g1)
Compute the distance between the nearest points of two geometries.static boolean
isWithinDistance(Geometry g0, Geometry g1, double distance)
Test whether two geometries lie within a given distance of each other.GeometryLocation[]
nearestLocations()
Report the locations of the nearest points in the input geometries.Coordinate[]
nearestPoints()
Report the coordinates of the nearest points in the input geometries.static Coordinate[]
nearestPoints(Geometry g0, Geometry g1)
Compute the the nearest points of two geometries.
-
-
-
Constructor Detail
-
Distance3DOp
public Distance3DOp(Geometry g0, Geometry g1)
Constructs a DistanceOp that computes the distance and nearest points between the two specified geometries.- Parameters:
g0
- a Geometryg1
- a Geometry
-
Distance3DOp
public Distance3DOp(Geometry g0, Geometry g1, double terminateDistance)
Constructs a DistanceOp that computes the distance and nearest points between the two specified geometries.- Parameters:
g0
- a Geometryg1
- a GeometryterminateDistance
- the distance on which to terminate the search
-
-
Method Detail
-
distance
public static double distance(Geometry g0, Geometry g1)
Compute the distance between the nearest points of two geometries.
-
isWithinDistance
public static boolean isWithinDistance(Geometry g0, Geometry g1, double distance)
Test whether two geometries lie within a given distance of each other.
-
nearestPoints
public static Coordinate[] nearestPoints(Geometry g0, Geometry g1)
Compute the the nearest points of two geometries. The points are presented in the same order as the input Geometries.
-
distance
public double distance()
Report the distance between the nearest points on the input geometries.- Returns:
- the distance between the geometries, or 0 if either input geometry is empty
- Throws:
java.lang.IllegalArgumentException
- if either input geometry is null
-
nearestPoints
public Coordinate[] nearestPoints()
Report the coordinates of the nearest points in the input geometries. The points are presented in the same order as the input Geometries.- Returns:
- a pair of
Coordinate
s of the nearest points
-
nearestLocations
public GeometryLocation[] nearestLocations()
Report the locations of the nearest points in the input geometries. The locations are presented in the same order as the input Geometries.- Returns:
- a pair of
GeometryLocation
s for the nearest points
-
-