snapToVertex method
Snaps the value of this location to the nearest vertex on the given linear {@link Geometry}, if the vertex is closer than minDistance.
@param linearGeom a linear geometry @param minDistance the minimum allowable distance to a vertex
Implementation
void snapToVertex(Geometry linearGeom, double minDistance) {
if (segmentFraction <= 0.0 || segmentFraction >= 1.0) return;
double segLen = getSegmentLength(linearGeom);
double lenToStart = segmentFraction * segLen;
double lenToEnd = segLen - lenToStart;
if (lenToStart <= lenToEnd && lenToStart < minDistance) {
segmentFraction = 0.0;
} else if (lenToEnd <= lenToStart && lenToEnd < minDistance) {
segmentFraction = 1.0;
}
}