Index: src/Common/NetTopologySuite/Noding/ScaledNoder.cs =================================================================== diff -u -r8f6ae890fed8e8eae3a32f9c0498a10f82e0ddf9 -r5fc71a385897af92ccb092f2f969b5709afab85a --- src/Common/NetTopologySuite/Noding/ScaledNoder.cs (.../ScaledNoder.cs) (revision 8f6ae890fed8e8eae3a32f9c0498a10f82e0ddf9) +++ src/Common/NetTopologySuite/Noding/ScaledNoder.cs (.../ScaledNoder.cs) (revision 5fc71a385897af92ccb092f2f969b5709afab85a) @@ -6,7 +6,6 @@ namespace GisSharpBlog.NetTopologySuite.Noding { - /// /// Wraps a and transforms its input into the integer domain. /// This is intended for use with Snap-Rounding noders, @@ -15,19 +14,19 @@ /// public class ScaledNoder : INoder { - private INoder noder = null; - private double scaleFactor = 0; - private double offsetX = 0; - private double offsetY = 0; - private bool isScaled = false; + private readonly INoder noder = null; + private readonly double scaleFactor = 0; + private readonly double offsetX = 0; + private readonly double offsetY = 0; + private readonly bool isScaled = false; /// /// Initializes a new instance of the class. /// /// /// - public ScaledNoder(INoder noder, double scaleFactor) - : this(noder, scaleFactor, 0, 0) { } + public ScaledNoder(INoder noder, double scaleFactor) + : this(noder, scaleFactor, 0, 0) {} /// /// @@ -36,19 +35,19 @@ /// /// /// - public ScaledNoder(INoder noder, double scaleFactor, double offsetX, double offsetY) + public ScaledNoder(INoder noder, double scaleFactor, double offsetX, double offsetY) { this.noder = noder; this.scaleFactor = scaleFactor; // no need to scale if input precision is already integral - isScaled = ! isIntegerPrecision; + isScaled = !isIntegerPrecision; } /// /// /// public bool isIntegerPrecision - { + { get { return scaleFactor == 1.0; @@ -62,8 +61,10 @@ public IList GetNodedSubstrings() { IList splitSS = noder.GetNodedSubstrings(); - if (isScaled) + if (isScaled) + { Rescale(splitSS); + } return splitSS; } @@ -74,10 +75,12 @@ public void ComputeNodes(IList inputSegStrings) { IList intSegStrings = inputSegStrings; - if(isScaled) + if (isScaled) + { intSegStrings = Scale(inputSegStrings); + } noder.ComputeNodes(intSegStrings); - } + } /// /// @@ -92,7 +95,7 @@ return new SegmentString(Scale(ss.Coordinates), ss.Data); }); } - + /// /// /// @@ -102,11 +105,13 @@ { ICoordinate[] roundPts = new ICoordinate[pts.Length]; for (int i = 0; i < pts.Length; i++) - roundPts[i] = new Coordinate(Math.Round((pts[i].X - offsetX) * scaleFactor), - Math.Round((pts[i].Y - offsetY) * scaleFactor)); + { + roundPts[i] = new Coordinate(Math.Round((pts[i].X - offsetX)*scaleFactor), + Math.Round((pts[i].Y - offsetY)*scaleFactor)); + } ICoordinate[] roundPtsNoDup = CoordinateArrays.RemoveRepeatedPoints(roundPts); return roundPtsNoDup; - } + } /// /// @@ -116,10 +121,10 @@ { CollectionUtil.Apply(segStrings, delegate(object obj) { - SegmentString ss = (SegmentString)obj; + SegmentString ss = (SegmentString) obj; Rescale(ss.Coordinates); return null; - }); + }); } /// @@ -128,11 +133,11 @@ /// private void Rescale(ICoordinate[] pts) { - for (int i = 0; i < pts.Length; i++) + for (int i = 0; i < pts.Length; i++) { - pts[i].X = pts[i].X / scaleFactor + offsetX; - pts[i].Y = pts[i].Y / scaleFactor + offsetY; + pts[i].X = pts[i].X/scaleFactor + offsetX; + pts[i].Y = pts[i].Y/scaleFactor + offsetY; } } } -} +} \ No newline at end of file