if (rule.getType() == SnappingType.CLOSEST_ENDPOINT) {
algorithm = new ClosestPointAlgorithm(currentGeometries, rule.getDistance());
} else {
algorithm = new NearestAlgorithm(currentGeometries, rule.getDistance());
}
Coordinate snapPointIfFound = algorithm.getSnappingPoint(coordinate, intersectDistance);
if (snapPointIfFound != null) {
snappedCoordinate = snapPointIfFound;
intersectSnappedCoordinate = snappedCoordinate;
intersectDistance = algorithm.getMinimumDistance();
}
} else {
geometries.addAll(currentGeometries);
}
}
}
if (intersectSnappedCoordinate == null && !geometries.isEmpty()) {
SnappingAlgorithm algorithm;
if (rule.getType() == SnappingType.CLOSEST_ENDPOINT) {
algorithm = new ClosestPointAlgorithm(geometries, rule.getDistance());
} else {
algorithm = new NearestAlgorithm(geometries, rule.getDistance());
}
Coordinate snapPointIfFound = algorithm.getSnappingPoint(coordinate, intersectDistance);
if (snapPointIfFound != null) {
snappedCoordinate = snapPointIfFound;
distance = algorithm.getMinimumDistance();
}
}