Index: src/Common/NetTopologySuite/LinearReferencing/LocationIndexOfPoint.cs =================================================================== diff -u -r8f6ae890fed8e8eae3a32f9c0498a10f82e0ddf9 -r5fc71a385897af92ccb092f2f969b5709afab85a --- src/Common/NetTopologySuite/LinearReferencing/LocationIndexOfPoint.cs (.../LocationIndexOfPoint.cs) (revision 8f6ae890fed8e8eae3a32f9c0498a10f82e0ddf9) +++ src/Common/NetTopologySuite/LinearReferencing/LocationIndexOfPoint.cs (.../LocationIndexOfPoint.cs) (revision 5fc71a385897af92ccb092f2f969b5709afab85a) @@ -12,8 +12,19 @@ /// always computes the nearest point closest to the start of the geometry. /// public class LocationIndexOfPoint - { + { + private readonly IGeometry linearGeom; + /// + /// Initializes a new instance of the class. + /// + /// A linear geometry. + public LocationIndexOfPoint(IGeometry linearGeom) + { + this.linearGeom = linearGeom; + } + + /// /// /// /// @@ -25,17 +36,6 @@ return locater.IndexOf(inputPt); } - private IGeometry linearGeom; - - /// - /// Initializes a new instance of the class. - /// - /// A linear geometry. - public LocationIndexOfPoint(IGeometry linearGeom) - { - this.linearGeom = linearGeom; - } - /// /// Find the nearest location along a linear {@link Geometry} to a given point. /// @@ -58,13 +58,17 @@ /// The location of the nearest point. public LinearLocation IndexOfAfter(ICoordinate inputPt, LinearLocation minIndex) { - if (minIndex == null) + if (minIndex == null) + { return IndexOf(inputPt); + } // sanity check for minLocation at or past end of line LinearLocation endLoc = LinearLocation.GetEndLocation(linearGeom); if (endLoc.CompareTo(minIndex) <= 0) + { return endLoc; + } LinearLocation closestAfter = IndexOfFromStart(inputPt, minIndex); @@ -79,7 +83,27 @@ /// /// /// + /// /// + /// + 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; + } + + /// + /// + /// + /// /// /// private LinearLocation IndexOfFromStart(ICoordinate inputPt, LinearLocation minIndex) @@ -114,27 +138,11 @@ minDistance = segDistance; } } - } + } } LinearLocation loc = new LinearLocation(minComponentIndex, minSegmentIndex, minFrac); return loc; } - - /// - /// - /// - /// - /// - /// - 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; - } } -} +} \ No newline at end of file