Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
43b8108
Add DirectedHausdorffDistance
dr-jts Jan 30, 2026
5fc963a
Expose IndexedPointInPolygonsLocater
dr-jts Jan 30, 2026
ee3d24d
Javadoc
dr-jts Jan 30, 2026
6f438f5
Add short circuiting for isFullyWithinDistance
dr-jts Jan 31, 2026
b27bfdd
Add stress test for isFullyWithinDistance
dr-jts Jan 31, 2026
12bc572
Add early discard for interior segments
dr-jts Jan 31, 2026
1b14eea
Rename methods
dr-jts Jan 31, 2026
1bf2555
Add isFullyWithinDistance envelope checks
dr-jts Feb 1, 2026
3e28c1d
Refine stress test
dr-jts Feb 1, 2026
57f6119
Javadoc
dr-jts Feb 2, 2026
9d62ddf
Check interior for segment endpoint distance
dr-jts Feb 3, 2026
0c1bf91
Javadoc, tests
dr-jts Feb 4, 2026
dfacfd6
Factor out TargetDistance
dr-jts Feb 6, 2026
45ba472
Add unit tests
dr-jts Feb 6, 2026
5bd5ecf
Simplify IndexedFacetDistance API
dr-jts Feb 8, 2026
c4962b3
Formatting
dr-jts Feb 8, 2026
1090f6f
Simplify coordinate handling
dr-jts Feb 8, 2026
8e878e7
Add FacetLocation
dr-jts Feb 9, 2026
9057ed1
Check for same segments
dr-jts Feb 9, 2026
85e964e
Improve checking for collinear segments
dr-jts Feb 9, 2026
c670ecc
Improve segment search termination criteria
dr-jts Feb 10, 2026
ed9c34d
Optimze adding segments to queue
dr-jts Feb 10, 2026
a02d44e
cache maxDistance
dr-jts Feb 10, 2026
bdfcef1
Rename method
dr-jts Feb 10, 2026
99c237c
Add topo equal lines test
dr-jts Feb 10, 2026
ab16df3
Rename CoordinateSequenceLocation
dr-jts Feb 13, 2026
19628ca
Rename distance functions
dr-jts Feb 21, 2026
3705cc1
Method renames
dr-jts Feb 21, 2026
82f081a
Simplify code
dr-jts Feb 21, 2026
7685a90
Add auto-tolerance
dr-jts Feb 23, 2026
4dd7927
Improve search termination criteria
dr-jts Feb 23, 2026
b8f8c4d
Renames, remove hausdorff distance function with tolerance
dr-jts Feb 24, 2026
e6d1210
Remove tolerance from Hausdorff test
dr-jts Feb 24, 2026
8480ff4
Remove tolerance from fullyWithin test
dr-jts Feb 24, 2026
811e320
Remove tolerance from tests
dr-jts Feb 24, 2026
5206b49
return point pairs instead of lines
dr-jts Feb 24, 2026
d3235ac
clean up Hausdorff distance functions
dr-jts Feb 24, 2026
66c749d
Handle empty inputs
dr-jts Feb 24, 2026
08b81e4
Variable renames
dr-jts Feb 24, 2026
fe5471c
Javadoc
dr-jts Feb 24, 2026
6e2f202
Update debugging code
dr-jts Feb 24, 2026
63d79af
Refactor tolerance factors
dr-jts Feb 25, 2026
50c0104
Add checks for invalid and zero input
dr-jts Feb 27, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

import org.locationtech.jts.algorithm.distance.DiscreteFrechetDistance;
import org.locationtech.jts.algorithm.distance.DiscreteHausdorffDistance;
import org.locationtech.jts.algorithm.distance.DirectedHausdorffDistance;
import org.locationtech.jts.geom.Coordinate;
import org.locationtech.jts.geom.Geometry;
import org.locationtech.jts.geom.LineString;
Expand Down Expand Up @@ -45,53 +46,61 @@ public static Geometry frechetDistanceLine(Geometry a, Geometry b)
return a.getFactory().createLineString(dist.getCoordinates());
}

public static double hausdorffDistance(Geometry a, Geometry b)
@Metadata(description="Oriented discrete Hausdorff distance from A to B")
public static double orientedDiscreteHausdorffDistance(Geometry a, Geometry b)
{
return DiscreteHausdorffDistance.orientedDistance(a, b);
}

@Metadata(description="Oriented discrete Hausdorff distance line from A to B, densified")
public static Geometry orientedDiscreteHausdorffLineDensify(Geometry a, Geometry b,
@Metadata(title="Densify fraction")
double frac)
{
return DiscreteHausdorffDistance.distance(a, b);
return DiscreteHausdorffDistance.orientedDistanceLine(a, b, frac);
}

@Metadata(description="Clipped directed Hausdorff distance from A to B")
public static Geometry clippedDirectedHausdorffLine(Geometry a, Geometry b)
{
Geometry clippedLine = LinearReferencingFunctions.project(a, b);
Coordinate[] pts = DirectedHausdorffDistance.distancePoints(clippedLine, b);
return a.getFactory().createLineString(pts);
}

