Coordinate snappingPoint = null;
double currThreshold = threshold;
for (Coordinate[] coordinateArray : coordinates) {
for (int j = 1; j < coordinateArray.length; j++) {
LineSegment line = new LineSegment(coordinateArray[j], coordinateArray[j - 1]);
double distance = line.distance(original);
if (distance < currThreshold && distance < ruleDistance) {
currThreshold = distance;
minimumDistance = distance;
snappingPoint = line.nearest(original);
}
}
}
return snappingPoint;