isWithinDistanceStatic static method
Test whether two geometries lie within a given distance of each other. @param g0 a {@link Geometry} @param g1 another {@link Geometry} @param distance the distance to test @return true if g0.distance(g1) <= distance
Implementation
static bool isWithinDistanceStatic(
Geometry g0, Geometry g1, double distance) {
// check envelope distance for a short-circuit negative result
double envDist =
g0.getEnvelopeInternal().distance(g1.getEnvelopeInternal());
if (envDist > distance) return false;
// MD - could improve this further with a positive short-circuit based on envelope MinMaxDist
DistanceOp distOp = new DistanceOp.withTerminateDistance(g0, g1, distance);
return distOp.distance() <= distance;
}