@Metadata(description="Hausdorff distance between A and B")
public static Geometry hausdorffDistanceLine(Geometry a, Geometry b)
@Metadata(description="Directed Hausdorff distance from A to B, up to tolerance")
public static double directedHausdorffDistance(Geometry a, Geometry b,
@Metadata(title="Distance tolerance")
double distTol)
{
return DiscreteHausdorffDistance.distanceLine(a, b);
return DirectedHausdorffDistance.distance(a, b, distTol);
}

@Metadata(description="Hausdorff distance between A and B, densified")
public static Geometry hausdorffDistanceLineDensify(Geometry a, Geometry b,
@Metadata(title="Densify fraction")
double frac)
{
return DiscreteHausdorffDistance.distanceLine(a, b, frac);
}

@Metadata(description="Oriented Hausdorff distance from A to B")
public static Geometry orientedHausdorffDistanceLine(Geometry a, Geometry b)

@Metadata(description="Directed Hausdorff distance line from A to B, up to tolerance")
public static Geometry directedHausdorffLineTol(Geometry a, Geometry b,
@Metadata(title="Distance tolerance")
double distTol)
{
return DiscreteHausdorffDistance.orientedDistanceLine(a, b);
Coordinate[] pts = DirectedHausdorffDistance.distancePoints(a, b, distTol);
return a.getFactory().createLineString(pts);
}

@Metadata(description="Oriented Hausdorff distance from A to B")
public static Geometry clippedOrientedHausdorffDistanceLine(Geometry a, Geometry b)
@Metadata(description="Directed Hausdorff distance line from A to B")
public static Geometry directedHausdorffLine(Geometry a, Geometry b)
{
//TODO: would this be more efficient done as part of DiscreteHausdorffDistance?
Geometry clippedLine = LinearReferencingFunctions.project(a, b);
return DiscreteHausdorffDistance.orientedDistanceLine(clippedLine, b);
Coordinate[] pts = DirectedHausdorffDistance.distancePoints(a, b);
return a.getFactory().createLineString(pts);
}

@Metadata(description="Oriented Hausdorff distance from A to B")
public static double orientedHausdorffDistance(Geometry a, Geometry b)
{
return DiscreteHausdorffDistance.orientedDistance(a, b);
}

@Metadata(description="Oriented Hausdorff distance from A to B, densified")
public static Geometry orientedHausdorffDistanceLineDensify(Geometry a, Geometry b,
@Metadata(title="Densify fraction")
double frac)

@Metadata(description="Hausdorff distance between A and B, up to tolerance")
public static Geometry hausdorffLine(Geometry a, Geometry b)
{
return DiscreteHausdorffDistance.orientedDistanceLine(a, b, frac);
Coordinate[] pts = DirectedHausdorffDistance.hausdorffDistancePoints(a, b);
return a.getFactory().createLineString(pts);
}


//--------------------------------------------

public static double distanceIndexed(Geometry a, Geometry b) {
return IndexedFacetDistance.distance(a, b);
}
Expand All @@ -117,4 +126,5 @@ public static Geometry nearestPointsIndexedEachB(Geometry a, Geometry b) {

return a.getFactory().createMultiLineString(lines);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import java.util.List;

import org.locationtech.jts.algorithm.construct.MaximumInscribedCircle;
import org.locationtech.jts.algorithm.distance.DirectedHausdorffDistance;
import org.locationtech.jts.geom.Geometry;
import org.locationtech.jts.geom.prep.PreparedGeometry;
import org.locationtech.jts.geom.prep.PreparedGeometryFactory;
Expand Down Expand Up @@ -238,6 +239,25 @@ public boolean isTrue(Geometry g) {
});
}

public static Geometry fullyWithinDistance(Geometry a, final Geometry mask, double maximumDistance)
{
return select(a, new GeometryPredicate() {
public boolean isTrue(Geometry g) {
return DirectedHausdorffDistance.isFullyWithinDistance(g, mask, maximumDistance);
}
});
}

public static Geometry fullyWithinDistancePrep(Geometry a, final Geometry mask, double maximumDistance)
{
DirectedHausdorffDistance dhd = new DirectedHausdorffDistance(mask);
return select(a, new GeometryPredicate() {
public boolean isTrue(Geometry g) {
return dhd.isFullyWithinDistance(g, maximumDistance);
}
});
}

public static Geometry maxInCircleRadiusWithin(Geometry a,
@Metadata(title="Max Radius Length")
double maximumRadius)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
*/
package org.locationtech.jts.algorithm.construct;

import org.locationtech.jts.algorithm.locate.IndexedPointInPolygonsLocator;
import org.locationtech.jts.geom.Coordinate;
import org.locationtech.jts.geom.Geometry;
import org.locationtech.jts.geom.Location;
Expand Down
Loading