Index: src/Common/NetTopologySuite/Precision/CommonBitsRemover.cs
===================================================================
diff -u -r8f6ae890fed8e8eae3a32f9c0498a10f82e0ddf9 -r5fc71a385897af92ccb092f2f969b5709afab85a
--- src/Common/NetTopologySuite/Precision/CommonBitsRemover.cs (.../CommonBitsRemover.cs) (revision 8f6ae890fed8e8eae3a32f9c0498a10f82e0ddf9)
+++ src/Common/NetTopologySuite/Precision/CommonBitsRemover.cs (.../CommonBitsRemover.cs) (revision 5fc71a385897af92ccb092f2f969b5709afab85a)
@@ -8,15 +8,22 @@
///
public class CommonBitsRemover
{
- private ICoordinate commonCoord = null;
- private CommonCoordinateFilter ccFilter = new CommonCoordinateFilter();
+ private readonly CommonCoordinateFilter ccFilter = new CommonCoordinateFilter();
///
///
///
- public CommonBitsRemover() { }
+ public CommonBitsRemover()
+ {
+ CommonCoordinate = null;
+ }
///
+ /// The common bits of the Coordinates in the supplied Geometries.
+ ///
+ public ICoordinate CommonCoordinate { get; private set; }
+
+ ///
/// Add a point to the set of geometries whose common bits are
/// being computed. After this method has executed the
/// common coordinate reflects the common bits of all added
@@ -26,31 +33,25 @@
public void Add(IGeometry geom)
{
geom.Apply(ccFilter);
- commonCoord = ccFilter.CommonCoordinate;
+ CommonCoordinate = ccFilter.CommonCoordinate;
}
///
- /// The common bits of the Coordinates in the supplied Geometries.
- ///
- public ICoordinate CommonCoordinate
- {
- get { return commonCoord; }
- }
-
- ///
/// Removes the common coordinate bits from a Geometry.
/// The coordinates of the Geometry are changed.
///
/// The Geometry from which to remove the common coordinate bits.
/// The shifted Geometry.
public IGeometry RemoveCommonBits(IGeometry geom)
{
- if (commonCoord.X == 0.0 && commonCoord.Y == 0.0)
+ if (CommonCoordinate.X == 0.0 && CommonCoordinate.Y == 0.0)
+ {
return geom;
- ICoordinate invCoord = new Coordinate(commonCoord);
+ }
+ ICoordinate invCoord = new Coordinate(CommonCoordinate);
invCoord.X = -invCoord.X;
invCoord.Y = -invCoord.Y;
- Translater trans = new Translater(invCoord);
+ Translater trans = new Translater(invCoord);
geom.Apply(trans);
geom.GeometryChanged();
return geom;
@@ -64,7 +65,7 @@
/// The shifted Geometry.
public void AddCommonBits(IGeometry geom)
{
- Translater trans = new Translater(commonCoord);
+ Translater trans = new Translater(CommonCoordinate);
geom.Apply(trans);
geom.GeometryChanged();
}
@@ -74,37 +75,37 @@
///
public class CommonCoordinateFilter : ICoordinateFilter
{
- private CommonBits commonBitsX = new CommonBits();
- private CommonBits commonBitsY = new CommonBits();
+ private readonly CommonBits commonBitsX = new CommonBits();
+ private readonly CommonBits commonBitsY = new CommonBits();
///
///
///
- ///
- public void Filter(ICoordinate coord)
+ public ICoordinate CommonCoordinate
{
- commonBitsX.Add(coord.X);
- commonBitsY.Add(coord.Y);
+ get
+ {
+ return new Coordinate(commonBitsX.Common, commonBitsY.Common);
+ }
}
///
///
///
- public ICoordinate CommonCoordinate
+ ///
+ public void Filter(ICoordinate coord)
{
- get
- {
- return new Coordinate(commonBitsX.Common, commonBitsY.Common);
- }
+ commonBitsX.Add(coord.X);
+ commonBitsY.Add(coord.Y);
}
}
///
///
///
- class Translater : ICoordinateFilter
+ private class Translater : ICoordinateFilter
{
- private ICoordinate trans = null;
+ private readonly ICoordinate trans = null;
///
///
@@ -126,4 +127,4 @@
}
}
}
-}
+}
\ No newline at end of file