code: public Coordinate snap(Coordinate coordinate, double distance) {
  		// Some initialization:
  		calculatedDistance = distance;
  		hasSnapped = false;
  		Coordinate snappingPoint = coordinate;
  
  		if (sortedX != null && sortedY != null) {
  			// Calculate the distances for all candidates:
  			List<Coordinate> coordinates = getPossibleCoordinates(coordinate, distance);
  			for (Coordinate candidate : coordinates) {
  				double d = MathService.distance(coordinate, candidate);
  				if (d < calculatedDistance) {
  					snappingPoint = candidate;
  					calculatedDistance = d;
  					hasSnapped = true;
  				}
  			}
  		}
  
  		return snappingPoint;
  	}
docs: Execute the snap operation.
  
  @param coordinate The original location.
  @param distance   The maximum distance allowed for snapping.
  @return The new location. If no snapping target was found, this may return the original location.