Index: src/Common/NetTopologySuite/Algorithm/InteriorPointLine.cs
===================================================================
diff -u -r8f6ae890fed8e8eae3a32f9c0498a10f82e0ddf9 -r5fc71a385897af92ccb092f2f969b5709afab85a
--- src/Common/NetTopologySuite/Algorithm/InteriorPointLine.cs (.../InteriorPointLine.cs) (revision 8f6ae890fed8e8eae3a32f9c0498a10f82e0ddf9)
+++ src/Common/NetTopologySuite/Algorithm/InteriorPointLine.cs (.../InteriorPointLine.cs) (revision 5fc71a385897af92ccb092f2f969b5709afab85a)
@@ -14,33 +14,29 @@
///
public class InteriorPointLine
{
- private ICoordinate centroid = null;
+ private readonly ICoordinate centroid = null;
private double minDistance = Double.MaxValue;
- private ICoordinate interiorPoint = null;
///
///
///
///
public InteriorPointLine(IGeometry g)
{
+ InteriorPoint = null;
centroid = g.Centroid.Coordinate;
AddInterior(g);
- if (interiorPoint == null)
+ if (InteriorPoint == null)
+ {
AddEndpoints(g);
+ }
}
///
///
///
- public ICoordinate InteriorPoint
- {
- get
- {
- return interiorPoint;
- }
- }
+ public ICoordinate InteriorPoint { get; private set; }
///
/// Tests the interior vertices (if any)
@@ -50,13 +46,17 @@
/// The point to add.
private void AddInterior(IGeometry geom)
{
- if(geom is ILineString)
- AddInterior(geom.Coordinates);
- else if(geom is IGeometryCollection)
+ if (geom is ILineString)
{
+ AddInterior(geom.Coordinates);
+ }
+ else if (geom is IGeometryCollection)
+ {
IGeometryCollection gc = (IGeometryCollection) geom;
foreach (IGeometry geometry in gc.Geometries)
+ {
AddInterior(geometry);
+ }
}
}
@@ -67,8 +67,9 @@
private void AddInterior(ICoordinate[] pts)
{
for (int i = 1; i < pts.Length - 1; i++)
+ {
Add(pts[i]);
-
+ }
}
///
@@ -79,13 +80,17 @@
/// The point to add.
private void AddEndpoints(IGeometry geom)
{
- if(geom is ILineString)
- AddEndpoints(geom.Coordinates);
- else if(geom is IGeometryCollection)
+ if (geom is ILineString)
{
+ AddEndpoints(geom.Coordinates);
+ }
+ else if (geom is IGeometryCollection)
+ {
IGeometryCollection gc = (IGeometryCollection) geom;
foreach (IGeometry geometry in gc.Geometries)
+ {
AddEndpoints(geometry);
+ }
}
}
@@ -108,9 +113,9 @@
double dist = point.Distance(centroid);
if (dist < minDistance)
{
- interiorPoint = new Coordinate(point);
+ InteriorPoint = new Coordinate(point);
minDistance = dist;
}
}
}
-}
+}
\ No newline at end of file