Coordinate getSnappingPoint(Coordinate original, double threshold) {
		minimumDistance = Double.MAX_VALUE;
		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;
	}
Coordinate getSnappingPoint ( Coordinate original , double threshold ) { minimumDistance = Double . MAX_VALUE ; 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 ; }
Calculates a snapping point from the given coordinate.

@param original
The original and unsnapped coordinate.
@param threshold
A threshold value that needs to be beaten in order to snap. Only if the distance between the original
and the candidate coordinate is smaller then this threshold, can the candidate coordinate be a snapped
coordinate.
@return Returns the eventual snapped coordinate, or null if no snapping occurred.