public class Distance3DOp
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).
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).
3D LineString
s and Point
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.
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 boolean |
isDone |
private double |
minDistance |
private GeometryLocation[] |
minDistanceLocation |
private double |
terminateDistance |
Constructor and 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.
|
Modifier and Type | Method and Description |
---|---|
private void |
computeMinDistance() |
private void |
computeMinDistance(Geometry g0,
Geometry g1,
boolean flip) |
private void |
computeMinDistanceLineLine(LineString line0,
LineString line1,
boolean flip) |
private void |
computeMinDistanceLinePoint(LineString line,
Point point,
boolean flip) |
private void |
computeMinDistanceMultiMulti(Geometry g0,
Geometry g1,
boolean flip) |
private void |
computeMinDistanceOneMulti(Geometry g0,
Geometry g1,
boolean flip) |
private void |
computeMinDistanceOneMulti(PlanarPolygon3D poly,
Geometry geom,
boolean flip) |
private void |
computeMinDistancePointPoint(Point point0,
Point point1,
boolean flip) |
private void |
computeMinDistancePolygonLine(PlanarPolygon3D poly,
LineString line,
boolean flip) |
private void |
computeMinDistancePolygonPoint(PlanarPolygon3D polyPlane,
Point point,
boolean flip) |
private void |
computeMinDistancePolygonPolygon(PlanarPolygon3D poly0,
Polygon poly1,
boolean flip)
Computes distance between two polygons.
|
private void |
computeMinDistancePolygonRings(PlanarPolygon3D poly,
Polygon ringPoly,
boolean flip)
Compute distance between a polygon and the rings of another.
|
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.
|
private Coordinate |
intersection(PlanarPolygon3D poly,
LineString line) |
static boolean |
isWithinDistance(Geometry g0,
Geometry g1,
double distance)
Test whether two geometries lie within a given distance of each other.
|
private int |
mostPolygonalIndex()
Finds the index of the "most polygonal" input geometry.
|
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 static PlanarPolygon3D |
polyPlane(Geometry poly)
Convenience method to create a Plane3DPolygon
|
private static Coordinate |
segmentPoint(Coordinate p0,
Coordinate p1,
double d0,
double d1)
Computes a point at a distance along a segment
specified by two relatively proportional values.
|
private void |
updateDistance(double dist,
GeometryLocation loc0,
GeometryLocation loc1,
boolean flip) |
private Geometry[] geom
private double terminateDistance
private GeometryLocation[] minDistanceLocation
private double minDistance
private boolean isDone
public Distance3DOp(Geometry g0, Geometry g1)
g0
- a Geometryg1
- a Geometrypublic Distance3DOp(Geometry g0, Geometry g1, double terminateDistance)
g0
- a Geometryg1
- a GeometryterminateDistance
- the distance on which to terminate the searchpublic 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 double distance()
java.lang.IllegalArgumentException
- if either input geometry is nullpublic Coordinate[] nearestPoints()
Coordinate
s of the nearest pointspublic GeometryLocation[] nearestLocations()
GeometryLocation
s for the nearest pointsprivate void updateDistance(double dist, GeometryLocation loc0, GeometryLocation loc1, boolean flip)
private void computeMinDistance()
private int mostPolygonalIndex()
private void computeMinDistanceMultiMulti(Geometry g0, Geometry g1, boolean flip)
private void computeMinDistanceOneMulti(Geometry g0, Geometry g1, boolean flip)
private void computeMinDistanceOneMulti(PlanarPolygon3D poly, Geometry geom, boolean flip)
private static PlanarPolygon3D polyPlane(Geometry poly)
poly
- private void computeMinDistancePolygonPolygon(PlanarPolygon3D poly0, Polygon poly1, boolean flip)
poly0
- poly1
- geomIndex
- private void computeMinDistancePolygonRings(PlanarPolygon3D poly, Polygon ringPoly, boolean flip)
poly
- ringPoly
- geomIndex
- private void computeMinDistancePolygonLine(PlanarPolygon3D poly, LineString line, boolean flip)
private Coordinate intersection(PlanarPolygon3D poly, LineString line)
private void computeMinDistancePolygonPoint(PlanarPolygon3D polyPlane, Point point, boolean flip)
private void computeMinDistanceLineLine(LineString line0, LineString line1, boolean flip)
private void computeMinDistanceLinePoint(LineString line, Point point, boolean flip)
private void computeMinDistancePointPoint(Point point0, Point point1, boolean flip)
private static Coordinate segmentPoint(Coordinate p0, Coordinate p1, double d0, double d1)
p0
- start point of the segmentp1
- end point of the segmentd0
- proportional distance from start point to computed pointd1
- proportional distance from computed point to end point