public class DistanceOp
extends java.lang.Object
Geometry
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).
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.
The algorithms used are straightforward O(n^2) comparisons. This worst-case performance could be improved on by using Voronoi techniques or spatial indexes.
Modifier and Type | Field and Description |
---|---|
private Geometry[] |
geom |
private double |
minDistance |
private GeometryLocation[] |
minDistanceLocation |
private PointLocator |
ptLocator |
private double |
terminateDistance |
Constructor and Description |
---|
DistanceOp(Geometry g0,
Geometry g1)
Constructs a DistanceOp that computes the distance and nearest points between
the two specified geometries.
|
DistanceOp(Geometry g0,
Geometry g1,
double terminateDistance)
Constructs a DistanceOp that computes the distance and nearest points between
the two specified geometries.
|
Modifier and Type | Method and Description |
---|---|
GeometryLocation[] |
closestLocations()
Deprecated.
renamed to nearestLocations
|
Coordinate[] |
closestPoints()
Deprecated.
renamed to nearestPoints
|
static Coordinate[] |
closestPoints(Geometry g0,
Geometry g1)
Deprecated.
renamed to nearestPoints
|
private void |
computeContainmentDistance() |
private void |
computeContainmentDistance(GeometryLocation ptLoc,
Polygon poly,
GeometryLocation[] locPtPoly) |
private void |
computeContainmentDistance(int polyGeomIndex,
GeometryLocation[] locPtPoly) |
private void |
computeContainmentDistance(java.util.List locs,
java.util.List polys,
GeometryLocation[] locPtPoly) |
private void |
computeFacetDistance()
Computes distance between facets (lines and points)
of input geometries.
|
private void |
computeMinDistance() |
private void |
computeMinDistance(LineString line0,
LineString line1,
GeometryLocation[] locGeom) |
private void |
computeMinDistance(LineString line,
Point pt,
GeometryLocation[] locGeom) |
private void |
computeMinDistanceLines(java.util.List lines0,
java.util.List lines1,
GeometryLocation[] locGeom) |
private void |
computeMinDistanceLinesPoints(java.util.List lines,
java.util.List points,
GeometryLocation[] locGeom) |
private void |
computeMinDistancePoints(java.util.List points0,
java.util.List points1,
GeometryLocation[] locGeom) |
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.
|
private void |
updateMinDistance(GeometryLocation[] locGeom,
boolean flip) |
private Geometry[] geom
private double terminateDistance
private PointLocator ptLocator
private GeometryLocation[] minDistanceLocation
private double minDistance
public DistanceOp(Geometry g0, Geometry g1)
g0
- a Geometryg1
- a Geometrypublic static double distance(Geometry g0, Geometry g1)
public static boolean isWithinDistance(Geometry g0, Geometry g1, double distance)
public static Coordinate[] nearestPoints(Geometry g0, Geometry g1)
public static Coordinate[] closestPoints(Geometry g0, Geometry g1)
public double distance()
java.lang.IllegalArgumentException
- if either input geometry is nullpublic Coordinate[] nearestPoints()
Coordinate
s of the nearest pointspublic Coordinate[] closestPoints()
Coordinate
s of the nearest pointspublic GeometryLocation[] nearestLocations()
GeometryLocation
s for the nearest pointspublic GeometryLocation[] closestLocations()
GeometryLocation
s for the nearest pointsprivate void updateMinDistance(GeometryLocation[] locGeom, boolean flip)
private void computeMinDistance()
private void computeContainmentDistance()
private void computeContainmentDistance(int polyGeomIndex, GeometryLocation[] locPtPoly)
private void computeContainmentDistance(java.util.List locs, java.util.List polys, GeometryLocation[] locPtPoly)
private void computeContainmentDistance(GeometryLocation ptLoc, Polygon poly, GeometryLocation[] locPtPoly)
private void computeFacetDistance()
private void computeMinDistanceLines(java.util.List lines0, java.util.List lines1, GeometryLocation[] locGeom)
private void computeMinDistancePoints(java.util.List points0, java.util.List points1, GeometryLocation[] locGeom)
private void computeMinDistanceLinesPoints(java.util.List lines, java.util.List points, GeometryLocation[] locGeom)
private void computeMinDistance(LineString line0, LineString line1, GeometryLocation[] locGeom)
private void computeMinDistance(LineString line, Point pt, GeometryLocation[] locGeom)