/// <summary> /// /// </summary> /// <param name="seg"></param> /// <param name="inputPt"></param> /// <returns></returns> public static double SegmentFraction(LineSegment seg, ICoordinate inputPt) { double segFrac = seg.ProjectionFactor(inputPt); if (segFrac < 0.0) segFrac = 0.0; else if (segFrac > 1.0) segFrac = 1.0; return segFrac; }
/// <summary> /// /// </summary> /// <param name="seg"></param> /// <param name="inputPt"></param> /// <param name="segmentStartMeasure"></param> /// <returns></returns> private double SegmentNearestMeasure(LineSegment seg, ICoordinate inputPt, double segmentStartMeasure) { // found new minimum, so compute location distance of point double projFactor = seg.ProjectionFactor(inputPt); if (projFactor <= 0.0) return segmentStartMeasure; if (projFactor <= 1.0) return segmentStartMeasure + projFactor * seg.Length; // ASSERT: projFactor > 1.0 return segmentStartMeasure + seg.Length; }