Index: src/Common/NetTopologySuite/LinearReferencing/LengthIndexOfPoint.cs
===================================================================
diff -u -r8f6ae890fed8e8eae3a32f9c0498a10f82e0ddf9 -r5fc71a385897af92ccb092f2f969b5709afab85a
--- src/Common/NetTopologySuite/LinearReferencing/LengthIndexOfPoint.cs (.../LengthIndexOfPoint.cs) (revision 8f6ae890fed8e8eae3a32f9c0498a10f82e0ddf9)
+++ src/Common/NetTopologySuite/LinearReferencing/LengthIndexOfPoint.cs (.../LengthIndexOfPoint.cs) (revision 5fc71a385897af92ccb092f2f969b5709afab85a)
@@ -5,13 +5,23 @@
namespace GisSharpBlog.NetTopologySuite.LinearReferencing
{
-
///
///
///
public class LengthIndexOfPoint
{
+ private readonly IGeometry linearGeom;
+
///
+ /// Initializes a new instance of the class.
+ ///
+ /// A linear geometry.
+ public LengthIndexOfPoint(IGeometry linearGeom)
+ {
+ this.linearGeom = linearGeom;
+ }
+
+ ///
///
///
///
@@ -36,18 +46,7 @@
return locater.IndexOfAfter(inputPt, minIndex);
}
- private IGeometry linearGeom;
-
///
- /// Initializes a new instance of the class.
- ///
- /// A linear geometry.
- public LengthIndexOfPoint(IGeometry linearGeom)
- {
- this.linearGeom = linearGeom;
- }
-
- ///
/// Find the nearest location along a linear {@link Geometry} to a given point.
///
/// The coordinate to locate.
@@ -72,12 +71,17 @@
/// The location of the nearest point.
public double IndexOfAfter(ICoordinate inputPt, double minIndex)
{
- if (minIndex < 0.0) return IndexOf(inputPt);
+ if (minIndex < 0.0)
+ {
+ return IndexOf(inputPt);
+ }
// sanity check for minIndex at or past end of line
double endIndex = linearGeom.Length;
if (endIndex < minIndex)
+ {
return endIndex;
+ }
double closestAfter = IndexOfFromStart(inputPt, minIndex);
@@ -103,7 +107,7 @@
double segmentStartMeasure = 0.0;
LineSegment seg = new LineSegment();
- foreach(LinearIterator.LinearElement element in new LinearIterator(linearGeom))
+ foreach (LinearIterator.LinearElement element in new LinearIterator(linearGeom))
{
if (!element.IsEndOfLine)
{
@@ -117,7 +121,7 @@
minDistance = segDistance;
}
segmentStartMeasure += seg.Length;
- }
+ }
}
return ptMeasure;
}
@@ -134,11 +138,15 @@
// 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;
+ {
+ return segmentStartMeasure + projFactor*seg.Length;
+ }
// ASSERT: projFactor > 1.0
return segmentStartMeasure + seg.Length;
}
}
-}
+}
\ No newline at end of file