[geos-commits] [SCM] GEOS branch master updated. f43aa53d27b3889823365317fcf4ff45e60dc90f

git at osgeo.org git at osgeo.org
Fri Feb 1 11:22:48 PST 2019


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GEOS".

The branch, master has been updated
       via  f43aa53d27b3889823365317fcf4ff45e60dc90f (commit)
      from  a252dd31edfe3e67271de4903cf94a1694d5bb33 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit f43aa53d27b3889823365317fcf4ff45e60dc90f
Author: Paul Ramsey <pramsey at cleverelephant.ca>
Date:   Fri Feb 1 11:18:06 2019 -0800

    Apply 4-spaces standard indenting,
    120 column wrapping, and some basic
    consistency around parens, operators and
    function signatures. Code now matches
    editorconfig so patches should largely
    lack whitespace noise, and folks trying
    to "match the code around" should find
    it easier to figure out what "match"
    means.
    Per https://lists.osgeo.org/pipermail/geos-devel/2018-September/008539.html

diff --git a/.astylerc b/.astylerc
new file mode 100644
index 0000000..fb05c50
--- /dev/null
+++ b/.astylerc
@@ -0,0 +1,12 @@
+--style=stroustrup
+--indent=spaces=4
+--max-code-length=120
+--lineend=linux
+--unpad-paren
+--pad-oper
+--align-pointer=type
+--align-reference=type
+--break-closing-braces
+--add-braces
+--break-return-type
+--break-after-logical
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 421862b..2f00af5 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -13,12 +13,12 @@
 cmake_minimum_required(VERSION 3.1.3)
 
 if(NOT CMAKE_VERSION)
-    set(CMAKE_VERSION
-      "${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}.${CMAKE_PATCH_VERSION}")
+  set(CMAKE_VERSION
+    "${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}.${CMAKE_PATCH_VERSION}")
 endif()
 
 if(POLICY CMP0048)
-    cmake_policy(SET CMP0048 NEW)
+  cmake_policy(SET CMP0048 NEW)
 endif()
 #################################################################################
 # Set GEOS project
diff --git a/capi/geos_c.cpp b/capi/geos_c.cpp
index cd22cd4..9f72e40 100644
--- a/capi/geos_c.cpp
+++ b/capi/geos_c.cpp
@@ -89,146 +89,144 @@ GEOSContextHandle_t handle = NULL;
 
 extern "C" {
 
-void
-initGEOS (GEOSMessageHandler nf, GEOSMessageHandler ef)
-{
-    if ( ! handle )
-    {
-        handle = initGEOS_r( nf, ef );
-    }
-    else
-    {
-        GEOSContext_setNoticeHandler_r(handle, nf);
-        GEOSContext_setErrorHandler_r(handle, ef);
-    }
-
-    geos::util::Interrupt::cancel();
-}
-
-void
-finishGEOS ()
-{
-    if (handle != NULL) {
-        finishGEOS_r( handle );
-        handle = NULL;
-    }
-}
-
-GEOSInterruptCallback*
-GEOS_interruptRegisterCallback(GEOSInterruptCallback* cb)
-{
-  return geos::util::Interrupt::registerCallback(cb);
-}
-
-void
-GEOS_interruptRequest()
-{
-  geos::util::Interrupt::request();
-}
-
-void
-GEOS_interruptCancel()
-{
-  geos::util::Interrupt::cancel();
-}
-
-void
-GEOSFree (void* buffer)
-{
-    GEOSFree_r( handle, buffer );
-}
-
-/****************************************************************
-** relate()-related functions
-** return 0 = false, 1 = true, 2 = error occured
-**
-*/
-char
-GEOSDisjoint(const Geometry *g1, const Geometry *g2)
-{
-    return GEOSDisjoint_r( handle, g1, g2 );
-}
-
-char
-GEOSTouches(const Geometry *g1, const Geometry *g2)
-{
-    return GEOSTouches_r( handle, g1, g2 );
-}
-
-char
-GEOSIntersects(const Geometry *g1, const Geometry *g2)
-{
-    return GEOSIntersects_r( handle, g1, g2 );
-}
-
-char
-GEOSCrosses(const Geometry *g1, const Geometry *g2)
-{
-    return GEOSCrosses_r( handle, g1, g2 );
-}
-
-char
-GEOSWithin(const Geometry *g1, const Geometry *g2)
-{
-    return GEOSWithin_r( handle, g1, g2 );
-}
+    void
+    initGEOS(GEOSMessageHandler nf, GEOSMessageHandler ef)
+    {
+        if(! handle) {
+            handle = initGEOS_r(nf, ef);
+        }
+        else {
+            GEOSContext_setNoticeHandler_r(handle, nf);
+            GEOSContext_setErrorHandler_r(handle, ef);
+        }
+
+        geos::util::Interrupt::cancel();
+    }
+
+    void
+    finishGEOS()
+    {
+        if(handle != NULL) {
+            finishGEOS_r(handle);
+            handle = NULL;
+        }
+    }
+
+    GEOSInterruptCallback*
+    GEOS_interruptRegisterCallback(GEOSInterruptCallback* cb)
+    {
+        return geos::util::Interrupt::registerCallback(cb);
+    }
+
+    void
+    GEOS_interruptRequest()
+    {
+        geos::util::Interrupt::request();
+    }
+
+    void
+    GEOS_interruptCancel()
+    {
+        geos::util::Interrupt::cancel();
+    }
+
+    void
+    GEOSFree(void* buffer)
+    {
+        GEOSFree_r(handle, buffer);
+    }
+
+    /****************************************************************
+    ** relate()-related functions
+    ** return 0 = false, 1 = true, 2 = error occured
+    **
+    */
+    char
+    GEOSDisjoint(const Geometry* g1, const Geometry* g2)
+    {
+        return GEOSDisjoint_r(handle, g1, g2);
+    }
+
+    char
+    GEOSTouches(const Geometry* g1, const Geometry* g2)
+    {
+        return GEOSTouches_r(handle, g1, g2);
+    }
+
+    char
+    GEOSIntersects(const Geometry* g1, const Geometry* g2)
+    {
+        return GEOSIntersects_r(handle, g1, g2);
+    }
+
+    char
+    GEOSCrosses(const Geometry* g1, const Geometry* g2)
+    {
+        return GEOSCrosses_r(handle, g1, g2);
+    }
+
+    char
+    GEOSWithin(const Geometry* g1, const Geometry* g2)
+    {
+        return GEOSWithin_r(handle, g1, g2);
+    }
 
 // call g1->contains(g2)
 // returns 0 = false
 //         1 = true
 //         2 = error was trapped
-char
-GEOSContains(const Geometry *g1, const Geometry *g2)
-{
-    return GEOSContains_r( handle, g1, g2 );
-}
-
-char
-GEOSOverlaps(const Geometry *g1, const Geometry *g2)
-{
-    return GEOSOverlaps_r( handle, g1, g2 );
-}
-
-char
-GEOSCovers(const Geometry *g1, const Geometry *g2)
-{
-    return GEOSCovers_r( handle, g1, g2 );
-}
-
-char
-GEOSCoveredBy(const Geometry *g1, const Geometry *g2)
-{
-    return GEOSCoveredBy_r( handle, g1, g2 );
-}
+    char
+    GEOSContains(const Geometry* g1, const Geometry* g2)
+    {
+        return GEOSContains_r(handle, g1, g2);
+    }
+
+    char
+    GEOSOverlaps(const Geometry* g1, const Geometry* g2)
+    {
+        return GEOSOverlaps_r(handle, g1, g2);
+    }
+
+    char
+    GEOSCovers(const Geometry* g1, const Geometry* g2)
+    {
+        return GEOSCovers_r(handle, g1, g2);
+    }
+
+    char
+    GEOSCoveredBy(const Geometry* g1, const Geometry* g2)
+    {
+        return GEOSCoveredBy_r(handle, g1, g2);
+    }
 
 
 //-------------------------------------------------------------------
 // low-level relate functions
 //------------------------------------------------------------------
 
-char
-GEOSRelatePattern(const Geometry *g1, const Geometry *g2, const char *pat)
-{
-    return GEOSRelatePattern_r( handle, g1, g2, pat );
-}
+    char
+    GEOSRelatePattern(const Geometry* g1, const Geometry* g2, const char* pat)
+    {
+        return GEOSRelatePattern_r(handle, g1, g2, pat);
+    }
 
-char
-GEOSRelatePatternMatch(const char *mat, const char *pat)
-{
-    return GEOSRelatePatternMatch_r( handle, mat, pat );
-}
+    char
+    GEOSRelatePatternMatch(const char* mat, const char* pat)
+    {
+        return GEOSRelatePatternMatch_r(handle, mat, pat);
+    }
 
-char *
-GEOSRelate(const Geometry *g1, const Geometry *g2)
-{
-    return GEOSRelate_r( handle, g1, g2 );
-}
+    char*
+    GEOSRelate(const Geometry* g1, const Geometry* g2)
+    {
+        return GEOSRelate_r(handle, g1, g2);
+    }
 
-char *
-GEOSRelateBoundaryNodeRule(const Geometry *g1, const Geometry *g2, int bnr)
-{
-    return GEOSRelateBoundaryNodeRule_r( handle, g1, g2, bnr );
-}
+    char*
+    GEOSRelateBoundaryNodeRule(const Geometry* g1, const Geometry* g2, int bnr)
+    {
+        return GEOSRelateBoundaryNodeRule_r(handle, g1, g2, bnr);
+    }
 
 
 //-----------------------------------------------------------------
@@ -236,167 +234,167 @@ GEOSRelateBoundaryNodeRule(const Geometry *g1, const Geometry *g2, int bnr)
 //-----------------------------------------------------------------
 
 
-char
-GEOSisValid(const Geometry *g)
-{
-    return GEOSisValid_r( handle, g );
-}
+    char
+    GEOSisValid(const Geometry* g)
+    {
+        return GEOSisValid_r(handle, g);
+    }
 
-char *
-GEOSisValidReason(const Geometry *g)
-{
-    return GEOSisValidReason_r( handle, g );
-}
+    char*
+    GEOSisValidReason(const Geometry* g)
+    {
+        return GEOSisValidReason_r(handle, g);
+    }
 
-char
-GEOSisValidDetail(const Geometry *g, int flags,
-	char** reason, Geometry ** location)
-{
-    return GEOSisValidDetail_r( handle, g, flags, reason, location );
-}
+    char
+    GEOSisValidDetail(const Geometry* g, int flags,
+                      char** reason, Geometry** location)
+    {
+        return GEOSisValidDetail_r(handle, g, flags, reason, location);
+    }
 
 //-----------------------------------------------------------------
 // general purpose
 //-----------------------------------------------------------------
 
-char
-GEOSEquals(const Geometry *g1, const Geometry *g2)
-{
-    return GEOSEquals_r( handle, g1, g2 );
-}
-
-char
-GEOSEqualsExact(const Geometry *g1, const Geometry *g2, double tolerance)
-{
-    return GEOSEqualsExact_r( handle, g1, g2, tolerance );
-}
-
-int
-GEOSDistance(const Geometry *g1, const Geometry *g2, double *dist)
-{
-    return GEOSDistance_r( handle, g1, g2, dist );
-}
-
-int
-GEOSDistanceIndexed(const Geometry *g1, const Geometry *g2, double *dist)
-{
-    return GEOSDistanceIndexed_r( handle, g1, g2, dist );
-}
-
-int
-GEOSHausdorffDistance(const Geometry *g1, const Geometry *g2, double *dist)
-{
-    return GEOSHausdorffDistance_r( handle, g1, g2, dist );
-}
-
-int
-GEOSHausdorffDistanceDensify(const Geometry *g1, const Geometry *g2, double densifyFrac, double *dist)
-{
-    return GEOSHausdorffDistanceDensify_r( handle, g1, g2, densifyFrac, dist );
-}
-
-int
-GEOSFrechetDistance(const Geometry *g1, const Geometry *g2, double *dist)
-{
-    return GEOSFrechetDistance_r( handle, g1, g2, dist );
-}
-
-int
-GEOSFrechetDistanceDensify(const Geometry *g1, const Geometry *g2, double densifyFrac, double *dist)
-{
-    return GEOSFrechetDistanceDensify_r( handle, g1, g2, densifyFrac, dist );
-}
-
-int
-GEOSArea(const Geometry *g, double *area)
-{
-    return GEOSArea_r( handle, g, area );
-}
-
-int
-GEOSLength(const Geometry *g, double *length)
-{
-    return GEOSLength_r( handle, g, length );
-}
-
-CoordinateSequence *
-GEOSNearestPoints(const Geometry *g1, const Geometry *g2)
-{
-    return GEOSNearestPoints_r( handle, g1, g2 );
-}
-
-Geometry *
-GEOSGeomFromWKT(const char *wkt)
-{
-    return GEOSGeomFromWKT_r( handle, wkt );
-}
-
-char *
-GEOSGeomToWKT(const Geometry *g)
-{
-    return GEOSGeomToWKT_r( handle, g );
-}
+    char
+    GEOSEquals(const Geometry* g1, const Geometry* g2)
+    {
+        return GEOSEquals_r(handle, g1, g2);
+    }
+
+    char
+    GEOSEqualsExact(const Geometry* g1, const Geometry* g2, double tolerance)
+    {
+        return GEOSEqualsExact_r(handle, g1, g2, tolerance);
+    }
+
+    int
+    GEOSDistance(const Geometry* g1, const Geometry* g2, double* dist)
+    {
+        return GEOSDistance_r(handle, g1, g2, dist);
+    }
+
+    int
+    GEOSDistanceIndexed(const Geometry* g1, const Geometry* g2, double* dist)
+    {
+        return GEOSDistanceIndexed_r(handle, g1, g2, dist);
+    }
+
+    int
+    GEOSHausdorffDistance(const Geometry* g1, const Geometry* g2, double* dist)
+    {
+        return GEOSHausdorffDistance_r(handle, g1, g2, dist);
+    }
+
+    int
+    GEOSHausdorffDistanceDensify(const Geometry* g1, const Geometry* g2, double densifyFrac, double* dist)
+    {
+        return GEOSHausdorffDistanceDensify_r(handle, g1, g2, densifyFrac, dist);
+    }
+
+    int
+    GEOSFrechetDistance(const Geometry* g1, const Geometry* g2, double* dist)
+    {
+        return GEOSFrechetDistance_r(handle, g1, g2, dist);
+    }
+
+    int
+    GEOSFrechetDistanceDensify(const Geometry* g1, const Geometry* g2, double densifyFrac, double* dist)
+    {
+        return GEOSFrechetDistanceDensify_r(handle, g1, g2, densifyFrac, dist);
+    }
+
+    int
+    GEOSArea(const Geometry* g, double* area)
+    {
+        return GEOSArea_r(handle, g, area);
+    }
+
+    int
+    GEOSLength(const Geometry* g, double* length)
+    {
+        return GEOSLength_r(handle, g, length);
+    }
+
+    CoordinateSequence*
+    GEOSNearestPoints(const Geometry* g1, const Geometry* g2)
+    {
+        return GEOSNearestPoints_r(handle, g1, g2);
+    }
+
+    Geometry*
+    GEOSGeomFromWKT(const char* wkt)
+    {
+        return GEOSGeomFromWKT_r(handle, wkt);
+    }
+
+    char*
+    GEOSGeomToWKT(const Geometry* g)
+    {
+        return GEOSGeomToWKT_r(handle, g);
+    }
 
 // Remember to free the result!
-unsigned char *
-GEOSGeomToWKB_buf(const Geometry *g, size_t *size)
-{
-    return GEOSGeomToWKB_buf_r( handle, g, size );
-}
-
-Geometry *
-GEOSGeomFromWKB_buf(const unsigned char *wkb, size_t size)
-{
-    return GEOSGeomFromWKB_buf_r( handle, wkb, size );
-}
-
-/* Read/write wkb hex values.  Returned geometries are
-   owned by the caller.*/
-unsigned char *
-GEOSGeomToHEX_buf(const Geometry *g, size_t *size)
-{
-    return GEOSGeomToHEX_buf_r( handle, g, size );
-}
-
-Geometry *
-GEOSGeomFromHEX_buf(const unsigned char *hex, size_t size)
-{
-    return GEOSGeomFromHEX_buf_r( handle, hex, size );
-}
-
-char
-GEOSisEmpty(const Geometry *g)
-{
-    return GEOSisEmpty_r( handle, g );
-}
-
-char
-GEOSisSimple(const Geometry *g)
-{
-    return GEOSisSimple_r( handle, g );
-}
-
-char
-GEOSisRing(const Geometry *g)
-{
-    return GEOSisRing_r( handle, g );
-}
+    unsigned char*
+    GEOSGeomToWKB_buf(const Geometry* g, size_t* size)
+    {
+        return GEOSGeomToWKB_buf_r(handle, g, size);
+    }
+
+    Geometry*
+    GEOSGeomFromWKB_buf(const unsigned char* wkb, size_t size)
+    {
+        return GEOSGeomFromWKB_buf_r(handle, wkb, size);
+    }
+
+    /* Read/write wkb hex values.  Returned geometries are
+       owned by the caller.*/
+    unsigned char*
+    GEOSGeomToHEX_buf(const Geometry* g, size_t* size)
+    {
+        return GEOSGeomToHEX_buf_r(handle, g, size);
+    }
+
+    Geometry*
+    GEOSGeomFromHEX_buf(const unsigned char* hex, size_t size)
+    {
+        return GEOSGeomFromHEX_buf_r(handle, hex, size);
+    }
+
+    char
+    GEOSisEmpty(const Geometry* g)
+    {
+        return GEOSisEmpty_r(handle, g);
+    }
+
+    char
+    GEOSisSimple(const Geometry* g)
+    {
+        return GEOSisSimple_r(handle, g);
+    }
+
+    char
+    GEOSisRing(const Geometry* g)
+    {
+        return GEOSisRing_r(handle, g);
+    }
 
 
 
 //free the result of this
-char *
-GEOSGeomType(const Geometry *g)
-{
-    return GEOSGeomType_r( handle, g );
-}
+    char*
+    GEOSGeomType(const Geometry* g)
+    {
+        return GEOSGeomType_r(handle, g);
+    }
 
 // Return postgis geometry type index
-int
-GEOSGeomTypeId(const Geometry *g)
-{
-    return GEOSGeomTypeId_r( handle, g );
-}
+    int
+    GEOSGeomTypeId(const Geometry* g)
+    {
+        return GEOSGeomTypeId_r(handle, g);
+    }
 
 
 
@@ -405,132 +403,132 @@ GEOSGeomTypeId(const Geometry *g)
 // GEOS functions that return geometries
 //-------------------------------------------------------------------
 
-Geometry *
-GEOSEnvelope(const Geometry *g)
-{
-    return GEOSEnvelope_r( handle, g );
-}
-
-Geometry *
-GEOSIntersection(const Geometry *g1, const Geometry *g2)
-{
-    return GEOSIntersection_r( handle, g1, g2 );
-}
-
-Geometry *
-GEOSBuffer(const Geometry *g, double width, int quadrantsegments)
-{
-    return GEOSBuffer_r( handle, g, width, quadrantsegments );
-}
-
-Geometry *
-GEOSBufferWithStyle(const Geometry *g, double width, int quadsegs,
-	int endCapStyle, int joinStyle, double mitreLimit)
-{
-    return GEOSBufferWithStyle_r( handle, g, width, quadsegs, endCapStyle,
-                               joinStyle, mitreLimit );
-}
-
-Geometry *
-GEOSSingleSidedBuffer(const Geometry *g, double width, int quadsegs,
-	int joinStyle, double mitreLimit, int leftSide)
-{
-    return GEOSSingleSidedBuffer_r( handle, g, width, quadsegs,
-                               joinStyle, mitreLimit, leftSide );
-}
-
-Geometry *
-GEOSOffsetCurve(const Geometry *g, double width, int quadsegs,
-	int joinStyle, double mitreLimit)
-{
-    return GEOSOffsetCurve_r( handle, g, width, quadsegs,
-                               joinStyle, mitreLimit );
-}
-
-Geometry *
-GEOSConvexHull(const Geometry *g)
-{
-    return GEOSConvexHull_r( handle, g );
-}
-
-Geometry *
-GEOSMinimumRotatedRectangle(const Geometry *g)
-{
-    return GEOSMinimumRotatedRectangle_r( handle, g );
-}
-
-Geometry *
-GEOSMinimumWidth(const Geometry *g)
-{
-    return GEOSMinimumWidth_r( handle, g );
-}
-
-Geometry *
-GEOSMinimumClearanceLine(const Geometry *g)
-{
-    return GEOSMinimumClearanceLine_r( handle, g );
-}
-
-int
-GEOSMinimumClearance(const Geometry *g, double *d)
-{
-    return GEOSMinimumClearance_r( handle, g, d);
-}
-
-Geometry *
-GEOSDifference(const Geometry *g1, const Geometry *g2)
-{
-    return GEOSDifference_r( handle, g1, g2 );
-}
-
-Geometry *
-GEOSBoundary(const Geometry *g)
-{
-    return GEOSBoundary_r( handle, g );
-}
-
-Geometry *
-GEOSSymDifference(const Geometry *g1, const Geometry *g2)
-{
-    return GEOSSymDifference_r( handle, g1, g2 );
-}
-
-Geometry *
-GEOSUnion(const Geometry *g1, const Geometry *g2)
-{
-    return GEOSUnion_r( handle, g1, g2 );
-}
-
-Geometry *
-GEOSUnaryUnion(const Geometry *g)
-{
-    return GEOSUnaryUnion_r( handle, g);
-}
-
-Geometry *
-GEOSNode(const Geometry *g)
-{
-    return GEOSNode_r( handle, g );
-}
-
-Geometry *
-GEOSUnionCascaded(const Geometry *g)
-{
-	return GEOSUnionCascaded_r( handle, g );
-}
-
-Geometry *
-GEOSPointOnSurface(const Geometry *g)
-{
-    return GEOSPointOnSurface_r( handle, g );
-}
-
-
-Geometry *
-GEOSClipByRect(const Geometry *g, double xmin, double ymin, double xmax, double ymax)
-{
-    return GEOSClipByRect_r( handle, g, xmin, ymin, xmax, ymax );
-}
+    Geometry*
+    GEOSEnvelope(const Geometry* g)
+    {
+        return GEOSEnvelope_r(handle, g);
+    }
+
+    Geometry*
+    GEOSIntersection(const Geometry* g1, const Geometry* g2)
+    {
+        return GEOSIntersection_r(handle, g1, g2);
+    }
+
+    Geometry*
+    GEOSBuffer(const Geometry* g, double width, int quadrantsegments)
+    {
+        return GEOSBuffer_r(handle, g, width, quadrantsegments);
+    }
+
+    Geometry*
+    GEOSBufferWithStyle(const Geometry* g, double width, int quadsegs,
+                        int endCapStyle, int joinStyle, double mitreLimit)
+    {
+        return GEOSBufferWithStyle_r(handle, g, width, quadsegs, endCapStyle,
+                                     joinStyle, mitreLimit);
+    }
+
+    Geometry*
+    GEOSSingleSidedBuffer(const Geometry* g, double width, int quadsegs,
+                          int joinStyle, double mitreLimit, int leftSide)
+    {
+        return GEOSSingleSidedBuffer_r(handle, g, width, quadsegs,
+                                       joinStyle, mitreLimit, leftSide);
+    }
+
+    Geometry*
+    GEOSOffsetCurve(const Geometry* g, double width, int quadsegs,
+                    int joinStyle, double mitreLimit)
+    {
+        return GEOSOffsetCurve_r(handle, g, width, quadsegs,
+                                 joinStyle, mitreLimit);
+    }
+
+    Geometry*
+    GEOSConvexHull(const Geometry* g)
+    {
+        return GEOSConvexHull_r(handle, g);
+    }
+
+    Geometry*
+    GEOSMinimumRotatedRectangle(const Geometry* g)
+    {
+        return GEOSMinimumRotatedRectangle_r(handle, g);
+    }
+
+    Geometry*
+    GEOSMinimumWidth(const Geometry* g)
+    {
+        return GEOSMinimumWidth_r(handle, g);
+    }
+
+    Geometry*
+    GEOSMinimumClearanceLine(const Geometry* g)
+    {
+        return GEOSMinimumClearanceLine_r(handle, g);
+    }
+
+    int
+    GEOSMinimumClearance(const Geometry* g, double* d)
+    {
+        return GEOSMinimumClearance_r(handle, g, d);
+    }
+
+    Geometry*
+    GEOSDifference(const Geometry* g1, const Geometry* g2)
+    {
+        return GEOSDifference_r(handle, g1, g2);
+    }
+
+    Geometry*
+    GEOSBoundary(const Geometry* g)
+    {
+        return GEOSBoundary_r(handle, g);
+    }
+
+    Geometry*
+    GEOSSymDifference(const Geometry* g1, const Geometry* g2)
+    {
+        return GEOSSymDifference_r(handle, g1, g2);
+    }
+
+    Geometry*
+    GEOSUnion(const Geometry* g1, const Geometry* g2)
+    {
+        return GEOSUnion_r(handle, g1, g2);
+    }
+
+    Geometry*
+    GEOSUnaryUnion(const Geometry* g)
+    {
+        return GEOSUnaryUnion_r(handle, g);
+    }
+
+    Geometry*
+    GEOSNode(const Geometry* g)
+    {
+        return GEOSNode_r(handle, g);
+    }
+
+    Geometry*
+    GEOSUnionCascaded(const Geometry* g)
+    {
+        return GEOSUnionCascaded_r(handle, g);
+    }
+
+    Geometry*
+    GEOSPointOnSurface(const Geometry* g)
+    {
+        return GEOSPointOnSurface_r(handle, g);
+    }
+
+
+    Geometry*
+    GEOSClipByRect(const Geometry* g, double xmin, double ymin, double xmax, double ymax)
+    {
+        return GEOSClipByRect_r(handle, g, xmin, ymin, xmax, ymax);
+    }
 
 
 
@@ -539,880 +537,880 @@ GEOSClipByRect(const Geometry *g, double xmin, double ymin, double xmax, double
 //------------------------------------------------------------------
 
 
-void
-GEOSGeom_destroy(Geometry *a)
-{
-    return GEOSGeom_destroy_r( handle, a );
-}
+    void
+    GEOSGeom_destroy(Geometry* a)
+    {
+        return GEOSGeom_destroy_r(handle, a);
+    }
 
 
-int
-GEOSGetNumCoordinates(const Geometry *g)
-{
-    return GEOSGetNumCoordinates_r( handle, g );
-}
+    int
+    GEOSGetNumCoordinates(const Geometry* g)
+    {
+        return GEOSGetNumCoordinates_r(handle, g);
+    }
+
+    /*
+     * Return -1 on exception, 0 otherwise.
+     * Converts Geometry to normal form (or canonical form).
+     */
+    int
+    GEOSNormalize(Geometry* g)
+    {
+        return GEOSNormalize_r(handle, g);
+    }
 
-/*
- * Return -1 on exception, 0 otherwise.
- * Converts Geometry to normal form (or canonical form).
- */
-int
-GEOSNormalize(Geometry *g)
-{
-    return GEOSNormalize_r( handle, g );
-}
-
-int
-GEOSGetNumInteriorRings(const Geometry *g)
-{
-    return GEOSGetNumInteriorRings_r( handle, g );
-}
+    int
+    GEOSGetNumInteriorRings(const Geometry* g)
+    {
+        return GEOSGetNumInteriorRings_r(handle, g);
+    }
 
 
 // returns -1 on error and 1 for non-multi geometries
-int
-GEOSGetNumGeometries(const Geometry *g)
-{
-    return GEOSGetNumGeometries_r( handle, g );
-}
+    int
+    GEOSGetNumGeometries(const Geometry* g)
+    {
+        return GEOSGetNumGeometries_r(handle, g);
+    }
 
 
-/*
- * Call only on GEOMETRYCOLLECTION or MULTI*.
- * Return a pointer to the internal Geometry.
- */
-const Geometry *
-GEOSGetGeometryN(const Geometry *g, int n)
-{
-    return GEOSGetGeometryN_r( handle, g, n );
-}
+    /*
+     * Call only on GEOMETRYCOLLECTION or MULTI*.
+     * Return a pointer to the internal Geometry.
+     */
+    const Geometry*
+    GEOSGetGeometryN(const Geometry* g, int n)
+    {
+        return GEOSGetGeometryN_r(handle, g, n);
+    }
 
-/*
- * Call only on LINESTRING
- * Returns NULL on exception
- */
-Geometry *
-GEOSGeomGetPointN(const Geometry *g, int n)
-{
-	return GEOSGeomGetPointN_r(handle, g, n);
-}
+    /*
+     * Call only on LINESTRING
+     * Returns NULL on exception
+     */
+    Geometry*
+    GEOSGeomGetPointN(const Geometry* g, int n)
+    {
+        return GEOSGeomGetPointN_r(handle, g, n);
+    }
 
-/*
- * Call only on LINESTRING
- */
-Geometry *
-GEOSGeomGetStartPoint(const Geometry *g)
-{
-	return GEOSGeomGetStartPoint_r(handle, g);
-}
+    /*
+     * Call only on LINESTRING
+     */
+    Geometry*
+    GEOSGeomGetStartPoint(const Geometry* g)
+    {
+        return GEOSGeomGetStartPoint_r(handle, g);
+    }
 
-/*
- * Call only on LINESTRING
- */
-Geometry *
-GEOSGeomGetEndPoint(const Geometry *g)
-{
-	return GEOSGeomGetEndPoint_r(handle, g);
-}
+    /*
+     * Call only on LINESTRING
+     */
+    Geometry*
+    GEOSGeomGetEndPoint(const Geometry* g)
+    {
+        return GEOSGeomGetEndPoint_r(handle, g);
+    }
 
-/*
- * Call only on LINESTRING
- * return 2 on exception, 1 on true, 0 on false
- */
-char
-GEOSisClosed(const Geometry *g)
-{
-	return GEOSisClosed_r(handle, g);
-}
+    /*
+     * Call only on LINESTRING
+     * return 2 on exception, 1 on true, 0 on false
+     */
+    char
+    GEOSisClosed(const Geometry* g)
+    {
+        return GEOSisClosed_r(handle, g);
+    }
 
-/*
- * Call only on LINESTRING
- * returns 0 on exception, otherwise 1
- */
-int
-GEOSGeomGetLength(const Geometry *g, double *length)
-{
-	return GEOSGeomGetLength_r(handle, g, length);
-}
+    /*
+     * Call only on LINESTRING
+     * returns 0 on exception, otherwise 1
+     */
+    int
+    GEOSGeomGetLength(const Geometry* g, double* length)
+    {
+        return GEOSGeomGetLength_r(handle, g, length);
+    }
 
-/*
- * Call only on LINESTRING
- * returns -1 on exception
- */
-int
-GEOSGeomGetNumPoints(const Geometry *g)
-{
-	return GEOSGeomGetNumPoints_r(handle, g);
-}
+    /*
+     * Call only on LINESTRING
+     * returns -1 on exception
+     */
+    int
+    GEOSGeomGetNumPoints(const Geometry* g)
+    {
+        return GEOSGeomGetNumPoints_r(handle, g);
+    }
 
-/*
- * For POINT
- * returns 0 on exception, otherwise 1
- */
-int
-GEOSGeomGetX(const Geometry *g, double *x)
-{
-	return GEOSGeomGetX_r(handle, g, x);
-}
+    /*
+     * For POINT
+     * returns 0 on exception, otherwise 1
+     */
+    int
+    GEOSGeomGetX(const Geometry* g, double* x)
+    {
+        return GEOSGeomGetX_r(handle, g, x);
+    }
 
-/*
- * For POINT
- * returns 0 on exception, otherwise 1
- */
-int
-GEOSGeomGetY(const Geometry *g, double *y)
-{
-	return GEOSGeomGetY_r(handle, g, y);
-}
+    /*
+     * For POINT
+     * returns 0 on exception, otherwise 1
+     */
+    int
+    GEOSGeomGetY(const Geometry* g, double* y)
+    {
+        return GEOSGeomGetY_r(handle, g, y);
+    }
 
-/*
- * For POINT
- * returns 0 on exception, otherwise 1
- */
-int
-GEOSGeomGetZ(const Geometry *g1, double *z)
-{
-	return GEOSGeomGetZ_r(handle, g1, z);
-}
+    /*
+     * For POINT
+     * returns 0 on exception, otherwise 1
+     */
+    int
+    GEOSGeomGetZ(const Geometry* g1, double* z)
+    {
+        return GEOSGeomGetZ_r(handle, g1, z);
+    }
 
-/*
- * Call only on polygon
- * Return a copy of the internal Geometry.
- */
-const Geometry *
-GEOSGetExteriorRing(const Geometry *g)
-{
-    return GEOSGetExteriorRing_r( handle, g );
-}
+    /*
+     * Call only on polygon
+     * Return a copy of the internal Geometry.
+     */
+    const Geometry*
+    GEOSGetExteriorRing(const Geometry* g)
+    {
+        return GEOSGetExteriorRing_r(handle, g);
+    }
 
-/*
- * Call only on polygon
- * Return a pointer to internal storage, do not destroy it.
- */
-const Geometry *
-GEOSGetInteriorRingN(const Geometry *g, int n)
-{
-    return GEOSGetInteriorRingN_r( handle, g, n );
-}
-
-Geometry *
-GEOSGetCentroid(const Geometry *g)
-{
-    return GEOSGetCentroid_r( handle, g );
-}
-
-Geometry *
-GEOSGeom_createCollection(int type, Geometry **geoms, unsigned int ngeoms)
-{
-    return GEOSGeom_createCollection_r( handle, type, geoms, ngeoms );
-}
-
-Geometry *
-GEOSPolygonize(const Geometry * const * g, unsigned int ngeoms)
-{
-    return GEOSPolygonize_r( handle, g, ngeoms );
-}
-
-Geometry *
-GEOSPolygonizer_getCutEdges(const Geometry * const * g, unsigned int ngeoms)
-{
-    return GEOSPolygonizer_getCutEdges_r( handle, g, ngeoms );
-}
-
-GEOSGeometry *
-GEOSPolygonize_full(const GEOSGeometry* input,
-	GEOSGeometry** cuts, GEOSGeometry** dangles, GEOSGeometry** invalid)
-{
-    return GEOSPolygonize_full_r(handle, input, cuts, dangles, invalid );
-}
-
-Geometry *
-GEOSLineMerge(const Geometry *g)
-{
-    return GEOSLineMerge_r( handle, g );
-}
-
-Geometry *
-GEOSReverse(const Geometry *g)
-{
-    return GEOSReverse_r( handle, g );
-}
-
-int
-GEOSGetSRID(const Geometry *g)
-{
-    return GEOSGetSRID_r( handle, g );
-}
-
-void
-GEOSSetSRID(Geometry *g, int srid)
-{
-    return GEOSSetSRID_r( handle, g, srid );
-}
-
-void *
-GEOSGeom_getUserData(const Geometry *g)
-{
-    return GEOSGeom_getUserData_r( handle, g );
-}
-
-void
-GEOSGeom_setUserData(Geometry *g, void* userData)
-{
-    return GEOSGeom_setUserData_r( handle, g, userData );
-}
-
-char
-GEOSHasZ(const Geometry *g)
-{
-    return GEOSHasZ_r( handle, g );
-}
-
-int
-GEOS_getWKBOutputDims()
-{
-    return GEOS_getWKBOutputDims_r( handle );
-}
-
-int
-GEOS_setWKBOutputDims(int newdims)
-{
-    return GEOS_setWKBOutputDims_r( handle, newdims );
-}
-
-int
-GEOS_getWKBByteOrder()
-{
-	return GEOS_getWKBByteOrder_r( handle );
-}
-
-int
-GEOS_setWKBByteOrder(int byteOrder)
-{
-	return GEOS_setWKBByteOrder_r( handle, byteOrder );
-}
-
-
-CoordinateSequence *
-GEOSCoordSeq_create(unsigned int size, unsigned int dims)
-{
-    return GEOSCoordSeq_create_r( handle, size, dims );
-}
-
-int
-GEOSCoordSeq_setOrdinate(CoordinateSequence *s, unsigned int idx, unsigned int dim, double val)
-{
-    return GEOSCoordSeq_setOrdinate_r( handle, s, idx, dim, val );
-}
-
-int
-GEOSCoordSeq_setX(CoordinateSequence *s, unsigned int idx, double val)
-{
-	return GEOSCoordSeq_setOrdinate(s, idx, 0, val);
-}
-
-int
-GEOSCoordSeq_setY(CoordinateSequence *s, unsigned int idx, double val)
-{
-	return GEOSCoordSeq_setOrdinate(s, idx, 1, val);
-}
-
-int
-GEOSCoordSeq_setZ(CoordinateSequence *s, unsigned int idx, double val)
-{
-	return GEOSCoordSeq_setOrdinate(s, idx, 2, val);
-}
-
-CoordinateSequence *
-GEOSCoordSeq_clone(const CoordinateSequence *s)
-{
-    return GEOSCoordSeq_clone_r( handle, s );
-}
-
-int
-GEOSCoordSeq_getOrdinate(const CoordinateSequence *s, unsigned int idx, unsigned int dim, double *val)
-{
-    return GEOSCoordSeq_getOrdinate_r( handle, s, idx, dim, val );
-}
-
-int
-GEOSCoordSeq_getX(const CoordinateSequence *s, unsigned int idx, double *val)
-{
-	return GEOSCoordSeq_getOrdinate(s, idx, 0, val);
-}
-
-int
-GEOSCoordSeq_getY(const CoordinateSequence *s, unsigned int idx, double *val)
-{
-	return GEOSCoordSeq_getOrdinate(s, idx, 1, val);
-}
-
-int
-GEOSCoordSeq_getZ(const CoordinateSequence *s, unsigned int idx, double *val)
-{
-	return GEOSCoordSeq_getOrdinate(s, idx, 2, val);
-}
-
-int
-GEOSCoordSeq_getSize(const CoordinateSequence *s, unsigned int *size)
-{
-    return GEOSCoordSeq_getSize_r( handle, s, size );
-}
-
-int
-GEOSCoordSeq_getDimensions(const CoordinateSequence *s, unsigned int *dims)
-{
-    return GEOSCoordSeq_getDimensions_r( handle, s, dims );
-}
-
-int
-GEOSCoordSeq_isCCW(const CoordinateSequence *s, char *is_ccw)
-{
-    return GEOSCoordSeq_isCCW_r(handle, s, is_ccw);
-}
-
-void
-GEOSCoordSeq_destroy(CoordinateSequence *s)
-{
-    return GEOSCoordSeq_destroy_r( handle, s );
-}
-
-const CoordinateSequence *
-GEOSGeom_getCoordSeq(const Geometry *g)
-{
-    return GEOSGeom_getCoordSeq_r( handle, g );
-}
-
-Geometry *
-GEOSGeom_createPoint(CoordinateSequence *cs)
-{
-    return GEOSGeom_createPoint_r( handle, cs );
-}
-
-Geometry *
-GEOSGeom_createLinearRing(CoordinateSequence *cs)
-{
-    return GEOSGeom_createLinearRing_r( handle, cs );
-}
-
-Geometry *
-GEOSGeom_createLineString(CoordinateSequence *cs)
-{
-    return GEOSGeom_createLineString_r( handle, cs );
-}
-
-Geometry *
-GEOSGeom_createPolygon(Geometry *shell, Geometry **holes, unsigned int nholes)
-{
-    return GEOSGeom_createPolygon_r( handle, shell, holes, nholes );
-}
-
-Geometry *
-GEOSGeom_clone(const Geometry *g)
-{
-    return GEOSGeom_clone_r( handle, g );
-}
-
-GEOSGeometry *
-GEOSGeom_setPrecision(const GEOSGeometry *g, double gridSize, int flags)
-{
-	return GEOSGeom_setPrecision_r(handle, g, gridSize, flags);
-}
-
-double
-GEOSGeom_getPrecision(const GEOSGeometry *g)
-{
-	return GEOSGeom_getPrecision_r(handle, g);
-}
-
-int
-GEOSGeom_getDimensions(const Geometry *g)
-{
-    return GEOSGeom_getDimensions_r( handle, g );
-}
-
-int
-GEOSGeom_getCoordinateDimension(const Geometry *g)
-{
-    return GEOSGeom_getCoordinateDimension_r( handle, g );
-}
-
-int GEOS_DLL GEOSGeom_getXMin(const GEOSGeometry* g, double* value)
-{
-    return GEOSGeom_getXMin_r(handle, g, value);
-}
-
-int GEOS_DLL GEOSGeom_getYMin(const GEOSGeometry* g, double* value)
-{
-    return GEOSGeom_getYMin_r(handle, g, value);
-}
-
-int GEOS_DLL GEOSGeom_getXMax(const GEOSGeometry* g, double* value)
-{
-    return GEOSGeom_getXMax_r(handle, g, value);
-}
-
-int GEOS_DLL GEOSGeom_getYMax(const GEOSGeometry* g, double* value)
-{
-    return GEOSGeom_getYMax_r(handle, g, value);
-}
-
-Geometry *
-GEOSSimplify(const Geometry *g, double tolerance)
-{
-    return GEOSSimplify_r( handle, g, tolerance );
-}
-
-Geometry *
-GEOSTopologyPreserveSimplify(const Geometry *g, double tolerance)
-{
-    return GEOSTopologyPreserveSimplify_r( handle, g, tolerance );
-}
-
-
-/* WKT Reader */
-WKTReader *
-GEOSWKTReader_create()
-{
-    return GEOSWKTReader_create_r( handle );
-}
-
-void
-GEOSWKTReader_destroy(WKTReader *reader)
-{
-    GEOSWKTReader_destroy_r( handle, reader );
-}
-
-
-Geometry*
-GEOSWKTReader_read(WKTReader *reader, const char *wkt)
-{
-    return GEOSWKTReader_read_r( handle, reader, wkt );
-}
-
-/* WKT Writer */
-WKTWriter *
-GEOSWKTWriter_create()
-{
-    return GEOSWKTWriter_create_r( handle );
-}
-
-void
-GEOSWKTWriter_destroy(WKTWriter *Writer)
-{
-    GEOSWKTWriter_destroy_r( handle, Writer );
-}
-
-char*
-GEOSWKTWriter_write(WKTWriter *writer, const Geometry *geom)
-{
-    return GEOSWKTWriter_write_r( handle, writer, geom );
-}
-
-void
-GEOSWKTWriter_setTrim(WKTWriter *writer, char trim)
-{
-	GEOSWKTWriter_setTrim_r(handle, writer, trim);
-}
-
-void
-GEOSWKTWriter_setRoundingPrecision(WKTWriter *writer, int precision)
-{
-	return GEOSWKTWriter_setRoundingPrecision_r(handle, writer, precision);
-}
-
-void
-GEOSWKTWriter_setOutputDimension(WKTWriter *writer, int dim)
-{
-	GEOSWKTWriter_setOutputDimension_r(handle, writer, dim);
-}
-
-int
-GEOSWKTWriter_getOutputDimension(WKTWriter *writer)
-{
-	return GEOSWKTWriter_getOutputDimension_r(handle, writer);
-}
-
-void
-GEOSWKTWriter_setOld3D(WKTWriter *writer, int useOld3D)
-{
-	GEOSWKTWriter_setOld3D_r(handle, writer, useOld3D);
-}
-
-/* WKB Reader */
-WKBReader *
-GEOSWKBReader_create()
-{
-    return GEOSWKBReader_create_r( handle );
-}
-
-void
-GEOSWKBReader_destroy(WKBReader *reader)
-{
-    GEOSWKBReader_destroy_r( handle, reader );
-}
-
-
-Geometry*
-GEOSWKBReader_read(WKBReader *reader, const unsigned char *wkb, size_t size)
-{
-    return GEOSWKBReader_read_r( handle, reader, wkb, size );
-}
-
-Geometry*
-GEOSWKBReader_readHEX(WKBReader *reader, const unsigned char *hex, size_t size)
-{
-    return GEOSWKBReader_readHEX_r( handle, reader, hex, size );
-}
-
-/* WKB Writer */
-WKBWriter *
-GEOSWKBWriter_create()
-{
-    return GEOSWKBWriter_create_r( handle );
-}
-
-void
-GEOSWKBWriter_destroy(WKBWriter *Writer)
-{
-    GEOSWKBWriter_destroy_r( handle, Writer );
-}
-
-
-/* The caller owns the result */
-unsigned char*
-GEOSWKBWriter_write(WKBWriter *writer, const Geometry *geom, size_t *size)
-{
-    return GEOSWKBWriter_write_r( handle, writer, geom, size );
-}
-
-/* The caller owns the result */
-unsigned char*
-GEOSWKBWriter_writeHEX(WKBWriter *writer, const Geometry *geom, size_t *size)
-{
-    return GEOSWKBWriter_writeHEX_r( handle, writer, geom, size );
-}
-
-int
-GEOSWKBWriter_getOutputDimension(const GEOSWKBWriter* writer)
-{
-    return GEOSWKBWriter_getOutputDimension_r( handle, writer );
-}
-
-void
-GEOSWKBWriter_setOutputDimension(GEOSWKBWriter* writer, int newDimension)
-{
-    GEOSWKBWriter_setOutputDimension_r( handle, writer, newDimension );
-}
-
-int
-GEOSWKBWriter_getByteOrder(const GEOSWKBWriter* writer)
-{
-    return GEOSWKBWriter_getByteOrder_r( handle, writer );
-}
-
-void
-GEOSWKBWriter_setByteOrder(GEOSWKBWriter* writer, int newByteOrder)
-{
-    GEOSWKBWriter_setByteOrder_r( handle, writer, newByteOrder );
-}
-
-char
-GEOSWKBWriter_getIncludeSRID(const GEOSWKBWriter* writer)
-{
-    return GEOSWKBWriter_getIncludeSRID_r( handle, writer );
-}
-
-void
-GEOSWKBWriter_setIncludeSRID(GEOSWKBWriter* writer, const char newIncludeSRID)
-{
-    GEOSWKBWriter_setIncludeSRID_r( handle, writer, newIncludeSRID );
-}
+    /*
+     * Call only on polygon
+     * Return a pointer to internal storage, do not destroy it.
+     */
+    const Geometry*
+    GEOSGetInteriorRingN(const Geometry* g, int n)
+    {
+        return GEOSGetInteriorRingN_r(handle, g, n);
+    }
 
+    Geometry*
+    GEOSGetCentroid(const Geometry* g)
+    {
+        return GEOSGetCentroid_r(handle, g);
+    }
 
-//-----------------------------------------------------------------
-// Prepared Geometry
-//-----------------------------------------------------------------
+    Geometry*
+    GEOSGeom_createCollection(int type, Geometry** geoms, unsigned int ngeoms)
+    {
+        return GEOSGeom_createCollection_r(handle, type, geoms, ngeoms);
+    }
+
+    Geometry*
+    GEOSPolygonize(const Geometry* const* g, unsigned int ngeoms)
+    {
+        return GEOSPolygonize_r(handle, g, ngeoms);
+    }
+
+    Geometry*
+    GEOSPolygonizer_getCutEdges(const Geometry* const* g, unsigned int ngeoms)
+    {
+        return GEOSPolygonizer_getCutEdges_r(handle, g, ngeoms);
+    }
+
+    GEOSGeometry*
+    GEOSPolygonize_full(const GEOSGeometry* input,
+                        GEOSGeometry** cuts, GEOSGeometry** dangles, GEOSGeometry** invalid)
+    {
+        return GEOSPolygonize_full_r(handle, input, cuts, dangles, invalid);
+    }
+
+    Geometry*
+    GEOSLineMerge(const Geometry* g)
+    {
+        return GEOSLineMerge_r(handle, g);
+    }
+
+    Geometry*
+    GEOSReverse(const Geometry* g)
+    {
+        return GEOSReverse_r(handle, g);
+    }
+
+    int
+    GEOSGetSRID(const Geometry* g)
+    {
+        return GEOSGetSRID_r(handle, g);
+    }
+
+    void
+    GEOSSetSRID(Geometry* g, int srid)
+    {
+        return GEOSSetSRID_r(handle, g, srid);
+    }
 
-const geos::geom::prep::PreparedGeometry*
-GEOSPrepare(const Geometry *g)
-{
-    return GEOSPrepare_r( handle, g );
-}
-
-void
-GEOSPreparedGeom_destroy(const geos::geom::prep::PreparedGeometry *a)
-{
-    GEOSPreparedGeom_destroy_r( handle, a );
-}
-
-char
-GEOSPreparedContains(const geos::geom::prep::PreparedGeometry *pg1, const Geometry *g2)
-{
-    return GEOSPreparedContains_r( handle, pg1, g2 );
-}
-
-char
-GEOSPreparedContainsProperly(const geos::geom::prep::PreparedGeometry *pg1, const Geometry *g2)
-{
-    return GEOSPreparedContainsProperly_r( handle, pg1, g2 );
-}
-
-char
-GEOSPreparedCoveredBy(const geos::geom::prep::PreparedGeometry *pg1, const Geometry *g2)
-{
-    return GEOSPreparedCoveredBy_r( handle, pg1, g2 );
-}
-
-char
-GEOSPreparedCovers(const geos::geom::prep::PreparedGeometry *pg1, const Geometry *g2)
-{
-    return GEOSPreparedCovers_r( handle, pg1, g2 );
-}
-
-char
-GEOSPreparedCrosses(const geos::geom::prep::PreparedGeometry *pg1, const Geometry *g2)
-{
-    return GEOSPreparedCrosses_r( handle, pg1, g2 );
-}
-
-char
-GEOSPreparedDisjoint(const geos::geom::prep::PreparedGeometry *pg1, const Geometry *g2)
-{
-    return GEOSPreparedDisjoint_r( handle, pg1, g2 );
-}
-
-char
-GEOSPreparedIntersects(const geos::geom::prep::PreparedGeometry *pg1, const Geometry *g2)
-{
-    return GEOSPreparedIntersects_r( handle, pg1, g2 );
-}
-
-char
-GEOSPreparedOverlaps(const geos::geom::prep::PreparedGeometry *pg1, const Geometry *g2)
-{
-    return GEOSPreparedOverlaps_r( handle, pg1, g2 );
-}
-
-char
-GEOSPreparedTouches(const geos::geom::prep::PreparedGeometry *pg1, const Geometry *g2)
-{
-    return GEOSPreparedTouches_r( handle, pg1, g2 );
-}
-
-char
-GEOSPreparedWithin(const geos::geom::prep::PreparedGeometry *pg1, const Geometry *g2)
-{
-    return GEOSPreparedWithin_r( handle, pg1, g2 );
-}
-
-STRtree *
-GEOSSTRtree_create (size_t nodeCapacity)
-{
-    return GEOSSTRtree_create_r( handle, nodeCapacity );
-}
-
-void
-GEOSSTRtree_insert (geos::index::strtree::STRtree *tree,
-                    const geos::geom::Geometry *g,
-                    void *item)
-{
-    GEOSSTRtree_insert_r( handle, tree, g, item );
-}
-
-void
-GEOSSTRtree_query (geos::index::strtree::STRtree *tree,
-                   const geos::geom::Geometry *g,
-                   GEOSQueryCallback cb,
-                   void *userdata)
-{
-    GEOSSTRtree_query_r( handle, tree, g, cb, userdata );
-}
-
-const GEOSGeometry *
-GEOSSTRtree_nearest (geos::index::strtree::STRtree *tree,
-                     const geos::geom::Geometry *g)
-{
-    return GEOSSTRtree_nearest_r( handle, tree, g);
-}
-
-const void* GEOSSTRtree_nearest_generic(GEOSSTRtree *tree,
-                                        const void* item,
-                                        const GEOSGeometry* itemEnvelope,
-                                        GEOSDistanceCallback distancefn,
-                                        void* userdata)
-{
-    return GEOSSTRtree_nearest_generic_r( handle, tree, item, itemEnvelope, distancefn, userdata);
-}
-
-void
-GEOSSTRtree_iterate(geos::index::strtree::STRtree *tree,
-                    GEOSQueryCallback callback,
-                    void *userdata)
-{
-    GEOSSTRtree_iterate_r( handle, tree, callback, userdata );
-}
-
-char
-GEOSSTRtree_remove (geos::index::strtree::STRtree *tree,
-                    const geos::geom::Geometry *g,
-                    void *item)
-{
-    return GEOSSTRtree_remove_r( handle, tree, g, item );
-}
-
-void
-GEOSSTRtree_destroy (geos::index::strtree::STRtree *tree)
-{
-    GEOSSTRtree_destroy_r( handle, tree );
-}
-
-double
-GEOSProject (const geos::geom::Geometry *g,
-             const geos::geom::Geometry *p)
-{
-    return GEOSProject_r (handle, g, p);
-}
-
-geos::geom::Geometry *
-GEOSInterpolate (const geos::geom::Geometry *g,
-                 double d)
-{
-    return GEOSInterpolate_r(handle, g, d);
-}
-
-double
-GEOSProjectNormalized (const geos::geom::Geometry *g,
-                       const geos::geom::Geometry *p)
-{
-    return GEOSProjectNormalized_r (handle, g, p);
-}
-
-geos::geom::Geometry *
-GEOSInterpolateNormalized (const geos::geom::Geometry *g,
-                           double d)
-{
-    return GEOSInterpolateNormalized_r(handle, g, d);
-}
-
-geos::geom::Geometry *
-GEOSGeom_extractUniquePoints (const geos::geom::Geometry *g)
-{
-    return GEOSGeom_extractUniquePoints_r(handle, g);
-}
-
-geos::geom::Geometry *
-GEOSGeom_createEmptyCollection(int type)
-{
-    return GEOSGeom_createEmptyCollection_r(handle, type);
-}
-
-geos::geom::Geometry *
-GEOSGeom_createEmptyPoint()
-{
-    return GEOSGeom_createEmptyPoint_r(handle);
-}
-
-geos::geom::Geometry *
-GEOSGeom_createEmptyLineString()
-{
-    return GEOSGeom_createEmptyLineString_r(handle);
-}
-
-geos::geom::Geometry *
-GEOSGeom_createEmptyPolygon()
-{
-    return GEOSGeom_createEmptyPolygon_r(handle);
-}
-
-int
-GEOSOrientationIndex(double Ax, double Ay, double Bx, double By,
-	double Px, double Py)
-{
-    return GEOSOrientationIndex_r(handle, Ax, Ay, Bx, By, Px, Py);
-}
-
-GEOSGeometry *
-GEOSSharedPaths(const GEOSGeometry* g1, const GEOSGeometry* g2)
-{
-    return GEOSSharedPaths_r(handle, g1, g2);
-}
-
-GEOSGeometry *
-GEOSSnap(const GEOSGeometry* g1, const GEOSGeometry* g2, double tolerance)
-{
-  return GEOSSnap_r(handle, g1, g2, tolerance);
-}
-
-GEOSBufferParams*
-GEOSBufferParams_create()
-{
-  return GEOSBufferParams_create_r(handle);
-}
-
-void
-GEOSBufferParams_destroy(GEOSBufferParams* p)
-{
-  return GEOSBufferParams_destroy_r(handle, p);
-}
-
-int
-GEOSBufferParams_setEndCapStyle(GEOSBufferParams* p, int style)
-{
-  return GEOSBufferParams_setEndCapStyle_r(handle, p, style);
-}
-
-int
-GEOSBufferParams_setJoinStyle(GEOSBufferParams* p, int joinStyle)
-{
-  return GEOSBufferParams_setJoinStyle_r(handle, p, joinStyle);
-}
-
-int
-GEOSBufferParams_setMitreLimit(GEOSBufferParams* p, double l)
-{
-  return GEOSBufferParams_setMitreLimit_r(handle, p, l);
-}
-
-int
-GEOSBufferParams_setQuadrantSegments(GEOSBufferParams* p, int joinStyle)
-{
-  return GEOSBufferParams_setQuadrantSegments_r(handle, p, joinStyle);
-}
-
-int
-GEOSBufferParams_setSingleSided(GEOSBufferParams* p, int singleSided)
-{
-  return GEOSBufferParams_setSingleSided_r(handle, p, singleSided);
-}
-
-Geometry*
-GEOSBufferWithParams(const Geometry* g, const GEOSBufferParams* p, double w)
-{
-  return GEOSBufferWithParams_r(handle, g, p, w);
-}
-
-Geometry *
-GEOSDelaunayTriangulation(const Geometry *g, double tolerance, int onlyEdges)
-{
-  return GEOSDelaunayTriangulation_r(handle, g, tolerance, onlyEdges);
-}
-
-Geometry*
-GEOSVoronoiDiagram(const Geometry *g, const Geometry *env, double tolerance, int onlyEdges)
-{
-  return GEOSVoronoiDiagram_r(handle, g, env, tolerance, onlyEdges);
-}
-
-int
-GEOSSegmentIntersection(double ax0, double ay0, double ax1, double ay1,
-                        double bx0, double by0, double bx1, double by1,
-                        double* cx, double* cy)
-{
-    return GEOSSegmentIntersection_r(handle,
-        ax0, ay0, ax1, ay1,
-        bx0, by0, bx1, by1,
-        cx, cy);
-}
+    void*
+    GEOSGeom_getUserData(const Geometry* g)
+    {
+        return GEOSGeom_getUserData_r(handle, g);
+    }
+
+    void
+    GEOSGeom_setUserData(Geometry* g, void* userData)
+    {
+        return GEOSGeom_setUserData_r(handle, g, userData);
+    }
+
+    char
+    GEOSHasZ(const Geometry* g)
+    {
+        return GEOSHasZ_r(handle, g);
+    }
+
+    int
+    GEOS_getWKBOutputDims()
+    {
+        return GEOS_getWKBOutputDims_r(handle);
+    }
+
+    int
+    GEOS_setWKBOutputDims(int newdims)
+    {
+        return GEOS_setWKBOutputDims_r(handle, newdims);
+    }
+
+    int
+    GEOS_getWKBByteOrder()
+    {
+        return GEOS_getWKBByteOrder_r(handle);
+    }
+
+    int
+    GEOS_setWKBByteOrder(int byteOrder)
+    {
+        return GEOS_setWKBByteOrder_r(handle, byteOrder);
+    }
+
+
+    CoordinateSequence*
+    GEOSCoordSeq_create(unsigned int size, unsigned int dims)
+    {
+        return GEOSCoordSeq_create_r(handle, size, dims);
+    }
+
+    int
+    GEOSCoordSeq_setOrdinate(CoordinateSequence* s, unsigned int idx, unsigned int dim, double val)
+    {
+        return GEOSCoordSeq_setOrdinate_r(handle, s, idx, dim, val);
+    }
+
+    int
+    GEOSCoordSeq_setX(CoordinateSequence* s, unsigned int idx, double val)
+    {
+        return GEOSCoordSeq_setOrdinate(s, idx, 0, val);
+    }
+
+    int
+    GEOSCoordSeq_setY(CoordinateSequence* s, unsigned int idx, double val)
+    {
+        return GEOSCoordSeq_setOrdinate(s, idx, 1, val);
+    }
+
+    int
+    GEOSCoordSeq_setZ(CoordinateSequence* s, unsigned int idx, double val)
+    {
+        return GEOSCoordSeq_setOrdinate(s, idx, 2, val);
+    }
+
+    CoordinateSequence*
+    GEOSCoordSeq_clone(const CoordinateSequence* s)
+    {
+        return GEOSCoordSeq_clone_r(handle, s);
+    }
+
+    int
+    GEOSCoordSeq_getOrdinate(const CoordinateSequence* s, unsigned int idx, unsigned int dim, double* val)
+    {
+        return GEOSCoordSeq_getOrdinate_r(handle, s, idx, dim, val);
+    }
+
+    int
+    GEOSCoordSeq_getX(const CoordinateSequence* s, unsigned int idx, double* val)
+    {
+        return GEOSCoordSeq_getOrdinate(s, idx, 0, val);
+    }
+
+    int
+    GEOSCoordSeq_getY(const CoordinateSequence* s, unsigned int idx, double* val)
+    {
+        return GEOSCoordSeq_getOrdinate(s, idx, 1, val);
+    }
+
+    int
+    GEOSCoordSeq_getZ(const CoordinateSequence* s, unsigned int idx, double* val)
+    {
+        return GEOSCoordSeq_getOrdinate(s, idx, 2, val);
+    }
+
+    int
+    GEOSCoordSeq_getSize(const CoordinateSequence* s, unsigned int* size)
+    {
+        return GEOSCoordSeq_getSize_r(handle, s, size);
+    }
+
+    int
+    GEOSCoordSeq_getDimensions(const CoordinateSequence* s, unsigned int* dims)
+    {
+        return GEOSCoordSeq_getDimensions_r(handle, s, dims);
+    }
+
+    int
+    GEOSCoordSeq_isCCW(const CoordinateSequence* s, char* is_ccw)
+    {
+        return GEOSCoordSeq_isCCW_r(handle, s, is_ccw);
+    }
+
+    void
+    GEOSCoordSeq_destroy(CoordinateSequence* s)
+    {
+        return GEOSCoordSeq_destroy_r(handle, s);
+    }
+
+    const CoordinateSequence*
+    GEOSGeom_getCoordSeq(const Geometry* g)
+    {
+        return GEOSGeom_getCoordSeq_r(handle, g);
+    }
+
+    Geometry*
+    GEOSGeom_createPoint(CoordinateSequence* cs)
+    {
+        return GEOSGeom_createPoint_r(handle, cs);
+    }
+
+    Geometry*
+    GEOSGeom_createLinearRing(CoordinateSequence* cs)
+    {
+        return GEOSGeom_createLinearRing_r(handle, cs);
+    }
+
+    Geometry*
+    GEOSGeom_createLineString(CoordinateSequence* cs)
+    {
+        return GEOSGeom_createLineString_r(handle, cs);
+    }
+
+    Geometry*
+    GEOSGeom_createPolygon(Geometry* shell, Geometry** holes, unsigned int nholes)
+    {
+        return GEOSGeom_createPolygon_r(handle, shell, holes, nholes);
+    }
+
+    Geometry*
+    GEOSGeom_clone(const Geometry* g)
+    {
+        return GEOSGeom_clone_r(handle, g);
+    }
+
+    GEOSGeometry*
+    GEOSGeom_setPrecision(const GEOSGeometry* g, double gridSize, int flags)
+    {
+        return GEOSGeom_setPrecision_r(handle, g, gridSize, flags);
+    }
+
+    double
+    GEOSGeom_getPrecision(const GEOSGeometry* g)
+    {
+        return GEOSGeom_getPrecision_r(handle, g);
+    }
+
+    int
+    GEOSGeom_getDimensions(const Geometry* g)
+    {
+        return GEOSGeom_getDimensions_r(handle, g);
+    }
+
+    int
+    GEOSGeom_getCoordinateDimension(const Geometry* g)
+    {
+        return GEOSGeom_getCoordinateDimension_r(handle, g);
+    }
+
+    int GEOS_DLL GEOSGeom_getXMin(const GEOSGeometry* g, double* value)
+    {
+        return GEOSGeom_getXMin_r(handle, g, value);
+    }
+
+    int GEOS_DLL GEOSGeom_getYMin(const GEOSGeometry* g, double* value)
+    {
+        return GEOSGeom_getYMin_r(handle, g, value);
+    }
+
+    int GEOS_DLL GEOSGeom_getXMax(const GEOSGeometry* g, double* value)
+    {
+        return GEOSGeom_getXMax_r(handle, g, value);
+    }
+
+    int GEOS_DLL GEOSGeom_getYMax(const GEOSGeometry* g, double* value)
+    {
+        return GEOSGeom_getYMax_r(handle, g, value);
+    }
+
+    Geometry*
+    GEOSSimplify(const Geometry* g, double tolerance)
+    {
+        return GEOSSimplify_r(handle, g, tolerance);
+    }
+
+    Geometry*
+    GEOSTopologyPreserveSimplify(const Geometry* g, double tolerance)
+    {
+        return GEOSTopologyPreserveSimplify_r(handle, g, tolerance);
+    }
+
+
+    /* WKT Reader */
+    WKTReader*
+    GEOSWKTReader_create()
+    {
+        return GEOSWKTReader_create_r(handle);
+    }
+
+    void
+    GEOSWKTReader_destroy(WKTReader* reader)
+    {
+        GEOSWKTReader_destroy_r(handle, reader);
+    }
+
+
+    Geometry*
+    GEOSWKTReader_read(WKTReader* reader, const char* wkt)
+    {
+        return GEOSWKTReader_read_r(handle, reader, wkt);
+    }
+
+    /* WKT Writer */
+    WKTWriter*
+    GEOSWKTWriter_create()
+    {
+        return GEOSWKTWriter_create_r(handle);
+    }
+
+    void
+    GEOSWKTWriter_destroy(WKTWriter* Writer)
+    {
+        GEOSWKTWriter_destroy_r(handle, Writer);
+    }
+
+    char*
+    GEOSWKTWriter_write(WKTWriter* writer, const Geometry* geom)
+    {
+        return GEOSWKTWriter_write_r(handle, writer, geom);
+    }
+
+    void
+    GEOSWKTWriter_setTrim(WKTWriter* writer, char trim)
+    {
+        GEOSWKTWriter_setTrim_r(handle, writer, trim);
+    }
+
+    void
+    GEOSWKTWriter_setRoundingPrecision(WKTWriter* writer, int precision)
+    {
+        return GEOSWKTWriter_setRoundingPrecision_r(handle, writer, precision);
+    }
+
+    void
+    GEOSWKTWriter_setOutputDimension(WKTWriter* writer, int dim)
+    {
+        GEOSWKTWriter_setOutputDimension_r(handle, writer, dim);
+    }
+
+    int
+    GEOSWKTWriter_getOutputDimension(WKTWriter* writer)
+    {
+        return GEOSWKTWriter_getOutputDimension_r(handle, writer);
+    }
+
+    void
+    GEOSWKTWriter_setOld3D(WKTWriter* writer, int useOld3D)
+    {
+        GEOSWKTWriter_setOld3D_r(handle, writer, useOld3D);
+    }
+
+    /* WKB Reader */
+    WKBReader*
+    GEOSWKBReader_create()
+    {
+        return GEOSWKBReader_create_r(handle);
+    }
+
+    void
+    GEOSWKBReader_destroy(WKBReader* reader)
+    {
+        GEOSWKBReader_destroy_r(handle, reader);
+    }
+
+
+    Geometry*
+    GEOSWKBReader_read(WKBReader* reader, const unsigned char* wkb, size_t size)
+    {
+        return GEOSWKBReader_read_r(handle, reader, wkb, size);
+    }
+
+    Geometry*
+    GEOSWKBReader_readHEX(WKBReader* reader, const unsigned char* hex, size_t size)
+    {
+        return GEOSWKBReader_readHEX_r(handle, reader, hex, size);
+    }
+
+    /* WKB Writer */
+    WKBWriter*
+    GEOSWKBWriter_create()
+    {
+        return GEOSWKBWriter_create_r(handle);
+    }
+
+    void
+    GEOSWKBWriter_destroy(WKBWriter* Writer)
+    {
+        GEOSWKBWriter_destroy_r(handle, Writer);
+    }
+
+
+    /* The caller owns the result */
+    unsigned char*
+    GEOSWKBWriter_write(WKBWriter* writer, const Geometry* geom, size_t* size)
+    {
+        return GEOSWKBWriter_write_r(handle, writer, geom, size);
+    }
+
+    /* The caller owns the result */
+    unsigned char*
+    GEOSWKBWriter_writeHEX(WKBWriter* writer, const Geometry* geom, size_t* size)
+    {
+        return GEOSWKBWriter_writeHEX_r(handle, writer, geom, size);
+    }
+
+    int
+    GEOSWKBWriter_getOutputDimension(const GEOSWKBWriter* writer)
+    {
+        return GEOSWKBWriter_getOutputDimension_r(handle, writer);
+    }
+
+    void
+    GEOSWKBWriter_setOutputDimension(GEOSWKBWriter* writer, int newDimension)
+    {
+        GEOSWKBWriter_setOutputDimension_r(handle, writer, newDimension);
+    }
+
+    int
+    GEOSWKBWriter_getByteOrder(const GEOSWKBWriter* writer)
+    {
+        return GEOSWKBWriter_getByteOrder_r(handle, writer);
+    }
+
+    void
+    GEOSWKBWriter_setByteOrder(GEOSWKBWriter* writer, int newByteOrder)
+    {
+        GEOSWKBWriter_setByteOrder_r(handle, writer, newByteOrder);
+    }
+
+    char
+    GEOSWKBWriter_getIncludeSRID(const GEOSWKBWriter* writer)
+    {
+        return GEOSWKBWriter_getIncludeSRID_r(handle, writer);
+    }
+
+    void
+    GEOSWKBWriter_setIncludeSRID(GEOSWKBWriter* writer, const char newIncludeSRID)
+    {
+        GEOSWKBWriter_setIncludeSRID_r(handle, writer, newIncludeSRID);
+    }
+
+
+//-----------------------------------------------------------------
+// Prepared Geometry
+//-----------------------------------------------------------------
+
+    const geos::geom::prep::PreparedGeometry*
+    GEOSPrepare(const Geometry* g)
+    {
+        return GEOSPrepare_r(handle, g);
+    }
+
+    void
+    GEOSPreparedGeom_destroy(const geos::geom::prep::PreparedGeometry* a)
+    {
+        GEOSPreparedGeom_destroy_r(handle, a);
+    }
+
+    char
+    GEOSPreparedContains(const geos::geom::prep::PreparedGeometry* pg1, const Geometry* g2)
+    {
+        return GEOSPreparedContains_r(handle, pg1, g2);
+    }
+
+    char
+    GEOSPreparedContainsProperly(const geos::geom::prep::PreparedGeometry* pg1, const Geometry* g2)
+    {
+        return GEOSPreparedContainsProperly_r(handle, pg1, g2);
+    }
+
+    char
+    GEOSPreparedCoveredBy(const geos::geom::prep::PreparedGeometry* pg1, const Geometry* g2)
+    {
+        return GEOSPreparedCoveredBy_r(handle, pg1, g2);
+    }
+
+    char
+    GEOSPreparedCovers(const geos::geom::prep::PreparedGeometry* pg1, const Geometry* g2)
+    {
+        return GEOSPreparedCovers_r(handle, pg1, g2);
+    }
+
+    char
+    GEOSPreparedCrosses(const geos::geom::prep::PreparedGeometry* pg1, const Geometry* g2)
+    {
+        return GEOSPreparedCrosses_r(handle, pg1, g2);
+    }
+
+    char
+    GEOSPreparedDisjoint(const geos::geom::prep::PreparedGeometry* pg1, const Geometry* g2)
+    {
+        return GEOSPreparedDisjoint_r(handle, pg1, g2);
+    }
+
+    char
+    GEOSPreparedIntersects(const geos::geom::prep::PreparedGeometry* pg1, const Geometry* g2)
+    {
+        return GEOSPreparedIntersects_r(handle, pg1, g2);
+    }
+
+    char
+    GEOSPreparedOverlaps(const geos::geom::prep::PreparedGeometry* pg1, const Geometry* g2)
+    {
+        return GEOSPreparedOverlaps_r(handle, pg1, g2);
+    }
+
+    char
+    GEOSPreparedTouches(const geos::geom::prep::PreparedGeometry* pg1, const Geometry* g2)
+    {
+        return GEOSPreparedTouches_r(handle, pg1, g2);
+    }
+
+    char
+    GEOSPreparedWithin(const geos::geom::prep::PreparedGeometry* pg1, const Geometry* g2)
+    {
+        return GEOSPreparedWithin_r(handle, pg1, g2);
+    }
+
+    STRtree*
+    GEOSSTRtree_create(size_t nodeCapacity)
+    {
+        return GEOSSTRtree_create_r(handle, nodeCapacity);
+    }
+
+    void
+    GEOSSTRtree_insert(geos::index::strtree::STRtree* tree,
+                       const geos::geom::Geometry* g,
+                       void* item)
+    {
+        GEOSSTRtree_insert_r(handle, tree, g, item);
+    }
+
+    void
+    GEOSSTRtree_query(geos::index::strtree::STRtree* tree,
+                      const geos::geom::Geometry* g,
+                      GEOSQueryCallback cb,
+                      void* userdata)
+    {
+        GEOSSTRtree_query_r(handle, tree, g, cb, userdata);
+    }
+
+    const GEOSGeometry*
+    GEOSSTRtree_nearest(geos::index::strtree::STRtree* tree,
+                        const geos::geom::Geometry* g)
+    {
+        return GEOSSTRtree_nearest_r(handle, tree, g);
+    }
+
+    const void* GEOSSTRtree_nearest_generic(GEOSSTRtree* tree,
+                                            const void* item,
+                                            const GEOSGeometry* itemEnvelope,
+                                            GEOSDistanceCallback distancefn,
+                                            void* userdata)
+    {
+        return GEOSSTRtree_nearest_generic_r(handle, tree, item, itemEnvelope, distancefn, userdata);
+    }
+
+    void
+    GEOSSTRtree_iterate(geos::index::strtree::STRtree* tree,
+                        GEOSQueryCallback callback,
+                        void* userdata)
+    {
+        GEOSSTRtree_iterate_r(handle, tree, callback, userdata);
+    }
+
+    char
+    GEOSSTRtree_remove(geos::index::strtree::STRtree* tree,
+                       const geos::geom::Geometry* g,
+                       void* item)
+    {
+        return GEOSSTRtree_remove_r(handle, tree, g, item);
+    }
+
+    void
+    GEOSSTRtree_destroy(geos::index::strtree::STRtree* tree)
+    {
+        GEOSSTRtree_destroy_r(handle, tree);
+    }
+
+    double
+    GEOSProject(const geos::geom::Geometry* g,
+                const geos::geom::Geometry* p)
+    {
+        return GEOSProject_r(handle, g, p);
+    }
+
+    geos::geom::Geometry*
+    GEOSInterpolate(const geos::geom::Geometry* g,
+                    double d)
+    {
+        return GEOSInterpolate_r(handle, g, d);
+    }
+
+    double
+    GEOSProjectNormalized(const geos::geom::Geometry* g,
+                          const geos::geom::Geometry* p)
+    {
+        return GEOSProjectNormalized_r(handle, g, p);
+    }
+
+    geos::geom::Geometry*
+    GEOSInterpolateNormalized(const geos::geom::Geometry* g,
+                              double d)
+    {
+        return GEOSInterpolateNormalized_r(handle, g, d);
+    }
+
+    geos::geom::Geometry*
+    GEOSGeom_extractUniquePoints(const geos::geom::Geometry* g)
+    {
+        return GEOSGeom_extractUniquePoints_r(handle, g);
+    }
+
+    geos::geom::Geometry*
+    GEOSGeom_createEmptyCollection(int type)
+    {
+        return GEOSGeom_createEmptyCollection_r(handle, type);
+    }
+
+    geos::geom::Geometry*
+    GEOSGeom_createEmptyPoint()
+    {
+        return GEOSGeom_createEmptyPoint_r(handle);
+    }
+
+    geos::geom::Geometry*
+    GEOSGeom_createEmptyLineString()
+    {
+        return GEOSGeom_createEmptyLineString_r(handle);
+    }
+
+    geos::geom::Geometry*
+    GEOSGeom_createEmptyPolygon()
+    {
+        return GEOSGeom_createEmptyPolygon_r(handle);
+    }
+
+    int
+    GEOSOrientationIndex(double Ax, double Ay, double Bx, double By,
+                         double Px, double Py)
+    {
+        return GEOSOrientationIndex_r(handle, Ax, Ay, Bx, By, Px, Py);
+    }
+
+    GEOSGeometry*
+    GEOSSharedPaths(const GEOSGeometry* g1, const GEOSGeometry* g2)
+    {
+        return GEOSSharedPaths_r(handle, g1, g2);
+    }
+
+    GEOSGeometry*
+    GEOSSnap(const GEOSGeometry* g1, const GEOSGeometry* g2, double tolerance)
+    {
+        return GEOSSnap_r(handle, g1, g2, tolerance);
+    }
+
+    GEOSBufferParams*
+    GEOSBufferParams_create()
+    {
+        return GEOSBufferParams_create_r(handle);
+    }
+
+    void
+    GEOSBufferParams_destroy(GEOSBufferParams* p)
+    {
+        return GEOSBufferParams_destroy_r(handle, p);
+    }
+
+    int
+    GEOSBufferParams_setEndCapStyle(GEOSBufferParams* p, int style)
+    {
+        return GEOSBufferParams_setEndCapStyle_r(handle, p, style);
+    }
+
+    int
+    GEOSBufferParams_setJoinStyle(GEOSBufferParams* p, int joinStyle)
+    {
+        return GEOSBufferParams_setJoinStyle_r(handle, p, joinStyle);
+    }
+
+    int
+    GEOSBufferParams_setMitreLimit(GEOSBufferParams* p, double l)
+    {
+        return GEOSBufferParams_setMitreLimit_r(handle, p, l);
+    }
+
+    int
+    GEOSBufferParams_setQuadrantSegments(GEOSBufferParams* p, int joinStyle)
+    {
+        return GEOSBufferParams_setQuadrantSegments_r(handle, p, joinStyle);
+    }
+
+    int
+    GEOSBufferParams_setSingleSided(GEOSBufferParams* p, int singleSided)
+    {
+        return GEOSBufferParams_setSingleSided_r(handle, p, singleSided);
+    }
+
+    Geometry*
+    GEOSBufferWithParams(const Geometry* g, const GEOSBufferParams* p, double w)
+    {
+        return GEOSBufferWithParams_r(handle, g, p, w);
+    }
+
+    Geometry*
+    GEOSDelaunayTriangulation(const Geometry* g, double tolerance, int onlyEdges)
+    {
+        return GEOSDelaunayTriangulation_r(handle, g, tolerance, onlyEdges);
+    }
+
+    Geometry*
+    GEOSVoronoiDiagram(const Geometry* g, const Geometry* env, double tolerance, int onlyEdges)
+    {
+        return GEOSVoronoiDiagram_r(handle, g, env, tolerance, onlyEdges);
+    }
+
+    int
+    GEOSSegmentIntersection(double ax0, double ay0, double ax1, double ay1,
+                            double bx0, double by0, double bx1, double by1,
+                            double* cx, double* cy)
+    {
+        return GEOSSegmentIntersection_r(handle,
+                                         ax0, ay0, ax1, ay1,
+                                         bx0, by0, bx1, by1,
+                                         cx, cy);
+    }
 
 } /* extern "C" */
diff --git a/capi/geos_ts_c.cpp b/capi/geos_ts_c.cpp
index 7b69c46..ca0625a 100644
--- a/capi/geos_ts_c.cpp
+++ b/capi/geos_ts_c.cpp
@@ -152,37 +152,36 @@ using geos::algorithm::distance::DiscreteFrechetDistance;
 
 typedef std::unique_ptr<Geometry> GeomPtr;
 
-typedef struct GEOSContextHandle_HS
-{
-    const GeometryFactory *geomFactory;
+typedef struct GEOSContextHandle_HS {
+    const GeometryFactory* geomFactory;
     char msgBuffer[1024];
     GEOSMessageHandler noticeMessageOld;
     GEOSMessageHandler_r noticeMessageNew;
-    void *noticeData;
+    void* noticeData;
     GEOSMessageHandler errorMessageOld;
     GEOSMessageHandler_r errorMessageNew;
-    void *errorData;
+    void* errorData;
     int WKBOutputDims;
     int WKBByteOrder;
     int initialized;
 
     GEOSContextHandle_HS()
-      :
-      geomFactory(0),
-      noticeMessageOld(0),
-      noticeMessageNew(0),
-      noticeData(0),
-      errorMessageOld(0),
-      errorMessageNew(0),
-      errorData(0)
-    {
-      memset(msgBuffer, 0, sizeof(msgBuffer));
-      geomFactory = GeometryFactory::getDefaultInstance();
-      WKBOutputDims = 2;
-      WKBByteOrder = getMachineByteOrder();
-      setNoticeHandler(NULL);
-      setErrorHandler(NULL);
-      initialized = 1;
+        :
+        geomFactory(0),
+        noticeMessageOld(0),
+        noticeMessageNew(0),
+        noticeData(0),
+        errorMessageOld(0),
+        errorMessageNew(0),
+        errorData(0)
+    {
+        memset(msgBuffer, 0, sizeof(msgBuffer));
+        geomFactory = GeometryFactory::getDefaultInstance();
+        WKBOutputDims = 2;
+        WKBByteOrder = getMachineByteOrder();
+        setNoticeHandler(NULL);
+        setErrorHandler(NULL);
+        initialized = 1;
     }
 
     GEOSMessageHandler
@@ -208,7 +207,8 @@ typedef struct GEOSContextHandle_HS
     }
 
     GEOSMessageHandler_r
-    setNoticeHandler(GEOSMessageHandler_r nf, void *userData) {
+    setNoticeHandler(GEOSMessageHandler_r nf, void* userData)
+    {
         GEOSMessageHandler_r f = noticeMessageNew;
         noticeMessageOld = NULL;
         noticeMessageNew = nf;
@@ -218,7 +218,7 @@ typedef struct GEOSContextHandle_HS
     }
 
     GEOSMessageHandler_r
-    setErrorHandler(GEOSMessageHandler_r ef, void *userData)
+    setErrorHandler(GEOSMessageHandler_r ef, void* userData)
     {
         GEOSMessageHandler_r f = errorMessageNew;
         errorMessageOld = NULL;
@@ -231,43 +231,45 @@ typedef struct GEOSContextHandle_HS
     void
     NOTICE_MESSAGE(string fmt, ...)
     {
-      if (NULL == noticeMessageOld && NULL == noticeMessageNew) {
-        return;
-      }
-
-      va_list args;
-      va_start(args, fmt);
-      int result = vsnprintf(msgBuffer, sizeof(msgBuffer) - 1, fmt.c_str(), args);
-      va_end(args);
+        if(NULL == noticeMessageOld && NULL == noticeMessageNew) {
+            return;
+        }
 
-      if (result > 0) {
-        if (noticeMessageOld) {
-          noticeMessageOld("%s", msgBuffer);
-        } else {
-          noticeMessageNew(msgBuffer, noticeData);
+        va_list args;
+        va_start(args, fmt);
+        int result = vsnprintf(msgBuffer, sizeof(msgBuffer) - 1, fmt.c_str(), args);
+        va_end(args);
+
+        if(result > 0) {
+            if(noticeMessageOld) {
+                noticeMessageOld("%s", msgBuffer);
+            }
+            else {
+                noticeMessageNew(msgBuffer, noticeData);
+            }
         }
-      }
     }
 
     void
     ERROR_MESSAGE(string fmt, ...)
     {
-      if (NULL == errorMessageOld && NULL == errorMessageNew) {
-        return;
-      }
-
-      va_list args;
-      va_start(args, fmt);
-      int result = vsnprintf(msgBuffer, sizeof(msgBuffer) - 1, fmt.c_str(), args);
-      va_end(args);
+        if(NULL == errorMessageOld && NULL == errorMessageNew) {
+            return;
+        }
 
-      if (result > 0) {
-        if (errorMessageOld) {
-          errorMessageOld("%s", msgBuffer);
-        } else {
-          errorMessageNew(msgBuffer, errorData);
+        va_list args;
+        va_start(args, fmt);
+        int result = vsnprintf(msgBuffer, sizeof(msgBuffer) - 1, fmt.c_str(), args);
+        va_end(args);
+
+        if(result > 0) {
+            if(errorMessageOld) {
+                errorMessageOld("%s", msgBuffer);
+            }
+            else {
+                errorMessageNew(msgBuffer, errorData);
+            }
         }
-      }
     }
 } GEOSContextHandleInternal_t;
 
@@ -276,27 +278,31 @@ typedef struct GEOSContextHandle_HS
 // extern "C" block.
 class CAPI_ItemVisitor : public geos::index::ItemVisitor {
     GEOSQueryCallback callback;
-    void *userdata;
-  public:
-    CAPI_ItemVisitor (GEOSQueryCallback cb, void *ud)
+    void* userdata;
+public:
+    CAPI_ItemVisitor(GEOSQueryCallback cb, void* ud)
         : ItemVisitor(), callback(cb), userdata(ud) {}
-    void visitItem (void *item) override { callback(item, userdata); }
+    void
+    visitItem(void* item) override
+    {
+        callback(item, userdata);
+    }
 };
 
 
 //## PROTOTYPES #############################################
 
-extern "C" const char GEOS_DLL *GEOSjtsport();
-extern "C" char GEOS_DLL *GEOSasText(Geometry *g1);
+extern "C" const char GEOS_DLL* GEOSjtsport();
+extern "C" char GEOS_DLL* GEOSasText(Geometry* g1);
 
 
 namespace { // anonymous
 
-char* gstrdup_s(const char* str, const std::size_t size)
+char*
+gstrdup_s(const char* str, const std::size_t size)
 {
     char* out = static_cast<char*>(malloc(size + 1));
-    if (0 != out)
-    {
+    if(0 != out) {
         // as no strlen call necessary, memcpy may be faster than strcpy
         std::memcpy(out, str, size + 1);
     }
@@ -304,15 +310,15 @@ char* gstrdup_s(const char* str, const std::size_t size)
     assert(0 != out);
 
     // we haven't been checking allocation before ticket #371
-    if (0 == out)
-    {
+    if(0 == out) {
         throw(std::runtime_error("Failed to allocate memory for duplicate string"));
     }
 
     return out;
 }
 
-char* gstrdup(std::string const& str)
+char*
+gstrdup(std::string const& str)
 {
     return gstrdup_s(str.c_str(), str.size());
 }
@@ -321,589 +327,522 @@ char* gstrdup(std::string const& str)
 
 extern "C" {
 
-GEOSContextHandle_t
-initGEOS_r(GEOSMessageHandler nf, GEOSMessageHandler ef)
-{
-  GEOSContextHandle_t handle = GEOS_init_r();
+    GEOSContextHandle_t
+    initGEOS_r(GEOSMessageHandler nf, GEOSMessageHandler ef)
+    {
+        GEOSContextHandle_t handle = GEOS_init_r();
 
-  if (0 != handle) {
-      GEOSContext_setNoticeHandler_r(handle, nf);
-      GEOSContext_setErrorHandler_r(handle, ef);
-  }
+        if(0 != handle) {
+            GEOSContext_setNoticeHandler_r(handle, nf);
+            GEOSContext_setErrorHandler_r(handle, ef);
+        }
 
-  return handle;
-}
+        return handle;
+    }
 
-GEOSContextHandle_t
-GEOS_init_r()
-{
-    GEOSContextHandleInternal_t *handle = new GEOSContextHandleInternal_t();
+    GEOSContextHandle_t
+    GEOS_init_r()
+    {
+        GEOSContextHandleInternal_t* handle = new GEOSContextHandleInternal_t();
 
-    geos::util::Interrupt::cancel();
+        geos::util::Interrupt::cancel();
 
-    return static_cast<GEOSContextHandle_t>(handle);
-}
+        return static_cast<GEOSContextHandle_t>(handle);
+    }
 
-GEOSMessageHandler
-GEOSContext_setNoticeHandler_r(GEOSContextHandle_t extHandle, GEOSMessageHandler nf)
-{
-    GEOSContextHandleInternal_t *handle = 0;
-    handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
-    if ( 0 == handle->initialized )
+    GEOSMessageHandler
+    GEOSContext_setNoticeHandler_r(GEOSContextHandle_t extHandle, GEOSMessageHandler nf)
     {
-        return NULL;
-    }
+        GEOSContextHandleInternal_t* handle = 0;
+        handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
+        if(0 == handle->initialized) {
+            return NULL;
+        }
 
-    return handle->setNoticeHandler(nf);
-}
+        return handle->setNoticeHandler(nf);
+    }
 
-GEOSMessageHandler
-GEOSContext_setErrorHandler_r(GEOSContextHandle_t extHandle, GEOSMessageHandler nf)
-{
-    GEOSContextHandleInternal_t *handle = 0;
-    handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
-    if ( 0 == handle->initialized )
+    GEOSMessageHandler
+    GEOSContext_setErrorHandler_r(GEOSContextHandle_t extHandle, GEOSMessageHandler nf)
     {
-        return NULL;
-    }
+        GEOSContextHandleInternal_t* handle = 0;
+        handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
+        if(0 == handle->initialized) {
+            return NULL;
+        }
 
-    return handle->setErrorHandler(nf);
-}
+        return handle->setErrorHandler(nf);
+    }
 
-GEOSMessageHandler_r
-GEOSContext_setNoticeMessageHandler_r(GEOSContextHandle_t extHandle, GEOSMessageHandler_r nf, void *userData) {
-    GEOSContextHandleInternal_t *handle = 0;
-    handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
-    if ( 0 == handle->initialized )
+    GEOSMessageHandler_r
+    GEOSContext_setNoticeMessageHandler_r(GEOSContextHandle_t extHandle, GEOSMessageHandler_r nf, void* userData)
     {
-        return NULL;
-    }
+        GEOSContextHandleInternal_t* handle = 0;
+        handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
+        if(0 == handle->initialized) {
+            return NULL;
+        }
 
-    return handle->setNoticeHandler(nf, userData);
-}
+        return handle->setNoticeHandler(nf, userData);
+    }
 
-GEOSMessageHandler_r
-GEOSContext_setErrorMessageHandler_r(GEOSContextHandle_t extHandle, GEOSMessageHandler_r ef, void *userData)
-{
-    GEOSContextHandleInternal_t *handle = 0;
-    handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
-    if ( 0 == handle->initialized )
+    GEOSMessageHandler_r
+    GEOSContext_setErrorMessageHandler_r(GEOSContextHandle_t extHandle, GEOSMessageHandler_r ef, void* userData)
     {
-        return NULL;
-    }
+        GEOSContextHandleInternal_t* handle = 0;
+        handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
+        if(0 == handle->initialized) {
+            return NULL;
+        }
 
-    return handle->setErrorHandler(ef, userData);
-}
+        return handle->setErrorHandler(ef, userData);
+    }
 
-void
-finishGEOS_r(GEOSContextHandle_t extHandle)
-{
-    // Fix up freeing handle w.r.t. malloc above
-    delete extHandle;
-    extHandle = NULL;
-}
+    void
+    finishGEOS_r(GEOSContextHandle_t extHandle)
+    {
+        // Fix up freeing handle w.r.t. malloc above
+        delete extHandle;
+        extHandle = NULL;
+    }
 
-void
-GEOS_finish_r(GEOSContextHandle_t extHandle)
-{
-    finishGEOS_r(extHandle);
-}
+    void
+    GEOS_finish_r(GEOSContextHandle_t extHandle)
+    {
+        finishGEOS_r(extHandle);
+    }
 
-void
-GEOSFree_r (GEOSContextHandle_t extHandle, void* buffer)
-{
-    assert(0 != extHandle);
+    void
+    GEOSFree_r(GEOSContextHandle_t extHandle, void* buffer)
+    {
+        assert(0 != extHandle);
 
-    free(buffer);
-}
+        free(buffer);
+    }
 
 //-----------------------------------------------------------
 // relate()-related functions
 //  return 0 = false, 1 = true, 2 = error occurred
 //-----------------------------------------------------------
 
-char
-GEOSDisjoint_r(GEOSContextHandle_t extHandle, const Geometry *g1, const Geometry *g2)
-{
-    if ( 0 == extHandle )
-    {
-        return 2;
-    }
-
-    GEOSContextHandleInternal_t *handle = 0;
-    handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
-    if ( handle->initialized == 0 )
+    char
+    GEOSDisjoint_r(GEOSContextHandle_t extHandle, const Geometry* g1, const Geometry* g2)
     {
-        return 2;
-    }
+        if(0 == extHandle) {
+            return 2;
+        }
 
-    try
-    {
-        bool result = g1->disjoint(g2);
-        return result;
-    }
+        GEOSContextHandleInternal_t* handle = 0;
+        handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
+        if(handle->initialized == 0) {
+            return 2;
+        }
 
-    // TODO: mloskot is going to replace these double-catch block
-    // with a macro to remove redundant code in this and
-    // following functions.
-    catch (const std::exception &e)
-    {
-        handle->ERROR_MESSAGE("%s", e.what());
-    }
-    catch (...)
-    {
-        handle->ERROR_MESSAGE("Unknown exception thrown");
-    }
+        try {
+            bool result = g1->disjoint(g2);
+            return result;
+        }
 
-    return 2;
-}
+        // TODO: mloskot is going to replace these double-catch block
+        // with a macro to remove redundant code in this and
+        // following functions.
+        catch(const std::exception& e) {
+            handle->ERROR_MESSAGE("%s", e.what());
+        }
+        catch(...) {
+            handle->ERROR_MESSAGE("Unknown exception thrown");
+        }
 
-char
-GEOSTouches_r(GEOSContextHandle_t extHandle, const Geometry *g1, const Geometry *g2)
-{
-    if ( 0 == extHandle )
-    {
         return 2;
     }
 
-    GEOSContextHandleInternal_t *handle = 0;
-    handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
-    if ( 0 == handle->initialized )
+    char
+    GEOSTouches_r(GEOSContextHandle_t extHandle, const Geometry* g1, const Geometry* g2)
     {
-        return 2;
-    }
+        if(0 == extHandle) {
+            return 2;
+        }
 
-    try
-    {
-        bool result = g1->touches(g2);
-        return result;
-    }
-    catch (const std::exception &e)
-    {
-        handle->ERROR_MESSAGE("%s", e.what());
-    }
-    catch (...)
-    {
-        handle->ERROR_MESSAGE("Unknown exception thrown");
-    }
+        GEOSContextHandleInternal_t* handle = 0;
+        handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
+        if(0 == handle->initialized) {
+            return 2;
+        }
 
-    return 2;
-}
+        try {
+            bool result = g1->touches(g2);
+            return result;
+        }
+        catch(const std::exception& e) {
+            handle->ERROR_MESSAGE("%s", e.what());
+        }
+        catch(...) {
+            handle->ERROR_MESSAGE("Unknown exception thrown");
+        }
 
-char
-GEOSIntersects_r(GEOSContextHandle_t extHandle, const Geometry *g1, const Geometry *g2)
-{
-    if ( 0 == extHandle )
-    {
         return 2;
     }
 
-    GEOSContextHandleInternal_t *handle = 0;
-    handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
-    if ( 0 == handle->initialized )
+    char
+    GEOSIntersects_r(GEOSContextHandle_t extHandle, const Geometry* g1, const Geometry* g2)
     {
-        return 2;
-    }
+        if(0 == extHandle) {
+            return 2;
+        }
 
-    try
-    {
-        bool result = g1->intersects(g2);
-        return result;
-    }
-    catch (const std::exception &e)
-    {
-        handle->ERROR_MESSAGE("%s", e.what());
-    }
-    catch (...)
-    {
-        handle->ERROR_MESSAGE("Unknown exception thrown");
-    }
+        GEOSContextHandleInternal_t* handle = 0;
+        handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
+        if(0 == handle->initialized) {
+            return 2;
+        }
 
-    return 2;
-}
+        try {
+            bool result = g1->intersects(g2);
+            return result;
+        }
+        catch(const std::exception& e) {
+            handle->ERROR_MESSAGE("%s", e.what());
+        }
+        catch(...) {
+            handle->ERROR_MESSAGE("Unknown exception thrown");
+        }
 
-char
-GEOSCrosses_r(GEOSContextHandle_t extHandle, const Geometry *g1, const Geometry *g2)
-{
-    if ( 0 == extHandle )
-    {
         return 2;
     }
 
-    GEOSContextHandleInternal_t *handle = 0;
-    handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
-    if ( 0 == handle->initialized )
+    char
+    GEOSCrosses_r(GEOSContextHandle_t extHandle, const Geometry* g1, const Geometry* g2)
     {
-        return 2;
-    }
+        if(0 == extHandle) {
+            return 2;
+        }
 
-    try
-    {
-        bool result = g1->crosses(g2);
-        return result;
-    }
-    catch (const std::exception &e)
-    {
-        handle->ERROR_MESSAGE("%s", e.what());
-    }
-    catch (...)
-    {
-        handle->ERROR_MESSAGE("Unknown exception thrown");
-    }
+        GEOSContextHandleInternal_t* handle = 0;
+        handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
+        if(0 == handle->initialized) {
+            return 2;
+        }
 
-    return 2;
-}
+        try {
+            bool result = g1->crosses(g2);
+            return result;
+        }
+        catch(const std::exception& e) {
+            handle->ERROR_MESSAGE("%s", e.what());
+        }
+        catch(...) {
+            handle->ERROR_MESSAGE("Unknown exception thrown");
+        }
 
-char
-GEOSWithin_r(GEOSContextHandle_t extHandle, const Geometry *g1, const Geometry *g2)
-{
-    if ( 0 == extHandle )
-    {
         return 2;
     }
 
-    GEOSContextHandleInternal_t *handle = 0;
-    handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
-    if ( 0 == handle->initialized )
+    char
+    GEOSWithin_r(GEOSContextHandle_t extHandle, const Geometry* g1, const Geometry* g2)
     {
-        return 2;
-    }
+        if(0 == extHandle) {
+            return 2;
+        }
 
-    try
-    {
-        bool result = g1->within(g2);
-        return result;
-    }
-    catch (const std::exception &e)
-    {
-        handle->ERROR_MESSAGE("%s", e.what());
-    }
-    catch (...)
-    {
-        handle->ERROR_MESSAGE("Unknown exception thrown");
-    }
+        GEOSContextHandleInternal_t* handle = 0;
+        handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
+        if(0 == handle->initialized) {
+            return 2;
+        }
 
-    return 2;
-}
+        try {
+            bool result = g1->within(g2);
+            return result;
+        }
+        catch(const std::exception& e) {
+            handle->ERROR_MESSAGE("%s", e.what());
+        }
+        catch(...) {
+            handle->ERROR_MESSAGE("Unknown exception thrown");
+        }
+
+        return 2;
+    }
 
 // call g1->contains(g2)
 // returns 0 = false
 //         1 = true
 //         2 = error was trapped
-char
-GEOSContains_r(GEOSContextHandle_t extHandle, const Geometry *g1, const Geometry *g2)
-{
-    if ( 0 == extHandle )
+    char
+    GEOSContains_r(GEOSContextHandle_t extHandle, const Geometry* g1, const Geometry* g2)
     {
-        return 2;
-    }
+        if(0 == extHandle) {
+            return 2;
+        }
+
+        GEOSContextHandleInternal_t* handle = 0;
+        handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
+        if(0 == handle->initialized) {
+            return 2;
+        }
+
+        try {
+            bool result = g1->contains(g2);
+            return result;
+        }
+        catch(const std::exception& e) {
+            handle->ERROR_MESSAGE("%s", e.what());
+        }
+        catch(...) {
+            handle->ERROR_MESSAGE("Unknown exception thrown");
+        }
 
-    GEOSContextHandleInternal_t *handle = 0;
-    handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
-    if ( 0 == handle->initialized )
-    {
         return 2;
     }
 
-    try
-    {
-        bool result = g1->contains(g2);
-        return result;
-    }
-    catch (const std::exception &e)
-    {
-        handle->ERROR_MESSAGE("%s", e.what());
-    }
-    catch (...)
+    char
+    GEOSOverlaps_r(GEOSContextHandle_t extHandle, const Geometry* g1, const Geometry* g2)
     {
-        handle->ERROR_MESSAGE("Unknown exception thrown");
-    }
+        if(0 == extHandle) {
+            return 2;
+        }
 
-    return 2;
-}
+        GEOSContextHandleInternal_t* handle = 0;
+        handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
+        if(0 == handle->initialized) {
+            return 2;
+        }
 
-char
-GEOSOverlaps_r(GEOSContextHandle_t extHandle, const Geometry *g1, const Geometry *g2)
-{
-    if ( 0 == extHandle )
-    {
-        return 2;
-    }
+        try {
+            bool result = g1->overlaps(g2);
+            return result;
+        }
+        catch(const std::exception& e) {
+            handle->ERROR_MESSAGE("%s", e.what());
+        }
+        catch(...) {
+            handle->ERROR_MESSAGE("Unknown exception thrown");
+        }
 
-    GEOSContextHandleInternal_t *handle = 0;
-    handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
-    if ( 0 == handle->initialized )
-    {
         return 2;
     }
 
-    try
+    char
+    GEOSCovers_r(GEOSContextHandle_t extHandle, const Geometry* g1, const Geometry* g2)
     {
-        bool result = g1->overlaps(g2);
-        return result;
-    }
-    catch (const std::exception &e)
-    {
-        handle->ERROR_MESSAGE("%s", e.what());
-    }
-    catch (...)
-    {
-        handle->ERROR_MESSAGE("Unknown exception thrown");
-    }
+        if(0 == extHandle) {
+            return 2;
+        }
 
-    return 2;
-}
+        GEOSContextHandleInternal_t* handle = 0;
+        handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
+        if(0 == handle->initialized) {
+            return 2;
+        }
 
-char
-GEOSCovers_r(GEOSContextHandle_t extHandle, const Geometry *g1, const Geometry *g2)
-{
-    if ( 0 == extHandle )
-    {
-        return 2;
-    }
+        try {
+            bool result = g1->covers(g2);
+            return result;
+        }
+        catch(const std::exception& e) {
+            handle->ERROR_MESSAGE("%s", e.what());
+        }
+        catch(...) {
+            handle->ERROR_MESSAGE("Unknown exception thrown");
+        }
 
-    GEOSContextHandleInternal_t *handle = 0;
-    handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
-    if ( 0 == handle->initialized )
-    {
         return 2;
     }
 
-    try
-    {
-        bool result = g1->covers(g2);
-        return result;
-    }
-    catch (const std::exception &e)
-    {
-        handle->ERROR_MESSAGE("%s", e.what());
-    }
-    catch (...)
+    char
+    GEOSCoveredBy_r(GEOSContextHandle_t extHandle, const Geometry* g1, const Geometry* g2)
     {
-        handle->ERROR_MESSAGE("Unknown exception thrown");
-    }
+        if(0 == extHandle) {
+            return 2;
+        }
 
-    return 2;
-}
+        GEOSContextHandleInternal_t* handle = 0;
+        handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
+        if(0 == handle->initialized) {
+            return 2;
+        }
 
-char
-GEOSCoveredBy_r(GEOSContextHandle_t extHandle, const Geometry *g1, const Geometry *g2)
-{
-    if ( 0 == extHandle )
-    {
-        return 2;
-    }
+        try {
+            bool result = g1->coveredBy(g2);
+            return result;
+        }
+        catch(const std::exception& e) {
+            handle->ERROR_MESSAGE("%s", e.what());
+        }
+        catch(...) {
+            handle->ERROR_MESSAGE("Unknown exception thrown");
+        }
 
-    GEOSContextHandleInternal_t *handle = 0;
-    handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
-    if ( 0 == handle->initialized )
-    {
         return 2;
     }
 
-    try
-    {
-        bool result = g1->coveredBy(g2);
-        return result;
-    }
-    catch (const std::exception &e)
-    {
-        handle->ERROR_MESSAGE("%s", e.what());
-    }
-    catch (...)
-    {
-        handle->ERROR_MESSAGE("Unknown exception thrown");
-    }
-
-    return 2;
-}
-
 
 //-------------------------------------------------------------------
 // low-level relate functions
 //------------------------------------------------------------------
 
-char
-GEOSRelatePattern_r(GEOSContextHandle_t extHandle, const Geometry *g1, const Geometry *g2, const char *pat)
-{
-    if ( 0 == extHandle )
+    char
+    GEOSRelatePattern_r(GEOSContextHandle_t extHandle, const Geometry* g1, const Geometry* g2, const char* pat)
     {
-        return 2;
-    }
-
-    GEOSContextHandleInternal_t *handle = 0;
-    handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
-    if ( 0 == handle->initialized )
-    {
-        return 2;
-    }
-
-    try
-    {
-        std::string s(pat);
-        bool result = g1->relate(g2, s);
-        return result;
-    }
-    catch (const std::exception &e)
-    {
-        handle->ERROR_MESSAGE("%s", e.what());
-    }
-    catch (...)
-    {
-        handle->ERROR_MESSAGE("Unknown exception thrown");
-    }
+        if(0 == extHandle) {
+            return 2;
+        }
 
-    return 2;
-}
+        GEOSContextHandleInternal_t* handle = 0;
+        handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
+        if(0 == handle->initialized) {
+            return 2;
+        }
 
-char
-GEOSRelatePatternMatch_r(GEOSContextHandle_t extHandle, const char *mat,
-                           const char *pat)
-{
-    if ( 0 == extHandle )
-    {
-        return 2;
-    }
+        try {
+            std::string s(pat);
+            bool result = g1->relate(g2, s);
+            return result;
+        }
+        catch(const std::exception& e) {
+            handle->ERROR_MESSAGE("%s", e.what());
+        }
+        catch(...) {
+            handle->ERROR_MESSAGE("Unknown exception thrown");
+        }
 
-    GEOSContextHandleInternal_t *handle = 0;
-    handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
-    if ( 0 == handle->initialized )
-    {
         return 2;
     }
 
-    try
+    char
+    GEOSRelatePatternMatch_r(GEOSContextHandle_t extHandle, const char* mat,
+                             const char* pat)
     {
-        using geos::geom::IntersectionMatrix;
+        if(0 == extHandle) {
+            return 2;
+        }
 
-        std::string m(mat);
-        std::string p(pat);
-        IntersectionMatrix im(m);
+        GEOSContextHandleInternal_t* handle = 0;
+        handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
+        if(0 == handle->initialized) {
+            return 2;
+        }
 
-        bool result = im.matches(p);
-        return result;
-    }
-    catch (const std::exception &e)
-    {
-        handle->ERROR_MESSAGE("%s", e.what());
-    }
-    catch (...)
-    {
-        handle->ERROR_MESSAGE("Unknown exception thrown");
-    }
+        try {
+            using geos::geom::IntersectionMatrix;
 
-    return 2;
-}
+            std::string m(mat);
+            std::string p(pat);
+            IntersectionMatrix im(m);
 
-char *
-GEOSRelate_r(GEOSContextHandle_t extHandle, const Geometry *g1, const Geometry *g2)
-{
-    if ( 0 == extHandle )
-    {
-        return NULL;
-    }
+            bool result = im.matches(p);
+            return result;
+        }
+        catch(const std::exception& e) {
+            handle->ERROR_MESSAGE("%s", e.what());
+        }
+        catch(...) {
+            handle->ERROR_MESSAGE("Unknown exception thrown");
+        }
 
-    GEOSContextHandleInternal_t *handle = 0;
-    handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
-    if ( 0 == handle->initialized )
-    {
-        return NULL;
+        return 2;
     }
 
-    try
+    char*
+    GEOSRelate_r(GEOSContextHandle_t extHandle, const Geometry* g1, const Geometry* g2)
     {
-        using geos::geom::IntersectionMatrix;
+        if(0 == extHandle) {
+            return NULL;
+        }
 
-        IntersectionMatrix* im = g1->relate(g2);
-        if (0 == im)
-        {
-            return 0;
+        GEOSContextHandleInternal_t* handle = 0;
+        handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
+        if(0 == handle->initialized) {
+            return NULL;
         }
 
-        char *result = gstrdup(im->toString());
+        try {
+            using geos::geom::IntersectionMatrix;
 
-        delete im;
-        im = 0;
+            IntersectionMatrix* im = g1->relate(g2);
+            if(0 == im) {
+                return 0;
+            }
 
-        return result;
-    }
-    catch (const std::exception &e)
-    {
-        handle->ERROR_MESSAGE("%s", e.what());
-    }
-    catch (...)
-    {
-        handle->ERROR_MESSAGE("Unknown exception thrown");
-    }
+            char* result = gstrdup(im->toString());
 
-    return NULL;
-}
+            delete im;
+            im = 0;
+
+            return result;
+        }
+        catch(const std::exception& e) {
+            handle->ERROR_MESSAGE("%s", e.what());
+        }
+        catch(...) {
+            handle->ERROR_MESSAGE("Unknown exception thrown");
+        }
 
-char *
-GEOSRelateBoundaryNodeRule_r(GEOSContextHandle_t extHandle, const Geometry *g1, const Geometry *g2, int bnr)
-{
-    if ( 0 == extHandle )
-    {
         return NULL;
     }
 
-    GEOSContextHandleInternal_t *handle = 0;
-    handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
-    if ( 0 == handle->initialized )
+    char*
+    GEOSRelateBoundaryNodeRule_r(GEOSContextHandle_t extHandle, const Geometry* g1, const Geometry* g2, int bnr)
     {
-        return NULL;
-    }
+        if(0 == extHandle) {
+            return NULL;
+        }
 
-    try
-    {
-        using geos::operation::relate::RelateOp;
-        using geos::geom::IntersectionMatrix;
-        using geos::algorithm::BoundaryNodeRule;
-
-        IntersectionMatrix* im;
-        switch (bnr) {
-          case GEOSRELATE_BNR_MOD2: /* same as OGC */
-            im = RelateOp::relate(g1, g2,
-                BoundaryNodeRule::getBoundaryRuleMod2());
-            break;
-          case GEOSRELATE_BNR_ENDPOINT:
-            im = RelateOp::relate(g1, g2,
-                BoundaryNodeRule::getBoundaryEndPoint());
-            break;
-          case GEOSRELATE_BNR_MULTIVALENT_ENDPOINT:
-            im = RelateOp::relate(g1, g2,
-                BoundaryNodeRule::getBoundaryMultivalentEndPoint());
-            break;
-          case GEOSRELATE_BNR_MONOVALENT_ENDPOINT:
-            im = RelateOp::relate(g1, g2,
-                BoundaryNodeRule::getBoundaryMonovalentEndPoint());
-            break;
-          default:
-            handle->ERROR_MESSAGE("Invalid boundary node rule %d", bnr);
-            return 0;
-            break;
+        GEOSContextHandleInternal_t* handle = 0;
+        handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
+        if(0 == handle->initialized) {
+            return NULL;
         }
 
-        if (0 == im) return 0;
+        try {
+            using geos::operation::relate::RelateOp;
+            using geos::geom::IntersectionMatrix;
+            using geos::algorithm::BoundaryNodeRule;
+
+            IntersectionMatrix* im;
+            switch(bnr) {
+            case GEOSRELATE_BNR_MOD2: /* same as OGC */
+                im = RelateOp::relate(g1, g2,
+                                      BoundaryNodeRule::getBoundaryRuleMod2());
+                break;
+            case GEOSRELATE_BNR_ENDPOINT:
+                im = RelateOp::relate(g1, g2,
+                                      BoundaryNodeRule::getBoundaryEndPoint());
+                break;
+            case GEOSRELATE_BNR_MULTIVALENT_ENDPOINT:
+                im = RelateOp::relate(g1, g2,
+                                      BoundaryNodeRule::getBoundaryMultivalentEndPoint());
+                break;
+            case GEOSRELATE_BNR_MONOVALENT_ENDPOINT:
+                im = RelateOp::relate(g1, g2,
+                                      BoundaryNodeRule::getBoundaryMonovalentEndPoint());
+                break;
+            default:
+                handle->ERROR_MESSAGE("Invalid boundary node rule %d", bnr);
+                return 0;
+                break;
+            }
+
+            if(0 == im) {
+                return 0;
+            }
 
-        char *result = gstrdup(im->toString());
+            char* result = gstrdup(im->toString());
 
-        delete im;
-        im = 0;
+            delete im;
+            im = 0;
 
-        return result;
-    }
-    catch (const std::exception &e)
-    {
-        handle->ERROR_MESSAGE("%s", e.what());
-    }
-    catch (...)
-    {
-        handle->ERROR_MESSAGE("Unknown exception thrown");
-    }
+            return result;
+        }
+        catch(const std::exception& e) {
+            handle->ERROR_MESSAGE("%s", e.what());
+        }
+        catch(...) {
+            handle->ERROR_MESSAGE("Unknown exception thrown");
+        }
 
-    return NULL;
-}
+        return NULL;
+    }
 
 
 
@@ -912,2482 +851,2156 @@ GEOSRelateBoundaryNodeRule_r(GEOSContextHandle_t extHandle, const Geometry *g1,
 //-----------------------------------------------------------------
 
 
-char
-GEOSisValid_r(GEOSContextHandle_t extHandle, const Geometry *g1)
-{
-    if ( 0 == extHandle )
-    {
-        return 2;
-    }
-
-    GEOSContextHandleInternal_t *handle = 0;
-    handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
-    if ( 0 == handle->initialized )
+    char
+    GEOSisValid_r(GEOSContextHandle_t extHandle, const Geometry* g1)
     {
-        return 2;
-    }
+        if(0 == extHandle) {
+            return 2;
+        }
 
-    try
-    {
-        using geos::operation::valid::IsValidOp;
-        using geos::operation::valid::TopologyValidationError;
+        GEOSContextHandleInternal_t* handle = 0;
+        handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
+        if(0 == handle->initialized) {
+            return 2;
+        }
 
-        IsValidOp ivo(g1);
-        TopologyValidationError *err = ivo.getValidationError();
-        if ( err )
-        {
-           handle->NOTICE_MESSAGE("%s", err->toString().c_str());
-           return 0;
+        try {
+            using geos::operation::valid::IsValidOp;
+            using geos::operation::valid::TopologyValidationError;
+
+            IsValidOp ivo(g1);
+            TopologyValidationError* err = ivo.getValidationError();
+            if(err) {
+                handle->NOTICE_MESSAGE("%s", err->toString().c_str());
+                return 0;
+            }
+            else {
+                return 1;
+            }
         }
-        else
-        {
-           return 1;
+        catch(const std::exception& e) {
+            handle->ERROR_MESSAGE("%s", e.what());
+        }
+        catch(...) {
+            handle->ERROR_MESSAGE("Unknown exception thrown");
         }
-    }
-    catch (const std::exception &e)
-    {
-        handle->ERROR_MESSAGE("%s", e.what());
-    }
-    catch (...)
-    {
-        handle->ERROR_MESSAGE("Unknown exception thrown");
-    }
-
-    return 2;
-}
-
-char *
-GEOSisValidReason_r(GEOSContextHandle_t extHandle, const Geometry *g1)
-{
-    if ( 0 == extHandle )
-    {
-        return NULL;
-    }
 
-    GEOSContextHandleInternal_t *handle = 0;
-    handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
-    if ( 0 == handle->initialized )
-    {
-        return NULL;
+        return 2;
     }
 
-    try
+    char*
+    GEOSisValidReason_r(GEOSContextHandle_t extHandle, const Geometry* g1)
     {
-        using geos::operation::valid::IsValidOp;
-        using geos::operation::valid::TopologyValidationError;
+        if(0 == extHandle) {
+            return NULL;
+        }
 
-        char* result = 0;
-        char const* const validstr = "Valid Geometry";
+        GEOSContextHandleInternal_t* handle = 0;
+        handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
+        if(0 == handle->initialized) {
+            return NULL;
+        }
 
-        IsValidOp ivo(g1);
-        TopologyValidationError *err = ivo.getValidationError();
-        if (0 != err)
-        {
-            std::ostringstream ss;
-            ss.precision(15);
-            ss << err->getCoordinate();
-            const std::string errloc = ss.str();
-            std::string errmsg(err->getMessage());
-            errmsg += "[" + errloc + "]";
-            result = gstrdup(errmsg);
-        }
-        else
-        {
-            result = gstrdup(std::string(validstr));
+        try {
+            using geos::operation::valid::IsValidOp;
+            using geos::operation::valid::TopologyValidationError;
+
+            char* result = 0;
+            char const* const validstr = "Valid Geometry";
+
+            IsValidOp ivo(g1);
+            TopologyValidationError* err = ivo.getValidationError();
+            if(0 != err) {
+                std::ostringstream ss;
+                ss.precision(15);
+                ss << err->getCoordinate();
+                const std::string errloc = ss.str();
+                std::string errmsg(err->getMessage());
+                errmsg += "[" + errloc + "]";
+                result = gstrdup(errmsg);
+            }
+            else {
+                result = gstrdup(std::string(validstr));
+            }
+
+            return result;
+        }
+        catch(const std::exception& e) {
+            handle->ERROR_MESSAGE("%s", e.what());
+        }
+        catch(...) {
+            handle->ERROR_MESSAGE("Unknown exception thrown");
         }
 
-        return result;
-    }
-    catch (const std::exception &e)
-    {
-        handle->ERROR_MESSAGE("%s", e.what());
-    }
-    catch (...)
-    {
-        handle->ERROR_MESSAGE("Unknown exception thrown");
+        return 0;
     }
 
-    return 0;
-}
-
-char
-GEOSisValidDetail_r(GEOSContextHandle_t extHandle, const Geometry *g,
-	int flags, char** reason, Geometry ** location)
-{
-    if ( 0 == extHandle )
+    char
+    GEOSisValidDetail_r(GEOSContextHandle_t extHandle, const Geometry* g,
+                        int flags, char** reason, Geometry** location)
     {
-        return 2;
-    }
+        if(0 == extHandle) {
+            return 2;
+        }
 
-    GEOSContextHandleInternal_t *handle = 0;
-    handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
-    if ( 0 == handle->initialized )
-    {
-        return 2;
-    }
+        GEOSContextHandleInternal_t* handle = 0;
+        handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
+        if(0 == handle->initialized) {
+            return 2;
+        }
 
-    try
-    {
-        using geos::operation::valid::IsValidOp;
-        using geos::operation::valid::TopologyValidationError;
+        try {
+            using geos::operation::valid::IsValidOp;
+            using geos::operation::valid::TopologyValidationError;
+
+            IsValidOp ivo(g);
+            if(flags & GEOSVALID_ALLOW_SELFTOUCHING_RING_FORMING_HOLE) {
+                ivo.setSelfTouchingRingFormingHoleValid(true);
+            }
+            TopologyValidationError* err = ivo.getValidationError();
+            if(0 != err) {
+                if(location) {
+                    *location = handle->geomFactory->createPoint(err->getCoordinate());
+                }
+                if(reason) {
+                    std::string errmsg(err->getMessage());
+                    *reason = gstrdup(errmsg);
+                }
+                return 0;
+            }
+
+            if(location) {
+                *location = 0;
+            }
+            if(reason) {
+                *reason = 0;
+            }
+            return 1; /* valid */
 
-        IsValidOp ivo(g);
-        if ( flags & GEOSVALID_ALLOW_SELFTOUCHING_RING_FORMING_HOLE ) {
-        	ivo.setSelfTouchingRingFormingHoleValid(true);
         }
-        TopologyValidationError *err = ivo.getValidationError();
-        if (0 != err)
-        {
-          if ( location ) {
-            *location = handle->geomFactory->createPoint(err->getCoordinate());
-          }
-          if ( reason ) {
-            std::string errmsg(err->getMessage());
-            *reason = gstrdup(errmsg);
-          }
-          return 0;
+        catch(const std::exception& e) {
+            handle->ERROR_MESSAGE("%s", e.what());
+        }
+        catch(...) {
+            handle->ERROR_MESSAGE("Unknown exception thrown");
         }
 
-        if ( location ) *location = 0;
-        if ( reason ) *reason = 0;
-        return 1; /* valid */
-
-    }
-    catch (const std::exception &e)
-    {
-        handle->ERROR_MESSAGE("%s", e.what());
-    }
-    catch (...)
-    {
-        handle->ERROR_MESSAGE("Unknown exception thrown");
+        return 2; /* exception */
     }
 
-    return 2; /* exception */
-}
-
 //-----------------------------------------------------------------
 // general purpose
 //-----------------------------------------------------------------
 
-char
-GEOSEquals_r(GEOSContextHandle_t extHandle, const Geometry *g1, const Geometry *g2)
-{
-    if ( 0 == extHandle )
+    char
+    GEOSEquals_r(GEOSContextHandle_t extHandle, const Geometry* g1, const Geometry* g2)
     {
-        return 2;
-    }
+        if(0 == extHandle) {
+            return 2;
+        }
+
+        GEOSContextHandleInternal_t* handle = 0;
+        handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
+        if(0 == handle->initialized) {
+            return 2;
+        }
+
+        try {
+            bool result = g1->equals(g2);
+            return result;
+        }
+        catch(const std::exception& e) {
+            handle->ERROR_MESSAGE("%s", e.what());
+        }
+        catch(...) {
+            handle->ERROR_MESSAGE("Unknown exception thrown");
+        }
 
-    GEOSContextHandleInternal_t *handle = 0;
-    handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
-    if ( 0 == handle->initialized )
-    {
         return 2;
     }
 
-    try
-    {
-        bool result = g1->equals(g2);
-        return result;
-    }
-    catch (const std::exception &e)
-    {
-        handle->ERROR_MESSAGE("%s", e.what());
-    }
-    catch (...)
+    char
+    GEOSEqualsExact_r(GEOSContextHandle_t extHandle, const Geometry* g1, const Geometry* g2, double tolerance)
     {
-        handle->ERROR_MESSAGE("Unknown exception thrown");
-    }
+        if(0 == extHandle) {
+            return 2;
+        }
 
-    return 2;
-}
+        GEOSContextHandleInternal_t* handle = 0;
+        handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
+        if(0 == handle->initialized) {
+            return 2;
+        }
 
-char
-GEOSEqualsExact_r(GEOSContextHandle_t extHandle, const Geometry *g1, const Geometry *g2, double tolerance)
-{
-    if ( 0 == extHandle )
-    {
-        return 2;
-    }
+        try {
+            bool result = g1->equalsExact(g2, tolerance);
+            return result;
+        }
+        catch(const std::exception& e) {
+            handle->ERROR_MESSAGE("%s", e.what());
+        }
+        catch(...) {
+            handle->ERROR_MESSAGE("Unknown exception thrown");
+        }
 
-    GEOSContextHandleInternal_t *handle = 0;
-    handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
-    if ( 0 == handle->initialized )
-    {
         return 2;
     }
 
-    try
-    {
-        bool result = g1->equalsExact(g2, tolerance);
-        return result;
-    }
-    catch (const std::exception &e)
-    {
-        handle->ERROR_MESSAGE("%s", e.what());
-    }
-    catch (...)
+    int
+    GEOSDistance_r(GEOSContextHandle_t extHandle, const Geometry* g1, const Geometry* g2, double* dist)
     {
-        handle->ERROR_MESSAGE("Unknown exception thrown");
-    }
+        assert(0 != dist);
 
-    return 2;
-}
+        if(0 == extHandle) {
+            return 0;
+        }
 
-int
-GEOSDistance_r(GEOSContextHandle_t extHandle, const Geometry *g1, const Geometry *g2, double *dist)
-{
-    assert(0 != dist);
+        GEOSContextHandleInternal_t* handle = 0;
+        handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
+        if(0 == handle->initialized) {
+            return 0;
+        }
 
-    if ( 0 == extHandle )
-    {
-        return 0;
-    }
+        try {
+            *dist = g1->distance(g2);
+            return 1;
+        }
+        catch(const std::exception& e) {
+            handle->ERROR_MESSAGE("%s", e.what());
+        }
+        catch(...) {
+            handle->ERROR_MESSAGE("Unknown exception thrown");
+        }
 
-    GEOSContextHandleInternal_t *handle = 0;
-    handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
-    if ( 0 == handle->initialized )
-    {
         return 0;
     }
 
-    try
-    {
-        *dist = g1->distance(g2);
-        return 1;
-    }
-    catch (const std::exception &e)
-    {
-        handle->ERROR_MESSAGE("%s", e.what());
-    }
-    catch (...)
+    int
+    GEOSDistanceIndexed_r(GEOSContextHandle_t extHandle, const Geometry* g1, const Geometry* g2, double* dist)
     {
-        handle->ERROR_MESSAGE("Unknown exception thrown");
-    }
+        assert(0 != dist);
 
-    return 0;
-}
+        if(0 == extHandle) {
+            return 0;
+        }
 
-int
-GEOSDistanceIndexed_r(GEOSContextHandle_t extHandle, const Geometry *g1, const Geometry *g2, double *dist)
-{
-    assert(0 != dist);
+        GEOSContextHandleInternal_t* handle = 0;
+        handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
+        if(0 == handle->initialized) {
+            return 0;
+        }
 
-    if ( 0 == extHandle )
-    {
-        return 0;
-    }
+        try {
+            *dist = IndexedFacetDistance::distance(g1, g2);
+            return 1;
+        }
+        catch(const std::exception& e) {
+            handle->ERROR_MESSAGE("%s", e.what());
+        }
+        catch(...) {
+            handle->ERROR_MESSAGE("Unknown exception thrown");
+        }
 
-    GEOSContextHandleInternal_t *handle = 0;
-    handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
-    if ( 0 == handle->initialized )
-    {
         return 0;
     }
 
-    try
-    {
-        *dist = IndexedFacetDistance::distance(g1, g2);
-        return 1;
-    }
-    catch (const std::exception &e)
-    {
-        handle->ERROR_MESSAGE("%s", e.what());
-    }
-    catch (...)
+    int
+    GEOSHausdorffDistance_r(GEOSContextHandle_t extHandle, const Geometry* g1, const Geometry* g2, double* dist)
     {
-        handle->ERROR_MESSAGE("Unknown exception thrown");
-    }
+        assert(0 != dist);
 
-    return 0;
-}
+        if(0 == extHandle) {
+            return 0;
+        }
 
-int
-GEOSHausdorffDistance_r(GEOSContextHandle_t extHandle, const Geometry *g1, const Geometry *g2, double *dist)
-{
-    assert(0 != dist);
+        GEOSContextHandleInternal_t* handle = 0;
+        handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
+        if(0 == handle->initialized) {
+            return 0;
+        }
 
-    if ( 0 == extHandle )
-    {
-        return 0;
-    }
+        try {
+            *dist = DiscreteHausdorffDistance::distance(*g1, *g2);
+            return 1;
+        }
+        catch(const std::exception& e) {
+            handle->ERROR_MESSAGE("%s", e.what());
+        }
+        catch(...) {
+            handle->ERROR_MESSAGE("Unknown exception thrown");
+        }
 
-    GEOSContextHandleInternal_t *handle = 0;
-    handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
-    if ( 0 == handle->initialized )
-    {
         return 0;
     }
 
-    try
-    {
-        *dist = DiscreteHausdorffDistance::distance(*g1, *g2);
-        return 1;
-    }
-    catch (const std::exception &e)
+    int
+    GEOSHausdorffDistanceDensify_r(GEOSContextHandle_t extHandle, const Geometry* g1, const Geometry* g2,
+                                   double densifyFrac, double* dist)
     {
-        handle->ERROR_MESSAGE("%s", e.what());
-    }
-    catch (...)
-    {
-        handle->ERROR_MESSAGE("Unknown exception thrown");
-    }
+        assert(0 != dist);
 
-    return 0;
-}
+        if(0 == extHandle) {
+            return 0;
+        }
 
-int
-GEOSHausdorffDistanceDensify_r(GEOSContextHandle_t extHandle, const Geometry *g1, const Geometry *g2, double densifyFrac, double *dist)
-{
-    assert(0 != dist);
+        GEOSContextHandleInternal_t* handle = 0;
+        handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
+        if(0 == handle->initialized) {
+            return 0;
+        }
 
-    if ( 0 == extHandle )
-    {
-        return 0;
-    }
+        try {
+            *dist = DiscreteHausdorffDistance::distance(*g1, *g2, densifyFrac);
+            return 1;
+        }
+        catch(const std::exception& e) {
+            handle->ERROR_MESSAGE("%s", e.what());
+        }
+        catch(...) {
+            handle->ERROR_MESSAGE("Unknown exception thrown");
+        }
 
-    GEOSContextHandleInternal_t *handle = 0;
-    handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
-    if ( 0 == handle->initialized )
-    {
         return 0;
     }
 
-    try
-    {
-        *dist = DiscreteHausdorffDistance::distance(*g1, *g2, densifyFrac);
-        return 1;
-    }
-    catch (const std::exception &e)
-    {
-        handle->ERROR_MESSAGE("%s", e.what());
-    }
-    catch (...)
+    int
+    GEOSFrechetDistance_r(GEOSContextHandle_t extHandle, const Geometry* g1, const Geometry* g2, double* dist)
     {
-        handle->ERROR_MESSAGE("Unknown exception thrown");
-    }
+        assert(0 != dist);
 
-    return 0;
-}
+        if(0 == extHandle) {
+            return 0;
+        }
 
-int
-GEOSFrechetDistance_r(GEOSContextHandle_t extHandle, const Geometry *g1, const Geometry *g2, double *dist)
-{
-    assert(0 != dist);
+        GEOSContextHandleInternal_t* handle = 0;
+        handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
+        if(0 == handle->initialized) {
+            return 0;
+        }
 
-    if ( 0 == extHandle )
-    {
-        return 0;
-    }
+        try {
+            *dist = DiscreteFrechetDistance::distance(*g1, *g2);
+            return 1;
+        }
+        catch(const std::exception& e) {
+            handle->ERROR_MESSAGE("%s", e.what());
+        }
+        catch(...) {
+            handle->ERROR_MESSAGE("Unknown exception thrown");
+        }
 
-    GEOSContextHandleInternal_t *handle = 0;
-    handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
-    if ( 0 == handle->initialized )
-    {
         return 0;
     }
 
-    try
+    int
+    GEOSFrechetDistanceDensify_r(GEOSContextHandle_t extHandle, const Geometry* g1, const Geometry* g2, double densifyFrac,
+                                 double* dist)
     {
-        *dist = DiscreteFrechetDistance::distance(*g1, *g2);
-        return 1;
-    }
-    catch (const std::exception &e)
-    {
-        handle->ERROR_MESSAGE("%s", e.what());
-    }
-    catch (...)
-    {
-        handle->ERROR_MESSAGE("Unknown exception thrown");
-    }
+        assert(0 != dist);
 
-    return 0;
-}
+        if(0 == extHandle) {
+            return 0;
+        }
 
-int
-GEOSFrechetDistanceDensify_r(GEOSContextHandle_t extHandle, const Geometry *g1, const Geometry *g2, double densifyFrac, double *dist)
-{
-    assert(0 != dist);
+        GEOSContextHandleInternal_t* handle = 0;
+        handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
+        if(0 == handle->initialized) {
+            return 0;
+        }
 
-    if ( 0 == extHandle )
-    {
-        return 0;
-    }
+        try {
+            *dist = DiscreteFrechetDistance::distance(*g1, *g2, densifyFrac);
+            return 1;
+        }
+        catch(const std::exception& e) {
+            handle->ERROR_MESSAGE("%s", e.what());
+        }
+        catch(...) {
+            handle->ERROR_MESSAGE("Unknown exception thrown");
+        }
 
-    GEOSContextHandleInternal_t *handle = 0;
-    handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
-    if ( 0 == handle->initialized )
-    {
         return 0;
     }
 
-    try
-    {
-        *dist = DiscreteFrechetDistance::distance(*g1, *g2, densifyFrac);
-        return 1;
-    }
-    catch (const std::exception &e)
-    {
-        handle->ERROR_MESSAGE("%s", e.what());
-    }
-    catch (...)
+    int
+    GEOSArea_r(GEOSContextHandle_t extHandle, const Geometry* g, double* area)
     {
-        handle->ERROR_MESSAGE("Unknown exception thrown");
-    }
+        assert(0 != area);
 
-    return 0;
-}
+        if(0 == extHandle) {
+            return 0;
+        }
 
-int
-GEOSArea_r(GEOSContextHandle_t extHandle, const Geometry *g, double *area)
-{
-    assert(0 != area);
+        GEOSContextHandleInternal_t* handle = 0;
+        handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
+        if(0 == handle->initialized) {
+            return 0;
+        }
 
-    if ( 0 == extHandle )
-    {
-        return 0;
-    }
+        try {
+            *area = g->getArea();
+            return 1;
+        }
+        catch(const std::exception& e) {
+            handle->ERROR_MESSAGE("%s", e.what());
+        }
+        catch(...) {
+            handle->ERROR_MESSAGE("Unknown exception thrown");
+        }
 
-    GEOSContextHandleInternal_t *handle = 0;
-    handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
-    if ( 0 == handle->initialized )
-    {
         return 0;
     }
 
-    try
-    {
-        *area = g->getArea();
-        return 1;
-    }
-    catch (const std::exception &e)
+    int
+    GEOSLength_r(GEOSContextHandle_t extHandle, const Geometry* g, double* length)
     {
-        handle->ERROR_MESSAGE("%s", e.what());
-    }
-    catch (...)
-    {
-        handle->ERROR_MESSAGE("Unknown exception thrown");
-    }
+        assert(0 != length);
 
-    return 0;
-}
+        if(0 == extHandle) {
+            return 0;
+        }
 
-int
-GEOSLength_r(GEOSContextHandle_t extHandle, const Geometry *g, double *length)
-{
-    assert(0 != length);
+        GEOSContextHandleInternal_t* handle = 0;
+        handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
+        if(0 == handle->initialized) {
+            return 0;
+        }
 
-    if ( 0 == extHandle )
-    {
-        return 0;
-    }
+        try {
+            *length = g->getLength();
+            return 1;
+        }
+        catch(const std::exception& e) {
+            handle->ERROR_MESSAGE("%s", e.what());
+        }
+        catch(...) {
+            handle->ERROR_MESSAGE("Unknown exception thrown");
+        }
 
-    GEOSContextHandleInternal_t *handle = 0;
-    handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
-    if ( 0 == handle->initialized )
-    {
         return 0;
     }
 
-    try
-    {
-        *length = g->getLength();
-        return 1;
-    }
-    catch (const std::exception &e)
-    {
-        handle->ERROR_MESSAGE("%s", e.what());
-    }
-    catch (...)
+    CoordinateSequence*
+    GEOSNearestPoints_r(GEOSContextHandle_t extHandle, const Geometry* g1, const Geometry* g2)
     {
-        handle->ERROR_MESSAGE("Unknown exception thrown");
-    }
+        if(0 == extHandle) {
+            return NULL;
+        }
 
-    return 0;
-}
+        GEOSContextHandleInternal_t* handle = 0;
+        handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
+        if(0 == handle->initialized) {
+            return NULL;
+        }
 
-CoordinateSequence *
-GEOSNearestPoints_r(GEOSContextHandle_t extHandle, const Geometry *g1, const Geometry *g2)
-{
-    if ( 0 == extHandle )
-    {
-        return NULL;
-    }
+        try {
+            if(g1->isEmpty() || g2->isEmpty()) {
+                return 0;
+            }
+            return geos::operation::distance::DistanceOp::nearestPoints(g1, g2);
+        }
+        catch(const std::exception& e) {
+            handle->ERROR_MESSAGE("%s", e.what());
+        }
+        catch(...) {
+            handle->ERROR_MESSAGE("Unknown exception thrown");
+        }
 
-    GEOSContextHandleInternal_t *handle = 0;
-    handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
-    if ( 0 == handle->initialized )
-    {
         return NULL;
     }
 
-    try
-    {
-        if (g1->isEmpty() || g2->isEmpty()) return 0;
-        return geos::operation::distance::DistanceOp::nearestPoints(g1, g2);
-    }
-    catch (const std::exception &e)
-    {
-        handle->ERROR_MESSAGE("%s", e.what());
-    }
-    catch (...)
+
+    Geometry*
+    GEOSGeomFromWKT_r(GEOSContextHandle_t extHandle, const char* wkt)
     {
-        handle->ERROR_MESSAGE("Unknown exception thrown");
-    }
+        if(0 == extHandle) {
+            return NULL;
+        }
 
-    return NULL;
-}
+        GEOSContextHandleInternal_t* handle = 0;
+        handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
+        if(0 == handle->initialized) {
+            return NULL;
+        }
 
+        try {
+            const std::string wktstring(wkt);
+            WKTReader r(static_cast<GeometryFactory const*>(handle->geomFactory));
 
-Geometry *
-GEOSGeomFromWKT_r(GEOSContextHandle_t extHandle, const char *wkt)
-{
-    if ( 0 == extHandle )
-    {
-        return NULL;
-    }
+            Geometry* g = r.read(wktstring);
+            return g;
+        }
+        catch(const std::exception& e) {
+            handle->ERROR_MESSAGE("%s", e.what());
+        }
+        catch(...) {
+            handle->ERROR_MESSAGE("Unknown exception thrown");
+        }
 
-    GEOSContextHandleInternal_t *handle = 0;
-    handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
-    if ( 0 == handle->initialized )
-    {
         return NULL;
     }
 
-    try
+    char*
+    GEOSGeomToWKT_r(GEOSContextHandle_t extHandle, const Geometry* g1)
     {
-        const std::string wktstring(wkt);
-        WKTReader r(static_cast<GeometryFactory const*>(handle->geomFactory));
+        if(0 == extHandle) {
+            return NULL;
+        }
 
-        Geometry *g = r.read(wktstring);
-        return g;
-    }
-    catch (const std::exception &e)
-    {
-        handle->ERROR_MESSAGE("%s", e.what());
-    }
-    catch (...)
-    {
-        handle->ERROR_MESSAGE("Unknown exception thrown");
-    }
+        GEOSContextHandleInternal_t* handle = 0;
+        handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
+        if(0 == handle->initialized) {
+            return NULL;
+        }
 
-    return NULL;
-}
+        try {
 
-char *
-GEOSGeomToWKT_r(GEOSContextHandle_t extHandle, const Geometry *g1)
-{
-    if ( 0 == extHandle )
-    {
+            char* result = gstrdup(g1->toString());
+            return result;
+        }
+        catch(const std::exception& e) {
+            handle->ERROR_MESSAGE("%s", e.what());
+        }
+        catch(...) {
+            handle->ERROR_MESSAGE("Unknown exception thrown");
+        }
         return NULL;
     }
 
-    GEOSContextHandleInternal_t *handle = 0;
-    handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
-    if ( 0 == handle->initialized )
+// Remember to free the result!
+    unsigned char*
+    GEOSGeomToWKB_buf_r(GEOSContextHandle_t extHandle, const Geometry* g, size_t* size)
     {
-        return NULL;
-    }
+        assert(0 != size);
 
-    try
-    {
+        if(0 == extHandle) {
+            return NULL;
+        }
 
-        char *result = gstrdup(g1->toString());
-        return result;
-    }
-    catch (const std::exception &e)
-    {
-        handle->ERROR_MESSAGE("%s", e.what());
-    }
-    catch (...)
-    {
-        handle->ERROR_MESSAGE("Unknown exception thrown");
-    }
-    return NULL;
-}
+        GEOSContextHandleInternal_t* handle = 0;
+        handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
+        if(0 == handle->initialized) {
+            return NULL;
+        }
 
-// Remember to free the result!
-unsigned char *
-GEOSGeomToWKB_buf_r(GEOSContextHandle_t extHandle, const Geometry *g, size_t *size)
-{
-    assert(0 != size);
+        using geos::io::WKBWriter;
+        try {
+            int byteOrder = handle->WKBByteOrder;
+            WKBWriter w(handle->WKBOutputDims, byteOrder);
+            std::ostringstream os(std::ios_base::binary);
+            w.write(*g, os);
+            std::string wkbstring(os.str());
+            const std::size_t len = wkbstring.length();
+
+            unsigned char* result = 0;
+            result = static_cast<unsigned char*>(malloc(len));
+            if(0 != result) {
+                std::memcpy(result, wkbstring.c_str(), len);
+                *size = len;
+            }
+            return result;
+        }
+        catch(const std::exception& e) {
+            handle->ERROR_MESSAGE("%s", e.what());
+        }
+        catch(...) {
+            handle->ERROR_MESSAGE("Unknown exception thrown");
+        }
 
-    if ( 0 == extHandle )
-    {
         return NULL;
     }
 
-    GEOSContextHandleInternal_t *handle = 0;
-    handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
-    if ( 0 == handle->initialized )
+    Geometry*
+    GEOSGeomFromWKB_buf_r(GEOSContextHandle_t extHandle, const unsigned char* wkb, size_t size)
     {
+        if(0 == extHandle) {
+            return NULL;
+        }
+
+        GEOSContextHandleInternal_t* handle = 0;
+        handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
+        if(0 == handle->initialized) {
+            return NULL;
+        }
+
+        using geos::io::WKBReader;
+        try {
+            std::string wkbstring(reinterpret_cast<const char*>(wkb), size); // make it binary !
+            WKBReader r(*(static_cast<GeometryFactory const*>(handle->geomFactory)));
+            std::istringstream is(std::ios_base::binary);
+            is.str(wkbstring);
+            is.seekg(0, std::ios::beg); // rewind reader pointer
+            Geometry* g = r.read(is);
+            return g;
+        }
+        catch(const std::exception& e) {
+            handle->ERROR_MESSAGE("%s", e.what());
+        }
+        catch(...) {
+            handle->ERROR_MESSAGE("Unknown exception thrown");
+        }
+
         return NULL;
     }
 
-    using geos::io::WKBWriter;
-    try
+    /* Read/write wkb hex values.  Returned geometries are
+       owned by the caller.*/
+    unsigned char*
+    GEOSGeomToHEX_buf_r(GEOSContextHandle_t extHandle, const Geometry* g, size_t* size)
     {
-        int byteOrder = handle->WKBByteOrder;
-        WKBWriter w(handle->WKBOutputDims, byteOrder);
-        std::ostringstream os(std::ios_base::binary);
-        w.write(*g, os);
-        std::string wkbstring(os.str());
-        const std::size_t len = wkbstring.length();
+        if(0 == extHandle) {
+            return NULL;
+        }
 
-        unsigned char* result = 0;
-        result = static_cast<unsigned char*>(malloc(len));
-        if (0 != result)
-        {
-            std::memcpy(result, wkbstring.c_str(), len);
-            *size = len;
+        GEOSContextHandleInternal_t* handle = 0;
+        handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
+        if(0 == handle->initialized) {
+            return NULL;
         }
-        return result;
-    }
-    catch (const std::exception &e)
-    {
-        handle->ERROR_MESSAGE("%s", e.what());
-    }
-    catch (...)
-    {
-        handle->ERROR_MESSAGE("Unknown exception thrown");
-    }
 
-    return NULL;
-}
+        using geos::io::WKBWriter;
+        try {
+            int byteOrder = handle->WKBByteOrder;
+            WKBWriter w(handle->WKBOutputDims, byteOrder);
+            std::ostringstream os(std::ios_base::binary);
+            w.writeHEX(*g, os);
+            std::string hexstring(os.str());
+
+            char* result = gstrdup(hexstring);
+            if(0 != result) {
+                *size = hexstring.length();
+            }
+
+            return reinterpret_cast<unsigned char*>(result);
+        }
+        catch(const std::exception& e) {
+            handle->ERROR_MESSAGE("%s", e.what());
+        }
+        catch(...) {
+            handle->ERROR_MESSAGE("Unknown exception thrown");
+        }
 
-Geometry *
-GEOSGeomFromWKB_buf_r(GEOSContextHandle_t extHandle, const unsigned char *wkb, size_t size)
-{
-    if ( 0 == extHandle )
-    {
         return NULL;
     }
 
-    GEOSContextHandleInternal_t *handle = 0;
-    handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
-    if ( 0 == handle->initialized )
+    Geometry*
+    GEOSGeomFromHEX_buf_r(GEOSContextHandle_t extHandle, const unsigned char* hex, size_t size)
     {
-        return NULL;
-    }
+        if(0 == extHandle) {
+            return NULL;
+        }
 
-    using geos::io::WKBReader;
-    try
-    {
-        std::string wkbstring(reinterpret_cast<const char*>(wkb), size); // make it binary !
-        WKBReader r(*(static_cast<GeometryFactory const*>(handle->geomFactory)));
-        std::istringstream is(std::ios_base::binary);
-        is.str(wkbstring);
-        is.seekg(0, std::ios::beg); // rewind reader pointer
-        Geometry *g = r.read(is);
-        return g;
-    }
-    catch (const std::exception &e)
-    {
-        handle->ERROR_MESSAGE("%s", e.what());
-    }
-    catch (...)
-    {
-        handle->ERROR_MESSAGE("Unknown exception thrown");
-    }
+        GEOSContextHandleInternal_t* handle = 0;
+        handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
+        if(0 == handle->initialized) {
+            return NULL;
+        }
 
-    return NULL;
-}
+        using geos::io::WKBReader;
+        try {
+            std::string hexstring(reinterpret_cast<const char*>(hex), size);
+            WKBReader r(*(static_cast<GeometryFactory const*>(handle->geomFactory)));
+            std::istringstream is(std::ios_base::binary);
+            is.str(hexstring);
+            is.seekg(0, std::ios::beg); // rewind reader pointer
 
-/* Read/write wkb hex values.  Returned geometries are
-   owned by the caller.*/
-unsigned char *
-GEOSGeomToHEX_buf_r(GEOSContextHandle_t extHandle, const Geometry *g, size_t *size)
-{
-    if ( 0 == extHandle )
-    {
-        return NULL;
-    }
+            Geometry* g = r.readHEX(is);
+            return g;
+        }
+        catch(const std::exception& e) {
+            handle->ERROR_MESSAGE("%s", e.what());
+        }
+        catch(...) {
+            handle->ERROR_MESSAGE("Unknown exception thrown");
+        }
 
-    GEOSContextHandleInternal_t *handle = 0;
-    handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
-    if ( 0 == handle->initialized )
-    {
         return NULL;
     }
 
-    using geos::io::WKBWriter;
-    try
+    char
+    GEOSisEmpty_r(GEOSContextHandle_t extHandle, const Geometry* g1)
     {
-        int byteOrder = handle->WKBByteOrder;
-        WKBWriter w(handle->WKBOutputDims, byteOrder);
-        std::ostringstream os(std::ios_base::binary);
-        w.writeHEX(*g, os);
-        std::string hexstring(os.str());
-
-        char *result = gstrdup(hexstring);
-        if (0 != result)
-        {
-            *size = hexstring.length();
+        if(0 == extHandle) {
+            return 2;
         }
 
-        return reinterpret_cast<unsigned char*>(result);
-    }
-    catch (const std::exception &e)
-    {
-        handle->ERROR_MESSAGE("%s", e.what());
-    }
-    catch (...)
-    {
-        handle->ERROR_MESSAGE("Unknown exception thrown");
-    }
-
-    return NULL;
-}
-
-Geometry *
-GEOSGeomFromHEX_buf_r(GEOSContextHandle_t extHandle, const unsigned char *hex, size_t size)
-{
-    if ( 0 == extHandle )
-    {
-        return NULL;
-    }
-
-    GEOSContextHandleInternal_t *handle = 0;
-    handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
-    if ( 0 == handle->initialized )
-    {
-        return NULL;
-    }
-
-    using geos::io::WKBReader;
-    try
-    {
-        std::string hexstring(reinterpret_cast<const char*>(hex), size);
-        WKBReader r(*(static_cast<GeometryFactory const*>(handle->geomFactory)));
-        std::istringstream is(std::ios_base::binary);
-        is.str(hexstring);
-        is.seekg(0, std::ios::beg); // rewind reader pointer
-
-        Geometry *g = r.readHEX(is);
-        return g;
-    }
-    catch (const std::exception &e)
-    {
-        handle->ERROR_MESSAGE("%s", e.what());
-    }
-    catch (...)
-    {
-        handle->ERROR_MESSAGE("Unknown exception thrown");
-    }
+        GEOSContextHandleInternal_t* handle = 0;
+        handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
+        if(0 == handle->initialized) {
+            return 2;
+        }
 
-    return NULL;
-}
+        try {
+            return g1->isEmpty();
+        }
+        catch(const std::exception& e) {
+            handle->ERROR_MESSAGE("%s", e.what());
+        }
+        catch(...) {
+            handle->ERROR_MESSAGE("Unknown exception thrown");
+        }
 
-char
-GEOSisEmpty_r(GEOSContextHandle_t extHandle, const Geometry *g1)
-{
-    if ( 0 == extHandle )
-    {
         return 2;
     }
 
-    GEOSContextHandleInternal_t *handle = 0;
-    handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
-    if ( 0 == handle->initialized )
+    char
+    GEOSisSimple_r(GEOSContextHandle_t extHandle, const Geometry* g1)
     {
-        return 2;
-    }
+        if(0 == extHandle) {
+            return 2;
+        }
 
-    try
-    {
-        return g1->isEmpty();
-    }
-    catch (const std::exception &e)
-    {
-        handle->ERROR_MESSAGE("%s", e.what());
-    }
-    catch (...)
-    {
-        handle->ERROR_MESSAGE("Unknown exception thrown");
-    }
+        GEOSContextHandleInternal_t* handle = 0;
+        handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
+        if(0 == handle->initialized) {
+            return 2;
+        }
 
-    return 2;
-}
+        try {
+            return g1->isSimple();
+        }
+        catch(const std::exception& e) {
+            handle->ERROR_MESSAGE("%s", e.what());
+            return 2;
+        }
 
-char
-GEOSisSimple_r(GEOSContextHandle_t extHandle, const Geometry *g1)
-{
-    if ( 0 == extHandle )
-    {
-        return 2;
+        catch(...) {
+            handle->ERROR_MESSAGE("Unknown exception thrown");
+            return 2;
+        }
     }
 
-    GEOSContextHandleInternal_t *handle = 0;
-    handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
-    if ( 0 == handle->initialized )
+    char
+    GEOSisRing_r(GEOSContextHandle_t extHandle, const Geometry* g)
     {
-        return 2;
-    }
+        if(0 == extHandle) {
+            return 2;
+        }
 
-    try
-    {
-        return g1->isSimple();
-    }
-    catch (const std::exception &e)
-    {
-        handle->ERROR_MESSAGE("%s", e.what());
-        return 2;
-    }
+        GEOSContextHandleInternal_t* handle = 0;
+        handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
+        if(0 == handle->initialized) {
+            return 2;
+        }
 
-    catch (...)
-    {
-        handle->ERROR_MESSAGE("Unknown exception thrown");
-        return 2;
-    }
-}
+        try {
+            const LineString* ls = dynamic_cast<const LineString*>(g);
+            if(ls) {
+                return (ls->isRing());
+            }
+            else {
+                return 0;
+            }
+        }
+        catch(const std::exception& e) {
+            handle->ERROR_MESSAGE("%s", e.what());
+            return 2;
+        }
 
-char
-GEOSisRing_r(GEOSContextHandle_t extHandle, const Geometry *g)
-{
-    if ( 0 == extHandle )
-    {
-        return 2;
+        catch(...) {
+            handle->ERROR_MESSAGE("Unknown exception thrown");
+            return 2;
+        }
     }
 
-    GEOSContextHandleInternal_t *handle = 0;
-    handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
-    if ( 0 == handle->initialized )
-    {
-        return 2;
-    }
 
-    try
-    {
-        const LineString *ls = dynamic_cast<const LineString *>(g);
-        if ( ls ) {
-            return (ls->isRing());
-        } else {
-            return 0;
-        }
-    }
-    catch (const std::exception &e)
-    {
-        handle->ERROR_MESSAGE("%s", e.what());
-        return 2;
-    }
 
-    catch (...)
+//free the result of this
+    char*
+    GEOSGeomType_r(GEOSContextHandle_t extHandle, const Geometry* g1)
     {
-        handle->ERROR_MESSAGE("Unknown exception thrown");
-        return 2;
-    }
-}
+        if(0 == extHandle) {
+            return NULL;
+        }
 
+        GEOSContextHandleInternal_t* handle = 0;
+        handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
+        if(0 == handle->initialized) {
+            return NULL;
+        }
 
+        try {
+            std::string s = g1->getGeometryType();
 
-//free the result of this
-char *
-GEOSGeomType_r(GEOSContextHandle_t extHandle, const Geometry *g1)
-{
-    if ( 0 == extHandle )
-    {
-        return NULL;
-    }
+            char* result = gstrdup(s);
+            return result;
+        }
+        catch(const std::exception& e) {
+            handle->ERROR_MESSAGE("%s", e.what());
+        }
+        catch(...) {
+            handle->ERROR_MESSAGE("Unknown exception thrown");
+        }
 
-    GEOSContextHandleInternal_t *handle = 0;
-    handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
-    if ( 0 == handle->initialized )
-    {
         return NULL;
     }
 
-    try
-    {
-        std::string s = g1->getGeometryType();
-
-        char *result = gstrdup(s);
-        return result;
-    }
-    catch (const std::exception &e)
-    {
-        handle->ERROR_MESSAGE("%s", e.what());
-    }
-    catch (...)
+// Return postgis geometry type index
+    int
+    GEOSGeomTypeId_r(GEOSContextHandle_t extHandle, const Geometry* g1)
     {
-        handle->ERROR_MESSAGE("Unknown exception thrown");
-    }
+        if(0 == extHandle) {
+            return -1;
+        }
 
-    return NULL;
-}
+        GEOSContextHandleInternal_t* handle = 0;
+        handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
+        if(0 == handle->initialized) {
+            return -1;
+        }
 
-// Return postgis geometry type index
-int
-GEOSGeomTypeId_r(GEOSContextHandle_t extHandle, const Geometry *g1)
-{
-    if ( 0 == extHandle )
-    {
-        return -1;
-    }
+        try {
+            return g1->getGeometryTypeId();
+        }
+        catch(const std::exception& e) {
+            handle->ERROR_MESSAGE("%s", e.what());
+        }
+        catch(...) {
+            handle->ERROR_MESSAGE("Unknown exception thrown");
+        }
 
-    GEOSContextHandleInternal_t *handle = 0;
-    handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
-    if ( 0 == handle->initialized )
-    {
         return -1;
     }
 
-    try
-    {
-        return g1->getGeometryTypeId();
-    }
-    catch (const std::exception &e)
-    {
-        handle->ERROR_MESSAGE("%s", e.what());
-    }
-    catch (...)
-    {
-        handle->ERROR_MESSAGE("Unknown exception thrown");
-    }
-
-    return -1;
-}
-
 //-------------------------------------------------------------------
 // GEOS functions that return geometries
 //-------------------------------------------------------------------
 
-Geometry *
-GEOSEnvelope_r(GEOSContextHandle_t extHandle, const Geometry *g1)
-{
-    if ( 0 == extHandle )
+    Geometry*
+    GEOSEnvelope_r(GEOSContextHandle_t extHandle, const Geometry* g1)
     {
-        return NULL;
-    }
+        if(0 == extHandle) {
+            return NULL;
+        }
+
+        GEOSContextHandleInternal_t* handle = 0;
+        handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
+        if(0 == handle->initialized) {
+            return NULL;
+        }
+
+        try {
+            Geometry* g3 = g1->getEnvelope();
+            return g3;
+        }
+        catch(const std::exception& e) {
+            handle->ERROR_MESSAGE("%s", e.what());
+        }
+        catch(...) {
+            handle->ERROR_MESSAGE("Unknown exception thrown");
+        }
 
-    GEOSContextHandleInternal_t *handle = 0;
-    handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
-    if ( 0 == handle->initialized )
-    {
         return NULL;
     }
 
-    try
-    {
-        Geometry *g3 = g1->getEnvelope();
-        return g3;
-    }
-    catch (const std::exception &e)
-    {
-        handle->ERROR_MESSAGE("%s", e.what());
-    }
-    catch (...)
+    Geometry*
+    GEOSIntersection_r(GEOSContextHandle_t extHandle, const Geometry* g1, const Geometry* g2)
     {
-        handle->ERROR_MESSAGE("Unknown exception thrown");
-    }
+        if(0 == extHandle) {
+            return NULL;
+        }
 
-    return NULL;
-}
+        GEOSContextHandleInternal_t* handle = 0;
+        handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
+        if(0 == handle->initialized) {
+            return NULL;
+        }
 
-Geometry *
-GEOSIntersection_r(GEOSContextHandle_t extHandle, const Geometry *g1, const Geometry *g2)
-{
-    if ( 0 == extHandle )
-    {
-        return NULL;
-    }
+        try {
+            return g1->intersection(g2);
+        }
+        catch(const std::exception& e) {
+            handle->ERROR_MESSAGE("%s", e.what());
+        }
+        catch(...) {
+            handle->ERROR_MESSAGE("Unknown exception thrown");
+        }
 
-    GEOSContextHandleInternal_t *handle = 0;
-    handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
-    if ( 0 == handle->initialized )
-    {
         return NULL;
     }
 
-    try
+    Geometry*
+    GEOSBuffer_r(GEOSContextHandle_t extHandle, const Geometry* g1, double width, int quadrantsegments)
     {
-        return g1->intersection(g2);
-    }
-    catch (const std::exception &e)
-    {
-        handle->ERROR_MESSAGE("%s", e.what());
-    }
-    catch (...)
-    {
-        handle->ERROR_MESSAGE("Unknown exception thrown");
-    }
+        if(0 == extHandle) {
+            return NULL;
+        }
 
-    return NULL;
-}
+        GEOSContextHandleInternal_t* handle = 0;
+        handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
+        if(0 == handle->initialized) {
+            return NULL;
+        }
 
-Geometry *
-GEOSBuffer_r(GEOSContextHandle_t extHandle, const Geometry *g1, double width, int quadrantsegments)
-{
-    if ( 0 == extHandle )
-    {
-        return NULL;
-    }
+        try {
+            Geometry* g3 = g1->buffer(width, quadrantsegments);
+            return g3;
+        }
+        catch(const std::exception& e) {
+            handle->ERROR_MESSAGE("%s", e.what());
+        }
+        catch(...) {
+            handle->ERROR_MESSAGE("Unknown exception thrown");
+        }
 
-    GEOSContextHandleInternal_t *handle = 0;
-    handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
-    if ( 0 == handle->initialized )
-    {
         return NULL;
     }
 
-    try
-    {
-        Geometry *g3 = g1->buffer(width, quadrantsegments);
-        return g3;
-    }
-    catch (const std::exception &e)
-    {
-        handle->ERROR_MESSAGE("%s", e.what());
-    }
-    catch (...)
+    Geometry*
+    GEOSBufferWithStyle_r(GEOSContextHandle_t extHandle, const Geometry* g1, double width, int quadsegs, int endCapStyle,
+                          int joinStyle, double mitreLimit)
     {
-        handle->ERROR_MESSAGE("Unknown exception thrown");
-    }
+        using geos::operation::buffer::BufferParameters;
+        using geos::operation::buffer::BufferOp;
+        using geos::util::IllegalArgumentException;
 
-    return NULL;
-}
+        if(0 == extHandle) {
+            return NULL;
+        }
 
-Geometry *
-GEOSBufferWithStyle_r(GEOSContextHandle_t extHandle, const Geometry *g1, double width, int quadsegs, int endCapStyle, int joinStyle, double mitreLimit)
-{
-    using geos::operation::buffer::BufferParameters;
-    using geos::operation::buffer::BufferOp;
-    using geos::util::IllegalArgumentException;
+        GEOSContextHandleInternal_t* handle = 0;
+        handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
+        if(0 == handle->initialized) {
+            return NULL;
+        }
 
-    if ( 0 == extHandle )
-    {
-        return NULL;
-    }
+        try {
+            BufferParameters bp;
+            bp.setQuadrantSegments(quadsegs);
+
+            if(endCapStyle > BufferParameters::CAP_SQUARE) {
+                throw IllegalArgumentException("Invalid buffer endCap style");
+            }
+            bp.setEndCapStyle(
+                static_cast<BufferParameters::EndCapStyle>(endCapStyle)
+            );
+
+            if(joinStyle > BufferParameters::JOIN_BEVEL) {
+                throw IllegalArgumentException("Invalid buffer join style");
+            }
+            bp.setJoinStyle(
+                static_cast<BufferParameters::JoinStyle>(joinStyle)
+            );
+            bp.setMitreLimit(mitreLimit);
+            BufferOp op(g1, bp);
+            Geometry* g3 = op.getResultGeometry(width);
+            return g3;
+        }
+        catch(const std::exception& e) {
+            handle->ERROR_MESSAGE("%s", e.what());
+        }
+        catch(...) {
+            handle->ERROR_MESSAGE("Unknown exception thrown");
+        }
 
-    GEOSContextHandleInternal_t *handle = 0;
-    handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
-    if ( 0 == handle->initialized )
-    {
         return NULL;
     }
 
-    try
+    Geometry*
+    GEOSOffsetCurve_r(GEOSContextHandle_t extHandle, const Geometry* g1, double width, int quadsegs, int joinStyle,
+                      double mitreLimit)
     {
-        BufferParameters bp;
-        bp.setQuadrantSegments(quadsegs);
-
-        if ( endCapStyle > BufferParameters::CAP_SQUARE )
-        {
-        	throw IllegalArgumentException("Invalid buffer endCap style");
+        if(0 == extHandle) {
+            return NULL;
         }
-        bp.setEndCapStyle(
-        	static_cast<BufferParameters::EndCapStyle>(endCapStyle)
-        );
 
-        if ( joinStyle > BufferParameters::JOIN_BEVEL )
-        {
-        	throw IllegalArgumentException("Invalid buffer join style");
+        GEOSContextHandleInternal_t* handle = 0;
+        handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
+        if(0 == handle->initialized) {
+            return NULL;
         }
-        bp.setJoinStyle(
-        	static_cast<BufferParameters::JoinStyle>(joinStyle)
-        );
-        bp.setMitreLimit(mitreLimit);
-        BufferOp op(g1, bp);
-        Geometry *g3 = op.getResultGeometry(width);
-        return g3;
-    }
-    catch (const std::exception &e)
-    {
-        handle->ERROR_MESSAGE("%s", e.what());
-    }
-    catch (...)
-    {
-        handle->ERROR_MESSAGE("Unknown exception thrown");
-    }
-
-    return NULL;
-}
 
-Geometry *
-GEOSOffsetCurve_r(GEOSContextHandle_t extHandle, const Geometry *g1, double width, int quadsegs, int joinStyle, double mitreLimit)
-{
-    if ( 0 == extHandle ) return NULL;
+        try {
+            BufferParameters bp;
+            bp.setEndCapStyle(BufferParameters::CAP_FLAT);
+            bp.setQuadrantSegments(quadsegs);
 
-    GEOSContextHandleInternal_t *handle = 0;
-    handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
-    if ( 0 == handle->initialized ) return NULL;
+            if(joinStyle > BufferParameters::JOIN_BEVEL) {
+                throw IllegalArgumentException("Invalid buffer join style");
+            }
+            bp.setJoinStyle(
+                static_cast<BufferParameters::JoinStyle>(joinStyle)
+            );
+            bp.setMitreLimit(mitreLimit);
 
-    try
-    {
-        BufferParameters bp;
-        bp.setEndCapStyle( BufferParameters::CAP_FLAT );
-        bp.setQuadrantSegments(quadsegs);
+            bool isLeftSide = true;
+            if(width < 0) {
+                isLeftSide = false;
+                width = -width;
+            }
+            BufferBuilder bufBuilder(bp);
+            Geometry* g3 = bufBuilder.bufferLineSingleSided(g1, width, isLeftSide);
 
-        if ( joinStyle > BufferParameters::JOIN_BEVEL )
-        {
-            throw IllegalArgumentException("Invalid buffer join style");
+            return g3;
         }
-        bp.setJoinStyle(
-            static_cast<BufferParameters::JoinStyle>(joinStyle)
-            );
-        bp.setMitreLimit(mitreLimit);
-
-        bool isLeftSide = true;
-        if ( width < 0 ) {
-          isLeftSide = false;
-          width = -width;
+        catch(const std::exception& e) {
+            handle->ERROR_MESSAGE("%s", e.what());
+        }
+        catch(...) {
+            handle->ERROR_MESSAGE("Unknown exception thrown");
         }
-        BufferBuilder bufBuilder (bp);
-        Geometry *g3 = bufBuilder.bufferLineSingleSided(g1, width, isLeftSide);
 
-        return g3;
-    }
-    catch (const std::exception &e)
-    {
-        handle->ERROR_MESSAGE("%s", e.what());
-    }
-    catch (...)
-    {
-        handle->ERROR_MESSAGE("Unknown exception thrown");
+        return NULL;
     }
 
-    return NULL;
-}
-
-/* @deprecated in 3.3.0 */
-Geometry *
-GEOSSingleSidedBuffer_r(GEOSContextHandle_t extHandle, const Geometry *g1, double width, int quadsegs, int joinStyle, double mitreLimit, int leftSide)
-{
-    if ( 0 == extHandle ) return NULL;
-
-    GEOSContextHandleInternal_t *handle = 0;
-    handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
-    if ( 0 == handle->initialized ) return NULL;
-
-    try
+    /* @deprecated in 3.3.0 */
+    Geometry*
+    GEOSSingleSidedBuffer_r(GEOSContextHandle_t extHandle, const Geometry* g1, double width, int quadsegs, int joinStyle,
+                            double mitreLimit, int leftSide)
     {
-        BufferParameters bp;
-        bp.setEndCapStyle( BufferParameters::CAP_FLAT );
-        bp.setQuadrantSegments(quadsegs);
+        if(0 == extHandle) {
+            return NULL;
+        }
 
-        if ( joinStyle > BufferParameters::JOIN_BEVEL )
-        {
-            throw IllegalArgumentException("Invalid buffer join style");
+        GEOSContextHandleInternal_t* handle = 0;
+        handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
+        if(0 == handle->initialized) {
+            return NULL;
         }
-        bp.setJoinStyle(
-            static_cast<BufferParameters::JoinStyle>(joinStyle)
-            );
-        bp.setMitreLimit(mitreLimit);
 
-        bool isLeftSide = leftSide == 0 ? false : true;
-        BufferBuilder bufBuilder (bp);
-        Geometry *g3 = bufBuilder.bufferLineSingleSided(g1, width, isLeftSide);
+        try {
+            BufferParameters bp;
+            bp.setEndCapStyle(BufferParameters::CAP_FLAT);
+            bp.setQuadrantSegments(quadsegs);
 
-        return g3;
-    }
-    catch (const std::exception &e)
-    {
-        handle->ERROR_MESSAGE("%s", e.what());
-    }
-    catch (...)
-    {
-        handle->ERROR_MESSAGE("Unknown exception thrown");
-    }
+            if(joinStyle > BufferParameters::JOIN_BEVEL) {
+                throw IllegalArgumentException("Invalid buffer join style");
+            }
+            bp.setJoinStyle(
+                static_cast<BufferParameters::JoinStyle>(joinStyle)
+            );
+            bp.setMitreLimit(mitreLimit);
 
-    return NULL;
-}
+            bool isLeftSide = leftSide == 0 ? false : true;
+            BufferBuilder bufBuilder(bp);
+            Geometry* g3 = bufBuilder.bufferLineSingleSided(g1, width, isLeftSide);
 
-Geometry *
-GEOSConvexHull_r(GEOSContextHandle_t extHandle, const Geometry *g1)
-{
-    if ( 0 == extHandle )
-    {
-        return NULL;
-    }
+            return g3;
+        }
+        catch(const std::exception& e) {
+            handle->ERROR_MESSAGE("%s", e.what());
+        }
+        catch(...) {
+            handle->ERROR_MESSAGE("Unknown exception thrown");
+        }
 
-    GEOSContextHandleInternal_t *handle = 0;
-    handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
-    if ( 0 == handle->initialized )
-    {
         return NULL;
     }
 
-    try
-    {
-        Geometry *g3 = g1->convexHull();
-        return g3;
-    }
-    catch (const std::exception &e)
-    {
-        handle->ERROR_MESSAGE("%s", e.what());
-    }
-    catch (...)
+    Geometry*
+    GEOSConvexHull_r(GEOSContextHandle_t extHandle, const Geometry* g1)
     {
-        handle->ERROR_MESSAGE("Unknown exception thrown");
-    }
+        if(0 == extHandle) {
+            return NULL;
+        }
 
-    return NULL;
-}
+        GEOSContextHandleInternal_t* handle = 0;
+        handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
+        if(0 == handle->initialized) {
+            return NULL;
+        }
 
+        try {
+            Geometry* g3 = g1->convexHull();
+            return g3;
+        }
+        catch(const std::exception& e) {
+            handle->ERROR_MESSAGE("%s", e.what());
+        }
+        catch(...) {
+            handle->ERROR_MESSAGE("Unknown exception thrown");
+        }
 
-Geometry *
-GEOSMinimumRotatedRectangle_r(GEOSContextHandle_t extHandle, const Geometry *g)
-{
-    if ( 0 == extHandle )
-    {
         return NULL;
     }
 
-    GEOSContextHandleInternal_t *handle = 0;
-    handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
-    if ( 0 == handle->initialized )
-    {
-        return NULL;
-    }
 
-    try
+    Geometry*
+    GEOSMinimumRotatedRectangle_r(GEOSContextHandle_t extHandle, const Geometry* g)
     {
-        geos::algorithm::MinimumDiameter m(g);
+        if(0 == extHandle) {
+            return NULL;
+        }
 
-        Geometry *g3 = m.getMinimumRectangle();
-        return g3;
-    }
-    catch (const std::exception &e)
-    {
-        handle->ERROR_MESSAGE("%s", e.what());
-    }
-    catch (...)
-    {
-        handle->ERROR_MESSAGE("Unknown exception thrown");
-    }
+        GEOSContextHandleInternal_t* handle = 0;
+        handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
+        if(0 == handle->initialized) {
+            return NULL;
+        }
 
-    return NULL;
-}
+        try {
+            geos::algorithm::MinimumDiameter m(g);
 
-Geometry *
-GEOSMinimumWidth_r(GEOSContextHandle_t extHandle, const Geometry *g)
-{
-    if ( 0 == extHandle )
-    {
-        return NULL;
-    }
+            Geometry* g3 = m.getMinimumRectangle();
+            return g3;
+        }
+        catch(const std::exception& e) {
+            handle->ERROR_MESSAGE("%s", e.what());
+        }
+        catch(...) {
+            handle->ERROR_MESSAGE("Unknown exception thrown");
+        }
 
-    GEOSContextHandleInternal_t *handle = 0;
-    handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
-    if ( 0 == handle->initialized )
-    {
         return NULL;
     }
 
-    try
+    Geometry*
+    GEOSMinimumWidth_r(GEOSContextHandle_t extHandle, const Geometry* g)
     {
-        geos::algorithm::MinimumDiameter m(g);
+        if(0 == extHandle) {
+            return NULL;
+        }
 
-        Geometry *g3 = m.getDiameter();
-        return g3;
-    }
-    catch (const std::exception &e)
-    {
-        handle->ERROR_MESSAGE("%s", e.what());
-    }
-    catch (...)
-    {
-        handle->ERROR_MESSAGE("Unknown exception thrown");
-    }
+        GEOSContextHandleInternal_t* handle = 0;
+        handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
+        if(0 == handle->initialized) {
+            return NULL;
+        }
 
-    return NULL;
-}
+        try {
+            geos::algorithm::MinimumDiameter m(g);
+
+            Geometry* g3 = m.getDiameter();
+            return g3;
+        }
+        catch(const std::exception& e) {
+            handle->ERROR_MESSAGE("%s", e.what());
+        }
+        catch(...) {
+            handle->ERROR_MESSAGE("Unknown exception thrown");
+        }
 
-Geometry *
-GEOSMinimumClearanceLine_r(GEOSContextHandle_t extHandle, const Geometry *g)
-{
-    if ( 0 == extHandle )
-    {
         return NULL;
     }
 
-    GEOSContextHandleInternal_t *handle = 0;
-    handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
-    if ( 0 == handle->initialized )
+    Geometry*
+    GEOSMinimumClearanceLine_r(GEOSContextHandle_t extHandle, const Geometry* g)
     {
+        if(0 == extHandle) {
+            return NULL;
+        }
+
+        GEOSContextHandleInternal_t* handle = 0;
+        handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
+        if(0 == handle->initialized) {
+            return NULL;
+        }
+
+        try {
+            geos::precision::MinimumClearance mc(g);
+            return mc.getLine().release();
+        }
+        catch(const std::exception& e) {
+            handle->ERROR_MESSAGE("%s", e.what());
+        }
+        catch(...) {
+            handle->ERROR_MESSAGE("Unknown exception thrown");
+        }
+
         return NULL;
     }
 
-    try
-    {
-        geos::precision::MinimumClearance mc(g);
-        return mc.getLine().release();
-    }
-    catch (const std::exception &e)
-    {
-        handle->ERROR_MESSAGE("%s", e.what());
-    }
-    catch (...)
+    int
+    GEOSMinimumClearance_r(GEOSContextHandle_t extHandle, const Geometry* g, double* d)
     {
-        handle->ERROR_MESSAGE("Unknown exception thrown");
-    }
+        if(0 == extHandle) {
+            return 2;
+        }
 
-    return NULL;
-}
+        GEOSContextHandleInternal_t* handle = 0;
+        handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
+        if(0 == handle->initialized) {
+            return 2;
+        }
 
-int
-GEOSMinimumClearance_r(GEOSContextHandle_t extHandle, const Geometry *g, double *d)
-{
-    if ( 0 == extHandle )
-    {
-        return 2;
-    }
+        try {
+            geos::precision::MinimumClearance mc(g);
+            double res = mc.getDistance();
+            *d = res;
+            return 0;
+        }
+        catch(const std::exception& e) {
+            handle->ERROR_MESSAGE("%s", e.what());
+        }
+        catch(...) {
+            handle->ERROR_MESSAGE("Unknown exception thrown");
+        }
 
-    GEOSContextHandleInternal_t *handle = 0;
-    handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
-    if ( 0 == handle->initialized )
-    {
         return 2;
     }
 
-    try
-    {
-        geos::precision::MinimumClearance mc(g);
-        double res = mc.getDistance();
-        *d = res;
-        return 0;
-    }
-    catch (const std::exception &e)
-    {
-        handle->ERROR_MESSAGE("%s", e.what());
-    }
-    catch (...)
+
+    Geometry*
+    GEOSDifference_r(GEOSContextHandle_t extHandle, const Geometry* g1, const Geometry* g2)
     {
-        handle->ERROR_MESSAGE("Unknown exception thrown");
-    }
+        if(0 == extHandle) {
+            return NULL;
+        }
 
-    return 2;
-}
+        GEOSContextHandleInternal_t* handle = 0;
+        handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
+        if(0 == handle->initialized) {
+            return NULL;
+        }
 
+        try {
+            return g1->difference(g2);
+        }
+        catch(const std::exception& e) {
+            handle->ERROR_MESSAGE("%s", e.what());
+        }
+        catch(...) {
+            handle->ERROR_MESSAGE("Unknown exception thrown");
+        }
 
-Geometry *
-GEOSDifference_r(GEOSContextHandle_t extHandle, const Geometry *g1, const Geometry *g2)
-{
-    if ( 0 == extHandle )
-    {
         return NULL;
     }
 
-    GEOSContextHandleInternal_t *handle = 0;
-    handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
-    if ( 0 == handle->initialized )
+    Geometry*
+    GEOSBoundary_r(GEOSContextHandle_t extHandle, const Geometry* g1)
     {
-        return NULL;
-    }
+        if(0 == extHandle) {
+            return NULL;
+        }
 
-    try
-    {
-        return g1->difference(g2);
-    }
-    catch (const std::exception &e)
-    {
-        handle->ERROR_MESSAGE("%s", e.what());
-    }
-    catch (...)
-    {
-        handle->ERROR_MESSAGE("Unknown exception thrown");
-    }
+        GEOSContextHandleInternal_t* handle = 0;
+        handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
+        if(0 == handle->initialized) {
+            return NULL;
+        }
 
-    return NULL;
-}
+        try {
+            Geometry* g3 = g1->getBoundary();
+            return g3;
+        }
+        catch(const std::exception& e) {
+            handle->ERROR_MESSAGE("%s", e.what());
+        }
+        catch(...) {
+            handle->ERROR_MESSAGE("Unknown exception thrown");
+        }
 
-Geometry *
-GEOSBoundary_r(GEOSContextHandle_t extHandle, const Geometry *g1)
-{
-    if ( 0 == extHandle )
-    {
         return NULL;
     }
 
-    GEOSContextHandleInternal_t *handle = 0;
-    handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
-    if ( 0 == handle->initialized )
+    Geometry*
+    GEOSSymDifference_r(GEOSContextHandle_t extHandle, const Geometry* g1, const Geometry* g2)
     {
-        return NULL;
-    }
+        if(0 == extHandle) {
+            return NULL;
+        }
 
-    try
-    {
-        Geometry *g3 = g1->getBoundary();
-        return g3;
-    }
-    catch (const std::exception &e)
-    {
-        handle->ERROR_MESSAGE("%s", e.what());
-    }
-    catch (...)
-    {
-        handle->ERROR_MESSAGE("Unknown exception thrown");
-    }
+        GEOSContextHandleInternal_t* handle = 0;
+        handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
+        if(0 == handle->initialized) {
+            return NULL;
+        }
 
-    return NULL;
-}
+        try {
+            return g1->symDifference(g2);
+        }
+        catch(const std::exception& e) {
+            handle->ERROR_MESSAGE("%s", e.what());
+            return NULL;
+        }
 
-Geometry *
-GEOSSymDifference_r(GEOSContextHandle_t extHandle, const Geometry *g1, const Geometry *g2)
-{
-    if ( 0 == extHandle )
-    {
-        return NULL;
+        catch(...) {
+            handle->ERROR_MESSAGE("Unknown exception thrown");
+            return NULL;
+        }
     }
 
-    GEOSContextHandleInternal_t *handle = 0;
-    handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
-    if ( 0 == handle->initialized )
+    Geometry*
+    GEOSUnion_r(GEOSContextHandle_t extHandle, const Geometry* g1, const Geometry* g2)
     {
-        return NULL;
-    }
+        if(0 == extHandle) {
+            return NULL;
+        }
 
-    try
-    {
-        return g1->symDifference(g2);
-    }
-    catch (const std::exception &e)
-    {
-        handle->ERROR_MESSAGE("%s", e.what());
-        return NULL;
-    }
+        GEOSContextHandleInternal_t* handle = 0;
+        handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
+        if(0 == handle->initialized) {
+            return NULL;
+        }
 
-    catch (...)
-    {
-        handle->ERROR_MESSAGE("Unknown exception thrown");
-        return NULL;
-    }
-}
+        try {
+            return g1->Union(g2);
+        }
+        catch(const std::exception& e) {
+#if VERBOSE_EXCEPTIONS
+            std::ostringstream s;
+            s << "Exception on GEOSUnion with following inputs:" << std::endl;
+            s << "A: " << g1->toString() << std::endl;
+            s << "B: " << g2->toString() << std::endl;
+            handle->NOTICE_MESSAGE("%s", s.str().c_str());
+#endif // VERBOSE_EXCEPTIONS
+            handle->ERROR_MESSAGE("%s", e.what());
+        }
+        catch(...) {
+            handle->ERROR_MESSAGE("Unknown exception thrown");
+        }
 
-Geometry *
-GEOSUnion_r(GEOSContextHandle_t extHandle, const Geometry *g1, const Geometry *g2)
-{
-    if ( 0 == extHandle )
-    {
         return NULL;
     }
 
-    GEOSContextHandleInternal_t *handle = 0;
-    handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
-    if ( 0 == handle->initialized )
+    Geometry*
+    GEOSUnaryUnion_r(GEOSContextHandle_t extHandle, const Geometry* g)
     {
-        return NULL;
-    }
+        if(0 == extHandle) {
+            return NULL;
+        }
 
-    try
-    {
-        return g1->Union(g2);
-    }
-    catch (const std::exception &e)
-    {
+        GEOSContextHandleInternal_t* handle = 0;
+        handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
+        if(0 == handle->initialized) {
+            return NULL;
+        }
+
+        try {
+            GeomPtr g3(g->Union());
+            return g3.release();
+        }
+        catch(const std::exception& e) {
 #if VERBOSE_EXCEPTIONS
-        std::ostringstream s;
-        s << "Exception on GEOSUnion with following inputs:" << std::endl;
-        s << "A: "<<g1->toString() << std::endl;
-        s << "B: "<<g2->toString() << std::endl;
-        handle->NOTICE_MESSAGE("%s", s.str().c_str());
+            std::ostringstream s;
+            s << "Exception on GEOSUnaryUnion with following inputs:" << std::endl;
+            s << "A: " << g1->toString() << std::endl;
+            s << "B: " << g2->toString() << std::endl;
+            handle->NOTICE_MESSAGE("%s", s.str().c_str());
 #endif // VERBOSE_EXCEPTIONS
-        handle->ERROR_MESSAGE("%s", e.what());
-    }
-    catch (...)
-    {
-        handle->ERROR_MESSAGE("Unknown exception thrown");
-    }
-
-    return NULL;
-}
+            handle->ERROR_MESSAGE("%s", e.what());
+        }
+        catch(...) {
+            handle->ERROR_MESSAGE("Unknown exception thrown");
+        }
 
-Geometry *
-GEOSUnaryUnion_r(GEOSContextHandle_t extHandle, const Geometry *g)
-{
-    if ( 0 == extHandle )
-    {
         return NULL;
     }
 
-    GEOSContextHandleInternal_t *handle = 0;
-    handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
-    if ( 0 == handle->initialized )
+    Geometry*
+    GEOSNode_r(GEOSContextHandle_t extHandle, const Geometry* g)
     {
-        return NULL;
-    }
+        if(0 == extHandle) {
+            return NULL;
+        }
 
-    try
-    {
-        GeomPtr g3 ( g->Union() );
-        return g3.release();
-    }
-    catch (const std::exception &e)
-    {
+        GEOSContextHandleInternal_t* handle = 0;
+        handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
+        if(0 == handle->initialized) {
+            return NULL;
+        }
+
+        try {
+            std::unique_ptr<Geometry> g3 = geos::noding::GeometryNoder::node(*g);
+            return g3.release();
+        }
+        catch(const std::exception& e) {
 #if VERBOSE_EXCEPTIONS
-        std::ostringstream s;
-        s << "Exception on GEOSUnaryUnion with following inputs:" << std::endl;
-        s << "A: "<<g1->toString() << std::endl;
-        s << "B: "<<g2->toString() << std::endl;
-        handle->NOTICE_MESSAGE("%s", s.str().c_str());
+            std::ostringstream s;
+            s << "Exception on GEOSUnaryUnion with following inputs:" << std::endl;
+            s << "A: " << g1->toString() << std::endl;
+            s << "B: " << g2->toString() << std::endl;
+            handle->NOTICE_MESSAGE("%s", s.str().c_str());
 #endif // VERBOSE_EXCEPTIONS
-        handle->ERROR_MESSAGE("%s", e.what());
-    }
-    catch (...)
-    {
-        handle->ERROR_MESSAGE("Unknown exception thrown");
-    }
-
-    return NULL;
-}
+            handle->ERROR_MESSAGE("%s", e.what());
+        }
+        catch(...) {
+            handle->ERROR_MESSAGE("Unknown exception thrown");
+        }
 
-Geometry *
-GEOSNode_r(GEOSContextHandle_t extHandle, const Geometry *g)
-{
-    if ( 0 == extHandle )
-    {
         return NULL;
     }
 
-    GEOSContextHandleInternal_t *handle = 0;
-    handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
-    if ( 0 == handle->initialized )
+    Geometry*
+    GEOSUnionCascaded_r(GEOSContextHandle_t extHandle, const Geometry* g1)
     {
-        return NULL;
-    }
-
-    try
-    {
-        std::unique_ptr<Geometry> g3 = geos::noding::GeometryNoder::node(*g);
-        return g3.release();
-    }
-    catch (const std::exception &e)
-    {
-#if VERBOSE_EXCEPTIONS
-        std::ostringstream s;
-        s << "Exception on GEOSUnaryUnion with following inputs:" << std::endl;
-        s << "A: "<<g1->toString() << std::endl;
-        s << "B: "<<g2->toString() << std::endl;
-        handle->NOTICE_MESSAGE("%s", s.str().c_str());
-#endif // VERBOSE_EXCEPTIONS
-        handle->ERROR_MESSAGE("%s", e.what());
-    }
-    catch (...)
-    {
-        handle->ERROR_MESSAGE("Unknown exception thrown");
-    }
+        if(0 == extHandle) {
+            return NULL;
+        }
 
-    return NULL;
-}
+        GEOSContextHandleInternal_t* handle = 0;
+        handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
+        if(0 == handle->initialized) {
+            return NULL;
+        }
 
-Geometry *
-GEOSUnionCascaded_r(GEOSContextHandle_t extHandle, const Geometry *g1)
-{
-    if ( 0 == extHandle )
-    {
-        return NULL;
-    }
+        try {
+            const geos::geom::MultiPolygon* p = dynamic_cast<const geos::geom::MultiPolygon*>(g1);
+            if(! p) {
+                handle->ERROR_MESSAGE("Invalid argument (must be a MultiPolygon)");
+                return NULL;
+            }
+
+            using geos::operation::geounion::CascadedPolygonUnion;
+            return CascadedPolygonUnion::Union(p);
+        }
+        catch(const std::exception& e) {
+            handle->ERROR_MESSAGE("%s", e.what());
+        }
+        catch(...) {
+            handle->ERROR_MESSAGE("Unknown exception thrown");
+        }
 
-    GEOSContextHandleInternal_t *handle = 0;
-    handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
-    if ( 0 == handle->initialized )
-    {
         return NULL;
     }
 
-    try
+    Geometry*
+    GEOSPointOnSurface_r(GEOSContextHandle_t extHandle, const Geometry* g1)
     {
-        const geos::geom::MultiPolygon *p = dynamic_cast<const geos::geom::MultiPolygon *>(g1);
-        if ( ! p )
-        {
-            handle->ERROR_MESSAGE("Invalid argument (must be a MultiPolygon)");
+        if(0 == extHandle) {
             return NULL;
         }
 
-        using geos::operation::geounion::CascadedPolygonUnion;
-        return CascadedPolygonUnion::Union(p);
-    }
-    catch (const std::exception &e)
-    {
-        handle->ERROR_MESSAGE("%s", e.what());
-    }
-    catch (...)
-    {
-        handle->ERROR_MESSAGE("Unknown exception thrown");
-    }
+        GEOSContextHandleInternal_t* handle = 0;
+        handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
+        if(0 == handle->initialized) {
+            return NULL;
+        }
 
-    return NULL;
-}
+        try {
+            Geometry* ret = g1->getInteriorPoint();
+            if(! ret) {
+                const GeometryFactory* gf = handle->geomFactory;
+                // return an empty point
+                return gf->createPoint();
+            }
+            return ret;
+        }
+        catch(const std::exception& e) {
+            handle->ERROR_MESSAGE("%s", e.what());
+        }
+        catch(...) {
+            handle->ERROR_MESSAGE("Unknown exception thrown");
+        }
 
-Geometry *
-GEOSPointOnSurface_r(GEOSContextHandle_t extHandle, const Geometry *g1)
-{
-    if ( 0 == extHandle )
-    {
         return NULL;
     }
 
-    GEOSContextHandleInternal_t *handle = 0;
-    handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
-    if ( 0 == handle->initialized )
+    Geometry*
+    GEOSClipByRect_r(GEOSContextHandle_t extHandle, const Geometry* g, double xmin, double ymin, double xmax, double ymax)
     {
-        return NULL;
-    }
+        if(0 == extHandle) {
+            return NULL;
+        }
 
-    try
-    {
-        Geometry *ret = g1->getInteriorPoint();
-        if ( ! ret )
-        {
-            const GeometryFactory* gf = handle->geomFactory;
-            // return an empty point
-            return gf->createPoint();
+        GEOSContextHandleInternal_t* handle = 0;
+        handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
+        if(0 == handle->initialized) {
+            return NULL;
         }
-        return ret;
-    }
-    catch (const std::exception &e)
-    {
-        handle->ERROR_MESSAGE("%s", e.what());
-    }
-    catch (...)
-    {
-        handle->ERROR_MESSAGE("Unknown exception thrown");
-    }
 
-    return NULL;
-}
+        try {
+            using geos::operation::intersection::Rectangle;
+            using geos::operation::intersection::RectangleIntersection;
+            Rectangle rect(xmin, ymin, xmax, ymax);
+            std::unique_ptr<Geometry> g3 = RectangleIntersection::clip(*g, rect);
+            return g3.release();
+        }
+        catch(const std::exception& e) {
+#if VERBOSE_EXCEPTIONS
+            std::ostringstream s;
+            s << "Exception on GEOSClipByRect with following inputs:" << std::endl;
+            s << "A: " << g1->toString() << std::endl;
+            s << "B: " << g2->toString() << std::endl;
+            handle->NOTICE_MESSAGE("%s", s.str().c_str());
+#endif // VERBOSE_EXCEPTIONS
+            handle->ERROR_MESSAGE("%s", e.what());
+        }
+        catch(...) {
+            handle->ERROR_MESSAGE("Unknown exception thrown");
+        }
 
-Geometry *
-GEOSClipByRect_r(GEOSContextHandle_t extHandle, const Geometry *g, double xmin, double ymin, double xmax, double ymax)
-{
-    if ( 0 == extHandle )
-    {
         return NULL;
     }
 
-    GEOSContextHandleInternal_t *handle = 0;
-    handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
-    if ( 0 == handle->initialized )
-    {
-        return NULL;
-    }
+//-------------------------------------------------------------------
+// memory management functions
+//------------------------------------------------------------------
 
-    try
-    {
-        using geos::operation::intersection::Rectangle;
-        using geos::operation::intersection::RectangleIntersection;
-        Rectangle rect(xmin, ymin, xmax, ymax);
-        std::unique_ptr<Geometry> g3 = RectangleIntersection::clip(*g, rect);
-        return g3.release();
-    }
-    catch (const std::exception &e)
-    {
-#if VERBOSE_EXCEPTIONS
-        std::ostringstream s;
-        s << "Exception on GEOSClipByRect with following inputs:" << std::endl;
-        s << "A: "<<g1->toString() << std::endl;
-        s << "B: "<<g2->toString() << std::endl;
-        handle->NOTICE_MESSAGE("%s", s.str().c_str());
-#endif // VERBOSE_EXCEPTIONS
-        handle->ERROR_MESSAGE("%s", e.what());
-    }
-    catch (...)
+    void
+    GEOSGeom_destroy_r(GEOSContextHandle_t extHandle, Geometry* a)
     {
-        handle->ERROR_MESSAGE("Unknown exception thrown");
-    }
+        GEOSContextHandleInternal_t* handle = 0;
 
-    return NULL;
-}
+        // FIXME: mloskot: Does this try-catch around delete means that
+        // destructors in GEOS may throw? If it does, this is a serious
+        // violation of "never throw an exception from a destructor" principle
 
-//-------------------------------------------------------------------
-// memory management functions
-//------------------------------------------------------------------
+        try {
+            delete a;
+        }
+        catch(const std::exception& e) {
+            if(0 == extHandle) {
+                return;
+            }
 
-void
-GEOSGeom_destroy_r(GEOSContextHandle_t extHandle, Geometry *a)
-{
-    GEOSContextHandleInternal_t *handle = 0;
+            handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
+            if(0 == handle->initialized) {
+                return;
+            }
 
-    // FIXME: mloskot: Does this try-catch around delete means that
-    // destructors in GEOS may throw? If it does, this is a serious
-    // violation of "never throw an exception from a destructor" principle
+            handle->ERROR_MESSAGE("%s", e.what());
+        }
+        catch(...) {
+            if(0 == extHandle) {
+                return;
+            }
 
-    try
-    {
-        delete a;
+            handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
+            if(0 == handle->initialized) {
+                return;
+            }
+
+            handle->ERROR_MESSAGE("Unknown exception thrown");
+        }
     }
-    catch (const std::exception &e)
+
+    void
+    GEOSGeom_setUserData_r(GEOSContextHandle_t extHandle, Geometry* g, void* userData)
     {
-        if ( 0 == extHandle )
-        {
+        assert(0 != g);
+
+        if(0 == extHandle) {
             return;
         }
 
+        GEOSContextHandleInternal_t* handle = 0;
         handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
-        if ( 0 == handle->initialized )
-        {
+        if(0 == handle->initialized) {
             return;
         }
 
-        handle->ERROR_MESSAGE("%s", e.what());
+        g->setUserData(userData);
     }
-    catch (...)
+
+    void
+    GEOSSetSRID_r(GEOSContextHandle_t extHandle, Geometry* g, int srid)
     {
-        if ( 0 == extHandle )
-        {
+        assert(0 != g);
+
+        if(0 == extHandle) {
             return;
         }
 
+        GEOSContextHandleInternal_t* handle = 0;
         handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
-        if ( 0 == handle->initialized )
-        {
+        if(0 == handle->initialized) {
             return;
         }
 
-        handle->ERROR_MESSAGE("Unknown exception thrown");
-    }
-}
-
-void
-GEOSGeom_setUserData_r(GEOSContextHandle_t extHandle, Geometry *g, void* userData)
-{
-    assert(0 != g);
-
-    if ( 0 == extHandle )
-    {
-        return;
-    }
-
-    GEOSContextHandleInternal_t *handle = 0;
-    handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
-    if ( 0 == handle->initialized )
-    {
-        return;
+        g->setSRID(srid);
     }
 
-    g->setUserData(userData);
-}
-
-void
-GEOSSetSRID_r(GEOSContextHandle_t extHandle, Geometry *g, int srid)
-{
-    assert(0 != g);
-
-    if ( 0 == extHandle )
-    {
-        return;
-    }
 
-    GEOSContextHandleInternal_t *handle = 0;
-    handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
-    if ( 0 == handle->initialized )
+    int
+    GEOSGetNumCoordinates_r(GEOSContextHandle_t extHandle, const Geometry* g)
     {
-        return;
-    }
+        assert(0 != g);
 
-    g->setSRID(srid);
-}
+        if(0 == extHandle) {
+            return -1;
+        }
 
+        GEOSContextHandleInternal_t* handle = 0;
+        handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
+        if(0 == handle->initialized) {
+            return -1;
+        }
 
-int
-GEOSGetNumCoordinates_r(GEOSContextHandle_t extHandle, const Geometry *g)
-{
-    assert(0 != g);
+        try {
+            return static_cast<int>(g->getNumPoints());
+        }
+        catch(const std::exception& e) {
+            handle->ERROR_MESSAGE("%s", e.what());
+        }
+        catch(...) {
+            handle->ERROR_MESSAGE("Unknown exception thrown");
+        }
 
-    if ( 0 == extHandle )
-    {
         return -1;
     }
 
-    GEOSContextHandleInternal_t *handle = 0;
-    handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
-    if ( 0 == handle->initialized )
+    /*
+     * Return -1 on exception, 0 otherwise.
+     * Converts Geometry to normal form (or canonical form).
+     */
+    int
+    GEOSNormalize_r(GEOSContextHandle_t extHandle, Geometry* g)
     {
-        return -1;
-    }
+        assert(0 != g);
 
-    try
-    {
-        return static_cast<int>(g->getNumPoints());
-    }
-    catch (const std::exception &e)
-    {
-        handle->ERROR_MESSAGE("%s", e.what());
-    }
-    catch (...)
-    {
-        handle->ERROR_MESSAGE("Unknown exception thrown");
-    }
+        if(0 == extHandle) {
+            return -1;
+        }
 
-    return -1;
-}
+        GEOSContextHandleInternal_t* handle = 0;
+        handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
+        if(0 == handle->initialized) {
+            return -1;
+        }
 
-/*
- * Return -1 on exception, 0 otherwise.
- * Converts Geometry to normal form (or canonical form).
- */
-int
-GEOSNormalize_r(GEOSContextHandle_t extHandle, Geometry *g)
-{
-    assert(0 != g);
+        try {
+            g->normalize();
+            return 0; // SUCCESS
+        }
+        catch(const std::exception& e) {
+            handle->ERROR_MESSAGE("%s", e.what());
+        }
+        catch(...) {
+            handle->ERROR_MESSAGE("Unknown exception thrown");
+        }
 
-    if ( 0 == extHandle )
-    {
         return -1;
     }
 
-    GEOSContextHandleInternal_t *handle = 0;
-    handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
-    if ( 0 == handle->initialized )
+    int
+    GEOSGetNumInteriorRings_r(GEOSContextHandle_t extHandle, const Geometry* g1)
     {
-        return -1;
-    }
+        if(0 == extHandle) {
+            return -1;
+        }
 
-    try
-    {
-        g->normalize();
-        return 0; // SUCCESS
-    }
-    catch (const std::exception &e)
-    {
-        handle->ERROR_MESSAGE("%s", e.what());
-    }
-    catch (...)
-    {
-        handle->ERROR_MESSAGE("Unknown exception thrown");
-    }
+        GEOSContextHandleInternal_t* handle = 0;
+        handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
+        if(0 == handle->initialized) {
+            return -1;
+        }
 
-    return -1;
-}
+        try {
+            const Polygon* p = dynamic_cast<const Polygon*>(g1);
+            if(! p) {
+                handle->ERROR_MESSAGE("Argument is not a Polygon");
+                return -1;
+            }
+            return static_cast<int>(p->getNumInteriorRing());
+        }
+        catch(const std::exception& e) {
+            handle->ERROR_MESSAGE("%s", e.what());
+        }
+        catch(...) {
+            handle->ERROR_MESSAGE("Unknown exception thrown");
+        }
 
-int
-GEOSGetNumInteriorRings_r(GEOSContextHandle_t extHandle, const Geometry *g1)
-{
-    if ( 0 == extHandle )
-    {
         return -1;
     }
 
-    GEOSContextHandleInternal_t *handle = 0;
-    handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
-    if ( 0 == handle->initialized )
-    {
-        return -1;
-    }
 
-    try
+// returns -1 on error and 1 for non-multi geometries
+    int
+    GEOSGetNumGeometries_r(GEOSContextHandle_t extHandle, const Geometry* g1)
     {
-        const Polygon *p = dynamic_cast<const Polygon *>(g1);
-        if ( ! p )
-        {
-            handle->ERROR_MESSAGE("Argument is not a Polygon");
+        if(0 == extHandle) {
             return -1;
         }
-        return static_cast<int>(p->getNumInteriorRing());
-    }
-    catch (const std::exception &e)
-    {
-        handle->ERROR_MESSAGE("%s", e.what());
-    }
-    catch (...)
-    {
-        handle->ERROR_MESSAGE("Unknown exception thrown");
-    }
 
-    return -1;
-}
+        GEOSContextHandleInternal_t* handle = 0;
+        handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
+        if(0 == handle->initialized) {
+            return -1;
+        }
 
+        try {
+            return static_cast<int>(g1->getNumGeometries());
+        }
+        catch(const std::exception& e) {
+            handle->ERROR_MESSAGE("%s", e.what());
+        }
+        catch(...) {
+            handle->ERROR_MESSAGE("Unknown exception thrown");
+        }
 
-// returns -1 on error and 1 for non-multi geometries
-int
-GEOSGetNumGeometries_r(GEOSContextHandle_t extHandle, const Geometry *g1)
-{
-    if ( 0 == extHandle )
-    {
         return -1;
     }
 
-    GEOSContextHandleInternal_t *handle = 0;
-    handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
-    if ( 0 == handle->initialized )
-    {
-        return -1;
-    }
 
-    try
+    /*
+     * Call only on GEOMETRYCOLLECTION or MULTI*.
+     * Return a pointer to the internal Geometry.
+     */
+    const Geometry*
+    GEOSGetGeometryN_r(GEOSContextHandle_t extHandle, const Geometry* g1, int n)
     {
-        return static_cast<int>(g1->getNumGeometries());
-    }
-    catch (const std::exception &e)
-    {
-        handle->ERROR_MESSAGE("%s", e.what());
-    }
-    catch (...)
-    {
-        handle->ERROR_MESSAGE("Unknown exception thrown");
-    }
+        if(0 == extHandle) {
+            return NULL;
+        }
 
-    return -1;
-}
+        GEOSContextHandleInternal_t* handle = 0;
+        handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
+        if(0 == handle->initialized) {
+            return NULL;
+        }
 
+        try {
+            return g1->getGeometryN(n);
+        }
+        catch(const std::exception& e) {
+            handle->ERROR_MESSAGE("%s", e.what());
+        }
+        catch(...) {
+            handle->ERROR_MESSAGE("Unknown exception thrown");
+        }
 
-/*
- * Call only on GEOMETRYCOLLECTION or MULTI*.
- * Return a pointer to the internal Geometry.
- */
-const Geometry *
-GEOSGetGeometryN_r(GEOSContextHandle_t extHandle, const Geometry *g1, int n)
-{
-    if ( 0 == extHandle )
-    {
         return NULL;
     }
 
-    GEOSContextHandleInternal_t *handle = 0;
-    handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
-    if ( 0 == handle->initialized )
+    /*
+     * Call only on LINESTRING
+     * Returns NULL on exception
+     */
+    Geometry*
+    GEOSGeomGetPointN_r(GEOSContextHandle_t extHandle, const Geometry* g1, int n)
     {
-        return NULL;
-    }
+        if(0 == extHandle) {
+            return NULL;
+        }
 
-    try
-    {
-        return g1->getGeometryN(n);
-    }
-    catch (const std::exception &e)
-    {
-        handle->ERROR_MESSAGE("%s", e.what());
-    }
-    catch (...)
-    {
-        handle->ERROR_MESSAGE("Unknown exception thrown");
-    }
+        GEOSContextHandleInternal_t* handle = 0;
+        handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
+        if(0 == handle->initialized) {
+            return NULL;
+        }
 
-    return NULL;
-}
+        try {
+            using geos::geom::LineString;
+            const LineString* ls = dynamic_cast<const LineString*>(g1);
+            if(! ls) {
+                handle->ERROR_MESSAGE("Argument is not a LineString");
+                return NULL;
+            }
+            return ls->getPointN(n);
+        }
+        catch(const std::exception& e) {
+            handle->ERROR_MESSAGE("%s", e.what());
+        }
+        catch(...) {
+            handle->ERROR_MESSAGE("Unknown exception thrown");
+        }
 
-/*
- * Call only on LINESTRING
- * Returns NULL on exception
- */
-Geometry *
-GEOSGeomGetPointN_r(GEOSContextHandle_t extHandle, const Geometry *g1, int n)
-{
-    if ( 0 == extHandle )
-    {
         return NULL;
     }
 
-    GEOSContextHandleInternal_t *handle = 0;
-    handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
-    if ( 0 == handle->initialized )
+    /*
+     * Call only on LINESTRING
+     */
+    Geometry*
+    GEOSGeomGetStartPoint_r(GEOSContextHandle_t extHandle, const Geometry* g1)
     {
+        if(0 == extHandle) {
+            return NULL;
+        }
+
+        GEOSContextHandleInternal_t* handle = 0;
+        handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
+        if(0 == handle->initialized) {
+            return NULL;
+        }
+
+        try {
+            using geos::geom::LineString;
+            const LineString* ls = dynamic_cast<const LineString*>(g1);
+            if(! ls) {
+                handle->ERROR_MESSAGE("Argument is not a LineString");
+                return NULL;
+            }
+            return ls->getStartPoint();
+        }
+        catch(const std::exception& e) {
+            handle->ERROR_MESSAGE("%s", e.what());
+        }
+        catch(...) {
+            handle->ERROR_MESSAGE("Unknown exception thrown");
+        }
+
         return NULL;
     }
 
-    try
-    {
-    	using geos::geom::LineString;
-    	const LineString *ls = dynamic_cast<const LineString *>(g1);
-    	if ( ! ls )
-    	{
-    		handle->ERROR_MESSAGE("Argument is not a LineString");
-    		return NULL;
-    	}
-    	return ls->getPointN(n);
-    }
-    catch (const std::exception &e)
-    {
-        handle->ERROR_MESSAGE("%s", e.what());
-    }
-    catch (...)
+    /*
+     * Call only on LINESTRING
+     */
+    Geometry*
+    GEOSGeomGetEndPoint_r(GEOSContextHandle_t extHandle, const Geometry* g1)
     {
-        handle->ERROR_MESSAGE("Unknown exception thrown");
-    }
+        if(0 == extHandle) {
+            return NULL;
+        }
 
-    return NULL;
-}
+        GEOSContextHandleInternal_t* handle = 0;
+        handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
+        if(0 == handle->initialized) {
+            return NULL;
+        }
 
-/*
- * Call only on LINESTRING
- */
-Geometry *
-GEOSGeomGetStartPoint_r(GEOSContextHandle_t extHandle, const Geometry *g1)
-{
-    if ( 0 == extHandle )
-    {
-        return NULL;
-    }
+        try {
+            using geos::geom::LineString;
+            const LineString* ls = dynamic_cast<const LineString*>(g1);
+            if(! ls) {
+                handle->ERROR_MESSAGE("Argument is not a LineString");
+                return NULL;
+            }
+            return ls->getEndPoint();
+        }
+        catch(const std::exception& e) {
+            handle->ERROR_MESSAGE("%s", e.what());
+        }
+        catch(...) {
+            handle->ERROR_MESSAGE("Unknown exception thrown");
+        }
 
-    GEOSContextHandleInternal_t *handle = 0;
-    handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
-    if ( 0 == handle->initialized )
-    {
         return NULL;
     }
 
-    try
-    {
-    	using geos::geom::LineString;
-    	const LineString *ls = dynamic_cast<const LineString *>(g1);
-    	if ( ! ls )
-    	{
-    		handle->ERROR_MESSAGE("Argument is not a LineString");
-    		return NULL;
-    	}
-    	return ls->getStartPoint();
-    }
-    catch (const std::exception &e)
-    {
-        handle->ERROR_MESSAGE("%s", e.what());
-    }
-    catch (...)
+    /*
+     * Call only on LINESTRING or MULTILINESTRING
+     * return 2 on exception, 1 on true, 0 on false
+     */
+    char
+    GEOSisClosed_r(GEOSContextHandle_t extHandle, const Geometry* g1)
     {
-        handle->ERROR_MESSAGE("Unknown exception thrown");
-    }
-
-    return NULL;
-}
+        if(0 == extHandle) {
+            return 2;
+        }
 
-/*
- * Call only on LINESTRING
- */
-Geometry *
-GEOSGeomGetEndPoint_r(GEOSContextHandle_t extHandle, const Geometry *g1)
-{
-    if ( 0 == extHandle )
-    {
-        return NULL;
-    }
+        GEOSContextHandleInternal_t* handle = 0;
+        handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
+        if(0 == handle->initialized) {
+            return 2;
+        }
 
-    GEOSContextHandleInternal_t *handle = 0;
-    handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
-    if ( 0 == handle->initialized )
-    {
-        return NULL;
-    }
+        try {
+            using geos::geom::LineString;
+            using geos::geom::MultiLineString;
 
-    try
-    {
-    	using geos::geom::LineString;
-    	const LineString *ls = dynamic_cast<const LineString *>(g1);
-    	if ( ! ls )
-    	{
-    		handle->ERROR_MESSAGE("Argument is not a LineString");
-    		return NULL;
-    	}
-    	return ls->getEndPoint();
-    }
-    catch (const std::exception &e)
-    {
-        handle->ERROR_MESSAGE("%s", e.what());
-    }
-    catch (...)
-    {
-        handle->ERROR_MESSAGE("Unknown exception thrown");
-    }
+            const LineString* ls = dynamic_cast<const LineString*>(g1);
+            if(ls) {
+                return ls->isClosed();
+            }
 
-    return NULL;
-}
+            const MultiLineString* mls = dynamic_cast<const MultiLineString*>(g1);
+            if(mls) {
+                return mls->isClosed();
+            }
 
-/*
- * Call only on LINESTRING or MULTILINESTRING
- * return 2 on exception, 1 on true, 0 on false
- */
-char
-GEOSisClosed_r(GEOSContextHandle_t extHandle, const Geometry *g1)
-{
-    if ( 0 == extHandle )
-    {
-        return 2;
-    }
+            handle->ERROR_MESSAGE("Argument is not a LineString or MultiLineString");
+            return 2;
+        }
+        catch(const std::exception& e) {
+            handle->ERROR_MESSAGE("%s", e.what());
+        }
+        catch(...) {
+            handle->ERROR_MESSAGE("Unknown exception thrown");
+        }
 
-    GEOSContextHandleInternal_t *handle = 0;
-    handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
-    if ( 0 == handle->initialized )
-    {
         return 2;
     }
 
-    try
-    {
-    	using geos::geom::LineString;
-    	using geos::geom::MultiLineString;
-
-    	const LineString *ls = dynamic_cast<const LineString *>(g1);
-    	if ( ls ) {
-    	    return ls->isClosed();
-    	}
-
-    	const MultiLineString *mls = dynamic_cast<const MultiLineString *>(g1);
-    	if ( mls ) {
-    	    return mls->isClosed();
-    	}
-
-        handle->ERROR_MESSAGE("Argument is not a LineString or MultiLineString");
-        return 2;
-    }
-    catch (const std::exception &e)
-    {
-        handle->ERROR_MESSAGE("%s", e.what());
-    }
-    catch (...)
+    /*
+     * Call only on LINESTRING
+     * return 0 on exception, otherwise 1
+     */
+    int
+    GEOSGeomGetLength_r(GEOSContextHandle_t extHandle, const Geometry* g1, double* length)
     {
-        handle->ERROR_MESSAGE("Unknown exception thrown");
-    }
+        if(0 == extHandle) {
+            return 0;
+        }
 
-    return 2;
-}
+        GEOSContextHandleInternal_t* handle = 0;
+        handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
+        if(0 == handle->initialized) {
+            return 0;
+        }
 
-/*
- * Call only on LINESTRING
- * return 0 on exception, otherwise 1
- */
-int
-GEOSGeomGetLength_r(GEOSContextHandle_t extHandle, const Geometry *g1, double *length)
-{
-    if ( 0 == extHandle )
-    {
-        return 0;
-    }
+        try {
+            using geos::geom::LineString;
+            const LineString* ls = dynamic_cast<const LineString*>(g1);
+            if(! ls) {
+                handle->ERROR_MESSAGE("Argument is not a LineString");
+                return 0;
+            }
+            *length = ls->getLength();
+            return 1;
+        }
+        catch(const std::exception& e) {
+            handle->ERROR_MESSAGE("%s", e.what());
+        }
+        catch(...) {
+            handle->ERROR_MESSAGE("Unknown exception thrown");
+        }
 
-    GEOSContextHandleInternal_t *handle = 0;
-    handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
-    if ( 0 == handle->initialized )
-    {
         return 0;
     }
 
-    try
-    {
-    	using geos::geom::LineString;
-    	const LineString *ls = dynamic_cast<const LineString *>(g1);
-    	if ( ! ls )
-    	{
-    		handle->ERROR_MESSAGE("Argument is not a LineString");
-    		return 0;
-    	}
-    	*length = ls->getLength();
-    	return 1;
-    }
-    catch (const std::exception &e)
-    {
-        handle->ERROR_MESSAGE("%s", e.what());
-    }
-    catch (...)
+    /*
+     * Call only on LINESTRING
+     */
+    int
+    GEOSGeomGetNumPoints_r(GEOSContextHandle_t extHandle, const Geometry* g1)
     {
-        handle->ERROR_MESSAGE("Unknown exception thrown");
-    }
+        if(0 == extHandle) {
+            return -1;
+        }
 
-    return 0;
-}
+        GEOSContextHandleInternal_t* handle = 0;
+        handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
+        if(0 == handle->initialized) {
+            return -1;
+        }
 
-/*
- * Call only on LINESTRING
- */
-int
-GEOSGeomGetNumPoints_r(GEOSContextHandle_t extHandle, const Geometry *g1)
-{
-    if ( 0 == extHandle )
-    {
-        return -1;
-    }
+        try {
+            using geos::geom::LineString;
+            const LineString* ls = dynamic_cast<const LineString*>(g1);
+            if(! ls) {
+                handle->ERROR_MESSAGE("Argument is not a LineString");
+                return -1;
+            }
+            return static_cast<int>(ls->getNumPoints());
+        }
+        catch(const std::exception& e) {
+            handle->ERROR_MESSAGE("%s", e.what());
+        }
+        catch(...) {
+            handle->ERROR_MESSAGE("Unknown exception thrown");
+        }
 
-    GEOSContextHandleInternal_t *handle = 0;
-    handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
-    if ( 0 == handle->initialized )
-    {
         return -1;
     }
 
-    try
-    {
-    	using geos::geom::LineString;
-		const LineString *ls = dynamic_cast<const LineString *>(g1);
-		if ( ! ls )
-		{
-			handle->ERROR_MESSAGE("Argument is not a LineString");
-			return -1;
-		}
-		return static_cast<int>(ls->getNumPoints());
-    }
-    catch (const std::exception &e)
-    {
-        handle->ERROR_MESSAGE("%s", e.what());
-    }
-    catch (...)
+    /*
+     * For POINT
+     * returns 0 on exception, otherwise 1
+     */
+    int
+    GEOSGeomGetX_r(GEOSContextHandle_t extHandle, const Geometry* g1, double* x)
     {
-        handle->ERROR_MESSAGE("Unknown exception thrown");
-    }
+        if(0 == extHandle) {
+            return 0;
+        }
 
-    return -1;
-}
+        GEOSContextHandleInternal_t* handle = 0;
+        handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
+        if(0 == handle->initialized) {
+            return 0;
+        }
 
-/*
- * For POINT
- * returns 0 on exception, otherwise 1
- */
-int
-GEOSGeomGetX_r(GEOSContextHandle_t extHandle, const Geometry *g1, double *x)
-{
-    if ( 0 == extHandle )
-    {
-        return 0;
-    }
+        try {
+            using geos::geom::Point;
+            const Point* po = dynamic_cast<const Point*>(g1);
+            if(! po) {
+                handle->ERROR_MESSAGE("Argument is not a Point");
+                return 0;
+            }
+            *x = po->getX();
+            return 1;
+        }
+        catch(const std::exception& e) {
+            handle->ERROR_MESSAGE("%s", e.what());
+        }
+        catch(...) {
+            handle->ERROR_MESSAGE("Unknown exception thrown");
+        }
 
-    GEOSContextHandleInternal_t *handle = 0;
-    handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
-    if ( 0 == handle->initialized )
-    {
         return 0;
     }
 
-    try
-    {
-    	using geos::geom::Point;
-    	const Point *po = dynamic_cast<const Point *>(g1);
-    	if ( ! po )
-    	{
-    		handle->ERROR_MESSAGE("Argument is not a Point");
-    		return 0;
-    	}
-    	*x = po->getX();
-    	return 1;
-    }
-    catch (const std::exception &e)
+    /*
+     * For POINT
+     * returns 0 on exception, otherwise 1
+     */
+    int
+    GEOSGeomGetY_r(GEOSContextHandle_t extHandle, const Geometry* g1, double* y)
     {
-        handle->ERROR_MESSAGE("%s", e.what());
-    }
-    catch (...)
-    {
-        handle->ERROR_MESSAGE("Unknown exception thrown");
-    }
+        if(0 == extHandle) {
+            return 0;
+        }
 
-    return 0;
-}
+        GEOSContextHandleInternal_t* handle = 0;
+        handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
+        if(0 == handle->initialized) {
+            return 0;
+        }
 
-/*
- * For POINT
- * returns 0 on exception, otherwise 1
- */
-int
-GEOSGeomGetY_r(GEOSContextHandle_t extHandle, const Geometry *g1, double *y)
-{
-    if ( 0 == extHandle )
-    {
-        return 0;
-    }
+        try {
+            using geos::geom::Point;
+            const Point* po = dynamic_cast<const Point*>(g1);
+            if(! po) {
+                handle->ERROR_MESSAGE("Argument is not a Point");
+                return 0;
+            }
+            *y = po->getY();
+            return 1;
+        }
+        catch(const std::exception& e) {
+            handle->ERROR_MESSAGE("%s", e.what());
+        }
+        catch(...) {
+            handle->ERROR_MESSAGE("Unknown exception thrown");
+        }
 
-    GEOSContextHandleInternal_t *handle = 0;
-    handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
-    if ( 0 == handle->initialized )
-    {
         return 0;
     }
 
-    try
-    {
-    	using geos::geom::Point;
-    	const Point *po = dynamic_cast<const Point *>(g1);
-    	if ( ! po )
-    	{
-    		handle->ERROR_MESSAGE("Argument is not a Point");
-    		return 0;
-    	}
-    	*y = po->getY();
-    	return 1;
-    }
-    catch (const std::exception &e)
-    {
-        handle->ERROR_MESSAGE("%s", e.what());
-    }
-    catch (...)
+    /*
+     * For POINT
+     * returns 0 on exception, otherwise 1
+     */
+    int
+    GEOSGeomGetZ_r(GEOSContextHandle_t extHandle, const Geometry* g1, double* z)
     {
-        handle->ERROR_MESSAGE("Unknown exception thrown");
-    }
+        if(0 == extHandle) {
+            return 0;
+        }
 
-    return 0;
-}
+        GEOSContextHandleInternal_t* handle = 0;
+        handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
+        if(0 == handle->initialized) {
+            return 0;
+        }
 
-/*
- * For POINT
- * returns 0 on exception, otherwise 1
- */
-int
-GEOSGeomGetZ_r(GEOSContextHandle_t extHandle, const Geometry *g1, double *z)
-{
-    if ( 0 == extHandle )
-    {
-        return 0;
-    }
+        try {
+            using geos::geom::Point;
+            const Point* po = dynamic_cast<const Point*>(g1);
+            if(! po) {
+                handle->ERROR_MESSAGE("Argument is not a Point");
+                return 0;
+            }
+            *z = po->getZ();
+            return 1;
+        }
+        catch(const std::exception& e) {
+            handle->ERROR_MESSAGE("%s", e.what());
+        }
+        catch(...) {
+            handle->ERROR_MESSAGE("Unknown exception thrown");
+        }
 
-    GEOSContextHandleInternal_t *handle = 0;
-    handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
-    if ( 0 == handle->initialized )
-    {
         return 0;
     }
 
-    try
+    /*
+     * Call only on polygon
+     * Return a copy of the internal Geometry.
+     */
+    const Geometry*
+    GEOSGetExteriorRing_r(GEOSContextHandle_t extHandle, const Geometry* g1)
     {
-        using geos::geom::Point;
-        const Point *po = dynamic_cast<const Point *>(g1);
-        if ( ! po )
-        {
-            handle->ERROR_MESSAGE("Argument is not a Point");
-            return 0;
+        if(0 == extHandle) {
+            return NULL;
         }
-        *z = po->getZ();
-        return 1;
-    }
-    catch (const std::exception &e)
-    {
-        handle->ERROR_MESSAGE("%s", e.what());
-    }
-    catch (...)
-    {
-        handle->ERROR_MESSAGE("Unknown exception thrown");
-    }
 
-    return 0;
-}
+        GEOSContextHandleInternal_t* handle = 0;
+        handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
+        if(0 == handle->initialized) {
+            return NULL;
+        }
 
-/*
- * Call only on polygon
- * Return a copy of the internal Geometry.
- */
-const Geometry *
-GEOSGetExteriorRing_r(GEOSContextHandle_t extHandle, const Geometry *g1)
-{
-    if ( 0 == extHandle )
-    {
-        return NULL;
-    }
+        try {
+            const Polygon* p = dynamic_cast<const Polygon*>(g1);
+            if(! p) {
+                handle->ERROR_MESSAGE("Invalid argument (must be a Polygon)");
+                return NULL;
+            }
+            return p->getExteriorRing();
+        }
+        catch(const std::exception& e) {
+            handle->ERROR_MESSAGE("%s", e.what());
+        }
+        catch(...) {
+            handle->ERROR_MESSAGE("Unknown exception thrown");
+        }
 
-    GEOSContextHandleInternal_t *handle = 0;
-    handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
-    if ( 0 == handle->initialized )
-    {
         return NULL;
     }
 
-    try
+    /*
+     * Call only on polygon
+     * Return a pointer to internal storage, do not destroy it.
+     */
+    const Geometry*
+    GEOSGetInteriorRingN_r(GEOSContextHandle_t extHandle, const Geometry* g1, int n)
     {
-        const Polygon *p = dynamic_cast<const Polygon *>(g1);
-        if ( ! p )
-        {
-            handle->ERROR_MESSAGE("Invalid argument (must be a Polygon)");
+        if(0 == extHandle) {
             return NULL;
         }
-        return p->getExteriorRing();
-    }
-    catch (const std::exception &e)
-    {
-        handle->ERROR_MESSAGE("%s", e.what());
-    }
-    catch (...)
-    {
-        handle->ERROR_MESSAGE("Unknown exception thrown");
-    }
 
-    return NULL;
-}
+        GEOSContextHandleInternal_t* handle = 0;
+        handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
+        if(0 == handle->initialized) {
+            return NULL;
+        }
 
-/*
- * Call only on polygon
- * Return a pointer to internal storage, do not destroy it.
- */
-const Geometry *
-GEOSGetInteriorRingN_r(GEOSContextHandle_t extHandle, const Geometry *g1, int n)
-{
-    if ( 0 == extHandle )
-    {
-        return NULL;
-    }
+        try {
+            const Polygon* p = dynamic_cast<const Polygon*>(g1);
+            if(! p) {
+                handle->ERROR_MESSAGE("Invalid argument (must be a Polygon)");
+                return NULL;
+            }
+            return p->getInteriorRingN(n);
+        }
+        catch(const std::exception& e) {
+            handle->ERROR_MESSAGE("%s", e.what());
+        }
+        catch(...) {
+            handle->ERROR_MESSAGE("Unknown exception thrown");
+        }
 
-    GEOSContextHandleInternal_t *handle = 0;
-    handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
-    if ( 0 == handle->initialized )
-    {
         return NULL;
     }
 
-    try
+    Geometry*
+    GEOSGetCentroid_r(GEOSContextHandle_t extHandle, const Geometry* g)
     {
-        const Polygon *p = dynamic_cast<const Polygon *>(g1);
-        if ( ! p )
-        {
-            handle->ERROR_MESSAGE("Invalid argument (must be a Polygon)");
+        if(0 == extHandle) {
             return NULL;
         }
-        return p->getInteriorRingN(n);
-    }
-    catch (const std::exception &e)
-    {
-        handle->ERROR_MESSAGE("%s", e.what());
-    }
-    catch (...)
-    {
-        handle->ERROR_MESSAGE("Unknown exception thrown");
-    }
 
-    return NULL;
-}
+        GEOSContextHandleInternal_t* handle = 0;
+        handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
+        if(0 == handle->initialized) {
+            return NULL;
+        }
 
-Geometry *
-GEOSGetCentroid_r(GEOSContextHandle_t extHandle, const Geometry *g)
-{
-    if ( 0 == extHandle )
-    {
-        return NULL;
-    }
+        try {
+            Geometry* ret = g->getCentroid();
+            if(0 == ret) {
+                const GeometryFactory* gf = handle->geomFactory;
+                return gf->createPoint();
+            }
+            return ret;
+        }
+        catch(const std::exception& e) {
+            handle->ERROR_MESSAGE("%s", e.what());
+        }
+        catch(...) {
+            handle->ERROR_MESSAGE("Unknown exception thrown");
+        }
 
-    GEOSContextHandleInternal_t *handle = 0;
-    handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
-    if ( 0 == handle->initialized )
-    {
         return NULL;
     }
 
-    try
+    Geometry*
+    GEOSGeom_createEmptyCollection_r(GEOSContextHandle_t extHandle, int type)
     {
-        Geometry *ret = g->getCentroid();
-        if (0 == ret)
-        {
-            const GeometryFactory *gf = handle->geomFactory;
-            return gf->createPoint();
+        if(0 == extHandle) {
+            return NULL;
         }
-        return ret;
-    }
-    catch (const std::exception &e)
-    {
-        handle->ERROR_MESSAGE("%s", e.what());
-    }
-    catch (...)
-    {
-        handle->ERROR_MESSAGE("Unknown exception thrown");
-    }
-
-    return NULL;
-}
-
-Geometry *
-GEOSGeom_createEmptyCollection_r(GEOSContextHandle_t extHandle, int type)
-{
-    if ( 0 == extHandle )
-    {
-        return NULL;
-    }
 
-    GEOSContextHandleInternal_t *handle = 0;
-    handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
-    if ( 0 == handle->initialized )
-    {
-        return NULL;
-    }
+        GEOSContextHandleInternal_t* handle = 0;
+        handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
+        if(0 == handle->initialized) {
+            return NULL;
+        }
 
 #ifdef GEOS_DEBUG
-    char buf[256];
-    sprintf(buf, "createCollection: requested type %d", type);
-    handle->NOTICE_MESSAGE("%s", buf);// TODO: Can handle->NOTICE_MESSAGE format that directly?
+        char buf[256];
+        sprintf(buf, "createCollection: requested type %d", type);
+        handle->NOTICE_MESSAGE("%s", buf);// TODO: Can handle->NOTICE_MESSAGE format that directly?
 #endif
 
-    try
-    {
-        const GeometryFactory* gf = handle->geomFactory;
+        try {
+            const GeometryFactory* gf = handle->geomFactory;
 
-        Geometry *g = 0;
-        switch (type)
-        {
+            Geometry* g = 0;
+            switch(type) {
             case GEOS_GEOMETRYCOLLECTION:
                 g = gf->createGeometryCollection();
                 break;
@@ -3404,52 +3017,46 @@ GEOSGeom_createEmptyCollection_r(GEOSContextHandle_t extHandle, int type)
                 handle->ERROR_MESSAGE("Unsupported type request for GEOSGeom_createEmptyCollection_r");
                 g = 0;
 
+            }
+
+            return g;
+        }
+        catch(const std::exception& e) {
+            handle->ERROR_MESSAGE("%s", e.what());
+        }
+        catch(...) {
+            handle->ERROR_MESSAGE("Unknown exception thrown");
         }
 
-        return g;
-    }
-    catch (const std::exception &e)
-    {
-        handle->ERROR_MESSAGE("%s", e.what());
+        return 0;
     }
-    catch (...)
+
+    Geometry*
+    GEOSGeom_createCollection_r(GEOSContextHandle_t extHandle, int type, Geometry** geoms, unsigned int ngeoms)
     {
-        handle->ERROR_MESSAGE("Unknown exception thrown");
-    }
-
-    return 0;
-}
-
-Geometry *
-GEOSGeom_createCollection_r(GEOSContextHandle_t extHandle, int type, Geometry **geoms, unsigned int ngeoms)
-{
-    if ( 0 == extHandle )
-    {
-        return NULL;
-    }
+        if(0 == extHandle) {
+            return NULL;
+        }
 
-    GEOSContextHandleInternal_t *handle = 0;
-    handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
-    if ( 0 == handle->initialized )
-    {
-        return NULL;
-    }
+        GEOSContextHandleInternal_t* handle = 0;
+        handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
+        if(0 == handle->initialized) {
+            return NULL;
+        }
 
 #ifdef GEOS_DEBUG
-    char buf[256];
-    sprintf(buf, "PostGIS2GEOS_collection: requested type %d, ngeoms: %d",
-            type, ngeoms);
-    handle->NOTICE_MESSAGE("%s", buf);// TODO: Can handle->NOTICE_MESSAGE format that directly?
+        char buf[256];
+        sprintf(buf, "PostGIS2GEOS_collection: requested type %d, ngeoms: %d",
+                type, ngeoms);
+        handle->NOTICE_MESSAGE("%s", buf);// TODO: Can handle->NOTICE_MESSAGE format that directly?
 #endif
 
-    try
-    {
-        const GeometryFactory* gf = handle->geomFactory;
-        std::vector<Geometry*>* vgeoms = new std::vector<Geometry*>(geoms, geoms + ngeoms);
+        try {
+            const GeometryFactory* gf = handle->geomFactory;
+            std::vector<Geometry*>* vgeoms = new std::vector<Geometry*>(geoms, geoms + ngeoms);
 
-        Geometry *g = 0;
-        switch (type)
-        {
+            Geometry* g = 0;
+            switch(type) {
             case GEOS_GEOMETRYCOLLECTION:
                 g = gf->createGeometryCollection(vgeoms);
                 break;
@@ -3467,3757 +3074,3362 @@ GEOSGeom_createCollection_r(GEOSContextHandle_t extHandle, int type, Geometry **
                 delete vgeoms;
                 g = 0;
 
-        }
+            }
 
-        return g;
-    }
-    catch (const std::exception &e)
-    {
-        handle->ERROR_MESSAGE("%s", e.what());
-    }
-    catch (...)
-    {
-        handle->ERROR_MESSAGE("Unknown exception thrown");
-    }
-
-    return 0;
-}
+            return g;
+        }
+        catch(const std::exception& e) {
+            handle->ERROR_MESSAGE("%s", e.what());
+        }
+        catch(...) {
+            handle->ERROR_MESSAGE("Unknown exception thrown");
+        }
 
-Geometry *
-GEOSPolygonize_r(GEOSContextHandle_t extHandle, const Geometry * const * g, unsigned int ngeoms)
-{
-    if ( 0 == extHandle )
-    {
         return 0;
     }
 
-    GEOSContextHandleInternal_t *handle = 0;
-    handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
-    if ( 0 == handle->initialized )
+    Geometry*
+    GEOSPolygonize_r(GEOSContextHandle_t extHandle, const Geometry* const* g, unsigned int ngeoms)
     {
-        return 0;
-    }
-
-    Geometry *out = 0;
+        if(0 == extHandle) {
+            return 0;
+        }
 
-    try
-    {
-        // Polygonize
-        using geos::operation::polygonize::Polygonizer;
-        Polygonizer plgnzr;
-        for (std::size_t i = 0; i < ngeoms; ++i)
-        {
-            plgnzr.add(g[i]);
+        GEOSContextHandleInternal_t* handle = 0;
+        handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
+        if(0 == handle->initialized) {
+            return 0;
         }
 
+        Geometry* out = 0;
+
+        try {
+            // Polygonize
+            using geos::operation::polygonize::Polygonizer;
+            Polygonizer plgnzr;
+            for(std::size_t i = 0; i < ngeoms; ++i) {
+                plgnzr.add(g[i]);
+            }
+
 #if GEOS_DEBUG
-        handle->NOTICE_MESSAGE("geometry vector added to polygonizer");
+            handle->NOTICE_MESSAGE("geometry vector added to polygonizer");
 #endif
 
-        std::vector<Polygon*> *polys = plgnzr.getPolygons();
-        assert(0 != polys);
+            std::vector<Polygon*>* polys = plgnzr.getPolygons();
+            assert(0 != polys);
 
 #if GEOS_DEBUG
-        handle->NOTICE_MESSAGE("output polygons got");
+            handle->NOTICE_MESSAGE("output polygons got");
 #endif
 
-        // We need a vector of Geometry pointers, not Polygon pointers.
-        // STL vector doesn't allow transparent upcast of this
-        // nature, so we explicitly convert.
-        // (it's just a waste of processor and memory, btw)
-        //
-        // XXX mloskot: Why not to extent GeometryFactory to accept
-        // vector of polygons or extend Polygonizer to return list of Geometry*
-        // or add a wrapper which semantic is similar to:
-        // std::vector<as_polygon<Geometry*> >
-        std::vector<Geometry*> *polyvec = new std::vector<Geometry *>(polys->size());
-
-        for (std::size_t i = 0; i < polys->size(); ++i)
-        {
-            (*polyvec)[i] = (*polys)[i];
-        }
-        delete polys;
-        polys = 0;
+            // We need a vector of Geometry pointers, not Polygon pointers.
+            // STL vector doesn't allow transparent upcast of this
+            // nature, so we explicitly convert.
+            // (it's just a waste of processor and memory, btw)
+            //
+            // XXX mloskot: Why not to extent GeometryFactory to accept
+            // vector of polygons or extend Polygonizer to return list of Geometry*
+            // or add a wrapper which semantic is similar to:
+            // std::vector<as_polygon<Geometry*> >
+            std::vector<Geometry*>* polyvec = new std::vector<Geometry*>(polys->size());
+
+            for(std::size_t i = 0; i < polys->size(); ++i) {
+                (*polyvec)[i] = (*polys)[i];
+            }
+            delete polys;
+            polys = 0;
 
-        const GeometryFactory *gf = handle->geomFactory;
-
-        // The below takes ownership of the passed vector,
-        // so we must *not* delete it
-        out = gf->createGeometryCollection(polyvec);
-    }
-    catch (const std::exception &e)
-    {
-        handle->ERROR_MESSAGE("%s", e.what());
-    }
-    catch (...)
-    {
-        handle->ERROR_MESSAGE("Unknown exception thrown");
-    }
+            const GeometryFactory* gf = handle->geomFactory;
 
-    return out;
-}
+            // The below takes ownership of the passed vector,
+            // so we must *not* delete it
+            out = gf->createGeometryCollection(polyvec);
+        }
+        catch(const std::exception& e) {
+            handle->ERROR_MESSAGE("%s", e.what());
+        }
+        catch(...) {
+            handle->ERROR_MESSAGE("Unknown exception thrown");
+        }
 
-Geometry *
-GEOSPolygonizer_getCutEdges_r(GEOSContextHandle_t extHandle, const Geometry * const * g, unsigned int ngeoms)
-{
-    if ( 0 == extHandle )
-    {
-        return 0;
+        return out;
     }
 
-    GEOSContextHandleInternal_t *handle = 0;
-    handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
-    if ( 0 == handle->initialized )
+    Geometry*
+    GEOSPolygonizer_getCutEdges_r(GEOSContextHandle_t extHandle, const Geometry* const* g, unsigned int ngeoms)
     {
-        return 0;
-    }
-
-    Geometry *out = 0;
+        if(0 == extHandle) {
+            return 0;
+        }
 
-    try
-    {
-        // Polygonize
-        using geos::operation::polygonize::Polygonizer;
-        Polygonizer plgnzr;
-        for (std::size_t i = 0; i < ngeoms; ++i)
-        {
-            plgnzr.add(g[i]);
+        GEOSContextHandleInternal_t* handle = 0;
+        handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
+        if(0 == handle->initialized) {
+            return 0;
         }
 
-#if GEOS_DEBUG
-        handle->NOTICE_MESSAGE("geometry vector added to polygonizer");
-#endif
+        Geometry* out = 0;
 
-        const std::vector<const LineString *>& lines = plgnzr.getCutEdges();
+        try {
+            // Polygonize
+            using geos::operation::polygonize::Polygonizer;
+            Polygonizer plgnzr;
+            for(std::size_t i = 0; i < ngeoms; ++i) {
+                plgnzr.add(g[i]);
+            }
 
 #if GEOS_DEBUG
-        handle->NOTICE_MESSAGE("output polygons got");
+            handle->NOTICE_MESSAGE("geometry vector added to polygonizer");
 #endif
 
-        // We need a vector of Geometry pointers, not Polygon pointers.
-        // STL vector doesn't allow transparent upcast of this
-        // nature, so we explicitly convert.
-        // (it's just a waste of processor and memory, btw)
-        // XXX mloskot: See comment for GEOSPolygonize_r
-        std::vector<Geometry*> *linevec = new std::vector<Geometry *>(lines.size());
-
-        for (std::size_t i = 0, n=lines.size(); i < n; ++i)
-        {
-            (*linevec)[i] = lines[i]->clone();
-        }
-
-        const GeometryFactory *gf = handle->geomFactory;
-
-        // The below takes ownership of the passed vector,
-        // so we must *not* delete it
-        out = gf->createGeometryCollection(linevec);
-    }
-    catch (const std::exception &e)
-    {
-        handle->ERROR_MESSAGE("%s", e.what());
-    }
-    catch (...)
-    {
-        handle->ERROR_MESSAGE("Unknown exception thrown");
-    }
-
-    return out;
-}
-
-Geometry *
-GEOSPolygonize_full_r(GEOSContextHandle_t extHandle, const Geometry* g,
-	Geometry** cuts, Geometry** dangles, Geometry** invalid)
-{
-    if ( 0 == extHandle )
-    {
-        return 0;
-    }
-
-    GEOSContextHandleInternal_t *handle = 0;
-    handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
-    if ( 0 == handle->initialized )
-    {
-        return 0;
-    }
-
-    try
-    {
-        // Polygonize
-        using geos::operation::polygonize::Polygonizer;
-        Polygonizer plgnzr;
-        for (std::size_t i = 0; i <g->getNumGeometries(); ++i)
-        {
-            plgnzr.add(g->getGeometryN(i));
-        }
+            const std::vector<const LineString*>& lines = plgnzr.getCutEdges();
 
 #if GEOS_DEBUG
-        handle->NOTICE_MESSAGE("geometry vector added to polygonizer");
+            handle->NOTICE_MESSAGE("output polygons got");
 #endif
-        const GeometryFactory *gf = handle->geomFactory;
-
-	if ( cuts ) {
-
-        	const std::vector<const LineString *>& lines = plgnzr.getCutEdges();
-        	std::vector<Geometry*> *linevec = new std::vector<Geometry *>(lines.size());
-		for (std::size_t i = 0, n=lines.size(); i < n; ++i)
-		{
-		    (*linevec)[i] = lines[i]->clone();
-		}
-
-		// The below takes ownership of the passed vector,
-		// so we must *not* delete it
-		*cuts = gf->createGeometryCollection(linevec);
-	}
-
-	if ( dangles ) {
-
-        	const std::vector<const LineString *>& lines = plgnzr.getDangles();
-        	std::vector<Geometry*> *linevec = new std::vector<Geometry *>(lines.size());
-		for (std::size_t i = 0, n=lines.size(); i < n; ++i)
-		{
-		    (*linevec)[i] = lines[i]->clone();
-		}
 
-		// The below takes ownership of the passed vector,
-		// so we must *not* delete it
-		*dangles = gf->createGeometryCollection(linevec);
-	}
+            // We need a vector of Geometry pointers, not Polygon pointers.
+            // STL vector doesn't allow transparent upcast of this
+            // nature, so we explicitly convert.
+            // (it's just a waste of processor and memory, btw)
+            // XXX mloskot: See comment for GEOSPolygonize_r
+            std::vector<Geometry*>* linevec = new std::vector<Geometry*>(lines.size());
 
-	if ( invalid ) {
+            for(std::size_t i = 0, n = lines.size(); i < n; ++i) {
+                (*linevec)[i] = lines[i]->clone();
+            }
 
-        	const std::vector<LineString *>& lines = plgnzr.getInvalidRingLines();
-        	std::vector<Geometry*> *linevec = new std::vector<Geometry *>(lines.size());
-		for (std::size_t i = 0, n=lines.size(); i < n; ++i)
-		{
-		    (*linevec)[i] = lines[i]->clone();
-		}
-
-		// The below takes ownership of the passed vector,
-		// so we must *not* delete it
-		*invalid = gf->createGeometryCollection(linevec);
-	}
-
-        std::vector<Polygon*> *polys = plgnzr.getPolygons();
-        std::vector<Geometry*> *polyvec = new std::vector<Geometry *>(polys->size());
-        for (std::size_t i = 0; i < polys->size(); ++i)
-	{
-            (*polyvec)[i] = (*polys)[i];
-	}
-        delete polys;
-
-        return gf->createGeometryCollection(polyvec);
+            const GeometryFactory* gf = handle->geomFactory;
 
-    }
-    catch (const std::exception &e)
-    {
-        handle->ERROR_MESSAGE("%s", e.what());
-	return 0;
-    }
-    catch (...)
-    {
-        handle->ERROR_MESSAGE("Unknown exception thrown");
-	return 0;
-    }
-}
+            // The below takes ownership of the passed vector,
+            // so we must *not* delete it
+            out = gf->createGeometryCollection(linevec);
+        }
+        catch(const std::exception& e) {
+            handle->ERROR_MESSAGE("%s", e.what());
+        }
+        catch(...) {
+            handle->ERROR_MESSAGE("Unknown exception thrown");
+        }
 
-Geometry *
-GEOSLineMerge_r(GEOSContextHandle_t extHandle, const Geometry *g)
-{
-    if ( 0 == extHandle )
-    {
-        return 0;
+        return out;
     }
 
-    GEOSContextHandleInternal_t *handle = 0;
-    handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
-    if ( 0 == handle->initialized )
+    Geometry*
+    GEOSPolygonize_full_r(GEOSContextHandle_t extHandle, const Geometry* g,
+                          Geometry** cuts, Geometry** dangles, Geometry** invalid)
     {
-        return 0;
-    }
-
-    Geometry *out = 0;
+        if(0 == extHandle) {
+            return 0;
+        }
 
-    try
-    {
-        using geos::operation::linemerge::LineMerger;
-        LineMerger lmrgr;
-        lmrgr.add(g);
+        GEOSContextHandleInternal_t* handle = 0;
+        handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
+        if(0 == handle->initialized) {
+            return 0;
+        }
 
-        std::vector<LineString *>* lines = lmrgr.getMergedLineStrings();
-        assert(0 != lines);
+        try {
+            // Polygonize
+            using geos::operation::polygonize::Polygonizer;
+            Polygonizer plgnzr;
+            for(std::size_t i = 0; i < g->getNumGeometries(); ++i) {
+                plgnzr.add(g->getGeometryN(i));
+            }
 
 #if GEOS_DEBUG
-        handle->NOTICE_MESSAGE("output lines got");
+            handle->NOTICE_MESSAGE("geometry vector added to polygonizer");
 #endif
+            const GeometryFactory* gf = handle->geomFactory;
 
-        std::vector<Geometry *>*geoms = new std::vector<Geometry *>(lines->size());
-        for (std::vector<Geometry *>::size_type i = 0; i < lines->size(); ++i)
-        {
-            (*geoms)[i] = (*lines)[i];
-        }
-        delete lines;
-        lines = 0;
-
-        const GeometryFactory *gf = handle->geomFactory;
-        out = gf->buildGeometry(geoms);
-
-        // XXX: old version
-        //out = gf->createGeometryCollection(geoms);
-    }
-    catch (const std::exception &e)
-    {
-        handle->ERROR_MESSAGE("%s", e.what());
-    }
-    catch (...)
-    {
-        handle->ERROR_MESSAGE("Unknown exception thrown");
-    }
-
-    return out;
-}
-
-Geometry *
-GEOSReverse_r(GEOSContextHandle_t extHandle, const Geometry *g)
-{
-    assert(0 != g);
-
-    if ( 0 == extHandle )
-    {
-        return nullptr;
-    }
-
-    GEOSContextHandleInternal_t *handle = 0;
-    handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
-    if ( 0 == handle->initialized )
-    {
-        return nullptr;
-    }
-
-    try
-    {
-        return g->reverse();
-    }
-    catch (const std::exception &e)
-    {
-        handle->ERROR_MESSAGE("%s", e.what());
-    }
-    catch (...)
-    {
-        handle->ERROR_MESSAGE("Unknown exception thrown");
-    }
-
-    return nullptr;
-}
-
- void*
-GEOSGeom_getUserData_r(GEOSContextHandle_t extHandle, const Geometry *g)
-{
-    assert(0 != g);
-
-    if ( 0 == extHandle )
-    {
-        return 0;
-    }
-
-    GEOSContextHandleInternal_t *handle = 0;
-    handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
-    if ( 0 == handle->initialized )
-    {
-        return 0;
-    }
-
-    try
-    {
-        return g->getUserData();
-    }
-    catch (const std::exception &e)
-    {
-        handle->ERROR_MESSAGE("%s", e.what());
-    }
-    catch (...)
-    {
-        handle->ERROR_MESSAGE("Unknown exception thrown");
-    }
-
-    return NULL;
-}
-
-int
-GEOSGetSRID_r(GEOSContextHandle_t extHandle, const Geometry *g)
-{
-    assert(0 != g);
-
-    if ( 0 == extHandle )
-    {
-        return 0;
-    }
-
-    GEOSContextHandleInternal_t *handle = 0;
-    handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
-    if ( 0 == handle->initialized )
-    {
-        return 0;
-    }
-
-    try
-    {
-        return g->getSRID();
-    }
-    catch (const std::exception &e)
-    {
-        handle->ERROR_MESSAGE("%s", e.what());
-    }
-    catch (...)
-    {
-        handle->ERROR_MESSAGE("Unknown exception thrown");
-    }
-
-    return 0;
-}
-
-const char* GEOSversion()
-{
-  static char version[256];
-  sprintf(version, "%s " GEOS_REVISION, GEOS_CAPI_VERSION);
-  return version;
-}
-
-const char* GEOSjtsport()
-{
-    return GEOS_JTS_PORT;
-}
-
-char
-GEOSHasZ_r(GEOSContextHandle_t extHandle, const Geometry *g)
-{
-    assert(0 != g);
-
-    if ( 0 == extHandle )
-    {
-        return -1;
-    }
-
-    GEOSContextHandleInternal_t *handle = 0;
-    handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
-    if ( 0 == handle->initialized )
-    {
-        return -1;
-    }
-
-    if (g->isEmpty())
-    {
-        return false;
-    }
-    assert(0 != g->getCoordinate());
-
-    double az = g->getCoordinate()->z;
-    //handle->ERROR_MESSAGE("ZCoord: %g", az);
-
-    return static_cast<char>(std::isfinite(az));
-}
-
-int
-GEOS_getWKBOutputDims_r(GEOSContextHandle_t extHandle)
-{
-    if ( 0 == extHandle )
-    {
-        return -1;
-    }
-
-    GEOSContextHandleInternal_t *handle = 0;
-    handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
-    if ( 0 == handle->initialized )
-    {
-        return -1;
-    }
-
-    return handle->WKBOutputDims;
-}
-
-int
-GEOS_setWKBOutputDims_r(GEOSContextHandle_t extHandle, int newdims)
-{
-    if ( 0 == extHandle )
-    {
-        return -1;
-    }
-
-    GEOSContextHandleInternal_t *handle = 0;
-    handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
-    if ( 0 == handle->initialized )
-    {
-        return -1;
-    }
-
-    if ( newdims < 2 || newdims > 3 )
-    {
-        handle->ERROR_MESSAGE("WKB output dimensions out of range 2..3");
-    }
-
-    const int olddims = handle->WKBOutputDims;
-    handle->WKBOutputDims = newdims;
-
-    return olddims;
-}
-
-int
-GEOS_getWKBByteOrder_r(GEOSContextHandle_t extHandle)
-{
-    if ( 0 == extHandle )
-    {
-        return -1;
-    }
-
-    GEOSContextHandleInternal_t *handle = 0;
-    handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
-    if ( 0 == handle->initialized )
-    {
-        return -1;
-    }
-
-    return handle->WKBByteOrder;
-}
-
-int
-GEOS_setWKBByteOrder_r(GEOSContextHandle_t extHandle, int byteOrder)
-{
-    if ( 0 == extHandle )
-    {
-        return -1;
-    }
-
-    GEOSContextHandleInternal_t *handle = 0;
-    handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
-    if ( 0 == handle->initialized )
-    {
-        return -1;
-    }
-
-    const int oldByteOrder = handle->WKBByteOrder;
-    handle->WKBByteOrder = byteOrder;
-
-    return oldByteOrder;
-}
-
-
-CoordinateSequence *
-GEOSCoordSeq_create_r(GEOSContextHandle_t extHandle, unsigned int size, unsigned int dims)
-{
-    if ( 0 == extHandle )
-    {
-        return NULL;
-    }
-
-    GEOSContextHandleInternal_t *handle = 0;
-    handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
-    if ( 0 == handle->initialized )
-    {
-        return NULL;
-    }
-
-    try
-    {
-        const GeometryFactory *gf = handle->geomFactory;
-        return gf->getCoordinateSequenceFactory()->create(size, dims);
-    }
-    catch (const std::exception &e)
-    {
-        handle->ERROR_MESSAGE("%s", e.what());
-    }
-    catch (...)
-    {
-        handle->ERROR_MESSAGE("Unknown exception thrown");
-    }
-
-    return NULL;
-}
-
-int
-GEOSCoordSeq_setOrdinate_r(GEOSContextHandle_t extHandle, CoordinateSequence *cs,
-                           unsigned int idx, unsigned int dim, double val)
-{
-    assert(0 != cs);
-    if ( 0 == extHandle )
-    {
-        return 0;
-    }
-
-    GEOSContextHandleInternal_t *handle = 0;
-    handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
-    if ( 0 == handle->initialized )
-    {
-        return 0;
-    }
-
-    try
-    {
-        cs->setOrdinate(idx, dim, val);
-        return 1;
-    }
-    catch (const std::exception &e)
-    {
-        handle->ERROR_MESSAGE("%s", e.what());
-    }
-    catch (...)
-    {
-        handle->ERROR_MESSAGE("Unknown exception thrown");
-    }
-
-    return 0;
-}
-
-int
-GEOSCoordSeq_setX_r(GEOSContextHandle_t extHandle, CoordinateSequence *s, unsigned int idx, double val)
-{
-    return GEOSCoordSeq_setOrdinate_r(extHandle, s, idx, 0, val);
-}
-
-int
-GEOSCoordSeq_setY_r(GEOSContextHandle_t extHandle, CoordinateSequence *s, unsigned int idx, double val)
-{
-    return GEOSCoordSeq_setOrdinate_r(extHandle, s, idx, 1, val);
-}
-
-int
-GEOSCoordSeq_setZ_r(GEOSContextHandle_t extHandle, CoordinateSequence *s, unsigned int idx, double val)
-{
-    return GEOSCoordSeq_setOrdinate_r(extHandle, s, idx, 2, val);
-}
+            if(cuts) {
 
-CoordinateSequence *
-GEOSCoordSeq_clone_r(GEOSContextHandle_t extHandle, const CoordinateSequence *cs)
-{
-    assert(0 != cs);
+                const std::vector<const LineString*>& lines = plgnzr.getCutEdges();
+                std::vector<Geometry*>* linevec = new std::vector<Geometry*>(lines.size());
+                for(std::size_t i = 0, n = lines.size(); i < n; ++i) {
+                    (*linevec)[i] = lines[i]->clone();
+                }
 
-    if ( 0 == extHandle )
-    {
-        return NULL;
-    }
+                // The below takes ownership of the passed vector,
+                // so we must *not* delete it
+                *cuts = gf->createGeometryCollection(linevec);
+            }
 
-    GEOSContextHandleInternal_t *handle = 0;
-    handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
-    if ( 0 == handle->initialized )
-    {
-        return NULL;
-    }
+            if(dangles) {
 
-    try
-    {
-        return cs->clone();
-    }
-    catch (const std::exception &e)
-    {
-        handle->ERROR_MESSAGE("%s", e.what());
-    }
-    catch (...)
-    {
-        handle->ERROR_MESSAGE("Unknown exception thrown");
-    }
+                const std::vector<const LineString*>& lines = plgnzr.getDangles();
+                std::vector<Geometry*>* linevec = new std::vector<Geometry*>(lines.size());
+                for(std::size_t i = 0, n = lines.size(); i < n; ++i) {
+                    (*linevec)[i] = lines[i]->clone();
+                }
 
-    return NULL;
-}
+                // The below takes ownership of the passed vector,
+                // so we must *not* delete it
+                *dangles = gf->createGeometryCollection(linevec);
+            }
 
-int
-GEOSCoordSeq_getOrdinate_r(GEOSContextHandle_t extHandle, const CoordinateSequence *cs,
-                           unsigned int idx, unsigned int dim, double *val)
-{
-    assert(0 != cs);
-    assert(0 != val);
+            if(invalid) {
 
-    if ( 0 == extHandle )
-    {
-        return 0;
-    }
+                const std::vector<LineString*>& lines = plgnzr.getInvalidRingLines();
+                std::vector<Geometry*>* linevec = new std::vector<Geometry*>(lines.size());
+                for(std::size_t i = 0, n = lines.size(); i < n; ++i) {
+                    (*linevec)[i] = lines[i]->clone();
+                }
 
-    GEOSContextHandleInternal_t *handle = 0;
-    handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
-    if ( 0 == handle->initialized )
-    {
-        return 0;
-    }
+                // The below takes ownership of the passed vector,
+                // so we must *not* delete it
+                *invalid = gf->createGeometryCollection(linevec);
+            }
 
-    try
-    {
-        double d = cs->getOrdinate(idx, dim);
-        *val = d;
+            std::vector<Polygon*>* polys = plgnzr.getPolygons();
+            std::vector<Geometry*>* polyvec = new std::vector<Geometry*>(polys->size());
+            for(std::size_t i = 0; i < polys->size(); ++i) {
+                (*polyvec)[i] = (*polys)[i];
+            }
+            delete polys;
 
-        return 1;
-    }
-    catch (const std::exception &e)
-    {
-        handle->ERROR_MESSAGE("%s", e.what());
-    }
-    catch (...)
-    {
-        handle->ERROR_MESSAGE("Unknown exception thrown");
-    }
-
-    return 0;
-}
-
-int
-GEOSCoordSeq_getX_r(GEOSContextHandle_t extHandle, const CoordinateSequence *s, unsigned int idx, double *val)
-{
-    return GEOSCoordSeq_getOrdinate_r(extHandle, s, idx, 0, val);
-}
-
-int
-GEOSCoordSeq_getY_r(GEOSContextHandle_t extHandle, const CoordinateSequence *s, unsigned int idx, double *val)
-{
-    return GEOSCoordSeq_getOrdinate_r(extHandle, s, idx, 1, val);
-}
-
-int
-GEOSCoordSeq_getZ_r(GEOSContextHandle_t extHandle, const CoordinateSequence *s, unsigned int idx, double *val)
-{
-    return GEOSCoordSeq_getOrdinate_r(extHandle, s, idx, 2, val);
-}
-
-int
-GEOSCoordSeq_getSize_r(GEOSContextHandle_t extHandle, const CoordinateSequence *cs, unsigned int *size)
-{
-    assert(0 != cs);
-    assert(0 != size);
-
-    if ( 0 == extHandle )
-    {
-        return 0;
-    }
+            return gf->createGeometryCollection(polyvec);
 
-    GEOSContextHandleInternal_t *handle = 0;
-    handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
-    if ( 0 == handle->initialized )
-    {
-        return 0;
-    }
-
-    try
-    {
-        const std::size_t sz = cs->getSize();
-        *size = static_cast<unsigned int>(sz);
-        return 1;
-    }
-    catch (const std::exception &e)
-    {
-        handle->ERROR_MESSAGE("%s", e.what());
-    }
-    catch (...)
-    {
-        handle->ERROR_MESSAGE("Unknown exception thrown");
-    }
-
-    return 0;
-}
-
-int
-GEOSCoordSeq_getDimensions_r(GEOSContextHandle_t extHandle, const CoordinateSequence *cs, unsigned int *dims)
-{
-    assert(0 != cs);
-    assert(0 != dims);
-
-    if ( 0 == extHandle )
-    {
-        return 0;
-    }
-
-    GEOSContextHandleInternal_t *handle = 0;
-    handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
-    if ( 0 == handle->initialized )
-    {
-        return 0;
-    }
-
-    try
-    {
-        const std::size_t dim = cs->getDimension();
-        *dims = static_cast<unsigned int>(dim);
-
-        return 1;
-    }
-    catch (const std::exception &e)
-    {
-        handle->ERROR_MESSAGE("%s", e.what());
+        }
+        catch(const std::exception& e) {
+            handle->ERROR_MESSAGE("%s", e.what());
+            return 0;
+        }
+        catch(...) {
+            handle->ERROR_MESSAGE("Unknown exception thrown");
+            return 0;
+        }
     }
 
-    catch (...)
+    Geometry*
+    GEOSLineMerge_r(GEOSContextHandle_t extHandle, const Geometry* g)
     {
-        handle->ERROR_MESSAGE("Unknown exception thrown");
-    }
+        if(0 == extHandle) {
+            return 0;
+        }
 
-    return 0;
-}
+        GEOSContextHandleInternal_t* handle = 0;
+        handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
+        if(0 == handle->initialized) {
+            return 0;
+        }
 
-int
-GEOSCoordSeq_isCCW_r(GEOSContextHandle_t extHandle, const CoordinateSequence *cs, char *val)
-{
-    assert(cs != nullptr);
-    assert(val != nullptr);
+        Geometry* out = 0;
 
-    if (extHandle == nullptr) {
-        return 0;
-    }
+        try {
+            using geos::operation::linemerge::LineMerger;
+            LineMerger lmrgr;
+            lmrgr.add(g);
 
-    GEOSContextHandleInternal_t *handle = nullptr;
-    handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
-    if ( 0 == handle->initialized )
-    {
-        return 0;
-    }
-    try
-    {
-        *val = geos::algorithm::Orientation::isCCW(cs);
-        return 1;
-    }
-    catch (const std::exception &e)
-    {
-        handle->ERROR_MESSAGE("%s", e.what());
-    }
+            std::vector<LineString*>* lines = lmrgr.getMergedLineStrings();
+            assert(0 != lines);
 
-    catch (...)
-    {
-        handle->ERROR_MESSAGE("Unknown exception thrown");
-    }
+#if GEOS_DEBUG
+            handle->NOTICE_MESSAGE("output lines got");
+#endif
 
-    return 0;
-}
+            std::vector<Geometry*>* geoms = new std::vector<Geometry*>(lines->size());
+            for(std::vector<Geometry*>::size_type i = 0; i < lines->size(); ++i) {
+                (*geoms)[i] = (*lines)[i];
+            }
+            delete lines;
+            lines = 0;
 
-void
-GEOSCoordSeq_destroy_r(GEOSContextHandle_t extHandle, CoordinateSequence *s)
-{
-    GEOSContextHandleInternal_t *handle = 0;
+            const GeometryFactory* gf = handle->geomFactory;
+            out = gf->buildGeometry(geoms);
 
-    try
-    {
-        delete s;
-    }
-    catch (const std::exception &e)
-    {
-        if ( 0 == extHandle )
-        {
-            return;
+            // XXX: old version
+            //out = gf->createGeometryCollection(geoms);
         }
-
-        handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
-        if ( 0 == handle->initialized )
-        {
-            return;
+        catch(const std::exception& e) {
+            handle->ERROR_MESSAGE("%s", e.what());
+        }
+        catch(...) {
+            handle->ERROR_MESSAGE("Unknown exception thrown");
         }
 
-        handle->ERROR_MESSAGE("%s", e.what());
+        return out;
     }
-    catch (...)
+
+    Geometry*
+    GEOSReverse_r(GEOSContextHandle_t extHandle, const Geometry* g)
     {
-        if ( 0 == extHandle )
-        {
-            return;
+        assert(0 != g);
+
+        if(0 == extHandle) {
+            return nullptr;
         }
 
+        GEOSContextHandleInternal_t* handle = 0;
         handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
-        if ( 0 == handle->initialized )
-        {
-            return;
+        if(0 == handle->initialized) {
+            return nullptr;
         }
 
-        handle->ERROR_MESSAGE("Unknown exception thrown");
-    }
-}
-
-const CoordinateSequence *
-GEOSGeom_getCoordSeq_r(GEOSContextHandle_t extHandle, const Geometry *g)
-{
-    if ( 0 == extHandle )
-    {
-        return 0;
-    }
+        try {
+            return g->reverse();
+        }
+        catch(const std::exception& e) {
+            handle->ERROR_MESSAGE("%s", e.what());
+        }
+        catch(...) {
+            handle->ERROR_MESSAGE("Unknown exception thrown");
+        }
 
-    GEOSContextHandleInternal_t *handle = 0;
-    handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
-    if ( 0 == handle->initialized )
-    {
-        return 0;
+        return nullptr;
     }
 
-    try
+    void*
+    GEOSGeom_getUserData_r(GEOSContextHandle_t extHandle, const Geometry* g)
     {
-        using geos::geom::Point;
+        assert(0 != g);
 
-        const LineString *ls = dynamic_cast<const LineString *>(g);
-        if ( ls )
-        {
-            return ls->getCoordinatesRO();
+        if(0 == extHandle) {
+            return 0;
         }
 
-        const Point *p = dynamic_cast<const Point *>(g);
-        if ( p )
-        {
-            return p->getCoordinatesRO();
+        GEOSContextHandleInternal_t* handle = 0;
+        handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
+        if(0 == handle->initialized) {
+            return 0;
         }
 
-        handle->ERROR_MESSAGE("Geometry must be a Point or LineString");
-        return 0;
-    }
-    catch (const std::exception &e)
-    {
-        handle->ERROR_MESSAGE("%s", e.what());
-    }
-    catch (...)
-    {
-        handle->ERROR_MESSAGE("Unknown exception thrown");
-    }
-
-    return 0;
-}
+        try {
+            return g->getUserData();
+        }
+        catch(const std::exception& e) {
+            handle->ERROR_MESSAGE("%s", e.what());
+        }
+        catch(...) {
+            handle->ERROR_MESSAGE("Unknown exception thrown");
+        }
 
-Geometry *
-GEOSGeom_createEmptyPoint_r(GEOSContextHandle_t extHandle)
-{
-    if ( 0 == extHandle )
-    {
         return NULL;
     }
 
-    GEOSContextHandleInternal_t *handle = 0;
-    handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
-    if ( 0 == handle->initialized )
+    int
+    GEOSGetSRID_r(GEOSContextHandle_t extHandle, const Geometry* g)
     {
-        return NULL;
-    }
+        assert(0 != g);
 
-    try
-    {
-        const GeometryFactory *gf = handle->geomFactory;
-        return gf->createPoint();
-    }
-    catch (const std::exception &e)
-    {
-        handle->ERROR_MESSAGE("%s", e.what());
-    }
-    catch (...)
-    {
-        handle->ERROR_MESSAGE("Unknown exception thrown");
-    }
+        if(0 == extHandle) {
+            return 0;
+        }
 
-    return NULL;
-}
+        GEOSContextHandleInternal_t* handle = 0;
+        handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
+        if(0 == handle->initialized) {
+            return 0;
+        }
 
-Geometry *
-GEOSGeom_createPoint_r(GEOSContextHandle_t extHandle, CoordinateSequence *cs)
-{
-    if ( 0 == extHandle )
-    {
-        return 0;
-    }
+        try {
+            return g->getSRID();
+        }
+        catch(const std::exception& e) {
+            handle->ERROR_MESSAGE("%s", e.what());
+        }
+        catch(...) {
+            handle->ERROR_MESSAGE("Unknown exception thrown");
+        }
 
-    GEOSContextHandleInternal_t *handle = 0;
-    handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
-    if ( 0 == handle->initialized )
-    {
         return 0;
     }
 
-    try
-    {
-        const GeometryFactory *gf = handle->geomFactory;
-        return gf->createPoint(cs);
-    }
-    catch (const std::exception &e)
-    {
-        handle->ERROR_MESSAGE("%s", e.what());
-    }
-    catch (...)
+    const char* GEOSversion()
     {
-        handle->ERROR_MESSAGE("Unknown exception thrown");
+        static char version[256];
+        sprintf(version, "%s " GEOS_REVISION, GEOS_CAPI_VERSION);
+        return version;
     }
 
-    return 0;
-}
-
-Geometry *
-GEOSGeom_createLinearRing_r(GEOSContextHandle_t extHandle, CoordinateSequence *cs)
-{
-    if ( 0 == extHandle )
+    const char* GEOSjtsport()
     {
-        return NULL;
+        return GEOS_JTS_PORT;
     }
 
-    GEOSContextHandleInternal_t *handle = 0;
-    handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
-    if ( 0 == handle->initialized )
+    char
+    GEOSHasZ_r(GEOSContextHandle_t extHandle, const Geometry* g)
     {
-        return NULL;
-    }
+        assert(0 != g);
 
-    try
-    {
-        const GeometryFactory *gf = handle->geomFactory;
+        if(0 == extHandle) {
+            return -1;
+        }
 
-        return gf->createLinearRing(cs);
-    }
-    catch (const std::exception &e)
-    {
-        handle->ERROR_MESSAGE("%s", e.what());
-    }
-    catch (...)
-    {
-        handle->ERROR_MESSAGE("Unknown exception thrown");
-    }
+        GEOSContextHandleInternal_t* handle = 0;
+        handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
+        if(0 == handle->initialized) {
+            return -1;
+        }
 
-    return NULL;
-}
+        if(g->isEmpty()) {
+            return false;
+        }
+        assert(0 != g->getCoordinate());
 
-Geometry *
-GEOSGeom_createEmptyLineString_r(GEOSContextHandle_t extHandle)
-{
-    if ( 0 == extHandle )
-    {
-        return NULL;
-    }
+        double az = g->getCoordinate()->z;
+        //handle->ERROR_MESSAGE("ZCoord: %g", az);
 
-    GEOSContextHandleInternal_t *handle = 0;
-    handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
-    if ( 0 == handle->initialized )
-    {
-        return NULL;
+        return static_cast<char>(std::isfinite(az));
     }
 
-    try
-    {
-        const GeometryFactory *gf = handle->geomFactory;
-
-        return gf->createLineString();
-    }
-    catch (const std::exception &e)
-    {
-        handle->ERROR_MESSAGE("%s", e.what());
-    }
-    catch (...)
+    int
+    GEOS_getWKBOutputDims_r(GEOSContextHandle_t extHandle)
     {
-        handle->ERROR_MESSAGE("Unknown exception thrown");
-    }
+        if(0 == extHandle) {
+            return -1;
+        }
 
-    return NULL;
-}
+        GEOSContextHandleInternal_t* handle = 0;
+        handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
+        if(0 == handle->initialized) {
+            return -1;
+        }
 
-Geometry *
-GEOSGeom_createLineString_r(GEOSContextHandle_t extHandle, CoordinateSequence *cs)
-{
-    if ( 0 == extHandle )
-    {
-        return NULL;
+        return handle->WKBOutputDims;
     }
 
-    GEOSContextHandleInternal_t *handle = 0;
-    handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
-    if ( 0 == handle->initialized )
+    int
+    GEOS_setWKBOutputDims_r(GEOSContextHandle_t extHandle, int newdims)
     {
-        return NULL;
-    }
+        if(0 == extHandle) {
+            return -1;
+        }
 
-    try
-    {
-        const GeometryFactory *gf = handle->geomFactory;
+        GEOSContextHandleInternal_t* handle = 0;
+        handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
+        if(0 == handle->initialized) {
+            return -1;
+        }
 
-        return gf->createLineString(cs);
-    }
-    catch (const std::exception &e)
-    {
-        handle->ERROR_MESSAGE("%s", e.what());
-    }
-    catch (...)
-    {
-        handle->ERROR_MESSAGE("Unknown exception thrown");
-    }
+        if(newdims < 2 || newdims > 3) {
+            handle->ERROR_MESSAGE("WKB output dimensions out of range 2..3");
+        }
 
-    return NULL;
-}
+        const int olddims = handle->WKBOutputDims;
+        handle->WKBOutputDims = newdims;
 
-Geometry *
-GEOSGeom_createEmptyPolygon_r(GEOSContextHandle_t extHandle)
-{
-    if ( 0 == extHandle )
-    {
-        return NULL;
+        return olddims;
     }
 
-    GEOSContextHandleInternal_t *handle = 0;
-    handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
-    if ( 0 == handle->initialized )
+    int
+    GEOS_getWKBByteOrder_r(GEOSContextHandle_t extHandle)
     {
-        return NULL;
-    }
+        if(0 == extHandle) {
+            return -1;
+        }
 
-    try
-    {
-        const GeometryFactory *gf = handle->geomFactory;
-        return gf->createPolygon();
-    }
-    catch (const std::exception &e)
-    {
-        handle->ERROR_MESSAGE("%s", e.what());
+        GEOSContextHandleInternal_t* handle = 0;
+        handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
+        if(0 == handle->initialized) {
+            return -1;
+        }
+
+        return handle->WKBByteOrder;
     }
-    catch (...)
+
+    int
+    GEOS_setWKBByteOrder_r(GEOSContextHandle_t extHandle, int byteOrder)
     {
-        handle->ERROR_MESSAGE("Unknown exception thrown");
-    }
+        if(0 == extHandle) {
+            return -1;
+        }
 
-    return NULL;
-}
+        GEOSContextHandleInternal_t* handle = 0;
+        handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
+        if(0 == handle->initialized) {
+            return -1;
+        }
 
-Geometry *
-GEOSGeom_createPolygon_r(GEOSContextHandle_t extHandle, Geometry *shell, Geometry **holes, unsigned int nholes)
-{
-    // FIXME: holes must be non-nullptr or may be nullptr?
-    //assert(0 != holes);
+        const int oldByteOrder = handle->WKBByteOrder;
+        handle->WKBByteOrder = byteOrder;
 
-    if ( 0 == extHandle )
-    {
-        return NULL;
+        return oldByteOrder;
     }
 
-    GEOSContextHandleInternal_t *handle = 0;
-    handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
-    if ( 0 == handle->initialized )
-    {
-        return NULL;
-    }
 
-    try
+    CoordinateSequence*
+    GEOSCoordSeq_create_r(GEOSContextHandle_t extHandle, unsigned int size, unsigned int dims)
     {
-        using geos::geom::LinearRing;
-
-        std::vector<Geometry *> *vholes = new std::vector<Geometry *>(holes, holes + nholes);
-
-        LinearRing *nshell = dynamic_cast<LinearRing *>(shell);
-        if ( ! nshell )
-        {
-            handle->ERROR_MESSAGE("Shell is not a LinearRing");
-            delete vholes;
+        if(0 == extHandle) {
             return NULL;
         }
-        const GeometryFactory *gf = handle->geomFactory;
-
-        return gf->createPolygon(nshell, vholes);
-    }
-    catch (const std::exception &e)
-    {
-        handle->ERROR_MESSAGE("%s", e.what());
-    }
-    catch (...)
-    {
-        handle->ERROR_MESSAGE("Unknown exception thrown");
-    }
-
-    return NULL;
-}
 
-Geometry *
-GEOSGeom_clone_r(GEOSContextHandle_t extHandle, const Geometry *g)
-{
-    assert(0 != g);
+        GEOSContextHandleInternal_t* handle = 0;
+        handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
+        if(0 == handle->initialized) {
+            return NULL;
+        }
 
-    if ( 0 == extHandle )
-    {
-        return NULL;
-    }
+        try {
+            const GeometryFactory* gf = handle->geomFactory;
+            return gf->getCoordinateSequenceFactory()->create(size, dims);
+        }
+        catch(const std::exception& e) {
+            handle->ERROR_MESSAGE("%s", e.what());
+        }
+        catch(...) {
+            handle->ERROR_MESSAGE("Unknown exception thrown");
+        }
 
-    GEOSContextHandleInternal_t *handle = 0;
-    handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
-    if ( 0 == handle->initialized )
-    {
         return NULL;
     }
 
-    try
-    {
-        return g->clone();
-    }
-    catch (const std::exception &e)
-    {
-        handle->ERROR_MESSAGE("%s", e.what());
-    }
-    catch (...)
+    int
+    GEOSCoordSeq_setOrdinate_r(GEOSContextHandle_t extHandle, CoordinateSequence* cs,
+                               unsigned int idx, unsigned int dim, double val)
     {
-        handle->ERROR_MESSAGE("Unknown exception thrown");
-    }
-
-    return NULL;
-}
+        assert(0 != cs);
+        if(0 == extHandle) {
+            return 0;
+        }
 
-GEOSGeometry *
-GEOSGeom_setPrecision_r(GEOSContextHandle_t extHandle, const GEOSGeometry *g,
-                                          double gridSize, int flags)
-{
-    using namespace geos::geom;
+        GEOSContextHandleInternal_t* handle = 0;
+        handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
+        if(0 == handle->initialized) {
+            return 0;
+        }
 
-    assert(0 != g);
+        try {
+            cs->setOrdinate(idx, dim, val);
+            return 1;
+        }
+        catch(const std::exception& e) {
+            handle->ERROR_MESSAGE("%s", e.what());
+        }
+        catch(...) {
+            handle->ERROR_MESSAGE("Unknown exception thrown");
+        }
 
-    if ( 0 == extHandle )
-    {
-        return NULL;
+        return 0;
     }
 
-    GEOSContextHandleInternal_t *handle = 0;
-    handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
-    if ( 0 == handle->initialized )
+    int
+    GEOSCoordSeq_setX_r(GEOSContextHandle_t extHandle, CoordinateSequence* s, unsigned int idx, double val)
     {
-        return NULL;
+        return GEOSCoordSeq_setOrdinate_r(extHandle, s, idx, 0, val);
     }
 
-    try
+    int
+    GEOSCoordSeq_setY_r(GEOSContextHandle_t extHandle, CoordinateSequence* s, unsigned int idx, double val)
     {
-        const PrecisionModel *pm = g->getPrecisionModel();
-        double cursize = pm->isFloating() ? 0 : 1.0/pm->getScale();
-        std::unique_ptr<PrecisionModel> newpm;
-        if ( gridSize ) newpm.reset( new PrecisionModel(1.0/gridSize) );
-        else newpm.reset( new PrecisionModel() );
-        GeometryFactory::Ptr gf =
-            GeometryFactory::create( newpm.get(), g->getSRID() );
-        Geometry *ret;
-        if ( gridSize && cursize != gridSize )
-        {
-          // We need to snap the geometry
-          GeometryPrecisionReducer reducer( *gf );
-          reducer.setPointwise( flags & GEOS_PREC_NO_TOPO );
-          reducer.setRemoveCollapsedComponents( ! (flags & GEOS_PREC_KEEP_COLLAPSED) );
-          ret = reducer.reduce( *g ).release();
-        }
-        else
-        {
-          // No need or willing to snap, just change the factory
-          ret = gf->createGeometry(g);
-        }
-        return ret;
+        return GEOSCoordSeq_setOrdinate_r(extHandle, s, idx, 1, val);
     }
-    catch (const std::exception &e)
+
+    int
+    GEOSCoordSeq_setZ_r(GEOSContextHandle_t extHandle, CoordinateSequence* s, unsigned int idx, double val)
     {
-        handle->ERROR_MESSAGE("%s", e.what());
+        return GEOSCoordSeq_setOrdinate_r(extHandle, s, idx, 2, val);
     }
-    catch (...)
+
+    CoordinateSequence*
+    GEOSCoordSeq_clone_r(GEOSContextHandle_t extHandle, const CoordinateSequence* cs)
     {
-        handle->ERROR_MESSAGE("Unknown exception thrown");
-    }
+        assert(0 != cs);
 
-    return NULL;
-}
+        if(0 == extHandle) {
+            return NULL;
+        }
 
-double
-GEOSGeom_getPrecision_r(GEOSContextHandle_t extHandle, const GEOSGeometry *g)
-{
-    using namespace geos::geom;
+        GEOSContextHandleInternal_t* handle = 0;
+        handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
+        if(0 == handle->initialized) {
+            return NULL;
+        }
 
-    assert(0 != g);
+        try {
+            return cs->clone();
+        }
+        catch(const std::exception& e) {
+            handle->ERROR_MESSAGE("%s", e.what());
+        }
+        catch(...) {
+            handle->ERROR_MESSAGE("Unknown exception thrown");
+        }
 
-    if ( 0 == extHandle )
-    {
-        return -1;
+        return NULL;
     }
 
-    GEOSContextHandleInternal_t *handle = 0;
-    handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
-    if ( 0 == handle->initialized )
+    int
+    GEOSCoordSeq_getOrdinate_r(GEOSContextHandle_t extHandle, const CoordinateSequence* cs,
+                               unsigned int idx, unsigned int dim, double* val)
     {
-        return -1;
-    }
+        assert(0 != cs);
+        assert(0 != val);
 
-    try
-    {
-        const PrecisionModel *pm = g->getPrecisionModel();
-        double cursize = pm->isFloating() ? 0 : 1.0/pm->getScale();
-        return cursize;
-    }
-    catch (const std::exception &e)
-    {
-        handle->ERROR_MESSAGE("%s", e.what());
-    }
-    catch (...)
-    {
-        handle->ERROR_MESSAGE("Unknown exception thrown");
-    }
+        if(0 == extHandle) {
+            return 0;
+        }
 
-    return -1;
-}
+        GEOSContextHandleInternal_t* handle = 0;
+        handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
+        if(0 == handle->initialized) {
+            return 0;
+        }
+
+        try {
+            double d = cs->getOrdinate(idx, dim);
+            *val = d;
+
+            return 1;
+        }
+        catch(const std::exception& e) {
+            handle->ERROR_MESSAGE("%s", e.what());
+        }
+        catch(...) {
+            handle->ERROR_MESSAGE("Unknown exception thrown");
+        }
 
-int
-GEOSGeom_getDimensions_r(GEOSContextHandle_t extHandle, const Geometry *g)
-{
-    if ( 0 == extHandle )
-    {
         return 0;
     }
 
-    GEOSContextHandleInternal_t *handle = 0;
-    handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
-    if ( 0 == handle->initialized )
+    int
+    GEOSCoordSeq_getX_r(GEOSContextHandle_t extHandle, const CoordinateSequence* s, unsigned int idx, double* val)
     {
-        return 0;
+        return GEOSCoordSeq_getOrdinate_r(extHandle, s, idx, 0, val);
     }
 
-    try
+    int
+    GEOSCoordSeq_getY_r(GEOSContextHandle_t extHandle, const CoordinateSequence* s, unsigned int idx, double* val)
     {
-        return (int) g->getDimension();
+        return GEOSCoordSeq_getOrdinate_r(extHandle, s, idx, 1, val);
     }
-    catch (const std::exception &e)
+
+    int
+    GEOSCoordSeq_getZ_r(GEOSContextHandle_t extHandle, const CoordinateSequence* s, unsigned int idx, double* val)
     {
-        handle->ERROR_MESSAGE("%s", e.what());
+        return GEOSCoordSeq_getOrdinate_r(extHandle, s, idx, 2, val);
     }
-    catch (...)
+
+    int
+    GEOSCoordSeq_getSize_r(GEOSContextHandle_t extHandle, const CoordinateSequence* cs, unsigned int* size)
     {
-        handle->ERROR_MESSAGE("Unknown exception thrown");
-    }
+        assert(0 != cs);
+        assert(0 != size);
 
-    return 0;
-}
+        if(0 == extHandle) {
+            return 0;
+        }
 
-int
-GEOSGeom_getCoordinateDimension_r(GEOSContextHandle_t extHandle, const Geometry *g)
-{
-    if ( 0 == extHandle )
-    {
-        return 0;
-    }
+        GEOSContextHandleInternal_t* handle = 0;
+        handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
+        if(0 == handle->initialized) {
+            return 0;
+        }
+
+        try {
+            const std::size_t sz = cs->getSize();
+            *size = static_cast<unsigned int>(sz);
+            return 1;
+        }
+        catch(const std::exception& e) {
+            handle->ERROR_MESSAGE("%s", e.what());
+        }
+        catch(...) {
+            handle->ERROR_MESSAGE("Unknown exception thrown");
+        }
 
-    GEOSContextHandleInternal_t *handle = 0;
-    handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
-    if ( 0 == handle->initialized )
-    {
         return 0;
     }
 
-    try
-    {
-        return g->getCoordinateDimension();
-    }
-    catch (const std::exception &e)
+    int
+    GEOSCoordSeq_getDimensions_r(GEOSContextHandle_t extHandle, const CoordinateSequence* cs, unsigned int* dims)
     {
-        handle->ERROR_MESSAGE("%s", e.what());
-    }
-    catch (...)
-    {
-        handle->ERROR_MESSAGE("Unknown exception thrown");
-    }
+        assert(0 != cs);
+        assert(0 != dims);
 
-    return 0;
-}
+        if(0 == extHandle) {
+            return 0;
+        }
 
-int
-GEOSGeom_getXMin_r(GEOSContextHandle_t extHandle, const Geometry *g, double *value)
-{
-    if ( 0 == extHandle )
-    {
-        return 0;
-    }
+        GEOSContextHandleInternal_t* handle = 0;
+        handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
+        if(0 == handle->initialized) {
+            return 0;
+        }
+
+        try {
+            const std::size_t dim = cs->getDimension();
+            *dims = static_cast<unsigned int>(dim);
+
+            return 1;
+        }
+        catch(const std::exception& e) {
+            handle->ERROR_MESSAGE("%s", e.what());
+        }
+
+        catch(...) {
+            handle->ERROR_MESSAGE("Unknown exception thrown");
+        }
 
-    GEOSContextHandleInternal_t *handle = 0;
-    handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
-    if ( 0 == handle->initialized )
-    {
         return 0;
     }
 
-    try
+    int
+    GEOSCoordSeq_isCCW_r(GEOSContextHandle_t extHandle, const CoordinateSequence* cs, char* val)
     {
-        if (g->isEmpty())
-        {
+        assert(cs != nullptr);
+        assert(val != nullptr);
+
+        if(extHandle == nullptr) {
             return 0;
         }
 
-        *value = g->getEnvelopeInternal()->getMinX();
-        return 1;
-    }
-    catch (const std::exception &e)
-    {
-        handle->ERROR_MESSAGE("%s", e.what());
-    }
-    catch (...)
-    {
-        handle->ERROR_MESSAGE("Unknown exception thrown");
-    }
+        GEOSContextHandleInternal_t* handle = nullptr;
+        handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
+        if(0 == handle->initialized) {
+            return 0;
+        }
+        try {
+            *val = geos::algorithm::Orientation::isCCW(cs);
+            return 1;
+        }
+        catch(const std::exception& e) {
+            handle->ERROR_MESSAGE("%s", e.what());
+        }
 
-    return 0;
-}
+        catch(...) {
+            handle->ERROR_MESSAGE("Unknown exception thrown");
+        }
 
-int
-GEOSGeom_getXMax_r(GEOSContextHandle_t extHandle, const Geometry *g, double *value)
-{
-    if ( 0 == extHandle )
-    {
         return 0;
     }
 
-    GEOSContextHandleInternal_t *handle = 0;
-    handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
-    if ( 0 == handle->initialized )
+    void
+    GEOSCoordSeq_destroy_r(GEOSContextHandle_t extHandle, CoordinateSequence* s)
     {
-        return 0;
+        GEOSContextHandleInternal_t* handle = 0;
+
+        try {
+            delete s;
+        }
+        catch(const std::exception& e) {
+            if(0 == extHandle) {
+                return;
+            }
+
+            handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
+            if(0 == handle->initialized) {
+                return;
+            }
+
+            handle->ERROR_MESSAGE("%s", e.what());
+        }
+        catch(...) {
+            if(0 == extHandle) {
+                return;
+            }
+
+            handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
+            if(0 == handle->initialized) {
+                return;
+            }
+
+            handle->ERROR_MESSAGE("Unknown exception thrown");
+        }
     }
 
-    try
+    const CoordinateSequence*
+    GEOSGeom_getCoordSeq_r(GEOSContextHandle_t extHandle, const Geometry* g)
     {
-        if (g->isEmpty())
-        {
+        if(0 == extHandle) {
             return 0;
         }
 
-        *value = g->getEnvelopeInternal()->getMaxX();
-        return 1;
-    }
-    catch (const std::exception &e)
-    {
-        handle->ERROR_MESSAGE("%s", e.what());
-    }
-    catch (...)
-    {
-        handle->ERROR_MESSAGE("Unknown exception thrown");
-    }
+        GEOSContextHandleInternal_t* handle = 0;
+        handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
+        if(0 == handle->initialized) {
+            return 0;
+        }
 
-    return 0;
-}
+        try {
+            using geos::geom::Point;
+
+            const LineString* ls = dynamic_cast<const LineString*>(g);
+            if(ls) {
+                return ls->getCoordinatesRO();
+            }
+
+            const Point* p = dynamic_cast<const Point*>(g);
+            if(p) {
+                return p->getCoordinatesRO();
+            }
+
+            handle->ERROR_MESSAGE("Geometry must be a Point or LineString");
+            return 0;
+        }
+        catch(const std::exception& e) {
+            handle->ERROR_MESSAGE("%s", e.what());
+        }
+        catch(...) {
+            handle->ERROR_MESSAGE("Unknown exception thrown");
+        }
 
-int
-GEOSGeom_getYMin_r(GEOSContextHandle_t extHandle, const Geometry *g, double *value)
-{
-    if ( 0 == extHandle )
-    {
         return 0;
     }
 
-    GEOSContextHandleInternal_t *handle = 0;
-    handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
-    if ( 0 == handle->initialized )
+    Geometry*
+    GEOSGeom_createEmptyPoint_r(GEOSContextHandle_t extHandle)
     {
-        return 0;
+        if(0 == extHandle) {
+            return NULL;
+        }
+
+        GEOSContextHandleInternal_t* handle = 0;
+        handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
+        if(0 == handle->initialized) {
+            return NULL;
+        }
+
+        try {
+            const GeometryFactory* gf = handle->geomFactory;
+            return gf->createPoint();
+        }
+        catch(const std::exception& e) {
+            handle->ERROR_MESSAGE("%s", e.what());
+        }
+        catch(...) {
+            handle->ERROR_MESSAGE("Unknown exception thrown");
+        }
+
+        return NULL;
     }
 
-    try
+    Geometry*
+    GEOSGeom_createPoint_r(GEOSContextHandle_t extHandle, CoordinateSequence* cs)
     {
-        if (g->isEmpty())
-        {
+        if(0 == extHandle) {
             return 0;
         }
 
-        *value = g->getEnvelopeInternal()->getMinY();
-        return 1;
-    }
-    catch (const std::exception &e)
-    {
-        handle->ERROR_MESSAGE("%s", e.what());
-    }
-    catch (...)
-    {
-        handle->ERROR_MESSAGE("Unknown exception thrown");
-    }
+        GEOSContextHandleInternal_t* handle = 0;
+        handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
+        if(0 == handle->initialized) {
+            return 0;
+        }
 
-    return 0;
-}
+        try {
+            const GeometryFactory* gf = handle->geomFactory;
+            return gf->createPoint(cs);
+        }
+        catch(const std::exception& e) {
+            handle->ERROR_MESSAGE("%s", e.what());
+        }
+        catch(...) {
+            handle->ERROR_MESSAGE("Unknown exception thrown");
+        }
 
-int
-GEOSGeom_getYMax_r(GEOSContextHandle_t extHandle, const Geometry *g, double *value)
-{
-    if ( 0 == extHandle )
-    {
         return 0;
     }
 
-    GEOSContextHandleInternal_t *handle = 0;
-    handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
-    if ( 0 == handle->initialized )
+    Geometry*
+    GEOSGeom_createLinearRing_r(GEOSContextHandle_t extHandle, CoordinateSequence* cs)
     {
-        return 0;
-    }
+        if(0 == extHandle) {
+            return NULL;
+        }
 
-    try
-    {
-        if (g->isEmpty())
-        {
-            return 0;
+        GEOSContextHandleInternal_t* handle = 0;
+        handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
+        if(0 == handle->initialized) {
+            return NULL;
         }
 
-        *value = g->getEnvelopeInternal()->getMaxY();
-        return 1;
-    }
-    catch (const std::exception &e)
-    {
-        handle->ERROR_MESSAGE("%s", e.what());
-    }
-    catch (...)
-    {
-        handle->ERROR_MESSAGE("Unknown exception thrown");
-    }
+        try {
+            const GeometryFactory* gf = handle->geomFactory;
 
-    return 0;
-}
+            return gf->createLinearRing(cs);
+        }
+        catch(const std::exception& e) {
+            handle->ERROR_MESSAGE("%s", e.what());
+        }
+        catch(...) {
+            handle->ERROR_MESSAGE("Unknown exception thrown");
+        }
 
-Geometry *
-GEOSSimplify_r(GEOSContextHandle_t extHandle, const Geometry *g1, double tolerance)
-{
-    if ( 0 == extHandle )
-    {
         return NULL;
     }
 
-    GEOSContextHandleInternal_t *handle = 0;
-    handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
-    if ( 0 == handle->initialized )
+    Geometry*
+    GEOSGeom_createEmptyLineString_r(GEOSContextHandle_t extHandle)
     {
-        return NULL;
-    }
+        if(0 == extHandle) {
+            return NULL;
+        }
 
-    try
-    {
-        using namespace geos::simplify;
-        Geometry::Ptr g(DouglasPeuckerSimplifier::simplify(g1, tolerance));
-        return g.release();
-    }
-    catch (const std::exception &e)
-    {
-        handle->ERROR_MESSAGE("%s", e.what());
-    }
-    catch (...)
-    {
-        handle->ERROR_MESSAGE("Unknown exception thrown");
-    }
+        GEOSContextHandleInternal_t* handle = 0;
+        handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
+        if(0 == handle->initialized) {
+            return NULL;
+        }
 
-    return NULL;
-}
+        try {
+            const GeometryFactory* gf = handle->geomFactory;
+
+            return gf->createLineString();
+        }
+        catch(const std::exception& e) {
+            handle->ERROR_MESSAGE("%s", e.what());
+        }
+        catch(...) {
+            handle->ERROR_MESSAGE("Unknown exception thrown");
+        }
 
-Geometry *
-GEOSTopologyPreserveSimplify_r(GEOSContextHandle_t extHandle, const Geometry *g1, double tolerance)
-{
-    if ( 0 == extHandle )
-    {
         return NULL;
     }
 
-    GEOSContextHandleInternal_t *handle = 0;
-    handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
-    if ( 0 == handle->initialized )
+    Geometry*
+    GEOSGeom_createLineString_r(GEOSContextHandle_t extHandle, CoordinateSequence* cs)
     {
+        if(0 == extHandle) {
+            return NULL;
+        }
+
+        GEOSContextHandleInternal_t* handle = 0;
+        handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
+        if(0 == handle->initialized) {
+            return NULL;
+        }
+
+        try {
+            const GeometryFactory* gf = handle->geomFactory;
+
+            return gf->createLineString(cs);
+        }
+        catch(const std::exception& e) {
+            handle->ERROR_MESSAGE("%s", e.what());
+        }
+        catch(...) {
+            handle->ERROR_MESSAGE("Unknown exception thrown");
+        }
+
         return NULL;
     }
 
-    try
-    {
-        using namespace geos::simplify;
-        Geometry::Ptr g(TopologyPreservingSimplifier::simplify(g1, tolerance));
-        return g.release();
-    }
-    catch (const std::exception &e)
-    {
-        handle->ERROR_MESSAGE("%s", e.what());
-    }
-    catch (...)
+    Geometry*
+    GEOSGeom_createEmptyPolygon_r(GEOSContextHandle_t extHandle)
     {
-        handle->ERROR_MESSAGE("Unknown exception thrown");
-    }
+        if(0 == extHandle) {
+            return NULL;
+        }
 
-    return NULL;
-}
+        GEOSContextHandleInternal_t* handle = 0;
+        handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
+        if(0 == handle->initialized) {
+            return NULL;
+        }
 
+        try {
+            const GeometryFactory* gf = handle->geomFactory;
+            return gf->createPolygon();
+        }
+        catch(const std::exception& e) {
+            handle->ERROR_MESSAGE("%s", e.what());
+        }
+        catch(...) {
+            handle->ERROR_MESSAGE("Unknown exception thrown");
+        }
 
-/* WKT Reader */
-WKTReader *
-GEOSWKTReader_create_r(GEOSContextHandle_t extHandle)
-{
-    if ( 0 == extHandle )
-    {
         return NULL;
     }
 
-    GEOSContextHandleInternal_t *handle = 0;
-    handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
-    if ( 0 == handle->initialized )
+    Geometry*
+    GEOSGeom_createPolygon_r(GEOSContextHandle_t extHandle, Geometry* shell, Geometry** holes, unsigned int nholes)
     {
+        // FIXME: holes must be non-nullptr or may be nullptr?
+        //assert(0 != holes);
+
+        if(0 == extHandle) {
+            return NULL;
+        }
+
+        GEOSContextHandleInternal_t* handle = 0;
+        handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
+        if(0 == handle->initialized) {
+            return NULL;
+        }
+
+        try {
+            using geos::geom::LinearRing;
+
+            std::vector<Geometry*>* vholes = new std::vector<Geometry*>(holes, holes + nholes);
+
+            LinearRing* nshell = dynamic_cast<LinearRing*>(shell);
+            if(! nshell) {
+                handle->ERROR_MESSAGE("Shell is not a LinearRing");
+                delete vholes;
+                return NULL;
+            }
+            const GeometryFactory* gf = handle->geomFactory;
+
+            return gf->createPolygon(nshell, vholes);
+        }
+        catch(const std::exception& e) {
+            handle->ERROR_MESSAGE("%s", e.what());
+        }
+        catch(...) {
+            handle->ERROR_MESSAGE("Unknown exception thrown");
+        }
+
         return NULL;
     }
 
-    try
-    {
-        using geos::io::WKTReader;
-        return new WKTReader((GeometryFactory*)handle->geomFactory);
-    }
-    catch (const std::exception &e)
+    Geometry*
+    GEOSGeom_clone_r(GEOSContextHandle_t extHandle, const Geometry* g)
     {
-        handle->ERROR_MESSAGE("%s", e.what());
-    }
-    catch (...)
-    {
-        handle->ERROR_MESSAGE("Unknown exception thrown");
-    }
+        assert(0 != g);
 
-    return NULL;
-}
+        if(0 == extHandle) {
+            return NULL;
+        }
 
-void
-GEOSWKTReader_destroy_r(GEOSContextHandle_t extHandle, WKTReader *reader)
-{
-    GEOSContextHandleInternal_t *handle = 0;
+        GEOSContextHandleInternal_t* handle = 0;
+        handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
+        if(0 == handle->initialized) {
+            return NULL;
+        }
 
-    try
-    {
-        delete reader;
+        try {
+            return g->clone();
+        }
+        catch(const std::exception& e) {
+            handle->ERROR_MESSAGE("%s", e.what());
+        }
+        catch(...) {
+            handle->ERROR_MESSAGE("Unknown exception thrown");
+        }
+
+        return NULL;
     }
-    catch (const std::exception &e)
+
+    GEOSGeometry*
+    GEOSGeom_setPrecision_r(GEOSContextHandle_t extHandle, const GEOSGeometry* g,
+                            double gridSize, int flags)
     {
-        if ( 0 == extHandle )
-        {
-            return;
+        using namespace geos::geom;
+
+        assert(0 != g);
+
+        if(0 == extHandle) {
+            return NULL;
         }
 
+        GEOSContextHandleInternal_t* handle = 0;
         handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
-        if ( 0 == handle->initialized )
-        {
-            return;
+        if(0 == handle->initialized) {
+            return NULL;
+        }
+
+        try {
+            const PrecisionModel* pm = g->getPrecisionModel();
+            double cursize = pm->isFloating() ? 0 : 1.0 / pm->getScale();
+            std::unique_ptr<PrecisionModel> newpm;
+            if(gridSize) {
+                newpm.reset(new PrecisionModel(1.0 / gridSize));
+            }
+            else {
+                newpm.reset(new PrecisionModel());
+            }
+            GeometryFactory::Ptr gf =
+                GeometryFactory::create(newpm.get(), g->getSRID());
+            Geometry* ret;
+            if(gridSize && cursize != gridSize) {
+                // We need to snap the geometry
+                GeometryPrecisionReducer reducer(*gf);
+                reducer.setPointwise(flags & GEOS_PREC_NO_TOPO);
+                reducer.setRemoveCollapsedComponents(!(flags & GEOS_PREC_KEEP_COLLAPSED));
+                ret = reducer.reduce(*g).release();
+            }
+            else {
+                // No need or willing to snap, just change the factory
+                ret = gf->createGeometry(g);
+            }
+            return ret;
+        }
+        catch(const std::exception& e) {
+            handle->ERROR_MESSAGE("%s", e.what());
+        }
+        catch(...) {
+            handle->ERROR_MESSAGE("Unknown exception thrown");
         }
 
-        handle->ERROR_MESSAGE("%s", e.what());
+        return NULL;
     }
-    catch (...)
+
+    double
+    GEOSGeom_getPrecision_r(GEOSContextHandle_t extHandle, const GEOSGeometry* g)
     {
-        if ( 0 == extHandle )
-        {
-            return;
+        using namespace geos::geom;
+
+        assert(0 != g);
+
+        if(0 == extHandle) {
+            return -1;
         }
 
+        GEOSContextHandleInternal_t* handle = 0;
         handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
-        if ( 0 == handle->initialized )
-        {
-            return;
+        if(0 == handle->initialized) {
+            return -1;
+        }
+
+        try {
+            const PrecisionModel* pm = g->getPrecisionModel();
+            double cursize = pm->isFloating() ? 0 : 1.0 / pm->getScale();
+            return cursize;
+        }
+        catch(const std::exception& e) {
+            handle->ERROR_MESSAGE("%s", e.what());
+        }
+        catch(...) {
+            handle->ERROR_MESSAGE("Unknown exception thrown");
         }
 
-        handle->ERROR_MESSAGE("Unknown exception thrown");
+        return -1;
     }
-}
 
+    int
+    GEOSGeom_getDimensions_r(GEOSContextHandle_t extHandle, const Geometry* g)
+    {
+        if(0 == extHandle) {
+            return 0;
+        }
 
-Geometry*
-GEOSWKTReader_read_r(GEOSContextHandle_t extHandle, WKTReader *reader, const char *wkt)
-{
-    assert(0 != reader);
+        GEOSContextHandleInternal_t* handle = 0;
+        handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
+        if(0 == handle->initialized) {
+            return 0;
+        }
 
-    if ( 0 == extHandle )
-    {
-        return 0;
-    }
+        try {
+            return (int) g->getDimension();
+        }
+        catch(const std::exception& e) {
+            handle->ERROR_MESSAGE("%s", e.what());
+        }
+        catch(...) {
+            handle->ERROR_MESSAGE("Unknown exception thrown");
+        }
 
-    GEOSContextHandleInternal_t *handle = 0;
-    handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
-    if ( 0 == handle->initialized )
-    {
         return 0;
     }
 
-    try
-    {
-        const std::string wktstring(wkt);
-        Geometry *g = reader->read(wktstring);
-        return g;
-    }
-    catch (const std::exception &e)
-    {
-        handle->ERROR_MESSAGE("%s", e.what());
-    }
-    catch (...)
+    int
+    GEOSGeom_getCoordinateDimension_r(GEOSContextHandle_t extHandle, const Geometry* g)
     {
-        handle->ERROR_MESSAGE("Unknown exception thrown");
-    }
+        if(0 == extHandle) {
+            return 0;
+        }
 
-    return 0;
-}
+        GEOSContextHandleInternal_t* handle = 0;
+        handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
+        if(0 == handle->initialized) {
+            return 0;
+        }
 
-/* WKT Writer */
-WKTWriter *
-GEOSWKTWriter_create_r(GEOSContextHandle_t extHandle)
-{
-    if ( 0 == extHandle )
-    {
-        return 0;
-    }
+        try {
+            return g->getCoordinateDimension();
+        }
+        catch(const std::exception& e) {
+            handle->ERROR_MESSAGE("%s", e.what());
+        }
+        catch(...) {
+            handle->ERROR_MESSAGE("Unknown exception thrown");
+        }
 
-    GEOSContextHandleInternal_t *handle = 0;
-    handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
-    if ( 0 == handle->initialized )
-    {
         return 0;
     }
 
-    try
+    int
+    GEOSGeom_getXMin_r(GEOSContextHandle_t extHandle, const Geometry* g, double* value)
     {
-        using geos::io::WKTWriter;
-        return new WKTWriter();
-    }
-    catch (const std::exception &e)
-    {
-        handle->ERROR_MESSAGE("%s", e.what());
-    }
-    catch (...)
-    {
-        handle->ERROR_MESSAGE("Unknown exception thrown");
-    }
+        if(0 == extHandle) {
+            return 0;
+        }
 
-    return 0;
-}
+        GEOSContextHandleInternal_t* handle = 0;
+        handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
+        if(0 == handle->initialized) {
+            return 0;
+        }
 
-void
-GEOSWKTWriter_destroy_r(GEOSContextHandle_t extHandle, WKTWriter *Writer)
-{
+        try {
+            if(g->isEmpty()) {
+                return 0;
+            }
 
-    GEOSContextHandleInternal_t *handle = 0;
+            *value = g->getEnvelopeInternal()->getMinX();
+            return 1;
+        }
+        catch(const std::exception& e) {
+            handle->ERROR_MESSAGE("%s", e.what());
+        }
+        catch(...) {
+            handle->ERROR_MESSAGE("Unknown exception thrown");
+        }
 
-    try
-    {
-        delete Writer;
+        return 0;
     }
-    catch (const std::exception &e)
+
+    int
+    GEOSGeom_getXMax_r(GEOSContextHandle_t extHandle, const Geometry* g, double* value)
     {
-        if ( 0 == extHandle )
-        {
-            return;
+        if(0 == extHandle) {
+            return 0;
         }
 
+        GEOSContextHandleInternal_t* handle = 0;
         handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
-        if ( 0 == handle->initialized )
-        {
-            return;
+        if(0 == handle->initialized) {
+            return 0;
+        }
+
+        try {
+            if(g->isEmpty()) {
+                return 0;
+            }
+
+            *value = g->getEnvelopeInternal()->getMaxX();
+            return 1;
+        }
+        catch(const std::exception& e) {
+            handle->ERROR_MESSAGE("%s", e.what());
+        }
+        catch(...) {
+            handle->ERROR_MESSAGE("Unknown exception thrown");
         }
 
-        handle->ERROR_MESSAGE("%s", e.what());
+        return 0;
     }
-    catch (...)
+
+    int
+    GEOSGeom_getYMin_r(GEOSContextHandle_t extHandle, const Geometry* g, double* value)
     {
-        if ( 0 == extHandle )
-        {
-            return;
+        if(0 == extHandle) {
+            return 0;
         }
 
+        GEOSContextHandleInternal_t* handle = 0;
         handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
-        if ( 0 == handle->initialized )
-        {
-            return;
+        if(0 == handle->initialized) {
+            return 0;
         }
 
-        handle->ERROR_MESSAGE("Unknown exception thrown");
-    }
-}
-
+        try {
+            if(g->isEmpty()) {
+                return 0;
+            }
 
-char*
-GEOSWKTWriter_write_r(GEOSContextHandle_t extHandle, WKTWriter *writer, const Geometry *geom)
-{
-    assert(0 != writer);
+            *value = g->getEnvelopeInternal()->getMinY();
+            return 1;
+        }
+        catch(const std::exception& e) {
+            handle->ERROR_MESSAGE("%s", e.what());
+        }
+        catch(...) {
+            handle->ERROR_MESSAGE("Unknown exception thrown");
+        }
 
-    if ( 0 == extHandle )
-    {
-        return NULL;
+        return 0;
     }
 
-    GEOSContextHandleInternal_t *handle = 0;
-    handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
-    if ( 0 == handle->initialized )
+    int
+    GEOSGeom_getYMax_r(GEOSContextHandle_t extHandle, const Geometry* g, double* value)
     {
-        return NULL;
-    }
+        if(0 == extHandle) {
+            return 0;
+        }
 
-    try
-    {
-        std::string sgeom(writer->write(geom));
-        char *result = gstrdup(sgeom);
-        return result;
-    }
-    catch (const std::exception &e)
-    {
-        handle->ERROR_MESSAGE("%s", e.what());
-    }
-    catch (...)
-    {
-        handle->ERROR_MESSAGE("Unknown exception thrown");
-    }
+        GEOSContextHandleInternal_t* handle = 0;
+        handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
+        if(0 == handle->initialized) {
+            return 0;
+        }
 
-    return NULL;
-}
+        try {
+            if(g->isEmpty()) {
+                return 0;
+            }
 
-void
-GEOSWKTWriter_setTrim_r(GEOSContextHandle_t extHandle, WKTWriter *writer, char trim)
-{
-    assert(0 != writer);
+            *value = g->getEnvelopeInternal()->getMaxY();
+            return 1;
+        }
+        catch(const std::exception& e) {
+            handle->ERROR_MESSAGE("%s", e.what());
+        }
+        catch(...) {
+            handle->ERROR_MESSAGE("Unknown exception thrown");
+        }
 
-    if ( 0 == extHandle )
-    {
-        return;
+        return 0;
     }
 
-    GEOSContextHandleInternal_t *handle = 0;
-    handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
-    if ( 0 == handle->initialized )
+    Geometry*
+    GEOSSimplify_r(GEOSContextHandle_t extHandle, const Geometry* g1, double tolerance)
     {
-        return;
-    }
+        if(0 == extHandle) {
+            return NULL;
+        }
 
-    writer->setTrim(0 != trim);
-}
+        GEOSContextHandleInternal_t* handle = 0;
+        handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
+        if(0 == handle->initialized) {
+            return NULL;
+        }
 
-void
-GEOSWKTWriter_setRoundingPrecision_r(GEOSContextHandle_t extHandle, WKTWriter *writer, int precision)
-{
-    assert(0 != writer);
+        try {
+            using namespace geos::simplify;
+            Geometry::Ptr g(DouglasPeuckerSimplifier::simplify(g1, tolerance));
+            return g.release();
+        }
+        catch(const std::exception& e) {
+            handle->ERROR_MESSAGE("%s", e.what());
+        }
+        catch(...) {
+            handle->ERROR_MESSAGE("Unknown exception thrown");
+        }
 
-    if ( 0 == extHandle )
-    {
-        return;
+        return NULL;
     }
 
-    GEOSContextHandleInternal_t *handle = 0;
-    handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
-    if ( 0 == handle->initialized )
+    Geometry*
+    GEOSTopologyPreserveSimplify_r(GEOSContextHandle_t extHandle, const Geometry* g1, double tolerance)
     {
-        return;
-    }
+        if(0 == extHandle) {
+            return NULL;
+        }
 
-    writer->setRoundingPrecision(precision);
-}
+        GEOSContextHandleInternal_t* handle = 0;
+        handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
+        if(0 == handle->initialized) {
+            return NULL;
+        }
 
-void
-GEOSWKTWriter_setOutputDimension_r(GEOSContextHandle_t extHandle, WKTWriter *writer, int dim)
-{
-    assert(0 != writer);
+        try {
+            using namespace geos::simplify;
+            Geometry::Ptr g(TopologyPreservingSimplifier::simplify(g1, tolerance));
+            return g.release();
+        }
+        catch(const std::exception& e) {
+            handle->ERROR_MESSAGE("%s", e.what());
+        }
+        catch(...) {
+            handle->ERROR_MESSAGE("Unknown exception thrown");
+        }
 
-    if ( 0 == extHandle )
-    {
-        return;
+        return NULL;
     }
 
-    GEOSContextHandleInternal_t *handle = 0;
-    handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
-    if ( 0 == handle->initialized )
-    {
-        return;
-    }
 
-    try
-    {
-        writer->setOutputDimension(dim);
-    }
-    catch (const std::exception &e)
-    {
-        handle->ERROR_MESSAGE("%s", e.what());
-    }
-    catch (...)
+    /* WKT Reader */
+    WKTReader*
+    GEOSWKTReader_create_r(GEOSContextHandle_t extHandle)
     {
-        handle->ERROR_MESSAGE("Unknown exception thrown");
-    }
-}
+        if(0 == extHandle) {
+            return NULL;
+        }
 
-int
-GEOSWKTWriter_getOutputDimension_r(GEOSContextHandle_t extHandle, WKTWriter *writer)
-{
-    assert(0 != writer);
+        GEOSContextHandleInternal_t* handle = 0;
+        handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
+        if(0 == handle->initialized) {
+            return NULL;
+        }
 
-    if ( 0 == extHandle )
-    {
-        return -1;
-    }
+        try {
+            using geos::io::WKTReader;
+            return new WKTReader((GeometryFactory*)handle->geomFactory);
+        }
+        catch(const std::exception& e) {
+            handle->ERROR_MESSAGE("%s", e.what());
+        }
+        catch(...) {
+            handle->ERROR_MESSAGE("Unknown exception thrown");
+        }
 
-    GEOSContextHandleInternal_t *handle = 0;
-    handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
-    if ( 0 == handle->initialized )
-    {
-        return -1;
+        return NULL;
     }
 
-    int  dim = -1;
-
-    try
-    {
-        dim = writer->getOutputDimension();
-    }
-    catch (const std::exception &e)
-    {
-        handle->ERROR_MESSAGE("%s", e.what());
-    }
-    catch (...)
+    void
+    GEOSWKTReader_destroy_r(GEOSContextHandle_t extHandle, WKTReader* reader)
     {
-        handle->ERROR_MESSAGE("Unknown exception thrown");
-    }
-
-    return dim;
-}
+        GEOSContextHandleInternal_t* handle = 0;
 
-void
-GEOSWKTWriter_setOld3D_r(GEOSContextHandle_t extHandle, WKTWriter *writer, int useOld3D)
-{
-    assert(0 != writer);
+        try {
+            delete reader;
+        }
+        catch(const std::exception& e) {
+            if(0 == extHandle) {
+                return;
+            }
 
-    if ( 0 == extHandle )
-    {
-        return;
-    }
+            handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
+            if(0 == handle->initialized) {
+                return;
+            }
 
-    GEOSContextHandleInternal_t *handle = 0;
-    handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
-    if ( 0 == handle->initialized )
-    {
-        return;
-    }
+            handle->ERROR_MESSAGE("%s", e.what());
+        }
+        catch(...) {
+            if(0 == extHandle) {
+                return;
+            }
 
-    writer->setOld3D(0 != useOld3D);
-}
+            handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
+            if(0 == handle->initialized) {
+                return;
+            }
 
-/* WKB Reader */
-WKBReader *
-GEOSWKBReader_create_r(GEOSContextHandle_t extHandle)
-{
-    if ( 0 == extHandle )
-    {
-        return NULL;
+            handle->ERROR_MESSAGE("Unknown exception thrown");
+        }
     }
 
-    GEOSContextHandleInternal_t *handle = 0;
-    handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
-    if ( 0 == handle->initialized )
-    {
-        return NULL;
-    }
 
-    using geos::io::WKBReader;
-    try
-    {
-        return new WKBReader(*(GeometryFactory*)handle->geomFactory);
-    }
-    catch (const std::exception &e)
-    {
-        handle->ERROR_MESSAGE("%s", e.what());
-    }
-    catch (...)
+    Geometry*
+    GEOSWKTReader_read_r(GEOSContextHandle_t extHandle, WKTReader* reader, const char* wkt)
     {
-        handle->ERROR_MESSAGE("Unknown exception thrown");
-    }
-
-    return NULL;
-}
+        assert(0 != reader);
 
-void
-GEOSWKBReader_destroy_r(GEOSContextHandle_t extHandle, WKBReader *reader)
-{
-    GEOSContextHandleInternal_t *handle = 0;
-
-    try
-    {
-        delete reader;
-    }
-    catch (const std::exception &e)
-    {
-        if ( 0 == extHandle )
-        {
-            return;
+        if(0 == extHandle) {
+            return 0;
         }
 
+        GEOSContextHandleInternal_t* handle = 0;
         handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
-        if ( 0 == handle->initialized )
-        {
-            return;
+        if(0 == handle->initialized) {
+            return 0;
         }
 
-        handle->ERROR_MESSAGE("%s", e.what());
-    }
-    catch (...)
-    {
-        if ( 0 == extHandle )
-        {
-            return;
+        try {
+            const std::string wktstring(wkt);
+            Geometry* g = reader->read(wktstring);
+            return g;
         }
-
-        handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
-        if ( 0 == handle->initialized )
-        {
-            return;
+        catch(const std::exception& e) {
+            handle->ERROR_MESSAGE("%s", e.what());
+        }
+        catch(...) {
+            handle->ERROR_MESSAGE("Unknown exception thrown");
         }
 
-        handle->ERROR_MESSAGE("Unknown exception thrown");
-    }
-}
-
-struct membuf : public std::streambuf
-{
-  membuf(char* s, std::size_t n)
-  {
-    setg(s, s, s + n);
-  }
-};
-
-Geometry*
-GEOSWKBReader_read_r(GEOSContextHandle_t extHandle, WKBReader *reader, const unsigned char *wkb, size_t size)
-{
-    assert(0 != reader);
-    assert(0 != wkb);
-
-    if ( 0 == extHandle )
-    {
         return 0;
     }
 
-    GEOSContextHandleInternal_t *handle = 0;
-    handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
-    if ( 0 == handle->initialized )
+    /* WKT Writer */
+    WKTWriter*
+    GEOSWKTWriter_create_r(GEOSContextHandle_t extHandle)
     {
+        if(0 == extHandle) {
+            return 0;
+        }
+
+        GEOSContextHandleInternal_t* handle = 0;
+        handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
+        if(0 == handle->initialized) {
+            return 0;
+        }
+
+        try {
+            using geos::io::WKTWriter;
+            return new WKTWriter();
+        }
+        catch(const std::exception& e) {
+            handle->ERROR_MESSAGE("%s", e.what());
+        }
+        catch(...) {
+            handle->ERROR_MESSAGE("Unknown exception thrown");
+        }
+
         return 0;
     }
 
-    try
+    void
+    GEOSWKTWriter_destroy_r(GEOSContextHandle_t extHandle, WKTWriter* Writer)
     {
-        //std::string wkbstring(reinterpret_cast<const char*>(wkb), size); // make it binary !
-        //std::istringstream is(std::ios_base::binary);
-        //is.str(wkbstring);
-        //is.seekg(0, std::ios::beg); // rewind reader pointer
 
-        // http://stackoverflow.com/questions/2079912/simpler-way-to-create-a-c-memorystream-from-char-size-t-without-copying-t
-        membuf mb((char*)wkb, size);
-        istream is(&mb);
+        GEOSContextHandleInternal_t* handle = 0;
 
-        Geometry *g = reader->read(is);
-        return g;
-    }
-    catch (const std::exception &e)
-    {
-        handle->ERROR_MESSAGE("%s", e.what());
-    }
-    catch (...)
-    {
-        handle->ERROR_MESSAGE("Unknown exception thrown");
-    }
+        try {
+            delete Writer;
+        }
+        catch(const std::exception& e) {
+            if(0 == extHandle) {
+                return;
+            }
 
-    return 0;
-}
+            handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
+            if(0 == handle->initialized) {
+                return;
+            }
 
-Geometry*
-GEOSWKBReader_readHEX_r(GEOSContextHandle_t extHandle, WKBReader *reader, const unsigned char *hex, size_t size)
-{
-    assert(0 != reader);
-    assert(0 != hex);
+            handle->ERROR_MESSAGE("%s", e.what());
+        }
+        catch(...) {
+            if(0 == extHandle) {
+                return;
+            }
 
-    if ( 0 == extHandle )
-    {
-        return 0;
-    }
+            handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
+            if(0 == handle->initialized) {
+                return;
+            }
 
-    GEOSContextHandleInternal_t *handle = 0;
-    handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
-    if ( 0 == handle->initialized )
-    {
-        return 0;
+            handle->ERROR_MESSAGE("Unknown exception thrown");
+        }
     }
 
-    try
-    {
-        std::string hexstring(reinterpret_cast<const char*>(hex), size);
-        std::istringstream is(std::ios_base::binary);
-        is.str(hexstring);
-        is.seekg(0, std::ios::beg); // rewind reader pointer
 
-        Geometry *g = reader->readHEX(is);
-        return g;
-    }
-    catch (const std::exception &e)
+    char*
+    GEOSWKTWriter_write_r(GEOSContextHandle_t extHandle, WKTWriter* writer, const Geometry* geom)
     {
-        handle->ERROR_MESSAGE("%s", e.what());
-    }
-    catch (...)
-    {
-        handle->ERROR_MESSAGE("Unknown exception thrown");
-    }
+        assert(0 != writer);
 
-    return 0;
-}
+        if(0 == extHandle) {
+            return NULL;
+        }
 
-/* WKB Writer */
-WKBWriter *
-GEOSWKBWriter_create_r(GEOSContextHandle_t extHandle)
-{
-    if ( 0 == extHandle )
-    {
-        return NULL;
-    }
+        GEOSContextHandleInternal_t* handle = 0;
+        handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
+        if(0 == handle->initialized) {
+            return NULL;
+        }
+
+        try {
+            std::string sgeom(writer->write(geom));
+            char* result = gstrdup(sgeom);
+            return result;
+        }
+        catch(const std::exception& e) {
+            handle->ERROR_MESSAGE("%s", e.what());
+        }
+        catch(...) {
+            handle->ERROR_MESSAGE("Unknown exception thrown");
+        }
 
-    GEOSContextHandleInternal_t *handle = 0;
-    handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
-    if ( 0 == handle->initialized )
-    {
         return NULL;
     }
 
-    try
-    {
-        using geos::io::WKBWriter;
-        return new WKBWriter();
-    }
-    catch (const std::exception &e)
-    {
-        handle->ERROR_MESSAGE("%s", e.what());
-    }
-    catch (...)
+    void
+    GEOSWKTWriter_setTrim_r(GEOSContextHandle_t extHandle, WKTWriter* writer, char trim)
     {
-        handle->ERROR_MESSAGE("Unknown exception thrown");
-    }
+        assert(0 != writer);
 
-    return NULL;
-}
+        if(0 == extHandle) {
+            return;
+        }
 
-void
-GEOSWKBWriter_destroy_r(GEOSContextHandle_t extHandle, WKBWriter *Writer)
-{
-    GEOSContextHandleInternal_t *handle = 0;
+        GEOSContextHandleInternal_t* handle = 0;
+        handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
+        if(0 == handle->initialized) {
+            return;
+        }
 
-    try
-    {
-        delete Writer;
+        writer->setTrim(0 != trim);
     }
-    catch (const std::exception &e)
+
+    void
+    GEOSWKTWriter_setRoundingPrecision_r(GEOSContextHandle_t extHandle, WKTWriter* writer, int precision)
     {
-        if ( 0 == extHandle )
-        {
+        assert(0 != writer);
+
+        if(0 == extHandle) {
             return;
         }
 
+        GEOSContextHandleInternal_t* handle = 0;
         handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
-        if ( 0 == handle->initialized )
-        {
+        if(0 == handle->initialized) {
             return;
         }
 
-        handle->ERROR_MESSAGE("%s", e.what());
+        writer->setRoundingPrecision(precision);
     }
-    catch (...)
+
+    void
+    GEOSWKTWriter_setOutputDimension_r(GEOSContextHandle_t extHandle, WKTWriter* writer, int dim)
     {
-        if ( 0 == extHandle )
-        {
+        assert(0 != writer);
+
+        if(0 == extHandle) {
             return;
         }
 
+        GEOSContextHandleInternal_t* handle = 0;
         handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
-        if ( 0 == handle->initialized )
-        {
+        if(0 == handle->initialized) {
             return;
         }
 
-        handle->ERROR_MESSAGE("Unknown exception thrown");
+        try {
+            writer->setOutputDimension(dim);
+        }
+        catch(const std::exception& e) {
+            handle->ERROR_MESSAGE("%s", e.what());
+        }
+        catch(...) {
+            handle->ERROR_MESSAGE("Unknown exception thrown");
+        }
     }
-}
 
+    int
+    GEOSWKTWriter_getOutputDimension_r(GEOSContextHandle_t extHandle, WKTWriter* writer)
+    {
+        assert(0 != writer);
 
-/* The caller owns the result */
-unsigned char*
-GEOSWKBWriter_write_r(GEOSContextHandle_t extHandle, WKBWriter *writer, const Geometry *geom, size_t *size)
-{
-    assert(0 != writer);
-    assert(0 != geom);
-    assert(0 != size);
+        if(0 == extHandle) {
+            return -1;
+        }
 
-    if ( 0 == extHandle )
-    {
-        return NULL;
-    }
+        GEOSContextHandleInternal_t* handle = 0;
+        handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
+        if(0 == handle->initialized) {
+            return -1;
+        }
 
-    GEOSContextHandleInternal_t *handle = 0;
-    handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
-    if ( 0 == handle->initialized )
-    {
-        return NULL;
+        int  dim = -1;
+
+        try {
+            dim = writer->getOutputDimension();
+        }
+        catch(const std::exception& e) {
+            handle->ERROR_MESSAGE("%s", e.what());
+        }
+        catch(...) {
+            handle->ERROR_MESSAGE("Unknown exception thrown");
+        }
+
+        return dim;
     }
 
-    try
+    void
+    GEOSWKTWriter_setOld3D_r(GEOSContextHandle_t extHandle, WKTWriter* writer, int useOld3D)
     {
-        std::ostringstream os(std::ios_base::binary);
-        writer->write(*geom, os);
+        assert(0 != writer);
 
-        const std::string& wkbstring = os.str();
-        const std::size_t len = wkbstring.length();
+        if(0 == extHandle) {
+            return;
+        }
 
-        unsigned char *result = NULL;
-        result = (unsigned char*) malloc(len);
-        std::memcpy(result, wkbstring.c_str(), len);
-        *size = len;
-        return result;
-    }
-    catch (const std::exception &e)
-    {
-        handle->ERROR_MESSAGE("%s", e.what());
+        GEOSContextHandleInternal_t* handle = 0;
+        handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
+        if(0 == handle->initialized) {
+            return;
+        }
+
+        writer->setOld3D(0 != useOld3D);
     }
-    catch (...)
+
+    /* WKB Reader */
+    WKBReader*
+    GEOSWKBReader_create_r(GEOSContextHandle_t extHandle)
     {
-        handle->ERROR_MESSAGE("Unknown exception thrown");
-    }
-    return NULL;
-}
+        if(0 == extHandle) {
+            return NULL;
+        }
 
-/* The caller owns the result */
-unsigned char*
-GEOSWKBWriter_writeHEX_r(GEOSContextHandle_t extHandle, WKBWriter *writer, const Geometry *geom, size_t *size)
-{
-    assert(0 != writer);
-    assert(0 != geom);
-    assert(0 != size);
+        GEOSContextHandleInternal_t* handle = 0;
+        handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
+        if(0 == handle->initialized) {
+            return NULL;
+        }
 
-    if ( 0 == extHandle )
-    {
-        return NULL;
-    }
+        using geos::io::WKBReader;
+        try {
+            return new WKBReader(*(GeometryFactory*)handle->geomFactory);
+        }
+        catch(const std::exception& e) {
+            handle->ERROR_MESSAGE("%s", e.what());
+        }
+        catch(...) {
+            handle->ERROR_MESSAGE("Unknown exception thrown");
+        }
 
-    GEOSContextHandleInternal_t *handle = 0;
-    handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
-    if ( 0 == handle->initialized )
-    {
         return NULL;
     }
 
-    try
+    void
+    GEOSWKBReader_destroy_r(GEOSContextHandle_t extHandle, WKBReader* reader)
     {
-        std::ostringstream os(std::ios_base::binary);
-        writer->writeHEX(*geom, os);
-        std::string wkbstring(os.str());
-        const std::size_t len = wkbstring.length();
+        GEOSContextHandleInternal_t* handle = 0;
 
-        unsigned char *result = NULL;
-        result = (unsigned char*) malloc(len);
-        std::memcpy(result, wkbstring.c_str(), len);
-        *size = len;
-        return result;
-    }
-    catch (const std::exception &e)
-    {
-        handle->ERROR_MESSAGE("%s", e.what());
-    }
-    catch (...)
-    {
-        handle->ERROR_MESSAGE("Unknown exception thrown");
-    }
+        try {
+            delete reader;
+        }
+        catch(const std::exception& e) {
+            if(0 == extHandle) {
+                return;
+            }
 
-    return NULL;
-}
+            handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
+            if(0 == handle->initialized) {
+                return;
+            }
 
-int
-GEOSWKBWriter_getOutputDimension_r(GEOSContextHandle_t extHandle, const GEOSWKBWriter* writer)
-{
-    assert(0 != writer);
+            handle->ERROR_MESSAGE("%s", e.what());
+        }
+        catch(...) {
+            if(0 == extHandle) {
+                return;
+            }
 
-    if ( 0 == extHandle )
-    {
-        return 0;
-    }
+            handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
+            if(0 == handle->initialized) {
+                return;
+            }
 
-    int ret = 0;
+            handle->ERROR_MESSAGE("Unknown exception thrown");
+        }
+    }
 
-    GEOSContextHandleInternal_t *handle = 0;
-    handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
-    if ( 0 != handle->initialized )
-    {
-        try
+    struct membuf : public std::streambuf {
+        membuf(char* s, std::size_t n)
         {
-            ret = writer->getOutputDimension();
+            setg(s, s, s + n);
         }
-        catch (...)
-        {
-            handle->ERROR_MESSAGE("Unknown exception thrown");
+    };
+
+    Geometry*
+    GEOSWKBReader_read_r(GEOSContextHandle_t extHandle, WKBReader* reader, const unsigned char* wkb, size_t size)
+    {
+        assert(0 != reader);
+        assert(0 != wkb);
+
+        if(0 == extHandle) {
+            return 0;
         }
-    }
 
-    return ret;
-}
+        GEOSContextHandleInternal_t* handle = 0;
+        handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
+        if(0 == handle->initialized) {
+            return 0;
+        }
 
-void
-GEOSWKBWriter_setOutputDimension_r(GEOSContextHandle_t extHandle, GEOSWKBWriter* writer, int newDimension)
-{
-    assert(0 != writer);
+        try {
+            //std::string wkbstring(reinterpret_cast<const char*>(wkb), size); // make it binary !
+            //std::istringstream is(std::ios_base::binary);
+            //is.str(wkbstring);
+            //is.seekg(0, std::ios::beg); // rewind reader pointer
 
-    if ( 0 == extHandle )
-    {
-        return;
-    }
+            // http://stackoverflow.com/questions/2079912/simpler-way-to-create-a-c-memorystream-from-char-size-t-without-copying-t
+            membuf mb((char*)wkb, size);
+            istream is(&mb);
 
-    GEOSContextHandleInternal_t *handle = 0;
-    handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
-    if ( 0 != handle->initialized )
-    {
-        try
-        {
-            writer->setOutputDimension(newDimension);
+            Geometry* g = reader->read(is);
+            return g;
         }
-        catch (const std::exception &e)
-        {
+        catch(const std::exception& e) {
             handle->ERROR_MESSAGE("%s", e.what());
         }
-        catch (...)
-        {
+        catch(...) {
             handle->ERROR_MESSAGE("Unknown exception thrown");
         }
-    }
-}
-
-int
-GEOSWKBWriter_getByteOrder_r(GEOSContextHandle_t extHandle, const GEOSWKBWriter* writer)
-{
-    assert(0 != writer);
 
-    if ( 0 == extHandle )
-    {
         return 0;
     }
 
-    int ret = 0;
-
-    GEOSContextHandleInternal_t *handle = 0;
-    handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
-    if ( 0 != handle->initialized )
+    Geometry*
+    GEOSWKBReader_readHEX_r(GEOSContextHandle_t extHandle, WKBReader* reader, const unsigned char* hex, size_t size)
     {
-        try
-        {
-            ret = writer->getByteOrder();
-        }
+        assert(0 != reader);
+        assert(0 != hex);
 
-        catch (...)
-        {
-            handle->ERROR_MESSAGE("Unknown exception thrown");
+        if(0 == extHandle) {
+            return 0;
         }
-    }
-
-    return ret;
-}
 
-void
-GEOSWKBWriter_setByteOrder_r(GEOSContextHandle_t extHandle, GEOSWKBWriter* writer, int newByteOrder)
-{
-    assert(0 != writer);
+        GEOSContextHandleInternal_t* handle = 0;
+        handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
+        if(0 == handle->initialized) {
+            return 0;
+        }
 
-    if ( 0 == extHandle )
-    {
-        return;
-    }
+        try {
+            std::string hexstring(reinterpret_cast<const char*>(hex), size);
+            std::istringstream is(std::ios_base::binary);
+            is.str(hexstring);
+            is.seekg(0, std::ios::beg); // rewind reader pointer
 
-    GEOSContextHandleInternal_t *handle = 0;
-    handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
-    if ( 0 != handle->initialized )
-    {
-        try
-        {
-            writer->setByteOrder(newByteOrder);
+            Geometry* g = reader->readHEX(is);
+            return g;
         }
-        catch (const std::exception &e)
-        {
+        catch(const std::exception& e) {
             handle->ERROR_MESSAGE("%s", e.what());
         }
-        catch (...)
-        {
+        catch(...) {
             handle->ERROR_MESSAGE("Unknown exception thrown");
         }
-    }
-}
 
-char
-GEOSWKBWriter_getIncludeSRID_r(GEOSContextHandle_t extHandle, const GEOSWKBWriter* writer)
-{
-    assert(0 != writer);
+        return 0;
+    }
 
-    if ( 0 == extHandle )
+    /* WKB Writer */
+    WKBWriter*
+    GEOSWKBWriter_create_r(GEOSContextHandle_t extHandle)
     {
-        return -1;
-    }
+        if(0 == extHandle) {
+            return NULL;
+        }
 
-    int ret = -1;
+        GEOSContextHandleInternal_t* handle = 0;
+        handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
+        if(0 == handle->initialized) {
+            return NULL;
+        }
 
-    GEOSContextHandleInternal_t *handle = 0;
-    handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
-    if ( 0 != handle->initialized )
-    {
-        try
-        {
-            int srid = writer->getIncludeSRID();
-            ret = srid;
+        try {
+            using geos::io::WKBWriter;
+            return new WKBWriter();
         }
-        catch (...)
-        {
+        catch(const std::exception& e) {
+            handle->ERROR_MESSAGE("%s", e.what());
+        }
+        catch(...) {
             handle->ERROR_MESSAGE("Unknown exception thrown");
         }
+
+        return NULL;
     }
 
-    return static_cast<char>(ret);
-}
+    void
+    GEOSWKBWriter_destroy_r(GEOSContextHandle_t extHandle, WKBWriter* Writer)
+    {
+        GEOSContextHandleInternal_t* handle = 0;
 
-void
-GEOSWKBWriter_setIncludeSRID_r(GEOSContextHandle_t extHandle, GEOSWKBWriter* writer, const char newIncludeSRID)
-{
-    assert(0 != writer);
+        try {
+            delete Writer;
+        }
+        catch(const std::exception& e) {
+            if(0 == extHandle) {
+                return;
+            }
 
-    if ( 0 == extHandle )
-    {
-        return;
-    }
+            handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
+            if(0 == handle->initialized) {
+                return;
+            }
 
-    GEOSContextHandleInternal_t *handle = 0;
-    handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
-    if ( 0 != handle->initialized )
-    {
-        try
-        {
-            writer->setIncludeSRID(newIncludeSRID);
+            handle->ERROR_MESSAGE("%s", e.what());
         }
-        catch (...)
-        {
+        catch(...) {
+            if(0 == extHandle) {
+                return;
+            }
+
+            handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
+            if(0 == handle->initialized) {
+                return;
+            }
+
             handle->ERROR_MESSAGE("Unknown exception thrown");
         }
     }
-}
 
 
-//-----------------------------------------------------------------
-// Prepared Geometry
-//-----------------------------------------------------------------
-
-const geos::geom::prep::PreparedGeometry*
-GEOSPrepare_r(GEOSContextHandle_t extHandle, const Geometry *g)
-{
-    if ( 0 == extHandle )
+    /* The caller owns the result */
+    unsigned char*
+    GEOSWKBWriter_write_r(GEOSContextHandle_t extHandle, WKBWriter* writer, const Geometry* geom, size_t* size)
     {
-        return 0;
-    }
+        assert(0 != writer);
+        assert(0 != geom);
+        assert(0 != size);
 
-    GEOSContextHandleInternal_t *handle = 0;
-    handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
-    if ( 0 == handle->initialized )
-    {
-        return 0;
-    }
+        if(0 == extHandle) {
+            return NULL;
+        }
+
+        GEOSContextHandleInternal_t* handle = 0;
+        handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
+        if(0 == handle->initialized) {
+            return NULL;
+        }
 
-    const geos::geom::prep::PreparedGeometry* prep = 0;
+        try {
+            std::ostringstream os(std::ios_base::binary);
+            writer->write(*geom, os);
 
-    try
-    {
-        prep = geos::geom::prep::PreparedGeometryFactory::prepare(g);
-    }
-    catch (const std::exception &e)
-    {
-        handle->ERROR_MESSAGE("%s", e.what());
-    }
-    catch (...)
-    {
-        handle->ERROR_MESSAGE("Unknown exception thrown");
+            const std::string& wkbstring = os.str();
+            const std::size_t len = wkbstring.length();
+
+            unsigned char* result = NULL;
+            result = (unsigned char*) malloc(len);
+            std::memcpy(result, wkbstring.c_str(), len);
+            *size = len;
+            return result;
+        }
+        catch(const std::exception& e) {
+            handle->ERROR_MESSAGE("%s", e.what());
+        }
+        catch(...) {
+            handle->ERROR_MESSAGE("Unknown exception thrown");
+        }
+        return NULL;
     }
 
-    return prep;
-}
-
-void
-GEOSPreparedGeom_destroy_r(GEOSContextHandle_t extHandle, const geos::geom::prep::PreparedGeometry *a)
-{
-    GEOSContextHandleInternal_t *handle = 0;
-
-    try
+    /* The caller owns the result */
+    unsigned char*
+    GEOSWKBWriter_writeHEX_r(GEOSContextHandle_t extHandle, WKBWriter* writer, const Geometry* geom, size_t* size)
     {
-        delete a;
-    }
-    catch (const std::exception &e)
-    {
-        if ( 0 == extHandle )
-        {
-            return;
+        assert(0 != writer);
+        assert(0 != geom);
+        assert(0 != size);
+
+        if(0 == extHandle) {
+            return NULL;
         }
 
+        GEOSContextHandleInternal_t* handle = 0;
         handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
-        if ( 0 == handle->initialized )
-        {
-            return;
+        if(0 == handle->initialized) {
+            return NULL;
+        }
+
+        try {
+            std::ostringstream os(std::ios_base::binary);
+            writer->writeHEX(*geom, os);
+            std::string wkbstring(os.str());
+            const std::size_t len = wkbstring.length();
+
+            unsigned char* result = NULL;
+            result = (unsigned char*) malloc(len);
+            std::memcpy(result, wkbstring.c_str(), len);
+            *size = len;
+            return result;
+        }
+        catch(const std::exception& e) {
+            handle->ERROR_MESSAGE("%s", e.what());
+        }
+        catch(...) {
+            handle->ERROR_MESSAGE("Unknown exception thrown");
         }
 
-        handle->ERROR_MESSAGE("%s", e.what());
+        return NULL;
     }
-    catch (...)
+
+    int
+    GEOSWKBWriter_getOutputDimension_r(GEOSContextHandle_t extHandle, const GEOSWKBWriter* writer)
     {
-        if ( 0 == extHandle )
-        {
-            return;
+        assert(0 != writer);
+
+        if(0 == extHandle) {
+            return 0;
         }
 
+        int ret = 0;
+
+        GEOSContextHandleInternal_t* handle = 0;
         handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
-        if ( 0 == handle->initialized )
-        {
-            return;
+        if(0 != handle->initialized) {
+            try {
+                ret = writer->getOutputDimension();
+            }
+            catch(...) {
+                handle->ERROR_MESSAGE("Unknown exception thrown");
+            }
         }
 
-        handle->ERROR_MESSAGE("Unknown exception thrown");
+        return ret;
     }
-}
-
-char
-GEOSPreparedContains_r(GEOSContextHandle_t extHandle,
-        const geos::geom::prep::PreparedGeometry *pg, const Geometry *g)
-{
-    assert(0 != pg);
-    assert(0 != g);
 
-    if ( 0 == extHandle )
+    void
+    GEOSWKBWriter_setOutputDimension_r(GEOSContextHandle_t extHandle, GEOSWKBWriter* writer, int newDimension)
     {
-        return 2;
-    }
+        assert(0 != writer);
 
-    GEOSContextHandleInternal_t *handle = 0;
-    handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
-    if ( 0 == handle->initialized )
-    {
-        return 2;
-    }
+        if(0 == extHandle) {
+            return;
+        }
 
-    try
-    {
-        bool result = pg->contains(g);
-        return result;
-    }
-    catch (const std::exception &e)
-    {
-        handle->ERROR_MESSAGE("%s", e.what());
+        GEOSContextHandleInternal_t* handle = 0;
+        handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
+        if(0 != handle->initialized) {
+            try {
+                writer->setOutputDimension(newDimension);
+            }
+            catch(const std::exception& e) {
+                handle->ERROR_MESSAGE("%s", e.what());
+            }
+            catch(...) {
+                handle->ERROR_MESSAGE("Unknown exception thrown");
+            }
+        }
     }
-    catch (...)
+
+    int
+    GEOSWKBWriter_getByteOrder_r(GEOSContextHandle_t extHandle, const GEOSWKBWriter* writer)
     {
-        handle->ERROR_MESSAGE("Unknown exception thrown");
-    }
+        assert(0 != writer);
 
-    return 2;
-}
+        if(0 == extHandle) {
+            return 0;
+        }
 
-char
-GEOSPreparedContainsProperly_r(GEOSContextHandle_t extHandle,
-        const geos::geom::prep::PreparedGeometry *pg, const Geometry *g)
-{
-    assert(0 != pg);
-    assert(0 != g);
+        int ret = 0;
 
-    if ( 0 == extHandle )
-    {
-        return 2;
-    }
+        GEOSContextHandleInternal_t* handle = 0;
+        handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
+        if(0 != handle->initialized) {
+            try {
+                ret = writer->getByteOrder();
+            }
+
+            catch(...) {
+                handle->ERROR_MESSAGE("Unknown exception thrown");
+            }
+        }
 
-    GEOSContextHandleInternal_t *handle = 0;
-    handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
-    if ( 0 == handle->initialized )
-    {
-        return 2;
+        return ret;
     }
 
-    try
-    {
-        bool result = pg->containsProperly(g);
-        return result;
-    }
-    catch (const std::exception &e)
-    {
-        handle->ERROR_MESSAGE("%s", e.what());
-    }
-    catch (...)
+    void
+    GEOSWKBWriter_setByteOrder_r(GEOSContextHandle_t extHandle, GEOSWKBWriter* writer, int newByteOrder)
     {
-        handle->ERROR_MESSAGE("Unknown exception thrown");
-    }
+        assert(0 != writer);
 
-    return 2;
-}
-
-char
-GEOSPreparedCoveredBy_r(GEOSContextHandle_t extHandle,
-        const geos::geom::prep::PreparedGeometry *pg, const Geometry *g)
-{
-    assert(0 != pg);
-    assert(0 != g);
+        if(0 == extHandle) {
+            return;
+        }
 
-    if ( 0 == extHandle )
-    {
-        return 2;
+        GEOSContextHandleInternal_t* handle = 0;
+        handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
+        if(0 != handle->initialized) {
+            try {
+                writer->setByteOrder(newByteOrder);
+            }
+            catch(const std::exception& e) {
+                handle->ERROR_MESSAGE("%s", e.what());
+            }
+            catch(...) {
+                handle->ERROR_MESSAGE("Unknown exception thrown");
+            }
+        }
     }
 
-    GEOSContextHandleInternal_t *handle = 0;
-    handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
-    if ( 0 == handle->initialized )
+    char
+    GEOSWKBWriter_getIncludeSRID_r(GEOSContextHandle_t extHandle, const GEOSWKBWriter* writer)
     {
-        return 2;
-    }
+        assert(0 != writer);
 
-    try
-    {
-        bool result = pg->coveredBy(g);
-        return result;
-    }
-    catch (const std::exception &e)
-    {
-        handle->ERROR_MESSAGE("%s", e.what());
-    }
-    catch (...)
-    {
-        handle->ERROR_MESSAGE("Unknown exception thrown");
-    }
+        if(0 == extHandle) {
+            return -1;
+        }
 
-    return 2;
-}
+        int ret = -1;
 
-char
-GEOSPreparedCovers_r(GEOSContextHandle_t extHandle,
-        const geos::geom::prep::PreparedGeometry *pg, const Geometry *g)
-{
-    assert(0 != pg);
-    assert(0 != g);
+        GEOSContextHandleInternal_t* handle = 0;
+        handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
+        if(0 != handle->initialized) {
+            try {
+                int srid = writer->getIncludeSRID();
+                ret = srid;
+            }
+            catch(...) {
+                handle->ERROR_MESSAGE("Unknown exception thrown");
+            }
+        }
 
-    if ( 0 == extHandle )
-    {
-        return 2;
+        return static_cast<char>(ret);
     }
 
-    GEOSContextHandleInternal_t *handle = 0;
-    handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
-    if ( 0 == handle->initialized )
+    void
+    GEOSWKBWriter_setIncludeSRID_r(GEOSContextHandle_t extHandle, GEOSWKBWriter* writer, const char newIncludeSRID)
     {
-        return 2;
-    }
+        assert(0 != writer);
 
-    try
-    {
-        bool result = pg->covers(g);
-        return result;
-    }
-    catch (const std::exception &e)
-    {
-        handle->ERROR_MESSAGE("%s", e.what());
-    }
-    catch (...)
-    {
-        handle->ERROR_MESSAGE("Unknown exception thrown");
-    }
+        if(0 == extHandle) {
+            return;
+        }
 
-    return 2;
-}
+        GEOSContextHandleInternal_t* handle = 0;
+        handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
+        if(0 != handle->initialized) {
+            try {
+                writer->setIncludeSRID(newIncludeSRID);
+            }
+            catch(...) {
+                handle->ERROR_MESSAGE("Unknown exception thrown");
+            }
+        }
+    }
 
-char
-GEOSPreparedCrosses_r(GEOSContextHandle_t extHandle,
-        const geos::geom::prep::PreparedGeometry *pg, const Geometry *g)
-{
-    assert(0 != pg);
-    assert(0 != g);
 
-    if ( 0 == extHandle )
-    {
-        return 2;
-    }
+//-----------------------------------------------------------------
+// Prepared Geometry
+//-----------------------------------------------------------------
 
-    GEOSContextHandleInternal_t *handle = 0;
-    handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
-    if ( 0 == handle->initialized )
+    const geos::geom::prep::PreparedGeometry*
+    GEOSPrepare_r(GEOSContextHandle_t extHandle, const Geometry* g)
     {
-        return 2;
-    }
+        if(0 == extHandle) {
+            return 0;
+        }
 
-    try
-    {
-        bool result = pg->crosses(g);
-        return result;
-    }
-    catch (const std::exception &e)
-    {
-        handle->ERROR_MESSAGE("%s", e.what());
-    }
-    catch (...)
-    {
-        handle->ERROR_MESSAGE("Unknown exception thrown");
-    }
+        GEOSContextHandleInternal_t* handle = 0;
+        handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
+        if(0 == handle->initialized) {
+            return 0;
+        }
 
-    return 2;
-}
+        const geos::geom::prep::PreparedGeometry* prep = 0;
 
-char
-GEOSPreparedDisjoint_r(GEOSContextHandle_t extHandle,
-        const geos::geom::prep::PreparedGeometry *pg, const Geometry *g)
-{
-    assert(0 != pg);
-    assert(0 != g);
+        try {
+            prep = geos::geom::prep::PreparedGeometryFactory::prepare(g);
+        }
+        catch(const std::exception& e) {
+            handle->ERROR_MESSAGE("%s", e.what());
+        }
+        catch(...) {
+            handle->ERROR_MESSAGE("Unknown exception thrown");
+        }
 
-    if ( 0 == extHandle )
-    {
-        return 2;
+        return prep;
     }
 
-    GEOSContextHandleInternal_t *handle = 0;
-    handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
-    if ( 0 == handle->initialized )
+    void
+    GEOSPreparedGeom_destroy_r(GEOSContextHandle_t extHandle, const geos::geom::prep::PreparedGeometry* a)
     {
-        return 2;
-    }
+        GEOSContextHandleInternal_t* handle = 0;
 
-    try
-    {
-        bool result = pg->disjoint(g);
-        return result;
-    }
-    catch (const std::exception &e)
-    {
-        handle->ERROR_MESSAGE("%s", e.what());
-    }
-    catch (...)
-    {
-        handle->ERROR_MESSAGE("Unknown exception thrown");
-    }
+        try {
+            delete a;
+        }
+        catch(const std::exception& e) {
+            if(0 == extHandle) {
+                return;
+            }
 
-    return 2;
-}
+            handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
+            if(0 == handle->initialized) {
+                return;
+            }
 
-char
-GEOSPreparedIntersects_r(GEOSContextHandle_t extHandle,
-        const geos::geom::prep::PreparedGeometry *pg, const Geometry *g)
-{
-    assert(0 != pg);
-    assert(0 != g);
+            handle->ERROR_MESSAGE("%s", e.what());
+        }
+        catch(...) {
+            if(0 == extHandle) {
+                return;
+            }
 
-    if ( 0 == extHandle )
-    {
-        return 2;
-    }
+            handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
+            if(0 == handle->initialized) {
+                return;
+            }
 
-    GEOSContextHandleInternal_t *handle = 0;
-    handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
-    if ( 0 == handle->initialized )
-    {
-        return 2;
+            handle->ERROR_MESSAGE("Unknown exception thrown");
+        }
     }
 
-    try
-    {
-        bool result = pg->intersects(g);
-        return result;
-    }
-    catch (const std::exception &e)
+    char
+    GEOSPreparedContains_r(GEOSContextHandle_t extHandle,
+                           const geos::geom::prep::PreparedGeometry* pg, const Geometry* g)
     {
-        handle->ERROR_MESSAGE("%s", e.what());
-    }
-    catch (...)
-    {
-        handle->ERROR_MESSAGE("Unknown exception thrown");
-    }
+        assert(0 != pg);
+        assert(0 != g);
 
-    return 2;
-}
+        if(0 == extHandle) {
+            return 2;
+        }
 
-char
-GEOSPreparedOverlaps_r(GEOSContextHandle_t extHandle,
-        const geos::geom::prep::PreparedGeometry *pg, const Geometry *g)
-{
-    assert(0 != pg);
-    assert(0 != g);
+        GEOSContextHandleInternal_t* handle = 0;
+        handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
+        if(0 == handle->initialized) {
+            return 2;
+        }
 
-    if ( 0 == extHandle )
-    {
-        return 2;
-    }
+        try {
+            bool result = pg->contains(g);
+            return result;
+        }
+        catch(const std::exception& e) {
+            handle->ERROR_MESSAGE("%s", e.what());
+        }
+        catch(...) {
+            handle->ERROR_MESSAGE("Unknown exception thrown");
+        }
 
-    GEOSContextHandleInternal_t *handle = 0;
-    handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
-    if ( 0 == handle->initialized )
-    {
         return 2;
     }
 
-    try
-    {
-        bool result = pg->overlaps(g);
-        return result;
-    }
-    catch (const std::exception &e)
-    {
-        handle->ERROR_MESSAGE("%s", e.what());
-    }
-    catch (...)
+    char
+    GEOSPreparedContainsProperly_r(GEOSContextHandle_t extHandle,
+                                   const geos::geom::prep::PreparedGeometry* pg, const Geometry* g)
     {
-        handle->ERROR_MESSAGE("Unknown exception thrown");
-    }
+        assert(0 != pg);
+        assert(0 != g);
 
-    return 2;
-}
+        if(0 == extHandle) {
+            return 2;
+        }
 
-char
-GEOSPreparedTouches_r(GEOSContextHandle_t extHandle,
-        const geos::geom::prep::PreparedGeometry *pg, const Geometry *g)
-{
-    assert(0 != pg);
-    assert(0 != g);
+        GEOSContextHandleInternal_t* handle = 0;
+        handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
+        if(0 == handle->initialized) {
+            return 2;
+        }
 
-    if ( 0 == extHandle )
-    {
-        return 2;
-    }
+        try {
+            bool result = pg->containsProperly(g);
+            return result;
+        }
+        catch(const std::exception& e) {
+            handle->ERROR_MESSAGE("%s", e.what());
+        }
+        catch(...) {
+            handle->ERROR_MESSAGE("Unknown exception thrown");
+        }
 
-    GEOSContextHandleInternal_t *handle = 0;
-    handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
-    if ( 0 == handle->initialized )
-    {
         return 2;
     }
 
-    try
-    {
-        bool result = pg->touches(g);
-        return result;
-    }
-    catch (const std::exception &e)
-    {
-        handle->ERROR_MESSAGE("%s", e.what());
-    }
-    catch (...)
+    char
+    GEOSPreparedCoveredBy_r(GEOSContextHandle_t extHandle,
+                            const geos::geom::prep::PreparedGeometry* pg, const Geometry* g)
     {
-        handle->ERROR_MESSAGE("Unknown exception thrown");
-    }
+        assert(0 != pg);
+        assert(0 != g);
 
-    return 2;
-}
+        if(0 == extHandle) {
+            return 2;
+        }
 
-char
-GEOSPreparedWithin_r(GEOSContextHandle_t extHandle,
-        const geos::geom::prep::PreparedGeometry *pg, const Geometry *g)
-{
-    assert(0 != pg);
-    assert(0 != g);
+        GEOSContextHandleInternal_t* handle = 0;
+        handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
+        if(0 == handle->initialized) {
+            return 2;
+        }
 
-    if ( 0 == extHandle )
-    {
-        return 2;
-    }
+        try {
+            bool result = pg->coveredBy(g);
+            return result;
+        }
+        catch(const std::exception& e) {
+            handle->ERROR_MESSAGE("%s", e.what());
+        }
+        catch(...) {
+            handle->ERROR_MESSAGE("Unknown exception thrown");
+        }
 
-    GEOSContextHandleInternal_t *handle = 0;
-    handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
-    if ( 0 == handle->initialized )
-    {
         return 2;
     }
 
-    try
-    {
-        bool result = pg->within(g);
-        return result;
-    }
-    catch (const std::exception &e)
-    {
-        handle->ERROR_MESSAGE("%s", e.what());
-    }
-    catch (...)
+    char
+    GEOSPreparedCovers_r(GEOSContextHandle_t extHandle,
+                         const geos::geom::prep::PreparedGeometry* pg, const Geometry* g)
     {
-        handle->ERROR_MESSAGE("Unknown exception thrown");
-    }
+        assert(0 != pg);
+        assert(0 != g);
 
-    return 2;
-}
+        if(0 == extHandle) {
+            return 2;
+        }
 
-//-----------------------------------------------------------------
-// STRtree
-//-----------------------------------------------------------------
+        GEOSContextHandleInternal_t* handle = 0;
+        handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
+        if(0 == handle->initialized) {
+            return 2;
+        }
 
-geos::index::strtree::STRtree *
-GEOSSTRtree_create_r(GEOSContextHandle_t extHandle,
-                                  size_t nodeCapacity)
-{
-    if ( 0 == extHandle )
-    {
-        return 0;
-    }
+        try {
+            bool result = pg->covers(g);
+            return result;
+        }
+        catch(const std::exception& e) {
+            handle->ERROR_MESSAGE("%s", e.what());
+        }
+        catch(...) {
+            handle->ERROR_MESSAGE("Unknown exception thrown");
+        }
 
-    GEOSContextHandleInternal_t *handle = 0;
-    handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
-    if ( 0 == handle->initialized )
-    {
-        return 0;
+        return 2;
     }
 
-    geos::index::strtree::STRtree *tree = 0;
-
-    try
+    char
+    GEOSPreparedCrosses_r(GEOSContextHandle_t extHandle,
+                          const geos::geom::prep::PreparedGeometry* pg, const Geometry* g)
     {
-        tree = new geos::index::strtree::STRtree(nodeCapacity);
-    }
-    catch (const std::exception &e)
-    {
-        handle->ERROR_MESSAGE("%s", e.what());
-    }
-    catch (...)
-    {
-        handle->ERROR_MESSAGE("Unknown exception thrown");
-    }
+        assert(0 != pg);
+        assert(0 != g);
 
-    return tree;
-}
+        if(0 == extHandle) {
+            return 2;
+        }
 
-void
-GEOSSTRtree_insert_r(GEOSContextHandle_t extHandle,
-                     geos::index::strtree::STRtree *tree,
-                     const geos::geom::Geometry *g,
-                     void *item)
-{
-    GEOSContextHandleInternal_t *handle = 0;
-    assert(tree != 0);
-    assert(g != 0);
+        GEOSContextHandleInternal_t* handle = 0;
+        handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
+        if(0 == handle->initialized) {
+            return 2;
+        }
+
+        try {
+            bool result = pg->crosses(g);
+            return result;
+        }
+        catch(const std::exception& e) {
+            handle->ERROR_MESSAGE("%s", e.what());
+        }
+        catch(...) {
+            handle->ERROR_MESSAGE("Unknown exception thrown");
+        }
 
-    try
-    {
-        tree->insert(g->getEnvelopeInternal(), item);
+        return 2;
     }
-    catch (const std::exception &e)
+
+    char
+    GEOSPreparedDisjoint_r(GEOSContextHandle_t extHandle,
+                           const geos::geom::prep::PreparedGeometry* pg, const Geometry* g)
     {
-        if ( 0 == extHandle )
-        {
-            return;
+        assert(0 != pg);
+        assert(0 != g);
+
+        if(0 == extHandle) {
+            return 2;
         }
 
+        GEOSContextHandleInternal_t* handle = 0;
         handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
-        if ( 0 == handle->initialized )
-        {
-            return;
+        if(0 == handle->initialized) {
+            return 2;
         }
 
-        handle->ERROR_MESSAGE("%s", e.what());
-    }
-    catch (...)
-    {
-        if ( 0 == extHandle )
-        {
-            return;
+        try {
+            bool result = pg->disjoint(g);
+            return result;
         }
-
-        handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
-        if ( 0 == handle->initialized )
-        {
-            return;
+        catch(const std::exception& e) {
+            handle->ERROR_MESSAGE("%s", e.what());
+        }
+        catch(...) {
+            handle->ERROR_MESSAGE("Unknown exception thrown");
         }
 
-        handle->ERROR_MESSAGE("Unknown exception thrown");
+        return 2;
     }
-}
-
-void
-GEOSSTRtree_query_r(GEOSContextHandle_t extHandle,
-                    geos::index::strtree::STRtree *tree,
-                    const geos::geom::Geometry *g,
-                    GEOSQueryCallback callback,
-                    void *userdata)
-{
-    GEOSContextHandleInternal_t *handle = 0;
-    assert(tree != 0);
-    assert(g != 0);
-    assert(callback != 0);
 
-    try
-    {
-        CAPI_ItemVisitor visitor(callback, userdata);
-        tree->query(g->getEnvelopeInternal(), visitor);
-    }
-    catch (const std::exception &e)
+    char
+    GEOSPreparedIntersects_r(GEOSContextHandle_t extHandle,
+                             const geos::geom::prep::PreparedGeometry* pg, const Geometry* g)
     {
-        if ( 0 == extHandle )
-        {
-            return;
+        assert(0 != pg);
+        assert(0 != g);
+
+        if(0 == extHandle) {
+            return 2;
         }
 
+        GEOSContextHandleInternal_t* handle = 0;
         handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
-        if ( 0 == handle->initialized )
-        {
-            return;
+        if(0 == handle->initialized) {
+            return 2;
         }
 
-        handle->ERROR_MESSAGE("%s", e.what());
-    }
-    catch (...)
-    {
-        if ( 0 == extHandle )
-        {
-            return;
+        try {
+            bool result = pg->intersects(g);
+            return result;
         }
-
-        handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
-        if ( 0 == handle->initialized )
-        {
-            return;
+        catch(const std::exception& e) {
+            handle->ERROR_MESSAGE("%s", e.what());
+        }
+        catch(...) {
+            handle->ERROR_MESSAGE("Unknown exception thrown");
         }
 
-        handle->ERROR_MESSAGE("Unknown exception thrown");
+        return 2;
     }
-}
 
-const GEOSGeometry *
-GEOSSTRtree_nearest_r(GEOSContextHandle_t extHandle,
-                      geos::index::strtree::STRtree *tree,
-                      const geos::geom::Geometry* geom)
-{
-    return (const GEOSGeometry*) GEOSSTRtree_nearest_generic_r( extHandle, tree, geom, geom, nullptr, nullptr);
-}
+    char
+    GEOSPreparedOverlaps_r(GEOSContextHandle_t extHandle,
+                           const geos::geom::prep::PreparedGeometry* pg, const Geometry* g)
+    {
+        assert(0 != pg);
+        assert(0 != g);
 
-const void *
-GEOSSTRtree_nearest_generic_r(GEOSContextHandle_t extHandle,
-                              geos::index::strtree::STRtree *tree,
-                              const void* item,
-                              const geos::geom::Geometry* itemEnvelope,
-                              GEOSDistanceCallback distancefn,
-                              void* userdata)
-{
-    using namespace geos::index::strtree;
+        if(0 == extHandle) {
+            return 2;
+        }
 
-    GEOSContextHandleInternal_t *handle = 0;
+        GEOSContextHandleInternal_t* handle = 0;
+        handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
+        if(0 == handle->initialized) {
+            return 2;
+        }
 
-		struct CustomItemDistance : public ItemDistance {
-				CustomItemDistance(GEOSDistanceCallback p_distancefn, void* p_userdata)
-								: m_distancefn(p_distancefn), m_userdata(p_userdata) {}
+        try {
+            bool result = pg->overlaps(g);
+            return result;
+        }
+        catch(const std::exception& e) {
+            handle->ERROR_MESSAGE("%s", e.what());
+        }
+        catch(...) {
+            handle->ERROR_MESSAGE("Unknown exception thrown");
+        }
 
-				GEOSDistanceCallback m_distancefn;
-				void* m_userdata;
+        return 2;
+    }
 
-				double distance(const ItemBoundable* item1, const ItemBoundable* item2) override {
-						const void* a = item1->getItem();
-						const void* b = item2->getItem();
-						double d;
+    char
+    GEOSPreparedTouches_r(GEOSContextHandle_t extHandle,
+                          const geos::geom::prep::PreparedGeometry* pg, const Geometry* g)
+    {
+        assert(0 != pg);
+        assert(0 != g);
 
-						if (!m_distancefn(a, b, &d, m_userdata)) {
-								throw std::runtime_error(std::string("Failed to compute distance."));
-						}
+        if(0 == extHandle) {
+            return 2;
+        }
 
-						return d;
-				}
-		};
+        GEOSContextHandleInternal_t* handle = 0;
+        handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
+        if(0 == handle->initialized) {
+            return 2;
+        }
 
-    try
-    {
-        if (distancefn) {
-            CustomItemDistance itemDistance(distancefn, userdata);
-            return tree->nearestNeighbour(itemEnvelope->getEnvelopeInternal(), item, &itemDistance);
-        } else {
-            GeometryItemDistance itemDistance = GeometryItemDistance();
-            return tree->nearestNeighbour(itemEnvelope->getEnvelopeInternal(), item, &itemDistance);
+        try {
+            bool result = pg->touches(g);
+            return result;
         }
-    }
-    catch (const std::exception &e)
-    {
-        if ( 0 == extHandle )
-        {
-            return NULL;
+        catch(const std::exception& e) {
+            handle->ERROR_MESSAGE("%s", e.what());
         }
-
-        handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
-        if ( 0 == handle->initialized )
-        {
-            return NULL;
+        catch(...) {
+            handle->ERROR_MESSAGE("Unknown exception thrown");
         }
 
-        handle->ERROR_MESSAGE("%s", e.what());
+        return 2;
     }
-    catch (...)
+
+    char
+    GEOSPreparedWithin_r(GEOSContextHandle_t extHandle,
+                         const geos::geom::prep::PreparedGeometry* pg, const Geometry* g)
     {
-        if ( 0 == extHandle )
-        {
-            return NULL;
+        assert(0 != pg);
+        assert(0 != g);
+
+        if(0 == extHandle) {
+            return 2;
         }
 
+        GEOSContextHandleInternal_t* handle = 0;
         handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
-        if ( 0 == handle->initialized )
-        {
-            return NULL;
+        if(0 == handle->initialized) {
+            return 2;
         }
 
-        handle->ERROR_MESSAGE("Unknown exception thrown");
-    }
+        try {
+            bool result = pg->within(g);
+            return result;
+        }
+        catch(const std::exception& e) {
+            handle->ERROR_MESSAGE("%s", e.what());
+        }
+        catch(...) {
+            handle->ERROR_MESSAGE("Unknown exception thrown");
+        }
 
-    return NULL;
-}
+        return 2;
+    }
 
-void
-GEOSSTRtree_iterate_r(GEOSContextHandle_t extHandle,
-                    geos::index::strtree::STRtree *tree,
-                    GEOSQueryCallback callback,
-                    void *userdata)
-{
-    GEOSContextHandleInternal_t *handle = 0;
-    assert(tree != 0);
-    assert(callback != 0);
+//-----------------------------------------------------------------
+// STRtree
+//-----------------------------------------------------------------
 
-    try
+    geos::index::strtree::STRtree*
+    GEOSSTRtree_create_r(GEOSContextHandle_t extHandle,
+                         size_t nodeCapacity)
     {
-        CAPI_ItemVisitor visitor(callback, userdata);
-        tree->iterate(visitor);
-    }
-    catch (const std::exception &e)
-    {
-        if ( 0 == extHandle )
-        {
-            return;
+        if(0 == extHandle) {
+            return 0;
         }
 
+        GEOSContextHandleInternal_t* handle = 0;
         handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
-        if ( 0 == handle->initialized )
-        {
-            return;
+        if(0 == handle->initialized) {
+            return 0;
+        }
+
+        geos::index::strtree::STRtree* tree = 0;
+
+        try {
+            tree = new geos::index::strtree::STRtree(nodeCapacity);
+        }
+        catch(const std::exception& e) {
+            handle->ERROR_MESSAGE("%s", e.what());
+        }
+        catch(...) {
+            handle->ERROR_MESSAGE("Unknown exception thrown");
         }
 
-        handle->ERROR_MESSAGE("%s", e.what());
+        return tree;
     }
-    catch (...)
+
+    void
+    GEOSSTRtree_insert_r(GEOSContextHandle_t extHandle,
+                         geos::index::strtree::STRtree* tree,
+                         const geos::geom::Geometry* g,
+                         void* item)
     {
-        if ( 0 == extHandle )
-        {
-            return;
+        GEOSContextHandleInternal_t* handle = 0;
+        assert(tree != 0);
+        assert(g != 0);
+
+        try {
+            tree->insert(g->getEnvelopeInternal(), item);
         }
+        catch(const std::exception& e) {
+            if(0 == extHandle) {
+                return;
+            }
 
-        handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
-        if ( 0 == handle->initialized )
-        {
-            return;
+            handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
+            if(0 == handle->initialized) {
+                return;
+            }
+
+            handle->ERROR_MESSAGE("%s", e.what());
         }
+        catch(...) {
+            if(0 == extHandle) {
+                return;
+            }
+
+            handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
+            if(0 == handle->initialized) {
+                return;
+            }
 
-        handle->ERROR_MESSAGE("Unknown exception thrown");
+            handle->ERROR_MESSAGE("Unknown exception thrown");
+        }
     }
-}
 
-char
-GEOSSTRtree_remove_r(GEOSContextHandle_t extHandle,
-                     geos::index::strtree::STRtree *tree,
-                     const geos::geom::Geometry *g,
-                     void *item)
-{
-    assert(0 != tree);
-    assert(0 != g);
+    void
+    GEOSSTRtree_query_r(GEOSContextHandle_t extHandle,
+                        geos::index::strtree::STRtree* tree,
+                        const geos::geom::Geometry* g,
+                        GEOSQueryCallback callback,
+                        void* userdata)
+    {
+        GEOSContextHandleInternal_t* handle = 0;
+        assert(tree != 0);
+        assert(g != 0);
+        assert(callback != 0);
+
+        try {
+            CAPI_ItemVisitor visitor(callback, userdata);
+            tree->query(g->getEnvelopeInternal(), visitor);
+        }
+        catch(const std::exception& e) {
+            if(0 == extHandle) {
+                return;
+            }
 
-    if ( 0 == extHandle )
-    {
-        return 2;
-    }
+            handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
+            if(0 == handle->initialized) {
+                return;
+            }
 
-    GEOSContextHandleInternal_t *handle = 0;
-    handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
-    if ( 0 == handle->initialized )
-    {
-        return 2;
-    }
+            handle->ERROR_MESSAGE("%s", e.what());
+        }
+        catch(...) {
+            if(0 == extHandle) {
+                return;
+            }
 
-    try
-    {
-        bool result = tree->remove(g->getEnvelopeInternal(), item);
-        return result;
+            handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
+            if(0 == handle->initialized) {
+                return;
+            }
+
+            handle->ERROR_MESSAGE("Unknown exception thrown");
+        }
     }
-    catch (const std::exception &e)
+
+    const GEOSGeometry*
+    GEOSSTRtree_nearest_r(GEOSContextHandle_t extHandle,
+                          geos::index::strtree::STRtree* tree,
+                          const geos::geom::Geometry* geom)
     {
-        handle->ERROR_MESSAGE("%s", e.what());
+        return (const GEOSGeometry*) GEOSSTRtree_nearest_generic_r(extHandle, tree, geom, geom, nullptr, nullptr);
     }
-    catch (...)
+
+    const void*
+    GEOSSTRtree_nearest_generic_r(GEOSContextHandle_t extHandle,
+                                  geos::index::strtree::STRtree* tree,
+                                  const void* item,
+                                  const geos::geom::Geometry* itemEnvelope,
+                                  GEOSDistanceCallback distancefn,
+                                  void* userdata)
     {
-        handle->ERROR_MESSAGE("Unknown exception thrown");
-    }
+        using namespace geos::index::strtree;
 
-    return 2;
-}
+        GEOSContextHandleInternal_t* handle = 0;
 
-void
-GEOSSTRtree_destroy_r(GEOSContextHandle_t extHandle,
-                      geos::index::strtree::STRtree *tree)
-{
-    GEOSContextHandleInternal_t *handle = 0;
+        struct CustomItemDistance : public ItemDistance {
+            CustomItemDistance(GEOSDistanceCallback p_distancefn, void* p_userdata)
+                : m_distancefn(p_distancefn), m_userdata(p_userdata) {}
 
-    try
-    {
-        delete tree;
+            GEOSDistanceCallback m_distancefn;
+            void* m_userdata;
+
+            double
+            distance(const ItemBoundable* item1, const ItemBoundable* item2) override
+            {
+                const void* a = item1->getItem();
+                const void* b = item2->getItem();
+                double d;
+
+                if(!m_distancefn(a, b, &d, m_userdata)) {
+                    throw std::runtime_error(std::string("Failed to compute distance."));
+                }
+
+                return d;
+            }
+        };
+
+        try {
+            if(distancefn) {
+                CustomItemDistance itemDistance(distancefn, userdata);
+                return tree->nearestNeighbour(itemEnvelope->getEnvelopeInternal(), item, &itemDistance);
+            }
+            else {
+                GeometryItemDistance itemDistance = GeometryItemDistance();
+                return tree->nearestNeighbour(itemEnvelope->getEnvelopeInternal(), item, &itemDistance);
+            }
+        }
+        catch(const std::exception& e) {
+            if(0 == extHandle) {
+                return NULL;
+            }
+
+            handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
+            if(0 == handle->initialized) {
+                return NULL;
+            }
+
+            handle->ERROR_MESSAGE("%s", e.what());
+        }
+        catch(...) {
+            if(0 == extHandle) {
+                return NULL;
+            }
+
+            handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
+            if(0 == handle->initialized) {
+                return NULL;
+            }
+
+            handle->ERROR_MESSAGE("Unknown exception thrown");
+        }
+
+        return NULL;
     }
-    catch (const std::exception &e)
-    {
-        if ( 0 == extHandle )
-        {
-            return;
+
+    void
+    GEOSSTRtree_iterate_r(GEOSContextHandle_t extHandle,
+                          geos::index::strtree::STRtree* tree,
+                          GEOSQueryCallback callback,
+                          void* userdata)
+    {
+        GEOSContextHandleInternal_t* handle = 0;
+        assert(tree != 0);
+        assert(callback != 0);
+
+        try {
+            CAPI_ItemVisitor visitor(callback, userdata);
+            tree->iterate(visitor);
         }
+        catch(const std::exception& e) {
+            if(0 == extHandle) {
+                return;
+            }
 
-        handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
-        if ( 0 == handle->initialized )
-        {
-            return;
+            handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
+            if(0 == handle->initialized) {
+                return;
+            }
+
+            handle->ERROR_MESSAGE("%s", e.what());
         }
+        catch(...) {
+            if(0 == extHandle) {
+                return;
+            }
+
+            handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
+            if(0 == handle->initialized) {
+                return;
+            }
 
-        handle->ERROR_MESSAGE("%s", e.what());
+            handle->ERROR_MESSAGE("Unknown exception thrown");
+        }
     }
-    catch (...)
+
+    char
+    GEOSSTRtree_remove_r(GEOSContextHandle_t extHandle,
+                         geos::index::strtree::STRtree* tree,
+                         const geos::geom::Geometry* g,
+                         void* item)
     {
-        if ( 0 == extHandle )
-        {
-            return;
+        assert(0 != tree);
+        assert(0 != g);
+
+        if(0 == extHandle) {
+            return 2;
         }
 
+        GEOSContextHandleInternal_t* handle = 0;
         handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
-        if ( 0 == handle->initialized )
-        {
-            return;
+        if(0 == handle->initialized) {
+            return 2;
         }
 
-        handle->ERROR_MESSAGE("Unknown exception thrown");
-    }
-}
-
-double
-GEOSProject_r(GEOSContextHandle_t extHandle,
-              const Geometry *g,
-              const Geometry *p)
-{
-    if ( 0 == extHandle ) return -1.0;
-    GEOSContextHandleInternal_t *handle =
-        reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
-    if ( handle->initialized == 0 ) return -1.0;
+        try {
+            bool result = tree->remove(g->getEnvelopeInternal(), item);
+            return result;
+        }
+        catch(const std::exception& e) {
+            handle->ERROR_MESSAGE("%s", e.what());
+        }
+        catch(...) {
+            handle->ERROR_MESSAGE("Unknown exception thrown");
+        }
 
-    const geos::geom::Point* point = dynamic_cast<const geos::geom::Point*>(p);
-    if (!point) {
-        handle->ERROR_MESSAGE("third argument of GEOSProject_r must be Point*");
-        return -1.0;
+        return 2;
     }
 
-    const geos::geom::Coordinate* inputPt = p->getCoordinate();
+    void
+    GEOSSTRtree_destroy_r(GEOSContextHandle_t extHandle,
+                          geos::index::strtree::STRtree* tree)
+    {
+        GEOSContextHandleInternal_t* handle = 0;
 
-    try {
-        return geos::linearref::LengthIndexedLine(g).project(*inputPt);
-    } catch (const std::exception &e) {
-        handle->ERROR_MESSAGE("%s", e.what());
-        return -1.0;
-    } catch (...) {
-        handle->ERROR_MESSAGE("Unknown exception thrown");
-        return -1.0;
-    }
-}
+        try {
+            delete tree;
+        }
+        catch(const std::exception& e) {
+            if(0 == extHandle) {
+                return;
+            }
 
+            handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
+            if(0 == handle->initialized) {
+                return;
+            }
 
-Geometry*
-GEOSInterpolate_r(GEOSContextHandle_t extHandle, const Geometry *g, double d)
-{
-    if ( 0 == extHandle ) return 0;
-    GEOSContextHandleInternal_t *handle =
-        reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
-    if ( handle->initialized == 0 ) return 0;
-
-    try {
-    	geos::linearref::LengthIndexedLine lil(g);
-    	geos::geom::Coordinate coord = lil.extractPoint(d);
-    	const GeometryFactory *gf = handle->geomFactory;
-    	Geometry* point = gf->createPoint(coord);
-    	return point;
-    } catch (const std::exception &e) {
-        handle->ERROR_MESSAGE("%s", e.what());
-        return 0;
-    } catch (...) {
-        handle->ERROR_MESSAGE("Unknown exception thrown");
-        return 0;
-    }
-}
+            handle->ERROR_MESSAGE("%s", e.what());
+        }
+        catch(...) {
+            if(0 == extHandle) {
+                return;
+            }
 
+            handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
+            if(0 == handle->initialized) {
+                return;
+            }
 
-double
-GEOSProjectNormalized_r(GEOSContextHandle_t extHandle, const Geometry *g,
-                        const Geometry *p)
-{
+            handle->ERROR_MESSAGE("Unknown exception thrown");
+        }
+    }
 
-    double length;
-    GEOSLength_r(extHandle, g, &length);
-    return GEOSProject_r(extHandle, g, p) / length;
-}
+    double
+    GEOSProject_r(GEOSContextHandle_t extHandle,
+                  const Geometry* g,
+                  const Geometry* p)
+    {
+        if(0 == extHandle) {
+            return -1.0;
+        }
+        GEOSContextHandleInternal_t* handle =
+            reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
+        if(handle->initialized == 0) {
+            return -1.0;
+        }
 
+        const geos::geom::Point* point = dynamic_cast<const geos::geom::Point*>(p);
+        if(!point) {
+            handle->ERROR_MESSAGE("third argument of GEOSProject_r must be Point*");
+            return -1.0;
+        }
 
-Geometry*
-GEOSInterpolateNormalized_r(GEOSContextHandle_t extHandle, const Geometry *g,
-                            double d)
-{
-    double length;
-    GEOSLength_r(extHandle, g, &length);
-    return GEOSInterpolate_r(extHandle, g, d * length);
-}
+        const geos::geom::Coordinate* inputPt = p->getCoordinate();
 
-GEOSGeometry*
-GEOSGeom_extractUniquePoints_r(GEOSContextHandle_t extHandle,
-                              const GEOSGeometry* g)
-{
-    if ( 0 == extHandle ) return 0;
-    GEOSContextHandleInternal_t *handle = 0;
-    handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
-    if ( handle->initialized == 0 ) return 0;
+        try {
+            return geos::linearref::LengthIndexedLine(g).project(*inputPt);
+        }
+        catch(const std::exception& e) {
+            handle->ERROR_MESSAGE("%s", e.what());
+            return -1.0;
+        }
+        catch(...) {
+            handle->ERROR_MESSAGE("Unknown exception thrown");
+            return -1.0;
+        }
+    }
 
-    using namespace geos::geom;
-    using namespace geos::util;
 
-    try
+    Geometry*
+    GEOSInterpolate_r(GEOSContextHandle_t extHandle, const Geometry* g, double d)
     {
+        if(0 == extHandle) {
+            return 0;
+        }
+        GEOSContextHandleInternal_t* handle =
+            reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
+        if(handle->initialized == 0) {
+            return 0;
+        }
+
+        try {
+            geos::linearref::LengthIndexedLine lil(g);
+            geos::geom::Coordinate coord = lil.extractPoint(d);
+            const GeometryFactory* gf = handle->geomFactory;
+            Geometry* point = gf->createPoint(coord);
+            return point;
+        }
+        catch(const std::exception& e) {
+            handle->ERROR_MESSAGE("%s", e.what());
+            return 0;
+        }
+        catch(...) {
+            handle->ERROR_MESSAGE("Unknown exception thrown");
+            return 0;
+        }
+    }
 
-    /* 1: extract points */
-    std::vector<const Coordinate*> coords;
-    UniqueCoordinateArrayFilter filter(coords);
-    g->apply_ro(&filter);
 
-    /* 2: for each point, create a geometry and put into a vector */
-    std::vector<Geometry*>* points = new std::vector<Geometry*>();
-    points->reserve(coords.size());
-    const GeometryFactory* factory = g->getFactory();
-    for (std::vector<const Coordinate*>::iterator it=coords.begin(),
-                                             itE=coords.end();
-                                             it != itE; ++it)
+    double
+    GEOSProjectNormalized_r(GEOSContextHandle_t extHandle, const Geometry* g,
+                            const Geometry* p)
     {
-        Geometry* point = factory->createPoint(*(*it));
-        points->push_back(point);
+
+        double length;
+        GEOSLength_r(extHandle, g, &length);
+        return GEOSProject_r(extHandle, g, p) / length;
     }
 
-    /* 3: create a multipoint */
-    return factory->createMultiPoint(points);
 
-    }
-    catch (const std::exception &e)
+    Geometry*
+    GEOSInterpolateNormalized_r(GEOSContextHandle_t extHandle, const Geometry* g,
+                                double d)
     {
-        handle->ERROR_MESSAGE("%s", e.what());
-        return 0;
+        double length;
+        GEOSLength_r(extHandle, g, &length);
+        return GEOSInterpolate_r(extHandle, g, d * length);
     }
-    catch (...)
+
+    GEOSGeometry*
+    GEOSGeom_extractUniquePoints_r(GEOSContextHandle_t extHandle,
+                                   const GEOSGeometry* g)
     {
-        handle->ERROR_MESSAGE("Unknown exception thrown");
-        return 0;
-    }
-}
+        if(0 == extHandle) {
+            return 0;
+        }
+        GEOSContextHandleInternal_t* handle = 0;
+        handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
+        if(handle->initialized == 0) {
+            return 0;
+        }
 
-int GEOSOrientationIndex_r(GEOSContextHandle_t extHandle,
-	double Ax, double Ay, double Bx, double By, double Px, double Py)
-{
-    GEOSContextHandleInternal_t *handle = 0;
+        using namespace geos::geom;
+        using namespace geos::util;
 
-    using geos::geom::Coordinate;
-    using geos::algorithm::Orientation;
+        try {
 
-    if ( 0 == extHandle )
-    {
-        return 2;
-    }
+            /* 1: extract points */
+            std::vector<const Coordinate*> coords;
+            UniqueCoordinateArrayFilter filter(coords);
+            g->apply_ro(&filter);
 
-    handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
-    if ( 0 == handle->initialized )
-    {
-        return 2;
+            /* 2: for each point, create a geometry and put into a vector */
+            std::vector<Geometry*>* points = new std::vector<Geometry*>();
+            points->reserve(coords.size());
+            const GeometryFactory* factory = g->getFactory();
+            for(std::vector<const Coordinate*>::iterator it = coords.begin(),
+                    itE = coords.end();
+                    it != itE; ++it) {
+                Geometry* point = factory->createPoint(*(*it));
+                points->push_back(point);
+            }
+
+            /* 3: create a multipoint */
+            return factory->createMultiPoint(points);
+
+        }
+        catch(const std::exception& e) {
+            handle->ERROR_MESSAGE("%s", e.what());
+            return 0;
+        }
+        catch(...) {
+            handle->ERROR_MESSAGE("Unknown exception thrown");
+            return 0;
+        }
     }
 
-    try
-    {
-        Coordinate A(Ax, Ay);
-        Coordinate B(Bx, By);
-        Coordinate P(Px, Py);
-        return Orientation::index(A, B, P);
-    }
-    catch (const std::exception &e)
-    {
-        handle->ERROR_MESSAGE("%s", e.what());
-        return 2;
-    }
-    catch (...)
+    int GEOSOrientationIndex_r(GEOSContextHandle_t extHandle,
+                               double Ax, double Ay, double Bx, double By, double Px, double Py)
     {
-        handle->ERROR_MESSAGE("Unknown exception thrown");
-        return 2;
-    }
-}
+        GEOSContextHandleInternal_t* handle = 0;
 
-GEOSGeometry *
-GEOSSharedPaths_r(GEOSContextHandle_t extHandle, const GEOSGeometry* g1, const GEOSGeometry* g2)
-{
-    using namespace geos::operation::sharedpaths;
+        using geos::geom::Coordinate;
+        using geos::algorithm::Orientation;
 
-    if ( 0 == extHandle ) return 0;
-    GEOSContextHandleInternal_t *handle =
-      reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
-    if ( handle->initialized == 0 ) return 0;
+        if(0 == extHandle) {
+            return 2;
+        }
 
-    SharedPathsOp::PathList forw, back;
-    try {
-      SharedPathsOp::sharedPathsOp(*g1, *g2, forw, back);
-    }
-    catch (const std::exception &e)
-    {
-        SharedPathsOp::clearEdges(forw);
-        SharedPathsOp::clearEdges(back);
-        handle->ERROR_MESSAGE("%s", e.what());
-        return 0;
-    }
-    catch (...)
-    {
-        SharedPathsOp::clearEdges(forw);
-        SharedPathsOp::clearEdges(back);
-        handle->ERROR_MESSAGE("Unknown exception thrown");
-        return 0;
+        handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
+        if(0 == handle->initialized) {
+            return 2;
+        }
+
+        try {
+            Coordinate A(Ax, Ay);
+            Coordinate B(Bx, By);
+            Coordinate P(Px, Py);
+            return Orientation::index(A, B, P);
+        }
+        catch(const std::exception& e) {
+            handle->ERROR_MESSAGE("%s", e.what());
+            return 2;
+        }
+        catch(...) {
+            handle->ERROR_MESSAGE("Unknown exception thrown");
+            return 2;
+        }
     }
 
-    // Now forw and back have the geoms we want to use to construct
-    // our output GeometryCollections...
+    GEOSGeometry*
+    GEOSSharedPaths_r(GEOSContextHandle_t extHandle, const GEOSGeometry* g1, const GEOSGeometry* g2)
+    {
+        using namespace geos::operation::sharedpaths;
 
-    const GeometryFactory* factory = g1->getFactory();
-    size_t count;
+        if(0 == extHandle) {
+            return 0;
+        }
+        GEOSContextHandleInternal_t* handle =
+            reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
+        if(handle->initialized == 0) {
+            return 0;
+        }
 
-    std::unique_ptr< std::vector<Geometry*> > out1(
-      new std::vector<Geometry*>()
-    );
-    count = forw.size();
-    out1->reserve(count);
-    for (size_t i=0; i<count; ++i) {
-        out1->push_back(forw[i]);
-    }
-    std::unique_ptr<Geometry> out1g (
-      factory->createMultiLineString(out1.release())
-    );
+        SharedPathsOp::PathList forw, back;
+        try {
+            SharedPathsOp::sharedPathsOp(*g1, *g2, forw, back);
+        }
+        catch(const std::exception& e) {
+            SharedPathsOp::clearEdges(forw);
+            SharedPathsOp::clearEdges(back);
+            handle->ERROR_MESSAGE("%s", e.what());
+            return 0;
+        }
+        catch(...) {
+            SharedPathsOp::clearEdges(forw);
+            SharedPathsOp::clearEdges(back);
+            handle->ERROR_MESSAGE("Unknown exception thrown");
+            return 0;
+        }
 
-    std::unique_ptr< std::vector<Geometry*> > out2(
-      new std::vector<Geometry*>()
-    );
-    count = back.size();
-    out2->reserve(count);
-    for (size_t i=0; i<count; ++i) {
-        out2->push_back(back[i]);
-    }
-    std::unique_ptr<Geometry> out2g (
-      factory->createMultiLineString(out2.release())
-    );
+        // Now forw and back have the geoms we want to use to construct
+        // our output GeometryCollections...
 
-    std::unique_ptr< std::vector<Geometry*> > out(
-      new std::vector<Geometry*>()
-    );
-    out->reserve(2);
-    out->push_back(out1g.release());
-    out->push_back(out2g.release());
+        const GeometryFactory* factory = g1->getFactory();
+        size_t count;
 
-    std::unique_ptr<Geometry> outg (
-      factory->createGeometryCollection(out.release())
-    );
+        std::unique_ptr< std::vector<Geometry*> > out1(
+            new std::vector<Geometry*>()
+        );
+        count = forw.size();
+        out1->reserve(count);
+        for(size_t i = 0; i < count; ++i) {
+            out1->push_back(forw[i]);
+        }
+        std::unique_ptr<Geometry> out1g(
+            factory->createMultiLineString(out1.release())
+        );
 
-    return outg.release();
+        std::unique_ptr< std::vector<Geometry*> > out2(
+            new std::vector<Geometry*>()
+        );
+        count = back.size();
+        out2->reserve(count);
+        for(size_t i = 0; i < count; ++i) {
+            out2->push_back(back[i]);
+        }
+        std::unique_ptr<Geometry> out2g(
+            factory->createMultiLineString(out2.release())
+        );
 
-}
+        std::unique_ptr< std::vector<Geometry*> > out(
+            new std::vector<Geometry*>()
+        );
+        out->reserve(2);
+        out->push_back(out1g.release());
+        out->push_back(out2g.release());
 
-GEOSGeometry *
-GEOSSnap_r(GEOSContextHandle_t extHandle, const GEOSGeometry* g1,
-           const GEOSGeometry* g2, double tolerance)
-{
-    using namespace geos::operation::overlay::snap;
+        std::unique_ptr<Geometry> outg(
+            factory->createGeometryCollection(out.release())
+        );
 
-    if ( 0 == extHandle ) return 0;
-    GEOSContextHandleInternal_t *handle =
-      reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
-    if ( handle->initialized == 0 ) return 0;
+        return outg.release();
 
-    try{
-      GeometrySnapper snapper( *g1 );
-      std::unique_ptr<Geometry> ret = snapper.snapTo(*g2, tolerance);
-      return ret.release();
     }
-    catch (const std::exception &e)
+
+    GEOSGeometry*
+    GEOSSnap_r(GEOSContextHandle_t extHandle, const GEOSGeometry* g1,
+               const GEOSGeometry* g2, double tolerance)
     {
-        handle->ERROR_MESSAGE("%s", e.what());
-        return 0;
+        using namespace geos::operation::overlay::snap;
+
+        if(0 == extHandle) {
+            return 0;
+        }
+        GEOSContextHandleInternal_t* handle =
+            reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
+        if(handle->initialized == 0) {
+            return 0;
+        }
+
+        try {
+            GeometrySnapper snapper(*g1);
+            std::unique_ptr<Geometry> ret = snapper.snapTo(*g2, tolerance);
+            return ret.release();
+        }
+        catch(const std::exception& e) {
+            handle->ERROR_MESSAGE("%s", e.what());
+            return 0;
+        }
+        catch(...) {
+            handle->ERROR_MESSAGE("Unknown exception thrown");
+            return 0;
+        }
     }
-    catch (...)
+
+    BufferParameters*
+    GEOSBufferParams_create_r(GEOSContextHandle_t extHandle)
     {
-        handle->ERROR_MESSAGE("Unknown exception thrown");
-        return 0;
-    }
-}
+        if(0 == extHandle) {
+            return NULL;
+        }
 
-BufferParameters *
-GEOSBufferParams_create_r(GEOSContextHandle_t extHandle)
-{
-    if ( 0 == extHandle ) return NULL;
+        GEOSContextHandleInternal_t* handle = 0;
+        handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
+        if(0 == handle->initialized) {
+            return NULL;
+        }
 
-    GEOSContextHandleInternal_t *handle = 0;
-    handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
-    if ( 0 == handle->initialized ) return NULL;
+        try {
+            BufferParameters* p = new BufferParameters();
+            return p;
+        }
+        catch(const std::exception& e) {
+            handle->ERROR_MESSAGE("%s", e.what());
+        }
+        catch(...) {
+            handle->ERROR_MESSAGE("Unknown exception thrown");
+        }
 
-    try
-    {
-        BufferParameters *p = new BufferParameters();
-        return p;
-    }
-    catch (const std::exception &e)
-    {
-        handle->ERROR_MESSAGE("%s", e.what());
+        return 0;
     }
-    catch (...)
+
+    void
+    GEOSBufferParams_destroy_r(GEOSContextHandle_t extHandle, BufferParameters* p)
     {
-        handle->ERROR_MESSAGE("Unknown exception thrown");
+        (void)extHandle;
+        delete p;
     }
 
-    return 0;
-}
+    int
+    GEOSBufferParams_setEndCapStyle_r(GEOSContextHandle_t extHandle,
+                                      GEOSBufferParams* p, int style)
+    {
+        if(0 == extHandle) {
+            return 0;
+        }
 
-void
-GEOSBufferParams_destroy_r(GEOSContextHandle_t extHandle, BufferParameters* p)
-{
-  (void)extHandle;
-  delete p;
-}
+        GEOSContextHandleInternal_t* handle = 0;
+        handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
+        if(0 == handle->initialized) {
+            return 0;
+        }
 
-int
-GEOSBufferParams_setEndCapStyle_r(GEOSContextHandle_t extHandle,
-  GEOSBufferParams* p, int style)
-{
-    if ( 0 == extHandle ) return 0;
+        try {
+            if(style > BufferParameters::CAP_SQUARE) {
+                throw IllegalArgumentException("Invalid buffer endCap style");
+            }
+            p->setEndCapStyle(static_cast<BufferParameters::EndCapStyle>(style));
+            return 1;
+        }
+        catch(const std::exception& e) {
+            handle->ERROR_MESSAGE("%s", e.what());
+        }
+        catch(...) {
+            handle->ERROR_MESSAGE("Unknown exception thrown");
+        }
 
-    GEOSContextHandleInternal_t *handle = 0;
-    handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
-    if ( 0 == handle->initialized ) return 0;
+        return 0;
+    }
 
-    try
+    int
+    GEOSBufferParams_setJoinStyle_r(GEOSContextHandle_t extHandle,
+                                    GEOSBufferParams* p, int style)
     {
-        if ( style > BufferParameters::CAP_SQUARE )
-        {
-        	throw IllegalArgumentException("Invalid buffer endCap style");
+        if(0 == extHandle) {
+            return 0;
         }
-        p->setEndCapStyle(static_cast<BufferParameters::EndCapStyle>(style));
-        return 1;
-    }
-    catch (const std::exception &e)
-    {
-        handle->ERROR_MESSAGE("%s", e.what());
-    }
-    catch (...)
-    {
-        handle->ERROR_MESSAGE("Unknown exception thrown");
-    }
 
-    return 0;
-}
+        GEOSContextHandleInternal_t* handle = 0;
+        handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
+        if(0 == handle->initialized) {
+            return 0;
+        }
 
-int
-GEOSBufferParams_setJoinStyle_r(GEOSContextHandle_t extHandle,
-  GEOSBufferParams* p, int style)
-{
-    if ( 0 == extHandle ) return 0;
+        try {
+            if(style > BufferParameters::JOIN_BEVEL) {
+                throw IllegalArgumentException("Invalid buffer join style");
+            }
+            p->setJoinStyle(static_cast<BufferParameters::JoinStyle>(style));
+            return 1;
+        }
+        catch(const std::exception& e) {
+            handle->ERROR_MESSAGE("%s", e.what());
+        }
+        catch(...) {
+            handle->ERROR_MESSAGE("Unknown exception thrown");
+        }
 
-    GEOSContextHandleInternal_t *handle = 0;
-    handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
-    if ( 0 == handle->initialized ) return 0;
+        return 0;
+    }
 
-    try
+    int
+    GEOSBufferParams_setMitreLimit_r(GEOSContextHandle_t extHandle,
+                                     GEOSBufferParams* p, double limit)
     {
-        if ( style > BufferParameters::JOIN_BEVEL ) {
-        	throw IllegalArgumentException("Invalid buffer join style");
+        if(0 == extHandle) {
+            return 0;
         }
-        p->setJoinStyle(static_cast<BufferParameters::JoinStyle>(style));
-        return 1;
-    }
-    catch (const std::exception &e)
-    {
-        handle->ERROR_MESSAGE("%s", e.what());
-    }
-    catch (...)
-    {
-        handle->ERROR_MESSAGE("Unknown exception thrown");
-    }
-
-    return 0;
-}
 
-int
-GEOSBufferParams_setMitreLimit_r(GEOSContextHandle_t extHandle,
-  GEOSBufferParams* p, double limit)
-{
-    if ( 0 == extHandle ) return 0;
+        GEOSContextHandleInternal_t* handle = 0;
+        handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
+        if(0 == handle->initialized) {
+            return 0;
+        }
 
-    GEOSContextHandleInternal_t *handle = 0;
-    handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
-    if ( 0 == handle->initialized ) return 0;
+        try {
+            p->setMitreLimit(limit);
+            return 1;
+        }
+        catch(const std::exception& e) {
+            handle->ERROR_MESSAGE("%s", e.what());
+        }
+        catch(...) {
+            handle->ERROR_MESSAGE("Unknown exception thrown");
+        }
 
-    try
-    {
-        p->setMitreLimit(limit);
-        return 1;
-    }
-    catch (const std::exception &e)
-    {
-        handle->ERROR_MESSAGE("%s", e.what());
-    }
-    catch (...)
-    {
-        handle->ERROR_MESSAGE("Unknown exception thrown");
+        return 0;
     }
 
-    return 0;
-}
+    int
+    GEOSBufferParams_setQuadrantSegments_r(GEOSContextHandle_t extHandle,
+                                           GEOSBufferParams* p, int segs)
+    {
+        if(0 == extHandle) {
+            return 0;
+        }
 
-int
-GEOSBufferParams_setQuadrantSegments_r(GEOSContextHandle_t extHandle,
-  GEOSBufferParams* p, int segs)
-{
-    if ( 0 == extHandle ) return 0;
+        GEOSContextHandleInternal_t* handle = 0;
+        handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
+        if(0 == handle->initialized) {
+            return 0;
+        }
 
-    GEOSContextHandleInternal_t *handle = 0;
-    handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
-    if ( 0 == handle->initialized ) return 0;
+        try {
+            p->setQuadrantSegments(segs);
+            return 1;
+        }
+        catch(const std::exception& e) {
+            handle->ERROR_MESSAGE("%s", e.what());
+        }
+        catch(...) {
+            handle->ERROR_MESSAGE("Unknown exception thrown");
+        }
 
-    try
-    {
-        p->setQuadrantSegments(segs);
-        return 1;
-    }
-    catch (const std::exception &e)
-    {
-        handle->ERROR_MESSAGE("%s", e.what());
-    }
-    catch (...)
-    {
-        handle->ERROR_MESSAGE("Unknown exception thrown");
+        return 0;
     }
 
-    return 0;
-}
+    int
+    GEOSBufferParams_setSingleSided_r(GEOSContextHandle_t extHandle,
+                                      GEOSBufferParams* p, int ss)
+    {
+        if(0 == extHandle) {
+            return 0;
+        }
 
-int
-GEOSBufferParams_setSingleSided_r(GEOSContextHandle_t extHandle,
-  GEOSBufferParams* p, int ss)
-{
-    if ( 0 == extHandle ) return 0;
+        GEOSContextHandleInternal_t* handle = 0;
+        handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
+        if(0 == handle->initialized) {
+            return 0;
+        }
 
-    GEOSContextHandleInternal_t *handle = 0;
-    handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
-    if ( 0 == handle->initialized ) return 0;
+        try {
+            p->setSingleSided((ss != 0));
+            return 1;
+        }
+        catch(const std::exception& e) {
+            handle->ERROR_MESSAGE("%s", e.what());
+        }
+        catch(...) {
+            handle->ERROR_MESSAGE("Unknown exception thrown");
+        }
 
-    try
-    {
-        p->setSingleSided( (ss != 0) );
-        return 1;
-    }
-    catch (const std::exception &e)
-    {
-        handle->ERROR_MESSAGE("%s", e.what());
-    }
-    catch (...)
-    {
-        handle->ERROR_MESSAGE("Unknown exception thrown");
+        return 0;
     }
 
-    return 0;
-}
+    Geometry*
+    GEOSBufferWithParams_r(GEOSContextHandle_t extHandle, const Geometry* g1, const BufferParameters* bp, double width)
+    {
+        using geos::operation::buffer::BufferOp;
 
-Geometry *
-GEOSBufferWithParams_r(GEOSContextHandle_t extHandle, const Geometry *g1, const BufferParameters* bp, double width)
-{
-    using geos::operation::buffer::BufferOp;
+        if(0 == extHandle) {
+            return NULL;
+        }
 
-    if ( 0 == extHandle ) return NULL;
+        GEOSContextHandleInternal_t* handle = 0;
+        handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
+        if(0 == handle->initialized) {
+            return NULL;
+        }
 
-    GEOSContextHandleInternal_t *handle = 0;
-    handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
-    if ( 0 == handle->initialized ) return NULL;
+        try {
+            BufferOp op(g1, *bp);
+            Geometry* g3 = op.getResultGeometry(width);
+            return g3;
+        }
+        catch(const std::exception& e) {
+            handle->ERROR_MESSAGE("%s", e.what());
+        }
+        catch(...) {
+            handle->ERROR_MESSAGE("Unknown exception thrown");
+        }
 
-    try
-    {
-        BufferOp op(g1, *bp);
-        Geometry *g3 = op.getResultGeometry(width);
-        return g3;
-    }
-    catch (const std::exception &e)
-    {
-        handle->ERROR_MESSAGE("%s", e.what());
-    }
-    catch (...)
-    {
-        handle->ERROR_MESSAGE("Unknown exception thrown");
+        return NULL;
     }
 
-    return NULL;
-}
+    Geometry*
+    GEOSDelaunayTriangulation_r(GEOSContextHandle_t extHandle, const Geometry* g1, double tolerance, int onlyEdges)
+    {
+        if(0 == extHandle) {
+            return NULL;
+        }
 
-Geometry *
-GEOSDelaunayTriangulation_r(GEOSContextHandle_t extHandle, const Geometry *g1, double tolerance, int onlyEdges)
-{
-    if ( 0 == extHandle ) return NULL;
+        GEOSContextHandleInternal_t* handle = 0;
+        handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
+        if(0 == handle->initialized) {
+            return NULL;
+        }
 
-    GEOSContextHandleInternal_t *handle = 0;
-    handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
-    if ( 0 == handle->initialized ) return NULL;
+        using geos::triangulate::DelaunayTriangulationBuilder;
 
-    using geos::triangulate::DelaunayTriangulationBuilder;
+        try {
+            DelaunayTriangulationBuilder builder;
+            builder.setTolerance(tolerance);
+            builder.setSites(*g1);
 
-    try
-    {
-      DelaunayTriangulationBuilder builder;
-      builder.setTolerance(tolerance);
-      builder.setSites(*g1);
+            if(onlyEdges) {
+                return builder.getEdges(*g1->getFactory()).release();
+            }
+            else {
+                return builder.getTriangles(*g1->getFactory()).release();
+            }
 
-      if ( onlyEdges ) return builder.getEdges( *g1->getFactory() ).release();
-      else return builder.getTriangles( *g1->getFactory() ).release();
+        }
+        catch(const std::exception& e) {
+            handle->ERROR_MESSAGE("%s", e.what());
+        }
+        catch(...) {
+            handle->ERROR_MESSAGE("Unknown exception thrown");
+        }
 
+        return NULL;
     }
-    catch (const std::exception &e)
+    Geometry*
+    GEOSVoronoiDiagram_r(GEOSContextHandle_t extHandle, const Geometry* g1, const Geometry* env, double tolerance,
+                         int onlyEdges)
     {
-        handle->ERROR_MESSAGE("%s", e.what());
+        if(0 == extHandle) {
+            return NULL;
+        }
+
+        GEOSContextHandleInternal_t* handle = 0;
+        handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
+        if(0 == handle->initialized) {
+            return NULL;
+        }
+
+        using geos::triangulate::VoronoiDiagramBuilder;
+
+        try {
+            VoronoiDiagramBuilder builder;
+            builder.setSites(*g1);
+            builder.setTolerance(tolerance);
+            if(env) {
+                builder.setClipEnvelope(env->getEnvelopeInternal());
+            }
+            if(onlyEdges) {
+                return builder.getDiagramEdges(*g1->getFactory()).release();
+            }
+            else {
+                return builder.getDiagram(*g1->getFactory()).release();
+            }
+        }
+        catch(const std::exception& e) {
+            handle->ERROR_MESSAGE("%s", e.what());
+        }
+        catch(...) {
+            handle->ERROR_MESSAGE("Unknown exception thrown");
+        }
+
+        return NULL;
     }
-    catch (...)
+
+    int
+    GEOSSegmentIntersection_r(GEOSContextHandle_t extHandle,
+                              double ax0, double ay0, double ax1, double ay1,
+                              double bx0, double by0, double bx1, double by1,
+                              double* cx, double* cy)
     {
-	    handle->ERROR_MESSAGE("Unknown exception thrown");
-    }
+        if(0 == extHandle) {
+            return 0;
+        }
 
-    return NULL;
-}
-Geometry*
-GEOSVoronoiDiagram_r(GEOSContextHandle_t extHandle, const Geometry *g1, const Geometry *env, double tolerance ,int onlyEdges)
-{
-	if ( 0 == extHandle ) return NULL;
-
-	GEOSContextHandleInternal_t *handle = 0;
-	handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
-	if ( 0 == handle->initialized ) return NULL;
-
-	using geos::triangulate::VoronoiDiagramBuilder;
-
-	try
-	{
-		VoronoiDiagramBuilder builder;
-		builder.setSites(*g1);
-		builder.setTolerance(tolerance);
-    if(env) builder.setClipEnvelope(env->getEnvelopeInternal());
-		if(onlyEdges) return builder.getDiagramEdges(*g1->getFactory()).release();
-		else return builder.getDiagram(*g1->getFactory()).release();
-	}
-	catch(const std::exception &e)
-	{
-		handle->ERROR_MESSAGE("%s", e.what());
-	}
-	catch(...)
-	{
-		handle->ERROR_MESSAGE("Unknown exception thrown");
-	}
-
-	return NULL;
-}
+        GEOSContextHandleInternal_t* handle = 0;
+        handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
+        if(0 == handle->initialized) {
+            return 0;
+        }
 
-int
-GEOSSegmentIntersection_r(GEOSContextHandle_t extHandle,
-    double ax0, double ay0, double ax1, double ay1,
-    double bx0, double by0, double bx1, double by1,
-    double* cx, double* cy)
-{
-    if ( 0 == extHandle ) return 0;
+        try {
+            geos::geom::LineSegment a(ax0, ay0, ax1, ay1);
+            geos::geom::LineSegment b(bx0, by0, bx1, by1);
+            geos::geom::Coordinate isect;
 
-    GEOSContextHandleInternal_t *handle = 0;
-    handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
-    if ( 0 == handle->initialized ) return 0;
+            bool intersects = a.intersection(b, isect);
 
-    try
-    {
-        geos::geom::LineSegment a(ax0, ay0, ax1, ay1);
-        geos::geom::LineSegment b(bx0, by0, bx1, by1);
-        geos::geom::Coordinate isect;
+            if(!intersects) {
+                return -1;
+            }
 
-        bool intersects = a.intersection(b, isect);
+            *cx = isect.x;
+            *cy = isect.y;
 
-        if (!intersects)
-        {
-            return -1;
+            return 1;
+        }
+        catch(const std::exception& e) {
+            handle->ERROR_MESSAGE("%s", e.what());
+        }
+        catch(...) {
+            handle->ERROR_MESSAGE("Unknown exception thrown");
         }
 
-        *cx = isect.x;
-        *cy = isect.y;
-
-        return 1;
-    }
-    catch(const std::exception &e)
-    {
-        handle->ERROR_MESSAGE("%s", e.what());
-    }
-    catch(...)
-    {
-        handle->ERROR_MESSAGE("Unknown exception thrown");
+        return 0;
     }
 
-    return 0;
-}
-
 } /* extern "C" */
 
diff --git a/doc/example.cpp b/doc/example.cpp
index 799ac4a..3756e32 100644
--- a/doc/example.cpp
+++ b/doc/example.cpp
@@ -73,7 +73,7 @@ using geos::util::IllegalArgumentException;
 
 
 // Prototypes
-void wkt_print_geoms(vector<Geometry *> *geoms);
+void wkt_print_geoms(vector<Geometry*>* geoms);
 
 
 // This object will be used to construct our geometries.
@@ -92,104 +92,108 @@ GeometryFactory::Ptr global_factory;
 //	- compare input and output geometries for equality
 //	- remove debugging lines (on stream state)
 //
-void WKBtest(vector<Geometry*>*geoms)
+void
+WKBtest(vector<Geometry*>* geoms)
 {
-	stringstream s(ios_base::binary|ios_base::in|ios_base::out);
-	io::WKBReader wkbReader(*global_factory);
-	io::WKBWriter wkbWriter;
-	Geometry *gout;
+    stringstream s(ios_base::binary | ios_base::in | ios_base::out);
+    io::WKBReader wkbReader(*global_factory);
+    io::WKBWriter wkbWriter;
+    Geometry* gout;
 
 #if DEBUG_STREAM_STATE
-	cout<<"WKBtest: machine byte order: "<<BYTE_ORDER<<endl;
+    cout << "WKBtest: machine byte order: " << BYTE_ORDER << endl;
 #endif
 
 
-	unsigned int ngeoms=geoms->size();
-	for (unsigned int i=0; i<ngeoms; ++i)
-	{
-		Geometry *gin = (*geoms)[i];
+    unsigned int ngeoms = geoms->size();
+    for(unsigned int i = 0; i < ngeoms; ++i) {
+        Geometry* gin = (*geoms)[i];
 
 #if DEBUG_STREAM_STATE
-		cout<<"State of stream before WRITE: ";
-		cout<<"p:"<<s.tellp()<<" g:"<<s.tellg()<<
-			" good:"<<s.good()<<
-			" eof:"<<s.eof()<<
-			" bad:"<<s.bad()<<
-			" fail:"<<s.fail()<<endl;
+        cout << "State of stream before WRITE: ";
+        cout << "p:" << s.tellp() << " g:" << s.tellg() <<
+             " good:" << s.good() <<
+             " eof:" << s.eof() <<
+             " bad:" << s.bad() <<
+             " fail:" << s.fail() << endl;
 #endif
 
 #if DEBUG_STREAM_STATE
-		cout<<"State of stream after SEEKP: ";
-		cout<<"p:"<<s.tellp()<<" g:"<<s.tellg()<<
-			" good:"<<s.good()<<
-			" eof:"<<s.eof()<<
-			" bad:"<<s.bad()<<
-			" fail:"<<s.fail()<<endl;
+        cout << "State of stream after SEEKP: ";
+        cout << "p:" << s.tellp() << " g:" << s.tellg() <<
+             " good:" << s.good() <<
+             " eof:" << s.eof() <<
+             " bad:" << s.bad() <<
+             " fail:" << s.fail() << endl;
 #endif
 
-		wkbWriter.write(*gin, s);
+        wkbWriter.write(*gin, s);
 #if DEBUG_STREAM_STATE
-		cout<<"wkbWriter wrote and reached ";
-		cout<<"p:"<<s.tellp()<<" g:"<<s.tellg()<<endl;
-
-		cout<<"State of stream before DUMP: ";
-		cout<<"p:"<<s.tellp()<<" g:"<<s.tellg()<<
-			" good:"<<s.good()<<
-			" eof:"<<s.eof()<<
-			" bad:"<<s.bad()<<
-			" fail:"<<s.fail()<<endl;
+        cout << "wkbWriter wrote and reached ";
+        cout << "p:" << s.tellp() << " g:" << s.tellg() << endl;
+
+        cout << "State of stream before DUMP: ";
+        cout << "p:" << s.tellp() << " g:" << s.tellg() <<
+             " good:" << s.good() <<
+             " eof:" << s.eof() <<
+             " bad:" << s.bad() <<
+             " fail:" << s.fail() << endl;
 #endif
 
 #if DEBUG_STREAM_STATE
-		cout<<"State of stream after DUMP: ";
-		cout<<"p:"<<s.tellp()<<" g:"<<s.tellg()<<
-			" good:"<<s.good()<<
-			" eof:"<<s.eof()<<
-			" bad:"<<s.bad()<<
-			" fail:"<<s.fail()<<endl;
+        cout << "State of stream after DUMP: ";
+        cout << "p:" << s.tellp() << " g:" << s.tellg() <<
+             " good:" << s.good() <<
+             " eof:" << s.eof() <<
+             " bad:" << s.bad() <<
+             " fail:" << s.fail() << endl;
 #endif
 
-		s.seekg(0, ios::beg); // rewind reader pointer
+        s.seekg(0, ios::beg); // rewind reader pointer
 
 #if DEBUG_STREAM_STATE
-		cout<<"State of stream before READ: ";
-		cout<<"p:"<<s.tellp()<<" g:"<<s.tellg()<<
-			" good:"<<s.good()<<
-			" eof:"<<s.eof()<<
-			" bad:"<<s.bad()<<
-			" fail:"<<s.fail()<<endl;
+        cout << "State of stream before READ: ";
+        cout << "p:" << s.tellp() << " g:" << s.tellg() <<
+             " good:" << s.good() <<
+             " eof:" << s.eof() <<
+             " bad:" << s.bad() <<
+             " fail:" << s.fail() << endl;
 #endif
 
-		gout = wkbReader.read(s);
+        gout = wkbReader.read(s);
 
 #if DEBUG_STREAM_STATE
-		cout<<"State of stream after READ: ";
-		cout<<"p:"<<s.tellp()<<" g:"<<s.tellg()<<
-			" good:"<<s.good()<<
-			" eof:"<<s.eof()<<
-			" bad:"<<s.bad()<<
-			" fail:"<<s.fail()<<endl;
+        cout << "State of stream after READ: ";
+        cout << "p:" << s.tellp() << " g:" << s.tellg() <<
+             " good:" << s.good() <<
+             " eof:" << s.eof() <<
+             " bad:" << s.bad() <<
+             " fail:" << s.fail() << endl;
 #endif
 
-		gin->normalize();
-		gout->normalize();
-		int failed = gin->compareTo(gout);
-		if ( failed ) cout<<"{"<<i<<"} (WKB) ";
-		else cout<<"["<<i<<"] (WKB) ";
+        gin->normalize();
+        gout->normalize();
+        int failed = gin->compareTo(gout);
+        if(failed) {
+            cout << "{" << i << "} (WKB) ";
+        }
+        else {
+            cout << "[" << i << "] (WKB) ";
+        }
 
-		io::WKBReader::printHEX(s, cout);
-		cout<<endl;
+        io::WKBReader::printHEX(s, cout);
+        cout << endl;
 
-		if ( failed ) {
-			io::WKTWriter wkt;
-			cout<<"  IN: "<<wkt.write(gin)<<endl;
-			cout<<" OUT: "<<wkt.write(gout)<<endl;
-		}
+        if(failed) {
+            io::WKTWriter wkt;
+            cout << "  IN: " << wkt.write(gin) << endl;
+            cout << " OUT: " << wkt.write(gout) << endl;
+        }
 
-		s.seekp(0, ios::beg); // rewind writer pointer
+        s.seekp(0, ios::beg); // rewind writer pointer
 
-		delete gout;
-	}
+        delete gout;
+    }
 
 }
 
@@ -198,161 +202,161 @@ void WKBtest(vector<Geometry*>*geoms)
 // format to stdout. As a side-effect, will test WKB
 // output and input, using the WKBtest function.
 void
-wkt_print_geoms(vector<Geometry *> *geoms)
+wkt_print_geoms(vector<Geometry*>* geoms)
 {
-	WKBtest(geoms); // test WKB parser
-
-	// WKT-print given geometries
-	io::WKTWriter *wkt = new io::WKTWriter();
-	for (unsigned int i=0; i<geoms->size(); i++) {
-		const Geometry *g = (*geoms)[i];
-		string tmp=wkt->write(g);
-		cout<<"["<<i<<"] (WKT) "<<tmp<<endl;
-	}
-	delete wkt;
+    WKBtest(geoms); // test WKB parser
+
+    // WKT-print given geometries
+    io::WKTWriter* wkt = new io::WKTWriter();
+    for(unsigned int i = 0; i < geoms->size(); i++) {
+        const Geometry* g = (*geoms)[i];
+        string tmp = wkt->write(g);
+        cout << "[" << i << "] (WKT) " << tmp << endl;
+    }
+    delete wkt;
 }
 
 // This is the simpler geometry you can get: a point.
-Point *
+Point*
 create_point(double x, double y)
 {
-	Coordinate c(x, y);
-	Point *p = global_factory->createPoint(c);
-	return p;
+    Coordinate c(x, y);
+    Point* p = global_factory->createPoint(c);
+    return p;
 }
 
 // This function will create a LinearString
 // geometry with the shape of the letter U
 // having top-left corner at given coordinates
 // and 'side' height and width
-LineString *
+LineString*
 create_ushaped_linestring(double xoffset, double yoffset, double side)
 {
-	// We will use a coordinate list to build the linestring
-	CoordinateSequence *cl = new CoordinateArraySequence();
+    // We will use a coordinate list to build the linestring
+    CoordinateSequence* cl = new CoordinateArraySequence();
 
-	cl->add(Coordinate(xoffset, yoffset));
-	cl->add(Coordinate(xoffset, yoffset+side));
-	cl->add(Coordinate(xoffset+side, yoffset+side));
-	cl->add(Coordinate(xoffset+side, yoffset));
+    cl->add(Coordinate(xoffset, yoffset));
+    cl->add(Coordinate(xoffset, yoffset + side));
+    cl->add(Coordinate(xoffset + side, yoffset + side));
+    cl->add(Coordinate(xoffset + side, yoffset));
 
-	// Now that we have a CoordinateSequence we can create
-	// the linestring.
-	// The newly created LineString will take ownership
-	// of the CoordinateSequence.
-	LineString *ls = global_factory->createLineString(cl);
+    // Now that we have a CoordinateSequence we can create
+    // the linestring.
+    // The newly created LineString will take ownership
+    // of the CoordinateSequence.
+    LineString* ls = global_factory->createLineString(cl);
 
-	// This is what you do if you want the new LineString
-	// to make a copy of your CoordinateSequence:
-	// LineString *ls = global_factory->createLineString(*cl);
+    // This is what you do if you want the new LineString
+    // to make a copy of your CoordinateSequence:
+    // LineString *ls = global_factory->createLineString(*cl);
 
-	return ls; // our LineString
+    return ls; // our LineString
 }
 
 // This function will create a LinearRing
 // geometry rapresenting a square with the given origin
 // and side
-LinearRing *
+LinearRing*
 create_square_linearring(double xoffset, double yoffset, double side)
 {
-	// We will use a coordinate list to build the linearring
-	CoordinateSequence *cl = new CoordinateArraySequence();
-
-	cl->add(Coordinate(xoffset, yoffset));
-	cl->add(Coordinate(xoffset, yoffset+side));
-	cl->add(Coordinate(xoffset+side, yoffset+side));
-	cl->add(Coordinate(xoffset+side, yoffset));
-	cl->add(Coordinate(xoffset, yoffset));
-
-	// Now that we have a CoordinateSequence we can create
-	// the linearring.
-	// The newly created LinearRing will take ownership
-	// of the CoordinateSequence.
-	LinearRing *lr = global_factory->createLinearRing(cl);
-
-	// This is what you do if you want the new LinearRing
-	// to make a copy of your CoordinateSequence:
-	// LinearRing *lr = global_factory->createLinearRing(*cl);
-
-	return lr; // our LinearRing
+    // We will use a coordinate list to build the linearring
+    CoordinateSequence* cl = new CoordinateArraySequence();
+
+    cl->add(Coordinate(xoffset, yoffset));
+    cl->add(Coordinate(xoffset, yoffset + side));
+    cl->add(Coordinate(xoffset + side, yoffset + side));
+    cl->add(Coordinate(xoffset + side, yoffset));
+    cl->add(Coordinate(xoffset, yoffset));
+
+    // Now that we have a CoordinateSequence we can create
+    // the linearring.
+    // The newly created LinearRing will take ownership
+    // of the CoordinateSequence.
+    LinearRing* lr = global_factory->createLinearRing(cl);
+
+    // This is what you do if you want the new LinearRing
+    // to make a copy of your CoordinateSequence:
+    // LinearRing *lr = global_factory->createLinearRing(*cl);
+
+    return lr; // our LinearRing
 }
 
 // This function will create a Polygon
 // geometry rapresenting a square with the given origin
 // and side and with a central hole 1/3 sided.
-Polygon *
+Polygon*
 create_square_polygon(double xoffset, double yoffset, double side)
 {
-	// We need a LinearRing for the polygon shell
-	LinearRing *outer = create_square_linearring(xoffset,yoffset,side);
-
-	// And another for the hole
-	LinearRing *inner = create_square_linearring(xoffset+(side/3),
-			yoffset+(side/3),(side/3));
-
-	// If we need to specify any hole, we do it using
-	// a vector of Geometry pointers (I don't know why
-	// not LinearRings)
-	vector<Geometry *> *holes = new vector<Geometry *>;
-
-	// We add the newly created geometry to the vector
-	// of holes.
-	holes->push_back(inner);
-
-	// And finally we call the polygon constructor.
-	// Both the outer LinearRing and the vector of holes
-	// will be referenced by the resulting Polygon object,
-	// thus we CANNOT delete them, neither the holes, nor
-	// the vector containing their pointers, nor the outer
-	// LinearRing. Everything will be deleted at Polygon
-	// deletion time (this is inconsistent with LinearRing
-	// behaviour... what should we do?).
-	Polygon *poly = global_factory->createPolygon(outer, holes);
-
-	return poly;
+    // We need a LinearRing for the polygon shell
+    LinearRing* outer = create_square_linearring(xoffset, yoffset, side);
+
+    // And another for the hole
+    LinearRing* inner = create_square_linearring(xoffset + (side / 3),
+                        yoffset + (side / 3), (side / 3));
+
+    // If we need to specify any hole, we do it using
+    // a vector of Geometry pointers (I don't know why
+    // not LinearRings)
+    vector<Geometry*>* holes = new vector<Geometry*>;
+
+    // We add the newly created geometry to the vector
+    // of holes.
+    holes->push_back(inner);
+
+    // And finally we call the polygon constructor.
+    // Both the outer LinearRing and the vector of holes
+    // will be referenced by the resulting Polygon object,
+    // thus we CANNOT delete them, neither the holes, nor
+    // the vector containing their pointers, nor the outer
+    // LinearRing. Everything will be deleted at Polygon
+    // deletion time (this is inconsistent with LinearRing
+    // behaviour... what should we do?).
+    Polygon* poly = global_factory->createPolygon(outer, holes);
+
+    return poly;
 }
 
 //
 // This function will create a GeometryCollection
 // containing copies of all Geometries in given vector.
 //
-GeometryCollection *
-create_simple_collection(vector<Geometry *> *geoms)
+GeometryCollection*
+create_simple_collection(vector<Geometry*>* geoms)
 {
-	return global_factory->createGeometryCollection(*geoms);
-	// if you wanted to transfer ownership of vector end
-	// its elements you should have call:
-	// return global_factory->createGeometryCollection(geoms);
+    return global_factory->createGeometryCollection(*geoms);
+    // if you wanted to transfer ownership of vector end
+    // its elements you should have call:
+    // return global_factory->createGeometryCollection(geoms);
 }
 
 //
 // This function uses GeometricShapeFactory to render
 // a circle having given center and radius
 //
-Polygon *
+Polygon*
 create_circle(double centerX, double centerY, double radius)
 {
-	geos::util::GeometricShapeFactory shapefactory(global_factory.get());
-	shapefactory.setCentre(Coordinate(centerX, centerY));
-	shapefactory.setSize(radius);
-	// same as:
-	//	shapefactory.setHeight(radius);
-	//	shapefactory.setWidth(radius);
-	return shapefactory.createCircle();
+    geos::util::GeometricShapeFactory shapefactory(global_factory.get());
+    shapefactory.setCentre(Coordinate(centerX, centerY));
+    shapefactory.setSize(radius);
+    // same as:
+    //	shapefactory.setHeight(radius);
+    //	shapefactory.setWidth(radius);
+    return shapefactory.createCircle();
 }
 
 //
 // This function uses GeometricShapeFactory to render
 // an ellipse having given center and axis size
 //
-Polygon *
+Polygon*
 create_ellipse(double centerX, double centerY, double width, double height)
 {
-	geos::util::GeometricShapeFactory shapefactory(global_factory.get());
-	shapefactory.setCentre(Coordinate(centerX, centerY));
-	shapefactory.setHeight(height);
-	shapefactory.setWidth(width);
-	return shapefactory.createCircle();
+    geos::util::GeometricShapeFactory shapefactory(global_factory.get());
+    shapefactory.setCentre(Coordinate(centerX, centerY));
+    shapefactory.setHeight(height);
+    shapefactory.setWidth(width);
+    return shapefactory.createCircle();
 }
 
 //
@@ -360,16 +364,16 @@ create_ellipse(double centerX, double centerY, double width, double height)
 // a rectangle having lower-left corner at given coordinates
 // and given sizes.
 //
-Polygon *
+Polygon*
 create_rectangle(double llX, double llY, double width, double height)
 {
-	geos::util::GeometricShapeFactory shapefactory(global_factory.get());
-	shapefactory.setBase(Coordinate(llX, llY));
-	shapefactory.setHeight(height);
-	shapefactory.setWidth(width);
-	shapefactory.setNumPoints(4); // we don't need more then 4 points for a rectangle...
-	// can use setSize for a square
-	return shapefactory.createRectangle();
+    geos::util::GeometricShapeFactory shapefactory(global_factory.get());
+    shapefactory.setBase(Coordinate(llX, llY));
+    shapefactory.setHeight(height);
+    shapefactory.setWidth(width);
+    shapefactory.setNumPoints(4); // we don't need more then 4 points for a rectangle...
+    // can use setSize for a square
+    return shapefactory.createRectangle();
 }
 
 //
@@ -377,75 +381,76 @@ create_rectangle(double llX, double llY, double width, double height)
 // an arc having lower-left corner at given coordinates,
 // given sizes and given angles.
 //
-LineString *
+LineString*
 create_arc(double llX, double llY, double width, double height, double startang, double endang)
 {
-	geos::util::GeometricShapeFactory shapefactory(global_factory.get());
-	shapefactory.setBase(Coordinate(llX, llY));
-	shapefactory.setHeight(height);
-	shapefactory.setWidth(width);
-	// shapefactory.setNumPoints(100); // the default (100 pts)
-	// can use setSize for a square
-	return shapefactory.createArc(startang, endang);
+    geos::util::GeometricShapeFactory shapefactory(global_factory.get());
+    shapefactory.setBase(Coordinate(llX, llY));
+    shapefactory.setHeight(height);
+    shapefactory.setWidth(width);
+    // shapefactory.setNumPoints(100); // the default (100 pts)
+    // can use setSize for a square
+    return shapefactory.createArc(startang, endang);
 }
 
 unique_ptr<Polygon>
 create_sinestar(double cx, double cy, double size, int nArms, double armLenRat)
 {
-	geos::geom::util::SineStarFactory fact(global_factory.get());
-	fact.setCentre(Coordinate(cx, cy));
-	fact.setSize(size);
-	fact.setNumPoints(nArms*5);
-  fact.setArmLengthRatio(armLenRat);
-	fact.setNumArms(nArms);
-	return fact.createSineStar();
+    geos::geom::util::SineStarFactory fact(global_factory.get());
+    fact.setCentre(Coordinate(cx, cy));
+    fact.setSize(size);
+    fact.setNumPoints(nArms * 5);
+    fact.setArmLengthRatio(armLenRat);
+    fact.setNumArms(nArms);
+    return fact.createSineStar();
 }
 
 // Start reading here
-void do_all()
+void
+do_all()
 {
-	vector<Geometry *> *geoms = new vector<Geometry *>;
-	vector<Geometry *> *newgeoms;
+    vector<Geometry*>* geoms = new vector<Geometry*>;
+    vector<Geometry*>* newgeoms;
 
-	// Define a precision model using 0,0 as the reference origin
-	// and 2.0 as coordinates scale.
-	PrecisionModel *pm = new PrecisionModel(2.0, 0, 0);
+    // Define a precision model using 0,0 as the reference origin
+    // and 2.0 as coordinates scale.
+    PrecisionModel* pm = new PrecisionModel(2.0, 0, 0);
 
-	// Initialize global factory with defined PrecisionModel
-	// and a SRID of -1 (undefined).
-	global_factory = GeometryFactory::create(pm, -1);
+    // Initialize global factory with defined PrecisionModel
+    // and a SRID of -1 (undefined).
+    global_factory = GeometryFactory::create(pm, -1);
 
-	// We do not need PrecisionMode object anymore, it has
-	// been copied to global_factory private storage
-	delete pm;
+    // We do not need PrecisionMode object anymore, it has
+    // been copied to global_factory private storage
+    delete pm;
 
 ////////////////////////////////////////////////////////////////////////
 // GEOMETRY CREATION
 ////////////////////////////////////////////////////////////////////////
 
-	// Read function bodies to see the magic behind them
-	geoms->push_back(create_point(150, 350));
-	geoms->push_back(create_square_linearring(0,0,100));
-	geoms->push_back(create_ushaped_linestring(60,60,100));
-	geoms->push_back(create_square_linearring(0,0,100));
-	geoms->push_back(create_square_polygon(0,200,300));
-	geoms->push_back(create_square_polygon(0,250,300));
-	geoms->push_back(create_simple_collection(geoms));
+    // Read function bodies to see the magic behind them
+    geoms->push_back(create_point(150, 350));
+    geoms->push_back(create_square_linearring(0, 0, 100));
+    geoms->push_back(create_ushaped_linestring(60, 60, 100));
+    geoms->push_back(create_square_linearring(0, 0, 100));
+    geoms->push_back(create_square_polygon(0, 200, 300));
+    geoms->push_back(create_square_polygon(0, 250, 300));
+    geoms->push_back(create_simple_collection(geoms));
 
 #if GEOMETRIC_SHAPES
-	// These ones use a GeometricShapeFactory
-	geoms->push_back(create_circle(0, 0, 10));
-	geoms->push_back(create_ellipse(0, 0, 8, 12));
-	geoms->push_back(create_rectangle(-5, -5, 10, 10)); // a square
-	geoms->push_back(create_rectangle(-5, -5, 10, 20)); // a rectangle
-	// The upper-right quarter of a vertical ellipse
-	geoms->push_back(create_arc(0, 0, 10, 20, 0, M_PI/2));
-	geoms->push_back(create_sinestar(10, 10, 100, 5, 2).release()); // a sine star
+    // These ones use a GeometricShapeFactory
+    geoms->push_back(create_circle(0, 0, 10));
+    geoms->push_back(create_ellipse(0, 0, 8, 12));
+    geoms->push_back(create_rectangle(-5, -5, 10, 10)); // a square
+    geoms->push_back(create_rectangle(-5, -5, 10, 20)); // a rectangle
+    // The upper-right quarter of a vertical ellipse
+    geoms->push_back(create_arc(0, 0, 10, 20, 0, M_PI / 2));
+    geoms->push_back(create_sinestar(10, 10, 100, 5, 2).release()); // a sine star
 #endif
 
-	// Print all geoms.
-	cout<<"--------HERE ARE THE BASE GEOMS ----------"<<endl;
-	wkt_print_geoms(geoms);
+    // Print all geoms.
+    cout << "--------HERE ARE THE BASE GEOMS ----------" << endl;
+    wkt_print_geoms(geoms);
 
 
 #if UNARY_OPERATIONS
@@ -454,71 +459,71 @@ void do_all()
 // UNARY OPERATIONS
 ////////////////////////////////////////////////////////////////////////
 
-	/////////////////////////////////////////////
-	// CENTROID
-	/////////////////////////////////////////////
-
-	// Find centroid of each base geometry
-	newgeoms = new vector<Geometry *>;
-	for (unsigned int i=0; i<geoms->size(); i++) {
-		Geometry *g = (*geoms)[i];
-		newgeoms->push_back( g->getCentroid() );
-	}
-
-	// Print all convex hulls
-	cout<<endl<<"------- AND HERE ARE THEIR CENTROIDS -----"<<endl;
-	wkt_print_geoms(newgeoms);
-
-	// Delete the centroids
-	for (unsigned int i=0; i<newgeoms->size(); i++) {
-		delete (*newgeoms)[i];
-	}
-	delete newgeoms;
-
-	/////////////////////////////////////////////
-	// BUFFER
-	/////////////////////////////////////////////
-
-	newgeoms = new vector<Geometry *>;
-	for (unsigned int i=0; i<geoms->size(); i++) {
-		Geometry *g = (*geoms)[i];
-		try {
-			Geometry *g2 = g->buffer(10);
-			newgeoms->push_back(g2);
-		}
-		catch (const GEOSException& exc) {
-			cerr <<"GEOS Exception: geometry "<<i<<"->buffer(10): "<<exc.what()<<"\n";
-		}
-	}
-
-	cout<<endl<<"--------HERE COMES THE BUFFERED GEOMS ----------"<<endl;
-	wkt_print_geoms(newgeoms);
-
-	for (unsigned int i=0; i<newgeoms->size(); i++) {
-		delete (*newgeoms)[i];
-	}
-	delete newgeoms;
-
-	/////////////////////////////////////////////
-	// CONVEX HULL
-	/////////////////////////////////////////////
-
-	// Make convex hulls of geometries
-	newgeoms = new vector<Geometry *>;
-	for (unsigned int i=0; i<geoms->size(); i++) {
-		Geometry *g = (*geoms)[i];
-		newgeoms->push_back( g->convexHull() );
-	}
-
-	// Print all convex hulls
-	cout<<endl<<"--------HERE COMES THE HULLS----------"<<endl;
-	wkt_print_geoms(newgeoms);
-
-	// Delete the hulls
-	for (unsigned int i=0; i<newgeoms->size(); i++) {
-		delete (*newgeoms)[i];
-	}
-	delete newgeoms;
+    /////////////////////////////////////////////
+    // CENTROID
+    /////////////////////////////////////////////
+
+    // Find centroid of each base geometry
+    newgeoms = new vector<Geometry*>;
+    for(unsigned int i = 0; i < geoms->size(); i++) {
+        Geometry* g = (*geoms)[i];
+        newgeoms->push_back(g->getCentroid());
+    }
+
+    // Print all convex hulls
+    cout << endl << "------- AND HERE ARE THEIR CENTROIDS -----" << endl;
+    wkt_print_geoms(newgeoms);
+
+    // Delete the centroids
+    for(unsigned int i = 0; i < newgeoms->size(); i++) {
+        delete(*newgeoms)[i];
+    }
+    delete newgeoms;
+
+    /////////////////////////////////////////////
+    // BUFFER
+    /////////////////////////////////////////////
+
+    newgeoms = new vector<Geometry*>;
+    for(unsigned int i = 0; i < geoms->size(); i++) {
+        Geometry* g = (*geoms)[i];
+        try {
+            Geometry* g2 = g->buffer(10);
+            newgeoms->push_back(g2);
+        }
+        catch(const GEOSException& exc) {
+            cerr << "GEOS Exception: geometry " << i << "->buffer(10): " << exc.what() << "\n";
+        }
+    }
+
+    cout << endl << "--------HERE COMES THE BUFFERED GEOMS ----------" << endl;
+    wkt_print_geoms(newgeoms);
+
+    for(unsigned int i = 0; i < newgeoms->size(); i++) {
+        delete(*newgeoms)[i];
+    }
+    delete newgeoms;
+
+    /////////////////////////////////////////////
+    // CONVEX HULL
+    /////////////////////////////////////////////
+
+    // Make convex hulls of geometries
+    newgeoms = new vector<Geometry*>;
+    for(unsigned int i = 0; i < geoms->size(); i++) {
+        Geometry* g = (*geoms)[i];
+        newgeoms->push_back(g->convexHull());
+    }
+
+    // Print all convex hulls
+    cout << endl << "--------HERE COMES THE HULLS----------" << endl;
+    wkt_print_geoms(newgeoms);
+
+    // Delete the hulls
+    for(unsigned int i = 0; i < newgeoms->size(); i++) {
+        delete(*newgeoms)[i];
+    }
+    delete newgeoms;
 
 #endif // UNARY_OPERATIONS
 
@@ -528,348 +533,392 @@ void do_all()
 // RELATIONAL OPERATORS
 ////////////////////////////////////////////////////////////////////////
 
-cout<<"-------------------------------------------------------------------------------"<<endl;
-cout<<"RELATIONAL OPERATORS"<<endl;
-cout<<"-------------------------------------------------------------------------------"<<endl;
-
-	/////////////////////////////////////////////
-	// DISJOINT
-	/////////////////////////////////////////////
-
-	cout<<endl;
-	cout<<"   DISJOINT   ";
-	for (unsigned int i=0; i<geoms->size(); i++) {
-		cout<<"\t["<<i<<"]";
-	}
-	cout<<endl;
-	for (unsigned int i=0; i<geoms->size(); i++) {
-		Geometry *g1 = (*geoms)[i];
-		cout<<"      ["<<i<<"]\t";
-		for (unsigned int j=0; j<geoms->size(); j++) {
-			Geometry *g2 = (*geoms)[j];
-			try {
-				if ( g1->disjoint(g2) ) cout<<" 1\t";
-				else cout<<" 0\t";
-			}
-			// Geometry Collection is not a valid argument
-			catch (const IllegalArgumentException& exc) {
-				cout<<" X\t";
-			}
-			catch (const std::exception& exc) {
-				cerr<<exc.what()<<endl;
-			}
-		}
-		cout<<endl;
-	}
-
-	/////////////////////////////////////////////
-	// TOUCHES
-	/////////////////////////////////////////////
-
-	cout<<endl;
-	cout<<"    TOUCHES   ";
-	for (unsigned int i=0; i<geoms->size(); i++) {
-		cout<<"\t["<<i<<"]";
-	}
-	cout<<endl;
-	for (unsigned int i=0; i<geoms->size(); i++) {
-		Geometry *g1 = (*geoms)[i];
-		cout<<"      ["<<i<<"]\t";
-		for (unsigned int j=0; j<geoms->size(); j++) {
-			Geometry *g2 = (*geoms)[j];
-			try {
-				if ( g1->touches(g2) ) cout<<" 1\t";
-				else cout<<" 0\t";
-			}
-			// Geometry Collection is not a valid argument
-			catch (const IllegalArgumentException& exc) {
-				cout<<" X\t";
-			}
-			catch (const std::exception& exc) {
-				cerr<<exc.what()<<endl;
-			}
-		}
-		cout<<endl;
-	}
-
-	/////////////////////////////////////////////
-	// INTERSECTS
-	/////////////////////////////////////////////
-
-	cout<<endl;
-	cout<<" INTERSECTS   ";
-	for (unsigned int i=0; i<geoms->size(); i++) {
-		cout<<"\t["<<i<<"]";
-	}
-	cout<<endl;
-	for (unsigned int i=0; i<geoms->size(); i++) {
-		Geometry *g1 = (*geoms)[i];
-		cout<<"      ["<<i<<"]\t";
-		for (unsigned int j=0; j<geoms->size(); j++) {
-			Geometry *g2 = (*geoms)[j];
-			try {
-				if ( g1->intersects(g2) ) cout<<" 1\t";
-				else cout<<" 0\t";
-			}
-			// Geometry Collection is not a valid argument
-			catch (const IllegalArgumentException& exc) {
-				cout<<" X\t";
-			}
-			catch (const std::exception& exc) {
-				cerr<<exc.what()<<endl;
-			}
-		}
-		cout<<endl;
-	}
-
-	/////////////////////////////////////////////
-	// CROSSES
-	/////////////////////////////////////////////
-
-	cout<<endl;
-	cout<<"    CROSSES   ";
-	for (unsigned int i=0; i<geoms->size(); i++) {
-		cout<<"\t["<<i<<"]";
-	}
-	cout<<endl;
-	for (unsigned int i=0; i<geoms->size(); i++) {
-		Geometry *g1 = (*geoms)[i];
-		cout<<"      ["<<i<<"]\t";
-		for (unsigned int j=0; j<geoms->size(); j++) {
-			Geometry *g2 = (*geoms)[j];
-			try {
-				if ( g1->crosses(g2) ) cout<<" 1\t";
-				else cout<<" 0\t";
-			}
-			// Geometry Collection is not a valid argument
-			catch (const IllegalArgumentException& exc) {
-				cout<<" X\t";
-			}
-			catch (const std::exception& exc) {
-				cerr<<exc.what()<<endl;
-			}
-		}
-		cout<<endl;
-	}
-
-	/////////////////////////////////////////////
-	// WITHIN
-	/////////////////////////////////////////////
-
-	cout<<endl;
-	cout<<"     WITHIN   ";
-	for (unsigned int i=0; i<geoms->size(); i++) {
-		cout<<"\t["<<i<<"]";
-	}
-	cout<<endl;
-	for (unsigned int i=0; i<geoms->size(); i++) {
-		Geometry *g1 = (*geoms)[i];
-		cout<<"      ["<<i<<"]\t";
-		for (unsigned int j=0; j<geoms->size(); j++) {
-			Geometry *g2 = (*geoms)[j];
-			try {
-				if ( g1->within(g2) ) cout<<" 1\t";
-				else cout<<" 0\t";
-			}
-			// Geometry Collection is not a valid argument
-			catch (const IllegalArgumentException& exc) {
-				cout<<" X\t";
-			}
-			catch (const std::exception& exc) {
-				cerr<<exc.what()<<endl;
-			}
-		}
-		cout<<endl;
-	}
-
-	/////////////////////////////////////////////
-	// CONTAINS
-	/////////////////////////////////////////////
-
-	cout<<endl;
-	cout<<"   CONTAINS   ";
-	for (unsigned int i=0; i<geoms->size(); i++) {
-		cout<<"\t["<<i<<"]";
-	}
-	cout<<endl;
-	for (unsigned int i=0; i<geoms->size(); i++) {
-		Geometry *g1 = (*geoms)[i];
-		cout<<"      ["<<i<<"]\t";
-		for (unsigned int j=0; j<geoms->size(); j++) {
-			Geometry *g2 = (*geoms)[j];
-			try {
-				if ( g1->contains(g2) ) cout<<" 1\t";
-				else cout<<" 0\t";
-			}
-			// Geometry Collection is not a valid argument
-			catch (const IllegalArgumentException& exc) {
-				cout<<" X\t";
-			}
-			catch (const std::exception& exc) {
-				cerr<<exc.what()<<endl;
-			}
-		}
-		cout<<endl;
-	}
-
-	/////////////////////////////////////////////
-	// OVERLAPS
-	/////////////////////////////////////////////
-
-	cout<<endl;
-	cout<<"   OVERLAPS   ";
-	for (unsigned int i=0; i<geoms->size(); i++) {
-		cout<<"\t["<<i<<"]";
-	}
-	cout<<endl;
-	for (unsigned int i=0; i<geoms->size(); i++) {
-		Geometry *g1 = (*geoms)[i];
-		cout<<"      ["<<i<<"]\t";
-		for (unsigned int j=0; j<geoms->size(); j++) {
-			Geometry *g2 = (*geoms)[j];
-			try {
-				if ( g1->overlaps(g2) ) cout<<" 1\t";
-				else cout<<" 0\t";
-			}
-			// Geometry Collection is not a valid argument
-			catch (const IllegalArgumentException& exc) {
-				cout<<" X\t";
-			}
-			catch (const std::exception& exc) {
-				cerr<<exc.what()<<endl;
-			}
-		}
-		cout<<endl;
-	}
-
-	/////////////////////////////////////////////
-	// RELATE
-	/////////////////////////////////////////////
-
-	cout<<endl;
-	cout<<"     RELATE   ";
-	for (unsigned int i=0; i<geoms->size(); i++) {
-		cout<<"\t["<<i<<"]";
-	}
-	cout<<endl;
-	for (unsigned int i=0; i<geoms->size(); i++) {
-		Geometry *g1 = (*geoms)[i];
-		cout<<"      ["<<i<<"]\t";
-		for (unsigned int j=0; j<geoms->size(); j++) {
-			Geometry *g2 = (*geoms)[j];
-			IntersectionMatrix *im=NULL;
-			try {
-				// second argument is intersectionPattern
-				string pattern = "212101212";
-				if ( g1->relate(g2, pattern) ) cout<<" 1\t";
-				else cout<<" 0\t";
-
-				// get the intersectionMatrix itself
-				im=g1->relate(g2);
-				delete im; // delete afterwards
-			}
-			// Geometry Collection is not a valid argument
-			catch (const IllegalArgumentException& exc) {
-				cout<<" X\t";
-			}
-			catch (const std::exception& exc) {
-				cerr<<exc.what()<<endl;
-			}
-		}
-		cout<<endl;
-	}
-
-	/////////////////////////////////////////////
-	// EQUALS
-	/////////////////////////////////////////////
-
-	cout<<endl;
-	cout<<"     EQUALS   ";
-	for (unsigned int i=0; i<geoms->size(); i++) {
-		cout<<"\t["<<i<<"]";
-	}
-	cout<<endl;
-	for (unsigned int i=0; i<geoms->size(); i++) {
-		Geometry *g1 = (*geoms)[i];
-		cout<<"      ["<<i<<"]\t";
-		for (unsigned int j=0; j<geoms->size(); j++) {
-			Geometry *g2 = (*geoms)[j];
-			try {
-				if ( g1->equals(g2) ) cout<<" 1\t";
-				else cout<<" 0\t";
-			}
-			// Geometry Collection is not a valid argument
-			catch (const IllegalArgumentException& exc) {
-				cout<<" X\t";
-			}
-			catch (const std::exception& exc) {
-				cerr<<exc.what()<<endl;
-			}
-		}
-		cout<<endl;
-	}
-
-	/////////////////////////////////////////////
-	// EQUALS_EXACT
-	/////////////////////////////////////////////
-
-	cout<<endl;
-	cout<<"EQUALS_EXACT  ";
-	for (unsigned int i=0; i<geoms->size(); i++) {
-		cout<<"\t["<<i<<"]";
-	}
-	cout<<endl;
-	for (unsigned int i=0; i<geoms->size(); i++) {
-		Geometry *g1 = (*geoms)[i];
-		cout<<"      ["<<i<<"]\t";
-		for (unsigned int j=0; j<geoms->size(); j++) {
-			Geometry *g2 = (*geoms)[j];
-			try {
-				// second argument is a tolerance
-				if ( g1->equalsExact(g2, 0.5) ) cout<<" 1\t";
-				else cout<<" 0\t";
-			}
-			// Geometry Collection is not a valid argument
-			catch (const IllegalArgumentException& exc) {
-				cout<<" X\t";
-			}
-			catch (const std::exception& exc) {
-				cerr<<exc.what()<<endl;
-			}
-		}
-		cout<<endl;
-	}
-
-	/////////////////////////////////////////////
-	// IS_WITHIN_DISTANCE
-	/////////////////////////////////////////////
-
-	cout<<endl;
-	cout<<"IS_WITHIN_DIST";
-	for (unsigned int i=0; i<geoms->size(); i++) {
-		cout<<"\t["<<i<<"]";
-	}
-	cout<<endl;
-	for (unsigned int i=0; i<geoms->size(); i++) {
-		Geometry *g1 = (*geoms)[i];
-		cout<<"      ["<<i<<"]\t";
-		for (unsigned int j=0; j<geoms->size(); j++) {
-			Geometry *g2 = (*geoms)[j];
-			try {
-				// second argument is the distance
-				if ( g1->isWithinDistance(g2,2) ) cout<<" 1\t";
-				else cout<<" 0\t";
-			}
-			// Geometry Collection is not a valid argument
-			catch (const IllegalArgumentException& exc) {
-				cout<<" X\t";
-			}
-			catch (const std::exception& exc) {
-				cerr<<exc.what()<<endl;
-			}
-		}
-		cout<<endl;
-	}
+    cout << "-------------------------------------------------------------------------------" << endl;
+    cout << "RELATIONAL OPERATORS" << endl;
+    cout << "-------------------------------------------------------------------------------" << endl;
+
+    /////////////////////////////////////////////
+    // DISJOINT
+    /////////////////////////////////////////////
+
+    cout << endl;
+    cout << "   DISJOINT   ";
+    for(unsigned int i = 0; i < geoms->size(); i++) {
+        cout << "\t[" << i << "]";
+    }
+    cout << endl;
+    for(unsigned int i = 0; i < geoms->size(); i++) {
+        Geometry* g1 = (*geoms)[i];
+        cout << "      [" << i << "]\t";
+        for(unsigned int j = 0; j < geoms->size(); j++) {
+            Geometry* g2 = (*geoms)[j];
+            try {
+                if(g1->disjoint(g2)) {
+                    cout << " 1\t";
+                }
+                else {
+                    cout << " 0\t";
+                }
+            }
+            // Geometry Collection is not a valid argument
+            catch(const IllegalArgumentException& exc) {
+                cout << " X\t";
+            }
+            catch(const std::exception& exc) {
+                cerr << exc.what() << endl;
+            }
+        }
+        cout << endl;
+    }
+
+    /////////////////////////////////////////////
+    // TOUCHES
+    /////////////////////////////////////////////
+
+    cout << endl;
+    cout << "    TOUCHES   ";
+    for(unsigned int i = 0; i < geoms->size(); i++) {
+        cout << "\t[" << i << "]";
+    }
+    cout << endl;
+    for(unsigned int i = 0; i < geoms->size(); i++) {
+        Geometry* g1 = (*geoms)[i];
+        cout << "      [" << i << "]\t";
+        for(unsigned int j = 0; j < geoms->size(); j++) {
+            Geometry* g2 = (*geoms)[j];
+            try {
+                if(g1->touches(g2)) {
+                    cout << " 1\t";
+                }
+                else {
+                    cout << " 0\t";
+                }
+            }
+            // Geometry Collection is not a valid argument
+            catch(const IllegalArgumentException& exc) {
+                cout << " X\t";
+            }
+            catch(const std::exception& exc) {
+                cerr << exc.what() << endl;
+            }
+        }
+        cout << endl;
+    }
+
+    /////////////////////////////////////////////
+    // INTERSECTS
+    /////////////////////////////////////////////
+
+    cout << endl;
+    cout << " INTERSECTS   ";
+    for(unsigned int i = 0; i < geoms->size(); i++) {
+        cout << "\t[" << i << "]";
+    }
+    cout << endl;
+    for(unsigned int i = 0; i < geoms->size(); i++) {
+        Geometry* g1 = (*geoms)[i];
+        cout << "      [" << i << "]\t";
+        for(unsigned int j = 0; j < geoms->size(); j++) {
+            Geometry* g2 = (*geoms)[j];
+            try {
+                if(g1->intersects(g2)) {
+                    cout << " 1\t";
+                }
+                else {
+                    cout << " 0\t";
+                }
+            }
+            // Geometry Collection is not a valid argument
+            catch(const IllegalArgumentException& exc) {
+                cout << " X\t";
+            }
+            catch(const std::exception& exc) {
+                cerr << exc.what() << endl;
+            }
+        }
+        cout << endl;
+    }
+
+    /////////////////////////////////////////////
+    // CROSSES
+    /////////////////////////////////////////////
+
+    cout << endl;
+    cout << "    CROSSES   ";
+    for(unsigned int i = 0; i < geoms->size(); i++) {
+        cout << "\t[" << i << "]";
+    }
+    cout << endl;
+    for(unsigned int i = 0; i < geoms->size(); i++) {
+        Geometry* g1 = (*geoms)[i];
+        cout << "      [" << i << "]\t";
+        for(unsigned int j = 0; j < geoms->size(); j++) {
+            Geometry* g2 = (*geoms)[j];
+            try {
+                if(g1->crosses(g2)) {
+                    cout << " 1\t";
+                }
+                else {
+                    cout << " 0\t";
+                }
+            }
+            // Geometry Collection is not a valid argument
+            catch(const IllegalArgumentException& exc) {
+                cout << " X\t";
+            }
+            catch(const std::exception& exc) {
+                cerr << exc.what() << endl;
+            }
+        }
+        cout << endl;
+    }
+
+    /////////////////////////////////////////////
+    // WITHIN
+    /////////////////////////////////////////////
+
+    cout << endl;
+    cout << "     WITHIN   ";
+    for(unsigned int i = 0; i < geoms->size(); i++) {
+        cout << "\t[" << i << "]";
+    }
+    cout << endl;
+    for(unsigned int i = 0; i < geoms->size(); i++) {
+        Geometry* g1 = (*geoms)[i];
+        cout << "      [" << i << "]\t";
+        for(unsigned int j = 0; j < geoms->size(); j++) {
+            Geometry* g2 = (*geoms)[j];
+            try {
+                if(g1->within(g2)) {
+                    cout << " 1\t";
+                }
+                else {
+                    cout << " 0\t";
+                }
+            }
+            // Geometry Collection is not a valid argument
+            catch(const IllegalArgumentException& exc) {
+                cout << " X\t";
+            }
+            catch(const std::exception& exc) {
+                cerr << exc.what() << endl;
+            }
+        }
+        cout << endl;
+    }
+
+    /////////////////////////////////////////////
+    // CONTAINS
+    /////////////////////////////////////////////
+
+    cout << endl;
+    cout << "   CONTAINS   ";
+    for(unsigned int i = 0; i < geoms->size(); i++) {
+        cout << "\t[" << i << "]";
+    }
+    cout << endl;
+    for(unsigned int i = 0; i < geoms->size(); i++) {
+        Geometry* g1 = (*geoms)[i];
+        cout << "      [" << i << "]\t";
+        for(unsigned int j = 0; j < geoms->size(); j++) {
+            Geometry* g2 = (*geoms)[j];
+            try {
+                if(g1->contains(g2)) {
+                    cout << " 1\t";
+                }
+                else {
+                    cout << " 0\t";
+                }
+            }
+            // Geometry Collection is not a valid argument
+            catch(const IllegalArgumentException& exc) {
+                cout << " X\t";
+            }
+            catch(const std::exception& exc) {
+                cerr << exc.what() << endl;
+            }
+        }
+        cout << endl;
+    }
+
+    /////////////////////////////////////////////
+    // OVERLAPS
+    /////////////////////////////////////////////
+
+    cout << endl;
+    cout << "   OVERLAPS   ";
+    for(unsigned int i = 0; i < geoms->size(); i++) {
+        cout << "\t[" << i << "]";
+    }
+    cout << endl;
+    for(unsigned int i = 0; i < geoms->size(); i++) {
+        Geometry* g1 = (*geoms)[i];
+        cout << "      [" << i << "]\t";
+        for(unsigned int j = 0; j < geoms->size(); j++) {
+            Geometry* g2 = (*geoms)[j];
+            try {
+                if(g1->overlaps(g2)) {
+                    cout << " 1\t";
+                }
+                else {
+                    cout << " 0\t";
+                }
+            }
+            // Geometry Collection is not a valid argument
+            catch(const IllegalArgumentException& exc) {
+                cout << " X\t";
+            }
+            catch(const std::exception& exc) {
+                cerr << exc.what() << endl;
+            }
+        }
+        cout << endl;
+    }
+
+    /////////////////////////////////////////////
+    // RELATE
+    /////////////////////////////////////////////
+
+    cout << endl;
+    cout << "     RELATE   ";
+    for(unsigned int i = 0; i < geoms->size(); i++) {
+        cout << "\t[" << i << "]";
+    }
+    cout << endl;
+    for(unsigned int i = 0; i < geoms->size(); i++) {
+        Geometry* g1 = (*geoms)[i];
+        cout << "      [" << i << "]\t";
+        for(unsigned int j = 0; j < geoms->size(); j++) {
+            Geometry* g2 = (*geoms)[j];
+            IntersectionMatrix* im = NULL;
+            try {
+                // second argument is intersectionPattern
+                string pattern = "212101212";
+                if(g1->relate(g2, pattern)) {
+                    cout << " 1\t";
+                }
+                else {
+                    cout << " 0\t";
+                }
+
+                // get the intersectionMatrix itself
+                im = g1->relate(g2);
+                delete im; // delete afterwards
+            }
+            // Geometry Collection is not a valid argument
+            catch(const IllegalArgumentException& exc) {
+                cout << " X\t";
+            }
+            catch(const std::exception& exc) {
+                cerr << exc.what() << endl;
+            }
+        }
+        cout << endl;
+    }
+
+    /////////////////////////////////////////////
+    // EQUALS
+    /////////////////////////////////////////////
+
+    cout << endl;
+    cout << "     EQUALS   ";
+    for(unsigned int i = 0; i < geoms->size(); i++) {
+        cout << "\t[" << i << "]";
+    }
+    cout << endl;
+    for(unsigned int i = 0; i < geoms->size(); i++) {
+        Geometry* g1 = (*geoms)[i];
+        cout << "      [" << i << "]\t";
+        for(unsigned int j = 0; j < geoms->size(); j++) {
+            Geometry* g2 = (*geoms)[j];
+            try {
+                if(g1->equals(g2)) {
+                    cout << " 1\t";
+                }
+                else {
+                    cout << " 0\t";
+                }
+            }
+            // Geometry Collection is not a valid argument
+            catch(const IllegalArgumentException& exc) {
+                cout << " X\t";
+            }
+            catch(const std::exception& exc) {
+                cerr << exc.what() << endl;
+            }
+        }
+        cout << endl;
+    }
+
+    /////////////////////////////////////////////
+    // EQUALS_EXACT
+    /////////////////////////////////////////////
+
+    cout << endl;
+    cout << "EQUALS_EXACT  ";
+    for(unsigned int i = 0; i < geoms->size(); i++) {
+        cout << "\t[" << i << "]";
+    }
+    cout << endl;
+    for(unsigned int i = 0; i < geoms->size(); i++) {
+        Geometry* g1 = (*geoms)[i];
+        cout << "      [" << i << "]\t";
+        for(unsigned int j = 0; j < geoms->size(); j++) {
+            Geometry* g2 = (*geoms)[j];
+            try {
+                // second argument is a tolerance
+                if(g1->equalsExact(g2, 0.5)) {
+                    cout << " 1\t";
+                }
+                else {
+                    cout << " 0\t";
+                }
+            }
+            // Geometry Collection is not a valid argument
+            catch(const IllegalArgumentException& exc) {
+                cout << " X\t";
+            }
+            catch(const std::exception& exc) {
+                cerr << exc.what() << endl;
+            }
+        }
+        cout << endl;
+    }
+
+    /////////////////////////////////////////////
+    // IS_WITHIN_DISTANCE
+    /////////////////////////////////////////////
+
+    cout << endl;
+    cout << "IS_WITHIN_DIST";
+    for(unsigned int i = 0; i < geoms->size(); i++) {
+        cout << "\t[" << i << "]";
+    }
+    cout << endl;
+    for(unsigned int i = 0; i < geoms->size(); i++) {
+        Geometry* g1 = (*geoms)[i];
+        cout << "      [" << i << "]\t";
+        for(unsigned int j = 0; j < geoms->size(); j++) {
+            Geometry* g2 = (*geoms)[j];
+            try {
+                // second argument is the distance
+                if(g1->isWithinDistance(g2, 2)) {
+                    cout << " 1\t";
+                }
+                else {
+                    cout << " 0\t";
+                }
+            }
+            // Geometry Collection is not a valid argument
+            catch(const IllegalArgumentException& exc) {
+                cout << " X\t";
+            }
+            catch(const std::exception& exc) {
+                cerr << exc.what() << endl;
+            }
+        }
+        cout << endl;
+    }
 
 #endif // RELATIONAL_OPERATORS
 
@@ -879,235 +928,233 @@ cout<<"-------------------------------------------------------------------------
 // COMBINATIONS
 ////////////////////////////////////////////////////////////////////////
 
-cout<<endl;
-cout<<"-------------------------------------------------------------------------------"<<endl;
-cout<<"COMBINATIONS"<<endl;
-cout<<"-------------------------------------------------------------------------------"<<endl;
-
-	/////////////////////////////////////////////
-	// UNION
-	/////////////////////////////////////////////
-
-	// Make unions of all geoms
-	newgeoms = new vector<Geometry *>;
-	for (unsigned int i=0; i<geoms->size()-1; i++) {
-		Geometry *g1 = (*geoms)[i];
-		for (unsigned int j=i+1; j<geoms->size(); j++) {
-			Geometry *g2 = (*geoms)[j];
-			try {
-				Geometry *g3 = g1->Union(g2);
-				newgeoms->push_back(g3);
-			}
-			// It's illegal to union a collection ...
-			catch (const IllegalArgumentException& ill) {
-				//cerr <<ill.toString()<<"\n";
-			}
-			catch (const std::exception& exc) {
-				cerr<<exc.what()<<endl;
-			}
-		}
-	}
-
-	// Print all unions
-	cout<<endl<<"----- AND HERE ARE SOME UNION COMBINATIONS ------"<<endl;
-	wkt_print_geoms(newgeoms);
-
-	// Delete the resulting geoms
-	for (unsigned int i=0; i<newgeoms->size(); i++) {
-		delete (*newgeoms)[i];
-	}
-	delete newgeoms;
-
-
-	/////////////////////////////////////////////
-	// INTERSECTION
-	/////////////////////////////////////////////
-
-	// Compute intersection of adhiacent geometries
-	newgeoms = new vector<Geometry *>;
-	for (unsigned int i=0; i<geoms->size()-1; i++) {
-		Geometry *g1 = (*geoms)[i];
-		for (unsigned int j=i+1; j<geoms->size(); j++) {
-			Geometry *g2 = (*geoms)[j];
-			try {
-				Geometry *g3 = g1->intersection(g2);
-				newgeoms->push_back(g3);
-			}
-			// Collection are illegal as intersection argument
-			catch (const IllegalArgumentException& ill) {
-				//cerr <<ill.toString()<<"\n";
-			}
-			catch (const std::exception& exc) {
-				cerr<<exc.what()<<endl;
-			}
-		}
-	}
-
-	cout<<endl<<"----- HERE ARE SOME INTERSECTIONS COMBINATIONS ------"<<endl;
-	wkt_print_geoms(newgeoms);
-
-	// Delete the resulting geoms
-	for (unsigned int i=0; i<newgeoms->size(); i++) {
-		delete (*newgeoms)[i];
-	}
-	delete newgeoms;
-
-	/////////////////////////////////////////////
-	// DIFFERENCE
-	/////////////////////////////////////////////
-
-	// Compute difference of adhiacent geometries
-	newgeoms = new vector<Geometry *>;
-	for (unsigned int i=0; i<geoms->size()-1; i++) {
-		Geometry *g1 = (*geoms)[i];
-		for (unsigned int j=i+1; j<geoms->size(); j++) {
-			Geometry *g2 = (*geoms)[j];
-			try {
-				Geometry *g3 = g1->difference(g2);
-				newgeoms->push_back(g3);
-			}
-			// Collection are illegal as difference argument
-			catch (const IllegalArgumentException& ill) {
-				//cerr <<ill.toString()<<"\n";
-			}
-			catch (const std::exception& exc) {
-				cerr<<exc.what()<<endl;
-			}
-		}
-	}
-
-	cout<<endl<<"----- HERE ARE SOME DIFFERENCE COMBINATIONS ------"<<endl;
-	wkt_print_geoms(newgeoms);
-
-	// Delete the resulting geoms
-	for (unsigned int i=0; i<newgeoms->size(); i++) {
-		delete (*newgeoms)[i];
-	}
-	delete newgeoms;
-
-	/////////////////////////////////////////////
-	// SYMMETRIC DIFFERENCE
-	/////////////////////////////////////////////
-
-	// Compute symmetric difference of adhiacent geometries
-	newgeoms = new vector<Geometry *>;
-	for (unsigned int i=0; i<geoms->size()-1; i++) {
-		Geometry *g1 = (*geoms)[i];
-		for (unsigned int j=i+1; j<geoms->size(); j++) {
-			Geometry *g2 = (*geoms)[j];
-			try {
-				Geometry *g3 = g1->symDifference(g2);
-				newgeoms->push_back(g3);
-			}
-			// Collection are illegal as symdifference argument
-			catch (const IllegalArgumentException& ill) {
-				//cerr <<ill.toString()<<"\n";
-			}
-			catch (const std::exception& exc) {
-				cerr<<exc.what()<<endl;
-			}
-		}
-	}
-
-	cout<<endl<<"----- HERE ARE SYMMETRIC DIFFERENCES ------"<<endl;
-	wkt_print_geoms(newgeoms);
-
-	// Delete the resulting geoms
-	for (unsigned int i=0; i<newgeoms->size(); i++) {
-		delete (*newgeoms)[i];
-	}
-	delete newgeoms;
+    cout << endl;
+    cout << "-------------------------------------------------------------------------------" << endl;
+    cout << "COMBINATIONS" << endl;
+    cout << "-------------------------------------------------------------------------------" << endl;
+
+    /////////////////////////////////////////////
+    // UNION
+    /////////////////////////////////////////////
+
+    // Make unions of all geoms
+    newgeoms = new vector<Geometry*>;
+    for(unsigned int i = 0; i < geoms->size() - 1; i++) {
+        Geometry* g1 = (*geoms)[i];
+        for(unsigned int j = i + 1; j < geoms->size(); j++) {
+            Geometry* g2 = (*geoms)[j];
+            try {
+                Geometry* g3 = g1->Union(g2);
+                newgeoms->push_back(g3);
+            }
+            // It's illegal to union a collection ...
+            catch(const IllegalArgumentException& ill) {
+                //cerr <<ill.toString()<<"\n";
+            }
+            catch(const std::exception& exc) {
+                cerr << exc.what() << endl;
+            }
+        }
+    }
+
+    // Print all unions
+    cout << endl << "----- AND HERE ARE SOME UNION COMBINATIONS ------" << endl;
+    wkt_print_geoms(newgeoms);
+
+    // Delete the resulting geoms
+    for(unsigned int i = 0; i < newgeoms->size(); i++) {
+        delete(*newgeoms)[i];
+    }
+    delete newgeoms;
+
+
+    /////////////////////////////////////////////
+    // INTERSECTION
+    /////////////////////////////////////////////
+
+    // Compute intersection of adhiacent geometries
+    newgeoms = new vector<Geometry*>;
+    for(unsigned int i = 0; i < geoms->size() - 1; i++) {
+        Geometry* g1 = (*geoms)[i];
+        for(unsigned int j = i + 1; j < geoms->size(); j++) {
+            Geometry* g2 = (*geoms)[j];
+            try {
+                Geometry* g3 = g1->intersection(g2);
+                newgeoms->push_back(g3);
+            }
+            // Collection are illegal as intersection argument
+            catch(const IllegalArgumentException& ill) {
+                //cerr <<ill.toString()<<"\n";
+            }
+            catch(const std::exception& exc) {
+                cerr << exc.what() << endl;
+            }
+        }
+    }
+
+    cout << endl << "----- HERE ARE SOME INTERSECTIONS COMBINATIONS ------" << endl;
+    wkt_print_geoms(newgeoms);
+
+    // Delete the resulting geoms
+    for(unsigned int i = 0; i < newgeoms->size(); i++) {
+        delete(*newgeoms)[i];
+    }
+    delete newgeoms;
+
+    /////////////////////////////////////////////
+    // DIFFERENCE
+    /////////////////////////////////////////////
+
+    // Compute difference of adhiacent geometries
+    newgeoms = new vector<Geometry*>;
+    for(unsigned int i = 0; i < geoms->size() - 1; i++) {
+        Geometry* g1 = (*geoms)[i];
+        for(unsigned int j = i + 1; j < geoms->size(); j++) {
+            Geometry* g2 = (*geoms)[j];
+            try {
+                Geometry* g3 = g1->difference(g2);
+                newgeoms->push_back(g3);
+            }
+            // Collection are illegal as difference argument
+            catch(const IllegalArgumentException& ill) {
+                //cerr <<ill.toString()<<"\n";
+            }
+            catch(const std::exception& exc) {
+                cerr << exc.what() << endl;
+            }
+        }
+    }
+
+    cout << endl << "----- HERE ARE SOME DIFFERENCE COMBINATIONS ------" << endl;
+    wkt_print_geoms(newgeoms);
+
+    // Delete the resulting geoms
+    for(unsigned int i = 0; i < newgeoms->size(); i++) {
+        delete(*newgeoms)[i];
+    }
+    delete newgeoms;
+
+    /////////////////////////////////////////////
+    // SYMMETRIC DIFFERENCE
+    /////////////////////////////////////////////
+
+    // Compute symmetric difference of adhiacent geometries
+    newgeoms = new vector<Geometry*>;
+    for(unsigned int i = 0; i < geoms->size() - 1; i++) {
+        Geometry* g1 = (*geoms)[i];
+        for(unsigned int j = i + 1; j < geoms->size(); j++) {
+            Geometry* g2 = (*geoms)[j];
+            try {
+                Geometry* g3 = g1->symDifference(g2);
+                newgeoms->push_back(g3);
+            }
+            // Collection are illegal as symdifference argument
+            catch(const IllegalArgumentException& ill) {
+                //cerr <<ill.toString()<<"\n";
+            }
+            catch(const std::exception& exc) {
+                cerr << exc.what() << endl;
+            }
+        }
+    }
+
+    cout << endl << "----- HERE ARE SYMMETRIC DIFFERENCES ------" << endl;
+    wkt_print_geoms(newgeoms);
+
+    // Delete the resulting geoms
+    for(unsigned int i = 0; i < newgeoms->size(); i++) {
+        delete(*newgeoms)[i];
+    }
+    delete newgeoms;
 
 #endif // COMBINATIONS
 
 #if LINEMERGE
 
-	/////////////////////////////////////////////
-	// LINEMERGE
-	/////////////////////////////////////////////
-	LineMerger lm;
-	lm.add(geoms);
-	vector<LineString *> *mls = lm.getMergedLineStrings();
-	newgeoms = new vector<Geometry *>;
-	for (unsigned int i=0; i<mls->size(); i++)
-		newgeoms->push_back((*mls)[i]);
-	delete mls;
-
-	cout<<endl<<"----- HERE IS THE LINEMERGE OUTPUT ------"<<endl;
-	wkt_print_geoms(newgeoms);
-
-	// Delete the resulting geoms
-	for (unsigned int i=0; i<newgeoms->size(); i++) {
-		delete (*newgeoms)[i];
-	}
-	delete newgeoms;
+    /////////////////////////////////////////////
+    // LINEMERGE
+    /////////////////////////////////////////////
+    LineMerger lm;
+    lm.add(geoms);
+    vector<LineString*>* mls = lm.getMergedLineStrings();
+    newgeoms = new vector<Geometry*>;
+    for(unsigned int i = 0; i < mls->size(); i++) {
+        newgeoms->push_back((*mls)[i]);
+    }
+    delete mls;
+
+    cout << endl << "----- HERE IS THE LINEMERGE OUTPUT ------" << endl;
+    wkt_print_geoms(newgeoms);
+
+    // Delete the resulting geoms
+    for(unsigned int i = 0; i < newgeoms->size(); i++) {
+        delete(*newgeoms)[i];
+    }
+    delete newgeoms;
 
 #endif // LINEMERGE
 
 #if POLYGONIZE
 
-	/////////////////////////////////////////////
-	// POLYGONIZE
-	/////////////////////////////////////////////
-	Polygonizer plgnzr;
-	plgnzr.add(geoms);
-	vector<Polygon *> *polys = plgnzr.getPolygons();
-	newgeoms = new vector<Geometry *>;
-	for (unsigned int i=0; i<polys->size(); i++)
-		newgeoms->push_back((*polys)[i]);
-	delete polys;
-
-	cout<<endl<<"----- HERE IS POLYGONIZE OUTPUT ------"<<endl;
-	wkt_print_geoms(newgeoms);
-
-	// Delete the resulting geoms
-	for (unsigned int i=0; i<newgeoms->size(); i++) {
-		delete (*newgeoms)[i];
-	}
-	delete newgeoms;
+    /////////////////////////////////////////////
+    // POLYGONIZE
+    /////////////////////////////////////////////
+    Polygonizer plgnzr;
+    plgnzr.add(geoms);
+    vector<Polygon*>* polys = plgnzr.getPolygons();
+    newgeoms = new vector<Geometry*>;
+    for(unsigned int i = 0; i < polys->size(); i++) {
+        newgeoms->push_back((*polys)[i]);
+    }
+    delete polys;
+
+    cout << endl << "----- HERE IS POLYGONIZE OUTPUT ------" << endl;
+    wkt_print_geoms(newgeoms);
+
+    // Delete the resulting geoms
+    for(unsigned int i = 0; i < newgeoms->size(); i++) {
+        delete(*newgeoms)[i];
+    }
+    delete newgeoms;
 
 #endif // POLYGONIZE
 
-	/////////////////////////////////////////////
-	// CLEANUP
-	/////////////////////////////////////////////
+    /////////////////////////////////////////////
+    // CLEANUP
+    /////////////////////////////////////////////
 
-	// Delete base geometries
-	for (unsigned int i=0; i<geoms->size(); i++) {
-		delete (*geoms)[i];
-	}
-	delete geoms;
+    // Delete base geometries
+    for(unsigned int i = 0; i < geoms->size(); i++) {
+        delete(*geoms)[i];
+    }
+    delete geoms;
 }
 
 int
 main()
 {
-	cout<<"GEOS "<<geosversion()<<" ported from JTS "<<jtsport()<<endl;
-	try
-	{
-		do_all();
-	}
-	// All exception thrown by GEOS are subclasses of this
-	// one, so this is a catch-all
-	catch (const GEOSException& exc)
-	{
-		cerr <<"GEOS Exception: "<<exc.what()<<"\n";
-		exit(1);
-	}
-	catch (const exception &e)
-	{
-		cerr <<"Standard exception thrown: "<<e.what()<<endl;
-		exit(1);
-	}
-	// and this is a catch-all non standard ;)
-	catch (...)
-	{
-		cerr <<"unknown exception trown!\n";
-		exit(1);
-	}
-
-	// Unload is no more necessary
-	//io::Unload::Release();
-
-	exit(0);
+    cout << "GEOS " << geosversion() << " ported from JTS " << jtsport() << endl;
+    try {
+        do_all();
+    }
+    // All exception thrown by GEOS are subclasses of this
+    // one, so this is a catch-all
+    catch(const GEOSException& exc) {
+        cerr << "GEOS Exception: " << exc.what() << "\n";
+        exit(1);
+    }
+    catch(const exception& e) {
+        cerr << "Standard exception thrown: " << e.what() << endl;
+        exit(1);
+    }
+    // and this is a catch-all non standard ;)
+    catch(...) {
+        cerr << "unknown exception trown!\n";
+        exit(1);
+    }
+
+    // Unload is no more necessary
+    //io::Unload::Release();
+
+    exit(0);
 }
diff --git a/include/geos/algorithm/Angle.h b/include/geos/algorithm/Angle.h
index 314d5e4..d329a78 100644
--- a/include/geos/algorithm/Angle.h
+++ b/include/geos/algorithm/Angle.h
@@ -24,9 +24,9 @@
 
 // Forward declarations
 namespace geos {
-	namespace geom {
-		class Coordinate;
-	}
+namespace geom {
+class Coordinate;
+}
 }
 
 namespace geos {
@@ -36,188 +36,187 @@ namespace algorithm { // geos::algorithm
 //
 /// Unless otherwise noted, methods in this class express angles in radians.
 ///
-class GEOS_DLL Angle
-{
+class GEOS_DLL Angle {
 public:
 
-	static const double PI_TIMES_2; // 2.0 * PI;
-	static const double PI_OVER_2; // PI / 2.0;
-	static const double PI_OVER_4; // PI / 4.0;
-
-	/// Constant representing counterclockwise orientation
-	static const int COUNTERCLOCKWISE = Orientation::COUNTERCLOCKWISE;
-
-	/// Constant representing clockwise orientation
-	static const int CLOCKWISE = Orientation::CLOCKWISE;
-
-	/// Constant representing no orientation
-	static const int NONE = Orientation::COLLINEAR;
-
-	/// Converts from radians to degrees.
-	//
-	/// @param radians an angle in radians
-	/// @return the angle in degrees
-	///
-	static double toDegrees(double radians);
-
-	/// Converts from degrees to radians.
-	//
-	/// @param angleDegrees an angle in degrees
-	/// @return the angle in radians
-	///
-	static double toRadians(double angleDegrees);
-
-	/// \brief
-	/// Returns the angle of the vector from p0 to p1,
-	/// relative to the positive X-axis.
-	//
-	/// The angle is normalized to be in the range [ -Pi, Pi ].
-	///
-	/// @return the normalized angle (in radians) that p0-p1 makes
-	///         with the positive x-axis.
-	///
-	static double angle(const geom::Coordinate& p0,
-	                    const geom::Coordinate& p1);
-
-	/// \brief
-	/// Returns the angle that the vector from (0,0) to p,
-	/// relative to the positive X-axis.
-	//
-	/// The angle is normalized to be in the range ( -Pi, Pi ].
-	///
-	/// @return the normalized angle (in radians) that p makes
-	///          with the positive x-axis.
-	///
-	static double angle(const geom::Coordinate& p);
-
-	/// Tests whether the angle between p0-p1-p2 is acute.
-	//
-	/// An angle is acute if it is less than 90 degrees.
-	///
-	/// Note: this implementation is not precise (determistic) for
-	///       angles very close to 90 degrees.
-	///
-	/// @param p0 an endpoint of the angle
-	/// @param p1 the base of the angle
-	/// @param p2 the other endpoint of the angle
-	///
-	static bool isAcute(const geom::Coordinate& p0,
-	                    const geom::Coordinate& p1,
-	                    const geom::Coordinate& p2);
-
-	/// Tests whether the angle between p0-p1-p2 is obtuse.
-	//
-	/// An angle is obtuse if it is greater than 90 degrees.
-	///
-	/// Note: this implementation is not precise (determistic) for
-	///       angles very close to 90 degrees.
-	///
-	/// @param p0 an endpoint of the angle
-	/// @param p1 the base of the angle
-	/// @param p2 the other endpoint of the angle
-	///
-	static bool isObtuse(const geom::Coordinate& p0,
-	                     const geom::Coordinate& p1,
-	                     const geom::Coordinate& p2);
-
-	/// Returns the unoriented smallest angle between two vectors.
-	//
-	/// The computed angle will be in the range [0, Pi).
-	///
-	/// @param tip1 the tip of one vector
-	/// @param tail the tail of each vector
-	/// @param tip2 the tip of the other vector
-	/// @return the angle between tail-tip1 and tail-tip2
-	///
-	static double angleBetween(const geom::Coordinate& tip1,
-	                           const geom::Coordinate& tail,
-	                           const geom::Coordinate& tip2);
-
-	/// Returns the oriented smallest angle between two vectors.
-	//
-	/// The computed angle will be in the range (-Pi, Pi].
-	/// A positive result corresponds to a counterclockwise rotation
-	/// from v1 to v2;
-	/// a negative result corresponds to a clockwise rotation.
-	///
-	/// @param tip1 the tip of v1
-	/// @param tail the tail of each vector
-	/// @param tip2 the tip of v2
-	/// @return the angle between v1 and v2, relative to v1
-	///
-	static double angleBetweenOriented(const geom::Coordinate& tip1,
-	                                   const geom::Coordinate& tail,
-	                                   const geom::Coordinate& tip2);
-
-	/// Computes the interior angle between two segments of a ring.
-	//
-	/// The ring is assumed to be oriented in a clockwise direction.
-	/// The computed angle will be in the range [0, 2Pi]
-	///
-	/// @param p0
-	///          a point of the ring
-	/// @param p1
-	///          the next point of the ring
-	/// @param p2
-	///          the next point of the ring
-	/// @return the interior angle based at <code>p1</code>
-	///
-	static double interiorAngle(const geom::Coordinate& p0,
-	                            const geom::Coordinate& p1,
-	                            const geom::Coordinate& p2);
-
-	/// \brief
-	/// Returns whether an angle must turn clockwise or counterclockwise
-	/// to overlap another angle.
-	///
-	/// @param ang1 an angle (in radians)
-	/// @param ang2 an angle (in radians)
-	/// @return whether a1 must turn CLOCKWISE, COUNTERCLOCKWISE or
-	///         NONE to overlap a2.
-	///
-	static int getTurn(double ang1, double ang2);
-
-	/// \brief
-	/// Computes the normalized value of an angle, which is the
-	/// equivalent angle in the range ( -Pi, Pi ].
-	///
-	/// @param angle the angle to normalize
-	/// @return an equivalent angle in the range (-Pi, Pi]
-	///
-	static double normalize(double angle);
-
-	/// \brief
-	/// Computes the normalized positive value of an angle,
-	/// which is the equivalent angle in the range [ 0, 2*Pi ).
-	///
-	/// E.g.:
-	/// - normalizePositive(0.0) = 0.0
-	/// - normalizePositive(-PI) = PI
-	/// - normalizePositive(-2PI) = 0.0
-	/// - normalizePositive(-3PI) = PI
-	/// - normalizePositive(-4PI) = 0
-	/// - normalizePositive(PI) = PI
-	/// - normalizePositive(2PI) = 0.0
-	/// - normalizePositive(3PI) = PI
-	/// - normalizePositive(4PI) = 0.0
-	///
-	/// @param angle the angle to normalize, in radians
-	/// @return an equivalent positive angle
-	///
-	static double normalizePositive(double angle);
-
-
-	/// Computes the unoriented smallest difference between two angles.
-	//
-	/// The angles are assumed to be normalized to the range [-Pi, Pi].
-	/// The result will be in the range [0, Pi].
-	///
-	/// @param ang1 the angle of one vector (in [-Pi, Pi] )
-	/// @param ang2 the angle of the other vector (in range [-Pi, Pi] )
-	/// @return the angle (in radians) between the two vectors
-	///         (in range [0, Pi] )
-	///
-	static double diff(double ang1, double ang2);
+    static const double PI_TIMES_2; // 2.0 * PI;
+    static const double PI_OVER_2; // PI / 2.0;
+    static const double PI_OVER_4; // PI / 4.0;
+
+    /// Constant representing counterclockwise orientation
+    static const int COUNTERCLOCKWISE = Orientation::COUNTERCLOCKWISE;
+
+    /// Constant representing clockwise orientation
+    static const int CLOCKWISE = Orientation::CLOCKWISE;
+
+    /// Constant representing no orientation
+    static const int NONE = Orientation::COLLINEAR;
+
+    /// Converts from radians to degrees.
+    //
+    /// @param radians an angle in radians
+    /// @return the angle in degrees
+    ///
+    static double toDegrees(double radians);
+
+    /// Converts from degrees to radians.
+    //
+    /// @param angleDegrees an angle in degrees
+    /// @return the angle in radians
+    ///
+    static double toRadians(double angleDegrees);
+
+    /// \brief
+    /// Returns the angle of the vector from p0 to p1,
+    /// relative to the positive X-axis.
+    //
+    /// The angle is normalized to be in the range [ -Pi, Pi ].
+    ///
+    /// @return the normalized angle (in radians) that p0-p1 makes
+    ///         with the positive x-axis.
+    ///
+    static double angle(const geom::Coordinate& p0,
+                        const geom::Coordinate& p1);
+
+    /// \brief
+    /// Returns the angle that the vector from (0,0) to p,
+    /// relative to the positive X-axis.
+    //
+    /// The angle is normalized to be in the range ( -Pi, Pi ].
+    ///
+    /// @return the normalized angle (in radians) that p makes
+    ///          with the positive x-axis.
+    ///
+    static double angle(const geom::Coordinate& p);
+
+    /// Tests whether the angle between p0-p1-p2 is acute.
+    //
+    /// An angle is acute if it is less than 90 degrees.
+    ///
+    /// Note: this implementation is not precise (determistic) for
+    ///       angles very close to 90 degrees.
+    ///
+    /// @param p0 an endpoint of the angle
+    /// @param p1 the base of the angle
+    /// @param p2 the other endpoint of the angle
+    ///
+    static bool isAcute(const geom::Coordinate& p0,
+                        const geom::Coordinate& p1,
+                        const geom::Coordinate& p2);
+
+    /// Tests whether the angle between p0-p1-p2 is obtuse.
+    //
+    /// An angle is obtuse if it is greater than 90 degrees.
+    ///
+    /// Note: this implementation is not precise (determistic) for
+    ///       angles very close to 90 degrees.
+    ///
+    /// @param p0 an endpoint of the angle
+    /// @param p1 the base of the angle
+    /// @param p2 the other endpoint of the angle
+    ///
+    static bool isObtuse(const geom::Coordinate& p0,
+                         const geom::Coordinate& p1,
+                         const geom::Coordinate& p2);
+
+    /// Returns the unoriented smallest angle between two vectors.
+    //
+    /// The computed angle will be in the range [0, Pi).
+    ///
+    /// @param tip1 the tip of one vector
+    /// @param tail the tail of each vector
+    /// @param tip2 the tip of the other vector
+    /// @return the angle between tail-tip1 and tail-tip2
+    ///
+    static double angleBetween(const geom::Coordinate& tip1,
+                               const geom::Coordinate& tail,
+                               const geom::Coordinate& tip2);
+
+    /// Returns the oriented smallest angle between two vectors.
+    //
+    /// The computed angle will be in the range (-Pi, Pi].
+    /// A positive result corresponds to a counterclockwise rotation
+    /// from v1 to v2;
+    /// a negative result corresponds to a clockwise rotation.
+    ///
+    /// @param tip1 the tip of v1
+    /// @param tail the tail of each vector
+    /// @param tip2 the tip of v2
+    /// @return the angle between v1 and v2, relative to v1
+    ///
+    static double angleBetweenOriented(const geom::Coordinate& tip1,
+                                       const geom::Coordinate& tail,
+                                       const geom::Coordinate& tip2);
+
+    /// Computes the interior angle between two segments of a ring.
+    //
+    /// The ring is assumed to be oriented in a clockwise direction.
+    /// The computed angle will be in the range [0, 2Pi]
+    ///
+    /// @param p0
+    ///          a point of the ring
+    /// @param p1
+    ///          the next point of the ring
+    /// @param p2
+    ///          the next point of the ring
+    /// @return the interior angle based at <code>p1</code>
+    ///
+    static double interiorAngle(const geom::Coordinate& p0,
+                                const geom::Coordinate& p1,
+                                const geom::Coordinate& p2);
+
+    /// \brief
+    /// Returns whether an angle must turn clockwise or counterclockwise
+    /// to overlap another angle.
+    ///
+    /// @param ang1 an angle (in radians)
+    /// @param ang2 an angle (in radians)
+    /// @return whether a1 must turn CLOCKWISE, COUNTERCLOCKWISE or
+    ///         NONE to overlap a2.
+    ///
+    static int getTurn(double ang1, double ang2);
+
+    /// \brief
+    /// Computes the normalized value of an angle, which is the
+    /// equivalent angle in the range ( -Pi, Pi ].
+    ///
+    /// @param angle the angle to normalize
+    /// @return an equivalent angle in the range (-Pi, Pi]
+    ///
+    static double normalize(double angle);
+
+    /// \brief
+    /// Computes the normalized positive value of an angle,
+    /// which is the equivalent angle in the range [ 0, 2*Pi ).
+    ///
+    /// E.g.:
+    /// - normalizePositive(0.0) = 0.0
+    /// - normalizePositive(-PI) = PI
+    /// - normalizePositive(-2PI) = 0.0
+    /// - normalizePositive(-3PI) = PI
+    /// - normalizePositive(-4PI) = 0
+    /// - normalizePositive(PI) = PI
+    /// - normalizePositive(2PI) = 0.0
+    /// - normalizePositive(3PI) = PI
+    /// - normalizePositive(4PI) = 0.0
+    ///
+    /// @param angle the angle to normalize, in radians
+    /// @return an equivalent positive angle
+    ///
+    static double normalizePositive(double angle);
+
+
+    /// Computes the unoriented smallest difference between two angles.
+    //
+    /// The angles are assumed to be normalized to the range [-Pi, Pi].
+    /// The result will be in the range [0, Pi].
+    ///
+    /// @param ang1 the angle of one vector (in [-Pi, Pi] )
+    /// @param ang2 the angle of the other vector (in range [-Pi, Pi] )
+    /// @return the angle (in radians) between the two vectors
+    ///         (in range [0, Pi] )
+    ///
+    static double diff(double ang1, double ang2);
 };
 
 
diff --git a/include/geos/algorithm/Area.h b/include/geos/algorithm/Area.h
index 71e4bd9..83e37a2 100644
--- a/include/geos/algorithm/Area.h
+++ b/include/geos/algorithm/Area.h
@@ -36,7 +36,7 @@ public:
     * @param ring the coordinates forming the ring
     * @return the area of the ring
     */
-    static double ofRing(const std::vector<geom::Coordinate> &ring);
+    static double ofRing(const std::vector<geom::Coordinate>& ring);
 
     /**
     * Computes the area for a ring.
@@ -44,7 +44,7 @@ public:
     * @param ring the coordinates forming the ring
     * @return the area of the ring
     */
-    static double ofRing(const geom::CoordinateSequence *ring);
+    static double ofRing(const geom::CoordinateSequence* ring);
 
     /**
     * Computes the signed area for a ring. The signed area is positive if the
@@ -55,7 +55,7 @@ public:
     *          the coordinates forming the ring
     * @return the signed area of the ring
     */
-    static double ofRingSigned(const std::vector<geom::Coordinate> &ring);
+    static double ofRingSigned(const std::vector<geom::Coordinate>& ring);
 
     /**
     * Computes the signed area for a ring. The signed area is positive if the
@@ -66,7 +66,7 @@ public:
     *          the coordinates forming the ring
     * @return the signed area of the ring
     */
-    static double ofRingSigned(const geom::CoordinateSequence *ring);
+    static double ofRingSigned(const geom::CoordinateSequence* ring);
 
 };
 
diff --git a/include/geos/algorithm/BoundaryNodeRule.h b/include/geos/algorithm/BoundaryNodeRule.h
index 77f3221..3a7b294 100644
--- a/include/geos/algorithm/BoundaryNodeRule.h
+++ b/include/geos/algorithm/BoundaryNodeRule.h
@@ -51,61 +51,62 @@ class GEOS_DLL BoundaryNodeRule {
 
 public:
 
-	// virtual classes should always have a virtual destructor..
-	virtual ~BoundaryNodeRule() {}
-
-	/**
-	 * Tests whether a point that lies in <tt>boundaryCount</tt>
-	 * geometry component boundaries is considered to form part of
-	 * the boundary of the parent geometry.
-	 *
- 	 * @param boundaryCount the number of component boundaries that
-	 *                      this point occurs in
-	 * @return true if points in this number of boundaries lie in
-	 *              the parent boundary
-	 */
-	virtual bool isInBoundary(int boundaryCount) const=0;
-
-	/** \brief
-	 * The Mod-2 Boundary Node Rule (which is the rule specified
-	 * in the OGC SFS).
-	 *
-	 * @see Mod2BoundaryNodeRule
-	 */
-	//static const BoundaryNodeRule& MOD2_BOUNDARY_RULE;
+    // virtual classes should always have a virtual destructor..
+    virtual
+    ~BoundaryNodeRule() {}
+
+    /**
+     * Tests whether a point that lies in <tt>boundaryCount</tt>
+     * geometry component boundaries is considered to form part of
+     * the boundary of the parent geometry.
+     *
+     * @param boundaryCount the number of component boundaries that
+     *                      this point occurs in
+     * @return true if points in this number of boundaries lie in
+     *              the parent boundary
+     */
+    virtual bool isInBoundary(int boundaryCount) const = 0;
+
+    /** \brief
+     * The Mod-2 Boundary Node Rule (which is the rule specified
+     * in the OGC SFS).
+     *
+     * @see Mod2BoundaryNodeRule
+     */
+    //static const BoundaryNodeRule& MOD2_BOUNDARY_RULE;
     static const BoundaryNodeRule& getBoundaryRuleMod2();
 
-	/** \brief
-	 * The Endpoint Boundary Node Rule.
-	 *
-	 * @see EndPointBoundaryNodeRule
-	 */
-	//static const BoundaryNodeRule& ENDPOINT_BOUNDARY_RULE;
+    /** \brief
+     * The Endpoint Boundary Node Rule.
+     *
+     * @see EndPointBoundaryNodeRule
+     */
+    //static const BoundaryNodeRule& ENDPOINT_BOUNDARY_RULE;
     static const BoundaryNodeRule& getBoundaryEndPoint();
 
-	/** \brief
-	 * The MultiValent Endpoint Boundary Node Rule.
-	 *
-	 * @see MultiValentEndPointBoundaryNodeRule
-	 */
-	//static const BoundaryNodeRule& MULTIVALENT_ENDPOINT_BOUNDARY_RULE;
+    /** \brief
+     * The MultiValent Endpoint Boundary Node Rule.
+     *
+     * @see MultiValentEndPointBoundaryNodeRule
+     */
+    //static const BoundaryNodeRule& MULTIVALENT_ENDPOINT_BOUNDARY_RULE;
     static const BoundaryNodeRule& getBoundaryMultivalentEndPoint();
 
-	/** \brief
-	 * The Monovalent Endpoint Boundary Node Rule.
-	 *
-	 * @see MonoValentEndPointBoundaryNodeRule
-	 */
-	//static const BoundaryNodeRule& MONOVALENT_ENDPOINT_BOUNDARY_RULE;
+    /** \brief
+     * The Monovalent Endpoint Boundary Node Rule.
+     *
+     * @see MonoValentEndPointBoundaryNodeRule
+     */
+    //static const BoundaryNodeRule& MONOVALENT_ENDPOINT_BOUNDARY_RULE;
     static const BoundaryNodeRule& getBoundaryMonovalentEndPoint();
 
-	/** \brief
-	 * The Boundary Node Rule specified by the OGC Simple Features
-	 * Specification, which is the same as the Mod-2 rule.
-	 *
-	 * @see Mod2BoundaryNodeRule
-	 */
-	//static const BoundaryNodeRule& OGC_SFS_BOUNDARY_RULE;
+    /** \brief
+     * The Boundary Node Rule specified by the OGC Simple Features
+     * Specification, which is the same as the Mod-2 rule.
+     *
+     * @see Mod2BoundaryNodeRule
+     */
+    //static const BoundaryNodeRule& OGC_SFS_BOUNDARY_RULE;
     static const BoundaryNodeRule& getBoundaryOGCSFS();
 };
 
diff --git a/include/geos/algorithm/CGAlgorithmsDD.h b/include/geos/algorithm/CGAlgorithmsDD.h
index 3c46b23..8b2cb50 100644
--- a/include/geos/algorithm/CGAlgorithmsDD.h
+++ b/include/geos/algorithm/CGAlgorithmsDD.h
@@ -47,16 +47,16 @@ class GEOS_DLL CGAlgorithmsDD {
 public:
 
     enum {
-        CLOCKWISE=-1,
-        COLLINEAR=0,
-        COUNTERCLOCKWISE=1
+        CLOCKWISE = -1,
+        COLLINEAR = 0,
+        COUNTERCLOCKWISE = 1
     };
 
     enum {
-        RIGHT=-1,
-        LEFT=1,
-        STRAIGHT=0,
-        FAILURE=2
+        RIGHT = -1,
+        LEFT = 1,
+        STRAIGHT = 0,
+        FAILURE = 2
     };
 
     /**
@@ -98,23 +98,28 @@ public:
                                       const geom::Coordinate& pb,
                                       const geom::Coordinate& pc);
 
-    static int orientation(double x)
+    static int
+    orientation(double x)
     {
-        if (x < 0) return CGAlgorithmsDD::RIGHT;
-        if (x > 0) return CGAlgorithmsDD::LEFT;
+        if(x < 0) {
+            return CGAlgorithmsDD::RIGHT;
+        }
+        if(x > 0) {
+            return CGAlgorithmsDD::LEFT;
+        }
         return CGAlgorithmsDD::STRAIGHT;
     }
 
     static void intersection(const geom::Coordinate& p1, const geom::Coordinate& p2,
                              const geom::Coordinate& q1, const geom::Coordinate& q2,
-                             geom::Coordinate &rv);
+                             geom::Coordinate& rv);
 
     static int signOfDet2x2(double dx1, double dy1, double dx2, double dy2);
 
 
 protected:
 
-    static int signOfDet2x2(DD &x1, DD &y1, DD &x2, DD &y2);
+    static int signOfDet2x2(DD& x1, DD& y1, DD& x2, DD& y2);
 
 };
 
diff --git a/include/geos/algorithm/CentralEndpointIntersector.h b/include/geos/algorithm/CentralEndpointIntersector.h
index 2c78b72..f70b092 100644
--- a/include/geos/algorithm/CentralEndpointIntersector.h
+++ b/include/geos/algorithm/CentralEndpointIntersector.h
@@ -32,9 +32,9 @@
 
 // Forward declarations
 namespace geos {
-	namespace geom {
-		//class PrecisionModel;
-	}
+namespace geom {
+//class PrecisionModel;
+}
 }
 
 namespace geos {
@@ -63,88 +63,94 @@ class GEOS_DLL CentralEndpointIntersector {
 
 public:
 
-	static const geom::Coordinate& getIntersection(const geom::Coordinate& p00,
-			const geom::Coordinate& p01, const geom::Coordinate& p10,
-			const geom::Coordinate& p11)
-	{
-		CentralEndpointIntersector intor(p00, p01, p10, p11);
-		return intor.getIntersection();
-	}
-
-	CentralEndpointIntersector(const geom::Coordinate& p00,
-			const geom::Coordinate& p01,
-			const geom::Coordinate& p10,
-			const geom::Coordinate& p11)
-		:
-		_pts(4)
-	{
-		_pts[0]=p00;
-		_pts[1]=p01;
-		_pts[2]=p10;
-		_pts[3]=p11;
-		compute();
-	}
-
-	const geom::Coordinate& getIntersection() const
-	{
-		return _intPt;
-	}
+    static const geom::Coordinate&
+    getIntersection(const geom::Coordinate& p00,
+                    const geom::Coordinate& p01, const geom::Coordinate& p10,
+                    const geom::Coordinate& p11)
+    {
+        CentralEndpointIntersector intor(p00, p01, p10, p11);
+        return intor.getIntersection();
+    }
+
+    CentralEndpointIntersector(const geom::Coordinate& p00,
+                               const geom::Coordinate& p01,
+                               const geom::Coordinate& p10,
+                               const geom::Coordinate& p11)
+        :
+        _pts(4)
+    {
+        _pts[0] = p00;
+        _pts[1] = p01;
+        _pts[2] = p10;
+        _pts[3] = p11;
+        compute();
+    }
+
+    const geom::Coordinate&
+    getIntersection() const
+    {
+        return _intPt;
+    }
 
 
 private:
 
-	// This is likely overkill.. we'll be allocating heap
-	// memory at every call !
-	std::vector<geom::Coordinate> _pts;
-
-	geom::Coordinate _intPt;
-
-	void compute()
-	{
-		geom::Coordinate centroid = average(_pts);
-		_intPt = findNearestPoint(centroid, _pts);
-	}
-
-	static geom::Coordinate average(
-			const std::vector<geom::Coordinate>& pts)
-	{
-		geom::Coordinate avg(0, 0);
-		size_t n = pts.size();
-		if ( ! n ) return avg;
-		for (std::size_t i=0; i<n; ++i)
-		{
-			avg.x += pts[i].x;
-			avg.y += pts[i].y;
-		}
-		avg.x /= n;
-		avg.y /= n;
-		return avg;
-	}
-
-	/**
-	 * Determines a point closest to the given point.
-	 *
-	 * @param p the point to compare against
-	 * @param p1 a potential result point
-	 * @param p2 a potential result point
-	 * @param q1 a potential result point
-	 * @param q2 a potential result point
-	 * @return the point closest to the input point p
-	 */
-	geom::Coordinate findNearestPoint(const geom::Coordinate& p,
-			const std::vector<geom::Coordinate>& pts) const
-	{
-		double minDist = std::numeric_limits<double>::max();
-		geom::Coordinate result = geom::Coordinate::getNull();
-		for (std::size_t i = 0, n=pts.size(); i < n; ++i) {
-			double dist = p.distance(pts[i]);
-			if (dist < minDist) {
-				minDist = dist;
-				result = pts[i];
-			}
-		}
-		return result;
-	}
+    // This is likely overkill.. we'll be allocating heap
+    // memory at every call !
+    std::vector<geom::Coordinate> _pts;
+
+    geom::Coordinate _intPt;
+
+    void
+    compute()
+    {
+        geom::Coordinate centroid = average(_pts);
+        _intPt = findNearestPoint(centroid, _pts);
+    }
+
+    static geom::Coordinate
+    average(
+        const std::vector<geom::Coordinate>& pts)
+    {
+        geom::Coordinate avg(0, 0);
+        size_t n = pts.size();
+        if(! n) {
+            return avg;
+        }
+        for(std::size_t i = 0; i < n; ++i) {
+            avg.x += pts[i].x;
+            avg.y += pts[i].y;
+        }
+        avg.x /= n;
+        avg.y /= n;
+        return avg;
+    }
+
+    /**
+     * Determines a point closest to the given point.
+     *
+     * @param p the point to compare against
+     * @param p1 a potential result point
+     * @param p2 a potential result point
+     * @param q1 a potential result point
+     * @param q2 a potential result point
+     * @return the point closest to the input point p
+     */
+    geom::Coordinate
+    findNearestPoint(const geom::Coordinate& p,
+                     const std::vector<geom::Coordinate>& pts) const
+    {
+        double minDist = std::numeric_limits<double>::max();
+        geom::Coordinate result = geom::Coordinate::getNull();
+        for(std::size_t i = 0, n = pts.size(); i < n; ++i) {
+            double dist = p.distance(pts[i]);
+            if(dist < minDist) {
+                minDist = dist;
+                result = pts[i];
+            }
+        }
+        return result;
+    }
 };
 
 } // namespace geos::algorithm
diff --git a/include/geos/algorithm/Centroid.h b/include/geos/algorithm/Centroid.h
index 9f7d268..e2eae3d 100644
--- a/include/geos/algorithm/Centroid.h
+++ b/include/geos/algorithm/Centroid.h
@@ -25,11 +25,11 @@
 
 // Forward declarations
 namespace geos {
-    namespace geom {
-        class Geometry;
-        class Polygon;
-        class CoordinateSequence;
-    }
+namespace geom {
+class Geometry;
+class Polygon;
+class CoordinateSequence;
+}
 }
 
 
@@ -62,93 +62,95 @@ class GEOS_DLL Centroid {
 
 public:
 
-  /**
-   * Computes the centroid point of a geometry.
-   *
-   * @param geom the geometry to use
-   * @param cent will be set to the centroid point, if any
-   *
-   * @return true if a centroid could be computed,
-   *         false otherwise (empty geom)
-   */
-  static bool getCentroid(const geom::Geometry& geom, geom::Coordinate& cent);
-
-  /**
-   * Creates a new instance for computing the centroid of a geometry
-   */
-  Centroid(const geom::Geometry& geom)
-    :
-    areasum2(0.0),
-    totalLength(0.0),
-    ptCount(0)
-  {
-    add(geom);
-  }
-
-  /**
-   * Gets the computed centroid.
-   *
-   * @param cent will be set to the centroid point, if any
-   *
-   * @return true if a centroid could be computed,
-   *         false otherwise (empty geom)
-   */
-  bool getCentroid(geom::Coordinate& cent) const;
+    /**
+     * Computes the centroid point of a geometry.
+     *
+     * @param geom the geometry to use
+     * @param cent will be set to the centroid point, if any
+     *
+     * @return true if a centroid could be computed,
+     *         false otherwise (empty geom)
+     */
+    static bool getCentroid(const geom::Geometry& geom, geom::Coordinate& cent);
+
+    /**
+     * Creates a new instance for computing the centroid of a geometry
+     */
+    Centroid(const geom::Geometry& geom)
+        :
+        areasum2(0.0),
+        totalLength(0.0),
+        ptCount(0)
+    {
+        add(geom);
+    }
+
+    /**
+     * Gets the computed centroid.
+     *
+     * @param cent will be set to the centroid point, if any
+     *
+     * @return true if a centroid could be computed,
+     *         false otherwise (empty geom)
+     */
+    bool getCentroid(geom::Coordinate& cent) const;
 
 private:
 
-  std::unique_ptr<geom::Coordinate> areaBasePt;
-  geom::Coordinate triangleCent3;
-  geom::Coordinate cg3;
-  geom::Coordinate lineCentSum;
-  geom::Coordinate ptCentSum;
-  double areasum2;
-  double totalLength;
-  int ptCount;
-
-  /**
-   * Adds a Geometry to the centroid total.
-   *
-   * @param geom the geometry to add
-   */
-  void add(const geom::Geometry& geom);
-
-  void setAreaBasePoint(const geom::Coordinate& basePt);
-
-  void add(const geom::Polygon& poly);
-
-  void addShell(const geom::CoordinateSequence& pts);
-
-  void addHole(const geom::CoordinateSequence& pts);
-
-  void addTriangle(const geom::Coordinate& p0, const geom::Coordinate& p1, const geom::Coordinate& p2, bool isPositiveArea);
-
-  /**
-   * Computes three times the centroid of the triangle p1-p2-p3.
-   * The factor of 3 is
-   * left in to permit division to be avoided until later.
-   */
-  static void centroid3(const geom::Coordinate& p1, const geom::Coordinate& p2, const geom::Coordinate& p3, geom::Coordinate& c );
-
-  /**
-   * Returns twice the signed area of the triangle p1-p2-p3.
-   * The area is positive if the triangle is oriented CCW, and negative if CW.
-   */
-  static double area2(const geom::Coordinate& p1, const geom::Coordinate& p2, const geom::Coordinate& p3 );
-
-  /**
-   * Adds the line segments defined by an array of coordinates
-   * to the linear centroid accumulators.
-   *
-   * @param pts an array of {@link Coordinate}s
-   */
-  void addLineSegments(const geom::CoordinateSequence& pts);
-
-  /**
-   * Adds a point to the point centroid accumulator.
-   * @param pt a {@link Coordinate}
-   */
-  void addPoint(const geom::Coordinate& pt);
+    std::unique_ptr<geom::Coordinate> areaBasePt;
+    geom::Coordinate triangleCent3;
+    geom::Coordinate cg3;
+    geom::Coordinate lineCentSum;
+    geom::Coordinate ptCentSum;
+    double areasum2;
+    double totalLength;
+    int ptCount;
+
+    /**
+     * Adds a Geometry to the centroid total.
+     *
+     * @param geom the geometry to add
+     */
+    void add(const geom::Geometry& geom);
+
+    void setAreaBasePoint(const geom::Coordinate& basePt);
+
+    void add(const geom::Polygon& poly);
+
+    void addShell(const geom::CoordinateSequence& pts);
+
+    void addHole(const geom::CoordinateSequence& pts);
+
+    void addTriangle(const geom::Coordinate& p0, const geom::Coordinate& p1, const geom::Coordinate& p2,
+                     bool isPositiveArea);
+
+    /**
+     * Computes three times the centroid of the triangle p1-p2-p3.
+     * The factor of 3 is
+     * left in to permit division to be avoided until later.
+     */
+    static void centroid3(const geom::Coordinate& p1, const geom::Coordinate& p2, const geom::Coordinate& p3,
+                          geom::Coordinate& c);
+
+    /**
+     * Returns twice the signed area of the triangle p1-p2-p3.
+     * The area is positive if the triangle is oriented CCW, and negative if CW.
+     */
+    static double area2(const geom::Coordinate& p1, const geom::Coordinate& p2, const geom::Coordinate& p3);
+
+    /**
+     * Adds the line segments defined by an array of coordinates
+     * to the linear centroid accumulators.
+     *
+     * @param pts an array of {@link Coordinate}s
+     */
+    void addLineSegments(const geom::CoordinateSequence& pts);
+
+    /**
+     * Adds a point to the point centroid accumulator.
+     * @param pt a {@link Coordinate}
+     */
+    void addPoint(const geom::Coordinate& pt);
 };
 
 } // namespace geos::algorithm
diff --git a/include/geos/algorithm/ConvexHull.h b/include/geos/algorithm/ConvexHull.h
index 161b1f8..6b687a1 100644
--- a/include/geos/algorithm/ConvexHull.h
+++ b/include/geos/algorithm/ConvexHull.h
@@ -34,11 +34,11 @@
 
 // Forward declarations
 namespace geos {
-	namespace geom {
-		class Geometry;
-		class GeometryFactory;
-		class CoordinateSequence;
-	}
+namespace geom {
+class Geometry;
+class GeometryFactory;
+class CoordinateSequence;
+}
 }
 
 namespace geos {
@@ -57,125 +57,125 @@ namespace algorithm { // geos::algorithm
  */
 class GEOS_DLL ConvexHull {
 private:
-	const geom::GeometryFactory *geomFactory;
-	geom::Coordinate::ConstVect inputPts;
-
-	void extractCoordinates(const geom::Geometry *geom);
-
-	/// Create a CoordinateSequence from the Coordinate::ConstVect
-	/// This is needed to construct the geometries.
-	/// Here coordinate copies happen
-	/// The returned object is newly allocated !NO EXCEPTION SAFE!
-	geom::CoordinateSequence *toCoordinateSequence(geom::Coordinate::ConstVect &cv);
-
-	void computeOctPts(const geom::Coordinate::ConstVect &src,
-			geom::Coordinate::ConstVect &tgt);
-
-	bool computeOctRing(const geom::Coordinate::ConstVect &src,
-			geom::Coordinate::ConstVect &tgt);
-
-	/**
-	 * Uses a heuristic to reduce the number of points scanned
-	 * to compute the hull.
-	 * The heuristic is to find a polygon guaranteed to
-	 * be in (or on) the hull, and eliminate all points inside it.
-	 * A quadrilateral defined by the extremal points
-	 * in the four orthogonal directions
-	 * can be used, but even more inclusive is
-	 * to use an octilateral defined by the points in the
-	 * 8 cardinal directions.
-	 *
-	 * Note that even if the method used to determine the polygon
-	 * vertices is not 100% robust, this does not affect the
-	 * robustness of the convex hull.
-	 *
-	 * To satisfy the requirements of the Graham Scan algorithm,
-	 * the resulting array has at least 3 entries.
-	 *
-	 * @param pts The vector of const Coordinate pointers
-	 *            to be reduced (to at least 3 elements)
-	 *
-	 * WARNING: the parameter will be modified
-	 *
-	 */
-	void reduce(geom::Coordinate::ConstVect &pts);
-
-	/// parameter will be modified
-	void padArray3(geom::Coordinate::ConstVect &pts);
-
-	/// parameter will be modified
-	void preSort(geom::Coordinate::ConstVect &pts);
-
-	/**
-	 * Given two points p and q compare them with respect to their radial
-	 * ordering about point o.  First checks radial ordering.
-	 * If points are collinear, the comparison is based
-	 * on their distance to the origin.
-	 *
-	 * p < q iff
-	 *
-	 * - ang(o-p) < ang(o-q) (e.g. o-p-q is CCW)
-	 * - or ang(o-p) == ang(o-q) && dist(o,p) < dist(o,q)
-	 *
-	 * @param o the origin
-	 * @param p a point
-	 * @param q another point
-	 * @return -1, 0 or 1 depending on whether p is less than,
-	 * equal to or greater than q
-	 */
-	int polarCompare(const geom::Coordinate &o,
-			const geom::Coordinate &p, const geom::Coordinate &q);
-
-	void grahamScan(const geom::Coordinate::ConstVect &c,
-			geom::Coordinate::ConstVect &ps);
-
-	/**
-	 * @param  vertices  the vertices of a linear ring,
-	 *                   which may or may not be
-	 *                   flattened (i.e. vertices collinear)
-	 *
-	 * @return           a 2-vertex LineString if the vertices are
-	 *                   collinear; otherwise, a Polygon with unnecessary
-	 *                   (collinear) vertices removed
-	 */
-	geom::Geometry* lineOrPolygon(const geom::Coordinate::ConstVect &vertices);
-
-	/**
-	 * Write in 'cleaned' a version of 'input' with collinear
-	 * vertexes removed.
-   	 */
-	void cleanRing(const geom::Coordinate::ConstVect &input,
-			geom::Coordinate::ConstVect &cleaned);
-
-	/**
-	 * @return  whether the three coordinates are collinear
-	 *          and c2 lies between c1 and c3 inclusive
-	 */
-	bool isBetween(const geom::Coordinate& c1, const geom::Coordinate& c2, const geom::Coordinate& c3);
+    const geom::GeometryFactory* geomFactory;
+    geom::Coordinate::ConstVect inputPts;
+
+    void extractCoordinates(const geom::Geometry* geom);
+
+    /// Create a CoordinateSequence from the Coordinate::ConstVect
+    /// This is needed to construct the geometries.
+    /// Here coordinate copies happen
+    /// The returned object is newly allocated !NO EXCEPTION SAFE!
+    geom::CoordinateSequence* toCoordinateSequence(geom::Coordinate::ConstVect& cv);
+
+    void computeOctPts(const geom::Coordinate::ConstVect& src,
+                       geom::Coordinate::ConstVect& tgt);
+
+    bool computeOctRing(const geom::Coordinate::ConstVect& src,
+                        geom::Coordinate::ConstVect& tgt);
+
+    /**
+     * Uses a heuristic to reduce the number of points scanned
+     * to compute the hull.
+     * The heuristic is to find a polygon guaranteed to
+     * be in (or on) the hull, and eliminate all points inside it.
+     * A quadrilateral defined by the extremal points
+     * in the four orthogonal directions
+     * can be used, but even more inclusive is
+     * to use an octilateral defined by the points in the
+     * 8 cardinal directions.
+     *
+     * Note that even if the method used to determine the polygon
+     * vertices is not 100% robust, this does not affect the
+     * robustness of the convex hull.
+     *
+     * To satisfy the requirements of the Graham Scan algorithm,
+     * the resulting array has at least 3 entries.
+     *
+     * @param pts The vector of const Coordinate pointers
+     *            to be reduced (to at least 3 elements)
+     *
+     * WARNING: the parameter will be modified
+     *
+     */
+    void reduce(geom::Coordinate::ConstVect& pts);
+
+    /// parameter will be modified
+    void padArray3(geom::Coordinate::ConstVect& pts);
+
+    /// parameter will be modified
+    void preSort(geom::Coordinate::ConstVect& pts);
+
+    /**
+     * Given two points p and q compare them with respect to their radial
+     * ordering about point o.  First checks radial ordering.
+     * If points are collinear, the comparison is based
+     * on their distance to the origin.
+     *
+     * p < q iff
+     *
+     * - ang(o-p) < ang(o-q) (e.g. o-p-q is CCW)
+     * - or ang(o-p) == ang(o-q) && dist(o,p) < dist(o,q)
+     *
+     * @param o the origin
+     * @param p a point
+     * @param q another point
+     * @return -1, 0 or 1 depending on whether p is less than,
+     * equal to or greater than q
+     */
+    int polarCompare(const geom::Coordinate& o,
+                     const geom::Coordinate& p, const geom::Coordinate& q);
+
+    void grahamScan(const geom::Coordinate::ConstVect& c,
+                    geom::Coordinate::ConstVect& ps);
+
+    /**
+     * @param  vertices  the vertices of a linear ring,
+     *                   which may or may not be
+     *                   flattened (i.e. vertices collinear)
+     *
+     * @return           a 2-vertex LineString if the vertices are
+     *                   collinear; otherwise, a Polygon with unnecessary
+     *                   (collinear) vertices removed
+     */
+    geom::Geometry* lineOrPolygon(const geom::Coordinate::ConstVect& vertices);
+
+    /**
+     * Write in 'cleaned' a version of 'input' with collinear
+     * vertexes removed.
+     */
+    void cleanRing(const geom::Coordinate::ConstVect& input,
+                   geom::Coordinate::ConstVect& cleaned);
+
+    /**
+     * @return  whether the three coordinates are collinear
+     *          and c2 lies between c1 and c3 inclusive
+     */
+    bool isBetween(const geom::Coordinate& c1, const geom::Coordinate& c2, const geom::Coordinate& c3);
 
 public:
 
-	/**
-	 * Create a new convex hull construction for the input Geometry.
-	 */
-	ConvexHull(const geom::Geometry *newGeometry);
-
-
-	~ConvexHull();
-
-	/**
-	 * Returns a Geometry that represents the convex hull of
-	 * the input geometry.
-	 * The returned geometry contains the minimal number of points
-	 * needed to represent the convex hull.
-	 * In particular, no more than two consecutive points
-	 * will be collinear.
-	 *
-	 * @return if the convex hull contains 3 or more points,
-	 *         a Polygon; 2 points, a LineString;
-	 *         1 point, a Point; 0 points, an empty GeometryCollection.
-	 */
-	geom::Geometry* getConvexHull();
+    /**
+     * Create a new convex hull construction for the input Geometry.
+     */
+    ConvexHull(const geom::Geometry* newGeometry);
+
+
+    ~ConvexHull();
+
+    /**
+     * Returns a Geometry that represents the convex hull of
+     * the input geometry.
+     * The returned geometry contains the minimal number of points
+     * needed to represent the convex hull.
+     * In particular, no more than two consecutive points
+     * will be collinear.
+     *
+     * @return if the convex hull contains 3 or more points,
+     *         a Polygon; 2 points, a LineString;
+     *         1 point, a Point; 0 points, an empty GeometryCollection.
+     */
+    geom::Geometry* getConvexHull();
 };
 
 } // namespace geos::algorithm
diff --git a/include/geos/algorithm/ConvexHull.inl b/include/geos/algorithm/ConvexHull.inl
index da092af..fef99e5 100644
--- a/include/geos/algorithm/ConvexHull.inl
+++ b/include/geos/algorithm/ConvexHull.inl
@@ -28,11 +28,11 @@ namespace geos {
 namespace algorithm { // geos::algorithm
 
 INLINE
-ConvexHull::ConvexHull(const geom::Geometry *newGeometry)
-	:
-	geomFactory(newGeometry->getFactory())
+ConvexHull::ConvexHull(const geom::Geometry* newGeometry)
+    :
+    geomFactory(newGeometry->getFactory())
 {
-	extractCoordinates(newGeometry);
+    extractCoordinates(newGeometry);
 }
 
 INLINE
@@ -41,10 +41,10 @@ ConvexHull::~ConvexHull()
 }
 
 INLINE void
-ConvexHull::extractCoordinates(const geom::Geometry *geom)
+ConvexHull::extractCoordinates(const geom::Geometry* geom)
 {
-	util::UniqueCoordinateArrayFilter filter(inputPts);
-	geom->apply_ro(&filter);
+    util::UniqueCoordinateArrayFilter filter(inputPts);
+    geom->apply_ro(&filter);
 }
 
 } // namespace geos::algorithm
diff --git a/include/geos/algorithm/Distance.h b/include/geos/algorithm/Distance.h
index 34e2373..c9e54a6 100644
--- a/include/geos/algorithm/Distance.h
+++ b/include/geos/algorithm/Distance.h
@@ -65,7 +65,7 @@ public:
     * @return the minimum distance between the point and the line segments
     */
     static double pointToSegmentString(const geom::Coordinate& p,
-        const geom::CoordinateSequence *seq);
+                                       const geom::CoordinateSequence* seq);
 
     /**
     * Computes the distance from a point p to a line segment AB
diff --git a/include/geos/algorithm/HCoordinate.h b/include/geos/algorithm/HCoordinate.h
index 897a104..f2a0fc3 100644
--- a/include/geos/algorithm/HCoordinate.h
+++ b/include/geos/algorithm/HCoordinate.h
@@ -26,9 +26,9 @@
 
 // Forward declarations
 namespace geos {
-	namespace geom {
-		class Coordinate;
-	}
+namespace geom {
+class Coordinate;
+}
 }
 
 namespace geos {
@@ -45,52 +45,52 @@ class GEOS_DLL HCoordinate {
 
 public:
 
-	friend std::ostream& operator<< (std::ostream& o, const HCoordinate& c);
+    friend std::ostream& operator<< (std::ostream& o, const HCoordinate& c);
 
-	/** \brief
-	 * Computes the (approximate) intersection point between two line
-	 * segments using homogeneous coordinates.
-	 *
-	 * Note that this algorithm is
-	 * not numerically stable; i.e. it can produce intersection points which
-	 * lie outside the envelope of the line segments themselves.  In order
-	 * to increase the precision of the calculation input points should be
-	 * normalized before passing them to this routine.
-	 */
-	static void intersection(const geom::Coordinate &p1,
-				 const geom::Coordinate &p2,
-				 const geom::Coordinate &q1,
-				 const geom::Coordinate &q2,
-				 geom::Coordinate &ret);
+    /** \brief
+     * Computes the (approximate) intersection point between two line
+     * segments using homogeneous coordinates.
+     *
+     * Note that this algorithm is
+     * not numerically stable; i.e. it can produce intersection points which
+     * lie outside the envelope of the line segments themselves.  In order
+     * to increase the precision of the calculation input points should be
+     * normalized before passing them to this routine.
+     */
+    static void intersection(const geom::Coordinate& p1,
+                             const geom::Coordinate& p2,
+                             const geom::Coordinate& q1,
+                             const geom::Coordinate& q2,
+                             geom::Coordinate& ret);
 
-	double x,y,w;
+    double x, y, w;
 
-	HCoordinate();
+    HCoordinate();
 
-	HCoordinate(double _x, double _y, double _w);
+    HCoordinate(double _x, double _y, double _w);
 
-	HCoordinate(const geom::Coordinate& p);
+    HCoordinate(const geom::Coordinate& p);
 
-	/** \brief
-	 * Constructs a homogeneous coordinate which is the intersection
-	 * of the lines define by the homogenous coordinates represented
-	 * by two {@link Coordinate}s.
-	 *
-	 * @param p1
-	 * @param p2
-	 */
-	HCoordinate(const geom::Coordinate& p1, const geom::Coordinate& p2);
+    /** \brief
+     * Constructs a homogeneous coordinate which is the intersection
+     * of the lines define by the homogenous coordinates represented
+     * by two {@link Coordinate}s.
+     *
+     * @param p1
+     * @param p2
+     */
+    HCoordinate(const geom::Coordinate& p1, const geom::Coordinate& p2);
 
-	HCoordinate(const geom::Coordinate& p1, const geom::Coordinate& p2,
-		    const geom::Coordinate& q1, const geom::Coordinate& q2);
+    HCoordinate(const geom::Coordinate& p1, const geom::Coordinate& p2,
+                const geom::Coordinate& q1, const geom::Coordinate& q2);
 
-	HCoordinate(const HCoordinate &p1, const HCoordinate &p2);
+    HCoordinate(const HCoordinate& p1, const HCoordinate& p2);
 
-	double getX() const;
+    double getX() const;
 
-	double getY() const;
+    double getY() const;
 
-	void getCoordinate(geom::Coordinate &ret) const;
+    void getCoordinate(geom::Coordinate& ret) const;
 
 };
 
diff --git a/include/geos/algorithm/InteriorPointArea.h b/include/geos/algorithm/InteriorPointArea.h
index b5a01b0..3a1bfd5 100644
--- a/include/geos/algorithm/InteriorPointArea.h
+++ b/include/geos/algorithm/InteriorPointArea.h
@@ -26,12 +26,12 @@
 
 // Forward declarations
 namespace geos {
-	namespace geom {
-		class Geometry;
-		class LineString;
-		class GeometryFactory;
-		class GeometryCollection;
-	}
+namespace geom {
+class Geometry;
+class LineString;
+class GeometryFactory;
+class GeometryCollection;
+}
 }
 
 
@@ -64,51 +64,51 @@ class GEOS_DLL InteriorPointArea {
 
 private:
 
-	bool foundInterior;
+    bool foundInterior;
 
-	const geom::GeometryFactory *factory;
+    const geom::GeometryFactory* factory;
 
-	geom::Coordinate interiorPoint;
+    geom::Coordinate interiorPoint;
 
-	double maxWidth;
+    double maxWidth;
 
-	void add(const geom::Geometry *geom);
+    void add(const geom::Geometry* geom);
 
-	const geom::Geometry *widestGeometry(const geom::Geometry *geometry);
+    const geom::Geometry* widestGeometry(const geom::Geometry* geometry);
 
-	const geom::Geometry *widestGeometry(const geom::GeometryCollection *gc);
+    const geom::Geometry* widestGeometry(const geom::GeometryCollection* gc);
 
-	geom::LineString *horizontalBisector(const geom::Geometry *geometry);
+    geom::LineString* horizontalBisector(const geom::Geometry* geometry);
 
 public:
 
-	/**
-	 * Creates a new interior point finder
-	 * for an areal geometry.
-	 *
-	 * @param g an areal geometry
-	 */
-	InteriorPointArea(const geom::Geometry *g);
+    /**
+     * Creates a new interior point finder
+     * for an areal geometry.
+     *
+     * @param g an areal geometry
+     */
+    InteriorPointArea(const geom::Geometry* g);
 
-	~InteriorPointArea();
+    ~InteriorPointArea();
 
-	/**
-	 * Gets the computed interior point.
-	 *
-	 * @return the coordinate of an interior point
-	 */
-	bool getInteriorPoint(geom::Coordinate& ret) const;
+    /**
+     * Gets the computed interior point.
+     *
+     * @return the coordinate of an interior point
+     */
+    bool getInteriorPoint(geom::Coordinate& ret) const;
 
 private:
 
-	/** \brief
-	 * Finds an interior point of a Polygon
-	 *
-	 * @param geometry the geometry to analyze
-	 * @return the midpoint of the largest intersection between the geometry and
-	 * a line halfway down its envelope
-	 */
-	void addPolygon(const geom::Geometry *geometry);
+    /** \brief
+     * Finds an interior point of a Polygon
+     *
+     * @param geometry the geometry to analyze
+     * @return the midpoint of the largest intersection between the geometry and
+     * a line halfway down its envelope
+     */
+    void addPolygon(const geom::Geometry* geometry);
 
 };
 
diff --git a/include/geos/algorithm/InteriorPointLine.h b/include/geos/algorithm/InteriorPointLine.h
index 3eb5156..ff43f64 100644
--- a/include/geos/algorithm/InteriorPointLine.h
+++ b/include/geos/algorithm/InteriorPointLine.h
@@ -25,10 +25,10 @@
 
 // Forward declarations
 namespace geos {
-	namespace geom {
-		class Geometry;
-		class CoordinateSequence;
-	}
+namespace geom {
+class Geometry;
+class CoordinateSequence;
+}
 }
 
 
@@ -48,33 +48,33 @@ namespace algorithm { // geos::algorithm
 class GEOS_DLL InteriorPointLine {
 public:
 
-	InteriorPointLine(const geom::Geometry *g);
+    InteriorPointLine(const geom::Geometry* g);
 
-	~InteriorPointLine();
+    ~InteriorPointLine();
 
-	//Coordinate* getInteriorPoint() const;
+    //Coordinate* getInteriorPoint() const;
 
-	bool getInteriorPoint(geom::Coordinate& ret) const;
+    bool getInteriorPoint(geom::Coordinate& ret) const;
 
 private:
 
-	bool hasInterior;
+    bool hasInterior;
 
-	geom::Coordinate centroid;
+    geom::Coordinate centroid;
 
-	double minDistance;
+    double minDistance;
 
-	geom::Coordinate interiorPoint;
+    geom::Coordinate interiorPoint;
 
-	void addInterior(const geom::Geometry *geom);
+    void addInterior(const geom::Geometry* geom);
 
-	void addInterior(const geom::CoordinateSequence *pts);
+    void addInterior(const geom::CoordinateSequence* pts);
 
-	void addEndpoints(const geom::Geometry *geom);
+    void addEndpoints(const geom::Geometry* geom);
 
-	void addEndpoints(const geom::CoordinateSequence *pts);
+    void addEndpoints(const geom::CoordinateSequence* pts);
 
-	void add(const geom::Coordinate& point);
+    void add(const geom::Coordinate& point);
 
 };
 
diff --git a/include/geos/algorithm/InteriorPointPoint.h b/include/geos/algorithm/InteriorPointPoint.h
index 043a179..1de7cf7 100644
--- a/include/geos/algorithm/InteriorPointPoint.h
+++ b/include/geos/algorithm/InteriorPointPoint.h
@@ -21,9 +21,9 @@
 
 // Forward declarations
 namespace geos {
-	namespace geom {
-		class Geometry;
-	}
+namespace geom {
+class Geometry;
+}
 }
 
 namespace geos {
@@ -41,30 +41,30 @@ namespace algorithm { // geos::algorithm
 class GEOS_DLL InteriorPointPoint {
 private:
 
-	bool hasInterior;
+    bool hasInterior;
 
-	geom::Coordinate centroid;
+    geom::Coordinate centroid;
 
-	double minDistance;
+    double minDistance;
 
-	geom::Coordinate interiorPoint;
+    geom::Coordinate interiorPoint;
 
-	/**
-	 * Tests the point(s) defined by a Geometry for the best inside point.
-	 * If a Geometry is not of dimension 0 it is not tested.
-	 * @param geom the geometry to add
-	 */
-	void add(const geom::Geometry *geom);
+    /**
+     * Tests the point(s) defined by a Geometry for the best inside point.
+     * If a Geometry is not of dimension 0 it is not tested.
+     * @param geom the geometry to add
+     */
+    void add(const geom::Geometry* geom);
 
-	void add(const geom::Coordinate *point);
+    void add(const geom::Coordinate* point);
 
 public:
 
-	InteriorPointPoint(const geom::Geometry *g);
+    InteriorPointPoint(const geom::Geometry* g);
 
-	~InteriorPointPoint() {}
+    ~InteriorPointPoint() {}
 
-	bool getInteriorPoint(geom::Coordinate& ret) const;
+    bool getInteriorPoint(geom::Coordinate& ret) const;
 
 };
 
diff --git a/include/geos/algorithm/Length.h b/include/geos/algorithm/Length.h
index 4af0b77..4d1a13f 100644
--- a/include/geos/algorithm/Length.h
+++ b/include/geos/algorithm/Length.h
@@ -41,7 +41,7 @@ public:
     * @param pts the points specifying the linestring
     * @return the length of the linestring
     */
-    static double ofLine(const geom::CoordinateSequence *ring);
+    static double ofLine(const geom::CoordinateSequence* ring);
 
 };
 
diff --git a/include/geos/algorithm/LineIntersector.h b/include/geos/algorithm/LineIntersector.h
index 293a1ef..8702459 100644
--- a/include/geos/algorithm/LineIntersector.h
+++ b/include/geos/algorithm/LineIntersector.h
@@ -27,9 +27,9 @@
 
 // Forward declarations
 namespace geos {
-	namespace geom {
-		class PrecisionModel;
-	}
+namespace geom {
+class PrecisionModel;
+}
 }
 
 namespace geos {
@@ -49,312 +49,334 @@ namespace algorithm { // geos::algorithm
 class GEOS_DLL LineIntersector {
 public:
 
-	/// \brief
-	/// Return a Z value being the interpolation of Z from p0 and p1 at
-	/// the given point p
-	static double interpolateZ(const geom::Coordinate &p, const geom::Coordinate &p0, const geom::Coordinate &p1);
-
-
-	/// Computes the "edge distance" of an intersection point p in an edge.
-	//
-	/// The edge distance is a metric of the point along the edge.
-	/// The metric used is a robust and easy to compute metric function.
-	/// It is <b>not</b> equivalent to the usual Euclidean metric.
-	/// It relies on the fact that either the x or the y ordinates of the
-	/// points in the edge are unique, depending on whether the edge is longer in
-	/// the horizontal or vertical direction.
-	///
-	/// NOTE: This function may produce incorrect distances
-	///  for inputs where p is not precisely on p1-p2
-	/// (E.g. p = (139,9) p1 = (139,10), p2 = (280,1) produces distanct
-	/// 0.0, which is incorrect.
-	///
-	/// My hypothesis is that the function is safe to use for points which are the
-	/// result of <b>rounding</b> points which lie on the line,
-	/// but not safe to use for <b>truncated</b> points.
-	///
-	static double computeEdgeDistance(const geom::Coordinate& p, const geom::Coordinate& p0, const geom::Coordinate& p1);
-
-	static double nonRobustComputeEdgeDistance(const geom::Coordinate& p,const geom::Coordinate& p1,const geom::Coordinate& p2);
-
-	LineIntersector(const geom::PrecisionModel* initialPrecisionModel=nullptr)
-		:
-		precisionModel(initialPrecisionModel),
-		result(0),
-		isProperVar(false)
-	{}
-
-	~LineIntersector() {}
-
-	/** \brief
-	 * Tests whether either intersection point is an interior point of
-	 * one of the input segments.
-	 *
-	 * @return <code>true</code> if either intersection point is in
-	 * the interior of one of the input segments
-	 */
-	bool isInteriorIntersection();
-
-	/** \brief
-	 * Tests whether either intersection point is an interior point
-	 * of the specified input segment.
-	 *
-	 * @return <code>true</code> if either intersection point is in
-	 * the interior of the input segment
-	 */
-	bool isInteriorIntersection(int inputLineIndex);
-
-	/// Force computed intersection to be rounded to a given precision model.
-	//
-	/// No getter is provided, because the precision model is not required
-	/// to be specified.
-	/// @param precisionModel the PrecisionModel to use for rounding
-	///
-	void setPrecisionModel(const geom::PrecisionModel *newPM) {
-		precisionModel=newPM;
-	}
-
-	/// Compute the intersection of a point p and the line p1-p2.
-	//
-	/// This function computes the boolean value of the hasIntersection test.
-	/// The actual value of the intersection (if there is one)
-	/// is equal to the value of <code>p</code>.
-	///
-	void computeIntersection(const geom::Coordinate& p, const geom::Coordinate& p1, const geom::Coordinate& p2);
-
-	/// Same as above but doen's compute intersection point. Faster.
-	static bool hasIntersection(const geom::Coordinate& p,const geom::Coordinate& p1,const geom::Coordinate& p2);
-
-	// These are deprecated, due to ambiguous naming
-	enum {
-		DONT_INTERSECT=0,
-		DO_INTERSECT=1,
-		COLLINEAR=2
-	};
-
-	enum {
-		/// Indicates that line segments do not intersect
-		NO_INTERSECTION=0,
-
-		/// Indicates that line segments intersect in a single point
-		POINT_INTERSECTION=1,
-
-		/// Indicates that line segments intersect in a line segment
-		COLLINEAR_INTERSECTION=2
-	};
-
-	/// Computes the intersection of the lines p1-p2 and p3-p4
-	void computeIntersection(const geom::Coordinate& p1, const geom::Coordinate& p2,
-			const geom::Coordinate& p3, const geom::Coordinate& p4);
-
-	std::string toString() const;
-
-	/**
-	 * Tests whether the input geometries intersect.
-	 *
-	 * @return true if the input geometries intersect
-	 */
-	bool hasIntersection() const { return result!=NO_INTERSECTION; }
-
-	/// Returns the number of intersection points found.
-	//
-	/// This will be either 0, 1 or 2.
-	///
-	size_t getIntersectionNum() const { return result; }
-
-
-	/// Returns the intIndex'th intersection point
-	//
-	/// @param intIndex is 0 or 1
-	///
-	/// @return the intIndex'th intersection point
-	///
-	const geom::Coordinate& getIntersection(size_t intIndex) const {
-		return intPt[intIndex];
-	}
-
-	/// Returns false if both numbers are zero.
-	//
-	/// @return true if both numbers are positive or if both numbers are negative.
-	///
-	static bool isSameSignAndNonZero(double a,double b);
-
-	/** \brief
-	 * Test whether a point is a intersection point of two line segments.
-	 *
-	 * Note that if the intersection is a line segment, this method only tests for
-	 * equality with the endpoints of the intersection segment.
-	 * It does <b>not</b> return true if
-	 * the input point is internal to the intersection segment.
-	 *
-	 * @return true if the input point is one of the intersection points.
-	 */
-	bool isIntersection(const geom::Coordinate& pt) const;
-
-	/** \brief
-	 * Tests whether an intersection is proper.
-	 *
-	 * The intersection between two line segments is considered proper if
-	 * they intersect in a single point in the interior of both segments
-	 * (e.g. the intersection is a single point and is not equal to any of the
-	 * endpoints).
-	 *
-	 * The intersection between a point and a line segment is considered proper
-	 * if the point lies in the interior of the segment (e.g. is not equal to
-	 * either of the endpoints).
-	 *
-	 * @return true if the intersection is proper
-	 */
-	bool isProper() const {
-		return hasIntersection()&&isProperVar;
-	}
-
-	/** \brief
-	 * Computes the intIndex'th intersection point in the direction of
-	 * a specified input line segment
-	 *
-	 * @param segmentIndex is 0 or 1
-	 * @param intIndex is 0 or 1
-	 *
-	 * @return the intIndex'th intersection point in the direction of the
-	 *         specified input line segment
-	 */
-	const geom::Coordinate& getIntersectionAlongSegment(int segmentIndex,int intIndex);
-
-	/** \brief
-	 * Computes the index of the intIndex'th intersection point in the direction of
-	 * a specified input line segment
-	 *
-	 * @param segmentIndex is 0 or 1
-	 * @param intIndex is 0 or 1
-	 *
-	 * @return the index of the intersection point along the segment (0 or 1)
-	 */
-	int getIndexAlongSegment(int segmentIndex,int intIndex);
-
-	/** \brief
-	 * Computes the "edge distance" of an intersection point along the specified
-	 * input line segment.
-	 *
-	 * @param segmentIndex is 0 or 1
-	 * @param intIndex is 0 or 1
-	 *
-	 * @return the edge distance of the intersection point
-	 */
-	double getEdgeDistance(size_t geomIndex, size_t intIndex) const;
+    /// \brief
+    /// Return a Z value being the interpolation of Z from p0 and p1 at
+    /// the given point p
+    static double interpolateZ(const geom::Coordinate& p, const geom::Coordinate& p0, const geom::Coordinate& p1);
+
+
+    /// Computes the "edge distance" of an intersection point p in an edge.
+    //
+    /// The edge distance is a metric of the point along the edge.
+    /// The metric used is a robust and easy to compute metric function.
+    /// It is <b>not</b> equivalent to the usual Euclidean metric.
+    /// It relies on the fact that either the x or the y ordinates of the
+    /// points in the edge are unique, depending on whether the edge is longer in
+    /// the horizontal or vertical direction.
+    ///
+    /// NOTE: This function may produce incorrect distances
+    ///  for inputs where p is not precisely on p1-p2
+    /// (E.g. p = (139,9) p1 = (139,10), p2 = (280,1) produces distanct
+    /// 0.0, which is incorrect.
+    ///
+    /// My hypothesis is that the function is safe to use for points which are the
+    /// result of <b>rounding</b> points which lie on the line,
+    /// but not safe to use for <b>truncated</b> points.
+    ///
+    static double computeEdgeDistance(const geom::Coordinate& p, const geom::Coordinate& p0, const geom::Coordinate& p1);
+
+    static double nonRobustComputeEdgeDistance(const geom::Coordinate& p, const geom::Coordinate& p1,
+            const geom::Coordinate& p2);
+
+    LineIntersector(const geom::PrecisionModel* initialPrecisionModel = nullptr)
+        :
+        precisionModel(initialPrecisionModel),
+        result(0),
+        isProperVar(false)
+    {}
+
+    ~LineIntersector() {}
+
+    /** \brief
+     * Tests whether either intersection point is an interior point of
+     * one of the input segments.
+     *
+     * @return <code>true</code> if either intersection point is in
+     * the interior of one of the input segments
+     */
+    bool isInteriorIntersection();
+
+    /** \brief
+     * Tests whether either intersection point is an interior point
+     * of the specified input segment.
+     *
+     * @return <code>true</code> if either intersection point is in
+     * the interior of the input segment
+     */
+    bool isInteriorIntersection(int inputLineIndex);
+
+    /// Force computed intersection to be rounded to a given precision model.
+    //
+    /// No getter is provided, because the precision model is not required
+    /// to be specified.
+    /// @param precisionModel the PrecisionModel to use for rounding
+    ///
+    void
+    setPrecisionModel(const geom::PrecisionModel* newPM)
+    {
+        precisionModel = newPM;
+    }
+
+    /// Compute the intersection of a point p and the line p1-p2.
+    //
+    /// This function computes the boolean value of the hasIntersection test.
+    /// The actual value of the intersection (if there is one)
+    /// is equal to the value of <code>p</code>.
+    ///
+    void computeIntersection(const geom::Coordinate& p, const geom::Coordinate& p1, const geom::Coordinate& p2);
+
+    /// Same as above but doen's compute intersection point. Faster.
+    static bool hasIntersection(const geom::Coordinate& p, const geom::Coordinate& p1, const geom::Coordinate& p2);
+
+    // These are deprecated, due to ambiguous naming
+    enum {
+        DONT_INTERSECT = 0,
+        DO_INTERSECT = 1,
+        COLLINEAR = 2
+    };
+
+    enum {
+        /// Indicates that line segments do not intersect
+        NO_INTERSECTION = 0,
+
+        /// Indicates that line segments intersect in a single point
+        POINT_INTERSECTION = 1,
+
+        /// Indicates that line segments intersect in a line segment
+        COLLINEAR_INTERSECTION = 2
+    };
+
+    /// Computes the intersection of the lines p1-p2 and p3-p4
+    void computeIntersection(const geom::Coordinate& p1, const geom::Coordinate& p2,
+                             const geom::Coordinate& p3, const geom::Coordinate& p4);
+
+    std::string toString() const;
+
+    /**
+     * Tests whether the input geometries intersect.
+     *
+     * @return true if the input geometries intersect
+     */
+    bool
+    hasIntersection() const
+    {
+        return result != NO_INTERSECTION;
+    }
+
+    /// Returns the number of intersection points found.
+    //
+    /// This will be either 0, 1 or 2.
+    ///
+    size_t
+    getIntersectionNum() const
+    {
+        return result;
+    }
+
+
+    /// Returns the intIndex'th intersection point
+    //
+    /// @param intIndex is 0 or 1
+    ///
+    /// @return the intIndex'th intersection point
+    ///
+    const geom::Coordinate&
+    getIntersection(size_t intIndex) const
+    {
+        return intPt[intIndex];
+    }
+
+    /// Returns false if both numbers are zero.
+    //
+    /// @return true if both numbers are positive or if both numbers are negative.
+    ///
+    static bool isSameSignAndNonZero(double a, double b);
+
+    /** \brief
+     * Test whether a point is a intersection point of two line segments.
+     *
+     * Note that if the intersection is a line segment, this method only tests for
+     * equality with the endpoints of the intersection segment.
+     * It does <b>not</b> return true if
+     * the input point is internal to the intersection segment.
+     *
+     * @return true if the input point is one of the intersection points.
+     */
+    bool isIntersection(const geom::Coordinate& pt) const;
+
+    /** \brief
+     * Tests whether an intersection is proper.
+     *
+     * The intersection between two line segments is considered proper if
+     * they intersect in a single point in the interior of both segments
+     * (e.g. the intersection is a single point and is not equal to any of the
+     * endpoints).
+     *
+     * The intersection between a point and a line segment is considered proper
+     * if the point lies in the interior of the segment (e.g. is not equal to
+     * either of the endpoints).
+     *
+     * @return true if the intersection is proper
+     */
+    bool
+    isProper() const
+    {
+        return hasIntersection() && isProperVar;
+    }
+
+    /** \brief
+     * Computes the intIndex'th intersection point in the direction of
+     * a specified input line segment
+     *
+     * @param segmentIndex is 0 or 1
+     * @param intIndex is 0 or 1
+     *
+     * @return the intIndex'th intersection point in the direction of the
+     *         specified input line segment
+     */
+    const geom::Coordinate& getIntersectionAlongSegment(int segmentIndex, int intIndex);
+
+    /** \brief
+     * Computes the index of the intIndex'th intersection point in the direction of
+     * a specified input line segment
+     *
+     * @param segmentIndex is 0 or 1
+     * @param intIndex is 0 or 1
+     *
+     * @return the index of the intersection point along the segment (0 or 1)
+     */
+    int getIndexAlongSegment(int segmentIndex, int intIndex);
+
+    /** \brief
+     * Computes the "edge distance" of an intersection point along the specified
+     * input line segment.
+     *
+     * @param segmentIndex is 0 or 1
+     * @param intIndex is 0 or 1
+     *
+     * @return the edge distance of the intersection point
+     */
+    double getEdgeDistance(size_t geomIndex, size_t intIndex) const;
 
 private:
 
-	void intersectionWithNormalization(const geom::Coordinate& p1,
-		const geom::Coordinate& p2,
-		const geom::Coordinate& q1,
-		const geom::Coordinate& q2,
-		geom::Coordinate &ret) const;
-
-	/**
-	 * If makePrecise is true, computed intersection coordinates
-	 * will be made precise using Coordinate#makePrecise
-	 */
-	const geom::PrecisionModel *precisionModel;
-
-	size_t result;
-
-	const geom::Coordinate *inputLines[2][2];
-
-	/**
-	 * We store real Coordinates here because
-	 * we must compute the Z of intersection point.
-	 */
-	geom::Coordinate intPt[2];
-
-	/**
-	 * The indexes of the endpoints of the intersection lines, in order along
-	 * the corresponding line
-	 */
-	int intLineIndex[2][2];
-
-	bool isProperVar;
-	//Coordinate &pa;
-	//Coordinate &pb;
-
-	bool isCollinear() const { return result==COLLINEAR_INTERSECTION; }
-
-	int computeIntersect(const geom::Coordinate& p1,const geom::Coordinate& p2,const geom::Coordinate& q1,const geom::Coordinate& q2);
-
-	bool isEndPoint() const {
-		return hasIntersection()&&!isProperVar;
-	}
-
-	void computeIntLineIndex();
-
-	void computeIntLineIndex(int segmentIndex);
-
-	int computeCollinearIntersection(const geom::Coordinate& p1,
-		const geom::Coordinate& p2, const geom::Coordinate& q1,
-		const geom::Coordinate& q2);
-
-	/** \brief
-	 * This method computes the actual value of the intersection point.
-	 *
-	 * To obtain the maximum precision from the intersection calculation,
-	 * the coordinates are normalized by subtracting the minimum
-	 * ordinate values (in absolute value).  This has the effect of
-	 * removing common significant digits from the calculation to
-	 * maintain more bits of precision.
-	 */
-	void intersection(const geom::Coordinate& p1,
-		const geom::Coordinate& p2,
-		const geom::Coordinate& q1,
-		const geom::Coordinate& q2,
-		geom::Coordinate &ret) const;
-
-	double smallestInAbsValue(double x1, double x2,
-		double x3, double x4) const;
-
-	/**
-	 * Test whether a point lies in the envelopes of both input segments.
-	 * A correctly computed intersection point should return true
-	 * for this test.
-	 * Since this test is for debugging purposes only, no attempt is
-	 * made to optimize the envelope test.
-	 *
-	 * @return true if the input point lies within both
-	 *         input segment envelopes
-	 */
-	bool isInSegmentEnvelopes(const geom::Coordinate& intPt) const;
-
-	/** \brief
-	 * Normalize the supplied coordinates to
-	 * so that the midpoint of their intersection envelope
-	 * lies at the origin.
-	 *
-	 * @param n00
-	 * @param n01
-	 * @param n10
-	 * @param n11
-	 * @param normPt
-	 */
-	void normalizeToEnvCentre(geom::Coordinate &n00, geom::Coordinate &n01,
-		geom::Coordinate &n10, geom::Coordinate &n11,
-		geom::Coordinate &normPt) const;
-
-	/**
-	 * Computes a segment intersection using homogeneous coordinates.
-	 * Round-off error can cause the raw computation to fail,
-	 * (usually due to the segments being approximately parallel).
-	 * If this happens, a reasonable approximation is computed instead.
-	 *
-	 * @param p1 a segment endpoint
-	 * @param p2 a segment endpoint
-	 * @param q1 a segment endpoint
-	 * @param q2 a segment endpoint
-	 * @param intPt the computed intersection point is stored there
-	 */
-	 void safeHCoordinateIntersection(const geom::Coordinate& p1,
-			 const geom::Coordinate& p2,
-			 const geom::Coordinate& q1,
-			 const geom::Coordinate& q2,
-			 geom::Coordinate& intPt) const;
+    void intersectionWithNormalization(const geom::Coordinate& p1,
+                                       const geom::Coordinate& p2,
+                                       const geom::Coordinate& q1,
+                                       const geom::Coordinate& q2,
+                                       geom::Coordinate& ret) const;
+
+    /**
+     * If makePrecise is true, computed intersection coordinates
+     * will be made precise using Coordinate#makePrecise
+     */
+    const geom::PrecisionModel* precisionModel;
+
+    size_t result;
+
+    const geom::Coordinate* inputLines[2][2];
+
+    /**
+     * We store real Coordinates here because
+     * we must compute the Z of intersection point.
+     */
+    geom::Coordinate intPt[2];
+
+    /**
+     * The indexes of the endpoints of the intersection lines, in order along
+     * the corresponding line
+     */
+    int intLineIndex[2][2];
+
+    bool isProperVar;
+    //Coordinate &pa;
+    //Coordinate &pb;
+
+    bool
+    isCollinear() const
+    {
+        return result == COLLINEAR_INTERSECTION;
+    }
+
+    int computeIntersect(const geom::Coordinate& p1, const geom::Coordinate& p2, const geom::Coordinate& q1,
+                         const geom::Coordinate& q2);
+
+    bool
+    isEndPoint() const
+    {
+        return hasIntersection() && !isProperVar;
+    }
+
+    void computeIntLineIndex();
+
+    void computeIntLineIndex(int segmentIndex);
+
+    int computeCollinearIntersection(const geom::Coordinate& p1,
+                                     const geom::Coordinate& p2, const geom::Coordinate& q1,
+                                     const geom::Coordinate& q2);
+
+    /** \brief
+     * This method computes the actual value of the intersection point.
+     *
+     * To obtain the maximum precision from the intersection calculation,
+     * the coordinates are normalized by subtracting the minimum
+     * ordinate values (in absolute value).  This has the effect of
+     * removing common significant digits from the calculation to
+     * maintain more bits of precision.
+     */
+    void intersection(const geom::Coordinate& p1,
+                      const geom::Coordinate& p2,
+                      const geom::Coordinate& q1,
+                      const geom::Coordinate& q2,
+                      geom::Coordinate& ret) const;
+
+    double smallestInAbsValue(double x1, double x2,
+                              double x3, double x4) const;
+
+    /**
+     * Test whether a point lies in the envelopes of both input segments.
+     * A correctly computed intersection point should return true
+     * for this test.
+     * Since this test is for debugging purposes only, no attempt is
+     * made to optimize the envelope test.
+     *
+     * @return true if the input point lies within both
+     *         input segment envelopes
+     */
+    bool isInSegmentEnvelopes(const geom::Coordinate& intPt) const;
+
+    /** \brief
+     * Normalize the supplied coordinates to
+     * so that the midpoint of their intersection envelope
+     * lies at the origin.
+     *
+     * @param n00
+     * @param n01
+     * @param n10
+     * @param n11
+     * @param normPt
+     */
+    void normalizeToEnvCentre(geom::Coordinate& n00, geom::Coordinate& n01,
+                              geom::Coordinate& n10, geom::Coordinate& n11,
+                              geom::Coordinate& normPt) const;
+
+    /**
+     * Computes a segment intersection using homogeneous coordinates.
+     * Round-off error can cause the raw computation to fail,
+     * (usually due to the segments being approximately parallel).
+     * If this happens, a reasonable approximation is computed instead.
+     *
+     * @param p1 a segment endpoint
+     * @param p2 a segment endpoint
+     * @param q1 a segment endpoint
+     * @param q2 a segment endpoint
+     * @param intPt the computed intersection point is stored there
+     */
+    void safeHCoordinateIntersection(const geom::Coordinate& p1,
+                                     const geom::Coordinate& p2,
+                                     const geom::Coordinate& q1,
+                                     const geom::Coordinate& q2,
+                                     geom::Coordinate& intPt) const;
 
 };
 
diff --git a/include/geos/algorithm/MinimumBoundingCircle.h b/include/geos/algorithm/MinimumBoundingCircle.h
index 6ba76d2..cc99891 100644
--- a/include/geos/algorithm/MinimumBoundingCircle.h
+++ b/include/geos/algorithm/MinimumBoundingCircle.h
@@ -44,7 +44,7 @@ class GEOS_DLL MinimumBoundingCircle {
 private:
 
     // member variables
-    const geom::Geometry *input;
+    const geom::Geometry* input;
     std::vector<geom::Coordinate> extremalPts;
     geom::Coordinate centre;
     double radius;
@@ -55,12 +55,12 @@ private:
     geom::Coordinate lowestPoint(std::vector<geom::Coordinate>& pts);
     geom::Coordinate pointWitMinAngleWithX(std::vector<geom::Coordinate>& pts, geom::Coordinate& P);
     geom::Coordinate pointWithMinAngleWithSegment(std::vector<geom::Coordinate>& pts,
-        geom::Coordinate& P, geom::Coordinate& Q);
+            geom::Coordinate& P, geom::Coordinate& Q);
 
 
 public:
 
-    MinimumBoundingCircle(const geom::Geometry *geom):
+    MinimumBoundingCircle(const geom::Geometry* geom):
         input(nullptr),
         radius(0.0)
     {
@@ -68,7 +68,7 @@ public:
         centre.setNull();
     }
 
-	~MinimumBoundingCircle() {};
+    ~MinimumBoundingCircle() {};
 
     /**
     * Gets a geometry which represents the Minimum Bounding Circle.
diff --git a/include/geos/algorithm/MinimumDiameter.h b/include/geos/algorithm/MinimumDiameter.h
index d8d38b7..92141ab 100644
--- a/include/geos/algorithm/MinimumDiameter.h
+++ b/include/geos/algorithm/MinimumDiameter.h
@@ -24,13 +24,13 @@
 
 // Forward declarations
 namespace geos {
-	namespace geom {
-		class Geometry;
-		class LineSegment;
-		class LineString;
-		class Coordinate;
-		class CoordinateSequence;
-	}
+namespace geom {
+class Geometry;
+class LineSegment;
+class LineString;
+class Coordinate;
+class CoordinateSequence;
+}
 }
 
 
@@ -64,112 +64,112 @@ namespace algorithm { // geos::algorithm
  */
 class GEOS_DLL MinimumDiameter {
 private:
-	const geom::Geometry* inputGeom;
-	bool isConvex;
+    const geom::Geometry* inputGeom;
+    bool isConvex;
 
-	geom::CoordinateSequence* convexHullPts;
+    geom::CoordinateSequence* convexHullPts;
 
-	geom::LineSegment* minBaseSeg;
-	geom::Coordinate* minWidthPt;
-	int minPtIndex;
-	double minWidth;
-	void computeMinimumDiameter();
-	void computeWidthConvex(const geom::Geometry* geom);
+    geom::LineSegment* minBaseSeg;
+    geom::Coordinate* minWidthPt;
+    int minPtIndex;
+    double minWidth;
+    void computeMinimumDiameter();
+    void computeWidthConvex(const geom::Geometry* geom);
 
-	/**
-	 * Compute the width information for a ring of {@link geom::Coordinate}s.
-	 * Leaves the width information in the instance variables.
-	 *
-	 * @param pts
-	 * @return
-	 */
-	void computeConvexRingMinDiameter(const geom::CoordinateSequence *pts);
+    /**
+     * Compute the width information for a ring of {@link geom::Coordinate}s.
+     * Leaves the width information in the instance variables.
+     *
+     * @param pts
+     * @return
+     */
+    void computeConvexRingMinDiameter(const geom::CoordinateSequence* pts);
 
-	unsigned int findMaxPerpDistance(const geom::CoordinateSequence* pts,
-		geom::LineSegment* seg, unsigned int startIndex);
+    unsigned int findMaxPerpDistance(const geom::CoordinateSequence* pts,
+                                     geom::LineSegment* seg, unsigned int startIndex);
 
-	static unsigned int getNextIndex(const geom::CoordinateSequence* pts,
-		unsigned int index);
+    static unsigned int getNextIndex(const geom::CoordinateSequence* pts,
+                                     unsigned int index);
 
-	static double computeC(double a, double b, const geom::Coordinate &p);
+    static double computeC(double a, double b, const geom::Coordinate& p);
 
-	static geom::LineSegment computeSegmentForLine(double a, double b, double c);
+    static geom::LineSegment computeSegmentForLine(double a, double b, double c);
 
 public:
-	~MinimumDiameter();
-
-	/** \brief
-	 * Compute a minimum diameter for a giver {@link Geometry}.
-	 *
-	 * @param geom a Geometry
-	 */
-	MinimumDiameter(const geom::Geometry* newInputGeom);
-
-	/** \brief
-	 * Compute a minimum diameter for a given Geometry,
-	 * with a hint if the Geometry is convex
-	 * (e.g. a convex Polygon or LinearRing,
-	 * or a two-point LineString, or a Point).
-	 *
-	 * @param geom a Geometry which is convex
-	 * @param isConvex <code>true</code> if the input geometry is convex
-	 */
-	MinimumDiameter(const geom::Geometry* newInputGeom,
-			const bool newIsConvex);
-
-	/** \brief
-	 * Gets the length of the minimum diameter of the input Geometry
-	 *
-	 * @return the length of the minimum diameter
-	 */
-	double getLength();
-
-	/** \brief
-	 * Gets the {@link geom::Coordinate} forming one end of the minimum diameter
-	 *
-	 * @return a coordinate forming one end of the minimum diameter
-	 */
-	geom::Coordinate* getWidthCoordinate();
-
-	/** \brief
-	 * Gets the segment forming the base of the minimum diameter
-	 *
-	 * @return the segment forming the base of the minimum diameter
-	 */
-	geom::LineString* getSupportingSegment();
-
-	/** \brief
-	 * Gets a LineString which is a minimum diameter
-	 *
-	 * @return a LineString which is a minimum diameter
-	 */
-	geom::LineString* getDiameter();
-
-	/**
-	 * Gets the minimum rectangular Polygon which encloses the input geometry. The rectangle has width
-	 * equal to the minimum diameter, and a longer length. If the convex hill of the input is degenerate
-	 * (a line or point) a LineString or Point is returned.
-	 * The minimum rectangle can be used as an extremely generalized representation for the given
-	 * geometry.
-	 *
-	 * @return the minimum rectangle enclosing the input (or a line or point if degenerate)
-	 */
-	geom::Geometry* getMinimumRectangle();
-
-	/**
-	 * Gets the minimum rectangle enclosing a geometry.
-	 *
-	 * @param geom the geometry
-	 * @return the minimum rectangle enclosing the geometry
-	*/
-	static geom::Geometry* getMinimumRectangle(geom::Geometry* geom);
-
-	/**
-	 * Gets the length of the minimum diameter enclosing a geometry
-	 * @param geom the geometry
-	 * @return the length of the minimum diameter of the geometry
-	 */
-	static geom::Geometry* getMinimumDiameter(geom::Geometry* geom);
+    ~MinimumDiameter();
+
+    /** \brief
+     * Compute a minimum diameter for a giver {@link Geometry}.
+     *
+     * @param geom a Geometry
+     */
+    MinimumDiameter(const geom::Geometry* newInputGeom);
+
+    /** \brief
+     * Compute a minimum diameter for a given Geometry,
+     * with a hint if the Geometry is convex
+     * (e.g. a convex Polygon or LinearRing,
+     * or a two-point LineString, or a Point).
+     *
+     * @param geom a Geometry which is convex
+     * @param isConvex <code>true</code> if the input geometry is convex
+     */
+    MinimumDiameter(const geom::Geometry* newInputGeom,
+                    const bool newIsConvex);
+
+    /** \brief
+     * Gets the length of the minimum diameter of the input Geometry
+     *
+     * @return the length of the minimum diameter
+     */
+    double getLength();
+
+    /** \brief
+     * Gets the {@link geom::Coordinate} forming one end of the minimum diameter
+     *
+     * @return a coordinate forming one end of the minimum diameter
+     */
+    geom::Coordinate* getWidthCoordinate();
+
+    /** \brief
+     * Gets the segment forming the base of the minimum diameter
+     *
+     * @return the segment forming the base of the minimum diameter
+     */
+    geom::LineString* getSupportingSegment();
+
+    /** \brief
+     * Gets a LineString which is a minimum diameter
+     *
+     * @return a LineString which is a minimum diameter
+     */
+    geom::LineString* getDiameter();
+
+    /**
+     * Gets the minimum rectangular Polygon which encloses the input geometry. The rectangle has width
+     * equal to the minimum diameter, and a longer length. If the convex hill of the input is degenerate
+     * (a line or point) a LineString or Point is returned.
+     * The minimum rectangle can be used as an extremely generalized representation for the given
+     * geometry.
+     *
+     * @return the minimum rectangle enclosing the input (or a line or point if degenerate)
+     */
+    geom::Geometry* getMinimumRectangle();
+
+    /**
+     * Gets the minimum rectangle enclosing a geometry.
+     *
+     * @param geom the geometry
+     * @return the minimum rectangle enclosing the geometry
+    */
+    static geom::Geometry* getMinimumRectangle(geom::Geometry* geom);
+
+    /**
+     * Gets the length of the minimum diameter enclosing a geometry
+     * @param geom the geometry
+     * @return the length of the minimum diameter of the geometry
+     */
+    static geom::Geometry* getMinimumDiameter(geom::Geometry* geom);
 
 };
 
diff --git a/include/geos/algorithm/NotRepresentableException.h b/include/geos/algorithm/NotRepresentableException.h
index f8a0fa7..6e44fba 100644
--- a/include/geos/algorithm/NotRepresentableException.h
+++ b/include/geos/algorithm/NotRepresentableException.h
@@ -34,9 +34,9 @@ namespace algorithm { // geos::algorithm
  */
 class GEOS_DLL NotRepresentableException: public util::GEOSException {
 public:
-	NotRepresentableException();
-	NotRepresentableException(std::string msg);
-	~NotRepresentableException() throw() override {}
+    NotRepresentableException();
+    NotRepresentableException(std::string msg);
+    ~NotRepresentableException() throw() override {}
 };
 
 } // namespace geos::algorithm
diff --git a/include/geos/algorithm/Orientation.h b/include/geos/algorithm/Orientation.h
index 1dea230..db9d6e7 100644
--- a/include/geos/algorithm/Orientation.h
+++ b/include/geos/algorithm/Orientation.h
@@ -45,12 +45,12 @@ public:
 
     /* A value that indicates an orientation or turn */
     enum {
-        CLOCKWISE=-1,
-        COLLINEAR=0,
-        COUNTERCLOCKWISE=1,
-        RIGHT=-1,
-        LEFT=1,
-        STRAIGHT=0
+        CLOCKWISE = -1,
+        COLLINEAR = 0,
+        COUNTERCLOCKWISE = 1,
+        RIGHT = -1,
+        LEFT = 1,
+        STRAIGHT = 0
     };
 
     /*
@@ -64,8 +64,8 @@ public:
     * ( {@link #Orientation::COUNTERCLOCKWISE},
     * {@link #Orientation::CLOCKWISE}, or {@link #Orientation::STRAIGHT} )
     */
-    static int index(const geom::Coordinate &p1, const geom::Coordinate &p2,
-                     const geom::Coordinate &q);
+    static int index(const geom::Coordinate& p1, const geom::Coordinate& p2,
+                     const geom::Coordinate& q);
 
     /**
     * Computes whether a ring defined by an array of {@link Coordinate}s is
diff --git a/include/geos/algorithm/PointInRing.h b/include/geos/algorithm/PointInRing.h
index 1541636..6561bc3 100644
--- a/include/geos/algorithm/PointInRing.h
+++ b/include/geos/algorithm/PointInRing.h
@@ -20,18 +20,19 @@
 
 // Forward declarations
 namespace geos {
-	namespace geom {
-		class Coordinate;
-	}
+namespace geom {
+class Coordinate;
+}
 }
 
 namespace geos {
 namespace algorithm { // geos::algorithm
 
-class GEOS_DLL PointInRing{
+class GEOS_DLL PointInRing {
 public:
-	virtual ~PointInRing(){}
-	virtual bool isInside(const geom::Coordinate& pt)=0;
+    virtual
+    ~PointInRing() {}
+    virtual bool isInside(const geom::Coordinate& pt) = 0;
 };
 
 } // namespace geos::algorithm
diff --git a/include/geos/algorithm/PointLocation.h b/include/geos/algorithm/PointLocation.h
index 7761d4c..0732d29 100644
--- a/include/geos/algorithm/PointLocation.h
+++ b/include/geos/algorithm/PointLocation.h
@@ -56,7 +56,7 @@ public:
     * @return true if the point is a vertex of the line or lies in the interior
     *         of a line segment in the line
     */
-    static bool isOnLine(const geom::Coordinate &p, const geom::CoordinateSequence *line);
+    static bool isOnLine(const geom::Coordinate& p, const geom::CoordinateSequence* line);
 
     /**
     * Tests whether a point lies inside or on a ring. The ring may be oriented in
@@ -75,8 +75,8 @@ public:
     *
     * @see locatePointInRing
     */
-    static bool isInRing(const geom::Coordinate &p, const std::vector<const geom::Coordinate*> &ring);
-    static bool isInRing(const geom::Coordinate &p, const geom::CoordinateSequence *ring);
+    static bool isInRing(const geom::Coordinate& p, const std::vector<const geom::Coordinate*>& ring);
+    static bool isInRing(const geom::Coordinate& p, const geom::CoordinateSequence* ring);
 
     /**
     * Determines whether a point lies in the interior, on the boundary, or in the
@@ -92,8 +92,8 @@ public:
     *          first point identical to last point)
     * @return the {@link Location} of p relative to the ring
     */
-    static int locateInRing(const geom::Coordinate &p, const std::vector<const geom::Coordinate*> &ring);
-    static int locateInRing(const geom::Coordinate &p, const geom::CoordinateSequence &ring);
+    static int locateInRing(const geom::Coordinate& p, const std::vector<const geom::Coordinate*>& ring);
+    static int locateInRing(const geom::Coordinate& p, const geom::CoordinateSequence& ring);
 
 };
 
diff --git a/include/geos/algorithm/PointLocator.h b/include/geos/algorithm/PointLocator.h
index 9bbe0a4..644b6dd 100644
--- a/include/geos/algorithm/PointLocator.h
+++ b/include/geos/algorithm/PointLocator.h
@@ -25,14 +25,14 @@
 
 // Forward declarations
 namespace geos {
-	namespace geom {
-		class Coordinate;
-		class Geometry;
-		class LinearRing;
-		class LineString;
-		class Polygon;
-		class Point;
-	}
+namespace geom {
+class Coordinate;
+class Geometry;
+class LinearRing;
+class LineString;
+class Polygon;
+class Point;
+}
 }
 
 namespace geos {
@@ -56,48 +56,50 @@ namespace algorithm { // geos::algorithm
  */
 class GEOS_DLL PointLocator {
 public:
-	PointLocator() {}
-	~PointLocator() {}
-
-	/**
-	 * Computes the topological relationship (Location) of a single point
-	 * to a Geometry. It handles both single-element and multi-element Geometries.
-	 * The algorithm for multi-part Geometriestakes into account the SFS
-	 * Boundary Determination rule.
-	 *
-	 * @return the Location of the point relative to the input Geometry
-	 */
-	int locate(const geom::Coordinate& p, const geom::Geometry *geom);
-
-	/**
-	 * Convenience method to test a point for intersection with
-	 * a Geometry
-	 *
-	 * @param p the coordinate to test
-	 * @param geom the Geometry to test
-	 * @return <code>true</code> if the point is in the interior or boundary of the Geometry
-	 */
-	bool intersects(const geom::Coordinate& p, const geom::Geometry *geom) {
-		return locate(p, geom) != geom::Location::EXTERIOR;
-	}
+    PointLocator() {}
+    ~PointLocator() {}
+
+    /**
+     * Computes the topological relationship (Location) of a single point
+     * to a Geometry. It handles both single-element and multi-element Geometries.
+     * The algorithm for multi-part Geometriestakes into account the SFS
+     * Boundary Determination rule.
+     *
+     * @return the Location of the point relative to the input Geometry
+     */
+    int locate(const geom::Coordinate& p, const geom::Geometry* geom);
+
+    /**
+     * Convenience method to test a point for intersection with
+     * a Geometry
+     *
+     * @param p the coordinate to test
+     * @param geom the Geometry to test
+     * @return <code>true</code> if the point is in the interior or boundary of the Geometry
+     */
+    bool
+    intersects(const geom::Coordinate& p, const geom::Geometry* geom)
+    {
+        return locate(p, geom) != geom::Location::EXTERIOR;
+    }
 
 private:
 
-	bool isIn;         // true if the point lies in or on any Geometry element
+    bool isIn;         // true if the point lies in or on any Geometry element
 
-	int numBoundaries;    // the number of sub-elements whose boundaries the point lies in
+    int numBoundaries;    // the number of sub-elements whose boundaries the point lies in
 
-	void computeLocation(const geom::Coordinate& p, const geom::Geometry *geom);
+    void computeLocation(const geom::Coordinate& p, const geom::Geometry* geom);
 
-	void updateLocationInfo(int loc);
+    void updateLocationInfo(int loc);
 
-	int locate(const geom::Coordinate& p, const geom::Point *pt);
+    int locate(const geom::Coordinate& p, const geom::Point* pt);
 
-	int locate(const geom::Coordinate& p, const geom::LineString *l);
+    int locate(const geom::Coordinate& p, const geom::LineString* l);
 
-	int locateInPolygonRing(const geom::Coordinate& p, const geom::LinearRing *ring);
+    int locateInPolygonRing(const geom::Coordinate& p, const geom::LinearRing* ring);
 
-	int locate(const geom::Coordinate& p, const geom::Polygon *poly);
+    int locate(const geom::Coordinate& p, const geom::Polygon* poly);
 
 };
 
diff --git a/include/geos/algorithm/RayCrossingCounter.h b/include/geos/algorithm/RayCrossingCounter.h
index 9891f37..fe5dc88 100644
--- a/include/geos/algorithm/RayCrossingCounter.h
+++ b/include/geos/algorithm/RayCrossingCounter.h
@@ -26,10 +26,10 @@
 
 // forward declarations
 namespace geos {
-	namespace geom {
-		class Coordinate;
-		class CoordinateSequence;
-	}
+namespace geom {
+class Coordinate;
+class CoordinateSequence;
+}
 }
 
 
@@ -63,14 +63,13 @@ namespace algorithm {
  * @author Martin Davis
  *
  */
-class GEOS_DLL RayCrossingCounter
-{
+class GEOS_DLL RayCrossingCounter {
 private:
-	const geom::Coordinate& point;
+    const geom::Coordinate& point;
 
-	int crossingCount;
+    int crossingCount;
 
-	// true if the test point lies on an input segment
+    // true if the test point lies on an input segment
     bool isPointOnSegment;
 
     // Declare type as noncopyable
@@ -78,89 +77,90 @@ private:
     RayCrossingCounter& operator=(const RayCrossingCounter& rhs) = delete;
 
 public:
-	/**
-	 * Determines the {@link Location} of a point in a ring.
-	 * This method is an exemplar of how to use this class.
-	 *
-	 * @param p the point to test
-	 * @param ring an array of Coordinates forming a ring
-	 * @return the location of the point in the ring
-	 */
-	static int locatePointInRing(const geom::Coordinate& p,
-	                             const geom::CoordinateSequence& ring);
-
-	/// Semantically equal to the above, just different args encoding
-	static int locatePointInRing(const geom::Coordinate& p,
-	         const std::vector<const geom::Coordinate*>& ring);
-
-	/** \brief
-	 * Returns the index of the direction of the point <code>q</code>
-	 * relative to a vector specified by <code>p1-p2</code>.
-	 *
-	 * @param p1 the origin point of the vector
-	 * @param p2 the final point of the vector
-	 * @param q the point to compute the direction to
-	 *
-	 * @return 1 if q is counter-clockwise (left) from p1-p2
-	 * @return -1 if q is clockwise (right) from p1-p2
-	 * @return 0 if q is collinear with p1-p2
-	 */
-	static int orientationIndex(const geom::Coordinate& p1,
-	         const geom::Coordinate& p2,
-	         const geom::Coordinate& q);
-
-	RayCrossingCounter(const geom::Coordinate& p_point)
-	:	point( p_point),
-		crossingCount( 0),
-		isPointOnSegment( false)
-	{ }
-
-	/**
-	 * Counts a segment
-	 *
-	 * @param p1 an endpoint of the segment
-	 * @param p2 another endpoint of the segment
-	 */
-	void countSegment(const geom::Coordinate& p1,
-	                  const geom::Coordinate& p2);
-
-	/**
-	 * Reports whether the point lies exactly on one of the supplied segments.
-	 * This method may be called at any time as segments are processed.
-	 * If the result of this method is <tt>true</tt>,
-	 * no further segments need be supplied, since the result
-	 * will never change again.
-	 *
-	 * @return true if the point lies exactly on a segment
-	 */
-	bool isOnSegment()
-	{
-		return isPointOnSegment;
-	}
-
-	/**
-	 * Gets the {@link Location} of the point relative to
-	 * the ring, polygon
-	 * or multipolygon from which the processed segments were provided.
-	 * <p>
-	 * This method only determines the correct location
-	 * if <b>all</b> relevant segments must have been processed.
-	 *
-	 * @return the Location of the point
- 	 */
-	int getLocation();
-
-	/**
-	 * Tests whether the point lies in or on
-	 * the ring, polygon
-	 * or multipolygon from which the processed segments were provided.
-	 * <p>
-	 * This method only determines the correct location
-	 * if <b>all</b> relevant segments must have been processed.
-	 *
-	 * @return true if the point lies in or on the supplied polygon
-	 */
-	bool isPointInPolygon();
+    /**
+     * Determines the {@link Location} of a point in a ring.
+     * This method is an exemplar of how to use this class.
+     *
+     * @param p the point to test
+     * @param ring an array of Coordinates forming a ring
+     * @return the location of the point in the ring
+     */
+    static int locatePointInRing(const geom::Coordinate& p,
+                                 const geom::CoordinateSequence& ring);
+
+    /// Semantically equal to the above, just different args encoding
+    static int locatePointInRing(const geom::Coordinate& p,
+                                 const std::vector<const geom::Coordinate*>& ring);
+
+    /** \brief
+     * Returns the index of the direction of the point <code>q</code>
+     * relative to a vector specified by <code>p1-p2</code>.
+     *
+     * @param p1 the origin point of the vector
+     * @param p2 the final point of the vector
+     * @param q the point to compute the direction to
+     *
+     * @return 1 if q is counter-clockwise (left) from p1-p2
+     * @return -1 if q is clockwise (right) from p1-p2
+     * @return 0 if q is collinear with p1-p2
+     */
+    static int orientationIndex(const geom::Coordinate& p1,
+                                const geom::Coordinate& p2,
+                                const geom::Coordinate& q);
+
+    RayCrossingCounter(const geom::Coordinate& p_point)
+        :	point(p_point),
+          crossingCount(0),
+          isPointOnSegment(false)
+    { }
+
+    /**
+     * Counts a segment
+     *
+     * @param p1 an endpoint of the segment
+     * @param p2 another endpoint of the segment
+     */
+    void countSegment(const geom::Coordinate& p1,
+                      const geom::Coordinate& p2);
+
+    /**
+     * Reports whether the point lies exactly on one of the supplied segments.
+     * This method may be called at any time as segments are processed.
+     * If the result of this method is <tt>true</tt>,
+     * no further segments need be supplied, since the result
+     * will never change again.
+     *
+     * @return true if the point lies exactly on a segment
+     */
+    bool
+    isOnSegment()
+    {
+        return isPointOnSegment;
+    }
+
+    /**
+     * Gets the {@link Location} of the point relative to
+     * the ring, polygon
+     * or multipolygon from which the processed segments were provided.
+     * <p>
+     * This method only determines the correct location
+     * if <b>all</b> relevant segments must have been processed.
+     *
+     * @return the Location of the point
+     */
+    int getLocation();
+
+    /**
+     * Tests whether the point lies in or on
+     * the ring, polygon
+     * or multipolygon from which the processed segments were provided.
+     * <p>
+     * This method only determines the correct location
+     * if <b>all</b> relevant segments must have been processed.
+     *
+     * @return true if the point lies in or on the supplied polygon
+     */
+    bool isPointInPolygon();
 
 };
 
diff --git a/include/geos/algorithm/RayCrossingCounterDD.h b/include/geos/algorithm/RayCrossingCounterDD.h
index 1bb431b..bc2ddf0 100644
--- a/include/geos/algorithm/RayCrossingCounterDD.h
+++ b/include/geos/algorithm/RayCrossingCounterDD.h
@@ -130,7 +130,8 @@ public:
      *
      * @return true if the point lies exactly on a segment
      */
-    bool isOnSegment()
+    bool
+    isOnSegment()
     {
         return isPointOnSegment;
     }
diff --git a/include/geos/algorithm/RobustDeterminant.h b/include/geos/algorithm/RobustDeterminant.h
index a873e01..b481a8d 100644
--- a/include/geos/algorithm/RobustDeterminant.h
+++ b/include/geos/algorithm/RobustDeterminant.h
@@ -51,15 +51,15 @@ namespace algorithm { // geos::algorithm
 class GEOS_DLL RobustDeterminant {
 public:
 
-	/** \brief
-	 * Computes the sign of the determinant of the 2x2 matrix
-	 * with the given entries, in a robust way.
-	 *
-	 * @return -1 if the determinant is negative,
-	 * @return  1 if the determinant is positive,
-	 * @return  0 if the determinant is 0.
-	 */
-	static int signOfDet2x2(double x1,double y1,double x2,double y2);
+    /** \brief
+     * Computes the sign of the determinant of the 2x2 matrix
+     * with the given entries, in a robust way.
+     *
+     * @return -1 if the determinant is negative,
+     * @return  1 if the determinant is positive,
+     * @return  0 if the determinant is 0.
+     */
+    static int signOfDet2x2(double x1, double y1, double x2, double y2);
 };
 
 } // namespace geos::algorithm
diff --git a/include/geos/algorithm/SimplePointInRing.h b/include/geos/algorithm/SimplePointInRing.h
index 05cfeda..b5bd6a3 100644
--- a/include/geos/algorithm/SimplePointInRing.h
+++ b/include/geos/algorithm/SimplePointInRing.h
@@ -21,11 +21,11 @@
 
 // Forward declarations
 namespace geos {
-	namespace geom {
-		class Coordinate;
-		class LinearRing;
-		class CoordinateSequence;
-	}
+namespace geom {
+class Coordinate;
+class LinearRing;
+class CoordinateSequence;
+}
 }
 
 namespace geos {
@@ -33,11 +33,11 @@ namespace algorithm { // geos::algorithm
 
 class GEOS_DLL SimplePointInRing: public PointInRing {
 public:
-	SimplePointInRing(geom::LinearRing *ring);
-	~SimplePointInRing() override;
-	bool isInside(const geom::Coordinate& pt) override;
+    SimplePointInRing(geom::LinearRing* ring);
+    ~SimplePointInRing() override;
+    bool isInside(const geom::Coordinate& pt) override;
 private:
-	const geom::CoordinateSequence* pts;
+    const geom::CoordinateSequence* pts;
 };
 
 } // namespace geos::algorithm
diff --git a/include/geos/algorithm/distance/DiscreteFrechetDistance.h b/include/geos/algorithm/distance/DiscreteFrechetDistance.h
index ba7b30b..b1dacee 100644
--- a/include/geos/algorithm/distance/DiscreteFrechetDistance.h
+++ b/include/geos/algorithm/distance/DiscreteFrechetDistance.h
@@ -40,19 +40,19 @@
 #endif
 
 namespace geos {
-	namespace algorithm {
-		//class RayCrossingCounter;
-	}
-	namespace geom {
-		class Geometry;
-		class Coordinate;
-		//class CoordinateSequence;
-	}
-	namespace index {
-		namespace intervalrtree {
-			//class SortedPackedIntervalRTree;
-		}
-	}
+namespace algorithm {
+//class RayCrossingCounter;
+}
+namespace geom {
+class Geometry;
+class Coordinate;
+//class CoordinateSequence;
+}
+namespace index {
+namespace intervalrtree {
+//class SortedPackedIntervalRTree;
+}
+}
 }
 
 namespace geos {
@@ -103,69 +103,71 @@ namespace distance { // geos::algorithm::distance
  *   DFD(A, B') = 282.842712474619
  * </pre>
  */
-class GEOS_DLL DiscreteFrechetDistance
-{
+class GEOS_DLL DiscreteFrechetDistance {
 public:
 
-	static double distance(const geom::Geometry& g0,
-			       const geom::Geometry& g1);
-
-	static double distance(const geom::Geometry& g0,
-			       const geom::Geometry& g1, double densifyFrac);
-
-	DiscreteFrechetDistance(const geom::Geometry& p_g0,
-				const geom::Geometry& p_g1)
-		:
-		g0(p_g0),
-		g1(p_g1),
-		ptDist(),
-		densifyFrac(0.0)
-	{}
-
-	/**
-	 * Sets the fraction by which to densify each segment.
-	 * Each segment will be (virtually) split into a number of equal-length
-	 * subsegments, whose fraction of the total length is closest
-	 * to the given fraction.
-	 *
-	 * @param dFrac
-	 */
-	void setDensifyFraction(double dFrac)
-	{
-		if ( dFrac > 1.0 || dFrac <= 0.0 )
-		{
-			throw util::IllegalArgumentException(
-				"Fraction is not in range (0.0 - 1.0]");
-		}
-
-		densifyFrac = dFrac;
-	}
-
-	double distance()
-	{
-		compute(g0, g1);
-		return ptDist.getDistance();
-	}
-
-	const std::vector<geom::Coordinate> getCoordinates() const
-	{
-		return ptDist.getCoordinates();
-	}
+    static double distance(const geom::Geometry& g0,
+                           const geom::Geometry& g1);
+
+    static double distance(const geom::Geometry& g0,
+                           const geom::Geometry& g1, double densifyFrac);
+
+    DiscreteFrechetDistance(const geom::Geometry& p_g0,
+                            const geom::Geometry& p_g1)
+        :
+        g0(p_g0),
+        g1(p_g1),
+        ptDist(),
+        densifyFrac(0.0)
+    {}
+
+    /**
+     * Sets the fraction by which to densify each segment.
+     * Each segment will be (virtually) split into a number of equal-length
+     * subsegments, whose fraction of the total length is closest
+     * to the given fraction.
+     *
+     * @param dFrac
+     */
+    void
+    setDensifyFraction(double dFrac)
+    {
+        if(dFrac > 1.0 || dFrac <= 0.0) {
+            throw util::IllegalArgumentException(
+                "Fraction is not in range (0.0 - 1.0]");
+        }
+
+        densifyFrac = dFrac;
+    }
+
+    double
+    distance()
+    {
+        compute(g0, g1);
+        return ptDist.getDistance();
+    }
+
+    const std::vector<geom::Coordinate>
+    getCoordinates() const
+    {
+        return ptDist.getCoordinates();
+    }
 
 private:
-	geom::Coordinate getSegementAt(const geom::CoordinateSequence& seq, size_t index);
+    geom::Coordinate getSegementAt(const geom::CoordinateSequence& seq, size_t index);
 
-	PointPairDistance& getFrecheDistance(std::vector< std::vector<PointPairDistance> >& ca, size_t i, size_t j, const geom::CoordinateSequence& p, const geom::CoordinateSequence& q);
+    PointPairDistance& getFrecheDistance(std::vector< std::vector<PointPairDistance> >& ca, size_t i, size_t j,
+                                         const geom::CoordinateSequence& p, const geom::CoordinateSequence& q);
 
-	void compute(const geom::Geometry& discreteGeom, const geom::Geometry& geom);
+    void compute(const geom::Geometry& discreteGeom, const geom::Geometry& geom);
 
-	const geom::Geometry& g0;
+    const geom::Geometry& g0;
 
-	const geom::Geometry& g1;
+    const geom::Geometry& g1;
 
-	PointPairDistance ptDist;
+    PointPairDistance ptDist;
 
-	/// Value of 0.0 indicates that no densification should take place
+    /// Value of 0.0 indicates that no densification should take place
     double densifyFrac; // = 0.0;
 
     // Declare type as noncopyable
diff --git a/include/geos/algorithm/distance/DiscreteHausdorffDistance.h b/include/geos/algorithm/distance/DiscreteHausdorffDistance.h
index 77d8535..10a8bef 100644
--- a/include/geos/algorithm/distance/DiscreteHausdorffDistance.h
+++ b/include/geos/algorithm/distance/DiscreteHausdorffDistance.h
@@ -37,19 +37,19 @@
 #endif
 
 namespace geos {
-	namespace algorithm {
-		//class RayCrossingCounter;
-	}
-	namespace geom {
-		class Geometry;
-		class Coordinate;
-		//class CoordinateSequence;
-	}
-	namespace index {
-		namespace intervalrtree {
-			//class SortedPackedIntervalRTree;
-		}
-	}
+namespace algorithm {
+//class RayCrossingCounter;
+}
+namespace geom {
+class Geometry;
+class Coordinate;
+//class CoordinateSequence;
+}
+namespace index {
+namespace intervalrtree {
+//class SortedPackedIntervalRTree;
+}
+}
 }
 
 namespace geos {
@@ -97,148 +97,161 @@ namespace distance { // geos::algorithm::distance
  *   HD(A, B) ~= 47.8
  * </pre>
  */
-class GEOS_DLL DiscreteHausdorffDistance
-{
+class GEOS_DLL DiscreteHausdorffDistance {
 public:
 
-	static double distance(const geom::Geometry& g0,
-	                       const geom::Geometry& g1);
-
-	static double distance(const geom::Geometry& g0,
-	                       const geom::Geometry& g1, double densifyFrac);
-
-	DiscreteHausdorffDistance(const geom::Geometry& p_g0,
-	                          const geom::Geometry& p_g1)
-		:
-		g0(p_g0),
-		g1(p_g1),
-		ptDist(),
-		densifyFrac(0.0)
-	{}
-
-	/**
-	 * Sets the fraction by which to densify each segment.
-	 * Each segment will be (virtually) split into a number of equal-length
-	 * subsegments, whose fraction of the total length is closest
-	 * to the given fraction.
-	 *
-	 * @param dFrac
-	 */
-	void setDensifyFraction(double dFrac)
-	{
-		if ( dFrac > 1.0 || dFrac <= 0.0 )
-		{
-			throw util::IllegalArgumentException(
-				"Fraction is not in range (0.0 - 1.0]");
-		}
-
-		densifyFrac = dFrac;
-	}
-
-	double distance()
-	{
-		compute(g0, g1);
-		return ptDist.getDistance();
-	}
-
-	double orientedDistance()
-	{
-		computeOrientedDistance(g0, g1, ptDist);
-		return ptDist.getDistance();
-	}
-
-	const std::vector<geom::Coordinate> getCoordinates() const
-	{
-		return ptDist.getCoordinates();
-	}
-
-	class MaxPointDistanceFilter : public geom::CoordinateFilter
-	{
-	public:
-		MaxPointDistanceFilter(const geom::Geometry& p_geom)
-			:
-			geom(p_geom)
-		{}
-
-		void filter_ro(const geom::Coordinate* pt) override
-		{
-			minPtDist.initialize();
-			DistanceToPoint::computeDistance(geom, *pt,
-			                                         minPtDist);
-			maxPtDist.setMaximum(minPtDist);
-		}
-
-		const PointPairDistance& getMaxPointDistance() const
-		{
-			return maxPtDist;
-		}
-
-	private:
-		PointPairDistance maxPtDist;
-		PointPairDistance minPtDist;
-		DistanceToPoint euclideanDist;
-		const geom::Geometry& geom;
+    static double distance(const geom::Geometry& g0,
+                           const geom::Geometry& g1);
+
+    static double distance(const geom::Geometry& g0,
+                           const geom::Geometry& g1, double densifyFrac);
+
+    DiscreteHausdorffDistance(const geom::Geometry& p_g0,
+                              const geom::Geometry& p_g1)
+        :
+        g0(p_g0),
+        g1(p_g1),
+        ptDist(),
+        densifyFrac(0.0)
+    {}
+
+    /**
+     * Sets the fraction by which to densify each segment.
+     * Each segment will be (virtually) split into a number of equal-length
+     * subsegments, whose fraction of the total length is closest
+     * to the given fraction.
+     *
+     * @param dFrac
+     */
+    void
+    setDensifyFraction(double dFrac)
+    {
+        if(dFrac > 1.0 || dFrac <= 0.0) {
+            throw util::IllegalArgumentException(
+                "Fraction is not in range (0.0 - 1.0]");
+        }
+
+        densifyFrac = dFrac;
+    }
+
+    double
+    distance()
+    {
+        compute(g0, g1);
+        return ptDist.getDistance();
+    }
+
+    double
+    orientedDistance()
+    {
+        computeOrientedDistance(g0, g1, ptDist);
+        return ptDist.getDistance();
+    }
+
+    const std::vector<geom::Coordinate>
+    getCoordinates() const
+    {
+        return ptDist.getCoordinates();
+    }
+
+    class MaxPointDistanceFilter : public geom::CoordinateFilter {
+    public:
+        MaxPointDistanceFilter(const geom::Geometry& p_geom)
+            :
+            geom(p_geom)
+        {}
+
+        void
+        filter_ro(const geom::Coordinate* pt) override
+        {
+            minPtDist.initialize();
+            DistanceToPoint::computeDistance(geom, *pt,
+                                             minPtDist);
+            maxPtDist.setMaximum(minPtDist);
+        }
+
+        const PointPairDistance&
+        getMaxPointDistance() const
+        {
+            return maxPtDist;
+        }
+
+    private:
+        PointPairDistance maxPtDist;
+        PointPairDistance minPtDist;
+        DistanceToPoint euclideanDist;
+        const geom::Geometry& geom;
 
         // Declare type as noncopyable
         MaxPointDistanceFilter(const MaxPointDistanceFilter& other);
         MaxPointDistanceFilter& operator=(const MaxPointDistanceFilter& rhs);
-	};
-
-	class MaxDensifiedByFractionDistanceFilter
-			: public geom::CoordinateSequenceFilter
-	{
-	public:
-
-		MaxDensifiedByFractionDistanceFilter(
-				const geom::Geometry& p_geom, double fraction)
-			:
-			geom(p_geom),
-                numSubSegs( std::size_t(util::round(1.0/fraction)) )
-		{
-		}
-
-		void filter_ro(const geom::CoordinateSequence& seq,
-		               std::size_t index) override;
-
-		bool isGeometryChanged() const override { return false; }
-
-		bool isDone() const override { return false; }
-
-		const PointPairDistance& getMaxPointDistance() const {
-			return maxPtDist;
-		}
-
-	private:
-		PointPairDistance maxPtDist;
-		PointPairDistance minPtDist;
-		const geom::Geometry& geom;
-		std::size_t numSubSegs; // = 0;
+    };
+
+    class MaxDensifiedByFractionDistanceFilter
+        : public geom::CoordinateSequenceFilter {
+    public:
+
+        MaxDensifiedByFractionDistanceFilter(
+            const geom::Geometry& p_geom, double fraction)
+            :
+            geom(p_geom),
+            numSubSegs(std::size_t(util::round(1.0 / fraction)))
+        {
+        }
+
+        void filter_ro(const geom::CoordinateSequence& seq,
+                       std::size_t index) override;
+
+        bool
+        isGeometryChanged() const override
+        {
+            return false;
+        }
+
+        bool
+        isDone() const override
+        {
+            return false;
+        }
+
+        const PointPairDistance&
+        getMaxPointDistance() const
+        {
+            return maxPtDist;
+        }
+
+    private:
+        PointPairDistance maxPtDist;
+        PointPairDistance minPtDist;
+        const geom::Geometry& geom;
+        std::size_t numSubSegs; // = 0;
 
         // Declare type as noncopyable
         MaxDensifiedByFractionDistanceFilter(const MaxDensifiedByFractionDistanceFilter& other);
         MaxDensifiedByFractionDistanceFilter& operator=(const MaxDensifiedByFractionDistanceFilter& rhs);
-	};
+    };
 
 private:
 
-	void compute(const geom::Geometry& p_g0,
-	             const geom::Geometry& p_g1)
-	{
-		computeOrientedDistance(p_g0, p_g1, ptDist);
-		computeOrientedDistance(p_g1, p_g0, ptDist);
-	}
+    void
+    compute(const geom::Geometry& p_g0,
+            const geom::Geometry& p_g1)
+    {
+        computeOrientedDistance(p_g0, p_g1, ptDist);
+        computeOrientedDistance(p_g1, p_g0, ptDist);
+    }
 
-	void computeOrientedDistance(const geom::Geometry& discreteGeom,
-	                             const geom::Geometry& geom,
-	                             PointPairDistance& ptDist);
+    void computeOrientedDistance(const geom::Geometry& discreteGeom,
+                                 const geom::Geometry& geom,
+                                 PointPairDistance& ptDist);
 
-	const geom::Geometry& g0;
+    const geom::Geometry& g0;
 
-	const geom::Geometry& g1;
+    const geom::Geometry& g1;
 
-	PointPairDistance ptDist;
+    PointPairDistance ptDist;
 
-	/// Value of 0.0 indicates that no densification should take place
+    /// Value of 0.0 indicates that no densification should take place
     double densifyFrac; // = 0.0;
 
     // Declare type as noncopyable
diff --git a/include/geos/algorithm/distance/DistanceToPoint.h b/include/geos/algorithm/distance/DistanceToPoint.h
index e8692f6..6864baf 100644
--- a/include/geos/algorithm/distance/DistanceToPoint.h
+++ b/include/geos/algorithm/distance/DistanceToPoint.h
@@ -22,17 +22,17 @@
 #include <geos/geom/LineSegment.h> // for composition
 
 namespace geos {
-	namespace algorithm {
-		namespace distance {
-			class PointPairDistance;
-		}
-	}
-	namespace geom {
-		class Geometry;
-		class Coordinate;
-		class LineString;
-		class Polygon;
-	}
+namespace algorithm {
+namespace distance {
+class PointPairDistance;
+}
+}
+namespace geom {
+class Geometry;
+class Coordinate;
+class LineString;
+class Polygon;
+}
 }
 
 namespace geos {
@@ -44,27 +44,26 @@ namespace distance { // geos::algorithm::distance
  *
  * Also computes two points which are separated by the distance.
  */
-class DistanceToPoint
-{
+class DistanceToPoint {
 public:
 
-	DistanceToPoint() {}
+    DistanceToPoint() {}
 
-	static void computeDistance(const geom::Geometry& geom,
-			            const geom::Coordinate& pt,
-	                            PointPairDistance& ptDist);
+    static void computeDistance(const geom::Geometry& geom,
+                                const geom::Coordinate& pt,
+                                PointPairDistance& ptDist);
 
-	static void computeDistance(const geom::LineString& geom,
-			            const geom::Coordinate& pt,
-	                            PointPairDistance& ptDist);
+    static void computeDistance(const geom::LineString& geom,
+                                const geom::Coordinate& pt,
+                                PointPairDistance& ptDist);
 
-	static void computeDistance(const geom::LineSegment& geom,
-			            const geom::Coordinate& pt,
-	                            PointPairDistance& ptDist);
+    static void computeDistance(const geom::LineSegment& geom,
+                                const geom::Coordinate& pt,
+                                PointPairDistance& ptDist);
 
-	static void computeDistance(const geom::Polygon& geom,
-			            const geom::Coordinate& pt,
-	                            PointPairDistance& ptDist);
+    static void computeDistance(const geom::Polygon& geom,
+                                const geom::Coordinate& pt,
+                                PointPairDistance& ptDist);
 
 };
 
diff --git a/include/geos/algorithm/distance/PointPairDistance.h b/include/geos/algorithm/distance/PointPairDistance.h
index 6c4bc62..effcc5e 100644
--- a/include/geos/algorithm/distance/PointPairDistance.h
+++ b/include/geos/algorithm/distance/PointPairDistance.h
@@ -34,107 +34,119 @@ namespace distance { // geos::algorithm::distance
  * Provides methods to update with a new point pair with
  * either maximum or minimum distance.
  */
-class PointPairDistance
-{
+class PointPairDistance {
 public:
 
-	PointPairDistance()
-		:
-		pt(2),
-		distance(DoubleNotANumber),
-		isNull(true)
-	{
-		assert(pt.size() == 2);
-	}
-
-	void initialize()
-	{
-		isNull = true;
-	}
-
-	void initialize(const geom::Coordinate& p0, const geom::Coordinate& p1)
-	{
-		pt[0] = p0;
-		pt[1] = p1;
-		distance = p0.distance(p1);
-		isNull = false;
-	}
-
-	double getDistance() const
-	{
-		return distance;
-	}
-
-	const std::vector<geom::Coordinate>& getCoordinates() const
-	{
-		return pt;
-	}
-
-	const geom::Coordinate& getCoordinate(size_t i) const
-	{
-		assert(i<pt.size());
-		return pt[i];
-	}
-
-	void setMaximum(const PointPairDistance& ptDist)
-	{
-		setMaximum(ptDist.pt[0], ptDist.pt[1]);
-	}
-
-	void setMaximum(const geom::Coordinate& p0, const geom::Coordinate& p1)
-	{
-		if (isNull) {
-			initialize(p0, p1);
-			return;
-		}
-		double dist = p0.distance(p1);
-		if (dist > distance)
-			initialize(p0, p1, dist);
-	}
-
-	void setMinimum(const PointPairDistance& ptDist)
-	{
-		setMinimum(ptDist.pt[0], ptDist.pt[1]);
-	}
-
-	void setMinimum(const geom::Coordinate& p0, const geom::Coordinate& p1)
-	{
-		if (isNull) {
-			initialize(p0, p1);
-			return;
-		}
-		double dist = p0.distance(p1);
-		if (dist < distance)
-			initialize(p0, p1, dist);
-	}
-
-	bool getIsNull()
-	{
-		return isNull;
-	}
+    PointPairDistance()
+        :
+        pt(2),
+        distance(DoubleNotANumber),
+        isNull(true)
+    {
+        assert(pt.size() == 2);
+    }
+
+    void
+    initialize()
+    {
+        isNull = true;
+    }
+
+    void
+    initialize(const geom::Coordinate& p0, const geom::Coordinate& p1)
+    {
+        pt[0] = p0;
+        pt[1] = p1;
+        distance = p0.distance(p1);
+        isNull = false;
+    }
+
+    double
+    getDistance() const
+    {
+        return distance;
+    }
+
+    const std::vector<geom::Coordinate>&
+    getCoordinates() const
+    {
+        return pt;
+    }
+
+    const geom::Coordinate&
+    getCoordinate(size_t i) const
+    {
+        assert(i < pt.size());
+        return pt[i];
+    }
+
+    void
+    setMaximum(const PointPairDistance& ptDist)
+    {
+        setMaximum(ptDist.pt[0], ptDist.pt[1]);
+    }
+
+    void
+    setMaximum(const geom::Coordinate& p0, const geom::Coordinate& p1)
+    {
+        if(isNull) {
+            initialize(p0, p1);
+            return;
+        }
+        double dist = p0.distance(p1);
+        if(dist > distance) {
+            initialize(p0, p1, dist);
+        }
+    }
+
+    void
+    setMinimum(const PointPairDistance& ptDist)
+    {
+        setMinimum(ptDist.pt[0], ptDist.pt[1]);
+    }
+
+    void
+    setMinimum(const geom::Coordinate& p0, const geom::Coordinate& p1)
+    {
+        if(isNull) {
+            initialize(p0, p1);
+            return;
+        }
+        double dist = p0.distance(p1);
+        if(dist < distance) {
+            initialize(p0, p1, dist);
+        }
+    }
+
+    bool
+    getIsNull()
+    {
+        return isNull;
+    }
 
 private:
 
-	/**
-	 * Initializes the points, avoiding recomputing the distance.
-	 * @param p0
-	 * @param p1
-	 * @param dist the distance between p0 and p1
-	 */
-	void initialize(const geom::Coordinate& p0, const geom::Coordinate& p1,
-	                double dist)
-	{
-		pt[0] = p0;
-		pt[1] = p1;
-		distance = dist;
-		isNull = false;
-	}
-
-	std::vector<geom::Coordinate> pt;
-
-	double distance;
-
-	bool isNull;
+    /**
+     * Initializes the points, avoiding recomputing the distance.
+     * @param p0
+     * @param p1
+     * @param dist the distance between p0 and p1
+     */
+    void
+    initialize(const geom::Coordinate& p0, const geom::Coordinate& p1,
+               double dist)
+    {
+        pt[0] = p0;
+        pt[1] = p1;
+        distance = dist;
+        isNull = false;
+    }
+
+    std::vector<geom::Coordinate> pt;
+
+    double distance;
+
+    bool isNull;
 };
 
 } // geos::algorithm::distance
diff --git a/include/geos/algorithm/locate/IndexedPointInAreaLocator.h b/include/geos/algorithm/locate/IndexedPointInAreaLocator.h
index 591241c..00ebbc0 100644
--- a/include/geos/algorithm/locate/IndexedPointInAreaLocator.h
+++ b/include/geos/algorithm/locate/IndexedPointInAreaLocator.h
@@ -51,48 +51,45 @@ namespace locate { // geos::algorithm::locate
  * {@link Polygonal} and {@link LinearRing} geometries
  * are supported.
  */
-class IndexedPointInAreaLocator : public PointOnGeometryLocator
-{
+class IndexedPointInAreaLocator : public PointOnGeometryLocator {
 private:
-    class IntervalIndexedGeometry
-    {
+    class IntervalIndexedGeometry {
     private:
         index::intervalrtree::SortedPackedIntervalRTree index;
 
-        void init(const geom::Geometry & g);
-        void addLine(const geom::CoordinateSequence * pts);
+        void init(const geom::Geometry& g);
+        void addLine(const geom::CoordinateSequence* pts);
 
         // To keep track of LineSegments
         std::vector< geom::LineSegment > segments;
 
     public:
-        IntervalIndexedGeometry(const geom::Geometry & g);
+        IntervalIndexedGeometry(const geom::Geometry& g);
 
-        void query(double min, double max, index::ItemVisitor * visitor);
+        void query(double min, double max, index::ItemVisitor* visitor);
     };
 
 
-    class SegmentVisitor : public index::ItemVisitor
-    {
+    class SegmentVisitor : public index::ItemVisitor {
     private:
-        algorithm::RayCrossingCounter * counter;
+        algorithm::RayCrossingCounter* counter;
 
     public:
-        SegmentVisitor(algorithm::RayCrossingCounter * p_counter)
+        SegmentVisitor(algorithm::RayCrossingCounter* p_counter)
             :	counter(p_counter)
         { }
 
         ~SegmentVisitor() override
         { }
 
-        void visitItem(void * item) override;
+        void visitItem(void* item) override;
     };
 
 
-    const geom::Geometry & areaGeom;
+    const geom::Geometry& areaGeom;
     std::unique_ptr<IntervalIndexedGeometry> index;
 
-    void buildIndex(const geom::Geometry & g);
+    void buildIndex(const geom::Geometry& g);
 
     // Declare type as noncopyable
     IndexedPointInAreaLocator(const IndexedPointInAreaLocator& other) = delete;
@@ -106,7 +103,7 @@ public:
     *
      * @param g the Geometry to locate in
      */
-    IndexedPointInAreaLocator(const geom::Geometry & g);
+    IndexedPointInAreaLocator(const geom::Geometry& g);
 
     /**
      * Determines the {@link Location} of a point in an areal {@link Geometry}.
@@ -114,7 +111,7 @@ public:
      * @param p the point to test
      * @return the location of the point in the geometry
      */
-    int locate(const geom::Coordinate * /*const*/ p) override;
+    int locate(const geom::Coordinate* /*const*/ p) override;
 
 };
 
diff --git a/include/geos/algorithm/locate/PointOnGeometryLocator.h b/include/geos/algorithm/locate/PointOnGeometryLocator.h
index 58f149d..c06fd8a 100644
--- a/include/geos/algorithm/locate/PointOnGeometryLocator.h
+++ b/include/geos/algorithm/locate/PointOnGeometryLocator.h
@@ -17,9 +17,9 @@
 #define GEOS_ALGORITHM_LOCATE_POINTONGEOMETRYLOCATOR_H
 
 namespace geos {
-	namespace geom {
-		class Coordinate;
-	}
+namespace geom {
+class Coordinate;
+}
 }
 
 namespace geos {
@@ -32,21 +32,21 @@ namespace locate { // geos::algorithm::locate
  *
  * @author Martin Davis
  */
-class PointOnGeometryLocator
-{
+class PointOnGeometryLocator {
 private:
 protected:
 public:
-	virtual ~PointOnGeometryLocator()
-	{ }
+    virtual
+    ~PointOnGeometryLocator()
+    { }
 
-	/**
-	 * Determines the {@link Location} of a point in an areal {@link Geometry}.
-	 *
-	 * @param p the point to test
-	 * @return the location of the point in the geometry
-	 */
-	virtual int locate( const geom::Coordinate * /*const*/ p) =0;
+    /**
+     * Determines the {@link Location} of a point in an areal {@link Geometry}.
+     *
+     * @param p the point to test
+     * @return the location of the point in the geometry
+     */
+    virtual int locate(const geom::Coordinate* /*const*/ p) = 0;
 };
 
 } // geos::algorithm::locate
diff --git a/include/geos/algorithm/locate/SimplePointInAreaLocator.h b/include/geos/algorithm/locate/SimplePointInAreaLocator.h
index 4020230..2b51986 100644
--- a/include/geos/algorithm/locate/SimplePointInAreaLocator.h
+++ b/include/geos/algorithm/locate/SimplePointInAreaLocator.h
@@ -44,13 +44,12 @@ namespace locate { // geos::algorithm::locate
  *
  * @version 1.7
  */
-class SimplePointInAreaLocator : public PointOnGeometryLocator
-{
+class SimplePointInAreaLocator : public PointOnGeometryLocator {
 
 public:
 
     static int locate(const geom::Coordinate& p,
-                      const geom::Geometry *geom);
+                      const geom::Geometry* geom);
 
     /**
     * Determines the {@link Location} of a point in a {@link Polygon}.
@@ -62,13 +61,14 @@ public:
     * @return the Location of the point in the polygon
     */
     static int locatePointInPolygon(const geom::Coordinate& p,
-                                    const geom::Polygon *poly);
+                                    const geom::Polygon* poly);
 
-    SimplePointInAreaLocator(const geom::Geometry * p_g)
+    SimplePointInAreaLocator(const geom::Geometry* p_g)
         :	g(p_g)
     { }
 
-    int locate(const geom::Coordinate * p) override
+    int
+    locate(const geom::Coordinate* p) override
     {
         return locate(*p, g);
     }
@@ -76,9 +76,9 @@ public:
 private:
 
     static int locateInGeometry(const geom::Coordinate& p,
-                                const geom::Geometry *geom);
+                                const geom::Geometry* geom);
 
-    const geom::Geometry * g;
+    const geom::Geometry* g;
 
 };
 
diff --git a/include/geos/geom/BinaryOp.h b/include/geos/geom/BinaryOp.h
index 272d33f..c973900 100644
--- a/include/geos/geom/BinaryOp.h
+++ b/include/geos/geom/BinaryOp.h
@@ -168,49 +168,48 @@ namespace geos {
 namespace geom { // geos::geom
 
 inline bool
-check_valid(const Geometry& g, const std::string& label, bool doThrow=false, bool validOnly=false)
+check_valid(const Geometry& g, const std::string& label, bool doThrow = false, bool validOnly = false)
 {
-  if ( dynamic_cast<const Lineal*>(&g) ) {
-    if ( ! validOnly ) {
-      operation::IsSimpleOp sop(g, algorithm::BoundaryNodeRule::getBoundaryEndPoint());
-      if ( ! sop.isSimple() )
-      {
-        if ( doThrow ) {
-          throw geos::util::TopologyException(
-            label + " is not simple");
+    if(dynamic_cast<const Lineal*>(&g)) {
+        if(! validOnly) {
+            operation::IsSimpleOp sop(g, algorithm::BoundaryNodeRule::getBoundaryEndPoint());
+            if(! sop.isSimple()) {
+                if(doThrow) {
+                    throw geos::util::TopologyException(
+                        label + " is not simple");
+                }
+                return false;
+            }
         }
-        return false;
-      }
     }
-  } else {
-    operation::valid::IsValidOp ivo(&g);
-    if ( ! ivo.isValid() )
-    {
-      using operation::valid::TopologyValidationError;
-      TopologyValidationError* err = ivo.getValidationError();
+    else {
+        operation::valid::IsValidOp ivo(&g);
+        if(! ivo.isValid()) {
+            using operation::valid::TopologyValidationError;
+            TopologyValidationError* err = ivo.getValidationError();
 #ifdef GEOS_DEBUG_BINARYOP
-      std::cerr << label << " is INVALID: "
-        << err->toString()
-        << " (" << std::setprecision(20)
-        << err->getCoordinate() << ")"
-        << std::endl
+            std::cerr << label << " is INVALID: "
+                      << err->toString()
+                      << " (" << std::setprecision(20)
+                      << err->getCoordinate() << ")"
+                      << std::endl
 #ifdef GEOS_DEBUG_BINARYOP_PRINT_INVALID
-        << "<A>" << std::endl
-        << g.toString()
-        << std::endl
-        << "</A>" << std::endl
-#endif
-        ;
-#endif
-      if ( doThrow ) {
-        throw geos::util::TopologyException(
-          label + " is invalid: " + err->toString(),
-                err->getCoordinate());
-      }
-      return false;
+                      << "<A>" << std::endl
+                      << g.toString()
+                      << std::endl
+                      << "</A>" << std::endl
+#endif
+                      ;
+#endif
+            if(doThrow) {
+                throw geos::util::TopologyException(
+                    label + " is invalid: " + err->toString(),
+                    err->getCoordinate());
+            }
+            return false;
+        }
     }
-  }
-	return true;
+    return true;
 }
 
 /*
@@ -222,44 +221,48 @@ check_valid(const Geometry& g, const std::string& label, bool doThrow=false, boo
 inline std::unique_ptr<Geometry>
 fix_self_intersections(std::unique_ptr<Geometry> g, const std::string& label)
 {
-  ::geos::ignore_unused_variable_warning(label);
+    ::geos::ignore_unused_variable_warning(label);
 #ifdef GEOS_DEBUG_BINARYOP
-	std::cerr << label << " fix_self_intersection (UnaryUnion)" << std::endl;
+    std::cerr << label << " fix_self_intersection (UnaryUnion)" << std::endl;
 #endif
 
-  // Only multi-components can be fixed by UnaryUnion
-  if ( ! dynamic_cast<const GeometryCollection*>(g.get()) ) return g;
+    // Only multi-components can be fixed by UnaryUnion
+    if(! dynamic_cast<const GeometryCollection*>(g.get())) {
+        return g;
+    }
 
-  using operation::valid::IsValidOp;
+    using operation::valid::IsValidOp;
 
-  IsValidOp ivo(g.get());
+    IsValidOp ivo(g.get());
 
-  // Polygon is valid, nothing to do
-  if ( ivo.isValid() ) return g;
+    // Polygon is valid, nothing to do
+    if(ivo.isValid()) {
+        return g;
+    }
 
-  // Not all invalidities can be fixed by this code
+    // Not all invalidities can be fixed by this code
 
-  using operation::valid::TopologyValidationError;
-  TopologyValidationError* err = ivo.getValidationError();
-  switch ( err->getErrorType() ) {
+    using operation::valid::TopologyValidationError;
+    TopologyValidationError* err = ivo.getValidationError();
+    switch(err->getErrorType()) {
     case TopologyValidationError::eRingSelfIntersection:
     case TopologyValidationError::eTooFewPoints: // collapsed lines
 #ifdef GEOS_DEBUG_BINARYOP
-	    std::cerr << label << " ATTEMPT_TO_FIX: " << err->getErrorType() << ": " << *g << std::endl;
+        std::cerr << label << " ATTEMPT_TO_FIX: " << err->getErrorType() << ": " << *g << std::endl;
 #endif
-      g = g->Union();
+        g = g->Union();
 #ifdef GEOS_DEBUG_BINARYOP
-	    std::cerr << label << " ATTEMPT_TO_FIX succeeded.. " << std::endl;
+        std::cerr << label << " ATTEMPT_TO_FIX succeeded.. " << std::endl;
 #endif
-      return g;
+        return g;
     case TopologyValidationError::eSelfIntersection:
-      // this one is within a single component, won't be fixed
+    // this one is within a single component, won't be fixed
     default:
 #ifdef GEOS_DEBUG_BINARYOP
-	    std::cerr << label << " invalidity is: " << err->getErrorType() << std::endl;
+        std::cerr << label << " invalidity is: " << err->getErrorType() << std::endl;
 #endif
-      return g;
-  }
+        return g;
+    }
 }
 
 
@@ -270,200 +273,196 @@ fix_self_intersections(std::unique_ptr<Geometry> g, const std::string& label)
 ///
 template <class BinOp>
 std::unique_ptr<Geometry>
-SnapOp(const Geometry* g0, const Geometry *g1, BinOp _Op)
+SnapOp(const Geometry* g0, const Geometry* g1, BinOp _Op)
 {
-	typedef std::unique_ptr<Geometry> GeomPtr;
+    typedef std::unique_ptr<Geometry> GeomPtr;
 
-	//using geos::precision::GeometrySnapper;
-	using geos::operation::overlay::snap::GeometrySnapper;
+    //using geos::precision::GeometrySnapper;
+    using geos::operation::overlay::snap::GeometrySnapper;
 
-	// Snap tolerance must be computed on the original
-	// (not commonbits-removed) geoms
-	double snapTolerance = GeometrySnapper::computeOverlaySnapTolerance(*g0, *g1);
+    // Snap tolerance must be computed on the original
+    // (not commonbits-removed) geoms
+    double snapTolerance = GeometrySnapper::computeOverlaySnapTolerance(*g0, *g1);
 #if GEOS_DEBUG_BINARYOP
-	std::cerr<< std::setprecision(20) << "Computed snap tolerance: "<<snapTolerance<<std::endl;
+    std::cerr << std::setprecision(20) << "Computed snap tolerance: " << snapTolerance << std::endl;
 #endif
 
 
 #if CBR_BEFORE_SNAPPING
-	// Compute common bits
-	geos::precision::CommonBitsRemover cbr;
-	cbr.add(g0); cbr.add(g1);
+    // Compute common bits
+    geos::precision::CommonBitsRemover cbr;
+    cbr.add(g0);
+    cbr.add(g1);
 #if GEOS_DEBUG_BINARYOP
-	std::cerr<<"Computed common bits: "<<cbr.getCommonCoordinate()<<std::endl;
+    std::cerr << "Computed common bits: " << cbr.getCommonCoordinate() << std::endl;
 #endif
 
-	// Now remove common bits
-	GeomPtr rG0( cbr.removeCommonBits(g0->clone()) );
-	GeomPtr rG1( cbr.removeCommonBits(g1->clone()) );
+    // Now remove common bits
+    GeomPtr rG0(cbr.removeCommonBits(g0->clone()));
+    GeomPtr rG1(cbr.removeCommonBits(g1->clone()));
 
 #if GEOS_DEBUG_BINARYOP
-	check_valid(*rG0, "CBR: removed-bits geom 0");
-	check_valid(*rG1, "CBR: removed-bits geom 1");
+    check_valid(*rG0, "CBR: removed-bits geom 0");
+    check_valid(*rG1, "CBR: removed-bits geom 1");
 #endif
 
-	const Geometry& operand0 = *rG0;
-	const Geometry& operand1 = *rG1;
+    const Geometry& operand0 = *rG0;
+    const Geometry& operand1 = *rG1;
 #else // don't CBR before snapping
-	const Geometry& operand0 = *g0;
-	const Geometry& operand1 = *g1;
+    const Geometry& operand0 = *g0;
+    const Geometry& operand1 = *g1;
 #endif
 
 
-	GeometrySnapper snapper0( operand0 );
-	GeomPtr snapG0( snapper0.snapTo(operand1, snapTolerance) );
-	//snapG0 = fix_self_intersections(snapG0, "SNAP: snapped geom 0");
+    GeometrySnapper snapper0(operand0);
+    GeomPtr snapG0(snapper0.snapTo(operand1, snapTolerance));
+    //snapG0 = fix_self_intersections(snapG0, "SNAP: snapped geom 0");
 
-	// NOTE: second geom is snapped on the snapped first one
-	GeometrySnapper snapper1( operand1 );
-	GeomPtr snapG1( snapper1.snapTo(*snapG0, snapTolerance) );
-	//snapG1 = fix_self_intersections(snapG1, "SNAP: snapped geom 1");
+    // NOTE: second geom is snapped on the snapped first one
+    GeometrySnapper snapper1(operand1);
+    GeomPtr snapG1(snapper1.snapTo(*snapG0, snapTolerance));
+    //snapG1 = fix_self_intersections(snapG1, "SNAP: snapped geom 1");
 
-	// Run the binary op
-	GeomPtr result( _Op(snapG0.get(), snapG1.get()) );
+    // Run the binary op
+    GeomPtr result(_Op(snapG0.get(), snapG1.get()));
 
 #if GEOS_DEBUG_BINARYOP
-	check_valid(*result, "SNAP: result (before common-bits addition");
+    check_valid(*result, "SNAP: result (before common-bits addition");
 #endif
 
 #if CBR_BEFORE_SNAPPING
-	// Add common bits back in
-	cbr.addCommonBits( result.get() );
-	//result = fix_self_intersections(result, "SNAP: result (after common-bits addition)");
+    // Add common bits back in
+    cbr.addCommonBits(result.get());
+    //result = fix_self_intersections(result, "SNAP: result (after common-bits addition)");
 
-  check_valid(*result, "CBR: result (after common-bits addition)", true);
+    check_valid(*result, "CBR: result (after common-bits addition)", true);
 
 #endif
 
-	return result;
+    return result;
 }
 
 template <class BinOp>
 std::unique_ptr<Geometry>
-BinaryOp(const Geometry* g0, const Geometry *g1, BinOp _Op)
+BinaryOp(const Geometry* g0, const Geometry* g1, BinOp _Op)
 {
-	typedef std::unique_ptr<Geometry> GeomPtr;
+    typedef std::unique_ptr<Geometry> GeomPtr;
 
-	GeomPtr ret;
-	geos::util::TopologyException origException;
+    GeomPtr ret;
+    geos::util::TopologyException origException;
 
 #ifdef USE_ORIGINAL_INPUT
-	// Try with original input
-	try
-	{
+    // Try with original input
+    try {
 #if GEOS_DEBUG_BINARYOP
-		std::cerr << "Trying with original input." << std::endl;
+        std::cerr << "Trying with original input." << std::endl;
 #endif
-		ret.reset(_Op(g0, g1));
+        ret.reset(_Op(g0, g1));
 
 #if GEOS_CHECK_ORIGINAL_RESULT_VALIDITY
-		check_valid(*ret, "Overlay result between original inputs", true, true);
+        check_valid(*ret, "Overlay result between original inputs", true, true);
 #endif
 
 #if GEOS_DEBUG_BINARYOP
-		std::cerr << "Attempt with original input succeeded" << std::endl;
+        std::cerr << "Attempt with original input succeeded" << std::endl;
 #endif
-		return ret;
-	}
-	catch (const geos::util::TopologyException& ex)
-	{
-		origException=ex;
+        return ret;
+    }
+    catch(const geos::util::TopologyException& ex) {
+        origException = ex;
 #if GEOS_DEBUG_BINARYOP
-		std::cerr << "Original exception: " << ex.what() << std::endl;
+        std::cerr << "Original exception: " << ex.what() << std::endl;
 #endif
-	}
+    }
 #endif // USE_ORIGINAL_INPUT
 
-	check_valid(*g0, "Input geom 0", true, true);
-	check_valid(*g1, "Input geom 1", true, true);
+    check_valid(*g0, "Input geom 0", true, true);
+    check_valid(*g1, "Input geom 1", true, true);
 
 #if USE_COMMONBITS_POLICY
-	// Try removing common bits (possibly obsoleted by snapping below)
-	//
-	// NOTE: this policy was _later_ implemented
-	//       in JTS as EnhancedPrecisionOp
-	// TODO: consider using the now-ported EnhancedPrecisionOp
-	//       here too
-	//
-	try
-	{
-		GeomPtr rG0;
-		GeomPtr rG1;
-		precision::CommonBitsRemover cbr;
+    // Try removing common bits (possibly obsoleted by snapping below)
+    //
+    // NOTE: this policy was _later_ implemented
+    //       in JTS as EnhancedPrecisionOp
+    // TODO: consider using the now-ported EnhancedPrecisionOp
+    //       here too
+    //
+    try {
+        GeomPtr rG0;
+        GeomPtr rG1;
+        precision::CommonBitsRemover cbr;
 
 #if GEOS_DEBUG_BINARYOP
-		std::cerr << "Trying with Common Bits Remover (CBR)" << std::endl;
+        std::cerr << "Trying with Common Bits Remover (CBR)" << std::endl;
 #endif
 
-		cbr.add(g0);
-		cbr.add(g1);
+        cbr.add(g0);
+        cbr.add(g1);
 
-		rG0.reset( cbr.removeCommonBits(g0->clone()) );
-		rG1.reset( cbr.removeCommonBits(g1->clone()) );
+        rG0.reset(cbr.removeCommonBits(g0->clone()));
+        rG1.reset(cbr.removeCommonBits(g1->clone()));
 
 #if GEOS_DEBUG_BINARYOP
-		check_valid(*rG0, "CBR: geom 0 (after common-bits removal)");
-		check_valid(*rG1, "CBR: geom 1 (after common-bits removal)");
+        check_valid(*rG0, "CBR: geom 0 (after common-bits removal)");
+        check_valid(*rG1, "CBR: geom 1 (after common-bits removal)");
 #endif
 
-		ret.reset( _Op(rG0.get(), rG1.get()) );
+        ret.reset(_Op(rG0.get(), rG1.get()));
 
 #if GEOS_DEBUG_BINARYOP
-		check_valid(*ret, "CBR: result (before common-bits addition)");
+        check_valid(*ret, "CBR: result (before common-bits addition)");
 #endif
 
-		cbr.addCommonBits( ret.get() );
+        cbr.addCommonBits(ret.get());
 
 #if GEOS_CHECK_COMMONBITS_VALIDITY
-		check_valid(*ret, "CBR: result (after common-bits addition)", true);
+        check_valid(*ret, "CBR: result (after common-bits addition)", true);
 #endif
 
 #if GEOS_DEBUG_BINARYOP
-		std::cerr << "Attempt with CBR succeeded" << std::endl;
+        std::cerr << "Attempt with CBR succeeded" << std::endl;
 #endif
 
-		return ret;
-	}
-	catch (const geos::util::TopologyException& ex)
-	{
+        return ret;
+    }
+    catch(const geos::util::TopologyException& ex) {
         ::geos::ignore_unused_variable_warning(ex);
 #if GEOS_DEBUG_BINARYOP
-		std::cerr << "CBR: " << ex.what() << std::endl;
+        std::cerr << "CBR: " << ex.what() << std::endl;
 #endif
-	}
+    }
 #endif
 
-	// Try with snapping
-	//
-	// TODO: possible optimization would be reusing the
-	//       already common-bit-removed inputs and just
-	//       apply geometry snapping, whereas the current
-	//       SnapOp function does both.
+    // Try with snapping
+    //
+    // TODO: possible optimization would be reusing the
+    //       already common-bit-removed inputs and just
+    //       apply geometry snapping, whereas the current
+    //       SnapOp function does both.
 // {
 #if USE_SNAPPING_POLICY
 
 #if GEOS_DEBUG_BINARYOP
-	std::cerr << "Trying with snapping " << std::endl;
+    std::cerr << "Trying with snapping " << std::endl;
 #endif
 
-	try {
-		ret = SnapOp(g0, g1, _Op);
+    try {
+        ret = SnapOp(g0, g1, _Op);
 #if GEOS_CHECK_SNAPPINGOP_VALIDITY
-		check_valid(*ret, "SNAP: result", true, true);
+        check_valid(*ret, "SNAP: result", true, true);
 #endif
 #if GEOS_DEBUG_BINARYOP
-		std::cerr << "SnapOp succeeded" << std::endl;
+        std::cerr << "SnapOp succeeded" << std::endl;
 #endif
-		return ret;
+        return ret;
 
-	}
-	catch (const geos::util::TopologyException& ex)
-	{
+    }
+    catch(const geos::util::TopologyException& ex) {
         ::geos::ignore_unused_variable_warning(ex);
 #if GEOS_DEBUG_BINARYOP
-		std::cerr << "SNAP: " << ex.what() << std::endl;
+        std::cerr << "SNAP: " << ex.what() << std::endl;
 #endif
-	}
+    }
 
 #endif // USE_SNAPPING_POLICY }
 
@@ -471,85 +470,86 @@ BinaryOp(const Geometry* g0, const Geometry *g1, BinOp _Op)
 #if USE_PRECISION_REDUCTION_POLICY
 
 
-	// Try reducing precision
-	try
-	{
-		long unsigned int g0scale =
+    // Try reducing precision
+    try {
+        long unsigned int g0scale =
             static_cast<long unsigned int>(g0->getFactory()->getPrecisionModel()->getScale());
-		long unsigned int g1scale =
+        long unsigned int g1scale =
             static_cast<long unsigned int>(g1->getFactory()->getPrecisionModel()->getScale());
 
 #if GEOS_DEBUG_BINARYOP
-		std::cerr << "Original input scales are: "
-              << g0scale
-              << " and "
-              << g1scale
-              << std::endl;
+        std::cerr << "Original input scales are: "
+                  << g0scale
+                  << " and "
+                  << g1scale
+                  << std::endl;
 #endif
 
-		double maxScale = 1e16;
+        double maxScale = 1e16;
 
-    // Don't use a scale bigger than the input one
-    if ( g0scale && static_cast<double>(g0scale) < maxScale ) maxScale = static_cast<double>(g0scale);
-    if ( g1scale && static_cast<double>(g1scale) < maxScale ) maxScale = static_cast<double>(g1scale);
+        // Don't use a scale bigger than the input one
+        if(g0scale && static_cast<double>(g0scale) < maxScale) {
+            maxScale = static_cast<double>(g0scale);
+        }
+        if(g1scale && static_cast<double>(g1scale) < maxScale) {
+            maxScale = static_cast<double>(g1scale);
+        }
 
 
-		for (double scale=maxScale; scale >= 1; scale /= 10)
-		{
-			PrecisionModel pm(scale);
-			GeometryFactory::Ptr gf = GeometryFactory::create(&pm);
+        for(double scale = maxScale; scale >= 1; scale /= 10) {
+            PrecisionModel pm(scale);
+            GeometryFactory::Ptr gf = GeometryFactory::create(&pm);
 #if GEOS_DEBUG_BINARYOP
-			std::cerr << "Trying with scale " << scale << std::endl;
+            std::cerr << "Trying with scale " << scale << std::endl;
 #endif
 
-			precision::GeometryPrecisionReducer reducer( *gf );
-			GeomPtr rG0( reducer.reduce(*g0) );
-			GeomPtr rG1( reducer.reduce(*g1) );
+            precision::GeometryPrecisionReducer reducer(*gf);
+            GeomPtr rG0(reducer.reduce(*g0));
+            GeomPtr rG1(reducer.reduce(*g1));
 
 #if GEOS_DEBUG_BINARYOP
-			check_valid(*rG0, "PR: geom 0 (after precision reduction)");
-			check_valid(*rG1, "PR: geom 1 (after precision reduction)");
+            check_valid(*rG0, "PR: geom 0 (after precision reduction)");
+            check_valid(*rG1, "PR: geom 1 (after precision reduction)");
 #endif
 
-			try
-			{
-				ret.reset( _Op(rG0.get(), rG1.get()) );
-        // restore original precision (least precision between inputs)
-        if ( g0->getFactory()->getPrecisionModel()->compareTo( g1->getFactory()->getPrecisionModel() ) < 0 ) {
-          ret.reset( g0->getFactory()->createGeometry(ret.get()) );
-        }
-        else {
-          ret.reset( g1->getFactory()->createGeometry(ret.get()) );
-        }
+            try {
+                ret.reset(_Op(rG0.get(), rG1.get()));
+                // restore original precision (least precision between inputs)
+                if(g0->getFactory()->getPrecisionModel()->compareTo(g1->getFactory()->getPrecisionModel()) < 0) {
+                    ret.reset(g0->getFactory()->createGeometry(ret.get()));
+                }
+                else {
+                    ret.reset(g1->getFactory()->createGeometry(ret.get()));
+                }
 
 #if GEOS_CHECK_PRECISION_REDUCTION_VALIDITY
-				check_valid(*ret, "PR: result (after restore of original precision)", true);
+                check_valid(*ret, "PR: result (after restore of original precision)", true);
 #endif
 
 #if GEOS_DEBUG_BINARYOP
-				std::cerr << "Attempt with scale " << scale << " succeeded" << std::endl;
+                std::cerr << "Attempt with scale " << scale << " succeeded" << std::endl;
 #endif
-				return ret;
-			}
-			catch (const geos::util::TopologyException& ex)
-			{
+                return ret;
+            }
+            catch(const geos::util::TopologyException& ex) {
 #if GEOS_DEBUG_BINARYOP
-				std::cerr << "Reduced with scale (" << scale << "): "
-				          << ex.what() << std::endl;
+                std::cerr << "Reduced with scale (" << scale << "): "
+                          << ex.what() << std::endl;
 #endif
-				if ( scale == 1 ) throw ex;
-			}
+                if(scale == 1) {
+                    throw ex;
+                }
+            }
 
-		}
+        }
 
-	}
-	catch (const geos::util::TopologyException& ex)
-	{
+    }
+    catch(const geos::util::TopologyException& ex) {
 #if GEOS_DEBUG_BINARYOP
-		std::cerr << "Reduced: " << ex.what() << std::endl;
+        std::cerr << "Reduced: " << ex.what() << std::endl;
 #endif
-		::geos::ignore_unused_variable_warning(ex);
-	}
+        ::geos::ignore_unused_variable_warning(ex);
+    }
 
 #endif
 // USE_PRECISION_REDUCTION_POLICY }
@@ -561,64 +561,61 @@ BinaryOp(const Geometry* g0, const Geometry *g1, BinOp _Op)
 // {
 #if USE_TP_SIMPLIFY_POLICY
 
-	// Try simplifying
-	try
-	{
+    // Try simplifying
+    try {
 
-		double maxTolerance = 0.04;
-		double minTolerance = 0.01;
-		double tolStep = 0.01;
+        double maxTolerance = 0.04;
+        double minTolerance = 0.01;
+        double tolStep = 0.01;
 
-		for (double tol = minTolerance; tol <= maxTolerance; tol += tolStep)
-		{
+        for(double tol = minTolerance; tol <= maxTolerance; tol += tolStep) {
 #if GEOS_DEBUG_BINARYOP
-			std::cerr << "Trying simplifying with tolerance " << tol << std::endl;
+            std::cerr << "Trying simplifying with tolerance " << tol << std::endl;
 #endif
 
-			GeomPtr rG0( simplify::TopologyPreservingSimplifier::simplify(g0, tol) );
-			GeomPtr rG1( simplify::TopologyPreservingSimplifier::simplify(g1, tol) );
+            GeomPtr rG0(simplify::TopologyPreservingSimplifier::simplify(g0, tol));
+            GeomPtr rG1(simplify::TopologyPreservingSimplifier::simplify(g1, tol));
 
-			try
-			{
-				ret.reset( _Op(rG0.get(), rG1.get()) );
-				return ret;
-			}
-			catch (const geos::util::TopologyException& ex)
-			{
-				if ( tol >= maxTolerance ) throw ex;
+            try {
+                ret.reset(_Op(rG0.get(), rG1.get()));
+                return ret;
+            }
+            catch(const geos::util::TopologyException& ex) {
+                if(tol >= maxTolerance) {
+                    throw ex;
+                }
 #if GEOS_DEBUG_BINARYOP
-				std::cerr << "Simplified with tolerance (" << tol << "): "
-				          << ex.what() << std::endl;
+                std::cerr << "Simplified with tolerance (" << tol << "): "
+                          << ex.what() << std::endl;
 #endif
-			}
+            }
 
-		}
+        }
 
-		return ret;
+        return ret;
 
-	}
-	catch (const geos::util::TopologyException& ex)
-	{
+    }
+    catch(const geos::util::TopologyException& ex) {
 #if GEOS_DEBUG_BINARYOP
-		std::cerr << "Simplified: " << ex.what() << std::endl;
+        std::cerr << "Simplified: " << ex.what() << std::endl;
 #endif
-	}
+    }
 
 #endif
 // USE_TP_SIMPLIFY_POLICY }
 
 #if GEOS_DEBUG_BINARYOP
-	std::cerr << "No attempts worked to union " << std::endl;
-	std::cerr << "Input geometries:" << std::endl
-	          << "<A>" << std::endl
-					  << g0->toString() << std::endl
-						<< "</A>" << std::endl
-	          << "<B>" << std::endl
-					  << g1->toString() << std::endl
-						<< "</B>" << std::endl;
+    std::cerr << "No attempts worked to union " << std::endl;
+    std::cerr << "Input geometries:" << std::endl
+              << "<A>" << std::endl
+              << g0->toString() << std::endl
+              << "</A>" << std::endl
+              << "<B>" << std::endl
+              << g1->toString() << std::endl
+              << "</B>" << std::endl;
 #endif
 
-	throw origException;
+    throw origException;
 }
 
 
diff --git a/include/geos/geom/Coordinate.h b/include/geos/geom/Coordinate.h
index 945ab7b..fdd5bbb 100644
--- a/include/geos/geom/Coordinate.h
+++ b/include/geos/geom/Coordinate.h
@@ -61,79 +61,81 @@ class GEOS_DLL Coordinate {
 
 private:
 
-	static Coordinate _nullCoord;
+    static Coordinate _nullCoord;
 
 public:
-	/// A set of const Coordinate pointers
-	typedef std::set<const Coordinate *, CoordinateLessThen> ConstSet;
+    /// A set of const Coordinate pointers
+    typedef std::set<const Coordinate*, CoordinateLessThen> ConstSet;
 
-	/// A vector of const Coordinate pointers
-	typedef std::vector<const Coordinate *> ConstVect;
+    /// A vector of const Coordinate pointers
+    typedef std::vector<const Coordinate*> ConstVect;
 
-	/// A stack of const Coordinate pointers
-	typedef std::stack<const Coordinate *> ConstStack;
+    /// A stack of const Coordinate pointers
+    typedef std::stack<const Coordinate*> ConstStack;
 
-	/// A vector of Coordinate objects (real object, not pointers)
-	typedef std::vector<Coordinate> Vect;
+    /// A vector of Coordinate objects (real object, not pointers)
+    typedef std::vector<Coordinate> Vect;
 
-	/// x-coordinate
-	double x;
+    /// x-coordinate
+    double x;
 
-	/// y-coordinate
-	double y;
+    /// y-coordinate
+    double y;
 
-	/// z-coordinate
-	double z;
+    /// z-coordinate
+    double z;
 
-	void setNull();
+    void setNull();
 
-	static Coordinate& getNull();
+    static Coordinate& getNull();
 
-	bool isNull() const;
+    bool isNull() const;
 
-	Coordinate(double xNew=0.0, double yNew=0.0, double zNew=DoubleNotANumber);
+    Coordinate(double xNew = 0.0, double yNew = 0.0, double zNew = DoubleNotANumber);
 
-	bool equals2D(const Coordinate& other) const;
+    bool equals2D(const Coordinate& other) const;
 
-	/// 2D only
-	bool equals(const Coordinate& other) const;
+    /// 2D only
+    bool equals(const Coordinate& other) const;
 
-	/// TODO: deprecate this, move logic to CoordinateLessThen instead
-	int compareTo(const Coordinate& other) const;
+    /// TODO: deprecate this, move logic to CoordinateLessThen instead
+    int compareTo(const Coordinate& other) const;
 
-	/// 3D comparison
-	bool equals3D(const Coordinate& other) const;
+    /// 3D comparison
+    bool equals3D(const Coordinate& other) const;
 
-	///  Returns a string of the form <I>(x,y,z)</I> .
-	std::string toString() const;
+    ///  Returns a string of the form <I>(x,y,z)</I> .
+    std::string toString() const;
 
-	/// TODO: obsoleted this, can use PrecisionModel::makePrecise(Coordinate*)
-	/// instead
-	//void makePrecise(const PrecisionModel *pm);
+    /// TODO: obsoleted this, can use PrecisionModel::makePrecise(Coordinate*)
+    /// instead
+    //void makePrecise(const PrecisionModel *pm);
 
-	double distance(const Coordinate& p) const;
+    double distance(const Coordinate& p) const;
 
-	int hashCode() const;
+    int hashCode() const;
 
-	/**
-	 * Returns a hash code for a double value, using the algorithm from
-	 * Joshua Bloch's book <i>Effective Java</i>
-	 */
-	static int hashCode(double d);
+    /**
+     * Returns a hash code for a double value, using the algorithm from
+     * Joshua Bloch's book <i>Effective Java</i>
+     */
+    static int hashCode(double d);
 
 };
 
 /// Strict weak ordering Functor for Coordinate
 struct GEOS_DLL CoordinateLessThen {
 
-	bool operator()(const Coordinate* a, const Coordinate* b) const;
-	bool operator()(const Coordinate& a, const Coordinate& b) const;
+    bool operator()(const Coordinate* a, const Coordinate* b) const;
+    bool operator()(const Coordinate& a, const Coordinate& b) const;
 
 };
 
 /// Strict weak ordering operator for Coordinate
-inline bool operator<(const Coordinate& a, const Coordinate& b) {
-  return CoordinateLessThen()(a,b);
+inline bool
+operator<(const Coordinate& a, const Coordinate& b)
+{
+    return CoordinateLessThen()(a, b);
 }
 
 /// Output function
diff --git a/include/geos/geom/Coordinate.inl b/include/geos/geom/Coordinate.inl
index 46ea94d..49d2b96 100644
--- a/include/geos/geom/Coordinate.inl
+++ b/include/geos/geom/Coordinate.inl
@@ -27,106 +27,126 @@ namespace geom { // geos::geom
 INLINE void
 Coordinate::setNull()
 {
-	x=DoubleNotANumber;
-	y=DoubleNotANumber;
-	z=DoubleNotANumber;
+    x = DoubleNotANumber;
+    y = DoubleNotANumber;
+    z = DoubleNotANumber;
 }
 
 INLINE bool
 Coordinate::isNull() const
 {
-	return (std::isnan(x) && std::isnan(y) && std::isnan(z));
+    return (std::isnan(x) && std::isnan(y) && std::isnan(z));
 }
 
 INLINE
 Coordinate::Coordinate(double xNew, double yNew, double zNew)
-	:
-	x(xNew),
-	y(yNew),
-	z(zNew)
+    :
+    x(xNew),
+    y(yNew),
+    z(zNew)
 {}
 
 INLINE bool
 Coordinate::equals2D(const Coordinate& other) const
 {
-	if (x != other.x) return false;
-	if (y != other.y) return false;
-	return true;
+    if(x != other.x) {
+        return false;
+    }
+    if(y != other.y) {
+        return false;
+    }
+    return true;
 }
 
 INLINE bool
 Coordinate::equals(const Coordinate& other) const
 {
-	return equals2D(other);
+    return equals2D(other);
 }
 
 INLINE int
 Coordinate::compareTo(const Coordinate& other) const
 {
-	if (x < other.x) return -1;
-	if (x > other.x) return 1;
-	if (y < other.y) return -1;
-	if (y > other.y) return 1;
-	return 0;
+    if(x < other.x) {
+        return -1;
+    }
+    if(x > other.x) {
+        return 1;
+    }
+    if(y < other.y) {
+        return -1;
+    }
+    if(y > other.y) {
+        return 1;
+    }
+    return 0;
 }
 
 INLINE bool
 Coordinate::equals3D(const Coordinate& other) const
 {
-	return (x == other.x) && ( y == other.y) &&
-		((z == other.z)||(std::isnan(z) && std::isnan(other.z)));
+    return (x == other.x) && (y == other.y) &&
+           ((z == other.z) || (std::isnan(z) && std::isnan(other.z)));
 }
 
 INLINE double
 Coordinate::distance(const Coordinate& p) const
 {
-	double dx = x - p.x;
-	double dy = y - p.y;
-	return std::sqrt(dx * dx + dy * dy);
+    double dx = x - p.x;
+    double dy = y - p.y;
+    return std::sqrt(dx * dx + dy * dy);
 }
 
 INLINE int
 Coordinate::hashCode() const
 {
-	//Algorithm from Effective Java by Joshua Bloch [Jon Aquino]
-	int result = 17;
-	result = 37 * result + hashCode(x);
-	result = 37 * result + hashCode(y);
-	return result;
+    //Algorithm from Effective Java by Joshua Bloch [Jon Aquino]
+    int result = 17;
+    result = 37 * result + hashCode(x);
+    result = 37 * result + hashCode(y);
+    return result;
 }
 
 /*static*/
 INLINE int
 Coordinate::hashCode(double d)
 {
-	int64 f = (int64)(d);
-	return (int)(f^(f>>32));
+    int64 f = (int64)(d);
+    return (int)(f ^ (f >> 32));
 }
 
 INLINE bool
 CoordinateLessThen::operator()(const Coordinate* a, const Coordinate* b) const
 {
-	if (a->compareTo(*b)<0) return true;
-	else return false;
+    if(a->compareTo(*b) < 0) {
+        return true;
+    }
+    else {
+        return false;
+    }
 }
 
 INLINE bool
 CoordinateLessThen::operator()(const Coordinate& a, const Coordinate& b) const
 {
-	if (a.compareTo(b)<0) return true;
-	else return false;
+    if(a.compareTo(b) < 0) {
+        return true;
+    }
+    else {
+        return false;
+    }
 }
 
 INLINE bool
 operator==(const Coordinate& a, const Coordinate& b)
 {
-	return a.equals2D(b);
+    return a.equals2D(b);
 }
 
 INLINE bool
 operator!=(const Coordinate& a, const Coordinate& b)
 {
-	return ! a.equals2D(b);
+    return ! a.equals2D(b);
 }
 
 } // namespace geos::geom
diff --git a/include/geos/geom/CoordinateArraySequence.h b/include/geos/geom/CoordinateArraySequence.h
index c080b63..3834f93 100644
--- a/include/geos/geom/CoordinateArraySequence.h
+++ b/include/geos/geom/CoordinateArraySequence.h
@@ -24,9 +24,9 @@
 
 // Forward declarations
 namespace geos {
-	namespace geom {
-		class Coordinate;
-	}
+namespace geom {
+class Coordinate;
+}
 }
 
 
@@ -37,89 +37,101 @@ namespace geom { // geos.geom
 class GEOS_DLL CoordinateArraySequence : public CoordinateSequence {
 public:
 
-	CoordinateArraySequence(const CoordinateArraySequence &cl);
+    CoordinateArraySequence(const CoordinateArraySequence& cl);
 
-	CoordinateArraySequence(const CoordinateSequence &cl);
+    CoordinateArraySequence(const CoordinateSequence& cl);
 
-	CoordinateSequence *clone() const override;
+    CoordinateSequence* clone() const override;
 
-	//const Coordinate& getCoordinate(int pos) const;
-	const Coordinate& getAt(std::size_t pos) const override;
+    //const Coordinate& getCoordinate(int pos) const;
+    const Coordinate& getAt(std::size_t pos) const override;
 
-	/// Copy Coordinate at position i to Coordinate c
-	void getAt(std::size_t i, Coordinate& c) const override;
+    /// Copy Coordinate at position i to Coordinate c
+    void getAt(std::size_t i, Coordinate& c) const override;
 
-	//int size() const;
-	size_t getSize() const override;
+    //int size() const;
+    size_t getSize() const override;
 
-	// @deprecated
-	const std::vector<Coordinate>* toVector() const override;
+    // @deprecated
+    const std::vector<Coordinate>* toVector() const override;
 
-	// See dox in CoordinateSequence.h
-	void toVector(std::vector<Coordinate>&) const override;
+    // See dox in CoordinateSequence.h
+    void toVector(std::vector<Coordinate>&) const override;
 
-	/// Construct an empty sequence
-	CoordinateArraySequence();
+    /// Construct an empty sequence
+    CoordinateArraySequence();
 
-	/// Construct sequence taking ownership of given Coordinate vector
-	CoordinateArraySequence(std::vector<Coordinate> *coords,
-                                std::size_t dimension = 0);
+    /// Construct sequence taking ownership of given Coordinate vector
+    CoordinateArraySequence(std::vector<Coordinate>* coords,
+                            std::size_t dimension = 0);
 
-	/// Construct sequence allocating space for n coordinates
-	CoordinateArraySequence(std::size_t n, std::size_t dimension = 0);
+    /// Construct sequence allocating space for n coordinates
+    CoordinateArraySequence(std::size_t n, std::size_t dimension = 0);
 
-	~CoordinateArraySequence() override;
+    ~CoordinateArraySequence() override;
 
-	bool isEmpty() const override { return empty(); }
+    bool
+    isEmpty() const override
+    {
+        return empty();
+    }
 
-	bool empty() const { return vect->empty(); }
+    bool
+    empty() const
+    {
+        return vect->empty();
+    }
 
-	/// Reset this CoordinateArraySequence to the empty state
-	void clear() { vect->clear(); }
+    /// Reset this CoordinateArraySequence to the empty state
+    void
+    clear()
+    {
+        vect->clear();
+    }
 
-	void add(const Coordinate& c) override;
+    void add(const Coordinate& c) override;
 
-	void add(const Coordinate& c, bool allowRepeated) override;
+    void add(const Coordinate& c, bool allowRepeated) override;
 
-	/** \brief
-	 * Inserts the specified coordinate at the specified position in
-	 * this list.
-	 *
-	 * @param i the position at which to insert
-	 * @param coord the coordinate to insert
-	 * @param allowRepeated if set to false, repeated coordinates are
-	 *                      collapsed
-	 *
-	 * NOTE: this is a CoordinateList interface in JTS
-	 */
-	void add(std::size_t i, const Coordinate& coord, bool allowRepeated) override;
+    /** \brief
+     * Inserts the specified coordinate at the specified position in
+     * this list.
+     *
+     * @param i the position at which to insert
+     * @param coord the coordinate to insert
+     * @param allowRepeated if set to false, repeated coordinates are
+     *                      collapsed
+     *
+     * NOTE: this is a CoordinateList interface in JTS
+     */
+    void add(std::size_t i, const Coordinate& coord, bool allowRepeated) override;
 
-	void setAt(const Coordinate& c, std::size_t pos) override;
+    void setAt(const Coordinate& c, std::size_t pos) override;
 
-	void deleteAt(std::size_t pos) override;
+    void deleteAt(std::size_t pos) override;
 
-	std::string toString() const override;
+    std::string toString() const override;
 
-	void setPoints(const std::vector<Coordinate> &v) override;
+    void setPoints(const std::vector<Coordinate>& v) override;
 
-	double getOrdinate(std::size_t index,
-			size_t ordinateIndex) const override;
+    double getOrdinate(std::size_t index,
+                       size_t ordinateIndex) const override;
 
-	void setOrdinate(std::size_t index, std::size_t ordinateIndex,
-			double value) override;
+    void setOrdinate(std::size_t index, std::size_t ordinateIndex,
+                     double value) override;
 
-	void expandEnvelope(Envelope &env) const override;
+    void expandEnvelope(Envelope& env) const override;
 
     std::size_t getDimension() const override;
 
-	void apply_rw(const CoordinateFilter *filter) override;
+    void apply_rw(const CoordinateFilter* filter) override;
 
-	void apply_ro(CoordinateFilter *filter) const override;
+    void apply_ro(CoordinateFilter* filter) const override;
 
-	CoordinateSequence& removeRepeatedPoints() override;
+    CoordinateSequence& removeRepeatedPoints() override;
 
 private:
-	std::vector<Coordinate> *vect;
+    std::vector<Coordinate>* vect;
     mutable std::size_t dimension;
 };
 
diff --git a/include/geos/geom/CoordinateArraySequenceFactory.h b/include/geos/geom/CoordinateArraySequenceFactory.h
index 3519480..9bb3abb 100644
--- a/include/geos/geom/CoordinateArraySequenceFactory.h
+++ b/include/geos/geom/CoordinateArraySequenceFactory.h
@@ -25,9 +25,9 @@
 
 // Forward declarations
 namespace geos {
-	namespace geom {
-		class Coordinate;
-	}
+namespace geom {
+class Coordinate;
+}
 }
 
 namespace geos {
@@ -43,19 +43,19 @@ namespace geom { // geos::geom
 class GEOS_DLL CoordinateArraySequenceFactory: public CoordinateSequenceFactory {
 
 public:
-	CoordinateSequence *create() const override;
+    CoordinateSequence* create() const override;
 
-	CoordinateSequence *create(std::vector<Coordinate> *coords, std::size_t dims=0) const override;
+    CoordinateSequence* create(std::vector<Coordinate>* coords, std::size_t dims = 0) const override;
 
-   	/** @see CoordinateSequenceFactory::create(std::size_t, int) */
-	CoordinateSequence *create(std::size_t size, std::size_t dimension=0) const override;
+    /** @see CoordinateSequenceFactory::create(std::size_t, int) */
+    CoordinateSequence* create(std::size_t size, std::size_t dimension = 0) const override;
 
-	CoordinateSequence *create(const CoordinateSequence &coordSeq) const override;
+    CoordinateSequence* create(const CoordinateSequence& coordSeq) const override;
 
-	/** \brief
-	 * Returns the singleton instance of CoordinateArraySequenceFactory
-	 */
-	static const CoordinateSequenceFactory *instance();
+    /** \brief
+     * Returns the singleton instance of CoordinateArraySequenceFactory
+     */
+    static const CoordinateSequenceFactory* instance();
 };
 
 /// This is for backward API compatibility
diff --git a/include/geos/geom/CoordinateArraySequenceFactory.inl b/include/geos/geom/CoordinateArraySequenceFactory.inl
index 5ad0122..39bc0d6 100644
--- a/include/geos/geom/CoordinateArraySequenceFactory.inl
+++ b/include/geos/geom/CoordinateArraySequenceFactory.inl
@@ -7,7 +7,7 @@
  *
  * This is free software; you can redistribute and/or modify it under
  * the terms of the GNU Lesser General Public Licence as published
- * by the Free Software Foundation. 
+ * by the Free Software Foundation.
  * See the COPYING file for more information.
  *
  **********************************************************************/
@@ -22,32 +22,32 @@
 namespace geos {
 namespace geom { // geos::geom
 
-INLINE CoordinateSequence *
+INLINE CoordinateSequence*
 CoordinateArraySequenceFactory::create() const
 {
     return new CoordinateArraySequence(
-                reinterpret_cast<std::vector<Coordinate>*>(0), 0);
+               reinterpret_cast<std::vector<Coordinate>*>(0), 0);
 }
 
-INLINE CoordinateSequence *
-CoordinateArraySequenceFactory::create(std::vector<Coordinate> *coords,
-		size_t dimension ) const
+INLINE CoordinateSequence*
+CoordinateArraySequenceFactory::create(std::vector<Coordinate>* coords,
+                                       size_t dimension) const
 {
-	return new CoordinateArraySequence(coords,dimension);
+    return new CoordinateArraySequence(coords, dimension);
 }
 
-INLINE CoordinateSequence *
+INLINE CoordinateSequence*
 CoordinateArraySequenceFactory::create(std::size_t size, std::size_t dimension)
-		const
+const
 {
-	return new CoordinateArraySequence(size,dimension);
+    return new CoordinateArraySequence(size, dimension);
 }
 
-INLINE CoordinateSequence *
+INLINE CoordinateSequence*
 CoordinateArraySequenceFactory::create(const CoordinateSequence& seq)
-		const
+const
 {
-	return new CoordinateArraySequence(seq);
+    return new CoordinateArraySequence(seq);
 }
 
 
diff --git a/include/geos/geom/CoordinateFilter.h b/include/geos/geom/CoordinateFilter.h
index a8b563c..9ea063b 100644
--- a/include/geos/geom/CoordinateFilter.h
+++ b/include/geos/geom/CoordinateFilter.h
@@ -42,21 +42,30 @@ class Coordinate;
  */
 class GEOS_DLL CoordinateFilter {
 public:
-   virtual ~CoordinateFilter() {}
+    virtual
+    ~CoordinateFilter() {}
 
-   /**
-    * Performs an operation on <code>coord</code>.
-    *
-    * @param  coord  a <code>Coordinate</code> to which the filter is applied.
-    */
-   virtual void filter_rw(Coordinate* /*coord*/) const { assert(0); }
+    /**
+     * Performs an operation on <code>coord</code>.
+     *
+     * @param  coord  a <code>Coordinate</code> to which the filter is applied.
+     */
+    virtual void
+    filter_rw(Coordinate* /*coord*/) const
+    {
+        assert(0);
+    }
 
-   /**
-    * Performs an operation with <code>coord</code>.
-    *
-    * @param  coord  a <code>Coordinate</code> to which the filter is applied.
-    */
-   virtual void filter_ro(const Coordinate* /*coord*/) { assert(0); }
+    /**
+     * Performs an operation with <code>coord</code>.
+     *
+     * @param  coord  a <code>Coordinate</code> to which the filter is applied.
+     */
+    virtual void
+    filter_ro(const Coordinate* /*coord*/)
+    {
+        assert(0);
+    }
 };
 
 } // namespace geos::geom
diff --git a/include/geos/geom/CoordinateList.h b/include/geos/geom/CoordinateList.h
index b478afb..bb2efc7 100644
--- a/include/geos/geom/CoordinateList.h
+++ b/include/geos/geom/CoordinateList.h
@@ -34,9 +34,9 @@
 
 // Forward declarations
 namespace geos {
-	namespace geom {
-		//class Coordinate;
-	}
+namespace geom {
+//class Coordinate;
+}
 }
 
 
@@ -56,137 +56,153 @@ class GEOS_DLL CoordinateList {
 
 public:
 
-	typedef std::list<Coordinate>::iterator iterator;
-	typedef std::list<Coordinate>::const_iterator const_iterator;
-
-	friend std::ostream& operator<< (std::ostream& os,
-		const CoordinateList& cl);
-
-	/** \brief
-	 * Constructs a new list from an array of Coordinates, allowing
-	 * repeated points.
-	 *
-	 * (I.e. this constructor produces a {@link CoordinateList} with
-	 * exactly the same set of points as the input array.)
-	 *
-	 * @param v the initial coordinates
-	 */
-	CoordinateList(const std::vector<Coordinate>& v)
-		:
-		coords(v.begin(), v.end())
-	{
-	}
-
-	CoordinateList()
-		:
-		coords()
-	{
-	}
-
-	size_t size() const
-	{
-		return coords.size();
-	}
-
-	bool empty() const
-	{
-		return coords.empty();
-	}
-
-	iterator begin()
-	{
-		return coords.begin();
-	}
-
-	iterator end()
-	{
-		return coords.end();
-	}
-
-	const_iterator begin() const
-	{
-		return coords.begin();
-	}
-
-	const_iterator end() const
-	{
-		return coords.end();
-	}
-
-	/** \brief
-	 * Inserts the specified coordinate at the specified position in this list.
-	 *
-	 * @param pos the position at which to insert
-	 * @param coord the coordinate to insert
-	 * @param allowRepeated if set to false, repeated coordinates are collapsed
-	 *
-	 * @return an iterator to the newly installed coordinate
-	 *         (or previous, if equal and repeated are not allowed)
-	 *
-	 * NOTE: when allowRepeated is false _next_ point is not checked
-	 *       this matches JTS behavior
-	 */
-	iterator insert(iterator pos, const Coordinate& c, bool allowRepeated)
-	{
-		if ( !allowRepeated && pos != coords.begin() ) {
-			iterator prev = pos; --prev;
-			if ( c.equals2D(*prev) ) return prev;
-		}
-		return coords.insert(pos, c);
-	}
-
-	iterator insert(iterator pos, const Coordinate& c)
-	{
-		return coords.insert(pos, c);
-	}
-
-	iterator erase(iterator pos)
-	{
-		return coords.erase(pos);
-	}
-
-	iterator erase(iterator first, iterator last)
-	{
-		return coords.erase(first, last);
-	}
-
-	std::unique_ptr<Coordinate::Vect> toCoordinateArray() const
-	{
-		std::unique_ptr<Coordinate::Vect> ret(new Coordinate::Vect);
-		ret->assign(coords.begin(), coords.end());
-		return ret;
-	}
-	void closeRing()
-	{
-		if(!coords.empty() && ! (*(coords.begin())).equals(*(coords.rbegin())))
-		{
-			const Coordinate &c = *(coords.begin());
-			coords.insert(coords.end(),c);
-		}
-	}
+    typedef std::list<Coordinate>::iterator iterator;
+    typedef std::list<Coordinate>::const_iterator const_iterator;
+
+    friend std::ostream& operator<< (std::ostream& os,
+                                     const CoordinateList& cl);
+
+    /** \brief
+     * Constructs a new list from an array of Coordinates, allowing
+     * repeated points.
+     *
+     * (I.e. this constructor produces a {@link CoordinateList} with
+     * exactly the same set of points as the input array.)
+     *
+     * @param v the initial coordinates
+     */
+    CoordinateList(const std::vector<Coordinate>& v)
+        :
+        coords(v.begin(), v.end())
+    {
+    }
+
+    CoordinateList()
+        :
+        coords()
+    {
+    }
+
+    size_t
+    size() const
+    {
+        return coords.size();
+    }
+
+    bool
+    empty() const
+    {
+        return coords.empty();
+    }
+
+    iterator
+    begin()
+    {
+        return coords.begin();
+    }
+
+    iterator
+    end()
+    {
+        return coords.end();
+    }
+
+    const_iterator
+    begin() const
+    {
+        return coords.begin();
+    }
+
+    const_iterator
+    end() const
+    {
+        return coords.end();
+    }
+
+    /** \brief
+     * Inserts the specified coordinate at the specified position in this list.
+     *
+     * @param pos the position at which to insert
+     * @param coord the coordinate to insert
+     * @param allowRepeated if set to false, repeated coordinates are collapsed
+     *
+     * @return an iterator to the newly installed coordinate
+     *         (or previous, if equal and repeated are not allowed)
+     *
+     * NOTE: when allowRepeated is false _next_ point is not checked
+     *       this matches JTS behavior
+     */
+    iterator
+    insert(iterator pos, const Coordinate& c, bool allowRepeated)
+    {
+        if(!allowRepeated && pos != coords.begin()) {
+            iterator prev = pos;
+            --prev;
+            if(c.equals2D(*prev)) {
+                return prev;
+            }
+        }
+        return coords.insert(pos, c);
+    }
+
+    iterator
+    insert(iterator pos, const Coordinate& c)
+    {
+        return coords.insert(pos, c);
+    }
+
+    iterator
+    erase(iterator pos)
+    {
+        return coords.erase(pos);
+    }
+
+    iterator
+    erase(iterator first, iterator last)
+    {
+        return coords.erase(first, last);
+    }
+
+    std::unique_ptr<Coordinate::Vect>
+    toCoordinateArray() const
+    {
+        std::unique_ptr<Coordinate::Vect> ret(new Coordinate::Vect);
+        ret->assign(coords.begin(), coords.end());
+        return ret;
+    }
+    void
+    closeRing()
+    {
+        if(!coords.empty() && !(*(coords.begin())).equals(*(coords.rbegin()))) {
+            const Coordinate& c = *(coords.begin());
+            coords.insert(coords.end(), c);
+        }
+    }
 
 
 private:
 
-	std::list<Coordinate> coords;
+    std::list<Coordinate> coords;
 };
 
 inline
-std::ostream& operator<< (std::ostream& os, const CoordinateList& cl)
+std::ostream&
+operator<< (std::ostream& os, const CoordinateList& cl)
 {
-	os << "(";
-	for (CoordinateList::const_iterator
-		it=cl.begin(), end=cl.end();
-		it != end;
-		++it)
-	{
-		const Coordinate& c = *it;
-		if ( it != cl.begin() ) os << ", ";
-		os << c;
-	}
-	os << ")";
-
-	return os;
+    os << "(";
+    for(CoordinateList::const_iterator
+            it = cl.begin(), end = cl.end();
+            it != end;
+            ++it) {
+        const Coordinate& c = *it;
+        if(it != cl.begin()) {
+            os << ", ";
+        }
+        os << c;
+    }
+    os << ")";
+
+    return os;
 }
 
 } // namespace geos::geom
diff --git a/include/geos/geom/CoordinateSequence.h b/include/geos/geom/CoordinateSequence.h
index 30e5491..54654d8 100644
--- a/include/geos/geom/CoordinateSequence.h
+++ b/include/geos/geom/CoordinateSequence.h
@@ -26,11 +26,11 @@
 
 // Forward declarations
 namespace geos {
-	namespace geom {
-		class Envelope;
-		class CoordinateFilter;
-		class Coordinate;
-	}
+namespace geom {
+class Envelope;
+class CoordinateFilter;
+class Coordinate;
+}
 }
 
 namespace geos {
@@ -59,325 +59,344 @@ class GEOS_DLL CoordinateSequence {
 
 protected:
 
-	CoordinateSequence() {}
+    CoordinateSequence() {}
 
-	CoordinateSequence(const CoordinateSequence&) {}
+    CoordinateSequence(const CoordinateSequence&) {}
 
 public:
 
-	typedef std::unique_ptr<CoordinateSequence> Ptr;
-
-	virtual ~CoordinateSequence() {}
-
-	/** \brief
-	 * Returns a deep copy of this collection.
-	 */
-	virtual CoordinateSequence *clone() const=0;
-
-	/** \brief
-	 * Returns a read-only reference to Coordinate at position i.
-	 *
-	 * Whether or not the Coordinate returned is the actual underlying
-	 * Coordinate or merely a copy depends on the implementation.
-	 */
-	//virtual const Coordinate& getCoordinate(int i) const=0;
-	virtual const Coordinate& getAt(std::size_t i) const=0;
-
-	/// Return last Coordinate in the sequence
-	const Coordinate& back() const {
-		return getAt(size()-1);
-	}
-
-	/// Return first Coordinate in the sequence
-	const Coordinate& front() const {
-		return getAt(0);
-	}
-
-	const Coordinate& operator[] (std::size_t i) const {
-		return getAt(i);
-	}
-
-	/** \brief
-	 * Write Coordinate at position i to given Coordinate.
-	 */
-	virtual void getAt(std::size_t i, Coordinate& c) const=0;
-
-	/** \brief
-	 * Returns the number of Coordinates (actual or otherwise, as
-	 * this implementation may not store its data in Coordinate objects).
-	 */
-	//virtual int size() const=0;
-	virtual std::size_t getSize() const=0;
-
-	size_t size() const { return getSize(); }
-
-	/** \brief
-	 * Returns a read-only vector with the Coordinates in this collection.
-	 *
-	 * Whether or not the Coordinates returned are the actual underlying
-	 * Coordinates or merely copies depends on the implementation.
-	 * Note that if this implementation does not store its data as an
-	 * array of Coordinates, this method will incur a performance penalty
-	 * because the array needs to be built from scratch.
-	 *
-	 * This method is a port of the toCoordinateArray() method of JTS.
-	 * It is not much used as memory management requires us to
-	 * know wheter we should or not delete the returned object
-	 * in a consistent way. Our options are: use shared_ptr<Coordinate>
-	 * or always keep ownerhips of an eventual newly created vector.
-	 * We opted for the second, so the returned object is a const, to
-	 * also ensure that returning an internal pointer doesn't make
-	 * the object mutable.
-	 *
-	 * @deprecated use toVector(std::vector<Coordinate>&) instead
-	 */
-	virtual	const std::vector<Coordinate>* toVector() const=0;
-
-	/// Pushes all Coordinates of this sequence onto the provided vector.
-	//
-	/// This method is a port of the toCoordinateArray() method of JTS.
-	///
-	virtual	void toVector(std::vector<Coordinate>& coords) const=0;
-
-	/**
-	 * \brief Add an array of coordinates
-	 * @param vc The coordinates
-	 * @param allowRepeated if set to false, repeated coordinates
-	 * 	are collapsed
-	 * @return true (as by general collection contract)
-	 */
-	void add(const std::vector<Coordinate>* vc, bool allowRepeated);
-
-	/* This is here for backward compatibility.. */
-	//void add(CoordinateSequence *cl,bool allowRepeated,bool direction);
-
-	/** \brief
-	 *  Add an array of coordinates
-	 *
-	 *  @param cl The coordinates
-	 *
-	 *  @param allowRepeated
-	 * 	if set to false, repeated coordinates are collapsed
-	 *
-	 *  @param direction if false, the array is added in reverse order
-	 *
-	 *  @return true (as by general collection contract)
-	 */
-	void add(const CoordinateSequence *cl, bool allowRepeated,
-			bool direction);
-
-	/**
-	 * \brief Add a coordinate
-	 * @param c The coordinate to add
-	 * @param allowRepeated if set to false, repeated coordinates
-	 * are collapsed
-	 * @return true (as by general collection contract)
-	 */
-	virtual void add(const Coordinate& c, bool allowRepeated);
-
-	/** \brief
-	 * Inserts the specified coordinate at the specified position in
-	 * this list.
-	 *
-	 * @param i the position at which to insert
-	 * @param coord the coordinate to insert
-	 * @param allowRepeated if set to false, repeated coordinates are
-	 *                      collapsed
-	 *
-	 * NOTE: this is a CoordinateList interface in JTS
-	 */
-	virtual void add(std::size_t i, const Coordinate& coord, bool allowRepeated)=0;
-
-	/// Returns <code>true</code> it list contains no coordinates.
-	virtual	bool isEmpty() const=0;
-
-	/// Add a Coordinate to the list
-	virtual	void add(const Coordinate& c)=0;
-
-	// Get number of coordinates
-	//virtual int getSize() const=0;
-
-	/// Get a reference to Coordinate at position pos
-	//virtual	const Coordinate& getAt(std::size_t pos) const=0;
-
-	/// Copy Coordinate c to position pos
-	virtual	void setAt(const Coordinate& c, std::size_t pos)=0;
-
-	/// Delete Coordinate at position pos (list will shrink).
-	virtual	void deleteAt(std::size_t pos)=0;
-
-	/// Get a string rapresentation of CoordinateSequence
-	virtual	std::string toString() const=0;
-
-	/// Substitute Coordinate list with a copy of the given vector
-	virtual	void setPoints(const std::vector<Coordinate> &v)=0;
-
-	/// Returns true if contains any two consecutive points
-	bool hasRepeatedPoints() const;
-
-	/// Returns lower-left Coordinate in list
-	const Coordinate* minCoordinate() const;
-
-
-	/// \brief
-	/// Returns a new CoordinateSequence being a copy of the input
-	/// with any consecutive equal Coordinate removed.
-	///
-	/// Equality test is 2D based
-	///
-	/// Ownership of returned object goes to the caller.
-	///
-	static CoordinateSequence* removeRepeatedPoints(
-			const CoordinateSequence *cl);
-
-	/// Remove consecutive equal Coordinates from the sequence
-	//
-	/// Equality test is 2D based. Returns a reference to self.
-	///
-	virtual CoordinateSequence& removeRepeatedPoints()=0;
-
-	/** \brief
-	 *  Returns true if given CoordinateSequence contains
-	 *  any two consecutive Coordinate
-	 */
-	static bool hasRepeatedPoints(const CoordinateSequence *cl);
-
-	/** \brief
-	 *  Returns either the given CoordinateSequence if its length
-	 *  is greater than the given amount, or an empty CoordinateSequence.
-	 */
-	static CoordinateSequence* atLeastNCoordinatesOrNothing(std::size_t n,
-			CoordinateSequence *c);
-
-	/** \brief
-	 *  Returns lower-left Coordinate in given CoordinateSequence.
-	 *  This is actually the Coordinate with lower X (and Y if needed)
-	 *  ordinate.
-	 */
-	static const Coordinate* minCoordinate(CoordinateSequence *cl);
-
-	/// Return position of a Coordinate, or -1 if not found
-	//
-	/// FIXME: return std::size_t, using numeric_limits<std::size_t>::max
-	/// as 'not found' value.
-	///
-	static size_t indexOf(const Coordinate *coordinate,
-			const CoordinateSequence *cl);
-
-	/**
-	 * \brief
-	 * Returns true if the two arrays are identical, both null,
-	 * or pointwise equal
-	 */
-	static bool equals(const CoordinateSequence *cl1,
-			const CoordinateSequence *cl2);
-
-	/// Scroll given CoordinateSequence so to start with given Coordinate.
-	static void scroll(CoordinateSequence *cl, const Coordinate *firstCoordinate);
-
-	/** \brief
-	 * Determines which orientation of the {@link Coordinate} array
-	 * is (overall) increasing.
-	 *
-	 * In other words, determines which end of the array is "smaller"
-	 * (using the standard ordering on {@link Coordinate}).
-	 * Returns an integer indicating the increasing direction.
-	 * If the sequence is a palindrome, it is defined to be
-	 * oriented in a positive direction.
-	 *
-	 * @param pts the array of Coordinates to test
-	 * @return <code>1</code> if the array is smaller at the start
-	 * or is a palindrome,
-	 * <code>-1</code> if smaller at the end
-	 *
-	 * NOTE: this method is found in CoordinateArrays class for JTS
-	 */
-	static int increasingDirection(const CoordinateSequence& pts);
-
-	/// Reverse Coordinate order in given CoordinateSequence
-	static void reverse(CoordinateSequence *cl);
-
-	/// Standard ordinate index values
-	enum { X,Y,Z,M };
-
-	/**
-	 * Returns the dimension (number of ordinates in each coordinate)
-	 * for this sequence.
-	 *
-	 * @return the dimension of the sequence.
-	 */
-	virtual std::size_t getDimension() const=0;
-
-	/**
-	 * Returns the ordinate of a coordinate in this sequence.
-	 * Ordinate indices 0 and 1 are assumed to be X and Y.
-	 * Ordinates indices greater than 1 have user-defined semantics
-	 * (for instance, they may contain other dimensions or measure values).
-	 *
-	 * @param index  the coordinate index in the sequence
-	 * @param ordinateIndex the ordinate index in the coordinate
-	 * 	   (in range [0, dimension-1])
-	 */
-	virtual double getOrdinate(std::size_t index, std::size_t ordinateIndex) const=0;
-
-	/**
-	 * Returns ordinate X (0) of the specified coordinate.
-	 *
-	 * @param index
-	 * @return the value of the X ordinate in the index'th coordinate
-	 */
-	virtual double getX(std::size_t index) const { return getOrdinate(index, X); }
-
-	/**
-	 * Returns ordinate Y (1) of the specified coordinate.
-	 *
-	 * @param index
-	 * @return the value of the Y ordinate in the index'th coordinate
-	 */
-	virtual double getY(std::size_t index) const { return getOrdinate(index, Y); }
-
-
-	/**
-	 * Sets the value for a given ordinate of a coordinate in this sequence.
-	 *
-	 * @param index  the coordinate index in the sequence
-	 * @param ordinateIndex the ordinate index in the coordinate
-	 * 		(in range [0, dimension-1])
-	 * @param value  the new ordinate value
-	 */
-	virtual void setOrdinate(std::size_t index, std::size_t ordinateIndex, double value)=0;
-
-	/**
-	 * Expands the given Envelope to include the coordinates in the
-	 * sequence.
-	 * Allows implementing classes to optimize access to coordinate values.
-	 *
-	 * @param env the envelope to expand
-	 */
-	virtual void expandEnvelope(Envelope &env) const;
-
-	virtual void apply_rw(const CoordinateFilter *filter)=0; //Abstract
-	virtual void apply_ro(CoordinateFilter *filter) const=0; //Abstract
-
-	/** \brief
-	 * Apply a fiter to each Coordinate of this sequence.
-	 * The filter is expected to provide a .filter(Coordinate&)
-	 * method.
-	 *
-	 * TODO: accept a Functor instead, will be more flexible.
-	 *       actually, define iterators on Geometry
-	 */
-	template <class T>
-	void applyCoordinateFilter(T& f)
-	{
-		Coordinate c;
-		for(std::size_t i=0, n=size(); i<n; ++i)
-		{
-			getAt(i, c);
-			f.filter(c);
-			setAt(c, i);
-		}
-	}
+    typedef std::unique_ptr<CoordinateSequence> Ptr;
+
+    virtual
+    ~CoordinateSequence() {}
+
+    /** \brief
+     * Returns a deep copy of this collection.
+     */
+    virtual CoordinateSequence* clone() const = 0;
+
+    /** \brief
+     * Returns a read-only reference to Coordinate at position i.
+     *
+     * Whether or not the Coordinate returned is the actual underlying
+     * Coordinate or merely a copy depends on the implementation.
+     */
+    //virtual const Coordinate& getCoordinate(int i) const=0;
+    virtual const Coordinate& getAt(std::size_t i) const = 0;
+
+    /// Return last Coordinate in the sequence
+    const Coordinate&
+    back() const
+    {
+        return getAt(size() - 1);
+    }
+
+    /// Return first Coordinate in the sequence
+    const Coordinate&
+    front() const
+    {
+        return getAt(0);
+    }
+
+    const Coordinate&
+    operator[](std::size_t i) const
+    {
+        return getAt(i);
+    }
+
+    /** \brief
+     * Write Coordinate at position i to given Coordinate.
+     */
+    virtual void getAt(std::size_t i, Coordinate& c) const = 0;
+
+    /** \brief
+     * Returns the number of Coordinates (actual or otherwise, as
+     * this implementation may not store its data in Coordinate objects).
+     */
+    //virtual int size() const=0;
+    virtual std::size_t getSize() const = 0;
+
+    size_t
+    size() const
+    {
+        return getSize();
+    }
+
+    /** \brief
+     * Returns a read-only vector with the Coordinates in this collection.
+     *
+     * Whether or not the Coordinates returned are the actual underlying
+     * Coordinates or merely copies depends on the implementation.
+     * Note that if this implementation does not store its data as an
+     * array of Coordinates, this method will incur a performance penalty
+     * because the array needs to be built from scratch.
+     *
+     * This method is a port of the toCoordinateArray() method of JTS.
+     * It is not much used as memory management requires us to
+     * know wheter we should or not delete the returned object
+     * in a consistent way. Our options are: use shared_ptr<Coordinate>
+     * or always keep ownerhips of an eventual newly created vector.
+     * We opted for the second, so the returned object is a const, to
+     * also ensure that returning an internal pointer doesn't make
+     * the object mutable.
+     *
+     * @deprecated use toVector(std::vector<Coordinate>&) instead
+     */
+    virtual	const std::vector<Coordinate>* toVector() const = 0;
+
+    /// Pushes all Coordinates of this sequence onto the provided vector.
+    //
+    /// This method is a port of the toCoordinateArray() method of JTS.
+    ///
+    virtual	void toVector(std::vector<Coordinate>& coords) const = 0;
+
+    /**
+     * \brief Add an array of coordinates
+     * @param vc The coordinates
+     * @param allowRepeated if set to false, repeated coordinates
+     * 	are collapsed
+     * @return true (as by general collection contract)
+     */
+    void add(const std::vector<Coordinate>* vc, bool allowRepeated);
+
+    /* This is here for backward compatibility.. */
+    //void add(CoordinateSequence *cl,bool allowRepeated,bool direction);
+
+    /** \brief
+     *  Add an array of coordinates
+     *
+     *  @param cl The coordinates
+     *
+     *  @param allowRepeated
+     * 	if set to false, repeated coordinates are collapsed
+     *
+     *  @param direction if false, the array is added in reverse order
+     *
+     *  @return true (as by general collection contract)
+     */
+    void add(const CoordinateSequence* cl, bool allowRepeated,
+             bool direction);
+
+    /**
+     * \brief Add a coordinate
+     * @param c The coordinate to add
+     * @param allowRepeated if set to false, repeated coordinates
+     * are collapsed
+     * @return true (as by general collection contract)
+     */
+    virtual void add(const Coordinate& c, bool allowRepeated);
+
+    /** \brief
+     * Inserts the specified coordinate at the specified position in
+     * this list.
+     *
+     * @param i the position at which to insert
+     * @param coord the coordinate to insert
+     * @param allowRepeated if set to false, repeated coordinates are
+     *                      collapsed
+     *
+     * NOTE: this is a CoordinateList interface in JTS
+     */
+    virtual void add(std::size_t i, const Coordinate& coord, bool allowRepeated) = 0;
+
+    /// Returns <code>true</code> it list contains no coordinates.
+    virtual	bool isEmpty() const = 0;
+
+    /// Add a Coordinate to the list
+    virtual	void add(const Coordinate& c) = 0;
+
+    // Get number of coordinates
+    //virtual int getSize() const=0;
+
+    /// Get a reference to Coordinate at position pos
+    //virtual	const Coordinate& getAt(std::size_t pos) const=0;
+
+    /// Copy Coordinate c to position pos
+    virtual	void setAt(const Coordinate& c, std::size_t pos) = 0;
+
+    /// Delete Coordinate at position pos (list will shrink).
+    virtual	void deleteAt(std::size_t pos) = 0;
+
+    /// Get a string rapresentation of CoordinateSequence
+    virtual	std::string toString() const = 0;
+
+    /// Substitute Coordinate list with a copy of the given vector
+    virtual	void setPoints(const std::vector<Coordinate>& v) = 0;
+
+    /// Returns true if contains any two consecutive points
+    bool hasRepeatedPoints() const;
+
+    /// Returns lower-left Coordinate in list
+    const Coordinate* minCoordinate() const;
+
+
+    /// \brief
+    /// Returns a new CoordinateSequence being a copy of the input
+    /// with any consecutive equal Coordinate removed.
+    ///
+    /// Equality test is 2D based
+    ///
+    /// Ownership of returned object goes to the caller.
+    ///
+    static CoordinateSequence* removeRepeatedPoints(
+        const CoordinateSequence* cl);
+
+    /// Remove consecutive equal Coordinates from the sequence
+    //
+    /// Equality test is 2D based. Returns a reference to self.
+    ///
+    virtual CoordinateSequence& removeRepeatedPoints() = 0;
+
+    /** \brief
+     *  Returns true if given CoordinateSequence contains
+     *  any two consecutive Coordinate
+     */
+    static bool hasRepeatedPoints(const CoordinateSequence* cl);
+
+    /** \brief
+     *  Returns either the given CoordinateSequence if its length
+     *  is greater than the given amount, or an empty CoordinateSequence.
+     */
+    static CoordinateSequence* atLeastNCoordinatesOrNothing(std::size_t n,
+            CoordinateSequence* c);
+
+    /** \brief
+     *  Returns lower-left Coordinate in given CoordinateSequence.
+     *  This is actually the Coordinate with lower X (and Y if needed)
+     *  ordinate.
+     */
+    static const Coordinate* minCoordinate(CoordinateSequence* cl);
+
+    /// Return position of a Coordinate, or -1 if not found
+    //
+    /// FIXME: return std::size_t, using numeric_limits<std::size_t>::max
+    /// as 'not found' value.
+    ///
+    static size_t indexOf(const Coordinate* coordinate,
+                          const CoordinateSequence* cl);
+
+    /**
+     * \brief
+     * Returns true if the two arrays are identical, both null,
+     * or pointwise equal
+     */
+    static bool equals(const CoordinateSequence* cl1,
+                       const CoordinateSequence* cl2);
+
+    /// Scroll given CoordinateSequence so to start with given Coordinate.
+    static void scroll(CoordinateSequence* cl, const Coordinate* firstCoordinate);
+
+    /** \brief
+     * Determines which orientation of the {@link Coordinate} array
+     * is (overall) increasing.
+     *
+     * In other words, determines which end of the array is "smaller"
+     * (using the standard ordering on {@link Coordinate}).
+     * Returns an integer indicating the increasing direction.
+     * If the sequence is a palindrome, it is defined to be
+     * oriented in a positive direction.
+     *
+     * @param pts the array of Coordinates to test
+     * @return <code>1</code> if the array is smaller at the start
+     * or is a palindrome,
+     * <code>-1</code> if smaller at the end
+     *
+     * NOTE: this method is found in CoordinateArrays class for JTS
+     */
+    static int increasingDirection(const CoordinateSequence& pts);
+
+    /// Reverse Coordinate order in given CoordinateSequence
+    static void reverse(CoordinateSequence* cl);
+
+    /// Standard ordinate index values
+    enum { X, Y, Z, M };
+
+    /**
+     * Returns the dimension (number of ordinates in each coordinate)
+     * for this sequence.
+     *
+     * @return the dimension of the sequence.
+     */
+    virtual std::size_t getDimension() const = 0;
+
+    /**
+     * Returns the ordinate of a coordinate in this sequence.
+     * Ordinate indices 0 and 1 are assumed to be X and Y.
+     * Ordinates indices greater than 1 have user-defined semantics
+     * (for instance, they may contain other dimensions or measure values).
+     *
+     * @param index  the coordinate index in the sequence
+     * @param ordinateIndex the ordinate index in the coordinate
+     * 	   (in range [0, dimension-1])
+     */
+    virtual double getOrdinate(std::size_t index, std::size_t ordinateIndex) const = 0;
+
+    /**
+     * Returns ordinate X (0) of the specified coordinate.
+     *
+     * @param index
+     * @return the value of the X ordinate in the index'th coordinate
+     */
+    virtual double
+    getX(std::size_t index) const
+    {
+        return getOrdinate(index, X);
+    }
+
+    /**
+     * Returns ordinate Y (1) of the specified coordinate.
+     *
+     * @param index
+     * @return the value of the Y ordinate in the index'th coordinate
+     */
+    virtual double
+    getY(std::size_t index) const
+    {
+        return getOrdinate(index, Y);
+    }
+
+
+    /**
+     * Sets the value for a given ordinate of a coordinate in this sequence.
+     *
+     * @param index  the coordinate index in the sequence
+     * @param ordinateIndex the ordinate index in the coordinate
+     * 		(in range [0, dimension-1])
+     * @param value  the new ordinate value
+     */
+    virtual void setOrdinate(std::size_t index, std::size_t ordinateIndex, double value) = 0;
+
+    /**
+     * Expands the given Envelope to include the coordinates in the
+     * sequence.
+     * Allows implementing classes to optimize access to coordinate values.
+     *
+     * @param env the envelope to expand
+     */
+    virtual void expandEnvelope(Envelope& env) const;
+
+    virtual void apply_rw(const CoordinateFilter* filter) = 0; //Abstract
+    virtual void apply_ro(CoordinateFilter* filter) const = 0; //Abstract
+
+    /** \brief
+     * Apply a fiter to each Coordinate of this sequence.
+     * The filter is expected to provide a .filter(Coordinate&)
+     * method.
+     *
+     * TODO: accept a Functor instead, will be more flexible.
+     *       actually, define iterators on Geometry
+     */
+    template <class T>
+    void
+    applyCoordinateFilter(T& f)
+    {
+        Coordinate c;
+        for(std::size_t i = 0, n = size(); i < n; ++i) {
+            getAt(i, c);
+            f.filter(c);
+            setAt(c, i);
+        }
+    }
 
 };
 
diff --git a/include/geos/geom/CoordinateSequenceFactory.h b/include/geos/geom/CoordinateSequenceFactory.h
index 85b5e5b..273e6a8 100644
--- a/include/geos/geom/CoordinateSequenceFactory.h
+++ b/include/geos/geom/CoordinateSequenceFactory.h
@@ -28,10 +28,10 @@
 
 // Forward declarations
 namespace geos {
-	namespace geom {
-		class CoordinateSequence;
-		class Coordinate;
-	}
+namespace geom {
+class CoordinateSequence;
+class Coordinate;
+}
 }
 
 namespace geos {
@@ -47,54 +47,54 @@ namespace geom { // geos::geom
 class GEOS_DLL CoordinateSequenceFactory {
 public:
 
-	/** \brief
-	 * Returns an empty CoordinateSequence, the dimensions will be autodetected
-	 * when it is populated.
-	 */
-	virtual CoordinateSequence *create() const=0;
+    /** \brief
+     * Returns an empty CoordinateSequence, the dimensions will be autodetected
+     * when it is populated.
+     */
+    virtual CoordinateSequence* create() const = 0;
 
-	/** \brief
-	 * Returns a CoordinateSequence based on the given array.
-	 *
-	 * Whether the array is copied or simply referenced
-	 * is implementation-dependent.
-	 * For this reason caller does give up ownership of it.
-	 * Implementations that will not copy it will need take care
-	 * of deleting it.
-	 *
-	 * This method must handle null arguments by creating
-	 * an empty sequence.
-	 *
-	 * @param coordinates the coordinates
+    /** \brief
+     * Returns a CoordinateSequence based on the given array.
+     *
+     * Whether the array is copied or simply referenced
+     * is implementation-dependent.
+     * For this reason caller does give up ownership of it.
+     * Implementations that will not copy it will need take care
+     * of deleting it.
+     *
+     * This method must handle null arguments by creating
+     * an empty sequence.
+     *
+     * @param coordinates the coordinates
      * @param dimension 0, 2 or 3 with 0 indicating unknown at this time.
-	 */
-	virtual CoordinateSequence *create(
-            std::vector<Coordinate> *coordinates,
-            std::size_t dimension=0 ) const=0;
+     */
+    virtual CoordinateSequence* create(
+        std::vector<Coordinate>* coordinates,
+        std::size_t dimension = 0) const = 0;
 
-	/** \brief
-	 * Creates a CoordinateSequence of the specified size and dimension.
-	 *
-	 * For this to be useful, the CoordinateSequence implementation must
-	 * be mutable.
-	 *
-	 * @param size the number of coordinates in the sequence
-	 * @param dimension the dimension of the coordinates in the sequence
-	 * 	(0=unknown, 2, or 3 - ignored if not user specifiable)
-	 */
-	virtual CoordinateSequence *create(std::size_t size,
-                                           std::size_t dimension=0) const=0;
+    /** \brief
+     * Creates a CoordinateSequence of the specified size and dimension.
+     *
+     * For this to be useful, the CoordinateSequence implementation must
+     * be mutable.
+     *
+     * @param size the number of coordinates in the sequence
+     * @param dimension the dimension of the coordinates in the sequence
+     * 	(0=unknown, 2, or 3 - ignored if not user specifiable)
+     */
+    virtual CoordinateSequence* create(std::size_t size,
+                                       std::size_t dimension = 0) const = 0;
 
-	/** \brief
-	 * Creates a CoordinateSequence which is a copy of the given one.
-	 *
-	 * This method must handle null arguments by creating an empty sequence.
-	 *
-	 * @param coordSeq the coordinate sequence to copy
-	 */
-	virtual CoordinateSequence *create(const CoordinateSequence &coordSeq) const=0;
+    /** \brief
+     * Creates a CoordinateSequence which is a copy of the given one.
+     *
+     * This method must handle null arguments by creating an empty sequence.
+     *
+     * @param coordSeq the coordinate sequence to copy
+     */
+    virtual CoordinateSequence* create(const CoordinateSequence& coordSeq) const = 0;
 
-	virtual ~CoordinateSequenceFactory();
+    virtual ~CoordinateSequenceFactory();
 };
 
 } // namespace geos::geom
diff --git a/include/geos/geom/CoordinateSequenceFilter.h b/include/geos/geom/CoordinateSequenceFilter.h
index c778fd8..0741328 100644
--- a/include/geos/geom/CoordinateSequenceFilter.h
+++ b/include/geos/geom/CoordinateSequenceFilter.h
@@ -26,9 +26,9 @@
 
 // Forward declarations
 namespace geos {
-	namespace geom {
-		class CoordinateSequence;
-	}
+namespace geom {
+class CoordinateSequence;
+}
 }
 
 namespace geos {
@@ -59,50 +59,57 @@ class GEOS_DLL CoordinateSequenceFilter {
 
 public:
 
-  virtual ~CoordinateSequenceFilter() {}
-
-  /**
-   * Performs an operation on a coordinate in a {@link CoordinateSequence}.
-   *
-   * @param seq  the <code>CoordinateSequence</code> to which the filter
-   *             is applied
-   * @param i the index of the coordinate to apply the filter to
-   */
-  virtual void filter_rw(CoordinateSequence& /*seq*/, std::size_t /*i*/)
-  { assert(0); }
-
-  /**
-   * Performs an operation on a coordinate in a {@link CoordinateSequence}.
-   *
-   * @param seq  the <code>CoordinateSequence</code> to which the filter
-   *             is applied
-   * @param i the index of the coordinate to apply the filter to
-   */
-  virtual void filter_ro(const CoordinateSequence& /*seq*/, std::size_t /*i*/)
-  { assert(0); }
-
-  /**
-   * Reports whether the application of this filter can be terminated.
-   * Once this method returns <tt>false</tt>, it should
-   * continue to return <tt>false</tt> on every subsequent call.
-   *
-   * @return true if the application of this filter can be terminated.
-   */
-  virtual bool isDone() const = 0;
-
-
-  /**
-   * Reports whether the execution of this filter
-   * has modified the coordinates of the geometry.
-   * If so, {@link Geometry#geometryChanged} will be executed
-   * after this filter has finished being executed.
-   *
-   * Most filters can simply return a constant value reflecting
-   * whether they are able to change the coordinates.
-   *
-   * @return true if this filter has changed the coordinates of the geometry
-   */
-  virtual bool isGeometryChanged() const = 0;
+    virtual
+    ~CoordinateSequenceFilter() {}
+
+    /**
+     * Performs an operation on a coordinate in a {@link CoordinateSequence}.
+     *
+     * @param seq  the <code>CoordinateSequence</code> to which the filter
+     *             is applied
+     * @param i the index of the coordinate to apply the filter to
+     */
+    virtual void
+    filter_rw(CoordinateSequence& /*seq*/, std::size_t /*i*/)
+    {
+        assert(0);
+    }
+
+    /**
+     * Performs an operation on a coordinate in a {@link CoordinateSequence}.
+     *
+     * @param seq  the <code>CoordinateSequence</code> to which the filter
+     *             is applied
+     * @param i the index of the coordinate to apply the filter to
+     */
+    virtual void
+    filter_ro(const CoordinateSequence& /*seq*/, std::size_t /*i*/)
+    {
+        assert(0);
+    }
+
+    /**
+     * Reports whether the application of this filter can be terminated.
+     * Once this method returns <tt>false</tt>, it should
+     * continue to return <tt>false</tt> on every subsequent call.
+     *
+     * @return true if the application of this filter can be terminated.
+     */
+    virtual bool isDone() const = 0;
+
+
+    /**
+     * Reports whether the execution of this filter
+     * has modified the coordinates of the geometry.
+     * If so, {@link Geometry#geometryChanged} will be executed
+     * after this filter has finished being executed.
+     *
+     * Most filters can simply return a constant value reflecting
+     * whether they are able to change the coordinates.
+     *
+     * @return true if this filter has changed the coordinates of the geometry
+     */
+    virtual bool isGeometryChanged() const = 0;
 
 };
 
diff --git a/include/geos/geom/Dimension.h b/include/geos/geom/Dimension.h
index b501522..0cf0dd8 100644
--- a/include/geos/geom/Dimension.h
+++ b/include/geos/geom/Dimension.h
@@ -28,35 +28,35 @@ namespace geom { // geos::geom
 ///
 class GEOS_DLL Dimension {
 public:
-	enum DimensionType {
-		/// Dimension value for any dimension (= {FALSE, TRUE}).
-		DONTCARE=-3,
+    enum DimensionType {
+        /// Dimension value for any dimension (= {FALSE, TRUE}).
+        DONTCARE = -3,
 
-		/// Dimension value of non-empty geometries (= {P, L, A}).
-		True=-2,
+        /// Dimension value of non-empty geometries (= {P, L, A}).
+        True = -2,
 
-		/// Dimension value of the empty geometry (-1).
-		False=-1,
+        /// Dimension value of the empty geometry (-1).
+        False = -1,
 
-		/// Dimension value of a point (0).
-		P=0,
+        /// Dimension value of a point (0).
+        P = 0,
 
-		/// Dimension value of a curve (1).
-		L=1,
+        /// Dimension value of a curve (1).
+        L = 1,
 
-		/// Dimension value of a surface (2).
-		A=2
-	};
+        /// Dimension value of a surface (2).
+        A = 2
+    };
 
-	//static const int P = 0;			/// Dimension value of a point (0).
-	//static const int L = 1;			/// Dimension value of a curve (1).
-	//static const int A = 2;			/// Dimension value of a surface (2).
-	//static const int False = -1;	/// Dimension value of the empty geometry (-1).
-	//static const int True = -2;		/// Dimension value of non-empty geometries (= {P, L, A}).
-	//static const int DONTCARE = -3;	/// Dimension value for any dimension (= {FALSE, TRUE}).
-	static char toDimensionSymbol(int dimensionValue);
+    //static const int P = 0;			/// Dimension value of a point (0).
+    //static const int L = 1;			/// Dimension value of a curve (1).
+    //static const int A = 2;			/// Dimension value of a surface (2).
+    //static const int False = -1;	/// Dimension value of the empty geometry (-1).
+    //static const int True = -2;		/// Dimension value of non-empty geometries (= {P, L, A}).
+    //static const int DONTCARE = -3;	/// Dimension value for any dimension (= {FALSE, TRUE}).
+    static char toDimensionSymbol(int dimensionValue);
 
-	static int toDimensionValue(char dimensionSymbol);
+    static int toDimensionValue(char dimensionSymbol);
 
 };
 
diff --git a/include/geos/geom/Envelope.h b/include/geos/geom/Envelope.h
index 19821f9..d7de720 100644
--- a/include/geos/geom/Envelope.h
+++ b/include/geos/geom/Envelope.h
@@ -60,81 +60,81 @@ class GEOS_DLL Envelope {
 
 public:
 
-	friend std::ostream& operator<< (std::ostream& os, const Envelope& o);
-
-	typedef std::unique_ptr<Envelope> Ptr;
-
-	/** \brief
-	 * Creates a null <code>Envelope</code>.
-	 */
-	Envelope(void);
-
-	/** \brief
-	 * Creates an <code>Envelope</code> for a region defined by
-	 * maximum and minimum values.
-	 *
-	 * @param  x1  the first x-value
-	 * @param  x2  the second x-value
-	 * @param  y1  the first y-value
-	 * @param  y2  the second y-value
-	 */
-	Envelope(double x1, double x2, double y1, double y2);
-
-	/** \brief
-	 * Creates an <code>Envelope</code> for a region defined by
-	 * two Coordinates.
-	 *
-	 * @param  p1  the first Coordinate
-	 * @param  p2  the second Coordinate
-	 */
-	Envelope(const Coordinate& p1, const Coordinate& p2);
-
-	/** \brief
-	 * Creates an Envelope for a region defined by a single Coordinate.
-	 *
-	 * @param  p  the Coordinate
-	 */
-	Envelope(const Coordinate& p);
-
-	/// Copy constructor
-	Envelope(const Envelope &env);
-
-	/// Assignment operator
-	Envelope& operator=(const Envelope& e);
-
-	/** \brief
-	 *  Create an <code>Envelope</code> from an Envelope
-	 *  string representation produced by Envelope.toString()
-	 */
-	Envelope(const std::string &str);
-
-	~Envelope(void);
-
-	/** \brief
-	 * Test the point q to see whether it intersects the
-	 * Envelope defined by p1-p2
-	 *
-	 * @param p1 one extremal point of the envelope
-	 * @param p2 another extremal point of the envelope
-	 * @param q the point to test for intersection
-	 * @return <code>true</code> if q intersects the envelope p1-p2
-	 */
-	static bool intersects(const Coordinate& p1, const Coordinate& p2,
-			const Coordinate& q);
-
-	/** \brief
-	 * Test the envelope defined by p1-p2 for intersection
-	 * with the envelope defined by q1-q2
-	 *
-	 * @param p1 one extremal point of the envelope P
-	 * @param p2 another extremal point of the envelope P
-	 * @param q1 one extremal point of the envelope Q
-	 * @param q2 another extremal point of the envelope Q
-	 *
-	 * @return <code>true</code> if Q intersects P
-	 */
-	static bool intersects(const Coordinate& p1, const Coordinate& p2,
-			const Coordinate& q1, const Coordinate& q2);
+    friend std::ostream& operator<< (std::ostream& os, const Envelope& o);
+
+    typedef std::unique_ptr<Envelope> Ptr;
+
+    /** \brief
+     * Creates a null <code>Envelope</code>.
+     */
+    Envelope(void);
+
+    /** \brief
+     * Creates an <code>Envelope</code> for a region defined by
+     * maximum and minimum values.
+     *
+     * @param  x1  the first x-value
+     * @param  x2  the second x-value
+     * @param  y1  the first y-value
+     * @param  y2  the second y-value
+     */
+    Envelope(double x1, double x2, double y1, double y2);
+
+    /** \brief
+     * Creates an <code>Envelope</code> for a region defined by
+     * two Coordinates.
+     *
+     * @param  p1  the first Coordinate
+     * @param  p2  the second Coordinate
+     */
+    Envelope(const Coordinate& p1, const Coordinate& p2);
+
+    /** \brief
+     * Creates an Envelope for a region defined by a single Coordinate.
+     *
+     * @param  p  the Coordinate
+     */
+    Envelope(const Coordinate& p);
+
+    /// Copy constructor
+    Envelope(const Envelope& env);
+
+    /// Assignment operator
+    Envelope& operator=(const Envelope& e);
+
+    /** \brief
+     *  Create an <code>Envelope</code> from an Envelope
+     *  string representation produced by Envelope.toString()
+     */
+    Envelope(const std::string& str);
+
+    ~Envelope(void);
+
+    /** \brief
+     * Test the point q to see whether it intersects the
+     * Envelope defined by p1-p2
+     *
+     * @param p1 one extremal point of the envelope
+     * @param p2 another extremal point of the envelope
+     * @param q the point to test for intersection
+     * @return <code>true</code> if q intersects the envelope p1-p2
+     */
+    static bool intersects(const Coordinate& p1, const Coordinate& p2,
+                           const Coordinate& q);
+
+    /** \brief
+     * Test the envelope defined by p1-p2 for intersection
+     * with the envelope defined by q1-q2
+     *
+     * @param p1 one extremal point of the envelope P
+     * @param p2 another extremal point of the envelope P
+     * @param q1 one extremal point of the envelope Q
+     * @param q2 another extremal point of the envelope Q
+     *
+     * @return <code>true</code> if Q intersects P
+     */
+    static bool intersects(const Coordinate& p1, const Coordinate& p2,
+                           const Coordinate& q1, const Coordinate& q2);
 
     /**
     *  Check if the extent defined by two extremal points
@@ -146,363 +146,378 @@ public:
     */
     bool intersects(const Coordinate& a, const Coordinate& b) const;
 
-	/** \brief
-	 *  Initialize to a null <code>Envelope</code>.
-	 */
-	void init(void);
-
-	/** \brief
-	 * Initialize an <code>Envelope</code> for a region defined by
-	 * maximum and minimum values.
-	 *
-	 * @param  x1  the first x-value
-	 * @param  x2  the second x-value
-	 * @param  y1  the first y-value
-	 * @param  y2  the second y-value
-	 */
-	void init(double x1, double x2, double y1, double y2);
-
-	/** \brief
-	 * Initialize an <code>Envelope</code> to a region defined
-	 * by two Coordinates.
-	 *
-	 * @param  p1  the first Coordinate
-	 * @param  p2  the second Coordinate
-	 */
-	void init(const Coordinate& p1, const Coordinate& p2);
-
-	/** \brief
-	 * Initialize an <code>Envelope</code> to a region defined
-	 * by a single Coordinate.
-	 *
-	 * @param  p  the Coordinate
-	 */
-	void init(const Coordinate& p);
-
-	// use assignment operator instead
-	//void init(Envelope env);
-
-	/** \brief
-	 * Makes this <code>Envelope</code> a "null" envelope,
-	 * that is, the envelope of the empty geometry.
-	 */
-	void setToNull(void);
-
-	/** \brief
-	 * Returns <code>true</code> if this <code>Envelope</code>
-	 * is a "null" envelope.
-	 *
-	 * @return <code>true</code> if this <code>Envelope</code>
-	 *         is uninitialized or is the envelope of the
-	 *         empty geometry.
-	 */
-	bool isNull(void) const;
-
-	/** \brief
-	 * Returns the difference between the maximum and minimum x values.
-	 *
-	 * @return  max x - min x, or 0 if this is a null Envelope
-	 */
-	double getWidth(void) const;
-
-	/** \brief
-	 * Returns the difference between the maximum and minimum y values.
-	 *
-	 * @return max y - min y, or 0 if this is a null Envelope
-	 */
-	double getHeight(void) const;
-
-	/**
-	 * Gets the area of this envelope.
-	 *
-	 * @return the area of the envelope
-	 * @return 0.0 if the envelope is null
-	 */
-	double getArea() const
-	{
-		return getWidth() * getHeight();
-	}
-
-	/**
-	 *  Returns the Envelope maximum y-value. min y > max y
-	 *  indicates that this is a null Envelope.
-	 */
-	double getMaxY() const;
-
-	/**
-	 *  Returns the Envelope maximum x-value. min x > max x
-	 *  indicates that this is a null Envelope.
-	 */
-	double getMaxX() const;
-
-	/**
-	 *  Returns the Envelope minimum y-value. min y > max y
-	 *  indicates that this is a null Envelope.
-	 */
-	double getMinY() const;
-
-	/**
-	 *  Returns the Envelope minimum x-value. min x > max x
-	 *  indicates that this is a null Envelope.
-	 */
-	double getMinX() const;
-
-	/**
-	 * Computes the coordinate of the centre of this envelope
-	 * (as long as it is non-null)
-	 *
-	 * @param centre The coordinate to write results into
-	 * @return NULL is the center could not be found
-	 * (null envelope).
-	 */
-	bool centre(Coordinate& centre) const;
-
-	/**
-	 * Computes the intersection of two {@link Envelopes}
-	 *
-	 * @param env the envelope to intersect with
-	 * @param result the envelope representing the intersection of
-	 *               the envelopes (this will be the null envelope
-	 *               if either argument is null, or they do not intersect)
-	 * @return false if not intersection is found
-	 */
-	bool intersection(const Envelope& env, Envelope& result) const;
-
-	/** \brief
-	 * Translates this envelope by given amounts in the X and Y direction.
-	 *
-	 * @param transX the amount to translate along the X axis
-	 * @param transY the amount to translate along the Y axis
-	 */
-	void translate(double transX, double transY);
-
-	/** \brief
-	 * Expands this envelope by a given distance in all directions.
-	 * Both positive and negative distances are supported.
-	 *
-	 * @param deltaX the distance to expand the envelope along
-	 *               the X axis
-	 * @param deltaY the distance to expand the envelope along
-	 *               the Y axis
-	 */
-	void expandBy(double deltaX, double deltaY);
-
-	/** \brief
-	 * Expands this envelope by a given distance in all directions.
-	 * Both positive and negative distances are supported.
-	 *
-	 * @param distance the distance to expand the envelope
-	 * @return this envelope
-	 */
-	void expandBy(double p_distance) { expandBy(p_distance, p_distance); }
-
-
-	/** \brief
-	 * Enlarges the boundary of the Envelope so that it contains
-	 *  p. Does nothing if p is already on or within the boundaries.
-	 *
-	 * @param  p  the Coordinate to include
-	 */
-	void expandToInclude(const Coordinate& p);
-
-	/** \brief
-	 * Enlarges the boundary of the Envelope so that it contains
-	 * (x,y). Does nothing if (x,y) is already on or within the boundaries.
-	 *
-	 * @param  x  the value to lower the minimum x
-	 *            to or to raise the maximum x to
-	 * @param  y  the value to lower the minimum y
-	 *            to or to raise the maximum y to
-	 */
-	void expandToInclude(double x, double y);
-
-	/** \brief
-	 * Enlarges the boundary of the Envelope so that it contains
-	 * <code>other</code>. Does nothing if other is wholly on or
-	 * within the boundaries.
-	 *
-	 * @param  other  the <code>Envelope</code> to merge with
-	 */
-	void expandToInclude(const Envelope* other);
-
-	/** \brief
-	 * Tests if the <code>Envelope other</code> lies wholely
-	 * inside this <code>Envelope</code> (inclusive of the boundary).
-	 *
-	 * Note that this is <b>not</b> the same definition as the SFS
-	 * <tt>contains</tt>, which would exclude the envelope boundary.
-	 *
-	 * @param  other the <code>Envelope</code> to check
-	 * @return true if <code>other</code> is contained in this
-	 *              <code>Envelope</code>
-	 *
-	 * @see covers(Envelope)
-	 */
-	bool contains(const Envelope& other) const {
-		return covers(other);
-	}
-
-	bool contains(const Envelope* other) const {
-		return contains(*other);
-	}
-
-	/** \brief
-	 * Returns <code>true</code> if the given point lies in
-	 * or on the envelope.
-	 *
-	 * @param  p  the point which this <code>Envelope</code> is
-	 *      being checked for containing
-	 * @return    <code>true</code> if the point lies in the interior or
-	 *      on the boundary of this <code>Envelope</code>.
-	 */
-	bool contains(const Coordinate& p) const {
-		return covers(p.x, p.y);
-	}
-
-	/** \brief
-	 * Returns <code>true</code> if the given point lies in
-	 * or on the envelope.
-	 *
-	 * @param  x  the x-coordinate of the point which this
-	 *            <code>Envelope</code> is
-	 *            being checked for containing
-	 *
-	 * @param  y  the y-coordinate of the point which this
-	 *            <code>Envelope</code> is being checked for containing
-	 *
-	 * @return    <code>true</code> if <code>(x, y)</code> lies in
-	 *            the interior or on the boundary of this
-	 *            <code>Envelope</code>.
-	 */
-	bool contains(double x, double y) const {
-		return covers(x, y);
-	}
-
-	/**
-	 * Check if the point p
-	 * intersects (lies inside) the region of this Envelope.
-	 *
-	 * @param  p  	the Coordinate to be tested
-	 * @return true if the point intersects this Envelope
-	 */
-	bool intersects(const Coordinate& p) const;
-
-	/**
-	 *  Check if the point (x, y)
-	 *  intersects (lies inside) the region of this Envelope.
-	 *
-	 * @param  x  the x-ordinate of the point
-	 * @param  y  the y-ordinate of the point
-	 * @return <code>true</code> if the point intersects this Envelope
-	 */
-	bool intersects(double x, double y) const;
-
-	/**
-	 * Check if the region defined by other Envelope
-	 * intersects (intersects) the region of this Envelope.
-	 *
-	 * @param other the Envelope which this Envelope is
-	 *              being checked for intersection
-	 *
-	 * @return      true if the Envelopes intersects
-	 */
-	bool intersects(const Envelope* other) const;
-
-	bool intersects(const Envelope& other) const;
-
-	/**
-	* Tests if the given point lies in or on the envelope.
-	*
-	*@param  x  the x-coordinate of the point which this <code>Envelope</code> is
-	*      being checked for containing
-	*@param  y  the y-coordinate of the point which this <code>Envelope</code> is
-	*      being checked for containing
-	*@return    <code>true</code> if <code>(x, y)</code> lies in the interior or
-	*      on the boundary of this <code>Envelope</code>.
-	*/
-	bool covers(double x, double y) const;
-
-	/**
-	* Tests if the given point lies in or on the envelope.
-	*
-	*@param  p  the point which this <code>Envelope</code> is
-	*      being checked for containing
-	*@return    <code>true</code> if the point lies in the interior or
-	*      on the boundary of this <code>Envelope</code>.
-	*/
-	bool covers(const Coordinate *p) const;
-
-	/**
-	 * Tests if the <code>Envelope other</code> lies wholely inside
-	 * this <code>Envelope</code> (inclusive of the boundary).
-	 *
-	 * @param  other the <code>Envelope</code> to check
-	 * @return true if this <code>Envelope</code> covers the
-	 * <code>other</code>
-	 */
-	bool covers(const Envelope& other) const;
-
-	bool covers(const Envelope* other) const {
-		return covers(*other);
-	}
-
-
-	/** \brief
-	 * Returns <code>true</code> if the <code>Envelope other</code>
-	 * spatially equals this <code>Envelope</code>.
-	 *
-	 * @param  other the <code>Envelope</code> which this
-	 *               <code>Envelope</code> is being checked for equality
-	 *
-	 * @return <code>true</code> if this and <code>other</code>
-	 *         Envelope objs are spatially equal
-	 */
-	bool equals(const Envelope* other) const;
-
-	/** \brief
-	 * Returns a <code>string</code> of the form
-	 * <I>Env[minx:maxx,miny:maxy]</I> .
-	 *
-	 * @return a <code>string</code> of the form
-	 *         <I>Env[minx:maxx,miny:maxy]</I>
-	 */
-	std::string toString(void) const;
-
-	/** \brief
-	 * Computes the distance between this and another
-	 * <code>Envelope</code>.
-	 *
-	 * The distance between overlapping Envelopes is 0.  Otherwise, the
-	 * distance is the Euclidean distance between the closest points.
-	 */
-	double distance(const Envelope* env) const;
-
-	int hashCode() const;
+    /** \brief
+     *  Initialize to a null <code>Envelope</code>.
+     */
+    void init(void);
+
+    /** \brief
+     * Initialize an <code>Envelope</code> for a region defined by
+     * maximum and minimum values.
+     *
+     * @param  x1  the first x-value
+     * @param  x2  the second x-value
+     * @param  y1  the first y-value
+     * @param  y2  the second y-value
+     */
+    void init(double x1, double x2, double y1, double y2);
+
+    /** \brief
+     * Initialize an <code>Envelope</code> to a region defined
+     * by two Coordinates.
+     *
+     * @param  p1  the first Coordinate
+     * @param  p2  the second Coordinate
+     */
+    void init(const Coordinate& p1, const Coordinate& p2);
+
+    /** \brief
+     * Initialize an <code>Envelope</code> to a region defined
+     * by a single Coordinate.
+     *
+     * @param  p  the Coordinate
+     */
+    void init(const Coordinate& p);
+
+    // use assignment operator instead
+    //void init(Envelope env);
+
+    /** \brief
+     * Makes this <code>Envelope</code> a "null" envelope,
+     * that is, the envelope of the empty geometry.
+     */
+    void setToNull(void);
+
+    /** \brief
+     * Returns <code>true</code> if this <code>Envelope</code>
+     * is a "null" envelope.
+     *
+     * @return <code>true</code> if this <code>Envelope</code>
+     *         is uninitialized or is the envelope of the
+     *         empty geometry.
+     */
+    bool isNull(void) const;
+
+    /** \brief
+     * Returns the difference between the maximum and minimum x values.
+     *
+     * @return  max x - min x, or 0 if this is a null Envelope
+     */
+    double getWidth(void) const;
+
+    /** \brief
+     * Returns the difference between the maximum and minimum y values.
+     *
+     * @return max y - min y, or 0 if this is a null Envelope
+     */
+    double getHeight(void) const;
+
+    /**
+     * Gets the area of this envelope.
+     *
+     * @return the area of the envelope
+     * @return 0.0 if the envelope is null
+     */
+    double
+    getArea() const
+    {
+        return getWidth() * getHeight();
+    }
+
+    /**
+     *  Returns the Envelope maximum y-value. min y > max y
+     *  indicates that this is a null Envelope.
+     */
+    double getMaxY() const;
+
+    /**
+     *  Returns the Envelope maximum x-value. min x > max x
+     *  indicates that this is a null Envelope.
+     */
+    double getMaxX() const;
+
+    /**
+     *  Returns the Envelope minimum y-value. min y > max y
+     *  indicates that this is a null Envelope.
+     */
+    double getMinY() const;
+
+    /**
+     *  Returns the Envelope minimum x-value. min x > max x
+     *  indicates that this is a null Envelope.
+     */
+    double getMinX() const;
+
+    /**
+     * Computes the coordinate of the centre of this envelope
+     * (as long as it is non-null)
+     *
+     * @param centre The coordinate to write results into
+     * @return NULL is the center could not be found
+     * (null envelope).
+     */
+    bool centre(Coordinate& centre) const;
+
+    /**
+     * Computes the intersection of two {@link Envelopes}
+     *
+     * @param env the envelope to intersect with
+     * @param result the envelope representing the intersection of
+     *               the envelopes (this will be the null envelope
+     *               if either argument is null, or they do not intersect)
+     * @return false if not intersection is found
+     */
+    bool intersection(const Envelope& env, Envelope& result) const;
+
+    /** \brief
+     * Translates this envelope by given amounts in the X and Y direction.
+     *
+     * @param transX the amount to translate along the X axis
+     * @param transY the amount to translate along the Y axis
+     */
+    void translate(double transX, double transY);
+
+    /** \brief
+     * Expands this envelope by a given distance in all directions.
+     * Both positive and negative distances are supported.
+     *
+     * @param deltaX the distance to expand the envelope along
+     *               the X axis
+     * @param deltaY the distance to expand the envelope along
+     *               the Y axis
+     */
+    void expandBy(double deltaX, double deltaY);
+
+    /** \brief
+     * Expands this envelope by a given distance in all directions.
+     * Both positive and negative distances are supported.
+     *
+     * @param distance the distance to expand the envelope
+     * @return this envelope
+     */
+    void
+    expandBy(double p_distance)
+    {
+        expandBy(p_distance, p_distance);
+    }
+
+
+    /** \brief
+     * Enlarges the boundary of the Envelope so that it contains
+     *  p. Does nothing if p is already on or within the boundaries.
+     *
+     * @param  p  the Coordinate to include
+     */
+    void expandToInclude(const Coordinate& p);
+
+    /** \brief
+     * Enlarges the boundary of the Envelope so that it contains
+     * (x,y). Does nothing if (x,y) is already on or within the boundaries.
+     *
+     * @param  x  the value to lower the minimum x
+     *            to or to raise the maximum x to
+     * @param  y  the value to lower the minimum y
+     *            to or to raise the maximum y to
+     */
+    void expandToInclude(double x, double y);
+
+    /** \brief
+     * Enlarges the boundary of the Envelope so that it contains
+     * <code>other</code>. Does nothing if other is wholly on or
+     * within the boundaries.
+     *
+     * @param  other  the <code>Envelope</code> to merge with
+     */
+    void expandToInclude(const Envelope* other);
+
+    /** \brief
+     * Tests if the <code>Envelope other</code> lies wholely
+     * inside this <code>Envelope</code> (inclusive of the boundary).
+     *
+     * Note that this is <b>not</b> the same definition as the SFS
+     * <tt>contains</tt>, which would exclude the envelope boundary.
+     *
+     * @param  other the <code>Envelope</code> to check
+     * @return true if <code>other</code> is contained in this
+     *              <code>Envelope</code>
+     *
+     * @see covers(Envelope)
+     */
+    bool
+    contains(const Envelope& other) const
+    {
+        return covers(other);
+    }
+
+    bool
+    contains(const Envelope* other) const
+    {
+        return contains(*other);
+    }
+
+    /** \brief
+     * Returns <code>true</code> if the given point lies in
+     * or on the envelope.
+     *
+     * @param  p  the point which this <code>Envelope</code> is
+     *      being checked for containing
+     * @return    <code>true</code> if the point lies in the interior or
+     *      on the boundary of this <code>Envelope</code>.
+     */
+    bool
+    contains(const Coordinate& p) const
+    {
+        return covers(p.x, p.y);
+    }
+
+    /** \brief
+     * Returns <code>true</code> if the given point lies in
+     * or on the envelope.
+     *
+     * @param  x  the x-coordinate of the point which this
+     *            <code>Envelope</code> is
+     *            being checked for containing
+     *
+     * @param  y  the y-coordinate of the point which this
+     *            <code>Envelope</code> is being checked for containing
+     *
+     * @return    <code>true</code> if <code>(x, y)</code> lies in
+     *            the interior or on the boundary of this
+     *            <code>Envelope</code>.
+     */
+    bool
+    contains(double x, double y) const
+    {
+        return covers(x, y);
+    }
+
+    /**
+     * Check if the point p
+     * intersects (lies inside) the region of this Envelope.
+     *
+     * @param  p  	the Coordinate to be tested
+     * @return true if the point intersects this Envelope
+     */
+    bool intersects(const Coordinate& p) const;
+
+    /**
+     *  Check if the point (x, y)
+     *  intersects (lies inside) the region of this Envelope.
+     *
+     * @param  x  the x-ordinate of the point
+     * @param  y  the y-ordinate of the point
+     * @return <code>true</code> if the point intersects this Envelope
+     */
+    bool intersects(double x, double y) const;
+
+    /**
+     * Check if the region defined by other Envelope
+     * intersects (intersects) the region of this Envelope.
+     *
+     * @param other the Envelope which this Envelope is
+     *              being checked for intersection
+     *
+     * @return      true if the Envelopes intersects
+     */
+    bool intersects(const Envelope* other) const;
+
+    bool intersects(const Envelope& other) const;
+
+    /**
+    * Tests if the given point lies in or on the envelope.
+    *
+    *@param  x  the x-coordinate of the point which this <code>Envelope</code> is
+    *      being checked for containing
+    *@param  y  the y-coordinate of the point which this <code>Envelope</code> is
+    *      being checked for containing
+    *@return    <code>true</code> if <code>(x, y)</code> lies in the interior or
+    *      on the boundary of this <code>Envelope</code>.
+    */
+    bool covers(double x, double y) const;
+
+    /**
+    * Tests if the given point lies in or on the envelope.
+    *
+    *@param  p  the point which this <code>Envelope</code> is
+    *      being checked for containing
+    *@return    <code>true</code> if the point lies in the interior or
+    *      on the boundary of this <code>Envelope</code>.
+    */
+    bool covers(const Coordinate* p) const;
+
+    /**
+     * Tests if the <code>Envelope other</code> lies wholely inside
+     * this <code>Envelope</code> (inclusive of the boundary).
+     *
+     * @param  other the <code>Envelope</code> to check
+     * @return true if this <code>Envelope</code> covers the
+     * <code>other</code>
+     */
+    bool covers(const Envelope& other) const;
+
+    bool
+    covers(const Envelope* other) const
+    {
+        return covers(*other);
+    }
+
+
+    /** \brief
+     * Returns <code>true</code> if the <code>Envelope other</code>
+     * spatially equals this <code>Envelope</code>.
+     *
+     * @param  other the <code>Envelope</code> which this
+     *               <code>Envelope</code> is being checked for equality
+     *
+     * @return <code>true</code> if this and <code>other</code>
+     *         Envelope objs are spatially equal
+     */
+    bool equals(const Envelope* other) const;
+
+    /** \brief
+     * Returns a <code>string</code> of the form
+     * <I>Env[minx:maxx,miny:maxy]</I> .
+     *
+     * @return a <code>string</code> of the form
+     *         <I>Env[minx:maxx,miny:maxy]</I>
+     */
+    std::string toString(void) const;
+
+    /** \brief
+     * Computes the distance between this and another
+     * <code>Envelope</code>.
+     *
+     * The distance between overlapping Envelopes is 0.  Otherwise, the
+     * distance is the Euclidean distance between the closest points.
+     */
+    double distance(const Envelope* env) const;
+
+    int hashCode() const;
 
 private:
 
-	/** \brief
-	 * Splits a string into parts based on the supplied delimiters.
-	 *
-	 * This is a generic function that really belongs in a utility
-	 * file somewhere
-	 */
-	std::vector<std::string> split(const std::string &str,
-			const std::string &delimiters = " ");
+    /** \brief
+     * Splits a string into parts based on the supplied delimiters.
+     *
+     * This is a generic function that really belongs in a utility
+     * file somewhere
+     */
+    std::vector<std::string> split(const std::string& str,
+                                   const std::string& delimiters = " ");
 
-	static double distance(double x0,double y0,double x1,double y1);
+    static double distance(double x0, double y0, double x1, double y1);
 
-	/// the minimum x-coordinate
-	double minx;
+    /// the minimum x-coordinate
+    double minx;
 
-	/// the maximum x-coordinate
-	double maxx;
+    /// the maximum x-coordinate
+    double maxx;
 
-	/// the minimum y-coordinate
-	double miny;
+    /// the minimum y-coordinate
+    double miny;
 
-	/// the maximum y-coordinate
-	double maxy;
+    /// the maximum y-coordinate
+    double maxy;
 };
 
 /// Checks if two Envelopes are equal (2D only check)
diff --git a/include/geos/geom/Envelope.inl b/include/geos/geom/Envelope.inl
index fb0a9bc..fa66133 100644
--- a/include/geos/geom/Envelope.inl
+++ b/include/geos/geom/Envelope.inl
@@ -7,7 +7,7 @@
  *
  * This is free software; you can redistribute and/or modify it under
  * the terms of the GNU Lesser General Public Licence as published
- * by the Free Software Foundation. 
+ * by the Free Software Foundation.
  * See the COPYING file for more information.
  *
  **********************************************************************
@@ -28,67 +28,81 @@ namespace geom { // geos::geom
 
 /*public*/
 INLINE double
-Envelope::getMaxY() const { return maxy; }
+Envelope::getMaxY() const
+{
+    return maxy;
+}
 
 /*public*/
 INLINE double
-Envelope::getMaxX() const { return maxx; }
+Envelope::getMaxX() const
+{
+    return maxx;
+}
 
 /*public*/
 INLINE double
-Envelope::getMinY() const { return miny; }
+Envelope::getMinY() const
+{
+    return miny;
+}
 
 /*public*/
 INLINE double
-Envelope::getMinX() const { return minx; }
+Envelope::getMinX() const
+{
+    return minx;
+}
 
 /*public*/
 INLINE bool
 Envelope::intersects(const Coordinate& other) const
 {
-	return (other.x <= maxx && other.x >= minx &&
-		other.y <= maxy && other.y >= miny);
+    return (other.x <= maxx && other.x >= minx &&
+            other.y <= maxy && other.y >= miny);
 }
 
 /*public*/
 INLINE bool
 Envelope::intersects(const Envelope& other) const
 {
-	return intersects(&other);
+    return intersects(&other);
 }
 
 /*public*/
 INLINE bool
 Envelope::isNull(void) const
 {
-	return maxx < minx;
+    return maxx < minx;
 }
 
 /*public*/
 INLINE bool
 Envelope::intersects(const Envelope* other) const
 {
-	// Optimized to reduce function calls
-	if ( isNull() || other->isNull() ) return false;
-	return !(other->minx > maxx ||
-			 other->maxx < minx ||
-			 other->miny > maxy ||
-			 other->maxy < miny);
+    // Optimized to reduce function calls
+    if(isNull() || other->isNull()) {
+        return false;
+    }
+    return !(other->minx > maxx ||
+             other->maxx < minx ||
+             other->miny > maxy ||
+             other->maxy < miny);
 }
 
 /*public*/
 INLINE bool
 Envelope::intersects(double x, double y) const
 {
-	return (x <= maxx && x >= minx && y <= maxy && y >= miny);
+    return (x <= maxx && x >= minx && y <= maxy && y >= miny);
 }
 
 
 /*public*/
-INLINE bool 
-Envelope::covers(const Coordinate *p) const
+INLINE bool
+Envelope::covers(const Coordinate* p) const
 {
-	return covers(p->x, p->y);
+    return covers(p->x, p->y);
 }
 
 } // namespace geos::geom
diff --git a/include/geos/geom/Geometry.h b/include/geos/geom/Geometry.h
index 4e01b46..64a9967 100644
--- a/include/geos/geom/Geometry.h
+++ b/include/geos/geom/Geometry.h
@@ -50,21 +50,21 @@
 
 // Forward declarations
 namespace geos {
-	namespace geom {
-		class Coordinate;
-		class CoordinateFilter;
-		class CoordinateSequence;
-		class CoordinateSequenceFilter;
-		class GeometryComponentFilter;
-		class GeometryFactory;
-		class GeometryFilter;
-		class IntersectionMatrix;
-		class PrecisionModel;
-		class Point;
-	}
-	namespace io { // geos.io
-		class Unload;
-	} // namespace geos.io
+namespace geom {
+class Coordinate;
+class CoordinateFilter;
+class CoordinateSequence;
+class CoordinateSequenceFilter;
+class GeometryComponentFilter;
+class GeometryFactory;
+class GeometryFilter;
+class IntersectionMatrix;
+class PrecisionModel;
+class Point;
+}
+namespace io { // geos.io
+class Unload;
+} // namespace geos.io
 }
 
 namespace geos {
@@ -72,33 +72,33 @@ namespace geom { // geos::geom
 
 /// Geometry types
 enum GeometryTypeId {
-	/// a point
-	GEOS_POINT,
-	/// a linestring
-	GEOS_LINESTRING,
-	/// a linear ring (linestring with 1st point == last point)
-	GEOS_LINEARRING,
-	/// a polygon
-	GEOS_POLYGON,
-	/// a collection of points
-	GEOS_MULTIPOINT,
-	/// a collection of linestrings
-	GEOS_MULTILINESTRING,
-	/// a collection of polygons
-	GEOS_MULTIPOLYGON,
-	/// a collection of heterogeneus geometries
-	GEOS_GEOMETRYCOLLECTION
+    /// a point
+    GEOS_POINT,
+    /// a linestring
+    GEOS_LINESTRING,
+    /// a linear ring (linestring with 1st point == last point)
+    GEOS_LINEARRING,
+    /// a polygon
+    GEOS_POLYGON,
+    /// a collection of points
+    GEOS_MULTIPOINT,
+    /// a collection of linestrings
+    GEOS_MULTILINESTRING,
+    /// a collection of polygons
+    GEOS_MULTIPOLYGON,
+    /// a collection of heterogeneus geometries
+    GEOS_GEOMETRYCOLLECTION
 };
 
 enum GeometrySortIndex {
-	SORTINDEX_POINT = 0,
-	SORTINDEX_MULTIPOINT = 1,
-	SORTINDEX_LINESTRING = 2,
-	SORTINDEX_LINEARRING = 3,
-	SORTINDEX_MULTILINESTRING = 4,
-	SORTINDEX_POLYGON = 5,
-	SORTINDEX_MULTIPOLYGON = 6,
-	SORTINDEX_GEOMETRYCOLLECTION = 7
+    SORTINDEX_POINT = 0,
+    SORTINDEX_MULTIPOINT = 1,
+    SORTINDEX_LINESTRING = 2,
+    SORTINDEX_LINEARRING = 3,
+    SORTINDEX_MULTILINESTRING = 4,
+    SORTINDEX_POLYGON = 5,
+    SORTINDEX_MULTIPOLYGON = 6,
+    SORTINDEX_GEOMETRYCOLLECTION = 7
 };
 
 /**
@@ -188,697 +188,735 @@ class GEOS_DLL Geometry {
 
 public:
 
-	friend class GeometryFactory;
-
-	/// A vector of const Geometry pointers
-	using ConstVect = std::vector<const Geometry *>;
-
-	/// A vector of non-const Geometry pointers
-	using NonConstVect = std::vector<Geometry *>;
-
-	/// An unique_ptr of Geometry
-	using Ptr = std::unique_ptr<Geometry> ;
-
-	/// Make a deep-copy of this Geometry
-	virtual Geometry* clone() const=0;
-
-	/// Destroy Geometry and all components
-	virtual ~Geometry();
-
-
-	/**
-	 * \brief
-	 * Gets the factory which contains the context in which this
-	 * geometry was created.
-	 *
-	 * @return the factory for this geometry
-	 */
-	const GeometryFactory* getFactory() const { return _factory; }
-
-	/**
-	* \brief
-	* A simple scheme for applications to add their own custom data to
-	* a Geometry.
-	* An example use might be to add an object representing a
-	* Coordinate Reference System.
-	*
-	* Note that user data objects are not present in geometries created
-	* by construction methods.
-	*
-	* @param newUserData an object, the semantics for which are
-	* defined by the application using this Geometry
-	*/
-	void setUserData(void* newUserData) { _userData=newUserData; }
-
-	/**
-	* \brief
-	* Gets the user data object for this geometry, if any.
-	*
-	* @return the user data object, or <code>null</code> if none set
-	*/
-	void* getUserData() const { return _userData; }
-
-	/*
-	 * \brief
-	 * Returns the ID of the Spatial Reference System used by the
-	 * <code>Geometry</code>.
-	 *
-	 * GEOS supports Spatial Reference System information in the simple way
-	 * defined in the SFS. A Spatial Reference System ID (SRID) is present
-	 * in each <code>Geometry</code> object. <code>Geometry</code>
-	 * provides basic accessor operations for this field, but no others.
-	 * The SRID is represented as an integer.
-	 *
-	 * @return the ID of the coordinate space in which the
-	 * <code>Geometry</code> is defined.
-	 *
-	 */
-	virtual int getSRID() const { return SRID; }
-
-	/*
-	 * Sets the ID of the Spatial Reference System used by the
-	 * <code>Geometry</code>.
-	 */
-	virtual void setSRID(int newSRID) { SRID=newSRID; }
-
-	/**
-	 * \brief
-	 * Get the PrecisionModel used to create this Geometry.
-	 */
-	const PrecisionModel* getPrecisionModel() const;
-
-	/// \brief
-	/// Returns a vertex of this Geometry,
-	/// or NULL if this is the empty geometry
-	///
-	virtual const Coordinate* getCoordinate() const=0; //Abstract
-
-	/**
-	 * \brief
-	 * Returns this Geometry vertices.
-	 * Caller takes ownership of the returned object.
-	 */
-	virtual CoordinateSequence* getCoordinates() const=0; //Abstract
-
-	/// Returns the count of this Geometrys vertices.
-	virtual std::size_t getNumPoints() const=0; //Abstract
-
-	/// Returns false if the Geometry not simple.
-	virtual bool isSimple() const;
-
-	/// Return a string representation of this Geometry type
-	virtual std::string getGeometryType() const=0; //Abstract
-
-	/// Return an integer representation of this Geometry type
-	virtual GeometryTypeId getGeometryTypeId() const=0; //Abstract
-
-	/// Returns the number of geometries in this collection
-	/// (or 1 if this is not a collection)
-	virtual std::size_t getNumGeometries() const { return 1; }
-
-	/// Returns a pointer to the nth Geometry in this collection
-	/// (or self if this is not a collection)
-	virtual const Geometry* getGeometryN(std::size_t /*n*/) const { return this; }
-
-	/**
-	 * \brief Tests the validity of this <code>Geometry</code>.
-	 *
-	 * Subclasses provide their own definition of "valid".
-	 *
-	 * @return <code>true</code> if this <code>Geometry</code> is valid
-	 *
-	 * @see IsValidOp
-	 */
-	virtual bool isValid() const;
-
-	/// Returns whether or not the set of points in this Geometry is empty.
-	virtual bool isEmpty() const=0; //Abstract
-
-	/// Polygon overrides to check for actual rectangle
-	virtual bool isRectangle() const { return false; }
-
-	/// Returns the dimension of this Geometry (0=point, 1=line, 2=surface)
-	virtual Dimension::DimensionType getDimension() const=0; //Abstract
-
-	/// Returns the coordinate dimension of this Geometry (2=XY, 3=XYZ, 4=XYZM in future).
-	virtual int getCoordinateDimension() const=0; //Abstract
-
-	/**
-	 * \brief
-	 * Returns the boundary, or an empty geometry of appropriate
-	 * dimension if this <code>Geometry</code>  is empty.
-	 *
-	 * (In the case of zero-dimensional geometries,
-	 * an empty GeometryCollection is returned.)
-	 * For a discussion of this function, see the OpenGIS Simple
-	 * Features Specification. As stated in SFS Section 2.1.13.1,
-	 * "the boundary of a Geometry is a set of Geometries of the
-	 * next lower dimension."
-	 *
-	 * @return  the closure of the combinatorial boundary
-	 *          of this <code>Geometry</code>.
-	 *          Ownershipof the returned object transferred to caller.
-	 */
-	virtual Geometry* getBoundary() const=0; //Abstract
-
-	/// Returns the dimension of this Geometrys inherent boundary.
-	virtual int getBoundaryDimension() const=0; //Abstract
-
-	/// Returns this Geometrys bounding box.
-	virtual Geometry* getEnvelope() const;
-
-	/** \brief
-	 * Returns the minimum and maximum x and y values in this Geometry,
-	 * or a null Envelope if this Geometry is empty.
-	 */
-	virtual const Envelope* getEnvelopeInternal() const;
-
-	/**
-	 * Tests whether this geometry is disjoint from the specified geometry.
-	 *
-	 * The <code>disjoint</code> predicate has the following equivalent
-	 * definitions:
-	 *  - The two geometries have no point in common
-	 *  - The DE-9IM Intersection Matrix for the two geometries matches
-	 *    <code>[FF*FF****]</code>
-	 *  - <code>! g.intersects(this)</code>
-	 *    (<code>disjoint</code> is the inverse of <code>intersects</code>)
-	 *
-	 * @param  g  the Geometry with which to compare this Geometry
-	 * @return true if the two <code>Geometry</code>s are disjoint
-	 *
-	 * @see Geometry::intersects
-	 */
-	virtual bool disjoint(const Geometry *other) const;
-
-	/** \brief
-	 * Returns true if the DE-9IM intersection matrix for the two
-	 * Geometrys is FT*******, F**T***** or F***T****.
-	 */
-	virtual bool touches(const Geometry *other) const;
-
-	/// Returns true if disjoint returns false.
-	virtual bool intersects(const Geometry *g) const;
-
-	/**
-	 * Tests whether this geometry crosses the specified geometry.
-	 *
-	 * The <code>crosses</code> predicate has the following equivalent
-	 * definitions:
-	 *  - The geometries have some but not all interior points in common.
-	 *  - The DE-9IM Intersection Matrix for the two geometries matches
-	 *    - <code>[T*T******]</code> (for P/L, P/A, and L/A situations)
-	 *    - <code>[T*****T**]</code> (for L/P, A/P, and A/L situations)
-	 *    - <code>[0********]</code> (for L/L situations)
-	 * For any other combination of dimensions this predicate returns
-	 * <code>false</code>.
-	 *
-	 * The SFS defined this predicate only for P/L, P/A, L/L, and L/A
-	 * situations.
-	 * JTS extends the definition to apply to L/P, A/P and A/L situations
-	 * as well, in order to make the relation symmetric.
-	 *
-	 * @param  g  the <code>Geometry</code> with which to compare this
-	 *            <code>Geometry</code>
-	 *@return  <code>true</code> if the two <code>Geometry</code>s cross.
-	 */
-	virtual bool crosses(const Geometry *g) const;
-
-	/** \brief
-	 * Returns true if the DE-9IM intersection matrix for the two
-	 * Geometrys is T*F**F***.
-	 */
-	virtual bool within(const Geometry *g) const;
-
-	/// Returns true if other.within(this) returns true.
-	virtual bool contains(const Geometry *g) const;
-
-	/** \brief
-	 * Returns true if the DE-9IM intersection matrix for the two
-	 * Geometrys is T*T***T** (for two points or two surfaces)
-	 * 1*T***T** (for two curves).
-	 */
-	virtual bool overlaps(const Geometry *g) const;
-
-	/**
-	 * \brief
-	 * Returns true if the elements in the DE-9IM intersection matrix
-	 * for the two Geometrys match the elements in intersectionPattern.
-	 *
-	 * IntersectionPattern elements may be: 0 1 2 T ( = 0, 1 or 2)
-	 * F ( = -1) * ( = -1, 0, 1 or 2).
-	 *
-	 * For more information on the DE-9IM, see the OpenGIS Simple
-	 * Features Specification.
-	 *
-	 * @throws util::IllegalArgumentException if either arg is a collection
-	 *
-	 */
-	virtual bool relate(const Geometry *g,
-			const std::string& intersectionPattern) const;
-
-	bool relate(const Geometry& g, const std::string& intersectionPattern) const
-	{
-		return relate(&g, intersectionPattern);
-	}
-
-	/// Returns the DE-9IM intersection matrix for the two Geometrys.
-	virtual IntersectionMatrix* relate(const Geometry *g) const;
-	IntersectionMatrix* relate(const Geometry &g) const {
-		return relate(&g);
-	}
-
-	/**
-	 * \brief
-	 * Returns true if the DE-9IM intersection matrix for the two
-	 * Geometrys is T*F**FFF*.
-	 */
-	virtual bool equals(const Geometry *g) const;
-
-	/** \brief
-	 * Returns <code>true</code> if this geometry covers the
-	 * specified geometry.
-	 *
-	 * The <code>covers</code> predicate has the following
-	 * equivalent definitions:
-	 *
-	 * - Every point of the other geometry is a point of this geometry.
-	 * - The DE-9IM Intersection Matrix for the two geometries is
-	 *    <code>T*****FF*</code>
-	 *    or <code>*T****FF*</code>
-	 *    or <code>***T**FF*</code>
-	 *    or <code>****T*FF*</code>
-	 * - <code>g.coveredBy(this)</code>
-	 *   (<code>covers</code> is the inverse of <code>coveredBy</code>)
-	 *
-	 * If either geometry is empty, the value of this predicate
-	 * is <tt>false</tt>.
-	 *
-	 * This predicate is similar to {@link #contains},
-	 * but is more inclusive (i.e. returns <tt>true</tt> for more cases).
-	 * In particular, unlike <code>contains</code> it does not distinguish
-	 * between points in the boundary and in the interior of geometries.
-	 * For most situations, <code>covers</code> should be used in
-	 * preference to <code>contains</code>.
-	 * As an added benefit, <code>covers</code> is more amenable to
-	 * optimization, and hence should be more performant.
-	 *
-	 * @param  g
-	 *         the <code>Geometry</code> with which to compare this
-	 *         <code>Geometry</code>
-	 *
-	 * @return <code>true</code> if this <code>Geometry</code>
-	 *                           covers <code>g</code>
-	 *
-	 * @see Geometry::contains
-	 * @see Geometry::coveredBy
-	 */
-	bool covers(const Geometry* g) const;
-
-	/** \brief
-	 * Tests whether this geometry is covered by the
-	 * specified geometry.
-	 *
-	 * The <code>coveredBy</code> predicate has the following
-	 * equivalent definitions:
-	 *
-	 *  - Every point of this geometry is a point of the other geometry.
-	 *  - The DE-9IM Intersection Matrix for the two geometries matches
-	 *       <code>[T*F**F***]</code>
-	 *    or <code>[*TF**F***]</code>
-	 *    or <code>[**FT*F***]</code>
-	 *    or <code>[**F*TF***]</code>
-	 *  - <code>g.covers(this)</code>
-	 *    (<code>coveredBy</code> is the converse of <code>covers</code>)
-	 *
-	 * If either geometry is empty, the value of this predicate
-	 * is <tt>false</tt>.
-	 *
-	 * This predicate is similar to {@link #within},
-	 * but is more inclusive (i.e. returns <tt>true</tt> for more cases).
-	 *
-	 * @param  g  the <code>Geometry</code> with which to compare
-	 *            this <code>Geometry</code>
-	 * @return  <code>true</code> if this <code>Geometry</code>
-	 *                            is covered by <code>g</code>
-	 *
-	 * @see Geometry#within
-	 * @see Geometry#covers
-	 */
-	bool coveredBy(const Geometry* g) const {
-	  return g->covers(this);
-	}
-
-
-	/// Returns the Well-known Text representation of this Geometry.
-	virtual std::string toString() const;
-
-	virtual std::string toText() const;
-
-	/// Returns a buffer region around this Geometry having the given width.
-	//
-	/// @throws util::TopologyException if a robustness error occurs
-	///
-	virtual Geometry* buffer(double distance) const;
-
-	/// \brief
-	/// Returns a buffer region around this Geometry having the
-	/// given width and with a specified number of segments used
-	/// to approximate curves.
-	//
-	/// @throws util::TopologyException if a robustness error occurs
-	///
-	virtual Geometry* buffer(double distance,int quadrantSegments) const;
-
-	/** \brief
-	 * Computes a buffer area around this geometry having the given
-	 * width and with a specified accuracy of approximation for circular
-	 * arcs, and using a specified end cap style.
-	 *
-	 * Buffer area boundaries can contain circular arcs.
-	 * To represent these arcs using linear geometry they must be
-	 * approximated with line segments.
-	 *
-	 * The <code>quadrantSegments</code> argument allows controlling the
-	 * accuracy of the approximation by specifying the number of line
-	 * segments used to represent a quadrant of a circle
-	 *
-	 * The end cap style specifies the buffer geometry that will be
-	 * created at the ends of linestrings.  The styles provided are:
-	 *
-	 * - BufferOp::CAP_ROUND - (default) a semi-circle
-	 * - BufferOp::CAP_BUTT  - a straight line perpendicular to the
-	 *                         end segment
-	 * - BufferOp::CAP_SQUARE - a half-square
-	 *
-	 *
-	 * @param distance the width of the buffer
-	 *                 (may be positive, negative or 0)
-	 *
-	 * @param quadrantSegments the number of line segments used
-	 *                         to represent a quadrant of a circle
-	 *
-	 * @param endCapStyle the end cap style to use
-	 *
-	 * @return an area geometry representing the buffer region
-	 *
-	 * @throws util::TopologyException if a robustness error occurs
-	 *
-	 * @see BufferOp
-	 */
-	virtual Geometry* buffer(double distance, int quadrantSegments,
-			int endCapStyle) const;
-
-	/// \brief
-	/// Returns the smallest convex Polygon that contains
-	/// all the points in the Geometry.
-	virtual Geometry* convexHull() const;
-
-	/**
+    friend class GeometryFactory;
+
+    /// A vector of const Geometry pointers
+    using ConstVect = std::vector<const Geometry*>;
+
+    /// A vector of non-const Geometry pointers
+    using NonConstVect = std::vector<Geometry*>;
+
+    /// An unique_ptr of Geometry
+    using Ptr = std::unique_ptr<Geometry> ;
+
+    /// Make a deep-copy of this Geometry
+    virtual Geometry* clone() const = 0;
+
+    /// Destroy Geometry and all components
+    virtual ~Geometry();
+
+
+    /**
+     * \brief
+     * Gets the factory which contains the context in which this
+     * geometry was created.
+     *
+     * @return the factory for this geometry
+     */
+    const GeometryFactory*
+    getFactory() const
+    {
+        return _factory;
+    }
+
+    /**
+    * \brief
+    * A simple scheme for applications to add their own custom data to
+    * a Geometry.
+    * An example use might be to add an object representing a
+    * Coordinate Reference System.
+    *
+    * Note that user data objects are not present in geometries created
+    * by construction methods.
+    *
+    * @param newUserData an object, the semantics for which are
+    * defined by the application using this Geometry
+    */
+    void
+    setUserData(void* newUserData)
+    {
+        _userData = newUserData;
+    }
+
+    /**
+    * \brief
+    * Gets the user data object for this geometry, if any.
+    *
+    * @return the user data object, or <code>null</code> if none set
+    */
+    void*
+    getUserData() const
+    {
+        return _userData;
+    }
+
+    /*
+     * \brief
+     * Returns the ID of the Spatial Reference System used by the
+     * <code>Geometry</code>.
+     *
+     * GEOS supports Spatial Reference System information in the simple way
+     * defined in the SFS. A Spatial Reference System ID (SRID) is present
+     * in each <code>Geometry</code> object. <code>Geometry</code>
+     * provides basic accessor operations for this field, but no others.
+     * The SRID is represented as an integer.
+     *
+     * @return the ID of the coordinate space in which the
+     * <code>Geometry</code> is defined.
+     *
+     */
+    virtual int
+    getSRID() const
+    {
+        return SRID;
+    }
+
+    /*
+     * Sets the ID of the Spatial Reference System used by the
+     * <code>Geometry</code>.
+     */
+    virtual void
+    setSRID(int newSRID)
+    {
+        SRID = newSRID;
+    }
+
+    /**
+     * \brief
+     * Get the PrecisionModel used to create this Geometry.
+     */
+    const PrecisionModel* getPrecisionModel() const;
+
+    /// \brief
+    /// Returns a vertex of this Geometry,
+    /// or NULL if this is the empty geometry
+    ///
+    virtual const Coordinate* getCoordinate() const = 0; //Abstract
+
+    /**
+     * \brief
+     * Returns this Geometry vertices.
+     * Caller takes ownership of the returned object.
+     */
+    virtual CoordinateSequence* getCoordinates() const = 0; //Abstract
+
+    /// Returns the count of this Geometrys vertices.
+    virtual std::size_t getNumPoints() const = 0; //Abstract
+
+    /// Returns false if the Geometry not simple.
+    virtual bool isSimple() const;
+
+    /// Return a string representation of this Geometry type
+    virtual std::string getGeometryType() const = 0; //Abstract
+
+    /// Return an integer representation of this Geometry type
+    virtual GeometryTypeId getGeometryTypeId() const = 0; //Abstract
+
+    /// Returns the number of geometries in this collection
+    /// (or 1 if this is not a collection)
+    virtual std::size_t
+    getNumGeometries() const
+    {
+        return 1;
+    }
+
+    /// Returns a pointer to the nth Geometry in this collection
+    /// (or self if this is not a collection)
+    virtual const Geometry*
+    getGeometryN(std::size_t /*n*/) const
+    {
+        return this;
+    }
+
+    /**
+     * \brief Tests the validity of this <code>Geometry</code>.
+     *
+     * Subclasses provide their own definition of "valid".
+     *
+     * @return <code>true</code> if this <code>Geometry</code> is valid
+     *
+     * @see IsValidOp
+     */
+    virtual bool isValid() const;
+
+    /// Returns whether or not the set of points in this Geometry is empty.
+    virtual bool isEmpty() const = 0; //Abstract
+
+    /// Polygon overrides to check for actual rectangle
+    virtual bool
+    isRectangle() const
+    {
+        return false;
+    }
+
+    /// Returns the dimension of this Geometry (0=point, 1=line, 2=surface)
+    virtual Dimension::DimensionType getDimension() const = 0; //Abstract
+
+    /// Returns the coordinate dimension of this Geometry (2=XY, 3=XYZ, 4=XYZM in future).
+    virtual int getCoordinateDimension() const = 0; //Abstract
+
+    /**
+     * \brief
+     * Returns the boundary, or an empty geometry of appropriate
+     * dimension if this <code>Geometry</code>  is empty.
+     *
+     * (In the case of zero-dimensional geometries,
+     * an empty GeometryCollection is returned.)
+     * For a discussion of this function, see the OpenGIS Simple
+     * Features Specification. As stated in SFS Section 2.1.13.1,
+     * "the boundary of a Geometry is a set of Geometries of the
+     * next lower dimension."
+     *
+     * @return  the closure of the combinatorial boundary
+     *          of this <code>Geometry</code>.
+     *          Ownershipof the returned object transferred to caller.
+     */
+    virtual Geometry* getBoundary() const = 0; //Abstract
+
+    /// Returns the dimension of this Geometrys inherent boundary.
+    virtual int getBoundaryDimension() const = 0; //Abstract
+
+    /// Returns this Geometrys bounding box.
+    virtual Geometry* getEnvelope() const;
+
+    /** \brief
+     * Returns the minimum and maximum x and y values in this Geometry,
+     * or a null Envelope if this Geometry is empty.
+     */
+    virtual const Envelope* getEnvelopeInternal() const;
+
+    /**
+     * Tests whether this geometry is disjoint from the specified geometry.
+     *
+     * The <code>disjoint</code> predicate has the following equivalent
+     * definitions:
+     *  - The two geometries have no point in common
+     *  - The DE-9IM Intersection Matrix for the two geometries matches
+     *    <code>[FF*FF****]</code>
+     *  - <code>! g.intersects(this)</code>
+     *    (<code>disjoint</code> is the inverse of <code>intersects</code>)
+     *
+     * @param  g  the Geometry with which to compare this Geometry
+     * @return true if the two <code>Geometry</code>s are disjoint
+     *
+     * @see Geometry::intersects
+     */
+    virtual bool disjoint(const Geometry* other) const;
+
+    /** \brief
+     * Returns true if the DE-9IM intersection matrix for the two
+     * Geometrys is FT*******, F**T***** or F***T****.
+     */
+    virtual bool touches(const Geometry* other) const;
+
+    /// Returns true if disjoint returns false.
+    virtual bool intersects(const Geometry* g) const;
+
+    /**
+     * Tests whether this geometry crosses the specified geometry.
+     *
+     * The <code>crosses</code> predicate has the following equivalent
+     * definitions:
+     *  - The geometries have some but not all interior points in common.
+     *  - The DE-9IM Intersection Matrix for the two geometries matches
+     *    - <code>[T*T******]</code> (for P/L, P/A, and L/A situations)
+     *    - <code>[T*****T**]</code> (for L/P, A/P, and A/L situations)
+     *    - <code>[0********]</code> (for L/L situations)
+     * For any other combination of dimensions this predicate returns
+     * <code>false</code>.
+     *
+     * The SFS defined this predicate only for P/L, P/A, L/L, and L/A
+     * situations.
+     * JTS extends the definition to apply to L/P, A/P and A/L situations
+     * as well, in order to make the relation symmetric.
+     *
+     * @param  g  the <code>Geometry</code> with which to compare this
+     *            <code>Geometry</code>
+     *@return  <code>true</code> if the two <code>Geometry</code>s cross.
+     */
+    virtual bool crosses(const Geometry* g) const;
+
+    /** \brief
+     * Returns true if the DE-9IM intersection matrix for the two
+     * Geometrys is T*F**F***.
+     */
+    virtual bool within(const Geometry* g) const;
+
+    /// Returns true if other.within(this) returns true.
+    virtual bool contains(const Geometry* g) const;
+
+    /** \brief
+     * Returns true if the DE-9IM intersection matrix for the two
+     * Geometrys is T*T***T** (for two points or two surfaces)
+     * 1*T***T** (for two curves).
+     */
+    virtual bool overlaps(const Geometry* g) const;
+
+    /**
+     * \brief
+     * Returns true if the elements in the DE-9IM intersection matrix
+     * for the two Geometrys match the elements in intersectionPattern.
+     *
+     * IntersectionPattern elements may be: 0 1 2 T ( = 0, 1 or 2)
+     * F ( = -1) * ( = -1, 0, 1 or 2).
+     *
+     * For more information on the DE-9IM, see the OpenGIS Simple
+     * Features Specification.
+     *
+     * @throws util::IllegalArgumentException if either arg is a collection
+     *
+     */
+    virtual bool relate(const Geometry* g,
+                        const std::string& intersectionPattern) const;
+
+    bool
+    relate(const Geometry& g, const std::string& intersectionPattern) const
+    {
+        return relate(&g, intersectionPattern);
+    }
+
+    /// Returns the DE-9IM intersection matrix for the two Geometrys.
+    virtual IntersectionMatrix* relate(const Geometry* g) const;
+    IntersectionMatrix*
+    relate(const Geometry& g) const
+    {
+        return relate(&g);
+    }
+
+    /**
+     * \brief
+     * Returns true if the DE-9IM intersection matrix for the two
+     * Geometrys is T*F**FFF*.
+     */
+    virtual bool equals(const Geometry* g) const;
+
+    /** \brief
+     * Returns <code>true</code> if this geometry covers the
+     * specified geometry.
+     *
+     * The <code>covers</code> predicate has the following
+     * equivalent definitions:
+     *
+     * - Every point of the other geometry is a point of this geometry.
+     * - The DE-9IM Intersection Matrix for the two geometries is
+     *    <code>T*****FF*</code>
+     *    or <code>*T****FF*</code>
+     *    or <code>***T**FF*</code>
+     *    or <code>****T*FF*</code>
+     * - <code>g.coveredBy(this)</code>
+     *   (<code>covers</code> is the inverse of <code>coveredBy</code>)
+     *
+     * If either geometry is empty, the value of this predicate
+     * is <tt>false</tt>.
+     *
+     * This predicate is similar to {@link #contains},
+     * but is more inclusive (i.e. returns <tt>true</tt> for more cases).
+     * In particular, unlike <code>contains</code> it does not distinguish
+     * between points in the boundary and in the interior of geometries.
+     * For most situations, <code>covers</code> should be used in
+     * preference to <code>contains</code>.
+     * As an added benefit, <code>covers</code> is more amenable to
+     * optimization, and hence should be more performant.
+     *
+     * @param  g
+     *         the <code>Geometry</code> with which to compare this
+     *         <code>Geometry</code>
+     *
+     * @return <code>true</code> if this <code>Geometry</code>
+     *                           covers <code>g</code>
+     *
+     * @see Geometry::contains
+     * @see Geometry::coveredBy
+     */
+    bool covers(const Geometry* g) const;
+
+    /** \brief
+     * Tests whether this geometry is covered by the
+     * specified geometry.
+     *
+     * The <code>coveredBy</code> predicate has the following
+     * equivalent definitions:
+     *
+     *  - Every point of this geometry is a point of the other geometry.
+     *  - The DE-9IM Intersection Matrix for the two geometries matches
+     *       <code>[T*F**F***]</code>
+     *    or <code>[*TF**F***]</code>
+     *    or <code>[**FT*F***]</code>
+     *    or <code>[**F*TF***]</code>
+     *  - <code>g.covers(this)</code>
+     *    (<code>coveredBy</code> is the converse of <code>covers</code>)
+     *
+     * If either geometry is empty, the value of this predicate
+     * is <tt>false</tt>.
+     *
+     * This predicate is similar to {@link #within},
+     * but is more inclusive (i.e. returns <tt>true</tt> for more cases).
+     *
+     * @param  g  the <code>Geometry</code> with which to compare
+     *            this <code>Geometry</code>
+     * @return  <code>true</code> if this <code>Geometry</code>
+     *                            is covered by <code>g</code>
+     *
+     * @see Geometry#within
+     * @see Geometry#covers
+     */
+    bool
+    coveredBy(const Geometry* g) const
+    {
+        return g->covers(this);
+    }
+
+
+    /// Returns the Well-known Text representation of this Geometry.
+    virtual std::string toString() const;
+
+    virtual std::string toText() const;
+
+    /// Returns a buffer region around this Geometry having the given width.
+    //
+    /// @throws util::TopologyException if a robustness error occurs
+    ///
+    virtual Geometry* buffer(double distance) const;
+
+    /// \brief
+    /// Returns a buffer region around this Geometry having the
+    /// given width and with a specified number of segments used
+    /// to approximate curves.
+    //
+    /// @throws util::TopologyException if a robustness error occurs
+    ///
+    virtual Geometry* buffer(double distance, int quadrantSegments) const;
+
+    /** \brief
+     * Computes a buffer area around this geometry having the given
+     * width and with a specified accuracy of approximation for circular
+     * arcs, and using a specified end cap style.
+     *
+     * Buffer area boundaries can contain circular arcs.
+     * To represent these arcs using linear geometry they must be
+     * approximated with line segments.
+     *
+     * The <code>quadrantSegments</code> argument allows controlling the
+     * accuracy of the approximation by specifying the number of line
+     * segments used to represent a quadrant of a circle
+     *
+     * The end cap style specifies the buffer geometry that will be
+     * created at the ends of linestrings.  The styles provided are:
+     *
+     * - BufferOp::CAP_ROUND - (default) a semi-circle
+     * - BufferOp::CAP_BUTT  - a straight line perpendicular to the
+     *                         end segment
+     * - BufferOp::CAP_SQUARE - a half-square
+     *
+     *
+     * @param distance the width of the buffer
+     *                 (may be positive, negative or 0)
+     *
+     * @param quadrantSegments the number of line segments used
+     *                         to represent a quadrant of a circle
+     *
+     * @param endCapStyle the end cap style to use
+     *
+     * @return an area geometry representing the buffer region
+     *
+     * @throws util::TopologyException if a robustness error occurs
+     *
+     * @see BufferOp
+     */
+    virtual Geometry* buffer(double distance, int quadrantSegments,
+                             int endCapStyle) const;
+
+    /// \brief
+    /// Returns the smallest convex Polygon that contains
+    /// all the points in the Geometry.
+    virtual Geometry* convexHull() const;
+
+    /**
      * Computes a new geometry which has all component coordinate sequences
      * in reverse order (opposite orientation) to this one.
      *
      * @return a reversed geometry
      */
-	virtual Geometry* reverse() const=0;
-
-	/** \brief
-	 * Returns a Geometry representing the points shared by
-	 * this Geometry and other.
-	 *
-	 * @throws util::TopologyException if a robustness error occurs
-	 * @throws util::IllegalArgumentException if either input is a
-	 *         non-empty GeometryCollection
-	 *
-	 */
-	virtual Geometry* intersection(const Geometry *other) const;
-
-	/** \brief
-	 * Returns a Geometry representing all the points in this Geometry
-	 * and other.
-	 *
-	 * @throws util::TopologyException if a robustness error occurs
-	 * @throws util::IllegalArgumentException if either input is a
-	 *         non-empty GeometryCollection
-	 *
-	 */
-	Geometry* Union(const Geometry *other) const;
-		// throw(IllegalArgumentException *, TopologyException *);
-
-  /**
-   * Computes the union of all the elements of this geometry. Heterogeneous
-   * {@link GeometryCollection}s are fully supported.
-   *
-   * The result obeys the following contract:
-   *
-   * - Unioning a set of {@link LineString}s has the effect of fully noding
-   *   and dissolving the linework.
-   * - Unioning a set of {@link Polygon}s will always
-   *   return a {@link Polygonal} geometry (unlike {link #union(Geometry)},
-   *   which may return geometrys of lower dimension if a topology collapse
-   *   occurred.
-   *
-   * @return the union geometry
-   *
-   * @see UnaryUnionOp
-   */
-  Ptr Union() const;
-		// throw(IllegalArgumentException *, TopologyException *);
-
-	/**
-	 * \brief
-	 * Returns a Geometry representing the points making up this
-	 * Geometry that do not make up other.
-	 *
-	 * @throws util::TopologyException if a robustness error occurs
-	 * @throws util::IllegalArgumentException if either input is a
-	 *         non-empty GeometryCollection
-	 *
-	 */
-	virtual Geometry* difference(const Geometry *other) const;
-
-	/** \brief
-	 * Returns a set combining the points in this Geometry not in other,
-	 * and the points in other not in this Geometry.
-	 *
-	 * @throws util::TopologyException if a robustness error occurs
-	 * @throws util::IllegalArgumentException if either input is a
-	 *         non-empty GeometryCollection
-	 *
-	 */
-	virtual Geometry* symDifference(const Geometry *other) const;
-
-	/** \brief
-	 * Returns true iff the two Geometrys are of the same type and their
-	 * vertices corresponding by index are equal up to a specified tolerance.
-	 */
-	virtual bool equalsExact(const Geometry *other, double tolerance=0)
-		const=0; //Abstract
-
-	virtual void apply_rw(const CoordinateFilter *filter)=0; //Abstract
-	virtual void apply_ro(CoordinateFilter *filter) const=0; //Abstract
-	virtual void apply_rw(GeometryFilter *filter);
-	virtual void apply_ro(GeometryFilter *filter) const;
-	virtual void apply_rw(GeometryComponentFilter *filter);
-	virtual void apply_ro(GeometryComponentFilter *filter) const;
-
-	/**
-	 *  Performs an operation on the coordinates in this Geometry's
-	 *  CoordinateSequences.
-	 *  If the filter reports that a coordinate value has been changed,
-	 *  {@link #geometryChanged} will be called automatically.
-	 *
-	 * @param  filter  the filter to apply
-	 */
-	virtual void apply_rw(CoordinateSequenceFilter& filter)=0;
-
-	/**
-	 *  Performs a read-only operation on the coordinates in this
-	 *  Geometry's CoordinateSequences.
-	 *
-	 * @param  filter  the filter to apply
-	 */
-	virtual void apply_ro(CoordinateSequenceFilter& filter) const=0;
-
-	/** \brief
-	 * Apply a fiter to each component of this geometry.
-	 * The filter is expected to provide a .filter(const Geometry*)
-	 * method.
-	 *
-	 * I intend similar templated methods to replace
-	 * all the virtual apply_rw and apply_ro functions...
-	 *                --strk(2005-02-06);
-	 */
-	template <class T>
-	void applyComponentFilter(T& f) const
-	{
-		for(std::size_t i=0, n=getNumGeometries(); i<n; ++i)
-			f.filter(getGeometryN(i));
-	}
-
-	/// Converts this Geometry to normal form (or  canonical form).
-	virtual void normalize()=0; //Abstract
-
-	virtual int compareTo(const Geometry *geom) const;
-
-	/** \brief
-	 * Returns the minimum distance between this Geometry
-	 * and the Geometry g
-	 */
-	virtual double distance(const Geometry *g) const;
-
-	/// Returns the area of this Geometry.
-	virtual double getArea() const;
-
-	/// Returns the length of this Geometry.
-	virtual double getLength() const;
-
-	/** \brief
-	 * Tests whether the distance from this Geometry  to another
-	 * is less than or equal to a specified value.
-	 *
-	 * @param geom the Geometry to check the distance to
-	 * @param cDistance the distance value to compare
-	 * @return <code>true</code> if the geometries are less than
-	 *  <code>distance</code> apart.
-	 *
-	 * @todo doesn't seem to need being virtual, make it concrete
-	 */
-	virtual bool isWithinDistance(const Geometry *geom,
-			double cDistance) const;
-
-	/** \brief
-	 * Computes the centroid of this <code>Geometry</code>.
-	 *
-	 * The centroid is equal to the centroid of the set of component
-	 * Geometries of highest dimension (since the lower-dimension geometries
-	 * contribute zero "weight" to the centroid)
-	 *
-	 * @return a {@link Point} which is the centroid of this Geometry
-	 */
-	virtual Point* getCentroid() const;
-
-	/// Computes the centroid of this Geometry as a Coordinate
-	//
-	/// Returns false if centroid cannot be computed (EMPTY geometry)
-	///
-	virtual bool getCentroid(Coordinate& ret) const;
-
-	/** \brief
-	 * Computes an interior point of this <code>Geometry</code>.
-	 *
-	 * An interior point is guaranteed to lie in the interior of the Geometry,
-	 * if it possible to calculate such a point exactly. Otherwise,
-	 * the point may lie on the boundary of the geometry.
-	 *
-	 * @return a Point which is in the interior of this Geometry, or
-	 *         null if the geometry doesn't have an interior (empty)
-	 */
-	virtual Point* getInteriorPoint() const;
-
-	/*
-	 * \brief
-	 * Notifies this Geometry that its Coordinates have been changed
-	 * by an external party (using a CoordinateFilter, for example).
-	 */
-	virtual void geometryChanged();
-
-	/**
-	 * \brief
-	 * Notifies this Geometry that its Coordinates have been changed
-	 * by an external party.
-	 */
-	void geometryChangedAction();
+    virtual Geometry* reverse() const = 0;
+
+    /** \brief
+     * Returns a Geometry representing the points shared by
+     * this Geometry and other.
+     *
+     * @throws util::TopologyException if a robustness error occurs
+     * @throws util::IllegalArgumentException if either input is a
+     *         non-empty GeometryCollection
+     *
+     */
+    virtual Geometry* intersection(const Geometry* other) const;
+
+    /** \brief
+     * Returns a Geometry representing all the points in this Geometry
+     * and other.
+     *
+     * @throws util::TopologyException if a robustness error occurs
+     * @throws util::IllegalArgumentException if either input is a
+     *         non-empty GeometryCollection
+     *
+     */
+    Geometry* Union(const Geometry* other) const;
+    // throw(IllegalArgumentException *, TopologyException *);
+
+    /**
+     * Computes the union of all the elements of this geometry. Heterogeneous
+     * {@link GeometryCollection}s are fully supported.
+     *
+     * The result obeys the following contract:
+     *
+     * - Unioning a set of {@link LineString}s has the effect of fully noding
+     *   and dissolving the linework.
+     * - Unioning a set of {@link Polygon}s will always
+     *   return a {@link Polygonal} geometry (unlike {link #union(Geometry)},
+     *   which may return geometrys of lower dimension if a topology collapse
+     *   occurred.
+     *
+     * @return the union geometry
+     *
+     * @see UnaryUnionOp
+     */
+    Ptr Union() const;
+    // throw(IllegalArgumentException *, TopologyException *);
+
+    /**
+     * \brief
+     * Returns a Geometry representing the points making up this
+     * Geometry that do not make up other.
+     *
+     * @throws util::TopologyException if a robustness error occurs
+     * @throws util::IllegalArgumentException if either input is a
+     *         non-empty GeometryCollection
+     *
+     */
+    virtual Geometry* difference(const Geometry* other) const;
+
+    /** \brief
+     * Returns a set combining the points in this Geometry not in other,
+     * and the points in other not in this Geometry.
+     *
+     * @throws util::TopologyException if a robustness error occurs
+     * @throws util::IllegalArgumentException if either input is a
+     *         non-empty GeometryCollection
+     *
+     */
+    virtual Geometry* symDifference(const Geometry* other) const;
+
+    /** \brief
+     * Returns true iff the two Geometrys are of the same type and their
+     * vertices corresponding by index are equal up to a specified tolerance.
+     */
+    virtual bool equalsExact(const Geometry* other, double tolerance = 0)
+    const = 0; //Abstract
+
+    virtual void apply_rw(const CoordinateFilter* filter) = 0; //Abstract
+    virtual void apply_ro(CoordinateFilter* filter) const = 0; //Abstract
+    virtual void apply_rw(GeometryFilter* filter);
+    virtual void apply_ro(GeometryFilter* filter) const;
+    virtual void apply_rw(GeometryComponentFilter* filter);
+    virtual void apply_ro(GeometryComponentFilter* filter) const;
+
+    /**
+     *  Performs an operation on the coordinates in this Geometry's
+     *  CoordinateSequences.
+     *  If the filter reports that a coordinate value has been changed,
+     *  {@link #geometryChanged} will be called automatically.
+     *
+     * @param  filter  the filter to apply
+     */
+    virtual void apply_rw(CoordinateSequenceFilter& filter) = 0;
+
+    /**
+     *  Performs a read-only operation on the coordinates in this
+     *  Geometry's CoordinateSequences.
+     *
+     * @param  filter  the filter to apply
+     */
+    virtual void apply_ro(CoordinateSequenceFilter& filter) const = 0;
+
+    /** \brief
+     * Apply a fiter to each component of this geometry.
+     * The filter is expected to provide a .filter(const Geometry*)
+     * method.
+     *
+     * I intend similar templated methods to replace
+     * all the virtual apply_rw and apply_ro functions...
+     *                --strk(2005-02-06);
+     */
+    template <class T>
+    void
+    applyComponentFilter(T& f) const
+    {
+        for(std::size_t i = 0, n = getNumGeometries(); i < n; ++i) {
+            f.filter(getGeometryN(i));
+        }
+    }
+
+    /// Converts this Geometry to normal form (or  canonical form).
+    virtual void normalize() = 0; //Abstract
+
+    virtual int compareTo(const Geometry* geom) const;
+
+    /** \brief
+     * Returns the minimum distance between this Geometry
+     * and the Geometry g
+     */
+    virtual double distance(const Geometry* g) const;
+
+    /// Returns the area of this Geometry.
+    virtual double getArea() const;
+
+    /// Returns the length of this Geometry.
+    virtual double getLength() const;
+
+    /** \brief
+     * Tests whether the distance from this Geometry  to another
+     * is less than or equal to a specified value.
+     *
+     * @param geom the Geometry to check the distance to
+     * @param cDistance the distance value to compare
+     * @return <code>true</code> if the geometries are less than
+     *  <code>distance</code> apart.
+     *
+     * @todo doesn't seem to need being virtual, make it concrete
+     */
+    virtual bool isWithinDistance(const Geometry* geom,
+                                  double cDistance) const;
+
+    /** \brief
+     * Computes the centroid of this <code>Geometry</code>.
+     *
+     * The centroid is equal to the centroid of the set of component
+     * Geometries of highest dimension (since the lower-dimension geometries
+     * contribute zero "weight" to the centroid)
+     *
+     * @return a {@link Point} which is the centroid of this Geometry
+     */
+    virtual Point* getCentroid() const;
+
+    /// Computes the centroid of this Geometry as a Coordinate
+    //
+    /// Returns false if centroid cannot be computed (EMPTY geometry)
+    ///
+    virtual bool getCentroid(Coordinate& ret) const;
+
+    /** \brief
+     * Computes an interior point of this <code>Geometry</code>.
+     *
+     * An interior point is guaranteed to lie in the interior of the Geometry,
+     * if it possible to calculate such a point exactly. Otherwise,
+     * the point may lie on the boundary of the geometry.
+     *
+     * @return a Point which is in the interior of this Geometry, or
+     *         null if the geometry doesn't have an interior (empty)
+     */
+    virtual Point* getInteriorPoint() const;
+
+    /*
+     * \brief
+     * Notifies this Geometry that its Coordinates have been changed
+     * by an external party (using a CoordinateFilter, for example).
+     */
+    virtual void geometryChanged();
+
+    /**
+     * \brief
+     * Notifies this Geometry that its Coordinates have been changed
+     * by an external party.
+     */
+    void geometryChangedAction();
 
 protected:
 
-	/// The bounding box of this Geometry
-	mutable std::unique_ptr<Envelope> envelope;
+    /// The bounding box of this Geometry
+    mutable std::unique_ptr<Envelope> envelope;
 
-	/// Returns true if the array contains any non-empty Geometrys.
-	static bool hasNonEmptyElements(const std::vector<Geometry *>* geometries);
+    /// Returns true if the array contains any non-empty Geometrys.
+    static bool hasNonEmptyElements(const std::vector<Geometry*>* geometries);
 
-	/// Returns true if the CoordinateSequence contains any null elements.
-	static bool hasNullElements(const CoordinateSequence* list);
+    /// Returns true if the CoordinateSequence contains any null elements.
+    static bool hasNullElements(const CoordinateSequence* list);
 
-	/// Returns true if the vector contains any null elements.
-	static bool hasNullElements(const std::vector<Geometry *>* lrs);
+    /// Returns true if the vector contains any null elements.
+    static bool hasNullElements(const std::vector<Geometry*>* lrs);
 
 //	static void reversePointOrder(CoordinateSequence* coordinates);
 //	static Coordinate& minCoordinate(CoordinateSequence* coordinates);
 //	static void scroll(CoordinateSequence* coordinates,Coordinate* firstCoordinate);
 //	static int indexOf(Coordinate* coordinate,CoordinateSequence* coordinates);
 //
-	/** \brief
-	 * Returns whether the two Geometrys are equal, from the point
-	 * of view of the equalsExact method.
-	 */
-	virtual bool isEquivalentClass(const Geometry *other) const;
+    /** \brief
+     * Returns whether the two Geometrys are equal, from the point
+     * of view of the equalsExact method.
+     */
+    virtual bool isEquivalentClass(const Geometry* other) const;
 
-	static void checkNotGeometryCollection(const Geometry *g);
-			// throw(IllegalArgumentException *);
+    static void checkNotGeometryCollection(const Geometry* g);
+    // throw(IllegalArgumentException *);
 
-	//virtual void checkEqualSRID(Geometry *other);
+    //virtual void checkEqualSRID(Geometry *other);
 
-	//virtual void checkEqualPrecisionModel(Geometry *other);
+    //virtual void checkEqualPrecisionModel(Geometry *other);
 
-	virtual Envelope::Ptr computeEnvelopeInternal() const=0; //Abstract
+    virtual Envelope::Ptr computeEnvelopeInternal() const = 0; //Abstract
 
-	virtual int compareToSameClass(const Geometry *geom) const=0; //Abstract
+    virtual int compareToSameClass(const Geometry* geom) const = 0; //Abstract
 
-	int compare(std::vector<Coordinate> a, std::vector<Coordinate> b) const;
+    int compare(std::vector<Coordinate> a, std::vector<Coordinate> b) const;
 
-	int compare(std::vector<Geometry *> a, std::vector<Geometry *> b) const;
+    int compare(std::vector<Geometry*> a, std::vector<Geometry*> b) const;
 
-	bool equal(const Coordinate& a, const Coordinate& b,
-			double tolerance) const;
-	int SRID;
+    bool equal(const Coordinate& a, const Coordinate& b,
+               double tolerance) const;
+    int SRID;
 
-	/// @deprecated
-	//Geometry* toInternalGeometry(const Geometry *g) const;
+    /// @deprecated
+    //Geometry* toInternalGeometry(const Geometry *g) const;
 
-	/// @deprecated
-	//Geometry* fromInternalGeometry(const Geometry *g) const;
+    /// @deprecated
+    //Geometry* fromInternalGeometry(const Geometry *g) const;
 
-	/// Polygon overrides to check for actual rectangle
-	//virtual bool isRectangle() const { return false; } -- moved to public
+    /// Polygon overrides to check for actual rectangle
+    //virtual bool isRectangle() const { return false; } -- moved to public
 
-	Geometry(const Geometry &geom);
+    Geometry(const Geometry& geom);
 
-	/** \brief
-	 * Construct a geometry with the given GeometryFactory.
-	 *
-	 * Will keep a reference to the factory, so don't
-	 * delete it until al Geometry objects referring to
-	 * it are deleted.
-	 *
-	 * @param factory
-	 */
-	Geometry(const GeometryFactory *factory);
+    /** \brief
+     * Construct a geometry with the given GeometryFactory.
+     *
+     * Will keep a reference to the factory, so don't
+     * delete it until al Geometry objects referring to
+     * it are deleted.
+     *
+     * @param factory
+     */
+    Geometry(const GeometryFactory* factory);
 
 
 protected:
 
-		virtual int getSortIndex() const = 0;
+    virtual int getSortIndex() const = 0;
 
 
 private:
 
-	class GEOS_DLL GeometryChangedFilter : public GeometryComponentFilter
-	{
-	public:
-		void filter_rw(Geometry* geom) override;
-	};
+    class GEOS_DLL GeometryChangedFilter : public GeometryComponentFilter {
+    public:
+        void filter_rw(Geometry* geom) override;
+    };
 
-	static GeometryChangedFilter geometryChangedFilter;
+    static GeometryChangedFilter geometryChangedFilter;
 
-	/// The GeometryFactory used to create this Geometry
-	//
-	/// Externally owned
-	///
-	const GeometryFactory* _factory;
+    /// The GeometryFactory used to create this Geometry
+    //
+    /// Externally owned
+    ///
+    const GeometryFactory* _factory;
 
-	void* _userData;
+    void* _userData;
 };
 
 /// \brief
@@ -888,7 +926,7 @@ private:
 GEOS_DLL std::ostream& operator<< (std::ostream& os, const Geometry& geom);
 
 struct GEOS_DLL GeometryGreaterThen {
-	bool operator()(const Geometry *first, const Geometry *second);
+    bool operator()(const Geometry* first, const Geometry* second);
 };
 
 
@@ -906,9 +944,9 @@ std::string jtsport();
 // forbids that construct:
 // http://lwg.github.com/issues/lwg-closed.html#2068
 struct GeomPtrPair {
-	typedef std::unique_ptr<Geometry> GeomPtr;
-	GeomPtr first;
-	GeomPtr second;
+    typedef std::unique_ptr<Geometry> GeomPtr;
+    GeomPtr first;
+    GeomPtr second;
 };
 
 } // namespace geos::geom
diff --git a/include/geos/geom/GeometryCollection.h b/include/geos/geom/GeometryCollection.h
index b108837..151997f 100644
--- a/include/geos/geom/GeometryCollection.h
+++ b/include/geos/geom/GeometryCollection.h
@@ -33,11 +33,11 @@
 
 // Forward declarations
 namespace geos {
-	namespace geom { // geos::geom
-		class Coordinate;
-		class CoordinateArraySequence;
-		class CoordinateSequenceFilter;
-	}
+namespace geom { // geos::geom
+class Coordinate;
+class CoordinateArraySequence;
+class CoordinateSequenceFilter;
+}
 }
 
 namespace geos {
@@ -55,155 +55,161 @@ namespace geom { // geos::geom
 class GEOS_DLL GeometryCollection : public virtual Geometry {
 
 public:
-	friend class GeometryFactory;
+    friend class GeometryFactory;
 
-	typedef std::vector<Geometry *>::const_iterator const_iterator;
+    typedef std::vector<Geometry*>::const_iterator const_iterator;
 
-	typedef std::vector<Geometry *>::iterator iterator;
+    typedef std::vector<Geometry*>::iterator iterator;
 
-	const_iterator begin() const;
+    const_iterator begin() const;
 
-	const_iterator end() const;
+    const_iterator end() const;
 
-	/**
-	 * Creates and returns a full copy of this GeometryCollection object.
-	 * (including all coordinates contained by it).
-	 *
-	 * @return a clone of this instance
-	 */
-	Geometry *clone() const override {
-		return new GeometryCollection(*this);
-	}
+    /**
+     * Creates and returns a full copy of this GeometryCollection object.
+     * (including all coordinates contained by it).
+     *
+     * @return a clone of this instance
+     */
+    Geometry*
+    clone() const override
+    {
+        return new GeometryCollection(*this);
+    }
 
-	~GeometryCollection() override;
+    ~GeometryCollection() override;
 
-	void setSRID(int) override;
+    void setSRID(int) override;
 
-	/**
-	 * \brief
-	 * Collects all coordinates of all subgeometries into a
-	 * CoordinateSequence.
-	 *
-	 * Note that the returned coordinates are copies, so
-	 * you want be able to use them to modify the geometries
-	 * in place. Also you'll need to delete the CoordinateSequence
-	 * when finished using it.
-	 *
-	 * @return the collected coordinates
-	 *
-	 */
-	CoordinateSequence* getCoordinates() const override;
+    /**
+     * \brief
+     * Collects all coordinates of all subgeometries into a
+     * CoordinateSequence.
+     *
+     * Note that the returned coordinates are copies, so
+     * you want be able to use them to modify the geometries
+     * in place. Also you'll need to delete the CoordinateSequence
+     * when finished using it.
+     *
+     * @return the collected coordinates
+     *
+     */
+    CoordinateSequence* getCoordinates() const override;
 
-	bool isEmpty() const override;
+    bool isEmpty() const override;
 
-	/**
-	 * \brief
-	 * Returns the maximum dimension of geometries in this collection
-	 * (0=point, 1=line, 2=surface)
-	 *
-	 * @see Dimension::DimensionType
-	 */
-	Dimension::DimensionType getDimension() const override;
+    /**
+     * \brief
+     * Returns the maximum dimension of geometries in this collection
+     * (0=point, 1=line, 2=surface)
+     *
+     * @see Dimension::DimensionType
+     */
+    Dimension::DimensionType getDimension() const override;
 
-	/// Returns coordinate dimension.
-	int getCoordinateDimension() const override;
+    /// Returns coordinate dimension.
+    int getCoordinateDimension() const override;
 
-	Geometry* getBoundary() const override;
+    Geometry* getBoundary() const override;
 
-	/**
-	 * \brief
-	 * Returns the maximum boundary dimension of geometries in
-	 * this collection.
-	 */
-	int getBoundaryDimension() const override;
+    /**
+     * \brief
+     * Returns the maximum boundary dimension of geometries in
+     * this collection.
+     */
+    int getBoundaryDimension() const override;
 
-	std::size_t getNumPoints() const override;
+    std::size_t getNumPoints() const override;
 
-	std::string getGeometryType() const override;
+    std::string getGeometryType() const override;
 
-	GeometryTypeId getGeometryTypeId() const override;
+    GeometryTypeId getGeometryTypeId() const override;
 
-	bool equalsExact(const Geometry *other,
-			double tolerance=0) const override;
+    bool equalsExact(const Geometry* other,
+                     double tolerance = 0) const override;
 
-	void apply_ro(CoordinateFilter *filter) const override;
+    void apply_ro(CoordinateFilter* filter) const override;
 
-	void apply_rw(const CoordinateFilter *filter) override;
+    void apply_rw(const CoordinateFilter* filter) override;
 
-	void apply_ro(GeometryFilter *filter) const override;
+    void apply_ro(GeometryFilter* filter) const override;
 
-	void apply_rw(GeometryFilter *filter) override;
+    void apply_rw(GeometryFilter* filter) override;
 
-	void apply_ro(GeometryComponentFilter *filter) const override;
+    void apply_ro(GeometryComponentFilter* filter) const override;
 
-	void apply_rw(GeometryComponentFilter *filter) override;
+    void apply_rw(GeometryComponentFilter* filter) override;
 
-	void apply_rw(CoordinateSequenceFilter& filter) override;
+    void apply_rw(CoordinateSequenceFilter& filter) override;
 
-	void apply_ro(CoordinateSequenceFilter& filter) const override;
+    void apply_ro(CoordinateSequenceFilter& filter) const override;
 
-	void normalize() override;
+    void normalize() override;
 
-	const Coordinate* getCoordinate() const override;
+    const Coordinate* getCoordinate() const override;
 
-	/// Returns the total area of this collection
-	double getArea() const override;
+    /// Returns the total area of this collection
+    double getArea() const override;
 
-	/// Returns the total length of this collection
-	double getLength() const override;
+    /// Returns the total length of this collection
+    double getLength() const override;
 
-	/// Returns the number of geometries in this collection
-	std::size_t getNumGeometries() const override;
+    /// Returns the number of geometries in this collection
+    std::size_t getNumGeometries() const override;
 
-	/// Returns a pointer to the nth Geometry in this collection
-	const Geometry* getGeometryN(std::size_t n) const override;
+    /// Returns a pointer to the nth Geometry in this collection
+    const Geometry* getGeometryN(std::size_t n) const override;
 
-	/**
+    /**
      * Creates a GeometryCollection with
      * every component reversed.
      * The order of the components in the collection are not reversed.
      *
      * @return a GeometryCollection in the reverse order
      */
-	Geometry* reverse() const override;
+    Geometry* reverse() const override;
 
 protected:
 
-	GeometryCollection(const GeometryCollection &gc);
-
-	/** \brief
-	 * Construct a GeometryCollection with the given GeometryFactory.
-	 * Will keep a reference to the factory, so don't
-	 * delete it until al Geometry objects referring to
-	 * it are deleted.
-	 * Will take ownership of the Geometry vector.
-	 *
-	 * @param newGeoms
-	 *	The <code>Geometry</code>s for this
-	 *	<code>GeometryCollection</code>,
-	 *	or <code>null</code> or an empty array to
-	 *	create the empty geometry.
-	 *	Elements may be empty <code>Geometry</code>s,
-	 *	but not <code>null</code>s.
-	 *
-	 *	If construction succeed the created object will take
-	 *	ownership of newGeoms vector and elements.
-	 *
-	 *	If construction	fails "IllegalArgumentException *"
-	 *	is thrown and it is your responsibility to delete newGeoms
-	 *	vector and content.
-	 *
-	 * @param newFactory the GeometryFactory used to create this geometry
-	 */
-	GeometryCollection(std::vector<Geometry *> *newGeoms, const GeometryFactory *newFactory);
-
-	int getSortIndex() const override { return SORTINDEX_GEOMETRYCOLLECTION; };
-
-	std::vector<Geometry *>* geometries;
-
-	Envelope::Ptr computeEnvelopeInternal() const override;
-
-	int compareToSameClass(const Geometry *gc) const override;
+    GeometryCollection(const GeometryCollection& gc);
+
+    /** \brief
+     * Construct a GeometryCollection with the given GeometryFactory.
+     * Will keep a reference to the factory, so don't
+     * delete it until al Geometry objects referring to
+     * it are deleted.
+     * Will take ownership of the Geometry vector.
+     *
+     * @param newGeoms
+     *	The <code>Geometry</code>s for this
+     *	<code>GeometryCollection</code>,
+     *	or <code>null</code> or an empty array to
+     *	create the empty geometry.
+     *	Elements may be empty <code>Geometry</code>s,
+     *	but not <code>null</code>s.
+     *
+     *	If construction succeed the created object will take
+     *	ownership of newGeoms vector and elements.
+     *
+     *	If construction	fails "IllegalArgumentException *"
+     *	is thrown and it is your responsibility to delete newGeoms
+     *	vector and content.
+     *
+     * @param newFactory the GeometryFactory used to create this geometry
+     */
+    GeometryCollection(std::vector<Geometry*>* newGeoms, const GeometryFactory* newFactory);
+
+    int
+    getSortIndex() const override
+    {
+        return SORTINDEX_GEOMETRYCOLLECTION;
+    };
+
+    std::vector<Geometry*>* geometries;
+
+    Envelope::Ptr computeEnvelopeInternal() const override;
+
+    int compareToSameClass(const Geometry* gc) const override;
 
 };
 
diff --git a/include/geos/geom/GeometryCollection.inl b/include/geos/geom/GeometryCollection.inl
index 53ad9d6..b6df063 100644
--- a/include/geos/geom/GeometryCollection.inl
+++ b/include/geos/geom/GeometryCollection.inl
@@ -7,7 +7,7 @@
  *
  * This is free software; you can redistribute and/or modify it under
  * the terms of the GNU Lesser General Public Licence as published
- * by the Free Software Foundation. 
+ * by the Free Software Foundation.
  * See the COPYING file for more information.
  *
  **********************************************************************
@@ -29,13 +29,13 @@ namespace geom { // geos::geom
 INLINE GeometryCollection::const_iterator
 GeometryCollection::begin() const
 {
-	return geometries->begin();
+    return geometries->begin();
 }
 
 INLINE GeometryCollection::const_iterator
 GeometryCollection::end() const
 {
-	return geometries->end();
+    return geometries->end();
 }
 
 
diff --git a/include/geos/geom/GeometryComponentFilter.h b/include/geos/geom/GeometryComponentFilter.h
index ea37325..514b64f 100644
--- a/include/geos/geom/GeometryComponentFilter.h
+++ b/include/geos/geom/GeometryComponentFilter.h
@@ -19,9 +19,9 @@
 #include <geos/inline.h>
 
 namespace geos {
-	namespace geom { // geos::geom
-		class Geometry;
-	}
+namespace geom { // geos::geom
+class Geometry;
+}
 }
 
 namespace geos {
@@ -43,16 +43,17 @@ namespace geom { // geos::geom
 class GEOS_DLL GeometryComponentFilter {
 public:
 
-	/**
-	 *  Performs an operation with or on <code>geom</code>.
-	 *
-	 * @param  geom  a <code>Geometry</code> to which the filter
-	 * is applied.
-	 */
-	virtual void filter_rw(Geometry *geom);
-	virtual void filter_ro(const Geometry *geom);
-
-	virtual ~GeometryComponentFilter() {}
+    /**
+     *  Performs an operation with or on <code>geom</code>.
+     *
+     * @param  geom  a <code>Geometry</code> to which the filter
+     * is applied.
+     */
+    virtual void filter_rw(Geometry* geom);
+    virtual void filter_ro(const Geometry* geom);
+
+    virtual
+    ~GeometryComponentFilter() {}
 };
 
 } // namespace geos::geom
diff --git a/include/geos/geom/GeometryFactory.h b/include/geos/geom/GeometryFactory.h
index 70b8441..8af6aaf 100644
--- a/include/geos/geom/GeometryFactory.h
+++ b/include/geos/geom/GeometryFactory.h
@@ -33,22 +33,22 @@
 #include <cassert>
 
 namespace geos {
-	namespace geom {
-		class CoordinateSequenceFactory;
-		class Coordinate;
-		class CoordinateSequence;
-		class Envelope;
-		class Geometry;
-		class GeometryCollection;
-		class LineString;
-		class LinearRing;
-		class MultiLineString;
-		class MultiPoint;
-		class MultiPolygon;
-		class Point;
-		class Polygon;
-		class PrecisionModel;
-	}
+namespace geom {
+class CoordinateSequenceFactory;
+class Coordinate;
+class CoordinateSequence;
+class Envelope;
+class Geometry;
+class GeometryCollection;
+class LineString;
+class LinearRing;
+class MultiLineString;
+class MultiPoint;
+class MultiPolygon;
+class Point;
+class Polygon;
+class PrecisionModel;
+}
 }
 
 namespace geos {
@@ -67,416 +67,418 @@ namespace geom { // geos::geom
 class GEOS_DLL GeometryFactory {
 private:
 
-	struct GeometryFactoryDeleter
-	{
-		void operator()(GeometryFactory* p) const
-		{
-			p->destroy();
-		}
-	};
+    struct GeometryFactoryDeleter {
+        void
+        operator()(GeometryFactory* p) const
+        {
+            p->destroy();
+        }
+    };
 
 public:
 
-	using Ptr = std::unique_ptr<GeometryFactory, GeometryFactoryDeleter>;
-
-	/**
-	 * \brief
-	 * Constructs a GeometryFactory that generates Geometries having a
-	 * floating PrecisionModel and a spatial-reference ID of 0.
-	 */
-	static GeometryFactory::Ptr create();
-
-	/**
-	 * \brief
-	 * Constructs a GeometryFactory that generates Geometries having
-	 * the given PrecisionModel, spatial-reference ID, and
-	 * CoordinateSequence implementation.
-	 *
-	 * NOTES:
-	 * (1) the given PrecisionModel is COPIED
-	 * (2) the CoordinateSequenceFactory is NOT COPIED
-	 *     and must be available for the whole lifetime
-	 *     of the GeometryFactory
-	 */
-	static GeometryFactory::Ptr create(const PrecisionModel *pm, int newSRID,
-		CoordinateSequenceFactory *nCoordinateSequenceFactory);
-
-	/**
-	 * \brief
-	 * Constructs a GeometryFactory that generates Geometries having the
-	 * given CoordinateSequence implementation, a double-precision floating
-	 * PrecisionModel and a spatial-reference ID of 0.
-	 */
-	static GeometryFactory::Ptr create(CoordinateSequenceFactory *nCoordinateSequenceFactory);
-
-	/**
-	 * \brief
-	 * Constructs a GeometryFactory that generates Geometries having
-	 * the given PrecisionModel and the default CoordinateSequence
-	 * implementation.
-	 *
-	 * @param pm the PrecisionModel to use
-	 */
-	static GeometryFactory::Ptr create(const PrecisionModel *pm);
-
-	/**
-	 * \brief
-	 * Constructs a GeometryFactory that generates Geometries having
-	 * the given {@link PrecisionModel} and spatial-reference ID,
-	 * and the default CoordinateSequence implementation.
-	 *
-	 * @param pm the PrecisionModel to use, will be copied internally
-	 * @param newSRID the SRID to use
-	 */
-	static GeometryFactory::Ptr create(const PrecisionModel* pm, int newSRID);
-
-	/**
-	 * \brief Copy constructor
-	 *
-	 * @param gf the GeometryFactory to clone from
-	 */
-	static GeometryFactory::Ptr create(const GeometryFactory &gf);
-
-	/**
-	 * \brief
-	 * Return a pointer to the default GeometryFactory.
-	 * This is a global shared object instantiated
-	 * using default constructor.
-	 */
-	static const GeometryFactory*
-	getDefaultInstance();
+    using Ptr = std::unique_ptr<GeometryFactory, GeometryFactoryDeleter>;
+
+    /**
+     * \brief
+     * Constructs a GeometryFactory that generates Geometries having a
+     * floating PrecisionModel and a spatial-reference ID of 0.
+     */
+    static GeometryFactory::Ptr create();
+
+    /**
+     * \brief
+     * Constructs a GeometryFactory that generates Geometries having
+     * the given PrecisionModel, spatial-reference ID, and
+     * CoordinateSequence implementation.
+     *
+     * NOTES:
+     * (1) the given PrecisionModel is COPIED
+     * (2) the CoordinateSequenceFactory is NOT COPIED
+     *     and must be available for the whole lifetime
+     *     of the GeometryFactory
+     */
+    static GeometryFactory::Ptr create(const PrecisionModel* pm, int newSRID,
+                                       CoordinateSequenceFactory* nCoordinateSequenceFactory);
+
+    /**
+     * \brief
+     * Constructs a GeometryFactory that generates Geometries having the
+     * given CoordinateSequence implementation, a double-precision floating
+     * PrecisionModel and a spatial-reference ID of 0.
+     */
+    static GeometryFactory::Ptr create(CoordinateSequenceFactory* nCoordinateSequenceFactory);
+
+    /**
+     * \brief
+     * Constructs a GeometryFactory that generates Geometries having
+     * the given PrecisionModel and the default CoordinateSequence
+     * implementation.
+     *
+     * @param pm the PrecisionModel to use
+     */
+    static GeometryFactory::Ptr create(const PrecisionModel* pm);
+
+    /**
+     * \brief
+     * Constructs a GeometryFactory that generates Geometries having
+     * the given {@link PrecisionModel} and spatial-reference ID,
+     * and the default CoordinateSequence implementation.
+     *
+     * @param pm the PrecisionModel to use, will be copied internally
+     * @param newSRID the SRID to use
+     */
+    static GeometryFactory::Ptr create(const PrecisionModel* pm, int newSRID);
+
+    /**
+     * \brief Copy constructor
+     *
+     * @param gf the GeometryFactory to clone from
+     */
+    static GeometryFactory::Ptr create(const GeometryFactory& gf);
+
+    /**
+     * \brief
+     * Return a pointer to the default GeometryFactory.
+     * This is a global shared object instantiated
+     * using default constructor.
+     */
+    static const GeometryFactory*
+    getDefaultInstance();
 
 //Skipped a lot of list to array convertors
 
-	Point* createPointFromInternalCoord(const Coordinate* coord,
-			const Geometry *exemplar) const;
+    Point* createPointFromInternalCoord(const Coordinate* coord,
+                                        const Geometry* exemplar) const;
 
-	/// Converts an Envelope to a Geometry.
-	//
-	/// Returned Geometry can be a Point, a Polygon or an EMPTY geom.
-	///
-	Geometry* toGeometry(const Envelope* envelope) const;
+    /// Converts an Envelope to a Geometry.
+    //
+    /// Returned Geometry can be a Point, a Polygon or an EMPTY geom.
+    ///
+    Geometry* toGeometry(const Envelope* envelope) const;
 
-	/// \brief
-	/// Returns the PrecisionModel that Geometries created by this
-	/// factory will be associated with.
-	const PrecisionModel* getPrecisionModel() const;
+    /// \brief
+    /// Returns the PrecisionModel that Geometries created by this
+    /// factory will be associated with.
+    const PrecisionModel* getPrecisionModel() const;
 
-	/// Creates an EMPTY Point
-	Point* createPoint() const;
+    /// Creates an EMPTY Point
+    Point* createPoint() const;
 
-	/// Creates a Point using the given Coordinate
-	Point* createPoint(const Coordinate& coordinate) const;
+    /// Creates a Point using the given Coordinate
+    Point* createPoint(const Coordinate& coordinate) const;
 
-	/// Creates a Point taking ownership of the given CoordinateSequence
-	Point* createPoint(CoordinateSequence *coordinates) const;
+    /// Creates a Point taking ownership of the given CoordinateSequence
+    Point* createPoint(CoordinateSequence* coordinates) const;
 
-	/// Creates a Point with a deep-copy of the given CoordinateSequence.
-	Point* createPoint(const CoordinateSequence &coordinates) const;
+    /// Creates a Point with a deep-copy of the given CoordinateSequence.
+    Point* createPoint(const CoordinateSequence& coordinates) const;
 
-	/// Construct an EMPTY GeometryCollection
-	GeometryCollection* createGeometryCollection() const;
+    /// Construct an EMPTY GeometryCollection
+    GeometryCollection* createGeometryCollection() const;
 
-	/// Construct the EMPTY Geometry
-	Geometry* createEmptyGeometry() const;
+    /// Construct the EMPTY Geometry
+    Geometry* createEmptyGeometry() const;
 
-	/// Construct a GeometryCollection taking ownership of given arguments
-	GeometryCollection* createGeometryCollection(
-			std::vector<Geometry *> *newGeoms) const;
+    /// Construct a GeometryCollection taking ownership of given arguments
+    GeometryCollection* createGeometryCollection(
+        std::vector<Geometry*>* newGeoms) const;
 
-	/// Constructs a GeometryCollection with a deep-copy of args
-	GeometryCollection* createGeometryCollection(
-			const std::vector<Geometry *> &newGeoms) const;
+    /// Constructs a GeometryCollection with a deep-copy of args
+    GeometryCollection* createGeometryCollection(
+        const std::vector<Geometry*>& newGeoms) const;
 
-	/// Construct an EMPTY MultiLineString
-	MultiLineString* createMultiLineString() const;
-
-	/// Construct a MultiLineString taking ownership of given arguments
-	MultiLineString* createMultiLineString(
-			std::vector<Geometry *> *newLines) const;
-
-	/// Construct a MultiLineString with a deep-copy of given arguments
-	MultiLineString* createMultiLineString(
-			const std::vector<Geometry *> &fromLines) const;
-
-	/// Construct an EMPTY MultiPolygon
-	MultiPolygon* createMultiPolygon() const;
-
-	/// Construct a MultiPolygon taking ownership of given arguments
-	MultiPolygon* createMultiPolygon(std::vector<Geometry *> *newPolys) const;
-
-	/// Construct a MultiPolygon with a deep-copy of given arguments
-	MultiPolygon* createMultiPolygon(
-			const std::vector<Geometry *> &fromPolys) const;
-
-	/// Construct an EMPTY LinearRing
-	LinearRing* createLinearRing() const;
-
-	/// Construct a LinearRing taking ownership of given arguments
-	LinearRing* createLinearRing(CoordinateSequence* newCoords) const;
-
-	std::unique_ptr<Geometry> createLinearRing(
-			std::unique_ptr<CoordinateSequence> newCoords) const;
-
-	/// Construct a LinearRing with a deep-copy of given arguments
-	LinearRing* createLinearRing(
-			const CoordinateSequence& coordinates) const;
-
-	/// Constructs an EMPTY <code>MultiPoint</code>.
-	MultiPoint* createMultiPoint() const;
-
-	/// Construct a MultiPoint taking ownership of given arguments
-	MultiPoint* createMultiPoint(std::vector<Geometry *> *newPoints) const;
-
-	/// Construct a MultiPoint with a deep-copy of given arguments
-	MultiPoint* createMultiPoint(
-			const std::vector<Geometry *> &fromPoints) const;
-
-	/// \brief
-	/// Construct a MultiPoint containing a Point geometry
-	/// for each Coordinate in the given list.
-	MultiPoint* createMultiPoint(
-			const CoordinateSequence &fromCoords) const;
-
-	/// \brief
-	/// Construct a MultiPoint containing a Point geometry
-	/// for each Coordinate in the given vector.
-	MultiPoint* createMultiPoint(
-			const std::vector<Coordinate> &fromCoords) const;
-
-	/// Construct an EMPTY Polygon
-	Polygon* createPolygon() const;
-
-	/// Construct a Polygon taking ownership of given arguments
-	Polygon* createPolygon(LinearRing *shell,
-			std::vector<Geometry *> *holes) const;
-
-	/// Construct a Polygon with a deep-copy of given arguments
-	Polygon* createPolygon(const LinearRing &shell,
-			const std::vector<Geometry *> &holes) const;
-
-	/// Construct an EMPTY LineString
-	LineString* createLineString() const;
-
-	/// Copy a LineString
-	std::unique_ptr<LineString> createLineString(const LineString& ls) const;
-
-	/// Construct a LineString taking ownership of given argument
-	LineString* createLineString(CoordinateSequence* coordinates) const;
-
-	std::unique_ptr<Geometry> createLineString(
-			std::unique_ptr<CoordinateSequence> coordinates) const;
-
-	/// Construct a LineString with a deep-copy of given argument
-	LineString* createLineString(
-			const CoordinateSequence& coordinates) const;
-
-	/**
-	 *  Build an appropriate <code>Geometry</code>, <code>MultiGeometry</code>, or
-	 *  <code>GeometryCollection</code> to contain the <code>Geometry</code>s in
-	 *  it.
-	 *
-	 *  For example:
-	 *
-	 *    - If <code>geomList</code> contains a single <code>Polygon</code>,
-	 *      the <code>Polygon</code> is returned.
-	 *    - If <code>geomList</code> contains several <code>Polygon</code>s, a
-	 *      <code>MultiPolygon</code> is returned.
-	 *    - If <code>geomList</code> contains some <code>Polygon</code>s and
-	 *      some <code>LineString</code>s, a <code>GeometryCollection</code> is
-	 *      returned.
-	 *    - If <code>geomList</code> is empty, an empty
-	 *      <code>GeometryCollection</code> is returned
-	 *    .
-	 *
-	 * Note that this method does not "flatten" Geometries in the input,
-	 * and hence if any MultiGeometries are contained in the input a
-	 * GeometryCollection containing them will be returned.
-	 *
-	 * @param  newGeoms  the <code>Geometry</code>s to combine
-	 *
-	 * @return
-	 *	A <code>Geometry</code> of the "smallest", "most type-specific"
-	 *	class that can contain the elements of <code>geomList</code>.
-	 *
-	 * NOTE: the returned Geometry will take ownership of the
-	 * 	given vector AND its elements
-	 */
-	Geometry* buildGeometry(std::vector<Geometry *> *geoms) const;
-
-  /// See buildGeometry(std::vector<Geometry *>&) for semantics
-  //
-  /// Will clone the geometries accessible trough the iterator.
-  ///
-  /// @tparam T an iterator yelding something which casts to const Geometry*
-  /// @param from start iterator
-  /// @param toofar end iterator
-  ///
-  template <class T>
-	std::unique_ptr<Geometry> buildGeometry(T from, T toofar) const
-  {
-    bool isHeterogeneous = false;
-    size_t count = 0;
-    int geomClass = -1;
-    for (T i=from; i != toofar; ++i)
+    /// Construct an EMPTY MultiLineString
+    MultiLineString* createMultiLineString() const;
+
+    /// Construct a MultiLineString taking ownership of given arguments
+    MultiLineString* createMultiLineString(
+        std::vector<Geometry*>* newLines) const;
+
+    /// Construct a MultiLineString with a deep-copy of given arguments
+    MultiLineString* createMultiLineString(
+        const std::vector<Geometry*>& fromLines) const;
+
+    /// Construct an EMPTY MultiPolygon
+    MultiPolygon* createMultiPolygon() const;
+
+    /// Construct a MultiPolygon taking ownership of given arguments
+    MultiPolygon* createMultiPolygon(std::vector<Geometry*>* newPolys) const;
+
+    /// Construct a MultiPolygon with a deep-copy of given arguments
+    MultiPolygon* createMultiPolygon(
+        const std::vector<Geometry*>& fromPolys) const;
+
+    /// Construct an EMPTY LinearRing
+    LinearRing* createLinearRing() const;
+
+    /// Construct a LinearRing taking ownership of given arguments
+    LinearRing* createLinearRing(CoordinateSequence* newCoords) const;
+
+    std::unique_ptr<Geometry> createLinearRing(
+        std::unique_ptr<CoordinateSequence> newCoords) const;
+
+    /// Construct a LinearRing with a deep-copy of given arguments
+    LinearRing* createLinearRing(
+        const CoordinateSequence& coordinates) const;
+
+    /// Constructs an EMPTY <code>MultiPoint</code>.
+    MultiPoint* createMultiPoint() const;
+
+    /// Construct a MultiPoint taking ownership of given arguments
+    MultiPoint* createMultiPoint(std::vector<Geometry*>* newPoints) const;
+
+    /// Construct a MultiPoint with a deep-copy of given arguments
+    MultiPoint* createMultiPoint(
+        const std::vector<Geometry*>& fromPoints) const;
+
+    /// \brief
+    /// Construct a MultiPoint containing a Point geometry
+    /// for each Coordinate in the given list.
+    MultiPoint* createMultiPoint(
+        const CoordinateSequence& fromCoords) const;
+
+    /// \brief
+    /// Construct a MultiPoint containing a Point geometry
+    /// for each Coordinate in the given vector.
+    MultiPoint* createMultiPoint(
+        const std::vector<Coordinate>& fromCoords) const;
+
+    /// Construct an EMPTY Polygon
+    Polygon* createPolygon() const;
+
+    /// Construct a Polygon taking ownership of given arguments
+    Polygon* createPolygon(LinearRing* shell,
+                           std::vector<Geometry*>* holes) const;
+
+    /// Construct a Polygon with a deep-copy of given arguments
+    Polygon* createPolygon(const LinearRing& shell,
+                           const std::vector<Geometry*>& holes) const;
+
+    /// Construct an EMPTY LineString
+    LineString* createLineString() const;
+
+    /// Copy a LineString
+    std::unique_ptr<LineString> createLineString(const LineString& ls) const;
+
+    /// Construct a LineString taking ownership of given argument
+    LineString* createLineString(CoordinateSequence* coordinates) const;
+
+    std::unique_ptr<Geometry> createLineString(
+        std::unique_ptr<CoordinateSequence> coordinates) const;
+
+    /// Construct a LineString with a deep-copy of given argument
+    LineString* createLineString(
+        const CoordinateSequence& coordinates) const;
+
+    /**
+     *  Build an appropriate <code>Geometry</code>, <code>MultiGeometry</code>, or
+     *  <code>GeometryCollection</code> to contain the <code>Geometry</code>s in
+     *  it.
+     *
+     *  For example:
+     *
+     *    - If <code>geomList</code> contains a single <code>Polygon</code>,
+     *      the <code>Polygon</code> is returned.
+     *    - If <code>geomList</code> contains several <code>Polygon</code>s, a
+     *      <code>MultiPolygon</code> is returned.
+     *    - If <code>geomList</code> contains some <code>Polygon</code>s and
+     *      some <code>LineString</code>s, a <code>GeometryCollection</code> is
+     *      returned.
+     *    - If <code>geomList</code> is empty, an empty
+     *      <code>GeometryCollection</code> is returned
+     *    .
+     *
+     * Note that this method does not "flatten" Geometries in the input,
+     * and hence if any MultiGeometries are contained in the input a
+     * GeometryCollection containing them will be returned.
+     *
+     * @param  newGeoms  the <code>Geometry</code>s to combine
+     *
+     * @return
+     *	A <code>Geometry</code> of the "smallest", "most type-specific"
+     *	class that can contain the elements of <code>geomList</code>.
+     *
+     * NOTE: the returned Geometry will take ownership of the
+     * 	given vector AND its elements
+     */
+    Geometry* buildGeometry(std::vector<Geometry*>* geoms) const;
+
+    /// See buildGeometry(std::vector<Geometry *>&) for semantics
+    //
+    /// Will clone the geometries accessible trough the iterator.
+    ///
+    /// @tparam T an iterator yelding something which casts to const Geometry*
+    /// @param from start iterator
+    /// @param toofar end iterator
+    ///
+    template <class T>
+    std::unique_ptr<Geometry>
+    buildGeometry(T from, T toofar) const
     {
-      ++count;
-      const Geometry* g = *i;
-      if ( geomClass < 0 ) {
-        geomClass = g->getSortIndex();
-      }
-      else if ( geomClass != g->getSortIndex() ) {
-        isHeterogeneous = true;
-      }
+        bool isHeterogeneous = false;
+        size_t count = 0;
+        int geomClass = -1;
+        for(T i = from; i != toofar; ++i) {
+            ++count;
+            const Geometry* g = *i;
+            if(geomClass < 0) {
+                geomClass = g->getSortIndex();
+            }
+            else if(geomClass != g->getSortIndex()) {
+                isHeterogeneous = true;
+            }
+        }
+
+        // for the empty geometry, return an empty GeometryCollection
+        if(count == 0) {
+            return std::unique_ptr<Geometry>(createGeometryCollection());
+        }
+
+        // for the single geometry, return a clone
+        if(count == 1) {
+            return std::unique_ptr<Geometry>((*from)->clone());
+        }
+
+        // Now we know it is a collection
+
+        // FIXME:
+        // Until we tweak all the createMulti* interfaces
+        // to support taking iterators we'll have to build
+        // a custom vector here.
+        std::vector<Geometry*> fromGeoms;
+        for(T i = from; i != toofar; ++i) {
+            const Geometry* g = *i;
+            fromGeoms.push_back(const_cast<Geometry*>(g));
+        }
+
+
+        // for an heterogeneous ...
+        if(isHeterogeneous) {
+            return std::unique_ptr<Geometry>(createGeometryCollection(fromGeoms));
+        }
+
+        // At this point we know the collection is not hetereogenous.
+        if(dynamic_cast<const Polygon*>(*from)) {
+            return std::unique_ptr<Geometry>(createMultiPolygon(fromGeoms));
+        }
+        else if(dynamic_cast<const LineString*>(*from)) {
+            return std::unique_ptr<Geometry>(createMultiLineString(fromGeoms));
+        }
+        else if(dynamic_cast<const Point*>(*from)) {
+            return std::unique_ptr<Geometry>(createMultiPoint(fromGeoms));
+        }
+        // FIXME: Why not to throw an exception? --mloskot
+        assert(0); // buildGeomtry encountered an unkwnon geometry type
+        return std::unique_ptr<Geometry>(); // nullptr
     }
 
-    // for the empty geometry, return an empty GeometryCollection
-    if ( count == 0 ) {
-      return std::unique_ptr<Geometry>( createGeometryCollection() );
-    }
+    /** \brief
+     * This function does the same thing of the omonimouse function
+     * taking vector pointer instead of reference.
+     *
+     * The difference is that this version will copy needed data
+     * leaving ownership to the caller.
+     */
+    Geometry* buildGeometry(const std::vector<Geometry*>& geoms) const;
 
-    // for the single geometry, return a clone
-    if ( count == 1 ) {
-      return std::unique_ptr<Geometry>( (*from)->clone() );
-    }
+    int getSRID() const;
 
-    // Now we know it is a collection
+    /// \brief
+    /// Returns the CoordinateSequenceFactory associated
+    /// with this GeometryFactory
+    const CoordinateSequenceFactory* getCoordinateSequenceFactory() const;
 
-    // FIXME:
-    // Until we tweak all the createMulti* interfaces
-    // to support taking iterators we'll have to build
-    // a custom vector here.
-    std::vector<Geometry*> fromGeoms;
-    for (T i=from; i != toofar; ++i) {
-      const Geometry* g = *i;
-      fromGeoms.push_back(const_cast<Geometry*>(g));
-    }
+    /// Returns a clone of given Geometry.
+    Geometry* createGeometry(const Geometry* g) const;
 
+    /// Destroy a Geometry, or release it
+    void destroyGeometry(Geometry* g) const;
 
-    // for an heterogeneous ...
-    if ( isHeterogeneous ) {
-      return std::unique_ptr<Geometry>( createGeometryCollection(fromGeoms) );
-    }
-
-    // At this point we know the collection is not hetereogenous.
-    if ( dynamic_cast<const Polygon*>(*from) ) {
-      return std::unique_ptr<Geometry>( createMultiPolygon(fromGeoms) );
-    } else if ( dynamic_cast<const LineString*>(*from) ) {
-      return std::unique_ptr<Geometry>( createMultiLineString(fromGeoms) );
-    } else if ( dynamic_cast<const Point*>(*from) ) {
-      return std::unique_ptr<Geometry>( createMultiPoint(fromGeoms) );
-    }
-    // FIXME: Why not to throw an exception? --mloskot
-    assert(0); // buildGeomtry encountered an unkwnon geometry type
-    return std::unique_ptr<Geometry>(); // nullptr
-  }
-
-	/** \brief
-	 * This function does the same thing of the omonimouse function
-	 * taking vector pointer instead of reference.
-	 *
-	 * The difference is that this version will copy needed data
-	 * leaving ownership to the caller.
-	 */
-	Geometry* buildGeometry(const std::vector<Geometry *> &geoms) const;
-
-	int getSRID() const;
-
-	/// \brief
-	/// Returns the CoordinateSequenceFactory associated
-	/// with this GeometryFactory
-	const CoordinateSequenceFactory* getCoordinateSequenceFactory() const;
-
-	/// Returns a clone of given Geometry.
-	Geometry* createGeometry(const Geometry *g) const;
-
-	/// Destroy a Geometry, or release it
-	void destroyGeometry(Geometry *g) const;
-
-	/// Request that the instance is deleted.
-  //
-  /// It will really be deleted only after last child Geometry is
-	/// deleted. Do not use the instance anymore after calling this function
-	/// (unless you're a live child!).
-	///
-	void destroy();
+    /// Request that the instance is deleted.
+    //
+    /// It will really be deleted only after last child Geometry is
+    /// deleted. Do not use the instance anymore after calling this function
+    /// (unless you're a live child!).
+    ///
+    void destroy();
 
 protected:
 
-	/**
-	 * \brief
-	 * Constructs a GeometryFactory that generates Geometries having a
-	 * floating PrecisionModel and a spatial-reference ID of 0.
-	 */
-	GeometryFactory();
-
-	/**
-	 * \brief
-	 * Constructs a GeometryFactory that generates Geometries having
-	 * the given PrecisionModel, spatial-reference ID, and
-	 * CoordinateSequence implementation.
-	 *
-	 * NOTES:
-	 * (1) the given PrecisionModel is COPIED
-	 * (2) the CoordinateSequenceFactory is NOT COPIED
-	 *     and must be available for the whole lifetime
-	 *     of the GeometryFactory
-	 */
-	GeometryFactory(const PrecisionModel *pm, int newSRID,
-		CoordinateSequenceFactory *nCoordinateSequenceFactory);
-
-	/**
-	 * \brief
-	 * Constructs a GeometryFactory that generates Geometries having the
-	 * given CoordinateSequence implementation, a double-precision floating
-	 * PrecisionModel and a spatial-reference ID of 0.
-	 */
-	GeometryFactory(CoordinateSequenceFactory *nCoordinateSequenceFactory);
-
-	/**
-	 * \brief
-	 * Constructs a GeometryFactory that generates Geometries having
-	 * the given PrecisionModel and the default CoordinateSequence
-	 * implementation.
-	 *
-	 * @param pm the PrecisionModel to use
-	 */
-	GeometryFactory(const PrecisionModel *pm);
-
-	/**
-	 * \brief
-	 * Constructs a GeometryFactory that generates Geometries having
-	 * the given {@link PrecisionModel} and spatial-reference ID,
-	 * and the default CoordinateSequence implementation.
-	 *
-	 * @param pm the PrecisionModel to use, will be copied internally
-	 * @param newSRID the SRID to use
-	 */
-	GeometryFactory(const PrecisionModel* pm, int newSRID);
-
-	/**
-	 * \brief Copy constructor
-	 *
-	 * @param gf the GeometryFactory to clone from
-	 */
-	GeometryFactory(const GeometryFactory &gf);
-
-	/// Destructor
-	virtual ~GeometryFactory();
+    /**
+     * \brief
+     * Constructs a GeometryFactory that generates Geometries having a
+     * floating PrecisionModel and a spatial-reference ID of 0.
+     */
+    GeometryFactory();
+
+    /**
+     * \brief
+     * Constructs a GeometryFactory that generates Geometries having
+     * the given PrecisionModel, spatial-reference ID, and
+     * CoordinateSequence implementation.
+     *
+     * NOTES:
+     * (1) the given PrecisionModel is COPIED
+     * (2) the CoordinateSequenceFactory is NOT COPIED
+     *     and must be available for the whole lifetime
+     *     of the GeometryFactory
+     */
+    GeometryFactory(const PrecisionModel* pm, int newSRID,
+                    CoordinateSequenceFactory* nCoordinateSequenceFactory);
+
+    /**
+     * \brief
+     * Constructs a GeometryFactory that generates Geometries having the
+     * given CoordinateSequence implementation, a double-precision floating
+     * PrecisionModel and a spatial-reference ID of 0.
+     */
+    GeometryFactory(CoordinateSequenceFactory* nCoordinateSequenceFactory);
+
+    /**
+     * \brief
+     * Constructs a GeometryFactory that generates Geometries having
+     * the given PrecisionModel and the default CoordinateSequence
+     * implementation.
+     *
+     * @param pm the PrecisionModel to use
+     */
+    GeometryFactory(const PrecisionModel* pm);
+
+    /**
+     * \brief
+     * Constructs a GeometryFactory that generates Geometries having
+     * the given {@link PrecisionModel} and spatial-reference ID,
+     * and the default CoordinateSequence implementation.
+     *
+     * @param pm the PrecisionModel to use, will be copied internally
+     * @param newSRID the SRID to use
+     */
+    GeometryFactory(const PrecisionModel* pm, int newSRID);
+
+    /**
+     * \brief Copy constructor
+     *
+     * @param gf the GeometryFactory to clone from
+     */
+    GeometryFactory(const GeometryFactory& gf);
+
+    /// Destructor
+    virtual ~GeometryFactory();
 
 private:
 
-	const PrecisionModel* precisionModel;
-	int SRID;
-	const CoordinateSequenceFactory *coordinateListFactory;
+    const PrecisionModel* precisionModel;
+    int SRID;
+    const CoordinateSequenceFactory* coordinateListFactory;
 
-	mutable int _refCount;
-	bool _autoDestroy;
+    mutable int _refCount;
+    bool _autoDestroy;
 
-friend class Geometry;
+    friend class Geometry;
 
-	void addRef() const;
-	void dropRef() const;
+    void addRef() const;
+    void dropRef() const;
 
 };
 
diff --git a/include/geos/geom/GeometryFactory.inl b/include/geos/geom/GeometryFactory.inl
index 74e2d14..2bdd6a1 100644
--- a/include/geos/geom/GeometryFactory.inl
+++ b/include/geos/geom/GeometryFactory.inl
@@ -7,7 +7,7 @@
  *
  * This is free software; you can redistribute and/or modify it under
  * the terms of the GNU Lesser General Public Licence as published
- * by the Free Software Foundation. 
+ * by the Free Software Foundation.
  * See the COPYING file for more information.
  *
  **********************************************************************
@@ -32,13 +32,13 @@ namespace geom { // geos::geom
 INLINE int
 GeometryFactory::getSRID() const
 {
-	return SRID;
+    return SRID;
 }
 
 INLINE const CoordinateSequenceFactory*
 GeometryFactory::getCoordinateSequenceFactory() const
 {
-	return coordinateListFactory;
+    return coordinateListFactory;
 }
 
 } // namespace geos::geom
diff --git a/include/geos/geom/GeometryFilter.h b/include/geos/geom/GeometryFilter.h
index 9bbaa5f..7ac4c38 100644
--- a/include/geos/geom/GeometryFilter.h
+++ b/include/geos/geom/GeometryFilter.h
@@ -24,9 +24,9 @@
 #include <cassert>
 
 namespace geos {
-	namespace geom { // geos::geom
-		class Geometry;
-	}
+namespace geom { // geos::geom
+class Geometry;
+}
 }
 
 namespace geos {
@@ -46,20 +46,29 @@ namespace geom { // geos::geom
  */
 class GEOS_DLL GeometryFilter {
 public:
-	/*
-	 * Performs an operation with or on <code>geom</code>.
-	 *
-	 * @param  geom  a <code>Geometry</code> to which the filter
-	 *         is applied.
-	 *
-	 * NOTE: this are not pure abstract to allow read-only
-	 * or read-write-only filters to avoid defining a fake
-	 * version of the not-implemented kind.
-	 */
-	virtual void filter_ro(const Geometry * /*geom*/) { assert(0); }
-	virtual void filter_rw(Geometry * /*geom*/) { assert(0); }
+    /*
+     * Performs an operation with or on <code>geom</code>.
+     *
+     * @param  geom  a <code>Geometry</code> to which the filter
+     *         is applied.
+     *
+     * NOTE: this are not pure abstract to allow read-only
+     * or read-write-only filters to avoid defining a fake
+     * version of the not-implemented kind.
+     */
+    virtual void
+    filter_ro(const Geometry* /*geom*/)
+    {
+        assert(0);
+    }
+    virtual void
+    filter_rw(Geometry* /*geom*/)
+    {
+        assert(0);
+    }
 
-	virtual ~GeometryFilter() {}
+    virtual
+    ~GeometryFilter() {}
 };
 
 } // namespace geos::geom
diff --git a/include/geos/geom/IntersectionMatrix.h b/include/geos/geom/IntersectionMatrix.h
index e225f4b..e1c1dcb 100644
--- a/include/geos/geom/IntersectionMatrix.h
+++ b/include/geos/geom/IntersectionMatrix.h
@@ -52,327 +52,327 @@ class GEOS_DLL IntersectionMatrix {
 
 public:
 
-	/** \brief
-	 * Default constructor.
-	 *
-	 * Creates an IntersectionMatrix with Dimension::False
-	 * dimension values ('F').
-	 */
-	IntersectionMatrix();
-
-	/** \brief
-	 * Overriden constructor.
-	 *
-	 * Creates an IntersectionMatrix with the given dimension symbols.
-	 *
-	 * @param elements - reference to string containing pattern
-	 *                   of dimension values for elements.
-	 */
-	IntersectionMatrix(const std::string& elements);
-
-	/** \brief
-	 * Copy constructor.
-	 *
-	 * Creates an IntersectionMatrix with the same elements as other.
-	 *
-	 * \todo Add assignment operator to make this class fully copyable.
-	 */
-	IntersectionMatrix(const IntersectionMatrix &other);
-
-	/** \brief
-	 * Returns whether the elements of this IntersectionMatrix
-	 * satisfies the required dimension symbols.
-	 *
-	 * @param requiredDimensionSymbols - nine dimension symbols with
-	 *        which to compare the elements of this IntersectionMatrix.
-	 *        Possible values are {T, F, * , 0, 1, 2}.
-	 * @return true if this IntersectionMatrix matches the required
-	 *         dimension symbols.
-	 */
-	bool matches(const std::string& requiredDimensionSymbols) const;
-
-	/** \brief
-	 * Tests if given dimension value satisfies the dimension symbol.
-	 *
-	 * @param actualDimensionValue - valid dimension value stored in
-	 *        the IntersectionMatrix.
-	 *        Possible values are {TRUE, FALSE, DONTCARE, 0, 1, 2}.
-	 * @param requiredDimensionSymbol - a character used in the string
-	 *        representation of an IntersectionMatrix.
-	 *        Possible values are {T, F, * , 0, 1, 2}.
-	 * @return true if the dimension symbol encompasses the
-	 *         dimension value.
-	 */
-	static bool matches(int actualDimensionValue,
-			char requiredDimensionSymbol);
-
-	/** \brief
-	 * Returns true if each of the actual dimension symbols satisfies
-	 * the corresponding required dimension symbol.
-	 *
-	 * @param actualDimensionSymbols - nine dimension symbols to validate.
-	 *        Possible values are {T, F, * , 0, 1, 2}.
-	 * @param requiredDimensionSymbols - nine dimension symbols to
-	 *        validate against.
-	 *        Possible values are {T, F, * , 0, 1, 2}.
-	 * @return true if each of the required dimension symbols encompass
-	 *         the corresponding actual dimension symbol.
-	 */
-	static bool matches(const std::string& actualDimensionSymbols,
-			const std::string& requiredDimensionSymbols);
-
-	/** \brief
-	 * Adds one matrix to another.
-	 *
-	 * Addition is defined by taking the maximum dimension value
-	 * of each position in the summand matrices.
-	 *
-	 * @param other - the matrix to add.
-	 *
-	 * \todo Why the 'other' matrix is not passed by const-reference?
-	 */
-	void add(IntersectionMatrix* other);
-
-	/** \brief
-	 * Changes the value of one of this IntersectionMatrixs elements.
-	 *
-	 * @param row - the row of this IntersectionMatrix, indicating
-	 *        the interior, boundary or exterior of the first Geometry.
-	 * @param column - the column of this IntersectionMatrix,
-	 *        indicating the interior, boundary or exterior of the
-	 *        second Geometry.
-	 * @param dimensionValue - the new value of the element.
-	 */
-	void set(int row, int column, int dimensionValue);
-
-	/** \brief
-	 * Changes the elements of this IntersectionMatrix to the dimension
-	 * symbols in dimensionSymbols.
-	 *
-	 * @param dimensionSymbols - nine dimension symbols to which to
-	 *        set this IntersectionMatrix elements.
-	 *        Possible values are {T, F, * , 0, 1, 2}.
-	 */
-	void set(const std::string& dimensionSymbols);
-
-	/** \brief
-	 * Changes the specified element to minimumDimensionValue if the
-	 * element is less.
-	 *
-	 * @param row - the row of this IntersectionMatrix, indicating
-	 *        the interior, boundary or exterior of the first Geometry.
-	 * @param column -  the column of this IntersectionMatrix, indicating
-	 *        the interior, boundary or exterior of the second Geometry.
-	 * @param minimumDimensionValue - the dimension value with which
-	 *        to compare the element.  The order of dimension values
-	 *        from least to greatest is {DONTCARE, TRUE, FALSE, 0, 1, 2}.
-	 */
-	void setAtLeast(size_t row, size_t column, int minimumDimensionValue);
-
-	/** \brief
-	 * If row >= 0 and column >= 0, changes the specified element
-	 * to minimumDimensionValue if the element is less.
-	 * Does nothing if row <0 or column < 0.
-	 *
-	 * @param row -
-	 *        the row of this IntersectionMatrix,
-	 *        indicating the interior, boundary or exterior of the
-	 *        first Geometry.
-	 *
-	 * @param column -
-	 *        the column of this IntersectionMatrix,
-	 *        indicating the interior, boundary or exterior of the
-	 *        second Geometry.
-	 *
-	 * @param minimumDimensionValue -
-	 *        the dimension value with which
-	 *        to compare the element. The order of dimension values
-	 *        from least to greatest is {DONTCARE, TRUE, FALSE, 0, 1, 2}.
-	 */
-	void setAtLeastIfValid(int row, int column, int minimumDimensionValue);
-
-	/** \brief
-	 * For each element in this IntersectionMatrix, changes the element to
-	 * the corresponding minimum dimension symbol if the element is less.
-	 *
-	 * @param minimumDimensionSymbols -
-	 *        nine dimension symbols with which
-	 *        to compare the elements of this IntersectionMatrix.
-	 *        The order of dimension values from least to greatest is
-	 *        {DONTCARE, TRUE, FALSE, 0, 1, 2}  .
-	 */
-	void setAtLeast(std::string minimumDimensionSymbols);
-
-	/** \brief
-	 * Changes the elements of this IntersectionMatrix to dimensionValue.
-	 *
-	 * @param dimensionValue -
-	 *        the dimension value to which to set this
-	 *        IntersectionMatrix elements. Possible values {TRUE,
-	 *        FALSE, DONTCARE, 0, 1, 2}.
-	 */
-	void setAll(int dimensionValue);
-
-	/** \brief
-	 * Returns the value of one of this IntersectionMatrixs elements.
-	 *
-	 * @param row -
-	 *        the row of this IntersectionMatrix, indicating the
-	 *        interior, boundary or exterior of the first Geometry.
-	 *
-	 * @param column -
-	 *        the column of this IntersectionMatrix, indicating the
-	 *        interior, boundary or exterior of the second Geometry.
-	 *
-	 * @return the dimension value at the given matrix position.
-	 */
-	int get(int row, int column) const;
-
-	/** \brief
-	 * Returns true if this IntersectionMatrix is FF*FF****.
-	 *
-	 * @return true if the two Geometrys related by this
-	 *         IntersectionMatrix are disjoint.
-	 */
-	bool isDisjoint() const;
-
-	/** \brief
-	 * Returns true if isDisjoint returns false.
-	 *
-	 * @return true if the two Geometrys related by this
-	 *         IntersectionMatrix intersect.
-	 */
-	bool isIntersects() const;
-
-	/** \brief
-	 * Returns true if this IntersectionMatrix is FT*******, F**T*****
-	 * or F***T****.
-	 *
-	 * @param dimensionOfGeometryA - the dimension of the first Geometry.
-	 *
-	 * @param dimensionOfGeometryB - the dimension of the second Geometry.
-	 *
-	 * @return true if the two Geometry's related by this
-	 *         IntersectionMatrix touch, false if both Geometrys
-	 *         are points.
-	 */
-	bool isTouches(int dimensionOfGeometryA, int dimensionOfGeometryB)
-			const;
-
-	/** \brief
-	 * Returns true if this IntersectionMatrix is:
-	 * - T*T****** (for a point and a curve, a point and an area or
-	 *   a line and an area)
-	 * - 0******** (for two curves)
-	 *
-	 * @param dimensionOfGeometryA - he dimension of the first Geometry.
-	 *
-	 * @param dimensionOfGeometryB - the dimension of the second Geometry.
-	 *
-	 * @return true if the two Geometry's related by this
-	 *         IntersectionMatrix cross.
-	 *
-	 * For this function to return true, the Geometrys must be a point
-	 * and a curve; a point and a surface; two curves; or a curve and
-	 * a surface.
-	 */
-	bool isCrosses(int dimensionOfGeometryA, int dimensionOfGeometryB)
-			const;
-
-	/** \brief
-	 * Returns true if this IntersectionMatrix is T*F**F***.
-	 *
-	 * @return true if the first Geometry is within the second.
-	 */
-	bool isWithin() const;
-
-	/** \brief
-	 * Returns true if this IntersectionMatrix is T*****FF*.
-	 *
-	 * @return true if the first Geometry contains the second.
-	 */
-	bool isContains() const;
-
-	/** \brief
-	 * Returns true if this IntersectionMatrix is T*F**FFF*.
-	 *
-	 * @param dimensionOfGeometryA - he dimension of the first Geometry.
-	 * @param dimensionOfGeometryB - the dimension of the second Geometry.
-	 * @return true if the two Geometry's related by this
-	 *         IntersectionMatrix are equal; the Geometrys must have
-	 *         the same dimension for this function to return true
-	 */
-	bool isEquals(int dimensionOfGeometryA, int dimensionOfGeometryB)
-		 const;
-
-	/** \brief
-	 * Returns true if this IntersectionMatrix is:
-	 * - T*T***T** (for two points or two surfaces)
-	 * - 1*T***T** (for two curves)
-	 *
-	 * @param dimensionOfGeometryA - he dimension of the first Geometry.
-	 * @param dimensionOfGeometryB - the dimension of the second Geometry.
-	 * @return true if the two Geometry's related by this
-	 *         IntersectionMatrix overlap.
-	 *
-	 * For this function to return true, the Geometrys must be two points,
-	 * two curves or two surfaces.
-	 */
-	bool isOverlaps(int dimensionOfGeometryA, int dimensionOfGeometryB)
-		const;
-
-	/** \brief
-	 * Returns true if this IntersectionMatrix is <code>T*****FF*</code>
-	 * or <code>*T****FF*</code> or <code>***T**FF*</code>
-	 * or <code>****T*FF*</code>
-	 *
-	 * @return <code>true</code> if the first Geometry covers the
-	 * second
-	 */
-	bool isCovers() const;
-
-
-	/** \brief
-	 * Returns true if this IntersectionMatrix is <code>T*F**F***</code>
-   	 * <code>*TF**F***</code> or <code>**FT*F***</code>
-	 * or <code>**F*TF***</code>
-	 *
-	 * @return <code>true</code> if the first Geometry is covered by
-	 * the second
-	 */
-	bool isCoveredBy() const;
-
-	/** \brief
-	 * Transposes this IntersectionMatrix.
-	 *
-	 * @return this IntersectionMatrix as a convenience.
-	 *
-	 * \todo It returns 'this' pointer so why not to return const-pointer?
-	 * \todo May be it would be better to return copy of transposed matrix?
-	 */
-	IntersectionMatrix* transpose();
-
-	/** \brief
-	 * Returns a nine-character String representation of this
-	 * IntersectionMatrix.
-	 *
-	 * @return the nine dimension symbols of this IntersectionMatrix
-	 * in row-major order.
-	 */
-	std::string toString() const;
+    /** \brief
+     * Default constructor.
+     *
+     * Creates an IntersectionMatrix with Dimension::False
+     * dimension values ('F').
+     */
+    IntersectionMatrix();
+
+    /** \brief
+     * Overriden constructor.
+     *
+     * Creates an IntersectionMatrix with the given dimension symbols.
+     *
+     * @param elements - reference to string containing pattern
+     *                   of dimension values for elements.
+     */
+    IntersectionMatrix(const std::string& elements);
+
+    /** \brief
+     * Copy constructor.
+     *
+     * Creates an IntersectionMatrix with the same elements as other.
+     *
+     * \todo Add assignment operator to make this class fully copyable.
+     */
+    IntersectionMatrix(const IntersectionMatrix& other);
+
+    /** \brief
+     * Returns whether the elements of this IntersectionMatrix
+     * satisfies the required dimension symbols.
+     *
+     * @param requiredDimensionSymbols - nine dimension symbols with
+     *        which to compare the elements of this IntersectionMatrix.
+     *        Possible values are {T, F, * , 0, 1, 2}.
+     * @return true if this IntersectionMatrix matches the required
+     *         dimension symbols.
+     */
+    bool matches(const std::string& requiredDimensionSymbols) const;
+
+    /** \brief
+     * Tests if given dimension value satisfies the dimension symbol.
+     *
+     * @param actualDimensionValue - valid dimension value stored in
+     *        the IntersectionMatrix.
+     *        Possible values are {TRUE, FALSE, DONTCARE, 0, 1, 2}.
+     * @param requiredDimensionSymbol - a character used in the string
+     *        representation of an IntersectionMatrix.
+     *        Possible values are {T, F, * , 0, 1, 2}.
+     * @return true if the dimension symbol encompasses the
+     *         dimension value.
+     */
+    static bool matches(int actualDimensionValue,
+                        char requiredDimensionSymbol);
+
+    /** \brief
+     * Returns true if each of the actual dimension symbols satisfies
+     * the corresponding required dimension symbol.
+     *
+     * @param actualDimensionSymbols - nine dimension symbols to validate.
+     *        Possible values are {T, F, * , 0, 1, 2}.
+     * @param requiredDimensionSymbols - nine dimension symbols to
+     *        validate against.
+     *        Possible values are {T, F, * , 0, 1, 2}.
+     * @return true if each of the required dimension symbols encompass
+     *         the corresponding actual dimension symbol.
+     */
+    static bool matches(const std::string& actualDimensionSymbols,
+                        const std::string& requiredDimensionSymbols);
+
+    /** \brief
+     * Adds one matrix to another.
+     *
+     * Addition is defined by taking the maximum dimension value
+     * of each position in the summand matrices.
+     *
+     * @param other - the matrix to add.
+     *
+     * \todo Why the 'other' matrix is not passed by const-reference?
+     */
+    void add(IntersectionMatrix* other);
+
+    /** \brief
+     * Changes the value of one of this IntersectionMatrixs elements.
+     *
+     * @param row - the row of this IntersectionMatrix, indicating
+     *        the interior, boundary or exterior of the first Geometry.
+     * @param column - the column of this IntersectionMatrix,
+     *        indicating the interior, boundary or exterior of the
+     *        second Geometry.
+     * @param dimensionValue - the new value of the element.
+     */
+    void set(int row, int column, int dimensionValue);
+
+    /** \brief
+     * Changes the elements of this IntersectionMatrix to the dimension
+     * symbols in dimensionSymbols.
+     *
+     * @param dimensionSymbols - nine dimension symbols to which to
+     *        set this IntersectionMatrix elements.
+     *        Possible values are {T, F, * , 0, 1, 2}.
+     */
+    void set(const std::string& dimensionSymbols);
+
+    /** \brief
+     * Changes the specified element to minimumDimensionValue if the
+     * element is less.
+     *
+     * @param row - the row of this IntersectionMatrix, indicating
+     *        the interior, boundary or exterior of the first Geometry.
+     * @param column -  the column of this IntersectionMatrix, indicating
+     *        the interior, boundary or exterior of the second Geometry.
+     * @param minimumDimensionValue - the dimension value with which
+     *        to compare the element.  The order of dimension values
+     *        from least to greatest is {DONTCARE, TRUE, FALSE, 0, 1, 2}.
+     */
+    void setAtLeast(size_t row, size_t column, int minimumDimensionValue);
+
+    /** \brief
+     * If row >= 0 and column >= 0, changes the specified element
+     * to minimumDimensionValue if the element is less.
+     * Does nothing if row <0 or column < 0.
+     *
+     * @param row -
+     *        the row of this IntersectionMatrix,
+     *        indicating the interior, boundary or exterior of the
+     *        first Geometry.
+     *
+     * @param column -
+     *        the column of this IntersectionMatrix,
+     *        indicating the interior, boundary or exterior of the
+     *        second Geometry.
+     *
+     * @param minimumDimensionValue -
+     *        the dimension value with which
+     *        to compare the element. The order of dimension values
+     *        from least to greatest is {DONTCARE, TRUE, FALSE, 0, 1, 2}.
+     */
+    void setAtLeastIfValid(int row, int column, int minimumDimensionValue);
+
+    /** \brief
+     * For each element in this IntersectionMatrix, changes the element to
+     * the corresponding minimum dimension symbol if the element is less.
+     *
+     * @param minimumDimensionSymbols -
+     *        nine dimension symbols with which
+     *        to compare the elements of this IntersectionMatrix.
+     *        The order of dimension values from least to greatest is
+     *        {DONTCARE, TRUE, FALSE, 0, 1, 2}  .
+     */
+    void setAtLeast(std::string minimumDimensionSymbols);
+
+    /** \brief
+     * Changes the elements of this IntersectionMatrix to dimensionValue.
+     *
+     * @param dimensionValue -
+     *        the dimension value to which to set this
+     *        IntersectionMatrix elements. Possible values {TRUE,
+     *        FALSE, DONTCARE, 0, 1, 2}.
+     */
+    void setAll(int dimensionValue);
+
+    /** \brief
+     * Returns the value of one of this IntersectionMatrixs elements.
+     *
+     * @param row -
+     *        the row of this IntersectionMatrix, indicating the
+     *        interior, boundary or exterior of the first Geometry.
+     *
+     * @param column -
+     *        the column of this IntersectionMatrix, indicating the
+     *        interior, boundary or exterior of the second Geometry.
+     *
+     * @return the dimension value at the given matrix position.
+     */
+    int get(int row, int column) const;
+
+    /** \brief
+     * Returns true if this IntersectionMatrix is FF*FF****.
+     *
+     * @return true if the two Geometrys related by this
+     *         IntersectionMatrix are disjoint.
+     */
+    bool isDisjoint() const;
+
+    /** \brief
+     * Returns true if isDisjoint returns false.
+     *
+     * @return true if the two Geometrys related by this
+     *         IntersectionMatrix intersect.
+     */
+    bool isIntersects() const;
+
+    /** \brief
+     * Returns true if this IntersectionMatrix is FT*******, F**T*****
+     * or F***T****.
+     *
+     * @param dimensionOfGeometryA - the dimension of the first Geometry.
+     *
+     * @param dimensionOfGeometryB - the dimension of the second Geometry.
+     *
+     * @return true if the two Geometry's related by this
+     *         IntersectionMatrix touch, false if both Geometrys
+     *         are points.
+     */
+    bool isTouches(int dimensionOfGeometryA, int dimensionOfGeometryB)
+    const;
+
+    /** \brief
+     * Returns true if this IntersectionMatrix is:
+     * - T*T****** (for a point and a curve, a point and an area or
+     *   a line and an area)
+     * - 0******** (for two curves)
+     *
+     * @param dimensionOfGeometryA - he dimension of the first Geometry.
+     *
+     * @param dimensionOfGeometryB - the dimension of the second Geometry.
+     *
+     * @return true if the two Geometry's related by this
+     *         IntersectionMatrix cross.
+     *
+     * For this function to return true, the Geometrys must be a point
+     * and a curve; a point and a surface; two curves; or a curve and
+     * a surface.
+     */
+    bool isCrosses(int dimensionOfGeometryA, int dimensionOfGeometryB)
+    const;
+
+    /** \brief
+     * Returns true if this IntersectionMatrix is T*F**F***.
+     *
+     * @return true if the first Geometry is within the second.
+     */
+    bool isWithin() const;
+
+    /** \brief
+     * Returns true if this IntersectionMatrix is T*****FF*.
+     *
+     * @return true if the first Geometry contains the second.
+     */
+    bool isContains() const;
+
+    /** \brief
+     * Returns true if this IntersectionMatrix is T*F**FFF*.
+     *
+     * @param dimensionOfGeometryA - he dimension of the first Geometry.
+     * @param dimensionOfGeometryB - the dimension of the second Geometry.
+     * @return true if the two Geometry's related by this
+     *         IntersectionMatrix are equal; the Geometrys must have
+     *         the same dimension for this function to return true
+     */
+    bool isEquals(int dimensionOfGeometryA, int dimensionOfGeometryB)
+    const;
+
+    /** \brief
+     * Returns true if this IntersectionMatrix is:
+     * - T*T***T** (for two points or two surfaces)
+     * - 1*T***T** (for two curves)
+     *
+     * @param dimensionOfGeometryA - he dimension of the first Geometry.
+     * @param dimensionOfGeometryB - the dimension of the second Geometry.
+     * @return true if the two Geometry's related by this
+     *         IntersectionMatrix overlap.
+     *
+     * For this function to return true, the Geometrys must be two points,
+     * two curves or two surfaces.
+     */
+    bool isOverlaps(int dimensionOfGeometryA, int dimensionOfGeometryB)
+    const;
+
+    /** \brief
+     * Returns true if this IntersectionMatrix is <code>T*****FF*</code>
+     * or <code>*T****FF*</code> or <code>***T**FF*</code>
+     * or <code>****T*FF*</code>
+     *
+     * @return <code>true</code> if the first Geometry covers the
+     * second
+     */
+    bool isCovers() const;
+
+
+    /** \brief
+     * Returns true if this IntersectionMatrix is <code>T*F**F***</code>
+     * <code>*TF**F***</code> or <code>**FT*F***</code>
+     * or <code>**F*TF***</code>
+     *
+     * @return <code>true</code> if the first Geometry is covered by
+     * the second
+     */
+    bool isCoveredBy() const;
+
+    /** \brief
+     * Transposes this IntersectionMatrix.
+     *
+     * @return this IntersectionMatrix as a convenience.
+     *
+     * \todo It returns 'this' pointer so why not to return const-pointer?
+     * \todo May be it would be better to return copy of transposed matrix?
+     */
+    IntersectionMatrix* transpose();
+
+    /** \brief
+     * Returns a nine-character String representation of this
+     * IntersectionMatrix.
+     *
+     * @return the nine dimension symbols of this IntersectionMatrix
+     * in row-major order.
+     */
+    std::string toString() const;
 
 private:
 
-	static const int firstDim; // = 3;
+    static const int firstDim; // = 3;
 
-	static const int secondDim; // = 3;
+    static const int secondDim; // = 3;
 
-	// Internal buffer for 3x3 matrix.
-	int matrix[3][3];
+    // Internal buffer for 3x3 matrix.
+    int matrix[3][3];
 
 }; // class IntersectionMatrix
 
-GEOS_DLL std::ostream& operator<< (std::ostream&os, const IntersectionMatrix& im);
+GEOS_DLL std::ostream& operator<< (std::ostream& os, const IntersectionMatrix& im);
 
 
 } // namespace geos::geom
diff --git a/include/geos/geom/LineSegment.h b/include/geos/geom/LineSegment.h
index 3c3bf02..073bea8 100644
--- a/include/geos/geom/LineSegment.h
+++ b/include/geos/geom/LineSegment.h
@@ -31,11 +31,11 @@
 
 // Forward declarations
 namespace geos {
-	namespace geom {
-		class CoordinateSequence;
-		class GeometryFactory;
-		class LineString;
-	}
+namespace geom {
+class CoordinateSequence;
+class GeometryFactory;
+class LineString;
+}
 }
 
 namespace geos {
@@ -57,314 +57,314 @@ namespace geom { // geos::geom
 class GEOS_DLL LineSegment {
 public:
 
-	friend std::ostream& operator<< (std::ostream& o, const LineSegment& l);
-
-	Coordinate p0; /// Segment start
-
-	Coordinate p1; /// Segment end
-
-	LineSegment();
-
-	LineSegment(const LineSegment &ls);
-
-	/// Constructs a LineSegment with the given start and end Coordinates.
-	LineSegment(const Coordinate& c0, const Coordinate& c1);
-
-	LineSegment(double x0, double y0, double x1, double y1);
-
-	virtual ~LineSegment();
-
-	void setCoordinates(const Coordinate& c0, const Coordinate& c1);
-
-	// obsoleted, use operator[] instead
-	//const Coordinate& getCoordinate(std::size_t i) const;
-
-	const Coordinate& operator[](std::size_t i) const;
-	Coordinate& operator[](std::size_t i);
-
-	void setCoordinates(const LineSegment& ls);
-
-	/// Computes the length of the line segment.
-	double getLength() const;
-
-	/// Tests whether the segment is horizontal.
-	//
-	/// @return <code>true</code> if the segment is horizontal
-	///
-	bool isHorizontal() const;
-
-	/// Tests whether the segment is vertical.
-	//
-	/// @return <code>true</code> if the segment is vertical
-	///
-	bool isVertical() const;
-
-	/**
-	 * Determines the orientation of a LineSegment relative to this segment.
-	 * The concept of orientation is specified as follows:
-	 * Given two line segments A and L,
-	 * <ul
-	 * <li>A is to the left of a segment L if A lies wholly in the
-	 * closed half-plane lying to the left of L
-	 * <li>A is to the right of a segment L if A lies wholly in the
-	 * closed half-plane lying to the right of L
-	 * <li>otherwise, A has indeterminate orientation relative to L.
-	 *     This happens if A is collinear with L or if A crosses
-	 *     the line determined by L.
-	 * </ul>
-	 *
-	 * @param seg the LineSegment to compare
-	 *
-	 * @return 1 if seg is to the left of this segment
-	 * @return -1 if seg is to the right of this segment
-	 * @return 0 if seg has indeterminate orientation relative
-	 *	     to this segment
-	 */
-	int orientationIndex(const LineSegment& seg) const;
-
-	// TODO: deprecate this
-	int orientationIndex(const LineSegment* seg) const;
-
-	/** \brief
-	 * Determines the orientation index of a Coordinate
-	 * relative to this segment.
-	 *
-	 * The orientation index is as defined in
-	 * Orientation::index.
-	 *
-	 * @param seg the LineSegment to compare
-	 *
-	 * @return 1 if <code>p</code> is to the left of this segment
-	 * @return -1 if <code>p</code> is to the right of this segment
-	 * @return 0 if <code>p</code> is collinear with this segment
-	 *
-	 * @see Orientation::index(Coordinate, Coordinate,
-	 *                                       Coordinate)
-	 */
-	int orientationIndex(const Coordinate& p) const;
-
-	/// Reverses the direction of the line segment.
-	void reverse();
-
-	/// Puts the line segment into a normalized form.
-	//
-	/// This is useful for using line segments in maps and indexes when
-	/// topological equality rather than exact equality is desired.
-	///
-	void normalize();
-
-	/// @return the angle this segment makes with the x-axis (in radians)
-	double angle() const;
-
-	/// Computes the midpoint of the segment
-	//
-	/// @param ret will be set to the midpoint of the segment
-	///
-	void midPoint(Coordinate& ret) const;
-
-	/// Computes the distance between this line segment and another one.
-	double distance(const LineSegment& ls) const;
-
-	/// Computes the distance between this line segment and a point.
-	double distance(const Coordinate& p) const;
-
-	/** \brief
-	 * Computes the perpendicular distance between the (infinite)
-	 * line defined by this line segment and a point.
-	 */
-	double distancePerpendicular(const Coordinate& p) const;
-
-	/** \brief
-	 * Computes the Coordinate that lies a given
-	 * fraction along the line defined by this segment.
-	 *
-	 * A fraction of <code>0.0</code> returns the start point of
-	 * the segment; a fraction of <code>1.0</code> returns the end
-	 * point of the segment.
-	 * If the fraction is < 0.0 or > 1.0 the point returned
-	 * will lie before the start or beyond the end of the segment.
-	 *
-	 * @param segmentLengthFraction the fraction of the segment length
-	 *        along the line
-	 * @param ret will be set to the point at that distance
-	 */
-	void pointAlong(double segmentLengthFraction, Coordinate& ret) const;
-
-	/** \brief
-	 * Computes the {@link Coordinate} that lies a given
-	 * fraction along the line defined by this segment and offset from
-	 * the segment by a given distance.
-	 *
-	 * A fraction of <code>0.0</code> offsets
-	 * from the start point of the segment;
-	 * a fraction of <code>1.0</code> offsets
-	 * from the end point of the segment.
-	 *
-	 * The computed point is offset to the left of the line
-	 * if the offset distance is positive, to the right if negative.
-	 *
-	 * @param segmentLengthFraction the fraction of the segment
-	 *                              length along the line
-	 *
-	 * @param offsetDistance the distance the point is offset
-	 *        from the segment
-	 *         (positive is to the left, negative is to the right)
-	 *
-	 * @param ret will be set to the point at that distance and offset
-	 *
-	 * @throws IllegalStateException if the segment has zero length
-	 */
-	void pointAlongOffset(double segmentLengthFraction,
-	                      double offsetDistance,
-	                      Coordinate& ret) const;
-
-	/** \brief
-	 * Compute the projection factor for the projection of the point p
-	 * onto this LineSegment.
-	 *
-	 * The projection factor is the constant r
-	 * by which the vector for this segment must be multiplied to
-	 * equal the vector for the projection of p on the line
-	 * defined by this segment.
-	 *
-	 * The projection factor returned will be in the range
-	 * (-inf, +inf)
-	 *
-	 * @param p the point to compute the factor for
-	 *
-	 * @return the projection factor for the point
-	 *
-	 */
-	double projectionFactor(const Coordinate& p) const;
-
-	/** \brief
-	 * Computes the fraction of distance (in <tt>[0.0, 1.0]</tt>)
-	 * that the projection of a point occurs along this line segment.
-	 *
-	 * If the point is beyond either ends of the line segment,
-	 * the closest fractional value (<tt>0.0</tt> or <tt>1.0</tt>)
-	 * is returned.
-	 *
-	 * Essentially, this is the {@link #projectionFactor} clamped to
-	 * the range <tt>[0.0, 1.0]</tt>.
-	 *
-	 * @param inputPt the point
-	 * @return the fraction along the line segment the projection
-	 *         of the point occurs
-	 */
-	double segmentFraction(const Coordinate& inputPt) const;
-
-	/** \brief
-	 * Compute the projection of a point onto the line determined
-	 * by this line segment.
-	 *
-	 * Note that the projected point
-	 * may lie outside the line segment.  If this is the case,
-	 * the projection factor will lie outside the range [0.0, 1.0].
-	 */
-	void project(const Coordinate& p, Coordinate& ret) const;
-
-	/** \brief
-	 * Project a line segment onto this line segment and return the resulting
-	 * line segment.
-	 *
-	 * The returned line segment will be a subset of
-	 * the target line line segment.  This subset may be null, if
-	 * the segments are oriented in such a way that there is no projection.
-	 *
-	 * Note that the returned line may have zero length (i.e. the same endpoints).
-	 * This can happen for instance if the lines are perpendicular to one another.
-	 *
-	 * @param seg the line segment to project
-	 * @param ret the projected line segment
-	 * @return true if there is an overlap, false otherwise
-	 */
-	bool project(const LineSegment& seg, LineSegment& ret) const;
-
-	/// Computes the closest point on this line segment to another point.
-	//
-	/// @param p the point to find the closest point to
-	/// @param ret the Coordinate to which the closest point on the line segment
-	///            to the point p will be written
-	///
-	void closestPoint(const Coordinate& p, Coordinate& ret) const;
-
-	/** \brief
-	 * Compares this object with the specified object for order.
-	 *
-	 * Uses the standard lexicographic ordering for the points in the LineSegment.
-	 *
-	 * @param  o  the LineSegment with which this LineSegment
-	 *            is being compared
-	 * @return a negative integer, zero, or a positive integer as this
-	 *         LineSegment is less than, equal to, or greater than the
-	 *         specified LineSegment
-	 */
-	int compareTo(const LineSegment& other) const;
-
-	/** \brief
-	 *  Returns <code>true</code> if <code>other</code> is
-	 *  topologically equal to this LineSegment (e.g. irrespective
-	 *  of orientation).
-	 *
-	 * @param  other  a <code>LineSegment</code> with which to do the comparison.
-	 * @return true if other is a LineSegment
-	 *      with the same values for the x and y ordinates.
-	 */
-	bool equalsTopo(const LineSegment& other) const;
-
-	/**
-	 * Computes the closest points on two line segments.
-	 * @param p the point to find the closest point to
-	 * @return a pair of Coordinates which are the closest points on
-	 * the line segments.
-	 * The returned CoordinateSequence must be deleted by caller
-	 */
-	CoordinateSequence* closestPoints(const LineSegment& line);
-
-	CoordinateSequence* closestPoints(const LineSegment* line);
-
-	/**
-	 * Computes an intersection point between two segments,
-	 * if there is one.
-	 * There may be 0, 1 or many intersection points between two segments.
-	 * If there are 0, null is returned. If there is 1 or more, a single
-	 * one is returned (chosen at the discretion of the algorithm).
-	 * If more information is required about the details of the
-	 * intersection, the LineIntersector class should be used.
-	 *
-	 * @param line
-	 * @param coord the Coordinate to write the result into
-	 * @return true if an intersection was found, false otherwise
-	 */
-	bool intersection(const LineSegment& line, Coordinate& coord) const;
-
-	/** \brief
-	 * Computes the intersection point of the lines defined
-	 * by two segments, if there is one.
-	 *
-	 * There may be 0, 1 or an infinite number of intersection points
-	 * between two lines.
-	 * If there is a unique intersection point, it is returned.
-	 * Otherwise, <tt>null</tt> is returned.
-	 * If more information is required about the details of the
-	 * intersection, the algorithms::LineIntersector class should
-	 * be used.
-	 *
-	 * @param line a line segment defining a straight line
-	 * @param ret will be set to the intersection point (if any)
-	 * @return true if an intersection was found, false otherwise
-	 *
-	 */
-	bool lineIntersection(const LineSegment& line, Coordinate& ret) const;
-
-	/**
-	 * Creates a LineString with the same coordinates as this segment
-	 *
-	 * @param gf the geometery factory to use
-	 * @return a LineString with the same geometry as this segment
-	 */
-	std::unique_ptr<LineString> toGeometry(const GeometryFactory& gf) const;
+    friend std::ostream& operator<< (std::ostream& o, const LineSegment& l);
+
+    Coordinate p0; /// Segment start
+
+    Coordinate p1; /// Segment end
+
+    LineSegment();
+
+    LineSegment(const LineSegment& ls);
+
+    /// Constructs a LineSegment with the given start and end Coordinates.
+    LineSegment(const Coordinate& c0, const Coordinate& c1);
+
+    LineSegment(double x0, double y0, double x1, double y1);
+
+    virtual ~LineSegment();
+
+    void setCoordinates(const Coordinate& c0, const Coordinate& c1);
+
+    // obsoleted, use operator[] instead
+    //const Coordinate& getCoordinate(std::size_t i) const;
+
+    const Coordinate& operator[](std::size_t i) const;
+    Coordinate& operator[](std::size_t i);
+
+    void setCoordinates(const LineSegment& ls);
+
+    /// Computes the length of the line segment.
+    double getLength() const;
+
+    /// Tests whether the segment is horizontal.
+    //
+    /// @return <code>true</code> if the segment is horizontal
+    ///
+    bool isHorizontal() const;
+
+    /// Tests whether the segment is vertical.
+    //
+    /// @return <code>true</code> if the segment is vertical
+    ///
+    bool isVertical() const;
+
+    /**
+     * Determines the orientation of a LineSegment relative to this segment.
+     * The concept of orientation is specified as follows:
+     * Given two line segments A and L,
+     * <ul
+     * <li>A is to the left of a segment L if A lies wholly in the
+     * closed half-plane lying to the left of L
+     * <li>A is to the right of a segment L if A lies wholly in the
+     * closed half-plane lying to the right of L
+     * <li>otherwise, A has indeterminate orientation relative to L.
+     *     This happens if A is collinear with L or if A crosses
+     *     the line determined by L.
+     * </ul>
+     *
+     * @param seg the LineSegment to compare
+     *
+     * @return 1 if seg is to the left of this segment
+     * @return -1 if seg is to the right of this segment
+     * @return 0 if seg has indeterminate orientation relative
+     *	     to this segment
+     */
+    int orientationIndex(const LineSegment& seg) const;
+
+    // TODO: deprecate this
+    int orientationIndex(const LineSegment* seg) const;
+
+    /** \brief
+     * Determines the orientation index of a Coordinate
+     * relative to this segment.
+     *
+     * The orientation index is as defined in
+     * Orientation::index.
+     *
+     * @param seg the LineSegment to compare
+     *
+     * @return 1 if <code>p</code> is to the left of this segment
+     * @return -1 if <code>p</code> is to the right of this segment
+     * @return 0 if <code>p</code> is collinear with this segment
+     *
+     * @see Orientation::index(Coordinate, Coordinate,
+     *                                       Coordinate)
+     */
+    int orientationIndex(const Coordinate& p) const;
+
+    /// Reverses the direction of the line segment.
+    void reverse();
+
+    /// Puts the line segment into a normalized form.
+    //
+    /// This is useful for using line segments in maps and indexes when
+    /// topological equality rather than exact equality is desired.
+    ///
+    void normalize();
+
+    /// @return the angle this segment makes with the x-axis (in radians)
+    double angle() const;
+
+    /// Computes the midpoint of the segment
+    //
+    /// @param ret will be set to the midpoint of the segment
+    ///
+    void midPoint(Coordinate& ret) const;
+
+    /// Computes the distance between this line segment and another one.
+    double distance(const LineSegment& ls) const;
+
+    /// Computes the distance between this line segment and a point.
+    double distance(const Coordinate& p) const;
+
+    /** \brief
+     * Computes the perpendicular distance between the (infinite)
+     * line defined by this line segment and a point.
+     */
+    double distancePerpendicular(const Coordinate& p) const;
+
+    /** \brief
+     * Computes the Coordinate that lies a given
+     * fraction along the line defined by this segment.
+     *
+     * A fraction of <code>0.0</code> returns the start point of
+     * the segment; a fraction of <code>1.0</code> returns the end
+     * point of the segment.
+     * If the fraction is < 0.0 or > 1.0 the point returned
+     * will lie before the start or beyond the end of the segment.
+     *
+     * @param segmentLengthFraction the fraction of the segment length
+     *        along the line
+     * @param ret will be set to the point at that distance
+     */
+    void pointAlong(double segmentLengthFraction, Coordinate& ret) const;
+
+    /** \brief
+     * Computes the {@link Coordinate} that lies a given
+     * fraction along the line defined by this segment and offset from
+     * the segment by a given distance.
+     *
+     * A fraction of <code>0.0</code> offsets
+     * from the start point of the segment;
+     * a fraction of <code>1.0</code> offsets
+     * from the end point of the segment.
+     *
+     * The computed point is offset to the left of the line
+     * if the offset distance is positive, to the right if negative.
+     *
+     * @param segmentLengthFraction the fraction of the segment
+     *                              length along the line
+     *
+     * @param offsetDistance the distance the point is offset
+     *        from the segment
+     *         (positive is to the left, negative is to the right)
+     *
+     * @param ret will be set to the point at that distance and offset
+     *
+     * @throws IllegalStateException if the segment has zero length
+     */
+    void pointAlongOffset(double segmentLengthFraction,
+                          double offsetDistance,
+                          Coordinate& ret) const;
+
+    /** \brief
+     * Compute the projection factor for the projection of the point p
+     * onto this LineSegment.
+     *
+     * The projection factor is the constant r
+     * by which the vector for this segment must be multiplied to
+     * equal the vector for the projection of p on the line
+     * defined by this segment.
+     *
+     * The projection factor returned will be in the range
+     * (-inf, +inf)
+     *
+     * @param p the point to compute the factor for
+     *
+     * @return the projection factor for the point
+     *
+     */
+    double projectionFactor(const Coordinate& p) const;
+
+    /** \brief
+     * Computes the fraction of distance (in <tt>[0.0, 1.0]</tt>)
+     * that the projection of a point occurs along this line segment.
+     *
+     * If the point is beyond either ends of the line segment,
+     * the closest fractional value (<tt>0.0</tt> or <tt>1.0</tt>)
+     * is returned.
+     *
+     * Essentially, this is the {@link #projectionFactor} clamped to
+     * the range <tt>[0.0, 1.0]</tt>.
+     *
+     * @param inputPt the point
+     * @return the fraction along the line segment the projection
+     *         of the point occurs
+     */
+    double segmentFraction(const Coordinate& inputPt) const;
+
+    /** \brief
+     * Compute the projection of a point onto the line determined
+     * by this line segment.
+     *
+     * Note that the projected point
+     * may lie outside the line segment.  If this is the case,
+     * the projection factor will lie outside the range [0.0, 1.0].
+     */
+    void project(const Coordinate& p, Coordinate& ret) const;
+
+    /** \brief
+     * Project a line segment onto this line segment and return the resulting
+     * line segment.
+     *
+     * The returned line segment will be a subset of
+     * the target line line segment.  This subset may be null, if
+     * the segments are oriented in such a way that there is no projection.
+     *
+     * Note that the returned line may have zero length (i.e. the same endpoints).
+     * This can happen for instance if the lines are perpendicular to one another.
+     *
+     * @param seg the line segment to project
+     * @param ret the projected line segment
+     * @return true if there is an overlap, false otherwise
+     */
+    bool project(const LineSegment& seg, LineSegment& ret) const;
+
+    /// Computes the closest point on this line segment to another point.
+    //
+    /// @param p the point to find the closest point to
+    /// @param ret the Coordinate to which the closest point on the line segment
+    ///            to the point p will be written
+    ///
+    void closestPoint(const Coordinate& p, Coordinate& ret) const;
+
+    /** \brief
+     * Compares this object with the specified object for order.
+     *
+     * Uses the standard lexicographic ordering for the points in the LineSegment.
+     *
+     * @param  o  the LineSegment with which this LineSegment
+     *            is being compared
+     * @return a negative integer, zero, or a positive integer as this
+     *         LineSegment is less than, equal to, or greater than the
+     *         specified LineSegment
+     */
+    int compareTo(const LineSegment& other) const;
+
+    /** \brief
+     *  Returns <code>true</code> if <code>other</code> is
+     *  topologically equal to this LineSegment (e.g. irrespective
+     *  of orientation).
+     *
+     * @param  other  a <code>LineSegment</code> with which to do the comparison.
+     * @return true if other is a LineSegment
+     *      with the same values for the x and y ordinates.
+     */
+    bool equalsTopo(const LineSegment& other) const;
+
+    /**
+     * Computes the closest points on two line segments.
+     * @param p the point to find the closest point to
+     * @return a pair of Coordinates which are the closest points on
+     * the line segments.
+     * The returned CoordinateSequence must be deleted by caller
+     */
+    CoordinateSequence* closestPoints(const LineSegment& line);
+
+    CoordinateSequence* closestPoints(const LineSegment* line);
+
+    /**
+     * Computes an intersection point between two segments,
+     * if there is one.
+     * There may be 0, 1 or many intersection points between two segments.
+     * If there are 0, null is returned. If there is 1 or more, a single
+     * one is returned (chosen at the discretion of the algorithm).
+     * If more information is required about the details of the
+     * intersection, the LineIntersector class should be used.
+     *
+     * @param line
+     * @param coord the Coordinate to write the result into
+     * @return true if an intersection was found, false otherwise
+     */
+    bool intersection(const LineSegment& line, Coordinate& coord) const;
+
+    /** \brief
+     * Computes the intersection point of the lines defined
+     * by two segments, if there is one.
+     *
+     * There may be 0, 1 or an infinite number of intersection points
+     * between two lines.
+     * If there is a unique intersection point, it is returned.
+     * Otherwise, <tt>null</tt> is returned.
+     * If more information is required about the details of the
+     * intersection, the algorithms::LineIntersector class should
+     * be used.
+     *
+     * @param line a line segment defining a straight line
+     * @param ret will be set to the intersection point (if any)
+     * @return true if an intersection was found, false otherwise
+     *
+     */
+    bool lineIntersection(const LineSegment& line, Coordinate& ret) const;
+
+    /**
+     * Creates a LineString with the same coordinates as this segment
+     *
+     * @param gf the geometery factory to use
+     * @return a LineString with the same geometry as this segment
+     */
+    std::unique_ptr<LineString> toGeometry(const GeometryFactory& gf) const;
 
 };
 
diff --git a/include/geos/geom/LineSegment.inl b/include/geos/geom/LineSegment.inl
index 5c43324..76724ee 100644
--- a/include/geos/geom/LineSegment.inl
+++ b/include/geos/geom/LineSegment.inl
@@ -33,25 +33,25 @@ namespace geom { // geos::geom
 
 INLINE
 LineSegment::LineSegment(const LineSegment& ls)
-	:
-	p0(ls.p0),
-	p1(ls.p1)
+    :
+    p0(ls.p0),
+    p1(ls.p1)
 {
 }
 
 INLINE
 LineSegment::LineSegment(const Coordinate& c0, const Coordinate& c1)
-	:
-	p0(c0),
-	p1(c1)
+    :
+    p0(c0),
+    p1(c1)
 {
 }
 
 INLINE
 LineSegment::LineSegment(double x0, double y0, double x1, double y1)
-	:
-	p0(x0, y0),
-	p1(x1, y1)
+    :
+    p0(x0, y0),
+    p1(x1, y1)
 {
 }
 
@@ -68,126 +68,133 @@ LineSegment::~LineSegment()
 INLINE double
 LineSegment::distancePerpendicular(const Coordinate& p) const
 {
-	return algorithm::Distance::pointToLinePerpendicular(p, p0, p1);
+    return algorithm::Distance::pointToLinePerpendicular(p, p0, p1);
 }
 
 INLINE void
 LineSegment::pointAlong(double segmentLengthFraction, Coordinate& ret) const
 {
     ret = Coordinate(
-	p0.x + segmentLengthFraction * (p1.x - p0.x),
-	p0.y + segmentLengthFraction * (p1.y - p0.y));
+              p0.x + segmentLengthFraction * (p1.x - p0.x),
+              p0.y + segmentLengthFraction * (p1.y - p0.y));
 }
 
 INLINE double
 LineSegment::distance(const LineSegment& ls) const
 {
-	return algorithm::Distance::segmentToSegment(p0, p1, ls.p0, ls.p1);
+    return algorithm::Distance::segmentToSegment(p0, p1, ls.p0, ls.p1);
 }
 
 /*public*/
 INLINE double
 LineSegment::distance(const Coordinate& p) const
 {
-	return algorithm::Distance::pointToSegment(p, p0, p1);
+    return algorithm::Distance::pointToSegment(p, p0, p1);
 }
 
 INLINE void
 LineSegment::normalize()
 {
-	if (p1.compareTo(p0)<0) reverse();
+    if(p1.compareTo(p0) < 0) {
+        reverse();
+    }
 }
 
 
 INLINE void
 LineSegment::setCoordinates(const Coordinate& c0, const Coordinate& c1)
 {
-	p0=c0; p1=c1;
+    p0 = c0;
+    p1 = c1;
 }
 
 INLINE const Coordinate&
 LineSegment::operator[](std::size_t i) const
 {
-	if (i==0) return p0;
-	assert(i==1);
-	return p1;
+    if(i == 0) {
+        return p0;
+    }
+    assert(i == 1);
+    return p1;
 }
 
 INLINE Coordinate&
 LineSegment::operator[](std::size_t i)
 {
-	if (i==0) return p0;
-	assert(i==1);
-	return p1;
+    if(i == 0) {
+        return p0;
+    }
+    assert(i == 1);
+    return p1;
 }
 
 INLINE void
 LineSegment::setCoordinates(const LineSegment& ls)
 {
-	setCoordinates(ls.p0,ls.p1);
+    setCoordinates(ls.p0, ls.p1);
 }
 
 INLINE double
 LineSegment::getLength() const
 {
-	return p0.distance(p1);
+    return p0.distance(p1);
 }
 
 INLINE bool
 LineSegment::isHorizontal() const
 {
-	return p0.y == p1.y;
+    return p0.y == p1.y;
 }
 
 INLINE bool
 LineSegment::isVertical() const
 {
-	return p0.x == p1.x;
+    return p0.x == p1.x;
 }
 
 INLINE int
 LineSegment::orientationIndex(const LineSegment* seg) const
 {
-	assert(seg);
-	return orientationIndex(*seg);
+    assert(seg);
+    return orientationIndex(*seg);
 }
 
 INLINE int
 LineSegment::orientationIndex(const Coordinate& p) const
 {
-	return algorithm::Orientation::index(p0, p1, p);
+    return algorithm::Orientation::index(p0, p1, p);
 }
 
 INLINE CoordinateSequence*
 LineSegment::closestPoints(const LineSegment* line)
 {
-	assert(line);
-	return closestPoints(*line);
+    assert(line);
+    return closestPoints(*line);
 }
 
 INLINE double
 LineSegment::angle() const
 {
-	return std::atan2(p1.y-p0.y,p1.x-p0.x);
+    return std::atan2(p1.y - p0.y, p1.x - p0.x);
 }
 
 INLINE void
 LineSegment::midPoint(Coordinate& ret) const
 {
-	ret = Coordinate( (p0.x + p1.x) / 2,
-	                  (p0.y + p1.y) / 2 );
+    ret = Coordinate((p0.x + p1.x) / 2,
+                     (p0.y + p1.y) / 2);
 }
 
 INLINE std::ostream&
 operator<< (std::ostream& o, const LineSegment& l)
 {
-	return o<<"LINESEGMENT("<<l.p0.x<<" "<<l.p0.y<<","<<l.p1.x<<" "<<l.p1.y<<")";
+    return o << "LINESEGMENT(" << l.p0.x << " " << l.p0.y << "," << l.p1.x << " " << l.p1.y << ")";
 }
 
 INLINE bool
 operator==(const LineSegment& a, const LineSegment& b)
 {
-	return a.p0==b.p0 && a.p1==b.p1;
+    return a.p0 == b.p0 && a.p1 == b.p1;
 }
 
 
diff --git a/include/geos/geom/LineString.h b/include/geos/geom/LineString.h
index 25bc13d..16a14ab 100644
--- a/include/geos/geom/LineString.h
+++ b/include/geos/geom/LineString.h
@@ -40,11 +40,11 @@
 #endif
 
 namespace geos {
-	namespace geom {
-		class Coordinate;
-		class CoordinateArraySequence;
-		class CoordinateSequenceFilter;
-	}
+namespace geom {
+class Coordinate;
+class CoordinateArraySequence;
+class CoordinateSequenceFilter;
+}
 }
 
 namespace geos {
@@ -70,155 +70,162 @@ class GEOS_DLL LineString: public virtual Geometry, public Lineal {
 
 public:
 
-	friend class GeometryFactory;
+    friend class GeometryFactory;
 
-	/// A vector of const LineString pointers
-	typedef std::vector<const LineString *> ConstVect;
+    /// A vector of const LineString pointers
+    typedef std::vector<const LineString*> ConstVect;
 
-	~LineString() override;
+    ~LineString() override;
 
-	/**
-	 * \brief
-	 * Creates and returns a full copy of this {@link LineString} object
-	 * (including all coordinates contained by it)
-	 *
-	 * @return A clone of this instance
-	 */
-	Geometry *clone() const override;
+    /**
+     * \brief
+     * Creates and returns a full copy of this {@link LineString} object
+     * (including all coordinates contained by it)
+     *
+     * @return A clone of this instance
+     */
+    Geometry* clone() const override;
 
-	CoordinateSequence* getCoordinates() const override;
+    CoordinateSequence* getCoordinates() const override;
 
-	/// Returns a read-only pointer to internal CoordinateSequence
-	const CoordinateSequence* getCoordinatesRO() const;
+    /// Returns a read-only pointer to internal CoordinateSequence
+    const CoordinateSequence* getCoordinatesRO() const;
 
-	virtual const Coordinate& getCoordinateN(size_t n) const;
+    virtual const Coordinate& getCoordinateN(size_t n) const;
 
-	/// Returns line dimension (1)
-	Dimension::DimensionType getDimension() const override;
+    /// Returns line dimension (1)
+    Dimension::DimensionType getDimension() const override;
 
-	/**
-	 * \brief
-	 * Returns Dimension::False for a closed LineString,
-	 * 0 otherwise (LineString boundary is a MultiPoint)
-	 */
-	int getBoundaryDimension() const override;
+    /**
+     * \brief
+     * Returns Dimension::False for a closed LineString,
+     * 0 otherwise (LineString boundary is a MultiPoint)
+     */
+    int getBoundaryDimension() const override;
 
-	/// Returns coordinate dimension.
-	int getCoordinateDimension() const override;
+    /// Returns coordinate dimension.
+    int getCoordinateDimension() const override;
 
-	/**
-	 * \brief
-	 * Returns a MultiPoint.
-	 * Empty for closed LineString, a Point for each vertex otherwise.
-	 */
-	Geometry* getBoundary() const override;
+    /**
+     * \brief
+     * Returns a MultiPoint.
+     * Empty for closed LineString, a Point for each vertex otherwise.
+     */
+    Geometry* getBoundary() const override;
 
-	bool isEmpty() const override;
+    bool isEmpty() const override;
 
-	std::size_t getNumPoints() const override;
+    std::size_t getNumPoints() const override;
 
-	virtual Point* getPointN(std::size_t n) const;
+    virtual Point* getPointN(std::size_t n) const;
 
-	/// \brief
-	/// Return the start point of the LineString
-	/// or NULL if this is an EMPTY LineString.
-	///
-	virtual Point* getStartPoint() const;
+    /// \brief
+    /// Return the start point of the LineString
+    /// or NULL if this is an EMPTY LineString.
+    ///
+    virtual Point* getStartPoint() const;
 
-	/// \brief
-	/// Return the end point of the LineString
-	/// or NULL if this is an EMPTY LineString.
-	///
-	virtual Point* getEndPoint() const;
+    /// \brief
+    /// Return the end point of the LineString
+    /// or NULL if this is an EMPTY LineString.
+    ///
+    virtual Point* getEndPoint() const;
 
-	virtual bool isClosed() const;
+    virtual bool isClosed() const;
 
-	virtual bool isRing() const;
+    virtual bool isRing() const;
 
-	std::string getGeometryType() const override;
+    std::string getGeometryType() const override;
 
-	GeometryTypeId getGeometryTypeId() const override;
+    GeometryTypeId getGeometryTypeId() const override;
 
-	virtual bool isCoordinate(Coordinate& pt) const;
+    virtual bool isCoordinate(Coordinate& pt) const;
 
-	bool equalsExact(const Geometry *other, double tolerance=0)
-		const override;
+    bool equalsExact(const Geometry* other, double tolerance = 0)
+    const override;
 
-	void apply_rw(const CoordinateFilter *filter) override;
+    void apply_rw(const CoordinateFilter* filter) override;
 
-	void apply_ro(CoordinateFilter *filter) const override;
+    void apply_ro(CoordinateFilter* filter) const override;
 
-	void apply_rw(GeometryFilter *filter) override;
+    void apply_rw(GeometryFilter* filter) override;
 
-	void apply_ro(GeometryFilter *filter) const override;
+    void apply_ro(GeometryFilter* filter) const override;
 
-	void apply_rw(GeometryComponentFilter *filter) override;
+    void apply_rw(GeometryComponentFilter* filter) override;
 
-	void apply_ro(GeometryComponentFilter *filter) const override;
+    void apply_ro(GeometryComponentFilter* filter) const override;
 
-	void apply_rw(CoordinateSequenceFilter& filter) override;
+    void apply_rw(CoordinateSequenceFilter& filter) override;
 
-	void apply_ro(CoordinateSequenceFilter& filter) const override;
+    void apply_ro(CoordinateSequenceFilter& filter) const override;
 
-	/** \brief
-	 * Normalizes a LineString.
-	 *
-	 * A normalized linestring
-	 * has the first point which is not equal to its reflected point
-	 * less than the reflected point.
-	 */
-	void normalize() override;
+    /** \brief
+     * Normalizes a LineString.
+     *
+     * A normalized linestring
+     * has the first point which is not equal to its reflected point
+     * less than the reflected point.
+     */
+    void normalize() override;
 
-	//was protected
-	int compareToSameClass(const Geometry *ls) const override;
+    //was protected
+    int compareToSameClass(const Geometry* ls) const override;
 
-	const Coordinate* getCoordinate() const override;
+    const Coordinate* getCoordinate() const override;
 
-	double getLength() const override;
+    double getLength() const override;
 
-	/**
-	 * Creates a LineString whose coordinates are in the reverse
-	 * order of this object's
-	 *
-	 * @return a LineString with coordinates in the reverse order
-	 */
-  	Geometry* reverse() const override;
+    /**
+     * Creates a LineString whose coordinates are in the reverse
+     * order of this object's
+     *
+     * @return a LineString with coordinates in the reverse order
+     */
+    Geometry* reverse() const override;
 
 protected:
 
-	LineString(const LineString &ls);
+    LineString(const LineString& ls);
 
-	/// \brief
-	/// Constructs a LineString taking ownership the
-	/// given CoordinateSequence.
-	LineString(CoordinateSequence *pts, const GeometryFactory *newFactory);
+    /// \brief
+    /// Constructs a LineString taking ownership the
+    /// given CoordinateSequence.
+    LineString(CoordinateSequence* pts, const GeometryFactory* newFactory);
 
-	/// Hopefully cleaner version of the above
-	LineString(CoordinateSequence::Ptr pts,
-			const GeometryFactory *newFactory);
+    /// Hopefully cleaner version of the above
+    LineString(CoordinateSequence::Ptr pts,
+               const GeometryFactory* newFactory);
 
-	Envelope::Ptr computeEnvelopeInternal() const override;
+    Envelope::Ptr computeEnvelopeInternal() const override;
 
-	CoordinateSequence::Ptr points;
+    CoordinateSequence::Ptr points;
 
-	int getSortIndex() const override { return SORTINDEX_LINESTRING; };
+    int
+    getSortIndex() const override
+    {
+        return SORTINDEX_LINESTRING;
+    };
 
 private:
 
-	void validateConstruction();
+    void validateConstruction();
 
 };
 
 struct GEOS_DLL  LineStringLT {
-	bool operator()(const LineString *ls1, const LineString *ls2) const {
-		return ls1->compareTo(ls2)<0;
-	}
+    bool
+    operator()(const LineString* ls1, const LineString* ls2) const
+    {
+        return ls1->compareTo(ls2) < 0;
+    }
 };
 
 
 inline Geometry*
-LineString::clone() const {
-	return new LineString(*this);
+LineString::clone() const
+{
+    return new LineString(*this);
 }
 
 } // namespace geos::geom
diff --git a/include/geos/geom/Lineal.h b/include/geos/geom/Lineal.h
index ebd8c32..8664367 100644
--- a/include/geos/geom/Lineal.h
+++ b/include/geos/geom/Lineal.h
@@ -34,10 +34,9 @@ namespace geom { // geos::geom
  * Identifies {@link Geometry} subclasses which
  * are 1-dimensional and with components which are {@link LineString}s.
  */
-class GEOS_DLL Lineal : public virtual Geometry
-{
+class GEOS_DLL Lineal : public virtual Geometry {
 protected:
-  Lineal(): Geometry(nullptr) {}
+    Lineal(): Geometry(nullptr) {}
 };
 
 } // namespace geos::geom
diff --git a/include/geos/geom/LinearRing.h b/include/geos/geom/LinearRing.h
index 71ef6f2..43b55d9 100644
--- a/include/geos/geom/LinearRing.h
+++ b/include/geos/geom/LinearRing.h
@@ -29,10 +29,10 @@
 
 // Forward declarations
 namespace geos {
-	namespace geom { // geos::geom
-		class Coordinate;
-		class CoordinateArraySequence;
-	}
+namespace geom { // geos::geom
+class Coordinate;
+class CoordinateArraySequence;
+}
 }
 
 namespace geos {
@@ -57,63 +57,71 @@ class GEOS_DLL LinearRing : public LineString {
 
 public:
 
-	/**
-	 * The minimum number of vertices allowed in a valid non-empty ring (= 4).
-	 * Empty rings with 0 vertices are also valid.
-	 */
-	static const unsigned int MINIMUM_VALID_SIZE = 4;
+    /**
+     * The minimum number of vertices allowed in a valid non-empty ring (= 4).
+     * Empty rings with 0 vertices are also valid.
+     */
+    static const unsigned int MINIMUM_VALID_SIZE = 4;
 
-	LinearRing(const LinearRing &lr);
+    LinearRing(const LinearRing& lr);
 
-	/**
-	 * \brief Constructs a <code>LinearRing</code> with the given points.
-	 *
-	 * @param  points  points forming a closed and simple linestring, or
-	 *      <code>null</code> or an empty array to create the empty
-	 *      geometry.
-	 *      This array must not contain <code>null</code> elements.
-	 *	If not null LinearRing will take ownership of points.
-	 *
-	 * @param newFactory the GeometryFactory used to create this geometry
-	 *
-	 */
-	LinearRing(CoordinateSequence* points,
-			const GeometryFactory *newFactory);
+    /**
+     * \brief Constructs a <code>LinearRing</code> with the given points.
+     *
+     * @param  points  points forming a closed and simple linestring, or
+     *      <code>null</code> or an empty array to create the empty
+     *      geometry.
+     *      This array must not contain <code>null</code> elements.
+     *	If not null LinearRing will take ownership of points.
+     *
+     * @param newFactory the GeometryFactory used to create this geometry
+     *
+     */
+    LinearRing(CoordinateSequence* points,
+               const GeometryFactory* newFactory);
 
-	/// Hopefully cleaner version of the above
-	LinearRing(CoordinateSequence::Ptr points,
-			const GeometryFactory *newFactory);
+    /// Hopefully cleaner version of the above
+    LinearRing(CoordinateSequence::Ptr points,
+               const GeometryFactory* newFactory);
 
-	Geometry *clone() const override { return new LinearRing(*this); }
+    Geometry*
+    clone() const override
+    {
+        return new LinearRing(*this);
+    }
 
-	~LinearRing() override;
+    ~LinearRing() override;
 
-	/** \brief
-	 * Returns <code>Dimension.FALSE</code>, since by definition
-	 * LinearRings do not have a boundary.
-	 *
-	 * @return Dimension::False
-	 */
-	int getBoundaryDimension() const override;
+    /** \brief
+     * Returns <code>Dimension.FALSE</code>, since by definition
+     * LinearRings do not have a boundary.
+     *
+     * @return Dimension::False
+     */
+    int getBoundaryDimension() const override;
 
-	bool isClosed() const override;
+    bool isClosed() const override;
 
-	std::string getGeometryType() const override;
+    std::string getGeometryType() const override;
 
-	GeometryTypeId getGeometryTypeId() const override;
+    GeometryTypeId getGeometryTypeId() const override;
 
-	void setPoints(CoordinateSequence* cl);
+    void setPoints(CoordinateSequence* cl);
 
-  	Geometry* reverse() const override;
+    Geometry* reverse() const override;
 
 protected:
 
-		int getSortIndex() const override { return SORTINDEX_LINEARRING; };
+    int
+    getSortIndex() const override
+    {
+        return SORTINDEX_LINEARRING;
+    };
 
 
 private:
 
-	void validateConstruction();
+    void validateConstruction();
 };
 
 
diff --git a/include/geos/geom/Location.h b/include/geos/geom/Location.h
index ebb80dd..24f9a71 100644
--- a/include/geos/geom/Location.h
+++ b/include/geos/geom/Location.h
@@ -34,36 +34,36 @@ namespace geom { // geos::geom
  */
 class GEOS_DLL Location {
 public:
-	enum Value {
+    enum Value {
 
-		/**
-		 *  Used for uninitialized location values.
-		 */
-		UNDEF=-1,   // Instead of NULL
+        /**
+         *  Used for uninitialized location values.
+         */
+        UNDEF = -1, // Instead of NULL
 
-		/**
-		 * DE-9IM row index of the interior of the first geometry and
-		 * column index of the interior of the second geometry.
-		 * Location value for the interior of a geometry.
-		 */
-		INTERIOR = 0,
+        /**
+         * DE-9IM row index of the interior of the first geometry and
+         * column index of the interior of the second geometry.
+         * Location value for the interior of a geometry.
+         */
+        INTERIOR = 0,
 
-		/**
-		 * DE-9IM row index of the boundary of the first geometry and
-		 * column index of the boundary of the second geometry.
-		 * Location value for the boundary of a geometry.
-		 */
-		BOUNDARY = 1,
+        /**
+         * DE-9IM row index of the boundary of the first geometry and
+         * column index of the boundary of the second geometry.
+         * Location value for the boundary of a geometry.
+         */
+        BOUNDARY = 1,
 
-		/**
-		 * DE-9IM row index of the exterior of the first geometry and
-		 * column index of the exterior of the second geometry.
-		 * Location value for the exterior of a geometry.
-		 */
-		EXTERIOR = 2
-	};
+        /**
+         * DE-9IM row index of the exterior of the first geometry and
+         * column index of the exterior of the second geometry.
+         * Location value for the exterior of a geometry.
+         */
+        EXTERIOR = 2
+    };
 
-	static char toLocationSymbol(int locationValue);
+    static char toLocationSymbol(int locationValue);
 };
 
 } // namespace geos::geom
diff --git a/include/geos/geom/MultiLineString.h b/include/geos/geom/MultiLineString.h
index d806481..95cd362 100644
--- a/include/geos/geom/MultiLineString.h
+++ b/include/geos/geom/MultiLineString.h
@@ -33,10 +33,10 @@
 
 // Forward declarations
 namespace geos {
-	namespace geom { // geos::geom
-		class Coordinate;
-		class CoordinateArraySequence;
-	}
+namespace geom { // geos::geom
+class Coordinate;
+class CoordinateArraySequence;
+}
 }
 
 namespace geos {
@@ -52,71 +52,75 @@ class GEOS_DLL MultiLineString: public GeometryCollection, public Lineal {
 
 public:
 
-	friend class GeometryFactory;
+    friend class GeometryFactory;
 
-	~MultiLineString() override;
+    ~MultiLineString() override;
 
-	/// Returns line dimension (1)
-	Dimension::DimensionType getDimension() const override;
+    /// Returns line dimension (1)
+    Dimension::DimensionType getDimension() const override;
 
-	/**
-	 * \brief
-	 * Returns Dimension::False if all LineStrings in the collection
-	 * are closed, 0 otherwise.
-	 */
-	int getBoundaryDimension() const override;
+    /**
+     * \brief
+     * Returns Dimension::False if all LineStrings in the collection
+     * are closed, 0 otherwise.
+     */
+    int getBoundaryDimension() const override;
 
-	/// Returns a (possibly empty) MultiPoint
-	Geometry* getBoundary() const override;
+    /// Returns a (possibly empty) MultiPoint
+    Geometry* getBoundary() const override;
 
-	std::string getGeometryType() const override;
+    std::string getGeometryType() const override;
 
-	GeometryTypeId getGeometryTypeId() const override;
+    GeometryTypeId getGeometryTypeId() const override;
 
-	bool isClosed() const;
+    bool isClosed() const;
 
-	bool equalsExact(const Geometry *other, double tolerance=0) const override;
+    bool equalsExact(const Geometry* other, double tolerance = 0) const override;
 
-	Geometry *clone() const override;
+    Geometry* clone() const override;
 
-	/**
-	 * Creates a MultiLineString in the reverse
-	 * order to this object.
-	 * Both the order of the component LineStrings
-	 * and the order of their coordinate sequences
-	 * are reversed.
-	 *
-	 * @return a MultiLineString in the reverse order
-	 */
-	Geometry* reverse() const override;
+    /**
+     * Creates a MultiLineString in the reverse
+     * order to this object.
+     * Both the order of the component LineStrings
+     * and the order of their coordinate sequences
+     * are reversed.
+     *
+     * @return a MultiLineString in the reverse order
+     */
+    Geometry* reverse() const override;
 
 protected:
 
-	/**
-	 * \brief Constructs a <code>MultiLineString</code>.
-	 *
-	 * @param  newLines
-	 *	The <code>LineStrings</code>s for this
-	 *	<code>MultiLineString</code>, or <code>null</code>
-	 *	or an empty array to create the empty geometry.
-	 *	Elements may be empty <code>LineString</code>s,
-	 *	but not <code>null</code>s.
-	 *
-	 *	Constructed object will take ownership of
-	 *	the vector and its elements.
-	 *
-	 * @param newFactory
-	 * 	The GeometryFactory used to create this geometry.
-	 *	Caller must keep the factory alive for the life-time
-	 *	of the constructed MultiLineString.
-	 *
-	 */
-	MultiLineString(std::vector<Geometry *> *newLines,
-			const GeometryFactory *newFactory);
-
-	MultiLineString(const MultiLineString &mp);
-
-	int getSortIndex() const override { return SORTINDEX_MULTILINESTRING; };
+    /**
+     * \brief Constructs a <code>MultiLineString</code>.
+     *
+     * @param  newLines
+     *	The <code>LineStrings</code>s for this
+     *	<code>MultiLineString</code>, or <code>null</code>
+     *	or an empty array to create the empty geometry.
+     *	Elements may be empty <code>LineString</code>s,
+     *	but not <code>null</code>s.
+     *
+     *	Constructed object will take ownership of
+     *	the vector and its elements.
+     *
+     * @param newFactory
+     * 	The GeometryFactory used to create this geometry.
+     *	Caller must keep the factory alive for the life-time
+     *	of the constructed MultiLineString.
+     *
+     */
+    MultiLineString(std::vector<Geometry*>* newLines,
+                    const GeometryFactory* newFactory);
+
+    MultiLineString(const MultiLineString& mp);
+
+    int
+    getSortIndex() const override
+    {
+        return SORTINDEX_MULTILINESTRING;
+    };
 
 };
 
diff --git a/include/geos/geom/MultiLineString.inl b/include/geos/geom/MultiLineString.inl
index dca5c81..3820859 100644
--- a/include/geos/geom/MultiLineString.inl
+++ b/include/geos/geom/MultiLineString.inl
@@ -8,7 +8,7 @@
  *
  * This is free software; you can redistribute and/or modify it under
  * the terms of the GNU Lesser General Public Licence as published
- * by the Free Software Foundation. 
+ * by the Free Software Foundation.
  * See the COPYING file for more information.
  *
  **********************************************************************
@@ -28,18 +28,18 @@
 namespace geos {
 namespace geom { // geos::geom
 
-INLINE 
-MultiLineString::MultiLineString(const MultiLineString &mp)
-	:
-	Geometry(mp),
-	GeometryCollection(mp)
+INLINE
+MultiLineString::MultiLineString(const MultiLineString& mp)
+    :
+    Geometry(mp),
+    GeometryCollection(mp)
 {
 }
 
 INLINE Geometry*
 MultiLineString::clone() const
 {
-	return new MultiLineString(*this);
+    return new MultiLineString(*this);
 }
 
 } // namespace geos::geom
diff --git a/include/geos/geom/MultiPoint.h b/include/geos/geom/MultiPoint.h
index bc4fbf0..3f2e227 100644
--- a/include/geos/geom/MultiPoint.h
+++ b/include/geos/geom/MultiPoint.h
@@ -32,10 +32,10 @@
 #include <vector>
 
 namespace geos {
-	namespace geom { // geos::geom
-		class Coordinate;
-		class CoordinateArraySequence;
-	}
+namespace geom { // geos::geom
+class Coordinate;
+class CoordinateArraySequence;
+}
 }
 
 namespace geos {
@@ -51,69 +51,80 @@ namespace geom { // geos::geom
  *
  * Any collection of Points is a valid MultiPoint.
  */
-class GEOS_DLL MultiPoint: public GeometryCollection, public Puntal
-{
+class GEOS_DLL MultiPoint: public GeometryCollection, public Puntal {
 
 public:
 
-	friend class GeometryFactory;
+    friend class GeometryFactory;
 
-	~MultiPoint() override;
+    ~MultiPoint() override;
 
-	/// Returns point dimension (0)
-	Dimension::DimensionType getDimension() const override;
+    /// Returns point dimension (0)
+    Dimension::DimensionType getDimension() const override;
 
-	/// Returns Dimension::False (Point has no boundary)
-	int getBoundaryDimension() const override;
+    /// Returns Dimension::False (Point has no boundary)
+    int getBoundaryDimension() const override;
 
-	/** \brief
-	 * Gets the boundary of this geometry.
-	 *
-	 * Zero-dimensional geometries have no boundary by definition,
-	 * so an empty GeometryCollection is returned.
-	 *
-	 * @return an empty GeometryCollection
-	 * @see Geometry#getBoundary
-	 */
-	Geometry* getBoundary() const override;
+    /** \brief
+     * Gets the boundary of this geometry.
+     *
+     * Zero-dimensional geometries have no boundary by definition,
+     * so an empty GeometryCollection is returned.
+     *
+     * @return an empty GeometryCollection
+     * @see Geometry#getBoundary
+     */
+    Geometry* getBoundary() const override;
 
-	std::string getGeometryType() const override;
+    std::string getGeometryType() const override;
 
-	GeometryTypeId getGeometryTypeId() const override;
+    GeometryTypeId getGeometryTypeId() const override;
 
-	bool equalsExact(const Geometry *other, double tolerance=0) const override;
+    bool equalsExact(const Geometry* other, double tolerance = 0) const override;
 
-	Geometry *clone() const override { return new MultiPoint(*this); }
+    Geometry*
+    clone() const override
+    {
+        return new MultiPoint(*this);
+    }
 
-	Geometry* reverse() const override { return clone(); }
+    Geometry*
+    reverse() const override
+    {
+        return clone();
+    }
 
 protected:
 
-	/**
-	 * \brief Constructs a <code>MultiPoint</code>.
-	 *
-	 * @param  newPoints
-	 *	the <code>Point</code>s for this <code>MultiPoint</code>,
-	 *	or <code>null</code> or an empty array to create the empty
-	 * 	geometry.
-	 *	Elements may be empty <code>Point</code>s,
-	 *	but not <code>null</code>s.
-	 *
-	 *	Constructed object will take ownership of
-	 *	the vector and its elements.
-	 *
-	 * @param newFactory
-	 * 	The GeometryFactory used to create this geometry
-	 *	Caller must keep the factory alive for the life-time
-	 *	of the constructed MultiPoint.
-	 */
-	MultiPoint(std::vector<Geometry *> *newPoints, const GeometryFactory *newFactory);
-
-	MultiPoint(const MultiPoint &mp): Geometry(mp), GeometryCollection(mp) {}
-
-	const Coordinate* getCoordinateN(size_t n) const;
-
-	int getSortIndex() const override { return SORTINDEX_MULTIPOINT; };
+    /**
+     * \brief Constructs a <code>MultiPoint</code>.
+     *
+     * @param  newPoints
+     *	the <code>Point</code>s for this <code>MultiPoint</code>,
+     *	or <code>null</code> or an empty array to create the empty
+     * 	geometry.
+     *	Elements may be empty <code>Point</code>s,
+     *	but not <code>null</code>s.
+     *
+     *	Constructed object will take ownership of
+     *	the vector and its elements.
+     *
+     * @param newFactory
+     * 	The GeometryFactory used to create this geometry
+     *	Caller must keep the factory alive for the life-time
+     *	of the constructed MultiPoint.
+     */
+    MultiPoint(std::vector<Geometry*>* newPoints, const GeometryFactory* newFactory);
+
+    MultiPoint(const MultiPoint& mp): Geometry(mp), GeometryCollection(mp) {}
+
+    const Coordinate* getCoordinateN(size_t n) const;
+
+    int
+    getSortIndex() const override
+    {
+        return SORTINDEX_MULTIPOINT;
+    };
 
 };
 
diff --git a/include/geos/geom/MultiPolygon.h b/include/geos/geom/MultiPolygon.h
index 77771ee..57e72e6 100644
--- a/include/geos/geom/MultiPolygon.h
+++ b/include/geos/geom/MultiPolygon.h
@@ -32,11 +32,11 @@
 
 // Forward declarations
 namespace geos {
-	namespace geom { // geos::geom
-		class Coordinate;
-		class CoordinateArraySequence;
-		class MultiPoint;
-	}
+namespace geom { // geos::geom
+class Coordinate;
+class CoordinateArraySequence;
+class MultiPoint;
+}
 }
 
 
@@ -56,66 +56,69 @@ namespace geom { // geos::geom
 /// This allows the topological point-set semantics
 /// to be well-defined.
 ///
-class GEOS_DLL MultiPolygon: public GeometryCollection, public Polygonal
-{
+class GEOS_DLL MultiPolygon: public GeometryCollection, public Polygonal {
 public:
 
-	friend class GeometryFactory;
+    friend class GeometryFactory;
 
-	~MultiPolygon() override;
+    ~MultiPolygon() override;
 
-	/// Returns surface dimension (2)
-	Dimension::DimensionType getDimension() const override;
+    /// Returns surface dimension (2)
+    Dimension::DimensionType getDimension() const override;
 
-	/// Returns 1 (MultiPolygon boundary is MultiLineString)
-	int getBoundaryDimension() const override;
+    /// Returns 1 (MultiPolygon boundary is MultiLineString)
+    int getBoundaryDimension() const override;
 
-	/** \brief
-	 * Computes the boundary of this geometry
-	 *
-	 * @return a lineal geometry (which may be empty)
-	 * @see Geometry#getBoundary
-	 */
-	Geometry* getBoundary() const override;
+    /** \brief
+     * Computes the boundary of this geometry
+     *
+     * @return a lineal geometry (which may be empty)
+     * @see Geometry#getBoundary
+     */
+    Geometry* getBoundary() const override;
 
-	std::string getGeometryType() const override;
+    std::string getGeometryType() const override;
 
-	GeometryTypeId getGeometryTypeId() const override;
+    GeometryTypeId getGeometryTypeId() const override;
 
-	bool equalsExact(const Geometry *other, double tolerance=0) const override;
+    bool equalsExact(const Geometry* other, double tolerance = 0) const override;
 
-	Geometry *clone() const override;
+    Geometry* clone() const override;
 
-	Geometry *reverse() const override;
+    Geometry* reverse() const override;
 
 protected:
 
-	/**
-	 * \brief Construct a MultiPolygon
-	 *
-	 * @param newPolys
-	 *	the <code>Polygon</code>s for this <code>MultiPolygon</code>,
-	 *	or <code>null</code> or an empty array to create the empty
-	 *	geometry. Elements may be empty <code>Polygon</code>s, but
-	 *	not <code>null</code>s.
-	 *	The polygons must conform to the assertions specified in the
-	 *	<A HREF="http://www.opengis.org/techno/specs.htm">
-	 *	OpenGIS Simple Features Specification for SQL
-	 *	</A>.
-	 *
-	 *	Constructed object will take ownership of
-	 *	the vector and its elements.
-	 *
-	 * @param newFactory
-	 * 	The GeometryFactory used to create this geometry
-	 *	Caller must keep the factory alive for the life-time
-	 *	of the constructed MultiPolygon.
-	 */
-	MultiPolygon(std::vector<Geometry *> *newPolys, const GeometryFactory *newFactory);
-
-	MultiPolygon(const MultiPolygon &mp);
-
-	int getSortIndex() const override { return SORTINDEX_MULTIPOLYGON; };
+    /**
+     * \brief Construct a MultiPolygon
+     *
+     * @param newPolys
+     *	the <code>Polygon</code>s for this <code>MultiPolygon</code>,
+     *	or <code>null</code> or an empty array to create the empty
+     *	geometry. Elements may be empty <code>Polygon</code>s, but
+     *	not <code>null</code>s.
+     *	The polygons must conform to the assertions specified in the
+     *	<A HREF="http://www.opengis.org/techno/specs.htm">
+     *	OpenGIS Simple Features Specification for SQL
+     *	</A>.
+     *
+     *	Constructed object will take ownership of
+     *	the vector and its elements.
+     *
+     * @param newFactory
+     * 	The GeometryFactory used to create this geometry
+     *	Caller must keep the factory alive for the life-time
+     *	of the constructed MultiPolygon.
+     */
+    MultiPolygon(std::vector<Geometry*>* newPolys, const GeometryFactory* newFactory);
+
+    MultiPolygon(const MultiPolygon& mp);
+
+    int
+    getSortIndex() const override
+    {
+        return SORTINDEX_MULTIPOLYGON;
+    };
 
 };
 
diff --git a/include/geos/geom/MultiPolygon.inl b/include/geos/geom/MultiPolygon.inl
index 8bb340f..e37a7e2 100644
--- a/include/geos/geom/MultiPolygon.inl
+++ b/include/geos/geom/MultiPolygon.inl
@@ -7,7 +7,7 @@
  *
  * This is free software; you can redistribute and/or modify it under
  * the terms of the GNU Lesser General Public Licence as published
- * by the Free Software Foundation. 
+ * by the Free Software Foundation.
  * See the COPYING file for more information.
  *
  **********************************************************************
@@ -25,18 +25,18 @@
 namespace geos {
 namespace geom { // geos::geom
 
-INLINE 
-MultiPolygon::MultiPolygon(const MultiPolygon &mp)
-	:
-	Geometry(mp),
-	GeometryCollection(mp)
+INLINE
+MultiPolygon::MultiPolygon(const MultiPolygon& mp)
+    :
+    Geometry(mp),
+    GeometryCollection(mp)
 {
 }
 
 INLINE Geometry*
 MultiPolygon::clone() const
 {
-	return new MultiPolygon(*this);
+    return new MultiPolygon(*this);
 }
 
 } // namespace geos::geom
diff --git a/include/geos/geom/Point.h b/include/geos/geom/Point.h
index e93990c..060cf6e 100644
--- a/include/geos/geom/Point.h
+++ b/include/geos/geom/Point.h
@@ -41,14 +41,14 @@
 
 // Forward declarations
 namespace geos {
-	namespace geom { // geos::geom
-		class Coordinate;
-		class CoordinateArraySequence;
-		class CoordinateFilter;
-		class CoordinateSequenceFilter;
-		class GeometryComponentFilter;
-		class GeometryFilter;
-	}
+namespace geom { // geos::geom
+class Coordinate;
+class CoordinateArraySequence;
+class CoordinateFilter;
+class CoordinateSequenceFilter;
+class GeometryComponentFilter;
+class GeometryFilter;
+}
 }
 
 namespace geos {
@@ -63,110 +63,119 @@ namespace geom { // geos::geom
  *   (i.e does not have an NaN X or Y ordinate)
  *
  */
-class GEOS_DLL Point : public virtual Geometry, public Puntal
-{
+class GEOS_DLL Point : public virtual Geometry, public Puntal {
 
 public:
 
-	friend class GeometryFactory;
-
-	/// A vector of const Point pointers
-	typedef std::vector<const Point *> ConstVect;
-
-	~Point() override;
-
-	/**
-	 * Creates and returns a full copy of this {@link Point} object.
-	 * (including all coordinates contained by it).
-	 *
-	 * @return a clone of this instance
-	 */
-	Geometry *clone() const override { return new Point(*this); }
-
-	CoordinateSequence* getCoordinates(void) const override;
-
-	const CoordinateSequence* getCoordinatesRO() const;
-
-	size_t getNumPoints() const override;
-	bool isEmpty() const override;
-	bool isSimple() const override;
-
-	/// Returns point dimension (0)
-	Dimension::DimensionType getDimension() const override;
-
-	/// Returns coordinate dimension.
-	int getCoordinateDimension() const override;
-
-	/// Returns Dimension::False (Point has no boundary)
-	int getBoundaryDimension() const override;
-
-	/**
-	 * Gets the boundary of this geometry.
-	 * Zero-dimensional geometries have no boundary by definition,
-	 * so an empty GeometryCollection is returned.
-	 *
-	 * @return an empty GeometryCollection
-	 * @see Geometry::getBoundary
-	 */
-	Geometry* getBoundary() const override;
-
-	double getX() const;
-	double getY() const;
-  double getZ() const;
-	const Coordinate* getCoordinate() const override;
-	std::string getGeometryType() const override;
-	GeometryTypeId getGeometryTypeId() const override;
-	void apply_ro(CoordinateFilter *filter) const override;
-	void apply_rw(const CoordinateFilter *filter) override;
-	void apply_ro(GeometryFilter *filter) const override;
-	void apply_rw(GeometryFilter *filter) override;
-	void apply_rw(GeometryComponentFilter *filter) override;
-	void apply_ro(GeometryComponentFilter *filter) const override;
-	void apply_rw(CoordinateSequenceFilter& filter) override;
-	void apply_ro(CoordinateSequenceFilter& filter) const override;
-
-	bool equalsExact(const Geometry *other, double tolerance=0) const override;
-
-	void normalize(void) override
-	{
-		// a Point is always in normalized form
-	}
-
-  	Geometry* reverse() const override
-	{
-		return clone();
-	}
+    friend class GeometryFactory;
+
+    /// A vector of const Point pointers
+    typedef std::vector<const Point*> ConstVect;
+
+    ~Point() override;
+
+    /**
+     * Creates and returns a full copy of this {@link Point} object.
+     * (including all coordinates contained by it).
+     *
+     * @return a clone of this instance
+     */
+    Geometry*
+    clone() const override
+    {
+        return new Point(*this);
+    }
+
+    CoordinateSequence* getCoordinates(void) const override;
+
+    const CoordinateSequence* getCoordinatesRO() const;
+
+    size_t getNumPoints() const override;
+    bool isEmpty() const override;
+    bool isSimple() const override;
+
+    /// Returns point dimension (0)
+    Dimension::DimensionType getDimension() const override;
+
+    /// Returns coordinate dimension.
+    int getCoordinateDimension() const override;
+
+    /// Returns Dimension::False (Point has no boundary)
+    int getBoundaryDimension() const override;
+
+    /**
+     * Gets the boundary of this geometry.
+     * Zero-dimensional geometries have no boundary by definition,
+     * so an empty GeometryCollection is returned.
+     *
+     * @return an empty GeometryCollection
+     * @see Geometry::getBoundary
+     */
+    Geometry* getBoundary() const override;
+
+    double getX() const;
+    double getY() const;
+    double getZ() const;
+    const Coordinate* getCoordinate() const override;
+    std::string getGeometryType() const override;
+    GeometryTypeId getGeometryTypeId() const override;
+    void apply_ro(CoordinateFilter* filter) const override;
+    void apply_rw(const CoordinateFilter* filter) override;
+    void apply_ro(GeometryFilter* filter) const override;
+    void apply_rw(GeometryFilter* filter) override;
+    void apply_rw(GeometryComponentFilter* filter) override;
+    void apply_ro(GeometryComponentFilter* filter) const override;
+    void apply_rw(CoordinateSequenceFilter& filter) override;
+    void apply_ro(CoordinateSequenceFilter& filter) const override;
+
+    bool equalsExact(const Geometry* other, double tolerance = 0) const override;
+
+    void
+    normalize(void) override
+    {
+        // a Point is always in normalized form
+    }
+
+    Geometry*
+    reverse() const override
+    {
+        return clone();
+    }
 
 protected:
 
-	/**
-	 * \brief
-	 * Creates a Point taking ownership of the given CoordinateSequence
-	 * (must have 1 element)
-	 *
-	 * @param  newCoords
-	 *	contains the single coordinate on which to base this
-	 *	<code>Point</code> or <code>null</code> to create
-	 *	the empty geometry.
-	 *
-	 * @param newFactory the GeometryFactory used to create this geometry
-	 */
-	Point(CoordinateSequence *newCoords, const GeometryFactory *newFactory);
+    /**
+     * \brief
+     * Creates a Point taking ownership of the given CoordinateSequence
+     * (must have 1 element)
+     *
+     * @param  newCoords
+     *	contains the single coordinate on which to base this
+     *	<code>Point</code> or <code>null</code> to create
+     *	the empty geometry.
+     *
+     * @param newFactory the GeometryFactory used to create this geometry
+     */
+    Point(CoordinateSequence* newCoords, const GeometryFactory* newFactory);
 
-	Point(const Point &p);
+    Point(const Point& p);
 
-	Envelope::Ptr computeEnvelopeInternal() const override;
+    Envelope::Ptr computeEnvelopeInternal() const override;
 
-	int compareToSameClass(const Geometry *p) const override;
+    int compareToSameClass(const Geometry* p) const override;
 
-	int getSortIndex() const override { return SORTINDEX_POINT; };
+    int
+    getSortIndex() const override
+    {
+        return SORTINDEX_POINT;
+    };
 
 private:
 
-	/**
-	 *  The <code>Coordinate</code> wrapped by this <code>Point</code>.
-	 */
-	std::unique_ptr<CoordinateSequence> coordinates;
+    /**
+     *  The <code>Coordinate</code> wrapped by this <code>Point</code>.
+     */
+    std::unique_ptr<CoordinateSequence> coordinates;
 };
 
 } // namespace geos::geom
diff --git a/include/geos/geom/Polygon.h b/include/geos/geom/Polygon.h
index 1c46dc4..dd85752 100644
--- a/include/geos/geom/Polygon.h
+++ b/include/geos/geom/Polygon.h
@@ -35,13 +35,13 @@
 
 // Forward declarations
 namespace geos {
-	namespace geom { // geos::geom
-		class Coordinate;
-		class CoordinateArraySequence;
-		class CoordinateSequenceFilter;
-		class LinearRing;
-		class LineString;
-	}
+namespace geom { // geos::geom
+class Coordinate;
+class CoordinateArraySequence;
+class CoordinateSequenceFilter;
+class LinearRing;
+class LineString;
+}
 }
 
 namespace geos {
@@ -62,125 +62,132 @@ namespace geom { // geos::geom
  *  Specification for SQL</A> .
  *
  */
-class GEOS_DLL Polygon: public virtual Geometry, public Polygonal
-{
+class GEOS_DLL Polygon: public virtual Geometry, public Polygonal {
 
 public:
 
-	friend class GeometryFactory;
+    friend class GeometryFactory;
 
-	/// A vector of const Polygon pointers
-	typedef std::vector<const Polygon *> ConstVect;
+    /// A vector of const Polygon pointers
+    typedef std::vector<const Polygon*> ConstVect;
 
-	~Polygon() override;
+    ~Polygon() override;
 
-	/**
-	 * Creates and returns a full copy of this {@link Polygon} object.
-	 * (including all coordinates contained by it).
-	 *
-	 * @return a clone of this instance
-	 */
-	Geometry *clone() const override { return new Polygon(*this); }
+    /**
+     * Creates and returns a full copy of this {@link Polygon} object.
+     * (including all coordinates contained by it).
+     *
+     * @return a clone of this instance
+     */
+    Geometry*
+    clone() const override
+    {
+        return new Polygon(*this);
+    }
 
-	CoordinateSequence* getCoordinates() const override;
+    CoordinateSequence* getCoordinates() const override;
 
-	size_t getNumPoints() const override;
+    size_t getNumPoints() const override;
 
-	/// Returns surface dimension (2)
-	Dimension::DimensionType getDimension() const override;
+    /// Returns surface dimension (2)
+    Dimension::DimensionType getDimension() const override;
 
-	/// Returns coordinate dimension.
-	int getCoordinateDimension() const override;
+    /// Returns coordinate dimension.
+    int getCoordinateDimension() const override;
 
-	/// Returns 1 (Polygon boundary is a MultiLineString)
-	int getBoundaryDimension() const override;
+    /// Returns 1 (Polygon boundary is a MultiLineString)
+    int getBoundaryDimension() const override;
 
-	/** \brief
-	 * Computes the boundary of this geometry
-	 *
-	 * @return a lineal geometry (which may be empty)
-	 * @see Geometry#getBoundary
-	 */
-	Geometry* getBoundary() const override;
+    /** \brief
+     * Computes the boundary of this geometry
+     *
+     * @return a lineal geometry (which may be empty)
+     * @see Geometry#getBoundary
+     */
+    Geometry* getBoundary() const override;
 
-	bool isEmpty() const override;
+    bool isEmpty() const override;
 
-	/// Returns the exterior ring (shell)
-	const LineString* getExteriorRing() const;
+    /// Returns the exterior ring (shell)
+    const LineString* getExteriorRing() const;
 
-	/// Returns number of interior rings (hole)
-	size_t getNumInteriorRing() const;
+    /// Returns number of interior rings (hole)
+    size_t getNumInteriorRing() const;
 
-	/// Get nth interior ring (hole)
-	const LineString* getInteriorRingN(std::size_t n) const;
+    /// Get nth interior ring (hole)
+    const LineString* getInteriorRingN(std::size_t n) const;
 
-	std::string getGeometryType() const override;
-	GeometryTypeId getGeometryTypeId() const override;
-	bool equalsExact(const Geometry *other, double tolerance=0) const override;
-	void apply_rw(const CoordinateFilter *filter) override;
-	void apply_ro(CoordinateFilter *filter) const override;
-	void apply_rw(GeometryFilter *filter) override;
-	void apply_ro(GeometryFilter *filter) const override;
-	void apply_rw(CoordinateSequenceFilter& filter) override;
-	void apply_ro(CoordinateSequenceFilter& filter) const override;
-	void apply_rw(GeometryComponentFilter *filter) override;
-	void apply_ro(GeometryComponentFilter *filter) const override;
+    std::string getGeometryType() const override;
+    GeometryTypeId getGeometryTypeId() const override;
+    bool equalsExact(const Geometry* other, double tolerance = 0) const override;
+    void apply_rw(const CoordinateFilter* filter) override;
+    void apply_ro(CoordinateFilter* filter) const override;
+    void apply_rw(GeometryFilter* filter) override;
+    void apply_ro(GeometryFilter* filter) const override;
+    void apply_rw(CoordinateSequenceFilter& filter) override;
+    void apply_ro(CoordinateSequenceFilter& filter) const override;
+    void apply_rw(GeometryComponentFilter* filter) override;
+    void apply_ro(GeometryComponentFilter* filter) const override;
 
-	Geometry* convexHull() const override;
+    Geometry* convexHull() const override;
 
-	void normalize() override;
+    void normalize() override;
 
-	Geometry* reverse() const override;
+    Geometry* reverse() const override;
 
-	int compareToSameClass(const Geometry *p) const override; //was protected
+    int compareToSameClass(const Geometry* p) const override; //was protected
 
-	const Coordinate* getCoordinate() const override;
+    const Coordinate* getCoordinate() const override;
 
-	double getArea() const override;
+    double getArea() const override;
 
- 	/// Returns the perimeter of this <code>Polygon</code>
-	double getLength() const override;
+    /// Returns the perimeter of this <code>Polygon</code>
+    double getLength() const override;
 
-	bool isRectangle() const override;
+    bool isRectangle() const override;
 
 protected:
 
 
-	Polygon(const Polygon &p);
+    Polygon(const Polygon& p);
 
-	/**
-	 * Constructs a <code>Polygon</code> with the given exterior
-	 * and interior boundaries.
-	 *
-	 * @param  newShell  the outer boundary of the new Polygon,
-	 *                   or <code>null</code> or an empty
-	 *		     LinearRing if the empty geometry
-	 *                   is to be created.
-	 *
-	 * @param  newHoles  the LinearRings defining the inner
-	 *                   boundaries of the new Polygon, or
-	 *                   null or empty LinearRing
-	 *                   if the empty  geometry is to be created.
-	 *
-	 * @param newFactory the GeometryFactory used to create this geometry
-	 *
-	 * Polygon will take ownership of Shell and Holes LinearRings
-	 */
-	Polygon(LinearRing *newShell, std::vector<Geometry *> *newHoles,
-		const GeometryFactory *newFactory);
+    /**
+     * Constructs a <code>Polygon</code> with the given exterior
+     * and interior boundaries.
+     *
+     * @param  newShell  the outer boundary of the new Polygon,
+     *                   or <code>null</code> or an empty
+     *		     LinearRing if the empty geometry
+     *                   is to be created.
+     *
+     * @param  newHoles  the LinearRings defining the inner
+     *                   boundaries of the new Polygon, or
+     *                   null or empty LinearRing
+     *                   if the empty  geometry is to be created.
+     *
+     * @param newFactory the GeometryFactory used to create this geometry
+     *
+     * Polygon will take ownership of Shell and Holes LinearRings
+     */
+    Polygon(LinearRing* newShell, std::vector<Geometry*>* newHoles,
+            const GeometryFactory* newFactory);
 
-	LinearRing *shell;
+    LinearRing* shell;
 
-	std::vector<Geometry *> *holes; //Actually vector<LinearRing *>
+    std::vector<Geometry*>* holes;  //Actually vector<LinearRing *>
 
-	Envelope::Ptr computeEnvelopeInternal() const override;
+    Envelope::Ptr computeEnvelopeInternal() const override;
 
-	int getSortIndex() const override { return SORTINDEX_POLYGON; };
+    int
+    getSortIndex() const override
+    {
+        return SORTINDEX_POLYGON;
+    };
 
 
 private:
 
-	void normalize(LinearRing *ring, bool clockwise);
+    void normalize(LinearRing* ring, bool clockwise);
 };
 
 } // namespace geos::geom
diff --git a/include/geos/geom/Polygonal.h b/include/geos/geom/Polygonal.h
index 8861d06..6b90ecf 100644
--- a/include/geos/geom/Polygonal.h
+++ b/include/geos/geom/Polygonal.h
@@ -34,10 +34,9 @@ namespace geom { // geos::geom
  * Identifies {@link Geometry} subclasses which
  * are 2-dimensional and with components which are {@link Polygon}s.
  */
-class GEOS_DLL Polygonal : public virtual Geometry
-{
+class GEOS_DLL Polygonal : public virtual Geometry {
 protected:
-  Polygonal(): Geometry(nullptr) {}
+    Polygonal(): Geometry(nullptr) {}
 };
 
 } // namespace geos::geom
diff --git a/include/geos/geom/PrecisionModel.h b/include/geos/geom/PrecisionModel.h
index 3358563..d1c39a5 100644
--- a/include/geos/geom/PrecisionModel.h
+++ b/include/geos/geom/PrecisionModel.h
@@ -28,12 +28,12 @@
 
 // Forward declarations
 namespace geos {
-	namespace io {
-		class Unload;
-	}
-	namespace geom {
-		class Coordinate;
-	}
+namespace io {
+class Unload;
+}
+namespace geom {
+class Coordinate;
+}
 }
 
 namespace geos {
@@ -85,237 +85,237 @@ namespace geom { // geos::geom
  * JTS methods currently do not handle inputs with different precision models.
  */
 class GEOS_DLL PrecisionModel {
-friend class io::Unload;
+    friend class io::Unload;
 
 public:
 
-	/// The types of Precision Model which GEOS supports.
-	typedef enum {
-
-		/**
-		 * Fixed Precision indicates that coordinates have a fixed
-		 * number of decimal places.
-		 * The number of decimal places is determined by the log10
-		 * of the scale factor.
-		 */
-		FIXED,
-
-		/**
-		 * Floating precision corresponds to the standard Java
-		 * double-precision floating-point representation, which is
-		 * based on the IEEE-754 standard
-		 */
-		FLOATING,
-
-		/**
-		 * Floating single precision corresponds to the standard Java
-		 * single-precision floating-point representation, which is
-		 * based on the IEEE-754 standard
-		 */
-		FLOATING_SINGLE
-
-	} Type;
-
-	/// Creates a PrecisionModel with a default precision of FLOATING.
-	PrecisionModel(void);
-
-	/// Creates a PrecisionModel specifying an explicit precision model type.
-	//
-	/// If the model type is FIXED the scale factor will default to 1.
-	///
-	/// @param nModelType the type of the precision model
-	///
-	PrecisionModel(Type nModelType);
-
-	/** \brief
-	 * Creates a <code>PrecisionModel</code> with Fixed precision.
-	 *
-	 * Fixed-precision coordinates are represented as precise internal
-	 * coordinates, which are rounded to the grid defined by the
-	 * scale factor.
-	 *
-	 * @param  scale
-	 *	amount by which to multiply a coordinate after subtracting
-	 *	the offset, to obtain a precise coordinate
-	 * @param  offsetX  not used.
-	 * @param  offsetY  not used.
-	 *
-	 * @deprecated offsets are no longer supported, since internal
-	 * representation is rounded floating point
-	 */
-	PrecisionModel(double newScale, double newOffsetX, double newOffsetY);
-
-	/**
-	 * \brief
-	 * Creates a PrecisionModel with Fixed precision.
-	 *
-	 * Fixed-precision coordinates are represented as precise
-	 * internal coordinates which are rounded to the grid defined
-	 * by the scale factor.
-	 *
-	 * @param newScale amount by which to multiply a coordinate
-	 * after subtracting the offset, to obtain a precise coordinate
-	 */
-	PrecisionModel(double newScale);
-
-	// copy constructor
-	PrecisionModel(const PrecisionModel &pm);
-
-	/// destructor
-	~PrecisionModel(void);
-
-
-	/// The maximum precise value representable in a double.
-	//
-	/// Since IEE754 double-precision numbers allow 53 bits of mantissa,
-	/// the value is equal to 2^53 - 1.
-	/// This provides <i>almost</i> 16 decimal digits of precision.
-	////
-	static const double maximumPreciseValue;
-
-	/** \brief
-	 * Rounds a numeric value to the PrecisionModel grid.
-	 *
-	 * Asymmetric Arithmetic Rounding is used, to provide
-	 * uniform rounding behaviour no matter where the number is
-	 * on the number line.
-	 *
-	 * <b>Note:</b> Java's <code>Math#rint</code> uses the "Banker's Rounding" algorithm,
-	 * which is not suitable for precision operations elsewhere in JTS.
-	 */
-	double makePrecise(double val) const;
-
-	/// Rounds the given Coordinate to the PrecisionModel grid.
-	void makePrecise(Coordinate& coord) const;
-
-	void makePrecise(Coordinate* coord) const;
-
-	/// Tests whether the precision model supports floating point
-	//
-	/// @return <code>true</code> if the precision model supports
-	/// floating point
-	///
-	bool isFloating() const;
-
-	/// \brief
-	/// Returns the maximum number of significant digits provided by
-	/// this precision model.
-	//
-	/// Intended for use by routines which need to print out precise
-	/// values.
-	///
-	/// @return the maximum number of decimal places provided by this
-	/// precision model
-	///
-	int getMaximumSignificantDigits() const;
-
-	/// Gets the type of this PrecisionModel
-	//
-	/// @return the type of this PrecisionModel
-	///
-	Type getType() const;
-
-	/// Returns the multiplying factor used to obtain a precise coordinate.
-	double getScale() const;
-
-	/// Returns the x-offset used to obtain a precise coordinate.
-	//
-	/// @return the amount by which to subtract the x-coordinate before
-	///         multiplying by the scale
-	/// @deprecated Offsets are no longer used
-	///
-	double getOffsetX() const;
-
-	/// Returns the y-offset used to obtain a precise coordinate.
-	//
-	/// @return the amount by which to subtract the y-coordinate before
-	///         multiplying by the scale
-	/// @deprecated Offsets are no longer used
-	///
-	double getOffsetY() const;
-
-	/** \brief
-	 *  Sets <code>internal</code> to the precise representation of
-	 * <code>external</code>.
-	 *
-	 * @param external the original coordinate
-	 * @param internal the coordinate whose values will be changed to the
-	 *                 precise representation of <code>external</code>
-	 * @deprecated use makePrecise instead
-	 */
-	//void toInternal(const Coordinate& external, Coordinate* internal) const;
-
-	/*
-	 *  Returns the precise representation of <code>external</code>.
-	 *
-	 *@param  external  the original coordinate
-	 *@return
-	 *	the coordinate whose values will be changed to the precise
-	 *	representation of <code>external</code>
-	 * @deprecated use makePrecise instead
-	 */
-	//Coordinate* toInternal(const Coordinate& external) const;
-
-	/*
-	 *  Returns the external representation of <code>internal</code>.
-	 *
-	 *@param  internal  the original coordinate
-	 *@return           the coordinate whose values will be changed to the
-	 *      external representation of <code>internal</code>
-	 * @deprecated no longer needed, since internal representation is same as external representation
-	 */
-	//Coordinate* toExternal(const Coordinate& internal) const;
-
-	/*
-	 *  Sets <code>external</code> to the external representation of
-	 *  <code>internal</code>.
-	 *
-	 * @param  internal  the original coordinate
-	 * @param  external
-	 *	the coordinate whose values will be changed to the
-	 *	external representation of <code>internal</code>
-	 * @deprecated no longer needed, since internal representation is same as external representation
-	 */
-	//void toExternal(const Coordinate& internal, Coordinate* external) const;
-
-	std::string toString() const;
-
-	/// \brief
-	/// Compares this PrecisionModel object with the specified object
-	/// for order.
-	//
-	/// A PrecisionModel is greater than another if it provides greater
-	/// precision.
-	/// The comparison is based on the value returned by the
-	/// getMaximumSignificantDigits method.
-	/// This comparison is not strictly accurate when comparing floating
-	/// precision models to fixed models;
-	/// however, it is correct when both models are either floating or
-	/// fixed.
-	///
-	/// @param other the PrecisionModel with which this PrecisionModel
-	///      is being compared
-	/// @return a negative integer, zero, or a positive integer as this
-	///      PrecisionModel is less than, equal to, or greater than the
-	///      specified PrecisionModel.
-	///
-	int compareTo(const PrecisionModel* other) const;
+    /// The types of Precision Model which GEOS supports.
+    typedef enum {
+
+        /**
+         * Fixed Precision indicates that coordinates have a fixed
+         * number of decimal places.
+         * The number of decimal places is determined by the log10
+         * of the scale factor.
+         */
+        FIXED,
+
+        /**
+         * Floating precision corresponds to the standard Java
+         * double-precision floating-point representation, which is
+         * based on the IEEE-754 standard
+         */
+        FLOATING,
+
+        /**
+         * Floating single precision corresponds to the standard Java
+         * single-precision floating-point representation, which is
+         * based on the IEEE-754 standard
+         */
+        FLOATING_SINGLE
+
+    } Type;
+
+    /// Creates a PrecisionModel with a default precision of FLOATING.
+    PrecisionModel(void);
+
+    /// Creates a PrecisionModel specifying an explicit precision model type.
+    //
+    /// If the model type is FIXED the scale factor will default to 1.
+    ///
+    /// @param nModelType the type of the precision model
+    ///
+    PrecisionModel(Type nModelType);
+
+    /** \brief
+     * Creates a <code>PrecisionModel</code> with Fixed precision.
+     *
+     * Fixed-precision coordinates are represented as precise internal
+     * coordinates, which are rounded to the grid defined by the
+     * scale factor.
+     *
+     * @param  scale
+     *	amount by which to multiply a coordinate after subtracting
+     *	the offset, to obtain a precise coordinate
+     * @param  offsetX  not used.
+     * @param  offsetY  not used.
+     *
+     * @deprecated offsets are no longer supported, since internal
+     * representation is rounded floating point
+     */
+    PrecisionModel(double newScale, double newOffsetX, double newOffsetY);
+
+    /**
+     * \brief
+     * Creates a PrecisionModel with Fixed precision.
+     *
+     * Fixed-precision coordinates are represented as precise
+     * internal coordinates which are rounded to the grid defined
+     * by the scale factor.
+     *
+     * @param newScale amount by which to multiply a coordinate
+     * after subtracting the offset, to obtain a precise coordinate
+     */
+    PrecisionModel(double newScale);
+
+    // copy constructor
+    PrecisionModel(const PrecisionModel& pm);
+
+    /// destructor
+    ~PrecisionModel(void);
+
+
+    /// The maximum precise value representable in a double.
+    //
+    /// Since IEE754 double-precision numbers allow 53 bits of mantissa,
+    /// the value is equal to 2^53 - 1.
+    /// This provides <i>almost</i> 16 decimal digits of precision.
+    ////
+    static const double maximumPreciseValue;
+
+    /** \brief
+     * Rounds a numeric value to the PrecisionModel grid.
+     *
+     * Asymmetric Arithmetic Rounding is used, to provide
+     * uniform rounding behaviour no matter where the number is
+     * on the number line.
+     *
+     * <b>Note:</b> Java's <code>Math#rint</code> uses the "Banker's Rounding" algorithm,
+     * which is not suitable for precision operations elsewhere in JTS.
+     */
+    double makePrecise(double val) const;
+
+    /// Rounds the given Coordinate to the PrecisionModel grid.
+    void makePrecise(Coordinate& coord) const;
+
+    void makePrecise(Coordinate* coord) const;
+
+    /// Tests whether the precision model supports floating point
+    //
+    /// @return <code>true</code> if the precision model supports
+    /// floating point
+    ///
+    bool isFloating() const;
+
+    /// \brief
+    /// Returns the maximum number of significant digits provided by
+    /// this precision model.
+    //
+    /// Intended for use by routines which need to print out precise
+    /// values.
+    ///
+    /// @return the maximum number of decimal places provided by this
+    /// precision model
+    ///
+    int getMaximumSignificantDigits() const;
+
+    /// Gets the type of this PrecisionModel
+    //
+    /// @return the type of this PrecisionModel
+    ///
+    Type getType() const;
+
+    /// Returns the multiplying factor used to obtain a precise coordinate.
+    double getScale() const;
+
+    /// Returns the x-offset used to obtain a precise coordinate.
+    //
+    /// @return the amount by which to subtract the x-coordinate before
+    ///         multiplying by the scale
+    /// @deprecated Offsets are no longer used
+    ///
+    double getOffsetX() const;
+
+    /// Returns the y-offset used to obtain a precise coordinate.
+    //
+    /// @return the amount by which to subtract the y-coordinate before
+    ///         multiplying by the scale
+    /// @deprecated Offsets are no longer used
+    ///
+    double getOffsetY() const;
+
+    /** \brief
+     *  Sets <code>internal</code> to the precise representation of
+     * <code>external</code>.
+     *
+     * @param external the original coordinate
+     * @param internal the coordinate whose values will be changed to the
+     *                 precise representation of <code>external</code>
+     * @deprecated use makePrecise instead
+     */
+    //void toInternal(const Coordinate& external, Coordinate* internal) const;
+
+    /*
+     *  Returns the precise representation of <code>external</code>.
+     *
+     *@param  external  the original coordinate
+     *@return
+     *	the coordinate whose values will be changed to the precise
+     *	representation of <code>external</code>
+     * @deprecated use makePrecise instead
+     */
+    //Coordinate* toInternal(const Coordinate& external) const;
+
+    /*
+     *  Returns the external representation of <code>internal</code>.
+     *
+     *@param  internal  the original coordinate
+     *@return           the coordinate whose values will be changed to the
+     *      external representation of <code>internal</code>
+     * @deprecated no longer needed, since internal representation is same as external representation
+     */
+    //Coordinate* toExternal(const Coordinate& internal) const;
+
+    /*
+     *  Sets <code>external</code> to the external representation of
+     *  <code>internal</code>.
+     *
+     * @param  internal  the original coordinate
+     * @param  external
+     *	the coordinate whose values will be changed to the
+     *	external representation of <code>internal</code>
+     * @deprecated no longer needed, since internal representation is same as external representation
+     */
+    //void toExternal(const Coordinate& internal, Coordinate* external) const;
+
+    std::string toString() const;
+
+    /// \brief
+    /// Compares this PrecisionModel object with the specified object
+    /// for order.
+    //
+    /// A PrecisionModel is greater than another if it provides greater
+    /// precision.
+    /// The comparison is based on the value returned by the
+    /// getMaximumSignificantDigits method.
+    /// This comparison is not strictly accurate when comparing floating
+    /// precision models to fixed models;
+    /// however, it is correct when both models are either floating or
+    /// fixed.
+    ///
+    /// @param other the PrecisionModel with which this PrecisionModel
+    ///      is being compared
+    /// @return a negative integer, zero, or a positive integer as this
+    ///      PrecisionModel is less than, equal to, or greater than the
+    ///      specified PrecisionModel.
+    ///
+    int compareTo(const PrecisionModel* other) const;
 
 private:
 
-	/** \brief
-	 * Sets the multiplying factor used to obtain a precise coordinate.
-	 *
-	 * This method is private because PrecisionModel is intended to
-	 * be an immutable (value) type.
-	 *
-	 */
-	void setScale(double newScale);
-			// throw IllegalArgumentException
+    /** \brief
+     * Sets the multiplying factor used to obtain a precise coordinate.
+     *
+     * This method is private because PrecisionModel is intended to
+     * be an immutable (value) type.
+     *
+     */
+    void setScale(double newScale);
+    // throw IllegalArgumentException
 
-	Type modelType;
+    Type modelType;
 
-	double scale;
+    double scale;
 
 };
 
diff --git a/include/geos/geom/PrecisionModel.inl b/include/geos/geom/PrecisionModel.inl
index dd2bbe7..4f1fdf6 100644
--- a/include/geos/geom/PrecisionModel.inl
+++ b/include/geos/geom/PrecisionModel.inl
@@ -8,7 +8,7 @@
  *
  * This is free software; you can redistribute and/or modify it under
  * the terms of the GNU Lesser General Public Licence as published
- * by the Free Software Foundation. 
+ * by the Free Software Foundation.
  * See the COPYING file for more information.
  *
  **********************************************************************
@@ -28,7 +28,7 @@ namespace geos {
 namespace geom { // geos::geom
 
 /*public*/
-INLINE 
+INLINE
 PrecisionModel::~PrecisionModel(void)
 {
 }
@@ -37,15 +37,15 @@ PrecisionModel::~PrecisionModel(void)
 INLINE void
 PrecisionModel::makePrecise(Coordinate* coord) const
 {
-	assert(coord);
-	return makePrecise(*coord);
+    assert(coord);
+    return makePrecise(*coord);
 }
 
 /*public*/
 INLINE PrecisionModel::Type
 PrecisionModel::getType() const
 {
-	return modelType;
+    return modelType;
 }
 
 /*public*/
diff --git a/include/geos/geom/Puntal.h b/include/geos/geom/Puntal.h
index a705d8a..7f05ac1 100644
--- a/include/geos/geom/Puntal.h
+++ b/include/geos/geom/Puntal.h
@@ -34,10 +34,9 @@ namespace geom { // geos::geom
  * Identifies {@link Geometry} subclasses which
  * are 0-dimensional and with components which are {@link Point}s.
  */
-class GEOS_DLL Puntal : public virtual Geometry
-{
+class GEOS_DLL Puntal : public virtual Geometry {
 protected:
-  Puntal(): Geometry(nullptr) {}
+    Puntal(): Geometry(nullptr) {}
 };
 
 } // namespace geos::geom
diff --git a/include/geos/geom/Triangle.h b/include/geos/geom/Triangle.h
index 1a78ec8..26f8f2d 100644
--- a/include/geos/geom/Triangle.h
+++ b/include/geos/geom/Triangle.h
@@ -30,61 +30,61 @@ namespace geom { // geos::geom
  */
 class GEOS_DLL Triangle {
 public:
-	Coordinate p0, p1, p2;
-
-	Triangle(const Coordinate& nP0, const Coordinate& nP1, const Coordinate& nP2)
-		:
-		p0(nP0),
-		p1(nP1),
-		p2(nP2)
-	{}
-
-	/**
-	 * The inCentre of a triangle is the point which is equidistant
-	 * from the sides of the triangle.  This is also the point at which the bisectors
-	 * of the angles meet.
-	 *
-	 * @param resultPoint the point into which to write the inCentre of the triangle
-	 */
-	void inCentre(Coordinate& resultPoint);
-
-	/**
-	 * Computes the circumcentre of a triangle. The circumcentre is the centre of
-	 * the circumcircle, the smallest circle which encloses the triangle. It is
-	 * also the common intersection point of the perpendicular bisectors of the
-	 * sides of the triangle, and is the only point which has equal distance to
-	 * all three vertices of the triangle.
-	 * <p>
-	 * The circumcentre does not necessarily lie within the triangle. For example,
-	 * the circumcentre of an obtuse isoceles triangle lies outside the triangle.
-	 * <p>
-	 * This method uses an algorithm due to J.R.Shewchuk which uses normalization
-	 * to the origin to improve the accuracy of computation. (See <i>Lecture Notes
-	 * on Geometric Robustness</i>, Jonathan Richard Shewchuk, 1999).
-	 *
-	 * @param resultPoint the point into which to write the inCentre of the triangle
-	 */
-	void circumcentre(Coordinate& resultPoint);
+    Coordinate p0, p1, p2;
+
+    Triangle(const Coordinate& nP0, const Coordinate& nP1, const Coordinate& nP2)
+        :
+        p0(nP0),
+        p1(nP1),
+        p2(nP2)
+    {}
+
+    /**
+     * The inCentre of a triangle is the point which is equidistant
+     * from the sides of the triangle.  This is also the point at which the bisectors
+     * of the angles meet.
+     *
+     * @param resultPoint the point into which to write the inCentre of the triangle
+     */
+    void inCentre(Coordinate& resultPoint);
+
+    /**
+     * Computes the circumcentre of a triangle. The circumcentre is the centre of
+     * the circumcircle, the smallest circle which encloses the triangle. It is
+     * also the common intersection point of the perpendicular bisectors of the
+     * sides of the triangle, and is the only point which has equal distance to
+     * all three vertices of the triangle.
+     * <p>
+     * The circumcentre does not necessarily lie within the triangle. For example,
+     * the circumcentre of an obtuse isoceles triangle lies outside the triangle.
+     * <p>
+     * This method uses an algorithm due to J.R.Shewchuk which uses normalization
+     * to the origin to improve the accuracy of computation. (See <i>Lecture Notes
+     * on Geometric Robustness</i>, Jonathan Richard Shewchuk, 1999).
+     *
+     * @param resultPoint the point into which to write the inCentre of the triangle
+     */
+    void circumcentre(Coordinate& resultPoint);
 
     static const Coordinate circumcentre(const Coordinate& p0, const Coordinate& p1, const Coordinate& p2);
 
 private:
 
-	/**
-	 * Computes the determinant of a 2x2 matrix. Uses standard double-precision
-	 * arithmetic, so is susceptible to round-off error.
-	 *
-	 * @param m00
-	 *          the [0,0] entry of the matrix
-	 * @param m01
-	 *          the [0,1] entry of the matrix
-	 * @param m10
-	 *          the [1,0] entry of the matrix
-	 * @param m11
-	 *          the [1,1] entry of the matrix
-	 * @return the determinant
-	 */
-	double det(double m00 , double m01 , double m10 , double m11) const;
+    /**
+     * Computes the determinant of a 2x2 matrix. Uses standard double-precision
+     * arithmetic, so is susceptible to round-off error.
+     *
+     * @param m00
+     *          the [0,0] entry of the matrix
+     * @param m01
+     *          the [0,1] entry of the matrix
+     * @param m10
+     *          the [1,0] entry of the matrix
+     * @param m11
+     *          the [1,1] entry of the matrix
+     * @return the determinant
+     */
+    double det(double m00, double m01, double m10, double m11) const;
 
 };
 
diff --git a/include/geos/geom/prep/AbstractPreparedPolygonContains.h b/include/geos/geom/prep/AbstractPreparedPolygonContains.h
index 3106ca4..d9c00cc 100644
--- a/include/geos/geom/prep/AbstractPreparedPolygonContains.h
+++ b/include/geos/geom/prep/AbstractPreparedPolygonContains.h
@@ -25,13 +25,13 @@
 
 // forward declarations
 namespace geos {
-	namespace geom {
-		class Geometry;
+namespace geom {
+class Geometry;
 
-		namespace prep {
-			class PreparedPolygon;
-		}
-	}
+namespace prep {
+class PreparedPolygon;
+}
+}
 }
 
 
@@ -62,71 +62,70 @@ namespace prep { // geos::geom::prep
  * @author Martin Davis
  *
  */
-class AbstractPreparedPolygonContains : public PreparedPolygonPredicate
-{
+class AbstractPreparedPolygonContains : public PreparedPolygonPredicate {
 private:
-	// information about geometric situation
-	bool hasSegmentIntersection;
-	bool hasProperIntersection;
-	bool hasNonProperIntersection;
+    // information about geometric situation
+    bool hasSegmentIntersection;
+    bool hasProperIntersection;
+    bool hasNonProperIntersection;
 
-	bool isProperIntersectionImpliesNotContainedSituation( const geom::Geometry * testGeom);
+    bool isProperIntersectionImpliesNotContainedSituation(const geom::Geometry* testGeom);
 
-	/**
-	 * Tests whether a geometry consists of a single polygon with no holes.
-	 *
-	 * @return true if the geometry is a single polygon with no holes
-	 */
-	bool isSingleShell( const geom::Geometry & geom);
+    /**
+     * Tests whether a geometry consists of a single polygon with no holes.
+     *
+     * @return true if the geometry is a single polygon with no holes
+     */
+    bool isSingleShell(const geom::Geometry& geom);
 
-	void findAndClassifyIntersections( const geom::Geometry * geom);
+    void findAndClassifyIntersections(const geom::Geometry* geom);
 
 protected:
-	/**
-	 * This flag controls a difference between contains and covers.
-	 *
-	 * For contains the value is true.
-	 * For covers the value is false.
-	 */
-	bool requireSomePointInInterior;
-
-	/**
-	 * Evaluate the <tt>contains</tt> or <tt>covers</tt> relationship
-	 * for the given geometry.
-	 *
-	 * @param geom the test geometry
-	 * @return true if the test geometry is contained
-	 */
-	bool eval( const geom::Geometry * geom);
-
- 	/**
- 	 * Computes the full topological predicate.
-	 * Used when short-circuit tests are not conclusive.
-	 *
-	 * @param geom the test geometry
-	 * @return true if this prepared polygon has the relationship with the test geometry
-	 */
-	virtual bool fullTopologicalPredicate( const geom::Geometry * geom) =0;
+    /**
+     * This flag controls a difference between contains and covers.
+     *
+     * For contains the value is true.
+     * For covers the value is false.
+     */
+    bool requireSomePointInInterior;
+
+    /**
+     * Evaluate the <tt>contains</tt> or <tt>covers</tt> relationship
+     * for the given geometry.
+     *
+     * @param geom the test geometry
+     * @return true if the test geometry is contained
+     */
+    bool eval(const geom::Geometry* geom);
+
+    /**
+     * Computes the full topological predicate.
+     * Used when short-circuit tests are not conclusive.
+     *
+     * @param geom the test geometry
+     * @return true if this prepared polygon has the relationship with the test geometry
+     */
+    virtual bool fullTopologicalPredicate(const geom::Geometry* geom) = 0;
 
 public:
-	AbstractPreparedPolygonContains( const PreparedPolygon * const p_prepPoly)
-	:	PreparedPolygonPredicate( p_prepPoly),
-		hasSegmentIntersection( false),
-		hasProperIntersection( false),
-		hasNonProperIntersection( false),
-		requireSomePointInInterior(true)
-	{ }
-
-	AbstractPreparedPolygonContains( const PreparedPolygon * const p_prepPoly, bool p_requireSomePointInInterior)
-	:	PreparedPolygonPredicate( p_prepPoly),
-		hasSegmentIntersection( false),
-		hasProperIntersection( false),
-		hasNonProperIntersection( false),
-		requireSomePointInInterior(p_requireSomePointInInterior)
-	{ }
-
-	~AbstractPreparedPolygonContains() override
-	{ }
+    AbstractPreparedPolygonContains(const PreparedPolygon* const p_prepPoly)
+        :	PreparedPolygonPredicate(p_prepPoly),
+          hasSegmentIntersection(false),
+          hasProperIntersection(false),
+          hasNonProperIntersection(false),
+          requireSomePointInInterior(true)
+    { }
+
+    AbstractPreparedPolygonContains(const PreparedPolygon* const p_prepPoly, bool p_requireSomePointInInterior)
+        :	PreparedPolygonPredicate(p_prepPoly),
+          hasSegmentIntersection(false),
+          hasProperIntersection(false),
+          hasNonProperIntersection(false),
+          requireSomePointInInterior(p_requireSomePointInInterior)
+    { }
+
+    ~AbstractPreparedPolygonContains() override
+    { }
 
 };
 
diff --git a/include/geos/geom/prep/BasicPreparedGeometry.h b/include/geos/geom/prep/BasicPreparedGeometry.h
index a084ab6..7157906 100644
--- a/include/geos/geom/prep/BasicPreparedGeometry.h
+++ b/include/geos/geom/prep/BasicPreparedGeometry.h
@@ -30,10 +30,10 @@
 #include <string>
 
 namespace geos {
-	namespace geom {
-		class Geometry;
-		class Coordinate;
-	}
+namespace geom {
+class Geometry;
+class Coordinate;
+}
 }
 
 
@@ -56,122 +56,123 @@ namespace prep { // geos::geom::prep
  * @author Martin Davis
  *
  */
-class BasicPreparedGeometry: public PreparedGeometry
-{
+class BasicPreparedGeometry: public PreparedGeometry {
 private:
-	const geom::Geometry * baseGeom;
-	Coordinate::ConstVect representativePts;
+    const geom::Geometry* baseGeom;
+    Coordinate::ConstVect representativePts;
 
 protected:
-	/**
-	 * Sets the original {@link Geometry} which will be prepared.
-	 */
-	void setGeometry( const geom::Geometry * geom );
-
-	/**
-	 * Determines whether a Geometry g interacts with
-	 * this geometry by testing the geometry envelopes.
-	 *
-	 * @param g a Geometry
-	 * @return true if the envelopes intersect
-	 */
-	bool envelopesIntersect(const geom::Geometry* g) const;
-
-	/**
-	 * Determines whether the envelope of
-	 * this geometry covers the Geometry g.
-	 *
-	 *
-	 * @param g a Geometry
-	 * @return true if g is contained in this envelope
-	 */
-	bool envelopeCovers(const geom::Geometry* g) const;
+    /**
+     * Sets the original {@link Geometry} which will be prepared.
+     */
+    void setGeometry(const geom::Geometry* geom);
+
+    /**
+     * Determines whether a Geometry g interacts with
+     * this geometry by testing the geometry envelopes.
+     *
+     * @param g a Geometry
+     * @return true if the envelopes intersect
+     */
+    bool envelopesIntersect(const geom::Geometry* g) const;
+
+    /**
+     * Determines whether the envelope of
+     * this geometry covers the Geometry g.
+     *
+     *
+     * @param g a Geometry
+     * @return true if g is contained in this envelope
+     */
+    bool envelopeCovers(const geom::Geometry* g) const;
 
 public:
-	BasicPreparedGeometry( const Geometry * geom);
-
-	~BasicPreparedGeometry( ) override;
-
-	const geom::Geometry & getGeometry() const override
-	{
-		return *baseGeom;
-	}
-
-	/**
-	 * Gets the list of representative points for this geometry.
-	 * One vertex is included for every component of the geometry
-	 * (i.e. including one for every ring of polygonal geometries)
-	 *
-	 * @return a List of Coordinate
-	 */
-	const Coordinate::ConstVect * getRepresentativePoints()  const
-	{
-		return &representativePts;
-	}
-
-	/**
-	 * Tests whether any representative of the target geometry
-	 * intersects the test geometry.
-	 * This is useful in A/A, A/L, A/P, L/P, and P/P cases.
-	 *
-	 * @param geom the test geometry
-	 * @param repPts the representative points of the target geometry
-	 * @return true if any component intersects the areal test geometry
-	 */
-	bool isAnyTargetComponentInTest(const geom::Geometry * testGeom) const;
-
-	/**
-	 * Default implementation.
-	 */
-	bool contains(const geom::Geometry * g) const override;
-
-	/**
-	 * Default implementation.
-	 */
-	bool containsProperly(const geom::Geometry * g)	const override;
-
-	/**
-	 * Default implementation.
-	 */
-	bool coveredBy(const geom::Geometry * g) const override;
-
-	/**
-	 * Default implementation.
-	 */
-	bool covers(const geom::Geometry * g) const override;
-
-	/**
-	 * Default implementation.
-	 */
-	bool crosses(const geom::Geometry * g) const override;
-
-	/**
-	 * Standard implementation for all geometries.
-	 * Supports {@link GeometryCollection}s as input.
-	 */
-	bool disjoint(const geom::Geometry * g)	const override;
-
-	/**
-	 * Default implementation.
-	 */
-	bool intersects(const geom::Geometry * g) const override;
-
-	/**
-	 * Default implementation.
-	 */
-	bool overlaps(const geom::Geometry * g)	const override;
-
-	/**
-	 * Default implementation.
-	 */
-	bool touches(const geom::Geometry * g) const override;
-
-	/**
-	 * Default implementation.
-	 */
-	bool within(const geom::Geometry * g) const override;
-
-	std::string toString();
+    BasicPreparedGeometry(const Geometry* geom);
+
+    ~BasicPreparedGeometry() override;
+
+    const geom::Geometry&
+    getGeometry() const override
+    {
+        return *baseGeom;
+    }
+
+    /**
+     * Gets the list of representative points for this geometry.
+     * One vertex is included for every component of the geometry
+     * (i.e. including one for every ring of polygonal geometries)
+     *
+     * @return a List of Coordinate
+     */
+    const Coordinate::ConstVect*
+    getRepresentativePoints()  const
+    {
+        return &representativePts;
+    }
+
+    /**
+     * Tests whether any representative of the target geometry
+     * intersects the test geometry.
+     * This is useful in A/A, A/L, A/P, L/P, and P/P cases.
+     *
+     * @param geom the test geometry
+     * @param repPts the representative points of the target geometry
+     * @return true if any component intersects the areal test geometry
+     */
+    bool isAnyTargetComponentInTest(const geom::Geometry* testGeom) const;
+
+    /**
+     * Default implementation.
+     */
+    bool contains(const geom::Geometry* g) const override;
+
+    /**
+     * Default implementation.
+     */
+    bool containsProperly(const geom::Geometry* g)	const override;
+
+    /**
+     * Default implementation.
+     */
+    bool coveredBy(const geom::Geometry* g) const override;
+
+    /**
+     * Default implementation.
+     */
+    bool covers(const geom::Geometry* g) const override;
+
+    /**
+     * Default implementation.
+     */
+    bool crosses(const geom::Geometry* g) const override;
+
+    /**
+     * Standard implementation for all geometries.
+     * Supports {@link GeometryCollection}s as input.
+     */
+    bool disjoint(const geom::Geometry* g)	const override;
+
+    /**
+     * Default implementation.
+     */
+    bool intersects(const geom::Geometry* g) const override;
+
+    /**
+     * Default implementation.
+     */
+    bool overlaps(const geom::Geometry* g)	const override;
+
+    /**
+     * Default implementation.
+     */
+    bool touches(const geom::Geometry* g) const override;
+
+    /**
+     * Default implementation.
+     */
+    bool within(const geom::Geometry* g) const override;
+
+    std::string toString();
 
 };
 
diff --git a/include/geos/geom/prep/PreparedGeometry.h b/include/geos/geom/prep/PreparedGeometry.h
index ebcdc96..4c96382 100644
--- a/include/geos/geom/prep/PreparedGeometry.h
+++ b/include/geos/geom/prep/PreparedGeometry.h
@@ -23,9 +23,9 @@
 
 // Forward declarations
 namespace geos {
-	namespace geom {
-		class Geometry;
-	}
+namespace geom {
+class Geometry;
+}
 }
 
 
@@ -52,145 +52,146 @@ namespace prep { // geos::geom::prep
  */
 class GEOS_DLL PreparedGeometry {
 public:
-	virtual ~PreparedGeometry() {}
-
-	/**
-	 * Gets the original {@link Geometry} which has been prepared.
-	 *
-	 * @return the base geometry
-	 */
-	virtual const geom::Geometry & getGeometry() const =0;
-
-	/**
-	 * Tests whether the base {@link Geometry} contains a given geometry.
-	 *
-	 * @param geom the Geometry to test
-	 * @return true if this Geometry contains the given Geometry
-	 *
-	 * @see Geometry#contains(Geometry)
-	 */
-	virtual bool contains(const geom::Geometry *geom) const =0;
-
-	/** \brief
-	 * Tests whether the base {@link Geometry} properly contains
-	 * a given geometry.
-	 *
-	 * The <code>containsProperly</code> predicate has the following
-	 * equivalent definitions:
-	 *
-	 * - Every point of the other geometry is a point of this
-	 *   geometry's interior.
-	 * - The DE-9IM Intersection Matrix for the two geometries matches
-	 *   <code>[T**FF*FF*]</code>
-	 *
+    virtual
+    ~PreparedGeometry() {}
+
+    /**
+     * Gets the original {@link Geometry} which has been prepared.
+     *
+     * @return the base geometry
+     */
+    virtual const geom::Geometry& getGeometry() const = 0;
+
+    /**
+     * Tests whether the base {@link Geometry} contains a given geometry.
+     *
+     * @param geom the Geometry to test
+     * @return true if this Geometry contains the given Geometry
+     *
+     * @see Geometry#contains(Geometry)
+     */
+    virtual bool contains(const geom::Geometry* geom) const = 0;
+
+    /** \brief
+     * Tests whether the base {@link Geometry} properly contains
+     * a given geometry.
+     *
+     * The <code>containsProperly</code> predicate has the following
+     * equivalent definitions:
+     *
+     * - Every point of the other geometry is a point of this
+     *   geometry's interior.
+     * - The DE-9IM Intersection Matrix for the two geometries matches
+     *   <code>[T**FF*FF*]</code>
+     *
          * In other words, if the test geometry has any interaction with
-	 * the boundary of the target
+     * the boundary of the target
          * geometry the result of <tt>containsProperly</tt> is <tt>false</tt>.
          * This is different semantics to the {@link Geometry::contains}
-	 * predicate, * in which test geometries can intersect the target's
-	 * boundary and still be contained.
-	 *
+     * predicate, * in which test geometries can intersect the target's
+     * boundary and still be contained.
+     *
          * The advantage of using this predicate is that it can be computed
          * efficiently, since it avoids the need to compute the full
-	 * topological relationship of the input boundaries in cases where
-	 * they intersect.
-	 *
+     * topological relationship of the input boundaries in cases where
+     * they intersect.
+     *
          * An example use case is computing the intersections
          * of a set of geometries with a large polygonal geometry.
          * Since <tt>intersection</tt> is a fairly slow operation, it can
-	 * be more efficient
+     * be more efficient
          * to use <tt>containsProperly</tt> to filter out test geometries
-	 * which lie
+     * which lie
          * wholly inside the area.  In these cases the intersection is
          * known <i>a priori</i> to be exactly the original test geometry.
-	 *
-	 * @param geom the Geometry to test
-	 * @return true if this Geometry properly contains the given Geometry
-	 *
-	 * @see Geometry::contains
-	 *
-	 */
-	virtual bool containsProperly(const geom::Geometry *geom) const =0;
-
-	/**
-	 * Tests whether the base {@link Geometry} is covered by a given geometry.
-	 *
-	 * @param geom the Geometry to test
-	 * @return true if this Geometry is covered by the given Geometry
-	 *
-	 * @see Geometry#coveredBy(Geometry)
-	 */
-	virtual bool coveredBy(const geom::Geometry *geom) const =0;
-
-	/**
-	 * Tests whether the base {@link Geometry} covers a given geometry.
-	 *
-	 * @param geom the Geometry to test
-	 * @return true if this Geometry covers the given Geometry
-	 *
-	 * @see Geometry#covers(Geometry)
-	 */
-	virtual bool covers(const geom::Geometry *geom) const =0;
-
-	/**
-	 * Tests whether the base {@link Geometry} crosses a given geometry.
-	 *
-	 * @param geom the Geometry to test
-	 * @return true if this Geometry crosses the given Geometry
-	 *
-	 * @see Geometry#crosses(Geometry)
-	 */
-	virtual bool crosses(const geom::Geometry *geom) const =0;
-
-	/**
-	 * Tests whether the base {@link Geometry} is disjoint from a given geometry.
-	 *
-	 * @param geom the Geometry to test
-	 * @return true if this Geometry is disjoint from the given Geometry
-	 *
-	 * @see Geometry#disjoint(Geometry)
-	 */
-	virtual bool disjoint(const geom::Geometry *geom) const =0;
-
-	/**
-	 * Tests whether the base {@link Geometry} intersects a given geometry.
-	 *
-	 * @param geom the Geometry to test
-	 * @return true if this Geometry intersects the given Geometry
-	 *
-	 * @see Geometry#intersects(Geometry)
-	 */
-	virtual bool intersects(const geom::Geometry *geom) const =0;
-
-	/**
-	 * Tests whether the base {@link Geometry} overlaps a given geometry.
-	 *
-	 * @param geom the Geometry to test
-	 * @return true if this Geometry overlaps the given Geometry
-	 *
-	 * @see Geometry#overlaps(Geometry)
-	 */
-	virtual bool overlaps(const geom::Geometry *geom) const =0;
-
-	/**
-	 * Tests whether the base {@link Geometry} touches a given geometry.
-	 *
-	 * @param geom the Geometry to test
-	 * @return true if this Geometry touches the given Geometry
-	 *
-	 * @see Geometry#touches(Geometry)
-	 */
-	virtual bool touches(const geom::Geometry *geom) const =0;
-
-	/**
-	 * Tests whether the base {@link Geometry} is within a given geometry.
-	 *
-	 * @param geom the Geometry to test
-	 * @return true if this Geometry is within the given Geometry
-	 *
-	 * @see Geometry#within(Geometry)
-	 */
-	virtual bool within(const geom::Geometry *geom) const =0;
+     *
+     * @param geom the Geometry to test
+     * @return true if this Geometry properly contains the given Geometry
+     *
+     * @see Geometry::contains
+     *
+     */
+    virtual bool containsProperly(const geom::Geometry* geom) const = 0;
+
+    /**
+     * Tests whether the base {@link Geometry} is covered by a given geometry.
+     *
+     * @param geom the Geometry to test
+     * @return true if this Geometry is covered by the given Geometry
+     *
+     * @see Geometry#coveredBy(Geometry)
+     */
+    virtual bool coveredBy(const geom::Geometry* geom) const = 0;
+
+    /**
+     * Tests whether the base {@link Geometry} covers a given geometry.
+     *
+     * @param geom the Geometry to test
+     * @return true if this Geometry covers the given Geometry
+     *
+     * @see Geometry#covers(Geometry)
+     */
+    virtual bool covers(const geom::Geometry* geom) const = 0;
+
+    /**
+     * Tests whether the base {@link Geometry} crosses a given geometry.
+     *
+     * @param geom the Geometry to test
+     * @return true if this Geometry crosses the given Geometry
+     *
+     * @see Geometry#crosses(Geometry)
+     */
+    virtual bool crosses(const geom::Geometry* geom) const = 0;
+
+    /**
+     * Tests whether the base {@link Geometry} is disjoint from a given geometry.
+     *
+     * @param geom the Geometry to test
+     * @return true if this Geometry is disjoint from the given Geometry
+     *
+     * @see Geometry#disjoint(Geometry)
+     */
+    virtual bool disjoint(const geom::Geometry* geom) const = 0;
+
+    /**
+     * Tests whether the base {@link Geometry} intersects a given geometry.
+     *
+     * @param geom the Geometry to test
+     * @return true if this Geometry intersects the given Geometry
+     *
+     * @see Geometry#intersects(Geometry)
+     */
+    virtual bool intersects(const geom::Geometry* geom) const = 0;
+
+    /**
+     * Tests whether the base {@link Geometry} overlaps a given geometry.
+     *
+     * @param geom the Geometry to test
+     * @return true if this Geometry overlaps the given Geometry
+     *
+     * @see Geometry#overlaps(Geometry)
+     */
+    virtual bool overlaps(const geom::Geometry* geom) const = 0;
+
+    /**
+     * Tests whether the base {@link Geometry} touches a given geometry.
+     *
+     * @param geom the Geometry to test
+     * @return true if this Geometry touches the given Geometry
+     *
+     * @see Geometry#touches(Geometry)
+     */
+    virtual bool touches(const geom::Geometry* geom) const = 0;
+
+    /**
+     * Tests whether the base {@link Geometry} is within a given geometry.
+     *
+     * @param geom the Geometry to test
+     * @return true if this Geometry is within the given Geometry
+     *
+     * @see Geometry#within(Geometry)
+     */
+    virtual bool within(const geom::Geometry* geom) const = 0;
 };
 
 
diff --git a/include/geos/geom/prep/PreparedGeometryFactory.h b/include/geos/geom/prep/PreparedGeometryFactory.h
index 9f07386..3260772 100644
--- a/include/geos/geom/prep/PreparedGeometryFactory.h
+++ b/include/geos/geom/prep/PreparedGeometryFactory.h
@@ -24,11 +24,11 @@
 #include <geos/geom/prep/PreparedGeometry.h>
 
 namespace geos {
-	namespace geom {
-        namespace prep {
-            class PreparedGeometry;
-		}
-	}
+namespace geom {
+namespace prep {
+class PreparedGeometry;
+}
+}
 }
 
 
@@ -49,39 +49,40 @@ namespace prep { // geos::geom::prep
  * @author Martin Davis
  *
  */
-class GEOS_DLL PreparedGeometryFactory
-{
+class GEOS_DLL PreparedGeometryFactory {
 public:
 
-	/**
-	* Creates a new {@link PreparedGeometry} appropriate for the argument {@link Geometry}.
-	*
-	* @param geom the geometry to prepare
-	* @return the prepared geometry
-	*/
-	static const PreparedGeometry * prepare(const geom::Geometry * geom)
-	{
-		PreparedGeometryFactory pf;
-		return pf.create(geom);
-	}
+    /**
+    * Creates a new {@link PreparedGeometry} appropriate for the argument {@link Geometry}.
+    *
+    * @param geom the geometry to prepare
+    * @return the prepared geometry
+    */
+    static const PreparedGeometry*
+    prepare(const geom::Geometry* geom)
+    {
+        PreparedGeometryFactory pf;
+        return pf.create(geom);
+    }
 
     /**
- 	* Destroys {@link PreparedGeometry} allocated with the factory.
- 	*
-	* @param geom to be deallocated
-	*/
-    static void destroy(const PreparedGeometry* geom)
+    * Destroys {@link PreparedGeometry} allocated with the factory.
+    *
+    * @param geom to be deallocated
+    */
+    static void
+    destroy(const PreparedGeometry* geom)
     {
         delete geom;
     }
 
-	/**
- 	* Creates a new {@link PreparedGeometry} appropriate for the argument {@link Geometry}.
- 	*
-	* @param geom the geometry to prepare
-	* @return the prepared geometry
-	*/
-	const PreparedGeometry* create(const geom::Geometry* geom) const;
+    /**
+    * Creates a new {@link PreparedGeometry} appropriate for the argument {@link Geometry}.
+    *
+    * @param geom the geometry to prepare
+    * @return the prepared geometry
+    */
+    const PreparedGeometry* create(const geom::Geometry* geom) const;
 
 };
 
diff --git a/include/geos/geom/prep/PreparedLineString.h b/include/geos/geom/prep/PreparedLineString.h
index d804b80..bf5789e 100644
--- a/include/geos/geom/prep/PreparedLineString.h
+++ b/include/geos/geom/prep/PreparedLineString.h
@@ -24,9 +24,9 @@
 #include <geos/noding/SegmentString.h>
 
 namespace geos {
-	namespace noding {
-		class FastSegmentSetIntersectionFinder;
-	}
+namespace noding {
+class FastSegmentSetIntersectionFinder;
+}
 }
 
 namespace geos {
@@ -40,25 +40,24 @@ namespace prep { // geos::geom::prep
  * @author mbdavis
  *
  */
-class PreparedLineString : public BasicPreparedGeometry
-{
+class PreparedLineString : public BasicPreparedGeometry {
 private:
-	noding::FastSegmentSetIntersectionFinder * segIntFinder;
-	mutable noding::SegmentString::ConstVect segStrings;
+    noding::FastSegmentSetIntersectionFinder* segIntFinder;
+    mutable noding::SegmentString::ConstVect segStrings;
 
 protected:
 public:
-	PreparedLineString(const Geometry * geom)
-		:
-		BasicPreparedGeometry( geom),
-		segIntFinder( nullptr)
-	{ }
+    PreparedLineString(const Geometry* geom)
+        :
+        BasicPreparedGeometry(geom),
+        segIntFinder(nullptr)
+    { }
 
-	~PreparedLineString() override;
+    ~PreparedLineString() override;
 
-	noding::FastSegmentSetIntersectionFinder * getIntersectionFinder();
+    noding::FastSegmentSetIntersectionFinder* getIntersectionFinder();
 
-	bool intersects(const geom::Geometry * g) const override;
+    bool intersects(const geom::Geometry* g) const override;
 
 };
 
diff --git a/include/geos/geom/prep/PreparedLineStringIntersects.h b/include/geos/geom/prep/PreparedLineStringIntersects.h
index a1aef89..2196257 100644
--- a/include/geos/geom/prep/PreparedLineStringIntersects.h
+++ b/include/geos/geom/prep/PreparedLineStringIntersects.h
@@ -41,51 +41,51 @@ namespace prep { // geos::geom::prep
  * @author Martin Davis
  *
  */
-class PreparedLineStringIntersects
-{
+class PreparedLineStringIntersects {
 public:
 
-	/**
-	 * Computes the intersects predicate between a {@link PreparedLineString}
-	 * and a {@link Geometry}.
-	 *
-	 * @param prep the prepared linestring
-	 * @param geom a test geometry
-	 * @return true if the linestring intersects the geometry
-	 */
-	static bool intersects(  PreparedLineString & prep, const geom::Geometry * geom )
-	{
-		PreparedLineStringIntersects op( prep);
-		return op.intersects( geom);
-	}
+    /**
+     * Computes the intersects predicate between a {@link PreparedLineString}
+     * and a {@link Geometry}.
+     *
+     * @param prep the prepared linestring
+     * @param geom a test geometry
+     * @return true if the linestring intersects the geometry
+     */
+    static bool
+    intersects(PreparedLineString& prep, const geom::Geometry* geom)
+    {
+        PreparedLineStringIntersects op(prep);
+        return op.intersects(geom);
+    }
 
     /**
      * \todo FIXME - mloskot: Why not taking linestring through const reference?
      */
-	PreparedLineStringIntersects(PreparedLineString & prep)
-		: prepLine( prep)
-	{ }
+    PreparedLineStringIntersects(PreparedLineString& prep)
+        : prepLine(prep)
+    { }
 
-	/**
-	 * Tests whether this geometry intersects a given geometry.
-	 *
-	 * @param geom the test geometry
-	 * @return true if the test geometry intersects
-	 */
-	bool intersects(const geom::Geometry * g) const;
+    /**
+     * Tests whether this geometry intersects a given geometry.
+     *
+     * @param geom the test geometry
+     * @return true if the test geometry intersects
+     */
+    bool intersects(const geom::Geometry* g) const;
 
 protected:
-	PreparedLineString & prepLine;
+    PreparedLineString& prepLine;
 
-	/**
-	 * Tests whether any representative point of the test Geometry intersects
-	 * the target geometry.
-	 * Only handles test geometries which are Puntal (dimension 0)
-	 *
-	 * @param geom a Puntal geometry to test
-	 * @return true if any point of the argument intersects the prepared geometry
-	 */
-	bool isAnyTestPointInTarget(const geom::Geometry * testGeom) const;
+    /**
+     * Tests whether any representative point of the test Geometry intersects
+     * the target geometry.
+     * Only handles test geometries which are Puntal (dimension 0)
+     *
+     * @param geom a Puntal geometry to test
+     * @return true if any point of the argument intersects the prepared geometry
+     */
+    bool isAnyTestPointInTarget(const geom::Geometry* testGeom) const;
 
     // Declare type as noncopyable
     PreparedLineStringIntersects(const PreparedLineStringIntersects& other) = delete;
diff --git a/include/geos/geom/prep/PreparedPoint.h b/include/geos/geom/prep/PreparedPoint.h
index 6355f07..5c4dd37 100644
--- a/include/geos/geom/prep/PreparedPoint.h
+++ b/include/geos/geom/prep/PreparedPoint.h
@@ -33,22 +33,21 @@ namespace prep { // geos::geom::prep
  * @author Martin Davis
  *
  */
-class PreparedPoint: public BasicPreparedGeometry
-{
+class PreparedPoint: public BasicPreparedGeometry {
 private:
 protected:
 public:
-	PreparedPoint(const Geometry * geom)
-		: BasicPreparedGeometry( geom)
-	{ }
-
-	/**
-	 * Tests whether this point intersects a {@link Geometry}.
-	 *
-	 * The optimization here is that computing topology for the test
-	 * geometry is avoided. This can be significant for large geometries.
-	 */
-	bool intersects(const geom::Geometry* g) const override;
+    PreparedPoint(const Geometry* geom)
+        : BasicPreparedGeometry(geom)
+    { }
+
+    /**
+     * Tests whether this point intersects a {@link Geometry}.
+     *
+     * The optimization here is that computing topology for the test
+     * geometry is avoided. This can be significant for large geometries.
+     */
+    bool intersects(const geom::Geometry* g) const override;
 
 };
 
diff --git a/include/geos/geom/prep/PreparedPolygon.h b/include/geos/geom/prep/PreparedPolygon.h
index 0bfde3d..295397d 100644
--- a/include/geos/geom/prep/PreparedPolygon.h
+++ b/include/geos/geom/prep/PreparedPolygon.h
@@ -24,14 +24,14 @@
 #include <geos/noding/SegmentString.h>
 
 namespace geos {
-	namespace noding {
-		class FastSegmentSetIntersectionFinder;
-	}
-	namespace algorithm {
-		namespace locate {
-			class PointOnGeometryLocator;
-		}
-	}
+namespace noding {
+class FastSegmentSetIntersectionFinder;
+}
+namespace algorithm {
+namespace locate {
+class PointOnGeometryLocator;
+}
+}
 }
 
 namespace geos {
@@ -45,26 +45,25 @@ namespace prep { // geos::geom::prep
  * @author mbdavis
  *
  */
-class PreparedPolygon : public BasicPreparedGeometry
-{
+class PreparedPolygon : public BasicPreparedGeometry {
 private:
-	bool isRectangle;
-	mutable noding::FastSegmentSetIntersectionFinder * segIntFinder;
-	mutable algorithm::locate::PointOnGeometryLocator * ptOnGeomLoc;
-	mutable noding::SegmentString::ConstVect segStrings;
+    bool isRectangle;
+    mutable noding::FastSegmentSetIntersectionFinder* segIntFinder;
+    mutable algorithm::locate::PointOnGeometryLocator* ptOnGeomLoc;
+    mutable noding::SegmentString::ConstVect segStrings;
 
 protected:
 public:
-	PreparedPolygon( const geom::Geometry * geom);
-	~PreparedPolygon( ) override;
+    PreparedPolygon(const geom::Geometry* geom);
+    ~PreparedPolygon() override;
 
-	noding::FastSegmentSetIntersectionFinder * getIntersectionFinder() const;
-	algorithm::locate::PointOnGeometryLocator * getPointLocator() const;
+    noding::FastSegmentSetIntersectionFinder* getIntersectionFinder() const;
+    algorithm::locate::PointOnGeometryLocator* getPointLocator() const;
 
-	bool contains( const geom::Geometry* g) const override;
-	bool containsProperly( const geom::Geometry* g) const override;
-	bool covers( const geom::Geometry* g) const override;
-	bool intersects( const geom::Geometry* g) const override;
+    bool contains(const geom::Geometry* g) const override;
+    bool containsProperly(const geom::Geometry* g) const override;
+    bool covers(const geom::Geometry* g) const override;
+    bool intersects(const geom::Geometry* g) const override;
 
 };
 
diff --git a/include/geos/geom/prep/PreparedPolygonContains.h b/include/geos/geom/prep/PreparedPolygonContains.h
index bf76452..c8fe743 100644
--- a/include/geos/geom/prep/PreparedPolygonContains.h
+++ b/include/geos/geom/prep/PreparedPolygonContains.h
@@ -24,13 +24,13 @@
 
 // forward declarations
 namespace geos {
-	namespace geom {
-		class Geometry;
+namespace geom {
+class Geometry;
 
-		namespace prep {
-			class PreparedPolygon;
-		}
-	}
+namespace prep {
+class PreparedPolygon;
+}
+}
 }
 
 namespace geos {
@@ -51,51 +51,52 @@ namespace prep { // geos::geom::prep
  * @author Martin Davis
  *
  */
-class PreparedPolygonContains : public AbstractPreparedPolygonContains
-{
+class PreparedPolygonContains : public AbstractPreparedPolygonContains {
 public:
 
-	/**
-	 * Creates an instance of this operation.
-	 *
-	 * @param prepPoly the PreparedPolygon to evaluate
-	 */
-	PreparedPolygonContains(const PreparedPolygon * const prepPoly);
+    /**
+     * Creates an instance of this operation.
+     *
+     * @param prepPoly the PreparedPolygon to evaluate
+     */
+    PreparedPolygonContains(const PreparedPolygon* const prepPoly);
 
-	/**
-	 * Tests whether this PreparedPolygon <tt>contains</tt> a given geometry.
-	 *
-	 * @param geom the test geometry
-	 * @return true if the test geometry is contained
-	 */
-	bool contains(const geom::Geometry * geom)
-	{
-		return eval(geom);
-	}
+    /**
+     * Tests whether this PreparedPolygon <tt>contains</tt> a given geometry.
+     *
+     * @param geom the test geometry
+     * @return true if the test geometry is contained
+     */
+    bool
+    contains(const geom::Geometry* geom)
+    {
+        return eval(geom);
+    }
 
-	/**
-	 * Computes the </tt>contains</tt> predicate between a {@link PreparedPolygon}
-	 * and a {@link Geometry}.
-	 *
-	 * @param prep the prepared polygon
-	 * @param geom a test geometry
-	 * @return true if the polygon contains the geometry
-	 */
-	static bool contains(const PreparedPolygon * const prep, const geom::Geometry * geom)
-	{
-		PreparedPolygonContains polyInt(prep);
-		return polyInt.contains(geom);
-	}
+    /**
+     * Computes the </tt>contains</tt> predicate between a {@link PreparedPolygon}
+     * and a {@link Geometry}.
+     *
+     * @param prep the prepared polygon
+     * @param geom a test geometry
+     * @return true if the polygon contains the geometry
+     */
+    static bool
+    contains(const PreparedPolygon* const prep, const geom::Geometry* geom)
+    {
+        PreparedPolygonContains polyInt(prep);
+        return polyInt.contains(geom);
+    }
 
 protected:
-	/**
-	* Computes the full topological <tt>contains</tt> predicate.
-	* Used when short-circuit tests are not conclusive.
-	*
-	* @param geom the test geometry
-	* @return true if this prepared polygon contains the test geometry
-	*/
-	bool fullTopologicalPredicate(const geom::Geometry * geom) override;
+    /**
+    * Computes the full topological <tt>contains</tt> predicate.
+    * Used when short-circuit tests are not conclusive.
+    *
+    * @param geom the test geometry
+    * @return true if this prepared polygon contains the test geometry
+    */
+    bool fullTopologicalPredicate(const geom::Geometry* geom) override;
 
 };
 
diff --git a/include/geos/geom/prep/PreparedPolygonContainsProperly.h b/include/geos/geom/prep/PreparedPolygonContainsProperly.h
index ee36d9e..09a71e1 100644
--- a/include/geos/geom/prep/PreparedPolygonContainsProperly.h
+++ b/include/geos/geom/prep/PreparedPolygonContainsProperly.h
@@ -24,13 +24,13 @@
 #include <geos/geom/prep/PreparedPolygonPredicate.h> // inherited
 
 namespace geos {
-	namespace geom {
-		class Geometry;
+namespace geom {
+class Geometry;
 
-		namespace prep {
-			class PreparedPolygon;
-		}
-	}
+namespace prep {
+class PreparedPolygon;
+}
+}
 }
 
 namespace geos {
@@ -56,44 +56,43 @@ namespace prep { // geos::geom::prep
  *
  * @author Martin Davis
  */
-class PreparedPolygonContainsProperly : public PreparedPolygonPredicate
-{
+class PreparedPolygonContainsProperly : public PreparedPolygonPredicate {
 private:
 protected:
 public:
-	/**
-	 * Computes the </tt>containsProperly</tt> predicate between a {@link PreparedPolygon}
-	 * and a {@link Geometry}.
-	 *
-	 * @param prep the prepared polygon
-	 * @param geom a test geometry
-	 * @return true if the polygon properly contains the geometry
-	 */
-	static
-	bool
-	containsProperly( const PreparedPolygon * const prep, const geom::Geometry * geom)
-	{
-		PreparedPolygonContainsProperly polyInt( prep);
-		return polyInt.containsProperly( geom);
-	}
+    /**
+     * Computes the </tt>containsProperly</tt> predicate between a {@link PreparedPolygon}
+     * and a {@link Geometry}.
+     *
+     * @param prep the prepared polygon
+     * @param geom a test geometry
+     * @return true if the polygon properly contains the geometry
+     */
+    static
+    bool
+    containsProperly(const PreparedPolygon* const prep, const geom::Geometry* geom)
+    {
+        PreparedPolygonContainsProperly polyInt(prep);
+        return polyInt.containsProperly(geom);
+    }
 
-	/**
-	 * Creates an instance of this operation.
-	 *
-	 * @param prepPoly the PreparedPolygon to evaluate
-	 */
-	PreparedPolygonContainsProperly( const PreparedPolygon * const prep)
-	:	PreparedPolygonPredicate( prep)
-	{ }
+    /**
+     * Creates an instance of this operation.
+     *
+     * @param prepPoly the PreparedPolygon to evaluate
+     */
+    PreparedPolygonContainsProperly(const PreparedPolygon* const prep)
+        :	PreparedPolygonPredicate(prep)
+    { }
 
-	/**
-	 * Tests whether this PreparedPolygon containsProperly a given geometry.
-	 *
-	 * @param geom the test geometry
-	 * @return true if the test geometry is contained properly
-	 */
-	bool
-	containsProperly( const geom::Geometry * geom);
+    /**
+     * Tests whether this PreparedPolygon containsProperly a given geometry.
+     *
+     * @param geom the test geometry
+     * @return true if the test geometry is contained properly
+     */
+    bool
+    containsProperly(const geom::Geometry* geom);
 
 };
 
diff --git a/include/geos/geom/prep/PreparedPolygonCovers.h b/include/geos/geom/prep/PreparedPolygonCovers.h
index f633523..494e47b 100644
--- a/include/geos/geom/prep/PreparedPolygonCovers.h
+++ b/include/geos/geom/prep/PreparedPolygonCovers.h
@@ -25,13 +25,13 @@
 
 // forward declarations
 namespace geos {
-	namespace geom {
-		class Geometry;
+namespace geom {
+class Geometry;
 
-		namespace prep {
-			class PreparedPolygon;
-		}
-	}
+namespace prep {
+class PreparedPolygon;
+}
+}
 }
 
 namespace geos {
@@ -52,53 +52,54 @@ namespace prep { // geos::geom::prep
  * @author Martin Davis
  *
  */
-class PreparedPolygonCovers : public AbstractPreparedPolygonContains
-{
+class PreparedPolygonCovers : public AbstractPreparedPolygonContains {
 private:
 protected:
-	/**
-	 * Computes the full topological <tt>covers</tt> predicate.
-	 * Used when short-circuit tests are not conclusive.
-	 *
-	 * @param geom the test geometry
-	 * @return true if this prepared polygon covers the test geometry
-	 */
-	bool fullTopologicalPredicate( const geom::Geometry * geom) override;
+    /**
+     * Computes the full topological <tt>covers</tt> predicate.
+     * Used when short-circuit tests are not conclusive.
+     *
+     * @param geom the test geometry
+     * @return true if this prepared polygon covers the test geometry
+     */
+    bool fullTopologicalPredicate(const geom::Geometry* geom) override;
 
 public:
-	/**
-	 * Computes the </tt>covers</tt> predicate between a {@link PreparedPolygon}
-	 * and a {@link Geometry}.
-	 *
-	 * @param prep the prepared polygon
-	 * @param geom a test geometry
-	 * @return true if the polygon covers the geometry
-	 */
-	static bool covers(const PreparedPolygon * const prep, const geom::Geometry * geom)
-	{
-	    PreparedPolygonCovers polyInt(prep);
-		return polyInt.covers(geom);
-	}
+    /**
+     * Computes the </tt>covers</tt> predicate between a {@link PreparedPolygon}
+     * and a {@link Geometry}.
+     *
+     * @param prep the prepared polygon
+     * @param geom a test geometry
+     * @return true if the polygon covers the geometry
+     */
+    static bool
+    covers(const PreparedPolygon* const prep, const geom::Geometry* geom)
+    {
+        PreparedPolygonCovers polyInt(prep);
+        return polyInt.covers(geom);
+    }
 
-	/**
-	 * Creates an instance of this operation.
-	 *
-	 * @param prepPoly the PreparedPolygon to evaluate
-	 */
-	PreparedPolygonCovers(const PreparedPolygon * const prep)
-	:	AbstractPreparedPolygonContains( prep, false)
-	{ }
+    /**
+     * Creates an instance of this operation.
+     *
+     * @param prepPoly the PreparedPolygon to evaluate
+     */
+    PreparedPolygonCovers(const PreparedPolygon* const prep)
+        :	AbstractPreparedPolygonContains(prep, false)
+    { }
 
-	/**
-	 * Tests whether this PreparedPolygon <tt>covers</tt> a given geometry.
-	 *
-	 * @param geom the test geometry
-	 * @return true if the test geometry is covered
-	 */
-	bool covers( const Geometry * geom)
-	{
-		return eval( geom);
-	}
+    /**
+     * Tests whether this PreparedPolygon <tt>covers</tt> a given geometry.
+     *
+     * @param geom the test geometry
+     * @return true if the test geometry is covered
+     */
+    bool
+    covers(const Geometry* geom)
+    {
+        return eval(geom);
+    }
 
 };
 
diff --git a/include/geos/geom/prep/PreparedPolygonIntersects.h b/include/geos/geom/prep/PreparedPolygonIntersects.h
index e34e18d..c73f4cd 100644
--- a/include/geos/geom/prep/PreparedPolygonIntersects.h
+++ b/include/geos/geom/prep/PreparedPolygonIntersects.h
@@ -24,13 +24,13 @@
 #include <geos/geom/prep/PreparedPolygonPredicate.h> // inherited
 
 namespace geos {
-	namespace geom {
-		class Geometry;
+namespace geom {
+class Geometry;
 
-		namespace prep {
-			class PreparedPolygon;
-		}
-	}
+namespace prep {
+class PreparedPolygon;
+}
+}
 }
 
 namespace geos {
@@ -47,41 +47,41 @@ namespace prep { // geos::geom::prep
  * @author Martin Davis
  *
  */
-class PreparedPolygonIntersects : public PreparedPolygonPredicate
-{
+class PreparedPolygonIntersects : public PreparedPolygonPredicate {
 private:
 protected:
 public:
-	/**
-	 * Computes the intersects predicate between a {@link PreparedPolygon}
-	 * and a {@link Geometry}.
-	 *
-	 * @param prep the prepared polygon
-	 * @param geom a test geometry
-	 * @return true if the polygon intersects the geometry
-	 */
-	static bool intersects( const PreparedPolygon * const prep, const geom::Geometry * geom)
-	{
-		PreparedPolygonIntersects polyInt(prep);
-		return polyInt.intersects( geom);
-	}
+    /**
+     * Computes the intersects predicate between a {@link PreparedPolygon}
+     * and a {@link Geometry}.
+     *
+     * @param prep the prepared polygon
+     * @param geom a test geometry
+     * @return true if the polygon intersects the geometry
+     */
+    static bool
+    intersects(const PreparedPolygon* const prep, const geom::Geometry* geom)
+    {
+        PreparedPolygonIntersects polyInt(prep);
+        return polyInt.intersects(geom);
+    }
 
-	/**
-	 * Creates an instance of this operation.
-	 *
-	 * @param prepPoly the PreparedPolygon to evaluate
-	 */
-	PreparedPolygonIntersects( const PreparedPolygon * const prep)
-	:	PreparedPolygonPredicate( prep)
-	{ }
+    /**
+     * Creates an instance of this operation.
+     *
+     * @param prepPoly the PreparedPolygon to evaluate
+     */
+    PreparedPolygonIntersects(const PreparedPolygon* const prep)
+        :	PreparedPolygonPredicate(prep)
+    { }
 
-	/**
-	 * Tests whether this PreparedPolygon intersects a given geometry.
-	 *
-	 * @param geom the test geometry
-	 * @return true if the test geometry intersects
-	 */
-	bool intersects( const geom::Geometry * geom);
+    /**
+     * Tests whether this PreparedPolygon intersects a given geometry.
+     *
+     * @param geom the test geometry
+     * @return true if the test geometry intersects
+     */
+    bool intersects(const geom::Geometry* geom);
 
 };
 
diff --git a/include/geos/geom/prep/PreparedPolygonPredicate.h b/include/geos/geom/prep/PreparedPolygonPredicate.h
index f340930..bcc1812 100644
--- a/include/geos/geom/prep/PreparedPolygonPredicate.h
+++ b/include/geos/geom/prep/PreparedPolygonPredicate.h
@@ -25,21 +25,21 @@
 
 // forward declarations
 namespace geos {
-	namespace algorithm {
-		namespace locate {
-			class PointOnGeometryLocator;
-		}
-	}
-	namespace geom {
-		class Geometry;
-
-		namespace prep {
-			class PreparedPolygon;
-		}
-	}
-	namespace noding {
-		class FastSegmentSetIntersectionFinder;
-	}
+namespace algorithm {
+namespace locate {
+class PointOnGeometryLocator;
+}
+}
+namespace geom {
+class Geometry;
+
+namespace prep {
+class PreparedPolygon;
+}
+}
+namespace noding {
+class FastSegmentSetIntersectionFinder;
+}
 }
 
 
@@ -54,86 +54,87 @@ namespace prep { // geos::geom::prep
  * @author mbdavis
  *
  */
-class PreparedPolygonPredicate
-{
+class PreparedPolygonPredicate {
 private:
     // Declare type as noncopyable
     PreparedPolygonPredicate(const PreparedPolygonPredicate& other) = delete;
     PreparedPolygonPredicate& operator=(const PreparedPolygonPredicate& rhs) = delete;
 
 protected:
-	const PreparedPolygon * const prepPoly;
-
-	/** \brief
-	 * Tests whether all components of the test Geometry
-	 * are contained in the target geometry.
-	 *
-	 * Handles both linear and point components.
-	 *
-	 * @param geom a geometry to test
-	 * @return true if all components of the argument are contained
-	 *              in the target geometry
-	 */
-	bool isAllTestComponentsInTarget(const geom::Geometry * testGeom) const;
-
-	/** \brief
-	 * Tests whether all components of the test Geometry
-	 * are contained in the interior of the target geometry.
-	 *
-	 * Handles both linear and point components.
-	 *
-	 * @param geom a geometry to test
-	 * @return true if all componenta of the argument are contained in
-	 *              the target geometry interior
-	 */
-	bool isAllTestComponentsInTargetInterior( const geom::Geometry * testGeom) const;
-
-	/** \brief
-	 * Tests whether any component of the test Geometry intersects
-	 * the area of the target geometry.
-	 *
-	 * Handles test geometries with both linear and point components.
-	 *
-	 * @param geom a geometry to test
-	 * @return true if any component of the argument intersects the
-	 *              prepared geometry
-	 */
-	bool isAnyTestComponentInTarget( const geom::Geometry * testGeom) const;
-
-	/** \brief
-	 * Tests whether any component of the test Geometry intersects
-	 * the interior of the target geometry.
-	 *
-	 * Handles test geometries with both linear and point components.
-	 *
-	 * @param geom a geometry to test
-	 * @return true if any component of the argument intersects the
-	 *              prepared area geometry interior
-	 */
-	bool isAnyTestComponentInTargetInterior( const geom::Geometry * testGeom) const;
-
-	/**
-	 * Tests whether any component of the target geometry
-	 * intersects the test geometry (which must be an areal geometry)
-	 *
-	 * @param geom the test geometry
-	 * @param repPts the representative points of the target geometry
-	 * @return true if any component intersects the areal test geometry
-	 */
-	bool isAnyTargetComponentInAreaTest( const geom::Geometry * testGeom, const geom::Coordinate::ConstVect * targetRepPts) const;
+    const PreparedPolygon* const prepPoly;
+
+    /** \brief
+     * Tests whether all components of the test Geometry
+     * are contained in the target geometry.
+     *
+     * Handles both linear and point components.
+     *
+     * @param geom a geometry to test
+     * @return true if all components of the argument are contained
+     *              in the target geometry
+     */
+    bool isAllTestComponentsInTarget(const geom::Geometry* testGeom) const;
+
+    /** \brief
+     * Tests whether all components of the test Geometry
+     * are contained in the interior of the target geometry.
+     *
+     * Handles both linear and point components.
+     *
+     * @param geom a geometry to test
+     * @return true if all componenta of the argument are contained in
+     *              the target geometry interior
+     */
+    bool isAllTestComponentsInTargetInterior(const geom::Geometry* testGeom) const;
+
+    /** \brief
+     * Tests whether any component of the test Geometry intersects
+     * the area of the target geometry.
+     *
+     * Handles test geometries with both linear and point components.
+     *
+     * @param geom a geometry to test
+     * @return true if any component of the argument intersects the
+     *              prepared geometry
+     */
+    bool isAnyTestComponentInTarget(const geom::Geometry* testGeom) const;
+
+    /** \brief
+     * Tests whether any component of the test Geometry intersects
+     * the interior of the target geometry.
+     *
+     * Handles test geometries with both linear and point components.
+     *
+     * @param geom a geometry to test
+     * @return true if any component of the argument intersects the
+     *              prepared area geometry interior
+     */
+    bool isAnyTestComponentInTargetInterior(const geom::Geometry* testGeom) const;
+
+    /**
+     * Tests whether any component of the target geometry
+     * intersects the test geometry (which must be an areal geometry)
+     *
+     * @param geom the test geometry
+     * @param repPts the representative points of the target geometry
+     * @return true if any component intersects the areal test geometry
+     */
+    bool isAnyTargetComponentInAreaTest(const geom::Geometry* testGeom,
+                                        const geom::Coordinate::ConstVect* targetRepPts) const;
 
 public:
-	/**
-	 * Creates an instance of this operation.
-	 *
-	 * @param prepPoly the PreparedPolygon to evaluate
-	 */
-	PreparedPolygonPredicate( const PreparedPolygon * const p_prepPoly)
-	:	prepPoly( p_prepPoly)
-	{ }
-
-	virtual ~PreparedPolygonPredicate()
-	{ }
+    /**
+     * Creates an instance of this operation.
+     *
+     * @param prepPoly the PreparedPolygon to evaluate
+     */
+    PreparedPolygonPredicate(const PreparedPolygon* const p_prepPoly)
+        :	prepPoly(p_prepPoly)
+    { }
+
+    virtual
+    ~PreparedPolygonPredicate()
+    { }
 
 };
 
diff --git a/include/geos/geom/util/ComponentCoordinateExtracter.h b/include/geos/geom/util/ComponentCoordinateExtracter.h
index dc86bd4..ddfc9d6 100644
--- a/include/geos/geom/util/ComponentCoordinateExtracter.h
+++ b/include/geos/geom/util/ComponentCoordinateExtracter.h
@@ -34,31 +34,30 @@ namespace util { // geos::geom::util
  *
  * @version 1.9
  */
-class ComponentCoordinateExtracter : public GeometryComponentFilter
-{
+class ComponentCoordinateExtracter : public GeometryComponentFilter {
 public:
-	/**
-	 * Push the linear components from a single geometry into
-	 * the provided vector.
-	 * If more than one geometry is to be processed, it is more
-	 * efficient to create a single ComponentCoordinateFilter instance
-	 * and pass it to multiple geometries.
-	 */
-	static void getCoordinates(const Geometry &geom, std::vector<const Coordinate*> &ret);
+    /**
+     * Push the linear components from a single geometry into
+     * the provided vector.
+     * If more than one geometry is to be processed, it is more
+     * efficient to create a single ComponentCoordinateFilter instance
+     * and pass it to multiple geometries.
+     */
+    static void getCoordinates(const Geometry& geom, std::vector<const Coordinate*>& ret);
 
-	/**
-	 * Constructs a ComponentCoordinateFilter with a list in which
-	 * to store Coordinates found.
-	 */
-	ComponentCoordinateExtracter( std::vector<const Coordinate*> &newComps);
+    /**
+     * Constructs a ComponentCoordinateFilter with a list in which
+     * to store Coordinates found.
+     */
+    ComponentCoordinateExtracter(std::vector<const Coordinate*>& newComps);
 
-	void filter_rw( Geometry * geom) override;
+    void filter_rw(Geometry* geom) override;
 
-	void filter_ro( const Geometry * geom) override;
+    void filter_ro(const Geometry* geom) override;
 
 private:
 
-	Coordinate::ConstVect &comps;
+    Coordinate::ConstVect& comps;
 
     // Declare type as noncopyable
     ComponentCoordinateExtracter(const ComponentCoordinateExtracter& other) = delete;
diff --git a/include/geos/geom/util/CoordinateOperation.h b/include/geos/geom/util/CoordinateOperation.h
index 8b87cf4..8f5701f 100644
--- a/include/geos/geom/util/CoordinateOperation.h
+++ b/include/geos/geom/util/CoordinateOperation.h
@@ -21,11 +21,11 @@
 
 // Forward declarations
 namespace geos {
-	namespace geom {
-		class Geometry;
-		class CoordinateSequence;
-		class GeometryFactory;
-	}
+namespace geom {
+class Geometry;
+class CoordinateSequence;
+class GeometryFactory;
+}
 }
 
 
@@ -42,25 +42,25 @@ class GEOS_DLL CoordinateOperation: public GeometryEditorOperation {
 
 public:
 
-	/**
-	 * Return a newly created geometry, ownership to caller
-	 */
-	Geometry* edit(const Geometry *geometry,
-			const GeometryFactory *factory) override;
+    /**
+     * Return a newly created geometry, ownership to caller
+     */
+    Geometry* edit(const Geometry* geometry,
+                   const GeometryFactory* factory) override;
 
-	/**
-	 * Edits the array of Coordinate from a Geometry.
-	 *
-	 * @param coordinates the coordinate array to operate on
-	 * @param geometry the geometry containing the coordinate list
-	 * @return an edited coordinate array (which may be the same as
-	 *         the input)
-	 */
-	virtual CoordinateSequence* edit(const CoordinateSequence* coordinates,
-			const Geometry *geometry)=0;
+    /**
+     * Edits the array of Coordinate from a Geometry.
+     *
+     * @param coordinates the coordinate array to operate on
+     * @param geometry the geometry containing the coordinate list
+     * @return an edited coordinate array (which may be the same as
+     *         the input)
+     */
+    virtual CoordinateSequence* edit(const CoordinateSequence* coordinates,
+                                     const Geometry* geometry) = 0;
 
 
-	~CoordinateOperation() override {}
+    ~CoordinateOperation() override {}
 };
 
 
diff --git a/include/geos/geom/util/Densifier.h b/include/geos/geom/util/Densifier.h
index d93cc3b..364b019 100644
--- a/include/geos/geom/util/Densifier.h
+++ b/include/geos/geom/util/Densifier.h
@@ -57,26 +57,27 @@ namespace util {
  */
 class GEOS_DLL Densifier {
 public:
-	Densifier(const Geometry *inputGeom);
+    Densifier(const Geometry* inputGeom);
 
-	Geometry::Ptr densify(const Geometry *geom, double distanceTolerance);
-	void setDistanceTolerance(double distanceTolerance);
-	Geometry::Ptr getResultGeometry() const;
+    Geometry::Ptr densify(const Geometry* geom, double distanceTolerance);
+    void setDistanceTolerance(double distanceTolerance);
+    Geometry::Ptr getResultGeometry() const;
 
 private:
-	double distanceTolerance;
-	const Geometry *inputGeom;
-	static std::unique_ptr<Coordinate::Vect> densifyPoints(const Coordinate::Vect pts, double distanceTolerance, const PrecisionModel *precModel);
+    double distanceTolerance;
+    const Geometry* inputGeom;
+    static std::unique_ptr<Coordinate::Vect> densifyPoints(const Coordinate::Vect pts, double distanceTolerance,
+            const PrecisionModel* precModel);
 
-	class GEOS_DLL DensifyTransformer: public GeometryTransformer {
-	public:
-		DensifyTransformer(double distanceTolerance);
-		double distanceTolerance;
-		CoordinateSequence::Ptr transformCoordinates(const CoordinateSequence *coords, const Geometry *parent);
-		Geometry::Ptr transformPolygon(const Polygon *geom, const Geometry *parent);
-		Geometry::Ptr transformMultiPolygon(const MultiPolygon *geom, const Geometry *parent);
-		Geometry *createValidArea(const Geometry *roughAreaGeom);
-	};
+    class GEOS_DLL DensifyTransformer: public GeometryTransformer {
+    public:
+        DensifyTransformer(double distanceTolerance);
+        double distanceTolerance;
+        CoordinateSequence::Ptr transformCoordinates(const CoordinateSequence* coords, const Geometry* parent);
+        Geometry::Ptr transformPolygon(const Polygon* geom, const Geometry* parent);
+        Geometry::Ptr transformMultiPolygon(const MultiPolygon* geom, const Geometry* parent);
+        Geometry* createValidArea(const Geometry* roughAreaGeom);
+    };
 
 }; // Densifier
 
diff --git a/include/geos/geom/util/GeometryCombiner.h b/include/geos/geom/util/GeometryCombiner.h
index 1b5f4db..8fcf5be 100644
--- a/include/geos/geom/util/GeometryCombiner.h
+++ b/include/geos/geom/util/GeometryCombiner.h
@@ -23,10 +23,10 @@
 
 // Forward declarations
 namespace geos {
-    namespace geom {
-        class Geometry;
-        class GeometryFactory;
-    }
+namespace geom {
+class Geometry;
+class GeometryFactory;
+}
 }
 
 namespace geos {
@@ -44,8 +44,7 @@ namespace util { // geos.geom.util
  *
  * @see GeometryFactory#buildGeometry
  */
-class GeometryCombiner
-{
+class GeometryCombiner {
 public:
     /**
      * Combines a collection of geometries.
diff --git a/include/geos/geom/util/GeometryEditor.h b/include/geos/geom/util/GeometryEditor.h
index 6cf4c84..77cbaa8 100644
--- a/include/geos/geom/util/GeometryEditor.h
+++ b/include/geos/geom/util/GeometryEditor.h
@@ -25,15 +25,15 @@
 
 // Forward declarations
 namespace geos {
-	namespace geom {
-		class Geometry;
-		class GeometryFactory;
-		class GeometryCollection;
-		class Polygon;
-		namespace util {
-			class GeometryEditorOperation;
-		}
-	}
+namespace geom {
+class Geometry;
+class GeometryFactory;
+class GeometryCollection;
+class Polygon;
+namespace util {
+class GeometryEditorOperation;
+}
+}
 }
 
 
@@ -77,48 +77,48 @@ namespace util { // geos.geom.util
  */
 class GEOS_DLL GeometryEditor {
 private:
-	/**
-	 * The factory used to create the modified Geometry
-	 */
-	const GeometryFactory* factory;
+    /**
+     * The factory used to create the modified Geometry
+     */
+    const GeometryFactory* factory;
 
-	Polygon* editPolygon(const Polygon *polygon,
-			GeometryEditorOperation *operation);
+    Polygon* editPolygon(const Polygon* polygon,
+                         GeometryEditorOperation* operation);
 
-	GeometryCollection* editGeometryCollection(
-			const GeometryCollection *collection,
-			GeometryEditorOperation *operation);
+    GeometryCollection* editGeometryCollection(
+        const GeometryCollection* collection,
+        GeometryEditorOperation* operation);
 
 public:
 
-	/**
-	 * Creates a new GeometryEditor object which will create
-	 * an edited Geometry with the same GeometryFactory as the
-	 * input Geometry.
-	 */
-	GeometryEditor();
+    /**
+     * Creates a new GeometryEditor object which will create
+     * an edited Geometry with the same GeometryFactory as the
+     * input Geometry.
+     */
+    GeometryEditor();
 
-	/**
-	 * Creates a new GeometryEditor object which will create
-	 * the edited Geometry with the given GeometryFactory
-	 *
-	 * @param newFactory the GeometryFactory to create the edited
-	 *                   Geometry with
-	 */
-	GeometryEditor(const GeometryFactory *newFactory);
+    /**
+     * Creates a new GeometryEditor object which will create
+     * the edited Geometry with the given GeometryFactory
+     *
+     * @param newFactory the GeometryFactory to create the edited
+     *                   Geometry with
+     */
+    GeometryEditor(const GeometryFactory* newFactory);
 
-	/**
-	 * Edit the input Geometry with the given edit operation.
-	 * Clients will create subclasses of GeometryEditorOperation or
-	 * CoordinateOperation to perform required modifications.
-	 *
-	 * @param geometry the Geometry to edit
-	 * @param operation the edit operation to carry out
-	 * @return a new Geometry which is the result of the editing
-	 *
-	 */
-	Geometry* edit(const Geometry *geometry,
-			GeometryEditorOperation *operation); // final
+    /**
+     * Edit the input Geometry with the given edit operation.
+     * Clients will create subclasses of GeometryEditorOperation or
+     * CoordinateOperation to perform required modifications.
+     *
+     * @param geometry the Geometry to edit
+     * @param operation the edit operation to carry out
+     * @return a new Geometry which is the result of the editing
+     *
+     */
+    Geometry* edit(const Geometry* geometry,
+                   GeometryEditorOperation* operation); // final
 };
 
 } // namespace geos.geom.util
diff --git a/include/geos/geom/util/GeometryEditorOperation.h b/include/geos/geom/util/GeometryEditorOperation.h
index 58194e3..4824903 100644
--- a/include/geos/geom/util/GeometryEditorOperation.h
+++ b/include/geos/geom/util/GeometryEditorOperation.h
@@ -20,10 +20,10 @@
 
 // Forward declarations
 namespace geos {
-	namespace geom {
-		class Geometry;
-		class GeometryFactory;
-	}
+namespace geom {
+class Geometry;
+class GeometryFactory;
+}
 }
 
 
@@ -38,22 +38,23 @@ namespace util { // geos.geom.util
 class GEOS_DLL GeometryEditorOperation {
 
 public:
-	/**
-	 * Edits a Geometry by returning a new Geometry with a modification.
-	 * The returned Geometry might be the same as the Geometry passed in.
-	 *
-	 * @param geometry the Geometry to modify
-	 *
-	 * @param factory the factory with which to construct the modified
-	 *                Geometry (may be different to the factory of the
-	 *                input geometry)
-	 *
-	 * @return a new Geometry which is a modification of the input Geometry
-	 */
-	virtual Geometry* edit(const Geometry *geometry,
-			const GeometryFactory *factory)=0;
-
-	virtual ~GeometryEditorOperation() {}
+    /**
+     * Edits a Geometry by returning a new Geometry with a modification.
+     * The returned Geometry might be the same as the Geometry passed in.
+     *
+     * @param geometry the Geometry to modify
+     *
+     * @param factory the factory with which to construct the modified
+     *                Geometry (may be different to the factory of the
+     *                input geometry)
+     *
+     * @return a new Geometry which is a modification of the input Geometry
+     */
+    virtual Geometry* edit(const Geometry* geometry,
+                           const GeometryFactory* factory) = 0;
+
+    virtual
+    ~GeometryEditorOperation() {}
 };
 
 } // namespace geos.geom.util
diff --git a/include/geos/geom/util/GeometryExtracter.h b/include/geos/geom/util/GeometryExtracter.h
index 89073c6..3a3c0f0 100644
--- a/include/geos/geom/util/GeometryExtracter.h
+++ b/include/geos/geom/util/GeometryExtracter.h
@@ -37,57 +37,57 @@ class GEOS_DLL GeometryExtracter {
 
 public:
 
-  /**
-   * Extracts the components of type <tt>clz</tt> from a {@link Geometry}
-   * and adds them to the provided container.
-   *
-   * @param geom the geometry from which to extract
-   * @param list the list to add the extracted elements to
-   */
-  template <class ComponentType, class TargetContainer>
-  static void extract(const Geometry& geom, TargetContainer& lst)
-  {
-    if ( const ComponentType* p_c = dynamic_cast<const ComponentType*>(&geom) )
-    {
-      lst.push_back(p_c);
-    }
-    else if ( const GeometryCollection* p_c1 =
-                   dynamic_cast<const GeometryCollection*>(&geom) )
+    /**
+     * Extracts the components of type <tt>clz</tt> from a {@link Geometry}
+     * and adds them to the provided container.
+     *
+     * @param geom the geometry from which to extract
+     * @param list the list to add the extracted elements to
+     */
+    template <class ComponentType, class TargetContainer>
+    static void
+    extract(const Geometry& geom, TargetContainer& lst)
     {
-      GeometryExtracter::Extracter<ComponentType, TargetContainer> extracter(lst);
-      p_c1->apply_ro(&extracter);
+        if(const ComponentType* p_c = dynamic_cast<const ComponentType*>(&geom)) {
+            lst.push_back(p_c);
+        }
+        else if(const GeometryCollection* p_c1 =
+                    dynamic_cast<const GeometryCollection*>(&geom)) {
+            GeometryExtracter::Extracter<ComponentType, TargetContainer> extracter(lst);
+            p_c1->apply_ro(&extracter);
+        }
     }
-  }
 
 private:
 
-  template <class ComponentType, class TargetContainer>
-  struct Extracter: public GeometryFilter {
+    template <class ComponentType, class TargetContainer>
+    struct Extracter: public GeometryFilter {
 
-    /**
-     * Constructs a filter with a list in which to store the elements found.
-     *
-     * @param comps the container to extract into (will push_back to it)
-     */
-    Extracter(TargetContainer& comps) : comps_(comps) {}
+        /**
+         * Constructs a filter with a list in which to store the elements found.
+         *
+         * @param comps the container to extract into (will push_back to it)
+         */
+        Extracter(TargetContainer& comps) : comps_(comps) {}
 
-    TargetContainer& comps_;
+        TargetContainer& comps_;
 
-    void filter_ro(const Geometry* geom) override
-    {
-      if ( const ComponentType* c = dynamic_cast<const ComponentType*>(geom) ) {
-        comps_.push_back(c);
-      }
-    }
+        void
+        filter_ro(const Geometry* geom) override
+        {
+            if(const ComponentType* c = dynamic_cast<const ComponentType*>(geom)) {
+                comps_.push_back(c);
+            }
+        }
 
-    // Declare type as noncopyable
-    Extracter(const Extracter& other);
-    Extracter& operator=(const Extracter& rhs);
-  };
+        // Declare type as noncopyable
+        Extracter(const Extracter& other);
+        Extracter& operator=(const Extracter& rhs);
+    };
 
-  // Declare type as noncopyable
-  GeometryExtracter(const GeometryExtracter& other) = delete;
-  GeometryExtracter& operator=(const GeometryExtracter& rhs) = delete;
+    // Declare type as noncopyable
+    GeometryExtracter(const GeometryExtracter& other) = delete;
+    GeometryExtracter& operator=(const GeometryExtracter& rhs) = delete;
 };
 
 } // namespace geos.geom.util
diff --git a/include/geos/geom/util/GeometryTransformer.h b/include/geos/geom/util/GeometryTransformer.h
index c26ac56..b596a08 100644
--- a/include/geos/geom/util/GeometryTransformer.h
+++ b/include/geos/geom/util/GeometryTransformer.h
@@ -31,21 +31,21 @@
 
 // Forward declarations
 namespace geos {
-	namespace geom {
-		class Geometry;
-		class GeometryFactory;
-		class Point;
-		class LinearRing;
-		class LineString;
-		class Polygon;
-		class MultiPoint;
-		class MultiPolygon;
-		class MultiLineString;
-		class GeometryCollection;
-		namespace util {
-			//class GeometryEditorOperation;
-		}
-	}
+namespace geom {
+class Geometry;
+class GeometryFactory;
+class Point;
+class LinearRing;
+class LineString;
+class Polygon;
+class MultiPoint;
+class MultiPolygon;
+class MultiLineString;
+class GeometryCollection;
+namespace util {
+//class GeometryEditorOperation;
+}
+}
 }
 
 
@@ -93,101 +93,101 @@ class GEOS_DLL GeometryTransformer {
 
 public:
 
-	GeometryTransformer();
+    GeometryTransformer();
 
-	virtual ~GeometryTransformer();
+    virtual ~GeometryTransformer();
 
-	std::unique_ptr<Geometry> transform(const Geometry* nInputGeom);
+    std::unique_ptr<Geometry> transform(const Geometry* nInputGeom);
 
-	void setSkipTransformedInvalidInteriorRings(bool b);
+    void setSkipTransformedInvalidInteriorRings(bool b);
 
 protected:
 
-	const GeometryFactory* factory;
+    const GeometryFactory* factory;
 
-	/**
-	 * Convenience method which provides standard way of
-	 * creating a {@link CoordinateSequence}
-	 *
-	 * @param coords the coordinate array to copy
-	 * @return a coordinate sequence for the array
-	 *
-	 * [final]
-	 */
-	CoordinateSequence::Ptr createCoordinateSequence(
-			std::unique_ptr< std::vector<Coordinate> > coords);
+    /**
+     * Convenience method which provides standard way of
+     * creating a {@link CoordinateSequence}
+     *
+     * @param coords the coordinate array to copy
+     * @return a coordinate sequence for the array
+     *
+     * [final]
+     */
+    CoordinateSequence::Ptr createCoordinateSequence(
+        std::unique_ptr< std::vector<Coordinate> > coords);
 
-	virtual CoordinateSequence::Ptr transformCoordinates(
-			const CoordinateSequence* coords,
-			const Geometry* parent);
+    virtual CoordinateSequence::Ptr transformCoordinates(
+        const CoordinateSequence* coords,
+        const Geometry* parent);
 
-	virtual Geometry::Ptr transformPoint(
-			const Point* geom,
-			const Geometry* parent);
+    virtual Geometry::Ptr transformPoint(
+        const Point* geom,
+        const Geometry* parent);
 
-	virtual Geometry::Ptr transformMultiPoint(
-			const MultiPoint* geom,
-			const Geometry* parent);
+    virtual Geometry::Ptr transformMultiPoint(
+        const MultiPoint* geom,
+        const Geometry* parent);
 
-	virtual Geometry::Ptr transformLinearRing(
-			const LinearRing* geom,
-			const Geometry* parent);
+    virtual Geometry::Ptr transformLinearRing(
+        const LinearRing* geom,
+        const Geometry* parent);
 
-	virtual Geometry::Ptr transformLineString(
-			const LineString* geom,
-			const Geometry* parent);
+    virtual Geometry::Ptr transformLineString(
+        const LineString* geom,
+        const Geometry* parent);
 
-	virtual Geometry::Ptr transformMultiLineString(
-			const MultiLineString* geom,
-			const Geometry* parent);
+    virtual Geometry::Ptr transformMultiLineString(
+        const MultiLineString* geom,
+        const Geometry* parent);
 
-	virtual Geometry::Ptr transformPolygon(
-			const Polygon* geom,
-			const Geometry* parent);
+    virtual Geometry::Ptr transformPolygon(
+        const Polygon* geom,
+        const Geometry* parent);
 
-	virtual Geometry::Ptr transformMultiPolygon(
-			const MultiPolygon* geom,
-			const Geometry* parent);
+    virtual Geometry::Ptr transformMultiPolygon(
+        const MultiPolygon* geom,
+        const Geometry* parent);
 
-	virtual Geometry::Ptr transformGeometryCollection(
-			const GeometryCollection* geom,
-			const Geometry* parent);
+    virtual Geometry::Ptr transformGeometryCollection(
+        const GeometryCollection* geom,
+        const Geometry* parent);
 
 private:
 
-	const Geometry* inputGeom;
-
-	// these could eventually be exposed to clients
-	/**
-	 * <code>true</code> if empty geometries should not be included in the result
-	 */
-	bool pruneEmptyGeometry;
-
-	/**
-	 * <code>true</code> if a homogenous collection result
-	 * from a {@link GeometryCollection} should still
-	 * be a general GeometryCollection
-	 */
-	bool preserveGeometryCollectionType;
-
-	/**
-	 * <code>true</code> if the output from a collection argument should still be a collection
-	 */
-	// bool preserveCollections;
-
-	/**
-	 * <code>true</code> if the type of the input should be preserved
-	 */
-	bool preserveType;
-
-	/**
-	 * <code>true</code> if transformed invalid interior rings should be skipped
-	 */
-	bool skipTransformedInvalidInteriorRings;
-
-	// Declare type as noncopyable
-	GeometryTransformer(const GeometryTransformer& other) = delete;
-	GeometryTransformer& operator=(const GeometryTransformer& rhs) = delete;
+    const Geometry* inputGeom;
+
+    // these could eventually be exposed to clients
+    /**
+     * <code>true</code> if empty geometries should not be included in the result
+     */
+    bool pruneEmptyGeometry;
+
+    /**
+     * <code>true</code> if a homogenous collection result
+     * from a {@link GeometryCollection} should still
+     * be a general GeometryCollection
+     */
+    bool preserveGeometryCollectionType;
+
+    /**
+     * <code>true</code> if the output from a collection argument should still be a collection
+     */
+    // bool preserveCollections;
+
+    /**
+     * <code>true</code> if the type of the input should be preserved
+     */
+    bool preserveType;
+
+    /**
+     * <code>true</code> if transformed invalid interior rings should be skipped
+     */
+    bool skipTransformedInvalidInteriorRings;
+
+    // Declare type as noncopyable
+    GeometryTransformer(const GeometryTransformer& other) = delete;
+    GeometryTransformer& operator=(const GeometryTransformer& rhs) = delete;
 };
 
 
diff --git a/include/geos/geom/util/LinearComponentExtracter.h b/include/geos/geom/util/LinearComponentExtracter.h
index 1c0756f..48a5398 100644
--- a/include/geos/geom/util/LinearComponentExtracter.h
+++ b/include/geos/geom/util/LinearComponentExtracter.h
@@ -35,30 +35,30 @@ class GEOS_DLL LinearComponentExtracter: public GeometryComponentFilter {
 
 private:
 
-	LineString::ConstVect &comps;
+    LineString::ConstVect& comps;
 
     // Declare type as noncopyable
     LinearComponentExtracter(const LinearComponentExtracter& other) = delete;
     LinearComponentExtracter& operator=(const LinearComponentExtracter& rhs) = delete;
 
 public:
-	/**
-	 * Push the linear components from a single geometry into
-	 * the provided vector.
-	 * If more than one geometry is to be processed, it is more
-	 * efficient to create a single LinearComponentExtracterFilter instance
-	 * and pass it to multiple geometries.
-	 */
-	static void getLines(const Geometry &geom, std::vector<const LineString*> &ret);
-	/**
-	 * Constructs a LinearComponentExtracterFilter with a list in which
-	 * to store LineStrings found.
-	 */
-	LinearComponentExtracter(std::vector<const LineString*> &newComps);
+    /**
+     * Push the linear components from a single geometry into
+     * the provided vector.
+     * If more than one geometry is to be processed, it is more
+     * efficient to create a single LinearComponentExtracterFilter instance
+     * and pass it to multiple geometries.
+     */
+    static void getLines(const Geometry& geom, std::vector<const LineString*>& ret);
+    /**
+     * Constructs a LinearComponentExtracterFilter with a list in which
+     * to store LineStrings found.
+     */
+    LinearComponentExtracter(std::vector<const LineString*>& newComps);
 
-	void filter_rw(Geometry *geom) override;
+    void filter_rw(Geometry* geom) override;
 
-	void filter_ro(const Geometry *geom) override;
+    void filter_ro(const Geometry* geom) override;
 
 };
 
diff --git a/include/geos/geom/util/PointExtracter.h b/include/geos/geom/util/PointExtracter.h
index df4c3d6..bc3b46d 100644
--- a/include/geos/geom/util/PointExtracter.h
+++ b/include/geos/geom/util/PointExtracter.h
@@ -31,27 +31,27 @@ namespace util { // geos.geom.util
 class GEOS_DLL PointExtracter: public GeometryFilter {
 
 public:
-	/**
-	 * Returns the Point components from a single geometry.
-	 * If more than one geometry is to be processed, it is more
-	 * efficient to create a single PointExtracter filter instance
-	 * and pass it to multiple geometries.
-	 */
-	static void getPoints(const Geometry &geom, Point::ConstVect &ret);
+    /**
+     * Returns the Point components from a single geometry.
+     * If more than one geometry is to be processed, it is more
+     * efficient to create a single PointExtracter filter instance
+     * and pass it to multiple geometries.
+     */
+    static void getPoints(const Geometry& geom, Point::ConstVect& ret);
 
-	/**
-	 * Constructs a PointExtracterFilter with a list in which
-	 * to store Points found.
-	 */
-	PointExtracter(Point::ConstVect& newComps);
+    /**
+     * Constructs a PointExtracterFilter with a list in which
+     * to store Points found.
+     */
+    PointExtracter(Point::ConstVect& newComps);
 
-	void filter_rw(Geometry *geom) override;
+    void filter_rw(Geometry* geom) override;
 
-	void filter_ro(const Geometry *geom) override;
+    void filter_ro(const Geometry* geom) override;
 
 private:
 
-	Point::ConstVect& comps;
+    Point::ConstVect& comps;
 
     // Declare type as noncopyable
     PointExtracter(const PointExtracter& other) = delete;
diff --git a/include/geos/geom/util/PolygonExtracter.h b/include/geos/geom/util/PolygonExtracter.h
index 176aa2c..1467d2c 100644
--- a/include/geos/geom/util/PolygonExtracter.h
+++ b/include/geos/geom/util/PolygonExtracter.h
@@ -32,24 +32,24 @@ class GEOS_DLL PolygonExtracter: public GeometryFilter {
 
 public:
 
-	/**
-	 * Pushes the Polygon components from a single geometry into
-	 * the provided vector.
-	 * If more than one geometry is to be processed, it is more
-	 * efficient to create a single PolygonExtracterFilter instance
-	 * and pass it to multiple geometries.
-	 */
-	static void getPolygons(const Geometry &geom, std::vector<const Polygon*>& ret);
+    /**
+     * Pushes the Polygon components from a single geometry into
+     * the provided vector.
+     * If more than one geometry is to be processed, it is more
+     * efficient to create a single PolygonExtracterFilter instance
+     * and pass it to multiple geometries.
+     */
+    static void getPolygons(const Geometry& geom, std::vector<const Polygon*>& ret);
 
-	/**
-	 * Constructs a PolygonExtracterFilter with a list in which
-	 * to store Polygons found.
-	 */
-	PolygonExtracter(std::vector<const Polygon*>& newComps);
+    /**
+     * Constructs a PolygonExtracterFilter with a list in which
+     * to store Polygons found.
+     */
+    PolygonExtracter(std::vector<const Polygon*>& newComps);
 
-	void filter_rw(Geometry *geom) override;
+    void filter_rw(Geometry* geom) override;
 
-	void filter_ro(const Geometry *geom) override;
+    void filter_ro(const Geometry* geom) override;
 
 private:
 
diff --git a/include/geos/geom/util/ShortCircuitedGeometryVisitor.h b/include/geos/geom/util/ShortCircuitedGeometryVisitor.h
index 90cd5cc..7e0ef9f 100644
--- a/include/geos/geom/util/ShortCircuitedGeometryVisitor.h
+++ b/include/geos/geom/util/ShortCircuitedGeometryVisitor.h
@@ -20,9 +20,9 @@
 
 // Forward declarations
 namespace geos {
-	namespace geom {
-		class Geometry;
-	}
+namespace geom {
+class Geometry;
+}
 }
 
 
@@ -36,28 +36,28 @@ namespace util { // geos.geom.util
  *
  * Last port: geom/util/ShortCircuitedGeometryVisitor.java rev. 1.1 (JTS-1.7)
  */
-class GEOS_DLL ShortCircuitedGeometryVisitor
-{
+class GEOS_DLL ShortCircuitedGeometryVisitor {
 
 private:
 
-	bool done;
+    bool done;
 
 protected:
 
-	virtual void visit(const Geometry &element)=0;
-	virtual bool isDone()=0;
+    virtual void visit(const Geometry& element) = 0;
+    virtual bool isDone() = 0;
 
 public:
 
-	ShortCircuitedGeometryVisitor()
-		:
-		done(false)
-		{}
+    ShortCircuitedGeometryVisitor()
+        :
+        done(false)
+    {}
 
-	void applyTo(const Geometry &geom);
+    void applyTo(const Geometry& geom);
 
-	virtual ~ShortCircuitedGeometryVisitor() {}
+    virtual
+    ~ShortCircuitedGeometryVisitor() {}
 
 };
 
diff --git a/include/geos/geom/util/SineStarFactory.h b/include/geos/geom/util/SineStarFactory.h
index 03c1b8c..e5768b9 100644
--- a/include/geos/geom/util/SineStarFactory.h
+++ b/include/geos/geom/util/SineStarFactory.h
@@ -32,14 +32,14 @@
 
 // Forward declarations
 namespace geos {
-	namespace geom {
-		class Coordinate;
-		class Envelope;
-		class Polygon;
-		class GeometryFactory;
-		class PrecisionModel;
-		class LineString;
-	}
+namespace geom {
+class Coordinate;
+class Envelope;
+class Polygon;
+class GeometryFactory;
+class PrecisionModel;
+class LineString;
+}
 }
 
 namespace geos {
@@ -59,54 +59,56 @@ class GEOS_DLL SineStarFactory : public geos::util::GeometricShapeFactory  {
 
 protected:
 
-  int numArms;
-  double armLengthRatio;
+    int numArms;
+    double armLengthRatio;
 
 public:
 
-  /**
-   * Creates a factory which will create sine stars using the given
-   * {@link GeometryFactory}.
-   *
-	 * @param fact the factory to use. You need to keep the
-	 *	factory alive for the whole SineStarFactory
-	 *	life time.
-   */
-	SineStarFactory(const geom::GeometryFactory* fact)
-    :
-    geos::util::GeometricShapeFactory(fact),
-    numArms(8),
-    armLengthRatio(0.5)
-  {}
-
-  /**
-   * Sets the number of arms in the star
-   *
-   * @param nArms the number of arms to generate
-   */
-  void setNumArms(int nArms)
-  {
-    numArms = nArms;
-  }
-
-  /**
-   * Sets the ration of the length of each arm to the distance from the tip
-   * of the arm to the centre of the star.
-   * Value should be between 0.0 and 1.0
-   *
-   * @param armLenRatio
-   */
-  void setArmLengthRatio(double armLenRatio)
-  {
+    /**
+     * Creates a factory which will create sine stars using the given
+     * {@link GeometryFactory}.
+     *
+     * @param fact the factory to use. You need to keep the
+     *	factory alive for the whole SineStarFactory
+     *	life time.
+     */
+    SineStarFactory(const geom::GeometryFactory* fact)
+        :
+        geos::util::GeometricShapeFactory(fact),
+        numArms(8),
+        armLengthRatio(0.5)
+    {}
+
+    /**
+     * Sets the number of arms in the star
+     *
+     * @param nArms the number of arms to generate
+     */
+    void
+    setNumArms(int nArms)
+    {
+        numArms = nArms;
+    }
+
+    /**
+     * Sets the ration of the length of each arm to the distance from the tip
+     * of the arm to the centre of the star.
+     * Value should be between 0.0 and 1.0
+     *
+     * @param armLenRatio
+     */
+    void
+    setArmLengthRatio(double armLenRatio)
+    {
         armLengthRatio = armLenRatio;
-  }
-
-  /**
-   * Generates the geometry for the sine star
-   *
-   * @return the geometry representing the sine star
-   */
-  std::unique_ptr<Polygon> createSineStar() const;
+    }
+
+    /**
+     * Generates the geometry for the sine star
+     *
+     * @return the geometry representing the sine star
+     */
+    std::unique_ptr<Polygon> createSineStar() const;
 
 
 };
diff --git a/include/geos/geomgraph/Depth.h b/include/geos/geomgraph/Depth.h
index 66a5743..cb247f9 100644
--- a/include/geos/geomgraph/Depth.h
+++ b/include/geos/geomgraph/Depth.h
@@ -28,9 +28,9 @@
 
 // Forward declarations
 namespace geos {
-	namespace geomgraph {
-		class Label;
-	}
+namespace geomgraph {
+class Label;
+}
 }
 
 namespace geos {
@@ -38,25 +38,25 @@ namespace geomgraph { // geos.geomgraph
 
 class GEOS_DLL Depth {
 public:
-	static int depthAtLocation(int location);
-	Depth();
-	virtual ~Depth(); // FIXME: shoudn't be virtual!
-	int getDepth(int geomIndex,int posIndex) const;
-	void setDepth(int geomIndex,int posIndex,int depthValue);
-	int getLocation(int geomIndex,int posIndex) const;
-	void add(int geomIndex,int posIndex,int location);
-	bool isNull() const;
-	bool isNull(int geomIndex) const;
-	bool isNull(int geomIndex, int posIndex) const;
-	int getDelta(int geomIndex) const;
-	void normalize();
-	void add(const Label& lbl);
-	std::string toString() const;
+    static int depthAtLocation(int location);
+    Depth();
+    virtual ~Depth(); // FIXME: shoudn't be virtual!
+    int getDepth(int geomIndex, int posIndex) const;
+    void setDepth(int geomIndex, int posIndex, int depthValue);
+    int getLocation(int geomIndex, int posIndex) const;
+    void add(int geomIndex, int posIndex, int location);
+    bool isNull() const;
+    bool isNull(int geomIndex) const;
+    bool isNull(int geomIndex, int posIndex) const;
+    int getDelta(int geomIndex) const;
+    void normalize();
+    void add(const Label& lbl);
+    std::string toString() const;
 private:
-	enum {
-		NULL_VALUE=-1 //Replaces NULL
-	};
-	int depth[2][3];
+    enum {
+        NULL_VALUE = -1 //Replaces NULL
+    };
+    int depth[2][3];
 };
 
 } // namespace geos.geomgraph
diff --git a/include/geos/geomgraph/DirectedEdge.h b/include/geos/geomgraph/DirectedEdge.h
index ee992d5..74cf390 100644
--- a/include/geos/geomgraph/DirectedEdge.h
+++ b/include/geos/geomgraph/DirectedEdge.h
@@ -31,10 +31,10 @@
 
 // Forward declarations
 namespace geos {
-	namespace geomgraph {
-		class Edge;
-		class EdgeRing;
-	}
+namespace geomgraph {
+class Edge;
+class EdgeRing;
+}
 }
 
 namespace geos {
@@ -45,140 +45,140 @@ class GEOS_DLL DirectedEdge: public EdgeEnd {
 
 public:
 
-	/** \brief
-	 * Computes the factor for the change in depth when moving from
-	 * one location to another.
-	 * E.g. if crossing from the INTERIOR to the EXTERIOR the depth
-	 * decreases, so the factor is -1
-	 */
-	static int depthFactor(int currLocation, int nextLocation);
+    /** \brief
+     * Computes the factor for the change in depth when moving from
+     * one location to another.
+     * E.g. if crossing from the INTERIOR to the EXTERIOR the depth
+     * decreases, so the factor is -1
+     */
+    static int depthFactor(int currLocation, int nextLocation);
 
-	//DirectedEdge();
-	//virtual ~DirectedEdge();
+    //DirectedEdge();
+    //virtual ~DirectedEdge();
 
-	DirectedEdge(Edge *newEdge, bool newIsForward);
+    DirectedEdge(Edge* newEdge, bool newIsForward);
 
-	// this is no different from Base class, no need to override
-	//Edge* getEdge();
+    // this is no different from Base class, no need to override
+    //Edge* getEdge();
 
-	void setInResult(bool newIsInResult);
+    void setInResult(bool newIsInResult);
 
-	bool isInResult();
+    bool isInResult();
 
-	bool isVisited();
+    bool isVisited();
 
-	void setVisited(bool newIsVisited);
+    void setVisited(bool newIsVisited);
 
-	void setEdgeRing(EdgeRing *newEdgeRing);
+    void setEdgeRing(EdgeRing* newEdgeRing);
 
-	EdgeRing* getEdgeRing();
+    EdgeRing* getEdgeRing();
 
-	void setMinEdgeRing(EdgeRing *newMinEdgeRing);
+    void setMinEdgeRing(EdgeRing* newMinEdgeRing);
 
-	EdgeRing* getMinEdgeRing();
+    EdgeRing* getMinEdgeRing();
 
-	int getDepth(int position);
+    int getDepth(int position);
 
-	void setDepth(int position, int newDepth);
+    void setDepth(int position, int newDepth);
 
-	int getDepthDelta() const;
+    int getDepthDelta() const;
 
-	/// Marks both DirectedEdges attached to a given Edge.
-	//
-	/// This is used for edges corresponding to lines, which will only
-	/// appear oriented in a single direction in the result.
-	///
-	void setVisitedEdge(bool newIsVisited);
+    /// Marks both DirectedEdges attached to a given Edge.
+    //
+    /// This is used for edges corresponding to lines, which will only
+    /// appear oriented in a single direction in the result.
+    ///
+    void setVisitedEdge(bool newIsVisited);
 
 
-	/** \brief
-	 * Each Edge gives rise to a pair of symmetric DirectedEdges,
-	 * in opposite directions.
-	 *
-	 * @return the DirectedEdge for the same Edge but in the
-	 *         opposite direction
-	 */
-	DirectedEdge* getSym();
+    /** \brief
+     * Each Edge gives rise to a pair of symmetric DirectedEdges,
+     * in opposite directions.
+     *
+     * @return the DirectedEdge for the same Edge but in the
+     *         opposite direction
+     */
+    DirectedEdge* getSym();
 
-	bool isForward();
+    bool isForward();
 
-	void setSym(DirectedEdge *de);
+    void setSym(DirectedEdge* de);
 
-	DirectedEdge* getNext();
+    DirectedEdge* getNext();
 
-	void setNext(DirectedEdge *newNext);
+    void setNext(DirectedEdge* newNext);
 
-	DirectedEdge* getNextMin();
+    DirectedEdge* getNextMin();
 
-	void setNextMin(DirectedEdge *newNextMin);
+    void setNextMin(DirectedEdge* newNextMin);
 
-	/** \brief
-	 * Tells wheter this edge is a Line
-	 *
-	 * This edge is a line edge if
-	 * - at least one of the labels is a line label
-	 * - any labels which are not line labels have all Locations = EXTERIOR
-	 *
-	 */
-	bool isLineEdge();
+    /** \brief
+     * Tells wheter this edge is a Line
+     *
+     * This edge is a line edge if
+     * - at least one of the labels is a line label
+     * - any labels which are not line labels have all Locations = EXTERIOR
+     *
+     */
+    bool isLineEdge();
 
-	/** \brief
-	 * Tells wheter this edge is an Area
-	 *
-	 * This is an interior Area edge if
-	 * - its label is an Area label for both Geometries
-	 * - and for each Geometry both sides are in the interior.
-	 *
-	 * @return true if this is an interior Area edge
-	 */
-	bool isInteriorAreaEdge();
+    /** \brief
+     * Tells wheter this edge is an Area
+     *
+     * This is an interior Area edge if
+     * - its label is an Area label for both Geometries
+     * - and for each Geometry both sides are in the interior.
+     *
+     * @return true if this is an interior Area edge
+     */
+    bool isInteriorAreaEdge();
 
-	/** \brief
-	 * Set both edge depths.
-	 *
-	 * One depth for a given side is provided.
-	 * The other is computed depending on the Location transition and the
-	 * depthDelta of the edge.
-	 */
-	void setEdgeDepths(int position, int newDepth);
+    /** \brief
+     * Set both edge depths.
+     *
+     * One depth for a given side is provided.
+     * The other is computed depending on the Location transition and the
+     * depthDelta of the edge.
+     */
+    void setEdgeDepths(int position, int newDepth);
 
-	std::string print() const override;
+    std::string print() const override;
 
-	std::string printEdge();
+    std::string printEdge();
 
 protected:
 
-	bool isForwardVar;
+    bool isForwardVar;
 
 private:
 
-	bool isInResultVar;
+    bool isInResultVar;
 
-	bool isVisitedVar;
+    bool isVisitedVar;
 
-	/// the symmetric edge
-	DirectedEdge *sym;
+    /// the symmetric edge
+    DirectedEdge* sym;
 
-	/// the next edge in the edge ring for the polygon containing this edge
-	DirectedEdge *next;
+    /// the next edge in the edge ring for the polygon containing this edge
+    DirectedEdge* next;
 
-	/// the next edge in the MinimalEdgeRing that contains this edge
-	DirectedEdge *nextMin;
+    /// the next edge in the MinimalEdgeRing that contains this edge
+    DirectedEdge* nextMin;
 
-	/// the EdgeRing that this edge is part of
-	EdgeRing *edgeRing;
+    /// the EdgeRing that this edge is part of
+    EdgeRing* edgeRing;
 
-	/// the MinimalEdgeRing that this edge is part of
-	EdgeRing *minEdgeRing;
+    /// the MinimalEdgeRing that this edge is part of
+    EdgeRing* minEdgeRing;
 
-	/** \brief
-	 * The depth of each side (position) of this edge.
-	 * The 0 element of the array is never used.
-	 */
-	int depth[3];
+    /** \brief
+     * The depth of each side (position) of this edge.
+     * The 0 element of the array is never used.
+     */
+    int depth[3];
 
-	/// Compute the label in the appropriate orientation for this DirEdge
-	void computeDirectedLabel();
+    /// Compute the label in the appropriate orientation for this DirEdge
+    void computeDirectedLabel();
 };
 
 } // namespace geos.geomgraph
diff --git a/include/geos/geomgraph/DirectedEdge.inl b/include/geos/geomgraph/DirectedEdge.inl
index 3bb06b4..8ccdbd2 100644
--- a/include/geos/geomgraph/DirectedEdge.inl
+++ b/include/geos/geomgraph/DirectedEdge.inl
@@ -9,7 +9,7 @@
  *
  * This is free software; you can redistribute and/or modify it under
  * the terms of the GNU Lesser General Public Licence as published
- * by the Free Software Foundation. 
+ * by the Free Software Foundation.
  * See the COPYING file for more information.
  *
  **********************************************************************
@@ -30,52 +30,100 @@ namespace geomgraph { // geos::geomgraph
 //DirectedEdge::getEdge() { return edge; }
 
 INLINE void
-DirectedEdge::setInResult(bool v) { isInResultVar=v; }
+DirectedEdge::setInResult(bool v)
+{
+    isInResultVar = v;
+}
 
 INLINE bool
-DirectedEdge::isInResult() { return isInResultVar; }
+DirectedEdge::isInResult()
+{
+    return isInResultVar;
+}
 
 INLINE bool
-DirectedEdge::isVisited() { return isVisitedVar; }
+DirectedEdge::isVisited()
+{
+    return isVisitedVar;
+}
 
 INLINE void
-DirectedEdge::setVisited(bool v) { isVisitedVar=v; }
+DirectedEdge::setVisited(bool v)
+{
+    isVisitedVar = v;
+}
 
 INLINE void
-DirectedEdge::setEdgeRing(EdgeRing *er) { edgeRing=er; }
+DirectedEdge::setEdgeRing(EdgeRing* er)
+{
+    edgeRing = er;
+}
 
 INLINE EdgeRing*
-DirectedEdge::getEdgeRing() { return edgeRing; }
+DirectedEdge::getEdgeRing()
+{
+    return edgeRing;
+}
 
 INLINE void
-DirectedEdge::setMinEdgeRing(EdgeRing *mer) { minEdgeRing=mer; }
+DirectedEdge::setMinEdgeRing(EdgeRing* mer)
+{
+    minEdgeRing = mer;
+}
 
 INLINE EdgeRing*
-DirectedEdge::getMinEdgeRing() { return minEdgeRing; }
+DirectedEdge::getMinEdgeRing()
+{
+    return minEdgeRing;
+}
 
 INLINE int
-DirectedEdge::getDepth(int position){ return depth[position]; }
+DirectedEdge::getDepth(int position)
+{
+    return depth[position];
+}
 
 INLINE DirectedEdge*
-DirectedEdge::getSym() { return sym; }
+DirectedEdge::getSym()
+{
+    return sym;
+}
 
 INLINE bool
-DirectedEdge::isForward() { return isForwardVar; }
+DirectedEdge::isForward()
+{
+    return isForwardVar;
+}
 
 INLINE void
-DirectedEdge::setSym(DirectedEdge *de) { sym=de; }
+DirectedEdge::setSym(DirectedEdge* de)
+{
+    sym = de;
+}
 
 INLINE DirectedEdge*
-DirectedEdge::getNext() { return next; }
+DirectedEdge::getNext()
+{
+    return next;
+}
 
 INLINE void
-DirectedEdge::setNext(DirectedEdge *newNext) { next=newNext; }
+DirectedEdge::setNext(DirectedEdge* newNext)
+{
+    next = newNext;
+}
 
 INLINE DirectedEdge*
-DirectedEdge::getNextMin() { return nextMin; }
+DirectedEdge::getNextMin()
+{
+    return nextMin;
+}
 
 INLINE void
-DirectedEdge::setNextMin(DirectedEdge *nm) { nextMin=nm; }
+DirectedEdge::setNextMin(DirectedEdge* nm)
+{
+    nextMin = nm;
+}
 
 
 } // namespace geos::geomgraph
diff --git a/include/geos/geomgraph/DirectedEdgeStar.h b/include/geos/geomgraph/DirectedEdgeStar.h
index 6af6bcb..fe1acec 100644
--- a/include/geos/geomgraph/DirectedEdgeStar.h
+++ b/include/geos/geomgraph/DirectedEdgeStar.h
@@ -35,10 +35,10 @@
 
 // Forward declarations
 namespace geos {
-	namespace geomgraph {
-		class DirectedEdge;
-		class EdgeRing;
-	}
+namespace geomgraph {
+class DirectedEdge;
+class EdgeRing;
+}
 }
 
 namespace geos {
@@ -56,106 +56,111 @@ class GEOS_DLL DirectedEdgeStar: public EdgeEndStar {
 
 public:
 
-	DirectedEdgeStar()
-		:
-		EdgeEndStar(),
-		resultAreaEdgeList(nullptr),
-		label()
-	{}
-
-	~DirectedEdgeStar() override {
-		delete resultAreaEdgeList;
-	}
-
-	/// Insert a directed edge in the list
-	void insert(EdgeEnd *ee) override;
-
-	Label &getLabel() { return label; }
-
-	int getOutgoingDegree();
-
-	int getOutgoingDegree(EdgeRing *er);
-
-	DirectedEdge* getRightmostEdge();
-
-	/** \brief
-	 * Compute the labelling for all dirEdges in this star, as well
-	 * as the overall labelling
-	 */
-	void computeLabelling(std::vector<GeometryGraph*> *geom) override; // throw(TopologyException *);
-
-	/** \brief
-	 * For each dirEdge in the star,
-	 * merge the label from the sym dirEdge into the label
-	 */
-	void mergeSymLabels();
-
-	/// Update incomplete dirEdge labels from the labelling for the node
-	void updateLabelling(const Label& nodeLabel);
-
-
-	/**
-	 * Traverse the star of DirectedEdges, linking the included edges together.
-	 * To link two dirEdges, the <next> pointer for an incoming dirEdge
-	 * is set to the next outgoing edge.
-	 *
-	 * DirEdges are only linked if:
-	 *
-	 * - they belong to an area (i.e. they have sides)
-	 * - they are marked as being in the result
-	 *
-	 * Edges are linked in CCW order (the order they are stored).
-	 * This means that rings have their face on the Right
-	 * (in other words,
-	 * the topological location of the face is given by the RHS label of the DirectedEdge)
-	 *
-	 * PRECONDITION: No pair of dirEdges are both marked as being in the result
-	 */
-	void linkResultDirectedEdges(); // throw(TopologyException *);
-
-	void linkMinimalDirectedEdges(EdgeRing *er);
-
-	void linkAllDirectedEdges();
-
-	/** \brief
-	 * Traverse the star of edges, maintaing the current location in the result
-	 * area at this node (if any).
-	 *
-	 * If any L edges are found in the interior of the result, mark them as covered.
-	 */
-	void findCoveredLineEdges();
-
-	/** \brief
-	 * Compute the DirectedEdge depths for a subsequence of the edge array.
-	 *
-	 * @return the last depth assigned (from the R side of the last edge visited)
-	 */
-	void computeDepths(DirectedEdge *de);
-
-	std::string print() const override;
+    DirectedEdgeStar()
+        :
+        EdgeEndStar(),
+        resultAreaEdgeList(nullptr),
+        label()
+    {}
+
+    ~DirectedEdgeStar() override
+    {
+        delete resultAreaEdgeList;
+    }
+
+    /// Insert a directed edge in the list
+    void insert(EdgeEnd* ee) override;
+
+    Label&
+    getLabel()
+    {
+        return label;
+    }
+
+    int getOutgoingDegree();
+
+    int getOutgoingDegree(EdgeRing* er);
+
+    DirectedEdge* getRightmostEdge();
+
+    /** \brief
+     * Compute the labelling for all dirEdges in this star, as well
+     * as the overall labelling
+     */
+    void computeLabelling(std::vector<GeometryGraph*>* geom) override; // throw(TopologyException *);
+
+    /** \brief
+     * For each dirEdge in the star,
+     * merge the label from the sym dirEdge into the label
+     */
+    void mergeSymLabels();
+
+    /// Update incomplete dirEdge labels from the labelling for the node
+    void updateLabelling(const Label& nodeLabel);
+
+
+    /**
+     * Traverse the star of DirectedEdges, linking the included edges together.
+     * To link two dirEdges, the <next> pointer for an incoming dirEdge
+     * is set to the next outgoing edge.
+     *
+     * DirEdges are only linked if:
+     *
+     * - they belong to an area (i.e. they have sides)
+     * - they are marked as being in the result
+     *
+     * Edges are linked in CCW order (the order they are stored).
+     * This means that rings have their face on the Right
+     * (in other words,
+     * the topological location of the face is given by the RHS label of the DirectedEdge)
+     *
+     * PRECONDITION: No pair of dirEdges are both marked as being in the result
+     */
+    void linkResultDirectedEdges(); // throw(TopologyException *);
+
+    void linkMinimalDirectedEdges(EdgeRing* er);
+
+    void linkAllDirectedEdges();
+
+    /** \brief
+     * Traverse the star of edges, maintaing the current location in the result
+     * area at this node (if any).
+     *
+     * If any L edges are found in the interior of the result, mark them as covered.
+     */
+    void findCoveredLineEdges();
+
+    /** \brief
+     * Compute the DirectedEdge depths for a subsequence of the edge array.
+     *
+     * @return the last depth assigned (from the R side of the last edge visited)
+     */
+    void computeDepths(DirectedEdge* de);
+
+    std::string print() const override;
 
 private:
 
-	/**
-	 * A list of all outgoing edges in the result, in CCW order
-	 */
-	std::vector<DirectedEdge*> *resultAreaEdgeList;
+    /**
+     * A list of all outgoing edges in the result, in CCW order
+     */
+    std::vector<DirectedEdge*>* resultAreaEdgeList;
 
-	Label label;
+    Label label;
 
-	/// \brief
-	/// Returned vector is onwed by DirectedEdgeStar object, but
-	/// lazily created
-	std::vector<DirectedEdge*>* getResultAreaEdges();
+    /// \brief
+    /// Returned vector is onwed by DirectedEdgeStar object, but
+    /// lazily created
+    std::vector<DirectedEdge*>* getResultAreaEdges();
 
-	/// States for linResultDirectedEdges
-	enum {
-		SCANNING_FOR_INCOMING=1,
-		LINKING_TO_OUTGOING
-	};
+    /// States for linResultDirectedEdges
+    enum {
+        SCANNING_FOR_INCOMING = 1,
+        LINKING_TO_OUTGOING
+    };
 
-	int computeDepths(EdgeEndStar::iterator startIt,
-		EdgeEndStar::iterator endIt, int startDepth);
+    int computeDepths(EdgeEndStar::iterator startIt,
+                      EdgeEndStar::iterator endIt, int startDepth);
 };
 
 
diff --git a/include/geos/geomgraph/Edge.h b/include/geos/geomgraph/Edge.h
index 6067c7e..e91a9ba 100644
--- a/include/geos/geomgraph/Edge.h
+++ b/include/geos/geomgraph/Edge.h
@@ -40,211 +40,245 @@
 
 // Forward declarations
 namespace geos {
-	namespace geom {
-		class Envelope;
-		class IntersectionMatrix;
-		class Coordinate;
-	}
-	namespace algorithm {
-		class LineIntersector;
-	}
-	namespace geomgraph {
-		class Node;
-		class EdgeEndStar;
-		class Label;
-		class NodeFactory;
-		namespace index {
-			class MonotoneChainEdge;
-		}
-	}
+namespace geom {
+class Envelope;
+class IntersectionMatrix;
+class Coordinate;
+}
+namespace algorithm {
+class LineIntersector;
+}
+namespace geomgraph {
+class Node;
+class EdgeEndStar;
+class Label;
+class NodeFactory;
+namespace index {
+class MonotoneChainEdge;
+}
+}
 }
 
 namespace geos {
 namespace geomgraph { // geos.geomgraph
 
 /** The edge component of a geometry graph */
-class GEOS_DLL Edge: public GraphComponent{
-using GraphComponent::updateIM;
+class GEOS_DLL Edge: public GraphComponent {
+    using GraphComponent::updateIM;
 
 private:
 
-	std::string name;
+    std::string name;
 
-	/// Lazily-created, owned by Edge.
-	index::MonotoneChainEdge *mce;
+    /// Lazily-created, owned by Edge.
+    index::MonotoneChainEdge* mce;
 
-	/// Lazily-created, owned by Edge.
-	geom::Envelope *env;
+    /// Lazily-created, owned by Edge.
+    geom::Envelope* env;
 
-	bool isIsolatedVar;
+    bool isIsolatedVar;
 
-	Depth depth;
+    Depth depth;
 
-	int depthDelta;   // the change in area depth from the R to L side of this edge
+    int depthDelta;   // the change in area depth from the R to L side of this edge
 
 public:
 
-	void testInvariant() const {
-		assert(pts);
-		assert(pts->size() > 1);
-	}
-
-
-	friend std::ostream& operator<< (std::ostream& os, const Edge& el);
-
-	static void updateIM(const Label& lbl, geom::IntersectionMatrix& im);
-
-	/// Externally-set, owned by Edge. FIXME: refuse ownership
-	geom::CoordinateSequence* pts;
-
-	EdgeIntersectionList eiList;
-
-	//Edge();
-
-	/// Takes ownership of CoordinateSequence
-	Edge(geom::CoordinateSequence* newPts, const Label& newLabel);
-
-	/// Takes ownership of CoordinateSequence
-	Edge(geom::CoordinateSequence* newPts);
-
-	~Edge() override;
-
-	virtual size_t getNumPoints() const {
-		return pts->getSize();
-	}
-
-	virtual void setName(const std::string &newName) {
-		name=newName;
-	}
-
-	virtual const geom::CoordinateSequence* getCoordinates() const {
-		testInvariant();
-		return pts;
-	}
-
-	virtual const geom::Coordinate& getCoordinate(size_t i) const {
-		testInvariant();
-		return pts->getAt(i);
-	}
-
-	virtual const geom::Coordinate& getCoordinate() const {
-		testInvariant();
-		return pts->getAt(0);
-	}
-
-
-	virtual Depth &getDepth() {
-		testInvariant();
-		return depth;
-	}
-
-	/** \brief
-	 * The depthDelta is the change in depth as an edge is crossed from R to L
-	 *
-	 * @return the change in depth as the edge is crossed from R to L
-	 */
-	virtual int getDepthDelta() const {
-		testInvariant();
-		return depthDelta;
-	}
-
-	virtual void setDepthDelta(int newDepthDelta) {
-		depthDelta=newDepthDelta;
-		testInvariant();
-	}
-
-	virtual size_t getMaximumSegmentIndex() const {
-		testInvariant();
-		return getNumPoints()-1;
-	}
-
-	virtual EdgeIntersectionList& getEdgeIntersectionList() {
-		testInvariant();
-		return eiList;
-	}
-
-	/// \brief
-	/// Return this Edge's index::MonotoneChainEdge,
-	/// ownership is retained by this object.
-	///
-	virtual index::MonotoneChainEdge* getMonotoneChainEdge();
-
-	virtual bool isClosed() const {
-		testInvariant();
-		return pts->getAt(0)==pts->getAt(getNumPoints()-1);
-	}
-
-	/** \brief
-	 * An Edge is collapsed if it is an Area edge and it consists of
-	 * two segments which are equal and opposite (eg a zero-width V).
-	 */
-	virtual bool isCollapsed() const;
-
-	virtual Edge* getCollapsedEdge();
-
-	virtual void setIsolated(bool newIsIsolated) {
-		isIsolatedVar=newIsIsolated;
-		testInvariant();
-	}
-
-	bool isIsolated() const override {
-		testInvariant();
-		return isIsolatedVar;
-	}
-
-	/** \brief
-	 * Adds EdgeIntersections for one or both
-	 * intersections found for a segment of an edge to the edge intersection list.
-	 */
-	virtual void addIntersections(algorithm::LineIntersector *li, size_t segmentIndex,
-		size_t geomIndex);
-
-	/// Add an EdgeIntersection for intersection intIndex.
-	//
-	/// An intersection that falls exactly on a vertex of the edge is normalized
-	/// to use the higher of the two possible segmentIndexes
-	///
-	virtual void addIntersection(algorithm::LineIntersector *li, size_t segmentIndex,
-		size_t geomIndex, size_t intIndex);
-
-	/// Update the IM with the contribution for this component.
-	//
-	/// A component only contributes if it has a labelling for both
-	/// parent geometries
-	///
-	void computeIM(geom::IntersectionMatrix& im) override {
-		updateIM(label, im);
-		testInvariant();
-	}
-
-	/// return true if the coordinate sequences of the Edges are identical
-	virtual bool isPointwiseEqual(const Edge *e) const;
-
-	virtual std::string print() const;
-
-	virtual std::string printReverse() const;
-
-	/**
-	 * equals is defined to be:
-	 *
-	 * e1 equals e2
-	 * <b>iff</b>
-	 * the coordinates of e1 are the same or the reverse of the coordinates in e2
-	 */
-	virtual bool equals(const Edge& e) const;
-
-	virtual bool equals(const Edge* e) const {
-		assert(e);
-		return equals(*e);
-	}
-
-	virtual geom::Envelope* getEnvelope();
+    void
+    testInvariant() const
+    {
+        assert(pts);
+        assert(pts->size() > 1);
+    }
+
+
+    friend std::ostream& operator<< (std::ostream& os, const Edge& el);
+
+    static void updateIM(const Label& lbl, geom::IntersectionMatrix& im);
+
+    /// Externally-set, owned by Edge. FIXME: refuse ownership
+    geom::CoordinateSequence* pts;
+
+    EdgeIntersectionList eiList;
+
+    //Edge();
+
+    /// Takes ownership of CoordinateSequence
+    Edge(geom::CoordinateSequence* newPts, const Label& newLabel);
+
+    /// Takes ownership of CoordinateSequence
+    Edge(geom::CoordinateSequence* newPts);
+
+    ~Edge() override;
+
+    virtual size_t
+    getNumPoints() const
+    {
+        return pts->getSize();
+    }
+
+    virtual void
+    setName(const std::string& newName)
+    {
+        name = newName;
+    }
+
+    virtual const geom::CoordinateSequence*
+    getCoordinates() const
+    {
+        testInvariant();
+        return pts;
+    }
+
+    virtual const geom::Coordinate&
+    getCoordinate(size_t i) const
+    {
+        testInvariant();
+        return pts->getAt(i);
+    }
+
+    virtual const geom::Coordinate&
+    getCoordinate() const
+    {
+        testInvariant();
+        return pts->getAt(0);
+    }
+
+
+    virtual Depth&
+    getDepth()
+    {
+        testInvariant();
+        return depth;
+    }
+
+    /** \brief
+     * The depthDelta is the change in depth as an edge is crossed from R to L
+     *
+     * @return the change in depth as the edge is crossed from R to L
+     */
+    virtual int
+    getDepthDelta() const
+    {
+        testInvariant();
+        return depthDelta;
+    }
+
+    virtual void
+    setDepthDelta(int newDepthDelta)
+    {
+        depthDelta = newDepthDelta;
+        testInvariant();
+    }
+
+    virtual size_t
+    getMaximumSegmentIndex() const
+    {
+        testInvariant();
+        return getNumPoints() - 1;
+    }
+
+    virtual EdgeIntersectionList&
+    getEdgeIntersectionList()
+    {
+        testInvariant();
+        return eiList;
+    }
+
+    /// \brief
+    /// Return this Edge's index::MonotoneChainEdge,
+    /// ownership is retained by this object.
+    ///
+    virtual index::MonotoneChainEdge* getMonotoneChainEdge();
+
+    virtual bool
+    isClosed() const
+    {
+        testInvariant();
+        return pts->getAt(0) == pts->getAt(getNumPoints() - 1);
+    }
+
+    /** \brief
+     * An Edge is collapsed if it is an Area edge and it consists of
+     * two segments which are equal and opposite (eg a zero-width V).
+     */
+    virtual bool isCollapsed() const;
+
+    virtual Edge* getCollapsedEdge();
+
+    virtual void
+    setIsolated(bool newIsIsolated)
+    {
+        isIsolatedVar = newIsIsolated;
+        testInvariant();
+    }
+
+    bool
+    isIsolated() const override
+    {
+        testInvariant();
+        return isIsolatedVar;
+    }
+
+    /** \brief
+     * Adds EdgeIntersections for one or both
+     * intersections found for a segment of an edge to the edge intersection list.
+     */
+    virtual void addIntersections(algorithm::LineIntersector* li, size_t segmentIndex,
+                                  size_t geomIndex);
+
+    /// Add an EdgeIntersection for intersection intIndex.
+    //
+    /// An intersection that falls exactly on a vertex of the edge is normalized
+    /// to use the higher of the two possible segmentIndexes
+    ///
+    virtual void addIntersection(algorithm::LineIntersector* li, size_t segmentIndex,
+                                 size_t geomIndex, size_t intIndex);
+
+    /// Update the IM with the contribution for this component.
+    //
+    /// A component only contributes if it has a labelling for both
+    /// parent geometries
+    ///
+    void
+    computeIM(geom::IntersectionMatrix& im) override
+    {
+        updateIM(label, im);
+        testInvariant();
+    }
+
+    /// return true if the coordinate sequences of the Edges are identical
+    virtual bool isPointwiseEqual(const Edge* e) const;
+
+    virtual std::string print() const;
+
+    virtual std::string printReverse() const;
+
+    /**
+     * equals is defined to be:
+     *
+     * e1 equals e2
+     * <b>iff</b>
+     * the coordinates of e1 are the same or the reverse of the coordinates in e2
+     */
+    virtual bool equals(const Edge& e) const;
+
+    virtual bool
+    equals(const Edge* e) const
+    {
+        assert(e);
+        return equals(*e);
+    }
+
+    virtual geom::Envelope* getEnvelope();
 };
 
 
 //Operators
-inline bool operator==(const Edge &a, const Edge &b) {
-	return a.equals(b);
+inline bool
+operator==(const Edge& a, const Edge& b)
+{
+    return a.equals(b);
 }
 
 std::ostream& operator<< (std::ostream& os, const Edge& el);
diff --git a/include/geos/geomgraph/EdgeEnd.h b/include/geos/geomgraph/EdgeEnd.h
index 30344a2..af6e196 100644
--- a/include/geos/geomgraph/EdgeEnd.h
+++ b/include/geos/geomgraph/EdgeEnd.h
@@ -31,13 +31,13 @@
 
 // Forward declarations
 namespace geos {
-	namespace algorithm {
-		class BoundaryNodeRule;
-	}
-	namespace geomgraph {
-		class Edge;
-		class Node;
-	}
+namespace algorithm {
+class BoundaryNodeRule;
+}
+namespace geomgraph {
+class Edge;
+class Node;
+}
 }
 
 namespace geos {
@@ -57,110 +57,129 @@ class GEOS_DLL EdgeEnd {
 
 public:
 
-	friend std::ostream& operator<< (std::ostream&, const EdgeEnd&);
-
-	EdgeEnd();
-
-	virtual ~EdgeEnd() {}
-
-	/**
-	 * NOTES:
-	 *  - Copies the given Label
-	 *  - keeps a pointer to given Edge, make sure it's
-	 *    not deleted before the EdgeEnd.
-	 *  - copies given Coordinates (maybe we should avoid that)
-	 */
-	EdgeEnd(Edge* newEdge, const geom::Coordinate& newP0,
-			const geom::Coordinate& newP1,
-			const Label& newLabel);
-
-	/**
-	 * NOTES:
-	 *  - keeps a pointer to given Edge, make sure it's
-	 *    not deleted before the EdgeEnd.
-	 *  - copies given Coordinates (maybe we should avoid that)
-	 */
-	EdgeEnd(Edge* newEdge, const geom::Coordinate& newP0,
-			const geom::Coordinate& newP1);
-
-	Edge* getEdge() { return edge; }
-	//virtual Edge* getEdge() { return edge; }
-
-	Label& getLabel() { return label; }
-
-	const Label& getLabel() const { return label; }
-
-	virtual geom::Coordinate& getCoordinate();
-
-	const geom::Coordinate& getCoordinate() const { return p0; }
-
-	virtual geom::Coordinate& getDirectedCoordinate();
-
-	virtual int getQuadrant();
-
-	virtual double getDx();
-
-	virtual double getDy();
-
-	virtual void setNode(Node* newNode);
-
-	virtual Node* getNode();
-
-	virtual int compareTo(const EdgeEnd *e) const;
-
-	/**
-	 * Implements the total order relation:
-	 *
-	 *    a has a greater angle with the positive x-axis than b
-	 *
-	 * Using the obvious algorithm of simply computing the angle
-	 * is not robust, since the angle calculation is obviously
-	 * susceptible to roundoff.
-	 * A robust algorithm is:
-	 * - first compare the quadrant.  If the quadrants
-	 *   are different, it it trivial to determine which vector
-	 *   is "greater".
-	 * - if the vectors lie in the same quadrant, the
-	 *   computeOrientation function can be used to decide
-	 *   the relative orientation of the vectors.
-	 */
-	virtual int compareDirection(const EdgeEnd *e) const;
-
-	virtual void computeLabel(const algorithm::BoundaryNodeRule& bnr);
-
-	virtual std::string print() const;
+    friend std::ostream& operator<< (std::ostream&, const EdgeEnd&);
+
+    EdgeEnd();
+
+    virtual
+    ~EdgeEnd() {}
+
+    /**
+     * NOTES:
+     *  - Copies the given Label
+     *  - keeps a pointer to given Edge, make sure it's
+     *    not deleted before the EdgeEnd.
+     *  - copies given Coordinates (maybe we should avoid that)
+     */
+    EdgeEnd(Edge* newEdge, const geom::Coordinate& newP0,
+            const geom::Coordinate& newP1,
+            const Label& newLabel);
+
+    /**
+     * NOTES:
+     *  - keeps a pointer to given Edge, make sure it's
+     *    not deleted before the EdgeEnd.
+     *  - copies given Coordinates (maybe we should avoid that)
+     */
+    EdgeEnd(Edge* newEdge, const geom::Coordinate& newP0,
+            const geom::Coordinate& newP1);
+
+    Edge*
+    getEdge()
+    {
+        return edge;
+    }
+    //virtual Edge* getEdge() { return edge; }
+
+    Label&
+    getLabel()
+    {
+        return label;
+    }
+
+    const Label&
+    getLabel() const
+    {
+        return label;
+    }
+
+    virtual geom::Coordinate& getCoordinate();
+
+    const geom::Coordinate&
+    getCoordinate() const
+    {
+        return p0;
+    }
+
+    virtual geom::Coordinate& getDirectedCoordinate();
+
+    virtual int getQuadrant();
+
+    virtual double getDx();
+
+    virtual double getDy();
+
+    virtual void setNode(Node* newNode);
+
+    virtual Node* getNode();
+
+    virtual int compareTo(const EdgeEnd* e) const;
+
+    /**
+     * Implements the total order relation:
+     *
+     *    a has a greater angle with the positive x-axis than b
+     *
+     * Using the obvious algorithm of simply computing the angle
+     * is not robust, since the angle calculation is obviously
+     * susceptible to roundoff.
+     * A robust algorithm is:
+     * - first compare the quadrant.  If the quadrants
+     *   are different, it it trivial to determine which vector
+     *   is "greater".
+     * - if the vectors lie in the same quadrant, the
+     *   computeOrientation function can be used to decide
+     *   the relative orientation of the vectors.
+     */
+    virtual int compareDirection(const EdgeEnd* e) const;
+
+    virtual void computeLabel(const algorithm::BoundaryNodeRule& bnr);
+
+    virtual std::string print() const;
 
 protected:
 
-	Edge* edge;// the parent edge of this edge end
+    Edge* edge;// the parent edge of this edge end
 
-	Label label;
+    Label label;
 
-	EdgeEnd(Edge* newEdge);
+    EdgeEnd(Edge* newEdge);
 
-	virtual void init(const geom::Coordinate& newP0,
-			const geom::Coordinate& newP1);
+    virtual void init(const geom::Coordinate& newP0,
+                      const geom::Coordinate& newP1);
 
 private:
 
-	/// the node this edge end originates at
-	Node* node;
+    /// the node this edge end originates at
+    Node* node;
 
-	/// points of initial line segment. FIXME: do we need a copy here ?
-	geom::Coordinate p0, p1;
+    /// points of initial line segment. FIXME: do we need a copy here ?
+    geom::Coordinate p0, p1;
 
-	/// the direction vector for this edge from its starting point
-	double dx, dy;
+    /// the direction vector for this edge from its starting point
+    double dx, dy;
 
-	int quadrant;
+    int quadrant;
 };
 
 std::ostream& operator<< (std::ostream&, const EdgeEnd&);
 
 struct GEOS_DLL  EdgeEndLT {
-	bool operator()(const EdgeEnd *s1, const EdgeEnd *s2) const {
-		return s1->compareTo(s2)<0;
-	}
+    bool
+    operator()(const EdgeEnd* s1, const EdgeEnd* s2) const
+    {
+        return s1->compareTo(s2) < 0;
+    }
 };
 
 } // namespace geos.geomgraph
diff --git a/include/geos/geomgraph/EdgeEndStar.h b/include/geos/geomgraph/EdgeEndStar.h
index 1763efc..e376fe6 100644
--- a/include/geos/geomgraph/EdgeEndStar.h
+++ b/include/geos/geomgraph/EdgeEndStar.h
@@ -40,12 +40,12 @@
 
 // Forward declarations
 namespace geos {
-	namespace algorithm {
-		class BoundaryNodeRule;
-	}
-	namespace geomgraph {
-		class GeometryGraph;
-	}
+namespace algorithm {
+class BoundaryNodeRule;
+}
+namespace geomgraph {
+class GeometryGraph;
+}
 }
 
 namespace geos {
@@ -63,134 +63,147 @@ namespace geomgraph { // geos.geomgraph
 class GEOS_DLL EdgeEndStar {
 public:
 
-	typedef std::set<EdgeEnd *, EdgeEndLT> container;
+    typedef std::set<EdgeEnd*, EdgeEndLT> container;
 
-	typedef container::iterator iterator;
-	typedef container::const_iterator const_iterator;
-	typedef container::reverse_iterator reverse_iterator;
+    typedef container::iterator iterator;
+    typedef container::const_iterator const_iterator;
+    typedef container::reverse_iterator reverse_iterator;
 
-	EdgeEndStar();
+    EdgeEndStar();
 
-	virtual ~EdgeEndStar() {}
+    virtual
+    ~EdgeEndStar() {}
 
-	/** \brief
-	 * Insert a EdgeEnd into this EdgeEndStar
-	 */
-	virtual void insert(EdgeEnd *e)=0;
+    /** \brief
+     * Insert a EdgeEnd into this EdgeEndStar
+     */
+    virtual void insert(EdgeEnd* e) = 0;
 
-	/** \brief
-	 * @return the coordinate for the node this star is based at
-	 *         or NULL if this is still an unbound star.
-	 * Be aware that the returned pointer will point to
-	 * a Coordinate owned by the specific EdgeEnd happening
-	 * to be the first in the star (ordered CCW)
-	 */
-	virtual geom::Coordinate& getCoordinate();
+    /** \brief
+     * @return the coordinate for the node this star is based at
+     *         or NULL if this is still an unbound star.
+     * Be aware that the returned pointer will point to
+     * a Coordinate owned by the specific EdgeEnd happening
+     * to be the first in the star (ordered CCW)
+     */
+    virtual geom::Coordinate& getCoordinate();
 
-	const geom::Coordinate& getCoordinate() const;
+    const geom::Coordinate& getCoordinate() const;
 
-	virtual std::size_t getDegree();
+    virtual std::size_t getDegree();
 
-	virtual iterator begin();
+    virtual iterator begin();
 
-	virtual iterator end();
+    virtual iterator end();
 
-	virtual reverse_iterator rbegin();
+    virtual reverse_iterator rbegin();
 
-	virtual reverse_iterator rend();
+    virtual reverse_iterator rend();
 
-	virtual const_iterator begin() const { return edgeMap.begin(); }
+    virtual const_iterator
+    begin() const
+    {
+        return edgeMap.begin();
+    }
 
-	virtual const_iterator end() const { return edgeMap.end(); }
+    virtual const_iterator
+    end() const
+    {
+        return edgeMap.end();
+    }
 
-	virtual container &getEdges();
+    virtual container& getEdges();
 
-	virtual EdgeEnd* getNextCW(EdgeEnd *ee);
+    virtual EdgeEnd* getNextCW(EdgeEnd* ee);
 
-	virtual void computeLabelling(std::vector<GeometryGraph*> *geomGraph);
-		// throw(TopologyException *);
+    virtual void computeLabelling(std::vector<GeometryGraph*>* geomGraph);
+    // throw(TopologyException *);
 
-	virtual bool isAreaLabelsConsistent(const GeometryGraph& geomGraph);
+    virtual bool isAreaLabelsConsistent(const GeometryGraph& geomGraph);
 
-	virtual void propagateSideLabels(int geomIndex);
-		// throw(TopologyException *);
+    virtual void propagateSideLabels(int geomIndex);
+    // throw(TopologyException *);
 
-	//virtual int findIndex(EdgeEnd *eSearch);
-	virtual iterator find(EdgeEnd *eSearch);
+    //virtual int findIndex(EdgeEnd *eSearch);
+    virtual iterator find(EdgeEnd* eSearch);
 
-	virtual std::string print() const;
+    virtual std::string print() const;
 
 protected:
 
-	/** \brief
-	 * A map which maintains the edges in sorted order
-	 * around the node
-	 */
-	EdgeEndStar::container edgeMap;
-
-	/** \brief
-	 * Insert an EdgeEnd into the map.
-	 */
-	virtual void insertEdgeEnd(EdgeEnd *e) { edgeMap.insert(e); }
+    /** \brief
+     * A map which maintains the edges in sorted order
+     * around the node
+     */
+    EdgeEndStar::container edgeMap;
+
+    /** \brief
+     * Insert an EdgeEnd into the map.
+     */
+    virtual void
+    insertEdgeEnd(EdgeEnd* e)
+    {
+        edgeMap.insert(e);
+    }
 
 private:
 
-	virtual int getLocation(int geomIndex,
-		const geom::Coordinate& p,
-		std::vector<GeometryGraph*> *geom);
+    virtual int getLocation(int geomIndex,
+                            const geom::Coordinate& p,
+                            std::vector<GeometryGraph*>* geom);
 
-	/** \brief
-	 * The location of the point for this star in
-	 * Geometry i Areas
-	 */
-	int ptInAreaLocation[2];
+    /** \brief
+     * The location of the point for this star in
+     * Geometry i Areas
+     */
+    int ptInAreaLocation[2];
 
-	virtual void computeEdgeEndLabels(const algorithm::BoundaryNodeRule&);
+    virtual void computeEdgeEndLabels(const algorithm::BoundaryNodeRule&);
 
-	virtual bool checkAreaLabelsConsistent(int geomIndex);
+    virtual bool checkAreaLabelsConsistent(int geomIndex);
 
 };
 
 inline std::size_t
 EdgeEndStar::getDegree()
 {
-	return edgeMap.size();
+    return edgeMap.size();
 }
 
 inline EdgeEndStar::iterator
 EdgeEndStar::begin()
 {
-	return edgeMap.begin();
+    return edgeMap.begin();
 }
 
 inline EdgeEndStar::container&
 EdgeEndStar::getEdges()
 {
-	return edgeMap;
+    return edgeMap;
 }
 
 inline EdgeEndStar::reverse_iterator
 EdgeEndStar::rend()
 {
-	return edgeMap.rend();
+    return edgeMap.rend();
 }
 
 inline EdgeEndStar::iterator
 EdgeEndStar::end()
 {
-	return edgeMap.end();
+    return edgeMap.end();
 }
 
 inline EdgeEndStar::reverse_iterator
 EdgeEndStar::rbegin()
 {
-	return edgeMap.rbegin();
+    return edgeMap.rbegin();
 }
 
 inline EdgeEndStar::iterator
-EdgeEndStar::find(EdgeEnd *eSearch)
+EdgeEndStar::find(EdgeEnd* eSearch)
 {
-	return edgeMap.find(eSearch);
+    return edgeMap.find(eSearch);
 }
 
 std::ostream& operator<< (std::ostream&, const EdgeEndStar&);
diff --git a/include/geos/geomgraph/EdgeIntersection.h b/include/geos/geomgraph/EdgeIntersection.h
index cc522f1..61aa498 100644
--- a/include/geos/geomgraph/EdgeIntersection.h
+++ b/include/geos/geomgraph/EdgeIntersection.h
@@ -45,70 +45,92 @@ namespace geomgraph { // geos.geomgraph
 class GEOS_DLL EdgeIntersection {
 public:
 
-	// the point of intersection
-	geom::Coordinate coord;
+    // the point of intersection
+    geom::Coordinate coord;
 
-	// the edge distance of this point along the containing line segment
-	double dist;
+    // the edge distance of this point along the containing line segment
+    double dist;
 
-	// the index of the containing line segment in the parent edge
-	size_t segmentIndex;
+    // the index of the containing line segment in the parent edge
+    size_t segmentIndex;
 
-	EdgeIntersection(const geom::Coordinate& newCoord,
-	                 size_t newSegmentIndex, double newDist)
-	  :
-	  coord(newCoord),
-	  dist(newDist),
-	  segmentIndex(newSegmentIndex)
-	{}
+    EdgeIntersection(const geom::Coordinate& newCoord,
+                     size_t newSegmentIndex, double newDist)
+        :
+        coord(newCoord),
+        dist(newDist),
+        segmentIndex(newSegmentIndex)
+    {}
 
-	bool isEndPoint(size_t maxSegmentIndex) const {
-	  if (segmentIndex==0 && dist==0.0) return true;
-	  if (segmentIndex==maxSegmentIndex) return true;
-	  return false;
-	}
+    bool
+    isEndPoint(size_t maxSegmentIndex) const
+    {
+        if(segmentIndex == 0 && dist == 0.0) {
+            return true;
+        }
+        if(segmentIndex == maxSegmentIndex) {
+            return true;
+        }
+        return false;
+    }
 
-	const geom::Coordinate& getCoordinate() const {
-		return coord;
-	}
+    const geom::Coordinate&
+    getCoordinate() const
+    {
+        return coord;
+    }
 
-	size_t getSegmentIndex() const { return segmentIndex; }
+    size_t
+    getSegmentIndex() const
+    {
+        return segmentIndex;
+    }
 
-	double getDistance() const { return dist; }
+    double
+    getDistance() const
+    {
+        return dist;
+    }
 
 };
 
 /// Strict weak ordering operator for EdgeIntersection
 //
 /// This is the C++ equivalent of JTS's compareTo
-inline bool operator< (const EdgeIntersection& ei1, const EdgeIntersection& ei2)
+inline bool
+operator< (const EdgeIntersection& ei1, const EdgeIntersection& ei2)
 {
-		if ( ei1.segmentIndex < ei2.segmentIndex ) return true;
-		if ( ei1.segmentIndex == ei2.segmentIndex )
-    {
-      if ( ei1.dist < ei2.dist ) return true;
-
-      // TODO: check if the Coordinate matches, or this will
-      //       be a robustness issue in computin distance
-      //       See http://trac.osgeo.org/geos/ticket/350
+    if(ei1.segmentIndex < ei2.segmentIndex) {
+        return true;
     }
-		return false;
+    if(ei1.segmentIndex == ei2.segmentIndex) {
+        if(ei1.dist < ei2.dist) {
+            return true;
+        }
+
+        // TODO: check if the Coordinate matches, or this will
+        //       be a robustness issue in computin distance
+        //       See http://trac.osgeo.org/geos/ticket/350
+    }
+    return false;
 }
 
 // @deprecated, use strict weak ordering operator
 struct GEOS_DLL  EdgeIntersectionLessThen {
-	bool operator()(const EdgeIntersection *ei1,
-		const EdgeIntersection *ei2) const
-	{
-    return *ei1 < *ei2;
-	}
+    bool
+    operator()(const EdgeIntersection* ei1,
+               const EdgeIntersection* ei2) const
+    {
+        return *ei1 < *ei2;
+    }
 };
 
 /// Output operator
-inline std::ostream& operator<< (std::ostream& os, const EdgeIntersection& e)
+inline std::ostream&
+operator<< (std::ostream& os, const EdgeIntersection& e)
 {
-  os << e.coord << " seg # = " << e.segmentIndex << " dist = " << e.dist;
-	return os;
+    os << e.coord << " seg # = " << e.segmentIndex << " dist = " << e.dist;
+    return os;
 }
 
 } // namespace geos.geomgraph
diff --git a/include/geos/geomgraph/EdgeIntersectionList.h b/include/geos/geomgraph/EdgeIntersectionList.h
index 212f8ad..37a8c83 100644
--- a/include/geos/geomgraph/EdgeIntersectionList.h
+++ b/include/geos/geomgraph/EdgeIntersectionList.h
@@ -39,12 +39,12 @@
 
 // Forward declarations
 namespace geos {
-	namespace geom {
-		class Coordinate;
-	}
-	namespace geomgraph {
-		class Edge;
-	}
+namespace geom {
+class Coordinate;
+}
+namespace geomgraph {
+class Edge;
+}
 }
 
 namespace geos {
@@ -56,54 +56,70 @@ namespace geomgraph { // geos.geomgraph
  * Implements splitting an edge with intersections
  * into multiple resultant edges.
  */
-class GEOS_DLL EdgeIntersectionList{
+class GEOS_DLL EdgeIntersectionList {
 public:
-	typedef std::set<EdgeIntersection *, EdgeIntersectionLessThen> container;
-	typedef container::iterator iterator;
-	typedef container::const_iterator const_iterator;
+    typedef std::set<EdgeIntersection*, EdgeIntersectionLessThen> container;
+    typedef container::iterator iterator;
+    typedef container::const_iterator const_iterator;
 
 private:
-	container nodeMap;
+    container nodeMap;
 
 public:
 
-	Edge *edge;
-	EdgeIntersectionList(Edge *edge);
-	~EdgeIntersectionList();
-
-	/*
-	 * Adds an intersection into the list, if it isn't already there.
-	 * The input segmentIndex and dist are expected to be normalized.
-	 * @return the EdgeIntersection found or added
-	 */
-	EdgeIntersection* add(const geom::Coordinate& coord,
-		size_t segmentIndex, double dist);
-
-	iterator begin() { return nodeMap.begin(); }
-	iterator end() { return nodeMap.end(); }
-	const_iterator begin() const { return nodeMap.begin(); }
-	const_iterator end() const { return nodeMap.end(); }
-
-	bool isEmpty() const;
-	bool isIntersection(const geom::Coordinate& pt) const;
-
-	/*
-	 * Adds entries for the first and last points of the edge to the list
-	 */
-	void addEndpoints();
-
-	/**
-	 * Creates new edges for all the edges that the intersections in this
-	 * list split the parent edge into.
-	 * Adds the edges to the input list (this is so a single list
-	 * can be used to accumulate all split edges for a Geometry).
-	 *
-	 * @param edgeList a list of EdgeIntersections
-	 */
-	void addSplitEdges(std::vector<Edge*> *edgeList);
-
-	Edge *createSplitEdge(EdgeIntersection *ei0, EdgeIntersection *ei1);
-	std::string print() const;
+    Edge* edge;
+    EdgeIntersectionList(Edge* edge);
+    ~EdgeIntersectionList();
+
+    /*
+     * Adds an intersection into the list, if it isn't already there.
+     * The input segmentIndex and dist are expected to be normalized.
+     * @return the EdgeIntersection found or added
+     */
+    EdgeIntersection* add(const geom::Coordinate& coord,
+                          size_t segmentIndex, double dist);
+
+    iterator
+    begin()
+    {
+        return nodeMap.begin();
+    }
+    iterator
+    end()
+    {
+        return nodeMap.end();
+    }
+    const_iterator
+    begin() const
+    {
+        return nodeMap.begin();
+    }
+    const_iterator
+    end() const
+    {
+        return nodeMap.end();
+    }
+
+    bool isEmpty() const;
+    bool isIntersection(const geom::Coordinate& pt) const;
+
+    /*
+     * Adds entries for the first and last points of the edge to the list
+     */
+    void addEndpoints();
+
+    /**
+     * Creates new edges for all the edges that the intersections in this
+     * list split the parent edge into.
+     * Adds the edges to the input list (this is so a single list
+     * can be used to accumulate all split edges for a Geometry).
+     *
+     * @param edgeList a list of EdgeIntersections
+     */
+    void addSplitEdges(std::vector<Edge*>* edgeList);
+
+    Edge* createSplitEdge(EdgeIntersection* ei0, EdgeIntersection* ei1);
+    std::string print() const;
 
 };
 
diff --git a/include/geos/geomgraph/EdgeList.h b/include/geos/geomgraph/EdgeList.h
index 526773a..8b4ca0e 100644
--- a/include/geos/geomgraph/EdgeList.h
+++ b/include/geos/geomgraph/EdgeList.h
@@ -38,12 +38,12 @@
 
 // Forward declarations
 namespace geos {
-	namespace index {
-		class SpatialIndex;
-	}
-	namespace geomgraph {
-		class Edge;
-	}
+namespace index {
+class SpatialIndex;
+}
+namespace geomgraph {
+class Edge;
+}
 }
 
 namespace geos {
@@ -59,57 +59,62 @@ class GEOS_DLL EdgeList {
 
 private:
 
-	std::vector<Edge*> edges;
-
-	struct OcaCmp {
-		bool operator()(
-			const noding::OrientedCoordinateArray *oca1,
-			const noding::OrientedCoordinateArray *oca2) const
-		{
-			return *oca1 < *oca2;
-		}
-	};
-
-	/**
-	 * An index of the edges, for fast lookup.
-	 *
-	 * OrientedCoordinateArray objects are owned by us.
-	 * TODO: optimize by dropping the OrientedCoordinateArray
-	 *       construction as a whole, and use CoordinateSequence
-	 *       directly instead..
-	 */
-	typedef std::map<noding::OrientedCoordinateArray*, Edge*, OcaCmp> EdgeMap;
-	EdgeMap ocaMap;
+    std::vector<Edge*> edges;
+
+    struct OcaCmp {
+        bool
+        operator()(
+            const noding::OrientedCoordinateArray* oca1,
+            const noding::OrientedCoordinateArray* oca2) const
+        {
+            return *oca1 < *oca2;
+        }
+    };
+
+    /**
+     * An index of the edges, for fast lookup.
+     *
+     * OrientedCoordinateArray objects are owned by us.
+     * TODO: optimize by dropping the OrientedCoordinateArray
+     *       construction as a whole, and use CoordinateSequence
+     *       directly instead..
+     */
+    typedef std::map<noding::OrientedCoordinateArray*, Edge*, OcaCmp> EdgeMap;
+    EdgeMap ocaMap;
 
 public:
-	friend std::ostream& operator<< (std::ostream& os, const EdgeList& el);
+    friend std::ostream& operator<< (std::ostream& os, const EdgeList& el);
 
-	EdgeList()
-		:
-		edges(),
-		ocaMap()
-	{}
+    EdgeList()
+        :
+        edges(),
+        ocaMap()
+    {}
 
-	virtual ~EdgeList();
+    virtual ~EdgeList();
 
-	/**
-	 * Insert an edge unless it is already in the list
-	 */
-	void add(Edge *e);
+    /**
+     * Insert an edge unless it is already in the list
+     */
+    void add(Edge* e);
 
-	void addAll(const std::vector<Edge*> &edgeColl);
+    void addAll(const std::vector<Edge*>& edgeColl);
 
-	std::vector<Edge*> &getEdges() { return edges; }
+    std::vector<Edge*>&
+    getEdges()
+    {
+        return edges;
+    }
 
-	Edge* findEqualEdge(Edge* e);
+    Edge* findEqualEdge(Edge* e);
 
-	Edge* get(int i);
+    Edge* get(int i);
 
-	int findEdgeIndex(Edge *e);
+    int findEdgeIndex(Edge* e);
 
-	std::string print();
+    std::string print();
 
-        void clearList();
+    void clearList();
 
 };
 
diff --git a/include/geos/geomgraph/EdgeNodingValidator.h b/include/geos/geomgraph/EdgeNodingValidator.h
index a8fa391..a8f0118 100644
--- a/include/geos/geomgraph/EdgeNodingValidator.h
+++ b/include/geos/geomgraph/EdgeNodingValidator.h
@@ -35,15 +35,15 @@
 
 // Forward declarations
 namespace geos {
-	namespace geom {
-		class CoordinateSequence;
-	}
-	namespace noding {
-		class SegmentString;
-	}
-	namespace geomgraph {
-		class Edge;
-	}
+namespace geom {
+class CoordinateSequence;
+}
+namespace noding {
+class SegmentString;
+}
+namespace geomgraph {
+class Edge;
+}
 }
 
 namespace geos {
@@ -57,51 +57,56 @@ namespace geomgraph { // geos.geomgraph
 class GEOS_DLL EdgeNodingValidator {
 
 private:
-	std::vector<noding::SegmentString*>& toSegmentStrings(std::vector<Edge*>& edges);
+    std::vector<noding::SegmentString*>& toSegmentStrings(std::vector<Edge*>& edges);
 
-	// Make sure this member is initialized *before*
-	// the NodingValidator, as initialization of
-	// NodingValidator will use toSegmentString(), that
-	// in turn expects this member to be initialized
-	std::vector<noding::SegmentString*> segStr;
+    // Make sure this member is initialized *before*
+    // the NodingValidator, as initialization of
+    // NodingValidator will use toSegmentString(), that
+    // in turn expects this member to be initialized
+    std::vector<noding::SegmentString*> segStr;
 
-	// Make sure this member is initialized *before*
-	// the NodingValidator, as initialization of
-	// NodingValidator will use toSegmentString(), that
-	// in turn expects this member to be initialized
-	std::vector<geom::CoordinateSequence*> newCoordSeq;
+    // Make sure this member is initialized *before*
+    // the NodingValidator, as initialization of
+    // NodingValidator will use toSegmentString(), that
+    // in turn expects this member to be initialized
+    std::vector<geom::CoordinateSequence*> newCoordSeq;
 
-	noding::FastNodingValidator nv;
+    noding::FastNodingValidator nv;
 
 public:
 
-        /** \brief
-	 * Checks whether the supplied {@link Edge}s
-	 * are correctly noded.
-	 *
-	 * Throws a  {@link TopologyException} if they are not.
-	 *
-	 * @param edges a collection of Edges.
-	 * @throws TopologyException if the SegmentStrings are not
-	 *         correctly noded
-	 *
-	 */
-        static void checkValid(std::vector<Edge*>& edges)
-        {
-                EdgeNodingValidator validator(edges);
-                validator.checkValid();
-        }
-
-	EdgeNodingValidator(std::vector<Edge*>& edges)
-		:
-		segStr(),
-		newCoordSeq(),
-		nv(toSegmentStrings(edges))
-	{}
-
-	~EdgeNodingValidator();
-
-	void checkValid() { nv.checkValid(); }
+    /** \brief
+    * Checks whether the supplied {@link Edge}s
+     * are correctly noded.
+     *
+     * Throws a  {@link TopologyException} if they are not.
+     *
+     * @param edges a collection of Edges.
+     * @throws TopologyException if the SegmentStrings are not
+     *         correctly noded
+     *
+     */
+    static void
+    checkValid(std::vector<Edge*>& edges)
+    {
+        EdgeNodingValidator validator(edges);
+        validator.checkValid();
+    }
+
+    EdgeNodingValidator(std::vector<Edge*>& edges)
+        :
+        segStr(),
+        newCoordSeq(),
+        nv(toSegmentStrings(edges))
+    {}
+
+    ~EdgeNodingValidator();
+
+    void
+    checkValid()
+    {
+        nv.checkValid();
+    }
 };
 
 
diff --git a/include/geos/geomgraph/EdgeRing.h b/include/geos/geomgraph/EdgeRing.h
index 97b803a..b6a8bb0 100644
--- a/include/geos/geomgraph/EdgeRing.h
+++ b/include/geos/geomgraph/EdgeRing.h
@@ -38,18 +38,18 @@
 
 // Forward declarations
 namespace geos {
-	namespace geom {
-		class GeometryFactory;
-		class LinearRing;
-		class Polygon;
-		class Coordinate;
-		class CoordinateSequence;
-	}
-	namespace geomgraph {
-		class DirectedEdge;
-		//class Label;
-		class Edge;
-	}
+namespace geom {
+class GeometryFactory;
+class LinearRing;
+class Polygon;
+class Coordinate;
+class CoordinateSequence;
+}
+namespace geomgraph {
+class DirectedEdge;
+//class Label;
+class Edge;
+}
 }
 
 namespace geos {
@@ -59,142 +59,141 @@ namespace geomgraph { // geos.geomgraph
 class GEOS_DLL EdgeRing {
 
 public:
-	friend std::ostream& operator<< (std::ostream& os, const EdgeRing& er);
+    friend std::ostream& operator<< (std::ostream& os, const EdgeRing& er);
 
-	EdgeRing(DirectedEdge *newStart,
-			const geom::GeometryFactory *newGeometryFactory);
+    EdgeRing(DirectedEdge* newStart,
+             const geom::GeometryFactory* newGeometryFactory);
 
-	virtual ~EdgeRing();
+    virtual ~EdgeRing();
 
-	bool isIsolated();
+    bool isIsolated();
 
-	bool isHole();
+    bool isHole();
 
-	/*
-	 * Return a pointer to the LinearRing owned by
-	 * this object. Make a copy if you need it beyond
-	 * this objects's lifetime.
-	 */
-	geom::LinearRing* getLinearRing();
+    /*
+     * Return a pointer to the LinearRing owned by
+     * this object. Make a copy if you need it beyond
+     * this objects's lifetime.
+     */
+    geom::LinearRing* getLinearRing();
 
-	Label& getLabel();
+    Label& getLabel();
 
-	bool isShell();
+    bool isShell();
 
-	EdgeRing *getShell();
+    EdgeRing* getShell();
 
-	void setShell(EdgeRing *newShell);
+    void setShell(EdgeRing* newShell);
 
-	void addHole(EdgeRing *edgeRing);
+    void addHole(EdgeRing* edgeRing);
 
-	/**
-	 * Return a Polygon copying coordinates from this
-	 * EdgeRing and its holes. Caller must remember
-	 * to delete the result
-	 */
-	geom::Polygon* toPolygon(const geom::GeometryFactory* geometryFactory);
+    /**
+     * Return a Polygon copying coordinates from this
+     * EdgeRing and its holes. Caller must remember
+     * to delete the result
+     */
+    geom::Polygon* toPolygon(const geom::GeometryFactory* geometryFactory);
 
-	/**
-	 * Compute a LinearRing from the point list previously collected.
-	 * Test if the ring is a hole (i.e. if it is CCW) and set the hole
-	 * flag accordingly.
-	 */
-	void computeRing();
+    /**
+     * Compute a LinearRing from the point list previously collected.
+     * Test if the ring is a hole (i.e. if it is CCW) and set the hole
+     * flag accordingly.
+     */
+    void computeRing();
 
-	virtual DirectedEdge* getNext(DirectedEdge *de)=0;
+    virtual DirectedEdge* getNext(DirectedEdge* de) = 0;
 
-	virtual void setEdgeRing(DirectedEdge *de, EdgeRing *er)=0;
+    virtual void setEdgeRing(DirectedEdge* de, EdgeRing* er) = 0;
 
-	/**
-	 * Returns the list of DirectedEdges that make up this EdgeRing
-	 */
-	std::vector<DirectedEdge*>& getEdges();
+    /**
+     * Returns the list of DirectedEdges that make up this EdgeRing
+     */
+    std::vector<DirectedEdge*>& getEdges();
 
-	int getMaxNodeDegree();
+    int getMaxNodeDegree();
 
-	void setInResult();
+    void setInResult();
 
-	/**
-	 * This method will use the computed ring.
-	 * It will also check any holes, if they have been assigned.
-	 */
-	bool containsPoint(const geom::Coordinate& p);
+    /**
+     * This method will use the computed ring.
+     * It will also check any holes, if they have been assigned.
+     */
+    bool containsPoint(const geom::Coordinate& p);
 
-	void testInvariant()
-	{
-		// pts are never NULL
-		assert(pts);
+    void
+    testInvariant()
+    {
+        // pts are never NULL
+        assert(pts);
 
 #ifndef NDEBUG
-		// If this is not an hole, check that
-		// each hole is not null and
-		// has 'this' as it's shell
-		if ( ! shell )
-		{
-			for (std::vector<EdgeRing*>::const_iterator
-				it=holes.begin(), itEnd=holes.end();
-				it != itEnd;
-				++it)
-			{
-				EdgeRing* hole=*it;
-				assert(hole);
-				assert(hole->getShell()==this);
-			}
-		}
+        // If this is not an hole, check that
+        // each hole is not null and
+        // has 'this' as it's shell
+        if(! shell) {
+            for(std::vector<EdgeRing*>::const_iterator
+                    it = holes.begin(), itEnd = holes.end();
+                    it != itEnd;
+                    ++it) {
+                EdgeRing* hole = *it;
+                assert(hole);
+                assert(hole->getShell() == this);
+            }
+        }
 #endif // ndef NDEBUG
-	}
+    }
 
 protected:
 
-	DirectedEdge *startDe; // the directed edge which starts the list of edges for this EdgeRing
+    DirectedEdge* startDe; // the directed edge which starts the list of edges for this EdgeRing
 
-	const geom::GeometryFactory *geometryFactory;
+    const geom::GeometryFactory* geometryFactory;
 
-	/// throw(const TopologyException &)
-	void computePoints(DirectedEdge *newStart);
+    /// throw(const TopologyException &)
+    void computePoints(DirectedEdge* newStart);
 
-	void mergeLabel(const Label& deLabel);
+    void mergeLabel(const Label& deLabel);
 
-	/** \brief
-	 * Merge the RHS label from a DirectedEdge into the label for
-	 * this EdgeRing.
-	 *
-	 * The DirectedEdge label may be null.
-	 * This is acceptable - it results from a node which is NOT
-	 * an intersection node between the Geometries
-	 * (e.g. the end node of a LinearRing).
-	 * In this case the DirectedEdge label does not contribute any
-	 * information to the overall labelling, and is
-	 * simply skipped.
-	 */
-	void mergeLabel(const Label& deLabel, int geomIndex);
+    /** \brief
+     * Merge the RHS label from a DirectedEdge into the label for
+     * this EdgeRing.
+     *
+     * The DirectedEdge label may be null.
+     * This is acceptable - it results from a node which is NOT
+     * an intersection node between the Geometries
+     * (e.g. the end node of a LinearRing).
+     * In this case the DirectedEdge label does not contribute any
+     * information to the overall labelling, and is
+     * simply skipped.
+     */
+    void mergeLabel(const Label& deLabel, int geomIndex);
 
-	void addPoints(Edge *edge, bool isForward, bool isFirstEdge);
+    void addPoints(Edge* edge, bool isForward, bool isFirstEdge);
 
-	/// a list of EdgeRings which are holes in this EdgeRing
-	std::vector<EdgeRing*> holes;
+    /// a list of EdgeRings which are holes in this EdgeRing
+    std::vector<EdgeRing*> holes;
 
 private:
 
-	int maxNodeDegree;
+    int maxNodeDegree;
 
-	/// the DirectedEdges making up this EdgeRing
-	std::vector<DirectedEdge*> edges;
+    /// the DirectedEdges making up this EdgeRing
+    std::vector<DirectedEdge*> edges;
 
-	geom::CoordinateSequence* pts;
+    geom::CoordinateSequence* pts;
 
-	// label stores the locations of each geometry on the
-	// face surrounded by this ring
-	Label label;
+    // label stores the locations of each geometry on the
+    // face surrounded by this ring
+    Label label;
 
-	geom::LinearRing *ring;  // the ring created for this EdgeRing
+    geom::LinearRing* ring;  // the ring created for this EdgeRing
 
-	bool isHoleVar;
+    bool isHoleVar;
 
-	/// if non-null, the ring is a hole and this EdgeRing is its containing shell
-	EdgeRing *shell;
+    /// if non-null, the ring is a hole and this EdgeRing is its containing shell
+    EdgeRing* shell;
 
-	void computeMaxNodeDegree();
+    void computeMaxNodeDegree();
 
 };
 
diff --git a/include/geos/geomgraph/GeometryGraph.h b/include/geos/geomgraph/GeometryGraph.h
index d91931b..311b827 100644
--- a/include/geos/geomgraph/GeometryGraph.h
+++ b/include/geos/geomgraph/GeometryGraph.h
@@ -41,27 +41,27 @@
 
 // Forward declarations
 namespace geos {
-	namespace geom {
-		class LineString;
-		class LinearRing;
-		class Polygon;
-		class Geometry;
-		class GeometryCollection;
-		class Point;
-		class Envelope;
-	}
-	namespace algorithm {
-		class LineIntersector;
-		class BoundaryNodeRule;
-	}
-	namespace geomgraph {
-		class Edge;
-		class Node;
-		namespace index {
-			class SegmentIntersector;
-			class EdgeSetIntersector;
-		}
-	}
+namespace geom {
+class LineString;
+class LinearRing;
+class Polygon;
+class Geometry;
+class GeometryCollection;
+class Point;
+class Envelope;
+}
+namespace algorithm {
+class LineIntersector;
+class BoundaryNodeRule;
+}
+namespace geomgraph {
+class Edge;
+class Node;
+namespace index {
+class SegmentIntersector;
+class EdgeSetIntersector;
+}
+}
 }
 
 namespace geos {
@@ -70,89 +70,88 @@ namespace geomgraph { // geos.geomgraph
 /**
  * A GeometryGraph is a graph that models a given Geometry
  */
-class GEOS_DLL GeometryGraph: public PlanarGraph
-{
-using PlanarGraph::add;
-using PlanarGraph::findEdge;
+class GEOS_DLL GeometryGraph: public PlanarGraph {
+    using PlanarGraph::add;
+    using PlanarGraph::findEdge;
 
 private:
 
-	const geom::Geometry* parentGeom;
+    const geom::Geometry* parentGeom;
 
-	/**
-	 * The lineEdgeMap is a map of the linestring components of the
-	 * parentGeometry to the edges which are derived from them.
-	 * This is used to efficiently perform findEdge queries
-	 *
-	 * Following the above description there's no need to
-	 * compare LineStrings other then by pointer value.
-	 */
+    /**
+     * The lineEdgeMap is a map of the linestring components of the
+     * parentGeometry to the edges which are derived from them.
+     * This is used to efficiently perform findEdge queries
+     *
+     * Following the above description there's no need to
+     * compare LineStrings other then by pointer value.
+     */
 //std::map<const geom::LineString*,Edge*,geom::LineStringLT> lineEdgeMap;
-	std::map<const geom::LineString*, Edge*> lineEdgeMap;
+    std::map<const geom::LineString*, Edge*> lineEdgeMap;
 
-	/**
-	 * If this flag is true, the Boundary Determination Rule will
-	 * used when deciding whether nodes are in the boundary or not
-	 */
-	bool useBoundaryDeterminationRule;
+    /**
+     * If this flag is true, the Boundary Determination Rule will
+     * used when deciding whether nodes are in the boundary or not
+     */
+    bool useBoundaryDeterminationRule;
 
-	const algorithm::BoundaryNodeRule& boundaryNodeRule;
+    const algorithm::BoundaryNodeRule& boundaryNodeRule;
 
-	/**
-	 * the index of this geometry as an argument to a spatial function
-	 * (used for labelling)
-	 */
-	int argIndex;
+    /**
+     * the index of this geometry as an argument to a spatial function
+     * (used for labelling)
+     */
+    int argIndex;
 
-	/// Cache for fast responses to getBoundaryPoints
-	std::unique_ptr< geom::CoordinateSequence > boundaryPoints;
+    /// Cache for fast responses to getBoundaryPoints
+    std::unique_ptr< geom::CoordinateSequence > boundaryPoints;
 
-	std::unique_ptr< std::vector<Node*> > boundaryNodes;
+    std::unique_ptr< std::vector<Node*> > boundaryNodes;
 
-	bool hasTooFewPointsVar;
+    bool hasTooFewPointsVar;
 
-	geom::Coordinate invalidPoint;
+    geom::Coordinate invalidPoint;
 
-	/// Allocates a new EdgeSetIntersector. Remember to delete it!
-	index::EdgeSetIntersector* createEdgeSetIntersector();
+    /// Allocates a new EdgeSetIntersector. Remember to delete it!
+    index::EdgeSetIntersector* createEdgeSetIntersector();
 
-	void add(const geom::Geometry *g);
-		// throw(UnsupportedOperationException);
+    void add(const geom::Geometry* g);
+    // throw(UnsupportedOperationException);
 
-	void addCollection(const geom::GeometryCollection *gc);
+    void addCollection(const geom::GeometryCollection* gc);
 
-	void addPoint(const geom::Point *p);
+    void addPoint(const geom::Point* p);
 
-	void addPolygonRing(const geom::LinearRing *lr,
-			int cwLeft, int cwRight);
+    void addPolygonRing(const geom::LinearRing* lr,
+                        int cwLeft, int cwRight);
 
-	void addPolygon(const geom::Polygon *p);
+    void addPolygon(const geom::Polygon* p);
 
-	void addLineString(const geom::LineString *line);
+    void addLineString(const geom::LineString* line);
 
-	void insertPoint(int argIndex, const geom::Coordinate& coord,
-			int onLocation);
+    void insertPoint(int argIndex, const geom::Coordinate& coord,
+                     int onLocation);
 
-	/** \brief
-	 * Adds candidate boundary points using the current
-	 * algorithm::BoundaryNodeRule.
-	 *
-	 * This is used to add the boundary
-	 * points of dim-1 geometries (Curves/MultiCurves).
-	 */
-	void insertBoundaryPoint(int argIndex, const geom::Coordinate& coord);
+    /** \brief
+     * Adds candidate boundary points using the current
+     * algorithm::BoundaryNodeRule.
+     *
+     * This is used to add the boundary
+     * points of dim-1 geometries (Curves/MultiCurves).
+     */
+    void insertBoundaryPoint(int argIndex, const geom::Coordinate& coord);
 
-	void addSelfIntersectionNodes(int argIndex);
+    void addSelfIntersectionNodes(int argIndex);
 
-	/** \brief
-	 * Add a node for a self-intersection.
-	 *
-	 * If the node is a potential boundary node (e.g. came from an edge
-	 * which is a boundary) then insert it as a potential boundary node.
-	 * Otherwise, just add it as a regular node.
-	 */
-	void addSelfIntersectionNode(int argIndex,
-		const geom::Coordinate& coord, int loc);
+    /** \brief
+     * Add a node for a self-intersection.
+     *
+     * If the node is a potential boundary node (e.g. came from an edge
+     * which is a boundary) then insert it as a potential boundary node.
+     * Otherwise, just add it as a regular node.
+     */
+    void addSelfIntersectionNode(int argIndex,
+                                 const geom::Coordinate& coord, int loc);
 
     // Declare type as noncopyable
     GeometryGraph(const GeometryGraph& other) = delete;
@@ -160,96 +159,101 @@ private:
 
 public:
 
-	static bool isInBoundary(int boundaryCount);
+    static bool isInBoundary(int boundaryCount);
 
-	static int determineBoundary(int boundaryCount);
+    static int determineBoundary(int boundaryCount);
 
-	static int determineBoundary(
-	             const algorithm::BoundaryNodeRule& boundaryNodeRule,
-	                                            int boundaryCount);
+    static int determineBoundary(
+        const algorithm::BoundaryNodeRule& boundaryNodeRule,
+        int boundaryCount);
 
-	GeometryGraph();
+    GeometryGraph();
 
-	GeometryGraph(int newArgIndex, const geom::Geometry *newParentGeom);
+    GeometryGraph(int newArgIndex, const geom::Geometry* newParentGeom);
 
-	GeometryGraph(int newArgIndex, const geom::Geometry *newParentGeom,
-	              const algorithm::BoundaryNodeRule& boundaryNodeRule);
+    GeometryGraph(int newArgIndex, const geom::Geometry* newParentGeom,
+                  const algorithm::BoundaryNodeRule& boundaryNodeRule);
 
-	~GeometryGraph() override;
+    ~GeometryGraph() override;
 
 
-	const geom::Geometry* getGeometry();
+    const geom::Geometry* getGeometry();
 
-	/// Returned object is owned by this GeometryGraph
-	std::vector<Node*>* getBoundaryNodes();
+    /// Returned object is owned by this GeometryGraph
+    std::vector<Node*>* getBoundaryNodes();
 
-	void getBoundaryNodes(std::vector<Node*>&bdyNodes);
+    void getBoundaryNodes(std::vector<Node*>& bdyNodes);
 
-	/// Returned object is owned by this GeometryGraph
-	geom::CoordinateSequence* getBoundaryPoints();
+    /// Returned object is owned by this GeometryGraph
+    geom::CoordinateSequence* getBoundaryPoints();
 
-	Edge* findEdge(const geom::LineString *line);
+    Edge* findEdge(const geom::LineString* line);
 
-	void computeSplitEdges(std::vector<Edge*> *edgelist);
+    void computeSplitEdges(std::vector<Edge*>* edgelist);
 
-	void addEdge(Edge *e);
+    void addEdge(Edge* e);
 
-	void addPoint(geom::Coordinate& pt);
+    void addPoint(geom::Coordinate& pt);
 
-	/**
-	 * \brief
-	 * Compute self-nodes, taking advantage of the Geometry type to
-	 * minimize the number of intersection tests.  (E.g. rings are
-	 * not tested for self-intersection, since
-	 * they are assumed to be valid).
-	 *
-	 * @param li the LineIntersector to use
-	 *
-	 * @param computeRingSelfNodes if <false>, intersection checks are
-	 *	optimized to not test rings for self-intersection
-	 *
-	 * @return the SegmentIntersector used, containing information about
-	 *	the intersections found
-	 */
-	index::SegmentIntersector* computeSelfNodes(
-			algorithm::LineIntersector *li,
-			bool computeRingSelfNodes,
-			const geom::Envelope *env=nullptr)
-	{
-		return computeSelfNodes(*li, computeRingSelfNodes, env);
-	}
+    /**
+     * \brief
+     * Compute self-nodes, taking advantage of the Geometry type to
+     * minimize the number of intersection tests.  (E.g. rings are
+     * not tested for self-intersection, since
+     * they are assumed to be valid).
+     *
+     * @param li the LineIntersector to use
+     *
+     * @param computeRingSelfNodes if <false>, intersection checks are
+     *	optimized to not test rings for self-intersection
+     *
+     * @return the SegmentIntersector used, containing information about
+     *	the intersections found
+     */
+    index::SegmentIntersector*
+    computeSelfNodes(
+        algorithm::LineIntersector* li,
+        bool computeRingSelfNodes,
+        const geom::Envelope* env = nullptr)
+    {
+        return computeSelfNodes(*li, computeRingSelfNodes, env);
+    }
 
-	index::SegmentIntersector* computeSelfNodes(
-			algorithm::LineIntersector *li,
-			bool computeRingSelfNodes,
-			bool isDoneIfProperInt,
-			const geom::Envelope *env=nullptr)
-	{
-		return computeSelfNodes(*li, computeRingSelfNodes, isDoneIfProperInt, env);
-	}
+    index::SegmentIntersector*
+    computeSelfNodes(
+        algorithm::LineIntersector* li,
+        bool computeRingSelfNodes,
+        bool isDoneIfProperInt,
+        const geom::Envelope* env = nullptr)
+    {
+        return computeSelfNodes(*li, computeRingSelfNodes, isDoneIfProperInt, env);
+    }
 
-	// Quick inline calling the function above, the above should probably
-	// be deprecated.
-	index::SegmentIntersector* computeSelfNodes(
-			algorithm::LineIntersector& li,
-			bool computeRingSelfNodes, const geom::Envelope *env=nullptr);
+    // Quick inline calling the function above, the above should probably
+    // be deprecated.
+    index::SegmentIntersector* computeSelfNodes(
+        algorithm::LineIntersector& li,
+        bool computeRingSelfNodes, const geom::Envelope* env = nullptr);
 
-	index::SegmentIntersector* computeSelfNodes(
-			algorithm::LineIntersector& li,
-			bool computeRingSelfNodes, bool isDoneIfProperInt, const geom::Envelope *env=nullptr);
+    index::SegmentIntersector* computeSelfNodes(
+        algorithm::LineIntersector& li,
+        bool computeRingSelfNodes, bool isDoneIfProperInt, const geom::Envelope* env = nullptr);
 
-	index::SegmentIntersector* computeEdgeIntersections(GeometryGraph *g,
-		algorithm::LineIntersector *li, bool includeProper,
-		const geom::Envelope *env=nullptr);
+    index::SegmentIntersector* computeEdgeIntersections(GeometryGraph* g,
+            algorithm::LineIntersector* li, bool includeProper,
+            const geom::Envelope* env = nullptr);
 
-	std::vector<Edge*> *getEdges();
+    std::vector<Edge*>* getEdges();
 
-	bool hasTooFewPoints();
+    bool hasTooFewPoints();
 
-	const geom::Coordinate& getInvalidPoint();
+    const geom::Coordinate& getInvalidPoint();
 
-	const algorithm::BoundaryNodeRule& getBoundaryNodeRule() const
-	{ return boundaryNodeRule; }
+    const algorithm::BoundaryNodeRule&
+    getBoundaryNodeRule() const
+    {
+        return boundaryNodeRule;
+    }
 
 };
 
diff --git a/include/geos/geomgraph/GeometryGraph.inl b/include/geos/geomgraph/GeometryGraph.inl
index e969d0e..18a53c3 100644
--- a/include/geos/geomgraph/GeometryGraph.inl
+++ b/include/geos/geomgraph/GeometryGraph.inl
@@ -9,7 +9,7 @@
  *
  * This is free software; you can redistribute and/or modify it under
  * the terms of the GNU Lesser General Public Licence as published
- * by the Free Software Foundation. 
+ * by the Free Software Foundation.
  * See the COPYING file for more information.
  *
  **********************************************************************
@@ -27,18 +27,18 @@ namespace geos {
 namespace geomgraph { // geos::geomgraph
 
 INLINE void
-GeometryGraph::getBoundaryNodes(std::vector<Node*>&bdyNodes)
+GeometryGraph::getBoundaryNodes(std::vector<Node*>& bdyNodes)
 {
-	nodes->getBoundaryNodes(argIndex, bdyNodes);
+    nodes->getBoundaryNodes(argIndex, bdyNodes);
 }
 
 INLINE const geom::Geometry*
 GeometryGraph::getGeometry()
 {
-	return parentGeom;
+    return parentGeom;
 }
 
-INLINE 
+INLINE
 GeometryGraph::~GeometryGraph()
 {
 }
diff --git a/include/geos/geomgraph/GraphComponent.h b/include/geos/geomgraph/GraphComponent.h
index 5790bef..73c190d 100644
--- a/include/geos/geomgraph/GraphComponent.h
+++ b/include/geos/geomgraph/GraphComponent.h
@@ -29,9 +29,9 @@
 
 // Forward declarations
 namespace geos {
-	namespace geom {
-		class IntersectionMatrix;
-	}
+namespace geom {
+class IntersectionMatrix;
+}
 }
 
 namespace geos {
@@ -46,35 +46,71 @@ namespace geomgraph { // geos.geomgraph
  */
 class GEOS_DLL GraphComponent {
 public:
-	GraphComponent();
+    GraphComponent();
 
-	/*
-	 * GraphComponent copies the given Label.
-	 */
-	GraphComponent(const Label& newLabel);
-	virtual ~GraphComponent();
+    /*
+     * GraphComponent copies the given Label.
+     */
+    GraphComponent(const Label& newLabel);
+    virtual ~GraphComponent();
 
-	Label& getLabel() { return label; }
-	const Label& getLabel() const { return label; }
-	void setLabel(const Label& newLabel) { label = newLabel; }
+    Label&
+    getLabel()
+    {
+        return label;
+    }
+    const Label&
+    getLabel() const
+    {
+        return label;
+    }
+    void
+    setLabel(const Label& newLabel)
+    {
+        label = newLabel;
+    }
 
-	virtual void setInResult(bool p_isInResult) { isInResultVar=p_isInResult; }
-	virtual bool isInResult() const { return isInResultVar; }
-	virtual void setCovered(bool isCovered);
-	virtual bool isCovered() const { return isCoveredVar; }
-	virtual bool isCoveredSet() const { return isCoveredSetVar; }
-	virtual bool isVisited() const { return isVisitedVar; }
-	virtual void setVisited(bool p_isVisited) { isVisitedVar = p_isVisited; }
-	virtual bool isIsolated() const=0;
-	virtual void updateIM(geom::IntersectionMatrix& im);
+    virtual void
+    setInResult(bool p_isInResult)
+    {
+        isInResultVar = p_isInResult;
+    }
+    virtual bool
+    isInResult() const
+    {
+        return isInResultVar;
+    }
+    virtual void setCovered(bool isCovered);
+    virtual bool
+    isCovered() const
+    {
+        return isCoveredVar;
+    }
+    virtual bool
+    isCoveredSet() const
+    {
+        return isCoveredSetVar;
+    }
+    virtual bool
+    isVisited() const
+    {
+        return isVisitedVar;
+    }
+    virtual void
+    setVisited(bool p_isVisited)
+    {
+        isVisitedVar = p_isVisited;
+    }
+    virtual bool isIsolated() const = 0;
+    virtual void updateIM(geom::IntersectionMatrix& im);
 protected:
-	Label label;
-	virtual void computeIM(geom::IntersectionMatrix& im)=0;
+    Label label;
+    virtual void computeIM(geom::IntersectionMatrix& im) = 0;
 private:
-	bool isInResultVar;
-	bool isCoveredVar;
-	bool isCoveredSetVar;
-	bool isVisitedVar;
+    bool isInResultVar;
+    bool isCoveredVar;
+    bool isCoveredSetVar;
+    bool isVisitedVar;
 };
 
 } // namespace geos.geomgraph
diff --git a/include/geos/geomgraph/Label.h b/include/geos/geomgraph/Label.h
index a1ccfcf..b9a1a07 100644
--- a/include/geos/geomgraph/Label.h
+++ b/include/geos/geomgraph/Label.h
@@ -58,108 +58,108 @@ class GEOS_DLL Label {
 
 public:
 
-	friend std::ostream& operator<< (std::ostream&, const Label&);
+    friend std::ostream& operator<< (std::ostream&, const Label&);
 
-	/** \brief
-	 * Converts a Label to a Line label
-	 * (that is, one with no side Locations)
-	 *
-	 */
-	static Label toLineLabel(const Label& label);
+    /** \brief
+     * Converts a Label to a Line label
+     * (that is, one with no side Locations)
+     *
+     */
+    static Label toLineLabel(const Label& label);
 
-	/** \brief
-	 * Construct a Label with a single location for both Geometries.
-	 */
-	Label(int onLoc);
+    /** \brief
+     * Construct a Label with a single location for both Geometries.
+     */
+    Label(int onLoc);
 
-	/** \brief
-	 * Construct a Label with the location specified
-	 * for the given Geometry.
-	 *
-	 * Other geometry location will be set to
-	 * Location::UNDEF.
-	 */
-	Label(int geomIndex, int onLoc);
+    /** \brief
+     * Construct a Label with the location specified
+     * for the given Geometry.
+     *
+     * Other geometry location will be set to
+     * Location::UNDEF.
+     */
+    Label(int geomIndex, int onLoc);
 
-	/** \brief
-	 * Construct a Label with On, Left and Right locations for both Geometries.
-	 *
-	 * Initialize the locations for both Geometries to the given values.
-	 */
-	Label(int onLoc, int leftLoc, int rightLoc);
+    /** \brief
+     * Construct a Label with On, Left and Right locations for both Geometries.
+     *
+     * Initialize the locations for both Geometries to the given values.
+     */
+    Label(int onLoc, int leftLoc, int rightLoc);
 
-	/// Copy ctor
-	Label(const Label &l);
+    /// Copy ctor
+    Label(const Label& l);
 
-	Label& operator= (const Label& l);
+    Label& operator= (const Label& l);
 
-	/** \brief
-	 * Initialize both locations to Location::UNDEF
-	 *
-	 * isNull() should return true after this kind of construction
-	 */
-	Label();
+    /** \brief
+     * Initialize both locations to Location::UNDEF
+     *
+     * isNull() should return true after this kind of construction
+     */
+    Label();
 
-	/** \brief
-	 * Construct a Label with On, Left and Right locations for the
-	 * given Geometries.
-	 * Initialize the locations for the other Geometry to
-	 * Location::UNDEF
-	 */
-	Label(int geomIndex, int onLoc, int leftLoc, int rightLoc);
+    /** \brief
+     * Construct a Label with On, Left and Right locations for the
+     * given Geometries.
+     * Initialize the locations for the other Geometry to
+     * Location::UNDEF
+     */
+    Label(int geomIndex, int onLoc, int leftLoc, int rightLoc);
 
-	void flip();
+    void flip();
 
-	int getLocation(int geomIndex, int posIndex) const;
+    int getLocation(int geomIndex, int posIndex) const;
 
-	int getLocation(int geomIndex) const;
+    int getLocation(int geomIndex) const;
 
-	void setLocation(int geomIndex, int posIndex, int location);
+    void setLocation(int geomIndex, int posIndex, int location);
 
-	void setLocation(int geomIndex, int location);
+    void setLocation(int geomIndex, int location);
 
-	void setAllLocations(int geomIndex, int location);
+    void setAllLocations(int geomIndex, int location);
 
-	void setAllLocationsIfNull(int geomIndex, int location);
+    void setAllLocationsIfNull(int geomIndex, int location);
 
-	void setAllLocationsIfNull(int location);
+    void setAllLocationsIfNull(int location);
 
-	/** \brief
-	 * Merge this label with another one.
-	 *
-	 * Merging updates any null attributes of this label with the attributes
-	 * from lbl
-	 */
-	void merge(const Label &lbl);
+    /** \brief
+     * Merge this label with another one.
+     *
+     * Merging updates any null attributes of this label with the attributes
+     * from lbl
+     */
+    void merge(const Label& lbl);
 
-	int getGeometryCount() const;
+    int getGeometryCount() const;
 
-	bool isNull() const;
+    bool isNull() const;
 
-	bool isNull(int geomIndex) const;
+    bool isNull(int geomIndex) const;
 
-	bool isAnyNull(int geomIndex) const;
+    bool isAnyNull(int geomIndex) const;
 
-	bool isArea() const;
+    bool isArea() const;
 
-	bool isArea(int geomIndex) const;
+    bool isArea(int geomIndex) const;
 
-	bool isLine(int geomIndex) const;
+    bool isLine(int geomIndex) const;
 
-	bool isEqualOnSide(const Label &lbl, int side) const;
+    bool isEqualOnSide(const Label& lbl, int side) const;
 
-	bool allPositionsEqual(int geomIndex, int loc) const;
+    bool allPositionsEqual(int geomIndex, int loc) const;
 
-	/** \brief
-	 * Converts one GeometryLocation to a Line location
-	 */
-	void toLine(int geomIndex);
+    /** \brief
+     * Converts one GeometryLocation to a Line location
+     */
+    void toLine(int geomIndex);
 
-	std::string toString() const;
+    std::string toString() const;
 
 private:
 
-	TopologyLocation elt[2];
+    TopologyLocation elt[2];
 };
 
 std::ostream& operator<< (std::ostream&, const Label&);
diff --git a/include/geos/geomgraph/Node.h b/include/geos/geomgraph/Node.h
index 1072fa6..06da110 100644
--- a/include/geos/geomgraph/Node.h
+++ b/include/geos/geomgraph/Node.h
@@ -43,16 +43,16 @@
 
 // Forward declarations
 namespace geos {
-	namespace geom {
-		class IntersectionMatrix;
-	}
-	namespace geomgraph {
-		class Node;
-		class EdgeEndStar;
-		class EdgeEnd;
-		class Label;
-		class NodeFactory;
-	}
+namespace geom {
+class IntersectionMatrix;
+}
+namespace geomgraph {
+class Node;
+class EdgeEndStar;
+class EdgeEnd;
+class Label;
+class NodeFactory;
+}
 }
 
 namespace geos {
@@ -60,93 +60,94 @@ namespace geomgraph { // geos.geomgraph
 
 /** The node component of a geometry graph */
 class GEOS_DLL Node: public GraphComponent {
-using GraphComponent::setLabel;
+    using GraphComponent::setLabel;
 
 public:
 
-	friend std::ostream& operator<< (std::ostream& os, const Node& node);
+    friend std::ostream& operator<< (std::ostream& os, const Node& node);
 
-	Node(const geom::Coordinate& newCoord, EdgeEndStar* newEdges);
+    Node(const geom::Coordinate& newCoord, EdgeEndStar* newEdges);
 
-	~Node() override;
+    ~Node() override;
 
-	virtual const geom::Coordinate& getCoordinate() const;
+    virtual const geom::Coordinate& getCoordinate() const;
 
-	virtual EdgeEndStar* getEdges();
+    virtual EdgeEndStar* getEdges();
 
-	bool isIsolated() const override;
+    bool isIsolated() const override;
 
-	/** \brief
-	 * Add the edge to the list of edges at this node
-	 */
-	virtual void add(EdgeEnd *e);
+    /** \brief
+     * Add the edge to the list of edges at this node
+     */
+    virtual void add(EdgeEnd* e);
 
-	virtual void mergeLabel(const Node& n);
+    virtual void mergeLabel(const Node& n);
 
-	/** \brief
-	 * To merge labels for two nodes,
-	 * the merged location for each LabelElement is computed.
-	 *
-	 * The location for the corresponding node LabelElement is set
-	 * to the result, as long as the location is non-null.
-	 */
-	virtual void mergeLabel(const Label& label2);
+    /** \brief
+     * To merge labels for two nodes,
+     * the merged location for each LabelElement is computed.
+     *
+     * The location for the corresponding node LabelElement is set
+     * to the result, as long as the location is non-null.
+     */
+    virtual void mergeLabel(const Label& label2);
 
-	virtual void setLabel(int argIndex, int onLocation);
+    virtual void setLabel(int argIndex, int onLocation);
 
-	/** \brief
-	 * Updates the label of a node to BOUNDARY,
-	 * obeying the mod-2 boundaryDetermination rule.
-	 */
-	virtual void setLabelBoundary(int argIndex);
+    /** \brief
+     * Updates the label of a node to BOUNDARY,
+     * obeying the mod-2 boundaryDetermination rule.
+     */
+    virtual void setLabelBoundary(int argIndex);
 
-	/**
-	 * The location for a given eltIndex for a node will be one
-	 * of { null, INTERIOR, BOUNDARY }.
-	 * A node may be on both the boundary and the interior of a geometry;
-	 * in this case, the rule is that the node is considered to be
-	 * in the boundary.
-	 * The merged location is the maximum of the two input values.
-	 */
-	virtual int computeMergedLocation(const Label& label2, int eltIndex);
+    /**
+     * The location for a given eltIndex for a node will be one
+     * of { null, INTERIOR, BOUNDARY }.
+     * A node may be on both the boundary and the interior of a geometry;
+     * in this case, the rule is that the node is considered to be
+     * in the boundary.
+     * The merged location is the maximum of the two input values.
+     */
+    virtual int computeMergedLocation(const Label& label2, int eltIndex);
 
-	virtual std::string print();
+    virtual std::string print();
 
-	virtual const std::vector<double> &getZ() const;
+    virtual const std::vector<double>& getZ() const;
 
-	virtual void addZ(double);
+    virtual void addZ(double);
 
-	/** \brief
-	 * Tests whether any incident edge is flagged as
-	 * being in the result.
-	 *
-	 * This test can be used to determine if the node is in the result,
-	 * since if any incident edge is in the result, the node must be in
-	 * the result as well.
-	 *
-	 * @return <code>true</code> if any indicident edge in the in
-	 *         the result
-	 */
-	virtual bool isIncidentEdgeInResult() const;
+    /** \brief
+     * Tests whether any incident edge is flagged as
+     * being in the result.
+     *
+     * This test can be used to determine if the node is in the result,
+     * since if any incident edge is in the result, the node must be in
+     * the result as well.
+     *
+     * @return <code>true</code> if any indicident edge in the in
+     *         the result
+     */
+    virtual bool isIncidentEdgeInResult() const;
 
 protected:
 
-	void testInvariant() const;
+    void testInvariant() const;
 
-	geom::Coordinate coord;
+    geom::Coordinate coord;
 
-	EdgeEndStar* edges;
+    EdgeEndStar* edges;
 
-	/** \brief
-	 * Basic nodes do not compute IMs
-	 */
-	void computeIM(geom::IntersectionMatrix& /*im*/) override {}
+    /** \brief
+     * Basic nodes do not compute IMs
+     */
+    void
+    computeIM(geom::IntersectionMatrix& /*im*/) override {}
 
 private:
 
-	std::vector<double> zvals;
+    std::vector<double> zvals;
 
-	double ztot;
+    double ztot;
 
 };
 
@@ -156,31 +157,28 @@ inline void
 Node::testInvariant() const
 {
 #ifndef NDEBUG
-	if (edges)
-	{
-		// Each EdgeEnd in the star has this Node's
-		// coordinate as first coordinate
-		for (EdgeEndStar::iterator
-				it=edges->begin(), itEnd=edges->end();
-				it != itEnd; it++)
-		{
-			EdgeEnd* e=*it;
-			assert(e);
-			assert(e->getCoordinate().equals2D(coord));
-		}
-	}
+    if(edges) {
+        // Each EdgeEnd in the star has this Node's
+        // coordinate as first coordinate
+        for(EdgeEndStar::iterator
+                it = edges->begin(), itEnd = edges->end();
+                it != itEnd; it++) {
+            EdgeEnd* e = *it;
+            assert(e);
+            assert(e->getCoordinate().equals2D(coord));
+        }
+    }
 
 #if 0 // We can't rely on numerical stability with FP computations
-	// ztot is the sum of doubnle sin zvals vector
-	double ztot_check=0.0;
-	for (std::vector<double>::const_iterator
-			i = zvals.begin(), e = zvals.end();
-			i != e;
-			i++)
-	{
-		ztot_check += *i;
-	}
-	assert(ztot_check == ztot);
+    // ztot is the sum of doubnle sin zvals vector
+    double ztot_check = 0.0;
+    for(std::vector<double>::const_iterator
+            i = zvals.begin(), e = zvals.end();
+            i != e;
+            i++) {
+        ztot_check += *i;
+    }
+    assert(ztot_check == ztot);
 #endif // 0
 
 #endif
diff --git a/include/geos/geomgraph/NodeFactory.h b/include/geos/geomgraph/NodeFactory.h
index 310c5a0..012023e 100644
--- a/include/geos/geomgraph/NodeFactory.h
+++ b/include/geos/geomgraph/NodeFactory.h
@@ -26,12 +26,12 @@
 
 // Forward declarations
 namespace geos {
-	namespace geom {
-		class Coordinate;
-	}
-	namespace geomgraph {
-		class Node;
-	}
+namespace geom {
+class Coordinate;
+}
+namespace geomgraph {
+class Node;
+}
 }
 
 namespace geos {
@@ -39,11 +39,12 @@ namespace geomgraph { // geos.geomgraph
 
 class GEOS_DLL NodeFactory {
 public:
-	virtual Node* createNode(const geom::Coordinate &coord) const;
-	static const NodeFactory &instance();
-	virtual ~NodeFactory() {}
+    virtual Node* createNode(const geom::Coordinate& coord) const;
+    static const NodeFactory& instance();
+    virtual
+    ~NodeFactory() {}
 protected:
-	NodeFactory() {}
+    NodeFactory() {}
 };
 
 
diff --git a/include/geos/geomgraph/NodeMap.h b/include/geos/geomgraph/NodeMap.h
index 15bca8a..31bb597 100644
--- a/include/geos/geomgraph/NodeMap.h
+++ b/include/geos/geomgraph/NodeMap.h
@@ -38,74 +38,90 @@
 
 // Forward declarations
 namespace geos {
-	namespace geomgraph {
-		class Node;
-		class EdgeEnd;
-		class NodeFactory;
-	}
+namespace geomgraph {
+class Node;
+class EdgeEnd;
+class NodeFactory;
+}
 }
 
 namespace geos {
 namespace geomgraph { // geos.geomgraph
 
-class GEOS_DLL NodeMap{
+class GEOS_DLL NodeMap {
 public:
 
-	typedef std::map<geom::Coordinate*,Node*,geom::CoordinateLessThen> container;
+    typedef std::map<geom::Coordinate*, Node*, geom::CoordinateLessThen> container;
 
-	typedef container::iterator iterator;
+    typedef container::iterator iterator;
 
-	typedef container::const_iterator const_iterator;
+    typedef container::const_iterator const_iterator;
 
-	typedef std::pair<geom::Coordinate*,Node*> pair;
+    typedef std::pair<geom::Coordinate*, Node*> pair;
 
-	container nodeMap;
+    container nodeMap;
 
-	const NodeFactory &nodeFact;
+    const NodeFactory& nodeFact;
 
-	/// \brief
-	/// NodeMap will keep a reference to the NodeFactory,
-	/// keep it alive for the whole NodeMap lifetime
-	NodeMap(const NodeFactory &newNodeFact);
+    /// \brief
+    /// NodeMap will keep a reference to the NodeFactory,
+    /// keep it alive for the whole NodeMap lifetime
+    NodeMap(const NodeFactory& newNodeFact);
 
-	virtual ~NodeMap();
+    virtual ~NodeMap();
 
-	Node* addNode(const geom::Coordinate& coord);
+    Node* addNode(const geom::Coordinate& coord);
 
-	Node* addNode(Node *n);
+    Node* addNode(Node* n);
 
-	void add(EdgeEnd *e);
+    void add(EdgeEnd* e);
 
-	Node *find(const geom::Coordinate& coord) const;
+    Node* find(const geom::Coordinate& coord) const;
 
-	const_iterator begin() const { return nodeMap.begin(); }
+    const_iterator
+    begin() const
+    {
+        return nodeMap.begin();
+    }
 
-	const_iterator end() const { return nodeMap.end(); }
+    const_iterator
+    end() const
+    {
+        return nodeMap.end();
+    }
 
-	iterator begin() { return nodeMap.begin(); }
+    iterator
+    begin()
+    {
+        return nodeMap.begin();
+    }
 
-	iterator end() { return nodeMap.end(); }
+    iterator
+    end()
+    {
+        return nodeMap.end();
+    }
 
-	void getBoundaryNodes(int geomIndex,
-		std::vector<Node*>&bdyNodes) const;
+    void getBoundaryNodes(int geomIndex,
+                          std::vector<Node*>& bdyNodes) const;
 
-	std::string print() const;
+    std::string print() const;
 
-	void testInvariant()
-	{
+    void
+    testInvariant()
+    {
 #ifndef NDEBUG
-		// Each Coordinate key is a pointer inside the Node value
-		for (iterator it=begin(), itEnd=end(); it != itEnd; ++it)
-		{
-			pair p = *it;
-			geomgraph::Node* n = p.second;
-			geom::Coordinate* c = const_cast<geom::Coordinate*>(
-				&(n->getCoordinate())
-			);
-			assert(p.first == c);
-		}
+        // Each Coordinate key is a pointer inside the Node value
+        for(iterator it = begin(), itEnd = end(); it != itEnd; ++it) {
+            pair p = *it;
+            geomgraph::Node* n = p.second;
+            geom::Coordinate* c = const_cast<geom::Coordinate*>(
+                                      &(n->getCoordinate())
+                                  );
+            assert(p.first == c);
+        }
 #endif
-	}
+    }
 
 private:
 
diff --git a/include/geos/geomgraph/PlanarGraph.h b/include/geos/geomgraph/PlanarGraph.h
index 62d8777..b94d9ae 100644
--- a/include/geos/geomgraph/PlanarGraph.h
+++ b/include/geos/geomgraph/PlanarGraph.h
@@ -35,15 +35,15 @@
 
 // Forward declarations
 namespace geos {
-	namespace geom {
-		class Coordinate;
-	}
-	namespace geomgraph {
-		class Edge;
-		class Node;
-		class EdgeEnd;
-		class NodeFactory;
-	}
+namespace geom {
+class Coordinate;
+}
+namespace geomgraph {
+class Edge;
+class Node;
+class EdgeEnd;
+class NodeFactory;
+}
 }
 
 namespace geos {
@@ -75,125 +75,125 @@ namespace geomgraph { // geos.geomgraph
 class GEOS_DLL PlanarGraph {
 public:
 
-	/** \brief
-	 * For nodes in the collection (first..last),
-	 * link the DirectedEdges at the node that are in the result.
-	 *
-	 * This allows clients to link only a subset of nodes in the graph,
-	 * for efficiency (because they know that only a subset is of
-	 * interest).
-	 */
-  template <typename It>
-  static void linkResultDirectedEdges(It first, It last)
+    /** \brief
+     * For nodes in the collection (first..last),
+     * link the DirectedEdges at the node that are in the result.
+     *
+     * This allows clients to link only a subset of nodes in the graph,
+     * for efficiency (because they know that only a subset is of
+     * interest).
+     */
+    template <typename It>
+    static void
+    linkResultDirectedEdges(It first, It last)
     // throw(TopologyException);
-  {
-    for ( ; first!=last; ++first )
     {
-      Node *node=*first;
-      assert(node);
-
-      EdgeEndStar* ees = node->getEdges();
-      assert(ees);
-      DirectedEdgeStar* des = dynamic_cast<DirectedEdgeStar*>(ees);
-      assert(des);
-
-      // this might throw an exception
-      des->linkResultDirectedEdges();
+        for(; first != last; ++first) {
+            Node* node = *first;
+            assert(node);
+
+            EdgeEndStar* ees = node->getEdges();
+            assert(ees);
+            DirectedEdgeStar* des = dynamic_cast<DirectedEdgeStar*>(ees);
+            assert(des);
+
+            // this might throw an exception
+            des->linkResultDirectedEdges();
+        }
     }
-  }
 
-	PlanarGraph(const NodeFactory &nodeFact);
+    PlanarGraph(const NodeFactory& nodeFact);
 
-	PlanarGraph();
+    PlanarGraph();
 
-	virtual ~PlanarGraph();
+    virtual ~PlanarGraph();
 
-	virtual std::vector<Edge*>::iterator getEdgeIterator();
+    virtual std::vector<Edge*>::iterator getEdgeIterator();
 
-	virtual std::vector<EdgeEnd*>* getEdgeEnds();
+    virtual std::vector<EdgeEnd*>* getEdgeEnds();
 
-	virtual bool isBoundaryNode(int geomIndex, const geom::Coordinate& coord);
+    virtual bool isBoundaryNode(int geomIndex, const geom::Coordinate& coord);
 
-	virtual void add(EdgeEnd *e);
+    virtual void add(EdgeEnd* e);
 
-	virtual NodeMap::iterator getNodeIterator();
+    virtual NodeMap::iterator getNodeIterator();
 
-	virtual void getNodes(std::vector<Node*>&);
+    virtual void getNodes(std::vector<Node*>&);
 
-	virtual Node* addNode(Node *node);
+    virtual Node* addNode(Node* node);
 
-	virtual Node* addNode(const geom::Coordinate& coord);
+    virtual Node* addNode(const geom::Coordinate& coord);
 
-	/** \brief
-	 * @return the node if found; null otherwise
-	 */
-	virtual Node* find(geom::Coordinate& coord);
+    /** \brief
+     * @return the node if found; null otherwise
+     */
+    virtual Node* find(geom::Coordinate& coord);
 
-	/** \brief
-	 * Add a set of edges to the graph.  For each edge two DirectedEdges
-	 * will be created.  DirectedEdges are NOT linked by this method.
-	 */
-	virtual void addEdges(const std::vector<Edge*> &edgesToAdd);
+    /** \brief
+     * Add a set of edges to the graph.  For each edge two DirectedEdges
+     * will be created.  DirectedEdges are NOT linked by this method.
+     */
+    virtual void addEdges(const std::vector<Edge*>& edgesToAdd);
 
-	virtual void linkResultDirectedEdges();
+    virtual void linkResultDirectedEdges();
 
-	virtual void linkAllDirectedEdges();
+    virtual void linkAllDirectedEdges();
 
-	/** \brief
-	 * Returns the EdgeEnd which has edge e as its base edge
-	 * (MD 18 Feb 2002 - this should return a pair of edges)
-	 *
-	 * @return the edge, if found
-	 *    <code>null</code> if the edge was not found
-	 */
-	virtual EdgeEnd* findEdgeEnd(Edge *e);
+    /** \brief
+     * Returns the EdgeEnd which has edge e as its base edge
+     * (MD 18 Feb 2002 - this should return a pair of edges)
+     *
+     * @return the edge, if found
+     *    <code>null</code> if the edge was not found
+     */
+    virtual EdgeEnd* findEdgeEnd(Edge* e);
 
-	/** \brief
-	 * Returns the edge whose first two coordinates are p0 and p1
-	 *
-	 * @return the edge, if found
-	 *    <code>null</code> if the edge was not found
-	 */
-	virtual Edge* findEdge(const geom::Coordinate& p0,
-			const geom::Coordinate& p1);
+    /** \brief
+     * Returns the edge whose first two coordinates are p0 and p1
+     *
+     * @return the edge, if found
+     *    <code>null</code> if the edge was not found
+     */
+    virtual Edge* findEdge(const geom::Coordinate& p0,
+                           const geom::Coordinate& p1);
 
-	/** \brief
-	 * Returns the edge which starts at p0 and whose first segment is
-	 * parallel to p1
-	 *
-	 * @return the edge, if found
-	 *    <code>null</code> if the edge was not found
-	 */
-	virtual Edge* findEdgeInSameDirection(const geom::Coordinate& p0,
-			const geom::Coordinate& p1);
+    /** \brief
+     * Returns the edge which starts at p0 and whose first segment is
+     * parallel to p1
+     *
+     * @return the edge, if found
+     *    <code>null</code> if the edge was not found
+     */
+    virtual Edge* findEdgeInSameDirection(const geom::Coordinate& p0,
+                                          const geom::Coordinate& p1);
 
-	virtual std::string printEdges();
+    virtual std::string printEdges();
 
-	virtual NodeMap* getNodeMap();
+    virtual NodeMap* getNodeMap();
 
 protected:
 
-	std::vector<Edge*> *edges;
+    std::vector<Edge*>* edges;
 
-	NodeMap *nodes;
+    NodeMap* nodes;
 
-	std::vector<EdgeEnd*> *edgeEndList;
+    std::vector<EdgeEnd*>* edgeEndList;
 
-	virtual void insertEdge(Edge *e);
+    virtual void insertEdge(Edge* e);
 
 private:
 
-	/** \brief
-	 * The coordinate pairs match if they define line segments
-	 * lying in the same direction.
-	 *
-	 * E.g. the segments are parallel and in the same quadrant
-	 * (as opposed to parallel and opposite!).
-	 */
-	bool matchInSameDirection(const geom::Coordinate& p0,
-			const geom::Coordinate& p1,
-			const geom::Coordinate& ep0,
-			const geom::Coordinate& ep1);
+    /** \brief
+     * The coordinate pairs match if they define line segments
+     * lying in the same direction.
+     *
+     * E.g. the segments are parallel and in the same quadrant
+     * (as opposed to parallel and opposite!).
+     */
+    bool matchInSameDirection(const geom::Coordinate& p0,
+                              const geom::Coordinate& p1,
+                              const geom::Coordinate& ep0,
+                              const geom::Coordinate& ep1);
 };
 
 
diff --git a/include/geos/geomgraph/Position.h b/include/geos/geomgraph/Position.h
index 51ad61c..16df86e 100644
--- a/include/geos/geomgraph/Position.h
+++ b/include/geos/geomgraph/Position.h
@@ -34,31 +34,31 @@ namespace geomgraph { // geos.geomgraph
 
 class GEOS_DLL Position {
 public:
-	enum {
-		/*
-		 * An indicator that a Location is <i>on</i>
-		 * a GraphComponent
-		 */
-		ON=0,
+    enum {
+        /*
+         * An indicator that a Location is <i>on</i>
+         * a GraphComponent
+         */
+        ON = 0,
 
-		/*
-		 * An indicator that a Location is to the
-		 * <i>left</i> of a GraphComponent
-		 */
-		LEFT,
+        /*
+         * An indicator that a Location is to the
+         * <i>left</i> of a GraphComponent
+         */
+        LEFT,
 
-		/*
-		 * An indicator that a Location is to the
-		 * <i>right</i> of a GraphComponent
-		 */
-		RIGHT
-	};
+        /*
+         * An indicator that a Location is to the
+         * <i>right</i> of a GraphComponent
+         */
+        RIGHT
+    };
 
-	/**
-	 * Returns LEFT if the position is RIGHT, RIGHT if
-	 * the position is LEFT, or the position otherwise.
-	 */
-	static int opposite(int position);
+    /**
+     * Returns LEFT if the position is RIGHT, RIGHT if
+     * the position is LEFT, or the position otherwise.
+     */
+    static int opposite(int position);
 };
 
 } // namespace geos.geomgraph
diff --git a/include/geos/geomgraph/Quadrant.h b/include/geos/geomgraph/Quadrant.h
index f1785ab..9992071 100644
--- a/include/geos/geomgraph/Quadrant.h
+++ b/include/geos/geomgraph/Quadrant.h
@@ -28,9 +28,9 @@
 
 // Forward declarations
 namespace geos {
-	namespace geom {
-		class Coordinate;
-	}
+namespace geom {
+class Coordinate;
+}
 }
 
 namespace geos {
@@ -49,50 +49,50 @@ class GEOS_DLL Quadrant {
 
 public:
 
-        static const int NE = 0;
-        static const int NW = 1;
-        static const int SW = 2;
-        static const int SE = 3;
-
-	/**
-	 * Returns the quadrant of a directed line segment
-	 * (specified as x and y displacements, which cannot both be 0).
-	 *
-	 * @throws IllegalArgumentException if the displacements are both 0
-	 */
-	static int quadrant(double dx, double dy);
-
-	/**
-	 * Returns the quadrant of a directed line segment from p0 to p1.
-	 *
-	 * @throws IllegalArgumentException if the points are equal
-	 */
-	static int quadrant(const geom::Coordinate& p0,
-	                    const geom::Coordinate& p1);
-
-	/**
-	 * Returns true if the quadrants are 1 and 3, or 2 and 4
-	 */
-	static bool isOpposite(int quad1, int quad2);
-
-	/*
-	 * Returns the right-hand quadrant of the halfplane defined by
-	 * the two quadrants,
-	 * or -1 if the quadrants are opposite, or the quadrant if they
-	 * are identical.
-	 */
-	static int commonHalfPlane(int quad1, int quad2);
-
-	/**
-	 * Returns whether the given quadrant lies within the given halfplane
-	 * (specified by its right-hand quadrant).
-	 */
-	static bool isInHalfPlane(int quad, int halfPlane);
-
-	/**
-	 * Returns true if the given quadrant is 0 or 1.
-	 */
-	static bool isNorthern(int quad);
+    static const int NE = 0;
+    static const int NW = 1;
+    static const int SW = 2;
+    static const int SE = 3;
+
+    /**
+     * Returns the quadrant of a directed line segment
+     * (specified as x and y displacements, which cannot both be 0).
+     *
+     * @throws IllegalArgumentException if the displacements are both 0
+     */
+    static int quadrant(double dx, double dy);
+
+    /**
+     * Returns the quadrant of a directed line segment from p0 to p1.
+     *
+     * @throws IllegalArgumentException if the points are equal
+     */
+    static int quadrant(const geom::Coordinate& p0,
+                        const geom::Coordinate& p1);
+
+    /**
+     * Returns true if the quadrants are 1 and 3, or 2 and 4
+     */
+    static bool isOpposite(int quad1, int quad2);
+
+    /*
+     * Returns the right-hand quadrant of the halfplane defined by
+     * the two quadrants,
+     * or -1 if the quadrants are opposite, or the quadrant if they
+     * are identical.
+     */
+    static int commonHalfPlane(int quad1, int quad2);
+
+    /**
+     * Returns whether the given quadrant lies within the given halfplane
+     * (specified by its right-hand quadrant).
+     */
+    static bool isInHalfPlane(int quad, int halfPlane);
+
+    /**
+     * Returns true if the given quadrant is 0 or 1.
+     */
+    static bool isNorthern(int quad);
 };
 
 
diff --git a/include/geos/geomgraph/TopologyLocation.h b/include/geos/geomgraph/TopologyLocation.h
index 658c7c0..5a568f5 100644
--- a/include/geos/geomgraph/TopologyLocation.h
+++ b/include/geos/geomgraph/TopologyLocation.h
@@ -59,79 +59,79 @@ class GEOS_DLL TopologyLocation {
 
 public:
 
-	friend std::ostream& operator<< (std::ostream&, const TopologyLocation&);
+    friend std::ostream& operator<< (std::ostream&, const TopologyLocation&);
 
-	TopologyLocation();
+    TopologyLocation();
 
-	~TopologyLocation();
+    ~TopologyLocation();
 
-	TopologyLocation(const std::vector<int> &newLocation);
+    TopologyLocation(const std::vector<int>& newLocation);
 
-	/** \brief
-	 * Constructs a TopologyLocation specifying how points on, to the
-	 * left of, and to the right of some GraphComponent relate to some
-	 * Geometry.
-	 *
-	 * Possible values for the
-	 * parameters are Location::UNDEF, Location::EXTERIOR, Location::BOUNDARY,
-	 * and Location::INTERIOR.
-	 *
-	 * @see Location
-	 */
-	TopologyLocation(int on, int left, int right);
+    /** \brief
+     * Constructs a TopologyLocation specifying how points on, to the
+     * left of, and to the right of some GraphComponent relate to some
+     * Geometry.
+     *
+     * Possible values for the
+     * parameters are Location::UNDEF, Location::EXTERIOR, Location::BOUNDARY,
+     * and Location::INTERIOR.
+     *
+     * @see Location
+     */
+    TopologyLocation(int on, int left, int right);
 
-	TopologyLocation(int on);
+    TopologyLocation(int on);
 
-	TopologyLocation(const TopologyLocation &gl);
+    TopologyLocation(const TopologyLocation& gl);
 
-	TopologyLocation& operator= (const TopologyLocation &gl);
+    TopologyLocation& operator= (const TopologyLocation& gl);
 
-	int get(std::size_t posIndex) const;
+    int get(std::size_t posIndex) const;
 
-	/**
-	 * @return true if all locations are Location::UNDEF
-	 */
-	bool isNull() const;
+    /**
+     * @return true if all locations are Location::UNDEF
+     */
+    bool isNull() const;
 
-	/**
-	 * @return true if any locations is Location::UNDEF
-	 */
-	bool isAnyNull() const;
+    /**
+     * @return true if any locations is Location::UNDEF
+     */
+    bool isAnyNull() const;
 
-	bool isEqualOnSide(const TopologyLocation &le, int locIndex) const;
+    bool isEqualOnSide(const TopologyLocation& le, int locIndex) const;
 
-	bool isArea() const;
+    bool isArea() const;
 
-	bool isLine() const;
+    bool isLine() const;
 
-	void flip();
+    void flip();
 
-	void setAllLocations(int locValue);
+    void setAllLocations(int locValue);
 
-	void setAllLocationsIfNull(int locValue);
+    void setAllLocationsIfNull(int locValue);
 
-	void setLocation(std::size_t locIndex, int locValue);
+    void setLocation(std::size_t locIndex, int locValue);
 
-	void setLocation(int locValue);
+    void setLocation(int locValue);
 
-	/// Warning: returns reference to owned memory
-	const std::vector<int> &getLocations() const;
+    /// Warning: returns reference to owned memory
+    const std::vector<int>& getLocations() const;
 
-	void setLocations(int on, int left, int right);
+    void setLocations(int on, int left, int right);
 
-	bool allPositionsEqual(int loc) const;
+    bool allPositionsEqual(int loc) const;
 
-	/** \brief
-	 * merge updates only the UNDEF attributes of this object
-	 * with the attributes of another.
-	 */
-	void merge(const TopologyLocation &gl);
+    /** \brief
+     * merge updates only the UNDEF attributes of this object
+     * with the attributes of another.
+     */
+    void merge(const TopologyLocation& gl);
 
-	std::string toString() const;
+    std::string toString() const;
 
 private:
 
-	std::vector<int> location;
+    std::vector<int> location;
 };
 
 std::ostream& operator<< (std::ostream&, const TopologyLocation&);
diff --git a/include/geos/geomgraph/index/EdgeSetIntersector.h b/include/geos/geomgraph/index/EdgeSetIntersector.h
index 349b4e4..8fe90b5 100644
--- a/include/geos/geomgraph/index/EdgeSetIntersector.h
+++ b/include/geos/geomgraph/index/EdgeSetIntersector.h
@@ -21,12 +21,12 @@
 
 // Forward declarations
 namespace geos {
-	namespace geomgraph {
-		class Edge;
-		namespace index {
-			class SegmentIntersector;
-		}
-	}
+namespace geomgraph {
+class Edge;
+namespace index {
+class SegmentIntersector;
+}
+}
 }
 
 namespace geos {
@@ -38,25 +38,26 @@ namespace index { // geos::geomgraph::index
  */
 class GEOS_DLL EdgeSetIntersector {
 public:
-	/**
-	 * Computes all self-intersections between edges in a set of edges,
-	 * allowing client to choose whether self-intersections are computed.
-	 *
-	 * @param edges a list of edges to test for intersections
-	 * @param si the SegmentIntersector to use
-	 * @param testAllSegments true if self-intersections are to be tested as well
-	 */
-	virtual void computeIntersections(std::vector<Edge*> *edges,
-			SegmentIntersector *si, bool testAllSegments)=0;
+    /**
+     * Computes all self-intersections between edges in a set of edges,
+     * allowing client to choose whether self-intersections are computed.
+     *
+     * @param edges a list of edges to test for intersections
+     * @param si the SegmentIntersector to use
+     * @param testAllSegments true if self-intersections are to be tested as well
+     */
+    virtual void computeIntersections(std::vector<Edge*>* edges,
+                                      SegmentIntersector* si, bool testAllSegments) = 0;
 
-	/**
-	 * Computes all mutual intersections between two sets of edges
-	 */
-	virtual void computeIntersections(std::vector<Edge*> *edges0,
-			std::vector<Edge*> *edges1,
-			SegmentIntersector *si)=0;
+    /**
+     * Computes all mutual intersections between two sets of edges
+     */
+    virtual void computeIntersections(std::vector<Edge*>* edges0,
+                                      std::vector<Edge*>* edges1,
+                                      SegmentIntersector* si) = 0;
 
-	virtual ~EdgeSetIntersector(){}
+    virtual
+    ~EdgeSetIntersector() {}
 };
 
 
diff --git a/include/geos/geomgraph/index/MonotoneChain.h b/include/geos/geomgraph/index/MonotoneChain.h
index f353136..4611a00 100644
--- a/include/geos/geomgraph/index/MonotoneChain.h
+++ b/include/geos/geomgraph/index/MonotoneChain.h
@@ -28,11 +28,11 @@
 
 // Forward declarations
 namespace geos {
-	namespace geomgraph {
-		namespace index {
-			class SegmentIntersector;
-		}
-	}
+namespace geomgraph {
+namespace index {
+class SegmentIntersector;
+}
+}
 }
 
 namespace geos {
@@ -44,21 +44,23 @@ namespace index { // geos::geomgraph::index
  */
 class GEOS_DLL MonotoneChain: public SweepLineEventOBJ {
 private:
-	MonotoneChainEdge *mce;
-	size_t chainIndex;
+    MonotoneChainEdge* mce;
+    size_t chainIndex;
 
 public:
 
-	MonotoneChain(MonotoneChainEdge *newMce, size_t newChainIndex):
-		mce(newMce),
-		chainIndex(newChainIndex)
-	{}
+    MonotoneChain(MonotoneChainEdge* newMce, size_t newChainIndex):
+        mce(newMce),
+        chainIndex(newChainIndex)
+    {}
 
-	~MonotoneChain() override {}
+    ~MonotoneChain() override {}
 
-	void computeIntersections(MonotoneChain *mc,SegmentIntersector *si) {
-		mce->computeIntersectsForChain(chainIndex,*(mc->mce),mc->chainIndex,*si);
-	}
+    void
+    computeIntersections(MonotoneChain* mc, SegmentIntersector* si)
+    {
+        mce->computeIntersectsForChain(chainIndex, *(mc->mce), mc->chainIndex, *si);
+    }
 };
 
 
diff --git a/include/geos/geomgraph/index/MonotoneChainEdge.h b/include/geos/geomgraph/index/MonotoneChainEdge.h
index 19ed048..1805439 100644
--- a/include/geos/geomgraph/index/MonotoneChainEdge.h
+++ b/include/geos/geomgraph/index/MonotoneChainEdge.h
@@ -26,15 +26,15 @@
 
 // Forward declarations
 namespace geos {
-	namespace geom {
-		class CoordinateSequence;
-	}
-	namespace geomgraph {
-		class Edge;
-		namespace index {
-			class SegmentIntersector;
-		}
-	}
+namespace geom {
+class CoordinateSequence;
+}
+namespace geomgraph {
+class Edge;
+namespace index {
+class SegmentIntersector;
+}
+}
 }
 
 namespace geos {
@@ -43,33 +43,33 @@ namespace index { // geos::geomgraph::index
 
 class GEOS_DLL MonotoneChainEdge {
 public:
-	//MonotoneChainEdge();
-	~MonotoneChainEdge();
-	MonotoneChainEdge(Edge *newE);
-	const geom::CoordinateSequence* getCoordinates();
-	std::vector<size_t>& getStartIndexes();
-	double getMinX(size_t chainIndex);
-	double getMaxX(size_t chainIndex);
+    //MonotoneChainEdge();
+    ~MonotoneChainEdge();
+    MonotoneChainEdge(Edge* newE);
+    const geom::CoordinateSequence* getCoordinates();
+    std::vector<size_t>& getStartIndexes();
+    double getMinX(size_t chainIndex);
+    double getMaxX(size_t chainIndex);
 
-	void computeIntersects(const MonotoneChainEdge &mce,
-		SegmentIntersector &si);
+    void computeIntersects(const MonotoneChainEdge& mce,
+                           SegmentIntersector& si);
 
-	void computeIntersectsForChain(size_t chainIndex0,
-		const MonotoneChainEdge &mce, size_t chainIndex1,
-		SegmentIntersector &si);
+    void computeIntersectsForChain(size_t chainIndex0,
+                                   const MonotoneChainEdge& mce, size_t chainIndex1,
+                                   SegmentIntersector& si);
 
 protected:
-	Edge *e;
-	const geom::CoordinateSequence* pts; // cache a reference to the coord array, for efficiency
-	// the lists of start/end indexes of the monotone chains.
-	// Includes the end point of the edge as a sentinel
-	std::vector<size_t> startIndex;
-	// these envelopes are created once and reused
+    Edge* e;
+    const geom::CoordinateSequence* pts; // cache a reference to the coord array, for efficiency
+    // the lists of start/end indexes of the monotone chains.
+    // Includes the end point of the edge as a sentinel
+    std::vector<size_t> startIndex;
+    // these envelopes are created once and reused
 private:
-	void computeIntersectsForChain(size_t start0, size_t end0,
-		const MonotoneChainEdge &mce,
-		size_t start1, size_t end1,
-		SegmentIntersector &ei);
+    void computeIntersectsForChain(size_t start0, size_t end0,
+                                   const MonotoneChainEdge& mce,
+                                   size_t start1, size_t end1,
+                                   SegmentIntersector& ei);
 
     bool overlaps(size_t start0, size_t end0, const MonotoneChainEdge& mce, size_t start1, size_t end1);
 
diff --git a/include/geos/geomgraph/index/MonotoneChainIndexer.h b/include/geos/geomgraph/index/MonotoneChainIndexer.h
index 1b282ee..616217e 100644
--- a/include/geos/geomgraph/index/MonotoneChainIndexer.h
+++ b/include/geos/geomgraph/index/MonotoneChainIndexer.h
@@ -21,9 +21,9 @@
 
 // Forward declarations
 namespace geos {
-	namespace geom {
-		class CoordinateSequence;
-	}
+namespace geom {
+class CoordinateSequence;
+}
 }
 
 namespace geos {
@@ -31,17 +31,17 @@ namespace geomgraph { // geos::geomgraph
 namespace index { // geos::geomgraph::index
 
 
-class GEOS_DLL MonotoneChainIndexer{
+class GEOS_DLL MonotoneChainIndexer {
 
 public:
 
-	MonotoneChainIndexer(){}
+    MonotoneChainIndexer() {}
 
-	void getChainStartIndices(const geom::CoordinateSequence*, std::vector<std::size_t>&);
+    void getChainStartIndices(const geom::CoordinateSequence*, std::vector<std::size_t>&);
 
 private:
 
-	std::size_t findChainEnd(const geom::CoordinateSequence* pts, std::size_t start);
+    std::size_t findChainEnd(const geom::CoordinateSequence* pts, std::size_t start);
 
 };
 
diff --git a/include/geos/geomgraph/index/SegmentIntersector.h b/include/geos/geomgraph/index/SegmentIntersector.h
index ec3bf62..5c1aec9 100644
--- a/include/geos/geomgraph/index/SegmentIntersector.h
+++ b/include/geos/geomgraph/index/SegmentIntersector.h
@@ -28,13 +28,13 @@
 
 // Forward declarations
 namespace geos {
-	namespace algorithm {
-		class LineIntersector;
-	}
-	namespace geomgraph {
-		class Node;
-		class Edge;
-	}
+namespace algorithm {
+class LineIntersector;
+}
+namespace geomgraph {
+class Node;
+class Edge;
+}
 }
 
 namespace geos {
@@ -42,96 +42,97 @@ namespace geomgraph { // geos::geomgraph
 namespace index { // geos::geomgraph::index
 
 
-class GEOS_DLL SegmentIntersector{
+class GEOS_DLL SegmentIntersector {
 
 private:
 
-	/**
-	 * These variables keep track of what types of intersections were
-	 * found during ALL edges that have been intersected.
-	 */
-	bool hasIntersectionVar;
+    /**
+     * These variables keep track of what types of intersections were
+     * found during ALL edges that have been intersected.
+     */
+    bool hasIntersectionVar;
 
-	bool hasProper;
+    bool hasProper;
 
-	bool hasProperInterior;
+    bool hasProperInterior;
 
-	bool isDone;
+    bool isDone;
 
-	bool isDoneWhenProperInt;
+    bool isDoneWhenProperInt;
 
-	// the proper intersection point found
-	geom::Coordinate properIntersectionPoint;
+    // the proper intersection point found
+    geom::Coordinate properIntersectionPoint;
 
-	algorithm::LineIntersector *li;
+    algorithm::LineIntersector* li;
 
-	bool includeProper;
+    bool includeProper;
 
-	bool recordIsolated;
+    bool recordIsolated;
 
-	//bool isSelfIntersection;
+    //bool isSelfIntersection;
 
-	//bool intersectionFound;
+    //bool intersectionFound;
 
-	int numIntersections;
+    int numIntersections;
 
-	/// Elements are externally owned
-	std::vector<std::vector<Node*>*> bdyNodes;
+    /// Elements are externally owned
+    std::vector<std::vector<Node*>*> bdyNodes;
 
-	bool isTrivialIntersection(Edge *e0, size_t segIndex0,Edge *e1, size_t segIndex1);
+    bool isTrivialIntersection(Edge* e0, size_t segIndex0, Edge* e1, size_t segIndex1);
 
-	bool isBoundaryPoint(algorithm::LineIntersector *li,
-			std::vector<std::vector<Node*>*>& tstBdyNodes);
+    bool isBoundaryPoint(algorithm::LineIntersector* li,
+                         std::vector<std::vector<Node*>*>& tstBdyNodes);
 
-	bool isBoundaryPoint(algorithm::LineIntersector *li,
-			std::vector<Node*> *tstBdyNodes);
+    bool isBoundaryPoint(algorithm::LineIntersector* li,
+                         std::vector<Node*>* tstBdyNodes);
 
 public:
 
-	static bool isAdjacentSegments(size_t i1, size_t i2);
+    static bool isAdjacentSegments(size_t i1, size_t i2);
 
-	// testing only
-	int numTests;
+    // testing only
+    int numTests;
 
-	//SegmentIntersector();
+    //SegmentIntersector();
 
-	virtual ~SegmentIntersector() {}
+    virtual
+    ~SegmentIntersector() {}
 
-	SegmentIntersector(algorithm::LineIntersector *newLi,
-			bool newIncludeProper, bool newRecordIsolated)
-		:
-		hasIntersectionVar(false),
-		hasProper(false),
-		hasProperInterior(false),
-		isDone(false),
-		isDoneWhenProperInt(false),
-		li(newLi),
-		includeProper(newIncludeProper),
-		recordIsolated(newRecordIsolated),
-		numIntersections(0),
-		bdyNodes(2),
-		numTests(0)
-	{}
+    SegmentIntersector(algorithm::LineIntersector* newLi,
+                       bool newIncludeProper, bool newRecordIsolated)
+        :
+        hasIntersectionVar(false),
+        hasProper(false),
+        hasProperInterior(false),
+        isDone(false),
+        isDoneWhenProperInt(false),
+        li(newLi),
+        includeProper(newIncludeProper),
+        recordIsolated(newRecordIsolated),
+        numIntersections(0),
+        bdyNodes(2),
+        numTests(0)
+    {}
 
-	/// \brief
-	/// Parameters are externally owned.
-	/// Make sure they live for the whole lifetime of this object
-	void setBoundaryNodes(std::vector<Node*> *bdyNodes0,
-			std::vector<Node*> *bdyNodes1);
+    /// \brief
+    /// Parameters are externally owned.
+    /// Make sure they live for the whole lifetime of this object
+    void setBoundaryNodes(std::vector<Node*>* bdyNodes0,
+                          std::vector<Node*>* bdyNodes1);
 
-	geom::Coordinate& getProperIntersectionPoint();
+    geom::Coordinate& getProperIntersectionPoint();
 
-	bool hasIntersection();
+    bool hasIntersection();
 
-	bool hasProperIntersection();
+    bool hasProperIntersection();
 
-	bool hasProperInteriorIntersection();
+    bool hasProperInteriorIntersection();
 
-	void addIntersections(Edge *e0, size_t segIndex0, Edge *e1, size_t segIndex1);
+    void addIntersections(Edge* e0, size_t segIndex0, Edge* e1, size_t segIndex1);
 
-	void setIsDoneIfProperInt(bool isDoneWhenProperInt);
+    void setIsDoneIfProperInt(bool isDoneWhenProperInt);
 
-	bool getIsDone();
+    bool getIsDone();
 
 };
 
diff --git a/include/geos/geomgraph/index/SimpleEdgeSetIntersector.h b/include/geos/geomgraph/index/SimpleEdgeSetIntersector.h
index 78d41ab..1cd1e32 100644
--- a/include/geos/geomgraph/index/SimpleEdgeSetIntersector.h
+++ b/include/geos/geomgraph/index/SimpleEdgeSetIntersector.h
@@ -23,12 +23,12 @@
 
 // Forward declarations
 namespace geos {
-	namespace geomgraph {
-		class Edge;
-		namespace index {
-			class SegmentIntersector;
-		}
-	}
+namespace geomgraph {
+class Edge;
+namespace index {
+class SegmentIntersector;
+}
+}
 }
 
 namespace geos {
@@ -39,19 +39,19 @@ class GEOS_DLL SimpleEdgeSetIntersector: public EdgeSetIntersector {
 
 public:
 
-	SimpleEdgeSetIntersector();
+    SimpleEdgeSetIntersector();
 
-	void computeIntersections(std::vector<Edge*> *edges,
-			SegmentIntersector *si, bool testAllSegments) override;
+    void computeIntersections(std::vector<Edge*>* edges,
+                              SegmentIntersector* si, bool testAllSegments) override;
 
-	void computeIntersections(std::vector<Edge*> *edges0,
-			std::vector<Edge*> *edges1, SegmentIntersector *si) override;
+    void computeIntersections(std::vector<Edge*>* edges0,
+                              std::vector<Edge*>* edges1, SegmentIntersector* si) override;
 
 private:
 
-	int nOverlaps;
+    int nOverlaps;
 
-	void computeIntersects(Edge *e0, Edge *e1, SegmentIntersector *si);
+    void computeIntersects(Edge* e0, Edge* e1, SegmentIntersector* si);
 };
 
 } // namespace geos.geomgraph.index
diff --git a/include/geos/geomgraph/index/SimpleMCSweepLineIntersector.h b/include/geos/geomgraph/index/SimpleMCSweepLineIntersector.h
index 4ebf526..4b3dcee 100644
--- a/include/geos/geomgraph/index/SimpleMCSweepLineIntersector.h
+++ b/include/geos/geomgraph/index/SimpleMCSweepLineIntersector.h
@@ -29,13 +29,13 @@
 
 // Forward declarations
 namespace geos {
-	namespace geomgraph {
-		class Edge;
-		namespace index {
-			// class SegmentIntersector;
-			class SweepLineEvent;
-		}
-	}
+namespace geomgraph {
+class Edge;
+namespace index {
+// class SegmentIntersector;
+class SweepLineEvent;
+}
+}
 }
 
 namespace geos {
@@ -55,38 +55,38 @@ class GEOS_DLL SimpleMCSweepLineIntersector: public EdgeSetIntersector {
 
 public:
 
-	SimpleMCSweepLineIntersector();
+    SimpleMCSweepLineIntersector();
 
-	~SimpleMCSweepLineIntersector() override;
+    ~SimpleMCSweepLineIntersector() override;
 
-	void computeIntersections(std::vector<Edge*> *edges,
-			SegmentIntersector *si, bool testAllSegments) override;
+    void computeIntersections(std::vector<Edge*>* edges,
+                              SegmentIntersector* si, bool testAllSegments) override;
 
-	void computeIntersections(std::vector<Edge*> *edges0,
-			std::vector<Edge*> *edges1,
-			SegmentIntersector *si) override;
+    void computeIntersections(std::vector<Edge*>* edges0,
+                              std::vector<Edge*>* edges1,
+                              SegmentIntersector* si) override;
 
 protected:
 
-	std::vector<SweepLineEvent*> events;
+    std::vector<SweepLineEvent*> events;
 
-	// statistics information
-	int nOverlaps;
+    // statistics information
+    int nOverlaps;
 
 private:
-	void add(std::vector<Edge*> *edges);
+    void add(std::vector<Edge*>* edges);
 
-	void add(std::vector<Edge*> *edges,void* edgeSet);
+    void add(std::vector<Edge*>* edges, void* edgeSet);
 
-	void add(Edge *edge,void* edgeSet);
+    void add(Edge* edge, void* edgeSet);
 
-	void prepareEvents();
+    void prepareEvents();
 
-	void computeIntersections(SegmentIntersector *si);
+    void computeIntersections(SegmentIntersector* si);
 
-	void processOverlaps(size_t start, size_t end,
-			SweepLineEvent *ev0,
-			SegmentIntersector *si);
+    void processOverlaps(size_t start, size_t end,
+                         SweepLineEvent* ev0,
+                         SegmentIntersector* si);
 };
 
 } // namespace geos.geomgraph.index
diff --git a/include/geos/geomgraph/index/SimpleSweepLineIntersector.h b/include/geos/geomgraph/index/SimpleSweepLineIntersector.h
index 2e17652..61bb130 100644
--- a/include/geos/geomgraph/index/SimpleSweepLineIntersector.h
+++ b/include/geos/geomgraph/index/SimpleSweepLineIntersector.h
@@ -28,13 +28,13 @@
 
 // Forward declarations
 namespace geos {
-	namespace geomgraph {
-		class Edge;
-		namespace index {
-			class SegmentIntersector;
-			class SweepLineEvent;
-		}
-	}
+namespace geomgraph {
+class Edge;
+namespace index {
+class SegmentIntersector;
+class SweepLineEvent;
+}
+}
 }
 
 namespace geos {
@@ -52,37 +52,37 @@ class GEOS_DLL SimpleSweepLineIntersector: public EdgeSetIntersector {
 
 public:
 
-	SimpleSweepLineIntersector();
+    SimpleSweepLineIntersector();
 
-	~SimpleSweepLineIntersector() override;
+    ~SimpleSweepLineIntersector() override;
 
-	void computeIntersections(std::vector<Edge*> *edges,
-			SegmentIntersector *si,
-			bool testAllSegments) override;
+    void computeIntersections(std::vector<Edge*>* edges,
+                              SegmentIntersector* si,
+                              bool testAllSegments) override;
 
-	void computeIntersections(std::vector<Edge*> *edges0,
-			std::vector<Edge*> *edges1,
-			SegmentIntersector *si) override;
+    void computeIntersections(std::vector<Edge*>* edges0,
+                              std::vector<Edge*>* edges1,
+                              SegmentIntersector* si) override;
 
 private:
 
-	void add(std::vector<Edge*> *edges);
+    void add(std::vector<Edge*>* edges);
 
-	std::vector<SweepLineEvent*> events;
+    std::vector<SweepLineEvent*> events;
 
-	// statistics information
-	int nOverlaps;
+    // statistics information
+    int nOverlaps;
 
-	void add(std::vector<Edge*> *edges, void* edgeSet);
+    void add(std::vector<Edge*>* edges, void* edgeSet);
 
-	void add(Edge *edge,void* edgeSet);
+    void add(Edge* edge, void* edgeSet);
 
-	void prepareEvents();
+    void prepareEvents();
 
-	void computeIntersections(SegmentIntersector *si);
+    void computeIntersections(SegmentIntersector* si);
 
-	void processOverlaps(size_t start, size_t end, SweepLineEvent *ev0,
-			SegmentIntersector *si);
+    void processOverlaps(size_t start, size_t end, SweepLineEvent* ev0,
+                         SegmentIntersector* si);
 };
 
 } // namespace geos.geomgraph.index
diff --git a/include/geos/geomgraph/index/SweepLineEvent.h b/include/geos/geomgraph/index/SweepLineEvent.h
index 854afe3..3f5c6ba 100644
--- a/include/geos/geomgraph/index/SweepLineEvent.h
+++ b/include/geos/geomgraph/index/SweepLineEvent.h
@@ -22,11 +22,11 @@
 
 // Forward declarations
 namespace geos {
-	namespace geomgraph {
-		namespace index {
-			class SweepLineEventOBJ;
-		}
-	}
+namespace geomgraph {
+namespace index {
+class SweepLineEventOBJ;
+}
+}
 }
 
 namespace geos {
@@ -35,66 +35,95 @@ namespace index { // geos::geomgraph::index
 
 //class SweepLineEventLessThen; // needed ??
 
-class GEOS_DLL SweepLineEvent{
-friend class SweepLineEventLessThen;
+class GEOS_DLL SweepLineEvent {
+    friend class SweepLineEventLessThen;
 
 public:
 
-	enum {
-		INSERT_EVENT = 1,
-		DELETE_EVENT
-	};
+    enum {
+        INSERT_EVENT = 1,
+        DELETE_EVENT
+    };
 
-	SweepLineEvent(void* newEdgeSet, double x,
-			SweepLineEvent *newInsertEvent,
-			SweepLineEventOBJ *newObj);
+    SweepLineEvent(void* newEdgeSet, double x,
+                   SweepLineEvent* newInsertEvent,
+                   SweepLineEventOBJ* newObj);
 
-	virtual ~SweepLineEvent();
+    virtual ~SweepLineEvent();
 
-	bool isInsert() { return insertEvent==nullptr; }
+    bool
+    isInsert()
+    {
+        return insertEvent == nullptr;
+    }
 
-	bool isDelete() { return insertEvent!=nullptr; }
+    bool
+    isDelete()
+    {
+        return insertEvent != nullptr;
+    }
 
-	SweepLineEvent* getInsertEvent() { return insertEvent; }
+    SweepLineEvent*
+    getInsertEvent()
+    {
+        return insertEvent;
+    }
 
-	size_t getDeleteEventIndex() { return deleteEventIndex; }
+    size_t
+    getDeleteEventIndex()
+    {
+        return deleteEventIndex;
+    }
 
-	void setDeleteEventIndex(size_t newDeleteEventIndex) {
-		deleteEventIndex=newDeleteEventIndex;
-	}
+    void
+    setDeleteEventIndex(size_t newDeleteEventIndex)
+    {
+        deleteEventIndex = newDeleteEventIndex;
+    }
 
-	SweepLineEventOBJ* getObject() const { return obj; }
+    SweepLineEventOBJ*
+    getObject() const
+    {
+        return obj;
+    }
 
-	int compareTo(SweepLineEvent *sle);
+    int compareTo(SweepLineEvent* sle);
 
-	std::string print();
+    std::string print();
 
-	void* edgeSet;    // used for red-blue intersection detection
+    void* edgeSet;    // used for red-blue intersection detection
 
 protected:
 
-	SweepLineEventOBJ* obj;
+    SweepLineEventOBJ* obj;
 
 private:
 
-	double xValue;
+    double xValue;
 
-	int eventType;
+    int eventType;
 
-	SweepLineEvent *insertEvent; // null if this is an INSERT_EVENT event
+    SweepLineEvent* insertEvent; // null if this is an INSERT_EVENT event
 
-	size_t deleteEventIndex;
+    size_t deleteEventIndex;
 };
 
 class GEOS_DLL SweepLineEventLessThen {
 public:
-	bool operator()(const SweepLineEvent *f, const SweepLineEvent *s) const
-	{
-		if (f->xValue<s->xValue) return true;
-		if (f->xValue>s->xValue) return false;
-		if (f->eventType<s->eventType) return true;
-		return false;
-	}
+    bool
+    operator()(const SweepLineEvent* f, const SweepLineEvent* s) const
+    {
+        if(f->xValue < s->xValue) {
+            return true;
+        }
+        if(f->xValue > s->xValue) {
+            return false;
+        }
+        if(f->eventType < s->eventType) {
+            return true;
+        }
+        return false;
+    }
 };
 
 
diff --git a/include/geos/geomgraph/index/SweepLineEventObj.h b/include/geos/geomgraph/index/SweepLineEventObj.h
index 08b7989..c305e03 100644
--- a/include/geos/geomgraph/index/SweepLineEventObj.h
+++ b/include/geos/geomgraph/index/SweepLineEventObj.h
@@ -28,7 +28,8 @@ namespace index { // geos::geomgraph::index
 // inherit from it.
 class GEOS_DLL SweepLineEventOBJ {
 public:
-	virtual ~SweepLineEventOBJ(){}
+    virtual
+    ~SweepLineEventOBJ() {}
 };
 
 
diff --git a/include/geos/geomgraph/index/SweepLineSegment.h b/include/geos/geomgraph/index/SweepLineSegment.h
index 6e4b5c3..5a91436 100644
--- a/include/geos/geomgraph/index/SweepLineSegment.h
+++ b/include/geos/geomgraph/index/SweepLineSegment.h
@@ -22,15 +22,15 @@
 
 // Forward declarations
 namespace geos {
-	namespace geom {
-		class CoordinateSequence;
-	}
-	namespace geomgraph {
-		class Edge;
-		namespace index {
-			class SegmentIntersector;
-		}
-	}
+namespace geom {
+class CoordinateSequence;
+}
+namespace geomgraph {
+class Edge;
+namespace index {
+class SegmentIntersector;
+}
+}
 }
 
 namespace geos {
@@ -39,15 +39,15 @@ namespace index { // geos::geomgraph::index
 
 class GEOS_DLL SweepLineSegment: public SweepLineEventOBJ {
 public:
-	SweepLineSegment(Edge *newEdge, size_t newPtIndex);
-	~SweepLineSegment() override;
-	double getMinX();
-	double getMaxX();
-	void computeIntersections(SweepLineSegment *ss, SegmentIntersector *si);
+    SweepLineSegment(Edge* newEdge, size_t newPtIndex);
+    ~SweepLineSegment() override;
+    double getMinX();
+    double getMaxX();
+    void computeIntersections(SweepLineSegment* ss, SegmentIntersector* si);
 protected:
-	Edge *edge;
-	const geom::CoordinateSequence* pts;
-	size_t ptIndex;
+    Edge* edge;
+    const geom::CoordinateSequence* pts;
+    size_t ptIndex;
 };
 
 
diff --git a/include/geos/index/ItemVisitor.h b/include/geos/index/ItemVisitor.h
index f906fa3..fbd9402 100644
--- a/include/geos/index/ItemVisitor.h
+++ b/include/geos/index/ItemVisitor.h
@@ -28,9 +28,10 @@ namespace index {
  */
 class GEOS_DLL ItemVisitor {
 public:
-	virtual void visitItem(void *)=0;
+    virtual void visitItem(void*) = 0;
 
-	virtual ~ItemVisitor() {}
+    virtual
+    ~ItemVisitor() {}
 };
 
 } // namespace geos.index
diff --git a/include/geos/index/SpatialIndex.h b/include/geos/index/SpatialIndex.h
index c74f93b..235e1b5 100644
--- a/include/geos/index/SpatialIndex.h
+++ b/include/geos/index/SpatialIndex.h
@@ -21,12 +21,12 @@
 
 // Forward declarations
 namespace geos {
-	namespace geom {
-		class Envelope;
-	}
-	namespace index {
-		class ItemVisitor;
-	}
+namespace geom {
+class Envelope;
+}
+namespace index {
+class ItemVisitor;
+}
 }
 
 namespace geos {
@@ -47,54 +47,55 @@ namespace index {
 class GEOS_DLL SpatialIndex {
 public:
 
-    virtual ~SpatialIndex() {}
-
-	/** \brief
-	 * Adds a spatial item with an extent specified by the given Envelope
-	 * to the index
-	 *
-	 * @param itemEnv
-	 *    Envelope of the item, ownership left to caller.
-	 *    TODO: Reference hold by this class ?
-	 *
-	 * @param item
-	 *    Opaque item, ownership left to caller.
-	 *    Reference hold by this class.
-	 */
-	virtual void insert(const geom::Envelope *itemEnv, void *item) = 0;
-
-	/** \brief
-	 * Queries the index for all items whose extents intersect the given search Envelope
-	 *
-	 * Note that some kinds of indexes may also return objects which do not in fact
-	 * intersect the query envelope.
-	 *
-	 * @param searchEnv the envelope to query for
-	 * @return a list of the items found by the query in a newly allocated vector
-	 */
-	//virtual std::vector<void*>* query(const geom::Envelope *searchEnv)=0;
-	virtual void query(const geom::Envelope* searchEnv, std::vector<void*>&) = 0;
-
-	/** \brief
-	 * Queries the index for all items whose extents intersect the given search Envelope
-	 * and applies an ItemVisitor to them.
-	 *
-	 * Note that some kinds of indexes may also return objects which do not in fact
-	 * intersect the query envelope.
-	 *
-	 * @param searchEnv the envelope to query for
-	 * @param visitor a visitor object to apply to the items found
-	 */
-	virtual void query(const geom::Envelope *searchEnv, ItemVisitor& visitor) = 0;
-
-	/** \brief
-	 * Removes a single item from the tree.
-	 *
-	 * @param itemEnv the Envelope of the item to remove
-	 * @param item the item to remove
-	 * @return <code>true</code> if the item was found
-	 */
-	virtual bool remove(const geom::Envelope* itemEnv, void* item) = 0;
+    virtual
+    ~SpatialIndex() {}
+
+    /** \brief
+     * Adds a spatial item with an extent specified by the given Envelope
+     * to the index
+     *
+     * @param itemEnv
+     *    Envelope of the item, ownership left to caller.
+     *    TODO: Reference hold by this class ?
+     *
+     * @param item
+     *    Opaque item, ownership left to caller.
+     *    Reference hold by this class.
+     */
+    virtual void insert(const geom::Envelope* itemEnv, void* item) = 0;
+
+    /** \brief
+     * Queries the index for all items whose extents intersect the given search Envelope
+     *
+     * Note that some kinds of indexes may also return objects which do not in fact
+     * intersect the query envelope.
+     *
+     * @param searchEnv the envelope to query for
+     * @return a list of the items found by the query in a newly allocated vector
+     */
+    //virtual std::vector<void*>* query(const geom::Envelope *searchEnv)=0;
+    virtual void query(const geom::Envelope* searchEnv, std::vector<void*>&) = 0;
+
+    /** \brief
+     * Queries the index for all items whose extents intersect the given search Envelope
+     * and applies an ItemVisitor to them.
+     *
+     * Note that some kinds of indexes may also return objects which do not in fact
+     * intersect the query envelope.
+     *
+     * @param searchEnv the envelope to query for
+     * @param visitor a visitor object to apply to the items found
+     */
+    virtual void query(const geom::Envelope* searchEnv, ItemVisitor& visitor) = 0;
+
+    /** \brief
+     * Removes a single item from the tree.
+     *
+     * @param itemEnv the Envelope of the item to remove
+     * @param item the item to remove
+     * @return <code>true</code> if the item was found
+     */
+    virtual bool remove(const geom::Envelope* itemEnv, void* item) = 0;
 
 };
 
diff --git a/include/geos/index/bintree/Bintree.h b/include/geos/index/bintree/Bintree.h
index 7f28602..10141a7 100644
--- a/include/geos/index/bintree/Bintree.h
+++ b/include/geos/index/bintree/Bintree.h
@@ -25,12 +25,12 @@
 
 // Forward declarations
 namespace geos {
-	namespace index {
-		namespace bintree {
-			class Interval;
-			class Root;
-		}
-	}
+namespace index {
+namespace bintree {
+class Interval;
+class Root;
+}
+}
 }
 
 namespace geos {
@@ -57,65 +57,65 @@ class GEOS_DLL Bintree {
 
 public:
 
-	/**
-	 * Ensure that the Interval for the inserted item has non-zero extents.
-	 * Use the current minExtent to pad it, if necessary
-	 *
-	 * NOTE: in GEOS this function always return a newly allocated object
-	 *       with ownership transferred to caller. TODO: change this ?
-	 *
-	 * @param itemInterval
-	 *      Source interval, ownership left to caller, no references hold.
-	 */
-	static Interval* ensureExtent(const Interval *itemInterval,
-	                                                 double minExtent);
+    /**
+     * Ensure that the Interval for the inserted item has non-zero extents.
+     * Use the current minExtent to pad it, if necessary
+     *
+     * NOTE: in GEOS this function always return a newly allocated object
+     *       with ownership transferred to caller. TODO: change this ?
+     *
+     * @param itemInterval
+     *      Source interval, ownership left to caller, no references hold.
+     */
+    static Interval* ensureExtent(const Interval* itemInterval,
+                                  double minExtent);
 
-	Bintree();
+    Bintree();
 
-	~Bintree();
+    ~Bintree();
 
-	int depth();
+    int depth();
 
-	int size();
+    int size();
 
-	int nodeSize();
+    int nodeSize();
 
-	/// @param itemInterval
-	///     Ownership left to caller, NO reference hold by this class.
-	///
-	/// @param item
-	///     Ownership left to caller, reference kept by this class.
-	///
-	void insert(Interval *itemInterval, void* item);
+    /// @param itemInterval
+    ///     Ownership left to caller, NO reference hold by this class.
+    ///
+    /// @param item
+    ///     Ownership left to caller, reference kept by this class.
+    ///
+    void insert(Interval* itemInterval, void* item);
 
-	std::vector<void*>* iterator();
+    std::vector<void*>* iterator();
 
-	std::vector<void*>* query(double x);
+    std::vector<void*>* query(double x);
 
-	std::vector<void*>* query(Interval *interval);
+    std::vector<void*>* query(Interval* interval);
 
-	void query(Interval *interval,
-			std::vector<void*> *foundItems);
+    void query(Interval* interval,
+               std::vector<void*>* foundItems);
 
 private:
 
-	std::vector<Interval *>newIntervals;
+    std::vector<Interval*>newIntervals;
 
-	Root *root;
+    Root* root;
 
-	/**
-	 *  Statistics
-	 *
-	 * minExtent is the minimum extent of all items
-	 * inserted into the tree so far. It is used as a heuristic value
-	 * to construct non-zero extents for features with zero extent.
-	 * Start with a non-zero extent, in case the first feature inserted has
-	 * a zero extent in both directions.  This value may be non-optimal, but
-	 * only one feature will be inserted with this value.
-	 */
-	double minExtent;
+    /**
+     *  Statistics
+     *
+     * minExtent is the minimum extent of all items
+     * inserted into the tree so far. It is used as a heuristic value
+     * to construct non-zero extents for features with zero extent.
+     * Start with a non-zero extent, in case the first feature inserted has
+     * a zero extent in both directions.  This value may be non-optimal, but
+     * only one feature will be inserted with this value.
+     */
+    double minExtent;
 
-	void collectStats(Interval *interval);
+    void collectStats(Interval* interval);
 };
 
 } // namespace geos::index::bintree
diff --git a/include/geos/index/bintree/Interval.h b/include/geos/index/bintree/Interval.h
index 1e4b5d8..f3b717c 100644
--- a/include/geos/index/bintree/Interval.h
+++ b/include/geos/index/bintree/Interval.h
@@ -26,36 +26,36 @@ class GEOS_DLL Interval {
 
 public:
 
-	double min, max;
+    double min, max;
 
-	Interval();
+    Interval();
 
-	~Interval();
+    ~Interval();
 
-	Interval(double nmin, double nmax);
+    Interval(double nmin, double nmax);
 
-	/// TODO: drop this, rely on copy ctor
-	Interval(const Interval *interval);
+    /// TODO: drop this, rely on copy ctor
+    Interval(const Interval* interval);
 
-	void init(double nmin, double nmax);
+    void init(double nmin, double nmax);
 
-	double getMin() const;
+    double getMin() const;
 
-	double getMax() const;
+    double getMax() const;
 
-	double getWidth() const;
+    double getWidth() const;
 
-	void expandToInclude(Interval *interval);
+    void expandToInclude(Interval* interval);
 
-	bool overlaps(const Interval *interval) const;
+    bool overlaps(const Interval* interval) const;
 
-	bool overlaps(double nmin, double nmax) const;
+    bool overlaps(double nmin, double nmax) const;
 
-	bool contains(const Interval *interval) const;
+    bool contains(const Interval* interval) const;
 
-	bool contains(double nmin, double nmax) const;
+    bool contains(double nmin, double nmax) const;
 
-	bool contains(double p) const;
+    bool contains(double p) const;
 };
 
 } // namespace geos::index::bintree
diff --git a/include/geos/index/bintree/Key.h b/include/geos/index/bintree/Key.h
index 6949d77..3a29110 100644
--- a/include/geos/index/bintree/Key.h
+++ b/include/geos/index/bintree/Key.h
@@ -19,11 +19,11 @@
 
 // Forward declarations
 namespace geos {
-	namespace index {
-		namespace bintree {
-			class Interval;
-		}
-	}
+namespace index {
+namespace bintree {
+class Interval;
+}
+}
 }
 
 namespace geos {
@@ -40,30 +40,30 @@ class GEOS_DLL Key {
 
 public:
 
-	static int computeLevel(Interval *newInterval);
+    static int computeLevel(Interval* newInterval);
 
-	Key(Interval *newInterval);
+    Key(Interval* newInterval);
 
-	~Key();
+    ~Key();
 
-	double getPoint();
+    double getPoint();
 
-	int getLevel();
+    int getLevel();
 
-	Interval* getInterval();
+    Interval* getInterval();
 
-	void computeKey(Interval *itemInterval);
+    void computeKey(Interval* itemInterval);
 
 private:
 
-	// the fields which make up the key
-	double pt;
-	int level;
+    // the fields which make up the key
+    double pt;
+    int level;
 
-	// auxiliary data which is derived from the key for use in computation
-	Interval *interval;
+    // auxiliary data which is derived from the key for use in computation
+    Interval* interval;
 
-	void computeInterval(int level, Interval *itemInterval);
+    void computeInterval(int level, Interval* itemInterval);
 };
 
 } // namespace geos::index::bintree
diff --git a/include/geos/index/bintree/Node.h b/include/geos/index/bintree/Node.h
index 8e92a49..d32bfdc 100644
--- a/include/geos/index/bintree/Node.h
+++ b/include/geos/index/bintree/Node.h
@@ -20,11 +20,11 @@
 
 // Forward declarations
 namespace geos {
-	namespace index {
-		namespace bintree {
-			class Interval;
-		}
-	}
+namespace index {
+namespace bintree {
+class Interval;
+}
+}
 }
 
 namespace geos {
@@ -36,37 +36,37 @@ class GEOS_DLL Node: public NodeBase {
 
 public:
 
-	static Node* createNode(Interval *itemInterval);
+    static Node* createNode(Interval* itemInterval);
 
-	static Node* createExpanded(Node *node,Interval *addInterval);
+    static Node* createExpanded(Node* node, Interval* addInterval);
 
-	Node(Interval *newInterval,int newLevel);
+    Node(Interval* newInterval, int newLevel);
 
-	~Node() override;
+    ~Node() override;
 
-	Interval* getInterval();
+    Interval* getInterval();
 
-	Node* getNode(Interval *searchInterval);
+    Node* getNode(Interval* searchInterval);
 
-	NodeBase* find(Interval *searchInterval);
+    NodeBase* find(Interval* searchInterval);
 
-	void insert(Node *node);
+    void insert(Node* node);
 
 private:
 
-	Interval *interval;
+    Interval* interval;
 
-	double centre;
+    double centre;
 
-	int level;
+    int level;
 
-	Node* getSubnode(int index);
+    Node* getSubnode(int index);
 
-	Node* createSubnode(int index);
+    Node* createSubnode(int index);
 
 protected:
 
-	bool isSearchMatch(Interval *itemInterval) override;
+    bool isSearchMatch(Interval* itemInterval) override;
 };
 
 } // namespace geos::index::bintree
diff --git a/include/geos/index/bintree/NodeBase.h b/include/geos/index/bintree/NodeBase.h
index 43578ed..b4f0d2b 100644
--- a/include/geos/index/bintree/NodeBase.h
+++ b/include/geos/index/bintree/NodeBase.h
@@ -20,12 +20,12 @@
 
 // Forward declarations
 namespace geos {
-	namespace index {
-		namespace bintree {
-			class Node;
-			class Interval;
-		}
-	}
+namespace index {
+namespace bintree {
+class Node;
+class Interval;
+}
+}
 }
 
 namespace geos {
@@ -37,39 +37,39 @@ class GEOS_DLL NodeBase {
 
 public:
 
-	static int getSubnodeIndex(Interval *interval, double centre);
+    static int getSubnodeIndex(Interval* interval, double centre);
 
-	NodeBase();
+    NodeBase();
 
-	virtual ~NodeBase();
+    virtual ~NodeBase();
 
-	virtual std::vector<void*> *getItems();
+    virtual std::vector<void*>* getItems();
 
-	virtual void add(void* item);
+    virtual void add(void* item);
 
-	virtual std::vector<void*>* addAllItems(std::vector<void*> *newItems);
+    virtual std::vector<void*>* addAllItems(std::vector<void*>* newItems);
 
-	virtual std::vector<void*>* addAllItemsFromOverlapping(Interval *interval,
-			std::vector<void*> *resultItems);
+    virtual std::vector<void*>* addAllItemsFromOverlapping(Interval* interval,
+            std::vector<void*>* resultItems);
 
-	virtual int depth();
+    virtual int depth();
 
-	virtual int size();
+    virtual int size();
 
-	virtual int nodeSize();
+    virtual int nodeSize();
 
 protected:
 
-	std::vector<void*>* items;
+    std::vector<void*>* items;
 
-	/**
-	 * subnodes are numbered as follows:
-	 *
-	 *  0 | 1
-	 */
-	Node* subnode[2];
+    /**
+     * subnodes are numbered as follows:
+     *
+     *  0 | 1
+     */
+    Node* subnode[2];
 
-	virtual bool isSearchMatch(Interval *interval)=0;
+    virtual bool isSearchMatch(Interval* interval) = 0;
 };
 
 } // namespace geos::index::bintree
diff --git a/include/geos/index/bintree/Root.h b/include/geos/index/bintree/Root.h
index ec90980..2f2ef2b 100644
--- a/include/geos/index/bintree/Root.h
+++ b/include/geos/index/bintree/Root.h
@@ -20,12 +20,12 @@
 
 // Forward declarations
 namespace geos {
-	namespace index {
-		namespace bintree {
-			class Interval;
-			class Node;
-		}
-	}
+namespace index {
+namespace bintree {
+class Interval;
+class Node;
+}
+}
 }
 
 namespace geos {
@@ -42,30 +42,34 @@ class GEOS_DLL Root: public NodeBase {
 
 private:
 
-	// the singleton root node is centred at the origin.
-	static double origin;
+    // the singleton root node is centred at the origin.
+    static double origin;
 
-	void insertContained(Node *tree,
-			Interval *itemInterval,
-			void* item);
+    void insertContained(Node* tree,
+                         Interval* itemInterval,
+                         void* item);
 
 public:
 
-	Root() {}
+    Root() {}
 
-	~Root() override {}
+    ~Root() override {}
 
-	/// @param itemInterval
-	///     Ownership left to caller, references kept in this class.
-	///
-	/// @param item
-	///     Ownership left to caller, references kept in this class.
-	///
-	void insert(Interval *itemInterval, void* item);
+    /// @param itemInterval
+    ///     Ownership left to caller, references kept in this class.
+    ///
+    /// @param item
+    ///     Ownership left to caller, references kept in this class.
+    ///
+    void insert(Interval* itemInterval, void* item);
 
 protected:
 
-	bool isSearchMatch(Interval* /*interval*/) override { return true; }
+    bool
+    isSearchMatch(Interval* /*interval*/) override
+    {
+        return true;
+    }
 };
 
 } // namespace geos::index::bintree
diff --git a/include/geos/index/chain/MonotoneChain.h b/include/geos/index/chain/MonotoneChain.h
index af17385..bab26a5 100644
--- a/include/geos/index/chain/MonotoneChain.h
+++ b/include/geos/index/chain/MonotoneChain.h
@@ -26,17 +26,17 @@
 
 // Forward declarations
 namespace geos {
-	namespace geom {
-		class Envelope;
-		class LineSegment;
-		class CoordinateSequence;
-	}
-	namespace index {
-		namespace chain {
-			class MonotoneChainSelectAction;
-			class MonotoneChainOverlapAction;
-		}
-	}
+namespace geom {
+class Envelope;
+class LineSegment;
+class CoordinateSequence;
+}
+namespace index {
+namespace chain {
+class MonotoneChainSelectAction;
+class MonotoneChainOverlapAction;
+}
+}
 }
 
 namespace geos {
@@ -82,91 +82,110 @@ namespace chain { // geos::index::chain
  * However, it does mean that the queries are not thread-safe.
  *
  */
-class GEOS_DLL MonotoneChain
-{
+class GEOS_DLL MonotoneChain {
 public:
 
-	/// @param pts
-	///   Ownership left to caller, this class holds a reference.
-	///
-	/// @param start
-	///
-	/// @param end
-	///
-	/// @param context
-	///   Ownership left to caller, this class holds a reference.
-	///
-	MonotoneChain(const geom::CoordinateSequence& pts,
+    /// @param pts
+    ///   Ownership left to caller, this class holds a reference.
+    ///
+    /// @param start
+    ///
+    /// @param end
+    ///
+    /// @param context
+    ///   Ownership left to caller, this class holds a reference.
+    ///
+    MonotoneChain(const geom::CoordinateSequence& pts,
                   std::size_t start, std::size_t end, void* context);
 
-	~MonotoneChain();
-
-	/// Returned envelope is owned by this class
-	const geom::Envelope& getEnvelope() const;
-
-	size_t getStartIndex() const { return start; }
-
-	size_t getEndIndex() const { return end; }
-
-	/** \brief
-	 *  Set given LineSegment with points of the segment starting
-	 *  at the given index.
-	 */
-	void getLineSegment(std::size_t index, geom::LineSegment& ls) const;
-
-	/**
-	 * Return the subsequence of coordinates forming this chain.
-	 * Allocates a new CoordinateSequence to hold the Coordinates
-	 *
-	 */
-	std::unique_ptr<geom::CoordinateSequence> getCoordinates() const;
-
-	/**
-	 * Determine all the line segments in the chain whose envelopes overlap
-	 * the searchEnvelope, and process them
-	 */
-	void select(const geom::Envelope& searchEnv,
-			MonotoneChainSelectAction& mcs);
-
-	void computeOverlaps(MonotoneChain *mc,
-			MonotoneChainOverlapAction *mco);
-
-	void setId(int nId) { id=nId; }
-
-	inline int getId() const { return id; }
-
-	void* getContext() { return context; }
+    ~MonotoneChain();
+
+    /// Returned envelope is owned by this class
+    const geom::Envelope& getEnvelope() const;
+
+    size_t
+    getStartIndex() const
+    {
+        return start;
+    }
+
+    size_t
+    getEndIndex() const
+    {
+        return end;
+    }
+
+    /** \brief
+     *  Set given LineSegment with points of the segment starting
+     *  at the given index.
+     */
+    void getLineSegment(std::size_t index, geom::LineSegment& ls) const;
+
+    /**
+     * Return the subsequence of coordinates forming this chain.
+     * Allocates a new CoordinateSequence to hold the Coordinates
+     *
+     */
+    std::unique_ptr<geom::CoordinateSequence> getCoordinates() const;
+
+    /**
+     * Determine all the line segments in the chain whose envelopes overlap
+     * the searchEnvelope, and process them
+     */
+    void select(const geom::Envelope& searchEnv,
+                MonotoneChainSelectAction& mcs);
+
+    void computeOverlaps(MonotoneChain* mc,
+                         MonotoneChainOverlapAction* mco);
+
+    void
+    setId(int nId)
+    {
+        id = nId;
+    }
+
+    inline int
+    getId() const
+    {
+        return id;
+    }
+
+    void*
+    getContext()
+    {
+        return context;
+    }
 
 private:
 
-	void computeSelect(const geom::Envelope& searchEnv,
-			size_t start0,
-			size_t end0,
-			MonotoneChainSelectAction& mcs);
+    void computeSelect(const geom::Envelope& searchEnv,
+                       size_t start0,
+                       size_t end0,
+                       MonotoneChainSelectAction& mcs);
 
-	void computeOverlaps(std::size_t start0, std::size_t end0, MonotoneChain& mc,
-			     std::size_t start1, std::size_t end1,
-	                     MonotoneChainOverlapAction& mco);
+    void computeOverlaps(std::size_t start0, std::size_t end0, MonotoneChain& mc,
+                         std::size_t start1, std::size_t end1,
+                         MonotoneChainOverlapAction& mco);
 
     bool overlaps(size_t start0, size_t end0, const MonotoneChain& mc, int start1, size_t end1);
 
-	/// Externally owned
-	const geom::CoordinateSequence& pts;
+    /// Externally owned
+    const geom::CoordinateSequence& pts;
 
-	/// Owned by this class, lazely created
-	mutable geom::Envelope* env;
+    /// Owned by this class, lazely created
+    mutable geom::Envelope* env;
 
-	/// user-defined information
-	void* context;
+    /// user-defined information
+    void* context;
 
-	/// Index of chain start vertex into the CoordinateSequence, 0 based.
-	size_t start;
+    /// Index of chain start vertex into the CoordinateSequence, 0 based.
+    size_t start;
 
-	/// Index of chain end vertex into the CoordinateSequence, 0 based.
-	size_t end;
+    /// Index of chain end vertex into the CoordinateSequence, 0 based.
+    size_t end;
 
-	/// useful for optimizing chain comparisons
-	int id;
+    /// useful for optimizing chain comparisons
+    int id;
 
     // Declare type as noncopyable
     MonotoneChain(const MonotoneChain& other) = delete;
diff --git a/include/geos/index/chain/MonotoneChainBuilder.h b/include/geos/index/chain/MonotoneChainBuilder.h
index d5e752e..bcd14fe 100644
--- a/include/geos/index/chain/MonotoneChainBuilder.h
+++ b/include/geos/index/chain/MonotoneChainBuilder.h
@@ -26,14 +26,14 @@
 
 // Forward declarations
 namespace geos {
-	namespace geom {
-		class CoordinateSequence;
-	}
-	namespace index {
-		namespace chain {
-			class MonotoneChain;
-		}
-	}
+namespace geom {
+class CoordinateSequence;
+}
+namespace index {
+namespace chain {
+class MonotoneChain;
+}
+}
 }
 
 namespace geos {
@@ -50,64 +50,65 @@ class GEOS_DLL MonotoneChainBuilder {
 
 public:
 
-	MonotoneChainBuilder(){}
-
-	/** \brief
-	 * Return a newly-allocated vector of newly-allocated
-	 * MonotoneChain objects for the given CoordinateSequence.
-	 * Remember to deep-delete the result.
-	 */
-	static std::unique_ptr<std::vector<std::unique_ptr<MonotoneChain>>> getChains(
-			const geom::CoordinateSequence *pts,
-			void* context);
-
-	/** \brief
-	 * Fill the provided vector with newly-allocated MonotoneChain objects
-	 * for the given CoordinateSequence.
-	 * Remember to delete vector elements!
-	 */
-	static void getChains(const geom::CoordinateSequence *pts,
-			void* context,
-			std::vector<std::unique_ptr<MonotoneChain>> & mcList);
-
-	static std::unique_ptr<std::vector<std::unique_ptr<MonotoneChain>>> getChains(const geom::CoordinateSequence *pts)
-	{
-		return getChains(pts, nullptr);
-	}
-
-	/** \brief
-	 * Fill the given vector with start/end indexes of the monotone chains
-	 * for the given CoordinateSequence.
-	 * The last entry in the array points to the end point of the point
-	 * array,
-	 * for use as a sentinel.
-	 */
-	static void getChainStartIndices(const geom::CoordinateSequence& pts,
-			std::vector<std::size_t>& startIndexList);
+    MonotoneChainBuilder() {}
+
+    /** \brief
+     * Return a newly-allocated vector of newly-allocated
+     * MonotoneChain objects for the given CoordinateSequence.
+     * Remember to deep-delete the result.
+     */
+    static std::unique_ptr<std::vector<std::unique_ptr<MonotoneChain>>> getChains(
+        const geom::CoordinateSequence* pts,
+        void* context);
+
+    /** \brief
+     * Fill the provided vector with newly-allocated MonotoneChain objects
+     * for the given CoordinateSequence.
+     * Remember to delete vector elements!
+     */
+    static void getChains(const geom::CoordinateSequence* pts,
+                          void* context,
+                          std::vector<std::unique_ptr<MonotoneChain>>& mcList);
+
+    static std::unique_ptr<std::vector<std::unique_ptr<MonotoneChain>>>
+    getChains(const geom::CoordinateSequence* pts)
+    {
+        return getChains(pts, nullptr);
+    }
+
+    /** \brief
+     * Fill the given vector with start/end indexes of the monotone chains
+     * for the given CoordinateSequence.
+     * The last entry in the array points to the end point of the point
+     * array,
+     * for use as a sentinel.
+     */
+    static void getChainStartIndices(const geom::CoordinateSequence& pts,
+                                     std::vector<std::size_t>& startIndexList);
 
     /**
      * Disable copy construction and assignment. Apparently needed to make this
      * class compile under MSVC. (See https://stackoverflow.com/q/29565299)
      */
-     MonotoneChainBuilder(const MonotoneChainBuilder&) = delete;
-     MonotoneChainBuilder& operator=(const MonotoneChainBuilder&) = delete;
+    MonotoneChainBuilder(const MonotoneChainBuilder&) = delete;
+    MonotoneChainBuilder& operator=(const MonotoneChainBuilder&) = delete;
 
 
 private:
 
-	/**
-	 * Finds the index of the last point in a monotone chain
-	 * starting at a given point.
-	 * Any repeated points (0-length segments) will be included
-	 * in the monotone chain returned.
-	 *
-	 * @return the index of the last point in the monotone chain
-	 *         starting at <code>start</code>.
-	 *
-	 * NOTE: aborts if 'start' is >= pts.getSize()
-	 */
-	static std::size_t findChainEnd(const geom::CoordinateSequence& pts,
-	                                                   std::size_t start);
+    /**
+     * Finds the index of the last point in a monotone chain
+     * starting at a given point.
+     * Any repeated points (0-length segments) will be included
+     * in the monotone chain returned.
+     *
+     * @return the index of the last point in the monotone chain
+     *         starting at <code>start</code>.
+     *
+     * NOTE: aborts if 'start' is >= pts.getSize()
+     */
+    static std::size_t findChainEnd(const geom::CoordinateSequence& pts,
+                                    std::size_t start);
 };
 
 } // namespace geos::index::chain
diff --git a/include/geos/index/chain/MonotoneChainOverlapAction.h b/include/geos/index/chain/MonotoneChainOverlapAction.h
index c9767c9..893e3be 100644
--- a/include/geos/index/chain/MonotoneChainOverlapAction.h
+++ b/include/geos/index/chain/MonotoneChainOverlapAction.h
@@ -25,11 +25,11 @@
 
 // Forward declarations
 namespace geos {
-	namespace index {
-		namespace chain {
-			class MonotoneChain;
-		}
-	}
+namespace index {
+namespace chain {
+class MonotoneChain;
+}
+}
 }
 
 namespace geos {
@@ -44,36 +44,38 @@ class GEOS_DLL MonotoneChainOverlapAction {
 
 protected:
 
-	geom::LineSegment overlapSeg1;
+    geom::LineSegment overlapSeg1;
 
-	geom::LineSegment overlapSeg2;
+    geom::LineSegment overlapSeg2;
 
 public:
 
-	MonotoneChainOverlapAction() {}
-
-	virtual ~MonotoneChainOverlapAction() {}
-
-	/**
-	 * This function can be overridden if the original chains are needed
-	 *
-	 * @param start1 the index of the start of the overlapping segment
-	 *               from mc1
-	 * @param start2 the index of the start of the overlapping segment
-	 *               from mc2
-	 */
-	virtual void overlap(MonotoneChain& mc1, std::size_t start1,
-	                     MonotoneChain& mc2, std::size_t start2);
-
-	/**
-	 * This is a convenience function which can be overridden to
-	 * obtain the actual line segments which overlap
-	 * @param seg1
-	 * @param seg2
-	 */
-	virtual void overlap(const geom::LineSegment& /*seg1*/,
-	                     const geom::LineSegment& /*seg2*/)
-	{}
+    MonotoneChainOverlapAction() {}
+
+    virtual
+    ~MonotoneChainOverlapAction() {}
+
+    /**
+     * This function can be overridden if the original chains are needed
+     *
+     * @param start1 the index of the start of the overlapping segment
+     *               from mc1
+     * @param start2 the index of the start of the overlapping segment
+     *               from mc2
+     */
+    virtual void overlap(MonotoneChain& mc1, std::size_t start1,
+                         MonotoneChain& mc2, std::size_t start2);
+
+    /**
+     * This is a convenience function which can be overridden to
+     * obtain the actual line segments which overlap
+     * @param seg1
+     * @param seg2
+     */
+    virtual void
+    overlap(const geom::LineSegment& /*seg1*/,
+            const geom::LineSegment& /*seg2*/)
+    {}
 
 };
 
diff --git a/include/geos/index/chain/MonotoneChainSelectAction.h b/include/geos/index/chain/MonotoneChainSelectAction.h
index 49bec11..eb7b491 100644
--- a/include/geos/index/chain/MonotoneChainSelectAction.h
+++ b/include/geos/index/chain/MonotoneChainSelectAction.h
@@ -26,11 +26,11 @@
 
 // Forward declarations
 namespace geos {
-	namespace index {
-		namespace chain {
-			class MonotoneChain;
-		}
-	}
+namespace index {
+namespace chain {
+class MonotoneChain;
+}
+}
 }
 
 namespace geos {
@@ -46,24 +46,25 @@ class GEOS_DLL MonotoneChainSelectAction {
 
 protected:
 
-	geom::LineSegment selectedSegment;
+    geom::LineSegment selectedSegment;
 
 public:
 
-	MonotoneChainSelectAction() {}
+    MonotoneChainSelectAction() {}
 
-	virtual ~MonotoneChainSelectAction() {}
+    virtual
+    ~MonotoneChainSelectAction() {}
 
-	/// This function can be overridden if the original chain is needed
-	virtual void select(MonotoneChain& mc, size_t start);
+    /// This function can be overridden if the original chain is needed
+    virtual void select(MonotoneChain& mc, size_t start);
 
-	/**
-	 * This is a convenience function which can be overridden
-	 * to obtain the actual line segment which is selected
-	 *
-	 * @param seg
-	 */
-	virtual void select(const geom::LineSegment& seg) = 0;
+    /**
+     * This is a convenience function which can be overridden
+     * to obtain the actual line segment which is selected
+     *
+     * @param seg
+     */
+    virtual void select(const geom::LineSegment& seg) = 0;
 
 };
 
diff --git a/include/geos/index/intervalrtree/IntervalRTreeBranchNode.h b/include/geos/index/intervalrtree/IntervalRTreeBranchNode.h
index ef7677f..0b7aeba 100644
--- a/include/geos/index/intervalrtree/IntervalRTreeBranchNode.h
+++ b/include/geos/index/intervalrtree/IntervalRTreeBranchNode.h
@@ -22,9 +22,9 @@
 
 // forward declarations
 namespace geos {
-	namespace index {
-		class ItemVisitor;
-	}
+namespace index {
+class ItemVisitor;
+}
 }
 
 
@@ -32,21 +32,20 @@ namespace geos {
 namespace index {
 namespace intervalrtree {
 
-class IntervalRTreeBranchNode : public IntervalRTreeNode
-{
+class IntervalRTreeBranchNode : public IntervalRTreeNode {
 private:
-	const IntervalRTreeNode * node1;
-	const IntervalRTreeNode * node2;
+    const IntervalRTreeNode* node1;
+    const IntervalRTreeNode* node2;
 
 protected:
 public:
-	IntervalRTreeBranchNode( const IntervalRTreeNode * n1, const IntervalRTreeNode * n2)
-	:	IntervalRTreeNode( std::min( n1->getMin(), n2->getMin()), std::max( n1->getMax(), n2->getMax())),
-		node1( n1),
-		node2( n2)
-	{ }
+    IntervalRTreeBranchNode(const IntervalRTreeNode* n1, const IntervalRTreeNode* n2)
+        :	IntervalRTreeNode(std::min(n1->getMin(), n2->getMin()), std::max(n1->getMax(), n2->getMax())),
+          node1(n1),
+          node2(n2)
+    { }
 
-	void query(double queryMin, double queryMax, index::ItemVisitor * visitor) const override;
+    void query(double queryMin, double queryMax, index::ItemVisitor* visitor) const override;
 };
 
 } // geos::intervalrtree
diff --git a/include/geos/index/intervalrtree/IntervalRTreeLeafNode.h b/include/geos/index/intervalrtree/IntervalRTreeLeafNode.h
index b190377..3af6411 100644
--- a/include/geos/index/intervalrtree/IntervalRTreeLeafNode.h
+++ b/include/geos/index/intervalrtree/IntervalRTreeLeafNode.h
@@ -22,9 +22,9 @@
 
 // forward declarations
 namespace geos {
-	namespace index {
-		class ItemVisitor;
-	}
+namespace index {
+class ItemVisitor;
+}
 }
 
 
@@ -32,26 +32,25 @@ namespace geos {
 namespace index {
 namespace intervalrtree {
 
-class IntervalRTreeLeafNode : public IntervalRTreeNode
-{
+class IntervalRTreeLeafNode : public IntervalRTreeNode {
 private:
-	/// externally owned
-	void * item;
+    /// externally owned
+    void* item;
 
 protected:
 public:
 
-	/// @param item externally owned
-	IntervalRTreeLeafNode( double p_min, double p_max, void * p_item)
-	:	IntervalRTreeNode( p_min, p_max),
-		item( p_item)
-	{ }
+    /// @param item externally owned
+    IntervalRTreeLeafNode(double p_min, double p_max, void* p_item)
+        :	IntervalRTreeNode(p_min, p_max),
+          item(p_item)
+    { }
 
-	~IntervalRTreeLeafNode() override
-	{
-	}
+    ~IntervalRTreeLeafNode() override
+    {
+    }
 
-	void query( double queryMin, double queryMax, index::ItemVisitor * visitor) const override;
+    void query(double queryMin, double queryMax, index::ItemVisitor* visitor) const override;
 
 };
 
diff --git a/include/geos/index/intervalrtree/IntervalRTreeNode.h b/include/geos/index/intervalrtree/IntervalRTreeNode.h
index 1dfa07b..6f8bbb7 100644
--- a/include/geos/index/intervalrtree/IntervalRTreeNode.h
+++ b/include/geos/index/intervalrtree/IntervalRTreeNode.h
@@ -22,9 +22,9 @@
 
 // forward declarations
 namespace geos {
-	namespace index {
-		class ItemVisitor;
-	}
+namespace index {
+class ItemVisitor;
+}
 }
 
 
@@ -32,66 +32,71 @@ namespace geos {
 namespace index {
 namespace intervalrtree {
 
-class IntervalRTreeNode
-{
+class IntervalRTreeNode {
 private:
 protected:
-	double min;
-	double max;
+    double min;
+    double max;
 
-	bool intersects( double queryMin, double queryMax) const
-	{
-		if (min > queryMax || max < queryMin)
-			return false;
+    bool
+    intersects(double queryMin, double queryMax) const
+    {
+        if(min > queryMax || max < queryMin) {
+            return false;
+        }
 
-		return true;
-	}
+        return true;
+    }
 
 public:
-	typedef std::vector<const IntervalRTreeNode *> ConstVect;
-
-	IntervalRTreeNode()
-	:	min( DoubleInfinity ),
-		max( DoubleNegInfinity )
-	{ }
-
-	IntervalRTreeNode( double p_min, double p_max)
-	:	min( p_min ),
-		max( p_max )
-	{ }
-
-	virtual ~IntervalRTreeNode()
-	{ }
-
-	double getMin() const
-	{
-		return min;
-	}
-
-	double getMax() const
-	{
-		return max;
-	}
-
-	virtual void query( double queryMin, double queryMax, ItemVisitor * visitor) const =0;
-
-	//std::string toString()
-	//{
-	//	return WKTWriter.toLineString(new Coordinate(min, 0), new Coordinate(max, 0));
-	//}
-
-
-	//class NodeComparator
-	//{
-	//public:
-		static bool compare( const IntervalRTreeNode * n1, const IntervalRTreeNode * n2)
-		{
-			double mid1 = n1->getMin() + n1->getMax();
-			double mid2 = n2->getMin() + n2->getMax();
-
-			return mid1 > mid2;
-		}
-	//};
+    typedef std::vector<const IntervalRTreeNode*> ConstVect;
+
+    IntervalRTreeNode()
+        :	min(DoubleInfinity),
+          max(DoubleNegInfinity)
+    { }
+
+    IntervalRTreeNode(double p_min, double p_max)
+        :	min(p_min),
+          max(p_max)
+    { }
+
+    virtual
+    ~IntervalRTreeNode()
+    { }
+
+    double
+    getMin() const
+    {
+        return min;
+    }
+
+    double
+    getMax() const
+    {
+        return max;
+    }
+
+    virtual void query(double queryMin, double queryMax, ItemVisitor* visitor) const = 0;
+
+    //std::string toString()
+    //{
+    //	return WKTWriter.toLineString(new Coordinate(min, 0), new Coordinate(max, 0));
+    //}
+
+
+    //class NodeComparator
+    //{
+    //public:
+    static bool
+    compare(const IntervalRTreeNode* n1, const IntervalRTreeNode* n2)
+    {
+        double mid1 = n1->getMin() + n1->getMax();
+        double mid2 = n2->getMin() + n2->getMax();
+
+        return mid1 > mid2;
+    }
+    //};
 
 };
 
diff --git a/include/geos/index/intervalrtree/SortedPackedIntervalRTree.h b/include/geos/index/intervalrtree/SortedPackedIntervalRTree.h
index ea8b3f4..2aab524 100644
--- a/include/geos/index/intervalrtree/SortedPackedIntervalRTree.h
+++ b/include/geos/index/intervalrtree/SortedPackedIntervalRTree.h
@@ -22,9 +22,9 @@
 
 // forward declarations
 namespace geos {
-	namespace index {
-		class ItemVisitor;
-	}
+namespace index {
+class ItemVisitor;
+}
 }
 
 namespace geos {
@@ -48,44 +48,46 @@ namespace intervalrtree {
  * @author Martin Davis
  *
  */
-class SortedPackedIntervalRTree
-{
+class SortedPackedIntervalRTree {
 private:
-	std::vector<IntervalRTreeLeafNode> leaves;
-	std::vector<IntervalRTreeBranchNode> branches;
-	const IntervalRTreeNode * root = nullptr;
-	int level = 0;
+    std::vector<IntervalRTreeLeafNode> leaves;
+    std::vector<IntervalRTreeBranchNode> branches;
+    const IntervalRTreeNode* root = nullptr;
+    int level = 0;
 
-	void init();
-	void buildLevel( IntervalRTreeNode::ConstVect & src, IntervalRTreeNode::ConstVect & dest);
-	const IntervalRTreeNode * buildTree();
+    void init();
+    void buildLevel(IntervalRTreeNode::ConstVect& src, IntervalRTreeNode::ConstVect& dest);
+    const IntervalRTreeNode* buildTree();
 
 protected:
 public:
-	SortedPackedIntervalRTree() {}
+    SortedPackedIntervalRTree() {}
 
-	SortedPackedIntervalRTree(std::size_t initialCapacity) { leaves.reserve(initialCapacity); }
+    SortedPackedIntervalRTree(std::size_t initialCapacity)
+    {
+        leaves.reserve(initialCapacity);
+    }
 
-	/**
-	 * Adds an item to the index which is associated with the given interval
-	 *
-	 * @param min the lower bound of the item interval
-	 * @param max the upper bound of the item interval
-	 * @param item the item to insert, ownership left to caller
-	 *
-	 * @throw IllegalStateException if the index has already been queried
-	 */
-	void insert( double min, double max, void * item);
+    /**
+     * Adds an item to the index which is associated with the given interval
+     *
+     * @param min the lower bound of the item interval
+     * @param max the upper bound of the item interval
+     * @param item the item to insert, ownership left to caller
+     *
+     * @throw IllegalStateException if the index has already been queried
+     */
+    void insert(double min, double max, void* item);
 
-	/**
-	 * Search for intervals in the index which intersect the given closed interval
-	 * and apply the visitor to them.
-	 *
-	 * @param min the lower bound of the query interval
-	 * @param max the upper bound of the query interval
-	 * @param visitor the visitor to pass any matched items to
-	 */
-	void query( double min, double max, index::ItemVisitor * visitor);
+    /**
+     * Search for intervals in the index which intersect the given closed interval
+     * and apply the visitor to them.
+     *
+     * @param min the lower bound of the query interval
+     * @param max the upper bound of the query interval
+     * @param visitor the visitor to pass any matched items to
+     */
+    void query(double min, double max, index::ItemVisitor* visitor);
 
 };
 
diff --git a/include/geos/index/quadtree/DoubleBits.h b/include/geos/index/quadtree/DoubleBits.h
index 6972a98..4fa3351 100644
--- a/include/geos/index/quadtree/DoubleBits.h
+++ b/include/geos/index/quadtree/DoubleBits.h
@@ -45,54 +45,54 @@ class GEOS_DLL DoubleBits {
 
 public:
 
-	static const int EXPONENT_BIAS=1023;
+    static const int EXPONENT_BIAS = 1023;
 
-	static double powerOf2(int exp);
+    static double powerOf2(int exp);
 
-	static int exponent(double d);
+    static int exponent(double d);
 
-	static double truncateToPowerOfTwo(double d);
+    static double truncateToPowerOfTwo(double d);
 
-	static std::string toBinaryString(double d);
+    static std::string toBinaryString(double d);
 
-	static double maximumCommonMantissa(double d1, double d2);
+    static double maximumCommonMantissa(double d1, double d2);
 
-	DoubleBits(double nx);
+    DoubleBits(double nx);
 
-	double getDouble() const;
+    double getDouble() const;
 
-	/// Determines the exponent for the number
-	int64 biasedExponent() const;
+    /// Determines the exponent for the number
+    int64 biasedExponent() const;
 
-	/// Determines the exponent for the number
-	int getExponent() const;
+    /// Determines the exponent for the number
+    int getExponent() const;
 
-	void zeroLowerBits(int nBits);
+    void zeroLowerBits(int nBits);
 
-	int getBit(int i) const;
+    int getBit(int i) const;
 
-	/** \brief
-	 * This computes the number of common most-significant bits in
-	 * the mantissa.
-	 *
-	 * It does not count the hidden bit, which is always 1.
-	 * It does not determine whether the numbers have the same exponent;
-	 * if they do not, the value computed by this function is meaningless.
-	 *
-	 * @param db
-	 *
-	 * @return the number of common most-significant mantissa bits
-	 */
-	int numCommonMantissaBits(const DoubleBits& db) const;
+    /** \brief
+     * This computes the number of common most-significant bits in
+     * the mantissa.
+     *
+     * It does not count the hidden bit, which is always 1.
+     * It does not determine whether the numbers have the same exponent;
+     * if they do not, the value computed by this function is meaningless.
+     *
+     * @param db
+     *
+     * @return the number of common most-significant mantissa bits
+     */
+    int numCommonMantissaBits(const DoubleBits& db) const;
 
-	/// A representation of the Double bits formatted for easy readability
-	std::string toString() const;
+    /// A representation of the Double bits formatted for easy readability
+    std::string toString() const;
 
 private:
 
-	double x;
+    double x;
 
-	int64 xBits;
+    int64 xBits;
 };
 
 } // namespace geos::index::quadtree
diff --git a/include/geos/index/quadtree/IntervalSize.h b/include/geos/index/quadtree/IntervalSize.h
index 698dcfb..edc7ad8 100644
--- a/include/geos/index/quadtree/IntervalSize.h
+++ b/include/geos/index/quadtree/IntervalSize.h
@@ -40,21 +40,21 @@ namespace quadtree { // geos::index::quadtree
  */
 class GEOS_DLL IntervalSize {
 public:
-	/**
-	 * This value is chosen to be a few powers of 2 less than the
-	 * number of bits available in the double representation (i.e. 53).
-	 * This should allow enough extra precision for simple computations
-	 * to be correct, at least for comparison purposes.
-	 */
-	static const int MIN_BINARY_EXPONENT = -50;
+    /**
+     * This value is chosen to be a few powers of 2 less than the
+     * number of bits available in the double representation (i.e. 53).
+     * This should allow enough extra precision for simple computations
+     * to be correct, at least for comparison purposes.
+     */
+    static const int MIN_BINARY_EXPONENT = -50;
 
-	/**
-	 * Computes whether the interval [min, max] is effectively zero width.
-	 * I.e. the width of the interval is so much less than the
-	 * location of the interval that the midpoint of the interval
-	 * cannot be represented precisely.
-	 */
-	static bool isZeroWidth(double min, double max);
+    /**
+     * Computes whether the interval [min, max] is effectively zero width.
+     * I.e. the width of the interval is so much less than the
+     * location of the interval that the midpoint of the interval
+     * cannot be represented precisely.
+     */
+    static bool isZeroWidth(double min, double max);
 };
 
 } // namespace geos::index::quadtree
diff --git a/include/geos/index/quadtree/Key.h b/include/geos/index/quadtree/Key.h
index a862c03..f003864 100644
--- a/include/geos/index/quadtree/Key.h
+++ b/include/geos/index/quadtree/Key.h
@@ -42,44 +42,44 @@ namespace quadtree { // geos::index::quadtree
 class GEOS_DLL Key {
 public:
 
-	// Doesn't touch the Envelope, might as well be const
-	static int computeQuadLevel(const geom::Envelope& env);
+    // Doesn't touch the Envelope, might as well be const
+    static int computeQuadLevel(const geom::Envelope& env);
 
-	// Reference to argument won't be used after construction
-	Key(const geom::Envelope& itemEnv);
+    // Reference to argument won't be used after construction
+    Key(const geom::Envelope& itemEnv);
 
-	// used to be virtual, but I don't see subclasses...
-	~Key();
+    // used to be virtual, but I don't see subclasses...
+    ~Key();
 
-	/// Returned object ownership retained by this class
-	const geom::Coordinate& getPoint() const;
+    /// Returned object ownership retained by this class
+    const geom::Coordinate& getPoint() const;
 
-	int getLevel() const;
+    int getLevel() const;
 
-	/// Returned object ownership retained by this class
-	const geom::Envelope& getEnvelope() const;
+    /// Returned object ownership retained by this class
+    const geom::Envelope& getEnvelope() const;
 
-	/// Returns newly allocated object (ownership transferred)
-	geom::Coordinate* getCentre() const;
+    /// Returns newly allocated object (ownership transferred)
+    geom::Coordinate* getCentre() const;
 
-	/**
-	 * return a square envelope containing the argument envelope,
-	 * whose extent is a power of two and which is based at a power of 2
-	 */
-	void computeKey(const geom::Envelope& itemEnv);
+    /**
+     * return a square envelope containing the argument envelope,
+     * whose extent is a power of two and which is based at a power of 2
+     */
+    void computeKey(const geom::Envelope& itemEnv);
 
 private:
-	// the fields which make up the key
+    // the fields which make up the key
 
-	// Owned by this class
-	geom::Coordinate pt;
+    // Owned by this class
+    geom::Coordinate pt;
 
-	int level;
+    int level;
 
-	// auxiliary data which is derived from the key for use in computation
-	geom::Envelope env;
+    // auxiliary data which is derived from the key for use in computation
+    geom::Envelope env;
 
-	void computeKey(int level, const geom::Envelope& itemEnv);
+    void computeKey(int level, const geom::Envelope& itemEnv);
 };
 
 } // namespace geos::index::quadtree
diff --git a/include/geos/index/quadtree/Node.h b/include/geos/index/quadtree/Node.h
index 5b01f50..afcd63d 100644
--- a/include/geos/index/quadtree/Node.h
+++ b/include/geos/index/quadtree/Node.h
@@ -34,10 +34,10 @@
 
 // Forward declarations
 namespace geos {
-	namespace geom {
-		//class Coordinate;
-		class Envelope;
-	}
+namespace geom {
+//class Coordinate;
+class Envelope;
+}
 }
 
 namespace geos {
@@ -56,73 +56,79 @@ class GEOS_DLL Node: public NodeBase {
 
 private:
 
-	/// Owned by this class
-	std::unique_ptr<geom::Envelope> env;
+    /// Owned by this class
+    std::unique_ptr<geom::Envelope> env;
 
-	geom::Coordinate centre;
+    geom::Coordinate centre;
 
-	int level;
+    int level;
 
-	/**
-	 * Get the subquad for the index.
-	 * If it doesn't exist, create it.
-	 *
-	 * Ownership of the returned object belongs to this class.
-	 */
-	Node* getSubnode(int index);
+    /**
+     * Get the subquad for the index.
+     * If it doesn't exist, create it.
+     *
+     * Ownership of the returned object belongs to this class.
+     */
+    Node* getSubnode(int index);
 
-	std::unique_ptr<Node> createSubnode(int index);
+    std::unique_ptr<Node> createSubnode(int index);
 
 protected:
 
-	bool isSearchMatch(const geom::Envelope& searchEnv) const override {
-		return env->intersects(searchEnv);
-	}
+    bool
+    isSearchMatch(const geom::Envelope& searchEnv) const override
+    {
+        return env->intersects(searchEnv);
+    }
 
 public:
 
-	// Create a node computing level from given envelope
-	static std::unique_ptr<Node> createNode(const geom::Envelope& env);
-
-	/// Create a node containing the given node and envelope
-	//
-	/// @param node if not null, will be inserted to the returned node
-	/// @param addEnv minimum envelope to use for the node
-	///
-	static std::unique_ptr<Node> createExpanded(std::unique_ptr<Node> node,
-			const geom::Envelope& addEnv);
-
-	Node(std::unique_ptr<geom::Envelope> nenv, int nlevel)
-		:
-		env(std::move(nenv)),
-		centre((env->getMinX()+env->getMaxX())/2,
-			(env->getMinY()+env->getMaxY())/2),
-		level(nlevel)
-	{
-	}
-
-	~Node() override {}
-
-	/// Return Envelope associated with this node
-	/// ownership retained by this object
-	geom::Envelope* getEnvelope() { return env.get(); }
-
-	/** \brief
-	 * Returns the subquad containing the envelope.
-	 * Creates the subquad if
-	 * it does not already exist.
-	 */
-	Node* getNode(const geom::Envelope *searchEnv);
-
-	/** \brief
-	 * Returns the smallest <i>existing</i>
-	 * node containing the envelope.
-	 */
-	NodeBase* find(const geom::Envelope *searchEnv);
-
-	void insertNode(std::unique_ptr<Node> node);
-
-	std::string toString() const override;
+    // Create a node computing level from given envelope
+    static std::unique_ptr<Node> createNode(const geom::Envelope& env);
+
+    /// Create a node containing the given node and envelope
+    //
+    /// @param node if not null, will be inserted to the returned node
+    /// @param addEnv minimum envelope to use for the node
+    ///
+    static std::unique_ptr<Node> createExpanded(std::unique_ptr<Node> node,
+            const geom::Envelope& addEnv);
+
+    Node(std::unique_ptr<geom::Envelope> nenv, int nlevel)
+        :
+        env(std::move(nenv)),
+        centre((env->getMinX() + env->getMaxX()) / 2,
+               (env->getMinY() + env->getMaxY()) / 2),
+        level(nlevel)
+    {
+    }
+
+    ~Node() override {}
+
+    /// Return Envelope associated with this node
+    /// ownership retained by this object
+    geom::Envelope*
+    getEnvelope()
+    {
+        return env.get();
+    }
+
+    /** \brief
+     * Returns the subquad containing the envelope.
+     * Creates the subquad if
+     * it does not already exist.
+     */
+    Node* getNode(const geom::Envelope* searchEnv);
+
+    /** \brief
+     * Returns the smallest <i>existing</i>
+     * node containing the envelope.
+     */
+    NodeBase* find(const geom::Envelope* searchEnv);
+
+    void insertNode(std::unique_ptr<Node> node);
+
+    std::string toString() const override;
 
 };
 
diff --git a/include/geos/index/quadtree/NodeBase.h b/include/geos/index/quadtree/NodeBase.h
index 4d9d76e..b306834 100644
--- a/include/geos/index/quadtree/NodeBase.h
+++ b/include/geos/index/quadtree/NodeBase.h
@@ -31,16 +31,16 @@
 
 // Forward declarations
 namespace geos {
-	namespace geom {
-		class Coordinate;
-		class Envelope;
-	}
-	namespace index {
-		class ItemVisitor;
-		namespace quadtree {
-			class Node;
-		}
-	}
+namespace geom {
+class Coordinate;
+class Envelope;
+}
+namespace index {
+class ItemVisitor;
+namespace quadtree {
+class Node;
+}
+}
 }
 
 namespace geos {
@@ -56,73 +56,73 @@ class GEOS_DLL NodeBase {
 
 private:
 
-	void visitItems(const geom::Envelope* searchEnv,
-			ItemVisitor& visitor);
+    void visitItems(const geom::Envelope* searchEnv,
+                    ItemVisitor& visitor);
 
 public:
 
-	static int getSubnodeIndex(const geom::Envelope *env,
-			const geom::Coordinate& centre);
+    static int getSubnodeIndex(const geom::Envelope* env,
+                               const geom::Coordinate& centre);
 
-	NodeBase();
+    NodeBase();
 
-	virtual ~NodeBase();
+    virtual ~NodeBase();
 
-	std::vector<void*>& getItems();
+    std::vector<void*>& getItems();
 
-	/// Add an item to this node.
-	/// Ownership of the item is left to caller.
-	void add(void* item);
+    /// Add an item to this node.
+    /// Ownership of the item is left to caller.
+    void add(void* item);
 
-	/// Push all node items to the given vector, return the argument
-	std::vector<void*>& addAllItems(std::vector<void*>& resultItems) const;
+    /// Push all node items to the given vector, return the argument
+    std::vector<void*>& addAllItems(std::vector<void*>& resultItems) const;
 
-	virtual void addAllItemsFromOverlapping(const geom::Envelope& searchEnv,
-			std::vector<void*>& resultItems) const;
+    virtual void addAllItemsFromOverlapping(const geom::Envelope& searchEnv,
+                                            std::vector<void*>& resultItems) const;
 
-	unsigned int depth() const;
+    unsigned int depth() const;
 
-	size_t size() const;
+    size_t size() const;
 
-	size_t getNodeCount() const;
+    size_t getNodeCount() const;
 
-	virtual std::string toString() const;
+    virtual std::string toString() const;
 
-	virtual void visit(const geom::Envelope* searchEnv, ItemVisitor& visitor);
+    virtual void visit(const geom::Envelope* searchEnv, ItemVisitor& visitor);
 
-	/**
-	 * Removes a single item from this subtree.
-	 *
-	 * @param searchEnv the envelope containing the item
-	 * @param item the item to remove
-	 * @return <code>true</code> if the item was found and removed
-	 */
-	bool remove(const geom::Envelope* itemEnv, void* item);
+    /**
+     * Removes a single item from this subtree.
+     *
+     * @param searchEnv the envelope containing the item
+     * @param item the item to remove
+     * @return <code>true</code> if the item was found and removed
+     */
+    bool remove(const geom::Envelope* itemEnv, void* item);
 
-	bool hasItems() const;
+    bool hasItems() const;
 
-	bool hasChildren() const;
+    bool hasChildren() const;
 
-	bool isPrunable() const;
+    bool isPrunable() const;
 
 protected:
 
-	/// Actual items are NOT owned by this class
-	std::vector<void*> items;
-
-	/**
-	 * subquads are numbered as follows:
-	 * <pre>
-	 *  2 | 3
-	 *  --+--
-	 *  0 | 1
-	 * </pre>
-	 *
-	 * Nodes are owned by this class
-	 */
-	std::array<Node*, 4> subnodes;
-
-	virtual bool isSearchMatch(const geom::Envelope& searchEnv) const=0;
+    /// Actual items are NOT owned by this class
+    std::vector<void*> items;
+
+    /**
+     * subquads are numbered as follows:
+     * <pre>
+     *  2 | 3
+     *  --+--
+     *  0 | 1
+     * </pre>
+     *
+     * Nodes are owned by this class
+     */
+    std::array<Node*, 4> subnodes;
+
+    virtual bool isSearchMatch(const geom::Envelope& searchEnv) const = 0;
 };
 
 
@@ -131,24 +131,25 @@ protected:
 inline bool
 NodeBase::hasChildren() const
 {
-	for (const auto& subnode : subnodes) {
-		if (subnode != nullptr)
-			return true;
-	}
+    for(const auto& subnode : subnodes) {
+        if(subnode != nullptr) {
+            return true;
+        }
+    }
 
-	return false;
+    return false;
 }
 
 inline bool
 NodeBase::isPrunable() const
 {
-	return ! (hasChildren() || hasItems());
+    return !(hasChildren() || hasItems());
 }
 
 inline bool
 NodeBase::hasItems() const
 {
-	return ! items.empty();
+    return ! items.empty();
 }
 
 } // namespace geos::index::quadtree
diff --git a/include/geos/index/quadtree/Quadtree.h b/include/geos/index/quadtree/Quadtree.h
index d541e40..be07ad2 100644
--- a/include/geos/index/quadtree/Quadtree.h
+++ b/include/geos/index/quadtree/Quadtree.h
@@ -35,11 +35,11 @@
 
 // Forward declarations
 namespace geos {
-	namespace index {
-		namespace quadtree {
-			// class Root;
-		}
-	}
+namespace index {
+namespace quadtree {
+// class Root;
+}
+}
 }
 
 namespace geos {
@@ -72,121 +72,122 @@ class GEOS_DLL Quadtree: public SpatialIndex {
 
 private:
 
-	std::vector<std::unique_ptr<geom::Envelope>> newEnvelopes;
+    std::vector<std::unique_ptr<geom::Envelope>> newEnvelopes;
 
-	void collectStats(const geom::Envelope& itemEnv);
+    void collectStats(const geom::Envelope& itemEnv);
 
-	Root root;
+    Root root;
 
-	/**
-	 *  Statistics
-	 *
-	 * minExtent is the minimum envelope extent of all items
-	 * inserted into the tree so far. It is used as a heuristic value
-	 * to construct non-zero envelopes for features with zero X and/or
-	 * Y extent.
-	 * Start with a non-zero extent, in case the first feature inserted has
-	 * a zero extent in both directions.  This value may be non-optimal, but
-	 * only one feature will be inserted with this value.
-	 */
-	double minExtent;
+    /**
+     *  Statistics
+     *
+     * minExtent is the minimum envelope extent of all items
+     * inserted into the tree so far. It is used as a heuristic value
+     * to construct non-zero envelopes for features with zero X and/or
+     * Y extent.
+     * Start with a non-zero extent, in case the first feature inserted has
+     * a zero extent in both directions.  This value may be non-optimal, but
+     * only one feature will be inserted with this value.
+     */
+    double minExtent;
 
 public:
-	/**
-	 * \brief
-	 * Ensure that the envelope for the inserted item has non-zero extents.
-	 *
-	 * Use the current minExtent to pad the envelope, if necessary.
-	 * Can return a new Envelope or the given one (casted to non-const).
-	 */
-	static geom::Envelope* ensureExtent(const geom::Envelope *itemEnv,
-			double minExtent);
-
-	/**
-	 * \brief
-	 * Constructs a Quadtree with zero items.
-	 */
-	Quadtree()
-		:
-		root(),
-		minExtent(1.0)
-	{}
-
-	~Quadtree() override = default;
-
-	/// Returns the number of levels in the tree.
-	int depth();
-
-	/// Returns the number of items in the tree.
-	size_t size();
-
-	void insert(const geom::Envelope *itemEnv, void *item) override;
-
-	/** \brief
-	 * Queries the tree and returns items which may lie
-	 * in the given search envelope.
-	 *
-	 * Precisely, the items that are returned are all items in the tree
-	 * whose envelope <b>may</b> intersect the search Envelope.
-	 * Note that some items with non-intersecting envelopes may be
-	 * returned as well;
-	 * the client is responsible for filtering these out.
-	 * In most situations there will be many items in the tree which do not
-	 * intersect the search envelope and which are not returned - thus
-	 * providing improved performance over a simple linear scan.
-	 *
-	 * @param searchEnv the envelope of the desired query area.
-	 * @param ret a vector where items which may intersect the
-	 * 	      search envelope are pushed
-	 */
-	void query(const geom::Envelope *searchEnv, std::vector<void*>& ret) override;
-
-
-	/** \brief
-	 * Queries the tree and visits items which may lie in
-	 * the given search envelope.
-	 *
-	 * Precisely, the items that are visited are all items in the tree
-	 * whose envelope <b>may</b> intersect the search Envelope.
-	 * Note that some items with non-intersecting envelopes may be
-	 * visited as well;
-	 * the client is responsible for filtering these out.
-	 * In most situations there will be many items in the tree which do not
-	 * intersect the search envelope and which are not visited - thus
-	 * providing improved performance over a simple linear scan.
-	 *
-	 * @param searchEnv the envelope of the desired query area.
-	 * @param visitor a visitor object which is passed the visited items
-	 */
-	void query(const geom::Envelope *searchEnv, ItemVisitor& visitor) override
-	{
-		/*
-		 * the items that are matched are the items in quads which
-		 * overlap the search envelope
-		 */
-		root.visit(searchEnv, visitor);
-	}
-
-	/**
-	 * Removes a single item from the tree.
-	 *
-	 * @param itemEnv the Envelope of the item to be removed
-	 * @param item the item to remove
-	 * @return <code>true</code> if the item was found (and thus removed)
-	 */
-	bool remove(const geom::Envelope* itemEnv, void* item) override;
-
-	/// Return a list of all items in the Quadtree
-	std::vector<void*>* queryAll();
-
-	std::string toString() const;
+    /**
+     * \brief
+     * Ensure that the envelope for the inserted item has non-zero extents.
+     *
+     * Use the current minExtent to pad the envelope, if necessary.
+     * Can return a new Envelope or the given one (casted to non-const).
+     */
+    static geom::Envelope* ensureExtent(const geom::Envelope* itemEnv,
+                                        double minExtent);
+
+    /**
+     * \brief
+     * Constructs a Quadtree with zero items.
+     */
+    Quadtree()
+        :
+        root(),
+        minExtent(1.0)
+    {}
+
+    ~Quadtree() override = default;
+
+    /// Returns the number of levels in the tree.
+    int depth();
+
+    /// Returns the number of items in the tree.
+    size_t size();
+
+    void insert(const geom::Envelope* itemEnv, void* item) override;
+
+    /** \brief
+     * Queries the tree and returns items which may lie
+     * in the given search envelope.
+     *
+     * Precisely, the items that are returned are all items in the tree
+     * whose envelope <b>may</b> intersect the search Envelope.
+     * Note that some items with non-intersecting envelopes may be
+     * returned as well;
+     * the client is responsible for filtering these out.
+     * In most situations there will be many items in the tree which do not
+     * intersect the search envelope and which are not returned - thus
+     * providing improved performance over a simple linear scan.
+     *
+     * @param searchEnv the envelope of the desired query area.
+     * @param ret a vector where items which may intersect the
+     * 	      search envelope are pushed
+     */
+    void query(const geom::Envelope* searchEnv, std::vector<void*>& ret) override;
+
+
+    /** \brief
+     * Queries the tree and visits items which may lie in
+     * the given search envelope.
+     *
+     * Precisely, the items that are visited are all items in the tree
+     * whose envelope <b>may</b> intersect the search Envelope.
+     * Note that some items with non-intersecting envelopes may be
+     * visited as well;
+     * the client is responsible for filtering these out.
+     * In most situations there will be many items in the tree which do not
+     * intersect the search envelope and which are not visited - thus
+     * providing improved performance over a simple linear scan.
+     *
+     * @param searchEnv the envelope of the desired query area.
+     * @param visitor a visitor object which is passed the visited items
+     */
+    void
+    query(const geom::Envelope* searchEnv, ItemVisitor& visitor) override
+    {
+        /*
+         * the items that are matched are the items in quads which
+         * overlap the search envelope
+         */
+        root.visit(searchEnv, visitor);
+    }
+
+    /**
+     * Removes a single item from the tree.
+     *
+     * @param itemEnv the Envelope of the item to be removed
+     * @param item the item to remove
+     * @return <code>true</code> if the item was found (and thus removed)
+     */
+    bool remove(const geom::Envelope* itemEnv, void* item) override;
+
+    /// Return a list of all items in the Quadtree
+    std::vector<void*>* queryAll();
+
+    std::string toString() const;
 
     /**
      * Disable copy construction and assignment. Apparently needed to make this
      * class compile under MSVC. (See https://stackoverflow.com/q/29565299)
      */
-     Quadtree(const Quadtree&) = delete;
-     Quadtree& operator=(const Quadtree&) = delete;
+    Quadtree(const Quadtree&) = delete;
+    Quadtree& operator=(const Quadtree&) = delete;
 
 };
 
diff --git a/include/geos/index/quadtree/Root.h b/include/geos/index/quadtree/Root.h
index 98342c9..65ed66d 100644
--- a/include/geos/index/quadtree/Root.h
+++ b/include/geos/index/quadtree/Root.h
@@ -25,14 +25,14 @@
 
 // Forward declarations
 namespace geos {
-	namespace geom {
-		class Envelope;
-	}
-	namespace index {
-		namespace quadtree {
-			class Node;
-		}
-	}
+namespace geom {
+class Envelope;
+}
+namespace index {
+namespace quadtree {
+class Node;
+}
+}
 }
 
 namespace geos {
@@ -51,32 +51,34 @@ class GEOS_DLL Root: public NodeBase {
 
 private:
 
-	static const geom::Coordinate origin;
+    static const geom::Coordinate origin;
 
-	/**
-	 * insert an item which is known to be contained in the tree rooted at
-	 * the given QuadNode root.  Lower levels of the tree will be created
-	 * if necessary to hold the item.
-	 */
-	void insertContained(Node *tree, const geom::Envelope *itemEnv,
-	                     void* item);
+    /**
+     * insert an item which is known to be contained in the tree rooted at
+     * the given QuadNode root.  Lower levels of the tree will be created
+     * if necessary to hold the item.
+     */
+    void insertContained(Node* tree, const geom::Envelope* itemEnv,
+                         void* item);
 
 public:
 
-	Root() {}
+    Root() {}
 
-	~Root() override {}
+    ~Root() override {}
 
-	/**
-	 * Insert an item into the quadtree this is the root of.
-	 */
-	void insert(const geom::Envelope *itemEnv, void* item);
+    /**
+     * Insert an item into the quadtree this is the root of.
+     */
+    void insert(const geom::Envelope* itemEnv, void* item);
 
 protected:
 
-	bool isSearchMatch(const geom::Envelope& /* searchEnv */) const override {
-		return true;
-	}
+    bool
+    isSearchMatch(const geom::Envelope& /* searchEnv */) const override
+    {
+        return true;
+    }
 
 };
 
diff --git a/include/geos/index/strtree/AbstractNode.h b/include/geos/index/strtree/AbstractNode.h
index f1802d7..97080db 100644
--- a/include/geos/index/strtree/AbstractNode.h
+++ b/include/geos/index/strtree/AbstractNode.h
@@ -42,47 +42,51 @@ namespace strtree { // geos::index::strtree
  */
 class GEOS_DLL AbstractNode: public Boundable {
 private:
-	std::vector<Boundable*> childBoundables;
-	int level;
+    std::vector<Boundable*> childBoundables;
+    int level;
 public:
-	AbstractNode(int newLevel, size_t capacity = 10);
-		~AbstractNode() override;
-
-	// TODO: change signature to return by ref,
-	// document ownership of the return
-	inline std::vector<Boundable*>* getChildBoundables() {
-		return &childBoundables;
-	}
-
-	// TODO: change signature to return by ref,
-	// document ownership of the return
-	inline const std::vector<Boundable*>* getChildBoundables() const {
-		return &childBoundables;
-	}
-
-	/**
-	 * Returns a representation of space that encloses this Boundable,
-	 * preferably not much bigger than this Boundable's boundary yet fast to
-	 * test for intersection with the bounds of other Boundables.
-	 * The class of object returned depends on the subclass of
-	 * AbstractSTRtree.
-	 *
-	 * @return an Envelope (for STRtrees), an Interval (for SIRtrees),
-	 *	or other object (for other subclasses of AbstractSTRtree)
-	 *
-	 * @see AbstractSTRtree::IntersectsOp
-	 */
-	const void* getBounds() const override;
-
-	int getLevel();
-
-	void addChildBoundable(Boundable *childBoundable);
+    AbstractNode(int newLevel, size_t capacity = 10);
+    ~AbstractNode() override;
+
+    // TODO: change signature to return by ref,
+    // document ownership of the return
+    inline std::vector<Boundable*>*
+    getChildBoundables()
+    {
+        return &childBoundables;
+    }
+
+    // TODO: change signature to return by ref,
+    // document ownership of the return
+    inline const std::vector<Boundable*>*
+    getChildBoundables() const
+    {
+        return &childBoundables;
+    }
+
+    /**
+     * Returns a representation of space that encloses this Boundable,
+     * preferably not much bigger than this Boundable's boundary yet fast to
+     * test for intersection with the bounds of other Boundables.
+     * The class of object returned depends on the subclass of
+     * AbstractSTRtree.
+     *
+     * @return an Envelope (for STRtrees), an Interval (for SIRtrees),
+     *	or other object (for other subclasses of AbstractSTRtree)
+     *
+     * @see AbstractSTRtree::IntersectsOp
+     */
+    const void* getBounds() const override;
+
+    int getLevel();
+
+    void addChildBoundable(Boundable* childBoundable);
 
 protected:
 
-	virtual void* computeBounds() const=0;
+    virtual void* computeBounds() const = 0;
 
-	mutable void* bounds;
+    mutable void* bounds;
 };
 
 
diff --git a/include/geos/index/strtree/AbstractSTRtree.h b/include/geos/index/strtree/AbstractSTRtree.h
index 719ce8b..589be45 100644
--- a/include/geos/index/strtree/AbstractSTRtree.h
+++ b/include/geos/index/strtree/AbstractSTRtree.h
@@ -27,13 +27,13 @@
 
 // Forward declarations
 namespace geos {
-	namespace index {
-		class ItemVisitor;
-		namespace strtree {
-			class Boundable;
-			class AbstractNode;
-		}
-	}
+namespace index {
+class ItemVisitor;
+namespace strtree {
+class Boundable;
+class AbstractNode;
+}
+}
 }
 
 namespace geos {
@@ -48,33 +48,38 @@ typedef std::vector<Boundable*> BoundableList;
 /// this class, the plain boundables are held by reference only.
 class ItemsList;
 
-class ItemsListItem
-{
+class ItemsListItem {
 public:
     enum type {
         item_is_geometry,
         item_is_list
     };
 
-    ItemsListItem(void *item_)
-      : t(item_is_geometry)
+    ItemsListItem(void* item_)
+        : t(item_is_geometry)
     {
         item.g = item_;
     }
     ItemsListItem(ItemsList* item_)
-      : t(item_is_list)
+        : t(item_is_list)
     {
         item.l = item_;
     }
 
-    type get_type() const { return t; }
+    type
+    get_type() const
+    {
+        return t;
+    }
 
-    void* get_geometry() const
+    void*
+    get_geometry() const
     {
         assert(t == item_is_geometry);
         return item.g;
     }
-    ItemsList* get_itemslist() const
+    ItemsList*
+    get_itemslist() const
     {
         assert(t == item_is_list);
         return item.l;
@@ -87,15 +92,16 @@ public:
     } item;
 };
 
-class ItemsList : public std::vector<ItemsListItem>
-{
+class ItemsList : public std::vector<ItemsListItem> {
 private:
     typedef std::vector<ItemsListItem> base_type;
 
-    static void delete_item(ItemsListItem& item)
+    static void
+    delete_item(ItemsListItem& item)
     {
-        if (ItemsListItem::item_is_list == item.t)
+        if(ItemsListItem::item_is_list == item.t) {
             delete item.item.l;
+        }
     }
 
 public:
@@ -105,13 +111,15 @@ public:
     }
 
     // lists of items need to be deleted in the end
-    void push_back(void* item)
+    void
+    push_back(void* item)
     {
         this->base_type::push_back(ItemsListItem(item));
     }
 
     // lists of items need to be deleted in the end
-    void push_back_owned(ItemsList* itemList)
+    void
+    push_back_owned(ItemsList* itemList)
     {
         this->base_type::push_back(ItemsListItem(itemList));
     }
@@ -132,168 +140,180 @@ public:
 class GEOS_DLL AbstractSTRtree {
 
 private:
-	bool built;
-	BoundableList* itemBoundables;
-
-	/**
-	 * Creates the levels higher than the given level
-	 *
-	 * @param boundablesOfALevel
-	 *            the level to build on
-	 * @param level
-	 *            the level of the Boundables, or -1 if the boundables are item
-	 *            boundables (that is, below level 0)
-	 * @return the root, which may be a ParentNode or a LeafNode
-	 */
-	virtual AbstractNode* createHigherLevels(
-			BoundableList* boundablesOfALevel,
-			int level);
-
-	virtual std::unique_ptr<BoundableList> sortBoundables(const BoundableList* input)=0;
-
-	bool remove(const void* searchBounds, AbstractNode& node, void* item);
-	bool removeItem(AbstractNode& node, void* item);
+    bool built;
+    BoundableList* itemBoundables;
+
+    /**
+     * Creates the levels higher than the given level
+     *
+     * @param boundablesOfALevel
+     *            the level to build on
+     * @param level
+     *            the level of the Boundables, or -1 if the boundables are item
+     *            boundables (that is, below level 0)
+     * @return the root, which may be a ParentNode or a LeafNode
+     */
+    virtual AbstractNode* createHigherLevels(
+        BoundableList* boundablesOfALevel,
+        int level);
+
+    virtual std::unique_ptr<BoundableList> sortBoundables(const BoundableList* input) = 0;
+
+    bool remove(const void* searchBounds, AbstractNode& node, void* item);
+    bool removeItem(AbstractNode& node, void* item);
 
     ItemsList* itemsTree(AbstractNode* node);
 
 protected:
 
-	/** \brief
-	 * A test for intersection between two bounds, necessary because
-	 * subclasses of AbstractSTRtree have different implementations of
-	 * bounds.
-	 */
-	class GEOS_DLL IntersectsOp {
-		public:
-			/**
-			 * For STRtrees, the bounds will be Envelopes; for
-			 * SIRtrees, Intervals; for other subclasses of
-			 * AbstractSTRtree, some other class.
-			 * @param aBounds the bounds of one spatial object
-			 * @param bBounds the bounds of another spatial object
-			 * @return whether the two bounds intersect
-			 */
-			virtual bool intersects(const void* aBounds,
-					const void* bBounds)=0;
-
-			virtual ~IntersectsOp() {}
-	};
-
-	AbstractNode *root;
-
-	std::vector <AbstractNode *> *nodes;
-
-	// Ownership to caller (TODO: return by unique_ptr)
-	virtual AbstractNode* createNode(int level)=0;
-
-	/**
-	 * Sorts the childBoundables then divides them into groups of size M, where
-	 * M is the node capacity.
-	 */
-	virtual std::unique_ptr<BoundableList> createParentBoundables(
-			BoundableList* childBoundables, int newLevel);
-
-	virtual AbstractNode* lastNode(BoundableList* nodeList)
-	{
-		assert(!nodeList->empty());
-		// Cast from Boundable to AbstractNode
-		return static_cast<AbstractNode*>(nodeList->back() );
-	}
-
-	virtual AbstractNode* getRoot() {
-                assert(built);
-		return root;
-	}
-
-	///  Also builds the tree, if necessary.
-	virtual void insert(const void* bounds,void* item);
-
-	///  Also builds the tree, if necessary.
-	void query(const void* searchBounds, std::vector<void*>& foundItems);
+    /** \brief
+     * A test for intersection between two bounds, necessary because
+     * subclasses of AbstractSTRtree have different implementations of
+     * bounds.
+     */
+    class GEOS_DLL IntersectsOp {
+    public:
+        /**
+         * For STRtrees, the bounds will be Envelopes; for
+         * SIRtrees, Intervals; for other subclasses of
+         * AbstractSTRtree, some other class.
+         * @param aBounds the bounds of one spatial object
+         * @param bBounds the bounds of another spatial object
+         * @return whether the two bounds intersect
+         */
+        virtual bool intersects(const void* aBounds,
+                                const void* bBounds) = 0;
+
+        virtual
+        ~IntersectsOp() {}
+    };
+
+    AbstractNode* root;
+
+    std::vector <AbstractNode*>* nodes;
+
+    // Ownership to caller (TODO: return by unique_ptr)
+    virtual AbstractNode* createNode(int level) = 0;
+
+    /**
+     * Sorts the childBoundables then divides them into groups of size M, where
+     * M is the node capacity.
+     */
+    virtual std::unique_ptr<BoundableList> createParentBoundables(
+        BoundableList* childBoundables, int newLevel);
+
+    virtual AbstractNode*
+    lastNode(BoundableList* nodeList)
+    {
+        assert(!nodeList->empty());
+        // Cast from Boundable to AbstractNode
+        return static_cast<AbstractNode*>(nodeList->back());
+    }
+
+    virtual AbstractNode*
+    getRoot()
+    {
+        assert(built);
+        return root;
+    }
+
+    ///  Also builds the tree, if necessary.
+    virtual void insert(const void* bounds, void* item);
+
+    ///  Also builds the tree, if necessary.
+    void query(const void* searchBounds, std::vector<void*>& foundItems);
 
 #if 0
-	///  Also builds the tree, if necessary.
-	std::vector<void*>* query(const void* searchBounds) {
-		vector<void*>* matches = new vector<void*>();
-		query(searchBounds, *matches);
-		return matches;
-	}
+    ///  Also builds the tree, if necessary.
+    std::vector<void*>*
+    query(const void* searchBounds)
+    {
+        vector<void*>* matches = new vector<void*>();
+        query(searchBounds, *matches);
+        return matches;
+    }
 #endif
-	///  Also builds the tree, if necessary.
-	void query(const void* searchBounds, ItemVisitor& visitor);
+    ///  Also builds the tree, if necessary.
+    void query(const void* searchBounds, ItemVisitor& visitor);
 
-	void query(const void* searchBounds, const AbstractNode& node, ItemVisitor& visitor);
+    void query(const void* searchBounds, const AbstractNode& node, ItemVisitor& visitor);
 
-	///  Also builds the tree, if necessary.
-	bool remove(const void* itemEnv, void* item);
+    ///  Also builds the tree, if necessary.
+    bool remove(const void* itemEnv, void* item);
 
-	std::unique_ptr<BoundableList> boundablesAtLevel(int level);
+    std::unique_ptr<BoundableList> boundablesAtLevel(int level);
 
-	// @@ should be size_t, probably
-	std::size_t nodeCapacity;
+    // @@ should be size_t, probably
+    std::size_t nodeCapacity;
 
-	/**
-	 * @return a test for intersection between two bounds,
-	 * necessary because subclasses
-	 * of AbstractSTRtree have different implementations of bounds.
-	 * @see IntersectsOp
-	 */
-	virtual IntersectsOp *getIntersectsOp()=0;
+    /**
+     * @return a test for intersection between two bounds,
+     * necessary because subclasses
+     * of AbstractSTRtree have different implementations of bounds.
+     * @see IntersectsOp
+     */
+    virtual IntersectsOp* getIntersectsOp() = 0;
 
 
 public:
 
-	/**
-	 * Constructs an AbstractSTRtree with the specified maximum number of child
-	 * nodes that a node may have
-	 */
-	AbstractSTRtree(std::size_t newNodeCapacity)
-		:
-		built(false),
-		itemBoundables(new BoundableList()),
-		nodes(new std::vector<AbstractNode *>()),
-		nodeCapacity(newNodeCapacity)
-	{
-		assert(newNodeCapacity>1);
-	}
-
-	static bool compareDoubles(double a, double b) {
-		// NOTE - strk:
-		// Ternary operation is a workaround for
-		// a probable MingW bug, see
-		// http://trac.osgeo.org/geos/ticket/293
-		return ( a < b ) ? true : false;
-	}
-
-	virtual ~AbstractSTRtree();
-
-	/**
-	 * Creates parent nodes, grandparent nodes, and so forth up to the root
-	 * node, for the data that has been inserted into the tree. Can only be
-	 * called once, and thus can be called only after all of the data has been
-	 * inserted into the tree.
-	 */
-	virtual void build();
-
-	/**
-	 * Returns the maximum number of child nodes that a node may have
-	 */
-	virtual std::size_t getNodeCapacity() { return nodeCapacity; }
-
-	virtual void query(const void* searchBounds, const AbstractNode* node, std::vector<void*>* matches);
-
-	/**
+    /**
+     * Constructs an AbstractSTRtree with the specified maximum number of child
+     * nodes that a node may have
+     */
+    AbstractSTRtree(std::size_t newNodeCapacity)
+        :
+        built(false),
+        itemBoundables(new BoundableList()),
+        nodes(new std::vector<AbstractNode *>()),
+        nodeCapacity(newNodeCapacity)
+    {
+        assert(newNodeCapacity > 1);
+    }
+
+    static bool
+    compareDoubles(double a, double b)
+    {
+        // NOTE - strk:
+        // Ternary operation is a workaround for
+        // a probable MingW bug, see
+        // http://trac.osgeo.org/geos/ticket/293
+        return (a < b) ? true : false;
+    }
+
+    virtual ~AbstractSTRtree();
+
+    /**
+     * Creates parent nodes, grandparent nodes, and so forth up to the root
+     * node, for the data that has been inserted into the tree. Can only be
+     * called once, and thus can be called only after all of the data has been
+     * inserted into the tree.
+     */
+    virtual void build();
+
+    /**
+     * Returns the maximum number of child nodes that a node may have
+     */
+    virtual std::size_t
+    getNodeCapacity()
+    {
+        return nodeCapacity;
+    }
+
+    virtual void query(const void* searchBounds, const AbstractNode* node, std::vector<void*>* matches);
+
+    /**
          * Iterate over all items added thus far.  Explicitly does not build
          * the tree.
          */
-	void iterate(ItemVisitor& visitor);
+    void iterate(ItemVisitor& visitor);
 
 
-	/**
-	 * @param level -1 to get items
-	 */
-	virtual void boundablesAtLevel(int level, AbstractNode* top,
-			BoundableList* boundables);
+    /**
+     * @param level -1 to get items
+     */
+    virtual void boundablesAtLevel(int level, AbstractNode* top,
+                                   BoundableList* boundables);
 
     /**
      * Gets a tree structure (as a nested list)
diff --git a/include/geos/index/strtree/Boundable.h b/include/geos/index/strtree/Boundable.h
index 90809c9..2a0ee4a 100644
--- a/include/geos/index/strtree/Boundable.h
+++ b/include/geos/index/strtree/Boundable.h
@@ -24,21 +24,22 @@ namespace strtree { // geos::index::strtree
 /// A spatial object in an AbstractSTRtree.
 class GEOS_DLL Boundable {
 public:
-	/**
-	 * Returns a representation of space that encloses this Boundable,
-	 * preferably not much bigger than this Boundable's boundary yet
-	 * fast to test for intersection with the bounds of other Boundables.
-	 *
-	 * The class of object returned depends
-	 * on the subclass of AbstractSTRtree.
-	 *
-	 * @return an Envelope (for STRtrees), an Interval (for SIRtrees),
-	 * or other object (for other subclasses of AbstractSTRtree)
-	 *
-	 * @see AbstractSTRtree::IntersectsOp
-	 */
-	virtual const void* getBounds() const=0;
-	virtual ~Boundable() {}
+    /**
+     * Returns a representation of space that encloses this Boundable,
+     * preferably not much bigger than this Boundable's boundary yet
+     * fast to test for intersection with the bounds of other Boundables.
+     *
+     * The class of object returned depends
+     * on the subclass of AbstractSTRtree.
+     *
+     * @return an Envelope (for STRtrees), an Interval (for SIRtrees),
+     * or other object (for other subclasses of AbstractSTRtree)
+     *
+     * @see AbstractSTRtree::IntersectsOp
+     */
+    virtual const void* getBounds() const = 0;
+    virtual
+    ~Boundable() {}
 };
 
 
diff --git a/include/geos/index/strtree/BoundablePair.h b/include/geos/index/strtree/BoundablePair.h
index 92f0b66..8294a65 100644
--- a/include/geos/index/strtree/BoundablePair.h
+++ b/include/geos/index/strtree/BoundablePair.h
@@ -41,67 +41,69 @@ namespace index {
 namespace strtree {
 
 class BoundablePair {
-	private:
-		const Boundable* boundable1;
-		const Boundable* boundable2;
-		ItemDistance* itemDistance;
-		double mDistance;
+private:
+    const Boundable* boundable1;
+    const Boundable* boundable2;
+    ItemDistance* itemDistance;
+    double mDistance;
 
-	public:
-		struct BoundablePairQueueCompare {
-			bool operator()(const BoundablePair* a, const BoundablePair* b) {
-				return a->getDistance() > b->getDistance();
-			}
-		};
+public:
+    struct BoundablePairQueueCompare {
+        bool
+        operator()(const BoundablePair* a, const BoundablePair* b)
+        {
+            return a->getDistance() > b->getDistance();
+        }
+    };
 
-		typedef std::priority_queue<BoundablePair*, std::vector<BoundablePair*>, BoundablePairQueueCompare> BoundablePairQueue;
-		BoundablePair(const Boundable* boundable1, const Boundable* boundable2, ItemDistance* itemDistance);
+    typedef std::priority_queue<BoundablePair*, std::vector<BoundablePair*>, BoundablePairQueueCompare> BoundablePairQueue;
+    BoundablePair(const Boundable* boundable1, const Boundable* boundable2, ItemDistance* itemDistance);
 
-		/**
-		 * Gets one of the member {@link Boundable}s in the pair
-		 * (indexed by [0, 1]).
-		 *
-		 * @param i the index of the member to return (0 or 1)
-		 * @return the chosen member
-		 */
-		const Boundable* getBoundable(int i) const;
+    /**
+     * Gets one of the member {@link Boundable}s in the pair
+     * (indexed by [0, 1]).
+     *
+     * @param i the index of the member to return (0 or 1)
+     * @return the chosen member
+     */
+    const Boundable* getBoundable(int i) const;
 
-		/**
-		 * Computes the distance between the {@link Boundable}s in this pair.
-		 * The boundables are either composites or leaves.
-		 * If either is composite, the distance is computed as the minimum distance
-		 * between the bounds.
-		 * If both are leaves, the distance is computed by {@link #itemDistance(ItemBoundable, ItemBoundable)}.
-		 *
-		 * @return
-		 */
-		double distance() const;
+    /**
+     * Computes the distance between the {@link Boundable}s in this pair.
+     * The boundables are either composites or leaves.
+     * If either is composite, the distance is computed as the minimum distance
+     * between the bounds.
+     * If both are leaves, the distance is computed by {@link #itemDistance(ItemBoundable, ItemBoundable)}.
+     *
+     * @return
+     */
+    double distance() const;
 
-		/**
-		 * Gets the minimum possible distance between the Boundables in
-		 * this pair.
-		 * If the members are both items, this will be the
-		 * exact distance between them.
-		 * Otherwise, this distance will be a lower bound on
-		 * the distances between the items in the members.
-		 *
-		 * @return the exact or lower bound distance for this pair
-		 */
-		double getDistance() const;
+    /**
+     * Gets the minimum possible distance between the Boundables in
+     * this pair.
+     * If the members are both items, this will be the
+     * exact distance between them.
+     * Otherwise, this distance will be a lower bound on
+     * the distances between the items in the members.
+     *
+     * @return the exact or lower bound distance for this pair
+     */
+    double getDistance() const;
 
-		/**
-		 * Tests if both elements of the pair are leaf nodes
-		 *
-		 * @return true if both pair elements are leaf nodes
-		 */
-		bool isLeaves() const;
+    /**
+     * Tests if both elements of the pair are leaf nodes
+     *
+     * @return true if both pair elements are leaf nodes
+     */
+    bool isLeaves() const;
 
-		static bool isComposite(const Boundable* item);
+    static bool isComposite(const Boundable* item);
 
-		static double area(const Boundable* b);
+    static double area(const Boundable* b);
 
-		void expandToQueue(BoundablePairQueue &, double minDistance);
-		void expand(const Boundable* bndComposite, const Boundable* bndOther, BoundablePairQueue & priQ, double minDistance);
+    void expandToQueue(BoundablePairQueue&, double minDistance);
+    void expand(const Boundable* bndComposite, const Boundable* bndOther, BoundablePairQueue& priQ, double minDistance);
 };
 }
 }
diff --git a/include/geos/index/strtree/GeometryItemDistance.h b/include/geos/index/strtree/GeometryItemDistance.h
index 887ea29..d41bc19 100644
--- a/include/geos/index/strtree/GeometryItemDistance.h
+++ b/include/geos/index/strtree/GeometryItemDistance.h
@@ -27,16 +27,16 @@ namespace index {
 namespace strtree {
 class GEOS_DLL GeometryItemDistance : public ItemDistance {
 public:
-	/**
-	 * Computes the distance between two {@link Geometry} items,
-	 * using the {@link Geometry#distance(Geometry)} method.
-	 *
-	 * @param item1 an item which is a Geometry
-	 * @param item2 an item which is a Geometry
-	 * @return the distance between the geometries
-	 * @throws ClassCastException if either item is not a Geometry
-	 */
-	double distance(const ItemBoundable* item1, const ItemBoundable* item2) override;
+    /**
+     * Computes the distance between two {@link Geometry} items,
+     * using the {@link Geometry#distance(Geometry)} method.
+     *
+     * @param item1 an item which is a Geometry
+     * @param item2 an item which is a Geometry
+     * @return the distance between the geometries
+     * @throws ClassCastException if either item is not a Geometry
+     */
+    double distance(const ItemBoundable* item1, const ItemBoundable* item2) override;
 };
 }
 }
diff --git a/include/geos/index/strtree/Interval.h b/include/geos/index/strtree/Interval.h
index 995a146..67fccb9 100644
--- a/include/geos/index/strtree/Interval.h
+++ b/include/geos/index/strtree/Interval.h
@@ -27,14 +27,14 @@ namespace strtree { // geos::index::strtree
 ///
 class GEOS_DLL Interval {
 public:
-	Interval(double newMin, double newMax);
-	double getCentre();
-	Interval* expandToInclude(const Interval *other);
-	bool intersects(const Interval *other) const;
-	bool equals(const Interval *o) const;
+    Interval(double newMin, double newMax);
+    double getCentre();
+    Interval* expandToInclude(const Interval* other);
+    bool intersects(const Interval* other) const;
+    bool equals(const Interval* o) const;
 private:
-	double imin;
-	double imax;
+    double imin;
+    double imax;
 };
 
 
diff --git a/include/geos/index/strtree/ItemBoundable.h b/include/geos/index/strtree/ItemBoundable.h
index f1cda7a..bf7be99 100644
--- a/include/geos/index/strtree/ItemBoundable.h
+++ b/include/geos/index/strtree/ItemBoundable.h
@@ -29,20 +29,19 @@ namespace strtree { // geos::index::strtree
  *
  * \todo TODO: It's unclear who takes ownership of passed newBounds and newItem objects.
  */
-class GEOS_DLL ItemBoundable: public Boundable
-{
+class GEOS_DLL ItemBoundable: public Boundable {
 public:
 
     ItemBoundable(const void* newBounds, void* newItem);
-	~ItemBoundable() override = default;
+    ~ItemBoundable() override = default;
 
     const void* getBounds() const override;
-	void* getItem() const;
+    void* getItem() const;
 
 private:
 
-	const void* bounds;
-	void* item;
+    const void* bounds;
+    void* item;
 };
 
 } // namespace geos::index::strtree
diff --git a/include/geos/index/strtree/ItemDistance.h b/include/geos/index/strtree/ItemDistance.h
index 54de9f4..6a05a12 100644
--- a/include/geos/index/strtree/ItemDistance.h
+++ b/include/geos/index/strtree/ItemDistance.h
@@ -26,16 +26,16 @@ namespace index {
 namespace strtree {
 class GEOS_DLL ItemDistance {
 public:
-	/**
-	 * Computes the distance between two items.
-	 *
-	 * @param item1
-	 * @param item2
-	 * @return the distance between the items
-	 *
-	 * @throws IllegalArgumentException if the metric is not applicable to the arguments
-	 */
-	virtual double distance(const ItemBoundable* item1, const ItemBoundable* item2) = 0;
+    /**
+     * Computes the distance between two items.
+     *
+     * @param item1
+     * @param item2
+     * @return the distance between the items
+     *
+     * @throws IllegalArgumentException if the metric is not applicable to the arguments
+     */
+    virtual double distance(const ItemBoundable* item1, const ItemBoundable* item2) = 0;
 };
 }
 }
diff --git a/include/geos/index/strtree/SIRtree.h b/include/geos/index/strtree/SIRtree.h
index 9e9c275..34be136 100644
--- a/include/geos/index/strtree/SIRtree.h
+++ b/include/geos/index/strtree/SIRtree.h
@@ -39,73 +39,82 @@ namespace strtree { // geos::index::strtree
  * @see STRtree
  */
 class GEOS_DLL SIRtree: public AbstractSTRtree {
-using AbstractSTRtree::insert;
-using AbstractSTRtree::query;
+    using AbstractSTRtree::insert;
+    using AbstractSTRtree::query;
 
 public:
 
-	/** \brief
-	 * Constructs an SIRtree with the default node capacity.
-	 */
-	SIRtree();
-
-	/** \brief
-	 * Constructs an SIRtree with the given maximum number of child nodes
-	 * that a node may have
-	 */
-	SIRtree(std::size_t nodeCapacity);
-
-	~SIRtree() override;
-
-	void insert(double x1, double x2, void* item);
-
-	/**
-	 * Returns items whose bounds intersect the given bounds.
-	 * @param x1 possibly equal to x2
-	 */
-	std::vector<void*>* query(double x1, double x2)
-	{
-		std::vector<void*>* results = new std::vector<void*>();
-		Interval interval(std::min(x1, x2), std::max(x1, x2));
-		AbstractSTRtree::query(&interval, *results);
-		return results;
-	}
-
-	/**
-	 * Returns items whose bounds intersect the given value.
-	 */
-	std::vector<void*>* query(double x) { return query(x,x); }
-
-	/**
-	 * Disable copy construction and assignment. Apparently needed to make this
-	 * class compile under MSVC. (See https://stackoverflow.com/q/29565299)
-	 */
-	 SIRtree(const SIRtree&) = delete;
-	 SIRtree& operator=(const SIRtree&) = delete;
+    /** \brief
+     * Constructs an SIRtree with the default node capacity.
+     */
+    SIRtree();
+
+    /** \brief
+     * Constructs an SIRtree with the given maximum number of child nodes
+     * that a node may have
+     */
+    SIRtree(std::size_t nodeCapacity);
+
+    ~SIRtree() override;
+
+    void insert(double x1, double x2, void* item);
+
+    /**
+     * Returns items whose bounds intersect the given bounds.
+     * @param x1 possibly equal to x2
+     */
+    std::vector<void*>*
+    query(double x1, double x2)
+    {
+        std::vector<void*>* results = new std::vector<void*>();
+        Interval interval(std::min(x1, x2), std::max(x1, x2));
+        AbstractSTRtree::query(&interval, *results);
+        return results;
+    }
+
+    /**
+     * Returns items whose bounds intersect the given value.
+     */
+    std::vector<void*>*
+    query(double x)
+    {
+        return query(x, x);
+    }
+
+    /**
+     * Disable copy construction and assignment. Apparently needed to make this
+     * class compile under MSVC. (See https://stackoverflow.com/q/29565299)
+     */
+    SIRtree(const SIRtree&) = delete;
+    SIRtree& operator=(const SIRtree&) = delete;
 
 protected:
 
-	class SIRIntersectsOp:public AbstractSTRtree::IntersectsOp {
-	public:
-		bool intersects(const void* aBounds, const void* bBounds) override;
-	};
+    class SIRIntersectsOp: public AbstractSTRtree::IntersectsOp {
+    public:
+        bool intersects(const void* aBounds, const void* bBounds) override;
+    };
 
-	/** \brief
-	 * Sorts the childBoundables then divides them into groups of size M, where
-	 * M is the node capacity.
-	 */
-	std::unique_ptr<BoundableList> createParentBoundables(
-			BoundableList* childBoundables, int newLevel) override;
+    /** \brief
+     * Sorts the childBoundables then divides them into groups of size M, where
+     * M is the node capacity.
+     */
+    std::unique_ptr<BoundableList> createParentBoundables(
+        BoundableList* childBoundables, int newLevel) override;
 
-	AbstractNode* createNode(int level) override;
+    AbstractNode* createNode(int level) override;
 
-	IntersectsOp* getIntersectsOp() override {return intersectsOp;}
+    IntersectsOp*
+    getIntersectsOp() override
+    {
+        return intersectsOp;
+    }
 
-	std::unique_ptr<BoundableList> sortBoundables(const BoundableList* input) override;
+    std::unique_ptr<BoundableList> sortBoundables(const BoundableList* input) override;
 
 private:
-	IntersectsOp* intersectsOp;
-	std::vector<std::unique_ptr<Interval>> intervals;
+    IntersectsOp* intersectsOp;
+    std::vector<std::unique_ptr<Interval>> intervals;
 };
 
 
diff --git a/include/geos/index/strtree/STRtree.h b/include/geos/index/strtree/STRtree.h
index 70be833..83d7b63 100644
--- a/include/geos/index/strtree/STRtree.h
+++ b/include/geos/index/strtree/STRtree.h
@@ -35,11 +35,11 @@
 
 // Forward declarations
 namespace geos {
-	namespace index {
-		namespace strtree {
-			class Boundable;
-		}
-	}
+namespace index {
+namespace strtree {
+class Boundable;
+}
+}
 }
 
 namespace geos {
@@ -61,93 +61,105 @@ namespace strtree { // geos::index::strtree
  * Databases With Application To GIS. Morgan Kaufmann, San Francisco, 2002.
  *
  */
-class GEOS_DLL STRtree: public AbstractSTRtree, public SpatialIndex
-{
-using AbstractSTRtree::insert;
-using AbstractSTRtree::query;
+class GEOS_DLL STRtree: public AbstractSTRtree, public SpatialIndex {
+    using AbstractSTRtree::insert;
+    using AbstractSTRtree::query;
 
 private:
-	class GEOS_DLL STRIntersectsOp: public AbstractSTRtree::IntersectsOp {
-		public:
-			bool intersects(const void* aBounds, const void* bBounds) override;
-	};
+    class GEOS_DLL STRIntersectsOp: public AbstractSTRtree::IntersectsOp {
+    public:
+        bool intersects(const void* aBounds, const void* bBounds) override;
+    };
 
-	/**
-	 * Creates the parent level for the given child level. First, orders the items
-	 * by the x-values of the midpoints, and groups them into vertical slices.
-	 * For each slice, orders the items by the y-values of the midpoints, and
-	 * group them into runs of size M (the node capacity). For each run, creates
-	 * a new (parent) node.
-	 */
-	std::unique_ptr<BoundableList> createParentBoundables(BoundableList* childBoundables, int newLevel) override;
+    /**
+     * Creates the parent level for the given child level. First, orders the items
+     * by the x-values of the midpoints, and groups them into vertical slices.
+     * For each slice, orders the items by the y-values of the midpoints, and
+     * group them into runs of size M (the node capacity). For each run, creates
+     * a new (parent) node.
+     */
+    std::unique_ptr<BoundableList> createParentBoundables(BoundableList* childBoundables, int newLevel) override;
 
-	std::unique_ptr<BoundableList> createParentBoundablesFromVerticalSlices(std::vector<BoundableList*>* verticalSlices, int newLevel);
+    std::unique_ptr<BoundableList> createParentBoundablesFromVerticalSlices(std::vector<BoundableList*>* verticalSlices,
+            int newLevel);
 
-	STRIntersectsOp intersectsOp;
+    STRIntersectsOp intersectsOp;
 
-	std::unique_ptr<BoundableList> sortBoundables(const BoundableList* input) override;
+    std::unique_ptr<BoundableList> sortBoundables(const BoundableList* input) override;
 
-	std::unique_ptr<BoundableList> createParentBoundablesFromVerticalSlice(
-			BoundableList* childBoundables,
-			int newLevel);
+    std::unique_ptr<BoundableList> createParentBoundablesFromVerticalSlice(
+        BoundableList* childBoundables,
+        int newLevel);
 
-	/**
-	 * @param childBoundables Must be sorted by the x-value of
-	 *        the envelope midpoints
-	 * @return
-	 */
-	std::vector<BoundableList*>* verticalSlices(
-			BoundableList* childBoundables,
-			size_t sliceCount);
+    /**
+     * @param childBoundables Must be sorted by the x-value of
+     *        the envelope midpoints
+     * @return
+     */
+    std::vector<BoundableList*>* verticalSlices(
+        BoundableList* childBoundables,
+        size_t sliceCount);
 
 
 protected:
 
-	AbstractNode* createNode(int level) override;
+    AbstractNode* createNode(int level) override;
 
-	IntersectsOp* getIntersectsOp() override {
-		return &intersectsOp;
-	}
+    IntersectsOp*
+    getIntersectsOp() override
+    {
+        return &intersectsOp;
+    }
 
 public:
 
-	~STRtree() override;
-
-	/**
-	 * Constructs an STRtree with the given maximum number of child nodes that
-	 * a node may have
-	 */
-	STRtree(std::size_t nodeCapacity=10);
-
-	void insert(const geom::Envelope *itemEnv,void* item) override;
-
-	//static double centreX(const geom::Envelope *e);
-
-	static double avg(double a, double b) {
-		return (a + b) / 2.0;
-	}
-
-	static double centreY(const geom::Envelope *e) {
-		return STRtree::avg(e->getMinY(), e->getMaxY());
-	}
-
-	void query(const geom::Envelope *searchEnv, std::vector<void*>& matches) override {
-		AbstractSTRtree::query(searchEnv, matches);
-	}
-
-	void query(const geom::Envelope *searchEnv, ItemVisitor& visitor) override {
-		return AbstractSTRtree::query(searchEnv, visitor);
-	}
-
-	const void* nearestNeighbour(const geom::Envelope *env, const void* item, ItemDistance* itemDist);
-	std::pair<const void*, const void*> nearestNeighbour(BoundablePair* initBndPair);
-	std::pair<const void*, const void*> nearestNeighbour(ItemDistance* itemDist);
-	std::pair<const void*, const void*> nearestNeighbour(BoundablePair* initBndPair, double maxDistance);
-	std::pair<const void*, const void*> nearestNeighbour(STRtree *tree, ItemDistance *itemDist);
-
-	bool remove(const geom::Envelope *itemEnv, void* item) override {
-		return AbstractSTRtree::remove(itemEnv, item);
-	}
+    ~STRtree() override;
+
+    /**
+     * Constructs an STRtree with the given maximum number of child nodes that
+     * a node may have
+     */
+    STRtree(std::size_t nodeCapacity = 10);
+
+    void insert(const geom::Envelope* itemEnv, void* item) override;
+
+    //static double centreX(const geom::Envelope *e);
+
+    static double
+    avg(double a, double b)
+    {
+        return (a + b) / 2.0;
+    }
+
+    static double
+    centreY(const geom::Envelope* e)
+    {
+        return STRtree::avg(e->getMinY(), e->getMaxY());
+    }
+
+    void
+    query(const geom::Envelope* searchEnv, std::vector<void*>& matches) override
+    {
+        AbstractSTRtree::query(searchEnv, matches);
+    }
+
+    void
+    query(const geom::Envelope* searchEnv, ItemVisitor& visitor) override
+    {
+        return AbstractSTRtree::query(searchEnv, visitor);
+    }
+
+    const void* nearestNeighbour(const geom::Envelope* env, const void* item, ItemDistance* itemDist);
+    std::pair<const void*, const void*> nearestNeighbour(BoundablePair* initBndPair);
+    std::pair<const void*, const void*> nearestNeighbour(ItemDistance* itemDist);
+    std::pair<const void*, const void*> nearestNeighbour(BoundablePair* initBndPair, double maxDistance);
+    std::pair<const void*, const void*> nearestNeighbour(STRtree* tree, ItemDistance* itemDist);
+
+    bool
+    remove(const geom::Envelope* itemEnv, void* item) override
+    {
+        return AbstractSTRtree::remove(itemEnv, item);
+    }
 
 };
 
diff --git a/include/geos/index/sweepline/SweepLineEvent.h b/include/geos/index/sweepline/SweepLineEvent.h
index c700ea3..4c51f6d 100644
--- a/include/geos/index/sweepline/SweepLineEvent.h
+++ b/include/geos/index/sweepline/SweepLineEvent.h
@@ -20,11 +20,11 @@
 
 // Forward declarations
 namespace geos {
-	namespace index {
-		namespace sweepline {
-			class SweepLineInterval;
-		}
-	}
+namespace index {
+namespace sweepline {
+class SweepLineInterval;
+}
+}
 }
 
 namespace geos {
@@ -35,48 +35,48 @@ class GEOS_DLL SweepLineEvent {
 
 public:
 
-	enum {
-		INSERT_EVENT = 1,
-		DELETE_EVENT
-	};
+    enum {
+        INSERT_EVENT = 1,
+        DELETE_EVENT
+    };
 
-	SweepLineEvent(double x, SweepLineEvent *newInsertEvent,
-			SweepLineInterval *newSweepInt);
+    SweepLineEvent(double x, SweepLineEvent* newInsertEvent,
+                   SweepLineInterval* newSweepInt);
 
-	bool isInsert();
+    bool isInsert();
 
-	bool isDelete();
+    bool isDelete();
 
-	SweepLineEvent* getInsertEvent();
+    SweepLineEvent* getInsertEvent();
 
-	size_t getDeleteEventIndex();
+    size_t getDeleteEventIndex();
 
-	void setDeleteEventIndex(size_t newDeleteEventIndex);
+    void setDeleteEventIndex(size_t newDeleteEventIndex);
 
-	SweepLineInterval* getInterval();
+    SweepLineInterval* getInterval();
 
-	/**
-	 * ProjectionEvents are ordered first by their x-value, and then by their eventType.
-	 * It is important that Insert events are sorted before Delete events, so that
-	 * items whose Insert and Delete events occur at the same x-value will be
-	 * correctly handled.
-	 */
-	int compareTo(const SweepLineEvent *pe) const;
+    /**
+     * ProjectionEvents are ordered first by their x-value, and then by their eventType.
+     * It is important that Insert events are sorted before Delete events, so that
+     * items whose Insert and Delete events occur at the same x-value will be
+     * correctly handled.
+     */
+    int compareTo(const SweepLineEvent* pe) const;
 
-	//int compareTo(void *o) const;
+    //int compareTo(void *o) const;
 
 private:
 
-	double xValue;
+    double xValue;
 
-	int eventType;
+    int eventType;
 
-	/// null if this is an INSERT_EVENT event
-	SweepLineEvent *insertEvent;
+    /// null if this is an INSERT_EVENT event
+    SweepLineEvent* insertEvent;
 
-	size_t deleteEventIndex;
+    size_t deleteEventIndex;
 
-	SweepLineInterval *sweepInt;
+    SweepLineInterval* sweepInt;
 
 };
 
@@ -84,7 +84,7 @@ private:
 //typedef SweepLineEvent indexSweepLineEvent;
 
 struct GEOS_DLL  SweepLineEventLessThen {
-	bool operator() (const SweepLineEvent* first, const SweepLineEvent* second) const;
+    bool operator()(const SweepLineEvent* first, const SweepLineEvent* second) const;
 };
 
 //bool isleLessThen(SweepLineEvent *first, SweepLineEvent *second);
diff --git a/include/geos/index/sweepline/SweepLineIndex.h b/include/geos/index/sweepline/SweepLineIndex.h
index 5d885ee..5282188 100644
--- a/include/geos/index/sweepline/SweepLineIndex.h
+++ b/include/geos/index/sweepline/SweepLineIndex.h
@@ -26,13 +26,13 @@
 
 // Forward declarations
 namespace geos {
-	namespace index {
-		namespace sweepline {
-			class SweepLineInterval;
-			class SweepLineEvent;
-			class SweepLineOverlapAction;
-		}
-	}
+namespace index {
+namespace sweepline {
+class SweepLineInterval;
+class SweepLineEvent;
+class SweepLineOverlapAction;
+}
+}
 }
 
 namespace geos {
@@ -48,34 +48,34 @@ class GEOS_DLL SweepLineIndex {
 
 public:
 
-	SweepLineIndex();
+    SweepLineIndex();
 
-	~SweepLineIndex();
+    ~SweepLineIndex();
 
-	void add(SweepLineInterval *sweepInt);
+    void add(SweepLineInterval* sweepInt);
 
-	void computeOverlaps(SweepLineOverlapAction *action);
+    void computeOverlaps(SweepLineOverlapAction* action);
 
 private:
 
-	// FIXME: make it a real vector rather then a pointer
-	std::vector<SweepLineEvent*> events;
+    // FIXME: make it a real vector rather then a pointer
+    std::vector<SweepLineEvent*> events;
 
-	bool indexBuilt;
+    bool indexBuilt;
 
-	// statistics information
-	int nOverlaps;
+    // statistics information
+    int nOverlaps;
 
-	/**
-	 * Because Delete Events have a link to their corresponding Insert event,
-	 * it is possible to compute exactly the range of events which must be
-	 * compared to a given Insert event object.
-	 */
-	void buildIndex();
+    /**
+     * Because Delete Events have a link to their corresponding Insert event,
+     * it is possible to compute exactly the range of events which must be
+     * compared to a given Insert event object.
+     */
+    void buildIndex();
 
-	void processOverlaps(std::size_t start, std::size_t end,
-			SweepLineInterval *s0,
-			SweepLineOverlapAction *action);
+    void processOverlaps(std::size_t start, std::size_t end,
+                         SweepLineInterval* s0,
+                         SweepLineOverlapAction* action);
 };
 
 } // namespace geos:index:sweepline
diff --git a/include/geos/index/sweepline/SweepLineInterval.h b/include/geos/index/sweepline/SweepLineInterval.h
index 164dd01..91f211f 100644
--- a/include/geos/index/sweepline/SweepLineInterval.h
+++ b/include/geos/index/sweepline/SweepLineInterval.h
@@ -23,13 +23,13 @@ namespace sweepline { // geos:index:sweepline
 
 class GEOS_DLL SweepLineInterval {
 public:
-	SweepLineInterval(double newMin, double newMax, void* newItem=nullptr);
-	double getMin();
-	double getMax();
-	void* getItem();
+    SweepLineInterval(double newMin, double newMax, void* newItem = nullptr);
+    double getMin();
+    double getMax();
+    void* getItem();
 private:
-	double min, max;
-	void* item;
+    double min, max;
+    void* item;
 };
 
 } // namespace geos:index:sweepline
diff --git a/include/geos/index/sweepline/SweepLineOverlapAction.h b/include/geos/index/sweepline/SweepLineOverlapAction.h
index d4fb7cc..9dc825a 100644
--- a/include/geos/index/sweepline/SweepLineOverlapAction.h
+++ b/include/geos/index/sweepline/SweepLineOverlapAction.h
@@ -19,11 +19,11 @@
 
 // Forward declarations
 namespace geos {
-	namespace index {
-		namespace sweepline {
-			class SweepLineInterval;
-		}
-	}
+namespace index {
+namespace sweepline {
+class SweepLineInterval;
+}
+}
 }
 
 namespace geos {
@@ -32,9 +32,10 @@ namespace sweepline { // geos:index:sweepline
 
 class GEOS_DLL SweepLineOverlapAction {
 public:
-	virtual void overlap(SweepLineInterval *s0,SweepLineInterval *s1)=0;
+    virtual void overlap(SweepLineInterval* s0, SweepLineInterval* s1) = 0;
 
-	virtual ~SweepLineOverlapAction() {}
+    virtual
+    ~SweepLineOverlapAction() {}
 };
 
 
diff --git a/include/geos/io/ByteOrderDataInStream.h b/include/geos/io/ByteOrderDataInStream.h
index 8596b56..eb79926 100644
--- a/include/geos/io/ByteOrderDataInStream.h
+++ b/include/geos/io/ByteOrderDataInStream.h
@@ -42,32 +42,32 @@ class GEOS_DLL ByteOrderDataInStream {
 
 public:
 
-	ByteOrderDataInStream(std::istream *s=nullptr);
+    ByteOrderDataInStream(std::istream* s = nullptr);
 
-	~ByteOrderDataInStream();
+    ~ByteOrderDataInStream();
 
-	/**
-	 * Allows a single ByteOrderDataInStream to be reused
-	 * on multiple istream.
-	 */
-	void setInStream(std::istream *s);
+    /**
+     * Allows a single ByteOrderDataInStream to be reused
+     * on multiple istream.
+     */
+    void setInStream(std::istream* s);
 
-	void setOrder(int order);
+    void setOrder(int order);
 
-	unsigned char readByte(); // throws ParseException
+    unsigned char readByte(); // throws ParseException
 
-	int readInt(); // throws ParseException
+    int readInt(); // throws ParseException
 
-	long readLong(); // throws ParseException
+    long readLong(); // throws ParseException
 
-	double readDouble(); // throws ParseException
+    double readDouble(); // throws ParseException
 
 private:
-	int byteOrder;
-	std::istream *stream;
+    int byteOrder;
+    std::istream* stream;
 
-	// buffers to hold primitive datatypes
-	unsigned char buf[8];
+    // buffers to hold primitive datatypes
+    unsigned char buf[8];
 
 };
 
diff --git a/include/geos/io/ByteOrderDataInStream.inl b/include/geos/io/ByteOrderDataInStream.inl
index e2c0746..ab8dcdb 100644
--- a/include/geos/io/ByteOrderDataInStream.inl
+++ b/include/geos/io/ByteOrderDataInStream.inl
@@ -8,7 +8,7 @@
  *
  * This is free software; you can redistribute and/or modify it under
  * the terms of the GNU Lesser General Public Licence as published
- * by the Free Software Foundation. 
+ * by the Free Software Foundation.
  * See the COPYING file for more information.
  *
  **********************************************************************
@@ -31,10 +31,10 @@ namespace geos {
 namespace io {
 
 INLINE
-ByteOrderDataInStream::ByteOrderDataInStream(std::istream *s)
-	:
-	byteOrder(getMachineByteOrder()),
-	stream(s)
+ByteOrderDataInStream::ByteOrderDataInStream(std::istream* s)
+    :
+    byteOrder(getMachineByteOrder()),
+    stream(s)
 {
 }
 
@@ -43,52 +43,56 @@ ByteOrderDataInStream::~ByteOrderDataInStream()
 {
 }
 
-INLINE void 
-ByteOrderDataInStream::setInStream(std::istream *s)
+INLINE void
+ByteOrderDataInStream::setInStream(std::istream* s)
 {
-	stream=s;
+    stream = s;
 }
 
 INLINE void
 ByteOrderDataInStream::setOrder(int order)
 {
-	byteOrder=order;
+    byteOrder = order;
 }
 
 INLINE unsigned char
 ByteOrderDataInStream::readByte() // throws ParseException
 {
-	stream->read(reinterpret_cast<char *>(buf), 1);
-	if ( stream->eof() )
-		throw  ParseException("Unexpected EOF parsing WKB");
-	return buf[0];
+    stream->read(reinterpret_cast<char*>(buf), 1);
+    if(stream->eof()) {
+        throw  ParseException("Unexpected EOF parsing WKB");
+    }
+    return buf[0];
 }
 
 INLINE int
-ByteOrderDataInStream::readInt() 
+ByteOrderDataInStream::readInt()
 {
-	stream->read(reinterpret_cast<char *>(buf), 4);
-	if ( stream->eof() )
-		throw  ParseException("Unexpected EOF parsing WKB");
-	return ByteOrderValues::getInt(buf, byteOrder);
+    stream->read(reinterpret_cast<char*>(buf), 4);
+    if(stream->eof()) {
+        throw  ParseException("Unexpected EOF parsing WKB");
+    }
+    return ByteOrderValues::getInt(buf, byteOrder);
 }
 
 INLINE long
-ByteOrderDataInStream::readLong() 
+ByteOrderDataInStream::readLong()
 {
-	stream->read(reinterpret_cast<char *>(buf), 8);
-	if ( stream->eof() )
-		throw  ParseException("Unexpected EOF parsing WKB");
-	return static_cast<long>(ByteOrderValues::getLong(buf, byteOrder));
+    stream->read(reinterpret_cast<char*>(buf), 8);
+    if(stream->eof()) {
+        throw  ParseException("Unexpected EOF parsing WKB");
+    }
+    return static_cast<long>(ByteOrderValues::getLong(buf, byteOrder));
 }
 
 INLINE double
-ByteOrderDataInStream::readDouble() 
+ByteOrderDataInStream::readDouble()
 {
-	stream->read(reinterpret_cast<char *>(buf), 8);
-	if ( stream->eof() )
-		throw  ParseException("Unexpected EOF parsing WKB");
-	return ByteOrderValues::getDouble(buf, byteOrder);
+    stream->read(reinterpret_cast<char*>(buf), 8);
+    if(stream->eof()) {
+        throw  ParseException("Unexpected EOF parsing WKB");
+    }
+    return ByteOrderValues::getDouble(buf, byteOrder);
 }
 
 } // namespace io
diff --git a/include/geos/io/ByteOrderValues.h b/include/geos/io/ByteOrderValues.h
index c7394ed..779cb9b 100644
--- a/include/geos/io/ByteOrderValues.h
+++ b/include/geos/io/ByteOrderValues.h
@@ -38,20 +38,19 @@ class GEOS_DLL ByteOrderValues {
 
 public:
 
-    enum EndianType
-    {
+    enum EndianType {
         ENDIAN_BIG = 0,
         ENDIAN_LITTLE = 1
     };
 
-	static int getInt(const unsigned char *buf, int byteOrder);
-	static void putInt(int intValue, unsigned char *buf, int byteOrder);
+    static int getInt(const unsigned char* buf, int byteOrder);
+    static void putInt(int intValue, unsigned char* buf, int byteOrder);
 
-	static int64 getLong(const unsigned char *buf, int byteOrder);
-	static void putLong(int64 longValue, unsigned char *buf, int byteOrder);
+    static int64 getLong(const unsigned char* buf, int byteOrder);
+    static void putLong(int64 longValue, unsigned char* buf, int byteOrder);
 
-	static double getDouble(const unsigned char *buf, int byteOrder);
-	static void putDouble(double doubleValue, unsigned char *buf, int byteOrder);
+    static double getDouble(const unsigned char* buf, int byteOrder);
+    static void putDouble(double doubleValue, unsigned char* buf, int byteOrder);
 
 };
 
diff --git a/include/geos/io/CLocalizer.h b/include/geos/io/CLocalizer.h
index 3b3d55c..a9b6175 100644
--- a/include/geos/io/CLocalizer.h
+++ b/include/geos/io/CLocalizer.h
@@ -34,8 +34,7 @@ namespace io {
 /**
  * \class CLocalizer io.h geos.h
  */
-class GEOS_DLL CLocalizer
-{
+class GEOS_DLL CLocalizer {
 public:
 
     CLocalizer();
diff --git a/include/geos/io/ParseException.h b/include/geos/io/ParseException.h
index bcef225..4b5003a 100644
--- a/include/geos/io/ParseException.h
+++ b/include/geos/io/ParseException.h
@@ -31,23 +31,22 @@ namespace io {
  * \class ParseException io.h geos.h
  * \brief Notifies a parsing error
  */
-class GEOS_DLL ParseException : public util::GEOSException
-{
+class GEOS_DLL ParseException : public util::GEOSException {
 
 public:
 
-	ParseException();
+    ParseException();
 
-	ParseException(const std::string& msg);
+    ParseException(const std::string& msg);
 
-	ParseException(const std::string& msg, const std::string& var);
+    ParseException(const std::string& msg, const std::string& var);
 
-	ParseException(const std::string& msg, double num);
+    ParseException(const std::string& msg, double num);
 
-	~ParseException() throw() override {}
+    ~ParseException() throw() override {}
 
 private:
-	static std::string stringify(double num);
+    static std::string stringify(double num);
 };
 
 } // namespace io
diff --git a/include/geos/io/StringTokenizer.h b/include/geos/io/StringTokenizer.h
index 7901326..e502c73 100644
--- a/include/geos/io/StringTokenizer.h
+++ b/include/geos/io/StringTokenizer.h
@@ -34,24 +34,24 @@ namespace io {
 
 class GEOS_DLL StringTokenizer {
 public:
-	enum {
-		TT_EOF,
-		TT_EOL,
-		TT_NUMBER,
-		TT_WORD
-	};
-	//StringTokenizer();
-	explicit StringTokenizer(const std::string& txt);
-	~StringTokenizer() {}
-	int nextToken();
-	int peekNextToken();
-	double getNVal();
-	std::string getSVal();
+    enum {
+        TT_EOF,
+        TT_EOL,
+        TT_NUMBER,
+        TT_WORD
+    };
+    //StringTokenizer();
+    explicit StringTokenizer(const std::string& txt);
+    ~StringTokenizer() {}
+    int nextToken();
+    int peekNextToken();
+    double getNVal();
+    std::string getSVal();
 private:
-	const std::string &str;
-	std::string stok;
-	double ntok;
-	std::string::const_iterator iter;
+    const std::string& str;
+    std::string stok;
+    double ntok;
+    std::string::const_iterator iter;
 
     // Declare type as noncopyable
     StringTokenizer(const StringTokenizer& other) = delete;
diff --git a/include/geos/io/WKBConstants.h b/include/geos/io/WKBConstants.h
index 202b5c8..59ab732 100644
--- a/include/geos/io/WKBConstants.h
+++ b/include/geos/io/WKBConstants.h
@@ -26,19 +26,19 @@ namespace io {
 /// Constant values used by the WKB format
 namespace WKBConstants {
 
-	/// Big Endian
-	const int wkbXDR = 0;
-
-	/// Little Endian
-	const int wkbNDR = 1;
-
-	const int wkbPoint = 1;
-	const int wkbLineString = 2;
-	const int wkbPolygon = 3;
-	const int wkbMultiPoint = 4;
-	const int wkbMultiLineString = 5;
-	const int wkbMultiPolygon = 6;
-	const int wkbGeometryCollection = 7;
+/// Big Endian
+const int wkbXDR = 0;
+
+/// Little Endian
+const int wkbNDR = 1;
+
+const int wkbPoint = 1;
+const int wkbLineString = 2;
+const int wkbPolygon = 3;
+const int wkbMultiPoint = 4;
+const int wkbMultiLineString = 5;
+const int wkbMultiPolygon = 6;
+const int wkbGeometryCollection = 7;
 }
 
 } // namespace geos::io
diff --git a/include/geos/io/WKBReader.h b/include/geos/io/WKBReader.h
index b9399ba..a12ca39 100644
--- a/include/geos/io/WKBReader.h
+++ b/include/geos/io/WKBReader.h
@@ -38,22 +38,22 @@
 
 // Forward declarations
 namespace geos {
-	namespace geom {
-
-		//class GeometryFactory;
-		class Coordinate;
-		class Geometry;
-		class GeometryCollection;
-		class Point;
-		class LineString;
-		class LinearRing;
-		class Polygon;
-		class MultiPoint;
-		class MultiLineString;
-		class MultiPolygon;
-		class PrecisionModel;
-
-	} // namespace geom
+namespace geom {
+
+//class GeometryFactory;
+class Coordinate;
+class Geometry;
+class GeometryCollection;
+class Point;
+class LineString;
+class LinearRing;
+class Polygon;
+class MultiPoint;
+class MultiLineString;
+class MultiPolygon;
+class PrecisionModel;
+
+} // namespace geom
 } // namespace geos
 
 
@@ -80,82 +80,82 @@ class GEOS_DLL WKBReader {
 
 public:
 
-	WKBReader(geom::GeometryFactory const& f): factory(f) {}
-
-	/// Inizialize parser with default GeometryFactory.
-	WKBReader();
-
-	/**
-	 * \brief Reads a Geometry from an istream.
-	 *
-	 * @param is the stream to read from
-	 * @return the Geometry read
-	 * @throws IOException
-	 * @throws ParseException
-	 */
-	geom::Geometry* read(std::istream &is);
-		// throws IOException, ParseException
-
-	/**
-	 * \brief Reads a Geometry from an istream in hex format.
-	 *
-	 * @param is the stream to read from
-	 * @return the Geometry read
-	 * @throws IOException
-	 * @throws ParseException
-	 */
-	geom::Geometry *readHEX(std::istream &is);
-		// throws IOException, ParseException
-
-	/**
-	 * \brief Print WKB in HEX form to out stream
-	 *
-	 * @param is is the stream to read from
-	 * @param os is the stream to write to
-	 */
-	static std::ostream &printHEX(std::istream &is, std::ostream &os);
+    WKBReader(geom::GeometryFactory const& f): factory(f) {}
+
+    /// Inizialize parser with default GeometryFactory.
+    WKBReader();
+
+    /**
+     * \brief Reads a Geometry from an istream.
+     *
+     * @param is the stream to read from
+     * @return the Geometry read
+     * @throws IOException
+     * @throws ParseException
+     */
+    geom::Geometry* read(std::istream& is);
+    // throws IOException, ParseException
+
+    /**
+     * \brief Reads a Geometry from an istream in hex format.
+     *
+     * @param is the stream to read from
+     * @return the Geometry read
+     * @throws IOException
+     * @throws ParseException
+     */
+    geom::Geometry* readHEX(std::istream& is);
+    // throws IOException, ParseException
+
+    /**
+     * \brief Print WKB in HEX form to out stream
+     *
+     * @param is is the stream to read from
+     * @param os is the stream to write to
+     */
+    static std::ostream& printHEX(std::istream& is, std::ostream& os);
 
 private:
 
-	const geom::GeometryFactory &factory;
+    const geom::GeometryFactory& factory;
 
-	// for now support the WKB standard only - may be generalized later
-	unsigned int inputDimension;
+    // for now support the WKB standard only - may be generalized later
+    unsigned int inputDimension;
 
-	ByteOrderDataInStream dis;
+    ByteOrderDataInStream dis;
 
-	std::vector<double> ordValues;
+    std::vector<double> ordValues;
 
-	geom::Geometry *readGeometry();
-		// throws IOException, ParseException
+    geom::Geometry* readGeometry();
+    // throws IOException, ParseException
 
-	geom::Point *readPoint();
-		// throws IOException
+    geom::Point* readPoint();
+    // throws IOException
 
-	geom::LineString *readLineString();
-		// throws IOException
+    geom::LineString* readLineString();
+    // throws IOException
 
-	geom::LinearRing *readLinearRing();
-		// throws IOException
+    geom::LinearRing* readLinearRing();
+    // throws IOException
 
-	geom::Polygon *readPolygon();
-		// throws IOException
+    geom::Polygon* readPolygon();
+    // throws IOException
 
-	geom::MultiPoint *readMultiPoint();
-		// throws IOException, ParseException
+    geom::MultiPoint* readMultiPoint();
+    // throws IOException, ParseException
 
-	geom::MultiLineString *readMultiLineString();
-		// throws IOException, ParseException
+    geom::MultiLineString* readMultiLineString();
+    // throws IOException, ParseException
 
-	geom::MultiPolygon *readMultiPolygon();
-		// throws IOException, ParseException
+    geom::MultiPolygon* readMultiPolygon();
+    // throws IOException, ParseException
 
-	geom::GeometryCollection *readGeometryCollection();
-		// throws IOException, ParseException
+    geom::GeometryCollection* readGeometryCollection();
+    // throws IOException, ParseException
 
-	geom::CoordinateSequence *readCoordinateSequence(int); // throws IOException
+    geom::CoordinateSequence* readCoordinateSequence(int); // throws IOException
 
-	void readCoordinate(); // throws IOException
+    void readCoordinate(); // throws IOException
 
     // Declare type as noncopyable
     WKBReader(const WKBReader& other) = delete;
diff --git a/include/geos/io/WKBWriter.h b/include/geos/io/WKBWriter.h
index 32a3914..902f303 100644
--- a/include/geos/io/WKBWriter.h
+++ b/include/geos/io/WKBWriter.h
@@ -27,21 +27,21 @@
 
 // Forward declarations
 namespace geos {
-	namespace geom {
-
-		class CoordinateSequence;
-		class Geometry;
-		class GeometryCollection;
-		class Point;
-		class LineString;
-		class LinearRing;
-		class Polygon;
-		class MultiPoint;
-		class MultiLineString;
-		class MultiPolygon;
-		class PrecisionModel;
-
-	} // namespace geom
+namespace geom {
+
+class CoordinateSequence;
+class Geometry;
+class GeometryCollection;
+class Point;
+class LineString;
+class LinearRing;
+class Polygon;
+class MultiPoint;
+class MultiLineString;
+class MultiPolygon;
+class PrecisionModel;
+
+} // namespace geom
 } // namespace geos
 
 namespace geos {
@@ -72,9 +72,9 @@ namespace io {
 class GEOS_DLL WKBWriter {
 
 public:
-	/*
-	 * \brief
-	 * Initializes writer with target coordinate dimension, endianness
+    /*
+     * \brief
+     * Initializes writer with target coordinate dimension, endianness
      * flag and SRID value.
      *
      * @param dims Supported values are 2 or 3.  Note that 3 indicates
@@ -84,118 +84,134 @@ public:
      * @param incudeSRID true if SRID should be included in WKB (an
      * extension).
      */
-	WKBWriter(int dims=2, int bo=getMachineByteOrder(), bool includeSRID=false);
-
-        /*
-         * \brief
-         * Destructor.
-         */
-	virtual ~WKBWriter();
-
-	/*
-	 * \brief
-	 * Returns the output dimension used by the
-	 * <code>WKBWriter</code>.
-	 */
-	virtual int getOutputDimension() const { return defaultOutputDimension; }
-
-	/*
-	 * Sets the output dimension used by the <code>WKBWriter</code>.
-	 *
-	 * @param newOutputDimension Supported values are 2 or 3.
-	 * Note that 3 indicates up to 3 dimensions will be written but
-	 * 2D WKB is still produced for 2D geometries.
-	 */
-	virtual void setOutputDimension(int newOutputDimension);
-
-	/*
-	 * \brief
-	 * Returns the byte order used by the
-	 * <code>WKBWriter</code>.
-	 */
-	virtual int getByteOrder() const { return byteOrder; }
-
-	/*
-	 * Sets the byte order used by the
-	 * <code>WKBWriter</code>.
-	 */
-	virtual void setByteOrder(int newByteOrder);
-
-	/*
-	 * \brief
-	 * Returns whether SRID values are output by the
-	 * <code>WKBWriter</code>.
-	 */
-	virtual int getIncludeSRID() const { return includeSRID; }
-
-	/*
-	 * Sets whether SRID values should be output by the
-	 * <code>WKBWriter</code>.
-	 */
-	virtual void setIncludeSRID(int newIncludeSRID) { includeSRID = (0 == newIncludeSRID ? false : true); }
-
-	/**
-	 * \brief Write a Geometry to an ostream.
-	 *
-	 * @param g the geometry to write
-	 * @param os the output stream
-	 * @throws IOException
-	 */
-	void write(const geom::Geometry &g, std::ostream &os);
-		// throws IOException, ParseException
-
-	/**
-	 * \brief Write a Geometry to an ostream in binary hex format.
-	 *
-	 * @param g the geometry to write
-	 * @param os the output stream
-	 * @throws IOException
-	 */
-	void writeHEX(const geom::Geometry &g, std::ostream &os);
-		// throws IOException, ParseException
+    WKBWriter(int dims = 2, int bo = getMachineByteOrder(), bool includeSRID = false);
+
+    /*
+     * \brief
+     * Destructor.
+     */
+    virtual ~WKBWriter();
+
+    /*
+     * \brief
+     * Returns the output dimension used by the
+     * <code>WKBWriter</code>.
+     */
+    virtual int
+    getOutputDimension() const
+    {
+        return defaultOutputDimension;
+    }
+
+    /*
+     * Sets the output dimension used by the <code>WKBWriter</code>.
+     *
+     * @param newOutputDimension Supported values are 2 or 3.
+     * Note that 3 indicates up to 3 dimensions will be written but
+     * 2D WKB is still produced for 2D geometries.
+     */
+    virtual void setOutputDimension(int newOutputDimension);
+
+    /*
+     * \brief
+     * Returns the byte order used by the
+     * <code>WKBWriter</code>.
+     */
+    virtual int
+    getByteOrder() const
+    {
+        return byteOrder;
+    }
+
+    /*
+     * Sets the byte order used by the
+     * <code>WKBWriter</code>.
+     */
+    virtual void setByteOrder(int newByteOrder);
+
+    /*
+     * \brief
+     * Returns whether SRID values are output by the
+     * <code>WKBWriter</code>.
+     */
+    virtual int
+    getIncludeSRID() const
+    {
+        return includeSRID;
+    }
+
+    /*
+     * Sets whether SRID values should be output by the
+     * <code>WKBWriter</code>.
+     */
+    virtual void
+    setIncludeSRID(int newIncludeSRID)
+    {
+        includeSRID = (0 == newIncludeSRID ? false : true);
+    }
+
+    /**
+     * \brief Write a Geometry to an ostream.
+     *
+     * @param g the geometry to write
+     * @param os the output stream
+     * @throws IOException
+     */
+    void write(const geom::Geometry& g, std::ostream& os);
+    // throws IOException, ParseException
+
+    /**
+     * \brief Write a Geometry to an ostream in binary hex format.
+     *
+     * @param g the geometry to write
+     * @param os the output stream
+     * @throws IOException
+     */
+    void writeHEX(const geom::Geometry& g, std::ostream& os);
+    // throws IOException, ParseException
 
 private:
 
-	int defaultOutputDimension;
+    int defaultOutputDimension;
     int outputDimension;
 
-	int byteOrder;
+    int byteOrder;
 
-	bool includeSRID;
+    bool includeSRID;
 
-	std::ostream *outStream;
+    std::ostream* outStream;
 
-	unsigned char buf[8];
+    unsigned char buf[8];
 
-	void writePoint(const geom::Point &p);
-		// throws IOException
+    void writePoint(const geom::Point& p);
+    // throws IOException
 
-	void writeLineString(const geom::LineString &ls);
-		// throws IOException
+    void writeLineString(const geom::LineString& ls);
+    // throws IOException
 
-	void writePolygon(const geom::Polygon &p);
-		// throws IOException
+    void writePolygon(const geom::Polygon& p);
+    // throws IOException
 
-	void writeGeometryCollection(const geom::GeometryCollection &c, int wkbtype);
-		// throws IOException, ParseException
+    void writeGeometryCollection(const geom::GeometryCollection& c, int wkbtype);
+    // throws IOException, ParseException
 
-	void writeCoordinateSequence(const geom::CoordinateSequence &cs, bool sized);
-		// throws IOException
+    void writeCoordinateSequence(const geom::CoordinateSequence& cs, bool sized);
+    // throws IOException
 
-	void writeCoordinate(const geom::CoordinateSequence &cs, size_t idx, bool is3d);
-		// throws IOException
+    void writeCoordinate(const geom::CoordinateSequence& cs, size_t idx, bool is3d);
+    // throws IOException
 
-	void writeGeometryType(int geometryType, int SRID);
-		// throws IOException
+    void writeGeometryType(int geometryType, int SRID);
+    // throws IOException
 
-	void writeSRID(int SRID);
-		// throws IOException
+    void writeSRID(int SRID);
+    // throws IOException
 
-	void writeByteOrder();
-		// throws IOException
+    void writeByteOrder();
+    // throws IOException
 
-	void writeInt(int intValue);
-		// throws IOException
+    void writeInt(int intValue);
+    // throws IOException
 
 };
 
diff --git a/include/geos/io/WKTReader.h b/include/geos/io/WKTReader.h
index 0d49bb5..1dfd4ff 100644
--- a/include/geos/io/WKTReader.h
+++ b/include/geos/io/WKTReader.h
@@ -28,23 +28,23 @@
 
 // Forward declarations
 namespace geos {
-	namespace io {
-		class StringTokenizer;
-	}
-	namespace geom {
-
-		class Coordinate;
-		class Geometry;
-		class GeometryCollection;
-		class Point;
-		class LineString;
-		class LinearRing;
-		class Polygon;
-		class MultiPoint;
-		class MultiLineString;
-		class MultiPolygon;
-		class PrecisionModel;
-	}
+namespace io {
+class StringTokenizer;
+}
+namespace geom {
+
+class Coordinate;
+class Geometry;
+class GeometryCollection;
+class Point;
+class LineString;
+class LinearRing;
+class Polygon;
+class MultiPoint;
+class MultiLineString;
+class MultiPolygon;
+class PrecisionModel;
+}
 }
 
 
@@ -57,57 +57,57 @@ namespace io {
  */
 class GEOS_DLL WKTReader {
 public:
-	//WKTReader();
+    //WKTReader();
 
-	/**
-	 * \brief Inizialize parser with given GeometryFactory.
-	 *
-	 * Note that all Geometry objects created by the
-	 * parser will contain a pointer to the given factory
-	 * so be sure you'll keep the factory alive for the
-	 * whole WKTReader and created Geometry life.
-	 */
-	WKTReader(const geom::GeometryFactory &gf);
+    /**
+     * \brief Inizialize parser with given GeometryFactory.
+     *
+     * Note that all Geometry objects created by the
+     * parser will contain a pointer to the given factory
+     * so be sure you'll keep the factory alive for the
+     * whole WKTReader and created Geometry life.
+     */
+    WKTReader(const geom::GeometryFactory& gf);
 
-	/** @deprecated in 3.4.0 */
-	WKTReader(const geom::GeometryFactory *gf);
+    /** @deprecated in 3.4.0 */
+    WKTReader(const geom::GeometryFactory* gf);
 
-	/**
-	 * \brief Inizialize parser with default GeometryFactory.
-	 *
-	 */
-	WKTReader();
+    /**
+     * \brief Inizialize parser with default GeometryFactory.
+     *
+     */
+    WKTReader();
 
-	~WKTReader();
+    ~WKTReader();
 
-	/// Parse a WKT string returning a Geometry
-	geom::Geometry* read(const std::string &wellKnownText);
+    /// Parse a WKT string returning a Geometry
+    geom::Geometry* read(const std::string& wellKnownText);
 
 //	Geometry* read(Reader& reader);	//Not implemented yet
 
 protected:
-	geom::CoordinateSequence* getCoordinates(io::StringTokenizer *tokenizer);
-	double getNextNumber(io::StringTokenizer *tokenizer);
-	std::string getNextEmptyOrOpener(io::StringTokenizer *tokenizer);
-	std::string getNextCloserOrComma(io::StringTokenizer *tokenizer);
-	std::string getNextCloser(io::StringTokenizer *tokenizer);
-	std::string getNextWord(io::StringTokenizer *tokenizer);
-	geom::Geometry* readGeometryTaggedText(io::StringTokenizer *tokenizer);
-	geom::Point* readPointText(io::StringTokenizer *tokenizer);
-	geom::LineString* readLineStringText(io::StringTokenizer *tokenizer);
-	geom::LinearRing* readLinearRingText(io::StringTokenizer *tokenizer);
-	geom::MultiPoint* readMultiPointText(io::StringTokenizer *tokenizer);
-	geom::Polygon* readPolygonText(io::StringTokenizer *tokenizer);
-	geom::MultiLineString* readMultiLineStringText(io::StringTokenizer *tokenizer);
-	geom::MultiPolygon* readMultiPolygonText(io::StringTokenizer *tokenizer);
-	geom::GeometryCollection* readGeometryCollectionText(io::StringTokenizer *tokenizer);
+    geom::CoordinateSequence* getCoordinates(io::StringTokenizer* tokenizer);
+    double getNextNumber(io::StringTokenizer* tokenizer);
+    std::string getNextEmptyOrOpener(io::StringTokenizer* tokenizer);
+    std::string getNextCloserOrComma(io::StringTokenizer* tokenizer);
+    std::string getNextCloser(io::StringTokenizer* tokenizer);
+    std::string getNextWord(io::StringTokenizer* tokenizer);
+    geom::Geometry* readGeometryTaggedText(io::StringTokenizer* tokenizer);
+    geom::Point* readPointText(io::StringTokenizer* tokenizer);
+    geom::LineString* readLineStringText(io::StringTokenizer* tokenizer);
+    geom::LinearRing* readLinearRingText(io::StringTokenizer* tokenizer);
+    geom::MultiPoint* readMultiPointText(io::StringTokenizer* tokenizer);
+    geom::Polygon* readPolygonText(io::StringTokenizer* tokenizer);
+    geom::MultiLineString* readMultiLineStringText(io::StringTokenizer* tokenizer);
+    geom::MultiPolygon* readMultiPolygonText(io::StringTokenizer* tokenizer);
+    geom::GeometryCollection* readGeometryCollectionText(io::StringTokenizer* tokenizer);
 private:
-	const geom::GeometryFactory *geometryFactory;
-	const geom::PrecisionModel *precisionModel;
+    const geom::GeometryFactory* geometryFactory;
+    const geom::PrecisionModel* precisionModel;
 
-	void getPreciseCoordinate(io::StringTokenizer *tokenizer, geom::Coordinate&, std::size_t &dim );
+    void getPreciseCoordinate(io::StringTokenizer* tokenizer, geom::Coordinate&, std::size_t& dim);
 
-	bool isNumberNext(io::StringTokenizer *tokenizer);
+    bool isNumberNext(io::StringTokenizer* tokenizer);
 };
 
 } // namespace io
diff --git a/include/geos/io/WKTReader.inl b/include/geos/io/WKTReader.inl
index a0f1bc5..2e91a36 100644
--- a/include/geos/io/WKTReader.inl
+++ b/include/geos/io/WKTReader.inl
@@ -7,7 +7,7 @@
  *
  * This is free software; you can redistribute and/or modify it under
  * the terms of the GNU Lesser General Public Licence as published
- * by the Free Software Foundation. 
+ * by the Free Software Foundation.
  * See the COPYING file for more information.
  *
  **********************************************************************
@@ -30,10 +30,10 @@ namespace geos {
 namespace io {
 
 INLINE
-WKTReader::WKTReader(const geom::GeometryFactory *gf)
-	:
-	geometryFactory(gf),
-	precisionModel(gf->getPrecisionModel())
+WKTReader::WKTReader(const geom::GeometryFactory* gf)
+    :
+    geometryFactory(gf),
+    precisionModel(gf->getPrecisionModel())
 {
 #if GEOS_DEBUG
     std::cerr << "\nGEOS_DEBUG: WKTReader::WKTReader(const GeometryFactory *gf)\n";
@@ -41,10 +41,10 @@ WKTReader::WKTReader(const geom::GeometryFactory *gf)
 }
 
 INLINE
-WKTReader::WKTReader(const geom::GeometryFactory &gf)
-	:
-	geometryFactory(&gf),
-	precisionModel(gf.getPrecisionModel())
+WKTReader::WKTReader(const geom::GeometryFactory& gf)
+    :
+    geometryFactory(&gf),
+    precisionModel(gf.getPrecisionModel())
 {
 #if GEOS_DEBUG
     std::cerr << "\nGEOS_DEBUG: WKTReader::WKTReader(const GeometryFactory &gf)\n";
@@ -53,9 +53,9 @@ WKTReader::WKTReader(const geom::GeometryFactory &gf)
 
 INLINE
 WKTReader::WKTReader()
-	:
-	geometryFactory(geom::GeometryFactory::getDefaultInstance()),
-	precisionModel(geometryFactory->getPrecisionModel())
+    :
+    geometryFactory(geom::GeometryFactory::getDefaultInstance()),
+    precisionModel(geometryFactory->getPrecisionModel())
 {
 #if GEOS_DEBUG
     std::cerr << "\nGEOS_DEBUG: WKTReader::WKTReader()\n";
diff --git a/include/geos/io/WKTWriter.h b/include/geos/io/WKTWriter.h
index e034804..ed05fc2 100644
--- a/include/geos/io/WKTWriter.h
+++ b/include/geos/io/WKTWriter.h
@@ -32,23 +32,23 @@
 
 // Forward declarations
 namespace geos {
-	namespace geom {
-		class Coordinate;
-		class CoordinateSequence;
-		class Geometry;
-		class GeometryCollection;
-		class Point;
-		class LineString;
-		class LinearRing;
-		class Polygon;
-		class MultiPoint;
-		class MultiLineString;
-		class MultiPolygon;
-		class PrecisionModel;
-	}
-	namespace io {
-		class Writer;
-	}
+namespace geom {
+class Coordinate;
+class CoordinateSequence;
+class Geometry;
+class GeometryCollection;
+class Point;
+class LineString;
+class LinearRing;
+class Polygon;
+class MultiPoint;
+class MultiLineString;
+class MultiPolygon;
+class PrecisionModel;
+}
+namespace io {
+class Writer;
+}
 }
 
 
@@ -78,190 +78,198 @@ namespace io {
  */
 class GEOS_DLL WKTWriter {
 public:
-	WKTWriter();
-	~WKTWriter();
-
-	//string(count, ch) can be used for this
-	//static string stringOfChar(char ch, int count);
-
-	/// Returns WKT string for the given Geometry
-	std::string write(const geom::Geometry *geometry);
-
-	// Send Geometry's WKT to the given Writer
-	void write(const geom::Geometry *geometry, Writer *writer);
-
-	std::string writeFormatted(const geom::Geometry *geometry);
-
-	void writeFormatted(const geom::Geometry *geometry, Writer *writer);
-
-	/**
-	 * Generates the WKT for a N-point <code>LineString</code>.
-	 *
-	 * @param seq the sequence to outpout
-	 *
-	 * @return the WKT
-	 */
-	static std::string toLineString(const geom::CoordinateSequence& seq);
-
-	/**
-	 * Generates the WKT for a 2-point <code>LineString</code>.
-	 *
-	 * @param p0 the first coordinate
-	 * @param p1 the second coordinate
-	 *
-	 * @return the WKT
-	 */
-	static std::string toLineString(const geom::Coordinate& p0, const geom::Coordinate& p1);
-
-	/**
-	 * Generates the WKT for a <code>Point</code>.
-	 *
-	 * @param p0 the point coordinate
-	 *
-	 * @return the WKT
-	 */
-	static std::string toPoint(const geom::Coordinate& p0);
-
-	/**
-	 * Sets the rounding precision when writing the WKT
-	 * a precision of -1 disables it
-	 *
-	 * @param p0 the new precision to use
-	 *
-	 */
-	void setRoundingPrecision(int p0);
-
-	/**
-	 * Enables/disables trimming of unnecessary decimals
-	 *
-	 * @param p0 the trim boolean
-	 *
-	 */
-	void setTrim(bool p0);
-
-	/**
-	 * Enable old style 3D/4D WKT generation.
-	 *
-	 * By default the WKBWriter produces new style 3D/4D WKT
-	 * (ie. "POINT Z (10 20 30)") but if this method is used
-	 * to turn on old style WKT production then the WKT will
-	 * be formatted in the style "POINT (10 20 30)".
-	 *
-	 * @param useOld3D true or false
-	 */
-	void setOld3D(bool useOld3D ) { old3D = useOld3D; }
-
-	/*
-	 * \brief
-	 * Returns the output dimension used by the
-	 * <code>WKBWriter</code>.
-	 */
-	int getOutputDimension() const { return defaultOutputDimension; }
-
-	/*
-	 * Sets the output dimension used by the <code>WKBWriter</code>.
-	 *
-	 * @param newOutputDimension Supported values are 2 or 3.
-	 *        Note that 3 indicates up to 3 dimensions will be
-	 *        written but 2D WKB is still produced for 2D geometries.
-	 */
-	void setOutputDimension(int newOutputDimension);
+    WKTWriter();
+    ~WKTWriter();
+
+    //string(count, ch) can be used for this
+    //static string stringOfChar(char ch, int count);
+
+    /// Returns WKT string for the given Geometry
+    std::string write(const geom::Geometry* geometry);
+
+    // Send Geometry's WKT to the given Writer
+    void write(const geom::Geometry* geometry, Writer* writer);
+
+    std::string writeFormatted(const geom::Geometry* geometry);
+
+    void writeFormatted(const geom::Geometry* geometry, Writer* writer);
+
+    /**
+     * Generates the WKT for a N-point <code>LineString</code>.
+     *
+     * @param seq the sequence to outpout
+     *
+     * @return the WKT
+     */
+    static std::string toLineString(const geom::CoordinateSequence& seq);
+
+    /**
+     * Generates the WKT for a 2-point <code>LineString</code>.
+     *
+     * @param p0 the first coordinate
+     * @param p1 the second coordinate
+     *
+     * @return the WKT
+     */
+    static std::string toLineString(const geom::Coordinate& p0, const geom::Coordinate& p1);
+
+    /**
+     * Generates the WKT for a <code>Point</code>.
+     *
+     * @param p0 the point coordinate
+     *
+     * @return the WKT
+     */
+    static std::string toPoint(const geom::Coordinate& p0);
+
+    /**
+     * Sets the rounding precision when writing the WKT
+     * a precision of -1 disables it
+     *
+     * @param p0 the new precision to use
+     *
+     */
+    void setRoundingPrecision(int p0);
+
+    /**
+     * Enables/disables trimming of unnecessary decimals
+     *
+     * @param p0 the trim boolean
+     *
+     */
+    void setTrim(bool p0);
+
+    /**
+     * Enable old style 3D/4D WKT generation.
+     *
+     * By default the WKBWriter produces new style 3D/4D WKT
+     * (ie. "POINT Z (10 20 30)") but if this method is used
+     * to turn on old style WKT production then the WKT will
+     * be formatted in the style "POINT (10 20 30)".
+     *
+     * @param useOld3D true or false
+     */
+    void
+    setOld3D(bool useOld3D)
+    {
+        old3D = useOld3D;
+    }
+
+    /*
+     * \brief
+     * Returns the output dimension used by the
+     * <code>WKBWriter</code>.
+     */
+    int
+    getOutputDimension() const
+    {
+        return defaultOutputDimension;
+    }
+
+    /*
+     * Sets the output dimension used by the <code>WKBWriter</code>.
+     *
+     * @param newOutputDimension Supported values are 2 or 3.
+     *        Note that 3 indicates up to 3 dimensions will be
+     *        written but 2D WKB is still produced for 2D geometries.
+     */
+    void setOutputDimension(int newOutputDimension);
 
 protected:
 
-  int decimalPlaces;
+    int decimalPlaces;
 
-	void appendGeometryTaggedText(const geom::Geometry *geometry, int level, Writer *writer);
+    void appendGeometryTaggedText(const geom::Geometry* geometry, int level, Writer* writer);
 
-	void appendPointTaggedText(
-			const geom::Coordinate* coordinate,
-			int level, Writer *writer);
+    void appendPointTaggedText(
+        const geom::Coordinate* coordinate,
+        int level, Writer* writer);
 
-	void appendLineStringTaggedText(
-			const geom::LineString *lineString,
-			int level, Writer *writer);
+    void appendLineStringTaggedText(
+        const geom::LineString* lineString,
+        int level, Writer* writer);
 
-	void appendLinearRingTaggedText(
-			const geom::LinearRing *lineString,
-			int level, Writer *writer);
+    void appendLinearRingTaggedText(
+        const geom::LinearRing* lineString,
+        int level, Writer* writer);
 
-	void appendPolygonTaggedText(
-			const geom::Polygon *polygon,
-			int level, Writer *writer);
+    void appendPolygonTaggedText(
+        const geom::Polygon* polygon,
+        int level, Writer* writer);
 
-	void appendMultiPointTaggedText(
-			const geom::MultiPoint *multipoint,
-			int level, Writer *writer);
+    void appendMultiPointTaggedText(
+        const geom::MultiPoint* multipoint,
+        int level, Writer* writer);
 
-	void appendMultiLineStringTaggedText(
-			const geom::MultiLineString *multiLineString,
-			int level,Writer *writer);
+    void appendMultiLineStringTaggedText(
+        const geom::MultiLineString* multiLineString,
+        int level, Writer* writer);
 
-	void appendMultiPolygonTaggedText(
-			const geom::MultiPolygon *multiPolygon,
-			int level, Writer *writer);
+    void appendMultiPolygonTaggedText(
+        const geom::MultiPolygon* multiPolygon,
+        int level, Writer* writer);
 
-	void appendGeometryCollectionTaggedText(
-			const geom::GeometryCollection *geometryCollection,
-			int level,Writer *writer);
+    void appendGeometryCollectionTaggedText(
+        const geom::GeometryCollection* geometryCollection,
+        int level, Writer* writer);
 
-	void appendPointText(const geom::Coordinate* coordinate, int level,
-			Writer *writer);
+    void appendPointText(const geom::Coordinate* coordinate, int level,
+                         Writer* writer);
 
-	void appendCoordinate(const geom::Coordinate* coordinate,
-			Writer *writer);
+    void appendCoordinate(const geom::Coordinate* coordinate,
+                          Writer* writer);
 
-	std::string writeNumber(double d);
+    std::string writeNumber(double d);
 
-	void appendLineStringText(
-			const geom::LineString *lineString,
-			int level, bool doIndent, Writer *writer);
+    void appendLineStringText(
+        const geom::LineString* lineString,
+        int level, bool doIndent, Writer* writer);
 
-	void appendPolygonText(
-			const geom::Polygon *polygon,
-			int level, bool indentFirst, Writer *writer);
+    void appendPolygonText(
+        const geom::Polygon* polygon,
+        int level, bool indentFirst, Writer* writer);
 
-	void appendMultiPointText(
-			const geom::MultiPoint *multiPoint,
-			int level, Writer *writer);
+    void appendMultiPointText(
+        const geom::MultiPoint* multiPoint,
+        int level, Writer* writer);
 
-	void appendMultiLineStringText(
-			const geom::MultiLineString *multiLineString,
-			int level, bool indentFirst,Writer *writer);
+    void appendMultiLineStringText(
+        const geom::MultiLineString* multiLineString,
+        int level, bool indentFirst, Writer* writer);
 
-	void appendMultiPolygonText(
-			const geom::MultiPolygon *multiPolygon,
-			int level, Writer *writer);
+    void appendMultiPolygonText(
+        const geom::MultiPolygon* multiPolygon,
+        int level, Writer* writer);
 
-	void appendGeometryCollectionText(
-			const geom::GeometryCollection *geometryCollection,
-			int level,Writer *writer);
+    void appendGeometryCollectionText(
+        const geom::GeometryCollection* geometryCollection,
+        int level, Writer* writer);
 
 private:
 
-	enum {
-		INDENT = 2
-	};
+    enum {
+        INDENT = 2
+    };
 
 //	static const int INDENT = 2;
 
-	bool isFormatted;
+    bool isFormatted;
 
-	int roundingPrecision;
+    int roundingPrecision;
 
-	bool trim;
+    bool trim;
 
-	int level;
+    int level;
 
-	int defaultOutputDimension;
+    int defaultOutputDimension;
     int outputDimension;
     bool old3D;
 
-	void writeFormatted(
-			const geom::Geometry *geometry,
-			bool isFormatted, Writer *writer);
+    void writeFormatted(
+        const geom::Geometry* geometry,
+        bool isFormatted, Writer* writer);
 
-	void indent(int level, Writer *writer);
+    void indent(int level, Writer* writer);
 };
 
 } // namespace geos::io
diff --git a/include/geos/io/Writer.h b/include/geos/io/Writer.h
index ffca1d8..9cfc344 100644
--- a/include/geos/io/Writer.h
+++ b/include/geos/io/Writer.h
@@ -34,13 +34,13 @@ namespace io {
 
 class GEOS_DLL Writer {
 public:
-	Writer();
-	void reserve(std::size_t capacity);
-	~Writer();
-	void write(const std::string& txt);
-	const std::string& toString();
+    Writer();
+    void reserve(std::size_t capacity);
+    ~Writer();
+    void write(const std::string& txt);
+    const std::string& toString();
 private:
-	std::string str;
+    std::string str;
 };
 
 } // namespace geos::io
diff --git a/include/geos/linearref/ExtractLineByLocation.h b/include/geos/linearref/ExtractLineByLocation.h
index 44a3b43..43e9968 100644
--- a/include/geos/linearref/ExtractLineByLocation.h
+++ b/include/geos/linearref/ExtractLineByLocation.h
@@ -24,65 +24,62 @@
 #include <geos/geom/Geometry.h>
 #include <geos/linearref/LinearLocation.h>
 
-namespace geos
-{
-namespace linearref   // geos::linearref
-{
+namespace geos {
+namespace linearref { // geos::linearref
 
 /**
  * Extracts the subline of a linear {@link Geometry} between
  * two {@link LinearLocation}s on the line.
  */
-class ExtractLineByLocation
-{
+class ExtractLineByLocation {
 
 private:
-	const geom::Geometry *line;
-	geom::Geometry *reverse(const geom::Geometry *linear);
+    const geom::Geometry* line;
+    geom::Geometry* reverse(const geom::Geometry* linear);
 
-	/**
-	 * Assumes input is valid (e.g. start <= end)
-	 *
-	 * @param start
-	 * @param end
-	 * @return a linear geometry
-	 */
-	geom::LineString* computeLine(const LinearLocation& start, const LinearLocation& end);
+    /**
+     * Assumes input is valid (e.g. start <= end)
+     *
+     * @param start
+     * @param end
+     * @return a linear geometry
+     */
+    geom::LineString* computeLine(const LinearLocation& start, const LinearLocation& end);
 
-	/**
-	 * Assumes input is valid (e.g. start <= end)
-	 *
-	 * @param start
-	 * @param end
-	 * @return a linear geometry
-	 */
-	geom::Geometry *computeLinear(const LinearLocation& start, const LinearLocation& end);
+    /**
+     * Assumes input is valid (e.g. start <= end)
+     *
+     * @param start
+     * @param end
+     * @return a linear geometry
+     */
+    geom::Geometry* computeLinear(const LinearLocation& start, const LinearLocation& end);
 
 public:
-	/**
-	 * Computes the subline of a {@link LineString} between
-	 * two {@link LineStringLocation}s on the line.
-	 * If the start location is after the end location,
-	 * the computed geometry is reversed.
-	 *
-	 * @param line the line to use as the baseline
-	 * @param start the start location
-	 * @param end the end location
-	 * @return the extracted subline
-	 */
-	static geom::Geometry *extract(const geom::Geometry *line, const LinearLocation& start, const LinearLocation& end);
+    /**
+     * Computes the subline of a {@link LineString} between
+     * two {@link LineStringLocation}s on the line.
+     * If the start location is after the end location,
+     * the computed geometry is reversed.
+     *
+     * @param line the line to use as the baseline
+     * @param start the start location
+     * @param end the end location
+     * @return the extracted subline
+     */
+    static geom::Geometry* extract(const geom::Geometry* line, const LinearLocation& start, const LinearLocation& end);
 
-	ExtractLineByLocation(const geom::Geometry *line);
+    ExtractLineByLocation(const geom::Geometry* line);
 
-	/**
-	 * Extracts a subline of the input.
-	 * If <code>end < start</code> the linear geometry computed will be reversed.
-	 *
-	 * @param start the start location
-	 * @param end the end location
-	 * @return a linear geometry
-	 */
-	geom::Geometry *extract(const LinearLocation& start, const LinearLocation& end);
+    /**
+     * Extracts a subline of the input.
+     * If <code>end < start</code> the linear geometry computed will be reversed.
+     *
+     * @param start the start location
+     * @param end the end location
+     * @return a linear geometry
+     */
+    geom::Geometry* extract(const LinearLocation& start, const LinearLocation& end);
 
 };
 }
diff --git a/include/geos/linearref/LengthIndexOfPoint.h b/include/geos/linearref/LengthIndexOfPoint.h
index fb5cdc4..f640394 100644
--- a/include/geos/linearref/LengthIndexOfPoint.h
+++ b/include/geos/linearref/LengthIndexOfPoint.h
@@ -28,10 +28,8 @@
 #include <geos/linearref/LinearLocation.h>
 
 
-namespace geos
-{
-namespace linearref   // geos::linearref
-{
+namespace geos {
+namespace linearref { // geos::linearref
 
 /**
  * \brief
@@ -42,48 +40,47 @@ namespace linearref   // geos::linearref
  * always computes the nearest point closest to
  * the start of the geometry.
  */
-class LengthIndexOfPoint
-{
+class LengthIndexOfPoint {
 
 private:
-	const geom::Geometry *linearGeom;
+    const geom::Geometry* linearGeom;
 
-	double indexOfFromStart(const geom::Coordinate& inputPt, const double minIndex) const;
+    double indexOfFromStart(const geom::Coordinate& inputPt, const double minIndex) const;
 
-	double segmentNearestMeasure(const geom::LineSegment *seg,
-                               const geom::Coordinate& inputPt,
-                               double segmentStartMeasure) const;
+    double segmentNearestMeasure(const geom::LineSegment* seg,
+                                 const geom::Coordinate& inputPt,
+                                 double segmentStartMeasure) const;
 public:
-	static double indexOf(const geom::Geometry *linearGeom, const geom::Coordinate& inputPt);
+    static double indexOf(const geom::Geometry* linearGeom, const geom::Coordinate& inputPt);
 
-	static double indexOfAfter(const geom::Geometry *linearGeom, const geom::Coordinate& inputPt, double minIndex);
+    static double indexOfAfter(const geom::Geometry* linearGeom, const geom::Coordinate& inputPt, double minIndex);
 
-	LengthIndexOfPoint(const geom::Geometry *linearGeom);
+    LengthIndexOfPoint(const geom::Geometry* linearGeom);
 
-	/**
-	 * Find the nearest location along a linear Geometry to a given point.
-	 *
-	 * @param inputPt the coordinate to locate
-	 * @return the location of the nearest point
-	 */
-	double indexOf(const geom::Coordinate& inputPt) const;
+    /**
+     * Find the nearest location along a linear Geometry to a given point.
+     *
+     * @param inputPt the coordinate to locate
+     * @return the location of the nearest point
+     */
+    double indexOf(const geom::Coordinate& inputPt) const;
 
-	/** \brief
-	 * Finds the nearest index along the linear Geometry
-	 * to a given Coordinate after the specified minimum index.
-	 *
-	 * If possible the location returned will be strictly greater than the
-	 * <code>minLocation</code>.
-	 * If this is not possible, the
-	 * value returned will equal <code>minLocation</code>.
-	 * (An example where this is not possible is when
-	 * minLocation = [end of line] ).
-	 *
-	 * @param inputPt the coordinate to locate
-	 * @param minLocation the minimum location for the point location
-	 * @return the location of the nearest point
-	 */
-	double indexOfAfter(const geom::Coordinate& inputPt, double minIndex) const;
+    /** \brief
+     * Finds the nearest index along the linear Geometry
+     * to a given Coordinate after the specified minimum index.
+     *
+     * If possible the location returned will be strictly greater than the
+     * <code>minLocation</code>.
+     * If this is not possible, the
+     * value returned will equal <code>minLocation</code>.
+     * (An example where this is not possible is when
+     * minLocation = [end of line] ).
+     *
+     * @param inputPt the coordinate to locate
+     * @param minLocation the minimum location for the point location
+     * @return the location of the nearest point
+     */
+    double indexOfAfter(const geom::Coordinate& inputPt, double minIndex) const;
 
 };
 }
diff --git a/include/geos/linearref/LengthIndexedLine.h b/include/geos/linearref/LengthIndexedLine.h
index ede548e..d0c74b3 100644
--- a/include/geos/linearref/LengthIndexedLine.h
+++ b/include/geos/linearref/LengthIndexedLine.h
@@ -26,10 +26,8 @@
 #include <geos/geom/Geometry.h>
 #include <geos/linearref/LinearLocation.h>
 
-namespace geos
-{
-namespace linearref   // geos::linearref
-{
+namespace geos {
+namespace linearref { // geos::linearref
 
 /** \brief
  * Supports linear referencing along a linear {@link Geometry}
@@ -42,166 +40,165 @@ namespace linearref   // geos::linearref
  * themselves) are supported.
  */
 
-class GEOS_DLL LengthIndexedLine
-{
+class GEOS_DLL LengthIndexedLine {
 private:
-	const geom::Geometry *linearGeom;
-	LinearLocation locationOf(double index) const;
-	LinearLocation locationOf(double index, bool resolveLower) const;
-	double positiveIndex(double index) const;
+    const geom::Geometry* linearGeom;
+    LinearLocation locationOf(double index) const;
+    LinearLocation locationOf(double index, bool resolveLower) const;
+    double positiveIndex(double index) const;
 
 public:
 
-	/** \brief
-	 * Constructs an object which allows a linear {@link Geometry}
-	 * to be linearly referenced using length as an index.
-	 *
-	 * @param linearGeom the linear geometry to reference along
-	 */
-
-	LengthIndexedLine(const geom::Geometry *linearGeom);
-
-	/** \brief
-	 * Computes the {@link Coordinate} for the point
-	 * on the line at the given index.
-	 * If the index is out of range the first or last point on the
-	 * line will be returned.
-	 * The Z-ordinate of the computed point will be interpolated from
-	 * the Z-ordinates of the line segment containing it, if they exist.
-	 *
-	 * @param index the index of the desired point
-	 * @return the Coordinate at the given index
-	 */
-	geom::Coordinate extractPoint(double index) const;
-
-
-	/**
-	 * \brief
-	 * Computes the {@link Coordinate} for the point
-	 * on the line at the given index, offset by the given distance.
-	 *
-	 * If the index is out of range the first or last point on the
-	 * line will be returned.
-	 * The computed point is offset to the left of the line if the
-	 * offset distance is positive, to the right if negative.
-	 *
-	 * The Z-ordinate of the computed point will be interpolated from
-	 * the Z-ordinates of the line segment containing it, if they exist.
-	 *
-	 * @param index the index of the desired point
-	 * @param offsetDistance the distance the point is offset from the segment
-	 *    (positive is to the left, negative is to the right)
-	 * @return the Coordinate at the given index
-	 */
-	geom::Coordinate extractPoint(double index, double offsetDistance) const;
-
-	/**
-	 * Computes the {@link LineString} for the interval
-	 * on the line between the given indices.
-	 * If the endIndex lies before the startIndex,
-	 * the computed geometry is reversed.
-	 *
-	 * @param startIndex the index of the start of the interval
-	 * @param endIndex the index of the end of the interval
-	 * @return the linear interval between the indices
-	 */
-	geom::Geometry *extractLine(double startIndex, double endIndex) const;
-
-
-	/**
-	 * Computes the minimum index for a point on the line.
-	 * If the line is not simple (i.e. loops back on itself)
-	 * a single point may have more than one possible index.
-	 * In this case, the smallest index is returned.
-	 *
-	 * The supplied point does not <i>necessarily</i> have to lie precisely
-	 * on the line, but if it is far from the line the accuracy and
-	 * performance of this function is not guaranteed.
-	 * Use {@link #project} to compute a guaranteed result for points
-	 * which may be far from the line.
-	 *
-	 * @param pt a point on the line
-	 * @return the minimum index of the point
-	 *
-	 * @see project
-	 */
-	double indexOf(const geom::Coordinate& pt) const;
-
-	/**
-	 * Finds the index for a point on the line
-	 * which is greater than the given index.
-	 * If no such index exists, returns <tt>minIndex</tt>.
-	 * This method can be used to determine all indexes for
-	 * a point which occurs more than once on a non-simple line.
-	 * It can also be used to disambiguate cases where the given point lies
-	 * slightly off the line and is equidistant from two different
-	 * points on the line.
-	 *
-	 * The supplied point does not <i>necessarily</i> have to lie precisely
-	 * on the line, but if it is far from the line the accuracy and
-	 * performance of this function is not guaranteed.
-	 * Use {@link #project} to compute a guaranteed result for points
-	 * which may be far from the line.
-	 *
-	 * @param pt a point on the line
-	 * @param minIndex the value the returned index must be greater than
-	 * @return the index of the point greater than the given minimum index
-	 *
-	 * @see project
-	 */
-	double indexOfAfter(const geom::Coordinate& pt, double minIndex) const;
-
-	/**
-	 * Computes the indices for a subline of the line.
-	 * (The subline must <b>conform</b> to the line; that is,
-	 * all vertices in the subline (except possibly the first and last)
-	 * must be vertices of the line and occcur in the same order).
-	 *
-	 * @param subLine a subLine of the line
-	 * @return a pair of indices for the start and end of the subline.
-	 */
-	double* indicesOf(const geom::Geometry *subLine) const;
-
-
-	/**
-	 * Computes the index for the closest point on the line to the given point.
-	 * If more than one point has the closest distance the first one along the line
-	 * is returned.
-	 * (The point does not necessarily have to lie precisely on the line.)
-	 *
-	 * @param pt a point on the line
-	 * @return the index of the point
-	 */
-	double project(const geom::Coordinate& pt) const;
-
-	/**
-	 * Returns the index of the start of the line
-	 * @return the start index
-	 */
-	double getStartIndex() const;
-
-	/**
-	 * Returns the index of the end of the line
-	 * @return the end index
-	 */
-	double getEndIndex() const;
-
-	/**
-	 * Tests whether an index is in the valid index range for the line.
-	 *
-	 * @param length the index to test
-	 * @return <code>true</code> if the index is in the valid range
-	 */
-	bool isValidIndex(double index) const;
-
-
-	/**
-	 * Computes a valid index for this line
-	 * by clamping the given index to the valid range of index values
-	 *
-	 * @return a valid index value
-	 */
-	double clampIndex(double index) const;
+    /** \brief
+     * Constructs an object which allows a linear {@link Geometry}
+     * to be linearly referenced using length as an index.
+     *
+     * @param linearGeom the linear geometry to reference along
+     */
+
+    LengthIndexedLine(const geom::Geometry* linearGeom);
+
+    /** \brief
+     * Computes the {@link Coordinate} for the point
+     * on the line at the given index.
+     * If the index is out of range the first or last point on the
+     * line will be returned.
+     * The Z-ordinate of the computed point will be interpolated from
+     * the Z-ordinates of the line segment containing it, if they exist.
+     *
+     * @param index the index of the desired point
+     * @return the Coordinate at the given index
+     */
+    geom::Coordinate extractPoint(double index) const;
+
+
+    /**
+     * \brief
+     * Computes the {@link Coordinate} for the point
+     * on the line at the given index, offset by the given distance.
+     *
+     * If the index is out of range the first or last point on the
+     * line will be returned.
+     * The computed point is offset to the left of the line if the
+     * offset distance is positive, to the right if negative.
+     *
+     * The Z-ordinate of the computed point will be interpolated from
+     * the Z-ordinates of the line segment containing it, if they exist.
+     *
+     * @param index the index of the desired point
+     * @param offsetDistance the distance the point is offset from the segment
+     *    (positive is to the left, negative is to the right)
+     * @return the Coordinate at the given index
+     */
+    geom::Coordinate extractPoint(double index, double offsetDistance) const;
+
+    /**
+     * Computes the {@link LineString} for the interval
+     * on the line between the given indices.
+     * If the endIndex lies before the startIndex,
+     * the computed geometry is reversed.
+     *
+     * @param startIndex the index of the start of the interval
+     * @param endIndex the index of the end of the interval
+     * @return the linear interval between the indices
+     */
+    geom::Geometry* extractLine(double startIndex, double endIndex) const;
+
+
+    /**
+     * Computes the minimum index for a point on the line.
+     * If the line is not simple (i.e. loops back on itself)
+     * a single point may have more than one possible index.
+     * In this case, the smallest index is returned.
+     *
+     * The supplied point does not <i>necessarily</i> have to lie precisely
+     * on the line, but if it is far from the line the accuracy and
+     * performance of this function is not guaranteed.
+     * Use {@link #project} to compute a guaranteed result for points
+     * which may be far from the line.
+     *
+     * @param pt a point on the line
+     * @return the minimum index of the point
+     *
+     * @see project
+     */
+    double indexOf(const geom::Coordinate& pt) const;
+
+    /**
+     * Finds the index for a point on the line
+     * which is greater than the given index.
+     * If no such index exists, returns <tt>minIndex</tt>.
+     * This method can be used to determine all indexes for
+     * a point which occurs more than once on a non-simple line.
+     * It can also be used to disambiguate cases where the given point lies
+     * slightly off the line and is equidistant from two different
+     * points on the line.
+     *
+     * The supplied point does not <i>necessarily</i> have to lie precisely
+     * on the line, but if it is far from the line the accuracy and
+     * performance of this function is not guaranteed.
+     * Use {@link #project} to compute a guaranteed result for points
+     * which may be far from the line.
+     *
+     * @param pt a point on the line
+     * @param minIndex the value the returned index must be greater than
+     * @return the index of the point greater than the given minimum index
+     *
+     * @see project
+     */
+    double indexOfAfter(const geom::Coordinate& pt, double minIndex) const;
+
+    /**
+     * Computes the indices for a subline of the line.
+     * (The subline must <b>conform</b> to the line; that is,
+     * all vertices in the subline (except possibly the first and last)
+     * must be vertices of the line and occcur in the same order).
+     *
+     * @param subLine a subLine of the line
+     * @return a pair of indices for the start and end of the subline.
+     */
+    double* indicesOf(const geom::Geometry* subLine) const;
+
+
+    /**
+     * Computes the index for the closest point on the line to the given point.
+     * If more than one point has the closest distance the first one along the line
+     * is returned.
+     * (The point does not necessarily have to lie precisely on the line.)
+     *
+     * @param pt a point on the line
+     * @return the index of the point
+     */
+    double project(const geom::Coordinate& pt) const;
+
+    /**
+     * Returns the index of the start of the line
+     * @return the start index
+     */
+    double getStartIndex() const;
+
+    /**
+     * Returns the index of the end of the line
+     * @return the end index
+     */
+    double getEndIndex() const;
+
+    /**
+     * Tests whether an index is in the valid index range for the line.
+     *
+     * @param length the index to test
+     * @return <code>true</code> if the index is in the valid range
+     */
+    bool isValidIndex(double index) const;
+
+
+    /**
+     * Computes a valid index for this line
+     * by clamping the given index to the valid range of index values
+     *
+     * @return a valid index value
+     */
+    double clampIndex(double index) const;
 };
 }
 }
diff --git a/include/geos/linearref/LengthLocationMap.h b/include/geos/linearref/LengthLocationMap.h
index bc4af6b..cb33543 100644
--- a/include/geos/linearref/LengthLocationMap.h
+++ b/include/geos/linearref/LengthLocationMap.h
@@ -34,95 +34,96 @@ namespace linearref { // geos::linearref
  * Negative lengths are measured in reverse from end of the linear geometry.
  * Out-of-range values are clamped.
  */
-class LengthLocationMap
-{
+class LengthLocationMap {
 
 
 private:
-	const geom::Geometry *linearGeom;
+    const geom::Geometry* linearGeom;
 
-	LinearLocation getLocationForward(double length) const;
+    LinearLocation getLocationForward(double length) const;
 
-	LinearLocation resolveHigher(const LinearLocation& loc) const;
+    LinearLocation resolveHigher(const LinearLocation& loc) const;
 
 public:
 
-	// TODO: cache computed cumulative length for each vertex
-	// TODO: support user-defined measures
-	// TODO: support measure index for fast mapping to a location
-
-	/**
-	 * \brief
-	 * Computes the {@link LinearLocation} for a
-	 * given length along a linear {@link Geometry}.
-	 *
-	 * @param line the linear geometry to use
-	 * @param length the length index of the location
-	 * @return the {@link LinearLocation} for the length
-	 */
-	static LinearLocation getLocation(const geom::Geometry *linearGeom, double length)
-	{
-    LengthLocationMap locater(linearGeom);
-    return locater.getLocation(length);
-	}
-
-	/**
-	 * \brief
-	 * Computes the {@link LinearLocation} for a
-	 * given length along a linear {@link Geometry}.
-	 *
-	 * @param line the linear geometry to use
-	 * @param length the length index of the location
-	 * @param resolveLower if true lengths are resolved to the
-	 *                     lowest possible index
-	 * @return the {@link LinearLocation} for the length
-	 */
-	static LinearLocation getLocation(const geom::Geometry *linearGeom, double length, bool resolveLower)
-  {
-    LengthLocationMap locater(linearGeom);
-    return locater.getLocation(length, resolveLower);
-  }
-
-	/**
-	 * Computes the length for a given {@link LinearLocation}
-	 * on a linear {@link Geometry}.
-	 *
-	 * @param line the linear geometry to use
-	 * @param loc the {@link LinearLocation} index of the location
-	 * @return the length for the {@link LinearLocation}
-	 */
-	static double getLength(const geom::Geometry *linearGeom, const LinearLocation& loc);
-
-	LengthLocationMap(const geom::Geometry *linearGeom);
-
-	/**
-	 * \brief
-	 * Compute the {@link LinearLocation} corresponding to a length.
-	 *
-	 * Negative lengths are measured in reverse from end of the linear geometry.
-	 * Out-of-range values are clamped.
-	 * Ambiguous indexes are resolved to the lowest possible location value,
-	 * depending on the value of <tt>resolveLower</tt>.
-	 *
-	 * @param length the length index
-	 * @return the corresponding LinearLocation
-	 */
-	LinearLocation getLocation(double length, bool resolveLower) const;
-
-	/**
-	 * \brief
-	 * Compute the {@link LinearLocation} corresponding to a length.
-	 *
-	 * Negative lengths are measured in reverse from end of the linear geometry.
-	 * Out-of-range values are clamped.
-	 * Ambiguous indexes are resolved to the lowest possible location value.
-	 *
-	 * @param length the length index
-	 * @return the corresponding LinearLocation
-	 */
-	LinearLocation getLocation(double length) const;
-
-	double getLength(const LinearLocation& loc) const;
+    // TODO: cache computed cumulative length for each vertex
+    // TODO: support user-defined measures
+    // TODO: support measure index for fast mapping to a location
+
+    /**
+     * \brief
+     * Computes the {@link LinearLocation} for a
+     * given length along a linear {@link Geometry}.
+     *
+     * @param line the linear geometry to use
+     * @param length the length index of the location
+     * @return the {@link LinearLocation} for the length
+     */
+    static LinearLocation
+    getLocation(const geom::Geometry* linearGeom, double length)
+    {
+        LengthLocationMap locater(linearGeom);
+        return locater.getLocation(length);
+    }
+
+    /**
+     * \brief
+     * Computes the {@link LinearLocation} for a
+     * given length along a linear {@link Geometry}.
+     *
+     * @param line the linear geometry to use
+     * @param length the length index of the location
+     * @param resolveLower if true lengths are resolved to the
+     *                     lowest possible index
+     * @return the {@link LinearLocation} for the length
+     */
+    static LinearLocation
+    getLocation(const geom::Geometry* linearGeom, double length, bool resolveLower)
+    {
+        LengthLocationMap locater(linearGeom);
+        return locater.getLocation(length, resolveLower);
+    }
+
+    /**
+     * Computes the length for a given {@link LinearLocation}
+     * on a linear {@link Geometry}.
+     *
+     * @param line the linear geometry to use
+     * @param loc the {@link LinearLocation} index of the location
+     * @return the length for the {@link LinearLocation}
+     */
+    static double getLength(const geom::Geometry* linearGeom, const LinearLocation& loc);
+
+    LengthLocationMap(const geom::Geometry* linearGeom);
+
+    /**
+     * \brief
+     * Compute the {@link LinearLocation} corresponding to a length.
+     *
+     * Negative lengths are measured in reverse from end of the linear geometry.
+     * Out-of-range values are clamped.
+     * Ambiguous indexes are resolved to the lowest possible location value,
+     * depending on the value of <tt>resolveLower</tt>.
+     *
+     * @param length the length index
+     * @return the corresponding LinearLocation
+     */
+    LinearLocation getLocation(double length, bool resolveLower) const;
+
+    /**
+     * \brief
+     * Compute the {@link LinearLocation} corresponding to a length.
+     *
+     * Negative lengths are measured in reverse from end of the linear geometry.
+     * Out-of-range values are clamped.
+     * Ambiguous indexes are resolved to the lowest possible location value.
+     *
+     * @param length the length index
+     * @return the corresponding LinearLocation
+     */
+    LinearLocation getLocation(double length) const;
+
+    double getLength(const LinearLocation& loc) const;
 
 };
 
diff --git a/include/geos/linearref/LinearGeometryBuilder.h b/include/geos/linearref/LinearGeometryBuilder.h
index a01c684..ebc0bd8 100644
--- a/include/geos/linearref/LinearGeometryBuilder.h
+++ b/include/geos/linearref/LinearGeometryBuilder.h
@@ -28,10 +28,8 @@
 
 #include <vector>
 
-namespace geos
-{
-namespace linearref   // geos::linearref
-{
+namespace geos {
+namespace linearref { // geos::linearref
 
 /**
  * Builds a linear geometry ({@link LineString} or {@link MultiLineString})
@@ -39,66 +37,65 @@ namespace linearref   // geos::linearref
  *
  * @version 1.7
  */
-class LinearGeometryBuilder
-{
+class LinearGeometryBuilder {
 private:
-	const geom::GeometryFactory* geomFact;
+    const geom::GeometryFactory* geomFact;
 
-	typedef std::vector<geom::Geometry *> GeomPtrVect;
+    typedef std::vector<geom::Geometry*> GeomPtrVect;
 
-	// Geometry elements owned by this class
-	GeomPtrVect lines;
+    // Geometry elements owned by this class
+    GeomPtrVect lines;
 
-	bool ignoreInvalidLines;
-	bool fixInvalidLines;
-	geom::CoordinateSequence* coordList;
+    bool ignoreInvalidLines;
+    bool fixInvalidLines;
+    geom::CoordinateSequence* coordList;
 
-	geom::Coordinate lastPt;
+    geom::Coordinate lastPt;
 
 public:
-	LinearGeometryBuilder(const geom::GeometryFactory* geomFact);
-
-	~LinearGeometryBuilder();
-
-	/**
-	 * Allows invalid lines to be ignored rather than causing Exceptions.
-	 * An invalid line is one which has only one unique point.
-	 *
-	 * @param ignoreShortLines <code>true</code> if short lines are
-	 *                         to be ignored
-	 */
-	void setIgnoreInvalidLines(bool ignoreInvalidLines);
-
-	/**
-	 * Allows invalid lines to be ignored rather than causing Exceptions.
-	 * An invalid line is one which has only one unique point.
-	 *
-	 * @param ignoreShortLines <code>true</code> if short lines are
-	 *                         to be ignored
-	 */
-	void setFixInvalidLines(bool fixInvalidLines);
-
-	/**
-	 * Adds a point to the current line.
-	 *
-	 * @param pt the Coordinate to add
-	 */
-	void add(const geom::Coordinate& pt);
-
-	/**
-	 * Adds a point to the current line.
-	 *
-	 * @param pt the Coordinate to add
-	 */
-	void add(const geom::Coordinate& pt, bool allowRepeatedPoints);
-
-	/// NOTE strk: why return by value ?
-	geom::Coordinate getLastCoordinate() const;
-
-	/// Terminate the current LineString.
-	void endLine();
-
-	geom::Geometry *getGeometry();
+    LinearGeometryBuilder(const geom::GeometryFactory* geomFact);
+
+    ~LinearGeometryBuilder();
+
+    /**
+     * Allows invalid lines to be ignored rather than causing Exceptions.
+     * An invalid line is one which has only one unique point.
+     *
+     * @param ignoreShortLines <code>true</code> if short lines are
+     *                         to be ignored
+     */
+    void setIgnoreInvalidLines(bool ignoreInvalidLines);
+
+    /**
+     * Allows invalid lines to be ignored rather than causing Exceptions.
+     * An invalid line is one which has only one unique point.
+     *
+     * @param ignoreShortLines <code>true</code> if short lines are
+     *                         to be ignored
+     */
+    void setFixInvalidLines(bool fixInvalidLines);
+
+    /**
+     * Adds a point to the current line.
+     *
+     * @param pt the Coordinate to add
+     */
+    void add(const geom::Coordinate& pt);
+
+    /**
+     * Adds a point to the current line.
+     *
+     * @param pt the Coordinate to add
+     */
+    void add(const geom::Coordinate& pt, bool allowRepeatedPoints);
+
+    /// NOTE strk: why return by value ?
+    geom::Coordinate getLastCoordinate() const;
+
+    /// Terminate the current LineString.
+    void endLine();
+
+    geom::Geometry* getGeometry();
 };
 
 } // namespace geos.linearref
diff --git a/include/geos/linearref/LinearIterator.h b/include/geos/linearref/LinearIterator.h
index 2aa1779..be4ffe9 100644
--- a/include/geos/linearref/LinearIterator.h
+++ b/include/geos/linearref/LinearIterator.h
@@ -27,8 +27,8 @@
 #include <geos/geom/LineSegment.h>
 #include <geos/linearref/LinearLocation.h>
 
-namespace geos { namespace linearref
-{
+namespace geos {
+namespace linearref {
 
 /** \brief
  * An iterator over the components and coordinates of a linear geometry
@@ -47,112 +47,112 @@ namespace geos { namespace linearref
  *
  * @version 1.7
  */
-class LinearIterator
-{
+class LinearIterator {
 public:
-	/**
-	 * Creates an iterator initialized to the start of a linear Geometry
-	 *
-	 * @param linear the linear geometry to iterate over
-	 */
-	LinearIterator(const geom::Geometry *linear);
-
-	/**
-	 * Creates an iterator starting at
-	 * a {@link LinearLocation} on a linear {@link Geometry}
-	 *
-	 * @param linear the linear geometry to iterate over
-	 * @param start the location to start at
-	 */
-	LinearIterator(const geom::Geometry *linear, const LinearLocation& start);
-
-	/**
-	 * Creates an iterator starting at
-	 * a component and vertex in a linear {@link Geometry}
-	 *
-	 * @param linear the linear geometry to iterate over
-	 * @param componentIndex the component to start at
-	 * @param vertexIndex the vertex to start at
-	 */
-	LinearIterator(const geom::Geometry *linear, size_t componentIndex, size_t vertexIndex);
-
-	/**
-	 * Tests whether there are any vertices left to iterator over.
-	 * @return <code>true</code> if there are more vertices to scan
-	 */
-	bool hasNext() const;
-
-
-	/**
-	 * Moves the iterator ahead to the next vertex and (possibly) linear component.
-	 */
-	void next();
-
-	/**
-	 * Checks whether the iterator cursor is pointing to the
-	 * endpoint of a component {@link LineString}.
-	 *
-	 * @return <code>true</true> if the iterator is at an endpoint
-	 */
-	bool isEndOfLine() const;
-
-	/**
-	 * The component index of the vertex the iterator is currently at.
-	 * @return the current component index
-	 */
-	size_t getComponentIndex() const;
-
-	/**
-	 * The vertex index of the vertex the iterator is currently at.
-	 * @return the current vertex index
-	 */
-	size_t getVertexIndex() const;
-
-	/**
-	 * Gets the {@link LineString} component the iterator is current at.
-	 * @return a linestring
-	 */
-	const geom::LineString* getLine() const;
-
-	/**
-	 * Gets the first {@link Coordinate} of the current segment.
-	 * (the coordinate of the current vertex).
-	 * @return a {@link Coordinate}
-	 */
-	geom::Coordinate getSegmentStart() const;
-
-	/**
-	 * Gets the second {@link Coordinate} of the current segment.
-	 * (the coordinate of the next vertex).
-	 * If the iterator is at the end of a line, <code>null</code> is returned.
-	 *
-	 * @return a {@link Coordinate} or <code>null</code>
-	 */
-	geom::Coordinate getSegmentEnd() const;
+    /**
+     * Creates an iterator initialized to the start of a linear Geometry
+     *
+     * @param linear the linear geometry to iterate over
+     */
+    LinearIterator(const geom::Geometry* linear);
+
+    /**
+     * Creates an iterator starting at
+     * a {@link LinearLocation} on a linear {@link Geometry}
+     *
+     * @param linear the linear geometry to iterate over
+     * @param start the location to start at
+     */
+    LinearIterator(const geom::Geometry* linear, const LinearLocation& start);
+
+    /**
+     * Creates an iterator starting at
+     * a component and vertex in a linear {@link Geometry}
+     *
+     * @param linear the linear geometry to iterate over
+     * @param componentIndex the component to start at
+     * @param vertexIndex the vertex to start at
+     */
+    LinearIterator(const geom::Geometry* linear, size_t componentIndex, size_t vertexIndex);
+
+    /**
+     * Tests whether there are any vertices left to iterator over.
+     * @return <code>true</code> if there are more vertices to scan
+     */
+    bool hasNext() const;
+
+
+    /**
+     * Moves the iterator ahead to the next vertex and (possibly) linear component.
+     */
+    void next();
+
+    /**
+     * Checks whether the iterator cursor is pointing to the
+     * endpoint of a component {@link LineString}.
+     *
+     * @return <code>true</true> if the iterator is at an endpoint
+     */
+    bool isEndOfLine() const;
+
+    /**
+     * The component index of the vertex the iterator is currently at.
+     * @return the current component index
+     */
+    size_t getComponentIndex() const;
+
+    /**
+     * The vertex index of the vertex the iterator is currently at.
+     * @return the current vertex index
+     */
+    size_t getVertexIndex() const;
+
+    /**
+     * Gets the {@link LineString} component the iterator is current at.
+     * @return a linestring
+     */
+    const geom::LineString* getLine() const;
+
+    /**
+     * Gets the first {@link Coordinate} of the current segment.
+     * (the coordinate of the current vertex).
+     * @return a {@link Coordinate}
+     */
+    geom::Coordinate getSegmentStart() const;
+
+    /**
+     * Gets the second {@link Coordinate} of the current segment.
+     * (the coordinate of the next vertex).
+     * If the iterator is at the end of a line, <code>null</code> is returned.
+     *
+     * @return a {@link Coordinate} or <code>null</code>
+     */
+    geom::Coordinate getSegmentEnd() const;
 
 private:
 
-	static size_t segmentEndVertexIndex(const LinearLocation& loc);
+    static size_t segmentEndVertexIndex(const LinearLocation& loc);
 
-	const geom::LineString *currentLine;
-	size_t vertexIndex;
-	size_t componentIndex;
-	const geom::Geometry *linear;
-	const size_t numLines;
+    const geom::LineString* currentLine;
+    size_t vertexIndex;
+    size_t componentIndex;
+    const geom::Geometry* linear;
+    const size_t numLines;
 
-	/**
-	 * Invariant: currentLine <> null if the iterator is pointing
-	 *            at a valid coordinate
-	 *
-	 * @throws IllegalArgumentException if linearGeom is not {@link Lineal}
-	 */
-	void loadCurrentLine();
+    /**
+     * Invariant: currentLine <> null if the iterator is pointing
+     *            at a valid coordinate
+     *
+     * @throws IllegalArgumentException if linearGeom is not {@link Lineal}
+     */
+    void loadCurrentLine();
 
     // Declare type as noncopyable
     LinearIterator(const LinearIterator& other) = delete;
     LinearIterator& operator=(const LinearIterator& rhs) = delete;
 };
 
-}} // namespace geos::linearref
+}
+} // namespace geos::linearref
 
 #endif // GEOS_LINEARREF_LINEARITERATOR_H
diff --git a/include/geos/linearref/LinearLocation.h b/include/geos/linearref/LinearLocation.h
index c129257..2b9da08 100644
--- a/include/geos/linearref/LinearLocation.h
+++ b/include/geos/linearref/LinearLocation.h
@@ -40,203 +40,203 @@ namespace linearref { // geos::linearref
  * Various methods are provided to manipulate the location value
  * and query the geometry it references.
  */
-class LinearLocation
-{
+class LinearLocation {
 private:
-	size_t componentIndex;
-	size_t segmentIndex;
-	double segmentFraction;
-
-	/**
-	 * Ensures the individual values are locally valid.
-	 * Does <b>not</b> ensure that the indexes are valid for
-	 * a particular linear geometry.
-	 *
-	 * @see clamp
-	 */
-	void normalize();
+    size_t componentIndex;
+    size_t segmentIndex;
+    double segmentFraction;
+
+    /**
+     * Ensures the individual values are locally valid.
+     * Does <b>not</b> ensure that the indexes are valid for
+     * a particular linear geometry.
+     *
+     * @see clamp
+     */
+    void normalize();
 
 public:
-	/**
-	 * Gets a location which refers to the end of a linear {@link Geometry}.
-	 * @param linear the linear geometry
-	 * @return a new <tt>LinearLocation</tt>
-	 */
-	static LinearLocation getEndLocation(const geom::Geometry* linear);
-
-	/**
-	 * Computes the {@link Coordinate} of a point a given fraction
-	 * along the line segment <tt>(p0, p1)</tt>.
-	 * If the fraction is greater than 1.0 the last
-	 * point of the segment is returned.
-	 * If the fraction is less than or equal to 0.0 the first point
-	 * of the segment is returned.
-	 * The Z ordinate is interpolated from the Z-ordinates of
-	 * the given points, if they are specified.
-	 *
-	 * @param p0 the first point of the line segment
-	 * @param p1 the last point of the line segment
-	 * @param frac the length to the desired point
-	 * @return the <tt>Coordinate</tt> of the desired point
-	 */
-	static geom::Coordinate pointAlongSegmentByFraction(const geom::Coordinate& p0, const geom::Coordinate& p1, double frac);
-
-
-	/**
-	 * Creates a location referring to the start of a linear geometry
-	 */
-	LinearLocation(size_t segmentIndex = 0, double segmentFraction = 0.0);
-
-	LinearLocation(size_t componentIndex, size_t segmentIndex, double segmentFraction);
-
-	/**
-	 * Ensures the indexes are valid for a given linear {@link Geometry}.
-	 *
-	 * @param linear a linear geometry
-	 */
-	void clamp(const geom::Geometry* linear);
-
-	/**
-	 * Snaps the value of this location to
-	 * the nearest vertex on the given linear {@link Geometry},
-	 * if the vertex is closer than <tt>minDistance</tt>.
-	 *
-	 * @param linearGeom a linear geometry
-	 * @param minDistance the minimum allowable distance to a vertex
-	 */
-	void snapToVertex(const geom::Geometry* linearGeom, double minDistance);
-
-	/**
-	 * Gets the length of the segment in the given
-	 * Geometry containing this location.
-	 *
-	 * @param linearGeom a linear geometry
-	 * @return the length of the segment
-	 */
-	double getSegmentLength(const geom::Geometry* linearGeom) const;
-
-	/**
-	 * Sets the value of this location to
-	 * refer the end of a linear geometry
-	 *
-	 * @param linear the linear geometry to set
-	 */
-	void setToEnd(const geom::Geometry* linear);
-
-	/**
-	 * Gets the component index for this location.
-	 *
-	 * @return the component index
-	 */
-	size_t getComponentIndex() const;
-
-	/**
-	 * Gets the segment index for this location
-	 *
-	 * @return the segment index
-	 */
-	size_t getSegmentIndex() const;
-
-	/**
-	 * Gets the segment fraction for this location
-	 *
-	 * @return the segment fraction
-	 */
-	double getSegmentFraction() const;
-
-	/**
-	 * Tests whether this location refers to a vertex
-	 *
-	 * @return true if the location is a vertex
-	 */
-	bool isVertex() const;
-
-	/**
-	 * Gets the {@link Coordinate} along the
-	 * given linear {@link Geometry} which is
-	 * referenced by this location.
-	 *
-	 * @param linearGeom the linear geometry referenced by this location
-	 * @return the <tt>Coordinate</tt> at the location
-	 */
-	geom::Coordinate getCoordinate(const geom::Geometry* linearGeom) const;
-
-	/**
-	 * Gets a {@link LineSegment} representing the segment of the
-	 * given linear {@link Geometry} which contains this location.
-	 *
-	 * @param linearGeom a linear geometry
-	 * @return the <tt>LineSegment</tt> containing the location
-	 */
-	std::unique_ptr<geom::LineSegment> getSegment(const geom::Geometry* linearGeom) const;
-
-	/**
-	 * Tests whether this location refers to a valid
-	 * location on the given linear {@link Geometry}.
-	 *
-	 * @param linearGeom a linear geometry
-	 * @return true if this location is valid
-	 */
-	bool isValid(const geom::Geometry* linearGeom) const;
-
-	/**
-	 *  Compares this object with the specified object for order.
-	 *
-	 *@param  o  the <code>LineStringLocation</code> with which this <code>Coordinate</code>
-	 *      is being compared
-	 *@return    a negative integer, zero, or a positive integer as this <code>LineStringLocation</code>
-	 *      is less than, equal to, or greater than the specified <code>LineStringLocation</code>
-	 */
-	int compareTo(const LinearLocation& other) const;
-
-	/**
-	 *  Compares this object with the specified index values for order.
-	 *
-	 * @param componentIndex1 a component index
-	 * @param segmentIndex1 a segment index
-	 * @param segmentFraction1 a segment fraction
-	 * @return    a negative integer, zero, or a positive integer as this <code>LineStringLocation</code>
-	 *      is less than, equal to, or greater than the specified locationValues
-	 */
-	int compareLocationValues(size_t componentIndex1, size_t segmentIndex1, double segmentFraction1) const;
-
-	/**
-	 *  Compares two sets of location values for order.
-	 *
-	 * @param componentIndex0 a component index
-	 * @param segmentIndex0 a segment index
-	 * @param segmentFraction0 a segment fraction
-	 * @param componentIndex1 another component index
-	 * @param segmentIndex1 another segment index
-	 * @param segmentFraction1 another segment fraction
-	 *@return    a negative integer, zero, or a positive integer
-	 *      as the first set of location values
-	 *      is less than, equal to, or greater than the second set of locationValues
-	 */
-	static int compareLocationValues(
-		size_t componentIndex0, size_t segmentIndex0, double segmentFraction0,
-		size_t componentIndex1, size_t segmentIndex1, double segmentFraction1);
-
-	/**
-	 * Tests whether two locations
-	 * are on the same segment in the parent {@link Geometry}.
-	 *
-	 * @param loc a location on the same geometry
-	 * @return true if the locations are on the same segment of the parent geometry
-	 */
-	bool isOnSameSegment(const LinearLocation& loc) const;
-
-	/**
-	 * \brief
-	 * Tests whether this location is an endpoint of
-	 * the linear component it refers to.
-	 *
-	 * @param linearGeom the linear geometry referenced by this location
-	 * @return true if the location is a component endpoint
-	 */
-	bool isEndpoint(const geom::Geometry& linearGeom) const;
-
-	friend std::ostream& operator<< (std::ostream& out, const LinearLocation& obj );
+    /**
+     * Gets a location which refers to the end of a linear {@link Geometry}.
+     * @param linear the linear geometry
+     * @return a new <tt>LinearLocation</tt>
+     */
+    static LinearLocation getEndLocation(const geom::Geometry* linear);
+
+    /**
+     * Computes the {@link Coordinate} of a point a given fraction
+     * along the line segment <tt>(p0, p1)</tt>.
+     * If the fraction is greater than 1.0 the last
+     * point of the segment is returned.
+     * If the fraction is less than or equal to 0.0 the first point
+     * of the segment is returned.
+     * The Z ordinate is interpolated from the Z-ordinates of
+     * the given points, if they are specified.
+     *
+     * @param p0 the first point of the line segment
+     * @param p1 the last point of the line segment
+     * @param frac the length to the desired point
+     * @return the <tt>Coordinate</tt> of the desired point
+     */
+    static geom::Coordinate pointAlongSegmentByFraction(const geom::Coordinate& p0, const geom::Coordinate& p1,
+            double frac);
+
+
+    /**
+     * Creates a location referring to the start of a linear geometry
+     */
+    LinearLocation(size_t segmentIndex = 0, double segmentFraction = 0.0);
+
+    LinearLocation(size_t componentIndex, size_t segmentIndex, double segmentFraction);
+
+    /**
+     * Ensures the indexes are valid for a given linear {@link Geometry}.
+     *
+     * @param linear a linear geometry
+     */
+    void clamp(const geom::Geometry* linear);
+
+    /**
+     * Snaps the value of this location to
+     * the nearest vertex on the given linear {@link Geometry},
+     * if the vertex is closer than <tt>minDistance</tt>.
+     *
+     * @param linearGeom a linear geometry
+     * @param minDistance the minimum allowable distance to a vertex
+     */
+    void snapToVertex(const geom::Geometry* linearGeom, double minDistance);
+
+    /**
+     * Gets the length of the segment in the given
+     * Geometry containing this location.
+     *
+     * @param linearGeom a linear geometry
+     * @return the length of the segment
+     */
+    double getSegmentLength(const geom::Geometry* linearGeom) const;
+
+    /**
+     * Sets the value of this location to
+     * refer the end of a linear geometry
+     *
+     * @param linear the linear geometry to set
+     */
+    void setToEnd(const geom::Geometry* linear);
+
+    /**
+     * Gets the component index for this location.
+     *
+     * @return the component index
+     */
+    size_t getComponentIndex() const;
+
+    /**
+     * Gets the segment index for this location
+     *
+     * @return the segment index
+     */
+    size_t getSegmentIndex() const;
+
+    /**
+     * Gets the segment fraction for this location
+     *
+     * @return the segment fraction
+     */
+    double getSegmentFraction() const;
+
+    /**
+     * Tests whether this location refers to a vertex
+     *
+     * @return true if the location is a vertex
+     */
+    bool isVertex() const;
+
+    /**
+     * Gets the {@link Coordinate} along the
+     * given linear {@link Geometry} which is
+     * referenced by this location.
+     *
+     * @param linearGeom the linear geometry referenced by this location
+     * @return the <tt>Coordinate</tt> at the location
+     */
+    geom::Coordinate getCoordinate(const geom::Geometry* linearGeom) const;
+
+    /**
+     * Gets a {@link LineSegment} representing the segment of the
+     * given linear {@link Geometry} which contains this location.
+     *
+     * @param linearGeom a linear geometry
+     * @return the <tt>LineSegment</tt> containing the location
+     */
+    std::unique_ptr<geom::LineSegment> getSegment(const geom::Geometry* linearGeom) const;
+
+    /**
+     * Tests whether this location refers to a valid
+     * location on the given linear {@link Geometry}.
+     *
+     * @param linearGeom a linear geometry
+     * @return true if this location is valid
+     */
+    bool isValid(const geom::Geometry* linearGeom) const;
+
+    /**
+     *  Compares this object with the specified object for order.
+     *
+     *@param  o  the <code>LineStringLocation</code> with which this <code>Coordinate</code>
+     *      is being compared
+     *@return    a negative integer, zero, or a positive integer as this <code>LineStringLocation</code>
+     *      is less than, equal to, or greater than the specified <code>LineStringLocation</code>
+     */
+    int compareTo(const LinearLocation& other) const;
+
+    /**
+     *  Compares this object with the specified index values for order.
+     *
+     * @param componentIndex1 a component index
+     * @param segmentIndex1 a segment index
+     * @param segmentFraction1 a segment fraction
+     * @return    a negative integer, zero, or a positive integer as this <code>LineStringLocation</code>
+     *      is less than, equal to, or greater than the specified locationValues
+     */
+    int compareLocationValues(size_t componentIndex1, size_t segmentIndex1, double segmentFraction1) const;
+
+    /**
+     *  Compares two sets of location values for order.
+     *
+     * @param componentIndex0 a component index
+     * @param segmentIndex0 a segment index
+     * @param segmentFraction0 a segment fraction
+     * @param componentIndex1 another component index
+     * @param segmentIndex1 another segment index
+     * @param segmentFraction1 another segment fraction
+     *@return    a negative integer, zero, or a positive integer
+     *      as the first set of location values
+     *      is less than, equal to, or greater than the second set of locationValues
+     */
+    static int compareLocationValues(
+        size_t componentIndex0, size_t segmentIndex0, double segmentFraction0,
+        size_t componentIndex1, size_t segmentIndex1, double segmentFraction1);
+
+    /**
+     * Tests whether two locations
+     * are on the same segment in the parent {@link Geometry}.
+     *
+     * @param loc a location on the same geometry
+     * @return true if the locations are on the same segment of the parent geometry
+     */
+    bool isOnSameSegment(const LinearLocation& loc) const;
+
+    /**
+     * \brief
+     * Tests whether this location is an endpoint of
+     * the linear component it refers to.
+     *
+     * @param linearGeom the linear geometry referenced by this location
+     * @return true if the location is a component endpoint
+     */
+    bool isEndpoint(const geom::Geometry& linearGeom) const;
+
+    friend std::ostream& operator<< (std::ostream& out, const LinearLocation& obj);
 
 };
 
diff --git a/include/geos/linearref/LocationIndexOfLine.h b/include/geos/linearref/LocationIndexOfLine.h
index e7eef5e..ea179d2 100644
--- a/include/geos/linearref/LocationIndexOfLine.h
+++ b/include/geos/linearref/LocationIndexOfLine.h
@@ -24,10 +24,8 @@
 #include <geos/geom/Geometry.h>
 #include <geos/linearref/LinearLocation.h>
 
-namespace geos
-{
-namespace linearref   // geos::linearref
-{
+namespace geos {
+namespace linearref { // geos::linearref
 
 /**
  * Determines the location of a subline along a linear {@link Geometry}.
@@ -38,37 +36,36 @@ namespace linearref   // geos::linearref
  * an endpoint of the test line occurs more than once in the input line.
  * (However, the common case of a ring is always handled correctly).
  */
-class LocationIndexOfLine
-{
-	/**
-	* MD - this algorithm has been extracted into a class
-	* because it is intended to validate that the subline truly is a subline,
-	* and also to use the internal vertex information to unambiguously locate the subline.
-	*/
+class LocationIndexOfLine {
+    /**
+    * MD - this algorithm has been extracted into a class
+    * because it is intended to validate that the subline truly is a subline,
+    * and also to use the internal vertex information to unambiguously locate the subline.
+    */
 private:
-	const geom::Geometry* linearGeom;
+    const geom::Geometry* linearGeom;
 
 public:
 
-	/** \brief
-	 * Determines the location of a subline along a linear {@link Geometry}.
-	 *
-	 * The location is reported as a pair of {@link LinearLocation}s.
-	 *
-	 * <b>Note:</b> Currently this algorithm is not guaranteed to
-	 * return the correct substring in some situations where
-	 * an endpoint of the test line occurs more than once in the input line.
-	 * (However, the common case of a ring is always handled correctly).
-	 *
-	 * Caller must take of releasing with delete[]
-	 *
-	 */
-	static LinearLocation* indicesOf(const geom::Geometry* linearGeom, const geom::Geometry* subLine);
+    /** \brief
+     * Determines the location of a subline along a linear {@link Geometry}.
+     *
+     * The location is reported as a pair of {@link LinearLocation}s.
+     *
+     * <b>Note:</b> Currently this algorithm is not guaranteed to
+     * return the correct substring in some situations where
+     * an endpoint of the test line occurs more than once in the input line.
+     * (However, the common case of a ring is always handled correctly).
+     *
+     * Caller must take of releasing with delete[]
+     *
+     */
+    static LinearLocation* indicesOf(const geom::Geometry* linearGeom, const geom::Geometry* subLine);
 
-	LocationIndexOfLine(const geom::Geometry* linearGeom);
+    LocationIndexOfLine(const geom::Geometry* linearGeom);
 
-	/// Caller must take of releasing with delete[]
-	LinearLocation* indicesOf(const geom::Geometry* subLine) const;
+    /// Caller must take of releasing with delete[]
+    LinearLocation* indicesOf(const geom::Geometry* subLine) const;
 };
 }
 }
diff --git a/include/geos/linearref/LocationIndexOfPoint.h b/include/geos/linearref/LocationIndexOfPoint.h
index 95a8607..330ac85 100644
--- a/include/geos/linearref/LocationIndexOfPoint.h
+++ b/include/geos/linearref/LocationIndexOfPoint.h
@@ -25,10 +25,8 @@
 #include <geos/geom/Geometry.h>
 #include <geos/linearref/LinearLocation.h>
 
-namespace geos
-{
-namespace linearref   // geos::linearref
-{
+namespace geos {
+namespace linearref { // geos::linearref
 
 /**
  * Computes the {@link LinearLocation} of the point
@@ -37,44 +35,44 @@ namespace linearref   // geos::linearref
  * always computes the nearest point closest to
  * the start of the geometry.
  */
-class LocationIndexOfPoint
-{
+class LocationIndexOfPoint {
 
 private:
-	const geom::Geometry *linearGeom;
+    const geom::Geometry* linearGeom;
 
-	LinearLocation indexOfFromStart(const geom::Coordinate& inputPt, const LinearLocation* minIndex) const;
+    LinearLocation indexOfFromStart(const geom::Coordinate& inputPt, const LinearLocation* minIndex) const;
 
 public:
-	static LinearLocation indexOf(const geom::Geometry *linearGeom, const geom::Coordinate& inputPt);
+    static LinearLocation indexOf(const geom::Geometry* linearGeom, const geom::Coordinate& inputPt);
 
-	static LinearLocation indexOfAfter(const geom::Geometry *linearGeom, const geom::Coordinate& inputPt, const LinearLocation* minIndex);
+    static LinearLocation indexOfAfter(const geom::Geometry* linearGeom, const geom::Coordinate& inputPt,
+                                       const LinearLocation* minIndex);
 
-	LocationIndexOfPoint(const geom::Geometry *linearGeom);
+    LocationIndexOfPoint(const geom::Geometry* linearGeom);
 
-	/**
-	 * Find the nearest location along a linear {@link Geometry} to a given point.
-	 *
-	 * @param inputPt the coordinate to locate
-	 * @return the location of the nearest point
-	 */
-	LinearLocation indexOf(const geom::Coordinate& inputPt) const;
-	/**
-	 * Find the nearest {@link LinearLocation} along the linear {@link Geometry}
-	 * to a given {@link Coordinate}
-	 * after the specified minimum {@link LinearLocation}.
-	 * If possible the location returned will be strictly greater than the
-	 * <code>minLocation</code>.
-	 * If this is not possible, the
-	 * value returned will equal <code>minLocation</code>.
-	 * (An example where this is not possible is when
-	 * minLocation = [end of line] ).
-	 *
-	 * @param inputPt the coordinate to locate
-	 * @param minLocation the minimum location for the point location
-	 * @return the location of the nearest point
-	 */
-	LinearLocation indexOfAfter(const geom::Coordinate& inputPt, const LinearLocation* minIndex) const;
+    /**
+     * Find the nearest location along a linear {@link Geometry} to a given point.
+     *
+     * @param inputPt the coordinate to locate
+     * @return the location of the nearest point
+     */
+    LinearLocation indexOf(const geom::Coordinate& inputPt) const;
+    /**
+     * Find the nearest {@link LinearLocation} along the linear {@link Geometry}
+     * to a given {@link Coordinate}
+     * after the specified minimum {@link LinearLocation}.
+     * If possible the location returned will be strictly greater than the
+     * <code>minLocation</code>.
+     * If this is not possible, the
+     * value returned will equal <code>minLocation</code>.
+     * (An example where this is not possible is when
+     * minLocation = [end of line] ).
+     *
+     * @param inputPt the coordinate to locate
+     * @param minLocation the minimum location for the point location
+     * @return the location of the nearest point
+     */
+    LinearLocation indexOfAfter(const geom::Coordinate& inputPt, const LinearLocation* minIndex) const;
 };
 }
 }
diff --git a/include/geos/linearref/LocationIndexedLine.h b/include/geos/linearref/LocationIndexedLine.h
index 95ed1dd..3ea639c 100644
--- a/include/geos/linearref/LocationIndexedLine.h
+++ b/include/geos/linearref/LocationIndexedLine.h
@@ -37,229 +37,241 @@ namespace linearref { // geos::linearref
  * along a linear {@link Geometry}
  * using {@link LinearLocation}s as the index.
  */
-class GEOS_DLL LocationIndexedLine
-{
+class GEOS_DLL LocationIndexedLine {
 private:
-  const geom::Geometry *linearGeom;
+    const geom::Geometry* linearGeom;
 
-  void checkGeometryType()
-  {
-    if ( ! dynamic_cast<const geom::Lineal*>(linearGeom) )
-      throw util::IllegalArgumentException("Input geometry must be linear");
-  }
+    void
+    checkGeometryType()
+    {
+        if(! dynamic_cast<const geom::Lineal*>(linearGeom)) {
+            throw util::IllegalArgumentException("Input geometry must be linear");
+        }
+    }
 
 public:
 
-  /**
-   * \brief
-   * Constructs an object which allows linear referencing along
-   * a given linear {@link Geometry}.
-   *
-   * @param linearGeom the linear geometry to reference along
-   */
-  LocationIndexedLine(const geom::Geometry *p_linearGeom)
-    : linearGeom(p_linearGeom)
-  {
-    checkGeometryType();
-  }
+    /**
+     * \brief
+     * Constructs an object which allows linear referencing along
+     * a given linear {@link Geometry}.
+     *
+     * @param linearGeom the linear geometry to reference along
+     */
+    LocationIndexedLine(const geom::Geometry* p_linearGeom)
+        : linearGeom(p_linearGeom)
+    {
+        checkGeometryType();
+    }
 
-  /**
-   * \brief
-   * Computes the {@link Coordinate} for the point
-   * on the line at the given index.
-   *
-   * If the index is out of range the first or last point on the
-   * line will be returned.
-   * The Z-ordinate of the computed point will be interpolated from
-   * the Z-ordinates of the line segment containing it, if they exist.
-   *
-   * @param index the index of the desired point
-   * @return the Coordinate at the given index
-   */
-  geom::Coordinate extractPoint(const LinearLocation& index) const
-  {
-    return index.getCoordinate(linearGeom);
-  }
+    /**
+     * \brief
+     * Computes the {@link Coordinate} for the point
+     * on the line at the given index.
+     *
+     * If the index is out of range the first or last point on the
+     * line will be returned.
+     * The Z-ordinate of the computed point will be interpolated from
+     * the Z-ordinates of the line segment containing it, if they exist.
+     *
+     * @param index the index of the desired point
+     * @return the Coordinate at the given index
+     */
+    geom::Coordinate
+    extractPoint(const LinearLocation& index) const
+    {
+        return index.getCoordinate(linearGeom);
+    }
 
 
-  /**
-   * \brief
-   * Computes the {@link Coordinate} for the point
-   * on the line at the given index, offset by the given distance.
-   *
-   * If the index is out of range the first or last point on the
-   * line will be returned.
-   * The computed point is offset to the left of the line if the offset
-   * distance is positive, to the right if negative.
-   *
-   * The Z-ordinate of the computed point will be interpolated from
-   * the Z-ordinates of the line segment containing it, if they exist.
-   *
-   * @param index the index of the desired point
-   * @param offsetDistance the distance the point is offset from the segment
-   *    (positive is to the left, negative is to the right)
-   * @return the Coordinate at the given index
-   */
-  geom::Coordinate extractPoint(const LinearLocation& index,
-                                               double offsetDistance) const
-  {
-    geom::Coordinate ret;
-    index.getSegment(linearGeom)->pointAlongOffset(
-                index.getSegmentFraction(), offsetDistance, ret
-           );
-    return ret;
-  }
+    /**
+     * \brief
+     * Computes the {@link Coordinate} for the point
+     * on the line at the given index, offset by the given distance.
+     *
+     * If the index is out of range the first or last point on the
+     * line will be returned.
+     * The computed point is offset to the left of the line if the offset
+     * distance is positive, to the right if negative.
+     *
+     * The Z-ordinate of the computed point will be interpolated from
+     * the Z-ordinates of the line segment containing it, if they exist.
+     *
+     * @param index the index of the desired point
+     * @param offsetDistance the distance the point is offset from the segment
+     *    (positive is to the left, negative is to the right)
+     * @return the Coordinate at the given index
+     */
+    geom::Coordinate
+    extractPoint(const LinearLocation& index,
+                 double offsetDistance) const
+    {
+        geom::Coordinate ret;
+        index.getSegment(linearGeom)->pointAlongOffset(
+            index.getSegmentFraction(), offsetDistance, ret
+        );
+        return ret;
+    }
 
-  /**
-   * \brief
-   * Computes the {@link LineString} for the interval
-   * on the line between the given indices.
-   *
-   * If the endIndex lies before the startIndex,
-   * the computed geometry is reversed.
-   *
-   * @param startIndex the index of the start of the interval
-   * @param endIndex the index of the end of the interval
-   * @return the linear interval between the indices
-   */
-  geom::Geometry *extractLine(const LinearLocation& startIndex,
-                              const LinearLocation& endIndex) const
-  {
-    return ExtractLineByLocation::extract(linearGeom, startIndex, endIndex);
-  }
+    /**
+     * \brief
+     * Computes the {@link LineString} for the interval
+     * on the line between the given indices.
+     *
+     * If the endIndex lies before the startIndex,
+     * the computed geometry is reversed.
+     *
+     * @param startIndex the index of the start of the interval
+     * @param endIndex the index of the end of the interval
+     * @return the linear interval between the indices
+     */
+    geom::Geometry*
+    extractLine(const LinearLocation& startIndex,
+                const LinearLocation& endIndex) const
+    {
+        return ExtractLineByLocation::extract(linearGeom, startIndex, endIndex);
+    }
 
 
-  /**
-   * \brief
-   * Computes the index for a given point on the line.
-   *
-   * The supplied point does not <i>necessarily</i> have to lie precisely
-   * on the line, but if it is far from the line the accuracy and
-   * performance of this function is not guaranteed.
-   * Use {@link #project} to compute a guaranteed result for points
-   * which may be far from the line.
-   *
-   * @param pt a point on the line
-   * @return the index of the point
-   *
-   * @see project
-   */
-  LinearLocation indexOf(const geom::Coordinate& pt) const
-  {
-    return LocationIndexOfPoint::indexOf(linearGeom, pt);
-  }
+    /**
+     * \brief
+     * Computes the index for a given point on the line.
+     *
+     * The supplied point does not <i>necessarily</i> have to lie precisely
+     * on the line, but if it is far from the line the accuracy and
+     * performance of this function is not guaranteed.
+     * Use {@link #project} to compute a guaranteed result for points
+     * which may be far from the line.
+     *
+     * @param pt a point on the line
+     * @return the index of the point
+     *
+     * @see project
+     */
+    LinearLocation
+    indexOf(const geom::Coordinate& pt) const
+    {
+        return LocationIndexOfPoint::indexOf(linearGeom, pt);
+    }
 
-  /**
-   * \brief
-   * Finds the index for a point on the line
-   * which is greater than the given index.
-   *
-   * If no such index exists, returns <tt>minIndex</tt>.
-   * This method can be used to determine all indexes for
-   * a point which occurs more than once on a non-simple line.
-   * It can also be used to disambiguate cases where the given point lies
-   * slightly off the line and is equidistant from two different
-   * points on the line.
-   *
-   * The supplied point does not <i>necessarily</i> have to lie precisely
-   * on the line, but if it is far from the line the accuracy and
-   * performance of this function is not guaranteed.
-   * Use {@link #project} to compute a guaranteed result for points
-   * which may be far from the line.
-   *
-   * @param pt a point on the line
-   * @param minIndex the value the returned index must be greater than
-   * @return the index of the point greater than the given minimum index
-   *
-   * @see project
-   */
-  LinearLocation indexOfAfter(const geom::Coordinate& pt,
-                                const LinearLocation& minIndex) const
-  {
-    return LocationIndexOfPoint::indexOfAfter(linearGeom, pt, &minIndex);
-  }
+    /**
+     * \brief
+     * Finds the index for a point on the line
+     * which is greater than the given index.
+     *
+     * If no such index exists, returns <tt>minIndex</tt>.
+     * This method can be used to determine all indexes for
+     * a point which occurs more than once on a non-simple line.
+     * It can also be used to disambiguate cases where the given point lies
+     * slightly off the line and is equidistant from two different
+     * points on the line.
+     *
+     * The supplied point does not <i>necessarily</i> have to lie precisely
+     * on the line, but if it is far from the line the accuracy and
+     * performance of this function is not guaranteed.
+     * Use {@link #project} to compute a guaranteed result for points
+     * which may be far from the line.
+     *
+     * @param pt a point on the line
+     * @param minIndex the value the returned index must be greater than
+     * @return the index of the point greater than the given minimum index
+     *
+     * @see project
+     */
+    LinearLocation
+    indexOfAfter(const geom::Coordinate& pt,
+                 const LinearLocation& minIndex) const
+    {
+        return LocationIndexOfPoint::indexOfAfter(linearGeom, pt, &minIndex);
+    }
 
-  /**
-   * \brief
-   * Computes the indices for a subline of the line.
-   *
-   * (The subline must <b>conform</b> to the line; that is,
-   * all vertices in the subline (except possibly the first and last)
-   * must be vertices of the line and occur in the same order).
-   *
-   * @param subLine a subLine of the line
-   * @return a pair of indices for the start and end of the subline.
-   */
-  LinearLocation* indicesOf(const geom::Geometry *subLine) const
-  {
-    return LocationIndexOfLine::indicesOf(linearGeom, subLine);
-  }
+    /**
+     * \brief
+     * Computes the indices for a subline of the line.
+     *
+     * (The subline must <b>conform</b> to the line; that is,
+     * all vertices in the subline (except possibly the first and last)
+     * must be vertices of the line and occur in the same order).
+     *
+     * @param subLine a subLine of the line
+     * @return a pair of indices for the start and end of the subline.
+     */
+    LinearLocation*
+    indicesOf(const geom::Geometry* subLine) const
+    {
+        return LocationIndexOfLine::indicesOf(linearGeom, subLine);
+    }
 
 
-  /**
-   * \brief
-   * Computes the index for the closest point on the line to the given point.
-   *
-   * If more than one point has the closest distance the first one along
-   * the line is returned.
-   * (The point does not necessarily have to lie precisely on the line.)
-   *
-   * @param pt a point on the line
-   * @return the index of the point
-   */
-  LinearLocation project(const geom::Coordinate& pt) const
-  {
-    return LocationIndexOfPoint::indexOf(linearGeom, pt);
-  }
+    /**
+     * \brief
+     * Computes the index for the closest point on the line to the given point.
+     *
+     * If more than one point has the closest distance the first one along
+     * the line is returned.
+     * (The point does not necessarily have to lie precisely on the line.)
+     *
+     * @param pt a point on the line
+     * @return the index of the point
+     */
+    LinearLocation
+    project(const geom::Coordinate& pt) const
+    {
+        return LocationIndexOfPoint::indexOf(linearGeom, pt);
+    }
 
-  /**
-   * \brief
-   * Returns the index of the start of the line
-   *
-   * @return the start index
-   */
-  LinearLocation getStartIndex() const
-  {
-    return LinearLocation();
-  }
+    /**
+     * \brief
+     * Returns the index of the start of the line
+     *
+     * @return the start index
+     */
+    LinearLocation
+    getStartIndex() const
+    {
+        return LinearLocation();
+    }
 
-  /**
-   * \brief
-   * Returns the index of the end of the line
-   *
-   * @return the end index
-   */
-  LinearLocation getEndIndex() const
-  {
-    return LinearLocation::getEndLocation(linearGeom);
-  }
+    /**
+     * \brief
+     * Returns the index of the end of the line
+     *
+     * @return the end index
+     */
+    LinearLocation
+    getEndIndex() const
+    {
+        return LinearLocation::getEndLocation(linearGeom);
+    }
 
-  /**
-   * \brief
-   * Tests whether an index is in the valid index range for the line.
-   *
-   * @param length the index to test
-   * @return <code>true</code> if the index is in the valid range
-   */
-  bool isValidIndex(const LinearLocation& index) const
-  {
-    return index.isValid(linearGeom);
-  }
+    /**
+     * \brief
+     * Tests whether an index is in the valid index range for the line.
+     *
+     * @param length the index to test
+     * @return <code>true</code> if the index is in the valid range
+     */
+    bool
+    isValidIndex(const LinearLocation& index) const
+    {
+        return index.isValid(linearGeom);
+    }
 
 
-  /**
-   * \brief
-   * Computes a valid index for this line
-   * by clamping the given index to the valid range of index values
-   *
-   * @return a valid index value
-   */
-  LinearLocation clampIndex(const LinearLocation& index) const
-  {
-    LinearLocation loc = index;
-    loc.clamp(linearGeom);
-    return loc;
-  }
+    /**
+     * \brief
+     * Computes a valid index for this line
+     * by clamping the given index to the valid range of index values
+     *
+     * @return a valid index value
+     */
+    LinearLocation
+    clampIndex(const LinearLocation& index) const
+    {
+        LinearLocation loc = index;
+        loc.clamp(linearGeom);
+        return loc;
+    }
 };
 
 } // geos::linearref
diff --git a/include/geos/noding/BasicSegmentString.h b/include/geos/noding/BasicSegmentString.h
index d009744..aad4bc0 100644
--- a/include/geos/noding/BasicSegmentString.h
+++ b/include/geos/noding/BasicSegmentString.h
@@ -29,9 +29,9 @@
 
 // Forward declarations
 namespace geos {
-	namespace algorithm {
-		//class LineIntersector;
-	}
+namespace algorithm {
+//class LineIntersector;
+}
 }
 
 namespace geos {
@@ -51,52 +51,53 @@ class GEOS_DLL BasicSegmentString : public SegmentString {
 
 public:
 
-	/// Construct a BasicSegmentString.
-	//
-	/// @param newPts CoordinateSequence representing the string,
-	///                externally owned
-	/// @param newContext the context associated to this SegmentString
-	///
-	BasicSegmentString(geom::CoordinateSequence *newPts,
-			const void* newContext)
-		:
-		SegmentString(newContext),
-		pts(newPts)
-	{}
-
-	~BasicSegmentString() override
-	{}
-
-	/// see dox in SegmentString.h
-	size_t size() const override
-	{
-		return pts->size();
-	}
-
-	/// see dox in SegmentString.h
-	const geom::Coordinate& getCoordinate(size_t i) const override;
-
-	/// see dox in SegmentString.h
-	geom::CoordinateSequence* getCoordinates() const override;
-
-	/// see dox in SegmentString.h
-	bool isClosed() const override;
-
-	/// see dox in SegmentString.h
-	std::ostream& print(std::ostream& os) const override;
-
-	/** \brief
-	 * Gets the octant of the segment starting at vertex index.
-	 *
-	 * @param index the index of the vertex starting the segment.
-	 *        Must not be the last index in the vertex list
-	 * @return the octant of the segment at the vertex
-	 */
-	int getSegmentOctant(size_t index) const;
+    /// Construct a BasicSegmentString.
+    //
+    /// @param newPts CoordinateSequence representing the string,
+    ///                externally owned
+    /// @param newContext the context associated to this SegmentString
+    ///
+    BasicSegmentString(geom::CoordinateSequence* newPts,
+                       const void* newContext)
+        :
+        SegmentString(newContext),
+        pts(newPts)
+    {}
+
+    ~BasicSegmentString() override
+    {}
+
+    /// see dox in SegmentString.h
+    size_t
+    size() const override
+    {
+        return pts->size();
+    }
+
+    /// see dox in SegmentString.h
+    const geom::Coordinate& getCoordinate(size_t i) const override;
+
+    /// see dox in SegmentString.h
+    geom::CoordinateSequence* getCoordinates() const override;
+
+    /// see dox in SegmentString.h
+    bool isClosed() const override;
+
+    /// see dox in SegmentString.h
+    std::ostream& print(std::ostream& os) const override;
+
+    /** \brief
+     * Gets the octant of the segment starting at vertex index.
+     *
+     * @param index the index of the vertex starting the segment.
+     *        Must not be the last index in the vertex list
+     * @return the octant of the segment at the vertex
+     */
+    int getSegmentOctant(size_t index) const;
 
 private:
 
-	geom::CoordinateSequence *pts;
+    geom::CoordinateSequence* pts;
 
 };
 
diff --git a/include/geos/noding/FastNodingValidator.h b/include/geos/noding/FastNodingValidator.h
index c9b6622..9347007 100644
--- a/include/geos/noding/FastNodingValidator.h
+++ b/include/geos/noding/FastNodingValidator.h
@@ -28,9 +28,9 @@
 
 // Forward declarations
 namespace geos {
-	namespace noding {
-		class SegmentString;
-	}
+namespace noding {
+class SegmentString;
+}
 }
 
 namespace geos {
@@ -57,65 +57,68 @@ namespace noding { // geos.noding
  * or request that a suitable {@link TopologyException} be thrown.
  *
  */
-class FastNodingValidator
-{
+class FastNodingValidator {
 
 public:
 
-	FastNodingValidator(std::vector<noding::SegmentString*>& newSegStrings)
-		:
-		li(), // robust...
-		segStrings(newSegStrings),
-		segInt(),
-		isValidVar(true)
-	{
-	}
-
-	/**
-	 * Checks for an intersection and
-	 * reports if one is found.
-	 *
-	 * @return true if the arrangement contains an interior intersection
-	 */
-	bool isValid()
-	{
-		execute();
-		return isValidVar;
-	}
-
-	/**
-	 * Returns an error message indicating the segments containing
-	 * the intersection.
-	 *
-	 * @return an error message documenting the intersection location
-	 */
-	std::string getErrorMessage() const;
-
-	/**
-	 * Checks for an intersection and throws
-	 * a TopologyException if one is found.
-	 *
-	 * @throws TopologyException if an intersection is found
-	 */
-	void checkValid();
+    FastNodingValidator(std::vector<noding::SegmentString*>& newSegStrings)
+        :
+        li(), // robust...
+        segStrings(newSegStrings),
+        segInt(),
+        isValidVar(true)
+    {
+    }
+
+    /**
+     * Checks for an intersection and
+     * reports if one is found.
+     *
+     * @return true if the arrangement contains an interior intersection
+     */
+    bool
+    isValid()
+    {
+        execute();
+        return isValidVar;
+    }
+
+    /**
+     * Returns an error message indicating the segments containing
+     * the intersection.
+     *
+     * @return an error message documenting the intersection location
+     */
+    std::string getErrorMessage() const;
+
+    /**
+     * Checks for an intersection and throws
+     * a TopologyException if one is found.
+     *
+     * @throws TopologyException if an intersection is found
+     */
+    void checkValid();
 
 private:
 
-	geos::algorithm::LineIntersector li;
+    geos::algorithm::LineIntersector li;
 
-	std::vector<noding::SegmentString*>& segStrings;
+    std::vector<noding::SegmentString*>& segStrings;
 
-	std::unique_ptr<NodingIntersectionFinder> segInt;
+    std::unique_ptr<NodingIntersectionFinder> segInt;
 
-	bool isValidVar;
+    bool isValidVar;
 
-	void execute()
-	{
-		if (segInt.get() != nullptr) return;
-		checkInteriorIntersections();
-	}
+    void
+    execute()
+    {
+        if(segInt.get() != nullptr) {
+            return;
+        }
+        checkInteriorIntersections();
+    }
 
-	void checkInteriorIntersections();
+    void checkInteriorIntersections();
 
     // Declare type as noncopyable
     FastNodingValidator(const FastNodingValidator& other) = delete;
diff --git a/include/geos/noding/FastSegmentSetIntersectionFinder.h b/include/geos/noding/FastSegmentSetIntersectionFinder.h
index 2d72ebf..6a4770e 100644
--- a/include/geos/noding/FastSegmentSetIntersectionFinder.h
+++ b/include/geos/noding/FastSegmentSetIntersectionFinder.h
@@ -27,11 +27,11 @@
 
 //forward declarations
 namespace geos {
-	namespace noding {
-		class SegmentIntersectionDetector;
-		class SegmentSetMutualIntersector;
-		//class MCIndexSegmentSetMutualIntersector : public SegmentSetMutualIntersector;
-	}
+namespace noding {
+class SegmentIntersectionDetector;
+class SegmentSetMutualIntersector;
+//class MCIndexSegmentSetMutualIntersector : public SegmentSetMutualIntersector;
+}
 }
 
 
@@ -47,31 +47,31 @@ namespace noding { // geos::noding
  *
  * @version 1.7
  */
-class FastSegmentSetIntersectionFinder
-{
+class FastSegmentSetIntersectionFinder {
 private:
-	std::unique_ptr<MCIndexSegmentSetMutualIntersector> segSetMutInt;
-	std::unique_ptr<geos::algorithm::LineIntersector> lineIntersector;
+    std::unique_ptr<MCIndexSegmentSetMutualIntersector> segSetMutInt;
+    std::unique_ptr<geos::algorithm::LineIntersector> lineIntersector;
 
 protected:
 public:
-	FastSegmentSetIntersectionFinder( SegmentString::ConstVect * baseSegStrings);
+    FastSegmentSetIntersectionFinder(SegmentString::ConstVect* baseSegStrings);
 
-	~FastSegmentSetIntersectionFinder() = default;
+    ~FastSegmentSetIntersectionFinder() = default;
 
-	/**
-	 * Gets the segment set intersector used by this class.
-	 * This allows other uses of the same underlying indexed structure.
-	 *
-	 * @return the segment set intersector used
-	 */
-	const SegmentSetMutualIntersector * getSegmentSetIntersector() const
-	{
-		return segSetMutInt.get();
-	}
+    /**
+     * Gets the segment set intersector used by this class.
+     * This allows other uses of the same underlying indexed structure.
+     *
+     * @return the segment set intersector used
+     */
+    const SegmentSetMutualIntersector*
+    getSegmentSetIntersector() const
+    {
+        return segSetMutInt.get();
+    }
 
-	bool intersects( SegmentString::ConstVect * segStrings);
-	bool intersects( SegmentString::ConstVect * segStrings, SegmentIntersectionDetector * intDetector);
+    bool intersects(SegmentString::ConstVect* segStrings);
+    bool intersects(SegmentString::ConstVect* segStrings, SegmentIntersectionDetector* intDetector);
 
 };
 
diff --git a/include/geos/noding/GeometryNoder.h b/include/geos/noding/GeometryNoder.h
index af8a790..07addff 100644
--- a/include/geos/noding/GeometryNoder.h
+++ b/include/geos/noding/GeometryNoder.h
@@ -26,44 +26,43 @@
 
 // Forward declarations
 namespace geos {
-	namespace geom {
-    class Geometry;
-  }
-	namespace noding {
-		class Noder;
-	}
+namespace geom {
+class Geometry;
+}
+namespace noding {
+class Noder;
+}
 }
 
 namespace geos {
 namespace noding { // geos.noding
 
-class GEOS_DLL GeometryNoder
-{
+class GEOS_DLL GeometryNoder {
 public:
 
-  static std::unique_ptr<geom::Geometry> node(const geom::Geometry& geom);
+    static std::unique_ptr<geom::Geometry> node(const geom::Geometry& geom);
 
-  GeometryNoder(const geom::Geometry& g);
+    GeometryNoder(const geom::Geometry& g);
 
-  std::unique_ptr<geom::Geometry> getNoded();
+    std::unique_ptr<geom::Geometry> getNoded();
 
 private:
 
-  const geom::Geometry& argGeom;
+    const geom::Geometry& argGeom;
 
-  SegmentString::NonConstVect lineList;
+    SegmentString::NonConstVect lineList;
 
-  static void extractSegmentStrings(const geom::Geometry& g,
-                                    SegmentString::NonConstVect& to);
+    static void extractSegmentStrings(const geom::Geometry& g,
+                                      SegmentString::NonConstVect& to);
 
-  Noder& getNoder();
+    Noder& getNoder();
 
-  std::unique_ptr<Noder> noder;
+    std::unique_ptr<Noder> noder;
 
-  std::unique_ptr<geom::Geometry> toGeometry(SegmentString::NonConstVect& noded);
+    std::unique_ptr<geom::Geometry> toGeometry(SegmentString::NonConstVect& noded);
 
-  GeometryNoder(GeometryNoder const&); /*= delete*/
-  GeometryNoder& operator=(GeometryNoder const&); /*= delete*/
+    GeometryNoder(GeometryNoder const&); /*= delete*/
+    GeometryNoder& operator=(GeometryNoder const&); /*= delete*/
 };
 
 } // namespace geos.noding
diff --git a/include/geos/noding/IntersectionAdder.h b/include/geos/noding/IntersectionAdder.h
index f9b49b3..79cca47 100644
--- a/include/geos/noding/IntersectionAdder.h
+++ b/include/geos/noding/IntersectionAdder.h
@@ -32,15 +32,15 @@
 
 // Forward declarations
 namespace geos {
-	namespace geom {
-		class Coordinate;
-	}
-	namespace noding {
-		class SegmentString;
-	}
-	namespace algorithm {
-		class LineIntersector;
-	}
+namespace geom {
+class Coordinate;
+}
+namespace noding {
+class SegmentString;
+}
+namespace algorithm {
+class LineIntersector;
+}
 }
 
 namespace geos {
@@ -59,30 +59,30 @@ class GEOS_DLL IntersectionAdder: public SegmentIntersector {
 
 private:
 
-	/**
-	 * These variables keep track of what types of intersections were
-	 * found during ALL edges that have been intersected.
-	 */
-	bool hasIntersectionVar;
-	bool hasProper;
-	bool hasProperInterior;
-	bool hasInterior;
-
-	// the proper intersection point found
-	const geom::Coordinate* properIntersectionPoint;
-
-	algorithm::LineIntersector& li;
-	// bool isSelfIntersection;
-	// bool intersectionFound;
-
-	/**
-	 * A trivial intersection is an apparent self-intersection which
-	 * in fact is simply the point shared by adjacent line segments.
-	 * Note that closed edges require a special check for the point
-	 * shared by the beginning and end segments.
-	 */
-	bool isTrivialIntersection(const SegmentString* e0, size_t segIndex0,
-			const SegmentString* e1, size_t segIndex1);
+    /**
+     * These variables keep track of what types of intersections were
+     * found during ALL edges that have been intersected.
+     */
+    bool hasIntersectionVar;
+    bool hasProper;
+    bool hasProperInterior;
+    bool hasInterior;
+
+    // the proper intersection point found
+    const geom::Coordinate* properIntersectionPoint;
+
+    algorithm::LineIntersector& li;
+    // bool isSelfIntersection;
+    // bool intersectionFound;
+
+    /**
+     * A trivial intersection is an apparent self-intersection which
+     * in fact is simply the point shared by adjacent line segments.
+     * Note that closed edges require a special check for the point
+     * shared by the beginning and end segments.
+     */
+    bool isTrivialIntersection(const SegmentString* e0, size_t segIndex0,
+                               const SegmentString* e1, size_t segIndex1);
 
     // Declare type as noncopyable
     IntersectionAdder(const IntersectionAdder& other) = delete;
@@ -90,89 +90,115 @@ private:
 
 public:
 
-	int numIntersections;
-	int numInteriorIntersections;
-	int numProperIntersections;
-
-	// testing only
-	int numTests;
-
-	IntersectionAdder(algorithm::LineIntersector& newLi)
-		:
-		hasIntersectionVar(false),
-		hasProper(false),
-		hasProperInterior(false),
-		hasInterior(false),
-		properIntersectionPoint(nullptr),
-		li(newLi),
-		numIntersections(0),
-		numInteriorIntersections(0),
-		numProperIntersections(0),
-		numTests(0)
-	{}
-
-	algorithm::LineIntersector& getLineIntersector() { return li; }
-
-	/**
-	 * @return the proper intersection point, or <code>NULL</code>
-	 *         if none was found
-	 */
-	const geom::Coordinate* getProperIntersectionPoint()  {
-		return properIntersectionPoint;
-	}
-
-	bool hasIntersection() { return hasIntersectionVar; }
-
-	/**
-	 * A proper intersection is an intersection which is interior to
-	 * at least two line segments.  Note that a proper intersection
-	 * is not necessarily in the interior of the entire Geometry,
-	 * since another edge may have an endpoint equal to the intersection,
-	 * which according to SFS semantics can result in the point being
-	 * on the Boundary of the Geometry.
-	 */
-	bool hasProperIntersection() { return hasProper; }
-
-	/**
-	 * A proper interior intersection is a proper intersection which is
-	 * <b>not</b> contained in the set of boundary nodes set for this
-	 * SegmentIntersector.
-	 */
-	bool hasProperInteriorIntersection() { return hasProperInterior; }
-
-	/**
-	 * An interior intersection is an intersection which is
-	 * in the interior of some segment.
-	 */
-	bool hasInteriorIntersection() { return hasInterior; }
-
-
-	/**
-	 * This method is called by clients
-	 * of the {@link SegmentIntersector} class to process
-	 * intersections for two segments of the SegmentStrings being
-	 * intersected.
-	 * Note that some clients (such as MonotoneChains) may optimize away
-	 * this call for segment pairs which they have determined do not
-	 * intersect (e.g. by an disjoint envelope test).
-	 */
-	void processIntersections(
-		SegmentString* e0,  size_t segIndex0,
-		SegmentString* e1,  size_t segIndex1) override;
-
-
-	static bool isAdjacentSegments(size_t i1, size_t i2) {
-		return (i1 > i2 ? i1 - i2 : i2 - i1) == 1;
-	}
-
-	/**
-	 * Always process all intersections
-	 *
-	 * @return false always
-	 */
-	bool isDone() const override {
-		return false;
-	}
+    int numIntersections;
+    int numInteriorIntersections;
+    int numProperIntersections;
+
+    // testing only
+    int numTests;
+
+    IntersectionAdder(algorithm::LineIntersector& newLi)
+        :
+        hasIntersectionVar(false),
+        hasProper(false),
+        hasProperInterior(false),
+        hasInterior(false),
+        properIntersectionPoint(nullptr),
+        li(newLi),
+        numIntersections(0),
+        numInteriorIntersections(0),
+        numProperIntersections(0),
+        numTests(0)
+    {}
+
+    algorithm::LineIntersector&
+    getLineIntersector()
+    {
+        return li;
+    }
+
+    /**
+     * @return the proper intersection point, or <code>NULL</code>
+     *         if none was found
+     */
+    const geom::Coordinate*
+    getProperIntersectionPoint()
+    {
+        return properIntersectionPoint;
+    }
+
+    bool
+    hasIntersection()
+    {
+        return hasIntersectionVar;
+    }
+
+    /**
+     * A proper intersection is an intersection which is interior to
+     * at least two line segments.  Note that a proper intersection
+     * is not necessarily in the interior of the entire Geometry,
+     * since another edge may have an endpoint equal to the intersection,
+     * which according to SFS semantics can result in the point being
+     * on the Boundary of the Geometry.
+     */
+    bool
+    hasProperIntersection()
+    {
+        return hasProper;
+    }
+
+    /**
+     * A proper interior intersection is a proper intersection which is
+     * <b>not</b> contained in the set of boundary nodes set for this
+     * SegmentIntersector.
+     */
+    bool
+    hasProperInteriorIntersection()
+    {
+        return hasProperInterior;
+    }
+
+    /**
+     * An interior intersection is an intersection which is
+     * in the interior of some segment.
+     */
+    bool
+    hasInteriorIntersection()
+    {
+        return hasInterior;
+    }
+
+
+    /**
+     * This method is called by clients
+     * of the {@link SegmentIntersector} class to process
+     * intersections for two segments of the SegmentStrings being
+     * intersected.
+     * Note that some clients (such as MonotoneChains) may optimize away
+     * this call for segment pairs which they have determined do not
+     * intersect (e.g. by an disjoint envelope test).
+     */
+    void processIntersections(
+        SegmentString* e0,  size_t segIndex0,
+        SegmentString* e1,  size_t segIndex1) override;
+
+
+    static bool
+    isAdjacentSegments(size_t i1, size_t i2)
+    {
+        return (i1 > i2 ? i1 - i2 : i2 - i1) == 1;
+    }
+
+    /**
+     * Always process all intersections
+     *
+     * @return false always
+     */
+    bool
+    isDone() const override
+    {
+        return false;
+    }
 };
 
 
diff --git a/include/geos/noding/IntersectionFinderAdder.h b/include/geos/noding/IntersectionFinderAdder.h
index 3f2225c..a828fd9 100644
--- a/include/geos/noding/IntersectionFinderAdder.h
+++ b/include/geos/noding/IntersectionFinderAdder.h
@@ -31,15 +31,15 @@
 
 // Forward declarations
 namespace geos {
-	namespace geom {
-		class Coordinate;
-	}
-	namespace noding {
-		class SegmentString;
-	}
-	namespace algorithm {
-		class LineIntersector;
-	}
+namespace geom {
+class Coordinate;
+}
+namespace noding {
+class SegmentString;
+}
+namespace algorithm {
+class LineIntersector;
+}
 }
 
 namespace geos {
@@ -54,50 +54,54 @@ class GEOS_DLL IntersectionFinderAdder: public SegmentIntersector {
 
 public:
 
-	/**
-	 * Creates an intersection finder which finds all proper intersections
-	 * and stores them in the provided Coordinate array
-	 *
-	 * @param li the LineIntersector to use
-	 * @param v  the Vector to push interior intersections to
-	 */
-	IntersectionFinderAdder(algorithm::LineIntersector& newLi,
-			std::vector<geom::Coordinate>& v)
-		:
-		li(newLi),
-		interiorIntersections(v)
-	{}
-
-	/**
-	 * This method is called by clients
-	 * of the {@link SegmentIntersector} class to process
-	 * intersections for two segments of the {@link SegmentStrings}
-	 * being intersected.
-	 * Note that some clients (such as {@link MonotoneChain}s) may
-	 * optimize away this call for segment pairs which they have
-	 * determined do not intersect
-	 * (e.g. by an disjoint envelope test).
-	 */
-	void processIntersections(
-		SegmentString* e0,  size_t segIndex0,
-		SegmentString* e1,  size_t segIndex1) override;
-
-	std::vector<geom::Coordinate>& getInteriorIntersections() {
-		return interiorIntersections;
-	}
-
-	/**
-	 * Always process all intersections
-	 *
-	 * @return false always
-	 */
-	bool isDone() const override {
-		return false;
-	}
+    /**
+     * Creates an intersection finder which finds all proper intersections
+     * and stores them in the provided Coordinate array
+     *
+     * @param li the LineIntersector to use
+     * @param v  the Vector to push interior intersections to
+     */
+    IntersectionFinderAdder(algorithm::LineIntersector& newLi,
+                            std::vector<geom::Coordinate>& v)
+        :
+        li(newLi),
+        interiorIntersections(v)
+    {}
+
+    /**
+     * This method is called by clients
+     * of the {@link SegmentIntersector} class to process
+     * intersections for two segments of the {@link SegmentStrings}
+     * being intersected.
+     * Note that some clients (such as {@link MonotoneChain}s) may
+     * optimize away this call for segment pairs which they have
+     * determined do not intersect
+     * (e.g. by an disjoint envelope test).
+     */
+    void processIntersections(
+        SegmentString* e0,  size_t segIndex0,
+        SegmentString* e1,  size_t segIndex1) override;
+
+    std::vector<geom::Coordinate>&
+    getInteriorIntersections()
+    {
+        return interiorIntersections;
+    }
+
+    /**
+     * Always process all intersections
+     *
+     * @return false always
+     */
+    bool
+    isDone() const override
+    {
+        return false;
+    }
 
 private:
-	algorithm::LineIntersector& li;
-	std::vector<geom::Coordinate>& interiorIntersections;
+    algorithm::LineIntersector& li;
+    std::vector<geom::Coordinate>& interiorIntersections;
 
     // Declare type as noncopyable
     IntersectionFinderAdder(const IntersectionFinderAdder& other) = delete;
diff --git a/include/geos/noding/IteratedNoder.h b/include/geos/noding/IteratedNoder.h
index 684d9c9..90cb2ea 100644
--- a/include/geos/noding/IteratedNoder.h
+++ b/include/geos/noding/IteratedNoder.h
@@ -32,9 +32,9 @@
 
 // Forward declarations
 namespace geos {
-	namespace geom {
-		class PrecisionModel;
-	}
+namespace geom {
+class PrecisionModel;
+}
 }
 
 namespace geos {
@@ -55,59 +55,65 @@ namespace noding { // geos::noding
 class GEOS_DLL IteratedNoder : public Noder { // implements Noder
 
 private:
-	static const int MAX_ITER = 5;
+    static const int MAX_ITER = 5;
 
 
-	const geom::PrecisionModel *pm;
-	algorithm::LineIntersector li;
-	std::vector<SegmentString*>* nodedSegStrings;
-	int maxIter;
+    const geom::PrecisionModel* pm;
+    algorithm::LineIntersector li;
+    std::vector<SegmentString*>* nodedSegStrings;
+    int maxIter;
 
-	/**
-	 * Node the input segment strings once
-	 * and create the split edges between the nodes
-	 */
-	void node(std::vector<SegmentString*>* segStrings,
-			int *numInteriorIntersections);
+    /**
+     * Node the input segment strings once
+     * and create the split edges between the nodes
+     */
+    void node(std::vector<SegmentString*>* segStrings,
+              int* numInteriorIntersections);
 
 public:
 
-	IteratedNoder(const geom::PrecisionModel *newPm)
-		:
-		pm(newPm),
-		li(pm),
-		maxIter(MAX_ITER)
-	{
-	}
-
-	~IteratedNoder() override {}
-
-	/**
-	 * Sets the maximum number of noding iterations performed before
-	 * the noding is aborted.
-	 * Experience suggests that this should rarely need to be changed
-	 * from the default.
-	 * The default is MAX_ITER.
-	 *
-	 * @param n the maximum number of iterations to perform
-	 */
-	void setMaximumIterations(int n) { maxIter = n; }
-
-	std::vector<SegmentString*>* getNodedSubstrings() const override {
-		return nodedSegStrings;
-	}
-
-
-	/**
-	 * Fully nodes a list of {@link SegmentStrings}, i.e. peforms noding iteratively
-	 * until no intersections are found between segments.
-	 * Maintains labelling of edges correctly through
-	 * the noding.
-	 *
-	 * @param segStrings a collection of SegmentStrings to be noded
-	 * @throws TopologyException if the iterated noding fails to converge.
-	 */
-	void computeNodes(std::vector<SegmentString*>* inputSegmentStrings) override; // throw(GEOSException);
+    IteratedNoder(const geom::PrecisionModel* newPm)
+        :
+        pm(newPm),
+        li(pm),
+        maxIter(MAX_ITER)
+    {
+    }
+
+    ~IteratedNoder() override {}
+
+    /**
+     * Sets the maximum number of noding iterations performed before
+     * the noding is aborted.
+     * Experience suggests that this should rarely need to be changed
+     * from the default.
+     * The default is MAX_ITER.
+     *
+     * @param n the maximum number of iterations to perform
+     */
+    void
+    setMaximumIterations(int n)
+    {
+        maxIter = n;
+    }
+
+    std::vector<SegmentString*>*
+    getNodedSubstrings() const override
+    {
+        return nodedSegStrings;
+    }
+
+
+    /**
+     * Fully nodes a list of {@link SegmentStrings}, i.e. peforms noding iteratively
+     * until no intersections are found between segments.
+     * Maintains labelling of edges correctly through
+     * the noding.
+     *
+     * @param segStrings a collection of SegmentStrings to be noded
+     * @throws TopologyException if the iterated noding fails to converge.
+     */
+    void computeNodes(std::vector<SegmentString*>* inputSegmentStrings) override; // throw(GEOSException);
 };
 
 } // namespace geos::noding
diff --git a/include/geos/noding/MCIndexNoder.h b/include/geos/noding/MCIndexNoder.h
index f0fd48d..d5ba28c 100644
--- a/include/geos/noding/MCIndexNoder.h
+++ b/include/geos/noding/MCIndexNoder.h
@@ -38,13 +38,13 @@
 
 // Forward declarations
 namespace geos {
-	namespace geom {
-		class LineSegment;
-	}
-	namespace noding {
-		class SegmentString;
-		class SegmentIntersector;
-	}
+namespace geom {
+class LineSegment;
+}
+namespace noding {
+class SegmentString;
+class SegmentIntersector;
+}
 }
 
 namespace geos {
@@ -63,55 +63,59 @@ namespace noding { // geos.noding
 class GEOS_DLL MCIndexNoder : public SinglePassNoder {
 
 private:
-	std::vector<index::chain::MonotoneChain*> monoChains;
-	index::strtree::STRtree index;
-	int idCounter;
-	std::vector<SegmentString*>* nodedSegStrings;
-	// statistics
-	int nOverlaps;
+    std::vector<index::chain::MonotoneChain*> monoChains;
+    index::strtree::STRtree index;
+    int idCounter;
+    std::vector<SegmentString*>* nodedSegStrings;
+    // statistics
+    int nOverlaps;
 
-	void intersectChains();
+    void intersectChains();
 
-	void add(SegmentString* segStr);
+    void add(SegmentString* segStr);
 
 public:
 
-	MCIndexNoder(SegmentIntersector *nSegInt=nullptr)
-		:
-		SinglePassNoder(nSegInt),
-		idCounter(0),
-		nodedSegStrings(nullptr),
-		nOverlaps(0)
-	{}
+    MCIndexNoder(SegmentIntersector* nSegInt = nullptr)
+        :
+        SinglePassNoder(nSegInt),
+        idCounter(0),
+        nodedSegStrings(nullptr),
+        nOverlaps(0)
+    {}
 
-	~MCIndexNoder() override;
+    ~MCIndexNoder() override;
 
-	/// Return a reference to this instance's std::vector of MonotoneChains
-	std::vector<index::chain::MonotoneChain*>& getMonotoneChains() { return monoChains; }
+    /// Return a reference to this instance's std::vector of MonotoneChains
+    std::vector<index::chain::MonotoneChain*>&
+    getMonotoneChains()
+    {
+        return monoChains;
+    }
 
-	index::SpatialIndex& getIndex();
+    index::SpatialIndex& getIndex();
 
-	std::vector<SegmentString*>* getNodedSubstrings() const override;
+    std::vector<SegmentString*>* getNodedSubstrings() const override;
 
-	void computeNodes(std::vector<SegmentString*>* inputSegmentStrings) override;
+    void computeNodes(std::vector<SegmentString*>* inputSegmentStrings) override;
 
-	class SegmentOverlapAction : public index::chain::MonotoneChainOverlapAction {
-	public:
-		SegmentOverlapAction(SegmentIntersector& newSi)
-			:
-			index::chain::MonotoneChainOverlapAction(),
-			si(newSi)
-		{}
+    class SegmentOverlapAction : public index::chain::MonotoneChainOverlapAction {
+    public:
+        SegmentOverlapAction(SegmentIntersector& newSi)
+            :
+            index::chain::MonotoneChainOverlapAction(),
+            si(newSi)
+        {}
 
-		void overlap(index::chain::MonotoneChain& mc1, std::size_t start1,
-            index::chain::MonotoneChain& mc2, std::size_t start2) override;
+        void overlap(index::chain::MonotoneChain& mc1, std::size_t start1,
+                     index::chain::MonotoneChain& mc2, std::size_t start2) override;
     private:
         SegmentIntersector& si;
 
         // Declare type as noncopyable
         SegmentOverlapAction(const SegmentOverlapAction& other) = delete;
         SegmentOverlapAction& operator=(const SegmentOverlapAction& rhs) = delete;
-	};
+    };
 
 };
 
diff --git a/include/geos/noding/MCIndexNoder.inl b/include/geos/noding/MCIndexNoder.inl
index 837197a..5883c4f 100644
--- a/include/geos/noding/MCIndexNoder.inl
+++ b/include/geos/noding/MCIndexNoder.inl
@@ -7,7 +7,7 @@
  *
  * This is free software; you can redistribute and/or modify it under
  * the terms of the GNU Lesser General Public Licence as published
- * by the Free Software Foundation. 
+ * by the Free Software Foundation.
  * See the COPYING file for more information.
  *
  **********************************************************************
@@ -31,14 +31,14 @@ namespace noding { // geos::noding
 INLINE index::SpatialIndex&
 MCIndexNoder::getIndex()
 {
-	return index;
+    return index;
 }
 
 INLINE std::vector<SegmentString*>*
 MCIndexNoder::getNodedSubstrings() const
 {
-	assert(nodedSegStrings); // must have colled computeNodes before!
-	return NodedSegmentString::getNodedSubstrings(*nodedSegStrings);
+    assert(nodedSegStrings); // must have colled computeNodes before!
+    return NodedSegmentString::getNodedSubstrings(*nodedSegStrings);
 }
 
 } // namespace geos::noding
diff --git a/include/geos/noding/MCIndexSegmentSetMutualIntersector.h b/include/geos/noding/MCIndexSegmentSetMutualIntersector.h
index d35daca..aed9dc5 100644
--- a/include/geos/noding/MCIndexSegmentSetMutualIntersector.h
+++ b/include/geos/noding/MCIndexSegmentSetMutualIntersector.h
@@ -24,20 +24,20 @@
 #include <geos/index/chain/MonotoneChainOverlapAction.h> // inherited
 
 namespace geos {
-	namespace index {
-		class SpatialIndex;
-
-		namespace chain {
-			class MonotoneChain;
-		}
-		namespace strtree {
-			//class STRtree;
-		}
-	}
-	namespace noding {
-		class SegmentString;
-		class SegmentIntersector;
-	}
+namespace index {
+class SpatialIndex;
+
+namespace chain {
+class MonotoneChain;
+}
+namespace strtree {
+//class STRtree;
+}
+}
+namespace noding {
+class SegmentString;
+class SegmentIntersector;
+}
 }
 
 //using namespace geos::index::strtree;
@@ -51,75 +51,74 @@ namespace noding { // geos::noding
  *
  * @version 1.7
  */
-class MCIndexSegmentSetMutualIntersector : public SegmentSetMutualIntersector
-{
+class MCIndexSegmentSetMutualIntersector : public SegmentSetMutualIntersector {
 public:
 
-	MCIndexSegmentSetMutualIntersector();
+    MCIndexSegmentSetMutualIntersector();
 
-	~MCIndexSegmentSetMutualIntersector() override;
+    ~MCIndexSegmentSetMutualIntersector() override;
 
-	index::SpatialIndex* getIndex()
-	{
-		return index;
-	}
+    index::SpatialIndex*
+    getIndex()
+    {
+        return index;
+    }
 
-	void setBaseSegments(SegmentString::ConstVect* segStrings) override;
+    void setBaseSegments(SegmentString::ConstVect* segStrings) override;
 
-	// NOTE: re-populates the MonotoneChain vector with newly created chains
-	void process(SegmentString::ConstVect* segStrings) override;
+    // NOTE: re-populates the MonotoneChain vector with newly created chains
+    void process(SegmentString::ConstVect* segStrings) override;
 
-    class SegmentOverlapAction : public index::chain::MonotoneChainOverlapAction
-    {
+    class SegmentOverlapAction : public index::chain::MonotoneChainOverlapAction {
     private:
-        SegmentIntersector & si;
+        SegmentIntersector& si;
 
         // Declare type as noncopyable
         SegmentOverlapAction(const SegmentOverlapAction& other) = delete;
         SegmentOverlapAction& operator=(const SegmentOverlapAction& rhs) = delete;
 
     public:
-        SegmentOverlapAction(SegmentIntersector & p_si) :
-          index::chain::MonotoneChainOverlapAction(), si(p_si)
-          {}
+        SegmentOverlapAction(SegmentIntersector& p_si) :
+            index::chain::MonotoneChainOverlapAction(), si(p_si)
+        {}
 
-          void overlap(index::chain::MonotoneChain& mc1, std::size_t start1,
-              index::chain::MonotoneChain& mc2, std::size_t start2) override;
+        void overlap(index::chain::MonotoneChain& mc1, std::size_t start1,
+                     index::chain::MonotoneChain& mc2, std::size_t start2) override;
     };
 
     /**
      * Disable copy construction and assignment. Apparently needed to make this
      * class compile under MSVC. (See https://stackoverflow.com/q/29565299)
      */
-     MCIndexSegmentSetMutualIntersector(const MCIndexSegmentSetMutualIntersector&) = delete;
-     MCIndexSegmentSetMutualIntersector& operator=(const MCIndexSegmentSetMutualIntersector&) = delete;
+    MCIndexSegmentSetMutualIntersector(const MCIndexSegmentSetMutualIntersector&) = delete;
+    MCIndexSegmentSetMutualIntersector& operator=(const MCIndexSegmentSetMutualIntersector&) = delete;
 
 private:
 
-	typedef std::vector<std::unique_ptr<index::chain::MonotoneChain>> MonoChains;
-	MonoChains monoChains;
-
-	/*
-	 * The {@link SpatialIndex} used should be something that supports
-	 * envelope (range) queries efficiently (such as a {@link Quadtree}
-	 * or {@link STRtree}.
-	 */
-	index::SpatialIndex * index;
-	int indexCounter;
-	int processCounter;
-	// statistics
-	int nOverlaps;
+    typedef std::vector<std::unique_ptr<index::chain::MonotoneChain>> MonoChains;
+    MonoChains monoChains;
 
-	/* memory management helper, holds MonotoneChain objects used
-	 * in the SpatialIndex. It's cleared when the SpatialIndex is
-	 */
-	MonoChains chainStore;
+    /*
+     * The {@link SpatialIndex} used should be something that supports
+     * envelope (range) queries efficiently (such as a {@link Quadtree}
+     * or {@link STRtree}.
+     */
+    index::SpatialIndex* index;
+    int indexCounter;
+    int processCounter;
+    // statistics
+    int nOverlaps;
+
+    /* memory management helper, holds MonotoneChain objects used
+     * in the SpatialIndex. It's cleared when the SpatialIndex is
+     */
+    MonoChains chainStore;
 
-	void addToIndex( SegmentString * segStr);
+    void addToIndex(SegmentString* segStr);
 
-	void intersectChains();
+    void intersectChains();
 
-	void addToMonoChains( SegmentString * segStr);
+    void addToMonoChains(SegmentString* segStr);
 
 };
 
diff --git a/include/geos/noding/NodableSegmentString.h b/include/geos/noding/NodableSegmentString.h
index 687057c..4263461 100644
--- a/include/geos/noding/NodableSegmentString.h
+++ b/include/geos/noding/NodableSegmentString.h
@@ -20,9 +20,9 @@
 #include <geos/noding/SegmentString.h> // for inheritance
 
 namespace geos {
-	namespace geom {
-		class Coordinate;
-	}
+namespace geom {
+class Coordinate;
+}
 }
 
 namespace geos {
@@ -34,23 +34,22 @@ namespace noding { // geos::noding
  *
  * @author Martin Davis
  */
-class GEOS_DLL NodableSegmentString : public SegmentString
-{
+class GEOS_DLL NodableSegmentString : public SegmentString {
 private:
 protected:
 public:
-	NodableSegmentString(const void* newContext)
-		:
-		SegmentString( newContext )
-	{ }
-
-	/**
-	 * Adds an intersection node for a given point and segment to this segment string.
-	 *
-	 * @param intPt the location of the intersection
-	 * @param segmentIndex the index of the segment containing the intersection
-	 */
-	//virtual void addIntersection( const geom::Coordinate * intPt, int segmentIndex) =0;
+    NodableSegmentString(const void* newContext)
+        :
+        SegmentString(newContext)
+    { }
+
+    /**
+     * Adds an intersection node for a given point and segment to this segment string.
+     *
+     * @param intPt the location of the intersection
+     * @param segmentIndex the index of the segment containing the intersection
+     */
+    //virtual void addIntersection( const geom::Coordinate * intPt, int segmentIndex) =0;
 };
 
 } // namespace geos::noding
diff --git a/include/geos/noding/NodedSegmentString.h b/include/geos/noding/NodedSegmentString.h
index 52b02be..46099b8 100644
--- a/include/geos/noding/NodedSegmentString.h
+++ b/include/geos/noding/NodedSegmentString.h
@@ -54,155 +54,155 @@ namespace noding { // geos::noding
  * All noded substrings are initialized with the same context object.
  *
  */
-class GEOS_DLL NodedSegmentString : public NodableSegmentString
-{
+class GEOS_DLL NodedSegmentString : public NodableSegmentString {
 public:
 
     // TODO: provide a templated method using an output iterator
     template <class II>
-    static void getNodedSubstrings(II from, II too_far,
-        SegmentString::NonConstVect* resultEdgelist)
+    static void
+    getNodedSubstrings(II from, II too_far,
+                       SegmentString::NonConstVect* resultEdgelist)
     {
-        for (II i=from; i != too_far; ++i)
-        {
-            NodedSegmentString * nss = dynamic_cast<NodedSegmentString*>(*i);
+        for(II i = from; i != too_far; ++i) {
+            NodedSegmentString* nss = dynamic_cast<NodedSegmentString*>(*i);
             assert(nss);
             nss->getNodeList().addSplitEdges(resultEdgelist);
         }
     }
 
     template <class C>
-    static void getNodedSubstrings(C *segStrings,
-        SegmentString::NonConstVect* resultEdgelist)
+    static void
+    getNodedSubstrings(C* segStrings,
+                       SegmentString::NonConstVect* resultEdgelist)
     {
         getNodedSubstrings(segStrings->begin(), segStrings->end(), resultEdgelist);
     }
 
-	static void getNodedSubstrings(const SegmentString::NonConstVect& segStrings,
-			SegmentString::NonConstVect* resultEdgeList);
+    static void getNodedSubstrings(const SegmentString::NonConstVect& segStrings,
+                                   SegmentString::NonConstVect* resultEdgeList);
 
-	/// Returns allocated object
-	static SegmentString::NonConstVect* getNodedSubstrings(
-			const SegmentString::NonConstVect& segStrings);
+    /// Returns allocated object
+    static SegmentString::NonConstVect* getNodedSubstrings(
+        const SegmentString::NonConstVect& segStrings);
 
 
-	/**
-	 * Creates a new segment string from a list of vertices.
-	 *
-	 * @param newPts CoordinateSequence representing the string,
-	 *               ownership transferred.
-	 *
-	 * @param data the user-defined data of this segment string
-	 *             (may be null)
-	 */
-    NodedSegmentString(geom::CoordinateSequence *newPts, const void* newContext)
+    /**
+     * Creates a new segment string from a list of vertices.
+     *
+     * @param newPts CoordinateSequence representing the string,
+     *               ownership transferred.
+     *
+     * @param data the user-defined data of this segment string
+     *             (may be null)
+     */
+    NodedSegmentString(geom::CoordinateSequence* newPts, const void* newContext)
         : NodableSegmentString(newContext)
         , nodeList(this)
         , pts(newPts)
     {}
 
-	~NodedSegmentString() override
-	{
-		delete pts;
-	}
-
-	/**
-	 * Adds an intersection node for a given point and segment to this segment string.
-	 * If an intersection already exists for this exact location, the existing
-	 * node will be returned.
-	 *
-	 * @param intPt the location of the intersection
-	 * @param segmentIndex the index of the segment containing the intersection
-	 * @return the intersection node for the point
-	 */
-	SegmentNode* addIntersectionNode( geom::Coordinate * intPt, std::size_t segmentIndex)
-	{
-		std::size_t normalizedSegmentIndex = segmentIndex;
-
-		// normalize the intersection point location
-		std::size_t nextSegIndex = normalizedSegmentIndex + 1;
-		if (nextSegIndex < size())
-		{
-			geom::Coordinate const& nextPt =
+    ~NodedSegmentString() override
+    {
+        delete pts;
+    }
+
+    /**
+     * Adds an intersection node for a given point and segment to this segment string.
+     * If an intersection already exists for this exact location, the existing
+     * node will be returned.
+     *
+     * @param intPt the location of the intersection
+     * @param segmentIndex the index of the segment containing the intersection
+     * @return the intersection node for the point
+     */
+    SegmentNode*
+    addIntersectionNode(geom::Coordinate* intPt, std::size_t segmentIndex)
+    {
+        std::size_t normalizedSegmentIndex = segmentIndex;
+
+        // normalize the intersection point location
+        std::size_t nextSegIndex = normalizedSegmentIndex + 1;
+        if(nextSegIndex < size()) {
+            geom::Coordinate const& nextPt =
                 getCoordinate(nextSegIndex);
 
-			// Normalize segment index if intPt falls on vertex
-			// The check for point equality is 2D only - Z values are ignored
-			if ( intPt->equals2D( nextPt ))
-			{
-				normalizedSegmentIndex = nextSegIndex;
-			}
-		}
-
-		// Add the intersection point to edge intersection list.
-		SegmentNode * ei = getNodeList().add( *intPt, normalizedSegmentIndex);
-		return ei;
-	}
-
-	SegmentNodeList& getNodeList();
-
-	const SegmentNodeList& getNodeList() const;
-
-	size_t size() const override
-	{
-		return pts->size();
-	}
-
-	const geom::Coordinate& getCoordinate(size_t i) const override;
-
-	geom::CoordinateSequence* getCoordinates() const override;
-
-	bool isClosed() const override;
-
-	std::ostream& print(std::ostream& os) const override;
-
-
-	/** \brief
-	 * Gets the octant of the segment starting at vertex index.
-	 *
-	 * @param index the index of the vertex starting the segment.
-	 *        Must not be the last index in the vertex list
-	 * @return the octant of the segment at the vertex
-	 */
-	int getSegmentOctant(size_t index) const;
-
-	/** \brief
-	 * Add {SegmentNode}s for one or both
-	 * intersections found for a segment of an edge to the edge
-	 * intersection list.
-	 */
-	void addIntersections(algorithm::LineIntersector *li,
-			size_t segmentIndex, size_t geomIndex);
-
-	/** \brief
-	 * Add an SegmentNode for intersection intIndex.
-	 *
-	 * An intersection that falls exactly on a vertex
-	 * of the SegmentString is normalized
-	 * to use the higher of the two possible segmentIndexes
-	 */
-	void addIntersection(algorithm::LineIntersector *li,
-			size_t segmentIndex,
-			size_t geomIndex, size_t intIndex);
-
-	/** \brief
-	 * Add an SegmentNode for intersection intIndex.
-	 *
-	 * An intersection that falls exactly on a vertex of the
-	 * edge is normalized
-	 * to use the higher of the two possible segmentIndexes
-	 */
-	void addIntersection(const geom::Coordinate& intPt,
-			size_t segmentIndex);
+            // Normalize segment index if intPt falls on vertex
+            // The check for point equality is 2D only - Z values are ignored
+            if(intPt->equals2D(nextPt)) {
+                normalizedSegmentIndex = nextSegIndex;
+            }
+        }
+
+        // Add the intersection point to edge intersection list.
+        SegmentNode* ei = getNodeList().add(*intPt, normalizedSegmentIndex);
+        return ei;
+    }
+
+    SegmentNodeList& getNodeList();
+
+    const SegmentNodeList& getNodeList() const;
+
+    size_t
+    size() const override
+    {
+        return pts->size();
+    }
+
+    const geom::Coordinate& getCoordinate(size_t i) const override;
+
+    geom::CoordinateSequence* getCoordinates() const override;
+
+    bool isClosed() const override;
+
+    std::ostream& print(std::ostream& os) const override;
+
+
+    /** \brief
+     * Gets the octant of the segment starting at vertex index.
+     *
+     * @param index the index of the vertex starting the segment.
+     *        Must not be the last index in the vertex list
+     * @return the octant of the segment at the vertex
+     */
+    int getSegmentOctant(size_t index) const;
+
+    /** \brief
+     * Add {SegmentNode}s for one or both
+     * intersections found for a segment of an edge to the edge
+     * intersection list.
+     */
+    void addIntersections(algorithm::LineIntersector* li,
+                          size_t segmentIndex, size_t geomIndex);
+
+    /** \brief
+     * Add an SegmentNode for intersection intIndex.
+     *
+     * An intersection that falls exactly on a vertex
+     * of the SegmentString is normalized
+     * to use the higher of the two possible segmentIndexes
+     */
+    void addIntersection(algorithm::LineIntersector* li,
+                         size_t segmentIndex,
+                         size_t geomIndex, size_t intIndex);
+
+    /** \brief
+     * Add an SegmentNode for intersection intIndex.
+     *
+     * An intersection that falls exactly on a vertex of the
+     * edge is normalized
+     * to use the higher of the two possible segmentIndexes
+     */
+    void addIntersection(const geom::Coordinate& intPt,
+                         size_t segmentIndex);
 
 
 private:
 
-	SegmentNodeList nodeList;
+    SegmentNodeList nodeList;
 
-	geom::CoordinateSequence *pts;
+    geom::CoordinateSequence* pts;
 
-	static int safeOctant(const geom::Coordinate& p0, const geom::Coordinate& p1);
+    static int safeOctant(const geom::Coordinate& p0, const geom::Coordinate& p1);
 
 };
 
diff --git a/include/geos/noding/Noder.h b/include/geos/noding/Noder.h
index 034916d..41625d0 100644
--- a/include/geos/noding/Noder.h
+++ b/include/geos/noding/Noder.h
@@ -24,9 +24,9 @@
 
 // Forward declarations
 namespace geos {
-	namespace noding {
-		class SegmentString;
-	}
+namespace noding {
+class SegmentString;
+}
 }
 
 namespace geos {
@@ -48,29 +48,30 @@ namespace noding { // geos.noding
  */
 class GEOS_DLL Noder {
 public:
-	/** \brief
-	 * Computes the noding for a collection of {@link SegmentString}s.
-	 *
-	 * Some Noders may add all these nodes to the input SegmentStrings;
-	 * others may only add some or none at all.
-	 *
-	 * @param segStrings a collection of {@link SegmentString}s to node
-	 */
-	virtual void computeNodes(std::vector<SegmentString*>* segStrings)=0;
+    /** \brief
+     * Computes the noding for a collection of {@link SegmentString}s.
+     *
+     * Some Noders may add all these nodes to the input SegmentStrings;
+     * others may only add some or none at all.
+     *
+     * @param segStrings a collection of {@link SegmentString}s to node
+     */
+    virtual void computeNodes(std::vector<SegmentString*>* segStrings) = 0;
 
-	/** \brief
-	 * Returns a {@link Collection} of fully noded {@link SegmentStrings}.
-	 * The SegmentStrings have the same context as their parent.
-	 *
-	 * @return a newly allocated std::vector of const SegmentStrings.
-	 *         Caller is responsible to delete container and elements.
-	 */
-	virtual std::vector<SegmentString*>* getNodedSubstrings() const=0;
+    /** \brief
+     * Returns a {@link Collection} of fully noded {@link SegmentStrings}.
+     * The SegmentStrings have the same context as their parent.
+     *
+     * @return a newly allocated std::vector of const SegmentStrings.
+     *         Caller is responsible to delete container and elements.
+     */
+    virtual std::vector<SegmentString*>* getNodedSubstrings() const = 0;
 
-	virtual ~Noder() {}
+    virtual
+    ~Noder() {}
 
 protected:
-	Noder(){}
+    Noder() {}
 };
 
 } // namespace geos.noding
diff --git a/include/geos/noding/NodingIntersectionFinder.h b/include/geos/noding/NodingIntersectionFinder.h
index c7d2f26..61ebc8c 100644
--- a/include/geos/noding/NodingIntersectionFinder.h
+++ b/include/geos/noding/NodingIntersectionFinder.h
@@ -22,12 +22,12 @@
 
 // Forward declarations
 namespace geos {
-	namespace algorithm {
-		class LineIntersector;
-	}
-	namespace noding {
-		class SegmentString;
-	}
+namespace algorithm {
+class LineIntersector;
+}
+namespace noding {
+class SegmentString;
+}
 }
 
 namespace geos {
@@ -44,55 +44,57 @@ namespace noding { // geos.noding
  *
  * @version 1.7
  */
-class NodingIntersectionFinder: public SegmentIntersector
-{
+class NodingIntersectionFinder: public SegmentIntersector {
 
 public:
 
-	/** \brief
-	 * Creates an intersection finder which finds an interior intersection
-	 * if one exists
-	 *
-	 * @param li the LineIntersector to use
-	 */
-	NodingIntersectionFinder(algorithm::LineIntersector& newLi)
-		:
-		li(newLi),
-		interiorIntersection(geom::Coordinate::getNull()),
+    /** \brief
+     * Creates an intersection finder which finds an interior intersection
+     * if one exists
+     *
+     * @param li the LineIntersector to use
+     */
+    NodingIntersectionFinder(algorithm::LineIntersector& newLi)
+        :
+        li(newLi),
+        interiorIntersection(geom::Coordinate::getNull()),
         intersectionCount(0),
         isCheckEndSegmentsOnly(false),
         findAllIntersections(false),
         keepIntersections(true)
-	{
-	}
-
-	/** \brief
-	 * Tests whether an intersection was found.
-	 *
-	 * @return true if an intersection was found
-	 */
-	bool hasIntersection() const
-	{
-		return !interiorIntersection.isNull();
-	}
-
-	/** \brief
-	 * Gets the computed location of the intersection.
-	 * Due to round-off, the location may not be exact.
-	 *
-	 * @return the coordinate for the intersection location
-	 */
-	const geom::Coordinate& getInteriorIntersection() const
-	{
-		return interiorIntersection;
-	}
+    {
+    }
+
+    /** \brief
+     * Tests whether an intersection was found.
+     *
+     * @return true if an intersection was found
+     */
+    bool
+    hasIntersection() const
+    {
+        return !interiorIntersection.isNull();
+    }
+
+    /** \brief
+     * Gets the computed location of the intersection.
+     * Due to round-off, the location may not be exact.
+     *
+     * @return the coordinate for the intersection location
+     */
+    const geom::Coordinate&
+    getInteriorIntersection() const
+    {
+        return interiorIntersection;
+    }
 
     /**
     * Gets the count of intersections found.
     *
     * @return the intersection count
     */
-    size_t count() const
+    size_t
+    count() const
     {
         return intersectionCount;
     }
@@ -106,7 +108,8 @@ public:
     *
     * @param isCheckEndSegmentsOnly whether to test only end segments
     */
-    void setCheckEndSegmentsOnly(bool isCESO)
+    void
+    setCheckEndSegmentsOnly(bool isCESO)
     {
         isCheckEndSegmentsOnly = isCESO;
     }
@@ -121,47 +124,50 @@ public:
     *
     * @param findAllIntersections whether all intersections should be computed
     */
-    void setFindAllIntersections(bool fAI)
+    void
+    setFindAllIntersections(bool fAI)
     {
         findAllIntersections = fAI;
     }
 
-	/** \brief
-	 * Gets the endpoints of the intersecting segments.
-	 *
-	 * @return an array of the segment endpoints (p00, p01, p10, p11)
-	 */
-	const std::vector<geom::Coordinate>& getIntersectionSegments() const
-	{
-		return intSegments;
-	}
-
-	/** \brief
-	 * This method is called by clients
-	 * of the {@link SegmentIntersector} class to process
-	 * intersections for two segments of the {@link SegmentStrings} being intersected.
-	 *
-	 * Note that some clients (such as {@link MonotoneChain}s) may optimize away
-	 * this call for segment pairs which they have determined do not intersect
-	 * (e.g. by an disjoint envelope test).
-	 */
-	void processIntersections(
-		SegmentString* e0,  size_t segIndex0,
-		SegmentString* e1,  size_t segIndex1) override;
-
-	bool isDone() const override
-	{
-		return !interiorIntersection.isNull();
-	}
+    /** \brief
+     * Gets the endpoints of the intersecting segments.
+     *
+     * @return an array of the segment endpoints (p00, p01, p10, p11)
+     */
+    const std::vector<geom::Coordinate>&
+    getIntersectionSegments() const
+    {
+        return intSegments;
+    }
+
+    /** \brief
+     * This method is called by clients
+     * of the {@link SegmentIntersector} class to process
+     * intersections for two segments of the {@link SegmentStrings} being intersected.
+     *
+     * Note that some clients (such as {@link MonotoneChain}s) may optimize away
+     * this call for segment pairs which they have determined do not intersect
+     * (e.g. by an disjoint envelope test).
+     */
+    void processIntersections(
+        SegmentString* e0,  size_t segIndex0,
+        SegmentString* e1,  size_t segIndex1) override;
+
+    bool
+    isDone() const override
+    {
+        return !interiorIntersection.isNull();
+    }
 
 private:
-	algorithm::LineIntersector& li;
-	geom::Coordinate interiorIntersection;
+    algorithm::LineIntersector& li;
+    geom::Coordinate interiorIntersection;
     size_t intersectionCount;
     bool isCheckEndSegmentsOnly;
     bool findAllIntersections;
     bool keepIntersections;
-	std::vector<geom::Coordinate> intSegments;
+    std::vector<geom::Coordinate> intSegments;
 
     // Declare type as noncopyable
     NodingIntersectionFinder(const NodingIntersectionFinder& other) = delete;
diff --git a/include/geos/noding/NodingValidator.h b/include/geos/noding/NodingValidator.h
index 0aad997..b62bafe 100644
--- a/include/geos/noding/NodingValidator.h
+++ b/include/geos/noding/NodingValidator.h
@@ -27,12 +27,12 @@
 
 // Forward declarations
 namespace geos {
-	namespace geom {
-		class Coordinate;
-	}
-	namespace noding {
-		class SegmentString;
-	}
+namespace geom {
+class Coordinate;
+}
+namespace noding {
+class SegmentString;
+}
 }
 
 namespace geos {
@@ -47,48 +47,48 @@ namespace noding { // geos.noding
  */
 class GEOS_DLL NodingValidator {
 private:
-	algorithm::LineIntersector li;
-	const std::vector<SegmentString*>& segStrings;
+    algorithm::LineIntersector li;
+    const std::vector<SegmentString*>& segStrings;
 
-	/**
-	 * Checks if a segment string contains a segment
-	 * pattern a-b-a (which implies a self-intersection)
-	 */
-	void checkCollapses() const;
+    /**
+     * Checks if a segment string contains a segment
+     * pattern a-b-a (which implies a self-intersection)
+     */
+    void checkCollapses() const;
 
-	void checkCollapses(const SegmentString& ss) const;
+    void checkCollapses(const SegmentString& ss) const;
 
-	void checkCollapse(const geom::Coordinate& p0, const geom::Coordinate& p1,
-			const geom::Coordinate& p2) const;
+    void checkCollapse(const geom::Coordinate& p0, const geom::Coordinate& p1,
+                       const geom::Coordinate& p2) const;
 
-	/**
-	 * Checks all pairs of segments for intersections at an
-	 * interior point of a segment
-	 */
-	void checkInteriorIntersections();
+    /**
+     * Checks all pairs of segments for intersections at an
+     * interior point of a segment
+     */
+    void checkInteriorIntersections();
 
-	void checkInteriorIntersections(const SegmentString& ss0,
-			const SegmentString& ss1);
+    void checkInteriorIntersections(const SegmentString& ss0,
+                                    const SegmentString& ss1);
 
-	void checkInteriorIntersections(
-			const SegmentString& e0, size_t segIndex0,
-			const SegmentString& e1, size_t segIndex1);
+    void checkInteriorIntersections(
+        const SegmentString& e0, size_t segIndex0,
+        const SegmentString& e1, size_t segIndex1);
 
-	/**
-	 * Checks for intersections between an endpoint of a segment string
-	 * and an interior vertex of another segment string
-	 */
-	void checkEndPtVertexIntersections() const;
+    /**
+     * Checks for intersections between an endpoint of a segment string
+     * and an interior vertex of another segment string
+     */
+    void checkEndPtVertexIntersections() const;
 
-	void checkEndPtVertexIntersections(const geom::Coordinate& testPt,
-			const std::vector<SegmentString*>& segStrings) const;
+    void checkEndPtVertexIntersections(const geom::Coordinate& testPt,
+                                       const std::vector<SegmentString*>& segStrings) const;
 
-	/**
-	 * @return true if there is an intersection point which is not an
-	 *         endpoint of the segment p0-p1
-	 */
-	bool hasInteriorIntersection(const algorithm::LineIntersector& aLi,
-			const geom::Coordinate& p0, const geom::Coordinate& p1) const;
+    /**
+     * @return true if there is an intersection point which is not an
+     *         endpoint of the segment p0-p1
+     */
+    bool hasInteriorIntersection(const algorithm::LineIntersector& aLi,
+                                 const geom::Coordinate& p0, const geom::Coordinate& p1) const;
 
     // Declare type as noncopyable
     NodingValidator(const NodingValidator& other) = delete;
@@ -96,13 +96,13 @@ private:
 
 public:
 
-	NodingValidator(const std::vector<SegmentString*>& newSegStrings):
-		segStrings(newSegStrings)
-	{}
+    NodingValidator(const std::vector<SegmentString*>& newSegStrings):
+        segStrings(newSegStrings)
+    {}
 
-	~NodingValidator() {}
+    ~NodingValidator() {}
 
-	void checkValid();
+    void checkValid();
 
 };
 
diff --git a/include/geos/noding/Octant.h b/include/geos/noding/Octant.h
index aab788f..327938f 100644
--- a/include/geos/noding/Octant.h
+++ b/include/geos/noding/Octant.h
@@ -22,9 +22,9 @@
 
 // Forward declarations
 namespace geos {
-	namespace geom {
-		class Coordinate;
-	}
+namespace geom {
+class Coordinate;
+}
 }
 
 namespace geos {
@@ -48,25 +48,26 @@ namespace noding { // geos.noding
  */
 class GEOS_DLL Octant {
 private:
-	Octant() {} // Can't instanciate it
+    Octant() {} // Can't instanciate it
 public:
 
-	/**
-	 * Returns the octant of a directed line segment (specified
-	 * as x and y displacements, which cannot both be 0).
-	 */
-	static int octant(double dx, double dy);
+    /**
+     * Returns the octant of a directed line segment (specified
+     * as x and y displacements, which cannot both be 0).
+     */
+    static int octant(double dx, double dy);
 
-	/**
-	 * Returns the octant of a directed line segment from p0 to p1.
-	 */
-	static int octant(const geom::Coordinate& p0, const geom::Coordinate& p1);
+    /**
+     * Returns the octant of a directed line segment from p0 to p1.
+     */
+    static int octant(const geom::Coordinate& p0, const geom::Coordinate& p1);
 
-    static int octant(const geom::Coordinate* p0, const geom::Coordinate* p1)
+    static int
+    octant(const geom::Coordinate* p0, const geom::Coordinate* p1)
     {
         ::geos::ignore_unused_variable_warning(p0);
-		return octant(*p0, *p1);
-	}
+        return octant(*p0, *p1);
+    }
 };
 
 
diff --git a/include/geos/noding/OrientedCoordinateArray.h b/include/geos/noding/OrientedCoordinateArray.h
index 4a4dd78..43eb97f 100644
--- a/include/geos/noding/OrientedCoordinateArray.h
+++ b/include/geos/noding/OrientedCoordinateArray.h
@@ -28,12 +28,12 @@
 
 // Forward declarations
 namespace geos {
-	namespace geom {
-		class CoordinateSequence;
-	}
-	namespace noding {
-		//class SegmentString;
-	}
+namespace geom {
+class CoordinateSequence;
+}
+namespace noding {
+//class SegmentString;
+}
 }
 
 namespace geos {
@@ -43,68 +43,68 @@ namespace noding { // geos.noding
  * Allows comparing {@link geom::CoordinateSequence}s
  * in an orientation-independent way.
  */
-class GEOS_DLL OrientedCoordinateArray
-{
+class GEOS_DLL OrientedCoordinateArray {
 public:
 
-	/**
-	 * Creates a new {@link OrientedCoordinateArray}
-	 * for the given {@link geom::CoordinateSequence}.
-	 *
-	 * @param pts the coordinates to orient
-	 */
-	OrientedCoordinateArray(const geom::CoordinateSequence& p_pts)
-		:
-		pts(&p_pts),
-		orientationVar(orientation(p_pts))
-	{
-	}
-
-	/** \brief
-	 * Compares two {@link OrientedCoordinateArray}s for their
-	 * relative order
-	 *
-	 * @return -1 this one is smaller
-	 * @return 0 the two objects are equal
-	 * @return 1 this one is greater
-	 *
-	 * In JTS, this is used automatically by ordered lists.
-	 * In C++, operator< would be used instead....
-	 */
-	int compareTo(const OrientedCoordinateArray& o1) const;
+    /**
+     * Creates a new {@link OrientedCoordinateArray}
+     * for the given {@link geom::CoordinateSequence}.
+     *
+     * @param pts the coordinates to orient
+     */
+    OrientedCoordinateArray(const geom::CoordinateSequence& p_pts)
+        :
+        pts(&p_pts),
+        orientationVar(orientation(p_pts))
+    {
+    }
+
+    /** \brief
+     * Compares two {@link OrientedCoordinateArray}s for their
+     * relative order
+     *
+     * @return -1 this one is smaller
+     * @return 0 the two objects are equal
+     * @return 1 this one is greater
+     *
+     * In JTS, this is used automatically by ordered lists.
+     * In C++, operator< would be used instead....
+     */
+    int compareTo(const OrientedCoordinateArray& o1) const;
 
 
 private:
 
-	static int compareOriented(const geom::CoordinateSequence& pts1,
-                                     bool orientation1,
-                                     const geom::CoordinateSequence& pts2,
-                                     bool orientation2);
+    static int compareOriented(const geom::CoordinateSequence& pts1,
+                               bool orientation1,
+                               const geom::CoordinateSequence& pts2,
+                               bool orientation2);
 
 
-	/**
-	 * Computes the canonical orientation for a coordinate array.
-	 *
-	 * @param pts the array to test
-	 * @return <code>true</code> if the points are oriented forwards
-	 * @return <code>false</code if the points are oriented in reverse
-	 */
-	static bool orientation(const geom::CoordinateSequence& pts);
+    /**
+     * Computes the canonical orientation for a coordinate array.
+     *
+     * @param pts the array to test
+     * @return <code>true</code> if the points are oriented forwards
+     * @return <code>false</code if the points are oriented in reverse
+     */
+    static bool orientation(const geom::CoordinateSequence& pts);
 
-	/// Externally owned
-	const geom::CoordinateSequence* pts;
+    /// Externally owned
+    const geom::CoordinateSequence* pts;
 
-	bool orientationVar;
+    bool orientationVar;
 
 };
 
 /// Strict weak ordering operator for OrientedCoordinateArray
 //
 /// This is the C++ equivalent of JTS's compareTo
-inline bool operator< ( const OrientedCoordinateArray& oca1,
-                        const OrientedCoordinateArray& oca2 )
+inline bool
+operator< (const OrientedCoordinateArray& oca1,
+           const OrientedCoordinateArray& oca2)
 {
-  return oca1.compareTo(oca2)<0;
+    return oca1.compareTo(oca2) < 0;
 }
 
 } // namespace geos.noding
diff --git a/include/geos/noding/ScaledNoder.h b/include/geos/noding/ScaledNoder.h
index 52decf0..75f256e 100644
--- a/include/geos/noding/ScaledNoder.h
+++ b/include/geos/noding/ScaledNoder.h
@@ -36,13 +36,13 @@
 
 // Forward declarations
 namespace geos {
-	namespace geom {
-		class Coordinate;
-		class CoordinateSequence;
-	}
-	namespace noding {
-		class SegmentString;
-	}
+namespace geom {
+class Coordinate;
+class CoordinateSequence;
+}
+namespace noding {
+class SegmentString;
+}
 }
 
 namespace geos {
@@ -62,57 +62,62 @@ class GEOS_DLL ScaledNoder : public Noder { // , public geom::CoordinateFilter {
 
 public:
 
-	bool isIntegerPrecision() { return (scaleFactor == 1.0); }
+    bool
+    isIntegerPrecision()
+    {
+        return (scaleFactor == 1.0);
+    }
 
-	ScaledNoder(Noder& n, double nScaleFactor,
-			double nOffsetX=0.0, double nOffsetY=0.0)
-		:
-		noder(n),
-		scaleFactor(nScaleFactor),
-		offsetX(nOffsetX),
-		offsetY(nOffsetY),
-		isScaled(nScaleFactor!=1.0)
-	{}
+    ScaledNoder(Noder& n, double nScaleFactor,
+                double nOffsetX = 0.0, double nOffsetY = 0.0)
+        :
+        noder(n),
+        scaleFactor(nScaleFactor),
+        offsetX(nOffsetX),
+        offsetY(nOffsetY),
+        isScaled(nScaleFactor != 1.0)
+    {}
 
-	~ScaledNoder() override;
+    ~ScaledNoder() override;
 
-	std::vector<SegmentString*>* getNodedSubstrings() const override;
+    std::vector<SegmentString*>* getNodedSubstrings() const override;
 
-	void computeNodes(std::vector<SegmentString*>* inputSegStr) override;
+    void computeNodes(std::vector<SegmentString*>* inputSegStr) override;
 
-	//void filter(Coordinate& c);
+    //void filter(Coordinate& c);
 
-	void filter_ro(const geom::Coordinate* c)
+    void
+    filter_ro(const geom::Coordinate* c)
     {
         ::geos::ignore_unused_variable_warning(c);
         assert(0);
     }
 
-	void filter_rw(geom::Coordinate* c) const;
+    void filter_rw(geom::Coordinate* c) const;
 
 private:
 
-	Noder& noder;
+    Noder& noder;
 
-	double scaleFactor;
+    double scaleFactor;
 
-	double offsetX;
+    double offsetX;
 
-	double offsetY;
+    double offsetY;
 
-	bool isScaled;
+    bool isScaled;
 
-	void rescale(std::vector<SegmentString*>& segStrings) const;
+    void rescale(std::vector<SegmentString*>& segStrings) const;
 
-	void scale(std::vector<SegmentString*>& segStrings) const;
+    void scale(std::vector<SegmentString*>& segStrings) const;
 
-	class Scaler;
+    class Scaler;
 
-	class ReScaler;
+    class ReScaler;
 
-	friend class ScaledNoder::Scaler;
+    friend class ScaledNoder::Scaler;
 
-	friend class ScaledNoder::ReScaler;
+    friend class ScaledNoder::ReScaler;
 
     mutable std::vector<geom::CoordinateSequence*> newCoordSeq;
 
diff --git a/include/geos/noding/SegmentIntersectionDetector.h b/include/geos/noding/SegmentIntersectionDetector.h
index 1957dbd..4d8c14f 100644
--- a/include/geos/noding/SegmentIntersectionDetector.h
+++ b/include/geos/noding/SegmentIntersectionDetector.h
@@ -39,128 +39,137 @@ namespace noding { // geos::noding
  *
  * @version 1.7
  */
-class SegmentIntersectionDetector : public SegmentIntersector
-{
+class SegmentIntersectionDetector : public SegmentIntersector {
 private:
-	algorithm::LineIntersector * li;
+    algorithm::LineIntersector* li;
 
-	bool findProper;
-	bool findAllTypes;
+    bool findProper;
+    bool findAllTypes;
 
-	bool _hasIntersection;
-	bool _hasProperIntersection;
-	bool _hasNonProperIntersection;
+    bool _hasIntersection;
+    bool _hasProperIntersection;
+    bool _hasNonProperIntersection;
 
-	const geom::Coordinate * intPt;
-	geom::CoordinateSequence * intSegments;
+    const geom::Coordinate* intPt;
+    geom::CoordinateSequence* intSegments;
 
 protected:
 public:
-	SegmentIntersectionDetector( algorithm::LineIntersector * p_li)
-		:
-		li( p_li),
-		findProper(false),
-		findAllTypes(false),
-		_hasIntersection(false),
-		_hasProperIntersection(false),
-		_hasNonProperIntersection(false),
-		intPt( nullptr),
-		intSegments( nullptr)
-	{ }
-
-	~SegmentIntersectionDetector() override
-	{
-		//delete intPt;
-		delete intSegments;
-	}
-
-
-	void setFindProper( bool p_findProper)
-	{
-		this->findProper = p_findProper;
-	}
-
-	void setFindAllIntersectionTypes( bool p_findAllTypes)
-	{
-		this->findAllTypes = p_findAllTypes;
-	}
-
-	/**
-	 * Tests whether an intersection was found.
-	 *
-	 * @return true if an intersection was found
-	 */
-	bool hasIntersection() const
-	{
-		return _hasIntersection;
-	}
-
-	/**
-	 * Tests whether a proper intersection was found.
-	 *
-	 * @return true if a proper intersection was found
-	 */
-	bool hasProperIntersection() const
-	{
-		return _hasProperIntersection;
-	}
-
-	/**
-	 * Tests whether a non-proper intersection was found.
-	 *
-	 * @return true if a non-proper intersection was found
-	 */
-	bool hasNonProperIntersection() const
-	{
-		return _hasNonProperIntersection;
-	}
-
-	/**
-	* Gets the computed location of the intersection.
-	* Due to round-off, the location may not be exact.
-	*
-	* @return the coordinate for the intersection location
-	*/
-	const geom::Coordinate * getIntersection()  const
-	{
-		return intPt;
-	}
-
-
-	/**
-	 * Gets the endpoints of the intersecting segments.
-	 *
-	 * @return an array of the segment endpoints (p00, p01, p10, p11)
-	 */
-	const geom::CoordinateSequence * getIntersectionSegments() const
-	{
-		return intSegments;
-	}
-
-	bool isDone() const override
-	{
-		// If finding all types, we can stop
-		// when both possible types have been found.
-		if (findAllTypes)
-			return _hasProperIntersection && _hasNonProperIntersection;
-
-		// If searching for a proper intersection, only stop if one is found
-		if (findProper)
-			return _hasProperIntersection;
-
-		return _hasIntersection;
-	}
-
-	/**
-	 * This method is called by clients
-	 * of the {@link SegmentIntersector} class to process
-	 * intersections for two segments of the {@link SegmentStrings} being intersected.
-	 * Note that some clients (such as {@link MonotoneChain}s) may optimize away
-	 * this call for segment pairs which they have determined do not intersect
-	 * (e.g. by an disjoint envelope test).
-	 */
-	void processIntersections(	noding::SegmentString * e0, size_t segIndex0,
-								noding::SegmentString * e1, size_t segIndex1 ) override;
+    SegmentIntersectionDetector(algorithm::LineIntersector* p_li)
+        :
+        li(p_li),
+        findProper(false),
+        findAllTypes(false),
+        _hasIntersection(false),
+        _hasProperIntersection(false),
+        _hasNonProperIntersection(false),
+        intPt(nullptr),
+        intSegments(nullptr)
+    { }
+
+    ~SegmentIntersectionDetector() override
+    {
+        //delete intPt;
+        delete intSegments;
+    }
+
+
+    void
+    setFindProper(bool p_findProper)
+    {
+        this->findProper = p_findProper;
+    }
+
+    void
+    setFindAllIntersectionTypes(bool p_findAllTypes)
+    {
+        this->findAllTypes = p_findAllTypes;
+    }
+
+    /**
+     * Tests whether an intersection was found.
+     *
+     * @return true if an intersection was found
+     */
+    bool
+    hasIntersection() const
+    {
+        return _hasIntersection;
+    }
+
+    /**
+     * Tests whether a proper intersection was found.
+     *
+     * @return true if a proper intersection was found
+     */
+    bool
+    hasProperIntersection() const
+    {
+        return _hasProperIntersection;
+    }
+
+    /**
+     * Tests whether a non-proper intersection was found.
+     *
+     * @return true if a non-proper intersection was found
+     */
+    bool
+    hasNonProperIntersection() const
+    {
+        return _hasNonProperIntersection;
+    }
+
+    /**
+    * Gets the computed location of the intersection.
+    * Due to round-off, the location may not be exact.
+    *
+    * @return the coordinate for the intersection location
+    */
+    const geom::Coordinate*
+    getIntersection()  const
+    {
+        return intPt;
+    }
+
+
+    /**
+     * Gets the endpoints of the intersecting segments.
+     *
+     * @return an array of the segment endpoints (p00, p01, p10, p11)
+     */
+    const geom::CoordinateSequence*
+    getIntersectionSegments() const
+    {
+        return intSegments;
+    }
+
+    bool
+    isDone() const override
+    {
+        // If finding all types, we can stop
+        // when both possible types have been found.
+        if(findAllTypes) {
+            return _hasProperIntersection && _hasNonProperIntersection;
+        }
+
+        // If searching for a proper intersection, only stop if one is found
+        if(findProper) {
+            return _hasProperIntersection;
+        }
+
+        return _hasIntersection;
+    }
+
+    /**
+     * This method is called by clients
+     * of the {@link SegmentIntersector} class to process
+     * intersections for two segments of the {@link SegmentStrings} being intersected.
+     * Note that some clients (such as {@link MonotoneChain}s) may optimize away
+     * this call for segment pairs which they have determined do not intersect
+     * (e.g. by an disjoint envelope test).
+     */
+    void processIntersections(noding::SegmentString* e0, size_t segIndex0,
+                              noding::SegmentString* e1, size_t segIndex1) override;
 
 };
 
diff --git a/include/geos/noding/SegmentIntersector.h b/include/geos/noding/SegmentIntersector.h
index f7d4535..5b9139a 100644
--- a/include/geos/noding/SegmentIntersector.h
+++ b/include/geos/noding/SegmentIntersector.h
@@ -22,9 +22,9 @@
 
 // Forward declarations
 namespace geos {
-	namespace noding {
-		class SegmentString;
-	}
+namespace noding {
+class SegmentString;
+}
 }
 
 namespace geos {
@@ -49,35 +49,38 @@ class GEOS_DLL SegmentIntersector {
 
 public:
 
-	/**
-	 * This method is called by clients
-	 * of the SegmentIntersector interface to process
-	 * intersections for two segments of the SegmentStrings
-	 * being intersected.
-	 */
-	virtual void processIntersections(
-		SegmentString* e0,  size_t segIndex0,
-		SegmentString* e1,  size_t segIndex1) = 0;
-
-	/**
-	 * \brief
-	 * Reports whether the client of this class
-	 * needs to continue testing all intersections in an arrangement.
-	 *
-	 * @return true if there is not need to continue testing segments
-	 *
-	 * The default implementation always return false (process all intersections).
-	 */
-	virtual bool isDone() const {
-		return false;
-	}
-
-	virtual ~SegmentIntersector()
-	{ }
+    /**
+     * This method is called by clients
+     * of the SegmentIntersector interface to process
+     * intersections for two segments of the SegmentStrings
+     * being intersected.
+     */
+    virtual void processIntersections(
+        SegmentString* e0,  size_t segIndex0,
+        SegmentString* e1,  size_t segIndex1) = 0;
+
+    /**
+     * \brief
+     * Reports whether the client of this class
+     * needs to continue testing all intersections in an arrangement.
+     *
+     * @return true if there is not need to continue testing segments
+     *
+     * The default implementation always return false (process all intersections).
+     */
+    virtual bool
+    isDone() const
+    {
+        return false;
+    }
+
+    virtual
+    ~SegmentIntersector()
+    { }
 
 protected:
 
-	SegmentIntersector() {}
+    SegmentIntersector() {}
 
 };
 
diff --git a/include/geos/noding/SegmentNode.h b/include/geos/noding/SegmentNode.h
index 862230f..5b2bc47 100644
--- a/include/geos/noding/SegmentNode.h
+++ b/include/geos/noding/SegmentNode.h
@@ -30,9 +30,9 @@
 
 // Forward declarations
 namespace geos {
-	namespace noding {
-		class NodedSegmentString;
-	}
+namespace noding {
+class NodedSegmentString;
+}
 }
 
 namespace geos {
@@ -44,70 +44,76 @@ namespace noding { // geos.noding
 ///
 class GEOS_DLL SegmentNode {
 private:
-	const NodedSegmentString& segString;
+    const NodedSegmentString& segString;
 
-	int segmentOctant;
+    int segmentOctant;
 
-	bool isInteriorVar;
+    bool isInteriorVar;
 
     // Declare type as noncopyable
     SegmentNode(const SegmentNode& other) = delete;
     SegmentNode& operator=(const SegmentNode& rhs) = delete;
 
 public:
-	friend std::ostream& operator<< (std::ostream& os, const SegmentNode& n);
-
-	/// the point of intersection (own copy)
-	geom::Coordinate coord;
-
-	/// the index of the containing line segment in the parent edge
-	size_t segmentIndex;
-
-	/// Construct a node on the given NodedSegmentString
-	//
-	/// @param ss the parent NodedSegmentString
-	///
-	/// @param coord the coordinate of the intersection, will be copied
-	///
-	/// @param nSegmentIndex the index of the segment on parent
-	///                      NodedSegmentString
-	///        where the Node is located.
-	///
-	/// @param nSegmentOctant
-	///
-	SegmentNode(const NodedSegmentString& ss,
-		    const geom::Coordinate& nCoord,
-			size_t nSegmentIndex, int nSegmentOctant);
-
-	~SegmentNode() {}
-
-	/// \brief
-	/// Return true if this Node is *internal* (not on the boundary)
-	/// of the corresponding segment. Currently only the *first*
-	/// segment endpoint is checked, actually.
-	///
-	bool isInterior() const { return isInteriorVar; }
-
-	bool isEndPoint(unsigned int maxSegmentIndex) const;
-
-	/**
-	 * @return -1 this EdgeIntersection is located before
-	 *            the argument location
-	 * @return 0 this EdgeIntersection is at the argument location
-	 * @return 1 this EdgeIntersection is located after the
-	 *           argument location
-	 */
-	int compareTo(const SegmentNode& other);
-
-	//string print() const;
+    friend std::ostream& operator<< (std::ostream& os, const SegmentNode& n);
+
+    /// the point of intersection (own copy)
+    geom::Coordinate coord;
+
+    /// the index of the containing line segment in the parent edge
+    size_t segmentIndex;
+
+    /// Construct a node on the given NodedSegmentString
+    //
+    /// @param ss the parent NodedSegmentString
+    ///
+    /// @param coord the coordinate of the intersection, will be copied
+    ///
+    /// @param nSegmentIndex the index of the segment on parent
+    ///                      NodedSegmentString
+    ///        where the Node is located.
+    ///
+    /// @param nSegmentOctant
+    ///
+    SegmentNode(const NodedSegmentString& ss,
+                const geom::Coordinate& nCoord,
+                size_t nSegmentIndex, int nSegmentOctant);
+
+    ~SegmentNode() {}
+
+    /// \brief
+    /// Return true if this Node is *internal* (not on the boundary)
+    /// of the corresponding segment. Currently only the *first*
+    /// segment endpoint is checked, actually.
+    ///
+    bool
+    isInterior() const
+    {
+        return isInteriorVar;
+    }
+
+    bool isEndPoint(unsigned int maxSegmentIndex) const;
+
+    /**
+     * @return -1 this EdgeIntersection is located before
+     *            the argument location
+     * @return 0 this EdgeIntersection is at the argument location
+     * @return 1 this EdgeIntersection is located after the
+     *           argument location
+     */
+    int compareTo(const SegmentNode& other);
+
+    //string print() const;
 };
 
 std::ostream& operator<< (std::ostream& os, const SegmentNode& n);
 
 struct GEOS_DLL  SegmentNodeLT {
-	bool operator()(SegmentNode *s1, SegmentNode *s2) const {
-		return s1->compareTo(*s2)<0;
-	}
+    bool
+    operator()(SegmentNode* s1, SegmentNode* s2) const
+    {
+        return s1->compareTo(*s2) < 0;
+    }
 };
 
 
diff --git a/include/geos/noding/SegmentNodeList.h b/include/geos/noding/SegmentNodeList.h
index 872e5ce..8f100fa 100644
--- a/include/geos/noding/SegmentNodeList.h
+++ b/include/geos/noding/SegmentNodeList.h
@@ -37,13 +37,13 @@
 
 // Forward declarations
 namespace geos {
-	namespace geom {
-		class CoordinateSequence;
-	}
-	namespace noding {
-		class SegmentString;
-		class NodedSegmentString;
-	}
+namespace geom {
+class CoordinateSequence;
+}
+namespace noding {
+class SegmentString;
+class NodedSegmentString;
+}
 }
 
 namespace geos {
@@ -55,58 +55,58 @@ namespace noding { // geos::noding
  */
 class GEOS_DLL SegmentNodeList {
 private:
-	std::set<SegmentNode*,SegmentNodeLT> nodeMap;
-
-	// the parent edge
-	const NodedSegmentString& edge;
-
-	/**
-	 * Checks the correctness of the set of split edges corresponding
-	 * to this edge
-	 *
-	 * @param splitEdges the split edges for this edge (in order)
-	 */
-	void checkSplitEdgesCorrectness(std::vector<SegmentString*>& splitEdges);
-
-	/**
-	 * Create a new "split edge" with the section of points between
-	 * (and including) the two intersections.
-	 * The label for the new edge is the same as the label for the
-	 * parent edge.
-	 *
-	 * ownership of return value is transferred
-	 */
-	SegmentString* createSplitEdge(SegmentNode *ei0, SegmentNode *ei1);
-
-	/**
-	 * Adds nodes for any collapsed edge pairs.
-	 * Collapsed edge pairs can be caused by inserted nodes, or they
-	 * can be pre-existing in the edge vertex list.
-	 * In order to provide the correct fully noded semantics,
-	 * the vertex at the base of a collapsed pair must also be added
-	 * as a node.
-	 */
-	void addCollapsedNodes();
-
-	/**
-	 * Adds nodes for any collapsed edge pairs
-	 * which are pre-existing in the vertex list.
-	 */
-	void findCollapsesFromExistingVertices(
-			std::vector<std::size_t>& collapsedVertexIndexes);
-
-	/**
-	 * Adds nodes for any collapsed edge pairs caused by inserted nodes
-	 * Collapsed edge pairs occur when the same coordinate is inserted
-	 * as a node both before and after an existing edge vertex.
-	 * To provide the correct fully noded semantics,
-	 * the vertex must be added as a node as well.
-	 */
-	void findCollapsesFromInsertedNodes(
-		std::vector<std::size_t>& collapsedVertexIndexes);
-
-	bool findCollapseIndex(SegmentNode& ei0, SegmentNode& ei1,
-		size_t& collapsedVertexIndex);
+    std::set<SegmentNode*, SegmentNodeLT> nodeMap;
+
+    // the parent edge
+    const NodedSegmentString& edge;
+
+    /**
+     * Checks the correctness of the set of split edges corresponding
+     * to this edge
+     *
+     * @param splitEdges the split edges for this edge (in order)
+     */
+    void checkSplitEdgesCorrectness(std::vector<SegmentString*>& splitEdges);
+
+    /**
+     * Create a new "split edge" with the section of points between
+     * (and including) the two intersections.
+     * The label for the new edge is the same as the label for the
+     * parent edge.
+     *
+     * ownership of return value is transferred
+     */
+    SegmentString* createSplitEdge(SegmentNode* ei0, SegmentNode* ei1);
+
+    /**
+     * Adds nodes for any collapsed edge pairs.
+     * Collapsed edge pairs can be caused by inserted nodes, or they
+     * can be pre-existing in the edge vertex list.
+     * In order to provide the correct fully noded semantics,
+     * the vertex at the base of a collapsed pair must also be added
+     * as a node.
+     */
+    void addCollapsedNodes();
+
+    /**
+     * Adds nodes for any collapsed edge pairs
+     * which are pre-existing in the vertex list.
+     */
+    void findCollapsesFromExistingVertices(
+        std::vector<std::size_t>& collapsedVertexIndexes);
+
+    /**
+     * Adds nodes for any collapsed edge pairs caused by inserted nodes
+     * Collapsed edge pairs occur when the same coordinate is inserted
+     * as a node both before and after an existing edge vertex.
+     * To provide the correct fully noded semantics,
+     * the vertex must be added as a node as well.
+     */
+    void findCollapsesFromInsertedNodes(
+        std::vector<std::size_t>& collapsedVertexIndexes);
+
+    bool findCollapseIndex(SegmentNode& ei0, SegmentNode& ei1,
+                           size_t& collapsedVertexIndex);
 
     // Declare type as noncopyable
     SegmentNodeList(const SegmentNodeList& other) = delete;
@@ -114,72 +114,104 @@ private:
 
 public:
 
-	friend std::ostream& operator<< (std::ostream& os, const SegmentNodeList& l);
-
-	typedef std::set<SegmentNode*,SegmentNodeLT> container;
-	typedef container::iterator iterator;
-	typedef container::const_iterator const_iterator;
-
-	SegmentNodeList(const NodedSegmentString* newEdge): edge(*newEdge) {}
-
-	SegmentNodeList(const NodedSegmentString& newEdge): edge(newEdge) {}
-
-	const NodedSegmentString& getEdge() const { return edge; }
-
-	// TODO: Is this a final class ?
-	// Should remove the virtual in that case
-	virtual ~SegmentNodeList();
-
-	/**
-	 * Adds an intersection into the list, if it isn't already there.
-	 * The input segmentIndex is expected to be normalized.
-	 *
-	 * @return the SegmentIntersection found or added. It will be
-	 *	   destroyed at SegmentNodeList destruction time.
-	 *
-	 * @param intPt the intersection Coordinate, will be copied
-	 * @param segmentIndex
-	 */
-	SegmentNode* add(const geom::Coordinate& intPt, std::size_t segmentIndex);
-
-	SegmentNode* add(const geom::Coordinate *intPt, std::size_t segmentIndex) {
-		return add(*intPt, segmentIndex);
-	}
-
-	/*
-	 * returns the set of SegmentNodes
-	 */
-	//replaces iterator()
-	// TODO: obsolete this function
-	std::set<SegmentNode*,SegmentNodeLT>* getNodes() { return &nodeMap; }
-
-	/// Return the number of nodes in this list
-	size_t size() const { return nodeMap.size(); }
-
-	container::iterator begin() { return nodeMap.begin(); }
-	container::const_iterator begin() const { return nodeMap.begin(); }
-	container::iterator end() { return nodeMap.end(); }
-	container::const_iterator end() const { return nodeMap.end(); }
-
-	/**
-	 * Adds entries for the first and last points of the edge to the list
-	 */
-	void addEndpoints();
-
-	/**
-	 * Creates new edges for all the edges that the intersections in this
-	 * list split the parent edge into.
-	 * Adds the edges to the input list (this is so a single list
-	 * can be used to accumulate all split edges for a Geometry).
-	 */
-	void addSplitEdges(std::vector<SegmentString*>& edgeList);
-
-	void addSplitEdges(std::vector<SegmentString*>* edgeList) {
-		assert(edgeList);
-		addSplitEdges(*edgeList);
-	}
-
-	//string print();
+    friend std::ostream& operator<< (std::ostream& os, const SegmentNodeList& l);
+
+    typedef std::set<SegmentNode*, SegmentNodeLT> container;
+    typedef container::iterator iterator;
+    typedef container::const_iterator const_iterator;
+
+    SegmentNodeList(const NodedSegmentString* newEdge): edge(*newEdge) {}
+
+    SegmentNodeList(const NodedSegmentString& newEdge): edge(newEdge) {}
+
+    const NodedSegmentString&
+    getEdge() const
+    {
+        return edge;
+    }
+
+    // TODO: Is this a final class ?
+    // Should remove the virtual in that case
+    virtual ~SegmentNodeList();
+
+    /**
+     * Adds an intersection into the list, if it isn't already there.
+     * The input segmentIndex is expected to be normalized.
+     *
+     * @return the SegmentIntersection found or added. It will be
+     *	   destroyed at SegmentNodeList destruction time.
+     *
+     * @param intPt the intersection Coordinate, will be copied
+     * @param segmentIndex
+     */
+    SegmentNode* add(const geom::Coordinate& intPt, std::size_t segmentIndex);
+
+    SegmentNode*
+    add(const geom::Coordinate* intPt, std::size_t segmentIndex)
+    {
+        return add(*intPt, segmentIndex);
+    }
+
+    /*
+     * returns the set of SegmentNodes
+     */
+    //replaces iterator()
+    // TODO: obsolete this function
+    std::set<SegmentNode*, SegmentNodeLT>*
+    getNodes()
+    {
+        return &nodeMap;
+    }
+
+    /// Return the number of nodes in this list
+    size_t
+    size() const
+    {
+        return nodeMap.size();
+    }
+
+    container::iterator
+    begin()
+    {
+        return nodeMap.begin();
+    }
+    container::const_iterator
+    begin() const
+    {
+        return nodeMap.begin();
+    }
+    container::iterator
+    end()
+    {
+        return nodeMap.end();
+    }
+    container::const_iterator
+    end() const
+    {
+        return nodeMap.end();
+    }
+
+    /**
+     * Adds entries for the first and last points of the edge to the list
+     */
+    void addEndpoints();
+
+    /**
+     * Creates new edges for all the edges that the intersections in this
+     * list split the parent edge into.
+     * Adds the edges to the input list (this is so a single list
+     * can be used to accumulate all split edges for a Geometry).
+     */
+    void addSplitEdges(std::vector<SegmentString*>& edgeList);
+
+    void
+    addSplitEdges(std::vector<SegmentString*>* edgeList)
+    {
+        assert(edgeList);
+        addSplitEdges(*edgeList);
+    }
+
+    //string print();
 };
 
 std::ostream& operator<< (std::ostream& os, const SegmentNodeList& l);
diff --git a/include/geos/noding/SegmentPointComparator.h b/include/geos/noding/SegmentPointComparator.h
index 7579195..48d5e11 100644
--- a/include/geos/noding/SegmentPointComparator.h
+++ b/include/geos/noding/SegmentPointComparator.h
@@ -40,53 +40,78 @@ class GEOS_DLL SegmentPointComparator {
 
 public:
 
-	/**
-	 * Compares two Coordinates for their relative position along a
-	 * segment lying in the specified Octant.
-	 *
-	 * @return -1 node0 occurs first
-	 * @return 0 the two nodes are equal
-	 * @return 1 node1 occurs first
-	 */
-	static int compare(int octant, const geom::Coordinate& p0,
-			const geom::Coordinate& p1)
-	{
-		// nodes can only be equal if their coordinates are equal
-		if (p0.equals2D(p1)) return 0;
+    /**
+     * Compares two Coordinates for their relative position along a
+     * segment lying in the specified Octant.
+     *
+     * @return -1 node0 occurs first
+     * @return 0 the two nodes are equal
+     * @return 1 node1 occurs first
+     */
+    static int
+    compare(int octant, const geom::Coordinate& p0,
+            const geom::Coordinate& p1)
+    {
+        // nodes can only be equal if their coordinates are equal
+        if(p0.equals2D(p1)) {
+            return 0;
+        }
 
-		int xSign = relativeSign(p0.x, p1.x);
-		int ySign = relativeSign(p0.y, p1.y);
+        int xSign = relativeSign(p0.x, p1.x);
+        int ySign = relativeSign(p0.y, p1.y);
 
-		switch (octant) {
-			case 0: return compareValue(xSign, ySign);
-			case 1: return compareValue(ySign, xSign);
-			case 2: return compareValue(ySign, -xSign);
-			case 3: return compareValue(-xSign, ySign);
-			case 4: return compareValue(-xSign, -ySign);
-			case 5: return compareValue(-ySign, -xSign);
-			case 6: return compareValue(-ySign, xSign);
-			case 7: return compareValue(xSign, -ySign);
-		}
-		assert(0); // invalid octant value
-		return 0;
+        switch(octant) {
+        case 0:
+            return compareValue(xSign, ySign);
+        case 1:
+            return compareValue(ySign, xSign);
+        case 2:
+            return compareValue(ySign, -xSign);
+        case 3:
+            return compareValue(-xSign, ySign);
+        case 4:
+            return compareValue(-xSign, -ySign);
+        case 5:
+            return compareValue(-ySign, -xSign);
+        case 6:
+            return compareValue(-ySign, xSign);
+        case 7:
+            return compareValue(xSign, -ySign);
+        }
+        assert(0); // invalid octant value
+        return 0;
 
-	}
+    }
 
-	static int relativeSign(double x0, double x1)
-	{
-		if (x0 < x1) return -1;
-		if (x0 > x1) return 1;
-		return 0;
-	}
+    static int
+    relativeSign(double x0, double x1)
+    {
+        if(x0 < x1) {
+            return -1;
+        }
+        if(x0 > x1) {
+            return 1;
+        }
+        return 0;
+    }
 
-	static int compareValue(int compareSign0, int compareSign1)
-	{
-		if (compareSign0 < 0) return -1;
-		if (compareSign0 > 0) return 1;
-		if (compareSign1 < 0) return -1;
-		if (compareSign1 > 0) return 1;
-		return 0;
-	}
+    static int
+    compareValue(int compareSign0, int compareSign1)
+    {
+        if(compareSign0 < 0) {
+            return -1;
+        }
+        if(compareSign0 > 0) {
+            return 1;
+        }
+        if(compareSign1 < 0) {
+            return -1;
+        }
+        if(compareSign1 > 0) {
+            return 1;
+        }
+        return 0;
+    }
 
 };
 
diff --git a/include/geos/noding/SegmentSetMutualIntersector.h b/include/geos/noding/SegmentSetMutualIntersector.h
index 5668a90..3ef94f8 100644
--- a/include/geos/noding/SegmentSetMutualIntersector.h
+++ b/include/geos/noding/SegmentSetMutualIntersector.h
@@ -34,40 +34,41 @@ namespace noding { // geos::noding
  * @author Martin Davis
  * @version 1.10
  */
-class SegmentSetMutualIntersector
-{
+class SegmentSetMutualIntersector {
 public:
 
     SegmentSetMutualIntersector()
         : segInt(nullptr)
     {}
 
-	virtual ~SegmentSetMutualIntersector() {}
+    virtual
+    ~SegmentSetMutualIntersector() {}
 
-	/**
-	 * Sets the {@link SegmentIntersector} to use with this intersector.
-	 * The SegmentIntersector will either rocord or add intersection nodes
-	 * for the input segment strings.
-	 *
-	 * @param segInt the segment intersector to use
-	 */
-	void setSegmentIntersector(SegmentIntersector* si)
-	{
-		segInt = si;
-	}
+    /**
+     * Sets the {@link SegmentIntersector} to use with this intersector.
+     * The SegmentIntersector will either rocord or add intersection nodes
+     * for the input segment strings.
+     *
+     * @param segInt the segment intersector to use
+     */
+    void
+    setSegmentIntersector(SegmentIntersector* si)
+    {
+        segInt = si;
+    }
 
-	/**
-	 *
-	 * @param segStrings0 a collection of {@link SegmentString}s to node
-	 */
-	virtual void setBaseSegments(SegmentString::ConstVect* segStrings) = 0;
+    /**
+     *
+     * @param segStrings0 a collection of {@link SegmentString}s to node
+     */
+    virtual void setBaseSegments(SegmentString::ConstVect* segStrings) = 0;
 
-	/**
-	 * Computes the intersections for two collections of {@link SegmentString}s.
-	 *
-	 * @param segStrings1 a collection of {@link SegmentString}s to node
-	 */
-	virtual void process(SegmentString::ConstVect* segStrings) = 0;
+    /**
+     * Computes the intersections for two collections of {@link SegmentString}s.
+     *
+     * @param segStrings1 a collection of {@link SegmentString}s to node
+     */
+    virtual void process(SegmentString::ConstVect* segStrings) = 0;
 
 protected:
 
diff --git a/include/geos/noding/SegmentString.h b/include/geos/noding/SegmentString.h
index 750490e..4b64e72 100644
--- a/include/geos/noding/SegmentString.h
+++ b/include/geos/noding/SegmentString.h
@@ -28,9 +28,9 @@
 
 // Forward declarations
 namespace geos {
-	namespace algorithm {
-		class LineIntersector;
-	}
+namespace algorithm {
+class LineIntersector;
+}
 }
 
 namespace geos {
@@ -45,57 +45,66 @@ namespace noding { // geos.noding
  */
 class GEOS_DLL SegmentString {
 public:
-	typedef std::vector<const SegmentString*> ConstVect;
-	typedef std::vector<SegmentString *> NonConstVect;
-
-	friend std::ostream& operator<< (std::ostream& os,
-			const SegmentString& ss);
-
-	/// Construct a SegmentString.
-	//
-	/// @param newContext the context associated to this SegmentString
-	///
-	SegmentString(const void* newContext)
-		:
-		context(newContext)
-	{}
-
-	virtual ~SegmentString() {}
-
-	/**
-	 * Gets the user-defined data for this segment string.
-	 *
-	 * @return the user-defined data
-	 */
-	const void* getData() const { return context; }
-
-	/**
-	 * Sets the user-defined data for this segment string.
-	 *
-	 * @param data an Object containing user-defined data
-	 */
-	void setData(const void* data) { context=data; }
-
-
-	virtual size_t size() const=0;
-
-	virtual const geom::Coordinate& getCoordinate(size_t i) const=0;
-
-	/// \brief
-	/// Return a pointer to the CoordinateSequence associated
-	/// with this SegmentString.
-	//
-	/// Note that the CoordinateSequence is owned by this SegmentString!
-	///
-	virtual geom::CoordinateSequence* getCoordinates() const=0;
-
-	virtual bool isClosed() const=0;
-
-	virtual std::ostream& print(std::ostream& os) const;
+    typedef std::vector<const SegmentString*> ConstVect;
+    typedef std::vector<SegmentString*> NonConstVect;
+
+    friend std::ostream& operator<< (std::ostream& os,
+                                     const SegmentString& ss);
+
+    /// Construct a SegmentString.
+    //
+    /// @param newContext the context associated to this SegmentString
+    ///
+    SegmentString(const void* newContext)
+        :
+        context(newContext)
+    {}
+
+    virtual
+    ~SegmentString() {}
+
+    /**
+     * Gets the user-defined data for this segment string.
+     *
+     * @return the user-defined data
+     */
+    const void*
+    getData() const
+    {
+        return context;
+    }
+
+    /**
+     * Sets the user-defined data for this segment string.
+     *
+     * @param data an Object containing user-defined data
+     */
+    void
+    setData(const void* data)
+    {
+        context = data;
+    }
+
+
+    virtual size_t size() const = 0;
+
+    virtual const geom::Coordinate& getCoordinate(size_t i) const = 0;
+
+    /// \brief
+    /// Return a pointer to the CoordinateSequence associated
+    /// with this SegmentString.
+    //
+    /// Note that the CoordinateSequence is owned by this SegmentString!
+    ///
+    virtual geom::CoordinateSequence* getCoordinates() const = 0;
+
+    virtual bool isClosed() const = 0;
+
+    virtual std::ostream& print(std::ostream& os) const;
 
 private:
 
-	const void* context;
+    const void* context;
 
     // Declare type as noncopyable
     SegmentString(const SegmentString& other) = delete;
diff --git a/include/geos/noding/SegmentStringUtil.h b/include/geos/noding/SegmentStringUtil.h
index 0aed670..99f3297 100644
--- a/include/geos/noding/SegmentStringUtil.h
+++ b/include/geos/noding/SegmentStringUtil.h
@@ -34,38 +34,37 @@ namespace noding { // geos::noding
  * @author Martin Davis
  *
  */
-class SegmentStringUtil
-{
+class SegmentStringUtil {
 public:
-	/** \brief
-	 * Extracts all linear components from a given {@link Geometry}
-	 * to {@link SegmentString}s.
-	 *
-	 * The SegmentString data item is set to be the source Geometry.
-	 *
-	 * @param geom the geometry to extract from
-	 * @param segStr a List of SegmentStrings (output parameter).
-	 *               Ownership of elements pushed to the vector
-	 *               is transferred to caller.
-	 */
-	static void extractSegmentStrings(const geom::Geometry * g,
-					  SegmentString::ConstVect& segStr)
-	{
-		geom::LineString::ConstVect lines;
-		geom::util::LinearComponentExtracter::getLines(*g, lines);
+    /** \brief
+     * Extracts all linear components from a given {@link Geometry}
+     * to {@link SegmentString}s.
+     *
+     * The SegmentString data item is set to be the source Geometry.
+     *
+     * @param geom the geometry to extract from
+     * @param segStr a List of SegmentStrings (output parameter).
+     *               Ownership of elements pushed to the vector
+     *               is transferred to caller.
+     */
+    static void
+    extractSegmentStrings(const geom::Geometry* g,
+                          SegmentString::ConstVect& segStr)
+    {
+        geom::LineString::ConstVect lines;
+        geom::util::LinearComponentExtracter::getLines(*g, lines);
 
-		for (std::size_t i=0, n=lines.size(); i<n; i++)
-		{
-			geom::LineString* line = (geom::LineString*)(lines[i]);
+        for(std::size_t i = 0, n = lines.size(); i < n; i++) {
+            geom::LineString* line = (geom::LineString*)(lines[i]);
 
-			// we take ownership of the coordinates here
-			// TODO: check if this can be optimized by getting
-			//       the internal CS.
-			geom::CoordinateSequence* pts = line->getCoordinates();
+            // we take ownership of the coordinates here
+            // TODO: check if this can be optimized by getting
+            //       the internal CS.
+            geom::CoordinateSequence* pts = line->getCoordinates();
 
-			segStr.push_back(new NodedSegmentString(pts, g));
-		}
-	}
+            segStr.push_back(new NodedSegmentString(pts, g));
+        }
+    }
 
 };
 
diff --git a/include/geos/noding/SimpleNoder.h b/include/geos/noding/SimpleNoder.h
index cb700db..18a288f 100644
--- a/include/geos/noding/SimpleNoder.h
+++ b/include/geos/noding/SimpleNoder.h
@@ -30,9 +30,9 @@
 
 // Forward declarations
 namespace geos {
-	namespace noding {
-		//class SegmentString;
-	}
+namespace noding {
+//class SegmentString;
+}
 }
 
 namespace geos {
@@ -50,20 +50,22 @@ namespace noding { // geos.noding
  */
 class GEOS_DLL SimpleNoder: public SinglePassNoder {
 private:
-	std::vector<SegmentString*>* nodedSegStrings;
-	virtual void computeIntersects(SegmentString *e0, SegmentString *e1);
+    std::vector<SegmentString*>* nodedSegStrings;
+    virtual void computeIntersects(SegmentString* e0, SegmentString* e1);
 
 public:
-	SimpleNoder(SegmentIntersector* nSegInt=nullptr)
-		:
-		SinglePassNoder(nSegInt)
-	{}
+    SimpleNoder(SegmentIntersector* nSegInt = nullptr)
+        :
+        SinglePassNoder(nSegInt)
+    {}
 
-	void computeNodes(std::vector<SegmentString*>* inputSegmentStrings) override;
+    void computeNodes(std::vector<SegmentString*>* inputSegmentStrings) override;
 
-	std::vector<SegmentString*>* getNodedSubstrings() const override {
-		return NodedSegmentString::getNodedSubstrings(*nodedSegStrings);
-	}
+    std::vector<SegmentString*>*
+    getNodedSubstrings() const override
+    {
+        return NodedSegmentString::getNodedSubstrings(*nodedSegStrings);
+    }
 };
 
 } // namespace geos.noding
diff --git a/include/geos/noding/SinglePassNoder.h b/include/geos/noding/SinglePassNoder.h
index c18781f..5a800d5 100644
--- a/include/geos/noding/SinglePassNoder.h
+++ b/include/geos/noding/SinglePassNoder.h
@@ -25,10 +25,10 @@
 
 // Forward declarations
 namespace geos {
-	namespace noding {
-		class SegmentString;
-		class SegmentIntersector;
-	}
+namespace noding {
+class SegmentString;
+class SegmentIntersector;
+}
 }
 
 namespace geos {
@@ -51,42 +51,44 @@ class GEOS_DLL SinglePassNoder : public Noder { // implements Noder
 
 protected:
 
-	/// Externally owned
-	SegmentIntersector* segInt;
+    /// Externally owned
+    SegmentIntersector* segInt;
 
 public:
 
-	SinglePassNoder(SegmentIntersector* nSegInt=nullptr): segInt(nSegInt) {}
-
-	~SinglePassNoder() override {}
-
-	/**
-	 * Sets the SegmentIntersector to use with this noder.
-	 * A SegmentIntersector will normally add intersection nodes
-	 * to the input segment strings, but it may not - it may
-	 * simply record the presence of intersections.
-	 * However, some Noders may require that intersections be added.
-	 *
-	 * @param newSegInt
-	 */
-	virtual void setSegmentIntersector(SegmentIntersector* newSegInt) {
-	  segInt = newSegInt;
-	}
-
-	/**
-	 * Computes the noding for a collection of {@link SegmentString}s.
-	 *
-	 * @param segStrings a collection of {@link SegmentString}s to node
-	 */
-	void computeNodes(std::vector<SegmentString*>* segStrings) override =0;
-
-	/**
-	 * Returns a {@link Collection} of fully noded {@link SegmentStrings}.
-	 * The SegmentStrings have the same context as their parent.
-	 *
-	 * @return a Collection of SegmentStrings
-	 */
-	std::vector<SegmentString*>* getNodedSubstrings() const override =0;
+    SinglePassNoder(SegmentIntersector* nSegInt = nullptr): segInt(nSegInt) {}
+
+    ~SinglePassNoder() override {}
+
+    /**
+     * Sets the SegmentIntersector to use with this noder.
+     * A SegmentIntersector will normally add intersection nodes
+     * to the input segment strings, but it may not - it may
+     * simply record the presence of intersections.
+     * However, some Noders may require that intersections be added.
+     *
+     * @param newSegInt
+     */
+    virtual void
+    setSegmentIntersector(SegmentIntersector* newSegInt)
+    {
+        segInt = newSegInt;
+    }
+
+    /**
+     * Computes the noding for a collection of {@link SegmentString}s.
+     *
+     * @param segStrings a collection of {@link SegmentString}s to node
+     */
+    void computeNodes(std::vector<SegmentString*>* segStrings) override = 0;
+
+    /**
+     * Returns a {@link Collection} of fully noded {@link SegmentStrings}.
+     * The SegmentStrings have the same context as their parent.
+     *
+     * @return a Collection of SegmentStrings
+     */
+    std::vector<SegmentString*>* getNodedSubstrings() const override = 0;
 
 };
 
diff --git a/include/geos/noding/snapround/HotPixel.h b/include/geos/noding/snapround/HotPixel.h
index e4b68e0..3d1296f 100644
--- a/include/geos/noding/snapround/HotPixel.h
+++ b/include/geos/noding/snapround/HotPixel.h
@@ -33,15 +33,15 @@
 
 // Forward declarations
 namespace geos {
-	namespace geom {
-		class Envelope;
-	}
-	namespace algorithm {
-		class LineIntersector;
-	}
-	namespace noding {
-		class NodedSegmentString;
-	}
+namespace geom {
+class Envelope;
+}
+namespace algorithm {
+class LineIntersector;
+}
+namespace noding {
+class NodedSegmentString;
+}
 }
 
 namespace geos {
@@ -63,85 +63,85 @@ class GEOS_DLL HotPixel {
 
 private:
 
-	algorithm::LineIntersector& li;
-
-	geom::Coordinate pt;
-	const geom::Coordinate& originalPt;
-	geom::Coordinate ptScaled;
-
-	mutable geom::Coordinate p0Scaled;
-	mutable geom::Coordinate p1Scaled;
-
-	double scaleFactor;
-
-	double minx;
-	double maxx;
-	double miny;
-	double maxy;
-
-	/** \brief
-	 * The corners of the hot pixel
-	 *
-	 * In the order:
-	 *  1 0
-	 *  2 3
-	 */
-	std::vector<geom::Coordinate> corner;
-
-	/// Owned by this class, constructed on demand
-	mutable std::unique_ptr<geom::Envelope> safeEnv;
-
-	void initCorners(const geom::Coordinate& pt);
-
-	double scale(double val) const;
-
-	void copyScaled(const geom::Coordinate& p,
-			geom::Coordinate& pScaled) const;
-
-	/** \brief
-	 * Tests whether the segment p0-p1 intersects the hot pixel
-	 * tolerance square.
-	 *
-	 * Because the tolerance square point set is partially open (along the
-	 * top and right) the test needs to be more sophisticated than
-	 * simply checking for any intersection.  However, it
-	 * can take advantage of the fact that because the hot pixel edges
-	 * do not lie on the coordinate grid.  It is sufficient to check
-	 * if there is at least one of:
-	 *
-	 * - a proper intersection with the segment and any hot pixel edge
-	 * - an intersection between the segment and both the left
-	 *   and bottom edges
-	 * - an intersection between a segment endpoint and the hot
-	 *   pixel coordinate
-	 *
-	 * @param p0
-	 * @param p1
-	 * @return
-	 */
-	bool intersectsToleranceSquare(const geom::Coordinate& p0,
-			const geom::Coordinate& p1) const;
-
-
-	/** \brief
-	 * Test whether the given segment intersects
-	 * the closure of this hot pixel.
-	 *
-	 * This is NOT the test used in the standard snap-rounding
-	 * algorithm, which uses the partially closed tolerance square
-	 * instead.
-	 * This routine is provided for testing purposes only.
-	 *
-	 * @param p0 the start point of a line segment
-	 * @param p1 the end point of a line segment
-	 * @return <code>true</code> if the segment intersects the
-	 *         closure of the pixel's tolerance square
-	 */
-	bool intersectsPixelClosure(const geom::Coordinate& p0,
-			const geom::Coordinate& p1);
-
-	bool intersectsScaled(const geom::Coordinate& p0,
-			const geom::Coordinate& p1) const;
+    algorithm::LineIntersector& li;
+
+    geom::Coordinate pt;
+    const geom::Coordinate& originalPt;
+    geom::Coordinate ptScaled;
+
+    mutable geom::Coordinate p0Scaled;
+    mutable geom::Coordinate p1Scaled;
+
+    double scaleFactor;
+
+    double minx;
+    double maxx;
+    double miny;
+    double maxy;
+
+    /** \brief
+     * The corners of the hot pixel
+     *
+     * In the order:
+     *  1 0
+     *  2 3
+     */
+    std::vector<geom::Coordinate> corner;
+
+    /// Owned by this class, constructed on demand
+    mutable std::unique_ptr<geom::Envelope> safeEnv;
+
+    void initCorners(const geom::Coordinate& pt);
+
+    double scale(double val) const;
+
+    void copyScaled(const geom::Coordinate& p,
+                    geom::Coordinate& pScaled) const;
+
+    /** \brief
+     * Tests whether the segment p0-p1 intersects the hot pixel
+     * tolerance square.
+     *
+     * Because the tolerance square point set is partially open (along the
+     * top and right) the test needs to be more sophisticated than
+     * simply checking for any intersection.  However, it
+     * can take advantage of the fact that because the hot pixel edges
+     * do not lie on the coordinate grid.  It is sufficient to check
+     * if there is at least one of:
+     *
+     * - a proper intersection with the segment and any hot pixel edge
+     * - an intersection between the segment and both the left
+     *   and bottom edges
+     * - an intersection between a segment endpoint and the hot
+     *   pixel coordinate
+     *
+     * @param p0
+     * @param p1
+     * @return
+     */
+    bool intersectsToleranceSquare(const geom::Coordinate& p0,
+                                   const geom::Coordinate& p1) const;
+
+
+    /** \brief
+     * Test whether the given segment intersects
+     * the closure of this hot pixel.
+     *
+     * This is NOT the test used in the standard snap-rounding
+     * algorithm, which uses the partially closed tolerance square
+     * instead.
+     * This routine is provided for testing purposes only.
+     *
+     * @param p0 the start point of a line segment
+     * @param p1 the end point of a line segment
+     * @return <code>true</code> if the segment intersects the
+     *         closure of the pixel's tolerance square
+     */
+    bool intersectsPixelClosure(const geom::Coordinate& p0,
+                                const geom::Coordinate& p1);
+
+    bool intersectsScaled(const geom::Coordinate& p0,
+                          const geom::Coordinate& p1) const;
 
     // Declare type as noncopyable
     HotPixel(const HotPixel& other) = delete;
@@ -149,52 +149,56 @@ private:
 
 public:
 
-	/**
-	 * Creates a new hot pixel.
-	 *
-	 * @param pt the coordinate at the centre of the pixel.
-	 *           Will be kept by reference, so make sure to keep it alive.
-	 * @param scaleFact the scaleFactor determining the pixel size
-	 * @param li the intersector to use for testing intersection with
-	 *        line segments
-	 */
-	HotPixel(const geom::Coordinate& pt,
-			double scaleFact,
-			algorithm::LineIntersector& li);
-
-	/// \brief
-	/// Return reference to original Coordinate
-	/// (the one provided at construction time)
-	const geom::Coordinate& getCoordinate() const { return originalPt; }
-
-	/** \brief
-	 * Returns a "safe" envelope that is guaranteed to contain
-	 * the hot pixel. Keeps ownership of it.
-	 *
-	 * The envelope returned will be larger than the exact envelope of the
-	 * pixel.
-	 */
-	const geom::Envelope& getSafeEnvelope() const;
-
-	/**
-	 * Tests whether the line segment (p0-p1) intersects this hot pixel.
-	 *
-	 * @param p0 the first coordinate of the line segment to test
-	 * @param p1 the second coordinate of the line segment to test
-	 * @return true if the line segment intersects this hot pixel
-	 */
-	bool intersects(const geom::Coordinate& p0,
-			const geom::Coordinate& p1) const;
-
-	/**
-	 * Adds a new node (equal to the snap pt) to the specified segment
-	 * if the segment passes through the hot pixel
-	 *
-	 * @param segStr
-	 * @param segIndex
-	 * @return true if a node was added to the segment
-	 */
-	bool addSnappedNode(NodedSegmentString& segStr, std::size_t segIndex);
+    /**
+     * Creates a new hot pixel.
+     *
+     * @param pt the coordinate at the centre of the pixel.
+     *           Will be kept by reference, so make sure to keep it alive.
+     * @param scaleFact the scaleFactor determining the pixel size
+     * @param li the intersector to use for testing intersection with
+     *        line segments
+     */
+    HotPixel(const geom::Coordinate& pt,
+             double scaleFact,
+             algorithm::LineIntersector& li);
+
+    /// \brief
+    /// Return reference to original Coordinate
+    /// (the one provided at construction time)
+    const geom::Coordinate&
+    getCoordinate() const
+    {
+        return originalPt;
+    }
+
+    /** \brief
+     * Returns a "safe" envelope that is guaranteed to contain
+     * the hot pixel. Keeps ownership of it.
+     *
+     * The envelope returned will be larger than the exact envelope of the
+     * pixel.
+     */
+    const geom::Envelope& getSafeEnvelope() const;
+
+    /**
+     * Tests whether the line segment (p0-p1) intersects this hot pixel.
+     *
+     * @param p0 the first coordinate of the line segment to test
+     * @param p1 the second coordinate of the line segment to test
+     * @return true if the line segment intersects this hot pixel
+     */
+    bool intersects(const geom::Coordinate& p0,
+                    const geom::Coordinate& p1) const;
+
+    /**
+     * Adds a new node (equal to the snap pt) to the specified segment
+     * if the segment passes through the hot pixel
+     *
+     * @param segStr
+     * @param segIndex
+     * @return true if a node was added to the segment
+     */
+    bool addSnappedNode(NodedSegmentString& segStr, std::size_t segIndex);
 
 };
 
diff --git a/include/geos/noding/snapround/HotPixel.inl b/include/geos/noding/snapround/HotPixel.inl
index 3ff4872..5f81788 100644
--- a/include/geos/noding/snapround/HotPixel.inl
+++ b/include/geos/noding/snapround/HotPixel.inl
@@ -7,7 +7,7 @@
  *
  * This is free software; you can redistribute and/or modify it under
  * the terms of the GNU Lesser General Public Licence as published
- * by the Free Software Foundation. 
+ * by the Free Software Foundation.
  * See the COPYING file for more information.
  *
  **********************************************************************
@@ -30,16 +30,16 @@ namespace snapround { // geos::noding::snapround
 INLINE double
 HotPixel::scale(double val) const
 {
-	// Math.round
-	//return round(val*scaleFactor);
-	return util::round(val*scaleFactor);
+    // Math.round
+    //return round(val*scaleFactor);
+    return util::round(val * scaleFactor);
 }
 
 INLINE void
 HotPixel::copyScaled(const geom::Coordinate& p, geom::Coordinate& pScaled) const
 {
-	pScaled.x = scale(p.x);
-	pScaled.y = scale(p.y);
+    pScaled.x = scale(p.x);
+    pScaled.y = scale(p.y);
 }
 
 } // namespace geos::noding::snapround
diff --git a/include/geos/noding/snapround/MCIndexPointSnapper.h b/include/geos/noding/snapround/MCIndexPointSnapper.h
index 2153617..15dbc30 100644
--- a/include/geos/noding/snapround/MCIndexPointSnapper.h
+++ b/include/geos/noding/snapround/MCIndexPointSnapper.h
@@ -26,15 +26,15 @@
 
 // Forward declarations
 namespace geos {
-	namespace index {
-		class SpatialIndex;
-	}
-	namespace noding {
-		class SegmentString;
-		namespace snapround {
-			class HotPixel;
-		}
-	}
+namespace index {
+class SpatialIndex;
+}
+namespace noding {
+class SegmentString;
+namespace snapround {
+class HotPixel;
+}
+}
 }
 
 namespace geos {
@@ -51,34 +51,36 @@ class GEOS_DLL MCIndexPointSnapper {
 public:
 
 
-	MCIndexPointSnapper(index::SpatialIndex& nIndex)
-		:
-		index(nIndex)
-	{}
-
-	/**
-	 * Snaps (nodes) all interacting segments to this hot pixel.
-	 * The hot pixel may represent a vertex of an edge,
-	 * in which case this routine uses the optimization
-	 * of not noding the vertex itself
-	 *
-	 * @param hotPixel the hot pixel to snap to
-	 * @param parentEdge the edge containing the vertex,
-	 *        if applicable, or <code>null</code>
-	 * @param vertexIndex the index of the vertex, if applicable, or -1
-	 * @return <code>true</code> if a node was added for this pixel
-	 */
-	bool snap(HotPixel& hotPixel, SegmentString* parentEdge,
-			size_t vertexIndex);
-
-	bool snap(HotPixel& hotPixel) {
-		return snap(hotPixel, nullptr, 0);
-	}
+    MCIndexPointSnapper(index::SpatialIndex& nIndex)
+        :
+        index(nIndex)
+    {}
+
+    /**
+     * Snaps (nodes) all interacting segments to this hot pixel.
+     * The hot pixel may represent a vertex of an edge,
+     * in which case this routine uses the optimization
+     * of not noding the vertex itself
+     *
+     * @param hotPixel the hot pixel to snap to
+     * @param parentEdge the edge containing the vertex,
+     *        if applicable, or <code>null</code>
+     * @param vertexIndex the index of the vertex, if applicable, or -1
+     * @return <code>true</code> if a node was added for this pixel
+     */
+    bool snap(HotPixel& hotPixel, SegmentString* parentEdge,
+              size_t vertexIndex);
+
+    bool
+    snap(HotPixel& hotPixel)
+    {
+        return snap(hotPixel, nullptr, 0);
+    }
 
 
 private:
 
-	index::SpatialIndex& index;
+    index::SpatialIndex& index;
 
     // Declare type as noncopyable
     MCIndexPointSnapper(const MCIndexPointSnapper& other) = delete;
diff --git a/include/geos/noding/snapround/MCIndexSnapRounder.h b/include/geos/noding/snapround/MCIndexSnapRounder.h
index 3f9cd03..e8da0d8 100644
--- a/include/geos/noding/snapround/MCIndexSnapRounder.h
+++ b/include/geos/noding/snapround/MCIndexSnapRounder.h
@@ -37,13 +37,13 @@
 
 // Forward declarations
 namespace geos {
-	namespace algorithm {
-		class LineIntersector;
-	}
-	namespace noding {
-		class SegmentString;
-		class MCIndexNoder;
-	}
+namespace algorithm {
+class LineIntersector;
+}
+namespace noding {
+class SegmentString;
+class MCIndexNoder;
+}
 }
 
 namespace geos {
@@ -75,71 +75,73 @@ class GEOS_DLL MCIndexSnapRounder: public Noder { // implments Noder
 
 public:
 
-	MCIndexSnapRounder(const geom::PrecisionModel& nPm)
-    :
-		pm(nPm),
-		scaleFactor(nPm.getScale()),
-		pointSnapper(nullptr)
-  {
-    li.setPrecisionModel(&pm);
-  }
-
-	std::vector<SegmentString*>* getNodedSubstrings() const override {
-	  return NodedSegmentString::getNodedSubstrings(*nodedSegStrings);
-  }
-
-	void computeNodes(std::vector<SegmentString*>* segStrings) override;
-
-	/**
-	 * Computes nodes introduced as a result of
-	 * snapping segments to vertices of other segments
-	 *
-	 * @param edges the list of segment strings to snap together
-	 *        NOTE: they *must* be instances of NodedSegmentString, or
-	 * 	            an assertion will fail.
-	 */
-	void computeVertexSnaps(std::vector<SegmentString*>& edges);
+    MCIndexSnapRounder(const geom::PrecisionModel& nPm)
+        :
+        pm(nPm),
+        scaleFactor(nPm.getScale()),
+        pointSnapper(nullptr)
+    {
+        li.setPrecisionModel(&pm);
+    }
+
+    std::vector<SegmentString*>*
+    getNodedSubstrings() const override
+    {
+        return NodedSegmentString::getNodedSubstrings(*nodedSegStrings);
+    }
+
+    void computeNodes(std::vector<SegmentString*>* segStrings) override;
+
+    /**
+     * Computes nodes introduced as a result of
+     * snapping segments to vertices of other segments
+     *
+     * @param edges the list of segment strings to snap together
+     *        NOTE: they *must* be instances of NodedSegmentString, or
+     * 	            an assertion will fail.
+     */
+    void computeVertexSnaps(std::vector<SegmentString*>& edges);
 
 private:
 
-	/// externally owned
-	const geom::PrecisionModel& pm;
+    /// externally owned
+    const geom::PrecisionModel& pm;
 
-	algorithm::LineIntersector li;
+    algorithm::LineIntersector li;
 
-	double scaleFactor;
+    double scaleFactor;
 
-	std::vector<SegmentString*>* nodedSegStrings;
+    std::vector<SegmentString*>* nodedSegStrings;
 
-	std::unique_ptr<MCIndexPointSnapper> pointSnapper;
+    std::unique_ptr<MCIndexPointSnapper> pointSnapper;
 
-	void snapRound(MCIndexNoder& noder, std::vector<SegmentString*>* segStrings);
+    void snapRound(MCIndexNoder& noder, std::vector<SegmentString*>* segStrings);
 
 
-	/**
-	 * Computes all interior intersections in the collection of SegmentStrings,
-	 * and push their Coordinate to the provided vector.
-	 *
-	 * Does NOT node the segStrings.
-	 *
-	 */
-	void findInteriorIntersections(MCIndexNoder& noder,
-			std::vector<SegmentString*>* segStrings,
-			std::vector<geom::Coordinate>& intersections);
+    /**
+     * Computes all interior intersections in the collection of SegmentStrings,
+     * and push their Coordinate to the provided vector.
+     *
+     * Does NOT node the segStrings.
+     *
+     */
+    void findInteriorIntersections(MCIndexNoder& noder,
+                                   std::vector<SegmentString*>* segStrings,
+                                   std::vector<geom::Coordinate>& intersections);
 
-	/**
-	 * Computes nodes introduced as a result of snapping
-	 * segments to snap points (hot pixels)
-	 */
-	void computeIntersectionSnaps(std::vector<geom::Coordinate>& snapPts);
+    /**
+     * Computes nodes introduced as a result of snapping
+     * segments to snap points (hot pixels)
+     */
+    void computeIntersectionSnaps(std::vector<geom::Coordinate>& snapPts);
 
-	/**
-	 * Performs a brute-force comparison of every segment in each {@link SegmentString}.
-	 * This has n^2 performance.
-	 */
-	void computeVertexSnaps(NodedSegmentString* e);
+    /**
+     * Performs a brute-force comparison of every segment in each {@link SegmentString}.
+     * This has n^2 performance.
+     */
+    void computeVertexSnaps(NodedSegmentString* e);
 
-	void checkCorrectness(std::vector<SegmentString*>& inputSegmentStrings);
+    void checkCorrectness(std::vector<SegmentString*>& inputSegmentStrings);
 
     // Declare type as noncopyable
     MCIndexSnapRounder(const MCIndexSnapRounder& other) = delete;
diff --git a/include/geos/noding/snapround/SimpleSnapRounder.h b/include/geos/noding/snapround/SimpleSnapRounder.h
index e145e84..121082b 100644
--- a/include/geos/noding/snapround/SimpleSnapRounder.h
+++ b/include/geos/noding/snapround/SimpleSnapRounder.h
@@ -32,19 +32,19 @@
 
 // Forward declarations
 namespace geos {
-	namespace geom {
-		//class PrecisionModel;
-	}
-	namespace algorithm {
-		class LineIntersector;
-	}
-	namespace noding {
-		class SegmentString;
-		class NodedSegmentString;
-		namespace snapround {
-			class HotPixel;
-		}
-	}
+namespace geom {
+//class PrecisionModel;
+}
+namespace algorithm {
+class LineIntersector;
+}
+namespace noding {
+class SegmentString;
+class NodedSegmentString;
+namespace snapround {
+class HotPixel;
+}
+}
 }
 
 namespace geos {
@@ -74,65 +74,65 @@ class GEOS_DLL SimpleSnapRounder: public Noder { // implements NoderIface
 
 public:
 
-	SimpleSnapRounder(const geom::PrecisionModel& newPm);
+    SimpleSnapRounder(const geom::PrecisionModel& newPm);
 
-	std::vector<SegmentString*>* getNodedSubstrings() const override;
+    std::vector<SegmentString*>* getNodedSubstrings() const override;
 
-	void computeNodes(std::vector<SegmentString*>* inputSegmentStrings) override;
+    void computeNodes(std::vector<SegmentString*>* inputSegmentStrings) override;
 
-	void add(const SegmentString* segStr);
+    void add(const SegmentString* segStr);
 
-	/**
-	 * Computes nodes introduced as a result of
-	 * snapping segments to vertices of other segments
-	 *
-	 * @param edges the list of segment strings to snap together.
-	 *        Must be NodedSegmentString or an assertion will fail.
-	 */
-	void computeVertexSnaps(const std::vector<SegmentString*>& edges);
+    /**
+     * Computes nodes introduced as a result of
+     * snapping segments to vertices of other segments
+     *
+     * @param edges the list of segment strings to snap together.
+     *        Must be NodedSegmentString or an assertion will fail.
+     */
+    void computeVertexSnaps(const std::vector<SegmentString*>& edges);
 
 private:
 
-	const geom::PrecisionModel& pm;
-	algorithm::LineIntersector li;
-	double scaleFactor;
-	std::vector<SegmentString*>* nodedSegStrings;
-
-	void checkCorrectness(std::vector<SegmentString*>& inputSegmentStrings);
-
-	void snapRound(std::vector<SegmentString*>* segStrings,
-			algorithm::LineIntersector& li);
-
-	/**
-	 * Computes all interior intersections in the vector
-	 * of SegmentString, and fill the given vector
-	 * with their Coordinates.
-	 *
-	 * Does NOT node the segStrings.
-	 *
-	 * @param segStrings a vector of const Coordinates for the intersections
-	 * @param li the algorithm::LineIntersector to use
-	 * @param ret the vector to push intersection Coordinates to
-	 */
-	void findInteriorIntersections(std::vector<SegmentString*>& segStrings,
-			algorithm::LineIntersector& li, std::vector<geom::Coordinate>& ret);
-
-	/** \brief
-	 * Computes nodes introduced as a result of snapping segments to
-	 * snap points (hot pixels)
-	 * @param li
-	 */
-	void computeSnaps(const std::vector<SegmentString*>& segStrings,
-		std::vector<geom::Coordinate>& snapPts);
-
-	void computeSnaps(NodedSegmentString* ss, std::vector<geom::Coordinate>& snapPts);
-
-	/** \brief
-	 * Performs a brute-force comparison of every segment in each
-	 * {@link SegmentString}.
-	 * This has n^2 performance.
-	 */
-	void computeVertexSnaps(NodedSegmentString* e0, NodedSegmentString* e1);
+    const geom::PrecisionModel& pm;
+    algorithm::LineIntersector li;
+    double scaleFactor;
+    std::vector<SegmentString*>* nodedSegStrings;
+
+    void checkCorrectness(std::vector<SegmentString*>& inputSegmentStrings);
+
+    void snapRound(std::vector<SegmentString*>* segStrings,
+                   algorithm::LineIntersector& li);
+
+    /**
+     * Computes all interior intersections in the vector
+     * of SegmentString, and fill the given vector
+     * with their Coordinates.
+     *
+     * Does NOT node the segStrings.
+     *
+     * @param segStrings a vector of const Coordinates for the intersections
+     * @param li the algorithm::LineIntersector to use
+     * @param ret the vector to push intersection Coordinates to
+     */
+    void findInteriorIntersections(std::vector<SegmentString*>& segStrings,
+                                   algorithm::LineIntersector& li, std::vector<geom::Coordinate>& ret);
+
+    /** \brief
+     * Computes nodes introduced as a result of snapping segments to
+     * snap points (hot pixels)
+     * @param li
+     */
+    void computeSnaps(const std::vector<SegmentString*>& segStrings,
+                      std::vector<geom::Coordinate>& snapPts);
+
+    void computeSnaps(NodedSegmentString* ss, std::vector<geom::Coordinate>& snapPts);
+
+    /** \brief
+     * Performs a brute-force comparison of every segment in each
+     * {@link SegmentString}.
+     * This has n^2 performance.
+     */
+    void computeVertexSnaps(NodedSegmentString* e0, NodedSegmentString* e1);
 
     // Declare type as noncopyable
     SimpleSnapRounder(const SimpleSnapRounder& other) = delete;
diff --git a/include/geos/operation/GeometryGraphOperation.h b/include/geos/operation/GeometryGraphOperation.h
index fdc49e4..3ffd79e 100644
--- a/include/geos/operation/GeometryGraphOperation.h
+++ b/include/geos/operation/GeometryGraphOperation.h
@@ -32,16 +32,16 @@
 
 // Forward declarations
 namespace geos {
-	namespace algorithm {
-		class BoundaryNodeRule;
-	}
-	namespace geom {
-		class Geometry;
-		class PrecisionModel;
-	}
-	namespace geomgraph {
-		class GeometryGraph;
-	}
+namespace algorithm {
+class BoundaryNodeRule;
+}
+namespace geom {
+class Geometry;
+class PrecisionModel;
+}
+namespace geomgraph {
+class GeometryGraph;
+}
 }
 
 
@@ -53,31 +53,31 @@ class GEOS_DLL GeometryGraphOperation {
 
 public:
 
-	GeometryGraphOperation(const geom::Geometry *g0,
-			const geom::Geometry *g1);
+    GeometryGraphOperation(const geom::Geometry* g0,
+                           const geom::Geometry* g1);
 
-	GeometryGraphOperation(const geom::Geometry *g0,
-		const geom::Geometry *g1,
-		const algorithm::BoundaryNodeRule& boundaryNodeRule);
+    GeometryGraphOperation(const geom::Geometry* g0,
+                           const geom::Geometry* g1,
+                           const algorithm::BoundaryNodeRule& boundaryNodeRule);
 
-	GeometryGraphOperation(const geom::Geometry *g0);
+    GeometryGraphOperation(const geom::Geometry* g0);
 
-	virtual ~GeometryGraphOperation();
+    virtual ~GeometryGraphOperation();
 
-	const geom::Geometry* getArgGeometry(unsigned int i) const;
+    const geom::Geometry* getArgGeometry(unsigned int i) const;
 
 protected:
 
-	algorithm::LineIntersector li;
+    algorithm::LineIntersector li;
 
-	const geom::PrecisionModel* resultPrecisionModel;
+    const geom::PrecisionModel* resultPrecisionModel;
 
-	/** \brief
-	 * The operation args into an array so they can be accessed by index
-	 */
-	std::vector<geomgraph::GeometryGraph*> arg;
+    /** \brief
+     * The operation args into an array so they can be accessed by index
+     */
+    std::vector<geomgraph::GeometryGraph*> arg;
 
-	void setComputationPrecision(const geom::PrecisionModel* pm);
+    void setComputationPrecision(const geom::PrecisionModel* pm);
 };
 
 } // namespace geos.operation
diff --git a/include/geos/operation/IsSimpleOp.h b/include/geos/operation/IsSimpleOp.h
index ccc2bca..0af00d7 100644
--- a/include/geos/operation/IsSimpleOp.h
+++ b/include/geos/operation/IsSimpleOp.h
@@ -34,25 +34,25 @@
 
 // Forward declarations
 namespace geos {
-	namespace algorithm {
-		class BoundaryNodeRule;
-	}
-	namespace geom {
-		class LineString;
-		class LinearRing;
-		class MultiLineString;
-		class MultiPoint;
-		class Geometry;
-		class Polygon;
-		class GeometryCollection;
-		struct CoordinateLessThen;
-	}
-	namespace geomgraph {
-		class GeometryGraph;
-	}
-	namespace operation {
-		class EndpointInfo;
-	}
+namespace algorithm {
+class BoundaryNodeRule;
+}
+namespace geom {
+class LineString;
+class LinearRing;
+class MultiLineString;
+class MultiPoint;
+class Geometry;
+class Polygon;
+class GeometryCollection;
+struct CoordinateLessThen;
+}
+namespace geomgraph {
+class GeometryGraph;
+}
+namespace operation {
+class EndpointInfo;
+}
 }
 
 
@@ -93,127 +93,127 @@ namespace operation { // geos.operation
  * @see algorithm::BoundaryNodeRule
  *
  */
-class GEOS_DLL IsSimpleOp
-{
+class GEOS_DLL IsSimpleOp {
 
 public:
 
-	/** \brief
-	 * Creates a simplicity checker using the default
-	 * SFS Mod-2 Boundary Node Rule
-	 *
-	 * @deprecated use IsSimpleOp(Geometry)
-	 */
-	IsSimpleOp();
-
-	/** \brief
-	 * Creates a simplicity checker using the default
-	 * SFS Mod-2 Boundary Node Rule
-	 *
-	 * @param geom The geometry to test.
-	 *             Will store a reference: keep it alive.
-	 */
-	IsSimpleOp(const geom::Geometry& geom);
-
-	/** \brief
-	 * Creates a simplicity checker using a given
-	 * algorithm::BoundaryNodeRule
-	 *
-	 * @param geom the geometry to test
-	 * @param boundaryNodeRule the rule to use.
-	 */
-	IsSimpleOp(const geom::Geometry& geom,
-		   const algorithm::BoundaryNodeRule& boundaryNodeRule);
-
-	/**
-	 * Tests whether the geometry is simple.
-	 *
-	 * @return true if the geometry is simple
-	 */
-	bool isSimple();
-
-	/**
-	 * Gets a coordinate for the location where the geometry
-	 * fails to be simple.
-	 * (i.e. where it has a non-boundary self-intersection).
-	 * {@link #isSimple} must be called before this method is called.
-	 *
-	 * @return a coordinate for the location of the non-boundary
-	 *           self-intersection. Ownership retained.
-	 * @return the null coordinate if the geometry is simple
-	 */
-	const geom::Coordinate* getNonSimpleLocation() const
-	{
-		return nonSimpleLocation.get();
-	}
-
-	/**
-	 * Reports whether a geom::LineString is simple.
-	 *
-	 * @param geom the lineal geometry to test
-	 * @return true if the geometry is simple
-	 *
-	 * @deprecated use isSimple()
-	 */
-	bool isSimple(const geom::LineString *geom);
-
-	/**
-	 * Reports whether a geom::MultiLineString is simple.
-	 *
-	 * @param geom the lineal geometry to test
-	 * @return true if the geometry is simple
-	 *
-	 * @deprecated use isSimple()
-	 */
-	bool isSimple(const geom::MultiLineString *geom);
-
-	/**
-	 * A MultiPoint is simple iff it has no repeated points
-	 *
-	 * @deprecated use isSimple()
-	 */
-	bool isSimple(const geom::MultiPoint *mp);
-
-	bool isSimpleLinearGeometry(const geom::Geometry *geom);
+    /** \brief
+     * Creates a simplicity checker using the default
+     * SFS Mod-2 Boundary Node Rule
+     *
+     * @deprecated use IsSimpleOp(Geometry)
+     */
+    IsSimpleOp();
+
+    /** \brief
+     * Creates a simplicity checker using the default
+     * SFS Mod-2 Boundary Node Rule
+     *
+     * @param geom The geometry to test.
+     *             Will store a reference: keep it alive.
+     */
+    IsSimpleOp(const geom::Geometry& geom);
+
+    /** \brief
+     * Creates a simplicity checker using a given
+     * algorithm::BoundaryNodeRule
+     *
+     * @param geom the geometry to test
+     * @param boundaryNodeRule the rule to use.
+     */
+    IsSimpleOp(const geom::Geometry& geom,
+               const algorithm::BoundaryNodeRule& boundaryNodeRule);
+
+    /**
+     * Tests whether the geometry is simple.
+     *
+     * @return true if the geometry is simple
+     */
+    bool isSimple();
+
+    /**
+     * Gets a coordinate for the location where the geometry
+     * fails to be simple.
+     * (i.e. where it has a non-boundary self-intersection).
+     * {@link #isSimple} must be called before this method is called.
+     *
+     * @return a coordinate for the location of the non-boundary
+     *           self-intersection. Ownership retained.
+     * @return the null coordinate if the geometry is simple
+     */
+    const geom::Coordinate*
+    getNonSimpleLocation() const
+    {
+        return nonSimpleLocation.get();
+    }
+
+    /**
+     * Reports whether a geom::LineString is simple.
+     *
+     * @param geom the lineal geometry to test
+     * @return true if the geometry is simple
+     *
+     * @deprecated use isSimple()
+     */
+    bool isSimple(const geom::LineString* geom);
+
+    /**
+     * Reports whether a geom::MultiLineString is simple.
+     *
+     * @param geom the lineal geometry to test
+     * @return true if the geometry is simple
+     *
+     * @deprecated use isSimple()
+     */
+    bool isSimple(const geom::MultiLineString* geom);
+
+    /**
+     * A MultiPoint is simple iff it has no repeated points
+     *
+     * @deprecated use isSimple()
+     */
+    bool isSimple(const geom::MultiPoint* mp);
+
+    bool isSimpleLinearGeometry(const geom::Geometry* geom);
 
 private:
 
-	/**
-	 * For all edges, check if there are any intersections which are
-	 * NOT at an endpoint.
-	 * The Geometry is not simple if there are intersections not at
-	 * endpoints.
-	 */
-	bool hasNonEndpointIntersection(geomgraph::GeometryGraph &graph);
-
-	/**
-	 * Tests that no edge intersection is the endpoint of a closed line.
-	 * This ensures that closed lines are not touched at their endpoint,
-	 * which is an interior point according to the Mod-2 rule
-	 * To check this we compute the degree of each endpoint.
-	 * The degree of endpoints of closed lines
-	 * must be exactly 2.
-	 */
-	bool hasClosedEndpointIntersection(geomgraph::GeometryGraph &graph);
-
-	bool computeSimple(const geom::Geometry *geom);
-  bool isSimplePolygonal(const geom::Geometry *geom);
-	bool isSimpleGeometryCollection(const geom::GeometryCollection *col);
-
-	/**
-	 * Add an endpoint to the map, creating an entry for it if none exists
-	 */
-	void addEndpoint(std::map<const geom::Coordinate*, EndpointInfo*,
-			geom::CoordinateLessThen>&endPoints,
-			const geom::Coordinate *p, bool isClosed);
-
-	bool isClosedEndpointsInInterior;
-
-	bool isSimpleMultiPoint(const geom::MultiPoint& mp);
-
-	const geom::Geometry* geom;
-
-	std::unique_ptr<geom::Coordinate> nonSimpleLocation;
+    /**
+     * For all edges, check if there are any intersections which are
+     * NOT at an endpoint.
+     * The Geometry is not simple if there are intersections not at
+     * endpoints.
+     */
+    bool hasNonEndpointIntersection(geomgraph::GeometryGraph& graph);
+
+    /**
+     * Tests that no edge intersection is the endpoint of a closed line.
+     * This ensures that closed lines are not touched at their endpoint,
+     * which is an interior point according to the Mod-2 rule
+     * To check this we compute the degree of each endpoint.
+     * The degree of endpoints of closed lines
+     * must be exactly 2.
+     */
+    bool hasClosedEndpointIntersection(geomgraph::GeometryGraph& graph);
+
+    bool computeSimple(const geom::Geometry* geom);
+    bool isSimplePolygonal(const geom::Geometry* geom);
+    bool isSimpleGeometryCollection(const geom::GeometryCollection* col);
+
+    /**
+     * Add an endpoint to the map, creating an entry for it if none exists
+     */
+    void addEndpoint(std::map<const geom::Coordinate*, EndpointInfo*,
+                     geom::CoordinateLessThen>& endPoints,
+                     const geom::Coordinate* p, bool isClosed);
+
+    bool isClosedEndpointsInInterior;
+
+    bool isSimpleMultiPoint(const geom::MultiPoint& mp);
+
+    const geom::Geometry* geom;
+
+    std::unique_ptr<geom::Coordinate> nonSimpleLocation;
 };
 
 } // namespace geos.operation
diff --git a/include/geos/operation/buffer/BufferBuilder.h b/include/geos/operation/buffer/BufferBuilder.h
index 2f9480d..43e3433 100644
--- a/include/geos/operation/buffer/BufferBuilder.h
+++ b/include/geos/operation/buffer/BufferBuilder.h
@@ -36,32 +36,32 @@
 
 // Forward declarations
 namespace geos {
-	namespace geom {
-		class PrecisionModel;
-		class Geometry;
-		class GeometryFactory;
-	}
-	namespace algorithm {
-		class LineIntersector;
-	}
-	namespace noding {
-		class Noder;
-		class SegmentString;
-		class IntersectionAdder;
-	}
-	namespace geomgraph {
-		class Edge;
-		class Label;
-		class PlanarGraph;
-	}
-	namespace operation {
-		namespace buffer {
-			class BufferSubgraph;
-		}
-		namespace overlay {
-			class PolygonBuilder;
-		}
-	}
+namespace geom {
+class PrecisionModel;
+class Geometry;
+class GeometryFactory;
+}
+namespace algorithm {
+class LineIntersector;
+}
+namespace noding {
+class Noder;
+class SegmentString;
+class IntersectionAdder;
+}
+namespace geomgraph {
+class Edge;
+class Label;
+class PlanarGraph;
+}
+namespace operation {
+namespace buffer {
+class BufferSubgraph;
+}
+namespace overlay {
+class PolygonBuilder;
+}
+}
 }
 
 namespace geos {
@@ -88,59 +88,65 @@ namespace buffer { // geos.operation.buffer
 class GEOS_DLL BufferBuilder {
 
 public:
-	/**
-	 * Creates a new BufferBuilder
-	 *
-	 * @param nBufParams buffer parameters, this object will
-	 *                   keep a reference to the passed parameters
-	 *                   so caller must make sure the object is
-	 *                   kept alive for the whole lifetime of
-	 *                   the buffer builder.
-	 */
-	BufferBuilder(const BufferParameters& nBufParams)
-		:
-		bufParams(nBufParams),
-		workingPrecisionModel(nullptr),
-		li(nullptr),
-		intersectionAdder(nullptr),
-		workingNoder(nullptr),
-		geomFact(nullptr),
-		edgeList()
-	{}
-
-	~BufferBuilder();
-
-
-	/**
-	 * Sets the precision model to use during the curve computation
-	 * and noding,
-	 * if it is different to the precision model of the Geometry.
-	 * If the precision model is less than the precision of the
-	 * Geometry precision model,
-	 * the Geometry must have previously been rounded to that precision.
-	 *
-	 * @param pm the precision model to use
-	 */
-	void setWorkingPrecisionModel(const geom::PrecisionModel *pm) {
-		workingPrecisionModel=pm;
-	}
-
-	/**
-	 * Sets the {@link noding::Noder} to use during noding.
-	 * This allows choosing fast but non-robust noding, or slower
-	 * but robust noding.
-	 *
-	 * @param noder the noder to use
-	 */
-	void setNoder(noding::Noder* newNoder) { workingNoder = newNoder; }
-
-	geom::Geometry* buffer(const geom::Geometry *g, double distance);
-		// throw (GEOSException);
-
-	/**
+    /**
+     * Creates a new BufferBuilder
+     *
+     * @param nBufParams buffer parameters, this object will
+     *                   keep a reference to the passed parameters
+     *                   so caller must make sure the object is
+     *                   kept alive for the whole lifetime of
+     *                   the buffer builder.
+     */
+    BufferBuilder(const BufferParameters& nBufParams)
+        :
+        bufParams(nBufParams),
+        workingPrecisionModel(nullptr),
+        li(nullptr),
+        intersectionAdder(nullptr),
+        workingNoder(nullptr),
+        geomFact(nullptr),
+        edgeList()
+    {}
+
+    ~BufferBuilder();
+
+
+    /**
+     * Sets the precision model to use during the curve computation
+     * and noding,
+     * if it is different to the precision model of the Geometry.
+     * If the precision model is less than the precision of the
+     * Geometry precision model,
+     * the Geometry must have previously been rounded to that precision.
+     *
+     * @param pm the precision model to use
+     */
+    void
+    setWorkingPrecisionModel(const geom::PrecisionModel* pm)
+    {
+        workingPrecisionModel = pm;
+    }
+
+    /**
+     * Sets the {@link noding::Noder} to use during noding.
+     * This allows choosing fast but non-robust noding, or slower
+     * but robust noding.
+     *
+     * @param noder the noder to use
+     */
+    void
+    setNoder(noding::Noder* newNoder)
+    {
+        workingNoder = newNoder;
+    }
+
+    geom::Geometry* buffer(const geom::Geometry* g, double distance);
+    // throw (GEOSException);
+
+    /**
      * Generates offset curve for linear geometry.
      *
-	 * @param g non-areal geometry object
+     * @param g non-areal geometry object
      * @param distance width of offset
      * @param leftSide controls on which side of the input geometry
      *        offset curve is generated.
@@ -154,84 +160,84 @@ public:
      *       areal geometries only, is ignored by this routine.
      *
      * @note Not in JTS: this is a GEOS extension
-	 */
-	geom::Geometry* bufferLineSingleSided( const geom::Geometry* g,
-	                                double distance, bool leftSide ) ;
-		// throw (GEOSException);
+     */
+    geom::Geometry* bufferLineSingleSided(const geom::Geometry* g,
+                                          double distance, bool leftSide) ;
+    // throw (GEOSException);
 
 private:
 
-	/**
-	 * Compute the change in depth as an edge is crossed from R to L
-	 */
-	static int depthDelta(const geomgraph::Label& label);
-
-	const BufferParameters& bufParams;
-
-	const geom::PrecisionModel* workingPrecisionModel;
-
-	algorithm::LineIntersector* li;
-
-	noding::IntersectionAdder* intersectionAdder;
-
-	noding::Noder* workingNoder;
-
-	const geom::GeometryFactory* geomFact;
-
-	geomgraph::EdgeList edgeList;
-
-	std::vector<geomgraph::Label *> newLabels;
-
-	void computeNodedEdges(std::vector<noding::SegmentString*>& bufSegStr,
-			const geom::PrecisionModel *precisionModel);
-			// throw(GEOSException);
-
-	/**
-	 * Inserted edges are checked to see if an identical edge already
-	 * exists.
-	 * If so, the edge is not inserted, but its label is merged
-	 * with the existing edge.
-	 *
-	 * The function takes responsability of releasing the Edge parameter
-	 * memory when appropriate.
-	 */
-	void insertUniqueEdge(geomgraph::Edge *e);
-
-	void createSubgraphs(geomgraph::PlanarGraph *graph,
-			std::vector<BufferSubgraph*>& list);
-
-	/**
-	 * Completes the building of the input subgraphs by
-	 * depth-labelling them,
-	 * and adds them to the PolygonBuilder.
-	 * The subgraph list must be sorted in rightmost-coordinate order.
-	 *
-	 * @param subgraphList the subgraphs to build
-	 * @param polyBuilder the PolygonBuilder which will build
-	 *        the final polygons
-	 */
-	void buildSubgraphs(const std::vector<BufferSubgraph*>& subgraphList,
-			overlay::PolygonBuilder& polyBuilder);
-
-	/// \brief
-	/// Return the externally-set noding::Noder OR a newly created
-	/// one using the given precisionModel.
-	//
-	/// NOTE: if an externally-set noding::Noder is available no
-	/// check is performed to ensure it will use the
-	/// given PrecisionModel
-	///
-	noding::Noder* getNoder(const geom::PrecisionModel* precisionModel);
-
-
-	/**
-	 * Gets the standard result for an empty buffer.
-	 * Since buffer always returns a polygonal result,
-	 * this is chosen to be an empty polygon.
-	 *
-	 * @return the empty result geometry, transferring ownership to caller.
-	 */
-	geom::Geometry* createEmptyResultGeometry() const;
+    /**
+     * Compute the change in depth as an edge is crossed from R to L
+     */
+    static int depthDelta(const geomgraph::Label& label);
+
+    const BufferParameters& bufParams;
+
+    const geom::PrecisionModel* workingPrecisionModel;
+
+    algorithm::LineIntersector* li;
+
+    noding::IntersectionAdder* intersectionAdder;
+
+    noding::Noder* workingNoder;
+
+    const geom::GeometryFactory* geomFact;
+
+    geomgraph::EdgeList edgeList;
+
+    std::vector<geomgraph::Label*> newLabels;
+
+    void computeNodedEdges(std::vector<noding::SegmentString*>& bufSegStr,
+                           const geom::PrecisionModel* precisionModel);
+    // throw(GEOSException);
+
+    /**
+     * Inserted edges are checked to see if an identical edge already
+     * exists.
+     * If so, the edge is not inserted, but its label is merged
+     * with the existing edge.
+     *
+     * The function takes responsability of releasing the Edge parameter
+     * memory when appropriate.
+     */
+    void insertUniqueEdge(geomgraph::Edge* e);
+
+    void createSubgraphs(geomgraph::PlanarGraph* graph,
+                         std::vector<BufferSubgraph*>& list);
+
+    /**
+     * Completes the building of the input subgraphs by
+     * depth-labelling them,
+     * and adds them to the PolygonBuilder.
+     * The subgraph list must be sorted in rightmost-coordinate order.
+     *
+     * @param subgraphList the subgraphs to build
+     * @param polyBuilder the PolygonBuilder which will build
+     *        the final polygons
+     */
+    void buildSubgraphs(const std::vector<BufferSubgraph*>& subgraphList,
+                        overlay::PolygonBuilder& polyBuilder);
+
+    /// \brief
+    /// Return the externally-set noding::Noder OR a newly created
+    /// one using the given precisionModel.
+    //
+    /// NOTE: if an externally-set noding::Noder is available no
+    /// check is performed to ensure it will use the
+    /// given PrecisionModel
+    ///
+    noding::Noder* getNoder(const geom::PrecisionModel* precisionModel);
+
+
+    /**
+     * Gets the standard result for an empty buffer.
+     * Since buffer always returns a polygonal result,
+     * this is chosen to be an empty polygon.
+     *
+     * @return the empty result geometry, transferring ownership to caller.
+     */
+    geom::Geometry* createEmptyResultGeometry() const;
 
     // Declare type as noncopyable
     BufferBuilder(const BufferBuilder& other) = delete;
diff --git a/include/geos/operation/buffer/BufferInputLineSimplifier.h b/include/geos/operation/buffer/BufferInputLineSimplifier.h
index 89d128d..7d5f7d4 100644
--- a/include/geos/operation/buffer/BufferInputLineSimplifier.h
+++ b/include/geos/operation/buffer/BufferInputLineSimplifier.h
@@ -27,10 +27,10 @@
 
 // Forward declarations
 namespace geos {
-	namespace geom {
-		class CoordinateSequence;
-		//class PrecisionModel;
-	}
+namespace geom {
+class CoordinateSequence;
+//class PrecisionModel;
+}
 }
 
 namespace geos {
@@ -69,106 +69,105 @@ namespace buffer { // geos.operation.buffer
  * @author Martin Davis
  *
  */
-class BufferInputLineSimplifier
-{
+class BufferInputLineSimplifier {
 
 public:
 
-	/**
-	 * Simplify the input coordinate list.
-	 *
-	 * If the distance tolerance is positive,
-	 * concavities on the LEFT side of the line are simplified.
-	 * If the supplied distance tolerance is negative,
-	 * concavities on the RIGHT side of the line are simplified.
-	 *
-	 * @param inputLine the coordinate sequence to simplify
-	 * @param distanceTol simplification distance tolerance to use
-	 * @return a simplified version of the coordinate sequence
-	 */
-	static std::unique_ptr<geom::CoordinateSequence> simplify(
-		const geom::CoordinateSequence& inputLine, double distanceTol);
-
-	BufferInputLineSimplifier(const geom::CoordinateSequence& input);
-
-	/**
-	 * Simplify the input coordinate list.
-	 * If the distance tolerance is positive,
-	 * concavities on the LEFT side of the line are simplified.
-	 * If the supplied distance tolerance is negative,
-	 * concavities on the RIGHT side of the line are simplified.
-	 *
-	 * @param distanceTol simplification distance tolerance to use
-	 * @return the simplified coordinate list
-	 */
-	std::unique_ptr<geom::CoordinateSequence> simplify(double distanceTol);
+    /**
+     * Simplify the input coordinate list.
+     *
+     * If the distance tolerance is positive,
+     * concavities on the LEFT side of the line are simplified.
+     * If the supplied distance tolerance is negative,
+     * concavities on the RIGHT side of the line are simplified.
+     *
+     * @param inputLine the coordinate sequence to simplify
+     * @param distanceTol simplification distance tolerance to use
+     * @return a simplified version of the coordinate sequence
+     */
+    static std::unique_ptr<geom::CoordinateSequence> simplify(
+        const geom::CoordinateSequence& inputLine, double distanceTol);
+
+    BufferInputLineSimplifier(const geom::CoordinateSequence& input);
+
+    /**
+     * Simplify the input coordinate list.
+     * If the distance tolerance is positive,
+     * concavities on the LEFT side of the line are simplified.
+     * If the supplied distance tolerance is negative,
+     * concavities on the RIGHT side of the line are simplified.
+     *
+     * @param distanceTol simplification distance tolerance to use
+     * @return the simplified coordinate list
+     */
+    std::unique_ptr<geom::CoordinateSequence> simplify(double distanceTol);
 
 private:
 
-	/**
-	 * Uses a sliding window containing 3 vertices to detect shallow angles
-	 * in which the middle vertex can be deleted, since it does not
-	 * affect the shape of the resulting buffer in a significant way.
-	 * @return
-	 */
-	bool deleteShallowConcavities();
-
-	/**
-	 * Finds the next non-deleted index,
-	 * or the end of the point array if none
-	 *
-	 * @param index
-	 * @return the next non-deleted index, if any
-	 * @return inputLine.size() if there are no more non-deleted indices
-	 */
-	size_t findNextNonDeletedIndex(size_t index) const;
-
-	std::unique_ptr<geom::CoordinateSequence> collapseLine() const;
-
-	bool isDeletable(size_t i0, size_t i1, size_t i2, double distanceTol) const;
-
-	bool isShallowConcavity(const geom::Coordinate& p0,
-	                        const geom::Coordinate& p1,
-	                        const geom::Coordinate& p2,
-	                        double distanceTol) const;
-
-	/**
-	 * Checks for shallowness over a sample of points in the given section.
-	 *
-	 * This helps prevents the siplification from incrementally
-	 * "skipping" over points which are in fact non-shallow.
-	 *
-	 * @param p0 start coordinate of section
-	 * @param p2 end coordinate of section
-	 * @param i0 start index of section
-	 * @param i2 end index of section
-	 * @param distanceTol distance tolerance
-	 * @return
-	 */
-	bool isShallowSampled(const geom::Coordinate& p0,
-	                      const geom::Coordinate& p2,
-	                      size_t i0, size_t i2, double distanceTol) const;
-
-	bool isShallow(const geom::Coordinate& p0,
-	               const geom::Coordinate& p1,
-	               const geom::Coordinate& p2,
-	               double distanceTol) const;
-
-	bool isConcave(const geom::Coordinate& p0,
-	               const geom::Coordinate& p1,
-	               const geom::Coordinate& p2) const;
-
-	static const int NUM_PTS_TO_CHECK = 10;
-
-	static const int INIT = 0;
-	static const int DELETE = 1;
-	static const int KEEP = 1;
-
-	const geom::CoordinateSequence& inputLine;
-	double distanceTol;
-	std::vector<int> isDeleted;
-
-	int angleOrientation;
+    /**
+     * Uses a sliding window containing 3 vertices to detect shallow angles
+     * in which the middle vertex can be deleted, since it does not
+     * affect the shape of the resulting buffer in a significant way.
+     * @return
+     */
+    bool deleteShallowConcavities();
+
+    /**
+     * Finds the next non-deleted index,
+     * or the end of the point array if none
+     *
+     * @param index
+     * @return the next non-deleted index, if any
+     * @return inputLine.size() if there are no more non-deleted indices
+     */
+    size_t findNextNonDeletedIndex(size_t index) const;
+
+    std::unique_ptr<geom::CoordinateSequence> collapseLine() const;
+
+    bool isDeletable(size_t i0, size_t i1, size_t i2, double distanceTol) const;
+
+    bool isShallowConcavity(const geom::Coordinate& p0,
+                            const geom::Coordinate& p1,
+                            const geom::Coordinate& p2,
+                            double distanceTol) const;
+
+    /**
+     * Checks for shallowness over a sample of points in the given section.
+     *
+     * This helps prevents the siplification from incrementally
+     * "skipping" over points which are in fact non-shallow.
+     *
+     * @param p0 start coordinate of section
+     * @param p2 end coordinate of section
+     * @param i0 start index of section
+     * @param i2 end index of section
+     * @param distanceTol distance tolerance
+     * @return
+     */
+    bool isShallowSampled(const geom::Coordinate& p0,
+                          const geom::Coordinate& p2,
+                          size_t i0, size_t i2, double distanceTol) const;
+
+    bool isShallow(const geom::Coordinate& p0,
+                   const geom::Coordinate& p1,
+                   const geom::Coordinate& p2,
+                   double distanceTol) const;
+
+    bool isConcave(const geom::Coordinate& p0,
+                   const geom::Coordinate& p1,
+                   const geom::Coordinate& p2) const;
+
+    static const int NUM_PTS_TO_CHECK = 10;
+
+    static const int INIT = 0;
+    static const int DELETE = 1;
+    static const int KEEP = 1;
+
+    const geom::CoordinateSequence& inputLine;
+    double distanceTol;
+    std::vector<int> isDeleted;
+
+    int angleOrientation;
 
     // Declare type as noncopyable
     BufferInputLineSimplifier(const BufferInputLineSimplifier& other) = delete;
diff --git a/include/geos/operation/buffer/BufferOp.h b/include/geos/operation/buffer/BufferOp.h
index eb5b1c9..f7c0111 100644
--- a/include/geos/operation/buffer/BufferOp.h
+++ b/include/geos/operation/buffer/BufferOp.h
@@ -33,10 +33,10 @@
 
 // Forward declarations
 namespace geos {
-	namespace geom {
-		class PrecisionModel;
-		class Geometry;
-	}
+namespace geom {
+class PrecisionModel;
+class Geometry;
+}
 }
 
 namespace geos {
@@ -80,166 +80,166 @@ class GEOS_DLL BufferOp {
 
 private:
 
-	/**
-	 *  A number of digits of precision which leaves some computational "headroom"
-	 *  for floating point operations.
-	 *
-	 *  This value should be less than the decimal precision of double-precision values (16).
-	 */
-	static const int MAX_PRECISION_DIGITS = 12;
+    /**
+     *  A number of digits of precision which leaves some computational "headroom"
+     *  for floating point operations.
+     *
+     *  This value should be less than the decimal precision of double-precision values (16).
+     */
+    static const int MAX_PRECISION_DIGITS = 12;
 
-	/**
-	 * Compute a reasonable scale factor to limit the precision of
-	 * a given combination of Geometry and buffer distance.
-	 * The scale factor is based on a heuristic.
-	 *
-	 * @param g the Geometry being buffered
-	 *
-	 * @param distance the buffer distance
-	 *
-	 * @param maxPrecisionDigits the mzx # of digits that should be
-	 *        allowed by the precision determined by the
-	 *        computed scale factor
-	 *
-	 * @return a scale factor that allows a reasonable amount of
-	 *         precision for the buffer computation
-	 */
-	static double precisionScaleFactor(const geom::Geometry *g,
-			double distance, int maxPrecisionDigits);
+    /**
+     * Compute a reasonable scale factor to limit the precision of
+     * a given combination of Geometry and buffer distance.
+     * The scale factor is based on a heuristic.
+     *
+     * @param g the Geometry being buffered
+     *
+     * @param distance the buffer distance
+     *
+     * @param maxPrecisionDigits the mzx # of digits that should be
+     *        allowed by the precision determined by the
+     *        computed scale factor
+     *
+     * @return a scale factor that allows a reasonable amount of
+     *         precision for the buffer computation
+     */
+    static double precisionScaleFactor(const geom::Geometry* g,
+                                       double distance, int maxPrecisionDigits);
 
-	const geom::Geometry *argGeom;
+    const geom::Geometry* argGeom;
 
-	util::TopologyException saveException;
+    util::TopologyException saveException;
 
-	double distance;
+    double distance;
 
-	//int quadrantSegments;
-	//int endCapStyle;
-	BufferParameters bufParams;
+    //int quadrantSegments;
+    //int endCapStyle;
+    BufferParameters bufParams;
 
-	geom::Geometry* resultGeometry;
+    geom::Geometry* resultGeometry;
 
-	void computeGeometry();
+    void computeGeometry();
 
-	void bufferOriginalPrecision();
+    void bufferOriginalPrecision();
 
-	void bufferReducedPrecision(int precisionDigits);
+    void bufferReducedPrecision(int precisionDigits);
 
-	void bufferReducedPrecision();
+    void bufferReducedPrecision();
 
-	void bufferFixedPrecision(const geom::PrecisionModel& fixedPM);
+    void bufferFixedPrecision(const geom::PrecisionModel& fixedPM);
 
 public:
 
-	enum {
-		/// Specifies a round line buffer end cap style.
-		/// @deprecated use BufferParameters
-		CAP_ROUND = BufferParameters::CAP_ROUND,
-
-		/// Specifies a butt (or flat) line buffer end cap style.
-		/// @deprecated use BufferParameters
-		CAP_BUTT = BufferParameters::CAP_FLAT,
-
-		/// Specifies a square line buffer end cap style.
-		/// @deprecated use BufferParameters
-		CAP_SQUARE = BufferParameters::CAP_SQUARE
-	};
-
-	/**
-	 * Computes the buffer for a geometry for a given buffer distance
-	 * and accuracy of approximation.
-	 *
-	 * @param g the geometry to buffer
-	 * @param distance the buffer distance
-	 * @param quadrantSegments the number of segments used to
-	 *        approximate a quarter circle
-	 * @return the buffer of the input geometry
-	 *
-	 */
-	static geom::Geometry* bufferOp(const geom::Geometry *g,
-		double distance,
-		int quadrantSegments=
-			BufferParameters::DEFAULT_QUADRANT_SEGMENTS,
-		int endCapStyle=BufferParameters::CAP_ROUND);
-
-	/**
-	 * Initializes a buffer computation for the given geometry
-	 *
-	 * @param g the geometry to buffer
-	 */
-	BufferOp(const geom::Geometry *g)
-		:
-		argGeom(g),
-		bufParams(),
-		resultGeometry(nullptr)
-	{
-	}
-
-	/**
-	 * Initializes a buffer computation for the given geometry
-	 * with the given set of parameters
-	 *
-	 * @param g the geometry to buffer
-	 * @param params the buffer parameters to use. This class will
-	 *               copy it to private memory.
-	 */
-	BufferOp(const geom::Geometry* g, const BufferParameters& params)
-		:
-		argGeom(g),
-		bufParams(params),
-		resultGeometry(nullptr)
-	{
-	}
-
-	/**
-	 * Specifies the end cap style of the generated buffer.
-	 * The styles supported are CAP_ROUND, CAP_BUTT, and CAP_SQUARE.
-	 * The default is CAP_ROUND.
-	 *
-	 * @param endCapStyle the end cap style to specify
-	 */
-	inline void setEndCapStyle(int nEndCapStyle);
-
-	/**
-	 * Specifies the end cap style of the generated buffer.
-	 * The styles supported are CAP_ROUND, CAP_BUTT, and CAP_SQUARE.
-	 * The default is CAP_ROUND.
-	 *
-	 * @param endCapStyle the end cap style to specify
-	 */
-	inline void setQuadrantSegments(int nQuadrantSegments);
-
-	/**
-	 * Sets whether the computed buffer should be single-sided.
-	 *
-	 * A single-sided buffer is constructed on only one side
-	 * of each input line.
-	 *
-	 * The side used is determined by the sign of the buffer distance:
-	 * - a positive distance indicates the left-hand side
-	 * - a negative distance indicates the right-hand side
-	 *
-	 * The single-sided buffer of point geometries is
-	 * the same as the regular buffer.
-	 *
-	 * The End Cap Style for single-sided buffers is
-	 * always ignored,
-	 * and forced to the equivalent of <tt>CAP_FLAT</tt>.
-	 *
-	 * @param isSingleSided true if a single-sided buffer
-	 *                      should be constructed
-	 */
-	inline void setSingleSided(bool isSingleSided);
-
-	/**
-	 * Returns the buffer computed for a geometry for a given buffer
-	 * distance.
-	 *
-	 * @param g the geometry to buffer
-	 * @param distance the buffer distance
-	 * @return the buffer of the input geometry
-	 */
-	geom::Geometry* getResultGeometry(double nDistance);
+    enum {
+        /// Specifies a round line buffer end cap style.
+        /// @deprecated use BufferParameters
+        CAP_ROUND = BufferParameters::CAP_ROUND,
+
+        /// Specifies a butt (or flat) line buffer end cap style.
+        /// @deprecated use BufferParameters
+        CAP_BUTT = BufferParameters::CAP_FLAT,
+
+        /// Specifies a square line buffer end cap style.
+        /// @deprecated use BufferParameters
+        CAP_SQUARE = BufferParameters::CAP_SQUARE
+    };
+
+    /**
+     * Computes the buffer for a geometry for a given buffer distance
+     * and accuracy of approximation.
+     *
+     * @param g the geometry to buffer
+     * @param distance the buffer distance
+     * @param quadrantSegments the number of segments used to
+     *        approximate a quarter circle
+     * @return the buffer of the input geometry
+     *
+     */
+    static geom::Geometry* bufferOp(const geom::Geometry* g,
+                                    double distance,
+                                    int quadrantSegments =
+                                        BufferParameters::DEFAULT_QUADRANT_SEGMENTS,
+                                    int endCapStyle = BufferParameters::CAP_ROUND);
+
+    /**
+     * Initializes a buffer computation for the given geometry
+     *
+     * @param g the geometry to buffer
+     */
+    BufferOp(const geom::Geometry* g)
+        :
+        argGeom(g),
+        bufParams(),
+        resultGeometry(nullptr)
+    {
+    }
+
+    /**
+     * Initializes a buffer computation for the given geometry
+     * with the given set of parameters
+     *
+     * @param g the geometry to buffer
+     * @param params the buffer parameters to use. This class will
+     *               copy it to private memory.
+     */
+    BufferOp(const geom::Geometry* g, const BufferParameters& params)
+        :
+        argGeom(g),
+        bufParams(params),
+        resultGeometry(nullptr)
+    {
+    }
+
+    /**
+     * Specifies the end cap style of the generated buffer.
+     * The styles supported are CAP_ROUND, CAP_BUTT, and CAP_SQUARE.
+     * The default is CAP_ROUND.
+     *
+     * @param endCapStyle the end cap style to specify
+     */
+    inline void setEndCapStyle(int nEndCapStyle);
+
+    /**
+     * Specifies the end cap style of the generated buffer.
+     * The styles supported are CAP_ROUND, CAP_BUTT, and CAP_SQUARE.
+     * The default is CAP_ROUND.
+     *
+     * @param endCapStyle the end cap style to specify
+     */
+    inline void setQuadrantSegments(int nQuadrantSegments);
+
+    /**
+     * Sets whether the computed buffer should be single-sided.
+     *
+     * A single-sided buffer is constructed on only one side
+     * of each input line.
+     *
+     * The side used is determined by the sign of the buffer distance:
+     * - a positive distance indicates the left-hand side
+     * - a negative distance indicates the right-hand side
+     *
+     * The single-sided buffer of point geometries is
+     * the same as the regular buffer.
+     *
+     * The End Cap Style for single-sided buffers is
+     * always ignored,
+     * and forced to the equivalent of <tt>CAP_FLAT</tt>.
+     *
+     * @param isSingleSided true if a single-sided buffer
+     *                      should be constructed
+     */
+    inline void setSingleSided(bool isSingleSided);
+
+    /**
+     * Returns the buffer computed for a geometry for a given buffer
+     * distance.
+     *
+     * @param g the geometry to buffer
+     * @param distance the buffer distance
+     * @return the buffer of the input geometry
+     */
+    geom::Geometry* getResultGeometry(double nDistance);
 
 };
 
@@ -247,19 +247,19 @@ public:
 void
 BufferOp::setQuadrantSegments(int q)
 {
-	bufParams.setQuadrantSegments(q);
+    bufParams.setQuadrantSegments(q);
 }
 
 void
 BufferOp::setEndCapStyle(int s)
 {
-	bufParams.setEndCapStyle((BufferParameters::EndCapStyle)s);
+    bufParams.setEndCapStyle((BufferParameters::EndCapStyle)s);
 }
 
 void
 BufferOp::setSingleSided(bool isSingleSided)
 {
-   bufParams.setSingleSided(isSingleSided);
+    bufParams.setSingleSided(isSingleSided);
 }
 
 } // namespace geos::operation::buffer
diff --git a/include/geos/operation/buffer/BufferParameters.h b/include/geos/operation/buffer/BufferParameters.h
index d80a367..6592683 100644
--- a/include/geos/operation/buffer/BufferParameters.h
+++ b/include/geos/operation/buffer/BufferParameters.h
@@ -34,15 +34,15 @@
 
 // Forward declarations
 namespace geos {
-	namespace geom {
-		class CoordinateSequence;
-		class PrecisionModel;
-	}
-	namespace operation {
-		namespace buffer {
-			class OffsetCurveVertexList;
-		}
-	}
+namespace geom {
+class CoordinateSequence;
+class PrecisionModel;
+}
+namespace operation {
+namespace buffer {
+class OffsetCurveVertexList;
+}
+}
 }
 
 namespace geos {
@@ -54,241 +54,262 @@ namespace buffer { // geos.operation.buffer
  * describe how a buffer should be constructed.
  *
  */
-class GEOS_DLL BufferParameters
-{
+class GEOS_DLL BufferParameters {
 
 public:
 
-	/// End cap styles
-        enum EndCapStyle {
-
-                /// Specifies a round line buffer end cap style.
-                CAP_ROUND=1,
-
-                /// Specifies a flat line buffer end cap style.
-                CAP_FLAT=2,
-
-                /// Specifies a square line buffer end cap style.
-                CAP_SQUARE=3
-        };
-
-	/// Join styles
-        enum JoinStyle {
-
-                /// Specifies a round join style.
-                JOIN_ROUND=1,
-
-                /// Specifies a mitre join style.
-                JOIN_MITRE=2,
-
-                /// Specifies a bevel join style.
-                JOIN_BEVEL=3
-        };
-
-	/// \brief
-	/// The default number of facets into which to divide a fillet
-	/// of 90 degrees.
-	//
-	/// A value of 8 gives less than 2% max error in the buffer distance.
-	/// For a max error of < 1%, use QS = 12.
-	/// For a max error of < 0.1%, use QS = 18.
-	///
-	static const int DEFAULT_QUADRANT_SEGMENTS = 8;
-
-	/// The default mitre limit
-	//
-	/// Allows fairly pointy mitres.
-	///
-	static const double DEFAULT_MITRE_LIMIT; // 5.0 (in .cpp file)
-
-	/// Creates a default set of parameters
-	BufferParameters();
-
-	/// Creates a set of parameters with the given quadrantSegments value.
-	//
-	/// @param quadrantSegments the number of quadrant segments to use
-	///
-	BufferParameters(int quadrantSegments);
-
-	/// \brief
-	/// Creates a set of parameters with the
-	/// given quadrantSegments and endCapStyle values.
-	//
-	/// @param quadrantSegments the number of quadrant segments to use
-	/// @param endCapStyle the end cap style to use
-	///
-	BufferParameters(int quadrantSegments, EndCapStyle endCapStyle);
-
-	/// \brief
-	/// Creates a set of parameters with the
-	/// given parameter values.
-	//
-	/// @param quadrantSegments the number of quadrant segments to use
-	/// @param endCapStyle the end cap style to use
-	/// @param joinStyle the join style to use
-	/// @param mitreLimit the mitre limit to use
-	///
-	BufferParameters(int quadrantSegments, EndCapStyle endCapStyle,
-	                 JoinStyle joinStyle, double mitreLimit);
-
-	/// Gets the number of quadrant segments which will be used
-	//
-	/// @return the number of quadrant segments
-	///
-	int getQuadrantSegments() const { return quadrantSegments; }
-
-	/// \brief
-	/// Sets the number of line segments used to approximate
-	/// an angle fillet.
-	//
-	/// - If <tt>quadSegs</tt> >= 1, joins are round,
-	///   and <tt>quadSegs</tt> indicates the number of
-	///   segments to use to approximate a quarter-circle.
-	/// - If <tt>quadSegs</tt> = 0, joins are bevelled (flat)
-	/// - If <tt>quadSegs</tt> < 0, joins are mitred, and the value of qs
-	///   indicates the mitre ration limit as
-	///   <pre>
-	///    mitreLimit = |<tt>quadSegs</tt>|
-	///    </pre>
-	///
-	/// For round joins, <tt>quadSegs</tt> determines the maximum
-	/// error in the approximation to the true buffer curve.
-	///
-	/// The default value of 8 gives less than 2% max error in the
-	/// buffer distance.
-	///
-	/// For a max error of < 1%, use QS = 12.
-	/// For a max error of < 0.1%, use QS = 18.
-	/// The error is always less than the buffer distance
-	/// (in other words, the computed buffer curve is always inside
-	///  the true curve).
-	///
-	/// @param quadrantSegments the number of segments in a
-	///                         fillet for a quadrant
-	////
-	void setQuadrantSegments(int quadSegs);
-
-	/// \brief
-	/// Computes the maximum distance error due to a given level
-	/// of approximation to a true arc.
-	//
-	/// @param quadSegs the number of segments used to approximate
-	///                 a quarter-circle
-	/// @return the error of approximation
-	///
-	static double bufferDistanceError(int quadSegs);
-
-	/// Gets the end cap style.
-	//
-	/// @return the end cap style
-	///
-	EndCapStyle getEndCapStyle() const { return endCapStyle; }
-
-	/// Specifies the end cap style of the generated buffer.
-	//
-	/// The styles supported are CAP_ROUND, CAP_BUTT,
-	/// and CAP_SQUARE.
-	///
-	/// The default is CAP_ROUND.
-	///
-	/// @param style the end cap style to specify
-	///
-	void setEndCapStyle(EndCapStyle style)
-	{
-		endCapStyle = style;
-	}
-
-	/// Gets the join style.
-	//
-	/// @return the join style
-	///
-	JoinStyle getJoinStyle() const { return joinStyle; }
-
-	/// \brief
-	/// Sets the join style for outside (reflex) corners between
-	/// line segments.
-	//
-	/// Allowable values are JOIN_ROUND (which is the default),
-	/// JOIN_MITRE and JOIN_BEVEL.
-	//
-	/// @param style the code for the join style
-	///
-	void setJoinStyle(JoinStyle style)
-	{
-		joinStyle = style;
-	}
-
-	/// Gets the mitre ratio limit.
-	//
-	/// @return the limit value
-	///
-	double getMitreLimit() const { return mitreLimit; }
-
-	/// Sets the limit on the mitre ratio used for very sharp corners.
-	//
-	/// The mitre ratio is the ratio of the distance from the corner
-	/// to the end of the mitred offset corner.
-	/// When two line segments meet at a sharp angle,
-	/// a miter join will extend far beyond the original geometry.
-	/// (and in the extreme case will be infinitely far.)
-	/// To prevent unreasonable geometry, the mitre limit
-	/// allows controlling the maximum length of the join corner.
-	/// Corners with a ratio which exceed the limit will be beveled.
-	///
-	/// @param limit the mitre ratio limit
-	///
-	void setMitreLimit(double limit)
-	{
-		mitreLimit = limit;
-	}
-
-	/**
-	 * Sets whether the computed buffer should be single-sided.
-	 * A single-sided buffer is constructed on only one side of each input line.
-	 *
-	 * The side used is determined by the sign of the buffer distance:
-	 * - a positive distance indicates the left-hand side
-	 * - a negative distance indicates the right-hand side
-	 *
-	 * The single-sided buffer of point geometries is
-	 * the same as the regular buffer.
-	 *
-	 * The End Cap Style for single-sided buffers is
-	 * always ignored,
-	 * and forced to the equivalent of <tt>CAP_FLAT</tt>.
-	 *
-	 * @param isSingleSided true if a single-sided buffer should be constructed
-	 */
-	void setSingleSided(bool p_isSingleSided)
-	{
-	  _isSingleSided = p_isSingleSided;
-	}
-
-	/**
-	 * Tests whether the buffer is to be generated on a single side only.
-	 *
-	 * @return true if the generated buffer is to be single-sided
-	 */
-	bool isSingleSided() const {
-	  return _isSingleSided;
-	}
+    /// End cap styles
+    enum EndCapStyle {
+
+        /// Specifies a round line buffer end cap style.
+        CAP_ROUND = 1,
+
+        /// Specifies a flat line buffer end cap style.
+        CAP_FLAT = 2,
+
+        /// Specifies a square line buffer end cap style.
+        CAP_SQUARE = 3
+    };
+
+    /// Join styles
+    enum JoinStyle {
+
+        /// Specifies a round join style.
+        JOIN_ROUND = 1,
+
+        /// Specifies a mitre join style.
+        JOIN_MITRE = 2,
+
+        /// Specifies a bevel join style.
+        JOIN_BEVEL = 3
+    };
+
+    /// \brief
+    /// The default number of facets into which to divide a fillet
+    /// of 90 degrees.
+    //
+    /// A value of 8 gives less than 2% max error in the buffer distance.
+    /// For a max error of < 1%, use QS = 12.
+    /// For a max error of < 0.1%, use QS = 18.
+    ///
+    static const int DEFAULT_QUADRANT_SEGMENTS = 8;
+
+    /// The default mitre limit
+    //
+    /// Allows fairly pointy mitres.
+    ///
+    static const double DEFAULT_MITRE_LIMIT; // 5.0 (in .cpp file)
+
+    /// Creates a default set of parameters
+    BufferParameters();
+
+    /// Creates a set of parameters with the given quadrantSegments value.
+    //
+    /// @param quadrantSegments the number of quadrant segments to use
+    ///
+    BufferParameters(int quadrantSegments);
+
+    /// \brief
+    /// Creates a set of parameters with the
+    /// given quadrantSegments and endCapStyle values.
+    //
+    /// @param quadrantSegments the number of quadrant segments to use
+    /// @param endCapStyle the end cap style to use
+    ///
+    BufferParameters(int quadrantSegments, EndCapStyle endCapStyle);
+
+    /// \brief
+    /// Creates a set of parameters with the
+    /// given parameter values.
+    //
+    /// @param quadrantSegments the number of quadrant segments to use
+    /// @param endCapStyle the end cap style to use
+    /// @param joinStyle the join style to use
+    /// @param mitreLimit the mitre limit to use
+    ///
+    BufferParameters(int quadrantSegments, EndCapStyle endCapStyle,
+                     JoinStyle joinStyle, double mitreLimit);
+
+    /// Gets the number of quadrant segments which will be used
+    //
+    /// @return the number of quadrant segments
+    ///
+    int
+    getQuadrantSegments() const
+    {
+        return quadrantSegments;
+    }
+
+    /// \brief
+    /// Sets the number of line segments used to approximate
+    /// an angle fillet.
+    //
+    /// - If <tt>quadSegs</tt> >= 1, joins are round,
+    ///   and <tt>quadSegs</tt> indicates the number of
+    ///   segments to use to approximate a quarter-circle.
+    /// - If <tt>quadSegs</tt> = 0, joins are bevelled (flat)
+    /// - If <tt>quadSegs</tt> < 0, joins are mitred, and the value of qs
+    ///   indicates the mitre ration limit as
+    ///   <pre>
+    ///    mitreLimit = |<tt>quadSegs</tt>|
+    ///    </pre>
+    ///
+    /// For round joins, <tt>quadSegs</tt> determines the maximum
+    /// error in the approximation to the true buffer curve.
+    ///
+    /// The default value of 8 gives less than 2% max error in the
+    /// buffer distance.
+    ///
+    /// For a max error of < 1%, use QS = 12.
+    /// For a max error of < 0.1%, use QS = 18.
+    /// The error is always less than the buffer distance
+    /// (in other words, the computed buffer curve is always inside
+    ///  the true curve).
+    ///
+    /// @param quadrantSegments the number of segments in a
+    ///                         fillet for a quadrant
+    ////
+    void setQuadrantSegments(int quadSegs);
+
+    /// \brief
+    /// Computes the maximum distance error due to a given level
+    /// of approximation to a true arc.
+    //
+    /// @param quadSegs the number of segments used to approximate
+    ///                 a quarter-circle
+    /// @return the error of approximation
+    ///
+    static double bufferDistanceError(int quadSegs);
+
+    /// Gets the end cap style.
+    //
+    /// @return the end cap style
+    ///
+    EndCapStyle
+    getEndCapStyle() const
+    {
+        return endCapStyle;
+    }
+
+    /// Specifies the end cap style of the generated buffer.
+    //
+    /// The styles supported are CAP_ROUND, CAP_BUTT,
+    /// and CAP_SQUARE.
+    ///
+    /// The default is CAP_ROUND.
+    ///
+    /// @param style the end cap style to specify
+    ///
+    void
+    setEndCapStyle(EndCapStyle style)
+    {
+        endCapStyle = style;
+    }
+
+    /// Gets the join style.
+    //
+    /// @return the join style
+    ///
+    JoinStyle
+    getJoinStyle() const
+    {
+        return joinStyle;
+    }
+
+    /// \brief
+    /// Sets the join style for outside (reflex) corners between
+    /// line segments.
+    //
+    /// Allowable values are JOIN_ROUND (which is the default),
+    /// JOIN_MITRE and JOIN_BEVEL.
+    //
+    /// @param style the code for the join style
+    ///
+    void
+    setJoinStyle(JoinStyle style)
+    {
+        joinStyle = style;
+    }
+
+    /// Gets the mitre ratio limit.
+    //
+    /// @return the limit value
+    ///
+    double
+    getMitreLimit() const
+    {
+        return mitreLimit;
+    }
+
+    /// Sets the limit on the mitre ratio used for very sharp corners.
+    //
+    /// The mitre ratio is the ratio of the distance from the corner
+    /// to the end of the mitred offset corner.
+    /// When two line segments meet at a sharp angle,
+    /// a miter join will extend far beyond the original geometry.
+    /// (and in the extreme case will be infinitely far.)
+    /// To prevent unreasonable geometry, the mitre limit
+    /// allows controlling the maximum length of the join corner.
+    /// Corners with a ratio which exceed the limit will be beveled.
+    ///
+    /// @param limit the mitre ratio limit
+    ///
+    void
+    setMitreLimit(double limit)
+    {
+        mitreLimit = limit;
+    }
+
+    /**
+     * Sets whether the computed buffer should be single-sided.
+     * A single-sided buffer is constructed on only one side of each input line.
+     *
+     * The side used is determined by the sign of the buffer distance:
+     * - a positive distance indicates the left-hand side
+     * - a negative distance indicates the right-hand side
+     *
+     * The single-sided buffer of point geometries is
+     * the same as the regular buffer.
+     *
+     * The End Cap Style for single-sided buffers is
+     * always ignored,
+     * and forced to the equivalent of <tt>CAP_FLAT</tt>.
+     *
+     * @param isSingleSided true if a single-sided buffer should be constructed
+     */
+    void
+    setSingleSided(bool p_isSingleSided)
+    {
+        _isSingleSided = p_isSingleSided;
+    }
+
+    /**
+     * Tests whether the buffer is to be generated on a single side only.
+     *
+     * @return true if the generated buffer is to be single-sided
+     */
+    bool
+    isSingleSided() const
+    {
+        return _isSingleSided;
+    }
 
 
 private:
 
-	/// Defaults to DEFAULT_QUADRANT_SEGMENTS;
-	int quadrantSegments;
+    /// Defaults to DEFAULT_QUADRANT_SEGMENTS;
+    int quadrantSegments;
 
-	/// Defaults to CAP_ROUND;
-	EndCapStyle endCapStyle;
+    /// Defaults to CAP_ROUND;
+    EndCapStyle endCapStyle;
 
-	/// Defaults to JOIN_ROUND;
-	JoinStyle joinStyle;
+    /// Defaults to JOIN_ROUND;
+    JoinStyle joinStyle;
 
-	/// Defaults to DEFAULT_MITRE_LIMIT;
-	double mitreLimit;
+    /// Defaults to DEFAULT_MITRE_LIMIT;
+    double mitreLimit;
 
-	bool _isSingleSided;
+    bool _isSingleSided;
 };
 
 } // namespace geos::operation::buffer
diff --git a/include/geos/operation/buffer/BufferSubgraph.h b/include/geos/operation/buffer/BufferSubgraph.h
index e1519a6..ed4872a 100644
--- a/include/geos/operation/buffer/BufferSubgraph.h
+++ b/include/geos/operation/buffer/BufferSubgraph.h
@@ -33,17 +33,17 @@
 
 // Forward declarations
 namespace geos {
-	namespace geom {
-		class Coordinate;
-		class Envelope;
-	}
-	namespace algorithm {
-		class CGAlgorithms;
-	}
-	namespace geomgraph {
-		class DirectedEdge;
-		class Node;
-	}
+namespace geom {
+class Coordinate;
+class Envelope;
+}
+namespace algorithm {
+class CGAlgorithms;
+}
+namespace geomgraph {
+class DirectedEdge;
+class Node;
+}
 }
 
 namespace geos {
@@ -60,131 +60,138 @@ namespace buffer { // geos.operation.buffer
  */
 class GEOS_DLL BufferSubgraph {
 private:
-	RightmostEdgeFinder finder;
+    RightmostEdgeFinder finder;
 
-	std::vector<geomgraph::DirectedEdge*> dirEdgeList;
+    std::vector<geomgraph::DirectedEdge*> dirEdgeList;
 
-	std::vector<geomgraph::Node*> nodes;
+    std::vector<geomgraph::Node*> nodes;
 
-	geom::Coordinate *rightMostCoord;
+    geom::Coordinate* rightMostCoord;
 
-	geom::Envelope *env;
+    geom::Envelope* env;
 
-	/** \brief
-	 * Adds all nodes and edges reachable from this node to the subgraph.
-	 *
-	 * Uses an explicit stack to avoid a large depth of recursion.
-	 *
-	 * @param node a node known to be in the subgraph
-	 */
-	void addReachable(geomgraph::Node *startNode);
+    /** \brief
+     * Adds all nodes and edges reachable from this node to the subgraph.
+     *
+     * Uses an explicit stack to avoid a large depth of recursion.
+     *
+     * @param node a node known to be in the subgraph
+     */
+    void addReachable(geomgraph::Node* startNode);
 
-	/// Adds the argument node and all its out edges to the subgraph
-	//
-	/// @param node the node to add
-	/// @param nodeStack the current set of nodes being traversed
-	///
-	void add(geomgraph::Node* node, std::vector<geomgraph::Node*>* nodeStack);
+    /// Adds the argument node and all its out edges to the subgraph
+    //
+    /// @param node the node to add
+    /// @param nodeStack the current set of nodes being traversed
+    ///
+    void add(geomgraph::Node* node, std::vector<geomgraph::Node*>* nodeStack);
 
-	void clearVisitedEdges();
+    void clearVisitedEdges();
 
-	/** \brief
-	 * Compute depths for all dirEdges via breadth-first traversal
-	 * of nodes in graph
-	 *
-	 * @param startEdge edge to start processing with
-	 */
-	// <FIX> MD - use iteration & queue rather than recursion, for speed and robustness
-	void computeDepths(geomgraph::DirectedEdge *startEdge);
+    /** \brief
+     * Compute depths for all dirEdges via breadth-first traversal
+     * of nodes in graph
+     *
+     * @param startEdge edge to start processing with
+     */
+    // <FIX> MD - use iteration & queue rather than recursion, for speed and robustness
+    void computeDepths(geomgraph::DirectedEdge* startEdge);
 
-	void computeNodeDepth(geomgraph::Node *n);
+    void computeNodeDepth(geomgraph::Node* n);
 
-	void copySymDepths(geomgraph::DirectedEdge *de);
+    void copySymDepths(geomgraph::DirectedEdge* de);
 
-	bool contains(std::set<geomgraph::Node*>& nodes, geomgraph::Node *node);
+    bool contains(std::set<geomgraph::Node*>& nodes, geomgraph::Node* node);
 
 public:
 
-	friend std::ostream& operator<< (std::ostream& os, const BufferSubgraph& bs);
-
-	BufferSubgraph();
-
-	~BufferSubgraph();
-
-	std::vector<geomgraph::DirectedEdge*>* getDirectedEdges();
-
-	std::vector<geomgraph::Node*>* getNodes();
-
-	/** \brief
-	 * Gets the rightmost coordinate in the edges of the subgraph
-	 */
-	geom::Coordinate* getRightmostCoordinate();
-
-	/** \brief
-	 * Creates the subgraph consisting of all edges reachable from
-	 * this node.
-	 *
-	 * Finds the edges in the graph and the rightmost coordinate.
-	 *
-	 * @param node a node to start the graph traversal from
-	 */
-	void create(geomgraph::Node *node);
-
-	void computeDepth(int outsideDepth);
-
-	/** \brief
-	 * Find all edges whose depths indicates that they are in the
-	 * result area(s).
-	 *
-	 * Since we want polygon shells to be
-	 * oriented CW, choose dirEdges with the interior of the result
-	 * on the RHS.
-	 * Mark them as being in the result.
-	 * Interior Area edges are the result of dimensional collapses.
-	 * They do not form part of the result area boundary.
-	 */
-	void findResultEdges();
-
-	/** \brief
-	 * BufferSubgraphs are compared on the x-value of their rightmost
-	 * Coordinate.
-	 *
-	 * This defines a partial ordering on the graphs such that:
-	 *
-	 * g1 >= g2 <==> Ring(g2) does not contain Ring(g1)
-	 *
-	 * where Polygon(g) is the buffer polygon that is built from g.
-	 *
-	 * This relationship is used to sort the BufferSubgraphs so
-	 * that shells are guaranteed to
-	 * be built before holes.
-	 */
-	int compareTo(BufferSubgraph *);
-
-	/** \brief
-	 * Computes the envelope of the edges in the subgraph.
-	 * The envelope is cached after being computed.
-	 *
-	 * @return the envelope of the graph.
-	 */
-	geom::Envelope *getEnvelope();
+    friend std::ostream& operator<< (std::ostream& os, const BufferSubgraph& bs);
+
+    BufferSubgraph();
+
+    ~BufferSubgraph();
+
+    std::vector<geomgraph::DirectedEdge*>* getDirectedEdges();
+
+    std::vector<geomgraph::Node*>* getNodes();
+
+    /** \brief
+     * Gets the rightmost coordinate in the edges of the subgraph
+     */
+    geom::Coordinate* getRightmostCoordinate();
+
+    /** \brief
+     * Creates the subgraph consisting of all edges reachable from
+     * this node.
+     *
+     * Finds the edges in the graph and the rightmost coordinate.
+     *
+     * @param node a node to start the graph traversal from
+     */
+    void create(geomgraph::Node* node);
+
+    void computeDepth(int outsideDepth);
+
+    /** \brief
+     * Find all edges whose depths indicates that they are in the
+     * result area(s).
+     *
+     * Since we want polygon shells to be
+     * oriented CW, choose dirEdges with the interior of the result
+     * on the RHS.
+     * Mark them as being in the result.
+     * Interior Area edges are the result of dimensional collapses.
+     * They do not form part of the result area boundary.
+     */
+    void findResultEdges();
+
+    /** \brief
+     * BufferSubgraphs are compared on the x-value of their rightmost
+     * Coordinate.
+     *
+     * This defines a partial ordering on the graphs such that:
+     *
+     * g1 >= g2 <==> Ring(g2) does not contain Ring(g1)
+     *
+     * where Polygon(g) is the buffer polygon that is built from g.
+     *
+     * This relationship is used to sort the BufferSubgraphs so
+     * that shells are guaranteed to
+     * be built before holes.
+     */
+    int compareTo(BufferSubgraph*);
+
+    /** \brief
+     * Computes the envelope of the edges in the subgraph.
+     * The envelope is cached after being computed.
+     *
+     * @return the envelope of the graph.
+     */
+    geom::Envelope* getEnvelope();
 };
 
 std::ostream& operator<< (std::ostream& os, const BufferSubgraph& bs);
 
 // INLINES
 inline geom::Coordinate*
-BufferSubgraph::getRightmostCoordinate() {return rightMostCoord;}
+BufferSubgraph::getRightmostCoordinate()
+{
+    return rightMostCoord;
+}
 
 inline std::vector<geomgraph::Node*>*
-BufferSubgraph::getNodes() { return &nodes; }
+BufferSubgraph::getNodes()
+{
+    return &nodes;
+}
 
 inline std::vector<geomgraph::DirectedEdge*>*
-BufferSubgraph::getDirectedEdges() {
-	return &dirEdgeList;
+BufferSubgraph::getDirectedEdges()
+{
+    return &dirEdgeList;
 }
 
-bool BufferSubgraphGT(BufferSubgraph *first, BufferSubgraph *second);
+bool BufferSubgraphGT(BufferSubgraph* first, BufferSubgraph* second);
 
 } // namespace geos::operation::buffer
 } // namespace geos::operation
diff --git a/include/geos/operation/buffer/OffsetCurveBuilder.h b/include/geos/operation/buffer/OffsetCurveBuilder.h
index 52f1d55..684dcfd 100644
--- a/include/geos/operation/buffer/OffsetCurveBuilder.h
+++ b/include/geos/operation/buffer/OffsetCurveBuilder.h
@@ -35,10 +35,10 @@
 
 // Forward declarations
 namespace geos {
-	namespace geom {
-		class CoordinateSequence;
-		class PrecisionModel;
-	}
+namespace geom {
+class CoordinateSequence;
+class PrecisionModel;
+}
 }
 
 namespace geos {
@@ -62,116 +62,117 @@ namespace buffer { // geos.operation.buffer
 class GEOS_DLL OffsetCurveBuilder {
 public:
 
-	/*
-	 * @param nBufParams buffer parameters, this object will
-	 *                   keep a reference to the passed parameters
-	 *                   so caller must make sure the object is
-	 *                   kept alive for the whole lifetime of
-	 *                   the buffer builder.
-	 */
-	OffsetCurveBuilder(const geom::PrecisionModel *newPrecisionModel,
-			const BufferParameters& nBufParams)
-		:
-		distance(0.0),
-		precisionModel(newPrecisionModel),
-		bufParams(nBufParams)
-  {}
-
-  /**
-   * Gets the buffer parameters being used to generate the curve.
-   *
-   * @return the buffer parameters being used
-   */
-  const BufferParameters& getBufferParameters() const
-  {
-    return bufParams;
-  }
-
-	/**
-	 * This method handles single points as well as lines.
-	 * Lines are assumed to <b>not</b> be closed (the function will not
-	 * fail for closed lines, but will generate superfluous line caps).
-	 *
-	 * @param lineList the std::vector to which the newly created
-	 *                 CoordinateSequences will be pushed_back.
-	 *                 Caller is responsible to delete these new elements.
-	 */
-	void getLineCurve(const geom::CoordinateSequence* inputPts,
-	                  double distance,
-	                  std::vector<geom::CoordinateSequence*>& lineList);
-
-	/**
-	 * This method handles single points as well as lines.
-	 *
-	 * Lines are assumed to <b>not</b> be closed (the function will not
-	 * fail for closed lines, but will generate superfluous line caps).
-	 *
-	 * @param lineList the std::vector to which newly created
-	 *                 CoordinateSequences will be pushed_back.
-	 *                 Caller will be responsible to delete them.
-	 * @param leftSide indicates that the left side buffer will be
-	 *                 obtained/skipped
-	 * @param rightSide indicates that the right side buffer will
-	 *                  be obtained/skipped
-	 *
-	 * NOTE: this is a GEOS extension
-	 */
-	void getSingleSidedLineCurve(const geom::CoordinateSequence* inputPts,
-	     double distance, std::vector<geom::CoordinateSequence*>& lineList,
-	     bool leftSide, bool rightSide ) ;
-
-	/**
-	 * This method handles the degenerate cases of single points and lines,
-	 * as well as rings.
-	 *
-	 * @param lineList the std::vector to which CoordinateSequences will
-	 *                 be pushed_back
-	 */
-	void getRingCurve(const geom::CoordinateSequence *inputPts, int side,
-	                  double distance,
-	                  std::vector<geom::CoordinateSequence*>& lineList);
+    /*
+     * @param nBufParams buffer parameters, this object will
+     *                   keep a reference to the passed parameters
+     *                   so caller must make sure the object is
+     *                   kept alive for the whole lifetime of
+     *                   the buffer builder.
+     */
+    OffsetCurveBuilder(const geom::PrecisionModel* newPrecisionModel,
+                       const BufferParameters& nBufParams)
+        :
+        distance(0.0),
+        precisionModel(newPrecisionModel),
+        bufParams(nBufParams)
+    {}
+
+    /**
+     * Gets the buffer parameters being used to generate the curve.
+     *
+     * @return the buffer parameters being used
+     */
+    const BufferParameters&
+    getBufferParameters() const
+    {
+        return bufParams;
+    }
+
+    /**
+     * This method handles single points as well as lines.
+     * Lines are assumed to <b>not</b> be closed (the function will not
+     * fail for closed lines, but will generate superfluous line caps).
+     *
+     * @param lineList the std::vector to which the newly created
+     *                 CoordinateSequences will be pushed_back.
+     *                 Caller is responsible to delete these new elements.
+     */
+    void getLineCurve(const geom::CoordinateSequence* inputPts,
+                      double distance,
+                      std::vector<geom::CoordinateSequence*>& lineList);
+
+    /**
+     * This method handles single points as well as lines.
+     *
+     * Lines are assumed to <b>not</b> be closed (the function will not
+     * fail for closed lines, but will generate superfluous line caps).
+     *
+     * @param lineList the std::vector to which newly created
+     *                 CoordinateSequences will be pushed_back.
+     *                 Caller will be responsible to delete them.
+     * @param leftSide indicates that the left side buffer will be
+     *                 obtained/skipped
+     * @param rightSide indicates that the right side buffer will
+     *                  be obtained/skipped
+     *
+     * NOTE: this is a GEOS extension
+     */
+    void getSingleSidedLineCurve(const geom::CoordinateSequence* inputPts,
+                                 double distance, std::vector<geom::CoordinateSequence*>& lineList,
+                                 bool leftSide, bool rightSide) ;
+
+    /**
+     * This method handles the degenerate cases of single points and lines,
+     * as well as rings.
+     *
+     * @param lineList the std::vector to which CoordinateSequences will
+     *                 be pushed_back
+     */
+    void getRingCurve(const geom::CoordinateSequence* inputPts, int side,
+                      double distance,
+                      std::vector<geom::CoordinateSequence*>& lineList);
 
 
 private:
 
-	double distance;
+    double distance;
 
-	const geom::PrecisionModel* precisionModel;
+    const geom::PrecisionModel* precisionModel;
 
-	const BufferParameters& bufParams;
+    const BufferParameters& bufParams;
 
-	/**
-	 * Use a value which results in a potential distance error which is
-	 * significantly less than the error due to
-	 * the quadrant segment discretization.
-	 * For QS = 8 a value of 100 is reasonable.
-	 * This should produce a maximum of 1% distance error.
-	 */
-	static const double SIMPLIFY_FACTOR; // 100.0;
+    /**
+     * Use a value which results in a potential distance error which is
+     * significantly less than the error due to
+     * the quadrant segment discretization.
+     * For QS = 8 a value of 100 is reasonable.
+     * This should produce a maximum of 1% distance error.
+     */
+    static const double SIMPLIFY_FACTOR; // 100.0;
 
-	/** \brief
-	 * Computes the distance tolerance to use during input
-	 * line simplification.
-	 *
-	 * @param distance the buffer distance
-	 * @return the simplification tolerance
-	 */
-	double simplifyTolerance(double bufDistance);
+    /** \brief
+     * Computes the distance tolerance to use during input
+     * line simplification.
+     *
+     * @param distance the buffer distance
+     * @return the simplification tolerance
+     */
+    double simplifyTolerance(double bufDistance);
 
-	void computeLineBufferCurve(const geom::CoordinateSequence& inputPts,
-                              OffsetSegmentGenerator& segGen);
+    void computeLineBufferCurve(const geom::CoordinateSequence& inputPts,
+                                OffsetSegmentGenerator& segGen);
 
-  void computeSingleSidedBufferCurve(const geom::CoordinateSequence& inputPts,
-                                     bool isRightSide,
-                                     OffsetSegmentGenerator& segGen);
+    void computeSingleSidedBufferCurve(const geom::CoordinateSequence& inputPts,
+                                       bool isRightSide,
+                                       OffsetSegmentGenerator& segGen);
 
-	void computeRingBufferCurve(const geom::CoordinateSequence& inputPts,
-	                            int side, OffsetSegmentGenerator& segGen);
+    void computeRingBufferCurve(const geom::CoordinateSequence& inputPts,
+                                int side, OffsetSegmentGenerator& segGen);
 
-  std::unique_ptr<OffsetSegmentGenerator> getSegGen(double dist);
+    std::unique_ptr<OffsetSegmentGenerator> getSegGen(double dist);
 
-  void computePointCurve(const geom::Coordinate& pt,
-                         OffsetSegmentGenerator& segGen);
+    void computePointCurve(const geom::Coordinate& pt,
+                           OffsetSegmentGenerator& segGen);
 
 
     // Declare type as noncopyable
diff --git a/include/geos/operation/buffer/OffsetCurveSetBuilder.h b/include/geos/operation/buffer/OffsetCurveSetBuilder.h
index 14ccc3f..5eba19c 100644
--- a/include/geos/operation/buffer/OffsetCurveSetBuilder.h
+++ b/include/geos/operation/buffer/OffsetCurveSetBuilder.h
@@ -31,26 +31,26 @@
 
 // Forward declarations
 namespace geos {
-	namespace geom {
-		class Geometry;
-		class CoordinateSequence;
-		class GeometryCollection;
-		class Point;
-		class LineString;
-		class LinearRing;
-		class Polygon;
-	}
-	namespace geomgraph {
-		class Label;
-	}
-	namespace noding {
-		class SegmentString;
-	}
-	namespace operation {
-		namespace buffer {
-			class OffsetCurveBuilder;
-		}
-	}
+namespace geom {
+class Geometry;
+class CoordinateSequence;
+class GeometryCollection;
+class Point;
+class LineString;
+class LinearRing;
+class Polygon;
+}
+namespace geomgraph {
+class Label;
+}
+namespace noding {
+class SegmentString;
+}
+namespace operation {
+namespace buffer {
+class OffsetCurveBuilder;
+}
+}
 }
 
 namespace geos {
@@ -71,103 +71,103 @@ class GEOS_DLL OffsetCurveSetBuilder {
 
 private:
 
-	// To keep track of newly-created Labels.
-	// Labels will be relesed by object dtor
-	std::vector<geomgraph::Label*> newLabels;
-
-	const geom::Geometry& inputGeom;
-
-	double distance;
-
-	OffsetCurveBuilder& curveBuilder;
-
-	/// The raw offset curves computed.
-	/// This class holds ownership of std::vector elements.
-	///
-	std::vector<noding::SegmentString*> curveList;
-
-	/**
-	 * Creates a noding::SegmentString for a coordinate list which is a raw
-	 * offset curve, and adds it to the list of buffer curves.
-	 * The noding::SegmentString is tagged with a geomgraph::Label
-	 * giving the topology of the curve.
-	 * The curve may be oriented in either direction.
-	 * If the curve is oriented CW, the locations will be:
-	 * - Left: Location.EXTERIOR
-	 * - Right: Location.INTERIOR
-	 *
-	 * @param coord is raw offset curve, ownership transferred here
-	 */
-	void addCurve(geom::CoordinateSequence *coord, int leftLoc,
-			int rightLoc);
-
-	void add(const geom::Geometry& g);
-
-	void addCollection(const geom::GeometryCollection *gc);
-
-	/**
-	 * Add a Point to the graph.
-	 */
-	void addPoint(const geom::Point *p);
-
-	void addLineString(const geom::LineString *line);
-
-	void addPolygon(const geom::Polygon *p);
-
-	/**
-	 * Add an offset curve for a polygon ring.
-	 * The side and left and right topological location arguments
-	 * assume that the ring is oriented CW.
-	 * If the ring is in the opposite orientation,
-	 * the left and right locations must be interchanged and the side
-	 * flipped.
-	 *
-	 * @param coord the coordinates of the ring (must not contain
-	 * repeated points)
-	 * @param offsetDistance the distance at which to create the buffer
-	 * @param side the side of the ring on which to construct the buffer
-	 *             line
-	 * @param cwLeftLoc the location on the L side of the ring
-	 *                  (if it is CW)
-	 * @param cwRightLoc the location on the R side of the ring
-	 *                   (if it is CW)
-	 */
-	void addPolygonRing(const geom::CoordinateSequence *coord,
-			double offsetDistance, int side, int cwLeftLoc,
-			int cwRightLoc);
-
-	/**
-	 * The ringCoord is assumed to contain no repeated points.
-	 * It may be degenerate (i.e. contain only 1, 2, or 3 points).
-	 * In this case it has no area, and hence has a minimum diameter of 0.
-	 *
-	 * @param ring
-	 * @param offsetDistance
-	 * @return
-	 */
-	bool isErodedCompletely(const geom::LinearRing* ringCoord,
-      double bufferDistance);
-
-	/**
-	 * Tests whether a triangular ring would be eroded completely by
-	 * the given buffer distance.
-	 * This is a precise test.  It uses the fact that the inner buffer
-	 * of a triangle converges on the inCentre of the triangle (the
-	 * point equidistant from all sides).  If the buffer distance is
-	 * greater than the distance of the inCentre from a side, the
-	 * triangle will be eroded completely.
-	 *
-	 * This test is important, since it removes a problematic case where
-	 * the buffer distance is slightly larger than the inCentre distance.
-	 * In this case the triangle buffer curve "inverts" with incorrect
-	 * topology, producing an incorrect hole in the buffer.
-	 *
-	 * @param triCoord
-	 * @param bufferDistance
-	 * @return
-	 */
-	bool isTriangleErodedCompletely(const geom::CoordinateSequence *triCoords,
-			double bufferDistance);
+    // To keep track of newly-created Labels.
+    // Labels will be relesed by object dtor
+    std::vector<geomgraph::Label*> newLabels;
+
+    const geom::Geometry& inputGeom;
+
+    double distance;
+
+    OffsetCurveBuilder& curveBuilder;
+
+    /// The raw offset curves computed.
+    /// This class holds ownership of std::vector elements.
+    ///
+    std::vector<noding::SegmentString*> curveList;
+
+    /**
+     * Creates a noding::SegmentString for a coordinate list which is a raw
+     * offset curve, and adds it to the list of buffer curves.
+     * The noding::SegmentString is tagged with a geomgraph::Label
+     * giving the topology of the curve.
+     * The curve may be oriented in either direction.
+     * If the curve is oriented CW, the locations will be:
+     * - Left: Location.EXTERIOR
+     * - Right: Location.INTERIOR
+     *
+     * @param coord is raw offset curve, ownership transferred here
+     */
+    void addCurve(geom::CoordinateSequence* coord, int leftLoc,
+                  int rightLoc);
+
+    void add(const geom::Geometry& g);
+
+    void addCollection(const geom::GeometryCollection* gc);
+
+    /**
+     * Add a Point to the graph.
+     */
+    void addPoint(const geom::Point* p);
+
+    void addLineString(const geom::LineString* line);
+
+    void addPolygon(const geom::Polygon* p);
+
+    /**
+     * Add an offset curve for a polygon ring.
+     * The side and left and right topological location arguments
+     * assume that the ring is oriented CW.
+     * If the ring is in the opposite orientation,
+     * the left and right locations must be interchanged and the side
+     * flipped.
+     *
+     * @param coord the coordinates of the ring (must not contain
+     * repeated points)
+     * @param offsetDistance the distance at which to create the buffer
+     * @param side the side of the ring on which to construct the buffer
+     *             line
+     * @param cwLeftLoc the location on the L side of the ring
+     *                  (if it is CW)
+     * @param cwRightLoc the location on the R side of the ring
+     *                   (if it is CW)
+     */
+    void addPolygonRing(const geom::CoordinateSequence* coord,
+                        double offsetDistance, int side, int cwLeftLoc,
+                        int cwRightLoc);
+
+    /**
+     * The ringCoord is assumed to contain no repeated points.
+     * It may be degenerate (i.e. contain only 1, 2, or 3 points).
+     * In this case it has no area, and hence has a minimum diameter of 0.
+     *
+     * @param ring
+     * @param offsetDistance
+     * @return
+     */
+    bool isErodedCompletely(const geom::LinearRing* ringCoord,
+                            double bufferDistance);
+
+    /**
+     * Tests whether a triangular ring would be eroded completely by
+     * the given buffer distance.
+     * This is a precise test.  It uses the fact that the inner buffer
+     * of a triangle converges on the inCentre of the triangle (the
+     * point equidistant from all sides).  If the buffer distance is
+     * greater than the distance of the inCentre from a side, the
+     * triangle will be eroded completely.
+     *
+     * This test is important, since it removes a problematic case where
+     * the buffer distance is slightly larger than the inCentre distance.
+     * In this case the triangle buffer curve "inverts" with incorrect
+     * topology, producing an incorrect hole in the buffer.
+     *
+     * @param triCoord
+     * @param bufferDistance
+     * @return
+     */
+    bool isTriangleErodedCompletely(const geom::CoordinateSequence* triCoords,
+                                    double bufferDistance);
 
     // Declare type as noncopyable
     OffsetCurveSetBuilder(const OffsetCurveSetBuilder& other) = delete;
@@ -175,31 +175,31 @@ private:
 
 public:
 
-	/// Constructor
-	OffsetCurveSetBuilder(const geom::Geometry& newInputGeom,
-		double newDistance, OffsetCurveBuilder& newCurveBuilder);
-
-	/// Destructor
-	~OffsetCurveSetBuilder();
-
-	/** \brief
-	 * Computes the set of raw offset curves for the buffer.
-	 *
-	 * Each offset curve has an attached {@link geomgraph::Label} indicating
-	 * its left and right location.
-	 *
-	 * @return a Collection of SegmentStrings representing the raw
-	 * buffer curves
-	 */
-	std::vector<noding::SegmentString*>& getCurves();
-
-	/// Add raw curves for a set of CoordinateSequences
-	//
-	/// @param lineList is a list of CoordinateSequence, ownership
-	///        of which is transferred here.
-	///
-	void addCurves(const std::vector<geom::CoordinateSequence*>& lineList,
-		int leftLoc, int rightLoc);
+    /// Constructor
+    OffsetCurveSetBuilder(const geom::Geometry& newInputGeom,
+                          double newDistance, OffsetCurveBuilder& newCurveBuilder);
+
+    /// Destructor
+    ~OffsetCurveSetBuilder();
+
+    /** \brief
+     * Computes the set of raw offset curves for the buffer.
+     *
+     * Each offset curve has an attached {@link geomgraph::Label} indicating
+     * its left and right location.
+     *
+     * @return a Collection of SegmentStrings representing the raw
+     * buffer curves
+     */
+    std::vector<noding::SegmentString*>& getCurves();
+
+    /// Add raw curves for a set of CoordinateSequences
+    //
+    /// @param lineList is a list of CoordinateSequence, ownership
+    ///        of which is transferred here.
+    ///
+    void addCurves(const std::vector<geom::CoordinateSequence*>& lineList,
+                   int leftLoc, int rightLoc);
 
 };
 
diff --git a/include/geos/operation/buffer/OffsetSegmentGenerator.h b/include/geos/operation/buffer/OffsetSegmentGenerator.h
index 2d2c8ab..f9974a6 100644
--- a/include/geos/operation/buffer/OffsetSegmentGenerator.h
+++ b/include/geos/operation/buffer/OffsetSegmentGenerator.h
@@ -36,10 +36,10 @@
 
 // Forward declarations
 namespace geos {
-  namespace geom {
-    class CoordinateSequence;
-    class PrecisionModel;
-  }
+namespace geom {
+class CoordinateSequence;
+class PrecisionModel;
+}
 }
 
 namespace geos {
@@ -62,285 +62,293 @@ class GEOS_DLL OffsetSegmentGenerator {
 
 public:
 
-  /*
-   * @param nBufParams buffer parameters, this object will
-   *                   keep a reference to the passed parameters
-   *                   so caller must make sure the object is
-   *                   kept alive for the whole lifetime of
-   *                   the buffer builder.
-   */
-  OffsetSegmentGenerator(const geom::PrecisionModel *newPrecisionModel,
-      const BufferParameters& bufParams, double distance);
-
-  /**
-   * Tests whether the input has a narrow concave angle
-   * (relative to the offset distance).
-   * In this case the generated offset curve will contain self-intersections
-   * and heuristic closing segments.
-   * This is expected behaviour in the case of buffer curves.
-   * For pure offset curves,
-   * the output needs to be further treated
-   * before it can be used.
-   *
-   * @return true if the input has a narrow concave angle
-   */
-  bool hasNarrowConcaveAngle() const
-  {
-    return _hasNarrowConcaveAngle;
-  }
-
-  void initSideSegments(const geom::Coordinate &nS1,
-                        const geom::Coordinate &nS2, int nSide);
-
-	/// Get coordinates by taking ownership of them
-	//
-	/// After this call, the coordinates reference in
-	/// this object are dropped. Calling twice will
-	/// segfault...
-	///
-	/// FIXME: refactor memory management of this
-	///
-	void getCoordinates(std::vector<geom::CoordinateSequence*>& to) {
-    to.push_back(segList.getCoordinates());
-  }
-
-	void closeRing() {
-    segList.closeRing();
-  }
-
-  /// Adds a CW circle around a point
-  void createCircle(const geom::Coordinate &p, double distance);
-
-  /// Adds a CW square around a point
-  void createSquare(const geom::Coordinate &p, double distance);
-
-  /// Add first offset point
-  void addFirstSegment()
-  {
-    segList.addPt(offset1.p0);
-  }
-
-  /// Add last offset point
-  void addLastSegment()
-  {
-    segList.addPt(offset1.p1);
-  }
-
-  void addNextSegment(const geom::Coordinate &p, bool addStartPoint);
-
-  /// \brief
-  /// Add an end cap around point p1, terminating a line segment
-  /// coming from p0
-  void addLineEndCap(const geom::Coordinate &p0,
-                     const geom::Coordinate &p1);
-
-  void addSegments(const geom::CoordinateSequence& pts, bool isForward)
-  {
-    segList.addPts(pts, isForward);
-  }
+    /*
+     * @param nBufParams buffer parameters, this object will
+     *                   keep a reference to the passed parameters
+     *                   so caller must make sure the object is
+     *                   kept alive for the whole lifetime of
+     *                   the buffer builder.
+     */
+    OffsetSegmentGenerator(const geom::PrecisionModel* newPrecisionModel,
+                           const BufferParameters& bufParams, double distance);
+
+    /**
+     * Tests whether the input has a narrow concave angle
+     * (relative to the offset distance).
+     * In this case the generated offset curve will contain self-intersections
+     * and heuristic closing segments.
+     * This is expected behaviour in the case of buffer curves.
+     * For pure offset curves,
+     * the output needs to be further treated
+     * before it can be used.
+     *
+     * @return true if the input has a narrow concave angle
+     */
+    bool
+    hasNarrowConcaveAngle() const
+    {
+        return _hasNarrowConcaveAngle;
+    }
+
+    void initSideSegments(const geom::Coordinate& nS1,
+                          const geom::Coordinate& nS2, int nSide);
+
+    /// Get coordinates by taking ownership of them
+    //
+    /// After this call, the coordinates reference in
+    /// this object are dropped. Calling twice will
+    /// segfault...
+    ///
+    /// FIXME: refactor memory management of this
+    ///
+    void
+    getCoordinates(std::vector<geom::CoordinateSequence*>& to)
+    {
+        to.push_back(segList.getCoordinates());
+    }
+
+    void
+    closeRing()
+    {
+        segList.closeRing();
+    }
+
+    /// Adds a CW circle around a point
+    void createCircle(const geom::Coordinate& p, double distance);
+
+    /// Adds a CW square around a point
+    void createSquare(const geom::Coordinate& p, double distance);
+
+    /// Add first offset point
+    void
+    addFirstSegment()
+    {
+        segList.addPt(offset1.p0);
+    }
+
+    /// Add last offset point
+    void
+    addLastSegment()
+    {
+        segList.addPt(offset1.p1);
+    }
+
+    void addNextSegment(const geom::Coordinate& p, bool addStartPoint);
+
+    /// \brief
+    /// Add an end cap around point p1, terminating a line segment
+    /// coming from p0
+    void addLineEndCap(const geom::Coordinate& p0,
+                       const geom::Coordinate& p1);
+
+    void
+    addSegments(const geom::CoordinateSequence& pts, bool isForward)
+    {
+        segList.addPts(pts, isForward);
+    }
 
 private:
 
-  /**
-   * Factor which controls how close offset segments can be to
-   * skip adding a filler or mitre.
-   */
-  static const double OFFSET_SEGMENT_SEPARATION_FACTOR; // 1.0E-3;
-
-  /**
-   * Factor which controls how close curve vertices on inside turns
-   * can be to be snapped
-   */
-  static const double INSIDE_TURN_VERTEX_SNAP_DISTANCE_FACTOR; // 1.0E-3;
-
-  /**
-   * Factor which controls how close curve vertices can be to be snapped
-   */
-  static const double CURVE_VERTEX_SNAP_DISTANCE_FACTOR; //  1.0E-6;
-
-  /**
-   * Factor which determines how short closing segs can be for round buffers
-   */
-  static const int MAX_CLOSING_SEG_LEN_FACTOR = 80;
-
-  /** \brief
-   * the max error of approximation (distance) between a quad segment and
-   * the true fillet curve
-   */
-  double maxCurveSegmentError; // 0.0
-
-  /** \brief
-   * The angle quantum with which to approximate a fillet curve
-   * (based on the input # of quadrant segments)
-   */
-  double filletAngleQuantum;
-
-  /// The Closing Segment Factor controls how long "closing
-  /// segments" are.  Closing segments are added at the middle of
-  /// inside corners to ensure a smoother boundary for the buffer
-  /// offset curve.  In some cases (particularly for round joins
-  /// with default-or-better quantization) the closing segments
-  /// can be made quite short.  This substantially improves
-  /// performance (due to fewer intersections being created).
-  ///
-  /// A closingSegFactor of 0 results in lines to the corner vertex.
-  /// A closingSegFactor of 1 results in lines halfway
-  /// to the corner vertex.
-  /// A closingSegFactor of 80 results in lines 1/81 of the way
-  /// to the corner vertex (this option is reasonable for the very
-  /// common default situation of round joins and quadrantSegs >= 8).
-  ///
-  /// The default is 1.
-  ///
-  int closingSegLengthFactor; // 1;
-
-  /// Owned by this object, destroyed by dtor
-  //
-  /// This actually gets created multiple times
-  /// and each of the old versions is pushed
-  /// to the ptLists std::vector to ensure all
-  /// created CoordinateSequences are properly
-  /// destroyed.
-  ///
-  OffsetSegmentString segList;
-
-  double distance;
-
-  const geom::PrecisionModel* precisionModel;
-
-  const BufferParameters& bufParams;
-
-  algorithm::LineIntersector li;
-
-  geom::Coordinate s0, s1, s2;
-
-  geom::LineSegment seg0;
-
-  geom::LineSegment seg1;
-
-  geom::LineSegment offset0;
-
-  geom::LineSegment offset1;
-
-  int side;
-
-  bool _hasNarrowConcaveAngle; // =false
-
-  void addCollinear(bool addStartPoint);
-
-  /// The mitre will be beveled if it exceeds the mitre ratio limit.
-  //
-  /// @param offset0 the first offset segment
-  /// @param offset1 the second offset segment
-  /// @param distance the offset distance
-  ///
-  void addMitreJoin(const geom::Coordinate& p,
-                    const geom::LineSegment& offset0,
-                    const geom::LineSegment& offset1,
-                    double distance);
-
-  /// Adds a limited mitre join connecting the two reflex offset segments.
-  //
-  /// A limited mitre is a mitre which is beveled at the distance
-  /// determined by the mitre ratio limit.
-  ///
-  /// @param offset0 the first offset segment
-  /// @param offset1 the second offset segment
-  /// @param distance the offset distance
-  /// @param mitreLimit the mitre limit ratio
-  ///
-  void addLimitedMitreJoin(
-                    const geom::LineSegment& offset0,
-                    const geom::LineSegment& offset1,
-                    double distance, double mitreLimit);
-
-  /// \brief
-  /// Adds a bevel join connecting the two offset segments
-  /// around a reflex corner.
-  //
-  /// @param offset0 the first offset segment
-  /// @param offset1 the second offset segment
-  ///
-  void addBevelJoin(const geom::LineSegment& offset0,
-                    const geom::LineSegment& offset1);
-
-  static const double PI; //  3.14159265358979
-
-  // Not in JTS, used for single-sided buffers
-  int endCapIndex;
-
-  void init(double newDistance);
-
-  /**
-   * Use a value which results in a potential distance error which is
-   * significantly less than the error due to
-   * the quadrant segment discretization.
-   * For QS = 8 a value of 100 is reasonable.
-   * This should produce a maximum of 1% distance error.
-   */
-  static const double SIMPLIFY_FACTOR; // 100.0;
-
-  /// Adds the offset points for an outside (convex) turn
-  //
-  /// @param orientation
-  /// @param addStartPoint
-  ///
-  void addOutsideTurn(int orientation, bool addStartPoint);
-
-  /// Adds the offset points for an inside (concave) turn
-  //
-  /// @param orientation
-  /// @param addStartPoint
-  ///
-  void addInsideTurn(int orientation, bool addStartPoint);
-
-  /** \brief
-   * Compute an offset segment for an input segment on a given
-   * side and at a given distance.
-   *
-   * The offset points are computed in full double precision,
-   * for accuracy.
-   *
-   * @param seg the segment to offset
-   * @param side the side of the segment the offset lies on
-   * @param distance the offset distance
-   * @param offset the points computed for the offset segment
-   */
-  void computeOffsetSegment(const geom::LineSegment& seg,
-                            int side, double distance,
-                            geom::LineSegment& offset);
-
-  /**
-   * Adds points for a circular fillet around a reflex corner.
-   *
-   * Adds the start and end points
-   *
-   * @param p base point of curve
-   * @param p0 start point of fillet curve
-   * @param p1 endpoint of fillet curve
-   * @param direction the orientation of the fillet
-   * @param radius the radius of the fillet
-   */
-  void addFillet(const geom::Coordinate &p, const geom::Coordinate &p0,
-                 const geom::Coordinate &p1,
-                 int direction, double radius);
-
-  /**
-   * Adds points for a circular fillet arc between two specified angles.
-   *
-   * The start and end point for the fillet are not added -
-   * the caller must add them if required.
-   *
-   * @param direction is -1 for a CW angle, 1 for a CCW angle
-   * @param radius the radius of the fillet
-   */
-  void addFillet(const geom::Coordinate &p, double startAngle,
-                 double endAngle, int direction, double radius);
+    /**
+     * Factor which controls how close offset segments can be to
+     * skip adding a filler or mitre.
+     */
+    static const double OFFSET_SEGMENT_SEPARATION_FACTOR; // 1.0E-3;
+
+    /**
+     * Factor which controls how close curve vertices on inside turns
+     * can be to be snapped
+     */
+    static const double INSIDE_TURN_VERTEX_SNAP_DISTANCE_FACTOR; // 1.0E-3;
+
+    /**
+     * Factor which controls how close curve vertices can be to be snapped
+     */
+    static const double CURVE_VERTEX_SNAP_DISTANCE_FACTOR; //  1.0E-6;
+
+    /**
+     * Factor which determines how short closing segs can be for round buffers
+     */
+    static const int MAX_CLOSING_SEG_LEN_FACTOR = 80;
+
+    /** \brief
+     * the max error of approximation (distance) between a quad segment and
+     * the true fillet curve
+     */
+    double maxCurveSegmentError; // 0.0
+
+    /** \brief
+     * The angle quantum with which to approximate a fillet curve
+     * (based on the input # of quadrant segments)
+     */
+    double filletAngleQuantum;
+
+    /// The Closing Segment Factor controls how long "closing
+    /// segments" are.  Closing segments are added at the middle of
+    /// inside corners to ensure a smoother boundary for the buffer
+    /// offset curve.  In some cases (particularly for round joins
+    /// with default-or-better quantization) the closing segments
+    /// can be made quite short.  This substantially improves
+    /// performance (due to fewer intersections being created).
+    ///
+    /// A closingSegFactor of 0 results in lines to the corner vertex.
+    /// A closingSegFactor of 1 results in lines halfway
+    /// to the corner vertex.
+    /// A closingSegFactor of 80 results in lines 1/81 of the way
+    /// to the corner vertex (this option is reasonable for the very
+    /// common default situation of round joins and quadrantSegs >= 8).
+    ///
+    /// The default is 1.
+    ///
+    int closingSegLengthFactor; // 1;
+
+    /// Owned by this object, destroyed by dtor
+    //
+    /// This actually gets created multiple times
+    /// and each of the old versions is pushed
+    /// to the ptLists std::vector to ensure all
+    /// created CoordinateSequences are properly
+    /// destroyed.
+    ///
+    OffsetSegmentString segList;
+
+    double distance;
+
+    const geom::PrecisionModel* precisionModel;
+
+    const BufferParameters& bufParams;
+
+    algorithm::LineIntersector li;
+
+    geom::Coordinate s0, s1, s2;
+
+    geom::LineSegment seg0;
+
+    geom::LineSegment seg1;
+
+    geom::LineSegment offset0;
+
+    geom::LineSegment offset1;
+
+    int side;
+
+    bool _hasNarrowConcaveAngle; // =false
+
+    void addCollinear(bool addStartPoint);
+
+    /// The mitre will be beveled if it exceeds the mitre ratio limit.
+    //
+    /// @param offset0 the first offset segment
+    /// @param offset1 the second offset segment
+    /// @param distance the offset distance
+    ///
+    void addMitreJoin(const geom::Coordinate& p,
+                      const geom::LineSegment& offset0,
+                      const geom::LineSegment& offset1,
+                      double distance);
+
+    /// Adds a limited mitre join connecting the two reflex offset segments.
+    //
+    /// A limited mitre is a mitre which is beveled at the distance
+    /// determined by the mitre ratio limit.
+    ///
+    /// @param offset0 the first offset segment
+    /// @param offset1 the second offset segment
+    /// @param distance the offset distance
+    /// @param mitreLimit the mitre limit ratio
+    ///
+    void addLimitedMitreJoin(
+        const geom::LineSegment& offset0,
+        const geom::LineSegment& offset1,
+        double distance, double mitreLimit);
+
+    /// \brief
+    /// Adds a bevel join connecting the two offset segments
+    /// around a reflex corner.
+    //
+    /// @param offset0 the first offset segment
+    /// @param offset1 the second offset segment
+    ///
+    void addBevelJoin(const geom::LineSegment& offset0,
+                      const geom::LineSegment& offset1);
+
+    static const double PI; //  3.14159265358979
+
+    // Not in JTS, used for single-sided buffers
+    int endCapIndex;
+
+    void init(double newDistance);
+
+    /**
+     * Use a value which results in a potential distance error which is
+     * significantly less than the error due to
+     * the quadrant segment discretization.
+     * For QS = 8 a value of 100 is reasonable.
+     * This should produce a maximum of 1% distance error.
+     */
+    static const double SIMPLIFY_FACTOR; // 100.0;
+
+    /// Adds the offset points for an outside (convex) turn
+    //
+    /// @param orientation
+    /// @param addStartPoint
+    ///
+    void addOutsideTurn(int orientation, bool addStartPoint);
+
+    /// Adds the offset points for an inside (concave) turn
+    //
+    /// @param orientation
+    /// @param addStartPoint
+    ///
+    void addInsideTurn(int orientation, bool addStartPoint);
+
+    /** \brief
+     * Compute an offset segment for an input segment on a given
+     * side and at a given distance.
+     *
+     * The offset points are computed in full double precision,
+     * for accuracy.
+     *
+     * @param seg the segment to offset
+     * @param side the side of the segment the offset lies on
+     * @param distance the offset distance
+     * @param offset the points computed for the offset segment
+     */
+    void computeOffsetSegment(const geom::LineSegment& seg,
+                              int side, double distance,
+                              geom::LineSegment& offset);
+
+    /**
+     * Adds points for a circular fillet around a reflex corner.
+     *
+     * Adds the start and end points
+     *
+     * @param p base point of curve
+     * @param p0 start point of fillet curve
+     * @param p1 endpoint of fillet curve
+     * @param direction the orientation of the fillet
+     * @param radius the radius of the fillet
+     */
+    void addFillet(const geom::Coordinate& p, const geom::Coordinate& p0,
+                   const geom::Coordinate& p1,
+                   int direction, double radius);
+
+    /**
+     * Adds points for a circular fillet arc between two specified angles.
+     *
+     * The start and end point for the fillet are not added -
+     * the caller must add them if required.
+     *
+     * @param direction is -1 for a CW angle, 1 for a CCW angle
+     * @param radius the radius of the fillet
+     */
+    void addFillet(const geom::Coordinate& p, double startAngle,
+                   double endAngle, int direction, double radius);
 private:
-	// An OffsetSegmentGenerator cannot be copied because of member "const BufferParameters& bufParams"
-	// Not declaring these functions triggers MSVC warning C4512: "assignment operator could not be generated"
-	OffsetSegmentGenerator(const OffsetSegmentGenerator&);
-	void operator=(const OffsetSegmentGenerator&);
+    // An OffsetSegmentGenerator cannot be copied because of member "const BufferParameters& bufParams"
+    // Not declaring these functions triggers MSVC warning C4512: "assignment operator could not be generated"
+    OffsetSegmentGenerator(const OffsetSegmentGenerator&);
+    void operator=(const OffsetSegmentGenerator&);
 
 };
 
diff --git a/include/geos/operation/buffer/OffsetSegmentString.h b/include/geos/operation/buffer/OffsetSegmentString.h
index 5a3859a..c5f699b 100644
--- a/include/geos/operation/buffer/OffsetSegmentString.h
+++ b/include/geos/operation/buffer/OffsetSegmentString.h
@@ -40,153 +40,173 @@ namespace buffer { // geos.operation.buffer
 ///
 /// @author Martin Davis
 ///
-class OffsetSegmentString
-{
+class OffsetSegmentString {
 
 private:
 
-	geom::CoordinateArraySequence* ptList;
-
-	const geom::PrecisionModel* precisionModel;
-
-	/** \brief
-	 * The distance below which two adjacent points on the curve
-	 * are considered to be coincident.
-	 *
-	 * This is chosen to be a small fraction of the offset distance.
-	 */
-	double minimumVertexDistance;
-
-	/** \brief
-	 * Tests whether the given point is redundant relative to the previous
-	 * point in the list (up to tolerance)
-	 *
-	 * @param pt
-	 * @return true if the point is redundant
-	 */
-	bool isRedundant(const geom::Coordinate& pt) const
-	{
-		if (ptList->size() < 1)
-			return false;
-		const geom::Coordinate& lastPt = ptList->back();
-		double ptDist = pt.distance(lastPt);
-		if (ptDist < minimumVertexDistance)
-			return true;
-		return false;
-	}
+    geom::CoordinateArraySequence* ptList;
+
+    const geom::PrecisionModel* precisionModel;
+
+    /** \brief
+     * The distance below which two adjacent points on the curve
+     * are considered to be coincident.
+     *
+     * This is chosen to be a small fraction of the offset distance.
+     */
+    double minimumVertexDistance;
+
+    /** \brief
+     * Tests whether the given point is redundant relative to the previous
+     * point in the list (up to tolerance)
+     *
+     * @param pt
+     * @return true if the point is redundant
+     */
+    bool
+    isRedundant(const geom::Coordinate& pt) const
+    {
+        if(ptList->size() < 1) {
+            return false;
+        }
+        const geom::Coordinate& lastPt = ptList->back();
+        double ptDist = pt.distance(lastPt);
+        if(ptDist < minimumVertexDistance) {
+            return true;
+        }
+        return false;
+    }
 
 
 public:
 
-	friend std::ostream& operator<< (std::ostream& os, const OffsetSegmentString& node);
-
-	OffsetSegmentString()
-		:
-		ptList(new geom::CoordinateArraySequence()),
-		precisionModel(nullptr),
-		minimumVertexDistance (0.0)
-	{
-	}
-
-	~OffsetSegmentString()
-	{
-		delete ptList;
-	}
-
-	void reset()
-	{
-		if ( ptList ) ptList->clear();
-		else ptList = new geom::CoordinateArraySequence();
-
-		precisionModel = nullptr;
-		minimumVertexDistance = 0.0;
-	}
-
-	void setPrecisionModel(const geom::PrecisionModel* nPrecisionModel)
-	{
-		precisionModel = nPrecisionModel;
-	}
-
-	void setMinimumVertexDistance(double nMinVertexDistance)
-	{
-		minimumVertexDistance = nMinVertexDistance;
-	}
-
-	void addPt(const geom::Coordinate& pt)
-	{
-		assert(precisionModel);
-
-		geom::Coordinate bufPt = pt;
-		precisionModel->makePrecise(bufPt);
-		// don't add duplicate (or near-duplicate) points
-		if (isRedundant(bufPt))
-		{
-			return;
-		}
-		// we ask to allow repeated as we checked this ourself
-		// (JTS uses a vector for ptList, not a CoordinateSequence,
-		// we should do the same)
-		ptList->add(bufPt, true);
-	}
-
-	void addPts(const geom::CoordinateSequence& pts, bool isForward)
-  {
-    if ( isForward ) {
-      for (size_t i=0, n=pts.size(); i<n; ++i) {
-        addPt(pts[i]);
-      }
-    } else {
-      for (size_t i=pts.size(); i>0; --i) {
-        addPt(pts[i-1]);
-      }
+    friend std::ostream& operator<< (std::ostream& os, const OffsetSegmentString& node);
+
+    OffsetSegmentString()
+        :
+        ptList(new geom::CoordinateArraySequence()),
+        precisionModel(nullptr),
+        minimumVertexDistance(0.0)
+    {
+    }
+
+    ~OffsetSegmentString()
+    {
+        delete ptList;
+    }
+
+    void
+    reset()
+    {
+        if(ptList) {
+            ptList->clear();
+        }
+        else {
+            ptList = new geom::CoordinateArraySequence();
+        }
+
+        precisionModel = nullptr;
+        minimumVertexDistance = 0.0;
+    }
+
+    void
+    setPrecisionModel(const geom::PrecisionModel* nPrecisionModel)
+    {
+        precisionModel = nPrecisionModel;
+    }
+
+    void
+    setMinimumVertexDistance(double nMinVertexDistance)
+    {
+        minimumVertexDistance = nMinVertexDistance;
+    }
+
+    void
+    addPt(const geom::Coordinate& pt)
+    {
+        assert(precisionModel);
+
+        geom::Coordinate bufPt = pt;
+        precisionModel->makePrecise(bufPt);
+        // don't add duplicate (or near-duplicate) points
+        if(isRedundant(bufPt)) {
+            return;
+        }
+        // we ask to allow repeated as we checked this ourself
+        // (JTS uses a vector for ptList, not a CoordinateSequence,
+        // we should do the same)
+        ptList->add(bufPt, true);
+    }
+
+    void
+    addPts(const geom::CoordinateSequence& pts, bool isForward)
+    {
+        if(isForward) {
+            for(size_t i = 0, n = pts.size(); i < n; ++i) {
+                addPt(pts[i]);
+            }
+        }
+        else {
+            for(size_t i = pts.size(); i > 0; --i) {
+                addPt(pts[i - 1]);
+            }
+        }
+    }
+
+    /// Check that points are a ring
+    //
+    /// add the startpoint again if they are not
+    void
+    closeRing()
+    {
+        if(ptList->size() < 1) {
+            return;
+        }
+        const geom::Coordinate& startPt = ptList->front();
+        const geom::Coordinate& lastPt = ptList->back();
+        if(startPt.equals(lastPt)) {
+            return;
+        }
+        // we ask to allow repeated as we checked this ourself
+        ptList->add(startPt, true);
+    }
+
+    /// Get coordinates by taking ownership of them
+    //
+    /// After this call, the coordinates reference in
+    /// this object are dropped. Calling twice will
+    /// segfault...
+    ///
+    /// FIXME: refactor memory management of this
+    ///
+    geom::CoordinateSequence*
+    getCoordinates()
+    {
+        closeRing();
+        geom::CoordinateSequence* ret = ptList;
+        ptList = nullptr;
+        return ret;
+    }
+
+    inline size_t
+    size() const
+    {
+        return ptList ? ptList->size() : 0 ;
     }
-  }
-
-	/// Check that points are a ring
-	//
-	/// add the startpoint again if they are not
-	void closeRing()
-	{
-		if (ptList->size() < 1) return;
-		const geom::Coordinate& startPt = ptList->front();
-		const geom::Coordinate& lastPt = ptList->back();
-		if (startPt.equals(lastPt)) return;
-		// we ask to allow repeated as we checked this ourself
-		ptList->add(startPt, true);
-	}
-
-	/// Get coordinates by taking ownership of them
-	//
-	/// After this call, the coordinates reference in
-	/// this object are dropped. Calling twice will
-	/// segfault...
-	///
-	/// FIXME: refactor memory management of this
-	///
-	geom::CoordinateSequence* getCoordinates()
-	{
-		closeRing();
-		geom::CoordinateSequence* ret = ptList;
-		ptList = nullptr;
-		return ret;
-	}
-
-	inline size_t size() const { return ptList ? ptList->size() : 0 ; }
 
 };
 
-inline std::ostream& operator<< (std::ostream& os,
-                                 const OffsetSegmentString& lst)
+inline std::ostream&
+operator<< (std::ostream& os,
+            const OffsetSegmentString& lst)
 {
-	if ( lst.ptList )
-	{
-		os << *(lst.ptList);
-	}
-	else
-	{
-		os << "empty (consumed?)";
-	}
-	return os;
+    if(lst.ptList) {
+        os << *(lst.ptList);
+    }
+    else {
+        os << "empty (consumed?)";
+    }
+    return os;
 }
 
 } // namespace geos.operation.buffer
diff --git a/include/geos/operation/buffer/RightmostEdgeFinder.h b/include/geos/operation/buffer/RightmostEdgeFinder.h
index b280b72..2500b61 100644
--- a/include/geos/operation/buffer/RightmostEdgeFinder.h
+++ b/include/geos/operation/buffer/RightmostEdgeFinder.h
@@ -27,11 +27,11 @@
 
 // Forward declarations
 namespace geos {
-	namespace geom {
-	}
-	namespace geomgraph {
-		class DirectedEdge;
-	}
+namespace geom {
+}
+namespace geomgraph {
+class DirectedEdge;
+}
 }
 
 namespace geos {
@@ -48,55 +48,55 @@ class GEOS_DLL RightmostEdgeFinder {
 
 private:
 
-	int minIndex;
+    int minIndex;
 
-	geom::Coordinate minCoord;
+    geom::Coordinate minCoord;
 
-	geomgraph::DirectedEdge *minDe;
+    geomgraph::DirectedEdge* minDe;
 
-	geomgraph::DirectedEdge *orientedDe;
+    geomgraph::DirectedEdge* orientedDe;
 
-	void findRightmostEdgeAtNode();
+    void findRightmostEdgeAtNode();
 
-	void findRightmostEdgeAtVertex();
+    void findRightmostEdgeAtVertex();
 
-	void checkForRightmostCoordinate(geomgraph::DirectedEdge *de);
+    void checkForRightmostCoordinate(geomgraph::DirectedEdge* de);
 
-	int getRightmostSide(geomgraph::DirectedEdge *de, int index);
+    int getRightmostSide(geomgraph::DirectedEdge* de, int index);
 
-	int getRightmostSideOfSegment(geomgraph::DirectedEdge *de, int i);
+    int getRightmostSideOfSegment(geomgraph::DirectedEdge* de, int i);
 
 public:
 
-	/** \brief
-	 * A RightmostEdgeFinder finds the geomgraph::DirectedEdge with the
-	 * rightmost coordinate.
-	 *
-	 * The geomgraph::DirectedEdge returned is guaranteed to have the R of
-	 * the world on its RHS.
-	 */
-	RightmostEdgeFinder();
+    /** \brief
+     * A RightmostEdgeFinder finds the geomgraph::DirectedEdge with the
+     * rightmost coordinate.
+     *
+     * The geomgraph::DirectedEdge returned is guaranteed to have the R of
+     * the world on its RHS.
+     */
+    RightmostEdgeFinder();
 
-	geomgraph::DirectedEdge* getEdge();
+    geomgraph::DirectedEdge* getEdge();
 
-	geom::Coordinate& getCoordinate();
+    geom::Coordinate& getCoordinate();
 
-	/// Note that only Forward DirectedEdges will be checked
-	void findEdge(std::vector<geomgraph::DirectedEdge*>* dirEdgeList);
+    /// Note that only Forward DirectedEdges will be checked
+    void findEdge(std::vector<geomgraph::DirectedEdge*>* dirEdgeList);
 };
 
 /*public*/
 inline geomgraph::DirectedEdge*
 RightmostEdgeFinder::getEdge()
 {
-	return orientedDe;
+    return orientedDe;
 }
 
 /*public*/
 inline geom::Coordinate&
 RightmostEdgeFinder::getCoordinate()
 {
-	return minCoord;
+    return minCoord;
 }
 
 
diff --git a/include/geos/operation/buffer/SubgraphDepthLocater.h b/include/geos/operation/buffer/SubgraphDepthLocater.h
index aea8238..b4e3ba6 100644
--- a/include/geos/operation/buffer/SubgraphDepthLocater.h
+++ b/include/geos/operation/buffer/SubgraphDepthLocater.h
@@ -27,18 +27,18 @@
 
 // Forward declarations
 namespace geos {
-	namespace geom {
-		class Coordinate;
-	}
-	namespace geomgraph {
-		class DirectedEdge;
-	}
-	namespace operation {
-		namespace buffer {
-			class BufferSubgraph;
-			class DepthSegment;
-		}
-	}
+namespace geom {
+class Coordinate;
+}
+namespace geomgraph {
+class DirectedEdge;
+}
+namespace operation {
+namespace buffer {
+class BufferSubgraph;
+class DepthSegment;
+}
+}
 }
 
 namespace geos {
@@ -60,57 +60,57 @@ class GEOS_DLL SubgraphDepthLocater {
 
 public:
 
-	SubgraphDepthLocater(std::vector<BufferSubgraph*> *newSubgraphs)
-		:
-		subgraphs(newSubgraphs)
-	{}
+    SubgraphDepthLocater(std::vector<BufferSubgraph*>* newSubgraphs)
+        :
+        subgraphs(newSubgraphs)
+    {}
 
-	~SubgraphDepthLocater() {}
+    ~SubgraphDepthLocater() {}
 
-	int getDepth(const geom::Coordinate &p);
+    int getDepth(const geom::Coordinate& p);
 
 private:
 
-	std::vector<BufferSubgraph*> *subgraphs;
-
-	geom::LineSegment seg;
-
-	/**
-	 * Finds all non-horizontal segments intersecting the stabbing line.
-	 * The stabbing line is the ray to the right of stabbingRayLeftPt.
-	 *
-	 * @param stabbingRayLeftPt the left-hand origin of the stabbing line
-	 * @param stabbedSegments a vector to which DepthSegments intersecting
-	 *        the stabbing line will be added.
-	 */
-	void findStabbedSegments(const geom::Coordinate &stabbingRayLeftPt,
-			std::vector<DepthSegment*>& stabbedSegments);
-
-	/**
-	 * Finds all non-horizontal segments intersecting the stabbing line
-	 * in the list of dirEdges.
-	 * The stabbing line is the ray to the right of stabbingRayLeftPt.
-	 *
-	 * @param stabbingRayLeftPt the left-hand origin of the stabbing line
-	 * @param stabbedSegments the current vector of DepthSegments
-	 *        intersecting the stabbing line will be added.
-	 */
-	void findStabbedSegments(const geom::Coordinate &stabbingRayLeftPt,
-			std::vector<geomgraph::DirectedEdge*> *dirEdges,
-			std::vector<DepthSegment*>& stabbedSegments);
-
-	/**
-	 * Finds all non-horizontal segments intersecting the stabbing line
-	 * in the input dirEdge.
-	 * The stabbing line is the ray to the right of stabbingRayLeftPt.
-	 *
-	 * @param stabbingRayLeftPt the left-hand origin of the stabbing line
-	 * @param stabbedSegments the current list of DepthSegments intersecting
-	 *        the stabbing line
-	 */
-	void findStabbedSegments(const geom::Coordinate &stabbingRayLeftPt,
-			geomgraph::DirectedEdge *dirEdge,
-			std::vector<DepthSegment*>& stabbedSegments);
+    std::vector<BufferSubgraph*>* subgraphs;
+
+    geom::LineSegment seg;
+
+    /**
+     * Finds all non-horizontal segments intersecting the stabbing line.
+     * The stabbing line is the ray to the right of stabbingRayLeftPt.
+     *
+     * @param stabbingRayLeftPt the left-hand origin of the stabbing line
+     * @param stabbedSegments a vector to which DepthSegments intersecting
+     *        the stabbing line will be added.
+     */
+    void findStabbedSegments(const geom::Coordinate& stabbingRayLeftPt,
+                             std::vector<DepthSegment*>& stabbedSegments);
+
+    /**
+     * Finds all non-horizontal segments intersecting the stabbing line
+     * in the list of dirEdges.
+     * The stabbing line is the ray to the right of stabbingRayLeftPt.
+     *
+     * @param stabbingRayLeftPt the left-hand origin of the stabbing line
+     * @param stabbedSegments the current vector of DepthSegments
+     *        intersecting the stabbing line will be added.
+     */
+    void findStabbedSegments(const geom::Coordinate& stabbingRayLeftPt,
+                             std::vector<geomgraph::DirectedEdge*>* dirEdges,
+                             std::vector<DepthSegment*>& stabbedSegments);
+
+    /**
+     * Finds all non-horizontal segments intersecting the stabbing line
+     * in the input dirEdge.
+     * The stabbing line is the ray to the right of stabbingRayLeftPt.
+     *
+     * @param stabbingRayLeftPt the left-hand origin of the stabbing line
+     * @param stabbedSegments the current list of DepthSegments intersecting
+     *        the stabbing line
+     */
+    void findStabbedSegments(const geom::Coordinate& stabbingRayLeftPt,
+                             geomgraph::DirectedEdge* dirEdge,
+                             std::vector<DepthSegment*>& stabbedSegments);
 
 };
 
diff --git a/include/geos/operation/distance/ConnectedElementLocationFilter.h b/include/geos/operation/distance/ConnectedElementLocationFilter.h
index 046465e..683a0e2 100644
--- a/include/geos/operation/distance/ConnectedElementLocationFilter.h
+++ b/include/geos/operation/distance/ConnectedElementLocationFilter.h
@@ -27,14 +27,14 @@
 
 // Forward declarations
 namespace geos {
-	namespace geom {
-		class Geometry;
-	}
-	namespace operation {
-		namespace distance {
-			class GeometryLocation;
-		}
-	}
+namespace geom {
+class Geometry;
+}
+namespace operation {
+namespace distance {
+class GeometryLocation;
+}
+}
 }
 
 
@@ -52,24 +52,24 @@ namespace distance { // geos::operation::distance
 class GEOS_DLL ConnectedElementLocationFilter: public geom::GeometryFilter {
 private:
 
-	std::vector<GeometryLocation*> *locations;
+    std::vector<GeometryLocation*>* locations;
 
 public:
-	/**
-	 * Returns a list containing a point from each Polygon, LineString, and Point
-	 * found inside the specified geometry. Thus, if the specified geometry is
-	 * not a GeometryCollection, an empty list will be returned. The elements of the list
-	 * are {@link com.vividsolutions.jts.operation.distance.GeometryLocation}s.
-	 */
-	static std::vector<GeometryLocation*>* getLocations(const geom::Geometry *geom);
-
-	ConnectedElementLocationFilter(std::vector<GeometryLocation*> *newLocations)
-		:
-		locations(newLocations)
-	{}
-
-	void filter_ro(const geom::Geometry *geom) override;
-	void filter_rw(geom::Geometry *geom) override;
+    /**
+     * Returns a list containing a point from each Polygon, LineString, and Point
+     * found inside the specified geometry. Thus, if the specified geometry is
+     * not a GeometryCollection, an empty list will be returned. The elements of the list
+     * are {@link com.vividsolutions.jts.operation.distance.GeometryLocation}s.
+     */
+    static std::vector<GeometryLocation*>* getLocations(const geom::Geometry* geom);
+
+    ConnectedElementLocationFilter(std::vector<GeometryLocation*>* newLocations)
+        :
+        locations(newLocations)
+    {}
+
+    void filter_ro(const geom::Geometry* geom) override;
+    void filter_rw(geom::Geometry* geom) override;
 };
 
 
diff --git a/include/geos/operation/distance/ConnectedElementPointFilter.h b/include/geos/operation/distance/ConnectedElementPointFilter.h
index bf2de98..660e027 100644
--- a/include/geos/operation/distance/ConnectedElementPointFilter.h
+++ b/include/geos/operation/distance/ConnectedElementPointFilter.h
@@ -27,10 +27,10 @@
 
 // Forward declarations
 namespace geos {
-	namespace geom {
-		class Coordinate;
-		class Geometry;
-	}
+namespace geom {
+class Coordinate;
+class Geometry;
+}
 }
 
 
@@ -47,24 +47,24 @@ namespace distance { // geos::operation::distance
 class GEOS_DLL ConnectedElementPointFilter: public geom::GeometryFilter {
 
 private:
-	std::vector<const geom::Coordinate*> *pts;
+    std::vector<const geom::Coordinate*>* pts;
 
 public:
-	/**
-	 * Returns a list containing a Coordinate from each Polygon, LineString, and Point
-	 * found inside the specified geometry. Thus, if the specified geometry is
-	 * not a GeometryCollection, an empty list will be returned.
-	 */
-	static std::vector<const geom::Coordinate*>* getCoordinates(const geom::Geometry *geom);
+    /**
+     * Returns a list containing a Coordinate from each Polygon, LineString, and Point
+     * found inside the specified geometry. Thus, if the specified geometry is
+     * not a GeometryCollection, an empty list will be returned.
+     */
+    static std::vector<const geom::Coordinate*>* getCoordinates(const geom::Geometry* geom);
 
-	ConnectedElementPointFilter(std::vector<const geom::Coordinate*> *newPts)
-		:
-		pts(newPts)
-	{}
+    ConnectedElementPointFilter(std::vector<const geom::Coordinate*>* newPts)
+        :
+        pts(newPts)
+    {}
 
-	void filter_ro(const geom::Geometry *geom) override;
+    void filter_ro(const geom::Geometry* geom) override;
 
-	//void filter_rw(geom::Geometry * /*geom*/) {};
+    //void filter_rw(geom::Geometry * /*geom*/) {};
 };
 
 
diff --git a/include/geos/operation/distance/DistanceOp.h b/include/geos/operation/distance/DistanceOp.h
index c9f64b4..e8f45cc 100644
--- a/include/geos/operation/distance/DistanceOp.h
+++ b/include/geos/operation/distance/DistanceOp.h
@@ -34,19 +34,19 @@
 
 // Forward declarations
 namespace geos {
-	namespace geom {
-		class Coordinate;
-		class Polygon;
-		class LineString;
-		class Point;
-		class Geometry;
-		class CoordinateSequence;
-	}
-	namespace operation {
-		namespace distance {
-			class GeometryLocation;
-		}
-	}
+namespace geom {
+class Coordinate;
+class Polygon;
+class LineString;
+class Point;
+class Geometry;
+class CoordinateSequence;
+}
+namespace operation {
+namespace distance {
+class GeometryLocation;
+}
+}
 }
 
 
@@ -74,199 +74,199 @@ namespace distance { // geos::operation::distance
  */
 class GEOS_DLL DistanceOp {
 public:
-	/**
-	 * \brief
-	 * Compute the distance between the nearest points of two geometries.
-	 *
-	 * @param g0 a {@link Geometry}
-	 * @param g1 another {@link Geometry}
-	 * @return the distance between the geometries
-	 * @return 0 if either input geometry is empty
-	 * @throws IllegalArgumentException if either input geometry is null
-	 */
-	static double distance(const geom::Geometry& g0,
-	                       const geom::Geometry& g1);
-
-	/// @deprecated, use the version taking references
-	static double distance(const geom::Geometry *g0,
-	                        const geom::Geometry *g1);
-
-	/**
-	 * \brief
-	 * Test whether two geometries lie within a given distance of
-	 * each other.
-	 *
-	 * @param g0 a {@link Geometry}
-	 * @param g1 another {@link Geometry}
-	 * @param distance the distance to test
-	 * @return true if g0.distance(g1) <= distance
-	 */
-	static bool isWithinDistance(const geom::Geometry& g0,
-	                             const geom::Geometry& g1,
-	                                            double distance);
-
-	/**
-	 * Compute the the nearest points of two geometries.
-	 *
-	 * The points are presented in the same order as the input Geometries.
-	 *
-	 * @param g0 a {@link Geometry}
-	 * @param g1 another {@link Geometry}
-	 *
-	 * @return the nearest points in the geometries, ownership to caller.
-	 *         A NULL return means one of the geometries is empty.
-	 *
-	 */
-	static geom::CoordinateSequence* nearestPoints(
-	                                        const geom::Geometry *g0,
-	                                        const geom::Geometry *g1);
-
-	/**
-	 * Compute the the closest points of two geometries.
-	 *
-	 * The points are presented in the same order as the input Geometries.
-	 *
-	 * @param g0 a {@link Geometry}
-	 * @param g1 another {@link Geometry}
-	 *
-	 * @return the closest points in the geometries, ownership to caller.
-	 *         A NULL return means one of the geometries is empty.
-	 *
-	 * @deprecated renamed to nearestPoints
-	 */
-	static geom::CoordinateSequence* closestPoints(
-	                                        const geom::Geometry *g0,
-	                                        const geom::Geometry *g1);
-
-	/// @deprecated use the one taking references
-	DistanceOp(const geom::Geometry *g0, const geom::Geometry *g1);
-
-	/**
-	 * \brief
-	 * Constructs a DistanceOp that computes the distance and
-	 * nearest points between the two specified geometries.
-	 *
-	 * @param g0 a Geometry
-	 * @param g1 a Geometry
-	 */
-	DistanceOp(const geom::Geometry& g0, const geom::Geometry& g1);
-
-	/**
-	 * \brief
-	 * Constructs a DistanceOp that computes the distance and nearest
-	 * points between the two specified geometries.
-	 *
-	 * @param g0 a Geometry
-	 * @param g1 a Geometry
-	 * @param terminateDistance the distance on which to terminate
-	 *                          the search
-	 */
-	DistanceOp(const geom::Geometry& g0, const geom::Geometry& g1,
-	                                      double terminateDistance);
-
-	~DistanceOp();
-
-	/**
-	 * Report the distance between the closest points on the input geometries.
-	 *
-	 * @return the distance between the geometries
-	 */
-	double distance();
-
-	/**
-	 * Report the coordinates of the closest points in the input geometries.
-	 * The points are presented in the same order as the input Geometries.
-	 *
-	 * @return a pair of {@link Coordinate}s of the closest points
-	 *         as a newly allocated object (ownership to caller)
-	 *
-	 * @deprecated renamed to nearestPoints
-	 */
-	geom::CoordinateSequence* closestPoints();
-
-	/**
-	 * Report the coordinates of the nearest points in the input geometries.
-	 * The points are presented in the same order as the input Geometries.
-	 *
-	 * @return a pair of {@link Coordinate}s of the nearest points
-	 *         as a newly allocated object (ownership to caller)
-	 *
-	 */
-	geom::CoordinateSequence* nearestPoints();
+    /**
+     * \brief
+     * Compute the distance between the nearest points of two geometries.
+     *
+     * @param g0 a {@link Geometry}
+     * @param g1 another {@link Geometry}
+     * @return the distance between the geometries
+     * @return 0 if either input geometry is empty
+     * @throws IllegalArgumentException if either input geometry is null
+     */
+    static double distance(const geom::Geometry& g0,
+                           const geom::Geometry& g1);
+
+    /// @deprecated, use the version taking references
+    static double distance(const geom::Geometry* g0,
+                           const geom::Geometry* g1);
+
+    /**
+     * \brief
+     * Test whether two geometries lie within a given distance of
+     * each other.
+     *
+     * @param g0 a {@link Geometry}
+     * @param g1 another {@link Geometry}
+     * @param distance the distance to test
+     * @return true if g0.distance(g1) <= distance
+     */
+    static bool isWithinDistance(const geom::Geometry& g0,
+                                 const geom::Geometry& g1,
+                                 double distance);
+
+    /**
+     * Compute the the nearest points of two geometries.
+     *
+     * The points are presented in the same order as the input Geometries.
+     *
+     * @param g0 a {@link Geometry}
+     * @param g1 another {@link Geometry}
+     *
+     * @return the nearest points in the geometries, ownership to caller.
+     *         A NULL return means one of the geometries is empty.
+     *
+     */
+    static geom::CoordinateSequence* nearestPoints(
+        const geom::Geometry* g0,
+        const geom::Geometry* g1);
+
+    /**
+     * Compute the the closest points of two geometries.
+     *
+     * The points are presented in the same order as the input Geometries.
+     *
+     * @param g0 a {@link Geometry}
+     * @param g1 another {@link Geometry}
+     *
+     * @return the closest points in the geometries, ownership to caller.
+     *         A NULL return means one of the geometries is empty.
+     *
+     * @deprecated renamed to nearestPoints
+     */
+    static geom::CoordinateSequence* closestPoints(
+        const geom::Geometry* g0,
+        const geom::Geometry* g1);
+
+    /// @deprecated use the one taking references
+    DistanceOp(const geom::Geometry* g0, const geom::Geometry* g1);
+
+    /**
+     * \brief
+     * Constructs a DistanceOp that computes the distance and
+     * nearest points between the two specified geometries.
+     *
+     * @param g0 a Geometry
+     * @param g1 a Geometry
+     */
+    DistanceOp(const geom::Geometry& g0, const geom::Geometry& g1);
+
+    /**
+     * \brief
+     * Constructs a DistanceOp that computes the distance and nearest
+     * points between the two specified geometries.
+     *
+     * @param g0 a Geometry
+     * @param g1 a Geometry
+     * @param terminateDistance the distance on which to terminate
+     *                          the search
+     */
+    DistanceOp(const geom::Geometry& g0, const geom::Geometry& g1,
+               double terminateDistance);
+
+    ~DistanceOp();
+
+    /**
+     * Report the distance between the closest points on the input geometries.
+     *
+     * @return the distance between the geometries
+     */
+    double distance();
+
+    /**
+     * Report the coordinates of the closest points in the input geometries.
+     * The points are presented in the same order as the input Geometries.
+     *
+     * @return a pair of {@link Coordinate}s of the closest points
+     *         as a newly allocated object (ownership to caller)
+     *
+     * @deprecated renamed to nearestPoints
+     */
+    geom::CoordinateSequence* closestPoints();
+
+    /**
+     * Report the coordinates of the nearest points in the input geometries.
+     * The points are presented in the same order as the input Geometries.
+     *
+     * @return a pair of {@link Coordinate}s of the nearest points
+     *         as a newly allocated object (ownership to caller)
+     *
+     */
+    geom::CoordinateSequence* nearestPoints();
 
 private:
 
-	/**
-	 * Report the locations of the closest points in the input geometries.
-	 * The locations are presented in the same order as the input
-	 * Geometries.
-	 *
-	 * @return a pair of {@link GeometryLocation}s for the closest points.
-	 *         Ownership of returned object is left to this instance and
-	 *         it's reference will be alive for the whole lifetime of it.
-	 *
-	 * NOTE: this is public in JTS, but we aim at API reduction here...
-	 *
-	 */
-	std::vector<GeometryLocation*>* nearestLocations();
-
-	// input
-	std::array<geom::Geometry const*, 2> geom;
-	double terminateDistance;
-
-	// working
-	algorithm::PointLocator ptLocator;
-	// TODO: use unique_ptr
-	std::vector<GeometryLocation*> *minDistanceLocation;
-	double minDistance;
-
-	// memory management
-	std::vector<geom::Coordinate *> newCoords;
-
-
-	void updateMinDistance(std::vector<GeometryLocation*>& locGeom,
-	                       bool flip);
-
-	void computeMinDistance();
-
-	void computeContainmentDistance();
-
-	void computeInside(std::vector<GeometryLocation*> *locs,
-			const std::vector<const geom::Polygon*>& polys,
-			std::vector<GeometryLocation*> *locPtPoly);
-
-	void computeInside(GeometryLocation *ptLoc,
-			const geom::Polygon *poly,
-			std::vector<GeometryLocation*> *locPtPoly);
-
-	/**
-	 * Computes distance between facets (lines and points)
-	 * of input geometries.
-	 */
-	void computeFacetDistance();
-
-	void computeMinDistanceLines(
-			const std::vector<const geom::LineString*>& lines0,
-			const std::vector<const geom::LineString*>& lines1,
-			std::vector<GeometryLocation*>& locGeom);
-
-	void computeMinDistancePoints(
-			const std::vector<const geom::Point*>& points0,
-			const std::vector<const geom::Point*>& points1,
-			std::vector<GeometryLocation*>& locGeom);
-
-	void computeMinDistanceLinesPoints(
-			const std::vector<const geom::LineString*>& lines0,
-			const std::vector<const geom::Point*>& points1,
-			std::vector<GeometryLocation*>& locGeom);
-
-	void computeMinDistance(const geom::LineString *line0,
-			const geom::LineString *line1,
-			std::vector<GeometryLocation*>& locGeom);
-
-	void computeMinDistance(const geom::LineString *line,
-			const geom::Point *pt,
-			std::vector<GeometryLocation*>& locGeom);
+    /**
+     * Report the locations of the closest points in the input geometries.
+     * The locations are presented in the same order as the input
+     * Geometries.
+     *
+     * @return a pair of {@link GeometryLocation}s for the closest points.
+     *         Ownership of returned object is left to this instance and
+     *         it's reference will be alive for the whole lifetime of it.
+     *
+     * NOTE: this is public in JTS, but we aim at API reduction here...
+     *
+     */
+    std::vector<GeometryLocation*>* nearestLocations();
+
+    // input
+    std::array<geom::Geometry const*, 2> geom;
+    double terminateDistance;
+
+    // working
+    algorithm::PointLocator ptLocator;
+    // TODO: use unique_ptr
+    std::vector<GeometryLocation*>* minDistanceLocation;
+    double minDistance;
+
+    // memory management
+    std::vector<geom::Coordinate*> newCoords;
+
+
+    void updateMinDistance(std::vector<GeometryLocation*>& locGeom,
+                           bool flip);
+
+    void computeMinDistance();
+
+    void computeContainmentDistance();
+
+    void computeInside(std::vector<GeometryLocation*>* locs,
+                       const std::vector<const geom::Polygon*>& polys,
+                       std::vector<GeometryLocation*>* locPtPoly);
+
+    void computeInside(GeometryLocation* ptLoc,
+                       const geom::Polygon* poly,
+                       std::vector<GeometryLocation*>* locPtPoly);
+
+    /**
+     * Computes distance between facets (lines and points)
+     * of input geometries.
+     */
+    void computeFacetDistance();
+
+    void computeMinDistanceLines(
+        const std::vector<const geom::LineString*>& lines0,
+        const std::vector<const geom::LineString*>& lines1,
+        std::vector<GeometryLocation*>& locGeom);
+
+    void computeMinDistancePoints(
+        const std::vector<const geom::Point*>& points0,
+        const std::vector<const geom::Point*>& points1,
+        std::vector<GeometryLocation*>& locGeom);
+
+    void computeMinDistanceLinesPoints(
+        const std::vector<const geom::LineString*>& lines0,
+        const std::vector<const geom::Point*>& points1,
+        std::vector<GeometryLocation*>& locGeom);
+
+    void computeMinDistance(const geom::LineString* line0,
+                            const geom::LineString* line1,
+                            std::vector<GeometryLocation*>& locGeom);
+
+    void computeMinDistance(const geom::LineString* line,
+                            const geom::Point* pt,
+                            std::vector<GeometryLocation*>& locGeom);
 };
 
 
diff --git a/include/geos/operation/distance/FacetSequence.h b/include/geos/operation/distance/FacetSequence.h
index 1dbc667..b3790fc 100644
--- a/include/geos/operation/distance/FacetSequence.h
+++ b/include/geos/operation/distance/FacetSequence.h
@@ -24,41 +24,41 @@
 #include <geos/geom/Coordinate.h>
 
 namespace geos {
-    namespace operation {
-        namespace distance {
-            class FacetSequence {
-            private:
-                const geom::CoordinateSequence *pts;
-                const size_t start;
-                const size_t end;
+namespace operation {
+namespace distance {
+class FacetSequence {
+private:
+    const geom::CoordinateSequence* pts;
+    const size_t start;
+    const size_t end;
 
-                /* Unlike JTS, we store the envelope in the FacetSequence so that it has a clear owner.  This is
-                 * helpful when making a tree of FacetSequence objects (FacetSequenceTreeBuilder)
-                 * */
-                geom::Envelope env;
+    /* Unlike JTS, we store the envelope in the FacetSequence so that it has a clear owner.  This is
+     * helpful when making a tree of FacetSequence objects (FacetSequenceTreeBuilder)
+     * */
+    geom::Envelope env;
 
-                double computeLineLineDistance(const FacetSequence & facetSeq) const;
+    double computeLineLineDistance(const FacetSequence& facetSeq) const;
 
-                double computePointLineDistance(const geom::Coordinate & pt, const FacetSequence & facetSeq) const;
+    double computePointLineDistance(const geom::Coordinate& pt, const FacetSequence& facetSeq) const;
 
-                void computeEnvelope();
+    void computeEnvelope();
 
-            public:
-                const geom::Envelope * getEnvelope() const;
+public:
+    const geom::Envelope* getEnvelope() const;
 
-                const geom::Coordinate * getCoordinate(size_t index) const;
+    const geom::Coordinate* getCoordinate(size_t index) const;
 
-                size_t size() const;
+    size_t size() const;
 
-                bool isPoint() const;
+    bool isPoint() const;
 
-                double distance(const FacetSequence & facetSeq) const;
+    double distance(const FacetSequence& facetSeq) const;
 
-                FacetSequence(const geom::CoordinateSequence *pts, size_t start, size_t end);
-            };
+    FacetSequence(const geom::CoordinateSequence* pts, size_t start, size_t end);
+};
 
-        }
-    }
+}
+}
 }
 
 #endif //GEOS_OPERATION_DISTANCE_FACETSEQUENCE_H
diff --git a/include/geos/operation/distance/FacetSequenceTreeBuilder.h b/include/geos/operation/distance/FacetSequenceTreeBuilder.h
index 8f4ae54..4dc003d 100644
--- a/include/geos/operation/distance/FacetSequenceTreeBuilder.h
+++ b/include/geos/operation/distance/FacetSequenceTreeBuilder.h
@@ -25,24 +25,24 @@
 #include <geos/operation/distance/FacetSequence.h>
 
 namespace geos {
-    namespace operation {
-        namespace distance {
-            class GEOS_DLL FacetSequenceTreeBuilder {
-            private:
-                // 6 seems to be a good facet sequence size
-                static const int FACET_SEQUENCE_SIZE = 6;
+namespace operation {
+namespace distance {
+class GEOS_DLL FacetSequenceTreeBuilder {
+private:
+    // 6 seems to be a good facet sequence size
+    static const int FACET_SEQUENCE_SIZE = 6;
 
-                // Seems to be better to use a minimum node capacity
-                static const int STR_TREE_NODE_CAPACITY = 4;
+    // Seems to be better to use a minimum node capacity
+    static const int STR_TREE_NODE_CAPACITY = 4;
 
-                static void addFacetSequences(const geom::CoordinateSequence* pts, std::vector<FacetSequence*> & sections);
-                static std::vector<FacetSequence*> * computeFacetSequences(const geom::Geometry* g);
+    static void addFacetSequences(const geom::CoordinateSequence* pts, std::vector<FacetSequence*>& sections);
+    static std::vector<FacetSequence*>* computeFacetSequences(const geom::Geometry* g);
 
-            public:
-                static geos::index::strtree::STRtree* build(const geom::Geometry* g);
-            };
-        }
-    }
+public:
+    static geos::index::strtree::STRtree* build(const geom::Geometry* g);
+};
+}
+}
 }
 
 #endif //GEOS_FACETSEQUENCETREEBUILDER_H
diff --git a/include/geos/operation/distance/GeometryLocation.h b/include/geos/operation/distance/GeometryLocation.h
index f787fd4..a8a3913 100644
--- a/include/geos/operation/distance/GeometryLocation.h
+++ b/include/geos/operation/distance/GeometryLocation.h
@@ -25,9 +25,9 @@
 
 // Forward declarations
 namespace geos {
-	namespace geom {
-		class Geometry;
-	}
+namespace geom {
+class Geometry;
+}
 }
 
 
@@ -49,67 +49,67 @@ namespace distance { // geos::operation::distance
  */
 class GEOS_DLL GeometryLocation {
 private:
-	const geom::Geometry *component;
-	size_t segIndex;
-	bool inside_area;
-	geom::Coordinate pt;
+    const geom::Geometry* component;
+    size_t segIndex;
+    bool inside_area;
+    geom::Coordinate pt;
 public:
-	/** \brief
-	 * A Special value of segmentIndex used for locations
-	 * inside area geometries.
-	 *
-	 * These locations are not located on a segment,
-	 * and thus do not have an associated segment index.
-	 */
-	static const int INSIDE_AREA = -1;
-
-	/** \brief
-	 * Constructs a GeometryLocation specifying a point on a geometry,
-	 * as well as the segment that the point is on (or INSIDE_AREA if
-	 * the point is not on a segment).
-	 *
-	 * @param component the component of the geometry containing the point
-	 * @param segIndex the segment index of the location, or INSIDE_AREA
-	 * @param pt the coordinate of the location
-	 */
-	GeometryLocation(const geom::Geometry *component,
-			size_t segIndex, const geom::Coordinate &pt);
-
-	/** \brief
-	 * Constructs a GeometryLocation specifying a point inside an
-	 * area geometry.
-	 *
-	 * @param component the component of the geometry containing the point
-	 * @param pt the coordinate of the location
-	 */
-	GeometryLocation(const geom::Geometry *component,
-	                      const geom::Coordinate &pt);
-
-	/**
-	 * Returns the geometry component on (or in) which this location occurs.
-	 */
-	const geom::Geometry* getGeometryComponent();
-
-	/**
-	 * Returns the segment index for this location.
-	 *
-	 * If the location is inside an
-	 * area, the index will have the value INSIDE_AREA;
-	 *
-	 * @return the segment index for the location, or INSIDE_AREA
-	 */
-	size_t getSegmentIndex();
-
-	/**
-	 * Returns the geom::Coordinate of this location.
-	 */
-	geom::Coordinate& getCoordinate();
-
-	/** \brief
-	 * Tests whether this location represents a point
-	 * inside an area geometry.
-	 */
-	bool isInsideArea();
+    /** \brief
+     * A Special value of segmentIndex used for locations
+     * inside area geometries.
+     *
+     * These locations are not located on a segment,
+     * and thus do not have an associated segment index.
+     */
+    static const int INSIDE_AREA = -1;
+
+    /** \brief
+     * Constructs a GeometryLocation specifying a point on a geometry,
+     * as well as the segment that the point is on (or INSIDE_AREA if
+     * the point is not on a segment).
+     *
+     * @param component the component of the geometry containing the point
+     * @param segIndex the segment index of the location, or INSIDE_AREA
+     * @param pt the coordinate of the location
+     */
+    GeometryLocation(const geom::Geometry* component,
+                     size_t segIndex, const geom::Coordinate& pt);
+
+    /** \brief
+     * Constructs a GeometryLocation specifying a point inside an
+     * area geometry.
+     *
+     * @param component the component of the geometry containing the point
+     * @param pt the coordinate of the location
+     */
+    GeometryLocation(const geom::Geometry* component,
+                     const geom::Coordinate& pt);
+
+    /**
+     * Returns the geometry component on (or in) which this location occurs.
+     */
+    const geom::Geometry* getGeometryComponent();
+
+    /**
+     * Returns the segment index for this location.
+     *
+     * If the location is inside an
+     * area, the index will have the value INSIDE_AREA;
+     *
+     * @return the segment index for the location, or INSIDE_AREA
+     */
+    size_t getSegmentIndex();
+
+    /**
+     * Returns the geom::Coordinate of this location.
+     */
+    geom::Coordinate& getCoordinate();
+
+    /** \brief
+     * Tests whether this location represents a point
+     * inside an area geometry.
+     */
+    bool isInsideArea();
 };
 
 } // namespace geos::operation::distance
diff --git a/include/geos/operation/distance/IndexedFacetDistance.h b/include/geos/operation/distance/IndexedFacetDistance.h
index 5068b33..257d802 100644
--- a/include/geos/operation/distance/IndexedFacetDistance.h
+++ b/include/geos/operation/distance/IndexedFacetDistance.h
@@ -22,26 +22,26 @@
 #include <geos/operation/distance/FacetSequenceTreeBuilder.h>
 
 namespace geos {
-    namespace operation {
-        namespace distance {
-            class GEOS_DLL IndexedFacetDistance {
-            public:
-                IndexedFacetDistance(const geom::Geometry * g) :
-                        cachedTree(FacetSequenceTreeBuilder::build(g))
-                        {}
+namespace operation {
+namespace distance {
+class GEOS_DLL IndexedFacetDistance {
+public:
+    IndexedFacetDistance(const geom::Geometry* g) :
+        cachedTree(FacetSequenceTreeBuilder::build(g))
+    {}
 
-                static double distance(const geom::Geometry * g1, const geom::Geometry * g2);
+    static double distance(const geom::Geometry* g1, const geom::Geometry* g2);
 
-                double getDistance(const geom::Geometry * g) const;
+    double getDistance(const geom::Geometry* g) const;
 
-                ~IndexedFacetDistance();
+    ~IndexedFacetDistance();
 
-            private:
-                std::unique_ptr<geos::index::strtree::STRtree> cachedTree;
+private:
+    std::unique_ptr<geos::index::strtree::STRtree> cachedTree;
 
-            };
-        }
-    }
+};
+}
+}
 }
 
 #endif //GEOS_INDEXEDFACETDISTANCE_H
diff --git a/include/geos/operation/intersection/Rectangle.h b/include/geos/operation/intersection/Rectangle.h
index 4f51906..8536581 100644
--- a/include/geos/operation/intersection/Rectangle.h
+++ b/include/geos/operation/intersection/Rectangle.h
@@ -24,12 +24,12 @@
 
 // Forward declarations
 namespace geos {
-  namespace geom {
-	class GeometryFactory;
-	class Geometry;
-	class Polygon;
-	class LinearRing;
-  }
+namespace geom {
+class GeometryFactory;
+class Geometry;
+class Polygon;
+class LinearRing;
+}
 }
 
 namespace geos {
@@ -48,157 +48,185 @@ namespace intersection { // geos::operation::intersection
  *
  */
 
-class GEOS_DLL Rectangle
-{
- public:
-
-  /**
-   * \brief Construct a clipping rectangle
-   *
-   * @param x1 x-coordinate of the left edge
-   * @param y1 y-coordinate of the bottom edge
-   * @param x2 x-coordinate of the right edge
-   * @param y2 y-coordinate of the right edge
-   * @throws IllegalArgumentException if the rectangle is empty
-   */
-
-  Rectangle(double x1, double y1, double x2, double y2);
-
-  /**
-   * \@return the minimum x-coordinate of the rectangle
-   */
-  double xmin() const { return xMin; }
-
-  /**
-   * \@return the minimum y-coordinate of the rectangle
-   */
-
-  double ymin() const { return yMin; }
-
-
-  /**
-   * \@return the maximum x-coordinate of the rectangle
-   */
-
-  double xmax() const { return xMax; }
-
-
-  /**
-   * \@return the maximum y-coordinate of the rectangle
-   */
-
-  double ymax() const { return yMax; }
-
-  /**
-   * \@return the rectangle as a polygon geometry
-   *
-   * Ownership transferred to caller
-   */
-	geom::Polygon* toPolygon(const geom::GeometryFactory &f) const;
-
-	geom::LinearRing* toLinearRing(const geom::GeometryFactory &f) const;
-
-  /**
-   * @brief Position with respect to a clipping rectangle
-   */
-
-  enum Position
-  {
-	Inside    = 1,
-	Outside   = 2,
-
-	Left        = 4,
-	Top         = 8,
-	Right       = 16,
-	Bottom      = 32,
-
-	TopLeft     = Top|Left,                 // 12
-	TopRight    = Top|Right,                // 24
-	BottomLeft  = Bottom|Left,              // 36
-	BottomRight = Bottom|Right              // 48
-  };
-
-  /**
-   * @brief Test if the given position is on a {@link Rectangle] edge
-   * @param pos {@link Rectangle} {@link Position}
-   * @return true, if the position is on an edge
-   */
-
-  static bool onEdge(Position pos)
-  {
-	return (pos > Outside);
-  }
-
-  /**
-   * @brief Test if the given positions are on the same {@link Rectangle} edge
-   * @param pos1 {@link Rectangle} {@link Position} of first coordinate
-   * @param pos2 {@link Rectangle} {@link Position} of second coordinate
-   * @return true, if the positions are on the same edge
-   */
-
-  static bool onSameEdge(Position pos1, Position pos2)
-  {
-	return onEdge(Position(pos1 & pos2));
-  }
-
-  /**
-   * @brief Establish position of coordinate with respect to a {@link Rectangle}
-   * @param x x-coordinate
-   * @param y y-coordinate
-   * @return {@link Position} of the coordinate
-   */
-
-  Position position(double x, double y) const
-  {
-	// We assume the point to be inside and test it first
-	if(x>xMin && x<xMax && y>yMin && y<yMax)
-	  return Inside;
-	// Next we assume the point to be outside and test it next
-	if(x<xMin || x>xMax || y<yMin || y>yMax)
-	  return Outside;
-	// Slower cases
-	unsigned int pos = 0;
-	if(x==xMin)
-	  pos |= Left;
-	else if(x==xMax)
-	  pos |= Right;
-	if(y==yMin)
-	  pos |= Bottom;
-	else if(y==yMax)
-	  pos |= Top;
-	return Position(pos);
-  }
-
-  /**
-   * @brief Next edge in clock-wise direction
-   * @param pos {@link Rectangle} {@link Position}
-   * @return next {@Rectangle} {@link Position} in clock-wise direction
-   */
-
-  static Position nextEdge(Position pos)
-  {
-	switch(pos)
-	  {
-	  case BottomLeft:
-	  case Left:       return Top;
-	  case TopLeft:
-	  case Top:        return Right;
-	  case TopRight:
-	  case Right:      return Bottom;
-	  case BottomRight:
-	  case Bottom:     return Left;
-	  /* silences compiler warnings, Inside & Outside are not handled explicitly */
-	  default:         return pos;
-	  }
-  }
-
- private:
-
-  Rectangle();
-  double xMin;
-  double yMin;
-  double xMax;
-  double yMax;
+class GEOS_DLL Rectangle {
+public:
+
+    /**
+     * \brief Construct a clipping rectangle
+     *
+     * @param x1 x-coordinate of the left edge
+     * @param y1 y-coordinate of the bottom edge
+     * @param x2 x-coordinate of the right edge
+     * @param y2 y-coordinate of the right edge
+     * @throws IllegalArgumentException if the rectangle is empty
+     */
+
+    Rectangle(double x1, double y1, double x2, double y2);
+
+    /**
+     * \@return the minimum x-coordinate of the rectangle
+     */
+    double
+    xmin() const
+    {
+        return xMin;
+    }
+
+    /**
+     * \@return the minimum y-coordinate of the rectangle
+     */
+
+    double
+    ymin() const
+    {
+        return yMin;
+    }
+
+
+    /**
+     * \@return the maximum x-coordinate of the rectangle
+     */
+
+    double
+    xmax() const
+    {
+        return xMax;
+    }
+
+
+    /**
+     * \@return the maximum y-coordinate of the rectangle
+     */
+
+    double
+    ymax() const
+    {
+        return yMax;
+    }
+
+    /**
+     * \@return the rectangle as a polygon geometry
+     *
+     * Ownership transferred to caller
+     */
+    geom::Polygon* toPolygon(const geom::GeometryFactory& f) const;
+
+    geom::LinearRing* toLinearRing(const geom::GeometryFactory& f) const;
+
+    /**
+     * @brief Position with respect to a clipping rectangle
+     */
+
+    enum Position {
+        Inside    = 1,
+        Outside   = 2,
+
+        Left        = 4,
+        Top         = 8,
+        Right       = 16,
+        Bottom      = 32,
+
+        TopLeft     = Top | Left,               // 12
+        TopRight    = Top | Right,              // 24
+        BottomLeft  = Bottom | Left,            // 36
+        BottomRight = Bottom | Right            // 48
+    };
+
+    /**
+     * @brief Test if the given position is on a {@link Rectangle] edge
+     * @param pos {@link Rectangle} {@link Position}
+     * @return true, if the position is on an edge
+     */
+
+    static bool
+    onEdge(Position pos)
+    {
+        return (pos > Outside);
+    }
+
+    /**
+     * @brief Test if the given positions are on the same {@link Rectangle} edge
+     * @param pos1 {@link Rectangle} {@link Position} of first coordinate
+     * @param pos2 {@link Rectangle} {@link Position} of second coordinate
+     * @return true, if the positions are on the same edge
+     */
+
+    static bool
+    onSameEdge(Position pos1, Position pos2)
+    {
+        return onEdge(Position(pos1 & pos2));
+    }
+
+    /**
+     * @brief Establish position of coordinate with respect to a {@link Rectangle}
+     * @param x x-coordinate
+     * @param y y-coordinate
+     * @return {@link Position} of the coordinate
+     */
+
+    Position
+    position(double x, double y) const
+    {
+        // We assume the point to be inside and test it first
+        if(x > xMin && x < xMax && y > yMin && y < yMax) {
+            return Inside;
+        }
+        // Next we assume the point to be outside and test it next
+        if(x < xMin || x > xMax || y < yMin || y > yMax) {
+            return Outside;
+        }
+        // Slower cases
+        unsigned int pos = 0;
+        if(x == xMin) {
+            pos |= Left;
+        }
+        else if(x == xMax) {
+            pos |= Right;
+        }
+        if(y == yMin) {
+            pos |= Bottom;
+        }
+        else if(y == yMax) {
+            pos |= Top;
+        }
+        return Position(pos);
+    }
+
+    /**
+     * @brief Next edge in clock-wise direction
+     * @param pos {@link Rectangle} {@link Position}
+     * @return next {@Rectangle} {@link Position} in clock-wise direction
+     */
+
+    static Position
+    nextEdge(Position pos)
+    {
+        switch(pos) {
+        case BottomLeft:
+        case Left:
+            return Top;
+        case TopLeft:
+        case Top:
+            return Right;
+        case TopRight:
+        case Right:
+            return Bottom;
+        case BottomRight:
+        case Bottom:
+            return Left;
+        /* silences compiler warnings, Inside & Outside are not handled explicitly */
+        default:
+            return pos;
+        }
+    }
+
+private:
+
+    Rectangle();
+    double xMin;
+    double yMin;
+    double xMax;
+    double yMax;
 
 }; // class RectangleIntersection
 
diff --git a/include/geos/operation/intersection/RectangleIntersection.h b/include/geos/operation/intersection/RectangleIntersection.h
index 673ab27..aff9d03 100644
--- a/include/geos/operation/intersection/RectangleIntersection.h
+++ b/include/geos/operation/intersection/RectangleIntersection.h
@@ -26,24 +26,24 @@
 
 // Forward declarations
 namespace geos {
-  namespace geom {
-	  class Point;
-	  class MultiPoint;
-	  class Polygon;
-	  class MultiPolygon;
-	  class LineString;
-	  class MultiLineString;
-	  class Geometry;
-	  class GeometryCollection;
-	  class GeometryFactory;
-	  class CoordinateSequenceFactory;
-  }
-  namespace operation {
-	namespace intersection {
-	  class Rectangle;
-	  class RectangleIntersectionBuilder;
-	}
-  }
+namespace geom {
+class Point;
+class MultiPoint;
+class Polygon;
+class MultiPolygon;
+class LineString;
+class MultiLineString;
+class Geometry;
+class GeometryCollection;
+class GeometryFactory;
+class CoordinateSequenceFactory;
+}
+namespace operation {
+namespace intersection {
+class Rectangle;
+class RectangleIntersectionBuilder;
+}
+}
 }
 
 namespace geos {
@@ -71,104 +71,103 @@ namespace intersection { // geos::operation::intersection
  * be properly closed, or the algorithm may not terminate.
  *
  */
-class GEOS_DLL RectangleIntersection
-{
- public:
-
-  /**
-   * \brief Clip geometry with a rectangle
-   *
-   * @param geom a {@link Geometry}
-   * @param rect a {@link Rectangle}
-   * @return the clipped geometry
-   * @return NULL if the geometry is outside the {@link Rectangle}
-   */
-  static std::unique_ptr<geom::Geometry> clip(const geom::Geometry & geom,
-							   const Rectangle & rect);
-
-  /**
-   * \brief Clip boundary of a geometry with a rectangle
-   *
-   *
-   * Any polygon which intersects the rectangle will be converted to
-   * a polyline or a multipolyline - including the holes.
-   *
-   * @param geom a {@link Geometry}
-   * @param rect a {@link Rectangle}
-   * @return the clipped geometry
-   * @return NULL if the geometry is outside the {@link Rectangle}
-   */
-  static std::unique_ptr<geom::Geometry> clipBoundary(const geom::Geometry & geom,
-									   const Rectangle & rect);
+class GEOS_DLL RectangleIntersection {
+public:
+
+    /**
+     * \brief Clip geometry with a rectangle
+     *
+     * @param geom a {@link Geometry}
+     * @param rect a {@link Rectangle}
+     * @return the clipped geometry
+     * @return NULL if the geometry is outside the {@link Rectangle}
+     */
+    static std::unique_ptr<geom::Geometry> clip(const geom::Geometry& geom,
+            const Rectangle& rect);
+
+    /**
+     * \brief Clip boundary of a geometry with a rectangle
+     *
+     *
+     * Any polygon which intersects the rectangle will be converted to
+     * a polyline or a multipolyline - including the holes.
+     *
+     * @param geom a {@link Geometry}
+     * @param rect a {@link Rectangle}
+     * @return the clipped geometry
+     * @return NULL if the geometry is outside the {@link Rectangle}
+     */
+    static std::unique_ptr<geom::Geometry> clipBoundary(const geom::Geometry& geom,
+            const Rectangle& rect);
 
 private:
 
-  RectangleIntersection(const geom::Geometry& geom, const Rectangle& rect);
+    RectangleIntersection(const geom::Geometry& geom, const Rectangle& rect);
 
-  std::unique_ptr<geom::Geometry> clipBoundary();
+    std::unique_ptr<geom::Geometry> clipBoundary();
 
-  std::unique_ptr<geom::Geometry> clip();
+    std::unique_ptr<geom::Geometry> clip();
 
-  const geom::Geometry &_geom;
-  const Rectangle &_rect;
-  const geom::GeometryFactory *_gf;
-  const geom::CoordinateSequenceFactory *_csf;
+    const geom::Geometry& _geom;
+    const Rectangle& _rect;
+    const geom::GeometryFactory* _gf;
+    const geom::CoordinateSequenceFactory* _csf;
 
-  void clip_geom(const geom::Geometry * g,
-           RectangleIntersectionBuilder & parts,
-           const Rectangle & rect,
-           bool keep_polygons);
+    void clip_geom(const geom::Geometry* g,
+                   RectangleIntersectionBuilder& parts,
+                   const Rectangle& rect,
+                   bool keep_polygons);
 
-  void clip_point(const geom::Point * g,
-				RectangleIntersectionBuilder & parts,
-				const Rectangle & rect);
+    void clip_point(const geom::Point* g,
+                    RectangleIntersectionBuilder& parts,
+                    const Rectangle& rect);
 
-  void clip_multipoint(const geom::MultiPoint * g,
-					 RectangleIntersectionBuilder & parts,
-					 const Rectangle & rect);
+    void clip_multipoint(const geom::MultiPoint* g,
+                         RectangleIntersectionBuilder& parts,
+                         const Rectangle& rect);
 
-  void clip_linestring(const geom::LineString * g,
-					 RectangleIntersectionBuilder & parts,
-					 const Rectangle & rect);
+    void clip_linestring(const geom::LineString* g,
+                         RectangleIntersectionBuilder& parts,
+                         const Rectangle& rect);
 
-  void clip_multilinestring(const geom::MultiLineString * g,
-						  RectangleIntersectionBuilder & parts,
-						  const Rectangle & rect);
+    void clip_multilinestring(const geom::MultiLineString* g,
+                              RectangleIntersectionBuilder& parts,
+                              const Rectangle& rect);
 
-  void clip_polygon(const geom::Polygon * g,
-				  RectangleIntersectionBuilder & parts,
-				  const Rectangle & rect,
-				  bool keep_polygons);
+    void clip_polygon(const geom::Polygon* g,
+                      RectangleIntersectionBuilder& parts,
+                      const Rectangle& rect,
+                      bool keep_polygons);
 
-  void clip_multipolygon(const geom::MultiPolygon * g,
-					   RectangleIntersectionBuilder & parts,
-					   const Rectangle & rect,
-					   bool keep_polygons);
+    void clip_multipolygon(const geom::MultiPolygon* g,
+                           RectangleIntersectionBuilder& parts,
+                           const Rectangle& rect,
+                           bool keep_polygons);
 
-  void clip_geometrycollection(
-               const geom::GeometryCollection * g,
-							 RectangleIntersectionBuilder & parts,
-							 const Rectangle & rect,
-							 bool keep_polygons);
+    void clip_geometrycollection(
+        const geom::GeometryCollection* g,
+        RectangleIntersectionBuilder& parts,
+        const Rectangle& rect,
+        bool keep_polygons);
 
-  void clip_polygon_to_linestrings(const geom::Polygon * g,
-								 RectangleIntersectionBuilder & parts,
-								 const Rectangle & rect);
+    void clip_polygon_to_linestrings(const geom::Polygon* g,
+                                     RectangleIntersectionBuilder& parts,
+                                     const Rectangle& rect);
 
-  void clip_polygon_to_polygons(const geom::Polygon * g,
-							  RectangleIntersectionBuilder & parts,
-							  const Rectangle & rect);
+    void clip_polygon_to_polygons(const geom::Polygon* g,
+                                  RectangleIntersectionBuilder& parts,
+                                  const Rectangle& rect);
 
 
-  /**
-   * \brief Clip geometry.
-   *
-   * Returns true if the geometry was fully inside, and does not output
-   * anything to RectangleIntersectionBuilder.
-   */
-  bool clip_linestring_parts(const geom::LineString * gi,
-               RectangleIntersectionBuilder & parts,
-               const Rectangle & rect);
+    /**
+     * \brief Clip geometry.
+     *
+     * Returns true if the geometry was fully inside, and does not output
+     * anything to RectangleIntersectionBuilder.
+     */
+    bool clip_linestring_parts(const geom::LineString* gi,
+                               RectangleIntersectionBuilder& parts,
+                               const Rectangle& rect);
 
 }; // class RectangleIntersection
 
diff --git a/include/geos/operation/intersection/RectangleIntersectionBuilder.h b/include/geos/operation/intersection/RectangleIntersectionBuilder.h
index 154444b..47383e0 100644
--- a/include/geos/operation/intersection/RectangleIntersectionBuilder.h
+++ b/include/geos/operation/intersection/RectangleIntersectionBuilder.h
@@ -29,19 +29,19 @@
 
 // Forward declarations
 namespace geos {
-  namespace geom {
-	class Coordinate;
-	class Geometry;
-	class GeometryFactory;
-	class Polygon;
-	class LineString;
-	class Point;
-  }
-  namespace operation {
-	namespace intersection {
-	  class Rectangle;
-	}
-  }
+namespace geom {
+class Coordinate;
+class Geometry;
+class GeometryFactory;
+class Polygon;
+class LineString;
+class Point;
+}
+namespace operation {
+namespace intersection {
+class Rectangle;
+}
+}
 }
 
 namespace geos {
@@ -60,97 +60,96 @@ namespace intersection { // geos::operation::intersection
  * intended for public use.
  */
 
-class GEOS_DLL RectangleIntersectionBuilder
-{
-  // Regular users are not supposed to use this utility class.
-  friend class RectangleIntersection;
+class GEOS_DLL RectangleIntersectionBuilder {
+    // Regular users are not supposed to use this utility class.
+    friend class RectangleIntersection;
 
 public:
 
-  ~RectangleIntersectionBuilder();
+    ~RectangleIntersectionBuilder();
 
 private:
 
-  /**
-   * \brief Build the result geometry from partial results and clean up
-   */
-  std::unique_ptr<geom::Geometry> build();
-
-  /**
-   * \brief Build polygons from parts left by clipping one
-   *
-   * 1. Build exterior ring(s) from lines
-   * 2. Attach polygons as holes to the exterior ring(s)
-   */
-  void reconnectPolygons(const Rectangle & rect);
-
-  /**
-   * Reconnect disjointed parts
-   *
-   * When we clip a LinearRing we may get multiple linestrings.
-   * Often the first and last ones can be reconnected to simplify
-   * output.
-   *
-   * Sample clip with a rectangle 0,0 --> 10,10 without reconnecting:
-   *
-   *   Input:   POLYGON ((5 10,0 0,10 0,5 10))
-   *   Output:  MULTILINESTRING ((5 10,0 0),(10 0,5 10))
-   *   Desired: LINESTRING (10 0,5 10,0 0)
-   *
-   * TODO: If there is a very sharp spike from inside the rectangle
-   *       outside, and then back in, it is possible that the
-   *       intersection points at the edge are equal. In this
-   *       case we could reconnect the linestrings. The task is
-   *       the same we're already doing for the 1st/last linestrings,
-   *       we'd just do it for any adjacent pair as well.
-   */
-  void reconnect();
-
-  void reverseLines();
-
-  /**
-   * Export parts to another container
-   */
-  void release(RectangleIntersectionBuilder & parts);
-
-  // Adding Geometry components
-  void add(geom::Polygon * g);
-  void add(geom::LineString * g);
-  void add(geom::Point * g);
-
-  // Trivial methods
-  bool empty() const;
-  void clear();
-
-  // Added components
-  std::list<geom::Polygon *> polygons;
-  std::list<geom::LineString *> lines;
-  std::list<geom::Point *> points;
-
-  /**
-   * \brief Close a ring clockwise along rectangle edges
-   *
-   * Only the 4 corners and x1,y1 need to be considered. The possible
-   * cases are:
-   *
-   *    x1,y1
-   *    corner1 x1,y1
-   *    corner1 corner2 x1,y1
-   *    corner1 corner2 corner3 x1,y1
-   *    corner1 corner2 corner3 corner4 x1,y1
-   */
-  void close_boundary(
-          const Rectangle & rect,
-          std::vector<geom::Coordinate> * ring,
-          double x1, double y1,
-          double x2, double y2);
-
-  void close_ring(const Rectangle & rect, std::vector<geom::Coordinate> * ring);
-
-  RectangleIntersectionBuilder(const geom::GeometryFactory& f)
-    : _gf(f) {}
-
-  const geom::GeometryFactory &_gf;
+    /**
+     * \brief Build the result geometry from partial results and clean up
+     */
+    std::unique_ptr<geom::Geometry> build();
+
+    /**
+     * \brief Build polygons from parts left by clipping one
+     *
+     * 1. Build exterior ring(s) from lines
+     * 2. Attach polygons as holes to the exterior ring(s)
+     */
+    void reconnectPolygons(const Rectangle& rect);
+
+    /**
+     * Reconnect disjointed parts
+     *
+     * When we clip a LinearRing we may get multiple linestrings.
+     * Often the first and last ones can be reconnected to simplify
+     * output.
+     *
+     * Sample clip with a rectangle 0,0 --> 10,10 without reconnecting:
+     *
+     *   Input:   POLYGON ((5 10,0 0,10 0,5 10))
+     *   Output:  MULTILINESTRING ((5 10,0 0),(10 0,5 10))
+     *   Desired: LINESTRING (10 0,5 10,0 0)
+     *
+     * TODO: If there is a very sharp spike from inside the rectangle
+     *       outside, and then back in, it is possible that the
+     *       intersection points at the edge are equal. In this
+     *       case we could reconnect the linestrings. The task is
+     *       the same we're already doing for the 1st/last linestrings,
+     *       we'd just do it for any adjacent pair as well.
+     */
+    void reconnect();
+
+    void reverseLines();
+
+    /**
+     * Export parts to another container
+     */
+    void release(RectangleIntersectionBuilder& parts);
+
+    // Adding Geometry components
+    void add(geom::Polygon* g);
+    void add(geom::LineString* g);
+    void add(geom::Point* g);
+
+    // Trivial methods
+    bool empty() const;
+    void clear();
+
+    // Added components
+    std::list<geom::Polygon*> polygons;
+    std::list<geom::LineString*> lines;
+    std::list<geom::Point*> points;
+
+    /**
+     * \brief Close a ring clockwise along rectangle edges
+     *
+     * Only the 4 corners and x1,y1 need to be considered. The possible
+     * cases are:
+     *
+     *    x1,y1
+     *    corner1 x1,y1
+     *    corner1 corner2 x1,y1
+     *    corner1 corner2 corner3 x1,y1
+     *    corner1 corner2 corner3 corner4 x1,y1
+     */
+    void close_boundary(
+        const Rectangle& rect,
+        std::vector<geom::Coordinate>* ring,
+        double x1, double y1,
+        double x2, double y2);
+
+    void close_ring(const Rectangle& rect, std::vector<geom::Coordinate>* ring);
+
+    RectangleIntersectionBuilder(const geom::GeometryFactory& f)
+        : _gf(f) {}
+
+    const geom::GeometryFactory& _gf;
 
 }; // class RectangleIntersectionBuilder
 
diff --git a/include/geos/operation/linemerge/EdgeString.h b/include/geos/operation/linemerge/EdgeString.h
index d308e6f..4c69e4c 100644
--- a/include/geos/operation/linemerge/EdgeString.h
+++ b/include/geos/operation/linemerge/EdgeString.h
@@ -31,16 +31,16 @@
 
 // Forward declarations
 namespace geos {
-	namespace geom {
-		class GeometryFactory;
-		class CoordinateSequence;
-		class LineString;
-	}
-	namespace operation {
-		namespace linemerge {
-			class LineMergeDirectedEdge;
-		}
-	}
+namespace geom {
+class GeometryFactory;
+class CoordinateSequence;
+class LineString;
+}
+namespace operation {
+namespace linemerge {
+class LineMergeDirectedEdge;
+}
+}
 }
 
 namespace geos {
@@ -54,29 +54,29 @@ namespace linemerge { // geos::operation::linemerge
  */
 class GEOS_DLL EdgeString {
 private:
-	const geom::GeometryFactory *factory;
-	std::vector<LineMergeDirectedEdge*> directedEdges;
-	geom::CoordinateSequence *coordinates;
-	geom::CoordinateSequence* getCoordinates();
+    const geom::GeometryFactory* factory;
+    std::vector<LineMergeDirectedEdge*> directedEdges;
+    geom::CoordinateSequence* coordinates;
+    geom::CoordinateSequence* getCoordinates();
 public:
-	/*
-	 * \brief
-	 * Constructs an EdgeString with the given factory used to
-	 * convert this EdgeString to a LineString
-	 */
-	EdgeString(const geom::GeometryFactory *newFactory);
+    /*
+     * \brief
+     * Constructs an EdgeString with the given factory used to
+     * convert this EdgeString to a LineString
+     */
+    EdgeString(const geom::GeometryFactory* newFactory);
 
-	~EdgeString();
+    ~EdgeString();
 
-	/**
-	* Adds a directed edge which is known to form part of this line.
-	*/
-	void add(LineMergeDirectedEdge *directedEdge);
+    /**
+    * Adds a directed edge which is known to form part of this line.
+    */
+    void add(LineMergeDirectedEdge* directedEdge);
 
-	/*
-	 * Converts this EdgeString into a LineString.
-	 */
-	geom::LineString* toLineString();
+    /*
+     * Converts this EdgeString into a LineString.
+     */
+    geom::LineString* toLineString();
 };
 
 } // namespace geos::operation::linemerge
diff --git a/include/geos/operation/linemerge/LineMergeDirectedEdge.h b/include/geos/operation/linemerge/LineMergeDirectedEdge.h
index f6c003d..a19bd22 100644
--- a/include/geos/operation/linemerge/LineMergeDirectedEdge.h
+++ b/include/geos/operation/linemerge/LineMergeDirectedEdge.h
@@ -25,13 +25,13 @@
 
 // Forward declarations
 namespace geos {
-	namespace geom {
-		class Coordinate;
-		//class LineString;
-	}
-	namespace planargraph {
-		class Node;
-	}
+namespace geom {
+class Coordinate;
+//class LineString;
+}
+namespace planargraph {
+class Node;
+}
 }
 
 
@@ -46,30 +46,30 @@ namespace linemerge { // geos::operation::linemerge
  */
 class GEOS_DLL LineMergeDirectedEdge: public planargraph::DirectedEdge {
 public:
-	/**
-	 * Constructs a LineMergeDirectedEdge connecting the <code>from</code>
-	 * node to the <code>to</code> node.
-	 *
-	 * @param directionPt
-	 *        specifies this DirectedEdge's direction (given by an
-	 *	  imaginary line from the <code>from</code> node to
-	 *	  <code>directionPt</code>)
-	 *
-	 * @param edgeDirection
-	 *        whether this DirectedEdge's direction is the same as or
-	 *        opposite to that of the parent Edge (if any)
-	 */
-	LineMergeDirectedEdge(planargraph::Node *from,
-			planargraph::Node *to,
-			const geom::Coordinate& directionPt,
-			bool edgeDirection);
+    /**
+     * Constructs a LineMergeDirectedEdge connecting the <code>from</code>
+     * node to the <code>to</code> node.
+     *
+     * @param directionPt
+     *        specifies this DirectedEdge's direction (given by an
+     *	  imaginary line from the <code>from</code> node to
+     *	  <code>directionPt</code>)
+     *
+     * @param edgeDirection
+     *        whether this DirectedEdge's direction is the same as or
+     *        opposite to that of the parent Edge (if any)
+     */
+    LineMergeDirectedEdge(planargraph::Node* from,
+                          planargraph::Node* to,
+                          const geom::Coordinate& directionPt,
+                          bool edgeDirection);
 
-	/**
-	* Returns the directed edge that starts at this directed edge's end point, or null
-	* if there are zero or multiple directed edges starting there.
-	* @return
-	*/
-	LineMergeDirectedEdge* getNext();
+    /**
+    * Returns the directed edge that starts at this directed edge's end point, or null
+    * if there are zero or multiple directed edges starting there.
+    * @return
+    */
+    LineMergeDirectedEdge* getNext();
 };
 
 } // namespace geos::operation::linemerge
diff --git a/include/geos/operation/linemerge/LineMergeEdge.h b/include/geos/operation/linemerge/LineMergeEdge.h
index 52e7666..c1e7e49 100644
--- a/include/geos/operation/linemerge/LineMergeEdge.h
+++ b/include/geos/operation/linemerge/LineMergeEdge.h
@@ -26,9 +26,9 @@
 
 // Forward declarations
 namespace geos {
-	namespace geom {
-		class LineString;
-	}
+namespace geom {
+class LineString;
+}
 }
 
 
@@ -42,18 +42,18 @@ namespace linemerge { // geos::operation::linemerge
  */
 class GEOS_DLL LineMergeEdge: public planargraph::Edge {
 private:
-	const geom::LineString *line;
+    const geom::LineString* line;
 public:
-	/**
-	 * Constructs a LineMergeEdge with vertices given by the specified
-	 * LineString.
-	 */
-	LineMergeEdge(const geom::LineString *newLine);
+    /**
+     * Constructs a LineMergeEdge with vertices given by the specified
+     * LineString.
+     */
+    LineMergeEdge(const geom::LineString* newLine);
 
-	/**
-	 * Returns the LineString specifying the vertices of this edge.
-	 */
-	const geom::LineString* getLine() const;
+    /**
+     * Returns the LineString specifying the vertices of this edge.
+     */
+    const geom::LineString* getLine() const;
 };
 
 
diff --git a/include/geos/operation/linemerge/LineMergeGraph.h b/include/geos/operation/linemerge/LineMergeGraph.h
index 6c932d1..353894b 100644
--- a/include/geos/operation/linemerge/LineMergeGraph.h
+++ b/include/geos/operation/linemerge/LineMergeGraph.h
@@ -33,15 +33,15 @@
 
 // Forward declarations
 namespace geos {
-	namespace geom {
-		class LineString;
-		class Coordinate;
-	}
-	namespace planargraph {
-		class Node;
-		class Edge;
-		class DirectedEdge;
-	}
+namespace geom {
+class LineString;
+class Coordinate;
+}
+namespace planargraph {
+class Node;
+class Edge;
+class DirectedEdge;
+}
 }
 
 
@@ -60,27 +60,27 @@ class GEOS_DLL LineMergeGraph: public planargraph::PlanarGraph {
 
 private:
 
-	planargraph::Node* getNode(const geom::Coordinate &coordinate);
+    planargraph::Node* getNode(const geom::Coordinate& coordinate);
 
-	std::vector<planargraph::Node*> newNodes;
+    std::vector<planargraph::Node*> newNodes;
 
-	std::vector<planargraph::Edge*> newEdges;
+    std::vector<planargraph::Edge*> newEdges;
 
-	std::vector<planargraph::DirectedEdge*> newDirEdges;
+    std::vector<planargraph::DirectedEdge*> newDirEdges;
 
 public:
 
-	/** \brief
-	 * Adds an Edge, DirectedEdges, and Nodes for the given
-	 * LineString representation of an edge.
-	 *
-	 * Empty lines or lines with all coordinates equal are not added.
-	 *
-	 * @param lineString the linestring to add to the graph
-	 */
-	void addEdge(const geom::LineString *lineString);
-
-	~LineMergeGraph() override;
+    /** \brief
+     * Adds an Edge, DirectedEdges, and Nodes for the given
+     * LineString representation of an edge.
+     *
+     * Empty lines or lines with all coordinates equal are not added.
+     *
+     * @param lineString the linestring to add to the graph
+     */
+    void addEdge(const geom::LineString* lineString);
+
+    ~LineMergeGraph() override;
 };
 } // namespace geos::operation::linemerge
 } // namespace geos::operation
diff --git a/include/geos/operation/linemerge/LineMerger.h b/include/geos/operation/linemerge/LineMerger.h
index 4322771..69b980f 100644
--- a/include/geos/operation/linemerge/LineMerger.h
+++ b/include/geos/operation/linemerge/LineMerger.h
@@ -31,20 +31,20 @@
 
 // Forward declarations
 namespace geos {
-	namespace geom {
-		class LineString;
-		class GeometryFactory;
-		class Geometry;
-	}
-	namespace planargraph {
-		class Node;
-	}
-	namespace operation {
-		namespace linemerge {
-			class EdgeString;
-			class LineMergeDirectedEdge;
-		}
-	}
+namespace geom {
+class LineString;
+class GeometryFactory;
+class Geometry;
+}
+namespace planargraph {
+class Node;
+}
+namespace operation {
+namespace linemerge {
+class EdgeString;
+class LineMergeDirectedEdge;
+}
+}
 }
 
 
@@ -76,61 +76,61 @@ class GEOS_DLL LineMerger {
 
 private:
 
-	LineMergeGraph graph;
+    LineMergeGraph graph;
 
-	std::vector<geom::LineString*> *mergedLineStrings;
+    std::vector<geom::LineString*>* mergedLineStrings;
 
-	std::vector<EdgeString*> edgeStrings;
+    std::vector<EdgeString*> edgeStrings;
 
-	const geom::GeometryFactory *factory;
+    const geom::GeometryFactory* factory;
 
-	void merge();
+    void merge();
 
-	void buildEdgeStringsForObviousStartNodes();
+    void buildEdgeStringsForObviousStartNodes();
 
-	void buildEdgeStringsForIsolatedLoops();
+    void buildEdgeStringsForIsolatedLoops();
 
-	void buildEdgeStringsForUnprocessedNodes();
+    void buildEdgeStringsForUnprocessedNodes();
 
-	void buildEdgeStringsForNonDegree2Nodes();
+    void buildEdgeStringsForNonDegree2Nodes();
 
-	void buildEdgeStringsStartingAt(planargraph::Node *node);
+    void buildEdgeStringsStartingAt(planargraph::Node* node);
 
-	EdgeString* buildEdgeStringStartingWith(LineMergeDirectedEdge *start);
+    EdgeString* buildEdgeStringStartingWith(LineMergeDirectedEdge* start);
 
 public:
-	LineMerger();
-	~LineMerger();
-
-	/**
-	 * \brief
-	 * Adds a collection of Geometries to be processed.
-	 * May be called multiple times.
-	 *
-	 * Any dimension of Geometry may be added; the constituent
-	 * linework will be extracted.
-	 */
-	void add(std::vector<geom::Geometry*> *geometries);
-
-	/**
-	 * \brief
-	 * Adds a Geometry to be processed.
-	 * May be called multiple times.
-	 *
-	 * Any dimension of Geometry may be added; the constituent
-	 * linework will be extracted.
-	 */
-	void add(const geom::Geometry *geometry);
-
-	/**
-	 * \brief
-	 * Returns the LineStrings built by the merging process.
-	 *
-	 * Ownership of vector _and_ its elements to caller.
-	 */
-	std::vector<geom::LineString*>* getMergedLineStrings();
-
-	void add(const geom::LineString *lineString);
+    LineMerger();
+    ~LineMerger();
+
+    /**
+     * \brief
+     * Adds a collection of Geometries to be processed.
+     * May be called multiple times.
+     *
+     * Any dimension of Geometry may be added; the constituent
+     * linework will be extracted.
+     */
+    void add(std::vector<geom::Geometry*>* geometries);
+
+    /**
+     * \brief
+     * Adds a Geometry to be processed.
+     * May be called multiple times.
+     *
+     * Any dimension of Geometry may be added; the constituent
+     * linework will be extracted.
+     */
+    void add(const geom::Geometry* geometry);
+
+    /**
+     * \brief
+     * Returns the LineStrings built by the merging process.
+     *
+     * Ownership of vector _and_ its elements to caller.
+     */
+    std::vector<geom::LineString*>* getMergedLineStrings();
+
+    void add(const geom::LineString* lineString);
 
 };
 
diff --git a/include/geos/operation/linemerge/LineSequencer.h b/include/geos/operation/linemerge/LineSequencer.h
index 03e3813..5c6a9f0 100644
--- a/include/geos/operation/linemerge/LineSequencer.h
+++ b/include/geos/operation/linemerge/LineSequencer.h
@@ -37,16 +37,16 @@
 
 // Forward declarations
 namespace geos {
-	namespace geom {
-		class GeometryFactory;
-		class Geometry;
-		class LineString;
-	}
-	namespace planargraph {
-		class DirectedEdge;
-		class Subgraph;
-		class Node;
-	}
+namespace geom {
+class GeometryFactory;
+class Geometry;
+class LineString;
+}
+namespace planargraph {
+class DirectedEdge;
+class Subgraph;
+class Node;
+}
 }
 
 
@@ -99,189 +99,199 @@ namespace linemerge { // geos::operation::linemerge
 class GEOS_DLL LineSequencer {
 
 private:
-	typedef std::list<planargraph::DirectedEdge*> DirEdgeList;
-	typedef std::vector< DirEdgeList* > Sequences;
-
-	LineMergeGraph graph;
-	const geom::GeometryFactory *factory;
-	unsigned int lineCount;
-	bool isRun;
-	std::unique_ptr<geom::Geometry> sequencedGeometry;
-	bool isSequenceableVar;
-
-	void addLine(const geom::LineString *lineString);
-	void computeSequence();
-	Sequences* findSequences();
-	DirEdgeList* findSequence(planargraph::Subgraph& graph);
-
-	void delAll( Sequences& );
-
-	/// return a newly allocated LineString
-	static geom::LineString* reverse(const geom::LineString *line);
-
-	/**
-	 * Builds a geometry ({@link LineString} or {@link MultiLineString} )
-	 * representing the sequence.
-	 *
-	 * @param sequences
-	 *    a vector of vectors of const planarDirectedEdges
-	 *    with LineMergeEdges as their parent edges.
-	 *    Ownership of container _and_ contents retained by caller.
-	 *
-	 * @return the sequenced geometry, possibly NULL
-	 *         if no sequence exists
-	 */
-	geom::Geometry* buildSequencedGeometry(const Sequences& sequences);
-
-	static const planargraph::Node* findLowestDegreeNode(
-			const planargraph::Subgraph& graph);
-
-	void addReverseSubpath(const planargraph::DirectedEdge *de,
-		DirEdgeList& deList,
-		DirEdgeList::iterator lit,
-		bool expectedClosed);
-
-	/**
-	 * Finds an {@link DirectedEdge} for an unvisited edge (if any),
-	 * choosing the dirEdge which preserves orientation, if possible.
-	 *
-	 * @param node the node to examine
-	 * @return the dirEdge found, or <code>null</code>
-	 *         if none were unvisited
-	 */
-	static const planargraph::DirectedEdge* findUnvisitedBestOrientedDE(
-			const planargraph::Node* node);
-
-	/**
-	 * Computes a version of the sequence which is optimally
-	 * oriented relative to the underlying geometry.
-	 *
-	 * Heuristics used are:
-	 *
-	 * - If the path has a degree-1 node which is the start
-	 *   node of an linestring, use that node as the start of the sequence
-	 * - If the path has a degree-1 node which is the end
-	 *   node of an linestring, use that node as the end of the sequence
-	 * - If the sequence has no degree-1 nodes, use any node as the start
-	 *   (NOTE: in this case could orient the sequence according to the
-	 *   majority of the linestring orientations)
-	 *
-	 * @param seq a List of planarDirectedEdges
-	 * @return the oriented sequence, possibly same as input if already
-	 *         oriented
-	 */
-	DirEdgeList* orient(DirEdgeList* seq);
-
-	/**
-	 * Reverse the sequence.
-	 * This requires reversing the order of the dirEdges, and flipping
-	 * each dirEdge as well
-	 *
-	 * @param seq a List of DirectedEdges, in sequential order
-	 * @return the reversed sequence
-	 */
-	DirEdgeList* reverse(DirEdgeList& seq);
-
-	/**
-	 * Tests whether a complete unique path exists in a graph
-	 * using Euler's Theorem.
-	 *
-	 * @param graph the subgraph containing the edges
-	 * @return <code>true</code> if a sequence exists
-	 */
-	bool hasSequence(planargraph::Subgraph& graph);
+    typedef std::list<planargraph::DirectedEdge*> DirEdgeList;
+    typedef std::vector< DirEdgeList* > Sequences;
+
+    LineMergeGraph graph;
+    const geom::GeometryFactory* factory;
+    unsigned int lineCount;
+    bool isRun;
+    std::unique_ptr<geom::Geometry> sequencedGeometry;
+    bool isSequenceableVar;
+
+    void addLine(const geom::LineString* lineString);
+    void computeSequence();
+    Sequences* findSequences();
+    DirEdgeList* findSequence(planargraph::Subgraph& graph);
+
+    void delAll(Sequences&);
+
+    /// return a newly allocated LineString
+    static geom::LineString* reverse(const geom::LineString* line);
+
+    /**
+     * Builds a geometry ({@link LineString} or {@link MultiLineString} )
+     * representing the sequence.
+     *
+     * @param sequences
+     *    a vector of vectors of const planarDirectedEdges
+     *    with LineMergeEdges as their parent edges.
+     *    Ownership of container _and_ contents retained by caller.
+     *
+     * @return the sequenced geometry, possibly NULL
+     *         if no sequence exists
+     */
+    geom::Geometry* buildSequencedGeometry(const Sequences& sequences);
+
+    static const planargraph::Node* findLowestDegreeNode(
+        const planargraph::Subgraph& graph);
+
+    void addReverseSubpath(const planargraph::DirectedEdge* de,
+                           DirEdgeList& deList,
+                           DirEdgeList::iterator lit,
+                           bool expectedClosed);
+
+    /**
+     * Finds an {@link DirectedEdge} for an unvisited edge (if any),
+     * choosing the dirEdge which preserves orientation, if possible.
+     *
+     * @param node the node to examine
+     * @return the dirEdge found, or <code>null</code>
+     *         if none were unvisited
+     */
+    static const planargraph::DirectedEdge* findUnvisitedBestOrientedDE(
+        const planargraph::Node* node);
+
+    /**
+     * Computes a version of the sequence which is optimally
+     * oriented relative to the underlying geometry.
+     *
+     * Heuristics used are:
+     *
+     * - If the path has a degree-1 node which is the start
+     *   node of an linestring, use that node as the start of the sequence
+     * - If the path has a degree-1 node which is the end
+     *   node of an linestring, use that node as the end of the sequence
+     * - If the sequence has no degree-1 nodes, use any node as the start
+     *   (NOTE: in this case could orient the sequence according to the
+     *   majority of the linestring orientations)
+     *
+     * @param seq a List of planarDirectedEdges
+     * @return the oriented sequence, possibly same as input if already
+     *         oriented
+     */
+    DirEdgeList* orient(DirEdgeList* seq);
+
+    /**
+     * Reverse the sequence.
+     * This requires reversing the order of the dirEdges, and flipping
+     * each dirEdge as well
+     *
+     * @param seq a List of DirectedEdges, in sequential order
+     * @return the reversed sequence
+     */
+    DirEdgeList* reverse(DirEdgeList& seq);
+
+    /**
+     * Tests whether a complete unique path exists in a graph
+     * using Euler's Theorem.
+     *
+     * @param graph the subgraph containing the edges
+     * @return <code>true</code> if a sequence exists
+     */
+    bool hasSequence(planargraph::Subgraph& graph);
 
 public:
 
-	static geom::Geometry* sequence(const geom::Geometry& geom)
-	{
-		LineSequencer sequencer;
-		sequencer.add(geom);
-		return sequencer.getSequencedLineStrings();
-	}
-
-	LineSequencer()
-		:
-		factory(nullptr),
-		lineCount(0),
-		isRun(false),
-		sequencedGeometry(nullptr),
-		isSequenceableVar(false)
-		{}
-
-	/**
-	 * Tests whether a {@link Geometry} is sequenced correctly.
-	 * {@llink LineString}s are trivially sequenced.
-	 * {@link MultiLineString}s are checked for correct sequencing.
-	 * Otherwise, <code>isSequenced</code> is defined
-	 * to be <code>true</code> for geometries that are not lineal.
-	 *
-	 * @param geom the geometry to test
-	 * @return true if the geometry is sequenced or is not lineal
-	 */
-	static bool isSequenced(const geom::Geometry* geom);
-
-	/**
-	 * Tests whether the arrangement of linestrings has a valid
-	 * sequence.
-	 *
-	 * @return <code>true</code> if a valid sequence exists.
-	 */
-	bool isSequenceable() {
-		computeSequence();
-		return isSequenceableVar;
-	}
-
-	/**
-	 * Adds a {@link Geometry} to be sequenced.
-	 * May be called multiple times.
-	 * Any dimension of Geometry may be added; the constituent
-	 * linework will be extracted.
-	 *
-	 * @param geometry the geometry to add
-	 */
-	void add(const geom::Geometry& geometry) {
-		geometry.applyComponentFilter(*this);
-	}
-
-  template <class TargetContainer>
-  void add(TargetContainer& geoms)
-  {
-    for (typename TargetContainer::const_iterator i = geoms.begin(),
-         e = geoms.end(); i != e; ++i)
+    static geom::Geometry*
+    sequence(const geom::Geometry& geom)
+    {
+        LineSequencer sequencer;
+        sequencer.add(geom);
+        return sequencer.getSequencedLineStrings();
+    }
+
+    LineSequencer()
+        :
+        factory(nullptr),
+        lineCount(0),
+        isRun(false),
+        sequencedGeometry(nullptr),
+        isSequenceableVar(false)
+    {}
+
+    /**
+     * Tests whether a {@link Geometry} is sequenced correctly.
+     * {@llink LineString}s are trivially sequenced.
+     * {@link MultiLineString}s are checked for correct sequencing.
+     * Otherwise, <code>isSequenced</code> is defined
+     * to be <code>true</code> for geometries that are not lineal.
+     *
+     * @param geom the geometry to test
+     * @return true if the geometry is sequenced or is not lineal
+     */
+    static bool isSequenced(const geom::Geometry* geom);
+
+    /**
+     * Tests whether the arrangement of linestrings has a valid
+     * sequence.
+     *
+     * @return <code>true</code> if a valid sequence exists.
+     */
+    bool
+    isSequenceable()
+    {
+        computeSequence();
+        return isSequenceableVar;
+    }
+
+    /**
+     * Adds a {@link Geometry} to be sequenced.
+     * May be called multiple times.
+     * Any dimension of Geometry may be added; the constituent
+     * linework will be extracted.
+     *
+     * @param geometry the geometry to add
+     */
+    void
+    add(const geom::Geometry& geometry)
+    {
+        geometry.applyComponentFilter(*this);
+    }
+
+    template <class TargetContainer>
+    void
+    add(TargetContainer& geoms)
+    {
+        for(typename TargetContainer::const_iterator i = geoms.begin(),
+                e = geoms.end(); i != e; ++i) {
+            const geom::Geometry* g = *i;
+            add(*g);
+        }
+    }
+
+    /**
+     * Act as a GeometryComponentFilter so to extract
+     * the linearworks
+     */
+    void
+    filter(const geom::Geometry* g)
+    {
+        if(const geom::LineString* ls = dynamic_cast<const geom::LineString*>(g)) {
+            addLine(ls);
+        }
+    }
+
+    /**
+     * Returns the LineString or MultiLineString
+     * built by the sequencing process, if one exists.
+     *
+     * @param release release ownership of computed Geometry
+     * @return the sequenced linestrings,
+     *         or <code>null</code> if a valid sequence
+     *         does not exist.
+     */
+    geom::Geometry*
+    getSequencedLineStrings(bool release = 1)
     {
-      const geom::Geometry* g = *i;
-      add(*g);
+        computeSequence();
+        if(release) {
+            return sequencedGeometry.release();
+        }
+        else {
+            return sequencedGeometry.get();
+        }
     }
-  }
-
-	/**
-	 * Act as a GeometryComponentFilter so to extract
-	 * the linearworks
-	 */
-	void filter(const geom::Geometry* g)
-	{
-		if (const geom::LineString *ls=dynamic_cast<const geom::LineString *>(g))
-		{
-			addLine(ls);
-		}
-	}
-
-	/**
-	 * Returns the LineString or MultiLineString
-	 * built by the sequencing process, if one exists.
-	 *
-	 * @param release release ownership of computed Geometry
-	 * @return the sequenced linestrings,
-	 *         or <code>null</code> if a valid sequence
-	 *         does not exist.
-	 */
-	geom::Geometry*
-	getSequencedLineStrings(bool release=1) {
-		computeSequence();
-		if (release) return sequencedGeometry.release();
-		else return sequencedGeometry.get();
-	}
 };
 
 } // namespace geos::operation::linemerge
diff --git a/include/geos/operation/overlay/EdgeSetNoder.h b/include/geos/operation/overlay/EdgeSetNoder.h
index ee633f8..f61438c 100644
--- a/include/geos/operation/overlay/EdgeSetNoder.h
+++ b/include/geos/operation/overlay/EdgeSetNoder.h
@@ -25,12 +25,12 @@
 
 // Forward declarations
 namespace geos {
-	namespace geomgraph {
-		class Edge;
-	}
-	namespace algorithm {
-		class LineIntersector;
-	}
+namespace geomgraph {
+class Edge;
+}
+namespace algorithm {
+class LineIntersector;
+}
 }
 
 namespace geos {
@@ -46,21 +46,22 @@ namespace overlay { // geos::operation::overlay
  */
 class GEOS_DLL EdgeSetNoder {
 private:
-	algorithm::LineIntersector *li;
-	std::vector<geomgraph::Edge*>* inputEdges;
+    algorithm::LineIntersector* li;
+    std::vector<geomgraph::Edge*>* inputEdges;
 public:
-	EdgeSetNoder(algorithm::LineIntersector *newLi)
-		:
-		li(newLi),
-		inputEdges(new std::vector<geomgraph::Edge*>())
-	{}
+    EdgeSetNoder(algorithm::LineIntersector* newLi)
+        :
+        li(newLi),
+        inputEdges(new std::vector<geomgraph::Edge*>())
+    {}
 
-	~EdgeSetNoder() {
-		delete inputEdges; // TODO: avoid heap allocation
-	}
+    ~EdgeSetNoder()
+    {
+        delete inputEdges; // TODO: avoid heap allocation
+    }
 
-	void addEdges(std::vector<geomgraph::Edge*> *edges);
-	std::vector<geomgraph::Edge*>* getNodedEdges();
+    void addEdges(std::vector<geomgraph::Edge*>* edges);
+    std::vector<geomgraph::Edge*>* getNodedEdges();
 };
 
 
diff --git a/include/geos/operation/overlay/ElevationMatrix.h b/include/geos/operation/overlay/ElevationMatrix.h
index 02d963e..aa38cde 100644
--- a/include/geos/operation/overlay/ElevationMatrix.h
+++ b/include/geos/operation/overlay/ElevationMatrix.h
@@ -35,16 +35,16 @@
 
 // Forward declarations
 namespace geos {
-	namespace geom {
-		class Coordinate;
-		class Geometry;
-	}
-	namespace operation {
-		namespace overlay {
-			class ElevationMatrixFilter;
-			class ElevationMatrix;
-		}
-	}
+namespace geom {
+class Coordinate;
+class Geometry;
+}
+namespace operation {
+namespace overlay {
+class ElevationMatrixFilter;
+class ElevationMatrix;
+}
+}
 }
 
 namespace geos {
@@ -58,16 +58,15 @@ namespace overlay { // geos::operation::overlay
  * values to the matrix.
  * filter_rw is used to actually elevate Geometries.
  */
-class GEOS_DLL ElevationMatrixFilter: public geom::CoordinateFilter
-{
+class GEOS_DLL ElevationMatrixFilter: public geom::CoordinateFilter {
 public:
-	ElevationMatrixFilter(ElevationMatrix &em);
-	~ElevationMatrixFilter() override;
-	void filter_rw(geom::Coordinate *c) const override;
-	void filter_ro(const geom::Coordinate *c) override;
+    ElevationMatrixFilter(ElevationMatrix& em);
+    ~ElevationMatrixFilter() override;
+    void filter_rw(geom::Coordinate* c) const override;
+    void filter_ro(const geom::Coordinate* c) override;
 private:
-	ElevationMatrix &em;
-	double avgElevation;
+    ElevationMatrix& em;
+    double avgElevation;
 
     // Declare type as noncopyable
     ElevationMatrixFilter(const ElevationMatrixFilter& other) = delete;
@@ -78,29 +77,29 @@ private:
 /*
  */
 class GEOS_DLL ElevationMatrix {
-friend class ElevationMatrixFilter;
+    friend class ElevationMatrixFilter;
 public:
-	ElevationMatrix(const geom::Envelope &extent, unsigned int rows,
-		unsigned int cols);
-	~ElevationMatrix();
-	void add(const geom::Geometry *geom);
-	void elevate(geom::Geometry *geom) const;
-	// set Z value for each cell w/out one
-	double getAvgElevation() const;
-	ElevationMatrixCell &getCell(const geom::Coordinate &c);
-	const ElevationMatrixCell &getCell(const geom::Coordinate &c) const;
-	std::string print() const;
+    ElevationMatrix(const geom::Envelope& extent, unsigned int rows,
+                    unsigned int cols);
+    ~ElevationMatrix();
+    void add(const geom::Geometry* geom);
+    void elevate(geom::Geometry* geom) const;
+    // set Z value for each cell w/out one
+    double getAvgElevation() const;
+    ElevationMatrixCell& getCell(const geom::Coordinate& c);
+    const ElevationMatrixCell& getCell(const geom::Coordinate& c) const;
+    std::string print() const;
 private:
-	ElevationMatrixFilter filter;
-	void add(const geom::Coordinate &c);
-	geom::Envelope env;
-	unsigned int cols;
-	unsigned int rows;
-	double cellwidth;
-	double cellheight;
-	mutable bool avgElevationComputed;
-	mutable double avgElevation;
-	std::vector<ElevationMatrixCell>cells;
+    ElevationMatrixFilter filter;
+    void add(const geom::Coordinate& c);
+    geom::Envelope env;
+    unsigned int cols;
+    unsigned int rows;
+    double cellwidth;
+    double cellheight;
+    mutable bool avgElevationComputed;
+    mutable double avgElevation;
+    std::vector<ElevationMatrixCell>cells;
 };
 
 } // namespace geos::operation::overlay
diff --git a/include/geos/operation/overlay/ElevationMatrixCell.h b/include/geos/operation/overlay/ElevationMatrixCell.h
index 10f1792..d2235fa 100644
--- a/include/geos/operation/overlay/ElevationMatrixCell.h
+++ b/include/geos/operation/overlay/ElevationMatrixCell.h
@@ -30,9 +30,9 @@
 
 // Forward declarations
 namespace geos {
-	namespace geom {
-		class Coordinate;
-	}
+namespace geom {
+class Coordinate;
+}
 }
 
 namespace geos {
@@ -42,16 +42,16 @@ namespace overlay { // geos::operation::overlay
 
 class GEOS_DLL ElevationMatrixCell {
 public:
-	ElevationMatrixCell();
-	~ElevationMatrixCell();
-	void add(const geom::Coordinate &c);
-	void add(double z);
-	double getAvg(void) const;
-	double getTotal(void) const;
-	std::string print() const;
+    ElevationMatrixCell();
+    ~ElevationMatrixCell();
+    void add(const geom::Coordinate& c);
+    void add(double z);
+    double getAvg(void) const;
+    double getTotal(void) const;
+    std::string print() const;
 private:
-	std::set<double>zvals;
-	double ztot;
+    std::set<double>zvals;
+    double ztot;
 };
 
 } // namespace geos::operation::overlay
diff --git a/include/geos/operation/overlay/LineBuilder.h b/include/geos/operation/overlay/LineBuilder.h
index 387da61..e08dc4c 100644
--- a/include/geos/operation/overlay/LineBuilder.h
+++ b/include/geos/operation/overlay/LineBuilder.h
@@ -32,23 +32,23 @@
 
 // Forward declarations
 namespace geos {
-	namespace geom {
-		class GeometryFactory;
-		class CoordinateSequence;
-		class LineString;
-	}
-	namespace geomgraph {
-		class DirectedEdge;
-		class Edge;
-	}
-	namespace algorithm {
-		class PointLocator;
-	}
-	namespace operation {
-		namespace overlay {
-			class OverlayOp;
-		}
-	}
+namespace geom {
+class GeometryFactory;
+class CoordinateSequence;
+class LineString;
+}
+namespace geomgraph {
+class DirectedEdge;
+class Edge;
+}
+namespace algorithm {
+class PointLocator;
+}
+namespace operation {
+namespace overlay {
+class OverlayOp;
+}
+}
 }
 
 namespace geos {
@@ -64,69 +64,69 @@ class GEOS_DLL LineBuilder {
 
 public:
 
-	LineBuilder(OverlayOp *newOp,
-			const geom::GeometryFactory *newGeometryFactory,
-			algorithm::PointLocator *newPtLocator);
-
-	~LineBuilder();
-
-	/**
-	 * @return a list of the LineStrings in the result of the specified overlay operation
-	 */
-	std::vector<geom::LineString*>* build(OverlayOp::OpCode opCode);
-
-	/**
-	 * Collect line edges which are in the result.
-	 *
-	 * Line edges are in the result if they are not part of
-	 * an area boundary, if they are in the result of the overlay operation,
-	 * and if they are not covered by a result area.
-	 *
-	 * @param de the directed edge to test.
-	 * @param opCode the overlap operation
-	 * @param edges the list of included line edges.
-	 */
-	void collectLineEdge(geomgraph::DirectedEdge *de,
-			OverlayOp::OpCode opCode,
-			std::vector<geomgraph::Edge*>* edges);
+    LineBuilder(OverlayOp* newOp,
+                const geom::GeometryFactory* newGeometryFactory,
+                algorithm::PointLocator* newPtLocator);
+
+    ~LineBuilder();
+
+    /**
+     * @return a list of the LineStrings in the result of the specified overlay operation
+     */
+    std::vector<geom::LineString*>* build(OverlayOp::OpCode opCode);
+
+    /**
+     * Collect line edges which are in the result.
+     *
+     * Line edges are in the result if they are not part of
+     * an area boundary, if they are in the result of the overlay operation,
+     * and if they are not covered by a result area.
+     *
+     * @param de the directed edge to test.
+     * @param opCode the overlap operation
+     * @param edges the list of included line edges.
+     */
+    void collectLineEdge(geomgraph::DirectedEdge* de,
+                         OverlayOp::OpCode opCode,
+                         std::vector<geomgraph::Edge*>* edges);
 
 private:
-	OverlayOp *op;
-	const geom::GeometryFactory *geometryFactory;
-	algorithm::PointLocator *ptLocator;
-	std::vector<geomgraph::Edge*> lineEdgesList;
-	std::vector<geom::LineString*>* resultLineList;
-	void findCoveredLineEdges();
-	void collectLines(OverlayOp::OpCode opCode);
-	void buildLines(OverlayOp::OpCode opCode);
-	void labelIsolatedLines(std::vector<geomgraph::Edge*> *edgesList);
-
-	/**
-	 * Collect edges from Area inputs which should be in the result but
-	 * which have not been included in a result area.
-	 * This happens ONLY:
-	 *
-	 *  -  during an intersection when the boundaries of two
-	 *     areas touch in a line segment
-	 *  -   OR as a result of a dimensional collapse.
-	 *
-	 */
-	void collectBoundaryTouchEdge(geomgraph::DirectedEdge *de,
-			OverlayOp::OpCode opCode,
-			std::vector<geomgraph::Edge*>* edges);
-
-	/**
-	 * Label an isolated node with its relationship to the target geometry.
-	 */
-	void labelIsolatedLine(geomgraph::Edge *e, int targetIndex);
-
-	/*
-	 * If the given CoordinateSequence has mixed 3d/2d vertexes
-	 * set Z for all vertexes missing it.
-	 * The Z value is interpolated between 3d vertexes and copied
-	 * from a 3d vertex to the end.
-	 */
-	void propagateZ(geom::CoordinateSequence *cs);
+    OverlayOp* op;
+    const geom::GeometryFactory* geometryFactory;
+    algorithm::PointLocator* ptLocator;
+    std::vector<geomgraph::Edge*> lineEdgesList;
+    std::vector<geom::LineString*>* resultLineList;
+    void findCoveredLineEdges();
+    void collectLines(OverlayOp::OpCode opCode);
+    void buildLines(OverlayOp::OpCode opCode);
+    void labelIsolatedLines(std::vector<geomgraph::Edge*>* edgesList);
+
+    /**
+     * Collect edges from Area inputs which should be in the result but
+     * which have not been included in a result area.
+     * This happens ONLY:
+     *
+     *  -  during an intersection when the boundaries of two
+     *     areas touch in a line segment
+     *  -   OR as a result of a dimensional collapse.
+     *
+     */
+    void collectBoundaryTouchEdge(geomgraph::DirectedEdge* de,
+                                  OverlayOp::OpCode opCode,
+                                  std::vector<geomgraph::Edge*>* edges);
+
+    /**
+     * Label an isolated node with its relationship to the target geometry.
+     */
+    void labelIsolatedLine(geomgraph::Edge* e, int targetIndex);
+
+    /*
+     * If the given CoordinateSequence has mixed 3d/2d vertexes
+     * set Z for all vertexes missing it.
+     * The Z value is interpolated between 3d vertexes and copied
+     * from a 3d vertex to the end.
+     */
+    void propagateZ(geom::CoordinateSequence* cs);
 };
 
 } // namespace geos::operation::overlay
diff --git a/include/geos/operation/overlay/MaximalEdgeRing.h b/include/geos/operation/overlay/MaximalEdgeRing.h
index bee9505..3a583ac 100644
--- a/include/geos/operation/overlay/MaximalEdgeRing.h
+++ b/include/geos/operation/overlay/MaximalEdgeRing.h
@@ -27,18 +27,18 @@
 
 // Forward declarations
 namespace geos {
-	namespace geom {
-		class GeometryFactory;
-	}
-	namespace geomgraph {
-		class DirectedEdge;
-		//class EdgeRing;
-	}
-	namespace operation {
-		namespace overlay {
-			class MinimalEdgeRing;
-		}
-	}
+namespace geom {
+class GeometryFactory;
+}
+namespace geomgraph {
+class DirectedEdge;
+//class EdgeRing;
+}
+namespace operation {
+namespace overlay {
+class MinimalEdgeRing;
+}
+}
 }
 
 namespace geos {
@@ -67,36 +67,36 @@ class GEOS_DLL MaximalEdgeRing: public geomgraph::EdgeRing {
 
 public:
 
-	MaximalEdgeRing(geomgraph::DirectedEdge *start,
-		const geom::GeometryFactory *geometryFactory);
-			// throw(const TopologyException &)
+    MaximalEdgeRing(geomgraph::DirectedEdge* start,
+                    const geom::GeometryFactory* geometryFactory);
+    // throw(const TopologyException &)
 
-	~MaximalEdgeRing() override;
+    ~MaximalEdgeRing() override;
 
-	geomgraph::DirectedEdge* getNext(geomgraph::DirectedEdge *de) override;
+    geomgraph::DirectedEdge* getNext(geomgraph::DirectedEdge* de) override;
 
-	void setEdgeRing(geomgraph::DirectedEdge* de, geomgraph::EdgeRing* er) override;
+    void setEdgeRing(geomgraph::DirectedEdge* de, geomgraph::EdgeRing* er) override;
 
-	/// \brief
-	/// This function returns a newly allocated vector of
-	/// pointers to newly allocated MinimalEdgeRing objects.
-	///
-	/// @deprecated pass the vector yourself instead
-	///
-	std::vector<MinimalEdgeRing*>* buildMinimalRings();
+    /// \brief
+    /// This function returns a newly allocated vector of
+    /// pointers to newly allocated MinimalEdgeRing objects.
+    ///
+    /// @deprecated pass the vector yourself instead
+    ///
+    std::vector<MinimalEdgeRing*>* buildMinimalRings();
 
-	/// \brief
-	/// This function pushes pointers to newly allocated  MinimalEdgeRing
-	/// objects to the provided vector.
-	///
-	void buildMinimalRings(std::vector<MinimalEdgeRing*>& minEdgeRings);
-	void buildMinimalRings(std::vector<EdgeRing*>& minEdgeRings);
+    /// \brief
+    /// This function pushes pointers to newly allocated  MinimalEdgeRing
+    /// objects to the provided vector.
+    ///
+    void buildMinimalRings(std::vector<MinimalEdgeRing*>& minEdgeRings);
+    void buildMinimalRings(std::vector<EdgeRing*>& minEdgeRings);
 
-	/// \brief
-	/// For all nodes in this EdgeRing,
-	/// link the DirectedEdges at the node to form minimalEdgeRings
-	///
-	void linkDirectedEdgesForMinimalEdgeRings();
+    /// \brief
+    /// For all nodes in this EdgeRing,
+    /// link the DirectedEdges at the node to form minimalEdgeRings
+    ///
+    void linkDirectedEdgesForMinimalEdgeRings();
 };
 
 
diff --git a/include/geos/operation/overlay/MinimalEdgeRing.h b/include/geos/operation/overlay/MinimalEdgeRing.h
index d80b70e..74f3abd 100644
--- a/include/geos/operation/overlay/MinimalEdgeRing.h
+++ b/include/geos/operation/overlay/MinimalEdgeRing.h
@@ -30,13 +30,13 @@
 
 // Forward declarations
 namespace geos {
-	namespace geom {
-		class GeometryFactory;
-	}
-	namespace geomgraph {
-		class DirectedEdge;
-		class EdgeRing;
-	}
+namespace geom {
+class GeometryFactory;
+}
+namespace geomgraph {
+class DirectedEdge;
+class EdgeRing;
+}
 }
 
 namespace geos {
@@ -57,15 +57,15 @@ class GEOS_DLL MinimalEdgeRing: public geomgraph::EdgeRing {
 
 public:
 
-	MinimalEdgeRing(geomgraph::DirectedEdge *start,
-		const geom::GeometryFactory *geometryFactory);
+    MinimalEdgeRing(geomgraph::DirectedEdge* start,
+                    const geom::GeometryFactory* geometryFactory);
 
-	~MinimalEdgeRing() override;
+    ~MinimalEdgeRing() override;
 
-	geomgraph::DirectedEdge* getNext(geomgraph::DirectedEdge *de) override;
+    geomgraph::DirectedEdge* getNext(geomgraph::DirectedEdge* de) override;
 
-	void setEdgeRing(geomgraph::DirectedEdge *de,
-			geomgraph::EdgeRing *er) override;
+    void setEdgeRing(geomgraph::DirectedEdge* de,
+                     geomgraph::EdgeRing* er) override;
 };
 
 
diff --git a/include/geos/operation/overlay/MinimalEdgeRing.inl b/include/geos/operation/overlay/MinimalEdgeRing.inl
index 2f60d0c..fd6e5d9 100644
--- a/include/geos/operation/overlay/MinimalEdgeRing.inl
+++ b/include/geos/operation/overlay/MinimalEdgeRing.inl
@@ -7,7 +7,7 @@
  *
  * This is free software; you can redistribute and/or modify it under
  * the terms of the GNU Lesser General Public Licence as published
- * by the Free Software Foundation. 
+ * by the Free Software Foundation.
  * See the COPYING file for more information.
  *
  **********************************************************************
@@ -30,22 +30,22 @@ namespace operation { // geos::operation
 namespace overlay { // geos::operation::overlay
 
 INLINE void
-MinimalEdgeRing::setEdgeRing(geomgraph::DirectedEdge *de, geomgraph::EdgeRing *er)
+MinimalEdgeRing::setEdgeRing(geomgraph::DirectedEdge* de, geomgraph::EdgeRing* er)
 {
-	de->setMinEdgeRing(er);
+    de->setMinEdgeRing(er);
 }
 
 INLINE geomgraph::DirectedEdge*
-MinimalEdgeRing::getNext(geomgraph::DirectedEdge *de)
+MinimalEdgeRing::getNext(geomgraph::DirectedEdge* de)
 {
-	return de->getNextMin();
+    return de->getNextMin();
 }
 
 INLINE
 MinimalEdgeRing::~MinimalEdgeRing()
 {
 #if GEOS_DEBUG
-	std::cerr << "MinimalEdgeRing[" << this << "] dtor" << std::endl;
+    std::cerr << "MinimalEdgeRing[" << this << "] dtor" << std::endl;
 #endif
 }
 
diff --git a/include/geos/operation/overlay/OverlayNodeFactory.h b/include/geos/operation/overlay/OverlayNodeFactory.h
index bd345b8..1b6b5d0 100644
--- a/include/geos/operation/overlay/OverlayNodeFactory.h
+++ b/include/geos/operation/overlay/OverlayNodeFactory.h
@@ -27,12 +27,12 @@
 
 // Forward declarations
 namespace geos {
-	namespace geom {
-		class Coordinate;
-	}
-	namespace geomgraph {
-		class Node;
-	}
+namespace geom {
+class Coordinate;
+}
+namespace geomgraph {
+class Node;
+}
 }
 
 namespace geos {
@@ -45,9 +45,9 @@ namespace overlay { // geos::operation::overlay
  */
 class GEOS_DLL OverlayNodeFactory: public geomgraph::NodeFactory {
 public:
-	OverlayNodeFactory():geomgraph::NodeFactory() {}
-	geomgraph::Node* createNode(const geom::Coordinate &coord) const override;
-	static const geomgraph::NodeFactory &instance();
+    OverlayNodeFactory(): geomgraph::NodeFactory() {}
+    geomgraph::Node* createNode(const geom::Coordinate& coord) const override;
+    static const geomgraph::NodeFactory& instance();
 };
 
 
diff --git a/include/geos/operation/overlay/OverlayOp.h b/include/geos/operation/overlay/OverlayOp.h
index b3991c7..2e2445e 100644
--- a/include/geos/operation/overlay/OverlayOp.h
+++ b/include/geos/operation/overlay/OverlayOp.h
@@ -36,25 +36,25 @@
 
 // Forward declarations
 namespace geos {
-	namespace geom {
-		class Geometry;
-		class Coordinate;
-		class Envelope;
-		class GeometryFactory;
-		class Polygon;
-		class LineString;
-		class Point;
-	}
-	namespace geomgraph {
-		class Label;
-		class Edge;
-		class Node;
-	}
-	namespace operation {
-		namespace overlay {
-			class ElevationMatrix;
-		}
-	}
+namespace geom {
+class Geometry;
+class Coordinate;
+class Envelope;
+class GeometryFactory;
+class Polygon;
+class LineString;
+class Point;
+}
+namespace geomgraph {
+class Label;
+class Edge;
+class Node;
+}
+namespace operation {
+namespace overlay {
+class ElevationMatrix;
+}
+}
 }
 
 namespace geos {
@@ -70,328 +70,332 @@ class GEOS_DLL OverlayOp: public GeometryGraphOperation {
 
 public:
 
-	/// The spatial functions supported by this class.
-	//
-	/// These operations implement various boolean combinations of
-	/// the resultants of the overlay.
-	///
-	enum OpCode {
-		/// The code for the Intersection overlay operation.
-		opINTERSECTION = 1,
-		/// The code for the Union overlay operation.
-		opUNION = 2,
-		/// The code for the Difference overlay operation.
-		opDIFFERENCE = 3,
-		/// The code for the Symmetric Difference overlay operation.
-		opSYMDIFFERENCE = 4
-	};
-
-	/**
-	 * Computes an overlay operation for the given geometry arguments.
-	 *
-	 * @param geom0 the first geometry argument
-	 * @param geom1 the second geometry argument
-	 * @param opCode the code for the desired overlay operation
-	 * @return the result of the overlay operation
-	 * @throws TopologyException if a robustness problem is encountered
-	 */
-	static geom::Geometry* overlayOp(const geom::Geometry *geom0,
-			const geom::Geometry *geom1,
-			OpCode opCode);
-		//throw(TopologyException *);
-
-	/**
-	 * Tests whether a point with a given topological {@link Label}
-	 * relative to two geometries is contained in
-	 * the result of overlaying the geometries using
-	 * a given overlay operation.
-	 *
-	 * The method handles arguments of {@link Location#NONE} correctly
-	 *
-	 * @param label the topological label of the point
-	 * @param opCode the code for the overlay operation to test
-	 * @return true if the label locations correspond to the overlayOpCode
-	 */
-	static bool isResultOfOp(const geomgraph::Label& label, OpCode opCode);
-
-	/// This method will handle arguments of Location.NULL correctly
-	//
-	/// @return true if the locations correspond to the opCode
-	///
-	static bool isResultOfOp(int loc0, int loc1, OpCode opCode);
-
-	/// Construct an OverlayOp with the given Geometry args.
-	//
-	/// Ownership of passed args will remain to caller, and
-	/// the OverlayOp won't change them in any way.
-	///
-	OverlayOp(const geom::Geometry *g0, const geom::Geometry *g1);
-
-	~OverlayOp() override; // FIXME: virtual ?
-
-	/**
-	 * Gets the result of the overlay for a given overlay operation.
-	 *
-	 * Note: this method can be called once only.
-	 *
-	 * @param overlayOpCode the overlay operation to perform
-	 * @return the compute result geometry
-	 * @throws TopologyException if a robustness problem is encountered
-	 */
-	geom::Geometry* getResultGeometry(OpCode overlayOpCode);
-		// throw(TopologyException *);
-
-	/**
-	 * Gets the graph constructed to compute the overlay.
-	 *
-	 * @return the overlay graph
-	 */
-	geomgraph::PlanarGraph& getGraph() { return graph; }
-
-	/** \brief
-	 * This method is used to decide if a point node should be included
-	 * in the result or not.
-	 *
-	 * @return true if the coord point is covered by a result Line
-	 * or Area geometry
-	 */
-	bool isCoveredByLA(const geom::Coordinate& coord);
-
-	/** \brief
-	 * This method is used to decide if an L edge should be included
-	 * in the result or not.
-	 *
-	 * @return true if the coord point is covered by a result Area geometry
-	 */
-	bool isCoveredByA(const geom::Coordinate& coord);
-
-	/*
-	 * @return true if the coord is located in the interior or boundary of
-	 * a geometry in the list.
-	 */
+    /// The spatial functions supported by this class.
+    //
+    /// These operations implement various boolean combinations of
+    /// the resultants of the overlay.
+    ///
+    enum OpCode {
+        /// The code for the Intersection overlay operation.
+        opINTERSECTION = 1,
+        /// The code for the Union overlay operation.
+        opUNION = 2,
+        /// The code for the Difference overlay operation.
+        opDIFFERENCE = 3,
+        /// The code for the Symmetric Difference overlay operation.
+        opSYMDIFFERENCE = 4
+    };
+
+    /**
+     * Computes an overlay operation for the given geometry arguments.
+     *
+     * @param geom0 the first geometry argument
+     * @param geom1 the second geometry argument
+     * @param opCode the code for the desired overlay operation
+     * @return the result of the overlay operation
+     * @throws TopologyException if a robustness problem is encountered
+     */
+    static geom::Geometry* overlayOp(const geom::Geometry* geom0,
+                                     const geom::Geometry* geom1,
+                                     OpCode opCode);
+    //throw(TopologyException *);
+
+    /**
+     * Tests whether a point with a given topological {@link Label}
+     * relative to two geometries is contained in
+     * the result of overlaying the geometries using
+     * a given overlay operation.
+     *
+     * The method handles arguments of {@link Location#NONE} correctly
+     *
+     * @param label the topological label of the point
+     * @param opCode the code for the overlay operation to test
+     * @return true if the label locations correspond to the overlayOpCode
+     */
+    static bool isResultOfOp(const geomgraph::Label& label, OpCode opCode);
+
+    /// This method will handle arguments of Location.NULL correctly
+    //
+    /// @return true if the locations correspond to the opCode
+    ///
+    static bool isResultOfOp(int loc0, int loc1, OpCode opCode);
+
+    /// Construct an OverlayOp with the given Geometry args.
+    //
+    /// Ownership of passed args will remain to caller, and
+    /// the OverlayOp won't change them in any way.
+    ///
+    OverlayOp(const geom::Geometry* g0, const geom::Geometry* g1);
+
+    ~OverlayOp() override; // FIXME: virtual ?
+
+    /**
+     * Gets the result of the overlay for a given overlay operation.
+     *
+     * Note: this method can be called once only.
+     *
+     * @param overlayOpCode the overlay operation to perform
+     * @return the compute result geometry
+     * @throws TopologyException if a robustness problem is encountered
+     */
+    geom::Geometry* getResultGeometry(OpCode overlayOpCode);
+    // throw(TopologyException *);
+
+    /**
+     * Gets the graph constructed to compute the overlay.
+     *
+     * @return the overlay graph
+     */
+    geomgraph::PlanarGraph&
+    getGraph()
+    {
+        return graph;
+    }
+
+    /** \brief
+     * This method is used to decide if a point node should be included
+     * in the result or not.
+     *
+     * @return true if the coord point is covered by a result Line
+     * or Area geometry
+     */
+    bool isCoveredByLA(const geom::Coordinate& coord);
+
+    /** \brief
+     * This method is used to decide if an L edge should be included
+     * in the result or not.
+     *
+     * @return true if the coord point is covered by a result Area geometry
+     */
+    bool isCoveredByA(const geom::Coordinate& coord);
+
+    /*
+     * @return true if the coord is located in the interior or boundary of
+     * a geometry in the list.
+     */
 
 protected:
 
-	/** \brief
-	 * Insert an edge from one of the noded input graphs.
-	 *
-	 * Checks edges that are inserted to see if an
-	 * identical edge already exists.
-	 * If so, the edge is not inserted, but its label is merged
-	 * with the existing edge.
-	 */
-	void insertUniqueEdge(geomgraph::Edge *e);
+    /** \brief
+     * Insert an edge from one of the noded input graphs.
+     *
+     * Checks edges that are inserted to see if an
+     * identical edge already exists.
+     * If so, the edge is not inserted, but its label is merged
+     * with the existing edge.
+     */
+    void insertUniqueEdge(geomgraph::Edge* e);
 
 private:
 
-	algorithm::PointLocator ptLocator;
-
-	const geom::GeometryFactory *geomFact;
-
-	geom::Geometry *resultGeom;
-
-	geomgraph::PlanarGraph graph;
-
-	geomgraph::EdgeList edgeList;
-
-	std::vector<geom::Polygon*> *resultPolyList;
-
-	std::vector<geom::LineString*> *resultLineList;
-
-	std::vector<geom::Point*> *resultPointList;
-
-	void computeOverlay(OpCode opCode); // throw(TopologyException *);
-
-	void insertUniqueEdges(std::vector<geomgraph::Edge*> *edges, const geom::Envelope *env=nullptr);
-
-	/*
-	 * If either of the GeometryLocations for the existing label is
-	 * exactly opposite to the one in the labelToMerge,
-	 * this indicates a dimensional collapse has happened.
-	 * In this case, convert the label for that Geometry to a Line label
-	 */
-	//Not needed
-	//void checkDimensionalCollapse(geomgraph::Label labelToMerge, geomgraph::Label existingLabel);
-
-	/** \brief
-	 * Update the labels for edges according to their depths.
-	 *
-	 * For each edge, the depths are first normalized.
-	 * Then, if the depths for the edge are equal,
-	 * this edge must have collapsed into a line edge.
-	 * If the depths are not equal, update the label
-	 * with the locations corresponding to the depths
-	 * (i.e. a depth of 0 corresponds to a Location of EXTERIOR,
-	 * a depth of 1 corresponds to INTERIOR)
-	 */
-	void computeLabelsFromDepths();
-
-	/** \brief
-	 * If edges which have undergone dimensional collapse are found,
-	 * replace them with a new edge which is a L edge
-	 */
-	void replaceCollapsedEdges();
-
-	/** \brief
-	 * Copy all nodes from an arg geometry into this graph.
-	 *
-	 * The node label in the arg geometry overrides any previously
-	 * computed label for that argIndex.
-	 * (E.g. a node may be an intersection node with
-	 * a previously computed label of BOUNDARY,
-	 * but in the original arg Geometry it is actually
-	 * in the interior due to the Boundary Determination Rule)
-	 */
-	void copyPoints(int argIndex, const geom::Envelope *env=nullptr);
-
-	/** \brief
-	 * Compute initial labelling for all DirectedEdges at each node.
-	 *
-	 * In this step, DirectedEdges will acquire a complete labelling
-	 * (i.e. one with labels for both Geometries)
-	 * only if they
-	 * are incident on a node which has edges for both Geometries
-	 */
-	void computeLabelling(); // throw(TopologyException *);
-
-	/**
-	 * For nodes which have edges from only one Geometry incident on them,
-	 * the previous step will have left their dirEdges with no
-	 * labelling for the other Geometry.
-	 * However, the sym dirEdge may have a labelling for the other
-	 * Geometry, so merge the two labels.
-	 */
-	void mergeSymLabels();
-
-	void updateNodeLabelling();
-
-	/**
-	 * Incomplete nodes are nodes whose labels are incomplete.
-	 *
-	 * (e.g. the location for one Geometry is NULL).
-	 * These are either isolated nodes,
-	 * or nodes which have edges from only a single Geometry incident
-	 * on them.
-	 *
-	 * Isolated nodes are found because nodes in one graph which
-	 * don't intersect nodes in the other are not completely
-	 * labelled by the initial process of adding nodes to the nodeList.
-	 * To complete the labelling we need to check for nodes that
-	 * lie in the interior of edges, and in the interior of areas.
-	 *
-	 * When each node labelling is completed, the labelling of the
-	 * incident edges is updated, to complete their labelling as well.
-	 */
-	void labelIncompleteNodes();
-
-	/** \brief
-	 * Label an isolated node with its relationship to the target geometry.
-	 */
-	void labelIncompleteNode(geomgraph::Node *n, int targetIndex);
-
-	/** \brief
-	 * Find all edges whose label indicates that they are in the result
-	 * area(s), according to the operation being performed.
-	 *
-	 * Since we want polygon shells to be
-	 * oriented CW, choose dirEdges with the interior of the result
-	 * on the RHS.
-	 * Mark them as being in the result.
-	 * Interior Area edges are the result of dimensional collapses.
-	 * They do not form part of the result area boundary.
-	 */
-	void findResultAreaEdges(OpCode opCode);
-
-	/**
-	 * If both a dirEdge and its sym are marked as being in the result,
-	 * cancel them out.
-	 */
-	void cancelDuplicateResultEdges();
-
-	/**
-	 * @return true if the coord is located in the interior or boundary of
-	 * a geometry in the list.
-	 */
-	bool isCovered(const geom::Coordinate& coord,
-			std::vector<geom::Geometry*> *geomList);
-
-	/**
-	 * @return true if the coord is located in the interior or boundary of
-	 * a geometry in the list.
-	 */
-	bool isCovered(const geom::Coordinate& coord,
-			std::vector<geom::Polygon*> *geomList);
-
-	/**
-	 * @return true if the coord is located in the interior or boundary of
-	 * a geometry in the list.
-	 */
-	bool isCovered(const geom::Coordinate& coord,
-			std::vector<geom::LineString*> *geomList);
-	/**
-	* For empty result, what is the correct geometry type to apply to
-	* the empty?
-	*/
-	static geom::Dimension::DimensionType resultDimension(OverlayOp::OpCode overlayOpCode,
-		const geom::Geometry *g0, const geom::Geometry *g1);
-
-	/**
-	* Creates an empty result geometry of the appropriate dimension,
-	* based on the given overlay operation and the dimensions of the inputs.
-	* The created geometry is always an atomic geometry,
-	* not a collection.
-	*
-	* The empty result is constructed using the following rules:
-	*
-	* * #opINTERSECTION  result has the dimension of the lowest input dimension
-	* * #opUNION - result has the dimension of the highest input dimension
-	* * #opDIFFERENCE - result has the dimension of the left-hand input
-	* * #opSYMDIFFERENCE - result has the dimension of the highest input dimension
-	*/
-	static geom::Geometry* createEmptyResult(
-		OverlayOp::OpCode overlayOpCode, const geom::Geometry *a,
-		const geom::Geometry *b, const geom::GeometryFactory *geomFact);
-
-	/**
-	 * Build a Geometry containing all Geometries in the given vectors.
-	 * Takes element's ownership, vector control is left to caller.
-	 */
-	geom::Geometry* computeGeometry(
-			std::vector<geom::Point*> *nResultPointList,
-			std::vector<geom::LineString*> *nResultLineList,
-			std::vector<geom::Polygon*> *nResultPolyList,
-			OverlayOp::OpCode opCode);
-
-	/// Caches for memory management
-	std::vector<geomgraph::Edge *>dupEdges;
-
-	/** \brief
-	 * Merge Z values of node with those of the segment or vertex in
-	 * the given Polygon it is on.
-	 */
-	int mergeZ(geomgraph::Node *n, const geom::Polygon *poly) const;
-
-	/**
-	 * Merge Z values of node with those of the segment or vertex in
-	 * the given LineString it is on.
-	 * @returns 1 if an intersection is found, 0 otherwise.
-	 */
-	int mergeZ(geomgraph::Node *n, const geom::LineString *line) const;
-
-	/**
-	 * Average Z of input geometries
-	 */
-	double avgz[2];
-	bool avgzcomputed[2];
-
-	double getAverageZ(int targetIndex);
-	static double getAverageZ(const geom::Polygon *poly);
-
-	ElevationMatrix *elevationMatrix;
-
-	/// Throw TopologyException if an obviously wrong result has
-	/// been computed.
-	void checkObviouslyWrongResult(OpCode opCode);
+    algorithm::PointLocator ptLocator;
+
+    const geom::GeometryFactory* geomFact;
+
+    geom::Geometry* resultGeom;
+
+    geomgraph::PlanarGraph graph;
+
+    geomgraph::EdgeList edgeList;
+
+    std::vector<geom::Polygon*>* resultPolyList;
+
+    std::vector<geom::LineString*>* resultLineList;
+
+    std::vector<geom::Point*>* resultPointList;
+
+    void computeOverlay(OpCode opCode); // throw(TopologyException *);
+
+    void insertUniqueEdges(std::vector<geomgraph::Edge*>* edges, const geom::Envelope* env = nullptr);
+
+    /*
+     * If either of the GeometryLocations for the existing label is
+     * exactly opposite to the one in the labelToMerge,
+     * this indicates a dimensional collapse has happened.
+     * In this case, convert the label for that Geometry to a Line label
+     */
+    //Not needed
+    //void checkDimensionalCollapse(geomgraph::Label labelToMerge, geomgraph::Label existingLabel);
+
+    /** \brief
+     * Update the labels for edges according to their depths.
+     *
+     * For each edge, the depths are first normalized.
+     * Then, if the depths for the edge are equal,
+     * this edge must have collapsed into a line edge.
+     * If the depths are not equal, update the label
+     * with the locations corresponding to the depths
+     * (i.e. a depth of 0 corresponds to a Location of EXTERIOR,
+     * a depth of 1 corresponds to INTERIOR)
+     */
+    void computeLabelsFromDepths();
+
+    /** \brief
+     * If edges which have undergone dimensional collapse are found,
+     * replace them with a new edge which is a L edge
+     */
+    void replaceCollapsedEdges();
+
+    /** \brief
+     * Copy all nodes from an arg geometry into this graph.
+     *
+     * The node label in the arg geometry overrides any previously
+     * computed label for that argIndex.
+     * (E.g. a node may be an intersection node with
+     * a previously computed label of BOUNDARY,
+     * but in the original arg Geometry it is actually
+     * in the interior due to the Boundary Determination Rule)
+     */
+    void copyPoints(int argIndex, const geom::Envelope* env = nullptr);
+
+    /** \brief
+     * Compute initial labelling for all DirectedEdges at each node.
+     *
+     * In this step, DirectedEdges will acquire a complete labelling
+     * (i.e. one with labels for both Geometries)
+     * only if they
+     * are incident on a node which has edges for both Geometries
+     */
+    void computeLabelling(); // throw(TopologyException *);
+
+    /**
+     * For nodes which have edges from only one Geometry incident on them,
+     * the previous step will have left their dirEdges with no
+     * labelling for the other Geometry.
+     * However, the sym dirEdge may have a labelling for the other
+     * Geometry, so merge the two labels.
+     */
+    void mergeSymLabels();
+
+    void updateNodeLabelling();
+
+    /**
+     * Incomplete nodes are nodes whose labels are incomplete.
+     *
+     * (e.g. the location for one Geometry is NULL).
+     * These are either isolated nodes,
+     * or nodes which have edges from only a single Geometry incident
+     * on them.
+     *
+     * Isolated nodes are found because nodes in one graph which
+     * don't intersect nodes in the other are not completely
+     * labelled by the initial process of adding nodes to the nodeList.
+     * To complete the labelling we need to check for nodes that
+     * lie in the interior of edges, and in the interior of areas.
+     *
+     * When each node labelling is completed, the labelling of the
+     * incident edges is updated, to complete their labelling as well.
+     */
+    void labelIncompleteNodes();
+
+    /** \brief
+     * Label an isolated node with its relationship to the target geometry.
+     */
+    void labelIncompleteNode(geomgraph::Node* n, int targetIndex);
+
+    /** \brief
+     * Find all edges whose label indicates that they are in the result
+     * area(s), according to the operation being performed.
+     *
+     * Since we want polygon shells to be
+     * oriented CW, choose dirEdges with the interior of the result
+     * on the RHS.
+     * Mark them as being in the result.
+     * Interior Area edges are the result of dimensional collapses.
+     * They do not form part of the result area boundary.
+     */
+    void findResultAreaEdges(OpCode opCode);
+
+    /**
+     * If both a dirEdge and its sym are marked as being in the result,
+     * cancel them out.
+     */
+    void cancelDuplicateResultEdges();
+
+    /**
+     * @return true if the coord is located in the interior or boundary of
+     * a geometry in the list.
+     */
+    bool isCovered(const geom::Coordinate& coord,
+                   std::vector<geom::Geometry*>* geomList);
+
+    /**
+     * @return true if the coord is located in the interior or boundary of
+     * a geometry in the list.
+     */
+    bool isCovered(const geom::Coordinate& coord,
+                   std::vector<geom::Polygon*>* geomList);
+
+    /**
+     * @return true if the coord is located in the interior or boundary of
+     * a geometry in the list.
+     */
+    bool isCovered(const geom::Coordinate& coord,
+                   std::vector<geom::LineString*>* geomList);
+    /**
+    * For empty result, what is the correct geometry type to apply to
+    * the empty?
+    */
+    static geom::Dimension::DimensionType resultDimension(OverlayOp::OpCode overlayOpCode,
+            const geom::Geometry* g0, const geom::Geometry* g1);
+
+    /**
+    * Creates an empty result geometry of the appropriate dimension,
+    * based on the given overlay operation and the dimensions of the inputs.
+    * The created geometry is always an atomic geometry,
+    * not a collection.
+    *
+    * The empty result is constructed using the following rules:
+    *
+    * * #opINTERSECTION  result has the dimension of the lowest input dimension
+    * * #opUNION - result has the dimension of the highest input dimension
+    * * #opDIFFERENCE - result has the dimension of the left-hand input
+    * * #opSYMDIFFERENCE - result has the dimension of the highest input dimension
+    */
+    static geom::Geometry* createEmptyResult(
+        OverlayOp::OpCode overlayOpCode, const geom::Geometry* a,
+        const geom::Geometry* b, const geom::GeometryFactory* geomFact);
+
+    /**
+     * Build a Geometry containing all Geometries in the given vectors.
+     * Takes element's ownership, vector control is left to caller.
+     */
+    geom::Geometry* computeGeometry(
+        std::vector<geom::Point*>* nResultPointList,
+        std::vector<geom::LineString*>* nResultLineList,
+        std::vector<geom::Polygon*>* nResultPolyList,
+        OverlayOp::OpCode opCode);
+
+    /// Caches for memory management
+    std::vector<geomgraph::Edge*>dupEdges;
+
+    /** \brief
+     * Merge Z values of node with those of the segment or vertex in
+     * the given Polygon it is on.
+     */
+    int mergeZ(geomgraph::Node* n, const geom::Polygon* poly) const;
+
+    /**
+     * Merge Z values of node with those of the segment or vertex in
+     * the given LineString it is on.
+     * @returns 1 if an intersection is found, 0 otherwise.
+     */
+    int mergeZ(geomgraph::Node* n, const geom::LineString* line) const;
+
+    /**
+     * Average Z of input geometries
+     */
+    double avgz[2];
+    bool avgzcomputed[2];
+
+    double getAverageZ(int targetIndex);
+    static double getAverageZ(const geom::Polygon* poly);
+
+    ElevationMatrix* elevationMatrix;
+
+    /// Throw TopologyException if an obviously wrong result has
+    /// been computed.
+    void checkObviouslyWrongResult(OpCode opCode);
 
 };
 
@@ -400,18 +404,19 @@ private:
  */
 struct overlayOp {
 
-        OverlayOp::OpCode opCode;
+    OverlayOp::OpCode opCode;
 
-        overlayOp(OverlayOp::OpCode code)
-                :
-                opCode(code)
-        {}
+    overlayOp(OverlayOp::OpCode code)
+        :
+        opCode(code)
+    {}
 
-        geom::Geometry* operator() (const geom::Geometry* g0,
-                                    const geom::Geometry* g1)
-        {
-                return OverlayOp::overlayOp(g0, g1, opCode);
-        }
+    geom::Geometry*
+    operator()(const geom::Geometry* g0,
+               const geom::Geometry* g1)
+    {
+        return OverlayOp::overlayOp(g0, g1, opCode);
+    }
 
 };
 
diff --git a/include/geos/operation/overlay/PointBuilder.h b/include/geos/operation/overlay/PointBuilder.h
index d85b3ee..86a7765 100644
--- a/include/geos/operation/overlay/PointBuilder.h
+++ b/include/geos/operation/overlay/PointBuilder.h
@@ -29,21 +29,21 @@
 
 // Forward declarations
 namespace geos {
-	namespace geom {
-		class GeometryFactory;
-		class Point;
-	}
-	namespace geomgraph {
-		class Node;
-	}
-	namespace algorithm {
-		class PointLocator;
-	}
-	namespace operation {
-		namespace overlay {
-			class OverlayOp;
-		}
-	}
+namespace geom {
+class GeometryFactory;
+class Point;
+}
+namespace geomgraph {
+class Node;
+}
+namespace algorithm {
+class PointLocator;
+}
+namespace operation {
+namespace overlay {
+class OverlayOp;
+}
+}
 }
 
 namespace geos {
@@ -56,46 +56,46 @@ namespace overlay { // geos::operation::overlay
 class GEOS_DLL PointBuilder {
 private:
 
-	OverlayOp *op;
-	const geom::GeometryFactory *geometryFactory;
-	void extractNonCoveredResultNodes(OverlayOp::OpCode opCode);
-
-	/*
-	 * Converts non-covered nodes to Point objects and adds them to
-	 * the result.
-	 *
-	 * A node is covered if it is contained in another element Geometry
-	 * with higher dimension (e.g. a node point might be contained in
-	 * a polygon, in which case the point can be eliminated from
-	 * the result).
-	 *
-	 * @param n the node to test
-	 */
-	void filterCoveredNodeToPoint(const geomgraph::Node *);
-
-	/// Allocated a construction time, but not owned.
-	/// Make sure you take ownership of it, getting
-	/// it from build()
-	std::vector<geom::Point*> *resultPointList;
+    OverlayOp* op;
+    const geom::GeometryFactory* geometryFactory;
+    void extractNonCoveredResultNodes(OverlayOp::OpCode opCode);
+
+    /*
+     * Converts non-covered nodes to Point objects and adds them to
+     * the result.
+     *
+     * A node is covered if it is contained in another element Geometry
+     * with higher dimension (e.g. a node point might be contained in
+     * a polygon, in which case the point can be eliminated from
+     * the result).
+     *
+     * @param n the node to test
+     */
+    void filterCoveredNodeToPoint(const geomgraph::Node*);
+
+    /// Allocated a construction time, but not owned.
+    /// Make sure you take ownership of it, getting
+    /// it from build()
+    std::vector<geom::Point*>* resultPointList;
 
 public:
 
-	PointBuilder(OverlayOp *newOp,
-			const geom::GeometryFactory *newGeometryFactory,
-			algorithm::PointLocator *newPtLocator=nullptr)
-		:
-		op(newOp),
-		geometryFactory(newGeometryFactory),
-		resultPointList(new std::vector<geom::Point *>())
-	{
+    PointBuilder(OverlayOp* newOp,
+                 const geom::GeometryFactory* newGeometryFactory,
+                 algorithm::PointLocator* newPtLocator = nullptr)
+        :
+        op(newOp),
+        geometryFactory(newGeometryFactory),
+        resultPointList(new std::vector<geom::Point *>())
+    {
         ::geos::ignore_unused_variable_warning(newPtLocator);
     }
 
-	/**
-	 * @return a list of the Points in the result of the specified
-	 * overlay operation
-	 */
-	std::vector<geom::Point*>* build(OverlayOp::OpCode opCode);
+    /**
+     * @return a list of the Points in the result of the specified
+     * overlay operation
+     */
+    std::vector<geom::Point*>* build(OverlayOp::OpCode opCode);
 };
 
 
diff --git a/include/geos/operation/overlay/PolygonBuilder.h b/include/geos/operation/overlay/PolygonBuilder.h
index b976d85..aa9e9a0 100644
--- a/include/geos/operation/overlay/PolygonBuilder.h
+++ b/include/geos/operation/overlay/PolygonBuilder.h
@@ -31,23 +31,23 @@
 
 // Forward declarations
 namespace geos {
-	namespace geom {
-		class Geometry;
-		class Coordinate;
-		class GeometryFactory;
-	}
-	namespace geomgraph {
-		class EdgeRing;
-		class Node;
-		class PlanarGraph;
-		class DirectedEdge;
-	}
-	namespace operation {
-		namespace overlay {
-			class MaximalEdgeRing;
-			class MinimalEdgeRing;
-		}
-	}
+namespace geom {
+class Geometry;
+class Coordinate;
+class GeometryFactory;
+}
+namespace geomgraph {
+class EdgeRing;
+class Node;
+class PlanarGraph;
+class DirectedEdge;
+}
+namespace operation {
+namespace overlay {
+class MaximalEdgeRing;
+class MinimalEdgeRing;
+}
+}
 }
 
 namespace geos {
@@ -62,142 +62,142 @@ namespace overlay { // geos::operation::overlay
 class GEOS_DLL PolygonBuilder {
 public:
 
-	PolygonBuilder(const geom::GeometryFactory *newGeometryFactory);
+    PolygonBuilder(const geom::GeometryFactory* newGeometryFactory);
 
-	~PolygonBuilder();
+    ~PolygonBuilder();
 
-	/**
-	 * Add a complete graph.
-	 * The graph is assumed to contain one or more polygons,
-	 * possibly with holes.
-	 */
-	void add(geomgraph::PlanarGraph *graph);
-	    // throw(const TopologyException &)
+    /**
+     * Add a complete graph.
+     * The graph is assumed to contain one or more polygons,
+     * possibly with holes.
+     */
+    void add(geomgraph::PlanarGraph* graph);
+    // throw(const TopologyException &)
 
-	/**
-	 * Add a set of edges and nodes, which form a graph.
-	 * The graph is assumed to contain one or more polygons,
-	 * possibly with holes.
-	 */
-	void add(const std::vector<geomgraph::DirectedEdge*> *dirEdges,
-			const std::vector<geomgraph::Node*> *nodes);
-			// throw(const TopologyException &)
+    /**
+     * Add a set of edges and nodes, which form a graph.
+     * The graph is assumed to contain one or more polygons,
+     * possibly with holes.
+     */
+    void add(const std::vector<geomgraph::DirectedEdge*>* dirEdges,
+             const std::vector<geomgraph::Node*>* nodes);
+    // throw(const TopologyException &)
 
-  	std::vector<geom::Geometry*>* getPolygons();
+    std::vector<geom::Geometry*>* getPolygons();
 
 private:
 
-	const geom::GeometryFactory *geometryFactory;
-
-	std::vector<geomgraph::EdgeRing*> shellList;
-
-	/**
-	 * For all DirectedEdges in result, form them into MaximalEdgeRings
-	 *
-	 * @param maxEdgeRings
-	 *   Formed MaximalEdgeRings will be pushed to this vector.
-	 *   Ownership of the elements is transferred to caller.
-	 */
-	void buildMaximalEdgeRings(
-		const std::vector<geomgraph::DirectedEdge*> *dirEdges,
-		std::vector<MaximalEdgeRing*> &maxEdgeRings);
-			// throw(const TopologyException &)
-
-	void buildMinimalEdgeRings(
-		std::vector<MaximalEdgeRing*> &maxEdgeRings,
-		std::vector<geomgraph::EdgeRing*> &newShellList,
-		std::vector<geomgraph::EdgeRing*> &freeHoleList,
-		std::vector<MaximalEdgeRing*> &edgeRings);
-
-	/**
-	 * This method takes a list of MinimalEdgeRings derived from a
-	 * MaximalEdgeRing, and tests whether they form a Polygon.
-	 * This is the case if there is a single shell
-	 * in the list.  In this case the shell is returned.
-	 * The other possibility is that they are a series of connected
-	 * holes, in which case no shell is returned.
-	 *
-	 * @return the shell geomgraph::EdgeRing, if there is one
-	 * @return NULL, if all the rings are holes
-	 */
-	geomgraph::EdgeRing* findShell(std::vector<MinimalEdgeRing*>* minEdgeRings);
-
-	/**
-	 * This method assigns the holes for a Polygon (formed from a list of
-	 * MinimalEdgeRings) to its shell.
-	 * Determining the holes for a MinimalEdgeRing polygon serves two
-	 * purposes:
-	 *
-	 *  - it is faster than using a point-in-polygon check later on.
-	 *  - it ensures correctness, since if the PIP test was used the point
-	 *    chosen might lie on the shell, which might return an incorrect
-	 *    result from the PIP test
-	 */
-	void placePolygonHoles(geomgraph::EdgeRing *shell,
-		std::vector<MinimalEdgeRing*> *minEdgeRings);
-
-	/**
-	 * For all rings in the input list,
-	 * determine whether the ring is a shell or a hole
-	 * and add it to the appropriate list.
-	 * Due to the way the DirectedEdges were linked,
-	 * a ring is a shell if it is oriented CW, a hole otherwise.
-	 */
-	void sortShellsAndHoles(std::vector<MaximalEdgeRing*> &edgeRings,
-		std::vector<geomgraph::EdgeRing*> &newShellList,
-		std::vector<geomgraph::EdgeRing*> &freeHoleList);
-
-	struct FastPIPRing {
-		geomgraph::EdgeRing* edgeRing;
-		algorithm::locate::IndexedPointInAreaLocator* pipLocator;
-	};
-
-	/** \brief
-	 * This method determines finds a containing shell for all holes
-	 * which have not yet been assigned to a shell.
-	 *
-	 * These "free" holes should all be <b>properly</b> contained in
-	 * their parent shells, so it is safe to use the
-	 * <code>findEdgeRingContaining</code> method.
-	 * This is the case because any holes which are NOT
-	 * properly contained (i.e. are connected to their
-	 * parent shell) would have formed part of a MaximalEdgeRing
-	 * and been handled in a previous step.
-	 *
-	 * @throws TopologyException if a hole cannot be assigned to a shell
-	 */
-	void placeFreeHoles(std::vector<FastPIPRing>& newShellList,
-		std::vector<geomgraph::EdgeRing*>& freeHoleList);
-		// throw(const TopologyException&)
-
-	/** \brief
-	 * Find the innermost enclosing shell geomgraph::EdgeRing containing the
-	 * argument geomgraph::EdgeRing, if any.
-	 *
-	 * The innermost enclosing ring is the <i>smallest</i> enclosing ring.
-	 * The algorithm used depends on the fact that:
-	 *
-	 * ring A contains ring B iff envelope(ring A)
-	 * contains envelope(ring B)
-	 *
-	 * This routine is only safe to use if the chosen point of the hole
-	 * is known to be properly contained in a shell
-	 * (which is guaranteed to be the case if the hole does not touch
-	 * its shell)
-	 *
-	 * @return containing geomgraph::EdgeRing, if there is one
-	 * @return NULL if no containing geomgraph::EdgeRing is found
-	 */
-	geomgraph::EdgeRing* findEdgeRingContaining(geomgraph::EdgeRing *testEr,
-        std::vector<FastPIPRing>& newShellList);
-
-	std::vector<geom::Geometry*>* computePolygons(
-			std::vector<geomgraph::EdgeRing*>& newShellList);
-
-	/**
-	 * Checks the current set of shells (with their associated holes) to
-	 * see if any of them contain the point.
-	 */
+    const geom::GeometryFactory* geometryFactory;
+
+    std::vector<geomgraph::EdgeRing*> shellList;
+
+    /**
+     * For all DirectedEdges in result, form them into MaximalEdgeRings
+     *
+     * @param maxEdgeRings
+     *   Formed MaximalEdgeRings will be pushed to this vector.
+     *   Ownership of the elements is transferred to caller.
+     */
+    void buildMaximalEdgeRings(
+        const std::vector<geomgraph::DirectedEdge*>* dirEdges,
+        std::vector<MaximalEdgeRing*>& maxEdgeRings);
+    // throw(const TopologyException &)
+
+    void buildMinimalEdgeRings(
+        std::vector<MaximalEdgeRing*>& maxEdgeRings,
+        std::vector<geomgraph::EdgeRing*>& newShellList,
+        std::vector<geomgraph::EdgeRing*>& freeHoleList,
+        std::vector<MaximalEdgeRing*>& edgeRings);
+
+    /**
+     * This method takes a list of MinimalEdgeRings derived from a
+     * MaximalEdgeRing, and tests whether they form a Polygon.
+     * This is the case if there is a single shell
+     * in the list.  In this case the shell is returned.
+     * The other possibility is that they are a series of connected
+     * holes, in which case no shell is returned.
+     *
+     * @return the shell geomgraph::EdgeRing, if there is one
+     * @return NULL, if all the rings are holes
+     */
+    geomgraph::EdgeRing* findShell(std::vector<MinimalEdgeRing*>* minEdgeRings);
+
+    /**
+     * This method assigns the holes for a Polygon (formed from a list of
+     * MinimalEdgeRings) to its shell.
+     * Determining the holes for a MinimalEdgeRing polygon serves two
+     * purposes:
+     *
+     *  - it is faster than using a point-in-polygon check later on.
+     *  - it ensures correctness, since if the PIP test was used the point
+     *    chosen might lie on the shell, which might return an incorrect
+     *    result from the PIP test
+     */
+    void placePolygonHoles(geomgraph::EdgeRing* shell,
+                           std::vector<MinimalEdgeRing*>* minEdgeRings);
+
+    /**
+     * For all rings in the input list,
+     * determine whether the ring is a shell or a hole
+     * and add it to the appropriate list.
+     * Due to the way the DirectedEdges were linked,
+     * a ring is a shell if it is oriented CW, a hole otherwise.
+     */
+    void sortShellsAndHoles(std::vector<MaximalEdgeRing*>& edgeRings,
+                            std::vector<geomgraph::EdgeRing*>& newShellList,
+                            std::vector<geomgraph::EdgeRing*>& freeHoleList);
+
+    struct FastPIPRing {
+        geomgraph::EdgeRing* edgeRing;
+        algorithm::locate::IndexedPointInAreaLocator* pipLocator;
+    };
+
+    /** \brief
+     * This method determines finds a containing shell for all holes
+     * which have not yet been assigned to a shell.
+     *
+     * These "free" holes should all be <b>properly</b> contained in
+     * their parent shells, so it is safe to use the
+     * <code>findEdgeRingContaining</code> method.
+     * This is the case because any holes which are NOT
+     * properly contained (i.e. are connected to their
+     * parent shell) would have formed part of a MaximalEdgeRing
+     * and been handled in a previous step.
+     *
+     * @throws TopologyException if a hole cannot be assigned to a shell
+     */
+    void placeFreeHoles(std::vector<FastPIPRing>& newShellList,
+                        std::vector<geomgraph::EdgeRing*>& freeHoleList);
+    // throw(const TopologyException&)
+
+    /** \brief
+     * Find the innermost enclosing shell geomgraph::EdgeRing containing the
+     * argument geomgraph::EdgeRing, if any.
+     *
+     * The innermost enclosing ring is the <i>smallest</i> enclosing ring.
+     * The algorithm used depends on the fact that:
+     *
+     * ring A contains ring B iff envelope(ring A)
+     * contains envelope(ring B)
+     *
+     * This routine is only safe to use if the chosen point of the hole
+     * is known to be properly contained in a shell
+     * (which is guaranteed to be the case if the hole does not touch
+     * its shell)
+     *
+     * @return containing geomgraph::EdgeRing, if there is one
+     * @return NULL if no containing geomgraph::EdgeRing is found
+     */
+    geomgraph::EdgeRing* findEdgeRingContaining(geomgraph::EdgeRing* testEr,
+            std::vector<FastPIPRing>& newShellList);
+
+    std::vector<geom::Geometry*>* computePolygons(
+        std::vector<geomgraph::EdgeRing*>& newShellList);
+
+    /**
+     * Checks the current set of shells (with their associated holes) to
+     * see if any of them contain the point.
+     */
 
 };
 
diff --git a/include/geos/operation/overlay/snap/GeometrySnapper.h b/include/geos/operation/overlay/snap/GeometrySnapper.h
index 7b65a67..d984fa7 100644
--- a/include/geos/operation/overlay/snap/GeometrySnapper.h
+++ b/include/geos/operation/overlay/snap/GeometrySnapper.h
@@ -27,12 +27,12 @@
 
 // Forward declarations
 namespace geos {
-	namespace geom {
-		//class PrecisionModel;
-		class Geometry;
-		class CoordinateSequence;
-		struct GeomPtrPair;
-	}
+namespace geom {
+//class PrecisionModel;
+class Geometry;
+class CoordinateSequence;
+struct GeomPtrPair;
+}
 }
 
 namespace geos {
@@ -59,89 +59,89 @@ class GEOS_DLL GeometrySnapper {
 
 public:
 
-	typedef std::unique_ptr<geom::Geometry> GeomPtr;
-
-	/**
-	 * Snaps two geometries together with a given tolerance.
-	 *
-	 * @param g0 a geometry to snap
-	 * @param g1 a geometry to snap
-	 * @param snapTolerance the tolerance to use
-	 * @param ret the snapped geometries as a pair of smart pointers
-	 *            (output parameter)
-	 */
-	static void snap(const geom::Geometry& g0,
-	                        const geom::Geometry& g1,
-	                        double snapTolerance, geom::GeomPtrPair& ret);
-
-	static GeomPtr snapToSelf(const geom::Geometry& g0,
-	                        double snapTolerance, bool cleanResult);
-
-	/**
-	 * Creates a new snapper acting on the given geometry
-	 *
-	 * @param g the geometry to snap
-	 */
-	GeometrySnapper(const geom::Geometry& g)
-		:
-		srcGeom(g)
-	{
-	}
-
-	/** \brief
-	 * Snaps the vertices in the component {@link LineString}s
-	 * of the source geometry to the vertices of the given snap geometry
-	 * with a given snap tolerance
-	 *
-	 * @param g a geometry to snap the source to
-	 * @param snapTolerance
-	 * @return a new snapped Geometry
-	 */
-	std::unique_ptr<geom::Geometry> snapTo(const geom::Geometry& g,
-	                                     double snapTolerance);
-
-	/** \brief
-	 * Snaps the vertices in the component {@link LineString}s
-	 * of the source geometry to the vertices of itself
-	 * with a given snap tolerance and optionally cleaning the result.
-	 *
-	 * @param snapTolerance
-	 * @param cleanResult clean the result
-	 * @return a new snapped Geometry
-	 */
-	std::unique_ptr<geom::Geometry> snapToSelf(double snapTolerance,
-	                                         bool cleanResult);
-
-	/** \brief
-	 * Estimates the snap tolerance for a Geometry, taking into account
-	 * its precision model.
-	 *
-	 * @param g a Geometry
-	 * @return the estimated snap tolerance
-	 */
-	static double computeOverlaySnapTolerance(const geom::Geometry& g);
-
-	static double computeSizeBasedSnapTolerance(const geom::Geometry& g);
-
-	/** \brief
-	 * Computes the snap tolerance based on input geometries;
-	 */
-	static double computeOverlaySnapTolerance(const geom::Geometry& g1,
-			const geom::Geometry& g2);
+    typedef std::unique_ptr<geom::Geometry> GeomPtr;
+
+    /**
+     * Snaps two geometries together with a given tolerance.
+     *
+     * @param g0 a geometry to snap
+     * @param g1 a geometry to snap
+     * @param snapTolerance the tolerance to use
+     * @param ret the snapped geometries as a pair of smart pointers
+     *            (output parameter)
+     */
+    static void snap(const geom::Geometry& g0,
+                     const geom::Geometry& g1,
+                     double snapTolerance, geom::GeomPtrPair& ret);
+
+    static GeomPtr snapToSelf(const geom::Geometry& g0,
+                              double snapTolerance, bool cleanResult);
+
+    /**
+     * Creates a new snapper acting on the given geometry
+     *
+     * @param g the geometry to snap
+     */
+    GeometrySnapper(const geom::Geometry& g)
+        :
+        srcGeom(g)
+    {
+    }
+
+    /** \brief
+     * Snaps the vertices in the component {@link LineString}s
+     * of the source geometry to the vertices of the given snap geometry
+     * with a given snap tolerance
+     *
+     * @param g a geometry to snap the source to
+     * @param snapTolerance
+     * @return a new snapped Geometry
+     */
+    std::unique_ptr<geom::Geometry> snapTo(const geom::Geometry& g,
+                                           double snapTolerance);
+
+    /** \brief
+     * Snaps the vertices in the component {@link LineString}s
+     * of the source geometry to the vertices of itself
+     * with a given snap tolerance and optionally cleaning the result.
+     *
+     * @param snapTolerance
+     * @param cleanResult clean the result
+     * @return a new snapped Geometry
+     */
+    std::unique_ptr<geom::Geometry> snapToSelf(double snapTolerance,
+            bool cleanResult);
+
+    /** \brief
+     * Estimates the snap tolerance for a Geometry, taking into account
+     * its precision model.
+     *
+     * @param g a Geometry
+     * @return the estimated snap tolerance
+     */
+    static double computeOverlaySnapTolerance(const geom::Geometry& g);
+
+    static double computeSizeBasedSnapTolerance(const geom::Geometry& g);
+
+    /** \brief
+     * Computes the snap tolerance based on input geometries;
+     */
+    static double computeOverlaySnapTolerance(const geom::Geometry& g1,
+            const geom::Geometry& g2);
 
 
 private:
 
-	// eventually this will be determined from the geometry topology
-	//static const double snapTol; //  = 0.000001;
+    // eventually this will be determined from the geometry topology
+    //static const double snapTol; //  = 0.000001;
 
-	static const double snapPrecisionFactor; //  = 10e-10
+    static const double snapPrecisionFactor; //  = 10e-10
 
-	const geom::Geometry& srcGeom;
+    const geom::Geometry& srcGeom;
 
-	/// Extract target (unique) coordinates
-	std::unique_ptr<geom::Coordinate::ConstVect> extractTargetCoordinates(
-			const geom::Geometry& g);
+    /// Extract target (unique) coordinates
+    std::unique_ptr<geom::Coordinate::ConstVect> extractTargetCoordinates(
+        const geom::Geometry& g);
 
     // Declare type as noncopyable
     GeometrySnapper(const GeometrySnapper& other) = delete;
diff --git a/include/geos/operation/overlay/snap/LineStringSnapper.h b/include/geos/operation/overlay/snap/LineStringSnapper.h
index 16d50d1..58a07b4 100644
--- a/include/geos/operation/overlay/snap/LineStringSnapper.h
+++ b/include/geos/operation/overlay/snap/LineStringSnapper.h
@@ -28,12 +28,12 @@
 
 // Forward declarations
 namespace geos {
-	namespace geom {
-		//class PrecisionModel;
-		//class CoordinateSequence;
-		class CoordinateList;
-		class Geometry;
-	}
+namespace geom {
+//class PrecisionModel;
+//class CoordinateSequence;
+class CoordinateList;
+class Geometry;
+}
 }
 
 namespace geos {
@@ -52,104 +52,106 @@ class GEOS_DLL LineStringSnapper {
 
 public:
 
-	/**
-	 * Creates a new snapper using the given points
-	 * as source points to be snapped.
-	 *
-	 * @param nSrcPts the points to snap
-	 * @param nSnapTolerance the snap tolerance to use
-	 */
-	LineStringSnapper(const geom::Coordinate::Vect& nSrcPts,
-	                                          double nSnapTol)
-		:
-		srcPts(nSrcPts),
-		snapTolerance(nSnapTol),
-		allowSnappingToSourceVertices(false)
-	{
-		size_t s = srcPts.size();
-		isClosed = s < 2 ? false : srcPts[0].equals2D(srcPts[s-1]);
-	}
-
-	// Snap points are assumed to be all distinct points (a set would be better, uh ?)
-	std::unique_ptr<geom::Coordinate::Vect> snapTo(const geom::Coordinate::ConstVect& snapPts);
-
-	void setAllowSnappingToSourceVertices(bool allow) {
-		allowSnappingToSourceVertices = allow;
-	}
+    /**
+     * Creates a new snapper using the given points
+     * as source points to be snapped.
+     *
+     * @param nSrcPts the points to snap
+     * @param nSnapTolerance the snap tolerance to use
+     */
+    LineStringSnapper(const geom::Coordinate::Vect& nSrcPts,
+                      double nSnapTol)
+        :
+        srcPts(nSrcPts),
+        snapTolerance(nSnapTol),
+        allowSnappingToSourceVertices(false)
+    {
+        size_t s = srcPts.size();
+        isClosed = s < 2 ? false : srcPts[0].equals2D(srcPts[s - 1]);
+    }
+
+    // Snap points are assumed to be all distinct points (a set would be better, uh ?)
+    std::unique_ptr<geom::Coordinate::Vect> snapTo(const geom::Coordinate::ConstVect& snapPts);
+
+    void
+    setAllowSnappingToSourceVertices(bool allow)
+    {
+        allowSnappingToSourceVertices = allow;
+    }
 
 private:
 
-	const geom::Coordinate::Vect& srcPts;
-
-	double snapTolerance;
-
-	bool allowSnappingToSourceVertices;
-	bool isClosed;
-
-
-	// Modifies first arg
-	void snapVertices(geom::CoordinateList& srcCoords,
-			const geom::Coordinate::ConstVect& snapPts);
-
-
-	// Returns snapPts.end() if no snap point is close enough (within snapTol distance)
-	geom::Coordinate::ConstVect::const_iterator findSnapForVertex(const geom::Coordinate& pt,
-			const geom::Coordinate::ConstVect& snapPts);
-
-  /** \brief
-   * Snap segments of the source to nearby snap vertices.
-   *
-   * Source segments are "cracked" at a snap vertex.
-   * A single input segment may be snapped several times
-   * to different snap vertices.
-   *
-   * For each distinct snap vertex, at most one source segment
-   * is snapped to.  This prevents "cracking" multiple segments
-   * at the same point, which would likely cause
-   * topology collapse when being used on polygonal linework.
-   *
-   * @param srcCoords the coordinates of the source linestring to be snapped
-   *                  the object will be modified (coords snapped)
-   * @param snapPts the target snap vertices                                       */
-  void snapSegments(geom::CoordinateList& srcCoords,
-                    const geom::Coordinate::ConstVect& snapPts);
-
-	/// \brief
-	/// Finds a src segment which snaps to (is close to) the given snap
-	/// point.
-	//
-	/// Only a single segment is selected for snapping.
-	/// This prevents multiple segments snapping to the same snap vertex,
-	/// which would almost certainly cause invalid geometry
-	/// to be created.
-	/// (The heuristic approach to snapping used here
-	/// is really only appropriate when
-	/// snap pts snap to a unique spot on the src geometry.)
-	///
-	/// Also, if the snap vertex occurs as a vertex in the src
-	/// coordinate list, no snapping is performed (may be changed
-	/// using setAllowSnappingToSourceVertices).
-	///
-	/// @param from
-	///        an iterator to first point of first segment to be checked
-	///
-	/// @param too_far
-	///        an iterator to last point of last segment to be checked
-	///
-	/// @returns an iterator to the snapped segment or
-	///          too_far if no segment needs snapping
-	///          (either none within snapTol distance,
-	///           or one found on the snapPt)
-	///
-	geom::CoordinateList::iterator findSegmentToSnap(
-			const geom::Coordinate& snapPt,
-			geom::CoordinateList::iterator from,
-			geom::CoordinateList::iterator too_far);
-
-	geom::CoordinateList::iterator findVertexToSnap(
-			const geom::Coordinate& snapPt,
-			geom::CoordinateList::iterator from,
-			geom::CoordinateList::iterator too_far);
+    const geom::Coordinate::Vect& srcPts;
+
+    double snapTolerance;
+
+    bool allowSnappingToSourceVertices;
+    bool isClosed;
+
+
+    // Modifies first arg
+    void snapVertices(geom::CoordinateList& srcCoords,
+                      const geom::Coordinate::ConstVect& snapPts);
+
+
+    // Returns snapPts.end() if no snap point is close enough (within snapTol distance)
+    geom::Coordinate::ConstVect::const_iterator findSnapForVertex(const geom::Coordinate& pt,
+            const geom::Coordinate::ConstVect& snapPts);
+
+    /** \brief
+     * Snap segments of the source to nearby snap vertices.
+     *
+     * Source segments are "cracked" at a snap vertex.
+     * A single input segment may be snapped several times
+     * to different snap vertices.
+     *
+     * For each distinct snap vertex, at most one source segment
+     * is snapped to.  This prevents "cracking" multiple segments
+     * at the same point, which would likely cause
+     * topology collapse when being used on polygonal linework.
+     *
+     * @param srcCoords the coordinates of the source linestring to be snapped
+     *                  the object will be modified (coords snapped)
+     * @param snapPts the target snap vertices                                       */
+    void snapSegments(geom::CoordinateList& srcCoords,
+                      const geom::Coordinate::ConstVect& snapPts);
+
+    /// \brief
+    /// Finds a src segment which snaps to (is close to) the given snap
+    /// point.
+    //
+    /// Only a single segment is selected for snapping.
+    /// This prevents multiple segments snapping to the same snap vertex,
+    /// which would almost certainly cause invalid geometry
+    /// to be created.
+    /// (The heuristic approach to snapping used here
+    /// is really only appropriate when
+    /// snap pts snap to a unique spot on the src geometry.)
+    ///
+    /// Also, if the snap vertex occurs as a vertex in the src
+    /// coordinate list, no snapping is performed (may be changed
+    /// using setAllowSnappingToSourceVertices).
+    ///
+    /// @param from
+    ///        an iterator to first point of first segment to be checked
+    ///
+    /// @param too_far
+    ///        an iterator to last point of last segment to be checked
+    ///
+    /// @returns an iterator to the snapped segment or
+    ///          too_far if no segment needs snapping
+    ///          (either none within snapTol distance,
+    ///           or one found on the snapPt)
+    ///
+    geom::CoordinateList::iterator findSegmentToSnap(
+        const geom::Coordinate& snapPt,
+        geom::CoordinateList::iterator from,
+        geom::CoordinateList::iterator too_far);
+
+    geom::CoordinateList::iterator findVertexToSnap(
+        const geom::Coordinate& snapPt,
+        geom::CoordinateList::iterator from,
+        geom::CoordinateList::iterator too_far);
 
     // Declare type as noncopyable
     LineStringSnapper(const LineStringSnapper& other) = delete;
diff --git a/include/geos/operation/overlay/snap/SnapIfNeededOverlayOp.h b/include/geos/operation/overlay/snap/SnapIfNeededOverlayOp.h
index fc3f78c..8bda9bb 100644
--- a/include/geos/operation/overlay/snap/SnapIfNeededOverlayOp.h
+++ b/include/geos/operation/overlay/snap/SnapIfNeededOverlayOp.h
@@ -25,9 +25,9 @@
 
 // Forward declarations
 namespace geos {
-	namespace geom {
-		class Geometry;
-	}
+namespace geom {
+class Geometry;
+}
 }
 
 namespace geos {
@@ -46,59 +46,58 @@ namespace snap { // geos::operation::overlay::snap
  * and invalid overlay computations.
  *
  */
-class SnapIfNeededOverlayOp
-{
+class SnapIfNeededOverlayOp {
 
 public:
 
-	static std::unique_ptr<geom::Geometry>
-	overlayOp(const geom::Geometry& g0, const geom::Geometry& g1,
-	          OverlayOp::OpCode opCode)
-	{
-		SnapIfNeededOverlayOp op(g0, g1);
-		return op.getResultGeometry(opCode);
-	}
-
-	static std::unique_ptr<geom::Geometry>
-	intersection(const geom::Geometry& g0, const geom::Geometry& g1)
-	{
-		return overlayOp(g0, g1, OverlayOp::opINTERSECTION);
-	}
-
-	static std::unique_ptr<geom::Geometry>
-	Union(const geom::Geometry& g0, const geom::Geometry& g1)
-	{
-		return overlayOp(g0, g1, OverlayOp::opUNION);
-	}
-
-	static std::unique_ptr<geom::Geometry>
-	difference(const geom::Geometry& g0, const geom::Geometry& g1)
-	{
-		return overlayOp(g0, g1, OverlayOp::opDIFFERENCE);
-	}
-
-	static std::unique_ptr<geom::Geometry>
-	symDifference(const geom::Geometry& g0, const geom::Geometry& g1)
-	{
-		return overlayOp(g0, g1, OverlayOp::opSYMDIFFERENCE);
-	}
-
-	SnapIfNeededOverlayOp(const geom::Geometry& g1, const geom::Geometry& g2)
-		:
-		geom0(g1),
-		geom1(g2)
-	{
-	}
-
-
-	typedef std::unique_ptr<geom::Geometry> GeomPtr;
-
-	GeomPtr getResultGeometry(OverlayOp::OpCode opCode);
+    static std::unique_ptr<geom::Geometry>
+    overlayOp(const geom::Geometry& g0, const geom::Geometry& g1,
+              OverlayOp::OpCode opCode)
+    {
+        SnapIfNeededOverlayOp op(g0, g1);
+        return op.getResultGeometry(opCode);
+    }
+
+    static std::unique_ptr<geom::Geometry>
+    intersection(const geom::Geometry& g0, const geom::Geometry& g1)
+    {
+        return overlayOp(g0, g1, OverlayOp::opINTERSECTION);
+    }
+
+    static std::unique_ptr<geom::Geometry>
+    Union(const geom::Geometry& g0, const geom::Geometry& g1)
+    {
+        return overlayOp(g0, g1, OverlayOp::opUNION);
+    }
+
+    static std::unique_ptr<geom::Geometry>
+    difference(const geom::Geometry& g0, const geom::Geometry& g1)
+    {
+        return overlayOp(g0, g1, OverlayOp::opDIFFERENCE);
+    }
+
+    static std::unique_ptr<geom::Geometry>
+    symDifference(const geom::Geometry& g0, const geom::Geometry& g1)
+    {
+        return overlayOp(g0, g1, OverlayOp::opSYMDIFFERENCE);
+    }
+
+    SnapIfNeededOverlayOp(const geom::Geometry& g1, const geom::Geometry& g2)
+        :
+        geom0(g1),
+        geom1(g2)
+    {
+    }
+
+
+    typedef std::unique_ptr<geom::Geometry> GeomPtr;
+
+    GeomPtr getResultGeometry(OverlayOp::OpCode opCode);
 
 private:
 
-	const geom::Geometry& geom0;
-	const geom::Geometry& geom1;
+    const geom::Geometry& geom0;
+    const geom::Geometry& geom1;
 
     // Declare type as noncopyable
     SnapIfNeededOverlayOp(const SnapIfNeededOverlayOp& other) = delete;
diff --git a/include/geos/operation/overlay/snap/SnapOverlayOp.h b/include/geos/operation/overlay/snap/SnapOverlayOp.h
index 4e12434..5dda6b6 100644
--- a/include/geos/operation/overlay/snap/SnapOverlayOp.h
+++ b/include/geos/operation/overlay/snap/SnapOverlayOp.h
@@ -31,10 +31,10 @@
 
 // Forward declarations
 namespace geos {
-	namespace geom {
-		class Geometry;
-		struct GeomPtrPair;
-	}
+namespace geom {
+class Geometry;
+struct GeomPtrPair;
+}
 }
 
 namespace geos {
@@ -53,76 +53,75 @@ namespace snap { // geos::operation::overlay::snap
  * if the standard overlay code fails to produce a correct result.
  *
  */
-class GEOS_DLL SnapOverlayOp
-{
+class GEOS_DLL SnapOverlayOp {
 
 public:
 
-	static std::unique_ptr<geom::Geometry>
-	overlayOp(const geom::Geometry& g0, const geom::Geometry& g1,
-	          OverlayOp::OpCode opCode)
-	{
-		SnapOverlayOp op(g0, g1);
-		return op.getResultGeometry(opCode);
-	}
-
-	static std::unique_ptr<geom::Geometry>
-	intersection(const geom::Geometry& g0, const geom::Geometry& g1)
-	{
-		return overlayOp(g0, g1, OverlayOp::opINTERSECTION);
-	}
-
-	static std::unique_ptr<geom::Geometry>
-	Union(const geom::Geometry& g0, const geom::Geometry& g1)
-	{
-		return overlayOp(g0, g1, OverlayOp::opUNION);
-	}
-
-	static std::unique_ptr<geom::Geometry>
-	difference(const geom::Geometry& g0, const geom::Geometry& g1)
-	{
-		return overlayOp(g0, g1, OverlayOp::opDIFFERENCE);
-	}
-
-	static std::unique_ptr<geom::Geometry>
-	symDifference(const geom::Geometry& g0, const geom::Geometry& g1)
-	{
-		return overlayOp(g0, g1, OverlayOp::opSYMDIFFERENCE);
-	}
-
-	SnapOverlayOp(const geom::Geometry& g1, const geom::Geometry& g2)
-		:
-		geom0(g1),
-		geom1(g2)
-	{
-		computeSnapTolerance();
-	}
-
-
-	typedef std::unique_ptr<geom::Geometry> GeomPtr;
-
-	GeomPtr getResultGeometry(OverlayOp::OpCode opCode);
+    static std::unique_ptr<geom::Geometry>
+    overlayOp(const geom::Geometry& g0, const geom::Geometry& g1,
+              OverlayOp::OpCode opCode)
+    {
+        SnapOverlayOp op(g0, g1);
+        return op.getResultGeometry(opCode);
+    }
+
+    static std::unique_ptr<geom::Geometry>
+    intersection(const geom::Geometry& g0, const geom::Geometry& g1)
+    {
+        return overlayOp(g0, g1, OverlayOp::opINTERSECTION);
+    }
+
+    static std::unique_ptr<geom::Geometry>
+    Union(const geom::Geometry& g0, const geom::Geometry& g1)
+    {
+        return overlayOp(g0, g1, OverlayOp::opUNION);
+    }
+
+    static std::unique_ptr<geom::Geometry>
+    difference(const geom::Geometry& g0, const geom::Geometry& g1)
+    {
+        return overlayOp(g0, g1, OverlayOp::opDIFFERENCE);
+    }
+
+    static std::unique_ptr<geom::Geometry>
+    symDifference(const geom::Geometry& g0, const geom::Geometry& g1)
+    {
+        return overlayOp(g0, g1, OverlayOp::opSYMDIFFERENCE);
+    }
+
+    SnapOverlayOp(const geom::Geometry& g1, const geom::Geometry& g2)
+        :
+        geom0(g1),
+        geom1(g2)
+    {
+        computeSnapTolerance();
+    }
+
+
+    typedef std::unique_ptr<geom::Geometry> GeomPtr;
+
+    GeomPtr getResultGeometry(OverlayOp::OpCode opCode);
 
 private:
 
-	void computeSnapTolerance();
+    void computeSnapTolerance();
 
-	void snap(geom::GeomPtrPair& ret);
+    void snap(geom::GeomPtrPair& ret);
 
-	void removeCommonBits(const geom::Geometry& geom0,
-	                      const geom::Geometry& geom1,
-	                      geom::GeomPtrPair& ret);
+    void removeCommonBits(const geom::Geometry& geom0,
+                          const geom::Geometry& geom1,
+                          geom::GeomPtrPair& ret);
 
-	// re-adds common bits to the given geom
-	void prepareResult(geom::Geometry& geom);
+    // re-adds common bits to the given geom
+    void prepareResult(geom::Geometry& geom);
 
 
-	const geom::Geometry& geom0;
-	const geom::Geometry& geom1;
+    const geom::Geometry& geom0;
+    const geom::Geometry& geom1;
 
-	double snapTolerance;
+    double snapTolerance;
 
-	std::unique_ptr<precision::CommonBitsRemover> cbr;
+    std::unique_ptr<precision::CommonBitsRemover> cbr;
 
     // Declare type as noncopyable
     SnapOverlayOp(const SnapOverlayOp& other) = delete;
diff --git a/include/geos/operation/overlay/validate/FuzzyPointLocator.h b/include/geos/operation/overlay/validate/FuzzyPointLocator.h
index 4799bd5..1215054 100644
--- a/include/geos/operation/overlay/validate/FuzzyPointLocator.h
+++ b/include/geos/operation/overlay/validate/FuzzyPointLocator.h
@@ -34,10 +34,10 @@
 
 // Forward declarations
 namespace geos {
-	namespace geom {
-		class Geometry;
-		class Coordinate;
-	}
+namespace geom {
+class Geometry;
+class Coordinate;
+}
 }
 
 namespace geos {
@@ -59,28 +59,28 @@ class GEOS_DLL FuzzyPointLocator {
 
 public:
 
-	FuzzyPointLocator(const geom::Geometry& geom, double nTolerance);
+    FuzzyPointLocator(const geom::Geometry& geom, double nTolerance);
 
-	geom::Location::Value getLocation(const geom::Coordinate& pt);
+    geom::Location::Value getLocation(const geom::Coordinate& pt);
 
 private:
 
-	const geom::Geometry& g;
+    const geom::Geometry& g;
 
-	double tolerance;
+    double tolerance;
 
-	algorithm::PointLocator ptLocator;
+    algorithm::PointLocator ptLocator;
 
-	std::unique_ptr<geom::Geometry> linework;
+    std::unique_ptr<geom::Geometry> linework;
 
-	// this function has been obsoleted
-	std::unique_ptr<geom::Geometry> getLineWork(const geom::Geometry& geom);
+    // this function has been obsoleted
+    std::unique_ptr<geom::Geometry> getLineWork(const geom::Geometry& geom);
 
-	/// Extracts linework for polygonal components.
-	//
-	/// @param g the geometry from which to extract
-	/// @return a lineal geometry containing the extracted linework
-	std::unique_ptr<geom::Geometry> extractLineWork(const geom::Geometry& geom);
+    /// Extracts linework for polygonal components.
+    //
+    /// @param g the geometry from which to extract
+    /// @return a lineal geometry containing the extracted linework
+    std::unique_ptr<geom::Geometry> extractLineWork(const geom::Geometry& geom);
 
     // Declare type as noncopyable
     FuzzyPointLocator(const FuzzyPointLocator& other) = delete;
diff --git a/include/geos/operation/overlay/validate/OffsetPointGenerator.h b/include/geos/operation/overlay/validate/OffsetPointGenerator.h
index e854106..98ad584 100644
--- a/include/geos/operation/overlay/validate/OffsetPointGenerator.h
+++ b/include/geos/operation/overlay/validate/OffsetPointGenerator.h
@@ -35,12 +35,12 @@
 
 // Forward declarations
 namespace geos {
-	namespace geom {
-		//class Geometry;
-		//class MultiPoint;
-		class LineString;
-		//class Coordinate;
-	}
+namespace geom {
+//class Geometry;
+//class MultiPoint;
+class LineString;
+//class Coordinate;
+}
 }
 
 namespace geos {
@@ -54,23 +54,23 @@ class GEOS_DLL OffsetPointGenerator {
 
 public:
 
-	OffsetPointGenerator(const geom::Geometry& geom, double offset);
+    OffsetPointGenerator(const geom::Geometry& geom, double offset);
 
-	/// Gets the computed offset points.
-	std::unique_ptr< std::vector<geom::Coordinate> > getPoints();
+    /// Gets the computed offset points.
+    std::unique_ptr< std::vector<geom::Coordinate> > getPoints();
 
 private:
 
-	const geom::Geometry& g;
+    const geom::Geometry& g;
 
-	double offsetDistance;
+    double offsetDistance;
 
-	std::unique_ptr< std::vector<geom::Coordinate> > offsetPts;
+    std::unique_ptr< std::vector<geom::Coordinate> > offsetPts;
 
-	void extractPoints(const geom::LineString* line);
+    void extractPoints(const geom::LineString* line);
 
-	void computeOffsets(const geom::Coordinate& p0,
-			const geom::Coordinate& p1);
+    void computeOffsets(const geom::Coordinate& p0,
+                        const geom::Coordinate& p1);
 
     // Declare type as noncopyable
     OffsetPointGenerator(const OffsetPointGenerator& other) = delete;
diff --git a/include/geos/operation/overlay/validate/OverlayResultValidator.h b/include/geos/operation/overlay/validate/OverlayResultValidator.h
index a7380b7..a4127b8 100644
--- a/include/geos/operation/overlay/validate/OverlayResultValidator.h
+++ b/include/geos/operation/overlay/validate/OverlayResultValidator.h
@@ -33,10 +33,10 @@
 
 // Forward declarations
 namespace geos {
-	namespace geom {
-		class Geometry;
-		class Coordinate;
-	}
+namespace geom {
+class Geometry;
+class Coordinate;
+}
 }
 
 namespace geos {
@@ -65,56 +65,58 @@ class GEOS_DLL OverlayResultValidator {
 
 public:
 
-	static bool isValid(
-			const geom::Geometry& geom0,
-			const geom::Geometry& geom1,
-			OverlayOp::OpCode opCode,
-			const geom::Geometry& result);
+    static bool isValid(
+        const geom::Geometry& geom0,
+        const geom::Geometry& geom1,
+        OverlayOp::OpCode opCode,
+        const geom::Geometry& result);
 
-	OverlayResultValidator(
-			const geom::Geometry& geom0,
-			const geom::Geometry& geom1,
-			const geom::Geometry& result);
+    OverlayResultValidator(
+        const geom::Geometry& geom0,
+        const geom::Geometry& geom1,
+        const geom::Geometry& result);
 
-	bool isValid(OverlayOp::OpCode opCode);
+    bool isValid(OverlayOp::OpCode opCode);
 
-	geom::Coordinate& getInvalidLocation() {
-		return invalidLocation;
-	}
+    geom::Coordinate&
+    getInvalidLocation()
+    {
+        return invalidLocation;
+    }
 
 private:
 
-	double boundaryDistanceTolerance;
+    double boundaryDistanceTolerance;
 
-	const geom::Geometry& g0;
+    const geom::Geometry& g0;
 
-	const geom::Geometry& g1;
+    const geom::Geometry& g1;
 
-	const geom::Geometry& gres;
+    const geom::Geometry& gres;
 
-	FuzzyPointLocator fpl0;
+    FuzzyPointLocator fpl0;
 
-	FuzzyPointLocator fpl1;
+    FuzzyPointLocator fpl1;
 
-	FuzzyPointLocator fplres;
+    FuzzyPointLocator fplres;
 
-	geom::Coordinate invalidLocation;
+    geom::Coordinate invalidLocation;
 
-	std::vector<geom::Coordinate> testCoords;
+    std::vector<geom::Coordinate> testCoords;
 
-	void addTestPts(const geom::Geometry& g);
+    void addTestPts(const geom::Geometry& g);
 
-	void addVertices(const geom::Geometry& g);
+    void addVertices(const geom::Geometry& g);
 
-	bool testValid(OverlayOp::OpCode overlayOp);
+    bool testValid(OverlayOp::OpCode overlayOp);
 
-	bool testValid(OverlayOp::OpCode overlayOp, const geom::Coordinate& pt);
+    bool testValid(OverlayOp::OpCode overlayOp, const geom::Coordinate& pt);
 
-	bool isValidResult(OverlayOp::OpCode overlayOp,
-			std::vector<geom::Location::Value>& location);
+    bool isValidResult(OverlayOp::OpCode overlayOp,
+                       std::vector<geom::Location::Value>& location);
 
-	static double computeBoundaryDistanceTolerance(
-		const geom::Geometry& g0, const geom::Geometry& g1);
+    static double computeBoundaryDistanceTolerance(
+        const geom::Geometry& g0, const geom::Geometry& g1);
 
     // Declare type as noncopyable
     OverlayResultValidator(const OverlayResultValidator& other) = delete;
diff --git a/include/geos/operation/polygonize/EdgeRing.h b/include/geos/operation/polygonize/EdgeRing.h
index e620411..42cc4e3 100644
--- a/include/geos/operation/polygonize/EdgeRing.h
+++ b/include/geos/operation/polygonize/EdgeRing.h
@@ -32,18 +32,18 @@
 
 // Forward declarations
 namespace geos {
-	namespace geom {
-		class LineString;
-		class LinearRing;
-		class Polygon;
-		class CoordinateSequence;
-		class Geometry;
-		class GeometryFactory;
-		class Coordinate;
-	}
-	namespace planargraph {
-		class DirectedEdge;
-	}
+namespace geom {
+class LineString;
+class LinearRing;
+class Polygon;
+class CoordinateSequence;
+class Geometry;
+class GeometryFactory;
+class Coordinate;
+}
+namespace planargraph {
+class DirectedEdge;
+}
 }
 
 namespace geos {
@@ -56,148 +56,148 @@ namespace polygonize { // geos::operation::polygonize
  */
 class GEOS_DLL EdgeRing {
 private:
-	const geom::GeometryFactory *factory;
+    const geom::GeometryFactory* factory;
 
-	typedef std::vector<const planargraph::DirectedEdge*> DeList;
-	DeList deList;
+    typedef std::vector<const planargraph::DirectedEdge*> DeList;
+    DeList deList;
 
-	// cache the following data for efficiency
-	geom::LinearRing *ring;
-	geom::CoordinateSequence *ringPts;
+    // cache the following data for efficiency
+    geom::LinearRing* ring;
+    geom::CoordinateSequence* ringPts;
 
-	typedef std::vector<geom::Geometry*> GeomVect;
-	GeomVect *holes;
+    typedef std::vector<geom::Geometry*> GeomVect;
+    GeomVect* holes;
 
-	/** \brief
-	 * Computes the list of coordinates which are contained in this ring.
-	 * The coordinatea are computed once only and cached.
-	 *
-	 * @return an array of the Coordinate in this ring
-	 */
-	geom::CoordinateSequence* getCoordinates();
+    /** \brief
+     * Computes the list of coordinates which are contained in this ring.
+     * The coordinatea are computed once only and cached.
+     *
+     * @return an array of the Coordinate in this ring
+     */
+    geom::CoordinateSequence* getCoordinates();
 
-	static void addEdge(const geom::CoordinateSequence *coords,
-			bool isForward,
-			geom::CoordinateSequence *coordList);
+    static void addEdge(const geom::CoordinateSequence* coords,
+                        bool isForward,
+                        geom::CoordinateSequence* coordList);
 
 public:
-	/**
-	 * \brief
-	 * Find the innermost enclosing shell EdgeRing
-	 * containing the argument EdgeRing, if any.
-	 *
-	 * The innermost enclosing ring is the <i>smallest</i> enclosing ring.
-	 * The algorithm used depends on the fact that:
-	 *
-	 * ring A contains ring B iff envelope(ring A) contains envelope(ring B)
-	 *
-	 * This routine is only safe to use if the chosen point of the hole
-	 * is known to be properly contained in a shell
-	 * (which is guaranteed to be the case if the hole does not touch
-	 * its shell)
-	 *
-	 * @return containing EdgeRing, if there is one
-	 * @return null if no containing EdgeRing is found
-	 */
-	static EdgeRing* findEdgeRingContaining(
-			EdgeRing *testEr,
-			std::vector<EdgeRing*> *shellList);
-
-	/**
-	 * \brief
-	 * Finds a point in a list of points which is not contained in
-	 * another list of points.
-	 *
-	 * @param testPts the CoordinateSequence to test
-	 * @param pts the CoordinateSequence to test the input points against
-	 * @return a Coordinate reference from <code>testPts</code> which is
-	 * not in <code>pts</code>, or <code>Coordinate::nullCoord</code>
-	 */
-	static const geom::Coordinate& ptNotInList(
-			const geom::CoordinateSequence *testPts,
-			const geom::CoordinateSequence *pts);
-
-	/** \brief
-	 * Tests whether a given point is in an array of points.
-	 * Uses a value-based test.
-	 *
-	 * @param pt a Coordinate for the test point
-	 * @param pts an array of Coordinate to test
-	 * @return <code>true</code> if the point is in the array
-	 */
-	static bool isInList(const geom::Coordinate &pt,
-			const geom::CoordinateSequence *pts);
-
-	EdgeRing(const geom::GeometryFactory *newFactory);
-
-	~EdgeRing();
-
-	/** \brief
-	 * Adds a DirectedEdge which is known to form part of this ring.
-	 *
-	 * @param de the DirectedEdge to add. Ownership to the caller.
-	 */
-	void add(const planargraph::DirectedEdge *de);
-
-	/** \brief
-	 * Tests whether this ring is a hole.
-	 *
-	 * Due to the way the edges in the polyongization graph are linked,
-	 * a ring is a hole if it is oriented counter-clockwise.
-	 * @return <code>true</code> if this ring is a hole
-	 */
-	bool isHole();
-
-	/** \brief
-	 * Adds a hole to the polygon formed by this ring.
-	 *
-	 * @param hole the LinearRing forming the hole.
-	 */
-	void addHole(geom::LinearRing *hole);
-
-	/** \brief
-	 * Computes the Polygon formed by this ring and any contained holes.
-	 *
-	 * LinearRings ownership is transferred to returned polygon.
-	 * Subsequent calls to the function will return NULL.
-	 *
-	 * @return the Polygon formed by this ring and its holes.
-	 */
-	geom::Polygon* getPolygon();
-
-	/** \brief
-	 * Tests if the LinearRing ring formed by this edge ring
-	 * is topologically valid.
-	 */
-	bool isValid();
-
-	/** \brief
-	 * Gets the coordinates for this ring as a LineString.
-	 *
-	 * Used to return the coordinates in this ring
-	 * as a valid geometry, when it has been detected that the ring
-	 * is topologically invalid.
-	 * @return a LineString containing the coordinates in this ring
-	 */
-	geom::LineString* getLineString();
-
-	/** \brief
-	 * Returns this ring as a LinearRing, or null if an Exception
-	 * occurs while creating it (such as a topology problem).
-	 *
-	 * Ownership of ring is retained by the object.
-	 * Details of problems are written to standard output.
-	 */
-	geom::LinearRing* getRingInternal();
-
-	/** \brief
-	 * Returns this ring as a LinearRing, or null if an Exception
-	 * occurs while creating it (such as a topology problem).
-	 *
-	 * Details of problems are written to standard output.
-	 * Caller gets ownership of ring.
-	 */
-	geom::LinearRing* getRingOwnership();
+    /**
+     * \brief
+     * Find the innermost enclosing shell EdgeRing
+     * containing the argument EdgeRing, if any.
+     *
+     * The innermost enclosing ring is the <i>smallest</i> enclosing ring.
+     * The algorithm used depends on the fact that:
+     *
+     * ring A contains ring B iff envelope(ring A) contains envelope(ring B)
+     *
+     * This routine is only safe to use if the chosen point of the hole
+     * is known to be properly contained in a shell
+     * (which is guaranteed to be the case if the hole does not touch
+     * its shell)
+     *
+     * @return containing EdgeRing, if there is one
+     * @return null if no containing EdgeRing is found
+     */
+    static EdgeRing* findEdgeRingContaining(
+        EdgeRing* testEr,
+        std::vector<EdgeRing*>* shellList);
+
+    /**
+     * \brief
+     * Finds a point in a list of points which is not contained in
+     * another list of points.
+     *
+     * @param testPts the CoordinateSequence to test
+     * @param pts the CoordinateSequence to test the input points against
+     * @return a Coordinate reference from <code>testPts</code> which is
+     * not in <code>pts</code>, or <code>Coordinate::nullCoord</code>
+     */
+    static const geom::Coordinate& ptNotInList(
+        const geom::CoordinateSequence* testPts,
+        const geom::CoordinateSequence* pts);
+
+    /** \brief
+     * Tests whether a given point is in an array of points.
+     * Uses a value-based test.
+     *
+     * @param pt a Coordinate for the test point
+     * @param pts an array of Coordinate to test
+     * @return <code>true</code> if the point is in the array
+     */
+    static bool isInList(const geom::Coordinate& pt,
+                         const geom::CoordinateSequence* pts);
+
+    EdgeRing(const geom::GeometryFactory* newFactory);
+
+    ~EdgeRing();
+
+    /** \brief
+     * Adds a DirectedEdge which is known to form part of this ring.
+     *
+     * @param de the DirectedEdge to add. Ownership to the caller.
+     */
+    void add(const planargraph::DirectedEdge* de);
+
+    /** \brief
+     * Tests whether this ring is a hole.
+     *
+     * Due to the way the edges in the polyongization graph are linked,
+     * a ring is a hole if it is oriented counter-clockwise.
+     * @return <code>true</code> if this ring is a hole
+     */
+    bool isHole();
+
+    /** \brief
+     * Adds a hole to the polygon formed by this ring.
+     *
+     * @param hole the LinearRing forming the hole.
+     */
+    void addHole(geom::LinearRing* hole);
+
+    /** \brief
+     * Computes the Polygon formed by this ring and any contained holes.
+     *
+     * LinearRings ownership is transferred to returned polygon.
+     * Subsequent calls to the function will return NULL.
+     *
+     * @return the Polygon formed by this ring and its holes.
+     */
+    geom::Polygon* getPolygon();
+
+    /** \brief
+     * Tests if the LinearRing ring formed by this edge ring
+     * is topologically valid.
+     */
+    bool isValid();
+
+    /** \brief
+     * Gets the coordinates for this ring as a LineString.
+     *
+     * Used to return the coordinates in this ring
+     * as a valid geometry, when it has been detected that the ring
+     * is topologically invalid.
+     * @return a LineString containing the coordinates in this ring
+     */
+    geom::LineString* getLineString();
+
+    /** \brief
+     * Returns this ring as a LinearRing, or null if an Exception
+     * occurs while creating it (such as a topology problem).
+     *
+     * Ownership of ring is retained by the object.
+     * Details of problems are written to standard output.
+     */
+    geom::LinearRing* getRingInternal();
+
+    /** \brief
+     * Returns this ring as a LinearRing, or null if an Exception
+     * occurs while creating it (such as a topology problem).
+     *
+     * Details of problems are written to standard output.
+     * Caller gets ownership of ring.
+     */
+    geom::LinearRing* getRingOwnership();
 };
 
 } // namespace geos::operation::polygonize
diff --git a/include/geos/operation/polygonize/PolygonizeDirectedEdge.h b/include/geos/operation/polygonize/PolygonizeDirectedEdge.h
index 1f9f72d..82daef9 100644
--- a/include/geos/operation/polygonize/PolygonizeDirectedEdge.h
+++ b/include/geos/operation/polygonize/PolygonizeDirectedEdge.h
@@ -27,17 +27,17 @@
 
 // Forward declarations
 namespace geos {
-	namespace geom {
-		//class LineString;
-	}
-	namespace planargraph {
-		class Node;
-	}
-	namespace operation {
-		namespace polygonize {
-			class EdgeRing;
-		}
-	}
+namespace geom {
+//class LineString;
+}
+namespace planargraph {
+class Node;
+}
+namespace operation {
+namespace polygonize {
+class EdgeRing;
+}
+}
 }
 
 namespace geos {
@@ -55,66 +55,66 @@ class GEOS_DLL PolygonizeDirectedEdge: public planargraph::DirectedEdge {
 
 private:
 
-	EdgeRing *edgeRing;
+    EdgeRing* edgeRing;
 
-	PolygonizeDirectedEdge *next;
+    PolygonizeDirectedEdge* next;
 
-	long label;
+    long label;
 
 public:
 
-	/*
-	 * \brief
-	 * Constructs a directed edge connecting the <code>from</code> node
-	 * to the <code>to</code> node.
-	 *
-	 * @param directionPt
-	 *    specifies this DirectedEdge's direction (given by an imaginary
-	 *    line from the <code>from</code> node to <code>directionPt</code>)
-	 *
-	 * @param edgeDirection
-	 *    whether this DirectedEdge's direction is the same as or
-	 *    opposite to that of the parent Edge (if any)
-	 */
-	PolygonizeDirectedEdge(planargraph::Node *newFrom,
-			planargraph::Node *newTo,
-			const geom::Coordinate& newDirectionPt,
-			bool nEdgeDirection);
-
-	/*
-	 * Returns the identifier attached to this directed edge.
-	 */
-	long getLabel() const;
-
-	/*
-	 * Attaches an identifier to this directed edge.
-	 */
-	void setLabel(long newLabel);
-
-	/*
-	 * Returns the next directed edge in the EdgeRing that this
-	 * directed edge is a member of.
-	 */
-	PolygonizeDirectedEdge* getNext() const;
-
-	/*
-	 * Sets the next directed edge in the EdgeRing that this
-	 * directed edge is a member of.
-	 */
-	void setNext(PolygonizeDirectedEdge *newNext);
-
-	/*
-	 * Returns the ring of directed edges that this directed edge is
-	 * a member of, or null if the ring has not been set.
-	 * @see #setRing(EdgeRing)
-	 */
-	bool isInRing() const;
-
-	/*
-	 * Sets the ring of directed edges that this directed edge is
-	 * a member of.
-	 */
-	void setRing(EdgeRing *newEdgeRing);
+    /*
+     * \brief
+     * Constructs a directed edge connecting the <code>from</code> node
+     * to the <code>to</code> node.
+     *
+     * @param directionPt
+     *    specifies this DirectedEdge's direction (given by an imaginary
+     *    line from the <code>from</code> node to <code>directionPt</code>)
+     *
+     * @param edgeDirection
+     *    whether this DirectedEdge's direction is the same as or
+     *    opposite to that of the parent Edge (if any)
+     */
+    PolygonizeDirectedEdge(planargraph::Node* newFrom,
+                           planargraph::Node* newTo,
+                           const geom::Coordinate& newDirectionPt,
+                           bool nEdgeDirection);
+
+    /*
+     * Returns the identifier attached to this directed edge.
+     */
+    long getLabel() const;
+
+    /*
+     * Attaches an identifier to this directed edge.
+     */
+    void setLabel(long newLabel);
+
+    /*
+     * Returns the next directed edge in the EdgeRing that this
+     * directed edge is a member of.
+     */
+    PolygonizeDirectedEdge* getNext() const;
+
+    /*
+     * Sets the next directed edge in the EdgeRing that this
+     * directed edge is a member of.
+     */
+    void setNext(PolygonizeDirectedEdge* newNext);
+
+    /*
+     * Returns the ring of directed edges that this directed edge is
+     * a member of, or null if the ring has not been set.
+     * @see #setRing(EdgeRing)
+     */
+    bool isInRing() const;
+
+    /*
+     * Sets the ring of directed edges that this directed edge is
+     * a member of.
+     */
+    void setRing(EdgeRing* newEdgeRing);
 };
 } // namespace geos::operation::polygonize
 } // namespace geos::operation
diff --git a/include/geos/operation/polygonize/PolygonizeEdge.h b/include/geos/operation/polygonize/PolygonizeEdge.h
index b308cea..2da144f 100644
--- a/include/geos/operation/polygonize/PolygonizeEdge.h
+++ b/include/geos/operation/polygonize/PolygonizeEdge.h
@@ -27,9 +27,9 @@
 
 // Forward declarations
 namespace geos {
-	namespace geom {
-		class LineString;
-	}
+namespace geom {
+class LineString;
+}
 }
 
 namespace geos {
@@ -43,15 +43,15 @@ namespace polygonize { // geos::operation::polygonize
  */
 class GEOS_DLL PolygonizeEdge: public planargraph::Edge {
 private:
-	// Externally owned
-	const geom::LineString *line;
+    // Externally owned
+    const geom::LineString* line;
 public:
 
-	// Keep the given pointer (won't do anything to it)
-	PolygonizeEdge(const geom::LineString *newLine);
+    // Keep the given pointer (won't do anything to it)
+    PolygonizeEdge(const geom::LineString* newLine);
 
-	// Just return what it was given initially
-	const geom::LineString* getLine();
+    // Just return what it was given initially
+    const geom::LineString* getLine();
 };
 
 } // namespace geos::operation::polygonize
diff --git a/include/geos/operation/polygonize/PolygonizeGraph.h b/include/geos/operation/polygonize/PolygonizeGraph.h
index 21248a1..a8ada5b 100644
--- a/include/geos/operation/polygonize/PolygonizeGraph.h
+++ b/include/geos/operation/polygonize/PolygonizeGraph.h
@@ -33,23 +33,23 @@
 
 // Forward declarations
 namespace geos {
-	namespace geom {
-		class LineString;
-		class GeometryFactory;
-		class Coordinate;
-		class CoordinateSequence;
-	}
-	namespace planargraph {
-		class Node;
-		class Edge;
-		class DirectedEdge;
-	}
-	namespace operation {
-		namespace polygonize {
-			class EdgeRing;
-			class PolygonizeDirectedEdge;
-		}
-	}
+namespace geom {
+class LineString;
+class GeometryFactory;
+class Coordinate;
+class CoordinateSequence;
+}
+namespace planargraph {
+class Node;
+class Edge;
+class DirectedEdge;
+}
+namespace operation {
+namespace polygonize {
+class EdgeRing;
+class PolygonizeDirectedEdge;
+}
+}
 }
 
 namespace geos {
@@ -70,151 +70,151 @@ class GEOS_DLL PolygonizeGraph: public planargraph::PlanarGraph {
 
 public:
 
-	/**
-	 * \brief
-	 * Deletes all edges at a node
-	 */
-	static void deleteAllEdges(planargraph::Node *node);
-
-	/**
-	 * \brief
-	 * Create a new polygonization graph.
-	 */
-	PolygonizeGraph(const geom::GeometryFactory *newFactory);
-
-	/**
-	 * \brief
-	 * Destroy a polygonization graph.
-	 */
-	~PolygonizeGraph() override;
-
-	/**
-	 * \brief
-	 * Add a LineString forming an edge of the polygon graph.
-	 * @param line the line to add
-	 */
-	void addEdge(const geom::LineString *line);
-
-	/**
-	 * \brief
-	 * Computes the EdgeRings formed by the edges in this graph.
-	 *
-	 * @param edgeRingList : the EdgeRing found by the
-	 * 	polygonization process will be pushed here.
-	 *
-	 */
-	void getEdgeRings(std::vector<EdgeRing*>& edgeRingList);
-
-	/**
-	 * \brief
-	 * Finds and removes all cut edges from the graph.
-	 *
-	 * @param cutLines : the list of the LineString forming the removed
-	 *                   cut edges will be pushed here.
-	 *
-	 * TODO: document ownership of the returned LineStrings
-	 */
-	void deleteCutEdges(std::vector<const geom::LineString*> &cutLines);
-
-	/** \brief
-	 * Marks all edges from the graph which are "dangles".
-	 *
-	 * Dangles are which are incident on a node with degree 1.
-	 * This process is recursive, since removing a dangling edge
-	 * may result in another edge becoming a dangle.
-	 * In order to handle large recursion depths efficiently,
-	 * an explicit recursion stack is used
-	 *
-	 * @param dangleLines : the LineStrings that formed dangles will
-	 *                      be push_back'ed here
-	 */
-	void deleteDangles(std::vector<const geom::LineString*> &dangleLines);
+    /**
+     * \brief
+     * Deletes all edges at a node
+     */
+    static void deleteAllEdges(planargraph::Node* node);
+
+    /**
+     * \brief
+     * Create a new polygonization graph.
+     */
+    PolygonizeGraph(const geom::GeometryFactory* newFactory);
+
+    /**
+     * \brief
+     * Destroy a polygonization graph.
+     */
+    ~PolygonizeGraph() override;
+
+    /**
+     * \brief
+     * Add a LineString forming an edge of the polygon graph.
+     * @param line the line to add
+     */
+    void addEdge(const geom::LineString* line);
+
+    /**
+     * \brief
+     * Computes the EdgeRings formed by the edges in this graph.
+     *
+     * @param edgeRingList : the EdgeRing found by the
+     * 	polygonization process will be pushed here.
+     *
+     */
+    void getEdgeRings(std::vector<EdgeRing*>& edgeRingList);
+
+    /**
+     * \brief
+     * Finds and removes all cut edges from the graph.
+     *
+     * @param cutLines : the list of the LineString forming the removed
+     *                   cut edges will be pushed here.
+     *
+     * TODO: document ownership of the returned LineStrings
+     */
+    void deleteCutEdges(std::vector<const geom::LineString*>& cutLines);
+
+    /** \brief
+     * Marks all edges from the graph which are "dangles".
+     *
+     * Dangles are which are incident on a node with degree 1.
+     * This process is recursive, since removing a dangling edge
+     * may result in another edge becoming a dangle.
+     * In order to handle large recursion depths efficiently,
+     * an explicit recursion stack is used
+     *
+     * @param dangleLines : the LineStrings that formed dangles will
+     *                      be push_back'ed here
+     */
+    void deleteDangles(std::vector<const geom::LineString*>& dangleLines);
 
 private:
 
-	static int getDegreeNonDeleted(planargraph::Node *node);
-
-	static int getDegree(planargraph::Node *node, long label);
-
-	const geom::GeometryFactory *factory;
-
-	planargraph::Node* getNode(const geom::Coordinate& pt);
-
-	void computeNextCWEdges();
-
-	/**
-	 * \brief
-	 * Convert the maximal edge rings found by the initial graph traversal
-	 * into the minimal edge rings required by JTS polygon topology rules.
-	 *
-	 * @param ringEdges
-	 * 	the list of start edges for the edgeRings to convert.
-	 *
-	 */
-	void convertMaximalToMinimalEdgeRings(
-			std::vector<PolygonizeDirectedEdge*> &ringEdges);
-
-	/**
-	 * \brief
-	 * Finds all nodes in a maximal edgering
-	 * which are self-intersection nodes
-	 *
-	 * @param startDE
-	 * @param label
-	 * @param intNodes : intersection nodes found will be pushed here
-	 *                   the vector won't be cleared before pushing.
-	 */
-	static void findIntersectionNodes( PolygonizeDirectedEdge *startDE,
-			long label, std::vector<planargraph::Node*>& intNodes
-);
-
-	/**
-	 * Finds and labels all edgerings in the graph.
-	 *
-	 * The edge rings are labelling with unique integers.
-	 * The labelling allows detecting cut edges.
-	 *
-	 * @param dirEdgesIn  a list of the DirectedEdges in the graph
-	 * @param dirEdgesOut each ring found will be pushed here
-	 */
-	static void findLabeledEdgeRings(
-			std::vector<planargraph::DirectedEdge*> &dirEdgesIn,
-			std::vector<PolygonizeDirectedEdge*> &dirEdgesOut);
-
-	static void label(std::vector<planargraph::DirectedEdge*> &dirEdges, long label);
-
-	static void computeNextCWEdges(planargraph::Node *node);
-
-	/**
-	 * \brief
-	 * Computes the next edge pointers going CCW around the given node,
-	 * for the given edgering label.
-	 * This algorithm has the effect of converting maximal edgerings
-	 * into minimal edgerings
-	 */
-	static void computeNextCCWEdges(planargraph::Node *node, long label);
-
-	/**
-	 * \brief
-	 * Traverse a ring of DirectedEdges, accumulating them into a list.
-	 * This assumes that all dangling directed edges have been removed
-	 * from the graph, so that there is always a next dirEdge.
-	 *
-	 * @param startDE the DirectedEdge to start traversing at
-	 * @param edgesInRing : the DirectedEdges that form a ring will
-	 *                      be pushed here.
-	 */
-	static void findDirEdgesInRing(PolygonizeDirectedEdge *startDE,
-		std::vector<planargraph::DirectedEdge*>& edgesInRing);
-
-	EdgeRing* findEdgeRing(PolygonizeDirectedEdge *startDE);
-
-	/* Tese are for memory management */
-	std::vector<planargraph::Edge *> newEdges;
-	std::vector<planargraph::DirectedEdge *> newDirEdges;
-	std::vector<planargraph::Node *> newNodes;
-	std::vector<EdgeRing *> newEdgeRings;
-	std::vector<geom::CoordinateSequence *> newCoords;
+    static int getDegreeNonDeleted(planargraph::Node* node);
+
+    static int getDegree(planargraph::Node* node, long label);
+
+    const geom::GeometryFactory* factory;
+
+    planargraph::Node* getNode(const geom::Coordinate& pt);
+
+    void computeNextCWEdges();
+
+    /**
+     * \brief
+     * Convert the maximal edge rings found by the initial graph traversal
+     * into the minimal edge rings required by JTS polygon topology rules.
+     *
+     * @param ringEdges
+     * 	the list of start edges for the edgeRings to convert.
+     *
+     */
+    void convertMaximalToMinimalEdgeRings(
+        std::vector<PolygonizeDirectedEdge*>& ringEdges);
+
+    /**
+     * \brief
+     * Finds all nodes in a maximal edgering
+     * which are self-intersection nodes
+     *
+     * @param startDE
+     * @param label
+     * @param intNodes : intersection nodes found will be pushed here
+     *                   the vector won't be cleared before pushing.
+     */
+    static void findIntersectionNodes(PolygonizeDirectedEdge* startDE,
+                                      long label, std::vector<planargraph::Node*>& intNodes
+                                     );
+
+    /**
+     * Finds and labels all edgerings in the graph.
+     *
+     * The edge rings are labelling with unique integers.
+     * The labelling allows detecting cut edges.
+     *
+     * @param dirEdgesIn  a list of the DirectedEdges in the graph
+     * @param dirEdgesOut each ring found will be pushed here
+     */
+    static void findLabeledEdgeRings(
+        std::vector<planargraph::DirectedEdge*>& dirEdgesIn,
+        std::vector<PolygonizeDirectedEdge*>& dirEdgesOut);
+
+    static void label(std::vector<planargraph::DirectedEdge*>& dirEdges, long label);
+
+    static void computeNextCWEdges(planargraph::Node* node);
+
+    /**
+     * \brief
+     * Computes the next edge pointers going CCW around the given node,
+     * for the given edgering label.
+     * This algorithm has the effect of converting maximal edgerings
+     * into minimal edgerings
+     */
+    static void computeNextCCWEdges(planargraph::Node* node, long label);
+
+    /**
+     * \brief
+     * Traverse a ring of DirectedEdges, accumulating them into a list.
+     * This assumes that all dangling directed edges have been removed
+     * from the graph, so that there is always a next dirEdge.
+     *
+     * @param startDE the DirectedEdge to start traversing at
+     * @param edgesInRing : the DirectedEdges that form a ring will
+     *                      be pushed here.
+     */
+    static void findDirEdgesInRing(PolygonizeDirectedEdge* startDE,
+                                   std::vector<planargraph::DirectedEdge*>& edgesInRing);
+
+    EdgeRing* findEdgeRing(PolygonizeDirectedEdge* startDE);
+
+    /* Tese are for memory management */
+    std::vector<planargraph::Edge*> newEdges;
+    std::vector<planargraph::DirectedEdge*> newDirEdges;
+    std::vector<planargraph::Node*> newNodes;
+    std::vector<EdgeRing*> newEdgeRings;
+    std::vector<geom::CoordinateSequence*> newCoords;
 };
 
 } // namespace geos::operation::polygonize
diff --git a/include/geos/operation/polygonize/Polygonizer.h b/include/geos/operation/polygonize/Polygonizer.h
index 6064db1..b38bdd2 100644
--- a/include/geos/operation/polygonize/Polygonizer.h
+++ b/include/geos/operation/polygonize/Polygonizer.h
@@ -33,17 +33,17 @@
 
 // Forward declarations
 namespace geos {
-	namespace geom {
-		class Geometry;
-		class LineString;
-		class Polygon;
-	}
-	namespace operation {
-		namespace polygonize {
-			class EdgeRing;
-			class PolygonizeGraph;
-		}
-	}
+namespace geom {
+class Geometry;
+class LineString;
+class Polygon;
+}
+namespace operation {
+namespace polygonize {
+class EdgeRing;
+class PolygonizeGraph;
+}
+}
 }
 
 namespace geos {
@@ -72,147 +72,147 @@ namespace polygonize { // geos::operation::polygonize
  */
 class GEOS_DLL Polygonizer {
 private:
-	/**
-	 * Add every linear element in a geometry into the polygonizer graph.
-	 */
-	class GEOS_DLL LineStringAdder: public geom::GeometryComponentFilter {
-	public:
-		Polygonizer *pol;
-		LineStringAdder(Polygonizer *p);
-		//void filter_rw(geom::Geometry *g);
-		void filter_ro(const geom::Geometry * g) override;
-	};
-
-	// default factory
-	LineStringAdder lineStringAdder;
-
-	/**
-	 * Add a linestring to the graph of polygon edges.
-	 *
-	 * @param line the {@link LineString} to add
-	 */
-	void add(const geom::LineString *line);
-
-	/**
-	 * Perform the polygonization, if it has not already been carried out.
-	 */
-	void polygonize();
-
-	void findValidRings(const std::vector<EdgeRing*>& edgeRingList,
-			std::vector<EdgeRing*>& validEdgeRingList,
-			std::vector<geom::LineString*>& invalidRingList);
-
-	void findShellsAndHoles(const std::vector<EdgeRing*>& edgeRingList);
-
-	static void assignHolesToShells(const std::vector<EdgeRing*>& holeList,
-			std::vector<EdgeRing*>& shellList);
-
-	static void assignHoleToShell(EdgeRing *holeER,
-			std::vector<EdgeRing*>& shellList);
+    /**
+     * Add every linear element in a geometry into the polygonizer graph.
+     */
+    class GEOS_DLL LineStringAdder: public geom::GeometryComponentFilter {
+    public:
+        Polygonizer* pol;
+        LineStringAdder(Polygonizer* p);
+        //void filter_rw(geom::Geometry *g);
+        void filter_ro(const geom::Geometry* g) override;
+    };
+
+    // default factory
+    LineStringAdder lineStringAdder;
+
+    /**
+     * Add a linestring to the graph of polygon edges.
+     *
+     * @param line the {@link LineString} to add
+     */
+    void add(const geom::LineString* line);
+
+    /**
+     * Perform the polygonization, if it has not already been carried out.
+     */
+    void polygonize();
+
+    void findValidRings(const std::vector<EdgeRing*>& edgeRingList,
+                        std::vector<EdgeRing*>& validEdgeRingList,
+                        std::vector<geom::LineString*>& invalidRingList);
+
+    void findShellsAndHoles(const std::vector<EdgeRing*>& edgeRingList);
+
+    static void assignHolesToShells(const std::vector<EdgeRing*>& holeList,
+                                    std::vector<EdgeRing*>& shellList);
+
+    static void assignHoleToShell(EdgeRing* holeER,
+                                  std::vector<EdgeRing*>& shellList);
 
 protected:
 
-	PolygonizeGraph *graph;
+    PolygonizeGraph* graph;
 
-	// initialize with empty collections, in case nothing is computed
-	std::vector<const geom::LineString*> dangles;
-	std::vector<const geom::LineString*> cutEdges;
-	std::vector<geom::LineString*> invalidRingLines;
+    // initialize with empty collections, in case nothing is computed
+    std::vector<const geom::LineString*> dangles;
+    std::vector<const geom::LineString*> cutEdges;
+    std::vector<geom::LineString*> invalidRingLines;
 
-	std::vector<EdgeRing*> holeList;
-	std::vector<EdgeRing*> shellList;
-	std::vector<geom::Polygon*> *polyList;
+    std::vector<EdgeRing*> holeList;
+    std::vector<EdgeRing*> shellList;
+    std::vector<geom::Polygon*>* polyList;
 
 public:
 
-	/** \brief
-	 * Create a polygonizer with the same GeometryFactory
-	 * as the input Geometry
-	 */
-	Polygonizer();
-
-	~Polygonizer();
-
-	/** \brief
-	 * Add a collection of geometries to be polygonized.
-	 * May be called multiple times.
-	 * Any dimension of Geometry may be added;
-	 * the constituent linework will be extracted and used
-	 *
-	 * @param geomList a list of Geometry with linework to be polygonized
-	 */
-	void add(std::vector<geom::Geometry*> *geomList);
-
-        /** \brief
-         * Add a collection of geometries to be polygonized.
-         * May be called multiple times.
-         * Any dimension of Geometry may be added;
-         * the constituent linework will be extracted and used
-         *
-         * @param geomList a list of Geometry with linework to be polygonized
-         */
-	void add(std::vector<const geom::Geometry*> *geomList);
-
-	/**
-	 * Add a geometry to the linework to be polygonized.
-	 * May be called multiple times.
-	 * Any dimension of Geometry may be added;
-	 * the constituent linework will be extracted and used
-	 *
-	 * @param g a Geometry with linework to be polygonized
-	 */
-	void add(geom::Geometry *g);
-
-        /**
-         * Add a geometry to the linework to be polygonized.
-         * May be called multiple times.
-         * Any dimension of Geometry may be added;
-         * the constituent linework will be extracted and used
-         *
-         * @param g a Geometry with linework to be polygonized
-         */
-	void add(const geom::Geometry *g);
-
-	/** \brief
-	 * Gets the list of polygons formed by the polygonization.
-	 *
-	 * Ownership of vector is transferred to caller, subsequent
-	 * calls will return NULL.
-	 * @return a collection of Polygons
-	 */
-	std::vector<geom::Polygon*>* getPolygons();
-
-	/** \brief
-	 * Get the list of dangling lines found during polygonization.
-	 *
-	 * @return a (possibly empty) collection of pointers to
-	 *         the input LineStrings which are dangles.
-	 *
-	 */
-	const std::vector<const geom::LineString*>& getDangles();
-
-
-	/** \brief
-	 * Get the list of cut edges found during polygonization.
-	 *
-	 * @return a (possibly empty) collection of pointers to
-	 *         the input LineStrings which are cut edges.
-	 *
-	 */
-	const std::vector<const geom::LineString*>& getCutEdges();
-
-	/** \brief
-	 * Get the list of lines forming invalid rings found during
-	 * polygonization.
-	 *
-	 * @return a (possibly empty) collection of pointers to
-	 *         the input LineStrings which form invalid rings
-	 *
-	 */
-	const std::vector<geom::LineString*>& getInvalidRingLines();
+    /** \brief
+     * Create a polygonizer with the same GeometryFactory
+     * as the input Geometry
+     */
+    Polygonizer();
+
+    ~Polygonizer();
+
+    /** \brief
+     * Add a collection of geometries to be polygonized.
+     * May be called multiple times.
+     * Any dimension of Geometry may be added;
+     * the constituent linework will be extracted and used
+     *
+     * @param geomList a list of Geometry with linework to be polygonized
+     */
+    void add(std::vector<geom::Geometry*>* geomList);
+
+    /** \brief
+     * Add a collection of geometries to be polygonized.
+     * May be called multiple times.
+     * Any dimension of Geometry may be added;
+     * the constituent linework will be extracted and used
+     *
+     * @param geomList a list of Geometry with linework to be polygonized
+     */
+    void add(std::vector<const geom::Geometry*>* geomList);
+
+    /**
+     * Add a geometry to the linework to be polygonized.
+     * May be called multiple times.
+     * Any dimension of Geometry may be added;
+     * the constituent linework will be extracted and used
+     *
+     * @param g a Geometry with linework to be polygonized
+     */
+    void add(geom::Geometry* g);
+
+    /**
+     * Add a geometry to the linework to be polygonized.
+     * May be called multiple times.
+     * Any dimension of Geometry may be added;
+     * the constituent linework will be extracted and used
+     *
+     * @param g a Geometry with linework to be polygonized
+     */
+    void add(const geom::Geometry* g);
+
+    /** \brief
+     * Gets the list of polygons formed by the polygonization.
+     *
+     * Ownership of vector is transferred to caller, subsequent
+     * calls will return NULL.
+     * @return a collection of Polygons
+     */
+    std::vector<geom::Polygon*>* getPolygons();
+
+    /** \brief
+     * Get the list of dangling lines found during polygonization.
+     *
+     * @return a (possibly empty) collection of pointers to
+     *         the input LineStrings which are dangles.
+     *
+     */
+    const std::vector<const geom::LineString*>& getDangles();
+
+
+    /** \brief
+     * Get the list of cut edges found during polygonization.
+     *
+     * @return a (possibly empty) collection of pointers to
+     *         the input LineStrings which are cut edges.
+     *
+     */
+    const std::vector<const geom::LineString*>& getCutEdges();
+
+    /** \brief
+     * Get the list of lines forming invalid rings found during
+     * polygonization.
+     *
+     * @return a (possibly empty) collection of pointers to
+     *         the input LineStrings which form invalid rings
+     *
+     */
+    const std::vector<geom::LineString*>& getInvalidRingLines();
 
 // This seems to be needed by    GCC 2.95.4
-friend class Polygonizer::LineStringAdder;
+    friend class Polygonizer::LineStringAdder;
 };
 
 } // namespace geos::operation::polygonize
diff --git a/include/geos/operation/predicate/RectangleContains.h b/include/geos/operation/predicate/RectangleContains.h
index 0cd78d7..60f39fd 100644
--- a/include/geos/operation/predicate/RectangleContains.h
+++ b/include/geos/operation/predicate/RectangleContains.h
@@ -25,14 +25,14 @@
 
 // Forward declarations
 namespace geos {
-	namespace geom {
-		class Envelope;
-		class Geometry;
-		class Point;
-		class Coordinate;
-		class LineString;
-		//class Polygon;
-	}
+namespace geom {
+class Envelope;
+class Geometry;
+class Point;
+class Coordinate;
+class LineString;
+//class Polygon;
+}
 }
 
 namespace geos {
@@ -52,62 +52,63 @@ class GEOS_DLL RectangleContains {
 
 private:
 
-	const geom::Polygon& rectangle;
-	const geom::Envelope& rectEnv;
-
-	bool isContainedInBoundary(const geom::Geometry& geom);
-
-	bool isPointContainedInBoundary(const geom::Point& geom);
-
-	/** \brief
-	 * Tests if a point is contained in the boundary of the target
-	 * rectangle.
-	 *
-	 * @param pt the point to test
-	 * @return true if the point is contained in the boundary
-	 */
-	bool isPointContainedInBoundary(const geom::Coordinate &pt);
-
-	/** \brief
-	 * Tests if a linestring is completely contained in the boundary
-	 * of the target rectangle.
-	 *
-	 * @param line the linestring to test
-	 * @return true if the linestring is contained in the boundary
-	 */
-	bool isLineStringContainedInBoundary(const geom::LineString &line);
-
-	/** \brief
-	 * Tests if a line segment is contained in the boundary of the
-	 * target rectangle.
-	 *
-	 * @param p0 an endpoint of the segment
-	 * @param p1 an endpoint of the segment
-	 * @return true if the line segment is contained in the boundary
-	 */
-	bool isLineSegmentContainedInBoundary(const geom::Coordinate& p0,
-			const geom::Coordinate& p1);
+    const geom::Polygon& rectangle;
+    const geom::Envelope& rectEnv;
+
+    bool isContainedInBoundary(const geom::Geometry& geom);
+
+    bool isPointContainedInBoundary(const geom::Point& geom);
+
+    /** \brief
+     * Tests if a point is contained in the boundary of the target
+     * rectangle.
+     *
+     * @param pt the point to test
+     * @return true if the point is contained in the boundary
+     */
+    bool isPointContainedInBoundary(const geom::Coordinate& pt);
+
+    /** \brief
+     * Tests if a linestring is completely contained in the boundary
+     * of the target rectangle.
+     *
+     * @param line the linestring to test
+     * @return true if the linestring is contained in the boundary
+     */
+    bool isLineStringContainedInBoundary(const geom::LineString& line);
+
+    /** \brief
+     * Tests if a line segment is contained in the boundary of the
+     * target rectangle.
+     *
+     * @param p0 an endpoint of the segment
+     * @param p1 an endpoint of the segment
+     * @return true if the line segment is contained in the boundary
+     */
+    bool isLineSegmentContainedInBoundary(const geom::Coordinate& p0,
+                                          const geom::Coordinate& p1);
 
 public:
 
-	static bool contains(const geom::Polygon& rect, const geom::Geometry& b)
-	{
-		RectangleContains rc(rect);
-		return rc.contains(b);
-	}
-
-	/**
-	 * Create a new contains computer for two geometries.
-	 *
-	 * @param rect a rectangular geometry
-	 */
-	RectangleContains(const geom::Polygon& rect)
-		:
-		rectangle(rect),
-		rectEnv(*(rect.getEnvelopeInternal()))
-		{}
-
-	bool contains(const geom::Geometry& geom);
+    static bool
+    contains(const geom::Polygon& rect, const geom::Geometry& b)
+    {
+        RectangleContains rc(rect);
+        return rc.contains(b);
+    }
+
+    /**
+     * Create a new contains computer for two geometries.
+     *
+     * @param rect a rectangular geometry
+     */
+    RectangleContains(const geom::Polygon& rect)
+        :
+        rectangle(rect),
+        rectEnv(*(rect.getEnvelopeInternal()))
+    {}
+
+    bool contains(const geom::Geometry& geom);
 
     // Declare type as noncopyable
     RectangleContains(const RectangleContains& other) = delete;
diff --git a/include/geos/operation/predicate/RectangleIntersects.h b/include/geos/operation/predicate/RectangleIntersects.h
index 772b6d7..c8831ff 100644
--- a/include/geos/operation/predicate/RectangleIntersects.h
+++ b/include/geos/operation/predicate/RectangleIntersects.h
@@ -26,10 +26,10 @@
 
 // Forward declarations
 namespace geos {
-	namespace geom {
-		class Envelope;
-		//class Polygon;
-	}
+namespace geom {
+class Envelope;
+//class Polygon;
+}
 }
 
 namespace geos {
@@ -53,9 +53,9 @@ class GEOS_DLL RectangleIntersects {
 
 private:
 
-	const geom::Polygon &rectangle;
+    const geom::Polygon& rectangle;
 
- 	const geom::Envelope &rectEnv;
+    const geom::Envelope& rectEnv;
 
     // Declare type as noncopyable
     RectangleIntersects(const RectangleIntersects& other) = delete;
@@ -63,32 +63,33 @@ private:
 
 public:
 
-	/** \brief
-	 * Create a new intersects computer for a rectangle.
-	 *
-	 * @param newRect a rectangular geometry
-	 */
-	RectangleIntersects(const geom::Polygon &newRect)
-		:
-		rectangle(newRect),
-		rectEnv(*(newRect.getEnvelopeInternal()))
-	{}
-
-	bool intersects(const geom::Geometry& geom);
-
-	/** \brief
-	 * Tests whether a rectangle intersects a given geometry.
-	 *
-	 * @param rectangle a rectangular Polygon
-	 * @param b a Geometry of any type
-	 * @return true if the geometries intersect
-	 */
-	static bool intersects(const geom::Polygon &rectangle,
-			const geom::Geometry &b)
-	{
-		RectangleIntersects rp(rectangle);
-		return rp.intersects(b);
-	}
+    /** \brief
+     * Create a new intersects computer for a rectangle.
+     *
+     * @param newRect a rectangular geometry
+     */
+    RectangleIntersects(const geom::Polygon& newRect)
+        :
+        rectangle(newRect),
+        rectEnv(*(newRect.getEnvelopeInternal()))
+    {}
+
+    bool intersects(const geom::Geometry& geom);
+
+    /** \brief
+     * Tests whether a rectangle intersects a given geometry.
+     *
+     * @param rectangle a rectangular Polygon
+     * @param b a Geometry of any type
+     * @return true if the geometries intersect
+     */
+    static bool
+    intersects(const geom::Polygon& rectangle,
+               const geom::Geometry& b)
+    {
+        RectangleIntersects rp(rectangle);
+        return rp.intersects(b);
+    }
 
 };
 
diff --git a/include/geos/operation/predicate/SegmentIntersectionTester.h b/include/geos/operation/predicate/SegmentIntersectionTester.h
index 30b707c..3a4d49c 100644
--- a/include/geos/operation/predicate/SegmentIntersectionTester.h
+++ b/include/geos/operation/predicate/SegmentIntersectionTester.h
@@ -27,10 +27,10 @@
 
 // Forward declarations
 namespace geos {
-	namespace geom {
-		class LineString;
-		class CoordinateSequence;
-	}
+namespace geom {
+class LineString;
+class CoordinateSequence;
+}
 }
 
 namespace geos {
@@ -49,46 +49,46 @@ class GEOS_DLL SegmentIntersectionTester {
 
 private:
 
-	/// \brief
-	/// For purposes of intersection testing,
-	/// don't need to set precision model
-	///
-	algorithm::LineIntersector li; // Robust
+    /// \brief
+    /// For purposes of intersection testing,
+    /// don't need to set precision model
+    ///
+    algorithm::LineIntersector li; // Robust
 
-	bool hasIntersectionVar;
+    bool hasIntersectionVar;
 
-  geom::Coordinate pt10;
-  geom::Coordinate pt11;
-  geom::Coordinate pt00;
-  geom::Coordinate pt01;
+    geom::Coordinate pt10;
+    geom::Coordinate pt11;
+    geom::Coordinate pt00;
+    geom::Coordinate pt01;
 
 
 public:
 
-	SegmentIntersectionTester(): hasIntersectionVar(false) {}
-
-	bool hasIntersectionWithLineStrings(const geom::LineString &line,
-		const std::vector<const geom::LineString *>& lines);
-
-	bool hasIntersection(const geom::LineString &line,
-		const geom::LineString &testLine);
-
-	/**
-	 * Tests the segments of a LineString against the segs in
-	 * another LineString for intersection.
-	 * Uses the envelope of the query LineString
-	 * to filter before testing segments directly.
-	 * This is optimized for the case when the query
-	 * LineString is a rectangle.
-	 *
-	 * Testing shows this is somewhat faster than not checking the envelope.
-	 *
-	 * @param line
-	 * @param testLine
-	 * @return
-	 */
-	bool hasIntersectionWithEnvelopeFilter(const geom::LineString &line,
-		const geom::LineString &testLine);
+    SegmentIntersectionTester(): hasIntersectionVar(false) {}
+
+    bool hasIntersectionWithLineStrings(const geom::LineString& line,
+                                        const std::vector<const geom::LineString*>& lines);
+
+    bool hasIntersection(const geom::LineString& line,
+                         const geom::LineString& testLine);
+
+    /**
+     * Tests the segments of a LineString against the segs in
+     * another LineString for intersection.
+     * Uses the envelope of the query LineString
+     * to filter before testing segments directly.
+     * This is optimized for the case when the query
+     * LineString is a rectangle.
+     *
+     * Testing shows this is somewhat faster than not checking the envelope.
+     *
+     * @param line
+     * @param testLine
+     * @return
+     */
+    bool hasIntersectionWithEnvelopeFilter(const geom::LineString& line,
+                                           const geom::LineString& testLine);
 
 
 };
diff --git a/include/geos/operation/relate/EdgeEndBuilder.h b/include/geos/operation/relate/EdgeEndBuilder.h
index fcb165c..eacb6a0 100644
--- a/include/geos/operation/relate/EdgeEndBuilder.h
+++ b/include/geos/operation/relate/EdgeEndBuilder.h
@@ -25,15 +25,15 @@
 
 // Forward declarations
 namespace geos {
-	namespace geom {
-		class IntersectionMatrix;
-		class Coordinate;
-	}
-	namespace geomgraph {
-		class Edge;
-		class EdgeIntersection;
-		class EdgeEnd;
-	}
+namespace geom {
+class IntersectionMatrix;
+class Coordinate;
+}
+namespace geomgraph {
+class Edge;
+class EdgeIntersection;
+class EdgeEnd;
+}
 }
 
 
@@ -47,22 +47,22 @@ namespace relate { // geos::operation::relate
  */
 class GEOS_DLL EdgeEndBuilder {
 public:
-	EdgeEndBuilder() {}
+    EdgeEndBuilder() {}
 
-	std::vector<geomgraph::EdgeEnd*> *computeEdgeEnds(std::vector<geomgraph::Edge*> *edges);
-	void computeEdgeEnds(geomgraph::Edge *edge,std::vector<geomgraph::EdgeEnd*> *l);
+    std::vector<geomgraph::EdgeEnd*>* computeEdgeEnds(std::vector<geomgraph::Edge*>* edges);
+    void computeEdgeEnds(geomgraph::Edge* edge, std::vector<geomgraph::EdgeEnd*>* l);
 
 protected:
 
-	void createEdgeEndForPrev(geomgraph::Edge *edge,
-			std::vector<geomgraph::EdgeEnd*> *l,
-			geomgraph::EdgeIntersection *eiCurr,
-			geomgraph::EdgeIntersection *eiPrev);
+    void createEdgeEndForPrev(geomgraph::Edge* edge,
+                              std::vector<geomgraph::EdgeEnd*>* l,
+                              geomgraph::EdgeIntersection* eiCurr,
+                              geomgraph::EdgeIntersection* eiPrev);
 
-	void createEdgeEndForNext(geomgraph::Edge *edge,
-			std::vector<geomgraph::EdgeEnd*> *l,
-			geomgraph::EdgeIntersection *eiCurr,
-			geomgraph::EdgeIntersection *eiNext);
+    void createEdgeEndForNext(geomgraph::Edge* edge,
+                              std::vector<geomgraph::EdgeEnd*>* l,
+                              geomgraph::EdgeIntersection* eiCurr,
+                              geomgraph::EdgeIntersection* eiNext);
 };
 
 } // namespace geos:operation:relate
diff --git a/include/geos/operation/relate/EdgeEndBundle.h b/include/geos/operation/relate/EdgeEndBundle.h
index 490cff3..95dc021 100644
--- a/include/geos/operation/relate/EdgeEndBundle.h
+++ b/include/geos/operation/relate/EdgeEndBundle.h
@@ -27,12 +27,12 @@
 
 // Forward declarations
 namespace geos {
-	namespace algorithm {
-		class BoundaryNodeRule;
-	}
-	namespace geom {
-		class IntersectionMatrix;
-	}
+namespace algorithm {
+class BoundaryNodeRule;
+}
+namespace geom {
+class IntersectionMatrix;
+}
 }
 
 
@@ -44,61 +44,60 @@ namespace relate { // geos::operation::relate
  * A collection of geomgraph::EdgeEnd objects which
  * originate at the same point and have the same direction.
  */
-class GEOS_DLL EdgeEndBundle: public geomgraph::EdgeEnd
-{
+class GEOS_DLL EdgeEndBundle: public geomgraph::EdgeEnd {
 public:
-	EdgeEndBundle(geomgraph::EdgeEnd *e);
-	~EdgeEndBundle() override;
-	std::vector<geomgraph::EdgeEnd*>* getEdgeEnds();
-	void insert(geomgraph::EdgeEnd *e);
+    EdgeEndBundle(geomgraph::EdgeEnd* e);
+    ~EdgeEndBundle() override;
+    std::vector<geomgraph::EdgeEnd*>* getEdgeEnds();
+    void insert(geomgraph::EdgeEnd* e);
 
-	void computeLabel(const algorithm::BoundaryNodeRule& bnr) override;
+    void computeLabel(const algorithm::BoundaryNodeRule& bnr) override;
 
-  /**
-   * \brief
-   * Update the IM with the contribution for the computed label for
-   * the EdgeStubs.
-   */
-	void updateIM(geom::IntersectionMatrix& im);
+    /**
+     * \brief
+     * Update the IM with the contribution for the computed label for
+     * the EdgeStubs.
+     */
+    void updateIM(geom::IntersectionMatrix& im);
 
-	std::string print() const override;
+    std::string print() const override;
 protected:
-	std::vector<geomgraph::EdgeEnd*> *edgeEnds;
+    std::vector<geomgraph::EdgeEnd*>* edgeEnds;
 
-	/**
-	 * Compute the overall ON location for the list of EdgeStubs.
-	 *
-	 * (This is essentially equivalent to computing the self-overlay of
-	 * a single Geometry)
-	 *
-	 * edgeStubs can be either on the boundary (eg Polygon edge)
-	 * OR in the interior (e.g. segment of a LineString)
-	 * of their parent Geometry.
-	 *
-	 * In addition, GeometryCollections use a algorithm::BoundaryNodeRule
-	 * to determine whether a segment is on the boundary or not.
-	 *
-	 * Finally, in GeometryCollections it can occur that an edge
-	 * is both
-	 * on the boundary and in the interior (e.g. a LineString segment
-	 * lying on
-	 * top of a Polygon edge.) In this case the Boundary is
-	 * given precendence.
-	 *
-	 * These observations result in the following rules for computing
-	 * the ON location:
-	 *  - if there are an odd number of Bdy edges, the attribute is Bdy
-	 *  - if there are an even number >= 2 of Bdy edges, the attribute
-	 *    is Int
-	 *  - if there are any Int edges, the attribute is Int
-	 *  - otherwise, the attribute is NULL.
-	 *
-	 */
-	void computeLabelOn(int geomIndex,
-		const algorithm::BoundaryNodeRule& boundaryNodeRule);
+    /**
+     * Compute the overall ON location for the list of EdgeStubs.
+     *
+     * (This is essentially equivalent to computing the self-overlay of
+     * a single Geometry)
+     *
+     * edgeStubs can be either on the boundary (eg Polygon edge)
+     * OR in the interior (e.g. segment of a LineString)
+     * of their parent Geometry.
+     *
+     * In addition, GeometryCollections use a algorithm::BoundaryNodeRule
+     * to determine whether a segment is on the boundary or not.
+     *
+     * Finally, in GeometryCollections it can occur that an edge
+     * is both
+     * on the boundary and in the interior (e.g. a LineString segment
+     * lying on
+     * top of a Polygon edge.) In this case the Boundary is
+     * given precendence.
+     *
+     * These observations result in the following rules for computing
+     * the ON location:
+     *  - if there are an odd number of Bdy edges, the attribute is Bdy
+     *  - if there are an even number >= 2 of Bdy edges, the attribute
+     *    is Int
+     *  - if there are any Int edges, the attribute is Int
+     *  - otherwise, the attribute is NULL.
+     *
+     */
+    void computeLabelOn(int geomIndex,
+                        const algorithm::BoundaryNodeRule& boundaryNodeRule);
 
-	void computeLabelSides(int geomIndex);
-	void computeLabelSide(int geomIndex,int side);
+    void computeLabelSides(int geomIndex);
+    void computeLabelSide(int geomIndex, int side);
 };
 
 } // namespace geos:operation:relate
diff --git a/include/geos/operation/relate/EdgeEndBundleStar.h b/include/geos/operation/relate/EdgeEndBundleStar.h
index 9118b24..e5b97a7 100644
--- a/include/geos/operation/relate/EdgeEndBundleStar.h
+++ b/include/geos/operation/relate/EdgeEndBundleStar.h
@@ -25,12 +25,12 @@
 
 // Forward declarations
 namespace geos {
-	namespace geom {
-		class IntersectionMatrix;
-	}
-	namespace geomgraph {
-		class EdgeEnd;
-	}
+namespace geom {
+class IntersectionMatrix;
+}
+namespace geomgraph {
+class EdgeEnd;
+}
 }
 
 
@@ -48,16 +48,16 @@ namespace relate { // geos::operation::relate
 class GEOS_DLL EdgeEndBundleStar: public geomgraph::EdgeEndStar {
 public:
 
-	/// Creates a new empty EdgeEndBundleStar
-	EdgeEndBundleStar() {}
+    /// Creates a new empty EdgeEndBundleStar
+    EdgeEndBundleStar() {}
 
-	~EdgeEndBundleStar() override;
-	void insert(geomgraph::EdgeEnd *e) override;
+    ~EdgeEndBundleStar() override;
+    void insert(geomgraph::EdgeEnd* e) override;
 
-	/**
-	 * Update the IM with the contribution for the EdgeStubs around the node.
-	 */
-	void updateIM(geom::IntersectionMatrix& im);
+    /**
+     * Update the IM with the contribution for the EdgeStubs around the node.
+     */
+    void updateIM(geom::IntersectionMatrix& im);
 };
 
 
diff --git a/include/geos/operation/relate/RelateComputer.h b/include/geos/operation/relate/RelateComputer.h
index 02a7515..874ae2b 100644
--- a/include/geos/operation/relate/RelateComputer.h
+++ b/include/geos/operation/relate/RelateComputer.h
@@ -38,19 +38,19 @@
 
 // Forward declarations
 namespace geos {
-	namespace geom {
-		class IntersectionMatrix;
-		class Geometry;
-	}
-	namespace geomgraph {
-		class GeometryGraph;
-		class Edge;
-		class EdgeEnd;
-		class Node;
-		namespace index {
-			class SegmentIntersector;
-		}
-	}
+namespace geom {
+class IntersectionMatrix;
+class Geometry;
+}
+namespace geomgraph {
+class GeometryGraph;
+class Edge;
+class EdgeEnd;
+class Node;
+namespace index {
+class SegmentIntersector;
+}
+}
 }
 
 
@@ -74,87 +74,87 @@ namespace relate { // geos::operation::relate
  */
 class GEOS_DLL RelateComputer {
 public:
-	RelateComputer(std::vector<geomgraph::GeometryGraph*> *newArg);
-	~RelateComputer();
+    RelateComputer(std::vector<geomgraph::GeometryGraph*>* newArg);
+    ~RelateComputer();
 
-	geom::IntersectionMatrix* computeIM();
+    geom::IntersectionMatrix* computeIM();
 private:
 
-	algorithm::LineIntersector li;
-
-	algorithm::PointLocator ptLocator;
-
-	/// the arg(s) of the operation
-	std::vector<geomgraph::GeometryGraph*> *arg;
-
-	geomgraph::NodeMap nodes;
-
-	/// this intersection matrix will hold the results compute for the relate
-	std::unique_ptr<geom::IntersectionMatrix> im;
-
-	std::vector<geomgraph::Edge*> isolatedEdges;
-
-	/// the intersection point found (if any)
-	geom::Coordinate invalidPoint;
-
-	void insertEdgeEnds(std::vector<geomgraph::EdgeEnd*> *ee);
-
-	void computeProperIntersectionIM(
-	    geomgraph::index::SegmentIntersector *intersector,
-	    geom::IntersectionMatrix *imX);
-
-	void copyNodesAndLabels(int argIndex);
-	void computeIntersectionNodes(int argIndex);
-	void labelIntersectionNodes(int argIndex);
-
-	/**
-	 * If the Geometries are disjoint, we need to enter their dimension and
-	 * boundary dimension in the Ext rows in the IM
-	 */
-	void computeDisjointIM(geom::IntersectionMatrix *imX);
-
-	void labelNodeEdges();
-
-	/**
-	 * update the IM with the sum of the IMs for each component
-	 */
-	void updateIM(geom::IntersectionMatrix& imX);
-
-	/**
-	 * Processes isolated edges by computing their labelling and adding them
-	 * to the isolated edges list.
-	 * Isolated edges are guaranteed not to touch the boundary of the target
-	 * (since if they
-	 * did, they would have caused an intersection to be computed and hence would
-	 * not be isolated)
-	 */
-	void labelIsolatedEdges(int thisIndex,int targetIndex);
-
-	/**
-	 * Label an isolated edge of a graph with its relationship to the target
-	 * geometry.
-	 * If the target has dim 2 or 1, the edge can either be in the interior
-	 * or the exterior.
-	 * If the target has dim 0, the edge must be in the exterior
-	 */
-	void labelIsolatedEdge(geomgraph::Edge *e,int targetIndex,
-	                       const geom::Geometry *target);
-
-	/**
-	 * Isolated nodes are nodes whose labels are incomplete
-	 * (e.g. the location for one Geometry is null).
-	 * This is the case because nodes in one graph which don't intersect
-	 * nodes in the other are not completely labelled by the initial process
-	 * of adding nodes to the nodeList.
-	 * To complete the labelling we need to check for nodes that lie in the
-	 * interior of edges, and in the interior of areas.
-	 */
-	void labelIsolatedNodes();
-
-	/**
-	 * Label an isolated node with its relationship to the target geometry.
-	 */
-	void labelIsolatedNode(geomgraph::Node *n,int targetIndex);
+    algorithm::LineIntersector li;
+
+    algorithm::PointLocator ptLocator;
+
+    /// the arg(s) of the operation
+    std::vector<geomgraph::GeometryGraph*>* arg;
+
+    geomgraph::NodeMap nodes;
+
+    /// this intersection matrix will hold the results compute for the relate
+    std::unique_ptr<geom::IntersectionMatrix> im;
+
+    std::vector<geomgraph::Edge*> isolatedEdges;
+
+    /// the intersection point found (if any)
+    geom::Coordinate invalidPoint;
+
+    void insertEdgeEnds(std::vector<geomgraph::EdgeEnd*>* ee);
+
+    void computeProperIntersectionIM(
+        geomgraph::index::SegmentIntersector* intersector,
+        geom::IntersectionMatrix* imX);
+
+    void copyNodesAndLabels(int argIndex);
+    void computeIntersectionNodes(int argIndex);
+    void labelIntersectionNodes(int argIndex);
+
+    /**
+     * If the Geometries are disjoint, we need to enter their dimension and
+     * boundary dimension in the Ext rows in the IM
+     */
+    void computeDisjointIM(geom::IntersectionMatrix* imX);
+
+    void labelNodeEdges();
+
+    /**
+     * update the IM with the sum of the IMs for each component
+     */
+    void updateIM(geom::IntersectionMatrix& imX);
+
+    /**
+     * Processes isolated edges by computing their labelling and adding them
+     * to the isolated edges list.
+     * Isolated edges are guaranteed not to touch the boundary of the target
+     * (since if they
+     * did, they would have caused an intersection to be computed and hence would
+     * not be isolated)
+     */
+    void labelIsolatedEdges(int thisIndex, int targetIndex);
+
+    /**
+     * Label an isolated edge of a graph with its relationship to the target
+     * geometry.
+     * If the target has dim 2 or 1, the edge can either be in the interior
+     * or the exterior.
+     * If the target has dim 0, the edge must be in the exterior
+     */
+    void labelIsolatedEdge(geomgraph::Edge* e, int targetIndex,
+                           const geom::Geometry* target);
+
+    /**
+     * Isolated nodes are nodes whose labels are incomplete
+     * (e.g. the location for one Geometry is null).
+     * This is the case because nodes in one graph which don't intersect
+     * nodes in the other are not completely labelled by the initial process
+     * of adding nodes to the nodeList.
+     * To complete the labelling we need to check for nodes that lie in the
+     * interior of edges, and in the interior of areas.
+     */
+    void labelIsolatedNodes();
+
+    /**
+     * Label an isolated node with its relationship to the target geometry.
+     */
+    void labelIsolatedNode(geomgraph::Node* n, int targetIndex);
 };
 
 
diff --git a/include/geos/operation/relate/RelateNode.h b/include/geos/operation/relate/RelateNode.h
index 7d9c43f..6c0fdcd 100644
--- a/include/geos/operation/relate/RelateNode.h
+++ b/include/geos/operation/relate/RelateNode.h
@@ -25,13 +25,13 @@
 
 // Forward declarations
 namespace geos {
-	namespace geom {
-		class IntersectionMatrix;
-		class Coordinate;
-	}
-	namespace geomgraph {
-		class EdgeEndStar;
-	}
+namespace geom {
+class IntersectionMatrix;
+class Coordinate;
+}
+namespace geomgraph {
+class EdgeEndStar;
+}
 }
 
 
@@ -47,18 +47,18 @@ class GEOS_DLL RelateNode: public geomgraph::Node {
 
 public:
 
-	RelateNode(const geom::Coordinate& coord, geomgraph::EdgeEndStar *edges);
+    RelateNode(const geom::Coordinate& coord, geomgraph::EdgeEndStar* edges);
 
-	~RelateNode() override;
+    ~RelateNode() override;
 
-	/**
-	 * Update the IM with the contribution for the EdgeEnds incident on this node.
-	 */
-	void updateIMFromEdges(geom::IntersectionMatrix& im);
+    /**
+     * Update the IM with the contribution for the EdgeEnds incident on this node.
+     */
+    void updateIMFromEdges(geom::IntersectionMatrix& im);
 
 protected:
 
-	void computeIM(geom::IntersectionMatrix& im) override;
+    void computeIM(geom::IntersectionMatrix& im) override;
 };
 
 
diff --git a/include/geos/operation/relate/RelateNodeFactory.h b/include/geos/operation/relate/RelateNodeFactory.h
index 60e38e2..2152fe0 100644
--- a/include/geos/operation/relate/RelateNodeFactory.h
+++ b/include/geos/operation/relate/RelateNodeFactory.h
@@ -25,12 +25,12 @@
 
 // Forward declarations
 namespace geos {
-	namespace geom {
-		class Coordinate;
-	}
-	namespace geomgraph {
-		class Node;
-	}
+namespace geom {
+class Coordinate;
+}
+namespace geomgraph {
+class Node;
+}
 }
 
 
@@ -43,10 +43,10 @@ namespace relate { // geos::operation::relate
  */
 class GEOS_DLL RelateNodeFactory: public geomgraph::NodeFactory {
 public:
-	geomgraph::Node* createNode(const geom::Coordinate &coord) const override;
-	static const geomgraph::NodeFactory &instance();
+    geomgraph::Node* createNode(const geom::Coordinate& coord) const override;
+    static const geomgraph::NodeFactory& instance();
 private:
-	RelateNodeFactory() {}
+    RelateNodeFactory() {}
 };
 
 
diff --git a/include/geos/operation/relate/RelateNodeGraph.h b/include/geos/operation/relate/RelateNodeGraph.h
index b57785c..88ee2f4 100644
--- a/include/geos/operation/relate/RelateNodeGraph.h
+++ b/include/geos/operation/relate/RelateNodeGraph.h
@@ -26,17 +26,17 @@
 
 // Forward declarations
 namespace geos {
-	namespace geom {
-		class Coordinate;
-		struct CoordinateLessThen;
-	}
-	namespace geomgraph {
-		//class EdgeEndStar;
-		class Node;
-		class GeometryGraph;
-		class EdgeEnd;
-		class NodeMap;
-	}
+namespace geom {
+class Coordinate;
+struct CoordinateLessThen;
+}
+namespace geomgraph {
+//class EdgeEndStar;
+class Node;
+class GeometryGraph;
+class EdgeEnd;
+class NodeMap;
+}
 }
 
 
@@ -69,25 +69,25 @@ class GEOS_DLL RelateNodeGraph {
 
 public:
 
-	RelateNodeGraph();
+    RelateNodeGraph();
 
-	virtual ~RelateNodeGraph();
+    virtual ~RelateNodeGraph();
 
-	std::map<geom::Coordinate*, geomgraph::Node*,
-			geom::CoordinateLessThen> &getNodeMap();
+    std::map<geom::Coordinate*, geomgraph::Node*,
+        geom::CoordinateLessThen>& getNodeMap();
 
-	void build(geomgraph::GeometryGraph *geomGraph);
+    void build(geomgraph::GeometryGraph* geomGraph);
 
-	void computeIntersectionNodes(geomgraph::GeometryGraph *geomGraph,
-			int argIndex);
+    void computeIntersectionNodes(geomgraph::GeometryGraph* geomGraph,
+                                  int argIndex);
 
-	void copyNodesAndLabels(geomgraph::GeometryGraph *geomGraph,int argIndex);
+    void copyNodesAndLabels(geomgraph::GeometryGraph* geomGraph, int argIndex);
 
-	void insertEdgeEnds(std::vector<geomgraph::EdgeEnd*> *ee);
+    void insertEdgeEnds(std::vector<geomgraph::EdgeEnd*>* ee);
 
 private:
 
-	geomgraph::NodeMap *nodes;
+    geomgraph::NodeMap* nodes;
 };
 
 
diff --git a/include/geos/operation/relate/RelateOp.h b/include/geos/operation/relate/RelateOp.h
index b3b99f6..389dae6 100644
--- a/include/geos/operation/relate/RelateOp.h
+++ b/include/geos/operation/relate/RelateOp.h
@@ -26,13 +26,13 @@
 
 // Forward declarations
 namespace geos {
-	namespace algorithm {
-		class BoundaryNodeRule;
-	}
-	namespace geom {
-		class IntersectionMatrix;
-		class Geometry;
-	}
+namespace algorithm {
+class BoundaryNodeRule;
+}
+namespace geom {
+class IntersectionMatrix;
+class Geometry;
+}
 }
 
 
@@ -58,75 +58,75 @@ class GEOS_DLL RelateOp: public GeometryGraphOperation {
 
 public:
 
-	/** \brief
-	 * Computes the geom::IntersectionMatrix for the spatial relationship
-	 * between two geom::Geometry objects, using the default (OGC SFS)
-	 * Boundary Node Rule
-	 *
-	 * @param a a Geometry to test. Ownership left to caller.
-	 * @param b a Geometry to test. Ownership left to caller.
-	 *
-	 * @return the IntersectonMatrix for the spatial relationship
-	 *         between the geometries. Ownership transferred.
-	 */
-	static geom::IntersectionMatrix* relate(
-			const geom::Geometry *a,
-			const geom::Geometry *b);
-
-	/** \brief
-	 * Computes the geom::IntersectionMatrix for the spatial relationship
-	 * between two geom::Geometry objects, using a specified
-	 * Boundary Node Rule
-	 *
-	 * @param a a Geometry to test. Ownership left to caller.
-	 * @param b a Geometry to test. Ownership left to caller.
-	 * @param boundaryNodeRule the Boundary Node Rule to use.
-	 *
-	 * @return the IntersectonMatrix for the spatial relationship
-	 *         between the geometries. Ownership transferred.
-	 */
-	static geom::IntersectionMatrix* relate(
-			const geom::Geometry *a,
-			const geom::Geometry *b,
-			const algorithm::BoundaryNodeRule& boundaryNodeRule);
-
-	/** \brief
-	 * Creates a new Relate operation, using the default (OGC SFS)
-	 * Boundary Node Rule.
-	 *
-	 * @param g0 a Geometry to relate. Ownership left to caller.
-	 * @param g1 another Geometry to relate. Ownership to caller.
-	 */
-	RelateOp(const geom::Geometry *g0,
-			const geom::Geometry *g1);
-
-	/** \brief
-	 * Creates a new Relate operation with a specified
-	 * Boundary Node Rule.
-	 *
-	 * @param g0 a Geometry to relate. Ownership left to caller.
-	 * @param g1 another Geometry to relate. Ownership to caller.
-	 * @param boundaryNodeRule the Boundary Node Rule to use
-	 */
-	RelateOp(const geom::Geometry *g0,
-	         const geom::Geometry *g1,
-	         const algorithm::BoundaryNodeRule& boundaryNodeRule);
-
-	~RelateOp() override;
-
-	/** \brief
-	 * Gets the IntersectionMatrix for the spatial relationship
-	 * between the input geometries.
-	 *
-	 * @return the geom::IntersectionMatrix for the spatial
-	 *         relationship between the input geometries.
-	 *         Ownership transferred.
-	 */
-	geom::IntersectionMatrix* getIntersectionMatrix();
+    /** \brief
+     * Computes the geom::IntersectionMatrix for the spatial relationship
+     * between two geom::Geometry objects, using the default (OGC SFS)
+     * Boundary Node Rule
+     *
+     * @param a a Geometry to test. Ownership left to caller.
+     * @param b a Geometry to test. Ownership left to caller.
+     *
+     * @return the IntersectonMatrix for the spatial relationship
+     *         between the geometries. Ownership transferred.
+     */
+    static geom::IntersectionMatrix* relate(
+        const geom::Geometry* a,
+        const geom::Geometry* b);
+
+    /** \brief
+     * Computes the geom::IntersectionMatrix for the spatial relationship
+     * between two geom::Geometry objects, using a specified
+     * Boundary Node Rule
+     *
+     * @param a a Geometry to test. Ownership left to caller.
+     * @param b a Geometry to test. Ownership left to caller.
+     * @param boundaryNodeRule the Boundary Node Rule to use.
+     *
+     * @return the IntersectonMatrix for the spatial relationship
+     *         between the geometries. Ownership transferred.
+     */
+    static geom::IntersectionMatrix* relate(
+        const geom::Geometry* a,
+        const geom::Geometry* b,
+        const algorithm::BoundaryNodeRule& boundaryNodeRule);
+
+    /** \brief
+     * Creates a new Relate operation, using the default (OGC SFS)
+     * Boundary Node Rule.
+     *
+     * @param g0 a Geometry to relate. Ownership left to caller.
+     * @param g1 another Geometry to relate. Ownership to caller.
+     */
+    RelateOp(const geom::Geometry* g0,
+             const geom::Geometry* g1);
+
+    /** \brief
+     * Creates a new Relate operation with a specified
+     * Boundary Node Rule.
+     *
+     * @param g0 a Geometry to relate. Ownership left to caller.
+     * @param g1 another Geometry to relate. Ownership to caller.
+     * @param boundaryNodeRule the Boundary Node Rule to use
+     */
+    RelateOp(const geom::Geometry* g0,
+             const geom::Geometry* g1,
+             const algorithm::BoundaryNodeRule& boundaryNodeRule);
+
+    ~RelateOp() override;
+
+    /** \brief
+     * Gets the IntersectionMatrix for the spatial relationship
+     * between the input geometries.
+     *
+     * @return the geom::IntersectionMatrix for the spatial
+     *         relationship between the input geometries.
+     *         Ownership transferred.
+     */
+    geom::IntersectionMatrix* getIntersectionMatrix();
 
 private:
 
-	RelateComputer relateComp;
+    RelateComputer relateComp;
 };
 
 
diff --git a/include/geos/operation/sharedpaths/SharedPathsOp.h b/include/geos/operation/sharedpaths/SharedPathsOp.h
index e2d3d14..3247352 100644
--- a/include/geos/operation/sharedpaths/SharedPathsOp.h
+++ b/include/geos/operation/sharedpaths/SharedPathsOp.h
@@ -32,11 +32,11 @@
 
 // Forward declarations
 namespace geos {
-  namespace geom {
-    class LineString;
-    class Geometry;
-    class GeometryFactory;
-  }
+namespace geom {
+class LineString;
+class Geometry;
+class GeometryFactory;
+}
 }
 
 
@@ -61,96 +61,97 @@ namespace sharedpaths { // geos.operation.sharedpaths
  * e Postgis (CIG 0494241492)"
  *
  */
-class GEOS_DLL SharedPathsOp
-{
+class GEOS_DLL SharedPathsOp {
 public:
 
-  /// LineString vector (list of edges)
-  typedef std::vector<geom::LineString*> PathList;
-
-  /// Find paths shared between two linear geometries
-  //
-  /// @param g1
-  ///   First geometry. Must be linear.
-  ///
-  /// @param g2
-  ///   Second geometry. Must be linear.
-  ///
-  /// @param sameDir
-  ///   Shared edges having the same direction are pushed
-  ///   onto this vector. They'll be of type LineString.
-  ///   Ownership of the edges is tranferred.
-  ///
-  /// @param oppositeDir
-  ///   Shared edges having the opposite direction are pushed
-  ///   onto this vector. They'll be of type geom::LineString.
-  ///   Ownership of the edges is tranferred.
-  ///
-  static void sharedPathsOp(const geom::Geometry& g1,
-                            const geom::Geometry& g2,
-                            PathList& sameDirection,
-                            PathList& oppositeDirection);
-
-  /// Constructor
-  //
-  /// @param g1
-  ///   First geometry. Must be linear.
-  ///
-  /// @param g2
-  ///   Second geometry. Must be linear.
-  ///
-  SharedPathsOp(const geom::Geometry& g1, const geom::Geometry& g2);
-
-  /// Get shared paths
-  //
-  /// @param sameDir
-  ///   Shared edges having the same direction are pushed
-  ///   onto this vector. They'll be of type geom::LineString.
-  ///   Ownership of the edges is tranferred.
-  ///
-  /// @param oppositeDir
-  ///   Shared edges having the opposite direction are pushed
-  ///   onto this vector. They'll be of type geom::LineString.
-  ///   Ownership of the edges is tranferred.
-  ///
-  void getSharedPaths(PathList& sameDirection, PathList& oppositeDirection);
-
-  /// Delete all edges in the list
-  static void clearEdges(PathList& from);
+    /// LineString vector (list of edges)
+    typedef std::vector<geom::LineString*> PathList;
+
+    /// Find paths shared between two linear geometries
+    //
+    /// @param g1
+    ///   First geometry. Must be linear.
+    ///
+    /// @param g2
+    ///   Second geometry. Must be linear.
+    ///
+    /// @param sameDir
+    ///   Shared edges having the same direction are pushed
+    ///   onto this vector. They'll be of type LineString.
+    ///   Ownership of the edges is tranferred.
+    ///
+    /// @param oppositeDir
+    ///   Shared edges having the opposite direction are pushed
+    ///   onto this vector. They'll be of type geom::LineString.
+    ///   Ownership of the edges is tranferred.
+    ///
+    static void sharedPathsOp(const geom::Geometry& g1,
+                              const geom::Geometry& g2,
+                              PathList& sameDirection,
+                              PathList& oppositeDirection);
+
+    /// Constructor
+    //
+    /// @param g1
+    ///   First geometry. Must be linear.
+    ///
+    /// @param g2
+    ///   Second geometry. Must be linear.
+    ///
+    SharedPathsOp(const geom::Geometry& g1, const geom::Geometry& g2);
+
+    /// Get shared paths
+    //
+    /// @param sameDir
+    ///   Shared edges having the same direction are pushed
+    ///   onto this vector. They'll be of type geom::LineString.
+    ///   Ownership of the edges is tranferred.
+    ///
+    /// @param oppositeDir
+    ///   Shared edges having the opposite direction are pushed
+    ///   onto this vector. They'll be of type geom::LineString.
+    ///   Ownership of the edges is tranferred.
+    ///
+    void getSharedPaths(PathList& sameDirection, PathList& oppositeDirection);
+
+    /// Delete all edges in the list
+    static void clearEdges(PathList& from);
 
 private:
 
-  /// Get all the linear intersections
-  //
-  /// Ownership of linestring pushed to the given container
-  /// is transferred to caller. See clearEdges for a deep
-  /// release if you need one.
-  ///
-  void findLinearIntersections(PathList& to);
-
-  /// Check if the given edge goes forward or backward on the given line.
-  //
-  /// PRECONDITION: It is assumed the edge fully lays on the geometry
-  ///
-  bool isForward(const geom::LineString& edge,
-                 const geom::Geometry& geom);
-
-  /// Check if the given edge goes in the same direction over
-  /// the two geometries.
-  bool isSameDirection(const geom::LineString& edge) {
-    return (isForward(edge, _g1) == isForward(edge, _g2));
-  }
-
-  /// Throw an IllegalArgumentException if the geom is not linear
-  void checkLinealInput(const geom::Geometry& g);
-
-  const geom::Geometry& _g1;
-  const geom::Geometry& _g2;
-  const geom::GeometryFactory& _gf;
-
-  // Declare type as noncopyable
-  SharedPathsOp(const SharedPathsOp& other) = delete;
-  SharedPathsOp& operator=(const SharedPathsOp& rhs) = delete;
+    /// Get all the linear intersections
+    //
+    /// Ownership of linestring pushed to the given container
+    /// is transferred to caller. See clearEdges for a deep
+    /// release if you need one.
+    ///
+    void findLinearIntersections(PathList& to);
+
+    /// Check if the given edge goes forward or backward on the given line.
+    //
+    /// PRECONDITION: It is assumed the edge fully lays on the geometry
+    ///
+    bool isForward(const geom::LineString& edge,
+                   const geom::Geometry& geom);
+
+    /// Check if the given edge goes in the same direction over
+    /// the two geometries.
+    bool
+    isSameDirection(const geom::LineString& edge)
+    {
+        return (isForward(edge, _g1) == isForward(edge, _g2));
+    }
+
+    /// Throw an IllegalArgumentException if the geom is not linear
+    void checkLinealInput(const geom::Geometry& g);
+
+    const geom::Geometry& _g1;
+    const geom::Geometry& _g2;
+    const geom::GeometryFactory& _gf;
+
+    // Declare type as noncopyable
+    SharedPathsOp(const SharedPathsOp& other) = delete;
+    SharedPathsOp& operator=(const SharedPathsOp& rhs) = delete;
 
 };
 
diff --git a/include/geos/operation/union/CascadedPolygonUnion.h b/include/geos/operation/union/CascadedPolygonUnion.h
index 775fd7e..c095bf2 100644
--- a/include/geos/operation/union/CascadedPolygonUnion.h
+++ b/include/geos/operation/union/CascadedPolygonUnion.h
@@ -31,18 +31,18 @@
 
 // Forward declarations
 namespace geos {
-    namespace geom {
-        class GeometryFactory;
-        class Geometry;
-        class Polygon;
-        class MultiPolygon;
-        class Envelope;
-    }
-    namespace index {
-        namespace strtree {
-            class ItemsList;
-        }
-    }
+namespace geom {
+class GeometryFactory;
+class Geometry;
+class Polygon;
+class MultiPolygon;
+class Envelope;
+}
+namespace index {
+namespace strtree {
+class ItemsList;
+}
+}
 }
 
 namespace geos {
@@ -68,8 +68,7 @@ namespace geounion {  // geos::operation::geounion
  * where there is <i>no</i> overlap between the input geometries.
  * However, this case is likely rare in practice.
  */
-class GEOS_DLL CascadedPolygonUnion
-{
+class GEOS_DLL CascadedPolygonUnion {
 private:
     std::vector<geom::Polygon*>* inputPolys;
     geom::GeometryFactory const* geomFactory;
@@ -119,14 +118,15 @@ public:
      * @param end end iterator
      */
     template <class T>
-    static geom::Geometry* Union(T start, T end)
+    static geom::Geometry*
+    Union(T start, T end)
     {
-      std::vector<geom::Polygon*> polys;
-      for (T i=start; i!=end; ++i) {
-        const geom::Polygon* p = dynamic_cast<const geom::Polygon*>(*i);
-        polys.push_back(const_cast<geom::Polygon*>(p));
-      }
-      return Union(&polys);
+        std::vector<geom::Polygon*> polys;
+        for(T i = start; i != end; ++i) {
+            const geom::Polygon* p = dynamic_cast<const geom::Polygon*>(*i);
+            polys.push_back(const_cast<geom::Polygon*>(p));
+        }
+        return Union(&polys);
     }
 
     /**
@@ -146,8 +146,8 @@ public:
      *        ownership of elements _and_ vector are left to caller.
      */
     CascadedPolygonUnion(std::vector<geom::Polygon*>* polys)
-      : inputPolys(polys),
-        geomFactory(nullptr)
+        : inputPolys(polys),
+          geomFactory(nullptr)
     {}
 
     /**
@@ -178,7 +178,7 @@ private:
      * @return the union of the list section
      */
     geom::Geometry* binaryUnion(GeometryListHolder* geoms, std::size_t start,
-        std::size_t end);
+                                std::size_t end);
 
     /**
      * Reduces a tree of geometries to a list of geometries
@@ -222,20 +222,20 @@ private:
      * @return the union of the inputs
      */
     geom::Geometry* unionUsingEnvelopeIntersection(geom::Geometry* g0,
-        geom::Geometry* g1, geom::Envelope const& common);
+            geom::Geometry* g1, geom::Envelope const& common);
 
     geom::Geometry* extractByEnvelope(geom::Envelope const& env,
-        geom::Geometry* geom, std::vector<geom::Geometry*>& disjointGeoms);
+                                      geom::Geometry* geom, std::vector<geom::Geometry*>& disjointGeoms);
 
     void extractByEnvelope(geom::Envelope const& env,
-        geom::Geometry* geom,
-        std::vector<geom::Geometry*>& intersectingGeoms,
-        std::vector<geom::Geometry*>& disjointGeoms);
+                           geom::Geometry* geom,
+                           std::vector<geom::Geometry*>& intersectingGeoms,
+                           std::vector<geom::Geometry*>& disjointGeoms);
 
     void extractByEnvelope(geom::Envelope const& env,
-        std::vector<geom::Geometry*>& sourceGeoms,
-        std::vector<geom::Geometry*>& intersectingGeoms,
-        std::vector<geom::Geometry*>& disjointGeoms);
+                           std::vector<geom::Geometry*>& sourceGeoms,
+                           std::vector<geom::Geometry*>& intersectingGeoms,
+                           std::vector<geom::Geometry*>& disjointGeoms);
 
     /**
      * Encapsulates the actual unioning of two polygonal geometries.
diff --git a/include/geos/operation/union/CascadedUnion.h b/include/geos/operation/union/CascadedUnion.h
index e01b8e5..77d6361 100644
--- a/include/geos/operation/union/CascadedUnion.h
+++ b/include/geos/operation/union/CascadedUnion.h
@@ -28,17 +28,17 @@
 
 // Forward declarations
 namespace geos {
-    namespace geom {
-        class GeometryFactory;
-        class Geometry;
-        class Geometry;
-        class Envelope;
-    }
-    namespace index {
-        namespace strtree {
-            class ItemsList;
-        }
-    }
+namespace geom {
+class GeometryFactory;
+class Geometry;
+class Geometry;
+class Envelope;
+}
+namespace index {
+namespace strtree {
+class ItemsList;
+}
+}
 }
 
 namespace geos {
@@ -52,8 +52,7 @@ namespace geounion {  // geos::operation::geounion
  * This algorithm is more robust than the simple iterated approach
  * of repeatedly unioning each geometry to a result geometry.
  */
-class GEOS_DLL CascadedUnion
-{
+class GEOS_DLL CascadedUnion {
 private:
     const std::vector<geom::Geometry*>* inputGeoms;
     geom::GeometryFactory const* geomFactory;
@@ -86,14 +85,15 @@ public:
      * @param end end iterator
      */
     template <class T>
-    static geom::Geometry* Union(T start, T end)
+    static geom::Geometry*
+    Union(T start, T end)
     {
-      std::vector<geom::Geometry*> polys;
-      for (T i=start; i!=end; ++i) {
-        const geom::Geometry* p = dynamic_cast<const geom::Geometry*>(*i);
-        polys.push_back(const_cast<geom::Geometry*>(p));
-      }
-      return Union(&polys);
+        std::vector<geom::Geometry*> polys;
+        for(T i = start; i != end; ++i) {
+            const geom::Geometry* p = dynamic_cast<const geom::Geometry*>(*i);
+            polys.push_back(const_cast<geom::Geometry*>(p));
+        }
+        return Union(&polys);
     }
 
     /**
@@ -104,8 +104,8 @@ public:
      *        ownership of elements _and_ vector are left to caller.
      */
     CascadedUnion(const std::vector<geom::Geometry*>* geoms)
-      : inputGeoms(geoms),
-        geomFactory(nullptr)
+        : inputGeoms(geoms),
+          geomFactory(nullptr)
     {}
 
     /**
@@ -136,7 +136,7 @@ private:
      * @return the union of the list section
      */
     geom::Geometry* binaryUnion(GeometryListHolder* geoms, std::size_t start,
-        std::size_t end);
+                                std::size_t end);
 
     /**
      * Reduces a tree of geometries to a list of geometries
@@ -177,10 +177,10 @@ private:
      * @return the union of the inputs
      */
     geom::Geometry* unionUsingEnvelopeIntersection(geom::Geometry* g0,
-        geom::Geometry* g1, geom::Envelope const& common);
+            geom::Geometry* g1, geom::Envelope const& common);
 
     geom::Geometry* extractByEnvelope(geom::Envelope const& env,
-        geom::Geometry* geom, std::vector<geom::Geometry*>& disjointGeoms);
+                                      geom::Geometry* geom, std::vector<geom::Geometry*>& disjointGeoms);
 
     /**
      * Encapsulates the actual unioning of two polygonal geometries.
diff --git a/include/geos/operation/union/GeometryListHolder.h b/include/geos/operation/union/GeometryListHolder.h
index e88f968..1498da0 100644
--- a/include/geos/operation/union/GeometryListHolder.h
+++ b/include/geos/operation/union/GeometryListHolder.h
@@ -18,9 +18,9 @@
 
 // Forward declarations
 namespace geos {
-  namespace geom {
-    class Geometry;
-  }
+namespace geom {
+class Geometry;
+}
 }
 
 namespace geos {
@@ -31,8 +31,7 @@ namespace geounion {  // geos::operation::geounion
  * \brief Helper class holding Geometries, part of which are held by reference
  *        others are held exclusively.
  */
-class GeometryListHolder : public std::vector<geom::Geometry*>
-{
+class GeometryListHolder : public std::vector<geom::Geometry*> {
 private:
     typedef std::vector<geom::Geometry*> base_type;
 
@@ -41,21 +40,24 @@ public:
     ~GeometryListHolder()
     {
         std::for_each(ownedItems.begin(), ownedItems.end(),
-            &GeometryListHolder::deleteItem);
+                      &GeometryListHolder::deleteItem);
     }
 
     // items need to be deleted in the end
-    void push_back_owned(geom::Geometry* item)
+    void
+    push_back_owned(geom::Geometry* item)
     {
         this->base_type::push_back(item);
         ownedItems.push_back(item);
     }
 
-    geom::Geometry* getGeometry(std::size_t index)
+    geom::Geometry*
+    getGeometry(std::size_t index)
     {
-      if (index >= this->base_type::size())
-          return nullptr;
-      return (*this)[index];
+        if(index >= this->base_type::size()) {
+            return nullptr;
+        }
+        return (*this)[index];
     }
 
 private:
diff --git a/include/geos/operation/union/PointGeometryUnion.h b/include/geos/operation/union/PointGeometryUnion.h
index 31bbec3..8ed31c4 100644
--- a/include/geos/operation/union/PointGeometryUnion.h
+++ b/include/geos/operation/union/PointGeometryUnion.h
@@ -25,11 +25,11 @@
 
 // Forward declarations
 namespace geos {
-    namespace geom {
-        class GeometryFactory;
-        class Geometry;
-        class Puntal;
-    }
+namespace geom {
+class GeometryFactory;
+class Geometry;
+class Puntal;
+}
 }
 
 namespace geos {
@@ -44,28 +44,27 @@ namespace geounion {  // geos::operation::geounion
  * Does not copy any component geometries.
  *
  */
-class GEOS_DLL PointGeometryUnion
-{
+class GEOS_DLL PointGeometryUnion {
 public:
 
-  static std::unique_ptr<geom::Geometry> Union(
-      const geom::Puntal& pointGeom,
-      const geom::Geometry& otherGeom);
+    static std::unique_ptr<geom::Geometry> Union(
+        const geom::Puntal& pointGeom,
+        const geom::Geometry& otherGeom);
 
 
-  PointGeometryUnion(const geom::Puntal& pointGeom,
-                     const geom::Geometry& otherGeom);
+    PointGeometryUnion(const geom::Puntal& pointGeom,
+                       const geom::Geometry& otherGeom);
 
-  std::unique_ptr<geom::Geometry> Union() const;
+    std::unique_ptr<geom::Geometry> Union() const;
 
 private:
-  const geom::Geometry& pointGeom;
-  const geom::Geometry& otherGeom;
-  const geom::GeometryFactory* geomFact;
+    const geom::Geometry& pointGeom;
+    const geom::Geometry& otherGeom;
+    const geom::GeometryFactory* geomFact;
 
-  // Declared as non-copyable
-  PointGeometryUnion(const PointGeometryUnion& other);
-  PointGeometryUnion& operator=(const PointGeometryUnion& rhs);
+    // Declared as non-copyable
+    PointGeometryUnion(const PointGeometryUnion& other);
+    PointGeometryUnion& operator=(const PointGeometryUnion& rhs);
 };
 
 } // namespace geos::operation::union
diff --git a/include/geos/operation/union/UnaryUnionOp.h b/include/geos/operation/union/UnaryUnionOp.h
index 832e173..e44e735 100644
--- a/include/geos/operation/union/UnaryUnionOp.h
+++ b/include/geos/operation/union/UnaryUnionOp.h
@@ -39,10 +39,10 @@
 
 // Forward declarations
 namespace geos {
-    namespace geom {
-        class GeometryFactory;
-        class Geometry;
-    }
+namespace geom {
+class GeometryFactory;
+class Geometry;
+}
 }
 
 namespace geos {
@@ -82,136 +82,142 @@ namespace geounion {  // geos::operation::geounion
  * MultiPolygons (although the polygon components must all still be
  * individually valid.)
  */
-class GEOS_DLL UnaryUnionOp
-{
+class GEOS_DLL UnaryUnionOp {
 public:
 
-  template <typename T>
-  static std::unique_ptr<geom::Geometry> Union(const T& geoms)
-  {
-    UnaryUnionOp op(geoms);
-    return op.Union();
-  }
-
-  template <class T>
-  static std::unique_ptr<geom::Geometry> Union(const T& geoms,
-      geom::GeometryFactory& geomFact)
-  {
-    UnaryUnionOp op(geoms, geomFact);
-    return op.Union();
-  }
-
-  static std::unique_ptr<geom::Geometry> Union(const geom::Geometry& geom)
-  {
-    UnaryUnionOp op(geom);
-    return op.Union();
-  }
-
-  template <class T>
-  UnaryUnionOp(const T& geoms, geom::GeometryFactory& geomFactIn)
-      :
-      geomFact(&geomFactIn)
-  {
-    extractGeoms(geoms);
-  }
-
-  template <class T>
-  UnaryUnionOp(const T& geoms)
-      :
-      geomFact(nullptr)
-  {
-    extractGeoms(geoms);
-  }
-
-  UnaryUnionOp(const geom::Geometry& geom)
-      :
-      geomFact(geom.getFactory())
-  {
-    extract(geom);
-  }
-
-  /**
-   * \brief
-   * Gets the union of the input geometries.
-   *
-   * If no input geometries were provided, a POINT EMPTY is returned.
-   *
-   * @return a Geometry containing the union
-   * @return an empty GEOMETRYCOLLECTION if no geometries were provided
-   *         in the input
-   */
-  std::unique_ptr<geom::Geometry> Union();
+    template <typename T>
+    static std::unique_ptr<geom::Geometry>
+    Union(const T& geoms)
+    {
+        UnaryUnionOp op(geoms);
+        return op.Union();
+    }
+
+    template <class T>
+    static std::unique_ptr<geom::Geometry>
+    Union(const T& geoms,
+          geom::GeometryFactory& geomFact)
+    {
+        UnaryUnionOp op(geoms, geomFact);
+        return op.Union();
+    }
+
+    static std::unique_ptr<geom::Geometry>
+    Union(const geom::Geometry& geom)
+    {
+        UnaryUnionOp op(geom);
+        return op.Union();
+    }
+
+    template <class T>
+    UnaryUnionOp(const T& geoms, geom::GeometryFactory& geomFactIn)
+        :
+        geomFact(&geomFactIn)
+    {
+        extractGeoms(geoms);
+    }
+
+    template <class T>
+    UnaryUnionOp(const T& geoms)
+        :
+        geomFact(nullptr)
+    {
+        extractGeoms(geoms);
+    }
+
+    UnaryUnionOp(const geom::Geometry& geom)
+        :
+        geomFact(geom.getFactory())
+    {
+        extract(geom);
+    }
+
+    /**
+     * \brief
+     * Gets the union of the input geometries.
+     *
+     * If no input geometries were provided, a POINT EMPTY is returned.
+     *
+     * @return a Geometry containing the union
+     * @return an empty GEOMETRYCOLLECTION if no geometries were provided
+     *         in the input
+     */
+    std::unique_ptr<geom::Geometry> Union();
 
 private:
 
-  template <typename T>
-  void extractGeoms(const T& geoms)
-  {
-      for (typename T::const_iterator
-              i=geoms.begin(),
-              e=geoms.end();
-              i!=e;
-              ++i)
-      {
-          const geom::Geometry* geom = *i;
-          extract(*geom);
-      }
-  }
-
-  void extract(const geom::Geometry& geom)
-  {
-      using namespace geom::util;
-
-      if ( ! geomFact ) geomFact = geom.getFactory();
-
-      GeometryExtracter::extract<geom::Polygon>(geom, polygons);
-      GeometryExtracter::extract<geom::LineString>(geom, lines);
-      GeometryExtracter::extract<geom::Point>(geom, points);
-  }
-
-  /**
-   * Computes a unary union with no extra optimization,
-   * and no short-circuiting.
-   * Due to the way the overlay operations
-   * are implemented, this is still efficient in the case of linear
-   * and puntal geometries.
-   * Uses robust version of overlay operation
-   * to ensure identical behaviour to the <tt>union(Geometry)</tt> operation.
-   *
-   * @param g0 a geometry
-   * @return the union of the input geometry
-   */
-  std::unique_ptr<geom::Geometry> unionNoOpt(const geom::Geometry& g0)
-  {
-    using geos::operation::overlay::OverlayOp;
-    //using geos::operation::overlay::snap::SnapIfNeededOverlayOp;
-
-    if ( ! empty.get() ) {
-      empty.reset( geomFact->createEmptyGeometry() );
+    template <typename T>
+    void
+    extractGeoms(const T& geoms)
+    {
+        for(typename T::const_iterator
+                i = geoms.begin(),
+                e = geoms.end();
+                i != e;
+                ++i) {
+            const geom::Geometry* geom = *i;
+            extract(*geom);
+        }
+    }
+
+    void
+    extract(const geom::Geometry& geom)
+    {
+        using namespace geom::util;
+
+        if(! geomFact) {
+            geomFact = geom.getFactory();
+        }
+
+        GeometryExtracter::extract<geom::Polygon>(geom, polygons);
+        GeometryExtracter::extract<geom::LineString>(geom, lines);
+        GeometryExtracter::extract<geom::Point>(geom, points);
     }
-    //return SnapIfNeededOverlayOp::overlayOp(g0, *empty, OverlayOp::opUNION);
-    return BinaryOp(&g0, empty.get(), overlay::overlayOp(OverlayOp::opUNION));
-  }
-
-  /**
-   * Computes the union of two geometries,
-   * either of both of which may be null.
-   *
-   * @param g0 a Geometry (ownership transferred)
-   * @param g1 a Geometry (ownership transferred)
-   * @return the union of the input(s)
-   * @return null if both inputs are null
-   */
-  std::unique_ptr<geom::Geometry> unionWithNull(std::unique_ptr<geom::Geometry> g0,
-                                              std::unique_ptr<geom::Geometry> g1);
-
-  std::vector<const geom::Polygon*> polygons;
-  std::vector<const geom::LineString*> lines;
-  std::vector<const geom::Point*> points;
-
-  const geom::GeometryFactory* geomFact;
-
-  std::unique_ptr<geom::Geometry> empty;
+
+    /**
+     * Computes a unary union with no extra optimization,
+     * and no short-circuiting.
+     * Due to the way the overlay operations
+     * are implemented, this is still efficient in the case of linear
+     * and puntal geometries.
+     * Uses robust version of overlay operation
+     * to ensure identical behaviour to the <tt>union(Geometry)</tt> operation.
+     *
+     * @param g0 a geometry
+     * @return the union of the input geometry
+     */
+    std::unique_ptr<geom::Geometry>
+    unionNoOpt(const geom::Geometry& g0)
+    {
+        using geos::operation::overlay::OverlayOp;
+        //using geos::operation::overlay::snap::SnapIfNeededOverlayOp;
+
+        if(! empty.get()) {
+            empty.reset(geomFact->createEmptyGeometry());
+        }
+        //return SnapIfNeededOverlayOp::overlayOp(g0, *empty, OverlayOp::opUNION);
+        return BinaryOp(&g0, empty.get(), overlay::overlayOp(OverlayOp::opUNION));
+    }
+
+    /**
+     * Computes the union of two geometries,
+     * either of both of which may be null.
+     *
+     * @param g0 a Geometry (ownership transferred)
+     * @param g1 a Geometry (ownership transferred)
+     * @return the union of the input(s)
+     * @return null if both inputs are null
+     */
+    std::unique_ptr<geom::Geometry> unionWithNull(std::unique_ptr<geom::Geometry> g0,
+            std::unique_ptr<geom::Geometry> g1);
+
+    std::vector<const geom::Polygon*> polygons;
+    std::vector<const geom::LineString*> lines;
+    std::vector<const geom::Point*> points;
+
+    const geom::GeometryFactory* geomFact;
+
+    std::unique_ptr<geom::Geometry> empty;
 };
 
 
diff --git a/include/geos/operation/valid/ConnectedInteriorTester.h b/include/geos/operation/valid/ConnectedInteriorTester.h
index 76a2786..4e101ba 100644
--- a/include/geos/operation/valid/ConnectedInteriorTester.h
+++ b/include/geos/operation/valid/ConnectedInteriorTester.h
@@ -34,20 +34,20 @@
 
 // Forward declarations
 namespace geos {
-	namespace geom {
-		//class Coordinate;
-		class Geometry;
-		class CoordinateSequence;
-		class GeometryFactory;
-		class LineString;
-	}
-	namespace geomgraph {
-		class GeometryGraph;
-		class PlanarGraph;
-		class EdgeRing;
-		class DirectedEdge;
-		class EdgeEnd;
-	}
+namespace geom {
+//class Coordinate;
+class Geometry;
+class CoordinateSequence;
+class GeometryFactory;
+class LineString;
+}
+namespace geomgraph {
+class GeometryGraph;
+class PlanarGraph;
+class EdgeRing;
+class DirectedEdge;
+class EdgeEnd;
+}
 }
 
 namespace geos {
@@ -70,68 +70,68 @@ namespace valid { // geos::operation::valid
  */
 class GEOS_DLL ConnectedInteriorTester {
 public:
-	ConnectedInteriorTester(geomgraph::GeometryGraph &newGeomGraph);
-	~ConnectedInteriorTester();
-	geom::Coordinate& getCoordinate();
-	bool isInteriorsConnected();
-	static const geom::Coordinate& findDifferentPoint(
-			const geom::CoordinateSequence *coord,
-			const geom::Coordinate& pt);
+    ConnectedInteriorTester(geomgraph::GeometryGraph& newGeomGraph);
+    ~ConnectedInteriorTester();
+    geom::Coordinate& getCoordinate();
+    bool isInteriorsConnected();
+    static const geom::Coordinate& findDifferentPoint(
+        const geom::CoordinateSequence* coord,
+        const geom::Coordinate& pt);
 
 protected:
 
-	void visitLinkedDirectedEdges(geomgraph::DirectedEdge *start);
+    void visitLinkedDirectedEdges(geomgraph::DirectedEdge* start);
 
 private:
 
-	geom::GeometryFactory::Ptr geometryFactory;
-
-	geomgraph::GeometryGraph &geomGraph;
-
-	/// Save a coordinate for any disconnected interior found
-	/// the coordinate will be somewhere on the ring surrounding
-	/// the disconnected interior
-	geom::Coordinate disconnectedRingcoord;
-
-	/// Used to track MaximalEdgeRings allocations
-	std::vector<geomgraph::EdgeRing*> maximalEdgeRings;
-
-	void setInteriorEdgesInResult(geomgraph::PlanarGraph &graph);
-
-
-	/**
-	 * \brief
-	 * Form DirectedEdges in graph into Minimal EdgeRings.
-	 *
-	 * Minimal Edgerings must be used, because only they are
-	 * guaranteed to provide a correct isHole computation.
-	 *
-	 * @param minEdgeRings : newly allocated minimal edge rings will
-	 *                       be push_back'ed here.
-	 *                       deletion responsibility is left to caller.
-	 */
-	void buildEdgeRings(std::vector<geomgraph::EdgeEnd*> *dirEdges,
-	                    std::vector<geomgraph::EdgeRing*>& minEdgeRings);
-
-	/**
-	 * Mark all the edges for the edgeRings corresponding to the shells
-	 * of the input polygons.  Note only ONE ring gets marked for each shell.
-	 */
-	void visitShellInteriors(const geom::Geometry *g, geomgraph::PlanarGraph &graph);
-
-	void visitInteriorRing(const geom::LineString *ring, geomgraph::PlanarGraph &graph);
-
-	/**
-	 * Check if any shell ring has an unvisited edge.
-	 * A shell ring is a ring which is not a hole and which has the interior
-	 * of the parent area on the RHS.
-	 * (Note that there may be non-hole rings with the interior on the LHS,
-	 * since the interior of holes will also be polygonized into CW rings
-	 * by the linkAllDirectedEdges() step)
-	 *
-	 * @return true if there is an unvisited edge in a non-hole ring
-	 */
-	bool hasUnvisitedShellEdge(std::vector<geomgraph::EdgeRing*> *edgeRings);
+    geom::GeometryFactory::Ptr geometryFactory;
+
+    geomgraph::GeometryGraph& geomGraph;
+
+    /// Save a coordinate for any disconnected interior found
+    /// the coordinate will be somewhere on the ring surrounding
+    /// the disconnected interior
+    geom::Coordinate disconnectedRingcoord;
+
+    /// Used to track MaximalEdgeRings allocations
+    std::vector<geomgraph::EdgeRing*> maximalEdgeRings;
+
+    void setInteriorEdgesInResult(geomgraph::PlanarGraph& graph);
+
+
+    /**
+     * \brief
+     * Form DirectedEdges in graph into Minimal EdgeRings.
+     *
+     * Minimal Edgerings must be used, because only they are
+     * guaranteed to provide a correct isHole computation.
+     *
+     * @param minEdgeRings : newly allocated minimal edge rings will
+     *                       be push_back'ed here.
+     *                       deletion responsibility is left to caller.
+     */
+    void buildEdgeRings(std::vector<geomgraph::EdgeEnd*>* dirEdges,
+                        std::vector<geomgraph::EdgeRing*>& minEdgeRings);
+
+    /**
+     * Mark all the edges for the edgeRings corresponding to the shells
+     * of the input polygons.  Note only ONE ring gets marked for each shell.
+     */
+    void visitShellInteriors(const geom::Geometry* g, geomgraph::PlanarGraph& graph);
+
+    void visitInteriorRing(const geom::LineString* ring, geomgraph::PlanarGraph& graph);
+
+    /**
+     * Check if any shell ring has an unvisited edge.
+     * A shell ring is a ring which is not a hole and which has the interior
+     * of the parent area on the RHS.
+     * (Note that there may be non-hole rings with the interior on the LHS,
+     * since the interior of holes will also be polygonized into CW rings
+     * by the linkAllDirectedEdges() step)
+     *
+     * @return true if there is an unvisited edge in a non-hole ring
+     */
+    bool hasUnvisitedShellEdge(std::vector<geomgraph::EdgeRing*>* edgeRings);
 
     // Declare type as noncopyable
     ConnectedInteriorTester(const ConnectedInteriorTester& other) = delete;
diff --git a/include/geos/operation/valid/ConsistentAreaTester.h b/include/geos/operation/valid/ConsistentAreaTester.h
index d02fc4c..ac31408 100644
--- a/include/geos/operation/valid/ConsistentAreaTester.h
+++ b/include/geos/operation/valid/ConsistentAreaTester.h
@@ -28,17 +28,17 @@
 
 // Forward declarations
 namespace geos {
-	namespace algorithm {
-		class LineIntersector;
-	}
-	namespace geomgraph {
-		class GeometryGraph;
-	}
-	namespace operation {
-		namespace relate {
-			class RelateNodeGraph;
-		}
-	}
+namespace algorithm {
+class LineIntersector;
+}
+namespace geomgraph {
+class GeometryGraph;
+}
+namespace operation {
+namespace relate {
+class RelateNodeGraph;
+}
+}
 }
 
 namespace geos {
@@ -83,65 +83,65 @@ namespace valid { // geos::operation::valid
 class GEOS_DLL ConsistentAreaTester {
 private:
 
-	algorithm::LineIntersector li;
+    algorithm::LineIntersector li;
 
-	/// Not owned
-	geomgraph::GeometryGraph *geomGraph;
+    /// Not owned
+    geomgraph::GeometryGraph* geomGraph;
 
-	relate::RelateNodeGraph nodeGraph;
+    relate::RelateNodeGraph nodeGraph;
 
-	/// the intersection point found (if any)
-	geom::Coordinate invalidPoint;
+    /// the intersection point found (if any)
+    geom::Coordinate invalidPoint;
 
-	/**
-	 * Check all nodes to see if their labels are consistent.
-	 * If any are not, return false
-	 */
-	bool isNodeEdgeAreaLabelsConsistent();
+    /**
+     * Check all nodes to see if their labels are consistent.
+     * If any are not, return false
+     */
+    bool isNodeEdgeAreaLabelsConsistent();
 
 public:
 
-	/**
-	 * Creates a new tester for consistent areas.
-	 *
-	 * @param geomGraph the topology graph of the area geometry.
-	 *                  Caller keeps responsibility for its deletion
-	 */
-	ConsistentAreaTester(geomgraph::GeometryGraph *newGeomGraph);
-
-	~ConsistentAreaTester();
-
-	/**
-	 * @return the intersection point, or <code>null</code>
-	 *         if none was found
-	 */
-	geom::Coordinate& getInvalidPoint();
-
-	/** \brief
-	 * Check all nodes to see if their labels are consistent with
-	 * area topology.
-	 *
-	 * @return <code>true</code> if this area has a consistent node
-	 *         labelling
-	 */
-	bool isNodeConsistentArea();
-
-	/**
-	 * Checks for two duplicate rings in an area.
-	 * Duplicate rings are rings that are topologically equal
-	 * (that is, which have the same sequence of points up to point order).
-	 * If the area is topologically consistent (determined by calling the
-	 * <code>isNodeConsistentArea</code>,
-	 * duplicate rings can be found by checking for EdgeBundles which contain
-	 * more than one geomgraph::EdgeEnd.
-	 * (This is because topologically consistent areas cannot have two rings sharing
-	 * the same line segment, unless the rings are equal).
-	 * The start point of one of the equal rings will be placed in
-	 * invalidPoint.
-	 *
-	 * @return true if this area Geometry is topologically consistent but has two duplicate rings
-	 */
-	bool hasDuplicateRings();
+    /**
+     * Creates a new tester for consistent areas.
+     *
+     * @param geomGraph the topology graph of the area geometry.
+     *                  Caller keeps responsibility for its deletion
+     */
+    ConsistentAreaTester(geomgraph::GeometryGraph* newGeomGraph);
+
+    ~ConsistentAreaTester();
+
+    /**
+     * @return the intersection point, or <code>null</code>
+     *         if none was found
+     */
+    geom::Coordinate& getInvalidPoint();
+
+    /** \brief
+     * Check all nodes to see if their labels are consistent with
+     * area topology.
+     *
+     * @return <code>true</code> if this area has a consistent node
+     *         labelling
+     */
+    bool isNodeConsistentArea();
+
+    /**
+     * Checks for two duplicate rings in an area.
+     * Duplicate rings are rings that are topologically equal
+     * (that is, which have the same sequence of points up to point order).
+     * If the area is topologically consistent (determined by calling the
+     * <code>isNodeConsistentArea</code>,
+     * duplicate rings can be found by checking for EdgeBundles which contain
+     * more than one geomgraph::EdgeEnd.
+     * (This is because topologically consistent areas cannot have two rings sharing
+     * the same line segment, unless the rings are equal).
+     * The start point of one of the equal rings will be placed in
+     * invalidPoint.
+     *
+     * @return true if this area Geometry is topologically consistent but has two duplicate rings
+     */
+    bool hasDuplicateRings();
 };
 
 
diff --git a/include/geos/operation/valid/IsValidOp.h b/include/geos/operation/valid/IsValidOp.h
index 09bb588..a4e3762 100644
--- a/include/geos/operation/valid/IsValidOp.h
+++ b/include/geos/operation/valid/IsValidOp.h
@@ -62,7 +62,7 @@ class GEOS_DLL IsValidOp {
     friend class Unload;
 private:
     /// the base Geometry to be validated
-    const geom::Geometry *parentGeometry;
+    const geom::Geometry* parentGeometry;
 
     bool isChecked;
 
@@ -72,14 +72,14 @@ private:
     // This is the version using 'isChecked' flag
     void checkValid();
 
-    void checkValid(const geom::Geometry *g);
-    void checkValid(const geom::Point *g);
-    void checkValid(const geom::LinearRing *g);
-    void checkValid(const geom::LineString *g);
-    void checkValid(const geom::Polygon *g);
-    void checkValid(const geom::MultiPolygon *g);
-    void checkValid(const geom::GeometryCollection *gc);
-    void checkConsistentArea(geomgraph::GeometryGraph *graph);
+    void checkValid(const geom::Geometry* g);
+    void checkValid(const geom::Point* g);
+    void checkValid(const geom::LinearRing* g);
+    void checkValid(const geom::LineString* g);
+    void checkValid(const geom::Polygon* g);
+    void checkValid(const geom::MultiPolygon* g);
+    void checkValid(const geom::GeometryCollection* gc);
+    void checkConsistentArea(geomgraph::GeometryGraph* graph);
 
 
     /**
@@ -90,7 +90,7 @@ private:
      *
      * @param graph the topology graph of the geometry
      */
-    void checkNoSelfIntersectingRings(geomgraph::GeometryGraph *graph);
+    void checkNoSelfIntersectingRings(geomgraph::GeometryGraph* graph);
 
     /**
      * check that a ring does not self-intersect, except at its endpoints.
@@ -99,9 +99,9 @@ private:
      * If any occur more than once, that must be a self-intersection.
      */
     void checkNoSelfIntersectingRing(
-        geomgraph::EdgeIntersectionList &eiList);
+        geomgraph::EdgeIntersectionList& eiList);
 
-    void checkTooFewPoints(geomgraph::GeometryGraph *graph);
+    void checkTooFewPoints(geomgraph::GeometryGraph* graph);
 
     /**
      * Test that each hole is inside the polygon shell.
@@ -114,8 +114,8 @@ private:
      * @param p the polygon to be tested for hole inclusion
      * @param graph a geomgraph::GeometryGraph incorporating the polygon
      */
-    void checkHolesInShell(const geom::Polygon *p,
-                           geomgraph::GeometryGraph *graph);
+    void checkHolesInShell(const geom::Polygon* p,
+                           geomgraph::GeometryGraph* graph);
 
     /**
      * Tests that no hole is nested inside another hole.
@@ -129,8 +129,8 @@ private:
      *    (checked by <code>checkRelateConsistency</code>)
      *
      */
-    void checkHolesNotNested(const geom::Polygon *p,
-                             geomgraph::GeometryGraph *graph);
+    void checkHolesNotNested(const geom::Polygon* p,
+                             geomgraph::GeometryGraph* graph);
 
     /**
      * Tests that no element polygon is wholly in the interior of another
@@ -146,8 +146,8 @@ private:
      * may touch at one or more vertices, they cannot touch at
      * ALL vertices.
      */
-    void checkShellsNotNested(const geom::MultiPolygon *mp,
-                              geomgraph::GeometryGraph *graph);
+    void checkShellsNotNested(const geom::MultiPolygon* mp,
+                              geomgraph::GeometryGraph* graph);
 
     /**
      * Check if a shell is incorrectly nested within a polygon.
@@ -160,9 +160,9 @@ private:
      * E.g. they cannot partially overlap (this has been previously
      * checked by <code>checkRelateConsistency</code>
      */
-    void checkShellNotNested(const geom::LinearRing *shell,
-                             const geom::Polygon *p,
-                             geomgraph::GeometryGraph *graph);
+    void checkShellNotNested(const geom::LinearRing* shell,
+                             const geom::Polygon* p,
+                             geomgraph::GeometryGraph* graph);
 
     /**
      * This routine checks to see if a shell is properly contained
@@ -174,20 +174,20 @@ private:
      *   a Coordinate which is not inside the hole if it is not
      *
      */
-    const geom::Coordinate *checkShellInsideHole(
-        const geom::LinearRing *shell,
-        const geom::LinearRing *hole,
-        geomgraph::GeometryGraph *graph);
+    const geom::Coordinate* checkShellInsideHole(
+        const geom::LinearRing* shell,
+        const geom::LinearRing* hole,
+        geomgraph::GeometryGraph* graph);
 
-    void checkConnectedInteriors(geomgraph::GeometryGraph &graph);
+    void checkConnectedInteriors(geomgraph::GeometryGraph& graph);
 
-    void checkInvalidCoordinates(const geom::CoordinateSequence *cs);
+    void checkInvalidCoordinates(const geom::CoordinateSequence* cs);
 
-    void checkInvalidCoordinates(const geom::Polygon *poly);
+    void checkInvalidCoordinates(const geom::Polygon* poly);
 
-    void checkClosedRings(const geom::Polygon *poly);
+    void checkClosedRings(const geom::Polygon* poly);
 
-    void checkClosedRing(const geom::LinearRing *ring);
+    void checkClosedRing(const geom::LinearRing* ring);
 
     bool isSelfTouchingRingFormingHoleValid;
 
@@ -198,10 +198,10 @@ public:
      *
      * @return the point found, or NULL if none found
      */
-    static const geom::Coordinate *findPtNotNode(
-        const geom::CoordinateSequence *testCoords,
-        const geom::LinearRing *searchRing,
-        geomgraph::GeometryGraph *graph);
+    static const geom::Coordinate* findPtNotNode(
+        const geom::CoordinateSequence* testCoords,
+        const geom::LinearRing* searchRing,
+        geomgraph::GeometryGraph* graph);
 
     /**
      * Checks whether a coordinate is valid for processing.
@@ -211,7 +211,7 @@ public:
      * @param coord the coordinate to validate
      * @return <code>true</code> if the coordinate is valid
      */
-    static bool isValid(const geom::Coordinate &coord);
+    static bool isValid(const geom::Coordinate& coord);
 
     /**
      * Tests whether a {@link Geometry} is valid.
@@ -219,9 +219,9 @@ public:
      * @param geom the Geometry to test
      * @return true if the geometry is valid
      */
-    static bool isValid(const geom::Geometry &geom);
+    static bool isValid(const geom::Geometry& geom);
 
-    IsValidOp(const geom::Geometry *geom)
+    IsValidOp(const geom::Geometry* geom)
         :
         parentGeometry(geom),
         isChecked(false),
@@ -230,7 +230,8 @@ public:
     {}
 
     /// TODO: validErr can't be a pointer!
-    virtual ~IsValidOp()
+    virtual
+    ~IsValidOp()
     {
         delete validErr;
     }
@@ -265,7 +266,8 @@ public:
      *
      * @param isValid states whether geometry with this condition is valid
      */
-    void setSelfTouchingRingFormingHoleValid(bool p_isValid)
+    void
+    setSelfTouchingRingFormingHoleValid(bool p_isValid)
     {
         isSelfTouchingRingFormingHoleValid = p_isValid;
     }
diff --git a/include/geos/operation/valid/QuadtreeNestedRingTester.h b/include/geos/operation/valid/QuadtreeNestedRingTester.h
index 3eaee53..698a64a 100644
--- a/include/geos/operation/valid/QuadtreeNestedRingTester.h
+++ b/include/geos/operation/valid/QuadtreeNestedRingTester.h
@@ -33,18 +33,18 @@
 
 // Forward declarations
 namespace geos {
-	namespace geom {
-		class LinearRing;
-		class Coordinate;
-	}
-	namespace index {
-		namespace quadtree {
-			class Quadtree;
-		}
-	}
-	namespace geomgraph {
-		class GeometryGraph;
-	}
+namespace geom {
+class LinearRing;
+class Coordinate;
+}
+namespace index {
+namespace quadtree {
+class Quadtree;
+}
+}
+namespace geomgraph {
+class GeometryGraph;
+}
 }
 
 namespace geos {
@@ -60,36 +60,36 @@ namespace valid { // geos::operation::valid
 class GEOS_DLL QuadtreeNestedRingTester {
 public:
 
-	/// Caller retains ownership of GeometryGraph
-	QuadtreeNestedRingTester(geomgraph::GeometryGraph* newGraph);
+    /// Caller retains ownership of GeometryGraph
+    QuadtreeNestedRingTester(geomgraph::GeometryGraph* newGraph);
 
-	~QuadtreeNestedRingTester();
+    ~QuadtreeNestedRingTester();
 
-	/*
-	 * Be aware that the returned Coordinate (if != NULL)
-	 * will point to storage owned by one of the LinearRing
-	 * previously added. If you destroy them, this
-	 * will point to an invalid memory address.
-	 */
-	geom::Coordinate* getNestedPoint();
+    /*
+     * Be aware that the returned Coordinate (if != NULL)
+     * will point to storage owned by one of the LinearRing
+     * previously added. If you destroy them, this
+     * will point to an invalid memory address.
+     */
+    geom::Coordinate* getNestedPoint();
 
-	void add(const geom::LinearRing* ring);
+    void add(const geom::LinearRing* ring);
 
-	bool isNonNested();
+    bool isNonNested();
 
 private:
 
-	geomgraph::GeometryGraph* graph;  // used to find non-node vertices
+    geomgraph::GeometryGraph* graph;  // used to find non-node vertices
 
-	std::vector<const geom::LinearRing*> rings;
+    std::vector<const geom::LinearRing*> rings;
 
-	geom::Envelope totalEnv;
+    geom::Envelope totalEnv;
 
-	index::quadtree::Quadtree* qt;
+    index::quadtree::Quadtree* qt;
 
-	geom::Coordinate* nestedPt;
+    geom::Coordinate* nestedPt;
 
-	void buildQuadtree();
+    void buildQuadtree();
 };
 
 } // namespace geos::operation::valid
diff --git a/include/geos/operation/valid/RepeatedPointTester.h b/include/geos/operation/valid/RepeatedPointTester.h
index 7901677..5abefe6 100644
--- a/include/geos/operation/valid/RepeatedPointTester.h
+++ b/include/geos/operation/valid/RepeatedPointTester.h
@@ -26,15 +26,15 @@
 
 // Forward declarations
 namespace geos {
-	namespace geom {
-		//class Coordinate;
-		class CoordinateSequence;
-		class Geometry;
-		class Polygon;
-		class MultiPolygon;
-		class MultiLineString;
-		class GeometryCollection;
-	}
+namespace geom {
+//class Coordinate;
+class CoordinateSequence;
+class Geometry;
+class Polygon;
+class MultiPolygon;
+class MultiLineString;
+class GeometryCollection;
+}
 }
 
 namespace geos {
@@ -48,16 +48,16 @@ namespace valid { // geos::operation::valid
  */
 class GEOS_DLL RepeatedPointTester {
 public:
-	RepeatedPointTester() {}
-	geom::Coordinate& getCoordinate();
-	bool hasRepeatedPoint(const geom::Geometry *g);
-	bool hasRepeatedPoint(const geom::CoordinateSequence *coord);
+    RepeatedPointTester() {}
+    geom::Coordinate& getCoordinate();
+    bool hasRepeatedPoint(const geom::Geometry* g);
+    bool hasRepeatedPoint(const geom::CoordinateSequence* coord);
 private:
-	geom::Coordinate repeatedCoord;
-	bool hasRepeatedPoint(const geom::Polygon *p);
-	bool hasRepeatedPoint(const geom::GeometryCollection *gc);
-	bool hasRepeatedPoint(const geom::MultiPolygon *gc);
-	bool hasRepeatedPoint(const geom::MultiLineString *gc);
+    geom::Coordinate repeatedCoord;
+    bool hasRepeatedPoint(const geom::Polygon* p);
+    bool hasRepeatedPoint(const geom::GeometryCollection* gc);
+    bool hasRepeatedPoint(const geom::MultiPolygon* gc);
+    bool hasRepeatedPoint(const geom::MultiLineString* gc);
 };
 
 
diff --git a/include/geos/operation/valid/SimpleNestedRingTester.h b/include/geos/operation/valid/SimpleNestedRingTester.h
index 2ec3e4b..d6d7de1 100644
--- a/include/geos/operation/valid/SimpleNestedRingTester.h
+++ b/include/geos/operation/valid/SimpleNestedRingTester.h
@@ -32,13 +32,13 @@
 
 // Forward declarations
 namespace geos {
-	namespace geom {
-		class Coordinate;
-		class LinearRing;
-	}
-	namespace geomgraph {
-		class GeometryGraph;
-	}
+namespace geom {
+class Coordinate;
+class LinearRing;
+}
+namespace geomgraph {
+class GeometryGraph;
+}
 }
 
 namespace geos {
@@ -53,35 +53,40 @@ namespace valid { // geos::operation::valid
  */
 class GEOS_DLL SimpleNestedRingTester {
 private:
-	geomgraph::GeometryGraph *graph;  // used to find non-node vertices
-	std::vector<geom::LinearRing*> rings;
-	geom::Coordinate *nestedPt;
+    geomgraph::GeometryGraph* graph;  // used to find non-node vertices
+    std::vector<geom::LinearRing*> rings;
+    geom::Coordinate* nestedPt;
 public:
-	SimpleNestedRingTester(geomgraph::GeometryGraph *newGraph)
-		:
-		graph(newGraph),
-		rings(),
-		nestedPt(nullptr)
-	{}
+    SimpleNestedRingTester(geomgraph::GeometryGraph* newGraph)
+        :
+        graph(newGraph),
+        rings(),
+        nestedPt(nullptr)
+    {}
 
-	~SimpleNestedRingTester() {
-	}
+    ~SimpleNestedRingTester()
+    {
+    }
 
-	void add(geom::LinearRing *ring) {
-		rings.push_back(ring);
-	}
+    void
+    add(geom::LinearRing* ring)
+    {
+        rings.push_back(ring);
+    }
 
-	/*
-	 * Be aware that the returned Coordinate (if != NULL)
-	 * will point to storage owned by one of the LinearRing
-	 * previously added. If you destroy them, this
-	 * will point to an invalid memory address.
-	 */
-	geom::Coordinate *getNestedPoint() {
-		return nestedPt;
-	}
+    /*
+     * Be aware that the returned Coordinate (if != NULL)
+     * will point to storage owned by one of the LinearRing
+     * previously added. If you destroy them, this
+     * will point to an invalid memory address.
+     */
+    geom::Coordinate*
+    getNestedPoint()
+    {
+        return nestedPt;
+    }
 
-	bool isNonNested();
+    bool isNonNested();
 };
 
 } // namespace geos.operation.valid
diff --git a/include/geos/operation/valid/SweeplineNestedRingTester.h b/include/geos/operation/valid/SweeplineNestedRingTester.h
index 86e21f6..71ba081 100644
--- a/include/geos/operation/valid/SweeplineNestedRingTester.h
+++ b/include/geos/operation/valid/SweeplineNestedRingTester.h
@@ -35,19 +35,19 @@
 
 // Forward declarations
 namespace geos {
-	namespace geom {
-		class LinearRing;
-		class Envelope;
-		class Coordinate;
-	}
-	namespace index {
-		namespace sweepline {
-			class SweepLineIndex;
-		}
-	}
-	namespace geomgraph {
-		class GeometryGraph;
-	}
+namespace geom {
+class LinearRing;
+class Envelope;
+class Coordinate;
+}
+namespace index {
+namespace sweepline {
+class SweepLineIndex;
+}
+}
+namespace geomgraph {
+class GeometryGraph;
+}
 }
 
 namespace geos {
@@ -62,50 +62,56 @@ namespace valid { // geos::operation::valid
 class GEOS_DLL SweeplineNestedRingTester {
 
 private:
-	geomgraph::GeometryGraph *graph;  // used to find non-node vertices
-	std::vector<geom::LinearRing*> rings;
-	index::sweepline::SweepLineIndex *sweepLine;
-	geom::Coordinate *nestedPt;
-	void buildIndex();
+    geomgraph::GeometryGraph* graph;  // used to find non-node vertices
+    std::vector<geom::LinearRing*> rings;
+    index::sweepline::SweepLineIndex* sweepLine;
+    geom::Coordinate* nestedPt;
+    void buildIndex();
 
 public:
 
-	SweeplineNestedRingTester(geomgraph::GeometryGraph *newGraph)
-		:
-		graph(newGraph),
-		rings(),
-		sweepLine(new index::sweepline::SweepLineIndex()),
-		nestedPt(nullptr)
-	{}
-
-	~SweeplineNestedRingTester()
-	{
-		delete sweepLine;
-	}
-
-	/*
-	 * Be aware that the returned Coordinate (if != NULL)
-	 * will point to storage owned by one of the LinearRing
-	 * previously added. If you destroy them, this
-	 * will point to an invalid memory address.
-	 */
-	geom::Coordinate *getNestedPoint() { return nestedPt; }
-
-	void add(geom::LinearRing* ring) {
-		rings.push_back(ring);
-	}
-
-	bool isNonNested();
-	bool isInside(geom::LinearRing *innerRing, geom::LinearRing *searchRing);
-	class OverlapAction: public index::sweepline::SweepLineOverlapAction {
-	public:
-		bool isNonNested;
-		OverlapAction(SweeplineNestedRingTester *p);
-		void overlap(index::sweepline::SweepLineInterval *s0,
-				index::sweepline::SweepLineInterval *s1) override;
-	private:
-		SweeplineNestedRingTester *parent;
-	};
+    SweeplineNestedRingTester(geomgraph::GeometryGraph* newGraph)
+        :
+        graph(newGraph),
+        rings(),
+        sweepLine(new index::sweepline::SweepLineIndex()),
+        nestedPt(nullptr)
+    {}
+
+    ~SweeplineNestedRingTester()
+    {
+        delete sweepLine;
+    }
+
+    /*
+     * Be aware that the returned Coordinate (if != NULL)
+     * will point to storage owned by one of the LinearRing
+     * previously added. If you destroy them, this
+     * will point to an invalid memory address.
+     */
+    geom::Coordinate*
+    getNestedPoint()
+    {
+        return nestedPt;
+    }
+
+    void
+    add(geom::LinearRing* ring)
+    {
+        rings.push_back(ring);
+    }
+
+    bool isNonNested();
+    bool isInside(geom::LinearRing* innerRing, geom::LinearRing* searchRing);
+    class OverlapAction: public index::sweepline::SweepLineOverlapAction {
+    public:
+        bool isNonNested;
+        OverlapAction(SweeplineNestedRingTester* p);
+        void overlap(index::sweepline::SweepLineInterval* s0,
+                     index::sweepline::SweepLineInterval* s1) override;
+    private:
+        SweeplineNestedRingTester* parent;
+    };
 };
 
 } // namespace geos::operation::valid
diff --git a/include/geos/operation/valid/TopologyValidationError.h b/include/geos/operation/valid/TopologyValidationError.h
index 9e2048b..f290899 100644
--- a/include/geos/operation/valid/TopologyValidationError.h
+++ b/include/geos/operation/valid/TopologyValidationError.h
@@ -40,33 +40,33 @@ namespace valid { // geos::operation::valid
 class GEOS_DLL TopologyValidationError {
 public:
 
-	enum errorEnum {
-		eError,
-		eRepeatedPoint,
-		eHoleOutsideShell,
-		eNestedHoles,
-		eDisconnectedInterior,
-		eSelfIntersection,
-		eRingSelfIntersection,
-		eNestedShells,
-		eDuplicatedRings,
-		eTooFewPoints,
-		eInvalidCoordinate,
-		eRingNotClosed
-	};
+    enum errorEnum {
+        eError,
+        eRepeatedPoint,
+        eHoleOutsideShell,
+        eNestedHoles,
+        eDisconnectedInterior,
+        eSelfIntersection,
+        eRingSelfIntersection,
+        eNestedShells,
+        eDuplicatedRings,
+        eTooFewPoints,
+        eInvalidCoordinate,
+        eRingNotClosed
+    };
 
-	TopologyValidationError(int newErrorType, const geom::Coordinate& newPt);
-	TopologyValidationError(int newErrorType);
-	geom::Coordinate& getCoordinate();
-	std::string getMessage();
-	int getErrorType();
-	std::string toString();
+    TopologyValidationError(int newErrorType, const geom::Coordinate& newPt);
+    TopologyValidationError(int newErrorType);
+    geom::Coordinate& getCoordinate();
+    std::string getMessage();
+    int getErrorType();
+    std::string toString();
 
 private:
-	// Used const char* to reduce dynamic allocations
-	static const char* errMsg[];
-	int errorType;
-	geom::Coordinate pt;
+    // Used const char* to reduce dynamic allocations
+    static const char* errMsg[];
+    int errorType;
+    geom::Coordinate pt;
 };
 
 
diff --git a/include/geos/planargraph/DirectedEdge.h b/include/geos/planargraph/DirectedEdge.h
index 25944ec..cb08f3b 100644
--- a/include/geos/planargraph/DirectedEdge.h
+++ b/include/geos/planargraph/DirectedEdge.h
@@ -25,10 +25,10 @@
 
 // Forward declarations
 namespace geos {
-	namespace planargraph {
-		class Edge;
-		class Node;
-	}
+namespace planargraph {
+class Edge;
+class Node;
+}
 }
 
 namespace geos {
@@ -47,185 +47,185 @@ class GEOS_DLL DirectedEdge: public GraphComponent {
 
 public:
 
-  friend std::ostream& operator << (std::ostream&, const DirectedEdge&);
+    friend std::ostream& operator << (std::ostream&, const DirectedEdge&);
 
-	typedef std::list<DirectedEdge *> NonConstList;
-	typedef std::list<const DirectedEdge *> ConstList;
-	typedef std::vector<DirectedEdge *> NonConstVect;
+    typedef std::list<DirectedEdge*> NonConstList;
+    typedef std::list<const DirectedEdge*> ConstList;
+    typedef std::vector<DirectedEdge*> NonConstVect;
 
 protected:
-	Edge* parentEdge;
-	Node* from;
-	Node* to;
-	geom::Coordinate p0, p1;
-	DirectedEdge* sym;  // optional
-	bool edgeDirection;
-	int quadrant;
-	double angle;
+    Edge* parentEdge;
+    Node* from;
+    Node* to;
+    geom::Coordinate p0, p1;
+    DirectedEdge* sym;  // optional
+    bool edgeDirection;
+    int quadrant;
+    double angle;
 public:
 
-	typedef std::vector<const DirectedEdge *> ConstVect;
-	typedef std::vector<DirectedEdge *> Vect;
-
-	/**
-	 * \brief
-	 * Returns a List containing the parent Edge (possibly null)
-	 * for each of the given DirectedEdges.
-	 *
-	 * NOTE: ownership of the returned vector is left to
-	 * the caller, see the equivalent function taking a vector
-	 * reference to avoid this.
-	 */
-	static std::vector<Edge*>* toEdges(
-		std::vector<DirectedEdge*>& dirEdges);
-
-	/**
-	 * \brief
-	 * Add parent Edge (possibly null) of each of the given DirectedEdges
-	 * to the given parentEdges vector.
-	 *
-	 * NOTE: parents are pushed to the parentEdges vector, make sure
-	 * it is empty if index-based corrispondence is important.
-	 */
-	static void toEdges( std::vector<DirectedEdge*>& dirEdges,
-			std::vector<Edge*>& parentEdges);
-
-	/**
-	 * \brief Constructs a DirectedEdge connecting the <code>from</code>
-	 * node to the <code>to</code> node.
-	 *
-	 * @param directionPt specifies this DirectedEdge's direction
-	 *                    (given by an imaginary line from the
-	 *		      <code>from</code> node to
-	 *		      <code>directionPt</code>)
-	 * @param edgeDirection whether this DirectedEdge's direction
-	 *		       is the same as or opposite to that of the
-	 *		       parent Edge (if any)
-	 */
-	DirectedEdge(Node *newFrom, Node *newTo,
-			const geom::Coordinate &directionPt,
-			bool newEdgeDirection);
-
-	/**
-	 * \brief Returns this DirectedEdge's parent Edge,
-	 * or null if it has none.
-	 */
-	Edge* getEdge() const;
-
-	/**
-	 * \brief Associates this DirectedEdge with an Edge
-	 * (possibly null, indicating no associated Edge).
-	 */
-	void setEdge(Edge* newParentEdge);
-
-	/**
-	 * \brief Returns 0, 1, 2, or 3, indicating the quadrant in which
-	 * this DirectedEdge's orientation lies.
-	 */
-	int getQuadrant() const;
-
-	/**
-	 * \brief Returns a point to which an imaginary line is drawn
-	 * from the from-node to specify this DirectedEdge's orientation.
-	 */
-	const geom::Coordinate& getDirectionPt() const;
-
-	/**
-	 * \brief Returns whether the direction of the parent Edge (if any)
-	 * is the same as that of this Directed Edge.
-	 */
-	bool getEdgeDirection() const;
-
-	/**
-	 * \brief Returns the node from which this DirectedEdge leaves.
-	 */
-	Node* getFromNode() const;
-
-	/**
-	 * \brief Returns the node to which this DirectedEdge goes.
-	 */
-	Node* getToNode() const;
-
-	/**
-	 * \brief
-	 * Returns the coordinate of the from-node.
-	 */
-	geom::Coordinate& getCoordinate() const;
-
-	/**
-	 * \brief
-	 * Returns the angle that the start of this DirectedEdge makes
-	 * with the positive x-axis, in radians.
-	 */
-	double getAngle() const;
-
-	/**
-	 * \brief
-	 * Returns the symmetric DirectedEdge -- the other DirectedEdge
-	 * associated with this DirectedEdge's parent Edge.
-	 */
-	DirectedEdge* getSym() const;
-
-	/**
-	 * \brief
-	 * Sets this DirectedEdge's symmetric DirectedEdge, which runs
-	 * in the opposite direction.
-	 */
-	void setSym(DirectedEdge *newSym);
-
-	/**
-	 * \brief
-	 * Returns 1 if this DirectedEdge has a greater angle with the
-	 * positive x-axis than b", 0 if the DirectedEdges are collinear,
-	 * and -1 otherwise.
-	 *
-	 * Using the obvious algorithm of simply computing the angle is
-	 * not robust, since the angle calculation is susceptible to roundoff.
-	 * A robust algorithm is:
-	 *
-	 * - first compare the quadrants.
-	 *   If the quadrants are different, it it
-	 *   trivial to determine which std::vector is "greater".
-	 * - if the vectors lie in the same quadrant, the robust
-	 *   Orientation::index(Coordinate, Coordinate, Coordinate)
-	 *   function can be used to decide the relative orientation of
-	 *   the vectors.
-	 *
-	 */
-	int compareTo(const DirectedEdge* obj) const;
-
-	/**
-	 * \brief
-	 * Returns 1 if this DirectedEdge has a greater angle with the
-	 * positive x-axis than b", 0 if the DirectedEdges are collinear,
-	 * and -1 otherwise.
-	 *
-	 * Using the obvious algorithm of simply computing the angle is
-	 * not robust, since the angle calculation is susceptible to roundoff.
-	 * A robust algorithm is:
-	 *
-	 * - first compare the quadrants.
-	 *   If the quadrants are different, it it trivial to determine
-	 *   which std::vector is "greater".
-	 * - if the vectors lie in the same quadrant, the robust
-	 *   Orientation::index(Coordinate, Coordinate, Coordinate)
-	 *   function can be used to decide the relative orientation of
-	 *   the vectors.
-	 *
-	 */
-	int compareDirection(const DirectedEdge *e) const;
-
-	/**
-	 * \brief
-	 * Prints a detailed string representation of this DirectedEdge
-	 * to the given PrintStream.
-	 */
-	std::string print() const;
+    typedef std::vector<const DirectedEdge*> ConstVect;
+    typedef std::vector<DirectedEdge*> Vect;
+
+    /**
+     * \brief
+     * Returns a List containing the parent Edge (possibly null)
+     * for each of the given DirectedEdges.
+     *
+     * NOTE: ownership of the returned vector is left to
+     * the caller, see the equivalent function taking a vector
+     * reference to avoid this.
+     */
+    static std::vector<Edge*>* toEdges(
+        std::vector<DirectedEdge*>& dirEdges);
+
+    /**
+     * \brief
+     * Add parent Edge (possibly null) of each of the given DirectedEdges
+     * to the given parentEdges vector.
+     *
+     * NOTE: parents are pushed to the parentEdges vector, make sure
+     * it is empty if index-based corrispondence is important.
+     */
+    static void toEdges(std::vector<DirectedEdge*>& dirEdges,
+                        std::vector<Edge*>& parentEdges);
+
+    /**
+     * \brief Constructs a DirectedEdge connecting the <code>from</code>
+     * node to the <code>to</code> node.
+     *
+     * @param directionPt specifies this DirectedEdge's direction
+     *                    (given by an imaginary line from the
+     *		      <code>from</code> node to
+     *		      <code>directionPt</code>)
+     * @param edgeDirection whether this DirectedEdge's direction
+     *		       is the same as or opposite to that of the
+     *		       parent Edge (if any)
+     */
+    DirectedEdge(Node* newFrom, Node* newTo,
+                 const geom::Coordinate& directionPt,
+                 bool newEdgeDirection);
+
+    /**
+     * \brief Returns this DirectedEdge's parent Edge,
+     * or null if it has none.
+     */
+    Edge* getEdge() const;
+
+    /**
+     * \brief Associates this DirectedEdge with an Edge
+     * (possibly null, indicating no associated Edge).
+     */
+    void setEdge(Edge* newParentEdge);
+
+    /**
+     * \brief Returns 0, 1, 2, or 3, indicating the quadrant in which
+     * this DirectedEdge's orientation lies.
+     */
+    int getQuadrant() const;
+
+    /**
+     * \brief Returns a point to which an imaginary line is drawn
+     * from the from-node to specify this DirectedEdge's orientation.
+     */
+    const geom::Coordinate& getDirectionPt() const;
+
+    /**
+     * \brief Returns whether the direction of the parent Edge (if any)
+     * is the same as that of this Directed Edge.
+     */
+    bool getEdgeDirection() const;
+
+    /**
+     * \brief Returns the node from which this DirectedEdge leaves.
+     */
+    Node* getFromNode() const;
+
+    /**
+     * \brief Returns the node to which this DirectedEdge goes.
+     */
+    Node* getToNode() const;
+
+    /**
+     * \brief
+     * Returns the coordinate of the from-node.
+     */
+    geom::Coordinate& getCoordinate() const;
+
+    /**
+     * \brief
+     * Returns the angle that the start of this DirectedEdge makes
+     * with the positive x-axis, in radians.
+     */
+    double getAngle() const;
+
+    /**
+     * \brief
+     * Returns the symmetric DirectedEdge -- the other DirectedEdge
+     * associated with this DirectedEdge's parent Edge.
+     */
+    DirectedEdge* getSym() const;
+
+    /**
+     * \brief
+     * Sets this DirectedEdge's symmetric DirectedEdge, which runs
+     * in the opposite direction.
+     */
+    void setSym(DirectedEdge* newSym);
+
+    /**
+     * \brief
+     * Returns 1 if this DirectedEdge has a greater angle with the
+     * positive x-axis than b", 0 if the DirectedEdges are collinear,
+     * and -1 otherwise.
+     *
+     * Using the obvious algorithm of simply computing the angle is
+     * not robust, since the angle calculation is susceptible to roundoff.
+     * A robust algorithm is:
+     *
+     * - first compare the quadrants.
+     *   If the quadrants are different, it it
+     *   trivial to determine which std::vector is "greater".
+     * - if the vectors lie in the same quadrant, the robust
+     *   Orientation::index(Coordinate, Coordinate, Coordinate)
+     *   function can be used to decide the relative orientation of
+     *   the vectors.
+     *
+     */
+    int compareTo(const DirectedEdge* obj) const;
+
+    /**
+     * \brief
+     * Returns 1 if this DirectedEdge has a greater angle with the
+     * positive x-axis than b", 0 if the DirectedEdges are collinear,
+     * and -1 otherwise.
+     *
+     * Using the obvious algorithm of simply computing the angle is
+     * not robust, since the angle calculation is susceptible to roundoff.
+     * A robust algorithm is:
+     *
+     * - first compare the quadrants.
+     *   If the quadrants are different, it it trivial to determine
+     *   which std::vector is "greater".
+     * - if the vectors lie in the same quadrant, the robust
+     *   Orientation::index(Coordinate, Coordinate, Coordinate)
+     *   function can be used to decide the relative orientation of
+     *   the vectors.
+     *
+     */
+    int compareDirection(const DirectedEdge* e) const;
+
+    /**
+     * \brief
+     * Prints a detailed string representation of this DirectedEdge
+     * to the given PrintStream.
+     */
+    std::string print() const;
 
 };
 
 /// Strict Weak comparator function for containers
-bool pdeLessThan(DirectedEdge *first, DirectedEdge * second);
+bool pdeLessThan(DirectedEdge* first, DirectedEdge* second);
 
 /// Output operator
 std::ostream& operator << (std::ostream&, const DirectedEdge&);
diff --git a/include/geos/planargraph/DirectedEdgeStar.h b/include/geos/planargraph/DirectedEdgeStar.h
index e1eca5d..919d316 100644
--- a/include/geos/planargraph/DirectedEdgeStar.h
+++ b/include/geos/planargraph/DirectedEdgeStar.h
@@ -27,13 +27,13 @@
 
 // Forward declarations
 namespace geos {
-	namespace geom {
-		class Coordinate;
-	}
-	namespace planargraph {
-		class DirectedEdge;
-		class Edge;
-	}
+namespace geom {
+class Coordinate;
+}
+namespace planargraph {
+class DirectedEdge;
+class Edge;
+}
 }
 
 namespace geos {
@@ -44,92 +44,101 @@ class GEOS_DLL DirectedEdgeStar {
 protected:
 
 private:
-	/**
-	 * \brief The underlying list of outgoing DirectedEdges
-	 */
-	mutable std::vector<DirectedEdge*> outEdges;
-	mutable bool sorted;
-	void sortEdges() const;
+    /**
+     * \brief The underlying list of outgoing DirectedEdges
+     */
+    mutable std::vector<DirectedEdge*> outEdges;
+    mutable bool sorted;
+    void sortEdges() const;
 
 public:
-	/**
-	 * \brief Constructs a DirectedEdgeStar with no edges.
-	 */
-	DirectedEdgeStar(): sorted(false) {}
-
-	virtual ~DirectedEdgeStar() {}
-
-	/**
-	 * \brief Adds a new member to this DirectedEdgeStar.
-	 */
-	void add(DirectedEdge *de);
-
-	/**
-	 * \brief Drops a member of this DirectedEdgeStar.
-	 */
-	void remove(DirectedEdge *de);
-
-	/**
-	 * \brief Returns an Iterator over the DirectedEdges,
-	 * in ascending order by angle with the positive x-axis.
-	 */
-	std::vector<DirectedEdge*>::iterator iterator() { return begin(); }
-	/// Returns an iterator to first DirectedEdge
-	std::vector<DirectedEdge*>::iterator begin();
-
-	/// Returns an iterator to one-past last DirectedEdge
-	std::vector<DirectedEdge*>::iterator end();
-
-	/// Returns an const_iterator to first DirectedEdge
-	std::vector<DirectedEdge*>::const_iterator begin() const;
-
-	/// Returns an const_iterator to one-past last DirectedEdge
-	std::vector<DirectedEdge*>::const_iterator end() const;
-
-	/**
-	 * \brief Returns the number of edges around the Node associated
-	 * with this DirectedEdgeStar.
-	 */
-	 std::size_t getDegree() const { return outEdges.size(); }
-
-	/**
-	 * \brief Returns the coordinate for the node at wich this
-	 * star is based
-	 */
-	geom::Coordinate& getCoordinate() const;
-
-	/**
-	 * \brief Returns the DirectedEdges, in ascending order
-	 * by angle with the positive x-axis.
-	 */
-	std::vector<DirectedEdge*>& getEdges();
-
-	/**
-	 * \brief Returns the zero-based index of the given Edge,
-	 * after sorting in ascending order by angle with the
-	 * positive x-axis.
-	 */
-	int getIndex(const Edge *edge);
-
-	/**
-	 * \brief Returns the zero-based index of the given DirectedEdge,
-	 * after sorting in ascending order
-	 * by angle with the positive x-axis.
-	 */
-	int getIndex(const DirectedEdge *dirEdge);
-
-	/**
-	 * \brief Returns the remainder when i is divided by the number of
-	 * edges in this DirectedEdgeStar.
-	 */
-	int getIndex(int i) const;
-
-	/**
-	 * \brief Returns the DirectedEdge on the left-hand side
-	 * of the given DirectedEdge (which must be a member of this
-	 * DirectedEdgeStar).
-	 */
-	DirectedEdge* getNextEdge(DirectedEdge *dirEdge);
+    /**
+     * \brief Constructs a DirectedEdgeStar with no edges.
+     */
+    DirectedEdgeStar(): sorted(false) {}
+
+    virtual
+    ~DirectedEdgeStar() {}
+
+    /**
+     * \brief Adds a new member to this DirectedEdgeStar.
+     */
+    void add(DirectedEdge* de);
+
+    /**
+     * \brief Drops a member of this DirectedEdgeStar.
+     */
+    void remove(DirectedEdge* de);
+
+    /**
+     * \brief Returns an Iterator over the DirectedEdges,
+     * in ascending order by angle with the positive x-axis.
+     */
+    std::vector<DirectedEdge*>::iterator
+    iterator()
+    {
+        return begin();
+    }
+    /// Returns an iterator to first DirectedEdge
+    std::vector<DirectedEdge*>::iterator begin();
+
+    /// Returns an iterator to one-past last DirectedEdge
+    std::vector<DirectedEdge*>::iterator end();
+
+    /// Returns an const_iterator to first DirectedEdge
+    std::vector<DirectedEdge*>::const_iterator begin() const;
+
+    /// Returns an const_iterator to one-past last DirectedEdge
+    std::vector<DirectedEdge*>::const_iterator end() const;
+
+    /**
+     * \brief Returns the number of edges around the Node associated
+     * with this DirectedEdgeStar.
+     */
+    std::size_t
+    getDegree() const
+    {
+        return outEdges.size();
+    }
+
+    /**
+     * \brief Returns the coordinate for the node at wich this
+     * star is based
+     */
+    geom::Coordinate& getCoordinate() const;
+
+    /**
+     * \brief Returns the DirectedEdges, in ascending order
+     * by angle with the positive x-axis.
+     */
+    std::vector<DirectedEdge*>& getEdges();
+
+    /**
+     * \brief Returns the zero-based index of the given Edge,
+     * after sorting in ascending order by angle with the
+     * positive x-axis.
+     */
+    int getIndex(const Edge* edge);
+
+    /**
+     * \brief Returns the zero-based index of the given DirectedEdge,
+     * after sorting in ascending order
+     * by angle with the positive x-axis.
+     */
+    int getIndex(const DirectedEdge* dirEdge);
+
+    /**
+     * \brief Returns the remainder when i is divided by the number of
+     * edges in this DirectedEdgeStar.
+     */
+    int getIndex(int i) const;
+
+    /**
+     * \brief Returns the DirectedEdge on the left-hand side
+     * of the given DirectedEdge (which must be a member of this
+     * DirectedEdgeStar).
+     */
+    DirectedEdge* getNextEdge(DirectedEdge* dirEdge);
 };
 
 } // namespace geos::planargraph
diff --git a/include/geos/planargraph/Edge.h b/include/geos/planargraph/Edge.h
index e16c7b3..089b3df 100644
--- a/include/geos/planargraph/Edge.h
+++ b/include/geos/planargraph/Edge.h
@@ -31,12 +31,12 @@
 
 // Forward declarations
 namespace geos {
-	namespace planargraph {
-		class DirectedEdgeStar;
-		class DirectedEdge;
-		class Edge;
-		class Node;
-	}
+namespace planargraph {
+class DirectedEdgeStar;
+class DirectedEdge;
+class Edge;
+class Node;
+}
 }
 
 namespace geos {
@@ -55,82 +55,82 @@ class GEOS_DLL Edge: public GraphComponent {
 
 public:
 
-	friend std::ostream& operator<< (std::ostream& os, const Node&);
+    friend std::ostream& operator<< (std::ostream& os, const Node&);
 
-	/// Set of const Edges pointers
-	typedef std::set<const Edge *> ConstSet;
+    /// Set of const Edges pointers
+    typedef std::set<const Edge*> ConstSet;
 
-	/// Set of non-const Edges pointers
-	typedef std::set<Edge *> NonConstSet;
+    /// Set of non-const Edges pointers
+    typedef std::set<Edge*> NonConstSet;
 
-	/// Vector of non-const Edges pointers
-	typedef std::vector<Edge *> NonConstVect;
+    /// Vector of non-const Edges pointers
+    typedef std::vector<Edge*> NonConstVect;
 
-	/// Vector of const Edges pointers
-	typedef std::vector<const Edge *> ConstVect;
+    /// Vector of const Edges pointers
+    typedef std::vector<const Edge*> ConstVect;
 
 protected:
 
-	/** \brief The two DirectedEdges associated with this Edge */
-	std::vector<DirectedEdge*> dirEdge;
+    /** \brief The two DirectedEdges associated with this Edge */
+    std::vector<DirectedEdge*> dirEdge;
 
-	/**
-	 * \brief Constructs an Edge whose DirectedEdges are not yet set.
-	 *
-	 * Be sure to call setDirectedEdges(DirectedEdge, DirectedEdge)
-	 */
+    /**
+     * \brief Constructs an Edge whose DirectedEdges are not yet set.
+     *
+     * Be sure to call setDirectedEdges(DirectedEdge, DirectedEdge)
+     */
 
 public:
 
-	/** \brief
-	 * Constructs a Edge whose DirectedEdges are
-	 * not yet set.
-	 *
-	 * Be sure to call
-	 * {@link setDirectedEdges(DirectedEdge, DirectedEdge)}
-	 */
-	Edge(): dirEdge() {}
-
-	/**
-	 * \brief Constructs an Edge initialized with the given DirectedEdges.
-	 *
-	 * For  each DirectedEdge: sets the Edge, sets the symmetric
-	 * DirectedEdge, and adds this Edge to its from-Node.
-	 */
-	Edge(DirectedEdge *de0, DirectedEdge *de1)
-		:
-		dirEdge()
-	{
-		setDirectedEdges(de0, de1);
-	}
-
-	/**
-	 * \brief Initializes this Edge's two DirectedEdges.
-	 *
-	 * For each DirectedEdge:
-	 *  sets the Edge, sets the symmetric DirectedEdge, and
-	 *  adds this Edge to its from-Node.
-	 */
-	void setDirectedEdges(DirectedEdge *de0, DirectedEdge *de1);
-
-	/**
-	 * \brief Returns one of the DirectedEdges associated with this Edge.
-	 * @param i 0 or 1
-	 */
-	DirectedEdge* getDirEdge(int i);
-
-	/**
-	 * \brief Returns the DirectedEdge that starts from the given node,
-	 * or null if the node is not one of the two nodes associated
-	 * with this Edge.
-	 */
-	DirectedEdge* getDirEdge(Node *fromNode);
-
-	/**
-	 * \brief If <code>node</code> is one of the two nodes associated
-	 * with this Edge, returns the other node; otherwise returns null.
-	 */
-	Node* getOppositeNode(Node *node);
+    /** \brief
+     * Constructs a Edge whose DirectedEdges are
+     * not yet set.
+     *
+     * Be sure to call
+     * {@link setDirectedEdges(DirectedEdge, DirectedEdge)}
+     */
+    Edge(): dirEdge() {}
+
+    /**
+     * \brief Constructs an Edge initialized with the given DirectedEdges.
+     *
+     * For  each DirectedEdge: sets the Edge, sets the symmetric
+     * DirectedEdge, and adds this Edge to its from-Node.
+     */
+    Edge(DirectedEdge* de0, DirectedEdge* de1)
+        :
+        dirEdge()
+    {
+        setDirectedEdges(de0, de1);
+    }
+
+    /**
+     * \brief Initializes this Edge's two DirectedEdges.
+     *
+     * For each DirectedEdge:
+     *  sets the Edge, sets the symmetric DirectedEdge, and
+     *  adds this Edge to its from-Node.
+     */
+    void setDirectedEdges(DirectedEdge* de0, DirectedEdge* de1);
+
+    /**
+     * \brief Returns one of the DirectedEdges associated with this Edge.
+     * @param i 0 or 1
+     */
+    DirectedEdge* getDirEdge(int i);
+
+    /**
+     * \brief Returns the DirectedEdge that starts from the given node,
+     * or null if the node is not one of the two nodes associated
+     * with this Edge.
+     */
+    DirectedEdge* getDirEdge(Node* fromNode);
+
+    /**
+     * \brief If <code>node</code> is one of the two nodes associated
+     * with this Edge, returns the other node; otherwise returns null.
+     */
+    Node* getOppositeNode(Node* node);
 };
 
 /// Print a Edge
diff --git a/include/geos/planargraph/GraphComponent.h b/include/geos/planargraph/GraphComponent.h
index ce74610..675ef5d 100644
--- a/include/geos/planargraph/GraphComponent.h
+++ b/include/geos/planargraph/GraphComponent.h
@@ -47,109 +47,134 @@ class GEOS_DLL GraphComponent {
 
 protected:
 
-	/// Variable holding ''marked'' status
-	bool isMarkedVar;
+    /// Variable holding ''marked'' status
+    bool isMarkedVar;
 
-	/// Variable holding ''visited'' status
-	bool isVisitedVar;
+    /// Variable holding ''visited'' status
+    bool isVisitedVar;
 
 public:
 
-	GraphComponent()
-		:
-		isMarkedVar(false),
-		isVisitedVar(false)
-		{}
-
-	virtual ~GraphComponent() {}
-
-	/** \brief
-	 * Tests if a component has been visited during the course
-	 * of a graph algorithm.
-	 *
-	 * @return <code>true</code> if the component has been visited
-	 */
-	virtual bool isVisited() const { return isVisitedVar; }
-
-	/** \brief
-	 * Sets the visited flag for this component.
-	 * @param isVisited the desired value of the visited flag
-	 */
-	virtual void setVisited(bool p_isVisited) { isVisitedVar=p_isVisited; }
-
-	/** \brief
-	 * Sets the Visited state for the elements of a container,
-	 * from start to end iterator.
-	 *
-	 * @param start the start element
-	 * @param end one past the last element
-	 * @param visited the state to set the visited flag to
-	 */
-	template <typename T>
-	static void setVisited(T start, T end, bool visited) {
-		for(T i=start; i!=end; ++i) {
-			(*i)->setVisited(visited);
-		}
-	}
-
-	/** \brief
-	 * Sets the Visited state for the values of each map
-	 * container element, from start to end iterator.
-	 *
-	 * @param start the start element
-	 * @param end one past the last element
-	 * @param visited the state to set the visited flag to
-	 */
-	template <typename T>
-	static void setVisitedMap(T start, T end, bool visited) {
-		for(T i=start; i!=end; ++i) {
-			i->second->setVisited(visited);
-		}
-	}
-
-	/** \brief
-	 * Sets the Marked state for the elements of a container,
-	 * from start to end iterator.
-	 *
-	 * @param start the start element
-	 * @param end one past the last element
-	 * @param marked the state to set the marked flag to
-	 */
-	template <typename T>
-	static void setMarked(T start, T end, bool marked) {
-		for(T i=start; i!=end; ++i) {
-			(*i)->setMarked(marked);
-		}
-	}
-
-
-	/** \brief
-	 * Sets the Marked state for the values of each map
-	 * container element, from start to end iterator.
-	 *
-	 * @param start the start element
-	 * @param end one past the last element
-	 * @param marked the state to set the visited flag to
-	 */
-	template <typename T>
-	static void setMarkedMap(T start, T end, bool marked) {
-		for(T i=start; i!=end; ++i) {
-			i->second->setMarked(marked);
-		}
-	}
-
-	/** \brief
-	 * Tests if a component has been marked at some point
-	 * during the processing involving this graph.
-	 * @return <code>true</code> if the component has been marked
-	 */
-	virtual bool isMarked() const { return isMarkedVar; }
-
-	/** \brief
-	 * Sets the marked flag for this component.
-	 * @param isMarked the desired value of the marked flag
-	 */
-	virtual void setMarked(bool p_isMarked) { isMarkedVar=p_isMarked; }
+    GraphComponent()
+        :
+        isMarkedVar(false),
+        isVisitedVar(false)
+    {}
+
+    virtual
+    ~GraphComponent() {}
+
+    /** \brief
+     * Tests if a component has been visited during the course
+     * of a graph algorithm.
+     *
+     * @return <code>true</code> if the component has been visited
+     */
+    virtual bool
+    isVisited() const
+    {
+        return isVisitedVar;
+    }
+
+    /** \brief
+     * Sets the visited flag for this component.
+     * @param isVisited the desired value of the visited flag
+     */
+    virtual void
+    setVisited(bool p_isVisited)
+    {
+        isVisitedVar = p_isVisited;
+    }
+
+    /** \brief
+     * Sets the Visited state for the elements of a container,
+     * from start to end iterator.
+     *
+     * @param start the start element
+     * @param end one past the last element
+     * @param visited the state to set the visited flag to
+     */
+    template <typename T>
+    static void
+    setVisited(T start, T end, bool visited)
+    {
+        for(T i = start; i != end; ++i) {
+            (*i)->setVisited(visited);
+        }
+    }
+
+    /** \brief
+     * Sets the Visited state for the values of each map
+     * container element, from start to end iterator.
+     *
+     * @param start the start element
+     * @param end one past the last element
+     * @param visited the state to set the visited flag to
+     */
+    template <typename T>
+    static void
+    setVisitedMap(T start, T end, bool visited)
+    {
+        for(T i = start; i != end; ++i) {
+            i->second->setVisited(visited);
+        }
+    }
+
+    /** \brief
+     * Sets the Marked state for the elements of a container,
+     * from start to end iterator.
+     *
+     * @param start the start element
+     * @param end one past the last element
+     * @param marked the state to set the marked flag to
+     */
+    template <typename T>
+    static void
+    setMarked(T start, T end, bool marked)
+    {
+        for(T i = start; i != end; ++i) {
+            (*i)->setMarked(marked);
+        }
+    }
+
+
+    /** \brief
+     * Sets the Marked state for the values of each map
+     * container element, from start to end iterator.
+     *
+     * @param start the start element
+     * @param end one past the last element
+     * @param marked the state to set the visited flag to
+     */
+    template <typename T>
+    static void
+    setMarkedMap(T start, T end, bool marked)
+    {
+        for(T i = start; i != end; ++i) {
+            i->second->setMarked(marked);
+        }
+    }
+
+    /** \brief
+     * Tests if a component has been marked at some point
+     * during the processing involving this graph.
+     * @return <code>true</code> if the component has been marked
+     */
+    virtual bool
+    isMarked() const
+    {
+        return isMarkedVar;
+    }
+
+    /** \brief
+     * Sets the marked flag for this component.
+     * @param isMarked the desired value of the marked flag
+     */
+    virtual void
+    setMarked(bool p_isMarked)
+    {
+        isMarkedVar = p_isMarked;
+    }
 
 };
 
diff --git a/include/geos/planargraph/Node.h b/include/geos/planargraph/Node.h
index 5a96ac9..721de4c 100644
--- a/include/geos/planargraph/Node.h
+++ b/include/geos/planargraph/Node.h
@@ -24,10 +24,10 @@
 
 // Forward declarations
 namespace geos {
-	namespace planargraph {
-		//class DirectedEdgeStar;
-		class DirectedEdge;
-	}
+namespace planargraph {
+//class DirectedEdgeStar;
+class DirectedEdge;
+}
 }
 
 namespace geos {
@@ -45,84 +45,103 @@ namespace planargraph { // geos.planargraph
 class GEOS_DLL Node: public GraphComponent {
 protected:
 
-	/// The location of this Node
-	geom::Coordinate pt;
+    /// The location of this Node
+    geom::Coordinate pt;
 
-	/// The collection of DirectedEdges that leave this Node
-	DirectedEdgeStar *deStar;
+    /// The collection of DirectedEdges that leave this Node
+    DirectedEdgeStar* deStar;
 
 public:
 
-	friend std::ostream& operator << (std::ostream& os, const Node&);
-
-	/** \brief
-	 * Returns all Edges that connect the two nodes (which are
-	 * assumed to be different).
-	 *
-	 * Note: returned vector is newly allocated, ownership to
-	 * the caller.
-	 */
-	static std::vector<Edge*>* getEdgesBetween(Node *node0,
-			Node *node1);
-
-	/// Constructs a Node with the given location.
-	Node(const geom::Coordinate& newPt)
-		:
-		pt(newPt)
-		{ deStar=new DirectedEdgeStar(); }
-
-	~Node() override {
-		delete deStar;
-	}
-
-	/**
-	 * \brief
-	 * Constructs a Node with the given location and
-	 * collection of outgoing DirectedEdges.
-	 * Takes ownership of the given DirectedEdgeStar!!
-	 */
-	Node(geom::Coordinate& newPt, DirectedEdgeStar *newDeStar)
-		:
-		pt(newPt),
-		deStar(newDeStar)
-		{}
-
-	/**
-	 * \brief Returns the location of this Node.
-	 */
-	geom::Coordinate& getCoordinate() {
-		return pt;
-	}
-
-	/**
-	 * \brief Adds an outgoing DirectedEdge to this Node.
-	 */
-	void addOutEdge(DirectedEdge *de) {
-		deStar->add(de);
-	}
-
-	/**
-	 * \brief Returns the collection of DirectedEdges that
-	 * leave this Node.
-	 */
-	DirectedEdgeStar* getOutEdges() { return deStar; }
-	const DirectedEdgeStar* getOutEdges() const { return deStar; }
-
-	/**
-	 * \brief Returns the number of edges around this Node.
-	 */
-	size_t getDegree() const {
-		return deStar->getDegree();
-	}
-
-	/**
-	 * \brief Returns the zero-based index of the given Edge,
-	 * after sorting in ascending order by angle with
-	 * the positive x-axis.
-	 */
-	int getIndex(Edge *edge) {
-		return deStar->getIndex(edge);
-	}
+    friend std::ostream& operator << (std::ostream& os, const Node&);
+
+    /** \brief
+     * Returns all Edges that connect the two nodes (which are
+     * assumed to be different).
+     *
+     * Note: returned vector is newly allocated, ownership to
+     * the caller.
+     */
+    static std::vector<Edge*>* getEdgesBetween(Node* node0,
+            Node* node1);
+
+    /// Constructs a Node with the given location.
+    Node(const geom::Coordinate& newPt)
+        :
+        pt(newPt)
+    {
+        deStar = new DirectedEdgeStar();
+    }
+
+    ~Node() override
+    {
+        delete deStar;
+    }
+
+    /**
+     * \brief
+     * Constructs a Node with the given location and
+     * collection of outgoing DirectedEdges.
+     * Takes ownership of the given DirectedEdgeStar!!
+     */
+    Node(geom::Coordinate& newPt, DirectedEdgeStar* newDeStar)
+        :
+        pt(newPt),
+        deStar(newDeStar)
+    {}
+
+    /**
+     * \brief Returns the location of this Node.
+     */
+    geom::Coordinate&
+    getCoordinate()
+    {
+        return pt;
+    }
+
+    /**
+     * \brief Adds an outgoing DirectedEdge to this Node.
+     */
+    void
+    addOutEdge(DirectedEdge* de)
+    {
+        deStar->add(de);
+    }
+
+    /**
+     * \brief Returns the collection of DirectedEdges that
+     * leave this Node.
+     */
+    DirectedEdgeStar*
+    getOutEdges()
+    {
+        return deStar;
+    }
+    const DirectedEdgeStar*
+    getOutEdges() const
+    {
+        return deStar;
+    }
+
+    /**
+     * \brief Returns the number of edges around this Node.
+     */
+    size_t
+    getDegree() const
+    {
+        return deStar->getDegree();
+    }
+
+    /**
+     * \brief Returns the zero-based index of the given Edge,
+     * after sorting in ascending order by angle with
+     * the positive x-axis.
+     */
+    int
+    getIndex(Edge* edge)
+    {
+        return deStar->getIndex(edge);
+    }
 
 };
 
diff --git a/include/geos/planargraph/NodeMap.h b/include/geos/planargraph/NodeMap.h
index 327524a..2a67fe4 100644
--- a/include/geos/planargraph/NodeMap.h
+++ b/include/geos/planargraph/NodeMap.h
@@ -29,12 +29,12 @@
 
 // Forward declarations
 namespace geos {
-	namespace planargraph {
-		class DirectedEdgeStar;
-		class DirectedEdge;
-		class Edge;
-		class Node;
-	}
+namespace planargraph {
+class DirectedEdgeStar;
+class DirectedEdge;
+class Edge;
+class Node;
+}
 }
 
 namespace geos {
@@ -47,73 +47,83 @@ namespace planargraph { // geos.planargraph
  */
 class GEOS_DLL NodeMap {
 public:
-	typedef std::map<geom::Coordinate, Node*, geom::CoordinateLessThen> container;
+    typedef std::map<geom::Coordinate, Node*, geom::CoordinateLessThen> container;
 private:
-	container nodeMap;
+    container nodeMap;
 public:
-	/**
-	 * \brief Constructs a NodeMap without any Nodes.
-	 */
-	NodeMap();
-
-	container& getNodeMap();
-
-	virtual ~NodeMap();
-
-	/**
-	 * \brief
-	 * Adds a node to the std::map, replacing any that is already
-	 * at that location.
-	 * @return the added node
-	 */
-	Node* add(Node *n);
-
-	/**
-	 * \brief
-	 * Removes the Node at the given location, and returns it
-	 * (or null if no Node was there).
-	 */
-	Node* remove(geom::Coordinate& pt);
-
-	/**
-	 * \brief
-	 * Returns the Node at the given location,
-	 * or null if no Node was there.
-	 */
-	Node* find(const geom::Coordinate& coord);
-
-	/**
-	 * \brief
-	 * Returns an Iterator over the Nodes in this NodeMap,
-	 * sorted in ascending order
-	 * by angle with the positive x-axis.
-	 */
-	container::iterator iterator() {
-		return nodeMap.begin();
-	}
-
-	container::iterator begin() {
-		return nodeMap.begin();
-	}
-	container::const_iterator begin() const {
-		return nodeMap.begin();
-	}
-
-	container::iterator end() {
-		return nodeMap.end();
-	}
-	container::const_iterator end() const {
-		return nodeMap.end();
-	}
-
-	/**
-	 * \brief
-	 * Returns the Nodes in this NodeMap, sorted in ascending order
-	 * by angle with the positive x-axis.
-	 *
-	 * @param nodes : the nodes are push_back'ed here
-	 */
-	void getNodes(std::vector<Node*>& nodes);
+    /**
+     * \brief Constructs a NodeMap without any Nodes.
+     */
+    NodeMap();
+
+    container& getNodeMap();
+
+    virtual ~NodeMap();
+
+    /**
+     * \brief
+     * Adds a node to the std::map, replacing any that is already
+     * at that location.
+     * @return the added node
+     */
+    Node* add(Node* n);
+
+    /**
+     * \brief
+     * Removes the Node at the given location, and returns it
+     * (or null if no Node was there).
+     */
+    Node* remove(geom::Coordinate& pt);
+
+    /**
+     * \brief
+     * Returns the Node at the given location,
+     * or null if no Node was there.
+     */
+    Node* find(const geom::Coordinate& coord);
+
+    /**
+     * \brief
+     * Returns an Iterator over the Nodes in this NodeMap,
+     * sorted in ascending order
+     * by angle with the positive x-axis.
+     */
+    container::iterator
+    iterator()
+    {
+        return nodeMap.begin();
+    }
+
+    container::iterator
+    begin()
+    {
+        return nodeMap.begin();
+    }
+    container::const_iterator
+    begin() const
+    {
+        return nodeMap.begin();
+    }
+
+    container::iterator
+    end()
+    {
+        return nodeMap.end();
+    }
+    container::const_iterator
+    end() const
+    {
+        return nodeMap.end();
+    }
+
+    /**
+     * \brief
+     * Returns the Nodes in this NodeMap, sorted in ascending order
+     * by angle with the positive x-axis.
+     *
+     * @param nodes : the nodes are push_back'ed here
+     */
+    void getNodes(std::vector<Node*>& nodes);
 };
 
 
diff --git a/include/geos/planargraph/PlanarGraph.h b/include/geos/planargraph/PlanarGraph.h
index 8bbb321..2172c11 100644
--- a/include/geos/planargraph/PlanarGraph.h
+++ b/include/geos/planargraph/PlanarGraph.h
@@ -31,14 +31,14 @@
 
 // Forward declarations
 namespace geos {
-	namespace geom {
-		class Coordinate;
-	}
-	namespace planargraph {
-		class DirectedEdge;
-		class Edge;
-		class Node;
-	}
+namespace geom {
+class Coordinate;
+}
+namespace planargraph {
+class DirectedEdge;
+class Edge;
+class Node;
+}
 }
 
 namespace geos {
@@ -61,187 +61,218 @@ class GEOS_DLL PlanarGraph {
 
 protected:
 
-	std::vector<Edge*> edges;
-	std::vector<DirectedEdge*> dirEdges;
-	NodeMap nodeMap;
-
-	/**
-	 * \brief
-	 * Adds a node to the std::map, replacing any that is already at that
-	 * location.
-	 *
-	 * Only subclasses can add Nodes, to ensure Nodes are
-	 * of the right type.
-	 * @return the added node
-	 */
-	void add(Node *node) {
-		nodeMap.add(node);
-	}
-
-	/**
-	 * \brief
-	 * Adds the Edge and its DirectedEdges with this PlanarGraph.
-	 *
-	 * Assumes that the Edge has already been created with its associated
-	 * DirectEdges.
-	 * Only subclasses can add Edges, to ensure the edges added are of
-	 * the right class.
-	 */
-	void add(Edge *edge);
-
-	/**
-	 * \brief
-	 * Adds the Edge to this PlanarGraph.
-	 *
-	 * Only subclasses can add DirectedEdges,
-	 * to ensure the edges added are of the right class.
-	 */
-	void add(DirectedEdge *dirEdge) {
-		dirEdges.push_back(dirEdge);
-	}
+    std::vector<Edge*> edges;
+    std::vector<DirectedEdge*> dirEdges;
+    NodeMap nodeMap;
+
+    /**
+     * \brief
+     * Adds a node to the std::map, replacing any that is already at that
+     * location.
+     *
+     * Only subclasses can add Nodes, to ensure Nodes are
+     * of the right type.
+     * @return the added node
+     */
+    void
+    add(Node* node)
+    {
+        nodeMap.add(node);
+    }
+
+    /**
+     * \brief
+     * Adds the Edge and its DirectedEdges with this PlanarGraph.
+     *
+     * Assumes that the Edge has already been created with its associated
+     * DirectEdges.
+     * Only subclasses can add Edges, to ensure the edges added are of
+     * the right class.
+     */
+    void add(Edge* edge);
+
+    /**
+     * \brief
+     * Adds the Edge to this PlanarGraph.
+     *
+     * Only subclasses can add DirectedEdges,
+     * to ensure the edges added are of the right class.
+     */
+    void
+    add(DirectedEdge* dirEdge)
+    {
+        dirEdges.push_back(dirEdge);
+    }
 
 public:
 
-	typedef std::vector<Edge *> EdgeContainer;
-	typedef EdgeContainer::iterator EdgeIterator;
-
-
-	/**
-	 * \brief
-	 * Constructs a PlanarGraph without any Edges, DirectedEdges, or Nodes.
-	 */
-	PlanarGraph() {}
-
-	virtual ~PlanarGraph() {}
-
-	/**
-	 * \brief
-	 * Returns the Node at the given location,
-	 * or null if no Node was there.
-	 */
-	Node* findNode(const geom::Coordinate& pt) {
-		return nodeMap.find(pt);
-	}
-
-	/**
-	 * \brief
-	 * Returns an Iterator over the Nodes in this PlanarGraph.
-	 */
-	NodeMap::container::iterator nodeIterator() {
-		return nodeMap.begin();
-	}
-
-	NodeMap::container::iterator nodeBegin() {
-		return nodeMap.begin();
-	}
-
-	NodeMap::container::const_iterator nodeBegin() const {
-		return nodeMap.begin();
-	}
-
-	NodeMap::container::iterator nodeEnd() {
-		return nodeMap.end();
-	}
-
-	NodeMap::container::const_iterator nodeEnd() const {
-		return nodeMap.end();
-	}
-
-	/**
-	 * \brief
-	 * Returns the Nodes in this PlanarGraph.
-	 *
-	 * @param nodes : the nodes are push_back'ed here
-	 */
-	void getNodes(std::vector<Node*>& nodes) { nodeMap.getNodes(nodes); }
-
-	/**
-	 * \brief
-	 * Returns an Iterator over the DirectedEdges in this PlanarGraph,
-	 * in the order in which they were added.
-	 *
-	 * @see add(Edge)
-	 * @see add(DirectedEdge)
-	 */
-	std::vector<DirectedEdge*>::iterator dirEdgeIterator() {
-		return dirEdges.begin();
-	}
-
-	/// Alias for edgeBegin()
-	std::vector<Edge*>::iterator edgeIterator() {
-		return edges.begin();
-	}
-
-	/// Returns an iterator to first Edge in this graph.
-	//
-	/// Edges are stored in the order they were added.
-	/// @see add(Edge)
-	///
-	std::vector<Edge*>::iterator edgeBegin() {
-		return edges.begin();
-	}
-
-	/// Returns an iterator to one-past last Edge in this graph.
-	//
-	/// Edges are stored in the order they were added.
-	/// @see add(Edge)
-	///
-	std::vector<Edge*>::iterator edgeEnd() {
-		return edges.end();
-	}
-
-	/**
-	 * \brief
-	 * Returns the Edges that have been added to this PlanarGraph
-	 * @see #add(Edge)
-	 */
-	std::vector<Edge*>* getEdges() {
-		return &edges;
-	}
-
-	/**
-	 * \brief
-	 * Removes an Edge and its associated DirectedEdges from their
-	 * from-Nodes and from this PlanarGraph.
-	 *
-	 * Note: This method does not remove the Nodes associated
-	 * with the Edge, even if the removal of the Edge reduces the
-	 * degree of a Node to zero.
-	 */
-	void remove(Edge *edge);
-
-	/**
-	 * \brief
-	 * Removes DirectedEdge from its from-Node and from this PlanarGraph.
-	 *
-	 * Note:
-	 * This method does not remove the Nodes associated with the
-	 * DirectedEdge, even if the removal of the DirectedEdge reduces
-	 * the degree of a Node to zero.
-	 */
-	void remove(DirectedEdge *de);
-
-	/**
-	 * \brief
-	 * Removes a node from the graph, along with any associated
-	 * DirectedEdges and Edges.
-	 */
-	void remove(Node *node);
-
-	/**
-	 * \brief
-	 * Returns all Nodes with the given number of Edges around it.
- 	 * The return value is a newly allocated vector of existing nodes
-	 */
-	std::vector<Node*>* findNodesOfDegree(std::size_t degree);
-
-	/**
-	 * \brief
-	 * Get all Nodes with the given number of Edges around it.
-	 *
- 	 * Found nodes are pushed to the given vector
-	 */
-	void findNodesOfDegree(std::size_t degree, std::vector<Node*>& to);
+    typedef std::vector<Edge*> EdgeContainer;
+    typedef EdgeContainer::iterator EdgeIterator;
+
+
+    /**
+     * \brief
+     * Constructs a PlanarGraph without any Edges, DirectedEdges, or Nodes.
+     */
+    PlanarGraph() {}
+
+    virtual
+    ~PlanarGraph() {}
+
+    /**
+     * \brief
+     * Returns the Node at the given location,
+     * or null if no Node was there.
+     */
+    Node*
+    findNode(const geom::Coordinate& pt)
+    {
+        return nodeMap.find(pt);
+    }
+
+    /**
+     * \brief
+     * Returns an Iterator over the Nodes in this PlanarGraph.
+     */
+    NodeMap::container::iterator
+    nodeIterator()
+    {
+        return nodeMap.begin();
+    }
+
+    NodeMap::container::iterator
+    nodeBegin()
+    {
+        return nodeMap.begin();
+    }
+
+    NodeMap::container::const_iterator
+    nodeBegin() const
+    {
+        return nodeMap.begin();
+    }
+
+    NodeMap::container::iterator
+    nodeEnd()
+    {
+        return nodeMap.end();
+    }
+
+    NodeMap::container::const_iterator
+    nodeEnd() const
+    {
+        return nodeMap.end();
+    }
+
+    /**
+     * \brief
+     * Returns the Nodes in this PlanarGraph.
+     *
+     * @param nodes : the nodes are push_back'ed here
+     */
+    void
+    getNodes(std::vector<Node*>& nodes)
+    {
+        nodeMap.getNodes(nodes);
+    }
+
+    /**
+     * \brief
+     * Returns an Iterator over the DirectedEdges in this PlanarGraph,
+     * in the order in which they were added.
+     *
+     * @see add(Edge)
+     * @see add(DirectedEdge)
+     */
+    std::vector<DirectedEdge*>::iterator
+    dirEdgeIterator()
+    {
+        return dirEdges.begin();
+    }
+
+    /// Alias for edgeBegin()
+    std::vector<Edge*>::iterator
+    edgeIterator()
+    {
+        return edges.begin();
+    }
+
+    /// Returns an iterator to first Edge in this graph.
+    //
+    /// Edges are stored in the order they were added.
+    /// @see add(Edge)
+    ///
+    std::vector<Edge*>::iterator
+    edgeBegin()
+    {
+        return edges.begin();
+    }
+
+    /// Returns an iterator to one-past last Edge in this graph.
+    //
+    /// Edges are stored in the order they were added.
+    /// @see add(Edge)
+    ///
+    std::vector<Edge*>::iterator
+    edgeEnd()
+    {
+        return edges.end();
+    }
+
+    /**
+     * \brief
+     * Returns the Edges that have been added to this PlanarGraph
+     * @see #add(Edge)
+     */
+    std::vector<Edge*>*
+    getEdges()
+    {
+        return &edges;
+    }
+
+    /**
+     * \brief
+     * Removes an Edge and its associated DirectedEdges from their
+     * from-Nodes and from this PlanarGraph.
+     *
+     * Note: This method does not remove the Nodes associated
+     * with the Edge, even if the removal of the Edge reduces the
+     * degree of a Node to zero.
+     */
+    void remove(Edge* edge);
+
+    /**
+     * \brief
+     * Removes DirectedEdge from its from-Node and from this PlanarGraph.
+     *
+     * Note:
+     * This method does not remove the Nodes associated with the
+     * DirectedEdge, even if the removal of the DirectedEdge reduces
+     * the degree of a Node to zero.
+     */
+    void remove(DirectedEdge* de);
+
+    /**
+     * \brief
+     * Removes a node from the graph, along with any associated
+     * DirectedEdges and Edges.
+     */
+    void remove(Node* node);
+
+    /**
+     * \brief
+     * Returns all Nodes with the given number of Edges around it.
+     * The return value is a newly allocated vector of existing nodes
+     */
+    std::vector<Node*>* findNodesOfDegree(std::size_t degree);
+
+    /**
+     * \brief
+     * Get all Nodes with the given number of Edges around it.
+     *
+     * Found nodes are pushed to the given vector
+     */
+    void findNodesOfDegree(std::size_t degree, std::vector<Node*>& to);
 };
 
 } // namespace geos::planargraph
diff --git a/include/geos/planargraph/Subgraph.h b/include/geos/planargraph/Subgraph.h
index 2d8dd08..c724f7a 100644
--- a/include/geos/planargraph/Subgraph.h
+++ b/include/geos/planargraph/Subgraph.h
@@ -28,11 +28,11 @@
 
 // Forward declarations
 namespace geos {
-	namespace planargraph {
-		class PlanarGraph;
-		class DirectedEdge;
-		class Edge;
-	}
+namespace planargraph {
+class PlanarGraph;
+class DirectedEdge;
+class Edge;
+}
 }
 
 namespace geos {
@@ -50,96 +50,121 @@ namespace planargraph { // geos.planargraph
 /// @@ Actually we'll be copying Coordinates in NodeMap.
 /// I guess that'll need to be changed soon.
 ///
-class GEOS_DLL Subgraph
-{
+class GEOS_DLL Subgraph {
 public:
-	/**
-	 * Creates a new subgraph of the given PlanarGraph
-	 *
-	 * @param parent the parent graph
-	 */
-	Subgraph(PlanarGraph &parent)
-		:
-		parentGraph(parent)
-		{}
-
-	/**
-	 * Gets the {@link PlanarGraph} which this subgraph
-	 * is part of.
-	 *
-	 * @return the parent PlanarGraph
-	 */
-	PlanarGraph& getParent() const { return parentGraph; }
-
-	/**
-	 * Adds an {@link Edge} to the subgraph.
-	 * The associated {@link DirectedEdge}s and {@link planarNode}s
-	 * are also added.
-	 *
-	 * @param e the edge to add
-	 *
-	 * @return a pair with first element being an iterator
-	 *         to the Edge in set and second element
-	 *	   being a boolean value indicating wheter
-	 *	   the Edge has been inserted now or was
-	 *	   already in the set.
-	 */
-	std::pair<std::set<Edge*>::iterator, bool> add(Edge *e);
-
-	/**
-	 * Returns an iterator over the DirectedEdge in this graph,
-	 * in the order in which they were added.
-	 *
-	 * @return an iterator over the directed edges
-	 *
-	 * @see add(Edge)
-	 */
-	std::vector<const DirectedEdge*>::iterator getDirEdgeBegin() {
-		return dirEdges.begin();
-	}
-
-
-	/**
-	 * Returns an {@link Iterator} over the {@link Edge}s in this
-	 * graph, in the order in which they were added.
-	 *
-	 * @return an iterator over the edges
-	 *
-	 * @see add(Edge)
-	 */
-	std::set<Edge*>::iterator edgeBegin() { return edges.begin(); }
-	std::set<Edge*>::iterator edgeEnd() { return edges.end(); }
-
-	/**
-	 * Returns a iterators over the planarNodesMap::container
-	 * in this graph.
-	 */
-	NodeMap::container::iterator nodeBegin() {
-		return nodeMap.begin();
-	}
-	NodeMap::container::const_iterator nodeEnd() const {
-		return nodeMap.end();
-	}
-	NodeMap::container::iterator nodeEnd() {
-		return nodeMap.end();
-	}
-	NodeMap::container::const_iterator nodeBegin() const {
-		return nodeMap.begin();
-	}
-
-	/**
-	 * Tests whether an {@link Edge} is contained in this subgraph
-	 * @param e the edge to test
-	 * @return <code>true</code> if the edge is contained in this subgraph
-	 */
-	bool contains(Edge *e) { return (edges.find(e) != edges.end()); }
+    /**
+     * Creates a new subgraph of the given PlanarGraph
+     *
+     * @param parent the parent graph
+     */
+    Subgraph(PlanarGraph& parent)
+        :
+        parentGraph(parent)
+    {}
+
+    /**
+     * Gets the {@link PlanarGraph} which this subgraph
+     * is part of.
+     *
+     * @return the parent PlanarGraph
+     */
+    PlanarGraph&
+    getParent() const
+    {
+        return parentGraph;
+    }
+
+    /**
+     * Adds an {@link Edge} to the subgraph.
+     * The associated {@link DirectedEdge}s and {@link planarNode}s
+     * are also added.
+     *
+     * @param e the edge to add
+     *
+     * @return a pair with first element being an iterator
+     *         to the Edge in set and second element
+     *	   being a boolean value indicating wheter
+     *	   the Edge has been inserted now or was
+     *	   already in the set.
+     */
+    std::pair<std::set<Edge*>::iterator, bool> add(Edge* e);
+
+    /**
+     * Returns an iterator over the DirectedEdge in this graph,
+     * in the order in which they were added.
+     *
+     * @return an iterator over the directed edges
+     *
+     * @see add(Edge)
+     */
+    std::vector<const DirectedEdge*>::iterator
+    getDirEdgeBegin()
+    {
+        return dirEdges.begin();
+    }
+
+
+    /**
+     * Returns an {@link Iterator} over the {@link Edge}s in this
+     * graph, in the order in which they were added.
+     *
+     * @return an iterator over the edges
+     *
+     * @see add(Edge)
+     */
+    std::set<Edge*>::iterator
+    edgeBegin()
+    {
+        return edges.begin();
+    }
+    std::set<Edge*>::iterator
+    edgeEnd()
+    {
+        return edges.end();
+    }
+
+    /**
+     * Returns a iterators over the planarNodesMap::container
+     * in this graph.
+     */
+    NodeMap::container::iterator
+    nodeBegin()
+    {
+        return nodeMap.begin();
+    }
+    NodeMap::container::const_iterator
+    nodeEnd() const
+    {
+        return nodeMap.end();
+    }
+    NodeMap::container::iterator
+    nodeEnd()
+    {
+        return nodeMap.end();
+    }
+    NodeMap::container::const_iterator
+    nodeBegin() const
+    {
+        return nodeMap.begin();
+    }
+
+    /**
+     * Tests whether an {@link Edge} is contained in this subgraph
+     * @param e the edge to test
+     * @return <code>true</code> if the edge is contained in this subgraph
+     */
+    bool
+    contains(Edge* e)
+    {
+        return (edges.find(e) != edges.end());
+    }
 
 protected:
 
-	PlanarGraph &parentGraph;
-	std::set<Edge*> edges;
-	std::vector<const DirectedEdge*> dirEdges;
-	NodeMap nodeMap;
+    PlanarGraph& parentGraph;
+    std::set<Edge*> edges;
+    std::vector<const DirectedEdge*> dirEdges;
+    NodeMap nodeMap;
 
     // Declare type as noncopyable
     Subgraph(const Subgraph& other) = delete;
diff --git a/include/geos/planargraph/algorithm/ConnectedSubgraphFinder.h b/include/geos/planargraph/algorithm/ConnectedSubgraphFinder.h
index d77c6b4..0505650 100644
--- a/include/geos/planargraph/algorithm/ConnectedSubgraphFinder.h
+++ b/include/geos/planargraph/algorithm/ConnectedSubgraphFinder.h
@@ -24,11 +24,11 @@
 
 // Forward declarations
 namespace geos {
-	namespace planargraph {
-		class PlanarGraph;
-		class Subgraph;
-		class Node;
-	}
+namespace planargraph {
+class PlanarGraph;
+class Subgraph;
+class Node;
+}
 }
 
 namespace geos {
@@ -40,48 +40,47 @@ namespace algorithm { // geos::planargraph::algorithm
  *
  * <b>Note:</b> uses the <code>isVisited</code> flag on the nodes.
  */
-class GEOS_DLL ConnectedSubgraphFinder
-{
+class GEOS_DLL ConnectedSubgraphFinder {
 public:
 
-	ConnectedSubgraphFinder(PlanarGraph& newGraph)
-		:
-		graph(newGraph)
-		{}
-
-	/// \brief
-	/// Store newly allocated connected Subgraphs into the
-	/// given std::vector
-	///
-	/// Caller take responsibility in releasing memory associated
-	/// with the subgraphs themself.
-	///
-	///
-	void getConnectedSubgraphs(std::vector<Subgraph *>& dest);
+    ConnectedSubgraphFinder(PlanarGraph& newGraph)
+        :
+        graph(newGraph)
+    {}
+
+    /// \brief
+    /// Store newly allocated connected Subgraphs into the
+    /// given std::vector
+    ///
+    /// Caller take responsibility in releasing memory associated
+    /// with the subgraphs themself.
+    ///
+    ///
+    void getConnectedSubgraphs(std::vector<Subgraph*>& dest);
 
 private:
 
-	PlanarGraph& graph;
+    PlanarGraph& graph;
 
-	/// Returns a newly allocated Subgraph
-	Subgraph* findSubgraph(Node* node);
+    /// Returns a newly allocated Subgraph
+    Subgraph* findSubgraph(Node* node);
 
 
-	/**
-	 * Adds all nodes and edges reachable from this node to the subgraph.
-	 * Uses an explicit stack to avoid a large depth of recursion.
-	 *
-	 * @param node a node known to be in the subgraph
-	 */
-	void addReachable(Node* node, Subgraph* subgraph);
+    /**
+     * Adds all nodes and edges reachable from this node to the subgraph.
+     * Uses an explicit stack to avoid a large depth of recursion.
+     *
+     * @param node a node known to be in the subgraph
+     */
+    void addReachable(Node* node, Subgraph* subgraph);
 
-	/**
-	 * Adds the argument node and all its out edges to the subgraph.
-	 * @param node the node to add
-	 * @param nodeStack the current set of nodes being traversed
-	 */
-	void addEdges(Node* node, std::stack<Node *>& nodeStack,
-			Subgraph* subgraph);
+    /**
+     * Adds the argument node and all its out edges to the subgraph.
+     * @param node the node to add
+     * @param nodeStack the current set of nodes being traversed
+     */
+    void addEdges(Node* node, std::stack<Node*>& nodeStack,
+                  Subgraph* subgraph);
 
     // Declare type as noncopyable
     ConnectedSubgraphFinder(const ConnectedSubgraphFinder& other) = delete;
diff --git a/include/geos/precision/CommonBits.h b/include/geos/precision/CommonBits.h
index 10637bd..4ffe9c9 100644
--- a/include/geos/precision/CommonBits.h
+++ b/include/geos/precision/CommonBits.h
@@ -34,61 +34,61 @@ class GEOS_DLL CommonBits {
 
 private:
 
-	bool isFirst;
+    bool isFirst;
 
-	int commonMantissaBitsCount;
+    int commonMantissaBitsCount;
 
-	int64 commonBits;
+    int64 commonBits;
 
-	int64 commonSignExp;
+    int64 commonSignExp;
 
 public:
 
-	/** \brief
-	 * Computes the bit pattern for the sign and exponent of a
-	 * double-precision number.
-	 *
-	 * @param num
-	 * @return the bit pattern for the sign and exponent
-	 */
-	static int64 signExpBits(int64 num);
-
-	/** \brief
-	 * This computes the number of common most-significant
-	 * bits in the mantissas of two double-precision numbers.
-	 *
-	 * It does not count the hidden bit, which is always 1.
-	 * It does not determine whether the numbers have the same
-	 * exponent - if they do not, the value computed by this
-	 * function is meaningless.
-	 * @param db
-	 * @return the number of common most-significant mantissa bits
-	 */
-	static int numCommonMostSigMantissaBits(int64 num1, int64 num2);
-
-	/** \brief
-	 * Zeroes the lower n bits of a bitstring.
-	 *
-	 * @param bits the bitstring to alter
-	 * @param i the number of bits to zero
-	 * @return the zeroed bitstring
-	 */
-	static int64 zeroLowerBits(int64 bits, int nBits);
-
-	/** \brief
-	 * Extracts the i'th bit of a bitstring.
-	 *
-	 * @param bits the bitstring to extract from
-	 * @param i the bit to extract
-	 * @return the value of the extracted bit
-	 */
-	static int getBit(int64 bits, int i);
-
-	CommonBits();
-
-	void add(double num);
-
-	double getCommon();
+    /** \brief
+     * Computes the bit pattern for the sign and exponent of a
+     * double-precision number.
+     *
+     * @param num
+     * @return the bit pattern for the sign and exponent
+     */
+    static int64 signExpBits(int64 num);
+
+    /** \brief
+     * This computes the number of common most-significant
+     * bits in the mantissas of two double-precision numbers.
+     *
+     * It does not count the hidden bit, which is always 1.
+     * It does not determine whether the numbers have the same
+     * exponent - if they do not, the value computed by this
+     * function is meaningless.
+     * @param db
+     * @return the number of common most-significant mantissa bits
+     */
+    static int numCommonMostSigMantissaBits(int64 num1, int64 num2);
+
+    /** \brief
+     * Zeroes the lower n bits of a bitstring.
+     *
+     * @param bits the bitstring to alter
+     * @param i the number of bits to zero
+     * @return the zeroed bitstring
+     */
+    static int64 zeroLowerBits(int64 bits, int nBits);
+
+    /** \brief
+     * Extracts the i'th bit of a bitstring.
+     *
+     * @param bits the bitstring to extract from
+     * @param i the bit to extract
+     * @return the value of the extracted bit
+     */
+    static int getBit(int64 bits, int i);
+
+    CommonBits();
+
+    void add(double num);
+
+    double getCommon();
 
 };
 
diff --git a/include/geos/precision/CommonBitsOp.h b/include/geos/precision/CommonBitsOp.h
index af16b8a..9240388 100644
--- a/include/geos/precision/CommonBitsOp.h
+++ b/include/geos/precision/CommonBitsOp.h
@@ -27,12 +27,12 @@
 #endif
 
 namespace geos {
-	namespace geom {
-		class Geometry;
-	}
-	namespace precision {
-		//class CommonBitsRemover;
-	}
+namespace geom {
+class Geometry;
+}
+namespace precision {
+//class CommonBitsRemover;
+}
 }
 
 namespace geos {
@@ -51,117 +51,117 @@ class GEOS_DLL CommonBitsOp {
 
 private:
 
-	bool returnToOriginalPrecision;
+    bool returnToOriginalPrecision;
 
-	std::unique_ptr<CommonBitsRemover> cbr;
+    std::unique_ptr<CommonBitsRemover> cbr;
 
-	/** \brief
-	 * Computes a copy of the input Geometry with the calculated
-	 * common bits removed from each coordinate.
-	 *
-	 * @param geom0 the Geometry to remove common bits from
-	 * @return a copy of the input Geometry with common bits removed
-	 *         (caller takes responsibility of its deletion)
-	 */
-	geom::Geometry* removeCommonBits(const geom::Geometry *geom0);
+    /** \brief
+     * Computes a copy of the input Geometry with the calculated
+     * common bits removed from each coordinate.
+     *
+     * @param geom0 the Geometry to remove common bits from
+     * @return a copy of the input Geometry with common bits removed
+     *         (caller takes responsibility of its deletion)
+     */
+    geom::Geometry* removeCommonBits(const geom::Geometry* geom0);
 
-	/** \brief
-	 *
-	 */
-	void removeCommonBits(
-			const geom::Geometry* geom0,
-			const geom::Geometry* geom1,
-			std::unique_ptr<geom::Geometry>& rgeom0,
-			std::unique_ptr<geom::Geometry>& rgeom1);
+    /** \brief
+     *
+     */
+    void removeCommonBits(
+        const geom::Geometry* geom0,
+        const geom::Geometry* geom1,
+        std::unique_ptr<geom::Geometry>& rgeom0,
+        std::unique_ptr<geom::Geometry>& rgeom1);
 
 
 public:
 
-	/**
-	 * Creates a new instance of class, which reshifts result Geometry
-	 */
-	CommonBitsOp();
-
-	/**
-	 * Creates a new instance of class, specifying whether
-	 * the result {@link Geometry}s should be reshifted.
-	 *
-	 * @param returnToOriginalPrecision
-	 */
-	CommonBitsOp(bool nReturnToOriginalPrecision);
-
-	/**
-	 * Computes the set-theoretic intersection of two Geometry,
-	 * using enhanced precision.
-	 * @param geom0 the first Geometry
-	 * @param geom1 the second Geometry
-	 * @return the Geometry representing the set-theoretic
-	 *  intersection of the input Geometries.
-	 */
-	geom::Geometry* intersection(
-			const geom::Geometry *geom0,
-			const geom::Geometry *geom1);
-
-	/**
-	 * Computes the set-theoretic union of two Geometry,
-	 * using enhanced precision.
-	 * @param geom0 the first Geometry
-	 * @param geom1 the second Geometry
-	 * @return the Geometry representing the set-theoretic union
-	 * of the input Geometries.
-	 */
-	geom::Geometry* Union(
-			const geom::Geometry *geom0,
-			const geom::Geometry *geom1);
-
-	/**
-	 * Computes the set-theoretic difference of two Geometry,
-	 * using enhanced precision.
-	 * @param geom0 the first Geometry
-	 * @param geom1 the second Geometry, to be subtracted from the first
-	 * @return the Geometry representing the set-theoretic difference
-	 * of the input Geometries.
-	 */
-	geom::Geometry* difference(
-			const geom::Geometry *geom0,
-			const geom::Geometry *geom1);
-
-	/**
-	 * Computes the set-theoretic symmetric difference of two geometries,
-	 * using enhanced precision.
-	 * @param geom0 the first Geometry
-	 * @param geom1 the second Geometry
-	 * @return the Geometry representing the set-theoretic symmetric
-	 * difference of the input Geometries.
-	 */
-	geom::Geometry* symDifference(
-			const geom::Geometry *geom0,
-			const geom::Geometry *geom1);
-
-	/**
-	 * Computes the buffer a geometry,
-	 * using enhanced precision.
-	 * @param geom0 the Geometry to buffer
-	 * @param distance the buffer distance
-	 * @return the Geometry representing the buffer of the input Geometry.
-	 */
-	geom::Geometry* buffer(
-			const geom::Geometry *geom0,
-			double distance);
-
-	/**
-	 * If required, returning the result to the orginal precision
-	 * if required.
-	 *
-	 * In this current implementation, no rounding is performed on the
-	 * reshifted result geometry, which means that it is possible
-	 * that the returned Geometry is invalid.
-	 *
-	 * @param result the result Geometry to modify
-	 * @return the result Geometry with the required precision
-	 */
-	geom::Geometry* computeResultPrecision(
-			geom::Geometry *result);
+    /**
+     * Creates a new instance of class, which reshifts result Geometry
+     */
+    CommonBitsOp();
+
+    /**
+     * Creates a new instance of class, specifying whether
+     * the result {@link Geometry}s should be reshifted.
+     *
+     * @param returnToOriginalPrecision
+     */
+    CommonBitsOp(bool nReturnToOriginalPrecision);
+
+    /**
+     * Computes the set-theoretic intersection of two Geometry,
+     * using enhanced precision.
+     * @param geom0 the first Geometry
+     * @param geom1 the second Geometry
+     * @return the Geometry representing the set-theoretic
+     *  intersection of the input Geometries.
+     */
+    geom::Geometry* intersection(
+        const geom::Geometry* geom0,
+        const geom::Geometry* geom1);
+
+    /**
+     * Computes the set-theoretic union of two Geometry,
+     * using enhanced precision.
+     * @param geom0 the first Geometry
+     * @param geom1 the second Geometry
+     * @return the Geometry representing the set-theoretic union
+     * of the input Geometries.
+     */
+    geom::Geometry* Union(
+        const geom::Geometry* geom0,
+        const geom::Geometry* geom1);
+
+    /**
+     * Computes the set-theoretic difference of two Geometry,
+     * using enhanced precision.
+     * @param geom0 the first Geometry
+     * @param geom1 the second Geometry, to be subtracted from the first
+     * @return the Geometry representing the set-theoretic difference
+     * of the input Geometries.
+     */
+    geom::Geometry* difference(
+        const geom::Geometry* geom0,
+        const geom::Geometry* geom1);
+
+    /**
+     * Computes the set-theoretic symmetric difference of two geometries,
+     * using enhanced precision.
+     * @param geom0 the first Geometry
+     * @param geom1 the second Geometry
+     * @return the Geometry representing the set-theoretic symmetric
+     * difference of the input Geometries.
+     */
+    geom::Geometry* symDifference(
+        const geom::Geometry* geom0,
+        const geom::Geometry* geom1);
+
+    /**
+     * Computes the buffer a geometry,
+     * using enhanced precision.
+     * @param geom0 the Geometry to buffer
+     * @param distance the buffer distance
+     * @return the Geometry representing the buffer of the input Geometry.
+     */
+    geom::Geometry* buffer(
+        const geom::Geometry* geom0,
+        double distance);
+
+    /**
+     * If required, returning the result to the orginal precision
+     * if required.
+     *
+     * In this current implementation, no rounding is performed on the
+     * reshifted result geometry, which means that it is possible
+     * that the returned Geometry is invalid.
+     *
+     * @param result the result Geometry to modify
+     * @return the result Geometry with the required precision
+     */
+    geom::Geometry* computeResultPrecision(
+        geom::Geometry* result);
 };
 
 } // namespace geos.precision
diff --git a/include/geos/precision/CommonBitsRemover.h b/include/geos/precision/CommonBitsRemover.h
index c071932..a723b1f 100644
--- a/include/geos/precision/CommonBitsRemover.h
+++ b/include/geos/precision/CommonBitsRemover.h
@@ -20,13 +20,13 @@
 
 // Forward declarations
 namespace geos {
-	namespace geom {
-		class Geometry;
-	}
-	namespace precision {
-		class CommonBitsRemover;
-		class CommonCoordinateFilter;
-	}
+namespace geom {
+class Geometry;
+}
+namespace precision {
+class CommonBitsRemover;
+class CommonCoordinateFilter;
+}
 }
 
 namespace geos {
@@ -41,49 +41,49 @@ class GEOS_DLL CommonBitsRemover {
 
 private:
 
-	geom::Coordinate commonCoord;
+    geom::Coordinate commonCoord;
 
-	CommonCoordinateFilter *ccFilter;
+    CommonCoordinateFilter* ccFilter;
 
 public:
 
-	CommonBitsRemover();
-
-	~CommonBitsRemover();
-
-	/**
-	 * Add a geometry 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
-	 * geometries.
-	 *
-	 * @param geom a Geometry to test for common bits
-	 */
-	void add(const geom::Geometry *geom);
-
-	/**
-	 * The common bits of the Coordinates in the supplied Geometries.
-	 */
-	geom::Coordinate& getCommonCoordinate();
-
-	/** \brief
-	 * Removes the common coordinate bits from a Geometry.
-	 * The coordinates of the Geometry are changed.
-	 *
-	 * @param geom the Geometry from which to remove the common
-	 *             coordinate bits
-	 * @return the shifted Geometry
-	 */
-	geom::Geometry* removeCommonBits(geom::Geometry *geom);
-
-	/** \brief
-	 * Adds the common coordinate bits back into a Geometry.
-	 * The coordinates of the Geometry are changed.
-	 *
-	 * @param geom the Geometry to which to add the common coordinate bits
-	 * @return the shifted Geometry
-	 */
-	geom::Geometry* addCommonBits(geom::Geometry *geom);
+    CommonBitsRemover();
+
+    ~CommonBitsRemover();
+
+    /**
+     * Add a geometry 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
+     * geometries.
+     *
+     * @param geom a Geometry to test for common bits
+     */
+    void add(const geom::Geometry* geom);
+
+    /**
+     * The common bits of the Coordinates in the supplied Geometries.
+     */
+    geom::Coordinate& getCommonCoordinate();
+
+    /** \brief
+     * Removes the common coordinate bits from a Geometry.
+     * The coordinates of the Geometry are changed.
+     *
+     * @param geom the Geometry from which to remove the common
+     *             coordinate bits
+     * @return the shifted Geometry
+     */
+    geom::Geometry* removeCommonBits(geom::Geometry* geom);
+
+    /** \brief
+     * Adds the common coordinate bits back into a Geometry.
+     * The coordinates of the Geometry are changed.
+     *
+     * @param geom the Geometry to which to add the common coordinate bits
+     * @return the shifted Geometry
+     */
+    geom::Geometry* addCommonBits(geom::Geometry* geom);
 };
 
 } // namespace geos.precision
diff --git a/include/geos/precision/EnhancedPrecisionOp.h b/include/geos/precision/EnhancedPrecisionOp.h
index 50f691e..df8ba79 100644
--- a/include/geos/precision/EnhancedPrecisionOp.h
+++ b/include/geos/precision/EnhancedPrecisionOp.h
@@ -24,9 +24,9 @@
 
 // Forward declarations
 namespace geos {
-	namespace geom {
-		class Geometry;
-	}
+namespace geom {
+class Geometry;
+}
 }
 
 namespace geos {
@@ -41,67 +41,67 @@ class GEOS_DLL EnhancedPrecisionOp {
 
 public:
 
-	/** \brief
-	 * Computes the set-theoretic intersection of two
-	 * Geometrys, using enhanced precision.
-	 *
-	 * @param geom0 the first Geometry
-	 * @param geom1 the second Geometry
-	 * @return the Geometry representing the set-theoretic
-	 * intersection of the input Geometries.
-	 */
-	static geom::Geometry* intersection(
-			const geom::Geometry *geom0,
-			const geom::Geometry *geom1);
+    /** \brief
+     * Computes the set-theoretic intersection of two
+     * Geometrys, using enhanced precision.
+     *
+     * @param geom0 the first Geometry
+     * @param geom1 the second Geometry
+     * @return the Geometry representing the set-theoretic
+     * intersection of the input Geometries.
+     */
+    static geom::Geometry* intersection(
+        const geom::Geometry* geom0,
+        const geom::Geometry* geom1);
 
-	/**
-	 * Computes the set-theoretic union of two Geometrys,
-	 * using enhanced precision.
-	 * @param geom0 the first Geometry
-	 * @param geom1 the second Geometry
-	 * @return the Geometry representing the set-theoretic
-	 * union of the input Geometries.
-	 */
-	static geom::Geometry* Union(
-			const geom::Geometry *geom0,
-			const geom::Geometry *geom1);
+    /**
+     * Computes the set-theoretic union of two Geometrys,
+     * using enhanced precision.
+     * @param geom0 the first Geometry
+     * @param geom1 the second Geometry
+     * @return the Geometry representing the set-theoretic
+     * union of the input Geometries.
+     */
+    static geom::Geometry* Union(
+        const geom::Geometry* geom0,
+        const geom::Geometry* geom1);
 
-	/**
-	 * Computes the set-theoretic difference of two Geometrys,
-	 * using enhanced precision.
-	 * @param geom0 the first Geometry
-	 * @param geom1 the second Geometry
-	 * @return the Geometry representing the set-theoretic
-	 * difference of the input Geometries.
-	 */
-	static geom::Geometry* difference(
-			const geom::Geometry *geom0,
-			const geom::Geometry *geom1);
+    /**
+     * Computes the set-theoretic difference of two Geometrys,
+     * using enhanced precision.
+     * @param geom0 the first Geometry
+     * @param geom1 the second Geometry
+     * @return the Geometry representing the set-theoretic
+     * difference of the input Geometries.
+     */
+    static geom::Geometry* difference(
+        const geom::Geometry* geom0,
+        const geom::Geometry* geom1);
 
-	/**
-	 * Computes the set-theoretic symmetric difference of two
-	 * Geometrys, using enhanced precision.
-	 * @param geom0 the first Geometry
-	 * @param geom1 the second Geometry
-	 * @return the Geometry representing the set-theoretic symmetric
-	 * difference of the input Geometries.
-	 */
-	static geom::Geometry* symDifference(
-			const geom::Geometry *geom0,
-			const geom::Geometry *geom1);
+    /**
+     * Computes the set-theoretic symmetric difference of two
+     * Geometrys, using enhanced precision.
+     * @param geom0 the first Geometry
+     * @param geom1 the second Geometry
+     * @return the Geometry representing the set-theoretic symmetric
+     * difference of the input Geometries.
+     */
+    static geom::Geometry* symDifference(
+        const geom::Geometry* geom0,
+        const geom::Geometry* geom1);
 
-	/**
-	 * Computes the buffer of a Geometry, using enhanced precision.
-	 * This method should no longer be necessary, since the buffer
-	 * algorithm now is highly robust.
-	 *
-	 * @param geom0 the first Geometry
-	 * @param distance the buffer distance
-	 * @return the Geometry representing the buffer of the input Geometry.
-	 */
-	static geom::Geometry* buffer(
-			const geom::Geometry *geom,
-			double distance);
+    /**
+     * Computes the buffer of a Geometry, using enhanced precision.
+     * This method should no longer be necessary, since the buffer
+     * algorithm now is highly robust.
+     *
+     * @param geom0 the first Geometry
+     * @param distance the buffer distance
+     * @return the Geometry representing the buffer of the input Geometry.
+     */
+    static geom::Geometry* buffer(
+        const geom::Geometry* geom,
+        double distance);
 };
 
 
diff --git a/include/geos/precision/GeometryPrecisionReducer.h b/include/geos/precision/GeometryPrecisionReducer.h
index 861c327..5999839 100644
--- a/include/geos/precision/GeometryPrecisionReducer.h
+++ b/include/geos/precision/GeometryPrecisionReducer.h
@@ -25,11 +25,11 @@
 
 // Forward declarations
 namespace geos {
-  namespace geom {
-    class PrecisionModel;
-    class GeometryFactory;
-    class Geometry;
-  }
+namespace geom {
+class PrecisionModel;
+class GeometryFactory;
+class Geometry;
+}
 }
 
 namespace geos {
@@ -44,116 +44,121 @@ class GEOS_DLL GeometryPrecisionReducer {
 
 private:
 
-  // Externally owned
-  const geom::GeometryFactory *newFactory;
+    // Externally owned
+    const geom::GeometryFactory* newFactory;
 
-  const geom::PrecisionModel &targetPM;
+    const geom::PrecisionModel& targetPM;
 
-  bool removeCollapsed;
+    bool removeCollapsed;
 
-  bool isPointwise;
+    bool isPointwise;
 
-  std::unique_ptr<geom::Geometry> reducePointwise( const geom::Geometry& geom );
+    std::unique_ptr<geom::Geometry> reducePointwise(const geom::Geometry& geom);
 
-  std::unique_ptr<geom::Geometry> fixPolygonalTopology(
-                                                 const geom::Geometry& geom );
+    std::unique_ptr<geom::Geometry> fixPolygonalTopology(
+        const geom::Geometry& geom);
 
-  geom::GeometryFactory::Ptr createFactory(
-                                          const geom::GeometryFactory& oldGF,
-                                          const geom::PrecisionModel& newPM );
+    geom::GeometryFactory::Ptr createFactory(
+        const geom::GeometryFactory& oldGF,
+        const geom::PrecisionModel& newPM);
 
-  GeometryPrecisionReducer(GeometryPrecisionReducer const&); /*= delete*/
-  GeometryPrecisionReducer& operator=(GeometryPrecisionReducer const&); /*= delete*/
+    GeometryPrecisionReducer(GeometryPrecisionReducer const&); /*= delete*/
+    GeometryPrecisionReducer& operator=(GeometryPrecisionReducer const&); /*= delete*/
 
 public:
 
-  /**
-   * Convenience method for doing precision reduction
-   * on a single geometry,
-   * with collapses removed
-   * and keeping the geometry precision model the same,
-   * and preserving polygonal topology.
-   *
-   * @param g the geometry to reduce
-   * @param precModel the precision model to use
-   * @return the reduced geometry
-   */
-  static std::unique_ptr<geom::Geometry> reduce(
-                                const geom::Geometry &g,
-                                const geom::PrecisionModel &precModel )
-  {
-    GeometryPrecisionReducer reducer(precModel);
-    return reducer.reduce(g);
-  }
-
-  /**
-   * Convenience method for doing precision reduction
-   * on a single geometry,
-   * with collapses removed
-   * and keeping the geometry precision model the same,
-   * but NOT preserving valid polygonal topology.
-   *
-   * @param g the geometry to reduce
-   * @param precModel the precision model to use
-   * @return the reduced geometry
-   */
-  static std::unique_ptr<geom::Geometry> reducePointwise(
-                                const geom::Geometry &g,
-                                const geom::PrecisionModel &precModel )
-  {
-    GeometryPrecisionReducer reducer(precModel);
-    reducer.setPointwise(true);
-    return reducer.reduce(g);
-  }
-
-  GeometryPrecisionReducer(const geom::PrecisionModel &pm)
-      :
-      newFactory(nullptr),
-      targetPM(pm),
-      removeCollapsed(true),
-      isPointwise(false)
-  {}
-
-  /**
-   * \brief
-   * Create a reducer that will change the precision model of the
-   * new reduced Geometry
-   *
-   * @param gf the factory for the created Geometry.
-   *           Its PrecisionModel will be used for the reduction.
-   *           NOTE: ownership left to caller must be kept alive for
-   *           the whole lifetime of the returned Geometry.
-   */
-  GeometryPrecisionReducer(const geom::GeometryFactory &gf);
-
-  /**
-   * Sets whether the reduction will result in collapsed components
-   * being removed completely, or simply being collapsed to an (invalid)
-   * Geometry of the same type.
-   *
-   * @param remove if <code>true</code> collapsed components will be removed
-   */
-  void setRemoveCollapsedComponents(bool remove) {
-    removeCollapsed = remove;
-  }
-
-  /** \brief
-   * Sets whether the precision reduction will be done
-   * in pointwise fashion only.
-   *
-   * Pointwise precision reduction reduces the precision
-   * of the individual coordinates only, but does
-   * not attempt to recreate valid topology.
-   * This is only relevant for geometries containing polygonal components.
-   *
-   * @param pointwise if reduction should be done pointwise only
-   */
-  void setPointwise(bool pointwise)
-  {
-    isPointwise = pointwise;
-  }
-
-  std::unique_ptr<geom::Geometry> reduce(const geom::Geometry& geom);
+    /**
+     * Convenience method for doing precision reduction
+     * on a single geometry,
+     * with collapses removed
+     * and keeping the geometry precision model the same,
+     * and preserving polygonal topology.
+     *
+     * @param g the geometry to reduce
+     * @param precModel the precision model to use
+     * @return the reduced geometry
+     */
+    static std::unique_ptr<geom::Geometry>
+    reduce(
+        const geom::Geometry& g,
+        const geom::PrecisionModel& precModel)
+    {
+        GeometryPrecisionReducer reducer(precModel);
+        return reducer.reduce(g);
+    }
+
+    /**
+     * Convenience method for doing precision reduction
+     * on a single geometry,
+     * with collapses removed
+     * and keeping the geometry precision model the same,
+     * but NOT preserving valid polygonal topology.
+     *
+     * @param g the geometry to reduce
+     * @param precModel the precision model to use
+     * @return the reduced geometry
+     */
+    static std::unique_ptr<geom::Geometry>
+    reducePointwise(
+        const geom::Geometry& g,
+        const geom::PrecisionModel& precModel)
+    {
+        GeometryPrecisionReducer reducer(precModel);
+        reducer.setPointwise(true);
+        return reducer.reduce(g);
+    }
+
+    GeometryPrecisionReducer(const geom::PrecisionModel& pm)
+        :
+        newFactory(nullptr),
+        targetPM(pm),
+        removeCollapsed(true),
+        isPointwise(false)
+    {}
+
+    /**
+     * \brief
+     * Create a reducer that will change the precision model of the
+     * new reduced Geometry
+     *
+     * @param gf the factory for the created Geometry.
+     *           Its PrecisionModel will be used for the reduction.
+     *           NOTE: ownership left to caller must be kept alive for
+     *           the whole lifetime of the returned Geometry.
+     */
+    GeometryPrecisionReducer(const geom::GeometryFactory& gf);
+
+    /**
+     * Sets whether the reduction will result in collapsed components
+     * being removed completely, or simply being collapsed to an (invalid)
+     * Geometry of the same type.
+     *
+     * @param remove if <code>true</code> collapsed components will be removed
+     */
+    void
+    setRemoveCollapsedComponents(bool remove)
+    {
+        removeCollapsed = remove;
+    }
+
+    /** \brief
+     * Sets whether the precision reduction will be done
+     * in pointwise fashion only.
+     *
+     * Pointwise precision reduction reduces the precision
+     * of the individual coordinates only, but does
+     * not attempt to recreate valid topology.
+     * This is only relevant for geometries containing polygonal components.
+     *
+     * @param pointwise if reduction should be done pointwise only
+     */
+    void
+    setPointwise(bool pointwise)
+    {
+        isPointwise = pointwise;
+    }
+
+    std::unique_ptr<geom::Geometry> reduce(const geom::Geometry& geom);
 
 };
 
diff --git a/include/geos/precision/MinimumClearance.h b/include/geos/precision/MinimumClearance.h
index d33ac9b..9fcd226 100644
--- a/include/geos/precision/MinimumClearance.h
+++ b/include/geos/precision/MinimumClearance.h
@@ -26,31 +26,31 @@
 namespace geos {
 namespace precision {
 class GEOS_DLL MinimumClearance {
-    private:
-        const geom::Geometry* inputGeom;
-        double minClearance;
-        std::unique_ptr<geom::CoordinateSequence> minClearancePts;
-
-        void compute();
-    public:
-        MinimumClearance(const geom::Geometry* g);
-
-        /**
-         * Gets the Minimum Clearance distance.
-         *
-         * @return the value of the minimum clearance distance
-         * or <tt>DBL_MAX</tt> if no Minimum Clearance distance exists
-         */
-        double getDistance();
-
-        /**
-         * Gets a LineString containing two points
-         * which are at the Minimum Clearance distance.
-         *
-         * @return the value of the minimum clearance distance
-         * or <tt>LINESTRING EMPTY</tt> if no Minimum Clearance distance exists
-         */
-        std::unique_ptr<geom::LineString> getLine();
+private:
+    const geom::Geometry* inputGeom;
+    double minClearance;
+    std::unique_ptr<geom::CoordinateSequence> minClearancePts;
+
+    void compute();
+public:
+    MinimumClearance(const geom::Geometry* g);
+
+    /**
+     * Gets the Minimum Clearance distance.
+     *
+     * @return the value of the minimum clearance distance
+     * or <tt>DBL_MAX</tt> if no Minimum Clearance distance exists
+     */
+    double getDistance();
+
+    /**
+     * Gets a LineString containing two points
+     * which are at the Minimum Clearance distance.
+     *
+     * @return the value of the minimum clearance distance
+     * or <tt>LINESTRING EMPTY</tt> if no Minimum Clearance distance exists
+     */
+    std::unique_ptr<geom::LineString> getLine();
 };
 }
 }
diff --git a/include/geos/precision/PrecisionReducerCoordinateOperation.h b/include/geos/precision/PrecisionReducerCoordinateOperation.h
index 90cb5ee..195c502 100644
--- a/include/geos/precision/PrecisionReducerCoordinateOperation.h
+++ b/include/geos/precision/PrecisionReducerCoordinateOperation.h
@@ -23,43 +23,42 @@
 
 // Forward declarations
 namespace geos {
-  namespace geom {
-    class PrecisionModel;
-    class CoordinateSequence;
-    class Geometry;
-  }
+namespace geom {
+class PrecisionModel;
+class CoordinateSequence;
+class Geometry;
+}
 }
 
 namespace geos {
 namespace precision { // geos.precision
 
 class PrecisionReducerCoordinateOperation :
-		public geom::util::CoordinateOperation
-{
-using CoordinateOperation::edit;
+    public geom::util::CoordinateOperation {
+    using CoordinateOperation::edit;
 private:
 
-	const geom::PrecisionModel& targetPM;
+    const geom::PrecisionModel& targetPM;
 
-	bool removeCollapsed;
+    bool removeCollapsed;
 
     PrecisionReducerCoordinateOperation(PrecisionReducerCoordinateOperation const&); /*= delete*/
     PrecisionReducerCoordinateOperation& operator=(PrecisionReducerCoordinateOperation const&); /*= delete*/
 
 public:
 
-	PrecisionReducerCoordinateOperation( const geom::PrecisionModel& pm,
-                                       bool doRemoveCollapsed )
-      :
-      targetPM(pm),
-      removeCollapsed(doRemoveCollapsed)
-  {}
+    PrecisionReducerCoordinateOperation(const geom::PrecisionModel& pm,
+                                        bool doRemoveCollapsed)
+        :
+        targetPM(pm),
+        removeCollapsed(doRemoveCollapsed)
+    {}
 
-	/// Ownership of returned CoordinateSequence to caller
-  //
-  /// virtual function
-	geom::CoordinateSequence* edit(const geom::CoordinateSequence *coordinates,
-	                         const geom::Geometry *geom) override;
+    /// Ownership of returned CoordinateSequence to caller
+    //
+    /// virtual function
+    geom::CoordinateSequence* edit(const geom::CoordinateSequence* coordinates,
+                                   const geom::Geometry* geom) override;
 };
 
 } // namespace geos.precision
diff --git a/include/geos/precision/SimpleGeometryPrecisionReducer.h b/include/geos/precision/SimpleGeometryPrecisionReducer.h
index c212ee5..83e1367 100644
--- a/include/geos/precision/SimpleGeometryPrecisionReducer.h
+++ b/include/geos/precision/SimpleGeometryPrecisionReducer.h
@@ -19,10 +19,10 @@
 
 // Forward declarations
 namespace geos {
-	namespace geom {
-		class PrecisionModel;
-		class Geometry;
-	}
+namespace geom {
+class PrecisionModel;
+class Geometry;
+}
 }
 
 namespace geos {
@@ -45,42 +45,42 @@ class GEOS_DLL SimpleGeometryPrecisionReducer {
 
 private:
 
-	const geom::PrecisionModel *newPrecisionModel;
+    const geom::PrecisionModel* newPrecisionModel;
 
-	bool removeCollapsed;
+    bool removeCollapsed;
 
-	//bool changePrecisionModel;
+    //bool changePrecisionModel;
 
 public:
 
-	SimpleGeometryPrecisionReducer(const geom::PrecisionModel *pm);
-
-	/**
-	 * Sets whether the reduction will result in collapsed components
-	 * being removed completely, or simply being collapsed to an (invalid)
-	 * Geometry of the same type.
-	 *
-	 * @param removeCollapsed if <code>true</code> collapsed
-	 * components will be removed
-	 */
-	void setRemoveCollapsedComponents(bool nRemoveCollapsed);
-
-	/*
-	 * Sets whether the {@link PrecisionModel} of the new reduced Geometry
-	 * will be changed to be the {@link PrecisionModel} supplied to
-	 * specify the reduction.  The default is to not change the
-	 * precision model
-	 *
-	 * @param changePrecisionModel if <code>true</code> the precision
-	 * model of the created Geometry will be the
-	 * the precisionModel supplied in the constructor.
-	 */
-	//void setChangePrecisionModel(bool nChangePrecisionModel);
-
-	const geom::PrecisionModel* getPrecisionModel();
-
-	bool getRemoveCollapsed();
-	geom::Geometry* reduce(const geom::Geometry *geom);
+    SimpleGeometryPrecisionReducer(const geom::PrecisionModel* pm);
+
+    /**
+     * Sets whether the reduction will result in collapsed components
+     * being removed completely, or simply being collapsed to an (invalid)
+     * Geometry of the same type.
+     *
+     * @param removeCollapsed if <code>true</code> collapsed
+     * components will be removed
+     */
+    void setRemoveCollapsedComponents(bool nRemoveCollapsed);
+
+    /*
+     * Sets whether the {@link PrecisionModel} of the new reduced Geometry
+     * will be changed to be the {@link PrecisionModel} supplied to
+     * specify the reduction.  The default is to not change the
+     * precision model
+     *
+     * @param changePrecisionModel if <code>true</code> the precision
+     * model of the created Geometry will be the
+     * the precisionModel supplied in the constructor.
+     */
+    //void setChangePrecisionModel(bool nChangePrecisionModel);
+
+    const geom::PrecisionModel* getPrecisionModel();
+
+    bool getRemoveCollapsed();
+    geom::Geometry* reduce(const geom::Geometry* geom);
 };
 
 } // namespace geos.precision
diff --git a/include/geos/profiler.h b/include/geos/profiler.h
index b6f951a..853d598 100644
--- a/include/geos/profiler.h
+++ b/include/geos/profiler.h
@@ -26,10 +26,10 @@
 
 #include <sys/time.h>
 extern "C" {
-  extern _CRTIMP void __cdecl	_tzset (void);
-  __MINGW_IMPORT int	_daylight;
-  __MINGW_IMPORT long	_timezone;
-  __MINGW_IMPORT char 	*_tzname[2];
+    extern _CRTIMP void __cdecl	_tzset(void);
+    __MINGW_IMPORT int	_daylight;
+    __MINGW_IMPORT long	_timezone;
+    __MINGW_IMPORT char* 	_tzname[2];
 }
 #endif
 
@@ -65,74 +65,82 @@ namespace util {
  */
 class GEOS_DLL Profile {
 public:
-	/** \brief Create a named profile */
-	Profile(std::string name);
-
-	/** \brief Destructor */
-	~Profile();
-
-	/** \brief start a new timer */
-	void start() {
-		gettimeofday(&starttime, nullptr);
-	}
-
-	/** \brief stop current timer */
-	void stop()
-	{
-		gettimeofday(&stoptime, nullptr);
-		double elapsed = static_cast<double>(
-				1000000 * (stoptime.tv_sec - starttime.tv_sec)
-				+ (stoptime.tv_usec - starttime.tv_usec));
-
-		timings.push_back(elapsed);
-		totaltime += elapsed;
-		if ( timings.size() == 1 ) max = min = elapsed;
-		else
-		{
-			if ( elapsed > max ) max = elapsed;
-			if ( elapsed < min ) min = elapsed;
-		}
-		avg = totaltime / static_cast<double>(timings.size());
-	}
-
-	/** \brief Return Max stored timing */
-	double getMax() const;
-
-	/** \brief Return Min stored timing */
-	double getMin() const;
-
-	/** \brief Return total timing */
-	double getTot() const;
-
-	/** \brief Return average timing */
-	double getAvg() const;
-
-	/** \brief Return number of timings */
-	size_t getNumTimings() const;
-
-	/** \brief Profile name */
-	std::string name;
+    /** \brief Create a named profile */
+    Profile(std::string name);
+
+    /** \brief Destructor */
+    ~Profile();
+
+    /** \brief start a new timer */
+    void
+    start()
+    {
+        gettimeofday(&starttime, nullptr);
+    }
+
+    /** \brief stop current timer */
+    void
+    stop()
+    {
+        gettimeofday(&stoptime, nullptr);
+        double elapsed = static_cast<double>(
+                             1000000 * (stoptime.tv_sec - starttime.tv_sec)
+                             + (stoptime.tv_usec - starttime.tv_usec));
+
+        timings.push_back(elapsed);
+        totaltime += elapsed;
+        if(timings.size() == 1) {
+            max = min = elapsed;
+        }
+        else {
+            if(elapsed > max) {
+                max = elapsed;
+            }
+            if(elapsed < min) {
+                min = elapsed;
+            }
+        }
+        avg = totaltime / static_cast<double>(timings.size());
+    }
+
+    /** \brief Return Max stored timing */
+    double getMax() const;
+
+    /** \brief Return Min stored timing */
+    double getMin() const;
+
+    /** \brief Return total timing */
+    double getTot() const;
+
+    /** \brief Return average timing */
+    double getAvg() const;
+
+    /** \brief Return number of timings */
+    size_t getNumTimings() const;
+
+    /** \brief Profile name */
+    std::string name;
 
 
 private:
 
-	/* \brief current start and stop times */
-	struct timeval starttime, stoptime;
+    /* \brief current start and stop times */
+    struct timeval starttime, stoptime;
 
-	/* \brief actual times */
-	std::vector<double> timings;
+    /* \brief actual times */
+    std::vector<double> timings;
 
-	/* \brief total time */
-	double totaltime;
+    /* \brief total time */
+    double totaltime;
 
-	/* \brief max time */
-	double max;
+    /* \brief max time */
+    double max;
 
-	/* \brief max time */
-	double min;
+    /* \brief max time */
+    double min;
 
-	/* \brief max time */
-	double avg;
+    /* \brief max time */
+    double avg;
 
 };
 
@@ -146,34 +154,34 @@ class GEOS_DLL Profiler {
 
 public:
 
-	Profiler();
-	~Profiler();
-
-	/**
-	 * \brief
-	 * Return the singleton instance of the
-	 * profiler.
-	 */
-	static Profiler *instance(void);
-
-	/**
-	 * \brief
-	 * Start timer for named task. The task is
-	 * created if does not exist.
-	 */
-	void start(std::string name);
-
-	/**
-	 * \brief
-	 * Stop timer for named task.
-	 * Elapsed time is registered in the given task.
-	 */
-	void stop(std::string name);
-
-	/** \brief get Profile of named task */
-	Profile *get(std::string name);
-
-	std::map<std::string, Profile *> profs;
+    Profiler();
+    ~Profiler();
+
+    /**
+     * \brief
+     * Return the singleton instance of the
+     * profiler.
+     */
+    static Profiler* instance(void);
+
+    /**
+     * \brief
+     * Start timer for named task. The task is
+     * created if does not exist.
+     */
+    void start(std::string name);
+
+    /**
+     * \brief
+     * Stop timer for named task.
+     * Elapsed time is registered in the given task.
+     */
+    void stop(std::string name);
+
+    /** \brief get Profile of named task */
+    Profile* get(std::string name);
+
+    std::map<std::string, Profile*> profs;
 };
 
 
diff --git a/include/geos/simplify/DouglasPeuckerLineSimplifier.h b/include/geos/simplify/DouglasPeuckerLineSimplifier.h
index 4bc39d3..6d67482 100644
--- a/include/geos/simplify/DouglasPeuckerLineSimplifier.h
+++ b/include/geos/simplify/DouglasPeuckerLineSimplifier.h
@@ -30,9 +30,9 @@
 
 // Forward declarations
 namespace geos {
-	namespace geom {
-		class Coordinate;
-	}
+namespace geom {
+class Coordinate;
+}
 }
 
 namespace geos {
@@ -46,46 +46,46 @@ class GEOS_DLL DouglasPeuckerLineSimplifier {
 
 public:
 
-	typedef std::vector<short int> BoolVect;
-	typedef std::unique_ptr<BoolVect> BoolVectAutoPtr;
+    typedef std::vector<short int> BoolVect;
+    typedef std::unique_ptr<BoolVect> BoolVectAutoPtr;
 
-	typedef std::vector<geom::Coordinate> CoordsVect;
-	typedef std::unique_ptr<CoordsVect> CoordsVectAutoPtr;
+    typedef std::vector<geom::Coordinate> CoordsVect;
+    typedef std::unique_ptr<CoordsVect> CoordsVectAutoPtr;
 
 
-	/** \brief
-	 * Returns a newly allocated Coordinate vector, wrapped
-	 * into an unique_ptr
-	 */
-	static CoordsVectAutoPtr simplify(
-			const CoordsVect& nPts,
-			double distanceTolerance);
+    /** \brief
+     * Returns a newly allocated Coordinate vector, wrapped
+     * into an unique_ptr
+     */
+    static CoordsVectAutoPtr simplify(
+        const CoordsVect& nPts,
+        double distanceTolerance);
 
-	DouglasPeuckerLineSimplifier(const CoordsVect& nPts);
+    DouglasPeuckerLineSimplifier(const CoordsVect& nPts);
 
-	/** \brief
-	 * Sets the distance tolerance for the simplification.
-	 *
-	 * All vertices in the simplified linestring will be within this
-	 * distance of the original linestring.
-	 *
-	 * @param nDistanceTolerance the approximation tolerance to use
-	 */
-	void setDistanceTolerance(double nDistanceTolerance);
+    /** \brief
+     * Sets the distance tolerance for the simplification.
+     *
+     * All vertices in the simplified linestring will be within this
+     * distance of the original linestring.
+     *
+     * @param nDistanceTolerance the approximation tolerance to use
+     */
+    void setDistanceTolerance(double nDistanceTolerance);
 
-	/** \brief
-	 * Returns a newly allocated Coordinate vector, wrapped
-	 * into an unique_ptr
-	 */
-	CoordsVectAutoPtr simplify();
+    /** \brief
+     * Returns a newly allocated Coordinate vector, wrapped
+     * into an unique_ptr
+     */
+    CoordsVectAutoPtr simplify();
 
 private:
 
-	const CoordsVect& pts;
-	BoolVectAutoPtr usePt;
-	double distanceTolerance;
+    const CoordsVect& pts;
+    BoolVectAutoPtr usePt;
+    double distanceTolerance;
 
-	void simplifySection(std::size_t i, std::size_t j);
+    void simplifySection(std::size_t i, std::size_t j);
 
     // Declare type as noncopyable
     DouglasPeuckerLineSimplifier(const DouglasPeuckerLineSimplifier& other) = delete;
diff --git a/include/geos/simplify/DouglasPeuckerSimplifier.h b/include/geos/simplify/DouglasPeuckerSimplifier.h
index d6c80f5..0190072 100644
--- a/include/geos/simplify/DouglasPeuckerSimplifier.h
+++ b/include/geos/simplify/DouglasPeuckerSimplifier.h
@@ -24,9 +24,9 @@
 
 // Forward declarations
 namespace geos {
-	namespace geom {
-		class Geometry;
-	}
+namespace geom {
+class Geometry;
+}
 }
 
 namespace geos {
@@ -51,32 +51,32 @@ class GEOS_DLL DouglasPeuckerSimplifier {
 
 public:
 
-	static std::unique_ptr<geom::Geometry> simplify(
-			const geom::Geometry* geom,
-			double tolerance);
+    static std::unique_ptr<geom::Geometry> simplify(
+        const geom::Geometry* geom,
+        double tolerance);
 
-	DouglasPeuckerSimplifier(const geom::Geometry* geom);
+    DouglasPeuckerSimplifier(const geom::Geometry* geom);
 
-	/** \brief
-	 * Sets the distance tolerance for the simplification.
-	 *
-	 * All vertices in the simplified geometry will be within this
-	 * distance of the original geometry.
-	 * The tolerance value must be non-negative.  A tolerance value
-	 * of zero is effectively a no-op.
-	 *
-	 * @param distanceTolerance the approximation tolerance to use
-	 */
-	void setDistanceTolerance(double tolerance);
+    /** \brief
+     * Sets the distance tolerance for the simplification.
+     *
+     * All vertices in the simplified geometry will be within this
+     * distance of the original geometry.
+     * The tolerance value must be non-negative.  A tolerance value
+     * of zero is effectively a no-op.
+     *
+     * @param distanceTolerance the approximation tolerance to use
+     */
+    void setDistanceTolerance(double tolerance);
 
-	std::unique_ptr<geom::Geometry> getResultGeometry();
+    std::unique_ptr<geom::Geometry> getResultGeometry();
 
 
 private:
 
-	const geom::Geometry* inputGeom;
+    const geom::Geometry* inputGeom;
 
-	double distanceTolerance;
+    double distanceTolerance;
 };
 
 
diff --git a/include/geos/simplify/LineSegmentIndex.h b/include/geos/simplify/LineSegmentIndex.h
index 307e9a8..aa25133 100644
--- a/include/geos/simplify/LineSegmentIndex.h
+++ b/include/geos/simplify/LineSegmentIndex.h
@@ -36,12 +36,12 @@
 
 // Forward declarations
 namespace geos {
-	namespace geom {
-		class LineSegment;
-	}
-	namespace simplify {
-		class TaggedLineString;
-	}
+namespace geom {
+class LineSegment;
+}
+namespace simplify {
+class TaggedLineString;
+}
 }
 
 namespace geos {
@@ -51,32 +51,32 @@ class GEOS_DLL LineSegmentIndex {
 
 public:
 
-	LineSegmentIndex() = default;
+    LineSegmentIndex() = default;
 
-	~LineSegmentIndex() = default;
+    ~LineSegmentIndex() = default;
 
-	void add(const TaggedLineString& line);
+    void add(const TaggedLineString& line);
 
-	void add(const geom::LineSegment* seg);
+    void add(const geom::LineSegment* seg);
 
-	void remove(const geom::LineSegment* seg);
+    void remove(const geom::LineSegment* seg);
 
-	std::unique_ptr< std::vector<geom::LineSegment*> >
-			query(const geom::LineSegment* seg);
+    std::unique_ptr< std::vector<geom::LineSegment*> >
+    query(const geom::LineSegment* seg);
 
 
 private:
 
-	index::quadtree::Quadtree index;
+    index::quadtree::Quadtree index;
 
-	std::vector<std::unique_ptr<geom::Envelope>> newEnvelopes;
+    std::vector<std::unique_ptr<geom::Envelope>> newEnvelopes;
 
     /**
      * Disable copy construction and assignment. Apparently needed to make this
      * class compile under MSVC. (See https://stackoverflow.com/q/29565299)
      */
-	LineSegmentIndex(const LineSegmentIndex&) = delete;
-	LineSegmentIndex& operator=(const LineSegmentIndex&) = delete;
+    LineSegmentIndex(const LineSegmentIndex&) = delete;
+    LineSegmentIndex& operator=(const LineSegmentIndex&) = delete;
 };
 
 } // namespace geos::simplify
diff --git a/include/geos/simplify/TaggedLineSegment.h b/include/geos/simplify/TaggedLineSegment.h
index 46bd2e5..d4be09a 100644
--- a/include/geos/simplify/TaggedLineSegment.h
+++ b/include/geos/simplify/TaggedLineSegment.h
@@ -35,10 +35,10 @@
 
 // Forward declarations
 namespace geos {
-	namespace geom {
-		class Coordinate;
-		class Geometry;
-	}
+namespace geom {
+class Coordinate;
+class Geometry;
+}
 }
 
 namespace geos {
@@ -51,30 +51,29 @@ namespace simplify { // geos::simplify
  * Used to index the segments in a geometry and recover the segment locations
  * from the index.
  */
-class GEOS_DLL TaggedLineSegment: public geom::LineSegment
-{
+class GEOS_DLL TaggedLineSegment: public geom::LineSegment {
 
 public:
 
-	TaggedLineSegment(const geom::Coordinate& p0,
-			const geom::Coordinate& p1,
-			const geom::Geometry* parent,
-			size_t index);
+    TaggedLineSegment(const geom::Coordinate& p0,
+                      const geom::Coordinate& p1,
+                      const geom::Geometry* parent,
+                      size_t index);
 
-	TaggedLineSegment(const geom::Coordinate& p0,
-			const geom::Coordinate& p1);
+    TaggedLineSegment(const geom::Coordinate& p0,
+                      const geom::Coordinate& p1);
 
-	TaggedLineSegment(const TaggedLineSegment& ls);
+    TaggedLineSegment(const TaggedLineSegment& ls);
 
-	const geom::Geometry* getParent() const;
+    const geom::Geometry* getParent() const;
 
-	size_t getIndex() const;
+    size_t getIndex() const;
 
 private:
 
-	const geom::Geometry* parent;
+    const geom::Geometry* parent;
 
-	size_t index;
+    size_t index;
 
 };
 
diff --git a/include/geos/simplify/TaggedLineString.h b/include/geos/simplify/TaggedLineString.h
index d21a904..1a3c8bf 100644
--- a/include/geos/simplify/TaggedLineString.h
+++ b/include/geos/simplify/TaggedLineString.h
@@ -36,16 +36,16 @@
 
 // Forward declarations
 namespace geos {
-	namespace geom {
-		class Coordinate;
-		class CoordinateSequence;
-		class Geometry;
-		class LineString;
-		class LinearRing;
-	}
-	namespace simplify {
-		class TaggedLineSegment;
-	}
+namespace geom {
+class Coordinate;
+class CoordinateSequence;
+class Geometry;
+class LineString;
+class LinearRing;
+}
+namespace simplify {
+class TaggedLineSegment;
+}
 }
 
 namespace geos {
@@ -61,63 +61,63 @@ class GEOS_DLL TaggedLineString {
 
 public:
 
-	typedef std::vector<geom::Coordinate> CoordVect;
+    typedef std::vector<geom::Coordinate> CoordVect;
 
-	typedef std::unique_ptr<CoordVect> CoordVectPtr;
+    typedef std::unique_ptr<CoordVect> CoordVectPtr;
 
-	typedef geom::CoordinateSequence CoordSeq;
+    typedef geom::CoordinateSequence CoordSeq;
 
-	typedef std::unique_ptr<geom::CoordinateSequence> CoordSeqPtr;
+    typedef std::unique_ptr<geom::CoordinateSequence> CoordSeqPtr;
 
-	TaggedLineString(const geom::LineString* nParentLine,
-			std::size_t minimumSize=2);
+    TaggedLineString(const geom::LineString* nParentLine,
+                     std::size_t minimumSize = 2);
 
-	~TaggedLineString();
+    ~TaggedLineString();
 
-	std::size_t getMinimumSize() const;
+    std::size_t getMinimumSize() const;
 
-	const geom::LineString* getParent() const;
+    const geom::LineString* getParent() const;
 
-	const CoordSeq* getParentCoordinates() const;
+    const CoordSeq* getParentCoordinates() const;
 
-	CoordSeqPtr getResultCoordinates() const;
+    CoordSeqPtr getResultCoordinates() const;
 
-	std::size_t getResultSize() const;
+    std::size_t getResultSize() const;
 
-	TaggedLineSegment* getSegment(std::size_t i);
+    TaggedLineSegment* getSegment(std::size_t i);
 
-	const TaggedLineSegment* getSegment(std::size_t i) const;
+    const TaggedLineSegment* getSegment(std::size_t i) const;
 
-	std::vector<TaggedLineSegment*>& getSegments();
+    std::vector<TaggedLineSegment*>& getSegments();
 
-	const std::vector<TaggedLineSegment*>& getSegments() const;
+    const std::vector<TaggedLineSegment*>& getSegments() const;
 
-	void addToResult(std::unique_ptr<TaggedLineSegment> seg);
+    void addToResult(std::unique_ptr<TaggedLineSegment> seg);
 
-	std::unique_ptr<geom::Geometry> asLineString() const;
+    std::unique_ptr<geom::Geometry> asLineString() const;
 
-	std::unique_ptr<geom::Geometry> asLinearRing() const;
+    std::unique_ptr<geom::Geometry> asLinearRing() const;
 
 private:
 
-	const geom::LineString* parentLine;
+    const geom::LineString* parentLine;
 
-	// TaggedLineSegments owned by this object
-	std::vector<TaggedLineSegment*> segs;
+    // TaggedLineSegments owned by this object
+    std::vector<TaggedLineSegment*> segs;
 
-	// TaggedLineSegments owned by this object
-	std::vector<TaggedLineSegment*> resultSegs;
+    // TaggedLineSegments owned by this object
+    std::vector<TaggedLineSegment*> resultSegs;
 
-	std::size_t minimumSize;
+    std::size_t minimumSize;
 
-	void init();
+    void init();
 
-	static CoordVectPtr extractCoordinates(
-			const std::vector<TaggedLineSegment*>& segs);
+    static CoordVectPtr extractCoordinates(
+        const std::vector<TaggedLineSegment*>& segs);
 
-	// Copying is turned off
-	TaggedLineString(const TaggedLineString&);
-	TaggedLineString& operator= (const TaggedLineString&);
+    // Copying is turned off
+    TaggedLineString(const TaggedLineString&);
+    TaggedLineString& operator= (const TaggedLineString&);
 
 };
 
diff --git a/include/geos/simplify/TaggedLineStringSimplifier.h b/include/geos/simplify/TaggedLineStringSimplifier.h
index dae0571..b1166f5 100644
--- a/include/geos/simplify/TaggedLineStringSimplifier.h
+++ b/include/geos/simplify/TaggedLineStringSimplifier.h
@@ -36,18 +36,18 @@
 
 // Forward declarations
 namespace geos {
-	namespace algorithm {
-		class LineIntersector;
-	}
-	namespace geom {
-		class CoordinateSequence;
-		class LineSegment;
-	}
-	namespace simplify {
-		class TaggedLineSegment;
-		class TaggedLineString;
-		class LineSegmentIndex;
-	}
+namespace algorithm {
+class LineIntersector;
+}
+namespace geom {
+class CoordinateSequence;
+class LineSegment;
+}
+namespace simplify {
+class TaggedLineSegment;
+class TaggedLineString;
+class LineSegmentIndex;
+}
 }
 
 namespace geos {
@@ -64,100 +64,100 @@ class GEOS_DLL TaggedLineStringSimplifier {
 
 public:
 
-	TaggedLineStringSimplifier(LineSegmentIndex* inputIndex,
-		LineSegmentIndex* outputIndex);
+    TaggedLineStringSimplifier(LineSegmentIndex* inputIndex,
+                               LineSegmentIndex* outputIndex);
 
-	/** \brief
-	 * Sets the distance tolerance for the simplification.
-	 *
-	 * All vertices in the simplified geometry will be within this
-	 * distance of the original geometry.
-	 *
-	 * @param d the approximation tolerance to use
-	 */
-	void setDistanceTolerance(double d);
+    /** \brief
+     * Sets the distance tolerance for the simplification.
+     *
+     * All vertices in the simplified geometry will be within this
+     * distance of the original geometry.
+     *
+     * @param d the approximation tolerance to use
+     */
+    void setDistanceTolerance(double d);
 
-	/**
-	 * Simplifies the given {@link TaggedLineString}
-	 * using the distance tolerance specified.
-	 *
-	 * @param line the linestring to simplify
-	 */
-	void simplify(TaggedLineString* line);
+    /**
+     * Simplifies the given {@link TaggedLineString}
+     * using the distance tolerance specified.
+     *
+     * @param line the linestring to simplify
+     */
+    void simplify(TaggedLineString* line);
 
 
 private:
 
-	// externally owned
-	LineSegmentIndex* inputIndex;
+    // externally owned
+    LineSegmentIndex* inputIndex;
 
-	// externally owned
-	LineSegmentIndex* outputIndex;
+    // externally owned
+    LineSegmentIndex* outputIndex;
 
-	std::unique_ptr<algorithm::LineIntersector> li;
+    std::unique_ptr<algorithm::LineIntersector> li;
 
-	/// non-const as segments are possibly added to it
-	TaggedLineString* line;
+    /// non-const as segments are possibly added to it
+    TaggedLineString* line;
 
-	const geom::CoordinateSequence* linePts;
+    const geom::CoordinateSequence* linePts;
 
-	double distanceTolerance;
+    double distanceTolerance;
 
-	void simplifySection(std::size_t i, std::size_t j,
-			std::size_t depth);
+    void simplifySection(std::size_t i, std::size_t j,
+                         std::size_t depth);
 
-	static std::size_t findFurthestPoint(
-			const geom::CoordinateSequence* pts,
-			std::size_t i, std::size_t j,
-			double& maxDistance);
+    static std::size_t findFurthestPoint(
+        const geom::CoordinateSequence* pts,
+        std::size_t i, std::size_t j,
+        double& maxDistance);
 
-	bool hasBadIntersection(const TaggedLineString* parentLine,
-                       const std::pair<std::size_t, std::size_t>& sectionIndex,
-                       const geom::LineSegment& candidateSeg);
+    bool hasBadIntersection(const TaggedLineString* parentLine,
+                            const std::pair<std::size_t, std::size_t>& sectionIndex,
+                            const geom::LineSegment& candidateSeg);
 
-	bool hasBadInputIntersection(const TaggedLineString* parentLine,
-                       const std::pair<std::size_t, std::size_t>& sectionIndex,
-                       const geom::LineSegment& candidateSeg);
+    bool hasBadInputIntersection(const TaggedLineString* parentLine,
+                                 const std::pair<std::size_t, std::size_t>& sectionIndex,
+                                 const geom::LineSegment& candidateSeg);
 
-	bool hasBadOutputIntersection(const geom::LineSegment& candidateSeg);
+    bool hasBadOutputIntersection(const geom::LineSegment& candidateSeg);
 
-	bool hasInteriorIntersection(const geom::LineSegment& seg0,
-			const geom::LineSegment& seg1) const;
+    bool hasInteriorIntersection(const geom::LineSegment& seg0,
+                                 const geom::LineSegment& seg1) const;
 
-	std::unique_ptr<TaggedLineSegment> flatten(
-			std::size_t start, std::size_t end);
+    std::unique_ptr<TaggedLineSegment> flatten(
+        std::size_t start, std::size_t end);
 
-	/** \brief
-	 * Tests whether a segment is in a section of a TaggedLineString
-	 *
-	 * @param line
-	 * @param sectionIndex
-	 * @param seg
-	 * @return
-	 */
-	static bool isInLineSection(
-		const TaggedLineString* parentLine,
-		const std::pair<std::size_t, std::size_t>& sectionIndex,
-		const TaggedLineSegment* seg);
+    /** \brief
+     * Tests whether a segment is in a section of a TaggedLineString
+     *
+     * @param line
+     * @param sectionIndex
+     * @param seg
+     * @return
+     */
+    static bool isInLineSection(
+        const TaggedLineString* parentLine,
+        const std::pair<std::size_t, std::size_t>& sectionIndex,
+        const TaggedLineSegment* seg);
 
-	/** \brief
-	 * Remove the segs in the section of the line
-	 *
-	 * @param line
-	 * @param pts
-	 * @param sectionStartIndex
-	 * @param sectionEndIndex
-	 */
-	void remove(const TaggedLineString* line,
-			std::size_t start,
-			std::size_t end);
+    /** \brief
+     * Remove the segs in the section of the line
+     *
+     * @param line
+     * @param pts
+     * @param sectionStartIndex
+     * @param sectionEndIndex
+     */
+    void remove(const TaggedLineString* line,
+                std::size_t start,
+                std::size_t end);
 
 };
 
 inline void
 TaggedLineStringSimplifier::setDistanceTolerance(double d)
 {
-	distanceTolerance = d;
+    distanceTolerance = d;
 }
 
 } // namespace geos::simplify
diff --git a/include/geos/simplify/TaggedLinesSimplifier.h b/include/geos/simplify/TaggedLinesSimplifier.h
index 11c2ce7..d8fa3f7 100644
--- a/include/geos/simplify/TaggedLinesSimplifier.h
+++ b/include/geos/simplify/TaggedLinesSimplifier.h
@@ -41,9 +41,9 @@
 
 // Forward declarations
 namespace geos {
-	namespace simplify {
-		class TaggedLineString;
-	}
+namespace simplify {
+class TaggedLineString;
+}
 }
 
 namespace geos {
@@ -57,59 +57,60 @@ class GEOS_DLL TaggedLinesSimplifier {
 
 public:
 
-	TaggedLinesSimplifier();
-
-	/** \brief
-	 * Sets the distance tolerance for the simplification.
-	 *
-	 * All vertices in the simplified geometry will be within this
-	 * distance of the original geometry.
-	 *
-	 * @param tolerance the approximation tolerance to use
-	 */
-	void setDistanceTolerance(double tolerance);
-
-	/**
-	 * Simplify a set of {@link TaggedLineString}s
-	 *
-	 * @param iterator_type
-	 * 	an iterator, must support assignment, increment,
-	 *      inequality and dereference operators.
-	 *	Dereference operator must return a TaggedLineString*
-	 *
-	 * @param begin iterator to the first element
-	 *              to be simplified.
-	 * @param end an iterator to one-past-last element
-	 *            to be simplified.
-	 */
-	template <class iterator_type>
-	void simplify(
-		iterator_type begin,
-		iterator_type end)
-	{
-		// add lines to the index
-		for (iterator_type it=begin; it != end; ++it) {
-			assert(*it);
-			inputIndex->add(*(*it));
-		}
-
-		// Simplify lines
-		for (iterator_type it=begin; it != end; ++it) {
-			assert(*it);
-			simplify(*(*it));
-		}
-	}
+    TaggedLinesSimplifier();
+
+    /** \brief
+     * Sets the distance tolerance for the simplification.
+     *
+     * All vertices in the simplified geometry will be within this
+     * distance of the original geometry.
+     *
+     * @param tolerance the approximation tolerance to use
+     */
+    void setDistanceTolerance(double tolerance);
+
+    /**
+     * Simplify a set of {@link TaggedLineString}s
+     *
+     * @param iterator_type
+     * 	an iterator, must support assignment, increment,
+     *      inequality and dereference operators.
+     *	Dereference operator must return a TaggedLineString*
+     *
+     * @param begin iterator to the first element
+     *              to be simplified.
+     * @param end an iterator to one-past-last element
+     *            to be simplified.
+     */
+    template <class iterator_type>
+    void
+    simplify(
+        iterator_type begin,
+        iterator_type end)
+    {
+        // add lines to the index
+        for(iterator_type it = begin; it != end; ++it) {
+            assert(*it);
+            inputIndex->add(*(*it));
+        }
+
+        // Simplify lines
+        for(iterator_type it = begin; it != end; ++it) {
+            assert(*it);
+            simplify(*(*it));
+        }
+    }
 
 
 private:
 
-	void simplify(TaggedLineString& line);
+    void simplify(TaggedLineString& line);
 
-	std::unique_ptr<LineSegmentIndex> inputIndex;
+    std::unique_ptr<LineSegmentIndex> inputIndex;
 
-	std::unique_ptr<LineSegmentIndex> outputIndex;
+    std::unique_ptr<LineSegmentIndex> outputIndex;
 
-	std::unique_ptr<TaggedLineStringSimplifier> taggedlineSimplifier;
+    std::unique_ptr<TaggedLineStringSimplifier> taggedlineSimplifier;
 };
 
 } // namespace geos::simplify
diff --git a/include/geos/simplify/TopologyPreservingSimplifier.h b/include/geos/simplify/TopologyPreservingSimplifier.h
index 8c38140..afba135 100644
--- a/include/geos/simplify/TopologyPreservingSimplifier.h
+++ b/include/geos/simplify/TopologyPreservingSimplifier.h
@@ -55,36 +55,35 @@ namespace simplify { // geos::simplify
  *     (although they may touch at fewer points)
  *
  */
-class GEOS_DLL TopologyPreservingSimplifier
-{
+class GEOS_DLL TopologyPreservingSimplifier {
 
 public:
 
-	static std::unique_ptr<geom::Geometry> simplify(
-			const geom::Geometry* geom,
-			double tolerance);
+    static std::unique_ptr<geom::Geometry> simplify(
+        const geom::Geometry* geom,
+        double tolerance);
 
-	TopologyPreservingSimplifier(const geom::Geometry* geom);
+    TopologyPreservingSimplifier(const geom::Geometry* geom);
 
-	/** \brief
-	 * Sets the distance tolerance for the simplification.
-	 *
-	 * All vertices in the simplified geometry will be within this
-	 * distance of the original geometry.
-	 * The tolerance value must be non-negative.  A tolerance value
-	 * of zero is effectively a no-op.
-	 *
-	 * @param distanceTolerance the approximation tolerance to use
-	 */
-	void setDistanceTolerance(double tolerance);
+    /** \brief
+     * Sets the distance tolerance for the simplification.
+     *
+     * All vertices in the simplified geometry will be within this
+     * distance of the original geometry.
+     * The tolerance value must be non-negative.  A tolerance value
+     * of zero is effectively a no-op.
+     *
+     * @param distanceTolerance the approximation tolerance to use
+     */
+    void setDistanceTolerance(double tolerance);
 
-	std::unique_ptr<geom::Geometry> getResultGeometry();
+    std::unique_ptr<geom::Geometry> getResultGeometry();
 
 private:
 
-	const geom::Geometry* inputGeom;
+    const geom::Geometry* inputGeom;
 
-	std::unique_ptr<TaggedLinesSimplifier> lineSimplifier;
+    std::unique_ptr<TaggedLinesSimplifier> lineSimplifier;
 
 };
 
diff --git a/include/geos/timeval.h b/include/geos/timeval.h
index 7985394..3ece94e 100644
--- a/include/geos/timeval.h
+++ b/include/geos/timeval.h
@@ -51,15 +51,15 @@ struct timezone {
 
 #if !defined(_WIN32_WCE)
 
-__inline int gettimeofday(struct timeval *tv, struct timezone *tz)
+__inline int
+gettimeofday(struct timeval* tv, struct timezone* tz)
 {
     FILETIME        ft;
     LARGE_INTEGER   li;
     __int64         t;
     static int      tzflag;
 
-    if (tv)
-    {
+    if(tv) {
         GetSystemTimeAsFileTime(&ft);
         li.LowPart  = ft.dwLowDateTime;
         li.HighPart = ft.dwHighDateTime;
@@ -70,10 +70,8 @@ __inline int gettimeofday(struct timeval *tv, struct timezone *tz)
         tv->tv_usec = (long)(t % 1000000);
     }
 
-    if (tz)
-    {
-        if (!tzflag)
-        {
+    if(tz) {
+        if(!tzflag) {
             _tzset();
             tzflag++;
         }
@@ -86,19 +84,19 @@ __inline int gettimeofday(struct timeval *tv, struct timezone *tz)
 
 #else
 
-__inline int gettimeofday(struct timeval *tv, struct timezone *tz)
+__inline int
+gettimeofday(struct timeval* tv, struct timezone* tz)
 {
-	SYSTEMTIME      st;
+    SYSTEMTIME      st;
     FILETIME        ft;
     LARGE_INTEGER   li;
     TIME_ZONE_INFORMATION tzi;
     __int64         t;
     static int      tzflag;
 
-    if (tv)
-    {
-		GetSystemTime(&st);
-		SystemTimeToFileTime(&st, &ft);
+    if(tv) {
+        GetSystemTime(&st);
+        SystemTimeToFileTime(&st, &ft);
         li.LowPart  = ft.dwLowDateTime;
         li.HighPart = ft.dwHighDateTime;
         t  = li.QuadPart;       /* In 100-nanosecond intervals */
@@ -108,22 +106,18 @@ __inline int gettimeofday(struct timeval *tv, struct timezone *tz)
         tv->tv_usec = (long)(t % 1000000);
     }
 
-    if (tz)
-    {
+    if(tz) {
         GetTimeZoneInformation(&tzi);
 
         tz->tz_minuteswest = tzi.Bias;
-		if (tzi.StandardDate.wMonth != 0)
-        {
-			tz->tz_minuteswest += tzi.StandardBias * 60;
+        if(tzi.StandardDate.wMonth != 0) {
+            tz->tz_minuteswest += tzi.StandardBias * 60;
         }
 
-        if (tzi.DaylightDate.wMonth != 0)
-        {
+        if(tzi.DaylightDate.wMonth != 0) {
             tz->tz_dsttime = 1;
         }
-        else
-        {
+        else {
             tz->tz_dsttime = 0;
         }
     }
diff --git a/include/geos/triangulate/DelaunayTriangulationBuilder.h b/include/geos/triangulate/DelaunayTriangulationBuilder.h
index 6b887cc..9d9fda3 100644
--- a/include/geos/triangulate/DelaunayTriangulationBuilder.h
+++ b/include/geos/triangulate/DelaunayTriangulationBuilder.h
@@ -23,19 +23,19 @@
 
 
 namespace geos {
-  namespace geom{
-	  class CoordinateSequence;
-	  class Geometry;
-	  class MultiLineString;
-	  class GeometryCollection;
-	  class GeometryFactory;
-	  class Envelope;
-  }
-  namespace triangulate {
-    namespace quadedge {
-      class QuadEdgeSubdivision;
-    }
-  }
+namespace geom {
+class CoordinateSequence;
+class Geometry;
+class MultiLineString;
+class GeometryCollection;
+class GeometryFactory;
+class Envelope;
+}
+namespace triangulate {
+namespace quadedge {
+class QuadEdgeSubdivision;
+}
+}
 }
 
 namespace geos {
@@ -51,103 +51,103 @@ namespace triangulate { //geos.triangulate
  * @author Benjamin Campbell
  *
  */
-class GEOS_DLL DelaunayTriangulationBuilder
-{
+class GEOS_DLL DelaunayTriangulationBuilder {
 public:
-	/**
-	 * Extracts the unique {@link Coordinate}s from the given {@link Geometry}.
-	 * @param geom the geometry to extract from
-	 * @return a List of the unique Coordinates. Caller takes ownership of the returned object.
-	 */
-	static geom::CoordinateSequence* extractUniqueCoordinates(const geom::Geometry& geom);
-
-	static void unique(geom::CoordinateSequence& coords);
-
-	/**
-	 * Converts all {@link Coordinate}s in a collection to {@link Vertex}es.
-	 * @param coords the coordinates to convert
-	 * @return a List of Vertex objects. Call takes ownership of returned object.
-	 */
-	static IncrementalDelaunayTriangulator::VertexList* toVertices(const geom::CoordinateSequence &coords);
+    /**
+     * Extracts the unique {@link Coordinate}s from the given {@link Geometry}.
+     * @param geom the geometry to extract from
+     * @return a List of the unique Coordinates. Caller takes ownership of the returned object.
+     */
+    static geom::CoordinateSequence* extractUniqueCoordinates(const geom::Geometry& geom);
+
+    static void unique(geom::CoordinateSequence& coords);
+
+    /**
+     * Converts all {@link Coordinate}s in a collection to {@link Vertex}es.
+     * @param coords the coordinates to convert
+     * @return a List of Vertex objects. Call takes ownership of returned object.
+     */
+    static IncrementalDelaunayTriangulator::VertexList* toVertices(const geom::CoordinateSequence& coords);
 
 private:
-	geom::CoordinateSequence* siteCoords;
-	double tolerance;
-	quadedge::QuadEdgeSubdivision *subdiv;
+    geom::CoordinateSequence* siteCoords;
+    double tolerance;
+    quadedge::QuadEdgeSubdivision* subdiv;
 
 public:
-	/**
-	 * Creates a new triangulation builder.
-	 *
-	 */
-	DelaunayTriangulationBuilder();
-
-	~DelaunayTriangulationBuilder();
-
-	/**
-	 * Sets the sites (vertices) which will be triangulated.
-	 * All vertices of the given geometry will be used as sites.
-	 *
-	 * @param geom the geometry from which the sites will be extracted.
-	 */
-	void setSites(const geom::Geometry& geom);
-
-	/**
-	 * Sets the sites (vertices) which will be triangulated
-	 * from a collection of {@link Coordinate}s.
-	 *
-	 * @param geom a CoordinateSequence.
-	 */
-	void setSites(const geom::CoordinateSequence& coords);
-
-	/**
-	 * Sets the snapping tolerance which will be used
-	 * to improved the robustness of the triangulation computation.
-	 * A tolerance of 0.0 specifies that no snapping will take place.
-	 *
-	 * @param tolerance the tolerance distance to use
-	 */
-	inline void setTolerance(double p_tolerance)
-	{
-		this->tolerance = p_tolerance;
-	}
+    /**
+     * Creates a new triangulation builder.
+     *
+     */
+    DelaunayTriangulationBuilder();
+
+    ~DelaunayTriangulationBuilder();
+
+    /**
+     * Sets the sites (vertices) which will be triangulated.
+     * All vertices of the given geometry will be used as sites.
+     *
+     * @param geom the geometry from which the sites will be extracted.
+     */
+    void setSites(const geom::Geometry& geom);
+
+    /**
+     * Sets the sites (vertices) which will be triangulated
+     * from a collection of {@link Coordinate}s.
+     *
+     * @param geom a CoordinateSequence.
+     */
+    void setSites(const geom::CoordinateSequence& coords);
+
+    /**
+     * Sets the snapping tolerance which will be used
+     * to improved the robustness of the triangulation computation.
+     * A tolerance of 0.0 specifies that no snapping will take place.
+     *
+     * @param tolerance the tolerance distance to use
+     */
+    inline void
+    setTolerance(double p_tolerance)
+    {
+        this->tolerance = p_tolerance;
+    }
 
 private:
-	void create();
+    void create();
 
 public:
-	/**
-	 * Gets the {@link quadedge::QuadEdgeSubdivision} which models the computed triangulation.
-	 *
-	 * @return the subdivision containing the triangulation
-	 */
-	quadedge::QuadEdgeSubdivision& getSubdivision();
-
-	/**
-	 * Gets the edges of the computed triangulation as a {@link MultiLineString}.
-	 *
-	 * @param geomFact the geometry factory to use to create the output
-	 * @return the edges of the triangulation. The caller takes ownership of the returned object.
-	 */
-	std::unique_ptr<geom::MultiLineString> getEdges(const geom::GeometryFactory &geomFact);
-
-	/**
-	 * Gets the faces of the computed triangulation as a {@link GeometryCollection}
-	 * of {@link Polygon}.
-	 *
-	 * @param geomFact the geometry factory to use to create the output
-	 * @return the faces of the triangulation. The caller takes ownership of the returned object.
-	 */
-	std::unique_ptr<geom::GeometryCollection> getTriangles(const geom::GeometryFactory& geomFact);
-
-	/**
-	 * Computes the {@link Envelope} of a collection of {@link Coordinate}s.
-	 *
-	 * @param coords a List of Coordinates
-	 * @return the envelope of the set of coordinates
-	 */
-
-	static geom::Envelope envelope(const geom::CoordinateSequence& coords);
+    /**
+     * Gets the {@link quadedge::QuadEdgeSubdivision} which models the computed triangulation.
+     *
+     * @return the subdivision containing the triangulation
+     */
+    quadedge::QuadEdgeSubdivision& getSubdivision();
+
+    /**
+     * Gets the edges of the computed triangulation as a {@link MultiLineString}.
+     *
+     * @param geomFact the geometry factory to use to create the output
+     * @return the edges of the triangulation. The caller takes ownership of the returned object.
+     */
+    std::unique_ptr<geom::MultiLineString> getEdges(const geom::GeometryFactory& geomFact);
+
+    /**
+     * Gets the faces of the computed triangulation as a {@link GeometryCollection}
+     * of {@link Polygon}.
+     *
+     * @param geomFact the geometry factory to use to create the output
+     * @return the faces of the triangulation. The caller takes ownership of the returned object.
+     */
+    std::unique_ptr<geom::GeometryCollection> getTriangles(const geom::GeometryFactory& geomFact);
+
+    /**
+     * Computes the {@link Envelope} of a collection of {@link Coordinate}s.
+     *
+     * @param coords a List of Coordinates
+     * @return the envelope of the set of coordinates
+     */
+
+    static geom::Envelope envelope(const geom::CoordinateSequence& coords);
 
 };
 
diff --git a/include/geos/triangulate/IncrementalDelaunayTriangulator.h b/include/geos/triangulate/IncrementalDelaunayTriangulator.h
index e28dad0..b4ad5fc 100644
--- a/include/geos/triangulate/IncrementalDelaunayTriangulator.h
+++ b/include/geos/triangulate/IncrementalDelaunayTriangulator.h
@@ -28,8 +28,8 @@ namespace geos {
 namespace triangulate { //geos.triangulate
 
 namespace quadedge {
-	class QuadEdge;
-	class QuadEdgeSubdivision;
+class QuadEdge;
+class QuadEdgeSubdivision;
 }
 
 /**
@@ -39,46 +39,45 @@ namespace quadedge {
  * @author JTS: Martin Davis
  * @author Benjamin Campbell
  */
-class GEOS_DLL IncrementalDelaunayTriangulator
-{
+class GEOS_DLL IncrementalDelaunayTriangulator {
 private:
-	quadedge::QuadEdgeSubdivision *subdiv;
-	bool isUsingTolerance;
+    quadedge::QuadEdgeSubdivision* subdiv;
+    bool isUsingTolerance;
 
 public:
-	/**
-	 * Creates a new triangulator using the given {@link QuadEdgeSubdivision}.
-	 * The triangulator uses the tolerance of the supplied subdivision.
-	 *
-	 * @param subdiv
-	 *          a subdivision in which to build the TIN
-	 */
-	IncrementalDelaunayTriangulator(quadedge::QuadEdgeSubdivision *subdiv);
+    /**
+     * Creates a new triangulator using the given {@link QuadEdgeSubdivision}.
+     * The triangulator uses the tolerance of the supplied subdivision.
+     *
+     * @param subdiv
+     *          a subdivision in which to build the TIN
+     */
+    IncrementalDelaunayTriangulator(quadedge::QuadEdgeSubdivision* subdiv);
 
-	typedef std::list<quadedge::Vertex> VertexList;
+    typedef std::list<quadedge::Vertex> VertexList;
 
-	/**
-	 * Inserts all sites in a collection. The inserted vertices <b>MUST</b> be
-	 * unique up to the provided tolerance value. (i.e. no two vertices should be
-	 * closer than the provided tolerance value). They do not have to be rounded
-	 * to the tolerance grid, however.
-	 *
-	 * @param vertices a Collection of Vertex
-	 *
-	 * @throws LocateFailureException if the location algorithm
-	 *         fails to converge in a reasonable number of iterations
-	 */
-	void insertSites(const VertexList& vertices);
+    /**
+     * Inserts all sites in a collection. The inserted vertices <b>MUST</b> be
+     * unique up to the provided tolerance value. (i.e. no two vertices should be
+     * closer than the provided tolerance value). They do not have to be rounded
+     * to the tolerance grid, however.
+     *
+     * @param vertices a Collection of Vertex
+     *
+     * @throws LocateFailureException if the location algorithm
+     *         fails to converge in a reasonable number of iterations
+     */
+    void insertSites(const VertexList& vertices);
 
-	/**
-	 * Inserts a new point into a subdivision representing a Delaunay
-	 * triangulation, and fixes the affected edges so that the result
-	 * is still a Delaunay triangulation.
-	 * <p>
-	 *
-	 * @return a quadedge containing the inserted vertex
-	 */
-	quadedge::QuadEdge& insertSite(const quadedge::Vertex &v);
+    /**
+     * Inserts a new point into a subdivision representing a Delaunay
+     * triangulation, and fixes the affected edges so that the result
+     * is still a Delaunay triangulation.
+     * <p>
+     *
+     * @return a quadedge containing the inserted vertex
+     */
+    quadedge::QuadEdge& insertSite(const quadedge::Vertex& v);
 };
 
 } //namespace geos.triangulate
diff --git a/include/geos/triangulate/VoronoiDiagramBuilder.h b/include/geos/triangulate/VoronoiDiagramBuilder.h
index dad3761..37df492 100644
--- a/include/geos/triangulate/VoronoiDiagramBuilder.h
+++ b/include/geos/triangulate/VoronoiDiagramBuilder.h
@@ -25,11 +25,11 @@
 #include <iostream>
 
 namespace geos {
-  namespace geom{
-	class Geometry;
-	class CoordinateSequence;
-	class GeometryCollection;
-	class GeometryFactory;
+namespace geom {
+class Geometry;
+class CoordinateSequence;
+class GeometryCollection;
+class GeometryFactory;
 }
 namespace triangulate { //geos.triangulate
 
@@ -43,89 +43,89 @@ namespace triangulate { //geos.triangulate
  * @author Martin Davis
  *
  */
-class GEOS_DLL VoronoiDiagramBuilder{
+class GEOS_DLL VoronoiDiagramBuilder {
 public:
-	/**
-	 * Creates a new Voronoi diagram builder.
-	 *
-	 */
-	VoronoiDiagramBuilder();
-
-	~VoronoiDiagramBuilder();
-
-	/**
-	 * Sets the sites (point or vertices) which will be diagrammed.
-	 * All vertices of the given geometry will be used as sites.
-	 *
-	 * @param geom the geometry from which the sites will be extracted.
-	 */
-	void setSites(const geom::Geometry& geom);
-
-	/**
-	 * Sets the sites (point or vertices) which will be diagrammed
-	 * from a collection of {@link Coordinate}s.
-	 *
-	 * @param coords a collection of Coordinates.
-	 */
-	void setSites(const geom::CoordinateSequence& coords);
-
-	/**
-	 * Sets the envelope to clip the diagram to.
-	 * The diagram will be clipped to the larger
-	 * of this envelope or an envelope surrounding the sites.
-	 *
-	 * @param clipEnv the clip envelope; must be kept alive by
-	 *                caller until done with this instance;
-	 *                set to 0 for no clipping.
-	 */
-	void setClipEnvelope(const geom::Envelope* clipEnv);
-
-	/**
-	 * Sets the snapping tolerance which will be used
-	 * to improved the robustness of the triangulation computation.
-	 * A tolerance of 0.0 specifies that no snapping will take place.
-	 *
-	 * @param tolerance the tolerance distance to use
-	 */
-	void setTolerance(double tolerance);
-
-	/**
-	 * Gets the {@link QuadEdgeSubdivision} which models the computed diagram.
-	 *
-	 * @return the subdivision containing the triangulation
-	 */
-	std::unique_ptr<quadedge::QuadEdgeSubdivision> getSubdivision();
-
-	/**
-	 * Gets the faces of the computed diagram as a {@link GeometryCollection}
-	 * of {@link Polygon}s, clipped as specified.
-	 *
-	 * @param geomFact the geometry factory to use to create the output
-	 * @return the faces of the diagram
-	 */
-	std::unique_ptr<geom::GeometryCollection> getDiagram(const geom::GeometryFactory& geomFact);
-
-	/**
-	 * Gets the faces of the computed diagram as a {@link GeometryCollection}
-	 * of {@link LineString}s, clipped as specified.
-	 *
-	 * @param geomFact the geometry factory to use to create the output
-	 * @return the faces of the diagram
-	 */
-	std::unique_ptr<geom::Geometry> getDiagramEdges(const geom::GeometryFactory& geomFact);
+    /**
+     * Creates a new Voronoi diagram builder.
+     *
+     */
+    VoronoiDiagramBuilder();
+
+    ~VoronoiDiagramBuilder();
+
+    /**
+     * Sets the sites (point or vertices) which will be diagrammed.
+     * All vertices of the given geometry will be used as sites.
+     *
+     * @param geom the geometry from which the sites will be extracted.
+     */
+    void setSites(const geom::Geometry& geom);
+
+    /**
+     * Sets the sites (point or vertices) which will be diagrammed
+     * from a collection of {@link Coordinate}s.
+     *
+     * @param coords a collection of Coordinates.
+     */
+    void setSites(const geom::CoordinateSequence& coords);
+
+    /**
+     * Sets the envelope to clip the diagram to.
+     * The diagram will be clipped to the larger
+     * of this envelope or an envelope surrounding the sites.
+     *
+     * @param clipEnv the clip envelope; must be kept alive by
+     *                caller until done with this instance;
+     *                set to 0 for no clipping.
+     */
+    void setClipEnvelope(const geom::Envelope* clipEnv);
+
+    /**
+     * Sets the snapping tolerance which will be used
+     * to improved the robustness of the triangulation computation.
+     * A tolerance of 0.0 specifies that no snapping will take place.
+     *
+     * @param tolerance the tolerance distance to use
+     */
+    void setTolerance(double tolerance);
+
+    /**
+     * Gets the {@link QuadEdgeSubdivision} which models the computed diagram.
+     *
+     * @return the subdivision containing the triangulation
+     */
+    std::unique_ptr<quadedge::QuadEdgeSubdivision> getSubdivision();
+
+    /**
+     * Gets the faces of the computed diagram as a {@link GeometryCollection}
+     * of {@link Polygon}s, clipped as specified.
+     *
+     * @param geomFact the geometry factory to use to create the output
+     * @return the faces of the diagram
+     */
+    std::unique_ptr<geom::GeometryCollection> getDiagram(const geom::GeometryFactory& geomFact);
+
+    /**
+     * Gets the faces of the computed diagram as a {@link GeometryCollection}
+     * of {@link LineString}s, clipped as specified.
+     *
+     * @param geomFact the geometry factory to use to create the output
+     * @return the faces of the diagram
+     */
+    std::unique_ptr<geom::Geometry> getDiagramEdges(const geom::GeometryFactory& geomFact);
 
 private:
 
-	std::unique_ptr<geom::CoordinateSequence> siteCoords;
-	double tolerance;
-	std::unique_ptr<quadedge::QuadEdgeSubdivision> subdiv;
-	const geom::Envelope* clipEnv; // externally owned
-	geom::Envelope diagramEnv;
+    std::unique_ptr<geom::CoordinateSequence> siteCoords;
+    double tolerance;
+    std::unique_ptr<quadedge::QuadEdgeSubdivision> subdiv;
+    const geom::Envelope* clipEnv; // externally owned
+    geom::Envelope diagramEnv;
 
-	void create();
+    void create();
 
-	static std::unique_ptr<geom::GeometryCollection>
-		clipGeometryCollection(const geom::GeometryCollection& geom, const geom::Envelope& clipEnv);
+    static std::unique_ptr<geom::GeometryCollection>
+    clipGeometryCollection(const geom::GeometryCollection& geom, const geom::Envelope& clipEnv);
 
 };
 
diff --git a/include/geos/triangulate/quadedge/LastFoundQuadEdgeLocator.h b/include/geos/triangulate/quadedge/LastFoundQuadEdgeLocator.h
index e7c9e65..a2e7fe7 100644
--- a/include/geos/triangulate/quadedge/LastFoundQuadEdgeLocator.h
+++ b/include/geos/triangulate/quadedge/LastFoundQuadEdgeLocator.h
@@ -40,24 +40,24 @@ class QuadEdgeSubdivision;
 
 class LastFoundQuadEdgeLocator : public QuadEdgeLocator {
 private:
-	QuadEdgeSubdivision* subdiv;
-	QuadEdge*			lastEdge;
+    QuadEdgeSubdivision* subdiv;
+    QuadEdge*			lastEdge;
 
 public:
-	LastFoundQuadEdgeLocator(QuadEdgeSubdivision *subdiv);
+    LastFoundQuadEdgeLocator(QuadEdgeSubdivision* subdiv);
 
 private:
-	virtual void init();
+    virtual void init();
 
-	virtual QuadEdge* findEdge();
+    virtual QuadEdge* findEdge();
 
 public:
-	/**
-	 * Locates an edge e, such that either v is on e, or e is an edge of a triangle containing v.
-	 * The search starts from the last located edge amd proceeds on the general direction of v.
-	 * @return The caller _does not_ take ownership of the returned object.
-	 */
-	QuadEdge* locate(const Vertex &v) override;
+    /**
+     * Locates an edge e, such that either v is on e, or e is an edge of a triangle containing v.
+     * The search starts from the last located edge amd proceeds on the general direction of v.
+     * @return The caller _does not_ take ownership of the returned object.
+     */
+    QuadEdge* locate(const Vertex& v) override;
 };
 
 } //namespace geos.triangulate.quadedge
diff --git a/include/geos/triangulate/quadedge/LocateFailureException.h b/include/geos/triangulate/quadedge/LocateFailureException.h
index ec143d8..1f3a479 100644
--- a/include/geos/triangulate/quadedge/LocateFailureException.h
+++ b/include/geos/triangulate/quadedge/LocateFailureException.h
@@ -29,7 +29,7 @@ namespace quadedge { //geos.triangulate.quadedge
 
 class GEOS_DLL LocateFailureException : public geos::util::GEOSException {
 public:
-	LocateFailureException(std::string const&msg);
+    LocateFailureException(std::string const& msg);
 };
 
 } //namespace geos.triangulate.quadedge
diff --git a/include/geos/triangulate/quadedge/QuadEdge.h b/include/geos/triangulate/quadedge/QuadEdge.h
index 7515b6a..0dd0de1 100644
--- a/include/geos/triangulate/quadedge/QuadEdge.h
+++ b/include/geos/triangulate/quadedge/QuadEdge.h
@@ -50,308 +50,344 @@ namespace quadedge { //geos.triangulate.quadedge
  * */
 class GEOS_DLL QuadEdge {
 public:
-	/**
-	 * Creates a new QuadEdge quartet from {@link Vertex} o to {@link Vertex} d.
-	 *
-	 * @param o
-	 *		  the origin Vertex
-	 * @param d
-	 *		  the destination Vertex
-	 * @return the new QuadEdge* The caller is reponsible for
-	 * freeing the returned pointer
-	 */
-	static std::unique_ptr<QuadEdge> makeEdge(const Vertex &o, const Vertex &d);
-
-	/**
-	 * Creates a new QuadEdge connecting the destination of a to the origin of
-	 * b, in such a way that all three have the same left face after the
-	 * connection is complete. Additionally, the data pointers of the new edge
-	 * are set.
-	 *
-	 * @return the new QuadEdge* The caller is reponsible for
-	 * freeing the returned pointer
-	 */
-	static std::unique_ptr<QuadEdge> connect(QuadEdge &a, QuadEdge &b);
-
-	/**
-	 * Splices two edges together or apart.
-	 * Splice affects the two edge rings around the origins of a and b, and, independently, the two
-	 * edge rings around the left faces of <tt>a</tt> and <tt>b</tt>.
-	 * In each case, (i) if the two rings are distinct,
-	 * Splice will combine them into one, or (ii) if the two are the same ring, Splice will break it
-	 * into two separate pieces. Thus, Splice can be used both to attach the two edges together, and
-	 * to break them apart.
-	 *
-	 * @param a an edge to splice
-	 * @param b an edge to splice
-	 *
-	 */
-	static void splice(QuadEdge &a, QuadEdge &b);
-
-	/**
-	 * Turns an edge counterclockwise inside its enclosing quadrilateral.
-	 *
-	 * @param e the quadedge to turn
-	 */
-	static void swap(QuadEdge &e);
+    /**
+     * Creates a new QuadEdge quartet from {@link Vertex} o to {@link Vertex} d.
+     *
+     * @param o
+     *		  the origin Vertex
+     * @param d
+     *		  the destination Vertex
+     * @return the new QuadEdge* The caller is reponsible for
+     * freeing the returned pointer
+     */
+    static std::unique_ptr<QuadEdge> makeEdge(const Vertex& o, const Vertex& d);
+
+    /**
+     * Creates a new QuadEdge connecting the destination of a to the origin of
+     * b, in such a way that all three have the same left face after the
+     * connection is complete. Additionally, the data pointers of the new edge
+     * are set.
+     *
+     * @return the new QuadEdge* The caller is reponsible for
+     * freeing the returned pointer
+     */
+    static std::unique_ptr<QuadEdge> connect(QuadEdge& a, QuadEdge& b);
+
+    /**
+     * Splices two edges together or apart.
+     * Splice affects the two edge rings around the origins of a and b, and, independently, the two
+     * edge rings around the left faces of <tt>a</tt> and <tt>b</tt>.
+     * In each case, (i) if the two rings are distinct,
+     * Splice will combine them into one, or (ii) if the two are the same ring, Splice will break it
+     * into two separate pieces. Thus, Splice can be used both to attach the two edges together, and
+     * to break them apart.
+     *
+     * @param a an edge to splice
+     * @param b an edge to splice
+     *
+     */
+    static void splice(QuadEdge& a, QuadEdge& b);
+
+    /**
+     * Turns an edge counterclockwise inside its enclosing quadrilateral.
+     *
+     * @param e the quadedge to turn
+     */
+    static void swap(QuadEdge& e);
 
 private:
-	//// the dual of this edge, directed from right to left
-	QuadEdge *_rot;
-	Vertex   vertex;			// The vertex that this edge represents
-	QuadEdge *next;			  // A reference to a connected edge
-	void*   data;
-	bool isAlive;
-
-	/**
-	 * Quadedges must be made using {@link makeEdge},
-	 * to ensure proper construction.
-	 */
-	QuadEdge();
+    //// the dual of this edge, directed from right to left
+    QuadEdge* _rot;
+    Vertex   vertex;			// The vertex that this edge represents
+    QuadEdge* next;			  // A reference to a connected edge
+    void*   data;
+    bool isAlive;
+
+    /**
+     * Quadedges must be made using {@link makeEdge},
+     * to ensure proper construction.
+     */
+    QuadEdge();
 
 public:
-	virtual ~QuadEdge();
-
-	/**
-	 * Free the QuadEdge quartet associated with this QuadEdge by a connect()
-	 * or makeEdge() call.
-	 * DO NOT call this function on a QuadEdge that was not returned
-	 * by connect() or makeEdge().
-	 */
-	virtual void free();
-
-	/**
-	 * Gets the primary edge of this quadedge and its <tt>sym</tt>.
-	 * The primary edge is the one for which the origin
-	 * and destination coordinates are ordered
-	 * according to the standard {@link Coordinate} ordering
-	 *
-	 * @return the primary quadedge
-	 */
-	const QuadEdge& getPrimary() const;
-
-	/**
-	 * Sets the external data value for this edge.
-	 *
-	 * @param data an object containing external data
-	 */
-	virtual void setData(void* data);
-
-	/**
-	 * Gets the external data value for this edge.
-	 *
-	 * @return the data object
-	 */
-	virtual void* getData();
-
-	/**
-	 * Marks this quadedge as being deleted.
-	 * This does not free the memory used by
-	 * this quadedge quartet, but indicates
-	 * that this quadedge quartet no longer participates
-	 * in a subdivision.
-	 *
-	 * NOTE: called "delete" in JTS
-	 *
-	 */
-	void remove();
-
-	/**
-	 * Tests whether this edge has been deleted.
-	 *
-	 * @return true if this edge has not been deleted.
-	 */
-	inline bool isLive() {
-		return isAlive;
-	}
-
-
-	/**
-	 * Sets the connected edge
-	 *
-	 * @param nextEdge edge
-	 */
-	inline void setNext(QuadEdge *p_next) {
-		this->next = p_next;
-	}
-
-	/***************************************************************************
-	 * QuadEdge Algebra
-	 ***************************************************************************
-	 */
-
-	/**
-	 * Gets the dual of this edge, directed from its right to its left.
-	 *
-	 * @return the rotated edge
-	 */
-	 inline QuadEdge& rot() const {
-	  return *_rot;
-	}
-
-	/**
-	 * Gets the dual of this edge, directed from its left to its right.
-	 *
-	 * @return the inverse rotated edge.
-	 */
-	inline QuadEdge& invRot() const  {
-	  return rot().sym();
-	}
-
-	/**
-	 * Gets the edge from the destination to the origin of this edge.
-	 *
-	 * @return the sym of the edge
-	 */
-	inline QuadEdge& sym() const {
-	  return rot().rot();
-	}
-
-	/**
-	 * Gets the next CCW edge around the origin of this edge.
-	 *
-	 * @return the next linked edge.
-	 */
-	inline QuadEdge& oNext() const {
-		return *next;
-	}
-
-	/**
-	 * Gets the next CW edge around (from) the origin of this edge.
-	 *
-	 * @return the previous edge.
-	 */
-	inline QuadEdge& oPrev() const {
-		return rot().oNext().rot();
-	}
-
-	/**
-	 * Gets the next CCW edge around (into) the destination of this edge.
-	 *
-	 * @return the next destination edge.
-	 */
-	inline QuadEdge& dNext() const {
-		return sym().oNext().sym();
-	}
-
-	/**
-	 * Gets the next CW edge around (into) the destination of this edge.
-	 *
-	 * @return the previous destination edge.
-	 */
-	inline QuadEdge& dPrev() const {
-		return invRot().oNext().invRot();
-	}
-
-	/**
-	 * Gets the CCW edge around the left face following this edge.
-	 *
-	 * @return the next left face edge.
-	 */
-	inline QuadEdge& lNext() const {
-		return invRot().oNext().rot();
-	}
-
-	/**
-	 * Gets the CCW edge around the left face before this edge.
-	 *
-	 * @return the previous left face edge.
-	 */
-	inline QuadEdge& lPrev() const {
-		return oNext().sym();
-	}
-
-	/**
-	 * Gets the edge around the right face ccw following this edge.
-	 *
-	 * @return the next right face edge.
-	 */
-	inline QuadEdge& rNext() {
-		return rot().oNext().invRot();
-	}
-
-	/**
-	 * Gets the edge around the right face ccw before this edge.
-	 *
-	 * @return the previous right face edge.
-	 */
-	inline QuadEdge& rPrev() {
-		return sym().oNext();
-	}
-
-	/***********************************************************************************************
-	 * Data Access
-	 **********************************************************************************************/
-	/**
-	 * Sets the vertex for this edge's origin
-	 *
-	 * @param o the origin vertex
-	 */
-	inline void setOrig(const Vertex &o) {
-		vertex = o;
-	}
-
-	/**
-	 * Sets the vertex for this edge's destination
-	 *
-	 * @param d the destination vertex
-	 */
-	inline void setDest(const Vertex &d) {
-		sym().setOrig(d);
-	}
-
-	/**
-	 * Gets the vertex for the edge's origin
-	 *
-	 * @return the origin vertex
-	 */
-	const Vertex& orig() const {
-		return vertex;
-	}
-
-	/**
-	 * Gets the vertex for the edge's destination
-	 *
-	 * @return the destination vertex
-	 */
-	const Vertex& dest() const {
-		return sym().orig();
-	}
-
-	/**
-	 * Gets the length of the geometry of this quadedge.
-	 *
-	 * @return the length of the quadedge
-	 */
-	inline double getLength() const {
-		return orig().getCoordinate().distance(dest().getCoordinate());
-	}
-
-	/**
-	 * Tests if this quadedge and another have the same line segment geometry,
-	 * regardless of orientation.
-	 *
-	 * @param qe a quadege
-	 * @return true if the quadedges are based on the same line segment regardless of orientation
-	 */
-	bool equalsNonOriented(const QuadEdge &qe) const;
-
-	/**
-	 * Tests if this quadedge and another have the same line segment geometry
-	 * with the same orientation.
-	 *
-	 * @param qe a quadege
-	 * @return true if the quadedges are based on the same line segment
-	 */
-	bool equalsOriented(const QuadEdge &qe) const;
-
-	/**
-	 * Creates a {@link LineSegment} representing the
-	 * geometry of this edge.
-	 *
-	 * @return a LineSegment
-	 */
-	std::unique_ptr<geom::LineSegment> toLineSegment() const;
+    virtual ~QuadEdge();
+
+    /**
+     * Free the QuadEdge quartet associated with this QuadEdge by a connect()
+     * or makeEdge() call.
+     * DO NOT call this function on a QuadEdge that was not returned
+     * by connect() or makeEdge().
+     */
+    virtual void free();
+
+    /**
+     * Gets the primary edge of this quadedge and its <tt>sym</tt>.
+     * The primary edge is the one for which the origin
+     * and destination coordinates are ordered
+     * according to the standard {@link Coordinate} ordering
+     *
+     * @return the primary quadedge
+     */
+    const QuadEdge& getPrimary() const;
+
+    /**
+     * Sets the external data value for this edge.
+     *
+     * @param data an object containing external data
+     */
+    virtual void setData(void* data);
+
+    /**
+     * Gets the external data value for this edge.
+     *
+     * @return the data object
+     */
+    virtual void* getData();
+
+    /**
+     * Marks this quadedge as being deleted.
+     * This does not free the memory used by
+     * this quadedge quartet, but indicates
+     * that this quadedge quartet no longer participates
+     * in a subdivision.
+     *
+     * NOTE: called "delete" in JTS
+     *
+     */
+    void remove();
+
+    /**
+     * Tests whether this edge has been deleted.
+     *
+     * @return true if this edge has not been deleted.
+     */
+    inline bool
+    isLive()
+    {
+        return isAlive;
+    }
+
+
+    /**
+     * Sets the connected edge
+     *
+     * @param nextEdge edge
+     */
+    inline void
+    setNext(QuadEdge* p_next)
+    {
+        this->next = p_next;
+    }
+
+    /***************************************************************************
+     * QuadEdge Algebra
+     ***************************************************************************
+     */
+
+    /**
+     * Gets the dual of this edge, directed from its right to its left.
+     *
+     * @return the rotated edge
+     */
+    inline QuadEdge&
+    rot() const
+    {
+        return *_rot;
+    }
+
+    /**
+     * Gets the dual of this edge, directed from its left to its right.
+     *
+     * @return the inverse rotated edge.
+     */
+    inline QuadEdge&
+    invRot() const
+    {
+        return rot().sym();
+    }
+
+    /**
+     * Gets the edge from the destination to the origin of this edge.
+     *
+     * @return the sym of the edge
+     */
+    inline QuadEdge&
+    sym() const
+    {
+        return rot().rot();
+    }
+
+    /**
+     * Gets the next CCW edge around the origin of this edge.
+     *
+     * @return the next linked edge.
+     */
+    inline QuadEdge&
+    oNext() const
+    {
+        return *next;
+    }
+
+    /**
+     * Gets the next CW edge around (from) the origin of this edge.
+     *
+     * @return the previous edge.
+     */
+    inline QuadEdge&
+    oPrev() const
+    {
+        return rot().oNext().rot();
+    }
+
+    /**
+     * Gets the next CCW edge around (into) the destination of this edge.
+     *
+     * @return the next destination edge.
+     */
+    inline QuadEdge&
+    dNext() const
+    {
+        return sym().oNext().sym();
+    }
+
+    /**
+     * Gets the next CW edge around (into) the destination of this edge.
+     *
+     * @return the previous destination edge.
+     */
+    inline QuadEdge&
+    dPrev() const
+    {
+        return invRot().oNext().invRot();
+    }
+
+    /**
+     * Gets the CCW edge around the left face following this edge.
+     *
+     * @return the next left face edge.
+     */
+    inline QuadEdge&
+    lNext() const
+    {
+        return invRot().oNext().rot();
+    }
+
+    /**
+     * Gets the CCW edge around the left face before this edge.
+     *
+     * @return the previous left face edge.
+     */
+    inline QuadEdge&
+    lPrev() const
+    {
+        return oNext().sym();
+    }
+
+    /**
+     * Gets the edge around the right face ccw following this edge.
+     *
+     * @return the next right face edge.
+     */
+    inline QuadEdge&
+    rNext()
+    {
+        return rot().oNext().invRot();
+    }
+
+    /**
+     * Gets the edge around the right face ccw before this edge.
+     *
+     * @return the previous right face edge.
+     */
+    inline QuadEdge&
+    rPrev()
+    {
+        return sym().oNext();
+    }
+
+    /***********************************************************************************************
+     * Data Access
+     **********************************************************************************************/
+    /**
+     * Sets the vertex for this edge's origin
+     *
+     * @param o the origin vertex
+     */
+    inline void
+    setOrig(const Vertex& o)
+    {
+        vertex = o;
+    }
+
+    /**
+     * Sets the vertex for this edge's destination
+     *
+     * @param d the destination vertex
+     */
+    inline void
+    setDest(const Vertex& d)
+    {
+        sym().setOrig(d);
+    }
+
+    /**
+     * Gets the vertex for the edge's origin
+     *
+     * @return the origin vertex
+     */
+    const Vertex&
+    orig() const
+    {
+        return vertex;
+    }
+
+    /**
+     * Gets the vertex for the edge's destination
+     *
+     * @return the destination vertex
+     */
+    const Vertex&
+    dest() const
+    {
+        return sym().orig();
+    }
+
+    /**
+     * Gets the length of the geometry of this quadedge.
+     *
+     * @return the length of the quadedge
+     */
+    inline double
+    getLength() const
+    {
+        return orig().getCoordinate().distance(dest().getCoordinate());
+    }
+
+    /**
+     * Tests if this quadedge and another have the same line segment geometry,
+     * regardless of orientation.
+     *
+     * @param qe a quadege
+     * @return true if the quadedges are based on the same line segment regardless of orientation
+     */
+    bool equalsNonOriented(const QuadEdge& qe) const;
+
+    /**
+     * Tests if this quadedge and another have the same line segment geometry
+     * with the same orientation.
+     *
+     * @param qe a quadege
+     * @return true if the quadedges are based on the same line segment
+     */
+    bool equalsOriented(const QuadEdge& qe) const;
+
+    /**
+     * Creates a {@link LineSegment} representing the
+     * geometry of this edge.
+     *
+     * @return a LineSegment
+     */
+    std::unique_ptr<geom::LineSegment> toLineSegment() const;
 };
 
 } //namespace geos.triangulate.quadedge
diff --git a/include/geos/triangulate/quadedge/QuadEdgeLocator.h b/include/geos/triangulate/quadedge/QuadEdgeLocator.h
index a5983b1..5d8dc68 100644
--- a/include/geos/triangulate/quadedge/QuadEdgeLocator.h
+++ b/include/geos/triangulate/quadedge/QuadEdgeLocator.h
@@ -38,8 +38,8 @@ class QuadEdge;
  */
 class QuadEdgeLocator {
 public:
-	virtual ~QuadEdgeLocator() = 0; //not implemented
-	virtual QuadEdge* locate(const Vertex &v) = 0; //not implemented
+    virtual ~QuadEdgeLocator() = 0; //not implemented
+    virtual QuadEdge* locate(const Vertex& v) = 0; //not implemented
 };
 
 } //namespace geos.triangulate.quadedge
diff --git a/include/geos/triangulate/quadedge/QuadEdgeSubdivision.h b/include/geos/triangulate/quadedge/QuadEdgeSubdivision.h
index e37f43b..ce5a49c 100644
--- a/include/geos/triangulate/quadedge/QuadEdgeSubdivision.h
+++ b/include/geos/triangulate/quadedge/QuadEdgeSubdivision.h
@@ -33,13 +33,13 @@ namespace geos {
 
 namespace geom {
 
-	class CoordinateSequence;
-	class GeometryCollection;
-	class MultiLineString;
-	class GeometryFactory;
-	class Coordinate;
-	class Geometry;
-	class Envelope;
+class CoordinateSequence;
+class GeometryCollection;
+class MultiLineString;
+class GeometryFactory;
+class Coordinate;
+class Geometry;
+class Envelope;
 }
 
 namespace triangulate { //geos.triangulate
@@ -78,416 +78,428 @@ const double EDGE_COINCIDENCE_TOL_FACTOR = 1000;
  */
 class GEOS_DLL QuadEdgeSubdivision {
 public:
-	typedef std::vector<QuadEdge*> QuadEdgeList;
-
-	/**
-	 * Gets the edges for the triangle to the left of the given {@link QuadEdge}.
-	 *
-	 * @param startQE
-	 * @param triEdge
-	 *
-	 * @throws IllegalArgumentException
-	 *           if the edges do not form a triangle
-	 */
-	static void getTriangleEdges(const QuadEdge &startQE,
-			const QuadEdge* triEdge[3]);
+    typedef std::vector<QuadEdge*> QuadEdgeList;
+
+    /**
+     * Gets the edges for the triangle to the left of the given {@link QuadEdge}.
+     *
+     * @param startQE
+     * @param triEdge
+     *
+     * @throws IllegalArgumentException
+     *           if the edges do not form a triangle
+     */
+    static void getTriangleEdges(const QuadEdge& startQE,
+                                 const QuadEdge* triEdge[3]);
 
 private:
-	QuadEdgeList quadEdges;
-	QuadEdgeList createdEdges;
-	QuadEdge* startingEdges[3];
-	double tolerance;
-	double edgeCoincidenceTolerance;
-	Vertex frameVertex[3];
-	geom::Envelope frameEnv;
-	std::unique_ptr<QuadEdgeLocator> locator;
+    QuadEdgeList quadEdges;
+    QuadEdgeList createdEdges;
+    QuadEdge* startingEdges[3];
+    double tolerance;
+    double edgeCoincidenceTolerance;
+    Vertex frameVertex[3];
+    geom::Envelope frameEnv;
+    std::unique_ptr<QuadEdgeLocator> locator;
 
 public:
-	/**
-	 * Creates a new instance of a quad-edge subdivision based on a frame triangle
-	 * that encloses a supplied bounding box. A new super-bounding box that
-	 * contains the triangle is computed and stored.
-	 *
-	 * @param env
-	 *          the bouding box to surround
-	 * @param tolerance
-	 *          the tolerance value for determining if two sites are equal
-	 */
-	QuadEdgeSubdivision(const geom::Envelope &env, double tolerance);
-
-	virtual ~QuadEdgeSubdivision();
+    /**
+     * Creates a new instance of a quad-edge subdivision based on a frame triangle
+     * that encloses a supplied bounding box. A new super-bounding box that
+     * contains the triangle is computed and stored.
+     *
+     * @param env
+     *          the bouding box to surround
+     * @param tolerance
+     *          the tolerance value for determining if two sites are equal
+     */
+    QuadEdgeSubdivision(const geom::Envelope& env, double tolerance);
+
+    virtual ~QuadEdgeSubdivision();
 
 private:
-	virtual void createFrame(const geom::Envelope &env);
+    virtual void createFrame(const geom::Envelope& env);
 
-	virtual void initSubdiv(QuadEdge* initEdges[3]);
+    virtual void initSubdiv(QuadEdge* initEdges[3]);
 
 public:
-	/**
-	 * Gets the vertex-equality tolerance value
-	 * used in this subdivision
-	 *
-	 * @return the tolerance value
-	 */
-	inline double getTolerance() const {
-		return tolerance;
-	}
-
-	/**
-	 * Gets the envelope of the Subdivision (including the frame).
-	 *
-	 * @return the envelope
-	 */
-	inline const geom::Envelope& getEnvelope() const {
-		return frameEnv;
-	}
-
-	/**
-	 * Gets the collection of base {@link QuadEdge}s (one for every pair of
-	 * vertices which is connected).
-	 *
-	 * @return a QuadEdgeList
-	 */
-	inline const QuadEdgeList& getEdges() const {
-		return quadEdges;
-	}
-
-	/**
-	 * Sets the {@link QuadEdgeLocator} to use for locating containing triangles
-	 * in this subdivision.
-	 *
-	 * @param locator
-	 *          a QuadEdgeLocator
-	 */
-	inline void setLocator(std::unique_ptr<QuadEdgeLocator> p_locator) {
-		this->locator = std::move(p_locator);
-	}
-
-	/**
-	 * Creates a new quadedge, recording it in the edges list.
-	 *
-	 * @param o
-	 * @param d
-	 * @return
-	 */
-	virtual QuadEdge& makeEdge(const Vertex &o, const Vertex &d);
-
-	/**
-	 * Creates a new QuadEdge connecting the destination of a to the origin of b,
-	 * in such a way that all three have the same left face after the connection
-	 * is complete. The quadedge is recorded in the edges list.
-	 *
-	 * @param a
-	 * @param b
-	 * @return
-	 */
-	virtual QuadEdge& connect(QuadEdge &a, QuadEdge &b);
-
-	/**
-	 * Deletes a quadedge from the subdivision. Linked quadedges are updated to
-	 * reflect the deletion.
-	 *
-	 * @param e
-	 *          the quadedge to delete
-	 */
-	void remove(QuadEdge &e);
-
-	/**
-	 * Locates an edge of a triangle which contains a location
-	 * specified by a Vertex v.
-	 * The edge returned has the
-	 * property that either v is on e, or e is an edge of a triangle containing v.
-	 * The search starts from startEdge amd proceeds on the general direction of v.
-	 * <p>
-	 * This locate algorithm relies on the subdivision being Delaunay. For
-	 * non-Delaunay subdivisions, this may loop for ever.
-	 *
-	 * @param v the location to search for
-	 * @param startEdge an edge of the subdivision to start searching at
-	 * @returns a QuadEdge which contains v, or is on the edge of a triangle containing v
-	 * @throws LocateFailureException
-	 *           if the location algorithm fails to converge in a reasonable
-	 *           number of iterations. The returned pointer should not be
-	 * freed be the caller.
-	 */
-	QuadEdge* locateFromEdge(const Vertex &v,
-			const QuadEdge &startEdge) const;
-
-	/**
-	 * Finds a quadedge of a triangle containing a location
-	 * specified by a {@link Vertex}, if one exists.
-	 *
-	 * @param x the vertex to locate
-	 * @return a quadedge on the edge of a triangle which touches or contains the location
-	 * @return null if no such triangle exists. The returned pointer should not be
-	 * freed be the caller.
-	 */
-	inline QuadEdge* locate(const Vertex &v) const {
-		return locator->locate(v);
-	}
-
-	/**
-	 * Finds a quadedge of a triangle containing a location
-	 * specified by a {@link Coordinate}, if one exists.
-	 *
-	 * @param p the Coordinate to locate
-	 * @return a quadedge on the edge of a triangle which touches or contains the location
-	 * @return null if no such triangle exists. The returned pointer should not be
-	 * freed be the caller.
-	 */
-	inline QuadEdge* locate(const geom::Coordinate &p) {
-		return locator->locate(Vertex(p));
-	}
-
-	/**
-	 * Locates the edge between the given vertices, if it exists in the
-	 * subdivision.
-	 *
-	 * @param p0 a coordinate
-	 * @param p1 another coordinate
-	 * @return the edge joining the coordinates, if present
-	 * @return null if no such edge exists
-	 * @return the caller _should not_ free the returned pointer
-	 */
-	QuadEdge* locate(const geom::Coordinate &p0, const geom::Coordinate &p1);
-
-	/**
-	 * Inserts a new site into the Subdivision, connecting it to the vertices of
-	 * the containing triangle (or quadrilateral, if the split point falls on an
-	 * existing edge).
-	 * <p>
-	 * This method does NOT maintain the Delaunay condition. If desired, this must
-	 * be checked and enforced by the caller.
-	 * <p>
-	 * This method does NOT check if the inserted vertex falls on an edge. This
-	 * must be checked by the caller, since this situation may cause erroneous
-	 * triangulation
-	 *
-	 * @param v
-	 *          the vertex to insert
-	 * @return a new quad edge terminating in v
-	 */
-	QuadEdge& insertSite(const Vertex &v);
-
-	/**
-	 * Tests whether a QuadEdge is an edge incident on a frame triangle vertex.
-	 *
-	 * @param e
-	 *          the edge to test
-	 * @return true if the edge is connected to the frame triangle
-	 */
-	bool isFrameEdge(const QuadEdge &e) const;
-
-	/**
-	 * Tests whether a QuadEdge is an edge on the border of the frame facets and
-	 * the internal facets. E.g. an edge which does not itself touch a frame
-	 * vertex, but which touches an edge which does.
-	 *
-	 * @param e
-	 *          the edge to test
-	 * @return true if the edge is on the border of the frame
-	 */
-	bool isFrameBorderEdge(const QuadEdge &e) const;
-
-	/**
-	 * Tests whether a vertex is a vertex of the outer triangle.
-	 *
-	 * @param v
-	 *          the vertex to test
-	 * @return true if the vertex is an outer triangle vertex
-	 */
-	bool isFrameVertex(const Vertex &v) const;
-
-
-	/**
-	 * Tests whether a {@link Coordinate} lies on a {@link QuadEdge}, up to a
-	 * tolerance determined by the subdivision tolerance.
-	 *
-	 * @param e
-	 *          a QuadEdge
-	 * @param p
-	 *          a point
-	 * @return true if the vertex lies on the edge
-	 */
-	bool isOnEdge(const QuadEdge &e, const geom::Coordinate &p) const;
-
-	/**
-	 * Tests whether a {@link Vertex} is the start or end vertex of a
-	 * {@link QuadEdge}, up to the subdivision tolerance distance.
-	 *
-	 * @param e
-	 * @param v
-	 * @return true if the vertex is a endpoint of the edge
-	 */
-	bool isVertexOfEdge(const QuadEdge &e, const Vertex &v) const;
-
-	/**
-	 * Gets all primary quadedges in the subdivision.
-	 * A primary edge is a {@link QuadEdge}
-	 * which occupies the 0'th position in its array of associated quadedges.
-	 * These provide the unique geometric edges of the triangulation.
-	 *
-	 * @param includeFrame true if the frame edges are to be included
-	 * @return a List of QuadEdges. The caller takes ownership of the returned QuadEdgeList but not the
-	 * items it contains.
-	 */
-	std::unique_ptr<QuadEdgeList> getPrimaryEdges(bool includeFrame);
-
-	/*****************************************************************************
-	 * Visitors
-	 ****************************************************************************/
-
-	void visitTriangles(TriangleVisitor *triVisitor, bool includeFrame);
+    /**
+     * Gets the vertex-equality tolerance value
+     * used in this subdivision
+     *
+     * @return the tolerance value
+     */
+    inline double
+    getTolerance() const
+    {
+        return tolerance;
+    }
+
+    /**
+     * Gets the envelope of the Subdivision (including the frame).
+     *
+     * @return the envelope
+     */
+    inline const geom::Envelope&
+    getEnvelope() const
+    {
+        return frameEnv;
+    }
+
+    /**
+     * Gets the collection of base {@link QuadEdge}s (one for every pair of
+     * vertices which is connected).
+     *
+     * @return a QuadEdgeList
+     */
+    inline const QuadEdgeList&
+    getEdges() const
+    {
+        return quadEdges;
+    }
+
+    /**
+     * Sets the {@link QuadEdgeLocator} to use for locating containing triangles
+     * in this subdivision.
+     *
+     * @param locator
+     *          a QuadEdgeLocator
+     */
+    inline void
+    setLocator(std::unique_ptr<QuadEdgeLocator> p_locator)
+    {
+        this->locator = std::move(p_locator);
+    }
+
+    /**
+     * Creates a new quadedge, recording it in the edges list.
+     *
+     * @param o
+     * @param d
+     * @return
+     */
+    virtual QuadEdge& makeEdge(const Vertex& o, const Vertex& d);
+
+    /**
+     * Creates a new QuadEdge connecting the destination of a to the origin of b,
+     * in such a way that all three have the same left face after the connection
+     * is complete. The quadedge is recorded in the edges list.
+     *
+     * @param a
+     * @param b
+     * @return
+     */
+    virtual QuadEdge& connect(QuadEdge& a, QuadEdge& b);
+
+    /**
+     * Deletes a quadedge from the subdivision. Linked quadedges are updated to
+     * reflect the deletion.
+     *
+     * @param e
+     *          the quadedge to delete
+     */
+    void remove(QuadEdge& e);
+
+    /**
+     * Locates an edge of a triangle which contains a location
+     * specified by a Vertex v.
+     * The edge returned has the
+     * property that either v is on e, or e is an edge of a triangle containing v.
+     * The search starts from startEdge amd proceeds on the general direction of v.
+     * <p>
+     * This locate algorithm relies on the subdivision being Delaunay. For
+     * non-Delaunay subdivisions, this may loop for ever.
+     *
+     * @param v the location to search for
+     * @param startEdge an edge of the subdivision to start searching at
+     * @returns a QuadEdge which contains v, or is on the edge of a triangle containing v
+     * @throws LocateFailureException
+     *           if the location algorithm fails to converge in a reasonable
+     *           number of iterations. The returned pointer should not be
+     * freed be the caller.
+     */
+    QuadEdge* locateFromEdge(const Vertex& v,
+                             const QuadEdge& startEdge) const;
+
+    /**
+     * Finds a quadedge of a triangle containing a location
+     * specified by a {@link Vertex}, if one exists.
+     *
+     * @param x the vertex to locate
+     * @return a quadedge on the edge of a triangle which touches or contains the location
+     * @return null if no such triangle exists. The returned pointer should not be
+     * freed be the caller.
+     */
+    inline QuadEdge*
+    locate(const Vertex& v) const
+    {
+        return locator->locate(v);
+    }
+
+    /**
+     * Finds a quadedge of a triangle containing a location
+     * specified by a {@link Coordinate}, if one exists.
+     *
+     * @param p the Coordinate to locate
+     * @return a quadedge on the edge of a triangle which touches or contains the location
+     * @return null if no such triangle exists. The returned pointer should not be
+     * freed be the caller.
+     */
+    inline QuadEdge*
+    locate(const geom::Coordinate& p)
+    {
+        return locator->locate(Vertex(p));
+    }
+
+    /**
+     * Locates the edge between the given vertices, if it exists in the
+     * subdivision.
+     *
+     * @param p0 a coordinate
+     * @param p1 another coordinate
+     * @return the edge joining the coordinates, if present
+     * @return null if no such edge exists
+     * @return the caller _should not_ free the returned pointer
+     */
+    QuadEdge* locate(const geom::Coordinate& p0, const geom::Coordinate& p1);
+
+    /**
+     * Inserts a new site into the Subdivision, connecting it to the vertices of
+     * the containing triangle (or quadrilateral, if the split point falls on an
+     * existing edge).
+     * <p>
+     * This method does NOT maintain the Delaunay condition. If desired, this must
+     * be checked and enforced by the caller.
+     * <p>
+     * This method does NOT check if the inserted vertex falls on an edge. This
+     * must be checked by the caller, since this situation may cause erroneous
+     * triangulation
+     *
+     * @param v
+     *          the vertex to insert
+     * @return a new quad edge terminating in v
+     */
+    QuadEdge& insertSite(const Vertex& v);
+
+    /**
+     * Tests whether a QuadEdge is an edge incident on a frame triangle vertex.
+     *
+     * @param e
+     *          the edge to test
+     * @return true if the edge is connected to the frame triangle
+     */
+    bool isFrameEdge(const QuadEdge& e) const;
+
+    /**
+     * Tests whether a QuadEdge is an edge on the border of the frame facets and
+     * the internal facets. E.g. an edge which does not itself touch a frame
+     * vertex, but which touches an edge which does.
+     *
+     * @param e
+     *          the edge to test
+     * @return true if the edge is on the border of the frame
+     */
+    bool isFrameBorderEdge(const QuadEdge& e) const;
+
+    /**
+     * Tests whether a vertex is a vertex of the outer triangle.
+     *
+     * @param v
+     *          the vertex to test
+     * @return true if the vertex is an outer triangle vertex
+     */
+    bool isFrameVertex(const Vertex& v) const;
+
+
+    /**
+     * Tests whether a {@link Coordinate} lies on a {@link QuadEdge}, up to a
+     * tolerance determined by the subdivision tolerance.
+     *
+     * @param e
+     *          a QuadEdge
+     * @param p
+     *          a point
+     * @return true if the vertex lies on the edge
+     */
+    bool isOnEdge(const QuadEdge& e, const geom::Coordinate& p) const;
+
+    /**
+     * Tests whether a {@link Vertex} is the start or end vertex of a
+     * {@link QuadEdge}, up to the subdivision tolerance distance.
+     *
+     * @param e
+     * @param v
+     * @return true if the vertex is a endpoint of the edge
+     */
+    bool isVertexOfEdge(const QuadEdge& e, const Vertex& v) const;
+
+    /**
+     * Gets all primary quadedges in the subdivision.
+     * A primary edge is a {@link QuadEdge}
+     * which occupies the 0'th position in its array of associated quadedges.
+     * These provide the unique geometric edges of the triangulation.
+     *
+     * @param includeFrame true if the frame edges are to be included
+     * @return a List of QuadEdges. The caller takes ownership of the returned QuadEdgeList but not the
+     * items it contains.
+     */
+    std::unique_ptr<QuadEdgeList> getPrimaryEdges(bool includeFrame);
+
+    /*****************************************************************************
+     * Visitors
+     ****************************************************************************/
+
+    void visitTriangles(TriangleVisitor* triVisitor, bool includeFrame);
 
 private:
-	typedef std::stack<QuadEdge*> QuadEdgeStack;
-	typedef std::set<QuadEdge*> QuadEdgeSet;
-	typedef std::list< geom::CoordinateSequence*> TriList;
-
-	/**
-	 * The quadedges forming a single triangle.
-	 * Only one visitor is allowed to be active at a
-	 * time, so this is safe.
-	 */
-	QuadEdge* triEdges[3];
-
-	/**
-	 * Stores the edges for a visited triangle. Also pushes sym (neighbour) edges
-	 * on stack to visit later.
-	 *
-	 * @param edge
-	 * @param edgeStack
-	 * @param includeFrame
-	 * @return the visited triangle edges
-	 * @return null if the triangle should not be visited (for instance, if it is
-	 *         outer)
-	 */
-	QuadEdge** fetchTriangleToVisit(QuadEdge *edge, QuadEdgeStack &edgeStack, bool includeFrame,
-			QuadEdgeSet &visitedEdges);
-
-	/**
-	 * Gets the coordinates for each triangle in the subdivision as an array.
-	 *
-	 * @param includeFrame
-	 *          true if the frame triangles should be included
-	 * @param triList a list of Coordinate[4] representing each triangle
-	 */
-	void getTriangleCoordinates(TriList* triList, bool includeFrame);
+    typedef std::stack<QuadEdge*> QuadEdgeStack;
+    typedef std::set<QuadEdge*> QuadEdgeSet;
+    typedef std::list< geom::CoordinateSequence*> TriList;
+
+    /**
+     * The quadedges forming a single triangle.
+     * Only one visitor is allowed to be active at a
+     * time, so this is safe.
+     */
+    QuadEdge* triEdges[3];
+
+    /**
+     * Stores the edges for a visited triangle. Also pushes sym (neighbour) edges
+     * on stack to visit later.
+     *
+     * @param edge
+     * @param edgeStack
+     * @param includeFrame
+     * @return the visited triangle edges
+     * @return null if the triangle should not be visited (for instance, if it is
+     *         outer)
+     */
+    QuadEdge** fetchTriangleToVisit(QuadEdge* edge, QuadEdgeStack& edgeStack, bool includeFrame,
+                                    QuadEdgeSet& visitedEdges);
+
+    /**
+     * Gets the coordinates for each triangle in the subdivision as an array.
+     *
+     * @param includeFrame
+     *          true if the frame triangles should be included
+     * @param triList a list of Coordinate[4] representing each triangle
+     */
+    void getTriangleCoordinates(TriList* triList, bool includeFrame);
 
 private:
-	class TriangleCoordinatesVisitor;
-	class TriangleCircumcentreVisitor;
+    class TriangleCoordinatesVisitor;
+    class TriangleCircumcentreVisitor;
 
 public:
-	/**
-	 * Gets the geometry for the edges in the subdivision as a {@link MultiLineString}
-	 * containing 2-point lines.
-	 *
-	 * @param geomFact the GeometryFactory to use
-	 * @return a MultiLineString. The caller takes ownership of the returned object.
-	 */
-	std::unique_ptr<geom::MultiLineString> getEdges(const geom::GeometryFactory& geomFact);
-
-	/**
-	 * Gets the geometry for the triangles in a triangulated subdivision as a {@link GeometryCollection}
-	 * of triangular {@link Polygon}s.
-	 *
-	 * @param geomFact the GeometryFactory to use
-	 * @return a GeometryCollection of triangular Polygons. The caller takes ownership of the returned object.
-	 */
-	std::unique_ptr<geom::GeometryCollection> getTriangles(const geom::GeometryFactory &geomFact);
-
-	/**
-	 * Gets the cells in the Voronoi diagram for this triangulation.
-	 * The cells are returned as a {@link GeometryCollection} of {@link Polygon}s
-	 * The userData of each polygon is set to be the {@link Coordinate}
-	 * of the cell site.  This allows easily associating external
-	 * data associated with the sites to the cells.
-	 *
-	 * @param geomFact a geometry factory
-	 * @return a GeometryCollection of Polygons
-	 */
-	std::unique_ptr<geom::GeometryCollection> getVoronoiDiagram(const geom::GeometryFactory& geomFact);
-
-	/**
-	 * Gets the cells in the Voronoi diagram for this triangulation.
-	 * The cells are returned as a {@link GeometryCollection} of {@link LineString}s
-	 * The userData of each polygon is set to be the {@link Coordinate}
-	 * of the cell site.  This allows easily associating external
-	 * data associated with the sites to the cells.
-	 *
-	 * @param geomFact a geometry factory
-	 * @return a MultiLineString
-	 */
-	std::unique_ptr<geom::MultiLineString> getVoronoiDiagramEdges(const geom::GeometryFactory& geomFact);
-
-	/**
-	 * Gets a List of {@link Polygon}s for the Voronoi cells
-	 * of this triangulation.
-	 * The userData of each polygon is set to be the {@link Coordinate}
-	 * of the cell site.  This allows easily associating external
-	 * data associated with the sites to the cells.
-	 *
-	 * @param geomFact a geometry factory
-	 * @return a List of Polygons
-	 */
-	std::unique_ptr< std::vector<geom::Geometry*> > getVoronoiCellPolygons(const geom::GeometryFactory& geomFact);
-
-	/**
-	 * Gets a List of {@link LineString}s for the Voronoi cells
-	 * of this triangulation.
-	 * The userData of each LineString is set to be the {@link Coordinate}
-	 * of the cell site.  This allows easily associating external
-	 * data associated with the sites to the cells.
-	 *
-	 * @param geomFact a geometry factory
-	 * @return a List of LineString
-	 */
-	std::unique_ptr< std::vector<geom::Geometry*> > getVoronoiCellEdges(const geom::GeometryFactory& geomFact);
-
-	/**
-	 * Gets a collection of {@link QuadEdge}s whose origin
-	 * vertices are a unique set which includes
-	 * all vertices in the subdivision.
-	 * The frame vertices can be included if required.
-	 * This is useful for algorithms which require traversing the
-	 * subdivision starting at all vertices.
-	 * Returning a quadedge for each vertex
-	 * is more efficient than
-	 * the alternative of finding the actual vertices
-	 * using {@link #getVertices} and then locating
-	 * quadedges attached to them.
-	 *
-	 * @param includeFrame true if the frame vertices should be included
-	 * @return a collection of QuadEdge with the vertices of the subdivision as their origins
-	 */
-	std::unique_ptr<QuadEdgeSubdivision::QuadEdgeList> getVertexUniqueEdges(bool includeFrame);
-
-	/**
-	 * Gets the Voronoi cell around a site specified
-	 * by the origin of a QuadEdge.
-	 * The userData of the polygon is set to be the {@link Coordinate}
-	 * of the site.  This allows attaching external
-	 * data associated with the site to this cell polygon.
-	 *
-	 * @param qe a quadedge originating at the cell site
-	 * @param geomFact a factory for building the polygon
-	 * @return a polygon indicating the cell extent
-	 */
-	std::unique_ptr<geom::Geometry> getVoronoiCellPolygon(QuadEdge* qe ,const geom::GeometryFactory& geomFact);
-
-	/**
-	 * Gets the Voronoi cell edge around a site specified
-	 * by the origin of a QuadEdge.
-	 * The userData of the LineString is set to be the {@link Coordinate}
-	 * of the site.  This allows attaching external
-	 * data associated with the site to this cell polygon.
-	 *
-	 * @param qe a quadedge originating at the cell site
-	 * @param geomFact a factory for building the polygon
-	 * @return a polygon indicating the cell extent
-	 */
-	std::unique_ptr<geom::Geometry> getVoronoiCellEdge(QuadEdge* qe ,const geom::GeometryFactory& geomFact);
+    /**
+     * Gets the geometry for the edges in the subdivision as a {@link MultiLineString}
+     * containing 2-point lines.
+     *
+     * @param geomFact the GeometryFactory to use
+     * @return a MultiLineString. The caller takes ownership of the returned object.
+     */
+    std::unique_ptr<geom::MultiLineString> getEdges(const geom::GeometryFactory& geomFact);
+
+    /**
+     * Gets the geometry for the triangles in a triangulated subdivision as a {@link GeometryCollection}
+     * of triangular {@link Polygon}s.
+     *
+     * @param geomFact the GeometryFactory to use
+     * @return a GeometryCollection of triangular Polygons. The caller takes ownership of the returned object.
+     */
+    std::unique_ptr<geom::GeometryCollection> getTriangles(const geom::GeometryFactory& geomFact);
+
+    /**
+     * Gets the cells in the Voronoi diagram for this triangulation.
+     * The cells are returned as a {@link GeometryCollection} of {@link Polygon}s
+     * The userData of each polygon is set to be the {@link Coordinate}
+     * of the cell site.  This allows easily associating external
+     * data associated with the sites to the cells.
+     *
+     * @param geomFact a geometry factory
+     * @return a GeometryCollection of Polygons
+     */
+    std::unique_ptr<geom::GeometryCollection> getVoronoiDiagram(const geom::GeometryFactory& geomFact);
+
+    /**
+     * Gets the cells in the Voronoi diagram for this triangulation.
+     * The cells are returned as a {@link GeometryCollection} of {@link LineString}s
+     * The userData of each polygon is set to be the {@link Coordinate}
+     * of the cell site.  This allows easily associating external
+     * data associated with the sites to the cells.
+     *
+     * @param geomFact a geometry factory
+     * @return a MultiLineString
+     */
+    std::unique_ptr<geom::MultiLineString> getVoronoiDiagramEdges(const geom::GeometryFactory& geomFact);
+
+    /**
+     * Gets a List of {@link Polygon}s for the Voronoi cells
+     * of this triangulation.
+     * The userData of each polygon is set to be the {@link Coordinate}
+     * of the cell site.  This allows easily associating external
+     * data associated with the sites to the cells.
+     *
+     * @param geomFact a geometry factory
+     * @return a List of Polygons
+     */
+    std::unique_ptr< std::vector<geom::Geometry*> > getVoronoiCellPolygons(const geom::GeometryFactory& geomFact);
+
+    /**
+     * Gets a List of {@link LineString}s for the Voronoi cells
+     * of this triangulation.
+     * The userData of each LineString is set to be the {@link Coordinate}
+     * of the cell site.  This allows easily associating external
+     * data associated with the sites to the cells.
+     *
+     * @param geomFact a geometry factory
+     * @return a List of LineString
+     */
+    std::unique_ptr< std::vector<geom::Geometry*> > getVoronoiCellEdges(const geom::GeometryFactory& geomFact);
+
+    /**
+     * Gets a collection of {@link QuadEdge}s whose origin
+     * vertices are a unique set which includes
+     * all vertices in the subdivision.
+     * The frame vertices can be included if required.
+     * This is useful for algorithms which require traversing the
+     * subdivision starting at all vertices.
+     * Returning a quadedge for each vertex
+     * is more efficient than
+     * the alternative of finding the actual vertices
+     * using {@link #getVertices} and then locating
+     * quadedges attached to them.
+     *
+     * @param includeFrame true if the frame vertices should be included
+     * @return a collection of QuadEdge with the vertices of the subdivision as their origins
+     */
+    std::unique_ptr<QuadEdgeSubdivision::QuadEdgeList> getVertexUniqueEdges(bool includeFrame);
+
+    /**
+     * Gets the Voronoi cell around a site specified
+     * by the origin of a QuadEdge.
+     * The userData of the polygon is set to be the {@link Coordinate}
+     * of the site.  This allows attaching external
+     * data associated with the site to this cell polygon.
+     *
+     * @param qe a quadedge originating at the cell site
+     * @param geomFact a factory for building the polygon
+     * @return a polygon indicating the cell extent
+     */
+    std::unique_ptr<geom::Geometry> getVoronoiCellPolygon(QuadEdge* qe, const geom::GeometryFactory& geomFact);
+
+    /**
+     * Gets the Voronoi cell edge around a site specified
+     * by the origin of a QuadEdge.
+     * The userData of the LineString is set to be the {@link Coordinate}
+     * of the site.  This allows attaching external
+     * data associated with the site to this cell polygon.
+     *
+     * @param qe a quadedge originating at the cell site
+     * @param geomFact a factory for building the polygon
+     * @return a polygon indicating the cell extent
+     */
+    std::unique_ptr<geom::Geometry> getVoronoiCellEdge(QuadEdge* qe, const geom::GeometryFactory& geomFact);
 
 };
 
diff --git a/include/geos/triangulate/quadedge/TrianglePredicate.h b/include/geos/triangulate/quadedge/TrianglePredicate.h
index 86c394b..2218f43 100644
--- a/include/geos/triangulate/quadedge/TrianglePredicate.h
+++ b/include/geos/triangulate/quadedge/TrianglePredicate.h
@@ -38,73 +38,72 @@ class Coordinate;
  * @author Benjamin Campbell
  *
  */
-class TrianglePredicate
-{
+class TrianglePredicate {
 public:
-  /**
-   * Tests if a point is inside the circle defined by
-   * the triangle with vertices a, b, c (oriented counter-clockwise).
-   * This test uses simple
-   * double-precision arithmetic, and thus may not be robust.
-   *
-   * @param a a vertex of the triangle
-   * @param b a vertex of the triangle
-   * @param c a vertex of the triangle
-   * @param P the point to test
-   * @return true if this point is inside the circle defined by the points a, b, c
-   */
-  static bool isInCircleNonRobust(
-	  const Coordinate &a, const Coordinate &b, const Coordinate &c,
-	  const Coordinate &p);
+    /**
+     * Tests if a point is inside the circle defined by
+     * the triangle with vertices a, b, c (oriented counter-clockwise).
+     * This test uses simple
+     * double-precision arithmetic, and thus may not be robust.
+     *
+     * @param a a vertex of the triangle
+     * @param b a vertex of the triangle
+     * @param c a vertex of the triangle
+     * @param P the point to test
+     * @return true if this point is inside the circle defined by the points a, b, c
+     */
+    static bool isInCircleNonRobust(
+        const Coordinate& a, const Coordinate& b, const Coordinate& c,
+        const Coordinate& p);
 
-  /**
-   * Tests if a point is inside the circle defined by
-   * the triangle with vertices a, b, c (oriented counter-clockwise).
-   * This test uses simple
-   * double-precision arithmetic, and thus is not 10% robust.
-   * However, by using normalization to the origin
-   * it provides improved robustness and increased performance.
-   * <p>
-   * Based on code by J.R.Shewchuk.
-   *
-   *
-   * @param a a vertex of the triangle
-   * @param b a vertex of the triangle
-   * @param c a vertex of the triangle
-   * @param P the point to test
-   * @return true if this point is inside the circle defined by the points a, b, c
-   */
-  static bool isInCircleNormalized(
-	  const Coordinate &a, const Coordinate &b, const Coordinate &c,
-	  const Coordinate &p);
+    /**
+     * Tests if a point is inside the circle defined by
+     * the triangle with vertices a, b, c (oriented counter-clockwise).
+     * This test uses simple
+     * double-precision arithmetic, and thus is not 10% robust.
+     * However, by using normalization to the origin
+     * it provides improved robustness and increased performance.
+     * <p>
+     * Based on code by J.R.Shewchuk.
+     *
+     *
+     * @param a a vertex of the triangle
+     * @param b a vertex of the triangle
+     * @param c a vertex of the triangle
+     * @param P the point to test
+     * @return true if this point is inside the circle defined by the points a, b, c
+     */
+    static bool isInCircleNormalized(
+        const Coordinate& a, const Coordinate& b, const Coordinate& c,
+        const Coordinate& p);
 
 private:
-  /**
-   * Computes twice the area of the oriented triangle (a, b, c), i.e., the area is positive if the
-   * triangle is oriented counterclockwise.
-   *
-   * @param a a vertex of the triangle
-   * @param b a vertex of the triangle
-   * @param c a vertex of the triangle
-   */
-  static double triArea(const Coordinate &a,
-		  const Coordinate &b, const Coordinate &c);
+    /**
+     * Computes twice the area of the oriented triangle (a, b, c), i.e., the area is positive if the
+     * triangle is oriented counterclockwise.
+     *
+     * @param a a vertex of the triangle
+     * @param b a vertex of the triangle
+     * @param c a vertex of the triangle
+     */
+    static double triArea(const Coordinate& a,
+                          const Coordinate& b, const Coordinate& c);
 
 public:
-  /**
-   * Tests if a point is inside the circle defined by
-   * the triangle with vertices a, b, c (oriented counter-clockwise).
-   * This method uses more robust computation.
-   *
-   * @param a a vertex of the triangle
-   * @param b a vertex of the triangle
-   * @param c a vertex of the triangle
-   * @param P the point to test
-   * @return true if this point is inside the circle defined by the points a, b, c
-   */
-  static bool isInCircleRobust(
-	  const Coordinate &a, const Coordinate &b, const Coordinate &c,
-	  const Coordinate &p);
+    /**
+     * Tests if a point is inside the circle defined by
+     * the triangle with vertices a, b, c (oriented counter-clockwise).
+     * This method uses more robust computation.
+     *
+     * @param a a vertex of the triangle
+     * @param b a vertex of the triangle
+     * @param c a vertex of the triangle
+     * @param P the point to test
+     * @return true if this point is inside the circle defined by the points a, b, c
+     */
+    static bool isInCircleRobust(
+        const Coordinate& a, const Coordinate& b, const Coordinate& c,
+        const Coordinate& p);
 } ;
 
 } // namespace geos.geom
diff --git a/include/geos/triangulate/quadedge/TriangleVisitor.h b/include/geos/triangulate/quadedge/TriangleVisitor.h
index 859e4b8..966f8ca 100644
--- a/include/geos/triangulate/quadedge/TriangleVisitor.h
+++ b/include/geos/triangulate/quadedge/TriangleVisitor.h
@@ -39,7 +39,7 @@ public:
      * @param triEdges an array of the 3 quad edges in a triangle (in CCW order)
      */
     virtual void visit(QuadEdge* triEdges[3]) = 0;
-	virtual ~TriangleVisitor() = 0 ;
+    virtual ~TriangleVisitor() = 0 ;
 private:
 } ;
 
diff --git a/include/geos/triangulate/quadedge/Vertex.h b/include/geos/triangulate/quadedge/Vertex.h
index 8c5becd..17eb663 100644
--- a/include/geos/triangulate/quadedge/Vertex.h
+++ b/include/geos/triangulate/quadedge/Vertex.h
@@ -30,7 +30,7 @@
 namespace geos {
 namespace triangulate {
 namespace quadedge {
-	class QuadEdge;
+class QuadEdge;
 }
 }
 }
@@ -60,223 +60,253 @@ namespace quadedge { //geos.triangulate.quadedge
 
 class GEOS_DLL Vertex {
 public:
-	static const int LEFT		= 0;
-	static const int RIGHT	   = 1;
-	static const int BEYOND	  = 2;
-	static const int BEHIND	  = 3;
-	static const int BETWEEN	 = 4;
-	static const int ORIGIN	  = 5;
-	static const int DESTINATION = 6;
+    static const int LEFT		= 0;
+    static const int RIGHT	   = 1;
+    static const int BEYOND	  = 2;
+    static const int BEHIND	  = 3;
+    static const int BETWEEN	 = 4;
+    static const int ORIGIN	  = 5;
+    static const int DESTINATION = 6;
 private:
-	geom::Coordinate	  p;
+    geom::Coordinate	  p;
 
 public:
-	Vertex(double _x, double _y);
-
-	Vertex(double _x, double _y, double _z);
-
-	Vertex(const geom::Coordinate &_p);
-
-	Vertex();
-
-	inline double getX() const {
-		return p.x;
-	}
-
-	inline double getY() const {
-		return p.y;
-	}
-
-	inline double getZ() const {
-		return p.z;
-	}
-
-	inline void setZ(double _z) {
-		p.z = _z;
-	}
-
-	inline const geom::Coordinate& getCoordinate() const {
-		return p;
-	}
-
-	inline bool equals(const Vertex &_x) const
-	{
-		if (p.x == _x.getX() && p.y == _x.getY())
-			return true;
-		return false;
-	}
-
-	inline bool equals(const Vertex &_x, double tolerance) const
-	{
-		if (p.distance(_x.getCoordinate()) < tolerance)
-			return true;
-		return false;
-	}
-
-	virtual int classify(const Vertex &p0, const Vertex &p1);
-
-	/**
-	 * Computes the cross product k = u X v.
-	 *
-	 * @param v a vertex
-	 * @return returns the magnitude of u X v
-	 */
-	inline double crossProduct(const Vertex &v) const
-	{
-		return (p.x * v.getY() - p.y * v.getX());
-	}
-
-	/**
-	 * Computes the inner or dot product
-	 *
-	 * @param v, a vertex
-	 * @return returns the dot product u.v
-	 */
-	inline double dot(Vertex v) const
-	{
-		return (p.x * v.getX() + p.y * v.getY());
-	}
-
-	/**
-	 * Computes the scalar product c(v)
-	 *
-	 * @param v, a vertex
-	 * @return returns the scaled vector
-	 */
-	inline std::unique_ptr<Vertex> times(double c) const {
-		return std::unique_ptr<Vertex>(new Vertex(c * p.x, c * p.y));
-	}
-
-	/* Vector addition */
-	inline std::unique_ptr<Vertex> sum(Vertex v) const {
-		return std::unique_ptr<Vertex>(new Vertex(p.x + v.getX(), p.y + v.getY()));
-	}
-
-	/* and subtraction */
-	inline std::unique_ptr<Vertex> sub(const Vertex &v) const {
-		return std::unique_ptr<Vertex>(new Vertex(p.x - v.getX(), p.y - v.getY()));
-	}
-
-	/* magnitude of vector */
-	inline double magn() const {
-		return (sqrt(p.x * p.x + p.y * p.y));
-	}
-
-	/* returns k X v (cross product). this is a vector perpendicular to v */
-	inline std::unique_ptr<Vertex> cross() const {
-		return std::unique_ptr<Vertex>(new Vertex(p.y, -p.x));
-	}
-
-  /** ************************************************************* */
-  /***********************************************************************************************
-   * Geometric primitives /
-   **********************************************************************************************/
-
-	/**
-	 * Tests if the vertex is inside the circle defined by
-	 * the triangle with vertices a, b, c (oriented counter-clockwise).
-	 *
-	 * @param a a vertex of the triangle
-	 * @param b a vertex of the triangle
-	 * @param c a vertex of the triangle
-	 * @return true if this vertex is in the circumcircle of (a,b,c)
-	 */
-	virtual bool isInCircle(const Vertex &a, const Vertex &b, const Vertex &c) const;
-
-	/**
-	 * Tests whether the triangle formed by this vertex and two
-	 * other vertices is in CCW orientation.
-	 *
-	 * @param b a vertex
-	 * @param c a vertex
-	 * @returns true if the triangle is oriented CCW
-	 */
-	inline bool isCCW(const Vertex &b, const Vertex &c) const
-	{
-		// is equal to the signed area of the triangle
-
-		return (b.p.x - p.x) * (c.p.y - p.y)
-			- (b.p.y - p.y) * (c.p.x - p.x) > 0;
-	}
-
-	bool rightOf(const QuadEdge &e) const;
-	bool leftOf(const QuadEdge &e) const;
+    Vertex(double _x, double _y);
+
+    Vertex(double _x, double _y, double _z);
+
+    Vertex(const geom::Coordinate& _p);
+
+    Vertex();
+
+    inline double
+    getX() const
+    {
+        return p.x;
+    }
+
+    inline double
+    getY() const
+    {
+        return p.y;
+    }
+
+    inline double
+    getZ() const
+    {
+        return p.z;
+    }
+
+    inline void
+    setZ(double _z)
+    {
+        p.z = _z;
+    }
+
+    inline const geom::Coordinate&
+    getCoordinate() const
+    {
+        return p;
+    }
+
+    inline bool
+    equals(const Vertex& _x) const
+    {
+        if(p.x == _x.getX() && p.y == _x.getY()) {
+            return true;
+        }
+        return false;
+    }
+
+    inline bool
+    equals(const Vertex& _x, double tolerance) const
+    {
+        if(p.distance(_x.getCoordinate()) < tolerance) {
+            return true;
+        }
+        return false;
+    }
+
+    virtual int classify(const Vertex& p0, const Vertex& p1);
+
+    /**
+     * Computes the cross product k = u X v.
+     *
+     * @param v a vertex
+     * @return returns the magnitude of u X v
+     */
+    inline double
+    crossProduct(const Vertex& v) const
+    {
+        return (p.x * v.getY() - p.y * v.getX());
+    }
+
+    /**
+     * Computes the inner or dot product
+     *
+     * @param v, a vertex
+     * @return returns the dot product u.v
+     */
+    inline double
+    dot(Vertex v) const
+    {
+        return (p.x * v.getX() + p.y * v.getY());
+    }
+
+    /**
+     * Computes the scalar product c(v)
+     *
+     * @param v, a vertex
+     * @return returns the scaled vector
+     */
+    inline std::unique_ptr<Vertex>
+    times(double c) const
+    {
+        return std::unique_ptr<Vertex>(new Vertex(c * p.x, c * p.y));
+    }
+
+    /* Vector addition */
+    inline std::unique_ptr<Vertex>
+    sum(Vertex v) const
+    {
+        return std::unique_ptr<Vertex>(new Vertex(p.x + v.getX(), p.y + v.getY()));
+    }
+
+    /* and subtraction */
+    inline std::unique_ptr<Vertex>
+    sub(const Vertex& v) const
+    {
+        return std::unique_ptr<Vertex>(new Vertex(p.x - v.getX(), p.y - v.getY()));
+    }
+
+    /* magnitude of vector */
+    inline double
+    magn() const
+    {
+        return (sqrt(p.x * p.x + p.y * p.y));
+    }
+
+    /* returns k X v (cross product). this is a vector perpendicular to v */
+    inline std::unique_ptr<Vertex>
+    cross() const
+    {
+        return std::unique_ptr<Vertex>(new Vertex(p.y, -p.x));
+    }
+
+    /** ************************************************************* */
+    /***********************************************************************************************
+     * Geometric primitives /
+     **********************************************************************************************/
+
+    /**
+     * Tests if the vertex is inside the circle defined by
+     * the triangle with vertices a, b, c (oriented counter-clockwise).
+     *
+     * @param a a vertex of the triangle
+     * @param b a vertex of the triangle
+     * @param c a vertex of the triangle
+     * @return true if this vertex is in the circumcircle of (a,b,c)
+     */
+    virtual bool isInCircle(const Vertex& a, const Vertex& b, const Vertex& c) const;
+
+    /**
+     * Tests whether the triangle formed by this vertex and two
+     * other vertices is in CCW orientation.
+     *
+     * @param b a vertex
+     * @param c a vertex
+     * @returns true if the triangle is oriented CCW
+     */
+    inline bool
+    isCCW(const Vertex& b, const Vertex& c) const
+    {
+        // is equal to the signed area of the triangle
+
+        return (b.p.x - p.x) * (c.p.y - p.y)
+               - (b.p.y - p.y) * (c.p.x - p.x) > 0;
+    }
+
+    bool rightOf(const QuadEdge& e) const;
+    bool leftOf(const QuadEdge& e) const;
 
 private:
-	static std::unique_ptr<algorithm::HCoordinate> bisector(const Vertex &a, const Vertex &b);
-
-	inline double distance(const Vertex &v1, const Vertex &v2)
-	{
-		return sqrt(pow(v2.getX() - v1.getX(), 2.0)
-				+ pow(v2.getY() - v1.getY(), 2.0));
-	}
-
-	/**
-	 * Computes the value of the ratio of the circumradius to shortest edge. If smaller than some
-	 * given tolerance B, the associated triangle is considered skinny. For an equal lateral
-	 * triangle this value is 0.57735. The ratio is related to the minimum triangle angle theta by:
-	 * circumRadius/shortestEdge = 1/(2sin(theta)).
-	 *
-	 * @param b second vertex of the triangle
-	 * @param c third vertex of the triangle
-	 * @return ratio of circumradius to shortest edge.
-	 */
-	virtual double circumRadiusRatio(const Vertex &b, const Vertex &c);
-
-	/**
-	 * returns a new vertex that is mid-way between this vertex and another end point.
-	 *
-	 * @param a the other end point.
-	 * @return the point mid-way between this and that.
-	 */
-	virtual std::unique_ptr<Vertex> midPoint(const Vertex &a);
-
-	/**
-	 * Computes the centre of the circumcircle of this vertex and two others.
-	 *
-	 * @param b
-	 * @param c
-	 * @return the Coordinate which is the circumcircle of the 3 points.
-	 */
-	virtual std::unique_ptr<Vertex> circleCenter(const Vertex &b, const Vertex &c) const;
-
-	/**
-	 * For this vertex enclosed in a triangle defined by three verticies v0, v1 and v2, interpolate
-	 * a z value from the surrounding vertices.
-	 */
-	virtual double interpolateZValue(const Vertex &v0, const Vertex &v1,
-			const Vertex &v2) const;
-
-	/**
-	 * Interpolates the Z-value (height) of a point enclosed in a triangle
-	 * whose vertices all have Z values.
-	 * The containing triangle must not be degenerate
-	 * (in other words, the three vertices must enclose a
-	 * non-zero area).
-	 *
-	 * @param p the point to interpolate the Z value of
-	 * @param v0 a vertex of a triangle containing the p
-	 * @param v1 a vertex of a triangle containing the p
-	 * @param v2 a vertex of a triangle containing the p
-	 * @return the interpolated Z-value (height) of the point
-	 */
-	static double interpolateZ(const geom::Coordinate &p, const geom::Coordinate &v0,
-			const geom::Coordinate &v1, const geom::Coordinate &v2);
-
-	/**
-	 * Computes the interpolated Z-value for a point p lying on the segment p0-p1
-	 *
-	 * @param p
-	 * @param p0
-	 * @param p1
-	 * @return the interpolated Z value
-	 */
-	static double interpolateZ(const geom::Coordinate &p, const geom::Coordinate &p0,
-			const geom::Coordinate &p1);
+    static std::unique_ptr<algorithm::HCoordinate> bisector(const Vertex& a, const Vertex& b);
+
+    inline double
+    distance(const Vertex& v1, const Vertex& v2)
+    {
+        return sqrt(pow(v2.getX() - v1.getX(), 2.0)
+                    + pow(v2.getY() - v1.getY(), 2.0));
+    }
+
+    /**
+     * Computes the value of the ratio of the circumradius to shortest edge. If smaller than some
+     * given tolerance B, the associated triangle is considered skinny. For an equal lateral
+     * triangle this value is 0.57735. The ratio is related to the minimum triangle angle theta by:
+     * circumRadius/shortestEdge = 1/(2sin(theta)).
+     *
+     * @param b second vertex of the triangle
+     * @param c third vertex of the triangle
+     * @return ratio of circumradius to shortest edge.
+     */
+    virtual double circumRadiusRatio(const Vertex& b, const Vertex& c);
+
+    /**
+     * returns a new vertex that is mid-way between this vertex and another end point.
+     *
+     * @param a the other end point.
+     * @return the point mid-way between this and that.
+     */
+    virtual std::unique_ptr<Vertex> midPoint(const Vertex& a);
+
+    /**
+     * Computes the centre of the circumcircle of this vertex and two others.
+     *
+     * @param b
+     * @param c
+     * @return the Coordinate which is the circumcircle of the 3 points.
+     */
+    virtual std::unique_ptr<Vertex> circleCenter(const Vertex& b, const Vertex& c) const;
+
+    /**
+     * For this vertex enclosed in a triangle defined by three verticies v0, v1 and v2, interpolate
+     * a z value from the surrounding vertices.
+     */
+    virtual double interpolateZValue(const Vertex& v0, const Vertex& v1,
+                                     const Vertex& v2) const;
+
+    /**
+     * Interpolates the Z-value (height) of a point enclosed in a triangle
+     * whose vertices all have Z values.
+     * The containing triangle must not be degenerate
+     * (in other words, the three vertices must enclose a
+     * non-zero area).
+     *
+     * @param p the point to interpolate the Z value of
+     * @param v0 a vertex of a triangle containing the p
+     * @param v1 a vertex of a triangle containing the p
+     * @param v2 a vertex of a triangle containing the p
+     * @return the interpolated Z-value (height) of the point
+     */
+    static double interpolateZ(const geom::Coordinate& p, const geom::Coordinate& v0,
+                               const geom::Coordinate& v1, const geom::Coordinate& v2);
+
+    /**
+     * Computes the interpolated Z-value for a point p lying on the segment p0-p1
+     *
+     * @param p
+     * @param p0
+     * @param p1
+     * @return the interpolated Z value
+     */
+    static double interpolateZ(const geom::Coordinate& p, const geom::Coordinate& p0,
+                               const geom::Coordinate& p1);
 };
 
-inline bool operator<(const Vertex& v1, const Vertex& v2) {
-  return v1.getCoordinate() < v2.getCoordinate();
+inline bool
+operator<(const Vertex& v1, const Vertex& v2)
+{
+    return v1.getCoordinate() < v2.getCoordinate();
 }
 
 } //namespace geos.triangulate.quadedge
diff --git a/include/geos/unload.h b/include/geos/unload.h
index 662683c..6124ec8 100644
--- a/include/geos/unload.h
+++ b/include/geos/unload.h
@@ -20,13 +20,12 @@
 namespace geos {
 namespace io {
 
-class GEOS_DLL Unload
-{
+class GEOS_DLL Unload {
 private:
-	Unload(void) {}
-	~Unload(void) {}
+    Unload(void) {}
+    ~Unload(void) {}
 public:
-	static void Release();
+    static void Release();
 };
 
 }
diff --git a/include/geos/util.h b/include/geos/util.h
index a53d746..cad5c5a 100644
--- a/include/geos/util.h
+++ b/include/geos/util.h
@@ -35,10 +35,10 @@
 // Private macros definition
 //
 
-namespace geos
-{
-    template<class T>
-    void ignore_unused_variable_warning(T const& ) {}
+namespace geos {
+template<class T>
+void
+ignore_unused_variable_warning(T const&) {}
 }
 
 
diff --git a/include/geos/util/Assert.h b/include/geos/util/Assert.h
index aa3964d..67b680b 100644
--- a/include/geos/util/Assert.h
+++ b/include/geos/util/Assert.h
@@ -21,9 +21,9 @@
 
 // Forward declarations
 namespace geos {
-	namespace geom {
-		class Coordinate;
-	}
+namespace geom {
+class Coordinate;
+}
 }
 
 namespace geos {
@@ -32,27 +32,34 @@ namespace util { // geos.util
 class GEOS_DLL Assert {
 public:
 
-	static void isTrue(bool assertion, const std::string& message);
+    static void isTrue(bool assertion, const std::string& message);
 
-	static void isTrue(bool assertion) {
-		isTrue(assertion, std::string());
-	}
+    static void
+    isTrue(bool assertion)
+    {
+        isTrue(assertion, std::string());
+    }
 
 
-	static void equals(const geom::Coordinate& expectedValue,
-			const geom::Coordinate& actualValue,
-			const std::string& message);
+    static void equals(const geom::Coordinate& expectedValue,
+                       const geom::Coordinate& actualValue,
+                       const std::string& message);
 
-	static void equals(const geom::Coordinate& expectedValue,
-			const geom::Coordinate& actualValue)
-	{
-		equals(expectedValue, actualValue, std::string());
-	}
+    static void
+    equals(const geom::Coordinate& expectedValue,
+           const geom::Coordinate& actualValue)
+    {
+        equals(expectedValue, actualValue, std::string());
+    }
 
 
-	static void shouldNeverReachHere(const std::string& message);
+    static void shouldNeverReachHere(const std::string& message);
 
-	static void shouldNeverReachHere() { shouldNeverReachHere(std::string()); }
+    static void
+    shouldNeverReachHere()
+    {
+        shouldNeverReachHere(std::string());
+    }
 };
 
 } // namespace geos.util
diff --git a/include/geos/util/AssertionFailedException.h b/include/geos/util/AssertionFailedException.h
index 7142c69..a41c8d4 100644
--- a/include/geos/util/AssertionFailedException.h
+++ b/include/geos/util/AssertionFailedException.h
@@ -31,17 +31,17 @@ class GEOS_DLL AssertionFailedException: public GEOSException {
 
 public:
 
-	AssertionFailedException()
-		:
-		GEOSException("AssertionFailedException", "")
-	{}
+    AssertionFailedException()
+        :
+        GEOSException("AssertionFailedException", "")
+    {}
 
-	AssertionFailedException(const std::string& msg)
-		:
-		GEOSException("AssertionFailedException", msg)
-	{}
+    AssertionFailedException(const std::string& msg)
+        :
+        GEOSException("AssertionFailedException", msg)
+    {}
 
-	~AssertionFailedException() throw() override {}
+    ~AssertionFailedException() throw() override {}
 };
 
 } // namespace geos.util
diff --git a/include/geos/util/CoordinateArrayFilter.h b/include/geos/util/CoordinateArrayFilter.h
index 520841c..e7c4d12 100644
--- a/include/geos/util/CoordinateArrayFilter.h
+++ b/include/geos/util/CoordinateArrayFilter.h
@@ -35,24 +35,26 @@ namespace util { // geos::util
  */
 class GEOS_DLL CoordinateArrayFilter: public geom::CoordinateFilter {
 private:
-	geom::Coordinate::ConstVect &pts; // target vector reference
+    geom::Coordinate::ConstVect& pts; // target vector reference
 public:
-	/**
-	 * Constructs a CoordinateArrayFilter.
-	 *
-	 * @param  target   The destination vector.
-	 */
-	CoordinateArrayFilter(geom::Coordinate::ConstVect& target)
-		:
-		pts(target)
-		{}
-
-	virtual ~CoordinateArrayFilter() {}
-
-	virtual void filter_ro(const geom::Coordinate *coord)
-	{
-		pts.push_back(coord);
-	}
+    /**
+     * Constructs a CoordinateArrayFilter.
+     *
+     * @param  target   The destination vector.
+     */
+    CoordinateArrayFilter(geom::Coordinate::ConstVect& target)
+        :
+        pts(target)
+    {}
+
+    virtual
+    ~CoordinateArrayFilter() {}
+
+    virtual void
+    filter_ro(const geom::Coordinate* coord)
+    {
+        pts.push_back(coord);
+    }
 };
 
 
diff --git a/include/geos/util/GEOSException.h b/include/geos/util/GEOSException.h
index a1ead30..1ecfaaa 100644
--- a/include/geos/util/GEOSException.h
+++ b/include/geos/util/GEOSException.h
@@ -39,20 +39,20 @@ class GEOS_DLL GEOSException: public std::runtime_error {
 
 public:
 
-	GEOSException()
-		:
-		std::runtime_error("Unknown error")
-	{}
+    GEOSException()
+        :
+        std::runtime_error("Unknown error")
+    {}
 
-	GEOSException(std::string const& msg)
-		:
-		std::runtime_error(msg)
-	{}
+    GEOSException(std::string const& msg)
+        :
+        std::runtime_error(msg)
+    {}
 
-	GEOSException(std::string const& name, std::string const& msg)
-		:
-		std::runtime_error(name + ": "+msg)
-	{}
+    GEOSException(std::string const& name, std::string const& msg)
+        :
+        std::runtime_error(name + ": " + msg)
+    {}
 
 };
 
diff --git a/include/geos/util/GeometricShapeFactory.h b/include/geos/util/GeometricShapeFactory.h
index 4bc2d3f..b6f0ded 100644
--- a/include/geos/util/GeometricShapeFactory.h
+++ b/include/geos/util/GeometricShapeFactory.h
@@ -33,14 +33,14 @@
 
 // Forward declarations
 namespace geos {
-	namespace geom {
-		class Coordinate;
-		class Envelope;
-		class Polygon;
-		class GeometryFactory;
-		class PrecisionModel;
-		class LineString;
-	}
+namespace geom {
+class Coordinate;
+class Envelope;
+class Polygon;
+class GeometryFactory;
+class PrecisionModel;
+class LineString;
+}
 }
 
 namespace geos {
@@ -65,128 +65,129 @@ namespace util { // geos::util
  */
 class GEOS_DLL GeometricShapeFactory {
 protected:
-	class Dimensions {
-	public:
-		Dimensions();
-		geom::Coordinate base;
-		geom::Coordinate centre;
-		double width;
-		double height;
-		void setBase(const geom::Coordinate& newBase);
-		void setCentre(const geom::Coordinate& newCentre);
-		void setSize(double size);
-		void setWidth(double nWidth);
-		void setHeight(double nHeight);
-
-		// Return newly-allocated object, ownership transferred
-		geom::Envelope* getEnvelope() const;
-	};
-	const geom::GeometryFactory* geomFact; // externally owned
-	const geom::PrecisionModel* precModel; // externally owned
-	Dimensions dim;
-	int nPts;
-
-	geom::Coordinate coord(double x, double y) const;
+    class Dimensions {
+    public:
+        Dimensions();
+        geom::Coordinate base;
+        geom::Coordinate centre;
+        double width;
+        double height;
+        void setBase(const geom::Coordinate& newBase);
+        void setCentre(const geom::Coordinate& newCentre);
+        void setSize(double size);
+        void setWidth(double nWidth);
+        void setHeight(double nHeight);
+
+        // Return newly-allocated object, ownership transferred
+        geom::Envelope* getEnvelope() const;
+    };
+    const geom::GeometryFactory* geomFact; // externally owned
+    const geom::PrecisionModel* precModel; // externally owned
+    Dimensions dim;
+    int nPts;
+
+    geom::Coordinate coord(double x, double y) const;
 
 public:
 
-	/**
-	 * \brief
-	 * Create a shape factory which will create shapes using the given
-	 * GeometryFactory.
-	 *
-	 * @param factory the factory to use. You need to keep the
-	 *	factory alive for the whole GeometricShapeFactory
-	 *	life time.
-	 *
-	 */
-	GeometricShapeFactory(const geom::GeometryFactory *factory);
-
-	virtual ~GeometricShapeFactory() {}
-
-	/**
-	 * \brief Creates an elliptical arc, as a LineString.
-	 *
-	 * The arc is always created in a counter-clockwise direction.
-	 *
-	 * @param startAng start angle in radians
-	 * @param angExtent size of angle in radians
-	 * @return an elliptical arc
-	 */
-	geom::LineString* createArc(double startAng, double angExtent);
-
-	/**
-	 * \brief Creates an elliptical arc polygon.
-	 *
-	 * The polygon is formed from the specified arc of an ellipse
-	 * and the two radii connecting the endpoints to the centre of
-	 * the ellipse.
-	 *
-	 * @param startAng start angle in radians
-	 * @param angExtent size of angle in radians
-	 * @return an elliptical arc polygon
-	 */
-	geom::Polygon* createArcPolygon(double startAng, double angExt);
-
-	/**
-	 * \brief Creates a circular Polygon.
-	 *
-	 * @return a circle
-	 */
-	geom::Polygon* createCircle();
-
-	/**
-	 * \brief Creates a rectangular Polygon.
-	 *
-	 * @return a rectangular Polygon
-	 */
-	geom::Polygon* createRectangle();
-
-	/**
-	 * \brief
-	 * Sets the location of the shape by specifying the base coordinate
-	 * (which in most cases is the * lower left point of the envelope
-	 * containing the shape).
-	 *
-	 * @param base the base coordinate of the shape
-	 */
-	void setBase(const geom::Coordinate& base);
-
-	/**
-	 * \brief
-	 * Sets the location of the shape by specifying the centre of
-	 * the shape's bounding box
-	 *
-	 * @param centre the centre coordinate of the shape
-	 */
-	void setCentre(const geom::Coordinate& centre);
-
-	/**
-	 * \brief Sets the height of the shape.
-	 *
-	 * @param height the height of the shape
-	 */
-	void setHeight(double height);
-
-	/**
-	 * \brief Sets the total number of points in the created Geometry
-	 */
-	void setNumPoints(int nNPts);
-
-	/**
-	 * \brief
-	 * Sets the size of the extent of the shape in both x and y directions.
-	 *
-	 * @param size the size of the shape's extent
-	 */
-	void setSize(double size);
-
-	/**
-	 * \brief Sets the width of the shape.
-	 *
-	 * @param width the width of the shape
-	 */
-	void setWidth(double width);
+    /**
+     * \brief
+     * Create a shape factory which will create shapes using the given
+     * GeometryFactory.
+     *
+     * @param factory the factory to use. You need to keep the
+     *	factory alive for the whole GeometricShapeFactory
+     *	life time.
+     *
+     */
+    GeometricShapeFactory(const geom::GeometryFactory* factory);
+
+    virtual
+    ~GeometricShapeFactory() {}
+
+    /**
+     * \brief Creates an elliptical arc, as a LineString.
+     *
+     * The arc is always created in a counter-clockwise direction.
+     *
+     * @param startAng start angle in radians
+     * @param angExtent size of angle in radians
+     * @return an elliptical arc
+     */
+    geom::LineString* createArc(double startAng, double angExtent);
+
+    /**
+     * \brief Creates an elliptical arc polygon.
+     *
+     * The polygon is formed from the specified arc of an ellipse
+     * and the two radii connecting the endpoints to the centre of
+     * the ellipse.
+     *
+     * @param startAng start angle in radians
+     * @param angExtent size of angle in radians
+     * @return an elliptical arc polygon
+     */
+    geom::Polygon* createArcPolygon(double startAng, double angExt);
+
+    /**
+     * \brief Creates a circular Polygon.
+     *
+     * @return a circle
+     */
+    geom::Polygon* createCircle();
+
+    /**
+     * \brief Creates a rectangular Polygon.
+     *
+     * @return a rectangular Polygon
+     */
+    geom::Polygon* createRectangle();
+
+    /**
+     * \brief
+     * Sets the location of the shape by specifying the base coordinate
+     * (which in most cases is the * lower left point of the envelope
+     * containing the shape).
+     *
+     * @param base the base coordinate of the shape
+     */
+    void setBase(const geom::Coordinate& base);
+
+    /**
+     * \brief
+     * Sets the location of the shape by specifying the centre of
+     * the shape's bounding box
+     *
+     * @param centre the centre coordinate of the shape
+     */
+    void setCentre(const geom::Coordinate& centre);
+
+    /**
+     * \brief Sets the height of the shape.
+     *
+     * @param height the height of the shape
+     */
+    void setHeight(double height);
+
+    /**
+     * \brief Sets the total number of points in the created Geometry
+     */
+    void setNumPoints(int nNPts);
+
+    /**
+     * \brief
+     * Sets the size of the extent of the shape in both x and y directions.
+     *
+     * @param size the size of the shape's extent
+     */
+    void setSize(double size);
+
+    /**
+     * \brief Sets the width of the shape.
+     *
+     * @param width the width of the shape
+     */
+    void setWidth(double width);
 
 };
 
diff --git a/include/geos/util/IllegalArgumentException.h b/include/geos/util/IllegalArgumentException.h
index f58a7d2..f47647d 100644
--- a/include/geos/util/IllegalArgumentException.h
+++ b/include/geos/util/IllegalArgumentException.h
@@ -33,17 +33,17 @@ namespace util { // geos::util
  */
 class GEOS_DLL IllegalArgumentException: public GEOSException {
 public:
-	IllegalArgumentException()
-		:
-		GEOSException("IllegalArgumentException", "")
-	{}
+    IllegalArgumentException()
+        :
+        GEOSException("IllegalArgumentException", "")
+    {}
 
-	IllegalArgumentException(const std::string& msg)
-		:
-		GEOSException("IllegalArgumentException", msg)
-	{}
+    IllegalArgumentException(const std::string& msg)
+        :
+        GEOSException("IllegalArgumentException", msg)
+    {}
 
-	~IllegalArgumentException() throw() override {}
+    ~IllegalArgumentException() throw() override {}
 };
 
 } // namespace geos::util
diff --git a/include/geos/util/IllegalStateException.h b/include/geos/util/IllegalStateException.h
index d23281f..60f8ed3 100644
--- a/include/geos/util/IllegalStateException.h
+++ b/include/geos/util/IllegalStateException.h
@@ -26,17 +26,17 @@ namespace util { // geos::util
 /// Indicates an illegal state
 class GEOS_DLL IllegalStateException: public GEOSException {
 public:
-	IllegalStateException()
-		:
-		GEOSException("IllegalStateException", "")
-	{}
+    IllegalStateException()
+        :
+        GEOSException("IllegalStateException", "")
+    {}
 
-	IllegalStateException(const std::string& msg)
-		:
-		GEOSException("IllegalStateException", msg)
-	{}
+    IllegalStateException(const std::string& msg)
+        :
+        GEOSException("IllegalStateException", msg)
+    {}
 
-	~IllegalStateException() throw() override {}
+    ~IllegalStateException() throw() override {}
 };
 
 } // namespace geos::util
diff --git a/include/geos/util/Interrupt.h b/include/geos/util/Interrupt.h
index 4b02d42..a3e564b 100644
--- a/include/geos/util/Interrupt.h
+++ b/include/geos/util/Interrupt.h
@@ -27,42 +27,42 @@ class GEOS_DLL Interrupt {
 
 public:
 
-  typedef void (Callback)(void);
-
-  /**
-   * Request interruption of operations
-   *
-   * Operations will be terminated by a GEOSInterrupt
-   * exception at first occasion.
-   */
-  static void request();
-
-  /** Cancel a pending interruption request */
-  static void cancel();
-
-  /** Check if an interruption request is pending */
-  static bool check();
-
-  /** \brief
-   * Register a callback that will be invoked
-   * before checking for interruption requests.
-   *
-   * NOTE that interruption request checking may happen
-   * frequently so any callback would better be quick.
-   *
-   * The callback can be used to call Interrupt::request()
-   *
-   */
-  static Callback* registerCallback(Callback *cb);
-
-  /**
-   * Invoke the callback, if any. Process pending interruption, if any.
-   *
-   */
-  static void process();
-
-  /* Perform the actual interruption (simply throw an exception) */
-  static void interrupt();
+    typedef void (Callback)(void);
+
+    /**
+     * Request interruption of operations
+     *
+     * Operations will be terminated by a GEOSInterrupt
+     * exception at first occasion.
+     */
+    static void request();
+
+    /** Cancel a pending interruption request */
+    static void cancel();
+
+    /** Check if an interruption request is pending */
+    static bool check();
+
+    /** \brief
+     * Register a callback that will be invoked
+     * before checking for interruption requests.
+     *
+     * NOTE that interruption request checking may happen
+     * frequently so any callback would better be quick.
+     *
+     * The callback can be used to call Interrupt::request()
+     *
+     */
+    static Callback* registerCallback(Callback* cb);
+
+    /**
+     * Invoke the callback, if any. Process pending interruption, if any.
+     *
+     */
+    static void process();
+
+    /* Perform the actual interruption (simply throw an exception) */
+    static void interrupt();
 
 };
 
diff --git a/include/geos/util/Machine.h b/include/geos/util/Machine.h
index 4d31fa3..c509ca4 100644
--- a/include/geos/util/Machine.h
+++ b/include/geos/util/Machine.h
@@ -18,10 +18,11 @@
  * Check endianness of current machine.
  * @return 0 for big_endian | xdr; 1 == little_endian | ndr
  */
-inline int getMachineByteOrder()
+inline int
+getMachineByteOrder()
 {
-	static int endian_check = 1; // don't modify !!
-	return *((char *)&endian_check);
+    static int endian_check = 1; // don't modify !!
+    return *((char*)&endian_check);
 }
 
 #endif
diff --git a/include/geos/util/TopologyException.h b/include/geos/util/TopologyException.h
index f87fd54..ed4d473 100644
--- a/include/geos/util/TopologyException.h
+++ b/include/geos/util/TopologyException.h
@@ -34,26 +34,30 @@ namespace util { // geos.util
  */
 class GEOS_DLL TopologyException: public GEOSException {
 public:
-	TopologyException()
-		:
-		GEOSException("TopologyException", "")
-	{}
-
-	TopologyException(const std::string& msg)
-		:
-		GEOSException("TopologyException", msg)
-	{}
-
-	TopologyException(const std::string& msg, const geom::Coordinate& newPt)
-		:
-		GEOSException("TopologyException", msg + " at " + newPt.toString()),
-		pt(newPt)
-	{}
-
-	~TopologyException() throw() override {}
-	geom::Coordinate& getCoordinate() { return pt; }
+    TopologyException()
+        :
+        GEOSException("TopologyException", "")
+    {}
+
+    TopologyException(const std::string& msg)
+        :
+        GEOSException("TopologyException", msg)
+    {}
+
+    TopologyException(const std::string& msg, const geom::Coordinate& newPt)
+        :
+        GEOSException("TopologyException", msg + " at " + newPt.toString()),
+        pt(newPt)
+    {}
+
+    ~TopologyException() throw() override {}
+    geom::Coordinate&
+    getCoordinate()
+    {
+        return pt;
+    }
 private:
-	geom::Coordinate pt;
+    geom::Coordinate pt;
 };
 
 } // namespace geos::util
diff --git a/include/geos/util/UniqueCoordinateArrayFilter.h b/include/geos/util/UniqueCoordinateArrayFilter.h
index b25804f..09023ff 100644
--- a/include/geos/util/UniqueCoordinateArrayFilter.h
+++ b/include/geos/util/UniqueCoordinateArrayFilter.h
@@ -39,42 +39,41 @@ namespace util { // geos::util
  *
  *  Last port: util/UniqueCoordinateArrayFilter.java rev. 1.17
  */
-class GEOS_DLL UniqueCoordinateArrayFilter: public geom::CoordinateFilter
-{
+class GEOS_DLL UniqueCoordinateArrayFilter: public geom::CoordinateFilter {
 public:
-	/**
-	 * Constructs a CoordinateArrayFilter.
-	 *
-	 * @param target The destination set.
-	 */
-	UniqueCoordinateArrayFilter(geom::Coordinate::ConstVect &target)
-		: pts(target)
-	{}
+    /**
+     * Constructs a CoordinateArrayFilter.
+     *
+     * @param target The destination set.
+     */
+    UniqueCoordinateArrayFilter(geom::Coordinate::ConstVect& target)
+        : pts(target)
+    {}
 
-	/**
-	 * Destructor.
-	 * Virtual dctor promises appropriate behaviour when someone will
-	 * delete a derived-class object via a base-class pointer.
-	 * http://www.parashift.com/c++-faq-lite/virtual-functions.html#faq-20.7
-	 */
-	~UniqueCoordinateArrayFilter() override {}
+    /**
+     * Destructor.
+     * Virtual dctor promises appropriate behaviour when someone will
+     * delete a derived-class object via a base-class pointer.
+     * http://www.parashift.com/c++-faq-lite/virtual-functions.html#faq-20.7
+     */
+    ~UniqueCoordinateArrayFilter() override {}
 
-	/**
-	 * Performs a filtering operation with or on coord in "read-only" mode.
-	 * @param coord The "read-only" Coordinate to which
-	 * 				the filter is applied.
-	 */
-	void filter_ro(const geom::Coordinate *coord) override
-	{
-		if ( uniqPts.insert(coord).second )
-		{
-			pts.push_back(coord);
-		}
+    /**
+     * Performs a filtering operation with or on coord in "read-only" mode.
+     * @param coord The "read-only" Coordinate to which
+     * 				the filter is applied.
+     */
+    void
+    filter_ro(const geom::Coordinate* coord) override
+    {
+        if(uniqPts.insert(coord).second) {
+            pts.push_back(coord);
+        }
     }
 
 private:
-	geom::Coordinate::ConstVect &pts;	// target set reference
-	geom::Coordinate::ConstSet uniqPts; 	// unique points set
+    geom::Coordinate::ConstVect& pts;	// target set reference
+    geom::Coordinate::ConstSet uniqPts; 	// unique points set
 
     // Declare type as noncopyable
     UniqueCoordinateArrayFilter(const UniqueCoordinateArrayFilter& other) = delete;
diff --git a/include/geos/util/UnsupportedOperationException.h b/include/geos/util/UnsupportedOperationException.h
index 95b2715..e3939ca 100644
--- a/include/geos/util/UnsupportedOperationException.h
+++ b/include/geos/util/UnsupportedOperationException.h
@@ -35,17 +35,17 @@ namespace util { // geos::util
  */
 class GEOS_DLL UnsupportedOperationException: public GEOSException {
 public:
-	UnsupportedOperationException()
-		:
-		GEOSException("UnsupportedOperationException", "")
-	{}
+    UnsupportedOperationException()
+        :
+        GEOSException("UnsupportedOperationException", "")
+    {}
 
-	UnsupportedOperationException(const std::string& msg)
-		:
-		GEOSException("UnsupportedOperationException", msg)
-	{}
+    UnsupportedOperationException(const std::string& msg)
+        :
+        GEOSException("UnsupportedOperationException", msg)
+    {}
 
-	~UnsupportedOperationException() throw() override {}
+    ~UnsupportedOperationException() throw() override {}
 };
 
 } // namespace geos::util
diff --git a/include/geos/util/math.h b/include/geos/util/math.h
index 54e2d9a..cc323d2 100644
--- a/include/geos/util/math.h
+++ b/include/geos/util/math.h
@@ -16,7 +16,8 @@
 #ifndef GEOS_UTIL_MATH_H
 #define GEOS_UTIL_MATH_H
 
-namespace geos { namespace util {
+namespace geos {
+namespace util {
 
 /// Symmetric Rounding Algorithm
 double sym_round(double val);
@@ -31,11 +32,13 @@ double rint_vc(double val);
 ///
 /// @note Always use this rounding method, to easy easy switching
 /// between different rounding method for the whole codebase.
-inline double round(double val)
+inline double
+round(double val)
 {
-	return java_math_round(val);
+    return java_math_round(val);
 }
 
-}} // namespace geos::util
+}
+} // namespace geos::util
 
 #endif // GEOS_UTIL_MATH_H
diff --git a/src/algorithm/Angle.cpp b/src/algorithm/Angle.cpp
index c05e758..24d0070 100644
--- a/src/algorithm/Angle.cpp
+++ b/src/algorithm/Angle.cpp
@@ -25,7 +25,7 @@ namespace geos {
 namespace algorithm { // geos.algorithm
 
 namespace {
-	const double PI = 3.14159265358979323846;
+const double PI = 3.14159265358979323846;
 }
 
 const double Angle::PI_TIMES_2 = 2.0 * PI;
@@ -36,14 +36,14 @@ const double Angle::PI_OVER_4 = PI / 4.0;
 double
 Angle::toDegrees(double radians)
 {
-      return (radians * 180) / (PI);
+    return (radians * 180) / (PI);
 }
 
 /* public static */
 double
 Angle::toRadians(double angleDegrees)
 {
-	return (angleDegrees * PI) / 180.0;
+    return (angleDegrees * PI) / 180.0;
 }
 
 /* public static */
@@ -51,16 +51,16 @@ double
 Angle::angle(const geom::Coordinate& p0,
              const geom::Coordinate& p1)
 {
-      double dx = p1.x - p0.x;
-      double dy = p1.y - p0.y;
-      return atan2(dy, dx);
+    double dx = p1.x - p0.x;
+    double dy = p1.y - p0.y;
+    return atan2(dy, dx);
 }
 
 /* public static */
 double
 Angle::angle(const geom::Coordinate& p)
 {
-	return atan2(p.y, p.x);
+    return atan2(p.y, p.x);
 }
 
 /* public static */
@@ -69,13 +69,13 @@ Angle::isAcute(const geom::Coordinate& p0,
                const geom::Coordinate& p1,
                const geom::Coordinate& p2)
 {
-	// relies on fact that A dot B is positive iff A ang B is acute
-	double dx0 = p0.x - p1.x;
-	double dy0 = p0.y - p1.y;
-	double dx1 = p2.x - p1.x;
-	double dy1 = p2.y - p1.y;
-	double dotprod = dx0 * dx1 + dy0 * dy1;
-	return dotprod > 0;
+    // relies on fact that A dot B is positive iff A ang B is acute
+    double dx0 = p0.x - p1.x;
+    double dy0 = p0.y - p1.y;
+    double dx1 = p2.x - p1.x;
+    double dy1 = p2.y - p1.y;
+    double dotprod = dx0 * dx1 + dy0 * dy1;
+    return dotprod > 0;
 }
 
 /* public static */
@@ -84,13 +84,13 @@ Angle::isObtuse(const geom::Coordinate& p0,
                 const geom::Coordinate& p1,
                 const geom::Coordinate& p2)
 {
-	// relies on fact that A dot B is negative iff A ang B is obtuse
-	double dx0 = p0.x - p1.x;
-	double dy0 = p0.y - p1.y;
-	double dx1 = p2.x - p1.x;
-	double dy1 = p2.y - p1.y;
-	double dotprod = dx0 * dx1 + dy0 * dy1;
-	return dotprod < 0;
+    // relies on fact that A dot B is negative iff A ang B is obtuse
+    double dx0 = p0.x - p1.x;
+    double dy0 = p0.y - p1.y;
+    double dx1 = p2.x - p1.x;
+    double dy1 = p2.y - p1.y;
+    double dotprod = dx0 * dx1 + dy0 * dy1;
+    return dotprod < 0;
 }
 
 /* public static */
@@ -99,10 +99,10 @@ Angle::angleBetween(const geom::Coordinate& tip1,
                     const geom::Coordinate& tail,
                     const geom::Coordinate& tip2)
 {
-	double a1 = angle(tail, tip1);
-	double a2 = angle(tail, tip2);
+    double a1 = angle(tail, tip1);
+    double a2 = angle(tail, tip2);
 
-	return diff(a1, a2);
+    return diff(a1, a2);
 }
 
 /* public static */
@@ -111,16 +111,18 @@ Angle::angleBetweenOriented(const geom::Coordinate& tip1,
                             const geom::Coordinate& tail,
                             const geom::Coordinate& tip2)
 {
-	double a1 = angle(tail, tip1);
-	double a2 = angle(tail, tip2);
-	double angDel = a2 - a1;
-
-	// normalize, maintaining orientation
-	if (angDel <= -PI)
-		return angDel + PI_TIMES_2;
-	if (angDel > PI)
-		return angDel - PI_TIMES_2;
-	return angDel;
+    double a1 = angle(tail, tip1);
+    double a2 = angle(tail, tip2);
+    double angDel = a2 - a1;
+
+    // normalize, maintaining orientation
+    if(angDel <= -PI) {
+        return angDel + PI_TIMES_2;
+    }
+    if(angDel > PI) {
+        return angDel - PI_TIMES_2;
+    }
+    return angDel;
 }
 
 /* public static */
@@ -128,75 +130,82 @@ double
 Angle::interiorAngle(const geom::Coordinate& p0, const geom::Coordinate& p1,
                      const geom::Coordinate& p2)
 {
-	double anglePrev = angle(p1, p0);
-	double angleNext = angle(p1, p2);
-	return fabs(angleNext - anglePrev);
+    double anglePrev = angle(p1, p0);
+    double angleNext = angle(p1, p2);
+    return fabs(angleNext - anglePrev);
 }
 
 /* public static */
 int
 Angle::getTurn(double ang1, double ang2)
 {
-	double crossproduct = sin(ang2 - ang1);
-
-	if (crossproduct > 0) {
-		return COUNTERCLOCKWISE;
-	}
-	if (crossproduct < 0) {
-		return CLOCKWISE;
-	}
-	return NONE;
+    double crossproduct = sin(ang2 - ang1);
+
+    if(crossproduct > 0) {
+        return COUNTERCLOCKWISE;
+    }
+    if(crossproduct < 0) {
+        return CLOCKWISE;
+    }
+    return NONE;
 }
 
 /* public static */
 double
 Angle::normalize(double angle)
 {
-	while (angle > PI)
-		angle -= PI_TIMES_2;
-	while (angle <= -PI)
-		angle += PI_TIMES_2;
-	return angle;
+    while(angle > PI) {
+        angle -= PI_TIMES_2;
+    }
+    while(angle <= -PI) {
+        angle += PI_TIMES_2;
+    }
+    return angle;
 }
 
 /* public static */
 double
 Angle::normalizePositive(double angle)
 {
-	if (angle < 0.0) {
-		while (angle < 0.0)
-			angle += PI_TIMES_2;
-		// in case round-off error bumps the value over
-		if (angle >= PI_TIMES_2)
-			angle = 0.0;
-	}
-	else {
-		while (angle >= PI_TIMES_2)
-			angle -= PI_TIMES_2;
-		// in case round-off error bumps the value under
-		if (angle < 0.0)
-			angle = 0.0;
-	}
-	return angle;
+    if(angle < 0.0) {
+        while(angle < 0.0) {
+            angle += PI_TIMES_2;
+        }
+        // in case round-off error bumps the value over
+        if(angle >= PI_TIMES_2) {
+            angle = 0.0;
+        }
+    }
+    else {
+        while(angle >= PI_TIMES_2) {
+            angle -= PI_TIMES_2;
+        }
+        // in case round-off error bumps the value under
+        if(angle < 0.0) {
+            angle = 0.0;
+        }
+    }
+    return angle;
 }
 
 /* public static */
 double
 Angle::diff(double ang1, double ang2)
 {
-	double delAngle;
+    double delAngle;
 
-	if (ang1 < ang2) {
-		delAngle = ang2 - ang1;
-	} else {
-		delAngle = ang1 - ang2;
-	}
+    if(ang1 < ang2) {
+        delAngle = ang2 - ang1;
+    }
+    else {
+        delAngle = ang1 - ang2;
+    }
 
-	if (delAngle > PI) {
-		delAngle = (2 * PI) - delAngle;
-	}
+    if(delAngle > PI) {
+        delAngle = (2 * PI) - delAngle;
+    }
 
-	return delAngle;
+    return delAngle;
 }
 
 } // namespace geos.algorithm
diff --git a/src/algorithm/Area.cpp b/src/algorithm/Area.cpp
index 021bbf3..81c76bb 100644
--- a/src/algorithm/Area.cpp
+++ b/src/algorithm/Area.cpp
@@ -26,25 +26,26 @@ namespace algorithm { // geos.algorithm
 
 /* public static */
 double
-Area::ofRing(const std::vector<geom::Coordinate> &ring)
+Area::ofRing(const std::vector<geom::Coordinate>& ring)
 {
     return std::abs(ofRingSigned(ring));
 }
 
 /* public static */
 double
-Area::ofRing(const geom::CoordinateSequence *ring)
+Area::ofRing(const geom::CoordinateSequence* ring)
 {
     return std::abs(ofRingSigned(ring));
 }
 
 /* public static */
 double
-Area::ofRingSigned(const std::vector<geom::Coordinate> &ring)
+Area::ofRingSigned(const std::vector<geom::Coordinate>& ring)
 {
     size_t rlen = ring.size();
-    if (rlen < 3)
+    if(rlen < 3) {
         return 0.0;
+    }
 
     double sum = 0.0;
     /**
@@ -52,7 +53,7 @@ Area::ofRingSigned(const std::vector<geom::Coordinate> &ring)
      * http://en.wikipedia.org/wiki/Shoelace_formula
      */
     double x0 = ring[0].x;
-    for (size_t i = 1; i < rlen - 1; i++) {
+    for(size_t i = 1; i < rlen - 1; i++) {
         double x = ring[i].x - x0;
         double y1 = ring[i + 1].y;
         double y2 = ring[i - 1].y;
@@ -63,11 +64,12 @@ Area::ofRingSigned(const std::vector<geom::Coordinate> &ring)
 
 /* public static */
 double
-Area::ofRingSigned(const geom::CoordinateSequence *ring)
+Area::ofRingSigned(const geom::CoordinateSequence* ring)
 {
     size_t n = ring->size();
-    if (n < 3)
+    if(n < 3) {
         return 0.0;
+    }
     /**
     * Based on the Shoelace formula.
     * http://en.wikipedia.org/wiki/Shoelace_formula
@@ -78,7 +80,7 @@ Area::ofRingSigned(const geom::CoordinateSequence *ring)
     double x0 = p1.x;
     p2.x -= x0;
     double sum = 0.0;
-    for (size_t i = 1; i < n - 1; i++) {
+    for(size_t i = 1; i < n - 1; i++) {
         p0.y = p1.y;
         p1.x = p2.x;
         p1.y = p2.y;
diff --git a/src/algorithm/BoundaryNodeRule.cpp b/src/algorithm/BoundaryNodeRule.cpp
index 1603696..c7417b9 100644
--- a/src/algorithm/BoundaryNodeRule.cpp
+++ b/src/algorithm/BoundaryNodeRule.cpp
@@ -41,14 +41,14 @@ namespace {
  * @author Martin Davis
  * @version 1.7
  */
-class Mod2BoundaryNodeRule : public BoundaryNodeRule
-{
+class Mod2BoundaryNodeRule : public BoundaryNodeRule {
 public:
-	bool isInBoundary(int boundaryCount) const override
-	{
-		// the "Mod-2 Rule"
-		return boundaryCount % 2 == 1;
-	}
+    bool
+    isInBoundary(int boundaryCount) const override
+    {
+        // the "Mod-2 Rule"
+        return boundaryCount % 2 == 1;
+    }
 };
 
 
@@ -79,12 +79,12 @@ public:
  * @author Martin Davis
  * @version 1.7
  */
-class EndPointBoundaryNodeRule : public BoundaryNodeRule
-{
-	bool isInBoundary(int boundaryCount) const override
-	{
-		return boundaryCount > 0;
-	}
+class EndPointBoundaryNodeRule : public BoundaryNodeRule {
+    bool
+    isInBoundary(int boundaryCount) const override
+    {
+        return boundaryCount > 0;
+    }
 };
 
 /**
@@ -97,12 +97,12 @@ class EndPointBoundaryNodeRule : public BoundaryNodeRule
  * @author Martin Davis
  * @version 1.7
  */
-class MultiValentEndPointBoundaryNodeRule : public BoundaryNodeRule
-{
-	bool isInBoundary(int boundaryCount) const override
-	{
-		return boundaryCount > 1;
-	}
+class MultiValentEndPointBoundaryNodeRule : public BoundaryNodeRule {
+    bool
+    isInBoundary(int boundaryCount) const override
+    {
+        return boundaryCount > 1;
+    }
 };
 
 /**
@@ -114,12 +114,12 @@ class MultiValentEndPointBoundaryNodeRule : public BoundaryNodeRule
  * @author Martin Davis
  * @version 1.7
  */
-class MonoValentEndPointBoundaryNodeRule : public BoundaryNodeRule
-{
-	bool isInBoundary(int boundaryCount) const override
-	{
-		return boundaryCount == 1;
-	}
+class MonoValentEndPointBoundaryNodeRule : public BoundaryNodeRule {
+    bool
+    isInBoundary(int boundaryCount) const override
+    {
+        return boundaryCount == 1;
+    }
 };
 
 Mod2BoundaryNodeRule mod2Rule;
@@ -130,31 +130,36 @@ MonoValentEndPointBoundaryNodeRule monoValentRule;
 } // anonymous namespace
 
 //const BoundaryNodeRule& BoundaryNodeRule::MOD2_BOUNDARY_RULE = mod2Rule;
-const BoundaryNodeRule& BoundaryNodeRule::getBoundaryRuleMod2()
+const BoundaryNodeRule&
+BoundaryNodeRule::getBoundaryRuleMod2()
 {
     return mod2Rule;
 }
 
 //const BoundaryNodeRule& BoundaryNodeRule::ENDPOINT_BOUNDARY_RULE = endPointRule;
-const BoundaryNodeRule& BoundaryNodeRule::getBoundaryEndPoint()
+const BoundaryNodeRule&
+BoundaryNodeRule::getBoundaryEndPoint()
 {
     return endPointRule;
 }
 
 //const BoundaryNodeRule& BoundaryNodeRule::MULTIVALENT_ENDPOINT_BOUNDARY_RULE = multiValentRule;
-const BoundaryNodeRule& BoundaryNodeRule::getBoundaryMultivalentEndPoint()
+const BoundaryNodeRule&
+BoundaryNodeRule::getBoundaryMultivalentEndPoint()
 {
     return multiValentRule;
 }
 
 //const BoundaryNodeRule& BoundaryNodeRule::MONOVALENT_ENDPOINT_BOUNDARY_RULE = monoValentRule;
-const BoundaryNodeRule& BoundaryNodeRule::getBoundaryMonovalentEndPoint()
+const BoundaryNodeRule&
+BoundaryNodeRule::getBoundaryMonovalentEndPoint()
 {
     return monoValentRule;
 }
 
 //const BoundaryNodeRule& BoundaryNodeRule::OGC_SFS_BOUNDARY_RULE = BoundaryNodeRule::MOD2_BOUNDARY_RULE;
-const BoundaryNodeRule& BoundaryNodeRule::getBoundaryOGCSFS()
+const BoundaryNodeRule&
+BoundaryNodeRule::getBoundaryOGCSFS()
 {
     return getBoundaryRuleMod2();
 }
diff --git a/src/algorithm/CGAlgorithmsDD.cpp b/src/algorithm/CGAlgorithmsDD.cpp
index 8bcf3e9..2fe8a55 100644
--- a/src/algorithm/CGAlgorithmsDD.cpp
+++ b/src/algorithm/CGAlgorithmsDD.cpp
@@ -33,14 +33,17 @@ namespace {
  */
 double constexpr DP_SAFE_EPSILON =  1e-15;
 
-inline int OrientationDD(DD const& dd)
+inline int
+OrientationDD(DD const& dd)
 {
     static DD const zero(0.0);
-    if (dd < zero)
+    if(dd < zero) {
         return CGAlgorithmsDD::RIGHT;
+    }
 
-    if (dd > zero)
+    if(dd > zero) {
         return CGAlgorithmsDD::LEFT;
+    }
 
     return CGAlgorithmsDD::STRAIGHT;
 }
@@ -54,19 +57,21 @@ inline int OrientationDD(DD const& dd)
 namespace geos {
 namespace algorithm { // geos::algorithm
 
-int CGAlgorithmsDD::orientationIndex(const Coordinate& p1,
-                                     const Coordinate& p2,
-                                     const Coordinate& q)
+int
+CGAlgorithmsDD::orientationIndex(const Coordinate& p1,
+                                 const Coordinate& p2,
+                                 const Coordinate& q)
 {
-    if (std::isnan(q.x) || std::isnan(q.y) || !std::isfinite(q.x) || !std::isfinite(q.y)) {
+    if(std::isnan(q.x) || std::isnan(q.y) || !std::isfinite(q.x) || !std::isfinite(q.y)) {
         throw util::IllegalArgumentException("CGAlgorithmsDD::orientationIndex encountered NaN/Inf numbers");
     }
 
     // fast filter for orientation index
     // avoids use of slow extended-precision arithmetic in many cases
     int index = orientationIndexFilter(p1, p2, q);
-    if (index <= 1)
+    if(index <= 1) {
         return index;
+    }
 
     // normalize coordinates
     DD dx1 = DD(p2.x) + DD(-p1.x);
@@ -81,7 +86,8 @@ int CGAlgorithmsDD::orientationIndex(const Coordinate& p1,
     return OrientationDD(d);
 }
 
-int CGAlgorithmsDD::signOfDet2x2(DD &x1, DD &y1, DD &x2, DD &y2)
+int
+CGAlgorithmsDD::signOfDet2x2(DD& x1, DD& y1, DD& x2, DD& y2)
 {
     DD mx1y2(x1 * y2);
     DD my1x2(y1 * x2);
@@ -89,10 +95,11 @@ int CGAlgorithmsDD::signOfDet2x2(DD &x1, DD &y1, DD &x2, DD &y2)
     return OrientationDD(d);
 }
 
-int CGAlgorithmsDD::signOfDet2x2(double dx1, double dy1, double dx2, double dy2)
+int
+CGAlgorithmsDD::signOfDet2x2(double dx1, double dy1, double dx2, double dy2)
 {
-    if (std::isnan(dx1)    ||  std::isnan(dy1)    ||  std::isnan(dx2)    ||  std::isnan(dy2) ||
-       !std::isfinite(dx1) || !std::isfinite(dy1) || !std::isfinite(dx2) || !std::isfinite(dy2)) {
+    if(std::isnan(dx1)    ||  std::isnan(dy1)    ||  std::isnan(dx2)    ||  std::isnan(dy2) ||
+            !std::isfinite(dx1) || !std::isfinite(dy1) || !std::isfinite(dx2) || !std::isfinite(dy2)) {
         throw util::IllegalArgumentException("CGAlgorithmsDD::signOfDet2x2 encountered NaN/Inf numbers");
     }
     DD x1(dx1);
@@ -102,25 +109,26 @@ int CGAlgorithmsDD::signOfDet2x2(double dx1, double dy1, double dx2, double dy2)
     return CGAlgorithmsDD::signOfDet2x2(x1, y1, x2, y2);
 }
 
-int CGAlgorithmsDD::orientationIndexFilter(const Coordinate& pa,
-        const Coordinate& pb,
-        const Coordinate& pc)
+int
+CGAlgorithmsDD::orientationIndexFilter(const Coordinate& pa,
+                                       const Coordinate& pb,
+                                       const Coordinate& pc)
 {
     double detsum;
     double const detleft = (pa.x - pc.x) * (pb.y - pc.y);
     double const detright = (pa.y - pc.y) * (pb.x - pc.x);
     double const det = detleft - detright;
 
-    if (detleft > 0.0) {
-        if (detright <= 0.0) {
+    if(detleft > 0.0) {
+        if(detright <= 0.0) {
             return orientation(det);
         }
         else {
             detsum = detleft + detright;
         }
     }
-    else if (detleft < 0.0) {
-        if (detright >= 0.0) {
+    else if(detleft < 0.0) {
+        if(detright >= 0.0) {
             return orientation(det);
         }
         else {
@@ -132,15 +140,16 @@ int CGAlgorithmsDD::orientationIndexFilter(const Coordinate& pa,
     }
 
     double const errbound = DP_SAFE_EPSILON * detsum;
-    if ((det >= errbound) || (-det >= errbound)) {
+    if((det >= errbound) || (-det >= errbound)) {
         return orientation(det);
     }
     return CGAlgorithmsDD::FAILURE;
 }
 
-void CGAlgorithmsDD::intersection(const Coordinate& p1, const Coordinate& p2,
-                                  const Coordinate& q1, const Coordinate& q2,
-                                  Coordinate &rv)
+void
+CGAlgorithmsDD::intersection(const Coordinate& p1, const Coordinate& p2,
+                             const Coordinate& q1, const Coordinate& q2,
+                             Coordinate& rv)
 {
     DD q1x(q1.x);
     DD q1y(q1.y);
diff --git a/src/algorithm/Centroid.cpp b/src/algorithm/Centroid.cpp
index f217420..8f65682 100644
--- a/src/algorithm/Centroid.cpp
+++ b/src/algorithm/Centroid.cpp
@@ -37,157 +37,162 @@ namespace algorithm { // geos.algorithm
 bool
 Centroid::getCentroid(const Geometry& geom, Coordinate& pt)
 {
-  Centroid cent(geom);
-  return cent.getCentroid(pt);
+    Centroid cent(geom);
+    return cent.getCentroid(pt);
 }
 
 /* public */
 bool
 Centroid::getCentroid(Coordinate& cent) const
 {
-  if (std::abs(areasum2) > 0.0) {
-    cent.x = cg3.x / 3 / areasum2;
-    cent.y = cg3.y / 3 / areasum2;
-  }
-  else if (totalLength > 0.0) {
-    // if polygon was degenerate, compute linear centroid instead
-    cent.x = lineCentSum.x / totalLength;
-    cent.y = lineCentSum.y / totalLength;
-  }
-  else if (ptCount > 0){
-    cent.x = ptCentSum.x / ptCount;
-    cent.y = ptCentSum.y / ptCount;
-  }
-  else {
-    return false;
-  }
-  return true;
+    if(std::abs(areasum2) > 0.0) {
+        cent.x = cg3.x / 3 / areasum2;
+        cent.y = cg3.y / 3 / areasum2;
+    }
+    else if(totalLength > 0.0) {
+        // if polygon was degenerate, compute linear centroid instead
+        cent.x = lineCentSum.x / totalLength;
+        cent.y = lineCentSum.y / totalLength;
+    }
+    else if(ptCount > 0) {
+        cent.x = ptCentSum.x / ptCount;
+        cent.y = ptCentSum.y / ptCount;
+    }
+    else {
+        return false;
+    }
+    return true;
 }
 
 /* private */
 void
 Centroid::add(const Geometry& geom)
 {
-  if (geom.isEmpty()) return;
-
-  if (const Point* pt = dynamic_cast<const Point*>(&geom)) {
-    addPoint(*pt->getCoordinate());
-  }
-  else if (const LineString* ls = dynamic_cast<const LineString*>(&geom)) {
-    addLineSegments(*ls->getCoordinatesRO());
-  }
-  else if (const Polygon* p = dynamic_cast<const Polygon*>(&geom)) {
-    add(*p);
-  }
-  else if (const GeometryCollection* g = dynamic_cast<const GeometryCollection*>(&geom)) {
-    for (size_t i = 0; i < g->getNumGeometries(); i++) {
-      add(*g->getGeometryN(i));
+    if(geom.isEmpty()) {
+        return;
+    }
+
+    if(const Point* pt = dynamic_cast<const Point*>(&geom)) {
+        addPoint(*pt->getCoordinate());
+    }
+    else if(const LineString* ls = dynamic_cast<const LineString*>(&geom)) {
+        addLineSegments(*ls->getCoordinatesRO());
+    }
+    else if(const Polygon* p = dynamic_cast<const Polygon*>(&geom)) {
+        add(*p);
+    }
+    else if(const GeometryCollection* g = dynamic_cast<const GeometryCollection*>(&geom)) {
+        for(size_t i = 0; i < g->getNumGeometries(); i++) {
+            add(*g->getGeometryN(i));
+        }
     }
-  }
 }
 
 /* private */
 void
 Centroid::setAreaBasePoint(const Coordinate& basePt)
 {
-  areaBasePt.reset( new Coordinate(basePt) );
+    areaBasePt.reset(new Coordinate(basePt));
 }
 
 /* private */
 void
 Centroid::add(const Polygon& poly)
 {
-  addShell(*poly.getExteriorRing()->getCoordinatesRO());
-  for (size_t i = 0; i < poly.getNumInteriorRing(); i++) {
-    addHole(*poly.getInteriorRingN(i)->getCoordinatesRO());
-  }
+    addShell(*poly.getExteriorRing()->getCoordinatesRO());
+    for(size_t i = 0; i < poly.getNumInteriorRing(); i++) {
+        addHole(*poly.getInteriorRingN(i)->getCoordinatesRO());
+    }
 }
 
 /* private */
 void
 Centroid::addShell(const CoordinateSequence& pts)
 {
-  size_t len = pts.size();
-  if (len > 0)
-    setAreaBasePoint(pts[0]);
-  bool isPositiveArea = ! Orientation::isCCW(&pts);
-  for (size_t i = 0; i < len - 1; ++i) {
-    addTriangle(*areaBasePt, pts[i], pts[i+1], isPositiveArea);
-  }
-  addLineSegments(pts);
+    size_t len = pts.size();
+    if(len > 0) {
+        setAreaBasePoint(pts[0]);
+    }
+    bool isPositiveArea = ! Orientation::isCCW(&pts);
+    for(size_t i = 0; i < len - 1; ++i) {
+        addTriangle(*areaBasePt, pts[i], pts[i + 1], isPositiveArea);
+    }
+    addLineSegments(pts);
 }
 
 /* private */
 void
 Centroid::addHole(const CoordinateSequence& pts)
 {
-  bool isPositiveArea = Orientation::isCCW(&pts);
-  for (size_t i = 0, e = pts.size() - 1; i < e; ++i) {
-    addTriangle(*areaBasePt, pts[i], pts[i+1], isPositiveArea);
-  }
-  addLineSegments(pts);
+    bool isPositiveArea = Orientation::isCCW(&pts);
+    for(size_t i = 0, e = pts.size() - 1; i < e; ++i) {
+        addTriangle(*areaBasePt, pts[i], pts[i + 1], isPositiveArea);
+    }
+    addLineSegments(pts);
 }
 
 /* private */
 void
 Centroid::addTriangle(const Coordinate& p0, const Coordinate& p1, const Coordinate& p2, bool isPositiveArea)
 {
-  double sign = (isPositiveArea) ? 1.0 : -1.0;
-  centroid3( p0, p1, p2, triangleCent3 );
-  double a2 = area2( p0, p1, p2 );
-  cg3.x += sign * a2 * triangleCent3.x;
-  cg3.y += sign * a2 * triangleCent3.y;
-  areasum2 += sign * a2;
+    double sign = (isPositiveArea) ? 1.0 : -1.0;
+    centroid3(p0, p1, p2, triangleCent3);
+    double a2 = area2(p0, p1, p2);
+    cg3.x += sign * a2 * triangleCent3.x;
+    cg3.y += sign * a2 * triangleCent3.y;
+    areasum2 += sign * a2;
 }
 
 /* static private */
 void
-Centroid::centroid3(const Coordinate& p1, const Coordinate& p2, const Coordinate& p3, Coordinate& c )
+Centroid::centroid3(const Coordinate& p1, const Coordinate& p2, const Coordinate& p3, Coordinate& c)
 {
-  c.x = p1.x + p2.x + p3.x;
-  c.y = p1.y + p2.y + p3.y;
-  return;
+    c.x = p1.x + p2.x + p3.x;
+    c.y = p1.y + p2.y + p3.y;
+    return;
 }
 
 /* static private */
 double
-Centroid::area2(const Coordinate& p1, const Coordinate& p2, const Coordinate& p3 )
+Centroid::area2(const Coordinate& p1, const Coordinate& p2, const Coordinate& p3)
 {
-  return
-    (p2.x - p1.x) * (p3.y - p1.y) -
-    (p3.x - p1.x) * (p2.y - p1.y);
+    return
+        (p2.x - p1.x) * (p3.y - p1.y) -
+        (p3.x - p1.x) * (p2.y - p1.y);
 }
 
 /* private */
 void
 Centroid::addLineSegments(const CoordinateSequence& pts)
 {
-  size_t npts = pts.size();
-  double lineLen = 0.0;
-  for (size_t i = 0; i < npts - 1; i++) {
-    double segmentLen = pts[i].distance(pts[i + 1]);
-    if (segmentLen == 0.0)
-      continue;
-
-    lineLen += segmentLen;
-
-    double midx = (pts[i].x + pts[i + 1].x) / 2;
-    lineCentSum.x += segmentLen * midx;
-    double midy = (pts[i].y + pts[i + 1].y) / 2;
-    lineCentSum.y += segmentLen * midy;
-  }
-  totalLength += lineLen;
-  if (lineLen == 0.0 && npts > 0)
-    addPoint(pts[0]);
+    size_t npts = pts.size();
+    double lineLen = 0.0;
+    for(size_t i = 0; i < npts - 1; i++) {
+        double segmentLen = pts[i].distance(pts[i + 1]);
+        if(segmentLen == 0.0) {
+            continue;
+        }
+
+        lineLen += segmentLen;
+
+        double midx = (pts[i].x + pts[i + 1].x) / 2;
+        lineCentSum.x += segmentLen * midx;
+        double midy = (pts[i].y + pts[i + 1].y) / 2;
+        lineCentSum.y += segmentLen * midy;
+    }
+    totalLength += lineLen;
+    if(lineLen == 0.0 && npts > 0) {
+        addPoint(pts[0]);
+    }
 }
 
 /* private */
 void
 Centroid::addPoint(const Coordinate& pt)
 {
-  ptCount += 1;
-  ptCentSum.x += pt.x;
-  ptCentSum.y += pt.y;
+    ptCount += 1;
+    ptCentSum.x += pt.x;
+    ptCentSum.y += pt.y;
 }
 
 } // namespace geos.algorithm
diff --git a/src/algorithm/ConvexHull.cpp b/src/algorithm/ConvexHull.cpp
index 40cb11b..0d8f650 100644
--- a/src/algorithm/ConvexHull.cpp
+++ b/src/algorithm/ConvexHull.cpp
@@ -52,346 +52,347 @@ class RadiallyLessThen {
 
 private:
 
-	const Coordinate *origin;
-
-	int
-	polarCompare(const Coordinate *o, const Coordinate *p,
-			const Coordinate *q)
-	{
-		double dxp=p->x-o->x;
-		double dyp=p->y-o->y;
-		double dxq=q->x-o->x;
-		double dyq=q->y-o->y;
-
-		int orient = Orientation::index(*o, *p, *q);
-
-		if (orient == Orientation::COUNTERCLOCKWISE) return 1;
-		if (orient == Orientation::CLOCKWISE) return -1;
-
-		// points are collinear - check distance
-		double op = dxp * dxp + dyp * dyp;
-		double oq = dxq * dxq + dyq * dyq;
-		if (op < oq) {
-			return -1;
-		}
-		if (op > oq) {
-			return 1;
-		}
-		return 0;
-	}
+    const Coordinate* origin;
+
+    int
+    polarCompare(const Coordinate* o, const Coordinate* p,
+                 const Coordinate* q)
+    {
+        double dxp = p->x - o->x;
+        double dyp = p->y - o->y;
+        double dxq = q->x - o->x;
+        double dyq = q->y - o->y;
+
+        int orient = Orientation::index(*o, *p, *q);
+
+        if(orient == Orientation::COUNTERCLOCKWISE) {
+            return 1;
+        }
+        if(orient == Orientation::CLOCKWISE) {
+            return -1;
+        }
+
+        // points are collinear - check distance
+        double op = dxp * dxp + dyp * dyp;
+        double oq = dxq * dxq + dyq * dyq;
+        if(op < oq) {
+            return -1;
+        }
+        if(op > oq) {
+            return 1;
+        }
+        return 0;
+    }
 
 public:
 
-	RadiallyLessThen(const Coordinate *c): origin(c) {}
+    RadiallyLessThen(const Coordinate* c): origin(c) {}
 
-	bool operator() (const Coordinate *p1, const Coordinate *p2)
-	{
-		return  ( polarCompare(origin, p1, p2) == -1 );
-	}
+    bool
+    operator()(const Coordinate* p1, const Coordinate* p2)
+    {
+        return (polarCompare(origin, p1, p2) == -1);
+    }
 
 };
 
 } // unnamed namespace
 
 /* private */
-CoordinateSequence *
-ConvexHull::toCoordinateSequence(Coordinate::ConstVect &cv)
+CoordinateSequence*
+ConvexHull::toCoordinateSequence(Coordinate::ConstVect& cv)
 {
-	const CoordinateSequenceFactory *csf =
-		geomFactory->getCoordinateSequenceFactory();
+    const CoordinateSequenceFactory* csf =
+        geomFactory->getCoordinateSequenceFactory();
 
-	// Create a new Coordinate::Vect for feeding it to
-	// the CoordinateSequenceFactory
-	Coordinate::Vect *vect=new Coordinate::Vect();
+    // Create a new Coordinate::Vect for feeding it to
+    // the CoordinateSequenceFactory
+    Coordinate::Vect* vect = new Coordinate::Vect();
 
-	size_t n=cv.size();
-	vect->reserve(n); // avoid multiple reallocs
+    size_t n = cv.size();
+    vect->reserve(n); // avoid multiple reallocs
 
-	for (size_t i=0; i<n; ++i)
-	{
-		vect->push_back(*(cv[i])); // Coordinate copy
-	}
+    for(size_t i = 0; i < n; ++i) {
+        vect->push_back(*(cv[i])); // Coordinate copy
+    }
 
-	return csf->create(vect); // takes ownership of the vector
+    return csf->create(vect); // takes ownership of the vector
 
 }
 
 /* private */
 void
-ConvexHull::computeOctPts(const Coordinate::ConstVect &p_inputPts,
-		Coordinate::ConstVect &pts)
+ConvexHull::computeOctPts(const Coordinate::ConstVect& p_inputPts,
+                          Coordinate::ConstVect& pts)
 {
-	// Initialize all slots with first input coordinate
-	pts = Coordinate::ConstVect(8, p_inputPts[0]);
-
-	for (size_t i=1, n=p_inputPts.size(); i<n; ++i)
-	{
-		if (p_inputPts[i]->x < pts[0]->x) {
-			pts[0] = p_inputPts[i];
-		}
-		if (p_inputPts[i]->x - p_inputPts[i]->y < pts[1]->x - pts[1]->y) {
-			pts[1] = p_inputPts[i];
-		}
-		if (p_inputPts[i]->y > pts[2]->y) {
-			pts[2] = p_inputPts[i];
-		}
-		if (p_inputPts[i]->x + p_inputPts[i]->y > pts[3]->x + pts[3]->y) {
-			pts[3] = p_inputPts[i];
-		}
-		if (p_inputPts[i]->x > pts[4]->x) {
-			pts[4] = p_inputPts[i];
-		}
-		if (p_inputPts[i]->x - p_inputPts[i]->y > pts[5]->x - pts[5]->y) {
-			pts[5] = p_inputPts[i];
-		}
-		if (p_inputPts[i]->y < pts[6]->y) {
-			pts[6] = p_inputPts[i];
-		}
-		if (p_inputPts[i]->x + p_inputPts[i]->y < pts[7]->x + pts[7]->y) {
-			pts[7] = p_inputPts[i];
-		}
-	}
+    // Initialize all slots with first input coordinate
+    pts = Coordinate::ConstVect(8, p_inputPts[0]);
+
+    for(size_t i = 1, n = p_inputPts.size(); i < n; ++i) {
+        if(p_inputPts[i]->x < pts[0]->x) {
+            pts[0] = p_inputPts[i];
+        }
+        if(p_inputPts[i]->x - p_inputPts[i]->y < pts[1]->x - pts[1]->y) {
+            pts[1] = p_inputPts[i];
+        }
+        if(p_inputPts[i]->y > pts[2]->y) {
+            pts[2] = p_inputPts[i];
+        }
+        if(p_inputPts[i]->x + p_inputPts[i]->y > pts[3]->x + pts[3]->y) {
+            pts[3] = p_inputPts[i];
+        }
+        if(p_inputPts[i]->x > pts[4]->x) {
+            pts[4] = p_inputPts[i];
+        }
+        if(p_inputPts[i]->x - p_inputPts[i]->y > pts[5]->x - pts[5]->y) {
+            pts[5] = p_inputPts[i];
+        }
+        if(p_inputPts[i]->y < pts[6]->y) {
+            pts[6] = p_inputPts[i];
+        }
+        if(p_inputPts[i]->x + p_inputPts[i]->y < pts[7]->x + pts[7]->y) {
+            pts[7] = p_inputPts[i];
+        }
+    }
 
 }
 
 
 /* private */
 bool
-ConvexHull::computeOctRing(const Coordinate::ConstVect &p_inputPts,
-	Coordinate::ConstVect &dest)
+ConvexHull::computeOctRing(const Coordinate::ConstVect& p_inputPts,
+                           Coordinate::ConstVect& dest)
 {
-	computeOctPts(p_inputPts, dest);
+    computeOctPts(p_inputPts, dest);
 
-	// Remove consecutive equal Coordinates
-	// unique() returns an iterator to the end of the resulting
-	// sequence, we erase from there to the end.
-	dest.erase( std::unique(dest.begin(),dest.end()), dest.end() );
+    // Remove consecutive equal Coordinates
+    // unique() returns an iterator to the end of the resulting
+    // sequence, we erase from there to the end.
+    dest.erase(std::unique(dest.begin(), dest.end()), dest.end());
 
-	// points must all lie in a line
-	if ( dest.size() < 3 ) return false;
+    // points must all lie in a line
+    if(dest.size() < 3) {
+        return false;
+    }
 
-	// close ring
-	dest.push_back(dest[0]);
+    // close ring
+    dest.push_back(dest[0]);
 
-	return true;
+    return true;
 }
 
 /* private */
 void
-ConvexHull::reduce(Coordinate::ConstVect &pts)
+ConvexHull::reduce(Coordinate::ConstVect& pts)
 {
-	Coordinate::ConstVect polyPts;
-
-	if ( ! computeOctRing(pts, polyPts) ) {
-	// unable to compute interior polygon for some reason
-		return;
-	}
-
-	// add points defining polygon
-	Coordinate::ConstSet reducedSet;
-	reducedSet.insert(polyPts.begin(), polyPts.end());
-
-	/**
-	 * Add all unique points not in the interior poly.
-	 * CGAlgorithms.isPointInRing is not defined for points
-	 * actually on the ring, but this doesn't matter since
-	 * the points of the interior polygon are forced to be
-	 * in the reduced set.
-	 *
-	 * @@TIP: there should be a std::algo for this
-	 */
-	for (size_t i=0, n=pts.size(); i<n; ++i)
-	{
-		if ( !PointLocation::isInRing(*(pts[i]), polyPts) )
-		{
-			reducedSet.insert(pts[i]);
-		}
-	}
-
-	inputPts.assign(reducedSet.begin(), reducedSet.end());
-
-	if ( inputPts.size() < 3 ) padArray3(inputPts);
+    Coordinate::ConstVect polyPts;
+
+    if(! computeOctRing(pts, polyPts)) {
+        // unable to compute interior polygon for some reason
+        return;
+    }
+
+    // add points defining polygon
+    Coordinate::ConstSet reducedSet;
+    reducedSet.insert(polyPts.begin(), polyPts.end());
+
+    /**
+     * Add all unique points not in the interior poly.
+     * CGAlgorithms.isPointInRing is not defined for points
+     * actually on the ring, but this doesn't matter since
+     * the points of the interior polygon are forced to be
+     * in the reduced set.
+     *
+     * @@TIP: there should be a std::algo for this
+     */
+    for(size_t i = 0, n = pts.size(); i < n; ++i) {
+        if(!PointLocation::isInRing(*(pts[i]), polyPts)) {
+            reducedSet.insert(pts[i]);
+        }
+    }
+
+    inputPts.assign(reducedSet.begin(), reducedSet.end());
+
+    if(inputPts.size() < 3) {
+        padArray3(inputPts);
+    }
 }
 
 /* private */
 void
-ConvexHull::padArray3(geom::Coordinate::ConstVect &pts)
+ConvexHull::padArray3(geom::Coordinate::ConstVect& pts)
 {
-  for (size_t i = pts.size(); i < 3; ++i) {
-    pts.push_back(pts[0]);
-  }
+    for(size_t i = pts.size(); i < 3; ++i) {
+        pts.push_back(pts[0]);
+    }
 }
 
 Geometry*
 ConvexHull::getConvexHull()
 {
-	size_t nInputPts=inputPts.size();
-
-	if (nInputPts==0) // Return an empty geometry
-		return geomFactory->createEmptyGeometry();
-
-	if (nInputPts==1) // Return a Point
-	{
-		// Copy the Coordinate from the ConstVect
-		return geomFactory->createPoint(*(inputPts[0]));
-	}
-
-	if (nInputPts==2) // Return a LineString
-	{
-		// Copy all Coordinates from the ConstVect
-		CoordinateSequence *cs = toCoordinateSequence(inputPts);
-		return geomFactory->createLineString(cs);
-	}
-
-	// use heuristic to reduce points, if large
-	if (nInputPts > 50 )
-	{
-		reduce(inputPts);
-	}
+    size_t nInputPts = inputPts.size();
+
+    if(nInputPts == 0) { // Return an empty geometry
+        return geomFactory->createEmptyGeometry();
+    }
+
+    if(nInputPts == 1) { // Return a Point
+        // Copy the Coordinate from the ConstVect
+        return geomFactory->createPoint(*(inputPts[0]));
+    }
+
+    if(nInputPts == 2) { // Return a LineString
+        // Copy all Coordinates from the ConstVect
+        CoordinateSequence* cs = toCoordinateSequence(inputPts);
+        return geomFactory->createLineString(cs);
+    }
+
+    // use heuristic to reduce points, if large
+    if(nInputPts > 50) {
+        reduce(inputPts);
+    }
 
     GEOS_CHECK_FOR_INTERRUPTS();
 
-	// sort points for Graham scan.
-	preSort(inputPts);
+    // sort points for Graham scan.
+    preSort(inputPts);
 
     GEOS_CHECK_FOR_INTERRUPTS();
 
-	// Use Graham scan to find convex hull.
-	Coordinate::ConstVect cHS;
-	grahamScan(inputPts, cHS);
+    // Use Graham scan to find convex hull.
+    Coordinate::ConstVect cHS;
+    grahamScan(inputPts, cHS);
 
     GEOS_CHECK_FOR_INTERRUPTS();
 
-	return lineOrPolygon(cHS);
+    return lineOrPolygon(cHS);
 
 }
 
 /* private */
 void
-ConvexHull::preSort(Coordinate::ConstVect &pts)
+ConvexHull::preSort(Coordinate::ConstVect& pts)
 {
-	// find the lowest point in the set. If two or more points have
-	// the same minimum y coordinate choose the one with the minimum x.
-	// This focal point is put in array location pts[0].
-	for(size_t i=1, n=pts.size(); i<n; ++i)
-	{
-		const Coordinate *p0=pts[0]; // this will change
-		const Coordinate *pi=pts[i];
-		if ( (pi->y<p0->y) || ((pi->y==p0->y) && (pi->x<p0->x)) )
-		{
-			const Coordinate *t=p0;
-			pts[0]=pi;
-			pts[i]=t;
-		}
-	}
-
-	// sort the points radially around the focal point.
+    // find the lowest point in the set. If two or more points have
+    // the same minimum y coordinate choose the one with the minimum x.
+    // This focal point is put in array location pts[0].
+    for(size_t i = 1, n = pts.size(); i < n; ++i) {
+        const Coordinate* p0 = pts[0]; // this will change
+        const Coordinate* pi = pts[i];
+        if((pi->y < p0->y) || ((pi->y == p0->y) && (pi->x < p0->x))) {
+            const Coordinate* t = p0;
+            pts[0] = pi;
+            pts[i] = t;
+        }
+    }
+
+    // sort the points radially around the focal point.
     std::sort(pts.begin(), pts.end(), RadiallyLessThen(pts[0]));
 }
 
 /*private*/
 void
-ConvexHull::grahamScan(const Coordinate::ConstVect &c,
-		Coordinate::ConstVect &ps)
+ConvexHull::grahamScan(const Coordinate::ConstVect& c,
+                       Coordinate::ConstVect& ps)
 {
-	ps.push_back(c[0]);
-	ps.push_back(c[1]);
-	ps.push_back(c[2]);
-
-	for(size_t i=3, n=c.size(); i<n; ++i)
-	{
-		const Coordinate *p = ps.back(); ps.pop_back();
-		while (!ps.empty() &&
-			Orientation::index(
-		    *(ps.back()), *p, *(c[i])) > 0)
-		{
-			p = ps.back(); ps.pop_back();
-		}
-		ps.push_back(p);
-		ps.push_back(c[i]);
-	}
-	ps.push_back(c[0]);
+    ps.push_back(c[0]);
+    ps.push_back(c[1]);
+    ps.push_back(c[2]);
+
+    for(size_t i = 3, n = c.size(); i < n; ++i) {
+        const Coordinate* p = ps.back();
+        ps.pop_back();
+        while(!ps.empty() &&
+                Orientation::index(
+                    *(ps.back()), *p, *(c[i])) > 0) {
+            p = ps.back();
+            ps.pop_back();
+        }
+        ps.push_back(p);
+        ps.push_back(c[i]);
+    }
+    ps.push_back(c[0]);
 }
 
 
 /*private*/
 bool
-ConvexHull::isBetween(const Coordinate &c1, const Coordinate &c2, const Coordinate &c3)
+ConvexHull::isBetween(const Coordinate& c1, const Coordinate& c2, const Coordinate& c3)
 {
-	if (Orientation::index(c1, c2, c3)!=0) {
-		return false;
-	}
-	if (c1.x!=c3.x) {
-		if (c1.x<=c2.x && c2.x<=c3.x) {
-			return true;
-		}
-		if (c3.x<=c2.x && c2.x<=c1.x) {
-			return true;
-		}
-	}
-	if (c1.y!=c3.y) {
-		if (c1.y<=c2.y && c2.y<=c3.y) {
-			return true;
-		}
-		if (c3.y<=c2.y && c2.y<=c1.y) {
-			return true;
-		}
-	}
-	return false;
+    if(Orientation::index(c1, c2, c3) != 0) {
+        return false;
+    }
+    if(c1.x != c3.x) {
+        if(c1.x <= c2.x && c2.x <= c3.x) {
+            return true;
+        }
+        if(c3.x <= c2.x && c2.x <= c1.x) {
+            return true;
+        }
+    }
+    if(c1.y != c3.y) {
+        if(c1.y <= c2.y && c2.y <= c3.y) {
+            return true;
+        }
+        if(c3.y <= c2.y && c2.y <= c1.y) {
+            return true;
+        }
+    }
+    return false;
 }
 
 
 /* private */
 Geometry*
-ConvexHull::lineOrPolygon(const Coordinate::ConstVect &input)
+ConvexHull::lineOrPolygon(const Coordinate::ConstVect& input)
 {
-	Coordinate::ConstVect cleaned;
-
-	cleanRing(input, cleaned);
-
-	if (cleaned.size()==3) { // shouldn't this be 2 ??
-		cleaned.resize(2);
-		CoordinateSequence *cl1=toCoordinateSequence(cleaned);
-		LineString *ret = geomFactory->createLineString(cl1);
-		return ret;
-	}
-	CoordinateSequence *cl2=toCoordinateSequence(cleaned);
-	LinearRing *linearRing=geomFactory->createLinearRing(cl2);
-	return geomFactory->createPolygon(linearRing,nullptr);
+    Coordinate::ConstVect cleaned;
+
+    cleanRing(input, cleaned);
+
+    if(cleaned.size() == 3) { // shouldn't this be 2 ??
+        cleaned.resize(2);
+        CoordinateSequence* cl1 = toCoordinateSequence(cleaned);
+        LineString* ret = geomFactory->createLineString(cl1);
+        return ret;
+    }
+    CoordinateSequence* cl2 = toCoordinateSequence(cleaned);
+    LinearRing* linearRing = geomFactory->createLinearRing(cl2);
+    return geomFactory->createPolygon(linearRing, nullptr);
 }
 
 /*private*/
 void
-ConvexHull::cleanRing(const Coordinate::ConstVect &original,
-		Coordinate::ConstVect &cleaned)
+ConvexHull::cleanRing(const Coordinate::ConstVect& original,
+                      Coordinate::ConstVect& cleaned)
 {
-	size_t npts=original.size();
+    size_t npts = original.size();
 
-	const Coordinate *last = original[npts-1];
+    const Coordinate* last = original[npts - 1];
 
-	//util::Assert::equals(*(original[0]), *last);
-	assert(last);
-	assert(original[0]->equals2D(*last));
+    //util::Assert::equals(*(original[0]), *last);
+    assert(last);
+    assert(original[0]->equals2D(*last));
 
-	const Coordinate *prev = nullptr;
-	for (size_t i=0; i<npts-1; ++i)
-	{
-		const Coordinate *curr = original[i];
-		const Coordinate *next = original[i+1];
+    const Coordinate* prev = nullptr;
+    for(size_t i = 0; i < npts - 1; ++i) {
+        const Coordinate* curr = original[i];
+        const Coordinate* next = original[i + 1];
 
-		// skip consecutive equal coordinates
-		if (curr->equals2D(*next)) continue;
+        // skip consecutive equal coordinates
+        if(curr->equals2D(*next)) {
+            continue;
+        }
 
-		if ( prev != nullptr &&  isBetween(*prev, *curr, *next) )
-		{
-			continue;
-		}
+        if(prev != nullptr &&  isBetween(*prev, *curr, *next)) {
+            continue;
+        }
 
-		cleaned.push_back(curr);
-		prev=curr;
-	}
+        cleaned.push_back(curr);
+        prev = curr;
+    }
 
-	cleaned.push_back(last);
+    cleaned.push_back(last);
 
 }
 
diff --git a/src/algorithm/Distance.cpp b/src/algorithm/Distance.cpp
index f1b4bef..f55a3df 100644
--- a/src/algorithm/Distance.cpp
+++ b/src/algorithm/Distance.cpp
@@ -29,11 +29,11 @@ namespace algorithm { // geos.algorithm
 /*public static*/
 double
 Distance::pointToSegment(const geom::Coordinate& p,
-    const geom::Coordinate& A,
-    const geom::Coordinate& B)
+                         const geom::Coordinate& A,
+                         const geom::Coordinate& B)
 {
     /* if start==end, then use pt distance */
-    if (A == B) {
+    if(A == B) {
         return p.distance(A);
     }
 
@@ -52,11 +52,15 @@ Distance::pointToSegment(const geom::Coordinate& p,
         0<r<1 P is interior to AB
     */
 
-    double r = ((p.x-A.x)*(B.x-A.x)+(p.y-A.y)*(B.y-A.y))/
-               ((B.x-A.x)*(B.x-A.x)+(B.y-A.y)*(B.y-A.y));
+    double r = ((p.x - A.x) * (B.x - A.x) + (p.y - A.y) * (B.y - A.y)) /
+               ((B.x - A.x) * (B.x - A.x) + (B.y - A.y) * (B.y - A.y));
 
-    if (r <= 0.0) return p.distance(A);
-    if (r >= 1.0) return p.distance(B);
+    if(r <= 0.0) {
+        return p.distance(A);
+    }
+    if(r >= 1.0) {
+        return p.distance(B);
+    }
 
     /*
         (2)
@@ -67,16 +71,16 @@ Distance::pointToSegment(const geom::Coordinate& p,
         Then the distance from C to P = |s|*L.
     */
 
-    double s=((A.y-p.y)*(B.x-A.x)-(A.x-p.x)*(B.y-A.y))/
-             ((B.x-A.x)*(B.x-A.x)+(B.y-A.y)*(B.y-A.y));
+    double s = ((A.y - p.y) * (B.x - A.x) - (A.x - p.x) * (B.y - A.y)) /
+               ((B.x - A.x) * (B.x - A.x) + (B.y - A.y) * (B.y - A.y));
 
-    return fabs(s)*sqrt(((B.x-A.x)*(B.x-A.x)+(B.y-A.y)*(B.y-A.y)));
+    return fabs(s) * sqrt(((B.x - A.x) * (B.x - A.x) + (B.y - A.y) * (B.y - A.y)));
 }
 
 /*public static*/
 double
 Distance::pointToLinePerpendicular(const geom::Coordinate& p,
-    const geom::Coordinate& A, const geom::Coordinate& B)
+                                   const geom::Coordinate& A, const geom::Coordinate& B)
 {
     /*
         use comp.graphics.algorithms method
@@ -89,21 +93,25 @@ Distance::pointToLinePerpendicular(const geom::Coordinate& p,
             Then the distance from C to P = |s|*L.
     */
 
-    double s = ((A.y - p.y) *(B.x - A.x) - (A.x - p.x)*(B.y - A.y))
-              /
+    double s = ((A.y - p.y) * (B.x - A.x) - (A.x - p.x) * (B.y - A.y))
+               /
                ((B.x - A.x) * (B.x - A.x) + (B.y - A.y) * (B.y - A.y));
-    return fabs(s)*sqrt(((B.x - A.x) * (B.x - A.x) + (B.y - A.y) * (B.y - A.y)));
+    return fabs(s) * sqrt(((B.x - A.x) * (B.x - A.x) + (B.y - A.y) * (B.y - A.y)));
 }
 
 /*public static*/
 double
 Distance::segmentToSegment(const geom::Coordinate& A,
-    const geom::Coordinate& B, const geom::Coordinate& C,
-    const geom::Coordinate& D)
+                           const geom::Coordinate& B, const geom::Coordinate& C,
+                           const geom::Coordinate& D)
 {
     /* Check for zero-length segments */
-    if (A == B) return pointToSegment(A,C,D);
-    if (C == D) return pointToSegment(D,A,B);
+    if(A == B) {
+        return pointToSegment(A, C, D);
+    }
+    if(C == D) {
+        return pointToSegment(D, A, B);
+    }
 
     /* AB and CD are line segments */
     /*
@@ -134,25 +142,25 @@ Distance::segmentToSegment(const geom::Coordinate& A,
         If the numerator in eqn 1 is also zero, AB & CD are collinear.
     */
 
-    double r_top=(A.y-C.y)*(D.x-C.x)-(A.x-C.x)*(D.y-C.y);
-    double r_bot=(B.x-A.x)*(D.y-C.y)-(B.y-A.y)*(D.x-C.x);
-    double s_top=(A.y-C.y)*(B.x-A.x)-(A.x-C.x)*(B.y-A.y);
-    double s_bot=(B.x-A.x)*(D.y-C.y)-(B.y-A.y)*(D.x-C.x);
+    double r_top = (A.y - C.y) * (D.x - C.x) - (A.x - C.x) * (D.y - C.y);
+    double r_bot = (B.x - A.x) * (D.y - C.y) - (B.y - A.y) * (D.x - C.x);
+    double s_top = (A.y - C.y) * (B.x - A.x) - (A.x - C.x) * (B.y - A.y);
+    double s_bot = (B.x - A.x) * (D.y - C.y) - (B.y - A.y) * (D.x - C.x);
 
-    if ((r_bot==0) || (s_bot==0)) {
-        return std::min(pointToSegment(A,C,D),
-               std::min(pointToSegment(B,C,D),
-               std::min(pointToSegment(C,A,B), pointToSegment(D,A,B))));
+    if((r_bot == 0) || (s_bot == 0)) {
+        return std::min(pointToSegment(A, C, D),
+                        std::min(pointToSegment(B, C, D),
+                                 std::min(pointToSegment(C, A, B), pointToSegment(D, A, B))));
     }
 
-    double s=s_top/s_bot;
-    double r=r_top/r_bot;
+    double s = s_top / s_bot;
+    double r = r_top / r_bot;
 
-    if ((r<0) || (r>1) || (s<0) || (s>1)) {
+    if((r < 0) || (r > 1) || (s < 0) || (s > 1)) {
         /* no intersection */
-        return std::min(pointToSegment(A,C,D),
-               std::min(pointToSegment(B,C,D),
-               std::min(pointToSegment(C,A,B), pointToSegment(D,A,B))));
+        return std::min(pointToSegment(A, C, D),
+                        std::min(pointToSegment(B, C, D),
+                                 std::min(pointToSegment(C, A, B), pointToSegment(D, A, B))));
     }
 
     return 0.0; /* intersection exists */
@@ -161,21 +169,21 @@ Distance::segmentToSegment(const geom::Coordinate& A,
 /*public static*/
 double
 Distance::pointToSegmentString(const geom::Coordinate& p,
-    const geom::CoordinateSequence *seq)
+                               const geom::CoordinateSequence* seq)
 {
-    if (seq->size() == 0) {
+    if(seq->size() == 0) {
         throw util::IllegalArgumentException(
             "Line array must contain at least one vertex");
     }
 
     /* this handles the case of length = 1 */
     double minDistance = p.distance(seq->getAt(0));
-    for (std::size_t i = 0; i < seq->size()-1; i++) {
+    for(std::size_t i = 0; i < seq->size() - 1; i++) {
         const geom::Coordinate& si = seq->getAt(i);
-        const geom::Coordinate& si1 = seq->getAt(i+1);
+        const geom::Coordinate& si1 = seq->getAt(i + 1);
         double dist = pointToSegment(p, si, si1);
 
-        if (dist < minDistance) {
+        if(dist < minDistance) {
             minDistance = dist;
         }
     }
diff --git a/src/algorithm/HCoordinate.cpp b/src/algorithm/HCoordinate.cpp
index 6fc8e82..7b9f86a 100644
--- a/src/algorithm/HCoordinate.cpp
+++ b/src/algorithm/HCoordinate.cpp
@@ -40,105 +40,104 @@ namespace algorithm { // geos.algorithm
 
 /*public static*/
 void
-HCoordinate::intersection(const Coordinate &p1, const Coordinate &p2,
-	const Coordinate &q1, const Coordinate &q2, Coordinate &ret)
+HCoordinate::intersection(const Coordinate& p1, const Coordinate& p2,
+                          const Coordinate& q1, const Coordinate& q2, Coordinate& ret)
 {
 
 #if GEOS_DEBUG
-	cerr << __FUNCTION__ << ":" << endl
-	     << setprecision(20)
-	     << " p1: " << p1 << endl
-	     << " p2: " << p2 << endl
-	     << " q1: " << q1 << endl
-	     << " q2: " << q2 << endl;
+    cerr << __FUNCTION__ << ":" << endl
+         << setprecision(20)
+         << " p1: " << p1 << endl
+         << " p2: " << p2 << endl
+         << " q1: " << q1 << endl
+         << " q2: " << q2 << endl;
 #endif
 
-	// unrolled computation
+    // unrolled computation
 
-	double px = p1.y - p2.y;
-	double py = p2.x - p1.x;
-	double pw = p1.x * p2.y - p2.x * p1.y;
+    double px = p1.y - p2.y;
+    double py = p2.x - p1.x;
+    double pw = p1.x * p2.y - p2.x * p1.y;
 
-	double qx = q1.y - q2.y;
-	double qy = q2.x - q1.x;
-	double qw = q1.x * q2.y - q2.x * q1.y;
+    double qx = q1.y - q2.y;
+    double qy = q2.x - q1.x;
+    double qw = q1.x * q2.y - q2.x * q1.y;
 
-	double x = py * qw - qy * pw;
-	double y = qx * pw - px * qw;
-	double w = px * qy - qx * py;
+    double x = py * qw - qy * pw;
+    double y = qx * pw - px * qw;
+    double w = px * qy - qx * py;
 
-	double xInt = x/w;
-	double yInt = y/w;
+    double xInt = x / w;
+    double yInt = y / w;
 
-	if ( (!std::isfinite(xInt)) || (!std::isfinite(yInt)) )
-	{
-		throw NotRepresentableException();
-	}
+    if((!std::isfinite(xInt)) || (!std::isfinite(yInt))) {
+        throw NotRepresentableException();
+    }
 
-	ret = Coordinate(xInt, yInt);
+    ret = Coordinate(xInt, yInt);
 }
 
 /*public*/
 HCoordinate::HCoordinate()
-	:
-	x(0.0),
-	y(0.0),
-	w(1.0)
+    :
+    x(0.0),
+    y(0.0),
+    w(1.0)
 {
 }
 
 /*public*/
 HCoordinate::HCoordinate(double _x, double _y, double _w)
-	:
-	x(_x),
-	y(_y),
-	w(_w)
+    :
+    x(_x),
+    y(_y),
+    w(_w)
 {
 }
 
 /*public*/
 HCoordinate::HCoordinate(const Coordinate& p)
-	:
-	x(p.x),
-	y(p.y),
-	w(1.0)
+    :
+    x(p.x),
+    y(p.y),
+    w(1.0)
 {
 }
 
 /*public*/
 HCoordinate::HCoordinate(const Coordinate& p1, const Coordinate& p2)
-	:
-	// optimization when it is known that w = 1
-	x ( p1.y - p2.y ),
-	y ( p2.x - p1.x ),
-	w ( p1.x * p2.y - p2.x * p1.y )
+    :
+    // optimization when it is known that w = 1
+    x(p1.y - p2.y),
+    y(p2.x - p1.x),
+    w(p1.x * p2.y - p2.x * p1.y)
 {
 }
 
 /*public*/
 HCoordinate::HCoordinate(const Coordinate& p1, const Coordinate& p2,
-			 const Coordinate& q1, const Coordinate& q2)
+                         const Coordinate& q1, const Coordinate& q2)
 {
-	// unrolled computation
-	double px = p1.y - p2.y;
-	double py = p2.x - p1.x;
-	double pw = p1.x * p2.y - p2.x * p1.y;
-
-	double qx = q1.y - q2.y;
-	double qy = q2.x - q1.x;
-	double qw = q1.x * q2.y - q2.x * q1.y;
-
-	x = py * qw - qy * pw;
-	y = qx * pw - px * qw;
-	w = px * qy - qx * py;
+    // unrolled computation
+    double px = p1.y - p2.y;
+    double py = p2.x - p1.x;
+    double pw = p1.x * p2.y - p2.x * p1.y;
+
+    double qx = q1.y - q2.y;
+    double qy = q2.x - q1.x;
+    double qw = q1.x * q2.y - q2.x * q1.y;
+
+    x = py * qw - qy * pw;
+    y = qx * pw - px * qw;
+    w = px * qy - qx * py;
 }
 
 /*public*/
-HCoordinate::HCoordinate(const HCoordinate &p1, const HCoordinate &p2)
-	:
-	x( p1.y*p2.w - p2.y*p1.w ),
-	y( p2.x*p1.w - p1.x*p2.w ),
-	w( p1.x*p2.y - p2.x*p1.y )
+HCoordinate::HCoordinate(const HCoordinate& p1, const HCoordinate& p2)
+    :
+    x(p1.y * p2.w - p2.y * p1.w),
+    y(p2.x * p1.w - p1.x * p2.w),
+    w(p1.x * p2.y - p2.x * p1.y)
 {
 }
 
@@ -146,35 +145,36 @@ HCoordinate::HCoordinate(const HCoordinate &p1, const HCoordinate &p2)
 double
 HCoordinate::getX() const
 {
-	double a = x/w;
-	if ( !std::isfinite(a) ) {
-		throw NotRepresentableException();
-	}
-	return a;
+    double a = x / w;
+    if(!std::isfinite(a)) {
+        throw NotRepresentableException();
+    }
+    return a;
 }
 
 /*public*/
 double
 HCoordinate::getY() const
 {
-	double a = y/w;
-	if ( !std::isfinite(a) ) {
-		throw  NotRepresentableException();
-	}
-	return a;
+    double a = y / w;
+    if(!std::isfinite(a)) {
+        throw  NotRepresentableException();
+    }
+    return a;
 }
 
 /*public*/
 void
-HCoordinate::getCoordinate(Coordinate &ret) const
+HCoordinate::getCoordinate(Coordinate& ret) const
 {
-	ret = Coordinate(static_cast<double>(getX()), static_cast<double>(getY()));
+    ret = Coordinate(static_cast<double>(getX()), static_cast<double>(getY()));
 }
 
-std::ostream& operator<< (std::ostream& o, const HCoordinate& c)
+std::ostream&
+operator<< (std::ostream& o, const HCoordinate& c)
 {
-	return o << "(" << c.x << ", "
-	         << c.y << ") [w: " << c.w << "]";
+    return o << "(" << c.x << ", "
+           << c.y << ") [w: " << c.w << "]";
 }
 
 } // namespace geos.algorithm
diff --git a/src/algorithm/InteriorPointArea.cpp b/src/algorithm/InteriorPointArea.cpp
index f1938d8..5eaa674 100644
--- a/src/algorithm/InteriorPointArea.cpp
+++ b/src/algorithm/InteriorPointArea.cpp
@@ -41,87 +41,97 @@ namespace algorithm { // geos.algorithm
 // file-statics
 namespace {
 
-  double avg(double a, double b){return (a+b)/2.0;}
-
-  /**
-   * Finds a safe bisector Y ordinate
-   * by projecting to the Y axis
-   * and finding the Y-ordinate interval
-   * which contains the centre of the Y extent.
-   * The centre of this interval is returned as the bisector Y-ordinate.
-   *
-   * @author mdavis
-   *
-   */
-  class SafeBisectorFinder
-  {
-  public:
-	  static double getBisectorY(const Polygon& poly)
-	  {
-		  SafeBisectorFinder finder(poly);
-		  return finder.getBisectorY();
-	  }
-	  SafeBisectorFinder(const Polygon& nPoly)
-      : poly(nPoly)
+double
+avg(double a, double b)
+{
+    return (a + b) / 2.0;
+}
+
+/**
+ * Finds a safe bisector Y ordinate
+ * by projecting to the Y axis
+ * and finding the Y-ordinate interval
+ * which contains the centre of the Y extent.
+ * The centre of this interval is returned as the bisector Y-ordinate.
+ *
+ * @author mdavis
+ *
+ */
+class SafeBisectorFinder {
+public:
+    static double
+    getBisectorY(const Polygon& poly)
+    {
+        SafeBisectorFinder finder(poly);
+        return finder.getBisectorY();
+    }
+    SafeBisectorFinder(const Polygon& nPoly)
+        : poly(nPoly)
+    {
+        // initialize using extremal values
+        hiY = poly.getEnvelopeInternal()->getMaxY();
+        loY = poly.getEnvelopeInternal()->getMinY();
+        centreY = avg(loY, hiY);
+    }
+
+    double
+    getBisectorY()
     {
-		  // initialize using extremal values
-		  hiY = poly.getEnvelopeInternal()->getMaxY();
-		  loY = poly.getEnvelopeInternal()->getMinY();
-		  centreY = avg(loY, hiY);
-	  }
-
-	  double getBisectorY()
-	  {
-		  process(*poly.getExteriorRing());
-		  for (size_t i = 0; i < poly.getNumInteriorRing(); i++) {
-			  process(*poly.getInteriorRingN(i));
-		  }
-		  double bisectY = avg(hiY, loY);
-		  return bisectY;
-	  }
-
-
-	private:
-	  const Polygon& poly;
-
-	  double centreY;
-	  double hiY;
-	  double loY;
-
-	  void process(const LineString& line) {
-      const CoordinateSequence* seq = line.getCoordinatesRO();
-      for (std::size_t i = 0, s = seq->size(); i < s; i++) {
-        double y = seq->getY(i);
-        updateInterval(y);
-      }
-    }
-
-    void updateInterval(double y) {
-      if (y <= centreY) {
-        if (y > loY)
-          loY = y;
-      }
-      else if (y > centreY) {
-        if (y < hiY) {
-          hiY = y;
+        process(*poly.getExteriorRing());
+        for(size_t i = 0; i < poly.getNumInteriorRing(); i++) {
+            process(*poly.getInteriorRingN(i));
+        }
+        double bisectY = avg(hiY, loY);
+        return bisectY;
+    }
+
+
+private:
+    const Polygon& poly;
+
+    double centreY;
+    double hiY;
+    double loY;
+
+    void
+    process(const LineString& line)
+    {
+        const CoordinateSequence* seq = line.getCoordinatesRO();
+        for(std::size_t i = 0, s = seq->size(); i < s; i++) {
+            double y = seq->getY(i);
+            updateInterval(y);
+        }
+    }
+
+    void
+    updateInterval(double y)
+    {
+        if(y <= centreY) {
+            if(y > loY) {
+                loY = y;
+            }
+        }
+        else if(y > centreY) {
+            if(y < hiY) {
+                hiY = y;
+            }
         }
-      }
     }
 
     SafeBisectorFinder(SafeBisectorFinder const&); /*= delete*/
     SafeBisectorFinder& operator=(SafeBisectorFinder const&); /*= delete*/
-  };
+};
 
 } // anonymous namespace
 
 
 /*public*/
-InteriorPointArea::InteriorPointArea(const Geometry *g)
+InteriorPointArea::InteriorPointArea(const Geometry* g)
 {
-	foundInterior=false;
-	maxWidth=0.0;
-	factory=g->getFactory();
-	add(g);
+    foundInterior = false;
+    maxWidth = 0.0;
+    factory = g->getFactory();
+    add(g);
 }
 
 /*public*/
@@ -133,115 +143,119 @@ InteriorPointArea::~InteriorPointArea()
 bool
 InteriorPointArea::getInteriorPoint(Coordinate& ret) const
 {
-	if ( ! foundInterior ) return false;
+    if(! foundInterior) {
+        return false;
+    }
 
-	ret=interiorPoint;
-	return true;
+    ret = interiorPoint;
+    return true;
 }
 
 /*public*/
 void
-InteriorPointArea::add(const Geometry *geom)
+InteriorPointArea::add(const Geometry* geom)
 {
-	const Polygon *poly = dynamic_cast<const Polygon*>(geom);
-	if ( poly ) {
-		addPolygon(geom);
-		return;
-	}
-
-	const GeometryCollection *gc = dynamic_cast<const GeometryCollection*>(geom);
-	if ( gc )
-	{
-        for(std::size_t i=0, n=gc->getNumGeometries(); i<n; i++) {
-			add(gc->getGeometryN(i));
-		}
-	}
+    const Polygon* poly = dynamic_cast<const Polygon*>(geom);
+    if(poly) {
+        addPolygon(geom);
+        return;
+    }
+
+    const GeometryCollection* gc = dynamic_cast<const GeometryCollection*>(geom);
+    if(gc) {
+        for(std::size_t i = 0, n = gc->getNumGeometries(); i < n; i++) {
+            add(gc->getGeometryN(i));
+        }
+    }
 }
 
 /*private*/
 void
-InteriorPointArea::addPolygon(const Geometry *geometry)
+InteriorPointArea::addPolygon(const Geometry* geometry)
 {
-  if (geometry->isEmpty()) return;
-
-  Coordinate intPt;
-  double width;
-
-  unique_ptr<LineString> bisector ( horizontalBisector(geometry) );
-  if ( bisector->getLength() == 0.0 ) {
-    width = 0;
-    intPt = bisector->getCoordinateN(0);
-  }
-  else {
-    unique_ptr<Geometry> intersections ( bisector->intersection(geometry) );
-    const Geometry *widestIntersection = widestGeometry(intersections.get());
-    const Envelope *env = widestIntersection->getEnvelopeInternal();
-    width=env->getWidth();
-    env->centre(intPt);
-  }
-  if (!foundInterior || width>maxWidth) {
-    interiorPoint = intPt;
-    maxWidth = width;
-    foundInterior=true;
-  }
+    if(geometry->isEmpty()) {
+        return;
+    }
+
+    Coordinate intPt;
+    double width;
+
+    unique_ptr<LineString> bisector(horizontalBisector(geometry));
+    if(bisector->getLength() == 0.0) {
+        width = 0;
+        intPt = bisector->getCoordinateN(0);
+    }
+    else {
+        unique_ptr<Geometry> intersections(bisector->intersection(geometry));
+        const Geometry* widestIntersection = widestGeometry(intersections.get());
+        const Envelope* env = widestIntersection->getEnvelopeInternal();
+        width = env->getWidth();
+        env->centre(intPt);
+    }
+    if(!foundInterior || width > maxWidth) {
+        interiorPoint = intPt;
+        maxWidth = width;
+        foundInterior = true;
+    }
 }
 
 //@return if geometry is a collection, the widest sub-geometry; otherwise,
 //the geometry itself
 const Geometry*
-InteriorPointArea::widestGeometry(const Geometry *geometry)
+InteriorPointArea::widestGeometry(const Geometry* geometry)
 {
-	const GeometryCollection *gc = dynamic_cast<const GeometryCollection*>(geometry);
-	if ( gc ) {
-		return widestGeometry(gc);
-	} else {
-		return geometry;
-	}
+    const GeometryCollection* gc = dynamic_cast<const GeometryCollection*>(geometry);
+    if(gc) {
+        return widestGeometry(gc);
+    }
+    else {
+        return geometry;
+    }
 }
 
 const Geometry*
-InteriorPointArea::widestGeometry(const GeometryCollection* gc) {
-	if (gc->isEmpty()) {
-		return gc;
-	}
-	const Geometry* p_widestGeometry=gc->getGeometryN(0);
-
-	// scan remaining geom components to see if any are wider
-	for(std::size_t i=1, n=gc->getNumGeometries(); i<n; i++) // start at 1
-	{
-		const Envelope *env1(gc->getGeometryN(i)->getEnvelopeInternal());
-		const Envelope *env2(p_widestGeometry->getEnvelopeInternal());
-		if (env1->getWidth()>env2->getWidth()) {
-				p_widestGeometry=gc->getGeometryN(i);
-		}
-	}
-	return p_widestGeometry;
+InteriorPointArea::widestGeometry(const GeometryCollection* gc)
+{
+    if(gc->isEmpty()) {
+        return gc;
+    }
+    const Geometry* p_widestGeometry = gc->getGeometryN(0);
+
+    // scan remaining geom components to see if any are wider
+    for(std::size_t i = 1, n = gc->getNumGeometries(); i < n; i++) { // start at 1
+        const Envelope* env1(gc->getGeometryN(i)->getEnvelopeInternal());
+        const Envelope* env2(p_widestGeometry->getEnvelopeInternal());
+        if(env1->getWidth() > env2->getWidth()) {
+            p_widestGeometry = gc->getGeometryN(i);
+        }
+    }
+    return p_widestGeometry;
 }
 
 /* private */
 LineString*
-InteriorPointArea::horizontalBisector(const Geometry *geometry)
+InteriorPointArea::horizontalBisector(const Geometry* geometry)
 {
-	const Envelope *envelope=geometry->getEnvelopeInternal();
-
-	/**
-	 * Original algorithm.  Fails when geometry contains a horizontal
-	 * segment at the Y midpoint.
-	 */
-	// Assert: for areas, minx <> maxx
-	//double avgY=avg(envelope->getMinY(),envelope->getMaxY());
-
-	double bisectY = SafeBisectorFinder::getBisectorY(*dynamic_cast<const Polygon *>(geometry));
-	vector<Coordinate>*cv=new vector<Coordinate>(2);
-	(*cv)[0].x = envelope->getMinX();
-	(*cv)[0].y = bisectY;
-	(*cv)[1].x = envelope->getMaxX();
-	(*cv)[1].y = bisectY;
-
-	CoordinateSequence *cl = factory->getCoordinateSequenceFactory()->create(cv);
-
-	LineString *ret = factory->createLineString(cl);
-	return ret;
+    const Envelope* envelope = geometry->getEnvelopeInternal();
+
+    /**
+     * Original algorithm.  Fails when geometry contains a horizontal
+     * segment at the Y midpoint.
+     */
+    // Assert: for areas, minx <> maxx
+    //double avgY=avg(envelope->getMinY(),envelope->getMaxY());
+
+    double bisectY = SafeBisectorFinder::getBisectorY(*dynamic_cast<const Polygon*>(geometry));
+    vector<Coordinate>* cv = new vector<Coordinate>(2);
+    (*cv)[0].x = envelope->getMinX();
+    (*cv)[0].y = bisectY;
+    (*cv)[1].x = envelope->getMaxX();
+    (*cv)[1].y = bisectY;
+
+    CoordinateSequence* cl = factory->getCoordinateSequenceFactory()->create(cv);
+
+    LineString* ret = factory->createLineString(cl);
+    return ret;
 }
 
 } // namespace geos.algorithm
diff --git a/src/algorithm/InteriorPointLine.cpp b/src/algorithm/InteriorPointLine.cpp
index c199503..4de12ad 100644
--- a/src/algorithm/InteriorPointLine.cpp
+++ b/src/algorithm/InteriorPointLine.cpp
@@ -38,18 +38,19 @@ using namespace geos::geom;
 namespace geos {
 namespace algorithm { // geos.algorithm
 
-InteriorPointLine::InteriorPointLine(const Geometry *g)
+InteriorPointLine::InteriorPointLine(const Geometry* g)
 {
-	minDistance=DoubleMax;
-	hasInterior=false;
-	if ( g->getCentroid(centroid) )
-	{
+    minDistance = DoubleMax;
+    hasInterior = false;
+    if(g->getCentroid(centroid)) {
 #if GEOS_DEBUG
-		std::cerr << "Centroid: " << centroid << std::endl;
+        std::cerr << "Centroid: " << centroid << std::endl;
 #endif
-		addInterior(g);
-	}
-	if (!hasInterior) addEndpoints(g);
+        addInterior(g);
+    }
+    if(!hasInterior) {
+        addEndpoints(g);
+    }
 }
 
 InteriorPointLine::~InteriorPointLine()
@@ -64,31 +65,29 @@ InteriorPointLine::~InteriorPointLine()
  * @param geom the geometry to add
  */
 void
-InteriorPointLine::addInterior(const Geometry *geom)
+InteriorPointLine::addInterior(const Geometry* geom)
 {
-	const LineString *ls = dynamic_cast<const LineString*>(geom);
-	if ( ls ) {
-		addInterior(ls->getCoordinatesRO());
-		return;
-	}
-
-	const GeometryCollection *gc = dynamic_cast<const GeometryCollection*>(geom);
-	if ( gc )
-	{
-		for(std::size_t i=0, n=gc->getNumGeometries(); i<n; i++) {
-			addInterior(gc->getGeometryN(i));
-		}
-	}
+    const LineString* ls = dynamic_cast<const LineString*>(geom);
+    if(ls) {
+        addInterior(ls->getCoordinatesRO());
+        return;
+    }
+
+    const GeometryCollection* gc = dynamic_cast<const GeometryCollection*>(geom);
+    if(gc) {
+        for(std::size_t i = 0, n = gc->getNumGeometries(); i < n; i++) {
+            addInterior(gc->getGeometryN(i));
+        }
+    }
 }
 
 void
-InteriorPointLine::addInterior(const CoordinateSequence *pts)
+InteriorPointLine::addInterior(const CoordinateSequence* pts)
 {
-	const std::size_t n=pts->getSize()-1;
-	for(std::size_t i=1; i<n; ++i)
-	{
-		add(pts->getAt(i));
-	}
+    const std::size_t n = pts->getSize() - 1;
+    for(std::size_t i = 1; i < n; ++i) {
+        add(pts->getAt(i));
+    }
 }
 
 /* private
@@ -99,31 +98,32 @@ InteriorPointLine::addInterior(const CoordinateSequence *pts)
  * @param geom the geometry to add
  */
 void
-InteriorPointLine::addEndpoints(const Geometry *geom)
+InteriorPointLine::addEndpoints(const Geometry* geom)
 {
-	const LineString *ls = dynamic_cast<const LineString*>(geom);
-	if ( ls ) {
-		addEndpoints(ls->getCoordinatesRO());
-		return;
-	}
-
-	const GeometryCollection *gc = dynamic_cast<const GeometryCollection*>(geom);
-	if ( gc )
-	{
-		for(std::size_t i=0, n=gc->getNumGeometries(); i<n; i++) {
-			addEndpoints(gc->getGeometryN(i));
-		}
-	}
+    const LineString* ls = dynamic_cast<const LineString*>(geom);
+    if(ls) {
+        addEndpoints(ls->getCoordinatesRO());
+        return;
+    }
+
+    const GeometryCollection* gc = dynamic_cast<const GeometryCollection*>(geom);
+    if(gc) {
+        for(std::size_t i = 0, n = gc->getNumGeometries(); i < n; i++) {
+            addEndpoints(gc->getGeometryN(i));
+        }
+    }
 }
 
 void
-InteriorPointLine::addEndpoints(const CoordinateSequence *pts)
+InteriorPointLine::addEndpoints(const CoordinateSequence* pts)
 {
-  size_t npts = pts->size();
-  if ( npts ) {
-    add(pts->getAt(0));
-    if ( npts > 1 ) add(pts->getAt(npts-1));
-  }
+    size_t npts = pts->size();
+    if(npts) {
+        add(pts->getAt(0));
+        if(npts > 1) {
+            add(pts->getAt(npts - 1));
+        }
+    }
 }
 
 /*private*/
@@ -131,26 +131,28 @@ void
 InteriorPointLine::add(const Coordinate& point)
 {
 
-	double dist=point.distance(centroid);
+    double dist = point.distance(centroid);
 #if GEOS_DEBUG
-	std::cerr << "point " << point << " dist " << dist << ", minDistance " << minDistance << std::endl;
+    std::cerr << "point " << point << " dist " << dist << ", minDistance " << minDistance << std::endl;
 #endif
-	if (!hasInterior || dist<minDistance) {
-		interiorPoint=point;
+    if(!hasInterior || dist < minDistance) {
+        interiorPoint = point;
 #if GEOS_DEBUG
-		std::cerr << " is new InteriorPoint" << std::endl;
+        std::cerr << " is new InteriorPoint" << std::endl;
 #endif
-		minDistance=dist;
-		hasInterior=true;
-	}
+        minDistance = dist;
+        hasInterior = true;
+    }
 }
 
 bool
 InteriorPointLine::getInteriorPoint(Coordinate& ret) const
 {
-	if ( ! hasInterior ) return false;
-	ret=interiorPoint;
-	return true;
+    if(! hasInterior) {
+        return false;
+    }
+    ret = interiorPoint;
+    return true;
 }
 
 } // namespace geos.algorithm
diff --git a/src/algorithm/InteriorPointPoint.cpp b/src/algorithm/InteriorPointPoint.cpp
index 22c8c25..7f953ae 100644
--- a/src/algorithm/InteriorPointPoint.cpp
+++ b/src/algorithm/InteriorPointPoint.cpp
@@ -31,55 +31,57 @@ namespace geos {
 namespace algorithm { // geos.algorithm
 
 /*public*/
-InteriorPointPoint::InteriorPointPoint(const Geometry *g)
+InteriorPointPoint::InteriorPointPoint(const Geometry* g)
 {
-	minDistance=DoubleMax;
-	if ( ! g->getCentroid(centroid) ) {
-		hasInterior=false;
-	} else {
-		hasInterior=true;
-		add(g);
-	}
+    minDistance = DoubleMax;
+    if(! g->getCentroid(centroid)) {
+        hasInterior = false;
+    }
+    else {
+        hasInterior = true;
+        add(g);
+    }
 }
 
 /*private*/
 void
-InteriorPointPoint::add(const Geometry *geom)
+InteriorPointPoint::add(const Geometry* geom)
 {
-	const Point *po = dynamic_cast<const Point*>(geom);
-	if ( po ) {
-		add(po->getCoordinate());
-		return;
-	}
+    const Point* po = dynamic_cast<const Point*>(geom);
+    if(po) {
+        add(po->getCoordinate());
+        return;
+    }
 
-	const GeometryCollection *gc = dynamic_cast<const GeometryCollection*>(geom);
-	if ( gc )
-	{
-		for(std::size_t i=0, n=gc->getNumGeometries(); i<n; i++) {
-			add(gc->getGeometryN(i));
-		}
-	}
+    const GeometryCollection* gc = dynamic_cast<const GeometryCollection*>(geom);
+    if(gc) {
+        for(std::size_t i = 0, n = gc->getNumGeometries(); i < n; i++) {
+            add(gc->getGeometryN(i));
+        }
+    }
 }
 
 /*private*/
 void
-InteriorPointPoint::add(const Coordinate *point)
+InteriorPointPoint::add(const Coordinate* point)
 {
-	assert ( point ); // we wouldn't been called if this was an empty geom
-	double dist=point->distance(centroid);
-	if (dist<minDistance) {
-		interiorPoint=*point;
-		minDistance=dist;
-	}
+    assert(point);    // we wouldn't been called if this was an empty geom
+    double dist = point->distance(centroid);
+    if(dist < minDistance) {
+        interiorPoint = *point;
+        minDistance = dist;
+    }
 }
 
 /*public*/
 bool
 InteriorPointPoint::getInteriorPoint(Coordinate& ret) const
 {
-	if ( ! hasInterior ) return false;
-	ret=interiorPoint;
-	return true;
+    if(! hasInterior) {
+        return false;
+    }
+    ret = interiorPoint;
+    return true;
 }
 
 } // namespace geos.algorithm
diff --git a/src/algorithm/Length.cpp b/src/algorithm/Length.cpp
index 4d4ceb6..caf87e6 100644
--- a/src/algorithm/Length.cpp
+++ b/src/algorithm/Length.cpp
@@ -26,21 +26,22 @@ namespace algorithm { // geos.algorithm
 
 /* public static */
 double
-Length::ofLine(const geom::CoordinateSequence *pts)
+Length::ofLine(const geom::CoordinateSequence* pts)
 {
     // optimized for processing CoordinateSequences
     size_t n = pts->size();
-    if (n <= 1)
+    if(n <= 1) {
         return 0.0;
+    }
 
     double len = 0.0;
 
-    const geom::Coordinate &p = pts->getAt(0);
+    const geom::Coordinate& p = pts->getAt(0);
     double x0 = p.x;
     double y0 = p.y;
 
-    for (size_t i = 1; i < n; i++) {
-        const geom::Coordinate &pi = pts->getAt(i);
+    for(size_t i = 1; i < n; i++) {
+        const geom::Coordinate& pi = pts->getAt(i);
         double x1 = pi.x;
         double y1 = pi.y;
         double dx = x1 - x0;
diff --git a/src/algorithm/LineIntersector.cpp b/src/algorithm/LineIntersector.cpp
index f3b6cfb..2be486f 100644
--- a/src/algorithm/LineIntersector.cpp
+++ b/src/algorithm/LineIntersector.cpp
@@ -73,28 +73,29 @@ namespace { // anonymous
  * @param q2 an endpoint of segment Q
  * @return the nearest endpoint to the other segment
  */
-Coordinate nearestEndpoint(const Coordinate& p1, const Coordinate& p2,
-    const Coordinate& q1, const Coordinate& q2)
+Coordinate
+nearestEndpoint(const Coordinate& p1, const Coordinate& p2,
+                const Coordinate& q1, const Coordinate& q2)
 {
-  Coordinate nearestPt = p1;
-  double minDist = Distance::pointToSegment(p1, q1, q2);
-
-  double dist = Distance::pointToSegment(p2, q1, q2);
-  if (dist < minDist) {
-    minDist = dist;
-    nearestPt = p2;
-  }
-  dist = Distance::pointToSegment(q1, p1, p2);
-  if (dist < minDist) {
-    minDist = dist;
-    nearestPt = q1;
-  }
-  dist = Distance::pointToSegment(q2, p1, p2);
-  if (dist < minDist) {
-    minDist = dist;
-    nearestPt = q2;
-  }
-  return nearestPt;
+    Coordinate nearestPt = p1;
+    double minDist = Distance::pointToSegment(p1, q1, q2);
+
+    double dist = Distance::pointToSegment(p2, q1, q2);
+    if(dist < minDist) {
+        minDist = dist;
+        nearestPt = p2;
+    }
+    dist = Distance::pointToSegment(q1, p1, p2);
+    if(dist < minDist) {
+        minDist = dist;
+        nearestPt = q1;
+    }
+    dist = Distance::pointToSegment(q2, p1, p2);
+    if(dist < minDist) {
+        minDist = dist;
+        nearestPt = q2;
+    }
+    return nearestPt;
 }
 
 
@@ -102,687 +103,796 @@ Coordinate nearestEndpoint(const Coordinate& p1, const Coordinate& p2,
 
 /*public static*/
 double
-LineIntersector::computeEdgeDistance(const Coordinate& p,const Coordinate& p0,const Coordinate& p1)
+LineIntersector::computeEdgeDistance(const Coordinate& p, const Coordinate& p0, const Coordinate& p1)
 {
-	double dx=fabs(p1.x-p0.x);
-	double dy=fabs(p1.y-p0.y);
-	double dist=-1.0;	// sentinel value
-	if (p==p0) {
-		dist=0.0;
-	} else if (p==p1) {
-		if (dx>dy)
-			dist=dx;
-		else
-			dist=dy;
-	} else {
-		double pdx=fabs(p.x - p0.x);
-		double pdy=fabs(p.y - p0.y);
-		if (dx > dy)
-			dist = pdx;
-		else
-			dist = pdy;
-		// <FIX>
-		// hack to ensure that non-endpoints always have a non-zero distance
-		if (dist == 0.0 && !(p==p0)) {
-			dist=std::max(pdx,pdy);
-		}
-	}
-	assert(!(dist == 0.0 && !(p==p0))); // Bad distance calculation
-	return dist;
+    double dx = fabs(p1.x - p0.x);
+    double dy = fabs(p1.y - p0.y);
+    double dist = -1.0;	// sentinel value
+    if(p == p0) {
+        dist = 0.0;
+    }
+    else if(p == p1) {
+        if(dx > dy) {
+            dist = dx;
+        }
+        else {
+            dist = dy;
+        }
+    }
+    else {
+        double pdx = fabs(p.x - p0.x);
+        double pdy = fabs(p.y - p0.y);
+        if(dx > dy) {
+            dist = pdx;
+        }
+        else {
+            dist = pdy;
+        }
+        // <FIX>
+        // hack to ensure that non-endpoints always have a non-zero distance
+        if(dist == 0.0 && !(p == p0)) {
+            dist = std::max(pdx, pdy);
+        }
+    }
+    assert(!(dist == 0.0 && !(p == p0))); // Bad distance calculation
+    return dist;
 }
 
 /*public*/
 void
-LineIntersector::computeIntersection(const Coordinate& p1,const Coordinate& p2,const Coordinate& p3,const Coordinate& p4)
+LineIntersector::computeIntersection(const Coordinate& p1, const Coordinate& p2, const Coordinate& p3,
+                                     const Coordinate& p4)
 {
-	inputLines[0][0]=&p1;
-	inputLines[0][1]=&p2;
-	inputLines[1][0]=&p3;
-	inputLines[1][1]=&p4;
-	result=computeIntersect(p1,p2,p3,p4);
-	//numIntersects++;
+    inputLines[0][0] = &p1;
+    inputLines[0][1] = &p2;
+    inputLines[1][0] = &p3;
+    inputLines[1][1] = &p4;
+    result = computeIntersect(p1, p2, p3, p4);
+    //numIntersects++;
 }
 
 /*public*/
 string
 LineIntersector::toString() const
 {
-	string str=inputLines[0][0]->toString()+"_"
-			  +inputLines[0][1]->toString()+" "
-			  +inputLines[1][0]->toString()+"_"
-			  +inputLines[1][1]->toString()+" : ";
-	if (isEndPoint()) {
-		str+=" endpoint";
-	}
-	if (isProperVar) {
-		str+=" proper";
-	}
-	if (isCollinear()) {
-		str+=" collinear";
-	}
-	return str;
+    string str = inputLines[0][0]->toString() + "_"
+                 + inputLines[0][1]->toString() + " "
+                 + inputLines[1][0]->toString() + "_"
+                 + inputLines[1][1]->toString() + " : ";
+    if(isEndPoint()) {
+        str += " endpoint";
+    }
+    if(isProperVar) {
+        str += " proper";
+    }
+    if(isCollinear()) {
+        str += " collinear";
+    }
+    return str;
 }
 
 /*public static*/
 bool
-LineIntersector::isSameSignAndNonZero(double a,double b)
+LineIntersector::isSameSignAndNonZero(double a, double b)
 {
-	if (a==0 || b==0) {
-		return false;
-	}
-	return (a<0 && b<0) || (a>0 && b>0);
+    if(a == 0 || b == 0) {
+        return false;
+    }
+    return (a < 0 && b < 0) || (a > 0 && b > 0);
 }
 
 /*private*/
 void
-LineIntersector::computeIntLineIndex() {
-	computeIntLineIndex(0);
-	computeIntLineIndex(1);
+LineIntersector::computeIntLineIndex()
+{
+    computeIntLineIndex(0);
+    computeIntLineIndex(1);
 }
 
 /*public*/
 bool
 LineIntersector::isIntersection(const Coordinate& pt) const
 {
-	for (size_t i=0; i < result; ++i) {
-		if (intPt[i].equals2D(pt)) {
-			return true;
-		}
-	}
-	return false;
+    for(size_t i = 0; i < result; ++i) {
+        if(intPt[i].equals2D(pt)) {
+            return true;
+        }
+    }
+    return false;
 }
 
 /*public*/
 const Coordinate&
-LineIntersector::getIntersectionAlongSegment(int segmentIndex,int intIndex)
+LineIntersector::getIntersectionAlongSegment(int segmentIndex, int intIndex)
 {
-	// lazily compute int line array
-	computeIntLineIndex();
-	return intPt[intLineIndex[segmentIndex][intIndex]];
+    // lazily compute int line array
+    computeIntLineIndex();
+    return intPt[intLineIndex[segmentIndex][intIndex]];
 }
 
 /*public*/
 int
-LineIntersector::getIndexAlongSegment(int segmentIndex,int intIndex)
+LineIntersector::getIndexAlongSegment(int segmentIndex, int intIndex)
 {
-	computeIntLineIndex();
-	return intLineIndex[segmentIndex][intIndex];
+    computeIntLineIndex();
+    return intLineIndex[segmentIndex][intIndex];
 }
 
 /*private*/
 void
 LineIntersector::computeIntLineIndex(int segmentIndex)
 {
-	double dist0=getEdgeDistance(segmentIndex,0);
-	double dist1=getEdgeDistance(segmentIndex,1);
-	if (dist0>dist1) {
-		intLineIndex[segmentIndex][0]=0;
-		intLineIndex[segmentIndex][1]=1;
-	} else {
-		intLineIndex[segmentIndex][0]=1;
-		intLineIndex[segmentIndex][1]=0;
-	}
+    double dist0 = getEdgeDistance(segmentIndex, 0);
+    double dist1 = getEdgeDistance(segmentIndex, 1);
+    if(dist0 > dist1) {
+        intLineIndex[segmentIndex][0] = 0;
+        intLineIndex[segmentIndex][1] = 1;
+    }
+    else {
+        intLineIndex[segmentIndex][0] = 1;
+        intLineIndex[segmentIndex][1] = 0;
+    }
 }
 
 /*public*/
 double
-LineIntersector::getEdgeDistance(size_t segmentIndex,size_t intIndex) const
+LineIntersector::getEdgeDistance(size_t segmentIndex, size_t intIndex) const
 {
-	double dist=computeEdgeDistance(intPt[intIndex],
-		*inputLines[segmentIndex][0],
-		*inputLines[segmentIndex][1]);
-	return dist;
+    double dist = computeEdgeDistance(intPt[intIndex],
+                                      *inputLines[segmentIndex][0],
+                                      *inputLines[segmentIndex][1]);
+    return dist;
 }
 
 /*public*/
 bool
 LineIntersector::isInteriorIntersection()
 {
-	if (isInteriorIntersection(0)) return true;
-	if (isInteriorIntersection(1)) return true;
-	return false;
+    if(isInteriorIntersection(0)) {
+        return true;
+    }
+    if(isInteriorIntersection(1)) {
+        return true;
+    }
+    return false;
 }
 
 /*public*/
 bool
 LineIntersector::isInteriorIntersection(int inputLineIndex)
 {
-	for (size_t i = 0; i < result; ++i)
-	{
-		if (!(intPt[i].equals2D(*inputLines[inputLineIndex][0])
-            		|| intPt[i].equals2D(*inputLines[inputLineIndex][1])))
-	    	{
-			return true;
-		}
-	}
-	return false;
+    for(size_t i = 0; i < result; ++i) {
+        if(!(intPt[i].equals2D(*inputLines[inputLineIndex][0])
+                || intPt[i].equals2D(*inputLines[inputLineIndex][1]))) {
+            return true;
+        }
+    }
+    return false;
 }
 
 /*public static*/
 double
-LineIntersector::interpolateZ(const Coordinate &p,
-	const Coordinate &p1, const Coordinate &p2)
+LineIntersector::interpolateZ(const Coordinate& p,
+                              const Coordinate& p1, const Coordinate& p2)
 {
 #if GEOS_DEBUG
-	cerr<<"LineIntersector::interpolateZ("<<p.toString()<<", "<<p1.toString()<<", "<<p2.toString()<<")"<<endl;
+    cerr << "LineIntersector::interpolateZ(" << p.toString() << ", " << p1.toString() << ", " << p2.toString() << ")" <<
+         endl;
 #endif
 
-	if ( std::isnan(p1.z) )
-	{
+    if(std::isnan(p1.z)) {
 #if GEOS_DEBUG
-		cerr<<" p1 do not have a Z"<<endl;
+        cerr << " p1 do not have a Z" << endl;
 #endif
-		return p2.z; // might be DoubleNotANumber again
-	}
+        return p2.z; // might be DoubleNotANumber again
+    }
 
-	if ( std::isnan(p2.z) )
-	{
+    if(std::isnan(p2.z)) {
 #if GEOS_DEBUG
-		cerr<<" p2 do not have a Z"<<endl;
+        cerr << " p2 do not have a Z" << endl;
 #endif
-		return p1.z; // might be DoubleNotANumber again
-	}
+        return p1.z; // might be DoubleNotANumber again
+    }
 
-	if (p==p1)
-	{
+    if(p == p1) {
 #if GEOS_DEBUG
-		cerr<<" p==p1, returning "<<p1.z<<endl;
+        cerr << " p==p1, returning " << p1.z << endl;
 #endif
-		return p1.z;
-	}
-	if (p==p2)
-	{
+        return p1.z;
+    }
+    if(p == p2) {
 #if GEOS_DEBUG
-		cerr<<" p==p2, returning "<<p2.z<<endl;
+        cerr << " p==p2, returning " << p2.z << endl;
 #endif
-		return p2.z;
-	}
+        return p2.z;
+    }
 
-	//double zgap = fabs(p2.z - p1.z);
-	double zgap = p2.z - p1.z;
-	if ( ! zgap )
-	{
+    //double zgap = fabs(p2.z - p1.z);
+    double zgap = p2.z - p1.z;
+    if(! zgap) {
 #if GEOS_DEBUG
-		cerr<<" no zgap, returning "<<p2.z<<endl;
-#endif
-		return p2.z;
-	}
-	double xoff = (p2.x-p1.x);
-	double yoff = (p2.y-p1.y);
-	double seglen = (xoff*xoff+yoff*yoff);
-	xoff = (p.x-p1.x);
-	yoff = (p.y-p1.y);
-	double pdist = (xoff*xoff+yoff*yoff);
-	double fract = sqrt(pdist/seglen);
-	double zoff = zgap*fract;
-	//double interpolated = p1.z < p2.z ? p1.z+zoff : p1.z-zoff;
-	double interpolated = p1.z+zoff;
+        cerr << " no zgap, returning " << p2.z << endl;
+#endif
+        return p2.z;
+    }
+    double xoff = (p2.x - p1.x);
+    double yoff = (p2.y - p1.y);
+    double seglen = (xoff * xoff + yoff * yoff);
+    xoff = (p.x - p1.x);
+    yoff = (p.y - p1.y);
+    double pdist = (xoff * xoff + yoff * yoff);
+    double fract = sqrt(pdist / seglen);
+    double zoff = zgap * fract;
+    //double interpolated = p1.z < p2.z ? p1.z+zoff : p1.z-zoff;
+    double interpolated = p1.z + zoff;
 #if GEOS_DEBUG
-	cerr<<" zgap:"<<zgap<<" seglen:"<<seglen<<" pdist:"<<pdist
-		<<" fract:"<<fract<<" z:"<<interpolated<<endl;
+    cerr << " zgap:" << zgap << " seglen:" << seglen << " pdist:" << pdist
+         << " fract:" << fract << " z:" << interpolated << endl;
 #endif
-	return interpolated;
+    return interpolated;
 
 }
 
 
 /*public*/
 void
-LineIntersector::computeIntersection(const Coordinate& p,const Coordinate& p1,const Coordinate& p2)
+LineIntersector::computeIntersection(const Coordinate& p, const Coordinate& p1, const Coordinate& p2)
 {
-	isProperVar=false;
-
-	// do between check first, since it is faster than the orientation test
-	if(Envelope::intersects(p1,p2,p)) {
-		if ((Orientation::index(p1,p2,p)==0)&&
-			(Orientation::index(p2,p1,p)==0)) {
-			isProperVar=true;
-			if ((p==p1)||(p==p2)) // 2d only test
-			{
-				isProperVar=false;
-			}
+    isProperVar = false;
+
+    // do between check first, since it is faster than the orientation test
+    if(Envelope::intersects(p1, p2, p)) {
+        if((Orientation::index(p1, p2, p) == 0) &&
+                (Orientation::index(p2, p1, p) == 0)) {
+            isProperVar = true;
+            if((p == p1) || (p == p2)) { // 2d only test
+                isProperVar = false;
+            }
 #if COMPUTE_Z
-			intPt[0]=p;
+            intPt[0] = p;
 #if GEOS_DEBUG
-			cerr<<"RobustIntersector::computeIntersection(Coordinate,Coordinate,Coordinate) calling interpolateZ"<<endl;
-#endif
-			double z = interpolateZ(p, p1, p2);
-			if ( !std::isnan(z) )
-			{
-				if ( std::isnan(intPt[0].z) )
-					intPt[0].z = z;
-				else
-					intPt[0].z = (intPt[0].z+z)/2;
-			}
+            cerr << "RobustIntersector::computeIntersection(Coordinate,Coordinate,Coordinate) calling interpolateZ" << endl;
+#endif
+            double z = interpolateZ(p, p1, p2);
+            if(!std::isnan(z)) {
+                if(std::isnan(intPt[0].z)) {
+                    intPt[0].z = z;
+                }
+                else {
+                    intPt[0].z = (intPt[0].z + z) / 2;
+                }
+            }
 #endif // COMPUTE_Z
-			result=POINT_INTERSECTION;
-			return;
-		}
-	}
-	result = NO_INTERSECTION;
+            result = POINT_INTERSECTION;
+            return;
+        }
+    }
+    result = NO_INTERSECTION;
 }
 
 /* public static */
 bool
 LineIntersector::hasIntersection(const Coordinate& p, const Coordinate& p1, const Coordinate& p2)
 {
-	if(Envelope::intersects(p1,p2,p)) {
-		if ((Orientation::index(p1,p2,p)==0)&&
-			(Orientation::index(p2,p1,p)==0)) {
-			return true;
-		}
-	}
-	return false;
+    if(Envelope::intersects(p1, p2, p)) {
+        if((Orientation::index(p1, p2, p) == 0) &&
+                (Orientation::index(p2, p1, p) == 0)) {
+            return true;
+        }
+    }
+    return false;
 }
 
 /*private*/
 int
-LineIntersector::computeIntersect(const Coordinate& p1,const Coordinate& p2,const Coordinate& q1,const Coordinate& q2)
+LineIntersector::computeIntersect(const Coordinate& p1, const Coordinate& p2, const Coordinate& q1,
+                                  const Coordinate& q2)
 {
 #if GEOS_DEBUG
-	cerr<<"LineIntersector::computeIntersect called"<<endl;
-	cerr<<" p1:"<<p1.toString()<<" p2:"<<p2.toString()<<" q1:"<<q1.toString()<<" q2:"<<q2.toString()<<endl;
+    cerr << "LineIntersector::computeIntersect called" << endl;
+    cerr << " p1:" << p1.toString() << " p2:" << p2.toString() << " q1:" << q1.toString() << " q2:" << q2.toString() <<
+         endl;
 #endif // GEOS_DEBUG
 
-	isProperVar=false;
+    isProperVar = false;
 
-	// first try a fast test to see if the envelopes of the lines intersect
-	if (!Envelope::intersects(p1,p2,q1,q2))
-	{
+    // first try a fast test to see if the envelopes of the lines intersect
+    if(!Envelope::intersects(p1, p2, q1, q2)) {
 #if GEOS_DEBUG
-		cerr<<" NO_INTERSECTION"<<endl;
+        cerr << " NO_INTERSECTION" << endl;
 #endif
-		return NO_INTERSECTION;
-	}
+        return NO_INTERSECTION;
+    }
 
-	// for each endpoint, compute which side of the other segment it lies
-	// if both endpoints lie on the same side of the other segment,
-	// the segments do not intersect
-	int Pq1=Orientation::index(p1,p2,q1);
-	int Pq2=Orientation::index(p1,p2,q2);
+    // for each endpoint, compute which side of the other segment it lies
+    // if both endpoints lie on the same side of the other segment,
+    // the segments do not intersect
+    int Pq1 = Orientation::index(p1, p2, q1);
+    int Pq2 = Orientation::index(p1, p2, q2);
 
-	if ((Pq1>0 && Pq2>0) || (Pq1<0 && Pq2<0))
-	{
+    if((Pq1 > 0 && Pq2 > 0) || (Pq1 < 0 && Pq2 < 0)) {
 #if GEOS_DEBUG
-		cerr<<" NO_INTERSECTION"<<endl;
+        cerr << " NO_INTERSECTION" << endl;
 #endif
-		return NO_INTERSECTION;
-	}
+        return NO_INTERSECTION;
+    }
 
-	int Qp1=Orientation::index(q1,q2,p1);
-	int Qp2=Orientation::index(q1,q2,p2);
+    int Qp1 = Orientation::index(q1, q2, p1);
+    int Qp2 = Orientation::index(q1, q2, p2);
 
-	if ((Qp1>0 && Qp2>0)||(Qp1<0 && Qp2<0)) {
+    if((Qp1 > 0 && Qp2 > 0) || (Qp1 < 0 && Qp2 < 0)) {
 #if GEOS_DEBUG
-		cerr<<" NO_INTERSECTION"<<endl;
+        cerr << " NO_INTERSECTION" << endl;
 #endif
-		return NO_INTERSECTION;
-	}
+        return NO_INTERSECTION;
+    }
 
-	bool collinear=Pq1==0 && Pq2==0 && Qp1==0 && Qp2==0;
-	if (collinear) {
+    bool collinear = Pq1 == 0 && Pq2 == 0 && Qp1 == 0 && Qp2 == 0;
+    if(collinear) {
 #if GEOS_DEBUG
-		cerr<<" computingCollinearIntersection"<<endl;
-#endif
-		return computeCollinearIntersection(p1,p2,q1,q2);
-	}
-
-	/**
-	 * At this point we know that there is a single intersection point
-	 * (since the lines are not collinear).
-	 */
-
-	/*
-	 * Check if the intersection is an endpoint.
-	 * If it is, copy the endpoint as
-	 * the intersection point. Copying the point rather than
-	 * computing it ensures the point has the exact value,
-	 * which is important for robustness. It is sufficient to
-	 * simply check for an endpoint which is on the other line,
-	 * since at this point we know that the inputLines must
-	 *  intersect.
-	 */
-	if (Pq1==0 || Pq2==0 || Qp1==0 || Qp2==0) {
+        cerr << " computingCollinearIntersection" << endl;
+#endif
+        return computeCollinearIntersection(p1, p2, q1, q2);
+    }
+
+    /**
+     * At this point we know that there is a single intersection point
+     * (since the lines are not collinear).
+     */
+
+    /*
+     * Check if the intersection is an endpoint.
+     * If it is, copy the endpoint as
+     * the intersection point. Copying the point rather than
+     * computing it ensures the point has the exact value,
+     * which is important for robustness. It is sufficient to
+     * simply check for an endpoint which is on the other line,
+     * since at this point we know that the inputLines must
+     *  intersect.
+     */
+    if(Pq1 == 0 || Pq2 == 0 || Qp1 == 0 || Qp2 == 0) {
 #if COMPUTE_Z
-		int hits=0;
-		double z=0.0;
-#endif
-		isProperVar=false;
-
-		/* Check for two equal endpoints.
-		 * This is done explicitly rather than by the orientation tests
-		 * below in order to improve robustness.
-		 *
-		 * (A example where the orientation tests fail
-		 *  to be consistent is:
-		 *
-		 * LINESTRING ( 19.850257749638203 46.29709338043669,
-		 * 			20.31970698357233 46.76654261437082 )
-		 * and
-		 * LINESTRING ( -48.51001596420236 -22.063180333403878,
-		 * 			19.850257749638203 46.29709338043669 )
-		 *
-		 * which used to produce the result:
-		 * (20.31970698357233, 46.76654261437082, NaN)
-		 */
-
-		if ( p1.equals2D(q1) || p1.equals2D(q2) ) {
-			intPt[0]=p1;
+        int hits = 0;
+        double z = 0.0;
+#endif
+        isProperVar = false;
+
+        /* Check for two equal endpoints.
+         * This is done explicitly rather than by the orientation tests
+         * below in order to improve robustness.
+         *
+         * (A example where the orientation tests fail
+         *  to be consistent is:
+         *
+         * LINESTRING ( 19.850257749638203 46.29709338043669,
+         * 			20.31970698357233 46.76654261437082 )
+         * and
+         * LINESTRING ( -48.51001596420236 -22.063180333403878,
+         * 			19.850257749638203 46.29709338043669 )
+         *
+         * which used to produce the result:
+         * (20.31970698357233, 46.76654261437082, NaN)
+         */
+
+        if(p1.equals2D(q1) || p1.equals2D(q2)) {
+            intPt[0] = p1;
 #if COMPUTE_Z
-			if ( !std::isnan(p1.z) )
-			{
-				z += p1.z;
-				hits++;
-			}
-#endif
-		}
-		else if ( p2.equals2D(q1) || p2.equals2D(q2) ) {
-			intPt[0]=p2;
+            if(!std::isnan(p1.z)) {
+                z += p1.z;
+                hits++;
+            }
+#endif
+        }
+        else if(p2.equals2D(q1) || p2.equals2D(q2)) {
+            intPt[0] = p2;
 #if COMPUTE_Z
-			if ( !std::isnan(p2.z) )
-			{
-				z += p2.z;
-				hits++;
-			}
-#endif
-		}
-
-		/**
-		 * Now check to see if any endpoint lies on the interior of the other segment.
-		 */
-		else if (Pq1==0) {
-			intPt[0]=q1;
+            if(!std::isnan(p2.z)) {
+                z += p2.z;
+                hits++;
+            }
+#endif
+        }
+
+        /**
+         * Now check to see if any endpoint lies on the interior of the other segment.
+         */
+        else if(Pq1 == 0) {
+            intPt[0] = q1;
 #if COMPUTE_Z
-			if ( !std::isnan(q1.z) )
-			{
-				z += q1.z;
-				hits++;
-			}
-#endif
-		}
-		else if (Pq2==0) {
-			intPt[0]=q2;
+            if(!std::isnan(q1.z)) {
+                z += q1.z;
+                hits++;
+            }
+#endif
+        }
+        else if(Pq2 == 0) {
+            intPt[0] = q2;
 #if COMPUTE_Z
-			if ( !std::isnan(q2.z) )
-			{
-				z += q2.z;
-				hits++;
-			}
-#endif
-		}
-		else if (Qp1==0) {
-			intPt[0]=p1;
+            if(!std::isnan(q2.z)) {
+                z += q2.z;
+                hits++;
+            }
+#endif
+        }
+        else if(Qp1 == 0) {
+            intPt[0] = p1;
 #if COMPUTE_Z
-			if ( !std::isnan(p1.z) )
-			{
-				z += p1.z;
-				hits++;
-			}
-#endif
-		}
-		else if (Qp2==0) {
-			intPt[0]=p2;
+            if(!std::isnan(p1.z)) {
+                z += p1.z;
+                hits++;
+            }
+#endif
+        }
+        else if(Qp2 == 0) {
+            intPt[0] = p2;
 #if COMPUTE_Z
-			if ( !std::isnan(p2.z) )
-			{
-				z += p2.z;
-				hits++;
-			}
+            if(!std::isnan(p2.z)) {
+                z += p2.z;
+                hits++;
+            }
 #endif
-		}
+        }
 #if COMPUTE_Z
 #if GEOS_DEBUG
-		cerr<<"LineIntersector::computeIntersect: z:"<<z<<" hits:"<<hits<<endl;
+        cerr << "LineIntersector::computeIntersect: z:" << z << " hits:" << hits << endl;
 #endif // GEOS_DEBUG
-		if ( hits ) intPt[0].z = z/hits;
+        if(hits) {
+            intPt[0].z = z / hits;
+        }
 #endif // COMPUTE_Z
-	} else {
-		isProperVar=true;
-		intersection(p1, p2, q1, q2, intPt[0]);
-	}
+    }
+    else {
+        isProperVar = true;
+        intersection(p1, p2, q1, q2, intPt[0]);
+    }
 #if GEOS_DEBUG
-	cerr<<" POINT_INTERSECTION; intPt[0]:"<<intPt[0].toString()<<endl;
+    cerr << " POINT_INTERSECTION; intPt[0]:" << intPt[0].toString() << endl;
 #endif // GEOS_DEBUG
-	return POINT_INTERSECTION;
+    return POINT_INTERSECTION;
 }
 
 /*private*/
 int
-LineIntersector::computeCollinearIntersection(const Coordinate& p1,const Coordinate& p2,const Coordinate& q1,const Coordinate& q2)
+LineIntersector::computeCollinearIntersection(const Coordinate& p1, const Coordinate& p2, const Coordinate& q1,
+        const Coordinate& q2)
 {
 #if COMPUTE_Z
-	double ztot;
-	int hits;
-	double p2z;
-	double p1z;
-	double q1z;
-	double q2z;
+    double ztot;
+    int hits;
+    double p2z;
+    double p1z;
+    double q1z;
+    double q2z;
 #endif // COMPUTE_Z
 
 #if GEOS_DEBUG
-	cerr<<"LineIntersector::computeCollinearIntersection called"<<endl;
-	cerr<<" p1:"<<p1.toString()<<" p2:"<<p2.toString()<<" q1:"<<q1.toString()<<" q2:"<<q2.toString()<<endl;
+    cerr << "LineIntersector::computeCollinearIntersection called" << endl;
+    cerr << " p1:" << p1.toString() << " p2:" << p2.toString() << " q1:" << q1.toString() << " q2:" << q2.toString() <<
+         endl;
 #endif // GEOS_DEBUG
 
-	bool p1q1p2=Envelope::intersects(p1,p2,q1);
-	bool p1q2p2=Envelope::intersects(p1,p2,q2);
-	bool q1p1q2=Envelope::intersects(q1,q2,p1);
-	bool q1p2q2=Envelope::intersects(q1,q2,p2);
+    bool p1q1p2 = Envelope::intersects(p1, p2, q1);
+    bool p1q2p2 = Envelope::intersects(p1, p2, q2);
+    bool q1p1q2 = Envelope::intersects(q1, q2, p1);
+    bool q1p2q2 = Envelope::intersects(q1, q2, p2);
 
-	if (p1q1p2 && p1q2p2) {
+    if(p1q1p2 && p1q2p2) {
 #if GEOS_DEBUG
-		cerr<<" p1q1p2 && p1q2p2"<<endl;
+        cerr << " p1q1p2 && p1q2p2" << endl;
 #endif
-		intPt[0]=q1;
+        intPt[0] = q1;
 #if COMPUTE_Z
-		ztot=0;
-		hits=0;
-		q1z = interpolateZ(q1, p1, p2);
-		if (!std::isnan(q1z)) { ztot+=q1z; hits++; }
-		if (!std::isnan(q1.z)) { ztot+=q1.z; hits++; }
-		if ( hits ) intPt[0].z = ztot/hits;
-#endif
-		intPt[1]=q2;
+        ztot = 0;
+        hits = 0;
+        q1z = interpolateZ(q1, p1, p2);
+        if(!std::isnan(q1z)) {
+            ztot += q1z;
+            hits++;
+        }
+        if(!std::isnan(q1.z)) {
+            ztot += q1.z;
+            hits++;
+        }
+        if(hits) {
+            intPt[0].z = ztot / hits;
+        }
+#endif
+        intPt[1] = q2;
 #if COMPUTE_Z
-		ztot=0;
-		hits=0;
-		q2z = interpolateZ(q2, p1, p2);
-		if (!std::isnan(q2z)) { ztot+=q2z; hits++; }
-		if (!std::isnan(q2.z)) { ztot+=q2.z; hits++; }
-		if ( hits ) intPt[1].z = ztot/hits;
+        ztot = 0;
+        hits = 0;
+        q2z = interpolateZ(q2, p1, p2);
+        if(!std::isnan(q2z)) {
+            ztot += q2z;
+            hits++;
+        }
+        if(!std::isnan(q2.z)) {
+            ztot += q2.z;
+            hits++;
+        }
+        if(hits) {
+            intPt[1].z = ztot / hits;
+        }
 #endif
 #if GEOS_DEBUG
-		cerr<<" intPt[0]: "<<intPt[0].toString()<<endl;
-		cerr<<" intPt[1]: "<<intPt[1].toString()<<endl;
+        cerr << " intPt[0]: " << intPt[0].toString() << endl;
+        cerr << " intPt[1]: " << intPt[1].toString() << endl;
 #endif
-		return COLLINEAR_INTERSECTION;
-	}
-	if (q1p1q2 && q1p2q2) {
+        return COLLINEAR_INTERSECTION;
+    }
+    if(q1p1q2 && q1p2q2) {
 #if GEOS_DEBUG
-		cerr<<" q1p1q2 && q1p2q2"<<endl;
+        cerr << " q1p1q2 && q1p2q2" << endl;
 #endif
-		intPt[0]=p1;
+        intPt[0] = p1;
 #if COMPUTE_Z
-		ztot=0;
-		hits=0;
-		p1z = interpolateZ(p1, q1, q2);
-		if (!std::isnan(p1z)) { ztot+=p1z; hits++; }
-		if (!std::isnan(p1.z)) { ztot+=p1.z; hits++; }
-		if ( hits ) intPt[0].z = ztot/hits;
-#endif
-		intPt[1]=p2;
+        ztot = 0;
+        hits = 0;
+        p1z = interpolateZ(p1, q1, q2);
+        if(!std::isnan(p1z)) {
+            ztot += p1z;
+            hits++;
+        }
+        if(!std::isnan(p1.z)) {
+            ztot += p1.z;
+            hits++;
+        }
+        if(hits) {
+            intPt[0].z = ztot / hits;
+        }
+#endif
+        intPt[1] = p2;
 #if COMPUTE_Z
-		ztot=0;
-		hits=0;
-		p2z = interpolateZ(p2, q1, q2);
-		if (!std::isnan(p2z)) { ztot+=p2z; hits++; }
-		if (!std::isnan(p2.z)) { ztot+=p2.z; hits++; }
-		if ( hits ) intPt[1].z = ztot/hits;
-#endif
-		return COLLINEAR_INTERSECTION;
-	}
-	if (p1q1p2 && q1p1q2) {
+        ztot = 0;
+        hits = 0;
+        p2z = interpolateZ(p2, q1, q2);
+        if(!std::isnan(p2z)) {
+            ztot += p2z;
+            hits++;
+        }
+        if(!std::isnan(p2.z)) {
+            ztot += p2.z;
+            hits++;
+        }
+        if(hits) {
+            intPt[1].z = ztot / hits;
+        }
+#endif
+        return COLLINEAR_INTERSECTION;
+    }
+    if(p1q1p2 && q1p1q2) {
 #if GEOS_DEBUG
-		cerr<<" p1q1p2 && q1p1q2"<<endl;
+        cerr << " p1q1p2 && q1p1q2" << endl;
 #endif
-		intPt[0]=q1;
+        intPt[0] = q1;
 #if COMPUTE_Z
-		ztot=0;
-		hits=0;
-		q1z = interpolateZ(q1, p1, p2);
-		if (!std::isnan(q1z)) { ztot+=q1z; hits++; }
-		if (!std::isnan(q1.z)) { ztot+=q1.z; hits++; }
-		if ( hits ) intPt[0].z = ztot/hits;
-#endif
-		intPt[1]=p1;
+        ztot = 0;
+        hits = 0;
+        q1z = interpolateZ(q1, p1, p2);
+        if(!std::isnan(q1z)) {
+            ztot += q1z;
+            hits++;
+        }
+        if(!std::isnan(q1.z)) {
+            ztot += q1.z;
+            hits++;
+        }
+        if(hits) {
+            intPt[0].z = ztot / hits;
+        }
+#endif
+        intPt[1] = p1;
 #if COMPUTE_Z
-		ztot=0;
-		hits=0;
-		p1z = interpolateZ(p1, q1, q2);
-		if (!std::isnan(p1z)) { ztot+=p1z; hits++; }
-		if (!std::isnan(p1.z)) { ztot+=p1.z; hits++; }
-		if ( hits ) intPt[1].z = ztot/hits;
+        ztot = 0;
+        hits = 0;
+        p1z = interpolateZ(p1, q1, q2);
+        if(!std::isnan(p1z)) {
+            ztot += p1z;
+            hits++;
+        }
+        if(!std::isnan(p1.z)) {
+            ztot += p1.z;
+            hits++;
+        }
+        if(hits) {
+            intPt[1].z = ztot / hits;
+        }
 #endif
 #if GEOS_DEBUG
-		cerr<<" intPt[0]: "<<intPt[0].toString()<<endl;
-		cerr<<" intPt[1]: "<<intPt[1].toString()<<endl;
+        cerr << " intPt[0]: " << intPt[0].toString() << endl;
+        cerr << " intPt[1]: " << intPt[1].toString() << endl;
 #endif
-		return (q1==p1) && !p1q2p2 && !q1p2q2 ? POINT_INTERSECTION : COLLINEAR_INTERSECTION;
-	}
-	if (p1q1p2 && q1p2q2) {
+        return (q1 == p1) && !p1q2p2 && !q1p2q2 ? POINT_INTERSECTION : COLLINEAR_INTERSECTION;
+    }
+    if(p1q1p2 && q1p2q2) {
 #if GEOS_DEBUG
-		cerr<<" p1q1p2 && q1p2q2"<<endl;
+        cerr << " p1q1p2 && q1p2q2" << endl;
 #endif
-		intPt[0]=q1;
+        intPt[0] = q1;
 #if COMPUTE_Z
-		ztot=0;
-		hits=0;
-		q1z = interpolateZ(q1, p1, p2);
-		if (!std::isnan(q1z)) { ztot+=q1z; hits++; }
-		if (!std::isnan(q1.z)) { ztot+=q1.z; hits++; }
-		if ( hits ) intPt[0].z = ztot/hits;
-#endif
-		intPt[1]=p2;
+        ztot = 0;
+        hits = 0;
+        q1z = interpolateZ(q1, p1, p2);
+        if(!std::isnan(q1z)) {
+            ztot += q1z;
+            hits++;
+        }
+        if(!std::isnan(q1.z)) {
+            ztot += q1.z;
+            hits++;
+        }
+        if(hits) {
+            intPt[0].z = ztot / hits;
+        }
+#endif
+        intPt[1] = p2;
 #if COMPUTE_Z
-		ztot=0;
-		hits=0;
-		p2z = interpolateZ(p2, q1, q2);
-		if (!std::isnan(p2z)) { ztot+=p2z; hits++; }
-		if (!std::isnan(p2.z)) { ztot+=p2.z; hits++; }
-		if ( hits ) intPt[1].z = ztot/hits;
+        ztot = 0;
+        hits = 0;
+        p2z = interpolateZ(p2, q1, q2);
+        if(!std::isnan(p2z)) {
+            ztot += p2z;
+            hits++;
+        }
+        if(!std::isnan(p2.z)) {
+            ztot += p2.z;
+            hits++;
+        }
+        if(hits) {
+            intPt[1].z = ztot / hits;
+        }
 #endif
 #if GEOS_DEBUG
-		cerr<<" intPt[0]: "<<intPt[0].toString()<<endl;
-		cerr<<" intPt[1]: "<<intPt[1].toString()<<endl;
+        cerr << " intPt[0]: " << intPt[0].toString() << endl;
+        cerr << " intPt[1]: " << intPt[1].toString() << endl;
 #endif
-		return (q1==p2) && !p1q2p2 && !q1p1q2 ? POINT_INTERSECTION : COLLINEAR_INTERSECTION;
-	}
-	if (p1q2p2 && q1p1q2) {
+        return (q1 == p2) && !p1q2p2 && !q1p1q2 ? POINT_INTERSECTION : COLLINEAR_INTERSECTION;
+    }
+    if(p1q2p2 && q1p1q2) {
 #if GEOS_DEBUG
-		cerr<<" p1q2p2 && q1p1q2"<<endl;
+        cerr << " p1q2p2 && q1p1q2" << endl;
 #endif
-		intPt[0]=q2;
+        intPt[0] = q2;
 #if COMPUTE_Z
-		ztot=0;
-		hits=0;
-		q2z = interpolateZ(q2, p1, p2);
-		if (!std::isnan(q2z)) { ztot+=q2z; hits++; }
-		if (!std::isnan(q2.z)) { ztot+=q2.z; hits++; }
-		if ( hits ) intPt[0].z = ztot/hits;
-#endif
-		intPt[1]=p1;
+        ztot = 0;
+        hits = 0;
+        q2z = interpolateZ(q2, p1, p2);
+        if(!std::isnan(q2z)) {
+            ztot += q2z;
+            hits++;
+        }
+        if(!std::isnan(q2.z)) {
+            ztot += q2.z;
+            hits++;
+        }
+        if(hits) {
+            intPt[0].z = ztot / hits;
+        }
+#endif
+        intPt[1] = p1;
 #if COMPUTE_Z
-		ztot=0;
-		hits=0;
-		p1z = interpolateZ(p1, q1, q2);
-		if (!std::isnan(p1z)) { ztot+=p1z; hits++; }
-		if (!std::isnan(p1.z)) { ztot+=p1.z; hits++; }
-		if ( hits ) intPt[1].z = ztot/hits;
+        ztot = 0;
+        hits = 0;
+        p1z = interpolateZ(p1, q1, q2);
+        if(!std::isnan(p1z)) {
+            ztot += p1z;
+            hits++;
+        }
+        if(!std::isnan(p1.z)) {
+            ztot += p1.z;
+            hits++;
+        }
+        if(hits) {
+            intPt[1].z = ztot / hits;
+        }
 #endif
 #if GEOS_DEBUG
-		cerr<<" intPt[0]: "<<intPt[0].toString()<<endl;
-		cerr<<" intPt[1]: "<<intPt[1].toString()<<endl;
+        cerr << " intPt[0]: " << intPt[0].toString() << endl;
+        cerr << " intPt[1]: " << intPt[1].toString() << endl;
 #endif
-		return (q2==p1) && !p1q1p2 && !q1p2q2 ? POINT_INTERSECTION : COLLINEAR_INTERSECTION;
-	}
-	if (p1q2p2 && q1p2q2) {
+        return (q2 == p1) && !p1q1p2 && !q1p2q2 ? POINT_INTERSECTION : COLLINEAR_INTERSECTION;
+    }
+    if(p1q2p2 && q1p2q2) {
 #if GEOS_DEBUG
-		cerr<<" p1q2p2 && q1p2q2"<<endl;
+        cerr << " p1q2p2 && q1p2q2" << endl;
 #endif
-		intPt[0]=q2;
+        intPt[0] = q2;
 #if COMPUTE_Z
-		ztot=0;
-		hits=0;
-		q2z = interpolateZ(q2, p1, p2);
-		if (!std::isnan(q2z)) { ztot+=q2z; hits++; }
-		if (!std::isnan(q2.z)) { ztot+=q2.z; hits++; }
-		if ( hits ) intPt[0].z = ztot/hits;
-#endif
-		intPt[1]=p2;
+        ztot = 0;
+        hits = 0;
+        q2z = interpolateZ(q2, p1, p2);
+        if(!std::isnan(q2z)) {
+            ztot += q2z;
+            hits++;
+        }
+        if(!std::isnan(q2.z)) {
+            ztot += q2.z;
+            hits++;
+        }
+        if(hits) {
+            intPt[0].z = ztot / hits;
+        }
+#endif
+        intPt[1] = p2;
 #if COMPUTE_Z
-		ztot=0;
-		hits=0;
-		p2z = interpolateZ(p2, q1, q2);
-		if (!std::isnan(p2z)) { ztot+=p2z; hits++; }
-		if (!std::isnan(p2.z)) { ztot+=p2.z; hits++; }
-		if ( hits ) intPt[1].z = ztot/hits;
+        ztot = 0;
+        hits = 0;
+        p2z = interpolateZ(p2, q1, q2);
+        if(!std::isnan(p2z)) {
+            ztot += p2z;
+            hits++;
+        }
+        if(!std::isnan(p2.z)) {
+            ztot += p2.z;
+            hits++;
+        }
+        if(hits) {
+            intPt[1].z = ztot / hits;
+        }
 #endif
 #if GEOS_DEBUG
-		cerr<<" intPt[0]: "<<intPt[0].toString()<<endl;
-		cerr<<" intPt[1]: "<<intPt[1].toString()<<endl;
+        cerr << " intPt[0]: " << intPt[0].toString() << endl;
+        cerr << " intPt[1]: " << intPt[1].toString() << endl;
 #endif
-		return (q2==p2) && !p1q1p2 && !q1p1q2 ? POINT_INTERSECTION : COLLINEAR_INTERSECTION;
-	}
-	return NO_INTERSECTION;
+        return (q2 == p2) && !p1q1p2 && !q1p1q2 ? POINT_INTERSECTION : COLLINEAR_INTERSECTION;
+    }
+    return NO_INTERSECTION;
 }
 
 /*private*/
 void
 LineIntersector::intersection(const Coordinate& p1,
-	const Coordinate& p2, const Coordinate& q1, const Coordinate& q2,
-	Coordinate &intPtOut) const
+                              const Coordinate& p2, const Coordinate& q1, const Coordinate& q2,
+                              Coordinate& intPtOut) const
 {
 
-	intersectionWithNormalization(p1, p2, q1, q2, intPtOut);
-
-	/*
-	 * Due to rounding it can happen that the computed intersection is
-	 * outside the envelopes of the input segments.  Clearly this
-	 * is inconsistent.
-	 * This code checks this condition and forces a more reasonable answer
-	 *
-	 * MD - May 4 2005 - This is still a problem.  Here is a failure case:
-	 *
-	 * LINESTRING (2089426.5233462777 1180182.3877339689,
-	 *             2085646.6891757075 1195618.7333999649)
-	 * LINESTRING (1889281.8148903656 1997547.0560044837,
-	 *             2259977.3672235999 483675.17050843034)
-	 * int point = (2097408.2633752143,1144595.8008114607)
-	 */
-
-	if (! isInSegmentEnvelopes(intPtOut))
-	{
-		//intPt = CentralEndpointIntersector::getIntersection(p1, p2, q1, q2);
-	  intPtOut = nearestEndpoint(p1, p2, q1, q2);
+    intersectionWithNormalization(p1, p2, q1, q2, intPtOut);
+
+    /*
+     * Due to rounding it can happen that the computed intersection is
+     * outside the envelopes of the input segments.  Clearly this
+     * is inconsistent.
+     * This code checks this condition and forces a more reasonable answer
+     *
+     * MD - May 4 2005 - This is still a problem.  Here is a failure case:
+     *
+     * LINESTRING (2089426.5233462777 1180182.3877339689,
+     *             2085646.6891757075 1195618.7333999649)
+     * LINESTRING (1889281.8148903656 1997547.0560044837,
+     *             2259977.3672235999 483675.17050843034)
+     * int point = (2097408.2633752143,1144595.8008114607)
+     */
+
+    if(! isInSegmentEnvelopes(intPtOut)) {
+        //intPt = CentralEndpointIntersector::getIntersection(p1, p2, q1, q2);
+        intPtOut = nearestEndpoint(p1, p2, q1, q2);
 #if GEOS_DEBUG
-		cerr << "Intersection outside segment envelopes, snapped to "
-		     << intPt.toString() << endl;
+        cerr << "Intersection outside segment envelopes, snapped to "
+             << intPt.toString() << endl;
 #endif
-	}
+    }
 
-	if (precisionModel!=nullptr) {
-		precisionModel->makePrecise(intPtOut);
-	}
+    if(precisionModel != nullptr) {
+        precisionModel->makePrecise(intPtOut);
+    }
 
 
 #if COMPUTE_Z
-	double ztot = 0;
-	double zvals = 0;
-	double zp = interpolateZ(intPtOut, p1, p2);
-	double zq = interpolateZ(intPtOut, q1, q2);
-	if ( !std::isnan(zp)) { ztot += zp; zvals++; }
-	if ( !std::isnan(zq)) { ztot += zq; zvals++; }
-	if ( zvals ) intPtOut.z = ztot/zvals;
+    double ztot = 0;
+    double zvals = 0;
+    double zp = interpolateZ(intPtOut, p1, p2);
+    double zq = interpolateZ(intPtOut, q1, q2);
+    if(!std::isnan(zp)) {
+        ztot += zp;
+        zvals++;
+    }
+    if(!std::isnan(zq)) {
+        ztot += zq;
+        zvals++;
+    }
+    if(zvals) {
+        intPtOut.z = ztot / zvals;
+    }
 #endif // COMPUTE_Z
 
 }
@@ -790,121 +900,128 @@ LineIntersector::intersection(const Coordinate& p1,
 /*private*/
 void
 LineIntersector::intersectionWithNormalization(const Coordinate& p1,
-	const Coordinate& p2, const Coordinate& q1, const Coordinate& q2,
-	Coordinate &intPtOut) const
+        const Coordinate& p2, const Coordinate& q1, const Coordinate& q2,
+        Coordinate& intPtOut) const
 {
-	Coordinate n1=p1;
-	Coordinate n2=p2;
-	Coordinate n3=q1;
-	Coordinate n4=q2;
-	Coordinate normPt;
-	normalizeToEnvCentre(n1, n2, n3, n4, normPt);
+    Coordinate n1 = p1;
+    Coordinate n2 = p2;
+    Coordinate n3 = q1;
+    Coordinate n4 = q2;
+    Coordinate normPt;
+    normalizeToEnvCentre(n1, n2, n3, n4, normPt);
 
-	safeHCoordinateIntersection(n1, n2, n3, n4, intPtOut);
+    safeHCoordinateIntersection(n1, n2, n3, n4, intPtOut);
 
-	intPtOut.x += normPt.x;
-	intPtOut.y += normPt.y;
+    intPtOut.x += normPt.x;
+    intPtOut.y += normPt.y;
 }
 
 
 /*private*/
 double
-LineIntersector::smallestInAbsValue(double x1,double x2,double x3,double x4) const
+LineIntersector::smallestInAbsValue(double x1, double x2, double x3, double x4) const
 {
-	double x=x1;
-	double xabs=fabs(x);
-	if(fabs(x2)<xabs) {
-		x=x2;
-		xabs=fabs(x2);
-	}
-	if(fabs(x3)<xabs) {
-		x=x3;
-		xabs=fabs(x3);
-	}
-	if(fabs(x4)<xabs) {
-		x=x4;
-	}
-	return x;
+    double x = x1;
+    double xabs = fabs(x);
+    if(fabs(x2) < xabs) {
+        x = x2;
+        xabs = fabs(x2);
+    }
+    if(fabs(x3) < xabs) {
+        x = x3;
+        xabs = fabs(x3);
+    }
+    if(fabs(x4) < xabs) {
+        x = x4;
+    }
+    return x;
 }
 
 /*private*/
 bool
 LineIntersector::isInSegmentEnvelopes(const Coordinate& pt) const
 {
-	Envelope env0(*inputLines[0][0], *inputLines[0][1]);
-	Envelope env1(*inputLines[1][0], *inputLines[1][1]);
-	return env0.contains(pt) && env1.contains(pt);
+    Envelope env0(*inputLines[0][0], *inputLines[0][1]);
+    Envelope env1(*inputLines[1][0], *inputLines[1][1]);
+    return env0.contains(pt) && env1.contains(pt);
 }
 
 /*private*/
 void
-LineIntersector::normalizeToEnvCentre(Coordinate &n00, Coordinate &n01,
-		Coordinate &n10, Coordinate &n11, Coordinate &normPt) const
+LineIntersector::normalizeToEnvCentre(Coordinate& n00, Coordinate& n01,
+                                      Coordinate& n10, Coordinate& n11, Coordinate& normPt) const
 {
-	double minX0 = n00.x < n01.x ? n00.x : n01.x;
-	double minY0 = n00.y < n01.y ? n00.y : n01.y;
-	double maxX0 = n00.x > n01.x ? n00.x : n01.x;
-	double maxY0 = n00.y > n01.y ? n00.y : n01.y;
-
-	double minX1 = n10.x < n11.x ? n10.x : n11.x;
-	double minY1 = n10.y < n11.y ? n10.y : n11.y;
-	double maxX1 = n10.x > n11.x ? n10.x : n11.x;
-	double maxY1 = n10.y > n11.y ? n10.y : n11.y;
-
-	double intMinX = minX0 > minX1 ? minX0 : minX1;
-	double intMaxX = maxX0 < maxX1 ? maxX0 : maxX1;
-	double intMinY = minY0 > minY1 ? minY0 : minY1;
-	double intMaxY = maxY0 < maxY1 ? maxY0 : maxY1;
-
-	double intMidX = (intMinX + intMaxX) / 2.0;
-	double intMidY = (intMinY + intMaxY) / 2.0;
-
-	normPt.x = intMidX;
-	normPt.y = intMidY;
-
-	n00.x -= normPt.x;    n00.y -= normPt.y;
-	n01.x -= normPt.x;    n01.y -= normPt.y;
-	n10.x -= normPt.x;    n10.y -= normPt.y;
-	n11.x -= normPt.x;    n11.y -= normPt.y;
+    double minX0 = n00.x < n01.x ? n00.x : n01.x;
+    double minY0 = n00.y < n01.y ? n00.y : n01.y;
+    double maxX0 = n00.x > n01.x ? n00.x : n01.x;
+    double maxY0 = n00.y > n01.y ? n00.y : n01.y;
+
+    double minX1 = n10.x < n11.x ? n10.x : n11.x;
+    double minY1 = n10.y < n11.y ? n10.y : n11.y;
+    double maxX1 = n10.x > n11.x ? n10.x : n11.x;
+    double maxY1 = n10.y > n11.y ? n10.y : n11.y;
+
+    double intMinX = minX0 > minX1 ? minX0 : minX1;
+    double intMaxX = maxX0 < maxX1 ? maxX0 : maxX1;
+    double intMinY = minY0 > minY1 ? minY0 : minY1;
+    double intMaxY = maxY0 < maxY1 ? maxY0 : maxY1;
+
+    double intMidX = (intMinX + intMaxX) / 2.0;
+    double intMidY = (intMinY + intMaxY) / 2.0;
+
+    normPt.x = intMidX;
+    normPt.y = intMidY;
+
+    n00.x -= normPt.x;
+    n00.y -= normPt.y;
+    n01.x -= normPt.x;
+    n01.y -= normPt.y;
+    n10.x -= normPt.x;
+    n10.y -= normPt.y;
+    n11.x -= normPt.x;
+    n11.y -= normPt.y;
 
 #if COMPUTE_Z
 
-	// Only do this if input does have Z
-	// See https://trac.osgeo.org/geos/ticket/811
-	if( std::isnan(n00.z) ) return;
-
-	double minZ0 = n00.z < n01.z ? n00.z : n01.z;
-	double minZ1 = n10.z < n11.z ? n10.z : n11.z;
-	double maxZ0 = n00.z > n01.z ? n00.z : n01.z;
-	double maxZ1 = n10.z > n11.z ? n10.z : n11.z;
-	double intMinZ = minZ0 > minZ1 ? minZ0 : minZ1;
-	double intMaxZ = maxZ0 < maxZ1 ? maxZ0 : maxZ1;
-	double intMidZ = (intMinZ + intMaxZ) / 2.0;
-	normPt.z = intMidZ;
-	n00.z -= normPt.z;
-	n01.z -= normPt.z;
-	n10.z -= normPt.z;
-	n11.z -= normPt.z;
+    // Only do this if input does have Z
+    // See https://trac.osgeo.org/geos/ticket/811
+    if(std::isnan(n00.z)) {
+        return;
+    }
+
+    double minZ0 = n00.z < n01.z ? n00.z : n01.z;
+    double minZ1 = n10.z < n11.z ? n10.z : n11.z;
+    double maxZ0 = n00.z > n01.z ? n00.z : n01.z;
+    double maxZ1 = n10.z > n11.z ? n10.z : n11.z;
+    double intMinZ = minZ0 > minZ1 ? minZ0 : minZ1;
+    double intMaxZ = maxZ0 < maxZ1 ? maxZ0 : maxZ1;
+    double intMidZ = (intMinZ + intMaxZ) / 2.0;
+    normPt.z = intMidZ;
+    n00.z -= normPt.z;
+    n01.z -= normPt.z;
+    n10.z -= normPt.z;
+    n11.z -= normPt.z;
 #endif
 }
 
 /*private*/
 void
 LineIntersector::safeHCoordinateIntersection(const Coordinate& p1,
-		const Coordinate& p2, const Coordinate& q1,
-		const Coordinate& q2, Coordinate& intPtOut) const
+        const Coordinate& p2, const Coordinate& q1,
+        const Coordinate& q2, Coordinate& intPtOut) const
 {
-	try {
-		HCoordinate::intersection(p1, p2, q1, q2, intPtOut);
+    try {
+        HCoordinate::intersection(p1, p2, q1, q2, intPtOut);
 #if GEOS_DEBUG
-		cerr<<" HCoordinate found intersection h:"<<intPt.toString()<<endl;
+        cerr << " HCoordinate found intersection h:" << intPt.toString() << endl;
 #endif
 
-	} catch (const NotRepresentableException& /* e */) {
-		// compute an approximate result
-		//intPt = CentralEndpointIntersector::getIntersection(p1, p2, q1, q2);
-		intPtOut = nearestEndpoint(p1, p2, q1, q2);
-    	}
+    }
+    catch(const NotRepresentableException& /* e */) {
+        // compute an approximate result
+        //intPt = CentralEndpointIntersector::getIntersection(p1, p2, q1, q2);
+        intPtOut = nearestEndpoint(p1, p2, q1, q2);
+    }
 }
 
 } // namespace geos.algorithm
diff --git a/src/algorithm/MinimumBoundingCircle.cpp b/src/algorithm/MinimumBoundingCircle.cpp
index 0928d66..59b1084 100644
--- a/src/algorithm/MinimumBoundingCircle.cpp
+++ b/src/algorithm/MinimumBoundingCircle.cpp
@@ -49,11 +49,13 @@ MinimumBoundingCircle::getCircle()
     //TODO: or maybe even ensure that the returned geometry contains ALL the input points?
 
     compute();
-    if (centre.isNull())
+    if(centre.isNull()) {
         return input->getFactory()->createPolygon();
-    Point *centrePoint = input->getFactory()->createPoint(centre);
-    if (radius == 0.0)
+    }
+    Point* centrePoint = input->getFactory()->createPoint(centre);
+    if(radius == 0.0) {
         return centrePoint;
+    }
     return centrePoint->buffer(radius);
 }
 
@@ -62,16 +64,16 @@ Geometry*
 MinimumBoundingCircle::getFarthestPoints()
 {
     compute();
-    switch (extremalPts.size()) {
-        case 0:
-            return input->getFactory()->createLineString();
-        case 1:
-            return input->getFactory()->createPoint(centre);
+    switch(extremalPts.size()) {
+    case 0:
+        return input->getFactory()->createLineString();
+    case 1:
+        return input->getFactory()->createPoint(centre);
     }
 
     size_t dims = input->getDimension();
     size_t len = 2;
-    CoordinateSequence *cs = input->getFactory()->getCoordinateSequenceFactory()->create(len, dims);
+    CoordinateSequence* cs = input->getFactory()->getCoordinateSequenceFactory()->create(len, dims);
     cs->add(extremalPts[0], true);
     cs->add(extremalPts[extremalPts.size() - 1], true);
     return input->getFactory()->createLineString(cs);
@@ -82,15 +84,15 @@ Geometry*
 MinimumBoundingCircle::getDiameter()
 {
     compute();
-    switch (extremalPts.size()) {
-        case 0:
-            return input->getFactory()->createLineString();
-        case 1:
-            return input->getFactory()->createPoint(centre);
+    switch(extremalPts.size()) {
+    case 0:
+        return input->getFactory()->createLineString();
+    case 1:
+        return input->getFactory()->createPoint(centre);
     }
     size_t dims = input->getDimension();
     size_t len = 2;
-    CoordinateSequence *cs = input->getFactory()->getCoordinateSequenceFactory()->create(len, dims);
+    CoordinateSequence* cs = input->getFactory()->getCoordinateSequenceFactory()->create(len, dims);
     // TODO: handle case of 3 extremal points, by computing a line from one of
     // them through the centre point with len = 2*radius
     cs->add(extremalPts[0], true);
@@ -126,29 +128,30 @@ MinimumBoundingCircle::getRadius()
 void
 MinimumBoundingCircle::computeCentre()
 {
-    switch (extremalPts.size()) {
-        case 0: {
-            centre.setNull();
-            break;
-        }
-        case 1: {
-            centre = extremalPts[0];
-            break;
-        }
-        case 2: {
-            double xAvg = (extremalPts[0].x + extremalPts[1].x) / 2.0;
-            double yAvg = (extremalPts[0].y + extremalPts[1].y) / 2.0;
-            Coordinate c(xAvg, yAvg);
-            centre = c;
-            break;
-        }
-        case 3: {
-            centre = Triangle::circumcentre(extremalPts[0], extremalPts[1], extremalPts[2]);
-            break;
-        }
-        default: {
-            util::GEOSException("Logic failure in MinimumBoundingCircle algorithm!");\
-        }
+    switch(extremalPts.size()) {
+    case 0: {
+        centre.setNull();
+        break;
+    }
+    case 1: {
+        centre = extremalPts[0];
+        break;
+    }
+    case 2: {
+        double xAvg = (extremalPts[0].x + extremalPts[1].x) / 2.0;
+        double yAvg = (extremalPts[0].y + extremalPts[1].y) / 2.0;
+        Coordinate c(xAvg, yAvg);
+        centre = c;
+        break;
+    }
+    case 3: {
+        centre = Triangle::circumcentre(extremalPts[0], extremalPts[1], extremalPts[2]);
+        break;
+    }
+    default: {
+        util::GEOSException("Logic failure in MinimumBoundingCircle algorithm!");
+        \
+    }
     }
 }
 
@@ -156,12 +159,15 @@ MinimumBoundingCircle::computeCentre()
 void
 MinimumBoundingCircle::compute()
 {
-    if (!extremalPts.empty()) return;
+    if(!extremalPts.empty()) {
+        return;
+    }
 
     computeCirclePoints();
     computeCentre();
-    if (!centre.isNull())
+    if(!centre.isNull()) {
         radius = centre.distance(extremalPts[0]);
+    }
 }
 
 /*private*/
@@ -169,10 +175,10 @@ void
 MinimumBoundingCircle::computeCirclePoints()
 {
     // handle degenerate or trivial cases
-    if (input->isEmpty()) {
+    if(input->isEmpty()) {
         return;
     }
-    if (input->getNumPoints() == 1) {
+    if(input->getNumPoints() == 1) {
         extremalPts.push_back(*(input->getCoordinate()));
         return;
     }
@@ -181,21 +187,21 @@ MinimumBoundingCircle::computeCirclePoints()
     * The problem is simplified by reducing to the convex hull.
     * Computing the convex hull also has the useful effect of eliminating duplicate points
     */
-    Geometry *convexHull = input->convexHull();
+    Geometry* convexHull = input->convexHull();
 
-    CoordinateSequence *cs = convexHull->getCoordinates();
+    CoordinateSequence* cs = convexHull->getCoordinates();
     std::vector<Coordinate> pts;
     cs->toVector(pts);
 
     // strip duplicate final point, if any
-    if (pts.front().equals2D(pts.back())) {
+    if(pts.front().equals2D(pts.back())) {
         pts.pop_back();
     }
 
     /**
     * Optimization for the trivial case where the CH has fewer than 3 points
     */
-    if (pts.size() <= 2) {
+    if(pts.size() <= 2) {
         extremalPts = pts;
         return;
     }
@@ -214,22 +220,22 @@ MinimumBoundingCircle::computeCirclePoints()
     * with a correct result.
     */
     size_t i = 0, n = pts.size();
-    while (i++ < n) {
+    while(i++ < n) {
         Coordinate R = pointWithMinAngleWithSegment(pts, P, Q);
 
         // if PRQ is obtuse, then MBC is determined by P and Q
-        if (algorithm::Angle::isObtuse(P, R, Q)) {
+        if(algorithm::Angle::isObtuse(P, R, Q)) {
             extremalPts.push_back(P);
             extremalPts.push_back(Q);
             return;
         }
         // if RPQ is obtuse, update baseline and iterate
-        if (algorithm::Angle::isObtuse(R, P, Q)) {
+        if(algorithm::Angle::isObtuse(R, P, Q)) {
             P = R;
             continue;
         }
         // if RQP is obtuse, update baseline and iterate
-        if (algorithm::Angle::isObtuse(R, Q, P)) {
+        if(algorithm::Angle::isObtuse(R, Q, P)) {
             Q = R;
             continue;
         }
@@ -248,9 +254,10 @@ Coordinate
 MinimumBoundingCircle::lowestPoint(std::vector<Coordinate>& pts)
 {
     Coordinate min = pts[0];
-    for (auto pt: pts) {
-        if (pt.y < min.y)
+    for(auto pt : pts) {
+        if(pt.y < min.y) {
             min = pt;
+        }
     }
     return min;
 }
@@ -263,20 +270,24 @@ MinimumBoundingCircle::pointWitMinAngleWithX(std::vector<Coordinate>& pts, Coord
     double minSin = std::numeric_limits<double>::max();
     Coordinate minAngPt;
     minAngPt.setNull();
-    for (auto p: pts) {
+    for(auto p : pts) {
 
-        if (p == P) continue;
+        if(p == P) {
+            continue;
+        }
 
         /**
         * The sin of the angle is a simpler proxy for the angle itself
         */
         double dx = p.x - P.x;
         double dy = p.y - P.y;
-        if (dy < 0) dy = -dy;
+        if(dy < 0) {
+            dy = -dy;
+        }
         double len = sqrt(dx * dx + dy * dy);
         double sin = dy / len;
 
-        if (sin < minSin) {
+        if(sin < minSin) {
             minSin = sin;
             minAngPt = p;
         }
@@ -292,12 +303,16 @@ MinimumBoundingCircle::pointWithMinAngleWithSegment(std::vector<Coordinate>& pts
     double minAng = std::numeric_limits<double>::max();
     Coordinate minAngPt;
     minAngPt.setNull();
-    for (auto p: pts) {
-        if (p == P) continue;
-        if (p == Q) continue;
+    for(auto p : pts) {
+        if(p == P) {
+            continue;
+        }
+        if(p == Q) {
+            continue;
+        }
 
         double ang = Angle::angleBetween(P, p, Q);
-        if (ang < minAng) {
+        if(ang < minAng) {
             minAng = ang;
             minAngPt = p;
         }
diff --git a/src/algorithm/MinimumDiameter.cpp b/src/algorithm/MinimumDiameter.cpp
index 1c51f1e..692da52 100644
--- a/src/algorithm/MinimumDiameter.cpp
+++ b/src/algorithm/MinimumDiameter.cpp
@@ -68,13 +68,13 @@ namespace algorithm { // geos.algorithm
  */
 MinimumDiameter::MinimumDiameter(const Geometry* newInputGeom)
 {
-	minBaseSeg=new LineSegment();
-	minWidthPt=nullptr;
-	minPtIndex=0;
-	minWidth=0.0;
-	inputGeom=newInputGeom;
-	isConvex=false;
-	convexHullPts=nullptr;
+    minBaseSeg = new LineSegment();
+    minWidthPt = nullptr;
+    minPtIndex = 0;
+    minWidth = 0.0;
+    inputGeom = newInputGeom;
+    isConvex = false;
+    convexHullPts = nullptr;
 }
 
 /**
@@ -89,19 +89,19 @@ MinimumDiameter::MinimumDiameter(const Geometry* newInputGeom)
  */
 MinimumDiameter::MinimumDiameter(const Geometry* newInputGeom, const bool newIsConvex)
 {
-	minBaseSeg=new LineSegment();
-	minWidthPt=nullptr;
-	minWidth=0.0;
-	inputGeom=newInputGeom;
-	isConvex=newIsConvex;
-	convexHullPts=nullptr;
+    minBaseSeg = new LineSegment();
+    minWidthPt = nullptr;
+    minWidth = 0.0;
+    inputGeom = newInputGeom;
+    isConvex = newIsConvex;
+    convexHullPts = nullptr;
 }
 
 MinimumDiameter::~MinimumDiameter()
 {
-	delete minBaseSeg;
-	delete minWidthPt;
-	delete convexHullPts;
+    delete minBaseSeg;
+    delete minWidthPt;
+    delete convexHullPts;
 }
 
 /**
@@ -112,8 +112,8 @@ MinimumDiameter::~MinimumDiameter()
 double
 MinimumDiameter::getLength()
 {
-	computeMinimumDiameter();
-	return minWidth;
+    computeMinimumDiameter();
+    return minWidth;
 }
 
 /**
@@ -124,8 +124,8 @@ MinimumDiameter::getLength()
 Coordinate*
 MinimumDiameter::getWidthCoordinate()
 {
-	computeMinimumDiameter();
-	return minWidthPt;
+    computeMinimumDiameter();
+    return minWidthPt;
 }
 
 /**
@@ -134,13 +134,14 @@ MinimumDiameter::getWidthCoordinate()
  * @return the segment forming the base of the minimum diameter
  */
 LineString*
-MinimumDiameter::getSupportingSegment() {
-	computeMinimumDiameter();
-	const GeometryFactory *fact = inputGeom->getFactory();
-	CoordinateSequence* cl=fact->getCoordinateSequenceFactory()->create();
-	cl->add(minBaseSeg->p0);
-	cl->add(minBaseSeg->p1);
-	return fact->createLineString(cl);
+MinimumDiameter::getSupportingSegment()
+{
+    computeMinimumDiameter();
+    const GeometryFactory* fact = inputGeom->getFactory();
+    CoordinateSequence* cl = fact->getCoordinateSequenceFactory()->create();
+    cl->add(minBaseSeg->p0);
+    cl->add(minBaseSeg->p1);
+    return fact->createLineString(cl);
 }
 
 /**
@@ -151,81 +152,81 @@ MinimumDiameter::getSupportingSegment() {
 LineString*
 MinimumDiameter::getDiameter()
 {
-	computeMinimumDiameter();
-	// return empty linestring if no minimum width calculated
-	if (minWidthPt==nullptr)
-		return inputGeom->getFactory()->createLineString(nullptr);
-
-	Coordinate basePt;
-	minBaseSeg->project(*minWidthPt, basePt);
-
-	CoordinateSequence* cl=inputGeom->getFactory()->getCoordinateSequenceFactory()->create();
-	cl->add(basePt);
-	cl->add(*minWidthPt);
-	return inputGeom->getFactory()->createLineString(cl);
+    computeMinimumDiameter();
+    // return empty linestring if no minimum width calculated
+    if(minWidthPt == nullptr) {
+        return inputGeom->getFactory()->createLineString(nullptr);
+    }
+
+    Coordinate basePt;
+    minBaseSeg->project(*minWidthPt, basePt);
+
+    CoordinateSequence* cl = inputGeom->getFactory()->getCoordinateSequenceFactory()->create();
+    cl->add(basePt);
+    cl->add(*minWidthPt);
+    return inputGeom->getFactory()->createLineString(cl);
 }
 
 /* private */
 void
 MinimumDiameter::computeMinimumDiameter()
 {
-	// check if computation is cached
-	if (minWidthPt!=nullptr)
-		return;
-	if (isConvex)
-		computeWidthConvex(inputGeom);
-	else {
-		ConvexHull ch(inputGeom);
-		Geometry* convexGeom=ch.getConvexHull();
-		computeWidthConvex(convexGeom);
-		delete convexGeom;
-	}
+    // check if computation is cached
+    if(minWidthPt != nullptr) {
+        return;
+    }
+    if(isConvex) {
+        computeWidthConvex(inputGeom);
+    }
+    else {
+        ConvexHull ch(inputGeom);
+        Geometry* convexGeom = ch.getConvexHull();
+        computeWidthConvex(convexGeom);
+        delete convexGeom;
+    }
 }
 
 /* private */
 void
-MinimumDiameter::computeWidthConvex(const Geometry *geom)
+MinimumDiameter::computeWidthConvex(const Geometry* geom)
 {
-	//System.out.println("Input = " + geom);
-	delete convexHullPts;
-	if (typeid(*geom)==typeid(Polygon))
-	{
-		const Polygon* p = dynamic_cast<const Polygon*>(geom);
-		convexHullPts=p->getExteriorRing()->getCoordinates();
-	}
-	else
-	{
-		convexHullPts=geom->getCoordinates();
-	}
-
-	// special cases for lines or points or degenerate rings
-	switch(convexHullPts->getSize())
-	{
-		case 0:
-			minWidth=0.0;
-			delete minWidthPt;
-			minWidthPt=nullptr;
-			delete minBaseSeg;
-			minBaseSeg=nullptr;
-			break;
-		case 1:
-			minWidth = 0.0;
-			delete minWidthPt;
-			minWidthPt=new Coordinate(convexHullPts->getAt(0));
-			minBaseSeg->p0=convexHullPts->getAt(0);
-			minBaseSeg->p1=convexHullPts->getAt(0);
-			break;
-		case 2:
-		case 3:
-			minWidth = 0.0;
-			delete minWidthPt;
-			minWidthPt=new Coordinate(convexHullPts->getAt(0));
-			minBaseSeg->p0=convexHullPts->getAt(0);
-			minBaseSeg->p1=convexHullPts->getAt(1);
-			break;
-		default:
-			computeConvexRingMinDiameter(convexHullPts);
-	}
+    //System.out.println("Input = " + geom);
+    delete convexHullPts;
+    if(typeid(*geom) == typeid(Polygon)) {
+        const Polygon* p = dynamic_cast<const Polygon*>(geom);
+        convexHullPts = p->getExteriorRing()->getCoordinates();
+    }
+    else {
+        convexHullPts = geom->getCoordinates();
+    }
+
+    // special cases for lines or points or degenerate rings
+    switch(convexHullPts->getSize()) {
+    case 0:
+        minWidth = 0.0;
+        delete minWidthPt;
+        minWidthPt = nullptr;
+        delete minBaseSeg;
+        minBaseSeg = nullptr;
+        break;
+    case 1:
+        minWidth = 0.0;
+        delete minWidthPt;
+        minWidthPt = new Coordinate(convexHullPts->getAt(0));
+        minBaseSeg->p0 = convexHullPts->getAt(0);
+        minBaseSeg->p1 = convexHullPts->getAt(0);
+        break;
+    case 2:
+    case 3:
+        minWidth = 0.0;
+        delete minWidthPt;
+        minWidthPt = new Coordinate(convexHullPts->getAt(0));
+        minBaseSeg->p0 = convexHullPts->getAt(0);
+        minBaseSeg->p1 = convexHullPts->getAt(1);
+        break;
+    default:
+        computeConvexRingMinDiameter(convexHullPts);
+    }
 }
 
 /**
@@ -238,159 +239,173 @@ MinimumDiameter::computeWidthConvex(const Geometry *geom)
 void
 MinimumDiameter::computeConvexRingMinDiameter(const CoordinateSequence* pts)
 {
-	minWidth=DoubleMax;
-	unsigned int currMaxIndex=1;
-	LineSegment seg;
-
-	// compute the max distance for all segments in the ring, and pick the minimum
-	const std::size_t npts=pts->getSize();
-	for (std::size_t i=1; i<npts; ++i) {
-		seg.p0=pts->getAt(i-1);
-		seg.p1=pts->getAt(i);
-		currMaxIndex=findMaxPerpDistance(pts, &seg, currMaxIndex);
-	}
+    minWidth = DoubleMax;
+    unsigned int currMaxIndex = 1;
+    LineSegment seg;
+
+    // compute the max distance for all segments in the ring, and pick the minimum
+    const std::size_t npts = pts->getSize();
+    for(std::size_t i = 1; i < npts; ++i) {
+        seg.p0 = pts->getAt(i - 1);
+        seg.p1 = pts->getAt(i);
+        currMaxIndex = findMaxPerpDistance(pts, &seg, currMaxIndex);
+    }
 }
 
 unsigned int
-MinimumDiameter::findMaxPerpDistance(const CoordinateSequence *pts,
-		LineSegment* seg, unsigned int startIndex)
+MinimumDiameter::findMaxPerpDistance(const CoordinateSequence* pts,
+                                     LineSegment* seg, unsigned int startIndex)
 {
-	double maxPerpDistance=seg->distancePerpendicular(pts->getAt(startIndex));
-	double nextPerpDistance = maxPerpDistance;
-	unsigned int maxIndex = startIndex;
-	unsigned int nextIndex = maxIndex;
-	while (nextPerpDistance >= maxPerpDistance) {
-		maxPerpDistance = nextPerpDistance;
-		maxIndex=nextIndex;
-		nextIndex=getNextIndex(pts, maxIndex);
-		nextPerpDistance = seg->distancePerpendicular(pts->getAt(nextIndex));
-	}
-
-	// found maximum width for this segment - update global min dist if appropriate
-	if (maxPerpDistance < minWidth) {
-		minPtIndex = maxIndex;
-		minWidth = maxPerpDistance;
-		delete minWidthPt;
-		minWidthPt = new Coordinate(pts->getAt(minPtIndex));
-		delete minBaseSeg;
-		minBaseSeg = new LineSegment(*seg);
+    double maxPerpDistance = seg->distancePerpendicular(pts->getAt(startIndex));
+    double nextPerpDistance = maxPerpDistance;
+    unsigned int maxIndex = startIndex;
+    unsigned int nextIndex = maxIndex;
+    while(nextPerpDistance >= maxPerpDistance) {
+        maxPerpDistance = nextPerpDistance;
+        maxIndex = nextIndex;
+        nextIndex = getNextIndex(pts, maxIndex);
+        nextPerpDistance = seg->distancePerpendicular(pts->getAt(nextIndex));
+    }
+
+    // found maximum width for this segment - update global min dist if appropriate
+    if(maxPerpDistance < minWidth) {
+        minPtIndex = maxIndex;
+        minWidth = maxPerpDistance;
+        delete minWidthPt;
+        minWidthPt = new Coordinate(pts->getAt(minPtIndex));
+        delete minBaseSeg;
+        minBaseSeg = new LineSegment(*seg);
 //      System.out.println(minBaseSeg);
 //      System.out.println(minWidth);
-	}
-	return maxIndex;
+    }
+    return maxIndex;
 }
 
 unsigned int
-MinimumDiameter::getNextIndex(const CoordinateSequence *pts,
-	unsigned int index)
+MinimumDiameter::getNextIndex(const CoordinateSequence* pts,
+                              unsigned int index)
 {
-	if (++index >= pts->getSize()) index = 0;
-	return index;
+    if(++index >= pts->getSize()) {
+        index = 0;
+    }
+    return index;
 }
 
-Geometry* MinimumDiameter::getMinimumRectangle()
+Geometry*
+MinimumDiameter::getMinimumRectangle()
 {
-	computeMinimumDiameter();
-
-	if ( !minBaseSeg || !convexHullPts )
-	{
-		//return empty polygon
-		return inputGeom->getFactory()->createPolygon();
-	}
-
-	// check if minimum rectangle is degenerate (a point or line segment)
-	if (minWidth == 0.0) {
-		if (minBaseSeg->p0.equals2D(minBaseSeg->p1)) {
-			return inputGeom->getFactory()->createPoint(minBaseSeg->p0);
-		}
-		return minBaseSeg->toGeometry(*inputGeom->getFactory()).release();
-	}
-
-	// deltas for the base segment of the minimum diameter
-	double dx = minBaseSeg->p1.x - minBaseSeg->p0.x;
-	double dy = minBaseSeg->p1.y - minBaseSeg->p0.y;
-
-	double minPara = DoubleMax;
-	double maxPara = -DoubleMax;
-	double minPerp = DoubleMax;
-	double maxPerp = -DoubleMax;
-
-	// compute maxima and minima of lines parallel and perpendicular to base segment
-	std::size_t const n=convexHullPts->getSize();
-	for (std::size_t i = 0; i < n; ++i) {
-
-		double paraC = computeC(dx, dy, convexHullPts->getAt(i));
-		if (paraC > maxPara) maxPara = paraC;
-		if (paraC < minPara) minPara = paraC;
-
-		double perpC = computeC(-dy, dx, convexHullPts->getAt(i));
-		if (perpC > maxPerp) maxPerp = perpC;
-		if (perpC < minPerp) minPerp = perpC;
-	}
-
-	// compute lines along edges of minimum rectangle
-	LineSegment maxPerpLine = computeSegmentForLine(-dx, -dy, maxPerp);
-	LineSegment minPerpLine = computeSegmentForLine(-dx, -dy, minPerp);
-	LineSegment maxParaLine = computeSegmentForLine(-dy, dx, maxPara);
-	LineSegment minParaLine = computeSegmentForLine(-dy, dx, minPara);
-
-	// compute vertices of rectangle (where the para/perp max & min lines intersect)
-	Coordinate p0, p1, p2, p3;
-	maxParaLine.lineIntersection(maxPerpLine, p0);
-	minParaLine.lineIntersection(maxPerpLine, p1);
-	minParaLine.lineIntersection(minPerpLine, p2);
-	maxParaLine.lineIntersection(minPerpLine, p3);
-
-	const CoordinateSequenceFactory *csf =
-	inputGeom->getFactory()->getCoordinateSequenceFactory();
-
-	geom::CoordinateSequence *seq = csf->create(5, 2);
-	seq->setAt(p0, 0);
-	seq->setAt(p1, 1);
-	seq->setAt(p2, 2);
-	seq->setAt(p3, 3);
-	seq->setAt(p0, 4); // close
-
-	LinearRing* shell = inputGeom->getFactory()->createLinearRing( seq );
-	return inputGeom->getFactory()->createPolygon( shell, nullptr );
+    computeMinimumDiameter();
+
+    if(!minBaseSeg || !convexHullPts) {
+        //return empty polygon
+        return inputGeom->getFactory()->createPolygon();
+    }
+
+    // check if minimum rectangle is degenerate (a point or line segment)
+    if(minWidth == 0.0) {
+        if(minBaseSeg->p0.equals2D(minBaseSeg->p1)) {
+            return inputGeom->getFactory()->createPoint(minBaseSeg->p0);
+        }
+        return minBaseSeg->toGeometry(*inputGeom->getFactory()).release();
+    }
+
+    // deltas for the base segment of the minimum diameter
+    double dx = minBaseSeg->p1.x - minBaseSeg->p0.x;
+    double dy = minBaseSeg->p1.y - minBaseSeg->p0.y;
+
+    double minPara = DoubleMax;
+    double maxPara = -DoubleMax;
+    double minPerp = DoubleMax;
+    double maxPerp = -DoubleMax;
+
+    // compute maxima and minima of lines parallel and perpendicular to base segment
+    std::size_t const n = convexHullPts->getSize();
+    for(std::size_t i = 0; i < n; ++i) {
+
+        double paraC = computeC(dx, dy, convexHullPts->getAt(i));
+        if(paraC > maxPara) {
+            maxPara = paraC;
+        }
+        if(paraC < minPara) {
+            minPara = paraC;
+        }
+
+        double perpC = computeC(-dy, dx, convexHullPts->getAt(i));
+        if(perpC > maxPerp) {
+            maxPerp = perpC;
+        }
+        if(perpC < minPerp) {
+            minPerp = perpC;
+        }
+    }
+
+    // compute lines along edges of minimum rectangle
+    LineSegment maxPerpLine = computeSegmentForLine(-dx, -dy, maxPerp);
+    LineSegment minPerpLine = computeSegmentForLine(-dx, -dy, minPerp);
+    LineSegment maxParaLine = computeSegmentForLine(-dy, dx, maxPara);
+    LineSegment minParaLine = computeSegmentForLine(-dy, dx, minPara);
+
+    // compute vertices of rectangle (where the para/perp max & min lines intersect)
+    Coordinate p0, p1, p2, p3;
+    maxParaLine.lineIntersection(maxPerpLine, p0);
+    minParaLine.lineIntersection(maxPerpLine, p1);
+    minParaLine.lineIntersection(minPerpLine, p2);
+    maxParaLine.lineIntersection(minPerpLine, p3);
+
+    const CoordinateSequenceFactory* csf =
+        inputGeom->getFactory()->getCoordinateSequenceFactory();
+
+    geom::CoordinateSequence* seq = csf->create(5, 2);
+    seq->setAt(p0, 0);
+    seq->setAt(p1, 1);
+    seq->setAt(p2, 2);
+    seq->setAt(p3, 3);
+    seq->setAt(p0, 4); // close
+
+    LinearRing* shell = inputGeom->getFactory()->createLinearRing(seq);
+    return inputGeom->getFactory()->createPolygon(shell, nullptr);
 }
 
-double MinimumDiameter::computeC(double a, double b, const Coordinate& p)
+double
+MinimumDiameter::computeC(double a, double b, const Coordinate& p)
 {
-	return a * p.y - b * p.x;
+    return a * p.y - b * p.x;
 }
 
-LineSegment MinimumDiameter::computeSegmentForLine(double a, double b, double c)
+LineSegment
+MinimumDiameter::computeSegmentForLine(double a, double b, double c)
 {
-	Coordinate p0;
-	Coordinate p1;
-	/*
-	* Line eqn is ax + by = c
-	* Slope is a/b.
-	* If slope is steep, use y values as the inputs
-	*/
-	if (fabs(b) > fabs(a) ) {
-		p0 = Coordinate(0.0, c/b);
-		p1 = Coordinate(1.0, c/b - a/b);
-	}
-	else {
-		p0 = Coordinate(c/a, 0.0);
-		p1 = Coordinate(c/a - b/a, 1.0);
-	}
-	return LineSegment(p0, p1);
+    Coordinate p0;
+    Coordinate p1;
+    /*
+    * Line eqn is ax + by = c
+    * Slope is a/b.
+    * If slope is steep, use y values as the inputs
+    */
+    if(fabs(b) > fabs(a)) {
+        p0 = Coordinate(0.0, c / b);
+        p1 = Coordinate(1.0, c / b - a / b);
+    }
+    else {
+        p0 = Coordinate(c / a, 0.0);
+        p1 = Coordinate(c / a - b / a, 1.0);
+    }
+    return LineSegment(p0, p1);
 }
 
 
-Geometry *MinimumDiameter::getMinimumRectangle(Geometry *geom)
+Geometry*
+MinimumDiameter::getMinimumRectangle(Geometry* geom)
 {
-	MinimumDiameter md( geom );
-	return md.getMinimumRectangle();
+    MinimumDiameter md(geom);
+    return md.getMinimumRectangle();
 }
 
-Geometry *MinimumDiameter::getMinimumDiameter(Geometry *geom)
+Geometry*
+MinimumDiameter::getMinimumDiameter(Geometry* geom)
 {
-	MinimumDiameter md( geom );
-	return md.getDiameter();
+    MinimumDiameter md(geom);
+    return md.getDiameter();
 }
 
 } // namespace geos.algorithm
diff --git a/src/algorithm/NotRepresentableException.cpp b/src/algorithm/NotRepresentableException.cpp
index 311107f..2ca729c 100644
--- a/src/algorithm/NotRepresentableException.cpp
+++ b/src/algorithm/NotRepresentableException.cpp
@@ -20,18 +20,18 @@ namespace geos {
 namespace algorithm { // geos.algorithm
 
 NotRepresentableException::NotRepresentableException()
-	:
-	GEOSException(
-		"NotRepresentableException",
-		"Projective point not representable on the Cartesian plane.")
+    :
+    GEOSException(
+        "NotRepresentableException",
+        "Projective point not representable on the Cartesian plane.")
 
 {
 }
 
 NotRepresentableException::NotRepresentableException(std::string msg)
-	:
-	GEOSException(
-		"NotRepresentableException", msg)
+    :
+    GEOSException(
+        "NotRepresentableException", msg)
 {
 }
 
diff --git a/src/algorithm/Orientation.cpp b/src/algorithm/Orientation.cpp
index de1d7bd..a2139b5 100644
--- a/src/algorithm/Orientation.cpp
+++ b/src/algorithm/Orientation.cpp
@@ -31,30 +31,30 @@ namespace algorithm { // geos.algorithm
 
 /* public static */
 int
-Orientation::index(const geom::Coordinate &p1, const geom::Coordinate &p2,
-                   const geom::Coordinate &q)
+Orientation::index(const geom::Coordinate& p1, const geom::Coordinate& p2,
+                   const geom::Coordinate& q)
 {
     return CGAlgorithmsDD::orientationIndex(p1, p2, q);
 }
 
 /* public static */
 bool
-Orientation::isCCW(const geom::CoordinateSequence *ring)
+Orientation::isCCW(const geom::CoordinateSequence* ring)
 {
     // sanity check
-    if (ring->getSize() < 4) {
+    if(ring->getSize() < 4) {
         throw util::IllegalArgumentException("Ring has fewer than 4 points, so orientation cannot be determined");
     }
 
     // # of points without closing endpoint
-    const std::size_t nPts = ring->getSize()-1;
+    const std::size_t nPts = ring->getSize() - 1;
 
     // find highest point
-    const geom::Coordinate *hiPt = &ring->getAt(0);
+    const geom::Coordinate* hiPt = &ring->getAt(0);
     size_t hiIndex = 0;
-    for (std::size_t i = 1; i <= nPts; ++i) {
-        const geom::Coordinate *p = &ring->getAt(i);
-        if (p->y > hiPt->y) {
+    for(std::size_t i = 1; i <= nPts; ++i) {
+        const geom::Coordinate* p = &ring->getAt(i);
+        if(p->y > hiPt->y) {
             hiPt = p;
             hiIndex = i;
         }
@@ -63,21 +63,22 @@ Orientation::isCCW(const geom::CoordinateSequence *ring)
     // find distinct point before highest point
     auto iPrev = hiIndex;
     do {
-        if (iPrev == 0)
+        if(iPrev == 0) {
             iPrev = nPts;
+        }
         iPrev = iPrev - 1;
     }
-    while (ring->getAt(iPrev) == *hiPt && iPrev != hiIndex);
+    while(ring->getAt(iPrev) == *hiPt && iPrev != hiIndex);
 
     // find distinct point after highest point
     auto iNext = hiIndex;
     do {
         iNext = (iNext + 1) % nPts;
     }
-    while (ring->getAt(iNext)==*hiPt && iNext != hiIndex);
+    while(ring->getAt(iNext) == *hiPt && iNext != hiIndex);
 
-    const geom::Coordinate *prev=&ring->getAt(iPrev);
-    const geom::Coordinate *next=&ring->getAt(iNext);
+    const geom::Coordinate* prev = &ring->getAt(iPrev);
+    const geom::Coordinate* next = &ring->getAt(iNext);
 
     /*
      * This check catches cases where the ring contains an A-B-A
@@ -86,8 +87,8 @@ Orientation::isCCW(const geom::CoordinateSequence *ring)
      * (including the case where the input array has fewer than 4 elements),
      * or it contains coincident line segments.
      */
-    if (prev->equals2D(*hiPt) || next->equals2D(*hiPt) ||
-        prev->equals2D(*next)) {
+    if(prev->equals2D(*hiPt) || next->equals2D(*hiPt) ||
+            prev->equals2D(*next)) {
         return false;
         // MD - don't bother throwing exception,
         // since this isn't a complete check for ring validity
@@ -108,7 +109,7 @@ Orientation::isCCW(const geom::CoordinateSequence *ring)
      */
     bool isCCW = false;
 
-    if (disc == 0) {
+    if(disc == 0) {
         // poly is CCW if prev x is right of next x
         isCCW = (prev->x > next->x);
     }
diff --git a/src/algorithm/PointLocation.cpp b/src/algorithm/PointLocation.cpp
index 682c0c1..03dd7cf 100644
--- a/src/algorithm/PointLocation.cpp
+++ b/src/algorithm/PointLocation.cpp
@@ -35,15 +35,16 @@ bool
 PointLocation::isOnLine(const geom::Coordinate& p, const geom::CoordinateSequence* pt)
 {
     size_t ptsize = pt->getSize();
-    if (ptsize == 0)
+    if(ptsize == 0) {
         return false;
+    }
 
-    const geom::Coordinate *pp = &(pt->getAt(0));
-    for(size_t i = 1; i < ptsize; ++i)
-    {
-        const geom::Coordinate &p1 = pt->getAt(i);
-        if (LineIntersector::hasIntersection(p, *pp, p1))
+    const geom::Coordinate* pp = &(pt->getAt(0));
+    for(size_t i = 1; i < ptsize; ++i) {
+        const geom::Coordinate& p1 = pt->getAt(i);
+        if(LineIntersector::hasIntersection(p, *pp, p1)) {
             return true;
+        }
         pp = &p1;
     }
     return false;
@@ -51,32 +52,32 @@ PointLocation::isOnLine(const geom::Coordinate& p, const geom::CoordinateSequenc
 
 /* public static */
 bool
-PointLocation::isInRing(const geom::Coordinate &p,
-                        const std::vector<const geom::Coordinate*> &ring)
+PointLocation::isInRing(const geom::Coordinate& p,
+                        const std::vector<const geom::Coordinate*>& ring)
 {
     return PointLocation::locateInRing(p, ring) != geom::Location::EXTERIOR;
 }
 
 /* public static */
 bool
-PointLocation::isInRing(const geom::Coordinate &p,
-                        const geom::CoordinateSequence *ring)
+PointLocation::isInRing(const geom::Coordinate& p,
+                        const geom::CoordinateSequence* ring)
 {
     return PointLocation::locateInRing(p, *ring) != geom::Location::EXTERIOR;
 }
 
 /* public static */
 int
-PointLocation::locateInRing(const geom::Coordinate &p,
-                            const std::vector<const geom::Coordinate*> &ring)
+PointLocation::locateInRing(const geom::Coordinate& p,
+                            const std::vector<const geom::Coordinate*>& ring)
 {
     return RayCrossingCounter::locatePointInRing(p, ring);
 }
 
 /* public static */
 int
-PointLocation::locateInRing(const geom::Coordinate &p,
-                            const geom::CoordinateSequence &ring)
+PointLocation::locateInRing(const geom::Coordinate& p,
+                            const geom::CoordinateSequence& ring)
 {
     return RayCrossingCounter::locatePointInRing(p, ring);
 }
diff --git a/src/algorithm/PointLocator.cpp b/src/algorithm/PointLocator.cpp
index ff57507..a32143f 100644
--- a/src/algorithm/PointLocator.cpp
+++ b/src/algorithm/PointLocator.cpp
@@ -39,69 +39,70 @@ namespace algorithm { // geos.algorithm
 
 
 int
-PointLocator::locate(const Coordinate& p, const Geometry *geom)
+PointLocator::locate(const Coordinate& p, const Geometry* geom)
 {
-	if (geom->isEmpty()) return Location::EXTERIOR;
+    if(geom->isEmpty()) {
+        return Location::EXTERIOR;
+    }
 
-	const LineString *ls_geom = dynamic_cast<const LineString *>(geom);
-	if (ls_geom) return locate(p, ls_geom);
+    const LineString* ls_geom = dynamic_cast<const LineString*>(geom);
+    if(ls_geom) {
+        return locate(p, ls_geom);
+    }
 
-	const Polygon *poly_geom = dynamic_cast<const Polygon *>(geom);
-	if (poly_geom) return locate(p, poly_geom);
+    const Polygon* poly_geom = dynamic_cast<const Polygon*>(geom);
+    if(poly_geom) {
+        return locate(p, poly_geom);
+    }
 
 
-	isIn=false;
-	numBoundaries=0;
-	computeLocation(p,geom);
-	if (geomgraph::GeometryGraph::isInBoundary(numBoundaries)) return Location::BOUNDARY;
-	if (numBoundaries>0 || isIn) return Location::INTERIOR;
-	return Location::EXTERIOR;
+    isIn = false;
+    numBoundaries = 0;
+    computeLocation(p, geom);
+    if(geomgraph::GeometryGraph::isInBoundary(numBoundaries)) {
+        return Location::BOUNDARY;
+    }
+    if(numBoundaries > 0 || isIn) {
+        return Location::INTERIOR;
+    }
+    return Location::EXTERIOR;
 }
 
 /* private */
 void
-PointLocator::computeLocation(const Coordinate& p, const Geometry *geom)
+PointLocator::computeLocation(const Coordinate& p, const Geometry* geom)
 {
-	if (const Point *pt=dynamic_cast<const Point*>(geom))
-	{
-		updateLocationInfo(locate(p, pt));
-	}
-	else if (const LineString *ls=dynamic_cast<const LineString*>(geom))
-	{
-		updateLocationInfo(locate(p, ls));
-	}
-	else if (const Polygon *po=dynamic_cast<const Polygon*>(geom))
-	{
-		updateLocationInfo(locate(p, po));
-	}
-	else if (const MultiLineString *mls=dynamic_cast<const MultiLineString *>(geom))
-	{
-		for(std::size_t i=0, n=mls->getNumGeometries(); i<n; ++i)
-		{
-			const LineString *l=dynamic_cast<const LineString *>(mls->getGeometryN(i));
-			updateLocationInfo(locate(p,l));
-		}
-	}
-	else if (const MultiPolygon *mpo=dynamic_cast<const MultiPolygon *>(geom))
-	{
-		for(std::size_t i=0, n=mpo->getNumGeometries(); i<n; ++i)
-		{
-			const Polygon *p_po=dynamic_cast<const Polygon *>(mpo->getGeometryN(i));
-			updateLocationInfo(locate(p, p_po));
-		}
-	}
-	else if (const GeometryCollection *col=dynamic_cast<const GeometryCollection *>(geom))
-	{
-		for (GeometryCollection::const_iterator
-				it=col->begin(), endIt=col->end();
-				it != endIt;
-				++it)
-		{
-			const Geometry *g2=*it;
-			assert (g2!=geom); // is this check really needed ?
-			computeLocation(p, g2);
-		}
-	}
+    if(const Point* pt = dynamic_cast<const Point*>(geom)) {
+        updateLocationInfo(locate(p, pt));
+    }
+    else if(const LineString* ls = dynamic_cast<const LineString*>(geom)) {
+        updateLocationInfo(locate(p, ls));
+    }
+    else if(const Polygon* po = dynamic_cast<const Polygon*>(geom)) {
+        updateLocationInfo(locate(p, po));
+    }
+    else if(const MultiLineString* mls = dynamic_cast<const MultiLineString*>(geom)) {
+        for(std::size_t i = 0, n = mls->getNumGeometries(); i < n; ++i) {
+            const LineString* l = dynamic_cast<const LineString*>(mls->getGeometryN(i));
+            updateLocationInfo(locate(p, l));
+        }
+    }
+    else if(const MultiPolygon* mpo = dynamic_cast<const MultiPolygon*>(geom)) {
+        for(std::size_t i = 0, n = mpo->getNumGeometries(); i < n; ++i) {
+            const Polygon* p_po = dynamic_cast<const Polygon*>(mpo->getGeometryN(i));
+            updateLocationInfo(locate(p, p_po));
+        }
+    }
+    else if(const GeometryCollection* col = dynamic_cast<const GeometryCollection*>(geom)) {
+        for(GeometryCollection::const_iterator
+                it = col->begin(), endIt = col->end();
+                it != endIt;
+                ++it) {
+            const Geometry* g2 = *it;
+            assert(g2 != geom); // is this check really needed ?
+            computeLocation(p, g2);
+        }
+    }
 
 }
 
@@ -109,81 +110,96 @@ PointLocator::computeLocation(const Coordinate& p, const Geometry *geom)
 void
 PointLocator::updateLocationInfo(int loc)
 {
-	if (loc==Location::INTERIOR) isIn=true;
-	if (loc==Location::BOUNDARY) ++numBoundaries;
+    if(loc == Location::INTERIOR) {
+        isIn = true;
+    }
+    if(loc == Location::BOUNDARY) {
+        ++numBoundaries;
+    }
 }
 
 /* private */
 int
-PointLocator::locate(const Coordinate& p, const Point *pt)
+PointLocator::locate(const Coordinate& p, const Point* pt)
 {
-	// no point in doing envelope test, since equality test is just as fast
-	const Coordinate *ptCoord = pt->getCoordinate();
-	if (ptCoord->equals2D(p))
-		return Location::INTERIOR;
-	return Location::EXTERIOR;
+    // no point in doing envelope test, since equality test is just as fast
+    const Coordinate* ptCoord = pt->getCoordinate();
+    if(ptCoord->equals2D(p)) {
+        return Location::INTERIOR;
+    }
+    return Location::EXTERIOR;
 }
 
 /* private */
 int
-PointLocator::locate(const Coordinate& p, const LineString *l)
+PointLocator::locate(const Coordinate& p, const LineString* l)
 {
-	if (!l->getEnvelopeInternal()->intersects(p))
-		return Location::EXTERIOR;
-
-	const CoordinateSequence* seq = l->getCoordinatesRO();
-	if (! l->isClosed()) {
-		if ((p == seq->getAt(0)) || (p == seq->getAt(seq->getSize()-1))) {
-			return Location::BOUNDARY;
-		}
-	}
-	if (PointLocation::isOnLine(p, seq)) {
-		return Location::INTERIOR;
-    }
-	return Location::EXTERIOR;
+    if(!l->getEnvelopeInternal()->intersects(p)) {
+        return Location::EXTERIOR;
+    }
+
+    const CoordinateSequence* seq = l->getCoordinatesRO();
+    if(! l->isClosed()) {
+        if((p == seq->getAt(0)) || (p == seq->getAt(seq->getSize() - 1))) {
+            return Location::BOUNDARY;
+        }
+    }
+    if(PointLocation::isOnLine(p, seq)) {
+        return Location::INTERIOR;
+    }
+    return Location::EXTERIOR;
 }
 
 /* private */
 int
-PointLocator::locateInPolygonRing(const Coordinate& p, const LinearRing *ring)
+PointLocator::locateInPolygonRing(const Coordinate& p, const LinearRing* ring)
 {
-	if (!ring->getEnvelopeInternal()->intersects(p)) {
-		return Location::EXTERIOR;
-	}
+    if(!ring->getEnvelopeInternal()->intersects(p)) {
+        return Location::EXTERIOR;
+    }
 
-	const CoordinateSequence *cl = ring->getCoordinatesRO();
+    const CoordinateSequence* cl = ring->getCoordinatesRO();
 
-	if (PointLocation::isOnLine(p,cl)) {
-		return Location::BOUNDARY;
+    if(PointLocation::isOnLine(p, cl)) {
+        return Location::BOUNDARY;
     }
-	if (PointLocation::isInRing(p,cl)) {
-		return Location::INTERIOR;
+    if(PointLocation::isInRing(p, cl)) {
+        return Location::INTERIOR;
     }
-	return Location::EXTERIOR;
+    return Location::EXTERIOR;
 }
 
 /* private */
 int
-PointLocator::locate(const Coordinate& p,const Polygon *poly)
+PointLocator::locate(const Coordinate& p, const Polygon* poly)
 {
-	if (poly->isEmpty()) return Location::EXTERIOR;
-
-	const LinearRing *shell=dynamic_cast<const LinearRing *>(poly->getExteriorRing());
-	assert(shell);
-
-	int shellLoc=locateInPolygonRing(p, shell);
-	if (shellLoc==Location::EXTERIOR) return Location::EXTERIOR;
-	if (shellLoc==Location::BOUNDARY) return Location::BOUNDARY;
-
-	// now test if the point lies in or on the holes
-	for(size_t i=0, n=poly->getNumInteriorRing(); i<n; ++i)
-	{
-		const LinearRing *hole=dynamic_cast<const LinearRing *>(poly->getInteriorRingN(i));
-		int holeLoc=locateInPolygonRing(p,hole);
-		if (holeLoc==Location::INTERIOR) return Location::EXTERIOR;
-		if (holeLoc==Location::BOUNDARY) return Location::BOUNDARY;
-	}
-	return Location::INTERIOR;
+    if(poly->isEmpty()) {
+        return Location::EXTERIOR;
+    }
+
+    const LinearRing* shell = dynamic_cast<const LinearRing*>(poly->getExteriorRing());
+    assert(shell);
+
+    int shellLoc = locateInPolygonRing(p, shell);
+    if(shellLoc == Location::EXTERIOR) {
+        return Location::EXTERIOR;
+    }
+    if(shellLoc == Location::BOUNDARY) {
+        return Location::BOUNDARY;
+    }
+
+    // now test if the point lies in or on the holes
+    for(size_t i = 0, n = poly->getNumInteriorRing(); i < n; ++i) {
+        const LinearRing* hole = dynamic_cast<const LinearRing*>(poly->getInteriorRingN(i));
+        int holeLoc = locateInPolygonRing(p, hole);
+        if(holeLoc == Location::INTERIOR) {
+            return Location::EXTERIOR;
+        }
+        if(holeLoc == Location::BOUNDARY) {
+            return Location::BOUNDARY;
+        }
+    }
+    return Location::INTERIOR;
 }
 
 } // namespace geos.algorithm
diff --git a/src/algorithm/RayCrossingCounter.cpp b/src/algorithm/RayCrossingCounter.cpp
index c2853f6..6593bb0 100644
--- a/src/algorithm/RayCrossingCounter.cpp
+++ b/src/algorithm/RayCrossingCounter.cpp
@@ -39,143 +39,144 @@ namespace algorithm {
 //
 /*static*/ int
 RayCrossingCounter::locatePointInRing(const geom::Coordinate& point,
-                         const geom::CoordinateSequence& ring)
+                                      const geom::CoordinateSequence& ring)
 {
-	RayCrossingCounter rcc(point);
+    RayCrossingCounter rcc(point);
 
-	for (std::size_t i = 1, ni = ring.size(); i < ni; i++)
-	{
-		const geom::Coordinate & p1 = ring[ i - 1 ];
-		const geom::Coordinate & p2 = ring[ i ];
+    for(std::size_t i = 1, ni = ring.size(); i < ni; i++) {
+        const geom::Coordinate& p1 = ring[ i - 1 ];
+        const geom::Coordinate& p2 = ring[ i ];
 
-		rcc.countSegment(p1, p2);
+        rcc.countSegment(p1, p2);
 
-		if ( rcc.isOnSegment() )
-			return rcc.getLocation();
-	}
-	return rcc.getLocation();
+        if(rcc.isOnSegment()) {
+            return rcc.getLocation();
+        }
+    }
+    return rcc.getLocation();
 }
 
 /*static*/ int
 RayCrossingCounter::locatePointInRing(const geom::Coordinate& point,
-	         const std::vector<const geom::Coordinate*>& ring)
+                                      const std::vector<const geom::Coordinate*>& ring)
 {
-	RayCrossingCounter rcc(point);
+    RayCrossingCounter rcc(point);
 
-	for (std::size_t i = 1, ni = ring.size(); i < ni; i++)
-	{
-		const geom::Coordinate & p1 = *ring[ i - 1 ];
-		const geom::Coordinate & p2 = *ring[ i ];
+    for(std::size_t i = 1, ni = ring.size(); i < ni; i++) {
+        const geom::Coordinate& p1 = *ring[ i - 1 ];
+        const geom::Coordinate& p2 = *ring[ i ];
 
-		rcc.countSegment(p1, p2);
+        rcc.countSegment(p1, p2);
 
-		if ( rcc.isOnSegment() )
-			return rcc.getLocation();
-	}
-	return rcc.getLocation();
+        if(rcc.isOnSegment()) {
+            return rcc.getLocation();
+        }
+    }
+    return rcc.getLocation();
 }
 
 /*public static*/
 int
 RayCrossingCounter::orientationIndex(const geom::Coordinate& p1,
-         const geom::Coordinate& p2, const geom::Coordinate& q)
+                                     const geom::Coordinate& p2, const geom::Coordinate& q)
 {
-	// travelling along p1->p2, turn counter clockwise to get to q return 1,
-	// travelling along p1->p2, turn clockwise to get to q return -1,
-	// p1, p2 and q are colinear return 0.
-	double dx1=p2.x-p1.x;
-	double dy1=p2.y-p1.y;
-	double dx2=q.x-p2.x;
-	double dy2=q.y-p2.y;
-	return CGAlgorithmsDD::signOfDet2x2(dx1,dy1,dx2,dy2);
+    // travelling along p1->p2, turn counter clockwise to get to q return 1,
+    // travelling along p1->p2, turn clockwise to get to q return -1,
+    // p1, p2 and q are colinear return 0.
+    double dx1 = p2.x - p1.x;
+    double dy1 = p2.y - p1.y;
+    double dx2 = q.x - p2.x;
+    double dy2 = q.y - p2.y;
+    return CGAlgorithmsDD::signOfDet2x2(dx1, dy1, dx2, dy2);
 }
 
 void
 RayCrossingCounter::countSegment(const geom::Coordinate& p1,
                                  const geom::Coordinate& p2)
 {
-	// For each segment, check if it crosses
-	// a horizontal ray running from the test point in
-	// the positive x direction.
-
-	// check if the segment is strictly to the left of the test point
-	if (p1.x < point.x && p2.x < point.x)
-		return;
-
-	// check if the point is equal to the current ring vertex
-	if (point.x == p2.x && point.y == p2.y)
-	{
-		isPointOnSegment = true;
-		return;
-	}
-
-	// For horizontal segments, check if the point is on the segment.
-	// Otherwise, horizontal segments are not counted.
-	if (p1.y == point.y && p2.y == point.y)
-	{
-		double minx = p1.x;
-		double maxx = p2.x;
-
-		if (minx > maxx)
-		{
-			minx = p2.x;
-			maxx = p1.x;
-		}
-
-		if (point.x >= minx && point.x <= maxx)
-			isPointOnSegment = true;
-
-		return;
-	}
-
-	// Evaluate all non-horizontal segments which cross a horizontal ray
-	// to the right of the test pt.
-	// To avoid double-counting shared vertices, we use the convention that
-	// - an upward edge includes its starting endpoint, and excludes its
-	//   final endpoint
-	// - a downward edge excludes its starting endpoint, and includes its
-	//   final endpoint
-	if (((p1.y > point.y) && (p2.y <= point.y)) ||
-		((p2.y > point.y) && (p1.y <= point.y)) )
-	{
-		// For an upward edge, orientationIndex will be positive when p1->p2
-		// crosses ray. Conversely, downward edges should have negative sign.
-		int sign = orientationIndex(p1, p2, point);
-		if (sign == 0)
-		{
-			isPointOnSegment = true;
-			return;
-		}
-
-		if (p2.y < p1.y)
-			sign = -sign;
-
-		// The segment crosses the ray if the sign is strictly positive.
-		if (sign > 0)
-			crossingCount++;
-	}
+    // For each segment, check if it crosses
+    // a horizontal ray running from the test point in
+    // the positive x direction.
+
+    // check if the segment is strictly to the left of the test point
+    if(p1.x < point.x && p2.x < point.x) {
+        return;
+    }
+
+    // check if the point is equal to the current ring vertex
+    if(point.x == p2.x && point.y == p2.y) {
+        isPointOnSegment = true;
+        return;
+    }
+
+    // For horizontal segments, check if the point is on the segment.
+    // Otherwise, horizontal segments are not counted.
+    if(p1.y == point.y && p2.y == point.y) {
+        double minx = p1.x;
+        double maxx = p2.x;
+
+        if(minx > maxx) {
+            minx = p2.x;
+            maxx = p1.x;
+        }
+
+        if(point.x >= minx && point.x <= maxx) {
+            isPointOnSegment = true;
+        }
+
+        return;
+    }
+
+    // Evaluate all non-horizontal segments which cross a horizontal ray
+    // to the right of the test pt.
+    // To avoid double-counting shared vertices, we use the convention that
+    // - an upward edge includes its starting endpoint, and excludes its
+    //   final endpoint
+    // - a downward edge excludes its starting endpoint, and includes its
+    //   final endpoint
+    if(((p1.y > point.y) && (p2.y <= point.y)) ||
+            ((p2.y > point.y) && (p1.y <= point.y))) {
+        // For an upward edge, orientationIndex will be positive when p1->p2
+        // crosses ray. Conversely, downward edges should have negative sign.
+        int sign = orientationIndex(p1, p2, point);
+        if(sign == 0) {
+            isPointOnSegment = true;
+            return;
+        }
+
+        if(p2.y < p1.y) {
+            sign = -sign;
+        }
+
+        // The segment crosses the ray if the sign is strictly positive.
+        if(sign > 0) {
+            crossingCount++;
+        }
+    }
 }
 
 
 int
 RayCrossingCounter::getLocation()
 {
-	if (isPointOnSegment)
-		return geom::Location::BOUNDARY;
+    if(isPointOnSegment) {
+        return geom::Location::BOUNDARY;
+    }
 
-	// The point is in the interior of the ring if the number
-	// of X-crossings is odd.
-	if ((crossingCount % 2) == 1)
-		return geom::Location::INTERIOR;
+    // The point is in the interior of the ring if the number
+    // of X-crossings is odd.
+    if((crossingCount % 2) == 1) {
+        return geom::Location::INTERIOR;
+    }
 
-	return geom::Location::EXTERIOR;
+    return geom::Location::EXTERIOR;
 }
 
 
 bool
 RayCrossingCounter::isPointInPolygon()
 {
-	return getLocation() != geom::Location::EXTERIOR;
+    return getLocation() != geom::Location::EXTERIOR;
 }
 
 
diff --git a/src/algorithm/RayCrossingCounterDD.cpp b/src/algorithm/RayCrossingCounterDD.cpp
index 44a7bf6..bc9430f 100644
--- a/src/algorithm/RayCrossingCounterDD.cpp
+++ b/src/algorithm/RayCrossingCounterDD.cpp
@@ -44,14 +44,15 @@ RayCrossingCounterDD::locatePointInRing(const geom::Coordinate& point,
 {
     RayCrossingCounterDD rcc(point);
 
-    for (std::size_t i = 1, ni = ring.size(); i < ni; i++) {
-        const geom::Coordinate & p1 = ring[ i - 1 ];
-        const geom::Coordinate & p2 = ring[ i ];
+    for(std::size_t i = 1, ni = ring.size(); i < ni; i++) {
+        const geom::Coordinate& p1 = ring[ i - 1 ];
+        const geom::Coordinate& p2 = ring[ i ];
 
         rcc.countSegment(p1, p2);
 
-        if (rcc.isOnSegment())
+        if(rcc.isOnSegment()) {
             return rcc.getLocation();
+        }
     }
     return rcc.getLocation();
 }
@@ -63,14 +64,15 @@ RayCrossingCounterDD::locatePointInRing(const geom::Coordinate& point,
 {
     RayCrossingCounterDD rcc(point);
 
-    for (std::size_t i = 1, ni = ring.size(); i < ni; i++) {
-        const geom::Coordinate & p1 = *ring[ i - 1 ];
-        const geom::Coordinate & p2 = *ring[ i ];
+    for(std::size_t i = 1, ni = ring.size(); i < ni; i++) {
+        const geom::Coordinate& p1 = *ring[ i - 1 ];
+        const geom::Coordinate& p2 = *ring[ i ];
 
         rcc.countSegment(p1, p2);
 
-        if (rcc.isOnSegment())
+        if(rcc.isOnSegment()) {
             return rcc.getLocation();
+        }
     }
     return rcc.getLocation();
 }
@@ -92,28 +94,30 @@ RayCrossingCounterDD::countSegment(const geom::Coordinate& p1,
     // the positive x direction.
 
     // check if the segment is strictly to the left of the test point
-    if (p1.x < point.x && p2.x < point.x)
+    if(p1.x < point.x && p2.x < point.x) {
         return;
+    }
 
     // check if the point is equal to the current ring vertex
-    if (point.x == p2.x && point.y == p2.y) {
+    if(point.x == p2.x && point.y == p2.y) {
         isPointOnSegment = true;
         return;
     }
 
     // For horizontal segments, check if the point is on the segment.
     // Otherwise, horizontal segments are not counted.
-    if (p1.y == point.y && p2.y == point.y) {
+    if(p1.y == point.y && p2.y == point.y) {
         double minx = p1.x;
         double maxx = p2.x;
 
-        if (minx > maxx) {
+        if(minx > maxx) {
             minx = p2.x;
             maxx = p1.x;
         }
 
-        if (point.x >= minx && point.x <= maxx)
+        if(point.x >= minx && point.x <= maxx) {
             isPointOnSegment = true;
+        }
 
         return;
     }
@@ -125,22 +129,24 @@ RayCrossingCounterDD::countSegment(const geom::Coordinate& p1,
     //   final endpoint
     // - a downward edge excludes its starting endpoint, and includes its
     //   final endpoint
-    if (((p1.y > point.y) && (p2.y <= point.y)) ||
+    if(((p1.y > point.y) && (p2.y <= point.y)) ||
             ((p2.y > point.y) && (p1.y <= point.y))) {
         // For an upward edge, orientationIndex will be positive when p1->p2
         // crosses ray. Conversely, downward edges should have negative sign.
         int sign = CGAlgorithmsDD::orientationIndex(p1, p2, point);
-        if (sign == CGAlgorithmsDD::STRAIGHT) {
+        if(sign == CGAlgorithmsDD::STRAIGHT) {
             isPointOnSegment = true;
             return;
         }
 
-        if (p2.y < p1.y)
+        if(p2.y < p1.y) {
             sign = -sign;
+        }
 
         // The segment crosses the ray if the sign is strictly positive.
-        if (sign == CGAlgorithmsDD::LEFT)
+        if(sign == CGAlgorithmsDD::LEFT) {
             crossingCount++;
+        }
     }
 }
 
@@ -148,13 +154,15 @@ RayCrossingCounterDD::countSegment(const geom::Coordinate& p1,
 int
 RayCrossingCounterDD::getLocation()
 {
-    if (isPointOnSegment)
+    if(isPointOnSegment) {
         return geom::Location::BOUNDARY;
+    }
 
     // The point is in the interior of the ring if the number
     // of X-crossings is odd.
-    if ((crossingCount % 2) == 1)
+    if((crossingCount % 2) == 1) {
         return geom::Location::INTERIOR;
+    }
 
     return geom::Location::EXTERIOR;
 }
diff --git a/src/algorithm/RobustDeterminant.cpp b/src/algorithm/RobustDeterminant.cpp
index 80cef7d..c2676cf 100644
--- a/src/algorithm/RobustDeterminant.cpp
+++ b/src/algorithm/RobustDeterminant.cpp
@@ -49,238 +49,264 @@ namespace geos {
 namespace algorithm { // geos.algorithm
 
 
-int RobustDeterminant::signOfDet2x2(double x1,double y1,double x2,double y2) {
-	// returns -1 if the determinant is negative,
-	// returns  1 if the determinant is positive,
-	// retunrs  0 if the determinant is null.
-	int sign=1;
-	double swap;
-	double k;
+int
+RobustDeterminant::signOfDet2x2(double x1, double y1, double x2, double y2)
+{
+    // returns -1 if the determinant is negative,
+    // returns  1 if the determinant is positive,
+    // retunrs  0 if the determinant is null.
+    int sign = 1;
+    double swap;
+    double k;
 
-  // Protect against non-finite numbers
-  if ( !std::isfinite(x1) || !std::isfinite(y1) || !std::isfinite(x2) || !std::isfinite(y2) )
-  {
-    throw util::IllegalArgumentException("RobustDeterminant encountered non-finite numbers ");
-  }
+    // Protect against non-finite numbers
+    if(!std::isfinite(x1) || !std::isfinite(y1) || !std::isfinite(x2) || !std::isfinite(y2)) {
+        throw util::IllegalArgumentException("RobustDeterminant encountered non-finite numbers ");
+    }
 
-	/*
-	*  testing null entries
-	*/
-	if ((x1==0.0) || (y2==0.0)) {
-		if ((y1==0.0) || (x2==0.0)) {
-			return 0;
-		} else if (y1>0) {
-			if (x2>0) {
-				return -sign;
-			} else {
-				return sign;
-			}
-		} else {
-			if (x2>0) {
-				return sign;
-			} else {
-				return -sign;
-			}
-		}
-	}
-	if ((y1==0.0) || (x2==0.0)) {
-		if (y2>0) {
-			if (x1>0) {
-				return sign;
-			} else {
-				return -sign;
-			}
-		} else {
-			if (x1>0) {
-				return -sign;
-			} else {
-				return sign;
-			}
-		}
-	}
+    /*
+    *  testing null entries
+    */
+    if((x1 == 0.0) || (y2 == 0.0)) {
+        if((y1 == 0.0) || (x2 == 0.0)) {
+            return 0;
+        }
+        else if(y1 > 0) {
+            if(x2 > 0) {
+                return -sign;
+            }
+            else {
+                return sign;
+            }
+        }
+        else {
+            if(x2 > 0) {
+                return sign;
+            }
+            else {
+                return -sign;
+            }
+        }
+    }
+    if((y1 == 0.0) || (x2 == 0.0)) {
+        if(y2 > 0) {
+            if(x1 > 0) {
+                return sign;
+            }
+            else {
+                return -sign;
+            }
+        }
+        else {
+            if(x1 > 0) {
+                return -sign;
+            }
+            else {
+                return sign;
+            }
+        }
+    }
 
-	/*
-	*  making y coordinates positive and permuting the entries
-	*  so that y2 is the biggest one
-	*/
-	if (0.0<y1) {
-		if (0.0<y2) {
-			if (y1<=y2) {
-				;
-			} else {
-				sign=-sign;
-				swap=x1;
-				x1=x2;
-				x2=swap;
-				swap=y1;
-				y1=y2;
-				y2=swap;
-			}
-		} else {
-			if (y1<=-y2) {
-				sign=-sign;
-				x2=-x2;
-				y2=-y2;
-			} else {
-				swap=x1;
-				x1=-x2;
-				x2=swap;
-				swap=y1;
-				y1=-y2;
-				y2=swap;
-			}
-		}
-	} else {
-		if (0.0<y2) {
-			if (-y1<=y2) {
-				sign=-sign;
-				x1=-x1;
-				y1=-y1;
-			} else {
-				swap=-x1;
-				x1=x2;
-				x2=swap;
-				swap=-y1;
-				y1=y2;
-				y2=swap;
-			}
-		} else {
-			if (y1>=y2) {
-				x1=-x1;
-				y1=-y1;
-				x2=-x2;
-				y2=-y2;
-			} else {
-				sign=-sign;
-				swap=-x1;
-				x1=-x2;
-				x2=swap;
-				swap=-y1;
-				y1=-y2;
-				y2=swap;
-			}
-		}
-	}
+    /*
+    *  making y coordinates positive and permuting the entries
+    *  so that y2 is the biggest one
+    */
+    if(0.0 < y1) {
+        if(0.0 < y2) {
+            if(y1 <= y2) {
+                ;
+            }
+            else {
+                sign = -sign;
+                swap = x1;
+                x1 = x2;
+                x2 = swap;
+                swap = y1;
+                y1 = y2;
+                y2 = swap;
+            }
+        }
+        else {
+            if(y1 <= -y2) {
+                sign = -sign;
+                x2 = -x2;
+                y2 = -y2;
+            }
+            else {
+                swap = x1;
+                x1 = -x2;
+                x2 = swap;
+                swap = y1;
+                y1 = -y2;
+                y2 = swap;
+            }
+        }
+    }
+    else {
+        if(0.0 < y2) {
+            if(-y1 <= y2) {
+                sign = -sign;
+                x1 = -x1;
+                y1 = -y1;
+            }
+            else {
+                swap = -x1;
+                x1 = x2;
+                x2 = swap;
+                swap = -y1;
+                y1 = y2;
+                y2 = swap;
+            }
+        }
+        else {
+            if(y1 >= y2) {
+                x1 = -x1;
+                y1 = -y1;
+                x2 = -x2;
+                y2 = -y2;
+            }
+            else {
+                sign = -sign;
+                swap = -x1;
+                x1 = -x2;
+                x2 = swap;
+                swap = -y1;
+                y1 = -y2;
+                y2 = swap;
+            }
+        }
+    }
 
-	/*
-	*  making x coordinates positive
-	*/
-	/*
-	*  if |x2|<|x1| one can conclude
-	*/
-	if (0.0<x1) {
-		if (0.0<x2) {
-			if (x1 <= x2) {
-				;
-			} else {
-				return sign;
-			}
-		} else {
-			return sign;
-		}
-	} else {
-		if (0.0<x2) {
-			return -sign;
-		} else {
-			if (x1 >= x2) {
-				sign=-sign;
-				x1=-x1;
-				x2=-x2;
-			} else {
-				return -sign;
-			}
-		}
-	}
+    /*
+    *  making x coordinates positive
+    */
+    /*
+    *  if |x2|<|x1| one can conclude
+    */
+    if(0.0 < x1) {
+        if(0.0 < x2) {
+            if(x1 <= x2) {
+                ;
+            }
+            else {
+                return sign;
+            }
+        }
+        else {
+            return sign;
+        }
+    }
+    else {
+        if(0.0 < x2) {
+            return -sign;
+        }
+        else {
+            if(x1 >= x2) {
+                sign = -sign;
+                x1 = -x1;
+                x2 = -x2;
+            }
+            else {
+                return -sign;
+            }
+        }
+    }
 
-	/*
-	*  all entries strictly positive   x1 <= x2 and y1 <= y2
-	*/
-	while (true) {
-		k=std::floor(x2/x1);
-		x2=x2-k*x1;
-		y2=y2-k*y1;
+    /*
+    *  all entries strictly positive   x1 <= x2 and y1 <= y2
+    */
+    while(true) {
+        k = std::floor(x2 / x1);
+        x2 = x2 - k * x1;
+        y2 = y2 - k * y1;
 
-		/*
-		*  testing if R (new U2) is in U1 rectangle
-		*/
-		if (y2<0.0) {
-			return -sign;
-		}
-		if (y2>y1) {
-			return sign;
-		}
+        /*
+        *  testing if R (new U2) is in U1 rectangle
+        */
+        if(y2 < 0.0) {
+            return -sign;
+        }
+        if(y2 > y1) {
+            return sign;
+        }
 
-		/*
-		*  finding R'
-		*/
-		if (x1>x2+x2) {
-			if (y1<y2+y2) {
-				return sign;
-			}
-		} else {
-			if (y1>y2+y2) {
-				return -sign;
-			} else {
-				x2=x1-x2;
-				y2=y1-y2;
-				sign=-sign;
-			}
-		}
-		if (y2==0.0) {
-			if (x2==0.0) {
-				return 0;
-			} else {
-				return -sign;
-			}
-		}
-		if (x2==0.0) {
-			return sign;
-		}
+        /*
+        *  finding R'
+        */
+        if(x1 > x2 + x2) {
+            if(y1 < y2 + y2) {
+                return sign;
+            }
+        }
+        else {
+            if(y1 > y2 + y2) {
+                return -sign;
+            }
+            else {
+                x2 = x1 - x2;
+                y2 = y1 - y2;
+                sign = -sign;
+            }
+        }
+        if(y2 == 0.0) {
+            if(x2 == 0.0) {
+                return 0;
+            }
+            else {
+                return -sign;
+            }
+        }
+        if(x2 == 0.0) {
+            return sign;
+        }
 
-		/*
-		*  exchange 1 and 2 role.
-		*/
-		k=std::floor(x1/x2);
-		x1=x1-k*x2;
-		y1=y1-k*y2;
+        /*
+        *  exchange 1 and 2 role.
+        */
+        k = std::floor(x1 / x2);
+        x1 = x1 - k * x2;
+        y1 = y1 - k * y2;
 
-		/*
-		*  testing if R (new U1) is in U2 rectangle
-		*/
-		if (y1<0.0) {
-			return sign;
-		}
-		if (y1>y2) {
-			return -sign;
-		}
+        /*
+        *  testing if R (new U1) is in U2 rectangle
+        */
+        if(y1 < 0.0) {
+            return sign;
+        }
+        if(y1 > y2) {
+            return -sign;
+        }
 
-		/*
-		*  finding R'
-		*/
-		if (x2>x1+x1) {
-			if (y2<y1+y1) {
-				return -sign;
-			}
-		} else {
-			if (y2>y1+y1) {
-				return sign;
-			} else {
-				x1=x2-x1;
-				y1=y2-y1;
-				sign=-sign;
-			}
-		}
-		if (y1==0.0) {
-			if (x1==0.0) {
-				return 0;
-			} else {
-				return sign;
-			}
-		}
-		if (x1==0.0) {
-			return -sign;
-		}
-	}
+        /*
+        *  finding R'
+        */
+        if(x2 > x1 + x1) {
+            if(y2 < y1 + y1) {
+                return -sign;
+            }
+        }
+        else {
+            if(y2 > y1 + y1) {
+                return sign;
+            }
+            else {
+                x1 = x2 - x1;
+                y1 = y2 - y1;
+                sign = -sign;
+            }
+        }
+        if(y1 == 0.0) {
+            if(x1 == 0.0) {
+                return 0;
+            }
+            else {
+                return sign;
+            }
+        }
+        if(x1 == 0.0) {
+            return -sign;
+        }
+    }
 }
 } // namespace geos.algorithm
 } // namespace geos
diff --git a/src/algorithm/SimplePointInRing.cpp b/src/algorithm/SimplePointInRing.cpp
index b45a446..a3fff70 100644
--- a/src/algorithm/SimplePointInRing.cpp
+++ b/src/algorithm/SimplePointInRing.cpp
@@ -19,23 +19,27 @@
 
 // Forward declarations
 namespace geos {
-	namespace geom {
-		class Coordinate;
-	}
+namespace geom {
+class Coordinate;
+}
 }
 
 namespace geos {
 namespace algorithm { // geos.algorithm
 
-SimplePointInRing::SimplePointInRing(geom::LinearRing *ring){
-	pts=ring->getCoordinatesRO();
+SimplePointInRing::SimplePointInRing(geom::LinearRing* ring)
+{
+    pts = ring->getCoordinatesRO();
 }
 
-SimplePointInRing::~SimplePointInRing(){
+SimplePointInRing::~SimplePointInRing()
+{
 }
 
-bool SimplePointInRing::isInside(const geom::Coordinate& pt){
-	return PointLocation::isInRing(pt,pts);
+bool
+SimplePointInRing::isInside(const geom::Coordinate& pt)
+{
+    return PointLocation::isInRing(pt, pts);
 }
 
 } // namespace geos.algorithm
diff --git a/src/algorithm/distance/DiscreteFrechetDistance.cpp b/src/algorithm/distance/DiscreteFrechetDistance.cpp
index f194336..408d858 100644
--- a/src/algorithm/distance/DiscreteFrechetDistance.cpp
+++ b/src/algorithm/distance/DiscreteFrechetDistance.cpp
@@ -36,21 +36,21 @@ namespace distance { // geos.algorithm.distance
 /* static public */
 double
 DiscreteFrechetDistance::distance(const geom::Geometry& g0,
-			       const geom::Geometry& g1)
+                                  const geom::Geometry& g1)
 {
-	DiscreteFrechetDistance dist(g0, g1);
-	return dist.distance();
+    DiscreteFrechetDistance dist(g0, g1);
+    return dist.distance();
 }
 
 /* static public */
 double
 DiscreteFrechetDistance::distance(const geom::Geometry& g0,
-			       const geom::Geometry& g1,
-			       double densifyFrac)
+                                  const geom::Geometry& g1,
+                                  double densifyFrac)
 {
-	DiscreteFrechetDistance dist(g0, g1);
-	dist.setDensifyFraction(densifyFrac);
-	return dist.distance();
+    DiscreteFrechetDistance dist(g0, g1);
+    dist.setDensifyFraction(densifyFrac);
+    return dist.distance();
 }
 
 /* private */
@@ -58,97 +58,89 @@ DiscreteFrechetDistance::distance(const geom::Geometry& g0,
 geom::Coordinate
 DiscreteFrechetDistance::getSegementAt(const CoordinateSequence& seq, size_t index)
 {
-	if (densifyFrac > 0.0)
-	{
-		size_t numSubSegs =  std::size_t(util::round(1.0/densifyFrac));
-		size_t i = index / numSubSegs;
-		size_t j = index % numSubSegs;
-		if (i >= seq.size()-1) {
-			return seq.getAt(seq.size()-1);
-		}
-		const geom::Coordinate& p0 = seq.getAt(i);
-		const geom::Coordinate& p1 = seq.getAt(i+1);
+    if(densifyFrac > 0.0) {
+        size_t numSubSegs =  std::size_t(util::round(1.0 / densifyFrac));
+        size_t i = index / numSubSegs;
+        size_t j = index % numSubSegs;
+        if(i >= seq.size() - 1) {
+            return seq.getAt(seq.size() - 1);
+        }
+        const geom::Coordinate& p0 = seq.getAt(i);
+        const geom::Coordinate& p1 = seq.getAt(i + 1);
 
-		double delx = (p1.x - p0.x)/static_cast<double>(numSubSegs);
-		double dely = (p1.y - p0.y)/static_cast<double>(numSubSegs);
+        double delx = (p1.x - p0.x) / static_cast<double>(numSubSegs);
+        double dely = (p1.y - p0.y) / static_cast<double>(numSubSegs);
 
-		double x = p0.x + static_cast<double>(j)*delx;
-		double y = p0.y + static_cast<double>(j)*dely;
-		Coordinate pt(x, y);
-		return pt;
-	}
-	else
-	{
-		return seq.getAt(index);
-	}
+        double x = p0.x + static_cast<double>(j) * delx;
+        double y = p0.y + static_cast<double>(j) * dely;
+        Coordinate pt(x, y);
+        return pt;
+    }
+    else {
+        return seq.getAt(index);
+    }
 }
 
 PointPairDistance&
-DiscreteFrechetDistance::getFrecheDistance(std::vector< std::vector<PointPairDistance> >& ca, size_t i, size_t j, const CoordinateSequence& p, const CoordinateSequence& q)
+DiscreteFrechetDistance::getFrecheDistance(std::vector< std::vector<PointPairDistance> >& ca, size_t i, size_t j,
+        const CoordinateSequence& p, const CoordinateSequence& q)
 {
-	PointPairDistance p_ptDist;
-	if (! ca[i][j].getIsNull())
-	{
-		return ca[i][j];
-	}
-	p_ptDist.initialize(getSegementAt(p, i), getSegementAt(q, j));
-	if (i == 0 && j == 0)
-	{
-		ca[i][j] = ptDist;
-	}
-	else if (i > 0 && j == 0)
-	{
-		PointPairDistance nextDist = getFrecheDistance(ca,i-1,0,p,q);
-		ca[i][j] =  (nextDist.getDistance() > p_ptDist.getDistance()) ? nextDist : p_ptDist;
-	}
-	else if (i == 0 && j > 0)
-	{
-		PointPairDistance nextDist = getFrecheDistance(ca,0,j-1,p,q);
-		ca[i][j] =  (nextDist.getDistance() > p_ptDist.getDistance()) ? nextDist : p_ptDist;
-	}
-	else
-	{
-		PointPairDistance d1 = getFrecheDistance(ca,i-1,j,p,q),
-				  d2 = getFrecheDistance(ca,i-1,j-1,p,q),
-				  d3 = getFrecheDistance(ca,i,j-1,p,q);
-		PointPairDistance& minDist = (d1.getDistance() < d2.getDistance()) ? d1 : d2;
-		if (d3.getDistance() < minDist.getDistance()) minDist = d3;
-		ca[i][j] =  (minDist.getDistance() > p_ptDist.getDistance()) ? minDist : p_ptDist;
-	}
+    PointPairDistance p_ptDist;
+    if(! ca[i][j].getIsNull()) {
+        return ca[i][j];
+    }
+    p_ptDist.initialize(getSegementAt(p, i), getSegementAt(q, j));
+    if(i == 0 && j == 0) {
+        ca[i][j] = ptDist;
+    }
+    else if(i > 0 && j == 0) {
+        PointPairDistance nextDist = getFrecheDistance(ca, i - 1, 0, p, q);
+        ca[i][j] = (nextDist.getDistance() > p_ptDist.getDistance()) ? nextDist : p_ptDist;
+    }
+    else if(i == 0 && j > 0) {
+        PointPairDistance nextDist = getFrecheDistance(ca, 0, j - 1, p, q);
+        ca[i][j] = (nextDist.getDistance() > p_ptDist.getDistance()) ? nextDist : p_ptDist;
+    }
+    else {
+        PointPairDistance d1 = getFrecheDistance(ca, i - 1, j, p, q),
+                          d2 = getFrecheDistance(ca, i - 1, j - 1, p, q),
+                          d3 = getFrecheDistance(ca, i, j - 1, p, q);
+        PointPairDistance& minDist = (d1.getDistance() < d2.getDistance()) ? d1 : d2;
+        if(d3.getDistance() < minDist.getDistance()) {
+            minDist = d3;
+        }
+        ca[i][j] = (minDist.getDistance() > p_ptDist.getDistance()) ? minDist : p_ptDist;
+    }
 
-	return ca[i][j];
+    return ca[i][j];
 }
 
 void
 DiscreteFrechetDistance::compute(
-		const geom::Geometry& discreteGeom,
-		const geom::Geometry& geom)
+    const geom::Geometry& discreteGeom,
+    const geom::Geometry& geom)
 {
-	const CoordinateSequence* lp = discreteGeom.getCoordinates();
-	const CoordinateSequence* lq = geom.getCoordinates();
-	size_t pSize, qSize;
-	if (densifyFrac > 0)
-	{
-		size_t numSubSegs =  std::size_t(util::round(1.0/densifyFrac));
-		pSize = numSubSegs * (lp->size() - 1) + 1;
-		qSize = numSubSegs * (lq->size() - 1) + 1;
-	}
-	else
-	{
-		pSize = lp->size();
-		qSize = lq->size();
-	}
-	std::vector< std::vector<PointPairDistance> > ca(pSize, std::vector<PointPairDistance>(qSize));
-	for (size_t i = 0; i < pSize; i++)
-	{
-		for (size_t j = 0; j < qSize; j++)
-		{
-			ca[i][j].initialize();
-		}
-	}
-	ptDist = getFrecheDistance(ca, pSize-1, qSize-1, *lp, *lq);
-	delete lp;
-	delete lq;
+    const CoordinateSequence* lp = discreteGeom.getCoordinates();
+    const CoordinateSequence* lq = geom.getCoordinates();
+    size_t pSize, qSize;
+    if(densifyFrac > 0) {
+        size_t numSubSegs =  std::size_t(util::round(1.0 / densifyFrac));
+        pSize = numSubSegs * (lp->size() - 1) + 1;
+        qSize = numSubSegs * (lq->size() - 1) + 1;
+    }
+    else {
+        pSize = lp->size();
+        qSize = lq->size();
+    }
+    std::vector< std::vector<PointPairDistance> > ca(pSize, std::vector<PointPairDistance>(qSize));
+    for(size_t i = 0; i < pSize; i++) {
+        for(size_t j = 0; j < qSize; j++) {
+            ca[i][j].initialize();
+        }
+    }
+    ptDist = getFrecheDistance(ca, pSize - 1, qSize - 1, *lp, *lq);
+    delete lp;
+    delete lq;
 }
 
 } // namespace geos.algorithm.distance
diff --git a/src/algorithm/distance/DiscreteHausdorffDistance.cpp b/src/algorithm/distance/DiscreteHausdorffDistance.cpp
index 745cc0f..78ddae3 100644
--- a/src/algorithm/distance/DiscreteHausdorffDistance.cpp
+++ b/src/algorithm/distance/DiscreteHausdorffDistance.cpp
@@ -30,13 +30,14 @@ namespace distance { // geos.algorithm.distance
 
 void
 DiscreteHausdorffDistance::MaxDensifiedByFractionDistanceFilter::filter_ro(
-	const geom::CoordinateSequence& seq, size_t index)
+    const geom::CoordinateSequence& seq, size_t index)
 {
     /**
      * This logic also handles skipping Point geometries
      */
-    if (index == 0)
-      return;
+    if(index == 0) {
+        return;
+    }
 
     const geom::Coordinate& p0 = seq.getAt(index - 1);
     const geom::Coordinate& p1 = seq.getAt(index);
@@ -44,13 +45,13 @@ DiscreteHausdorffDistance::MaxDensifiedByFractionDistanceFilter::filter_ro(
     double delx = (p1.x - p0.x) / static_cast<double>(numSubSegs);
     double dely = (p1.y - p0.y) / static_cast<double>(numSubSegs);
 
-    for (size_t i = 0; i < numSubSegs; ++i) {
-      double x = p0.x + static_cast<double>(i) * delx;
-      double y = p0.y + static_cast<double>(i) * dely;
-      Coordinate pt(x, y);
-      minPtDist.initialize();
-      DistanceToPoint::computeDistance(geom, pt, minPtDist);
-      maxPtDist.setMaximum(minPtDist);
+    for(size_t i = 0; i < numSubSegs; ++i) {
+        double x = p0.x + static_cast<double>(i) * delx;
+        double y = p0.y + static_cast<double>(i) * dely;
+        Coordinate pt(x, y);
+        minPtDist.initialize();
+        DistanceToPoint::computeDistance(geom, pt, minPtDist);
+        maxPtDist.setMaximum(minPtDist);
     }
 
 }
@@ -58,41 +59,40 @@ DiscreteHausdorffDistance::MaxDensifiedByFractionDistanceFilter::filter_ro(
 /* static public */
 double
 DiscreteHausdorffDistance::distance(const geom::Geometry& g0,
-	                       const geom::Geometry& g1)
+                                    const geom::Geometry& g1)
 {
-	DiscreteHausdorffDistance dist(g0, g1);
-	return dist.distance();
+    DiscreteHausdorffDistance dist(g0, g1);
+    return dist.distance();
 }
 
 /* static public */
 double
 DiscreteHausdorffDistance::distance(const geom::Geometry& g0,
-	                       const geom::Geometry& g1,
-                               double densifyFrac)
+                                    const geom::Geometry& g1,
+                                    double densifyFrac)
 {
-	DiscreteHausdorffDistance dist(g0, g1);
-	dist.setDensifyFraction(densifyFrac);
-	return dist.distance();
+    DiscreteHausdorffDistance dist(g0, g1);
+    dist.setDensifyFraction(densifyFrac);
+    return dist.distance();
 }
 
 /* private */
 void
 DiscreteHausdorffDistance::computeOrientedDistance(
-		const geom::Geometry& discreteGeom,
-		const geom::Geometry& geom,
-		PointPairDistance& p_ptDist)
+    const geom::Geometry& discreteGeom,
+    const geom::Geometry& geom,
+    PointPairDistance& p_ptDist)
 {
-	MaxPointDistanceFilter distFilter(geom);
-	discreteGeom.apply_ro(&distFilter);
-	p_ptDist.setMaximum(distFilter.getMaxPointDistance());
+    MaxPointDistanceFilter distFilter(geom);
+    discreteGeom.apply_ro(&distFilter);
+    p_ptDist.setMaximum(distFilter.getMaxPointDistance());
 
-	if (densifyFrac > 0)
-	{
-		MaxDensifiedByFractionDistanceFilter fracFilter(geom,
-							  densifyFrac);
-		discreteGeom.apply_ro(fracFilter);
-		ptDist.setMaximum(fracFilter.getMaxPointDistance());
-	}
+    if(densifyFrac > 0) {
+        MaxDensifiedByFractionDistanceFilter fracFilter(geom,
+                densifyFrac);
+        discreteGeom.apply_ro(fracFilter);
+        ptDist.setMaximum(fracFilter.getMaxPointDistance());
+    }
 }
 
 } // namespace geos.algorithm.distance
diff --git a/src/algorithm/distance/DistanceToPoint.cpp b/src/algorithm/distance/DistanceToPoint.cpp
index e6e0bef..706d7df 100644
--- a/src/algorithm/distance/DistanceToPoint.cpp
+++ b/src/algorithm/distance/DistanceToPoint.cpp
@@ -37,81 +37,76 @@ namespace distance { // geos.algorithm.distance
 /* public static */
 void
 DistanceToPoint::computeDistance(const geom::Geometry& geom,
-                                          const geom::Coordinate& pt,
-                                          PointPairDistance& ptDist)
+                                 const geom::Coordinate& pt,
+                                 PointPairDistance& ptDist)
 {
-	if ( const LineString* ls = dynamic_cast<const LineString*>(&geom) )
-	{
-		computeDistance(*ls, pt, ptDist);
-	}
-	else if ( const Polygon* pl = dynamic_cast<const Polygon*>(&geom) )
-	{
-		computeDistance(*pl, pt, ptDist);
-	}
-	else if ( const GeometryCollection* gc = dynamic_cast<const GeometryCollection*>(&geom) )
-	{
-		for (size_t i = 0; i < gc->getNumGeometries(); i++)
-		{
-			const Geometry* g = gc->getGeometryN(i);
-			computeDistance(*g, pt, ptDist);
-		}
-	}
-	else
-	{
-		// assume geom is Point
-		ptDist.setMinimum(*(geom.getCoordinate()), pt);
-	}
+    if(const LineString* ls = dynamic_cast<const LineString*>(&geom)) {
+        computeDistance(*ls, pt, ptDist);
+    }
+    else if(const Polygon* pl = dynamic_cast<const Polygon*>(&geom)) {
+        computeDistance(*pl, pt, ptDist);
+    }
+    else if(const GeometryCollection* gc = dynamic_cast<const GeometryCollection*>(&geom)) {
+        for(size_t i = 0; i < gc->getNumGeometries(); i++) {
+            const Geometry* g = gc->getGeometryN(i);
+            computeDistance(*g, pt, ptDist);
+        }
+    }
+    else {
+        // assume geom is Point
+        ptDist.setMinimum(*(geom.getCoordinate()), pt);
+    }
 }
 
 /* public static */
 void
 DistanceToPoint::computeDistance(const geom::LineString& line,
-                                          const geom::Coordinate& pt,
-                                          PointPairDistance& ptDist)
+                                 const geom::Coordinate& pt,
+                                 PointPairDistance& ptDist)
 {
-	const CoordinateSequence* coordsRO = line.getCoordinatesRO();
-	const CoordinateSequence& coords = *coordsRO;
+    const CoordinateSequence* coordsRO = line.getCoordinatesRO();
+    const CoordinateSequence& coords = *coordsRO;
 
-	size_t npts = coords.size();
-	if ( ! npts ) return; // can this ever be ?
+    size_t npts = coords.size();
+    if(! npts) {
+        return;    // can this ever be ?
+    }
 
-	LineSegment tempSegment;
-	Coordinate closestPt;
+    LineSegment tempSegment;
+    Coordinate closestPt;
 
-	Coordinate* segPts[2] = { &(tempSegment.p0), &(tempSegment.p1) };
-	tempSegment.p0 = coords.getAt(0);
-	for (size_t i=1; i<npts; ++i)
-	{
-		*(segPts[i%2]) = coords.getAt(i);
+    Coordinate* segPts[2] = { &(tempSegment.p0), &(tempSegment.p1) };
+    tempSegment.p0 = coords.getAt(0);
+    for(size_t i = 1; i < npts; ++i) {
+        *(segPts[i % 2]) = coords.getAt(i);
 
-		// this is somewhat inefficient - could do better
-		tempSegment.closestPoint(pt, closestPt);
-		ptDist.setMinimum(closestPt, pt);
-	}
+        // this is somewhat inefficient - could do better
+        tempSegment.closestPoint(pt, closestPt);
+        ptDist.setMinimum(closestPt, pt);
+    }
 }
 
 /* public static */
 void
 DistanceToPoint::computeDistance(const geom::LineSegment& segment,
-                                          const geom::Coordinate& pt,
-                                          PointPairDistance& ptDist)
+                                 const geom::Coordinate& pt,
+                                 PointPairDistance& ptDist)
 {
-	Coordinate closestPt;
-	segment.closestPoint(pt, closestPt);
-	ptDist.setMinimum(closestPt, pt);
+    Coordinate closestPt;
+    segment.closestPoint(pt, closestPt);
+    ptDist.setMinimum(closestPt, pt);
 }
 
 /* public static */
 void
 DistanceToPoint::computeDistance(const geom::Polygon& poly,
-                                          const geom::Coordinate& pt,
-                                          PointPairDistance& ptDist)
+                                 const geom::Coordinate& pt,
+                                 PointPairDistance& ptDist)
 {
-	computeDistance(*(poly.getExteriorRing()), pt, ptDist);
-	for (size_t i=0, n=poly.getNumInteriorRing(); i<n; ++i)
-	{
-		computeDistance(*(poly.getInteriorRingN(i)), pt, ptDist);
-	}
+    computeDistance(*(poly.getExteriorRing()), pt, ptDist);
+    for(size_t i = 0, n = poly.getNumInteriorRing(); i < n; ++i) {
+        computeDistance(*(poly.getInteriorRingN(i)), pt, ptDist);
+    }
 }
 
 
diff --git a/src/algorithm/locate/IndexedPointInAreaLocator.cpp b/src/algorithm/locate/IndexedPointInAreaLocator.cpp
index 7ded462..d3552de 100644
--- a/src/algorithm/locate/IndexedPointInAreaLocator.cpp
+++ b/src/algorithm/locate/IndexedPointInAreaLocator.cpp
@@ -37,40 +37,40 @@ namespace locate {
 //
 // private:
 //
-IndexedPointInAreaLocator::IntervalIndexedGeometry::IntervalIndexedGeometry( const geom::Geometry & g)
+IndexedPointInAreaLocator::IntervalIndexedGeometry::IntervalIndexedGeometry(const geom::Geometry& g)
 {
-    init( g);
+    init(g);
 }
 
 void
-IndexedPointInAreaLocator::IntervalIndexedGeometry::init( const geom::Geometry & g)
+IndexedPointInAreaLocator::IntervalIndexedGeometry::init(const geom::Geometry& g)
 {
     geom::LineString::ConstVect lines;
-    geom::util::LinearComponentExtracter::getLines( g, lines);
+    geom::util::LinearComponentExtracter::getLines(g, lines);
 
-    for (const geom::LineString* line : lines) {
+    for(const geom::LineString* line : lines) {
         addLine(line->getCoordinatesRO());
     }
 
-    for (geom::LineSegment & seg : segments) {
+    for(geom::LineSegment& seg : segments) {
         index.insert(
-            std::min( seg.p0.y, seg.p1.y),
-            std::max( seg.p0.y, seg.p1.y),
+            std::min(seg.p0.y, seg.p1.y),
+            std::max(seg.p0.y, seg.p1.y),
             &seg);
     }
 }
 
 void
-IndexedPointInAreaLocator::IntervalIndexedGeometry::addLine(const geom::CoordinateSequence * pts)
+IndexedPointInAreaLocator::IntervalIndexedGeometry::addLine(const geom::CoordinateSequence* pts)
 {
-    for (size_t i = 1, ni = pts->size(); i < ni; i++) {
+    for(size_t i = 1, ni = pts->size(); i < ni; i++) {
         segments.emplace_back((*pts)[i - 1], (*pts)[i]);
     }
 }
 
 
 void
-IndexedPointInAreaLocator::buildIndex( const geom::Geometry & g)
+IndexedPointInAreaLocator::buildIndex(const geom::Geometry& g)
 {
     index = std::unique_ptr<IntervalIndexedGeometry>(new IntervalIndexedGeometry(g));
 }
@@ -83,32 +83,33 @@ IndexedPointInAreaLocator::buildIndex( const geom::Geometry & g)
 //
 // public:
 //
-IndexedPointInAreaLocator::IndexedPointInAreaLocator( const geom::Geometry & g)
-    :	areaGeom( g)
+IndexedPointInAreaLocator::IndexedPointInAreaLocator(const geom::Geometry& g)
+    :	areaGeom(g)
 {
     const std::type_info& areaGeomId = typeid(areaGeom);
-    if (	areaGeomId != typeid( geom::Polygon)
-            &&	areaGeomId != typeid( geom::MultiPolygon)
-            &&	areaGeomId != typeid( geom::LinearRing) )
+    if(areaGeomId != typeid(geom::Polygon)
+            &&	areaGeomId != typeid(geom::MultiPolygon)
+            &&	areaGeomId != typeid(geom::LinearRing)) {
         throw util::IllegalArgumentException("Argument must be Polygonal or LinearRing");
+    }
 
-    buildIndex( areaGeom);
+    buildIndex(areaGeom);
 }
 
 int
-IndexedPointInAreaLocator::locate( const geom::Coordinate * /*const*/ p)
+IndexedPointInAreaLocator::locate(const geom::Coordinate* /*const*/ p)
 {
     algorithm::RayCrossingCounter rcc(*p);
 
-    IndexedPointInAreaLocator::SegmentVisitor visitor( &rcc);
+    IndexedPointInAreaLocator::SegmentVisitor visitor(&rcc);
 
-    index->query( p->y, p->y, &visitor);
+    index->query(p->y, p->y, &visitor);
 
     return rcc.getLocation();
 }
 
 void
-IndexedPointInAreaLocator::SegmentVisitor::visitItem( void * item)
+IndexedPointInAreaLocator::SegmentVisitor::visitItem(void* item)
 {
     geom::LineSegment* seg = static_cast<geom::LineSegment*>(item);
 
@@ -116,9 +117,9 @@ IndexedPointInAreaLocator::SegmentVisitor::visitItem( void * item)
 }
 
 void
-IndexedPointInAreaLocator::IntervalIndexedGeometry::query( double min, double max, index::ItemVisitor * visitor)
+IndexedPointInAreaLocator::IntervalIndexedGeometry::query(double min, double max, index::ItemVisitor* visitor)
 {
-    index.query( min, max, visitor);
+    index.query(min, max, visitor);
 }
 
 
diff --git a/src/algorithm/locate/SimplePointInAreaLocator.cpp b/src/algorithm/locate/SimplePointInAreaLocator.cpp
index 00ab1e3..8f9a971 100644
--- a/src/algorithm/locate/SimplePointInAreaLocator.cpp
+++ b/src/algorithm/locate/SimplePointInAreaLocator.cpp
@@ -38,61 +38,67 @@ namespace locate { // geos.algorithm
  * is more complex, since it has to take into account the boundaryDetermination rule
  */
 int
-SimplePointInAreaLocator::locate(const Coordinate& p, const Geometry *geom)
+SimplePointInAreaLocator::locate(const Coordinate& p, const Geometry* geom)
 {
-    if (geom->isEmpty())
+    if(geom->isEmpty()) {
         return Location::EXTERIOR;
+    }
 
     return locateInGeometry(p, geom);
 }
 
 int
-SimplePointInAreaLocator::locateInGeometry(const Coordinate& p,const Geometry *geom)
+SimplePointInAreaLocator::locateInGeometry(const Coordinate& p, const Geometry* geom)
 {
-    if (const Polygon *poly = dynamic_cast<const Polygon*>(geom))
-    {
+    if(const Polygon* poly = dynamic_cast<const Polygon*>(geom)) {
         return locatePointInPolygon(p, poly);
     }
 
-    if (!geom->getEnvelopeInternal()->contains(p)) return Location::EXTERIOR;
-    if (const GeometryCollection *col = dynamic_cast<const GeometryCollection*>(geom))
-    {
-        for (auto g2: *col)
-        {
-            assert (g2!=geom);
+    if(!geom->getEnvelopeInternal()->contains(p)) {
+        return Location::EXTERIOR;
+    }
+    if(const GeometryCollection* col = dynamic_cast<const GeometryCollection*>(geom)) {
+        for(auto g2 : *col) {
+            assert(g2 != geom);
             int loc = locateInGeometry(p, g2);
-            if (loc != Location::EXTERIOR)
+            if(loc != Location::EXTERIOR) {
                 return loc;
+            }
         }
     }
     return Location::EXTERIOR;
 }
 
 int
-SimplePointInAreaLocator::locatePointInPolygon(const Coordinate& p, const Polygon *poly)
+SimplePointInAreaLocator::locatePointInPolygon(const Coordinate& p, const Polygon* poly)
 {
-    if (poly->isEmpty()) return Location::EXTERIOR;
-    if (!poly->getEnvelopeInternal()->contains(p)) return Location::EXTERIOR;
-    const LineString *shell=poly->getExteriorRing();
-    const CoordinateSequence *cl;
+    if(poly->isEmpty()) {
+        return Location::EXTERIOR;
+    }
+    if(!poly->getEnvelopeInternal()->contains(p)) {
+        return Location::EXTERIOR;
+    }
+    const LineString* shell = poly->getExteriorRing();
+    const CoordinateSequence* cl;
     cl = shell->getCoordinatesRO();
-    int shellLoc = PointLocation::locateInRing(p,*cl);
-    if (shellLoc != Location::INTERIOR)
+    int shellLoc = PointLocation::locateInRing(p, *cl);
+    if(shellLoc != Location::INTERIOR) {
         return shellLoc;
+    }
 
     // now test if the point lies in or on the holes
-    for(size_t i=0, n=poly->getNumInteriorRing(); i<n; i++)
-    {
-        const LineString *hole = poly->getInteriorRingN(i);
-        if (hole->getEnvelopeInternal()->contains(p))
-        {
-          cl = hole->getCoordinatesRO();
-          int holeLoc = RayCrossingCounter::locatePointInRing(p,*cl);
-          if (holeLoc == Location::BOUNDARY)
-              return Location::BOUNDARY;
-          if (holeLoc == Location::INTERIOR)
-              return Location::EXTERIOR;
-          // if in EXTERIOR of this hole, keep checking other holes
+    for(size_t i = 0, n = poly->getNumInteriorRing(); i < n; i++) {
+        const LineString* hole = poly->getInteriorRingN(i);
+        if(hole->getEnvelopeInternal()->contains(p)) {
+            cl = hole->getCoordinatesRO();
+            int holeLoc = RayCrossingCounter::locatePointInRing(p, *cl);
+            if(holeLoc == Location::BOUNDARY) {
+                return Location::BOUNDARY;
+            }
+            if(holeLoc == Location::INTERIOR) {
+                return Location::EXTERIOR;
+            }
+            // if in EXTERIOR of this hole, keep checking other holes
         }
     }
     return Location::INTERIOR;
diff --git a/src/geom/Coordinate.cpp b/src/geom/Coordinate.cpp
index 685301e..3ce798b 100644
--- a/src/geom/Coordinate.cpp
+++ b/src/geom/Coordinate.cpp
@@ -29,31 +29,32 @@ using namespace std;
 namespace geos {
 namespace geom { // geos::geom
 
-Coordinate Coordinate::_nullCoord=Coordinate(DoubleNotANumber,DoubleNotANumber,DoubleNotANumber);
+Coordinate Coordinate::_nullCoord = Coordinate(DoubleNotANumber, DoubleNotANumber, DoubleNotANumber);
 
 Coordinate&
 Coordinate::getNull()
 {
-	return _nullCoord;
+    return _nullCoord;
 }
 
 string
 Coordinate::toString() const
 {
-	ostringstream s;
-	s << std::setprecision(17) << *this;
-	return s.str();
+    ostringstream s;
+    s << std::setprecision(17) << *this;
+    return s.str();
 }
 
-std::ostream& operator<< (std::ostream& os, const Coordinate& c)
+std::ostream&
+operator<< (std::ostream& os, const Coordinate& c)
 {
-	if ( std::isnan(c.z) )
-	{
-		os << c.x << " " << c.y;
-	} else {
-		os << c.x << " " << c.y << " " << c.z;
-	}
-	return os;
+    if(std::isnan(c.z)) {
+        os << c.x << " " << c.y;
+    }
+    else {
+        os << c.x << " " << c.y << " " << c.z;
+    }
+    return os;
 }
 
 } // namespace geos::geom
diff --git a/src/geom/CoordinateArraySequence.cpp b/src/geom/CoordinateArraySequence.cpp
index 80c4aa5..4b529f8 100644
--- a/src/geom/CoordinateArraySequence.cpp
+++ b/src/geom/CoordinateArraySequence.cpp
@@ -31,77 +31,83 @@ namespace geos {
 namespace geom { // geos::geom
 
 CoordinateArraySequence::CoordinateArraySequence():
-	vect(new vector<Coordinate>()),
-        dimension(3)
+    vect(new vector<Coordinate>()),
+    dimension(3)
 {
 }
 
 CoordinateArraySequence::CoordinateArraySequence(size_t n,
-                                                 size_t dimension_in ):
-	vect(new vector<Coordinate>(n)),
-        dimension(dimension_in)
+        size_t dimension_in):
+    vect(new vector<Coordinate>(n)),
+    dimension(dimension_in)
 {
 }
 
 CoordinateArraySequence::CoordinateArraySequence(
-    vector<Coordinate> *coords, size_t dimension_in )
-        : vect(coords), dimension(dimension_in)
+    vector<Coordinate>* coords, size_t dimension_in)
+    : vect(coords), dimension(dimension_in)
 {
-	if ( ! vect ) vect = new vector<Coordinate>();
+    if(! vect) {
+        vect = new vector<Coordinate>();
+    }
 }
 
 CoordinateArraySequence::CoordinateArraySequence(
-    const CoordinateArraySequence &c )
-	:
-	CoordinateSequence(c),
-	vect(new vector<Coordinate>(*(c.vect))),
-        dimension(c.getDimension())
+    const CoordinateArraySequence& c)
+    :
+    CoordinateSequence(c),
+    vect(new vector<Coordinate>(*(c.vect))),
+    dimension(c.getDimension())
 {
 }
 
 CoordinateArraySequence::CoordinateArraySequence(
-    const CoordinateSequence &c )
-	:
-	CoordinateSequence(c),
-	vect(new vector<Coordinate>(c.size())),
-  dimension(c.getDimension())
+    const CoordinateSequence& c)
+    :
+    CoordinateSequence(c),
+    vect(new vector<Coordinate>(c.size())),
+    dimension(c.getDimension())
 {
-  for (size_t i = 0, n = vect->size(); i < n; ++i) {
-      (*vect)[i] = c.getAt(i);
-  }
+    for(size_t i = 0, n = vect->size(); i < n; ++i) {
+        (*vect)[i] = c.getAt(i);
+    }
 }
 
-CoordinateSequence *
+CoordinateSequence*
 CoordinateArraySequence::clone() const
 {
-	return new CoordinateArraySequence(*this);
+    return new CoordinateArraySequence(*this);
 }
 
 void
-CoordinateArraySequence::setPoints(const vector<Coordinate> &v)
+CoordinateArraySequence::setPoints(const vector<Coordinate>& v)
 {
-	vect->assign(v.begin(), v.end());
+    vect->assign(v.begin(), v.end());
 }
 
 const vector<Coordinate>*
 CoordinateArraySequence::toVector() const
 {
-	return vect; //new vector<Coordinate>(vect->begin(),vect->end());
+    return vect; //new vector<Coordinate>(vect->begin(),vect->end());
 }
 
 std::size_t
 CoordinateArraySequence::getDimension() const
 {
-    if( dimension != 0 )
+    if(dimension != 0) {
         return dimension;
+    }
 
-    if( vect->empty() )
+    if(vect->empty()) {
         return 3;
+    }
 
-    if( std::isnan((*vect)[0].z) )
+    if(std::isnan((*vect)[0].z)) {
         dimension = 2;
-    else
+    }
+    else {
         dimension = 3;
+    }
 
     return dimension;
 }
@@ -109,180 +115,182 @@ CoordinateArraySequence::getDimension() const
 void
 CoordinateArraySequence::toVector(vector<Coordinate>& out) const
 {
-	// TODO: can this be optimized ?
-	out.insert(out.end(), vect->begin(), vect->end());
+    // TODO: can this be optimized ?
+    out.insert(out.end(), vect->begin(), vect->end());
 }
 
 void
 CoordinateArraySequence::add(const Coordinate& c)
 {
-	vect->push_back(c);
+    vect->push_back(c);
 }
 
 void
 CoordinateArraySequence::add(const Coordinate& c, bool allowRepeated)
 {
-	if (!allowRepeated && ! vect->empty() )
-	{
-		const Coordinate& last=vect->back();
-		if (last.equals2D(c)) return;
-	}
-	vect->push_back(c);
+    if(!allowRepeated && ! vect->empty()) {
+        const Coordinate& last = vect->back();
+        if(last.equals2D(c)) {
+            return;
+        }
+    }
+    vect->push_back(c);
 }
 
 /*public*/
 void
 CoordinateArraySequence::add(size_t i, const Coordinate& coord,
-                                       bool allowRepeated)
+                             bool allowRepeated)
 {
     // don't add duplicate coordinates
-    if (! allowRepeated) {
-      size_t sz = size();
-      if (sz > 0) {
-        if (i > 0) {
-          const Coordinate& prev = getAt(i - 1);
-          if (prev.equals2D(coord)) return;
-        }
-        if (i < sz) {
-          const Coordinate& next = getAt(i);
-          if (next.equals2D(coord)) return;
+    if(! allowRepeated) {
+        size_t sz = size();
+        if(sz > 0) {
+            if(i > 0) {
+                const Coordinate& prev = getAt(i - 1);
+                if(prev.equals2D(coord)) {
+                    return;
+                }
+            }
+            if(i < sz) {
+                const Coordinate& next = getAt(i);
+                if(next.equals2D(coord)) {
+                    return;
+                }
+            }
         }
-      }
     }
 
-    vect->insert(vect->begin()+i, coord);
+    vect->insert(vect->begin() + i, coord);
 }
 
 size_t
 CoordinateArraySequence::getSize() const
 {
-	return vect->size();
+    return vect->size();
 }
 
-const Coordinate &
+const Coordinate&
 CoordinateArraySequence::getAt(size_t pos) const
 {
-	return (*vect)[pos];
+    return (*vect)[pos];
 }
 
 void
-CoordinateArraySequence::getAt(size_t pos, Coordinate &c) const
+CoordinateArraySequence::getAt(size_t pos, Coordinate& c) const
 {
-	c=(*vect)[pos];
+    c = (*vect)[pos];
 }
 
 void
 CoordinateArraySequence::setAt(const Coordinate& c, size_t pos)
 {
-	(*vect)[pos]=c;
+    (*vect)[pos] = c;
 }
 
 void
 CoordinateArraySequence::deleteAt(size_t pos)
 {
-	vect->erase(vect->begin()+pos);
+    vect->erase(vect->begin() + pos);
 }
 
 string
 CoordinateArraySequence::toString() const
 {
-	string result("(");
-	if (getSize()>0) {
-		//char buffer[100];
-		for (size_t i=0, n=vect->size(); i<n; i++)
-		{
-			Coordinate& c=(*vect)[i];
-			if ( i ) result.append(", ");
-			result.append(c.toString());
-		}
-	}
-	result.append(")");
-
-	return result;
+    string result("(");
+    if(getSize() > 0) {
+        //char buffer[100];
+        for(size_t i = 0, n = vect->size(); i < n; i++) {
+            Coordinate& c = (*vect)[i];
+            if(i) {
+                result.append(", ");
+            }
+            result.append(c.toString());
+        }
+    }
+    result.append(")");
+
+    return result;
 }
 
 CoordinateArraySequence::~CoordinateArraySequence()
 {
-	delete vect;
+    delete vect;
 }
 
 void
-CoordinateArraySequence::expandEnvelope(Envelope &env) const
+CoordinateArraySequence::expandEnvelope(Envelope& env) const
 {
-	for (size_t i=0, n=vect->size(); i<n; ++i)
-		env.expandToInclude((*vect)[i]);
+    for(size_t i = 0, n = vect->size(); i < n; ++i) {
+        env.expandToInclude((*vect)[i]);
+    }
 }
 
 double
 CoordinateArraySequence::getOrdinate(size_t index, size_t ordinateIndex) const
 {
-	switch (ordinateIndex)
-	{
-		case CoordinateSequence::X:
-			return (*vect)[index].x;
-		case CoordinateSequence::Y:
-			return (*vect)[index].y;
-		case CoordinateSequence::Z:
-			return (*vect)[index].z;
-		default:
-			return DoubleNotANumber;
-	}
+    switch(ordinateIndex) {
+    case CoordinateSequence::X:
+        return (*vect)[index].x;
+    case CoordinateSequence::Y:
+        return (*vect)[index].y;
+    case CoordinateSequence::Z:
+        return (*vect)[index].z;
+    default:
+        return DoubleNotANumber;
+    }
 }
 
 void
 CoordinateArraySequence::setOrdinate(size_t index, size_t ordinateIndex,
-	double value)
+                                     double value)
 {
-	switch (ordinateIndex)
-	{
-		case CoordinateSequence::X:
-			(*vect)[index].x = value;
-			break;
-		case CoordinateSequence::Y:
-			(*vect)[index].y = value;
-			break;
-		case CoordinateSequence::Z:
-			(*vect)[index].z = value;
-			break;
-		default:
-		{
-			std::stringstream ss;
-			ss << "Unknown ordinate index " << index;
-			throw util::IllegalArgumentException(ss.str());
-			break;
-		}
-	}
+    switch(ordinateIndex) {
+    case CoordinateSequence::X:
+        (*vect)[index].x = value;
+        break;
+    case CoordinateSequence::Y:
+        (*vect)[index].y = value;
+        break;
+    case CoordinateSequence::Z:
+        (*vect)[index].z = value;
+        break;
+    default: {
+        std::stringstream ss;
+        ss << "Unknown ordinate index " << index;
+        throw util::IllegalArgumentException(ss.str());
+        break;
+    }
+    }
 }
 
 void
-CoordinateArraySequence::apply_rw(const CoordinateFilter *filter)
+CoordinateArraySequence::apply_rw(const CoordinateFilter* filter)
 {
-	for (vector<Coordinate>::iterator i=vect->begin(), e=vect->end(); i!=e; ++i)
-	{
-		filter->filter_rw(&(*i));
-	}
-	dimension = 0; // re-check (see http://trac.osgeo.org/geos/ticket/435)
+    for(vector<Coordinate>::iterator i = vect->begin(), e = vect->end(); i != e; ++i) {
+        filter->filter_rw(&(*i));
+    }
+    dimension = 0; // re-check (see http://trac.osgeo.org/geos/ticket/435)
 }
 
 void
-CoordinateArraySequence::apply_ro(CoordinateFilter *filter) const
+CoordinateArraySequence::apply_ro(CoordinateFilter* filter) const
 {
-	for (vector<Coordinate>::const_iterator i=vect->begin(), e=vect->end(); i!=e; ++i)
-	{
-		filter->filter_ro(&(*i));
-	}
+    for(vector<Coordinate>::const_iterator i = vect->begin(), e = vect->end(); i != e; ++i) {
+        filter->filter_ro(&(*i));
+    }
 }
 
 CoordinateSequence&
 CoordinateArraySequence::removeRepeatedPoints()
 {
-	// We use == operator, which is 2D only
-	vector<Coordinate>::iterator new_end = \
-		std::unique(vect->begin(), vect->end());
+    // We use == operator, which is 2D only
+    vector<Coordinate>::iterator new_end = \
+                                           std::unique(vect->begin(), vect->end());
 
-	vect->erase(new_end, vect->end());
+    vect->erase(new_end, vect->end());
 
-	return *this;
+    return *this;
 }
 
 } // namespace geos::geom
diff --git a/src/geom/CoordinateArraySequenceFactory.cpp b/src/geom/CoordinateArraySequenceFactory.cpp
index d1ed8cc..decd6bd 100644
--- a/src/geom/CoordinateArraySequenceFactory.cpp
+++ b/src/geom/CoordinateArraySequenceFactory.cpp
@@ -25,10 +25,10 @@ namespace geom { // geos::geom
 
 static CoordinateArraySequenceFactory defaultCoordinateSequenceFactory;
 
-const CoordinateSequenceFactory *
+const CoordinateSequenceFactory*
 CoordinateArraySequenceFactory::instance()
 {
-	return &defaultCoordinateSequenceFactory;
+    return &defaultCoordinateSequenceFactory;
 }
 
 } // namespace geos::geom
diff --git a/src/geom/CoordinateSequence.cpp b/src/geom/CoordinateSequence.cpp
index 76ad269..5c61610 100644
--- a/src/geom/CoordinateSequence.cpp
+++ b/src/geom/CoordinateSequence.cpp
@@ -32,184 +32,190 @@ namespace geos {
 namespace geom { // geos::geom
 
 #if PROFILE
-static Profiler *profiler = Profiler::instance();
+static Profiler* profiler = Profiler::instance();
 #endif
 
 bool
 CoordinateSequence::hasRepeatedPoints() const
 {
-    const std::size_t p_size=getSize();
-	for(std::size_t i=1; i<p_size; i++) {
-		if (getAt(i-1)==getAt(i)) {
-			return true;
-		}
-	}
-	return false;
+    const std::size_t p_size = getSize();
+    for(std::size_t i = 1; i < p_size; i++) {
+        if(getAt(i - 1) == getAt(i)) {
+            return true;
+        }
+    }
+    return false;
 }
 
 /*
  * Returns either the given coordinate array if its length is greater than the
  * given amount, or an empty coordinate array.
  */
-CoordinateSequence *
+CoordinateSequence*
 CoordinateSequence::atLeastNCoordinatesOrNothing(size_t n,
-		CoordinateSequence *c)
+        CoordinateSequence* c)
 {
-	if ( c->getSize() >= n )
-	{
-		return c;
-	}
-	else
-	{
-		// FIXME: return NULL rather then empty coordinate array
-		return CoordinateArraySequenceFactory::instance()->create();
-	}
+    if(c->getSize() >= n) {
+        return c;
+    }
+    else {
+        // FIXME: return NULL rather then empty coordinate array
+        return CoordinateArraySequenceFactory::instance()->create();
+    }
 }
 
 
 bool
-CoordinateSequence::hasRepeatedPoints(const CoordinateSequence *cl)
+CoordinateSequence::hasRepeatedPoints(const CoordinateSequence* cl)
 {
-	const std::size_t size=cl->getSize();
-	for(std::size_t i=1;i<size; i++) {
-		if (cl->getAt(i-1)==cl->getAt(i)) {
-			return true;
-		}
-	}
-	return false;
+    const std::size_t size = cl->getSize();
+    for(std::size_t i = 1; i < size; i++) {
+        if(cl->getAt(i - 1) == cl->getAt(i)) {
+            return true;
+        }
+    }
+    return false;
 }
 
 const Coordinate*
 CoordinateSequence::minCoordinate() const
 {
-	const Coordinate* minCoord=nullptr;
-	const std::size_t p_size=getSize();
-	for(std::size_t i=0; i<p_size; i++) {
-		if(minCoord==nullptr || minCoord->compareTo(getAt(i))>0) {
-			minCoord=&getAt(i);
-		}
-	}
-	return minCoord;
+    const Coordinate* minCoord = nullptr;
+    const std::size_t p_size = getSize();
+    for(std::size_t i = 0; i < p_size; i++) {
+        if(minCoord == nullptr || minCoord->compareTo(getAt(i)) > 0) {
+            minCoord = &getAt(i);
+        }
+    }
+    return minCoord;
 }
 
 const Coordinate*
-CoordinateSequence::minCoordinate(CoordinateSequence *cl)
+CoordinateSequence::minCoordinate(CoordinateSequence* cl)
 {
-	const Coordinate* minCoord=nullptr;
-	const std::size_t p_size=cl->getSize();
-	for(std::size_t i=0;i<p_size; i++) {
-		if(minCoord==nullptr || minCoord->compareTo(cl->getAt(i))>0) {
-			minCoord=&(cl->getAt(i));
-		}
-	}
-	return minCoord;
+    const Coordinate* minCoord = nullptr;
+    const std::size_t p_size = cl->getSize();
+    for(std::size_t i = 0; i < p_size; i++) {
+        if(minCoord == nullptr || minCoord->compareTo(cl->getAt(i)) > 0) {
+            minCoord = &(cl->getAt(i));
+        }
+    }
+    return minCoord;
 }
 
 size_t
-CoordinateSequence::indexOf(const Coordinate *coordinate,
-		const CoordinateSequence *cl)
+CoordinateSequence::indexOf(const Coordinate* coordinate,
+                            const CoordinateSequence* cl)
 {
-	size_t p_size = cl->size();
-	for (size_t i=0; i < p_size; ++i)
-	{
-		if ((*coordinate)==cl->getAt(i))
-		{
-			return i;
-		}
-	}
-	return std::numeric_limits<std::size_t>::max();
+    size_t p_size = cl->size();
+    for(size_t i = 0; i < p_size; ++i) {
+        if((*coordinate) == cl->getAt(i)) {
+            return i;
+        }
+    }
+    return std::numeric_limits<std::size_t>::max();
 }
 
 void
 CoordinateSequence::scroll(CoordinateSequence* cl,
-		const Coordinate* firstCoordinate)
+                           const Coordinate* firstCoordinate)
 {
-	// FIXME: use a standard algorithm instead
-	std::size_t i, j=0;
-	std::size_t ind=indexOf(firstCoordinate,cl);
-	if (ind<1)
-        return; // not found or already first
-
-	const std::size_t length=cl->getSize();
-	vector<Coordinate> v(length);
-	for (i=ind; i<length; i++) {
-		v[j++]=cl->getAt(i);
-	}
-	for (i=0; i<ind; i++) {
-		v[j++]=cl->getAt(i);
-	}
-	cl->setPoints(v);
+    // FIXME: use a standard algorithm instead
+    std::size_t i, j = 0;
+    std::size_t ind = indexOf(firstCoordinate, cl);
+    if(ind < 1) {
+        return;    // not found or already first
+    }
+
+    const std::size_t length = cl->getSize();
+    vector<Coordinate> v(length);
+    for(i = ind; i < length; i++) {
+        v[j++] = cl->getAt(i);
+    }
+    for(i = 0; i < ind; i++) {
+        v[j++] = cl->getAt(i);
+    }
+    cl->setPoints(v);
 }
 
 int
 CoordinateSequence::increasingDirection(const CoordinateSequence& pts)
 {
-	size_t ptsize = pts.size();
-	for (size_t i=0, n=ptsize/2; i<n; ++i)
-	{
-		size_t j = ptsize - 1 - i;
-		// skip equal points on both ends
-		int comp = pts[i].compareTo(pts[j]);
-		if (comp != 0) return comp;
-	}
-	// array must be a palindrome - defined to be in positive direction
-	return 1;
+    size_t ptsize = pts.size();
+    for(size_t i = 0, n = ptsize / 2; i < n; ++i) {
+        size_t j = ptsize - 1 - i;
+        // skip equal points on both ends
+        int comp = pts[i].compareTo(pts[j]);
+        if(comp != 0) {
+            return comp;
+        }
+    }
+    // array must be a palindrome - defined to be in positive direction
+    return 1;
 }
 
 void
-CoordinateSequence::reverse(CoordinateSequence *cl)
+CoordinateSequence::reverse(CoordinateSequence* cl)
 {
 
-	// FIXME: use a standard algorithm
-	auto last = cl->size() - 1;
-	auto mid = last / 2;
-	for(size_t i=0; i <= mid; i++) {
-		const Coordinate tmp=cl->getAt(i);
-		cl->setAt(cl->getAt(last-i),i);
-		cl->setAt(tmp,last-i);
-	}
+    // FIXME: use a standard algorithm
+    auto last = cl->size() - 1;
+    auto mid = last / 2;
+    for(size_t i = 0; i <= mid; i++) {
+        const Coordinate tmp = cl->getAt(i);
+        cl->setAt(cl->getAt(last - i), i);
+        cl->setAt(tmp, last - i);
+    }
 }
 
 bool
-CoordinateSequence::equals(const CoordinateSequence *cl1,
-		const CoordinateSequence *cl2)
+CoordinateSequence::equals(const CoordinateSequence* cl1,
+                           const CoordinateSequence* cl2)
 {
-	// FIXME: use std::equals()
-
-	if (cl1==cl2) return true;
-	if (cl1==nullptr||cl2==nullptr) return false;
-	size_t npts1=cl1->getSize();
-	if (npts1!=cl2->getSize()) return false;
-	for (size_t i=0; i<npts1; i++) {
-		if (!(cl1->getAt(i)==cl2->getAt(i))) return false;
-	}
-	return true;
+    // FIXME: use std::equals()
+
+    if(cl1 == cl2) {
+        return true;
+    }
+    if(cl1 == nullptr || cl2 == nullptr) {
+        return false;
+    }
+    size_t npts1 = cl1->getSize();
+    if(npts1 != cl2->getSize()) {
+        return false;
+    }
+    for(size_t i = 0; i < npts1; i++) {
+        if(!(cl1->getAt(i) == cl2->getAt(i))) {
+            return false;
+        }
+    }
+    return true;
 }
 
 /*public*/
 void
 CoordinateSequence::add(const vector<Coordinate>* vc, bool allowRepeated)
 {
-	assert(vc);
-	for(size_t i=0; i<vc->size(); ++i)
-	{
-		add((*vc)[i], allowRepeated);
-	}
+    assert(vc);
+    for(size_t i = 0; i < vc->size(); ++i) {
+        add((*vc)[i], allowRepeated);
+    }
 }
 
 /*public*/
 void
 CoordinateSequence::add(const Coordinate& c, bool allowRepeated)
 {
-	if (!allowRepeated) {
-        std::size_t npts=getSize();
-		if (npts>=1) {
-			const Coordinate& last=getAt(npts-1);
-			if (last.equals2D(c))
+    if(!allowRepeated) {
+        std::size_t npts = getSize();
+        if(npts >= 1) {
+            const Coordinate& last = getAt(npts - 1);
+            if(last.equals2D(c)) {
                 return;
-		}
-	}
-	add(c);
+            }
+        }
+    }
+    add(c);
 }
 
 /* Here for backward compatibility */
@@ -222,75 +228,81 @@ CoordinateSequence::add(const Coordinate& c, bool allowRepeated)
 
 /*public*/
 void
-CoordinateSequence::add(const CoordinateSequence *cl,
-		bool allowRepeated, bool direction)
+CoordinateSequence::add(const CoordinateSequence* cl,
+                        bool allowRepeated, bool direction)
 {
-	// FIXME:  don't rely on negative values for 'j' (the reverse case)
-
-	const auto npts = cl->size();
-	if (direction) {
-		for (size_t i = 0; i < npts; ++i) {
-			add(cl->getAt(i), allowRepeated);
-		}
-	} else {
-		for (auto j = npts; j > 0; --j) {
-			add(cl->getAt(j - 1), allowRepeated);
-		}
-	}
+    // FIXME:  don't rely on negative values for 'j' (the reverse case)
+
+    const auto npts = cl->size();
+    if(direction) {
+        for(size_t i = 0; i < npts; ++i) {
+            add(cl->getAt(i), allowRepeated);
+        }
+    }
+    else {
+        for(auto j = npts; j > 0; --j) {
+            add(cl->getAt(j - 1), allowRepeated);
+        }
+    }
 }
 
 
 /*public static*/
 CoordinateSequence*
-CoordinateSequence::removeRepeatedPoints(const CoordinateSequence *cl)
+CoordinateSequence::removeRepeatedPoints(const CoordinateSequence* cl)
 {
 #if PROFILE
-	static Profile *prof= profiler->get("CoordinateSequence::removeRepeatedPoints()");
-	prof->start();
+    static Profile* prof = profiler->get("CoordinateSequence::removeRepeatedPoints()");
+    prof->start();
 #endif
-	const vector<Coordinate> *v=cl->toVector();
+    const vector<Coordinate>* v = cl->toVector();
 
-	vector<Coordinate> *nv=new vector<Coordinate>;
-	nv->reserve(v->size());
-	unique_copy(v->begin(), v->end(), back_inserter(*nv));
-	CoordinateSequence* ret=CoordinateArraySequenceFactory::instance()->create(nv);
+    vector<Coordinate>* nv = new vector<Coordinate>;
+    nv->reserve(v->size());
+    unique_copy(v->begin(), v->end(), back_inserter(*nv));
+    CoordinateSequence* ret = CoordinateArraySequenceFactory::instance()->create(nv);
 
 #if PROFILE
-	prof->stop();
+    prof->stop();
 #endif
-	return ret;
+    return ret;
 }
 
 void
-CoordinateSequence::expandEnvelope(Envelope &env) const
+CoordinateSequence::expandEnvelope(Envelope& env) const
 {
-	const std::size_t p_size = getSize();
-	for (std::size_t i=0; i<p_size; i++)
+    const std::size_t p_size = getSize();
+    for(std::size_t i = 0; i < p_size; i++) {
         env.expandToInclude(getAt(i));
+    }
 }
 
-std::ostream& operator<< (std::ostream& os, const CoordinateSequence& cs)
+std::ostream&
+operator<< (std::ostream& os, const CoordinateSequence& cs)
 {
-	os << "(";
-	for (size_t i=0, n=cs.size(); i<n; ++i)
-	{
-		const Coordinate& c = cs[i];
-		if ( i ) os << ", ";
-		os << c;
-	}
-	os << ")";
-
-	return os;
+    os << "(";
+    for(size_t i = 0, n = cs.size(); i < n; ++i) {
+        const Coordinate& c = cs[i];
+        if(i) {
+            os << ", ";
+        }
+        os << c;
+    }
+    os << ")";
+
+    return os;
 }
 
-bool operator== ( const CoordinateSequence& s1, const CoordinateSequence& s2)
+bool
+operator== (const CoordinateSequence& s1, const CoordinateSequence& s2)
 {
-	return CoordinateSequence::equals(&s1, &s2);
+    return CoordinateSequence::equals(&s1, &s2);
 }
 
-bool operator!= ( const CoordinateSequence& s1, const CoordinateSequence& s2)
+bool
+operator!= (const CoordinateSequence& s1, const CoordinateSequence& s2)
 {
-	return ! CoordinateSequence::equals(&s1, &s2);
+    return ! CoordinateSequence::equals(&s1, &s2);
 }
 
 } // namespace geos::geom
diff --git a/src/geom/Dimension.cpp b/src/geom/Dimension.cpp
index be6222f..d4e7ccd 100644
--- a/src/geom/Dimension.cpp
+++ b/src/geom/Dimension.cpp
@@ -30,25 +30,27 @@ namespace geom { // geos::geom
  *@return   a character for use in the string representation of
  *      an <code>IntersectionMatrix</code>. Possible values are <code>{T, F, * , 0, 1, 2}</code>.
  */
-char Dimension::toDimensionSymbol(int dimensionValue) {
-	switch (dimensionValue) {
-		case False:
-			return 'F';
-		case True:
-			return 'T';
-		case DONTCARE:
-			return '*';
-		case P:
-			return '0';
-		case L:
-			return '1';
-		case A:
-			return '2';
-		default:
-			ostringstream s;
-			s<<"Unknown dimension value: "<<dimensionValue<<endl;
-			throw  util::IllegalArgumentException(s.str());
-	}
+char
+Dimension::toDimensionSymbol(int dimensionValue)
+{
+    switch(dimensionValue) {
+    case False:
+        return 'F';
+    case True:
+        return 'T';
+    case DONTCARE:
+        return '*';
+    case P:
+        return '0';
+    case L:
+        return '1';
+    case A:
+        return '2';
+    default:
+        ostringstream s;
+        s << "Unknown dimension value: " << dimensionValue << endl;
+        throw  util::IllegalArgumentException(s.str());
+    }
 }
 
 /**
@@ -59,27 +61,29 @@ char Dimension::toDimensionSymbol(int dimensionValue) {
  *@return       a number that can be stored in the <code>IntersectionMatrix</code>.
  *				Possible values are <code>{TRUE, FALSE, DONTCARE, 0, 1, 2}</code>.
  */
-int Dimension::toDimensionValue(char dimensionSymbol) {
-	switch (dimensionSymbol) {
-		case 'F':
-		case 'f':
-			return False;
-		case 'T':
-		case 't':
-			return True;
-		case '*':
-			return DONTCARE;
-		case '0':
-			return P;
-		case '1':
-			return L;
-		case '2':
-			return A;
-		default:
-			ostringstream s;
-			s<<"Unknown dimension symbol: "<<dimensionSymbol<<endl;
-			throw  util::IllegalArgumentException(s.str());
-	}
+int
+Dimension::toDimensionValue(char dimensionSymbol)
+{
+    switch(dimensionSymbol) {
+    case 'F':
+    case 'f':
+        return False;
+    case 'T':
+    case 't':
+        return True;
+    case '*':
+        return DONTCARE;
+    case '0':
+        return P;
+    case '1':
+        return L;
+    case '2':
+        return A;
+    default:
+        ostringstream s;
+        s << "Unknown dimension symbol: " << dimensionSymbol << endl;
+        throw  util::IllegalArgumentException(s.str());
+    }
 }
 
 } // namespace geos::geom
diff --git a/src/geom/Envelope.cpp b/src/geom/Envelope.cpp
index 5edfcfa..43bd73a 100644
--- a/src/geom/Envelope.cpp
+++ b/src/geom/Envelope.cpp
@@ -44,124 +44,138 @@ namespace geom { // geos::geom
 /*public*/
 bool
 Envelope::intersects(const Coordinate& p1, const Coordinate& p2,
-		const Coordinate& q)
+                     const Coordinate& q)
 {
-	//OptimizeIt shows that Math#min and Math#max here are a bottleneck.
+    //OptimizeIt shows that Math#min and Math#max here are a bottleneck.
     //Replace with direct comparisons. [Jon Aquino]
-    if (((q.x >= (p1.x < p2.x ? p1.x : p2.x)) && (q.x <= (p1.x > p2.x ? p1.x : p2.x))) &&
-        ((q.y >= (p1.y < p2.y ? p1.y : p2.y)) && (q.y <= (p1.y > p2.y ? p1.y : p2.y)))) {
-			return true;
-	}
-	return false;
+    if(((q.x >= (p1.x < p2.x ? p1.x : p2.x)) && (q.x <= (p1.x > p2.x ? p1.x : p2.x))) &&
+            ((q.y >= (p1.y < p2.y ? p1.y : p2.y)) && (q.y <= (p1.y > p2.y ? p1.y : p2.y)))) {
+        return true;
+    }
+    return false;
 }
 
 /*public*/
 bool
 Envelope::intersects(const Coordinate& p1, const Coordinate& p2,
-	const Coordinate& q1, const Coordinate& q2)
-{
-	double minq=min(q1.x,q2.x);
-	double maxq=max(q1.x,q2.x);
-	double minp=min(p1.x,p2.x);
-	double maxp=max(p1.x,p2.x);
-	if(minp>maxq)
-		return false;
-	if(maxp<minq)
-		return false;
-	minq=min(q1.y,q2.y);
-	maxq=max(q1.y,q2.y);
-	minp=min(p1.y,p2.y);
-	maxp=max(p1.y,p2.y);
-	if(minp>maxq)
-		return false;
-	if(maxp<minq)
-		return false;
-	return true;
-}
-
-/*public*/
-bool Envelope::intersects(const Coordinate& a, const Coordinate& b) const {
+                     const Coordinate& q1, const Coordinate& q2)
+{
+    double minq = min(q1.x, q2.x);
+    double maxq = max(q1.x, q2.x);
+    double minp = min(p1.x, p2.x);
+    double maxp = max(p1.x, p2.x);
+    if(minp > maxq) {
+        return false;
+    }
+    if(maxp < minq) {
+        return false;
+    }
+    minq = min(q1.y, q2.y);
+    maxq = max(q1.y, q2.y);
+    minp = min(p1.y, p2.y);
+    maxp = max(p1.y, p2.y);
+    if(minp > maxq) {
+        return false;
+    }
+    if(maxp < minq) {
+        return false;
+    }
+    return true;
+}
+
+/*public*/
+bool
+Envelope::intersects(const Coordinate& a, const Coordinate& b) const
+{
 
     double envminx = (a.x < b.x) ? a.x : b.x;
-    if (envminx > maxx) return false;
+    if(envminx > maxx) {
+        return false;
+    }
 
     double envmaxx = (a.x > b.x) ? a.x : b.x;
-    if (envmaxx < minx) return false;
+    if(envmaxx < minx) {
+        return false;
+    }
 
     double envminy = (a.y < b.y) ? a.y : b.y;
-    if (envminy > maxy) return false;
+    if(envminy > maxy) {
+        return false;
+    }
 
     double envmaxy = (a.y > b.y) ? a.y : b.y;
-    if (envmaxy < miny) return false;
+    if(envmaxy < miny) {
+        return false;
+    }
 
     return true;
 }
 
 /*public*/
 double
-Envelope::distance(double x0,double y0,double x1,double y1)
+Envelope::distance(double x0, double y0, double x1, double y1)
 {
-	double dx=x1-x0;
-	double dy=y1-y0;
-	return sqrt(dx*dx+dy*dy);
+    double dx = x1 - x0;
+    double dy = y1 - y0;
+    return sqrt(dx * dx + dy * dy);
 }
 
 /*public*/
 Envelope::Envelope(void)
 {
-	init();
+    init();
 }
 
 /*public*/
 Envelope::Envelope(double x1, double x2, double y1, double y2)
 {
-	init(x1, x2, y1, y2);
+    init(x1, x2, y1, y2);
 }
 
 /*public*/
 Envelope::Envelope(const Coordinate& p1, const Coordinate& p2)
 {
-	init(p1, p2);
+    init(p1, p2);
 }
 
 /*public*/
 Envelope::Envelope(const Coordinate& p)
 {
-	init(p);
+    init(p);
 }
 
 /*public*/
-Envelope::Envelope(const Envelope &env)
-	:
-	minx(env.minx),
-	maxx(env.maxx),
-	miny(env.miny),
-	maxy(env.maxy)
+Envelope::Envelope(const Envelope& env)
+    :
+    minx(env.minx),
+    maxx(env.maxx),
+    miny(env.miny),
+    maxy(env.maxy)
 {
 #if GEOS_DEBUG
-	std::cerr<<"Envelope copy"<<std::endl;
+    std::cerr << "Envelope copy" << std::endl;
 #endif
-	//init(env.minx, env.maxx, env.miny, env.maxy);
+    //init(env.minx, env.maxx, env.miny, env.maxy);
 }
 
 /*public*/
-Envelope::Envelope(const string &str)
+Envelope::Envelope(const string& str)
 {
-  // The string should be in the format:
-  // Env[7.2:2.3,7.1:8.2]
+    // The string should be in the format:
+    // Env[7.2:2.3,7.1:8.2]
 
-  // extract out the values between the [ and ] characters
-  string::size_type index = str.find("[");
-  string coordString = str.substr(index + 1, str.size() - 1 - 1);
+    // extract out the values between the [ and ] characters
+    string::size_type index = str.find("[");
+    string coordString = str.substr(index + 1, str.size() - 1 - 1);
 
-  // now split apart the string on : and , characters
-  vector<string> values = split(coordString, ":,");
+    // now split apart the string on : and , characters
+    vector<string> values = split(coordString, ":,");
 
-  // create a new envelopet
-  init(strtod(values[0].c_str(), nullptr),
-       strtod(values[1].c_str(), nullptr),
-       strtod(values[2].c_str(), nullptr),
-       strtod(values[3].c_str(), nullptr));
+    // create a new envelopet
+    init(strtod(values[0].c_str(), nullptr),
+         strtod(values[1].c_str(), nullptr),
+         strtod(values[2].c_str(), nullptr),
+         strtod(values[3].c_str(), nullptr));
 }
 
 /*public*/
@@ -171,41 +185,43 @@ Envelope::~Envelope(void) {}
 void
 Envelope::init()
 {
-	setToNull();
+    setToNull();
 }
 
 /*public*/
 void
 Envelope::init(double x1, double x2, double y1, double y2)
 {
-	if (x1 < x2) {
-		minx = x1;
-		maxx = x2;
-	} else {
-		minx = x2;
-		maxx = x1;
-	}
-	if (y1 < y2) {
-		miny = y1;
-		maxy = y2;
-	} else {
-		miny = y2;
-		maxy = y1;
-	}
+    if(x1 < x2) {
+        minx = x1;
+        maxx = x2;
+    }
+    else {
+        minx = x2;
+        maxx = x1;
+    }
+    if(y1 < y2) {
+        miny = y1;
+        maxy = y2;
+    }
+    else {
+        miny = y2;
+        maxy = y1;
+    }
 }
 
 /*public*/
 void
 Envelope::init(const Coordinate& p1, const Coordinate& p2)
 {
-	init(p1.x, p2.x, p1.y, p2.y);
+    init(p1.x, p2.x, p1.y, p2.y);
 }
 
 /*public*/
 void
 Envelope::init(const Coordinate& p)
 {
-	init(p.x, p.x, p.y, p.y);
+    init(p.x, p.x, p.y, p.y);
 }
 
 #if 0
@@ -217,7 +233,7 @@ Envelope::init(const Coordinate& p)
 void
 Envelope::init(Envelope env)
 {
-	init(env.minx, env.maxx, env.miny, env.maxy);
+    init(env.minx, env.maxx, env.miny, env.maxy);
 }
 #endif // 0
 
@@ -225,101 +241,105 @@ Envelope::init(Envelope env)
 void
 Envelope::setToNull()
 {
-	minx=0;
-	maxx=-1;
-	miny=0;
-	maxy=-1;
+    minx = 0;
+    maxx = -1;
+    miny = 0;
+    maxy = -1;
 }
 
 /*public*/
 double
 Envelope::getWidth() const
 {
-	if (isNull()) {
-		return 0;
-	}
-	return maxx - minx;
+    if(isNull()) {
+        return 0;
+    }
+    return maxx - minx;
 }
 
 /*public*/
 double
 Envelope::getHeight() const
 {
-	if (isNull()) {
-		return 0;
-	}
-	return maxy - miny;
+    if(isNull()) {
+        return 0;
+    }
+    return maxy - miny;
 }
 
 /*public*/
 void
 Envelope::expandToInclude(const Coordinate& p)
 {
-	expandToInclude(p.x, p.y);
+    expandToInclude(p.x, p.y);
 }
 
 /*public*/
 void
 Envelope::expandToInclude(double x, double y)
 {
-	if (isNull()) {
-		minx = x;
-		maxx = x;
-		miny = y;
-		maxy = y;
-	} else {
-		if (x < minx) {
-			minx = x;
-		}
-		if (x > maxx) {
-			maxx = x;
-		}
-		if (y < miny) {
-			miny = y;
-		}
-		if (y > maxy) {
-			maxy = y;
-		}
-	}
+    if(isNull()) {
+        minx = x;
+        maxx = x;
+        miny = y;
+        maxy = y;
+    }
+    else {
+        if(x < minx) {
+            minx = x;
+        }
+        if(x > maxx) {
+            maxx = x;
+        }
+        if(y < miny) {
+            miny = y;
+        }
+        if(y > maxy) {
+            maxy = y;
+        }
+    }
 }
 
 /*public*/
 void
 Envelope::expandToInclude(const Envelope* other)
 {
-	if (other->isNull()) {
-		return;
-	}
-	if (isNull()) {
-		minx = other->getMinX();
-		maxx = other->getMaxX();
-		miny = other->getMinY();
-		maxy = other->getMaxY();
-	} else {
-		if (other->minx < minx) {
-			minx = other->minx;
-		}
-		if (other->maxx > maxx) {
-			maxx = other->maxx;
-		}
-		if (other->miny < miny) {
-			miny = other->miny;
-		}
-		if (other->maxy > maxy) {
-			maxy = other->maxy;
-		}
-	}
+    if(other->isNull()) {
+        return;
+    }
+    if(isNull()) {
+        minx = other->getMinX();
+        maxx = other->getMaxX();
+        miny = other->getMinY();
+        maxy = other->getMaxY();
+    }
+    else {
+        if(other->minx < minx) {
+            minx = other->minx;
+        }
+        if(other->maxx > maxx) {
+            maxx = other->maxx;
+        }
+        if(other->miny < miny) {
+            miny = other->miny;
+        }
+        if(other->maxy > maxy) {
+            maxy = other->maxy;
+        }
+    }
 }
 
 /*public*/
 bool
 Envelope::covers(double x, double y) const
 {
-	if (isNull()) return false;
-	return x >= minx &&
-		x <= maxx &&
-		y >= miny &&
-		y <= maxy;
+    if(isNull()) {
+        return false;
+    }
+    return x >= minx &&
+           x <= maxx &&
+           y >= miny &&
+           y <= maxy;
 }
 
 
@@ -327,13 +347,15 @@ Envelope::covers(double x, double y) const
 bool
 Envelope::covers(const Envelope& other) const
 {
-	if (isNull() || other.isNull()) return false;
+    if(isNull() || other.isNull()) {
+        return false;
+    }
 
-	return
-		other.getMinX() >= minx &&
-		other.getMaxX() <= maxx &&
-		other.getMinY() >= miny &&
-		other.getMaxY() <= maxy;
+    return
+        other.getMinX() >= minx &&
+        other.getMaxX() <= maxx &&
+        other.getMinY() >= miny &&
+        other.getMaxY() <= maxy;
 }
 
 
@@ -343,19 +365,22 @@ Envelope::covers(const Envelope& other) const
 bool
 Envelope::equals(const Envelope* other) const
 {
-	if (isNull()) return other->isNull();
-	return  other->getMinX() == minx &&
-			other->getMaxX() == maxx &&
-			other->getMinY() == miny &&
-			other->getMaxY() == maxy;
+    if(isNull()) {
+        return other->isNull();
+    }
+    return  other->getMinX() == minx &&
+            other->getMaxX() == maxx &&
+            other->getMinY() == miny &&
+            other->getMaxY() == maxy;
 }
 
 /* public */
-std::ostream& operator<< (std::ostream& os, const Envelope& o)
+std::ostream&
+operator<< (std::ostream& os, const Envelope& o)
 {
-	os << "Env[" << o.minx << ":" << o.maxx << ","
-		 << o.miny << ":" << o.maxy << "]";
-	return os;
+    os << "Env[" << o.minx << ":" << o.maxx << ","
+       << o.miny << ":" << o.maxy << "]";
+    return os;
 }
 
 
@@ -363,113 +388,132 @@ std::ostream& operator<< (std::ostream& os, const Envelope& o)
 string
 Envelope::toString() const
 {
-	ostringstream s;
-	s<<*this;
-	return s.str();
+    ostringstream s;
+    s << *this;
+    return s.str();
 }
 
 /*public*/
 double
 Envelope::distance(const Envelope* env) const
 {
-	if (intersects(env)) return 0;
-	double dx=0.0;
-	if(maxx<env->minx) dx=env->minx-maxx;
-	if(minx>env->maxx) dx=minx-env->maxx;
-	double dy=0.0;
-	if(maxy<env->miny) dy=env->miny-maxy;
-	if(miny>env->maxy) dy=miny-env->maxy;
-	// if either is zero, the envelopes overlap either vertically or horizontally
-	if (dx==0.0) return dy;
-	if (dy==0.0) return dx;
-	return sqrt(dx*dx+dy*dy);
+    if(intersects(env)) {
+        return 0;
+    }
+    double dx = 0.0;
+    if(maxx < env->minx) {
+        dx = env->minx - maxx;
+    }
+    if(minx > env->maxx) {
+        dx = minx - env->maxx;
+    }
+    double dy = 0.0;
+    if(maxy < env->miny) {
+        dy = env->miny - maxy;
+    }
+    if(miny > env->maxy) {
+        dy = miny - env->maxy;
+    }
+    // if either is zero, the envelopes overlap either vertically or horizontally
+    if(dx == 0.0) {
+        return dy;
+    }
+    if(dy == 0.0) {
+        return dx;
+    }
+    return sqrt(dx * dx + dy * dy);
 }
 
 /*public*/
 bool
 operator==(const Envelope& a, const Envelope& b)
 {
-	if (a.isNull()) {
-		return b.isNull();
-	}
-	if (b.isNull()) {
-		return a.isNull();
-	}
-	return a.getMaxX() == b.getMaxX() &&
-		   a.getMaxY() == b.getMaxY() &&
-		   a.getMinX() == b.getMinX() &&
-		   a.getMinY() == b.getMinY();
+    if(a.isNull()) {
+        return b.isNull();
+    }
+    if(b.isNull()) {
+        return a.isNull();
+    }
+    return a.getMaxX() == b.getMaxX() &&
+           a.getMaxY() == b.getMaxY() &&
+           a.getMinX() == b.getMinX() &&
+           a.getMinY() == b.getMinY();
 }
 
 /*public*/
 int
 Envelope::hashCode() const
 {
-	//Algorithm from Effective Java by Joshua Bloch [Jon Aquino]
-	int result = 17;
-	result = 37 * result + Coordinate::hashCode(minx);
-	result = 37 * result + Coordinate::hashCode(maxx);
-	result = 37 * result + Coordinate::hashCode(miny);
-	result = 37 * result + Coordinate::hashCode(maxy);
-	return result;
+    //Algorithm from Effective Java by Joshua Bloch [Jon Aquino]
+    int result = 17;
+    result = 37 * result + Coordinate::hashCode(minx);
+    result = 37 * result + Coordinate::hashCode(maxx);
+    result = 37 * result + Coordinate::hashCode(miny);
+    result = 37 * result + Coordinate::hashCode(maxy);
+    return result;
 }
 
 /*public static*/
 vector<string>
-Envelope::split(const string &str, const string &delimiters)
+Envelope::split(const string& str, const string& delimiters)
 {
-  vector<string> tokens;
+    vector<string> tokens;
 
-  // Find first "non-delimiter".
-  string::size_type lastPos = 0;
-  string::size_type pos = str.find_first_of(delimiters, lastPos);
+    // Find first "non-delimiter".
+    string::size_type lastPos = 0;
+    string::size_type pos = str.find_first_of(delimiters, lastPos);
 
-  while (string::npos != pos || string::npos != lastPos)
-  {
-    // Found a token, add it to the vector.
-    tokens.push_back(str.substr(lastPos, pos - lastPos));
+    while(string::npos != pos || string::npos != lastPos) {
+        // Found a token, add it to the vector.
+        tokens.push_back(str.substr(lastPos, pos - lastPos));
 
-    // Skip delimiters.  Note the "not_of"
-    lastPos = str.find_first_not_of(delimiters, pos);
+        // Skip delimiters.  Note the "not_of"
+        lastPos = str.find_first_not_of(delimiters, pos);
 
-    // Find next "non-delimiter"
-    pos = str.find_first_of(delimiters, lastPos);
-  }
+        // Find next "non-delimiter"
+        pos = str.find_first_of(delimiters, lastPos);
+    }
 
-  return tokens;
+    return tokens;
 }
 
 /*public*/
 bool
 Envelope::centre(Coordinate& p_centre) const
 {
-	if (isNull()) return false;
-	p_centre.x=(getMinX() + getMaxX()) / 2.0;
-	p_centre.y=(getMinY() + getMaxY()) / 2.0;
-	return true;
+    if(isNull()) {
+        return false;
+    }
+    p_centre.x = (getMinX() + getMaxX()) / 2.0;
+    p_centre.y = (getMinY() + getMaxY()) / 2.0;
+    return true;
 }
 
 /*public*/
 bool
 Envelope::intersection(const Envelope& env, Envelope& result) const
 {
-	if (isNull() || env.isNull() || ! intersects(env)) return false;
+    if(isNull() || env.isNull() || ! intersects(env)) {
+        return false;
+    }
 
-	double intMinX = minx > env.minx ? minx : env.minx;
-	double intMinY = miny > env.miny ? miny : env.miny;
-	double intMaxX = maxx < env.maxx ? maxx : env.maxx;
-	double intMaxY = maxy < env.maxy ? maxy : env.maxy;
-	result.init(intMinX, intMaxX, intMinY, intMaxY);
-	return true;
+    double intMinX = minx > env.minx ? minx : env.minx;
+    double intMinY = miny > env.miny ? miny : env.miny;
+    double intMaxX = maxx < env.maxx ? maxx : env.maxx;
+    double intMaxY = maxy < env.maxy ? maxy : env.maxy;
+    result.init(intMinX, intMaxX, intMinY, intMaxY);
+    return true;
 }
 
 /*public*/
 void
 Envelope::translate(double transX, double transY)
 {
-	if (isNull()) return;
-	init(getMinX() + transX, getMaxX() + transX,
-		getMinY() + transY, getMaxY() + transY);
+    if(isNull()) {
+        return;
+    }
+    init(getMinX() + transX, getMaxX() + transX,
+         getMinY() + transY, getMaxY() + transY);
 }
 
 
@@ -477,16 +521,19 @@ Envelope::translate(double transX, double transY)
 void
 Envelope::expandBy(double deltaX, double deltaY)
 {
-	if (isNull()) return;
+    if(isNull()) {
+        return;
+    }
 
-	minx -= deltaX;
-	maxx += deltaX;
-	miny -= deltaY;
-	maxy += deltaY;
+    minx -= deltaX;
+    maxx += deltaX;
+    miny -= deltaY;
+    maxy += deltaY;
 
-	// check for envelope disappearing
-	if (minx > maxx || miny > maxy)
-		setToNull();
+    // check for envelope disappearing
+    if(minx > maxx || miny > maxy) {
+        setToNull();
+    }
 }
 
 /*public*/
@@ -494,16 +541,15 @@ Envelope&
 Envelope::operator=(const Envelope& e)
 {
 #if GEOS_DEBUG
-	std::cerr<<"Envelope assignment"<<std::endl;
+    std::cerr << "Envelope assignment" << std::endl;
 #endif
-	if ( &e != this ) // is this check useful ?
-	{
-		minx=e.minx;
-		maxx=e.maxx;
-		miny=e.miny;
-		maxy=e.maxy;
-	}
-	return *this;
+    if(&e != this) {  // is this check useful ?
+        minx = e.minx;
+        maxx = e.maxx;
+        miny = e.miny;
+        maxy = e.maxy;
+    }
+    return *this;
 }
 
 
diff --git a/src/geom/Geometry.cpp b/src/geom/Geometry.cpp
index bd156dc..1ffacbe 100644
--- a/src/geom/Geometry.cpp
+++ b/src/geom/Geometry.cpp
@@ -91,7 +91,7 @@ namespace geom { // geos::geom
 string
 geosversion()
 {
-	return GEOS_VERSION;
+    return GEOS_VERSION;
 }
 
 /*
@@ -101,138 +101,149 @@ geosversion()
 string
 jtsport()
 {
-	return GEOS_JTS_PORT;
+    return GEOS_JTS_PORT;
 }
 
 Geometry::GeometryChangedFilter Geometry::geometryChangedFilter;
 
-Geometry::Geometry(const GeometryFactory *newFactory)
-	:
-	envelope(nullptr),
-	_factory(newFactory),
-	_userData(nullptr)
+Geometry::Geometry(const GeometryFactory* newFactory)
+    :
+    envelope(nullptr),
+    _factory(newFactory),
+    _userData(nullptr)
 {
-	if ( _factory == nullptr ) {
-		_factory = GeometryFactory::getDefaultInstance();
-	}
-	SRID=_factory->getSRID();
-	_factory->addRef();
+    if(_factory == nullptr) {
+        _factory = GeometryFactory::getDefaultInstance();
+    }
+    SRID = _factory->getSRID();
+    _factory->addRef();
 }
 
-Geometry::Geometry(const Geometry &geom)
-	:
-	SRID(geom.getSRID()),
-	_factory(geom._factory),
-	_userData(nullptr)
+Geometry::Geometry(const Geometry& geom)
+    :
+    SRID(geom.getSRID()),
+    _factory(geom._factory),
+    _userData(nullptr)
 {
-	if ( geom.envelope.get() )
-	{
-		envelope.reset(new Envelope(*(geom.envelope)));
-	}
-	//factory=geom.factory;
-	//envelope(new Envelope(*(geom.envelope.get())));
-	//SRID=geom.getSRID();
-	//_userData=NULL;
-	_factory->addRef();
+    if(geom.envelope.get()) {
+        envelope.reset(new Envelope(*(geom.envelope)));
+    }
+    //factory=geom.factory;
+    //envelope(new Envelope(*(geom.envelope.get())));
+    //SRID=geom.getSRID();
+    //_userData=NULL;
+    _factory->addRef();
 }
 
 bool
-Geometry::hasNonEmptyElements(const vector<Geometry *>* geometries)
+Geometry::hasNonEmptyElements(const vector<Geometry*>* geometries)
 {
-	for (size_t i=0; i<geometries->size(); i++) {
-		if (!(*geometries)[i]->isEmpty()) {
-			return true;
-		}
-	}
-	return false;
+    for(size_t i = 0; i < geometries->size(); i++) {
+        if(!(*geometries)[i]->isEmpty()) {
+            return true;
+        }
+    }
+    return false;
 }
 
 bool
 Geometry::hasNullElements(const CoordinateSequence* list)
 {
-	size_t npts=list->getSize();
-	for (size_t i=0; i<npts; ++i) {
-		if (list->getAt(i).isNull()) {
-			return true;
-		}
-	}
-	return false;
+    size_t npts = list->getSize();
+    for(size_t i = 0; i < npts; ++i) {
+        if(list->getAt(i).isNull()) {
+            return true;
+        }
+    }
+    return false;
 }
 
 bool
-Geometry::hasNullElements(const vector<Geometry *>* lrs)
+Geometry::hasNullElements(const vector<Geometry*>* lrs)
 {
-	size_t n=lrs->size();
-	for (size_t i=0; i<n; ++i) {
-		if ((*lrs)[i]==nullptr) {
-			return true;
-		}
-	}
-	return false;
+    size_t n = lrs->size();
+    for(size_t i = 0; i < n; ++i) {
+        if((*lrs)[i] == nullptr) {
+            return true;
+        }
+    }
+    return false;
 }
 
 /* public */
 bool
-Geometry::isWithinDistance(const Geometry *geom,double cDistance) const
-{
-	const Envelope *env0=getEnvelopeInternal();
-	const Envelope *env1=geom->getEnvelopeInternal();
-	double envDist=env0->distance(env1);
-	//delete env0;
-	//delete env1;
-	if (envDist>cDistance)
-	{
-		return false;
-	}
-	// NOTE: this could be implemented more efficiently
-	double geomDist=distance(geom);
-	if (geomDist>cDistance)
-	{
-		return false;
-	}
-	return true;
+Geometry::isWithinDistance(const Geometry* geom, double cDistance) const
+{
+    const Envelope* env0 = getEnvelopeInternal();
+    const Envelope* env1 = geom->getEnvelopeInternal();
+    double envDist = env0->distance(env1);
+    //delete env0;
+    //delete env1;
+    if(envDist > cDistance) {
+        return false;
+    }
+    // NOTE: this could be implemented more efficiently
+    double geomDist = distance(geom);
+    if(geomDist > cDistance) {
+        return false;
+    }
+    return true;
 }
 
 /*public*/
 Point*
 Geometry::getCentroid() const
 {
-	Coordinate centPt;
-	if ( ! getCentroid(centPt) ) return nullptr;
+    Coordinate centPt;
+    if(! getCentroid(centPt)) {
+        return nullptr;
+    }
 
-	// We don't use createPointFromInternalCoord here
-	// because ::getCentroid() takes care about rounding
-	Point *pt=getFactory()->createPoint(centPt);
-	return pt;
+    // We don't use createPointFromInternalCoord here
+    // because ::getCentroid() takes care about rounding
+    Point* pt = getFactory()->createPoint(centPt);
+    return pt;
 }
 
 /*public*/
 bool
 Geometry::getCentroid(Coordinate& ret) const
 {
-	if ( isEmpty() ) { return false; }
-	if ( ! Centroid::getCentroid(*this, ret) ) return false;
-	getPrecisionModel()->makePrecise(ret); // not in JTS
-	return true;
+    if(isEmpty()) {
+        return false;
+    }
+    if(! Centroid::getCentroid(*this, ret)) {
+        return false;
+    }
+    getPrecisionModel()->makePrecise(ret); // not in JTS
+    return true;
 }
 
 Point*
 Geometry::getInteriorPoint() const
 {
-	Coordinate interiorPt;
-	int dim=getDimension();
-	if (dim==0) {
-		InteriorPointPoint intPt(this);
-		if ( ! intPt.getInteriorPoint(interiorPt) ) return nullptr;
-	} else if (dim==1) {
-		InteriorPointLine intPt(this);
-		if ( ! intPt.getInteriorPoint(interiorPt) ) return nullptr;
-	} else {
-		InteriorPointArea intPt(this);
-		if ( ! intPt.getInteriorPoint(interiorPt) ) return nullptr;
-	}
-	Point *p=getFactory()->createPointFromInternalCoord(&interiorPt, this);
-	return p;
+    Coordinate interiorPt;
+    int dim = getDimension();
+    if(dim == 0) {
+        InteriorPointPoint intPt(this);
+        if(! intPt.getInteriorPoint(interiorPt)) {
+            return nullptr;
+        }
+    }
+    else if(dim == 1) {
+        InteriorPointLine intPt(this);
+        if(! intPt.getInteriorPoint(interiorPt)) {
+            return nullptr;
+        }
+    }
+    else {
+        InteriorPointArea intPt(this);
+        if(! intPt.getInteriorPoint(interiorPt)) {
+            return nullptr;
+        }
+    }
+    Point* p = getFactory()->createPointFromInternalCoord(&interiorPt, this);
+    return p;
 }
 
 /**
@@ -243,7 +254,7 @@ Geometry::getInteriorPoint() const
 void
 Geometry::geometryChanged()
 {
-	apply_rw(&geometryChangedFilter);
+    apply_rw(&geometryChangedFilter);
 }
 
 /**
@@ -255,95 +266,98 @@ Geometry::geometryChanged()
 void
 Geometry::geometryChangedAction()
 {
-	//delete envelope;
-	envelope.reset(nullptr);
+    //delete envelope;
+    envelope.reset(nullptr);
 }
 
 bool
 Geometry::isValid() const
 {
-	return IsValidOp(this).isValid();
+    return IsValidOp(this).isValid();
 }
 
 Geometry*
 Geometry::getEnvelope() const
 {
-	return getFactory()->toGeometry(getEnvelopeInternal());
+    return getFactory()->toGeometry(getEnvelopeInternal());
 }
 
-const Envelope *
+const Envelope*
 Geometry::getEnvelopeInternal() const
 {
-	if (!envelope.get()) {
-		envelope = computeEnvelopeInternal();
-	}
-	return envelope.get();
+    if(!envelope.get()) {
+        envelope = computeEnvelopeInternal();
+    }
+    return envelope.get();
 }
 
 bool
-Geometry::disjoint(const Geometry *g) const
+Geometry::disjoint(const Geometry* g) const
 {
 #ifdef SHORTCIRCUIT_PREDICATES
-	// short-circuit test
-	if (! getEnvelopeInternal()->intersects(g->getEnvelopeInternal()))
-		return true;
+    // short-circuit test
+    if(! getEnvelopeInternal()->intersects(g->getEnvelopeInternal())) {
+        return true;
+    }
 #endif
-	unique_ptr<IntersectionMatrix> im ( relate(g) );
-	bool res=im->isDisjoint();
-	return res;
+    unique_ptr<IntersectionMatrix> im(relate(g));
+    bool res = im->isDisjoint();
+    return res;
 }
 
 bool
-Geometry::touches(const Geometry *g) const
+Geometry::touches(const Geometry* g) const
 {
 #ifdef SHORTCIRCUIT_PREDICATES
-	// short-circuit test
-	if (! getEnvelopeInternal()->intersects(g->getEnvelopeInternal()))
-		return false;
+    // short-circuit test
+    if(! getEnvelopeInternal()->intersects(g->getEnvelopeInternal())) {
+        return false;
+    }
 #endif
-	unique_ptr<IntersectionMatrix> im ( relate(g) );
-	bool res=im->isTouches(getDimension(), g->getDimension());
-	return res;
+    unique_ptr<IntersectionMatrix> im(relate(g));
+    bool res = im->isTouches(getDimension(), g->getDimension());
+    return res;
 }
 
 bool
-Geometry::intersects(const Geometry *g) const
+Geometry::intersects(const Geometry* g) const
 {
 #ifdef SHORTCIRCUIT_PREDICATES
-	// short-circuit test
-	if (! getEnvelopeInternal()->intersects(g->getEnvelopeInternal()))
-		return false;
+    // short-circuit test
+    if(! getEnvelopeInternal()->intersects(g->getEnvelopeInternal())) {
+        return false;
+    }
 #endif
 
-	/**
-	 * TODO: (MD) Add optimizations:
-	 *
-	 * - for P-A case:
-	 * If P is in env(A), test for point-in-poly
-	 *
-	 * - for A-A case:
-	 * If env(A1).overlaps(env(A2))
-	 * test for overlaps via point-in-poly first (both ways)
-	 * Possibly optimize selection of point to test by finding point of A1
-	 * closest to centre of env(A2).
-	 * (Is there a test where we shouldn't bother - e.g. if env A
-	 * is much smaller than env B, maybe there's no point in testing
-	 * pt(B) in env(A)?
-	 */
-
-	// optimization for rectangle arguments
-	if (isRectangle()) {
-		const Polygon* p = dynamic_cast<const Polygon*>(this);
-		return predicate::RectangleIntersects::intersects(*p, *g);
-	}
-	if (g->isRectangle()) {
-		const Polygon* p = dynamic_cast<const Polygon*>(g);
-		return predicate::RectangleIntersects::intersects(*p, *this);
-	}
-
-	unique_ptr<IntersectionMatrix> im ( relate(g) );
-	bool res=im->isIntersects();
-	return res;
+    /**
+     * TODO: (MD) Add optimizations:
+     *
+     * - for P-A case:
+     * If P is in env(A), test for point-in-poly
+     *
+     * - for A-A case:
+     * If env(A1).overlaps(env(A2))
+     * test for overlaps via point-in-poly first (both ways)
+     * Possibly optimize selection of point to test by finding point of A1
+     * closest to centre of env(A2).
+     * (Is there a test where we shouldn't bother - e.g. if env A
+     * is much smaller than env B, maybe there's no point in testing
+     * pt(B) in env(A)?
+     */
+
+    // optimization for rectangle arguments
+    if(isRectangle()) {
+        const Polygon* p = dynamic_cast<const Polygon*>(this);
+        return predicate::RectangleIntersects::intersects(*p, *g);
+    }
+    if(g->isRectangle()) {
+        const Polygon* p = dynamic_cast<const Polygon*>(g);
+        return predicate::RectangleIntersects::intersects(*p, *this);
+    }
+
+    unique_ptr<IntersectionMatrix> im(relate(g));
+    bool res = im->isIntersects();
+    return res;
 }
 
 /*public*/
@@ -351,419 +365,446 @@ bool
 Geometry::covers(const Geometry* g) const
 {
     // optimization - lower dimension cannot cover areas
-    if (g->getDimension() == 2 && getDimension() < 2) {
+    if(g->getDimension() == 2 && getDimension() < 2) {
         return false;
     }
 
     // optimization - P cannot cover a non-zero-length L
     // Note that a point can cover a zero-length lineal geometry
-    if (g->getDimension() == 1 && getDimension() < 1 && g->getLength() > 0.0) {
+    if(g->getDimension() == 1 && getDimension() < 1 && g->getLength() > 0.0) {
         return false;
     }
 
 #ifdef SHORTCIRCUIT_PREDICATES
-	// short-circuit test
-	if (! getEnvelopeInternal()->covers(g->getEnvelopeInternal()))
-		return false;
+    // short-circuit test
+    if(! getEnvelopeInternal()->covers(g->getEnvelopeInternal())) {
+        return false;
+    }
 #endif
 
-	// optimization for rectangle arguments
-	if (isRectangle()) {
-		// since we have already tested that the test envelope
-		// is covered
-		return true;
-	}
+    // optimization for rectangle arguments
+    if(isRectangle()) {
+        // since we have already tested that the test envelope
+        // is covered
+        return true;
+    }
 
-	unique_ptr<IntersectionMatrix> im(relate(g));
-	return im->isCovers();
+    unique_ptr<IntersectionMatrix> im(relate(g));
+    return im->isCovers();
 }
 
 
 bool
-Geometry::crosses(const Geometry *g) const
+Geometry::crosses(const Geometry* g) const
 {
 #ifdef SHORTCIRCUIT_PREDICATES
-	// short-circuit test
-	if (! getEnvelopeInternal()->intersects(g->getEnvelopeInternal()))
-		return false;
+    // short-circuit test
+    if(! getEnvelopeInternal()->intersects(g->getEnvelopeInternal())) {
+        return false;
+    }
 #endif
-	unique_ptr<IntersectionMatrix> im ( relate(g) );
-	bool res=im->isCrosses(getDimension(), g->getDimension());
-	return res;
+    unique_ptr<IntersectionMatrix> im(relate(g));
+    bool res = im->isCrosses(getDimension(), g->getDimension());
+    return res;
 }
 
 bool
-Geometry::within(const Geometry *g) const
+Geometry::within(const Geometry* g) const
 {
-	return g->contains(this);
+    return g->contains(this);
 }
 
 bool
-Geometry::contains(const Geometry *g) const
+Geometry::contains(const Geometry* g) const
 {
     // optimization - lower dimension cannot contain areas
-    if (g->getDimension() == 2 && getDimension() < 2) {
+    if(g->getDimension() == 2 && getDimension() < 2) {
         return false;
     }
 
     // optimization - P cannot contain a non-zero-length L
     // Note that a point can contain a zero-length lineal geometry,
     // since the line has no boundary due to Mod-2 Boundary Rule
-    if (g->getDimension() == 1 && getDimension() < 1 && g->getLength() > 0.0) {
+    if(g->getDimension() == 1 && getDimension() < 1 && g->getLength() > 0.0) {
         return false;
     }
 
 #ifdef SHORTCIRCUIT_PREDICATES
-	// short-circuit test
-	if (! getEnvelopeInternal()->contains(g->getEnvelopeInternal()))
-		return false;
+    // short-circuit test
+    if(! getEnvelopeInternal()->contains(g->getEnvelopeInternal())) {
+        return false;
+    }
 #endif
 
-	// optimization for rectangle arguments
-	if (isRectangle()) {
-		const Polygon* p = dynamic_cast<const Polygon*>(this);
-		return predicate::RectangleContains::contains(*p, *g);
-	}
-	// Incorrect: contains is not commutative
-	//if (g->isRectangle()) {
-	//	return predicate::RectangleContains::contains((const Polygon&)*g, *this);
-	//}
+    // optimization for rectangle arguments
+    if(isRectangle()) {
+        const Polygon* p = dynamic_cast<const Polygon*>(this);
+        return predicate::RectangleContains::contains(*p, *g);
+    }
+    // Incorrect: contains is not commutative
+    //if (g->isRectangle()) {
+    //	return predicate::RectangleContains::contains((const Polygon&)*g, *this);
+    //}
 
-	unique_ptr<IntersectionMatrix> im ( relate(g) );
-	bool res=im->isContains();
-	return res;
+    unique_ptr<IntersectionMatrix> im(relate(g));
+    bool res = im->isContains();
+    return res;
 }
 
 bool
-Geometry::overlaps(const Geometry *g) const
+Geometry::overlaps(const Geometry* g) const
 {
 #ifdef SHORTCIRCUIT_PREDICATES
-	// short-circuit test
-	if (! getEnvelopeInternal()->intersects(g->getEnvelopeInternal()))
-		return false;
+    // short-circuit test
+    if(! getEnvelopeInternal()->intersects(g->getEnvelopeInternal())) {
+        return false;
+    }
 #endif
-	unique_ptr<IntersectionMatrix> im ( relate(g) );
-	bool res=im->isOverlaps(getDimension(), g->getDimension());
-	return res;
+    unique_ptr<IntersectionMatrix> im(relate(g));
+    bool res = im->isOverlaps(getDimension(), g->getDimension());
+    return res;
 }
 
 bool
-Geometry::relate(const Geometry *g, const string &intersectionPattern) const
+Geometry::relate(const Geometry* g, const string& intersectionPattern) const
 {
-	unique_ptr<IntersectionMatrix> im ( relate(g) );
-	bool res=im->matches(intersectionPattern);
-	return res;
+    unique_ptr<IntersectionMatrix> im(relate(g));
+    bool res = im->matches(intersectionPattern);
+    return res;
 }
 
 bool
-Geometry::equals(const Geometry *g) const
+Geometry::equals(const Geometry* g) const
 {
 #ifdef SHORTCIRCUIT_PREDICATES
-	// short-circuit test
-	if (! getEnvelopeInternal()->equals(g->getEnvelopeInternal()))
-		return false;
+    // short-circuit test
+    if(! getEnvelopeInternal()->equals(g->getEnvelopeInternal())) {
+        return false;
+    }
 #endif
 
-	if (isEmpty()) return g->isEmpty();
-	else if (g->isEmpty()) return isEmpty();
+    if(isEmpty()) {
+        return g->isEmpty();
+    }
+    else if(g->isEmpty()) {
+        return isEmpty();
+    }
 
-	unique_ptr<IntersectionMatrix> im ( relate(g) );
-	bool res=im->isEquals(getDimension(), g->getDimension());
-	return res;
+    unique_ptr<IntersectionMatrix> im(relate(g));
+    bool res = im->isEquals(getDimension(), g->getDimension());
+    return res;
 }
 
 IntersectionMatrix*
-Geometry::relate(const Geometry *other) const
-	//throw(IllegalArgumentException *)
+Geometry::relate(const Geometry* other) const
+//throw(IllegalArgumentException *)
 {
-	return RelateOp::relate(this, other);
+    return RelateOp::relate(this, other);
 }
 
 string
 Geometry::toString() const
 {
-	return toText();
+    return toText();
 }
 
 std::ostream&
 operator<< (std::ostream& os, const Geometry& geom)
 {
-	io::WKBWriter writer;
-	writer.writeHEX(geom, os);
-	return os;
+    io::WKBWriter writer;
+    writer.writeHEX(geom, os);
+    return os;
 }
 
 string
 Geometry::toText() const
 {
-	io::WKTWriter writer;
-	return writer.write(this);
+    io::WKTWriter writer;
+    return writer.write(this);
 }
 
 Geometry*
 Geometry::buffer(double p_distance) const
 {
-	return BufferOp::bufferOp(this, p_distance);
+    return BufferOp::bufferOp(this, p_distance);
 }
 
 Geometry*
-Geometry::buffer(double p_distance,int quadrantSegments) const
+Geometry::buffer(double p_distance, int quadrantSegments) const
 {
-	return BufferOp::bufferOp(this, p_distance, quadrantSegments);
+    return BufferOp::bufferOp(this, p_distance, quadrantSegments);
 }
 
 Geometry*
 Geometry::buffer(double p_distance, int quadrantSegments, int endCapStyle) const
 {
-	return BufferOp::bufferOp(this, p_distance, quadrantSegments, endCapStyle);
+    return BufferOp::bufferOp(this, p_distance, quadrantSegments, endCapStyle);
 }
 
 Geometry*
 Geometry::convexHull() const
 {
-	return ConvexHull(this).getConvexHull();
+    return ConvexHull(this).getConvexHull();
 }
 
 Geometry*
-Geometry::intersection(const Geometry *other) const
+Geometry::intersection(const Geometry* other) const
 {
-	/**
-   * TODO: MD - add optimization for P-A case using Point-In-Polygon
-   */
+    /**
+    * TODO: MD - add optimization for P-A case using Point-In-Polygon
+    */
 
-	// special case: if one input is empty ==> empty
-	if (isEmpty() || other->isEmpty() )
-	{
-		return getFactory()->createGeometryCollection();
-	}
+    // special case: if one input is empty ==> empty
+    if(isEmpty() || other->isEmpty()) {
+        return getFactory()->createGeometryCollection();
+    }
 
 #ifdef USE_RECTANGLE_INTERSECTION
-	// optimization for rectangle arguments
-  using operation::intersection::Rectangle;
-  using operation::intersection::RectangleIntersection;
-	if ( isRectangle() ) {
-    const Envelope* env = getEnvelopeInternal();
-    Rectangle rect(env->getMinX(), env->getMinY(),
-                   env->getMaxX(), env->getMaxY());
-    return RectangleIntersection::clip(*other, rect).release();
-  }
-	if (other->isRectangle()) {
-    const Envelope* env = other->getEnvelopeInternal();
-    Rectangle rect(env->getMinX(), env->getMinY(),
-                   env->getMaxX(), env->getMaxY());
-    return RectangleIntersection::clip(*this, rect).release();
-  }
+    // optimization for rectangle arguments
+    using operation::intersection::Rectangle;
+    using operation::intersection::RectangleIntersection;
+    if(isRectangle()) {
+        const Envelope* env = getEnvelopeInternal();
+        Rectangle rect(env->getMinX(), env->getMinY(),
+                       env->getMaxX(), env->getMaxY());
+        return RectangleIntersection::clip(*other, rect).release();
+    }
+    if(other->isRectangle()) {
+        const Envelope* env = other->getEnvelopeInternal();
+        Rectangle rect(env->getMinX(), env->getMinY(),
+                       env->getMaxX(), env->getMaxY());
+        return RectangleIntersection::clip(*this, rect).release();
+    }
 #endif
 
-	return BinaryOp(this, other, overlayOp(OverlayOp::opINTERSECTION)).release();
+    return BinaryOp(this, other, overlayOp(OverlayOp::opINTERSECTION)).release();
 }
 
 Geometry*
-Geometry::Union(const Geometry *other) const
-	//throw(TopologyException *, IllegalArgumentException *)
+Geometry::Union(const Geometry* other) const
+//throw(TopologyException *, IllegalArgumentException *)
 {
 
-	// special case: if one input is empty ==> other input
-	if ( isEmpty() ) return other->clone();
-	if ( other->isEmpty() ) return clone();
+    // special case: if one input is empty ==> other input
+    if(isEmpty()) {
+        return other->clone();
+    }
+    if(other->isEmpty()) {
+        return clone();
+    }
 
-	Geometry *out = nullptr;
+    Geometry* out = nullptr;
 
 #ifdef SHORTCIRCUIT_PREDICATES
-	// if envelopes are disjoint return a MULTI geom or
-	// a geometrycollection
-	if ( ! getEnvelopeInternal()->intersects(other->getEnvelopeInternal()) )
-	{
+    // if envelopes are disjoint return a MULTI geom or
+    // a geometrycollection
+    if(! getEnvelopeInternal()->intersects(other->getEnvelopeInternal())) {
 //cerr<<"SHORTCIRCUITED-UNION engaged"<<endl;
-		const GeometryCollection *coll;
-
-		size_t ngeomsThis = getNumGeometries();
-		size_t ngeomsOther = other->getNumGeometries();
-
-		// Allocated for ownership transfer
-		vector<Geometry *> *v = new vector<Geometry *>();
-		v->reserve(ngeomsThis+ngeomsOther);
-
-
-		if ( nullptr != (coll = dynamic_cast<const GeometryCollection *>(this)) )
-		{
-			for (size_t i=0; i<ngeomsThis; ++i)
-				v->push_back(coll->getGeometryN(i)->clone());
-		} else {
-			v->push_back(this->clone());
-		}
-
-		if ( nullptr != (coll = dynamic_cast<const GeometryCollection *>(other)) )
-		{
-			for (size_t i=0; i<ngeomsOther; ++i)
-				v->push_back(coll->getGeometryN(i)->clone());
-		} else {
-			v->push_back(other->clone());
-		}
-
-		out = _factory->buildGeometry(v);
-		return out;
-	}
+        const GeometryCollection* coll;
+
+        size_t ngeomsThis = getNumGeometries();
+        size_t ngeomsOther = other->getNumGeometries();
+
+        // Allocated for ownership transfer
+        vector<Geometry*>* v = new vector<Geometry*>();
+        v->reserve(ngeomsThis + ngeomsOther);
+
+
+        if(nullptr != (coll = dynamic_cast<const GeometryCollection*>(this))) {
+            for(size_t i = 0; i < ngeomsThis; ++i) {
+                v->push_back(coll->getGeometryN(i)->clone());
+            }
+        }
+        else {
+            v->push_back(this->clone());
+        }
+
+        if(nullptr != (coll = dynamic_cast<const GeometryCollection*>(other))) {
+            for(size_t i = 0; i < ngeomsOther; ++i) {
+                v->push_back(coll->getGeometryN(i)->clone());
+            }
+        }
+        else {
+            v->push_back(other->clone());
+        }
+
+        out = _factory->buildGeometry(v);
+        return out;
+    }
 #endif
 
-	return BinaryOp(this, other, overlayOp(OverlayOp::opUNION)).release();
+    return BinaryOp(this, other, overlayOp(OverlayOp::opUNION)).release();
 }
 
 /* public */
 Geometry::Ptr
 Geometry::Union() const
 {
-  using geos::operation::geounion::UnaryUnionOp;
-  return UnaryUnionOp::Union(*this);
+    using geos::operation::geounion::UnaryUnionOp;
+    return UnaryUnionOp::Union(*this);
 }
 
 Geometry*
-Geometry::difference(const Geometry *other) const
-	//throw(IllegalArgumentException *)
+Geometry::difference(const Geometry* other) const
+//throw(IllegalArgumentException *)
 {
-	// special case: if A.isEmpty ==> empty; if B.isEmpty ==> A
-	if (isEmpty()) return getFactory()->createGeometryCollection();
-	if (other->isEmpty()) return clone();
+    // special case: if A.isEmpty ==> empty; if B.isEmpty ==> A
+    if(isEmpty()) {
+        return getFactory()->createGeometryCollection();
+    }
+    if(other->isEmpty()) {
+        return clone();
+    }
 
-	return BinaryOp(this, other, overlayOp(OverlayOp::opDIFFERENCE)).release();
+    return BinaryOp(this, other, overlayOp(OverlayOp::opDIFFERENCE)).release();
 }
 
 Geometry*
-Geometry::symDifference(const Geometry *other) const
+Geometry::symDifference(const Geometry* other) const
 {
-	// special case: if either input is empty ==> other input
-	if ( isEmpty() ) return other->clone();
-	if ( other->isEmpty() ) return clone();
-
-	// if envelopes are disjoint return a MULTI geom or
-	// a geometrycollection
-	if ( ! getEnvelopeInternal()->intersects(other->getEnvelopeInternal()) )
-	{
-		const GeometryCollection *coll;
-
-		size_t ngeomsThis = getNumGeometries();
-		size_t ngeomsOther = other->getNumGeometries();
-
-		// Allocated for ownership transfer
-		vector<Geometry *> *v = new vector<Geometry *>();
-		v->reserve(ngeomsThis+ngeomsOther);
-
-
-		if ( nullptr != (coll = dynamic_cast<const GeometryCollection *>(this)) )
-		{
-			for (size_t i=0; i<ngeomsThis; ++i)
-				v->push_back(coll->getGeometryN(i)->clone());
-		} else {
-			v->push_back(this->clone());
-		}
-
-		if ( nullptr != (coll = dynamic_cast<const GeometryCollection *>(other)) )
-		{
-			for (size_t i=0; i<ngeomsOther; ++i)
-				v->push_back(coll->getGeometryN(i)->clone());
-		} else {
-			v->push_back(other->clone());
-		}
+    // special case: if either input is empty ==> other input
+    if(isEmpty()) {
+        return other->clone();
+    }
+    if(other->isEmpty()) {
+        return clone();
+    }
 
-		return _factory->buildGeometry(v);
-	}
+    // if envelopes are disjoint return a MULTI geom or
+    // a geometrycollection
+    if(! getEnvelopeInternal()->intersects(other->getEnvelopeInternal())) {
+        const GeometryCollection* coll;
+
+        size_t ngeomsThis = getNumGeometries();
+        size_t ngeomsOther = other->getNumGeometries();
+
+        // Allocated for ownership transfer
+        vector<Geometry*>* v = new vector<Geometry*>();
+        v->reserve(ngeomsThis + ngeomsOther);
+
+
+        if(nullptr != (coll = dynamic_cast<const GeometryCollection*>(this))) {
+            for(size_t i = 0; i < ngeomsThis; ++i) {
+                v->push_back(coll->getGeometryN(i)->clone());
+            }
+        }
+        else {
+            v->push_back(this->clone());
+        }
+
+        if(nullptr != (coll = dynamic_cast<const GeometryCollection*>(other))) {
+            for(size_t i = 0; i < ngeomsOther; ++i) {
+                v->push_back(coll->getGeometryN(i)->clone());
+            }
+        }
+        else {
+            v->push_back(other->clone());
+        }
+
+        return _factory->buildGeometry(v);
+    }
 
-	return BinaryOp(this, other, overlayOp(OverlayOp::opSYMDIFFERENCE)).release();
+    return BinaryOp(this, other, overlayOp(OverlayOp::opSYMDIFFERENCE)).release();
 }
 
 int
-Geometry::compareTo(const Geometry *geom) const
-{
-	// compare to self
-	if (this == geom) return 0;
-
-	if (getSortIndex() != geom->getSortIndex()) {
-		int diff = getSortIndex() - geom->getSortIndex();
-		return (diff > 0) - (diff < 0); // signum()
-	}
-	if (isEmpty() && geom->isEmpty()) {
-		return 0;
-	}
-	if (isEmpty()) {
-		return -1;
-	}
-	if (geom->isEmpty()) {
-		return 1;
-	}
-	return compareToSameClass(geom);
+Geometry::compareTo(const Geometry* geom) const
+{
+    // compare to self
+    if(this == geom) {
+        return 0;
+    }
+
+    if(getSortIndex() != geom->getSortIndex()) {
+        int diff = getSortIndex() - geom->getSortIndex();
+        return (diff > 0) - (diff < 0); // signum()
+    }
+    if(isEmpty() && geom->isEmpty()) {
+        return 0;
+    }
+    if(isEmpty()) {
+        return -1;
+    }
+    if(geom->isEmpty()) {
+        return 1;
+    }
+    return compareToSameClass(geom);
 }
 
 bool
-Geometry::isEquivalentClass(const Geometry *other) const
+Geometry::isEquivalentClass(const Geometry* other) const
 {
-	if (typeid(*this)==typeid(*other))
-		return true;
-	else
-		return false;
+    if(typeid(*this) == typeid(*other)) {
+        return true;
+    }
+    else {
+        return false;
+    }
 }
 
 /*public static*/
 void
-Geometry::checkNotGeometryCollection(const Geometry *g)
-	//throw(IllegalArgumentException *)
+Geometry::checkNotGeometryCollection(const Geometry* g)
+//throw(IllegalArgumentException *)
 {
-	if (g->getSortIndex() == SORTINDEX_GEOMETRYCOLLECTION) {
-		throw  geos::util::IllegalArgumentException("This method does not support GeometryCollection arguments\n");
-	}
+    if(g->getSortIndex() == SORTINDEX_GEOMETRYCOLLECTION) {
+        throw  geos::util::IllegalArgumentException("This method does not support GeometryCollection arguments\n");
+    }
 }
 
 
-void Geometry::GeometryChangedFilter::filter_rw(Geometry* geom)
+void
+Geometry::GeometryChangedFilter::filter_rw(Geometry* geom)
 {
-   geom->geometryChangedAction();
+    geom->geometryChangedAction();
 }
 
 int
 Geometry::compare(vector<Coordinate> a, vector<Coordinate> b) const
 {
-	size_t i=0;
-	size_t j=0;
-	while (i<a.size() && j<b.size()) {
-		Coordinate& aCoord=a[i];
-		Coordinate& bCoord=b[j];
-		int comparison=aCoord.compareTo(bCoord);
-		if (comparison!=0) {
-			return comparison;
-		}
-		i++;
-		j++;
-	}
-	if (i<a.size()) {
-		return 1;
-	}
-	if (j<b.size()) {
-		return -1;
-	}
-	return 0;
+    size_t i = 0;
+    size_t j = 0;
+    while(i < a.size() && j < b.size()) {
+        Coordinate& aCoord = a[i];
+        Coordinate& bCoord = b[j];
+        int comparison = aCoord.compareTo(bCoord);
+        if(comparison != 0) {
+            return comparison;
+        }
+        i++;
+        j++;
+    }
+    if(i < a.size()) {
+        return 1;
+    }
+    if(j < b.size()) {
+        return -1;
+    }
+    return 0;
 }
 
 int
-Geometry::compare(vector<Geometry *> a, vector<Geometry *> b) const
-{
-	size_t i=0;
-	size_t j=0;
-	while (i<a.size() && j<b.size()) {
-		Geometry *aGeom=a[i];
-		Geometry *bGeom=b[j];
-		int comparison=aGeom->compareTo(bGeom);
-		if (comparison!=0) {
-			return comparison;
-		}
-		i++;
-		j++;
-	}
-	if (i<a.size()) {
-		return 1;
-	}
-	if (j<b.size()) {
-		return -1;
-	}
-	return 0;
+Geometry::compare(vector<Geometry*> a, vector<Geometry*> b) const
+{
+    size_t i = 0;
+    size_t j = 0;
+    while(i < a.size() && j < b.size()) {
+        Geometry* aGeom = a[i];
+        Geometry* bGeom = b[j];
+        int comparison = aGeom->compareTo(bGeom);
+        if(comparison != 0) {
+            return comparison;
+        }
+        i++;
+        j++;
+    }
+    if(i < a.size()) {
+        return 1;
+    }
+    if(j < b.size()) {
+        return -1;
+    }
+    return 0;
 }
 
 /**
@@ -773,9 +814,9 @@ Geometry::compare(vector<Geometry *> a, vector<Geometry *> b) const
  * @param  other  the Geometry from which to compute the distance
  */
 double
-Geometry::distance(const Geometry *other) const
+Geometry::distance(const Geometry* other) const
 {
-	return DistanceOp::distance(this, other);
+    return DistanceOp::distance(this, other);
 }
 
 /**
@@ -789,7 +830,7 @@ Geometry::distance(const Geometry *other) const
 double
 Geometry::getArea() const
 {
-	return 0.0;
+    return 0.0;
 }
 
 /**
@@ -804,71 +845,72 @@ Geometry::getArea() const
 double
 Geometry::getLength() const
 {
-	return 0.0;
+    return 0.0;
 }
 
 Geometry::~Geometry()
 {
-	_factory->dropRef();
+    _factory->dropRef();
 }
 
 bool
-GeometryGreaterThen::operator()(const Geometry *first, const Geometry *second)
+GeometryGreaterThen::operator()(const Geometry* first, const Geometry* second)
 {
-	if (first->compareTo(second)>0)
-		return true;
-	else
-		return false;
+    if(first->compareTo(second) > 0) {
+        return true;
+    }
+    else {
+        return false;
+    }
 }
 
 bool
 Geometry::equal(const Coordinate& a, const Coordinate& b,
-	double tolerance) const
+                double tolerance) const
 {
-	if (tolerance==0)
-	{
-		return a == b; // 2D only !!!
-	}
-	//double dist=a.distance(b);
-	return a.distance(b)<=tolerance;
+    if(tolerance == 0) {
+        return a == b; // 2D only !!!
+    }
+    //double dist=a.distance(b);
+    return a.distance(b) <= tolerance;
 }
 
 void
-Geometry::apply_ro(GeometryFilter *filter) const
+Geometry::apply_ro(GeometryFilter* filter) const
 {
-	filter->filter_ro(this);
+    filter->filter_ro(this);
 }
 
 void
-Geometry::apply_rw(GeometryFilter *filter)
+Geometry::apply_rw(GeometryFilter* filter)
 {
-	filter->filter_rw(this);
+    filter->filter_rw(this);
 }
 
 void
-Geometry::apply_ro(GeometryComponentFilter *filter) const
+Geometry::apply_ro(GeometryComponentFilter* filter) const
 {
-	filter->filter_ro(this);
+    filter->filter_ro(this);
 }
 
 void
-Geometry::apply_rw(GeometryComponentFilter *filter)
+Geometry::apply_rw(GeometryComponentFilter* filter)
 {
-	filter->filter_rw(this);
+    filter->filter_rw(this);
 }
 
 bool
 Geometry::isSimple() const
 {
-	operation::IsSimpleOp op(*this);
-	return op.isSimple();
+    operation::IsSimpleOp op(*this);
+    return op.isSimple();
 }
 
 /* public */
 const PrecisionModel*
 Geometry::getPrecisionModel() const
 {
-	return _factory->getPrecisionModel();
+    return _factory->getPrecisionModel();
 }
 
 } // namespace geos::geom
diff --git a/src/geom/GeometryCollection.cpp b/src/geom/GeometryCollection.cpp
index 3f78830..8b03c4f 100644
--- a/src/geom/GeometryCollection.cpp
+++ b/src/geom/GeometryCollection.cpp
@@ -42,49 +42,46 @@ namespace geos {
 namespace geom { // geos::geom
 
 /*protected*/
-GeometryCollection::GeometryCollection(const GeometryCollection &gc)
-	:
-	Geometry(gc)
+GeometryCollection::GeometryCollection(const GeometryCollection& gc)
+    :
+    Geometry(gc)
 {
-	size_t ngeoms=gc.geometries->size();
+    size_t ngeoms = gc.geometries->size();
 
-	geometries=new vector<Geometry *>(ngeoms);
-	for(size_t i=0; i<ngeoms; ++i)
-	{
-		(*geometries)[i]=(*gc.geometries)[i]->clone();
-	}
+    geometries = new vector<Geometry*>(ngeoms);
+    for(size_t i = 0; i < ngeoms; ++i) {
+        (*geometries)[i] = (*gc.geometries)[i]->clone();
+    }
 }
 
 /*protected*/
-GeometryCollection::GeometryCollection(vector<Geometry *> *newGeoms, const GeometryFactory *factory):
-	Geometry(factory)
+GeometryCollection::GeometryCollection(vector<Geometry*>* newGeoms, const GeometryFactory* factory):
+    Geometry(factory)
 {
-	if (newGeoms==nullptr) {
-		geometries=new vector<Geometry *>();
-		return;
-	}
-	if (hasNullElements(newGeoms)) {
-		throw  util::IllegalArgumentException("geometries must not contain null elements\n");
-		return;
-	}
-	geometries=newGeoms;
-
-	// Set SRID for inner geoms
-	size_t ngeoms=geometries->size();
-	for(size_t i=0; i<ngeoms; ++i)
-	{
-		(*geometries)[i]->setSRID(getSRID());
-	}
+    if(newGeoms == nullptr) {
+        geometries = new vector<Geometry*>();
+        return;
+    }
+    if(hasNullElements(newGeoms)) {
+        throw  util::IllegalArgumentException("geometries must not contain null elements\n");
+        return;
+    }
+    geometries = newGeoms;
+
+    // Set SRID for inner geoms
+    size_t ngeoms = geometries->size();
+    for(size_t i = 0; i < ngeoms; ++i) {
+        (*geometries)[i]->setSRID(getSRID());
+    }
 }
 
 void
 GeometryCollection::setSRID(int newSRID)
 {
-	Geometry::setSRID(newSRID);
-	for (size_t i = 0; i < geometries->size(); i++)
-	{
-		(*geometries)[i]->setSRID(newSRID);
-	}
+    Geometry::setSRID(newSRID);
+    for(size_t i = 0; i < geometries->size(); i++) {
+        (*geometries)[i]->setSRID(newSRID);
+    }
 }
 
 /*
@@ -93,196 +90,191 @@ GeometryCollection::setSRID(int newSRID)
  * Returns a newly the collected coordinates
  *
  */
-CoordinateSequence *
+CoordinateSequence*
 GeometryCollection::getCoordinates() const
 {
-	vector<Coordinate> *coordinates = new vector<Coordinate>(getNumPoints());
-
-	int k = -1;
-	for (size_t i=0; i<geometries->size(); ++i) {
-		CoordinateSequence* childCoordinates=(*geometries)[i]->getCoordinates();
-		size_t npts=childCoordinates->getSize();
-		for (size_t j=0; j<npts; ++j) {
-			k++;
-			(*coordinates)[k] = childCoordinates->getAt(j);
-		}
-		delete childCoordinates;
-	}
-	return CoordinateArraySequenceFactory::instance()->create(coordinates);
+    vector<Coordinate>* coordinates = new vector<Coordinate>(getNumPoints());
+
+    int k = -1;
+    for(size_t i = 0; i < geometries->size(); ++i) {
+        CoordinateSequence* childCoordinates = (*geometries)[i]->getCoordinates();
+        size_t npts = childCoordinates->getSize();
+        for(size_t j = 0; j < npts; ++j) {
+            k++;
+            (*coordinates)[k] = childCoordinates->getAt(j);
+        }
+        delete childCoordinates;
+    }
+    return CoordinateArraySequenceFactory::instance()->create(coordinates);
 }
 
 bool
 GeometryCollection::isEmpty() const
 {
-	for (size_t i=0; i<geometries->size(); ++i) {
-		if (!(*geometries)[i]->isEmpty()) {
-			return false;
-		}
-	}
-	return true;
+    for(size_t i = 0; i < geometries->size(); ++i) {
+        if(!(*geometries)[i]->isEmpty()) {
+            return false;
+        }
+    }
+    return true;
 }
 
 Dimension::DimensionType
 GeometryCollection::getDimension() const
 {
-	Dimension::DimensionType dimension=Dimension::False;
-	for (size_t i=0, n=geometries->size(); i<n; ++i)
-	{
-		dimension=max(dimension,(*geometries)[i]->getDimension());
-	}
-	return dimension;
+    Dimension::DimensionType dimension = Dimension::False;
+    for(size_t i = 0, n = geometries->size(); i < n; ++i) {
+        dimension = max(dimension, (*geometries)[i]->getDimension());
+    }
+    return dimension;
 }
 
 int
 GeometryCollection::getBoundaryDimension() const
 {
-	int dimension=Dimension::False;
-	for(size_t i=0; i<geometries->size(); ++i) {
-		dimension=max(dimension,(*geometries)[i]->getBoundaryDimension());
-	}
-	return dimension;
+    int dimension = Dimension::False;
+    for(size_t i = 0; i < geometries->size(); ++i) {
+        dimension = max(dimension, (*geometries)[i]->getBoundaryDimension());
+    }
+    return dimension;
 }
 
 int
 GeometryCollection::getCoordinateDimension() const
 {
-	int dimension=2;
+    int dimension = 2;
 
-	for (size_t i=0, n=geometries->size(); i<n; ++i)
-	{
-		dimension=max(dimension,(*geometries)[i]->getCoordinateDimension());
-	}
-	return dimension;
+    for(size_t i = 0, n = geometries->size(); i < n; ++i) {
+        dimension = max(dimension, (*geometries)[i]->getCoordinateDimension());
+    }
+    return dimension;
 }
 
 size_t
 GeometryCollection::getNumGeometries() const
 {
-	return geometries->size();
+    return geometries->size();
 }
 
 const Geometry*
 GeometryCollection::getGeometryN(size_t n) const
 {
-	return (*geometries)[n];
+    return (*geometries)[n];
 }
 
 size_t
 GeometryCollection::getNumPoints() const
 {
-	size_t numPoints = 0;
-	for (size_t i=0, n=geometries->size(); i<n; ++i)
-	{
-		numPoints +=(*geometries)[i]->getNumPoints();
-	}
-	return numPoints;
+    size_t numPoints = 0;
+    for(size_t i = 0, n = geometries->size(); i < n; ++i) {
+        numPoints += (*geometries)[i]->getNumPoints();
+    }
+    return numPoints;
 }
 
 string
 GeometryCollection::getGeometryType() const
 {
-	return "GeometryCollection";
+    return "GeometryCollection";
 }
 
 Geometry*
 GeometryCollection::getBoundary() const
 {
-	throw util::IllegalArgumentException("Operation not supported by GeometryCollection\n");
+    throw util::IllegalArgumentException("Operation not supported by GeometryCollection\n");
 }
 
 bool
-GeometryCollection::equalsExact(const Geometry *other, double tolerance) const
+GeometryCollection::equalsExact(const Geometry* other, double tolerance) const
 {
-	if (!isEquivalentClass(other)) return false;
-
-	const GeometryCollection* otherCollection=dynamic_cast<const GeometryCollection *>(other);
-	if ( ! otherCollection ) return false;
-
-	if (geometries->size()!=otherCollection->geometries->size()) {
-		return false;
-	}
-	for (size_t i=0; i<geometries->size(); ++i) {
-		if (!((*geometries)[i]->equalsExact((*(otherCollection->geometries))[i],tolerance)))
-		{
-			return false;
-		}
-	}
-	return true;
+    if(!isEquivalentClass(other)) {
+        return false;
+    }
+
+    const GeometryCollection* otherCollection = dynamic_cast<const GeometryCollection*>(other);
+    if(! otherCollection) {
+        return false;
+    }
+
+    if(geometries->size() != otherCollection->geometries->size()) {
+        return false;
+    }
+    for(size_t i = 0; i < geometries->size(); ++i) {
+        if(!((*geometries)[i]->equalsExact((*(otherCollection->geometries))[i], tolerance))) {
+            return false;
+        }
+    }
+    return true;
 }
 
 void
-GeometryCollection::apply_rw(const CoordinateFilter *filter)
+GeometryCollection::apply_rw(const CoordinateFilter* filter)
 {
-	for (size_t i=0; i<geometries->size(); ++i)
-	{
-		(*geometries)[i]->apply_rw(filter);
-	}
+    for(size_t i = 0; i < geometries->size(); ++i) {
+        (*geometries)[i]->apply_rw(filter);
+    }
 }
 
 void
-GeometryCollection::apply_ro(CoordinateFilter *filter) const
+GeometryCollection::apply_ro(CoordinateFilter* filter) const
 {
-	for (size_t i=0; i<geometries->size(); ++i)
-	{
-		(*geometries)[i]->apply_ro(filter);
-	}
+    for(size_t i = 0; i < geometries->size(); ++i) {
+        (*geometries)[i]->apply_ro(filter);
+    }
 }
 
 void
-GeometryCollection::apply_ro(GeometryFilter *filter) const
+GeometryCollection::apply_ro(GeometryFilter* filter) const
 {
-	filter->filter_ro(this);
-	for(size_t i=0; i<geometries->size(); ++i)
-	{
-		(*geometries)[i]->apply_ro(filter);
-	}
+    filter->filter_ro(this);
+    for(size_t i = 0; i < geometries->size(); ++i) {
+        (*geometries)[i]->apply_ro(filter);
+    }
 }
 
 void
-GeometryCollection::apply_rw(GeometryFilter *filter)
+GeometryCollection::apply_rw(GeometryFilter* filter)
 {
-	filter->filter_rw(this);
-	for(size_t i=0; i<geometries->size(); ++i)
-	{
-		(*geometries)[i]->apply_rw(filter);
-	}
+    filter->filter_rw(this);
+    for(size_t i = 0; i < geometries->size(); ++i) {
+        (*geometries)[i]->apply_rw(filter);
+    }
 }
 
 void
 GeometryCollection::normalize()
 {
-	for (size_t i=0; i<geometries->size(); ++i) {
-		(*geometries)[i]->normalize();
-	}
-	sort(geometries->begin(), geometries->end(), GeometryGreaterThen());
+    for(size_t i = 0; i < geometries->size(); ++i) {
+        (*geometries)[i]->normalize();
+    }
+    sort(geometries->begin(), geometries->end(), GeometryGreaterThen());
 }
 
 Envelope::Ptr
 GeometryCollection::computeEnvelopeInternal() const
 {
-	Envelope::Ptr p_envelope(new Envelope());
-	for (size_t i=0; i<geometries->size(); i++) {
-		const Envelope *env=(*geometries)[i]->getEnvelopeInternal();
-		p_envelope->expandToInclude(env);
-	}
-	return p_envelope;
+    Envelope::Ptr p_envelope(new Envelope());
+    for(size_t i = 0; i < geometries->size(); i++) {
+        const Envelope* env = (*geometries)[i]->getEnvelopeInternal();
+        p_envelope->expandToInclude(env);
+    }
+    return p_envelope;
 }
 
 int
-GeometryCollection::compareToSameClass(const Geometry *g) const
+GeometryCollection::compareToSameClass(const Geometry* g) const
 {
-  const GeometryCollection* gc = dynamic_cast<const GeometryCollection*>(g);
-	return compare(*geometries, *(gc->geometries));
+    const GeometryCollection* gc = dynamic_cast<const GeometryCollection*>(g);
+    return compare(*geometries, *(gc->geometries));
 }
 
 const Coordinate*
 GeometryCollection::getCoordinate() const
 {
-	// should use unique_ptr here or return NULL or throw an exception !
-	// 	--strk;
-    for (size_t i = 0; i < geometries->size(); ++i)
-    {
-        if (!(*geometries)[i]->isEmpty()) {
+    // should use unique_ptr here or return NULL or throw an exception !
+    // 	--strk;
+    for(size_t i = 0; i < geometries->size(); ++i) {
+        if(!(*geometries)[i]->isEmpty()) {
             return (*geometries)[i]->getCoordinate();
         }
     }
@@ -295,12 +287,11 @@ GeometryCollection::getCoordinate() const
 double
 GeometryCollection::getArea() const
 {
-	double area=0.0;
-	for(size_t i=0; i<geometries->size(); ++i)
-	{
-        	area+=(*geometries)[i]->getArea();
-	}
-	return area;
+    double area = 0.0;
+    for(size_t i = 0; i < geometries->size(); ++i) {
+        area += (*geometries)[i]->getArea();
+    }
+    return area;
 }
 
 /**
@@ -309,94 +300,98 @@ GeometryCollection::getArea() const
 double
 GeometryCollection::getLength() const
 {
-	double sum=0.0;
-	for(size_t i=0; i<geometries->size(); ++i)
-	{
-        	sum+=(*geometries)[i]->getLength();
-	}
-	return sum;
+    double sum = 0.0;
+    for(size_t i = 0; i < geometries->size(); ++i) {
+        sum += (*geometries)[i]->getLength();
+    }
+    return sum;
 }
 
 void
-GeometryCollection::apply_rw(GeometryComponentFilter *filter)
+GeometryCollection::apply_rw(GeometryComponentFilter* filter)
 {
-	filter->filter_rw(this);
-	for(size_t i=0; i<geometries->size(); ++i)
-	{
-        	(*geometries)[i]->apply_rw(filter);
-	}
+    filter->filter_rw(this);
+    for(size_t i = 0; i < geometries->size(); ++i) {
+        (*geometries)[i]->apply_rw(filter);
+    }
 }
 
 void
-GeometryCollection::apply_ro(GeometryComponentFilter *filter) const
+GeometryCollection::apply_ro(GeometryComponentFilter* filter) const
 {
-	filter->filter_ro(this);
-	for(size_t i=0; i<geometries->size(); ++i)
-	{
-		(*geometries)[i]->apply_ro(filter);
-	}
+    filter->filter_ro(this);
+    for(size_t i = 0; i < geometries->size(); ++i) {
+        (*geometries)[i]->apply_ro(filter);
+    }
 }
 
 void
 GeometryCollection::apply_rw(CoordinateSequenceFilter& filter)
 {
-	size_t ngeoms = geometries->size();
-	if (ngeoms == 0 ) return;
-	for (size_t i = 0; i < ngeoms; ++i)
-	{
-		(*geometries)[i]->apply_rw(filter);
-		if (filter.isDone()) break;
-	}
-	if (filter.isGeometryChanged()) geometryChanged();
+    size_t ngeoms = geometries->size();
+    if(ngeoms == 0) {
+        return;
+    }
+    for(size_t i = 0; i < ngeoms; ++i) {
+        (*geometries)[i]->apply_rw(filter);
+        if(filter.isDone()) {
+            break;
+        }
+    }
+    if(filter.isGeometryChanged()) {
+        geometryChanged();
+    }
 }
 
 void
 GeometryCollection::apply_ro(CoordinateSequenceFilter& filter) const
 {
-	size_t ngeoms = geometries->size();
-	if (ngeoms == 0 ) return;
-	for (size_t i = 0; i < ngeoms; ++i)
-	{
-		(*geometries)[i]->apply_ro(filter);
-		if (filter.isDone()) break;
-	}
-
-	assert(!filter.isGeometryChanged()); // read-only filter...
-	//if (filter.isGeometryChanged()) geometryChanged();
+    size_t ngeoms = geometries->size();
+    if(ngeoms == 0) {
+        return;
+    }
+    for(size_t i = 0; i < ngeoms; ++i) {
+        (*geometries)[i]->apply_ro(filter);
+        if(filter.isDone()) {
+            break;
+        }
+    }
+
+    assert(!filter.isGeometryChanged()); // read-only filter...
+    //if (filter.isGeometryChanged()) geometryChanged();
 }
 
 GeometryCollection::~GeometryCollection()
 {
-	for(size_t i=0; i<geometries->size(); ++i)
-	{
-		delete (*geometries)[i];
-	}
-	delete geometries;
+    for(size_t i = 0; i < geometries->size(); ++i) {
+        delete(*geometries)[i];
+    }
+    delete geometries;
 }
 
 GeometryTypeId
 GeometryCollection::getGeometryTypeId() const
 {
-	return GEOS_GEOMETRYCOLLECTION;
+    return GEOS_GEOMETRYCOLLECTION;
 }
 
 Geometry*
 GeometryCollection::reverse() const
 {
-	if (isEmpty()) {
-		return clone();
-	}
+    if(isEmpty()) {
+        return clone();
+    }
 
-	auto* reversed = new std::vector<Geometry*>{geometries->size()};
+    auto* reversed = new std::vector<Geometry*> {geometries->size()};
 
-	std::transform(geometries->begin(),
-				   geometries->end(),
-				   reversed->begin(),
-				   [](const Geometry* g) {
-					   return g->reverse();
-				   });
+    std::transform(geometries->begin(),
+                   geometries->end(),
+                   reversed->begin(),
+    [](const Geometry * g) {
+        return g->reverse();
+    });
 
-	return getFactory()->createGeometryCollection(reversed);
+    return getFactory()->createGeometryCollection(reversed);
 }
 
 } // namespace geos::geom
diff --git a/src/geom/GeometryComponentFilter.cpp b/src/geom/GeometryComponentFilter.cpp
index bb0e533..cda1f39 100644
--- a/src/geom/GeometryComponentFilter.cpp
+++ b/src/geom/GeometryComponentFilter.cpp
@@ -22,16 +22,18 @@
 namespace geos {
 namespace geom { // geos::geom
 
-void GeometryComponentFilter::filter_rw(Geometry *geom)
+void
+GeometryComponentFilter::filter_rw(Geometry* geom)
 {
-	::geos::ignore_unused_variable_warning(geom);
-	assert(0);
+    ::geos::ignore_unused_variable_warning(geom);
+    assert(0);
 }
 
-void GeometryComponentFilter::filter_ro(const Geometry *geom)
+void
+GeometryComponentFilter::filter_ro(const Geometry* geom)
 {
-	::geos::ignore_unused_variable_warning(geom);
-	assert(0);
+    ::geos::ignore_unused_variable_warning(geom);
+    assert(0);
 }
 
 
diff --git a/src/geom/GeometryFactory.cpp b/src/geom/GeometryFactory.cpp
index e504a09..d62f10b 100644
--- a/src/geom/GeometryFactory.cpp
+++ b/src/geom/GeometryFactory.cpp
@@ -62,17 +62,18 @@ namespace geom { // geos::geom
 namespace {
 
 class gfCoordinateOperation: public util::CoordinateOperation {
-using CoordinateOperation::edit;
-  const CoordinateSequenceFactory* _gsf;
+    using CoordinateOperation::edit;
+    const CoordinateSequenceFactory* _gsf;
 public:
-  gfCoordinateOperation(const CoordinateSequenceFactory* gsf)
-      : _gsf(gsf)
-  {}
-  CoordinateSequence* edit( const CoordinateSequence *coordSeq,
-                            const Geometry * ) override
-  {
-    return _gsf->create(*coordSeq);
-  }
+    gfCoordinateOperation(const CoordinateSequenceFactory* gsf)
+        : _gsf(gsf)
+    {}
+    CoordinateSequence*
+    edit(const CoordinateSequence* coordSeq,
+         const Geometry*) override
+    {
+        return _gsf->create(*coordSeq);
+    }
 };
 
 } // anonymous namespace
@@ -81,172 +82,184 @@ public:
 
 /*protected*/
 GeometryFactory::GeometryFactory()
-	:
-	precisionModel(new PrecisionModel()),
-	SRID(0),
-	coordinateListFactory(CoordinateArraySequenceFactory::instance())
-	,_refCount(0),_autoDestroy(false)
+    :
+    precisionModel(new PrecisionModel()),
+    SRID(0),
+    coordinateListFactory(CoordinateArraySequenceFactory::instance())
+    , _refCount(0), _autoDestroy(false)
 {
 #if GEOS_DEBUG
-	std::cerr << "GEOS_DEBUG: GeometryFactory["<<this<<"]::GeometryFactory()" << std::endl;
-	std::cerr << "\tcreate PrecisionModel["<<precisionModel<<"]" << std::endl;
+    std::cerr << "GEOS_DEBUG: GeometryFactory[" << this << "]::GeometryFactory()" << std::endl;
+    std::cerr << "\tcreate PrecisionModel[" << precisionModel << "]" << std::endl;
 #endif
 }
 
 /*public static*/
 GeometryFactory::Ptr
-GeometryFactory::create() { return GeometryFactory::Ptr(new GeometryFactory()); }
+GeometryFactory::create()
+{
+    return GeometryFactory::Ptr(new GeometryFactory());
+}
 
 /*protected*/
 GeometryFactory::GeometryFactory(const PrecisionModel* pm, int newSRID,
-		CoordinateSequenceFactory* nCoordinateSequenceFactory)
-	:
-	SRID(newSRID)
-	,_refCount(0),_autoDestroy(false)
+                                 CoordinateSequenceFactory* nCoordinateSequenceFactory)
+    :
+    SRID(newSRID)
+    , _refCount(0), _autoDestroy(false)
 {
 #if GEOS_DEBUG
-	std::cerr << "GEOS_DEBUG: GeometryFactory["<<this<<"]::GeometryFactory(PrecisionModel["<<pm<<"], SRID)" << std::endl;
+    std::cerr << "GEOS_DEBUG: GeometryFactory[" << this << "]::GeometryFactory(PrecisionModel[" << pm << "], SRID)" <<
+              std::endl;
 #endif
-	if ( ! pm ) {
-		precisionModel=new PrecisionModel();
-	} else {
-		precisionModel=new PrecisionModel(*pm);
-	}
+    if(! pm) {
+        precisionModel = new PrecisionModel();
+    }
+    else {
+        precisionModel = new PrecisionModel(*pm);
+    }
 
-	if ( ! nCoordinateSequenceFactory ) {
-		coordinateListFactory=CoordinateArraySequenceFactory::instance();
-	} else {
-		coordinateListFactory=nCoordinateSequenceFactory;
-	}
+    if(! nCoordinateSequenceFactory) {
+        coordinateListFactory = CoordinateArraySequenceFactory::instance();
+    }
+    else {
+        coordinateListFactory = nCoordinateSequenceFactory;
+    }
 }
 
 /*public static*/
 GeometryFactory::Ptr
 GeometryFactory::create(const PrecisionModel* pm, int newSRID,
-		CoordinateSequenceFactory* nCoordinateSequenceFactory)
+                        CoordinateSequenceFactory* nCoordinateSequenceFactory)
 {
-  return GeometryFactory::Ptr(
-    new GeometryFactory(pm, newSRID, nCoordinateSequenceFactory)
-  );
+    return GeometryFactory::Ptr(
+               new GeometryFactory(pm, newSRID, nCoordinateSequenceFactory)
+           );
 }
 
 /*protected*/
 GeometryFactory::GeometryFactory(
-		CoordinateSequenceFactory* nCoordinateSequenceFactory)
-	:
-	precisionModel(new PrecisionModel()),
-	SRID(0)
-	,_refCount(0),_autoDestroy(false)
+    CoordinateSequenceFactory* nCoordinateSequenceFactory)
+    :
+    precisionModel(new PrecisionModel()),
+    SRID(0)
+    , _refCount(0), _autoDestroy(false)
 {
 #if GEOS_DEBUG
-	std::cerr << "GEOS_DEBUG: GeometryFactory["<<this<<"]::GeometryFactory(CoordinateSequenceFactory["<<nCoordinateSequenceFactory<<"])" << std::endl;
+    std::cerr << "GEOS_DEBUG: GeometryFactory[" << this << "]::GeometryFactory(CoordinateSequenceFactory[" <<
+              nCoordinateSequenceFactory << "])" << std::endl;
 #endif
-	if ( ! nCoordinateSequenceFactory ) {
-		coordinateListFactory=CoordinateArraySequenceFactory::instance();
-	} else {
-		coordinateListFactory=nCoordinateSequenceFactory;
-	}
+    if(! nCoordinateSequenceFactory) {
+        coordinateListFactory = CoordinateArraySequenceFactory::instance();
+    }
+    else {
+        coordinateListFactory = nCoordinateSequenceFactory;
+    }
 }
 
 /*public static*/
 GeometryFactory::Ptr
 GeometryFactory::create(
-		CoordinateSequenceFactory* nCoordinateSequenceFactory)
+    CoordinateSequenceFactory* nCoordinateSequenceFactory)
 {
-  return GeometryFactory::Ptr(
-    new GeometryFactory(nCoordinateSequenceFactory)
-  );
+    return GeometryFactory::Ptr(
+               new GeometryFactory(nCoordinateSequenceFactory)
+           );
 }
 
 /*protected*/
-GeometryFactory::GeometryFactory(const PrecisionModel *pm)
-	:
-	SRID(0),
-	coordinateListFactory(CoordinateArraySequenceFactory::instance())
-	,_refCount(0),_autoDestroy(false)
+GeometryFactory::GeometryFactory(const PrecisionModel* pm)
+    :
+    SRID(0),
+    coordinateListFactory(CoordinateArraySequenceFactory::instance())
+    , _refCount(0), _autoDestroy(false)
 {
 #if GEOS_DEBUG
-	std::cerr << "GEOS_DEBUG: GeometryFactory["<<this<<"]::GeometryFactory(PrecisionModel["<<pm<<"])" << std::endl;
+    std::cerr << "GEOS_DEBUG: GeometryFactory[" << this << "]::GeometryFactory(PrecisionModel[" << pm << "])" << std::endl;
 #endif
-	if ( ! pm ) {
-		precisionModel=new PrecisionModel();
-	} else {
-		precisionModel=new PrecisionModel(*pm);
-	}
+    if(! pm) {
+        precisionModel = new PrecisionModel();
+    }
+    else {
+        precisionModel = new PrecisionModel(*pm);
+    }
 }
 
 /*public static*/
 GeometryFactory::Ptr
-GeometryFactory::create(const PrecisionModel *pm)
+GeometryFactory::create(const PrecisionModel* pm)
 {
-  return GeometryFactory::Ptr(
-    new GeometryFactory(pm)
-  );
+    return GeometryFactory::Ptr(
+               new GeometryFactory(pm)
+           );
 }
 
 /*protected*/
 GeometryFactory::GeometryFactory(const PrecisionModel* pm, int newSRID)
-	:
-	SRID(newSRID),
-	coordinateListFactory(CoordinateArraySequenceFactory::instance())
-	,_refCount(0),_autoDestroy(false)
+    :
+    SRID(newSRID),
+    coordinateListFactory(CoordinateArraySequenceFactory::instance())
+    , _refCount(0), _autoDestroy(false)
 {
 #if GEOS_DEBUG
-	std::cerr << "GEOS_DEBUG: GeometryFactory["<<this<<"]::GeometryFactory(PrecisionModel["<<pm<<"], SRID)" << std::endl;
+    std::cerr << "GEOS_DEBUG: GeometryFactory[" << this << "]::GeometryFactory(PrecisionModel[" << pm << "], SRID)" <<
+              std::endl;
 #endif
-	if ( ! pm ) {
-		precisionModel=new PrecisionModel();
-	} else {
-		precisionModel=new PrecisionModel(*pm);
-	}
+    if(! pm) {
+        precisionModel = new PrecisionModel();
+    }
+    else {
+        precisionModel = new PrecisionModel(*pm);
+    }
 }
 
 /*public static*/
 GeometryFactory::Ptr
 GeometryFactory::create(const PrecisionModel* pm, int newSRID)
 {
-  return GeometryFactory::Ptr(
-    new GeometryFactory(pm, newSRID)
-  );
+    return GeometryFactory::Ptr(
+               new GeometryFactory(pm, newSRID)
+           );
 }
 
 /*protected*/
-GeometryFactory::GeometryFactory(const GeometryFactory &gf)
+GeometryFactory::GeometryFactory(const GeometryFactory& gf)
 {
-	assert(gf.precisionModel);
-	precisionModel=new PrecisionModel(*(gf.precisionModel));
-	SRID=gf.SRID;
-	coordinateListFactory=gf.coordinateListFactory;
-  _autoDestroy=false;
-  _refCount=0;
+    assert(gf.precisionModel);
+    precisionModel = new PrecisionModel(*(gf.precisionModel));
+    SRID = gf.SRID;
+    coordinateListFactory = gf.coordinateListFactory;
+    _autoDestroy = false;
+    _refCount = 0;
 }
 
 /*public static*/
 GeometryFactory::Ptr
-GeometryFactory::create(const GeometryFactory &gf)
+GeometryFactory::create(const GeometryFactory& gf)
 {
-  return GeometryFactory::Ptr(
-    new GeometryFactory(gf)
-  );
+    return GeometryFactory::Ptr(
+               new GeometryFactory(gf)
+           );
 }
 
 /*public virtual*/
-GeometryFactory::~GeometryFactory(){
+GeometryFactory::~GeometryFactory()
+{
 #if GEOS_DEBUG
-	std::cerr << "GEOS_DEBUG: GeometryFactory["<<this<<"]::~GeometryFactory()" << std::endl;
+    std::cerr << "GEOS_DEBUG: GeometryFactory[" << this << "]::~GeometryFactory()" << std::endl;
 #endif
-	delete precisionModel;
+    delete precisionModel;
 }
 
 /*public*/
 Point*
 GeometryFactory::createPointFromInternalCoord(const Coordinate* coord,
-		const Geometry *exemplar) const
+        const Geometry* exemplar) const
 {
-	assert(coord);
-	Coordinate newcoord = *coord;
-	exemplar->getPrecisionModel()->makePrecise(&newcoord);
-	return exemplar->getFactory()->createPoint(newcoord);
+    assert(coord);
+    Coordinate newcoord = *coord;
+    exemplar->getPrecisionModel()->makePrecise(&newcoord);
+    return exemplar->getFactory()->createPoint(newcoord);
 }
 
 
@@ -254,87 +267,89 @@ GeometryFactory::createPointFromInternalCoord(const Coordinate* coord,
 Geometry*
 GeometryFactory::toGeometry(const Envelope* envelope) const
 {
-	Coordinate coord;
-
-	if (envelope->isNull()) {
-		return createPoint();
-	}
-	if (envelope->getMinX()==envelope->getMaxX() && envelope->getMinY()==envelope->getMaxY()) {
-		coord.x = envelope->getMinX();
-		coord.y = envelope->getMinY();
-		return createPoint(coord);
-	}
-	CoordinateSequence *cl=CoordinateArraySequenceFactory::instance()->
-        create((size_t) 0, 2);
-	coord.x = envelope->getMinX();
-	coord.y = envelope->getMinY();
-	cl->add(coord);
-	coord.x = envelope->getMaxX();
-	coord.y = envelope->getMinY();
-	cl->add(coord);
-	coord.x = envelope->getMaxX();
-	coord.y = envelope->getMaxY();
-	cl->add(coord);
-	coord.x = envelope->getMinX();
-	coord.y = envelope->getMaxY();
-	cl->add(coord);
-	coord.x = envelope->getMinX();
-	coord.y = envelope->getMinY();
-	cl->add(coord);
-
-	Polygon *p = createPolygon(createLinearRing(cl), nullptr);
-	return p;
+    Coordinate coord;
+
+    if(envelope->isNull()) {
+        return createPoint();
+    }
+    if(envelope->getMinX() == envelope->getMaxX() && envelope->getMinY() == envelope->getMaxY()) {
+        coord.x = envelope->getMinX();
+        coord.y = envelope->getMinY();
+        return createPoint(coord);
+    }
+    CoordinateSequence* cl = CoordinateArraySequenceFactory::instance()->
+                             create((size_t) 0, 2);
+    coord.x = envelope->getMinX();
+    coord.y = envelope->getMinY();
+    cl->add(coord);
+    coord.x = envelope->getMaxX();
+    coord.y = envelope->getMinY();
+    cl->add(coord);
+    coord.x = envelope->getMaxX();
+    coord.y = envelope->getMaxY();
+    cl->add(coord);
+    coord.x = envelope->getMinX();
+    coord.y = envelope->getMaxY();
+    cl->add(coord);
+    coord.x = envelope->getMinX();
+    coord.y = envelope->getMinY();
+    cl->add(coord);
+
+    Polygon* p = createPolygon(createLinearRing(cl), nullptr);
+    return p;
 }
 
 /*public*/
 const PrecisionModel*
 GeometryFactory::getPrecisionModel() const
 {
-	return precisionModel;
+    return precisionModel;
 }
 
 /*public*/
 Point*
 GeometryFactory::createPoint() const
 {
-	return new Point(nullptr, this);
+    return new Point(nullptr, this);
 }
 
 /*public*/
 Point*
 GeometryFactory::createPoint(const Coordinate& coordinate) const
 {
-	if (coordinate.isNull()) {
-		return createPoint();
-	} else {
-		std::size_t dim = std::isnan(coordinate.z) ? 2 : 3;
-		CoordinateSequence *cl = coordinateListFactory->create(new vector<Coordinate>(1, coordinate), dim);
-		//cl->setAt(coordinate, 0);
-		Point *ret = createPoint(cl);
-		return ret;
-	}
+    if(coordinate.isNull()) {
+        return createPoint();
+    }
+    else {
+        std::size_t dim = std::isnan(coordinate.z) ? 2 : 3;
+        CoordinateSequence* cl = coordinateListFactory->create(new vector<Coordinate>(1, coordinate), dim);
+        //cl->setAt(coordinate, 0);
+        Point* ret = createPoint(cl);
+        return ret;
+    }
 }
 
 /*public*/
 Point*
-GeometryFactory::createPoint(CoordinateSequence *newCoords) const
+GeometryFactory::createPoint(CoordinateSequence* newCoords) const
 {
-	return new Point(newCoords,this);
+    return new Point(newCoords, this);
 }
 
 /*public*/
 Point*
-GeometryFactory::createPoint(const CoordinateSequence &fromCoords) const
+GeometryFactory::createPoint(const CoordinateSequence& fromCoords) const
 {
-	CoordinateSequence *newCoords = fromCoords.clone();
-	Point *g = nullptr;
-	try {
-		g = new Point(newCoords,this);
-	} catch (...) {
-		delete newCoords;
-		throw;
-	}
-	return g;
+    CoordinateSequence* newCoords = fromCoords.clone();
+    Point* g = nullptr;
+    try {
+        g = new Point(newCoords, this);
+    }
+    catch(...) {
+        delete newCoords;
+        throw;
+    }
+    return g;
 
 }
 
@@ -342,465 +357,474 @@ GeometryFactory::createPoint(const CoordinateSequence &fromCoords) const
 MultiLineString*
 GeometryFactory::createMultiLineString() const
 {
-	return new MultiLineString(nullptr,this);
+    return new MultiLineString(nullptr, this);
 }
 
 /*public*/
 MultiLineString*
-GeometryFactory::createMultiLineString(vector<Geometry *> *newLines)
-	const
+GeometryFactory::createMultiLineString(vector<Geometry*>* newLines)
+const
 {
-	return new MultiLineString(newLines,this);
+    return new MultiLineString(newLines, this);
 }
 
 /*public*/
 MultiLineString*
-GeometryFactory::createMultiLineString(const vector<Geometry *> &fromLines)
-	const
-{
-	vector<Geometry *>*newGeoms = new vector<Geometry *>(fromLines.size());
-	for (size_t i=0; i<fromLines.size(); i++)
-	{
-		const LineString *line = dynamic_cast<const LineString *>(fromLines[i]);
-		if ( ! line ) throw geos::util::IllegalArgumentException("createMultiLineString called with a vector containing non-LineStrings");
-		(*newGeoms)[i] = new LineString(*line);
-	}
-	MultiLineString *g = nullptr;
-	try {
-		g = new MultiLineString(newGeoms,this);
-	} catch (...) {
-		for (size_t i=0; i<newGeoms->size(); i++) {
-			delete (*newGeoms)[i];
-		}
-		delete newGeoms;
-		throw;
-	}
-	return g;
+GeometryFactory::createMultiLineString(const vector<Geometry*>& fromLines)
+const
+{
+    vector<Geometry*>* newGeoms = new vector<Geometry*>(fromLines.size());
+    for(size_t i = 0; i < fromLines.size(); i++) {
+        const LineString* line = dynamic_cast<const LineString*>(fromLines[i]);
+        if(! line) {
+            throw geos::util::IllegalArgumentException("createMultiLineString called with a vector containing non-LineStrings");
+        }
+        (*newGeoms)[i] = new LineString(*line);
+    }
+    MultiLineString* g = nullptr;
+    try {
+        g = new MultiLineString(newGeoms, this);
+    }
+    catch(...) {
+        for(size_t i = 0; i < newGeoms->size(); i++) {
+            delete(*newGeoms)[i];
+        }
+        delete newGeoms;
+        throw;
+    }
+    return g;
 }
 
 /*public*/
 GeometryCollection*
 GeometryFactory::createGeometryCollection() const
 {
-	return new GeometryCollection(nullptr,this);
+    return new GeometryCollection(nullptr, this);
 }
 
 /*public*/
 Geometry*
 GeometryFactory::createEmptyGeometry() const
 {
-	return new GeometryCollection(nullptr,this);
+    return new GeometryCollection(nullptr, this);
 }
 
 /*public*/
 GeometryCollection*
-GeometryFactory::createGeometryCollection(vector<Geometry *> *newGeoms) const
+GeometryFactory::createGeometryCollection(vector<Geometry*>* newGeoms) const
 {
-	return new GeometryCollection(newGeoms,this);
+    return new GeometryCollection(newGeoms, this);
 }
 
 /*public*/
 GeometryCollection*
-GeometryFactory::createGeometryCollection(const vector<Geometry *> &fromGeoms) const
-{
-	vector<Geometry *> *newGeoms = new vector<Geometry *>(fromGeoms.size());
-	for (size_t i=0; i<fromGeoms.size(); i++) {
-		(*newGeoms)[i] = fromGeoms[i]->clone();
-	}
-	GeometryCollection *g = nullptr;
-	try {
-		g = new GeometryCollection(newGeoms,this);
-	} catch (...) {
-		for (size_t i=0; i<newGeoms->size(); i++) {
-			delete (*newGeoms)[i];
-		}
-		delete newGeoms;
-		throw;
-	}
-	return g;
+GeometryFactory::createGeometryCollection(const vector<Geometry*>& fromGeoms) const
+{
+    vector<Geometry*>* newGeoms = new vector<Geometry*>(fromGeoms.size());
+    for(size_t i = 0; i < fromGeoms.size(); i++) {
+        (*newGeoms)[i] = fromGeoms[i]->clone();
+    }
+    GeometryCollection* g = nullptr;
+    try {
+        g = new GeometryCollection(newGeoms, this);
+    }
+    catch(...) {
+        for(size_t i = 0; i < newGeoms->size(); i++) {
+            delete(*newGeoms)[i];
+        }
+        delete newGeoms;
+        throw;
+    }
+    return g;
 }
 
 /*public*/
 MultiPolygon*
 GeometryFactory::createMultiPolygon() const
 {
-	return new MultiPolygon(nullptr,this);
+    return new MultiPolygon(nullptr, this);
 }
 
 /*public*/
 MultiPolygon*
-GeometryFactory::createMultiPolygon(vector<Geometry *> *newPolys) const
+GeometryFactory::createMultiPolygon(vector<Geometry*>* newPolys) const
 {
-	return new MultiPolygon(newPolys,this);
+    return new MultiPolygon(newPolys, this);
 }
 
 /*public*/
 MultiPolygon*
-GeometryFactory::createMultiPolygon(const vector<Geometry *> &fromPolys) const
-{
-	vector<Geometry *>*newGeoms = new vector<Geometry *>(fromPolys.size());
-	for (size_t i=0; i<fromPolys.size(); i++)
-	{
-		(*newGeoms)[i] = fromPolys[i]->clone();
-	}
-	MultiPolygon *g = nullptr;
-	try {
-		g = new MultiPolygon(newGeoms,this);
-	} catch (...) {
-		for (size_t i=0; i<newGeoms->size(); i++) {
-			delete (*newGeoms)[i];
-		}
-		delete newGeoms;
-		throw;
-	}
-	return g;
+GeometryFactory::createMultiPolygon(const vector<Geometry*>& fromPolys) const
+{
+    vector<Geometry*>* newGeoms = new vector<Geometry*>(fromPolys.size());
+    for(size_t i = 0; i < fromPolys.size(); i++) {
+        (*newGeoms)[i] = fromPolys[i]->clone();
+    }
+    MultiPolygon* g = nullptr;
+    try {
+        g = new MultiPolygon(newGeoms, this);
+    }
+    catch(...) {
+        for(size_t i = 0; i < newGeoms->size(); i++) {
+            delete(*newGeoms)[i];
+        }
+        delete newGeoms;
+        throw;
+    }
+    return g;
 }
 
 /*public*/
 LinearRing*
 GeometryFactory::createLinearRing() const
 {
-	return new LinearRing(nullptr,this);
+    return new LinearRing(nullptr, this);
 }
 
 /*public*/
 LinearRing*
 GeometryFactory::createLinearRing(CoordinateSequence* newCoords) const
 {
-	return new LinearRing(newCoords,this);
+    return new LinearRing(newCoords, this);
 }
 
 /*public*/
 Geometry::Ptr
 GeometryFactory::createLinearRing(CoordinateSequence::Ptr newCoords) const
 {
-	return Geometry::Ptr(new LinearRing(std::move(newCoords), this));
+    return Geometry::Ptr(new LinearRing(std::move(newCoords), this));
 }
 
 /*public*/
 LinearRing*
 GeometryFactory::createLinearRing(const CoordinateSequence& fromCoords) const
 {
-	CoordinateSequence *newCoords = fromCoords.clone();
-	LinearRing *g = nullptr;
-	// construction failure will delete newCoords
-	g = new LinearRing(newCoords, this);
-	return g;
+    CoordinateSequence* newCoords = fromCoords.clone();
+    LinearRing* g = nullptr;
+    // construction failure will delete newCoords
+    g = new LinearRing(newCoords, this);
+    return g;
 }
 
 /*public*/
 MultiPoint*
-GeometryFactory::createMultiPoint(vector<Geometry *> *newPoints) const
+GeometryFactory::createMultiPoint(vector<Geometry*>* newPoints) const
 {
-	return new MultiPoint(newPoints,this);
+    return new MultiPoint(newPoints, this);
 }
 
 /*public*/
 MultiPoint*
-GeometryFactory::createMultiPoint(const vector<Geometry *> &fromPoints) const
+GeometryFactory::createMultiPoint(const vector<Geometry*>& fromPoints) const
 {
-	vector<Geometry *>*newGeoms = new vector<Geometry *>(fromPoints.size());
-	for (size_t i=0; i<fromPoints.size(); i++)
-	{
-		(*newGeoms)[i] = fromPoints[i]->clone();
-	}
+    vector<Geometry*>* newGeoms = new vector<Geometry*>(fromPoints.size());
+    for(size_t i = 0; i < fromPoints.size(); i++) {
+        (*newGeoms)[i] = fromPoints[i]->clone();
+    }
 
-	MultiPoint *g = nullptr;
-	try {
-		g = new MultiPoint(newGeoms,this);
-	} catch (...) {
-		for (size_t i=0; i<newGeoms->size(); i++) {
-			delete (*newGeoms)[i];
-		}
-		delete newGeoms;
-		throw;
-	}
-	return g;
+    MultiPoint* g = nullptr;
+    try {
+        g = new MultiPoint(newGeoms, this);
+    }
+    catch(...) {
+        for(size_t i = 0; i < newGeoms->size(); i++) {
+            delete(*newGeoms)[i];
+        }
+        delete newGeoms;
+        throw;
+    }
+    return g;
 }
 
 /*public*/
 MultiPoint*
 GeometryFactory::createMultiPoint() const
 {
-	return new MultiPoint(nullptr, this);
+    return new MultiPoint(nullptr, this);
 }
 
 /*public*/
 MultiPoint*
-GeometryFactory::createMultiPoint(const CoordinateSequence &fromCoords) const
-{
-	size_t npts=fromCoords.getSize();
-	vector<Geometry *> *pts=new vector<Geometry *>;
-	pts->reserve(npts);
-	for (size_t i=0; i<npts; ++i) {
-		Point *pt=createPoint(fromCoords.getAt(i));
-		pts->push_back(pt);
-	}
-	MultiPoint *mp = nullptr;
-	try {
-		mp = createMultiPoint(pts);
-	} catch (...) {
-		for (size_t i=0; i<npts; ++i) delete (*pts)[i];
-		delete pts;
-		throw;
-	}
-	return mp;
+GeometryFactory::createMultiPoint(const CoordinateSequence& fromCoords) const
+{
+    size_t npts = fromCoords.getSize();
+    vector<Geometry*>* pts = new vector<Geometry*>;
+    pts->reserve(npts);
+    for(size_t i = 0; i < npts; ++i) {
+        Point* pt = createPoint(fromCoords.getAt(i));
+        pts->push_back(pt);
+    }
+    MultiPoint* mp = nullptr;
+    try {
+        mp = createMultiPoint(pts);
+    }
+    catch(...) {
+        for(size_t i = 0; i < npts; ++i) {
+            delete(*pts)[i];
+        }
+        delete pts;
+        throw;
+    }
+    return mp;
 }
 
 /*public*/
 MultiPoint*
-GeometryFactory::createMultiPoint(const std::vector<Coordinate> &fromCoords) const
-{
-	size_t npts=fromCoords.size();
-	vector<Geometry *> *pts=new vector<Geometry *>;
-	pts->reserve(npts);
-	for (size_t i=0; i<npts; ++i) {
-		Point *pt=createPoint(fromCoords[i]);
-		pts->push_back(pt);
-	}
-	MultiPoint *mp = nullptr;
-	try {
-		mp = createMultiPoint(pts);
-	} catch (...) {
-		for (size_t i=0; i<npts; ++i) delete (*pts)[i];
-		delete pts;
-		throw;
-	}
-	return mp;
+GeometryFactory::createMultiPoint(const std::vector<Coordinate>& fromCoords) const
+{
+    size_t npts = fromCoords.size();
+    vector<Geometry*>* pts = new vector<Geometry*>;
+    pts->reserve(npts);
+    for(size_t i = 0; i < npts; ++i) {
+        Point* pt = createPoint(fromCoords[i]);
+        pts->push_back(pt);
+    }
+    MultiPoint* mp = nullptr;
+    try {
+        mp = createMultiPoint(pts);
+    }
+    catch(...) {
+        for(size_t i = 0; i < npts; ++i) {
+            delete(*pts)[i];
+        }
+        delete pts;
+        throw;
+    }
+    return mp;
 }
 
 /*public*/
 Polygon*
 GeometryFactory::createPolygon() const
 {
-	return new Polygon(nullptr, nullptr, this);
+    return new Polygon(nullptr, nullptr, this);
 }
 
 /*public*/
 Polygon*
-GeometryFactory::createPolygon(LinearRing *shell, vector<Geometry *> *holes)
-	const
+GeometryFactory::createPolygon(LinearRing* shell, vector<Geometry*>* holes)
+const
 {
-	return new Polygon(shell, holes, this);
+    return new Polygon(shell, holes, this);
 }
 
 /*public*/
 Polygon*
-GeometryFactory::createPolygon(const LinearRing &shell, const vector<Geometry *> &holes)
-	const
-{
-	LinearRing *newRing = dynamic_cast<LinearRing *>(shell.clone());
-	vector<Geometry *>*newHoles = new vector<Geometry *>(holes.size());
-	for (size_t i=0; i<holes.size(); i++)
-	{
-		(*newHoles)[i] = holes[i]->clone();
-	}
-	Polygon *g = nullptr;
-	try {
-		g = new Polygon(newRing, newHoles, this);
-	} catch (...) {
-		delete newRing;
-		for (size_t i=0; i<holes.size(); i++)
-			delete (*newHoles)[i];
-		delete newHoles;
-		throw;
-	}
-	return g;
-}
-
-/*public*/
-LineString *
+GeometryFactory::createPolygon(const LinearRing& shell, const vector<Geometry*>& holes)
+const
+{
+    LinearRing* newRing = dynamic_cast<LinearRing*>(shell.clone());
+    vector<Geometry*>* newHoles = new vector<Geometry*>(holes.size());
+    for(size_t i = 0; i < holes.size(); i++) {
+        (*newHoles)[i] = holes[i]->clone();
+    }
+    Polygon* g = nullptr;
+    try {
+        g = new Polygon(newRing, newHoles, this);
+    }
+    catch(...) {
+        delete newRing;
+        for(size_t i = 0; i < holes.size(); i++) {
+            delete(*newHoles)[i];
+        }
+        delete newHoles;
+        throw;
+    }
+    return g;
+}
+
+/*public*/
+LineString*
 GeometryFactory::createLineString() const
 {
-	return new LineString(nullptr, this);
+    return new LineString(nullptr, this);
 }
 
 /*public*/
 std::unique_ptr<LineString>
 GeometryFactory::createLineString(const LineString& ls) const
 {
-	return std::unique_ptr<LineString>(new LineString(ls));
+    return std::unique_ptr<LineString>(new LineString(ls));
 }
 
 /*public*/
 LineString*
-GeometryFactory::createLineString(CoordinateSequence *newCoords)
-	const
+GeometryFactory::createLineString(CoordinateSequence* newCoords)
+const
 {
-	return new LineString(newCoords, this);
+    return new LineString(newCoords, this);
 }
 
 /*public*/
 Geometry::Ptr
 GeometryFactory::createLineString(CoordinateSequence::Ptr newCoords)
-	const
+const
 {
-	return Geometry::Ptr(new LineString(std::move(newCoords), this));
+    return Geometry::Ptr(new LineString(std::move(newCoords), this));
 }
 
 /*public*/
 LineString*
-GeometryFactory::createLineString(const CoordinateSequence &fromCoords)
-	const
+GeometryFactory::createLineString(const CoordinateSequence& fromCoords)
+const
 {
-	CoordinateSequence *newCoords = fromCoords.clone();
-	LineString *g = nullptr;
-	// construction failure will delete newCoords
-	g = new LineString(newCoords, this);
-	return g;
+    CoordinateSequence* newCoords = fromCoords.clone();
+    LineString* g = nullptr;
+    // construction failure will delete newCoords
+    g = new LineString(newCoords, this);
+    return g;
 }
 
 /*public*/
 Geometry*
-GeometryFactory::buildGeometry(vector<Geometry *> *newGeoms) const
-{
-	if (!newGeoms->size())
-	{
-		// we do not need the vector anymore
-		delete newGeoms;
-		return createGeometryCollection();
-	}
-
-	bool isHeterogeneous=false;
-	bool hasGeometryCollection=false;
-	GeometryTypeId type = (*newGeoms)[0]->getGeometryTypeId();
-
-	for (Geometry* gp : *newGeoms)
-	{
-		GeometryTypeId geometryType = gp->getGeometryTypeId();
-		if (type != geometryType)
-		{
-			isHeterogeneous=true;
-		}
-		if (geometryType == GEOS_GEOMETRYCOLLECTION)
-		{
-			hasGeometryCollection=true;
-		}
-	}
-
-	if (isHeterogeneous || hasGeometryCollection)
-	{
-		return createGeometryCollection(newGeoms);
-	}
-
-	// At this point we know the collection is not hetereogenous.
-	bool isCollection=newGeoms->size()>1;
-	if (isCollection)
-	{
-		if (type == GEOS_POLYGON) {
-			return createMultiPolygon(newGeoms);
-		} else if (type == GEOS_LINESTRING) {
-			return createMultiLineString(newGeoms);
-		} else if (type == GEOS_LINEARRING) {
-			return createMultiLineString(newGeoms);
-		} else if (type == GEOS_POINT) {
-			return createMultiPoint(newGeoms);
-		} else {
-			return createGeometryCollection(newGeoms);
-		}
-	}
-
-	// since this is not a collection we can delete vector
-        Geometry *geom0=(*newGeoms)[0];
-	delete newGeoms;
-	return geom0;
+GeometryFactory::buildGeometry(vector<Geometry*>* newGeoms) const
+{
+    if(!newGeoms->size()) {
+        // we do not need the vector anymore
+        delete newGeoms;
+        return createGeometryCollection();
+    }
+
+    bool isHeterogeneous = false;
+    bool hasGeometryCollection = false;
+    GeometryTypeId type = (*newGeoms)[0]->getGeometryTypeId();
+
+    for(Geometry* gp : *newGeoms) {
+        GeometryTypeId geometryType = gp->getGeometryTypeId();
+        if(type != geometryType) {
+            isHeterogeneous = true;
+        }
+        if(geometryType == GEOS_GEOMETRYCOLLECTION) {
+            hasGeometryCollection = true;
+        }
+    }
+
+    if(isHeterogeneous || hasGeometryCollection) {
+        return createGeometryCollection(newGeoms);
+    }
+
+    // At this point we know the collection is not hetereogenous.
+    bool isCollection = newGeoms->size() > 1;
+    if(isCollection) {
+        if(type == GEOS_POLYGON) {
+            return createMultiPolygon(newGeoms);
+        }
+        else if(type == GEOS_LINESTRING) {
+            return createMultiLineString(newGeoms);
+        }
+        else if(type == GEOS_LINEARRING) {
+            return createMultiLineString(newGeoms);
+        }
+        else if(type == GEOS_POINT) {
+            return createMultiPoint(newGeoms);
+        }
+        else {
+            return createGeometryCollection(newGeoms);
+        }
+    }
+
+    // since this is not a collection we can delete vector
+    Geometry* geom0 = (*newGeoms)[0];
+    delete newGeoms;
+    return geom0;
 }
 
 /*public*/
 Geometry*
-GeometryFactory::buildGeometry(const vector<Geometry *> &fromGeoms) const
-{
-	size_t geomsSize = fromGeoms.size();
-	if (geomsSize == 0)
-	{
-		return createGeometryCollection();
-	}
-
-	if (geomsSize == 1)
-	{
-		return fromGeoms[0]->clone();
-	}
-
-	bool isHeterogeneous=false;
-	GeometryTypeId type = fromGeoms[0]->getGeometryTypeId();
-
-	for (const Geometry *gp : fromGeoms)
-	{
-		GeometryTypeId geometryType = gp->getGeometryTypeId();
-		if (type != geometryType)
-		{
-			isHeterogeneous=true;
-		}
-	}
-
-	if (isHeterogeneous)
-	{
-		return createGeometryCollection(fromGeoms);
-	}
-
-	if (type == GEOS_POLYGON) {
-		return createMultiPolygon(fromGeoms);
-	} else if (type == GEOS_LINESTRING) {
-		return createMultiLineString(fromGeoms);
-	} else if (type == GEOS_LINEARRING) {
-		return createMultiLineString(fromGeoms);
-	} else if (type == GEOS_POINT) {
-		return createMultiPoint(fromGeoms);
-	}
+GeometryFactory::buildGeometry(const vector<Geometry*>& fromGeoms) const
+{
+    size_t geomsSize = fromGeoms.size();
+    if(geomsSize == 0) {
+        return createGeometryCollection();
+    }
+
+    if(geomsSize == 1) {
+        return fromGeoms[0]->clone();
+    }
+
+    bool isHeterogeneous = false;
+    GeometryTypeId type = fromGeoms[0]->getGeometryTypeId();
+
+    for(const Geometry* gp : fromGeoms) {
+        GeometryTypeId geometryType = gp->getGeometryTypeId();
+        if(type != geometryType) {
+            isHeterogeneous = true;
+        }
+    }
+
+    if(isHeterogeneous) {
+        return createGeometryCollection(fromGeoms);
+    }
+
+    if(type == GEOS_POLYGON) {
+        return createMultiPolygon(fromGeoms);
+    }
+    else if(type == GEOS_LINESTRING) {
+        return createMultiLineString(fromGeoms);
+    }
+    else if(type == GEOS_LINEARRING) {
+        return createMultiLineString(fromGeoms);
+    }
+    else if(type == GEOS_POINT) {
+        return createMultiPoint(fromGeoms);
+    }
     geos::util::GEOSException("GeometryFactory::buildGeometry encountered an unknown geometry type!");
     return fromGeoms[0]->clone();
 }
 
 /*public*/
 Geometry*
-GeometryFactory::createGeometry(const Geometry *g) const
+GeometryFactory::createGeometry(const Geometry* g) const
 {
-	// could this be cached to make this more efficient? Or maybe it isn't enough overhead to bother
-	//return g->clone();
-	util::GeometryEditor editor(this);
-	gfCoordinateOperation coordOp(coordinateListFactory);
-	Geometry *ret = editor.edit(g, &coordOp);
-	return ret;
+    // could this be cached to make this more efficient? Or maybe it isn't enough overhead to bother
+    //return g->clone();
+    util::GeometryEditor editor(this);
+    gfCoordinateOperation coordOp(coordinateListFactory);
+    Geometry* ret = editor.edit(g, &coordOp);
+    return ret;
 }
 
 /*public*/
 void
-GeometryFactory::destroyGeometry(Geometry *g) const
+GeometryFactory::destroyGeometry(Geometry* g) const
 {
-	delete g;
+    delete g;
 }
 
 /*public static*/
 const GeometryFactory*
 GeometryFactory::getDefaultInstance()
 {
-	static GeometryFactory* defInstance = new GeometryFactory();
-	return defInstance;
+    static GeometryFactory* defInstance = new GeometryFactory();
+    return defInstance;
 }
 
 /*private*/
 void
 GeometryFactory::addRef() const
 {
-	++_refCount;
+    ++_refCount;
 }
 
 /*private*/
 void
 GeometryFactory::dropRef() const
 {
-	if ( ! --_refCount )
-	{
-		if ( _autoDestroy ) delete this;
-	}
+    if(! --_refCount) {
+        if(_autoDestroy) {
+            delete this;
+        }
+    }
 }
 
 void
 GeometryFactory::destroy()
 {
-	assert(!_autoDestroy); // don't call me twice !
-	_autoDestroy = true;
-	if ( ! _refCount ) delete this;
+    assert(!_autoDestroy); // don't call me twice !
+    _autoDestroy = true;
+    if(! _refCount) {
+        delete this;
+    }
 }
 
 } // namespace geos::geom
diff --git a/src/geom/IntersectionMatrix.cpp b/src/geom/IntersectionMatrix.cpp
index 9c391ec..740187b 100644
--- a/src/geom/IntersectionMatrix.cpp
+++ b/src/geom/IntersectionMatrix.cpp
@@ -36,401 +36,392 @@ const int IntersectionMatrix::secondDim = 3;
 /*public*/
 IntersectionMatrix::IntersectionMatrix()
 {
-	//matrix = new int[3][3];
-	setAll(Dimension::False);
+    //matrix = new int[3][3];
+    setAll(Dimension::False);
 }
 
 /*public*/
 IntersectionMatrix::IntersectionMatrix(const string& elements)
 {
-	setAll(Dimension::False);
-	set(elements);
+    setAll(Dimension::False);
+    set(elements);
 }
 
 /*public*/
 IntersectionMatrix::IntersectionMatrix(const IntersectionMatrix& other)
 {
-	matrix[Location::INTERIOR][Location::INTERIOR] = other.matrix[Location::INTERIOR][Location::INTERIOR];
-	matrix[Location::INTERIOR][Location::BOUNDARY] = other.matrix[Location::INTERIOR][Location::BOUNDARY];
-	matrix[Location::INTERIOR][Location::EXTERIOR] = other.matrix[Location::INTERIOR][Location::EXTERIOR];
-	matrix[Location::BOUNDARY][Location::INTERIOR] = other.matrix[Location::BOUNDARY][Location::INTERIOR];
-	matrix[Location::BOUNDARY][Location::BOUNDARY] = other.matrix[Location::BOUNDARY][Location::BOUNDARY];
-	matrix[Location::BOUNDARY][Location::EXTERIOR] = other.matrix[Location::BOUNDARY][Location::EXTERIOR];
-	matrix[Location::EXTERIOR][Location::INTERIOR] = other.matrix[Location::EXTERIOR][Location::INTERIOR];
-	matrix[Location::EXTERIOR][Location::BOUNDARY] = other.matrix[Location::EXTERIOR][Location::BOUNDARY];
-	matrix[Location::EXTERIOR][Location::EXTERIOR] = other.matrix[Location::EXTERIOR][Location::EXTERIOR];
+    matrix[Location::INTERIOR][Location::INTERIOR] = other.matrix[Location::INTERIOR][Location::INTERIOR];
+    matrix[Location::INTERIOR][Location::BOUNDARY] = other.matrix[Location::INTERIOR][Location::BOUNDARY];
+    matrix[Location::INTERIOR][Location::EXTERIOR] = other.matrix[Location::INTERIOR][Location::EXTERIOR];
+    matrix[Location::BOUNDARY][Location::INTERIOR] = other.matrix[Location::BOUNDARY][Location::INTERIOR];
+    matrix[Location::BOUNDARY][Location::BOUNDARY] = other.matrix[Location::BOUNDARY][Location::BOUNDARY];
+    matrix[Location::BOUNDARY][Location::EXTERIOR] = other.matrix[Location::BOUNDARY][Location::EXTERIOR];
+    matrix[Location::EXTERIOR][Location::INTERIOR] = other.matrix[Location::EXTERIOR][Location::INTERIOR];
+    matrix[Location::EXTERIOR][Location::BOUNDARY] = other.matrix[Location::EXTERIOR][Location::BOUNDARY];
+    matrix[Location::EXTERIOR][Location::EXTERIOR] = other.matrix[Location::EXTERIOR][Location::EXTERIOR];
 }
 
 /*public*/
 void
 IntersectionMatrix::add(IntersectionMatrix* other)
 {
-	for(int i = 0; i < firstDim; i++) {
-		for(int j = 0; j < secondDim; j++) {
-			setAtLeast(i, j, other->get(i, j));
-		}
-	}
+    for(int i = 0; i < firstDim; i++) {
+        for(int j = 0; j < secondDim; j++) {
+            setAtLeast(i, j, other->get(i, j));
+        }
+    }
 }
 
 /*public*/
 bool
 IntersectionMatrix::matches(const string& requiredDimensionSymbols) const
 {
-	if (requiredDimensionSymbols.length() != 9) {
-		ostringstream s;
-		s << "IllegalArgumentException: Should be length 9, is "
-				<< "[" << requiredDimensionSymbols << "] instead" << endl;
-		throw util::IllegalArgumentException(s.str());
-	}
-	for (int ai = 0; ai < firstDim; ai++) {
-		for (int bi = 0; bi < secondDim; bi++) {
-			if (!matches(matrix[ai][bi],requiredDimensionSymbols[3*ai+bi])) {
-				return false;
-			}
-		}
-	}
-	return true;
+    if(requiredDimensionSymbols.length() != 9) {
+        ostringstream s;
+        s << "IllegalArgumentException: Should be length 9, is "
+          << "[" << requiredDimensionSymbols << "] instead" << endl;
+        throw util::IllegalArgumentException(s.str());
+    }
+    for(int ai = 0; ai < firstDim; ai++) {
+        for(int bi = 0; bi < secondDim; bi++) {
+            if(!matches(matrix[ai][bi], requiredDimensionSymbols[3 * ai + bi])) {
+                return false;
+            }
+        }
+    }
+    return true;
 }
 
 /*public static*/
 bool
 IntersectionMatrix::matches(int actualDimensionValue,
-	char requiredDimensionSymbol)
+                            char requiredDimensionSymbol)
 {
 
-	if (requiredDimensionSymbol=='*') return true;
-
-	if (requiredDimensionSymbol=='T' && (actualDimensionValue >= 0 ||
-		actualDimensionValue==Dimension::True))
-	{
-		return true;
-	}
-
-	if (requiredDimensionSymbol=='F' &&
-		actualDimensionValue==Dimension::False)
-	{
-		return true;
-	}
-
-	if (requiredDimensionSymbol=='0' &&
-		actualDimensionValue==Dimension::P)
-	{
-		return true;
-	}
-
-	if (requiredDimensionSymbol=='1' &&
-		actualDimensionValue==Dimension::L)
-	{
-		return true;
-	}
-
-	if (requiredDimensionSymbol=='2' &&
-		actualDimensionValue==Dimension::A)
-	{
-		return true;
-	}
-
-	return false;
+    if(requiredDimensionSymbol == '*') {
+        return true;
+    }
+
+    if(requiredDimensionSymbol == 'T' && (actualDimensionValue >= 0 ||
+                                          actualDimensionValue == Dimension::True)) {
+        return true;
+    }
+
+    if(requiredDimensionSymbol == 'F' &&
+            actualDimensionValue == Dimension::False) {
+        return true;
+    }
+
+    if(requiredDimensionSymbol == '0' &&
+            actualDimensionValue == Dimension::P) {
+        return true;
+    }
+
+    if(requiredDimensionSymbol == '1' &&
+            actualDimensionValue == Dimension::L) {
+        return true;
+    }
+
+    if(requiredDimensionSymbol == '2' &&
+            actualDimensionValue == Dimension::A) {
+        return true;
+    }
+
+    return false;
 }
 
 /*public static*/
 bool
 IntersectionMatrix::matches(const string& actualDimensionSymbols,
-	const string& requiredDimensionSymbols)
+                            const string& requiredDimensionSymbols)
 {
-	IntersectionMatrix m(actualDimensionSymbols);
-	bool result=m.matches(requiredDimensionSymbols);
+    IntersectionMatrix m(actualDimensionSymbols);
+    bool result = m.matches(requiredDimensionSymbols);
 
-	return result;
+    return result;
 }
 
 /*public*/
 void
 IntersectionMatrix::set(int row, int col, int dimensionValue)
 {
-	assert( row >= 0 && row < firstDim );
-	assert( col >= 0 && col < secondDim );
+    assert(row >= 0 && row < firstDim);
+    assert(col >= 0 && col < secondDim);
 
-	matrix[row][col] = dimensionValue;
+    matrix[row][col] = dimensionValue;
 }
 
 /*public*/
 void
 IntersectionMatrix::set(const string& dimensionSymbols)
 {
-	auto limit = dimensionSymbols.length();
-
-	for (size_t i = 0; i < limit; i++)
-	{
-		auto row = i / firstDim;
-		auto col = i % secondDim;
-		matrix[row][col] = Dimension::toDimensionValue(dimensionSymbols[i]);
-	}
+    auto limit = dimensionSymbols.length();
+
+    for(size_t i = 0; i < limit; i++) {
+        auto row = i / firstDim;
+        auto col = i % secondDim;
+        matrix[row][col] = Dimension::toDimensionValue(dimensionSymbols[i]);
+    }
 }
 
 /*public*/
 void
 IntersectionMatrix::setAtLeast(size_t row, size_t col, int minimumDimensionValue)
 {
-	assert( row < firstDim );
-	assert( col < secondDim );
+    assert(row < firstDim);
+    assert(col < secondDim);
 
-	if (matrix[row][col] < minimumDimensionValue)
-	{
-		matrix[row][col] = minimumDimensionValue;
-	}
+    if(matrix[row][col] < minimumDimensionValue) {
+        matrix[row][col] = minimumDimensionValue;
+    }
 }
 
 /*public*/
 void
 IntersectionMatrix::setAtLeastIfValid(int row, int col, int minimumDimensionValue)
 {
-	assert( row >= 0 && row < firstDim );
-	assert( col >= 0 && col < secondDim );
+    assert(row >= 0 && row < firstDim);
+    assert(col >= 0 && col < secondDim);
 
-	if (row >= 0 && col >= 0)
-	{
-		setAtLeast(row, col, minimumDimensionValue);
-	}
+    if(row >= 0 && col >= 0) {
+        setAtLeast(row, col, minimumDimensionValue);
+    }
 }
 
 /*public*/
 void
 IntersectionMatrix::setAtLeast(string minimumDimensionSymbols)
 {
-	auto limit = minimumDimensionSymbols.length();
-
-	for (size_t i = 0; i < limit; i++)
-	{
-		auto row = i / firstDim;
-		auto col = i % secondDim;
-		setAtLeast(row, col, Dimension::toDimensionValue(minimumDimensionSymbols[i]));
-	}
+    auto limit = minimumDimensionSymbols.length();
+
+    for(size_t i = 0; i < limit; i++) {
+        auto row = i / firstDim;
+        auto col = i % secondDim;
+        setAtLeast(row, col, Dimension::toDimensionValue(minimumDimensionSymbols[i]));
+    }
 }
 
 /*public*/
 void
 IntersectionMatrix::setAll(int dimensionValue)
 {
-	for (int ai = 0; ai < firstDim; ai++) {
-		for (int bi = 0; bi < secondDim; bi++) {
-			matrix[ai][bi] = dimensionValue;
-		}
-	}
+    for(int ai = 0; ai < firstDim; ai++) {
+        for(int bi = 0; bi < secondDim; bi++) {
+            matrix[ai][bi] = dimensionValue;
+        }
+    }
 }
 
 /*public*/
 int
 IntersectionMatrix::get(int row, int col) const
 {
-	assert( row >= 0 && row < firstDim );
-	assert( col >= 0 && col < secondDim );
+    assert(row >= 0 && row < firstDim);
+    assert(col >= 0 && col < secondDim);
 
-	return matrix[row][col];
+    return matrix[row][col];
 }
 
 /*public*/
 bool
 IntersectionMatrix::isDisjoint() const
 {
-	return
-		matrix[Location::INTERIOR][Location::INTERIOR]==Dimension::False
-		&&
-		matrix[Location::INTERIOR][Location::BOUNDARY]==Dimension::False
-		&&
-		matrix[Location::BOUNDARY][Location::INTERIOR]==Dimension::False
-		&&
-		matrix[Location::BOUNDARY][Location::BOUNDARY]==Dimension::False;
+    return
+        matrix[Location::INTERIOR][Location::INTERIOR] == Dimension::False
+        &&
+        matrix[Location::INTERIOR][Location::BOUNDARY] == Dimension::False
+        &&
+        matrix[Location::BOUNDARY][Location::INTERIOR] == Dimension::False
+        &&
+        matrix[Location::BOUNDARY][Location::BOUNDARY] == Dimension::False;
 }
 
 /*public*/
 bool
 IntersectionMatrix::isIntersects() const
 {
-	return !isDisjoint();
+    return !isDisjoint();
 }
 
 /*public*/
 bool
 IntersectionMatrix::isTouches(int dimensionOfGeometryA,
-		int dimensionOfGeometryB) const
+                              int dimensionOfGeometryB) const
 {
-	if (dimensionOfGeometryA > dimensionOfGeometryB)
-	{
-		//no need to get transpose because pattern matrix is symmetrical
-		return isTouches(dimensionOfGeometryB, dimensionOfGeometryA);
-	}
-	if ((dimensionOfGeometryA==Dimension::A && dimensionOfGeometryB==Dimension::A)
-		||
-		(dimensionOfGeometryA==Dimension::L && dimensionOfGeometryB==Dimension::L)
-		||
-		(dimensionOfGeometryA==Dimension::L && dimensionOfGeometryB==Dimension::A)
-		||
-		(dimensionOfGeometryA==Dimension::P && dimensionOfGeometryB==Dimension::A)
-		||
-		(dimensionOfGeometryA==Dimension::P && dimensionOfGeometryB==Dimension::L))
-	{
-		return matrix[Location::INTERIOR][Location::INTERIOR]==Dimension::False &&
-			  (matches(matrix[Location::INTERIOR][Location::BOUNDARY], 'T') ||
-			   matches(matrix[Location::BOUNDARY][Location::INTERIOR], 'T') ||
-			   matches(matrix[Location::BOUNDARY][Location::BOUNDARY], 'T'));
-	}
-	return false;
+    if(dimensionOfGeometryA > dimensionOfGeometryB) {
+        //no need to get transpose because pattern matrix is symmetrical
+        return isTouches(dimensionOfGeometryB, dimensionOfGeometryA);
+    }
+    if((dimensionOfGeometryA == Dimension::A && dimensionOfGeometryB == Dimension::A)
+            ||
+            (dimensionOfGeometryA == Dimension::L && dimensionOfGeometryB == Dimension::L)
+            ||
+            (dimensionOfGeometryA == Dimension::L && dimensionOfGeometryB == Dimension::A)
+            ||
+            (dimensionOfGeometryA == Dimension::P && dimensionOfGeometryB == Dimension::A)
+            ||
+            (dimensionOfGeometryA == Dimension::P && dimensionOfGeometryB == Dimension::L)) {
+        return matrix[Location::INTERIOR][Location::INTERIOR] == Dimension::False &&
+               (matches(matrix[Location::INTERIOR][Location::BOUNDARY], 'T') ||
+                matches(matrix[Location::BOUNDARY][Location::INTERIOR], 'T') ||
+                matches(matrix[Location::BOUNDARY][Location::BOUNDARY], 'T'));
+    }
+    return false;
 }
 
 /*public*/
 bool
 IntersectionMatrix::isCrosses(int dimensionOfGeometryA,
-		int dimensionOfGeometryB) const
+                              int dimensionOfGeometryB) const
 {
-	if ((dimensionOfGeometryA==Dimension::P && dimensionOfGeometryB==Dimension::L) ||
-		(dimensionOfGeometryA==Dimension::P && dimensionOfGeometryB==Dimension::A) ||
-		(dimensionOfGeometryA==Dimension::L && dimensionOfGeometryB==Dimension::A)) {
-		return matches(matrix[Location::INTERIOR][Location::INTERIOR], 'T') &&
-			   matches(matrix[Location::INTERIOR][Location::EXTERIOR], 'T');
-	}
-	if ((dimensionOfGeometryA==Dimension::L && dimensionOfGeometryB==Dimension::P) ||
-		(dimensionOfGeometryA==Dimension::A && dimensionOfGeometryB==Dimension::P) ||
-		(dimensionOfGeometryA==Dimension::A && dimensionOfGeometryB==Dimension::L)) {
-		return matches(matrix[Location::INTERIOR][Location::INTERIOR], 'T') &&
-			   matches(matrix[Location::EXTERIOR][Location::INTERIOR], 'T');
-	}
-	if (dimensionOfGeometryA==Dimension::L && dimensionOfGeometryB==Dimension::L) {
-		return matrix[Location::INTERIOR][Location::INTERIOR]==0;
-	}
-	return false;
+    if((dimensionOfGeometryA == Dimension::P && dimensionOfGeometryB == Dimension::L) ||
+            (dimensionOfGeometryA == Dimension::P && dimensionOfGeometryB == Dimension::A) ||
+            (dimensionOfGeometryA == Dimension::L && dimensionOfGeometryB == Dimension::A)) {
+        return matches(matrix[Location::INTERIOR][Location::INTERIOR], 'T') &&
+               matches(matrix[Location::INTERIOR][Location::EXTERIOR], 'T');
+    }
+    if((dimensionOfGeometryA == Dimension::L && dimensionOfGeometryB == Dimension::P) ||
+            (dimensionOfGeometryA == Dimension::A && dimensionOfGeometryB == Dimension::P) ||
+            (dimensionOfGeometryA == Dimension::A && dimensionOfGeometryB == Dimension::L)) {
+        return matches(matrix[Location::INTERIOR][Location::INTERIOR], 'T') &&
+               matches(matrix[Location::EXTERIOR][Location::INTERIOR], 'T');
+    }
+    if(dimensionOfGeometryA == Dimension::L && dimensionOfGeometryB == Dimension::L) {
+        return matrix[Location::INTERIOR][Location::INTERIOR] == 0;
+    }
+    return false;
 }
 
 /*public*/
 bool
 IntersectionMatrix::isWithin() const
 {
-	return matches(matrix[Location::INTERIOR][Location::INTERIOR], 'T') &&
-		   matrix[Location::INTERIOR][Location::EXTERIOR]==Dimension::False &&
-		   matrix[Location::BOUNDARY][Location::EXTERIOR]==Dimension::False;
+    return matches(matrix[Location::INTERIOR][Location::INTERIOR], 'T') &&
+           matrix[Location::INTERIOR][Location::EXTERIOR] == Dimension::False &&
+           matrix[Location::BOUNDARY][Location::EXTERIOR] == Dimension::False;
 }
 
 /*public*/
 bool
 IntersectionMatrix::isContains() const
 {
-	return matches(matrix[Location::INTERIOR][Location::INTERIOR], 'T') &&
-		   matrix[Location::EXTERIOR][Location::INTERIOR]==Dimension::False &&
-		   matrix[Location::EXTERIOR][Location::BOUNDARY]==Dimension::False;
+    return matches(matrix[Location::INTERIOR][Location::INTERIOR], 'T') &&
+           matrix[Location::EXTERIOR][Location::INTERIOR] == Dimension::False &&
+           matrix[Location::EXTERIOR][Location::BOUNDARY] == Dimension::False;
 }
 
 /*public*/
 bool
 IntersectionMatrix::isEquals(int dimensionOfGeometryA,
-		int dimensionOfGeometryB) const
+                             int dimensionOfGeometryB) const
 {
-	if (dimensionOfGeometryA != dimensionOfGeometryB) {
-		return false;
-	}
-	return matches(matrix[Location::INTERIOR][Location::INTERIOR], 'T') &&
-		   matrix[Location::EXTERIOR][Location::INTERIOR]==Dimension::False &&
-		   matrix[Location::INTERIOR][Location::EXTERIOR]==Dimension::False &&
-		   matrix[Location::EXTERIOR][Location::BOUNDARY]==Dimension::False &&
-		   matrix[Location::BOUNDARY][Location::EXTERIOR]==Dimension::False;
+    if(dimensionOfGeometryA != dimensionOfGeometryB) {
+        return false;
+    }
+    return matches(matrix[Location::INTERIOR][Location::INTERIOR], 'T') &&
+           matrix[Location::EXTERIOR][Location::INTERIOR] == Dimension::False &&
+           matrix[Location::INTERIOR][Location::EXTERIOR] == Dimension::False &&
+           matrix[Location::EXTERIOR][Location::BOUNDARY] == Dimension::False &&
+           matrix[Location::BOUNDARY][Location::EXTERIOR] == Dimension::False;
 }
 
 /*public*/
 bool
 IntersectionMatrix::isOverlaps(int dimensionOfGeometryA,
-		int dimensionOfGeometryB) const
+                               int dimensionOfGeometryB) const
 {
-	if ((dimensionOfGeometryA==Dimension::P && dimensionOfGeometryB==Dimension::P) ||
-		(dimensionOfGeometryA==Dimension::A && dimensionOfGeometryB==Dimension::A)) {
-		return matches(matrix[Location::INTERIOR][Location::INTERIOR], 'T') &&
-			   matches(matrix[Location::INTERIOR][Location::EXTERIOR], 'T') &&
-			   matches(matrix[Location::EXTERIOR][Location::INTERIOR],'T');
-	}
-	if (dimensionOfGeometryA==Dimension::L && dimensionOfGeometryB==Dimension::L) {
-		return matrix[Location::INTERIOR][Location::INTERIOR]==1 &&
-			   matches(matrix[Location::INTERIOR][Location::EXTERIOR], 'T') &&
-			   matches(matrix[Location::EXTERIOR][Location::INTERIOR], 'T');
-	}
-	return false;
+    if((dimensionOfGeometryA == Dimension::P && dimensionOfGeometryB == Dimension::P) ||
+            (dimensionOfGeometryA == Dimension::A && dimensionOfGeometryB == Dimension::A)) {
+        return matches(matrix[Location::INTERIOR][Location::INTERIOR], 'T') &&
+               matches(matrix[Location::INTERIOR][Location::EXTERIOR], 'T') &&
+               matches(matrix[Location::EXTERIOR][Location::INTERIOR], 'T');
+    }
+    if(dimensionOfGeometryA == Dimension::L && dimensionOfGeometryB == Dimension::L) {
+        return matrix[Location::INTERIOR][Location::INTERIOR] == 1 &&
+               matches(matrix[Location::INTERIOR][Location::EXTERIOR], 'T') &&
+               matches(matrix[Location::EXTERIOR][Location::INTERIOR], 'T');
+    }
+    return false;
 }
 
 /*public*/
 bool
 IntersectionMatrix::isCovers() const
 {
-	bool hasPointInCommon =
-		matches(matrix[Location::INTERIOR][Location::INTERIOR], 'T')
-		||
-		matches(matrix[Location::INTERIOR][Location::BOUNDARY], 'T')
-		||
-		matches(matrix[Location::BOUNDARY][Location::INTERIOR], 'T')
-		||
-		matches(matrix[Location::BOUNDARY][Location::BOUNDARY], 'T');
-
-	return hasPointInCommon
-		&&
-		matrix[Location::EXTERIOR][Location::INTERIOR] ==
-			Dimension::False
-		&&
-		matrix[Location::EXTERIOR][Location::BOUNDARY] ==
-			Dimension::False;
+    bool hasPointInCommon =
+        matches(matrix[Location::INTERIOR][Location::INTERIOR], 'T')
+        ||
+        matches(matrix[Location::INTERIOR][Location::BOUNDARY], 'T')
+        ||
+        matches(matrix[Location::BOUNDARY][Location::INTERIOR], 'T')
+        ||
+        matches(matrix[Location::BOUNDARY][Location::BOUNDARY], 'T');
+
+    return hasPointInCommon
+           &&
+           matrix[Location::EXTERIOR][Location::INTERIOR] ==
+           Dimension::False
+           &&
+           matrix[Location::EXTERIOR][Location::BOUNDARY] ==
+           Dimension::False;
 }
 
 /*public*/
 bool
 IntersectionMatrix::isCoveredBy() const
 {
-	bool hasPointInCommon =
-		matches(matrix[Location::INTERIOR][Location::INTERIOR], 'T')
-		||
-		matches(matrix[Location::INTERIOR][Location::BOUNDARY], 'T')
-		||
-		matches(matrix[Location::BOUNDARY][Location::INTERIOR], 'T')
-		||
-		matches(matrix[Location::BOUNDARY][Location::BOUNDARY], 'T');
-
-	return
-		hasPointInCommon
-		&&
-		matrix[Location::INTERIOR][Location::EXTERIOR] ==
-			Dimension::False
-		&&
-		matrix[Location::BOUNDARY][Location::EXTERIOR] ==
-			Dimension::False;
+    bool hasPointInCommon =
+        matches(matrix[Location::INTERIOR][Location::INTERIOR], 'T')
+        ||
+        matches(matrix[Location::INTERIOR][Location::BOUNDARY], 'T')
+        ||
+        matches(matrix[Location::BOUNDARY][Location::INTERIOR], 'T')
+        ||
+        matches(matrix[Location::BOUNDARY][Location::BOUNDARY], 'T');
+
+    return
+        hasPointInCommon
+        &&
+        matrix[Location::INTERIOR][Location::EXTERIOR] ==
+        Dimension::False
+        &&
+        matrix[Location::BOUNDARY][Location::EXTERIOR] ==
+        Dimension::False;
 }
 
 //Not sure
 IntersectionMatrix*
 IntersectionMatrix::transpose()
 {
-	int temp = matrix[1][0];
-	matrix[1][0] = matrix[0][1];
-	matrix[0][1] = temp;
-	temp = matrix[2][0];
-	matrix[2][0] = matrix[0][2];
-	matrix[0][2] = temp;
-	temp = matrix[2][1];
-	matrix[2][1] = matrix[1][2];
-	matrix[1][2] = temp;
-	return this;
+    int temp = matrix[1][0];
+    matrix[1][0] = matrix[0][1];
+    matrix[0][1] = temp;
+    temp = matrix[2][0];
+    matrix[2][0] = matrix[0][2];
+    matrix[0][2] = temp;
+    temp = matrix[2][1];
+    matrix[2][1] = matrix[1][2];
+    matrix[1][2] = temp;
+    return this;
 }
 
 /*public*/
 string
 IntersectionMatrix::toString() const
 {
-	string result("");
-	for (int ai = 0; ai < firstDim; ai++) {
-		for (int bi = 0; bi < secondDim; bi++) {
-			result += Dimension::toDimensionSymbol(matrix[ai][bi]);
-		}
-	}
-	return result;
+    string result("");
+    for(int ai = 0; ai < firstDim; ai++) {
+        for(int bi = 0; bi < secondDim; bi++) {
+            result += Dimension::toDimensionSymbol(matrix[ai][bi]);
+        }
+    }
+    return result;
 }
 
 std::ostream&
-operator<< (std::ostream&os, const IntersectionMatrix& im)
+operator<< (std::ostream& os, const IntersectionMatrix& im)
 {
-	return os << im.toString();
+    return os << im.toString();
 }
 
 } // namespace geos::geom
diff --git a/src/geom/LineSegment.cpp b/src/geom/LineSegment.cpp
index 0e75f7c..9c490e4 100644
--- a/src/geom/LineSegment.cpp
+++ b/src/geom/LineSegment.cpp
@@ -55,18 +55,22 @@ namespace geom { // geos::geom
 void
 LineSegment::reverse()
 {
-	// TODO: use std::swap<>
-	Coordinate temp=p0;
-	p0=p1;
-	p1=temp;
+    // TODO: use std::swap<>
+    Coordinate temp = p0;
+    p0 = p1;
+    p1 = temp;
 }
 
 /*public*/
 double
 LineSegment::projectionFactor(const Coordinate& p) const
 {
-	if (p==p0) return 0.0;
-	if (p==p1) return 1.0;
+    if(p == p0) {
+        return 0.0;
+    }
+    if(p == p1) {
+        return 1.0;
+    }
     // Otherwise, use comp.graphics.algorithms Frequently Asked Questions method
     /*(1)     	      AC dot AB
                    r = ---------
@@ -78,241 +82,251 @@ LineSegment::projectionFactor(const Coordinate& p) const
                 r>1 P is on the forward extension of AB
                 0<r<1 P is interior to AB
         */
-	double dx=p1.x-p0.x;
-	double dy=p1.y-p0.y;
-	double len2=dx*dx+dy*dy;
-	double r=((p.x-p0.x)*dx+(p.y-p0.y)*dy)/len2;
-	return r;
+    double dx = p1.x - p0.x;
+    double dy = p1.y - p0.y;
+    double len2 = dx * dx + dy * dy;
+    double r = ((p.x - p0.x) * dx + (p.y - p0.y) * dy) / len2;
+    return r;
 }
 
 /*public*/
 double
 LineSegment::segmentFraction(const Coordinate& inputPt) const
 {
-	double segFrac = projectionFactor(inputPt);
-	if (segFrac < 0.0)
-		segFrac = 0.0;
-	else if (segFrac > 1.0)
-		segFrac = 1.0;
-	return segFrac;
+    double segFrac = projectionFactor(inputPt);
+    if(segFrac < 0.0) {
+        segFrac = 0.0;
+    }
+    else if(segFrac > 1.0) {
+        segFrac = 1.0;
+    }
+    return segFrac;
 }
 
 /*public*/
 void
 LineSegment::project(const Coordinate& p, Coordinate& ret) const
 {
-	if (p==p0 || p==p1) ret=p;
-	double r=projectionFactor(p);
-	ret=Coordinate(p0.x+r*(p1.x-p0.x),p0.y+r*(p1.y-p0.y));
+    if(p == p0 || p == p1) {
+        ret = p;
+    }
+    double r = projectionFactor(p);
+    ret = Coordinate(p0.x + r * (p1.x - p0.x), p0.y + r * (p1.y - p0.y));
 }
 
 bool
 LineSegment::project(const LineSegment& seg, LineSegment& ret) const
 {
-	double pf0=projectionFactor(seg.p0);
-	double pf1=projectionFactor(seg.p1);
-	// check if segment projects at all
+    double pf0 = projectionFactor(seg.p0);
+    double pf1 = projectionFactor(seg.p1);
+    // check if segment projects at all
 
-	if (pf0>=1.0 && pf1>=1.0) return false;
+    if(pf0 >= 1.0 && pf1 >= 1.0) {
+        return false;
+    }
 
-	if (pf0<=0.0 && pf1<=0.0) return false;
+    if(pf0 <= 0.0 && pf1 <= 0.0) {
+        return false;
+    }
 
-	Coordinate newp0;
-	project(seg.p0, newp0);
-	Coordinate newp1;
-	project(seg.p1, newp1);
+    Coordinate newp0;
+    project(seg.p0, newp0);
+    Coordinate newp1;
+    project(seg.p1, newp1);
 
-	ret.setCoordinates(newp0, newp1);
+    ret.setCoordinates(newp0, newp1);
 
-	return true;
+    return true;
 }
 
 //Coordinate*
 void
 LineSegment::closestPoint(const Coordinate& p, Coordinate& ret) const
 {
-	double factor=projectionFactor(p);
-	if (factor>0 && factor<1) {
-		project(p, ret);
-		return;
-	}
-	double dist0=p0.distance(p);
-	double dist1=p1.distance(p);
-	if (dist0<dist1)
-	{
-		ret=p0;
-		return;
-	}
-	ret=p1;
+    double factor = projectionFactor(p);
+    if(factor > 0 && factor < 1) {
+        project(p, ret);
+        return;
+    }
+    double dist0 = p0.distance(p);
+    double dist1 = p1.distance(p);
+    if(dist0 < dist1) {
+        ret = p0;
+        return;
+    }
+    ret = p1;
 }
 
 /*public*/
 int
 LineSegment::compareTo(const LineSegment& other) const
 {
-	int comp0=p0.compareTo(other.p0);
-	if (comp0!=0) return comp0;
-	return p1.compareTo(other.p1);
+    int comp0 = p0.compareTo(other.p0);
+    if(comp0 != 0) {
+        return comp0;
+    }
+    return p1.compareTo(other.p1);
 }
 
 /*public*/
 bool
 LineSegment::equalsTopo(const LineSegment& other) const
 {
-	return (p0==other.p0 && p1==other.p1) || (p0==other.p1 && p1==other.p0);
+    return (p0 == other.p0 && p1 == other.p1) || (p0 == other.p1 && p1 == other.p0);
 }
 
 /*public*/
 int
 LineSegment::orientationIndex(const LineSegment& seg) const
 {
-	int orient0 = algorithm::Orientation::index(p0, p1, seg.p0);
-	int orient1 = algorithm::Orientation::index(p0, p1, seg.p1);
-	// this handles the case where the points are L or collinear
-	if (orient0 >= 0 && orient1 >= 0)
-		return std::max(orient0, orient1);
-	// this handles the case where the points are R or collinear
-	if (orient0 <= 0 && orient1 <= 0)
+    int orient0 = algorithm::Orientation::index(p0, p1, seg.p0);
+    int orient1 = algorithm::Orientation::index(p0, p1, seg.p1);
+    // this handles the case where the points are L or collinear
+    if(orient0 >= 0 && orient1 >= 0) {
         return std::max(orient0, orient1);
-	// points lie on opposite sides ==> indeterminate orientation
-	return 0;
+    }
+    // this handles the case where the points are R or collinear
+    if(orient0 <= 0 && orient1 <= 0) {
+        return std::max(orient0, orient1);
+    }
+    // points lie on opposite sides ==> indeterminate orientation
+    return 0;
 }
 
 CoordinateSequence*
 LineSegment::closestPoints(const LineSegment& line)
 {
-	// test for intersection
-	Coordinate intPt;
-	if ( intersection(line, intPt) )
-	{
-		CoordinateSequence *cl=new CoordinateArraySequence(new vector<Coordinate>(2, intPt));
-		return cl;
-	}
-
-	/*
-	 * if no intersection closest pair contains at least one endpoint.
-	 * Test each endpoint in turn.
-	 */
-	CoordinateSequence *closestPt=new CoordinateArraySequence(2);
-	//vector<Coordinate> *cv = new vector<Coordinate>(2);
-
-	double minDistance=DoubleMax;
-	double dist;
-
-	Coordinate close00;
-	closestPoint(line.p0, close00);
-	minDistance = close00.distance(line.p0);
-
-	closestPt->setAt(close00, 0);
-	closestPt->setAt(line.p0, 1);
-
-	Coordinate close01;
-	closestPoint(line.p1, close01);
-	dist = close01.distance(line.p1);
-	if (dist < minDistance) {
-		minDistance = dist;
-		closestPt->setAt(close01,0);
-		closestPt->setAt(line.p1,1);
-		//(*cv)[0] = close01;
-		//(*cv)[1] = line.p1;
-	}
-
-	Coordinate close10;
-	line.closestPoint(p0, close10);
-	dist = close10.distance(p0);
-		if (dist < minDistance) {
-		minDistance = dist;
-		closestPt->setAt(p0,0);
-		closestPt->setAt(close10,1);
-		//(*cv)[0] = p0;
-		//(*cv)[1] = close10;
-	}
-
-	Coordinate close11;
-	line.closestPoint(p1, close11);
-	dist = close11.distance(p1);
-	if (dist < minDistance) {
-		minDistance = dist;
-		closestPt->setAt(p1,0);
-		closestPt->setAt(close11,1);
-		//(*cv)[0] = p1;
-		//(*cv)[1] = *close11;
-	}
-
-	return closestPt;
+    // test for intersection
+    Coordinate intPt;
+    if(intersection(line, intPt)) {
+        CoordinateSequence* cl = new CoordinateArraySequence(new vector<Coordinate>(2, intPt));
+        return cl;
+    }
+
+    /*
+     * if no intersection closest pair contains at least one endpoint.
+     * Test each endpoint in turn.
+     */
+    CoordinateSequence* closestPt = new CoordinateArraySequence(2);
+    //vector<Coordinate> *cv = new vector<Coordinate>(2);
+
+    double minDistance = DoubleMax;
+    double dist;
+
+    Coordinate close00;
+    closestPoint(line.p0, close00);
+    minDistance = close00.distance(line.p0);
+
+    closestPt->setAt(close00, 0);
+    closestPt->setAt(line.p0, 1);
+
+    Coordinate close01;
+    closestPoint(line.p1, close01);
+    dist = close01.distance(line.p1);
+    if(dist < minDistance) {
+        minDistance = dist;
+        closestPt->setAt(close01, 0);
+        closestPt->setAt(line.p1, 1);
+        //(*cv)[0] = close01;
+        //(*cv)[1] = line.p1;
+    }
+
+    Coordinate close10;
+    line.closestPoint(p0, close10);
+    dist = close10.distance(p0);
+    if(dist < minDistance) {
+        minDistance = dist;
+        closestPt->setAt(p0, 0);
+        closestPt->setAt(close10, 1);
+        //(*cv)[0] = p0;
+        //(*cv)[1] = close10;
+    }
+
+    Coordinate close11;
+    line.closestPoint(p1, close11);
+    dist = close11.distance(p1);
+    if(dist < minDistance) {
+        minDistance = dist;
+        closestPt->setAt(p1, 0);
+        closestPt->setAt(close11, 1);
+        //(*cv)[0] = p1;
+        //(*cv)[1] = *close11;
+    }
+
+    return closestPt;
 }
 
 bool
 LineSegment::intersection(const LineSegment& line, Coordinate& ret) const
 {
-	algorithm::LineIntersector li;
-	li.computeIntersection(p0, p1, line.p0, line.p1);
-	if (li.hasIntersection()) {
-		ret=li.getIntersection(0);
-		return true;
-	}
-	return false;
+    algorithm::LineIntersector li;
+    li.computeIntersection(p0, p1, line.p0, line.p1);
+    if(li.hasIntersection()) {
+        ret = li.getIntersection(0);
+        return true;
+    }
+    return false;
 }
 
 bool
 LineSegment::lineIntersection(const LineSegment& line, Coordinate& ret) const
 {
-	try {
-		HCoordinate::intersection(p0, p1, line.p0, line.p1, ret);
-		return true;
-	}
-	catch (const NotRepresentableException& /*ex*/) {
-		// eat this exception, and return null;
-	}
-	return false;
+    try {
+        HCoordinate::intersection(p0, p1, line.p0, line.p1, ret);
+        return true;
+    }
+    catch(const NotRepresentableException& /*ex*/) {
+        // eat this exception, and return null;
+    }
+    return false;
 }
 
 
 /* public */
 void
 LineSegment::pointAlongOffset(double segmentLengthFraction,
-	                      double offsetDistance,
-	                      Coordinate& ret) const
+                              double offsetDistance,
+                              Coordinate& ret) const
 {
-	// the point on the segment line
-	double segx = p0.x + segmentLengthFraction * (p1.x - p0.x);
-	double segy = p0.y + segmentLengthFraction * (p1.y - p0.y);
-
-	double dx = p1.x - p0.x;
-	double dy = p1.y - p0.y;
-	double len = sqrt(dx * dx + dy * dy);
-
-	double ux = 0.0;
-	double uy = 0.0;
-	if (offsetDistance != 0.0) {
-		if (len <= 0.0) {
-			throw util::IllegalStateException("Cannot compute offset from zero-length line segment");
-		}
-
-		// u is the vector that is the length of the offset,
-		// in the direction of the segment
-		ux = offsetDistance * dx / len;
-		uy = offsetDistance * dy / len;
-	}
-
-	// the offset point is the seg point plus the offset
-	// vector rotated 90 degrees CCW
-	double offsetx = segx - uy;
-	double offsety = segy + ux;
-
-	ret = Coordinate(offsetx, offsety);
+    // the point on the segment line
+    double segx = p0.x + segmentLengthFraction * (p1.x - p0.x);
+    double segy = p0.y + segmentLengthFraction * (p1.y - p0.y);
+
+    double dx = p1.x - p0.x;
+    double dy = p1.y - p0.y;
+    double len = sqrt(dx * dx + dy * dy);
+
+    double ux = 0.0;
+    double uy = 0.0;
+    if(offsetDistance != 0.0) {
+        if(len <= 0.0) {
+            throw util::IllegalStateException("Cannot compute offset from zero-length line segment");
+        }
+
+        // u is the vector that is the length of the offset,
+        // in the direction of the segment
+        ux = offsetDistance * dx / len;
+        uy = offsetDistance * dy / len;
+    }
+
+    // the offset point is the seg point plus the offset
+    // vector rotated 90 degrees CCW
+    double offsetx = segx - uy;
+    double offsety = segy + ux;
+
+    ret = Coordinate(offsetx, offsety);
 }
 
 /* public */
 std::unique_ptr<LineString>
 LineSegment::toGeometry(const GeometryFactory& gf) const
 {
-	CoordinateSequence *cl=new CoordinateArraySequence();
-	cl->add(p0);
-	cl->add(p1);
-	return std::unique_ptr<LineString>(
-		gf.createLineString(cl) // ownership transferred
-	);
+    CoordinateSequence* cl = new CoordinateArraySequence();
+    cl->add(p0);
+    cl->add(p1);
+    return std::unique_ptr<LineString>(
+               gf.createLineString(cl) // ownership transferred
+           );
 }
 
 } // namespace geos::geom
diff --git a/src/geom/LineString.cpp b/src/geom/LineString.cpp
index 30bcab8..161facf 100644
--- a/src/geom/LineString.cpp
+++ b/src/geom/LineString.cpp
@@ -46,26 +46,26 @@ namespace geos {
 namespace geom { // geos::geom
 
 /*protected*/
-LineString::LineString(const LineString &ls)
-	:
-	Geometry(ls),
-	points(ls.points->clone())
+LineString::LineString(const LineString& ls)
+    :
+    Geometry(ls),
+    points(ls.points->clone())
 {
-	//points=ls.points->clone();
+    //points=ls.points->clone();
 }
 
 Geometry*
 LineString::reverse() const
 {
-	if (isEmpty()) {
-		return clone();
-	}
+    if(isEmpty()) {
+        return clone();
+    }
 
-	assert(points.get());
-	CoordinateSequence* seq = points->clone();
-	CoordinateSequence::reverse(seq);
-	assert(getFactory());
-	return getFactory()->createLineString(seq);
+    assert(points.get());
+    CoordinateSequence* seq = points->clone();
+    CoordinateSequence::reverse(seq);
+    assert(getFactory());
+    return getFactory()->createLineString(seq);
 }
 
 
@@ -73,70 +73,68 @@ LineString::reverse() const
 void
 LineString::validateConstruction()
 {
-	if (points.get()==nullptr)
-	{
-		points.reset(getFactory()->getCoordinateSequenceFactory()->create());
-		return;
-	}
+    if(points.get() == nullptr) {
+        points.reset(getFactory()->getCoordinateSequenceFactory()->create());
+        return;
+    }
 
-	if (points->size()==1)
-	{
-		throw util::IllegalArgumentException("point array must contain 0 or >1 elements\n");
-	}
+    if(points->size() == 1) {
+        throw util::IllegalArgumentException("point array must contain 0 or >1 elements\n");
+    }
 }
 
 /*protected*/
-LineString::LineString(CoordinateSequence *newCoords,
-		const GeometryFactory *factory)
-	:
-	Geometry(factory),
-	points(newCoords)
+LineString::LineString(CoordinateSequence* newCoords,
+                       const GeometryFactory* factory)
+    :
+    Geometry(factory),
+    points(newCoords)
 {
-	validateConstruction();
+    validateConstruction();
 }
 
 /*public*/
 LineString::LineString(CoordinateSequence::Ptr newCoords,
-		const GeometryFactory *factory)
-	:
-	Geometry(factory),
-	points(std::move(newCoords))
+                       const GeometryFactory* factory)
+    :
+    Geometry(factory),
+    points(std::move(newCoords))
 {
-	validateConstruction();
+    validateConstruction();
 }
 
 
 LineString::~LineString()
 {
-	//delete points;
+    //delete points;
 }
 
 CoordinateSequence*
 LineString::getCoordinates() const
 {
-	assert(points.get());
-	return points->clone();
-	//return points;
+    assert(points.get());
+    return points->clone();
+    //return points;
 }
 
 const CoordinateSequence*
 LineString::getCoordinatesRO() const
 {
-	assert(nullptr != points.get());
-	return points.get();
+    assert(nullptr != points.get());
+    return points.get();
 }
 
 const Coordinate&
 LineString::getCoordinateN(size_t n) const
 {
-	assert(points.get());
-	return points->getAt(n);
+    assert(points.get());
+    return points->getAt(n);
 }
 
 Dimension::DimensionType
 LineString::getDimension() const
 {
-	return Dimension::L; // line
+    return Dimension::L; // line
 }
 
 int
@@ -148,280 +146,297 @@ LineString::getCoordinateDimension() const
 int
 LineString::getBoundaryDimension() const
 {
-	if (isClosed()) {
-		return Dimension::False;
-	}
-	return 0;
+    if(isClosed()) {
+        return Dimension::False;
+    }
+    return 0;
 }
 
 bool
 LineString::isEmpty() const
 {
-	assert(points.get());
-	return points->isEmpty();
+    assert(points.get());
+    return points->isEmpty();
 }
 
 size_t
 LineString::getNumPoints() const
 {
-	assert(points.get());
-	return points->getSize();
+    assert(points.get());
+    return points->getSize();
 }
 
 Point*
 LineString::getPointN(size_t n) const
 {
-	assert(getFactory());
-	assert(points.get());
-	return getFactory()->createPoint(points->getAt(n));
+    assert(getFactory());
+    assert(points.get());
+    return getFactory()->createPoint(points->getAt(n));
 }
 
 Point*
 LineString::getStartPoint() const
 {
-	if (isEmpty()) {
-		return nullptr;
-		//return new Point(NULL,NULL);
-	}
-	return getPointN(0);
+    if(isEmpty()) {
+        return nullptr;
+        //return new Point(NULL,NULL);
+    }
+    return getPointN(0);
 }
 
 Point*
 LineString::getEndPoint() const
 {
-	if (isEmpty()) {
-		return nullptr;
-		//return new Point(NULL,NULL);
-	}
-	return getPointN(getNumPoints() - 1);
+    if(isEmpty()) {
+        return nullptr;
+        //return new Point(NULL,NULL);
+    }
+    return getPointN(getNumPoints() - 1);
 }
 
 bool
 LineString::isClosed() const
 {
-	if (isEmpty()) {
-		return false;
-	}
-	return getCoordinateN(0).equals2D(getCoordinateN(getNumPoints() - 1));
+    if(isEmpty()) {
+        return false;
+    }
+    return getCoordinateN(0).equals2D(getCoordinateN(getNumPoints() - 1));
 }
 
 bool
 LineString::isRing() const
 {
-	return isClosed() && isSimple();
+    return isClosed() && isSimple();
 }
 
 string
 LineString::getGeometryType() const
 {
-	return "LineString";
+    return "LineString";
 }
 
 Geometry*
 LineString::getBoundary() const
 {
-	if (isEmpty()) {
-		return getFactory()->createMultiPoint();
-	}
+    if(isEmpty()) {
+        return getFactory()->createMultiPoint();
+    }
 
-	// using the default OGC_SFS MOD2 rule, the boundary of a
-	// closed LineString is empty
-	if (isClosed()) {
-		return getFactory()->createMultiPoint();
-	}
-	vector<Geometry*> *pts=new vector<Geometry*>();
-	pts->push_back(getStartPoint());
-	pts->push_back(getEndPoint());
-	MultiPoint *mp = getFactory()->createMultiPoint(pts);
-	return mp;
+    // using the default OGC_SFS MOD2 rule, the boundary of a
+    // closed LineString is empty
+    if(isClosed()) {
+        return getFactory()->createMultiPoint();
+    }
+    vector<Geometry*>* pts = new vector<Geometry*>();
+    pts->push_back(getStartPoint());
+    pts->push_back(getEndPoint());
+    MultiPoint* mp = getFactory()->createMultiPoint(pts);
+    return mp;
 }
 
 bool
 LineString::isCoordinate(Coordinate& pt) const
 {
-	assert(points.get());
-	std::size_t npts=points->getSize();
-	for (std::size_t i = 0; i<npts; i++) {
-		if (points->getAt(i)==pt) {
-			return true;
-		}
-	}
-	return false;
+    assert(points.get());
+    std::size_t npts = points->getSize();
+    for(std::size_t i = 0; i < npts; i++) {
+        if(points->getAt(i) == pt) {
+            return true;
+        }
+    }
+    return false;
 }
 
 /*protected*/
 Envelope::Ptr
 LineString::computeEnvelopeInternal() const
 {
-	if (isEmpty()) {
-		// We don't return NULL here
-		// as it would indicate "unknown"
-		// envelope. In this case we
-		// *know* the envelope is EMPTY.
-		return Envelope::Ptr(new Envelope());
-	}
-
-	assert(points.get());
-	const Coordinate& c=points->getAt(0);
-	double minx = c.x;
-	double miny = c.y;
-	double maxx = c.x;
-	double maxy = c.y;
-	std::size_t npts=points->getSize();
-	for (std::size_t i=1; i<npts; i++) {
-		const Coordinate &c1=points->getAt(i);
-		minx = minx < c1.x ? minx : c1.x;
-		maxx = maxx > c1.x ? maxx : c1.x;
-		miny = miny < c1.y ? miny : c1.y;
-		maxy = maxy > c1.y ? maxy : c1.y;
-	}
-
-	// caller expects a newly allocated Envelope.
-	// this function won't be called twice, unless
-	// cached Envelope is invalidated (set to NULL)
-	return Envelope::Ptr(new Envelope(minx, maxx, miny, maxy));
+    if(isEmpty()) {
+        // We don't return NULL here
+        // as it would indicate "unknown"
+        // envelope. In this case we
+        // *know* the envelope is EMPTY.
+        return Envelope::Ptr(new Envelope());
+    }
+
+    assert(points.get());
+    const Coordinate& c = points->getAt(0);
+    double minx = c.x;
+    double miny = c.y;
+    double maxx = c.x;
+    double maxy = c.y;
+    std::size_t npts = points->getSize();
+    for(std::size_t i = 1; i < npts; i++) {
+        const Coordinate& c1 = points->getAt(i);
+        minx = minx < c1.x ? minx : c1.x;
+        maxx = maxx > c1.x ? maxx : c1.x;
+        miny = miny < c1.y ? miny : c1.y;
+        maxy = maxy > c1.y ? maxy : c1.y;
+    }
+
+    // caller expects a newly allocated Envelope.
+    // this function won't be called twice, unless
+    // cached Envelope is invalidated (set to NULL)
+    return Envelope::Ptr(new Envelope(minx, maxx, miny, maxy));
 }
 
 bool
-LineString::equalsExact(const Geometry *other, double tolerance) const
-{
-	if (!isEquivalentClass(other)) {
-		return false;
-	}
-
-	const LineString *otherLineString=dynamic_cast<const LineString*>(other);
-	assert(otherLineString);
-	size_t npts=points->getSize();
-	if (npts!=otherLineString->points->getSize()) {
-		return false;
-	}
-	for (size_t i=0; i<npts; ++i) {
-		if (!equal(points->getAt(i),otherLineString->points->getAt(i),tolerance)) {
-			return false;
-		}
-	}
-	return true;
+LineString::equalsExact(const Geometry* other, double tolerance) const
+{
+    if(!isEquivalentClass(other)) {
+        return false;
+    }
+
+    const LineString* otherLineString = dynamic_cast<const LineString*>(other);
+    assert(otherLineString);
+    size_t npts = points->getSize();
+    if(npts != otherLineString->points->getSize()) {
+        return false;
+    }
+    for(size_t i = 0; i < npts; ++i) {
+        if(!equal(points->getAt(i), otherLineString->points->getAt(i), tolerance)) {
+            return false;
+        }
+    }
+    return true;
 }
 
 void
-LineString::apply_rw(const CoordinateFilter *filter)
+LineString::apply_rw(const CoordinateFilter* filter)
 {
-	assert(points.get());
-	points->apply_rw(filter);
+    assert(points.get());
+    points->apply_rw(filter);
 }
 
 void
-LineString::apply_ro(CoordinateFilter *filter) const
+LineString::apply_ro(CoordinateFilter* filter) const
 {
-	assert(points.get());
-	points->apply_ro(filter);
+    assert(points.get());
+    points->apply_ro(filter);
 }
 
-void LineString::apply_rw(GeometryFilter *filter)
+void
+LineString::apply_rw(GeometryFilter* filter)
 {
-	assert(filter);
-	filter->filter_rw(this);
+    assert(filter);
+    filter->filter_rw(this);
 }
 
-void LineString::apply_ro(GeometryFilter *filter) const
+void
+LineString::apply_ro(GeometryFilter* filter) const
 {
-	assert(filter);
-	filter->filter_ro(this);
+    assert(filter);
+    filter->filter_ro(this);
 }
 
 /*public*/
 void
 LineString::normalize()
 {
-	assert(points.get());
-	std::size_t npts=points->getSize();
-	std::size_t n=npts/2;
-	for (std::size_t i=0; i<n; i++) {
-		std::size_t j = npts - 1 - i;
-		if (!(points->getAt(i)==points->getAt(j))) {
-			if (points->getAt(i).compareTo(points->getAt(j)) > 0) {
-				CoordinateSequence::reverse(points.get());
-			}
-			return;
-		}
-	}
+    assert(points.get());
+    std::size_t npts = points->getSize();
+    std::size_t n = npts / 2;
+    for(std::size_t i = 0; i < n; i++) {
+        std::size_t j = npts - 1 - i;
+        if(!(points->getAt(i) == points->getAt(j))) {
+            if(points->getAt(i).compareTo(points->getAt(j)) > 0) {
+                CoordinateSequence::reverse(points.get());
+            }
+            return;
+        }
+    }
 }
 
 int
-LineString::compareToSameClass(const Geometry *ls) const
-{
-	const LineString *line=dynamic_cast<const LineString*>(ls);
-	assert(line);
-	// MD - optimized implementation
-	std::size_t mynpts=points->getSize();
-	std::size_t othnpts=line->points->getSize();
-	if ( mynpts > othnpts ) return 1;
-	if ( mynpts < othnpts ) return -1;
-	for (std::size_t i=0; i<mynpts; i++)
-	{
-		int cmp=points->getAt(i).compareTo(line->points->getAt(i));
-		if (cmp) return cmp;
-	}
-	return 0;
+LineString::compareToSameClass(const Geometry* ls) const
+{
+    const LineString* line = dynamic_cast<const LineString*>(ls);
+    assert(line);
+    // MD - optimized implementation
+    std::size_t mynpts = points->getSize();
+    std::size_t othnpts = line->points->getSize();
+    if(mynpts > othnpts) {
+        return 1;
+    }
+    if(mynpts < othnpts) {
+        return -1;
+    }
+    for(std::size_t i = 0; i < mynpts; i++) {
+        int cmp = points->getAt(i).compareTo(line->points->getAt(i));
+        if(cmp) {
+            return cmp;
+        }
+    }
+    return 0;
 }
 
 const Coordinate*
 LineString::getCoordinate() const
 {
-	if (isEmpty()) return nullptr;
-	return &(points->getAt(0));
+    if(isEmpty()) {
+        return nullptr;
+    }
+    return &(points->getAt(0));
 }
 
 double
 LineString::getLength() const
 {
-	return Length::ofLine(points.get());
+    return Length::ofLine(points.get());
 }
 
 void
-LineString::apply_rw(GeometryComponentFilter *filter)
+LineString::apply_rw(GeometryComponentFilter* filter)
 {
-	assert(filter);
-	filter->filter_rw(this);
+    assert(filter);
+    filter->filter_rw(this);
 }
 
 void
-LineString::apply_ro(GeometryComponentFilter *filter) const
+LineString::apply_ro(GeometryComponentFilter* filter) const
 {
-	assert(filter);
-	filter->filter_ro(this);
+    assert(filter);
+    filter->filter_ro(this);
 }
 
 void
 LineString::apply_rw(CoordinateSequenceFilter& filter)
 {
-	size_t npts=points->size();
-	if (!npts) return;
-	for (size_t i = 0; i<npts; ++i)
-	{
-		filter.filter_rw(*points, i);
-		if (filter.isDone()) break;
-	}
-	if (filter.isGeometryChanged()) geometryChanged();
+    size_t npts = points->size();
+    if(!npts) {
+        return;
+    }
+    for(size_t i = 0; i < npts; ++i) {
+        filter.filter_rw(*points, i);
+        if(filter.isDone()) {
+            break;
+        }
+    }
+    if(filter.isGeometryChanged()) {
+        geometryChanged();
+    }
 }
 
 void
 LineString::apply_ro(CoordinateSequenceFilter& filter) const
 {
-	size_t npts=points->size();
-	if (!npts) return;
-	for (size_t i = 0; i<npts; ++i)
-	{
-		filter.filter_ro(*points, i);
-		if (filter.isDone()) break;
-	}
-	//if (filter.isGeometryChanged()) geometryChanged();
+    size_t npts = points->size();
+    if(!npts) {
+        return;
+    }
+    for(size_t i = 0; i < npts; ++i) {
+        filter.filter_ro(*points, i);
+        if(filter.isDone()) {
+            break;
+        }
+    }
+    //if (filter.isGeometryChanged()) geometryChanged();
 }
 
 GeometryTypeId
 LineString::getGeometryTypeId() const
 {
-	return GEOS_LINESTRING;
+    return GEOS_LINESTRING;
 }
 
 } // namespace geos::geom
diff --git a/src/geom/LinearRing.cpp b/src/geom/LinearRing.cpp
index 01e10f3..af022fe 100644
--- a/src/geom/LinearRing.cpp
+++ b/src/geom/LinearRing.cpp
@@ -34,100 +34,106 @@ namespace geos {
 namespace geom { // geos::geom
 
 /*public*/
-LinearRing::LinearRing(const LinearRing &lr): Geometry(lr), LineString(lr) {}
+LinearRing::LinearRing(const LinearRing& lr): Geometry(lr), LineString(lr) {}
 
 /*public*/
 LinearRing::LinearRing(CoordinateSequence* newCoords,
-		const GeometryFactory *newFactory)
-	:
-	Geometry(newFactory),
-	LineString(newCoords, newFactory)
+                       const GeometryFactory* newFactory)
+    :
+    Geometry(newFactory),
+    LineString(newCoords, newFactory)
 {
-	validateConstruction();
+    validateConstruction();
 }
 
 /*public*/
 LinearRing::LinearRing(CoordinateSequence::Ptr newCoords,
-		const GeometryFactory *newFactory)
-	:
-	Geometry(newFactory),
-	LineString(std::move(newCoords), newFactory)
+                       const GeometryFactory* newFactory)
+    :
+    Geometry(newFactory),
+    LineString(std::move(newCoords), newFactory)
 {
-	validateConstruction();
+    validateConstruction();
 }
 
 
 void
 LinearRing::validateConstruction()
 {
-	// Empty ring is valid
-	if ( points->isEmpty() ) return;
-
-	if ( !LineString::isClosed() )
-	{
-		throw util::IllegalArgumentException(
-		  "Points of LinearRing do not form a closed linestring"
-		);
-	}
-
-	if ( points->getSize() < MINIMUM_VALID_SIZE )
-	{
-		std::ostringstream os;
-		os << "Invalid number of points in LinearRing found "
-		   << points->getSize() << " - must be 0 or >= 4";
-		throw util::IllegalArgumentException(os.str());
-	}
+    // Empty ring is valid
+    if(points->isEmpty()) {
+        return;
+    }
+
+    if(!LineString::isClosed()) {
+        throw util::IllegalArgumentException(
+            "Points of LinearRing do not form a closed linestring"
+        );
+    }
+
+    if(points->getSize() < MINIMUM_VALID_SIZE) {
+        std::ostringstream os;
+        os << "Invalid number of points in LinearRing found "
+           << points->getSize() << " - must be 0 or >= 4";
+        throw util::IllegalArgumentException(os.str());
+    }
 }
 
 
 
 // superclass LineString will delete internal CoordinateSequence
-LinearRing::~LinearRing(){
+LinearRing::~LinearRing()
+{
 }
 
 int
 LinearRing::getBoundaryDimension() const
 {
-	return Dimension::False;
+    return Dimension::False;
 }
 
 bool
 LinearRing::isClosed() const
 {
-	if ( points->isEmpty() ) {
-		// empty LinearRings are closed by definition
-		return true;
-	}
-	return LineString::isClosed();
+    if(points->isEmpty()) {
+        // empty LinearRings are closed by definition
+        return true;
+    }
+    return LineString::isClosed();
 }
 
-string LinearRing::getGeometryType() const {
-	return "LinearRing";
+string
+LinearRing::getGeometryType() const
+{
+    return "LinearRing";
 }
 
-void LinearRing::setPoints(CoordinateSequence* cl){
-	const vector<Coordinate> *v=cl->toVector();
-	points->setPoints(*(v));
-	//delete v;
+void
+LinearRing::setPoints(CoordinateSequence* cl)
+{
+    const vector<Coordinate>* v = cl->toVector();
+    points->setPoints(*(v));
+    //delete v;
 }
 
 GeometryTypeId
-LinearRing::getGeometryTypeId() const {
-	return GEOS_LINEARRING;
+LinearRing::getGeometryTypeId() const
+{
+    return GEOS_LINEARRING;
 }
 
 Geometry*
 LinearRing::reverse() const
 {
-	if (isEmpty()) {
-		return clone();
-	}
-
-	assert(points.get());
-	CoordinateSequence* seq = points->clone();
-	CoordinateSequence::reverse(seq);
-	assert(getFactory());
-	return getFactory()->createLinearRing(seq);
+    if(isEmpty()) {
+        return clone();
+    }
+
+    assert(points.get());
+    CoordinateSequence* seq = points->clone();
+    CoordinateSequence::reverse(seq);
+    assert(getFactory());
+    return getFactory()->createLinearRing(seq);
 }
 
 } // namespace geos::geom
diff --git a/src/geom/Location.cpp b/src/geom/Location.cpp
index d936928..cd1d51d 100644
--- a/src/geom/Location.cpp
+++ b/src/geom/Location.cpp
@@ -28,21 +28,23 @@ namespace geom { // geos::geom
  *@param  locationValue  either EXTERIOR, BOUNDARY, INTERIOR or NULL
  *@return                either 'e', 'b', 'i' or '-'
  */
-char Location::toLocationSymbol(int locationValue) {
-	switch (locationValue) {
-		case EXTERIOR:
-			return 'e';
-		case BOUNDARY:
-			return 'b';
-		case INTERIOR:
-			return 'i';
-		case UNDEF: //NULL
-			return '-';
-		default:
-			ostringstream s;
-			s<<"Unknown location value: "<<locationValue;
-			throw util::IllegalArgumentException(s.str());
-	}
+char
+Location::toLocationSymbol(int locationValue)
+{
+    switch(locationValue) {
+    case EXTERIOR:
+        return 'e';
+    case BOUNDARY:
+        return 'b';
+    case INTERIOR:
+        return 'i';
+    case UNDEF: //NULL
+        return '-';
+    default:
+        ostringstream s;
+        s << "Unknown location value: " << locationValue;
+        throw util::IllegalArgumentException(s.str());
+    }
 }
 
 } // namespace geos::geom
diff --git a/src/geom/MultiLineString.cpp b/src/geom/MultiLineString.cpp
index 5f875d3..58def9a 100644
--- a/src/geom/MultiLineString.cpp
+++ b/src/geom/MultiLineString.cpp
@@ -40,87 +40,94 @@ namespace geos {
 namespace geom { // geos::geom
 
 /*protected*/
-MultiLineString::MultiLineString(vector<Geometry *> *newLines,
-		const GeometryFactory *factory)
-	:
-	Geometry(factory),
-	GeometryCollection(newLines,factory)
+MultiLineString::MultiLineString(vector<Geometry*>* newLines,
+                                 const GeometryFactory* factory)
+    :
+    Geometry(factory),
+    GeometryCollection(newLines, factory)
 {
 }
 
-MultiLineString::~MultiLineString(){}
+MultiLineString::~MultiLineString() {}
 
 Dimension::DimensionType
-MultiLineString::getDimension() const {
-	return Dimension::L; // line
+MultiLineString::getDimension() const
+{
+    return Dimension::L; // line
 }
 
-int MultiLineString::getBoundaryDimension() const {
-	if (isClosed()) {
-		return Dimension::False;
-	}
-	return 0;
+int
+MultiLineString::getBoundaryDimension() const
+{
+    if(isClosed()) {
+        return Dimension::False;
+    }
+    return 0;
 }
 
-string MultiLineString::getGeometryType() const {
-	return "MultiLineString";
+string
+MultiLineString::getGeometryType() const
+{
+    return "MultiLineString";
 }
 
-bool MultiLineString::isClosed() const {
-	if (isEmpty()) {
-		return false;
-	}
-	for (size_t i = 0, n = geometries->size(); i < n; ++i) {
-		LineString *ls = dynamic_cast<LineString*>((*geometries)[i]);
-		if ( ! ls->isClosed() ) {
-			return false;
-		}
-	}
-	return true;
+bool
+MultiLineString::isClosed() const
+{
+    if(isEmpty()) {
+        return false;
+    }
+    for(size_t i = 0, n = geometries->size(); i < n; ++i) {
+        LineString* ls = dynamic_cast<LineString*>((*geometries)[i]);
+        if(! ls->isClosed()) {
+            return false;
+        }
+    }
+    return true;
 }
 
 Geometry*
 MultiLineString::getBoundary() const
 {
-	if (isEmpty()) {
-		return getFactory()->createGeometryCollection(nullptr);
-	}
-	//Geometry *in = toInternalGeometry(this);
-	GeometryGraph gg(0, this);
-	CoordinateSequence *pts=gg.getBoundaryPoints();
-	Geometry *ret = getFactory()->createMultiPoint(*pts);
-	return ret;
+    if(isEmpty()) {
+        return getFactory()->createGeometryCollection(nullptr);
+    }
+    //Geometry *in = toInternalGeometry(this);
+    GeometryGraph gg(0, this);
+    CoordinateSequence* pts = gg.getBoundaryPoints();
+    Geometry* ret = getFactory()->createMultiPoint(*pts);
+    return ret;
 }
 
 bool
-MultiLineString::equalsExact(const Geometry *other, double tolerance) const
+MultiLineString::equalsExact(const Geometry* other, double tolerance) const
 {
-    if (!isEquivalentClass(other)) {
-      return false;
+    if(!isEquivalentClass(other)) {
+        return false;
     }
-	return GeometryCollection::equalsExact(other, tolerance);
+    return GeometryCollection::equalsExact(other, tolerance);
 }
 GeometryTypeId
-MultiLineString::getGeometryTypeId() const {
-	return GEOS_MULTILINESTRING;
+MultiLineString::getGeometryTypeId() const
+{
+    return GEOS_MULTILINESTRING;
 }
 
 Geometry*
 MultiLineString::reverse() const
 {
-	if (isEmpty()) {
-		return clone();
-	}
-
-	size_t nLines = geometries->size();
-	Geometry::NonConstVect *revLines = new Geometry::NonConstVect(nLines);
-	for (size_t i=0; i<nLines; ++i)
-	{
-		LineString *iLS = dynamic_cast<LineString*>((*geometries)[i]);
-		assert(iLS);
-		(*revLines)[nLines-1-i] = iLS->reverse();
-	}
-	return getFactory()->createMultiLineString(revLines);
+    if(isEmpty()) {
+        return clone();
+    }
+
+    size_t nLines = geometries->size();
+    Geometry::NonConstVect* revLines = new Geometry::NonConstVect(nLines);
+    for(size_t i = 0; i < nLines; ++i) {
+        LineString* iLS = dynamic_cast<LineString*>((*geometries)[i]);
+        assert(iLS);
+        (*revLines)[nLines - 1 - i] = iLS->reverse();
+    }
+    return getFactory()->createMultiLineString(revLines);
 }
 
 } // namespace geos::geom
diff --git a/src/geom/MultiPoint.cpp b/src/geom/MultiPoint.cpp
index f20af5b..fc4abc0 100644
--- a/src/geom/MultiPoint.cpp
+++ b/src/geom/MultiPoint.cpp
@@ -32,48 +32,58 @@ namespace geos {
 namespace geom { // geos::geom
 
 /*protected*/
-MultiPoint::MultiPoint(vector<Geometry *> *newPoints, const GeometryFactory *factory)
-	:
-	Geometry(factory),
-	GeometryCollection(newPoints,factory)
+MultiPoint::MultiPoint(vector<Geometry*>* newPoints, const GeometryFactory* factory)
+    :
+    Geometry(factory),
+    GeometryCollection(newPoints, factory)
 {
 }
 
 
-MultiPoint::~MultiPoint(){}
+MultiPoint::~MultiPoint() {}
 
 Dimension::DimensionType
-MultiPoint::getDimension() const {
-	return Dimension::P; // point
+MultiPoint::getDimension() const
+{
+    return Dimension::P; // point
 }
 
-int MultiPoint::getBoundaryDimension() const {
-	return Dimension::False;
+int
+MultiPoint::getBoundaryDimension() const
+{
+    return Dimension::False;
 }
 
-string MultiPoint::getGeometryType() const {
-	return "MultiPoint";
+string
+MultiPoint::getGeometryType() const
+{
+    return "MultiPoint";
 }
 
-Geometry* MultiPoint::getBoundary() const {
-	return getFactory()->createGeometryCollection();
+Geometry*
+MultiPoint::getBoundary() const
+{
+    return getFactory()->createGeometryCollection();
 }
 
 bool
-MultiPoint::equalsExact(const Geometry *other, double tolerance) const
+MultiPoint::equalsExact(const Geometry* other, double tolerance) const
 {
-    if (!isEquivalentClass(other)) {
-      return false;
+    if(!isEquivalentClass(other)) {
+        return false;
     }
-	return GeometryCollection::equalsExact(other,tolerance);
-  }
+    return GeometryCollection::equalsExact(other, tolerance);
+}
 
-const Coordinate* MultiPoint::getCoordinateN(size_t n) const {
-	return ((*geometries)[n])->getCoordinate();
+const Coordinate*
+MultiPoint::getCoordinateN(size_t n) const
+{
+    return ((*geometries)[n])->getCoordinate();
 }
 GeometryTypeId
-MultiPoint::getGeometryTypeId() const {
-	return GEOS_MULTIPOINT;
+MultiPoint::getGeometryTypeId() const
+{
+    return GEOS_MULTIPOINT;
 }
 
 } // namespace geos::geom
diff --git a/src/geom/MultiPolygon.cpp b/src/geom/MultiPolygon.cpp
index 84fce6a..0e52aad 100644
--- a/src/geom/MultiPolygon.cpp
+++ b/src/geom/MultiPolygon.cpp
@@ -40,86 +40,91 @@ namespace geos {
 namespace geom { // geos::geom
 
 /*protected*/
-MultiPolygon::MultiPolygon(vector<Geometry *> *newPolys, const GeometryFactory *factory)
-	: Geometry(factory),
-	  GeometryCollection(newPolys,factory)
+MultiPolygon::MultiPolygon(vector<Geometry*>* newPolys, const GeometryFactory* factory)
+    : Geometry(factory),
+      GeometryCollection(newPolys, factory)
 {}
 
-MultiPolygon::~MultiPolygon(){}
+MultiPolygon::~MultiPolygon() {}
 
 Dimension::DimensionType
-MultiPolygon::getDimension() const {
-	return Dimension::A; // area
+MultiPolygon::getDimension() const
+{
+    return Dimension::A; // area
 }
 
-int MultiPolygon::getBoundaryDimension() const {
-	return 1;
+int
+MultiPolygon::getBoundaryDimension() const
+{
+    return 1;
 }
 
-string MultiPolygon::getGeometryType() const {
-	return "MultiPolygon";
+string
+MultiPolygon::getGeometryType() const
+{
+    return "MultiPolygon";
 }
 
-Geometry* MultiPolygon::getBoundary() const {
-	if (isEmpty()) {
-		return getFactory()->createMultiLineString();
-	}
-	vector<Geometry *>* allRings=new vector<Geometry *>();
-	for (size_t i = 0; i < geometries->size(); i++) {
-		Polygon *pg=dynamic_cast<Polygon *>((*geometries)[i]);
-		assert(pg);
-		Geometry *g=pg->getBoundary();
-		if ( LineString *ls=dynamic_cast<LineString *>(g) )
-		{
-			allRings->push_back(ls);
-		}
-		else
-		{
-			GeometryCollection* rings=dynamic_cast<GeometryCollection*>(g);
-			for (size_t j=0, jn=rings->getNumGeometries();
-					j<jn; ++j)
-			{
-				//allRings->push_back(new LineString(*(LineString*)rings->getGeometryN(j)));
-				allRings->push_back(rings->getGeometryN(j)->clone());
-			}
-			delete g;
-		}
-	}
-
-	Geometry *ret=getFactory()->createMultiLineString(allRings);
-	//for (int i=0; i<allRings->size(); i++) delete (*allRings)[i];
-	//delete allRings;
-	return ret;
+Geometry*
+MultiPolygon::getBoundary() const
+{
+    if(isEmpty()) {
+        return getFactory()->createMultiLineString();
+    }
+    vector<Geometry*>* allRings = new vector<Geometry*>();
+    for(size_t i = 0; i < geometries->size(); i++) {
+        Polygon* pg = dynamic_cast<Polygon*>((*geometries)[i]);
+        assert(pg);
+        Geometry* g = pg->getBoundary();
+        if(LineString* ls = dynamic_cast<LineString*>(g)) {
+            allRings->push_back(ls);
+        }
+        else {
+            GeometryCollection* rings = dynamic_cast<GeometryCollection*>(g);
+            for(size_t j = 0, jn = rings->getNumGeometries();
+                    j < jn; ++j) {
+                //allRings->push_back(new LineString(*(LineString*)rings->getGeometryN(j)));
+                allRings->push_back(rings->getGeometryN(j)->clone());
+            }
+            delete g;
+        }
+    }
+
+    Geometry* ret = getFactory()->createMultiLineString(allRings);
+    //for (int i=0; i<allRings->size(); i++) delete (*allRings)[i];
+    //delete allRings;
+    return ret;
 }
 
 bool
-MultiPolygon::equalsExact(const Geometry *other, double tolerance) const
+MultiPolygon::equalsExact(const Geometry* other, double tolerance) const
 {
-    if (!isEquivalentClass(other)) {
-      return false;
+    if(!isEquivalentClass(other)) {
+        return false;
     }
-	return GeometryCollection::equalsExact(other, tolerance);
+    return GeometryCollection::equalsExact(other, tolerance);
 }
 GeometryTypeId
-MultiPolygon::getGeometryTypeId() const {
-	return GEOS_MULTIPOLYGON;
+MultiPolygon::getGeometryTypeId() const
+{
+    return GEOS_MULTIPOLYGON;
 }
 
 Geometry*
 MultiPolygon::reverse() const
 {
-	if (isEmpty()) {
-		return clone();
-	}
+    if(isEmpty()) {
+        return clone();
+    }
 
-    auto* reversed = new std::vector<Geometry*>{geometries->size()};
+    auto* reversed = new std::vector<Geometry*> {geometries->size()};
 
     std::transform(geometries->begin(),
                    geometries->end(),
                    reversed->begin(),
-                   [](const Geometry* g) {
-                       return g->reverse();
-                   });
+    [](const Geometry * g) {
+        return g->reverse();
+    });
 
     return getFactory()->createMultiPolygon(reversed);
 }
diff --git a/src/geom/Point.cpp b/src/geom/Point.cpp
index a602d05..f9071ab 100644
--- a/src/geom/Point.cpp
+++ b/src/geom/Point.cpp
@@ -43,57 +43,56 @@ namespace geom { // geos::geom
 
 
 /*protected*/
-Point::Point(CoordinateSequence *newCoords, const GeometryFactory *factory)
-	:
-	Geometry(factory),
-	coordinates(newCoords)
+Point::Point(CoordinateSequence* newCoords, const GeometryFactory* factory)
+    :
+    Geometry(factory),
+    coordinates(newCoords)
 {
-	if (coordinates.get()==nullptr) {
-		coordinates.reset(factory->getCoordinateSequenceFactory()->create());
-		return;
-	}
-	if (coordinates->getSize() != 1)
-	{
-		throw util::IllegalArgumentException("Point coordinate list must contain a single element");
-	}
+    if(coordinates.get() == nullptr) {
+        coordinates.reset(factory->getCoordinateSequenceFactory()->create());
+        return;
+    }
+    if(coordinates->getSize() != 1) {
+        throw util::IllegalArgumentException("Point coordinate list must contain a single element");
+    }
 }
 
 /*protected*/
-Point::Point(const Point &p)
-	:
-	Geometry(p),
-	coordinates(p.coordinates->clone())
+Point::Point(const Point& p)
+    :
+    Geometry(p),
+    coordinates(p.coordinates->clone())
 {
 }
 
-CoordinateSequence *
+CoordinateSequence*
 Point::getCoordinates() const
 {
-	return coordinates->clone();
+    return coordinates->clone();
 }
 
 size_t
 Point::getNumPoints() const
 {
-	return isEmpty() ? 0 : 1;
+    return isEmpty() ? 0 : 1;
 }
 
 bool
 Point::isEmpty() const
 {
-	return coordinates->isEmpty();
+    return coordinates->isEmpty();
 }
 
 bool
 Point::isSimple() const
 {
-	return true;
+    return true;
 }
 
 Dimension::DimensionType
 Point::getDimension() const
 {
-	return Dimension::P; // point
+    return Dimension::P; // point
 }
 
 int
@@ -105,168 +104,182 @@ Point::getCoordinateDimension() const
 int
 Point::getBoundaryDimension() const
 {
-	return Dimension::False;
+    return Dimension::False;
 }
 
 double
 Point::getX() const
 {
-	if (isEmpty()) {
-		throw util::UnsupportedOperationException("getX called on empty Point\n");
-	}
-	return getCoordinate()->x;
+    if(isEmpty()) {
+        throw util::UnsupportedOperationException("getX called on empty Point\n");
+    }
+    return getCoordinate()->x;
 }
 
 double
 Point::getY() const
 {
-	if (isEmpty()) {
-		throw util::UnsupportedOperationException("getY called on empty Point\n");
-	}
-	return getCoordinate()->y;
+    if(isEmpty()) {
+        throw util::UnsupportedOperationException("getY called on empty Point\n");
+    }
+    return getCoordinate()->y;
 }
 
 double
 Point::getZ() const
 {
-	if (isEmpty()) {
-		throw util::UnsupportedOperationException("getZ called on empty Point\n");
-	}
-	return getCoordinate()->z;
+    if(isEmpty()) {
+        throw util::UnsupportedOperationException("getZ called on empty Point\n");
+    }
+    return getCoordinate()->z;
 }
 
-const Coordinate *
+const Coordinate*
 Point::getCoordinate() const
 {
-	return coordinates->getSize()!=0 ? &(coordinates->getAt(0)) : nullptr;
+    return coordinates->getSize() != 0 ? &(coordinates->getAt(0)) : nullptr;
 }
 
 string
 Point::getGeometryType() const
 {
-	return "Point";
+    return "Point";
 }
 
-Geometry *
+Geometry*
 Point::getBoundary() const
 {
-	return getFactory()->createGeometryCollection(nullptr);
+    return getFactory()->createGeometryCollection(nullptr);
 }
 
 Envelope::Ptr
 Point::computeEnvelopeInternal() const
 {
-	if (isEmpty()) {
-		return Envelope::Ptr(new Envelope());
-	}
+    if(isEmpty()) {
+        return Envelope::Ptr(new Envelope());
+    }
 
-	return Envelope::Ptr(new Envelope(getCoordinate()->x,
-			getCoordinate()->x, getCoordinate()->y,
-			getCoordinate()->y));
+    return Envelope::Ptr(new Envelope(getCoordinate()->x,
+                                      getCoordinate()->x, getCoordinate()->y,
+                                      getCoordinate()->y));
 }
 
 void
-Point::apply_ro(CoordinateFilter *filter) const
+Point::apply_ro(CoordinateFilter* filter) const
 {
-	if (isEmpty()) {return;}
-	filter->filter_ro(getCoordinate());
+    if(isEmpty()) {
+        return;
+    }
+    filter->filter_ro(getCoordinate());
 }
 
 void
-Point::apply_rw(const CoordinateFilter *filter)
+Point::apply_rw(const CoordinateFilter* filter)
 {
-	if (isEmpty()) {return;}
-	Coordinate newcoord = coordinates->getAt(0);
-	filter->filter_rw(&newcoord);
-	coordinates->setAt(newcoord, 0);
+    if(isEmpty()) {
+        return;
+    }
+    Coordinate newcoord = coordinates->getAt(0);
+    filter->filter_rw(&newcoord);
+    coordinates->setAt(newcoord, 0);
 }
 
 void
-Point::apply_rw(GeometryFilter *filter)
+Point::apply_rw(GeometryFilter* filter)
 {
-	filter->filter_rw(this);
+    filter->filter_rw(this);
 }
 
 void
-Point::apply_ro(GeometryFilter *filter) const
+Point::apply_ro(GeometryFilter* filter) const
 {
-	filter->filter_ro(this);
+    filter->filter_ro(this);
 }
 
 void
-Point::apply_rw(GeometryComponentFilter *filter)
+Point::apply_rw(GeometryComponentFilter* filter)
 {
-	filter->filter_rw(this);
+    filter->filter_rw(this);
 }
 
 void
-Point::apply_ro(GeometryComponentFilter *filter) const
+Point::apply_ro(GeometryComponentFilter* filter) const
 {
-	filter->filter_ro(this);
+    filter->filter_ro(this);
 }
 
 void
 Point::apply_rw(CoordinateSequenceFilter& filter)
 {
-	if (isEmpty()) return;
-	filter.filter_rw(*coordinates, 0);
-	if (filter.isGeometryChanged()) geometryChanged();
+    if(isEmpty()) {
+        return;
+    }
+    filter.filter_rw(*coordinates, 0);
+    if(filter.isGeometryChanged()) {
+        geometryChanged();
+    }
 }
 
 void
 Point::apply_ro(CoordinateSequenceFilter& filter) const
 {
-	if (isEmpty()) return;
-	filter.filter_ro(*coordinates, 0);
-	//if (filter.isGeometryChanged()) geometryChanged();
+    if(isEmpty()) {
+        return;
+    }
+    filter.filter_ro(*coordinates, 0);
+    //if (filter.isGeometryChanged()) geometryChanged();
 }
 
 bool
-Point::equalsExact(const Geometry *other, double tolerance) const
+Point::equalsExact(const Geometry* other, double tolerance) const
 {
-	if (!isEquivalentClass(other)) {
-		return false;
-	}
+    if(!isEquivalentClass(other)) {
+        return false;
+    }
 
-	// assume the isEquivalentClass would return false
-	// if other is not a point
-	assert(dynamic_cast<const Point*>(other));
+    // assume the isEquivalentClass would return false
+    // if other is not a point
+    assert(dynamic_cast<const Point*>(other));
 
-	if ( isEmpty() ) return other->isEmpty();
-	else if ( other->isEmpty() ) return false;
+    if(isEmpty()) {
+        return other->isEmpty();
+    }
+    else if(other->isEmpty()) {
+        return false;
+    }
 
-	const Coordinate* this_coord = getCoordinate();
-	const Coordinate* other_coord = other->getCoordinate();
+    const Coordinate* this_coord = getCoordinate();
+    const Coordinate* other_coord = other->getCoordinate();
 
-	// assume the isEmpty checks above worked :)
-	assert(this_coord && other_coord);
+    // assume the isEmpty checks above worked :)
+    assert(this_coord && other_coord);
 
-	return equal(*this_coord, *other_coord, tolerance);
+    return equal(*this_coord, *other_coord, tolerance);
 }
 
 int
-Point::compareToSameClass(const Geometry *g) const
+Point::compareToSameClass(const Geometry* g) const
 {
-	const Point* p = dynamic_cast<const Point*>(g);
-	return getCoordinate()->compareTo(*(p->getCoordinate()));
+    const Point* p = dynamic_cast<const Point*>(g);
+    return getCoordinate()->compareTo(*(p->getCoordinate()));
 }
 
 Point::~Point()
 {
-	//delete coordinates;
+    //delete coordinates;
 }
 
 GeometryTypeId
 Point::getGeometryTypeId() const
 {
-	return GEOS_POINT;
+    return GEOS_POINT;
 }
 
 /*public*/
 const CoordinateSequence*
 Point::getCoordinatesRO() const
 {
-	return coordinates.get();
+    return coordinates.get();
 }
 
 } // namespace geos::geom
diff --git a/src/geom/Polygon.cpp b/src/geom/Polygon.cpp
index 8211b91..737d316 100644
--- a/src/geom/Polygon.cpp
+++ b/src/geom/Polygon.cpp
@@ -51,154 +51,149 @@ namespace geos {
 namespace geom { // geos::geom
 
 /*protected*/
-Polygon::Polygon(const Polygon &p)
-	:
-	Geometry(p)
-{
-	shell=new LinearRing(*p.shell);
-	size_t nholes=p.holes->size();
-	holes=new vector<Geometry *>(nholes);
-	for(size_t i=0; i<nholes; ++i)
-	{
-    // TODO: holes is a vector of Geometry, anyway
-    //       so there's no point in casting here,
-    //       just use ->clone instead !
-		const LinearRing* lr = dynamic_cast<const LinearRing *>((*p.holes)[i]);
-		LinearRing *h=new LinearRing(*lr);
-		(*holes)[i]=h;
-	}
+Polygon::Polygon(const Polygon& p)
+    :
+    Geometry(p)
+{
+    shell = new LinearRing(*p.shell);
+    size_t nholes = p.holes->size();
+    holes = new vector<Geometry*>(nholes);
+    for(size_t i = 0; i < nholes; ++i) {
+        // TODO: holes is a vector of Geometry, anyway
+        //       so there's no point in casting here,
+        //       just use ->clone instead !
+        const LinearRing* lr = dynamic_cast<const LinearRing*>((*p.holes)[i]);
+        LinearRing* h = new LinearRing(*lr);
+        (*holes)[i] = h;
+    }
 }
 
 /*protected*/
-Polygon::Polygon(LinearRing *newShell, vector<Geometry *> *newHoles,
-		const GeometryFactory *newFactory):
-	Geometry(newFactory)
-{
-	if (newShell==nullptr) {
-		shell=getFactory()->createLinearRing(nullptr);
-	}
-	else
-	{
-		if (newHoles != nullptr && newShell->isEmpty() && hasNonEmptyElements(newHoles)) {
-			throw util::IllegalArgumentException("shell is empty but holes are not");
-		}
-		shell=newShell;
-	}
-
-	if (newHoles==nullptr)
-	{
-		holes=new vector<Geometry *>();
-	}
-	else
-	{
-		if (hasNullElements(newHoles)) {
-			throw util::IllegalArgumentException("holes must not contain null elements");
-		}
-		for (size_t i=0; i<newHoles->size(); i++)
-			if ( (*newHoles)[i]->getGeometryTypeId() != GEOS_LINEARRING)
-				throw util::IllegalArgumentException("holes must be LinearRings");
-		holes=newHoles;
-	}
+Polygon::Polygon(LinearRing* newShell, vector<Geometry*>* newHoles,
+                 const GeometryFactory* newFactory):
+    Geometry(newFactory)
+{
+    if(newShell == nullptr) {
+        shell = getFactory()->createLinearRing(nullptr);
+    }
+    else {
+        if(newHoles != nullptr && newShell->isEmpty() && hasNonEmptyElements(newHoles)) {
+            throw util::IllegalArgumentException("shell is empty but holes are not");
+        }
+        shell = newShell;
+    }
+
+    if(newHoles == nullptr) {
+        holes = new vector<Geometry*>();
+    }
+    else {
+        if(hasNullElements(newHoles)) {
+            throw util::IllegalArgumentException("holes must not contain null elements");
+        }
+        for(size_t i = 0; i < newHoles->size(); i++)
+            if((*newHoles)[i]->getGeometryTypeId() != GEOS_LINEARRING) {
+                throw util::IllegalArgumentException("holes must be LinearRings");
+            }
+        holes = newHoles;
+    }
 }
 
 CoordinateSequence*
 Polygon::getCoordinates() const
 {
-	if (isEmpty()) {
-		return getFactory()->getCoordinateSequenceFactory()->create();
-	}
+    if(isEmpty()) {
+        return getFactory()->getCoordinateSequenceFactory()->create();
+    }
 
-	vector<Coordinate> *cl = new vector<Coordinate>;
+    vector<Coordinate>* cl = new vector<Coordinate>;
 
-	// reserve space in the vector for all the polygon points
-	cl->reserve(getNumPoints());
+    // reserve space in the vector for all the polygon points
+    cl->reserve(getNumPoints());
 
-	// Add shell points
-	const CoordinateSequence* shellCoords=shell->getCoordinatesRO();
-	shellCoords->toVector(*cl);
+    // Add shell points
+    const CoordinateSequence* shellCoords = shell->getCoordinatesRO();
+    shellCoords->toVector(*cl);
 
-	// Add holes points
-	size_t nholes=holes->size();
-	for (size_t i=0; i<nholes; ++i)
-	{
-		const LinearRing* lr = dynamic_cast<const LinearRing *>((*holes)[i]);
-		const CoordinateSequence* childCoords = lr->getCoordinatesRO();
-		childCoords->toVector(*cl);
-	}
+    // Add holes points
+    size_t nholes = holes->size();
+    for(size_t i = 0; i < nholes; ++i) {
+        const LinearRing* lr = dynamic_cast<const LinearRing*>((*holes)[i]);
+        const CoordinateSequence* childCoords = lr->getCoordinatesRO();
+        childCoords->toVector(*cl);
+    }
 
-	return getFactory()->getCoordinateSequenceFactory()->create(cl);
+    return getFactory()->getCoordinateSequenceFactory()->create(cl);
 }
 
 size_t
 Polygon::getNumPoints() const
 {
-	size_t numPoints = shell->getNumPoints();
-	for(size_t i=0, n=holes->size(); i<n; ++i)
-	{
-		const LinearRing* lr = dynamic_cast<const LinearRing *>((*holes)[i]);
-		numPoints += lr->getNumPoints();
-	}
-	return numPoints;
+    size_t numPoints = shell->getNumPoints();
+    for(size_t i = 0, n = holes->size(); i < n; ++i) {
+        const LinearRing* lr = dynamic_cast<const LinearRing*>((*holes)[i]);
+        numPoints += lr->getNumPoints();
+    }
+    return numPoints;
 }
 
 Dimension::DimensionType
 Polygon::getDimension() const
 {
-	return Dimension::A; // area
+    return Dimension::A; // area
 }
 
 int
 Polygon::getCoordinateDimension() const
 {
-	int dimension=2;
+    int dimension = 2;
 
-	if( shell != nullptr )
-		dimension = max(dimension,shell->getCoordinateDimension());
+    if(shell != nullptr) {
+        dimension = max(dimension, shell->getCoordinateDimension());
+    }
 
-	size_t nholes=holes->size();
-	for (size_t i=0; i<nholes; ++i)
-	{
-        dimension = max(dimension,(*holes)[i]->getCoordinateDimension());
-	}
+    size_t nholes = holes->size();
+    for(size_t i = 0; i < nholes; ++i) {
+        dimension = max(dimension, (*holes)[i]->getCoordinateDimension());
+    }
 
-	return dimension;
+    return dimension;
 }
 
 int
 Polygon::getBoundaryDimension() const
 {
-	return 1;
+    return 1;
 }
 
 bool
 Polygon::isEmpty() const
 {
-	return shell->isEmpty();
+    return shell->isEmpty();
 }
 
 const LineString*
 Polygon::getExteriorRing() const
 {
-	return shell;
+    return shell;
 }
 
 size_t
 Polygon::getNumInteriorRing() const
 {
-	return holes->size();
+    return holes->size();
 }
 
 const LineString*
 Polygon::getInteriorRingN(size_t n) const
 {
-  const LinearRing* lr = dynamic_cast<const LinearRing *>((*holes)[n]);
-	return lr;
+    const LinearRing* lr = dynamic_cast<const LinearRing*>((*holes)[n]);
+    return lr;
 }
 
 string
 Polygon::getGeometryType() const
 {
-	return "Polygon";
+    return "Polygon";
 }
 
 // Returns a newly allocated Geometry object
@@ -206,129 +201,124 @@ Polygon::getGeometryType() const
 Geometry*
 Polygon::getBoundary() const
 {
-	/*
-	 * We will make sure that what we
-	 * return is composed of LineString,
-	 * not LinearRings
-	 */
+    /*
+     * We will make sure that what we
+     * return is composed of LineString,
+     * not LinearRings
+     */
 
-	const GeometryFactory* gf = getFactory();
+    const GeometryFactory* gf = getFactory();
 
-	if (isEmpty()) {
-		return gf->createMultiLineString();
-	}
+    if(isEmpty()) {
+        return gf->createMultiLineString();
+    }
 
-	if ( ! holes->size() )
-	{
-		return gf->createLineString(*shell).release();
-	}
+    if(! holes->size()) {
+        return gf->createLineString(*shell).release();
+    }
 
-	vector<Geometry *> *rings = new vector<Geometry *>(holes->size()+1);
+    vector<Geometry*>* rings = new vector<Geometry*>(holes->size() + 1);
 
-	(*rings)[0] = gf->createLineString(*shell).release();
-	for(size_t i=0, n=holes->size(); i<n; ++i)
-	{
-		const LinearRing* hole = dynamic_cast<const LinearRing *>((*holes)[i]);
-		assert( hole );
-		LineString* ls = gf->createLineString( *hole ).release();
-		(*rings)[i + 1] = ls;
-	}
-	MultiLineString *ret = getFactory()->createMultiLineString(rings);
-	return ret;
+    (*rings)[0] = gf->createLineString(*shell).release();
+    for(size_t i = 0, n = holes->size(); i < n; ++i) {
+        const LinearRing* hole = dynamic_cast<const LinearRing*>((*holes)[i]);
+        assert(hole);
+        LineString* ls = gf->createLineString(*hole).release();
+        (*rings)[i + 1] = ls;
+    }
+    MultiLineString* ret = getFactory()->createMultiLineString(rings);
+    return ret;
 }
 
 Envelope::Ptr
 Polygon::computeEnvelopeInternal() const
 {
-	return Envelope::Ptr(new Envelope(*(shell->getEnvelopeInternal())));
+    return Envelope::Ptr(new Envelope(*(shell->getEnvelopeInternal())));
 }
 
 bool
-Polygon::equalsExact(const Geometry *other, double tolerance) const
+Polygon::equalsExact(const Geometry* other, double tolerance) const
 {
-	const Polygon* otherPolygon=dynamic_cast<const Polygon*>(other);
-	if ( ! otherPolygon ) return false;
+    const Polygon* otherPolygon = dynamic_cast<const Polygon*>(other);
+    if(! otherPolygon) {
+        return false;
+    }
 
-	if (!shell->equalsExact(otherPolygon->shell, tolerance)) {
-		return false;
-	}
+    if(!shell->equalsExact(otherPolygon->shell, tolerance)) {
+        return false;
+    }
 
-	size_t nholes = holes->size();
+    size_t nholes = holes->size();
 
-	if (nholes != otherPolygon->holes->size()) {
-		return false;
-	}
+    if(nholes != otherPolygon->holes->size()) {
+        return false;
+    }
 
-	for (size_t i=0; i<nholes; i++)
-	{
-		const Geometry* hole=(*holes)[i];
-		const Geometry* otherhole=(*(otherPolygon->holes))[i];
-		if (!hole->equalsExact(otherhole, tolerance))
-		{
-			return false;
-		}
-	}
+    for(size_t i = 0; i < nholes; i++) {
+        const Geometry* hole = (*holes)[i];
+        const Geometry* otherhole = (*(otherPolygon->holes))[i];
+        if(!hole->equalsExact(otherhole, tolerance)) {
+            return false;
+        }
+    }
 
-	return true;
+    return true;
 }
 
 void
-Polygon::apply_ro(CoordinateFilter *filter) const
+Polygon::apply_ro(CoordinateFilter* filter) const
 {
-	shell->apply_ro(filter);
-	for(size_t i=0, n=holes->size(); i<n; ++i)
-	{
-		const LinearRing* lr = dynamic_cast<const LinearRing *>((*holes)[i]);
-		lr->apply_ro(filter);
-	}
+    shell->apply_ro(filter);
+    for(size_t i = 0, n = holes->size(); i < n; ++i) {
+        const LinearRing* lr = dynamic_cast<const LinearRing*>((*holes)[i]);
+        lr->apply_ro(filter);
+    }
 }
 
 void
-Polygon::apply_rw(const CoordinateFilter *filter)
+Polygon::apply_rw(const CoordinateFilter* filter)
 {
-	shell->apply_rw(filter);
-	for(size_t i=0, n=holes->size(); i<n; ++i)
-	{
-		LinearRing* lr = dynamic_cast<LinearRing *>((*holes)[i]);
-		lr->apply_rw(filter);
-	}
+    shell->apply_rw(filter);
+    for(size_t i = 0, n = holes->size(); i < n; ++i) {
+        LinearRing* lr = dynamic_cast<LinearRing*>((*holes)[i]);
+        lr->apply_rw(filter);
+    }
 }
 
 void
-Polygon::apply_rw(GeometryFilter *filter)
+Polygon::apply_rw(GeometryFilter* filter)
 {
-	filter->filter_rw(this);
+    filter->filter_rw(this);
 }
 
 void
-Polygon::apply_ro(GeometryFilter *filter) const
+Polygon::apply_ro(GeometryFilter* filter) const
 {
-	filter->filter_ro(this);
+    filter->filter_ro(this);
 }
 
 Geometry*
 Polygon::convexHull() const
 {
-	return getExteriorRing()->convexHull();
+    return getExteriorRing()->convexHull();
 }
 
 void
 Polygon::normalize()
 {
-	normalize(shell, true);
-	for(size_t i=0, n=holes->size(); i<n; ++i)
-	{
-		LinearRing* lr = dynamic_cast<LinearRing *>((*holes)[i]);
-		normalize(lr, false);
-	}
-	sort(holes->begin(), holes->end(), GeometryGreaterThen());
+    normalize(shell, true);
+    for(size_t i = 0, n = holes->size(); i < n; ++i) {
+        LinearRing* lr = dynamic_cast<LinearRing*>((*holes)[i]);
+        normalize(lr, false);
+    }
+    sort(holes->begin(), holes->end(), GeometryGreaterThen());
 }
 
 int
-Polygon::compareToSameClass(const Geometry *g) const
+Polygon::compareToSameClass(const Geometry* g) const
 {
-	const Polygon* p = dynamic_cast<const Polygon*>(g);
-	return shell->compareToSameClass(p->shell);
+    const Polygon* p = dynamic_cast<const Polygon*>(g);
+    return shell->compareToSameClass(p->shell);
 }
 
 /*
@@ -336,27 +326,27 @@ Polygon::compareToSameClass(const Geometry *g) const
  *       reduction possibility.
  */
 void
-Polygon::normalize(LinearRing *ring, bool clockwise)
-{
-	if (ring->isEmpty()) {
-		return;
-	}
-	CoordinateSequence* uniqueCoordinates = ring->getCoordinates();
-	uniqueCoordinates->deleteAt(uniqueCoordinates->getSize()-1);
-	const Coordinate* minCoordinate = CoordinateSequence::minCoordinate(uniqueCoordinates);
-	CoordinateSequence::scroll(uniqueCoordinates, minCoordinate);
-	uniqueCoordinates->add(uniqueCoordinates->getAt(0));
-	if (algorithm::Orientation::isCCW(uniqueCoordinates) == clockwise) {
-		CoordinateSequence::reverse(uniqueCoordinates);
-	}
-	ring->setPoints(uniqueCoordinates);
-	delete(uniqueCoordinates);
+Polygon::normalize(LinearRing* ring, bool clockwise)
+{
+    if(ring->isEmpty()) {
+        return;
+    }
+    CoordinateSequence* uniqueCoordinates = ring->getCoordinates();
+    uniqueCoordinates->deleteAt(uniqueCoordinates->getSize() - 1);
+    const Coordinate* minCoordinate = CoordinateSequence::minCoordinate(uniqueCoordinates);
+    CoordinateSequence::scroll(uniqueCoordinates, minCoordinate);
+    uniqueCoordinates->add(uniqueCoordinates->getAt(0));
+    if(algorithm::Orientation::isCCW(uniqueCoordinates) == clockwise) {
+        CoordinateSequence::reverse(uniqueCoordinates);
+    }
+    ring->setPoints(uniqueCoordinates);
+    delete(uniqueCoordinates);
 }
 
 const Coordinate*
 Polygon::getCoordinate() const
 {
-	return shell->getCoordinate();
+    return shell->getCoordinate();
 }
 
 /*
@@ -367,15 +357,14 @@ Polygon::getCoordinate() const
 double
 Polygon::getArea() const
 {
-	double area = 0.0;
-	area += fabs(algorithm::Area::ofRing(shell->getCoordinatesRO()));
-	for(size_t i=0, n=holes->size(); i<n; ++i)
-	{
-		const LinearRing *lr = dynamic_cast<const LinearRing *>((*holes)[i]);
-		const CoordinateSequence *h = lr->getCoordinatesRO();
-    	area -= fabs(algorithm::Area::ofRing(h));
-	}
-	return area;
+    double area = 0.0;
+    area += fabs(algorithm::Area::ofRing(shell->getCoordinatesRO()));
+    for(size_t i = 0, n = holes->size(); i < n; ++i) {
+        const LinearRing* lr = dynamic_cast<const LinearRing*>((*holes)[i]);
+        const CoordinateSequence* h = lr->getCoordinatesRO();
+        area -= fabs(algorithm::Area::ofRing(h));
+    }
+    return area;
 }
 
 /**
@@ -386,138 +375,144 @@ Polygon::getArea() const
 double
 Polygon::getLength() const
 {
-	double len=0.0;
-	len+=shell->getLength();
-	for(size_t i=0, n=holes->size(); i<n; ++i)
-	{
-		len+=(*holes)[i]->getLength();
-	}
-	return len;
+    double len = 0.0;
+    len += shell->getLength();
+    for(size_t i = 0, n = holes->size(); i < n; ++i) {
+        len += (*holes)[i]->getLength();
+    }
+    return len;
 }
 
 void
-Polygon::apply_ro(GeometryComponentFilter *filter) const
+Polygon::apply_ro(GeometryComponentFilter* filter) const
 {
-	filter->filter_ro(this);
-	shell->apply_ro(filter);
-	for(size_t i=0, n=holes->size(); i<n; ++i)
-	{
-        	(*holes)[i]->apply_ro(filter);
-	}
+    filter->filter_ro(this);
+    shell->apply_ro(filter);
+    for(size_t i = 0, n = holes->size(); i < n; ++i) {
+        (*holes)[i]->apply_ro(filter);
+    }
 }
 
 void
-Polygon::apply_rw(GeometryComponentFilter *filter)
+Polygon::apply_rw(GeometryComponentFilter* filter)
 {
-	filter->filter_rw(this);
-	shell->apply_rw(filter);
-	for(size_t i=0, n=holes->size(); i<n; ++i)
-	{
-        	(*holes)[i]->apply_rw(filter);
-	}
+    filter->filter_rw(this);
+    shell->apply_rw(filter);
+    for(size_t i = 0, n = holes->size(); i < n; ++i) {
+        (*holes)[i]->apply_rw(filter);
+    }
 }
 
 void
 Polygon::apply_rw(CoordinateSequenceFilter& filter)
 {
-	shell->apply_rw(filter);
+    shell->apply_rw(filter);
 
-	if (! filter.isDone())
-	{
-		for (size_t i=0, n=holes->size(); i<n; ++i)
-		{
-			(*holes)[i]->apply_rw(filter);
-			if (filter.isDone())
-			break;
-        	}
-	}
-	if (filter.isGeometryChanged()) geometryChanged();
+    if(! filter.isDone()) {
+        for(size_t i = 0, n = holes->size(); i < n; ++i) {
+            (*holes)[i]->apply_rw(filter);
+            if(filter.isDone()) {
+                break;
+            }
+        }
+    }
+    if(filter.isGeometryChanged()) {
+        geometryChanged();
+    }
 }
 
 void
 Polygon::apply_ro(CoordinateSequenceFilter& filter) const
 {
-	shell->apply_ro(filter);
+    shell->apply_ro(filter);
 
-	if (! filter.isDone())
-	{
-		for (size_t i=0, n=holes->size(); i<n; ++i)
-		{
-			(*holes)[i]->apply_ro(filter);
-			if (filter.isDone())
-			break;
-        	}
-	}
-	//if (filter.isGeometryChanged()) geometryChanged();
+    if(! filter.isDone()) {
+        for(size_t i = 0, n = holes->size(); i < n; ++i) {
+            (*holes)[i]->apply_ro(filter);
+            if(filter.isDone()) {
+                break;
+            }
+        }
+    }
+    //if (filter.isGeometryChanged()) geometryChanged();
 }
 
 Polygon::~Polygon()
 {
-	delete shell;
-	for(size_t i=0, n=holes->size(); i<n; ++i)
-	{
-		delete (*holes)[i];
-	}
-	delete holes;
+    delete shell;
+    for(size_t i = 0, n = holes->size(); i < n; ++i) {
+        delete(*holes)[i];
+    }
+    delete holes;
 }
 
 GeometryTypeId
 Polygon::getGeometryTypeId() const
 {
-	return GEOS_POLYGON;
+    return GEOS_POLYGON;
 }
 
 bool
 Polygon::isRectangle() const
 {
-	if ( getNumInteriorRing() != 0 ) return false;
-	assert(shell!=nullptr);
-	if ( shell->getNumPoints() != 5 ) return false;
-
-	const CoordinateSequence &seq = *(shell->getCoordinatesRO());
-
-	// check vertices have correct values
-	const Envelope &env = *getEnvelopeInternal();
-	for (int i=0; i<5; i++) {
-		double x = seq.getX(i);
-		if (! (x == env.getMinX() || x == env.getMaxX())) return false;
-		double y = seq.getY(i);
-		if (! (y == env.getMinY() || y == env.getMaxY())) return false;
-	}
-
-	// check vertices are in right order
-	double prevX = seq.getX(0);
-	double prevY = seq.getY(0);
-	for (int i = 1; i <= 4; i++) {
-		double x = seq.getX(i);
-		double y = seq.getY(i);
-		bool xChanged = (x != prevX);
-		bool yChanged = (y != prevY);
-		if (xChanged == yChanged) return false;
-		prevX = x;
-		prevY = y;
-	}
-	return true;
+    if(getNumInteriorRing() != 0) {
+        return false;
+    }
+    assert(shell != nullptr);
+    if(shell->getNumPoints() != 5) {
+        return false;
+    }
+
+    const CoordinateSequence& seq = *(shell->getCoordinatesRO());
+
+    // check vertices have correct values
+    const Envelope& env = *getEnvelopeInternal();
+    for(int i = 0; i < 5; i++) {
+        double x = seq.getX(i);
+        if(!(x == env.getMinX() || x == env.getMaxX())) {
+            return false;
+        }
+        double y = seq.getY(i);
+        if(!(y == env.getMinY() || y == env.getMaxY())) {
+            return false;
+        }
+    }
+
+    // check vertices are in right order
+    double prevX = seq.getX(0);
+    double prevY = seq.getY(0);
+    for(int i = 1; i <= 4; i++) {
+        double x = seq.getX(i);
+        double y = seq.getY(i);
+        bool xChanged = (x != prevX);
+        bool yChanged = (y != prevY);
+        if(xChanged == yChanged) {
+            return false;
+        }
+        prevX = x;
+        prevY = y;
+    }
+    return true;
 }
 
 Geometry*
 Polygon::reverse() const
 {
-	if (isEmpty()) {
-		return clone();
-	}
+    if(isEmpty()) {
+        return clone();
+    }
 
-	auto* exteriorRingReversed = dynamic_cast<LinearRing*>(shell->reverse());
-	auto* interiorRingsReversed = new std::vector<Geometry*>{holes->size()};
+    auto* exteriorRingReversed = dynamic_cast<LinearRing*>(shell->reverse());
+    auto* interiorRingsReversed = new std::vector<Geometry*> {holes->size()};
 
-	std::transform(holes->begin(),
-				   holes->end(),
-				   interiorRingsReversed->begin(),
-				   [](const Geometry * g) {
-		             return g->reverse();
-	});
+    std::transform(holes->begin(),
+                   holes->end(),
+                   interiorRingsReversed->begin(),
+    [](const Geometry * g) {
+        return g->reverse();
+    });
 
-	return getFactory()->createPolygon(exteriorRingReversed, interiorRingsReversed);
+    return getFactory()->createPolygon(exteriorRingReversed, interiorRingsReversed);
 }
 
 } // namespace geos::geom
diff --git a/src/geom/PrecisionModel.cpp b/src/geom/PrecisionModel.cpp
index 6ffcec3..d801e88 100644
--- a/src/geom/PrecisionModel.cpp
+++ b/src/geom/PrecisionModel.cpp
@@ -41,23 +41,23 @@ using namespace std;
 namespace geos {
 namespace geom { // geos::geom
 
-const double PrecisionModel::maximumPreciseValue=9007199254740992.0;
+const double PrecisionModel::maximumPreciseValue = 9007199254740992.0;
 
 /*public*/
 double
 PrecisionModel::makePrecise(double val) const
 {
 #if GEOS_DEBUG
-    cerr<<"PrecisionModel["<<this<<"]::makePrecise called"<<endl;
+    cerr << "PrecisionModel[" << this << "]::makePrecise called" << endl;
 #endif
 
-    if (modelType==FLOATING_SINGLE) {
+    if(modelType == FLOATING_SINGLE) {
         float floatSingleVal = static_cast<float>(val);
         return static_cast<double>(floatSingleVal);
     }
-    if (modelType == FIXED) {
+    if(modelType == FIXED) {
         // Use whatever happens to be the default rounding method
-        const double ret = util::round(val*scale)/scale;
+        const double ret = util::round(val * scale) / scale;
         return ret;
     }
     // modelType == FLOATING - no rounding necessary
@@ -68,79 +68,81 @@ PrecisionModel::makePrecise(double val) const
 void
 PrecisionModel::makePrecise(Coordinate& coord) const
 {
-	// optimization for full precision
-	if (modelType==FLOATING) return;
+    // optimization for full precision
+    if(modelType == FLOATING) {
+        return;
+    }
 
-	coord.x=makePrecise(coord.x);
-	coord.y=makePrecise(coord.y);
+    coord.x = makePrecise(coord.x);
+    coord.y = makePrecise(coord.y);
 }
 
 
 /*public*/
 PrecisionModel::PrecisionModel()
-	:
-	modelType(FLOATING),
-	scale(0.0)
+    :
+    modelType(FLOATING),
+    scale(0.0)
 {
 #if GEOS_DEBUG
-	cerr<<"PrecisionModel["<<this<<"] ctor()"<<endl;
+    cerr << "PrecisionModel[" << this << "] ctor()" << endl;
 #endif
-	//modelType=FLOATING;
-	//scale=1.0;
+    //modelType=FLOATING;
+    //scale=1.0;
 }
 
 /*public*/
 PrecisionModel::PrecisionModel(Type nModelType)
-	:
-	modelType(nModelType),
-	scale(1.0)
+    :
+    modelType(nModelType),
+    scale(1.0)
 {
 #if GEOS_DEBUG
-	cerr<<"PrecisionModel["<<this<<"] ctor(Type)"<<endl;
+    cerr << "PrecisionModel[" << this << "] ctor(Type)" << endl;
 #endif
-	//modelType=nModelType;
-	//if (modelType==FIXED) setScale(1.0);
-	//else setScale(666); // arbitrary number for invariant testing
+    //modelType=nModelType;
+    //if (modelType==FIXED) setScale(1.0);
+    //else setScale(666); // arbitrary number for invariant testing
 }
 
 
 /*public (deprecated) */
 PrecisionModel::PrecisionModel(double newScale, double newOffsetX, double newOffsetY)
-		//throw(IllegalArgumentException *)
-	:
-	modelType(FIXED)
+//throw(IllegalArgumentException *)
+    :
+    modelType(FIXED)
 {
     ::geos::ignore_unused_variable_warning(newOffsetX);
     ::geos::ignore_unused_variable_warning(newOffsetY);
 
 #if GEOS_DEBUG
-	cerr<<"PrecisionModel["<<this<<"] ctor(scale,offsets)"<<endl;
+    cerr << "PrecisionModel[" << this << "] ctor(scale,offsets)" << endl;
 #endif
 
-	//modelType = FIXED;
-	setScale(newScale);
+    //modelType = FIXED;
+    setScale(newScale);
 }
 
 /*public*/
 PrecisionModel::PrecisionModel(double newScale)
-		//throw (IllegalArgumentException *)
-	:
-	modelType(FIXED)
+//throw (IllegalArgumentException *)
+    :
+    modelType(FIXED)
 {
 #if GEOS_DEBUG
-	cerr<<"PrecisionModel["<<this<<"] ctor(scale)"<<endl;
+    cerr << "PrecisionModel[" << this << "] ctor(scale)" << endl;
 #endif
-	setScale(newScale);
+    setScale(newScale);
 }
 
 
-PrecisionModel::PrecisionModel(const PrecisionModel &pm)
-	:
-	modelType(pm.modelType),
-	scale(pm.scale)
+PrecisionModel::PrecisionModel(const PrecisionModel& pm)
+    :
+    modelType(pm.modelType),
+    scale(pm.scale)
 {
 #if GEOS_DEBUG
-	cerr<<"PrecisionModel["<<this<<"] ctor(pm["<< &pm <<"])"<<endl;
+    cerr << "PrecisionModel[" << this << "] ctor(pm[" << &pm << "])" << endl;
 #endif
 }
 
@@ -148,38 +150,41 @@ PrecisionModel::PrecisionModel(const PrecisionModel &pm)
 bool
 PrecisionModel::isFloating() const
 {
-	return (modelType == FLOATING || modelType == FLOATING_SINGLE);
+    return (modelType == FLOATING || modelType == FLOATING_SINGLE);
 }
 
 /*public*/
 int
 PrecisionModel::getMaximumSignificantDigits() const
 {
-	int maxSigDigits = 16;
-	if (modelType == FLOATING) {
-		maxSigDigits = 16;
-	} else if (modelType == FLOATING_SINGLE) {
-		maxSigDigits = 6;
-	} else if (modelType == FIXED) {
-
-		double dgtsd = std::log(getScale()) / std::log(double(10.0));
-		const int dgts = static_cast<int>(
-			dgtsd > 0 ? std::ceil(dgtsd)
-			          : std::floor(dgtsd)
-		);
-		maxSigDigits = dgts;
-	}
-	return maxSigDigits;
+    int maxSigDigits = 16;
+    if(modelType == FLOATING) {
+        maxSigDigits = 16;
+    }
+    else if(modelType == FLOATING_SINGLE) {
+        maxSigDigits = 6;
+    }
+    else if(modelType == FIXED) {
+
+        double dgtsd = std::log(getScale()) / std::log(double(10.0));
+        const int dgts = static_cast<int>(
+                             dgtsd > 0 ? std::ceil(dgtsd)
+                             : std::floor(dgtsd)
+                         );
+        maxSigDigits = dgts;
+    }
+    return maxSigDigits;
 }
 
 
 /*private*/
 void
 PrecisionModel::setScale(double newScale)
-		// throw IllegalArgumentException
+// throw IllegalArgumentException
 {
-	if ( newScale <= 0 )
-		throw util::IllegalArgumentException("PrecisionModel scale cannot be 0");
+    if(newScale <= 0) {
+        throw util::IllegalArgumentException("PrecisionModel scale cannot be 0");
+    }
     scale = std::fabs(newScale);
 }
 
@@ -187,48 +192,53 @@ PrecisionModel::setScale(double newScale)
 double
 PrecisionModel::getOffsetX() const
 {
-	return 0;
+    return 0;
 }
 
 /*public*/
 double
 PrecisionModel::getOffsetY() const
 {
-	return 0;
+    return 0;
 }
 
 
 string
 PrecisionModel::toString() const
 {
-	ostringstream s;
-  	if (modelType == FLOATING) {
-  		s<<"Floating";
-  	} else if (modelType == FLOATING_SINGLE) {
-  		s<<"Floating-Single";
-  	} else if (modelType == FIXED) {
-		s <<"Fixed (Scale=" << getScale()
-		  << " OffsetX=" << getOffsetX()
-		  << " OffsetY=" << getOffsetY()
-		  << ")";
-	} else {
-		s<<"UNKNOWN";
-	}
-	return s.str();
+    ostringstream s;
+    if(modelType == FLOATING) {
+        s << "Floating";
+    }
+    else if(modelType == FLOATING_SINGLE) {
+        s << "Floating-Single";
+    }
+    else if(modelType == FIXED) {
+        s << "Fixed (Scale=" << getScale()
+          << " OffsetX=" << getOffsetX()
+          << " OffsetY=" << getOffsetY()
+          << ")";
+    }
+    else {
+        s << "UNKNOWN";
+    }
+    return s.str();
 }
 
-bool operator==(const PrecisionModel& a, const PrecisionModel& b) {
-	return a.isFloating() == b.isFloating() &&
-			a.getScale() == b.getScale();
+bool
+operator==(const PrecisionModel& a, const PrecisionModel& b)
+{
+    return a.isFloating() == b.isFloating() &&
+           a.getScale() == b.getScale();
 }
 
 /*public*/
 int
-PrecisionModel::compareTo(const PrecisionModel *other) const
+PrecisionModel::compareTo(const PrecisionModel* other) const
 {
-	int sigDigits=getMaximumSignificantDigits();
-	int otherSigDigits=other->getMaximumSignificantDigits();
-	return sigDigits<otherSigDigits? -1: (sigDigits==otherSigDigits? 0:1);
+    int sigDigits = getMaximumSignificantDigits();
+    int otherSigDigits = other->getMaximumSignificantDigits();
+    return sigDigits < otherSigDigits ? -1 : (sigDigits == otherSigDigits ? 0 : 1);
 }
 
 } // namespace geos::geom
diff --git a/src/geom/Triangle.cpp b/src/geom/Triangle.cpp
index 4a9685c..6552745 100644
--- a/src/geom/Triangle.cpp
+++ b/src/geom/Triangle.cpp
@@ -22,34 +22,35 @@ namespace geom { // geos::geom
 void
 Triangle::inCentre(Coordinate& result)
 {
-	// the lengths of the sides, labelled by their opposite vertex
-	double len0 = p1.distance(p2);
-	double len1 = p0.distance(p2);
-	double len2 = p0.distance(p1);
-	double circum = len0 + len1 + len2;
-	double inCentreX = (len0 * p0.x + len1 * p1.x +len2 * p2.x)  / circum;
-	double inCentreY = (len0 * p0.y + len1 * p1.y +len2 * p2.y)  / circum;
+    // the lengths of the sides, labelled by their opposite vertex
+    double len0 = p1.distance(p2);
+    double len1 = p0.distance(p2);
+    double len2 = p0.distance(p1);
+    double circum = len0 + len1 + len2;
+    double inCentreX = (len0 * p0.x + len1 * p1.x + len2 * p2.x)  / circum;
+    double inCentreY = (len0 * p0.y + len1 * p1.y + len2 * p2.y)  / circum;
 
-	result = Coordinate(inCentreX, inCentreY);
+    result = Coordinate(inCentreX, inCentreY);
 }
 
-void Triangle::circumcentre(Coordinate& result)
+void
+Triangle::circumcentre(Coordinate& result)
 {
-	double cx = p2.x;
-	double cy = p2.y;
-	double ax = p0.x - cx;
-	double ay = p0.y - cy;
-	double bx = p1.x - cx;
-	double by = p1.y - cy;
+    double cx = p2.x;
+    double cy = p2.y;
+    double ax = p0.x - cx;
+    double ay = p0.y - cy;
+    double bx = p1.x - cx;
+    double by = p1.y - cy;
 
-	double denom = 2 * det(ax,ay,bx,by);
-	double numx = det(ay , ax * ax + ay * ay , by , bx * bx + by * by);
-	double numy = det(ax, ax * ax + ay * ay, bx, bx * bx + by * by);
+    double denom = 2 * det(ax, ay, bx, by);
+    double numx = det(ay, ax * ax + ay * ay, by, bx * bx + by * by);
+    double numy = det(ax, ax * ax + ay * ay, bx, bx * bx + by * by);
 
-	double ccx = cx - numx / denom;
-	double ccy = cy + numy / denom;
+    double ccx = cx - numx / denom;
+    double ccy = cy + numy / denom;
 
-	result = Coordinate(ccx,ccy);
+    result = Coordinate(ccx, ccy);
 }
 
 /* public static */
@@ -63,9 +64,10 @@ Triangle::circumcentre(const Coordinate& p0, const Coordinate& p1, const Coordin
 }
 
 
-double Triangle::det(double m00 , double m01 , double m10 , double m11) const
+double
+Triangle::det(double m00, double m01, double m10, double m11) const
 {
-	return m00 * m11 - m01 * m10;
+    return m00 * m11 - m01 * m10;
 }
 
 
diff --git a/src/geom/prep/AbstractPreparedPolygonContains.cpp b/src/geom/prep/AbstractPreparedPolygonContains.cpp
index e74cb83..49bfe6f 100644
--- a/src/geom/prep/AbstractPreparedPolygonContains.cpp
+++ b/src/geom/prep/AbstractPreparedPolygonContains.cpp
@@ -36,68 +36,68 @@ namespace prep { // geos::geom::prep
 // private:
 //
 bool
-AbstractPreparedPolygonContains::isProperIntersectionImpliesNotContainedSituation( const geom::Geometry * testGeom)
+AbstractPreparedPolygonContains::isProperIntersectionImpliesNotContainedSituation(const geom::Geometry* testGeom)
 {
-	// If the test geometry is polygonal we have the A/A situation.
-	// In this case, a proper intersection indicates that
-	// the Epsilon-Neighbourhood Exterior Intersection condition exists.
-	// This condition means that in some small
-	// area around the intersection point, there must exist a situation
-	// where the interior of the test intersects the exterior of the target.
-	// This implies the test is NOT contained in the target.
-	if (	testGeom->getGeometryTypeId() == geos::geom::GEOS_MULTIPOLYGON
-		||	testGeom->getGeometryTypeId() == geos::geom::GEOS_POLYGON )
-		return true;
-
-	// A single shell with no holes allows concluding that
-	// a proper intersection implies not contained
-	// (due to the Epsilon-Neighbourhood Exterior Intersection condition)
-	if ( isSingleShell( prepPoly->getGeometry()) )
-		return true;
-
-	return false;
+    // If the test geometry is polygonal we have the A/A situation.
+    // In this case, a proper intersection indicates that
+    // the Epsilon-Neighbourhood Exterior Intersection condition exists.
+    // This condition means that in some small
+    // area around the intersection point, there must exist a situation
+    // where the interior of the test intersects the exterior of the target.
+    // This implies the test is NOT contained in the target.
+    if(testGeom->getGeometryTypeId() == geos::geom::GEOS_MULTIPOLYGON
+            ||	testGeom->getGeometryTypeId() == geos::geom::GEOS_POLYGON) {
+        return true;
+    }
+
+    // A single shell with no holes allows concluding that
+    // a proper intersection implies not contained
+    // (due to the Epsilon-Neighbourhood Exterior Intersection condition)
+    if(isSingleShell(prepPoly->getGeometry())) {
+        return true;
+    }
+
+    return false;
 }
 
 
 bool
 AbstractPreparedPolygonContains::isSingleShell(const geom::Geometry& geom)
 {
-	// handles single-element MultiPolygons, as well as Polygons
-	if (geom.getNumGeometries() != 1)
-    {
-		return false;
+    // handles single-element MultiPolygons, as well as Polygons
+    if(geom.getNumGeometries() != 1) {
+        return false;
     }
 
-  const geom::Geometry* g = geom.getGeometryN(0);
-  const geom::Polygon* poly = dynamic_cast<const Polygon*>(g);
-  assert(poly);
+    const geom::Geometry* g = geom.getGeometryN(0);
+    const geom::Polygon* poly = dynamic_cast<const Polygon*>(g);
+    assert(poly);
 
-  std::size_t numHoles = poly->getNumInteriorRing();
-  return (0 == numHoles);
+    std::size_t numHoles = poly->getNumInteriorRing();
+    return (0 == numHoles);
 }
 
 
 void
 AbstractPreparedPolygonContains::findAndClassifyIntersections(const geom::Geometry* geom)
 {
-	noding::SegmentString::ConstVect lineSegStr;
-	noding::SegmentStringUtil::extractSegmentStrings(geom, lineSegStr);
+    noding::SegmentString::ConstVect lineSegStr;
+    noding::SegmentStringUtil::extractSegmentStrings(geom, lineSegStr);
 
-	algorithm::LineIntersector li;
+    algorithm::LineIntersector li;
 
-	noding::SegmentIntersectionDetector intDetector(&li);
+    noding::SegmentIntersectionDetector intDetector(&li);
 
-	intDetector.setFindAllIntersectionTypes(true);
-	prepPoly->getIntersectionFinder()->intersects(&lineSegStr, &intDetector);
+    intDetector.setFindAllIntersectionTypes(true);
+    prepPoly->getIntersectionFinder()->intersects(&lineSegStr, &intDetector);
 
-	hasSegmentIntersection = intDetector.hasIntersection();
-	hasProperIntersection = intDetector.hasProperIntersection();
-	hasNonProperIntersection = intDetector.hasNonProperIntersection();
+    hasSegmentIntersection = intDetector.hasIntersection();
+    hasProperIntersection = intDetector.hasProperIntersection();
+    hasNonProperIntersection = intDetector.hasNonProperIntersection();
 
-	for (std::size_t i = 0, ni = lineSegStr.size(); i < ni; i++ )
-	{
-		delete lineSegStr[i];
-	}
+    for(std::size_t i = 0, ni = lineSegStr.size(); i < ni; i++) {
+        delete lineSegStr[i];
+    }
 }
 
 
@@ -105,83 +105,86 @@ AbstractPreparedPolygonContains::findAndClassifyIntersections(const geom::Geomet
 // protected:
 //
 bool
-AbstractPreparedPolygonContains::eval( const geom::Geometry * geom)
+AbstractPreparedPolygonContains::eval(const geom::Geometry* geom)
 {
-	// Do point-in-poly tests first, since they are cheaper and may result
-	// in a quick negative result.
-	//
-	// If a point of any test components does not lie in target,
-	// result is false
-	bool isAllInTargetArea = isAllTestComponentsInTarget( geom);
-	if ( !isAllInTargetArea )
-		return false;
-
-	// If the test geometry consists of only Points,
-	// then it is now sufficient to test if any of those
-	// points lie in the interior of the target geometry.
-	// If so, the test is contained.
-	// If not, all points are on the boundary of the area,
-	// which implies not contained.
-	if ( requireSomePointInInterior && geom->getDimension() == 0 )
-	{
-		bool isAnyInTargetInterior = isAnyTestComponentInTargetInterior( geom);
-		return isAnyInTargetInterior;
-	}
-
-	// Check if there is any intersection between the line segments
-	// in target and test.
-	// In some important cases, finding a proper interesection implies that the
-	// test geometry is NOT contained.
-	// These cases are:
-	// - If the test geometry is polygonal
-	// - If the target geometry is a single polygon with no holes
-	// In both of these cases, a proper intersection implies that there
-	// is some portion of the interior of the test geometry lying outside
-	// the target, which means that the test is not contained.
-	bool properIntersectionImpliesNotContained = isProperIntersectionImpliesNotContainedSituation( geom);
+    // Do point-in-poly tests first, since they are cheaper and may result
+    // in a quick negative result.
+    //
+    // If a point of any test components does not lie in target,
+    // result is false
+    bool isAllInTargetArea = isAllTestComponentsInTarget(geom);
+    if(!isAllInTargetArea) {
+        return false;
+    }
+
+    // If the test geometry consists of only Points,
+    // then it is now sufficient to test if any of those
+    // points lie in the interior of the target geometry.
+    // If so, the test is contained.
+    // If not, all points are on the boundary of the area,
+    // which implies not contained.
+    if(requireSomePointInInterior && geom->getDimension() == 0) {
+        bool isAnyInTargetInterior = isAnyTestComponentInTargetInterior(geom);
+        return isAnyInTargetInterior;
+    }
+
+    // Check if there is any intersection between the line segments
+    // in target and test.
+    // In some important cases, finding a proper interesection implies that the
+    // test geometry is NOT contained.
+    // These cases are:
+    // - If the test geometry is polygonal
+    // - If the target geometry is a single polygon with no holes
+    // In both of these cases, a proper intersection implies that there
+    // is some portion of the interior of the test geometry lying outside
+    // the target, which means that the test is not contained.
+    bool properIntersectionImpliesNotContained = isProperIntersectionImpliesNotContainedSituation(geom);
 
     // find all intersection types which exist
-    findAndClassifyIntersections( geom);
-
-	if ( properIntersectionImpliesNotContained && hasProperIntersection )
-		return false;
-
-	// If all intersections are proper
-	// (i.e. no non-proper intersections occur)
-	// we can conclude that the test geometry is not contained in the target area,
-	// by the Epsilon-Neighbourhood Exterior Intersection condition.
-	// In real-world data this is likely to be by far the most common situation,
-	// since natural data is unlikely to have many exact vertex segment intersections.
-	// Thus this check is very worthwhile, since it avoid having to perform
-	// a full topological check.
-	//
-	// (If non-proper (vertex) intersections ARE found, this may indicate
-	// a situation where two shells touch at a single vertex, which admits
-	// the case where a line could cross between the shells and still be wholely contained in them.
-	if ( hasSegmentIntersection && !hasNonProperIntersection )
-		return false;
-
-	// If there is a segment intersection and the situation is not one
-	// of the ones above, the only choice is to compute the full topological
-	// relationship.  This is because contains/covers is very sensitive
-	// to the situation along the boundary of the target.
-	if ( hasSegmentIntersection )
-		return fullTopologicalPredicate( geom);
-
-	// This tests for the case where a ring of the target lies inside
-	// a test polygon - which implies the exterior of the Target
-	// intersects the interior of the Test, and hence the result is false
-	if (	geom->getGeometryTypeId() == geos::geom::GEOS_MULTIPOLYGON
-		||	geom->getGeometryTypeId() == geos::geom::GEOS_POLYGON )
-	{
-		// TODO: generalize this to handle GeometryCollections
-		bool isTargetInTestArea = isAnyTargetComponentInAreaTest( geom, prepPoly->getRepresentativePoints());
-
-		if ( isTargetInTestArea )
-			return false;
-	}
-
-	return true;
+    findAndClassifyIntersections(geom);
+
+    if(properIntersectionImpliesNotContained && hasProperIntersection) {
+        return false;
+    }
+
+    // If all intersections are proper
+    // (i.e. no non-proper intersections occur)
+    // we can conclude that the test geometry is not contained in the target area,
+    // by the Epsilon-Neighbourhood Exterior Intersection condition.
+    // In real-world data this is likely to be by far the most common situation,
+    // since natural data is unlikely to have many exact vertex segment intersections.
+    // Thus this check is very worthwhile, since it avoid having to perform
+    // a full topological check.
+    //
+    // (If non-proper (vertex) intersections ARE found, this may indicate
+    // a situation where two shells touch at a single vertex, which admits
+    // the case where a line could cross between the shells and still be wholely contained in them.
+    if(hasSegmentIntersection && !hasNonProperIntersection) {
+        return false;
+    }
+
+    // If there is a segment intersection and the situation is not one
+    // of the ones above, the only choice is to compute the full topological
+    // relationship.  This is because contains/covers is very sensitive
+    // to the situation along the boundary of the target.
+    if(hasSegmentIntersection) {
+        return fullTopologicalPredicate(geom);
+    }
+
+    // This tests for the case where a ring of the target lies inside
+    // a test polygon - which implies the exterior of the Target
+    // intersects the interior of the Test, and hence the result is false
+    if(geom->getGeometryTypeId() == geos::geom::GEOS_MULTIPOLYGON
+            ||	geom->getGeometryTypeId() == geos::geom::GEOS_POLYGON) {
+        // TODO: generalize this to handle GeometryCollections
+        bool isTargetInTestArea = isAnyTargetComponentInAreaTest(geom, prepPoly->getRepresentativePoints());
+
+        if(isTargetInTestArea) {
+            return false;
+        }
+    }
+
+    return true;
 }
 
 //
diff --git a/src/geom/prep/BasicPreparedGeometry.cpp b/src/geom/prep/BasicPreparedGeometry.cpp
index c3a6f31..f3d62c6 100644
--- a/src/geom/prep/BasicPreparedGeometry.cpp
+++ b/src/geom/prep/BasicPreparedGeometry.cpp
@@ -31,124 +31,123 @@ namespace prep { // geos.geom.prep
  *            */
 
 void
-BasicPreparedGeometry::setGeometry( const geom::Geometry * geom )
+BasicPreparedGeometry::setGeometry(const geom::Geometry* geom)
 {
-	baseGeom = geom;
-	geom::util::ComponentCoordinateExtracter::getCoordinates(*baseGeom, representativePts);
+    baseGeom = geom;
+    geom::util::ComponentCoordinateExtracter::getCoordinates(*baseGeom, representativePts);
 }
 
 bool
-BasicPreparedGeometry::envelopesIntersect( const geom::Geometry* g) const
+BasicPreparedGeometry::envelopesIntersect(const geom::Geometry* g) const
 {
-	return baseGeom->getEnvelopeInternal()->intersects(g->getEnvelopeInternal());
+    return baseGeom->getEnvelopeInternal()->intersects(g->getEnvelopeInternal());
 }
 
 bool
-BasicPreparedGeometry::envelopeCovers( const geom::Geometry* g) const
+BasicPreparedGeometry::envelopeCovers(const geom::Geometry* g) const
 {
-	return baseGeom->getEnvelopeInternal()->covers(g->getEnvelopeInternal());
+    return baseGeom->getEnvelopeInternal()->covers(g->getEnvelopeInternal());
 }
 
 /*
  * public:
  */
-BasicPreparedGeometry::BasicPreparedGeometry( const Geometry * geom)
+BasicPreparedGeometry::BasicPreparedGeometry(const Geometry* geom)
 {
-	setGeometry( geom);
+    setGeometry(geom);
 }
 
-BasicPreparedGeometry::~BasicPreparedGeometry( )
+BasicPreparedGeometry::~BasicPreparedGeometry()
 {
 }
 
 
 bool
-BasicPreparedGeometry::isAnyTargetComponentInTest( const geom::Geometry * testGeom) const
+BasicPreparedGeometry::isAnyTargetComponentInTest(const geom::Geometry* testGeom) const
 {
-	algorithm::PointLocator locator;
+    algorithm::PointLocator locator;
 
-	for (size_t i=0, n=representativePts.size(); i<n; i++)
-	{
-		const geom::Coordinate& c = *(representativePts[i]);
-		if ( locator.intersects( c, testGeom) )
-		return true;
-	}
-	return false;
+    for(size_t i = 0, n = representativePts.size(); i < n; i++) {
+        const geom::Coordinate& c = *(representativePts[i]);
+        if(locator.intersects(c, testGeom)) {
+            return true;
+        }
+    }
+    return false;
 }
 
 bool
-BasicPreparedGeometry::contains(const geom::Geometry * g) const
+BasicPreparedGeometry::contains(const geom::Geometry* g) const
 {
-	return baseGeom->contains(g);
+    return baseGeom->contains(g);
 }
 
 bool
-BasicPreparedGeometry::containsProperly(const geom::Geometry * g)	const
+BasicPreparedGeometry::containsProperly(const geom::Geometry* g)	const
 {
-	// since raw relate is used, provide some optimizations
+    // since raw relate is used, provide some optimizations
 
-	// short-circuit test
-	if (! baseGeom->getEnvelopeInternal()->contains(g->getEnvelopeInternal()))
-	{
-		return false;
-	}
+    // short-circuit test
+    if(! baseGeom->getEnvelopeInternal()->contains(g->getEnvelopeInternal())) {
+        return false;
+    }
 
-	// otherwise, compute using relate mask
-	return baseGeom->relate(g, "T**FF*FF*");
+    // otherwise, compute using relate mask
+    return baseGeom->relate(g, "T**FF*FF*");
 }
 
 bool
-BasicPreparedGeometry::coveredBy(const geom::Geometry * g) const
+BasicPreparedGeometry::coveredBy(const geom::Geometry* g) const
 {
-	return baseGeom->coveredBy(g);
+    return baseGeom->coveredBy(g);
 }
 
 bool
-BasicPreparedGeometry::covers(const geom::Geometry * g) const
+BasicPreparedGeometry::covers(const geom::Geometry* g) const
 {
-	return baseGeom->covers(g);
+    return baseGeom->covers(g);
 }
 
 bool
-BasicPreparedGeometry::crosses(const geom::Geometry * g) const
+BasicPreparedGeometry::crosses(const geom::Geometry* g) const
 {
-	return baseGeom->crosses(g);
+    return baseGeom->crosses(g);
 }
 
 bool
-BasicPreparedGeometry::disjoint(const geom::Geometry * g)	const
+BasicPreparedGeometry::disjoint(const geom::Geometry* g)	const
 {
-	return ! intersects(g);
+    return ! intersects(g);
 }
 
 bool
-BasicPreparedGeometry::intersects(const geom::Geometry * g) const
+BasicPreparedGeometry::intersects(const geom::Geometry* g) const
 {
-	return baseGeom->intersects(g);
+    return baseGeom->intersects(g);
 }
 
 bool
-BasicPreparedGeometry::overlaps(const geom::Geometry * g)	const
+BasicPreparedGeometry::overlaps(const geom::Geometry* g)	const
 {
-	return baseGeom->overlaps(g);
+    return baseGeom->overlaps(g);
 }
 
 bool
-BasicPreparedGeometry::touches(const geom::Geometry * g) const
+BasicPreparedGeometry::touches(const geom::Geometry* g) const
 {
-	return baseGeom->touches(g);
+    return baseGeom->touches(g);
 }
 
 bool
-BasicPreparedGeometry::within(const geom::Geometry * g) const
+BasicPreparedGeometry::within(const geom::Geometry* g) const
 {
-	return baseGeom->within(g);
+    return baseGeom->within(g);
 }
 
 std::string
 BasicPreparedGeometry::toString()
 {
-	return baseGeom->toString();
+    return baseGeom->toString();
 }
 
 } // namespace geos.geom.prep
diff --git a/src/geom/prep/PreparedGeometryFactory.cpp b/src/geom/prep/PreparedGeometryFactory.cpp
index 463e306..a37b75a 100644
--- a/src/geom/prep/PreparedGeometryFactory.cpp
+++ b/src/geom/prep/PreparedGeometryFactory.cpp
@@ -36,40 +36,38 @@ namespace geos {
 namespace geom { // geos.geom
 namespace prep { // geos.geom.prep
 
-const PreparedGeometry *
-PreparedGeometryFactory::create( const geom::Geometry * g) const
+const PreparedGeometry*
+PreparedGeometryFactory::create(const geom::Geometry* g) const
 {
     using geos::geom::GeometryTypeId;
 
-    if (nullptr == g)
-    {
+    if(nullptr == g) {
         throw util::IllegalArgumentException("PreparedGeometry constructed with null Geometry object");
     }
 
-	PreparedGeometry* pg = nullptr;
+    PreparedGeometry* pg = nullptr;
 
-	switch ( g->getGeometryTypeId() )
-	{
-		case GEOS_MULTIPOINT:
-		case GEOS_POINT:
-			pg = new PreparedPoint( g);
-			break;
+    switch(g->getGeometryTypeId()) {
+    case GEOS_MULTIPOINT:
+    case GEOS_POINT:
+        pg = new PreparedPoint(g);
+        break;
 
-		case GEOS_LINEARRING:
-		case GEOS_LINESTRING:
-		case GEOS_MULTILINESTRING:
-			pg = new PreparedLineString( g);
-			break;
+    case GEOS_LINEARRING:
+    case GEOS_LINESTRING:
+    case GEOS_MULTILINESTRING:
+        pg = new PreparedLineString(g);
+        break;
 
-		case GEOS_POLYGON:
-		case GEOS_MULTIPOLYGON:
-			pg = new PreparedPolygon( g);
-			break;
+    case GEOS_POLYGON:
+    case GEOS_MULTIPOLYGON:
+        pg = new PreparedPolygon(g);
+        break;
 
-		default:
-			pg = new BasicPreparedGeometry( g);
-	}
-	return pg;
+    default:
+        pg = new BasicPreparedGeometry(g);
+    }
+    return pg;
 }
 
 } // namespace geos.geom.prep
diff --git a/src/geom/prep/PreparedLineString.cpp b/src/geom/prep/PreparedLineString.cpp
index e059e74..90cd075 100644
--- a/src/geom/prep/PreparedLineString.cpp
+++ b/src/geom/prep/PreparedLineString.cpp
@@ -32,31 +32,28 @@ namespace prep { // geos.geom.prep
 
 PreparedLineString::~PreparedLineString()
 {
-	delete segIntFinder;
-	for ( noding::SegmentString::ConstVect::size_type i = 0,
-	     ni = segStrings.size(); i < ni; ++i )
-	{
-		delete segStrings[ i ];
-	}
+    delete segIntFinder;
+    for(noding::SegmentString::ConstVect::size_type i = 0,
+            ni = segStrings.size(); i < ni; ++i) {
+        delete segStrings[ i ];
+    }
 }
 
-noding::FastSegmentSetIntersectionFinder *
+noding::FastSegmentSetIntersectionFinder*
 PreparedLineString::getIntersectionFinder()
 {
-	if (! segIntFinder)
-	{
-		noding::SegmentStringUtil::extractSegmentStrings( &getGeometry(), segStrings );
-		segIntFinder = new noding::FastSegmentSetIntersectionFinder( &segStrings );
-	}
+    if(! segIntFinder) {
+        noding::SegmentStringUtil::extractSegmentStrings(&getGeometry(), segStrings);
+        segIntFinder = new noding::FastSegmentSetIntersectionFinder(&segStrings);
+    }
 
-	return segIntFinder;
+    return segIntFinder;
 }
 
 bool
-PreparedLineString::intersects(const geom::Geometry * g) const
+PreparedLineString::intersects(const geom::Geometry* g) const
 {
-	if (! envelopesIntersect(g))
-    {
+    if(! envelopesIntersect(g)) {
         return false;
     }
 
diff --git a/src/geom/prep/PreparedLineStringIntersects.cpp b/src/geom/prep/PreparedLineStringIntersects.cpp
index 472ef50..0e9189a 100644
--- a/src/geom/prep/PreparedLineStringIntersects.cpp
+++ b/src/geom/prep/PreparedLineStringIntersects.cpp
@@ -32,55 +32,62 @@ namespace geos {
 namespace geom { // geos.geom
 namespace prep { // geos.geom.prep
 
-	bool PreparedLineStringIntersects::isAnyTestPointInTarget(const geom::Geometry * testGeom) const
-	{
-		/**
-		 * This could be optimized by using the segment index on the lineal target.
-		 * However, it seems like the L/P case would be pretty rare in practice.
-		 */
-		PointLocator  locator;
-
-		geom::Coordinate::ConstVect coords;
-		ComponentCoordinateExtracter::getCoordinates( *testGeom, coords);
-
-		for (size_t i=0, n=coords.size(); i<n; i++)
-		{
-			geom::Coordinate c = *(coords[i]);
-			if ( locator.intersects( c, &(prepLine.getGeometry()) ))
-				return true;
-		}
-		return false;
-	}
-
-	bool PreparedLineStringIntersects::intersects(const geom::Geometry * g) const
-	{
-		// If any segments intersect, obviously intersects = true
-		noding::SegmentString::ConstVect lineSegStr;
-		noding::SegmentStringUtil::extractSegmentStrings( g, lineSegStr);
-		noding::FastSegmentSetIntersectionFinder * fssif = prepLine.getIntersectionFinder();
-		bool segsIntersect = fssif->intersects( &lineSegStr);// prepLine.getIntersectionFinder()->intersects(lineSegStr);
-
-		for ( size_t i = 0, ni = lineSegStr.size(); i < ni; i++ ) {
-			delete lineSegStr[ i ];
-		}
-
-		if ( segsIntersect ) return true;
-
-		// For L/L case we are done
-		if ( g->getDimension() == 1 )
-			return false;
-
-		// For L/A case, need to check for proper inclusion of the target in the test
-		if (	g->getDimension() == 2
-			&&	prepLine.isAnyTargetComponentInTest(g) )
-			return true;
-
-		// For L/P case, need to check if any points lie on line(s)
-		if ( g->getDimension() == 0 )
-			return isAnyTestPointInTarget(g);
-
-		return false;
-	}
+bool
+PreparedLineStringIntersects::isAnyTestPointInTarget(const geom::Geometry* testGeom) const
+{
+    /**
+     * This could be optimized by using the segment index on the lineal target.
+     * However, it seems like the L/P case would be pretty rare in practice.
+     */
+    PointLocator  locator;
+
+    geom::Coordinate::ConstVect coords;
+    ComponentCoordinateExtracter::getCoordinates(*testGeom, coords);
+
+    for(size_t i = 0, n = coords.size(); i < n; i++) {
+        geom::Coordinate c = *(coords[i]);
+        if(locator.intersects(c, &(prepLine.getGeometry()))) {
+            return true;
+        }
+    }
+    return false;
+}
+
+bool
+PreparedLineStringIntersects::intersects(const geom::Geometry* g) const
+{
+    // If any segments intersect, obviously intersects = true
+    noding::SegmentString::ConstVect lineSegStr;
+    noding::SegmentStringUtil::extractSegmentStrings(g, lineSegStr);
+    noding::FastSegmentSetIntersectionFinder* fssif = prepLine.getIntersectionFinder();
+    bool segsIntersect = fssif->intersects(&lineSegStr); // prepLine.getIntersectionFinder()->intersects(lineSegStr);
+
+    for(size_t i = 0, ni = lineSegStr.size(); i < ni; i++) {
+        delete lineSegStr[ i ];
+    }
+
+    if(segsIntersect) {
+        return true;
+    }
+
+    // For L/L case we are done
+    if(g->getDimension() == 1) {
+        return false;
+    }
+
+    // For L/A case, need to check for proper inclusion of the target in the test
+    if(g->getDimension() == 2
+            &&	prepLine.isAnyTargetComponentInTest(g)) {
+        return true;
+    }
+
+    // For L/P case, need to check if any points lie on line(s)
+    if(g->getDimension() == 0) {
+        return isAnyTestPointInTarget(g);
+    }
+
+    return false;
+}
 
 } // namespace geos.geom.prep
 } // namespace geos.geom
diff --git a/src/geom/prep/PreparedPoint.cpp b/src/geom/prep/PreparedPoint.cpp
index cd530a8..8fa3f94 100644
--- a/src/geom/prep/PreparedPoint.cpp
+++ b/src/geom/prep/PreparedPoint.cpp
@@ -26,10 +26,12 @@ namespace prep { // geos.geom.prep
 bool
 PreparedPoint::intersects(const geom::Geometry* g) const
 {
-	if (! envelopesIntersect( g)) return false;
+    if(! envelopesIntersect(g)) {
+        return false;
+    }
 
-	// This avoids computing topology for the test geometry
-	return isAnyTargetComponentInTest( g);
+    // This avoids computing topology for the test geometry
+    return isAnyTargetComponentInTest(g);
 }
 
 } // namespace geos.geom.prep
diff --git a/src/geom/prep/PreparedPolygon.cpp b/src/geom/prep/PreparedPolygon.cpp
index 25cb739..69d672a 100644
--- a/src/geom/prep/PreparedPolygon.cpp
+++ b/src/geom/prep/PreparedPolygon.cpp
@@ -38,110 +38,112 @@ namespace prep { // geos.geom.prep
 //
 // public:
 //
-PreparedPolygon::PreparedPolygon(const geom::Geometry * geom)
+PreparedPolygon::PreparedPolygon(const geom::Geometry* geom)
     : BasicPreparedGeometry(geom), segIntFinder(nullptr), ptOnGeomLoc(nullptr)
 {
-	isRectangle = getGeometry().isRectangle();
+    isRectangle = getGeometry().isRectangle();
 }
 
 PreparedPolygon::~PreparedPolygon()
 {
-	delete segIntFinder;
-	delete ptOnGeomLoc;
+    delete segIntFinder;
+    delete ptOnGeomLoc;
 
-	for ( std::size_t i = 0, ni = segStrings.size(); i < ni; i++ )
-	{
-		delete segStrings[ i ];
-	}
+    for(std::size_t i = 0, ni = segStrings.size(); i < ni; i++) {
+        delete segStrings[ i ];
+    }
 }
 
 
-noding::FastSegmentSetIntersectionFinder *
+noding::FastSegmentSetIntersectionFinder*
 PreparedPolygon::
 getIntersectionFinder() const
 {
-	if (! segIntFinder)
-	{
-		noding::SegmentStringUtil::extractSegmentStrings( &getGeometry(), segStrings );
-		segIntFinder = new noding::FastSegmentSetIntersectionFinder( &segStrings );
-	}
-	return segIntFinder;
+    if(! segIntFinder) {
+        noding::SegmentStringUtil::extractSegmentStrings(&getGeometry(), segStrings);
+        segIntFinder = new noding::FastSegmentSetIntersectionFinder(&segStrings);
+    }
+    return segIntFinder;
 }
 
-algorithm::locate::PointOnGeometryLocator *
+algorithm::locate::PointOnGeometryLocator*
 PreparedPolygon::
 getPointLocator() const
 {
-	if (! ptOnGeomLoc)
-		ptOnGeomLoc = new algorithm::locate::IndexedPointInAreaLocator( getGeometry() );
+    if(! ptOnGeomLoc) {
+        ptOnGeomLoc = new algorithm::locate::IndexedPointInAreaLocator(getGeometry());
+    }
 
-	return ptOnGeomLoc;
+    return ptOnGeomLoc;
 }
 
 bool
 PreparedPolygon::
-contains( const geom::Geometry * g) const
+contains(const geom::Geometry* g) const
 {
     // short-circuit test
-    if ( !envelopeCovers( g) )
-		return false;
+    if(!envelopeCovers(g)) {
+        return false;
+    }
 
     // optimization for rectangles
-    if ( isRectangle )
-    {
+    if(isRectangle) {
         geom::Geometry const& geom = getGeometry();
         geom::Polygon const& poly = dynamic_cast<geom::Polygon const&>(geom);
 
         return operation::predicate::RectangleContains::contains(poly, *g);
     }
 
-	return PreparedPolygonContains::contains(this, g);
+    return PreparedPolygonContains::contains(this, g);
 }
 
 bool
 PreparedPolygon::
-containsProperly( const geom::Geometry* g) const
+containsProperly(const geom::Geometry* g) const
 {
     // short-circuit test
-    if ( !envelopeCovers( g) )
-		return false;
+    if(!envelopeCovers(g)) {
+        return false;
+    }
 
-	return PreparedPolygonContainsProperly::containsProperly( this, g);
+    return PreparedPolygonContainsProperly::containsProperly(this, g);
 }
 
 bool
 PreparedPolygon::
-covers( const geom::Geometry* g) const
+covers(const geom::Geometry* g) const
 {
     // short-circuit test
-    if ( !envelopeCovers( g) )
-		return false;
+    if(!envelopeCovers(g)) {
+        return false;
+    }
 
     // optimization for rectangle arguments
-    if ( isRectangle)
-		return true;
+    if(isRectangle) {
+        return true;
+    }
 
-	return PreparedPolygonCovers::covers( this, g);
+    return PreparedPolygonCovers::covers(this, g);
 }
 
 bool
 PreparedPolygon::
-intersects( const geom::Geometry* g) const
+intersects(const geom::Geometry* g) const
 {
-  	// envelope test
-  	if ( !envelopesIntersect( g) )
-		return false;
+    // envelope test
+    if(!envelopesIntersect(g)) {
+        return false;
+    }
 
     // optimization for rectangles
-    if ( isRectangle )
-    {
+    if(isRectangle) {
         geom::Geometry const& geom = getGeometry();
         geom::Polygon const& poly = dynamic_cast<geom::Polygon const&>(geom);
 
         return operation::predicate::RectangleIntersects::intersects(poly, *g);
     }
 
-	return PreparedPolygonIntersects::intersects( this, g);
+    return PreparedPolygonIntersects::intersects(this, g);
 }
 
 } // namespace geos.geom.prep
diff --git a/src/geom/prep/PreparedPolygonContains.cpp b/src/geom/prep/PreparedPolygonContains.cpp
index 89f8c08..59c50a9 100644
--- a/src/geom/prep/PreparedPolygonContains.cpp
+++ b/src/geom/prep/PreparedPolygonContains.cpp
@@ -28,8 +28,8 @@ namespace prep { // geos.geom.prep
 //
 // public:
 //
-PreparedPolygonContains::PreparedPolygonContains(const PreparedPolygon * const p_prepPoly)
-    : AbstractPreparedPolygonContains( p_prepPoly)
+PreparedPolygonContains::PreparedPolygonContains(const PreparedPolygon* const p_prepPoly)
+    : AbstractPreparedPolygonContains(p_prepPoly)
 {
 }
 
@@ -37,10 +37,10 @@ PreparedPolygonContains::PreparedPolygonContains(const PreparedPolygon * const p
 // protected:
 //
 bool
-PreparedPolygonContains::fullTopologicalPredicate( const geom::Geometry * geom)
+PreparedPolygonContains::fullTopologicalPredicate(const geom::Geometry* geom)
 {
-	bool isContained = prepPoly->getGeometry().contains( geom);
-	return isContained;
+    bool isContained = prepPoly->getGeometry().contains(geom);
+    return isContained;
 }
 
 //
diff --git a/src/geom/prep/PreparedPolygonContainsProperly.cpp b/src/geom/prep/PreparedPolygonContainsProperly.cpp
index cb98a3e..89ec3b3 100644
--- a/src/geom/prep/PreparedPolygonContainsProperly.cpp
+++ b/src/geom/prep/PreparedPolygonContainsProperly.cpp
@@ -43,43 +43,45 @@ namespace prep { // geos.geom.prep
 // public:
 //
 bool
-PreparedPolygonContainsProperly::containsProperly( const geom::Geometry * geom)
+PreparedPolygonContainsProperly::containsProperly(const geom::Geometry* geom)
 {
-	// Do point-in-poly tests first, since they are cheaper and may result
-	// in a quick negative result.
-	// If a point of any test components does not lie in target,
-	// result is false
-	bool isAllInPrepGeomArea = isAllTestComponentsInTargetInterior( geom);
-	if ( !isAllInPrepGeomArea )
-		return false;
+    // Do point-in-poly tests first, since they are cheaper and may result
+    // in a quick negative result.
+    // If a point of any test components does not lie in target,
+    // result is false
+    bool isAllInPrepGeomArea = isAllTestComponentsInTargetInterior(geom);
+    if(!isAllInPrepGeomArea) {
+        return false;
+    }
 
-	// If any segments intersect, result is false
-	noding::SegmentString::ConstVect lineSegStr;
-	noding::SegmentStringUtil::extractSegmentStrings( geom, lineSegStr);
-	bool segsIntersect = prepPoly->getIntersectionFinder()->intersects( &lineSegStr);
+    // If any segments intersect, result is false
+    noding::SegmentString::ConstVect lineSegStr;
+    noding::SegmentStringUtil::extractSegmentStrings(geom, lineSegStr);
+    bool segsIntersect = prepPoly->getIntersectionFinder()->intersects(&lineSegStr);
 
-	for ( size_t i = 0, ni = lineSegStr.size(); i < ni; i++ ) {
-		delete lineSegStr[ i ];
-	}
+    for(size_t i = 0, ni = lineSegStr.size(); i < ni; i++) {
+        delete lineSegStr[ i ];
+    }
 
-	if (segsIntersect)
-		return false;
+    if(segsIntersect) {
+        return false;
+    }
 
-	/**
-	 * Given that no segments intersect, if any vertex of the target
-	 * is contained in some test component.
-	 * the test is NOT properly contained.
-	 */
-	if (	geom->getGeometryTypeId() == geos::geom::GEOS_MULTIPOLYGON
-		||	geom->getGeometryTypeId() == geos::geom::GEOS_POLYGON )
-	{
-		// TODO: generalize this to handle GeometryCollections
-		bool isTargetGeomInTestArea = isAnyTargetComponentInAreaTest( geom, prepPoly->getRepresentativePoints());
-		if (isTargetGeomInTestArea)
-			return false;
-	}
+    /**
+     * Given that no segments intersect, if any vertex of the target
+     * is contained in some test component.
+     * the test is NOT properly contained.
+     */
+    if(geom->getGeometryTypeId() == geos::geom::GEOS_MULTIPOLYGON
+            ||	geom->getGeometryTypeId() == geos::geom::GEOS_POLYGON) {
+        // TODO: generalize this to handle GeometryCollections
+        bool isTargetGeomInTestArea = isAnyTargetComponentInAreaTest(geom, prepPoly->getRepresentativePoints());
+        if(isTargetGeomInTestArea) {
+            return false;
+        }
+    }
 
-	return true;
+    return true;
 }
 
 } // namespace geos.geom.prep
diff --git a/src/geom/prep/PreparedPolygonCovers.cpp b/src/geom/prep/PreparedPolygonCovers.cpp
index d8139fa..79f5d28 100644
--- a/src/geom/prep/PreparedPolygonCovers.cpp
+++ b/src/geom/prep/PreparedPolygonCovers.cpp
@@ -33,10 +33,10 @@ namespace prep { // geos.geom.prep
 // protected:
 //
 bool
-PreparedPolygonCovers::fullTopologicalPredicate( const geom::Geometry * geom)
+PreparedPolygonCovers::fullTopologicalPredicate(const geom::Geometry* geom)
 {
-	bool result = prepPoly->getGeometry().covers( geom);
-	return result;
+    bool result = prepPoly->getGeometry().covers(geom);
+    return result;
 }
 
 //
diff --git a/src/geom/prep/PreparedPolygonIntersects.cpp b/src/geom/prep/PreparedPolygonIntersects.cpp
index 235a3ec..255c4ab 100644
--- a/src/geom/prep/PreparedPolygonIntersects.cpp
+++ b/src/geom/prep/PreparedPolygonIntersects.cpp
@@ -44,46 +44,47 @@ namespace prep { // geos::geom::prep
 // public:
 //
 bool
-PreparedPolygonIntersects::intersects( const geom::Geometry * geom)
+PreparedPolygonIntersects::intersects(const geom::Geometry* geom)
 {
-	// Do point-in-poly tests first, since they are cheaper and may result
-	// in a quick positive result.
-	// If a point of any test components lie in target, result is true
-	bool isInPrepGeomArea = isAnyTestComponentInTarget( geom);
-	if ( isInPrepGeomArea )
-		return true;
+    // Do point-in-poly tests first, since they are cheaper and may result
+    // in a quick positive result.
+    // If a point of any test components lie in target, result is true
+    bool isInPrepGeomArea = isAnyTestComponentInTarget(geom);
+    if(isInPrepGeomArea) {
+        return true;
+    }
 
-	if ( dynamic_cast<const geom::Puntal *>(geom) ) {
-		// point-in-poly failed, no way there can be an intersection
-		// (NOTE: isAnyTestComponentInTarget also checks for boundary)
-		return false;
-	}
+    if(dynamic_cast<const geom::Puntal*>(geom)) {
+        // point-in-poly failed, no way there can be an intersection
+        // (NOTE: isAnyTestComponentInTarget also checks for boundary)
+        return false;
+    }
 
-	// If any segments intersect, result is true
-	noding::SegmentString::ConstVect lineSegStr;
-	noding::SegmentStringUtil::extractSegmentStrings( geom, lineSegStr );
-	bool segsIntersect = prepPoly->getIntersectionFinder()->intersects( &lineSegStr);
+    // If any segments intersect, result is true
+    noding::SegmentString::ConstVect lineSegStr;
+    noding::SegmentStringUtil::extractSegmentStrings(geom, lineSegStr);
+    bool segsIntersect = prepPoly->getIntersectionFinder()->intersects(&lineSegStr);
 
-	for ( size_t i = 0, ni = lineSegStr.size(); i < ni; i++ )
-	{
-		delete lineSegStr[ i ];
-	}
+    for(size_t i = 0, ni = lineSegStr.size(); i < ni; i++) {
+        delete lineSegStr[ i ];
+    }
 
-	if (segsIntersect)
-		return true;
+    if(segsIntersect) {
+        return true;
+    }
 
-	// If the test has dimension = 2 as well, it is necessary to
-	// test for proper inclusion of the target.
-	// Since no segments intersect, it is sufficient to test representative points.
-	if ( geom->getDimension() == 2)
-	{
-		// TODO: generalize this to handle GeometryCollections
-		bool isPrepGeomInArea = isAnyTargetComponentInAreaTest( geom, prepPoly->getRepresentativePoints());
-		if ( isPrepGeomInArea )
-			return true;
-	}
+    // If the test has dimension = 2 as well, it is necessary to
+    // test for proper inclusion of the target.
+    // Since no segments intersect, it is sufficient to test representative points.
+    if(geom->getDimension() == 2) {
+        // TODO: generalize this to handle GeometryCollections
+        bool isPrepGeomInArea = isAnyTargetComponentInAreaTest(geom, prepPoly->getRepresentativePoints());
+        if(isPrepGeomInArea) {
+            return true;
+        }
+    }
 
-	return false;
+    return false;
 }
 
 } // geos::geom::prep
diff --git a/src/geom/prep/PreparedPolygonPredicate.cpp b/src/geom/prep/PreparedPolygonPredicate.cpp
index 9971b17..faff645 100644
--- a/src/geom/prep/PreparedPolygonPredicate.cpp
+++ b/src/geom/prep/PreparedPolygonPredicate.cpp
@@ -43,12 +43,10 @@ PreparedPolygonPredicate::isAllTestComponentsInTarget(const geom::Geometry* test
     geom::Coordinate::ConstVect pts;
     geom::util::ComponentCoordinateExtracter::getCoordinates(*testGeom, pts);
 
-    for (std::size_t i = 0, ni = pts.size(); i < ni; i++)
-    {
+    for(std::size_t i = 0, ni = pts.size(); i < ni; i++) {
         const geom::Coordinate* pt = pts[i];
         const int loc = prepPoly->getPointLocator()->locate(pt);
-        if (geom::Location::EXTERIOR == loc)
-        {
+        if(geom::Location::EXTERIOR == loc) {
             return false;
         }
     }
@@ -57,17 +55,15 @@ PreparedPolygonPredicate::isAllTestComponentsInTarget(const geom::Geometry* test
 
 bool
 PreparedPolygonPredicate::isAllTestComponentsInTargetInterior(
-		const geom::Geometry* testGeom) const
+    const geom::Geometry* testGeom) const
 {
     geom::Coordinate::ConstVect pts;
     geom::util::ComponentCoordinateExtracter::getCoordinates(*testGeom, pts);
 
-    for (std::size_t i = 0, ni = pts.size(); i < ni; i++)
-    {
-        const geom::Coordinate * pt = pts[i];
+    for(std::size_t i = 0, ni = pts.size(); i < ni; i++) {
+        const geom::Coordinate* pt = pts[i];
         const int loc = prepPoly->getPointLocator()->locate(pt);
-        if (geom::Location::INTERIOR != loc)
-        {
+        if(geom::Location::INTERIOR != loc) {
             return false;
         }
     }
@@ -76,17 +72,15 @@ PreparedPolygonPredicate::isAllTestComponentsInTargetInterior(
 
 bool
 PreparedPolygonPredicate::isAnyTestComponentInTarget(
-		const geom::Geometry* testGeom) const
+    const geom::Geometry* testGeom) const
 {
     geom::Coordinate::ConstVect pts;
     geom::util::ComponentCoordinateExtracter::getCoordinates(*testGeom, pts);
 
-    for (std::size_t i = 0, ni = pts.size(); i < ni; i++)
-    {
+    for(std::size_t i = 0, ni = pts.size(); i < ni; i++) {
         const Coordinate* pt = pts[i];
         const int loc = prepPoly->getPointLocator()->locate(pt);
-        if (geom::Location::EXTERIOR != loc)
-        {
+        if(geom::Location::EXTERIOR != loc) {
             return true;
         }
     }
@@ -95,17 +89,15 @@ PreparedPolygonPredicate::isAnyTestComponentInTarget(
 
 bool
 PreparedPolygonPredicate::isAnyTestComponentInTargetInterior(
-	const geom::Geometry * testGeom) const
+    const geom::Geometry* testGeom) const
 {
     geom::Coordinate::ConstVect pts;
     geom::util::ComponentCoordinateExtracter::getCoordinates(*testGeom, pts);
 
-    for (std::size_t i = 0, ni = pts.size(); i < ni; i++)
-    {
-        const Coordinate * pt = pts[i];
+    for(std::size_t i = 0, ni = pts.size(); i < ni; i++) {
+        const Coordinate* pt = pts[i];
         const int loc = prepPoly->getPointLocator()->locate(pt);
-        if (geom::Location::INTERIOR == loc)
-        {
+        if(geom::Location::INTERIOR == loc) {
             return true;
         }
     }
@@ -114,17 +106,15 @@ PreparedPolygonPredicate::isAnyTestComponentInTargetInterior(
 
 bool
 PreparedPolygonPredicate::isAnyTargetComponentInAreaTest(
-	const geom::Geometry* testGeom,
-	const geom::Coordinate::ConstVect* targetRepPts) const
+    const geom::Geometry* testGeom,
+    const geom::Coordinate::ConstVect* targetRepPts) const
 {
     algorithm::locate::SimplePointInAreaLocator piaLoc(testGeom);
 
-    for (std::size_t i = 0, ni = targetRepPts->size(); i < ni; i++)
-    {
-        const geom::Coordinate * pt = (*targetRepPts)[i];
+    for(std::size_t i = 0, ni = targetRepPts->size(); i < ni; i++) {
+        const geom::Coordinate* pt = (*targetRepPts)[i];
         const int loc = piaLoc.locate(pt);
-        if (geom::Location::EXTERIOR != loc)
-        {
+        if(geom::Location::EXTERIOR != loc) {
             return true;
         }
     }
diff --git a/src/geom/util/ComponentCoordinateExtracter.cpp b/src/geom/util/ComponentCoordinateExtracter.cpp
index f1ae31f..3927c4a 100644
--- a/src/geom/util/ComponentCoordinateExtracter.cpp
+++ b/src/geom/util/ComponentCoordinateExtracter.cpp
@@ -20,41 +20,46 @@ namespace geos {
 namespace geom { // geos.geom
 namespace util { // geos.geom.util
 
-         ComponentCoordinateExtracter::ComponentCoordinateExtracter( std::vector<const Coordinate*> &newComps)
-            :
-         comps(newComps)
-         {}
-
-         void ComponentCoordinateExtracter::filter_rw( Geometry * geom)
-         {
-            if (	geom->getGeometryTypeId() == geos::geom::GEOS_LINEARRING
-               ||	geom->getGeometryTypeId() == geos::geom::GEOS_LINESTRING
-               ||	geom->getGeometryTypeId() == geos::geom::GEOS_POINT )
-               comps.push_back( geom->getCoordinate() );
-            //if (	typeid( *geom ) == typeid( LineString )
-            //	||	typeid( *geom ) == typeid( Point ) )
-            //if ( const Coordinate *ls=dynamic_cast<const Coordinate *>(geom) )
-            //	comps.push_back(ls);
-         }
-
-         void ComponentCoordinateExtracter::filter_ro( const Geometry * geom)
-         {
-            //if (	typeid( *geom ) == typeid( LineString )
-            //	||	typeid( *geom ) == typeid( Point ) )
-            if (	geom->getGeometryTypeId() == geos::geom::GEOS_LINEARRING
-               ||	geom->getGeometryTypeId() == geos::geom::GEOS_LINESTRING
-               ||	geom->getGeometryTypeId() == geos::geom::GEOS_POINT )
-               comps.push_back( geom->getCoordinate() );
-            //if ( const Coordinate *ls=dynamic_cast<const Coordinate *>(geom) )
-            //	comps.push_back(ls);
-         }
-
-
-         void ComponentCoordinateExtracter::getCoordinates(const Geometry &geom, std::vector<const Coordinate*> &ret)
-         {
-            ComponentCoordinateExtracter cce(ret);
-            geom.apply_ro(&cce);
-         }
+ComponentCoordinateExtracter::ComponentCoordinateExtracter(std::vector<const Coordinate*>& newComps)
+    :
+    comps(newComps)
+{}
+
+void
+ComponentCoordinateExtracter::filter_rw(Geometry* geom)
+{
+    if(geom->getGeometryTypeId() == geos::geom::GEOS_LINEARRING
+            ||	geom->getGeometryTypeId() == geos::geom::GEOS_LINESTRING
+            ||	geom->getGeometryTypeId() == geos::geom::GEOS_POINT) {
+        comps.push_back(geom->getCoordinate());
+    }
+    //if (	typeid( *geom ) == typeid( LineString )
+    //	||	typeid( *geom ) == typeid( Point ) )
+    //if ( const Coordinate *ls=dynamic_cast<const Coordinate *>(geom) )
+    //	comps.push_back(ls);
+}
+
+void
+ComponentCoordinateExtracter::filter_ro(const Geometry* geom)
+{
+    //if (	typeid( *geom ) == typeid( LineString )
+    //	||	typeid( *geom ) == typeid( Point ) )
+    if(geom->getGeometryTypeId() == geos::geom::GEOS_LINEARRING
+            ||	geom->getGeometryTypeId() == geos::geom::GEOS_LINESTRING
+            ||	geom->getGeometryTypeId() == geos::geom::GEOS_POINT) {
+        comps.push_back(geom->getCoordinate());
+    }
+    //if ( const Coordinate *ls=dynamic_cast<const Coordinate *>(geom) )
+    //	comps.push_back(ls);
+}
+
+
+void
+ComponentCoordinateExtracter::getCoordinates(const Geometry& geom, std::vector<const Coordinate*>& ret)
+{
+    ComponentCoordinateExtracter cce(ret);
+    geom.apply_ro(&cce);
+}
 
 } // namespace geos.geom.util
 } // namespace geos.geom
diff --git a/src/geom/util/CoordinateOperation.cpp b/src/geom/util/CoordinateOperation.cpp
index c3b15bd..367da52 100644
--- a/src/geom/util/CoordinateOperation.cpp
+++ b/src/geom/util/CoordinateOperation.cpp
@@ -27,30 +27,30 @@ namespace geom { // geos.geom
 namespace util { // geos.geom.util
 
 Geometry*
-CoordinateOperation::edit(const Geometry *geometry,
-		const GeometryFactory *factory)
+CoordinateOperation::edit(const Geometry* geometry,
+                          const GeometryFactory* factory)
 {
-		const LinearRing *ring = dynamic_cast<const LinearRing *>(geometry);
-		if (ring) {
-			const CoordinateSequence *coords = ring->getCoordinatesRO();
-			CoordinateSequence *newCoords = edit(coords,geometry);
-            // LinearRing instance takes over ownership of newCoords instance
-			return factory->createLinearRing(newCoords);
-		}
-		const LineString *line = dynamic_cast<const LineString *>(geometry);
-		if (line) {
-			const CoordinateSequence *coords = line->getCoordinatesRO();
-			CoordinateSequence *newCoords = edit(coords,geometry);
-			return factory->createLineString(newCoords);
-		}
-		if (typeid(*geometry)==typeid(Point)) {
-			CoordinateSequence *coords = geometry->getCoordinates();
-			CoordinateSequence *newCoords = edit(coords,geometry);
-			delete coords;
-			return factory->createPoint(newCoords);
-		}
+    const LinearRing* ring = dynamic_cast<const LinearRing*>(geometry);
+    if(ring) {
+        const CoordinateSequence* coords = ring->getCoordinatesRO();
+        CoordinateSequence* newCoords = edit(coords, geometry);
+        // LinearRing instance takes over ownership of newCoords instance
+        return factory->createLinearRing(newCoords);
+    }
+    const LineString* line = dynamic_cast<const LineString*>(geometry);
+    if(line) {
+        const CoordinateSequence* coords = line->getCoordinatesRO();
+        CoordinateSequence* newCoords = edit(coords, geometry);
+        return factory->createLineString(newCoords);
+    }
+    if(typeid(*geometry) == typeid(Point)) {
+        CoordinateSequence* coords = geometry->getCoordinates();
+        CoordinateSequence* newCoords = edit(coords, geometry);
+        delete coords;
+        return factory->createPoint(newCoords);
+    }
 
-		return geometry->clone();
+    return geometry->clone();
 }
 
 
diff --git a/src/geom/util/Densifier.cpp b/src/geom/util/Densifier.cpp
index 30f868d..a9e4616 100644
--- a/src/geom/util/Densifier.cpp
+++ b/src/geom/util/Densifier.cpp
@@ -48,86 +48,83 @@ namespace util { // geos.geom.util
 
 /* geom::util::Densifier::DensifyTransformer */
 Densifier::DensifyTransformer::DensifyTransformer(double distTol):
-	distanceTolerance(distTol)
+    distanceTolerance(distTol)
 {}
 
 CoordinateSequence::Ptr
-Densifier::DensifyTransformer::transformCoordinates(const CoordinateSequence *coords, const Geometry *parent)
+Densifier::DensifyTransformer::transformCoordinates(const CoordinateSequence* coords, const Geometry* parent)
 {
-	Coordinate::Vect emptyPts;
-	Coordinate::Vect inputPts;
-	coords->toVector(inputPts);
-	std::unique_ptr<Coordinate::Vect> newPts = Densifier::densifyPoints(inputPts, distanceTolerance, parent->getPrecisionModel());
-	if (const LineString* ls=dynamic_cast<const LineString*>(parent))
-	{
-		if (ls->getNumPoints() <= 1)
-			newPts->clear();
-	}
-	CoordinateSequence::Ptr csp(factory->getCoordinateSequenceFactory()->create(newPts.release()));
-	return csp;
+    Coordinate::Vect emptyPts;
+    Coordinate::Vect inputPts;
+    coords->toVector(inputPts);
+    std::unique_ptr<Coordinate::Vect> newPts = Densifier::densifyPoints(inputPts, distanceTolerance,
+            parent->getPrecisionModel());
+    if(const LineString* ls = dynamic_cast<const LineString*>(parent)) {
+        if(ls->getNumPoints() <= 1) {
+            newPts->clear();
+        }
+    }
+    CoordinateSequence::Ptr csp(factory->getCoordinateSequenceFactory()->create(newPts.release()));
+    return csp;
 }
 
 Geometry::Ptr
-Densifier::DensifyTransformer::transformPolygon(const Polygon *geom, const Geometry *parent)
+Densifier::DensifyTransformer::transformPolygon(const Polygon* geom, const Geometry* parent)
 {
-	Geometry::Ptr roughGeom = GeometryTransformer::transformPolygon(geom, parent);
-	// don't try and correct if the parent is going to do this
-	if (parent && parent->getGeometryTypeId() == GEOS_MULTIPOLYGON)
-	{
-		return roughGeom;
-	}
-	Geometry::Ptr validGeom(createValidArea(roughGeom.get()));
-	return validGeom;
+    Geometry::Ptr roughGeom = GeometryTransformer::transformPolygon(geom, parent);
+    // don't try and correct if the parent is going to do this
+    if(parent && parent->getGeometryTypeId() == GEOS_MULTIPOLYGON) {
+        return roughGeom;
+    }
+    Geometry::Ptr validGeom(createValidArea(roughGeom.get()));
+    return validGeom;
 }
 
 Geometry::Ptr
-Densifier::DensifyTransformer::transformMultiPolygon(const MultiPolygon *geom, const Geometry *parent)
+Densifier::DensifyTransformer::transformMultiPolygon(const MultiPolygon* geom, const Geometry* parent)
 {
-	Geometry::Ptr roughGeom = GeometryTransformer::transformMultiPolygon(geom, parent);
-	Geometry::Ptr validGeom(createValidArea(roughGeom.get()));
-	return validGeom;
+    Geometry::Ptr roughGeom = GeometryTransformer::transformMultiPolygon(geom, parent);
+    Geometry::Ptr validGeom(createValidArea(roughGeom.get()));
+    return validGeom;
 }
 
-Geometry *
-Densifier::DensifyTransformer::createValidArea(const Geometry *roughAreaGeom)
+Geometry*
+Densifier::DensifyTransformer::createValidArea(const Geometry* roughAreaGeom)
 {
-	return roughAreaGeom->buffer(0.0);
+    return roughAreaGeom->buffer(0.0);
 }
 
 /* util::Densifier */
 
-Densifier::Densifier(const Geometry *geom):
-	inputGeom(geom)
+Densifier::Densifier(const Geometry* geom):
+    inputGeom(geom)
 {}
 
 std::unique_ptr<Coordinate::Vect>
-Densifier::densifyPoints(const Coordinate::Vect pts, double distanceTolerance, const PrecisionModel *precModel)
+Densifier::densifyPoints(const Coordinate::Vect pts, double distanceTolerance, const PrecisionModel* precModel)
 {
-	geom::LineSegment seg;
-	geom::CoordinateList coordList;
-
-	for (Coordinate::Vect::const_iterator it=pts.begin(), itEnd=pts.end()-1; it < itEnd; ++it)
-	{
-		seg.p0 = *it;
-		seg.p1 = *(it+1);
-		coordList.insert(coordList.end(), seg.p0, false);
-		double len = seg.getLength();
-		int densifiedSegCount = (int) (len / distanceTolerance) + 1;
-		if (densifiedSegCount > 1)
-		{
-			double densifiedSegLen = len / densifiedSegCount;
-			for (int j = 1; j < densifiedSegCount; j++)
-			{
-				double segFract = (j * densifiedSegLen) / len;
-				Coordinate p;
-				seg.pointAlong(segFract, p);
-				precModel->makePrecise(p);
-				coordList.insert(coordList.end(), p, false);
-			}
-		}
-	}
-	coordList.insert(coordList.end(), pts[pts.size()-1], false);
-	return coordList.toCoordinateArray();
+    geom::LineSegment seg;
+    geom::CoordinateList coordList;
+
+    for(Coordinate::Vect::const_iterator it = pts.begin(), itEnd = pts.end() - 1; it < itEnd; ++it) {
+        seg.p0 = *it;
+        seg.p1 = *(it + 1);
+        coordList.insert(coordList.end(), seg.p0, false);
+        double len = seg.getLength();
+        int densifiedSegCount = (int)(len / distanceTolerance) + 1;
+        if(densifiedSegCount > 1) {
+            double densifiedSegLen = len / densifiedSegCount;
+            for(int j = 1; j < densifiedSegCount; j++) {
+                double segFract = (j * densifiedSegLen) / len;
+                Coordinate p;
+                seg.pointAlong(segFract, p);
+                precModel->makePrecise(p);
+                coordList.insert(coordList.end(), p, false);
+            }
+        }
+    }
+    coordList.insert(coordList.end(), pts[pts.size() - 1], false);
+    return coordList.toCoordinateArray();
 }
 
 /**
@@ -139,26 +136,27 @@ Densifier::densifyPoints(const Coordinate::Vect pts, double distanceTolerance, c
  * @return the densified geometry
  */
 Geometry::Ptr
-Densifier::densify(const Geometry *geom, double distTol)
+Densifier::densify(const Geometry* geom, double distTol)
 {
-	util::Densifier densifier(geom);
-	densifier.setDistanceTolerance(distTol);
-	return densifier.getResultGeometry();
+    util::Densifier densifier(geom);
+    densifier.setDistanceTolerance(distTol);
+    return densifier.getResultGeometry();
 }
 
 void
 Densifier::setDistanceTolerance(double tol)
 {
-	if (tol <= 0.0)
-		throw geos::util::IllegalArgumentException("Tolerance must be positive");
-	distanceTolerance = tol;
+    if(tol <= 0.0) {
+        throw geos::util::IllegalArgumentException("Tolerance must be positive");
+    }
+    distanceTolerance = tol;
 }
 
 Geometry::Ptr
 Densifier::getResultGeometry() const
 {
-	DensifyTransformer dt(distanceTolerance);
-	return dt.transform(inputGeom);
+    DensifyTransformer dt(distanceTolerance);
+    return dt.transform(inputGeom);
 }
 
 
diff --git a/src/geom/util/GeometryCombiner.cpp b/src/geom/util/GeometryCombiner.cpp
index 9b00945..5580b92 100644
--- a/src/geom/util/GeometryCombiner.cpp
+++ b/src/geom/util/GeometryCombiner.cpp
@@ -25,13 +25,15 @@ namespace geos {
 namespace geom { // geos.geom
 namespace util { // geos.geom.util
 
-Geometry* GeometryCombiner::combine(std::vector<Geometry*> const& geoms)
+Geometry*
+GeometryCombiner::combine(std::vector<Geometry*> const& geoms)
 {
     GeometryCombiner combiner(geoms);
     return combiner.combine();
 }
 
-Geometry* GeometryCombiner::combine(const Geometry* g0, const Geometry* g1)
+Geometry*
+GeometryCombiner::combine(const Geometry* g0, const Geometry* g1)
 {
     std::vector<Geometry*> geoms;
     geoms.push_back(const_cast<Geometry*>(g0));
@@ -41,8 +43,9 @@ Geometry* GeometryCombiner::combine(const Geometry* g0, const Geometry* g1)
     return combiner.combine();
 }
 
-Geometry* GeometryCombiner::combine(const Geometry* g0, const Geometry* g1,
-                                    const Geometry* g2)
+Geometry*
+GeometryCombiner::combine(const Geometry* g0, const Geometry* g1,
+                          const Geometry* g2)
 {
     std::vector<Geometry*> geoms;
     geoms.push_back(const_cast<Geometry*>(g0));
@@ -54,7 +57,7 @@ Geometry* GeometryCombiner::combine(const Geometry* g0, const Geometry* g1,
 }
 
 GeometryCombiner::GeometryCombiner(std::vector<Geometry*> const& geoms)
-  : geomFactory(extractFactory(geoms)), skipEmpty(false), inputGeoms(geoms)
+    : geomFactory(extractFactory(geoms)), skipEmpty(false), inputGeoms(geoms)
 {
 }
 
@@ -64,19 +67,19 @@ GeometryCombiner::extractFactory(std::vector<Geometry*> const& geoms)
     return geoms.empty() ? nullptr : geoms.front()->getFactory();
 }
 
-Geometry* GeometryCombiner::combine()
+Geometry*
+GeometryCombiner::combine()
 {
     std::vector<Geometry*> elems;
 
     std::vector<Geometry*>::const_iterator end = inputGeoms.end();
-    for (std::vector<Geometry*>::const_iterator i = inputGeoms.begin();
-         i != end; ++i)
-    {
+    for(std::vector<Geometry*>::const_iterator i = inputGeoms.begin();
+            i != end; ++i) {
         extractElements(*i, elems);
     }
 
-    if (elems.empty()) {
-        if (geomFactory != nullptr) {
+    if(elems.empty()) {
+        if(geomFactory != nullptr) {
             return geomFactory->createGeometryCollection(nullptr);
         }
         return nullptr;
@@ -89,13 +92,15 @@ Geometry* GeometryCombiner::combine()
 void
 GeometryCombiner::extractElements(Geometry* geom, std::vector<Geometry*>& elems)
 {
-    if (geom == nullptr)
+    if(geom == nullptr) {
         return;
+    }
 
-    for (std::size_t i = 0; i < geom->getNumGeometries(); ++i) {
+    for(std::size_t i = 0; i < geom->getNumGeometries(); ++i) {
         Geometry* elemGeom = const_cast<Geometry*>(geom->getGeometryN(i));
-        if (skipEmpty && elemGeom->isEmpty())
+        if(skipEmpty && elemGeom->isEmpty()) {
             continue;
+        }
         elems.push_back(elemGeom);
     }
 }
diff --git a/src/geom/util/GeometryEditor.cpp b/src/geom/util/GeometryEditor.cpp
index 5ef1086..64d0946 100644
--- a/src/geom/util/GeometryEditor.cpp
+++ b/src/geom/util/GeometryEditor.cpp
@@ -47,8 +47,9 @@ namespace util { // geos.geom.util
  * Creates a new GeometryEditor object which will create
  * an edited Geometry with the same GeometryFactory as the input Geometry.
  */
-GeometryEditor::GeometryEditor(){
-	factory=nullptr;
+GeometryEditor::GeometryEditor()
+{
+    factory = nullptr;
 }
 
 /**
@@ -57,8 +58,9 @@ GeometryEditor::GeometryEditor(){
  *
  * @param factory the GeometryFactory to create the edited Geometry with
  */
-GeometryEditor::GeometryEditor(const GeometryFactory *newFactory){
-	factory=newFactory;
+GeometryEditor::GeometryEditor(const GeometryFactory* newFactory)
+{
+    factory = newFactory;
 }
 
 /**
@@ -71,32 +73,29 @@ GeometryEditor::GeometryEditor(const GeometryFactory *newFactory){
  * @return a new {@link Geometry} which is the result of the editing
  */
 Geometry*
-GeometryEditor::edit(const Geometry *geometry, GeometryEditorOperation *operation)
+GeometryEditor::edit(const Geometry* geometry, GeometryEditorOperation* operation)
 {
-	// if client did not supply a GeometryFactory, use the one from the input Geometry
-	if (factory == nullptr)
-		factory=geometry->getFactory();
-
-  if ( const GeometryCollection *gc =
-            dynamic_cast<const GeometryCollection*>(geometry) )
-  {
-		return editGeometryCollection(gc, operation);
-  }
-
-  if ( const Polygon *p = dynamic_cast<const Polygon*>(geometry) )
-  {
-		return editPolygon(p, operation);
-  }
-
-  if ( dynamic_cast<const Point*>(geometry) )
-  {
-		return operation->edit(geometry, factory);
-  }
-
-  if ( dynamic_cast<const LineString*>(geometry) )
-  {
-		return operation->edit(geometry, factory);
-  }
+    // if client did not supply a GeometryFactory, use the one from the input Geometry
+    if(factory == nullptr) {
+        factory = geometry->getFactory();
+    }
+
+    if(const GeometryCollection* gc =
+                dynamic_cast<const GeometryCollection*>(geometry)) {
+        return editGeometryCollection(gc, operation);
+    }
+
+    if(const Polygon* p = dynamic_cast<const Polygon*>(geometry)) {
+        return editPolygon(p, operation);
+    }
+
+    if(dynamic_cast<const Point*>(geometry)) {
+        return operation->edit(geometry, factory);
+    }
+
+    if(dynamic_cast<const LineString*>(geometry)) {
+        return operation->edit(geometry, factory);
+    }
 
     // Unsupported Geometry classes should be caught in the GeometryEditorOperation.
     assert(!static_cast<bool>("SHOULD NEVER GET HERE"));
@@ -104,84 +103,82 @@ GeometryEditor::edit(const Geometry *geometry, GeometryEditorOperation *operatio
 }
 
 Polygon*
-GeometryEditor::editPolygon(const Polygon *polygon,GeometryEditorOperation *operation)
+GeometryEditor::editPolygon(const Polygon* polygon, GeometryEditorOperation* operation)
 {
-	Polygon* newPolygon= dynamic_cast<Polygon*>(
-    operation->edit(polygon, factory)
-  );
-	if (newPolygon->isEmpty()) {
-		//RemoveSelectedPlugIn relies on this behaviour. [Jon Aquino]
-		if ( newPolygon->getFactory() != factory ) {
-		  Polygon *ret = factory->createPolygon(nullptr, nullptr);
-		  delete newPolygon;
-		  return ret;
-		} else {
-		  return newPolygon;
-		}
-	}
-
-	Geometry* editResult = edit(newPolygon->getExteriorRing(),operation);
-
-	LinearRing* shell = dynamic_cast<LinearRing*>(editResult);
-	if (shell->isEmpty()) {
-		//RemoveSelectedPlugIn relies on this behaviour. [Jon Aquino]
-		delete shell;
-		delete newPolygon;
-		return factory->createPolygon(nullptr,nullptr);
-	}
-
-	vector<Geometry*> *holes=new vector<Geometry*>;
-	for (size_t i=0, n=newPolygon->getNumInteriorRing(); i<n; ++i)
-	{
-
-		Geometry *hole_geom = edit(newPolygon->getInteriorRingN(i),
-			operation);
-
-		LinearRing *hole = dynamic_cast<LinearRing*>(hole_geom);
-		assert(hole);
-
-		if (hole->isEmpty())
-		{
-			continue;
-		}
-		holes->push_back(hole);
-	}
-	delete newPolygon;
-	return factory->createPolygon(shell,holes);
+    Polygon* newPolygon = dynamic_cast<Polygon*>(
+                              operation->edit(polygon, factory)
+                          );
+    if(newPolygon->isEmpty()) {
+        //RemoveSelectedPlugIn relies on this behaviour. [Jon Aquino]
+        if(newPolygon->getFactory() != factory) {
+            Polygon* ret = factory->createPolygon(nullptr, nullptr);
+            delete newPolygon;
+            return ret;
+        }
+        else {
+            return newPolygon;
+        }
+    }
+
+    Geometry* editResult = edit(newPolygon->getExteriorRing(), operation);
+
+    LinearRing* shell = dynamic_cast<LinearRing*>(editResult);
+    if(shell->isEmpty()) {
+        //RemoveSelectedPlugIn relies on this behaviour. [Jon Aquino]
+        delete shell;
+        delete newPolygon;
+        return factory->createPolygon(nullptr, nullptr);
+    }
+
+    vector<Geometry*>* holes = new vector<Geometry*>;
+    for(size_t i = 0, n = newPolygon->getNumInteriorRing(); i < n; ++i) {
+
+        Geometry* hole_geom = edit(newPolygon->getInteriorRingN(i),
+                                   operation);
+
+        LinearRing* hole = dynamic_cast<LinearRing*>(hole_geom);
+        assert(hole);
+
+        if(hole->isEmpty()) {
+            continue;
+        }
+        holes->push_back(hole);
+    }
+    delete newPolygon;
+    return factory->createPolygon(shell, holes);
 }
 
 GeometryCollection*
-GeometryEditor::editGeometryCollection(const GeometryCollection *collection, GeometryEditorOperation *operation)
+GeometryEditor::editGeometryCollection(const GeometryCollection* collection, GeometryEditorOperation* operation)
 {
-	GeometryCollection *newCollection = dynamic_cast<GeometryCollection*>( operation->edit(collection,factory) );
-	vector<Geometry*> *geometries = new vector<Geometry*>();
-	for (std::size_t i=0, n=newCollection->getNumGeometries(); i<n; i++)
-	{
-		Geometry *geometry = edit(newCollection->getGeometryN(i),
-			operation);
-		if (geometry->isEmpty()) {
-			delete geometry;
-			continue;
-		}
-		geometries->push_back(geometry);
-	}
-
-	if (typeid(*newCollection)==typeid(MultiPoint)) {
-		delete newCollection;
-		return factory->createMultiPoint(geometries);
-	}
-	else if (typeid(*newCollection)==typeid(MultiLineString)) {
-		delete newCollection;
-		return factory->createMultiLineString(geometries);
-	}
-	else if (typeid(*newCollection)==typeid(MultiPolygon)) {
-		delete newCollection;
-		return factory->createMultiPolygon(geometries);
-	}
-	else {
-		delete newCollection;
-		return factory->createGeometryCollection(geometries);
-	}
+    GeometryCollection* newCollection = dynamic_cast<GeometryCollection*>(operation->edit(collection, factory));
+    vector<Geometry*>* geometries = new vector<Geometry*>();
+    for(std::size_t i = 0, n = newCollection->getNumGeometries(); i < n; i++) {
+        Geometry* geometry = edit(newCollection->getGeometryN(i),
+                                  operation);
+        if(geometry->isEmpty()) {
+            delete geometry;
+            continue;
+        }
+        geometries->push_back(geometry);
+    }
+
+    if(typeid(*newCollection) == typeid(MultiPoint)) {
+        delete newCollection;
+        return factory->createMultiPoint(geometries);
+    }
+    else if(typeid(*newCollection) == typeid(MultiLineString)) {
+        delete newCollection;
+        return factory->createMultiLineString(geometries);
+    }
+    else if(typeid(*newCollection) == typeid(MultiPolygon)) {
+        delete newCollection;
+        return factory->createMultiPolygon(geometries);
+    }
+    else {
+        delete newCollection;
+        return factory->createGeometryCollection(geometries);
+    }
 }
 
 } // namespace geos.geom.util
diff --git a/src/geom/util/GeometryTransformer.cpp b/src/geom/util/GeometryTransformer.cpp
index cf95b5d..1bd9637 100644
--- a/src/geom/util/GeometryTransformer.cpp
+++ b/src/geom/util/GeometryTransformer.cpp
@@ -53,340 +53,360 @@ namespace util { // geos.geom.util
 
 /*public*/
 GeometryTransformer::GeometryTransformer()
-	:
-	factory(nullptr),
-	inputGeom(nullptr),
-	pruneEmptyGeometry(true),
-	preserveGeometryCollectionType(true),
-	// preserveCollections(false),
-	preserveType(false),
-	skipTransformedInvalidInteriorRings(false)
+    :
+    factory(nullptr),
+    inputGeom(nullptr),
+    pruneEmptyGeometry(true),
+    preserveGeometryCollectionType(true),
+    // preserveCollections(false),
+    preserveType(false),
+    skipTransformedInvalidInteriorRings(false)
 {}
 
 GeometryTransformer::~GeometryTransformer()
 {
 }
 
-void GeometryTransformer::setSkipTransformedInvalidInteriorRings(bool b)
+void
+GeometryTransformer::setSkipTransformedInvalidInteriorRings(bool b)
 {
-	skipTransformedInvalidInteriorRings = b;
+    skipTransformedInvalidInteriorRings = b;
 }
 
 /*public*/
 unique_ptr<Geometry>
 GeometryTransformer::transform(const Geometry* nInputGeom)
 {
-	using geos::util::IllegalArgumentException;
+    using geos::util::IllegalArgumentException;
 
 #if GEOS_DEBUG
-	std::cerr << "GeometryTransformer::transform(Geometry " << nInputGeom << ");" << std::endl;
+    std::cerr << "GeometryTransformer::transform(Geometry " << nInputGeom << ");" << std::endl;
 #endif
 
-	inputGeom = nInputGeom;
-	factory = inputGeom->getFactory();
-
-	if ( const Point* p=dynamic_cast<const Point*>(inputGeom) )
-		return transformPoint(p, nullptr);
-	if ( const MultiPoint* mp=dynamic_cast<const MultiPoint*>(inputGeom) )
-		return transformMultiPoint(mp, nullptr);
-	if ( const LinearRing* lr=dynamic_cast<const LinearRing*>(inputGeom) )
-		return transformLinearRing(lr, nullptr);
-	if ( const LineString* ls=dynamic_cast<const LineString*>(inputGeom) )
-		return transformLineString(ls, nullptr);
-	if ( const MultiLineString* mls=dynamic_cast<const MultiLineString*>(inputGeom) )
-		return transformMultiLineString(mls, nullptr);
-	if ( const Polygon* p=dynamic_cast<const Polygon*>(inputGeom) )
-		return transformPolygon(p, nullptr);
-	if ( const MultiPolygon* mp=dynamic_cast<const MultiPolygon*>(inputGeom) )
-		return transformMultiPolygon(mp, nullptr);
-	if ( const GeometryCollection* gc=dynamic_cast<const GeometryCollection*>(inputGeom) )
-		return transformGeometryCollection(gc, nullptr);
-
-	throw IllegalArgumentException("Unknown Geometry subtype.");
+    inputGeom = nInputGeom;
+    factory = inputGeom->getFactory();
+
+    if(const Point* p = dynamic_cast<const Point*>(inputGeom)) {
+        return transformPoint(p, nullptr);
+    }
+    if(const MultiPoint* mp = dynamic_cast<const MultiPoint*>(inputGeom)) {
+        return transformMultiPoint(mp, nullptr);
+    }
+    if(const LinearRing* lr = dynamic_cast<const LinearRing*>(inputGeom)) {
+        return transformLinearRing(lr, nullptr);
+    }
+    if(const LineString* ls = dynamic_cast<const LineString*>(inputGeom)) {
+        return transformLineString(ls, nullptr);
+    }
+    if(const MultiLineString* mls = dynamic_cast<const MultiLineString*>(inputGeom)) {
+        return transformMultiLineString(mls, nullptr);
+    }
+    if(const Polygon* p = dynamic_cast<const Polygon*>(inputGeom)) {
+        return transformPolygon(p, nullptr);
+    }
+    if(const MultiPolygon* mp = dynamic_cast<const MultiPolygon*>(inputGeom)) {
+        return transformMultiPolygon(mp, nullptr);
+    }
+    if(const GeometryCollection* gc = dynamic_cast<const GeometryCollection*>(inputGeom)) {
+        return transformGeometryCollection(gc, nullptr);
+    }
+
+    throw IllegalArgumentException("Unknown Geometry subtype.");
 }
 
 std::unique_ptr<CoordinateSequence>
 GeometryTransformer::createCoordinateSequence(
-		std::unique_ptr< std::vector<Coordinate> > coords)
+    std::unique_ptr< std::vector<Coordinate> > coords)
 {
-	return std::unique_ptr<CoordinateSequence>(
-		factory->getCoordinateSequenceFactory()->create(
-				coords.release())
-	);
+    return std::unique_ptr<CoordinateSequence>(
+               factory->getCoordinateSequenceFactory()->create(
+                   coords.release())
+           );
 }
 
 std::unique_ptr<CoordinateSequence>
 GeometryTransformer::transformCoordinates(
-		const CoordinateSequence* coords,
-		const Geometry* parent)
+    const CoordinateSequence* coords,
+    const Geometry* parent)
 {
 
     ::geos::ignore_unused_variable_warning(parent);
 #if GEOS_DEBUG
-	std::cerr << "GeometryTransformer::transformCoordinates(CoordinateSequence " << coords <<", Geometry " << parent << ");" << std::endl;
+    std::cerr << "GeometryTransformer::transformCoordinates(CoordinateSequence " << coords << ", Geometry " << parent <<
+              ");" << std::endl;
 #endif
 
-	return std::unique_ptr<CoordinateSequence>(coords->clone());
+    return std::unique_ptr<CoordinateSequence>(coords->clone());
 }
 
 Geometry::Ptr
 GeometryTransformer::transformPoint(
-		const Point* geom,
-		const Geometry* parent)
+    const Point* geom,
+    const Geometry* parent)
 {
     ::geos::ignore_unused_variable_warning(parent);
 
 #if GEOS_DEBUG
-	std::cerr << "GeometryTransformer::transformPoint(Point " << geom <<", Geometry " << parent << ");" << std::endl;
+    std::cerr << "GeometryTransformer::transformPoint(Point " << geom << ", Geometry " << parent << ");" << std::endl;
 #endif
 
-	CoordinateSequence::Ptr cs(transformCoordinates(
-		geom->getCoordinatesRO(), geom));
+    CoordinateSequence::Ptr cs(transformCoordinates(
+                                   geom->getCoordinatesRO(), geom));
 
-	return Geometry::Ptr(factory->createPoint(cs.release()));
+    return Geometry::Ptr(factory->createPoint(cs.release()));
 }
 
 Geometry::Ptr
 GeometryTransformer::transformMultiPoint(
-		const MultiPoint* geom,
-		const Geometry* parent)
+    const MultiPoint* geom,
+    const Geometry* parent)
 {
     ::geos::ignore_unused_variable_warning(parent);
 
 #if GEOS_DEBUG
-	std::cerr << "GeometryTransformer::transformMultiPoint(MultiPoint " << geom <<", Geometry " << parent << ");" << std::endl;
+    std::cerr << "GeometryTransformer::transformMultiPoint(MultiPoint " << geom << ", Geometry " << parent << ");" <<
+              std::endl;
 #endif
 
-	vector<Geometry*>* transGeomList = new vector<Geometry*>();
+    vector<Geometry*>* transGeomList = new vector<Geometry*>();
 
-	for (size_t i = 0, n = geom->getNumGeometries(); i < n; i++)
-	{
-		const Point* p = dynamic_cast<const Point*>(geom->getGeometryN(i));
-		assert(p);
+    for(size_t i = 0, n = geom->getNumGeometries(); i < n; i++) {
+        const Point* p = dynamic_cast<const Point*>(geom->getGeometryN(i));
+        assert(p);
 
-		Geometry::Ptr transformGeom = transformPoint(p, geom);
-		if ( transformGeom.get() == nullptr ) continue;
-		if ( transformGeom->isEmpty() ) continue;
+        Geometry::Ptr transformGeom = transformPoint(p, geom);
+        if(transformGeom.get() == nullptr) {
+            continue;
+        }
+        if(transformGeom->isEmpty()) {
+            continue;
+        }
 
-		// If an exception is thrown we'll leak
-		transGeomList->push_back(transformGeom.release());
-	}
+        // If an exception is thrown we'll leak
+        transGeomList->push_back(transformGeom.release());
+    }
 
-	return Geometry::Ptr(factory->buildGeometry(transGeomList));
+    return Geometry::Ptr(factory->buildGeometry(transGeomList));
 
 }
 
 Geometry::Ptr
 GeometryTransformer::transformLinearRing(
-		const LinearRing* geom,
-		const Geometry* parent)
+    const LinearRing* geom,
+    const Geometry* parent)
 {
     ::geos::ignore_unused_variable_warning(parent);
 
 #if GEOS_DEBUG
-	std::cerr << "GeometryTransformer::transformLinearRing(LinearRing " << geom <<", Geometry " << parent << ");" << std::endl;
+    std::cerr << "GeometryTransformer::transformLinearRing(LinearRing " << geom << ", Geometry " << parent << ");" <<
+              std::endl;
 #endif
 
-	CoordinateSequence::Ptr seq(transformCoordinates(
-		geom->getCoordinatesRO(), geom));
+    CoordinateSequence::Ptr seq(transformCoordinates(
+                                    geom->getCoordinatesRO(), geom));
 
-	auto seqSize = seq->size();
+    auto seqSize = seq->size();
 
-	// ensure a valid LinearRing
-	if ( seqSize > 0 && seqSize < 4 && ! preserveType )
-	{
-		return factory->createLineString(std::move(seq));
-	}
-	else
-	{
-		return factory->createLinearRing(std::move(seq));
-	}
+    // ensure a valid LinearRing
+    if(seqSize > 0 && seqSize < 4 && ! preserveType) {
+        return factory->createLineString(std::move(seq));
+    }
+    else {
+        return factory->createLinearRing(std::move(seq));
+    }
 }
 
 Geometry::Ptr
 GeometryTransformer::transformLineString(
-		const LineString* geom,
-		const Geometry* parent)
+    const LineString* geom,
+    const Geometry* parent)
 {
     ::geos::ignore_unused_variable_warning(parent);
 
 #if GEOS_DEBUG
-	std::cerr << "GeometryTransformer::transformLineString(LineString " << geom <<", Geometry " << parent << ");" << std::endl;
+    std::cerr << "GeometryTransformer::transformLineString(LineString " << geom << ", Geometry " << parent << ");" <<
+              std::endl;
 #endif
 
-	// should check for 1-point sequences and downgrade them to points
-	return factory->createLineString(
-		transformCoordinates(geom->getCoordinatesRO(), geom));
+    // should check for 1-point sequences and downgrade them to points
+    return factory->createLineString(
+               transformCoordinates(geom->getCoordinatesRO(), geom));
 }
 
 Geometry::Ptr
 GeometryTransformer::transformMultiLineString(
-		const MultiLineString* geom,
-		const Geometry* parent)
+    const MultiLineString* geom,
+    const Geometry* parent)
 {
     ::geos::ignore_unused_variable_warning(parent);
 
 #if GEOS_DEBUG
-	std::cerr << "GeometryTransformer::transformMultiLineString(MultiLineString " << geom <<", Geometry " << parent << ");" << std::endl;
+    std::cerr << "GeometryTransformer::transformMultiLineString(MultiLineString " << geom << ", Geometry " << parent << ");"
+              << std::endl;
 #endif
 
-	vector<Geometry*>* transGeomList = new vector<Geometry*>();
+    vector<Geometry*>* transGeomList = new vector<Geometry*>();
 
-	for (size_t i = 0, n = geom->getNumGeometries(); i < n; i++)
-	{
-		const LineString* l = dynamic_cast<const LineString*>(
-				geom->getGeometryN(i));
-		assert(l);
+    for(size_t i = 0, n = geom->getNumGeometries(); i < n; i++) {
+        const LineString* l = dynamic_cast<const LineString*>(
+                                  geom->getGeometryN(i));
+        assert(l);
 
-		Geometry::Ptr transformGeom = transformLineString(l, geom);
-		if ( transformGeom.get() == nullptr ) continue;
-		if ( transformGeom->isEmpty() ) continue;
+        Geometry::Ptr transformGeom = transformLineString(l, geom);
+        if(transformGeom.get() == nullptr) {
+            continue;
+        }
+        if(transformGeom->isEmpty()) {
+            continue;
+        }
 
-		// If an exception is thrown we'll leak
-		transGeomList->push_back(transformGeom.release());
-	}
+        // If an exception is thrown we'll leak
+        transGeomList->push_back(transformGeom.release());
+    }
 
-	return Geometry::Ptr(factory->buildGeometry(transGeomList));
+    return Geometry::Ptr(factory->buildGeometry(transGeomList));
 
 }
 
 Geometry::Ptr
 GeometryTransformer::transformPolygon(
-		const Polygon* geom,
-		const Geometry* parent)
+    const Polygon* geom,
+    const Geometry* parent)
 {
     ::geos::ignore_unused_variable_warning(parent);
 
 #if GEOS_DEBUG
-	std::cerr << "GeometryTransformer::transformPolygon(Polygon " << geom <<", Geometry " << parent << ");" << std::endl;
+    std::cerr << "GeometryTransformer::transformPolygon(Polygon " << geom << ", Geometry " << parent << ");" << std::endl;
 #endif
 
-	bool isAllValidLinearRings = true;
-
-	const LinearRing* lr = dynamic_cast<const LinearRing*>(
-			geom->getExteriorRing());
-	assert(lr);
-
-	Geometry::Ptr shell = transformLinearRing(lr, geom);
-	if ( shell.get() == nullptr
-		|| ! dynamic_cast<LinearRing*>(shell.get())
-		|| shell->isEmpty() )
-	{
-		isAllValidLinearRings = false;
-	}
-
-	vector<Geometry*>* holes = new vector<Geometry*>();
-	for (size_t i = 0, n = geom->getNumInteriorRing(); i<n; i++)
-	{
-		const LinearRing* p_lr = dynamic_cast<const LinearRing*>(
-			geom->getInteriorRingN(i));
-		assert(p_lr);
-
-		Geometry::Ptr hole(transformLinearRing(p_lr, geom));
-
-		if ( hole.get() == nullptr || hole->isEmpty() ) {
-			continue;
-		}
-
-		if ( ! dynamic_cast<LinearRing*>(hole.get()) )
-		{
-			if ( skipTransformedInvalidInteriorRings )
-			    continue;
-			isAllValidLinearRings = false;
-		}
-
-		holes->push_back(hole.release());
-	}
-
-	if ( isAllValidLinearRings)
-	{
-		Geometry* sh = shell.release();
-		LinearRing* p_lr = dynamic_cast<LinearRing*>(sh);
-    assert(p_lr);
-		return Geometry::Ptr(factory->createPolygon(p_lr, holes));
-	}
-	else
-	{
-		// would like to use a manager constructor here
-		vector<Geometry*>* components = new vector<Geometry*>();
-		if ( shell.get() != nullptr ) {
-			components->push_back(shell.release());
-		}
-
-		components->insert(components->end(),
-			holes->begin(), holes->end());
-
-		delete holes; // :(
-
-		return Geometry::Ptr(factory->buildGeometry(components));
-	}
+    bool isAllValidLinearRings = true;
+
+    const LinearRing* lr = dynamic_cast<const LinearRing*>(
+                               geom->getExteriorRing());
+    assert(lr);
+
+    Geometry::Ptr shell = transformLinearRing(lr, geom);
+    if(shell.get() == nullptr
+            || ! dynamic_cast<LinearRing*>(shell.get())
+            || shell->isEmpty()) {
+        isAllValidLinearRings = false;
+    }
+
+    vector<Geometry*>* holes = new vector<Geometry*>();
+    for(size_t i = 0, n = geom->getNumInteriorRing(); i < n; i++) {
+        const LinearRing* p_lr = dynamic_cast<const LinearRing*>(
+                                     geom->getInteriorRingN(i));
+        assert(p_lr);
+
+        Geometry::Ptr hole(transformLinearRing(p_lr, geom));
+
+        if(hole.get() == nullptr || hole->isEmpty()) {
+            continue;
+        }
+
+        if(! dynamic_cast<LinearRing*>(hole.get())) {
+            if(skipTransformedInvalidInteriorRings) {
+                continue;
+            }
+            isAllValidLinearRings = false;
+        }
+
+        holes->push_back(hole.release());
+    }
+
+    if(isAllValidLinearRings) {
+        Geometry* sh = shell.release();
+        LinearRing* p_lr = dynamic_cast<LinearRing*>(sh);
+        assert(p_lr);
+        return Geometry::Ptr(factory->createPolygon(p_lr, holes));
+    }
+    else {
+        // would like to use a manager constructor here
+        vector<Geometry*>* components = new vector<Geometry*>();
+        if(shell.get() != nullptr) {
+            components->push_back(shell.release());
+        }
+
+        components->insert(components->end(),
+                           holes->begin(), holes->end());
+
+        delete holes; // :(
+
+        return Geometry::Ptr(factory->buildGeometry(components));
+    }
 
 }
 
 Geometry::Ptr
 GeometryTransformer::transformMultiPolygon(
-		const MultiPolygon* geom,
-		const Geometry* parent)
+    const MultiPolygon* geom,
+    const Geometry* parent)
 {
     ::geos::ignore_unused_variable_warning(parent);
 
 #if GEOS_DEBUG
-	std::cerr << "GeometryTransformer::transformMultiPolygon(MultiPolygon " << geom <<", Geometry " << parent << ");" << std::endl;
+    std::cerr << "GeometryTransformer::transformMultiPolygon(MultiPolygon " << geom << ", Geometry " << parent << ");" <<
+              std::endl;
 #endif
 
-	unique_ptr< vector<Geometry*> > transGeomList( new vector<Geometry*>() );
+    unique_ptr< vector<Geometry*> > transGeomList(new vector<Geometry*>());
 
-	for (std::size_t i=0, n=geom->getNumGeometries(); i<n; i++)
-	{
-		const Polygon* p = dynamic_cast<const Polygon*>(
-				geom->getGeometryN(i));
-		assert(p);
+    for(std::size_t i = 0, n = geom->getNumGeometries(); i < n; i++) {
+        const Polygon* p = dynamic_cast<const Polygon*>(
+                               geom->getGeometryN(i));
+        assert(p);
 
-		Geometry::Ptr transformGeom = transformPolygon(p, geom);
-		if ( transformGeom.get() == nullptr ) continue;
-		if ( transformGeom->isEmpty() ) continue;
+        Geometry::Ptr transformGeom = transformPolygon(p, geom);
+        if(transformGeom.get() == nullptr) {
+            continue;
+        }
+        if(transformGeom->isEmpty()) {
+            continue;
+        }
 
-		// If an exception is thrown we'll leak
-		transGeomList->push_back(transformGeom.release());
-	}
+        // If an exception is thrown we'll leak
+        transGeomList->push_back(transformGeom.release());
+    }
 
-	return Geometry::Ptr(factory->buildGeometry(transGeomList.release()));
+    return Geometry::Ptr(factory->buildGeometry(transGeomList.release()));
 
 }
 
 Geometry::Ptr
 GeometryTransformer::transformGeometryCollection(
-		const GeometryCollection* geom,
-		const Geometry* parent)
+    const GeometryCollection* geom,
+    const Geometry* parent)
 {
     ::geos::ignore_unused_variable_warning(parent);
 
 #if GEOS_DEBUG
-	std::cerr << "GeometryTransformer::transformGeometryCollection(GeometryCollection " << geom <<", Geometry " << parent << ");" << std::endl;
+    std::cerr << "GeometryTransformer::transformGeometryCollection(GeometryCollection " << geom << ", Geometry " << parent
+              << ");" << std::endl;
 #endif
 
-	vector<Geometry*>* transGeomList = new vector<Geometry*>();
-
-	for (std::size_t i=0, n=geom->getNumGeometries(); i<n; i++)
-	{
-		Geometry::Ptr transformGeom = transform(
-			geom->getGeometryN(i)); // no parent ?
-		if ( transformGeom.get() == nullptr ) continue;
-		if ( pruneEmptyGeometry && transformGeom->isEmpty() ) continue;
-
-		// If an exception is thrown we'll leak
-		transGeomList->push_back(transformGeom.release());
-	}
-
-	if ( preserveGeometryCollectionType )
-	{
-		return Geometry::Ptr(factory->createGeometryCollection(
-			transGeomList));
-	}
-	else
-	{
-		return Geometry::Ptr(factory->buildGeometry(transGeomList));
-	}
+    vector<Geometry*>* transGeomList = new vector<Geometry*>();
+
+    for(std::size_t i = 0, n = geom->getNumGeometries(); i < n; i++) {
+        Geometry::Ptr transformGeom = transform(
+                                          geom->getGeometryN(i)); // no parent ?
+        if(transformGeom.get() == nullptr) {
+            continue;
+        }
+        if(pruneEmptyGeometry && transformGeom->isEmpty()) {
+            continue;
+        }
+
+        // If an exception is thrown we'll leak
+        transGeomList->push_back(transformGeom.release());
+    }
+
+    if(preserveGeometryCollectionType) {
+        return Geometry::Ptr(factory->createGeometryCollection(
+                                 transGeomList));
+    }
+    else {
+        return Geometry::Ptr(factory->buildGeometry(transGeomList));
+    }
 
 }
 
diff --git a/src/geom/util/LinearComponentExtracter.cpp b/src/geom/util/LinearComponentExtracter.cpp
index 79fb0be..57c5372 100644
--- a/src/geom/util/LinearComponentExtracter.cpp
+++ b/src/geom/util/LinearComponentExtracter.cpp
@@ -20,32 +20,37 @@
 #include <geos/geom/util/LinearComponentExtracter.h>
 
 namespace geos {
-   namespace geom { // geos.geom
-      namespace util { // geos.geom.util
-
-         LinearComponentExtracter::LinearComponentExtracter(std::vector<const LineString*> &newComps)
-            :
-         comps(newComps)
-         {}
-
-         void LinearComponentExtracter::getLines(const Geometry &geom, std::vector<const LineString*> &ret)
-         {
-            LinearComponentExtracter lce(ret);
-            geom.apply_ro(&lce);
-         }
-
-         void LinearComponentExtracter::filter_rw(Geometry *geom)
-         {
-            if ( const LineString *ls=dynamic_cast<const LineString *>(geom) )
-               comps.push_back(ls);
-         }
-
-         void LinearComponentExtracter::filter_ro(const Geometry *geom)
-         {
-            if ( const LineString *ls=dynamic_cast<const LineString *>(geom) )
-               comps.push_back(ls);
-         }
-
-      }
-   }
+namespace geom { // geos.geom
+namespace util { // geos.geom.util
+
+LinearComponentExtracter::LinearComponentExtracter(std::vector<const LineString*>& newComps)
+    :
+    comps(newComps)
+{}
+
+void
+LinearComponentExtracter::getLines(const Geometry& geom, std::vector<const LineString*>& ret)
+{
+    LinearComponentExtracter lce(ret);
+    geom.apply_ro(&lce);
+}
+
+void
+LinearComponentExtracter::filter_rw(Geometry* geom)
+{
+    if(const LineString* ls = dynamic_cast<const LineString*>(geom)) {
+        comps.push_back(ls);
+    }
+}
+
+void
+LinearComponentExtracter::filter_ro(const Geometry* geom)
+{
+    if(const LineString* ls = dynamic_cast<const LineString*>(geom)) {
+        comps.push_back(ls);
+    }
+}
+
+}
+}
 }
diff --git a/src/geom/util/PointExtracter.cpp b/src/geom/util/PointExtracter.cpp
index 44c3c86..5dc74b9 100644
--- a/src/geom/util/PointExtracter.cpp
+++ b/src/geom/util/PointExtracter.cpp
@@ -21,36 +21,41 @@
 #include <geos/geom/util/PointExtracter.h>
 
 namespace geos {
-   namespace geom { // geos.geom
-      namespace util { // geos.geom.util
-
-
-          void PointExtracter::getPoints(const Geometry &geom, Point::ConstVect &ret)
-         {
-            PointExtracter pe(ret);
-            geom.apply_ro(&pe);
-         }
-
-         /**
-         * Constructs a PointExtracterFilter with a list in which
-         * to store Points found.
-         */
-         PointExtracter::PointExtracter(Point::ConstVect& newComps)
-            :
-         comps(newComps)
-         {}
-
-         void PointExtracter::filter_rw(Geometry *geom)
-         {
-            if ( const Point *p=dynamic_cast<const Point *>(geom) )
-               comps.push_back(p);
-         }
-
-         void PointExtracter::filter_ro(const Geometry *geom)
-         {
-            if ( const Point *p=dynamic_cast<const Point *>(geom) )
-               comps.push_back(p);
-         }
-      }
-   }
+namespace geom { // geos.geom
+namespace util { // geos.geom.util
+
+
+void
+PointExtracter::getPoints(const Geometry& geom, Point::ConstVect& ret)
+{
+    PointExtracter pe(ret);
+    geom.apply_ro(&pe);
+}
+
+/**
+* Constructs a PointExtracterFilter with a list in which
+* to store Points found.
+*/
+PointExtracter::PointExtracter(Point::ConstVect& newComps)
+    :
+    comps(newComps)
+{}
+
+void
+PointExtracter::filter_rw(Geometry* geom)
+{
+    if(const Point* p = dynamic_cast<const Point*>(geom)) {
+        comps.push_back(p);
+    }
+}
+
+void
+PointExtracter::filter_ro(const Geometry* geom)
+{
+    if(const Point* p = dynamic_cast<const Point*>(geom)) {
+        comps.push_back(p);
+    }
+}
+}
+}
 }
diff --git a/src/geom/util/PolygonExtracter.cpp b/src/geom/util/PolygonExtracter.cpp
index e0c5713..5e4ae6b 100644
--- a/src/geom/util/PolygonExtracter.cpp
+++ b/src/geom/util/PolygonExtracter.cpp
@@ -24,31 +24,33 @@ namespace geos {
 namespace geom { // geos.geom
 namespace util { // geos.geom.util
 
-         void PolygonExtracter::getPolygons(const Geometry &geom, std::vector<const Polygon*>& ret)
-         {
-            PolygonExtracter pe(ret);
-            geom.apply_ro(&pe);
-         }
-
-         PolygonExtracter::PolygonExtracter(std::vector<const Polygon*>& newComps)
-         :
-         comps(newComps)
-         {}
-
-         void PolygonExtracter::filter_rw(Geometry *geom) {
-            if ( const Polygon *p=dynamic_cast<const Polygon *>(geom) )
-            {
-               comps.push_back(p);
-            }
-         }
-
-         void PolygonExtracter::filter_ro(const Geometry *geom)
-         {
-            if ( const Polygon *p=dynamic_cast<const Polygon *>(geom) )
-            {
-               comps.push_back(p);
-            }
-         }
+void
+PolygonExtracter::getPolygons(const Geometry& geom, std::vector<const Polygon*>& ret)
+{
+    PolygonExtracter pe(ret);
+    geom.apply_ro(&pe);
+}
+
+PolygonExtracter::PolygonExtracter(std::vector<const Polygon*>& newComps)
+    :
+    comps(newComps)
+{}
+
+void
+PolygonExtracter::filter_rw(Geometry* geom)
+{
+    if(const Polygon* p = dynamic_cast<const Polygon*>(geom)) {
+        comps.push_back(p);
+    }
+}
+
+void
+PolygonExtracter::filter_ro(const Geometry* geom)
+{
+    if(const Polygon* p = dynamic_cast<const Polygon*>(geom)) {
+        comps.push_back(p);
+    }
+}
 }
 }
 }
diff --git a/src/geom/util/ShortCircuitedGeometryVisitor.cpp b/src/geom/util/ShortCircuitedGeometryVisitor.cpp
index c1e1d20..f75bd2f 100644
--- a/src/geom/util/ShortCircuitedGeometryVisitor.cpp
+++ b/src/geom/util/ShortCircuitedGeometryVisitor.cpp
@@ -28,24 +28,25 @@ namespace geom { // geos.geom
 namespace util { // geos.geom.util
 
 void
-ShortCircuitedGeometryVisitor::applyTo(const Geometry &geom)
+ShortCircuitedGeometryVisitor::applyTo(const Geometry& geom)
 {
-	for (std::size_t i=0, n=geom.getNumGeometries(); i<n; ++i)
-	{
-		const Geometry *element = geom.getGeometryN(i);
-		if (dynamic_cast<const GeometryCollection*>(element))
-		{
-			applyTo(*element);
-		}
-		else
-		{
-			// calls the abstract virtual
-			visit(*element);
-			if (isDone()) done = true;
-		}
-
-		if ( done ) return;
-	}
+    for(std::size_t i = 0, n = geom.getNumGeometries(); i < n; ++i) {
+        const Geometry* element = geom.getGeometryN(i);
+        if(dynamic_cast<const GeometryCollection*>(element)) {
+            applyTo(*element);
+        }
+        else {
+            // calls the abstract virtual
+            visit(*element);
+            if(isDone()) {
+                done = true;
+            }
+        }
+
+        if(done) {
+            return;
+        }
+    }
 }
 
 
diff --git a/src/geom/util/SineStarFactory.cpp b/src/geom/util/SineStarFactory.cpp
index a734cc4..80a335a 100644
--- a/src/geom/util/SineStarFactory.cpp
+++ b/src/geom/util/SineStarFactory.cpp
@@ -41,49 +41,53 @@ namespace util { // geos::geom::util
 unique_ptr<Polygon>
 SineStarFactory::createSineStar() const
 {
-  unique_ptr<Envelope> env ( dim.getEnvelope() );
-  double radius = env->getWidth() / 2.0;
+    unique_ptr<Envelope> env(dim.getEnvelope());
+    double radius = env->getWidth() / 2.0;
 
-  double armRatio = armLengthRatio;
-  if (armRatio < 0.0) armRatio = 0.0;
-  if (armRatio > 1.0) armRatio = 1.0;
+    double armRatio = armLengthRatio;
+    if(armRatio < 0.0) {
+        armRatio = 0.0;
+    }
+    if(armRatio > 1.0) {
+        armRatio = 1.0;
+    }
 
-  double armMaxLen = armRatio * radius;
-  double insideRadius = (1 - armRatio) * radius;
+    double armMaxLen = armRatio * radius;
+    double insideRadius = (1 - armRatio) * radius;
 
-  double centreX = env->getMinX() + radius;
-  double centreY = env->getMinY() + radius;
+    double centreX = env->getMinX() + radius;
+    double centreY = env->getMinY() + radius;
 
-  unique_ptr< vector<Coordinate> > pts ( new vector<Coordinate>(nPts+1) );
-  int iPt = 0;
-  for (int i = 0; i < nPts; i++) {
-    // the fraction of the way thru the current arm - in [0,1]
-    double ptArcFrac = (i / (double) nPts) * numArms;
-    double armAngFrac = ptArcFrac - floor(ptArcFrac);
+    unique_ptr< vector<Coordinate> > pts(new vector<Coordinate>(nPts + 1));
+    int iPt = 0;
+    for(int i = 0; i < nPts; i++) {
+        // the fraction of the way thru the current arm - in [0,1]
+        double ptArcFrac = (i / (double) nPts) * numArms;
+        double armAngFrac = ptArcFrac - floor(ptArcFrac);
 
-    // the angle for the current arm - in [0,2Pi]
-    // (each arm is a complete sine wave cycle)
-    double armAng = 2 * M_PI * armAngFrac;
-    // the current length of the arm
-    double armLenFrac = (cos(armAng) + 1.0) / 2.0;
+        // the angle for the current arm - in [0,2Pi]
+        // (each arm is a complete sine wave cycle)
+        double armAng = 2 * M_PI * armAngFrac;
+        // the current length of the arm
+        double armLenFrac = (cos(armAng) + 1.0) / 2.0;
 
-    // the current radius of the curve (core + arm)
-    double curveRadius = insideRadius + armMaxLen * armLenFrac;
+        // the current radius of the curve (core + arm)
+        double curveRadius = insideRadius + armMaxLen * armLenFrac;
 
-    // the current angle of the curve
-    double ang = i * (2 * M_PI / nPts);
-    double x = curveRadius * cos(ang) + centreX;
-    double y = curveRadius * sin(ang) + centreY;
-    (*pts)[iPt++] = coord(x, y);
-  }
-  (*pts)[iPt] = Coordinate((*pts)[0]);
+        // the current angle of the curve
+        double ang = i * (2 * M_PI / nPts);
+        double x = curveRadius * cos(ang) + centreX;
+        double y = curveRadius * sin(ang) + centreY;
+        (*pts)[iPt++] = coord(x, y);
+    }
+    (*pts)[iPt] = Coordinate((*pts)[0]);
 
-  unique_ptr<CoordinateSequence> cs (
-    geomFact->getCoordinateSequenceFactory()->create( pts.release() )
-  );
-  unique_ptr<LinearRing> ring ( geomFact->createLinearRing( cs.release() ) );
-  unique_ptr<Polygon> poly ( geomFact->createPolygon(ring.release(), nullptr) );
-  return poly;
+    unique_ptr<CoordinateSequence> cs(
+        geomFact->getCoordinateSequenceFactory()->create(pts.release())
+    );
+    unique_ptr<LinearRing> ring(geomFact->createLinearRing(cs.release()));
+    unique_ptr<Polygon> poly(geomFact->createPolygon(ring.release(), nullptr));
+    return poly;
 }
 
 } // namespace geos::geom::util
diff --git a/src/geomgraph/Depth.cpp b/src/geomgraph/Depth.cpp
index 455d99b..e86fa48 100644
--- a/src/geomgraph/Depth.cpp
+++ b/src/geomgraph/Depth.cpp
@@ -36,19 +36,23 @@ namespace geomgraph { // geos.geomgraph
 int
 Depth::depthAtLocation(int location)
 {
-	if (location == Location::EXTERIOR) return 0;
-	if (location == Location::INTERIOR) return 1;
-	return NULL_VALUE;
+    if(location == Location::EXTERIOR) {
+        return 0;
+    }
+    if(location == Location::INTERIOR) {
+        return 1;
+    }
+    return NULL_VALUE;
 }
 
 Depth::Depth()
 {
-	// initialize depth array to a sentinel value
-	for (int i=0; i<2; i++) {
-		for (int j=0; j<3;j++) {
-			depth[i][j]=NULL_VALUE;
-		}
-	}
+    // initialize depth array to a sentinel value
+    for(int i = 0; i < 2; i++) {
+        for(int j = 0; j < 3; j++) {
+            depth[i][j] = NULL_VALUE;
+        }
+    }
 }
 
 Depth::~Depth()
@@ -57,29 +61,32 @@ Depth::~Depth()
 }
 
 int
-Depth::getDepth(int geomIndex,int posIndex) const
+Depth::getDepth(int geomIndex, int posIndex) const
 {
-	return depth[geomIndex][posIndex];
+    return depth[geomIndex][posIndex];
 }
 
 void
-Depth::setDepth(int geomIndex,int posIndex,int depthValue)
+Depth::setDepth(int geomIndex, int posIndex, int depthValue)
 {
-	depth[geomIndex][posIndex] = depthValue;
+    depth[geomIndex][posIndex] = depthValue;
 }
 
 int
-Depth::getLocation(int geomIndex,int posIndex) const
+Depth::getLocation(int geomIndex, int posIndex) const
 {
-	if (depth[geomIndex][posIndex] <= 0) return Location::EXTERIOR;
-	return Location::INTERIOR;
+    if(depth[geomIndex][posIndex] <= 0) {
+        return Location::EXTERIOR;
+    }
+    return Location::INTERIOR;
 }
 
 void
-Depth::add(int geomIndex,int posIndex,int location)
+Depth::add(int geomIndex, int posIndex, int location)
 {
-	if (location == Location::INTERIOR)
-		depth[geomIndex][posIndex]++;
+    if(location == Location::INTERIOR) {
+        depth[geomIndex][posIndex]++;
+    }
 }
 
 /**
@@ -88,31 +95,32 @@ Depth::add(int geomIndex,int posIndex,int location)
 bool
 Depth::isNull() const
 {
-	for (int i=0; i<2; i++) {
-		for (int j=0; j<3; j++) {
-			if (depth[i][j] != NULL_VALUE)
-				return false;
-		}
-	}
-	return true;
+    for(int i = 0; i < 2; i++) {
+        for(int j = 0; j < 3; j++) {
+            if(depth[i][j] != NULL_VALUE) {
+                return false;
+            }
+        }
+    }
+    return true;
 }
 
 bool
 Depth::isNull(int geomIndex) const
 {
-	return depth[geomIndex][1] == NULL_VALUE;
+    return depth[geomIndex][1] == NULL_VALUE;
 }
 
 bool
 Depth::isNull(int geomIndex, int posIndex) const
 {
-	return depth[geomIndex][posIndex] == NULL_VALUE;
+    return depth[geomIndex][posIndex] == NULL_VALUE;
 }
 
 int
 Depth::getDelta(int geomIndex) const
 {
-	return depth[geomIndex][Position::RIGHT]-depth[geomIndex][Position::LEFT];
+    return depth[geomIndex][Position::RIGHT] - depth[geomIndex][Position::LEFT];
 }
 
 /**
@@ -126,48 +134,53 @@ Depth::getDelta(int geomIndex) const
 void
 Depth::normalize()
 {
-	for (int i=0; i<2; i++) {
-		if (!isNull(i)) {
-			int minDepth=depth[i][1];
-			if (depth[i][2]<minDepth)
-				minDepth=depth[i][2];
-			if (minDepth<0) minDepth = 0;
-			for (int j=1; j<3; j++) {
-				int newValue=0;
-				if (depth[i][j]>minDepth)
-					newValue = 1;
-				depth[i][j] = newValue;
-			}
-		}
-	}
+    for(int i = 0; i < 2; i++) {
+        if(!isNull(i)) {
+            int minDepth = depth[i][1];
+            if(depth[i][2] < minDepth) {
+                minDepth = depth[i][2];
+            }
+            if(minDepth < 0) {
+                minDepth = 0;
+            }
+            for(int j = 1; j < 3; j++) {
+                int newValue = 0;
+                if(depth[i][j] > minDepth) {
+                    newValue = 1;
+                }
+                depth[i][j] = newValue;
+            }
+        }
+    }
 }
 
 void
 Depth::add(const Label& lbl)
 {
-	for (int i=0; i<2; i++) {
-		for (int j=1; j<3; j++) {
-			int loc=lbl.getLocation(i,j);
-			if (loc==Location::EXTERIOR || loc==Location::INTERIOR)
-			{
-				// initialize depth if it is null, otherwise
-				// add this location value
-				if (isNull(i,j)) {
-					depth[i][j]=depthAtLocation(loc);
-				} else
-					depth[i][j]+=depthAtLocation(loc);
-			}
-		}
-	}
+    for(int i = 0; i < 2; i++) {
+        for(int j = 1; j < 3; j++) {
+            int loc = lbl.getLocation(i, j);
+            if(loc == Location::EXTERIOR || loc == Location::INTERIOR) {
+                // initialize depth if it is null, otherwise
+                // add this location value
+                if(isNull(i, j)) {
+                    depth[i][j] = depthAtLocation(loc);
+                }
+                else {
+                    depth[i][j] += depthAtLocation(loc);
+                }
+            }
+        }
+    }
 }
 
 string
 Depth::toString() const
 {
-	ostringstream s;
-	s<<"A:"<<depth[0][1]<<","<<depth[0][2]<<" ";
-	s<<"B:"<<depth[1][1]<<","<<depth[1][2]<<"]";
-	return s.str();
+    ostringstream s;
+    s << "A:" << depth[0][1] << "," << depth[0][2] << " ";
+    s << "B:" << depth[1][1] << "," << depth[1][2] << "]";
+    return s.str();
 }
 
 
diff --git a/src/geomgraph/DirectedEdge.cpp b/src/geomgraph/DirectedEdge.cpp
index 9d091d7..6e0307e 100644
--- a/src/geomgraph/DirectedEdge.cpp
+++ b/src/geomgraph/DirectedEdge.cpp
@@ -46,56 +46,59 @@ namespace geomgraph { // geos.geomgraph
 int
 DirectedEdge::depthFactor(int currLocation, int nextLocation)
 {
-	if (currLocation==Location::EXTERIOR && nextLocation==Location::INTERIOR)
-		return 1;
-	else if (currLocation==Location::INTERIOR && nextLocation==Location::EXTERIOR)
-		return -1;
-	return 0;
+    if(currLocation == Location::EXTERIOR && nextLocation == Location::INTERIOR) {
+        return 1;
+    }
+    else if(currLocation == Location::INTERIOR && nextLocation == Location::EXTERIOR) {
+        return -1;
+    }
+    return 0;
 }
 
 #if 0
 DirectedEdge::DirectedEdge():
-	EdgeEnd(),
-	isInResultVar(false),
-	isVisitedVar(false),
-	sym(NULL),
-	next(NULL),
-	nextMin(NULL),
-	edgeRing(NULL),
-	minEdgeRing(NULL)
+    EdgeEnd(),
+    isInResultVar(false),
+    isVisitedVar(false),
+    sym(NULL),
+    next(NULL),
+    nextMin(NULL),
+    edgeRing(NULL),
+    minEdgeRing(NULL)
 {
-	depth[0]=0;
-	depth[1]=-999;
-	depth[2]=-999;
+    depth[0] = 0;
+    depth[1] = -999;
+    depth[2] = -999;
 
 }
 #endif
 
-DirectedEdge::DirectedEdge(Edge *newEdge, bool newIsForward):
-	EdgeEnd(newEdge),
-	isForwardVar(newIsForward),
-	isInResultVar(false),
-	isVisitedVar(false),
-	sym(nullptr),
-	next(nullptr),
-	nextMin(nullptr),
-	edgeRing(nullptr),
-	minEdgeRing(nullptr)
+DirectedEdge::DirectedEdge(Edge* newEdge, bool newIsForward):
+    EdgeEnd(newEdge),
+    isForwardVar(newIsForward),
+    isInResultVar(false),
+    isVisitedVar(false),
+    sym(nullptr),
+    next(nullptr),
+    nextMin(nullptr),
+    edgeRing(nullptr),
+    minEdgeRing(nullptr)
 {
-	depth[0]=0;
-	depth[1]=-999;
-	depth[2]=-999;
-
-	assert(newEdge);
-	assert(newEdge->getNumPoints() >= 2);
-
-	if (isForwardVar) {
-		init(edge->getCoordinate(0), edge->getCoordinate(1));
-	} else {
-		auto  n = edge->getNumPoints() - 1;
-		init(edge->getCoordinate(n), edge->getCoordinate(n-1));
-	}
-	computeDirectedLabel();
+    depth[0] = 0;
+    depth[1] = -999;
+    depth[2] = -999;
+
+    assert(newEdge);
+    assert(newEdge->getNumPoints() >= 2);
+
+    if(isForwardVar) {
+        init(edge->getCoordinate(0), edge->getCoordinate(1));
+    }
+    else {
+        auto  n = edge->getNumPoints() - 1;
+        init(edge->getCoordinate(n), edge->getCoordinate(n - 1));
+    }
+    computeDirectedLabel();
 }
 
 
@@ -103,30 +106,33 @@ DirectedEdge::DirectedEdge(Edge *newEdge, bool newIsForward):
 void
 DirectedEdge::setDepth(int position, int newDepth)
 {
-	if (depth[position]!=-999) {
-		if (depth[position]!=newDepth)
-			throw util::TopologyException("assigned depths do not match", getCoordinate());
-			//Assert.isTrue(depth[position] == depthVal, "assigned depths do not match at " + getCoordinate());
-	}
-	depth[position]=newDepth;
+    if(depth[position] != -999) {
+        if(depth[position] != newDepth) {
+            throw util::TopologyException("assigned depths do not match", getCoordinate());
+        }
+        //Assert.isTrue(depth[position] == depthVal, "assigned depths do not match at " + getCoordinate());
+    }
+    depth[position] = newDepth;
 }
 
 /*public*/
 int
 DirectedEdge::getDepthDelta() const
 {
-	int depthDelta=edge->getDepthDelta();
-	if (!isForwardVar) depthDelta=-depthDelta;
-	return depthDelta;
+    int depthDelta = edge->getDepthDelta();
+    if(!isForwardVar) {
+        depthDelta = -depthDelta;
+    }
+    return depthDelta;
 }
 
 /*public*/
 void
 DirectedEdge::setVisitedEdge(bool newIsVisited)
 {
-	setVisited(newIsVisited);
-	assert(sym);
-	sym->setVisited(newIsVisited);
+    setVisited(newIsVisited);
+    assert(sym);
+    sym->setVisited(newIsVisited);
 }
 
 
@@ -134,92 +140,96 @@ DirectedEdge::setVisitedEdge(bool newIsVisited)
 bool
 DirectedEdge::isLineEdge()
 {
-	bool isLine = label.isLine(0) || label.isLine(1);
-	bool isExteriorIfArea0=!label.isArea(0) || label.allPositionsEqual(0,Location::EXTERIOR);
-	bool isExteriorIfArea1=!label.isArea(1) || label.allPositionsEqual(1,Location::EXTERIOR);
-	return isLine && isExteriorIfArea0 && isExteriorIfArea1;
+    bool isLine = label.isLine(0) || label.isLine(1);
+    bool isExteriorIfArea0 = !label.isArea(0) || label.allPositionsEqual(0, Location::EXTERIOR);
+    bool isExteriorIfArea1 = !label.isArea(1) || label.allPositionsEqual(1, Location::EXTERIOR);
+    return isLine && isExteriorIfArea0 && isExteriorIfArea1;
 }
 
 /*public*/
 bool
 DirectedEdge::isInteriorAreaEdge()
 {
-	bool p_isInteriorAreaEdge=true;
-	for (int i=0; i<2; i++) {
-		if (!(label.isArea(i)
-			&& label.getLocation(i,Position::LEFT )==Location::INTERIOR
-			&& label.getLocation(i,Position::RIGHT)==Location::INTERIOR)) {
-				p_isInteriorAreaEdge=false;
-		}
-	}
-	return p_isInteriorAreaEdge;
+    bool p_isInteriorAreaEdge = true;
+    for(int i = 0; i < 2; i++) {
+        if(!(label.isArea(i)
+                && label.getLocation(i, Position::LEFT) == Location::INTERIOR
+                && label.getLocation(i, Position::RIGHT) == Location::INTERIOR)) {
+            p_isInteriorAreaEdge = false;
+        }
+    }
+    return p_isInteriorAreaEdge;
 }
 
 /*private*/
 void
 DirectedEdge::computeDirectedLabel()
 {
-	label = edge->getLabel();
-	if (!isForwardVar)
-		label.flip();
+    label = edge->getLabel();
+    if(!isForwardVar) {
+        label.flip();
+    }
 }
 
 /*public*/
 void
 DirectedEdge::setEdgeDepths(int position, int newDepth)
 {
-	// get the depth transition delta from R to L for this directed Edge
-	int depthDelta=getEdge()->getDepthDelta();
-	if (!isForwardVar) depthDelta=-depthDelta;
-	// if moving from L to R instead of R to L must change sign of delta
-	int directionFactor=1;
-	if (position==Position::LEFT)
-		directionFactor=-1;
-	int oppositePos=Position::opposite(position);
-	int delta=depthDelta*directionFactor;
-	//TESTINGint delta = depthDelta * DirectedEdge.depthFactor(loc, oppositeLoc);
-	int oppositeDepth=newDepth+delta;
-	setDepth(position,newDepth);
-	setDepth(oppositePos,oppositeDepth);
+    // get the depth transition delta from R to L for this directed Edge
+    int depthDelta = getEdge()->getDepthDelta();
+    if(!isForwardVar) {
+        depthDelta = -depthDelta;
+    }
+    // if moving from L to R instead of R to L must change sign of delta
+    int directionFactor = 1;
+    if(position == Position::LEFT) {
+        directionFactor = -1;
+    }
+    int oppositePos = Position::opposite(position);
+    int delta = depthDelta * directionFactor;
+    //TESTINGint delta = depthDelta * DirectedEdge.depthFactor(loc, oppositeLoc);
+    int oppositeDepth = newDepth + delta;
+    setDepth(position, newDepth);
+    setDepth(oppositePos, oppositeDepth);
 }
 
 /*public*/
 std::string
 DirectedEdge::print() const
 {
-	std::stringstream ss;
-	ss << EdgeEnd::print();
-	ss << " "
-	   << depth[Position::LEFT]
-	   << "/"
-	   << depth[Position::RIGHT]
-	   << " ("
-	   << getDepthDelta()
-	   << ")";
-	if (isInResultVar)
-	{
-		ss << " inResult";
-	}
-	ss << " EdgeRing: " << edgeRing;
-	if ( edgeRing )
-	{
-		EdgeRing* er = edgeRing;
-		ss << " (" << *er << ")";
-	}
-	return ss.str();
+    std::stringstream ss;
+    ss << EdgeEnd::print();
+    ss << " "
+       << depth[Position::LEFT]
+       << "/"
+       << depth[Position::RIGHT]
+       << " ("
+       << getDepthDelta()
+       << ")";
+    if(isInResultVar) {
+        ss << " inResult";
+    }
+    ss << " EdgeRing: " << edgeRing;
+    if(edgeRing) {
+        EdgeRing* er = edgeRing;
+        ss << " (" << *er << ")";
+    }
+    return ss.str();
 }
 
 /*public*/
 std::string
 DirectedEdge::printEdge()
 {
-	//std::string out=print();
-	std::string out("");
-	if (isForwardVar)
-		out += edge->print();
-	else
-		out += edge->printReverse();
-	return out;
+    //std::string out=print();
+    std::string out("");
+    if(isForwardVar) {
+        out += edge->print();
+    }
+    else {
+        out += edge->printReverse();
+    }
+    return out;
 }
 
 } // namespace geos.geomgraph
diff --git a/src/geomgraph/DirectedEdgeStar.cpp b/src/geomgraph/DirectedEdgeStar.cpp
index 58447d9..60fbf84 100644
--- a/src/geomgraph/DirectedEdgeStar.cpp
+++ b/src/geomgraph/DirectedEdgeStar.cpp
@@ -45,430 +45,457 @@ namespace geomgraph { // geos.geomgraph
 
 /*public*/
 void
-DirectedEdgeStar::insert(EdgeEnd *ee)
+DirectedEdgeStar::insert(EdgeEnd* ee)
 {
-	assert(ee);
-	assert(dynamic_cast<DirectedEdge*>(ee));
-	DirectedEdge *de=static_cast<DirectedEdge*>(ee);
-	insertEdgeEnd(de);
+    assert(ee);
+    assert(dynamic_cast<DirectedEdge*>(ee));
+    DirectedEdge* de = static_cast<DirectedEdge*>(ee);
+    insertEdgeEnd(de);
 }
 
 /*public*/
 int
 DirectedEdgeStar::getOutgoingDegree()
 {
-	int degree = 0;
-	EdgeEndStar::iterator endIt=end();
-	for (EdgeEndStar::iterator it=begin(); it!=endIt; ++it)
-	{
-		assert(*it);
-		assert(dynamic_cast<DirectedEdge*>(*it));
-		DirectedEdge *de=static_cast<DirectedEdge*>(*it);
-		if (de->isInResult()) ++degree;
-	}
-	return degree;
+    int degree = 0;
+    EdgeEndStar::iterator endIt = end();
+    for(EdgeEndStar::iterator it = begin(); it != endIt; ++it) {
+        assert(*it);
+        assert(dynamic_cast<DirectedEdge*>(*it));
+        DirectedEdge* de = static_cast<DirectedEdge*>(*it);
+        if(de->isInResult()) {
+            ++degree;
+        }
+    }
+    return degree;
 }
 
 /*public*/
 int
-DirectedEdgeStar::getOutgoingDegree(EdgeRing *er)
+DirectedEdgeStar::getOutgoingDegree(EdgeRing* er)
 {
-	int degree = 0;
-	EdgeEndStar::iterator endIt=end();
-	for (EdgeEndStar::iterator it=begin(); it!=endIt; ++it)
-	{
-		assert(*it);
-		assert(dynamic_cast<DirectedEdge*>(*it));
-		DirectedEdge *de=static_cast<DirectedEdge*>(*it);
-		if (de->getEdgeRing()==er) ++degree;
-	}
-	return degree;
+    int degree = 0;
+    EdgeEndStar::iterator endIt = end();
+    for(EdgeEndStar::iterator it = begin(); it != endIt; ++it) {
+        assert(*it);
+        assert(dynamic_cast<DirectedEdge*>(*it));
+        DirectedEdge* de = static_cast<DirectedEdge*>(*it);
+        if(de->getEdgeRing() == er) {
+            ++degree;
+        }
+    }
+    return degree;
 }
 
 /*public*/
 DirectedEdge*
 DirectedEdgeStar::getRightmostEdge()
 {
-	EdgeEndStar::iterator it=begin();
-	if ( it==end() ) return nullptr;
-
-	assert(*it);
-	assert(dynamic_cast<DirectedEdge*>(*it));
-	DirectedEdge *de0=static_cast<DirectedEdge*>(*it);
-	++it;
-	if ( it==end() ) return de0;
-
-	it=end(); --it;
-
-	assert(*it);
-	assert(dynamic_cast<DirectedEdge*>(*it));
-	DirectedEdge *deLast=static_cast<DirectedEdge*>(*it);
-
-	assert(de0);
-	int quad0=de0->getQuadrant();
-	assert(deLast);
-	int quad1=deLast->getQuadrant();
-	if (Quadrant::isNorthern(quad0) && Quadrant::isNorthern(quad1))
-		return de0;
-	else if (!Quadrant::isNorthern(quad0) && !Quadrant::isNorthern(quad1))
-		return deLast;
-	else {
-		// edges are in different hemispheres - make sure we return one that is non-horizontal
-		//DirectedEdge *nonHorizontalEdge=NULL;
-		if (de0->getDy()!=0)
-			return de0;
-		else if (deLast->getDy()!=0)
-			return deLast;
-	}
-	assert(0); // found two horizontal edges incident on node
-	return nullptr;
+    EdgeEndStar::iterator it = begin();
+    if(it == end()) {
+        return nullptr;
+    }
+
+    assert(*it);
+    assert(dynamic_cast<DirectedEdge*>(*it));
+    DirectedEdge* de0 = static_cast<DirectedEdge*>(*it);
+    ++it;
+    if(it == end()) {
+        return de0;
+    }
+
+    it = end();
+    --it;
+
+    assert(*it);
+    assert(dynamic_cast<DirectedEdge*>(*it));
+    DirectedEdge* deLast = static_cast<DirectedEdge*>(*it);
+
+    assert(de0);
+    int quad0 = de0->getQuadrant();
+    assert(deLast);
+    int quad1 = deLast->getQuadrant();
+    if(Quadrant::isNorthern(quad0) && Quadrant::isNorthern(quad1)) {
+        return de0;
+    }
+    else if(!Quadrant::isNorthern(quad0) && !Quadrant::isNorthern(quad1)) {
+        return deLast;
+    }
+    else {
+        // edges are in different hemispheres - make sure we return one that is non-horizontal
+        //DirectedEdge *nonHorizontalEdge=NULL;
+        if(de0->getDy() != 0) {
+            return de0;
+        }
+        else if(deLast->getDy() != 0) {
+            return deLast;
+        }
+    }
+    assert(0); // found two horizontal edges incident on node
+    return nullptr;
 }
 
 /*public*/
 void
-DirectedEdgeStar::computeLabelling(std::vector<GeometryGraph*> *geom)
-	//throw(TopologyException *)
+DirectedEdgeStar::computeLabelling(std::vector<GeometryGraph*>* geom)
+//throw(TopologyException *)
 {
-	// this call can throw a TopologyException
-	// we don't have any cleanup to do...
-	EdgeEndStar::computeLabelling(geom);
-
-	// determine the overall labelling for this DirectedEdgeStar
-	// (i.e. for the node it is based at)
-	label=Label(Location::UNDEF);
-	EdgeEndStar::iterator endIt=end();
-	for (EdgeEndStar::iterator it=begin(); it!=endIt; ++it)
-	{
-		EdgeEnd *ee=*it;
-		assert(ee);
-		Edge *e=ee->getEdge();
-		assert(e);
-		const Label& eLabel=e->getLabel();
-		for (int i=0; i<2; ++i) {
-			int eLoc=eLabel.getLocation(i);
-			if (eLoc==Location::INTERIOR || eLoc==Location::BOUNDARY)
-				label.setLocation(i, Location::INTERIOR);
-		}
-	}
+    // this call can throw a TopologyException
+    // we don't have any cleanup to do...
+    EdgeEndStar::computeLabelling(geom);
+
+    // determine the overall labelling for this DirectedEdgeStar
+    // (i.e. for the node it is based at)
+    label = Label(Location::UNDEF);
+    EdgeEndStar::iterator endIt = end();
+    for(EdgeEndStar::iterator it = begin(); it != endIt; ++it) {
+        EdgeEnd* ee = *it;
+        assert(ee);
+        Edge* e = ee->getEdge();
+        assert(e);
+        const Label& eLabel = e->getLabel();
+        for(int i = 0; i < 2; ++i) {
+            int eLoc = eLabel.getLocation(i);
+            if(eLoc == Location::INTERIOR || eLoc == Location::BOUNDARY) {
+                label.setLocation(i, Location::INTERIOR);
+            }
+        }
+    }
 }
 
 /*public*/
 void
 DirectedEdgeStar::mergeSymLabels()
 {
-	EdgeEndStar::iterator endIt=end();
-	for (EdgeEndStar::iterator it=begin(); it!=endIt; ++it)
-	{
-		assert(*it);
-		assert(dynamic_cast<DirectedEdge*>(*it));
-		DirectedEdge *de=static_cast<DirectedEdge*>(*it);
-		Label& deLabel = de->getLabel();
+    EdgeEndStar::iterator endIt = end();
+    for(EdgeEndStar::iterator it = begin(); it != endIt; ++it) {
+        assert(*it);
+        assert(dynamic_cast<DirectedEdge*>(*it));
+        DirectedEdge* de = static_cast<DirectedEdge*>(*it);
+        Label& deLabel = de->getLabel();
 
-		DirectedEdge* deSym=de->getSym();
-		assert(deSym);
+        DirectedEdge* deSym = de->getSym();
+        assert(deSym);
 
-		const Label& labelToMerge = deSym->getLabel();
+        const Label& labelToMerge = deSym->getLabel();
 
-		deLabel.merge(labelToMerge);
-	}
+        deLabel.merge(labelToMerge);
+    }
 }
 
 /*public*/
 void
 DirectedEdgeStar::updateLabelling(const Label& nodeLabel)
 {
-	EdgeEndStar::iterator endIt=end();
-	for (EdgeEndStar::iterator it=begin(); it!=endIt; ++it)
-	{
-		DirectedEdge *de=dynamic_cast<DirectedEdge*>(*it);
-		assert(de);
-		Label& deLabel = de->getLabel();
-		deLabel.setAllLocationsIfNull(0, nodeLabel.getLocation(0));
-		deLabel.setAllLocationsIfNull(1, nodeLabel.getLocation(1));
-	}
+    EdgeEndStar::iterator endIt = end();
+    for(EdgeEndStar::iterator it = begin(); it != endIt; ++it) {
+        DirectedEdge* de = dynamic_cast<DirectedEdge*>(*it);
+        assert(de);
+        Label& deLabel = de->getLabel();
+        deLabel.setAllLocationsIfNull(0, nodeLabel.getLocation(0));
+        deLabel.setAllLocationsIfNull(1, nodeLabel.getLocation(1));
+    }
 }
 
 /*private*/
 std::vector<DirectedEdge*>*
 DirectedEdgeStar::getResultAreaEdges()
 {
-	if (resultAreaEdgeList!=nullptr) return resultAreaEdgeList;
-
-	resultAreaEdgeList=new std::vector<DirectedEdge*>();
-
-	EdgeEndStar::iterator endIt=end();
-	for (EdgeEndStar::iterator it=begin(); it!=endIt; ++it)
-	{
-		assert(*it);
-		assert(dynamic_cast<DirectedEdge*>(*it));
-		DirectedEdge *de=static_cast<DirectedEdge*>(*it);
-		if (de->isInResult() || de->getSym()->isInResult())
-			resultAreaEdgeList->push_back(de);
-	}
-	return resultAreaEdgeList;
+    if(resultAreaEdgeList != nullptr) {
+        return resultAreaEdgeList;
+    }
+
+    resultAreaEdgeList = new std::vector<DirectedEdge*>();
+
+    EdgeEndStar::iterator endIt = end();
+    for(EdgeEndStar::iterator it = begin(); it != endIt; ++it) {
+        assert(*it);
+        assert(dynamic_cast<DirectedEdge*>(*it));
+        DirectedEdge* de = static_cast<DirectedEdge*>(*it);
+        if(de->isInResult() || de->getSym()->isInResult()) {
+            resultAreaEdgeList->push_back(de);
+        }
+    }
+    return resultAreaEdgeList;
 }
 
 /*public*/
 void
 DirectedEdgeStar::linkResultDirectedEdges()
-	// throw(TopologyException *)
+// throw(TopologyException *)
 {
-	// make sure edges are copied to resultAreaEdges list
-	getResultAreaEdges();
-	// find first area edge (if any) to start linking at
-	DirectedEdge *firstOut=nullptr;
-	DirectedEdge *incoming=nullptr;
-	int state=SCANNING_FOR_INCOMING;
-	// link edges in CCW order
-	for (std::vector<DirectedEdge*>::iterator
-		i=resultAreaEdgeList->begin(), iEnd=resultAreaEdgeList->end();
-		i != iEnd;
-		++i)
-	{
-        	DirectedEdge *nextOut=*i;
-		assert(nextOut);
-
-		// skip de's that we're not interested in
-		if (!nextOut->getLabel().isArea()) continue;
-
-		DirectedEdge *nextIn=nextOut->getSym();
-		assert(nextIn);
-
-		// record first outgoing edge, in order to link the last incoming edge
-		if (firstOut==nullptr && nextOut->isInResult()) firstOut=nextOut;
-
-		switch (state) {
-			case SCANNING_FOR_INCOMING:
-				if (!nextIn->isInResult()) continue;
-				incoming=nextIn;
-				state=LINKING_TO_OUTGOING;
-				break;
-			case LINKING_TO_OUTGOING:
-				if (!nextOut->isInResult()) continue;
-				incoming->setNext(nextOut);
-				state=SCANNING_FOR_INCOMING;
-				break;
-		}
-	}
-	if (state==LINKING_TO_OUTGOING) {
-		if (firstOut==nullptr)
-		{
-			throw util::TopologyException("no outgoing dirEdge found",
-					getCoordinate());
-		}
-		assert(firstOut->isInResult()); // unable to link last incoming dirEdge
-		assert(incoming);
-		incoming->setNext(firstOut);
-	}
+    // make sure edges are copied to resultAreaEdges list
+    getResultAreaEdges();
+    // find first area edge (if any) to start linking at
+    DirectedEdge* firstOut = nullptr;
+    DirectedEdge* incoming = nullptr;
+    int state = SCANNING_FOR_INCOMING;
+    // link edges in CCW order
+    for(std::vector<DirectedEdge*>::iterator
+            i = resultAreaEdgeList->begin(), iEnd = resultAreaEdgeList->end();
+            i != iEnd;
+            ++i) {
+        DirectedEdge* nextOut = *i;
+        assert(nextOut);
+
+        // skip de's that we're not interested in
+        if(!nextOut->getLabel().isArea()) {
+            continue;
+        }
+
+        DirectedEdge* nextIn = nextOut->getSym();
+        assert(nextIn);
+
+        // record first outgoing edge, in order to link the last incoming edge
+        if(firstOut == nullptr && nextOut->isInResult()) {
+            firstOut = nextOut;
+        }
+
+        switch(state) {
+        case SCANNING_FOR_INCOMING:
+            if(!nextIn->isInResult()) {
+                continue;
+            }
+            incoming = nextIn;
+            state = LINKING_TO_OUTGOING;
+            break;
+        case LINKING_TO_OUTGOING:
+            if(!nextOut->isInResult()) {
+                continue;
+            }
+            incoming->setNext(nextOut);
+            state = SCANNING_FOR_INCOMING;
+            break;
+        }
+    }
+    if(state == LINKING_TO_OUTGOING) {
+        if(firstOut == nullptr) {
+            throw util::TopologyException("no outgoing dirEdge found",
+                                          getCoordinate());
+        }
+        assert(firstOut->isInResult()); // unable to link last incoming dirEdge
+        assert(incoming);
+        incoming->setNext(firstOut);
+    }
 }
 
 /*public*/
 void
-DirectedEdgeStar::linkMinimalDirectedEdges(EdgeRing *er)
+DirectedEdgeStar::linkMinimalDirectedEdges(EdgeRing* er)
 {
-	// find first area edge (if any) to start linking at
-	DirectedEdge *firstOut=nullptr;
-	DirectedEdge *incoming=nullptr;
-	int state=SCANNING_FOR_INCOMING;
-
-	// link edges in CW order
-	for (std::vector<DirectedEdge*>::reverse_iterator
-		i=resultAreaEdgeList->rbegin(), iEnd=resultAreaEdgeList->rend();
-		i != iEnd;
-		++i)
-	{
-		//DirectedEdge *nextOut=(*resultAreaEdgeList)[i];
-		DirectedEdge *nextOut=*i;
-		assert(nextOut);
-
-		DirectedEdge *nextIn=nextOut->getSym();
-		assert(nextIn);
-
-		// record first outgoing edge, in order to link the last incoming edge
-		if (firstOut==nullptr && nextOut->getEdgeRing()==er) firstOut=nextOut;
-		switch (state) {
-			case SCANNING_FOR_INCOMING:
-				if (nextIn->getEdgeRing()!=er) continue;
-				incoming=nextIn;
-				state = LINKING_TO_OUTGOING;
-				break;
-			case LINKING_TO_OUTGOING:
-				if (nextOut->getEdgeRing()!=er) continue;
-				assert(incoming);
-				incoming->setNextMin(nextOut);
-				state = SCANNING_FOR_INCOMING;
-				break;
-		}
-	}
-	if (state==LINKING_TO_OUTGOING) {
-		assert(firstOut!=nullptr); // found null for first outgoing dirEdge
-		assert(firstOut->getEdgeRing()==er); // unable to link last incoming dirEdge
-		assert(incoming);
-		incoming->setNextMin(firstOut);
-	}
+    // find first area edge (if any) to start linking at
+    DirectedEdge* firstOut = nullptr;
+    DirectedEdge* incoming = nullptr;
+    int state = SCANNING_FOR_INCOMING;
+
+    // link edges in CW order
+    for(std::vector<DirectedEdge*>::reverse_iterator
+            i = resultAreaEdgeList->rbegin(), iEnd = resultAreaEdgeList->rend();
+            i != iEnd;
+            ++i) {
+        //DirectedEdge *nextOut=(*resultAreaEdgeList)[i];
+        DirectedEdge* nextOut = *i;
+        assert(nextOut);
+
+        DirectedEdge* nextIn = nextOut->getSym();
+        assert(nextIn);
+
+        // record first outgoing edge, in order to link the last incoming edge
+        if(firstOut == nullptr && nextOut->getEdgeRing() == er) {
+            firstOut = nextOut;
+        }
+        switch(state) {
+        case SCANNING_FOR_INCOMING:
+            if(nextIn->getEdgeRing() != er) {
+                continue;
+            }
+            incoming = nextIn;
+            state = LINKING_TO_OUTGOING;
+            break;
+        case LINKING_TO_OUTGOING:
+            if(nextOut->getEdgeRing() != er) {
+                continue;
+            }
+            assert(incoming);
+            incoming->setNextMin(nextOut);
+            state = SCANNING_FOR_INCOMING;
+            break;
+        }
+    }
+    if(state == LINKING_TO_OUTGOING) {
+        assert(firstOut != nullptr); // found null for first outgoing dirEdge
+        assert(firstOut->getEdgeRing() == er); // unable to link last incoming dirEdge
+        assert(incoming);
+        incoming->setNextMin(firstOut);
+    }
 }
 
 /*public*/
 void
 DirectedEdgeStar::linkAllDirectedEdges()
 {
-	//getEdges();
-
-	// find first area edge (if any) to start linking at
-	DirectedEdge *prevOut=nullptr;
-	DirectedEdge *firstIn=nullptr;
-
-	// link edges in CW order
-	EdgeEndStar::reverse_iterator rbeginIt=rbegin();
-	EdgeEndStar::reverse_iterator rendIt=rend();
-	for(EdgeEndStar::reverse_iterator it=rbeginIt; it!=rendIt; ++it)
-	{
-		assert(*it);
-        	assert(dynamic_cast<DirectedEdge*>(*it));
-        	DirectedEdge *nextOut=static_cast<DirectedEdge*>(*it);
-
-		DirectedEdge *nextIn=nextOut->getSym();
-		assert(nextIn);
-
-		if (firstIn==nullptr) firstIn=nextIn;
-		if (prevOut!=nullptr) nextIn->setNext(prevOut);
-		// record outgoing edge, in order to link the last incoming edge
-		prevOut=nextOut;
-	}
-	assert(firstIn);
-	firstIn->setNext(prevOut);
+    //getEdges();
+
+    // find first area edge (if any) to start linking at
+    DirectedEdge* prevOut = nullptr;
+    DirectedEdge* firstIn = nullptr;
+
+    // link edges in CW order
+    EdgeEndStar::reverse_iterator rbeginIt = rbegin();
+    EdgeEndStar::reverse_iterator rendIt = rend();
+    for(EdgeEndStar::reverse_iterator it = rbeginIt; it != rendIt; ++it) {
+        assert(*it);
+        assert(dynamic_cast<DirectedEdge*>(*it));
+        DirectedEdge* nextOut = static_cast<DirectedEdge*>(*it);
+
+        DirectedEdge* nextIn = nextOut->getSym();
+        assert(nextIn);
+
+        if(firstIn == nullptr) {
+            firstIn = nextIn;
+        }
+        if(prevOut != nullptr) {
+            nextIn->setNext(prevOut);
+        }
+        // record outgoing edge, in order to link the last incoming edge
+        prevOut = nextOut;
+    }
+    assert(firstIn);
+    firstIn->setNext(prevOut);
 }
 
 /*public*/
 void
 DirectedEdgeStar::findCoveredLineEdges()
 {
-	// Since edges are stored in CCW order around the node,
-	// as we move around the ring we move from the right to the left side of the edge
-
-	/**
-	 * Find first DirectedEdge of result area (if any).
-	 * The interior of the result is on the RHS of the edge,
-	 * so the start location will be:
-	 * - INTERIOR if the edge is outgoing
-	 * - EXTERIOR if the edge is incoming
-	 */
-	int startLoc=Location::UNDEF;
-
-	EdgeEndStar::iterator endIt=end();
-	for (EdgeEndStar::iterator it=begin(); it!=endIt; ++it)
-	{
-		assert(*it);
-        	assert(dynamic_cast<DirectedEdge*>(*it));
-        	DirectedEdge *nextOut=static_cast<DirectedEdge*>(*it);
-
-		DirectedEdge *nextIn=nextOut->getSym();
-		assert(nextIn);
-
-		if (!nextOut->isLineEdge()) {
-			if (nextOut->isInResult()) {
-				startLoc=Location::INTERIOR;
-				break;
-			}
-			if (nextIn->isInResult()) {
-				startLoc=Location::EXTERIOR;
-				break;
-			}
-		}
-	}
-
-	// no A edges found, so can't determine if L edges are covered or not
-	if (startLoc==Location::UNDEF) return;
-
-	/**
-	 * move around ring, keeping track of the current location
-	 * (Interior or Exterior) for the result area.
-	 * If L edges are found, mark them as covered if they are in the interior
-	 */
-	int currLoc=startLoc;
-	for (EdgeEndStar::iterator it=begin(); it!=endIt; ++it)
-	{
-		assert(*it);
-        	assert(dynamic_cast<DirectedEdge*>(*it));
-        	DirectedEdge *nextOut=static_cast<DirectedEdge*>(*it);
-
-		DirectedEdge *nextIn=nextOut->getSym();
-		assert(nextIn);
-
-		if (nextOut->isLineEdge()) {
-			nextOut->getEdge()->setCovered(currLoc==Location::INTERIOR);
-		} else {  // edge is an Area edge
-			if (nextOut->isInResult())
-				currLoc=Location::EXTERIOR;
-			if (nextIn->isInResult())
-				currLoc=Location::INTERIOR;
-		}
-	}
+    // Since edges are stored in CCW order around the node,
+    // as we move around the ring we move from the right to the left side of the edge
+
+    /**
+     * Find first DirectedEdge of result area (if any).
+     * The interior of the result is on the RHS of the edge,
+     * so the start location will be:
+     * - INTERIOR if the edge is outgoing
+     * - EXTERIOR if the edge is incoming
+     */
+    int startLoc = Location::UNDEF;
+
+    EdgeEndStar::iterator endIt = end();
+    for(EdgeEndStar::iterator it = begin(); it != endIt; ++it) {
+        assert(*it);
+        assert(dynamic_cast<DirectedEdge*>(*it));
+        DirectedEdge* nextOut = static_cast<DirectedEdge*>(*it);
+
+        DirectedEdge* nextIn = nextOut->getSym();
+        assert(nextIn);
+
+        if(!nextOut->isLineEdge()) {
+            if(nextOut->isInResult()) {
+                startLoc = Location::INTERIOR;
+                break;
+            }
+            if(nextIn->isInResult()) {
+                startLoc = Location::EXTERIOR;
+                break;
+            }
+        }
+    }
+
+    // no A edges found, so can't determine if L edges are covered or not
+    if(startLoc == Location::UNDEF) {
+        return;
+    }
+
+    /**
+     * move around ring, keeping track of the current location
+     * (Interior or Exterior) for the result area.
+     * If L edges are found, mark them as covered if they are in the interior
+     */
+    int currLoc = startLoc;
+    for(EdgeEndStar::iterator it = begin(); it != endIt; ++it) {
+        assert(*it);
+        assert(dynamic_cast<DirectedEdge*>(*it));
+        DirectedEdge* nextOut = static_cast<DirectedEdge*>(*it);
+
+        DirectedEdge* nextIn = nextOut->getSym();
+        assert(nextIn);
+
+        if(nextOut->isLineEdge()) {
+            nextOut->getEdge()->setCovered(currLoc == Location::INTERIOR);
+        }
+        else {    // edge is an Area edge
+            if(nextOut->isInResult()) {
+                currLoc = Location::EXTERIOR;
+            }
+            if(nextIn->isInResult()) {
+                currLoc = Location::INTERIOR;
+            }
+        }
+    }
 }
 
 /*public*/
 void
-DirectedEdgeStar::computeDepths(DirectedEdge *de)
+DirectedEdgeStar::computeDepths(DirectedEdge* de)
 {
-	assert(de);
+    assert(de);
 
-	EdgeEndStar::iterator edgeIterator=find(de);
+    EdgeEndStar::iterator edgeIterator = find(de);
 
-	int startDepth=de->getDepth(Position::LEFT);
-	int targetLastDepth=de->getDepth(Position::RIGHT);
+    int startDepth = de->getDepth(Position::LEFT);
+    int targetLastDepth = de->getDepth(Position::RIGHT);
 
-	// compute the depths from this edge up to the end of the edge array
-	EdgeEndStar::iterator nextEdgeIterator=edgeIterator;
-	++nextEdgeIterator;
-	int nextDepth=computeDepths(nextEdgeIterator, end(), startDepth);
+    // compute the depths from this edge up to the end of the edge array
+    EdgeEndStar::iterator nextEdgeIterator = edgeIterator;
+    ++nextEdgeIterator;
+    int nextDepth = computeDepths(nextEdgeIterator, end(), startDepth);
 
-	// compute the depths for the initial part of the array
-	int lastDepth=computeDepths(begin(), edgeIterator, nextDepth);
+    // compute the depths for the initial part of the array
+    int lastDepth = computeDepths(begin(), edgeIterator, nextDepth);
 
-	if (lastDepth!=targetLastDepth)
-		throw util::TopologyException("depth mismatch at ", de->getCoordinate());
+    if(lastDepth != targetLastDepth) {
+        throw util::TopologyException("depth mismatch at ", de->getCoordinate());
+    }
 }
 
 /*public*/
 int
 DirectedEdgeStar::computeDepths(EdgeEndStar::iterator startIt,
-	EdgeEndStar::iterator endIt, int startDepth)
+                                EdgeEndStar::iterator endIt, int startDepth)
 {
-	int currDepth=startDepth;
-	for (EdgeEndStar::iterator it=startIt; it!=endIt; ++it)
-	{
-		assert(*it);
-        	assert(dynamic_cast<DirectedEdge*>(*it));
-        	DirectedEdge *nextDe=static_cast<DirectedEdge*>(*it);
-
-		nextDe->setEdgeDepths(Position::RIGHT, currDepth);
-		currDepth=nextDe->getDepth(Position::LEFT);
-	}
-	return currDepth;
+    int currDepth = startDepth;
+    for(EdgeEndStar::iterator it = startIt; it != endIt; ++it) {
+        assert(*it);
+        assert(dynamic_cast<DirectedEdge*>(*it));
+        DirectedEdge* nextDe = static_cast<DirectedEdge*>(*it);
+
+        nextDe->setEdgeDepths(Position::RIGHT, currDepth);
+        currDepth = nextDe->getDepth(Position::LEFT);
+    }
+    return currDepth;
 }
 
 /*public*/
 std::string
 DirectedEdgeStar::print() const
 {
-	std::string out="DirectedEdgeStar: " + getCoordinate().toString();
-
-	EdgeEndStar::iterator endIt=end();
-	for (EdgeEndStar::iterator it=begin(); it!=endIt; ++it)
-	{
-		assert(*it);
-        	assert(dynamic_cast<DirectedEdge*>(*it));
-        	DirectedEdge *de=static_cast<DirectedEdge*>(*it);
-		assert(de);
-		out+="out ";
-		out+=de->print();
-		out+="\n";
-		out+="in ";
-		assert(de->getSym());
-		out+=de->getSym()->print();
-		out+="\n";
-	}
-	return out;
+    std::string out = "DirectedEdgeStar: " + getCoordinate().toString();
+
+    EdgeEndStar::iterator endIt = end();
+    for(EdgeEndStar::iterator it = begin(); it != endIt; ++it) {
+        assert(*it);
+        assert(dynamic_cast<DirectedEdge*>(*it));
+        DirectedEdge* de = static_cast<DirectedEdge*>(*it);
+        assert(de);
+        out += "out ";
+        out += de->print();
+        out += "\n";
+        out += "in ";
+        assert(de->getSym());
+        out += de->getSym()->print();
+        out += "\n";
+    }
+    return out;
 }
 
 } // namespace geos.geomgraph
diff --git a/src/geomgraph/Edge.cpp b/src/geomgraph/Edge.cpp
index 38ebd85..5787260 100644
--- a/src/geomgraph/Edge.cpp
+++ b/src/geomgraph/Edge.cpp
@@ -61,67 +61,69 @@ using namespace geos::algorithm;
 void
 Edge::updateIM(const Label& lbl, IntersectionMatrix& im)
 {
-	im.setAtLeastIfValid(lbl.getLocation(0,Position::ON),
-	                      lbl.getLocation(1,Position::ON),
-	                      1);
-	if (lbl.isArea()) {
-
-		im.setAtLeastIfValid(lbl.getLocation(0,Position::LEFT),
-		                      lbl.getLocation(1,Position::LEFT),
-		                      2);
-
-		im.setAtLeastIfValid(lbl.getLocation(0,Position::RIGHT),
-		                      lbl.getLocation(1,Position::RIGHT),
-		                      2);
-	}
+    im.setAtLeastIfValid(lbl.getLocation(0, Position::ON),
+                         lbl.getLocation(1, Position::ON),
+                         1);
+    if(lbl.isArea()) {
+
+        im.setAtLeastIfValid(lbl.getLocation(0, Position::LEFT),
+                             lbl.getLocation(1, Position::LEFT),
+                             2);
+
+        im.setAtLeastIfValid(lbl.getLocation(0, Position::RIGHT),
+                             lbl.getLocation(1, Position::RIGHT),
+                             2);
+    }
 }
 
 /*public*/
 Edge::~Edge()
 {
-	//cerr<<"["<<this<<"] ~Edge()"<<endl;
-	delete mce;
-	delete pts;
-	delete env;
+    //cerr<<"["<<this<<"] ~Edge()"<<endl;
+    delete mce;
+    delete pts;
+    delete env;
 }
 
 /*public*/
 Edge::Edge(CoordinateSequence* newPts, const Label& newLabel)
-	:
-	GraphComponent(newLabel),
-	mce(nullptr),
-	env(nullptr),
-	isIsolatedVar(true),
-	depth(),
-	depthDelta(0),
-	pts(newPts),
-	eiList(this)
+    :
+    GraphComponent(newLabel),
+    mce(nullptr),
+    env(nullptr),
+    isIsolatedVar(true),
+    depth(),
+    depthDelta(0),
+    pts(newPts),
+    eiList(this)
 {
-	testInvariant();
+    testInvariant();
 }
 
 /*public*/
 Edge::Edge(CoordinateSequence* newPts)
-	:
-	GraphComponent(),
-	mce(nullptr),
-	env(nullptr),
-	isIsolatedVar(true),
-	depth(),
-	depthDelta(0),
-	pts(newPts),
-	eiList(this)
+    :
+    GraphComponent(),
+    mce(nullptr),
+    env(nullptr),
+    isIsolatedVar(true),
+    depth(),
+    depthDelta(0),
+    pts(newPts),
+    eiList(this)
 {
-	testInvariant();
+    testInvariant();
 }
 
 /*public*/
 MonotoneChainEdge*
 Edge::getMonotoneChainEdge()
 {
-	testInvariant();
-	if (mce==nullptr) mce=new MonotoneChainEdge(this);
-	return mce;
+    testInvariant();
+    if(mce == nullptr) {
+        mce = new MonotoneChainEdge(this);
+    }
+    return mce;
 }
 
 
@@ -129,192 +131,210 @@ Edge::getMonotoneChainEdge()
 bool
 Edge::isCollapsed() const
 {
-	testInvariant();
-	if (!label.isArea()) return false;
-	if (getNumPoints() != 3) return false;
-	if (pts->getAt(0) == pts->getAt(2)) return true;
-	return false;
+    testInvariant();
+    if(!label.isArea()) {
+        return false;
+    }
+    if(getNumPoints() != 3) {
+        return false;
+    }
+    if(pts->getAt(0) == pts->getAt(2)) {
+        return true;
+    }
+    return false;
 }
 
 Edge*
 Edge::getCollapsedEdge()
 {
-	testInvariant();
-	CoordinateSequence *newPts = new CoordinateArraySequence(2);
-	newPts->setAt(pts->getAt(0),0);
-	newPts->setAt(pts->getAt(1),1);
-	return new Edge(newPts, Label::toLineLabel(label));
+    testInvariant();
+    CoordinateSequence* newPts = new CoordinateArraySequence(2);
+    newPts->setAt(pts->getAt(0), 0);
+    newPts->setAt(pts->getAt(1), 1);
+    return new Edge(newPts, Label::toLineLabel(label));
 }
 
 /*public*/
 void
-Edge::addIntersections(LineIntersector *li, size_t segmentIndex, size_t geomIndex)
+Edge::addIntersections(LineIntersector* li, size_t segmentIndex, size_t geomIndex)
 {
 #if GEOS_DEBUG
-	cerr<<"["<<this<<"] Edge::addIntersections("<<li->toString()<<", "<<segmentIndex<<", "<<geomIndex<<") called"<<endl;
+    cerr << "[" << this << "] Edge::addIntersections(" << li->toString() << ", " << segmentIndex << ", " << geomIndex <<
+         ") called" << endl;
 #endif
-	for (size_t i = 0; i < li->getIntersectionNum(); ++i) {
-		addIntersection(li,segmentIndex,geomIndex,i);
-	}
+    for(size_t i = 0; i < li->getIntersectionNum(); ++i) {
+        addIntersection(li, segmentIndex, geomIndex, i);
+    }
 
-	testInvariant();
+    testInvariant();
 }
 
 /*public*/
 void
-Edge::addIntersection(LineIntersector *li,
-	size_t segmentIndex, size_t geomIndex, size_t intIndex)
+Edge::addIntersection(LineIntersector* li,
+                      size_t segmentIndex, size_t geomIndex, size_t intIndex)
 {
 #if GEOS_DEBUG
-	std::cerr << "["<<this<<"] Edge::addIntersection("<<li->toString()<<", "<<segmentIndex<<", "<<geomIndex<<", "<<intIndex<<") called"<< std::endl;
+    std::cerr << "[" << this << "] Edge::addIntersection(" << li->toString() << ", " << segmentIndex << ", " << geomIndex <<
+              ", " << intIndex << ") called" << std::endl;
 #endif
-	const Coordinate& intPt=li->getIntersection(intIndex);
-	auto normalizedSegmentIndex = segmentIndex;
-	double dist = li->getEdgeDistance(geomIndex, intIndex);
-
-	// normalize the intersection point location
-	auto nextSegIndex = normalizedSegmentIndex + 1;
-	auto npts = getNumPoints();
-	if (nextSegIndex < npts)
-	{
-		const Coordinate& nextPt=pts->getAt(nextSegIndex);
+    const Coordinate& intPt = li->getIntersection(intIndex);
+    auto normalizedSegmentIndex = segmentIndex;
+    double dist = li->getEdgeDistance(geomIndex, intIndex);
+
+    // normalize the intersection point location
+    auto nextSegIndex = normalizedSegmentIndex + 1;
+    auto npts = getNumPoints();
+    if(nextSegIndex < npts) {
+        const Coordinate& nextPt = pts->getAt(nextSegIndex);
         // Normalize segment index if intPt falls on vertex
         // The check for point equality is 2D only - Z values are ignored
-		if (intPt.equals2D(nextPt)) {
-			normalizedSegmentIndex=nextSegIndex;
-			dist=0.0;
-		}
-	}
-
-	/*
-	 * Add the intersection point to edge intersection list.
-	 */
+        if(intPt.equals2D(nextPt)) {
+            normalizedSegmentIndex = nextSegIndex;
+            dist = 0.0;
+        }
+    }
+
+    /*
+     * Add the intersection point to edge intersection list.
+     */
 #if GEOS_DEBUG
-	cerr<<"Edge::addIntersection adding to edge intersection list point "<<intPt.toString()<<endl;
+    cerr << "Edge::addIntersection adding to edge intersection list point " << intPt.toString() << endl;
 #endif
-	eiList.add(intPt,normalizedSegmentIndex,dist);
+    eiList.add(intPt, normalizedSegmentIndex, dist);
 
-	testInvariant();
+    testInvariant();
 }
 
 /*public*/
 bool
 Edge::equals(const Edge& e) const
 {
-	testInvariant();
-
-	auto npts1 = getNumPoints();
-	auto npts2 = e.getNumPoints();
-
-	if (npts1 != npts2 ) return false;
-
-	bool isEqualForward=true;
-	bool isEqualReverse=true;
-
-	for (size_t i = 0, iRev = npts1 - 1; i < npts1; ++i, --iRev)
-	{
-		const Coordinate &e1pi=pts->getAt(i);
-		const Coordinate &e2pi=e.pts->getAt(i);
-		const Coordinate &e2piRev=e.pts->getAt(iRev);
-
-		if ( !e1pi.equals2D(e2pi) ) isEqualForward=false;
-		if ( !e1pi.equals2D(e2piRev) ) isEqualReverse=false;
-		if ( !isEqualForward && !isEqualReverse ) return false;
-	}
-	return true;
+    testInvariant();
+
+    auto npts1 = getNumPoints();
+    auto npts2 = e.getNumPoints();
+
+    if(npts1 != npts2) {
+        return false;
+    }
+
+    bool isEqualForward = true;
+    bool isEqualReverse = true;
+
+    for(size_t i = 0, iRev = npts1 - 1; i < npts1; ++i, --iRev) {
+        const Coordinate& e1pi = pts->getAt(i);
+        const Coordinate& e2pi = e.pts->getAt(i);
+        const Coordinate& e2piRev = e.pts->getAt(iRev);
+
+        if(!e1pi.equals2D(e2pi)) {
+            isEqualForward = false;
+        }
+        if(!e1pi.equals2D(e2piRev)) {
+            isEqualReverse = false;
+        }
+        if(!isEqualForward && !isEqualReverse) {
+            return false;
+        }
+    }
+    return true;
 }
 
 /*public*/
 bool
-Edge::isPointwiseEqual(const Edge *e) const
+Edge::isPointwiseEqual(const Edge* e) const
 {
-	testInvariant();
+    testInvariant();
 
 #if GEOS_DEBUG > 2
-	cerr<<"Edge::isPointwiseEqual call"<<endl;
+    cerr << "Edge::isPointwiseEqual call" << endl;
 #endif
-	auto npts = getNumPoints();
-	auto enpts = e->getNumPoints();
-	if (npts!=enpts) return false;
+    auto npts = getNumPoints();
+    auto enpts = e->getNumPoints();
+    if(npts != enpts) {
+        return false;
+    }
 #if GEOS_DEBUG
-	cerr<<"Edge::isPointwiseEqual scanning "<<enpts<<"x"<<npts<<" points"<<endl;
+    cerr << "Edge::isPointwiseEqual scanning " << enpts << "x" << npts << " points" << endl;
 #endif
-	for (unsigned int i=0; i<npts; ++i)
-	{
-		if (!pts->getAt(i).equals2D(e->pts->getAt(i))) {
-			return false;
-		}
-	}
-	return true;
+    for(unsigned int i = 0; i < npts; ++i) {
+        if(!pts->getAt(i).equals2D(e->pts->getAt(i))) {
+            return false;
+        }
+    }
+    return true;
 }
 
 string
 Edge::print() const
 {
-	testInvariant();
+    testInvariant();
 
-	std::stringstream ss;
-	ss << *this;
-	return ss.str();
+    std::stringstream ss;
+    ss << *this;
+    return ss.str();
 }
 
 // Dunno how to implemente this in terms of operator<<
 string
 Edge::printReverse() const
 {
-	testInvariant();
-
-	stringstream os;
-
-	os << "EDGE (rev)";
-	if ( name != "" ) os << " name:" << name;
-
-	os << " label:" << label
-	   << " depthDelta:" << depthDelta
-	   << ":" << std::endl
-	   << "  LINESTRING(";
-	auto npts=getNumPoints();
-	for (auto i=npts; i>0; --i)
-	{
-		if (i<npts) os << ", ";
-		os << pts->getAt(i-1).toString();
-	}
-	os << ")";
-
-	return os.str();
+    testInvariant();
+
+    stringstream os;
+
+    os << "EDGE (rev)";
+    if(name != "") {
+        os << " name:" << name;
+    }
+
+    os << " label:" << label
+       << " depthDelta:" << depthDelta
+       << ":" << std::endl
+       << "  LINESTRING(";
+    auto npts = getNumPoints();
+    for(auto i = npts; i > 0; --i) {
+        if(i < npts) {
+            os << ", ";
+        }
+        os << pts->getAt(i - 1).toString();
+    }
+    os << ")";
+
+    return os.str();
 }
 
 Envelope*
 Edge::getEnvelope()
 {
-	// compute envelope lazily
-	if (env==nullptr)
-	{
-		env=new Envelope();
-		auto npts=getNumPoints();
-		for (size_t i = 0; i < npts; ++i)
-		{
-			env->expandToInclude(pts->getAt(i));
-		}
-	}
-	testInvariant();
-	return env;
+    // compute envelope lazily
+    if(env == nullptr) {
+        env = new Envelope();
+        auto npts = getNumPoints();
+        for(size_t i = 0; i < npts; ++i) {
+            env->expandToInclude(pts->getAt(i));
+        }
+    }
+    testInvariant();
+    return env;
 }
 
 std::ostream&
-operator<< (std::ostream&os, const Edge& e)
+operator<< (std::ostream& os, const Edge& e)
 {
-	os << "edge";
-	if ( e.name != "" ) os << " " << e.name;
-
-	os
-	   << "  LINESTRING"
-	   << *(e.pts)
-	   << "  " << e.label
-	   << "  " << e.depthDelta
-	   ;
-
-	return os;
+    os << "edge";
+    if(e.name != "") {
+        os << " " << e.name;
+    }
+
+    os
+            << "  LINESTRING"
+            << *(e.pts)
+            << "  " << e.label
+            << "  " << e.depthDelta
+            ;
+
+    return os;
 }
 
 } // namespace geos.geomgraph
diff --git a/src/geomgraph/EdgeEnd.cpp b/src/geomgraph/EdgeEnd.cpp
index d5ebcdd..4ee7239 100644
--- a/src/geomgraph/EdgeEnd.cpp
+++ b/src/geomgraph/EdgeEnd.cpp
@@ -41,177 +41,182 @@ using namespace geos::algorithm;
 
 /*public*/
 EdgeEnd::EdgeEnd()
-	:
-	edge(nullptr),
-	label(),
-	node(nullptr),
-	dx(0.0),
-	dy(0.0),
-	quadrant(0)
+    :
+    edge(nullptr),
+    label(),
+    node(nullptr),
+    dx(0.0),
+    dy(0.0),
+    quadrant(0)
 {
 }
 
 /*protected*/
 EdgeEnd::EdgeEnd(Edge* newEdge)
-	:
-	edge(newEdge),
-	label(),
-	node(nullptr),
-	dx(0.0),
-	dy(0.0),
-	quadrant(0)
+    :
+    edge(newEdge),
+    label(),
+    node(nullptr),
+    dx(0.0),
+    dy(0.0),
+    quadrant(0)
 {
 }
 
 /*public*/
 EdgeEnd::EdgeEnd(Edge* newEdge, const Coordinate& newP0,
-		const Coordinate& newP1, const Label& newLabel)
-	:
-	edge(newEdge),
-	label(newLabel),
-	node(nullptr),
-	dx(0.0),
-	dy(0.0),
-	quadrant(0)
+                 const Coordinate& newP1, const Label& newLabel)
+    :
+    edge(newEdge),
+    label(newLabel),
+    node(nullptr),
+    dx(0.0),
+    dy(0.0),
+    quadrant(0)
 {
-	init(newP0, newP1);
+    init(newP0, newP1);
 }
 
 /*public*/
 EdgeEnd::EdgeEnd(Edge* newEdge, const Coordinate& newP0,
-		const Coordinate& newP1)
-	:
-	edge(newEdge),
-	label(),
-	node(nullptr),
-	dx(0.0),
-	dy(0.0),
-	quadrant(0)
+                 const Coordinate& newP1)
+    :
+    edge(newEdge),
+    label(),
+    node(nullptr),
+    dx(0.0),
+    dy(0.0),
+    quadrant(0)
 {
-	init(newP0, newP1);
+    init(newP0, newP1);
 }
 
 /*public*/
 void
 EdgeEnd::init(const Coordinate& newP0, const Coordinate& newP1)
 {
-	p0=newP0;
-	p1=newP1;
-	dx=p1.x-p0.x;
-	dy=p1.y-p0.y;
-	quadrant=Quadrant::quadrant(dx,dy);
+    p0 = newP0;
+    p1 = newP1;
+    dx = p1.x - p0.x;
+    dy = p1.y - p0.y;
+    quadrant = Quadrant::quadrant(dx, dy);
 
-	// "EdgeEnd with identical endpoints found");
-	assert(!(dx == 0 && dy == 0));
+    // "EdgeEnd with identical endpoints found");
+    assert(!(dx == 0 && dy == 0));
 }
 
 /*public*/
 Coordinate&
 EdgeEnd::getCoordinate()
 {
-	return p0;
+    return p0;
 }
 
 /*public*/
 Coordinate&
 EdgeEnd::getDirectedCoordinate()
 {
-	return p1;
+    return p1;
 }
 
 /*public*/
 int
 EdgeEnd::getQuadrant()
 {
-	return quadrant;
+    return quadrant;
 }
 
 /*public*/
 double
 EdgeEnd::getDx()
 {
-	return dx;
+    return dx;
 }
 
 /*public*/
 double
 EdgeEnd::getDy()
 {
-	return dy;
+    return dy;
 }
 
 /*public*/
 void
 EdgeEnd::setNode(Node* newNode)
 {
-	node=newNode;
-	assert(node->getCoordinate().equals2D(p0));
+    node = newNode;
+    assert(node->getCoordinate().equals2D(p0));
 }
 
 /*public*/
 Node*
 EdgeEnd::getNode()
 {
-	return node;
+    return node;
 }
 
 /*public*/
 int
 EdgeEnd::compareTo(const EdgeEnd* e) const
 {
-	return compareDirection(e);
+    return compareDirection(e);
 }
 
 /*public*/
 int
 EdgeEnd::compareDirection(const EdgeEnd* e) const
 {
-	assert(e);
-	if (dx == e->dx && dy == e->dy)
-		return 0;
+    assert(e);
+    if(dx == e->dx && dy == e->dy) {
+        return 0;
+    }
 
-	// if the rays are in different quadrants,
-	// determining the ordering is trivial
-	if (quadrant>e->quadrant) return 1;
-	if (quadrant<e->quadrant) return -1;
+    // if the rays are in different quadrants,
+    // determining the ordering is trivial
+    if(quadrant > e->quadrant) {
+        return 1;
+    }
+    if(quadrant < e->quadrant) {
+        return -1;
+    }
 
-	// vectors are in the same quadrant - check relative
-	// orientation of direction vectors
-	// this is > e if it is CCW of e
-	return Orientation::index(e->p0, e->p1, p1);
+    // vectors are in the same quadrant - check relative
+    // orientation of direction vectors
+    // this is > e if it is CCW of e
+    return Orientation::index(e->p0, e->p1, p1);
 }
 
 /*public*/
 void
 EdgeEnd::computeLabel(const algorithm::BoundaryNodeRule& /*boundaryNodeRule*/)
 {
-	// subclasses should override this if they are using labels
+    // subclasses should override this if they are using labels
 }
 
 /*public*/
 std::string
 EdgeEnd::print() const
 {
-	std::ostringstream s;
+    std::ostringstream s;
 
-	s<<*this;
+    s << *this;
 
-	return s.str();
+    return s.str();
 }
 
 std::ostream&
 operator<< (std::ostream& os, const EdgeEnd& ee)
 {
-	os << "EdgeEnd: ";
-	os << ee.p0;
-	os << " - ";
-	os << ee.p1;
-	os << " ";
-	os << ee.quadrant << ":" << std::atan2(ee.dy, ee.dx);
-	os << "  ";
-	os << ee.label;
+    os << "EdgeEnd: ";
+    os << ee.p0;
+    os << " - ";
+    os << ee.p1;
+    os << " ";
+    os << ee.quadrant << ":" << std::atan2(ee.dy, ee.dx);
+    os << "  ";
+    os << ee.label;
 
-	return os;
+    return os;
 }
 
 
diff --git a/src/geomgraph/EdgeEndStar.cpp b/src/geomgraph/EdgeEndStar.cpp
index f10e391..4d601d0 100644
--- a/src/geomgraph/EdgeEndStar.cpp
+++ b/src/geomgraph/EdgeEndStar.cpp
@@ -44,324 +44,327 @@ namespace geomgraph { // geos.geomgraph
 
 /*public*/
 EdgeEndStar::EdgeEndStar()
-	:
-	edgeMap()
+    :
+    edgeMap()
 {
-	ptInAreaLocation[0]=Location::UNDEF;
-	ptInAreaLocation[1]=Location::UNDEF;
+    ptInAreaLocation[0] = Location::UNDEF;
+    ptInAreaLocation[1] = Location::UNDEF;
 }
 
 /*public*/
 Coordinate&
 EdgeEndStar::getCoordinate()
 {
-	static Coordinate nullCoord(DoubleNotANumber, DoubleNotANumber, DoubleNotANumber);
-	if (edgeMap.empty()) return nullCoord;
-
-	EdgeEndStar::iterator it=begin();
-	EdgeEnd *e=*it;
-	assert(e);
-	return e->getCoordinate();
+    static Coordinate nullCoord(DoubleNotANumber, DoubleNotANumber, DoubleNotANumber);
+    if(edgeMap.empty()) {
+        return nullCoord;
+    }
+
+    EdgeEndStar::iterator it = begin();
+    EdgeEnd* e = *it;
+    assert(e);
+    return e->getCoordinate();
 }
 
 /*public*/
 const Coordinate&
 EdgeEndStar::getCoordinate() const
 {
-	return const_cast<EdgeEndStar*>(this)->getCoordinate();
+    return const_cast<EdgeEndStar*>(this)->getCoordinate();
 }
 
 /*public*/
 EdgeEnd*
-EdgeEndStar::getNextCW(EdgeEnd *ee)
+EdgeEndStar::getNextCW(EdgeEnd* ee)
 {
-	EdgeEndStar::iterator it=find(ee);
-	if ( it==end() ) return nullptr;
-	if ( it==begin() ) { it=end(); --it; }
-	else --it;
-	return *it;
+    EdgeEndStar::iterator it = find(ee);
+    if(it == end()) {
+        return nullptr;
+    }
+    if(it == begin()) {
+        it = end();
+        --it;
+    }
+    else {
+        --it;
+    }
+    return *it;
 }
 
 /*public*/
 void
-EdgeEndStar::computeLabelling(std::vector<GeometryGraph*> *geomGraph)
-	//throw(TopologyException *)
+EdgeEndStar::computeLabelling(std::vector<GeometryGraph*>* geomGraph)
+//throw(TopologyException *)
 {
-	computeEdgeEndLabels((*geomGraph)[0]->getBoundaryNodeRule());
-
-	// Propagate side labels  around the edges in the star
-	// for each parent Geometry
-	//
-	// these calls can throw a TopologyException
-	propagateSideLabels(0);
-	propagateSideLabels(1);
-
-	/**
-	 * If there are edges that still have null labels for a geometry
-	 * this must be because there are no area edges for that geometry
-	 * incident on this node.
-	 * In this case, to label the edge for that geometry we must test
-	 * whether the edge is in the interior of the geometry.
-	 * To do this it suffices to determine whether the node for the
-	 * edge is in the interior of an area.
-	 * If so, the edge has location INTERIOR for the geometry.
-	 * In all other cases (e.g. the node is on a line, on a point, or
-	 * not on the geometry at all) the edge
-	 * has the location EXTERIOR for the geometry.
-	 *
-	 * Note that the edge cannot be on the BOUNDARY of the geometry,
-	 * since then there would have been a parallel edge from the
-	 * Geometry at this node also labelled BOUNDARY
-	 * and this edge would have been labelled in the previous step.
-	 *
-	 * This code causes a problem when dimensional collapses are present,
-	 * since it may try and determine the location of a node where a
-	 * dimensional collapse has occurred.
-	 * The point should be considered to be on the EXTERIOR
-	 * of the polygon, but locate() will return INTERIOR, since it is
-	 * passed the original Geometry, not the collapsed version.
-	 *
-	 * If there are incident edges which are Line edges labelled BOUNDARY,
-	 * then they must be edges resulting from dimensional collapses.
-	 * In this case the other edges can be labelled EXTERIOR for this
-	 * Geometry.
-	 *
-	 * MD 8/11/01 - NOT TRUE!  The collapsed edges may in fact be in the
-	 * interior of the Geometry, which means the other edges should be
-	 * labelled INTERIOR for this Geometry.
-	 * Not sure how solve this...  Possibly labelling needs to be split
-	 * into several phases:
-	 * area label propagation, symLabel merging, then finally null label
-	 * resolution.
-	 */
-	bool hasDimensionalCollapseEdge[2]={false,false};
-
-	EdgeEndStar::iterator endIt=end();
-	for (EdgeEndStar::iterator it=begin(); it!=endIt; ++it)
-	{
-		EdgeEnd *e=*it;
-		assert(e);
-		const Label& label = e->getLabel();
-		for(int geomi=0; geomi<2; geomi++)
-		{
-			if (label.isLine(geomi) && label.getLocation(geomi) == Location::BOUNDARY)
-				hasDimensionalCollapseEdge[geomi]=true;
-		}
-	}
-
-	for (EdgeEndStar::iterator it=begin(); it!=end(); ++it)
-	{
-		EdgeEnd *e=*it;
-		assert(e);
-		Label& label = e->getLabel();
-		for(int geomi=0; geomi<2; ++geomi)
-		{
-			if (label.isAnyNull(geomi)) {
-				int loc=Location::UNDEF;
-				if (hasDimensionalCollapseEdge[geomi]){
-					loc=Location::EXTERIOR;
-				}else {
-					Coordinate& p=e->getCoordinate();
-					loc = getLocation(geomi, p, geomGraph);
-				}
-				label.setAllLocationsIfNull(geomi, loc);
-			}
-		}
-	}
+    computeEdgeEndLabels((*geomGraph)[0]->getBoundaryNodeRule());
+
+    // Propagate side labels  around the edges in the star
+    // for each parent Geometry
+    //
+    // these calls can throw a TopologyException
+    propagateSideLabels(0);
+    propagateSideLabels(1);
+
+    /**
+     * If there are edges that still have null labels for a geometry
+     * this must be because there are no area edges for that geometry
+     * incident on this node.
+     * In this case, to label the edge for that geometry we must test
+     * whether the edge is in the interior of the geometry.
+     * To do this it suffices to determine whether the node for the
+     * edge is in the interior of an area.
+     * If so, the edge has location INTERIOR for the geometry.
+     * In all other cases (e.g. the node is on a line, on a point, or
+     * not on the geometry at all) the edge
+     * has the location EXTERIOR for the geometry.
+     *
+     * Note that the edge cannot be on the BOUNDARY of the geometry,
+     * since then there would have been a parallel edge from the
+     * Geometry at this node also labelled BOUNDARY
+     * and this edge would have been labelled in the previous step.
+     *
+     * This code causes a problem when dimensional collapses are present,
+     * since it may try and determine the location of a node where a
+     * dimensional collapse has occurred.
+     * The point should be considered to be on the EXTERIOR
+     * of the polygon, but locate() will return INTERIOR, since it is
+     * passed the original Geometry, not the collapsed version.
+     *
+     * If there are incident edges which are Line edges labelled BOUNDARY,
+     * then they must be edges resulting from dimensional collapses.
+     * In this case the other edges can be labelled EXTERIOR for this
+     * Geometry.
+     *
+     * MD 8/11/01 - NOT TRUE!  The collapsed edges may in fact be in the
+     * interior of the Geometry, which means the other edges should be
+     * labelled INTERIOR for this Geometry.
+     * Not sure how solve this...  Possibly labelling needs to be split
+     * into several phases:
+     * area label propagation, symLabel merging, then finally null label
+     * resolution.
+     */
+    bool hasDimensionalCollapseEdge[2] = {false, false};
+
+    EdgeEndStar::iterator endIt = end();
+    for(EdgeEndStar::iterator it = begin(); it != endIt; ++it) {
+        EdgeEnd* e = *it;
+        assert(e);
+        const Label& label = e->getLabel();
+        for(int geomi = 0; geomi < 2; geomi++) {
+            if(label.isLine(geomi) && label.getLocation(geomi) == Location::BOUNDARY) {
+                hasDimensionalCollapseEdge[geomi] = true;
+            }
+        }
+    }
+
+    for(EdgeEndStar::iterator it = begin(); it != end(); ++it) {
+        EdgeEnd* e = *it;
+        assert(e);
+        Label& label = e->getLabel();
+        for(int geomi = 0; geomi < 2; ++geomi) {
+            if(label.isAnyNull(geomi)) {
+                int loc = Location::UNDEF;
+                if(hasDimensionalCollapseEdge[geomi]) {
+                    loc = Location::EXTERIOR;
+                }
+                else {
+                    Coordinate& p = e->getCoordinate();
+                    loc = getLocation(geomi, p, geomGraph);
+                }
+                label.setAllLocationsIfNull(geomi, loc);
+            }
+        }
+    }
 }
 
 /*private*/
 void
 EdgeEndStar::computeEdgeEndLabels(
-		const algorithm::BoundaryNodeRule& boundaryNodeRule)
+    const algorithm::BoundaryNodeRule& boundaryNodeRule)
 {
-	// Compute edge label for each EdgeEnd
-	for (EdgeEndStar::iterator it=begin(); it!=end(); ++it)
-	{
-		EdgeEnd *ee=*it;
-		assert(ee);
-		ee->computeLabel(boundaryNodeRule);
-	}
+    // Compute edge label for each EdgeEnd
+    for(EdgeEndStar::iterator it = begin(); it != end(); ++it) {
+        EdgeEnd* ee = *it;
+        assert(ee);
+        ee->computeLabel(boundaryNodeRule);
+    }
 }
 
 /*public*/
 int
 EdgeEndStar::getLocation(int geomIndex,
-	const Coordinate& p, std::vector<GeometryGraph*> *geom)
+                         const Coordinate& p, std::vector<GeometryGraph*>* geom)
 {
-	// compute location only on demand
-	if (ptInAreaLocation[geomIndex]==Location::UNDEF)
-	{
-		ptInAreaLocation[geomIndex]=algorithm::locate::SimplePointInAreaLocator::locate(p,
-				(*geom)[geomIndex]->getGeometry());
-	}
-	return ptInAreaLocation[geomIndex];
+    // compute location only on demand
+    if(ptInAreaLocation[geomIndex] == Location::UNDEF) {
+        ptInAreaLocation[geomIndex] = algorithm::locate::SimplePointInAreaLocator::locate(p,
+                                      (*geom)[geomIndex]->getGeometry());
+    }
+    return ptInAreaLocation[geomIndex];
 }
 
 /*public*/
 bool
 EdgeEndStar::isAreaLabelsConsistent(const GeometryGraph& geomGraph)
 {
-	computeEdgeEndLabels(geomGraph.getBoundaryNodeRule());
-	return checkAreaLabelsConsistent(0);
+    computeEdgeEndLabels(geomGraph.getBoundaryNodeRule());
+    return checkAreaLabelsConsistent(0);
 }
 
 /*private*/
 bool
 EdgeEndStar::checkAreaLabelsConsistent(int geomIndex)
 {
-	// Since edges are stored in CCW order around the node,
-	// As we move around the ring we move from the right to
-	// the left side of the edge
-
-	// if no edges, trivially consistent
-	if (edgeMap.empty()) return true;
-
-	// initialize startLoc to location of last L side (if any)
-	assert(*rbegin());
-	const Label& startLabel = (*rbegin())->getLabel();
-	int startLoc = startLabel.getLocation(geomIndex, Position::LEFT);
-
-	// Found unlabelled area edge
-	assert(startLoc!=Location::UNDEF);
-
-	int currLoc=startLoc;
-
-	for (EdgeEndStar::iterator it=begin(), itEnd=end(); it!=itEnd; ++it)
-	{
-		EdgeEnd *e=*it;
-		assert(e);
-		const Label& eLabel = e->getLabel();
-
-		// we assume that we are only checking a area
-
-		// Found non-area edge
-		assert(eLabel.isArea(geomIndex));
-
-		int leftLoc=eLabel.getLocation(geomIndex, Position::LEFT);
-		int rightLoc=eLabel.getLocation(geomIndex, Position::RIGHT);
-		// check that edge is really a boundary between inside and outside!
-		if (leftLoc==rightLoc) {
-			return false;
-		}
-		// check side location conflict
-		//assert(rightLoc == currLoc); // "side location conflict " + locStr);
-		if (rightLoc!=currLoc) {
-			return false;
-		}
-		currLoc=leftLoc;
-	}
-	return true;
+    // Since edges are stored in CCW order around the node,
+    // As we move around the ring we move from the right to
+    // the left side of the edge
+
+    // if no edges, trivially consistent
+    if(edgeMap.empty()) {
+        return true;
+    }
+
+    // initialize startLoc to location of last L side (if any)
+    assert(*rbegin());
+    const Label& startLabel = (*rbegin())->getLabel();
+    int startLoc = startLabel.getLocation(geomIndex, Position::LEFT);
+
+    // Found unlabelled area edge
+    assert(startLoc != Location::UNDEF);
+
+    int currLoc = startLoc;
+
+    for(EdgeEndStar::iterator it = begin(), itEnd = end(); it != itEnd; ++it) {
+        EdgeEnd* e = *it;
+        assert(e);
+        const Label& eLabel = e->getLabel();
+
+        // we assume that we are only checking a area
+
+        // Found non-area edge
+        assert(eLabel.isArea(geomIndex));
+
+        int leftLoc = eLabel.getLocation(geomIndex, Position::LEFT);
+        int rightLoc = eLabel.getLocation(geomIndex, Position::RIGHT);
+        // check that edge is really a boundary between inside and outside!
+        if(leftLoc == rightLoc) {
+            return false;
+        }
+        // check side location conflict
+        //assert(rightLoc == currLoc); // "side location conflict " + locStr);
+        if(rightLoc != currLoc) {
+            return false;
+        }
+        currLoc = leftLoc;
+    }
+    return true;
 }
 
 /*public*/
 void
 EdgeEndStar::propagateSideLabels(int geomIndex)
-	//throw(TopologyException *)
+//throw(TopologyException *)
 {
-	// Since edges are stored in CCW order around the node,
-	// As we move around the ring we move from the right to the
-	// left side of the edge
-	int startLoc=Location::UNDEF;
-
-	EdgeEndStar::iterator beginIt=begin();
-	EdgeEndStar::iterator endIt=end();
-	EdgeEndStar::iterator it;
-
-	// initialize loc to location of last L side (if any)
-	for (it=beginIt; it!=endIt; ++it)
-	{
-		EdgeEnd *e=*it;
-		assert(e);
-		const Label& label = e->getLabel();
-		if (label.isArea(geomIndex) &&
-		    label.getLocation(geomIndex,Position::LEFT) != Location::UNDEF)
-		{
-			startLoc = label.getLocation(geomIndex, Position::LEFT);
-		}
-	}
-
-	// no labelled sides found, so no labels to propagate
-	if (startLoc==Location::UNDEF) return;
-
-	int currLoc=startLoc;
-	for (it=beginIt; it!=endIt; ++it)
-	{
-		EdgeEnd *e=*it;
-		assert(e);
-		Label& label = e->getLabel();
-		// set null ON values to be in current location
-		if (label.getLocation(geomIndex,Position::ON) == Location::UNDEF)
-		{
-			label.setLocation(geomIndex,Position::ON,currLoc);
-		}
-
-		// set side labels (if any)
-		// if (label.isArea())  //ORIGINAL
-		if (label.isArea(geomIndex))
-		{
-			int leftLoc=label.getLocation(geomIndex,
-				Position::LEFT);
-
-			int rightLoc=label.getLocation(geomIndex,
-				Position::RIGHT);
-
-			// if there is a right location, that is the next
-			// location to propagate
-			if (rightLoc!=Location::UNDEF) {
-				if (rightLoc!=currLoc)
-					throw util::TopologyException("side location conflict",
-						e->getCoordinate());
-				if (leftLoc==Location::UNDEF) {
-					// found single null side at e->getCoordinate()
-					assert(0);
-				}
-				currLoc=leftLoc;
-			} else {
-				/**
-				 * RHS is null - LHS must be null too.
-				 * This must be an edge from the other
-				 * geometry, which has no location
-				 * labelling for this geometry.
-				 * This edge must lie wholly inside or
-				 * outside the other geometry (which is
-				 * determined by the current location).
-				 * Assign both sides to be the current
-				 * location.
-				 */
-				// found single null side
-				assert(label.getLocation(geomIndex,
-					Position::LEFT)==Location::UNDEF);
-
-				label.setLocation(geomIndex,Position::RIGHT,
-					currLoc);
-				label.setLocation(geomIndex,Position::LEFT,
-					currLoc);
-			}
-		}
-	}
+    // Since edges are stored in CCW order around the node,
+    // As we move around the ring we move from the right to the
+    // left side of the edge
+    int startLoc = Location::UNDEF;
+
+    EdgeEndStar::iterator beginIt = begin();
+    EdgeEndStar::iterator endIt = end();
+    EdgeEndStar::iterator it;
+
+    // initialize loc to location of last L side (if any)
+    for(it = beginIt; it != endIt; ++it) {
+        EdgeEnd* e = *it;
+        assert(e);
+        const Label& label = e->getLabel();
+        if(label.isArea(geomIndex) &&
+                label.getLocation(geomIndex, Position::LEFT) != Location::UNDEF) {
+            startLoc = label.getLocation(geomIndex, Position::LEFT);
+        }
+    }
+
+    // no labelled sides found, so no labels to propagate
+    if(startLoc == Location::UNDEF) {
+        return;
+    }
+
+    int currLoc = startLoc;
+    for(it = beginIt; it != endIt; ++it) {
+        EdgeEnd* e = *it;
+        assert(e);
+        Label& label = e->getLabel();
+        // set null ON values to be in current location
+        if(label.getLocation(geomIndex, Position::ON) == Location::UNDEF) {
+            label.setLocation(geomIndex, Position::ON, currLoc);
+        }
+
+        // set side labels (if any)
+        // if (label.isArea())  //ORIGINAL
+        if(label.isArea(geomIndex)) {
+            int leftLoc = label.getLocation(geomIndex,
+                                            Position::LEFT);
+
+            int rightLoc = label.getLocation(geomIndex,
+                                             Position::RIGHT);
+
+            // if there is a right location, that is the next
+            // location to propagate
+            if(rightLoc != Location::UNDEF) {
+                if(rightLoc != currLoc)
+                    throw util::TopologyException("side location conflict",
+                                                  e->getCoordinate());
+                if(leftLoc == Location::UNDEF) {
+                    // found single null side at e->getCoordinate()
+                    assert(0);
+                }
+                currLoc = leftLoc;
+            }
+            else {
+                /**
+                 * RHS is null - LHS must be null too.
+                 * This must be an edge from the other
+                 * geometry, which has no location
+                 * labelling for this geometry.
+                 * This edge must lie wholly inside or
+                 * outside the other geometry (which is
+                 * determined by the current location).
+                 * Assign both sides to be the current
+                 * location.
+                 */
+                // found single null side
+                assert(label.getLocation(geomIndex,
+                                         Position::LEFT) == Location::UNDEF);
+
+                label.setLocation(geomIndex, Position::RIGHT,
+                                  currLoc);
+                label.setLocation(geomIndex, Position::LEFT,
+                                  currLoc);
+            }
+        }
+    }
 }
 
 /*public*/
 std::string
 EdgeEndStar::print() const
 {
-	std::ostringstream s;
-  s << *this;
-  return s.str();
+    std::ostringstream s;
+    s << *this;
+    return s.str();
 }
 
 std::ostream&
 operator<< (std::ostream& os, const EdgeEndStar& es)
 {
-	os << "EdgeEndStar:   " << es.getCoordinate() << "\n";
-	for (EdgeEndStar::const_iterator it=es.begin(), itEnd=es.end(); it!=itEnd; ++it)
-	{
-		const EdgeEnd *e=*it;
-		assert(e);
-		os << *e;
-	}
-	return os;
+    os << "EdgeEndStar:   " << es.getCoordinate() << "\n";
+    for(EdgeEndStar::const_iterator it = es.begin(), itEnd = es.end(); it != itEnd; ++it) {
+        const EdgeEnd* e = *it;
+        assert(e);
+        os << *e;
+    }
+    return os;
 }
 
 } // namespace geos.geomgraph
diff --git a/src/geomgraph/EdgeIntersectionList.cpp b/src/geomgraph/EdgeIntersectionList.cpp
index cc41ed7..9ee0776 100644
--- a/src/geomgraph/EdgeIntersectionList.cpp
+++ b/src/geomgraph/EdgeIntersectionList.cpp
@@ -46,155 +46,154 @@ using namespace geos::geom;
 namespace geos {
 namespace geomgraph { // geos.geomgraph
 
-EdgeIntersectionList::EdgeIntersectionList(Edge *newEdge):
-	edge(newEdge)
+EdgeIntersectionList::EdgeIntersectionList(Edge* newEdge):
+    edge(newEdge)
 {
 }
 
 EdgeIntersectionList::~EdgeIntersectionList()
 {
-	for (EdgeIntersectionList::iterator it=nodeMap.begin(),
-		endIt=nodeMap.end();
-		it!=endIt; ++it)
-	{
-		delete *it;
-	}
+    for(EdgeIntersectionList::iterator it = nodeMap.begin(),
+            endIt = nodeMap.end();
+            it != endIt; ++it) {
+        delete *it;
+    }
 }
 
 EdgeIntersection*
 EdgeIntersectionList::add(const Coordinate& coord,
-	size_t segmentIndex, double dist)
+                          size_t segmentIndex, double dist)
 {
-	EdgeIntersection *eiNew=new EdgeIntersection(coord, segmentIndex, dist);
-
-	pair<EdgeIntersectionList::iterator, bool> p = nodeMap.insert(eiNew);
-	if ( p.second ) { // new EdgeIntersection inserted
-		return eiNew;
-	} else {
-		delete eiNew;
-		return *(p.first);
-	}
+    EdgeIntersection* eiNew = new EdgeIntersection(coord, segmentIndex, dist);
+
+    pair<EdgeIntersectionList::iterator, bool> p = nodeMap.insert(eiNew);
+    if(p.second) {    // new EdgeIntersection inserted
+        return eiNew;
+    }
+    else {
+        delete eiNew;
+        return *(p.first);
+    }
 }
 
 bool
 EdgeIntersectionList::isEmpty() const
 {
-	return nodeMap.empty();
+    return nodeMap.empty();
 }
 
 bool
 EdgeIntersectionList::isIntersection(const Coordinate& pt) const
 {
-	EdgeIntersectionList::const_iterator
-		it=nodeMap.begin(),
-		endIt=nodeMap.end();
-
-	for (; it!=endIt; ++it)
-	{
-		EdgeIntersection *ei=*it;
-		if (ei->coord==pt) return true;
-	}
-	return false;
+    EdgeIntersectionList::const_iterator
+    it = nodeMap.begin(),
+    endIt = nodeMap.end();
+
+    for(; it != endIt; ++it) {
+        EdgeIntersection* ei = *it;
+        if(ei->coord == pt) {
+            return true;
+        }
+    }
+    return false;
 }
 
 void
 EdgeIntersectionList::addEndpoints()
 {
-	auto maxSegIndex = edge->getNumPoints() - 1;
-	add(edge->pts->getAt(0), 0, 0.0);
-	add(edge->pts->getAt(maxSegIndex), maxSegIndex, 0.0);
+    auto maxSegIndex = edge->getNumPoints() - 1;
+    add(edge->pts->getAt(0), 0, 0.0);
+    add(edge->pts->getAt(maxSegIndex), maxSegIndex, 0.0);
 }
 
 void
-EdgeIntersectionList::addSplitEdges(vector<Edge*> *edgeList)
+EdgeIntersectionList::addSplitEdges(vector<Edge*>* edgeList)
 {
-	// ensure that the list has entries for the first and last point
-	// of the edge
-	addEndpoints();
-
-	EdgeIntersectionList::iterator it=nodeMap.begin();
-
-	// there should always be at least two entries in the list
-	EdgeIntersection *eiPrev=*it;
-	++it;
-
-	while (it!=nodeMap.end()) {
-		EdgeIntersection *ei=*it;
-		Edge *newEdge=createSplitEdge(eiPrev,ei);
-		edgeList->push_back(newEdge);
-		eiPrev=ei;
-		it++;
-	}
+    // ensure that the list has entries for the first and last point
+    // of the edge
+    addEndpoints();
+
+    EdgeIntersectionList::iterator it = nodeMap.begin();
+
+    // there should always be at least two entries in the list
+    EdgeIntersection* eiPrev = *it;
+    ++it;
+
+    while(it != nodeMap.end()) {
+        EdgeIntersection* ei = *it;
+        Edge* newEdge = createSplitEdge(eiPrev, ei);
+        edgeList->push_back(newEdge);
+        eiPrev = ei;
+        it++;
+    }
 }
 
-Edge *
-EdgeIntersectionList::createSplitEdge(EdgeIntersection *ei0,
-	EdgeIntersection *ei1)
+Edge*
+EdgeIntersectionList::createSplitEdge(EdgeIntersection* ei0,
+                                      EdgeIntersection* ei1)
 {
 #if GEOS_DEBUG
-	cerr<<"["<<this<<"] EdgeIntersectionList::createSplitEdge()"<<endl;
+    cerr << "[" << this << "] EdgeIntersectionList::createSplitEdge()" << endl;
 #endif // GEOS_DEBUG
-	auto npts = ei1->segmentIndex - ei0->segmentIndex + 2;
+    auto npts = ei1->segmentIndex - ei0->segmentIndex + 2;
 
-	const Coordinate& lastSegStartPt=edge->pts->getAt(ei1->segmentIndex);
+    const Coordinate& lastSegStartPt = edge->pts->getAt(ei1->segmentIndex);
 
-	// if the last intersection point is not equal to the its segment
-	// start pt, add it to the points list as well.
-	// (This check is needed because the distance metric is not totally
-	// reliable!). The check for point equality is 2D only - Z values
-	// are ignored
-	bool useIntPt1=ei1->dist>0.0 || !ei1->coord.equals2D(lastSegStartPt);
+    // if the last intersection point is not equal to the its segment
+    // start pt, add it to the points list as well.
+    // (This check is needed because the distance metric is not totally
+    // reliable!). The check for point equality is 2D only - Z values
+    // are ignored
+    bool useIntPt1 = ei1->dist > 0.0 || !ei1->coord.equals2D(lastSegStartPt);
 
-	if (!useIntPt1) --npts;
+    if(!useIntPt1) {
+        --npts;
+    }
 
 #if GEOS_DEBUG
-	cerr<<"    npts:"<<npts<<endl;
+    cerr << "    npts:" << npts << endl;
 #endif // GEOS_DEBUG
 
-	vector<Coordinate> *vc=new vector<Coordinate>();
-	vc->reserve(npts);
-
-	vc->push_back(ei0->coord);
-	for(auto i = ei0->segmentIndex + 1; i <= ei1->segmentIndex; ++i)
-	{
-		if ( ! useIntPt1 && ei1->segmentIndex == i )
-		{
-			vc->push_back(ei1->coord);
-		}
-		else
-		{
-			vc->push_back(edge->pts->getAt(i));
-		}
-	}
-
-	if (useIntPt1)
-	{
-		vc->push_back(ei1->coord);
-	}
-
-	CoordinateSequence* pts=new CoordinateArraySequence(vc);
-
-	return new Edge(pts, edge->getLabel());
+    vector<Coordinate>* vc = new vector<Coordinate>();
+    vc->reserve(npts);
+
+    vc->push_back(ei0->coord);
+    for(auto i = ei0->segmentIndex + 1; i <= ei1->segmentIndex; ++i) {
+        if(! useIntPt1 && ei1->segmentIndex == i) {
+            vc->push_back(ei1->coord);
+        }
+        else {
+            vc->push_back(edge->pts->getAt(i));
+        }
+    }
+
+    if(useIntPt1) {
+        vc->push_back(ei1->coord);
+    }
+
+    CoordinateSequence* pts = new CoordinateArraySequence(vc);
+
+    return new Edge(pts, edge->getLabel());
 }
 
 string
 EdgeIntersectionList::print() const
 {
-	std::stringstream ss;
-  ss << *this;
-  return ss.str();
+    std::stringstream ss;
+    ss << *this;
+    return ss.str();
 }
 
 std::ostream&
-operator<< (std::ostream&os, const EdgeIntersectionList& e)
+operator<< (std::ostream& os, const EdgeIntersectionList& e)
 {
-  os << "Intersections:" << std::endl;
-  EdgeIntersectionList::const_iterator it=e.begin(), endIt=e.end();
-  for (; it!=endIt; ++it) {
-    EdgeIntersection *ei=*it;
-    os << *ei << endl;
-  }
-  return os;
+    os << "Intersections:" << std::endl;
+    EdgeIntersectionList::const_iterator it = e.begin(), endIt = e.end();
+    for(; it != endIt; ++it) {
+        EdgeIntersection* ei = *it;
+        os << *ei << endl;
+    }
+    return os;
 }
 
 } // namespace geos.geomgraph
diff --git a/src/geomgraph/EdgeList.cpp b/src/geomgraph/EdgeList.cpp
index f87b8b5..398438e 100644
--- a/src/geomgraph/EdgeList.cpp
+++ b/src/geomgraph/EdgeList.cpp
@@ -36,25 +36,24 @@ namespace geos {
 namespace geomgraph { // geos.geomgraph
 
 #if PROFILE
-static Profiler *profiler = Profiler::instance();
+static Profiler* profiler = Profiler::instance();
 #endif
 
 /*public*/
 void
-EdgeList::add(Edge *e)
+EdgeList::add(Edge* e)
 {
-	edges.push_back(e);
-	OrientedCoordinateArray* oca = new OrientedCoordinateArray(*(e->getCoordinates()));
-	ocaMap[oca] = e;
+    edges.push_back(e);
+    OrientedCoordinateArray* oca = new OrientedCoordinateArray(*(e->getCoordinates()));
+    ocaMap[oca] = e;
 }
 
 void
-EdgeList::addAll(const vector<Edge*> &edgeColl)
+EdgeList::addAll(const vector<Edge*>& edgeColl)
 {
-    for (std::size_t i=0, s=edgeColl.size(); i<s ; ++i)
-	{
-		add(edgeColl[i]);
-	}
+    for(std::size_t i = 0, s = edgeColl.size(); i < s ; ++i) {
+        add(edgeColl[i]);
+    }
 }
 
 /**
@@ -63,30 +62,32 @@ EdgeList::addAll(const vector<Edge*> &edgeColl)
  * @return  equal edge, if there is one already in the list
  *          null otherwise
  */
-Edge *
-EdgeList::findEqualEdge(Edge *e)
+Edge*
+EdgeList::findEqualEdge(Edge* e)
 {
 #if PROFILE
-	static Profile *prof = profiler->get("EdgeList::findEqualEdge(Edge *e)");
-	prof->start();
+    static Profile* prof = profiler->get("EdgeList::findEqualEdge(Edge *e)");
+    prof->start();
 #endif
 
-	OrientedCoordinateArray oca(*(e->getCoordinates()));
+    OrientedCoordinateArray oca(*(e->getCoordinates()));
 
-	EdgeMap::iterator it = ocaMap.find(&oca);
+    EdgeMap::iterator it = ocaMap.find(&oca);
 
 #if PROFILE
-	prof->stop();
+    prof->stop();
 #endif
 
-	if ( it != ocaMap.end() ) return it->second;
-	return nullptr;
+    if(it != ocaMap.end()) {
+        return it->second;
+    }
+    return nullptr;
 }
 
 Edge*
 EdgeList::get(int i)
 {
-	return edges[i];
+    return edges[i];
 }
 
 /**
@@ -95,61 +96,62 @@ EdgeList::get(int i)
  *          -1 otherwise
  */
 int
-EdgeList::findEdgeIndex(Edge *e)
+EdgeList::findEdgeIndex(Edge* e)
 {
-	for (int i=0, s=(int)edges.size(); i<s; ++i)
-	{
-		if ( edges[i]->equals(e) ) return i;
-	}
-	return -1;
+    for(int i = 0, s = (int)edges.size(); i < s; ++i) {
+        if(edges[i]->equals(e)) {
+            return i;
+        }
+    }
+    return -1;
 }
 
 string
 EdgeList::print()
 {
-	ostringstream ss;
-	ss << *this;
-	return ss.str();
+    ostringstream ss;
+    ss << *this;
+    return ss.str();
 #if 0
-	string out="EdgeList( ";
-	for(unsigned int j=0, s=edges.size(); j<s; ++j)
-	{
-       		Edge *e=edges[j];
-		if (j) out+=",";
-		out += e->print();
-	}
-	out+=")  ";
-	return out;
+    string out = "EdgeList( ";
+    for(unsigned int j = 0, s = edges.size(); j < s; ++j) {
+        Edge* e = edges[j];
+        if(j) {
+            out += ",";
+        }
+        out += e->print();
+    }
+    out += ")  ";
+    return out;
 #endif
 }
 
 void
 EdgeList::clearList()
 {
-        for (unsigned int pos=0; pos < edges.size(); pos++)
-                delete *(&edges[pos]);
+    for(unsigned int pos = 0; pos < edges.size(); pos++) {
+        delete *(&edges[pos]);
+    }
 
-        edges.clear();
+    edges.clear();
 }
 
 std::ostream&
-operator<< (std::ostream&os, const EdgeList& el)
+operator<< (std::ostream& os, const EdgeList& el)
 {
-	os << "EdgeList: " << std::endl;
-	for(std::size_t j=0, s=el.edges.size(); j<s; ++j)
-	{
-       		Edge *e=el.edges[j];
-		os << "  " << *e << std::endl;
-	}
-	return os;
+    os << "EdgeList: " << std::endl;
+    for(std::size_t j = 0, s = el.edges.size(); j < s; ++j) {
+        Edge* e = el.edges[j];
+        os << "  " << *e << std::endl;
+    }
+    return os;
 }
 
 EdgeList::~EdgeList()
 {
-	for (EdgeMap::iterator i=ocaMap.begin(), e=ocaMap.end(); i!=e; ++i)
-	{
-		delete i->first; // OrientedCoordinateArray
-	}
+    for(EdgeMap::iterator i = ocaMap.begin(), e = ocaMap.end(); i != e; ++i) {
+        delete i->first; // OrientedCoordinateArray
+    }
 }
 
 } // namespace geos.geomgraph
diff --git a/src/geomgraph/EdgeNodingValidator.cpp b/src/geomgraph/EdgeNodingValidator.cpp
index 8c688f9..246f3a0 100644
--- a/src/geomgraph/EdgeNodingValidator.cpp
+++ b/src/geomgraph/EdgeNodingValidator.cpp
@@ -34,28 +34,28 @@ namespace geomgraph { // geos.geomgraph
 vector<SegmentString*>&
 EdgeNodingValidator::toSegmentStrings(vector<Edge*>& edges)
 {
-	// convert Edges to SegmentStrings
-	for(size_t i=0, n=edges.size(); i<n; ++i) {
-		Edge *e=edges[i];
-		CoordinateSequence* cs=e->getCoordinates()->clone();
-		newCoordSeq.push_back(cs);
-		segStr.push_back(new BasicSegmentString(cs, e));
-	}
-	return segStr;
+    // convert Edges to SegmentStrings
+    for(size_t i = 0, n = edges.size(); i < n; ++i) {
+        Edge* e = edges[i];
+        CoordinateSequence* cs = e->getCoordinates()->clone();
+        newCoordSeq.push_back(cs);
+        segStr.push_back(new BasicSegmentString(cs, e));
+    }
+    return segStr;
 }
 
 EdgeNodingValidator::~EdgeNodingValidator()
 {
-	for (SegmentString::NonConstVect::iterator
-			i=segStr.begin(), e=segStr.end();
-			i != e;
-			++i)
-	{
-		delete *i;
-	}
-
-	for(size_t i=0, n=newCoordSeq.size(); i<n; ++i)
-		delete newCoordSeq[i];
+    for(SegmentString::NonConstVect::iterator
+            i = segStr.begin(), e = segStr.end();
+            i != e;
+            ++i) {
+        delete *i;
+    }
+
+    for(size_t i = 0, n = newCoordSeq.size(); i < n; ++i) {
+        delete newCoordSeq[i];
+    }
 }
 
 } // namespace geos.geomgraph
diff --git a/src/geomgraph/EdgeRing.cpp b/src/geomgraph/EdgeRing.cpp
index d6013d6..61a80cd 100644
--- a/src/geomgraph/EdgeRing.cpp
+++ b/src/geomgraph/EdgeRing.cpp
@@ -47,159 +47,159 @@ using namespace geos::geom;
 namespace geos {
 namespace geomgraph { // geos.geomgraph
 
-EdgeRing::EdgeRing(DirectedEdge *newStart,
-		const GeometryFactory *newGeometryFactory)
-	:
-        startDe(newStart),
-        geometryFactory(newGeometryFactory),
-	holes(),
-        maxNodeDegree(-1),
-	edges(),
-	pts(newGeometryFactory->getCoordinateSequenceFactory()->create()),
-        label(Location::UNDEF), // new Label(Location::UNDEF)),
-        ring(nullptr),
-        isHoleVar(false),
-        shell(nullptr)
+EdgeRing::EdgeRing(DirectedEdge* newStart,
+                   const GeometryFactory* newGeometryFactory)
+    :
+    startDe(newStart),
+    geometryFactory(newGeometryFactory),
+    holes(),
+    maxNodeDegree(-1),
+    edges(),
+    pts(newGeometryFactory->getCoordinateSequenceFactory()->create()),
+    label(Location::UNDEF), // new Label(Location::UNDEF)),
+    ring(nullptr),
+    isHoleVar(false),
+    shell(nullptr)
 {
-	/*
-	 * Commented out to fix different polymorphism in C++ (from Java)
-	 * Make sure these calls are made by derived classes !
-	 */
-	//computePoints(start);
-	//computeRing();
+    /*
+     * Commented out to fix different polymorphism in C++ (from Java)
+     * Make sure these calls are made by derived classes !
+     */
+    //computePoints(start);
+    //computeRing();
 #ifdef GEOS_DEBUG
-	cerr << "EdgeRing[" << this << "] ctor" << endl;
+    cerr << "EdgeRing[" << this << "] ctor" << endl;
 #endif
-	testInvariant();
+    testInvariant();
 }
 
 EdgeRing::~EdgeRing()
 {
-	testInvariant();
-
-	/*
-	 * If we constructed a ring, we did by transferring
-	 * ownership of the CoordinateSequence, so it will be
-	 * destroyed by `ring' dtor and we must not destroy
-	 * it twice.
-	 */
-	if ( ring == nullptr )
-	{
-		delete pts;
-	}
-	else
-	{
-		delete ring;
-	}
-
-	for(size_t i=0, n=holes.size(); i<n; ++i)
-	{
-		delete holes[i];
-	}
+    testInvariant();
+
+    /*
+     * If we constructed a ring, we did by transferring
+     * ownership of the CoordinateSequence, so it will be
+     * destroyed by `ring' dtor and we must not destroy
+     * it twice.
+     */
+    if(ring == nullptr) {
+        delete pts;
+    }
+    else {
+        delete ring;
+    }
+
+    for(size_t i = 0, n = holes.size(); i < n; ++i) {
+        delete holes[i];
+    }
 
 #ifdef GEOS_DEBUG
-	cerr << "EdgeRing[" << this << "] dtor" << endl;
+    cerr << "EdgeRing[" << this << "] dtor" << endl;
 #endif
 }
 
 bool
 EdgeRing::isIsolated()
 {
-	testInvariant();
-	return (label.getGeometryCount()==1);
+    testInvariant();
+    return (label.getGeometryCount() == 1);
 }
 
 bool
 EdgeRing::isHole()
 {
-	testInvariant();
+    testInvariant();
 
-	// We can't tell if this is an hole
-	// unless we computed the ring
-	// see computeRing()
-	assert(ring);
+    // We can't tell if this is an hole
+    // unless we computed the ring
+    // see computeRing()
+    assert(ring);
 
-	return isHoleVar;
+    return isHoleVar;
 }
 
 
 LinearRing*
 EdgeRing::getLinearRing()
 {
-	testInvariant();
+    testInvariant();
 //	return new LinearRing(*ring);
-	return ring;
+    return ring;
 }
 
 Label&
 EdgeRing::getLabel()
 {
-	testInvariant();
-	return label;
+    testInvariant();
+    return label;
 }
 
 bool
 EdgeRing::isShell()
 {
-	testInvariant();
-	return (shell==nullptr);
+    testInvariant();
+    return (shell == nullptr);
 }
 
 EdgeRing*
 EdgeRing::getShell()
 {
-	testInvariant();
-	return shell;
+    testInvariant();
+    return shell;
 }
 
 void
-EdgeRing::setShell(EdgeRing *newShell)
+EdgeRing::setShell(EdgeRing* newShell)
 {
-	shell=newShell;
-	if (shell!=nullptr) shell->addHole(this);
-	testInvariant();
+    shell = newShell;
+    if(shell != nullptr) {
+        shell->addHole(this);
+    }
+    testInvariant();
 }
 
 void
-EdgeRing::addHole(EdgeRing *edgeRing)
+EdgeRing::addHole(EdgeRing* edgeRing)
 {
-	holes.push_back(edgeRing);
-	testInvariant();
+    holes.push_back(edgeRing);
+    testInvariant();
 }
 
 /*public*/
 Polygon*
 EdgeRing::toPolygon(const GeometryFactory* p_geometryFactory)
 {
-	testInvariant();
-
-	size_t nholes=holes.size();
-	vector<Geometry *> *holeLR=new vector<Geometry *>(nholes);
-	for (size_t i=0; i<nholes; ++i)
-	{
-		Geometry *hole=holes[i]->getLinearRing()->clone();
-        	(*holeLR)[i]=hole;
-	}
-
-	// We don't use "clone" here because
-	// GeometryFactory::createPolygon really
-	// wants a LinearRing
-	//
-	LinearRing *shellLR=new LinearRing(*(getLinearRing()));
-	return p_geometryFactory->createPolygon(shellLR, holeLR);
+    testInvariant();
+
+    size_t nholes = holes.size();
+    vector<Geometry*>* holeLR = new vector<Geometry*>(nholes);
+    for(size_t i = 0; i < nholes; ++i) {
+        Geometry* hole = holes[i]->getLinearRing()->clone();
+        (*holeLR)[i] = hole;
+    }
+
+    // We don't use "clone" here because
+    // GeometryFactory::createPolygon really
+    // wants a LinearRing
+    //
+    LinearRing* shellLR = new LinearRing(*(getLinearRing()));
+    return p_geometryFactory->createPolygon(shellLR, holeLR);
 }
 
 /*public*/
 void
 EdgeRing::computeRing()
 {
-	testInvariant();
+    testInvariant();
 
-	if (ring!=nullptr) return;   // don't compute more than once
-	ring=geometryFactory->createLinearRing(pts);
-	isHoleVar=Orientation::isCCW(pts);
+    if(ring != nullptr) {
+        return;    // don't compute more than once
+    }
+    ring = geometryFactory->createLinearRing(pts);
+    isHoleVar = Orientation::isCCW(pts);
 
-	testInvariant();
+    testInvariant();
 
 }
 
@@ -207,42 +207,43 @@ EdgeRing::computeRing()
 vector<DirectedEdge*>&
 EdgeRing::getEdges()
 {
-	testInvariant();
+    testInvariant();
 
-	return edges;
+    return edges;
 }
 
 /*protected*/
 void
-EdgeRing::computePoints(DirectedEdge *newStart)
-	// throw(const TopologyException &)
+EdgeRing::computePoints(DirectedEdge* newStart)
+// throw(const TopologyException &)
 {
-	startDe=newStart;
-	DirectedEdge *de=newStart;
-	bool isFirstEdge=true;
-	do {
-		//util::Assert::isTrue(de!=NULL,"EdgeRing::computePoints: found null Directed Edge");
-		//assert(de!=NULL); // EdgeRing::computePoints: found null Directed Edge
-		if(de==nullptr)
-			throw util::TopologyException(
-				"EdgeRing::computePoints: found null Directed Edge");
-
-		if (de->getEdgeRing()==this)
-			throw util::TopologyException(
-				"Directed Edge visited twice during ring-building",
-				de->getCoordinate());
-
-		edges.push_back(de);
-		const Label& deLabel = de->getLabel();
-		assert(deLabel.isArea());
-		mergeLabel(deLabel);
-		addPoints(de->getEdge(),de->isForward(),isFirstEdge);
-		isFirstEdge=false;
-		setEdgeRing(de,this);
-		de=getNext(de);
-	} while (de!=startDe);
-
-	testInvariant();
+    startDe = newStart;
+    DirectedEdge* de = newStart;
+    bool isFirstEdge = true;
+    do {
+        //util::Assert::isTrue(de!=NULL,"EdgeRing::computePoints: found null Directed Edge");
+        //assert(de!=NULL); // EdgeRing::computePoints: found null Directed Edge
+        if(de == nullptr)
+            throw util::TopologyException(
+                "EdgeRing::computePoints: found null Directed Edge");
+
+        if(de->getEdgeRing() == this)
+            throw util::TopologyException(
+                "Directed Edge visited twice during ring-building",
+                de->getCoordinate());
+
+        edges.push_back(de);
+        const Label& deLabel = de->getLabel();
+        assert(deLabel.isArea());
+        mergeLabel(deLabel);
+        addPoints(de->getEdge(), de->isForward(), isFirstEdge);
+        isFirstEdge = false;
+        setEdgeRing(de, this);
+        de = getNext(de);
+    }
+    while(de != startDe);
+
+    testInvariant();
 
 }
 
@@ -251,30 +252,35 @@ int
 EdgeRing::getMaxNodeDegree()
 {
 
-	testInvariant();
+    testInvariant();
 
-	if (maxNodeDegree<0) computeMaxNodeDegree();
-	return maxNodeDegree;
+    if(maxNodeDegree < 0) {
+        computeMaxNodeDegree();
+    }
+    return maxNodeDegree;
 }
 
 /*private*/
 void
 EdgeRing::computeMaxNodeDegree()
 {
-	maxNodeDegree=0;
-	DirectedEdge *de=startDe;
-	do {
-		Node *node=de->getNode();
-		EdgeEndStar* ees = node->getEdges();
-		assert(dynamic_cast<DirectedEdgeStar*>(ees));
-		DirectedEdgeStar* des = static_cast<DirectedEdgeStar*>(ees);
-		int degree=des->getOutgoingDegree(this);
-		if (degree>maxNodeDegree) maxNodeDegree=degree;
-		de=getNext(de);
-	} while (de!=startDe);
-	maxNodeDegree *= 2;
-
-	testInvariant();
+    maxNodeDegree = 0;
+    DirectedEdge* de = startDe;
+    do {
+        Node* node = de->getNode();
+        EdgeEndStar* ees = node->getEdges();
+        assert(dynamic_cast<DirectedEdgeStar*>(ees));
+        DirectedEdgeStar* des = static_cast<DirectedEdgeStar*>(ees);
+        int degree = des->getOutgoingDegree(this);
+        if(degree > maxNodeDegree) {
+            maxNodeDegree = degree;
+        }
+        de = getNext(de);
+    }
+    while(de != startDe);
+    maxNodeDegree *= 2;
+
+    testInvariant();
 
 }
 
@@ -282,13 +288,14 @@ EdgeRing::computeMaxNodeDegree()
 void
 EdgeRing::setInResult()
 {
-	DirectedEdge *de=startDe;
-	do {
-		de->getEdge()->setInResult(true);
-		de=de->getNext();
-	} while (de!=startDe);
+    DirectedEdge* de = startDe;
+    do {
+        de->getEdge()->setInResult(true);
+        de = de->getNext();
+    }
+    while(de != startDe);
 
-	testInvariant();
+    testInvariant();
 
 }
 
@@ -296,10 +303,10 @@ EdgeRing::setInResult()
 void
 EdgeRing::mergeLabel(const Label& deLabel)
 {
-	mergeLabel(deLabel, 0);
-	mergeLabel(deLabel, 1);
+    mergeLabel(deLabel, 0);
+    mergeLabel(deLabel, 1);
 
-	testInvariant();
+    testInvariant();
 
 }
 
@@ -308,54 +315,58 @@ void
 EdgeRing::mergeLabel(const Label& deLabel, int geomIndex)
 {
 
-	testInvariant();
+    testInvariant();
 
-	int loc=deLabel.getLocation(geomIndex, Position::RIGHT);
-	// no information to be had from this label
-	if (loc==Location::UNDEF) return;
+    int loc = deLabel.getLocation(geomIndex, Position::RIGHT);
+    // no information to be had from this label
+    if(loc == Location::UNDEF) {
+        return;
+    }
 
-	// if there is no current RHS value, set it
-	if (label.getLocation(geomIndex)==Location::UNDEF) {
-		label.setLocation(geomIndex,loc);
-		return;
-	}
+    // if there is no current RHS value, set it
+    if(label.getLocation(geomIndex) == Location::UNDEF) {
+        label.setLocation(geomIndex, loc);
+        return;
+    }
 }
 
 /*protected*/
 void
-EdgeRing::addPoints(Edge *edge, bool isForward, bool isFirstEdge)
+EdgeRing::addPoints(Edge* edge, bool isForward, bool isFirstEdge)
 {
-	// EdgeRing::addPoints: can't add points after LinearRing construction
-	assert(ring==nullptr);
-
-	assert(edge);
-	const CoordinateSequence* edgePts=edge->getCoordinates();
-
-	assert(edgePts);
-	size_t numEdgePts=edgePts->getSize();
-
-	assert(pts);
-
-	if (isForward) {
-		size_t startIndex=1;
-		if (isFirstEdge) startIndex=0;
-		for (size_t i=startIndex; i<numEdgePts; ++i)
-		{
-			pts->add(edgePts->getAt(i));
-		}
-	}
-
-	else { // is backward
-		size_t startIndex=numEdgePts-1;
-		if (isFirstEdge) startIndex=numEdgePts;
-		//for (int i=startIndex;i>=0;i--)
-		for (size_t i=startIndex; i>0; --i)
-		{
-			pts->add(edgePts->getAt(i-1));
-		}
-	}
-
-	testInvariant();
+    // EdgeRing::addPoints: can't add points after LinearRing construction
+    assert(ring == nullptr);
+
+    assert(edge);
+    const CoordinateSequence* edgePts = edge->getCoordinates();
+
+    assert(edgePts);
+    size_t numEdgePts = edgePts->getSize();
+
+    assert(pts);
+
+    if(isForward) {
+        size_t startIndex = 1;
+        if(isFirstEdge) {
+            startIndex = 0;
+        }
+        for(size_t i = startIndex; i < numEdgePts; ++i) {
+            pts->add(edgePts->getAt(i));
+        }
+    }
+
+    else { // is backward
+        size_t startIndex = numEdgePts - 1;
+        if(isFirstEdge) {
+            startIndex = numEdgePts;
+        }
+        //for (int i=startIndex;i>=0;i--)
+        for(size_t i = startIndex; i > 0; --i) {
+            pts->add(edgePts->getAt(i - 1));
+        }
+    }
+
+    testInvariant();
 
 }
 
@@ -364,36 +375,38 @@ bool
 EdgeRing::containsPoint(const Coordinate& p)
 {
 
-	testInvariant();
+    testInvariant();
 
-	assert(ring);
+    assert(ring);
 
-	const Envelope* env=ring->getEnvelopeInternal();
-	assert(env);
-	if ( ! env->contains(p) ) return false;
+    const Envelope* env = ring->getEnvelopeInternal();
+    assert(env);
+    if(! env->contains(p)) {
+        return false;
+    }
 
-	if ( ! PointLocation::isInRing(p, ring->getCoordinatesRO()) )
-		return false;
+    if(! PointLocation::isInRing(p, ring->getCoordinatesRO())) {
+        return false;
+    }
 
-	for (vector<EdgeRing*>::iterator i=holes.begin(); i<holes.end(); ++i)
-	{
-		EdgeRing *hole=*i;
-		assert(hole);
-		if (hole->containsPoint(p))
-		{
-			return false;
-		}
-	}
-	return true;
+    for(vector<EdgeRing*>::iterator i = holes.begin(); i < holes.end(); ++i) {
+        EdgeRing* hole = *i;
+        assert(hole);
+        if(hole->containsPoint(p)) {
+            return false;
+        }
+    }
+    return true;
 }
 
-std::ostream& operator<< (std::ostream& os, const EdgeRing& er)
+std::ostream&
+operator<< (std::ostream& os, const EdgeRing& er)
 {
-	os << "EdgeRing[" << &er << "]: "
-	   << std::endl
-	   << "Points: " << er.pts
-	   << std::endl;
-	return os;
+    os << "EdgeRing[" << &er << "]: "
+       << std::endl
+       << "Points: " << er.pts
+       << std::endl;
+    return os;
 }
 
 } // namespace geos.geomgraph
diff --git a/src/geomgraph/GeometryGraph.cpp b/src/geomgraph/GeometryGraph.cpp
index e0ab745..2bf95f6 100644
--- a/src/geomgraph/GeometryGraph.cpp
+++ b/src/geomgraph/GeometryGraph.cpp
@@ -85,42 +85,41 @@ namespace geomgraph { // geos.geomgraph
 bool
 GeometryGraph::isInBoundary(int boundaryCount)
 {
-	// the "Mod-2 Rule"
-	return boundaryCount%2==1;
+    // the "Mod-2 Rule"
+    return boundaryCount % 2 == 1;
 }
 
 int
 GeometryGraph::determineBoundary(int boundaryCount)
 {
-	return isInBoundary(boundaryCount)?Location::BOUNDARY : Location::INTERIOR;
+    return isInBoundary(boundaryCount) ? Location::BOUNDARY : Location::INTERIOR;
 }
 
 
 EdgeSetIntersector*
 GeometryGraph::createEdgeSetIntersector()
 {
-	// various options for computing intersections, from slowest to fastest
+    // various options for computing intersections, from slowest to fastest
 
-	//private EdgeSetIntersector esi = new SimpleEdgeSetIntersector();
-	//private EdgeSetIntersector esi = new MonotoneChainIntersector();
-	//private EdgeSetIntersector esi = new NonReversingChainIntersector();
-	//private EdgeSetIntersector esi = new SimpleSweepLineIntersector();
-	//private EdgeSetIntersector esi = new MCSweepLineIntersector();
+    //private EdgeSetIntersector esi = new SimpleEdgeSetIntersector();
+    //private EdgeSetIntersector esi = new MonotoneChainIntersector();
+    //private EdgeSetIntersector esi = new NonReversingChainIntersector();
+    //private EdgeSetIntersector esi = new SimpleSweepLineIntersector();
+    //private EdgeSetIntersector esi = new MCSweepLineIntersector();
 
-	//return new SimpleEdgeSetIntersector();
-	return new SimpleMCSweepLineIntersector();
+    //return new SimpleEdgeSetIntersector();
+    return new SimpleMCSweepLineIntersector();
 }
 
 /*public*/
 vector<Node*>*
 GeometryGraph::getBoundaryNodes()
 {
-	if ( ! boundaryNodes.get() )
-	{
-		boundaryNodes.reset(new vector<Node*>());
-		getBoundaryNodes(*(boundaryNodes.get()));
-	}
-	return boundaryNodes.get();
+    if(! boundaryNodes.get()) {
+        boundaryNodes.reset(new vector<Node*>());
+        getBoundaryNodes(*(boundaryNodes.get()));
+    }
+    return boundaryNodes.get();
 }
 
 /*public*/
@@ -128,102 +127,104 @@ CoordinateSequence*
 GeometryGraph::getBoundaryPoints()
 {
 
-	if ( ! boundaryPoints.get() )
-	{
-		// Collection will be destroied by GeometryGraph dtor
-		vector<Node*>* coll = getBoundaryNodes();
-		boundaryPoints.reset(new CoordinateArraySequence(coll->size()));
-		size_t i=0;
-		for (vector<Node*>::iterator it=coll->begin(), endIt=coll->end();
-			it!=endIt; ++it)
-		{
-			Node *node=*it;
-			boundaryPoints->setAt(node->getCoordinate(), i++);
-		}
-	}
-
-	// We keep ownership of this, will be destroyed by destructor
-	return boundaryPoints.get();
+    if(! boundaryPoints.get()) {
+        // Collection will be destroied by GeometryGraph dtor
+        vector<Node*>* coll = getBoundaryNodes();
+        boundaryPoints.reset(new CoordinateArraySequence(coll->size()));
+        size_t i = 0;
+        for(vector<Node*>::iterator it = coll->begin(), endIt = coll->end();
+                it != endIt; ++it) {
+            Node* node = *it;
+            boundaryPoints->setAt(node->getCoordinate(), i++);
+        }
+    }
+
+    // We keep ownership of this, will be destroyed by destructor
+    return boundaryPoints.get();
 }
 
 Edge*
-GeometryGraph::findEdge(const LineString *line)
+GeometryGraph::findEdge(const LineString* line)
 {
-	return lineEdgeMap.find(line)->second;
+    return lineEdgeMap.find(line)->second;
 }
 
 void
-GeometryGraph::computeSplitEdges(vector<Edge*> *edgelist)
+GeometryGraph::computeSplitEdges(vector<Edge*>* edgelist)
 {
 #if GEOS_DEBUG
-	cerr<<"["<<this<<"] GeometryGraph::computeSplitEdges() scanning "<<edges->size()<<" local and "<<edgelist->size()<<" provided edges"<<endl;
+    cerr << "[" << this << "] GeometryGraph::computeSplitEdges() scanning " << edges->size() << " local and " <<
+         edgelist->size() << " provided edges" << endl;
 #endif
-	for (vector<Edge*>::iterator i=edges->begin(), endIt=edges->end();
-		i!=endIt; ++i)
-	{
-		Edge *e=*i;
+    for(vector<Edge*>::iterator i = edges->begin(), endIt = edges->end();
+            i != endIt; ++i) {
+        Edge* e = *i;
 #if GEOS_DEBUG
-		cerr<<"   "<<e->print()<<" adding split edges from arg"<<endl;
+        cerr << "   " << e->print() << " adding split edges from arg" << endl;
 #endif
-		e->eiList.addSplitEdges(edgelist);
-	}
+        e->eiList.addSplitEdges(edgelist);
+    }
 #if GEOS_DEBUG
-	cerr<<"["<<this<<"] GeometryGraph::computeSplitEdges() completed "<<endl;
+    cerr << "[" << this << "] GeometryGraph::computeSplitEdges() completed " << endl;
 #endif
 }
 
 void
-GeometryGraph::add(const Geometry *g)
-	//throw (UnsupportedOperationException *)
+GeometryGraph::add(const Geometry* g)
+//throw (UnsupportedOperationException *)
 {
-	if (g->isEmpty()) return;
-
-	// check if this Geometry should obey the Boundary Determination Rule
-	// all collections except MultiPolygons obey the rule
-	if ( dynamic_cast<const MultiPolygon*>(g) )
-		useBoundaryDeterminationRule = false;
-
-
-	if ( const Polygon* x1 = dynamic_cast<const Polygon*>(g) )
-		addPolygon(x1);
-
-	// LineString also handles LinearRings
-	else if ( const LineString* x2 = dynamic_cast<const LineString*>(g) )
-		addLineString(x2);
-
-	else if ( const Point* x3 = dynamic_cast<const Point*>(g) )
-		addPoint(x3);
-
-	else if ( const GeometryCollection* x4 =
-            dynamic_cast<const GeometryCollection*>(g) )
-  {
-		addCollection(x4);
-  }
-
-	else {
-		string out=typeid(*g).name();
-		throw util::UnsupportedOperationException("GeometryGraph::add(Geometry *): unknown geometry type: "+out);
-	}
+    if(g->isEmpty()) {
+        return;
+    }
+
+    // check if this Geometry should obey the Boundary Determination Rule
+    // all collections except MultiPolygons obey the rule
+    if(dynamic_cast<const MultiPolygon*>(g)) {
+        useBoundaryDeterminationRule = false;
+    }
+
+
+    if(const Polygon* x1 = dynamic_cast<const Polygon*>(g)) {
+        addPolygon(x1);
+    }
+
+    // LineString also handles LinearRings
+    else if(const LineString* x2 = dynamic_cast<const LineString*>(g)) {
+        addLineString(x2);
+    }
+
+    else if(const Point* x3 = dynamic_cast<const Point*>(g)) {
+        addPoint(x3);
+    }
+
+    else if(const GeometryCollection* x4 =
+                dynamic_cast<const GeometryCollection*>(g)) {
+        addCollection(x4);
+    }
+
+    else {
+        string out = typeid(*g).name();
+        throw util::UnsupportedOperationException("GeometryGraph::add(Geometry *): unknown geometry type: " + out);
+    }
 }
 
 void
-GeometryGraph::addCollection(const GeometryCollection *gc)
+GeometryGraph::addCollection(const GeometryCollection* gc)
 {
-	for (size_t i=0, n=gc->getNumGeometries(); i<n; ++i)
-	{
-		const Geometry *g=gc->getGeometryN(i);
-		add(g);
-	}
+    for(size_t i = 0, n = gc->getNumGeometries(); i < n; ++i) {
+        const Geometry* g = gc->getGeometryN(i);
+        add(g);
+    }
 }
 
 /*
  * Add a Point to the graph.
  */
 void
-GeometryGraph::addPoint(const Point *p)
+GeometryGraph::addPoint(const Point* p)
 {
-	const Coordinate& coord=*(p->getCoordinate());
-	insertPoint(argIndex, coord, Location::INTERIOR);
+    const Coordinate& coord = *(p->getCoordinate());
+    insertPoint(argIndex, coord, Location::INTERIOR);
 }
 
 /*
@@ -233,95 +234,94 @@ GeometryGraph::addPoint(const Point *p)
  * the left and right locations must be interchanged.
  */
 void
-GeometryGraph::addPolygonRing(const LinearRing *lr, int cwLeft, int cwRight)
-	// throw IllegalArgumentException (see below)
+GeometryGraph::addPolygonRing(const LinearRing* lr, int cwLeft, int cwRight)
+// throw IllegalArgumentException (see below)
 {
-	// skip empty component (see bug #234)
-	if ( lr->isEmpty() ) return;
-
-	const CoordinateSequence *lrcl = lr->getCoordinatesRO();
-
-	CoordinateSequence* coord=CoordinateSequence::removeRepeatedPoints(lrcl);
-	if (coord->getSize()<4) {
-		hasTooFewPointsVar=true;
-		invalidPoint=coord->getAt(0); // its now a Coordinate
-		delete coord;
-		return;
-	}
-	int left=cwLeft;
-	int right=cwRight;
-
-	/*
-	 * the isCCW call might throw an
-	 * IllegalArgumentException if degenerate ring does
-	 * not contain 3 distinct points.
-	 */
-	try
-	{
-		if (Orientation::isCCW(coord)) {
-			left=cwRight;
-			right=cwLeft;
-		}
-	}
-	catch(...)
-	{
-		delete coord;
-		throw;
-	}
-
-	Edge *e=new Edge(coord, Label(argIndex, Location::BOUNDARY, left, right));
-	lineEdgeMap[lr]=e;
-	insertEdge(e);
-	insertPoint(argIndex,coord->getAt(0), Location::BOUNDARY);
+    // skip empty component (see bug #234)
+    if(lr->isEmpty()) {
+        return;
+    }
+
+    const CoordinateSequence* lrcl = lr->getCoordinatesRO();
+
+    CoordinateSequence* coord = CoordinateSequence::removeRepeatedPoints(lrcl);
+    if(coord->getSize() < 4) {
+        hasTooFewPointsVar = true;
+        invalidPoint = coord->getAt(0); // its now a Coordinate
+        delete coord;
+        return;
+    }
+    int left = cwLeft;
+    int right = cwRight;
+
+    /*
+     * the isCCW call might throw an
+     * IllegalArgumentException if degenerate ring does
+     * not contain 3 distinct points.
+     */
+    try {
+        if(Orientation::isCCW(coord)) {
+            left = cwRight;
+            right = cwLeft;
+        }
+    }
+    catch(...) {
+        delete coord;
+        throw;
+    }
+
+    Edge* e = new Edge(coord, Label(argIndex, Location::BOUNDARY, left, right));
+    lineEdgeMap[lr] = e;
+    insertEdge(e);
+    insertPoint(argIndex, coord->getAt(0), Location::BOUNDARY);
 }
 
 void
-GeometryGraph::addPolygon(const Polygon *p)
+GeometryGraph::addPolygon(const Polygon* p)
 {
-	const LineString* ls;
-	const LinearRing* lr;
-
-	ls = p->getExteriorRing();
-	assert(dynamic_cast<const LinearRing*>(ls));
-	lr = static_cast<const LinearRing*>(ls);
-	addPolygonRing(lr, Location::EXTERIOR, Location::INTERIOR);
-	for (size_t i=0, n=p->getNumInteriorRing(); i<n; ++i)
-	{
-		// Holes are topologically labelled opposite to the shell, since
-		// the interior of the polygon lies on their opposite side
-		// (on the left, if the hole is oriented CW)
-		ls = p->getInteriorRingN(i);
-		assert(dynamic_cast<const LinearRing*>(ls));
-		lr = static_cast<const LinearRing*>(ls);
-		addPolygonRing(lr, Location::INTERIOR, Location::EXTERIOR);
-	}
+    const LineString* ls;
+    const LinearRing* lr;
+
+    ls = p->getExteriorRing();
+    assert(dynamic_cast<const LinearRing*>(ls));
+    lr = static_cast<const LinearRing*>(ls);
+    addPolygonRing(lr, Location::EXTERIOR, Location::INTERIOR);
+    for(size_t i = 0, n = p->getNumInteriorRing(); i < n; ++i) {
+        // Holes are topologically labelled opposite to the shell, since
+        // the interior of the polygon lies on their opposite side
+        // (on the left, if the hole is oriented CW)
+        ls = p->getInteriorRingN(i);
+        assert(dynamic_cast<const LinearRing*>(ls));
+        lr = static_cast<const LinearRing*>(ls);
+        addPolygonRing(lr, Location::INTERIOR, Location::EXTERIOR);
+    }
 }
 
 void
-GeometryGraph::addLineString(const LineString *line)
+GeometryGraph::addLineString(const LineString* line)
 {
-	CoordinateSequence* coord=CoordinateSequence::removeRepeatedPoints(line->getCoordinatesRO());
-	if(coord->getSize()<2) {
-		hasTooFewPointsVar=true;
-		invalidPoint=coord->getAt(0);
-		delete coord;
-		return;
-	}
-
-	Edge *e=new Edge(coord, Label(argIndex, Location::INTERIOR));
-	lineEdgeMap[line]=e;
-	insertEdge(e);
-
-	/*
-	 * Add the boundary points of the LineString, if any.
-	 * Even if the LineString is closed, add both points as if they
-	 * were endpoints.
-	 * This allows for the case that the node already exists and is
-	 * a boundary point.
-	 */
-	assert(coord->size() >= 2); // found LineString with single point
-	insertBoundaryPoint(argIndex, coord->getAt(0));
-	insertBoundaryPoint(argIndex, coord->getAt(coord->getSize()-1));
+    CoordinateSequence* coord = CoordinateSequence::removeRepeatedPoints(line->getCoordinatesRO());
+    if(coord->getSize() < 2) {
+        hasTooFewPointsVar = true;
+        invalidPoint = coord->getAt(0);
+        delete coord;
+        return;
+    }
+
+    Edge* e = new Edge(coord, Label(argIndex, Location::INTERIOR));
+    lineEdgeMap[line] = e;
+    insertEdge(e);
+
+    /*
+     * Add the boundary points of the LineString, if any.
+     * Even if the LineString is closed, add both points as if they
+     * were endpoints.
+     * This allows for the case that the node already exists and is
+     * a boundary point.
+     */
+    assert(coord->size() >= 2); // found LineString with single point
+    insertBoundaryPoint(argIndex, coord->getAt(0));
+    insertBoundaryPoint(argIndex, coord->getAt(coord->getSize() - 1));
 }
 
 /*
@@ -329,13 +329,13 @@ GeometryGraph::addLineString(const LineString *line)
  * to be correct.
  */
 void
-GeometryGraph::addEdge(Edge *e)
+GeometryGraph::addEdge(Edge* e)
 {
-	insertEdge(e);
-	const CoordinateSequence* coord=e->getCoordinates();
-	// insert the endpoint as a node, to mark that it is on the boundary
-	insertPoint(argIndex,coord->getAt(0),Location::BOUNDARY);
-	insertPoint(argIndex,coord->getAt(coord->getSize()-1),Location::BOUNDARY);
+    insertEdge(e);
+    const CoordinateSequence* coord = e->getCoordinates();
+    // insert the endpoint as a node, to mark that it is on the boundary
+    insertPoint(argIndex, coord->getAt(0), Location::BOUNDARY);
+    insertPoint(argIndex, coord->getAt(coord->getSize() - 1), Location::BOUNDARY);
 }
 
 /*
@@ -345,114 +345,114 @@ GeometryGraph::addEdge(Edge *e)
 void
 GeometryGraph::addPoint(Coordinate& pt)
 {
-	insertPoint(argIndex,pt,Location::INTERIOR);
+    insertPoint(argIndex, pt, Location::INTERIOR);
 }
 
 template <class T, class C>
-void collect_intersecting_edges(const Envelope *env, T start, T end, C &to)
+void
+collect_intersecting_edges(const Envelope* env, T start, T end, C& to)
 {
-  for (T i=start; i != end; ++i)
-  {
-    Edge *e = *i;
-    if ( e->getEnvelope()->intersects(env) ) to.push_back(e);
-  }
+    for(T i = start; i != end; ++i) {
+        Edge* e = *i;
+        if(e->getEnvelope()->intersects(env)) {
+            to.push_back(e);
+        }
+    }
 }
 
 /*public*/
 SegmentIntersector*
-GeometryGraph::computeSelfNodes(LineIntersector &li,
-  bool computeRingSelfNodes, const Envelope *env)
+GeometryGraph::computeSelfNodes(LineIntersector& li,
+                                bool computeRingSelfNodes, const Envelope* env)
 {
-	return computeSelfNodes(li, computeRingSelfNodes, false, env);
+    return computeSelfNodes(li, computeRingSelfNodes, false, env);
 }
 
 SegmentIntersector*
-GeometryGraph::computeSelfNodes(LineIntersector &li,
-  bool computeRingSelfNodes, bool isDoneIfProperInt, const Envelope *env)
+GeometryGraph::computeSelfNodes(LineIntersector& li,
+                                bool computeRingSelfNodes, bool isDoneIfProperInt, const Envelope* env)
 {
-	SegmentIntersector *si = new SegmentIntersector(&li, true, false);
-	si->setIsDoneIfProperInt(isDoneIfProperInt);
-	unique_ptr<EdgeSetIntersector> esi(createEdgeSetIntersector());
+    SegmentIntersector* si = new SegmentIntersector(&li, true, false);
+    si->setIsDoneIfProperInt(isDoneIfProperInt);
+    unique_ptr<EdgeSetIntersector> esi(createEdgeSetIntersector());
 
-	typedef vector<Edge*> EC;
-	EC *se = edges;
-	EC self_edges_copy;
+    typedef vector<Edge*> EC;
+    EC* se = edges;
+    EC self_edges_copy;
 
-	if ( env && ! env->covers(parentGeom->getEnvelopeInternal()) ) {
-		collect_intersecting_edges(env, se->begin(), se->end(), self_edges_copy);
-    //cerr << "(computeSelfNodes) Self edges reduced from " << se->size() << " to " << self_edges_copy.size() << endl;
-		se = &self_edges_copy;
-	}
+    if(env && ! env->covers(parentGeom->getEnvelopeInternal())) {
+        collect_intersecting_edges(env, se->begin(), se->end(), self_edges_copy);
+        //cerr << "(computeSelfNodes) Self edges reduced from " << se->size() << " to " << self_edges_copy.size() << endl;
+        se = &self_edges_copy;
+    }
 
-	bool isRings = dynamic_cast<const LinearRing*>(parentGeom)
-	    || dynamic_cast<const Polygon*>(parentGeom)
-	    || dynamic_cast<const MultiPolygon*>(parentGeom);
+    bool isRings = dynamic_cast<const LinearRing*>(parentGeom)
+                   || dynamic_cast<const Polygon*>(parentGeom)
+                   || dynamic_cast<const MultiPolygon*>(parentGeom);
 
-	bool computeAllSegments = computeRingSelfNodes || ! isRings;
+    bool computeAllSegments = computeRingSelfNodes || ! isRings;
 
-	esi->computeIntersections(se, si, computeAllSegments);
+    esi->computeIntersections(se, si, computeAllSegments);
 
 #if GEOS_DEBUG
-	cerr << "SegmentIntersector # tests = " << si->numTests << endl;
+    cerr << "SegmentIntersector # tests = " << si->numTests << endl;
 #endif // GEOS_DEBUG
 
-	addSelfIntersectionNodes(argIndex);
-	return si;
+    addSelfIntersectionNodes(argIndex);
+    return si;
 }
 
 SegmentIntersector*
-GeometryGraph::computeEdgeIntersections(GeometryGraph *g,
-	LineIntersector *li, bool includeProper, const Envelope *env)
+GeometryGraph::computeEdgeIntersections(GeometryGraph* g,
+                                        LineIntersector* li, bool includeProper, const Envelope* env)
 {
 #if GEOS_DEBUG
-	cerr<<"GeometryGraph::computeEdgeIntersections call"<<endl;
+    cerr << "GeometryGraph::computeEdgeIntersections call" << endl;
 #endif
-	SegmentIntersector *si=new SegmentIntersector(li, includeProper, true);
-
-	si->setBoundaryNodes(getBoundaryNodes(), g->getBoundaryNodes());
-	unique_ptr<EdgeSetIntersector> esi(createEdgeSetIntersector());
-
-	typedef vector<Edge*> EC;
-
-	EC self_edges_copy;
-	EC other_edges_copy;
-
-	EC *se = edges;
-	EC *oe = g->edges;
-	if ( env && ! env->covers(parentGeom->getEnvelopeInternal()) ) {
-		collect_intersecting_edges(env, se->begin(), se->end(), self_edges_copy);
-    //cerr << "Self edges reduced from " << se->size() << " to " << self_edges_copy.size() << endl;
-		se = &self_edges_copy;
-	}
-	if ( env && ! env->covers(g->parentGeom->getEnvelopeInternal()) ) {
-		collect_intersecting_edges(env, oe->begin(), oe->end(), other_edges_copy);
-    //cerr << "Other edges reduced from " << oe->size() << " to " << other_edges_copy.size() << endl;
-		oe = &other_edges_copy;
-	}
-	esi->computeIntersections(se, oe, si);
+    SegmentIntersector* si = new SegmentIntersector(li, includeProper, true);
+
+    si->setBoundaryNodes(getBoundaryNodes(), g->getBoundaryNodes());
+    unique_ptr<EdgeSetIntersector> esi(createEdgeSetIntersector());
+
+    typedef vector<Edge*> EC;
+
+    EC self_edges_copy;
+    EC other_edges_copy;
+
+    EC* se = edges;
+    EC* oe = g->edges;
+    if(env && ! env->covers(parentGeom->getEnvelopeInternal())) {
+        collect_intersecting_edges(env, se->begin(), se->end(), self_edges_copy);
+        //cerr << "Self edges reduced from " << se->size() << " to " << self_edges_copy.size() << endl;
+        se = &self_edges_copy;
+    }
+    if(env && ! env->covers(g->parentGeom->getEnvelopeInternal())) {
+        collect_intersecting_edges(env, oe->begin(), oe->end(), other_edges_copy);
+        //cerr << "Other edges reduced from " << oe->size() << " to " << other_edges_copy.size() << endl;
+        oe = &other_edges_copy;
+    }
+    esi->computeIntersections(se, oe, si);
 #if GEOS_DEBUG
-	cerr<<"GeometryGraph::computeEdgeIntersections returns"<<endl;
+    cerr << "GeometryGraph::computeEdgeIntersections returns" << endl;
 #endif
-	return si;
+    return si;
 }
 
 void
 GeometryGraph::insertPoint(int p_argIndex, const Coordinate& coord,
-	int onLocation)
+                           int onLocation)
 {
 #if GEOS_DEBUG > 1
-	cerr<<"GeometryGraph::insertPoint("<<coord.toString()<<" called"<<endl;
+    cerr << "GeometryGraph::insertPoint(" << coord.toString() << " called" << endl;
 #endif
-	Node *n=nodes->addNode(coord);
-	Label& lbl = n->getLabel();
-	if ( lbl.isNull() )
-	{
-		n->setLabel(p_argIndex, onLocation);
-	}
-	else
-	{
-		lbl.setLocation(p_argIndex, onLocation);
-	}
+    Node* n = nodes->addNode(coord);
+    Label& lbl = n->getLabel();
+    if(lbl.isNull()) {
+        n->setLabel(p_argIndex, onLocation);
+    }
+    else {
+        lbl.setLocation(p_argIndex, onLocation);
+    }
 }
 
 /*
@@ -464,114 +464,118 @@ GeometryGraph::insertPoint(int p_argIndex, const Coordinate& coord,
 void
 GeometryGraph::insertBoundaryPoint(int p_argIndex, const Coordinate& coord)
 {
-	Node *n=nodes->addNode(coord);
-	// nodes always have labels
-	Label& lbl = n->getLabel();
-
-	// the new point to insert is on a boundary
-	int boundaryCount=1;
-
-	// determine the current location for the point (if any)
-	int loc = lbl.getLocation(p_argIndex,Position::ON);
-	if (loc==Location::BOUNDARY) boundaryCount++;
-
-	// determine the boundary status of the point according to the
-	// Boundary Determination Rule
-	int newLoc = determineBoundary(boundaryNodeRule, boundaryCount);
-	lbl.setLocation(p_argIndex,newLoc);
+    Node* n = nodes->addNode(coord);
+    // nodes always have labels
+    Label& lbl = n->getLabel();
+
+    // the new point to insert is on a boundary
+    int boundaryCount = 1;
+
+    // determine the current location for the point (if any)
+    int loc = lbl.getLocation(p_argIndex, Position::ON);
+    if(loc == Location::BOUNDARY) {
+        boundaryCount++;
+    }
+
+    // determine the boundary status of the point according to the
+    // Boundary Determination Rule
+    int newLoc = determineBoundary(boundaryNodeRule, boundaryCount);
+    lbl.setLocation(p_argIndex, newLoc);
 }
 
 /*private*/
 void
 GeometryGraph::addSelfIntersectionNodes(int p_argIndex)
 {
-	for (vector<Edge*>::iterator i=edges->begin(), endIt=edges->end();
-		i!=endIt; ++i)
-	{
-		Edge *e=*i;
-		int eLoc = e->getLabel().getLocation(p_argIndex);
-		EdgeIntersectionList &eiL = e->eiList;
-		for (EdgeIntersectionList::iterator
-			eiIt=eiL.begin(), eiEnd=eiL.end();
-			eiIt!=eiEnd; ++eiIt)
-		{
-			EdgeIntersection *ei=*eiIt;
-			addSelfIntersectionNode(p_argIndex, ei->coord, eLoc);
-			GEOS_CHECK_FOR_INTERRUPTS();
-		}
-	}
+    for(vector<Edge*>::iterator i = edges->begin(), endIt = edges->end();
+            i != endIt; ++i) {
+        Edge* e = *i;
+        int eLoc = e->getLabel().getLocation(p_argIndex);
+        EdgeIntersectionList& eiL = e->eiList;
+        for(EdgeIntersectionList::iterator
+                eiIt = eiL.begin(), eiEnd = eiL.end();
+                eiIt != eiEnd; ++eiIt) {
+            EdgeIntersection* ei = *eiIt;
+            addSelfIntersectionNode(p_argIndex, ei->coord, eLoc);
+            GEOS_CHECK_FOR_INTERRUPTS();
+        }
+    }
 }
 
 /*private*/
 void
 GeometryGraph::addSelfIntersectionNode(int p_argIndex,
-	const Coordinate& coord, int loc)
+                                       const Coordinate& coord, int loc)
 {
-	// if this node is already a boundary node, don't change it
-	if (isBoundaryNode(p_argIndex,coord)) return;
-	if (loc==Location::BOUNDARY && useBoundaryDeterminationRule)
-	{
-		insertBoundaryPoint(p_argIndex,coord);
-	}
-	else
-	{
-		insertPoint(p_argIndex,coord,loc);
-	}
+    // if this node is already a boundary node, don't change it
+    if(isBoundaryNode(p_argIndex, coord)) {
+        return;
+    }
+    if(loc == Location::BOUNDARY && useBoundaryDeterminationRule) {
+        insertBoundaryPoint(p_argIndex, coord);
+    }
+    else {
+        insertPoint(p_argIndex, coord, loc);
+    }
 }
 
-vector<Edge*> *
+vector<Edge*>*
 GeometryGraph::getEdges()
 {
-	return edges;
+    return edges;
 }
 
 bool
 GeometryGraph::hasTooFewPoints()
 {
-	return hasTooFewPointsVar;
+    return hasTooFewPointsVar;
 }
 
 const Coordinate&
 GeometryGraph::getInvalidPoint()
 {
-	return invalidPoint;
+    return invalidPoint;
 }
 
 GeometryGraph::GeometryGraph(int newArgIndex,
-		const geom::Geometry *newParentGeom)
-	:
-	PlanarGraph(),
-	parentGeom(newParentGeom),
-	useBoundaryDeterminationRule(true),
+                             const geom::Geometry* newParentGeom)
+    :
+    PlanarGraph(),
+    parentGeom(newParentGeom),
+    useBoundaryDeterminationRule(true),
     boundaryNodeRule(algorithm::BoundaryNodeRule::getBoundaryOGCSFS()),
-	argIndex(newArgIndex),
-	hasTooFewPointsVar(false)
+    argIndex(newArgIndex),
+    hasTooFewPointsVar(false)
 {
-	if (parentGeom!=nullptr) add(parentGeom);
+    if(parentGeom != nullptr) {
+        add(parentGeom);
+    }
 }
 
 GeometryGraph::GeometryGraph(int newArgIndex,
-		const geom::Geometry *newParentGeom,
-		const algorithm::BoundaryNodeRule& bnr)
-	:
-	PlanarGraph(),
-	parentGeom(newParentGeom),
-	useBoundaryDeterminationRule(true),
-	boundaryNodeRule(bnr),
-	argIndex(newArgIndex),
-	hasTooFewPointsVar(false)
+                             const geom::Geometry* newParentGeom,
+                             const algorithm::BoundaryNodeRule& bnr)
+    :
+    PlanarGraph(),
+    parentGeom(newParentGeom),
+    useBoundaryDeterminationRule(true),
+    boundaryNodeRule(bnr),
+    argIndex(newArgIndex),
+    hasTooFewPointsVar(false)
 {
-	if (parentGeom!=nullptr) add(parentGeom);
+    if(parentGeom != nullptr) {
+        add(parentGeom);
+    }
 }
 
 GeometryGraph::GeometryGraph()
-	:
-	PlanarGraph(),
-	parentGeom(nullptr),
-	useBoundaryDeterminationRule(true),
+    :
+    PlanarGraph(),
+    parentGeom(nullptr),
+    useBoundaryDeterminationRule(true),
     boundaryNodeRule(algorithm::BoundaryNodeRule::getBoundaryOGCSFS()),
-	argIndex(-1),
-	hasTooFewPointsVar(false)
+    argIndex(-1),
+    hasTooFewPointsVar(false)
 {
 }
 
@@ -579,11 +583,11 @@ GeometryGraph::GeometryGraph()
 /* public static */
 int
 GeometryGraph::determineBoundary(
-	             const algorithm::BoundaryNodeRule& boundaryNodeRule,
-	                                            int boundaryCount)
+    const algorithm::BoundaryNodeRule& boundaryNodeRule,
+    int boundaryCount)
 {
-	return boundaryNodeRule.isInBoundary(boundaryCount)
-		? Location::BOUNDARY : Location::INTERIOR;
+    return boundaryNodeRule.isInBoundary(boundaryCount)
+           ? Location::BOUNDARY : Location::INTERIOR;
 }
 
 } // namespace geos.geomgraph
diff --git a/src/geomgraph/GraphComponent.cpp b/src/geomgraph/GraphComponent.cpp
index f6be97e..f1993c2 100644
--- a/src/geomgraph/GraphComponent.cpp
+++ b/src/geomgraph/GraphComponent.cpp
@@ -29,21 +29,21 @@ namespace geos {
 namespace geomgraph { // geos.geomgraph
 
 GraphComponent::GraphComponent()
-  :
-  label(),
-	isInResultVar(false),
-	isCoveredVar(false),
-	isCoveredSetVar(false),
-	isVisitedVar(false)
+    :
+    label(),
+    isInResultVar(false),
+    isCoveredVar(false),
+    isCoveredSetVar(false),
+    isVisitedVar(false)
 {
 }
 
 GraphComponent::GraphComponent(const Label& newLabel):
-	label(newLabel),
-	isInResultVar(false),
-	isCoveredVar(false),
-	isCoveredSetVar(false),
-	isVisitedVar(false)
+    label(newLabel),
+    isInResultVar(false),
+    isCoveredVar(false),
+    isCoveredSetVar(false),
+    isVisitedVar(false)
 {
 }
 
@@ -54,15 +54,15 @@ GraphComponent::~GraphComponent()
 void
 GraphComponent::setCovered(bool p_isCovered)
 {
-	isCoveredVar = p_isCovered;
-	isCoveredSetVar = true;
+    isCoveredVar = p_isCovered;
+    isCoveredSetVar = true;
 }
 
 void
 GraphComponent::updateIM(IntersectionMatrix& im)
 {
-	assert(label.getGeometryCount() >= 2); // found partial label
-	computeIM(im);
+    assert(label.getGeometryCount() >= 2); // found partial label
+    computeIM(im);
 }
 
 } // namespace geos.geomgraph
diff --git a/src/geomgraph/Label.cpp b/src/geomgraph/Label.cpp
index 13c6b8a..b8c14a8 100644
--- a/src/geomgraph/Label.cpp
+++ b/src/geomgraph/Label.cpp
@@ -36,241 +36,245 @@ namespace geomgraph { // geos.geomgraph
 
 /*public static*/
 Label
-Label::toLineLabel(const Label &label)
+Label::toLineLabel(const Label& label)
 {
-	Label lineLabel(Location::UNDEF);
-	for (int i=0; i<2; i++) {
-		lineLabel.setLocation(i, label.getLocation(i));
-	}
-	return lineLabel;
+    Label lineLabel(Location::UNDEF);
+    for(int i = 0; i < 2; i++) {
+        lineLabel.setLocation(i, label.getLocation(i));
+    }
+    return lineLabel;
 }
 
 /*public*/
 Label::Label(int onLoc)
 {
-	elt[0]=TopologyLocation(onLoc);
-	elt[1]=TopologyLocation(onLoc);
+    elt[0] = TopologyLocation(onLoc);
+    elt[1] = TopologyLocation(onLoc);
 }
 
 /*public*/
-Label::Label(int geomIndex,int onLoc)
+Label::Label(int geomIndex, int onLoc)
 {
-	assert(geomIndex>=0 && geomIndex<2);
-	elt[0]=TopologyLocation(Location::UNDEF);
-	elt[1]=TopologyLocation(Location::UNDEF);
-	elt[geomIndex].setLocation(onLoc);
+    assert(geomIndex >= 0 && geomIndex < 2);
+    elt[0] = TopologyLocation(Location::UNDEF);
+    elt[1] = TopologyLocation(Location::UNDEF);
+    elt[geomIndex].setLocation(onLoc);
 }
 
 /*public*/
-Label::Label(int onLoc,int leftLoc,int rightLoc)
+Label::Label(int onLoc, int leftLoc, int rightLoc)
 {
-	elt[0]=TopologyLocation(onLoc,leftLoc,rightLoc);
-	elt[1]=TopologyLocation(onLoc,leftLoc,rightLoc);
+    elt[0] = TopologyLocation(onLoc, leftLoc, rightLoc);
+    elt[1] = TopologyLocation(onLoc, leftLoc, rightLoc);
 }
 
 /*public*/
 Label::Label()
 {
-	elt[0]=TopologyLocation(Location::UNDEF);
-	elt[1]=TopologyLocation(Location::UNDEF);
+    elt[0] = TopologyLocation(Location::UNDEF);
+    elt[1] = TopologyLocation(Location::UNDEF);
 }
 
 /*public*/
-Label::Label(const Label &l)
+Label::Label(const Label& l)
 {
-	elt[0]=TopologyLocation(l.elt[0]);
-	elt[1]=TopologyLocation(l.elt[1]);
+    elt[0] = TopologyLocation(l.elt[0]);
+    elt[1] = TopologyLocation(l.elt[1]);
 }
 
 /*public*/
 Label&
-Label::operator=(const Label &l)
+Label::operator=(const Label& l)
 {
-	elt[0] = TopologyLocation(l.elt[0]);
-	elt[1] = TopologyLocation(l.elt[1]);
-	return *this;
+    elt[0] = TopologyLocation(l.elt[0]);
+    elt[1] = TopologyLocation(l.elt[1]);
+    return *this;
 }
 
 /*public*/
-Label::Label(int geomIndex,int onLoc,int leftLoc,int rightLoc)
+Label::Label(int geomIndex, int onLoc, int leftLoc, int rightLoc)
 {
-	elt[0]=TopologyLocation(Location::UNDEF,Location::UNDEF,Location::UNDEF);
-	elt[1]=TopologyLocation(Location::UNDEF,Location::UNDEF,Location::UNDEF);
-	elt[geomIndex].setLocations(onLoc,leftLoc,rightLoc);
+    elt[0] = TopologyLocation(Location::UNDEF, Location::UNDEF, Location::UNDEF);
+    elt[1] = TopologyLocation(Location::UNDEF, Location::UNDEF, Location::UNDEF);
+    elt[geomIndex].setLocations(onLoc, leftLoc, rightLoc);
 }
 
 /*public*/
 void
 Label::flip()
 {
-	elt[0].flip();
-	elt[1].flip();
+    elt[0].flip();
+    elt[1].flip();
 }
 
 /*public*/
 int
 Label::getLocation(int geomIndex, int posIndex) const
 {
-	assert(geomIndex>=0 && geomIndex<2);
-	return elt[geomIndex].get(posIndex);
+    assert(geomIndex >= 0 && geomIndex < 2);
+    return elt[geomIndex].get(posIndex);
 }
 
 /*public*/
 int
 Label::getLocation(int geomIndex) const
 {
-	assert(geomIndex>=0 && geomIndex<2);
-	return elt[geomIndex].get(Position::ON);
+    assert(geomIndex >= 0 && geomIndex < 2);
+    return elt[geomIndex].get(Position::ON);
 }
 
 /*public*/
 void
-Label::setLocation(int geomIndex,int posIndex,int location)
+Label::setLocation(int geomIndex, int posIndex, int location)
 {
-	assert(geomIndex>=0 && geomIndex<2);
-	elt[geomIndex].setLocation(posIndex,location);
+    assert(geomIndex >= 0 && geomIndex < 2);
+    elt[geomIndex].setLocation(posIndex, location);
 }
 
 /*public*/
 void
-Label::setLocation(int geomIndex,int location)
+Label::setLocation(int geomIndex, int location)
 {
-	assert(geomIndex>=0 && geomIndex<2);
-	elt[geomIndex].setLocation(Position::ON,location);
+    assert(geomIndex >= 0 && geomIndex < 2);
+    elt[geomIndex].setLocation(Position::ON, location);
 }
 
 /*public*/
 void
-Label::setAllLocations(int geomIndex,int location)
+Label::setAllLocations(int geomIndex, int location)
 {
-	assert(geomIndex>=0 && geomIndex<2);
-	elt[geomIndex].setAllLocations(location);
+    assert(geomIndex >= 0 && geomIndex < 2);
+    elt[geomIndex].setAllLocations(location);
 }
 
 /*public*/
 void
-Label::setAllLocationsIfNull(int geomIndex,int location)
+Label::setAllLocationsIfNull(int geomIndex, int location)
 {
-	assert(geomIndex>=0 && geomIndex<2);
-	elt[geomIndex].setAllLocationsIfNull(location);
+    assert(geomIndex >= 0 && geomIndex < 2);
+    elt[geomIndex].setAllLocationsIfNull(location);
 }
 
 /*public*/
 void
 Label::setAllLocationsIfNull(int location)
 {
-	setAllLocationsIfNull(0,location);
-	setAllLocationsIfNull(1,location);
+    setAllLocationsIfNull(0, location);
+    setAllLocationsIfNull(1, location);
 }
 
 /*public*/
 void
-Label::merge(const Label &lbl)
+Label::merge(const Label& lbl)
 {
-	for (int i=0; i<2; i++) {
-		elt[i].merge(lbl.elt[i]);
-	}
+    for(int i = 0; i < 2; i++) {
+        elt[i].merge(lbl.elt[i]);
+    }
 }
 
 /*public*/
 int
 Label::getGeometryCount() const
 {
-	int count = 0;
-	if (!elt[0].isNull()) count++;
-	if (!elt[1].isNull()) count++;
-	return count;
+    int count = 0;
+    if(!elt[0].isNull()) {
+        count++;
+    }
+    if(!elt[1].isNull()) {
+        count++;
+    }
+    return count;
 }
 
 /*public*/
 bool
 Label::isNull(int geomIndex) const
 {
-	assert(geomIndex>=0 && geomIndex<2);
-	return elt[geomIndex].isNull();
+    assert(geomIndex >= 0 && geomIndex < 2);
+    return elt[geomIndex].isNull();
 }
 
 /*public*/
 bool
 Label::isNull() const
 {
-	return elt[0].isNull() && elt[1].isNull();
+    return elt[0].isNull() && elt[1].isNull();
 }
 
 /*public*/
 bool
 Label::isAnyNull(int geomIndex) const
 {
-	assert(geomIndex>=0 && geomIndex<2);
-	return elt[geomIndex].isAnyNull();
+    assert(geomIndex >= 0 && geomIndex < 2);
+    return elt[geomIndex].isAnyNull();
 }
 
 /*public*/
 bool
 Label::isArea() const
 {
-	return elt[0].isArea() || elt[1].isArea();
+    return elt[0].isArea() || elt[1].isArea();
 }
 
 /*public*/
 bool
 Label::isArea(int geomIndex) const
 {
-	assert(geomIndex>=0 && geomIndex<2);
-	return elt[geomIndex].isArea();
+    assert(geomIndex >= 0 && geomIndex < 2);
+    return elt[geomIndex].isArea();
 }
 
 /*public*/
 bool
 Label::isLine(int geomIndex) const
 {
-	assert(geomIndex>=0 && geomIndex<2);
-	return elt[geomIndex].isLine();
+    assert(geomIndex >= 0 && geomIndex < 2);
+    return elt[geomIndex].isLine();
 }
 
 /*public*/
 bool
 Label::isEqualOnSide(const Label& lbl, int side) const
 {
-	return
-		elt[0].isEqualOnSide(lbl.elt[0], side)
-		&& elt[1].isEqualOnSide(lbl.elt[1], side);
+    return
+        elt[0].isEqualOnSide(lbl.elt[0], side)
+        && elt[1].isEqualOnSide(lbl.elt[1], side);
 }
 
 /*public*/
 bool
 Label::allPositionsEqual(int geomIndex, int loc) const
 {
-	assert(geomIndex>=0 && geomIndex<2);
-	return elt[geomIndex].allPositionsEqual(loc);
+    assert(geomIndex >= 0 && geomIndex < 2);
+    return elt[geomIndex].allPositionsEqual(loc);
 }
 
 /*public*/
 void
 Label::toLine(int geomIndex)
 {
-	assert(geomIndex>=0 && geomIndex<2);
-	if (elt[geomIndex].isArea()) {
-		elt[geomIndex]=TopologyLocation(elt[geomIndex].getLocations()[0]);
-	}
+    assert(geomIndex >= 0 && geomIndex < 2);
+    if(elt[geomIndex].isArea()) {
+        elt[geomIndex] = TopologyLocation(elt[geomIndex].getLocations()[0]);
+    }
 }
 
 string
 Label::toString() const
 {
-	stringstream ss;
-	ss << *this;
-	return ss.str();
+    stringstream ss;
+    ss << *this;
+    return ss.str();
 }
 
 std::ostream&
 operator<< (std::ostream& os, const Label& l)
 {
-	os << "A:"
-	   << l.elt[0]
-	   << " B:"
-	   << l.elt[1];
-	return os;
+    os << "A:"
+       << l.elt[0]
+       << " B:"
+       << l.elt[1];
+    return os;
 }
 
 } // namespace geos.geomgraph
diff --git a/src/geomgraph/Node.cpp b/src/geomgraph/Node.cpp
index 6f4a609..40209b3 100644
--- a/src/geomgraph/Node.cpp
+++ b/src/geomgraph/Node.cpp
@@ -48,193 +48,206 @@ namespace geomgraph { // geos.geomgraph
 
 /*public*/
 Node::Node(const Coordinate& newCoord, EdgeEndStar* newEdges)
-	:
-	GraphComponent(Label(0,Location::UNDEF)),
-	coord(newCoord),
-	edges(newEdges)
+    :
+    GraphComponent(Label(0, Location::UNDEF)),
+    coord(newCoord),
+    edges(newEdges)
 
 {
 #if GEOS_DEBUG
-	cerr<<"["<<this<<"] Node::Node("<<newCoord.toString()<<")"<<endl;
+    cerr << "[" << this << "] Node::Node(" << newCoord.toString() << ")" << endl;
 #endif
 
 #if COMPUTE_Z
-	ztot = 0;
-	addZ(newCoord.z);
-	if ( edges )
-	{
-		EdgeEndStar::iterator endIt = edges->end();
-		for (EdgeEndStar::iterator it=edges->begin(); it!=endIt; ++it)
-		{
-			EdgeEnd *ee = *it;
-			addZ(ee->getCoordinate().z);
-		}
-	}
+    ztot = 0;
+    addZ(newCoord.z);
+    if(edges) {
+        EdgeEndStar::iterator endIt = edges->end();
+        for(EdgeEndStar::iterator it = edges->begin(); it != endIt; ++it) {
+            EdgeEnd* ee = *it;
+            addZ(ee->getCoordinate().z);
+        }
+    }
 #endif // COMPUTE_Z
 
-	testInvariant();
+    testInvariant();
 }
 
 /*public*/
 Node::~Node()
 {
-	testInvariant();
+    testInvariant();
 #if GEOS_DEBUG
-	cerr<<"["<<this<<"] Node::~Node()"<<endl;
+    cerr << "[" << this << "] Node::~Node()" << endl;
 #endif
-	delete edges;
+    delete edges;
 }
 
 /*public*/
 const Coordinate&
 Node::getCoordinate() const
 {
-	testInvariant();
-	return coord;
+    testInvariant();
+    return coord;
 }
 
 /*public*/
-EdgeEndStar *
+EdgeEndStar*
 Node::getEdges()
 {
-	testInvariant();
+    testInvariant();
 
-	return edges;
+    return edges;
 }
 
 /*public*/
 bool
 Node::isIsolated() const
 {
-	testInvariant();
+    testInvariant();
 
-	return (label.getGeometryCount()==1);
+    return (label.getGeometryCount() == 1);
 }
 
 /*public*/
 bool
 Node::isIncidentEdgeInResult() const
 {
-	testInvariant();
-
-	if (!edges) return false;
-
-	EdgeEndStar::iterator it=edges->begin();
-	EdgeEndStar::iterator endIt=edges->end();
-	for ( ; it!=endIt; ++it)
-	{
-		assert(*it);
-		assert(dynamic_cast<DirectedEdge *>(*it));
-		DirectedEdge *de = static_cast<DirectedEdge *>(*it);
-		if ( de->getEdge()->isInResult() ) return true;
-	}
-	return false;
+    testInvariant();
+
+    if(!edges) {
+        return false;
+    }
+
+    EdgeEndStar::iterator it = edges->begin();
+    EdgeEndStar::iterator endIt = edges->end();
+    for(; it != endIt; ++it) {
+        assert(*it);
+        assert(dynamic_cast<DirectedEdge*>(*it));
+        DirectedEdge* de = static_cast<DirectedEdge*>(*it);
+        if(de->getEdge()->isInResult()) {
+            return true;
+        }
+    }
+    return false;
 }
 
 void
-Node::add(EdgeEnd *e)
+Node::add(EdgeEnd* e)
 {
-	assert(e);
+    assert(e);
 #if GEOS_DEBUG
-	cerr<<"["<<this<<"] Node::add("<<e->print()<<")"<<endl;
+    cerr << "[" << this << "] Node::add(" << e->print() << ")" << endl;
 #endif
-	// Assert: start pt of e is equal to node point
-	if ( ! e->getCoordinate().equals2D(coord) ) {
-		std::stringstream ss;
-		ss << "EdgeEnd with coordinate " << e->getCoordinate()
-		   << " invalid for node " << coord;
-		throw util::IllegalArgumentException(ss.str());
-  }
-
-	// It seems it's legal for edges to be NULL
-	// we'd not be honouring the promise of adding
-	// an EdgeEnd in this case, though ...
-	assert(edges);
-	//if (edges==NULL) return;
-
-	edges->insert(e);
-	e->setNode(this);
+    // Assert: start pt of e is equal to node point
+    if(! e->getCoordinate().equals2D(coord)) {
+        std::stringstream ss;
+        ss << "EdgeEnd with coordinate " << e->getCoordinate()
+           << " invalid for node " << coord;
+        throw util::IllegalArgumentException(ss.str());
+    }
+
+    // It seems it's legal for edges to be NULL
+    // we'd not be honouring the promise of adding
+    // an EdgeEnd in this case, though ...
+    assert(edges);
+    //if (edges==NULL) return;
+
+    edges->insert(e);
+    e->setNode(this);
 #if COMPUTE_Z
-	addZ(e->getCoordinate().z);
+    addZ(e->getCoordinate().z);
 #endif
-	testInvariant();
+    testInvariant();
 }
 
 /*public*/
 void
 Node::mergeLabel(const Node& n)
 {
-	assert(!n.label.isNull());
-	mergeLabel(n.label);
-	testInvariant();
+    assert(!n.label.isNull());
+    mergeLabel(n.label);
+    testInvariant();
 }
 
 /*public*/
 void
 Node::mergeLabel(const Label& label2)
 {
-	for (int i=0; i<2; i++) {
-		int loc=computeMergedLocation(label2, i);
-		int thisLoc=label.getLocation(i);
-		if (thisLoc==Location::UNDEF) label.setLocation(i,loc);
-	}
-	testInvariant();
+    for(int i = 0; i < 2; i++) {
+        int loc = computeMergedLocation(label2, i);
+        int thisLoc = label.getLocation(i);
+        if(thisLoc == Location::UNDEF) {
+            label.setLocation(i, loc);
+        }
+    }
+    testInvariant();
 }
 
 /*public*/
 void
 Node::setLabel(int argIndex, int onLocation)
 {
-	if ( label.isNull() ) {
-		label = Label(argIndex, onLocation);
-	} else
-		label.setLocation(argIndex, onLocation);
-
-	testInvariant();
+    if(label.isNull()) {
+        label = Label(argIndex, onLocation);
+    }
+    else {
+        label.setLocation(argIndex, onLocation);
+    }
+
+    testInvariant();
 }
 
 /*public*/
 void
 Node::setLabelBoundary(int argIndex)
 {
-	int loc = label.getLocation(argIndex);
-	// flip the loc
-	int newLoc;
-	switch (loc){
-		case Location::BOUNDARY: newLoc=Location::INTERIOR; break;
-		case Location::INTERIOR: newLoc=Location::BOUNDARY; break;
-		default: newLoc=Location::BOUNDARY;  break;
-	}
-	label.setLocation(argIndex, newLoc);
-
-	testInvariant();
+    int loc = label.getLocation(argIndex);
+    // flip the loc
+    int newLoc;
+    switch(loc) {
+    case Location::BOUNDARY:
+        newLoc = Location::INTERIOR;
+        break;
+    case Location::INTERIOR:
+        newLoc = Location::BOUNDARY;
+        break;
+    default:
+        newLoc = Location::BOUNDARY;
+        break;
+    }
+    label.setLocation(argIndex, newLoc);
+
+    testInvariant();
 }
 
 /*public*/
 int
 Node::computeMergedLocation(const Label& label2, int eltIndex)
 {
-	int loc=Location::UNDEF;
-	loc=label.getLocation(eltIndex);
-	if (!label2.isNull(eltIndex)) {
-		int nLoc=label2.getLocation(eltIndex);
-		if (loc!=Location::BOUNDARY) loc=nLoc;
-	}
-
-	testInvariant();
-
-	return loc;
+    int loc = Location::UNDEF;
+    loc = label.getLocation(eltIndex);
+    if(!label2.isNull(eltIndex)) {
+        int nLoc = label2.getLocation(eltIndex);
+        if(loc != Location::BOUNDARY) {
+            loc = nLoc;
+        }
+    }
+
+    testInvariant();
+
+    return loc;
 }
 
 /*public*/
 string
 Node::print()
 {
-	testInvariant();
+    testInvariant();
 
-	ostringstream ss;
-	ss<<*this;
-	return ss.str();
+    ostringstream ss;
+    ss << *this;
+    return ss.str();
 }
 
 /*public*/
@@ -242,27 +255,25 @@ void
 Node::addZ(double z)
 {
 #if GEOS_DEBUG
-	cerr<<"["<<this<<"] Node::addZ("<<z<<")";
+    cerr << "[" << this << "] Node::addZ(" << z << ")";
 #endif
-	if ( std::isnan(z) )
-	{
+    if(std::isnan(z)) {
 #if GEOS_DEBUG
-		cerr<<" skipped"<<endl;
+        cerr << " skipped" << endl;
 #endif
-		return;
-	}
-	if ( find(zvals.begin(), zvals.end(), z) != zvals.end() )
-	{
+        return;
+    }
+    if(find(zvals.begin(), zvals.end(), z) != zvals.end()) {
 #if GEOS_DEBUG
-		cerr<<" already stored"<<endl;
+        cerr << " already stored" << endl;
 #endif
-		return;
-	}
-	zvals.push_back(z);
-	ztot+=z;
-	coord.z = ztot / static_cast<double>(zvals.size());
+        return;
+    }
+    zvals.push_back(z);
+    ztot += z;
+    coord.z = ztot / static_cast<double>(zvals.size());
 #if GEOS_DEBUG
-	cerr<<" added "<<z<<": ["<<ztot<<"/"<<zvals.size()<<"="<<coord.z<<"]"<<endl;
+    cerr << " added " << z << ": [" << ztot << "/" << zvals.size() << "=" << coord.z << "]" << endl;
 #endif
 }
 
@@ -270,15 +281,16 @@ Node::addZ(double z)
 const vector<double>&
 Node::getZ() const
 {
-	return zvals;
+    return zvals;
 }
 
-std::ostream& operator<< (std::ostream& os, const Node& node)
+std::ostream&
+operator<< (std::ostream& os, const Node& node)
 {
-	os << "Node["<<&node<<"]" << std::endl
-	   << "  POINT(" << node.coord << ")" << std::endl
-	   << "  lbl: " << node.label;
-	return os;
+    os << "Node[" << &node << "]" << std::endl
+       << "  POINT(" << node.coord << ")" << std::endl
+       << "  lbl: " << node.label;
+    return os;
 }
 
 } // namespace geos.geomgraph
diff --git a/src/geomgraph/NodeFactory.cpp b/src/geomgraph/NodeFactory.cpp
index ae1a754..539c479 100644
--- a/src/geomgraph/NodeFactory.cpp
+++ b/src/geomgraph/NodeFactory.cpp
@@ -25,17 +25,17 @@ using namespace geos::geom;
 namespace geos {
 namespace geomgraph { // geos.geomgraph
 
-Node *
-NodeFactory::createNode(const Coordinate &coord) const
+Node*
+NodeFactory::createNode(const Coordinate& coord) const
 {
-	return new Node(coord,nullptr);
+    return new Node(coord, nullptr);
 }
 
-const NodeFactory &
+const NodeFactory&
 NodeFactory::instance()
 {
-	static const NodeFactory nf;
-	return nf;
+    static const NodeFactory nf;
+    return nf;
 }
 
 
diff --git a/src/geomgraph/NodeMap.cpp b/src/geomgraph/NodeMap.cpp
index 44ebc92..c74ecd6 100644
--- a/src/geomgraph/NodeMap.cpp
+++ b/src/geomgraph/NodeMap.cpp
@@ -38,91 +38,88 @@ using namespace geos::geom;
 namespace geos {
 namespace geomgraph { // geos.geomgraph
 
-NodeMap::NodeMap(const NodeFactory &newNodeFact)
-	:
-	nodeFact(newNodeFact)
+NodeMap::NodeMap(const NodeFactory& newNodeFact)
+    :
+    nodeFact(newNodeFact)
 {
 #if GEOS_DEBUG
-	cerr<<"["<<this<<"] NodeMap::NodeMap"<<endl;
+    cerr << "[" << this << "] NodeMap::NodeMap" << endl;
 #endif
 }
 
 NodeMap::~NodeMap()
 {
-	NodeMap::const_iterator it=nodeMap.begin();
-	for (;it!=nodeMap.end();it++) {
-		delete it->second;
-	}
+    NodeMap::const_iterator it = nodeMap.begin();
+    for(; it != nodeMap.end(); it++) {
+        delete it->second;
+    }
 }
 
 Node*
 NodeMap::addNode(const Coordinate& coord)
 {
 #if GEOS_DEBUG
-        cerr<<"["<<this<<"] NodeMap::addNode("<<coord.toString()<<")";
+    cerr << "[" << this << "] NodeMap::addNode(" << coord.toString() << ")";
 #endif
-        Node *node=find(coord);
-        if (node==nullptr) {
+    Node* node = find(coord);
+    if(node == nullptr) {
 #if GEOS_DEBUG
-                cerr<<" is new"<<endl;
+        cerr << " is new" << endl;
 #endif
-                node=nodeFact.createNode(coord);
-		Coordinate* c = const_cast<Coordinate *>(
-			&(node->getCoordinate()));
-                nodeMap[c]=node;
-                //nodeMap[const_cast<Coordinate *>(&coord)]=node;
-        }
-        else
-        {
+        node = nodeFact.createNode(coord);
+        Coordinate* c = const_cast<Coordinate*>(
+                            &(node->getCoordinate()));
+        nodeMap[c] = node;
+        //nodeMap[const_cast<Coordinate *>(&coord)]=node;
+    }
+    else {
 #if GEOS_DEBUG
-                cerr<<" already found ("<<node->getCoordinate().toString()<<") - adding Z"<<endl;
+        cerr << " already found (" << node->getCoordinate().toString() << ") - adding Z" << endl;
 #endif
-                node->addZ(coord.z);
-        }
-        return node;
+        node->addZ(coord.z);
+    }
+    return node;
 }
 
 // first arg cannot be const because
 // it is liable to label-merging ... --strk;
 Node*
-NodeMap::addNode(Node *n)
+NodeMap::addNode(Node* n)
 {
-	assert(n);
+    assert(n);
 
 #if GEOS_DEBUG
-	cerr<<"["<<this<<"] NodeMap::addNode("<<n->print()<<")";
+    cerr << "[" << this << "] NodeMap::addNode(" << n->print() << ")";
 #endif
-	Coordinate *c=const_cast<Coordinate *>(&n->getCoordinate());
-	Node *node=find(*c);
-	if (node==nullptr) {
+    Coordinate* c = const_cast<Coordinate*>(&n->getCoordinate());
+    Node* node = find(*c);
+    if(node == nullptr) {
 #if GEOS_DEBUG
-		cerr<<" is new"<<endl;
+        cerr << " is new" << endl;
 #endif
-		nodeMap[c]=n;
-		return n;
-	}
+        nodeMap[c] = n;
+        return n;
+    }
 #if GEOS_DEBUG
-	else
-	{
-		cerr<<" found already, merging label"<<endl;
-		const vector<double>&zvals = n->getZ();
-		for (unsigned int i=0; i<zvals.size(); i++)
-		{
-			node->addZ(zvals[i]);
-		}
-	}
+    else {
+        cerr << " found already, merging label" << endl;
+        const vector<double>& zvals = n->getZ();
+        for(unsigned int i = 0; i < zvals.size(); i++) {
+            node->addZ(zvals[i]);
+        }
+    }
 #endif // GEOS_DEBUG
 
-	node->mergeLabel(*n);
-	return node;
+    node->mergeLabel(*n);
+    return node;
 }
 
 void
-NodeMap::add(EdgeEnd *e)
+NodeMap::add(EdgeEnd* e)
 {
-	Coordinate& p=e->getCoordinate();
-	Node *n=addNode(p);
-	n->add(e);
+    Coordinate& p = e->getCoordinate();
+    Node* n = addNode(p);
+    n->add(e);
 }
 
 /*
@@ -131,37 +128,40 @@ NodeMap::add(EdgeEnd *e)
 Node*
 NodeMap::find(const Coordinate& coord) const
 {
-	Coordinate *c=const_cast<Coordinate *>(&coord);
+    Coordinate* c = const_cast<Coordinate*>(&coord);
 
-	NodeMap::const_iterator found=nodeMap.find(c);
+    NodeMap::const_iterator found = nodeMap.find(c);
 
-	if (found==nodeMap.end())
-		return nullptr;
-	else
-		return found->second;
+    if(found == nodeMap.end()) {
+        return nullptr;
+    }
+    else {
+        return found->second;
+    }
 }
 
 void
-NodeMap::getBoundaryNodes(int geomIndex, vector<Node*>&bdyNodes) const
+NodeMap::getBoundaryNodes(int geomIndex, vector<Node*>& bdyNodes) const
 {
-	NodeMap::const_iterator it=nodeMap.begin();
-	for (;it!=nodeMap.end();it++) {
-		Node *node=it->second;
-		if (node->getLabel().getLocation(geomIndex)==Location::BOUNDARY)
-			bdyNodes.push_back(node);
-	}
+    NodeMap::const_iterator it = nodeMap.begin();
+    for(; it != nodeMap.end(); it++) {
+        Node* node = it->second;
+        if(node->getLabel().getLocation(geomIndex) == Location::BOUNDARY) {
+            bdyNodes.push_back(node);
+        }
+    }
 }
 
 string
 NodeMap::print() const
 {
-	string out="";
-	NodeMap::const_iterator it=nodeMap.begin();
-	for (;it!=nodeMap.end();it++) {
-		Node *node=it->second;
-		out+=node->print();
-	}
-	return out;
+    string out = "";
+    NodeMap::const_iterator it = nodeMap.begin();
+    for(; it != nodeMap.end(); it++) {
+        Node* node = it->second;
+        out += node->print();
+    }
+    return out;
 }
 
 } // namespace geos.geomgraph
diff --git a/src/geomgraph/PlanarGraph.cpp b/src/geomgraph/PlanarGraph.cpp
index 18d9d04..57b79df 100644
--- a/src/geomgraph/PlanarGraph.cpp
+++ b/src/geomgraph/PlanarGraph.cpp
@@ -51,20 +51,20 @@ namespace geos {
 namespace geomgraph { // geos.geomgraph
 
 /*public*/
-PlanarGraph::PlanarGraph(const NodeFactory &nodeFact)
-	:
-	edges(new vector<Edge*>()),
-	nodes(new NodeMap(nodeFact)),
-	edgeEndList(new vector<EdgeEnd*>())
+PlanarGraph::PlanarGraph(const NodeFactory& nodeFact)
+    :
+    edges(new vector<Edge*>()),
+    nodes(new NodeMap(nodeFact)),
+    edgeEndList(new vector<EdgeEnd*>())
 {
 }
 
 /*public*/
 PlanarGraph::PlanarGraph()
-	:
-	edges(new vector<Edge*>()),
-	nodes(new NodeMap(NodeFactory::instance())),
-	edgeEndList(new vector<EdgeEnd*>())
+    :
+    edges(new vector<Edge*>()),
+    nodes(new NodeMap(NodeFactory::instance())),
+    edgeEndList(new vector<EdgeEnd*>())
 {
 }
 
@@ -72,110 +72,113 @@ PlanarGraph::PlanarGraph()
 PlanarGraph::~PlanarGraph()
 {
 #if GEOS_DEBUG
-	std::cerr << "~PlanarGraph" << std::endl;
+    std::cerr << "~PlanarGraph" << std::endl;
 #endif
 
-	delete nodes;
+    delete nodes;
 #if 1 // FIXME: PlanarGraph should *not* own edges!
-	for(size_t i=0, n=edges->size(); i<n; i++) {
-		delete (*edges)[i];
-	}
+    for(size_t i = 0, n = edges->size(); i < n; i++) {
+        delete(*edges)[i];
+    }
 #endif
-	delete edges;
+    delete edges;
 
-	for(size_t i=0, n=edgeEndList->size(); i<n; i++) {
-		delete (*edgeEndList)[i];
-	}
-	delete edgeEndList;
+    for(size_t i = 0, n = edgeEndList->size(); i < n; i++) {
+        delete(*edgeEndList)[i];
+    }
+    delete edgeEndList;
 }
 
 /*public*/
 vector<Edge*>::iterator
 PlanarGraph::getEdgeIterator()
 {
-	assert(edges);
-	return edges->begin();
+    assert(edges);
+    return edges->begin();
 }
 
 /*public*/
-vector<EdgeEnd*> *
+vector<EdgeEnd*>*
 PlanarGraph::getEdgeEnds()
 {
-	return edgeEndList;
+    return edgeEndList;
 }
 
 /*public*/
 bool
 PlanarGraph::isBoundaryNode(int geomIndex, const Coordinate& coord)
 {
-	assert(nodes);
+    assert(nodes);
 
-	Node *node=nodes->find(coord);
-	if (node==nullptr) return false;
+    Node* node = nodes->find(coord);
+    if(node == nullptr) {
+        return false;
+    }
 
-	const Label& label = node->getLabel();
-	if (! label.isNull() && label.getLocation(geomIndex)==Location::BOUNDARY)
-			return true;
+    const Label& label = node->getLabel();
+    if(! label.isNull() && label.getLocation(geomIndex) == Location::BOUNDARY) {
+        return true;
+    }
 
-	return false;
+    return false;
 }
 
 /*protected*/
 void
-PlanarGraph::insertEdge(Edge *e)
+PlanarGraph::insertEdge(Edge* e)
 {
-	assert(e);
-	assert(edges);
-	edges->push_back(e);
+    assert(e);
+    assert(edges);
+    edges->push_back(e);
 }
 
 /*public*/
 void
 PlanarGraph::add(EdgeEnd* e)
 {
-	// It is critical to add the edge to the edgeEndList first,
-	// then it is safe to follow with any potentially throwing operations.
-	assert(edgeEndList);
-	edgeEndList->push_back(e);
-
-	assert(e);
-	assert(nodes);
-	nodes->add(e);
+    // It is critical to add the edge to the edgeEndList first,
+    // then it is safe to follow with any potentially throwing operations.
+    assert(edgeEndList);
+    edgeEndList->push_back(e);
+
+    assert(e);
+    assert(nodes);
+    nodes->add(e);
 }
 
 /*public*/
 NodeMap::iterator
 PlanarGraph::getNodeIterator()
 {
-	assert(nodes);
-	return nodes->begin();
+    assert(nodes);
+    return nodes->begin();
 }
 
 /*public*/
 void
 PlanarGraph::getNodes(vector<Node*>& values)
 {
-	assert(nodes);
-	NodeMap::iterator it=nodes->nodeMap.begin();
-	while(it!=nodes->nodeMap.end()) {
-		assert(it->second);
-		values.push_back(it->second);
-		it++;
-	}
+    assert(nodes);
+    NodeMap::iterator it = nodes->nodeMap.begin();
+    while(it != nodes->nodeMap.end()) {
+        assert(it->second);
+        values.push_back(it->second);
+        it++;
+    }
 }
 
 // arg cannot be const, NodeMap::addNode will
 // occasionally label-merge first arg.
 /*public*/
 Node*
-PlanarGraph::addNode(Node *node)
+PlanarGraph::addNode(Node* node)
 {
-	assert(nodes);
+    assert(nodes);
 #if GEOS_DEBUG > 1
-	cerr << "PlanarGraph::addNode(Node * " << *node
-		<< ")" << endl;
+    cerr << "PlanarGraph::addNode(Node * " << *node
+         << ")" << endl;
 #endif
-	return nodes->addNode(node);
+    return nodes->addNode(node);
 }
 
 /*public*/
@@ -183,44 +186,43 @@ Node*
 PlanarGraph::addNode(const Coordinate& coord)
 {
 #if GEOS_DEBUG > 1
-	cerr << "PlanarGraph::addNode(Coordinate& "
-		<< coord << ")" << endl;
+    cerr << "PlanarGraph::addNode(Coordinate& "
+         << coord << ")" << endl;
 #endif
-	return nodes->addNode(coord);
+    return nodes->addNode(coord);
 }
 
 /*public*/
 Node*
 PlanarGraph::find(Coordinate& coord)
 {
-	assert(nodes);
-	return nodes->find(coord);
+    assert(nodes);
+    return nodes->find(coord);
 }
 
 /*public*/
 void
 PlanarGraph::addEdges(const vector<Edge*>& edgesToAdd)
 {
-	// create all the nodes for the edges
-	for (vector<Edge*>::const_iterator it=edgesToAdd.begin(),
-		endIt=edgesToAdd.end(); it!=endIt; ++it)
-	{
-		Edge *e=*it;
-		assert(e);
-		edges->push_back(e);
-
-		// PlanarGraph destructor will delete all DirectedEdges
-		// in edgeEndList, which is where these are added
-		// by the ::add(EdgeEnd) call
-		std::unique_ptr<DirectedEdge> de1(new DirectedEdge(e, true));
-		std::unique_ptr<DirectedEdge> de2(new DirectedEdge(e, false));
-		de1->setSym(de2.get());
-		de2->setSym(de1.get());
-
-		// First, ::add takes the ownership, then follows with operations that may throw.
-		add(de1.release());
-		add(de2.release());
-	}
+    // create all the nodes for the edges
+    for(vector<Edge*>::const_iterator it = edgesToAdd.begin(),
+            endIt = edgesToAdd.end(); it != endIt; ++it) {
+        Edge* e = *it;
+        assert(e);
+        edges->push_back(e);
+
+        // PlanarGraph destructor will delete all DirectedEdges
+        // in edgeEndList, which is where these are added
+        // by the ::add(EdgeEnd) call
+        std::unique_ptr<DirectedEdge> de1(new DirectedEdge(e, true));
+        std::unique_ptr<DirectedEdge> de2(new DirectedEdge(e, false));
+        de1->setSym(de2.get());
+        de2->setSym(de1.get());
+
+        // First, ::add takes the ownership, then follows with operations that may throw.
+        add(de1.release());
+        add(de2.release());
+    }
 }
 
 /*public static*/
@@ -228,21 +230,21 @@ void
 PlanarGraph::linkResultDirectedEdges()
 {
 #if GEOS_DEBUG
-	cerr<<"PlanarGraph::linkResultDirectedEdges called"<<endl;
+    cerr << "PlanarGraph::linkResultDirectedEdges called" << endl;
 #endif
-	NodeMap::iterator nodeit=nodes->nodeMap.begin();
-	for (;nodeit!=nodes->nodeMap.end();nodeit++) {
-		Node *node=nodeit->second;
-		assert(node);
-
-		EdgeEndStar* ees=node->getEdges();
-		assert(ees);
-		assert(dynamic_cast<DirectedEdgeStar*>(ees));
-		DirectedEdgeStar* des = static_cast<DirectedEdgeStar*>(ees);
-
-		// this might throw an exception
-		des->linkResultDirectedEdges();
-	}
+    NodeMap::iterator nodeit = nodes->nodeMap.begin();
+    for(; nodeit != nodes->nodeMap.end(); nodeit++) {
+        Node* node = nodeit->second;
+        assert(node);
+
+        EdgeEndStar* ees = node->getEdges();
+        assert(ees);
+        assert(dynamic_cast<DirectedEdgeStar*>(ees));
+        DirectedEdgeStar* des = static_cast<DirectedEdgeStar*>(ees);
+
+        // this might throw an exception
+        des->linkResultDirectedEdges();
+    }
 }
 
 /*
@@ -254,109 +256,108 @@ void
 PlanarGraph::linkAllDirectedEdges()
 {
 #if GEOS_DEBUG
-	cerr<<"PlanarGraph::linkAllDirectedEdges called"<<endl;
+    cerr << "PlanarGraph::linkAllDirectedEdges called" << endl;
 #endif
-	NodeMap::iterator nodeit=nodes->nodeMap.begin();
-	for (;nodeit!=nodes->nodeMap.end();nodeit++)
-	{
-		Node *node=nodeit->second;
-		assert(node);
+    NodeMap::iterator nodeit = nodes->nodeMap.begin();
+    for(; nodeit != nodes->nodeMap.end(); nodeit++) {
+        Node* node = nodeit->second;
+        assert(node);
 
-		EdgeEndStar *ees=node->getEdges();
-		assert(ees);
+        EdgeEndStar* ees = node->getEdges();
+        assert(ees);
 
-		// Unespected non-DirectedEdgeStar in node
-		assert(dynamic_cast<DirectedEdgeStar *>(ees));
-		DirectedEdgeStar *des=static_cast<DirectedEdgeStar *>(ees);
+        // Unespected non-DirectedEdgeStar in node
+        assert(dynamic_cast<DirectedEdgeStar*>(ees));
+        DirectedEdgeStar* des = static_cast<DirectedEdgeStar*>(ees);
 
-		des->linkAllDirectedEdges();
-	}
+        des->linkAllDirectedEdges();
+    }
 }
 
 /*public*/
 EdgeEnd*
-PlanarGraph::findEdgeEnd(Edge *e)
+PlanarGraph::findEdgeEnd(Edge* e)
 {
-	vector<EdgeEnd*>* eev=getEdgeEnds();
-	assert(eev);
-
-	for (vector<EdgeEnd*>::iterator i=eev->begin(), iEnd=eev->end();
-			i != iEnd;
-			++i)
-	{
-		EdgeEnd *ee=*i;
-		assert(ee);
-
-		// should test using values rather then pointers ?
-		if (ee->getEdge()==e) return ee;
-	}
-	return nullptr;
+    vector<EdgeEnd*>* eev = getEdgeEnds();
+    assert(eev);
+
+    for(vector<EdgeEnd*>::iterator i = eev->begin(), iEnd = eev->end();
+            i != iEnd;
+            ++i) {
+        EdgeEnd* ee = *i;
+        assert(ee);
+
+        // should test using values rather then pointers ?
+        if(ee->getEdge() == e) {
+            return ee;
+        }
+    }
+    return nullptr;
 }
 
 /*public*/
 Edge*
 PlanarGraph::findEdge(const Coordinate& p0, const Coordinate& p1)
 {
-	for (size_t i=0, n=edges->size(); i<n; ++i)
-	{
-		Edge *e=(*edges)[i];
-		assert(e);
-
-		const CoordinateSequence* eCoord=e->getCoordinates();
-		assert(eCoord);
-
-		if (p0==eCoord->getAt(0) && p1==eCoord->getAt(1))
-			return e;
-	}
-	return nullptr;
+    for(size_t i = 0, n = edges->size(); i < n; ++i) {
+        Edge* e = (*edges)[i];
+        assert(e);
+
+        const CoordinateSequence* eCoord = e->getCoordinates();
+        assert(eCoord);
+
+        if(p0 == eCoord->getAt(0) && p1 == eCoord->getAt(1)) {
+            return e;
+        }
+    }
+    return nullptr;
 }
 
 /*public*/
 Edge*
 PlanarGraph::findEdgeInSameDirection(const Coordinate& p0,
-		const Coordinate& p1)
+                                     const Coordinate& p1)
 {
-	for(size_t i=0, n=edges->size(); i<n; i++)
-	{
-		Edge *e=(*edges)[i];
-		assert(e);
-
-		const CoordinateSequence* eCoord=e->getCoordinates();
-		assert(eCoord);
-
-		size_t nCoords=eCoord->size();
-		assert(nCoords>1);
-
-		if (matchInSameDirection(p0, p1,
-				eCoord->getAt(0),
-				eCoord->getAt(1)))
-		{
-			return e;
-		}
-
-		if (matchInSameDirection(p0, p1,
-				eCoord->getAt(nCoords-1),
-				eCoord->getAt(nCoords-2)))
-		{
-			return e;
-		}
-	}
-
-	return nullptr;
+    for(size_t i = 0, n = edges->size(); i < n; i++) {
+        Edge* e = (*edges)[i];
+        assert(e);
+
+        const CoordinateSequence* eCoord = e->getCoordinates();
+        assert(eCoord);
+
+        size_t nCoords = eCoord->size();
+        assert(nCoords > 1);
+
+        if(matchInSameDirection(p0, p1,
+                                eCoord->getAt(0),
+                                eCoord->getAt(1))) {
+            return e;
+        }
+
+        if(matchInSameDirection(p0, p1,
+                                eCoord->getAt(nCoords - 1),
+                                eCoord->getAt(nCoords - 2))) {
+            return e;
+        }
+    }
+
+    return nullptr;
 }
 
 /*private*/
 bool
 PlanarGraph::matchInSameDirection(const Coordinate& p0, const Coordinate& p1,
-		const Coordinate& ep0, const Coordinate& ep1)
+                                  const Coordinate& ep0, const Coordinate& ep1)
 {
-	if (!(p0==ep0))
-		return false;
-
-	if (Orientation::index(p0,p1,ep1)==Orientation::COLLINEAR
-		&& Quadrant::quadrant(p0,p1)==Quadrant::quadrant(ep0,ep1))
-			return true;
-	return false;
+    if(!(p0 == ep0)) {
+        return false;
+    }
+
+    if(Orientation::index(p0, p1, ep1) == Orientation::COLLINEAR
+            && Quadrant::quadrant(p0, p1) == Quadrant::quadrant(ep0, ep1)) {
+        return true;
+    }
+    return false;
 }
 
 string
@@ -365,18 +366,17 @@ PlanarGraph::printEdges()
 
     std::ostringstream oss;
     oss << "Edges: ";
-	for(size_t i=0, n=edges->size(); i<n; ++i)
-	{
-        Edge *e=(*edges)[i];
-		oss << "edge " << i << ":\n" << e->print() << e->eiList.print();
-	}
+    for(size_t i = 0, n = edges->size(); i < n; ++i) {
+        Edge* e = (*edges)[i];
+        oss << "edge " << i << ":\n" << e->print() << e->eiList.print();
+    }
     return oss.str();
 }
 
 NodeMap*
 PlanarGraph::getNodeMap()
 {
-	return nodes;
+    return nodes;
 }
 
 } // namespace geos.geomgraph
diff --git a/src/geomgraph/Position.cpp b/src/geomgraph/Position.cpp
index 2933ccf..275f3c4 100644
--- a/src/geomgraph/Position.cpp
+++ b/src/geomgraph/Position.cpp
@@ -34,13 +34,20 @@ namespace geomgraph { // geos.geomgraph
 * Returns LEFT if the position is RIGHT, RIGHT if the position is LEFT, or the position
 * otherwise.
 */
-int Position::opposite(int position){
-	if (position==LEFT) return RIGHT;
-	if (position==RIGHT) return LEFT;
+int
+Position::opposite(int position)
+{
+    if(position == LEFT) {
+        return RIGHT;
+    }
+    if(position == RIGHT) {
+        return LEFT;
+    }
 #if GEOS_DEBUG
-	std::cerr<<"Position::opposite: position is neither LEFT ("<<LEFT<<") nor RIGHT ("<<RIGHT<<") but "<<position<<std::endl;
+    std::cerr << "Position::opposite: position is neither LEFT (" << LEFT << ") nor RIGHT (" << RIGHT << ") but " <<
+              position << std::endl;
 #endif
-	return position;
+    return position;
 }
 
 } // namespace geos.geomgraph
diff --git a/src/geomgraph/Quadrant.cpp b/src/geomgraph/Quadrant.cpp
index dc026c1..a668279 100644
--- a/src/geomgraph/Quadrant.cpp
+++ b/src/geomgraph/Quadrant.cpp
@@ -33,95 +33,113 @@ namespace geomgraph { // geos.geomgraph
 int
 Quadrant::quadrant(double dx, double dy)
 {
-	if (dx == 0.0 && dy == 0.0) {
-		ostringstream s;
-		s<<"Cannot compute the quadrant for point ";
-		s<<"("<<dx<<","<<dy<<")"<<endl;
-		throw util::IllegalArgumentException(s.str());
-	}
-	if (dx >= 0) {
-		if (dy >= 0)
-			return NE;
-		else
-			return SE;
-	} else {
-		if (dy >= 0)
-			return NW;
-		else
-			return SW;
-	}
+    if(dx == 0.0 && dy == 0.0) {
+        ostringstream s;
+        s << "Cannot compute the quadrant for point ";
+        s << "(" << dx << "," << dy << ")" << endl;
+        throw util::IllegalArgumentException(s.str());
+    }
+    if(dx >= 0) {
+        if(dy >= 0) {
+            return NE;
+        }
+        else {
+            return SE;
+        }
+    }
+    else {
+        if(dy >= 0) {
+            return NW;
+        }
+        else {
+            return SW;
+        }
+    }
 }
 
 /* public static */
 int
 Quadrant::quadrant(const Coordinate& p0, const Coordinate& p1)
 {
-	if (p1.x == p0.x && p1.y == p0.y)
-	{
-		throw util::IllegalArgumentException("Cannot compute the quadrant for two identical points " + p0.toString());
-	}
+    if(p1.x == p0.x && p1.y == p0.y) {
+        throw util::IllegalArgumentException("Cannot compute the quadrant for two identical points " + p0.toString());
+    }
 
-	if (p1.x >= p0.x) {
-		if (p1.y >= p0.y)
-			return NE;
-		else
-			return SE;
-	}
-	else {
-		if (p1.y >= p0.y)
-			return NW;
-		else
-			return SW;
-	}
+    if(p1.x >= p0.x) {
+        if(p1.y >= p0.y) {
+            return NE;
+        }
+        else {
+            return SE;
+        }
+    }
+    else {
+        if(p1.y >= p0.y) {
+            return NW;
+        }
+        else {
+            return SW;
+        }
+    }
 }
 
 /* public static */
 bool
 Quadrant::isOpposite(int quad1, int quad2)
 {
-	if (quad1==quad2) return false;
-	int diff=(quad1-quad2+4)%4;
-	// if quadrants are not adjacent, they are opposite
-	if (diff==2) return true;
-	return false;
+    if(quad1 == quad2) {
+        return false;
+    }
+    int diff = (quad1 - quad2 + 4) % 4;
+    // if quadrants are not adjacent, they are opposite
+    if(diff == 2) {
+        return true;
+    }
+    return false;
 }
 
 /* public static */
 int
 Quadrant::commonHalfPlane(int quad1, int quad2)
 {
-	// if quadrants are the same they do not determine a unique
-	// common halfplane.
-	// Simply return one of the two possibilities
-	if (quad1==quad2) return quad1;
-	int diff=(quad1-quad2+4)%4;
-	// if quadrants are not adjacent, they do not share a common halfplane
-	if (diff==2) return -1;
-	//
-	int min=(quad1<quad2)? quad1:quad2;
-	int max=(quad1>quad2)? quad1:quad2;
-	// for this one case, the righthand plane is NOT the minimum index;
-	if (min==0 && max==3) return 3;
-	// in general, the halfplane index is the minimum of the two
-	// adjacent quadrants
-	return min;
+    // if quadrants are the same they do not determine a unique
+    // common halfplane.
+    // Simply return one of the two possibilities
+    if(quad1 == quad2) {
+        return quad1;
+    }
+    int diff = (quad1 - quad2 + 4) % 4;
+    // if quadrants are not adjacent, they do not share a common halfplane
+    if(diff == 2) {
+        return -1;
+    }
+    //
+    int min = (quad1 < quad2) ? quad1 : quad2;
+    int max = (quad1 > quad2) ? quad1 : quad2;
+    // for this one case, the righthand plane is NOT the minimum index;
+    if(min == 0 && max == 3) {
+        return 3;
+    }
+    // in general, the halfplane index is the minimum of the two
+    // adjacent quadrants
+    return min;
 }
 
 /* public static */
 bool
 Quadrant::isInHalfPlane(int quad, int halfPlane)
 {
-	if (halfPlane==SE) {
-		return quad==SE || quad==SW;
-	}
-	return quad==halfPlane || quad==halfPlane+1;
+    if(halfPlane == SE) {
+        return quad == SE || quad == SW;
+    }
+    return quad == halfPlane || quad == halfPlane + 1;
 }
 
 /* public static */
 bool
 Quadrant::isNorthern(int quad)
 {
-	return quad==NE || quad==NW;
+    return quad == NE || quad == NW;
 }
 
 } // namespace geos.geomgraph
diff --git a/src/geomgraph/TopologyLocation.cpp b/src/geomgraph/TopologyLocation.cpp
index 14a6944..173237d 100644
--- a/src/geomgraph/TopologyLocation.cpp
+++ b/src/geomgraph/TopologyLocation.cpp
@@ -33,8 +33,8 @@ namespace geos {
 namespace geomgraph { // geos.geomgraph
 
 /*public*/
-TopologyLocation::TopologyLocation(const vector<int> &newLocation):
-	location(newLocation.size(), Location::UNDEF)
+TopologyLocation::TopologyLocation(const vector<int>& newLocation):
+    location(newLocation.size(), Location::UNDEF)
 {
 }
 
@@ -50,186 +50,204 @@ TopologyLocation::~TopologyLocation()
 
 /*public*/
 TopologyLocation::TopologyLocation(int on, int left, int right):
-	location(3)
+    location(3)
 {
-	location[Position::ON]=on;
-	location[Position::LEFT]=left;
-	location[Position::RIGHT]=right;
+    location[Position::ON] = on;
+    location[Position::LEFT] = left;
+    location[Position::RIGHT] = right;
 }
 
 /*public*/
 TopologyLocation::TopologyLocation(int on):
-	location(1, on)
+    location(1, on)
 {
-	//(*location)[Position::ON]=on;
+    //(*location)[Position::ON]=on;
 }
 
 /*public*/
-TopologyLocation::TopologyLocation(const TopologyLocation &gl)
-  :
-	location(gl.location)
+TopologyLocation::TopologyLocation(const TopologyLocation& gl)
+    :
+    location(gl.location)
 {
 }
 
 /*public*/
 TopologyLocation&
-TopologyLocation::operator= (const TopologyLocation &gl)
+TopologyLocation::operator= (const TopologyLocation& gl)
 {
-	location = gl.location;
-  return *this;
+    location = gl.location;
+    return *this;
 }
 
 /*public*/
 int
 TopologyLocation::get(size_t posIndex) const
 {
-	// should be an assert() instead ?
-	if (posIndex<location.size()) return location[posIndex];
-	return Location::UNDEF;
+    // should be an assert() instead ?
+    if(posIndex < location.size()) {
+        return location[posIndex];
+    }
+    return Location::UNDEF;
 }
 
 /*public*/
 bool
 TopologyLocation::isNull() const
 {
-	for (size_t i=0, sz=location.size(); i<sz; ++i) {
-		if (location[i]!=Location::UNDEF) return false;
-	}
-	return true;
+    for(size_t i = 0, sz = location.size(); i < sz; ++i) {
+        if(location[i] != Location::UNDEF) {
+            return false;
+        }
+    }
+    return true;
 }
 
 /*public*/
 bool
 TopologyLocation::isAnyNull() const
 {
-	for (size_t i=0, sz=location.size(); i<sz; ++i) {
-		if (location[i]==Location::UNDEF) return true;
-	}
-	return false;
+    for(size_t i = 0, sz = location.size(); i < sz; ++i) {
+        if(location[i] == Location::UNDEF) {
+            return true;
+        }
+    }
+    return false;
 }
 
 /*public*/
 bool
-TopologyLocation::isEqualOnSide(const TopologyLocation &le, int locIndex) const
+TopologyLocation::isEqualOnSide(const TopologyLocation& le, int locIndex) const
 {
-	return location[locIndex]==le.location[locIndex];
+    return location[locIndex] == le.location[locIndex];
 }
 
 /*public*/
 bool
 TopologyLocation::isArea() const
 {
-	return location.size()>1;
+    return location.size() > 1;
 }
 
 /*public*/
 bool
 TopologyLocation::isLine() const
 {
-	return location.size()==1;
+    return location.size() == 1;
 }
 
 /*public*/
 void
 TopologyLocation::flip()
 {
-	if (location.size()<=1) return;
-	int temp=location[Position::LEFT];
-	location[Position::LEFT]=location[Position::RIGHT];
-	location[Position::RIGHT] = temp;
+    if(location.size() <= 1) {
+        return;
+    }
+    int temp = location[Position::LEFT];
+    location[Position::LEFT] = location[Position::RIGHT];
+    location[Position::RIGHT] = temp;
 }
 
 /*public*/
 void
 TopologyLocation::setAllLocations(int locValue)
 {
-	for (size_t i=0, sz=location.size(); i<sz; ++i) {
-		location[i]=locValue;
-	}
+    for(size_t i = 0, sz = location.size(); i < sz; ++i) {
+        location[i] = locValue;
+    }
 }
 
 /*public*/
 void
 TopologyLocation::setAllLocationsIfNull(int locValue)
 {
-	for (size_t i=0, sz=location.size(); i<sz; ++i) {
-		if (location[i]==Location::UNDEF) location[i]=locValue;
-	}
+    for(size_t i = 0, sz = location.size(); i < sz; ++i) {
+        if(location[i] == Location::UNDEF) {
+            location[i] = locValue;
+        }
+    }
 }
 
 /*public*/
 void
 TopologyLocation::setLocation(size_t locIndex, int locValue)
 {
-	location[locIndex]=locValue;
+    location[locIndex] = locValue;
 }
 
 /*public*/
 void
 TopologyLocation::setLocation(int locValue)
 {
-	setLocation(Position::ON, locValue);
+    setLocation(Position::ON, locValue);
 }
 
 /*public*/
-const vector<int> &
+const vector<int>&
 TopologyLocation::getLocations() const
 {
-	return location;
+    return location;
 }
 
 /*public*/
 void
 TopologyLocation::setLocations(int on, int left, int right)
 {
-	assert(location.size() >= 3);
-	location[Position::ON]=on;
-	location[Position::LEFT]=left;
-	location[Position::RIGHT]=right;
+    assert(location.size() >= 3);
+    location[Position::ON] = on;
+    location[Position::LEFT] = left;
+    location[Position::RIGHT] = right;
 }
 
 /*public*/
 bool
 TopologyLocation::allPositionsEqual(int loc) const
 {
-	for (size_t i=0, sz=location.size(); i<sz; ++i) {
-		if (location[i]!=loc) return false;
-	}
-	return true;
+    for(size_t i = 0, sz = location.size(); i < sz; ++i) {
+        if(location[i] != loc) {
+            return false;
+        }
+    }
+    return true;
 }
 
 /*public*/
 void
-TopologyLocation::merge(const TopologyLocation &gl)
-{
-	// if the src is an Area label & and the dest is not, increase the dest to be an Area
-	size_t sz=location.size();
-	size_t glsz=gl.location.size();
-	if (glsz>sz) {
-		location.resize(3);
-		location[Position::LEFT]=Location::UNDEF;
-		location[Position::RIGHT]=Location::UNDEF;
-	}
-	for (size_t i=0; i<sz; ++i) {
-		if (location[i]==Location::UNDEF && i<glsz)
-			location[i]=gl.location[i];
-	}
+TopologyLocation::merge(const TopologyLocation& gl)
+{
+    // if the src is an Area label & and the dest is not, increase the dest to be an Area
+    size_t sz = location.size();
+    size_t glsz = gl.location.size();
+    if(glsz > sz) {
+        location.resize(3);
+        location[Position::LEFT] = Location::UNDEF;
+        location[Position::RIGHT] = Location::UNDEF;
+    }
+    for(size_t i = 0; i < sz; ++i) {
+        if(location[i] == Location::UNDEF && i < glsz) {
+            location[i] = gl.location[i];
+        }
+    }
 }
 
 string
 TopologyLocation::toString() const
 {
-	stringstream ss;
-	ss << *this;
-	return ss.str();
+    stringstream ss;
+    ss << *this;
+    return ss.str();
 }
 
-std::ostream& operator<< (std::ostream& os, const TopologyLocation& tl)
+std::ostream&
+operator<< (std::ostream& os, const TopologyLocation& tl)
 {
-	if (tl.location.size()>1) os << Location::toLocationSymbol(tl.location[Position::LEFT]);
-	os << Location::toLocationSymbol(tl.location[Position::ON]);
-	if (tl.location.size()>1) os << Location::toLocationSymbol(tl.location[Position::RIGHT]);
-	return os;
+    if(tl.location.size() > 1) {
+        os << Location::toLocationSymbol(tl.location[Position::LEFT]);
+    }
+    os << Location::toLocationSymbol(tl.location[Position::ON]);
+    if(tl.location.size() > 1) {
+        os << Location::toLocationSymbol(tl.location[Position::RIGHT]);
+    }
+    return os;
 }
 
 } // namespace geos.geomgraph
diff --git a/src/geomgraph/index/MonotoneChainEdge.cpp b/src/geomgraph/index/MonotoneChainEdge.cpp
index fd15901..42126cf 100644
--- a/src/geomgraph/index/MonotoneChainEdge.cpp
+++ b/src/geomgraph/index/MonotoneChainEdge.cpp
@@ -52,115 +52,115 @@ MonotoneChainEdge::~MonotoneChainEdge()
 {
 }
 
-MonotoneChainEdge::MonotoneChainEdge(Edge *newE):
-	e(newE),
-	pts(newE->getCoordinates())
+MonotoneChainEdge::MonotoneChainEdge(Edge* newE):
+    e(newE),
+    pts(newE->getCoordinates())
 {
-	assert(e);
-	MonotoneChainIndexer mcb;
-	mcb.getChainStartIndices(pts, startIndex);
-	assert(e);
+    assert(e);
+    MonotoneChainIndexer mcb;
+    mcb.getChainStartIndices(pts, startIndex);
+    assert(e);
 }
 
 const CoordinateSequence*
 MonotoneChainEdge::getCoordinates()
 {
-	assert(pts);
-	return pts;
+    assert(pts);
+    return pts;
 }
 
-vector<size_t> &
+vector<size_t>&
 MonotoneChainEdge::getStartIndexes()
 {
-	return startIndex;
+    return startIndex;
 }
 
 double
 MonotoneChainEdge::getMinX(size_t chainIndex)
 {
-	double x1=pts->getAt(startIndex[chainIndex]).x;
-	double x2=pts->getAt(startIndex[chainIndex+1]).x;
-	return x1<x2?x1:x2;
+    double x1 = pts->getAt(startIndex[chainIndex]).x;
+    double x2 = pts->getAt(startIndex[chainIndex + 1]).x;
+    return x1 < x2 ? x1 : x2;
 }
 
 double
 MonotoneChainEdge::getMaxX(size_t chainIndex)
 {
-	double x1=pts->getAt(startIndex[chainIndex]).x;
-	double x2=pts->getAt(startIndex[chainIndex+1]).x;
-	return x1>x2?x1:x2;
+    double x1 = pts->getAt(startIndex[chainIndex]).x;
+    double x2 = pts->getAt(startIndex[chainIndex + 1]).x;
+    return x1 > x2 ? x1 : x2;
 }
 
 void
-MonotoneChainEdge::computeIntersects(const MonotoneChainEdge &mce,
-	SegmentIntersector &si)
+MonotoneChainEdge::computeIntersects(const MonotoneChainEdge& mce,
+                                     SegmentIntersector& si)
 {
-	size_t I=startIndex.size()-1;
-	size_t J=mce.startIndex.size()-1;
-	for(size_t i=0; i<I; ++i)
-	{
-		for(size_t j=0; j<J; ++j)
-		{
-			computeIntersectsForChain(i, mce, j, si);
-		}
-	}
+    size_t I = startIndex.size() - 1;
+    size_t J = mce.startIndex.size() - 1;
+    for(size_t i = 0; i < I; ++i) {
+        for(size_t j = 0; j < J; ++j) {
+            computeIntersectsForChain(i, mce, j, si);
+        }
+    }
 }
 
 void
 MonotoneChainEdge::computeIntersectsForChain(size_t chainIndex0,
-	const MonotoneChainEdge &mce, size_t chainIndex1,
-	SegmentIntersector &si)
+        const MonotoneChainEdge& mce, size_t chainIndex1,
+        SegmentIntersector& si)
 {
-	computeIntersectsForChain(startIndex[chainIndex0],
-		startIndex[chainIndex0+1], mce,
-		mce.startIndex[chainIndex1],
-		mce.startIndex[chainIndex1+1],
-		si);
+    computeIntersectsForChain(startIndex[chainIndex0],
+                              startIndex[chainIndex0 + 1], mce,
+                              mce.startIndex[chainIndex1],
+                              mce.startIndex[chainIndex1 + 1],
+                              si);
 }
 
 void
 MonotoneChainEdge::computeIntersectsForChain(size_t start0, size_t end0,
-	const MonotoneChainEdge &mce, size_t start1, size_t end1,
-	SegmentIntersector &ei)
+        const MonotoneChainEdge& mce, size_t start1, size_t end1,
+        SegmentIntersector& ei)
 {
-	// terminating condition for the recursion
-	if (end0-start0==1 && end1-start1==1) {
-		ei.addIntersections(e, start0, mce.e, start1);
-		return;
-	}
-
-	if (!overlaps(start0, end0, mce, start1, end1)) return;
-	// the chains overlap, so split each in half and iterate
-	// (binary search)
-	size_t mid0 = (start0 + end0) / 2;
-	size_t mid1 = (start1 + end1) / 2;
-
-	// Assert: mid != start or end
-	// (since we checked above for end - start <= 1)
-	// check terminating conditions before recursing
-	if (start0<mid0) {
-		if (start1<mid1)
-			computeIntersectsForChain(start0, mid0, mce,
-				start1, mid1, ei);
-		if (mid1<end1)
-			computeIntersectsForChain(start0, mid0, mce,
-				mid1, end1, ei);
-	}
-	if (mid0<end0) {
-		if (start1<mid1)
-			computeIntersectsForChain(mid0, end0, mce,
-				start1, mid1, ei);
-		if (mid1<end1)
-			computeIntersectsForChain(mid0, end0, mce,
-				mid1, end1, ei);
-	}
+    // terminating condition for the recursion
+    if(end0 - start0 == 1 && end1 - start1 == 1) {
+        ei.addIntersections(e, start0, mce.e, start1);
+        return;
+    }
+
+    if(!overlaps(start0, end0, mce, start1, end1)) {
+        return;
+    }
+    // the chains overlap, so split each in half and iterate
+    // (binary search)
+    size_t mid0 = (start0 + end0) / 2;
+    size_t mid1 = (start1 + end1) / 2;
+
+    // Assert: mid != start or end
+    // (since we checked above for end - start <= 1)
+    // check terminating conditions before recursing
+    if(start0 < mid0) {
+        if(start1 < mid1)
+            computeIntersectsForChain(start0, mid0, mce,
+                                      start1, mid1, ei);
+        if(mid1 < end1)
+            computeIntersectsForChain(start0, mid0, mce,
+                                      mid1, end1, ei);
+    }
+    if(mid0 < end0) {
+        if(start1 < mid1)
+            computeIntersectsForChain(mid0, end0, mce,
+                                      start1, mid1, ei);
+        if(mid1 < end1)
+            computeIntersectsForChain(mid0, end0, mce,
+                                      mid1, end1, ei);
+    }
 }
 
 bool
 MonotoneChainEdge::overlaps(size_t start0, size_t end0, const MonotoneChainEdge& mce, size_t start1, size_t end1)
 {
     return Envelope::intersects(pts->getAt(start0), pts->getAt(end0),
-        mce.pts->getAt(start1), mce.pts->getAt(end1));
+                                mce.pts->getAt(start1), mce.pts->getAt(end1));
 }
 
 
diff --git a/src/geomgraph/index/MonotoneChainIndexer.cpp b/src/geomgraph/index/MonotoneChainIndexer.cpp
index 54e5b82..b53d7df 100644
--- a/src/geomgraph/index/MonotoneChainIndexer.cpp
+++ b/src/geomgraph/index/MonotoneChainIndexer.cpp
@@ -29,36 +29,41 @@ namespace index { // geos.geomgraph.index
 
 void
 MonotoneChainIndexer::getChainStartIndices(const CoordinateSequence* pts,
-	vector<size_t> &startIndexList)
+        vector<size_t>& startIndexList)
 {
-	// find the startpoint (and endpoints) of all monotone chains
-	// in this edge
-	size_t start=0;
-	//vector<int>* startIndexList=new vector<int>();
-	startIndexList.push_back(start);
-	do {
-		auto last = findChainEnd(pts, start);
-		startIndexList.push_back(last);
-		start = last;
-	} while(start < pts->size() - 1);
-	// copy list to an array of ints, for efficiency
-	//return startIndexList;
+    // find the startpoint (and endpoints) of all monotone chains
+    // in this edge
+    size_t start = 0;
+    //vector<int>* startIndexList=new vector<int>();
+    startIndexList.push_back(start);
+    do {
+        auto last = findChainEnd(pts, start);
+        startIndexList.push_back(last);
+        start = last;
+    }
+    while(start < pts->size() - 1);
+    // copy list to an array of ints, for efficiency
+    //return startIndexList;
 }
 
 /**
 * @return the index of the last point in the monotone chain
 */
-size_t MonotoneChainIndexer::findChainEnd(const CoordinateSequence* pts, size_t start){
-	// determine quadrant for chain
-	auto chainQuad = Quadrant::quadrant(pts->getAt(start), pts->getAt(start + 1));
-	auto last = start + 1;
-	while(last < pts->size()) {
-		// compute quadrant for next possible segment in chain
-		auto quad=Quadrant::quadrant(pts->getAt(last - 1),pts->getAt(last));
-		if (quad!=chainQuad) break;
-		++last;
-	}
-	return last - 1;
+size_t
+MonotoneChainIndexer::findChainEnd(const CoordinateSequence* pts, size_t start)
+{
+    // determine quadrant for chain
+    auto chainQuad = Quadrant::quadrant(pts->getAt(start), pts->getAt(start + 1));
+    auto last = start + 1;
+    while(last < pts->size()) {
+        // compute quadrant for next possible segment in chain
+        auto quad = Quadrant::quadrant(pts->getAt(last - 1), pts->getAt(last));
+        if(quad != chainQuad) {
+            break;
+        }
+        ++last;
+    }
+    return last - 1;
 }
 
 } // namespace geos.geomgraph.index
diff --git a/src/geomgraph/index/SegmentIntersector.cpp b/src/geomgraph/index/SegmentIntersector.cpp
index 630cf80..f3d5c78 100644
--- a/src/geomgraph/index/SegmentIntersector.cpp
+++ b/src/geomgraph/index/SegmentIntersector.cpp
@@ -46,15 +46,15 @@ using namespace geos::algorithm;
 bool
 SegmentIntersector::isAdjacentSegments(size_t i1, size_t i2)
 {
-	return (i1 > i2 ? i1 - i2 : i2 - i1) == 1;
+    return (i1 > i2 ? i1 - i2 : i2 - i1) == 1;
 }
 
 void
-SegmentIntersector::setBoundaryNodes(vector<Node*> *bdyNodes0,
-	vector<Node*> *bdyNodes1)
+SegmentIntersector::setBoundaryNodes(vector<Node*>* bdyNodes0,
+                                     vector<Node*>* bdyNodes1)
 {
-	bdyNodes[0]=bdyNodes0;
-	bdyNodes[1]=bdyNodes1;
+    bdyNodes[0] = bdyNodes0;
+    bdyNodes[1] = bdyNodes1;
 }
 
 /*
@@ -64,25 +64,25 @@ SegmentIntersector::setBoundaryNodes(vector<Node*> *bdyNodes0,
 Coordinate&
 SegmentIntersector::getProperIntersectionPoint()
 {
-	return properIntersectionPoint;
+    return properIntersectionPoint;
 }
 
 bool
 SegmentIntersector::hasIntersection()
 {
-	return hasIntersectionVar;
+    return hasIntersectionVar;
 }
 
 void
 SegmentIntersector::setIsDoneIfProperInt(bool idwpi)
 {
-	isDoneWhenProperInt = idwpi;
+    isDoneWhenProperInt = idwpi;
 }
 
 bool
 SegmentIntersector::getIsDone()
 {
-	return isDone;
+    return isDone;
 }
 
 /*
@@ -95,7 +95,7 @@ SegmentIntersector::getIsDone()
 bool
 SegmentIntersector::hasProperIntersection()
 {
-	return hasProper;
+    return hasProper;
 }
 
 /*
@@ -105,7 +105,7 @@ SegmentIntersector::hasProperIntersection()
 bool
 SegmentIntersector::hasProperInteriorIntersection()
 {
-	return hasProperInterior;
+    return hasProperInterior;
 }
 
 /*
@@ -115,25 +115,26 @@ SegmentIntersector::hasProperInteriorIntersection()
  * shared by the beginning and end segments.
  */
 bool
-SegmentIntersector::isTrivialIntersection(Edge *e0,
-		size_t segIndex0,Edge *e1,
-		size_t segIndex1)
+SegmentIntersector::isTrivialIntersection(Edge* e0,
+        size_t segIndex0, Edge* e1,
+        size_t segIndex1)
 {
 //	if (e0->equals(e1))
-	if (e0==e1) {
-		if (li->getIntersectionNum()==1) {
-			if (isAdjacentSegments(segIndex0,segIndex1))
-				return true;
-			if (e0->isClosed()) {
-				auto maxSegIndex = e0->getNumPoints() - 1;
-				if ((segIndex0==0 && segIndex1==maxSegIndex)
-					|| (segIndex1==0 && segIndex0==maxSegIndex)) {
-					return true;
-				}
-			}
-		}
-	}
-	return false;
+    if(e0 == e1) {
+        if(li->getIntersectionNum() == 1) {
+            if(isAdjacentSegments(segIndex0, segIndex1)) {
+                return true;
+            }
+            if(e0->isClosed()) {
+                auto maxSegIndex = e0->getNumPoints() - 1;
+                if((segIndex0 == 0 && segIndex1 == maxSegIndex)
+                        || (segIndex1 == 0 && segIndex0 == maxSegIndex)) {
+                    return true;
+                }
+            }
+        }
+    }
+    return false;
 }
 
 /**
@@ -143,98 +144,107 @@ SegmentIntersector::isTrivialIntersection(Edge *e0,
  * certain pairs of segments for efficiency reasons.
  */
 void
-SegmentIntersector::addIntersections(Edge *e0, size_t segIndex0, Edge *e1, size_t segIndex1)
+SegmentIntersector::addIntersections(Edge* e0, size_t segIndex0, Edge* e1, size_t segIndex1)
 {
 
 #if GEOS_DEBUG
-	cerr<<"SegmentIntersector::addIntersections() called"<<endl;
+    cerr << "SegmentIntersector::addIntersections() called" << endl;
 #endif
 
 //	if (e0->equals(e1) && segIndex0==segIndex1) return;
-	if (e0==e1 && segIndex0==segIndex1) return;
-	numTests++;
-	const CoordinateSequence* cl0=e0->getCoordinates();
-	const Coordinate& p00=cl0->getAt(segIndex0);
-	const Coordinate& p01=cl0->getAt(segIndex0+1);
-	const CoordinateSequence* cl1=e1->getCoordinates();
-	const Coordinate& p10=cl1->getAt(segIndex1);
-	const Coordinate& p11=cl1->getAt(segIndex1+1);
-	li->computeIntersection(p00,p01,p10,p11);
-
-	/*
-	 * Always record any non-proper intersections.
-	 * If includeProper is true, record any proper intersections as well.
-	 */
-	if (li->hasIntersection()) {
-		if (recordIsolated) {
-			e0->setIsolated(false);
-			e1->setIsolated(false);
-		}
-		//intersectionFound = true;
-		numIntersections++;
-
-		// If the segments are adjacent they have at least one trivial
-		// intersection, the shared endpoint.
-		// Don't bother adding it if it is the
-		// only intersection.
-		if (!isTrivialIntersection(e0,segIndex0,e1,segIndex1))
-		{
+    if(e0 == e1 && segIndex0 == segIndex1) {
+        return;
+    }
+    numTests++;
+    const CoordinateSequence* cl0 = e0->getCoordinates();
+    const Coordinate& p00 = cl0->getAt(segIndex0);
+    const Coordinate& p01 = cl0->getAt(segIndex0 + 1);
+    const CoordinateSequence* cl1 = e1->getCoordinates();
+    const Coordinate& p10 = cl1->getAt(segIndex1);
+    const Coordinate& p11 = cl1->getAt(segIndex1 + 1);
+    li->computeIntersection(p00, p01, p10, p11);
+
+    /*
+     * Always record any non-proper intersections.
+     * If includeProper is true, record any proper intersections as well.
+     */
+    if(li->hasIntersection()) {
+        if(recordIsolated) {
+            e0->setIsolated(false);
+            e1->setIsolated(false);
+        }
+        //intersectionFound = true;
+        numIntersections++;
+
+        // If the segments are adjacent they have at least one trivial
+        // intersection, the shared endpoint.
+        // Don't bother adding it if it is the
+        // only intersection.
+        if(!isTrivialIntersection(e0, segIndex0, e1, segIndex1)) {
 #if GEOS_DEBUG
-			cerr<<"SegmentIntersector::addIntersections(): has !TrivialIntersection"<<endl;
+            cerr << "SegmentIntersector::addIntersections(): has !TrivialIntersection" << endl;
 #endif // DEBUG_INTERSECT
-			hasIntersectionVar=true;
-			if (includeProper || !li->isProper()) {
-				//Debug.println(li);
-				e0->addIntersections(li,segIndex0,0);
-				e1->addIntersections(li,segIndex1,1);
+            hasIntersectionVar = true;
+            if(includeProper || !li->isProper()) {
+                //Debug.println(li);
+                e0->addIntersections(li, segIndex0, 0);
+                e1->addIntersections(li, segIndex1, 1);
 #if GEOS_DEBUG
-				cerr<<"SegmentIntersector::addIntersections(): includeProper || !li->isProper()"<<endl;
+                cerr << "SegmentIntersector::addIntersections(): includeProper || !li->isProper()" << endl;
 #endif // DEBUG_INTERSECT
-			}
-			if (li->isProper())
-			{
-				properIntersectionPoint=li->getIntersection(0);
+            }
+            if(li->isProper()) {
+                properIntersectionPoint = li->getIntersection(0);
 #if GEOS_DEBUG
-				cerr<<"SegmentIntersector::addIntersections(): properIntersectionPoint: "<<properIntersectionPoint.toString()<<endl;
+                cerr << "SegmentIntersector::addIntersections(): properIntersectionPoint: " << properIntersectionPoint.toString() <<
+                     endl;
 #endif // DEBUG_INTERSECT
-				hasProper=true;
-				if (isDoneWhenProperInt)
-				{
-					isDone = true;
-				}
-				if (!isBoundaryPoint(li,bdyNodes))
-					hasProperInterior=true;
-			}
-			//if (li.isCollinear())
-			//hasCollinear = true;
-		}
-	}
+                hasProper = true;
+                if(isDoneWhenProperInt) {
+                    isDone = true;
+                }
+                if(!isBoundaryPoint(li, bdyNodes)) {
+                    hasProperInterior = true;
+                }
+            }
+            //if (li.isCollinear())
+            //hasCollinear = true;
+        }
+    }
 }
 
 /*private*/
 bool
-SegmentIntersector::isBoundaryPoint(LineIntersector *p_li,
-		vector<Node*> *tstBdyNodes)
+SegmentIntersector::isBoundaryPoint(LineIntersector* p_li,
+                                    vector<Node*>* tstBdyNodes)
 {
-	if ( ! tstBdyNodes ) return false;
-
-	for(vector<Node*>::iterator i=tstBdyNodes->begin();i<tstBdyNodes->end();i++) {
-		Node *node=*i;
-		const Coordinate& pt=node->getCoordinate();
-		if (p_li->isIntersection(pt)) return true;
-	}
-	return false;
+    if(! tstBdyNodes) {
+        return false;
+    }
+
+    for(vector<Node*>::iterator i = tstBdyNodes->begin(); i < tstBdyNodes->end(); i++) {
+        Node* node = *i;
+        const Coordinate& pt = node->getCoordinate();
+        if(p_li->isIntersection(pt)) {
+            return true;
+        }
+    }
+    return false;
 }
 
 
 /*private*/
 bool
-SegmentIntersector::isBoundaryPoint(LineIntersector *p_li,
-		vector<vector<Node*>*>& tstBdyNodes)
+SegmentIntersector::isBoundaryPoint(LineIntersector* p_li,
+                                    vector<vector<Node*>*>& tstBdyNodes)
 {
-	if (isBoundaryPoint(p_li, tstBdyNodes[0])) return true;
-	if (isBoundaryPoint(p_li, tstBdyNodes[1])) return true;
-	return false;
+    if(isBoundaryPoint(p_li, tstBdyNodes[0])) {
+        return true;
+    }
+    if(isBoundaryPoint(p_li, tstBdyNodes[1])) {
+        return true;
+    }
+    return false;
 }
 
 } // namespace geos.geomgraph.index
diff --git a/src/geomgraph/index/SimpleEdgeSetIntersector.cpp b/src/geomgraph/index/SimpleEdgeSetIntersector.cpp
index 7ebdf20..f87a56c 100644
--- a/src/geomgraph/index/SimpleEdgeSetIntersector.cpp
+++ b/src/geomgraph/index/SimpleEdgeSetIntersector.cpp
@@ -28,47 +28,44 @@ namespace geomgraph { // geos.geomgraph
 namespace index { // geos.geomgraph.index
 
 SimpleEdgeSetIntersector::SimpleEdgeSetIntersector():
-	nOverlaps(0)
+    nOverlaps(0)
 {
 }
 
 void
-SimpleEdgeSetIntersector::computeIntersections(vector<Edge*> *edges,
-		SegmentIntersector *si, bool testAllSegments)
+SimpleEdgeSetIntersector::computeIntersections(vector<Edge*>* edges,
+        SegmentIntersector* si, bool testAllSegments)
 {
-	nOverlaps = 0;
-	size_t nedges=edges->size();
-	for(size_t i0=0; i0<nedges; ++i0)
-	{
-		Edge *edge0=(*edges)[i0];
-		for(size_t i1=0; i1<nedges; ++i1)
-		{
-			Edge *edge1=(*edges)[i1];
-			if (testAllSegments || edge0!=edge1)
-				computeIntersects(edge0,edge1,si);
-		}
-	}
+    nOverlaps = 0;
+    size_t nedges = edges->size();
+    for(size_t i0 = 0; i0 < nedges; ++i0) {
+        Edge* edge0 = (*edges)[i0];
+        for(size_t i1 = 0; i1 < nedges; ++i1) {
+            Edge* edge1 = (*edges)[i1];
+            if(testAllSegments || edge0 != edge1) {
+                computeIntersects(edge0, edge1, si);
+            }
+        }
+    }
 }
 
 
 void
-SimpleEdgeSetIntersector::computeIntersections(vector<Edge*> *edges0,
-		vector<Edge*> *edges1, SegmentIntersector *si)
+SimpleEdgeSetIntersector::computeIntersections(vector<Edge*>* edges0,
+        vector<Edge*>* edges1, SegmentIntersector* si)
 {
-	nOverlaps = 0;
+    nOverlaps = 0;
 
-	size_t nedges0=edges0->size();
-	size_t nedges1=edges1->size();
+    size_t nedges0 = edges0->size();
+    size_t nedges1 = edges1->size();
 
-	for(size_t i0=0;i0<nedges0; ++i0)
-	{
-		Edge *edge0=(*edges0)[i0];
-		for(size_t i1=0; i1<nedges1; ++i1)
-		{
-			Edge *edge1=(*edges1)[i1];
-			computeIntersects(edge0,edge1,si);
-		}
-	}
+    for(size_t i0 = 0; i0 < nedges0; ++i0) {
+        Edge* edge0 = (*edges0)[i0];
+        for(size_t i1 = 0; i1 < nedges1; ++i1) {
+            Edge* edge1 = (*edges1)[i1];
+            computeIntersects(edge0, edge1, si);
+        }
+    }
 }
 
 /**
@@ -77,22 +74,20 @@ SimpleEdgeSetIntersector::computeIntersections(vector<Edge*> *edges0,
  * monotone chains.
  */
 void
-SimpleEdgeSetIntersector::computeIntersects(Edge *e0, Edge *e1,
-		SegmentIntersector *si)
+SimpleEdgeSetIntersector::computeIntersects(Edge* e0, Edge* e1,
+        SegmentIntersector* si)
 {
-	const CoordinateSequence *pts0=e0->getCoordinates();
-	const CoordinateSequence *pts1=e1->getCoordinates();
+    const CoordinateSequence* pts0 = e0->getCoordinates();
+    const CoordinateSequence* pts1 = e1->getCoordinates();
 
-	auto npts0 = pts0->size();
-	auto npts1 = pts1->size();
+    auto npts0 = pts0->size();
+    auto npts1 = pts1->size();
 
-	for(size_t i0 = 0; i0 < npts0 - 1; ++i0)
-	{
-		for(size_t i1 = 0; i1<npts1 - 1; ++i1)
-		{
-			si->addIntersections(e0, i0, e1, i1);
-		}
-	}
+    for(size_t i0 = 0; i0 < npts0 - 1; ++i0) {
+        for(size_t i1 = 0; i1 < npts1 - 1; ++i1) {
+            si->addIntersections(e0, i0, e1, i1);
+        }
+    }
 }
 
 } // namespace geos.geomgraph.index
diff --git a/src/geomgraph/index/SimpleMCSweepLineIntersector.cpp b/src/geomgraph/index/SimpleMCSweepLineIntersector.cpp
index 2cd5bdb..c11fd27 100644
--- a/src/geomgraph/index/SimpleMCSweepLineIntersector.cpp
+++ b/src/geomgraph/index/SimpleMCSweepLineIntersector.cpp
@@ -30,76 +30,76 @@ namespace geomgraph { // geos.geomgraph
 namespace index { // geos.geomgraph.index
 
 SimpleMCSweepLineIntersector::SimpleMCSweepLineIntersector()
-	//events(new vector<SweepLineEvent*>())
+//events(new vector<SweepLineEvent*>())
 {
 }
 
 SimpleMCSweepLineIntersector::~SimpleMCSweepLineIntersector()
 {
-	for(size_t i=0; i<events.size(); ++i)
-	{
-		SweepLineEvent *sle=events[i];
-		if (sle->isDelete()) delete sle;
-	}
-	//delete events;
+    for(size_t i = 0; i < events.size(); ++i) {
+        SweepLineEvent* sle = events[i];
+        if(sle->isDelete()) {
+            delete sle;
+        }
+    }
+    //delete events;
 }
 
 void
-SimpleMCSweepLineIntersector::computeIntersections(vector<Edge*> *edges,
-	SegmentIntersector *si, bool testAllSegments)
+SimpleMCSweepLineIntersector::computeIntersections(vector<Edge*>* edges,
+        SegmentIntersector* si, bool testAllSegments)
 {
-	if (testAllSegments)
-		add(edges,nullptr);
-	else
-		add(edges);
-	computeIntersections(si);
+    if(testAllSegments) {
+        add(edges, nullptr);
+    }
+    else {
+        add(edges);
+    }
+    computeIntersections(si);
 }
 
 void
-SimpleMCSweepLineIntersector::computeIntersections(vector<Edge*> *edges0,
-	vector<Edge*> *edges1, SegmentIntersector *si)
+SimpleMCSweepLineIntersector::computeIntersections(vector<Edge*>* edges0,
+        vector<Edge*>* edges1, SegmentIntersector* si)
 {
-	add(edges0,edges0);
-	add(edges1,edges1);
-	computeIntersections(si);
+    add(edges0, edges0);
+    add(edges1, edges1);
+    computeIntersections(si);
 }
 
 void
-SimpleMCSweepLineIntersector::add(vector<Edge*> *edges)
+SimpleMCSweepLineIntersector::add(vector<Edge*>* edges)
 {
-	for (size_t i=0; i<edges->size(); ++i)
-	{
-		Edge *edge=(*edges)[i];
-		// edge is its own group
-		add(edge, edge);
-	}
+    for(size_t i = 0; i < edges->size(); ++i) {
+        Edge* edge = (*edges)[i];
+        // edge is its own group
+        add(edge, edge);
+    }
 }
 
 void
-SimpleMCSweepLineIntersector::add(vector<Edge*> *edges,void* edgeSet)
+SimpleMCSweepLineIntersector::add(vector<Edge*>* edges, void* edgeSet)
 {
-	for (size_t i=0; i<edges->size(); ++i)
-	{
-		Edge *edge=(*edges)[i];
-		add(edge,edgeSet);
-	}
+    for(size_t i = 0; i < edges->size(); ++i) {
+        Edge* edge = (*edges)[i];
+        add(edge, edgeSet);
+    }
 }
 
 void
-SimpleMCSweepLineIntersector::add(Edge *edge, void* edgeSet)
+SimpleMCSweepLineIntersector::add(Edge* edge, void* edgeSet)
 {
-	MonotoneChainEdge *mce=edge->getMonotoneChainEdge();
-	auto& startIndex = mce->getStartIndexes();
-	size_t n = startIndex.size() - 1;
-	events.reserve(events.size()+(n*2));
-	for(size_t i = 0; i < n; ++i)
-	{
-		GEOS_CHECK_FOR_INTERRUPTS();
-		MonotoneChain *mc=new MonotoneChain(mce, i);
-		SweepLineEvent *insertEvent=new SweepLineEvent(edgeSet, mce->getMinX(i), nullptr, mc);
-		events.push_back(insertEvent);
-		events.push_back(new SweepLineEvent(edgeSet, mce->getMaxX(i), insertEvent, mc));
-	}
+    MonotoneChainEdge* mce = edge->getMonotoneChainEdge();
+    auto& startIndex = mce->getStartIndexes();
+    size_t n = startIndex.size() - 1;
+    events.reserve(events.size() + (n * 2));
+    for(size_t i = 0; i < n; ++i) {
+        GEOS_CHECK_FOR_INTERRUPTS();
+        MonotoneChain* mc = new MonotoneChain(mce, i);
+        SweepLineEvent* insertEvent = new SweepLineEvent(edgeSet, mce->getMinX(i), nullptr, mc);
+        events.push_back(insertEvent);
+        events.push_back(new SweepLineEvent(edgeSet, mce->getMaxX(i), insertEvent, mc));
+    }
 }
 
 /**
@@ -110,64 +110,56 @@ SimpleMCSweepLineIntersector::add(Edge *edge, void* edgeSet)
 void
 SimpleMCSweepLineIntersector::prepareEvents()
 {
-	sort(events.begin(), events.end(), SweepLineEventLessThen());
-	for(size_t i=0; i<events.size(); ++i)
-	{
-		GEOS_CHECK_FOR_INTERRUPTS();
-		SweepLineEvent *ev=events[i];
-		if (ev->isDelete())
-		{
-			ev->getInsertEvent()->setDeleteEventIndex(i);
-		}
-	}
+    sort(events.begin(), events.end(), SweepLineEventLessThen());
+    for(size_t i = 0; i < events.size(); ++i) {
+        GEOS_CHECK_FOR_INTERRUPTS();
+        SweepLineEvent* ev = events[i];
+        if(ev->isDelete()) {
+            ev->getInsertEvent()->setDeleteEventIndex(i);
+        }
+    }
 }
 
 void
-SimpleMCSweepLineIntersector::computeIntersections(SegmentIntersector *si)
+SimpleMCSweepLineIntersector::computeIntersections(SegmentIntersector* si)
 {
-	nOverlaps=0;
-	prepareEvents();
-	for(size_t i=0; i<events.size(); ++i)
-	{
-		GEOS_CHECK_FOR_INTERRUPTS();
-		SweepLineEvent *ev=events[i];
-		if (ev->isInsert())
-		{
-			processOverlaps(i, ev->getDeleteEventIndex(), ev, si);
-		}
-		if (si->getIsDone())
-		{
-			break;
-		}
-	}
+    nOverlaps = 0;
+    prepareEvents();
+    for(size_t i = 0; i < events.size(); ++i) {
+        GEOS_CHECK_FOR_INTERRUPTS();
+        SweepLineEvent* ev = events[i];
+        if(ev->isInsert()) {
+            processOverlaps(i, ev->getDeleteEventIndex(), ev, si);
+        }
+        if(si->getIsDone()) {
+            break;
+        }
+    }
 }
 
 void
 SimpleMCSweepLineIntersector::processOverlaps(size_t start, size_t end,
-	SweepLineEvent *ev0, SegmentIntersector *si)
+        SweepLineEvent* ev0, SegmentIntersector* si)
 {
-	MonotoneChain *mc0=(MonotoneChain*) ev0->getObject();
-
-	/*
-	 * Since we might need to test for self-intersections,
-	 * include current insert event object in list of event objects to test.
-	 * Last index can be skipped, because it must be a Delete event.
-	 */
-	for(auto i = start; i < end; ++i)
-	{
-		SweepLineEvent *ev1=events[i];
-		if (ev1->isInsert())
-		{
-			MonotoneChain *mc1=(MonotoneChain*) ev1->getObject();
-			// don't compare edges in same group
-			// null group indicates that edges should be compared
-			if (ev0->edgeSet==nullptr || (ev0->edgeSet!=ev1->edgeSet))
-			{
-				mc0->computeIntersections(mc1,si);
-				nOverlaps++;
-			}
-		}
-	}
+    MonotoneChain* mc0 = (MonotoneChain*) ev0->getObject();
+
+    /*
+     * Since we might need to test for self-intersections,
+     * include current insert event object in list of event objects to test.
+     * Last index can be skipped, because it must be a Delete event.
+     */
+    for(auto i = start; i < end; ++i) {
+        SweepLineEvent* ev1 = events[i];
+        if(ev1->isInsert()) {
+            MonotoneChain* mc1 = (MonotoneChain*) ev1->getObject();
+            // don't compare edges in same group
+            // null group indicates that edges should be compared
+            if(ev0->edgeSet == nullptr || (ev0->edgeSet != ev1->edgeSet)) {
+                mc0->computeIntersections(mc1, si);
+                nOverlaps++;
+            }
+        }
+    }
 }
 
 } // namespace geos.geomgraph.index
diff --git a/src/geomgraph/index/SimpleSweepLineIntersector.cpp b/src/geomgraph/index/SimpleSweepLineIntersector.cpp
index 6893d35..c2972fe 100644
--- a/src/geomgraph/index/SimpleSweepLineIntersector.cpp
+++ b/src/geomgraph/index/SimpleSweepLineIntersector.cpp
@@ -30,70 +30,70 @@ namespace geomgraph { // geos.geomgraph
 namespace index { // geos.geomgraph.index
 
 SimpleSweepLineIntersector::SimpleSweepLineIntersector():
-	//events(new vector<SweepLineEvent*>()),
-	nOverlaps(0)
+    //events(new vector<SweepLineEvent*>()),
+    nOverlaps(0)
 {
 }
 
 SimpleSweepLineIntersector::~SimpleSweepLineIntersector()
 {
-	for(unsigned int i=0; i<events.size(); ++i)
-		delete events[i];
-	//delete events;
+    for(unsigned int i = 0; i < events.size(); ++i) {
+        delete events[i];
+    }
+    //delete events;
 }
 
 void
-SimpleSweepLineIntersector::computeIntersections(vector<Edge*> *edges,
-	SegmentIntersector *si, bool testAllSegments)
+SimpleSweepLineIntersector::computeIntersections(vector<Edge*>* edges,
+        SegmentIntersector* si, bool testAllSegments)
 {
-	if (testAllSegments)
-		add(edges,nullptr);
-	else
-		add(edges);
-	computeIntersections(si);
+    if(testAllSegments) {
+        add(edges, nullptr);
+    }
+    else {
+        add(edges);
+    }
+    computeIntersections(si);
 }
 
 void
-SimpleSweepLineIntersector::computeIntersections(vector<Edge*> *edges0,vector<Edge*> *edges1,SegmentIntersector *si)
+SimpleSweepLineIntersector::computeIntersections(vector<Edge*>* edges0, vector<Edge*>* edges1, SegmentIntersector* si)
 {
-	add(edges0,edges0);
-	add(edges1,edges1);
-	computeIntersections(si);
+    add(edges0, edges0);
+    add(edges1, edges1);
+    computeIntersections(si);
 }
 
 void
-SimpleSweepLineIntersector::add(vector<Edge*> *edges)
+SimpleSweepLineIntersector::add(vector<Edge*>* edges)
 {
-	for (unsigned int i=0; i<edges->size(); ++i)
-	{
-		Edge *edge=(*edges)[i];
-		// edge is its own group
-		add(edge,edge);
-	}
+    for(unsigned int i = 0; i < edges->size(); ++i) {
+        Edge* edge = (*edges)[i];
+        // edge is its own group
+        add(edge, edge);
+    }
 }
 
 void
-SimpleSweepLineIntersector::add(vector<Edge*> *edges, void* edgeSet)
+SimpleSweepLineIntersector::add(vector<Edge*>* edges, void* edgeSet)
 {
-	for (unsigned int i=0; i<edges->size(); ++i)
-	{
-		Edge *edge=(*edges)[i];
-		add(edge,edgeSet);
-	}
+    for(unsigned int i = 0; i < edges->size(); ++i) {
+        Edge* edge = (*edges)[i];
+        add(edge, edgeSet);
+    }
 }
 
 void
-SimpleSweepLineIntersector::add(Edge *edge, void* edgeSet)
+SimpleSweepLineIntersector::add(Edge* edge, void* edgeSet)
 {
-	const CoordinateSequence *pts=edge->getCoordinates();
-	std::size_t n=pts->getSize()-1;
-	for(std::size_t i=0; i<n; ++i)
-	{
-		SweepLineSegment *ss=new SweepLineSegment(edge, i);
-		SweepLineEvent *insertEvent=new SweepLineEvent(edgeSet, ss->getMinX(), nullptr, ss);
-		events.push_back(insertEvent);
-		events.push_back(new SweepLineEvent(edgeSet, ss->getMaxX(), insertEvent, ss));
-	}
+    const CoordinateSequence* pts = edge->getCoordinates();
+    std::size_t n = pts->getSize() - 1;
+    for(std::size_t i = 0; i < n; ++i) {
+        SweepLineSegment* ss = new SweepLineSegment(edge, i);
+        SweepLineEvent* insertEvent = new SweepLineEvent(edgeSet, ss->getMinX(), nullptr, ss);
+        events.push_back(insertEvent);
+        events.push_back(new SweepLineEvent(edgeSet, ss->getMaxX(), insertEvent, ss));
+    }
 }
 
 /**
@@ -104,57 +104,50 @@ SimpleSweepLineIntersector::add(Edge *edge, void* edgeSet)
 void
 SimpleSweepLineIntersector::prepareEvents()
 {
-	sort(events.begin(), events.end(), SweepLineEventLessThen());
-	for(unsigned int i=0; i<events.size(); ++i )
-	{
-		SweepLineEvent *ev=events[i];
-		if (ev->isDelete())
-		{
-			ev->getInsertEvent()->setDeleteEventIndex(i);
-		}
-	}
+    sort(events.begin(), events.end(), SweepLineEventLessThen());
+    for(unsigned int i = 0; i < events.size(); ++i) {
+        SweepLineEvent* ev = events[i];
+        if(ev->isDelete()) {
+            ev->getInsertEvent()->setDeleteEventIndex(i);
+        }
+    }
 }
 
 void
-SimpleSweepLineIntersector::computeIntersections(SegmentIntersector *si)
+SimpleSweepLineIntersector::computeIntersections(SegmentIntersector* si)
 {
-	nOverlaps=0;
-	prepareEvents();
-	for(unsigned int i=0; i<events.size(); ++i)
-	{
-		SweepLineEvent *ev=events[i];
-		if (ev->isInsert())
-		{
-			processOverlaps(i,ev->getDeleteEventIndex(),ev,si);
-		}
-	}
+    nOverlaps = 0;
+    prepareEvents();
+    for(unsigned int i = 0; i < events.size(); ++i) {
+        SweepLineEvent* ev = events[i];
+        if(ev->isInsert()) {
+            processOverlaps(i, ev->getDeleteEventIndex(), ev, si);
+        }
+    }
 }
 
 void
-SimpleSweepLineIntersector::processOverlaps(size_t start, size_t end,SweepLineEvent *ev0,
-	SegmentIntersector *si)
+SimpleSweepLineIntersector::processOverlaps(size_t start, size_t end, SweepLineEvent* ev0,
+        SegmentIntersector* si)
 {
 
-	SweepLineSegment *ss0=(SweepLineSegment*) ev0->getObject();
-
-	/**
-	 * Since we might need to test for self-intersections,
-	 * include current insert event object in list of event objects to test.
-	 * Last index can be skipped, because it must be a Delete event.
- 	 */
-	for(auto i = start; i < end; ++i)
-	{
-		SweepLineEvent *ev1=events[i];
-		if (ev1->isInsert())
-		{
-			SweepLineSegment *ss1=(SweepLineSegment*) ev1->getObject();
-			if (ev0->edgeSet==nullptr || (ev0->edgeSet!=ev1->edgeSet))
-			{
-				ss0->computeIntersections(ss1,si);
-				nOverlaps++;
-			}
-		}
-	}
+    SweepLineSegment* ss0 = (SweepLineSegment*) ev0->getObject();
+
+    /**
+     * Since we might need to test for self-intersections,
+     * include current insert event object in list of event objects to test.
+     * Last index can be skipped, because it must be a Delete event.
+     */
+    for(auto i = start; i < end; ++i) {
+        SweepLineEvent* ev1 = events[i];
+        if(ev1->isInsert()) {
+            SweepLineSegment* ss1 = (SweepLineSegment*) ev1->getObject();
+            if(ev0->edgeSet == nullptr || (ev0->edgeSet != ev1->edgeSet)) {
+                ss0->computeIntersections(ss1, si);
+                nOverlaps++;
+            }
+        }
+    }
 }
 
 } // namespace geos.geomgraph.index
diff --git a/src/geomgraph/index/SweepLineEvent.cpp b/src/geomgraph/index/SweepLineEvent.cpp
index 81951f8..81001cb 100644
--- a/src/geomgraph/index/SweepLineEvent.cpp
+++ b/src/geomgraph/index/SweepLineEvent.cpp
@@ -25,22 +25,27 @@ namespace geomgraph { // geos.geomgraph
 namespace index { // geos.geomgraph.index
 
 SweepLineEvent::SweepLineEvent(void* newEdgeSet, double x,
-	SweepLineEvent *newInsertEvent, SweepLineEventOBJ *newObj):
-		edgeSet(newEdgeSet),
-		obj(newObj),
-		xValue(x),
-		insertEvent(newInsertEvent),
-		deleteEventIndex(0)
+                               SweepLineEvent* newInsertEvent, SweepLineEventOBJ* newObj):
+    edgeSet(newEdgeSet),
+    obj(newObj),
+    xValue(x),
+    insertEvent(newInsertEvent),
+    deleteEventIndex(0)
 {
-	if(insertEvent!=nullptr) eventType=DELETE_EVENT;
-	else eventType=INSERT_EVENT;
+    if(insertEvent != nullptr) {
+        eventType = DELETE_EVENT;
+    }
+    else {
+        eventType = INSERT_EVENT;
+    }
 }
 
-SweepLineEvent::~SweepLineEvent(){
-	if (eventType==DELETE_EVENT) {
-		delete insertEvent;
-		delete obj;
-	}
+SweepLineEvent::~SweepLineEvent()
+{
+    if(eventType == DELETE_EVENT) {
+        delete insertEvent;
+        delete obj;
+    }
 }
 
 /**
@@ -51,27 +56,39 @@ SweepLineEvent::~SweepLineEvent(){
  * correctly handled.
  */
 int
-SweepLineEvent::compareTo(SweepLineEvent *sle)
+SweepLineEvent::compareTo(SweepLineEvent* sle)
 {
-	if (xValue<sle->xValue) return -1;
-	if (xValue>sle->xValue) return 1;
-	if (eventType<sle->eventType) return -1;
-	if (eventType>sle->eventType) return 1;
-	return 0;
+    if(xValue < sle->xValue) {
+        return -1;
+    }
+    if(xValue > sle->xValue) {
+        return 1;
+    }
+    if(eventType < sle->eventType) {
+        return -1;
+    }
+    if(eventType > sle->eventType) {
+        return 1;
+    }
+    return 0;
 }
 
 string
 SweepLineEvent::print()
 {
-	ostringstream s;
+    ostringstream s;
 
-	s<<"SweepLineEvent:";
-	s<<" xValue="<<xValue<<" deleteEventIndex="<<deleteEventIndex;
-	s<<( (eventType==INSERT_EVENT) ? " INSERT_EVENT" : " DELETE_EVENT" );
-	s<<endl<<"\tinsertEvent=";
-	if (insertEvent) s<<insertEvent->print();
-	else s<<"NULL";
-	return s.str();
+    s << "SweepLineEvent:";
+    s << " xValue=" << xValue << " deleteEventIndex=" << deleteEventIndex;
+    s << ((eventType == INSERT_EVENT) ? " INSERT_EVENT" : " DELETE_EVENT");
+    s << endl << "\tinsertEvent=";
+    if(insertEvent) {
+        s << insertEvent->print();
+    }
+    else {
+        s << "NULL";
+    }
+    return s.str();
 }
 
 } // namespace geos.geomgraph.index
diff --git a/src/geomgraph/index/SweepLineSegment.cpp b/src/geomgraph/index/SweepLineSegment.cpp
index 2a72b70..125fae7 100644
--- a/src/geomgraph/index/SweepLineSegment.cpp
+++ b/src/geomgraph/index/SweepLineSegment.cpp
@@ -25,14 +25,14 @@ namespace geos {
 namespace geomgraph { // geos.geomgraph
 namespace index { // geos.geomgraph.index
 
-SweepLineSegment::SweepLineSegment(Edge *newEdge, size_t newPtIndex):
-	edge(newEdge),
-	pts(newEdge->getCoordinates()),
-	ptIndex(newPtIndex)
+SweepLineSegment::SweepLineSegment(Edge* newEdge, size_t newPtIndex):
+    edge(newEdge),
+    pts(newEdge->getCoordinates()),
+    ptIndex(newPtIndex)
 {
-	//pts=newEdge->getCoordinates();
-	//edge=newEdge;
-	//ptIndex=newPtIndex;
+    //pts=newEdge->getCoordinates();
+    //edge=newEdge;
+    //ptIndex=newPtIndex;
 }
 
 SweepLineSegment::~SweepLineSegment()
@@ -42,24 +42,24 @@ SweepLineSegment::~SweepLineSegment()
 double
 SweepLineSegment::getMinX()
 {
-	double x1=pts->getAt(ptIndex).x;
-	double x2=pts->getAt(ptIndex+1).x;
-	return x1<x2?x1:x2;
+    double x1 = pts->getAt(ptIndex).x;
+    double x2 = pts->getAt(ptIndex + 1).x;
+    return x1 < x2 ? x1 : x2;
 }
 
 double
 SweepLineSegment::getMaxX()
 {
-	double x1=pts->getAt(ptIndex).x;
-	double x2=pts->getAt(ptIndex+1).x;
-	return x1>x2?x1:x2;
+    double x1 = pts->getAt(ptIndex).x;
+    double x2 = pts->getAt(ptIndex + 1).x;
+    return x1 > x2 ? x1 : x2;
 }
 
 void
-SweepLineSegment::computeIntersections(SweepLineSegment *ss,
-	SegmentIntersector *si)
+SweepLineSegment::computeIntersections(SweepLineSegment* ss,
+                                       SegmentIntersector* si)
 {
-	si->addIntersections(edge, ptIndex, ss->edge, ss->ptIndex);
+    si->addIntersections(edge, ptIndex, ss->edge, ss->ptIndex);
 }
 
 } // namespace geos.geomgraph.index
diff --git a/src/index/bintree/Bintree.cpp b/src/index/bintree/Bintree.cpp
index c09dc82..879dfba 100644
--- a/src/index/bintree/Bintree.cpp
+++ b/src/index/bintree/Bintree.cpp
@@ -28,53 +28,56 @@ using namespace std;
 Interval*
 Bintree::ensureExtent(const Interval* itemInterval, double minExtent)
 {
-	double min = itemInterval->getMin();
-	double max = itemInterval->getMax();
-	// has a non-zero extent
-	if (min != max)
-	{
-		// GEOS forces a copy here to be predictable wrt
-		// memory management. May change in the future.
-		return new Interval(*itemInterval);
-	}
-
-	// pad extent
-	if (min==max)
-	{
-		min = min-minExtent/2.0;
-		max = min+minExtent/2.0;
-	}
-
-	return new Interval(min, max);
+    double min = itemInterval->getMin();
+    double max = itemInterval->getMax();
+    // has a non-zero extent
+    if(min != max) {
+        // GEOS forces a copy here to be predictable wrt
+        // memory management. May change in the future.
+        return new Interval(*itemInterval);
+    }
+
+    // pad extent
+    if(min == max) {
+        min = min - minExtent / 2.0;
+        max = min + minExtent / 2.0;
+    }
+
+    return new Interval(min, max);
 }
 
 
 
 Bintree::Bintree()
 {
-	minExtent=1.0;
-	root=new Root();
+    minExtent = 1.0;
+    root = new Root();
 }
 
 Bintree::~Bintree()
 {
-	for (unsigned int i=0; i<newIntervals.size(); i++)
-		delete newIntervals[i];
-	delete root;
+    for(unsigned int i = 0; i < newIntervals.size(); i++) {
+        delete newIntervals[i];
+    }
+    delete root;
 }
 
 int
 Bintree::depth()
 {
-	if (root!=nullptr) return root->depth();
-	return 0;
+    if(root != nullptr) {
+        return root->depth();
+    }
+    return 0;
 }
 
 int
 Bintree::size()
 {
-	if (root!=nullptr) return root->size();
-	return 0;
+    if(root != nullptr) {
+        return root->size();
+    }
+    return 0;
 }
 
 /**
@@ -85,66 +88,76 @@ Bintree::size()
 int
 Bintree::nodeSize()
 {
-	if (root!=nullptr) return root->nodeSize();
-	return 0;
+    if(root != nullptr) {
+        return root->nodeSize();
+    }
+    return 0;
 }
 
 void
-Bintree::insert(Interval *itemInterval,void* item)
+Bintree::insert(Interval* itemInterval, void* item)
 {
-	collectStats(itemInterval);
-	Interval *insertInterval=ensureExtent(itemInterval,minExtent);
-	if ( insertInterval != itemInterval )
-		newIntervals.push_back(insertInterval);
-	//int oldSize=size();
-	root->insert(insertInterval,item);
-
-	/* GEOS_DEBUG
-	int newSize=size();
-	System.out.println("BinTree: size="+newSize+"   node size="+nodeSize());
-	if (newSize <= oldSize) {
-	System.out.println("Lost item!");
-	root.insert(insertInterval, item);
-	System.out.println("reinsertion size="+size());
-	}
-	*/
+    collectStats(itemInterval);
+    Interval* insertInterval = ensureExtent(itemInterval, minExtent);
+    if(insertInterval != itemInterval) {
+        newIntervals.push_back(insertInterval);
+    }
+    //int oldSize=size();
+    root->insert(insertInterval, item);
+
+    /* GEOS_DEBUG
+    int newSize=size();
+    System.out.println("BinTree: size="+newSize+"   node size="+nodeSize());
+    if (newSize <= oldSize) {
+    System.out.println("Lost item!");
+    root.insert(insertInterval, item);
+    System.out.println("reinsertion size="+size());
+    }
+    */
 }
 
-vector<void*>* Bintree::iterator() {
-	vector<void*>* foundItems=new vector<void*>();
-	root->addAllItems(foundItems);
-	return foundItems;
+vector<void*>*
+Bintree::iterator()
+{
+    vector<void*>* foundItems = new vector<void*>();
+    root->addAllItems(foundItems);
+    return foundItems;
 }
 
-vector<void*>* Bintree::query(double x) {
-	return query(new Interval(x, x));
+vector<void*>*
+Bintree::query(double x)
+{
+    return query(new Interval(x, x));
 }
 
 /**
 * min and max may be the same value
 */
-vector<void*>* Bintree::query(Interval *interval) {
-	/**
-	* the items that are matched are all items in intervals
-	* which overlap the query interval
-	*/
-	vector<void*>* foundItems=new vector<void*>();
-	query(interval,foundItems);
-	return foundItems;
+vector<void*>*
+Bintree::query(Interval* interval)
+{
+    /**
+    * the items that are matched are all items in intervals
+    * which overlap the query interval
+    */
+    vector<void*>* foundItems = new vector<void*>();
+    query(interval, foundItems);
+    return foundItems;
 }
 
 void
-Bintree::query(Interval *interval,vector<void*> *foundItems)
+Bintree::query(Interval* interval, vector<void*>* foundItems)
 {
-	root->addAllItemsFromOverlapping(interval,foundItems);
+    root->addAllItemsFromOverlapping(interval, foundItems);
 }
 
 void
-Bintree::collectStats(Interval *interval)
+Bintree::collectStats(Interval* interval)
 {
-	double del=interval->getWidth();
-	if (del<minExtent && del>0.0)
-		minExtent=del;
+    double del = interval->getWidth();
+    if(del < minExtent && del > 0.0) {
+        minExtent = del;
+    }
 }
 
 } // namespace geos.index.bintree
diff --git a/src/index/bintree/Interval.cpp b/src/index/bintree/Interval.cpp
index d5cfd1d..859ec79 100644
--- a/src/index/bintree/Interval.cpp
+++ b/src/index/bintree/Interval.cpp
@@ -21,13 +21,13 @@ namespace bintree { // geos.index.bintree
 
 Interval::Interval()
 {
-	min=0.0;
-	max=0.0;
+    min = 0.0;
+    max = 0.0;
 }
 
 Interval::Interval(double nmin, double nmax)
 {
-	init(nmin, nmax);
+    init(nmin, nmax);
 }
 
 Interval::~Interval()
@@ -36,74 +36,80 @@ Interval::~Interval()
 
 Interval::Interval(const Interval* interval)
 {
-	init(interval->min, interval->max);
+    init(interval->min, interval->max);
 }
 
 void
 Interval::init(double nmin, double nmax)
 {
-	min=nmin;
-	max=nmax;
-	if (min>max) {
-		min=nmax;
-		max=nmin;
-	}
+    min = nmin;
+    max = nmax;
+    if(min > max) {
+        min = nmax;
+        max = nmin;
+    }
 }
 
 double
 Interval::getMin() const
 {
-	return min;
+    return min;
 }
 
 double
 Interval::getMax() const
 {
-	return max;
+    return max;
 }
 
 double
 Interval::getWidth() const
 {
-	return max-min;
+    return max - min;
 }
 
 void
-Interval::expandToInclude(Interval *interval)
+Interval::expandToInclude(Interval* interval)
 {
-	if (interval->max>max) max=interval->max;
-	if (interval->min<min) min=interval->min;
+    if(interval->max > max) {
+        max = interval->max;
+    }
+    if(interval->min < min) {
+        min = interval->min;
+    }
 }
 
 bool
-Interval::overlaps(const Interval *interval) const
+Interval::overlaps(const Interval* interval) const
 {
-	return overlaps(interval->min,interval->max);
+    return overlaps(interval->min, interval->max);
 }
 
 bool
 Interval::overlaps(double nmin, double nmax) const
 {
-	if (min>nmax || max<nmin) return false;
-	return true;
+    if(min > nmax || max < nmin) {
+        return false;
+    }
+    return true;
 }
 
 bool
-Interval::contains(const Interval *interval) const
+Interval::contains(const Interval* interval) const
 {
-	return contains(interval->min,interval->max);
+    return contains(interval->min, interval->max);
 }
 
 bool
 Interval::contains(double nmin, double nmax) const
 {
-	return (nmin>=min && nmax<=max);
+    return (nmin >= min && nmax <= max);
 }
 
 bool
 Interval::contains(double p) const
 {
-	return (p>=min && p<=max);
+    return (p >= min && p <= max);
 }
 
 } // namespace geos.index.bintree
diff --git a/src/index/bintree/Key.cpp b/src/index/bintree/Key.cpp
index 27d3a5d..2a35d0f 100644
--- a/src/index/bintree/Key.cpp
+++ b/src/index/bintree/Key.cpp
@@ -24,44 +24,44 @@ namespace index { // geos.index
 namespace bintree { // geos.index.bintree
 
 int
-Key::computeLevel(Interval *newInterval)
+Key::computeLevel(Interval* newInterval)
 {
-	using geos::index::quadtree::DoubleBits;
-	double dx=newInterval->getWidth();
-	//int level = BinaryPower.exponent(dx) + 1;
-	int level=DoubleBits::exponent(dx)+1;
-	return level;
+    using geos::index::quadtree::DoubleBits;
+    double dx = newInterval->getWidth();
+    //int level = BinaryPower.exponent(dx) + 1;
+    int level = DoubleBits::exponent(dx) + 1;
+    return level;
 }
 
-Key::Key(Interval *newInterval)
+Key::Key(Interval* newInterval)
 {
-	interval=nullptr;
-	pt=0.0;
-	level=0;
-	computeKey(newInterval);
+    interval = nullptr;
+    pt = 0.0;
+    level = 0;
+    computeKey(newInterval);
 }
 
 Key::~Key()
 {
-	delete interval;
+    delete interval;
 }
 
 double
 Key::getPoint()
 {
-	return pt;
+    return pt;
 }
 
 int
 Key::getLevel()
 {
-	return level;
+    return level;
 }
 
 Interval*
 Key::getInterval()
 {
-	return interval;
+    return interval;
 }
 
 /**
@@ -69,28 +69,28 @@ Key::getInterval()
  * whose extent is a power of two and which is based at a power of 2
  */
 void
-Key::computeKey(Interval *itemInterval)
+Key::computeKey(Interval* itemInterval)
 {
-	level=computeLevel(itemInterval);
-	delete interval;
-	interval=new Interval();
-	computeInterval(level,itemInterval);
-	// MD - would be nice to have a non-iterative form of this algorithm
-	while (!interval->contains(itemInterval)) {
-		level+=1;
-		computeInterval(level,itemInterval);
-	}
+    level = computeLevel(itemInterval);
+    delete interval;
+    interval = new Interval();
+    computeInterval(level, itemInterval);
+    // MD - would be nice to have a non-iterative form of this algorithm
+    while(!interval->contains(itemInterval)) {
+        level += 1;
+        computeInterval(level, itemInterval);
+    }
 }
 
 void
-Key::computeInterval(int p_level, Interval *itemInterval)
+Key::computeInterval(int p_level, Interval* itemInterval)
 {
-	using geos::index::quadtree::DoubleBits;
+    using geos::index::quadtree::DoubleBits;
 
-	double size=DoubleBits::powerOf2(p_level);
-	//double size = pow2.power(p_level);
-	pt=std::floor(itemInterval->getMin()/size)*size;
-	interval->init(pt,pt+size);
+    double size = DoubleBits::powerOf2(p_level);
+    //double size = pow2.power(p_level);
+    pt = std::floor(itemInterval->getMin() / size) * size;
+    interval->init(pt, pt + size);
 }
 
 } // namespace geos.index.bintree
diff --git a/src/index/bintree/Node.cpp b/src/index/bintree/Node.cpp
index 5d9cd56..9aa9cd4 100644
--- a/src/index/bintree/Node.cpp
+++ b/src/index/bintree/Node.cpp
@@ -25,48 +25,52 @@ namespace index { // geos.index
 namespace bintree { // geos.index.bintree
 
 Node*
-Node::createNode(Interval *itemInterval)
+Node::createNode(Interval* itemInterval)
 {
-	Key *key=new Key(itemInterval);
-	//System.out.println("input: " + env + "  binaryEnv: " + key.getEnvelope());
-	Node* node=new Node(new Interval(key->getInterval()),key->getLevel());
-	delete key;
-	return node;
+    Key* key = new Key(itemInterval);
+    //System.out.println("input: " + env + "  binaryEnv: " + key.getEnvelope());
+    Node* node = new Node(new Interval(key->getInterval()), key->getLevel());
+    delete key;
+    return node;
 }
 
 Node*
-Node::createExpanded(Node *node,Interval *addInterval)
+Node::createExpanded(Node* node, Interval* addInterval)
 {
-	Interval *expandInt=new Interval(addInterval);
-	if (node!=nullptr) expandInt->expandToInclude(node->interval);
-	Node *largerNode=createNode(expandInt);
-	if (node!=nullptr) largerNode->insert(node);
-	delete expandInt;
-	return largerNode;
+    Interval* expandInt = new Interval(addInterval);
+    if(node != nullptr) {
+        expandInt->expandToInclude(node->interval);
+    }
+    Node* largerNode = createNode(expandInt);
+    if(node != nullptr) {
+        largerNode->insert(node);
+    }
+    delete expandInt;
+    return largerNode;
 }
 
-Node::Node(Interval *newInterval,int newLevel)
+Node::Node(Interval* newInterval, int newLevel)
 {
-	interval=newInterval;
-	level=newLevel;
-	centre=(interval->getMin()+interval->getMax())/2;
+    interval = newInterval;
+    level = newLevel;
+    centre = (interval->getMin() + interval->getMax()) / 2;
 }
 
 Node::~Node()
 {
-	delete interval;
+    delete interval;
 }
 
 Interval*
 Node::getInterval()
 {
-	return interval;
+    return interval;
 }
 
 bool
-Node::isSearchMatch(Interval *itemInterval)
+Node::isSearchMatch(Interval* itemInterval)
 {
-	return itemInterval->overlaps(interval);
+    return itemInterval->overlaps(interval);
 }
 
 /**
@@ -75,18 +79,19 @@ Node::isSearchMatch(Interval *itemInterval)
  * it does not already exist.
  */
 Node*
-Node::getNode(Interval *searchInterval)
+Node::getNode(Interval* searchInterval)
 {
-	int subnodeIndex=getSubnodeIndex(searchInterval,centre);
-	// if index is -1 searchEnv is not contained in a subnode
-	if (subnodeIndex!=-1) {
-		// create the node if it does not exist
-		Node* node=getSubnode(subnodeIndex);
-		// recursively search the found/created node
-		return node->getNode(searchInterval);
-	} else {
-		return this;
-	}
+    int subnodeIndex = getSubnodeIndex(searchInterval, centre);
+    // if index is -1 searchEnv is not contained in a subnode
+    if(subnodeIndex != -1) {
+        // create the node if it does not exist
+        Node* node = getSubnode(subnodeIndex);
+        // recursively search the found/created node
+        return node->getNode(searchInterval);
+    }
+    else {
+        return this;
+    }
 }
 
 /**
@@ -94,35 +99,37 @@ Node::getNode(Interval *searchInterval)
  * node containing the envelope.
  */
 NodeBase*
-Node::find(Interval *searchInterval)
+Node::find(Interval* searchInterval)
 {
-	int subnodeIndex=getSubnodeIndex(searchInterval,centre);
-	if (subnodeIndex==-1)
-		return this;
-	if (subnode[subnodeIndex]!=nullptr) {
-		// query lies in subnode, so search it
-		Node *node=subnode[subnodeIndex];
-		return node->find(searchInterval);
-	}
-	// no existing subnode, so return this one anyway
-	return this;
+    int subnodeIndex = getSubnodeIndex(searchInterval, centre);
+    if(subnodeIndex == -1) {
+        return this;
+    }
+    if(subnode[subnodeIndex] != nullptr) {
+        // query lies in subnode, so search it
+        Node* node = subnode[subnodeIndex];
+        return node->find(searchInterval);
+    }
+    // no existing subnode, so return this one anyway
+    return this;
 }
 
 void
-Node::insert(Node *node)
+Node::insert(Node* node)
 {
-	assert(interval==nullptr || interval->contains(node->interval));
-	int index=getSubnodeIndex(node->interval,centre);
-	assert(index >= 0);
-	if (node->level==level-1) {
-		subnode[index]=node;
-	} else {
-		// the node is not a direct child, so make a new child node to contain it
-		// and recursively insert the node
-		Node* childNode=createSubnode(index);
-		childNode->insert(node);
-		subnode[index]=childNode;
-	}
+    assert(interval == nullptr || interval->contains(node->interval));
+    int index = getSubnodeIndex(node->interval, centre);
+    assert(index >= 0);
+    if(node->level == level - 1) {
+        subnode[index] = node;
+    }
+    else {
+        // the node is not a direct child, so make a new child node to contain it
+        // and recursively insert the node
+        Node* childNode = createSubnode(index);
+        childNode->insert(node);
+        subnode[index] = childNode;
+    }
 }
 
 /**
@@ -132,31 +139,31 @@ Node::insert(Node *node)
 Node*
 Node::getSubnode(int index)
 {
-	if (subnode[index]==nullptr) {
-		subnode[index]=createSubnode(index);
-	}
-	return subnode[index];
+    if(subnode[index] == nullptr) {
+        subnode[index] = createSubnode(index);
+    }
+    return subnode[index];
 }
 
 Node*
 Node::createSubnode(int index)
 {
-	// create a new subnode in the appropriate interval
-	double min=0.0;
-	double max=0.0;
-	switch (index) {
-		case 0:
-			min=interval->getMin();
-			max=centre;
-			break;
-		case 1:
-			min=centre;
-			max=interval->getMax();
-			break;
-	}
-	Interval* subInt=new Interval(min,max);
-	Node *node=new Node(subInt,level-1);
-	return node;
+    // create a new subnode in the appropriate interval
+    double min = 0.0;
+    double max = 0.0;
+    switch(index) {
+    case 0:
+        min = interval->getMin();
+        max = centre;
+        break;
+    case 1:
+        min = centre;
+        max = interval->getMax();
+        break;
+    }
+    Interval* subInt = new Interval(min, max);
+    Node* node = new Node(subInt, level - 1);
+    return node;
 }
 
 } // namespace geos.index.bintree
diff --git a/src/index/bintree/NodeBase.cpp b/src/index/bintree/NodeBase.cpp
index b801b43..d44b9aa 100644
--- a/src/index/bintree/NodeBase.cpp
+++ b/src/index/bintree/NodeBase.cpp
@@ -30,99 +30,110 @@ namespace bintree { // geos.index.bintree
  * If none does, returns -1.
  */
 int
-NodeBase::getSubnodeIndex(Interval *interval, double centre)
+NodeBase::getSubnodeIndex(Interval* interval, double centre)
 {
-	int subnodeIndex=-1;
-	if (interval->min>=centre) subnodeIndex=1;
-	if (interval->max<=centre) subnodeIndex=0;
-	return subnodeIndex;
+    int subnodeIndex = -1;
+    if(interval->min >= centre) {
+        subnodeIndex = 1;
+    }
+    if(interval->max <= centre) {
+        subnodeIndex = 0;
+    }
+    return subnodeIndex;
 }
 
 NodeBase::NodeBase()
 {
-	items=new vector<void*>();
-	subnode[0]=nullptr;
-	subnode[1]=nullptr;
+    items = new vector<void*>();
+    subnode[0] = nullptr;
+    subnode[1] = nullptr;
 }
 
-NodeBase::~NodeBase() {
-	delete items;
-	delete subnode[0];
-	delete subnode[1];
-	subnode[0]=nullptr;
-	subnode[1]=nullptr;
+NodeBase::~NodeBase()
+{
+    delete items;
+    delete subnode[0];
+    delete subnode[1];
+    subnode[0] = nullptr;
+    subnode[1] = nullptr;
 }
 
 vector<void*>*
 NodeBase::getItems()
 {
-	return items;
+    return items;
 }
 
-void NodeBase::add(void* item){
-	items->push_back(item);
+void
+NodeBase::add(void* item)
+{
+    items->push_back(item);
 }
 
-vector<void*>* NodeBase::addAllItems(vector<void*> *newItems) {
-	items->insert(items->end(),newItems->begin(),newItems->end());
-	for(int i=0;i<2;i++) {
-		if (subnode[i]!=nullptr) {
-			subnode[i]->addAllItems(newItems);
-		}
-	}
-	return items;
+vector<void*>*
+NodeBase::addAllItems(vector<void*>* newItems)
+{
+    items->insert(items->end(), newItems->begin(), newItems->end());
+    for(int i = 0; i < 2; i++) {
+        if(subnode[i] != nullptr) {
+            subnode[i]->addAllItems(newItems);
+        }
+    }
+    return items;
 }
 
 vector<void*>*
-NodeBase::addAllItemsFromOverlapping(Interval *interval,vector<void*> *resultItems)
+NodeBase::addAllItemsFromOverlapping(Interval* interval, vector<void*>* resultItems)
 {
-	if (!isSearchMatch(interval))
-		return items;
-	resultItems->insert(resultItems->end(),items->begin(),items->end());
-	for (int i=0;i<2;i++) {
-		if (subnode[i]!=nullptr) {
-			subnode[i]->addAllItemsFromOverlapping(interval,resultItems);
-		}
-	}
-	return items;
+    if(!isSearchMatch(interval)) {
+        return items;
+    }
+    resultItems->insert(resultItems->end(), items->begin(), items->end());
+    for(int i = 0; i < 2; i++) {
+        if(subnode[i] != nullptr) {
+            subnode[i]->addAllItemsFromOverlapping(interval, resultItems);
+        }
+    }
+    return items;
 }
 
 int
 NodeBase::depth()
 {
-	int maxSubDepth=0;
-	for (int i=0;i<2;i++) {
-		if (subnode[i]!=nullptr) {
-			int sqd=subnode[i]->depth();
-			if (sqd>maxSubDepth)
-				maxSubDepth=sqd;
-		}
-	}
-	return maxSubDepth+1;
+    int maxSubDepth = 0;
+    for(int i = 0; i < 2; i++) {
+        if(subnode[i] != nullptr) {
+            int sqd = subnode[i]->depth();
+            if(sqd > maxSubDepth) {
+                maxSubDepth = sqd;
+            }
+        }
+    }
+    return maxSubDepth + 1;
 }
 
 int
 NodeBase::size()
 {
-	int subSize=0;
-	for (int i=0;i<2;i++) {
-		if (subnode[i]!=nullptr) {
-			subSize+=subnode[i]->size();
-		}
-	}
-	return subSize+(int)items->size();
+    int subSize = 0;
+    for(int i = 0; i < 2; i++) {
+        if(subnode[i] != nullptr) {
+            subSize += subnode[i]->size();
+        }
+    }
+    return subSize + (int)items->size();
 }
 
 int
 NodeBase::nodeSize()
 {
-	int subSize=0;
-	for (int i=0;i<2;i++) {
-		if (subnode[i]!=nullptr) {
-			subSize+=subnode[i]->nodeSize();
-		}
-	}
-	return subSize+1;
+    int subSize = 0;
+    for(int i = 0; i < 2; i++) {
+        if(subnode[i] != nullptr) {
+            subSize += subnode[i]->nodeSize();
+        }
+    }
+    return subSize + 1;
 }
 
 
diff --git a/src/index/bintree/Root.cpp b/src/index/bintree/Root.cpp
index 0dfe939..d42fe43 100644
--- a/src/index/bintree/Root.cpp
+++ b/src/index/bintree/Root.cpp
@@ -25,62 +25,63 @@ namespace geos {
 namespace index { // geos.index
 namespace bintree { // geos.index.bintree
 
-double Root::origin=0.0;
+double Root::origin = 0.0;
 
 void
-Root::insert(Interval *itemInterval,void* item)
+Root::insert(Interval* itemInterval, void* item)
 {
-	int index=getSubnodeIndex(itemInterval,origin);
-	// if index is -1, itemEnv must contain the origin.
-	if (index==-1) {
-		add(item);
-		return;
-	}
+    int index = getSubnodeIndex(itemInterval, origin);
+    // if index is -1, itemEnv must contain the origin.
+    if(index == -1) {
+        add(item);
+        return;
+    }
 
-	/**
-	 * the item must be contained in one interval, so insert it into the
-	 * tree for that interval (which may not yet exist)
-	 */
-	Node *node=subnode[index];
+    /**
+     * the item must be contained in one interval, so insert it into the
+     * tree for that interval (which may not yet exist)
+     */
+    Node* node = subnode[index];
 
-	/**
-	 *  If the subnode doesn't exist or this item is not contained in it,
-	 *  have to expand the tree upward to contain the item.
-	 */
-	if (node==nullptr || !node->getInterval()->contains(itemInterval))
-	{
-		Node* largerNode=Node::createExpanded(node,itemInterval);
+    /**
+     *  If the subnode doesn't exist or this item is not contained in it,
+     *  have to expand the tree upward to contain the item.
+     */
+    if(node == nullptr || !node->getInterval()->contains(itemInterval)) {
+        Node* largerNode = Node::createExpanded(node, itemInterval);
 //		delete subnode[index];
-		subnode[index]=largerNode;
-	}
-	/**
-	* At this point we have a subnode which exists and must contain
-	* contains the env for the item.  Insert the item into the tree.
-	*/
-	insertContained(subnode[index],itemInterval,item);
-	//System.out.println("depth = " + root.depth() + " size = " + root.size());
+        subnode[index] = largerNode;
+    }
+    /**
+    * At this point we have a subnode which exists and must contain
+    * contains the env for the item.  Insert the item into the tree.
+    */
+    insertContained(subnode[index], itemInterval, item);
+    //System.out.println("depth = " + root.depth() + " size = " + root.size());
 }
 
 void
-Root::insertContained(Node *tree, Interval *itemInterval, void* item)
+Root::insertContained(Node* tree, Interval* itemInterval, void* item)
 {
-	using geos::index::quadtree::IntervalSize;
+    using geos::index::quadtree::IntervalSize;
 
-	assert(tree->getInterval()->contains(itemInterval));
+    assert(tree->getInterval()->contains(itemInterval));
 
-	/**
-	 * Do NOT create a new node for zero-area intervals - this would lead
-	 * to infinite recursion. Instead, use a heuristic of simply returning
-	 * the smallest existing node containing the query
-	 */
-	bool isZeroArea=IntervalSize::isZeroWidth(itemInterval->getMin(),
-			itemInterval->getMax());
-	NodeBase *node;
-	if (isZeroArea)
-		node=tree->find(itemInterval);
-	else
-		node=tree->getNode(itemInterval);
-	node->add(item);
+    /**
+     * Do NOT create a new node for zero-area intervals - this would lead
+     * to infinite recursion. Instead, use a heuristic of simply returning
+     * the smallest existing node containing the query
+     */
+    bool isZeroArea = IntervalSize::isZeroWidth(itemInterval->getMin(),
+                      itemInterval->getMax());
+    NodeBase* node;
+    if(isZeroArea) {
+        node = tree->find(itemInterval);
+    }
+    else {
+        node = tree->getNode(itemInterval);
+    }
+    node->add(item);
 }
 
 } // namespace geos.index.bintree
diff --git a/src/index/chain/MonotoneChain.cpp b/src/index/chain/MonotoneChain.cpp
index 53f6af1..35be392 100644
--- a/src/index/chain/MonotoneChain.cpp
+++ b/src/index/chain/MonotoneChain.cpp
@@ -32,13 +32,13 @@ namespace chain { // geos.index.chain
 
 MonotoneChain::MonotoneChain(const geom::CoordinateSequence& newPts,
                              size_t nstart, size_t nend, void* nContext)
-	:
-	pts(newPts),
-	env(nullptr),
-	context(nContext),
-	start(nstart),
-	end(nend),
-	id(-1)
+    :
+    pts(newPts),
+    env(nullptr),
+    context(nContext),
+    start(nstart),
+    end(nend),
+    id(-1)
 {
 }
 
@@ -50,8 +50,7 @@ MonotoneChain::~MonotoneChain()
 const Envelope&
 MonotoneChain::getEnvelope() const
 {
-    if (nullptr == env)
-    {
+    if(nullptr == env) {
         const Coordinate& p0 = pts[start];
         const Coordinate& p1 = pts[end];
         env = new Envelope(p0, p1);
@@ -63,7 +62,7 @@ void
 MonotoneChain::getLineSegment(size_t index, LineSegment& ls) const
 {
     ls.p0 = pts[index];
-    ls.p1 = pts[index+1];
+    ls.p1 = pts[index + 1];
 }
 
 std::unique_ptr<CoordinateSequence>
@@ -81,40 +80,38 @@ MonotoneChain::select(const Envelope& searchEnv, MonotoneChainSelectAction& mcs)
 void
 MonotoneChain::computeSelect(const Envelope& searchEnv,
                              size_t start0, size_t end0,
-                             MonotoneChainSelectAction& mcs )
+                             MonotoneChainSelectAction& mcs)
 {
-    const Coordinate& p0=pts[start0];
-    const Coordinate& p1=pts[end0];
+    const Coordinate& p0 = pts[start0];
+    const Coordinate& p1 = pts[end0];
 
     // terminating condition for the recursion
-    if(end0-start0==1)
-    {
+    if(end0 - start0 == 1) {
         mcs.select(*this, start0);
         return;
     }
     // nothing to do if the envelopes don't overlap
-    if (!searchEnv.intersects(p0, p1))
+    if(!searchEnv.intersects(p0, p1)) {
         return;
+    }
     // the chains overlap,so split each in half and iterate (binary search)
     size_t mid = (start0 + end0) / 2;
 
     // Assert: mid != start or end (since we checked above for end-start <= 1)
     // check terminating conditions before recursing
-    if (start0 < mid)
-    {
-        computeSelect(searchEnv,start0,mid,mcs);
+    if(start0 < mid) {
+        computeSelect(searchEnv, start0, mid, mcs);
     }
 
-    if (mid < end0)
-    {
-        computeSelect(searchEnv,mid,end0,mcs);
+    if(mid < end0) {
+        computeSelect(searchEnv, mid, end0, mcs);
     }
 }
 
 /* public */
 void
-MonotoneChain::computeOverlaps(MonotoneChain *mc,
-                               MonotoneChainOverlapAction *mco)
+MonotoneChain::computeOverlaps(MonotoneChain* mc,
+                               MonotoneChainOverlapAction* mco)
 {
     computeOverlaps(start, end, *mc, mc->start, mc->end, *mco);
 }
@@ -127,36 +124,39 @@ MonotoneChain::computeOverlaps(size_t start0, size_t end0,
                                MonotoneChainOverlapAction& mco)
 {
     // terminating condition for the recursion
-    if (end0-start0==1 && end1-start1==1)
-    {
+    if(end0 - start0 == 1 && end1 - start1 == 1) {
         mco.overlap(*this, start0, mc, start1);
         return;
     }
 
     // nothing to do if the envelopes of these subchains don't overlap
-    if (!overlaps(start0, end0, mc, start1, end1)) return;
+    if(!overlaps(start0, end0, mc, start1, end1)) {
+        return;
+    }
 
     // the chains overlap,so split each in half and iterate (binary search)
-    size_t mid0=(start0+end0)/2;
-    size_t mid1=(start1+end1)/2;
+    size_t mid0 = (start0 + end0) / 2;
+    size_t mid1 = (start1 + end1) / 2;
 
     // Assert: mid != start or end (since we checked above for
     // end-start <= 1)
     // check terminating conditions before recursing
-    if (start0<mid0)
-    {
-        if (start1<mid1)
+    if(start0 < mid0) {
+        if(start1 < mid1) {
             computeOverlaps(start0, mid0, mc, start1, mid1, mco);
-        if (mid1<end1)
+        }
+        if(mid1 < end1) {
             computeOverlaps(start0, mid0, mc, mid1, end1, mco);
+        }
     }
 
-    if (mid0<end0)
-    {
-        if (start1<mid1)
+    if(mid0 < end0) {
+        if(start1 < mid1) {
             computeOverlaps(mid0, end0, mc, start1, mid1, mco);
-        if (mid1<end1)
+        }
+        if(mid1 < end1) {
             computeOverlaps(mid0, end0, mc, mid1, end1, mco);
+        }
     }
 }
 
@@ -165,7 +165,7 @@ bool
 MonotoneChain::overlaps(size_t start0, size_t end0, const MonotoneChain& mc, int start1, size_t end1)
 {
     return Envelope::intersects(pts.getAt(start0), pts.getAt(end0),
-        mc.pts.getAt(start1), mc.pts.getAt(end1));
+                                mc.pts.getAt(start1), mc.pts.getAt(end1));
 }
 
 } // namespace geos.index.chain
diff --git a/src/index/chain/MonotoneChainBuilder.cpp b/src/index/chain/MonotoneChainBuilder.cpp
index 2e30a63..64fce94 100644
--- a/src/index/chain/MonotoneChainBuilder.cpp
+++ b/src/index/chain/MonotoneChainBuilder.cpp
@@ -45,10 +45,10 @@ namespace chain { // geos.index.chain
 std::unique_ptr<std::vector<std::unique_ptr<MonotoneChain>>>
 MonotoneChainBuilder::getChains(const CoordinateSequence* pts, void* context)
 {
-   	// TODO clean this up with std::make_unique (C++14)
-	std::unique_ptr<std::vector<std::unique_ptr<MonotoneChain>>> mcList{new vector<std::unique_ptr<MonotoneChain>>()};
-	getChains(pts, context, *mcList);
-	return mcList;
+    // TODO clean this up with std::make_unique (C++14)
+    std::unique_ptr<std::vector<std::unique_ptr<MonotoneChain>>> mcList{new vector<std::unique_ptr<MonotoneChain>>()};
+    getChains(pts, context, *mcList);
+    return mcList;
 }
 
 /* static public */
@@ -56,35 +56,33 @@ void
 MonotoneChainBuilder::getChains(const CoordinateSequence* pts, void* context,
                                 vector<std::unique_ptr<MonotoneChain>>& mcList)
 {
-	vector<std::size_t> startIndex;
-	getChainStartIndices(*pts, startIndex);
-	std::size_t nindexes = startIndex.size();
-	if (nindexes > 0)
-	{
-		std::size_t n = nindexes - 1;
-		for(std::size_t i = 0; i < n; i++)
-		{
-			mcList.emplace_back(new MonotoneChain(*pts, startIndex[i], startIndex[i+1], context));
-		}
-	}
+    vector<std::size_t> startIndex;
+    getChainStartIndices(*pts, startIndex);
+    std::size_t nindexes = startIndex.size();
+    if(nindexes > 0) {
+        std::size_t n = nindexes - 1;
+        for(std::size_t i = 0; i < n; i++) {
+            mcList.emplace_back(new MonotoneChain(*pts, startIndex[i], startIndex[i + 1], context));
+        }
+    }
 }
 
 /* static public */
 void
 MonotoneChainBuilder::getChainStartIndices(const CoordinateSequence& pts,
-                                           vector<std::size_t>& startIndexList)
+        vector<std::size_t>& startIndexList)
 {
-	// find the startpoint (and endpoints) of all monotone chains
-	// in this edge
-	std::size_t start = 0;
-	startIndexList.push_back(start);
-	const std::size_t n = pts.getSize() - 1;
-	do
-	{
-		std::size_t last = findChainEnd(pts, start);
-		startIndexList.push_back(last);
-		start = last;
-	} while (start < n);
+    // find the startpoint (and endpoints) of all monotone chains
+    // in this edge
+    std::size_t start = 0;
+    startIndexList.push_back(start);
+    const std::size_t n = pts.getSize() - 1;
+    do {
+        std::size_t last = findChainEnd(pts, start);
+        startIndexList.push_back(last);
+        start = last;
+    }
+    while(start < n);
 
 }
 
@@ -93,49 +91,48 @@ std::size_t
 MonotoneChainBuilder::findChainEnd(const CoordinateSequence& pts, std::size_t start)
 {
 
-	const std::size_t npts = pts.getSize(); // cache
-
-	assert(start < npts);
-	assert(npts); // should be implied by the assertion above,
-	              // 'start' being unsigned
-
-	std::size_t safeStart = start;
-
-        // skip any zero-length segments at the start of the sequence
-        // (since they cannot be used to establish a quadrant)
-	while ( safeStart < npts - 1
-		&& pts[safeStart].equals2D(pts[safeStart+1]) )
-	{
-		++safeStart;
-	}
-
-	// check if there are NO non-zero-length segments
-	if (safeStart >= npts - 1) {
-		return npts - 1;
-	}
-
-	// determine overall quadrant for chain
-	// (which is the starting quadrant)
-	int chainQuad = Quadrant::quadrant(pts[safeStart],
-	                                   pts[safeStart + 1]);
-	std::size_t last = start + 1;
-	while (last < npts)
-	{
-		// skip zero-length segments, but include them in the chain
-		if (! pts[last - 1].equals2D( pts[last] ) )
-		{
-			// compute quadrant for next possible segment in chain
-			int quad = Quadrant::quadrant( pts[last - 1],
-			                               pts[last]      );
-			if (quad != chainQuad) break;
-		}
-		++last;
-	}
+    const std::size_t npts = pts.getSize(); // cache
+
+    assert(start < npts);
+    assert(npts); // should be implied by the assertion above,
+    // 'start' being unsigned
+
+    std::size_t safeStart = start;
+
+    // skip any zero-length segments at the start of the sequence
+    // (since they cannot be used to establish a quadrant)
+    while(safeStart < npts - 1
+            && pts[safeStart].equals2D(pts[safeStart + 1])) {
+        ++safeStart;
+    }
+
+    // check if there are NO non-zero-length segments
+    if(safeStart >= npts - 1) {
+        return npts - 1;
+    }
+
+    // determine overall quadrant for chain
+    // (which is the starting quadrant)
+    int chainQuad = Quadrant::quadrant(pts[safeStart],
+                                       pts[safeStart + 1]);
+    std::size_t last = start + 1;
+    while(last < npts) {
+        // skip zero-length segments, but include them in the chain
+        if(! pts[last - 1].equals2D(pts[last])) {
+            // compute quadrant for next possible segment in chain
+            int quad = Quadrant::quadrant(pts[last - 1],
+                                          pts[last]);
+            if(quad != chainQuad) {
+                break;
+            }
+        }
+        ++last;
+    }
 #if GEOS_DEBUG
-	std::cerr<<"MonotoneChainBuilder::findChainEnd() returning"<<std::endl;
+    std::cerr << "MonotoneChainBuilder::findChainEnd() returning" << std::endl;
 #endif
 
-	return last - 1;
+    return last - 1;
 }
 
 } // namespace geos.index.chain
diff --git a/src/index/chain/MonotoneChainOverlapAction.cpp b/src/index/chain/MonotoneChainOverlapAction.cpp
index a6fcb8f..8dd479b 100644
--- a/src/index/chain/MonotoneChainOverlapAction.cpp
+++ b/src/index/chain/MonotoneChainOverlapAction.cpp
@@ -30,11 +30,11 @@ namespace chain { // geos.index.chain
 
 void
 MonotoneChainOverlapAction::overlap(MonotoneChain& mc1, size_t start1,
-		MonotoneChain& mc2, size_t start2)
+                                    MonotoneChain& mc2, size_t start2)
 {
-	mc1.getLineSegment(start1, overlapSeg1);
-	mc2.getLineSegment(start2, overlapSeg2);
-	overlap(overlapSeg1, overlapSeg2);
+    mc1.getLineSegment(start1, overlapSeg1);
+    mc2.getLineSegment(start2, overlapSeg2);
+    overlap(overlapSeg1, overlapSeg2);
 }
 
 } // namespace geos.index.chain
diff --git a/src/index/chain/MonotoneChainSelectAction.cpp b/src/index/chain/MonotoneChainSelectAction.cpp
index ac505a1..4f4478d 100644
--- a/src/index/chain/MonotoneChainSelectAction.cpp
+++ b/src/index/chain/MonotoneChainSelectAction.cpp
@@ -30,9 +30,9 @@ namespace chain { // geos.index.chain
 void
 MonotoneChainSelectAction::select(MonotoneChain& mc, size_t start)
 {
-	mc.getLineSegment(start, selectedSegment);
+    mc.getLineSegment(start, selectedSegment);
 
-	select(selectedSegment);
+    select(selectedSegment);
 }
 
 } // namespace geos.index.chain
diff --git a/src/index/intervalrtree/IntervalRTreeBranchNode.cpp b/src/index/intervalrtree/IntervalRTreeBranchNode.cpp
index 3031f2e..e24515c 100644
--- a/src/index/intervalrtree/IntervalRTreeBranchNode.cpp
+++ b/src/index/intervalrtree/IntervalRTreeBranchNode.cpp
@@ -33,16 +33,19 @@ namespace intervalrtree {
 
 
 void
-IntervalRTreeBranchNode::query( double queryMin, double queryMax, index::ItemVisitor * visitor) const
+IntervalRTreeBranchNode::query(double queryMin, double queryMax, index::ItemVisitor* visitor) const
 {
-	if (! intersects(queryMin, queryMax))
-		return;
+    if(! intersects(queryMin, queryMax)) {
+        return;
+    }
 
-	if (node1)
-		node1->query( queryMin, queryMax, visitor);
+    if(node1) {
+        node1->query(queryMin, queryMax, visitor);
+    }
 
-	if (node2)
-		node2->query( queryMin, queryMax, visitor);
+    if(node2) {
+        node2->query(queryMin, queryMax, visitor);
+    }
 }
 
 
diff --git a/src/index/intervalrtree/IntervalRTreeLeafNode.cpp b/src/index/intervalrtree/IntervalRTreeLeafNode.cpp
index 1de76eb..7812d69 100644
--- a/src/index/intervalrtree/IntervalRTreeLeafNode.cpp
+++ b/src/index/intervalrtree/IntervalRTreeLeafNode.cpp
@@ -31,12 +31,13 @@ namespace intervalrtree {
 // public:
 //
 void
-IntervalRTreeLeafNode::query( double queryMin, double queryMax, index::ItemVisitor * visitor) const
+IntervalRTreeLeafNode::query(double queryMin, double queryMax, index::ItemVisitor* visitor) const
 {
-	if (! intersects( queryMin, queryMax))
-		return;
+    if(! intersects(queryMin, queryMax)) {
+        return;
+    }
 
-	visitor->visitItem( item);
+    visitor->visitItem(item);
 }
 
 } // geos::intervalrtree
diff --git a/src/index/intervalrtree/SortedPackedIntervalRTree.cpp b/src/index/intervalrtree/SortedPackedIntervalRTree.cpp
index dedc661..b2b8b86 100644
--- a/src/index/intervalrtree/SortedPackedIntervalRTree.cpp
+++ b/src/index/intervalrtree/SortedPackedIntervalRTree.cpp
@@ -34,60 +34,59 @@ namespace intervalrtree {
 void
 SortedPackedIntervalRTree::init()
 {
-	if (root != nullptr) return;
+    if(root != nullptr) {
+        return;
+    }
 
-	root = buildTree();
+    root = buildTree();
 }
 
-const IntervalRTreeNode *
+const IntervalRTreeNode*
 SortedPackedIntervalRTree::buildTree()
 {
-	branches.reserve(leaves.size() - 1);
+    branches.reserve(leaves.size() - 1);
 
-	// now group nodes into blocks of two and build tree up recursively
-	std::vector<const IntervalRTreeNode*> src{leaves.size()};
-	std::vector<const IntervalRTreeNode*> dest;
-	std::transform(leaves.begin(), leaves.end(), src.begin(), [](const IntervalRTreeLeafNode & n) { return &n; });
+    // now group nodes into blocks of two and build tree up recursively
+    std::vector<const IntervalRTreeNode*> src{leaves.size()};
+    std::vector<const IntervalRTreeNode*> dest;
+    std::transform(leaves.begin(), leaves.end(), src.begin(), [](const IntervalRTreeLeafNode & n) {
+        return &n;
+    });
 
-	// sort the leaf nodes
-	std::sort( src.begin(), src.end(), IntervalRTreeNode::compare );
+    // sort the leaf nodes
+    std::sort(src.begin(), src.end(), IntervalRTreeNode::compare);
 
-	while (true)
-	{
-		buildLevel(src, dest);
+    while(true) {
+        buildLevel(src, dest);
 
-		if (dest.size() == 1)
-		{
-		    return dest[0];
-		}
+        if(dest.size() == 1) {
+            return dest[0];
+        }
 
-		std::swap(src, dest);
-	}
+        std::swap(src, dest);
+    }
 }
 
 void
-SortedPackedIntervalRTree::buildLevel(IntervalRTreeNode::ConstVect & src, IntervalRTreeNode::ConstVect & dest)
+SortedPackedIntervalRTree::buildLevel(IntervalRTreeNode::ConstVect& src, IntervalRTreeNode::ConstVect& dest)
 {
-	level++;
-
-	dest.clear();
-
-	for (size_t i = 0, ni = src.size(); i < ni; i += 2)
-	{
-		const IntervalRTreeNode * n1 = src[i];
-
-		if ( i + 1 < ni )
-		{
-			const IntervalRTreeNode * n2 = src[i + 1];
-
-			branches.emplace_back(n1, n2);
-			dest.push_back(&branches.back());
-		}
-		else
-		{
-			dest.push_back( n1);
-		}
-	}
+    level++;
+
+    dest.clear();
+
+    for(size_t i = 0, ni = src.size(); i < ni; i += 2) {
+        const IntervalRTreeNode* n1 = src[i];
+
+        if(i + 1 < ni) {
+            const IntervalRTreeNode* n2 = src[i + 1];
+
+            branches.emplace_back(n1, n2);
+            dest.push_back(&branches.back());
+        }
+        else {
+            dest.push_back(n1);
+        }
+    }
 }
 
 //
@@ -99,20 +98,21 @@ SortedPackedIntervalRTree::buildLevel(IntervalRTreeNode::ConstVect & src, Interv
 //
 
 void
-SortedPackedIntervalRTree::insert( double min, double max, void * item)
+SortedPackedIntervalRTree::insert(double min, double max, void* item)
 {
-	if (root != nullptr)
-		throw util::UnsupportedOperationException( "Index cannot be added to once it has been queried");
+    if(root != nullptr) {
+        throw util::UnsupportedOperationException("Index cannot be added to once it has been queried");
+    }
 
-	leaves.emplace_back(min, max, item);
+    leaves.emplace_back(min, max, item);
 }
 
 void
-SortedPackedIntervalRTree::query( double min, double max, index::ItemVisitor * visitor)
+SortedPackedIntervalRTree::query(double min, double max, index::ItemVisitor* visitor)
 {
-	init();
+    init();
 
-	root->query( min, max, visitor);
+    root->query(min, max, visitor);
 }
 
 } // geos::intervalrtree
diff --git a/src/index/quadtree/DoubleBits.cpp b/src/index/quadtree/DoubleBits.cpp
index 36e93bb..ec036de 100644
--- a/src/index/quadtree/DoubleBits.cpp
+++ b/src/index/quadtree/DoubleBits.cpp
@@ -42,75 +42,82 @@ using namespace std;
 double
 DoubleBits::powerOf2(int exp)
 {
-	if (exp>1023 || exp<-1022)
-		throw util::IllegalArgumentException("Exponent out of bounds");
+    if(exp > 1023 || exp < -1022) {
+        throw util::IllegalArgumentException("Exponent out of bounds");
+    }
 #if ASSUME_IEEE_DOUBLE
-	int64 expBias=exp+EXPONENT_BIAS;
-	int64 bits=expBias << 52;
-	double ret;
-	memcpy(&ret, &bits, sizeof(int64));
-	return ret;
+    int64 expBias = exp + EXPONENT_BIAS;
+    int64 bits = expBias << 52;
+    double ret;
+    memcpy(&ret, &bits, sizeof(int64));
+    return ret;
 #else
-	return pow(2.0, exp);
+    return pow(2.0, exp);
 #endif
 }
 
 int
 DoubleBits::exponent(double d)
 {
-	DoubleBits db(d);
-	return db.getExponent();
+    DoubleBits db(d);
+    return db.getExponent();
 }
 
 double
 DoubleBits::truncateToPowerOfTwo(double d)
 {
-	DoubleBits db(d);
-	db.zeroLowerBits(52);
-	return db.getDouble();
+    DoubleBits db(d);
+    db.zeroLowerBits(52);
+    return db.getDouble();
 }
 
-string DoubleBits::toBinaryString(double d) {
-	DoubleBits db(d);
-	return db.toString();
+string
+DoubleBits::toBinaryString(double d)
+{
+    DoubleBits db(d);
+    return db.toString();
 }
 
 double
 DoubleBits::maximumCommonMantissa(double d1, double d2)
 {
-	if (d1==0.0 || d2==0.0) return 0.0;
-	DoubleBits db1(d1);
-	DoubleBits db2(d2);
-	if (db1.getExponent() != db2.getExponent()) return 0.0;
-	int maxCommon=db1.numCommonMantissaBits(db2);
-	db1.zeroLowerBits(64-(12+maxCommon));
-	return db1.getDouble();
+    if(d1 == 0.0 || d2 == 0.0) {
+        return 0.0;
+    }
+    DoubleBits db1(d1);
+    DoubleBits db2(d2);
+    if(db1.getExponent() != db2.getExponent()) {
+        return 0.0;
+    }
+    int maxCommon = db1.numCommonMantissaBits(db2);
+    db1.zeroLowerBits(64 - (12 + maxCommon));
+    return db1.getDouble();
 }
 
 /*public*/
 DoubleBits::DoubleBits(double nx)
 {
 #if ASSUME_IEEE_DOUBLE
-	memcpy(&xBits,&nx,sizeof(double));
+    memcpy(&xBits, &nx, sizeof(double));
 #endif
-	x = nx;
+    x = nx;
 }
 
 /*public*/
 double
 DoubleBits::getDouble() const
 {
-	return x;
+    return x;
 }
 
 /*public*/
 int64
 DoubleBits::biasedExponent() const
 {
-	int64 signExp=xBits>>52;
-	int64 exp=signExp&0x07ff;
-	//cerr<<"xBits:"<<xBits<<" signExp:"<<signExp<<" exp:"<<exp<<endl;
-	return exp;
+    int64 signExp = xBits >> 52;
+    int64 exp = signExp & 0x07ff;
+    //cerr<<"xBits:"<<xBits<<" signExp:"<<signExp<<" exp:"<<exp<<endl;
+    return exp;
 }
 
 /*public*/
@@ -118,10 +125,12 @@ int
 DoubleBits::getExponent() const
 {
 #if ASSUME_IEEE_DOUBLE
-	return static_cast<int>(biasedExponent() - EXPONENT_BIAS);
+    return static_cast<int>(biasedExponent() - EXPONENT_BIAS);
 #else
-	if ( x <= 0 ) return 0; // EDOM || ERANGE
-	return (int)((log(x)/log(2.0))+(x<1?-0.9:0.00000000001));
+    if(x <= 0) {
+        return 0;    // EDOM || ERANGE
+    }
+    return (int)((log(x) / log(2.0)) + (x < 1 ? -0.9 : 0.00000000001));
 #endif
 }
 
@@ -129,29 +138,30 @@ DoubleBits::getExponent() const
 void
 DoubleBits::zeroLowerBits(int nBits)
 {
-	long invMask=(1L<<nBits)-1L;
-	long mask=~invMask;
-	xBits&=mask;
+    long invMask = (1L << nBits) - 1L;
+    long mask = ~invMask;
+    xBits &= mask;
 }
 
 /*public*/
 int
 DoubleBits::getBit(int i) const
 {
-	long mask=(1L<<i);
-	return (xBits&mask)!=0?1:0;
+    long mask = (1L << i);
+    return (xBits & mask) != 0 ? 1 : 0;
 }
 
 /*public*/
 int
 DoubleBits::numCommonMantissaBits(const DoubleBits& db) const
 {
-	for (int i=0;i<52;i++) {
-		//int bitIndex=i+12;
-		if (getBit(i)!=db.getBit(i))
-			return i;
-	}
-	return 52;
+    for(int i = 0; i < 52; i++) {
+        //int bitIndex=i+12;
+        if(getBit(i) != db.getBit(i)) {
+            return i;
+        }
+    }
+    return 52;
 }
 
 /*public*/
diff --git a/src/index/quadtree/IntervalSize.cpp b/src/index/quadtree/IntervalSize.cpp
index f2b8568..54d5e5c 100644
--- a/src/index/quadtree/IntervalSize.cpp
+++ b/src/index/quadtree/IntervalSize.cpp
@@ -33,13 +33,15 @@ namespace quadtree { // geos.index.quadtree
 bool
 IntervalSize::isZeroWidth(double mn, double mx)
 {
-	double width = mx - mn;
-	if (width == 0.0) return true;
+    double width = mx - mn;
+    if(width == 0.0) {
+        return true;
+    }
 
-	double maxAbs = max(fabs(mn), fabs(mx));
-	double scaledInterval = width / maxAbs;
-	int level = DoubleBits::exponent(scaledInterval);
-	return level <= MIN_BINARY_EXPONENT;
+    double maxAbs = max(fabs(mn), fabs(mx));
+    double scaledInterval = width / maxAbs;
+    int level = DoubleBits::exponent(scaledInterval);
+    return level <= MIN_BINARY_EXPONENT;
 }
 
 } // namespace geos.index.quadtree
diff --git a/src/index/quadtree/Key.cpp b/src/index/quadtree/Key.cpp
index f20e2c8..fedfa61 100644
--- a/src/index/quadtree/Key.cpp
+++ b/src/index/quadtree/Key.cpp
@@ -43,23 +43,23 @@ namespace quadtree { // geos.index.quadtree
 int
 Key::computeQuadLevel(const Envelope& env)
 {
-	double dx = env.getWidth();
-	double dy = env.getHeight();
-	double dMax = dx > dy ? dx : dy;
-	int level=DoubleBits::exponent(dMax)+1;
+    double dx = env.getWidth();
+    double dy = env.getHeight();
+    double dMax = dx > dy ? dx : dy;
+    int level = DoubleBits::exponent(dMax) + 1;
 #if GEOS_DEBUG
-	std::cerr<<"Maxdelta:"<<dMax<<" exponent:"<<(level-1)<<std::endl;
+    std::cerr << "Maxdelta:" << dMax << " exponent:" << (level - 1) << std::endl;
 #endif
-	return level;
+    return level;
 }
 
 Key::Key(const Envelope& itemEnv)
-	:
-	pt(),
-	level(0),
-	env()
+    :
+    pt(),
+    level(0),
+    env()
 {
-	computeKey(itemEnv);
+    computeKey(itemEnv);
 }
 
 Key::~Key()
@@ -69,47 +69,47 @@ Key::~Key()
 const Coordinate&
 Key::getPoint() const
 {
-	return pt;
+    return pt;
 }
 
 int
 Key::getLevel() const
 {
-	return level;
+    return level;
 }
 
 const Envelope&
 Key::getEnvelope() const
 {
-	return env;
+    return env;
 }
 
 Coordinate*
 Key::getCentre() const
 {
-	return new Coordinate(
-			( env.getMinX() + env.getMaxX() ) / 2,
-			( env.getMinY() + env.getMaxY() ) / 2
-		);
+    return new Coordinate(
+               (env.getMinX() + env.getMaxX()) / 2,
+               (env.getMinY() + env.getMaxY()) / 2
+           );
 }
 
 /*public*/
 void
 Key::computeKey(const Envelope& itemEnv)
 {
-	level=computeQuadLevel(itemEnv);
-	env.init(); // reset to null
-	computeKey(level, itemEnv);
-	// MD - would be nice to have a non-iterative form of this algorithm
-	while (!env.contains(itemEnv)) {
-		level+=1;
-		computeKey(level, itemEnv);
-	}
+    level = computeQuadLevel(itemEnv);
+    env.init(); // reset to null
+    computeKey(level, itemEnv);
+    // MD - would be nice to have a non-iterative form of this algorithm
+    while(!env.contains(itemEnv)) {
+        level += 1;
+        computeKey(level, itemEnv);
+    }
 #if GEOS_DEBUG
-	std::cerr<<"Key::computeKey:"<<std::endl;
-	std::cerr<<" itemEnv: "<<itemEnv.toString()<<std::endl;
-	std::cerr<<"  keyEnv: "<<env.toString()<<std::endl;
-	std::cerr<<"  keyLvl: "<<level<<std::endl;
+    std::cerr << "Key::computeKey:" << std::endl;
+    std::cerr << " itemEnv: " << itemEnv.toString() << std::endl;
+    std::cerr << "  keyEnv: " << env.toString() << std::endl;
+    std::cerr << "  keyLvl: " << level << std::endl;
 
 #endif
 }
@@ -117,11 +117,11 @@ Key::computeKey(const Envelope& itemEnv)
 void
 Key::computeKey(int p_level, const Envelope& itemEnv)
 {
-	double quadSize=DoubleBits::powerOf2(p_level);
-	//double quadSize=pow2.power(level);
-	pt.x = std::floor(itemEnv.getMinX()/quadSize)*quadSize;
-	pt.y = std::floor(itemEnv.getMinY()/quadSize)*quadSize;
-	env.init(pt.x, pt.x + quadSize, pt.y, pt.y + quadSize);
+    double quadSize = DoubleBits::powerOf2(p_level);
+    //double quadSize=pow2.power(level);
+    pt.x = std::floor(itemEnv.getMinX() / quadSize) * quadSize;
+    pt.y = std::floor(itemEnv.getMinY() / quadSize) * quadSize;
+    env.init(pt.x, pt.x + quadSize, pt.y, pt.y + quadSize);
 }
 
 } // namespace geos.index.quadtree
diff --git a/src/index/quadtree/Node.cpp b/src/index/quadtree/Node.cpp
index 0268b93..7cc1ba6 100644
--- a/src/index/quadtree/Node.cpp
+++ b/src/index/quadtree/Node.cpp
@@ -45,161 +45,155 @@ namespace quadtree { // geos.index.quadtree
 std::unique_ptr<Node>
 Node::createNode(const Envelope& env)
 {
-	Key key(env);
-	std::unique_ptr<Envelope> envelope(new Envelope(key.getEnvelope()));
-	std::unique_ptr<Node> node (
-	  new Node(std::move(envelope), key.getLevel())
-	);
-	return node;
+    Key key(env);
+    std::unique_ptr<Envelope> envelope(new Envelope(key.getEnvelope()));
+    std::unique_ptr<Node> node(
+        new Node(std::move(envelope), key.getLevel())
+    );
+    return node;
 }
 
 /* static public */
 std::unique_ptr<Node>
 Node::createExpanded(std::unique_ptr<Node> node, const Envelope& addEnv)
 {
-	Envelope expandEnv(addEnv);
-	if ( node.get() ) // should this be asserted ?
-	{
-		expandEnv.expandToInclude(node->getEnvelope());
-	}
+    Envelope expandEnv(addEnv);
+    if(node.get()) {  // should this be asserted ?
+        expandEnv.expandToInclude(node->getEnvelope());
+    }
 
 #if GEOS_DEBUG
-	cerr<<"Node::createExpanded computed "<<expandEnv.toString()<<endl;
+    cerr << "Node::createExpanded computed " << expandEnv.toString() << endl;
 #endif
 
-	std::unique_ptr<Node> largerNode = createNode(expandEnv);
-	if ( node.get() ) // should this be asserted ?
-	{
-		largerNode->insertNode(std::move(node));
-	}
+    std::unique_ptr<Node> largerNode = createNode(expandEnv);
+    if(node.get()) {  // should this be asserted ?
+        largerNode->insertNode(std::move(node));
+    }
 
-	return largerNode;
+    return largerNode;
 }
 
 /*public*/
 Node*
-Node::getNode(const Envelope *searchEnv)
+Node::getNode(const Envelope* searchEnv)
 {
-	int subnodeIndex = getSubnodeIndex(searchEnv, centre);
-	// if subquadIndex is -1 searchEnv is not contained in a subquad
-	if (subnodeIndex != -1)
-	{
-		// create the quad if it does not exist
-		Node *node = getSubnode(subnodeIndex);
-		// recursively search the found/created quad
-		return node->getNode(searchEnv);
-	}
-	else
-	{
-		return this;
-	}
+    int subnodeIndex = getSubnodeIndex(searchEnv, centre);
+    // if subquadIndex is -1 searchEnv is not contained in a subquad
+    if(subnodeIndex != -1) {
+        // create the quad if it does not exist
+        Node* node = getSubnode(subnodeIndex);
+        // recursively search the found/created quad
+        return node->getNode(searchEnv);
+    }
+    else {
+        return this;
+    }
 }
 
 /*public*/
 NodeBase*
-Node::find(const Envelope *searchEnv)
+Node::find(const Envelope* searchEnv)
 {
-	int subnodeIndex=getSubnodeIndex(searchEnv, centre);
-	if (subnodeIndex==-1)
-		return this;
-	if (subnodes[subnodeIndex]!=nullptr) {
-		// query lies in subquad, so search it
-		Node *node=subnodes[subnodeIndex];
-		return node->find(searchEnv);
-	}
-	// no existing subquad, so return this one anyway
-	return this;
+    int subnodeIndex = getSubnodeIndex(searchEnv, centre);
+    if(subnodeIndex == -1) {
+        return this;
+    }
+    if(subnodes[subnodeIndex] != nullptr) {
+        // query lies in subquad, so search it
+        Node* node = subnodes[subnodeIndex];
+        return node->find(searchEnv);
+    }
+    // no existing subquad, so return this one anyway
+    return this;
 }
 
 void
 Node::insertNode(std::unique_ptr<Node> node)
 {
-	assert( env->contains(node->getEnvelope()) );
-
-	int index = getSubnodeIndex(node->getEnvelope(), centre);
-	assert(index >= 0);
-
-	if (node->level == level-1)
-	{
-		// We take ownership of node
-		delete subnodes[index];
-		subnodes[index] = node.release();
-
-		//System.out.println("inserted");
-	}
-	else
-	{
-		// the quad is not a direct child, so make a new child
-		// quad to contain it and recursively insert the quad
-		std::unique_ptr<Node> childNode ( createSubnode(index) );
-
-		// childNode takes ownership of node
-		childNode->insertNode(std::move(node));
-
-		// We take ownership of childNode
-		delete subnodes[index];
-		subnodes[index] = childNode.release();
-	}
+    assert(env->contains(node->getEnvelope()));
+
+    int index = getSubnodeIndex(node->getEnvelope(), centre);
+    assert(index >= 0);
+
+    if(node->level == level - 1) {
+        // We take ownership of node
+        delete subnodes[index];
+        subnodes[index] = node.release();
+
+        //System.out.println("inserted");
+    }
+    else {
+        // the quad is not a direct child, so make a new child
+        // quad to contain it and recursively insert the quad
+        std::unique_ptr<Node> childNode(createSubnode(index));
+
+        // childNode takes ownership of node
+        childNode->insertNode(std::move(node));
+
+        // We take ownership of childNode
+        delete subnodes[index];
+        subnodes[index] = childNode.release();
+    }
 }
 
 Node*
 Node::getSubnode(int index)
 {
-	assert(index >=0 && index < 4);
-	if (subnodes[index] == nullptr)
-	{
-		subnodes[index] = createSubnode(index).release();
-	}
-	return subnodes[index];
+    assert(index >= 0 && index < 4);
+    if(subnodes[index] == nullptr) {
+        subnodes[index] = createSubnode(index).release();
+    }
+    return subnodes[index];
 }
 
 std::unique_ptr<Node>
 Node::createSubnode(int index)
 {
-	// create a new subquad in the appropriate quadrant
-	double minx=0.0;
-	double maxx=0.0;
-	double miny=0.0;
-	double maxy=0.0;
-
-	switch (index) {
-		case 0:
-			minx=env->getMinX();
-			maxx=centre.x;
-			miny=env->getMinY();
-			maxy=centre.y;
-			break;
-		case 1:
-			minx=centre.x;
-			maxx=env->getMaxX();
-			miny=env->getMinY();
-			maxy=centre.y;
-			break;
-		case 2:
-			minx=env->getMinX();
-			maxx=centre.x;
-			miny=centre.y;
-			maxy=env->getMaxY();
-			break;
-		case 3:
-			minx=centre.x;
-			maxx=env->getMaxX();
-			miny=centre.y;
-			maxy=env->getMaxY();
-			break;
-	}
-	std::unique_ptr<Envelope> sqEnv ( new Envelope(minx,maxx,miny,maxy) );
-	std::unique_ptr<Node> node ( new Node(std::move(sqEnv), level-1) );
-	return node;
+    // create a new subquad in the appropriate quadrant
+    double minx = 0.0;
+    double maxx = 0.0;
+    double miny = 0.0;
+    double maxy = 0.0;
+
+    switch(index) {
+    case 0:
+        minx = env->getMinX();
+        maxx = centre.x;
+        miny = env->getMinY();
+        maxy = centre.y;
+        break;
+    case 1:
+        minx = centre.x;
+        maxx = env->getMaxX();
+        miny = env->getMinY();
+        maxy = centre.y;
+        break;
+    case 2:
+        minx = env->getMinX();
+        maxx = centre.x;
+        miny = centre.y;
+        maxy = env->getMaxY();
+        break;
+    case 3:
+        minx = centre.x;
+        maxx = env->getMaxX();
+        miny = centre.y;
+        maxy = env->getMaxY();
+        break;
+    }
+    std::unique_ptr<Envelope> sqEnv(new Envelope(minx, maxx, miny, maxy));
+    std::unique_ptr<Node> node(new Node(std::move(sqEnv), level - 1));
+    return node;
 }
 
 string
 Node::toString() const
 {
-	ostringstream os;
-	os <<"L"<<level<<" "<<env->toString()<<" Ctr["<<centre.toString()<<"]";
-	os <<" "+NodeBase::toString();
-	return os.str();
+    ostringstream os;
+    os << "L" << level << " " << env->toString() << " Ctr[" << centre.toString() << "]";
+    os << " " + NodeBase::toString();
+    return os.str();
 }
 
 
diff --git a/src/index/quadtree/NodeBase.cpp b/src/index/quadtree/NodeBase.cpp
index 394ab01..937bc67 100644
--- a/src/index/quadtree/NodeBase.cpp
+++ b/src/index/quadtree/NodeBase.cpp
@@ -44,93 +44,98 @@ namespace index { // geos.index
 namespace quadtree { // geos.index.quadtree
 
 int
-NodeBase::getSubnodeIndex(const Envelope *env, const Coordinate& centre)
+NodeBase::getSubnodeIndex(const Envelope* env, const Coordinate& centre)
 {
-	int subnodeIndex=-1;
-	if (env->getMinX()>=centre.x) {
-		if (env->getMinY()>=centre.y) subnodeIndex=3;
-		if (env->getMaxY()<=centre.y) subnodeIndex=1;
-	}
-	if (env->getMaxX()<=centre.x) {
-		if (env->getMinY()>=centre.y) subnodeIndex=2;
-		if (env->getMaxY()<=centre.y) subnodeIndex=0;
-	}
+    int subnodeIndex = -1;
+    if(env->getMinX() >= centre.x) {
+        if(env->getMinY() >= centre.y) {
+            subnodeIndex = 3;
+        }
+        if(env->getMaxY() <= centre.y) {
+            subnodeIndex = 1;
+        }
+    }
+    if(env->getMaxX() <= centre.x) {
+        if(env->getMinY() >= centre.y) {
+            subnodeIndex = 2;
+        }
+        if(env->getMaxY() <= centre.y) {
+            subnodeIndex = 0;
+        }
+    }
 #if GEOS_DEBUG
-	cerr<<"getSubNodeIndex("<<env->toString()<<", "<<centre.toString()<<") returning "<<subnodeIndex<<endl;
+    cerr << "getSubNodeIndex(" << env->toString() << ", " << centre.toString() << ") returning " << subnodeIndex << endl;
 #endif
-	return subnodeIndex;
+    return subnodeIndex;
 }
 
 NodeBase::NodeBase()
 {
-	subnodes[0]=nullptr;
-	subnodes[1]=nullptr;
-	subnodes[2]=nullptr;
-	subnodes[3]=nullptr;
+    subnodes[0] = nullptr;
+    subnodes[1] = nullptr;
+    subnodes[2] = nullptr;
+    subnodes[3] = nullptr;
 }
 
 NodeBase::~NodeBase()
 {
-	delete subnodes[0];
-	delete subnodes[1];
-	delete subnodes[2];
-	delete subnodes[3];
-	subnodes[0]=nullptr;
-	subnodes[1]=nullptr;
-	subnodes[2]=nullptr;
-	subnodes[3]=nullptr;
+    delete subnodes[0];
+    delete subnodes[1];
+    delete subnodes[2];
+    delete subnodes[3];
+    subnodes[0] = nullptr;
+    subnodes[1] = nullptr;
+    subnodes[2] = nullptr;
+    subnodes[3] = nullptr;
 }
 
 vector<void*>&
 NodeBase::getItems()
 {
-	return items;
+    return items;
 }
 
 void
 NodeBase::add(void* item)
 {
-	items.push_back(item);
-	//GEOS_DEBUG itemCount++;
-	//GEOS_DEBUG System.out.print(itemCount);
+    items.push_back(item);
+    //GEOS_DEBUG itemCount++;
+    //GEOS_DEBUG System.out.print(itemCount);
 }
 
 vector<void*>&
 NodeBase::addAllItems(vector<void*>& resultItems) const
 {
-	// this node may have items as well as subnodes (since items may not
-	// be wholly contained in any single subnode
-	resultItems.insert(resultItems.end(), items.begin(), items.end());
-
-	for(const auto& subnode : subnodes)
-	{
-		if (subnode != nullptr)
-		{
-			subnode->addAllItems(resultItems);
-		}
-	}
-	return resultItems;
+    // this node may have items as well as subnodes (since items may not
+    // be wholly contained in any single subnode
+    resultItems.insert(resultItems.end(), items.begin(), items.end());
+
+    for(const auto& subnode : subnodes) {
+        if(subnode != nullptr) {
+            subnode->addAllItems(resultItems);
+        }
+    }
+    return resultItems;
 }
 
 void
 NodeBase::addAllItemsFromOverlapping(const Envelope& searchEnv,
                                      vector<void*>& resultItems) const
 {
-	if (!isSearchMatch(searchEnv))
-		return;
-
-	// this node may have items as well as subnodes (since items may not
-	// be wholly contained in any single subnode
-	resultItems.insert(resultItems.end(), items.begin(), items.end());
-
-	for(const auto& subnode : subnodes)
-	{
-		if (subnode != nullptr)
-		{
-			subnode->addAllItemsFromOverlapping(searchEnv,
-			                                       resultItems);
-		}
-	}
+    if(!isSearchMatch(searchEnv)) {
+        return;
+    }
+
+    // this node may have items as well as subnodes (since items may not
+    // be wholly contained in any single subnode
+    resultItems.insert(resultItems.end(), items.begin(), items.end());
+
+    for(const auto& subnode : subnodes) {
+        if(subnode != nullptr) {
+            subnode->addAllItemsFromOverlapping(searchEnv,
+                                                resultItems);
+        }
+    }
 }
 
 //<<TODO:RENAME?>> In Samet's terminology, I think what we're returning here is
@@ -138,77 +143,79 @@ NodeBase::addAllItemsFromOverlapping(const Envelope& searchEnv,
 unsigned int
 NodeBase::depth() const
 {
-	unsigned int maxSubDepth=0;
-
-	for (const auto& subnode : subnodes)
-	{
-		if (subnode != nullptr)
-		{
-			unsigned int sqd=subnode->depth();
-			if ( sqd > maxSubDepth )
-				maxSubDepth=sqd;
-		}
-	}
-	return maxSubDepth + 1;
+    unsigned int maxSubDepth = 0;
+
+    for(const auto& subnode : subnodes) {
+        if(subnode != nullptr) {
+            unsigned int sqd = subnode->depth();
+            if(sqd > maxSubDepth) {
+                maxSubDepth = sqd;
+            }
+        }
+    }
+    return maxSubDepth + 1;
 }
 
 size_t
 NodeBase::size() const
 {
-	size_t subSize = 0;
-	for(const auto& subnode : subnodes)
-	{
-		if (subnode != nullptr)
-		{
-			subSize += subnode->size();
-		}
-	}
-	return subSize + items.size();
+    size_t subSize = 0;
+    for(const auto& subnode : subnodes) {
+        if(subnode != nullptr) {
+            subSize += subnode->size();
+        }
+    }
+    return subSize + items.size();
 }
 
 size_t
 NodeBase::getNodeCount() const
 {
-	size_t subSize = 0;
-	for (const auto& subnode : subnodes) {
-		if (subnode != nullptr) {
-			subSize += subnode->size();
-		}
-	}
-
-	return subSize + 1;
+    size_t subSize = 0;
+    for(const auto& subnode : subnodes) {
+        if(subnode != nullptr) {
+            subSize += subnode->size();
+        }
+    }
+
+    return subSize + 1;
 }
 
 string
 NodeBase::toString() const
 {
-	ostringstream s;
-	s<<"ITEMS:"<<items.size()<<endl;
-	for (size_t i=0; i < subnodes.size(); i++)
-	{
-		s<<"subnode["<<i<<"] ";
-		if ( subnodes[i] == nullptr ) s<<"NULL";
-		else s<<subnodes[i]->toString();
-		s<<endl;
-	}
-	return s.str();
+    ostringstream s;
+    s << "ITEMS:" << items.size() << endl;
+    for(size_t i = 0; i < subnodes.size(); i++) {
+        s << "subnode[" << i << "] ";
+        if(subnodes[i] == nullptr) {
+            s << "NULL";
+        }
+        else {
+            s << subnodes[i]->toString();
+        }
+        s << endl;
+    }
+    return s.str();
 }
 
 /*public*/
 void
 NodeBase::visit(const Envelope* searchEnv, ItemVisitor& visitor)
 {
-	if (! isSearchMatch(*searchEnv)) return;
-
-	// this node may have items as well as subnodes (since items may not
-	// be wholly contained in any single subnode
-	visitItems(searchEnv, visitor);
-
-	for (const auto& subnode : subnodes) {
-		if (subnode != nullptr) {
-			subnode->visit(searchEnv, visitor);
-		}
-	}
+    if(! isSearchMatch(*searchEnv)) {
+        return;
+    }
+
+    // this node may have items as well as subnodes (since items may not
+    // be wholly contained in any single subnode
+    visitItems(searchEnv, visitor);
+
+    for(const auto& subnode : subnodes) {
+        if(subnode != nullptr) {
+            subnode->visit(searchEnv, visitor);
+        }
+    }
 }
 
 /*private*/
@@ -217,50 +224,51 @@ NodeBase::visitItems(const Envelope* searchEnv, ItemVisitor& visitor)
 {
     ::geos::ignore_unused_variable_warning(searchEnv);
 
-	// would be nice to filter items based on search envelope, but can't
-	// until they contain an envelope
-	for (auto& item : items) {
-		visitor.visitItem(item);
-	}
+    // would be nice to filter items based on search envelope, but can't
+    // until they contain an envelope
+    for(auto& item : items) {
+        visitor.visitItem(item);
+    }
 }
 
 /*public*/
 bool
 NodeBase::remove(const Envelope* itemEnv, void* item)
 {
-	// use envelope to restrict nodes scanned
-	if (! isSearchMatch(*itemEnv)) return false;
-
-	bool found = false;
-	for (auto& subnode : subnodes)
-	{
-		if (subnode != nullptr)
-		{
-			found = subnode->remove(itemEnv, item);
-			if (found)
-			{
-				// trim subtree if empty
-				if (subnode->isPrunable())
-				{
-					delete subnode;
-					subnode = nullptr;
-				}
-				break;
-			}
-		}
-	}
-	// if item was found lower down, don't need to search for it here
-	if (found) return found;
-
-	// otherwise, try and remove the item from the list of items
-	// in this node
-	auto foundIter = find(items.begin(), items.end(), item);
-	if ( foundIter != items.end() ) {
-		items.erase(foundIter);
-		return true;
-	} else {
-		return false;
-	}
+    // use envelope to restrict nodes scanned
+    if(! isSearchMatch(*itemEnv)) {
+        return false;
+    }
+
+    bool found = false;
+    for(auto& subnode : subnodes) {
+        if(subnode != nullptr) {
+            found = subnode->remove(itemEnv, item);
+            if(found) {
+                // trim subtree if empty
+                if(subnode->isPrunable()) {
+                    delete subnode;
+                    subnode = nullptr;
+                }
+                break;
+            }
+        }
+    }
+    // if item was found lower down, don't need to search for it here
+    if(found) {
+        return found;
+    }
+
+    // otherwise, try and remove the item from the list of items
+    // in this node
+    auto foundIter = find(items.begin(), items.end(), item);
+    if(foundIter != items.end()) {
+        items.erase(foundIter);
+        return true;
+    }
+    else {
+        return false;
+    }
 }
 
 
diff --git a/src/index/quadtree/Quadtree.cpp b/src/index/quadtree/Quadtree.cpp
index e09623b..cf82e3e 100644
--- a/src/index/quadtree/Quadtree.cpp
+++ b/src/index/quadtree/Quadtree.cpp
@@ -40,77 +40,81 @@ namespace quadtree { // geos.index.quadtree
 
 /*public static*/
 Envelope*
-Quadtree::ensureExtent(const Envelope *itemEnv, double minExtent)
+Quadtree::ensureExtent(const Envelope* itemEnv, double minExtent)
 {
-	//The names "ensureExtent" and "minExtent" are misleading -- sounds like
-	//this method ensures that the extents are greater than minExtent.
-	//Perhaps we should rename them to "ensurePositiveExtent" and "defaultExtent".
-	//[Jon Aquino]
-	double minx=itemEnv->getMinX();
-	double maxx=itemEnv->getMaxX();
-	double miny=itemEnv->getMinY();
-	double maxy=itemEnv->getMaxY();
-	// has a non-zero extent
-	if (minx!=maxx && miny!=maxy) return (Envelope *)itemEnv;
-	// pad one or both extents
-	if (minx==maxx) {
-		minx=minx-minExtent/2.0;
-		maxx=minx+minExtent/2.0;
-	}
-	if (miny==maxy) {
-		miny=miny-minExtent/2.0;
-		maxy=miny+minExtent/2.0;
-	}
-	Envelope *newEnv = new Envelope(minx, maxx, miny, maxy);
-	return newEnv;
+    //The names "ensureExtent" and "minExtent" are misleading -- sounds like
+    //this method ensures that the extents are greater than minExtent.
+    //Perhaps we should rename them to "ensurePositiveExtent" and "defaultExtent".
+    //[Jon Aquino]
+    double minx = itemEnv->getMinX();
+    double maxx = itemEnv->getMaxX();
+    double miny = itemEnv->getMinY();
+    double maxy = itemEnv->getMaxY();
+    // has a non-zero extent
+    if(minx != maxx && miny != maxy) {
+        return (Envelope*)itemEnv;
+    }
+    // pad one or both extents
+    if(minx == maxx) {
+        minx = minx - minExtent / 2.0;
+        maxx = minx + minExtent / 2.0;
+    }
+    if(miny == maxy) {
+        miny = miny - minExtent / 2.0;
+        maxy = miny + minExtent / 2.0;
+    }
+    Envelope* newEnv = new Envelope(minx, maxx, miny, maxy);
+    return newEnv;
 }
 
 /*public*/
 int
 Quadtree::depth()
 {
-	return root.depth();
+    return root.depth();
 }
 
 /*public*/
 size_t
 Quadtree::size()
 {
-	return root.size();
+    return root.size();
 }
 
 /*public*/
 void
-Quadtree::insert(const Envelope *itemEnv, void* item)
+Quadtree::insert(const Envelope* itemEnv, void* item)
 {
-	collectStats(*itemEnv);
+    collectStats(*itemEnv);
 
-	Envelope *insertEnv=ensureExtent(itemEnv,minExtent);
-	if ( insertEnv != itemEnv ) newEnvelopes.emplace_back(insertEnv);
-	root.insert(insertEnv,item);
+    Envelope* insertEnv = ensureExtent(itemEnv, minExtent);
+    if(insertEnv != itemEnv) {
+        newEnvelopes.emplace_back(insertEnv);
+    }
+    root.insert(insertEnv, item);
 #if GEOS_DEBUG
-	cerr<<"Quadtree::insert("<<itemEnv->toString()<<", "<<item<<")"<<endl;
-	cerr<<"       insertEnv:"<<insertEnv->toString()<<endl;
-	cerr<<"       tree:"<<endl<<root.toString()<<endl;
+    cerr << "Quadtree::insert(" << itemEnv->toString() << ", " << item << ")" << endl;
+    cerr << "       insertEnv:" << insertEnv->toString() << endl;
+    cerr << "       tree:" << endl << root.toString() << endl;
 #endif
 }
 
 
 /*public*/
 void
-Quadtree::query(const Envelope *searchEnv,
-	vector<void*>& foundItems)
+Quadtree::query(const Envelope* searchEnv,
+                vector<void*>& foundItems)
 {
-	/*
-	 * the items that are matched are the items in quads which
-	 * overlap the search envelope
-	 */
-	root.addAllItemsFromOverlapping(*searchEnv, foundItems);
+    /*
+     * the items that are matched are the items in quads which
+     * overlap the search envelope
+     */
+    root.addAllItemsFromOverlapping(*searchEnv, foundItems);
 #if GEOS_DEBUG
-	cerr<<"Quadtree::query returning "<<foundItems.size()
-		<<" items over "<<size()
-		<<" items in index (of depth: "<<depth()<<")"<<endl;
-	cerr<<" Root:\n"<<root.toString()<<endl;
+    cerr << "Quadtree::query returning " << foundItems.size()
+         << " items over " << size()
+         << " items in index (of depth: " << depth() << ")" << endl;
+    cerr << " Root:\n" << root.toString() << endl;
 #endif
 }
 
@@ -118,40 +122,44 @@ Quadtree::query(const Envelope *searchEnv,
 vector<void*>*
 Quadtree::queryAll()
 {
-	vector<void*> *foundItems=new vector<void*>();
-	root.addAllItems(*foundItems);
-	return foundItems;
+    vector<void*>* foundItems = new vector<void*>();
+    root.addAllItems(*foundItems);
+    return foundItems;
 }
 
 /*public*/
 bool
 Quadtree::remove(const Envelope* itemEnv, void* item)
 {
-	Envelope* posEnv = ensureExtent(itemEnv, minExtent);
-	bool ret = root.remove(posEnv, item);
-	if ( posEnv != itemEnv ) delete posEnv;
-	return ret;
+    Envelope* posEnv = ensureExtent(itemEnv, minExtent);
+    bool ret = root.remove(posEnv, item);
+    if(posEnv != itemEnv) {
+        delete posEnv;
+    }
+    return ret;
 }
 
 /*private*/
 void
 Quadtree::collectStats(const Envelope& itemEnv)
 {
-	double delX = itemEnv.getWidth();
-	if (delX < minExtent && delX > 0.0)
-		minExtent = delX;
-
-	double delY = itemEnv.getHeight();
-	if (delY < minExtent && delY > 0.0)
-		minExtent = delY;
+    double delX = itemEnv.getWidth();
+    if(delX < minExtent && delX > 0.0) {
+        minExtent = delX;
+    }
+
+    double delY = itemEnv.getHeight();
+    if(delY < minExtent && delY > 0.0) {
+        minExtent = delY;
+    }
 }
 
 /*public*/
 string
 Quadtree::toString() const
 {
-	string ret = root.toString();
-	return ret;
+    string ret = root.toString();
+    return ret;
 }
 
 } // namespace geos.index.quadtree
diff --git a/src/index/quadtree/Root.cpp b/src/index/quadtree/Root.cpp
index 3dbe298..46f5ed3 100644
--- a/src/index/quadtree/Root.cpp
+++ b/src/index/quadtree/Root.cpp
@@ -45,99 +45,97 @@ const Coordinate Root::origin(0.0, 0.0);
 
 /*public*/
 void
-Root::insert(const Envelope *itemEnv, void* item)
+Root::insert(const Envelope* itemEnv, void* item)
 {
 
 #if GEOS_DEBUG
-	std::cerr<< "Root("<<this<<")::insert("<<itemEnv->toString()<<", "<<item<<") called"<<std::endl;
+    std::cerr << "Root(" << this << ")::insert(" << itemEnv->toString() << ", " << item << ") called" << std::endl;
 #endif
-	int index = getSubnodeIndex(itemEnv, origin);
-	// if index is -1, itemEnv must cross the X or Y axis.
-	if (index==-1)
-	{
+    int index = getSubnodeIndex(itemEnv, origin);
+    // if index is -1, itemEnv must cross the X or Y axis.
+    if(index == -1) {
 #if GEOS_DEBUG
-	std::cerr<<"  -1 subnode index"<<std::endl;
+        std::cerr << "  -1 subnode index" << std::endl;
 #endif
-		add(item);
-		return;
-	}
+        add(item);
+        return;
+    }
 
-	/*
-	 * the item must be contained in one quadrant, so insert it into the
-	 * tree for that quadrant (which may not yet exist)
-	 */
-	Node *node = subnodes[index];
+    /*
+     * the item must be contained in one quadrant, so insert it into the
+     * tree for that quadrant (which may not yet exist)
+     */
+    Node* node = subnodes[index];
 
 #if GEOS_DEBUG
-	std::cerr<<"("<<this<<") subnode["<<index<<"] @ "<<node<<std::endl;
+    std::cerr << "(" << this << ") subnode[" << index << "] @ " << node << std::endl;
 #endif
 
-	/*
-	 *  If the subquad doesn't exist or this item is not contained in it,
-	 *  have to expand the tree upward to contain the item.
-	 */
-	if (node==nullptr || !node->getEnvelope()->contains(itemEnv))
-	{
-		std::unique_ptr<Node> snode (node); // may be NULL
-		node = nullptr; subnodes[index] = nullptr;
+    /*
+     *  If the subquad doesn't exist or this item is not contained in it,
+     *  have to expand the tree upward to contain the item.
+     */
+    if(node == nullptr || !node->getEnvelope()->contains(itemEnv)) {
+        std::unique_ptr<Node> snode(node);  // may be NULL
+        node = nullptr;
+        subnodes[index] = nullptr;
 
-		std::unique_ptr<Node> largerNode =
-			Node::createExpanded(std::move(snode), *itemEnv);
+        std::unique_ptr<Node> largerNode =
+            Node::createExpanded(std::move(snode), *itemEnv);
 
 #if GEOS_DEBUG
-		std::cerr<<"("<<this<<") created expanded node " << largerNode.get() << " containing previously reported subnode" << std::endl;
+        std::cerr << "(" << this << ") created expanded node " << largerNode.get() << " containing previously reported subnode"
+                  << std::endl;
 #endif
 
-		// Previous subnode was passed as a child of the larger one
-		assert(!subnodes[index]);
-		subnodes[index] = largerNode.release();
-	}
+        // Previous subnode was passed as a child of the larger one
+        assert(!subnodes[index]);
+        subnodes[index] = largerNode.release();
+    }
 
 #if GEOS_DEBUG
-	std::cerr<<"("<<this<<") calling insertContained with subnode " << subnode[index] << std::endl;
+    std::cerr << "(" << this << ") calling insertContained with subnode " << subnode[index] << std::endl;
 #endif
-	/*
-	 * At this point we have a subquad which exists and must contain
-	 * contains the env for the item.  Insert the item into the tree.
-	 */
-	insertContained(subnodes[index], itemEnv, item);
+    /*
+     * At this point we have a subquad which exists and must contain
+     * contains the env for the item.  Insert the item into the tree.
+     */
+    insertContained(subnodes[index], itemEnv, item);
 
 #if GEOS_DEBUG
-	std::cerr<<"("<<this<<") done calling insertContained with subnode " << subnode[index] << std::endl;
+    std::cerr << "(" << this << ") done calling insertContained with subnode " << subnode[index] << std::endl;
 #endif
 
-	//System.out.println("depth = " + root.depth() + " size = " + root.size());
-	//System.out.println(" size = " + size());
+    //System.out.println("depth = " + root.depth() + " size = " + root.size());
+    //System.out.println(" size = " + size());
 }
 
 /*private*/
 void
-Root::insertContained(Node *tree, const Envelope *itemEnv, void *item)
+Root::insertContained(Node* tree, const Envelope* itemEnv, void* item)
 {
-	assert(tree->getEnvelope()->contains(itemEnv));
-
-	/**
-	 * Do NOT create a new quad for zero-area envelopes - this would lead
-	 * to infinite recursion. Instead, use a heuristic of simply returning
-	 * the smallest existing quad containing the query
-	 */
-	bool isZeroX = IntervalSize::isZeroWidth(itemEnv->getMinX(),
-	                                         itemEnv->getMaxX());
-	bool isZeroY = IntervalSize::isZeroWidth(itemEnv->getMinY(),
-	                                         itemEnv->getMaxY());
-
-	NodeBase *node;
-
-	if (isZeroX || isZeroY)
-	{
-		node = tree->find(itemEnv);
-	}
-	else
-	{
-		node = tree->getNode(itemEnv);
-	}
-
-	node->add(item);
+    assert(tree->getEnvelope()->contains(itemEnv));
+
+    /**
+     * Do NOT create a new quad for zero-area envelopes - this would lead
+     * to infinite recursion. Instead, use a heuristic of simply returning
+     * the smallest existing quad containing the query
+     */
+    bool isZeroX = IntervalSize::isZeroWidth(itemEnv->getMinX(),
+                   itemEnv->getMaxX());
+    bool isZeroY = IntervalSize::isZeroWidth(itemEnv->getMinY(),
+                   itemEnv->getMaxY());
+
+    NodeBase* node;
+
+    if(isZeroX || isZeroY) {
+        node = tree->find(itemEnv);
+    }
+    else {
+        node = tree->getNode(itemEnv);
+    }
+
+    node->add(item);
 }
 
 } // namespace geos.index.quadtree
diff --git a/src/index/strtree/AbstractNode.cpp b/src/index/strtree/AbstractNode.cpp
index f0d64d9..5d6848b 100644
--- a/src/index/strtree/AbstractNode.cpp
+++ b/src/index/strtree/AbstractNode.cpp
@@ -30,39 +30,45 @@ namespace strtree { // geos.index.strtree
  * @param level 0 if this node is a leaf, 1 if a parent of a leaf, and so on;
  * the root node will have the highest level
  */
-AbstractNode::AbstractNode(int newLevel, size_t capacity) {
-	childBoundables.reserve(capacity);
-	bounds=nullptr;
-	level=newLevel;
+AbstractNode::AbstractNode(int newLevel, size_t capacity)
+{
+    childBoundables.reserve(capacity);
+    bounds = nullptr;
+    level = newLevel;
 }
 
-AbstractNode::~AbstractNode() {
+AbstractNode::~AbstractNode()
+{
 }
 
-const void *
+const void*
 AbstractNode::getBounds() const
 {
-	if (bounds==nullptr) {
-		bounds = computeBounds();
-	}
-	return bounds;
+    if(bounds == nullptr) {
+        bounds = computeBounds();
+    }
+    return bounds;
 }
 
 /**
 * Returns 0 if this node is a leaf, 1 if a parent of a leaf, and so on; the
 * root node will have the highest level
 */
-int AbstractNode::getLevel() {
-	return level;
+int
+AbstractNode::getLevel()
+{
+    return level;
 }
 
 /**
  * Adds either an AbstractNode, or if this is a leaf node, a data object
  * (wrapped in an ItemBoundable)
  */
-void AbstractNode::addChildBoundable(Boundable *childBoundable) {
-	assert(bounds==nullptr);
-	childBoundables.push_back(childBoundable);
+void
+AbstractNode::addChildBoundable(Boundable* childBoundable)
+{
+    assert(bounds == nullptr);
+    childBoundables.push_back(childBoundable);
 }
 
 } // namespace geos.index.strtree
diff --git a/src/index/strtree/AbstractSTRtree.cpp b/src/index/strtree/AbstractSTRtree.cpp
index 12fa521..ffbf349 100644
--- a/src/index/strtree/AbstractSTRtree.cpp
+++ b/src/index/strtree/AbstractSTRtree.cpp
@@ -33,227 +33,224 @@ namespace strtree { // geos.index.strtree
 
 AbstractSTRtree::~AbstractSTRtree()
 {
-	assert(nullptr != itemBoundables);
+    assert(nullptr != itemBoundables);
     BoundableList::iterator it = itemBoundables->begin();
     BoundableList::iterator end = itemBoundables->end();
-	while (it != end)
-	{
-		delete *it;
+    while(it != end) {
+        delete *it;
         ++it;
-	}
-	delete itemBoundables;
+    }
+    delete itemBoundables;
 
-	assert(nullptr != nodes);
-	for (std::size_t i = 0, nsize = nodes->size(); i < nsize; i++)
-    {
-		delete (*nodes)[i];
+    assert(nullptr != nodes);
+    for(std::size_t i = 0, nsize = nodes->size(); i < nsize; i++) {
+        delete(*nodes)[i];
     }
-	delete nodes;
+    delete nodes;
 }
 
 /*public*/
 void
 AbstractSTRtree::build()
 {
-	if(built)
-		return;
+    if(built) {
+        return;
+    }
 
-	root=(itemBoundables->empty()?createNode(0):createHigherLevels(itemBoundables,-1));
-	built=true;
+    root = (itemBoundables->empty() ? createNode(0) : createHigherLevels(itemBoundables, -1));
+    built = true;
 }
 
 /*protected*/
 std::unique_ptr<BoundableList>
 AbstractSTRtree::createParentBoundables(BoundableList* childBoundables,
-		int newLevel)
+                                        int newLevel)
 {
-	assert(!childBoundables->empty());
-	std::unique_ptr< BoundableList > parentBoundables ( new BoundableList() );
-	parentBoundables->push_back(createNode(newLevel));
-
-	std::unique_ptr< BoundableList > sortedChildBoundables ( sortBoundables(childBoundables) );
-
-	for (BoundableList::iterator i=sortedChildBoundables->begin(),
-			e=sortedChildBoundables->end();
-			i!=e; i++)
-	//for(std::size_t i=0, scbsize=sortedChildBoundables->size(); i<scbsize; ++i)
-	{
-		Boundable *childBoundable=*i; // (*sortedChildBoundables)[i];
-
-		AbstractNode *last = lastNode(parentBoundables.get());
-		if (last->getChildBoundables()->size() == nodeCapacity)
-		{
-			last=createNode(newLevel);
-			parentBoundables->push_back(last);
-		}
-		last->addChildBoundable(childBoundable);
-	}
-	return parentBoundables;
+    assert(!childBoundables->empty());
+    std::unique_ptr< BoundableList > parentBoundables(new BoundableList());
+    parentBoundables->push_back(createNode(newLevel));
+
+    std::unique_ptr< BoundableList > sortedChildBoundables(sortBoundables(childBoundables));
+
+    for(BoundableList::iterator i = sortedChildBoundables->begin(),
+            e = sortedChildBoundables->end();
+            i != e; i++)
+        //for(std::size_t i=0, scbsize=sortedChildBoundables->size(); i<scbsize; ++i)
+    {
+        Boundable* childBoundable = *i; // (*sortedChildBoundables)[i];
+
+        AbstractNode* last = lastNode(parentBoundables.get());
+        if(last->getChildBoundables()->size() == nodeCapacity) {
+            last = createNode(newLevel);
+            parentBoundables->push_back(last);
+        }
+        last->addChildBoundable(childBoundable);
+    }
+    return parentBoundables;
 }
 
 /*private*/
 AbstractNode*
 AbstractSTRtree::createHigherLevels(BoundableList* boundablesOfALevel, int level)
 {
-	assert(!boundablesOfALevel->empty());
-	std::unique_ptr< BoundableList > parentBoundables (
-			createParentBoundables(boundablesOfALevel,level+1)
-			);
-
-	if (parentBoundables->size()==1)
-	{
-		// Cast from Boundable to AbstractNode
-		AbstractNode *ret = static_cast<AbstractNode*>(parentBoundables->front());
-		return ret;
-	}
-	AbstractNode *ret = createHigherLevels(parentBoundables.get(), level+1);
-	return ret;
+    assert(!boundablesOfALevel->empty());
+    std::unique_ptr< BoundableList > parentBoundables(
+        createParentBoundables(boundablesOfALevel, level + 1)
+    );
+
+    if(parentBoundables->size() == 1) {
+        // Cast from Boundable to AbstractNode
+        AbstractNode* ret = static_cast<AbstractNode*>(parentBoundables->front());
+        return ret;
+    }
+    AbstractNode* ret = createHigherLevels(parentBoundables.get(), level + 1);
+    return ret;
 }
 
 /*protected*/
 void
-AbstractSTRtree::insert(const void* bounds,void* item)
+AbstractSTRtree::insert(const void* bounds, void* item)
 {
-	// Cannot insert items into an STR packed R-tree after it has been built
-	assert(!built);
-	itemBoundables->push_back(new ItemBoundable(bounds,item));
+    // Cannot insert items into an STR packed R-tree after it has been built
+    assert(!built);
+    itemBoundables->push_back(new ItemBoundable(bounds, item));
 }
 
 /*protected*/
 void
 AbstractSTRtree::query(const void* searchBounds, vector<void*>& matches)
 {
-	if (!built) build();
+    if(!built) {
+        build();
+    }
 
-	if (itemBoundables->empty()) {
-		assert(root->getBounds()==nullptr);
-		return;
-	}
+    if(itemBoundables->empty()) {
+        assert(root->getBounds() == nullptr);
+        return;
+    }
 
-	if (getIntersectsOp()->intersects(root->getBounds(), searchBounds))
-	{
-		query(searchBounds,root, &matches);
-	}
+    if(getIntersectsOp()->intersects(root->getBounds(), searchBounds)) {
+        query(searchBounds, root, &matches);
+    }
 }
 
 /*protected*/
 void
 AbstractSTRtree::query(const void* searchBounds, ItemVisitor& visitor)
 {
-	if (!built) build();
+    if(!built) {
+        build();
+    }
 
-	if (itemBoundables->empty()) {
-        assert(root->getBounds()==nullptr);
+    if(itemBoundables->empty()) {
+        assert(root->getBounds() == nullptr);
         return;
-	}
+    }
 
-	if (getIntersectsOp()->intersects(root->getBounds(),searchBounds))
-	{
-		query(searchBounds, *root, visitor);
-	}
+    if(getIntersectsOp()->intersects(root->getBounds(), searchBounds)) {
+        query(searchBounds, *root, visitor);
+    }
 }
 
 /*protected*/
 void
 AbstractSTRtree::query(const void* searchBounds, const AbstractNode& node,
-		ItemVisitor& visitor)
+                       ItemVisitor& visitor)
 {
 
-	const BoundableList& boundables = *(node.getChildBoundables());
-
-	for (BoundableList::const_iterator i=boundables.begin(), e=boundables.end();
-			i!=e; i++)
-	{
-		const Boundable* childBoundable = *i;
-		if (!getIntersectsOp()->intersects(childBoundable->getBounds(), searchBounds)) {
-			continue;
-		}
-
-		if(const AbstractNode *an=dynamic_cast<const AbstractNode*>(childBoundable))
-		{
-			query(searchBounds, *an, visitor);
-		}
-		else if (const ItemBoundable *ib=dynamic_cast<const ItemBoundable *>(childBoundable))
-		{
-			visitor.visitItem(ib->getItem());
-		}
-		else
-		{
-			assert(0); // unsupported childBoundable type
-		}
-	}
+    const BoundableList& boundables = *(node.getChildBoundables());
+
+    for(BoundableList::const_iterator i = boundables.begin(), e = boundables.end();
+            i != e; i++) {
+        const Boundable* childBoundable = *i;
+        if(!getIntersectsOp()->intersects(childBoundable->getBounds(), searchBounds)) {
+            continue;
+        }
+
+        if(const AbstractNode* an = dynamic_cast<const AbstractNode*>(childBoundable)) {
+            query(searchBounds, *an, visitor);
+        }
+        else if(const ItemBoundable* ib = dynamic_cast<const ItemBoundable*>(childBoundable)) {
+            visitor.visitItem(ib->getItem());
+        }
+        else {
+            assert(0); // unsupported childBoundable type
+        }
+    }
 }
 
 /* protected */
 bool
 AbstractSTRtree::remove(const void* searchBounds, void* item)
 {
-	if (!built) build();
-	if (itemBoundables->empty()) {
-		assert(root->getBounds() == nullptr);
-	}
-	if (getIntersectsOp()->intersects(root->getBounds(), searchBounds)) {
-		return remove(searchBounds, *root, item);
-	}
-	return false;
+    if(!built) {
+        build();
+    }
+    if(itemBoundables->empty()) {
+        assert(root->getBounds() == nullptr);
+    }
+    if(getIntersectsOp()->intersects(root->getBounds(), searchBounds)) {
+        return remove(searchBounds, *root, item);
+    }
+    return false;
 }
 
 /* private */
 bool
 AbstractSTRtree::remove(const void* searchBounds, AbstractNode& node, void* item)
 {
-	// first try removing item from this node
-	if ( removeItem(node, item) ) return true;
-
-	BoundableList& boundables = *(node.getChildBoundables());
-
-	// next try removing item from lower nodes
-	for (BoundableList::iterator i=boundables.begin(), e=boundables.end();
-			i!=e; i++)
-	{
-		Boundable* childBoundable = *i;
-		if (!getIntersectsOp()->intersects(childBoundable->getBounds(), searchBounds))
-			continue;
-
-		if (AbstractNode *an=dynamic_cast<AbstractNode*>(childBoundable))
-		{
-			// if found, record child for pruning and exit
-			if ( remove(searchBounds, *an, item) )
-			{
-				if (an->getChildBoundables()->empty()) {
-					boundables.erase(i);
-				}
-				return true;
-			}
-		}
-	}
-
-	return false;
+    // first try removing item from this node
+    if(removeItem(node, item)) {
+        return true;
+    }
+
+    BoundableList& boundables = *(node.getChildBoundables());
+
+    // next try removing item from lower nodes
+    for(BoundableList::iterator i = boundables.begin(), e = boundables.end();
+            i != e; i++) {
+        Boundable* childBoundable = *i;
+        if(!getIntersectsOp()->intersects(childBoundable->getBounds(), searchBounds)) {
+            continue;
+        }
+
+        if(AbstractNode* an = dynamic_cast<AbstractNode*>(childBoundable)) {
+            // if found, record child for pruning and exit
+            if(remove(searchBounds, *an, item)) {
+                if(an->getChildBoundables()->empty()) {
+                    boundables.erase(i);
+                }
+                return true;
+            }
+        }
+    }
+
+    return false;
 }
 
 /*private*/
 bool
 AbstractSTRtree::removeItem(AbstractNode& node, void* item)
 {
-	BoundableList& boundables = *(node.getChildBoundables());
-
-	BoundableList::iterator childToRemove = boundables.end();
-
-	for (BoundableList::iterator i=boundables.begin(),
-			e=boundables.end();
-			i!=e; i++)
-	{
-		Boundable* childBoundable = *i;
-		if (ItemBoundable *ib=dynamic_cast<ItemBoundable*>(childBoundable))
-		{
-			if ( ib->getItem() == item) childToRemove = i;
-		}
-	}
-	if (childToRemove != boundables.end()) {
-		boundables.erase(childToRemove);
-		return true;
-	}
-	return false;
+    BoundableList& boundables = *(node.getChildBoundables());
+
+    BoundableList::iterator childToRemove = boundables.end();
+
+    for(BoundableList::iterator i = boundables.begin(),
+            e = boundables.end();
+            i != e; i++) {
+        Boundable* childBoundable = *i;
+        if(ItemBoundable* ib = dynamic_cast<ItemBoundable*>(childBoundable)) {
+            if(ib->getItem() == item) {
+                childToRemove = i;
+            }
+        }
+    }
+    if(childToRemove != boundables.end()) {
+        boundables.erase(childToRemove);
+        return true;
+    }
+    return false;
 }
 
 
@@ -261,117 +258,106 @@ AbstractSTRtree::removeItem(AbstractNode& node, void* item)
 /*public*/
 void
 AbstractSTRtree::query(const void* searchBounds,
-	const AbstractNode* node, vector<void*> *matches)
+                       const AbstractNode* node, vector<void*>* matches)
 {
-	assert(node);
-
-	const BoundableList& vb = *(node->getChildBoundables());
-
-
-	IntersectsOp *io=getIntersectsOp();
-	//std::size_t vbsize=vb.size();
-	//cerr<<"AbstractSTRtree::query: childBoundables: "<<vbsize<<endl;
-	for(BoundableList::const_iterator i=vb.begin(), e=vb.end();
-			i!=e; ++i)
-	{
-		const Boundable* childBoundable=*i;
-		if (!io->intersects(childBoundable->getBounds(), searchBounds))
-		{
-			continue;
-		}
-
-		if(const AbstractNode *an=dynamic_cast<const AbstractNode*>(childBoundable))
-		{
-			query(searchBounds, an, matches);
-		}
-		else if (const ItemBoundable *ib=dynamic_cast<const ItemBoundable *>(childBoundable))
-		{
-			matches->push_back(ib->getItem());
-		}
-		else
-		{
-			assert(0); // unsupported childBoundable type
-		}
-	}
+    assert(node);
+
+    const BoundableList& vb = *(node->getChildBoundables());
+
+
+    IntersectsOp* io = getIntersectsOp();
+    //std::size_t vbsize=vb.size();
+    //cerr<<"AbstractSTRtree::query: childBoundables: "<<vbsize<<endl;
+    for(BoundableList::const_iterator i = vb.begin(), e = vb.end();
+            i != e; ++i) {
+        const Boundable* childBoundable = *i;
+        if(!io->intersects(childBoundable->getBounds(), searchBounds)) {
+            continue;
+        }
+
+        if(const AbstractNode* an = dynamic_cast<const AbstractNode*>(childBoundable)) {
+            query(searchBounds, an, matches);
+        }
+        else if(const ItemBoundable* ib = dynamic_cast<const ItemBoundable*>(childBoundable)) {
+            matches->push_back(ib->getItem());
+        }
+        else {
+            assert(0); // unsupported childBoundable type
+        }
+    }
 }
 
 void
 AbstractSTRtree::iterate(ItemVisitor& visitor)
 {
-    for (BoundableList::const_iterator i=itemBoundables->begin(), e=itemBoundables->end();
-			i!=e; i++)
-	{
-		const Boundable* boundable = *i;
-		if (const ItemBoundable *ib=dynamic_cast<const ItemBoundable *>(boundable))
-		{
-			visitor.visitItem(ib->getItem());
-		}
+    for(BoundableList::const_iterator i = itemBoundables->begin(), e = itemBoundables->end();
+            i != e; i++) {
+        const Boundable* boundable = *i;
+        if(const ItemBoundable* ib = dynamic_cast<const ItemBoundable*>(boundable)) {
+            visitor.visitItem(ib->getItem());
         }
+    }
 }
 
 /*protected*/
 std::unique_ptr<BoundableList>
 AbstractSTRtree::boundablesAtLevel(int level)
 {
-	std::unique_ptr<BoundableList> boundables ( new BoundableList() );
-	boundablesAtLevel(level, root, boundables.get());
-	return boundables;
+    std::unique_ptr<BoundableList> boundables(new BoundableList());
+    boundablesAtLevel(level, root, boundables.get());
+    return boundables;
 }
 
 /*public*/
 void
 AbstractSTRtree::boundablesAtLevel(int level, AbstractNode* top,
-		BoundableList* boundables)
+                                   BoundableList* boundables)
 {
-	assert(level>-2);
-	if (top->getLevel()==level)
-	{
-		boundables->push_back(top);
-		return;
-	}
-
-	assert(top);
-
-	const BoundableList& vb = *(top->getChildBoundables());
-
-	for(BoundableList::const_iterator i=vb.begin(), e=vb.end();
-			i!=e; ++i)
-	{
-		Boundable* boundable=*i;
-		if (typeid(*boundable)==typeid(AbstractNode))
-		{
-			boundablesAtLevel(level, (AbstractNode*)boundable,
-				boundables);
-		}
-		else
-		{
-			assert(typeid(*boundable)==typeid(ItemBoundable));
-			if (level==-1)
-			{
-				boundables->push_back(boundable);
-			}
-		}
-	}
-	return;
+    assert(level > -2);
+    if(top->getLevel() == level) {
+        boundables->push_back(top);
+        return;
+    }
+
+    assert(top);
+
+    const BoundableList& vb = *(top->getChildBoundables());
+
+    for(BoundableList::const_iterator i = vb.begin(), e = vb.end();
+            i != e; ++i) {
+        Boundable* boundable = *i;
+        if(typeid(*boundable) == typeid(AbstractNode)) {
+            boundablesAtLevel(level, (AbstractNode*)boundable,
+                              boundables);
+        }
+        else {
+            assert(typeid(*boundable) == typeid(ItemBoundable));
+            if(level == -1) {
+                boundables->push_back(boundable);
+            }
+        }
+    }
+    return;
 }
 
-ItemsList* AbstractSTRtree::itemsTree(AbstractNode* node)
+ItemsList*
+AbstractSTRtree::itemsTree(AbstractNode* node)
 {
-    std::unique_ptr<ItemsList> valuesTreeForNode (new ItemsList());
+    std::unique_ptr<ItemsList> valuesTreeForNode(new ItemsList());
 
     BoundableList::iterator end = node->getChildBoundables()->end();
-    for (BoundableList::iterator i = node->getChildBoundables()->begin();
-         i != end; ++i)
-    {
+    for(BoundableList::iterator i = node->getChildBoundables()->begin();
+            i != end; ++i) {
         Boundable* childBoundable = *i;
-        if (dynamic_cast<AbstractNode*>(childBoundable)) {
+        if(dynamic_cast<AbstractNode*>(childBoundable)) {
             ItemsList* valuesTreeForChild =
                 itemsTree(static_cast<AbstractNode*>(childBoundable));
             // only add if not null (which indicates an item somewhere in this tree
-            if (valuesTreeForChild != nullptr)
+            if(valuesTreeForChild != nullptr) {
                 valuesTreeForNode->push_back_owned(valuesTreeForChild);
+            }
         }
-        else if (dynamic_cast<ItemBoundable*>(childBoundable)) {
+        else if(dynamic_cast<ItemBoundable*>(childBoundable)) {
             valuesTreeForNode->push_back(
                 static_cast<ItemBoundable*>(childBoundable)->getItem());
         }
@@ -379,21 +365,24 @@ ItemsList* AbstractSTRtree::itemsTree(AbstractNode* node)
             assert(!static_cast<bool>("should never be reached"));
         }
     }
-    if (valuesTreeForNode->empty())
+    if(valuesTreeForNode->empty()) {
         return nullptr;
+    }
 
     return valuesTreeForNode.release();
 }
 
-ItemsList* AbstractSTRtree::itemsTree()
+ItemsList*
+AbstractSTRtree::itemsTree()
 {
-    if (!built) {
+    if(!built) {
         build();
     }
 
-    ItemsList* valuesTree (itemsTree(root));
-    if (valuesTree == nullptr)
+    ItemsList* valuesTree(itemsTree(root));
+    if(valuesTree == nullptr) {
         return new ItemsList();
+    }
 
     return valuesTree;
 }
diff --git a/src/index/strtree/BoundablePair.cpp b/src/index/strtree/BoundablePair.cpp
index 8e42d87..209249c 100644
--- a/src/index/strtree/BoundablePair.cpp
+++ b/src/index/strtree/BoundablePair.cpp
@@ -25,90 +25,111 @@ namespace geos {
 namespace index {
 namespace strtree {
 
-BoundablePair::BoundablePair(const Boundable* p_boundable1, const Boundable* p_boundable2, ItemDistance* p_itemDistance) :
-	boundable1(p_boundable1),
-	boundable2(p_boundable2),
-	itemDistance(p_itemDistance)
+BoundablePair::BoundablePair(const Boundable* p_boundable1, const Boundable* p_boundable2,
+                             ItemDistance* p_itemDistance) :
+    boundable1(p_boundable1),
+    boundable2(p_boundable2),
+    itemDistance(p_itemDistance)
 {
-	mDistance = distance();
+    mDistance = distance();
 }
 
-const Boundable* BoundablePair::getBoundable(int i) const {
-	if (i == 0)
-		return boundable1;
-	return boundable2;
+const Boundable*
+BoundablePair::getBoundable(int i) const
+{
+    if(i == 0) {
+        return boundable1;
+    }
+    return boundable2;
 }
 
-double BoundablePair::distance() const {
-	// if items, compute exact distance
-	if (isLeaves()) {
-		return itemDistance->distance((ItemBoundable*) boundable1, (ItemBoundable*) boundable2);
-	}
-
-	// otherwise compute distance between bounds of boundables
-	const geom::Envelope* e1 = (const geom::Envelope*) boundable1->getBounds();
-	const geom::Envelope* e2 = (const geom::Envelope*) boundable2->getBounds();
-
-	if (!e1 || !e2)
-		throw util::GEOSException("Can't compute envelope of item in BoundablePair");
-	return e1->distance(e2);
+double
+BoundablePair::distance() const
+{
+    // if items, compute exact distance
+    if(isLeaves()) {
+        return itemDistance->distance((ItemBoundable*) boundable1, (ItemBoundable*) boundable2);
+    }
+
+    // otherwise compute distance between bounds of boundables
+    const geom::Envelope* e1 = (const geom::Envelope*) boundable1->getBounds();
+    const geom::Envelope* e2 = (const geom::Envelope*) boundable2->getBounds();
+
+    if(!e1 || !e2) {
+        throw util::GEOSException("Can't compute envelope of item in BoundablePair");
+    }
+    return e1->distance(e2);
 }
 
-double BoundablePair::getDistance() const {
-	return mDistance;
+double
+BoundablePair::getDistance() const
+{
+    return mDistance;
 }
 
-bool BoundablePair::isLeaves() const {
-	return !(isComposite(boundable1) || isComposite(boundable2));
+bool
+BoundablePair::isLeaves() const
+{
+    return !(isComposite(boundable1) || isComposite(boundable2));
 }
 
-bool BoundablePair::isComposite(const Boundable* item) {
-	return dynamic_cast<const AbstractNode*>(item) != nullptr;
+bool
+BoundablePair::isComposite(const Boundable* item)
+{
+    return dynamic_cast<const AbstractNode*>(item) != nullptr;
 }
 
-double BoundablePair::area(const Boundable* b) {
-	return ((const geos::geom::Envelope*) b->getBounds())->getArea();
+double
+BoundablePair::area(const Boundable* b)
+{
+    return ((const geos::geom::Envelope*) b->getBounds())->getArea();
 }
 
-void BoundablePair::expandToQueue(BoundablePairQueue & priQ, double minDistance) {
-	bool isComp1 = isComposite(boundable1);
-	bool isComp2 = isComposite(boundable2);
-
-	/**
-	 * HEURISTIC: If both boundables are composite,
-	 * choose the one with largest area to expand.
-	 * Otherwise, simply expand whichever is composite.
-	 */
-	if (isComp1 && isComp2) {
-		if (area(boundable1) > area(boundable2)) {
-			expand(boundable1, boundable2, priQ, minDistance);
-			return;
-		} else {
-			expand(boundable2, boundable1, priQ, minDistance);
-			return;
-		}
-	}
-	else if (isComp1) {
-		expand(boundable1, boundable2, priQ, minDistance);
-		return;
-	}
-	else if (isComp2) {
-		expand(boundable2, boundable1, priQ, minDistance);
-		return;
-	}
-
-	throw geos::util::IllegalArgumentException("neither boundable is composite");
+void
+BoundablePair::expandToQueue(BoundablePairQueue& priQ, double minDistance)
+{
+    bool isComp1 = isComposite(boundable1);
+    bool isComp2 = isComposite(boundable2);
+
+    /**
+     * HEURISTIC: If both boundables are composite,
+     * choose the one with largest area to expand.
+     * Otherwise, simply expand whichever is composite.
+     */
+    if(isComp1 && isComp2) {
+        if(area(boundable1) > area(boundable2)) {
+            expand(boundable1, boundable2, priQ, minDistance);
+            return;
+        }
+        else {
+            expand(boundable2, boundable1, priQ, minDistance);
+            return;
+        }
+    }
+    else if(isComp1) {
+        expand(boundable1, boundable2, priQ, minDistance);
+        return;
+    }
+    else if(isComp2) {
+        expand(boundable2, boundable1, priQ, minDistance);
+        return;
+    }
+
+    throw geos::util::IllegalArgumentException("neither boundable is composite");
 }
 
-void BoundablePair::expand(const Boundable* bndComposite, const Boundable* bndOther, BoundablePairQueue & priQ, double minDistance) {
-	std::vector<Boundable*> *children = ((AbstractNode*) bndComposite)->getChildBoundables();
-	for(std::vector<Boundable*>::iterator it = children->begin(); it != children->end(); ++it) {
-		Boundable* child = *it;
-		std::unique_ptr<BoundablePair> bp(new BoundablePair(child, bndOther, itemDistance));
-		if (minDistance == std::numeric_limits<double>::infinity() || bp->getDistance() < minDistance) {
-			priQ.push(bp.release());
-		}
-	}
+void
+BoundablePair::expand(const Boundable* bndComposite, const Boundable* bndOther, BoundablePairQueue& priQ,
+                      double minDistance)
+{
+    std::vector<Boundable*>* children = ((AbstractNode*) bndComposite)->getChildBoundables();
+    for(std::vector<Boundable*>::iterator it = children->begin(); it != children->end(); ++it) {
+        Boundable* child = *it;
+        std::unique_ptr<BoundablePair> bp(new BoundablePair(child, bndOther, itemDistance));
+        if(minDistance == std::numeric_limits<double>::infinity() || bp->getDistance() < minDistance) {
+            priQ.push(bp.release());
+        }
+    }
 }
 
 }
diff --git a/src/index/strtree/GeometryItemDistance.cpp b/src/index/strtree/GeometryItemDistance.cpp
index af446f0..aa0b91a 100644
--- a/src/index/strtree/GeometryItemDistance.cpp
+++ b/src/index/strtree/GeometryItemDistance.cpp
@@ -23,8 +23,10 @@
 using namespace geos::geom;
 using namespace geos::index::strtree;
 
-double GeometryItemDistance::distance(const ItemBoundable* item1, const ItemBoundable* item2) {
-	const Geometry* g1 = (Geometry*) item1->getItem();
-	const Geometry* g2 = (Geometry*) item2->getItem();
-	return g1->distance(g2);
+double
+GeometryItemDistance::distance(const ItemBoundable* item1, const ItemBoundable* item2)
+{
+    const Geometry* g1 = (Geometry*) item1->getItem();
+    const Geometry* g2 = (Geometry*) item2->getItem();
+    return g1->distance(g2);
 }
diff --git a/src/index/strtree/Interval.cpp b/src/index/strtree/Interval.cpp
index 0f2d28a..350bf33 100644
--- a/src/index/strtree/Interval.cpp
+++ b/src/index/strtree/Interval.cpp
@@ -26,36 +26,37 @@ namespace geos {
 namespace index { // geos.index
 namespace strtree { // geos.index.strtree
 
-Interval::Interval(double newMin,double newMax)
+Interval::Interval(double newMin, double newMax)
 {
-	assert(newMin<=newMax);
-	imin=newMin;
-	imax=newMax;
+    assert(newMin <= newMax);
+    imin = newMin;
+    imax = newMax;
 }
 
 double
 Interval::getCentre()
 {
-	return (imin+imax)/2;
+    return (imin + imax) / 2;
 }
 
 Interval*
-Interval::expandToInclude(const Interval *other)
+Interval::expandToInclude(const Interval* other)
 {
-	imax=max(imax,other->imax);
-	imin=min(imin,other->imin);
-	return this;
+    imax = max(imax, other->imax);
+    imin = min(imin, other->imin);
+    return this;
 }
 
 bool
-Interval::intersects(const Interval *other) const
+Interval::intersects(const Interval* other) const
 {
-	return !(other->imin>imax || other->imax<imin);
+    return !(other->imin > imax || other->imax < imin);
 }
 
 bool
-Interval::equals(const Interval *other) const {
-	return imin==other->imin && imax==other->imax;
+Interval::equals(const Interval* other) const
+{
+    return imin == other->imin && imax == other->imax;
 }
 
 } // namespace geos.index.strtree
diff --git a/src/index/strtree/ItemBoundable.cpp b/src/index/strtree/ItemBoundable.cpp
index 64835ca..4726625 100644
--- a/src/index/strtree/ItemBoundable.cpp
+++ b/src/index/strtree/ItemBoundable.cpp
@@ -25,12 +25,15 @@ ItemBoundable::ItemBoundable(const void* newBounds, void* newItem) :
 }
 
 const void*
-ItemBoundable::getBounds() const {
-	return bounds;
+ItemBoundable::getBounds() const
+{
+    return bounds;
 }
 
-void* ItemBoundable::getItem() const {
-	return item;
+void*
+ItemBoundable::getItem() const
+{
+    return item;
 }
 
 } // namespace geos.index.strtree
diff --git a/src/index/strtree/SIRtree.cpp b/src/index/strtree/SIRtree.cpp
index 06343e2..4e4981c 100644
--- a/src/index/strtree/SIRtree.cpp
+++ b/src/index/strtree/SIRtree.cpp
@@ -28,118 +28,123 @@ namespace geos {
 namespace index { // geos.index
 namespace strtree { // geos.index.strtree
 
-static bool compareSIRBoundables(Boundable *a, Boundable *b){
-	return AbstractSTRtree::compareDoubles(((Interval*)a->getBounds())->getCentre(),((Interval*)b->getBounds())->getCentre());
+static bool
+compareSIRBoundables(Boundable* a, Boundable* b)
+{
+    return AbstractSTRtree::compareDoubles(((Interval*)a->getBounds())->getCentre(),
+                                           ((Interval*)b->getBounds())->getCentre());
 }
 
 /*protected*/
 std::unique_ptr<BoundableList>
-SIRtree::createParentBoundables(BoundableList *childBoundables,int newLevel)
+SIRtree::createParentBoundables(BoundableList* childBoundables, int newLevel)
 {
-	assert(!childBoundables->empty());
-	std::unique_ptr<BoundableList> parentBoundables ( new BoundableList() );
-	parentBoundables->push_back(createNode(newLevel));
-
-	std::unique_ptr<BoundableList> sortedChildBoundables ( sortBoundables(childBoundables) );
-
-	//for(unsigned int i=0;i<sortedChildBoundables->size();i++)
-	for (BoundableList::iterator i=sortedChildBoundables->begin(),
-			e=sortedChildBoundables->end();
-			i!=e; ++i)
-	{
-		//Boundable *childBoundable=(AbstractNode*)(*sortedChildBoundables)[i];
-		Boundable *childBoundable=*i;
-		AbstractNode* lNode = lastNode(parentBoundables.get());
-		if (lNode->getChildBoundables()->size() == nodeCapacity)
-		{
-			parentBoundables->push_back(createNode(newLevel));
-		}
-		lNode->addChildBoundable(childBoundable);
-	}
-	return parentBoundables;
+    assert(!childBoundables->empty());
+    std::unique_ptr<BoundableList> parentBoundables(new BoundableList());
+    parentBoundables->push_back(createNode(newLevel));
+
+    std::unique_ptr<BoundableList> sortedChildBoundables(sortBoundables(childBoundables));
+
+    //for(unsigned int i=0;i<sortedChildBoundables->size();i++)
+    for(BoundableList::iterator i = sortedChildBoundables->begin(),
+            e = sortedChildBoundables->end();
+            i != e; ++i) {
+        //Boundable *childBoundable=(AbstractNode*)(*sortedChildBoundables)[i];
+        Boundable* childBoundable = *i;
+        AbstractNode* lNode = lastNode(parentBoundables.get());
+        if(lNode->getChildBoundables()->size() == nodeCapacity) {
+            parentBoundables->push_back(createNode(newLevel));
+        }
+        lNode->addChildBoundable(childBoundable);
+    }
+    return parentBoundables;
 }
 
 bool
 SIRtree::SIRIntersectsOp::intersects(const void* aBounds, const void* bBounds)
 {
-	return ((Interval*)aBounds)->intersects((Interval*)bBounds);
+    return ((Interval*)aBounds)->intersects((Interval*)bBounds);
 }
 
 /*public*/
 SIRtree::SIRtree():
-	AbstractSTRtree(10),
-	intersectsOp(new SIRIntersectsOp())
+    AbstractSTRtree(10),
+    intersectsOp(new SIRIntersectsOp())
 {
 }
 
 /*public*/
 SIRtree::SIRtree(size_t p_nodeCapacity):
-	AbstractSTRtree(p_nodeCapacity),
-	intersectsOp(new SIRIntersectsOp())
+    AbstractSTRtree(p_nodeCapacity),
+    intersectsOp(new SIRIntersectsOp())
 {
 }
 
-SIRtree::~SIRtree() {
-	delete intersectsOp;
+SIRtree::~SIRtree()
+{
+    delete intersectsOp;
 }
 
 
 class SIRAbstractNode: public AbstractNode {
 public:
-	SIRAbstractNode(int p_level, size_t capacity)
-		:
-		AbstractNode(p_level, capacity)
-	{}
+    SIRAbstractNode(int p_level, size_t capacity)
+        :
+        AbstractNode(p_level, capacity)
+    {}
 
-	~SIRAbstractNode() override
-	{
-		delete (Interval *)bounds;
-	}
+    ~SIRAbstractNode() override
+    {
+        delete(Interval*)bounds;
+    }
 
 protected:
 
-	void* computeBounds() const override
-	{
-		Interval* p_bounds=nullptr;
-		const BoundableList& b = *getChildBoundables();
-		for(unsigned int i=0; i<b.size(); ++i)
-		{
-			const Boundable* childBoundable=b[i];
-			if (p_bounds==nullptr) {
-				p_bounds=new Interval(*((Interval*)childBoundable->getBounds()));
-			} else {
-				p_bounds->expandToInclude((Interval*)childBoundable->getBounds());
-			}
-		}
-		return p_bounds;
-	}
+    void*
+    computeBounds() const override
+    {
+        Interval* p_bounds = nullptr;
+        const BoundableList& b = *getChildBoundables();
+        for(unsigned int i = 0; i < b.size(); ++i) {
+            const Boundable* childBoundable = b[i];
+            if(p_bounds == nullptr) {
+                p_bounds = new Interval(*((Interval*)childBoundable->getBounds()));
+            }
+            else {
+                p_bounds->expandToInclude((Interval*)childBoundable->getBounds());
+            }
+        }
+        return p_bounds;
+    }
 
 };
 
 AbstractNode*
 SIRtree::createNode(int level)
 {
-	AbstractNode *an = new SIRAbstractNode(level, nodeCapacity);
-	nodes->push_back(an);
-	return an;
+    AbstractNode* an = new SIRAbstractNode(level, nodeCapacity);
+    nodes->push_back(an);
+    return an;
 }
 
 /**
 * Inserts an item having the given bounds into the tree.
 */
-void SIRtree::insert(double x1, double x2, void* item) {
-	std::unique_ptr<Interval> i{new Interval(std::min(x1,x2), std::max(x1, x2))};
-	AbstractSTRtree::insert(i.get(), item);
-	intervals.push_back(std::move(i));
+void
+SIRtree::insert(double x1, double x2, void* item)
+{
+    std::unique_ptr<Interval> i{new Interval(std::min(x1, x2), std::max(x1, x2))};
+    AbstractSTRtree::insert(i.get(), item);
+    intervals.push_back(std::move(i));
 }
 
 std::unique_ptr<BoundableList>
 SIRtree::sortBoundables(const BoundableList* input)
 {
-	std::unique_ptr<BoundableList> output ( new BoundableList(*input) );
-	sort(output->begin(), output->end(), compareSIRBoundables);
-	//output->sort(compareSIRBoundables);
-	return output;
+    std::unique_ptr<BoundableList> output(new BoundableList(*input));
+    sort(output->begin(), output->end(), compareSIRBoundables);
+    //output->sort(compareSIRBoundables);
+    return output;
 }
 
 } // namespace geos.index.strtree
diff --git a/src/index/strtree/STRtree.cpp b/src/index/strtree/STRtree.cpp
index 80fa3c6..faaf29f 100644
--- a/src/index/strtree/STRtree.cpp
+++ b/src/index/strtree/STRtree.cpp
@@ -37,16 +37,17 @@ namespace index { // geos.index
 namespace strtree { // geos.index.strtree
 
 
-static bool yComparator(Boundable *a, Boundable *b)
+static bool
+yComparator(Boundable* a, Boundable* b)
 {
-	assert(a);
-	assert(b);
-	const void* aBounds = a->getBounds();
-	const void* bBounds = b->getBounds();
-	assert(aBounds);
-	assert(bBounds);
-	const Envelope* aEnv = static_cast<const Envelope*>(aBounds);
-	const Envelope* bEnv = static_cast<const Envelope*>(bBounds);
+    assert(a);
+    assert(b);
+    const void* aBounds = a->getBounds();
+    const void* bBounds = b->getBounds();
+    assert(aBounds);
+    assert(bBounds);
+    const Envelope* aEnv = static_cast<const Envelope*>(aBounds);
+    const Envelope* bEnv = static_cast<const Envelope*>(bBounds);
 
     // NOTE - mloskot:
     // The problem of instability is directly related to mathematical definition of
@@ -60,10 +61,10 @@ static bool yComparator(Boundable *a, Boundable *b)
     // For some very low values, this predicate does not fulfill this requiremnet,
 
     // NOTE - strk:
-	// It seems that the '<' comparison here gives unstable results.
-	// In particular, when inlines are on (for Envelope::getMinY and getMaxY)
-	// things are fine, but when they are off we can even get a memory corruption !!
-	//return STRtree::centreY(aEnv) < STRtree::centreY(bEnv);
+    // It seems that the '<' comparison here gives unstable results.
+    // In particular, when inlines are on (for Envelope::getMinY and getMaxY)
+    // things are fine, but when they are off we can even get a memory corruption !!
+    //return STRtree::centreY(aEnv) < STRtree::centreY(bEnv);
 
     // NOTE - mloskot:
     // This comparison does not answer if a is "lower" than b
@@ -78,7 +79,7 @@ static bool yComparator(Boundable *a, Boundable *b)
       See xutility around line 320:
 
       	bool __CLRCALL_OR_CDECL _Debug_lt_pred(_Pr _Pred, _Ty1& _Left, _Ty2& _Right,
-		const wchar_t *_Where, unsigned int _Line)*/
+    	const wchar_t *_Where, unsigned int _Line)*/
 
     //return std::fabs( STRtree::centreY(aEnv) - STRtree::centreY(bEnv) ) < 1e-30
 
@@ -102,211 +103,225 @@ STRtree::~STRtree()
 bool
 STRtree::STRIntersectsOp::intersects(const void* aBounds, const void* bBounds)
 {
-	return ((Envelope*)aBounds)->intersects((Envelope*)bBounds);
+    return ((Envelope*)aBounds)->intersects((Envelope*)bBounds);
 }
 
 /*private*/
 std::unique_ptr<BoundableList>
 STRtree::createParentBoundables(BoundableList* childBoundables, int newLevel)
 {
-	assert(!childBoundables->empty());
-	int minLeafCount=(int) ceil((double)childBoundables->size()/(double)getNodeCapacity());
+    assert(!childBoundables->empty());
+    int minLeafCount = (int) ceil((double)childBoundables->size() / (double)getNodeCapacity());
 
-	std::unique_ptr<BoundableList> sortedChildBoundables ( sortBoundables(childBoundables) );
+    std::unique_ptr<BoundableList> sortedChildBoundables(sortBoundables(childBoundables));
 
-	std::unique_ptr< vector<BoundableList*> > verticalSlicesV (
-			verticalSlices(sortedChildBoundables.get(), (int)ceil(sqrt((double)minLeafCount)))
-			);
+    std::unique_ptr< vector<BoundableList*> > verticalSlicesV(
+        verticalSlices(sortedChildBoundables.get(), (int)ceil(sqrt((double)minLeafCount)))
+    );
 
-	std::unique_ptr<BoundableList> ret (
-		createParentBoundablesFromVerticalSlices(verticalSlicesV.get(), newLevel)
-	);
-	for (size_t i=0, vssize=verticalSlicesV->size(); i<vssize; ++i)
-	{
-		BoundableList* inner = (*verticalSlicesV)[i];
-		delete inner;
-	}
+    std::unique_ptr<BoundableList> ret(
+        createParentBoundablesFromVerticalSlices(verticalSlicesV.get(), newLevel)
+    );
+    for(size_t i = 0, vssize = verticalSlicesV->size(); i < vssize; ++i) {
+        BoundableList* inner = (*verticalSlicesV)[i];
+        delete inner;
+    }
 
-	return ret;
+    return ret;
 }
 
 /*private*/
 std::unique_ptr<BoundableList>
 STRtree::createParentBoundablesFromVerticalSlices(std::vector<BoundableList*>* p_verticalSlices, int newLevel)
 {
-	assert(!p_verticalSlices->empty());
-	std::unique_ptr<BoundableList> parentBoundables( new BoundableList() );
-
-	for (size_t i=0, vssize=p_verticalSlices->size(); i<vssize; ++i)
-	{
-		std::unique_ptr<BoundableList> toAdd (
-			createParentBoundablesFromVerticalSlice(
-				(*p_verticalSlices)[i], newLevel)
-			);
-		assert(!toAdd->empty());
-
-		parentBoundables->insert(
-				parentBoundables->end(),
-				toAdd->begin(),
-				toAdd->end());
-	}
-	return parentBoundables;
+    assert(!p_verticalSlices->empty());
+    std::unique_ptr<BoundableList> parentBoundables(new BoundableList());
+
+    for(size_t i = 0, vssize = p_verticalSlices->size(); i < vssize; ++i) {
+        std::unique_ptr<BoundableList> toAdd(
+            createParentBoundablesFromVerticalSlice(
+                (*p_verticalSlices)[i], newLevel)
+        );
+        assert(!toAdd->empty());
+
+        parentBoundables->insert(
+            parentBoundables->end(),
+            toAdd->begin(),
+            toAdd->end());
+    }
+    return parentBoundables;
 }
 
 /*protected*/
 std::unique_ptr<BoundableList>
 STRtree::createParentBoundablesFromVerticalSlice(BoundableList* childBoundables, int newLevel)
 {
-	return AbstractSTRtree::createParentBoundables(childBoundables, newLevel);
+    return AbstractSTRtree::createParentBoundables(childBoundables, newLevel);
 }
 
 /*private*/
 std::vector<BoundableList*>*
 STRtree::verticalSlices(BoundableList* childBoundables, size_t sliceCount)
 {
-	size_t sliceCapacity = (size_t) ceil((double)childBoundables->size() / (double) sliceCount);
-	vector<BoundableList*>* slices = new vector<BoundableList*>(sliceCount);
-
-	size_t i=0, nchilds=childBoundables->size();
-
-	for (size_t j=0; j<sliceCount; j++)
-	{
-		(*slices)[j]=new BoundableList();
-		(*slices)[j]->reserve(sliceCapacity);
-		size_t boundablesAddedToSlice = 0;
-		while (i<nchilds && boundablesAddedToSlice<sliceCapacity)
-		{
-			Boundable *childBoundable=(*childBoundables)[i];
-			++i;
-			(*slices)[j]->push_back(childBoundable);
-			++boundablesAddedToSlice;
-		}
-	}
-	return slices;
+    size_t sliceCapacity = (size_t) ceil((double)childBoundables->size() / (double) sliceCount);
+    vector<BoundableList*>* slices = new vector<BoundableList*>(sliceCount);
+
+    size_t i = 0, nchilds = childBoundables->size();
+
+    for(size_t j = 0; j < sliceCount; j++) {
+        (*slices)[j] = new BoundableList();
+        (*slices)[j]->reserve(sliceCapacity);
+        size_t boundablesAddedToSlice = 0;
+        while(i < nchilds && boundablesAddedToSlice < sliceCapacity) {
+            Boundable* childBoundable = (*childBoundables)[i];
+            ++i;
+            (*slices)[j]->push_back(childBoundable);
+            ++boundablesAddedToSlice;
+        }
+    }
+    return slices;
 }
 
 /*public*/
-const void* STRtree::nearestNeighbour(const Envelope* env, const void* item, ItemDistance* itemDist) {
-	build();
+const void*
+STRtree::nearestNeighbour(const Envelope* env, const void* item, ItemDistance* itemDist)
+{
+    build();
 
-	ItemBoundable bnd = ItemBoundable(env, (void*) item);
-	BoundablePair bp(getRoot(), &bnd, itemDist);
+    ItemBoundable bnd = ItemBoundable(env, (void*) item);
+    BoundablePair bp(getRoot(), &bnd, itemDist);
 
-	return nearestNeighbour(&bp).first;
+    return nearestNeighbour(&bp).first;
 }
 
-std::pair<const void*, const void*> STRtree::nearestNeighbour(BoundablePair* initBndPair) {
-	return nearestNeighbour(initBndPair, std::numeric_limits<double>::infinity());
+std::pair<const void*, const void*>
+STRtree::nearestNeighbour(BoundablePair* initBndPair)
+{
+    return nearestNeighbour(initBndPair, std::numeric_limits<double>::infinity());
 }
 
-std::pair<const void*, const void*> STRtree::nearestNeighbour(ItemDistance * itemDist) {
-	BoundablePair bp(this->getRoot(), this->getRoot(), itemDist);
-	return nearestNeighbour(&bp);
+std::pair<const void*, const void*>
+STRtree::nearestNeighbour(ItemDistance* itemDist)
+{
+    BoundablePair bp(this->getRoot(), this->getRoot(), itemDist);
+    return nearestNeighbour(&bp);
 }
 
-std::pair<const void*, const void*> STRtree::nearestNeighbour(STRtree* tree, ItemDistance* itemDist) {
-	BoundablePair bp(getRoot(), tree->getRoot(), itemDist);
-	return nearestNeighbour(&bp);
+std::pair<const void*, const void*>
+STRtree::nearestNeighbour(STRtree* tree, ItemDistance* itemDist)
+{
+    BoundablePair bp(getRoot(), tree->getRoot(), itemDist);
+    return nearestNeighbour(&bp);
 }
 
-std::pair<const void*, const void*> STRtree::nearestNeighbour(BoundablePair* initBndPair, double maxDistance) {
-	double distanceLowerBound = maxDistance;
-	BoundablePair* minPair = nullptr;
-
-	BoundablePair::BoundablePairQueue priQ;
-	priQ.push(initBndPair);
-
-	while(!priQ.empty() && distanceLowerBound > 0.0) {
-		BoundablePair* bndPair = priQ.top();
-		double currentDistance = bndPair->getDistance();
-
-		/**
-		 * If the distance for the first node in the queue
-		 * is >= the current minimum distance, all other nodes
-		 * in the queue must also have a greater distance.
-		 * So the current minDistance must be the true minimum,
-		 * and we are done.
-		 */
-		if (minPair && currentDistance >= distanceLowerBound)
-			break;
-
-		priQ.pop();
-
-		/**
-		 * If the pair members are leaves
-		 * then their distance is the exact lower bound.
-		 * Update the distanceLowerBound to reflect this
-		 * (which must be smaller, due to the test
-		 * immediately prior to this).
-		 */
-		if (bndPair->isLeaves()) {
-			distanceLowerBound = currentDistance;
-			minPair = bndPair;
-		} else {
-			/**
-			 * Otherwise, expand one side of the pair,
-			 * (the choice of which side to expand is heuristically determined)
-			 * and insert the new expanded pairs into the queue
-			 */
-			bndPair->expandToQueue(priQ, distanceLowerBound);
-		}
-
-		if (bndPair != initBndPair && bndPair != minPair)
+std::pair<const void*, const void*>
+STRtree::nearestNeighbour(BoundablePair* initBndPair, double maxDistance)
+{
+    double distanceLowerBound = maxDistance;
+    BoundablePair* minPair = nullptr;
+
+    BoundablePair::BoundablePairQueue priQ;
+    priQ.push(initBndPair);
+
+    while(!priQ.empty() && distanceLowerBound > 0.0) {
+        BoundablePair* bndPair = priQ.top();
+        double currentDistance = bndPair->getDistance();
+
+        /**
+         * If the distance for the first node in the queue
+         * is >= the current minimum distance, all other nodes
+         * in the queue must also have a greater distance.
+         * So the current minDistance must be the true minimum,
+         * and we are done.
+         */
+        if(minPair && currentDistance >= distanceLowerBound) {
+            break;
+        }
+
+        priQ.pop();
+
+        /**
+         * If the pair members are leaves
+         * then their distance is the exact lower bound.
+         * Update the distanceLowerBound to reflect this
+         * (which must be smaller, due to the test
+         * immediately prior to this).
+         */
+        if(bndPair->isLeaves()) {
+            distanceLowerBound = currentDistance;
+            minPair = bndPair;
+        }
+        else {
+            /**
+             * Otherwise, expand one side of the pair,
+             * (the choice of which side to expand is heuristically determined)
+             * and insert the new expanded pairs into the queue
+             */
+            bndPair->expandToQueue(priQ, distanceLowerBound);
+        }
+
+        if(bndPair != initBndPair && bndPair != minPair) {
             delete bndPair;
-	}
-
-	/* Free any remaining BoundablePairs in the queue */
-	while(!priQ.empty()) {
-		BoundablePair* bndPair = priQ.top();
-		priQ.pop();
-		if (bndPair != initBndPair)
+        }
+    }
+
+    /* Free any remaining BoundablePairs in the queue */
+    while(!priQ.empty()) {
+        BoundablePair* bndPair = priQ.top();
+        priQ.pop();
+        if(bndPair != initBndPair) {
             delete bndPair;
-	}
+        }
+    }
 
-	if (!minPair)
-		throw util::GEOSException("Error computing nearest neighbor");
+    if(!minPair) {
+        throw util::GEOSException("Error computing nearest neighbor");
+    }
 
-	const void* item0 = dynamic_cast<const ItemBoundable*>(minPair->getBoundable(0))->getItem();
-	const void* item1 = dynamic_cast<const ItemBoundable*>(minPair->getBoundable(1))->getItem();
-	if (minPair != initBndPair)
+    const void* item0 = dynamic_cast<const ItemBoundable*>(minPair->getBoundable(0))->getItem();
+    const void* item1 = dynamic_cast<const ItemBoundable*>(minPair->getBoundable(1))->getItem();
+    if(minPair != initBndPair) {
         delete minPair;
+    }
 
-	return std::pair<const void*, const void*>(item0, item1);
+    return std::pair<const void*, const void*>(item0, item1);
 }
 
-class STRAbstractNode: public AbstractNode{
+class STRAbstractNode: public AbstractNode {
 public:
 
-	STRAbstractNode(int p_level, size_t capacity)
-		:
-		AbstractNode(p_level, capacity)
-	{}
+    STRAbstractNode(int p_level, size_t capacity)
+        :
+        AbstractNode(p_level, capacity)
+    {}
 
-	~STRAbstractNode() override
-	{
-		delete (Envelope *)bounds;
-	}
+    ~STRAbstractNode() override
+    {
+        delete(Envelope*)bounds;
+    }
 
 protected:
 
-	void* computeBounds() const override
-	{
-		Envelope* p_bounds=nullptr;
-		const BoundableList& b = *getChildBoundables();
+    void*
+    computeBounds() const override
+    {
+        Envelope* p_bounds = nullptr;
+        const BoundableList& b = *getChildBoundables();
 
-		if ( b.empty() ) return nullptr;
+        if(b.empty()) {
+            return nullptr;
+        }
 
-		BoundableList::const_iterator i=b.begin();
-		BoundableList::const_iterator e=b.end();
+        BoundableList::const_iterator i = b.begin();
+        BoundableList::const_iterator e = b.end();
 
-		p_bounds=new Envelope(* static_cast<const Envelope*>((*i)->getBounds()) );
-		for(; i!=e; ++i)
-		{
-			const Boundable* childBoundable=*i;
-			p_bounds->expandToInclude((Envelope*)childBoundable->getBounds());
-		}
-		return p_bounds;
-	}
+        p_bounds = new Envelope(* static_cast<const Envelope*>((*i)->getBounds()));
+        for(; i != e; ++i) {
+            const Boundable* childBoundable = *i;
+            p_bounds->expandToInclude((Envelope*)childBoundable->getBounds());
+        }
+        return p_bounds;
+    }
 
 };
 
@@ -314,29 +329,31 @@ protected:
 AbstractNode*
 STRtree::createNode(int level)
 {
-	AbstractNode *an = new STRAbstractNode(level, nodeCapacity);
-	nodes->push_back(an);
-	return an;
+    AbstractNode* an = new STRAbstractNode(level, nodeCapacity);
+    nodes->push_back(an);
+    return an;
 }
 
 /*public*/
 void
-STRtree::insert(const Envelope *itemEnv, void* item)
+STRtree::insert(const Envelope* itemEnv, void* item)
 {
-	if (itemEnv->isNull()) { return; }
-	AbstractSTRtree::insert(itemEnv, item);
+    if(itemEnv->isNull()) {
+        return;
+    }
+    AbstractSTRtree::insert(itemEnv, item);
 }
 
 /*private*/
 std::unique_ptr<BoundableList>
 STRtree::sortBoundables(const BoundableList* input)
 {
-	assert(input);
-	std::unique_ptr<BoundableList> output ( new BoundableList(*input) );
-	assert(output->size() == input->size());
+    assert(input);
+    std::unique_ptr<BoundableList> output(new BoundableList(*input));
+    assert(output->size() == input->size());
 
-	sort(output->begin(), output->end(), yComparator);
-	return output;
+    sort(output->begin(), output->end(), yComparator);
+    return output;
 }
 
 } // namespace geos.index.strtree
diff --git a/src/index/sweepline/SweepLineEvent.cpp b/src/index/sweepline/SweepLineEvent.cpp
index 6e9aeb9..3d0256a 100644
--- a/src/index/sweepline/SweepLineEvent.cpp
+++ b/src/index/sweepline/SweepLineEvent.cpp
@@ -19,84 +19,103 @@ namespace geos {
 namespace index { // geos.index
 namespace sweepline { // geos.index.sweepline
 
-SweepLineEvent::SweepLineEvent(double x, SweepLineEvent *newInsertEvent,
-		SweepLineInterval *newSweepInt)
-	:
-	xValue(x),
-	eventType(SweepLineEvent::INSERT_EVENT),
-	insertEvent(newInsertEvent),
-	sweepInt(newSweepInt)
+SweepLineEvent::SweepLineEvent(double x, SweepLineEvent* newInsertEvent,
+                               SweepLineInterval* newSweepInt)
+    :
+    xValue(x),
+    eventType(SweepLineEvent::INSERT_EVENT),
+    insertEvent(newInsertEvent),
+    sweepInt(newSweepInt)
 {
-	if (insertEvent!=nullptr)
-		eventType=SweepLineEvent::DELETE_EVENT;
+    if(insertEvent != nullptr) {
+        eventType = SweepLineEvent::DELETE_EVENT;
+    }
 }
 
 bool
 SweepLineEvent::isInsert()
 {
-	return insertEvent==nullptr;
+    return insertEvent == nullptr;
 }
 
 bool
 SweepLineEvent::isDelete()
 {
-	return insertEvent!=nullptr;
+    return insertEvent != nullptr;
 }
 
 SweepLineEvent*
 SweepLineEvent::getInsertEvent()
 {
-	return insertEvent;
+    return insertEvent;
 }
 
 size_t
 SweepLineEvent::getDeleteEventIndex()
 {
-	return deleteEventIndex;
+    return deleteEventIndex;
 }
 
 void
 SweepLineEvent::setDeleteEventIndex(size_t newDeleteEventIndex)
 {
-	deleteEventIndex=newDeleteEventIndex;
+    deleteEventIndex = newDeleteEventIndex;
 }
 
 SweepLineInterval*
 SweepLineEvent::getInterval()
 {
-	return sweepInt;
+    return sweepInt;
 }
 
 int
-SweepLineEvent::compareTo(const SweepLineEvent *pe) const
+SweepLineEvent::compareTo(const SweepLineEvent* pe) const
 {
-	if (xValue<pe->xValue) return -1;
-	if (xValue>pe->xValue) return 1;
-	if (eventType<pe->eventType) return -1;
-	if (eventType>pe->eventType) return 1;
-	return 0;
+    if(xValue < pe->xValue) {
+        return -1;
+    }
+    if(xValue > pe->xValue) {
+        return 1;
+    }
+    if(eventType < pe->eventType) {
+        return -1;
+    }
+    if(eventType > pe->eventType) {
+        return 1;
+    }
+    return 0;
 }
 
 #if 0
 int
-SweepLineEvent::compareTo(void *o) const
+SweepLineEvent::compareTo(void* o) const
 {
-	SweepLineEvent *pe=(SweepLineEvent*) o;
-	if (xValue<pe->xValue) return -1;
-	if (xValue>pe->xValue) return 1;
-	if (eventType<pe->eventType) return -1;
-	if (eventType>pe->eventType) return 1;
-	return 0;
+    SweepLineEvent* pe = (SweepLineEvent*) o;
+    if(xValue < pe->xValue) {
+        return -1;
+    }
+    if(xValue > pe->xValue) {
+        return 1;
+    }
+    if(eventType < pe->eventType) {
+        return -1;
+    }
+    if(eventType > pe->eventType) {
+        return 1;
+    }
+    return 0;
 }
 #endif // 0
 
 bool
-SweepLineEventLessThen::operator() (const SweepLineEvent *first, const SweepLineEvent *second) const
+SweepLineEventLessThen::operator()(const SweepLineEvent* first, const SweepLineEvent* second) const
 {
-	if (first->compareTo(second)<0)
-		return true;
-	else
-		return false;
+    if(first->compareTo(second) < 0) {
+        return true;
+    }
+    else {
+        return false;
+    }
 }
 
 
diff --git a/src/index/sweepline/SweepLineIndex.cpp b/src/index/sweepline/SweepLineIndex.cpp
index 33db463..6dabf8e 100644
--- a/src/index/sweepline/SweepLineIndex.cpp
+++ b/src/index/sweepline/SweepLineIndex.cpp
@@ -27,41 +27,38 @@ namespace index { // geos.index
 namespace sweepline { // geos.index.sweepline
 
 SweepLineIndex::SweepLineIndex()
-	:
-	indexBuilt(false),
-	nOverlaps(0)
+    :
+    indexBuilt(false),
+    nOverlaps(0)
 {
-	//events=new vector<SweepLineEvent*>();
-	//nOverlaps=0;
+    //events=new vector<SweepLineEvent*>();
+    //nOverlaps=0;
 }
 
 SweepLineIndex::~SweepLineIndex()
 {
-	//delete events;
+    //delete events;
 }
 
 void
-SweepLineIndex::add(SweepLineInterval *sweepInt)
+SweepLineIndex::add(SweepLineInterval* sweepInt)
 {
-	// FIXME: who's going to delete the newly-created events ?
-	SweepLineEvent *insertEvent=new SweepLineEvent(sweepInt->getMin(),nullptr,sweepInt);
-	events.push_back(insertEvent);
-	events.push_back(new SweepLineEvent(sweepInt->getMax(), insertEvent, sweepInt));
+    // FIXME: who's going to delete the newly-created events ?
+    SweepLineEvent* insertEvent = new SweepLineEvent(sweepInt->getMin(), nullptr, sweepInt);
+    events.push_back(insertEvent);
+    events.push_back(new SweepLineEvent(sweepInt->getMax(), insertEvent, sweepInt));
 }
 
 /*private*/
 void
 SweepLineIndex::buildIndex()
 {
-    if (!indexBuilt)
-    {
+    if(!indexBuilt) {
         sort(events.begin(), events.end(), SweepLineEventLessThen());
         const std::vector<SweepLineEvent*>::size_type n = events.size();
-        for(std::vector<SweepLineEvent*>::size_type i = 0; i < n; i++)
-        {
-            SweepLineEvent *ev=events[i];
-            if (ev->isDelete())
-            {
+        for(std::vector<SweepLineEvent*>::size_type i = 0; i < n; i++) {
+            SweepLineEvent* ev = events[i];
+            if(ev->isDelete()) {
                 ev->getInsertEvent()->setDeleteEventIndex(i);
             }
         }
@@ -70,43 +67,40 @@ SweepLineIndex::buildIndex()
 }
 
 void
-SweepLineIndex::computeOverlaps(SweepLineOverlapAction *action)
+SweepLineIndex::computeOverlaps(SweepLineOverlapAction* action)
 {
     nOverlaps = 0;
 
     buildIndex();
 
-    const std::vector<SweepLineEvent*>::size_type n=events.size();
-    for(size_t i = 0; i < n; i++)
-    {
-        SweepLineEvent *ev=events[i];
-        if (ev->isInsert())
-        {
+    const std::vector<SweepLineEvent*>::size_type n = events.size();
+    for(size_t i = 0; i < n; i++) {
+        SweepLineEvent* ev = events[i];
+        if(ev->isInsert()) {
             processOverlaps(i,
-                ev->getDeleteEventIndex(),
-                ev->getInterval(), action);
+                            ev->getDeleteEventIndex(),
+                            ev->getInterval(), action);
         }
     }
 }
 
 void
 SweepLineIndex::processOverlaps(size_t start, size_t end,
-		SweepLineInterval *s0, SweepLineOverlapAction *action)
+                                SweepLineInterval* s0, SweepLineOverlapAction* action)
 {
-	/**
-	 * Since we might need to test for self-intersections,
-	 * include current insert event object in list of event objects to test.
-	 * Last index can be skipped, because it must be a Delete event.
-	 */
-	for(auto i = start; i < end; i++)
-	{
-		SweepLineEvent *ev=events[i];
-		if (ev->isInsert()) {
-			SweepLineInterval *s1=ev->getInterval();
-			action->overlap(s0,s1);
-			nOverlaps++;
-		}
-	}
+    /**
+     * Since we might need to test for self-intersections,
+     * include current insert event object in list of event objects to test.
+     * Last index can be skipped, because it must be a Delete event.
+     */
+    for(auto i = start; i < end; i++) {
+        SweepLineEvent* ev = events[i];
+        if(ev->isInsert()) {
+            SweepLineInterval* s1 = ev->getInterval();
+            action->overlap(s0, s1);
+            nOverlaps++;
+        }
+    }
 }
 
 } // namespace geos.index.sweepline
diff --git a/src/index/sweepline/SweepLineInterval.cpp b/src/index/sweepline/SweepLineInterval.cpp
index 8dcc2a2..a05dfbe 100644
--- a/src/index/sweepline/SweepLineInterval.cpp
+++ b/src/index/sweepline/SweepLineInterval.cpp
@@ -21,27 +21,27 @@ namespace sweepline { // geos.index.sweepline
 
 SweepLineInterval::SweepLineInterval(double newMin, double newMax, void* newItem)
 {
-	min=newMin<newMax?newMin:newMax;
-	max=newMax>newMin?newMax:newMin;
-	item=newItem;
+    min = newMin < newMax ? newMin : newMax;
+    max = newMax > newMin ? newMax : newMin;
+    item = newItem;
 }
 
 double
 SweepLineInterval::getMin()
 {
-	return min;
+    return min;
 }
 
 double
 SweepLineInterval::getMax()
 {
-	return max;
+    return max;
 }
 
 void*
 SweepLineInterval::getItem()
 {
-	return item;
+    return item;
 }
 
 } // namespace geos.index.sweepline
diff --git a/src/io/ByteOrderValues.cpp b/src/io/ByteOrderValues.cpp
index c5be5b4..8b3f8da 100644
--- a/src/io/ByteOrderValues.cpp
+++ b/src/io/ByteOrderValues.cpp
@@ -32,130 +32,123 @@ namespace geos {
 namespace io { // geos.io
 
 int
-ByteOrderValues::getInt(const unsigned char *buf, int byteOrder)
+ByteOrderValues::getInt(const unsigned char* buf, int byteOrder)
 {
-	if ( byteOrder == ENDIAN_BIG )
-	{
-		return  ((int) (buf[0]&0xff) <<24) |
-			((int) (buf[1]&0xff) <<16) |
-			((int) (buf[2]&0xff) <<8) |
-			((int) (buf[3]&0xff) );
-	}
-	else // ENDIAN_LITTLE
-	{
-		assert(byteOrder == ENDIAN_LITTLE);
+    if(byteOrder == ENDIAN_BIG) {
+        return ((int)(buf[0] & 0xff) << 24) |
+               ((int)(buf[1] & 0xff) << 16) |
+               ((int)(buf[2] & 0xff) << 8) |
+               ((int)(buf[3] & 0xff));
+    }
+    else { // ENDIAN_LITTLE
+        assert(byteOrder == ENDIAN_LITTLE);
 
-		return  ((int) (buf[3]&0xff) <<24) |
-			((int) (buf[2]&0xff) <<16) |
-			((int) (buf[1]&0xff) <<8) |
-			((int) (buf[0]&0xff) );
-	}
+        return ((int)(buf[3] & 0xff) << 24) |
+               ((int)(buf[2] & 0xff) << 16) |
+               ((int)(buf[1] & 0xff) << 8) |
+               ((int)(buf[0] & 0xff));
+    }
 }
 
 void
-ByteOrderValues::putInt(int intValue, unsigned char *buf, int byteOrder)
+ByteOrderValues::putInt(int intValue, unsigned char* buf, int byteOrder)
 {
-	if ( byteOrder == ENDIAN_BIG )
-	{
-		buf[0] = (unsigned char)(intValue >> 24);
-		buf[1] = (unsigned char)(intValue >> 16);
-		buf[2] = (unsigned char)(intValue >> 8);
-		buf[3] = (unsigned char) intValue;
-	}
-	else // ENDIAN_LITTLE
-	{
-		assert(byteOrder == ENDIAN_LITTLE);
+    if(byteOrder == ENDIAN_BIG) {
+        buf[0] = (unsigned char)(intValue >> 24);
+        buf[1] = (unsigned char)(intValue >> 16);
+        buf[2] = (unsigned char)(intValue >> 8);
+        buf[3] = (unsigned char) intValue;
+    }
+    else { // ENDIAN_LITTLE
+        assert(byteOrder == ENDIAN_LITTLE);
 
-		buf[3] = (unsigned char)(intValue >> 24);
-		buf[2] = (unsigned char)(intValue >> 16);
-		buf[1] = (unsigned char)(intValue >> 8);
-		buf[0] = (unsigned char) intValue;
-	}
+        buf[3] = (unsigned char)(intValue >> 24);
+        buf[2] = (unsigned char)(intValue >> 16);
+        buf[1] = (unsigned char)(intValue >> 8);
+        buf[0] = (unsigned char) intValue;
+    }
 }
 
 int64
-ByteOrderValues::getLong(const unsigned char *buf, int byteOrder)
+ByteOrderValues::getLong(const unsigned char* buf, int byteOrder)
 {
-	if ( byteOrder == ENDIAN_BIG )
-	{
-		return
-			(int64) (buf[0]) << 56
-			| (int64) (buf[1] & 0xff) << 48
-			| (int64) (buf[2] & 0xff) << 40
-			| (int64) (buf[3] & 0xff) << 32
-			| (int64) (buf[4] & 0xff) << 24
-			| (int64) (buf[5] & 0xff) << 16
-			| (int64) (buf[6] & 0xff) <<  8
-			| (int64) (buf[7] & 0xff);
-	}
-	else // ENDIAN_LITTLE
-	{
-		assert(byteOrder == ENDIAN_LITTLE);
+    if(byteOrder == ENDIAN_BIG) {
+        return
+            (int64)(buf[0]) << 56
+            | (int64)(buf[1] & 0xff) << 48
+            | (int64)(buf[2] & 0xff) << 40
+            | (int64)(buf[3] & 0xff) << 32
+            | (int64)(buf[4] & 0xff) << 24
+            | (int64)(buf[5] & 0xff) << 16
+            | (int64)(buf[6] & 0xff) <<  8
+            | (int64)(buf[7] & 0xff);
+    }
+    else { // ENDIAN_LITTLE
+        assert(byteOrder == ENDIAN_LITTLE);
 
-		return
-			(int64) (buf[7]) << 56
-			| (int64) (buf[6] & 0xff) << 48
-			| (int64) (buf[5] & 0xff) << 40
-			| (int64) (buf[4] & 0xff) << 32
-			| (int64) (buf[3] & 0xff) << 24
-			| (int64) (buf[2] & 0xff) << 16
-			| (int64) (buf[1] & 0xff) <<  8
-			| (int64) (buf[0] & 0xff);
-	}
+        return
+            (int64)(buf[7]) << 56
+            | (int64)(buf[6] & 0xff) << 48
+            | (int64)(buf[5] & 0xff) << 40
+            | (int64)(buf[4] & 0xff) << 32
+            | (int64)(buf[3] & 0xff) << 24
+            | (int64)(buf[2] & 0xff) << 16
+            | (int64)(buf[1] & 0xff) <<  8
+            | (int64)(buf[0] & 0xff);
+    }
 }
 
 void
-ByteOrderValues::putLong(int64 longValue, unsigned char *buf, int byteOrder)
+ByteOrderValues::putLong(int64 longValue, unsigned char* buf, int byteOrder)
 {
-	if ( byteOrder == ENDIAN_BIG )
-	{
-		buf[0] = (unsigned char)(longValue >> 56);
-		buf[1] = (unsigned char)(longValue >> 48);
-		buf[2] = (unsigned char)(longValue >> 40);
-		buf[3] = (unsigned char)(longValue >> 32);
-		buf[4] = (unsigned char)(longValue >> 24);
-		buf[5] = (unsigned char)(longValue >> 16);
-		buf[6] = (unsigned char)(longValue >> 8);
-		buf[7] = (unsigned char) longValue;
-	}
-	else // ENDIAN_LITTLE
-	{
-		assert(byteOrder == ENDIAN_LITTLE);
+    if(byteOrder == ENDIAN_BIG) {
+        buf[0] = (unsigned char)(longValue >> 56);
+        buf[1] = (unsigned char)(longValue >> 48);
+        buf[2] = (unsigned char)(longValue >> 40);
+        buf[3] = (unsigned char)(longValue >> 32);
+        buf[4] = (unsigned char)(longValue >> 24);
+        buf[5] = (unsigned char)(longValue >> 16);
+        buf[6] = (unsigned char)(longValue >> 8);
+        buf[7] = (unsigned char) longValue;
+    }
+    else { // ENDIAN_LITTLE
+        assert(byteOrder == ENDIAN_LITTLE);
 
-		buf[0] = (unsigned char) longValue;
-		buf[1] = (unsigned char)(longValue >> 8);
-		buf[2] = (unsigned char)(longValue >> 16);
-		buf[3] = (unsigned char)(longValue >> 24);
-		buf[4] = (unsigned char)(longValue >> 32);
-		buf[5] = (unsigned char)(longValue >> 40);
-		buf[6] = (unsigned char)(longValue >> 48);
-		buf[7] = (unsigned char)(longValue >> 56);
-	}
+        buf[0] = (unsigned char) longValue;
+        buf[1] = (unsigned char)(longValue >> 8);
+        buf[2] = (unsigned char)(longValue >> 16);
+        buf[3] = (unsigned char)(longValue >> 24);
+        buf[4] = (unsigned char)(longValue >> 32);
+        buf[5] = (unsigned char)(longValue >> 40);
+        buf[6] = (unsigned char)(longValue >> 48);
+        buf[7] = (unsigned char)(longValue >> 56);
+    }
 }
 
 double
-ByteOrderValues::getDouble(const unsigned char *buf, int byteOrder)
+ByteOrderValues::getDouble(const unsigned char* buf, int byteOrder)
 {
-	int64 longValue = getLong(buf, byteOrder);
-	double ret;
+    int64 longValue = getLong(buf, byteOrder);
+    double ret;
     std::memcpy(&ret, &longValue, sizeof(double));
-	return ret;
+    return ret;
 }
 
 void
-ByteOrderValues::putDouble(double doubleValue, unsigned char *buf, int byteOrder)
+ByteOrderValues::putDouble(double doubleValue, unsigned char* buf, int byteOrder)
 {
-	int64 longValue;
+    int64 longValue;
     std::memcpy(&longValue, &doubleValue, sizeof(double));
 #if DEBUG_BYTEORDER_VALUES
-	std::cout<<"ByteOrderValues::putDouble("<<doubleValue<<
-		", order:"<<byteOrder
-		<<") = "<<std::hex;
-	for (int i=0; i<8; i++)
-		std::cout<<"["<<(int)buf[i]<<"]";
-	std::cout<<std::dec<<std::endl;
+    std::cout << "ByteOrderValues::putDouble(" << doubleValue <<
+              ", order:" << byteOrder
+              << ") = " << std::hex;
+    for(int i = 0; i < 8; i++) {
+        std::cout << "[" << (int)buf[i] << "]";
+    }
+    std::cout << std::dec << std::endl;
 #endif
-	putLong(longValue, buf, byteOrder);
+    putLong(longValue, buf, byteOrder);
 }
 
 } // namespace geos.io
diff --git a/src/io/CLocalizer.cpp b/src/io/CLocalizer.cpp
index bea037f..a93afcd 100644
--- a/src/io/CLocalizer.cpp
+++ b/src/io/CLocalizer.cpp
@@ -33,8 +33,7 @@ CLocalizer::CLocalizer()
     _configthreadlocale(_ENABLE_PER_THREAD_LOCALE);
 #endif
     char* p = std::setlocale(LC_NUMERIC, nullptr);
-    if (nullptr != p)
-    {
+    if(nullptr != p) {
         saved_locale = p;
     }
     std::setlocale(LC_NUMERIC, "C");
diff --git a/src/io/ParseException.cpp b/src/io/ParseException.cpp
index 69ef927..123d8ee 100644
--- a/src/io/ParseException.cpp
+++ b/src/io/ParseException.cpp
@@ -27,35 +27,35 @@ namespace geos {
 namespace io { // geos.io
 
 ParseException::ParseException()
-	:
-	GEOSException("ParseException", "")
+    :
+    GEOSException("ParseException", "")
 {
 }
 
 ParseException::ParseException(const string& msg)
-	:
-	GEOSException("ParseException", msg)
+    :
+    GEOSException("ParseException", msg)
 {
 }
 
 ParseException::ParseException(const string& msg, const string& var)
-	:
-	GEOSException("ParseException", msg+": '"+var+"'")
+    :
+    GEOSException("ParseException", msg + ": '" + var + "'")
 {
 }
 
 ParseException::ParseException(const string& msg, double num)
-	:
-	GEOSException("ParseException", msg+": '"+stringify(num)+"'")
+    :
+    GEOSException("ParseException", msg + ": '" + stringify(num) + "'")
 {
 }
 
 string
 ParseException::stringify(double num)
 {
-	stringstream ss;
-	ss<<num;
-	return ss.str();
+    stringstream ss;
+    ss << num;
+    return ss.str();
 }
 
 } // namespace geos.io
diff --git a/src/io/StringTokenizer.cpp b/src/io/StringTokenizer.cpp
index e3737ea..ecb0767 100644
--- a/src/io/StringTokenizer.cpp
+++ b/src/io/StringTokenizer.cpp
@@ -29,99 +29,105 @@ namespace geos {
 namespace io { // geos.io
 
 /*public*/
-StringTokenizer::StringTokenizer(const string &txt)
-	:
-	str(txt),
-	stok(""),
-	ntok(0.0)
+StringTokenizer::StringTokenizer(const string& txt)
+    :
+    str(txt),
+    stok(""),
+    ntok(0.0)
 {
-	iter=str.begin();
+    iter = str.begin();
 }
 
-double strtod_with_vc_fix(const char * str, char ** str_end)
+double
+strtod_with_vc_fix(const char* str, char** str_end)
 {
-	double dbl = strtod(str, str_end);
+    double dbl = strtod(str, str_end);
 #if _MSC_VER && !__INTEL_COMPILER
-	// Special handling of NAN and INF in MSVC, where strtod returns 0.0
-	// for NAN and INF.
-	// This fixes failing test GEOSisValidDetail::test<3>, maybe others
-	// as well.
-	// Note: this hack is not robust, Boost lexical_cast or
-	// std::stod (C++11) would be better.
-	if (*str_end[0] != '\0')
-	{
-		char sign = 0;
-		const char *pos = str;
-		if (*pos == '+' || *pos == '-')
-			sign = *pos++;
-
-		if (stricmp(pos, "inf") == 0)
-		{
-			if (!sign || sign == '+')
-				dbl = std::numeric_limits<double>::infinity();
-			else
-				dbl = -(std::numeric_limits<double>::infinity)();
-			*str_end[0] = '\0';
-		}
-		else if (stricmp(pos, "nan") == 0)
-		{
-			dbl = std::numeric_limits<double>::quiet_NaN();
-			*str_end[0] = '\0';
-		}
-	}
+    // Special handling of NAN and INF in MSVC, where strtod returns 0.0
+    // for NAN and INF.
+    // This fixes failing test GEOSisValidDetail::test<3>, maybe others
+    // as well.
+    // Note: this hack is not robust, Boost lexical_cast or
+    // std::stod (C++11) would be better.
+    if(*str_end[0] != '\0') {
+        char sign = 0;
+        const char* pos = str;
+        if(*pos == '+' || *pos == '-') {
+            sign = *pos++;
+        }
+
+        if(stricmp(pos, "inf") == 0) {
+            if(!sign || sign == '+') {
+                dbl = std::numeric_limits<double>::infinity();
+            }
+            else {
+                dbl = -(std::numeric_limits<double>::infinity)();
+            }
+            *str_end[0] = '\0';
+        }
+        else if(stricmp(pos, "nan") == 0) {
+            dbl = std::numeric_limits<double>::quiet_NaN();
+            *str_end[0] = '\0';
+        }
+    }
 #endif
-	return dbl;
+    return dbl;
 }
 
 /*public*/
 int
 StringTokenizer::nextToken()
 {
-	string tok="";
-	if (iter==str.end())
-		return StringTokenizer::TT_EOF;
-	switch(*iter) {
-		case '(':
-		case ')':
-		case ',':
-			return *iter++;
-		case '\n':
-		case '\r':
-		case '\t':
-		case ' ':
-			string::size_type pos=str.find_first_not_of(" \n\r\t",
-				iter-str.begin());
-			if (pos==string::npos) {
-				return StringTokenizer::TT_EOF;
-			} else {
-				iter=str.begin()+pos;
-				return nextToken();
-			}
-	}
-	string::size_type pos=str.find_first_of("\n\r\t() ,",
-		iter-str.begin());
-	if (pos==string::npos) {
-		if (iter!=str.end()) {
-			tok.assign(iter,str.end());
-			iter=str.end();
-		} else {
-			return StringTokenizer::TT_EOF;
-		}
-	} else {
-		tok.assign(iter, str.begin()+pos);
-		iter=str.begin()+pos;
-	}
-	char *stopstring;
-	double dbl=strtod_with_vc_fix(tok.c_str(),&stopstring);
-	if (*stopstring=='\0') {
-		ntok=dbl;
-		stok="";
-		return StringTokenizer::TT_NUMBER;
-	} else {
-		ntok=0.0;
-		stok=tok;
-		return StringTokenizer::TT_WORD;
-	}
+    string tok = "";
+    if(iter == str.end()) {
+        return StringTokenizer::TT_EOF;
+    }
+    switch(*iter) {
+    case '(':
+    case ')':
+    case ',':
+        return *iter++;
+    case '\n':
+    case '\r':
+    case '\t':
+    case ' ':
+        string::size_type pos = str.find_first_not_of(" \n\r\t",
+                                iter - str.begin());
+        if(pos == string::npos) {
+            return StringTokenizer::TT_EOF;
+        }
+        else {
+            iter = str.begin() + pos;
+            return nextToken();
+        }
+    }
+    string::size_type pos = str.find_first_of("\n\r\t() ,",
+                            iter - str.begin());
+    if(pos == string::npos) {
+        if(iter != str.end()) {
+            tok.assign(iter, str.end());
+            iter = str.end();
+        }
+        else {
+            return StringTokenizer::TT_EOF;
+        }
+    }
+    else {
+        tok.assign(iter, str.begin() + pos);
+        iter = str.begin() + pos;
+    }
+    char* stopstring;
+    double dbl = strtod_with_vc_fix(tok.c_str(), &stopstring);
+    if(*stopstring == '\0') {
+        ntok = dbl;
+        stok = "";
+        return StringTokenizer::TT_NUMBER;
+    }
+    else {
+        ntok = 0.0;
+        stok = tok;
+        return StringTokenizer::TT_WORD;
+    }
 }
 
 /*public*/
@@ -129,61 +135,67 @@ int
 StringTokenizer::peekNextToken()
 {
 
-	string::size_type pos;
-	string tok="";
-	if (iter==str.end())
-		return StringTokenizer::TT_EOF;
-
-	pos=str.find_first_not_of(" \r\n\t", iter-str.begin());
-
-	if (pos==string::npos) return StringTokenizer::TT_EOF;
-	switch(str[pos]) {
-		case '(':
-		case ')':
-		case ',':
-			return str[pos];
-	}
-
-	// It's either a Number or a Word, let's
-	// see when it ends
-
-	pos=str.find_first_of("\n\r\t() ,", iter-str.begin());
-
-	if (pos==string::npos) {
-		if (iter!=str.end()) {
-			tok.assign(iter,str.end());
-		} else {
-			return StringTokenizer::TT_EOF;
-		}
-	} else {
-		tok.assign(iter, str.begin()+pos); //str.end());
-	}
-
-	char *stopstring;
-	double dbl = strtod_with_vc_fix(tok.c_str(), &stopstring);
-	if (*stopstring=='\0') {
-		ntok=dbl;
-		stok="";
-		return StringTokenizer::TT_NUMBER;
-	} else {
-		ntok=0.0;
-		stok=tok;
-		return StringTokenizer::TT_WORD;
-	}
+    string::size_type pos;
+    string tok = "";
+    if(iter == str.end()) {
+        return StringTokenizer::TT_EOF;
+    }
+
+    pos = str.find_first_not_of(" \r\n\t", iter - str.begin());
+
+    if(pos == string::npos) {
+        return StringTokenizer::TT_EOF;
+    }
+    switch(str[pos]) {
+    case '(':
+    case ')':
+    case ',':
+        return str[pos];
+    }
+
+    // It's either a Number or a Word, let's
+    // see when it ends
+
+    pos = str.find_first_of("\n\r\t() ,", iter - str.begin());
+
+    if(pos == string::npos) {
+        if(iter != str.end()) {
+            tok.assign(iter, str.end());
+        }
+        else {
+            return StringTokenizer::TT_EOF;
+        }
+    }
+    else {
+        tok.assign(iter, str.begin() + pos); //str.end());
+    }
+
+    char* stopstring;
+    double dbl = strtod_with_vc_fix(tok.c_str(), &stopstring);
+    if(*stopstring == '\0') {
+        ntok = dbl;
+        stok = "";
+        return StringTokenizer::TT_NUMBER;
+    }
+    else {
+        ntok = 0.0;
+        stok = tok;
+        return StringTokenizer::TT_WORD;
+    }
 }
 
 /*public*/
 double
 StringTokenizer::getNVal()
 {
-	return ntok;
+    return ntok;
 }
 
 /*public*/
 string
 StringTokenizer::getSVal()
 {
-	return stok;
+    return stok;
 }
 
 } // namespace geos.io
diff --git a/src/io/Unload.cpp b/src/io/Unload.cpp
index a764242..ff869e8 100644
--- a/src/io/Unload.cpp
+++ b/src/io/Unload.cpp
@@ -21,9 +21,10 @@ namespace geos {
 namespace io { // geos.io
 
 /*public static*/
-void Unload::Release()
+void
+Unload::Release()
 {
-	//delete geom::Geometry::INTERNAL_GEOMETRY_FACTORY;
+    //delete geom::Geometry::INTERNAL_GEOMETRY_FACTORY;
 }
 
 } // namespace geos.io
diff --git a/src/io/WKBReader.cpp b/src/io/WKBReader.cpp
index 7b1265a..99e2cec 100644
--- a/src/io/WKBReader.cpp
+++ b/src/io/WKBReader.cpp
@@ -47,411 +47,431 @@ namespace geos {
 namespace io { // geos.io
 
 WKBReader::WKBReader()
-	:
-	factory(*(GeometryFactory::getDefaultInstance()))
+    :
+    factory(*(GeometryFactory::getDefaultInstance()))
 {}
 
-ostream &
-WKBReader::printHEX(istream &is, ostream &os)
+ostream&
+WKBReader::printHEX(istream& is, ostream& os)
 {
-	static const char hex[] = "0123456789ABCDEF";
+    static const char hex[] = "0123456789ABCDEF";
 
     std::streampos pos = is.tellg(); // take note of input stream get pointer
-	is.seekg(0, ios::beg); // rewind input stream
+    is.seekg(0, ios::beg); // rewind input stream
 
-	char each=0;
-	while(is.read(&each, 1))
-	{
-		const unsigned char c=each;
-		int low = (c & 0x0F);
-		int high = (c >> 4);
-		os << hex[high] << hex[low];
-	}
+    char each = 0;
+    while(is.read(&each, 1)) {
+        const unsigned char c = each;
+        int low = (c & 0x0F);
+        int high = (c >> 4);
+        os << hex[high] << hex[low];
+    }
 
-	is.clear(); // clear input stream eof flag
-	is.seekg(pos); // reset input stream position
+    is.clear(); // clear input stream eof flag
+    is.seekg(pos); // reset input stream position
 
-	return os;
+    return os;
 }
 
 
 namespace {
 
-unsigned char ASCIIHexToUChar(char val)
+unsigned char
+ASCIIHexToUChar(char val)
 {
-	switch ( val )
-	{
-		case '0' :
-			return 0;
-		case '1' :
-			return 1;
-		case '2' :
-			return 2;
-		case '3' :
-			return 3;
-		case '4' :
-			return 4;
-		case '5' :
-			return 5;
-		case '6' :
-			return 6;
-		case '7' :
-			return 7;
-		case '8' :
-			return 8;
-		case '9' :
-			return 9;
-		case 'A' :
-		case 'a' :
-			return 10;
-		case 'B' :
-		case 'b' :
-			return 11;
-		case 'C' :
-		case 'c' :
-			return 12;
-		case 'D' :
-		case 'd' :
-			return 13;
-		case 'E' :
-		case 'e' :
-			return 14;
-		case 'F' :
-		case 'f' :
-			return 15;
-		default:
-			throw ParseException("Invalid HEX char");
-	}
+    switch(val) {
+    case '0' :
+        return 0;
+    case '1' :
+        return 1;
+    case '2' :
+        return 2;
+    case '3' :
+        return 3;
+    case '4' :
+        return 4;
+    case '5' :
+        return 5;
+    case '6' :
+        return 6;
+    case '7' :
+        return 7;
+    case '8' :
+        return 8;
+    case '9' :
+        return 9;
+    case 'A' :
+    case 'a' :
+        return 10;
+    case 'B' :
+    case 'b' :
+        return 11;
+    case 'C' :
+    case 'c' :
+        return 12;
+    case 'D' :
+    case 'd' :
+        return 13;
+    case 'E' :
+    case 'e' :
+        return 14;
+    case 'F' :
+    case 'f' :
+        return 15;
+    default:
+        throw ParseException("Invalid HEX char");
+    }
 }
 
 }  // namespace
 
 // Must be an even number of characters in the istream.
 // Throws a ParseException if there are an odd number of characters.
-Geometry *
-WKBReader::readHEX(istream &is)
+Geometry*
+WKBReader::readHEX(istream& is)
 {
-	// setup input/output stream
-	stringstream os(ios_base::binary|ios_base::in|ios_base::out);
+    // setup input/output stream
+    stringstream os(ios_base::binary | ios_base::in | ios_base::out);
 
-	while( true )
-	{
-		const int input_high = is.get();
-		if (input_high == char_traits<char>::eof())
-			break;
+    while(true) {
+        const int input_high = is.get();
+        if(input_high == char_traits<char>::eof()) {
+            break;
+        }
 
-		const int input_low = is.get();
-		if (input_low == char_traits<char>::eof())
-			throw ParseException("Premature end of HEX string");
+        const int input_low = is.get();
+        if(input_low == char_traits<char>::eof()) {
+            throw ParseException("Premature end of HEX string");
+        }
 
-		const char high = static_cast<char>(input_high);
-		const char low = static_cast<char>(input_low);
+        const char high = static_cast<char>(input_high);
+        const char low = static_cast<char>(input_low);
 
-		const unsigned char result_high = ASCIIHexToUChar(high);
-		const unsigned char result_low = ASCIIHexToUChar(low);
+        const unsigned char result_high = ASCIIHexToUChar(high);
+        const unsigned char result_low = ASCIIHexToUChar(low);
 
-		const unsigned char value =
-			static_cast<char>((result_high<<4) + result_low);
+        const unsigned char value =
+            static_cast<char>((result_high << 4) + result_low);
 
 #if DEBUG_HEX_READER
-	cout<<"HEX "<<high<<low<<" -> DEC "<<(int)value<<endl;
+        cout << "HEX " << high << low << " -> DEC " << (int)value << endl;
 #endif
-		// write the value to the output stream
-		os << value;
-	}
+        // write the value to the output stream
+        os << value;
+    }
 
-	// now call read to convert the geometry
-	return this->read(os);
+    // now call read to convert the geometry
+    return this->read(os);
 }
 
-Geometry *
-WKBReader::read(istream &is)
+Geometry*
+WKBReader::read(istream& is)
 {
-	dis.setInStream(&is); // will default to machine endian
-	return readGeometry();
+    dis.setInStream(&is); // will default to machine endian
+    return readGeometry();
 }
 
-Geometry *
+Geometry*
 WKBReader::readGeometry()
 {
-	// determine byte order
-	unsigned char byteOrder = dis.readByte();
+    // determine byte order
+    unsigned char byteOrder = dis.readByte();
 
 #if DEBUG_WKB_READER
-	cout<<"WKB byteOrder: "<<(int)byteOrder<<endl;
+    cout << "WKB byteOrder: " << (int)byteOrder << endl;
 #endif
 
-	// default is machine endian
-	if (byteOrder == WKBConstants::wkbNDR)
-		dis.setOrder(ByteOrderValues::ENDIAN_LITTLE);
-        else if (byteOrder == WKBConstants::wkbXDR)
-                dis.setOrder(ByteOrderValues::ENDIAN_BIG);
-
-	int typeInt = dis.readInt();
-	/* Pick up both ISO and SFSQL geometry type */
-	int geometryType = (typeInt & 0xffff) % 1000;
-	/* ISO type range 1000 is Z, 2000 is M, 3000 is ZM */
-	int isoTypeRange = (typeInt & 0xffff) / 1000;
-	int isoHasZ = (isoTypeRange == 1) || (isoTypeRange == 3);
-	//int isoHasM = (isoTypeRange == 2) || (isoTypeRange == 3);
-	/* SFSQL high bit flag for Z, next bit for M */
-	int sfsqlHasZ = (typeInt & 0x80000000) != 0;
-	//int sfsqlHasM = (typeInt & 0x40000000) != 0;
+    // default is machine endian
+    if(byteOrder == WKBConstants::wkbNDR) {
+        dis.setOrder(ByteOrderValues::ENDIAN_LITTLE);
+    }
+    else if(byteOrder == WKBConstants::wkbXDR) {
+        dis.setOrder(ByteOrderValues::ENDIAN_BIG);
+    }
+
+    int typeInt = dis.readInt();
+    /* Pick up both ISO and SFSQL geometry type */
+    int geometryType = (typeInt & 0xffff) % 1000;
+    /* ISO type range 1000 is Z, 2000 is M, 3000 is ZM */
+    int isoTypeRange = (typeInt & 0xffff) / 1000;
+    int isoHasZ = (isoTypeRange == 1) || (isoTypeRange == 3);
+    //int isoHasM = (isoTypeRange == 2) || (isoTypeRange == 3);
+    /* SFSQL high bit flag for Z, next bit for M */
+    int sfsqlHasZ = (typeInt & 0x80000000) != 0;
+    //int sfsqlHasM = (typeInt & 0x40000000) != 0;
 
 #if DEBUG_WKB_READER
-	cout<<"WKB geometryType: "<<geometryType<<endl;
+    cout << "WKB geometryType: " << geometryType << endl;
 #endif
 
-	bool hasZ = sfsqlHasZ || isoHasZ;
-	if (hasZ) inputDimension = 3;
-	else inputDimension = 2; // doesn't handle M currently
+    bool hasZ = sfsqlHasZ || isoHasZ;
+    if(hasZ) {
+        inputDimension = 3;
+    }
+    else {
+        inputDimension = 2;    // doesn't handle M currently
+    }
 
 #if DEBUG_WKB_READER
-	cout<<"WKB hasZ: "<<hasZ<<endl;
+    cout << "WKB hasZ: " << hasZ << endl;
 #endif
 
 #if DEBUG_WKB_READER
-	cout<<"WKB dimensions: "<<inputDimension<<endl;
+    cout << "WKB dimensions: " << inputDimension << endl;
 #endif
 
-	bool hasSRID = ((typeInt & 0x20000000) != 0);
+    bool hasSRID = ((typeInt & 0x20000000) != 0);
 
 #if DEBUG_WKB_READER
-	cout<<"WKB hasSRID: "<<hasSRID<<endl;
+    cout << "WKB hasSRID: " << hasSRID << endl;
 #endif
 
-	int SRID = 0;
-	if (hasSRID) SRID = dis.readInt(); // read SRID
-
-
-	// allocate space for ordValues
-	if ( ordValues.size() < inputDimension )
-		ordValues.resize(inputDimension);
-
-	Geometry *result;
-
-	switch (geometryType) {
-		case WKBConstants::wkbPoint :
-			result = readPoint();
-			break;
-		case WKBConstants::wkbLineString :
-			result = readLineString();
-			break;
-		case WKBConstants::wkbPolygon :
-			result = readPolygon();
-			break;
-		case WKBConstants::wkbMultiPoint :
-			result = readMultiPoint();
-			break;
-		case WKBConstants::wkbMultiLineString :
-			result = readMultiLineString();
-			break;
-		case WKBConstants::wkbMultiPolygon :
-			result = readMultiPolygon();
-			break;
-		case WKBConstants::wkbGeometryCollection :
-			result = readGeometryCollection();
-			break;
-		default:
-			stringstream err;
-			err << "Unknown WKB type " << geometryType;
-			throw  ParseException(err.str());
-	}
-
-	result->setSRID(SRID);
-	return result;
+    int SRID = 0;
+    if(hasSRID) {
+        SRID = dis.readInt();    // read SRID
+    }
+
+
+    // allocate space for ordValues
+    if(ordValues.size() < inputDimension) {
+        ordValues.resize(inputDimension);
+    }
+
+    Geometry* result;
+
+    switch(geometryType) {
+    case WKBConstants::wkbPoint :
+        result = readPoint();
+        break;
+    case WKBConstants::wkbLineString :
+        result = readLineString();
+        break;
+    case WKBConstants::wkbPolygon :
+        result = readPolygon();
+        break;
+    case WKBConstants::wkbMultiPoint :
+        result = readMultiPoint();
+        break;
+    case WKBConstants::wkbMultiLineString :
+        result = readMultiLineString();
+        break;
+    case WKBConstants::wkbMultiPolygon :
+        result = readMultiPolygon();
+        break;
+    case WKBConstants::wkbGeometryCollection :
+        result = readGeometryCollection();
+        break;
+    default:
+        stringstream err;
+        err << "Unknown WKB type " << geometryType;
+        throw  ParseException(err.str());
+    }
+
+    result->setSRID(SRID);
+    return result;
 }
 
-Point *
+Point*
 WKBReader::readPoint()
 {
-	readCoordinate();
-	if(inputDimension == 3){
-	  return factory.createPoint(Coordinate(ordValues[0], ordValues[1], ordValues[2]));
-	}else{
-	  return factory.createPoint(Coordinate(ordValues[0], ordValues[1]));
-	}
+    readCoordinate();
+    if(inputDimension == 3) {
+        return factory.createPoint(Coordinate(ordValues[0], ordValues[1], ordValues[2]));
+    }
+    else {
+        return factory.createPoint(Coordinate(ordValues[0], ordValues[1]));
+    }
 }
 
-LineString *
+LineString*
 WKBReader::readLineString()
 {
-	int size = dis.readInt();
+    int size = dis.readInt();
 #if DEBUG_WKB_READER
-	cout<<"WKB npoints: "<<size<<endl;
+    cout << "WKB npoints: " << size << endl;
 #endif
-	CoordinateSequence *pts = readCoordinateSequence(size);
-	return factory.createLineString(pts);
+    CoordinateSequence* pts = readCoordinateSequence(size);
+    return factory.createLineString(pts);
 }
 
-LinearRing *
+LinearRing*
 WKBReader::readLinearRing()
 {
-	int size = dis.readInt();
+    int size = dis.readInt();
 #if DEBUG_WKB_READER
-	cout<<"WKB npoints: "<<size<<endl;
+    cout << "WKB npoints: " << size << endl;
 #endif
-	CoordinateSequence *pts = readCoordinateSequence(size);
-	return factory.createLinearRing(pts);
+    CoordinateSequence* pts = readCoordinateSequence(size);
+    return factory.createLinearRing(pts);
 }
 
-Polygon *
+Polygon*
 WKBReader::readPolygon()
 {
-	int numRings = dis.readInt();
+    int numRings = dis.readInt();
 
 #if DEBUG_WKB_READER
-	cout<<"WKB numRings: "<<numRings<<endl;
+    cout << "WKB numRings: " << numRings << endl;
 #endif
 
-        LinearRing *shell = nullptr;
-        if( numRings > 0 )
-            shell = readLinearRing();
-
-	vector<Geometry *>*holes=nullptr;
-	if ( numRings > 1 )
-	{
-		try {
-			holes = new vector<Geometry *>(numRings-1);
-			for (int i=0; i<numRings-1; i++)
-				(*holes)[i] = (Geometry *)readLinearRing();
-		} catch (...) {
-			for (unsigned int i=0; i<holes->size(); i++)
-				delete (*holes)[i];
-			delete holes;
-			delete shell;
-			throw;
-		}
-	}
-	return factory.createPolygon(shell, holes);
+    LinearRing* shell = nullptr;
+    if(numRings > 0) {
+        shell = readLinearRing();
+    }
+
+    vector<Geometry*>* holes = nullptr;
+    if(numRings > 1) {
+        try {
+            holes = new vector<Geometry*>(numRings - 1);
+            for(int i = 0; i < numRings - 1; i++) {
+                (*holes)[i] = (Geometry*)readLinearRing();
+            }
+        }
+        catch(...) {
+            for(unsigned int i = 0; i < holes->size(); i++) {
+                delete(*holes)[i];
+            }
+            delete holes;
+            delete shell;
+            throw;
+        }
+    }
+    return factory.createPolygon(shell, holes);
 }
 
-MultiPoint *
+MultiPoint*
 WKBReader::readMultiPoint()
 {
-	int numGeoms = dis.readInt();
-	vector<Geometry *> *geoms = new vector<Geometry *>(numGeoms);
-
-	try {
-		for (int i=0; i<numGeoms; i++)
-		{
-			Geometry *g = readGeometry();
-			if (!dynamic_cast<Point *>(g))
-			{
-				stringstream err;
-				err << BAD_GEOM_TYPE_MSG << " MultiPoint";
-				throw ParseException(err.str());
-			}
-			(*geoms)[i] = g;
-		}
-	} catch (...) {
-		for (unsigned int i=0; i<geoms->size(); i++)
-			delete (*geoms)[i];
-		delete geoms;
-		throw;
-	}
-	return factory.createMultiPoint(geoms);
+    int numGeoms = dis.readInt();
+    vector<Geometry*>* geoms = new vector<Geometry*>(numGeoms);
+
+    try {
+        for(int i = 0; i < numGeoms; i++) {
+            Geometry* g = readGeometry();
+            if(!dynamic_cast<Point*>(g)) {
+                stringstream err;
+                err << BAD_GEOM_TYPE_MSG << " MultiPoint";
+                throw ParseException(err.str());
+            }
+            (*geoms)[i] = g;
+        }
+    }
+    catch(...) {
+        for(unsigned int i = 0; i < geoms->size(); i++) {
+            delete(*geoms)[i];
+        }
+        delete geoms;
+        throw;
+    }
+    return factory.createMultiPoint(geoms);
 }
 
-MultiLineString *
+MultiLineString*
 WKBReader::readMultiLineString()
 {
-	int numGeoms = dis.readInt();
-	vector<Geometry *> *geoms = new vector<Geometry *>(numGeoms);
-
-	try {
-		for (int i=0; i<numGeoms; i++)
-		{
-			Geometry *g = readGeometry();
-			if (!dynamic_cast<LineString *>(g))
-			{
-				stringstream err;
-				err << BAD_GEOM_TYPE_MSG << " LineString";
-				throw  ParseException(err.str());
-			}
-			(*geoms)[i] = g;
-		}
-	} catch (...) {
-		for (unsigned int i=0; i<geoms->size(); i++)
-			delete (*geoms)[i];
-		delete geoms;
-		throw;
-	}
-	return factory.createMultiLineString(geoms);
+    int numGeoms = dis.readInt();
+    vector<Geometry*>* geoms = new vector<Geometry*>(numGeoms);
+
+    try {
+        for(int i = 0; i < numGeoms; i++) {
+            Geometry* g = readGeometry();
+            if(!dynamic_cast<LineString*>(g)) {
+                stringstream err;
+                err << BAD_GEOM_TYPE_MSG << " LineString";
+                throw  ParseException(err.str());
+            }
+            (*geoms)[i] = g;
+        }
+    }
+    catch(...) {
+        for(unsigned int i = 0; i < geoms->size(); i++) {
+            delete(*geoms)[i];
+        }
+        delete geoms;
+        throw;
+    }
+    return factory.createMultiLineString(geoms);
 }
 
-MultiPolygon *
+MultiPolygon*
 WKBReader::readMultiPolygon()
 {
-	int numGeoms = dis.readInt();
-	vector<Geometry *> *geoms = new vector<Geometry *>(numGeoms);
-
-	try {
-		for (int i=0; i<numGeoms; i++)
-		{
-			Geometry *g = readGeometry();
-			if (!dynamic_cast<Polygon *>(g))
-			{
-				stringstream err;
-				err << BAD_GEOM_TYPE_MSG << " Polygon";
-				throw  ParseException(err.str());
-			}
-			(*geoms)[i] = g;
-		}
-	} catch (...) {
-		for (unsigned int i=0; i<geoms->size(); i++)
-			delete (*geoms)[i];
-		delete geoms;
-		throw;
-	}
-	return factory.createMultiPolygon(geoms);
+    int numGeoms = dis.readInt();
+    vector<Geometry*>* geoms = new vector<Geometry*>(numGeoms);
+
+    try {
+        for(int i = 0; i < numGeoms; i++) {
+            Geometry* g = readGeometry();
+            if(!dynamic_cast<Polygon*>(g)) {
+                stringstream err;
+                err << BAD_GEOM_TYPE_MSG << " Polygon";
+                throw  ParseException(err.str());
+            }
+            (*geoms)[i] = g;
+        }
+    }
+    catch(...) {
+        for(unsigned int i = 0; i < geoms->size(); i++) {
+            delete(*geoms)[i];
+        }
+        delete geoms;
+        throw;
+    }
+    return factory.createMultiPolygon(geoms);
 }
 
-GeometryCollection *
+GeometryCollection*
 WKBReader::readGeometryCollection()
 {
-	int numGeoms = dis.readInt();
-	vector<Geometry *> *geoms = new vector<Geometry *>(numGeoms);
-
-	try {
-		for (int i=0; i<numGeoms; i++)
-			(*geoms)[i] = (readGeometry());
-	} catch (...) {
-		for (unsigned int i=0; i<geoms->size(); i++)
-			delete (*geoms)[i];
-		delete geoms;
-		throw;
-	}
-	return factory.createGeometryCollection(geoms);
+    int numGeoms = dis.readInt();
+    vector<Geometry*>* geoms = new vector<Geometry*>(numGeoms);
+
+    try {
+        for(int i = 0; i < numGeoms; i++) {
+            (*geoms)[i] = (readGeometry());
+        }
+    }
+    catch(...) {
+        for(unsigned int i = 0; i < geoms->size(); i++) {
+            delete(*geoms)[i];
+        }
+        delete geoms;
+        throw;
+    }
+    return factory.createGeometryCollection(geoms);
 }
 
-CoordinateSequence *
+CoordinateSequence*
 WKBReader::readCoordinateSequence(int size)
 {
-	CoordinateSequence *seq = factory.getCoordinateSequenceFactory()->create(size, inputDimension);
-	auto targetDim = seq->getDimension();
-	if ( targetDim > inputDimension )
-		targetDim = inputDimension;
-	for (int i=0; i<size; i++) {
-		readCoordinate();
-		for (unsigned int j=0; j<targetDim; j++) {
-			seq->setOrdinate(i, j, ordValues[j]);
-		}
-	}
-	return seq;
+    CoordinateSequence* seq = factory.getCoordinateSequenceFactory()->create(size, inputDimension);
+    auto targetDim = seq->getDimension();
+    if(targetDim > inputDimension) {
+        targetDim = inputDimension;
+    }
+    for(int i = 0; i < size; i++) {
+        readCoordinate();
+        for(unsigned int j = 0; j < targetDim; j++) {
+            seq->setOrdinate(i, j, ordValues[j]);
+        }
+    }
+    return seq;
 }
 
 void
 WKBReader::readCoordinate()
 {
-	const PrecisionModel &pm = *factory.getPrecisionModel();
-	for (unsigned int i=0; i<inputDimension; ++i)
-	{
-		if ( i <= 1 ) ordValues[i] = pm.makePrecise(dis.readDouble());
-		else ordValues[i] = dis.readDouble();
-	}
+    const PrecisionModel& pm = *factory.getPrecisionModel();
+    for(unsigned int i = 0; i < inputDimension; ++i) {
+        if(i <= 1) {
+            ordValues[i] = pm.makePrecise(dis.readDouble());
+        }
+        else {
+            ordValues[i] = dis.readDouble();
+        }
+    }
 #if DEBUG_WKB_READER
-	cout<<"WKB coordinate: "<<ordValues[0]<<","<<ordValues[1]<<endl;
+    cout << "WKB coordinate: " << ordValues[0] << "," << ordValues[1] << endl;
 #endif
 }
 
diff --git a/src/io/WKBWriter.cpp b/src/io/WKBWriter.cpp
index f9bd7ff..a72c479 100644
--- a/src/io/WKBWriter.cpp
+++ b/src/io/WKBWriter.cpp
@@ -42,13 +42,14 @@ using namespace std;
 using namespace geos::geom;
 
 namespace geos {
-	namespace io { // geos.io
+namespace io { // geos.io
 
 WKBWriter::WKBWriter(int dims, int bo, bool srid):
-		defaultOutputDimension(dims), byteOrder(bo), includeSRID(srid), outStream(nullptr)
+    defaultOutputDimension(dims), byteOrder(bo), includeSRID(srid), outStream(nullptr)
 {
-	if ( dims < 2 || dims > 3 )
-		throw util::IllegalArgumentException("WKB output dimension must be 2 or 3");
+    if(dims < 2 || dims > 3) {
+        throw util::IllegalArgumentException("WKB output dimension must be 2 or 3");
+    }
     outputDimension = defaultOutputDimension;
 }
 
@@ -57,8 +58,9 @@ WKBWriter::WKBWriter(int dims, int bo, bool srid):
 void
 WKBWriter::setOutputDimension(int dims)
 {
-	if ( dims < 2 || dims > 3 )
-		throw util::IllegalArgumentException("WKB output dimension must be 2 or 3");
+    if(dims < 2 || dims > 3) {
+        throw util::IllegalArgumentException("WKB output dimension must be 2 or 3");
+    }
 
     defaultOutputDimension = dims;
 }
@@ -68,247 +70,243 @@ WKBWriter::~WKBWriter()
 }
 
 void
-WKBWriter::writeHEX(const Geometry &g, ostream &os)
+WKBWriter::writeHEX(const Geometry& g, ostream& os)
 {
-	// setup input/output stream
-	stringstream stream;
+    // setup input/output stream
+    stringstream stream;
 
-	// write the geometry in wkb format
-	this->write(g, stream);
+    // write the geometry in wkb format
+    this->write(g, stream);
 
-	// convert to HEX
-	WKBReader::printHEX(stream, os);
+    // convert to HEX
+    WKBReader::printHEX(stream, os);
 }
 
 void
-WKBWriter::write(const Geometry &g, ostream &os)
+WKBWriter::write(const Geometry& g, ostream& os)
 {
-	outputDimension = defaultOutputDimension;
-	if( outputDimension > g.getCoordinateDimension() )
-		outputDimension = g.getCoordinateDimension();
-
-	outStream = &os;
-
-  if ( const Point* x = dynamic_cast<const Point*>(&g) )
-  {
-    return writePoint(*x);
-  }
-
-  if ( const LineString* x = dynamic_cast<const LineString*>(&g) )
-  {
-    return writeLineString(*x);
-  }
-
-  if ( const Polygon* x = dynamic_cast<const Polygon*>(&g) )
-  {
-    return writePolygon(*x);
-  }
-
-  if ( const MultiPoint* x = dynamic_cast<const MultiPoint*>(&g) )
-  {
-    return writeGeometryCollection(*x, WKBConstants::wkbMultiPoint);
-  }
-
-  if ( const MultiLineString* x = dynamic_cast<const MultiLineString*>(&g) )
-  {
-    return writeGeometryCollection(*x, WKBConstants::wkbMultiLineString);
-  }
-
-  if ( const MultiPolygon* x = dynamic_cast<const MultiPolygon*>(&g) )
-  {
-    return writeGeometryCollection(*x, WKBConstants::wkbMultiPolygon);
-  }
-
-  if ( const GeometryCollection* x =
-       dynamic_cast<const GeometryCollection*>(&g) )
-  {
-    return writeGeometryCollection(*x, WKBConstants::wkbGeometryCollection);
-  }
-
-  assert(0); // Unknown Geometry type
+    outputDimension = defaultOutputDimension;
+    if(outputDimension > g.getCoordinateDimension()) {
+        outputDimension = g.getCoordinateDimension();
+    }
+
+    outStream = &os;
+
+    if(const Point* x = dynamic_cast<const Point*>(&g)) {
+        return writePoint(*x);
+    }
+
+    if(const LineString* x = dynamic_cast<const LineString*>(&g)) {
+        return writeLineString(*x);
+    }
+
+    if(const Polygon* x = dynamic_cast<const Polygon*>(&g)) {
+        return writePolygon(*x);
+    }
+
+    if(const MultiPoint* x = dynamic_cast<const MultiPoint*>(&g)) {
+        return writeGeometryCollection(*x, WKBConstants::wkbMultiPoint);
+    }
+
+    if(const MultiLineString* x = dynamic_cast<const MultiLineString*>(&g)) {
+        return writeGeometryCollection(*x, WKBConstants::wkbMultiLineString);
+    }
+
+    if(const MultiPolygon* x = dynamic_cast<const MultiPolygon*>(&g)) {
+        return writeGeometryCollection(*x, WKBConstants::wkbMultiPolygon);
+    }
+
+    if(const GeometryCollection* x =
+                dynamic_cast<const GeometryCollection*>(&g)) {
+        return writeGeometryCollection(*x, WKBConstants::wkbGeometryCollection);
+    }
+
+    assert(0); // Unknown Geometry type
 }
 
 void
-WKBWriter::writePoint(const Point &g)
+WKBWriter::writePoint(const Point& g)
 {
-	if (g.isEmpty()) throw
-		util::IllegalArgumentException("Empty Points cannot be represented in WKB");
+    if(g.isEmpty()) throw
+        util::IllegalArgumentException("Empty Points cannot be represented in WKB");
 
-	writeByteOrder();
+    writeByteOrder();
 
-	writeGeometryType(WKBConstants::wkbPoint, g.getSRID());
-	writeSRID(g.getSRID());
+    writeGeometryType(WKBConstants::wkbPoint, g.getSRID());
+    writeSRID(g.getSRID());
 
-	const CoordinateSequence* cs=g.getCoordinatesRO();
-	assert(cs);
-	writeCoordinateSequence(*cs, false);
+    const CoordinateSequence* cs = g.getCoordinatesRO();
+    assert(cs);
+    writeCoordinateSequence(*cs, false);
 }
 
 void
-WKBWriter::writeLineString(const LineString &g)
+WKBWriter::writeLineString(const LineString& g)
 {
-	writeByteOrder();
+    writeByteOrder();
 
-	writeGeometryType(WKBConstants::wkbLineString, g.getSRID());
-	writeSRID(g.getSRID());
+    writeGeometryType(WKBConstants::wkbLineString, g.getSRID());
+    writeSRID(g.getSRID());
 
-	const CoordinateSequence* cs=g.getCoordinatesRO();
-	assert(cs);
-	writeCoordinateSequence(*cs, true);
+    const CoordinateSequence* cs = g.getCoordinatesRO();
+    assert(cs);
+    writeCoordinateSequence(*cs, true);
 }
 
 void
-WKBWriter::writePolygon(const Polygon &g)
+WKBWriter::writePolygon(const Polygon& g)
 {
-	writeByteOrder();
+    writeByteOrder();
 
-	writeGeometryType(WKBConstants::wkbPolygon, g.getSRID());
-	writeSRID(g.getSRID());
+    writeGeometryType(WKBConstants::wkbPolygon, g.getSRID());
+    writeSRID(g.getSRID());
 
-	if (g.isEmpty()) {
-		writeInt(0);
-		return;
-	}
+    if(g.isEmpty()) {
+        writeInt(0);
+        return;
+    }
 
-	std::size_t nholes = g.getNumInteriorRing();
-	writeInt(static_cast<int>(nholes + 1));
+    std::size_t nholes = g.getNumInteriorRing();
+    writeInt(static_cast<int>(nholes + 1));
 
-	const LineString* ls = g.getExteriorRing();
-	assert(ls);
+    const LineString* ls = g.getExteriorRing();
+    assert(ls);
 
-	const CoordinateSequence* cs=ls->getCoordinatesRO();
-	assert(cs);
+    const CoordinateSequence* cs = ls->getCoordinatesRO();
+    assert(cs);
 
-	writeCoordinateSequence(*cs, true);
-	for (std::size_t i=0; i<nholes; i++)
-	{
-		ls = g.getInteriorRingN(i);
-		assert(ls);
+    writeCoordinateSequence(*cs, true);
+    for(std::size_t i = 0; i < nholes; i++) {
+        ls = g.getInteriorRingN(i);
+        assert(ls);
 
-		cs = ls->getCoordinatesRO();
-		assert(cs);
+        cs = ls->getCoordinatesRO();
+        assert(cs);
 
-		writeCoordinateSequence(*cs, true);
-	}
+        writeCoordinateSequence(*cs, true);
+    }
 }
 
 void
-WKBWriter::writeGeometryCollection(const GeometryCollection &g,
-	int wkbtype)
+WKBWriter::writeGeometryCollection(const GeometryCollection& g,
+                                   int wkbtype)
 {
-	writeByteOrder();
+    writeByteOrder();
 
-	writeGeometryType(wkbtype, g.getSRID());
-	writeSRID(g.getSRID());
+    writeGeometryType(wkbtype, g.getSRID());
+    writeSRID(g.getSRID());
 
-	auto ngeoms = g.getNumGeometries();
-	writeInt(static_cast<int>(ngeoms));
-	auto orig_includeSRID = includeSRID;
-	includeSRID = false;
+    auto ngeoms = g.getNumGeometries();
+    writeInt(static_cast<int>(ngeoms));
+    auto orig_includeSRID = includeSRID;
+    includeSRID = false;
 
-	assert(outStream);
-	for (std::size_t i=0; i<ngeoms; i++)
-	{
-		const Geometry* elem = g.getGeometryN(i);
-		assert(elem);
+    assert(outStream);
+    for(std::size_t i = 0; i < ngeoms; i++) {
+        const Geometry* elem = g.getGeometryN(i);
+        assert(elem);
 
-		write(*elem, *outStream);
-	}
-	includeSRID = orig_includeSRID;
+        write(*elem, *outStream);
+    }
+    includeSRID = orig_includeSRID;
 }
 
 void
 WKBWriter::writeByteOrder()
 {
-	if (byteOrder == ByteOrderValues::ENDIAN_LITTLE)
-	{
-		buf[0] = WKBConstants::wkbNDR;
-	}
-	else
-	{
-		buf[0] = WKBConstants::wkbXDR;
-	}
-
-	assert(outStream);
-	outStream->write(reinterpret_cast<char*>(buf), 1);
+    if(byteOrder == ByteOrderValues::ENDIAN_LITTLE) {
+        buf[0] = WKBConstants::wkbNDR;
+    }
+    else {
+        buf[0] = WKBConstants::wkbXDR;
+    }
+
+    assert(outStream);
+    outStream->write(reinterpret_cast<char*>(buf), 1);
 }
 
 /* public */
 void
 WKBWriter::setByteOrder(int bo)
 {
-	if (bo != ByteOrderValues::ENDIAN_LITTLE &&
-	    bo != ByteOrderValues::ENDIAN_BIG )
-	{
-	    std::ostringstream os;
-		os << "WKB output dimension must be LITTLE ("
-		   << ByteOrderValues::ENDIAN_LITTLE
-		   << ") or BIG (" << ByteOrderValues::ENDIAN_BIG << ")";
-		throw util::IllegalArgumentException(os.str());
-	}
-
-	byteOrder = bo;
+    if(bo != ByteOrderValues::ENDIAN_LITTLE &&
+            bo != ByteOrderValues::ENDIAN_BIG) {
+        std::ostringstream os;
+        os << "WKB output dimension must be LITTLE ("
+           << ByteOrderValues::ENDIAN_LITTLE
+           << ") or BIG (" << ByteOrderValues::ENDIAN_BIG << ")";
+        throw util::IllegalArgumentException(os.str());
+    }
+
+    byteOrder = bo;
 }
 
 void
 WKBWriter::writeGeometryType(int typeId, int SRID)
 {
-	int flag3D = (outputDimension == 3) ? 0x80000000 : 0;
-	int typeInt = typeId | flag3D;
+    int flag3D = (outputDimension == 3) ? 0x80000000 : 0;
+    int typeInt = typeId | flag3D;
 
-	if (includeSRID && SRID != 0)
-		typeInt = typeInt | 0x20000000;
+    if(includeSRID && SRID != 0) {
+        typeInt = typeInt | 0x20000000;
+    }
 
-	writeInt(typeInt);
+    writeInt(typeInt);
 }
 
 void
 WKBWriter::writeSRID(int SRID)
 {
-    if (includeSRID && SRID != 0)
+    if(includeSRID && SRID != 0) {
         writeInt(SRID);
+    }
 }
 
 void
 WKBWriter::writeInt(int val)
 {
-	ByteOrderValues::putInt(val, buf, byteOrder);
-	outStream->write(reinterpret_cast<char *>(buf), 4);
-	//outStream->write(reinterpret_cast<char *>(&val), 4);
+    ByteOrderValues::putInt(val, buf, byteOrder);
+    outStream->write(reinterpret_cast<char*>(buf), 4);
+    //outStream->write(reinterpret_cast<char *>(&val), 4);
 }
 
 void
-WKBWriter::writeCoordinateSequence(const CoordinateSequence &cs,
-	bool sized)
+WKBWriter::writeCoordinateSequence(const CoordinateSequence& cs,
+                                   bool sized)
 {
-	std::size_t size = cs.getSize();
-	bool is3d=false;
-	if ( outputDimension > 2) is3d = true;
-
-	if (sized) writeInt(static_cast<int>(size));
-	for (std::size_t i = 0; i < size; i++) writeCoordinate(cs, i, is3d);
+    std::size_t size = cs.getSize();
+    bool is3d = false;
+    if(outputDimension > 2) {
+        is3d = true;
+    }
+
+    if(sized) {
+        writeInt(static_cast<int>(size));
+    }
+    for(std::size_t i = 0; i < size; i++) {
+        writeCoordinate(cs, i, is3d);
+    }
 }
 
 void
-WKBWriter::writeCoordinate(const CoordinateSequence &cs, size_t idx,
-	bool is3d)
+WKBWriter::writeCoordinate(const CoordinateSequence& cs, size_t idx,
+                           bool is3d)
 {
 #if DEBUG_WKB_WRITER
-	cout<<"writeCoordinate: X:"<<cs.getX(idx)<<" Y:"<<cs.getY(idx)<<endl;
+    cout << "writeCoordinate: X:" << cs.getX(idx) << " Y:" << cs.getY(idx) << endl;
 #endif
-	assert(outStream);
-
-	ByteOrderValues::putDouble(cs.getX(idx), buf, byteOrder);
-	outStream->write(reinterpret_cast<char *>(buf), 8);
-	ByteOrderValues::putDouble(cs.getY(idx), buf, byteOrder);
-	outStream->write(reinterpret_cast<char *>(buf), 8);
-	if ( is3d )
-	{
-		ByteOrderValues::putDouble(
-			cs.getOrdinate(idx, CoordinateSequence::Z),
-			buf, byteOrder);
-		outStream->write(reinterpret_cast<char *>(buf), 8);
-	}
+    assert(outStream);
+
+    ByteOrderValues::putDouble(cs.getX(idx), buf, byteOrder);
+    outStream->write(reinterpret_cast<char*>(buf), 8);
+    ByteOrderValues::putDouble(cs.getY(idx), buf, byteOrder);
+    outStream->write(reinterpret_cast<char*>(buf), 8);
+    if(is3d) {
+        ByteOrderValues::putDouble(
+            cs.getOrdinate(idx, CoordinateSequence::Z),
+            buf, byteOrder);
+        outStream->write(reinterpret_cast<char*>(buf), 8);
+    }
 }
 
 
diff --git a/src/io/WKTReader.cpp b/src/io/WKTReader.cpp
index 086f778..4c77ef0 100644
--- a/src/io/WKTReader.cpp
+++ b/src/io/WKTReader.cpp
@@ -57,432 +57,458 @@ using namespace geos::geom;
 namespace geos {
 namespace io { // geos.io
 
-Geometry *
-WKTReader::read(const string &wellKnownText)
+Geometry*
+WKTReader::read(const string& wellKnownText)
 {
-	//unique_ptr<StringTokenizer> tokenizer(new StringTokenizer(wellKnownText));
-        CLocalizer clocale;
-	StringTokenizer tokenizer(wellKnownText);
-	Geometry *g=nullptr;
-	g=readGeometryTaggedText(&tokenizer);
-	return g;
+    //unique_ptr<StringTokenizer> tokenizer(new StringTokenizer(wellKnownText));
+    CLocalizer clocale;
+    StringTokenizer tokenizer(wellKnownText);
+    Geometry* g = nullptr;
+    g = readGeometryTaggedText(&tokenizer);
+    return g;
 }
 
 CoordinateSequence*
-WKTReader::getCoordinates(StringTokenizer *tokenizer)
+WKTReader::getCoordinates(StringTokenizer* tokenizer)
 {
-	size_t dim;
-	string nextToken=getNextEmptyOrOpener(tokenizer);
-	if (nextToken=="EMPTY") {
-		return geometryFactory->getCoordinateSequenceFactory()->create();
-		//new CoordinateArraySequence();
-	}
-
-	Coordinate coord;
-	getPreciseCoordinate(tokenizer, coord, dim);
-
-	CoordinateSequence *coordinates = \
-            geometryFactory->getCoordinateSequenceFactory()->create((size_t)0,dim);
-	coordinates->add(coord);
-	try {
-		nextToken=getNextCloserOrComma(tokenizer);
-		while (nextToken==",") {
-			getPreciseCoordinate(tokenizer, coord, dim );
-			coordinates->add(coord);
-			nextToken=getNextCloserOrComma(tokenizer);
-		}
-	} catch (...) {
-		delete coordinates;
-		throw;
-	}
-
-	return coordinates;
+    size_t dim;
+    string nextToken = getNextEmptyOrOpener(tokenizer);
+    if(nextToken == "EMPTY") {
+        return geometryFactory->getCoordinateSequenceFactory()->create();
+        //new CoordinateArraySequence();
+    }
+
+    Coordinate coord;
+    getPreciseCoordinate(tokenizer, coord, dim);
+
+    CoordinateSequence* coordinates = \
+                                      geometryFactory->getCoordinateSequenceFactory()->create((size_t)0, dim);
+    coordinates->add(coord);
+    try {
+        nextToken = getNextCloserOrComma(tokenizer);
+        while(nextToken == ",") {
+            getPreciseCoordinate(tokenizer, coord, dim);
+            coordinates->add(coord);
+            nextToken = getNextCloserOrComma(tokenizer);
+        }
+    }
+    catch(...) {
+        delete coordinates;
+        throw;
+    }
+
+    return coordinates;
 }
 
 
 void
-WKTReader::getPreciseCoordinate(StringTokenizer *tokenizer,
+WKTReader::getPreciseCoordinate(StringTokenizer* tokenizer,
                                 Coordinate& coord,
-                                size_t &dim )
+                                size_t& dim)
 {
-	coord.x=getNextNumber(tokenizer);
-	coord.y=getNextNumber(tokenizer);
-	if (isNumberNext(tokenizer)) {
-		coord.z=getNextNumber(tokenizer);
-		dim = 3;
+    coord.x = getNextNumber(tokenizer);
+    coord.y = getNextNumber(tokenizer);
+    if(isNumberNext(tokenizer)) {
+        coord.z = getNextNumber(tokenizer);
+        dim = 3;
 
         // If there is a fourth value (M) read and discard it.
-        if (isNumberNext(tokenizer))
+        if(isNumberNext(tokenizer)) {
             getNextNumber(tokenizer);
+        }
 
-	} else {
-		coord.z=DoubleNotANumber;
-		dim = 2;
-	}
-	precisionModel->makePrecise(coord);
+    }
+    else {
+        coord.z = DoubleNotANumber;
+        dim = 2;
+    }
+    precisionModel->makePrecise(coord);
 }
 
 bool
-WKTReader::isNumberNext(StringTokenizer *tokenizer)
+WKTReader::isNumberNext(StringTokenizer* tokenizer)
 {
-	return tokenizer->peekNextToken()==StringTokenizer::TT_NUMBER;
+    return tokenizer->peekNextToken() == StringTokenizer::TT_NUMBER;
 }
 
 double
-WKTReader::getNextNumber(StringTokenizer *tokenizer)
+WKTReader::getNextNumber(StringTokenizer* tokenizer)
 {
-	int type=tokenizer->nextToken();
-	switch(type){
-		case StringTokenizer::TT_EOF:
-			throw  ParseException("Expected number but encountered end of stream");
-		case StringTokenizer::TT_EOL:
-			throw  ParseException("Expected number but encountered end of line");
-		case StringTokenizer::TT_NUMBER:
-			return tokenizer->getNVal();
-		case StringTokenizer::TT_WORD:
-			throw  ParseException("Expected number but encountered word",tokenizer->getSVal());
-		case '(':
-			throw  ParseException("Expected number but encountered '('");
-		case ')':
-			throw  ParseException("Expected number but encountered ')'");
-		case ',':
-			throw  ParseException("Expected number but encountered ','");
-	}
-	assert(0); // Encountered unexpected StreamTokenizer type
-	return 0;
+    int type = tokenizer->nextToken();
+    switch(type) {
+    case StringTokenizer::TT_EOF:
+        throw  ParseException("Expected number but encountered end of stream");
+    case StringTokenizer::TT_EOL:
+        throw  ParseException("Expected number but encountered end of line");
+    case StringTokenizer::TT_NUMBER:
+        return tokenizer->getNVal();
+    case StringTokenizer::TT_WORD:
+        throw  ParseException("Expected number but encountered word", tokenizer->getSVal());
+    case '(':
+        throw  ParseException("Expected number but encountered '('");
+    case ')':
+        throw  ParseException("Expected number but encountered ')'");
+    case ',':
+        throw  ParseException("Expected number but encountered ','");
+    }
+    assert(0); // Encountered unexpected StreamTokenizer type
+    return 0;
 }
 
 string
-WKTReader::getNextEmptyOrOpener(StringTokenizer *tokenizer)
+WKTReader::getNextEmptyOrOpener(StringTokenizer* tokenizer)
 {
-	string nextWord=getNextWord(tokenizer);
+    string nextWord = getNextWord(tokenizer);
 
-	// Skip the Z, M or ZM of an SF1.2 3/4 dim coordinate.
-	if (nextWord == "Z" || nextWord == "M" || nextWord == "ZM" )
-		nextWord = getNextWord(tokenizer);
+    // Skip the Z, M or ZM of an SF1.2 3/4 dim coordinate.
+    if(nextWord == "Z" || nextWord == "M" || nextWord == "ZM") {
+        nextWord = getNextWord(tokenizer);
+    }
 
-	if (nextWord=="EMPTY" || nextWord=="(") {
-		return nextWord;
-	}
-	throw  ParseException("Expected 'Z', 'M', 'ZM', 'EMPTY' or '(' but encountered ",nextWord);
+    if(nextWord == "EMPTY" || nextWord == "(") {
+        return nextWord;
+    }
+    throw  ParseException("Expected 'Z', 'M', 'ZM', 'EMPTY' or '(' but encountered ", nextWord);
 }
 
 string
-WKTReader::getNextCloserOrComma(StringTokenizer *tokenizer)
+WKTReader::getNextCloserOrComma(StringTokenizer* tokenizer)
 {
-	string nextWord=getNextWord(tokenizer);
-	if (nextWord=="," || nextWord==")") {
-		return nextWord;
-	}
-	throw  ParseException("Expected ')' or ',' but encountered",nextWord);
+    string nextWord = getNextWord(tokenizer);
+    if(nextWord == "," || nextWord == ")") {
+        return nextWord;
+    }
+    throw  ParseException("Expected ')' or ',' but encountered", nextWord);
 }
 
 string
-WKTReader::getNextCloser(StringTokenizer *tokenizer)
+WKTReader::getNextCloser(StringTokenizer* tokenizer)
 {
-	string nextWord=getNextWord(tokenizer);
-	if (nextWord==")") {
-		return nextWord;
-	}
-	throw  ParseException("Expected ')' but encountered",nextWord);
+    string nextWord = getNextWord(tokenizer);
+    if(nextWord == ")") {
+        return nextWord;
+    }
+    throw  ParseException("Expected ')' but encountered", nextWord);
 }
 
 string
-WKTReader::getNextWord(StringTokenizer *tokenizer)
+WKTReader::getNextWord(StringTokenizer* tokenizer)
 {
-	int type=tokenizer->nextToken();
-	switch(type){
-		case StringTokenizer::TT_EOF:
-			throw  ParseException("Expected word but encountered end of stream");
-		case StringTokenizer::TT_EOL:
-			throw  ParseException("Expected word but encountered end of line");
-		case StringTokenizer::TT_NUMBER:
-			throw  ParseException("Expected word but encountered number", tokenizer->getNVal());
-		case StringTokenizer::TT_WORD:
-        {
-            string word = tokenizer->getSVal();
-            int i = static_cast<int>(word.size());
-
-            while( --i >= 0 )
-            {
-                word[i] = static_cast<char>(toupper(word[i]));
-            }
-			return word;
+    int type = tokenizer->nextToken();
+    switch(type) {
+    case StringTokenizer::TT_EOF:
+        throw  ParseException("Expected word but encountered end of stream");
+    case StringTokenizer::TT_EOL:
+        throw  ParseException("Expected word but encountered end of line");
+    case StringTokenizer::TT_NUMBER:
+        throw  ParseException("Expected word but encountered number", tokenizer->getNVal());
+    case StringTokenizer::TT_WORD: {
+        string word = tokenizer->getSVal();
+        int i = static_cast<int>(word.size());
+
+        while(--i >= 0) {
+            word[i] = static_cast<char>(toupper(word[i]));
         }
-		case '(':
-			return "(";
-		case ')':
-			return ")";
-		case ',':
-			return ",";
-	}
-	assert(0);
-	//throw  ParseException("Encountered unexpected StreamTokenizer type");
-	return "";
+        return word;
+    }
+    case '(':
+        return "(";
+    case ')':
+        return ")";
+    case ',':
+        return ",";
+    }
+    assert(0);
+    //throw  ParseException("Encountered unexpected StreamTokenizer type");
+    return "";
 }
 
 Geometry*
-WKTReader::readGeometryTaggedText(StringTokenizer *tokenizer)
+WKTReader::readGeometryTaggedText(StringTokenizer* tokenizer)
 {
-	string type = getNextWord(tokenizer);
-	if (type=="POINT") {
-		return readPointText(tokenizer);
-	} else if (type=="LINESTRING") {
-		return readLineStringText(tokenizer);
-	} else if (type=="LINEARRING") {
-		return readLinearRingText(tokenizer);
-	} else if (type=="POLYGON") {
-		return readPolygonText(tokenizer);
-	} else if (type=="MULTIPOINT") {
-		return readMultiPointText(tokenizer);
-	} else if (type=="MULTILINESTRING") {
-		return readMultiLineStringText(tokenizer);
-	} else if (type=="MULTIPOLYGON") {
-		return readMultiPolygonText(tokenizer);
-	} else if (type=="GEOMETRYCOLLECTION") {
-		return readGeometryCollectionText(tokenizer);
-	}
-	throw  ParseException("Unknown type",type);
+    string type = getNextWord(tokenizer);
+    if(type == "POINT") {
+        return readPointText(tokenizer);
+    }
+    else if(type == "LINESTRING") {
+        return readLineStringText(tokenizer);
+    }
+    else if(type == "LINEARRING") {
+        return readLinearRingText(tokenizer);
+    }
+    else if(type == "POLYGON") {
+        return readPolygonText(tokenizer);
+    }
+    else if(type == "MULTIPOINT") {
+        return readMultiPointText(tokenizer);
+    }
+    else if(type == "MULTILINESTRING") {
+        return readMultiLineStringText(tokenizer);
+    }
+    else if(type == "MULTIPOLYGON") {
+        return readMultiPolygonText(tokenizer);
+    }
+    else if(type == "GEOMETRYCOLLECTION") {
+        return readGeometryCollectionText(tokenizer);
+    }
+    throw  ParseException("Unknown type", type);
 }
 
 Point*
-WKTReader::readPointText(StringTokenizer *tokenizer)
+WKTReader::readPointText(StringTokenizer* tokenizer)
 {
-	size_t dim;
-	string nextToken=getNextEmptyOrOpener(tokenizer);
-	if (nextToken=="EMPTY") {
-		return geometryFactory->createPoint(Coordinate::getNull());
-	}
+    size_t dim;
+    string nextToken = getNextEmptyOrOpener(tokenizer);
+    if(nextToken == "EMPTY") {
+        return geometryFactory->createPoint(Coordinate::getNull());
+    }
 
-	Coordinate coord;
-	getPreciseCoordinate(tokenizer, coord, dim);
-	getNextCloser(tokenizer);
+    Coordinate coord;
+    getPreciseCoordinate(tokenizer, coord, dim);
+    getNextCloser(tokenizer);
 
-	return geometryFactory->createPoint(coord);
+    return geometryFactory->createPoint(coord);
 }
 
-LineString* WKTReader::readLineStringText(StringTokenizer *tokenizer) {
-	CoordinateSequence *coords = getCoordinates(tokenizer);
-	LineString *ret = geometryFactory->createLineString(coords);
-	return ret;
+LineString*
+WKTReader::readLineStringText(StringTokenizer* tokenizer)
+{
+    CoordinateSequence* coords = getCoordinates(tokenizer);
+    LineString* ret = geometryFactory->createLineString(coords);
+    return ret;
 }
 
-LinearRing* WKTReader::readLinearRingText(StringTokenizer *tokenizer) {
-	CoordinateSequence *coords = getCoordinates(tokenizer);
-	LinearRing *ret;
-	ret = geometryFactory->createLinearRing(coords);
-	return ret;
+LinearRing*
+WKTReader::readLinearRingText(StringTokenizer* tokenizer)
+{
+    CoordinateSequence* coords = getCoordinates(tokenizer);
+    LinearRing* ret;
+    ret = geometryFactory->createLinearRing(coords);
+    return ret;
 }
 
 MultiPoint*
-WKTReader::readMultiPointText(StringTokenizer *tokenizer)
+WKTReader::readMultiPointText(StringTokenizer* tokenizer)
 {
-	string nextToken=getNextEmptyOrOpener(tokenizer);
-	if (nextToken=="EMPTY") {
-		return geometryFactory->createMultiPoint();
-	}
-
-	int tok = tokenizer->peekNextToken();
-
-	if ( tok == StringTokenizer::TT_NUMBER )
-	{
-		size_t dim;
-
-		// Try to parse deprecated form "MULTIPOINT(0 0, 1 1)"
-		const CoordinateSequenceFactory* csf = \
-			geometryFactory->getCoordinateSequenceFactory();
-		CoordinateSequence *coords = csf->create();
-		try {
-			do {
-				Coordinate coord;
-				getPreciseCoordinate(tokenizer, coord, dim);
-				coords->add(coord);
-				nextToken=getNextCloserOrComma(tokenizer);
-			} while(nextToken == ",");
-
-			MultiPoint *ret = geometryFactory->createMultiPoint(*coords);
-			delete coords;
-			return ret;
-		} catch (...) {
-			delete coords;
-			throw;
-		}
-	}
-
-	else if ( tok == '(' )
-	{
-		// Try to parse correct form "MULTIPOINT((0 0), (1 1))"
-		vector<Geometry *> *points=new vector<Geometry *>();
-		try {
-			do {
-				Point *point=readPointText(tokenizer);
-				points->push_back(point);
-				nextToken=getNextCloserOrComma(tokenizer);
-			} while(nextToken == ",");
-			return geometryFactory->createMultiPoint(points);
-		} catch (...) {
-			// clean up
-			for (size_t i=0; i<points->size(); i++)
-			{
-				delete (*points)[i];
-			}
-			delete points;
-			throw;
-		}
-	}
-
-	else
-	{
-		stringstream err;
-		err << "Unexpected token: ";
-		switch (tok)
-		{
-			case StringTokenizer::TT_WORD:
-				err << "WORD " << tokenizer->getSVal();
-				break;
-			case StringTokenizer::TT_NUMBER:
-				err << "NUMBER " << tokenizer->getNVal();
-				break;
-			case StringTokenizer::TT_EOF:
-			case StringTokenizer::TT_EOL:
-				err << "EOF or EOL";
-				break;
-			case '(':
-				err << "(";
-				break;
-			case ')':
-				err << ")";
-				break;
-			case ',':
-				err << ",";
-				break;
-			default:
-				err << "??";
-				break;
-		}
-		err << endl;
-		throw ParseException(err.str());
-	}
+    string nextToken = getNextEmptyOrOpener(tokenizer);
+    if(nextToken == "EMPTY") {
+        return geometryFactory->createMultiPoint();
+    }
+
+    int tok = tokenizer->peekNextToken();
+
+    if(tok == StringTokenizer::TT_NUMBER) {
+        size_t dim;
+
+        // Try to parse deprecated form "MULTIPOINT(0 0, 1 1)"
+        const CoordinateSequenceFactory* csf = \
+                                               geometryFactory->getCoordinateSequenceFactory();
+        CoordinateSequence* coords = csf->create();
+        try {
+            do {
+                Coordinate coord;
+                getPreciseCoordinate(tokenizer, coord, dim);
+                coords->add(coord);
+                nextToken = getNextCloserOrComma(tokenizer);
+            }
+            while(nextToken == ",");
+
+            MultiPoint* ret = geometryFactory->createMultiPoint(*coords);
+            delete coords;
+            return ret;
+        }
+        catch(...) {
+            delete coords;
+            throw;
+        }
+    }
+
+    else if(tok == '(') {
+        // Try to parse correct form "MULTIPOINT((0 0), (1 1))"
+        vector<Geometry*>* points = new vector<Geometry*>();
+        try {
+            do {
+                Point* point = readPointText(tokenizer);
+                points->push_back(point);
+                nextToken = getNextCloserOrComma(tokenizer);
+            }
+            while(nextToken == ",");
+            return geometryFactory->createMultiPoint(points);
+        }
+        catch(...) {
+            // clean up
+            for(size_t i = 0; i < points->size(); i++) {
+                delete(*points)[i];
+            }
+            delete points;
+            throw;
+        }
+    }
+
+    else {
+        stringstream err;
+        err << "Unexpected token: ";
+        switch(tok) {
+        case StringTokenizer::TT_WORD:
+            err << "WORD " << tokenizer->getSVal();
+            break;
+        case StringTokenizer::TT_NUMBER:
+            err << "NUMBER " << tokenizer->getNVal();
+            break;
+        case StringTokenizer::TT_EOF:
+        case StringTokenizer::TT_EOL:
+            err << "EOF or EOL";
+            break;
+        case '(':
+            err << "(";
+            break;
+        case ')':
+            err << ")";
+            break;
+        case ',':
+            err << ",";
+            break;
+        default:
+            err << "??";
+            break;
+        }
+        err << endl;
+        throw ParseException(err.str());
+    }
 }
 
 Polygon*
-WKTReader::readPolygonText(StringTokenizer *tokenizer)
+WKTReader::readPolygonText(StringTokenizer* tokenizer)
 {
-	Polygon *poly=nullptr;
-	LinearRing *shell=nullptr;
-	string nextToken=getNextEmptyOrOpener(tokenizer);
-	if (nextToken=="EMPTY") {
-		return geometryFactory->createPolygon(nullptr,nullptr);
-	}
-
-	vector<Geometry *> *holes=new vector<Geometry *>();
-	try {
-		shell=readLinearRingText(tokenizer);
-		nextToken=getNextCloserOrComma(tokenizer);
-		while(nextToken==",") {
-			LinearRing *hole=readLinearRingText(tokenizer);
-			holes->push_back(hole);
-			nextToken=getNextCloserOrComma(tokenizer);
-		}
-		poly = geometryFactory->createPolygon(shell,holes);
-	} catch (...) {
-		for (unsigned int i=0; i<holes->size(); i++)
-			delete (*holes)[i];
-		delete holes;
-		delete shell;
-		throw;
-	}
-	return poly;
+    Polygon* poly = nullptr;
+    LinearRing* shell = nullptr;
+    string nextToken = getNextEmptyOrOpener(tokenizer);
+    if(nextToken == "EMPTY") {
+        return geometryFactory->createPolygon(nullptr, nullptr);
+    }
+
+    vector<Geometry*>* holes = new vector<Geometry*>();
+    try {
+        shell = readLinearRingText(tokenizer);
+        nextToken = getNextCloserOrComma(tokenizer);
+        while(nextToken == ",") {
+            LinearRing* hole = readLinearRingText(tokenizer);
+            holes->push_back(hole);
+            nextToken = getNextCloserOrComma(tokenizer);
+        }
+        poly = geometryFactory->createPolygon(shell, holes);
+    }
+    catch(...) {
+        for(unsigned int i = 0; i < holes->size(); i++) {
+            delete(*holes)[i];
+        }
+        delete holes;
+        delete shell;
+        throw;
+    }
+    return poly;
 }
 
-MultiLineString* WKTReader::readMultiLineStringText(StringTokenizer *tokenizer) {
-	string nextToken=getNextEmptyOrOpener(tokenizer);
-	if (nextToken=="EMPTY") {
-		return geometryFactory->createMultiLineString(nullptr);
-	}
-	vector<Geometry *> *lineStrings=new vector<Geometry *>();
-	LineString *lineString = nullptr;
-	try {
-		lineString=readLineStringText(tokenizer);
-		lineStrings->push_back(lineString);
-		lineString=nullptr;
-		nextToken=getNextCloserOrComma(tokenizer);
-		while(nextToken==",") {
-			lineString=readLineStringText(tokenizer);
-			lineStrings->push_back(lineString);
-			lineString=nullptr;
-			nextToken=getNextCloserOrComma(tokenizer);
-		}
-	} catch (...) {
-		for (size_t i=0; i < lineStrings->size(); i++)
-			delete (*lineStrings)[i];
-		delete lineStrings;
-		throw;
-	}
-	MultiLineString *ret = geometryFactory->createMultiLineString(lineStrings);
-	//for (int i=0; i<lineStrings->size(); i++) delete (*lineStrings)[i];
-	//delete lineStrings;
-	return ret;
+MultiLineString*
+WKTReader::readMultiLineStringText(StringTokenizer* tokenizer)
+{
+    string nextToken = getNextEmptyOrOpener(tokenizer);
+    if(nextToken == "EMPTY") {
+        return geometryFactory->createMultiLineString(nullptr);
+    }
+    vector<Geometry*>* lineStrings = new vector<Geometry*>();
+    LineString* lineString = nullptr;
+    try {
+        lineString = readLineStringText(tokenizer);
+        lineStrings->push_back(lineString);
+        lineString = nullptr;
+        nextToken = getNextCloserOrComma(tokenizer);
+        while(nextToken == ",") {
+            lineString = readLineStringText(tokenizer);
+            lineStrings->push_back(lineString);
+            lineString = nullptr;
+            nextToken = getNextCloserOrComma(tokenizer);
+        }
+    }
+    catch(...) {
+        for(size_t i = 0; i < lineStrings->size(); i++) {
+            delete(*lineStrings)[i];
+        }
+        delete lineStrings;
+        throw;
+    }
+    MultiLineString* ret = geometryFactory->createMultiLineString(lineStrings);
+    //for (int i=0; i<lineStrings->size(); i++) delete (*lineStrings)[i];
+    //delete lineStrings;
+    return ret;
 }
 
-MultiPolygon* WKTReader::readMultiPolygonText(StringTokenizer *tokenizer) {
-	string nextToken=getNextEmptyOrOpener(tokenizer);
-	if (nextToken=="EMPTY") {
-		return geometryFactory->createMultiPolygon(nullptr);
-	}
-	vector<Geometry *> *polygons=new vector<Geometry *>();
-	Polygon *polygon = nullptr;
-	try {
-		polygon=readPolygonText(tokenizer);
-		polygons->push_back(polygon);
-		polygon=nullptr;
-		nextToken=getNextCloserOrComma(tokenizer);
-		while(nextToken==",") {
-			polygon=readPolygonText(tokenizer);
-			polygons->push_back(polygon);
-			polygon=nullptr;
-			nextToken=getNextCloserOrComma(tokenizer);
-		}
-	} catch (...) {
-		for (size_t i=0; i < polygons->size(); i++)
-			delete (*polygons)[i];
-		delete polygons;
-		throw;
-	}
-	MultiPolygon *ret = geometryFactory->createMultiPolygon(polygons);
-	//for (int i=0; i<polygons->size(); i++) delete (*polygons)[i];
-	//delete polygons;
-	return ret;
+MultiPolygon*
+WKTReader::readMultiPolygonText(StringTokenizer* tokenizer)
+{
+    string nextToken = getNextEmptyOrOpener(tokenizer);
+    if(nextToken == "EMPTY") {
+        return geometryFactory->createMultiPolygon(nullptr);
+    }
+    vector<Geometry*>* polygons = new vector<Geometry*>();
+    Polygon* polygon = nullptr;
+    try {
+        polygon = readPolygonText(tokenizer);
+        polygons->push_back(polygon);
+        polygon = nullptr;
+        nextToken = getNextCloserOrComma(tokenizer);
+        while(nextToken == ",") {
+            polygon = readPolygonText(tokenizer);
+            polygons->push_back(polygon);
+            polygon = nullptr;
+            nextToken = getNextCloserOrComma(tokenizer);
+        }
+    }
+    catch(...) {
+        for(size_t i = 0; i < polygons->size(); i++) {
+            delete(*polygons)[i];
+        }
+        delete polygons;
+        throw;
+    }
+    MultiPolygon* ret = geometryFactory->createMultiPolygon(polygons);
+    //for (int i=0; i<polygons->size(); i++) delete (*polygons)[i];
+    //delete polygons;
+    return ret;
 }
 
-GeometryCollection* WKTReader::readGeometryCollectionText(StringTokenizer *tokenizer) {
-	string nextToken=getNextEmptyOrOpener(tokenizer);
-	if (nextToken=="EMPTY") {
-		return geometryFactory->createGeometryCollection(nullptr);
-	}
-	vector<Geometry *> *geoms=new vector<Geometry *>();
-	Geometry *geom=nullptr;
-	try {
-		geom=readGeometryTaggedText(tokenizer);
-		geoms->push_back(geom);
-		geom=nullptr;
-		nextToken=getNextCloserOrComma(tokenizer);
-		while(nextToken==",") {
-			geom=readGeometryTaggedText(tokenizer);
-			geoms->push_back(geom);
-			geom=nullptr;
-			nextToken=getNextCloserOrComma(tokenizer);
-		}
-	} catch (...) {
-		for (size_t i=0; i < geoms->size(); i++)
-			delete (*geoms)[i];
-		delete geoms;
-		throw;
-	}
-	GeometryCollection *ret = geometryFactory->createGeometryCollection(geoms);
-	//for (int i=0; i<geoms->size(); i++) delete (*geoms)[i];
-	//delete geoms;
-	return ret;
+GeometryCollection*
+WKTReader::readGeometryCollectionText(StringTokenizer* tokenizer)
+{
+    string nextToken = getNextEmptyOrOpener(tokenizer);
+    if(nextToken == "EMPTY") {
+        return geometryFactory->createGeometryCollection(nullptr);
+    }
+    vector<Geometry*>* geoms = new vector<Geometry*>();
+    Geometry* geom = nullptr;
+    try {
+        geom = readGeometryTaggedText(tokenizer);
+        geoms->push_back(geom);
+        geom = nullptr;
+        nextToken = getNextCloserOrComma(tokenizer);
+        while(nextToken == ",") {
+            geom = readGeometryTaggedText(tokenizer);
+            geoms->push_back(geom);
+            geom = nullptr;
+            nextToken = getNextCloserOrComma(tokenizer);
+        }
+    }
+    catch(...) {
+        for(size_t i = 0; i < geoms->size(); i++) {
+            delete(*geoms)[i];
+        }
+        delete geoms;
+        throw;
+    }
+    GeometryCollection* ret = geometryFactory->createGeometryCollection(geoms);
+    //for (int i=0; i<geoms->size(); i++) delete (*geoms)[i];
+    //delete geoms;
+    return ret;
 }
 
 } // namespace geos.io
diff --git a/src/io/WKTWriter.cpp b/src/io/WKTWriter.cpp
index f1704c5..7a67bb6 100644
--- a/src/io/WKTWriter.cpp
+++ b/src/io/WKTWriter.cpp
@@ -49,13 +49,13 @@ namespace geos {
 namespace io { // geos.io
 
 WKTWriter::WKTWriter():
-  decimalPlaces(6),
-	isFormatted(false),
-	roundingPrecision(-1),
-	trim(false),
-	level(0),
-	defaultOutputDimension(2),
-	old3D(false)
+    decimalPlaces(6),
+    isFormatted(false),
+    roundingPrecision(-1),
+    trim(false),
+    level(0),
+    defaultOutputDimension(2),
+    old3D(false)
 {
 }
 
@@ -63,9 +63,10 @@ WKTWriter::WKTWriter():
 void
 WKTWriter::setOutputDimension(int dims)
 {
-	if ( dims < 2 || dims > 3 )
-		throw util::IllegalArgumentException("WKT output dimension must be 2 or 3");
-	defaultOutputDimension = dims;
+    if(dims < 2 || dims > 3) {
+        throw util::IllegalArgumentException("WKT output dimension must be 2 or 3");
+    }
+    defaultOutputDimension = dims;
 }
 
 WKTWriter::~WKTWriter() {}
@@ -74,182 +75,183 @@ WKTWriter::~WKTWriter() {}
 string
 WKTWriter::toLineString(const CoordinateSequence& seq)
 {
-	stringstream buf(ios_base::in|ios_base::out);
+    stringstream buf(ios_base::in | ios_base::out);
     buf << "LINESTRING ";
-	auto npts = seq.size();
-	if ( npts == 0 )
-	{
-		buf << "EMPTY";
-	}
-	else
-	{
-		buf << "(";
-		for (size_t i = 0; i < npts; ++i)
-		{
-			if (i) buf << ", ";
-			buf << seq.getX(i) << " " << seq.getY(i);
+    auto npts = seq.size();
+    if(npts == 0) {
+        buf << "EMPTY";
+    }
+    else {
+        buf << "(";
+        for(size_t i = 0; i < npts; ++i) {
+            if(i) {
+                buf << ", ";
+            }
+            buf << seq.getX(i) << " " << seq.getY(i);
 #if PRINT_Z
-			buf << seq.getZ(i);
+            buf << seq.getZ(i);
 #endif
-		}
-		buf << ")";
-	}
+        }
+        buf << ")";
+    }
 
-	return buf.str();
+    return buf.str();
 }
 
 /*static*/
 string
 WKTWriter::toLineString(const Coordinate& p0, const Coordinate& p1)
 {
-	stringstream ret(ios_base::in|ios_base::out);
-	ret << "LINESTRING (" << p0.x << " " << p0.y;
+    stringstream ret(ios_base::in | ios_base::out);
+    ret << "LINESTRING (" << p0.x << " " << p0.y;
 #if PRINT_Z
-	ret << " " << p0.z;
+    ret << " " << p0.z;
 #endif
-	ret << ", " << p1.x << " " << p1.y;
+    ret << ", " << p1.x << " " << p1.y;
 #if PRINT_Z
-	ret << " " << p1.z;
+    ret << " " << p1.z;
 #endif
     ret << ")";
 
-	return ret.str();
+    return ret.str();
 }
 
 /*static*/
 string
 WKTWriter::toPoint(const Coordinate& p0)
 {
-	stringstream ret(ios_base::in|ios_base::out);
+    stringstream ret(ios_base::in | ios_base::out);
     ret << "POINT (";
 #if PRINT_Z
-	ret << p0.x << " " << p0.y  << " " << p0.z << " )";
+    ret << p0.x << " " << p0.y  << " " << p0.z << " )";
 #else
-	ret << p0.x << " " << p0.y  << " )";
+    ret << p0.x << " " << p0.y  << " )";
 #endif
-	return ret.str();
+    return ret.str();
 }
 
 void
 WKTWriter::setRoundingPrecision(int p0)
 {
-	if(p0 < -1) {
-		p0 = -1;
-	}
-	roundingPrecision = p0;
+    if(p0 < -1) {
+        p0 = -1;
+    }
+    roundingPrecision = p0;
 }
 
 void
 WKTWriter::setTrim(bool p0)
 {
-	trim = p0;
+    trim = p0;
 }
 
-string WKTWriter::write(const Geometry *geometry) {
-	Writer sw;
-  writeFormatted(geometry,false,&sw);
-	string res=sw.toString();
-	return res;
+string
+WKTWriter::write(const Geometry* geometry)
+{
+    Writer sw;
+    writeFormatted(geometry, false, &sw);
+    string res = sw.toString();
+    return res;
 }
 
-void WKTWriter::write(const Geometry *geometry, Writer *writer) {
-	writeFormatted(geometry, false, writer);
+void
+WKTWriter::write(const Geometry* geometry, Writer* writer)
+{
+    writeFormatted(geometry, false, writer);
 }
 
-string WKTWriter::writeFormatted(const Geometry *geometry) {
-	Writer sw;
-	writeFormatted(geometry, true, &sw);
-	return sw.toString();
+string
+WKTWriter::writeFormatted(const Geometry* geometry)
+{
+    Writer sw;
+    writeFormatted(geometry, true, &sw);
+    return sw.toString();
 }
 
-void WKTWriter::writeFormatted(const Geometry *geometry, Writer *writer) {
-	writeFormatted(geometry, true, writer);
+void
+WKTWriter::writeFormatted(const Geometry* geometry, Writer* writer)
+{
+    writeFormatted(geometry, true, writer);
 }
 
 void
-WKTWriter::writeFormatted(const Geometry *geometry, bool p_isFormatted,
-                          Writer *writer)
+WKTWriter::writeFormatted(const Geometry* geometry, bool p_isFormatted,
+                          Writer* writer)
 {
-        CLocalizer clocale;
-	this->isFormatted=p_isFormatted;
-  decimalPlaces = roundingPrecision == -1 ? geometry->getPrecisionModel()->getMaximumSignificantDigits() : roundingPrecision;
-	appendGeometryTaggedText(geometry, 0, writer);
+    CLocalizer clocale;
+    this->isFormatted = p_isFormatted;
+    decimalPlaces = roundingPrecision == -1 ? geometry->getPrecisionModel()->getMaximumSignificantDigits() :
+                    roundingPrecision;
+    appendGeometryTaggedText(geometry, 0, writer);
 }
 
 void
-WKTWriter::appendGeometryTaggedText(const Geometry *geometry, int p_level,
-		Writer *writer)
+WKTWriter::appendGeometryTaggedText(const Geometry* geometry, int p_level,
+                                    Writer* writer)
 {
-  outputDimension = std::min( defaultOutputDimension,
-                         geometry->getCoordinateDimension() );
-
-  indent(p_level, writer);
-  if ( const Point* point = dynamic_cast<const Point*>(geometry) )
-  {
-    appendPointTaggedText(point->getCoordinate(),p_level,writer);
-  }
-  else if ( const LinearRing* lr =
-    dynamic_cast<const LinearRing*>(geometry) )
-  {
-    appendLinearRingTaggedText(lr, p_level, writer);
-  }
-  else if ( const LineString* ls =
-    dynamic_cast<const LineString*>(geometry) )
-  {
-    appendLineStringTaggedText(ls, p_level, writer);
-  }
-  else if ( const Polygon* x1 =
-    dynamic_cast<const Polygon*>(geometry) )
-  {
-    appendPolygonTaggedText(x1, p_level, writer);
-  }
-  else if ( const MultiPoint* x2 =
-    dynamic_cast<const MultiPoint*>(geometry) )
-  {
-    appendMultiPointTaggedText(x2, p_level, writer);
-  }
-  else if ( const MultiLineString* x3 =
-    dynamic_cast<const MultiLineString*>(geometry) )
-  {
-    appendMultiLineStringTaggedText(x3, p_level, writer);
-  }
-  else if ( const MultiPolygon* x4 =
-    dynamic_cast<const MultiPolygon*>(geometry) )
-  {
-    appendMultiPolygonTaggedText(x4, p_level, writer);
-  }
-  else if ( const GeometryCollection* x5 =
-    dynamic_cast<const GeometryCollection*>(geometry) )
-  {
-    appendGeometryCollectionTaggedText(x5, p_level, writer);
-  }
-  else
-  {
-    assert(0); // Unsupported Geometry implementation
-  }
+    outputDimension = std::min(defaultOutputDimension,
+                               geometry->getCoordinateDimension());
+
+    indent(p_level, writer);
+    if(const Point* point = dynamic_cast<const Point*>(geometry)) {
+        appendPointTaggedText(point->getCoordinate(), p_level, writer);
+    }
+    else if(const LinearRing* lr =
+                dynamic_cast<const LinearRing*>(geometry)) {
+        appendLinearRingTaggedText(lr, p_level, writer);
+    }
+    else if(const LineString* ls =
+                dynamic_cast<const LineString*>(geometry)) {
+        appendLineStringTaggedText(ls, p_level, writer);
+    }
+    else if(const Polygon* x1 =
+                dynamic_cast<const Polygon*>(geometry)) {
+        appendPolygonTaggedText(x1, p_level, writer);
+    }
+    else if(const MultiPoint* x2 =
+                dynamic_cast<const MultiPoint*>(geometry)) {
+        appendMultiPointTaggedText(x2, p_level, writer);
+    }
+    else if(const MultiLineString* x3 =
+                dynamic_cast<const MultiLineString*>(geometry)) {
+        appendMultiLineStringTaggedText(x3, p_level, writer);
+    }
+    else if(const MultiPolygon* x4 =
+                dynamic_cast<const MultiPolygon*>(geometry)) {
+        appendMultiPolygonTaggedText(x4, p_level, writer);
+    }
+    else if(const GeometryCollection* x5 =
+                dynamic_cast<const GeometryCollection*>(geometry)) {
+        appendGeometryCollectionTaggedText(x5, p_level, writer);
+    }
+    else {
+        assert(0); // Unsupported Geometry implementation
+    }
 }
 
 /*protected*/
 void
 WKTWriter::appendPointTaggedText(const Coordinate* coordinate, int p_level,
-		Writer *writer)
+                                 Writer* writer)
 {
-	writer->write("POINT ");
-	if( outputDimension == 3 && !old3D && coordinate != nullptr )
-		writer->write( "Z " );
+    writer->write("POINT ");
+    if(outputDimension == 3 && !old3D && coordinate != nullptr) {
+        writer->write("Z ");
+    }
 
-	appendPointText(coordinate, p_level, writer);
+    appendPointText(coordinate, p_level, writer);
 }
 
 void
-WKTWriter::appendLineStringTaggedText(const LineString *lineString, int p_level,
-		Writer *writer)
+WKTWriter::appendLineStringTaggedText(const LineString* lineString, int p_level,
+                                      Writer* writer)
 {
-	writer->write("LINESTRING ");
-	if( outputDimension == 3 && !old3D && !lineString->isEmpty() )
-		writer->write( "Z " );
+    writer->write("LINESTRING ");
+    if(outputDimension == 3 && !old3D && !lineString->isEmpty()) {
+        writer->write("Z ");
+    }
 
-	appendLineStringText(lineString, p_level, false, writer);
+    appendLineStringText(lineString, p_level, false, writer);
 }
 
 /*
@@ -259,230 +261,270 @@ WKTWriter::appendLineStringTaggedText(const LineString *lineString, int p_level,
  * @param  linearRing  the <code>LinearRing</code> to process
  * @param  writer      the output writer to append to
  */
-void WKTWriter::appendLinearRingTaggedText(const LinearRing* linearRing, int p_level, Writer *writer) {
-	writer->write("LINEARRING ");
-	if( outputDimension == 3 && !old3D && !linearRing->isEmpty() )
-		writer->write( "Z " );
-	appendLineStringText((LineString*)linearRing, p_level, false, writer);
+void
+WKTWriter::appendLinearRingTaggedText(const LinearRing* linearRing, int p_level, Writer* writer)
+{
+    writer->write("LINEARRING ");
+    if(outputDimension == 3 && !old3D && !linearRing->isEmpty()) {
+        writer->write("Z ");
+    }
+    appendLineStringText((LineString*)linearRing, p_level, false, writer);
 }
 
-void WKTWriter::appendPolygonTaggedText(const Polygon *polygon, int p_level, Writer *writer) {
-	writer->write("POLYGON ");
-	if( outputDimension == 3 && !old3D && !polygon->isEmpty())
-		writer->write( "Z " );
-	appendPolygonText(polygon, p_level, false, writer);
+void
+WKTWriter::appendPolygonTaggedText(const Polygon* polygon, int p_level, Writer* writer)
+{
+    writer->write("POLYGON ");
+    if(outputDimension == 3 && !old3D && !polygon->isEmpty()) {
+        writer->write("Z ");
+    }
+    appendPolygonText(polygon, p_level, false, writer);
 }
 
-void WKTWriter::appendMultiPointTaggedText(const MultiPoint *multipoint, int p_level, Writer *writer) {
-	writer->write("MULTIPOINT ");
-	if( outputDimension == 3 && !old3D && !multipoint->isEmpty() )
-		writer->write( "Z " );
-	appendMultiPointText(multipoint, p_level, writer);
+void
+WKTWriter::appendMultiPointTaggedText(const MultiPoint* multipoint, int p_level, Writer* writer)
+{
+    writer->write("MULTIPOINT ");
+    if(outputDimension == 3 && !old3D && !multipoint->isEmpty()) {
+        writer->write("Z ");
+    }
+    appendMultiPointText(multipoint, p_level, writer);
 }
 
-void WKTWriter::appendMultiLineStringTaggedText(const MultiLineString *multiLineString, int p_level,Writer *writer) {
-	writer->write("MULTILINESTRING ");
-	if( outputDimension == 3 && !old3D && !multiLineString->isEmpty() )
-		writer->write( "Z " );
-	appendMultiLineStringText(multiLineString, p_level, false, writer);
+void
+WKTWriter::appendMultiLineStringTaggedText(const MultiLineString* multiLineString, int p_level, Writer* writer)
+{
+    writer->write("MULTILINESTRING ");
+    if(outputDimension == 3 && !old3D && !multiLineString->isEmpty()) {
+        writer->write("Z ");
+    }
+    appendMultiLineStringText(multiLineString, p_level, false, writer);
 }
 
-void WKTWriter::appendMultiPolygonTaggedText(const MultiPolygon *multiPolygon, int p_level, Writer *writer) {
-	writer->write("MULTIPOLYGON ");
-	if( outputDimension == 3 && !old3D && !multiPolygon->isEmpty() )
-		writer->write( "Z " );
-	appendMultiPolygonText(multiPolygon, p_level, writer);
+void
+WKTWriter::appendMultiPolygonTaggedText(const MultiPolygon* multiPolygon, int p_level, Writer* writer)
+{
+    writer->write("MULTIPOLYGON ");
+    if(outputDimension == 3 && !old3D && !multiPolygon->isEmpty()) {
+        writer->write("Z ");
+    }
+    appendMultiPolygonText(multiPolygon, p_level, writer);
 }
 
-void WKTWriter::appendGeometryCollectionTaggedText(const GeometryCollection *geometryCollection, int p_level,Writer *writer) {
-	writer->write("GEOMETRYCOLLECTION ");
-	if( outputDimension == 3 && !old3D && !geometryCollection->isEmpty() )
-		writer->write( "Z " );
-	appendGeometryCollectionText(geometryCollection, p_level, writer);
+void
+WKTWriter::appendGeometryCollectionTaggedText(const GeometryCollection* geometryCollection, int p_level,
+        Writer* writer)
+{
+    writer->write("GEOMETRYCOLLECTION ");
+    if(outputDimension == 3 && !old3D && !geometryCollection->isEmpty()) {
+        writer->write("Z ");
+    }
+    appendGeometryCollectionText(geometryCollection, p_level, writer);
 }
 
 void
 WKTWriter::appendPointText(const Coordinate* coordinate, int /*level*/,
-		Writer *writer)
+                           Writer* writer)
 {
-	if (coordinate==nullptr) {
-		writer->write("EMPTY");
-	} else {
-		writer->write("(");
-		appendCoordinate(coordinate, writer);
-		writer->write(")");
-	}
+    if(coordinate == nullptr) {
+        writer->write("EMPTY");
+    }
+    else {
+        writer->write("(");
+        appendCoordinate(coordinate, writer);
+        writer->write(")");
+    }
 }
 
 /* protected */
 void
 WKTWriter::appendCoordinate(const Coordinate* coordinate,
-		Writer *writer)
+                            Writer* writer)
 {
-	writer->write(writeNumber(coordinate->x));
-	writer->write(" ");
-	writer->write(writeNumber(coordinate->y));
-	if( outputDimension == 3 )
-	{
-		writer->write(" ");
-		if( std::isnan(coordinate->z) )
-			writer->write(writeNumber(0.0));
-		else
-			writer->write(writeNumber(coordinate->z));
-	}
+    writer->write(writeNumber(coordinate->x));
+    writer->write(" ");
+    writer->write(writeNumber(coordinate->y));
+    if(outputDimension == 3) {
+        writer->write(" ");
+        if(std::isnan(coordinate->z)) {
+            writer->write(writeNumber(0.0));
+        }
+        else {
+            writer->write(writeNumber(coordinate->z));
+        }
+    }
 }
 
 /* protected */
 string
-WKTWriter::writeNumber(double d) {
+WKTWriter::writeNumber(double d)
+{
 
-  std::stringstream ss;
+    std::stringstream ss;
 
-  if ( ! trim ) ss << std::fixed;
-  ss << std::setprecision(decimalPlaces >= 0 ? decimalPlaces : 0) << d;
+    if(! trim) {
+        ss << std::fixed;
+    }
+    ss << std::setprecision(decimalPlaces >= 0 ? decimalPlaces : 0) << d;
 
-	return ss.str();
+    return ss.str();
 }
 
 void
-WKTWriter::appendLineStringText(const LineString *lineString, int p_level,
-		bool doIndent, Writer *writer)
+WKTWriter::appendLineStringText(const LineString* lineString, int p_level,
+                                bool doIndent, Writer* writer)
 {
-	if (lineString->isEmpty()) {
-		writer->write("EMPTY");
-	} else {
-		if (doIndent) indent(p_level, writer);
-		writer->write("(");
-		for(size_t i=0, n=lineString->getNumPoints(); i<n; ++i)
-		{
-			if (i>0) {
-				writer->write(", ");
-				if (i%10==0) indent(p_level + 2, writer);
-			}
-			appendCoordinate(&(lineString->getCoordinateN(i)), writer);
-		}
-		writer->write(")");
-	}
+    if(lineString->isEmpty()) {
+        writer->write("EMPTY");
+    }
+    else {
+        if(doIndent) {
+            indent(p_level, writer);
+        }
+        writer->write("(");
+        for(size_t i = 0, n = lineString->getNumPoints(); i < n; ++i) {
+            if(i > 0) {
+                writer->write(", ");
+                if(i % 10 == 0) {
+                    indent(p_level + 2, writer);
+                }
+            }
+            appendCoordinate(&(lineString->getCoordinateN(i)), writer);
+        }
+        writer->write(")");
+    }
 }
 
 void
-WKTWriter::appendPolygonText(const Polygon *polygon, int /*level*/,
-		bool indentFirst, Writer *writer)
+WKTWriter::appendPolygonText(const Polygon* polygon, int /*level*/,
+                             bool indentFirst, Writer* writer)
 {
-	if (polygon->isEmpty()) {
-		writer->write("EMPTY");
-	} else {
-		if (indentFirst) indent(level, writer);
-		writer->write("(");
-		appendLineStringText(polygon->getExteriorRing(), level, false, writer);
-		for (size_t i=0, n=polygon->getNumInteriorRing(); i<n; ++i)
-		{
-			writer->write(", ");
-			const LineString *ls=polygon->getInteriorRingN(i);
-			appendLineStringText(ls, level + 1, true, writer);
-		}
-		writer->write(")");
-	}
+    if(polygon->isEmpty()) {
+        writer->write("EMPTY");
+    }
+    else {
+        if(indentFirst) {
+            indent(level, writer);
+        }
+        writer->write("(");
+        appendLineStringText(polygon->getExteriorRing(), level, false, writer);
+        for(size_t i = 0, n = polygon->getNumInteriorRing(); i < n; ++i) {
+            writer->write(", ");
+            const LineString* ls = polygon->getInteriorRingN(i);
+            appendLineStringText(ls, level + 1, true, writer);
+        }
+        writer->write(")");
+    }
 }
 
 void
-WKTWriter::appendMultiPointText(const MultiPoint *multiPoint,
-		int /*level*/, Writer *writer)
+WKTWriter::appendMultiPointText(const MultiPoint* multiPoint,
+                                int /*level*/, Writer* writer)
 {
-	if (multiPoint->isEmpty()) {
-		writer->write("EMPTY");
-	} else {
-		writer->write("(");
-		for (size_t i = 0, n = multiPoint->getNumGeometries();
-				i < n; ++i)
-		{
-			if (i > 0) writer->write(", ");
-
-			appendCoordinate(
-				dynamic_cast<const Point*>(multiPoint->getGeometryN(i))->getCoordinate(),
-				writer);
-		}
-		writer->write(")");
-	}
+    if(multiPoint->isEmpty()) {
+        writer->write("EMPTY");
+    }
+    else {
+        writer->write("(");
+        for(size_t i = 0, n = multiPoint->getNumGeometries();
+                i < n; ++i) {
+            if(i > 0) {
+                writer->write(", ");
+            }
+
+            appendCoordinate(
+                dynamic_cast<const Point*>(multiPoint->getGeometryN(i))->getCoordinate(),
+                writer);
+        }
+        writer->write(")");
+    }
 }
 
-void WKTWriter::appendMultiLineStringText(const MultiLineString *multiLineString, int p_level, bool indentFirst,
-											Writer *writer) {
-	if (multiLineString->isEmpty()) {
-		writer->write("EMPTY");
-	} else {
-		int level2=p_level;
-		bool doIndent=indentFirst;
-		writer->write("(");
-		for (size_t i = 0, n = multiLineString->getNumGeometries();
-				i < n; ++i)
-		{
-			if (i>0) {
-				writer->write(", ");
-				level2=p_level+1;
-				doIndent=true;
-			}
-			const LineString* ls = dynamic_cast<const LineString *>(
-			  multiLineString->getGeometryN(i)
-			);
-			appendLineStringText(ls, level2, doIndent, writer);
-		}
-		writer->write(")");
-	}
+void
+WKTWriter::appendMultiLineStringText(const MultiLineString* multiLineString, int p_level, bool indentFirst,
+                                     Writer* writer)
+{
+    if(multiLineString->isEmpty()) {
+        writer->write("EMPTY");
+    }
+    else {
+        int level2 = p_level;
+        bool doIndent = indentFirst;
+        writer->write("(");
+        for(size_t i = 0, n = multiLineString->getNumGeometries();
+                i < n; ++i) {
+            if(i > 0) {
+                writer->write(", ");
+                level2 = p_level + 1;
+                doIndent = true;
+            }
+            const LineString* ls = dynamic_cast<const LineString*>(
+                                       multiLineString->getGeometryN(i)
+                                   );
+            appendLineStringText(ls, level2, doIndent, writer);
+        }
+        writer->write(")");
+    }
 }
 
-void WKTWriter::appendMultiPolygonText(const MultiPolygon *multiPolygon, int p_level, Writer *writer) {
-	if (multiPolygon->isEmpty()) {
-		writer->write("EMPTY");
-	} else {
-		int level2=p_level;
-		bool doIndent=false;
-		writer->write("(");
-		for (size_t i = 0, n = multiPolygon->getNumGeometries();
-				i < n; ++i)
-		{
-			if (i>0) {
-				writer->write(", ");
-				level2=p_level+1;
-				doIndent=true;
-			}
-			const Polygon *p = dynamic_cast<const Polygon *>(
-			  multiPolygon->getGeometryN(i)
-			);
-			appendPolygonText(p, level2, doIndent, writer);
-		}
-		writer->write(")");
-	}
+void
+WKTWriter::appendMultiPolygonText(const MultiPolygon* multiPolygon, int p_level, Writer* writer)
+{
+    if(multiPolygon->isEmpty()) {
+        writer->write("EMPTY");
+    }
+    else {
+        int level2 = p_level;
+        bool doIndent = false;
+        writer->write("(");
+        for(size_t i = 0, n = multiPolygon->getNumGeometries();
+                i < n; ++i) {
+            if(i > 0) {
+                writer->write(", ");
+                level2 = p_level + 1;
+                doIndent = true;
+            }
+            const Polygon* p = dynamic_cast<const Polygon*>(
+                                   multiPolygon->getGeometryN(i)
+                               );
+            appendPolygonText(p, level2, doIndent, writer);
+        }
+        writer->write(")");
+    }
 }
 
 void
 WKTWriter::appendGeometryCollectionText(
-		const GeometryCollection *geometryCollection,
-		int p_level,
-		Writer *writer)
+    const GeometryCollection* geometryCollection,
+    int p_level,
+    Writer* writer)
 {
-	if (geometryCollection->isEmpty()) {
-		writer->write("EMPTY");
-	} else {
-		int level2=p_level;
-		writer->write("(");
-		for (size_t i = 0, n = geometryCollection->getNumGeometries();
-				i < n; ++i)
-		{
-			if (i>0) {
-				writer->write(", ");
-				level2=p_level+1;
-			}
-			appendGeometryTaggedText(geometryCollection->getGeometryN(i),level2,writer);
-		}
-		writer->write(")");
-	}
+    if(geometryCollection->isEmpty()) {
+        writer->write("EMPTY");
+    }
+    else {
+        int level2 = p_level;
+        writer->write("(");
+        for(size_t i = 0, n = geometryCollection->getNumGeometries();
+                i < n; ++i) {
+            if(i > 0) {
+                writer->write(", ");
+                level2 = p_level + 1;
+            }
+            appendGeometryTaggedText(geometryCollection->getGeometryN(i), level2, writer);
+        }
+        writer->write(")");
+    }
 }
 
-void WKTWriter::indent(int p_level, Writer *writer) {
-	if (!isFormatted || p_level<=0) return;
-	writer->write("\n");
-	writer->write(string(INDENT * p_level, ' '));
+void
+WKTWriter::indent(int p_level, Writer* writer)
+{
+    if(!isFormatted || p_level <= 0) {
+        return;
+    }
+    writer->write("\n");
+    writer->write(string(INDENT * p_level, ' '));
 }
 
 } // namespace geos.io
diff --git a/src/io/Writer.cpp b/src/io/Writer.cpp
index 707b46c..363e09f 100644
--- a/src/io/Writer.cpp
+++ b/src/io/Writer.cpp
@@ -32,7 +32,7 @@ Writer::Writer()
 void
 Writer::reserve(std::size_t capacity)
 {
-  str.reserve(capacity);
+    str.reserve(capacity);
 }
 
 Writer::~Writer()
@@ -42,13 +42,13 @@ Writer::~Writer()
 void
 Writer::write(const std::string& txt)
 {
-	str.append(txt);
+    str.append(txt);
 }
 
 const std::string&
 Writer::toString()
 {
-	return str;
+    return str;
 }
 
 } // namespace geos.io
diff --git a/src/linearref/ExtractLineByLocation.cpp b/src/linearref/ExtractLineByLocation.cpp
index e044955..2da4548 100644
--- a/src/linearref/ExtractLineByLocation.cpp
+++ b/src/linearref/ExtractLineByLocation.cpp
@@ -35,143 +35,128 @@ using namespace std;
 
 using namespace geos::geom;
 
-namespace geos
-{
-namespace linearref   // geos.linearref
-{
+namespace geos {
+namespace linearref { // geos.linearref
 
 
-Geometry *ExtractLineByLocation::extract(const Geometry *line, const LinearLocation& start, const LinearLocation& end)
+Geometry*
+ExtractLineByLocation::extract(const Geometry* line, const LinearLocation& start, const LinearLocation& end)
 {
-	ExtractLineByLocation ls(line);
-	return ls.extract(start, end);
+    ExtractLineByLocation ls(line);
+    return ls.extract(start, end);
 }
 
-ExtractLineByLocation::ExtractLineByLocation(const Geometry *p_line) :
-		line(p_line) {}
+ExtractLineByLocation::ExtractLineByLocation(const Geometry* p_line) :
+    line(p_line) {}
 
 
-Geometry *ExtractLineByLocation::extract(const LinearLocation& start, const LinearLocation& end)
+Geometry*
+ExtractLineByLocation::extract(const LinearLocation& start, const LinearLocation& end)
 {
-	if (end.compareTo(start) < 0)
-	{
-		Geometry* backwards = computeLinear(end, start);
-		Geometry* forwards = reverse(backwards);
-		delete backwards;
-		return forwards;
-	}
-	return computeLinear(start, end);
+    if(end.compareTo(start) < 0) {
+        Geometry* backwards = computeLinear(end, start);
+        Geometry* forwards = reverse(backwards);
+        delete backwards;
+        return forwards;
+    }
+    return computeLinear(start, end);
 }
 
-Geometry *ExtractLineByLocation::reverse(const Geometry *linear)
+Geometry*
+ExtractLineByLocation::reverse(const Geometry* linear)
 {
-	const LineString* ls = dynamic_cast<const LineString *>(linear);
-	if (ls)
-	{
-		return ls->reverse();
-	}
-	else
-	{
-		const MultiLineString* mls = dynamic_cast<const MultiLineString *>(linear);
-		if (mls)
-		{
-			return mls->reverse();
-		}
-		else
-		{
-			assert(!static_cast<bool>("non-linear geometry encountered"));
+    const LineString* ls = dynamic_cast<const LineString*>(linear);
+    if(ls) {
+        return ls->reverse();
+    }
+    else {
+        const MultiLineString* mls = dynamic_cast<const MultiLineString*>(linear);
+        if(mls) {
+            return mls->reverse();
+        }
+        else {
+            assert(!static_cast<bool>("non-linear geometry encountered"));
             return nullptr;
-		}
-	}
+        }
+    }
 }
 
-LineString* ExtractLineByLocation::computeLine(const LinearLocation& start, const LinearLocation& end)
+LineString*
+ExtractLineByLocation::computeLine(const LinearLocation& start, const LinearLocation& end)
 {
-	CoordinateSequence* coordinates = line->getCoordinates();
-	CoordinateArraySequence newCoordinateArray;
+    CoordinateSequence* coordinates = line->getCoordinates();
+    CoordinateArraySequence newCoordinateArray;
 
     const size_t indexStep = 1;
-	auto startSegmentIndex = start.getSegmentIndex();
+    auto startSegmentIndex = start.getSegmentIndex();
 
-	if (start.getSegmentFraction() > 0.0)
-    {
-		startSegmentIndex += indexStep;
+    if(start.getSegmentFraction() > 0.0) {
+        startSegmentIndex += indexStep;
     }
 
     auto lastSegmentIndex = end.getSegmentIndex();
-	if (end.getSegmentFraction() == 1.0)
-    {
-		lastSegmentIndex += indexStep;
+    if(end.getSegmentFraction() == 1.0) {
+        lastSegmentIndex += indexStep;
     }
 
-	if (lastSegmentIndex >= coordinates->size())
-    {
+    if(lastSegmentIndex >= coordinates->size()) {
         assert(!coordinates->isEmpty());
         lastSegmentIndex = coordinates->size() - indexStep;
     }
 
-	if (! start.isVertex())
-    {
-		newCoordinateArray.add(start.getCoordinate(line));
+    if(! start.isVertex()) {
+        newCoordinateArray.add(start.getCoordinate(line));
     }
 
-	for (auto i = startSegmentIndex; i <= lastSegmentIndex; i++)
-	{
-		newCoordinateArray.add((*coordinates)[i]);
-	}
+    for(auto i = startSegmentIndex; i <= lastSegmentIndex; i++) {
+        newCoordinateArray.add((*coordinates)[i]);
+    }
 
-	if (! end.isVertex())
-    {
-		newCoordinateArray.add(end.getCoordinate(line));
+    if(! end.isVertex()) {
+        newCoordinateArray.add(end.getCoordinate(line));
     }
 
-	// ensure there is at least one coordinate in the result
-	if (newCoordinateArray.isEmpty())
-    {
-		newCoordinateArray.add(start.getCoordinate(line));
+    // ensure there is at least one coordinate in the result
+    if(newCoordinateArray.isEmpty()) {
+        newCoordinateArray.add(start.getCoordinate(line));
     }
 
-	/**
-	 * Ensure there is enough coordinates to build a valid line.
-	 * Make a 2-point line with duplicate coordinates, if necessary.
-	 * There will always be at least one coordinate in the coordList.
-	 */
-	if (newCoordinateArray.size() <= 1)
-	{
-		newCoordinateArray.add(newCoordinateArray[0]);
-	}
-
-	return line->getFactory()->createLineString(newCoordinateArray);
+    /**
+     * Ensure there is enough coordinates to build a valid line.
+     * Make a 2-point line with duplicate coordinates, if necessary.
+     * There will always be at least one coordinate in the coordList.
+     */
+    if(newCoordinateArray.size() <= 1) {
+        newCoordinateArray.add(newCoordinateArray[0]);
+    }
+
+    return line->getFactory()->createLineString(newCoordinateArray);
 }
 
-Geometry *ExtractLineByLocation::computeLinear(const LinearLocation& start, const LinearLocation& end)
+Geometry*
+ExtractLineByLocation::computeLinear(const LinearLocation& start, const LinearLocation& end)
 {
-	LinearGeometryBuilder builder(line->getFactory());
-	builder.setFixInvalidLines(true);
-
-	if (! start.isVertex())
-	{
-		builder.add(start.getCoordinate(line));
-	}
-
-	for (LinearIterator it(line, start); it.hasNext(); it.next())
-	{
-		if (end.compareLocationValues(it.getComponentIndex(), it.getVertexIndex(), 0.0) < 0)
-		{
-			break;
-		}
-		Coordinate pt = it.getSegmentStart();
-		builder.add(pt);
-		if (it.isEndOfLine())
-		{
-			builder.endLine();
-		}
-	}
-	if (! end.isVertex())
-	{
-		builder.add(end.getCoordinate(line));
-	}
-	return builder.getGeometry();
+    LinearGeometryBuilder builder(line->getFactory());
+    builder.setFixInvalidLines(true);
+
+    if(! start.isVertex()) {
+        builder.add(start.getCoordinate(line));
+    }
+
+    for(LinearIterator it(line, start); it.hasNext(); it.next()) {
+        if(end.compareLocationValues(it.getComponentIndex(), it.getVertexIndex(), 0.0) < 0) {
+            break;
+        }
+        Coordinate pt = it.getSegmentStart();
+        builder.add(pt);
+        if(it.isEndOfLine()) {
+            builder.endLine();
+        }
+    }
+    if(! end.isVertex()) {
+        builder.add(end.getCoordinate(line));
+    }
+    return builder.getGeometry();
 }
 }
 }
diff --git a/src/linearref/LengthIndexOfPoint.cpp b/src/linearref/LengthIndexOfPoint.cpp
index f7698d9..2391b64 100644
--- a/src/linearref/LengthIndexOfPoint.cpp
+++ b/src/linearref/LengthIndexOfPoint.cpp
@@ -30,94 +30,99 @@ using namespace std;
 
 using namespace geos::geom;
 
-namespace geos
-{
-namespace linearref   // geos.linearref
-{
+namespace geos {
+namespace linearref { // geos.linearref
 
-double LengthIndexOfPoint::indexOf(const Geometry *linearGeom, const Coordinate& inputPt)
+double
+LengthIndexOfPoint::indexOf(const Geometry* linearGeom, const Coordinate& inputPt)
 {
-	LengthIndexOfPoint locater(linearGeom);
-	return locater.indexOf(inputPt);
+    LengthIndexOfPoint locater(linearGeom);
+    return locater.indexOf(inputPt);
 }
 
-double LengthIndexOfPoint::indexOfAfter(const Geometry *linearGeom, const Coordinate& inputPt, double minIndex)
+double
+LengthIndexOfPoint::indexOfAfter(const Geometry* linearGeom, const Coordinate& inputPt, double minIndex)
 {
-	LengthIndexOfPoint locater(linearGeom);
-	return locater.indexOfAfter(inputPt, minIndex);
+    LengthIndexOfPoint locater(linearGeom);
+    return locater.indexOfAfter(inputPt, minIndex);
 }
 
-LengthIndexOfPoint::LengthIndexOfPoint(const Geometry *p_linearGeom):
-		linearGeom(p_linearGeom) {}
+LengthIndexOfPoint::LengthIndexOfPoint(const Geometry* p_linearGeom):
+    linearGeom(p_linearGeom) {}
 
-double LengthIndexOfPoint::indexOf(const Coordinate& inputPt) const
+double
+LengthIndexOfPoint::indexOf(const Coordinate& inputPt) const
 {
-	return indexOfFromStart(inputPt, -1.0);
+    return indexOfFromStart(inputPt, -1.0);
 }
 
 
-double LengthIndexOfPoint::indexOfAfter(const Coordinate& inputPt, double minIndex) const
+double
+LengthIndexOfPoint::indexOfAfter(const Coordinate& inputPt, double minIndex) const
 {
-	if (minIndex < 0.0) return indexOf(inputPt);
-
-	// sanity check for minIndex at or past end of line
-	double endIndex = linearGeom->getLength();
-	if (endIndex < minIndex)
-		return endIndex;
-
-	double closestAfter = indexOfFromStart(inputPt, minIndex);
-	/**
-	 * Return the minDistanceLocation found.
-	 * This will not be null, since it was initialized to minLocation
-	 */
-	if (closestAfter <= minIndex)
-	{
-		throw util::IllegalArgumentException("computed index is before specified minimum index");
-	}
-	return closestAfter;
+    if(minIndex < 0.0) {
+        return indexOf(inputPt);
+    }
+
+    // sanity check for minIndex at or past end of line
+    double endIndex = linearGeom->getLength();
+    if(endIndex < minIndex) {
+        return endIndex;
+    }
+
+    double closestAfter = indexOfFromStart(inputPt, minIndex);
+    /**
+     * Return the minDistanceLocation found.
+     * This will not be null, since it was initialized to minLocation
+     */
+    if(closestAfter <= minIndex) {
+        throw util::IllegalArgumentException("computed index is before specified minimum index");
+    }
+    return closestAfter;
 }
 
-double LengthIndexOfPoint::indexOfFromStart(const Coordinate& inputPt, double minIndex) const
+double
+LengthIndexOfPoint::indexOfFromStart(const Coordinate& inputPt, double minIndex) const
 {
-	double minDistance = numeric_limits<double>::max();
-
-	double ptMeasure = minIndex;
-	double segmentStartMeasure = 0.0;
-	LineSegment seg;
-	LinearIterator it(linearGeom);
-	while (it.hasNext())
-	{
-		if (! it.isEndOfLine())
-		{
-			seg.p0 = it.getSegmentStart();
-			seg.p1 = it.getSegmentEnd();
-			double segDistance = seg.distance(inputPt);
-			double segMeasureToPt = segmentNearestMeasure(&seg, inputPt, segmentStartMeasure);
-			if (segDistance < minDistance
-					&& segMeasureToPt > minIndex)
-			{
-				ptMeasure = segMeasureToPt;
-				minDistance = segDistance;
-			}
-			segmentStartMeasure += seg.getLength();
-		}
-		it.next();
-	}
-	return ptMeasure;
+    double minDistance = numeric_limits<double>::max();
+
+    double ptMeasure = minIndex;
+    double segmentStartMeasure = 0.0;
+    LineSegment seg;
+    LinearIterator it(linearGeom);
+    while(it.hasNext()) {
+        if(! it.isEndOfLine()) {
+            seg.p0 = it.getSegmentStart();
+            seg.p1 = it.getSegmentEnd();
+            double segDistance = seg.distance(inputPt);
+            double segMeasureToPt = segmentNearestMeasure(&seg, inputPt, segmentStartMeasure);
+            if(segDistance < minDistance
+                    && segMeasureToPt > minIndex) {
+                ptMeasure = segMeasureToPt;
+                minDistance = segDistance;
+            }
+            segmentStartMeasure += seg.getLength();
+        }
+        it.next();
+    }
+    return ptMeasure;
 }
 
-double LengthIndexOfPoint::segmentNearestMeasure(const LineSegment* seg,
-                                                 const Coordinate& inputPt,
-                                                 double segmentStartMeasure) const
+double
+LengthIndexOfPoint::segmentNearestMeasure(const LineSegment* seg,
+        const Coordinate& inputPt,
+        double segmentStartMeasure) const
 {
-	// 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->getLength();
-	// projFactor > 1.0
-	return segmentStartMeasure + seg->getLength();
+    // 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->getLength();
+    }
+    // projFactor > 1.0
+    return segmentStartMeasure + seg->getLength();
 }
 }
 }
diff --git a/src/linearref/LengthIndexedLine.cpp b/src/linearref/LengthIndexedLine.cpp
index 4265b12..ec2f91a 100644
--- a/src/linearref/LengthIndexedLine.cpp
+++ b/src/linearref/LengthIndexedLine.cpp
@@ -30,122 +30,136 @@ using namespace std;
 
 using namespace geos::geom;
 
-namespace geos
-{
-namespace linearref   // geos.linearref
-{
+namespace geos {
+namespace linearref { // geos.linearref
 
 LengthIndexedLine::LengthIndexedLine(const Geometry* p_linearGeom) :
-		linearGeom(p_linearGeom) {}
+    linearGeom(p_linearGeom) {}
 
-Coordinate LengthIndexedLine::extractPoint(double index) const
+Coordinate
+LengthIndexedLine::extractPoint(double index) const
 {
-	LinearLocation loc = LengthLocationMap::getLocation(linearGeom, index);
-	Coordinate coord = loc.getCoordinate(linearGeom);
-	return coord;
+    LinearLocation loc = LengthLocationMap::getLocation(linearGeom, index);
+    Coordinate coord = loc.getCoordinate(linearGeom);
+    return coord;
 }
 
-Coordinate LengthIndexedLine::extractPoint(double index, double offsetDistance) const
+Coordinate
+LengthIndexedLine::extractPoint(double index, double offsetDistance) const
 {
-	LinearLocation loc = LengthLocationMap::getLocation(linearGeom, index);
-	Coordinate ret;
-	loc.getSegment(linearGeom)->pointAlongOffset(loc.getSegmentFraction(), offsetDistance, ret);
-	return ret;
+    LinearLocation loc = LengthLocationMap::getLocation(linearGeom, index);
+    Coordinate ret;
+    loc.getSegment(linearGeom)->pointAlongOffset(loc.getSegmentFraction(), offsetDistance, ret);
+    return ret;
 }
 
 
-Geometry *
+Geometry*
 LengthIndexedLine::extractLine(double startIndex, double endIndex) const
 {
-  const LocationIndexedLine lil(linearGeom);
-  const double startIndex2 = clampIndex(startIndex);
-  const double endIndex2 = clampIndex(endIndex);
-  // if extracted line is zero-length, resolve start lower as well to
-  // ensure they are equal
-  const bool resolveStartLower = ( startIndex2 == endIndex2 );
-  const LinearLocation startLoc = locationOf(startIndex2, resolveStartLower);
-  const LinearLocation endLoc = locationOf(endIndex2);
+    const LocationIndexedLine lil(linearGeom);
+    const double startIndex2 = clampIndex(startIndex);
+    const double endIndex2 = clampIndex(endIndex);
+    // if extracted line is zero-length, resolve start lower as well to
+    // ensure they are equal
+    const bool resolveStartLower = (startIndex2 == endIndex2);
+    const LinearLocation startLoc = locationOf(startIndex2, resolveStartLower);
+    const LinearLocation endLoc = locationOf(endIndex2);
 //    LinearLocation endLoc = locationOf(endIndex2, true);
 //    LinearLocation startLoc = locationOf(startIndex2);
-  return ExtractLineByLocation::extract(linearGeom, startLoc, endLoc);
+    return ExtractLineByLocation::extract(linearGeom, startLoc, endLoc);
 }
 
-LinearLocation LengthIndexedLine::locationOf(double index) const
+LinearLocation
+LengthIndexedLine::locationOf(double index) const
 {
-	return LengthLocationMap::getLocation(linearGeom, index);
+    return LengthLocationMap::getLocation(linearGeom, index);
 }
 
 LinearLocation
 LengthIndexedLine::locationOf(double index, bool resolveLower) const
 {
-	return LengthLocationMap::getLocation(linearGeom, index, resolveLower);
+    return LengthLocationMap::getLocation(linearGeom, index, resolveLower);
 }
 
 
-double LengthIndexedLine::indexOf(const Coordinate& pt) const
+double
+LengthIndexedLine::indexOf(const Coordinate& pt) const
 {
-	return LengthIndexOfPoint::indexOf(linearGeom, pt);
+    return LengthIndexOfPoint::indexOf(linearGeom, pt);
 }
 
 
-double LengthIndexedLine::indexOfAfter(const Coordinate& pt, double minIndex) const
+double
+LengthIndexedLine::indexOfAfter(const Coordinate& pt, double minIndex) const
 {
-	return LengthIndexOfPoint::indexOfAfter(linearGeom, pt, minIndex);
+    return LengthIndexOfPoint::indexOfAfter(linearGeom, pt, minIndex);
 }
 
 
-double* LengthIndexedLine::indicesOf(const Geometry* subLine) const
+double*
+LengthIndexedLine::indicesOf(const Geometry* subLine) const
 {
-	LinearLocation* locIndex = LocationIndexOfLine::indicesOf(linearGeom, subLine);
-	double* index = new double[2];
-	index[0] = LengthLocationMap::getLength(linearGeom, locIndex[0]);
-	index[1] = LengthLocationMap::getLength(linearGeom, locIndex[1]);
-	delete [] locIndex;
-	return index;
+    LinearLocation* locIndex = LocationIndexOfLine::indicesOf(linearGeom, subLine);
+    double* index = new double[2];
+    index[0] = LengthLocationMap::getLength(linearGeom, locIndex[0]);
+    index[1] = LengthLocationMap::getLength(linearGeom, locIndex[1]);
+    delete [] locIndex;
+    return index;
 }
 
 
-double LengthIndexedLine::project(const Coordinate& pt) const
+double
+LengthIndexedLine::project(const Coordinate& pt) const
 {
-	return LengthIndexOfPoint::indexOf(linearGeom, pt);
+    return LengthIndexOfPoint::indexOf(linearGeom, pt);
 }
 
-double LengthIndexedLine::getStartIndex() const
+double
+LengthIndexedLine::getStartIndex() const
 {
-	return 0.0;
+    return 0.0;
 }
 
-double LengthIndexedLine::getEndIndex() const
+double
+LengthIndexedLine::getEndIndex() const
 {
-	return linearGeom->getLength();
+    return linearGeom->getLength();
 }
 
-bool LengthIndexedLine::isValidIndex(double index) const
+bool
+LengthIndexedLine::isValidIndex(double index) const
 {
-	return (index >= getStartIndex()
-		&& index <= getEndIndex());
+    return (index >= getStartIndex()
+            && index <= getEndIndex());
 }
 
 /* public */
 double
 LengthIndexedLine::clampIndex(double index) const
 {
-  double posIndex = positiveIndex(index);
-	double startIndex = getStartIndex();
-  if (posIndex < startIndex) return startIndex;
+    double posIndex = positiveIndex(index);
+    double startIndex = getStartIndex();
+    if(posIndex < startIndex) {
+        return startIndex;
+    }
 
-	double endIndex = getEndIndex();
-	if (posIndex > endIndex) return endIndex;
+    double endIndex = getEndIndex();
+    if(posIndex > endIndex) {
+        return endIndex;
+    }
 
-	return posIndex;
+    return posIndex;
 }
 
 /* private */
 double
 LengthIndexedLine::positiveIndex(double index) const
 {
-  if (index >= 0.0) return index;
-  return linearGeom->getLength() + index;
+    if(index >= 0.0) {
+        return index;
+    }
+    return linearGeom->getLength() + index;
 }
 
 } // geos.linearref
diff --git a/src/linearref/LengthLocationMap.cpp b/src/linearref/LengthLocationMap.cpp
index 0e60071..2ce89ac 100644
--- a/src/linearref/LengthLocationMap.cpp
+++ b/src/linearref/LengthLocationMap.cpp
@@ -28,144 +28,143 @@ using namespace std;
 
 using namespace geos::geom;
 
-namespace geos
-{
-namespace linearref   // geos.linearref
-{
+namespace geos {
+namespace linearref { // geos.linearref
 
 
-double LengthLocationMap::getLength(const Geometry* linearGeom, const LinearLocation& loc)
+double
+LengthLocationMap::getLength(const Geometry* linearGeom, const LinearLocation& loc)
 {
-	LengthLocationMap locater(linearGeom);
-	return locater.getLength(loc);
+    LengthLocationMap locater(linearGeom);
+    return locater.getLength(loc);
 }
 
 
 LengthLocationMap::LengthLocationMap(const Geometry* p_linearGeom) :
-		linearGeom(p_linearGeom) {}
+    linearGeom(p_linearGeom) {}
 
 LinearLocation
 LengthLocationMap::getLocation(double length) const
 {
-	double forwardLength = length;
-	if (length < 0.0)
-	{
-		double lineLen = linearGeom->getLength();
-		forwardLength = lineLen + length;
-	}
-	return getLocationForward(forwardLength);
+    double forwardLength = length;
+    if(length < 0.0) {
+        double lineLen = linearGeom->getLength();
+        forwardLength = lineLen + length;
+    }
+    return getLocationForward(forwardLength);
 }
 
 LinearLocation
 LengthLocationMap::getLocation(double length, bool resolveLower) const
 {
-	double forwardLength = length;
-
-	// negative values are measured from end of geometry
-	if (length < 0.0)
-	{
-		double lineLen = linearGeom->getLength();
-		forwardLength = lineLen + length;
-	}
-
-	LinearLocation loc = getLocationForward(forwardLength);
-	if (resolveLower) {
-		return loc;
-	}
-	return resolveHigher(loc);
+    double forwardLength = length;
+
+    // negative values are measured from end of geometry
+    if(length < 0.0) {
+        double lineLen = linearGeom->getLength();
+        forwardLength = lineLen + length;
+    }
+
+    LinearLocation loc = getLocationForward(forwardLength);
+    if(resolveLower) {
+        return loc;
+    }
+    return resolveHigher(loc);
 }
 
 /* private */
 LinearLocation
 LengthLocationMap::getLocationForward(double length) const
 {
-	if (length <= 0.0)
-		return LinearLocation();
-
-	double totalLength = 0.0;
-
-	LinearIterator it (linearGeom);
-	while (it.hasNext())
-	{
-		/**
-		 * Special handling is required for the situation when the
-		 * length references exactly to a component endpoint.
-		 * In this case, the endpoint location of the current component
-		 * is returned,
-		 * rather than the startpoint location of the next component.
-		 * This produces consistent behaviour with the project method.
-		 */
-		if (it.isEndOfLine()) {
-			if (totalLength == length) {
-				auto compIndex = it.getComponentIndex();
-				auto segIndex = it.getVertexIndex();
-				return LinearLocation(compIndex, segIndex, 0.0);
-			}
-		}
-		else {
-			Coordinate p0 = it.getSegmentStart();
-			Coordinate p1 = it.getSegmentEnd();
-			double segLen = p1.distance(p0);
-			// length falls in this segment
-			if (totalLength + segLen > length)
-			{
-				double frac = (length - totalLength) / segLen;
-				auto compIndex = it.getComponentIndex();
-				auto segIndex = it.getVertexIndex();
-				return LinearLocation(compIndex, segIndex, frac);
-			}
-			totalLength += segLen;
-		}
-
-		it.next();
-	}
-	// length is longer than line - return end location
-	return LinearLocation::getEndLocation(linearGeom);
+    if(length <= 0.0) {
+        return LinearLocation();
+    }
+
+    double totalLength = 0.0;
+
+    LinearIterator it(linearGeom);
+    while(it.hasNext()) {
+        /**
+         * Special handling is required for the situation when the
+         * length references exactly to a component endpoint.
+         * In this case, the endpoint location of the current component
+         * is returned,
+         * rather than the startpoint location of the next component.
+         * This produces consistent behaviour with the project method.
+         */
+        if(it.isEndOfLine()) {
+            if(totalLength == length) {
+                auto compIndex = it.getComponentIndex();
+                auto segIndex = it.getVertexIndex();
+                return LinearLocation(compIndex, segIndex, 0.0);
+            }
+        }
+        else {
+            Coordinate p0 = it.getSegmentStart();
+            Coordinate p1 = it.getSegmentEnd();
+            double segLen = p1.distance(p0);
+            // length falls in this segment
+            if(totalLength + segLen > length) {
+                double frac = (length - totalLength) / segLen;
+                auto compIndex = it.getComponentIndex();
+                auto segIndex = it.getVertexIndex();
+                return LinearLocation(compIndex, segIndex, frac);
+            }
+            totalLength += segLen;
+        }
+
+        it.next();
+    }
+    // length is longer than line - return end location
+    return LinearLocation::getEndLocation(linearGeom);
 }
 
 /* private */
 LinearLocation
 LengthLocationMap::resolveHigher(const LinearLocation& loc) const
 {
-  if (! loc.isEndpoint(*linearGeom)) return loc;
-
-  auto compIndex = loc.getComponentIndex();
-  // if last component can't resolve any higher
-  if (compIndex >= linearGeom->getNumGeometries() - 1) return loc;
-
-  do {
-    compIndex++;
-  } while (compIndex < linearGeom->getNumGeometries() - 1
-           && linearGeom->getGeometryN(compIndex)->getLength() == 0);
-
-  // resolve to next higher location
-  return LinearLocation(compIndex, 0, 0.0);
+    if(! loc.isEndpoint(*linearGeom)) {
+        return loc;
+    }
+
+    auto compIndex = loc.getComponentIndex();
+    // if last component can't resolve any higher
+    if(compIndex >= linearGeom->getNumGeometries() - 1) {
+        return loc;
+    }
+
+    do {
+        compIndex++;
+    }
+    while(compIndex < linearGeom->getNumGeometries() - 1
+            && linearGeom->getGeometryN(compIndex)->getLength() == 0);
+
+    // resolve to next higher location
+    return LinearLocation(compIndex, 0, 0.0);
 }
 
 
-double LengthLocationMap::getLength(const LinearLocation& loc) const
+double
+LengthLocationMap::getLength(const LinearLocation& loc) const
 {
-	double totalLength = 0.0;
-
-	LinearIterator it(linearGeom);
-	while (it.hasNext())
-	{
-		if (! it.isEndOfLine())
-		{
-			Coordinate p0 = it.getSegmentStart();
-			Coordinate p1 = it.getSegmentEnd();
-			double segLen = p1.distance(p0);
-			// length falls in this segment
-			if (loc.getComponentIndex() == it.getComponentIndex()
-					&& loc.getSegmentIndex() == it.getVertexIndex())
-			{
-				return totalLength + segLen * loc.getSegmentFraction();
-			}
-			totalLength += segLen;
-		}
-		it.next();
-	}
-	return totalLength;
+    double totalLength = 0.0;
+
+    LinearIterator it(linearGeom);
+    while(it.hasNext()) {
+        if(! it.isEndOfLine()) {
+            Coordinate p0 = it.getSegmentStart();
+            Coordinate p1 = it.getSegmentEnd();
+            double segLen = p1.distance(p0);
+            // length falls in this segment
+            if(loc.getComponentIndex() == it.getComponentIndex()
+                    && loc.getSegmentIndex() == it.getVertexIndex()) {
+                return totalLength + segLen * loc.getSegmentFraction();
+            }
+            totalLength += segLen;
+        }
+        it.next();
+    }
+    return totalLength;
 }
 
 }
diff --git a/src/linearref/LinearGeometryBuilder.cpp b/src/linearref/LinearGeometryBuilder.cpp
index f05ada8..78600e0 100644
--- a/src/linearref/LinearGeometryBuilder.cpp
+++ b/src/linearref/LinearGeometryBuilder.cpp
@@ -34,128 +34,122 @@ using namespace std;
 
 using namespace geos::geom;
 
-namespace geos
-{
+namespace geos {
 
-namespace linearref   // geos.linearref
-{
+namespace linearref { // geos.linearref
 
 /* public */
 LinearGeometryBuilder::LinearGeometryBuilder(const GeometryFactory* p_geomFact) :
-		geomFact(p_geomFact),
-		ignoreInvalidLines(false),
-		fixInvalidLines(false),
-		coordList(nullptr) {}
+    geomFact(p_geomFact),
+    ignoreInvalidLines(false),
+    fixInvalidLines(false),
+    coordList(nullptr) {}
 
 /* public */
 void
 LinearGeometryBuilder::setIgnoreInvalidLines(bool p_ignoreInvalidLines)
 {
-	this->ignoreInvalidLines = p_ignoreInvalidLines;
+    this->ignoreInvalidLines = p_ignoreInvalidLines;
 }
 
 /* public */
 void
 LinearGeometryBuilder::setFixInvalidLines(bool p_fixInvalidLines)
 {
-	this->fixInvalidLines = p_fixInvalidLines;
+    this->fixInvalidLines = p_fixInvalidLines;
 }
 
 /* public */
 void
 LinearGeometryBuilder::add(const Coordinate& pt)
 {
-	add(pt, true);
+    add(pt, true);
 }
 
 /* public */
 void
 LinearGeometryBuilder::add(const Coordinate& pt, bool allowRepeatedPoints)
 {
-	if (!coordList)
-		coordList = new CoordinateArraySequence();
-	coordList->add(pt, allowRepeatedPoints);
-	lastPt = pt;
+    if(!coordList) {
+        coordList = new CoordinateArraySequence();
+    }
+    coordList->add(pt, allowRepeatedPoints);
+    lastPt = pt;
 }
 
 /* public */
 Coordinate
 LinearGeometryBuilder::getLastCoordinate() const
 {
-	return lastPt;
+    return lastPt;
 }
 
 /* public */
 void
 LinearGeometryBuilder::endLine()
 {
-	if (!coordList)
-	{
-		return;
-	}
-	if (coordList->size() < 2)
-	{
-		if (ignoreInvalidLines)
-		{
-			if (coordList)
-			{
-				delete coordList;
-				coordList = nullptr;
-			}
-			return;
-		}
-		else if (fixInvalidLines)
-		{
-			assert(!coordList->isEmpty()); // just to be sure
-
-			// NOTE: we copy the point cause reallocation of
-			//       vector memory will invalidate the reference
-			//       to one of its elements.
-			//
-			//       We wouldn't have such problems with a vector
-			//       of pointers (as used in JTS)...
-			//
-			Coordinate firstPoint = (*coordList)[0];
-			add(firstPoint);
-		}
-	}
-
-	LineString* line = nullptr;
-	try
-	{
-		line = geomFact->createLineString(coordList);
-	}
-	catch (util::IllegalArgumentException ex)
-	{
-		// exception is due to too few points in line.
-		// only propagate if not ignoring short lines
-		if (! ignoreInvalidLines)
-			throw ex;
-	}
-
-	if (line) lines.push_back(line);
-	coordList = nullptr;
+    if(!coordList) {
+        return;
+    }
+    if(coordList->size() < 2) {
+        if(ignoreInvalidLines) {
+            if(coordList) {
+                delete coordList;
+                coordList = nullptr;
+            }
+            return;
+        }
+        else if(fixInvalidLines) {
+            assert(!coordList->isEmpty()); // just to be sure
+
+            // NOTE: we copy the point cause reallocation of
+            //       vector memory will invalidate the reference
+            //       to one of its elements.
+            //
+            //       We wouldn't have such problems with a vector
+            //       of pointers (as used in JTS)...
+            //
+            Coordinate firstPoint = (*coordList)[0];
+            add(firstPoint);
+        }
+    }
+
+    LineString* line = nullptr;
+    try {
+        line = geomFact->createLineString(coordList);
+    }
+    catch(util::IllegalArgumentException ex) {
+        // exception is due to too few points in line.
+        // only propagate if not ignoring short lines
+        if(! ignoreInvalidLines) {
+            throw ex;
+        }
+    }
+
+    if(line) {
+        lines.push_back(line);
+    }
+    coordList = nullptr;
 }
 
 /* public */
 Geometry*
 LinearGeometryBuilder::getGeometry()
 {
-	// end last line in case it was not done by user
-	endLine();
+    // end last line in case it was not done by user
+    endLine();
 
-	// NOTE: lines elements are cloned
-	return geomFact->buildGeometry(lines);
+    // NOTE: lines elements are cloned
+    return geomFact->buildGeometry(lines);
 }
 
 /* public */
 LinearGeometryBuilder::~LinearGeometryBuilder()
 {
-	for (GeomPtrVect::const_iterator i=lines.begin(), e=lines.end();
-		i != e; ++i)
-	{
-		delete *i;
-	}
+    for(GeomPtrVect::const_iterator i = lines.begin(), e = lines.end();
+            i != e; ++i) {
+        delete *i;
+    }
 }
 
 } // namespace geos.linearref
diff --git a/src/linearref/LinearIterator.cpp b/src/linearref/LinearIterator.cpp
index 60783e9..a1deb72 100644
--- a/src/linearref/LinearIterator.cpp
+++ b/src/linearref/LinearIterator.cpp
@@ -26,119 +26,136 @@
 
 using namespace geos::geom;
 
-namespace geos
-{
-namespace linearref   // geos.linearref
-{
+namespace geos {
+namespace linearref { // geos.linearref
 
-size_t LinearIterator::segmentEndVertexIndex(const LinearLocation& loc)
+size_t
+LinearIterator::segmentEndVertexIndex(const LinearLocation& loc)
 {
-	if (loc.getSegmentFraction() > 0.0)
-		return loc.getSegmentIndex() + 1;
-	return loc.getSegmentIndex();
+    if(loc.getSegmentFraction() > 0.0) {
+        return loc.getSegmentIndex() + 1;
+    }
+    return loc.getSegmentIndex();
 }
 
 LinearIterator::LinearIterator(const Geometry* p_linear) :
-		vertexIndex(0),
-		componentIndex(0),
-		linear(p_linear),
-		numLines(p_linear->getNumGeometries())
+    vertexIndex(0),
+    componentIndex(0),
+    linear(p_linear),
+    numLines(p_linear->getNumGeometries())
 {
-	loadCurrentLine();
+    loadCurrentLine();
 }
 
 
 LinearIterator::LinearIterator(const Geometry* p_linear, const LinearLocation& start):
-		vertexIndex(segmentEndVertexIndex(start)),
-		componentIndex(start.getComponentIndex()),
-		linear(p_linear),
-		numLines(p_linear->getNumGeometries())
+    vertexIndex(segmentEndVertexIndex(start)),
+    componentIndex(start.getComponentIndex()),
+    linear(p_linear),
+    numLines(p_linear->getNumGeometries())
 {
-	loadCurrentLine();
+    loadCurrentLine();
 }
 
 LinearIterator::LinearIterator(const Geometry* p_linear, size_t p_componentIndex, size_t p_vertexIndex) :
-		vertexIndex(p_vertexIndex),
-		componentIndex(p_componentIndex),
-		linear(p_linear),
-		numLines(p_linear->getNumGeometries())
+    vertexIndex(p_vertexIndex),
+    componentIndex(p_componentIndex),
+    linear(p_linear),
+    numLines(p_linear->getNumGeometries())
 {
-	loadCurrentLine();
+    loadCurrentLine();
 }
 
-void LinearIterator::loadCurrentLine()
+void
+LinearIterator::loadCurrentLine()
 {
-	if (componentIndex >= numLines)
-	{
-		currentLine = nullptr;
-		return;
-	}
-	currentLine = dynamic_cast<const LineString *> (linear->getGeometryN(componentIndex));
-	if ( ! currentLine ) {
-		throw util::IllegalArgumentException("LinearIterator only supports lineal geometry components");
-	}
+    if(componentIndex >= numLines) {
+        currentLine = nullptr;
+        return;
+    }
+    currentLine = dynamic_cast<const LineString*>(linear->getGeometryN(componentIndex));
+    if(! currentLine) {
+        throw util::IllegalArgumentException("LinearIterator only supports lineal geometry components");
+    }
 }
 
-bool LinearIterator::hasNext() const
+bool
+LinearIterator::hasNext() const
 {
-	if (componentIndex >= numLines) return false;
-	if (componentIndex == numLines - 1
-			&& vertexIndex >= currentLine->getNumPoints())
-		return false;
-	return true;
+    if(componentIndex >= numLines) {
+        return false;
+    }
+    if(componentIndex == numLines - 1
+            && vertexIndex >= currentLine->getNumPoints()) {
+        return false;
+    }
+    return true;
 }
 
-void LinearIterator::next()
+void
+LinearIterator::next()
 {
-	if (! hasNext()) return;
-
-	vertexIndex++;
-	if (vertexIndex >= currentLine->getNumPoints())
-	{
-		componentIndex++;
-		loadCurrentLine();
-		vertexIndex = 0;
-	}
+    if(! hasNext()) {
+        return;
+    }
+
+    vertexIndex++;
+    if(vertexIndex >= currentLine->getNumPoints()) {
+        componentIndex++;
+        loadCurrentLine();
+        vertexIndex = 0;
+    }
 }
 
-bool LinearIterator::isEndOfLine() const
+bool
+LinearIterator::isEndOfLine() const
 {
-	if (componentIndex >= numLines) return false;
-	//LineString currentLine = (LineString) linear.getGeometryN(componentIndex);
-	if (!currentLine)
-		return false;
-	if (vertexIndex < currentLine->getNumPoints() - 1)
-		return false;
-	return true;
+    if(componentIndex >= numLines) {
+        return false;
+    }
+    //LineString currentLine = (LineString) linear.getGeometryN(componentIndex);
+    if(!currentLine) {
+        return false;
+    }
+    if(vertexIndex < currentLine->getNumPoints() - 1) {
+        return false;
+    }
+    return true;
 }
 
-size_t LinearIterator::getComponentIndex() const
+size_t
+LinearIterator::getComponentIndex() const
 {
-	return componentIndex;
+    return componentIndex;
 }
 
-size_t LinearIterator::getVertexIndex() const
+size_t
+LinearIterator::getVertexIndex() const
 {
-	return vertexIndex;
+    return vertexIndex;
 }
 
-const LineString* LinearIterator::getLine() const
+const LineString*
+LinearIterator::getLine() const
 {
-	return currentLine;
+    return currentLine;
 }
 
-Coordinate LinearIterator::getSegmentStart() const
+Coordinate
+LinearIterator::getSegmentStart() const
 {
-	return currentLine->getCoordinateN(vertexIndex);
+    return currentLine->getCoordinateN(vertexIndex);
 }
 
-Coordinate LinearIterator::getSegmentEnd() const
+Coordinate
+LinearIterator::getSegmentEnd() const
 {
-	if (vertexIndex < getLine()->getNumPoints() - 1)
-		return currentLine->getCoordinateN(vertexIndex + 1);
-	Coordinate c;
-	c.setNull();
-	return c;
+    if(vertexIndex < getLine()->getNumPoints() - 1) {
+        return currentLine->getCoordinateN(vertexIndex + 1);
+    }
+    Coordinate c;
+    c.setNull();
+    return c;
 }
 }
 }
diff --git a/src/linearref/LinearLocation.cpp b/src/linearref/LinearLocation.cpp
index 3c1c452..ce93cb3 100644
--- a/src/linearref/LinearLocation.cpp
+++ b/src/linearref/LinearLocation.cpp
@@ -35,264 +35,303 @@ namespace linearref { // geos::linearref
 LinearLocation
 LinearLocation::getEndLocation(const Geometry* linear)
 {
-	// assert: linear is LineString or MultiLineString
-	LinearLocation loc;
-	loc.setToEnd(linear);
-	return loc;
+    // assert: linear is LineString or MultiLineString
+    LinearLocation loc;
+    loc.setToEnd(linear);
+    return loc;
 }
 
 /* public static */
 Coordinate
 LinearLocation::pointAlongSegmentByFraction(const Coordinate& p0, const Coordinate& p1, double frac)
 {
-	if (frac <= 0.0) return p0;
-	if (frac >= 1.0) return p1;
-
-	double x = (p1.x - p0.x) * frac + p0.x;
-	double y = (p1.y - p0.y) * frac + p0.y;
-	// interpolate Z value. If either input Z is NaN, result z will be NaN as well.
-	double z = (p1.z - p0.z) * frac + p0.z;
-	return Coordinate(x, y, z);
+    if(frac <= 0.0) {
+        return p0;
+    }
+    if(frac >= 1.0) {
+        return p1;
+    }
+
+    double x = (p1.x - p0.x) * frac + p0.x;
+    double y = (p1.y - p0.y) * frac + p0.y;
+    // interpolate Z value. If either input Z is NaN, result z will be NaN as well.
+    double z = (p1.z - p0.z) * frac + p0.z;
+    return Coordinate(x, y, z);
 }
 
 /* public */
 LinearLocation::LinearLocation(size_t p_segmentIndex,
-		double p_segmentFraction)
-	:
-	componentIndex(0),
-	segmentIndex(p_segmentIndex),
-	segmentFraction(p_segmentFraction)
+                               double p_segmentFraction)
+    :
+    componentIndex(0),
+    segmentIndex(p_segmentIndex),
+    segmentFraction(p_segmentFraction)
 {}
 
 
 /* public */
 LinearLocation::LinearLocation(size_t p_componentIndex,
-		size_t p_segmentIndex, double p_segmentFraction)
-	:
-	componentIndex(p_componentIndex),
-	segmentIndex(p_segmentIndex),
-	segmentFraction(p_segmentFraction)
+                               size_t p_segmentIndex, double p_segmentFraction)
+    :
+    componentIndex(p_componentIndex),
+    segmentIndex(p_segmentIndex),
+    segmentFraction(p_segmentFraction)
 {
-	normalize();
+    normalize();
 }
 
 /* private */
 void
 LinearLocation::normalize()
 {
-	if (segmentFraction < 0.0)
-	{
-		segmentFraction = 0.0;
-	}
-	if (segmentFraction > 1.0)
-	{
-		segmentFraction = 1.0;
-	}
-
-	if (segmentFraction == 1.0)
-	{
-		segmentFraction = 0.0;
-		segmentIndex += 1;
-	}
+    if(segmentFraction < 0.0) {
+        segmentFraction = 0.0;
+    }
+    if(segmentFraction > 1.0) {
+        segmentFraction = 1.0;
+    }
+
+    if(segmentFraction == 1.0) {
+        segmentFraction = 0.0;
+        segmentIndex += 1;
+    }
 }
 
 /* public */
 void
 LinearLocation::clamp(const Geometry* linear)
 {
-	if (componentIndex >= linear->getNumGeometries())
-	{
-		setToEnd(linear);
-		return;
-	}
-	if (segmentIndex >= linear->getNumPoints())
-	{
-		const LineString* line = dynamic_cast<const LineString*> (linear->getGeometryN(componentIndex));
-		segmentIndex = line->getNumPoints() - 1;
-		segmentFraction = 1.0;
-	}
+    if(componentIndex >= linear->getNumGeometries()) {
+        setToEnd(linear);
+        return;
+    }
+    if(segmentIndex >= linear->getNumPoints()) {
+        const LineString* line = dynamic_cast<const LineString*>(linear->getGeometryN(componentIndex));
+        segmentIndex = line->getNumPoints() - 1;
+        segmentFraction = 1.0;
+    }
 }
 
 /* public */
 void
 LinearLocation::snapToVertex(const Geometry* linearGeom, double minDistance)
 {
-	if (segmentFraction <= 0.0 || segmentFraction >= 1.0)
-		return;
-	double segLen = getSegmentLength(linearGeom);
-	double lenToStart = segmentFraction * segLen;
-	double lenToEnd = segLen - lenToStart;
-	if (lenToStart <= lenToEnd && lenToStart < minDistance)
-	{
-		segmentFraction = 0.0;
-	}
-	else if (lenToEnd <= lenToStart && lenToEnd < minDistance)
-	{
-		segmentFraction = 1.0;
-	}
+    if(segmentFraction <= 0.0 || segmentFraction >= 1.0) {
+        return;
+    }
+    double segLen = getSegmentLength(linearGeom);
+    double lenToStart = segmentFraction * segLen;
+    double lenToEnd = segLen - lenToStart;
+    if(lenToStart <= lenToEnd && lenToStart < minDistance) {
+        segmentFraction = 0.0;
+    }
+    else if(lenToEnd <= lenToStart && lenToEnd < minDistance) {
+        segmentFraction = 1.0;
+    }
 }
 
 /* public */
 double
 LinearLocation::getSegmentLength(const Geometry* linearGeom) const
 {
-	const LineString* lineComp = dynamic_cast<const LineString*> (linearGeom->getGeometryN(componentIndex));
+    const LineString* lineComp = dynamic_cast<const LineString*>(linearGeom->getGeometryN(componentIndex));
 
-	// ensure segment index is valid
-	size_t segIndex = segmentIndex;
-	if (segmentIndex >= lineComp->getNumPoints() - 1)
-		segIndex = lineComp->getNumPoints() - 2;
+    // ensure segment index is valid
+    size_t segIndex = segmentIndex;
+    if(segmentIndex >= lineComp->getNumPoints() - 1) {
+        segIndex = lineComp->getNumPoints() - 2;
+    }
 
-	Coordinate p0 = lineComp->getCoordinateN(segIndex);
-	Coordinate p1 = lineComp->getCoordinateN(segIndex + 1);
-	return p0.distance(p1);
+    Coordinate p0 = lineComp->getCoordinateN(segIndex);
+    Coordinate p1 = lineComp->getCoordinateN(segIndex + 1);
+    return p0.distance(p1);
 }
 
 /* public */
 void
 LinearLocation::setToEnd(const Geometry* linear)
 {
-	componentIndex = linear->getNumGeometries() - 1;
-	const LineString* lastLine = dynamic_cast<const LineString*>(linear->getGeometryN(componentIndex));
-	segmentIndex = lastLine->getNumPoints() - 1;
-	segmentFraction = 1.0;
+    componentIndex = linear->getNumGeometries() - 1;
+    const LineString* lastLine = dynamic_cast<const LineString*>(linear->getGeometryN(componentIndex));
+    segmentIndex = lastLine->getNumPoints() - 1;
+    segmentFraction = 1.0;
 }
 
 /* public */
 size_t
 LinearLocation::getComponentIndex() const
 {
-	return componentIndex;
+    return componentIndex;
 }
 
 /* public */
 size_t
 LinearLocation::getSegmentIndex() const
 {
-	return segmentIndex;
+    return segmentIndex;
 }
 
 /* public */
 double
 LinearLocation::getSegmentFraction() const
 {
-	return segmentFraction;
+    return segmentFraction;
 }
 
 /* public */
 bool
 LinearLocation::isVertex() const
 {
-	return segmentFraction <= 0.0 || segmentFraction >= 1.0;
+    return segmentFraction <= 0.0 || segmentFraction >= 1.0;
 }
 
 /* public */
 Coordinate
 LinearLocation::getCoordinate(const Geometry* linearGeom) const
 {
-	const LineString* lineComp = dynamic_cast<const LineString *> (linearGeom->getGeometryN(componentIndex));
-	if ( ! lineComp ) {
-		throw util::IllegalArgumentException("LinearLocation::getCoordinate only works with LineString geometries");
-	}
-	if (linearGeom->isEmpty()) {
-		return Coordinate::getNull();
-	}
-	Coordinate p0 = lineComp->getCoordinateN(segmentIndex);
-	if (segmentIndex >= lineComp->getNumPoints() - 1)
-		return p0;
-	Coordinate p1 = lineComp->getCoordinateN(segmentIndex + 1);
-	return pointAlongSegmentByFraction(p0, p1, segmentFraction);
+    const LineString* lineComp = dynamic_cast<const LineString*>(linearGeom->getGeometryN(componentIndex));
+    if(! lineComp) {
+        throw util::IllegalArgumentException("LinearLocation::getCoordinate only works with LineString geometries");
+    }
+    if(linearGeom->isEmpty()) {
+        return Coordinate::getNull();
+    }
+    Coordinate p0 = lineComp->getCoordinateN(segmentIndex);
+    if(segmentIndex >= lineComp->getNumPoints() - 1) {
+        return p0;
+    }
+    Coordinate p1 = lineComp->getCoordinateN(segmentIndex + 1);
+    return pointAlongSegmentByFraction(p0, p1, segmentFraction);
 }
 
 /* public */
 std::unique_ptr<LineSegment>
 LinearLocation::getSegment(const Geometry* linearGeom) const
 {
-	const LineString* lineComp = dynamic_cast<const LineString *> (linearGeom->getGeometryN(componentIndex));
-	Coordinate p0 = lineComp->getCoordinateN(segmentIndex);
-	// check for endpoint - return last segment of the line if so
-	if (segmentIndex >= lineComp->getNumPoints() - 1)
-	{
-		Coordinate prev = lineComp->getCoordinateN(lineComp->getNumPoints() - 2);
-		return std::unique_ptr<LineSegment>(new LineSegment(prev, p0));
-	}
-	Coordinate p1 = lineComp->getCoordinateN(segmentIndex + 1);
-	return std::unique_ptr<LineSegment>(new LineSegment(p0, p1));
+    const LineString* lineComp = dynamic_cast<const LineString*>(linearGeom->getGeometryN(componentIndex));
+    Coordinate p0 = lineComp->getCoordinateN(segmentIndex);
+    // check for endpoint - return last segment of the line if so
+    if(segmentIndex >= lineComp->getNumPoints() - 1) {
+        Coordinate prev = lineComp->getCoordinateN(lineComp->getNumPoints() - 2);
+        return std::unique_ptr<LineSegment>(new LineSegment(prev, p0));
+    }
+    Coordinate p1 = lineComp->getCoordinateN(segmentIndex + 1);
+    return std::unique_ptr<LineSegment>(new LineSegment(p0, p1));
 }
 
 /* public */
 bool
 LinearLocation::isValid(const Geometry* linearGeom) const
 {
-	if (componentIndex >= linearGeom->getNumGeometries())
-		return false;
-
-	const LineString* lineComp = dynamic_cast<const LineString*> (linearGeom->getGeometryN(componentIndex));
-	if (segmentIndex > lineComp->getNumPoints())
-		return false;
-	if (segmentIndex == lineComp->getNumPoints() && segmentFraction != 0.0)
-		return false;
-
-	if (segmentFraction < 0.0 || segmentFraction > 1.0)
-		return false;
-	return true;
+    if(componentIndex >= linearGeom->getNumGeometries()) {
+        return false;
+    }
+
+    const LineString* lineComp = dynamic_cast<const LineString*>(linearGeom->getGeometryN(componentIndex));
+    if(segmentIndex > lineComp->getNumPoints()) {
+        return false;
+    }
+    if(segmentIndex == lineComp->getNumPoints() && segmentFraction != 0.0) {
+        return false;
+    }
+
+    if(segmentFraction < 0.0 || segmentFraction > 1.0) {
+        return false;
+    }
+    return true;
 }
 
 /* public */
 int
 LinearLocation::compareTo(const LinearLocation& other) const
 {
-	// compare component indices
-	if (componentIndex < other.componentIndex) return -1;
-	if (componentIndex > other.componentIndex) return 1;
-	// compare segments
-	if (segmentIndex < other.segmentIndex) return -1;
-	if (segmentIndex > other.segmentIndex) return 1;
-	// same segment, so compare segment fraction
-	if (segmentFraction < other.segmentFraction) return -1;
-	if (segmentFraction > other.segmentFraction) return 1;
-	// same location
-	return 0;
+    // compare component indices
+    if(componentIndex < other.componentIndex) {
+        return -1;
+    }
+    if(componentIndex > other.componentIndex) {
+        return 1;
+    }
+    // compare segments
+    if(segmentIndex < other.segmentIndex) {
+        return -1;
+    }
+    if(segmentIndex > other.segmentIndex) {
+        return 1;
+    }
+    // same segment, so compare segment fraction
+    if(segmentFraction < other.segmentFraction) {
+        return -1;
+    }
+    if(segmentFraction > other.segmentFraction) {
+        return 1;
+    }
+    // same location
+    return 0;
 }
 
 /* public */
 int
 LinearLocation::compareLocationValues(size_t componentIndex1,
-		size_t segmentIndex1, double segmentFraction1) const
+                                      size_t segmentIndex1, double segmentFraction1) const
 {
-	// compare component indices
-	if (componentIndex < componentIndex1) return -1;
-	if (componentIndex > componentIndex1) return 1;
-	// compare segments
-	if (segmentIndex < segmentIndex1) return -1;
-	if (segmentIndex > segmentIndex1) return 1;
-	// same segment, so compare segment fraction
-	if (segmentFraction < segmentFraction1) return -1;
-	if (segmentFraction > segmentFraction1) return 1;
-	// same location
-	return 0;
+    // compare component indices
+    if(componentIndex < componentIndex1) {
+        return -1;
+    }
+    if(componentIndex > componentIndex1) {
+        return 1;
+    }
+    // compare segments
+    if(segmentIndex < segmentIndex1) {
+        return -1;
+    }
+    if(segmentIndex > segmentIndex1) {
+        return 1;
+    }
+    // same segment, so compare segment fraction
+    if(segmentFraction < segmentFraction1) {
+        return -1;
+    }
+    if(segmentFraction > segmentFraction1) {
+        return 1;
+    }
+    // same location
+    return 0;
 }
 
 
 /* public static */
 int
 LinearLocation::compareLocationValues(
-	size_t componentIndex0, size_t segmentIndex0,
-	double segmentFraction0,
-	size_t componentIndex1, size_t segmentIndex1,
-	double segmentFraction1)
+    size_t componentIndex0, size_t segmentIndex0,
+    double segmentFraction0,
+    size_t componentIndex1, size_t segmentIndex1,
+    double segmentFraction1)
 {
-	// compare component indices
-	if (componentIndex0 < componentIndex1) return -1;
-	if (componentIndex0 > componentIndex1) return 1;
-	// compare segments
-	if (segmentIndex0 < segmentIndex1) return -1;
-	if (segmentIndex0 > segmentIndex1) return 1;
-	// same segment, so compare segment fraction
-	if (segmentFraction0 < segmentFraction1) return -1;
-	if (segmentFraction0 > segmentFraction1) return 1;
-	// same location
-	return 0;
+    // compare component indices
+    if(componentIndex0 < componentIndex1) {
+        return -1;
+    }
+    if(componentIndex0 > componentIndex1) {
+        return 1;
+    }
+    // compare segments
+    if(segmentIndex0 < segmentIndex1) {
+        return -1;
+    }
+    if(segmentIndex0 > segmentIndex1) {
+        return 1;
+    }
+    // same segment, so compare segment fraction
+    if(segmentFraction0 < segmentFraction1) {
+        return -1;
+    }
+    if(segmentFraction0 > segmentFraction1) {
+        return 1;
+    }
+    // same location
+    return 0;
 }
 
 
@@ -300,35 +339,42 @@ LinearLocation::compareLocationValues(
 bool
 LinearLocation::isOnSameSegment(const LinearLocation& loc) const
 {
-	if (componentIndex != loc.componentIndex) return false;
-	if (segmentIndex == loc.segmentIndex) return true;
-	if (loc.segmentIndex - segmentIndex == 1
-			&& loc.segmentFraction == 0.0)
-		return true;
-	if (segmentIndex - loc.segmentIndex == 1
-			&& segmentFraction == 0.0)
-		return true;
-	return false;
+    if(componentIndex != loc.componentIndex) {
+        return false;
+    }
+    if(segmentIndex == loc.segmentIndex) {
+        return true;
+    }
+    if(loc.segmentIndex - segmentIndex == 1
+            && loc.segmentFraction == 0.0) {
+        return true;
+    }
+    if(segmentIndex - loc.segmentIndex == 1
+            && segmentFraction == 0.0) {
+        return true;
+    }
+    return false;
 }
 
 /* public */
 bool
 LinearLocation::isEndpoint(const Geometry& linearGeom) const
 {
-  const LineString& lineComp = dynamic_cast<const LineString&>(
-      *(linearGeom.getGeometryN(componentIndex)) );
-  // check for endpoint
-  auto nseg = lineComp.getNumPoints() - 1;
-  return segmentIndex >= nseg
-        || (segmentIndex == nseg && segmentFraction >= 1.0);
+    const LineString& lineComp = dynamic_cast<const LineString&>(
+                                     *(linearGeom.getGeometryN(componentIndex)));
+    // check for endpoint
+    auto nseg = lineComp.getNumPoints() - 1;
+    return segmentIndex >= nseg
+           || (segmentIndex == nseg && segmentFraction >= 1.0);
 
 }
 
 
-ostream& operator<<(ostream &out, const LinearLocation &obj)
+ostream&
+operator<<(ostream& out, const LinearLocation& obj)
 {
-	return out << "LinearLoc[" << obj.componentIndex << ", " <<
-	       obj.segmentIndex << ", " << obj.segmentFraction << "]";
+    return out << "LinearLoc[" << obj.componentIndex << ", " <<
+           obj.segmentIndex << ", " << obj.segmentFraction << "]";
 }
 
 } // namespace geos.linearref
diff --git a/src/linearref/LocationIndexOfLine.cpp b/src/linearref/LocationIndexOfLine.cpp
index f438e1e..d25e244 100644
--- a/src/linearref/LocationIndexOfLine.cpp
+++ b/src/linearref/LocationIndexOfLine.cpp
@@ -27,45 +27,41 @@ using namespace std;
 
 using namespace geos::geom;
 
-namespace geos
-{
-namespace linearref   // geos.linearref
-{
+namespace geos {
+namespace linearref { // geos.linearref
 
 /* public static */
 LinearLocation*
 LocationIndexOfLine::indicesOf(const Geometry* linearGeom,
-		const Geometry* subLine)
+                               const Geometry* subLine)
 {
-	LocationIndexOfLine locater(linearGeom);
-	return locater.indicesOf(subLine);
+    LocationIndexOfLine locater(linearGeom);
+    return locater.indicesOf(subLine);
 }
 
 LocationIndexOfLine::LocationIndexOfLine(const Geometry* p_linearGeom) :
-		linearGeom(p_linearGeom) {}
+    linearGeom(p_linearGeom) {}
 
 /* public */
 LinearLocation*
 LocationIndexOfLine::indicesOf(const Geometry* subLine) const
 {
-	Coordinate startPt = dynamic_cast<const LineString*> (subLine->getGeometryN(0))->getCoordinateN(0);
-	const LineString* lastLine = dynamic_cast<const LineString*> (subLine->getGeometryN(subLine->getNumGeometries() - 1));
-	Coordinate endPt = lastLine->getCoordinateN(lastLine->getNumPoints() - 1);
+    Coordinate startPt = dynamic_cast<const LineString*>(subLine->getGeometryN(0))->getCoordinateN(0);
+    const LineString* lastLine = dynamic_cast<const LineString*>(subLine->getGeometryN(subLine->getNumGeometries() - 1));
+    Coordinate endPt = lastLine->getCoordinateN(lastLine->getNumPoints() - 1);
 
-	LocationIndexOfPoint locPt(linearGeom);
-	LinearLocation *subLineLoc = new LinearLocation[2];
-	subLineLoc[0] = locPt.indexOf(startPt);
+    LocationIndexOfPoint locPt(linearGeom);
+    LinearLocation* subLineLoc = new LinearLocation[2];
+    subLineLoc[0] = locPt.indexOf(startPt);
 
-	// check for case where subline is zero length
-	if (subLine->getLength() == 0.0)
-	{
-		subLineLoc[1] = subLineLoc[0];
-	}
-	else
-	{
-		subLineLoc[1] = locPt.indexOfAfter(endPt, &subLineLoc[0]);
-	}
-	return subLineLoc;
+    // check for case where subline is zero length
+    if(subLine->getLength() == 0.0) {
+        subLineLoc[1] = subLineLoc[0];
+    }
+    else {
+        subLineLoc[1] = locPt.indexOfAfter(endPt, &subLineLoc[0]);
+    }
+    return subLineLoc;
 }
 }
 }
diff --git a/src/linearref/LocationIndexOfPoint.cpp b/src/linearref/LocationIndexOfPoint.cpp
index 860d4b6..23a837f 100644
--- a/src/linearref/LocationIndexOfPoint.cpp
+++ b/src/linearref/LocationIndexOfPoint.cpp
@@ -32,95 +32,95 @@ using namespace std;
 
 using namespace geos::geom;
 
-namespace geos
-{
-namespace linearref   // geos.linearref
-{
+namespace geos {
+namespace linearref { // geos.linearref
 
 LinearLocation
 LocationIndexOfPoint::indexOfFromStart(const Coordinate& inputPt,
-  const LinearLocation* minIndex) const
+                                       const LinearLocation* minIndex) const
 {
-	double minDistance = numeric_limits<double>::max();
-	size_t minComponentIndex = 0;
-	size_t minSegmentIndex = 0;
-	double minFrac = -1.0;
-
-	LineSegment seg;
-	for (LinearIterator it(linearGeom);
-			it.hasNext(); it.next())
-	{
-		if (! it.isEndOfLine())
-		{
-			seg.p0 = it.getSegmentStart();
-			seg.p1 = it.getSegmentEnd();
-			double segDistance = seg.distance(inputPt);
-			double segFrac = seg.segmentFraction(inputPt);
-
-			auto candidateComponentIndex = it.getComponentIndex();
-			auto candidateSegmentIndex = it.getVertexIndex();
-			if (segDistance < minDistance)
-			{
-				// ensure after minLocation, if any
-				if (!minIndex ||
-						minIndex->compareLocationValues(candidateComponentIndex, candidateSegmentIndex, segFrac) < 0)
-				{
-					// otherwise, save this as new minimum
-					minComponentIndex = candidateComponentIndex;
-					minSegmentIndex = candidateSegmentIndex;
-					minFrac = segFrac;
-					minDistance = segDistance;
-				}
-			}
-		}
-	}
-	LinearLocation loc(minComponentIndex, minSegmentIndex, minFrac);
-	return loc;
+    double minDistance = numeric_limits<double>::max();
+    size_t minComponentIndex = 0;
+    size_t minSegmentIndex = 0;
+    double minFrac = -1.0;
+
+    LineSegment seg;
+    for(LinearIterator it(linearGeom);
+            it.hasNext(); it.next()) {
+        if(! it.isEndOfLine()) {
+            seg.p0 = it.getSegmentStart();
+            seg.p1 = it.getSegmentEnd();
+            double segDistance = seg.distance(inputPt);
+            double segFrac = seg.segmentFraction(inputPt);
+
+            auto candidateComponentIndex = it.getComponentIndex();
+            auto candidateSegmentIndex = it.getVertexIndex();
+            if(segDistance < minDistance) {
+                // ensure after minLocation, if any
+                if(!minIndex ||
+                        minIndex->compareLocationValues(candidateComponentIndex, candidateSegmentIndex, segFrac) < 0) {
+                    // otherwise, save this as new minimum
+                    minComponentIndex = candidateComponentIndex;
+                    minSegmentIndex = candidateSegmentIndex;
+                    minFrac = segFrac;
+                    minDistance = segDistance;
+                }
+            }
+        }
+    }
+    LinearLocation loc(minComponentIndex, minSegmentIndex, minFrac);
+    return loc;
 }
 
 
-LinearLocation LocationIndexOfPoint::indexOf(const Geometry *linearGeom, const Coordinate& inputPt)
+LinearLocation
+LocationIndexOfPoint::indexOf(const Geometry* linearGeom, const Coordinate& inputPt)
 {
-	LocationIndexOfPoint locater(linearGeom);
-	return locater.indexOf(inputPt);
+    LocationIndexOfPoint locater(linearGeom);
+    return locater.indexOf(inputPt);
 }
 
-LinearLocation LocationIndexOfPoint::indexOfAfter(const Geometry *linearGeom, const Coordinate& inputPt, const LinearLocation* minIndex)
+LinearLocation
+LocationIndexOfPoint::indexOfAfter(const Geometry* linearGeom, const Coordinate& inputPt,
+                                   const LinearLocation* minIndex)
 {
-	LocationIndexOfPoint locater(linearGeom);
-	return locater.indexOfAfter(inputPt, minIndex);
+    LocationIndexOfPoint locater(linearGeom);
+    return locater.indexOfAfter(inputPt, minIndex);
 }
 
-LocationIndexOfPoint::LocationIndexOfPoint(const Geometry *p_linearGeom) :
-		linearGeom(p_linearGeom)
+LocationIndexOfPoint::LocationIndexOfPoint(const Geometry* p_linearGeom) :
+    linearGeom(p_linearGeom)
 {}
 
-LinearLocation LocationIndexOfPoint::indexOf(const Coordinate& inputPt) const
+LinearLocation
+LocationIndexOfPoint::indexOf(const Coordinate& inputPt) const
 {
-	return indexOfFromStart(inputPt, nullptr);
+    return indexOfFromStart(inputPt, nullptr);
 }
 
 LinearLocation
 LocationIndexOfPoint::indexOfAfter(const Coordinate& inputPt,
                                    const LinearLocation* minIndex) const
 {
-	if (!minIndex) 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);
-	/**
-	 * Return the minDistanceLocation found.
-	 * This will not be null, since it was initialized to minLocation
-	 */
-	if (closestAfter.compareTo(*minIndex) < 0)
-	{
-		throw util::IllegalArgumentException("computed location is before specified minimum location");
-	}
-	return closestAfter;
+    if(!minIndex) {
+        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);
+    /**
+     * Return the minDistanceLocation found.
+     * This will not be null, since it was initialized to minLocation
+     */
+    if(closestAfter.compareTo(*minIndex) < 0) {
+        throw util::IllegalArgumentException("computed location is before specified minimum location");
+    }
+    return closestAfter;
 }
 }
 }
diff --git a/src/noding/BasicSegmentString.cpp b/src/noding/BasicSegmentString.cpp
index 9717094..5c98203 100644
--- a/src/noding/BasicSegmentString.cpp
+++ b/src/noding/BasicSegmentString.cpp
@@ -42,39 +42,41 @@ namespace noding { // geos.noding
 int
 BasicSegmentString::getSegmentOctant(size_t index) const
 {
-	if (index >= size() - 1) return -1;
-	return Octant::octant(getCoordinate(index), getCoordinate(index+1));
+    if(index >= size() - 1) {
+        return -1;
+    }
+    return Octant::octant(getCoordinate(index), getCoordinate(index + 1));
 }
 
 /* virtual public */
 const geom::Coordinate&
 BasicSegmentString::getCoordinate(size_t i) const
 {
-	return pts->getAt(i);
+    return pts->getAt(i);
 }
 
 /* virtual public */
 geom::CoordinateSequence*
 BasicSegmentString::getCoordinates() const
 {
-	return pts;
+    return pts;
 }
 
 /* virtual public */
 bool
 BasicSegmentString::isClosed() const
 {
-	return pts->getAt(0)==pts->getAt(size()-1);
+    return pts->getAt(0) == pts->getAt(size() - 1);
 }
 
 /* public virtual */
 std::ostream&
 BasicSegmentString::print(std::ostream& os) const
 {
-	os << "BasicSegmentString: " << std::endl;
-	os << " LINESTRING" << *(pts) << ";" << std::endl;
+    os << "BasicSegmentString: " << std::endl;
+    os << " LINESTRING" << *(pts) << ";" << std::endl;
 
-	return os;
+    return os;
 }
 
 
diff --git a/src/noding/FastNodingValidator.cpp b/src/noding/FastNodingValidator.cpp
index eb6e3f9..425cde0 100644
--- a/src/noding/FastNodingValidator.cpp
+++ b/src/noding/FastNodingValidator.cpp
@@ -38,7 +38,7 @@ FastNodingValidator::checkInteriorIntersections()
     MCIndexNoder noder;
     noder.setSegmentIntersector(segInt.get());
     noder.computeNodes(&segStrings);
-    if (segInt->hasIntersection()) {
+    if(segInt->hasIntersection()) {
         isValidVar = false;
         return;
     }
@@ -51,24 +51,25 @@ FastNodingValidator::getErrorMessage() const
     using geos::io::WKTWriter;
     using geos::geom::Coordinate;
 
-    if (isValidVar) return std::string("no intersections found");
+    if(isValidVar) {
+        return std::string("no intersections found");
+    }
 
     //return std::string("found non-noded intersection etc etc");
 
     const std::vector<Coordinate>& intSegs = segInt->getIntersectionSegments();
     assert(intSegs.size() == 4);
     return "found non-noded intersection between "
-        + WKTWriter::toLineString(intSegs[0], intSegs[1])
-        + " and "
-        + WKTWriter::toLineString(intSegs[2], intSegs[3]);
+           + WKTWriter::toLineString(intSegs[0], intSegs[1])
+           + " and "
+           + WKTWriter::toLineString(intSegs[2], intSegs[3]);
 }
 
 void
 FastNodingValidator::checkValid()
 {
     execute();
-    if (! isValidVar)
-    {
+    if(! isValidVar) {
         //std::cerr << "Not valid: " << getErrorMessage() << " interior intersection: " << segInt->getInteriorIntersection() << std::endl;
         throw util::TopologyException(getErrorMessage(), segInt->getInteriorIntersection());
     }
diff --git a/src/noding/FastSegmentSetIntersectionFinder.cpp b/src/noding/FastSegmentSetIntersectionFinder.cpp
index 37c313f..c9f5289 100644
--- a/src/noding/FastSegmentSetIntersectionFinder.cpp
+++ b/src/noding/FastSegmentSetIntersectionFinder.cpp
@@ -38,31 +38,31 @@ namespace noding { // geos::noding
  * public:
  */
 FastSegmentSetIntersectionFinder::
-FastSegmentSetIntersectionFinder( noding::SegmentString::ConstVect * baseSegStrings)
-:	segSetMutInt( new MCIndexSegmentSetMutualIntersector()),
-	lineIntersector( new algorithm::LineIntersector())
+FastSegmentSetIntersectionFinder(noding::SegmentString::ConstVect* baseSegStrings)
+    :	segSetMutInt(new MCIndexSegmentSetMutualIntersector()),
+      lineIntersector(new algorithm::LineIntersector())
 {
-	segSetMutInt->setBaseSegments( baseSegStrings);
+    segSetMutInt->setBaseSegments(baseSegStrings);
 }
 
 bool
 FastSegmentSetIntersectionFinder::
-intersects( noding::SegmentString::ConstVect * segStrings)
+intersects(noding::SegmentString::ConstVect* segStrings)
 {
-	SegmentIntersectionDetector intFinder(lineIntersector.get());
+    SegmentIntersectionDetector intFinder(lineIntersector.get());
 
-	return this->intersects( segStrings, &intFinder);
+    return this->intersects(segStrings, &intFinder);
 }
 
 bool
 FastSegmentSetIntersectionFinder::
-intersects( noding::SegmentString::ConstVect * segStrings,
-			SegmentIntersectionDetector * intDetector)
+intersects(noding::SegmentString::ConstVect* segStrings,
+           SegmentIntersectionDetector* intDetector)
 {
-	segSetMutInt->setSegmentIntersector( intDetector);
-	segSetMutInt->process( segStrings);
+    segSetMutInt->setSegmentIntersector(intDetector);
+    segSetMutInt->process(segStrings);
 
-	return intDetector->hasIntersection();
+    return intDetector->hasIntersection();
 }
 
 } // geos::noding
diff --git a/src/noding/GeometryNoder.cpp b/src/noding/GeometryNoder.cpp
index 20c51a1..4101a0d 100644
--- a/src/noding/GeometryNoder.cpp
+++ b/src/noding/GeometryNoder.cpp
@@ -49,24 +49,26 @@ namespace {
  */
 class SegmentStringExtractor: public geom::GeometryComponentFilter {
 public:
-  SegmentStringExtractor(SegmentString::NonConstVect& to)
-    : _to(to)
-  {}
-
-  void filter_ro(const geom::Geometry * g) override {
-    const geom::LineString *ls = dynamic_cast<const geom::LineString *>(g);
-    if ( ls ) {
-      geom::CoordinateSequence* coord = ls->getCoordinates();
-      // coord ownership transferred to SegmentString
-      SegmentString *ss = new NodedSegmentString(coord, nullptr);
-      _to.push_back(ss);
+    SegmentStringExtractor(SegmentString::NonConstVect& to)
+        : _to(to)
+    {}
+
+    void
+    filter_ro(const geom::Geometry* g) override
+    {
+        const geom::LineString* ls = dynamic_cast<const geom::LineString*>(g);
+        if(ls) {
+            geom::CoordinateSequence* coord = ls->getCoordinates();
+            // coord ownership transferred to SegmentString
+            SegmentString* ss = new NodedSegmentString(coord, nullptr);
+            _to.push_back(ss);
+        }
     }
-  }
 private:
-  SegmentString::NonConstVect& _to;
+    SegmentString::NonConstVect& _to;
 
-  SegmentStringExtractor(SegmentStringExtractor const&); /*= delete*/
-  SegmentStringExtractor& operator=(SegmentStringExtractor const&); /*= delete*/
+    SegmentStringExtractor(SegmentStringExtractor const&); /*= delete*/
+    SegmentStringExtractor& operator=(SegmentStringExtractor const&); /*= delete*/
 };
 
 }
@@ -76,14 +78,14 @@ private:
 std::unique_ptr<geom::Geometry>
 GeometryNoder::node(const geom::Geometry& geom)
 {
-  GeometryNoder noder(geom);
-  return noder.getNoded();
+    GeometryNoder noder(geom);
+    return noder.getNoded();
 }
 
 /* public */
 GeometryNoder::GeometryNoder(const geom::Geometry& g)
-  :
-  argGeom(g)
+    :
+    argGeom(g)
 {
 }
 
@@ -91,61 +93,62 @@ GeometryNoder::GeometryNoder(const geom::Geometry& g)
 std::unique_ptr<geom::Geometry>
 GeometryNoder::toGeometry(SegmentString::NonConstVect& nodedEdges)
 {
-  const geom::GeometryFactory *geomFact = argGeom.getFactory();
-
-  std::set< OrientedCoordinateArray > ocas;
-
-  // Create a geometry out of the noded substrings.
-  std::vector< geom::Geometry* >* lines = new std::vector< geom::Geometry * >();
-  lines->reserve(nodedEdges.size());
-  for (auto &ss :  nodedEdges)
-  {
-    const geom::CoordinateSequence* coords = ss->getCoordinates();
-
-    // Check if an equivalent edge is known
-    OrientedCoordinateArray oca1( *coords );
-    if ( ocas.insert(oca1).second ) {
-      geom::Geometry* tmp = geomFact->createLineString( coords->clone() );
-      lines->push_back( tmp );
+    const geom::GeometryFactory* geomFact = argGeom.getFactory();
+
+    std::set< OrientedCoordinateArray > ocas;
+
+    // Create a geometry out of the noded substrings.
+    std::vector< geom::Geometry* >* lines = new std::vector< geom::Geometry* >();
+    lines->reserve(nodedEdges.size());
+    for(auto& ss :  nodedEdges) {
+        const geom::CoordinateSequence* coords = ss->getCoordinates();
+
+        // Check if an equivalent edge is known
+        OrientedCoordinateArray oca1(*coords);
+        if(ocas.insert(oca1).second) {
+            geom::Geometry* tmp = geomFact->createLineString(coords->clone());
+            lines->push_back(tmp);
+        }
     }
-  }
 
-  std::unique_ptr<geom::Geometry> noded ( geomFact->createMultiLineString( lines ) );
+    std::unique_ptr<geom::Geometry> noded(geomFact->createMultiLineString(lines));
 
-  return noded;
+    return noded;
 }
 
 /* public */
 std::unique_ptr<geom::Geometry>
 GeometryNoder::getNoded()
 {
-  SegmentString::NonConstVect p_lineList;
-  extractSegmentStrings(argGeom, p_lineList);
+    SegmentString::NonConstVect p_lineList;
+    extractSegmentStrings(argGeom, p_lineList);
 
-  Noder& p_noder = getNoder();
-  SegmentString::NonConstVect* nodedEdges = nullptr;
+    Noder& p_noder = getNoder();
+    SegmentString::NonConstVect* nodedEdges = nullptr;
 
-  try {
-    p_noder.computeNodes( &p_lineList );
-    nodedEdges = p_noder.getNodedSubstrings();
-  }
-  catch (const std::exception&)
-  {
-    for (size_t i=0, n=p_lineList.size(); i<n; ++i)
-      delete p_lineList[i];
-    throw;
-  }
+    try {
+        p_noder.computeNodes(&p_lineList);
+        nodedEdges = p_noder.getNodedSubstrings();
+    }
+    catch(const std::exception&) {
+        for(size_t i = 0, n = p_lineList.size(); i < n; ++i) {
+            delete p_lineList[i];
+        }
+        throw;
+    }
 
-  std::unique_ptr<geom::Geometry> noded = toGeometry(*nodedEdges);
+    std::unique_ptr<geom::Geometry> noded = toGeometry(*nodedEdges);
 
-  for (auto &elem : (*nodedEdges))
-    delete elem;
-  delete nodedEdges;
+    for(auto& elem : (*nodedEdges)) {
+        delete elem;
+    }
+    delete nodedEdges;
 
-  for (auto &elem : p_lineList)
-    delete elem;
+    for(auto& elem : p_lineList) {
+        delete elem;
+    }
 
-  return noded;
+    return noded;
 }
 
 /* private static */
@@ -153,36 +156,35 @@ void
 GeometryNoder::extractSegmentStrings(const geom::Geometry& g,
                                      SegmentString::NonConstVect& to)
 {
-  SegmentStringExtractor ex(to);
-	g.apply_ro(&ex);
+    SegmentStringExtractor ex(to);
+    g.apply_ro(&ex);
 }
 
 /* private */
 Noder&
 GeometryNoder::getNoder()
 {
-  if ( ! noder.get() )
-  {
-    const geom::PrecisionModel *pm = argGeom.getFactory()->getPrecisionModel();
+    if(! noder.get()) {
+        const geom::PrecisionModel* pm = argGeom.getFactory()->getPrecisionModel();
 #if 0
-    using algorithm::LineIntersector;
-		LineIntersector li;
-		IntersectionAdder intersectionAdder(li);
-    noder.reset( new MCIndexNoder(&intersectionAdder) );
+        using algorithm::LineIntersector;
+        LineIntersector li;
+        IntersectionAdder intersectionAdder(li);
+        noder.reset(new MCIndexNoder(&intersectionAdder));
 #else
 
-    IteratedNoder* in = new IteratedNoder(pm);
-    //in->setMaximumIterations(0);
-    noder.reset( in );
+        IteratedNoder* in = new IteratedNoder(pm);
+        //in->setMaximumIterations(0);
+        noder.reset(in);
 
-    //using snapround::SimpleSnapRounder;
-    //noder.reset( new SimpleSnapRounder(*pm) );
+        //using snapround::SimpleSnapRounder;
+        //noder.reset( new SimpleSnapRounder(*pm) );
 
-    //using snapround::MCIndexSnapRounder;
-    //noder.reset( new MCIndexSnapRounder(*pm) );
+        //using snapround::MCIndexSnapRounder;
+        //noder.reset( new MCIndexSnapRounder(*pm) );
 #endif
-  }
-  return *noder;
+    }
+    return *noder;
 
 
 }
diff --git a/src/noding/IntersectionAdder.cpp b/src/noding/IntersectionAdder.cpp
index 2288261..4c4f89a 100644
--- a/src/noding/IntersectionAdder.cpp
+++ b/src/noding/IntersectionAdder.cpp
@@ -30,82 +30,91 @@ namespace noding { // geos.noding
 /*private*/
 bool
 IntersectionAdder::isTrivialIntersection(const SegmentString* e0,
-		size_t segIndex0, const SegmentString* e1, size_t segIndex1)
+        size_t segIndex0, const SegmentString* e1, size_t segIndex1)
 {
-	if (e0 != e1) return false;
+    if(e0 != e1) {
+        return false;
+    }
 
-	if (li.getIntersectionNum() != 1) return false;
+    if(li.getIntersectionNum() != 1) {
+        return false;
+    }
 
-	if (isAdjacentSegments(segIndex0, segIndex1)) return true;
+    if(isAdjacentSegments(segIndex0, segIndex1)) {
+        return true;
+    }
 
-	if (! e0->isClosed()) return false;
+    if(! e0->isClosed()) {
+        return false;
+    }
 
-	auto maxSegIndex = e0->size() - 1;
-	if ( (segIndex0 == 0 && segIndex1 == maxSegIndex)
-		||  (segIndex1 == 0 && segIndex0 == maxSegIndex) )
-	{
-		return true;
-	}
-	return false;
+    auto maxSegIndex = e0->size() - 1;
+    if((segIndex0 == 0 && segIndex1 == maxSegIndex)
+            || (segIndex1 == 0 && segIndex0 == maxSegIndex)) {
+        return true;
+    }
+    return false;
 
 }
 
 /*public*/
 void
 IntersectionAdder::processIntersections(
-		SegmentString* e0,  size_t segIndex0,
-		SegmentString* e1,  size_t segIndex1)
+    SegmentString* e0,  size_t segIndex0,
+    SegmentString* e1,  size_t segIndex1)
 {
-	// don't bother intersecting a segment with itself
-	if (e0 == e1 && segIndex0 == segIndex1) return;
+    // don't bother intersecting a segment with itself
+    if(e0 == e1 && segIndex0 == segIndex1) {
+        return;
+    }
 
-	numTests++;
+    numTests++;
 
 
-	const Coordinate& p00 = e0->getCoordinate(segIndex0);
-	const Coordinate& p01 = e0->getCoordinate(segIndex0 + 1);
-	const Coordinate& p10 = e1->getCoordinate(segIndex1);
-	const Coordinate& p11 = e1->getCoordinate(segIndex1 + 1);
+    const Coordinate& p00 = e0->getCoordinate(segIndex0);
+    const Coordinate& p01 = e0->getCoordinate(segIndex0 + 1);
+    const Coordinate& p10 = e1->getCoordinate(segIndex1);
+    const Coordinate& p11 = e1->getCoordinate(segIndex1 + 1);
 
-	li.computeIntersection(p00, p01, p10, p11);
+    li.computeIntersection(p00, p01, p10, p11);
 //if (li.hasIntersection() && li.isProper()) Debug.println(li);
 
-	// No intersection, nothing to do
-	if (! li.hasIntersection()) return;
-
-	//intersectionFound = true;
-	numIntersections++;
-
-	if (li.isInteriorIntersection())
-	{
-
-		numInteriorIntersections++;
-		hasInterior=true;
-	}
-
-	// if the segments are adjacent they have at least
-	// one trivial intersection,
-	// the shared endpoint.  Don't bother adding it if it
-	// is the only intersection.
-	if (! isTrivialIntersection(e0, segIndex0, e1, segIndex1))
-	{
-		hasIntersectionVar = true;
-
-		NodedSegmentString* ee0 = dynamic_cast<NodedSegmentString*>(e0);
-		NodedSegmentString* ee1 = dynamic_cast<NodedSegmentString*>(e1);
-		assert(ee0 && ee1);
-		ee0->addIntersections(&li, segIndex0, 0);
-		ee1->addIntersections(&li, segIndex1, 1);
-
-		if (li.isProper()) {
-			numProperIntersections++;
-			//Debug.println(li.toString());
-			//Debug.println(li.getIntersection(0));
+    // No intersection, nothing to do
+    if(! li.hasIntersection()) {
+        return;
+    }
+
+    //intersectionFound = true;
+    numIntersections++;
+
+    if(li.isInteriorIntersection()) {
+
+        numInteriorIntersections++;
+        hasInterior = true;
+    }
+
+    // if the segments are adjacent they have at least
+    // one trivial intersection,
+    // the shared endpoint.  Don't bother adding it if it
+    // is the only intersection.
+    if(! isTrivialIntersection(e0, segIndex0, e1, segIndex1)) {
+        hasIntersectionVar = true;
+
+        NodedSegmentString* ee0 = dynamic_cast<NodedSegmentString*>(e0);
+        NodedSegmentString* ee1 = dynamic_cast<NodedSegmentString*>(e1);
+        assert(ee0 && ee1);
+        ee0->addIntersections(&li, segIndex0, 0);
+        ee1->addIntersections(&li, segIndex1, 1);
+
+        if(li.isProper()) {
+            numProperIntersections++;
+            //Debug.println(li.toString());
+            //Debug.println(li.getIntersection(0));
 //properIntersectionPoint = (Coordinate) li.getIntersection(0).clone();
-			hasProper = true;
-			hasProperInterior = true;
-		}
-	}
+            hasProper = true;
+            hasProperInterior = true;
+        }
+    }
 }
 
 } // namespace geos.noding
diff --git a/src/noding/IntersectionFinderAdder.cpp b/src/noding/IntersectionFinderAdder.cpp
index a777f39..3235119 100644
--- a/src/noding/IntersectionFinderAdder.cpp
+++ b/src/noding/IntersectionFinderAdder.cpp
@@ -31,36 +31,35 @@ namespace noding { // geos.noding
 
 void
 IntersectionFinderAdder::processIntersections(
-		SegmentString* e0,  size_t segIndex0,
-		SegmentString* e1,  size_t segIndex1)
+    SegmentString* e0,  size_t segIndex0,
+    SegmentString* e1,  size_t segIndex1)
 {
-	// don't bother intersecting a segment with itself
-	if (e0 == e1 && segIndex0 == segIndex1) return;
+    // don't bother intersecting a segment with itself
+    if(e0 == e1 && segIndex0 == segIndex1) {
+        return;
+    }
 
-	const Coordinate& p00 = e0->getCoordinate(segIndex0);
-	const Coordinate& p01 = e0->getCoordinate(segIndex0 + 1);
-	const Coordinate& p10 = e1->getCoordinate(segIndex1);
-	const Coordinate& p11 = e1->getCoordinate(segIndex1 + 1);
+    const Coordinate& p00 = e0->getCoordinate(segIndex0);
+    const Coordinate& p01 = e0->getCoordinate(segIndex0 + 1);
+    const Coordinate& p10 = e1->getCoordinate(segIndex1);
+    const Coordinate& p11 = e1->getCoordinate(segIndex1 + 1);
 
-	li.computeIntersection(p00, p01, p10, p11);
+    li.computeIntersection(p00, p01, p10, p11);
 //if (li.hasIntersection() && li.isProper()) Debug.println(li);
 
-	if (li.hasIntersection())
-	{
-		if (li.isInteriorIntersection())
-		{
-			for (size_t intIndex = 0, n = li.getIntersectionNum(); intIndex < n; ++intIndex)
-			{
-				interiorIntersections.push_back(li.getIntersection(intIndex));
-			}
+    if(li.hasIntersection()) {
+        if(li.isInteriorIntersection()) {
+            for(size_t intIndex = 0, n = li.getIntersectionNum(); intIndex < n; ++intIndex) {
+                interiorIntersections.push_back(li.getIntersection(intIndex));
+            }
 
-			NodedSegmentString* ee0 = dynamic_cast<NodedSegmentString*>(e0);
-			NodedSegmentString* ee1 = dynamic_cast<NodedSegmentString*>(e1);
-			assert(ee0 && ee1);
-        		ee0->addIntersections(&li, segIndex0, 0);
-			ee1->addIntersections(&li, segIndex1, 1);
-		}
-	}
+            NodedSegmentString* ee0 = dynamic_cast<NodedSegmentString*>(e0);
+            NodedSegmentString* ee1 = dynamic_cast<NodedSegmentString*>(e1);
+            assert(ee0 && ee1);
+            ee0->addIntersections(&li, segIndex0, 0);
+            ee1->addIntersections(&li, segIndex1, 1);
+        }
+    }
 }
 
 } // namespace geos.noding
diff --git a/src/noding/IteratedNoder.cpp b/src/noding/IteratedNoder.cpp
index 4241fae..7718bf5 100644
--- a/src/noding/IteratedNoder.cpp
+++ b/src/noding/IteratedNoder.cpp
@@ -39,62 +39,63 @@ namespace noding { // geos.noding
 
 /* private */
 void
-IteratedNoder::node(vector<SegmentString*> *segStrings,
-		int *numInteriorIntersections)
+IteratedNoder::node(vector<SegmentString*>* segStrings,
+                    int* numInteriorIntersections)
 {
-	IntersectionAdder si(li);
-	MCIndexNoder noder;
-	noder.setSegmentIntersector(&si);
-	noder.computeNodes(segStrings);
-	nodedSegStrings = noder.getNodedSubstrings();
-	*numInteriorIntersections = si.numInteriorIntersections;
+    IntersectionAdder si(li);
+    MCIndexNoder noder;
+    noder.setSegmentIntersector(&si);
+    noder.computeNodes(segStrings);
+    nodedSegStrings = noder.getNodedSubstrings();
+    *numInteriorIntersections = si.numInteriorIntersections;
 //System.out.println("# intersection tests: " + si.numTests);
 }
 
 /* public */
 void
 IteratedNoder::computeNodes(SegmentString::NonConstVect* segStrings)
-	// throw(GEOSException);
+// throw(GEOSException);
 {
-	int numInteriorIntersections;
-	nodedSegStrings = segStrings;
-	int nodingIterationCount = 0;
-	int lastNodesCreated = -1;
-	vector<SegmentString*> *lastStrings = nullptr;
-	do {
+    int numInteriorIntersections;
+    nodedSegStrings = segStrings;
+    int nodingIterationCount = 0;
+    int lastNodesCreated = -1;
+    vector<SegmentString*>* lastStrings = nullptr;
+    do {
 
-		// NOTE: will change this.nodedSegStrings
-		node(nodedSegStrings, &numInteriorIntersections);
+        // NOTE: will change this.nodedSegStrings
+        node(nodedSegStrings, &numInteriorIntersections);
 
-		// Delete noded strings from previous iteration
-		if ( lastStrings ) {
-			for (auto &s : *lastStrings)
-				delete s;
-			delete lastStrings;
-		}
-		lastStrings = nodedSegStrings;
+        // Delete noded strings from previous iteration
+        if(lastStrings) {
+            for(auto& s : *lastStrings) {
+                delete s;
+            }
+            delete lastStrings;
+        }
+        lastStrings = nodedSegStrings;
 
-		nodingIterationCount++;
-		int nodesCreated = numInteriorIntersections;
+        nodingIterationCount++;
+        int nodesCreated = numInteriorIntersections;
 
-		/**
-		 * Fail if the number of nodes created is not declining.
-		 * However, allow a few iterations at least before doing this
-		 */
-		//cerr<<"# nodes created: "<<nodesCreated<<endl;
-		if (lastNodesCreated > 0
-				&& nodesCreated >= lastNodesCreated
-				&& nodingIterationCount > maxIter)
-		{
-			stringstream s;
-			s<<"Iterated noding failed to converge after "<<
-                                    nodingIterationCount << " iterations";
-			throw util::TopologyException(s.str());
-		}
-		lastNodesCreated = nodesCreated;
+        /**
+         * Fail if the number of nodes created is not declining.
+         * However, allow a few iterations at least before doing this
+         */
+        //cerr<<"# nodes created: "<<nodesCreated<<endl;
+        if(lastNodesCreated > 0
+                && nodesCreated >= lastNodesCreated
+                && nodingIterationCount > maxIter) {
+            stringstream s;
+            s << "Iterated noding failed to converge after " <<
+              nodingIterationCount << " iterations";
+            throw util::TopologyException(s.str());
+        }
+        lastNodesCreated = nodesCreated;
 
-	} while (lastNodesCreated > 0);
-	//cerr<<"# nodings = "<<nodingIterationCount<<endl;
+    }
+    while(lastNodesCreated > 0);
+    //cerr<<"# nodings = "<<nodingIterationCount<<endl;
 }
 
 
diff --git a/src/noding/MCIndexNoder.cpp b/src/noding/MCIndexNoder.cpp
index aa79c65..c966f08 100644
--- a/src/noding/MCIndexNoder.cpp
+++ b/src/noding/MCIndexNoder.cpp
@@ -45,13 +45,13 @@ namespace noding { // geos.noding
 void
 MCIndexNoder::computeNodes(SegmentString::NonConstVect* inputSegStrings)
 {
-	nodedSegStrings = inputSegStrings;
-	assert(nodedSegStrings);
+    nodedSegStrings = inputSegStrings;
+    assert(nodedSegStrings);
 
-	for_each(nodedSegStrings->begin(), nodedSegStrings->end(),
-			bind1st(mem_fun(&MCIndexNoder::add), this));
+    for_each(nodedSegStrings->begin(), nodedSegStrings->end(),
+             bind1st(mem_fun(&MCIndexNoder::add), this));
 
-	intersectChains();
+    intersectChains();
 //cerr<<"MCIndexNoder: # chain overlaps = "<<nOverlaps<<endl;
 }
 
@@ -59,96 +59,94 @@ MCIndexNoder::computeNodes(SegmentString::NonConstVect* inputSegStrings)
 void
 MCIndexNoder::intersectChains()
 {
-	assert(segInt);
-
-	SegmentOverlapAction overlapAction(*segInt);
-
-	for (vector<MonotoneChain*>::iterator
-			i=monoChains.begin(), iEnd=monoChains.end();
-			i != iEnd;
-			++i)
-	{
-
-		GEOS_CHECK_FOR_INTERRUPTS();
-
-		MonotoneChain* queryChain = *i;
-		assert(queryChain);
-		vector<void*> overlapChains;
-		index.query(&(queryChain->getEnvelope()), overlapChains);
-		for (vector<void*>::iterator
-			j=overlapChains.begin(), jEnd=overlapChains.end();
-			j != jEnd;
-			++j)
-		{
-			MonotoneChain* testChain = static_cast<MonotoneChain*>(*j);
-			assert(testChain);
-
-			/**
-			 * following test makes sure we only compare each
-			 * pair of chains once and that we don't compare a
-			 * chain to itself
-			 */
-			if (testChain->getId() > queryChain->getId()) {
-				queryChain->computeOverlaps(testChain,
-						&overlapAction);
-				nOverlaps++;
-			}
-
-			// short-circuit if possible
-			if (segInt->isDone()) return;
-
-		}
-	}
+    assert(segInt);
+
+    SegmentOverlapAction overlapAction(*segInt);
+
+    for(vector<MonotoneChain*>::iterator
+            i = monoChains.begin(), iEnd = monoChains.end();
+            i != iEnd;
+            ++i) {
+
+        GEOS_CHECK_FOR_INTERRUPTS();
+
+        MonotoneChain* queryChain = *i;
+        assert(queryChain);
+        vector<void*> overlapChains;
+        index.query(&(queryChain->getEnvelope()), overlapChains);
+        for(vector<void*>::iterator
+                j = overlapChains.begin(), jEnd = overlapChains.end();
+                j != jEnd;
+                ++j) {
+            MonotoneChain* testChain = static_cast<MonotoneChain*>(*j);
+            assert(testChain);
+
+            /**
+             * following test makes sure we only compare each
+             * pair of chains once and that we don't compare a
+             * chain to itself
+             */
+            if(testChain->getId() > queryChain->getId()) {
+                queryChain->computeOverlaps(testChain,
+                                            &overlapAction);
+                nOverlaps++;
+            }
+
+            // short-circuit if possible
+            if(segInt->isDone()) {
+                return;
+            }
+
+        }
+    }
 }
 
 /*private*/
 void
 MCIndexNoder::add(SegmentString* segStr)
 {
-	vector<std::unique_ptr<MonotoneChain>> segChains;
+    vector<std::unique_ptr<MonotoneChain>> segChains;
 
-	// segChains will contain nelwy allocated MonotoneChain objects
-	MonotoneChainBuilder::getChains(segStr->getCoordinates(),
-			segStr, segChains);
+    // segChains will contain nelwy allocated MonotoneChain objects
+    MonotoneChainBuilder::getChains(segStr->getCoordinates(),
+                                    segStr, segChains);
 
-	for(auto& mc : segChains)
-	{
-		assert(mc);
+    for(auto& mc : segChains) {
+        assert(mc);
 
-		mc->setId(idCounter++);
-		index.insert(&(mc->getEnvelope()), mc.get());
+        mc->setId(idCounter++);
+        index.insert(&(mc->getEnvelope()), mc.get());
 
-		// MonotoneChain objects deletion delegated to destructor
-		monoChains.push_back(mc.release());
-	}
+        // MonotoneChain objects deletion delegated to destructor
+        monoChains.push_back(mc.release());
+    }
 }
 
 MCIndexNoder::~MCIndexNoder()
 {
-	for(vector<MonotoneChain*>::iterator
-			i=monoChains.begin(), iEnd=monoChains.end();
-			i!=iEnd; ++i)
-	{
-		assert(*i);
-		delete *i;
-	}
+    for(vector<MonotoneChain*>::iterator
+            i = monoChains.begin(), iEnd = monoChains.end();
+            i != iEnd; ++i) {
+        assert(*i);
+        delete *i;
+    }
 }
 
 void
 MCIndexNoder::SegmentOverlapAction::overlap(MonotoneChain& mc1, size_t start1,
-		MonotoneChain& mc2, size_t start2)
+        MonotoneChain& mc2, size_t start2)
 {
-	SegmentString* ss1 = const_cast<SegmentString*>(
-		static_cast<const SegmentString *>(mc1.getContext())
-		);
-	assert(ss1);
+    SegmentString* ss1 = const_cast<SegmentString*>(
+                             static_cast<const SegmentString*>(mc1.getContext())
+                         );
+    assert(ss1);
 
-	SegmentString* ss2 = const_cast<SegmentString*>(
-		static_cast<const SegmentString *>(mc2.getContext())
-		);
-	assert(ss2);
+    SegmentString* ss2 = const_cast<SegmentString*>(
+                             static_cast<const SegmentString*>(mc2.getContext())
+                         );
+    assert(ss2);
 
-	si.processIntersections(ss1, start1, ss2, start2);
+    si.processIntersections(ss1, start1, ss2, start2);
 }
 
 
diff --git a/src/noding/MCIndexSegmentSetMutualIntersector.cpp b/src/noding/MCIndexSegmentSetMutualIntersector.cpp
index f35718a..e06abf1 100644
--- a/src/noding/MCIndexSegmentSetMutualIntersector.cpp
+++ b/src/noding/MCIndexSegmentSetMutualIntersector.cpp
@@ -39,12 +39,11 @@ MCIndexSegmentSetMutualIntersector::addToIndex(SegmentString* segStr)
 {
     MonoChains segChains;
     MonotoneChainBuilder::getChains(segStr->getCoordinates(),
-      segStr, segChains);
+                                    segStr, segChains);
 
     MonoChains::size_type n = segChains.size();
     chainStore.reserve(chainStore.size() + n);
-    for (auto& mc : segChains)
-    {
+    for(auto& mc : segChains) {
         mc->setId(indexCounter++);
         index->insert(&(mc->getEnvelope()), mc.get());
         chainStore.push_back(std::move(mc));
@@ -56,21 +55,20 @@ MCIndexSegmentSetMutualIntersector::addToIndex(SegmentString* segStr)
 void
 MCIndexSegmentSetMutualIntersector::intersectChains()
 {
-    MCIndexSegmentSetMutualIntersector::SegmentOverlapAction overlapAction( *segInt);
+    MCIndexSegmentSetMutualIntersector::SegmentOverlapAction overlapAction(*segInt);
 
-    for (const auto& queryChain : monoChains)
-    {
+    for(const auto& queryChain : monoChains) {
         std::vector<void*> overlapChains;
-        index->query( &(queryChain->getEnvelope()), overlapChains);
+        index->query(&(queryChain->getEnvelope()), overlapChains);
 
-        for (std::size_t j = 0, nj = overlapChains.size(); j < nj; j++)
-        {
-            MonotoneChain * testChain = (MonotoneChain *)(overlapChains[j]);
+        for(std::size_t j = 0, nj = overlapChains.size(); j < nj; j++) {
+            MonotoneChain* testChain = (MonotoneChain*)(overlapChains[j]);
 
-            queryChain->computeOverlaps( testChain, &overlapAction);
+            queryChain->computeOverlaps(testChain, &overlapAction);
             nOverlaps++;
-            if (segInt->isDone())
+            if(segInt->isDone()) {
                 return;
+            }
         }
     }
 }
@@ -85,20 +83,19 @@ MCIndexSegmentSetMutualIntersector::addToMonoChains(SegmentString* segStr)
 
     MonoChains::size_type n = segChains.size();
     monoChains.reserve(monoChains.size() + n);
-    for (auto& mc : segChains)
-    {
-        mc->setId( processCounter++ );
+    for(auto& mc : segChains) {
+        mc->setId(processCounter++);
         monoChains.push_back(std::move(mc));
     }
 }
 
 /* public */
 MCIndexSegmentSetMutualIntersector::MCIndexSegmentSetMutualIntersector()
-:	monoChains(),
-index(new geos::index::strtree::STRtree()),
-indexCounter(0),
-processCounter(0),
-nOverlaps(0)
+    :	monoChains(),
+      index(new geos::index::strtree::STRtree()),
+      indexCounter(0),
+      processCounter(0),
+      nOverlaps(0)
 {
 }
 
@@ -116,8 +113,7 @@ MCIndexSegmentSetMutualIntersector::setBaseSegments(SegmentString::ConstVect* se
 {
     // NOTE - mloskot: const qualifier is removed silently, dirty.
 
-    for (std::size_t i = 0, n = segStrings->size(); i < n; i++)
-    {
+    for(std::size_t i = 0, n = segStrings->size(); i < n; i++) {
         const SegmentString* css = (*segStrings)[i];
         SegmentString* ss = const_cast<SegmentString*>(css);
         addToIndex(ss);
@@ -126,17 +122,16 @@ MCIndexSegmentSetMutualIntersector::setBaseSegments(SegmentString::ConstVect* se
 
 /*public*/
 void
-MCIndexSegmentSetMutualIntersector::process(SegmentString::ConstVect * segStrings)
+MCIndexSegmentSetMutualIntersector::process(SegmentString::ConstVect* segStrings)
 {
     processCounter = indexCounter + 1;
     nOverlaps = 0;
 
     monoChains.clear();
 
-    for (SegmentString::ConstVect::size_type i = 0, n = segStrings->size(); i < n; i++)
-    {
-        SegmentString * seg = (SegmentString *)((*segStrings)[i]);
-        addToMonoChains( seg);
+    for(SegmentString::ConstVect::size_type i = 0, n = segStrings->size(); i < n; i++) {
+        SegmentString* seg = (SegmentString*)((*segStrings)[i]);
+        addToMonoChains(seg);
     }
     intersectChains();
 }
@@ -145,10 +140,10 @@ MCIndexSegmentSetMutualIntersector::process(SegmentString::ConstVect * segString
 /* public */
 void
 MCIndexSegmentSetMutualIntersector::SegmentOverlapAction::overlap(
-	MonotoneChain& mc1, size_t start1, MonotoneChain& mc2, size_t start2)
+    MonotoneChain& mc1, size_t start1, MonotoneChain& mc2, size_t start2)
 {
-    SegmentString * ss1 = (SegmentString *)(mc1.getContext());
-    SegmentString * ss2 = (SegmentString *)(mc2.getContext());
+    SegmentString* ss1 = (SegmentString*)(mc1.getContext());
+    SegmentString* ss2 = (SegmentString*)(mc2.getContext());
 
     si.processIntersections(ss1, start1, ss2, start2);
 }
diff --git a/src/noding/NodedSegmentString.cpp b/src/noding/NodedSegmentString.cpp
index 712b722..d092c50 100644
--- a/src/noding/NodedSegmentString.cpp
+++ b/src/noding/NodedSegmentString.cpp
@@ -32,21 +32,23 @@ namespace noding { // geos::noding
 const SegmentNodeList&
 NodedSegmentString::getNodeList() const
 {
-	return nodeList;
+    return nodeList;
 }
 
 SegmentNodeList&
 NodedSegmentString::getNodeList()
 {
-	return nodeList;
+    return nodeList;
 }
 
 /*static private*/
 int
 NodedSegmentString::safeOctant(const Coordinate& p0, const Coordinate& p1)
 {
-  if ( p0.equals2D(p1) ) return 0;
-	return Octant::octant(p0, p1);
+    if(p0.equals2D(p1)) {
+        return 0;
+    }
+    return Octant::octant(p0, p1);
 }
 
 
@@ -54,65 +56,65 @@ NodedSegmentString::safeOctant(const Coordinate& p0, const Coordinate& p1)
 int
 NodedSegmentString::getSegmentOctant(size_t index) const
 {
-	if (index >= size() - 1) return -1;
-	return safeOctant(getCoordinate(index), getCoordinate(index+1));
-	//return Octant::octant(getCoordinate(index), getCoordinate(index+1));
+    if(index >= size() - 1) {
+        return -1;
+    }
+    return safeOctant(getCoordinate(index), getCoordinate(index + 1));
+    //return Octant::octant(getCoordinate(index), getCoordinate(index+1));
 }
 
 /*public*/
 void
-NodedSegmentString::addIntersections(LineIntersector *li,
-	 	size_t segmentIndex, size_t geomIndex)
+NodedSegmentString::addIntersections(LineIntersector* li,
+                                     size_t segmentIndex, size_t geomIndex)
 {
-	for (size_t i = 0, n = li->getIntersectionNum(); i < n; ++i) {
-		addIntersection(li, segmentIndex, geomIndex, i);
-	}
+    for(size_t i = 0, n = li->getIntersectionNum(); i < n; ++i) {
+        addIntersection(li, segmentIndex, geomIndex, i);
+    }
 }
 
 /*public*/
 void
-NodedSegmentString::addIntersection(LineIntersector *li,
-		size_t segmentIndex,
-		size_t geomIndex, size_t intIndex)
+NodedSegmentString::addIntersection(LineIntersector* li,
+                                    size_t segmentIndex,
+                                    size_t geomIndex, size_t intIndex)
 {
     ::geos::ignore_unused_variable_warning(geomIndex);
 
-	const Coordinate &intPt=li->getIntersection(intIndex);
-	addIntersection(intPt, segmentIndex);
+    const Coordinate& intPt = li->getIntersection(intIndex);
+    addIntersection(intPt, segmentIndex);
 }
 
 /*public*/
 void
 NodedSegmentString::addIntersection(const Coordinate& intPt,
-	size_t segmentIndex)
+                                    size_t segmentIndex)
 {
-	size_t normalizedSegmentIndex = segmentIndex;
-
-	if ( segmentIndex > size()-2 )
-	{
-		throw util::IllegalArgumentException("SegmentString::addIntersection: SegmentIndex out of range");
-	}
-
-	// normalize the intersection point location
-	auto nextSegIndex = normalizedSegmentIndex + 1;
-	if (nextSegIndex < size())
-	{
-		const Coordinate& nextPt = pts->getAt(nextSegIndex);
-
-		// Normalize segment index if intPt falls on vertex
-		// The check for point equality is 2D only -
-		// Z values are ignored
-		if (intPt.equals2D(nextPt)) {
-			normalizedSegmentIndex = nextSegIndex;
-		}
-	}
-
-	/*
-	 * Add the intersection point to edge intersection list
-	 * (unless the node is already known)
-	 */
-	//SegmentNode *ei=
-	nodeList.add(intPt, normalizedSegmentIndex);
+    size_t normalizedSegmentIndex = segmentIndex;
+
+    if(segmentIndex > size() - 2) {
+        throw util::IllegalArgumentException("SegmentString::addIntersection: SegmentIndex out of range");
+    }
+
+    // normalize the intersection point location
+    auto nextSegIndex = normalizedSegmentIndex + 1;
+    if(nextSegIndex < size()) {
+        const Coordinate& nextPt = pts->getAt(nextSegIndex);
+
+        // Normalize segment index if intPt falls on vertex
+        // The check for point equality is 2D only -
+        // Z values are ignored
+        if(intPt.equals2D(nextPt)) {
+            normalizedSegmentIndex = nextSegIndex;
+        }
+    }
+
+    /*
+     * Add the intersection point to edge intersection list
+     * (unless the node is already known)
+     */
+    //SegmentNode *ei=
+    nodeList.add(intPt, normalizedSegmentIndex);
 
 
 }
@@ -120,61 +122,60 @@ NodedSegmentString::addIntersection(const Coordinate& intPt,
 /* public static */
 void
 NodedSegmentString::getNodedSubstrings(
-	const SegmentString::NonConstVect& segStrings,
-	SegmentString::NonConstVect *resultEdgeList)
+    const SegmentString::NonConstVect& segStrings,
+    SegmentString::NonConstVect* resultEdgeList)
 {
-	assert(resultEdgeList);
-	for ( SegmentString::NonConstVect::const_iterator
-		i=segStrings.begin(), iEnd=segStrings.end();
-		i != iEnd; ++i )
-	{
-		NodedSegmentString* ss = dynamic_cast<NodedSegmentString*>(*i);
-		assert(ss);
-		ss->getNodeList().addSplitEdges(resultEdgeList);
-	}
+    assert(resultEdgeList);
+    for(SegmentString::NonConstVect::const_iterator
+            i = segStrings.begin(), iEnd = segStrings.end();
+            i != iEnd; ++i) {
+        NodedSegmentString* ss = dynamic_cast<NodedSegmentString*>(*i);
+        assert(ss);
+        ss->getNodeList().addSplitEdges(resultEdgeList);
+    }
 }
 
 /* public static */
 SegmentString::NonConstVect*
 NodedSegmentString::getNodedSubstrings(
-		const SegmentString::NonConstVect& segStrings)
+    const SegmentString::NonConstVect& segStrings)
 {
-	SegmentString::NonConstVect* resultEdgelist = \
-		new SegmentString::NonConstVect();
-	getNodedSubstrings(segStrings, resultEdgelist);
-	return resultEdgelist;
+    SegmentString::NonConstVect* resultEdgelist = \
+            new SegmentString::NonConstVect();
+    getNodedSubstrings(segStrings, resultEdgelist);
+    return resultEdgelist;
 }
 
 /* virtual public */
 const geom::Coordinate&
 NodedSegmentString::getCoordinate(size_t i) const
 {
-	return pts->getAt(i);
+    return pts->getAt(i);
 }
 
 /* virtual public */
 geom::CoordinateSequence*
 NodedSegmentString::getCoordinates() const
 {
-	return pts;
+    return pts;
 }
 
 /* virtual public */
 bool
 NodedSegmentString::isClosed() const
 {
-	return pts->getAt(0)==pts->getAt(size()-1);
+    return pts->getAt(0) == pts->getAt(size() - 1);
 }
 
 /* public virtual */
 std::ostream&
 NodedSegmentString::print(std::ostream& os) const
 {
-	os << "NodedSegmentString: " << std::endl;
-	os << " LINESTRING" << *(pts) << ";" << std::endl;
-	os << " Nodes: " << nodeList.size() << std::endl;
+    os << "NodedSegmentString: " << std::endl;
+    os << " LINESTRING" << *(pts) << ";" << std::endl;
+    os << " Nodes: " << nodeList.size() << std::endl;
 
-	return os;
+    return os;
 }
 
 
diff --git a/src/noding/NodingIntersectionFinder.cpp b/src/noding/NodingIntersectionFinder.cpp
index a86b5c5..0d8b1e8 100644
--- a/src/noding/NodingIntersectionFinder.cpp
+++ b/src/noding/NodingIntersectionFinder.cpp
@@ -32,8 +32,12 @@ namespace noding { // geos.noding
 bool
 NodingIntersectionFinder::isEndSegment(const SegmentString* segStr, size_t index)
 {
-    if (index == 0) return true;
-    if (index >= segStr->size() - 2) return true;
+    if(index == 0) {
+        return true;
+    }
+    if(index >= segStr->size() - 2) {
+        return true;
+    }
     return false;
 }
 
@@ -44,9 +48,13 @@ NodingIntersectionFinder::isInteriorVertexIntersection(
     bool isEnd0, bool isEnd1)
 {
     // Intersections between endpoints are valid nodes, so not reported
-    if (isEnd0 && isEnd1) return false;
+    if(isEnd0 && isEnd1) {
+        return false;
+    }
 
-    if (p0.equals2D(p1)) return true;
+    if(p0.equals2D(p1)) {
+        return true;
+    }
 
     return false;
 }
@@ -58,10 +66,18 @@ NodingIntersectionFinder::isInteriorVertexIntersection(
     const Coordinate& p00, const Coordinate& p01, const Coordinate& p10, const Coordinate& p11,
     bool isEnd00, bool isEnd01, bool isEnd10, bool isEnd11)
 {
-    if (isInteriorVertexIntersection(p00, p10, isEnd00, isEnd10)) return true;
-    if (isInteriorVertexIntersection(p00, p11, isEnd00, isEnd11)) return true;
-    if (isInteriorVertexIntersection(p01, p10, isEnd01, isEnd10)) return true;
-    if (isInteriorVertexIntersection(p01, p11, isEnd01, isEnd11)) return true;
+    if(isInteriorVertexIntersection(p00, p10, isEnd00, isEnd10)) {
+        return true;
+    }
+    if(isInteriorVertexIntersection(p00, p11, isEnd00, isEnd11)) {
+        return true;
+    }
+    if(isInteriorVertexIntersection(p01, p10, isEnd01, isEnd10)) {
+        return true;
+    }
+    if(isInteriorVertexIntersection(p01, p11, isEnd01, isEnd11)) {
+        return true;
+    }
     return false;
 }
 
@@ -69,43 +85,46 @@ NodingIntersectionFinder::isInteriorVertexIntersection(
 /* public (override) */
 void
 NodingIntersectionFinder::processIntersections(
-	SegmentString* e0,  size_t segIndex0,
-	SegmentString* e1,  size_t segIndex1)
+    SegmentString* e0,  size_t segIndex0,
+    SegmentString* e1,  size_t segIndex1)
 {
-	using geos::geom::Coordinate;
+    using geos::geom::Coordinate;
 
-	// short-circuit if intersection already found
-	if (!findAllIntersections && hasIntersection())
-		return;
+    // short-circuit if intersection already found
+    if(!findAllIntersections && hasIntersection()) {
+        return;
+    }
 
-	// don't bother intersecting a segment with itself
+    // don't bother intersecting a segment with itself
     bool isSameSegString = e0 == e1;
     bool isSameSegment = isSameSegString && segIndex0 == segIndex1;
-	if (isSameSegment) return;
+    if(isSameSegment) {
+        return;
+    }
 
     /**
      * If enabled, only test end segments (on either segString).
      */
-    if (isCheckEndSegmentsOnly)
-    {
+    if(isCheckEndSegmentsOnly) {
         bool isEndSegPresent =
             isEndSegment(e0, segIndex0) ||
             isEndSegment(e1, segIndex1);
-        if (! isEndSegPresent)
+        if(! isEndSegPresent) {
             return;
+        }
     }
 
-	const Coordinate& p00 = e0->getCoordinate(segIndex0);
-	const Coordinate& p01 = e0->getCoordinate(segIndex0 + 1);
-	const Coordinate& p10 = e1->getCoordinate(segIndex1);
-	const Coordinate& p11 = e1->getCoordinate(segIndex1 + 1);
+    const Coordinate& p00 = e0->getCoordinate(segIndex0);
+    const Coordinate& p01 = e0->getCoordinate(segIndex0 + 1);
+    const Coordinate& p10 = e1->getCoordinate(segIndex1);
+    const Coordinate& p11 = e1->getCoordinate(segIndex1 + 1);
 
     bool isEnd00 = segIndex0 == 0;
     bool isEnd01 = segIndex0 + 2 == e0->size();
     bool isEnd10 = segIndex1 == 0;
     bool isEnd11 = segIndex1 + 2 == e1->size();
 
-	li.computeIntersection(p00, p01, p10, p11);
+    li.computeIntersection(p00, p01, p10, p11);
     /**
      * Check for an intersection in the interior of a segment
      */
@@ -116,10 +135,9 @@ NodingIntersectionFinder::processIntersections(
     int segDiff = segIndex1 - segIndex0;
     bool isAdjacentSegment = isSameSegString && std::abs(segDiff) <= 1;
     bool isInteriorVertexInt = (!isAdjacentSegment) &&
-        isInteriorVertexIntersection(p00, p01, p10, p11, isEnd00, isEnd01, isEnd10, isEnd11);
+                               isInteriorVertexIntersection(p00, p01, p10, p11, isEnd00, isEnd01, isEnd10, isEnd11);
 
-    if (isInteriorInt || isInteriorVertexInt)
-    {
+    if(isInteriorInt || isInteriorVertexInt) {
         // found an intersection!
         intSegments.push_back(p00);
         intSegments.push_back(p01);
diff --git a/src/noding/NodingValidator.cpp b/src/noding/NodingValidator.cpp
index 5741725..a43d6de 100644
--- a/src/noding/NodingValidator.cpp
+++ b/src/noding/NodingValidator.cpp
@@ -38,150 +38,143 @@ namespace noding { // geos.noding
 void
 NodingValidator::checkValid()
 {
-	checkEndPtVertexIntersections();
-	checkInteriorIntersections();
-	checkCollapses();
+    checkEndPtVertexIntersections();
+    checkInteriorIntersections();
+    checkCollapses();
 }
 
 /*private*/
 void
 NodingValidator::checkCollapses() const
 {
-	for (SegmentString::NonConstVect::const_iterator
-		it = segStrings.begin(), itEnd = segStrings.end();
-		it != itEnd;
-		++it)
-	{
-		const SegmentString* ss = *it;
-		checkCollapses(*ss);
-	}
+    for(SegmentString::NonConstVect::const_iterator
+            it = segStrings.begin(), itEnd = segStrings.end();
+            it != itEnd;
+            ++it) {
+        const SegmentString* ss = *it;
+        checkCollapses(*ss);
+    }
 }
 
 /* private */
 void
 NodingValidator::checkCollapses(const SegmentString& ss) const
 {
-	const CoordinateSequence& pts = *(ss.getCoordinates());
-	for (size_t i = 0, n = pts.size() - 2; i < n; ++i)
-	{
-		checkCollapse(pts[i], pts[i + 1], pts[i + 2]);
-	}
+    const CoordinateSequence& pts = *(ss.getCoordinates());
+    for(size_t i = 0, n = pts.size() - 2; i < n; ++i) {
+        checkCollapse(pts[i], pts[i + 1], pts[i + 2]);
+    }
 }
 
 /* private */
 void
 NodingValidator::checkCollapse(const Coordinate& p0,
-		const Coordinate& p1, const Coordinate& p2) const
+                               const Coordinate& p1, const Coordinate& p2) const
 {
-	if (p0.equals2D(p2))
-		throw util::TopologyException("found non-noded collapse at " +
-			p0.toString() + ", " +
-			p1.toString() + ", " +
-			p2.toString());
+    if(p0.equals2D(p2))
+        throw util::TopologyException("found non-noded collapse at " +
+                                      p0.toString() + ", " +
+                                      p1.toString() + ", " +
+                                      p2.toString());
 }
 
 /*private*/
 void
 NodingValidator::checkInteriorIntersections()
 {
-	for (SegmentString::NonConstVect::const_iterator
-		it = segStrings.begin(), itEnd = segStrings.end();
-		it != itEnd;
-		++it)
-	{
-		SegmentString* ss0 = *it;
-		for (SegmentString::NonConstVect::const_iterator
-			j = segStrings.begin(), jEnd = segStrings.end();
-			j != jEnd; ++j)
-		{
-        		const SegmentString* ss1 = *j;
-			checkInteriorIntersections(*ss0, *ss1);
-		}
-	}
+    for(SegmentString::NonConstVect::const_iterator
+            it = segStrings.begin(), itEnd = segStrings.end();
+            it != itEnd;
+            ++it) {
+        SegmentString* ss0 = *it;
+        for(SegmentString::NonConstVect::const_iterator
+                j = segStrings.begin(), jEnd = segStrings.end();
+                j != jEnd; ++j) {
+            const SegmentString* ss1 = *j;
+            checkInteriorIntersections(*ss0, *ss1);
+        }
+    }
 
 }
 
 /* private */
 void
 NodingValidator::checkInteriorIntersections(const SegmentString& ss0,
-		const SegmentString& ss1)
+        const SegmentString& ss1)
 {
-	const CoordinateSequence& pts0 = *(ss0.getCoordinates());
-	const CoordinateSequence& pts1 = *(ss1.getCoordinates());
-	for (size_t i0 = 0, n0 = pts0.size(); i0 < n0 - 1; ++i0) {
-		for (size_t i1 = 0, n1 = pts1.size(); i1 < n1 - 1; ++i1) {
-			checkInteriorIntersections(ss0, i0, ss1, i1);
-		}
-	}
+    const CoordinateSequence& pts0 = *(ss0.getCoordinates());
+    const CoordinateSequence& pts1 = *(ss1.getCoordinates());
+    for(size_t i0 = 0, n0 = pts0.size(); i0 < n0 - 1; ++i0) {
+        for(size_t i1 = 0, n1 = pts1.size(); i1 < n1 - 1; ++i1) {
+            checkInteriorIntersections(ss0, i0, ss1, i1);
+        }
+    }
 }
 
 
 /* private */
 void
 NodingValidator::checkInteriorIntersections(
-		const SegmentString& e0, size_t segIndex0,
-		const SegmentString& e1, size_t segIndex1)
+    const SegmentString& e0, size_t segIndex0,
+    const SegmentString& e1, size_t segIndex1)
 {
-	if (&e0 == &e1 && segIndex0 == segIndex1) return;
-	const Coordinate& p00 = e0.getCoordinates()->getAt(segIndex0);
-	const Coordinate& p01 = e0.getCoordinates()->getAt(segIndex0 + 1);
-	const Coordinate& p10 = e1.getCoordinates()->getAt(segIndex1);
-	const Coordinate& p11 = e1.getCoordinates()->getAt(segIndex1 + 1);
-
-	li.computeIntersection(p00, p01, p10, p11);
-	if (li.hasIntersection()) {
-		if (li.isProper()
-			|| hasInteriorIntersection(li, p00, p01)
-			|| hasInteriorIntersection(li, p10, p11))
-		{
-			throw util::TopologyException(
-				"found non-noded intersection at "
-				+ p00.toString() + "-" + p01.toString()
-				+ " and "
-				+ p10.toString() + "-" + p11.toString());
-		}
-	}
+    if(&e0 == &e1 && segIndex0 == segIndex1) {
+        return;
+    }
+    const Coordinate& p00 = e0.getCoordinates()->getAt(segIndex0);
+    const Coordinate& p01 = e0.getCoordinates()->getAt(segIndex0 + 1);
+    const Coordinate& p10 = e1.getCoordinates()->getAt(segIndex1);
+    const Coordinate& p11 = e1.getCoordinates()->getAt(segIndex1 + 1);
+
+    li.computeIntersection(p00, p01, p10, p11);
+    if(li.hasIntersection()) {
+        if(li.isProper()
+                || hasInteriorIntersection(li, p00, p01)
+                || hasInteriorIntersection(li, p10, p11)) {
+            throw util::TopologyException(
+                "found non-noded intersection at "
+                + p00.toString() + "-" + p01.toString()
+                + " and "
+                + p10.toString() + "-" + p11.toString());
+        }
+    }
 }
 
 /* private */
 void
 NodingValidator::checkEndPtVertexIntersections() const
 {
-	for (SegmentString::NonConstVect::const_iterator
-		it = segStrings.begin(), itEnd = segStrings.end();
-		it != itEnd;
-		++it)
-	{
-		const SegmentString* ss = *it;
-		const CoordinateSequence& pts = *(ss->getCoordinates());
-		checkEndPtVertexIntersections(pts[0], segStrings);
-		checkEndPtVertexIntersections(pts[pts.size() - 1], segStrings);
-	}
+    for(SegmentString::NonConstVect::const_iterator
+            it = segStrings.begin(), itEnd = segStrings.end();
+            it != itEnd;
+            ++it) {
+        const SegmentString* ss = *it;
+        const CoordinateSequence& pts = *(ss->getCoordinates());
+        checkEndPtVertexIntersections(pts[0], segStrings);
+        checkEndPtVertexIntersections(pts[pts.size() - 1], segStrings);
+    }
 }
 
 /* private */
 void
 NodingValidator::checkEndPtVertexIntersections(const Coordinate& testPt,
-		const SegmentString::NonConstVect& p_segStrings) const
+        const SegmentString::NonConstVect& p_segStrings) const
 {
-	for (SegmentString::NonConstVect::const_iterator
-		it = p_segStrings.begin(), itEnd = p_segStrings.end();
-		it != itEnd;
-		++it)
-	{
-		const SegmentString* ss0 = *it;
-		const CoordinateSequence& pts = *(ss0->getCoordinates());
-		for (size_t j = 1, n=pts.size() - 1; j < n; ++j)
-		{
-			if (pts[j].equals(testPt))
-			{
-				stringstream s;
-				s<<"found endpt/interior pt intersection ";
-				s<<"at index "<<j<<" :pt "<<testPt;
-				throw util::TopologyException(s.str());
-			}
-		}
-	}
+    for(SegmentString::NonConstVect::const_iterator
+            it = p_segStrings.begin(), itEnd = p_segStrings.end();
+            it != itEnd;
+            ++it) {
+        const SegmentString* ss0 = *it;
+        const CoordinateSequence& pts = *(ss0->getCoordinates());
+        for(size_t j = 1, n = pts.size() - 1; j < n; ++j) {
+            if(pts[j].equals(testPt)) {
+                stringstream s;
+                s << "found endpt/interior pt intersection ";
+                s << "at index " << j << " :pt " << testPt;
+                throw util::TopologyException(s.str());
+            }
+        }
+    }
 }
 
 
@@ -191,15 +184,15 @@ NodingValidator::checkEndPtVertexIntersections(const Coordinate& testPt,
 /* private */
 bool
 NodingValidator::hasInteriorIntersection(const LineIntersector& aLi,
-		const Coordinate& p0, const Coordinate& p1) const
+        const Coordinate& p0, const Coordinate& p1) const
 {
-	for (size_t i=0, n = aLi.getIntersectionNum(); i < n; ++i)
-	{
-		const Coordinate &intPt=aLi.getIntersection(i);
-		if (!(intPt==p0 || intPt==p1))
-			return true;
-	}
-	return false;
+    for(size_t i = 0, n = aLi.getIntersectionNum(); i < n; ++i) {
+        const Coordinate& intPt = aLi.getIntersection(i);
+        if(!(intPt == p0 || intPt == p1)) {
+            return true;
+        }
+    }
+    return false;
 }
 
 
diff --git a/src/noding/Octant.cpp b/src/noding/Octant.cpp
index 1611101..5f545a8 100644
--- a/src/noding/Octant.cpp
+++ b/src/noding/Octant.cpp
@@ -33,43 +33,50 @@ namespace noding { // geos.noding
 int
 Octant::octant(double dx, double dy)
 {
-	if (dx == 0.0 && dy == 0.0)
-	{
-		std::ostringstream s;
-      		s<<"Cannot compute the octant for point ( "<<dx<<", "<<dy<<" )";
-      		throw util::IllegalArgumentException(s.str());
-	}
+    if(dx == 0.0 && dy == 0.0) {
+        std::ostringstream s;
+        s << "Cannot compute the octant for point ( " << dx << ", " << dy << " )";
+        throw util::IllegalArgumentException(s.str());
+    }
 
     double adx = std::fabs(dx);
     double ady = std::fabs(dy);
 
-    if (dx >= 0) {
-      if (dy >= 0) {
-        if (adx >= ady)
-          return 0;
-        else
-          return 1;
-      }
-      else { // dy < 0
-        if (adx >= ady)
-          return 7;
-        else
-          return 6;
-      }
+    if(dx >= 0) {
+        if(dy >= 0) {
+            if(adx >= ady) {
+                return 0;
+            }
+            else {
+                return 1;
+            }
+        }
+        else { // dy < 0
+            if(adx >= ady) {
+                return 7;
+            }
+            else {
+                return 6;
+            }
+        }
     }
     else { // dx < 0
-      if (dy >= 0) {
-        if (adx >= ady)
-          return 3;
-        else
-          return 2;
-      }
-      else { // dy < 0
-        if (adx >= ady)
-          return 4;
-        else
-          return 5;
-      }
+        if(dy >= 0) {
+            if(adx >= ady) {
+                return 3;
+            }
+            else {
+                return 2;
+            }
+        }
+        else { // dy < 0
+            if(adx >= ady) {
+                return 4;
+            }
+            else {
+                return 5;
+            }
+        }
     }
 
 }
@@ -78,17 +85,16 @@ Octant::octant(double dx, double dy)
 int
 Octant::octant(const Coordinate& p0, const Coordinate& p1)
 {
-	double dx = p1.x - p0.x;
-	double dy = p1.y - p0.y;
+    double dx = p1.x - p0.x;
+    double dy = p1.y - p0.y;
 
-	if (dx == 0.0 && dy == 0.0)
-	{
-		std::ostringstream s;
-      		s<<"Cannot compute the octant for "<<"two identical points "<<p0.toString();
-      		throw util::IllegalArgumentException(s.str());
-	}
+    if(dx == 0.0 && dy == 0.0) {
+        std::ostringstream s;
+        s << "Cannot compute the octant for " << "two identical points " << p0.toString();
+        throw util::IllegalArgumentException(s.str());
+    }
 
-	return octant(dx, dy);
+    return octant(dx, dy);
 }
 
 } // namespace geos.noding
diff --git a/src/noding/OrientedCoordinateArray.cpp b/src/noding/OrientedCoordinateArray.cpp
index fcfbebf..b5be19a 100644
--- a/src/noding/OrientedCoordinateArray.cpp
+++ b/src/noding/OrientedCoordinateArray.cpp
@@ -40,37 +40,37 @@ namespace noding { // geos.noding
 bool
 OrientedCoordinateArray::orientation(const CoordinateSequence& pts)
 {
-	return CoordinateSequence::increasingDirection(pts) == 1;
+    return CoordinateSequence::increasingDirection(pts) == 1;
 }
 
 int
 OrientedCoordinateArray::compareTo(const OrientedCoordinateArray& oca) const
 {
-	int comp = compareOriented(*pts, orientationVar,
+    int comp = compareOriented(*pts, orientationVar,
                                *oca.pts, oca.orientationVar);
 #if 0 // MD - testing only
     int oldComp = SegmentStringDissolver.ptsComp.compare(pts, oca.pts);
-    if ((oldComp == 0 || comp == 0) && oldComp != comp) {
-      System.out.println("bidir mismatch");
+    if((oldComp == 0 || comp == 0) && oldComp != comp) {
+        System.out.println("bidir mismatch");
 
-      boolean orient1 = orientation(pts);
-      boolean orient2 = orientation(oca.pts);
-      int comp2 = compareOriented(pts, orientation,
-                               oca.pts, oca.orientation);
-      int oldComp2 = SegmentStringDissolver.ptsComp.compare(pts, oca.pts);
+        boolean orient1 = orientation(pts);
+        boolean orient2 = orientation(oca.pts);
+        int comp2 = compareOriented(pts, orientation,
+                                    oca.pts, oca.orientation);
+        int oldComp2 = SegmentStringDissolver.ptsComp.compare(pts, oca.pts);
     }
 #endif
 
-	return comp;
+    return comp;
 }
 
 
 /* private static */
 int
 OrientedCoordinateArray::compareOriented(const geom::CoordinateSequence& pts1,
-                                     bool orientation1,
-                                     const geom::CoordinateSequence& pts2,
-                                     bool orientation2)
+        bool orientation1,
+        const geom::CoordinateSequence& pts2,
+        bool orientation2)
 {
     int dir1 = orientation1 ? 1 : -1;
     int dir2 = orientation2 ? 1 : -1;
@@ -80,17 +80,24 @@ OrientedCoordinateArray::compareOriented(const geom::CoordinateSequence& pts1,
     auto i1 = orientation1 ? 0 : pts1.size() - 1;
     auto i2 = orientation2 ? 0 : pts2.size() - 1;
     //int comp = 0; // unused, but is in JTS ...
-    while (true) {
-      int compPt = pts1[i1].compareTo(pts2[i2]);
-      if (compPt != 0)
-        return compPt;
-      i1 += dir1;
-      i2 += dir2;
-      bool done1 = i1 == limit1;
-      bool done2 = i2 == limit2;
-      if (done1 && ! done2) return -1;
-      if (! done1 && done2) return 1;
-      if (done1 && done2) return 0;
+    while(true) {
+        int compPt = pts1[i1].compareTo(pts2[i2]);
+        if(compPt != 0) {
+            return compPt;
+        }
+        i1 += dir1;
+        i2 += dir2;
+        bool done1 = i1 == limit1;
+        bool done2 = i2 == limit2;
+        if(done1 && ! done2) {
+            return -1;
+        }
+        if(! done1 && done2) {
+            return 1;
+        }
+        if(done1 && done2) {
+            return 0;
+        }
     }
 }
 
diff --git a/src/noding/ScaledNoder.cpp b/src/noding/ScaledNoder.cpp
index 6e2e84e..dcbb005 100644
--- a/src/noding/ScaledNoder.cpp
+++ b/src/noding/ScaledNoder.cpp
@@ -50,23 +50,22 @@ namespace {
 void
 sqlPrint(const std::string& table, std::vector<SegmentString*>& ssv)
 {
-	std::cerr << "CREATE TABLE \"" << table
-		<< "\" (id integer, geom geometry);" << std::endl;
-
-	std::cerr << "COPY \"" << table
-		<< "\" FROM stdin;" << std::endl;
-
-	for (size_t i=0, n=ssv.size(); i<n; i++)
-	{
-		SegmentString* ss=ssv[i];
-		geom::CoordinateSequence* cs = ss->getCoordinates();
-		assert(cs);
-
-		std::cerr << i << '\t' << "LINESTRING"
-			<< *cs
-			<< std::endl;
-	}
-	std::cerr << "\\." << std::endl;
+    std::cerr << "CREATE TABLE \"" << table
+              << "\" (id integer, geom geometry);" << std::endl;
+
+    std::cerr << "COPY \"" << table
+              << "\" FROM stdin;" << std::endl;
+
+    for(size_t i = 0, n = ssv.size(); i < n; i++) {
+        SegmentString* ss = ssv[i];
+        geom::CoordinateSequence* cs = ss->getCoordinates();
+        assert(cs);
+
+        std::cerr << i << '\t' << "LINESTRING"
+                  << *cs
+                  << std::endl;
+    }
+    std::cerr << "\\." << std::endl;
 }
 #endif // GEOS_DEBUG > 1
 
@@ -74,22 +73,24 @@ sqlPrint(const std::string& table, std::vector<SegmentString*>& ssv)
 
 class ScaledNoder::Scaler : public geom::CoordinateFilter {
 public:
-	const ScaledNoder& sn;
-	Scaler(const ScaledNoder&n): sn(n)
-	{
+    const ScaledNoder& sn;
+    Scaler(const ScaledNoder& n): sn(n)
+    {
 #if GEOS_DEBUG
-		std::cerr << "Scaler: offsetX,Y: " << sn.offsetX << ","
-			<< sn.offsetY << " scaleFactor: " << sn.scaleFactor
-			<< std::endl;
+        std::cerr << "Scaler: offsetX,Y: " << sn.offsetX << ","
+                  << sn.offsetY << " scaleFactor: " << sn.scaleFactor
+                  << std::endl;
 #endif
-	}
+    }
 
-	//void filter_ro(const geom::Coordinate* c) { assert(0); }
+    //void filter_ro(const geom::Coordinate* c) { assert(0); }
 
-	void filter_rw(geom::Coordinate* c) const override {
-		c->x = util::round( ( c->x - sn.offsetX ) * sn.scaleFactor );
-		c->y = util::round( ( c->y - sn.offsetY ) * sn.scaleFactor );
-	}
+    void
+    filter_rw(geom::Coordinate* c) const override
+    {
+        c->x = util::round((c->x - sn.offsetX) * sn.scaleFactor);
+        c->y = util::round((c->y - sn.offsetY) * sn.scaleFactor);
+    }
 
 private:
     // Declare type as noncopyable
@@ -99,26 +100,29 @@ private:
 
 class ScaledNoder::ReScaler: public geom::CoordinateFilter {
 public:
-	const ScaledNoder& sn;
-	ReScaler(const ScaledNoder&n): sn(n)
-	{
+    const ScaledNoder& sn;
+    ReScaler(const ScaledNoder& n): sn(n)
+    {
 #if GEOS_DEBUG
-		std::cerr << "ReScaler: offsetX,Y: " << sn.offsetX << ","
-			<< sn.offsetY << " scaleFactor: " << sn.scaleFactor
-			<< std::endl;
+        std::cerr << "ReScaler: offsetX,Y: " << sn.offsetX << ","
+                  << sn.offsetY << " scaleFactor: " << sn.scaleFactor
+                  << std::endl;
 #endif
-	}
+    }
 
-	void filter_ro(const geom::Coordinate* c) override
+    void
+    filter_ro(const geom::Coordinate* c) override
     {
         ::geos::ignore_unused_variable_warning(c);
         assert(0);
     }
 
-	void filter_rw(geom::Coordinate* c) const override {
-		c->x = c->x / sn.scaleFactor + sn.offsetX;
-		c->y = c->y / sn.scaleFactor + sn.offsetY;
-	}
+    void
+    filter_rw(geom::Coordinate* c) const override
+    {
+        c->x = c->x / sn.scaleFactor + sn.offsetX;
+        c->y = c->y / sn.scaleFactor + sn.offsetY;
+    }
 
 private:
     // Declare type as noncopyable
@@ -130,17 +134,16 @@ private:
 void
 ScaledNoder::rescale(SegmentString::NonConstVect& segStrings) const
 {
-	ReScaler rescaler(*this);
-	for (SegmentString::NonConstVect::const_iterator
-		i0=segStrings.begin(), i0End=segStrings.end();
-			i0!=i0End; ++i0)
-	{
+    ReScaler rescaler(*this);
+    for(SegmentString::NonConstVect::const_iterator
+            i0 = segStrings.begin(), i0End = segStrings.end();
+            i0 != i0End; ++i0) {
 
-		SegmentString* ss=*i0;
+        SegmentString* ss = *i0;
 
-		ss->getCoordinates()->apply_rw(&rescaler);
+        ss->getCoordinates()->apply_rw(&rescaler);
 
-	}
+    }
 }
 
 
@@ -148,39 +151,37 @@ ScaledNoder::rescale(SegmentString::NonConstVect& segStrings) const
 void
 ScaledNoder::scale(SegmentString::NonConstVect& segStrings) const
 {
-	Scaler scaler(*this);
-	for (SegmentString::NonConstVect::const_iterator
-		i0=segStrings.begin(), i0End=segStrings.end();
-			i0!=i0End; ++i0)
-	{
-		SegmentString* ss=*i0;
+    Scaler scaler(*this);
+    for(SegmentString::NonConstVect::const_iterator
+            i0 = segStrings.begin(), i0End = segStrings.end();
+            i0 != i0End; ++i0) {
+        SegmentString* ss = *i0;
 
-		CoordinateSequence* cs=ss->getCoordinates();
+        CoordinateSequence* cs = ss->getCoordinates();
 
 #ifndef NDEBUG
-		size_t npts = cs->size();
+        size_t npts = cs->size();
 #endif
-		cs->apply_rw(&scaler);
-		assert(cs->size() == npts);
+        cs->apply_rw(&scaler);
+        assert(cs->size() == npts);
 
-		// Actually, we should be creating *new*
-		// SegmentStrings here, but who's going
-		// to delete them then ? And is it worth
-		// the memory cost ?
-		cs->removeRepeatedPoints();
+        // Actually, we should be creating *new*
+        // SegmentStrings here, but who's going
+        // to delete them then ? And is it worth
+        // the memory cost ?
+        cs->removeRepeatedPoints();
 
-	}
+    }
 }
 
 ScaledNoder::~ScaledNoder()
 {
-	for (std::vector<geom::CoordinateSequence*>::const_iterator
-		it=newCoordSeq.begin(), end=newCoordSeq.end();
-		it != end;
-		++it)
-	{
-		delete *it;
-	}
+    for(std::vector<geom::CoordinateSequence*>::const_iterator
+            it = newCoordSeq.begin(), end = newCoordSeq.end();
+            it != end;
+            ++it) {
+        delete *it;
+    }
 }
 
 
@@ -188,19 +189,21 @@ ScaledNoder::~ScaledNoder()
 SegmentString::NonConstVect*
 ScaledNoder::getNodedSubstrings() const
 {
-	SegmentString::NonConstVect* splitSS = noder.getNodedSubstrings();
+    SegmentString::NonConstVect* splitSS = noder.getNodedSubstrings();
 
 #if GEOS_DEBUG > 1
-	sqlPrint("nodedSegStr", *splitSS);
+    sqlPrint("nodedSegStr", *splitSS);
 #endif
 
-	if ( isScaled ) rescale(*splitSS);
+    if(isScaled) {
+        rescale(*splitSS);
+    }
 
 #if GEOS_DEBUG > 1
-	sqlPrint("scaledNodedSegStr", *splitSS);
+    sqlPrint("scaledNodedSegStr", *splitSS);
 #endif
 
-	return splitSS;
+    return splitSS;
 
 }
 
@@ -210,16 +213,18 @@ ScaledNoder::computeNodes(SegmentString::NonConstVect* inputSegStr)
 {
 
 #if GEOS_DEBUG > 1
-	sqlPrint("inputSegStr", *inputSegStr);
+    sqlPrint("inputSegStr", *inputSegStr);
 #endif
 
-	if (isScaled) scale(*inputSegStr);
+    if(isScaled) {
+        scale(*inputSegStr);
+    }
 
 #if GEOS_DEBUG > 1
-	sqlPrint("scaledInputSegStr", *inputSegStr);
+    sqlPrint("scaledInputSegStr", *inputSegStr);
 #endif
 
-	noder.computeNodes(inputSegStr);
+    noder.computeNodes(inputSegStr);
 }
 
 
diff --git a/src/noding/SegmentIntersectionDetector.cpp b/src/noding/SegmentIntersectionDetector.cpp
index e7fd399..cf71286 100644
--- a/src/noding/SegmentIntersectionDetector.cpp
+++ b/src/noding/SegmentIntersectionDetector.cpp
@@ -29,54 +29,57 @@ namespace noding { // geos::noding
 void
 SegmentIntersectionDetector::
 processIntersections(
-	noding::SegmentString * e0, size_t segIndex0,
-	noding::SegmentString * e1, size_t segIndex1 )
+    noding::SegmentString* e0, size_t segIndex0,
+    noding::SegmentString* e1, size_t segIndex1)
 {
-	// don't bother intersecting a segment with itself
-	if (e0 == e1 && segIndex0 == segIndex1) return;
-
-	const geom::Coordinate & p00 = (*e0->getCoordinates())[ segIndex0 ];
-	const geom::Coordinate & p01 = (*e0->getCoordinates())[ segIndex0 + 1 ];
-	const geom::Coordinate & p10 = (*e1->getCoordinates())[ segIndex1 ];
-	const geom::Coordinate & p11 = (*e1->getCoordinates())[ segIndex1 + 1 ];
-
-	li->computeIntersection( p00, p01, p10, p11);
-
-	if (li->hasIntersection())
-	{
-		// record intersection info
-		_hasIntersection = true;
-
-		bool isProper = li->isProper();
-
-		if (isProper)
-			_hasProperIntersection = true;
-		else
-			_hasNonProperIntersection = true;
-
-		// If this is the kind of intersection we are searching for
-		// OR no location has yet been recorded
-		// save the location data
-		bool saveLocation = true;
-
-		if (findProper && !isProper)
-			saveLocation = false;
-
-		if (!intPt || saveLocation)
-		{
-			// record intersection location (approximate)
-			intPt = &li->getIntersection(0);
-
-			delete intSegments;
-
-			// record intersecting segments
-			intSegments = new geom::CoordinateArraySequence();
-			intSegments->add( p00, true);
-			intSegments->add( p01, true);
-			intSegments->add( p10, true);
-			intSegments->add( p11, true);
-		}
-	}
+    // don't bother intersecting a segment with itself
+    if(e0 == e1 && segIndex0 == segIndex1) {
+        return;
+    }
+
+    const geom::Coordinate& p00 = (*e0->getCoordinates())[ segIndex0 ];
+    const geom::Coordinate& p01 = (*e0->getCoordinates())[ segIndex0 + 1 ];
+    const geom::Coordinate& p10 = (*e1->getCoordinates())[ segIndex1 ];
+    const geom::Coordinate& p11 = (*e1->getCoordinates())[ segIndex1 + 1 ];
+
+    li->computeIntersection(p00, p01, p10, p11);
+
+    if(li->hasIntersection()) {
+        // record intersection info
+        _hasIntersection = true;
+
+        bool isProper = li->isProper();
+
+        if(isProper) {
+            _hasProperIntersection = true;
+        }
+        else {
+            _hasNonProperIntersection = true;
+        }
+
+        // If this is the kind of intersection we are searching for
+        // OR no location has yet been recorded
+        // save the location data
+        bool saveLocation = true;
+
+        if(findProper && !isProper) {
+            saveLocation = false;
+        }
+
+        if(!intPt || saveLocation) {
+            // record intersection location (approximate)
+            intPt = &li->getIntersection(0);
+
+            delete intSegments;
+
+            // record intersecting segments
+            intSegments = new geom::CoordinateArraySequence();
+            intSegments->add(p00, true);
+            intSegments->add(p01, true);
+            intSegments->add(p10, true);
+            intSegments->add(p11, true);
+        }
+    }
 }
 
 
diff --git a/src/noding/SegmentNode.cpp b/src/noding/SegmentNode.cpp
index 5d3bbce..b7913cb 100644
--- a/src/noding/SegmentNode.cpp
+++ b/src/noding/SegmentNode.cpp
@@ -39,18 +39,18 @@ namespace noding { // geos.noding
 
 /*public*/
 SegmentNode::SegmentNode(const NodedSegmentString& ss, const Coordinate& nCoord,
-		size_t nSegmentIndex, int nSegmentOctant)
-	:
-	segString(ss),
-	segmentOctant(nSegmentOctant),
-	coord(nCoord),
-	segmentIndex(nSegmentIndex)
+                         size_t nSegmentIndex, int nSegmentOctant)
+    :
+    segString(ss),
+    segmentOctant(nSegmentOctant),
+    coord(nCoord),
+    segmentIndex(nSegmentIndex)
 {
-	// Number of points in NodedSegmentString is one-more number of segments
-	assert(segmentIndex < segString.size() );
+    // Number of points in NodedSegmentString is one-more number of segments
+    assert(segmentIndex < segString.size());
 
-	isInteriorVar = \
-		!coord.equals2D(segString.getCoordinate(segmentIndex));
+    isInteriorVar = \
+                    !coord.equals2D(segString.getCoordinate(segmentIndex));
 
 }
 
@@ -58,9 +58,13 @@ SegmentNode::SegmentNode(const NodedSegmentString& ss, const Coordinate& nCoord,
 bool
 SegmentNode::isEndPoint(unsigned int maxSegmentIndex) const
 {
-	if (segmentIndex == 0 && ! isInteriorVar) return true;
-	if (segmentIndex == maxSegmentIndex) return true;
-	return false;
+    if(segmentIndex == 0 && ! isInteriorVar) {
+        return true;
+    }
+    if(segmentIndex == maxSegmentIndex) {
+        return true;
+    }
+    return false;
 }
 
 /**
@@ -71,33 +75,38 @@ SegmentNode::isEndPoint(unsigned int maxSegmentIndex) const
 int
 SegmentNode::compareTo(const SegmentNode& other)
 {
-	if (segmentIndex < other.segmentIndex) return -1;
-	if (segmentIndex > other.segmentIndex) return 1;
+    if(segmentIndex < other.segmentIndex) {
+        return -1;
+    }
+    if(segmentIndex > other.segmentIndex) {
+        return 1;
+    }
 
 #if GEOS_DEBUG
-	cerr << setprecision(17) << "compareTo: " << *this << ", " << other <<endl;
+    cerr << setprecision(17) << "compareTo: " << *this << ", " << other << endl;
 #endif
 
-	if (coord.equals2D(other.coord)) {
+    if(coord.equals2D(other.coord)) {
 
 #if GEOS_DEBUG
-		cerr << " Coordinates equal!"<<endl;
+        cerr << " Coordinates equal!" << endl;
 #endif
 
-		return 0;
-	}
+        return 0;
+    }
 
 #if GEOS_DEBUG
-	cerr << " Coordinates do not equal!"<<endl;
+    cerr << " Coordinates do not equal!" << endl;
 #endif
 
-	return SegmentPointComparator::compare(segmentOctant, coord,
-			other.coord);
+    return SegmentPointComparator::compare(segmentOctant, coord,
+                                           other.coord);
 }
 
-ostream& operator<< (ostream& os, const SegmentNode& n)
+ostream&
+operator<< (ostream& os, const SegmentNode& n)
 {
-	return os<<n.coord<<" seg#="<<n.segmentIndex<<" octant#="<<n.segmentOctant<<endl;
+    return os << n.coord << " seg#=" << n.segmentIndex << " octant#=" << n.segmentOctant << endl;
 }
 
 } // namespace geos.noding
diff --git a/src/noding/SegmentNodeList.cpp b/src/noding/SegmentNodeList.cpp
index 1799a84..65504e9 100644
--- a/src/noding/SegmentNodeList.cpp
+++ b/src/noding/SegmentNodeList.cpp
@@ -44,129 +44,132 @@ namespace geos {
 namespace noding { // geos.noding
 
 #if PROFILE
-static Profiler *profiler = Profiler::instance();
+static Profiler* profiler = Profiler::instance();
 #endif
 
 
 SegmentNodeList::~SegmentNodeList()
 {
-	std::set<SegmentNode *, SegmentNodeLT>::iterator it=nodeMap.begin();
-	for(; it!=nodeMap.end(); it++)
-	{
-		delete *it;
-	}
+    std::set<SegmentNode*, SegmentNodeLT>::iterator it = nodeMap.begin();
+    for(; it != nodeMap.end(); it++) {
+        delete *it;
+    }
 }
 
 SegmentNode*
 SegmentNodeList::add(const Coordinate& intPt, size_t segmentIndex)
 {
-	SegmentNode *eiNew=new SegmentNode(edge, intPt, segmentIndex,
-			edge.getSegmentOctant(segmentIndex));
+    SegmentNode* eiNew = new SegmentNode(edge, intPt, segmentIndex,
+                                         edge.getSegmentOctant(segmentIndex));
 
-	std::pair<SegmentNodeList::iterator,bool> p = nodeMap.insert(eiNew);
-	if ( p.second ) { // new SegmentNode inserted
-		return eiNew;
-	} else {
+    std::pair<SegmentNodeList::iterator, bool> p = nodeMap.insert(eiNew);
+    if(p.second) {    // new SegmentNode inserted
+        return eiNew;
+    }
+    else {
 
-		// sanity check
-		assert(eiNew->coord.equals2D(intPt));
+        // sanity check
+        assert(eiNew->coord.equals2D(intPt));
 
-		delete eiNew;
-		return *(p.first);
-	}
+        delete eiNew;
+        return *(p.first);
+    }
 }
 
-void SegmentNodeList::addEndpoints()
+void
+SegmentNodeList::addEndpoints()
 {
-	size_t maxSegIndex = edge.size() - 1;
-	add(&(edge.getCoordinate(0)), 0);
-	add(&(edge.getCoordinate(maxSegIndex)), maxSegIndex);
+    size_t maxSegIndex = edge.size() - 1;
+    add(&(edge.getCoordinate(0)), 0);
+    add(&(edge.getCoordinate(maxSegIndex)), maxSegIndex);
 }
 
 /* private */
 void
 SegmentNodeList::addCollapsedNodes()
 {
-	std::vector<size_t> collapsedVertexIndexes;
-
-	findCollapsesFromInsertedNodes(collapsedVertexIndexes);
-	findCollapsesFromExistingVertices(collapsedVertexIndexes);
-
-	// node the collapses
-	for (std::vector<size_t>::iterator
-		i=collapsedVertexIndexes.begin(),
-			e=collapsedVertexIndexes.end();
-		i != e; ++i)
-	{
-		auto vertexIndex = *i;
-		add(edge.getCoordinate(vertexIndex), vertexIndex);
-	}
+    std::vector<size_t> collapsedVertexIndexes;
+
+    findCollapsesFromInsertedNodes(collapsedVertexIndexes);
+    findCollapsesFromExistingVertices(collapsedVertexIndexes);
+
+    // node the collapses
+    for(std::vector<size_t>::iterator
+            i = collapsedVertexIndexes.begin(),
+            e = collapsedVertexIndexes.end();
+            i != e; ++i) {
+        auto vertexIndex = *i;
+        add(edge.getCoordinate(vertexIndex), vertexIndex);
+    }
 }
 
 
 /* private */
 void
 SegmentNodeList::findCollapsesFromExistingVertices(
-			std::vector<size_t>& collapsedVertexIndexes)
+    std::vector<size_t>& collapsedVertexIndexes)
 {
-	if ( edge.size() < 2 ) return; // or we'll never exit the loop below
-
-	for (size_t i=0, n=edge.size()-2; i<n; ++i)
-	{
-		const Coordinate& p0 = edge.getCoordinate(i);
-		const Coordinate& p2 = edge.getCoordinate(i + 2);
-		if (p0.equals2D(p2)) {
-			// add base of collapse as node
-			collapsedVertexIndexes.push_back(i + 1);
-		}
-	}
+    if(edge.size() < 2) {
+        return;    // or we'll never exit the loop below
+    }
+
+    for(size_t i = 0, n = edge.size() - 2; i < n; ++i) {
+        const Coordinate& p0 = edge.getCoordinate(i);
+        const Coordinate& p2 = edge.getCoordinate(i + 2);
+        if(p0.equals2D(p2)) {
+            // add base of collapse as node
+            collapsedVertexIndexes.push_back(i + 1);
+        }
+    }
 }
 
 /* private */
 void
 SegmentNodeList::findCollapsesFromInsertedNodes(
-		std::vector<size_t>& collapsedVertexIndexes)
+    std::vector<size_t>& collapsedVertexIndexes)
 {
-	size_t collapsedVertexIndex;
-
-	// there should always be at least two entries in the list,
-	// since the endpoints are nodes
-	iterator it = begin();
-	SegmentNode* eiPrev = *it;
-	++it;
-	for(iterator itEnd=end(); it!=itEnd; ++it)
-	{
-		SegmentNode *ei=*it;
-      		bool isCollapsed = findCollapseIndex(*eiPrev, *ei,
-				collapsedVertexIndex);
-		if (isCollapsed)
-			collapsedVertexIndexes.push_back(collapsedVertexIndex);
-
-		eiPrev = ei;
-	}
+    size_t collapsedVertexIndex;
+
+    // there should always be at least two entries in the list,
+    // since the endpoints are nodes
+    iterator it = begin();
+    SegmentNode* eiPrev = *it;
+    ++it;
+    for(iterator itEnd = end(); it != itEnd; ++it) {
+        SegmentNode* ei = *it;
+        bool isCollapsed = findCollapseIndex(*eiPrev, *ei,
+                                             collapsedVertexIndex);
+        if(isCollapsed) {
+            collapsedVertexIndexes.push_back(collapsedVertexIndex);
+        }
+
+        eiPrev = ei;
+    }
 }
 
 /* private */
 bool
 SegmentNodeList::findCollapseIndex(SegmentNode& ei0, SegmentNode& ei1,
-		size_t& collapsedVertexIndex)
+                                   size_t& collapsedVertexIndex)
 {
-	assert(ei1.segmentIndex >= ei0.segmentIndex);
-	// only looking for equal nodes
-	if (! ei0.coord.equals2D(ei1.coord)) return false;
-
-	auto numVerticesBetween = ei1.segmentIndex - ei0.segmentIndex;
-	if (! ei1.isInterior()) {
-		numVerticesBetween--;
-	}
-
-	// if there is a single vertex between the two equal nodes,
-	// this is a collapse
-	if (numVerticesBetween == 1) {
-		collapsedVertexIndex = ei0.segmentIndex + 1;
-		return true;
-	}
-	return false;
+    assert(ei1.segmentIndex >= ei0.segmentIndex);
+    // only looking for equal nodes
+    if(! ei0.coord.equals2D(ei1.coord)) {
+        return false;
+    }
+
+    auto numVerticesBetween = ei1.segmentIndex - ei0.segmentIndex;
+    if(! ei1.isInterior()) {
+        numVerticesBetween--;
+    }
+
+    // if there is a single vertex between the two equal nodes,
+    // this is a collapse
+    if(numVerticesBetween == 1) {
+        collapsedVertexIndex = ei0.segmentIndex + 1;
+        return true;
+    }
+    return false;
 }
 
 
@@ -175,40 +178,41 @@ void
 SegmentNodeList::addSplitEdges(std::vector<SegmentString*>& edgeList)
 {
 
-	// testingOnly
+    // testingOnly
 #if GEOS_DEBUG
-	std::cerr<<__FUNCTION__<<" entered"<<std::endl;
-	std::vector<SegmentString*> testingSplitEdges;
+    std::cerr << __FUNCTION__ << " entered" << std::endl;
+    std::vector<SegmentString*> testingSplitEdges;
 #endif
 
-	// ensure that the list has entries for the first and last
-	// point of the edge
-	addEndpoints();
-	addCollapsedNodes();
-
-	// there should always be at least two entries in the list
-	// since the endpoints are nodes
-	iterator it=begin();
-	SegmentNode *eiPrev=*it;
-	assert(eiPrev);
-	it++;
-	for(iterator itEnd=end(); it!=itEnd; ++it)
-	{
-		SegmentNode *ei=*it;
-		assert(ei);
-
-		if ( ! ei->compareTo(*eiPrev) ) continue;
-
-		SegmentString *newEdge=createSplitEdge(eiPrev, ei);
-		edgeList.push_back(newEdge);
+    // ensure that the list has entries for the first and last
+    // point of the edge
+    addEndpoints();
+    addCollapsedNodes();
+
+    // there should always be at least two entries in the list
+    // since the endpoints are nodes
+    iterator it = begin();
+    SegmentNode* eiPrev = *it;
+    assert(eiPrev);
+    it++;
+    for(iterator itEnd = end(); it != itEnd; ++it) {
+        SegmentNode* ei = *it;
+        assert(ei);
+
+        if(! ei->compareTo(*eiPrev)) {
+            continue;
+        }
+
+        SegmentString* newEdge = createSplitEdge(eiPrev, ei);
+        edgeList.push_back(newEdge);
 #if GEOS_DEBUG
-		testingSplitEdges.push_back(newEdge);
+        testingSplitEdges.push_back(newEdge);
 #endif
-		eiPrev = ei;
-	}
+        eiPrev = ei;
+    }
 #if GEOS_DEBUG
-	std::cerr<<__FUNCTION__<<" finished, now checking correctness"<<std::endl;
-	checkSplitEdgesCorrectness(testingSplitEdges);
+    std::cerr << __FUNCTION__ << " finished, now checking correctness" << std::endl;
+    checkSplitEdgesCorrectness(testingSplitEdges);
 #endif
 }
 
@@ -216,91 +220,93 @@ SegmentNodeList::addSplitEdges(std::vector<SegmentString*>& edgeList)
 void
 SegmentNodeList::checkSplitEdgesCorrectness(std::vector<SegmentString*>& splitEdges)
 {
-	const CoordinateSequence *edgePts=edge.getCoordinates();
-	assert(edgePts);
+    const CoordinateSequence* edgePts = edge.getCoordinates();
+    assert(edgePts);
 
-	// check that first and last points of split edges
-	// are same as endpoints of edge
-	SegmentString *split0=splitEdges[0];
-	assert(split0);
+    // check that first and last points of split edges
+    // are same as endpoints of edge
+    SegmentString* split0 = splitEdges[0];
+    assert(split0);
 
-	const Coordinate& pt0=split0->getCoordinate(0);
-	if (!(pt0==edgePts->getAt(0)))
-		throw util::GEOSException("bad split edge start point at " + pt0.toString());
+    const Coordinate& pt0 = split0->getCoordinate(0);
+    if(!(pt0 == edgePts->getAt(0))) {
+        throw util::GEOSException("bad split edge start point at " + pt0.toString());
+    }
 
-	SegmentString *splitn=splitEdges[splitEdges.size()-1];
-	assert(splitn);
+    SegmentString* splitn = splitEdges[splitEdges.size() - 1];
+    assert(splitn);
 
-	const CoordinateSequence *splitnPts=splitn->getCoordinates();
-	assert(splitnPts);
+    const CoordinateSequence* splitnPts = splitn->getCoordinates();
+    assert(splitnPts);
 
-	const Coordinate &ptn=splitnPts->getAt(splitnPts->getSize()-1);
-	if (!(ptn==edgePts->getAt(edgePts->getSize()-1)))
-		throw util::GEOSException("bad split edge end point at " + ptn.toString());
+    const Coordinate& ptn = splitnPts->getAt(splitnPts->getSize() - 1);
+    if(!(ptn == edgePts->getAt(edgePts->getSize() - 1))) {
+        throw util::GEOSException("bad split edge end point at " + ptn.toString());
+    }
 }
 
 /*private*/
 SegmentString*
-SegmentNodeList::createSplitEdge(SegmentNode *ei0, SegmentNode *ei1)
+SegmentNodeList::createSplitEdge(SegmentNode* ei0, SegmentNode* ei1)
 {
-	assert(ei0);
-	assert(ei1);
+    assert(ei0);
+    assert(ei1);
 
-	size_t npts = ei1->segmentIndex - ei0->segmentIndex + 2;
+    size_t npts = ei1->segmentIndex - ei0->segmentIndex + 2;
 
-	const Coordinate &lastSegStartPt=edge.getCoordinate(ei1->segmentIndex);
+    const Coordinate& lastSegStartPt = edge.getCoordinate(ei1->segmentIndex);
 
-	// if the last intersection point is not equal to the its
-	// segment start pt, add it to the points list as well.
-	// (This check is needed because the distance metric is not
-	// totally reliable!)
+    // if the last intersection point is not equal to the its
+    // segment start pt, add it to the points list as well.
+    // (This check is needed because the distance metric is not
+    // totally reliable!)
 
-	// The check for point equality is 2D only - Z values are ignored
+    // The check for point equality is 2D only - Z values are ignored
 
-	// Added check for npts being == 2 as in that case NOT using second point
-	// would mean creating a SegmentString with a single point
-	// FIXME: check with mbdavis about this, ie: is it a bug in the caller ?
-	//
-	bool useIntPt1 = npts == 2 || (ei1->isInterior() || ! ei1->coord.equals2D(lastSegStartPt));
+    // Added check for npts being == 2 as in that case NOT using second point
+    // would mean creating a SegmentString with a single point
+    // FIXME: check with mbdavis about this, ie: is it a bug in the caller ?
+    //
+    bool useIntPt1 = npts == 2 || (ei1->isInterior() || ! ei1->coord.equals2D(lastSegStartPt));
 
-	if (! useIntPt1) {
-		npts--;
-	}
+    if(! useIntPt1) {
+        npts--;
+    }
 
-	CoordinateSequence *pts = new CoordinateArraySequence(npts);
-	size_t ipt = 0;
-	pts->setAt(ei0->coord, ipt++);
-	for (size_t i=ei0->segmentIndex+1; i<=ei1->segmentIndex; i++)
-	{
-		pts->setAt(edge.getCoordinate(i),ipt++);
-	}
-	if (useIntPt1) 	pts->setAt(ei1->coord, ipt++);
+    CoordinateSequence* pts = new CoordinateArraySequence(npts);
+    size_t ipt = 0;
+    pts->setAt(ei0->coord, ipt++);
+    for(size_t i = ei0->segmentIndex + 1; i <= ei1->segmentIndex; i++) {
+        pts->setAt(edge.getCoordinate(i), ipt++);
+    }
+    if(useIntPt1) {
+        pts->setAt(ei1->coord, ipt++);
+    }
 
-	// SegmentString takes ownership of CoordinateList 'pts'
-	SegmentString *ret = new NodedSegmentString(pts, edge.getData());
+    // SegmentString takes ownership of CoordinateList 'pts'
+    SegmentString* ret = new NodedSegmentString(pts, edge.getData());
 
 #if GEOS_DEBUG
-	std::cerr<<" SegmentString created"<<std::endl;
+    std::cerr << " SegmentString created" << std::endl;
 #endif
 
-	return ret;
+    return ret;
 }
 
 std::ostream&
 operator<< (std::ostream& os, const SegmentNodeList& nlist)
 {
-	os << "Intersections: (" << nlist.nodeMap.size() << "):" << std::endl;
-
-	std::set<SegmentNode*,SegmentNodeLT>::const_iterator
-			it = nlist.nodeMap.begin(),
-			itEnd = nlist.nodeMap.end();
-
-	for(; it!=itEnd; it++)
-	{
-		SegmentNode *ei=*it;
-		os << " " << *ei;
-	}
-	return os;
+    os << "Intersections: (" << nlist.nodeMap.size() << "):" << std::endl;
+
+    std::set<SegmentNode*, SegmentNodeLT>::const_iterator
+    it = nlist.nodeMap.begin(),
+    itEnd = nlist.nodeMap.end();
+
+    for(; it != itEnd; it++) {
+        SegmentNode* ei = *it;
+        os << " " << *ei;
+    }
+    return os;
 }
 
 } // namespace geos.noding
diff --git a/src/noding/SegmentString.cpp b/src/noding/SegmentString.cpp
index 26b1981..7531bfd 100644
--- a/src/noding/SegmentString.cpp
+++ b/src/noding/SegmentString.cpp
@@ -40,16 +40,17 @@ using namespace geos::geom;
 namespace geos {
 namespace noding { // geos.noding
 
-std::ostream& operator<< (std::ostream& os, const SegmentString& ss)
+std::ostream&
+operator<< (std::ostream& os, const SegmentString& ss)
 {
-	return ss.print(os);
+    return ss.print(os);
 }
 
 std::ostream&
 SegmentString::print(std::ostream& os) const
 {
-	os << "SegmentString" << std::endl;
-	return os;
+    os << "SegmentString" << std::endl;
+    return os;
 }
 
 } // namespace geos.noding
diff --git a/src/noding/SimpleNoder.cpp b/src/noding/SimpleNoder.cpp
index 8bc6fb5..b45218f 100644
--- a/src/noding/SimpleNoder.cpp
+++ b/src/noding/SimpleNoder.cpp
@@ -31,15 +31,15 @@ namespace noding { // geos.noding
 void
 SimpleNoder::computeIntersects(SegmentString* e0, SegmentString* e1)
 {
-	assert(segInt); // must provide a segment intersector!
+    assert(segInt); // must provide a segment intersector!
 
-	const CoordinateSequence* pts0 = e0->getCoordinates();
-	const CoordinateSequence* pts1 = e1->getCoordinates();
-	for (size_t i0=0, n0 = pts0->getSize() - 1; i0 < n0; i0++) {
-		for (size_t i1=0, n1 = pts1->getSize() - 1; i1 < n1; i1++) {
-			segInt->processIntersections(e0, i0, e1, i1);
-		}
-	}
+    const CoordinateSequence* pts0 = e0->getCoordinates();
+    const CoordinateSequence* pts1 = e1->getCoordinates();
+    for(size_t i0 = 0, n0 = pts0->getSize() - 1; i0 < n0; i0++) {
+        for(size_t i1 = 0, n1 = pts1->getSize() - 1; i1 < n1; i1++) {
+            segInt->processIntersections(e0, i0, e1, i1);
+        }
+    }
 
 }
 
@@ -47,21 +47,19 @@ SimpleNoder::computeIntersects(SegmentString* e0, SegmentString* e1)
 void
 SimpleNoder::computeNodes(SegmentString::NonConstVect* inputSegmentStrings)
 {
-	nodedSegStrings=inputSegmentStrings;
+    nodedSegStrings = inputSegmentStrings;
 
-	for (SegmentString::NonConstVect::const_iterator
-			i0=inputSegmentStrings->begin(), i0End=inputSegmentStrings->end();
-			i0!=i0End; ++i0)
-	{
-		SegmentString* edge0 = *i0;
-		for (SegmentString::NonConstVect::iterator
-			i1=inputSegmentStrings->begin(), i1End=inputSegmentStrings->end();
-			i1!=i1End; ++i1)
-		{
-		        SegmentString* edge1 = *i1;
-			computeIntersects(edge0, edge1);
-		}
-	}
+    for(SegmentString::NonConstVect::const_iterator
+            i0 = inputSegmentStrings->begin(), i0End = inputSegmentStrings->end();
+            i0 != i0End; ++i0) {
+        SegmentString* edge0 = *i0;
+        for(SegmentString::NonConstVect::iterator
+                i1 = inputSegmentStrings->begin(), i1End = inputSegmentStrings->end();
+                i1 != i1End; ++i1) {
+            SegmentString* edge1 = *i1;
+            computeIntersects(edge0, edge1);
+        }
+    }
 }
 
 
diff --git a/src/noding/snapround/HotPixel.cpp b/src/noding/snapround/HotPixel.cpp
index 5d1459f..f026851 100644
--- a/src/noding/snapround/HotPixel.cpp
+++ b/src/noding/snapround/HotPixel.cpp
@@ -38,118 +38,140 @@ namespace noding { // geos.noding
 namespace snapround { // geos.noding.snapround
 
 HotPixel::HotPixel(const Coordinate& newPt, double newScaleFactor,
-		LineIntersector& newLi)
-	:
-	li(newLi),
-	pt(newPt),
-	originalPt(newPt),
-	scaleFactor(newScaleFactor)
+                   LineIntersector& newLi)
+    :
+    li(newLi),
+    pt(newPt),
+    originalPt(newPt),
+    scaleFactor(newScaleFactor)
 {
-	if (scaleFactor != 1.0) {
-		assert( scaleFactor != 0 ); // or should it be an IllegalArgumentException ?
-		pt.x=scale(pt.x);
-		pt.y=scale(pt.y);
-	}
-	initCorners(pt);
+    if(scaleFactor != 1.0) {
+        assert(scaleFactor != 0);   // or should it be an IllegalArgumentException ?
+        pt.x = scale(pt.x);
+        pt.y = scale(pt.y);
+    }
+    initCorners(pt);
 }
 
 const Envelope&
 HotPixel::getSafeEnvelope() const
 {
-	static const double SAFE_ENV_EXPANSION_FACTOR = 0.75;
-
-	if (safeEnv.get() == nullptr) {
-		double safeTolerance = SAFE_ENV_EXPANSION_FACTOR / scaleFactor;
-		safeEnv = unique_ptr<Envelope>(new Envelope(originalPt.x - safeTolerance,
-			originalPt.x + safeTolerance,
-			originalPt.y - safeTolerance,
-			originalPt.y + safeTolerance
-			));
-	}
-	return *safeEnv;
+    static const double SAFE_ENV_EXPANSION_FACTOR = 0.75;
+
+    if(safeEnv.get() == nullptr) {
+        double safeTolerance = SAFE_ENV_EXPANSION_FACTOR / scaleFactor;
+        safeEnv = unique_ptr<Envelope>(new Envelope(originalPt.x - safeTolerance,
+                                       originalPt.x + safeTolerance,
+                                       originalPt.y - safeTolerance,
+                                       originalPt.y + safeTolerance
+                                                   ));
+    }
+    return *safeEnv;
 }
 
 /*private*/
 void
 HotPixel::initCorners(const Coordinate& p_pt)
 {
-	double tolerance = 0.5;
-	minx = p_pt.x - tolerance;
-	maxx = p_pt.x + tolerance;
-	miny = p_pt.y - tolerance;
-	maxy = p_pt.y + tolerance;
-
-	corner.resize(4);
-	corner[0] = Coordinate(maxx, maxy);
-	corner[1] = Coordinate(minx, maxy);
-	corner[2] = Coordinate(minx, miny);
-	corner[3] = Coordinate(maxx, miny);
+    double tolerance = 0.5;
+    minx = p_pt.x - tolerance;
+    maxx = p_pt.x + tolerance;
+    miny = p_pt.y - tolerance;
+    maxy = p_pt.y + tolerance;
+
+    corner.resize(4);
+    corner[0] = Coordinate(maxx, maxy);
+    corner[1] = Coordinate(minx, maxy);
+    corner[2] = Coordinate(minx, miny);
+    corner[3] = Coordinate(maxx, miny);
 }
 
 bool
 HotPixel::intersects(const Coordinate& p0,
-		const Coordinate& p1) const
+                     const Coordinate& p1) const
 {
-	if (scaleFactor == 1.0) return intersectsScaled(p0, p1);
+    if(scaleFactor == 1.0) {
+        return intersectsScaled(p0, p1);
+    }
 
-	copyScaled(p0, p0Scaled);
-	copyScaled(p1, p1Scaled);
+    copyScaled(p0, p0Scaled);
+    copyScaled(p1, p1Scaled);
 
-	return intersectsScaled(p0Scaled, p1Scaled);
+    return intersectsScaled(p0Scaled, p1Scaled);
 }
 
 /* private */
 bool
 HotPixel::intersectsScaled(const Coordinate& p0,
-		const Coordinate& p1) const
+                           const Coordinate& p1) const
 {
 
-	double const segMinx = std::min(p0.x, p1.x);
-	double const segMaxx = std::max(p0.x, p1.x);
-	double const segMiny = std::min(p0.y, p1.y);
-	double const segMaxy = std::max(p0.y, p1.y);
+    double const segMinx = std::min(p0.x, p1.x);
+    double const segMaxx = std::max(p0.x, p1.x);
+    double const segMiny = std::min(p0.y, p1.y);
+    double const segMaxy = std::max(p0.y, p1.y);
 
-	bool isOutsidePixelEnv =  maxx < segMinx
-                         || minx > segMaxx
-                         || maxy < segMiny
-                         || miny > segMaxy;
+    bool isOutsidePixelEnv =  maxx < segMinx
+                              || minx > segMaxx
+                              || maxy < segMiny
+                              || miny > segMaxy;
 
-	if (isOutsidePixelEnv) return false;
+    if(isOutsidePixelEnv) {
+        return false;
+    }
 
-	bool p_intersects = intersectsToleranceSquare(p0, p1);
+    bool p_intersects = intersectsToleranceSquare(p0, p1);
 
-	// Found bad envelope test
-	assert(!(isOutsidePixelEnv && p_intersects));
+    // Found bad envelope test
+    assert(!(isOutsidePixelEnv && p_intersects));
 
-	return p_intersects;
+    return p_intersects;
 }
 
 /*private*/
 bool
 HotPixel::intersectsToleranceSquare(const Coordinate& p0,
-		const Coordinate& p1) const
+                                    const Coordinate& p1) const
 {
     bool intersectsLeft = false;
     bool intersectsBottom = false;
 
     li.computeIntersection(p0, p1, corner[0], corner[1]);
-    if (li.isProper()) return true;
+    if(li.isProper()) {
+        return true;
+    }
 
     li.computeIntersection(p0, p1, corner[1], corner[2]);
-    if (li.isProper()) return true;
-    if (li.hasIntersection()) intersectsLeft = true;
+    if(li.isProper()) {
+        return true;
+    }
+    if(li.hasIntersection()) {
+        intersectsLeft = true;
+    }
 
     li.computeIntersection(p0, p1, corner[2], corner[3]);
-    if (li.isProper()) return true;
-    if (li.hasIntersection()) intersectsBottom = true;
+    if(li.isProper()) {
+        return true;
+    }
+    if(li.hasIntersection()) {
+        intersectsBottom = true;
+    }
 
     li.computeIntersection(p0, p1, corner[3], corner[0]);
-    if (li.isProper()) return true;
+    if(li.isProper()) {
+        return true;
+    }
 
-    if (intersectsLeft && intersectsBottom) return true;
+    if(intersectsLeft && intersectsBottom) {
+        return true;
+    }
 
-    if (p0.equals2D(pt)) return true;
-    if (p1.equals2D(pt)) return true;
+    if(p0.equals2D(pt)) {
+        return true;
+    }
+    if(p1.equals2D(pt)) {
+        return true;
+    }
 
     return false;
 }
@@ -157,16 +179,24 @@ HotPixel::intersectsToleranceSquare(const Coordinate& p0,
 /*private*/
 bool
 HotPixel::intersectsPixelClosure(const Coordinate& p0,
-		const Coordinate& p1)
+                                 const Coordinate& p1)
 {
     li.computeIntersection(p0, p1, corner[0], corner[1]);
-    if (li.hasIntersection()) return true;
+    if(li.hasIntersection()) {
+        return true;
+    }
     li.computeIntersection(p0, p1, corner[1], corner[2]);
-    if (li.hasIntersection()) return true;
+    if(li.hasIntersection()) {
+        return true;
+    }
     li.computeIntersection(p0, p1, corner[2], corner[3]);
-    if (li.hasIntersection()) return true;
+    if(li.hasIntersection()) {
+        return true;
+    }
     li.computeIntersection(p0, p1, corner[3], corner[0]);
-    if (li.hasIntersection()) return true;
+    if(li.hasIntersection()) {
+        return true;
+    }
 
     return false;
 }
@@ -174,16 +204,15 @@ HotPixel::intersectsPixelClosure(const Coordinate& p0,
 bool
 HotPixel::addSnappedNode(NodedSegmentString& segStr, size_t segIndex)
 {
-	const Coordinate& p0 = segStr.getCoordinate(segIndex);
-	const Coordinate& p1 = segStr.getCoordinate(segIndex + 1);
-
-	if (intersects(p0, p1))
-	{
-		//cout << "snapped: " <<  snapPt << endl;
-		segStr.addIntersection(getCoordinate(), segIndex);
-		return true;
-	}
-	return false;
+    const Coordinate& p0 = segStr.getCoordinate(segIndex);
+    const Coordinate& p1 = segStr.getCoordinate(segIndex + 1);
+
+    if(intersects(p0, p1)) {
+        //cout << "snapped: " <<  snapPt << endl;
+        segStr.addIntersection(getCoordinate(), segIndex);
+        return true;
+    }
+    return false;
 }
 
 
diff --git a/src/noding/snapround/MCIndexPointSnapper.cpp b/src/noding/snapround/MCIndexPointSnapper.cpp
index accfd94..b798eaa 100644
--- a/src/noding/snapround/MCIndexPointSnapper.cpp
+++ b/src/noding/snapround/MCIndexPointSnapper.cpp
@@ -40,44 +40,52 @@ class HotPixelSnapAction: public index::chain::MonotoneChainSelectAction {
 
 public:
 
-	HotPixelSnapAction(HotPixel& nHotPixel,
-			SegmentString* nParentEdge,
-			size_t nVertexIndex)
-		:
-		MonotoneChainSelectAction(),
-		hotPixel(nHotPixel),
-		parentEdge(nParentEdge),
-		vertexIndex(nVertexIndex),
-		isNodeAddedVar(false)
-	{}
-
-	bool isNodeAdded() const { return isNodeAddedVar; }
-
-	void select(chain::MonotoneChain& mc, size_t startIndex) override
-	{
-		// This is casting away 'constness'!
-		NodedSegmentString& ss = *(static_cast<NodedSegmentString*>(mc.getContext()));
-
-		// don't snap a vertex to itself
-		if ( parentEdge ) {
-			if (&ss == parentEdge && startIndex == vertexIndex) return;
-		}
-
-		//isNodeAddedVar = SimpleSnapRounder::addSnappedNode(hotPixel, ss, startIndex);
-
-		isNodeAddedVar = hotPixel.addSnappedNode(ss, startIndex);
-	}
-
-	void select(const LineSegment& ls) override
-	{
-		::geos::ignore_unused_variable_warning(ls);
-	}
+    HotPixelSnapAction(HotPixel& nHotPixel,
+                       SegmentString* nParentEdge,
+                       size_t nVertexIndex)
+        :
+        MonotoneChainSelectAction(),
+        hotPixel(nHotPixel),
+        parentEdge(nParentEdge),
+        vertexIndex(nVertexIndex),
+        isNodeAddedVar(false)
+    {}
+
+    bool
+    isNodeAdded() const
+    {
+        return isNodeAddedVar;
+    }
+
+    void
+    select(chain::MonotoneChain& mc, size_t startIndex) override
+    {
+        // This is casting away 'constness'!
+        NodedSegmentString& ss = *(static_cast<NodedSegmentString*>(mc.getContext()));
+
+        // don't snap a vertex to itself
+        if(parentEdge) {
+            if(&ss == parentEdge && startIndex == vertexIndex) {
+                return;
+            }
+        }
+
+        //isNodeAddedVar = SimpleSnapRounder::addSnappedNode(hotPixel, ss, startIndex);
+
+        isNodeAddedVar = hotPixel.addSnappedNode(ss, startIndex);
+    }
+
+    void
+    select(const LineSegment& ls) override
+    {
+        ::geos::ignore_unused_variable_warning(ls);
+    }
 
 private:
-	HotPixel& hotPixel;
-	SegmentString* parentEdge;
-	size_t vertexIndex;
-	bool isNodeAddedVar;
+    HotPixel& hotPixel;
+    SegmentString* parentEdge;
+    size_t vertexIndex;
+    bool isNodeAddedVar;
 
     // Declare type as noncopyable
     HotPixelSnapAction(const HotPixelSnapAction& other) = delete;
@@ -87,23 +95,25 @@ private:
 class MCIndexPointSnapperVisitor: public ItemVisitor {
 
 public:
-	MCIndexPointSnapperVisitor(const Envelope& nPixelEnv, HotPixelSnapAction& nAction)
-		:
-		pixelEnv(nPixelEnv),
-		action(nAction)
-	{}
-
-	~MCIndexPointSnapperVisitor() override {}
-
-	void visitItem(void* item) override {
-		chain::MonotoneChain& testChain =
-			*(static_cast<chain::MonotoneChain*>(item));
-		testChain.select(pixelEnv, action);
-	}
+    MCIndexPointSnapperVisitor(const Envelope& nPixelEnv, HotPixelSnapAction& nAction)
+        :
+        pixelEnv(nPixelEnv),
+        action(nAction)
+    {}
+
+    ~MCIndexPointSnapperVisitor() override {}
+
+    void
+    visitItem(void* item) override
+    {
+        chain::MonotoneChain& testChain =
+            *(static_cast<chain::MonotoneChain*>(item));
+        testChain.select(pixelEnv, action);
+    }
 
 private:
-	const Envelope& pixelEnv;
-	chain::MonotoneChainSelectAction& action;
+    const Envelope& pixelEnv;
+    chain::MonotoneChainSelectAction& action;
 
     // Declare type as noncopyable
     MCIndexPointSnapperVisitor(const MCIndexPointSnapperVisitor& other);
@@ -113,16 +123,16 @@ private:
 /* public */
 bool
 MCIndexPointSnapper::snap(HotPixel& hotPixel,
-		SegmentString* parentEdge,
-		size_t vertexIndex)
+                          SegmentString* parentEdge,
+                          size_t vertexIndex)
 {
-	const Envelope& pixelEnv = hotPixel.getSafeEnvelope();
-	HotPixelSnapAction hotPixelSnapAction(hotPixel, parentEdge, vertexIndex);
-	MCIndexPointSnapperVisitor visitor(pixelEnv, hotPixelSnapAction);
+    const Envelope& pixelEnv = hotPixel.getSafeEnvelope();
+    HotPixelSnapAction hotPixelSnapAction(hotPixel, parentEdge, vertexIndex);
+    MCIndexPointSnapperVisitor visitor(pixelEnv, hotPixelSnapAction);
 
-	index.query(&pixelEnv, visitor);
+    index.query(&pixelEnv, visitor);
 
-	return hotPixelSnapAction.isNodeAdded();
+    return hotPixelSnapAction.isNodeAdded();
 }
 
 } // namespace geos.noding.snapround
diff --git a/src/noding/snapround/MCIndexSnapRounder.cpp b/src/noding/snapround/MCIndexSnapRounder.cpp
index b756c1b..5089caa 100644
--- a/src/noding/snapround/MCIndexSnapRounder.cpp
+++ b/src/noding/snapround/MCIndexSnapRounder.cpp
@@ -41,68 +41,65 @@ namespace snapround { // geos.noding.snapround
 /*private*/
 void
 MCIndexSnapRounder::findInteriorIntersections(MCIndexNoder& noder,
-		NodedSegmentString::NonConstVect* segStrings,
-		vector<Coordinate>& intersections)
+        NodedSegmentString::NonConstVect* segStrings,
+        vector<Coordinate>& intersections)
 {
-	IntersectionFinderAdder intFinderAdder(li, intersections);
-	noder.setSegmentIntersector(&intFinderAdder);
-	noder.computeNodes(segStrings);
+    IntersectionFinderAdder intFinderAdder(li, intersections);
+    noder.setSegmentIntersector(&intFinderAdder);
+    noder.computeNodes(segStrings);
 }
 
 /* private */
 void
 MCIndexSnapRounder::computeIntersectionSnaps(vector<Coordinate>& snapPts)
 {
-	for (vector<Coordinate>::iterator
-			it=snapPts.begin(), itEnd=snapPts.end();
-			it!=itEnd;
-			++it)
-	{
-		Coordinate& snapPt = *it;
-		HotPixel hotPixel(snapPt, scaleFactor, li);
-		pointSnapper->snap(hotPixel);
-	}
+    for(vector<Coordinate>::iterator
+            it = snapPts.begin(), itEnd = snapPts.end();
+            it != itEnd;
+            ++it) {
+        Coordinate& snapPt = *it;
+        HotPixel hotPixel(snapPt, scaleFactor, li);
+        pointSnapper->snap(hotPixel);
+    }
 }
 
 /*private*/
 void
 MCIndexSnapRounder::computeVertexSnaps(NodedSegmentString* e)
 {
-	CoordinateSequence& pts0 = *(e->getCoordinates());
-	for (size_t i = 0, n = pts0.size() - 1; i < n; ++i)
-	{
-		HotPixel hotPixel(pts0[i], scaleFactor, li);
-		bool isNodeAdded = pointSnapper->snap(hotPixel, e, i);
-		// if a node is created for a vertex, that vertex must be noded too
-		if (isNodeAdded) {
-			e->addIntersection(pts0[i], i);
-		}
-	}
+    CoordinateSequence& pts0 = *(e->getCoordinates());
+    for(size_t i = 0, n = pts0.size() - 1; i < n; ++i) {
+        HotPixel hotPixel(pts0[i], scaleFactor, li);
+        bool isNodeAdded = pointSnapper->snap(hotPixel, e, i);
+        // if a node is created for a vertex, that vertex must be noded too
+        if(isNodeAdded) {
+            e->addIntersection(pts0[i], i);
+        }
+    }
 }
 
 /*public*/
 void
 MCIndexSnapRounder::computeVertexSnaps(SegmentString::NonConstVect& edges)
 {
-	SegmentString::NonConstVect::iterator i=edges.begin(), e=edges.end();
-	for (; i!=e; ++i)
-	{
-		NodedSegmentString* edge0 =
-			dynamic_cast<NodedSegmentString*>(*i);
-		assert(edge0);
-		computeVertexSnaps(edge0);
-	}
+    SegmentString::NonConstVect::iterator i = edges.begin(), e = edges.end();
+    for(; i != e; ++i) {
+        NodedSegmentString* edge0 =
+            dynamic_cast<NodedSegmentString*>(*i);
+        assert(edge0);
+        computeVertexSnaps(edge0);
+    }
 }
 
 /*private*/
 void
 MCIndexSnapRounder::snapRound(MCIndexNoder& noder,
-		SegmentString::NonConstVect* segStrings)
+                              SegmentString::NonConstVect* segStrings)
 {
-	vector<Coordinate> intersections;
- 	findInteriorIntersections(noder, segStrings, intersections);
-	computeIntersectionSnaps(intersections);
-	computeVertexSnaps(*segStrings);
+    vector<Coordinate> intersections;
+    findInteriorIntersections(noder, segStrings, intersections);
+    computeIntersectionSnaps(intersections);
+    computeVertexSnaps(*segStrings);
 
 }
 
@@ -110,33 +107,34 @@ MCIndexSnapRounder::snapRound(MCIndexNoder& noder,
 void
 MCIndexSnapRounder::computeNodes(SegmentString::NonConstVect* inputSegmentStrings)
 {
-	nodedSegStrings = inputSegmentStrings;
-	MCIndexNoder noder;
-	pointSnapper.release(); // let it leak ?!
-	pointSnapper.reset(new MCIndexPointSnapper(noder.getIndex()));
-	snapRound(noder, inputSegmentStrings);
-
-	// testing purposes only - remove in final version
-	assert(nodedSegStrings == inputSegmentStrings);
-	//checkCorrectness(*inputSegmentStrings);
+    nodedSegStrings = inputSegmentStrings;
+    MCIndexNoder noder;
+    pointSnapper.release(); // let it leak ?!
+    pointSnapper.reset(new MCIndexPointSnapper(noder.getIndex()));
+    snapRound(noder, inputSegmentStrings);
+
+    // testing purposes only - remove in final version
+    assert(nodedSegStrings == inputSegmentStrings);
+    //checkCorrectness(*inputSegmentStrings);
 }
 
 /*private*/
 void
 MCIndexSnapRounder::checkCorrectness(
-	SegmentString::NonConstVect& inputSegmentStrings)
+    SegmentString::NonConstVect& inputSegmentStrings)
 {
-	unique_ptr<SegmentString::NonConstVect> resultSegStrings(
-		NodedSegmentString::getNodedSubstrings(inputSegmentStrings)
-	);
-
-	NodingValidator nv(*(resultSegStrings.get()));
-	try {
-		nv.checkValid();
-	} catch (const std::exception &ex) {
-		std::cerr << ex.what() << std::endl;
-		throw;
-	}
+    unique_ptr<SegmentString::NonConstVect> resultSegStrings(
+        NodedSegmentString::getNodedSubstrings(inputSegmentStrings)
+    );
+
+    NodingValidator nv(*(resultSegStrings.get()));
+    try {
+        nv.checkValid();
+    }
+    catch(const std::exception& ex) {
+        std::cerr << ex.what() << std::endl;
+        throw;
+    }
 }
 
 
diff --git a/src/noding/snapround/SimpleSnapRounder.cpp b/src/noding/snapround/SimpleSnapRounder.cpp
index 3098e9a..723aa90 100644
--- a/src/noding/snapround/SimpleSnapRounder.cpp
+++ b/src/noding/snapround/SimpleSnapRounder.cpp
@@ -42,10 +42,10 @@ namespace snapround { // geos.noding.snapround
 
 /*public*/
 SimpleSnapRounder::SimpleSnapRounder(const geom::PrecisionModel& newPm)
-	:
-	pm(newPm),
-	li(&newPm),
-	scaleFactor(newPm.getScale())
+    :
+    pm(newPm),
+    li(&newPm),
+    scaleFactor(newPm.getScale())
 {
 }
 
@@ -53,120 +53,114 @@ SimpleSnapRounder::SimpleSnapRounder(const geom::PrecisionModel& newPm)
 std::vector<SegmentString*>*
 SimpleSnapRounder::getNodedSubstrings() const
 {
-	std::vector<SegmentString*> *ret = new std::vector<SegmentString*>();
-	NodedSegmentString::getNodedSubstrings(nodedSegStrings->begin(), nodedSegStrings->end(), ret);
-	return ret;
+    std::vector<SegmentString*>* ret = new std::vector<SegmentString*>();
+    NodedSegmentString::getNodedSubstrings(nodedSegStrings->begin(), nodedSegStrings->end(), ret);
+    return ret;
 }
 
 /*public*/
 void
 SimpleSnapRounder::computeNodes(
-		std::vector<SegmentString*>* inputSegmentStrings)
+    std::vector<SegmentString*>* inputSegmentStrings)
 {
-	nodedSegStrings = inputSegmentStrings;
-	snapRound(inputSegmentStrings, li);
+    nodedSegStrings = inputSegmentStrings;
+    snapRound(inputSegmentStrings, li);
 
-	// testing purposes only - remove in final version
-	assert(nodedSegStrings == inputSegmentStrings);
-	checkCorrectness(*inputSegmentStrings);
+    // testing purposes only - remove in final version
+    assert(nodedSegStrings == inputSegmentStrings);
+    checkCorrectness(*inputSegmentStrings);
 }
 
 
 /*private*/
 void
 SimpleSnapRounder::checkCorrectness(
-		SegmentString::NonConstVect& inputSegmentStrings)
+    SegmentString::NonConstVect& inputSegmentStrings)
 {
-  SegmentString::NonConstVect resultSegStrings;
-  NodedSegmentString::getNodedSubstrings(
-    inputSegmentStrings.begin(), inputSegmentStrings.end(), &resultSegStrings
-  );
+    SegmentString::NonConstVect resultSegStrings;
+    NodedSegmentString::getNodedSubstrings(
+        inputSegmentStrings.begin(), inputSegmentStrings.end(), &resultSegStrings
+    );
 
-  NodingValidator nv(resultSegStrings);
+    NodingValidator nv(resultSegStrings);
 
-  try {
-    nv.checkValid();
-  }
+    try {
+        nv.checkValid();
+    }
 
-  catch (const std::exception &ex) {
+    catch(const std::exception& ex) {
 
-    for ( SegmentString::NonConstVect::iterator i=resultSegStrings.begin(),
-                                                e=resultSegStrings.end();
-          i!=e; ++i )
-    {
-      delete *i;
-    }
+        for(SegmentString::NonConstVect::iterator i = resultSegStrings.begin(),
+                e = resultSegStrings.end();
+                i != e; ++i) {
+            delete *i;
+        }
 
-    std::cerr << ex.what() << std::endl;
-    throw;
-  }
+        std::cerr << ex.what() << std::endl;
+        throw;
+    }
 
-  for ( SegmentString::NonConstVect::iterator i=resultSegStrings.begin(),
-                                              e=resultSegStrings.end();
-        i!=e; ++i )
-  {
-    delete *i;
-  }
+    for(SegmentString::NonConstVect::iterator i = resultSegStrings.begin(),
+            e = resultSegStrings.end();
+            i != e; ++i) {
+        delete *i;
+    }
 
 }
 
 /*private*/
 void
 SimpleSnapRounder::computeSnaps(const SegmentString::NonConstVect& segStrings,
-		vector<Coordinate>& snapPts)
+                                vector<Coordinate>& snapPts)
 {
-	for (SegmentString::NonConstVect::const_iterator
-			i=segStrings.begin(), iEnd=segStrings.end();
-			i!=iEnd; ++i)
-	{
-		NodedSegmentString* ss = dynamic_cast<NodedSegmentString*>(*i);
-
-		computeSnaps(ss, snapPts);
-	}
+    for(SegmentString::NonConstVect::const_iterator
+            i = segStrings.begin(), iEnd = segStrings.end();
+            i != iEnd; ++i) {
+        NodedSegmentString* ss = dynamic_cast<NodedSegmentString*>(*i);
+
+        computeSnaps(ss, snapPts);
+    }
 }
 
 /*private*/
 void
 SimpleSnapRounder::computeSnaps(NodedSegmentString* ss, vector<Coordinate>& snapPts)
 {
-	for (vector<Coordinate>::iterator
-		it=snapPts.begin(), itEnd=snapPts.end();
-		it!=itEnd; ++it)
-	{
-		const Coordinate& snapPt = *it;
-		HotPixel hotPixel(snapPt, scaleFactor, li);
-		for (size_t i = 0, n = ss->size() - 1; i < n; ++i) {
-			hotPixel.addSnappedNode(*ss, i);
-		}
-	}
+    for(vector<Coordinate>::iterator
+            it = snapPts.begin(), itEnd = snapPts.end();
+            it != itEnd; ++it) {
+        const Coordinate& snapPt = *it;
+        HotPixel hotPixel(snapPt, scaleFactor, li);
+        for(size_t i = 0, n = ss->size() - 1; i < n; ++i) {
+            hotPixel.addSnappedNode(*ss, i);
+        }
+    }
 }
 
 /*private*/
 void
 SimpleSnapRounder::computeVertexSnaps(NodedSegmentString* e0, NodedSegmentString* e1)
 {
-	const CoordinateSequence* pts0 = e0->getCoordinates();
-	const CoordinateSequence* pts1 = e1->getCoordinates();
-
-	for (size_t i0 = 0, n0 = pts0->getSize() - 1; i0 < n0; ++i0)
-	{
-		const Coordinate& p0 = pts0->getAt(i0);
-
-		HotPixel hotPixel(p0, scaleFactor, li);
-		for (size_t i1 = 1, n1 = pts1->getSize()-1; i1 < n1; ++i1)
-		{
-        		// don't snap a vertex to itself
-			if (i0 == i1 && e0 == e1) {
-				continue;
-			}
+    const CoordinateSequence* pts0 = e0->getCoordinates();
+    const CoordinateSequence* pts1 = e1->getCoordinates();
+
+    for(size_t i0 = 0, n0 = pts0->getSize() - 1; i0 < n0; ++i0) {
+        const Coordinate& p0 = pts0->getAt(i0);
+
+        HotPixel hotPixel(p0, scaleFactor, li);
+        for(size_t i1 = 1, n1 = pts1->getSize() - 1; i1 < n1; ++i1) {
+            // don't snap a vertex to itself
+            if(i0 == i1 && e0 == e1) {
+                continue;
+            }
 //cerr<<"trying "<<p0<<" against "<<pts1->getAt(i1)<<" "<<pts1->getAt(i1 + 1)<<endl;
-			bool isNodeAdded = hotPixel.addSnappedNode(*e1, i1);
-			// if a node is created for a vertex, that vertex must be noded too
-			if (isNodeAdded) {
-				e0->addIntersection(p0, i0);
-			}
-		}
-	}
+            bool isNodeAdded = hotPixel.addSnappedNode(*e1, i1);
+            // if a node is created for a vertex, that vertex must be noded too
+            if(isNodeAdded) {
+                e0->addIntersection(p0, i0);
+            }
+        }
+    }
 
 }
 
@@ -174,48 +168,46 @@ SimpleSnapRounder::computeVertexSnaps(NodedSegmentString* e0, NodedSegmentString
 void
 SimpleSnapRounder::computeVertexSnaps(const SegmentString::NonConstVect& edges)
 {
-	for (SegmentString::NonConstVect::const_iterator
-			i0=edges.begin(), i0End=edges.end();
-			i0!=i0End; ++i0)
-	{
-		NodedSegmentString* edge0 = dynamic_cast<NodedSegmentString*>(*i0);
-		assert(edge0);
-		for (SegmentString::NonConstVect::const_iterator
-				i1=edges.begin(), i1End=edges.end();
-				i1!=i1End; ++i1)
-		{
-			NodedSegmentString* edge1 = dynamic_cast<NodedSegmentString*>(*i1);
-			assert(edge1);
-			computeVertexSnaps(edge0, edge1);
-		}
-	}
+    for(SegmentString::NonConstVect::const_iterator
+            i0 = edges.begin(), i0End = edges.end();
+            i0 != i0End; ++i0) {
+        NodedSegmentString* edge0 = dynamic_cast<NodedSegmentString*>(*i0);
+        assert(edge0);
+        for(SegmentString::NonConstVect::const_iterator
+                i1 = edges.begin(), i1End = edges.end();
+                i1 != i1End; ++i1) {
+            NodedSegmentString* edge1 = dynamic_cast<NodedSegmentString*>(*i1);
+            assert(edge1);
+            computeVertexSnaps(edge0, edge1);
+        }
+    }
 }
 
 
 /*private*/
 void
 SimpleSnapRounder::snapRound(SegmentString::NonConstVect* segStrings,
-		LineIntersector& p_li)
+                             LineIntersector& p_li)
 {
-	assert(segStrings);
+    assert(segStrings);
 
-	vector<Coordinate> intersections;
-	findInteriorIntersections(*segStrings, p_li, intersections);
-	computeSnaps(*segStrings, intersections);
-	computeVertexSnaps(*segStrings);
+    vector<Coordinate> intersections;
+    findInteriorIntersections(*segStrings, p_li, intersections);
+    computeSnaps(*segStrings, intersections);
+    computeVertexSnaps(*segStrings);
 }
 
 /*private*/
 void
 SimpleSnapRounder::findInteriorIntersections(
-	SegmentString::NonConstVect& segStrings,
-	LineIntersector& p_li, vector<Coordinate>& ret)
+    SegmentString::NonConstVect& segStrings,
+    LineIntersector& p_li, vector<Coordinate>& ret)
 {
-	IntersectionFinderAdder intFinderAdder(p_li, ret);
-	MCIndexNoder noder;
-	noder.setSegmentIntersector(&intFinderAdder);
-	noder.computeNodes(&segStrings);
-	//intFinderAdder.getInteriorIntersections();
+    IntersectionFinderAdder intFinderAdder(p_li, ret);
+    MCIndexNoder noder;
+    noder.setSegmentIntersector(&intFinderAdder);
+    noder.computeNodes(&segStrings);
+    //intFinderAdder.getInteriorIntersections();
 }
 
 
diff --git a/src/operation/GeometryGraphOperation.cpp b/src/operation/GeometryGraphOperation.cpp
index 05fd8fe..42d157b 100644
--- a/src/operation/GeometryGraphOperation.cpp
+++ b/src/operation/GeometryGraphOperation.cpp
@@ -35,85 +35,88 @@ namespace operation { // geos.operation
 
 //LineIntersector* GeometryGraphOperation::li=new LineIntersector();
 
-GeometryGraphOperation::GeometryGraphOperation(const Geometry *g0,
-		const Geometry *g1)
-	:
-	arg(2)
+GeometryGraphOperation::GeometryGraphOperation(const Geometry* g0,
+        const Geometry* g1)
+    :
+    arg(2)
 {
-	const PrecisionModel* pm0 = g0->getPrecisionModel();
-	assert(pm0);
-
-	const PrecisionModel* pm1 = g1->getPrecisionModel();
-	assert(pm1);
-
-	// use the most precise model for the result
-	if (pm0->compareTo(pm1) >= 0)
-		setComputationPrecision(pm0);
-	else
-		setComputationPrecision(pm1);
-
-	arg[0]=new GeometryGraph(0, g0,
-        algorithm::BoundaryNodeRule::getBoundaryOGCSFS());
-	arg[1]=new GeometryGraph(1, g1,
-		algorithm::BoundaryNodeRule::getBoundaryOGCSFS());
+    const PrecisionModel* pm0 = g0->getPrecisionModel();
+    assert(pm0);
+
+    const PrecisionModel* pm1 = g1->getPrecisionModel();
+    assert(pm1);
+
+    // use the most precise model for the result
+    if(pm0->compareTo(pm1) >= 0) {
+        setComputationPrecision(pm0);
+    }
+    else {
+        setComputationPrecision(pm1);
+    }
+
+    arg[0] = new GeometryGraph(0, g0,
+                               algorithm::BoundaryNodeRule::getBoundaryOGCSFS());
+    arg[1] = new GeometryGraph(1, g1,
+                               algorithm::BoundaryNodeRule::getBoundaryOGCSFS());
 }
 
-GeometryGraphOperation::GeometryGraphOperation(const Geometry *g0,
-		const Geometry *g1,
-		const algorithm::BoundaryNodeRule& boundaryNodeRule)
-	:
-	arg(2)
+GeometryGraphOperation::GeometryGraphOperation(const Geometry* g0,
+        const Geometry* g1,
+        const algorithm::BoundaryNodeRule& boundaryNodeRule)
+    :
+    arg(2)
 {
-	const PrecisionModel* pm0 = g0->getPrecisionModel();
-	assert(pm0);
-
-	const PrecisionModel* pm1 = g1->getPrecisionModel();
-	assert(pm1);
-
-	// use the most precise model for the result
-	if (pm0->compareTo(pm1) >= 0)
-		setComputationPrecision(pm0);
-	else
-		setComputationPrecision(pm1);
-
-	arg[0]=new GeometryGraph(0, g0, boundaryNodeRule);
-	arg[1]=new GeometryGraph(1, g1, boundaryNodeRule);
+    const PrecisionModel* pm0 = g0->getPrecisionModel();
+    assert(pm0);
+
+    const PrecisionModel* pm1 = g1->getPrecisionModel();
+    assert(pm1);
+
+    // use the most precise model for the result
+    if(pm0->compareTo(pm1) >= 0) {
+        setComputationPrecision(pm0);
+    }
+    else {
+        setComputationPrecision(pm1);
+    }
+
+    arg[0] = new GeometryGraph(0, g0, boundaryNodeRule);
+    arg[1] = new GeometryGraph(1, g1, boundaryNodeRule);
 }
 
 
-GeometryGraphOperation::GeometryGraphOperation(const Geometry *g0):
-	arg(1)
+GeometryGraphOperation::GeometryGraphOperation(const Geometry* g0):
+    arg(1)
 {
-	const PrecisionModel* pm0 = g0->getPrecisionModel();
-	assert(pm0);
+    const PrecisionModel* pm0 = g0->getPrecisionModel();
+    assert(pm0);
 
-	setComputationPrecision(pm0);
+    setComputationPrecision(pm0);
 
-	arg[0]=new GeometryGraph(0, g0);
+    arg[0] = new GeometryGraph(0, g0);
 }
 
 const Geometry*
 GeometryGraphOperation::getArgGeometry(unsigned int i) const
 {
-	assert(i<arg.size());
-	return arg[i]->getGeometry();
+    assert(i < arg.size());
+    return arg[i]->getGeometry();
 }
 
 /*protected*/
 void
 GeometryGraphOperation::setComputationPrecision(const PrecisionModel* pm)
 {
-	assert(pm);
-	resultPrecisionModel=pm;
-	li.setPrecisionModel(resultPrecisionModel);
+    assert(pm);
+    resultPrecisionModel = pm;
+    li.setPrecisionModel(resultPrecisionModel);
 }
 
 GeometryGraphOperation::~GeometryGraphOperation()
 {
-	for(unsigned int i=0; i<arg.size(); ++i)
-	{
-		delete arg[i];
-	}
+    for(unsigned int i = 0; i < arg.size(); ++i) {
+        delete arg[i];
+    }
 }
 
 } // namespace geos.operation
diff --git a/src/operation/IsSimpleOp.cpp b/src/operation/IsSimpleOp.cpp
index be361ee..03c1fd5 100644
--- a/src/operation/IsSimpleOp.cpp
+++ b/src/operation/IsSimpleOp.cpp
@@ -50,32 +50,36 @@ namespace geos {
 namespace operation { // geos.operation
 
 // This is supposedly a private of IsSimpleOp...
-class EndpointInfo
-{
+class EndpointInfo {
 public:
 
-	Coordinate pt;
+    Coordinate pt;
 
-	bool isClosed;
+    bool isClosed;
 
-	int degree;
+    int degree;
 
-    	EndpointInfo(const geom::Coordinate& newPt);
+    EndpointInfo(const geom::Coordinate& newPt);
 
-	const Coordinate& getCoordinate() const { return pt; }
+    const Coordinate&
+    getCoordinate() const
+    {
+        return pt;
+    }
 
-	void addEndpoint(bool newIsClosed)
-	{
-		degree++;
-		isClosed |= newIsClosed;
-	}
+    void
+    addEndpoint(bool newIsClosed)
+    {
+        degree++;
+        isClosed |= newIsClosed;
+    }
 };
 
 EndpointInfo::EndpointInfo(const Coordinate& newPt)
 {
-	pt=newPt;
-	isClosed=false;
-	degree=0;
+    pt = newPt;
+    isClosed = false;
+    degree = 0;
 }
 
 // -----------------------------------------------------
@@ -84,253 +88,267 @@ EndpointInfo::EndpointInfo(const Coordinate& newPt)
 
 /*public*/
 IsSimpleOp::IsSimpleOp()
-	:
-	isClosedEndpointsInInterior(true),
-	geom(nullptr),
-	nonSimpleLocation()
+    :
+    isClosedEndpointsInInterior(true),
+    geom(nullptr),
+    nonSimpleLocation()
 {}
 
 /*public*/
 IsSimpleOp::IsSimpleOp(const Geometry& g)
-	:
-	isClosedEndpointsInInterior(true),
-	geom(&g),
-	nonSimpleLocation()
+    :
+    isClosedEndpointsInInterior(true),
+    geom(&g),
+    nonSimpleLocation()
 {}
 
 /*public*/
 IsSimpleOp::IsSimpleOp(const Geometry& g,
-	               const BoundaryNodeRule& boundaryNodeRule)
-	:
-	isClosedEndpointsInInterior( ! boundaryNodeRule.isInBoundary(2) ),
-	geom(&g),
-	nonSimpleLocation()
+                       const BoundaryNodeRule& boundaryNodeRule)
+    :
+    isClosedEndpointsInInterior(! boundaryNodeRule.isInBoundary(2)),
+    geom(&g),
+    nonSimpleLocation()
 {}
 
 /*public*/
 bool
 IsSimpleOp::isSimple()
 {
-	nonSimpleLocation.reset();
-	return computeSimple(geom);
+    nonSimpleLocation.reset();
+    return computeSimple(geom);
 }
 
 
 /*public*/
 bool
-IsSimpleOp::isSimple(const LineString *p_geom)
+IsSimpleOp::isSimple(const LineString* p_geom)
 {
-	return isSimpleLinearGeometry(p_geom);
+    return isSimpleLinearGeometry(p_geom);
 }
 
 /*public*/
 bool
-IsSimpleOp::isSimple(const MultiLineString *p_geom)
+IsSimpleOp::isSimple(const MultiLineString* p_geom)
 {
-	return isSimpleLinearGeometry(p_geom);
+    return isSimpleLinearGeometry(p_geom);
 }
 
 /*public*/
 bool
-IsSimpleOp::isSimple(const MultiPoint *mp)
+IsSimpleOp::isSimple(const MultiPoint* mp)
 {
-	return isSimpleMultiPoint(*mp);
+    return isSimpleMultiPoint(*mp);
 }
 
 /*private*/
 bool
 IsSimpleOp::isSimpleMultiPoint(const MultiPoint& mp)
 {
-	if (mp.isEmpty()) return true;
-	set<const Coordinate*, CoordinateLessThen> points;
-
-	for (std::size_t i=0, n=mp.getNumGeometries(); i<n; ++i)
-	{
-		const Point *pt = dynamic_cast<const Point*>(mp.getGeometryN(i));
-		assert(pt);
-		const Coordinate *p=pt->getCoordinate();
-		if (points.find(p) != points.end())
-		{
-			nonSimpleLocation.reset(new Coordinate(*p));
-			return false;
-		}
-		points.insert(p);
-	}
-	return true;
+    if(mp.isEmpty()) {
+        return true;
+    }
+    set<const Coordinate*, CoordinateLessThen> points;
+
+    for(std::size_t i = 0, n = mp.getNumGeometries(); i < n; ++i) {
+        const Point* pt = dynamic_cast<const Point*>(mp.getGeometryN(i));
+        assert(pt);
+        const Coordinate* p = pt->getCoordinate();
+        if(points.find(p) != points.end()) {
+            nonSimpleLocation.reset(new Coordinate(*p));
+            return false;
+        }
+        points.insert(p);
+    }
+    return true;
 }
 
 bool
-IsSimpleOp::isSimpleLinearGeometry(const Geometry *p_geom)
+IsSimpleOp::isSimpleLinearGeometry(const Geometry* p_geom)
 {
-	if (p_geom->isEmpty()) return true;
-	GeometryGraph graph(0,p_geom);
-	LineIntersector li;
-	std::unique_ptr<SegmentIntersector> si(graph.computeSelfNodes(&li,true));
-
-	// if no self-intersection, must be simple
-	if (!si->hasIntersection()) return true;
-
-	if (si->hasProperIntersection())
-	{
-		nonSimpleLocation.reset(
-			new Coordinate(si->getProperIntersectionPoint())
-		);
-		return false;
-	}
-
-	if (hasNonEndpointIntersection(graph)) return false;
-
-	if ( isClosedEndpointsInInterior ) {
-		if (hasClosedEndpointIntersection(graph)) return false;
-	}
-
-	return true;
+    if(p_geom->isEmpty()) {
+        return true;
+    }
+    GeometryGraph graph(0, p_geom);
+    LineIntersector li;
+    std::unique_ptr<SegmentIntersector> si(graph.computeSelfNodes(&li, true));
+
+    // if no self-intersection, must be simple
+    if(!si->hasIntersection()) {
+        return true;
+    }
+
+    if(si->hasProperIntersection()) {
+        nonSimpleLocation.reset(
+            new Coordinate(si->getProperIntersectionPoint())
+        );
+        return false;
+    }
+
+    if(hasNonEndpointIntersection(graph)) {
+        return false;
+    }
+
+    if(isClosedEndpointsInInterior) {
+        if(hasClosedEndpointIntersection(graph)) {
+            return false;
+        }
+    }
+
+    return true;
 }
 
 /*private*/
 bool
-IsSimpleOp::hasNonEndpointIntersection(GeometryGraph &graph)
+IsSimpleOp::hasNonEndpointIntersection(GeometryGraph& graph)
 {
-	vector<Edge*> *edges=graph.getEdges();
-	for (vector<Edge*>::iterator i=edges->begin();i<edges->end();i++) {
-		Edge *e=*i;
-		auto maxSegmentIndex = e->getMaximumSegmentIndex();
-		EdgeIntersectionList &eiL=e->getEdgeIntersectionList();
-		for ( EdgeIntersectionList::iterator eiIt=eiL.begin(),
-			eiEnd=eiL.end(); eiIt!=eiEnd; ++eiIt )
-		{
-			EdgeIntersection *ei=*eiIt;
-			if (!ei->isEndPoint(maxSegmentIndex))
-			{
-				nonSimpleLocation.reset(
-					new Coordinate(ei->getCoordinate())
-				);
-				return true;
-			}
-		}
-	}
-	return false;
+    vector<Edge*>* edges = graph.getEdges();
+    for(vector<Edge*>::iterator i = edges->begin(); i < edges->end(); i++) {
+        Edge* e = *i;
+        auto maxSegmentIndex = e->getMaximumSegmentIndex();
+        EdgeIntersectionList& eiL = e->getEdgeIntersectionList();
+        for(EdgeIntersectionList::iterator eiIt = eiL.begin(),
+                eiEnd = eiL.end(); eiIt != eiEnd; ++eiIt) {
+            EdgeIntersection* ei = *eiIt;
+            if(!ei->isEndPoint(maxSegmentIndex)) {
+                nonSimpleLocation.reset(
+                    new Coordinate(ei->getCoordinate())
+                );
+                return true;
+            }
+        }
+    }
+    return false;
 }
 
 /*private*/
 bool
-IsSimpleOp::computeSimple(const geom::Geometry *g)
+IsSimpleOp::computeSimple(const geom::Geometry* g)
 {
-	nonSimpleLocation.reset();
-
-	if (dynamic_cast<const LineString*>(g))
-		return isSimpleLinearGeometry(g);
-
-	if (dynamic_cast<const LinearRing*>(g))
-		return isSimpleLinearGeometry(g);
-
-	if (dynamic_cast<const MultiLineString*>(g))
-		return isSimpleLinearGeometry(g);
-
-	if (dynamic_cast<const Polygon*>(g))
-		return isSimplePolygonal(g);
-
-	const MultiPoint* mp = dynamic_cast<const MultiPoint*>(g);
-	if (mp) return isSimpleMultiPoint(*mp);
-
-	// This must be after MultiPoint test, as MultiPoint can
-	// cast cleanly into GeometryCollection
-	const GeometryCollection* gc = dynamic_cast<const GeometryCollection*>(g);
-	if (gc)
-		return isSimpleGeometryCollection(gc);
-
-	// all other geometry types are simple by definition
-	return true;
+    nonSimpleLocation.reset();
+
+    if(dynamic_cast<const LineString*>(g)) {
+        return isSimpleLinearGeometry(g);
+    }
+
+    if(dynamic_cast<const LinearRing*>(g)) {
+        return isSimpleLinearGeometry(g);
+    }
+
+    if(dynamic_cast<const MultiLineString*>(g)) {
+        return isSimpleLinearGeometry(g);
+    }
+
+    if(dynamic_cast<const Polygon*>(g)) {
+        return isSimplePolygonal(g);
+    }
+
+    const MultiPoint* mp = dynamic_cast<const MultiPoint*>(g);
+    if(mp) {
+        return isSimpleMultiPoint(*mp);
+    }
+
+    // This must be after MultiPoint test, as MultiPoint can
+    // cast cleanly into GeometryCollection
+    const GeometryCollection* gc = dynamic_cast<const GeometryCollection*>(g);
+    if(gc) {
+        return isSimpleGeometryCollection(gc);
+    }
+
+    // all other geometry types are simple by definition
+    return true;
 }
 
 /*private*/
 bool
-IsSimpleOp::isSimpleGeometryCollection(const geom::GeometryCollection *col)
+IsSimpleOp::isSimpleGeometryCollection(const geom::GeometryCollection* col)
 {
-	GeometryCollection::const_iterator it;
-	for (it = col->begin(); it < col->end(); ++it)
-	{
-		const geom::Geometry *g = *it;
-		if (!computeSimple(g)) return false;
-	}
-	return true;
+    GeometryCollection::const_iterator it;
+    for(it = col->begin(); it < col->end(); ++it) {
+        const geom::Geometry* g = *it;
+        if(!computeSimple(g)) {
+            return false;
+        }
+    }
+    return true;
 }
 
 /*private*/
 bool
-IsSimpleOp::isSimplePolygonal(const geom::Geometry *g)
+IsSimpleOp::isSimplePolygonal(const geom::Geometry* g)
 {
 
-	LineString::ConstVect rings;
-	LinearComponentExtracter::getLines(*g, rings);
-	for (const geom::LineString *ring : rings)
-	{
-			if(!isSimpleLinearGeometry(ring))
-				return false;
-	}
-	return true;
+    LineString::ConstVect rings;
+    LinearComponentExtracter::getLines(*g, rings);
+    for(const geom::LineString* ring : rings) {
+        if(!isSimpleLinearGeometry(ring)) {
+            return false;
+        }
+    }
+    return true;
 }
 
 /*private*/
 bool
-IsSimpleOp::hasClosedEndpointIntersection(GeometryGraph &graph)
+IsSimpleOp::hasClosedEndpointIntersection(GeometryGraph& graph)
 {
-	map<const Coordinate*,EndpointInfo*,CoordinateLessThen> endPoints;
-	vector<Edge*> *edges=graph.getEdges();
-	for (vector<Edge*>::iterator i=edges->begin();i<edges->end();i++) {
-		Edge *e=*i;
-		//int maxSegmentIndex=e->getMaximumSegmentIndex();
-		bool isClosed=e->isClosed();
-		const Coordinate *p0=&e->getCoordinate(0);
-		addEndpoint(endPoints,p0,isClosed);
-		const Coordinate *p1=&e->getCoordinate(e->getNumPoints()-1);
-		addEndpoint(endPoints,p1,isClosed);
-	}
-
-	map<const Coordinate*,EndpointInfo*,CoordinateLessThen>::iterator it=endPoints.begin();
-	for (; it!=endPoints.end(); ++it) {
-		EndpointInfo *eiInfo=it->second;
-		if (eiInfo->isClosed && eiInfo->degree!=2) {
-
-			nonSimpleLocation.reset(
-				new Coordinate( eiInfo->getCoordinate() )
-			);
-
-			it=endPoints.begin();
-			for (; it!=endPoints.end(); ++it) {
-				EndpointInfo *ep=it->second;
-				delete ep;
-			}
-            		return true;
-		}
-	}
-
-	it=endPoints.begin();
-	for (; it!=endPoints.end(); ++it) {
-		EndpointInfo *ep=it->second;
-		delete ep;
-	}
-	return false;
+    map<const Coordinate*, EndpointInfo*, CoordinateLessThen> endPoints;
+    vector<Edge*>* edges = graph.getEdges();
+    for(vector<Edge*>::iterator i = edges->begin(); i < edges->end(); i++) {
+        Edge* e = *i;
+        //int maxSegmentIndex=e->getMaximumSegmentIndex();
+        bool isClosed = e->isClosed();
+        const Coordinate* p0 = &e->getCoordinate(0);
+        addEndpoint(endPoints, p0, isClosed);
+        const Coordinate* p1 = &e->getCoordinate(e->getNumPoints() - 1);
+        addEndpoint(endPoints, p1, isClosed);
+    }
+
+    map<const Coordinate*, EndpointInfo*, CoordinateLessThen>::iterator it = endPoints.begin();
+    for(; it != endPoints.end(); ++it) {
+        EndpointInfo* eiInfo = it->second;
+        if(eiInfo->isClosed && eiInfo->degree != 2) {
+
+            nonSimpleLocation.reset(
+                new Coordinate(eiInfo->getCoordinate())
+            );
+
+            it = endPoints.begin();
+            for(; it != endPoints.end(); ++it) {
+                EndpointInfo* ep = it->second;
+                delete ep;
+            }
+            return true;
+        }
+    }
+
+    it = endPoints.begin();
+    for(; it != endPoints.end(); ++it) {
+        EndpointInfo* ep = it->second;
+        delete ep;
+    }
+    return false;
 }
 
 /*private*/
 void
 IsSimpleOp::addEndpoint(
-	map<const Coordinate*,EndpointInfo*,CoordinateLessThen>&endPoints,
-	const Coordinate *p,bool isClosed)
+    map<const Coordinate*, EndpointInfo*, CoordinateLessThen>& endPoints,
+    const Coordinate* p, bool isClosed)
 {
-	map<const Coordinate*,EndpointInfo*,CoordinateLessThen>::iterator it=endPoints.find(p);
-	EndpointInfo *eiInfo;
-	if (it==endPoints.end()) {
-		eiInfo=nullptr;
-	} else {
-		eiInfo=it->second;
-	}
-	if (eiInfo==nullptr) {
-		eiInfo=new EndpointInfo(*p);
-		endPoints[p]=eiInfo;
-	}
-	eiInfo->addEndpoint(isClosed);
+    map<const Coordinate*, EndpointInfo*, CoordinateLessThen>::iterator it = endPoints.find(p);
+    EndpointInfo* eiInfo;
+    if(it == endPoints.end()) {
+        eiInfo = nullptr;
+    }
+    else {
+        eiInfo = it->second;
+    }
+    if(eiInfo == nullptr) {
+        eiInfo = new EndpointInfo(*p);
+        endPoints[p] = eiInfo;
+    }
+    eiInfo->addEndpoint(isClosed);
 }
 
 } // namespace geos::operation
diff --git a/src/operation/buffer/BufferBuilder.cpp b/src/operation/buffer/BufferBuilder.cpp
index 636011f..5e1afe5 100644
--- a/src/operation/buffer/BufferBuilder.cpp
+++ b/src/operation/buffer/BufferBuilder.cpp
@@ -84,14 +84,14 @@ template <class Iterator>
 std::unique_ptr<Geometry>
 convertSegStrings(const GeometryFactory* fact, Iterator it, Iterator et)
 {
-  std::vector<Geometry*> lines;
-  while(it != et) {
-    const SegmentString* ss = *it;
-    LineString* line = fact->createLineString(ss->getCoordinates()->clone());
-    lines.push_back(line);
-    ++it;
-  }
-  return std::unique_ptr<Geometry>(fact->buildGeometry(lines));
+    std::vector<Geometry*> lines;
+    while(it != et) {
+        const SegmentString* ss = *it;
+        LineString* line = fact->createLineString(ss->getCoordinates()->clone());
+        lines.push_back(line);
+        ++it;
+    }
+    return std::unique_ptr<Geometry>(fact->buildGeometry(lines));
 }
 
 }
@@ -101,598 +101,610 @@ namespace operation { // geos.operation
 namespace buffer { // geos.operation.buffer
 
 #if PROFILE
-static Profiler *profiler = Profiler::instance();
+static Profiler* profiler = Profiler::instance();
 #endif
 
 int
 BufferBuilder::depthDelta(const Label& label)
 {
-	int lLoc=label.getLocation(0, Position::LEFT);
-	int rLoc=label.getLocation(0, Position::RIGHT);
-	if (lLoc== Location::INTERIOR && rLoc== Location::EXTERIOR)
-		return 1;
-	else if (lLoc== Location::EXTERIOR && rLoc== Location::INTERIOR)
-		return -1;
-	return 0;
+    int lLoc = label.getLocation(0, Position::LEFT);
+    int rLoc = label.getLocation(0, Position::RIGHT);
+    if(lLoc == Location::INTERIOR && rLoc == Location::EXTERIOR) {
+        return 1;
+    }
+    else if(lLoc == Location::EXTERIOR && rLoc == Location::INTERIOR) {
+        return -1;
+    }
+    return 0;
 }
 
 BufferBuilder::~BufferBuilder()
 {
-	delete li; // could be NULL
-	delete intersectionAdder;
+    delete li; // could be NULL
+    delete intersectionAdder;
 }
 
 /*public*/
 Geometry*
-BufferBuilder::bufferLineSingleSided( const Geometry* g, double distance,
-                                      bool leftSide )
+BufferBuilder::bufferLineSingleSided(const Geometry* g, double distance,
+                                     bool leftSide)
 {
-   // Returns the line used to create a single-sided buffer.
-   // Input requirement: Must be a LineString.
-   const LineString* l = dynamic_cast< const LineString* >( g );
-   if ( !l ) throw util::IllegalArgumentException("BufferBuilder::bufferLineSingleSided only accept linestrings");
-
-   // Nothing to do for a distance of zero
-   if ( distance == 0 ) return g->clone();
-
-   // Get geometry factory and precision model.
-   const PrecisionModel* precisionModel = workingPrecisionModel;
-   if ( !precisionModel ) precisionModel = l->getPrecisionModel();
-
-   assert( precisionModel );
-   assert( l );
-
-   geomFact = l->getFactory();
-
-   // First, generate the two-sided buffer using a butt-cap.
-   BufferParameters modParams = bufParams;
-   modParams.setEndCapStyle(BufferParameters::CAP_FLAT);
-   modParams.setSingleSided(false); // ignore parameter for areal-only geometries
-   std::unique_ptr<Geometry> buf;
-
-   // This is a (temp?) hack to workaround the fact that
-   // BufferBuilder BufferParamaters are immutable after
-   // construction, while we want to force the end cap
-   // style to FLAT for single-sided buffering
-   {
-      BufferBuilder tmp(modParams);
-      buf.reset( tmp.buffer( l, distance ) );
-   }
-
-   // Create MultiLineStrings from this polygon.
-   std::unique_ptr<Geometry> bufLineString ( buf->getBoundary() );
+    // Returns the line used to create a single-sided buffer.
+    // Input requirement: Must be a LineString.
+    const LineString* l = dynamic_cast< const LineString* >(g);
+    if(!l) {
+        throw util::IllegalArgumentException("BufferBuilder::bufferLineSingleSided only accept linestrings");
+    }
+
+    // Nothing to do for a distance of zero
+    if(distance == 0) {
+        return g->clone();
+    }
+
+    // Get geometry factory and precision model.
+    const PrecisionModel* precisionModel = workingPrecisionModel;
+    if(!precisionModel) {
+        precisionModel = l->getPrecisionModel();
+    }
+
+    assert(precisionModel);
+    assert(l);
+
+    geomFact = l->getFactory();
+
+    // First, generate the two-sided buffer using a butt-cap.
+    BufferParameters modParams = bufParams;
+    modParams.setEndCapStyle(BufferParameters::CAP_FLAT);
+    modParams.setSingleSided(false); // ignore parameter for areal-only geometries
+    std::unique_ptr<Geometry> buf;
+
+    // This is a (temp?) hack to workaround the fact that
+    // BufferBuilder BufferParamaters are immutable after
+    // construction, while we want to force the end cap
+    // style to FLAT for single-sided buffering
+    {
+        BufferBuilder tmp(modParams);
+        buf.reset(tmp.buffer(l, distance));
+    }
+
+    // Create MultiLineStrings from this polygon.
+    std::unique_ptr<Geometry> bufLineString(buf->getBoundary());
 
 #ifdef GEOS_DEBUG_SSB
-   std::cerr << "input|" << *l << std::endl;
-   std::cerr << "buffer|" << *bufLineString << std::endl;
+    std::cerr << "input|" << *l << std::endl;
+    std::cerr << "buffer|" << *bufLineString << std::endl;
 #endif
 
-   // Then, get the raw (i.e. unnoded) single sided offset curve.
-   OffsetCurveBuilder curveBuilder( precisionModel, modParams );
-   std::vector< CoordinateSequence* > lineList;
+    // Then, get the raw (i.e. unnoded) single sided offset curve.
+    OffsetCurveBuilder curveBuilder(precisionModel, modParams);
+    std::vector< CoordinateSequence* > lineList;
 
-   {
-       std::unique_ptr< CoordinateSequence > coords(g->getCoordinates());
-       curveBuilder.getSingleSidedLineCurve(coords.get(), distance,
-           lineList, leftSide, !leftSide);
-       coords.reset();
-   }
+    {
+        std::unique_ptr< CoordinateSequence > coords(g->getCoordinates());
+        curveBuilder.getSingleSidedLineCurve(coords.get(), distance,
+                                             lineList, leftSide, !leftSide);
+        coords.reset();
+    }
 
-   // Create a SegmentString from these coordinates.
-   SegmentString::NonConstVect curveList;
-   for ( unsigned int i = 0; i < lineList.size(); ++i )
-   {
-      CoordinateSequence* seq = lineList[i];
+    // Create a SegmentString from these coordinates.
+    SegmentString::NonConstVect curveList;
+    for(unsigned int i = 0; i < lineList.size(); ++i) {
+        CoordinateSequence* seq = lineList[i];
 
-      // SegmentString takes ownership of CoordinateSequence
-      SegmentString* ss = new NodedSegmentString(seq, nullptr);
-      curveList.push_back( ss );
-   }
-   lineList.clear();
+        // SegmentString takes ownership of CoordinateSequence
+        SegmentString* ss = new NodedSegmentString(seq, nullptr);
+        curveList.push_back(ss);
+    }
+    lineList.clear();
 
 
-   // Node these SegmentStrings.
-   Noder* noder = getNoder( precisionModel );
-   noder->computeNodes( &curveList );
+    // Node these SegmentStrings.
+    Noder* noder = getNoder(precisionModel);
+    noder->computeNodes(&curveList);
 
-   SegmentString::NonConstVect* nodedEdges = noder->getNodedSubstrings();
+    SegmentString::NonConstVect* nodedEdges = noder->getNodedSubstrings();
 
-   // Create a geometry out of the noded substrings.
-   std::vector< Geometry* >* singleSidedNodedEdges =
-      new std::vector< Geometry * >();
-   singleSidedNodedEdges->reserve(nodedEdges->size());
-   for ( std::size_t i = 0, n = nodedEdges->size(); i < n; ++i )
-   {
-      SegmentString* ss = ( *nodedEdges )[i];
+    // Create a geometry out of the noded substrings.
+    std::vector< Geometry* >* singleSidedNodedEdges =
+        new std::vector< Geometry* >();
+    singleSidedNodedEdges->reserve(nodedEdges->size());
+    for(std::size_t i = 0, n = nodedEdges->size(); i < n; ++i) {
+        SegmentString* ss = (*nodedEdges)[i];
 
-      Geometry* tmp = geomFact->createLineString(
-                        ss->getCoordinates()->clone()
-                      );
-      delete ss;
+        Geometry* tmp = geomFact->createLineString(
+                            ss->getCoordinates()->clone()
+                        );
+        delete ss;
 
-      singleSidedNodedEdges->push_back( tmp );
-   }
+        singleSidedNodedEdges->push_back(tmp);
+    }
 
-   delete nodedEdges;
+    delete nodedEdges;
 
-   for (size_t i=0, n=curveList.size(); i<n; ++i) delete curveList[i];
-   curveList.clear();
+    for(size_t i = 0, n = curveList.size(); i < n; ++i) {
+        delete curveList[i];
+    }
+    curveList.clear();
 
-   std::unique_ptr<Geometry> singleSided ( geomFact->createMultiLineString(
-      singleSidedNodedEdges ) );
+    std::unique_ptr<Geometry> singleSided(geomFact->createMultiLineString(
+            singleSidedNodedEdges));
 
 #ifdef GEOS_DEBUG_SSB
-     std::cerr << "edges|" << *singleSided << std::endl;
+    std::cerr << "edges|" << *singleSided << std::endl;
 #endif
 
-   // Use the boolean operation intersect to obtain the line segments lying
-   // on both the butt-cap buffer and this multi-line.
-   //Geometry* intersectedLines = singleSided->intersection( bufLineString );
-   // NOTE: we use Snapped overlay because the actual buffer boundary might
-   //       diverge from original offset curves due to the addition of
-   //       intersections with caps and joins curves
-   using geos::operation::overlay::snap::SnapOverlayOp;
-   std::unique_ptr<Geometry> intersectedLines = SnapOverlayOp::overlayOp(*singleSided, *bufLineString, OverlayOp::opINTERSECTION);
+    // Use the boolean operation intersect to obtain the line segments lying
+    // on both the butt-cap buffer and this multi-line.
+    //Geometry* intersectedLines = singleSided->intersection( bufLineString );
+    // NOTE: we use Snapped overlay because the actual buffer boundary might
+    //       diverge from original offset curves due to the addition of
+    //       intersections with caps and joins curves
+    using geos::operation::overlay::snap::SnapOverlayOp;
+    std::unique_ptr<Geometry> intersectedLines = SnapOverlayOp::overlayOp(*singleSided, *bufLineString,
+            OverlayOp::opINTERSECTION);
 
 #ifdef GEOS_DEBUG_SSB
-     std::cerr << "intersection" << "|" << *intersectedLines << std::endl;
+    std::cerr << "intersection" << "|" << *intersectedLines << std::endl;
 #endif
 
-   // Merge result lines together.
-   LineMerger lineMerge;
-   lineMerge.add( intersectedLines.get() );
-   std::unique_ptr< std::vector< LineString* > > mergedLines (
-	lineMerge.getMergedLineStrings() );
-
-   // Convert the result into a std::vector< Geometry* >.
-   std::vector< Geometry* >* mergedLinesGeom = new std::vector< Geometry* >();
-   const Coordinate& startPoint = l->getCoordinatesRO()->front();
-   const Coordinate& endPoint = l->getCoordinatesRO()->back();
-   while( !mergedLines->empty() )
-   {
-      // Remove end points if they are a part of the original line to be
-      // buffered.
-      CoordinateSequence::Ptr coords(mergedLines->back()->getCoordinates());
-      if ( nullptr != coords.get() )
-      {
-         // Use 98% of the buffer width as the point-distance requirement - this
-         // is to ensure that the point that is "distance" +/- epsilon is not
-         // included.
-         //
-         // Let's try and estimate a more accurate bound instead of just assuming
-         // 98%. With 98%, the episilon grows as the buffer distance grows,
-         // so that at large distance, artifacts may skip through this filter
-         // Let the length of the line play a factor in the distance, which is still
-         // going to be bounded by 98%. Take 10% of the length of the line  from the buffer distance
-         // to try and minimize any artifacts.
-         const double ptDistAllowance = std::max(distance - l->getLength()*0.1, distance * 0.98);
-         // Use 102% of the buffer width as the line-length requirement - this
-         // is to ensure that line segments that is length "distance" +/-
-         // epsilon is removed.
-         const double segLengthAllowance = 1.02 * distance;
-
-         // Clean up the front of the list.
-         // Loop until the line's end is not inside the buffer width from
-         // the startPoint.
-         while ( coords->size() > 1 &&
-                 coords->front().distance( startPoint ) < ptDistAllowance )
-         {
-            // Record the end segment length.
-            double segLength = coords->front().distance( ( *coords )[1] );
-            // Stop looping if there are no more points, or if the segment
-            // length is larger than the buffer width.
-            if ( coords->size() <= 1 || segLength > segLengthAllowance )
-            {
-               break;
+    // Merge result lines together.
+    LineMerger lineMerge;
+    lineMerge.add(intersectedLines.get());
+    std::unique_ptr< std::vector< LineString* > > mergedLines(
+        lineMerge.getMergedLineStrings());
+
+    // Convert the result into a std::vector< Geometry* >.
+    std::vector< Geometry* >* mergedLinesGeom = new std::vector< Geometry* >();
+    const Coordinate& startPoint = l->getCoordinatesRO()->front();
+    const Coordinate& endPoint = l->getCoordinatesRO()->back();
+    while(!mergedLines->empty()) {
+        // Remove end points if they are a part of the original line to be
+        // buffered.
+        CoordinateSequence::Ptr coords(mergedLines->back()->getCoordinates());
+        if(nullptr != coords.get()) {
+            // Use 98% of the buffer width as the point-distance requirement - this
+            // is to ensure that the point that is "distance" +/- epsilon is not
+            // included.
+            //
+            // Let's try and estimate a more accurate bound instead of just assuming
+            // 98%. With 98%, the episilon grows as the buffer distance grows,
+            // so that at large distance, artifacts may skip through this filter
+            // Let the length of the line play a factor in the distance, which is still
+            // going to be bounded by 98%. Take 10% of the length of the line  from the buffer distance
+            // to try and minimize any artifacts.
+            const double ptDistAllowance = std::max(distance - l->getLength() * 0.1, distance * 0.98);
+            // Use 102% of the buffer width as the line-length requirement - this
+            // is to ensure that line segments that is length "distance" +/-
+            // epsilon is removed.
+            const double segLengthAllowance = 1.02 * distance;
+
+            // Clean up the front of the list.
+            // Loop until the line's end is not inside the buffer width from
+            // the startPoint.
+            while(coords->size() > 1 &&
+                    coords->front().distance(startPoint) < ptDistAllowance) {
+                // Record the end segment length.
+                double segLength = coords->front().distance((*coords)[1]);
+                // Stop looping if there are no more points, or if the segment
+                // length is larger than the buffer width.
+                if(coords->size() <= 1 || segLength > segLengthAllowance) {
+                    break;
+                }
+                // If the first point is less than buffer width away from the
+                // reference point, then delete the point.
+                coords->deleteAt(0);
             }
-            // If the first point is less than buffer width away from the
-            // reference point, then delete the point.
-            coords->deleteAt( 0 );
-         }
-         while ( coords->size() > 1 &&
-                 coords->front().distance( endPoint ) < ptDistAllowance )
-         {
-            double segLength = coords->front().distance( ( *coords )[1] );
-            if ( coords->size() <= 1 || segLength > segLengthAllowance )
-            {
-               break;
+            while(coords->size() > 1 &&
+                    coords->front().distance(endPoint) < ptDistAllowance) {
+                double segLength = coords->front().distance((*coords)[1]);
+                if(coords->size() <= 1 || segLength > segLengthAllowance) {
+                    break;
+                }
+                coords->deleteAt(0);
             }
-            coords->deleteAt( 0 );
-         }
-
-         // Clean up the back of the list.
-         while ( coords->size() > 1 &&
-                 coords->back().distance( startPoint ) < ptDistAllowance )
-         {
-            double segLength = coords->back().distance(
-               ( *coords )[coords->size()-2] );
-            if ( coords->size() <= 1 || segLength > segLengthAllowance )
-            {
-               break;
+
+            // Clean up the back of the list.
+            while(coords->size() > 1 &&
+                    coords->back().distance(startPoint) < ptDistAllowance) {
+                double segLength = coords->back().distance(
+                                       (*coords)[coords->size() - 2]);
+                if(coords->size() <= 1 || segLength > segLengthAllowance) {
+                    break;
+                }
+                coords->deleteAt(coords->size() - 1);
             }
-            coords->deleteAt( coords->size()-1 );
-         }
-         while ( coords->size() > 1 &&
-                 coords->back().distance( endPoint ) < ptDistAllowance )
-         {
-            double segLength = coords->back().distance(
-               ( *coords )[coords->size()-2] );
-            if ( coords->size() <= 1 || segLength > segLengthAllowance )
-            {
-               break;
+            while(coords->size() > 1 &&
+                    coords->back().distance(endPoint) < ptDistAllowance) {
+                double segLength = coords->back().distance(
+                                       (*coords)[coords->size() - 2]);
+                if(coords->size() <= 1 || segLength > segLengthAllowance) {
+                    break;
+                }
+                coords->deleteAt(coords->size() - 1);
             }
-            coords->deleteAt( coords->size()-1 );
-         }
-
-         // Add the coordinates to the resultant line string.
-         if ( coords->size() > 1 )
-         {
-            mergedLinesGeom->push_back( geomFact->createLineString( coords.release() ) );
-         }
-      }
-
-      geomFact->destroyGeometry( mergedLines->back() );
-      mergedLines->pop_back();
-   }
-
-   // Clean up.
-   if ( noder != workingNoder ) delete noder;
-   buf.reset();
-   singleSided.reset();
-   intersectedLines.reset();
-
-   if ( mergedLinesGeom->size() > 1 )
-   {
-      return geomFact->createMultiLineString( mergedLinesGeom );
-   }
-   else if ( mergedLinesGeom->size() == 1 )
-   {
-
-      Geometry* single = (*mergedLinesGeom)[0];
-      delete mergedLinesGeom;
-      return single;
-   }
-   else
-   {
-      delete mergedLinesGeom;
-      return geomFact->createLineString();
-   }
+
+            // Add the coordinates to the resultant line string.
+            if(coords->size() > 1) {
+                mergedLinesGeom->push_back(geomFact->createLineString(coords.release()));
+            }
+        }
+
+        geomFact->destroyGeometry(mergedLines->back());
+        mergedLines->pop_back();
+    }
+
+    // Clean up.
+    if(noder != workingNoder) {
+        delete noder;
+    }
+    buf.reset();
+    singleSided.reset();
+    intersectedLines.reset();
+
+    if(mergedLinesGeom->size() > 1) {
+        return geomFact->createMultiLineString(mergedLinesGeom);
+    }
+    else if(mergedLinesGeom->size() == 1) {
+
+        Geometry* single = (*mergedLinesGeom)[0];
+        delete mergedLinesGeom;
+        return single;
+    }
+    else {
+        delete mergedLinesGeom;
+        return geomFact->createLineString();
+    }
 }
 
 /*public*/
 Geometry*
-BufferBuilder::buffer(const Geometry *g, double distance)
-	// throw(GEOSException *)
+BufferBuilder::buffer(const Geometry* g, double distance)
+// throw(GEOSException *)
 {
-	const PrecisionModel *precisionModel=workingPrecisionModel;
-	if (precisionModel==nullptr)
-		precisionModel=g->getPrecisionModel();
+    const PrecisionModel* precisionModel = workingPrecisionModel;
+    if(precisionModel == nullptr) {
+        precisionModel = g->getPrecisionModel();
+    }
 
-	assert(precisionModel);
-	assert(g);
+    assert(precisionModel);
+    assert(g);
 
-	// factory must be the same as the one used by the input
-	geomFact=g->getFactory();
+    // factory must be the same as the one used by the input
+    geomFact = g->getFactory();
 
-  { // This scope is here to force release of resources owned by
-    // OffsetCurveSetBuilder when we're doing with it
+    {
+        // This scope is here to force release of resources owned by
+        // OffsetCurveSetBuilder when we're doing with it
 
-	OffsetCurveBuilder curveBuilder(precisionModel, bufParams);
-	OffsetCurveSetBuilder curveSetBuilder(*g, distance, curveBuilder);
+        OffsetCurveBuilder curveBuilder(precisionModel, bufParams);
+        OffsetCurveSetBuilder curveSetBuilder(*g, distance, curveBuilder);
 
-  GEOS_CHECK_FOR_INTERRUPTS();
+        GEOS_CHECK_FOR_INTERRUPTS();
 
-	std::vector<SegmentString*>& bufferSegStrList=curveSetBuilder.getCurves();
+        std::vector<SegmentString*>& bufferSegStrList = curveSetBuilder.getCurves();
 
 #if GEOS_DEBUG
-	std::cerr << "OffsetCurveSetBuilder got " << bufferSegStrList.size()
-	          << " curves" << std::endl;
+        std::cerr << "OffsetCurveSetBuilder got " << bufferSegStrList.size()
+                  << " curves" << std::endl;
 #endif
-	// short-circuit test
-	if (bufferSegStrList.size()<=0) {
-		return createEmptyResultGeometry();
-	}
+        // short-circuit test
+        if(bufferSegStrList.size() <= 0) {
+            return createEmptyResultGeometry();
+        }
 
 #if GEOS_DEBUG
-	std::cerr<<"BufferBuilder::buffer computing NodedEdges"<<std::endl;
+        std::cerr << "BufferBuilder::buffer computing NodedEdges" << std::endl;
 #endif
 
-	computeNodedEdges(bufferSegStrList, precisionModel);
+        computeNodedEdges(bufferSegStrList, precisionModel);
 
-  GEOS_CHECK_FOR_INTERRUPTS();
+        GEOS_CHECK_FOR_INTERRUPTS();
 
-  } // bufferSegStrList and contents are released here
+    } // bufferSegStrList and contents are released here
 
 #if GEOS_DEBUG > 1
-	std::cerr << std::endl << edgeList << std::endl;
+    std::cerr << std::endl << edgeList << std::endl;
 #endif
 
-	Geometry* resultGeom=nullptr;
-	std::unique_ptr< std::vector<Geometry*> > resultPolyList;
-	std::vector<BufferSubgraph*> subgraphList;
+    Geometry* resultGeom = nullptr;
+    std::unique_ptr< std::vector<Geometry*> > resultPolyList;
+    std::vector<BufferSubgraph*> subgraphList;
 
-	try {
-		PlanarGraph graph(OverlayNodeFactory::instance());
-		graph.addEdges(edgeList.getEdges());
+    try {
+        PlanarGraph graph(OverlayNodeFactory::instance());
+        graph.addEdges(edgeList.getEdges());
 
-    GEOS_CHECK_FOR_INTERRUPTS();
+        GEOS_CHECK_FOR_INTERRUPTS();
 
-		createSubgraphs(&graph, subgraphList);
+        createSubgraphs(&graph, subgraphList);
 
 #if GEOS_DEBUG
-	std::cerr<<"Created "<<subgraphList.size()<<" subgraphs"<<std::endl;
+        std::cerr << "Created " << subgraphList.size() << " subgraphs" << std::endl;
 #if GEOS_DEBUG > 1
-	for (size_t i=0, n=subgraphList.size(); i<n; i++)
-		std::cerr << std::setprecision(10) << *(subgraphList[i]) << std::endl;
+        for(size_t i = 0, n = subgraphList.size(); i < n; i++) {
+            std::cerr << std::setprecision(10) << *(subgraphList[i]) << std::endl;
+        }
 #endif
 #endif
 
-    GEOS_CHECK_FOR_INTERRUPTS();
+        GEOS_CHECK_FOR_INTERRUPTS();
 
-		{ // scope for earlier PolygonBuilder cleanupt
-		  PolygonBuilder polyBuilder(geomFact);
-		  buildSubgraphs(subgraphList, polyBuilder);
+        {
+            // scope for earlier PolygonBuilder cleanupt
+            PolygonBuilder polyBuilder(geomFact);
+            buildSubgraphs(subgraphList, polyBuilder);
 
-		  resultPolyList.reset( polyBuilder.getPolygons() );
-		}
+            resultPolyList.reset(polyBuilder.getPolygons());
+        }
 
-		// Get rid of the subgraphs, shouldn't be needed anymore
-    for (size_t i=0, n=subgraphList.size(); i<n; i++) delete subgraphList[i];
-    subgraphList.clear();
+        // Get rid of the subgraphs, shouldn't be needed anymore
+        for(size_t i = 0, n = subgraphList.size(); i < n; i++) {
+            delete subgraphList[i];
+        }
+        subgraphList.clear();
 
 #if GEOS_DEBUG
-	std::cerr << "PolygonBuilder got " << resultPolyList->size()
-	          << " polygons" << std::endl;
+        std::cerr << "PolygonBuilder got " << resultPolyList->size()
+                  << " polygons" << std::endl;
 #if GEOS_DEBUG > 1
-	for (size_t i=0, n=resultPolyList->size(); i<n; i++)
-		std::cerr << (*resultPolyList)[i]->toString() << std::endl;
+        for(size_t i = 0, n = resultPolyList->size(); i < n; i++) {
+            std::cerr << (*resultPolyList)[i]->toString() << std::endl;
+        }
 #endif
 #endif
 
-		// just in case ...
-		if ( resultPolyList->empty() ) return createEmptyResultGeometry();
+        // just in case ...
+        if(resultPolyList->empty()) {
+            return createEmptyResultGeometry();
+        }
 
-		// resultPolyList ownership transferred here
-		resultGeom=geomFact->buildGeometry(resultPolyList.release());
+        // resultPolyList ownership transferred here
+        resultGeom = geomFact->buildGeometry(resultPolyList.release());
 
-	} catch (const util::GEOSException& /* exc */) {
+    }
+    catch(const util::GEOSException& /* exc */) {
 
-		// In case they're still around
-		for (size_t i=0, n=subgraphList.size(); i<n; i++)
-			delete subgraphList[i];
-		subgraphList.clear();
+        // In case they're still around
+        for(size_t i = 0, n = subgraphList.size(); i < n; i++) {
+            delete subgraphList[i];
+        }
+        subgraphList.clear();
 
-		throw;
-	}
+        throw;
+    }
 
-	return resultGeom;
+    return resultGeom;
 }
 
 /*private*/
 Noder*
 BufferBuilder::getNoder(const PrecisionModel* pm)
 {
-	// this doesn't change workingNoder precisionModel!
-	if (workingNoder != nullptr) return workingNoder;
+    // this doesn't change workingNoder precisionModel!
+    if(workingNoder != nullptr) {
+        return workingNoder;
+    }
 
-	// otherwise use a fast (but non-robust) noder
+    // otherwise use a fast (but non-robust) noder
 
-	if ( li ) // reuse existing IntersectionAdder and LineIntersector
-	{
-		li->setPrecisionModel(pm);
-		assert(intersectionAdder!=nullptr);
-	}
-	else
-	{
-		li = new LineIntersector(pm);
-		intersectionAdder = new IntersectionAdder(*li);
-	}
+    if(li) {  // reuse existing IntersectionAdder and LineIntersector
+        li->setPrecisionModel(pm);
+        assert(intersectionAdder != nullptr);
+    }
+    else {
+        li = new LineIntersector(pm);
+        intersectionAdder = new IntersectionAdder(*li);
+    }
 
-	MCIndexNoder* noder = new MCIndexNoder(intersectionAdder);
+    MCIndexNoder* noder = new MCIndexNoder(intersectionAdder);
 
 #if 0
-	/* CoordinateArraySequence.cpp:84:
-	 * virtual const geos::Coordinate& geos::CoordinateArraySequence::getAt(size_t) const:
-	 * Assertion `pos<vect->size()' failed.
-	 */
-	//Noder* noder = new snapround::SimpleSnapRounder(*pm);
-
-	Noder* noder = new IteratedNoder(pm);
-
-	Noder noder = new SimpleSnapRounder(pm);
-	Noder noder = new MCIndexSnapRounder(pm);
-	Noder noder = new ScaledNoder(
-		new MCIndexSnapRounder(new PrecisionModel(1.0)),
-			pm.getScale());
+    /* CoordinateArraySequence.cpp:84:
+     * virtual const geos::Coordinate& geos::CoordinateArraySequence::getAt(size_t) const:
+     * Assertion `pos<vect->size()' failed.
+     */
+    //Noder* noder = new snapround::SimpleSnapRounder(*pm);
+
+    Noder* noder = new IteratedNoder(pm);
+
+    Noder noder = new SimpleSnapRounder(pm);
+    Noder noder = new MCIndexSnapRounder(pm);
+    Noder noder = new ScaledNoder(
+        new MCIndexSnapRounder(new PrecisionModel(1.0)),
+        pm.getScale());
 #endif
 
-	return noder;
+    return noder;
 
 }
 
 /* private */
 void
 BufferBuilder::computeNodedEdges(SegmentString::NonConstVect& bufferSegStrList,
-		const PrecisionModel *precisionModel) // throw(GEOSException)
+                                 const PrecisionModel* precisionModel) // throw(GEOSException)
 {
-	Noder* noder = getNoder( precisionModel );
+    Noder* noder = getNoder(precisionModel);
 
 #if JTS_DEBUG
-geos::io::WKTWriter wktWriter; wktWriter.setTrim(true);
-std::cerr << "before noding: "
-  << wktWriter.write(
-        convertSegStrings(geomFact, bufferSegStrList.begin(),
+    geos::io::WKTWriter wktWriter;
+    wktWriter.setTrim(true);
+    std::cerr << "before noding: "
+              << wktWriter.write(
+                  convertSegStrings(geomFact, bufferSegStrList.begin(),
                                     bufferSegStrList.end()).get()
-     ) << std::endl;
+              ) << std::endl;
 #endif
 
-	noder->computeNodes(&bufferSegStrList);
+    noder->computeNodes(&bufferSegStrList);
 
-	SegmentString::NonConstVect* nodedSegStrings = \
-			noder->getNodedSubstrings();
+    SegmentString::NonConstVect* nodedSegStrings = \
+            noder->getNodedSubstrings();
 
 #if JTS_DEBUG
-std::cerr << "after noding: "
-  << wktWriter.write(
-        convertSegStrings(geomFact, bufferSegStrList.begin(),
+    std::cerr << "after noding: "
+              << wktWriter.write(
+                  convertSegStrings(geomFact, bufferSegStrList.begin(),
                                     bufferSegStrList.end()).get()
-     ) << std::endl;
+              ) << std::endl;
 #endif
 
 
-	for (SegmentString::NonConstVect::iterator
-		i=nodedSegStrings->begin(), e=nodedSegStrings->end();
-		i!=e;
-		++i)
-	{
-		SegmentString* segStr = *i;
-		const Label* oldLabel = static_cast<const Label*>(segStr->getData());
+    for(SegmentString::NonConstVect::iterator
+            i = nodedSegStrings->begin(), e = nodedSegStrings->end();
+            i != e;
+            ++i) {
+        SegmentString* segStr = *i;
+        const Label* oldLabel = static_cast<const Label*>(segStr->getData());
 
-		CoordinateSequence* cs = CoordinateSequence::removeRepeatedPoints(segStr->getCoordinates());
-		delete segStr;
-		if ( cs->size() < 2 )
-		{
-			// don't insert collapsed edges
-			// we need to take care of the memory here as cs is a new sequence
-			delete cs;
-			continue;
-		}
+        CoordinateSequence* cs = CoordinateSequence::removeRepeatedPoints(segStr->getCoordinates());
+        delete segStr;
+        if(cs->size() < 2) {
+            // don't insert collapsed edges
+            // we need to take care of the memory here as cs is a new sequence
+            delete cs;
+            continue;
+        }
 
-		// Edge takes ownership of the CoordinateSequence
-		Edge* edge = new Edge(cs, *oldLabel);
+        // Edge takes ownership of the CoordinateSequence
+        Edge* edge = new Edge(cs, *oldLabel);
 
-		// will take care of the Edge ownership
-		insertUniqueEdge(edge);
-	}
+        // will take care of the Edge ownership
+        insertUniqueEdge(edge);
+    }
 
-	delete nodedSegStrings;
+    delete nodedSegStrings;
 
-	if ( noder != workingNoder ) delete noder;
+    if(noder != workingNoder) {
+        delete noder;
+    }
 }
 
 /*private*/
 void
-BufferBuilder::insertUniqueEdge(Edge *e)
+BufferBuilder::insertUniqueEdge(Edge* e)
 {
-	//<FIX> MD 8 Oct 03  speed up identical edge lookup
-	// fast lookup
-	Edge *existingEdge = edgeList.findEqualEdge(e);
-	// If an identical edge already exists, simply update its label
-	if (existingEdge != nullptr) {
-		Label& existingLabel = existingEdge->getLabel();
-		Label labelToMerge = e->getLabel();
-
-		// check if new edge is in reverse direction to existing edge
-		// if so, must flip the label before merging it
-		if (! existingEdge->isPointwiseEqual(e))
-		{
-			labelToMerge = e->getLabel();
-			labelToMerge.flip();
-		}
-
-		existingLabel.merge(labelToMerge);
-
-		// compute new depth delta of sum of edges
-		int mergeDelta = depthDelta(labelToMerge);
-		int existingDelta = existingEdge->getDepthDelta();
-		int newDelta = existingDelta + mergeDelta;
-		existingEdge->setDepthDelta(newDelta);
-
-		// we have memory release responsibility
-		delete e;
-
-	} else {   // no matching existing edge was found
-
-		// add this new edge to the list of edges in this graph
-		edgeList.add(e);
-
-		e->setDepthDelta(depthDelta(e->getLabel()));
-	}
+    //<FIX> MD 8 Oct 03  speed up identical edge lookup
+    // fast lookup
+    Edge* existingEdge = edgeList.findEqualEdge(e);
+    // If an identical edge already exists, simply update its label
+    if(existingEdge != nullptr) {
+        Label& existingLabel = existingEdge->getLabel();
+        Label labelToMerge = e->getLabel();
+
+        // check if new edge is in reverse direction to existing edge
+        // if so, must flip the label before merging it
+        if(! existingEdge->isPointwiseEqual(e)) {
+            labelToMerge = e->getLabel();
+            labelToMerge.flip();
+        }
+
+        existingLabel.merge(labelToMerge);
+
+        // compute new depth delta of sum of edges
+        int mergeDelta = depthDelta(labelToMerge);
+        int existingDelta = existingEdge->getDepthDelta();
+        int newDelta = existingDelta + mergeDelta;
+        existingEdge->setDepthDelta(newDelta);
+
+        // we have memory release responsibility
+        delete e;
+
+    }
+    else {     // no matching existing edge was found
+
+        // add this new edge to the list of edges in this graph
+        edgeList.add(e);
+
+        e->setDepthDelta(depthDelta(e->getLabel()));
+    }
 }
 
-bool BufferSubgraphGT(BufferSubgraph *first, BufferSubgraph *second) {
-	if (first->compareTo(second)>0)
-		return true;
-	else
-		return false;
+bool
+BufferSubgraphGT(BufferSubgraph* first, BufferSubgraph* second)
+{
+    if(first->compareTo(second) > 0) {
+        return true;
+    }
+    else {
+        return false;
+    }
 }
 
 /*private*/
 void
-BufferBuilder::createSubgraphs(PlanarGraph *graph, std::vector<BufferSubgraph*>& subgraphList)
+BufferBuilder::createSubgraphs(PlanarGraph* graph, std::vector<BufferSubgraph*>& subgraphList)
 {
-	std::vector<Node*> nodes;
-	graph->getNodes(nodes);
-	for (size_t i=0, n=nodes.size(); i<n; i++) {
-		Node *node=nodes[i];
-		if (!node->isVisited()) {
-			BufferSubgraph *subgraph=new BufferSubgraph();
-			subgraph->create(node);
-			subgraphList.push_back(subgraph);
-		}
-	}
-
-	/*
-	 * Sort the subgraphs in descending order of their rightmost coordinate
-	 * This ensures that when the Polygons for the subgraphs are built,
-	 * subgraphs for shells will have been built before the subgraphs for
-	 * any holes they contain
-	 */
+    std::vector<Node*> nodes;
+    graph->getNodes(nodes);
+    for(size_t i = 0, n = nodes.size(); i < n; i++) {
+        Node* node = nodes[i];
+        if(!node->isVisited()) {
+            BufferSubgraph* subgraph = new BufferSubgraph();
+            subgraph->create(node);
+            subgraphList.push_back(subgraph);
+        }
+    }
+
+    /*
+     * Sort the subgraphs in descending order of their rightmost coordinate
+     * This ensures that when the Polygons for the subgraphs are built,
+     * subgraphs for shells will have been built before the subgraphs for
+     * any holes they contain
+     */
     std::sort(subgraphList.begin(), subgraphList.end(), BufferSubgraphGT);
 }
 
 /*private*/
 void
 BufferBuilder::buildSubgraphs(const std::vector<BufferSubgraph*>& subgraphList,
-		PolygonBuilder& polyBuilder)
+                              PolygonBuilder& polyBuilder)
 {
 
 #if GEOS_DEBUG
-	std::cerr << __FUNCTION__ << " got " << subgraphList.size() << " subgraphs" << std::endl;
+    std::cerr << __FUNCTION__ << " got " << subgraphList.size() << " subgraphs" << std::endl;
 #endif
-	std::vector<BufferSubgraph*> processedGraphs;
-	for (size_t i=0, n=subgraphList.size(); i<n; i++)
-	{
-		BufferSubgraph *subgraph=subgraphList[i];
-		Coordinate *p=subgraph->getRightmostCoordinate();
-		assert(p);
+    std::vector<BufferSubgraph*> processedGraphs;
+    for(size_t i = 0, n = subgraphList.size(); i < n; i++) {
+        BufferSubgraph* subgraph = subgraphList[i];
+        Coordinate* p = subgraph->getRightmostCoordinate();
+        assert(p);
 
 #if GEOS_DEBUG
-		std::cerr << " " << i << ") Subgraph[" << subgraph << "]" << std::endl;
-		std::cerr << "  rightmost Coordinate " << *p;
+        std::cerr << " " << i << ") Subgraph[" << subgraph << "]" << std::endl;
+        std::cerr << "  rightmost Coordinate " << *p;
 #endif
-		SubgraphDepthLocater locater(&processedGraphs);
+        SubgraphDepthLocater locater(&processedGraphs);
 #if GEOS_DEBUG
-		std::cerr << " after SubgraphDepthLocater processedGraphs contain "
-		          << processedGraphs.size()
-		          << " elements" << std::endl;
+        std::cerr << " after SubgraphDepthLocater processedGraphs contain "
+                  << processedGraphs.size()
+                  << " elements" << std::endl;
 #endif
-		int outsideDepth=locater.getDepth(*p);
+        int outsideDepth = locater.getDepth(*p);
 #if GEOS_DEBUG
-		std::cerr << " Depth of rightmost coordinate: " << outsideDepth << std::endl;
+        std::cerr << " Depth of rightmost coordinate: " << outsideDepth << std::endl;
 #endif
-		subgraph->computeDepth(outsideDepth);
-		subgraph->findResultEdges();
+        subgraph->computeDepth(outsideDepth);
+        subgraph->findResultEdges();
 #if GEOS_DEBUG
-		std::cerr << " after computeDepth and findResultEdges subgraph contain:" << std::endl
-		          << "   " << subgraph->getDirectedEdges()->size() << " DirecteEdges " << std::endl
-		          << "   " << subgraph->getNodes()->size() << " Nodes " << std::endl;
+        std::cerr << " after computeDepth and findResultEdges subgraph contain:" << std::endl
+                  << "   " << subgraph->getDirectedEdges()->size() << " DirecteEdges " << std::endl
+                  << "   " << subgraph->getNodes()->size() << " Nodes " << std::endl;
 #endif
-		processedGraphs.push_back(subgraph);
+        processedGraphs.push_back(subgraph);
 #if GEOS_DEBUG
-		std::cerr << " added " << subgraph << " to processedGraphs, new size is "
-		          << processedGraphs.size() << std::endl;
+        std::cerr << " added " << subgraph << " to processedGraphs, new size is "
+                  << processedGraphs.size() << std::endl;
 #endif
-		polyBuilder.add(subgraph->getDirectedEdges(), subgraph->getNodes());
-	}
+        polyBuilder.add(subgraph->getDirectedEdges(), subgraph->getNodes());
+    }
 }
 
 /*private*/
 geom::Geometry*
 BufferBuilder::createEmptyResultGeometry() const
 {
-	geom::Geometry* emptyGeom = geomFact->createPolygon(nullptr, nullptr);
-	return emptyGeom;
+    geom::Geometry* emptyGeom = geomFact->createPolygon(nullptr, nullptr);
+    return emptyGeom;
 }
 
 } // namespace geos.operation.buffer
diff --git a/src/operation/buffer/BufferInputLineSimplifier.cpp b/src/operation/buffer/BufferInputLineSimplifier.cpp
index 259fa94..5d1d9d1 100644
--- a/src/operation/buffer/BufferInputLineSimplifier.cpp
+++ b/src/operation/buffer/BufferInputLineSimplifier.cpp
@@ -37,10 +37,10 @@ namespace operation { // geos.operation
 namespace buffer { // geos.operation.buffer
 
 BufferInputLineSimplifier::BufferInputLineSimplifier(
-		const geom::CoordinateSequence& input)
-	:
-	inputLine(input),
-	angleOrientation(Orientation::COUNTERCLOCKWISE)
+    const geom::CoordinateSequence& input)
+    :
+    inputLine(input),
+    angleOrientation(Orientation::COUNTERCLOCKWISE)
 {}
 
 /*public static*/
@@ -48,92 +48,95 @@ std::unique_ptr<geom::CoordinateSequence>
 BufferInputLineSimplifier::simplify(const geom::CoordinateSequence& inputLine,
                                     double distanceTol)
 {
-	BufferInputLineSimplifier simp(inputLine);
-	return simp.simplify(distanceTol);
+    BufferInputLineSimplifier simp(inputLine);
+    return simp.simplify(distanceTol);
 }
 
 /* public */
 std::unique_ptr<geom::CoordinateSequence>
 BufferInputLineSimplifier::simplify(double nDistanceTol)
 {
-	distanceTol = fabs(nDistanceTol);
-	if (nDistanceTol < 0)
-		angleOrientation = Orientation::CLOCKWISE;
-
-	// rely on fact that boolean array is filled with false value
-	static const int startValue = INIT;
-	isDeleted.assign(inputLine.size(), startValue);
-
-	bool isChanged = false;
-	do {
-		isChanged = deleteShallowConcavities();
-	} while (isChanged);
-
-	return collapseLine();
+    distanceTol = fabs(nDistanceTol);
+    if(nDistanceTol < 0) {
+        angleOrientation = Orientation::CLOCKWISE;
+    }
+
+    // rely on fact that boolean array is filled with false value
+    static const int startValue = INIT;
+    isDeleted.assign(inputLine.size(), startValue);
+
+    bool isChanged = false;
+    do {
+        isChanged = deleteShallowConcavities();
+    }
+    while(isChanged);
+
+    return collapseLine();
 }
 
 /* private */
 bool
 BufferInputLineSimplifier::deleteShallowConcavities()
 {
-	/**
-	 * Do not simplify end line segments of the line string.
-	 * This ensures that end caps are generated consistently.
-	 */
-	size_t index = 1;
-
-	auto midIndex = findNextNonDeletedIndex(index);
-	auto lastIndex = findNextNonDeletedIndex(midIndex);
-
-	bool isChanged = false;
-	while (lastIndex < inputLine.size())
-	{
-		// test triple for shallow concavity
-		bool isMiddleVertexDeleted = false;
-		if (isDeletable(index, midIndex, lastIndex,
-		                distanceTol))
-		{
-			isDeleted[midIndex] = DELETE;
-			isMiddleVertexDeleted = true;
-			isChanged = true;
-		}
-		// move simplification window forward
-		if (isMiddleVertexDeleted)
-			index = lastIndex;
-		else
-			index = midIndex;
-
-		midIndex = findNextNonDeletedIndex(index);
-		lastIndex = findNextNonDeletedIndex(midIndex);
-	}
-	return isChanged;
+    /**
+     * Do not simplify end line segments of the line string.
+     * This ensures that end caps are generated consistently.
+     */
+    size_t index = 1;
+
+    auto midIndex = findNextNonDeletedIndex(index);
+    auto lastIndex = findNextNonDeletedIndex(midIndex);
+
+    bool isChanged = false;
+    while(lastIndex < inputLine.size()) {
+        // test triple for shallow concavity
+        bool isMiddleVertexDeleted = false;
+        if(isDeletable(index, midIndex, lastIndex,
+                       distanceTol)) {
+            isDeleted[midIndex] = DELETE;
+            isMiddleVertexDeleted = true;
+            isChanged = true;
+        }
+        // move simplification window forward
+        if(isMiddleVertexDeleted) {
+            index = lastIndex;
+        }
+        else {
+            index = midIndex;
+        }
+
+        midIndex = findNextNonDeletedIndex(index);
+        lastIndex = findNextNonDeletedIndex(midIndex);
+    }
+    return isChanged;
 }
 
 /* private */
 size_t
 BufferInputLineSimplifier::findNextNonDeletedIndex(size_t index) const
 {
-	std::size_t next = index + 1;
-	const std::size_t len = inputLine.size();
-	while (next < len && isDeleted[next] == DELETE)
-		next++;
-	return next;
+    std::size_t next = index + 1;
+    const std::size_t len = inputLine.size();
+    while(next < len && isDeleted[next] == DELETE) {
+        next++;
+    }
+    return next;
 }
 
 /* private */
 std::unique_ptr<geom::CoordinateSequence>
 BufferInputLineSimplifier::collapseLine() const
 {
-	std::unique_ptr<geom::CoordinateSequence> coordList(
-		new CoordinateArraySequence());
+    std::unique_ptr<geom::CoordinateSequence> coordList(
+        new CoordinateArraySequence());
 
-	for (size_t i=0, n=inputLine.size(); i<n; ++i)
-	{
-		if (isDeleted[i] != DELETE)
-			coordList->add(inputLine[i], false);
-	}
+    for(size_t i = 0, n = inputLine.size(); i < n; ++i) {
+        if(isDeleted[i] != DELETE) {
+            coordList->add(inputLine[i], false);
+        }
+    }
 
-	return coordList;
+    return coordList;
 }
 
 /* private */
@@ -141,51 +144,59 @@ bool
 BufferInputLineSimplifier::isDeletable(size_t i0, size_t i1, size_t i2,
                                        double p_distanceTol) const
 {
-	const Coordinate& p0 = inputLine[i0];
-	const Coordinate& p1 = inputLine[i1];
-	const Coordinate& p2 = inputLine[i2];
+    const Coordinate& p0 = inputLine[i0];
+    const Coordinate& p1 = inputLine[i1];
+    const Coordinate& p2 = inputLine[i2];
 
-	if (! isConcave(p0, p1, p2)) return false;
-	if (! isShallow(p0, p1, p2, p_distanceTol)) return false;
+    if(! isConcave(p0, p1, p2)) {
+        return false;
+    }
+    if(! isShallow(p0, p1, p2, p_distanceTol)) {
+        return false;
+    }
 
-	// MD - don't use this heuristic - it's too restricting
-	// if (p0.distance(p2) > distanceTol) return false;
+    // MD - don't use this heuristic - it's too restricting
+    // if (p0.distance(p2) > distanceTol) return false;
 
-	return isShallowSampled(p0, p1, i0, i2, p_distanceTol);
+    return isShallowSampled(p0, p1, i0, i2, p_distanceTol);
 }
 
 /* private */
 bool
 BufferInputLineSimplifier::isShallowConcavity(const geom::Coordinate& p0,
-                                              const geom::Coordinate& p1,
-                                              const geom::Coordinate& p2,
-                                              double p_distanceTol) const
+        const geom::Coordinate& p1,
+        const geom::Coordinate& p2,
+        double p_distanceTol) const
 {
-	int orientation = Orientation::index(p0, p1, p2);
-	bool isAngleToSimplify = (orientation == angleOrientation);
-	if (! isAngleToSimplify)
-		return false;
-
-	double dist = Distance::pointToSegment(p1, p0, p2);
-	return dist < p_distanceTol;
+    int orientation = Orientation::index(p0, p1, p2);
+    bool isAngleToSimplify = (orientation == angleOrientation);
+    if(! isAngleToSimplify) {
+        return false;
+    }
+
+    double dist = Distance::pointToSegment(p1, p0, p2);
+    return dist < p_distanceTol;
 }
 
 /* private */
 bool
 BufferInputLineSimplifier::isShallowSampled(const geom::Coordinate& p0,
-                                            const geom::Coordinate& p2,
-                                            size_t i0, size_t i2,
-                                            double p_distanceTol) const
+        const geom::Coordinate& p2,
+        size_t i0, size_t i2,
+        double p_distanceTol) const
 {
-	// check every n'th point to see if it is within tolerance
-	auto inc = (i2 - i0) / NUM_PTS_TO_CHECK;
-	if (inc <= 0) inc = 1;
-
-	for (size_t i = i0; i < i2; i += inc) {
-		if (! isShallow(p0, p2, inputLine[i], p_distanceTol))
-			return false;
-	}
-	return true;
+    // check every n'th point to see if it is within tolerance
+    auto inc = (i2 - i0) / NUM_PTS_TO_CHECK;
+    if(inc <= 0) {
+        inc = 1;
+    }
+
+    for(size_t i = i0; i < i2; i += inc) {
+        if(! isShallow(p0, p2, inputLine[i], p_distanceTol)) {
+            return false;
+        }
+    }
+    return true;
 }
 
 /* private */
@@ -195,8 +206,8 @@ BufferInputLineSimplifier::isShallow(const geom::Coordinate& p0,
                                      const geom::Coordinate& p2,
                                      double p_distanceTol) const
 {
-	double dist = Distance::pointToSegment(p1, p0, p2);
-	return dist < p_distanceTol;
+    double dist = Distance::pointToSegment(p1, p0, p2);
+    return dist < p_distanceTol;
 }
 
 /* private */
@@ -205,9 +216,9 @@ BufferInputLineSimplifier::isConcave(const geom::Coordinate& p0,
                                      const geom::Coordinate& p1,
                                      const geom::Coordinate& p2) const
 {
-	int orientation = Orientation::index(p0, p1, p2);
-	bool p_isConcave = (orientation == angleOrientation);
-	return p_isConcave;
+    int orientation = Orientation::index(p0, p1, p2);
+    bool p_isConcave = (orientation == angleOrientation);
+    return p_isConcave;
 }
 
 } // namespace geos.operation.buffer
diff --git a/src/operation/buffer/BufferOp.cpp b/src/operation/buffer/BufferOp.cpp
index e34c2fb..3e815fd 100644
--- a/src/operation/buffer/BufferOp.cpp
+++ b/src/operation/buffer/BufferOp.cpp
@@ -57,69 +57,70 @@ namespace operation { // geos.operation
 namespace buffer { // geos.operation.buffer
 
 #if PROFILE
-static Profiler *profiler = Profiler::instance();
+static Profiler* profiler = Profiler::instance();
 #endif
 
 #if 0
-double OLDprecisionScaleFactor(const Geometry *g,
-	double distance, int maxPrecisionDigits)
+double
+OLDprecisionScaleFactor(const Geometry* g,
+                        double distance, int maxPrecisionDigits)
 {
-	const Envelope *env=g->getEnvelopeInternal();
-	double envSize=std::max(env->getHeight(), env->getWidth());
-	double expandByDistance=distance > 0.0 ? distance : 0.0;
-	double bufEnvSize=envSize + 2 * expandByDistance;
-	// the smallest power of 10 greater than the buffer envelope
-	int bufEnvLog10=(int) (std::log(bufEnvSize) / std::log(10.0) + 1.0);
-	int minUnitLog10=bufEnvLog10 - maxPrecisionDigits;
-	// scale factor is inverse of min Unit size, so flip sign of exponent
-	double scaleFactor=std::pow(10.0,-minUnitLog10);
-	return scaleFactor;
+    const Envelope* env = g->getEnvelopeInternal();
+    double envSize = std::max(env->getHeight(), env->getWidth());
+    double expandByDistance = distance > 0.0 ? distance : 0.0;
+    double bufEnvSize = envSize + 2 * expandByDistance;
+    // the smallest power of 10 greater than the buffer envelope
+    int bufEnvLog10 = (int)(std::log(bufEnvSize) / std::log(10.0) + 1.0);
+    int minUnitLog10 = bufEnvLog10 - maxPrecisionDigits;
+    // scale factor is inverse of min Unit size, so flip sign of exponent
+    double scaleFactor = std::pow(10.0, -minUnitLog10);
+    return scaleFactor;
 }
 #endif
 
 /*private*/
 double
-BufferOp::precisionScaleFactor(const Geometry *g,
-	double distance,
-	int maxPrecisionDigits)
+BufferOp::precisionScaleFactor(const Geometry* g,
+                               double distance,
+                               int maxPrecisionDigits)
 {
-  const Envelope *env=g->getEnvelopeInternal();
-  double envMax = std::max(
-    std::max(fabs(env->getMaxX()), fabs(env->getMinX())),
-    std::max(fabs(env->getMaxY()), fabs(env->getMinY()))
-  );
+    const Envelope* env = g->getEnvelopeInternal();
+    double envMax = std::max(
+                        std::max(fabs(env->getMaxX()), fabs(env->getMinX())),
+                        std::max(fabs(env->getMaxY()), fabs(env->getMinY()))
+                    );
 
-  double expandByDistance = distance > 0.0 ? distance : 0.0;
-  double bufEnvMax = envMax + 2 * expandByDistance;
+    double expandByDistance = distance > 0.0 ? distance : 0.0;
+    double bufEnvMax = envMax + 2 * expandByDistance;
 
-  // the smallest power of 10 greater than the buffer envelope
-  int bufEnvPrecisionDigits = (int) (std::log(bufEnvMax) / std::log(10.0) + 1.0);
-  int minUnitLog10 = maxPrecisionDigits - bufEnvPrecisionDigits;
+    // the smallest power of 10 greater than the buffer envelope
+    int bufEnvPrecisionDigits = (int)(std::log(bufEnvMax) / std::log(10.0) + 1.0);
+    int minUnitLog10 = maxPrecisionDigits - bufEnvPrecisionDigits;
 
-  double scaleFactor = std::pow(10.0, minUnitLog10);
+    double scaleFactor = std::pow(10.0, minUnitLog10);
 
-  return scaleFactor;
+    return scaleFactor;
 }
 
 /*public static*/
 Geometry*
-BufferOp::bufferOp(const Geometry *g, double distance,
-		int quadrantSegments,
-		int nEndCapStyle)
+BufferOp::bufferOp(const Geometry* g, double distance,
+                   int quadrantSegments,
+                   int nEndCapStyle)
 {
-	BufferOp bufOp(g);
-	bufOp.setQuadrantSegments(quadrantSegments);
-	bufOp.setEndCapStyle(nEndCapStyle);
-	return bufOp.getResultGeometry(distance);
+    BufferOp bufOp(g);
+    bufOp.setQuadrantSegments(quadrantSegments);
+    bufOp.setEndCapStyle(nEndCapStyle);
+    return bufOp.getResultGeometry(distance);
 }
 
 /*public*/
 Geometry*
 BufferOp::getResultGeometry(double nDistance)
 {
-	distance=nDistance;
-	computeGeometry();
-	return resultGeometry;
+    distance = nDistance;
+    computeGeometry();
+    return resultGeometry;
 }
 
 /*private*/
@@ -127,23 +128,27 @@ void
 BufferOp::computeGeometry()
 {
 #if GEOS_DEBUG
-	std::cerr<<"BufferOp::computeGeometry: trying with original precision"<<std::endl;
+    std::cerr << "BufferOp::computeGeometry: trying with original precision" << std::endl;
 #endif
 
-	bufferOriginalPrecision();
+    bufferOriginalPrecision();
 
-	if (resultGeometry!=nullptr) return;
+    if(resultGeometry != nullptr) {
+        return;
+    }
 
 #if GEOS_DEBUG
-	std::cerr << "bufferOriginalPrecision failed (" << saveException.what() << "), trying with reduced precision"
-	          << std::endl;
+    std::cerr << "bufferOriginalPrecision failed (" << saveException.what() << "), trying with reduced precision"
+              << std::endl;
 #endif
 
-	const PrecisionModel& argPM = *(argGeom->getFactory()->getPrecisionModel());
-	if ( argPM.getType() == PrecisionModel::FIXED )
-		bufferFixedPrecision(argPM);
-	else
-		bufferReducedPrecision();
+    const PrecisionModel& argPM = *(argGeom->getFactory()->getPrecisionModel());
+    if(argPM.getType() == PrecisionModel::FIXED) {
+        bufferFixedPrecision(argPM);
+    }
+    else {
+        bufferReducedPrecision();
+    }
 }
 
 /*private*/
@@ -151,68 +156,66 @@ void
 BufferOp::bufferReducedPrecision()
 {
 
-	// try and compute with decreasing precision,
-	// up to a min, to avoid gross results
-	// (not in JTS, see http://trac.osgeo.org/geos/ticket/605)
+    // try and compute with decreasing precision,
+    // up to a min, to avoid gross results
+    // (not in JTS, see http://trac.osgeo.org/geos/ticket/605)
 #define MIN_PRECISION_DIGITS 6
-	for (int precDigits=MAX_PRECISION_DIGITS; precDigits >= MIN_PRECISION_DIGITS; precDigits--)
-	{
+    for(int precDigits = MAX_PRECISION_DIGITS; precDigits >= MIN_PRECISION_DIGITS; precDigits--) {
 #if GEOS_DEBUG
-		std::cerr<<"BufferOp::computeGeometry: trying with precDigits "<<precDigits<<std::endl;
+        std::cerr << "BufferOp::computeGeometry: trying with precDigits " << precDigits << std::endl;
 #endif
-		try {
-			bufferReducedPrecision(precDigits);
-		} catch (const util::TopologyException& ex) {
-			saveException=ex;
-			// don't propagate the exception - it will be detected by fact that resultGeometry is null
-		}
-
-		if (resultGeometry!=nullptr) {
-			// debug
-			//if ( saveException ) std::cerr<<saveException->toString()<<std::endl;
-			return;
-		}
-	}
-	// tried everything - have to bail
-	throw saveException;
+        try {
+            bufferReducedPrecision(precDigits);
+        }
+        catch(const util::TopologyException& ex) {
+            saveException = ex;
+            // don't propagate the exception - it will be detected by fact that resultGeometry is null
+        }
+
+        if(resultGeometry != nullptr) {
+            // debug
+            //if ( saveException ) std::cerr<<saveException->toString()<<std::endl;
+            return;
+        }
+    }
+    // tried everything - have to bail
+    throw saveException;
 }
 
 /*private*/
 void
 BufferOp::bufferOriginalPrecision()
 {
-	BufferBuilder bufBuilder(bufParams);
-
-	//std::cerr<<"computing with original precision"<<std::endl;
-	try
-	{
-		resultGeometry=bufBuilder.buffer(argGeom, distance);
-	}
-	catch (const util::TopologyException& ex)
-	{
-		// don't propagate the exception - it will be detected by
-		// fact that resultGeometry is null
-		saveException=ex;
-
-		//std::cerr<<ex->toString()<<std::endl;
-	}
-	//std::cerr<<"done"<<std::endl;
+    BufferBuilder bufBuilder(bufParams);
+
+    //std::cerr<<"computing with original precision"<<std::endl;
+    try {
+        resultGeometry = bufBuilder.buffer(argGeom, distance);
+    }
+    catch(const util::TopologyException& ex) {
+        // don't propagate the exception - it will be detected by
+        // fact that resultGeometry is null
+        saveException = ex;
+
+        //std::cerr<<ex->toString()<<std::endl;
+    }
+    //std::cerr<<"done"<<std::endl;
 }
 
 void
 BufferOp::bufferReducedPrecision(int precisionDigits)
 {
-	double sizeBasedScaleFactor=precisionScaleFactor(argGeom, distance, precisionDigits);
+    double sizeBasedScaleFactor = precisionScaleFactor(argGeom, distance, precisionDigits);
 
 #if GEOS_DEBUG
-	std::cerr << "recomputing with precision scale factor = "
-		<< sizeBasedScaleFactor
-		<< std::endl;
+    std::cerr << "recomputing with precision scale factor = "
+              << sizeBasedScaleFactor
+              << std::endl;
 #endif
 
-	assert(sizeBasedScaleFactor>0);
-	PrecisionModel fixedPM(sizeBasedScaleFactor);
-	bufferFixedPrecision(fixedPM);
+    assert(sizeBasedScaleFactor > 0);
+    PrecisionModel fixedPM(sizeBasedScaleFactor);
+    bufferFixedPrecision(fixedPM);
 }
 
 /*private*/
@@ -221,49 +224,48 @@ BufferOp::bufferFixedPrecision(const PrecisionModel& fixedPM)
 {
 
 
-	PrecisionModel pm(1.0); // fixed as well
+    PrecisionModel pm(1.0); // fixed as well
 
 #if 0 /* FIXME: MCIndexSnapRounder seems to be still bogus */
-  snapround::MCIndexSnapRounder inoder(pm);
+    snapround::MCIndexSnapRounder inoder(pm);
 #else
-  algorithm::LineIntersector li(&fixedPM);
-  IntersectionAdder ia(li);
-  MCIndexNoder inoder(&ia);
+    algorithm::LineIntersector li(&fixedPM);
+    IntersectionAdder ia(li);
+    MCIndexNoder inoder(&ia);
 #endif
 
-	ScaledNoder noder(inoder, fixedPM.getScale());
-
-	BufferBuilder bufBuilder(bufParams);
-	bufBuilder.setWorkingPrecisionModel(&fixedPM);
-
-	bufBuilder.setNoder(&noder);
-
-	// Reduce precision of the input geometry
-	//
-	// NOTE: this reduction is not in JTS and should supposedly
-	//       not be needed because the PrecisionModel we pass
-	//       to the BufferBuilder above (with setWorkingPrecisionModel)
-	//       should be used to round coordinates emitted by the
-	//       OffsetCurveBuilder, thus effectively producing a fully
-	//       rounded input to the noder.
-	//       Nonetheless the amount of scrambling done by rounding here
-	//       is known to fix at least one case in which MCIndexNoder
-	//       would fail: http://trac.osgeo.org/geos/ticket/605
-	//
-	// TODO: follow JTS in MCIndexSnapRounder usage
-	//
-	const Geometry *workGeom = argGeom;
-	const PrecisionModel& argPM = *(argGeom->getFactory()->getPrecisionModel());
-	std::unique_ptr<Geometry> fixedGeom;
-	if ( argPM.getType() != PrecisionModel::FIXED || argPM.getScale() != fixedPM.getScale() )
-	{
-		using precision::GeometryPrecisionReducer;
-		fixedGeom = GeometryPrecisionReducer::reduce(*argGeom, fixedPM);
-		workGeom = fixedGeom.get();
-	}
-
-	// this may throw an exception, if robustness errors are encountered
-	resultGeometry = bufBuilder.buffer(workGeom, distance);
+    ScaledNoder noder(inoder, fixedPM.getScale());
+
+    BufferBuilder bufBuilder(bufParams);
+    bufBuilder.setWorkingPrecisionModel(&fixedPM);
+
+    bufBuilder.setNoder(&noder);
+
+    // Reduce precision of the input geometry
+    //
+    // NOTE: this reduction is not in JTS and should supposedly
+    //       not be needed because the PrecisionModel we pass
+    //       to the BufferBuilder above (with setWorkingPrecisionModel)
+    //       should be used to round coordinates emitted by the
+    //       OffsetCurveBuilder, thus effectively producing a fully
+    //       rounded input to the noder.
+    //       Nonetheless the amount of scrambling done by rounding here
+    //       is known to fix at least one case in which MCIndexNoder
+    //       would fail: http://trac.osgeo.org/geos/ticket/605
+    //
+    // TODO: follow JTS in MCIndexSnapRounder usage
+    //
+    const Geometry* workGeom = argGeom;
+    const PrecisionModel& argPM = *(argGeom->getFactory()->getPrecisionModel());
+    std::unique_ptr<Geometry> fixedGeom;
+    if(argPM.getType() != PrecisionModel::FIXED || argPM.getScale() != fixedPM.getScale()) {
+        using precision::GeometryPrecisionReducer;
+        fixedGeom = GeometryPrecisionReducer::reduce(*argGeom, fixedPM);
+        workGeom = fixedGeom.get();
+    }
+
+    // this may throw an exception, if robustness errors are encountered
+    resultGeometry = bufBuilder.buffer(workGeom, distance);
 }
 
 } // namespace geos.operation.buffer
diff --git a/src/operation/buffer/BufferParameters.cpp b/src/operation/buffer/BufferParameters.cpp
index f547c95..1a88d3b 100644
--- a/src/operation/buffer/BufferParameters.cpp
+++ b/src/operation/buffer/BufferParameters.cpp
@@ -42,28 +42,28 @@ BufferParameters::BufferParameters()
 
 // public
 BufferParameters::BufferParameters(int p_quadrantSegments)
-	:
-	quadrantSegments(DEFAULT_QUADRANT_SEGMENTS),
-	endCapStyle(CAP_ROUND),
-	joinStyle(JOIN_ROUND),
-	mitreLimit(DEFAULT_MITRE_LIMIT),
-	_isSingleSided(false)
+    :
+    quadrantSegments(DEFAULT_QUADRANT_SEGMENTS),
+    endCapStyle(CAP_ROUND),
+    joinStyle(JOIN_ROUND),
+    mitreLimit(DEFAULT_MITRE_LIMIT),
+    _isSingleSided(false)
 {
-	setQuadrantSegments(p_quadrantSegments);
+    setQuadrantSegments(p_quadrantSegments);
 }
 
 // public
 BufferParameters::BufferParameters(int p_quadrantSegments,
                                    EndCapStyle p_endCapStyle)
-	:
-	quadrantSegments(DEFAULT_QUADRANT_SEGMENTS),
-	endCapStyle(CAP_ROUND),
-	joinStyle(JOIN_ROUND),
-	mitreLimit(DEFAULT_MITRE_LIMIT),
-	_isSingleSided(false)
+    :
+    quadrantSegments(DEFAULT_QUADRANT_SEGMENTS),
+    endCapStyle(CAP_ROUND),
+    joinStyle(JOIN_ROUND),
+    mitreLimit(DEFAULT_MITRE_LIMIT),
+    _isSingleSided(false)
 {
-	setQuadrantSegments(p_quadrantSegments);
-	setEndCapStyle(p_endCapStyle);
+    setQuadrantSegments(p_quadrantSegments);
+    setEndCapStyle(p_endCapStyle);
 }
 
 // public
@@ -71,61 +71,62 @@ BufferParameters::BufferParameters(int p_quadrantSegments,
                                    EndCapStyle p_endCapStyle,
                                    JoinStyle p_joinStyle,
                                    double p_mitreLimit)
-	:
-	quadrantSegments(DEFAULT_QUADRANT_SEGMENTS),
-	endCapStyle(CAP_ROUND),
-	joinStyle(JOIN_ROUND),
-	mitreLimit(DEFAULT_MITRE_LIMIT),
-	_isSingleSided(false)
+    :
+    quadrantSegments(DEFAULT_QUADRANT_SEGMENTS),
+    endCapStyle(CAP_ROUND),
+    joinStyle(JOIN_ROUND),
+    mitreLimit(DEFAULT_MITRE_LIMIT),
+    _isSingleSided(false)
 {
-	setQuadrantSegments(p_quadrantSegments);
-	setEndCapStyle(p_endCapStyle);
-	setJoinStyle(p_joinStyle);
-	setMitreLimit(p_mitreLimit);
+    setQuadrantSegments(p_quadrantSegments);
+    setEndCapStyle(p_endCapStyle);
+    setJoinStyle(p_joinStyle);
+    setMitreLimit(p_mitreLimit);
 }
 
 // public
 void
 BufferParameters::setQuadrantSegments(int quadSegs)
 {
-	quadrantSegments = quadSegs;
-
-	/**
-	 * Indicates how to construct fillets.
-	 * If qs >= 1, fillet is round, and qs indicates number of
-	 * segments to use to approximate a quarter-circle.
-	 * If qs = 0, fillet is bevelled flat (i.e. no filleting is performed)
-	 * If qs < 0, fillet is mitred, and absolute value of qs
-	 * indicates maximum length of mitre according to
-	 *
-	 * mitreLimit = |qs|
-	 */
-	if (quadrantSegments == 0)
-		joinStyle = JOIN_BEVEL;
-	if (quadrantSegments < 0) {
-		joinStyle = JOIN_MITRE;
-		mitreLimit = std::abs(quadrantSegments);
-	}
-
-	if (quadSegs <= 0) {
-		quadrantSegments = 1;
-	}
-
-	/**
-	 * If join style was set by the quadSegs value,
-	 * use the default for the actual quadrantSegments value.
-	 */
-	if (joinStyle != JOIN_ROUND) {
-		quadrantSegments = DEFAULT_QUADRANT_SEGMENTS;
-	}
+    quadrantSegments = quadSegs;
+
+    /**
+     * Indicates how to construct fillets.
+     * If qs >= 1, fillet is round, and qs indicates number of
+     * segments to use to approximate a quarter-circle.
+     * If qs = 0, fillet is bevelled flat (i.e. no filleting is performed)
+     * If qs < 0, fillet is mitred, and absolute value of qs
+     * indicates maximum length of mitre according to
+     *
+     * mitreLimit = |qs|
+     */
+    if(quadrantSegments == 0) {
+        joinStyle = JOIN_BEVEL;
+    }
+    if(quadrantSegments < 0) {
+        joinStyle = JOIN_MITRE;
+        mitreLimit = std::abs(quadrantSegments);
+    }
+
+    if(quadSegs <= 0) {
+        quadrantSegments = 1;
+    }
+
+    /**
+     * If join style was set by the quadSegs value,
+     * use the default for the actual quadrantSegments value.
+     */
+    if(joinStyle != JOIN_ROUND) {
+        quadrantSegments = DEFAULT_QUADRANT_SEGMENTS;
+    }
 }
 
 // public static
 double
 BufferParameters::bufferDistanceError(int quadSegs)
 {
-	double alpha = M_PI / 2.0 / quadSegs;
-	return 1 - cos(alpha / 2.0);
+    double alpha = M_PI / 2.0 / quadSegs;
+    return 1 - cos(alpha / 2.0);
 }
 
 } // namespace geos.operation.buffer
diff --git a/src/operation/buffer/BufferSubgraph.cpp b/src/operation/buffer/BufferSubgraph.cpp
index 98ee051..9efb623 100644
--- a/src/operation/buffer/BufferSubgraph.cpp
+++ b/src/operation/buffer/BufferSubgraph.cpp
@@ -49,164 +49,161 @@ namespace buffer { // geos.operation.buffer
 
 // Argument is unused
 BufferSubgraph::BufferSubgraph()
-	:
-	finder(),
-	dirEdgeList(),
-	nodes(),
-	rightMostCoord(nullptr),
-	env(nullptr)
+    :
+    finder(),
+    dirEdgeList(),
+    nodes(),
+    rightMostCoord(nullptr),
+    env(nullptr)
 {
 }
 
 BufferSubgraph::~BufferSubgraph()
 {
-	delete env;
+    delete env;
 }
 
 /*public*/
 void
-BufferSubgraph::create(Node *node)
+BufferSubgraph::create(Node* node)
 {
-	addReachable(node);
+    addReachable(node);
 
-	// We are assuming that dirEdgeList
-	// contains *at leas* ONE forward DirectedEdge
-	finder.findEdge(&dirEdgeList);
+    // We are assuming that dirEdgeList
+    // contains *at leas* ONE forward DirectedEdge
+    finder.findEdge(&dirEdgeList);
 
-	rightMostCoord=&(finder.getCoordinate());
+    rightMostCoord = &(finder.getCoordinate());
 
-	// this is what happen if no forward DirectedEdge
-	// is passed to the RightmostEdgeFinder
-	assert(rightMostCoord);
+    // this is what happen if no forward DirectedEdge
+    // is passed to the RightmostEdgeFinder
+    assert(rightMostCoord);
 }
 
 /*private*/
 void
-BufferSubgraph::addReachable(Node *startNode)
+BufferSubgraph::addReachable(Node* startNode)
 {
-	vector<Node*> nodeStack;
-	nodeStack.push_back(startNode);
-	while (!nodeStack.empty()) {
-		Node *node=nodeStack.back();
-		nodeStack.pop_back();
-		add(node, &nodeStack);
-	}
+    vector<Node*> nodeStack;
+    nodeStack.push_back(startNode);
+    while(!nodeStack.empty()) {
+        Node* node = nodeStack.back();
+        nodeStack.pop_back();
+        add(node, &nodeStack);
+    }
 }
 
 /*private*/
 void
-BufferSubgraph::add(Node *node, vector<Node*> *nodeStack)
+BufferSubgraph::add(Node* node, vector<Node*>* nodeStack)
 {
-	node->setVisited(true);
-	nodes.push_back(node);
-	EdgeEndStar *ees=node->getEdges();
-	EdgeEndStar::iterator it=ees->begin();
-	EdgeEndStar::iterator endIt=ees->end();
-	for( ; it!=endIt; ++it)
-	{
-		assert(dynamic_cast<DirectedEdge*>(*it));
-		DirectedEdge *de=static_cast<DirectedEdge*>(*it);
-		dirEdgeList.push_back(de);
-		DirectedEdge *sym=de->getSym();
-		Node *symNode=sym->getNode();
-		/**
-		 * NOTE: this is a depth-first traversal of the graph.
-		 * This will cause a large depth of recursion.
-		 * It might be better to do a breadth-first traversal.
-		 */
-		if (! symNode->isVisited()) nodeStack->push_back(symNode);
-	}
+    node->setVisited(true);
+    nodes.push_back(node);
+    EdgeEndStar* ees = node->getEdges();
+    EdgeEndStar::iterator it = ees->begin();
+    EdgeEndStar::iterator endIt = ees->end();
+    for(; it != endIt; ++it) {
+        assert(dynamic_cast<DirectedEdge*>(*it));
+        DirectedEdge* de = static_cast<DirectedEdge*>(*it);
+        dirEdgeList.push_back(de);
+        DirectedEdge* sym = de->getSym();
+        Node* symNode = sym->getNode();
+        /**
+         * NOTE: this is a depth-first traversal of the graph.
+         * This will cause a large depth of recursion.
+         * It might be better to do a breadth-first traversal.
+         */
+        if(! symNode->isVisited()) {
+            nodeStack->push_back(symNode);
+        }
+    }
 }
 
 /*private*/
 void
 BufferSubgraph::clearVisitedEdges()
 {
-	for(size_t i=0, n=dirEdgeList.size(); i<n; ++i)
-	{
-		DirectedEdge *de=dirEdgeList[i];
-		de->setVisited(false);
-	}
+    for(size_t i = 0, n = dirEdgeList.size(); i < n; ++i) {
+        DirectedEdge* de = dirEdgeList[i];
+        de->setVisited(false);
+    }
 }
 
 /*public*/
 void
 BufferSubgraph::computeDepth(int outsideDepth)
 {
-	clearVisitedEdges();
-	// find an outside edge to assign depth to
-	DirectedEdge *de=finder.getEdge();
+    clearVisitedEdges();
+    // find an outside edge to assign depth to
+    DirectedEdge* de = finder.getEdge();
 #if GEOS_DEBUG
-cerr<<"outside depth: "<<outsideDepth<<endl;
+    cerr << "outside depth: " << outsideDepth << endl;
 #endif
-	//Node *n=de->getNode();
-	//Label *label=de->getLabel();
+    //Node *n=de->getNode();
+    //Label *label=de->getLabel();
 
-	// right side of line returned by finder is on the outside
-	de->setEdgeDepths(Position::RIGHT, outsideDepth);
-	copySymDepths(de);
+    // right side of line returned by finder is on the outside
+    de->setEdgeDepths(Position::RIGHT, outsideDepth);
+    copySymDepths(de);
 
-	//computeNodeDepth(n, de);
-	computeDepths(de);
+    //computeNodeDepth(n, de);
+    computeDepths(de);
 }
 
 void
-BufferSubgraph::computeNodeDepth(Node *n)
-	// throw(TopologyException *)
+BufferSubgraph::computeNodeDepth(Node* n)
+// throw(TopologyException *)
 {
-	// find a visited dirEdge to start at
-	DirectedEdge *startEdge=nullptr;
-
-	assert(dynamic_cast<DirectedEdgeStar *>(n->getEdges()));
-	DirectedEdgeStar *ees=static_cast<DirectedEdgeStar *>(n->getEdges());
-
-	EdgeEndStar::iterator endIt=ees->end();
-
-	EdgeEndStar::iterator it=ees->begin();
-	for(; it!=endIt; ++it)
-	{
-		assert(dynamic_cast<DirectedEdge*>(*it));
-		DirectedEdge *de=static_cast<DirectedEdge*>(*it);
-		if (de->isVisited() || de->getSym()->isVisited()) {
-			startEdge=de;
-			break;
-		}
-	}
-	// MD - testing  Result: breaks algorithm
-	//if (startEdge==null) return;
-
-	// only compute string append if assertion would fail
-	if (startEdge == nullptr)
-	{
-		throw util::TopologyException(
-			"unable to find edge to compute depths at",
-			n->getCoordinate());
-	}
-
-	ees->computeDepths(startEdge);
-
-	// copy depths to sym edges
-	for(it=ees->begin(); it!=endIt; ++it)
-	{
-		assert(dynamic_cast<DirectedEdge*>(*it));
-		DirectedEdge *de=static_cast<DirectedEdge*>(*it);
-		de->setVisited(true);
-		copySymDepths(de);
-	}
+    // find a visited dirEdge to start at
+    DirectedEdge* startEdge = nullptr;
+
+    assert(dynamic_cast<DirectedEdgeStar*>(n->getEdges()));
+    DirectedEdgeStar* ees = static_cast<DirectedEdgeStar*>(n->getEdges());
+
+    EdgeEndStar::iterator endIt = ees->end();
+
+    EdgeEndStar::iterator it = ees->begin();
+    for(; it != endIt; ++it) {
+        assert(dynamic_cast<DirectedEdge*>(*it));
+        DirectedEdge* de = static_cast<DirectedEdge*>(*it);
+        if(de->isVisited() || de->getSym()->isVisited()) {
+            startEdge = de;
+            break;
+        }
+    }
+    // MD - testing  Result: breaks algorithm
+    //if (startEdge==null) return;
+
+    // only compute string append if assertion would fail
+    if(startEdge == nullptr) {
+        throw util::TopologyException(
+            "unable to find edge to compute depths at",
+            n->getCoordinate());
+    }
+
+    ees->computeDepths(startEdge);
+
+    // copy depths to sym edges
+    for(it = ees->begin(); it != endIt; ++it) {
+        assert(dynamic_cast<DirectedEdge*>(*it));
+        DirectedEdge* de = static_cast<DirectedEdge*>(*it);
+        de->setVisited(true);
+        copySymDepths(de);
+    }
 }
 
 /*private*/
 void
-BufferSubgraph::copySymDepths(DirectedEdge *de)
+BufferSubgraph::copySymDepths(DirectedEdge* de)
 {
 #if GEOS_DEBUG
-	cerr << "copySymDepths: " << de->getDepth(Position::LEFT)
-	     << ", " << de->getDepth(Position::RIGHT)
-	     << endl;
+    cerr << "copySymDepths: " << de->getDepth(Position::LEFT)
+         << ", " << de->getDepth(Position::RIGHT)
+         << endl;
 #endif
-	DirectedEdge *sym=de->getSym();
-	sym->setDepth(Position::LEFT, de->getDepth(Position::RIGHT));
-	sym->setDepth(Position::RIGHT, de->getDepth(Position::LEFT));
+    DirectedEdge* sym = de->getSym();
+    sym->setDepth(Position::LEFT, de->getDepth(Position::RIGHT));
+    sym->setDepth(Position::RIGHT, de->getDepth(Position::LEFT));
 }
 
 /*public*/
@@ -214,143 +211,143 @@ void
 BufferSubgraph::findResultEdges()
 {
 #if GEOS_DEBUG
-	cerr<<"BufferSubgraph::findResultEdges got "<<dirEdgeList.size()<<" edges"<<endl;
+    cerr << "BufferSubgraph::findResultEdges got " << dirEdgeList.size() << " edges" << endl;
 #endif
-	for(size_t i=0, n=dirEdgeList.size(); i<n; ++i)
-	{
-		DirectedEdge *de=dirEdgeList[i];
-
-		/**
-		 * Select edges which have an interior depth on the RHS
-		 * and an exterior depth on the LHS.
-		 * Note that because of weird rounding effects there may be
-		 * edges which have negative depths!  Negative depths
-		 * count as "outside".
-		 */
-		// <FIX> - handle negative depths
+    for(size_t i = 0, n = dirEdgeList.size(); i < n; ++i) {
+        DirectedEdge* de = dirEdgeList[i];
+
+        /**
+         * Select edges which have an interior depth on the RHS
+         * and an exterior depth on the LHS.
+         * Note that because of weird rounding effects there may be
+         * edges which have negative depths!  Negative depths
+         * count as "outside".
+         */
+        // <FIX> - handle negative depths
 #if GEOS_DEBUG
-		cerr << " dirEdge "<<i<<": " << de->printEdge() << endl
-		     << "         depth right: " << de->getDepth(Position::RIGHT) << endl
-		     << "          depth left: " << de->getDepth(Position::LEFT) << endl
-		     << "    interiorAreaEdge: " << de->isInteriorAreaEdge()<<endl;
+        cerr << " dirEdge " << i << ": " << de->printEdge() << endl
+             << "         depth right: " << de->getDepth(Position::RIGHT) << endl
+             << "          depth left: " << de->getDepth(Position::LEFT) << endl
+             << "    interiorAreaEdge: " << de->isInteriorAreaEdge() << endl;
 #endif
-		if ( de->getDepth(Position::RIGHT)>=1
-			&&  de->getDepth(Position::LEFT)<=0
-			&& !de->isInteriorAreaEdge()) {
-					de->setInResult(true);
+        if(de->getDepth(Position::RIGHT) >= 1
+                &&  de->getDepth(Position::LEFT) <= 0
+                && !de->isInteriorAreaEdge()) {
+            de->setInResult(true);
 #if GEOS_DEBUG
-					cerr<<"   IN RESULT"<<endl;
+            cerr << "   IN RESULT" << endl;
 #endif
-		}
-	}
+        }
+    }
 }
 
 /*public*/
 int
-BufferSubgraph::compareTo(BufferSubgraph *graph)
+BufferSubgraph::compareTo(BufferSubgraph* graph)
 {
-	assert(rightMostCoord);
-	if (rightMostCoord->x<graph->rightMostCoord->x) {
-		return -1;
-	}
-	if (rightMostCoord->x>graph->rightMostCoord->x) {
-		return 1;
-	}
-	return 0;
+    assert(rightMostCoord);
+    if(rightMostCoord->x < graph->rightMostCoord->x) {
+        return -1;
+    }
+    if(rightMostCoord->x > graph->rightMostCoord->x) {
+        return 1;
+    }
+    return 0;
 }
 
 /*private*/
 void
-BufferSubgraph::computeDepths(DirectedEdge *startEdge)
+BufferSubgraph::computeDepths(DirectedEdge* startEdge)
 {
-	set<Node *> nodesVisited;
-	list<Node*> nodeQueue; // Used to be a vector
-	Node *startNode=startEdge->getNode();
-	nodeQueue.push_back(startNode);
-	//nodesVisited.push_back(startNode);
-	nodesVisited.insert(startNode);
-	startEdge->setVisited(true);
-
-	while (! nodeQueue.empty())
-	{
-		//System.out.println(nodes.size() + " queue: " + nodeQueue.size());
-		Node *n=nodeQueue.front(); // [0];
-		//nodeQueue.erase(nodeQueue.begin());
-		nodeQueue.pop_front();
-
-		nodesVisited.insert(n);
-
-		// compute depths around node, starting at this edge since it has depths assigned
-		computeNodeDepth(n);
-
-		// add all adjacent nodes to process queue,
-		// unless the node has been visited already
-		EdgeEndStar *ees=n->getEdges();
-		EdgeEndStar::iterator endIt=ees->end();
-		EdgeEndStar::iterator it=ees->begin();
-		for(; it!=endIt; ++it)
-		{
-			assert(dynamic_cast<DirectedEdge*>(*it));
-			DirectedEdge *de=static_cast<DirectedEdge*>(*it);
-			DirectedEdge *sym=de->getSym();
-			if (sym->isVisited()) continue;
-			Node *adjNode=sym->getNode();
-
-			//if (! contains(nodesVisited,adjNode))
-			if(nodesVisited.insert(adjNode).second)
-			{
-				nodeQueue.push_back(adjNode);
-				//nodesVisited.insert(adjNode);
-			}
-		}
-	}
+    set<Node*> nodesVisited;
+    list<Node*> nodeQueue; // Used to be a vector
+    Node* startNode = startEdge->getNode();
+    nodeQueue.push_back(startNode);
+    //nodesVisited.push_back(startNode);
+    nodesVisited.insert(startNode);
+    startEdge->setVisited(true);
+
+    while(! nodeQueue.empty()) {
+        //System.out.println(nodes.size() + " queue: " + nodeQueue.size());
+        Node* n = nodeQueue.front(); // [0];
+        //nodeQueue.erase(nodeQueue.begin());
+        nodeQueue.pop_front();
+
+        nodesVisited.insert(n);
+
+        // compute depths around node, starting at this edge since it has depths assigned
+        computeNodeDepth(n);
+
+        // add all adjacent nodes to process queue,
+        // unless the node has been visited already
+        EdgeEndStar* ees = n->getEdges();
+        EdgeEndStar::iterator endIt = ees->end();
+        EdgeEndStar::iterator it = ees->begin();
+        for(; it != endIt; ++it) {
+            assert(dynamic_cast<DirectedEdge*>(*it));
+            DirectedEdge* de = static_cast<DirectedEdge*>(*it);
+            DirectedEdge* sym = de->getSym();
+            if(sym->isVisited()) {
+                continue;
+            }
+            Node* adjNode = sym->getNode();
+
+            //if (! contains(nodesVisited,adjNode))
+            if(nodesVisited.insert(adjNode).second) {
+                nodeQueue.push_back(adjNode);
+                //nodesVisited.insert(adjNode);
+            }
+        }
+    }
 }
 
 /*private*/
 bool
-BufferSubgraph::contains(set<Node*>&nodeSet, Node *node)
+BufferSubgraph::contains(set<Node*>& nodeSet, Node* node)
 {
-	//bool result=false;
-	if ( nodeSet.find(node) != nodeSet.end() ) return true;
-	return false;
+    //bool result=false;
+    if(nodeSet.find(node) != nodeSet.end()) {
+        return true;
+    }
+    return false;
 }
 
 /*public*/
-Envelope *
+Envelope*
 BufferSubgraph::getEnvelope()
 {
-	if (env == nullptr) {
-		env = new Envelope();
-		std::size_t const size = dirEdgeList.size();
-		for(std::size_t i=0; i<size; ++i)
-		{
-			DirectedEdge *dirEdge=dirEdgeList[i];
-			const CoordinateSequence *pts = dirEdge->getEdge()->getCoordinates();
-			std::size_t const n = pts->getSize()-1;
-			for (std::size_t j=0; j<n; ++j) {
-				env->expandToInclude(pts->getAt(j));
-			}
-		}
-	}
-	return env;
+    if(env == nullptr) {
+        env = new Envelope();
+        std::size_t const size = dirEdgeList.size();
+        for(std::size_t i = 0; i < size; ++i) {
+            DirectedEdge* dirEdge = dirEdgeList[i];
+            const CoordinateSequence* pts = dirEdge->getEdge()->getCoordinates();
+            std::size_t const n = pts->getSize() - 1;
+            for(std::size_t j = 0; j < n; ++j) {
+                env->expandToInclude(pts->getAt(j));
+            }
+        }
+    }
+    return env;
 }
 
-std::ostream& operator<< (std::ostream& os, const BufferSubgraph& bs)
+std::ostream&
+operator<< (std::ostream& os, const BufferSubgraph& bs)
 {
-	os << "BufferSubgraph[" << &bs << "] "
-	   << bs.nodes.size() << " nodes, "
-	   << bs.dirEdgeList.size() << " directed edges" << std::endl;
+    os << "BufferSubgraph[" << &bs << "] "
+       << bs.nodes.size() << " nodes, "
+       << bs.dirEdgeList.size() << " directed edges" << std::endl;
 
-	for (size_t i=0, n=bs.nodes.size(); i<n; i++)
-		os << "  Node " << i << ": " << *(bs.nodes[i]) << std::endl;
+    for(size_t i = 0, n = bs.nodes.size(); i < n; i++) {
+        os << "  Node " << i << ": " << *(bs.nodes[i]) << std::endl;
+    }
 
-	for (size_t i=0, n=bs.dirEdgeList.size(); i<n; i++)
-	{
-		os << "  DirEdge " << i << ": " << std::endl
-		   << bs.dirEdgeList[i]->printEdge() << std::endl;
-	}
+    for(size_t i = 0, n = bs.dirEdgeList.size(); i < n; i++) {
+        os << "  DirEdge " << i << ": " << std::endl
+           << bs.dirEdgeList[i]->printEdge() << std::endl;
+    }
 
-	return os;
+    return os;
 }
 
 } // namespace geos.operation.buffer
diff --git a/src/operation/buffer/OffsetCurveBuilder.cpp b/src/operation/buffer/OffsetCurveBuilder.cpp
index 0bf5c35..e377417 100644
--- a/src/operation/buffer/OffsetCurveBuilder.cpp
+++ b/src/operation/buffer/OffsetCurveBuilder.cpp
@@ -55,31 +55,36 @@ const double OffsetCurveBuilder::SIMPLIFY_FACTOR = 100.0;
 
 /*public*/
 void
-OffsetCurveBuilder::getLineCurve(const CoordinateSequence *inputPts,
-		double nDistance, vector<CoordinateSequence*>& lineList)
+OffsetCurveBuilder::getLineCurve(const CoordinateSequence* inputPts,
+                                 double nDistance, vector<CoordinateSequence*>& lineList)
 {
-  distance = nDistance;
+    distance = nDistance;
 
-	// a zero or (non-singlesided) negative width buffer of a line/point is empty
-	if (distance == 0.0) return;
-  if (distance < 0.0 && ! bufParams.isSingleSided()) return;
+    // a zero or (non-singlesided) negative width buffer of a line/point is empty
+    if(distance == 0.0) {
+        return;
+    }
+    if(distance < 0.0 && ! bufParams.isSingleSided()) {
+        return;
+    }
 
-  double posDistance = std::abs(distance);
+    double posDistance = std::abs(distance);
 
-  std::unique_ptr<OffsetSegmentGenerator> segGen = getSegGen(posDistance);
-  if (inputPts->getSize() <= 1) {
-    computePointCurve(inputPts->getAt(0), *segGen);
-  } else {
-    if (bufParams.isSingleSided()) {
-      bool isRightSide = distance < 0.0;
-      computeSingleSidedBufferCurve(*inputPts, isRightSide, *segGen);
+    std::unique_ptr<OffsetSegmentGenerator> segGen = getSegGen(posDistance);
+    if(inputPts->getSize() <= 1) {
+        computePointCurve(inputPts->getAt(0), *segGen);
     }
     else {
-      computeLineBufferCurve(*inputPts, *segGen);
+        if(bufParams.isSingleSided()) {
+            bool isRightSide = distance < 0.0;
+            computeSingleSidedBufferCurve(*inputPts, isRightSide, *segGen);
+        }
+        else {
+            computeLineBufferCurve(*inputPts, *segGen);
+        }
     }
-  }
 
-  segGen->getCoordinates(lineList);
+    segGen->getCoordinates(lineList);
 }
 
 /* private */
@@ -87,173 +92,176 @@ void
 OffsetCurveBuilder::computePointCurve(const Coordinate& pt,
                                       OffsetSegmentGenerator& segGen)
 {
-  switch (bufParams.getEndCapStyle()) {
+    switch(bufParams.getEndCapStyle()) {
     case BufferParameters::CAP_ROUND:
-      segGen.createCircle(pt, distance);
-      break;
+        segGen.createCircle(pt, distance);
+        break;
     case BufferParameters::CAP_SQUARE:
-      segGen.createSquare(pt, distance);
-      break;
+        segGen.createSquare(pt, distance);
+        break;
     default:
-      // otherwise curve is empty (e.g. for a butt cap);
-      break;
-  }
+        // otherwise curve is empty (e.g. for a butt cap);
+        break;
+    }
 }
 
 /*public*/
 void
 OffsetCurveBuilder::getSingleSidedLineCurve(const CoordinateSequence* inputPts,
-   double p_distance, vector<CoordinateSequence*>& lineList, bool leftSide,
-   bool rightSide)
+        double p_distance, vector<CoordinateSequence*>& lineList, bool leftSide,
+        bool rightSide)
 {
-   // A zero or negative width buffer of a line/point is empty.
-   if ( p_distance <= 0.0 ) return ;
+    // A zero or negative width buffer of a line/point is empty.
+    if(p_distance <= 0.0) {
+        return ;
+    }
 
-   if ( inputPts->getSize() < 2 )
-   {
-      // No cap, so just return.
-      return ;
-   }
+    if(inputPts->getSize() < 2) {
+        // No cap, so just return.
+        return ;
+    }
 
-	double distTol = simplifyTolerance(p_distance);
+    double distTol = simplifyTolerance(p_distance);
 
-  std::unique_ptr<OffsetSegmentGenerator> segGen = getSegGen(p_distance);
+    std::unique_ptr<OffsetSegmentGenerator> segGen = getSegGen(p_distance);
 
-  if ( leftSide ) {
-	  //--------- compute points for left side of line
-    // Simplify the appropriate side of the line before generating
-    std::unique_ptr<CoordinateSequence> simp1_ =
-      BufferInputLineSimplifier::simplify( *inputPts, distTol );
-    const CoordinateSequence& simp1 = *simp1_;
+    if(leftSide) {
+        //--------- compute points for left side of line
+        // Simplify the appropriate side of the line before generating
+        std::unique_ptr<CoordinateSequence> simp1_ =
+            BufferInputLineSimplifier::simplify(*inputPts, distTol);
+        const CoordinateSequence& simp1 = *simp1_;
 
 
-    auto n1 = simp1.size() - 1;
-    if ( ! n1 )
-      throw util::IllegalArgumentException("Cannot get offset of single-vertex line");
-    segGen->initSideSegments(simp1[0], simp1[1], Position::LEFT);
-    segGen->addFirstSegment();
-    for (size_t i = 2; i <= n1; ++i) {
-      segGen->addNextSegment(simp1[i], true);
+        auto n1 = simp1.size() - 1;
+        if(! n1) {
+            throw util::IllegalArgumentException("Cannot get offset of single-vertex line");
+        }
+        segGen->initSideSegments(simp1[0], simp1[1], Position::LEFT);
+        segGen->addFirstSegment();
+        for(size_t i = 2; i <= n1; ++i) {
+            segGen->addNextSegment(simp1[i], true);
+        }
+        segGen->addLastSegment();
     }
-    segGen->addLastSegment();
-  }
-
-  if ( rightSide ) {
-
-    //---------- compute points for right side of line
-    // Simplify the appropriate side of the line before generating
-    std::unique_ptr<CoordinateSequence> simp2_ =
-      BufferInputLineSimplifier::simplify( *inputPts, -distTol );
-    const CoordinateSequence& simp2 = *simp2_;
 
-    auto n2 = simp2.size() - 1;
-    if ( ! n2 )
-      throw util::IllegalArgumentException("Cannot get offset of single-vertex line");
-    segGen->initSideSegments(simp2[n2], simp2[n2-1], Position::LEFT);
-    segGen->addFirstSegment();
-    for (size_t i = n2 - 1; i > 0; --i) {
-      segGen->addNextSegment(simp2[i - 1], true);
+    if(rightSide) {
+
+        //---------- compute points for right side of line
+        // Simplify the appropriate side of the line before generating
+        std::unique_ptr<CoordinateSequence> simp2_ =
+            BufferInputLineSimplifier::simplify(*inputPts, -distTol);
+        const CoordinateSequence& simp2 = *simp2_;
+
+        auto n2 = simp2.size() - 1;
+        if(! n2) {
+            throw util::IllegalArgumentException("Cannot get offset of single-vertex line");
+        }
+        segGen->initSideSegments(simp2[n2], simp2[n2 - 1], Position::LEFT);
+        segGen->addFirstSegment();
+        for(size_t i = n2 - 1; i > 0; --i) {
+            segGen->addNextSegment(simp2[i - 1], true);
+        }
+        segGen->addLastSegment();
     }
-    segGen->addLastSegment();
-  }
 
-  segGen->getCoordinates(lineList);
+    segGen->getCoordinates(lineList);
 }
 
 /*public*/
 void
-OffsetCurveBuilder::getRingCurve(const CoordinateSequence *inputPts,
-		int side, double nDistance,
-		vector<CoordinateSequence*>& lineList)
+OffsetCurveBuilder::getRingCurve(const CoordinateSequence* inputPts,
+                                 int side, double nDistance,
+                                 vector<CoordinateSequence*>& lineList)
 {
-  distance = nDistance;
-
-	// optimize creating ring for zero distance
-	if (distance == 0.0) {
-		lineList.push_back(inputPts->clone());
-		return;
-	}
-
-	if (inputPts->getSize() <= 2)
-	{
-		getLineCurve(inputPts, distance, lineList);
-		return;
-	}
-
-  std::unique_ptr<OffsetSegmentGenerator> segGen = getSegGen(std::abs(distance));
-	computeRingBufferCurve(*inputPts, side, *segGen);
-  segGen->getCoordinates(lineList);
+    distance = nDistance;
+
+    // optimize creating ring for zero distance
+    if(distance == 0.0) {
+        lineList.push_back(inputPts->clone());
+        return;
+    }
+
+    if(inputPts->getSize() <= 2) {
+        getLineCurve(inputPts, distance, lineList);
+        return;
+    }
+
+    std::unique_ptr<OffsetSegmentGenerator> segGen = getSegGen(std::abs(distance));
+    computeRingBufferCurve(*inputPts, side, *segGen);
+    segGen->getCoordinates(lineList);
 }
 
 /* private */
 double
 OffsetCurveBuilder::simplifyTolerance(double bufDistance)
 {
-	return bufDistance / SIMPLIFY_FACTOR;
+    return bufDistance / SIMPLIFY_FACTOR;
 }
 
 /*private*/
 void
 OffsetCurveBuilder::computeLineBufferCurve(const CoordinateSequence& inputPts,
-    OffsetSegmentGenerator& segGen)
+        OffsetSegmentGenerator& segGen)
 {
-	double distTol = simplifyTolerance(distance);
-
-	//--------- compute points for left side of line
-	// Simplify the appropriate side of the line before generating
-	std::unique_ptr<CoordinateSequence> simp1_ =
-		BufferInputLineSimplifier::simplify(inputPts, distTol);
-	const CoordinateSequence& simp1 = *simp1_;
-
-
-	auto n1 = simp1.size() - 1;
-	segGen.initSideSegments(simp1[0], simp1[1], Position::LEFT);
-	for (size_t i = 2; i <= n1; ++i) {
-		segGen.addNextSegment(simp1[i], true);
-	}
-	segGen.addLastSegment();
-	// add line cap for end of line
-	segGen.addLineEndCap(simp1[n1-1], simp1[n1]);
-
-	//---------- compute points for right side of line
-	// Simplify the appropriate side of the line before generating
-	std::unique_ptr<CoordinateSequence> simp2_ =
-		BufferInputLineSimplifier::simplify(inputPts, -distTol);
-	const CoordinateSequence& simp2 = *simp2_;
-
-	auto n2 = simp2.size() - 1;
-	segGen.initSideSegments(simp2[n2], simp2[n2-1], Position::LEFT);
-	for (size_t i = n2 - 1; i > 0; --i) {
-		segGen.addNextSegment(simp2[i - 1], true);
-	}
-	segGen.addLastSegment();
-	// add line cap for start of line
-	segGen.addLineEndCap(simp2[1], simp2[0]);
-
-	segGen.closeRing();
+    double distTol = simplifyTolerance(distance);
+
+    //--------- compute points for left side of line
+    // Simplify the appropriate side of the line before generating
+    std::unique_ptr<CoordinateSequence> simp1_ =
+        BufferInputLineSimplifier::simplify(inputPts, distTol);
+    const CoordinateSequence& simp1 = *simp1_;
+
+
+    auto n1 = simp1.size() - 1;
+    segGen.initSideSegments(simp1[0], simp1[1], Position::LEFT);
+    for(size_t i = 2; i <= n1; ++i) {
+        segGen.addNextSegment(simp1[i], true);
+    }
+    segGen.addLastSegment();
+    // add line cap for end of line
+    segGen.addLineEndCap(simp1[n1 - 1], simp1[n1]);
+
+    //---------- compute points for right side of line
+    // Simplify the appropriate side of the line before generating
+    std::unique_ptr<CoordinateSequence> simp2_ =
+        BufferInputLineSimplifier::simplify(inputPts, -distTol);
+    const CoordinateSequence& simp2 = *simp2_;
+
+    auto n2 = simp2.size() - 1;
+    segGen.initSideSegments(simp2[n2], simp2[n2 - 1], Position::LEFT);
+    for(size_t i = n2 - 1; i > 0; --i) {
+        segGen.addNextSegment(simp2[i - 1], true);
+    }
+    segGen.addLastSegment();
+    // add line cap for start of line
+    segGen.addLineEndCap(simp2[1], simp2[0]);
+
+    segGen.closeRing();
 }
 
 /*private*/
 void
 OffsetCurveBuilder::computeRingBufferCurve(const CoordinateSequence& inputPts,
-    int side, OffsetSegmentGenerator& segGen)
+        int side, OffsetSegmentGenerator& segGen)
 {
-  // simplify input line to improve performance
-  double distTol = simplifyTolerance(distance);
-	// ensure that correct side is simplified
-	if (side == Position::RIGHT)
-		distTol = -distTol;
-	std::unique_ptr<CoordinateSequence> simp_ =
-		BufferInputLineSimplifier::simplify(inputPts, distTol);
-	const CoordinateSequence& simp = *simp_;
-
-	auto n = simp.size() - 1;
-	segGen.initSideSegments(simp[n-1], simp[0], side);
-	for (size_t i = 1; i <= n; i++) {
-		bool addStartPoint = i != 1;
-		segGen.addNextSegment(simp[i], addStartPoint);
-	}
-	segGen.closeRing();
+    // simplify input line to improve performance
+    double distTol = simplifyTolerance(distance);
+    // ensure that correct side is simplified
+    if(side == Position::RIGHT) {
+        distTol = -distTol;
+    }
+    std::unique_ptr<CoordinateSequence> simp_ =
+        BufferInputLineSimplifier::simplify(inputPts, distTol);
+    const CoordinateSequence& simp = *simp_;
+
+    auto n = simp.size() - 1;
+    segGen.initSideSegments(simp[n - 1], simp[0], side);
+    for(size_t i = 1; i <= n; i++) {
+        bool addStartPoint = i != 1;
+        segGen.addNextSegment(simp[i], addStartPoint);
+    }
+    segGen.closeRing();
 }
 
 /*private*/
@@ -262,57 +270,58 @@ OffsetCurveBuilder::computeSingleSidedBufferCurve(
     const CoordinateSequence& inputPts, bool isRightSide,
     OffsetSegmentGenerator& segGen)
 {
-	double distTol = simplifyTolerance(distance);
+    double distTol = simplifyTolerance(distance);
 
-  if ( isRightSide ) {
+    if(isRightSide) {
 
-    // add original line
-    segGen.addSegments(inputPts, true);
+        // add original line
+        segGen.addSegments(inputPts, true);
 
-    //---------- compute points for right side of line
-    // Simplify the appropriate side of the line before generating
-    std::unique_ptr<CoordinateSequence> simp2_ =
-      BufferInputLineSimplifier::simplify(inputPts, -distTol);
-    const CoordinateSequence& simp2 = *simp2_;
+        //---------- compute points for right side of line
+        // Simplify the appropriate side of the line before generating
+        std::unique_ptr<CoordinateSequence> simp2_ =
+            BufferInputLineSimplifier::simplify(inputPts, -distTol);
+        const CoordinateSequence& simp2 = *simp2_;
+
+        auto n2 = simp2.size() - 1;
+        segGen.initSideSegments(simp2[n2], simp2[n2 - 1], Position::LEFT);
+        segGen.addFirstSegment();
+        for(size_t  i = n2 - 1; i > 0; --i) {
+            segGen.addNextSegment(simp2[i - 1], true);
+        }
 
-    auto n2 = simp2.size() - 1;
-    segGen.initSideSegments(simp2[n2], simp2[n2-1], Position::LEFT);
-    segGen.addFirstSegment();
-    for (size_t  i = n2 - 1; i > 0; --i) {
-      segGen.addNextSegment(simp2[i - 1], true);
     }
+    else {
 
-  } else {
+        // add original line
+        segGen.addSegments(inputPts, false);
 
-    // add original line
-    segGen.addSegments(inputPts, false);
+        //--------- compute points for left side of line
+        // Simplify the appropriate side of the line before generating
+        std::unique_ptr<CoordinateSequence> simp1_ =
+            BufferInputLineSimplifier::simplify(inputPts, distTol);
+        const CoordinateSequence& simp1 = *simp1_;
 
-    //--------- compute points for left side of line
-    // Simplify the appropriate side of the line before generating
-    std::unique_ptr<CoordinateSequence> simp1_ =
-      BufferInputLineSimplifier::simplify(inputPts, distTol);
-    const CoordinateSequence& simp1 = *simp1_;
+        auto n1 = simp1.size() - 1;
+        segGen.initSideSegments(simp1[0], simp1[1], Position::LEFT);
+        segGen.addFirstSegment();
+        for(size_t i = 2; i <= n1; ++i) {
+            segGen.addNextSegment(simp1[i], true);
+        }
 
-    auto n1 = simp1.size() - 1;
-    segGen.initSideSegments(simp1[0], simp1[1], Position::LEFT);
-    segGen.addFirstSegment();
-    for (size_t i = 2; i <= n1; ++i) {
-      segGen.addNextSegment(simp1[i], true);
     }
-
-  }
-	segGen.addLastSegment();
-	segGen.closeRing();
+    segGen.addLastSegment();
+    segGen.closeRing();
 }
 
 /*private*/
 std::unique_ptr<OffsetSegmentGenerator>
 OffsetCurveBuilder::getSegGen(double dist)
 {
-  std::unique_ptr<OffsetSegmentGenerator> osg(
-    new OffsetSegmentGenerator(precisionModel, bufParams, dist)
-  );
-  return osg;
+    std::unique_ptr<OffsetSegmentGenerator> osg(
+        new OffsetSegmentGenerator(precisionModel, bufParams, dist)
+    );
+    return osg;
 }
 
 } // namespace geos.operation.buffer
diff --git a/src/operation/buffer/OffsetCurveSetBuilder.cpp b/src/operation/buffer/OffsetCurveSetBuilder.cpp
index 47bf9a3..a32770a 100644
--- a/src/operation/buffer/OffsetCurveSetBuilder.cpp
+++ b/src/operation/buffer/OffsetCurveSetBuilder.cpp
@@ -61,72 +61,71 @@ namespace operation { // geos.operation
 namespace buffer { // geos.operation.buffer
 
 OffsetCurveSetBuilder::OffsetCurveSetBuilder(const Geometry& newInputGeom,
-		double newDistance, OffsetCurveBuilder& newCurveBuilder):
-	inputGeom(newInputGeom),
-	distance(newDistance),
-	curveBuilder(newCurveBuilder),
-	curveList()
+        double newDistance, OffsetCurveBuilder& newCurveBuilder):
+    inputGeom(newInputGeom),
+    distance(newDistance),
+    curveBuilder(newCurveBuilder),
+    curveList()
 {
 }
 
 OffsetCurveSetBuilder::~OffsetCurveSetBuilder()
 {
-	for (size_t i=0, n=curveList.size(); i<n; ++i)
-	{
-		SegmentString* ss = curveList[i];
-		delete ss;
-	}
-	for (size_t i=0, n=newLabels.size(); i<n; ++i)
-		delete newLabels[i];
+    for(size_t i = 0, n = curveList.size(); i < n; ++i) {
+        SegmentString* ss = curveList[i];
+        delete ss;
+    }
+    for(size_t i = 0, n = newLabels.size(); i < n; ++i) {
+        delete newLabels[i];
+    }
 }
 
 /* public */
 std::vector<SegmentString*>&
 OffsetCurveSetBuilder::getCurves()
 {
-	add(inputGeom);
-	return curveList;
+    add(inputGeom);
+    return curveList;
 }
 
 /*public*/
 void
 OffsetCurveSetBuilder::addCurves(const std::vector<CoordinateSequence*>& lineList,
-	int leftLoc, int rightLoc)
+                                 int leftLoc, int rightLoc)
 {
-	for (size_t i=0, n=lineList.size(); i<n; ++i)
-	{
-		CoordinateSequence *coords = lineList[i];
-		addCurve(coords, leftLoc, rightLoc);
-	}
+    for(size_t i = 0, n = lineList.size(); i < n; ++i) {
+        CoordinateSequence* coords = lineList[i];
+        addCurve(coords, leftLoc, rightLoc);
+    }
 }
 
 /*private*/
 void
-OffsetCurveSetBuilder::addCurve(CoordinateSequence *coord,
-	int leftLoc, int rightLoc)
+OffsetCurveSetBuilder::addCurve(CoordinateSequence* coord,
+                                int leftLoc, int rightLoc)
 {
 #if GEOS_DEBUG
-	std::cerr<<__FUNCTION__<<": coords="<<coord->toString()<<std::endl;
+    std::cerr << __FUNCTION__ << ": coords=" << coord->toString() << std::endl;
 #endif
-	// don't add null curves!
-	if (coord->getSize() < 2) {
+    // don't add null curves!
+    if(coord->getSize() < 2) {
 #if GEOS_DEBUG
-		std::cerr<<" skipped (size<2)"<<std::endl;
+        std::cerr << " skipped (size<2)" << std::endl;
 #endif
-		delete coord;
-		return;
-	}
+        delete coord;
+        return;
+    }
 
-	// add the edge for a coordinate list which is a raw offset curve
-	Label *newlabel = new Label(0, Location::BOUNDARY, leftLoc, rightLoc);
+    // add the edge for a coordinate list which is a raw offset curve
+    Label* newlabel = new Label(0, Location::BOUNDARY, leftLoc, rightLoc);
 
-	// coord ownership transferred to SegmentString
-	SegmentString *e=new NodedSegmentString(coord, newlabel);
+    // coord ownership transferred to SegmentString
+    SegmentString* e = new NodedSegmentString(coord, newlabel);
 
-	// SegmentString doesnt own the sequence, so we need to delete in
-	// the destructor
-	newLabels.push_back(newlabel);
-	curveList.push_back(e);
+    // SegmentString doesnt own the sequence, so we need to delete in
+    // the destructor
+    newLabels.push_back(newlabel);
+    curveList.push_back(e);
 }
 
 
@@ -134,248 +133,247 @@ OffsetCurveSetBuilder::addCurve(CoordinateSequence *coord,
 void
 OffsetCurveSetBuilder::add(const Geometry& g)
 {
-  if (g.isEmpty()) {
+    if(g.isEmpty()) {
 #if GEOS_DEBUG
-    std::cerr<<__FUNCTION__<<": skip empty geometry"<<std::endl;
+        std::cerr << __FUNCTION__ << ": skip empty geometry" << std::endl;
 #endif
-    return;
-  }
-
-	const Polygon *poly = dynamic_cast<const Polygon *>(&g);
-	if ( poly ) {
-		addPolygon(poly);
-		return;
-	}
-
-	const LineString *line = dynamic_cast<const LineString *>(&g);
-	if ( line ) {
-		addLineString(line);
-		return;
-	}
-
-	const Point *point = dynamic_cast<const Point *>(&g);
-	if ( point ) {
-		addPoint(point);
-		return;
-	}
-
-	const GeometryCollection *collection = dynamic_cast<const GeometryCollection *>(&g);
-	if ( collection ) {
-		addCollection(collection);
-		return;
-	}
-
-	std::string out=typeid(g).name();
-	throw util::UnsupportedOperationException("GeometryGraph::add(Geometry &): unknown geometry type: "+out);
+        return;
+    }
+
+    const Polygon* poly = dynamic_cast<const Polygon*>(&g);
+    if(poly) {
+        addPolygon(poly);
+        return;
+    }
+
+    const LineString* line = dynamic_cast<const LineString*>(&g);
+    if(line) {
+        addLineString(line);
+        return;
+    }
+
+    const Point* point = dynamic_cast<const Point*>(&g);
+    if(point) {
+        addPoint(point);
+        return;
+    }
+
+    const GeometryCollection* collection = dynamic_cast<const GeometryCollection*>(&g);
+    if(collection) {
+        addCollection(collection);
+        return;
+    }
+
+    std::string out = typeid(g).name();
+    throw util::UnsupportedOperationException("GeometryGraph::add(Geometry &): unknown geometry type: " + out);
 }
 
 /*private*/
 void
-OffsetCurveSetBuilder::addCollection(const GeometryCollection *gc)
+OffsetCurveSetBuilder::addCollection(const GeometryCollection* gc)
 {
-	for (size_t i = 0, n = gc->getNumGeometries(); i < n; i++) {
-		const Geometry *g=gc->getGeometryN(i);
-		add(*g);
-	}
+    for(size_t i = 0, n = gc->getNumGeometries(); i < n; i++) {
+        const Geometry* g = gc->getGeometryN(i);
+        add(*g);
+    }
 }
 
 /*private*/
 void
-OffsetCurveSetBuilder::addPoint(const Point *p)
+OffsetCurveSetBuilder::addPoint(const Point* p)
 {
-	if (distance <= 0.0) return;
-	const CoordinateSequence *coord=p->getCoordinatesRO();
-	std::vector<CoordinateSequence*> lineList;
-	curveBuilder.getLineCurve(coord, distance, lineList);
-
-	addCurves(lineList, Location::EXTERIOR, Location::INTERIOR);
-	//delete lineList;
+    if(distance <= 0.0) {
+        return;
+    }
+    const CoordinateSequence* coord = p->getCoordinatesRO();
+    std::vector<CoordinateSequence*> lineList;
+    curveBuilder.getLineCurve(coord, distance, lineList);
+
+    addCurves(lineList, Location::EXTERIOR, Location::INTERIOR);
+    //delete lineList;
 }
 
 /*private*/
 void
-OffsetCurveSetBuilder::addLineString(const LineString *line)
+OffsetCurveSetBuilder::addLineString(const LineString* line)
 {
-	if (distance <= 0.0 && ! curveBuilder.getBufferParameters().isSingleSided())
-	{
-		return;
-	}
+    if(distance <= 0.0 && ! curveBuilder.getBufferParameters().isSingleSided()) {
+        return;
+    }
 
 #if GEOS_DEBUG
-	std::cerr<<__FUNCTION__<<": "<<line->toString()<<std::endl;
+    std::cerr << __FUNCTION__ << ": " << line->toString() << std::endl;
 #endif
-	std::unique_ptr<CoordinateSequence> coord(CoordinateSequence::removeRepeatedPoints(line->getCoordinatesRO()));
+    std::unique_ptr<CoordinateSequence> coord(CoordinateSequence::removeRepeatedPoints(line->getCoordinatesRO()));
 #if GEOS_DEBUG
-	std::cerr<<" After coordinate removal: "<<coord->toString()<<std::endl;
+    std::cerr << " After coordinate removal: " << coord->toString() << std::endl;
 #endif
-	std::vector<CoordinateSequence*> lineList;
-	curveBuilder.getLineCurve(coord.get(), distance, lineList);
-	addCurves(lineList, Location::EXTERIOR, Location::INTERIOR);
+    std::vector<CoordinateSequence*> lineList;
+    curveBuilder.getLineCurve(coord.get(), distance, lineList);
+    addCurves(lineList, Location::EXTERIOR, Location::INTERIOR);
 }
 
 /*private*/
 void
-OffsetCurveSetBuilder::addPolygon(const Polygon *p)
+OffsetCurveSetBuilder::addPolygon(const Polygon* p)
 {
-	double offsetDistance=distance;
-
-	int offsetSide=Position::LEFT;
-	if (distance < 0.0)
-	{
-		offsetDistance = -distance;
-		offsetSide = Position::RIGHT;
-	}
-
-	// FIXME: avoid the C-style cast
-	const LinearRing *shell=(const LinearRing *)p->getExteriorRing();
-
-	// optimization - don't bother computing buffer
-	// if the polygon would be completely eroded
-	if (distance < 0.0 && isErodedCompletely(shell, distance))
-	{
+    double offsetDistance = distance;
+
+    int offsetSide = Position::LEFT;
+    if(distance < 0.0) {
+        offsetDistance = -distance;
+        offsetSide = Position::RIGHT;
+    }
+
+    // FIXME: avoid the C-style cast
+    const LinearRing* shell = (const LinearRing*)p->getExteriorRing();
+
+    // optimization - don't bother computing buffer
+    // if the polygon would be completely eroded
+    if(distance < 0.0 && isErodedCompletely(shell, distance)) {
 #if GEOS_DEBUG
-		std::cerr<<__FUNCTION__<<": polygon is eroded completely "<<std::endl;
+        std::cerr << __FUNCTION__ << ": polygon is eroded completely " << std::endl;
 #endif
-		return;
-	}
-
-	// don't attempt to buffer a polygon
-	// with too few distinct vertices
-	CoordinateSequence *shellCoord =
-		CoordinateSequence::removeRepeatedPoints(shell->getCoordinatesRO());
-	if (distance <= 0.0 && shellCoord->size() < 3)
-	{
-		delete shellCoord;
-		return;
-	}
-
-	addPolygonRing(
-		shellCoord,
-		offsetDistance,
-		offsetSide,
-		Location::EXTERIOR,
-		Location::INTERIOR);
-
-	delete shellCoord;
-
-	for (size_t i=0, n=p->getNumInteriorRing(); i<n; ++i)
-	{
-		const LineString *hls=p->getInteriorRingN(i);
-		assert(dynamic_cast<const LinearRing *>(hls));
-		const LinearRing *hole=static_cast<const LinearRing *>(hls);
-
-		// optimization - don't bother computing buffer for this hole
-		// if the hole would be completely covered
-		if (distance > 0.0 && isErodedCompletely(hole, -distance))
-		{
-			continue;
-		}
-
-		CoordinateSequence *holeCoord =
-			CoordinateSequence::removeRepeatedPoints(hole->getCoordinatesRO());
-
-		// Holes are topologically labelled opposite to the shell,
-		// since the interior of the polygon lies on their opposite
-		// side (on the left, if the hole is oriented CCW)
-		addPolygonRing(
-			holeCoord,
-			offsetDistance,
-			Position::opposite(offsetSide),
-			Location::INTERIOR,
-			Location::EXTERIOR);
-
-		delete holeCoord;
-	}
+        return;
+    }
+
+    // don't attempt to buffer a polygon
+    // with too few distinct vertices
+    CoordinateSequence* shellCoord =
+        CoordinateSequence::removeRepeatedPoints(shell->getCoordinatesRO());
+    if(distance <= 0.0 && shellCoord->size() < 3) {
+        delete shellCoord;
+        return;
+    }
+
+    addPolygonRing(
+        shellCoord,
+        offsetDistance,
+        offsetSide,
+        Location::EXTERIOR,
+        Location::INTERIOR);
+
+    delete shellCoord;
+
+    for(size_t i = 0, n = p->getNumInteriorRing(); i < n; ++i) {
+        const LineString* hls = p->getInteriorRingN(i);
+        assert(dynamic_cast<const LinearRing*>(hls));
+        const LinearRing* hole = static_cast<const LinearRing*>(hls);
+
+        // optimization - don't bother computing buffer for this hole
+        // if the hole would be completely covered
+        if(distance > 0.0 && isErodedCompletely(hole, -distance)) {
+            continue;
+        }
+
+        CoordinateSequence* holeCoord =
+            CoordinateSequence::removeRepeatedPoints(hole->getCoordinatesRO());
+
+        // Holes are topologically labelled opposite to the shell,
+        // since the interior of the polygon lies on their opposite
+        // side (on the left, if the hole is oriented CCW)
+        addPolygonRing(
+            holeCoord,
+            offsetDistance,
+            Position::opposite(offsetSide),
+            Location::INTERIOR,
+            Location::EXTERIOR);
+
+        delete holeCoord;
+    }
 }
 
 /* private */
 void
-OffsetCurveSetBuilder::addPolygonRing(const CoordinateSequence *coord,
-	double offsetDistance, int side, int cwLeftLoc, int cwRightLoc)
+OffsetCurveSetBuilder::addPolygonRing(const CoordinateSequence* coord,
+                                      double offsetDistance, int side, int cwLeftLoc, int cwRightLoc)
 {
 
-	// don't bother adding ring if it is "flat" and
-	// will disappear in the output
-	if (offsetDistance == 0.0 && coord->size() < LinearRing::MINIMUM_VALID_SIZE)
-		return;
+    // don't bother adding ring if it is "flat" and
+    // will disappear in the output
+    if(offsetDistance == 0.0 && coord->size() < LinearRing::MINIMUM_VALID_SIZE) {
+        return;
+    }
 
-	int leftLoc=cwLeftLoc;
-	int rightLoc=cwRightLoc;
+    int leftLoc = cwLeftLoc;
+    int rightLoc = cwRightLoc;
 #if GEOS_DEBUG
-	std::cerr<<"OffsetCurveSetBuilder::addPolygonRing: CCW: "<<Orientation::isCCW(coord)<<std::endl;
+    std::cerr << "OffsetCurveSetBuilder::addPolygonRing: CCW: " << Orientation::isCCW(coord) << std::endl;
 #endif
-	if (coord->size() >= LinearRing::MINIMUM_VALID_SIZE
-			&& Orientation::isCCW(coord))
-	{
-		leftLoc=cwRightLoc;
-		rightLoc=cwLeftLoc;
+    if(coord->size() >= LinearRing::MINIMUM_VALID_SIZE
+            && Orientation::isCCW(coord)) {
+        leftLoc = cwRightLoc;
+        rightLoc = cwLeftLoc;
 #if GEOS_DEBUG
-	std::cerr<<" side "<<side<<" becomes "<<Position::opposite(side)<<std::endl;
+        std::cerr << " side " << side << " becomes " << Position::opposite(side) << std::endl;
 #endif
-		side=Position::opposite(side);
-	}
-	std::vector<CoordinateSequence*> lineList;
-	curveBuilder.getRingCurve(coord, side, offsetDistance, lineList);
-	addCurves(lineList, leftLoc, rightLoc);
+        side = Position::opposite(side);
+    }
+    std::vector<CoordinateSequence*> lineList;
+    curveBuilder.getRingCurve(coord, side, offsetDistance, lineList);
+    addCurves(lineList, leftLoc, rightLoc);
 }
 
 /*private*/
 bool
-OffsetCurveSetBuilder::isErodedCompletely(const LinearRing *ring,
-	double bufferDistance)
+OffsetCurveSetBuilder::isErodedCompletely(const LinearRing* ring,
+        double bufferDistance)
 {
-	const CoordinateSequence *ringCoord = ring->getCoordinatesRO();
-
-	// degenerate ring has no area
-	if (ringCoord->getSize() < 4)
-		return bufferDistance < 0;
-
-	// important test to eliminate inverted triangle bug
-	// also optimizes erosion test for triangles
-	if (ringCoord->getSize() == 4)
-		return isTriangleErodedCompletely(ringCoord, bufferDistance);
-
-  const Envelope* env = ring->getEnvelopeInternal();
-  double envMinDimension = std::min(env->getHeight(), env->getWidth());
-  if (bufferDistance < 0.0 && 2 * std::abs(bufferDistance) > envMinDimension)
-      return true;
-
-	/**
-	 * The following is a heuristic test to determine whether an
-	 * inside buffer will be eroded completely->
-	 * It is based on the fact that the minimum diameter of the ring
-	 * pointset
-	 * provides an upper bound on the buffer distance which would erode the
-	 * ring->
-	 * If the buffer distance is less than the minimum diameter, the ring
-	 * may still be eroded, but this will be determined by
-	 * a full topological computation->
-	 *
-	 */
-
-/* MD  7 Feb 2005 - there's an unknown bug in the MD code,
- so disable this for now */
+    const CoordinateSequence* ringCoord = ring->getCoordinatesRO();
+
+    // degenerate ring has no area
+    if(ringCoord->getSize() < 4) {
+        return bufferDistance < 0;
+    }
+
+    // important test to eliminate inverted triangle bug
+    // also optimizes erosion test for triangles
+    if(ringCoord->getSize() == 4) {
+        return isTriangleErodedCompletely(ringCoord, bufferDistance);
+    }
+
+    const Envelope* env = ring->getEnvelopeInternal();
+    double envMinDimension = std::min(env->getHeight(), env->getWidth());
+    if(bufferDistance < 0.0 && 2 * std::abs(bufferDistance) > envMinDimension) {
+        return true;
+    }
+
+    /**
+     * The following is a heuristic test to determine whether an
+     * inside buffer will be eroded completely->
+     * It is based on the fact that the minimum diameter of the ring
+     * pointset
+     * provides an upper bound on the buffer distance which would erode the
+     * ring->
+     * If the buffer distance is less than the minimum diameter, the ring
+     * may still be eroded, but this will be determined by
+     * a full topological computation->
+     *
+     */
+
+    /* MD  7 Feb 2005 - there's an unknown bug in the MD code,
+     so disable this for now */
 #if 0
-	MinimumDiameter md(ring); //=new MinimumDiameter(ring);
-	double minDiam = md.getLength();
-	return minDiam < (2 * std::fabs(bufferDistance));
+    MinimumDiameter md(ring); //=new MinimumDiameter(ring);
+    double minDiam = md.getLength();
+    return minDiam < (2 * std::fabs(bufferDistance));
 #endif
 
-  return false;
+    return false;
 }
 
 /*private*/
 bool
 OffsetCurveSetBuilder::isTriangleErodedCompletely(
-	const CoordinateSequence *triangleCoord, double bufferDistance)
+    const CoordinateSequence* triangleCoord, double bufferDistance)
 {
-	Triangle tri(triangleCoord->getAt(0), triangleCoord->getAt(1), triangleCoord->getAt(2));
+    Triangle tri(triangleCoord->getAt(0), triangleCoord->getAt(1), triangleCoord->getAt(2));
 
-	Coordinate inCentre;
-	tri.inCentre(inCentre);
-	double distToCentre = Distance::pointToSegment(inCentre, tri.p0, tri.p1);
-	bool ret = distToCentre < std::fabs(bufferDistance);
-	return ret;
+    Coordinate inCentre;
+    tri.inCentre(inCentre);
+    double distToCentre = Distance::pointToSegment(inCentre, tri.p0, tri.p1);
+    bool ret = distToCentre < std::fabs(bufferDistance);
+    return ret;
 }
 
 
diff --git a/src/operation/buffer/OffsetSegmentGenerator.cpp b/src/operation/buffer/OffsetSegmentGenerator.cpp
index cad67d7..6c392ae 100644
--- a/src/operation/buffer/OffsetSegmentGenerator.cpp
+++ b/src/operation/buffer/OffsetSegmentGenerator.cpp
@@ -58,7 +58,7 @@ const double OffsetSegmentGenerator::SIMPLIFY_FACTOR = 100.0;
 
 /*public*/
 OffsetSegmentGenerator::OffsetSegmentGenerator(
-    const PrecisionModel *newPrecisionModel,
+    const PrecisionModel* newPrecisionModel,
     const BufferParameters& nBufParams,
     double dist)
     :
@@ -80,320 +80,321 @@ OffsetSegmentGenerator::OffsetSegmentGenerator(
     _hasNarrowConcaveAngle(false),
     endCapIndex(0)
 {
-  // compute intersections in full precision, to provide accuracy
-  // the points are rounded as they are inserted into the curve line
-  filletAngleQuantum = PI / 2.0 / bufParams.getQuadrantSegments();
-
-  /**
-   * Non-round joins cause issues with short closing segments,
-   * so don't use them.  In any case, non-round joins
-   * only really make sense for relatively small buffer distances.
-   */
-  if (bufParams.getQuadrantSegments() >= 8
-       && bufParams.getJoinStyle() == BufferParameters::JOIN_ROUND)
-  {
-    closingSegLengthFactor = MAX_CLOSING_SEG_LEN_FACTOR;
-  }
-
-  init(distance);
+    // compute intersections in full precision, to provide accuracy
+    // the points are rounded as they are inserted into the curve line
+    filletAngleQuantum = PI / 2.0 / bufParams.getQuadrantSegments();
+
+    /**
+     * Non-round joins cause issues with short closing segments,
+     * so don't use them.  In any case, non-round joins
+     * only really make sense for relatively small buffer distances.
+     */
+    if(bufParams.getQuadrantSegments() >= 8
+            && bufParams.getJoinStyle() == BufferParameters::JOIN_ROUND) {
+        closingSegLengthFactor = MAX_CLOSING_SEG_LEN_FACTOR;
+    }
+
+    init(distance);
 }
 
 /*private*/
 void
 OffsetSegmentGenerator::init(double newDistance)
 {
-  distance = newDistance;
-  maxCurveSegmentError = distance * (1 - cos(filletAngleQuantum/2.0));
-
-  // Point list needs to be reset
-  segList.reset();
-  segList.setPrecisionModel(precisionModel);
-
-  /**
-   * Choose the min vertex separation as a small fraction of
-   * the offset distance.
-   */
-  segList.setMinimumVertexDistance(
-    distance * CURVE_VERTEX_SNAP_DISTANCE_FACTOR);
+    distance = newDistance;
+    maxCurveSegmentError = distance * (1 - cos(filletAngleQuantum / 2.0));
+
+    // Point list needs to be reset
+    segList.reset();
+    segList.setPrecisionModel(precisionModel);
+
+    /**
+     * Choose the min vertex separation as a small fraction of
+     * the offset distance.
+     */
+    segList.setMinimumVertexDistance(
+        distance * CURVE_VERTEX_SNAP_DISTANCE_FACTOR);
 }
 
 /*public*/
 void
-OffsetSegmentGenerator::initSideSegments(const Coordinate &nS1,
-    const Coordinate &nS2, int nSide)
+OffsetSegmentGenerator::initSideSegments(const Coordinate& nS1,
+        const Coordinate& nS2, int nSide)
 {
-  s1 = nS1;
-  s2 = nS2;
-  side = nSide;
-  seg1.setCoordinates(s1, s2);
-  computeOffsetSegment(seg1, side, distance, offset1);
+    s1 = nS1;
+    s2 = nS2;
+    side = nSide;
+    seg1.setCoordinates(s1, s2);
+    computeOffsetSegment(seg1, side, distance, offset1);
 }
 
 /*public*/
 void
-OffsetSegmentGenerator::addNextSegment(const Coordinate &p, bool addStartPoint)
+OffsetSegmentGenerator::addNextSegment(const Coordinate& p, bool addStartPoint)
 {
 
-  // do nothing if points are equal
-  if (s2==p) return;
-
-  // s0-s1-s2 are the coordinates of the previous segment
-  // and the current one
-  s0=s1;
-  s1=s2;
-  s2=p;
-  seg0.setCoordinates(s0, s1);
-  computeOffsetSegment(seg0, side, distance, offset0);
-  seg1.setCoordinates(s1, s2);
-  computeOffsetSegment(seg1, side, distance, offset1);
-
-  int orientation=Orientation::index(s0, s1, s2);
-  bool outsideTurn =
-    (orientation==Orientation::CLOCKWISE
-     && side==Position::LEFT)
-    ||
-    (orientation==Orientation::COUNTERCLOCKWISE
-     && side==Position::RIGHT);
-
-  if (orientation==0)
-  {
-    // lines are collinear
-    addCollinear(addStartPoint);
-  }
-  else if (outsideTurn)
-  {
-    addOutsideTurn(orientation, addStartPoint);
-  }
-  else
-  {
-    // inside turn
-    addInsideTurn(orientation, addStartPoint);
-  }
+    // do nothing if points are equal
+    if(s2 == p) {
+        return;
+    }
+
+    // s0-s1-s2 are the coordinates of the previous segment
+    // and the current one
+    s0 = s1;
+    s1 = s2;
+    s2 = p;
+    seg0.setCoordinates(s0, s1);
+    computeOffsetSegment(seg0, side, distance, offset0);
+    seg1.setCoordinates(s1, s2);
+    computeOffsetSegment(seg1, side, distance, offset1);
+
+    int orientation = Orientation::index(s0, s1, s2);
+    bool outsideTurn =
+        (orientation == Orientation::CLOCKWISE
+         && side == Position::LEFT)
+        ||
+        (orientation == Orientation::COUNTERCLOCKWISE
+         && side == Position::RIGHT);
+
+    if(orientation == 0) {
+        // lines are collinear
+        addCollinear(addStartPoint);
+    }
+    else if(outsideTurn) {
+        addOutsideTurn(orientation, addStartPoint);
+    }
+    else {
+        // inside turn
+        addInsideTurn(orientation, addStartPoint);
+    }
 }
 
 /*private*/
 void
 OffsetSegmentGenerator::computeOffsetSegment(const LineSegment& seg, int p_side,
-  double p_distance, LineSegment& offset)
+        double p_distance, LineSegment& offset)
 {
-  int sideSign = p_side == Position::LEFT ? 1 : -1;
-  double dx = seg.p1.x - seg.p0.x;
-  double dy = seg.p1.y - seg.p0.y;
-  double len = sqrt(dx * dx + dy * dy);
-  // u is the vector that is the length of the offset,
-  // in the direction of the segment
-  double ux = sideSign * p_distance * dx / len;
-  double uy = sideSign * p_distance * dy / len;
-  offset.p0.x = seg.p0.x - uy;
-  offset.p0.y = seg.p0.y + ux;
-  offset.p1.x = seg.p1.x - uy;
-  offset.p1.y = seg.p1.y + ux;
+    int sideSign = p_side == Position::LEFT ? 1 : -1;
+    double dx = seg.p1.x - seg.p0.x;
+    double dy = seg.p1.y - seg.p0.y;
+    double len = sqrt(dx * dx + dy * dy);
+    // u is the vector that is the length of the offset,
+    // in the direction of the segment
+    double ux = sideSign * p_distance * dx / len;
+    double uy = sideSign * p_distance * dy / len;
+    offset.p0.x = seg.p0.x - uy;
+    offset.p0.y = seg.p0.y + ux;
+    offset.p1.x = seg.p1.x - uy;
+    offset.p1.y = seg.p1.y + ux;
 }
 
 /*public*/
 void
-OffsetSegmentGenerator::addLineEndCap(const Coordinate &p0, const Coordinate &p1)
+OffsetSegmentGenerator::addLineEndCap(const Coordinate& p0, const Coordinate& p1)
 {
-  LineSegment seg(p0, p1);
+    LineSegment seg(p0, p1);
 
-  LineSegment offsetL;
-  computeOffsetSegment(seg, Position::LEFT, distance, offsetL);
-  LineSegment offsetR;
-  computeOffsetSegment(seg, Position::RIGHT, distance, offsetR);
+    LineSegment offsetL;
+    computeOffsetSegment(seg, Position::LEFT, distance, offsetL);
+    LineSegment offsetR;
+    computeOffsetSegment(seg, Position::RIGHT, distance, offsetR);
 
-  double dx=p1.x-p0.x;
-  double dy=p1.y-p0.y;
-  double angle=atan2(dy, dx);
+    double dx = p1.x - p0.x;
+    double dy = p1.y - p0.y;
+    double angle = atan2(dy, dx);
 
-  switch (bufParams.getEndCapStyle()) {
+    switch(bufParams.getEndCapStyle()) {
     case BufferParameters::CAP_ROUND:
-      // add offset seg points with a fillet between them
-      segList.addPt(offsetL.p1);
-      addFillet(p1, angle+PI/2.0, angle-PI/2.0,
-                Orientation::CLOCKWISE, distance);
-      segList.addPt(offsetR.p1);
-      break;
+        // add offset seg points with a fillet between them
+        segList.addPt(offsetL.p1);
+        addFillet(p1, angle + PI / 2.0, angle - PI / 2.0,
+                  Orientation::CLOCKWISE, distance);
+        segList.addPt(offsetR.p1);
+        break;
     case BufferParameters::CAP_FLAT:
-      // only offset segment points are added
-      segList.addPt(offsetL.p1);
-      segList.addPt(offsetR.p1);
-      break;
+        // only offset segment points are added
+        segList.addPt(offsetL.p1);
+        segList.addPt(offsetR.p1);
+        break;
     case BufferParameters::CAP_SQUARE:
-      // add a square defined by extensions of the offset
-      // segment endpoints
-      Coordinate squareCapSideOffset;
-      squareCapSideOffset.x=fabs(distance)*cos(angle);
-      squareCapSideOffset.y=fabs(distance)*sin(angle);
-
-      Coordinate squareCapLOffset(
-        offsetL.p1.x+squareCapSideOffset.x,
-        offsetL.p1.y+squareCapSideOffset.y);
-      Coordinate squareCapROffset(
-        offsetR.p1.x+squareCapSideOffset.x,
-        offsetR.p1.y+squareCapSideOffset.y);
-      segList.addPt(squareCapLOffset);
-      segList.addPt(squareCapROffset);
-      break;
-  }
+        // add a square defined by extensions of the offset
+        // segment endpoints
+        Coordinate squareCapSideOffset;
+        squareCapSideOffset.x = fabs(distance) * cos(angle);
+        squareCapSideOffset.y = fabs(distance) * sin(angle);
+
+        Coordinate squareCapLOffset(
+            offsetL.p1.x + squareCapSideOffset.x,
+            offsetL.p1.y + squareCapSideOffset.y);
+        Coordinate squareCapROffset(
+            offsetR.p1.x + squareCapSideOffset.x,
+            offsetR.p1.y + squareCapSideOffset.y);
+        segList.addPt(squareCapLOffset);
+        segList.addPt(squareCapROffset);
+        break;
+    }
 }
 
 /*private*/
 void
-OffsetSegmentGenerator::addFillet(const Coordinate &p, const Coordinate &p0,
-  const Coordinate &p1, int direction, double radius)
+OffsetSegmentGenerator::addFillet(const Coordinate& p, const Coordinate& p0,
+                                  const Coordinate& p1, int direction, double radius)
 {
-  double dx0 = p0.x - p.x;
-  double dy0 = p0.y - p.y;
-  double startAngle = atan2(dy0, dx0);
-  double dx1 = p1.x - p.x;
-  double dy1 = p1.y - p.y;
-  double endAngle = atan2(dy1, dx1);
-
-  if (direction == Orientation::CLOCKWISE) {
-    if (startAngle <= endAngle) startAngle += 2.0 * PI;
-  }
-  else {    // direction==COUNTERCLOCKWISE
-    if (startAngle >= endAngle) startAngle -= 2.0 * PI;
-  }
-
-  segList.addPt(p0);
-  addFillet(p, startAngle, endAngle, direction, radius);
-  segList.addPt(p1);
+    double dx0 = p0.x - p.x;
+    double dy0 = p0.y - p.y;
+    double startAngle = atan2(dy0, dx0);
+    double dx1 = p1.x - p.x;
+    double dy1 = p1.y - p.y;
+    double endAngle = atan2(dy1, dx1);
+
+    if(direction == Orientation::CLOCKWISE) {
+        if(startAngle <= endAngle) {
+            startAngle += 2.0 * PI;
+        }
+    }
+    else {    // direction==COUNTERCLOCKWISE
+        if(startAngle >= endAngle) {
+            startAngle -= 2.0 * PI;
+        }
+    }
+
+    segList.addPt(p0);
+    addFillet(p, startAngle, endAngle, direction, radius);
+    segList.addPt(p1);
 }
 
 /*private*/
 void
-OffsetSegmentGenerator::addFillet(const Coordinate &p, double startAngle,
-  double endAngle, int direction, double radius)
+OffsetSegmentGenerator::addFillet(const Coordinate& p, double startAngle,
+                                  double endAngle, int direction, double radius)
 {
-  int directionFactor = direction == Orientation::CLOCKWISE ? -1 : 1;
+    int directionFactor = direction == Orientation::CLOCKWISE ? -1 : 1;
 
-  double totalAngle = fabs(startAngle - endAngle);
-  int nSegs = (int) (totalAngle / filletAngleQuantum + 0.5);
+    double totalAngle = fabs(startAngle - endAngle);
+    int nSegs = (int)(totalAngle / filletAngleQuantum + 0.5);
 
-  // no segments because angle is less than increment-nothing to do!
-  if (nSegs<1) return;
+    // no segments because angle is less than increment-nothing to do!
+    if(nSegs < 1) {
+        return;
+    }
 
-  double initAngle, currAngleInc;
+    double initAngle, currAngleInc;
 
-  // choose angle increment so that each segment has equal length
-  initAngle = 0.0;
-  currAngleInc = totalAngle / nSegs;
+    // choose angle increment so that each segment has equal length
+    initAngle = 0.0;
+    currAngleInc = totalAngle / nSegs;
 
-  double currAngle = initAngle;
-  Coordinate pt;
-  while (currAngle < totalAngle) {
-    double angle = startAngle + directionFactor * currAngle;
-    pt.x = p.x + radius * cos(angle);
-    pt.y = p.y + radius * sin(angle);
-    segList.addPt(pt);
-    currAngle += currAngleInc;
-  }
+    double currAngle = initAngle;
+    Coordinate pt;
+    while(currAngle < totalAngle) {
+        double angle = startAngle + directionFactor * currAngle;
+        pt.x = p.x + radius * cos(angle);
+        pt.y = p.y + radius * sin(angle);
+        segList.addPt(pt);
+        currAngle += currAngleInc;
+    }
 }
 
 
 /*private*/
 void
-OffsetSegmentGenerator::createCircle(const Coordinate &p, double p_distance)
+OffsetSegmentGenerator::createCircle(const Coordinate& p, double p_distance)
 {
-  // add start point
-  Coordinate pt(p.x + p_distance, p.y);
-  segList.addPt(pt);
-  addFillet(p, 0.0, 2.0*PI, -1, p_distance);
-  segList.closeRing();
+    // add start point
+    Coordinate pt(p.x + p_distance, p.y);
+    segList.addPt(pt);
+    addFillet(p, 0.0, 2.0 * PI, -1, p_distance);
+    segList.closeRing();
 }
 
 /*private*/
 void
-OffsetSegmentGenerator::createSquare(const Coordinate &p, double p_distance)
+OffsetSegmentGenerator::createSquare(const Coordinate& p, double p_distance)
 {
-  segList.addPt(Coordinate(p.x+p_distance, p.y+p_distance));
-  segList.addPt(Coordinate(p.x+p_distance, p.y-p_distance));
-  segList.addPt(Coordinate(p.x-p_distance, p.y-p_distance));
-  segList.addPt(Coordinate(p.x-p_distance, p.y+p_distance));
-  segList.closeRing();
+    segList.addPt(Coordinate(p.x + p_distance, p.y + p_distance));
+    segList.addPt(Coordinate(p.x + p_distance, p.y - p_distance));
+    segList.addPt(Coordinate(p.x - p_distance, p.y - p_distance));
+    segList.addPt(Coordinate(p.x - p_distance, p.y + p_distance));
+    segList.closeRing();
 }
 
 /* private */
 void
 OffsetSegmentGenerator::addCollinear(bool addStartPoint)
 {
-  /**
-   * This test could probably be done more efficiently,
-   * but the situation of exact collinearity should be fairly rare.
-   */
-
-  li.computeIntersection(s0,s1,s1,s2);
-  auto numInt = li.getIntersectionNum();
-
-  /**
-   * if numInt is<2, the lines are parallel and in the same direction.
-   * In this case the point can be ignored, since the offset lines
-   * will also be parallel.
-   */
-  if (numInt>= 2)
-  {
     /**
-     * Segments are collinear but reversing.
-     * Add an "end-cap" fillet
-     * all the way around to other direction
-     *
-     * This case should ONLY happen for LineStrings,
-     * so the orientation is always CW (Polygons can never
-     * have two consecutive segments which are parallel but
-     * reversed, because that would be a self intersection).
+     * This test could probably be done more efficiently,
+     * but the situation of exact collinearity should be fairly rare.
      */
-    if (  bufParams.getJoinStyle() == BufferParameters::JOIN_BEVEL
-       || bufParams.getJoinStyle() == BufferParameters::JOIN_MITRE)
-    {
-      if (addStartPoint) segList.addPt(offset0.p1);
-      segList.addPt(offset1.p0);
-    }
-    else
-    {
-      addFillet(s1, offset0.p1, offset1.p0,
-          Orientation::CLOCKWISE, distance);
+
+    li.computeIntersection(s0, s1, s1, s2);
+    auto numInt = li.getIntersectionNum();
+
+    /**
+     * if numInt is<2, the lines are parallel and in the same direction.
+     * In this case the point can be ignored, since the offset lines
+     * will also be parallel.
+     */
+    if(numInt >= 2) {
+        /**
+         * Segments are collinear but reversing.
+         * Add an "end-cap" fillet
+         * all the way around to other direction
+         *
+         * This case should ONLY happen for LineStrings,
+         * so the orientation is always CW (Polygons can never
+         * have two consecutive segments which are parallel but
+         * reversed, because that would be a self intersection).
+         */
+        if(bufParams.getJoinStyle() == BufferParameters::JOIN_BEVEL
+                || bufParams.getJoinStyle() == BufferParameters::JOIN_MITRE) {
+            if(addStartPoint) {
+                segList.addPt(offset0.p1);
+            }
+            segList.addPt(offset1.p0);
+        }
+        else {
+            addFillet(s1, offset0.p1, offset1.p0,
+                      Orientation::CLOCKWISE, distance);
+        }
     }
-  }
 }
 
 /* private */
 void
 OffsetSegmentGenerator::addOutsideTurn(int orientation, bool addStartPoint)
 {
-  /**
-   * Heuristic: If offset endpoints are very close together,
-   * just use one of them as the corner vertex.
-   * This avoids problems with computing mitre corners in the case
-   * where the two segments are almost parallel
-   * (which is hard to compute a robust intersection for).
-   */
-
-  if (offset0.p1.distance(offset1.p0) <
-    distance*OFFSET_SEGMENT_SEPARATION_FACTOR)
-  {
-    segList.addPt(offset0.p1);
-    return;
-  }
-
-  if (bufParams.getJoinStyle() == BufferParameters::JOIN_MITRE)
-  {
-    addMitreJoin(s1, offset0, offset1, distance);
-  }
-  else if (bufParams.getJoinStyle() == BufferParameters::JOIN_BEVEL)
-  {
-    addBevelJoin(offset0, offset1);
-  }
-  else
-  {
-    // add a circular fillet connecting the endpoints
-    // of the offset segments
-    if (addStartPoint) segList.addPt(offset0.p1);
-
-    // TESTING - comment out to produce beveled joins
-    addFillet(s1, offset0.p1, offset1.p0, orientation, distance);
-    segList.addPt(offset1.p0);
-  }
+    /**
+     * Heuristic: If offset endpoints are very close together,
+     * just use one of them as the corner vertex.
+     * This avoids problems with computing mitre corners in the case
+     * where the two segments are almost parallel
+     * (which is hard to compute a robust intersection for).
+     */
+
+    if(offset0.p1.distance(offset1.p0) <
+            distance * OFFSET_SEGMENT_SEPARATION_FACTOR) {
+        segList.addPt(offset0.p1);
+        return;
+    }
+
+    if(bufParams.getJoinStyle() == BufferParameters::JOIN_MITRE) {
+        addMitreJoin(s1, offset0, offset1, distance);
+    }
+    else if(bufParams.getJoinStyle() == BufferParameters::JOIN_BEVEL) {
+        addBevelJoin(offset0, offset1);
+    }
+    else {
+        // add a circular fillet connecting the endpoints
+        // of the offset segments
+        if(addStartPoint) {
+            segList.addPt(offset0.p1);
+        }
+
+        // TESTING - comment out to produce beveled joins
+        addFillet(s1, offset0.p1, offset1.p0, orientation, distance);
+        segList.addPt(offset1.p0);
+    }
 }
 
 /* private */
@@ -403,126 +404,118 @@ OffsetSegmentGenerator::addInsideTurn(int orientation, bool addStartPoint)
     ::geos::ignore_unused_variable_warning(orientation);
     ::geos::ignore_unused_variable_warning(addStartPoint);
 
-  // add intersection point of offset segments (if any)
-  li.computeIntersection(offset0.p0, offset0.p1, offset1.p0, offset1.p1);
-  if (li.hasIntersection())
-  {
-    segList.addPt(li.getIntersection(0));
-    return;
-  }
-
-  // If no intersection is detected, it means the angle is so small
-  // and/or the offset so large that the offsets segments don't
-  // intersect. In this case we must add a "closing segment" to make
-  // sure the buffer curve is continuous,
-  // fairly smooth (e.g. no sharp reversals in direction)
-  // and tracks the buffer correctly around the corner.
-  // The curve connects the endpoints of the segment offsets to points
-  // which lie toward the centre point of the corner.
-  // The joining curve will not appear in the final buffer outline,
-  // since it is completely internal to the buffer polygon.
-  //
-  // In complex buffer cases the closing segment may cut across many
-  // other segments in the generated offset curve.
-  // In order to improve the performance of the noding, the closing
-  // segment should be kept as short as possible.
-  // (But not too short, since that would defeat it's purpose).
-  // This is the purpose of the closingSegLengthFactor heuristic value.
-
-       /**
-        * The intersection test above is vulnerable to robustness errors;
-  * i.e. it may be that the offsets should intersect very close to
-  * their endpoints, but aren't reported as such due to rounding.
-  * To handle this situation appropriately, we use the following test:
-  * If the offset points are very close, don't add closing segments
-  * but simply use one of the offset points
-        */
-
-  if (offset0.p1.distance(offset1.p0) <
-    distance * INSIDE_TURN_VERTEX_SNAP_DISTANCE_FACTOR)
-  {
-    segList.addPt(offset0.p1);
-  }
-  else
-  {
-    // add endpoint of this segment offset
-    segList.addPt(offset0.p1);
-
-    // Add "closing segment" of required length.
-    if ( closingSegLengthFactor > 0 )
-    {
-      Coordinate mid0(
- (closingSegLengthFactor*offset0.p1.x + s1.x)/(closingSegLengthFactor + 1),
- (closingSegLengthFactor*offset0.p1.y + s1.y)/(closingSegLengthFactor + 1)
-      );
-      segList.addPt(mid0);
-
-      Coordinate mid1(
- (closingSegLengthFactor*offset1.p0.x + s1.x)/(closingSegLengthFactor + 1),
- (closingSegLengthFactor*offset1.p0.y + s1.y)/(closingSegLengthFactor + 1)
-      );
-      segList.addPt(mid1);
-    }
-    else
-    {
-      // This branch is not expected to be used
-      // except for testing purposes.
-      // It is equivalent to the JTS 1.9 logic for
-      // closing segments (which results in very poor
-      // performance for large buffer distances)
-      segList.addPt(s1);
+    // add intersection point of offset segments (if any)
+    li.computeIntersection(offset0.p0, offset0.p1, offset1.p0, offset1.p1);
+    if(li.hasIntersection()) {
+        segList.addPt(li.getIntersection(0));
+        return;
     }
 
-    // add start point of next segment offset
-    segList.addPt(offset1.p0);
-  }
+    // If no intersection is detected, it means the angle is so small
+    // and/or the offset so large that the offsets segments don't
+    // intersect. In this case we must add a "closing segment" to make
+    // sure the buffer curve is continuous,
+    // fairly smooth (e.g. no sharp reversals in direction)
+    // and tracks the buffer correctly around the corner.
+    // The curve connects the endpoints of the segment offsets to points
+    // which lie toward the centre point of the corner.
+    // The joining curve will not appear in the final buffer outline,
+    // since it is completely internal to the buffer polygon.
+    //
+    // In complex buffer cases the closing segment may cut across many
+    // other segments in the generated offset curve.
+    // In order to improve the performance of the noding, the closing
+    // segment should be kept as short as possible.
+    // (But not too short, since that would defeat it's purpose).
+    // This is the purpose of the closingSegLengthFactor heuristic value.
+
+    /**
+     * The intersection test above is vulnerable to robustness errors;
+    * i.e. it may be that the offsets should intersect very close to
+    * their endpoints, but aren't reported as such due to rounding.
+    * To handle this situation appropriately, we use the following test:
+    * If the offset points are very close, don't add closing segments
+    * but simply use one of the offset points
+     */
+
+    if(offset0.p1.distance(offset1.p0) <
+            distance * INSIDE_TURN_VERTEX_SNAP_DISTANCE_FACTOR) {
+        segList.addPt(offset0.p1);
+    }
+    else {
+        // add endpoint of this segment offset
+        segList.addPt(offset0.p1);
+
+        // Add "closing segment" of required length.
+        if(closingSegLengthFactor > 0) {
+            Coordinate mid0(
+                (closingSegLengthFactor * offset0.p1.x + s1.x) / (closingSegLengthFactor + 1),
+                (closingSegLengthFactor * offset0.p1.y + s1.y) / (closingSegLengthFactor + 1)
+            );
+            segList.addPt(mid0);
+
+            Coordinate mid1(
+                (closingSegLengthFactor * offset1.p0.x + s1.x) / (closingSegLengthFactor + 1),
+                (closingSegLengthFactor * offset1.p0.y + s1.y) / (closingSegLengthFactor + 1)
+            );
+            segList.addPt(mid1);
+        }
+        else {
+            // This branch is not expected to be used
+            // except for testing purposes.
+            // It is equivalent to the JTS 1.9 logic for
+            // closing segments (which results in very poor
+            // performance for large buffer distances)
+            segList.addPt(s1);
+        }
+
+        // add start point of next segment offset
+        segList.addPt(offset1.p0);
+    }
 }
 
 /* private */
 void
 OffsetSegmentGenerator::addMitreJoin(const geom::Coordinate& p,
-                    const geom::LineSegment& p_offset0,
-                    const geom::LineSegment& p_offset1,
-                    double p_distance)
+                                     const geom::LineSegment& p_offset0,
+                                     const geom::LineSegment& p_offset1,
+                                     double p_distance)
 {
-  bool isMitreWithinLimit = true;
-  Coordinate intPt;
+    bool isMitreWithinLimit = true;
+    Coordinate intPt;
 
-        /**
-         * This computation is unstable if the offset segments
-   * are nearly collinear.
-         * Howver, this situation should have been eliminated earlier
-   * by the check for whether the offset segment endpoints are
-   * almost coincident
-         */
-    try
-    {
+    /**
+     * This computation is unstable if the offset segments
+    * are nearly collinear.
+     * Howver, this situation should have been eliminated earlier
+    * by the check for whether the offset segment endpoints are
+    * almost coincident
+     */
+    try {
         HCoordinate::intersection(p_offset0.p0, p_offset0.p1,
-            p_offset1.p0, p_offset1.p1,
-            intPt);
+                                  p_offset1.p0, p_offset1.p1,
+                                  intPt);
 
         double mitreRatio = p_distance <= 0.0 ? 1.0
-            : intPt.distance(p) / fabs(p_distance);
+                            : intPt.distance(p) / fabs(p_distance);
 
-        if (mitreRatio > bufParams.getMitreLimit())
+        if(mitreRatio > bufParams.getMitreLimit()) {
             isMitreWithinLimit = false;
+        }
     }
-    catch (const NotRepresentableException& e)
-    {
+    catch(const NotRepresentableException& e) {
         ::geos::ignore_unused_variable_warning(e);
 
-        intPt = Coordinate(0,0);
+        intPt = Coordinate(0, 0);
         isMitreWithinLimit = false;
     }
 
-    if (isMitreWithinLimit)
-    {
+    if(isMitreWithinLimit) {
         segList.addPt(intPt);
     }
-    else
-    {
+    else {
         addLimitedMitreJoin(p_offset0, p_offset1, p_distance,
-            bufParams.getMitreLimit());
+                            bufParams.getMitreLimit());
         //addBevelJoin(offset0, offset1);
     }
 }
@@ -530,69 +523,69 @@ OffsetSegmentGenerator::addMitreJoin(const geom::Coordinate& p,
 /* private */
 void
 OffsetSegmentGenerator::addLimitedMitreJoin(
-                    const geom::LineSegment& p_offset0,
-                    const geom::LineSegment& p_offset1,
-                    double p_distance, double p_mitreLimit)
+    const geom::LineSegment& p_offset0,
+    const geom::LineSegment& p_offset1,
+    double p_distance, double p_mitreLimit)
 {
     ::geos::ignore_unused_variable_warning(p_offset0);
     ::geos::ignore_unused_variable_warning(p_offset1);
 
-  const Coordinate& basePt = seg0.p1;
-
-  double ang0 = Angle::angle(basePt, seg0.p0);
-  //double ang1 = Angle::angle(basePt, seg1.p1); // unused in JTS, bug ?
-
-  // oriented angle between segments
-  double angDiff = Angle::angleBetweenOriented(seg0.p0, basePt, seg1.p1);
-  // half of the interior angle
-  double angDiffHalf = angDiff / 2;
-
-  // angle for bisector of the interior angle between the segments
-  double midAng = Angle::normalize(ang0 + angDiffHalf);
-  // rotating this by PI gives the bisector of the reflex angle
-  double mitreMidAng = Angle::normalize(midAng + PI);
-
-  // the miterLimit determines the distance to the mitre bevel
-  double mitreDist = p_mitreLimit * p_distance;
-  // the bevel delta is the difference between the buffer distance
-  // and half of the length of the bevel segment
-  double bevelDelta = mitreDist * fabs(sin(angDiffHalf));
-  double bevelHalfLen = p_distance - bevelDelta;
-
-  // compute the midpoint of the bevel segment
-  double bevelMidX = basePt.x + mitreDist * cos(mitreMidAng);
-  double bevelMidY = basePt.y + mitreDist * sin(mitreMidAng);
-  Coordinate bevelMidPt(bevelMidX, bevelMidY);
-
-  // compute the mitre midline segment from the corner point to
-  // the bevel segment midpoint
-  LineSegment mitreMidLine(basePt, bevelMidPt);
-
-  // finally the bevel segment endpoints are computed as offsets from
-  // the mitre midline
-  Coordinate bevelEndLeft;
-  mitreMidLine.pointAlongOffset(1.0, bevelHalfLen, bevelEndLeft);
-  Coordinate bevelEndRight;
-  mitreMidLine.pointAlongOffset(1.0, -bevelHalfLen, bevelEndRight);
-
-  if (side == Position::LEFT) {
-    segList.addPt(bevelEndLeft);
-    segList.addPt(bevelEndRight);
-  }
-  else {
-    segList.addPt(bevelEndRight);
-    segList.addPt(bevelEndLeft);
-  }
+    const Coordinate& basePt = seg0.p1;
+
+    double ang0 = Angle::angle(basePt, seg0.p0);
+    //double ang1 = Angle::angle(basePt, seg1.p1); // unused in JTS, bug ?
+
+    // oriented angle between segments
+    double angDiff = Angle::angleBetweenOriented(seg0.p0, basePt, seg1.p1);
+    // half of the interior angle
+    double angDiffHalf = angDiff / 2;
+
+    // angle for bisector of the interior angle between the segments
+    double midAng = Angle::normalize(ang0 + angDiffHalf);
+    // rotating this by PI gives the bisector of the reflex angle
+    double mitreMidAng = Angle::normalize(midAng + PI);
+
+    // the miterLimit determines the distance to the mitre bevel
+    double mitreDist = p_mitreLimit * p_distance;
+    // the bevel delta is the difference between the buffer distance
+    // and half of the length of the bevel segment
+    double bevelDelta = mitreDist * fabs(sin(angDiffHalf));
+    double bevelHalfLen = p_distance - bevelDelta;
+
+    // compute the midpoint of the bevel segment
+    double bevelMidX = basePt.x + mitreDist * cos(mitreMidAng);
+    double bevelMidY = basePt.y + mitreDist * sin(mitreMidAng);
+    Coordinate bevelMidPt(bevelMidX, bevelMidY);
+
+    // compute the mitre midline segment from the corner point to
+    // the bevel segment midpoint
+    LineSegment mitreMidLine(basePt, bevelMidPt);
+
+    // finally the bevel segment endpoints are computed as offsets from
+    // the mitre midline
+    Coordinate bevelEndLeft;
+    mitreMidLine.pointAlongOffset(1.0, bevelHalfLen, bevelEndLeft);
+    Coordinate bevelEndRight;
+    mitreMidLine.pointAlongOffset(1.0, -bevelHalfLen, bevelEndRight);
+
+    if(side == Position::LEFT) {
+        segList.addPt(bevelEndLeft);
+        segList.addPt(bevelEndRight);
+    }
+    else {
+        segList.addPt(bevelEndRight);
+        segList.addPt(bevelEndLeft);
+    }
 
 }
 
 /* private */
 void
-OffsetSegmentGenerator::addBevelJoin( const geom::LineSegment& p_offset0,
-                    const geom::LineSegment& p_offset1)
+OffsetSegmentGenerator::addBevelJoin(const geom::LineSegment& p_offset0,
+                                     const geom::LineSegment& p_offset1)
 {
-  segList.addPt(p_offset0.p1);
-  segList.addPt(p_offset1.p0);
+    segList.addPt(p_offset0.p1);
+    segList.addPt(p_offset1.p0);
 }
 
 } // namespace geos.operation.buffer
diff --git a/src/operation/buffer/RightmostEdgeFinder.cpp b/src/operation/buffer/RightmostEdgeFinder.cpp
index b58fdfb..02b4741 100644
--- a/src/operation/buffer/RightmostEdgeFinder.cpp
+++ b/src/operation/buffer/RightmostEdgeFinder.cpp
@@ -39,12 +39,12 @@ namespace buffer { // geos.operation.buffer
 
 /*public*/
 RightmostEdgeFinder::RightmostEdgeFinder()
-	:
-	minIndex(-1), // FIXME: don't use -1 as a sentinel, or we won't be
-	              // able to use an unsigned int here
-	minCoord(Coordinate::getNull()),
-	minDe(nullptr),
-	orientedDe(nullptr)
+    :
+    minIndex(-1), // FIXME: don't use -1 as a sentinel, or we won't be
+    // able to use an unsigned int here
+    minCoord(Coordinate::getNull()),
+    minDe(nullptr),
+    orientedDe(nullptr)
 {
 }
 
@@ -54,213 +54,217 @@ RightmostEdgeFinder::findEdge(std::vector<DirectedEdge*>* dirEdgeList)
 {
 
 #ifndef NDEBUG
-	size_t checked=0;
+    size_t checked = 0;
 #endif
 
-	/*
-	 * Check all forward DirectedEdges only.  This is still general,
-	 * because each edge has a forward DirectedEdge.
-	 */
-	size_t dirEdgeListSize=dirEdgeList->size();
-	for(size_t i=0; i<dirEdgeListSize; ++i)
-	{
-		DirectedEdge *de=(*dirEdgeList)[i];
-		assert(de);
-		if (!de->isForward()) continue;
-		checkForRightmostCoordinate(de);
+    /*
+     * Check all forward DirectedEdges only.  This is still general,
+     * because each edge has a forward DirectedEdge.
+     */
+    size_t dirEdgeListSize = dirEdgeList->size();
+    for(size_t i = 0; i < dirEdgeListSize; ++i) {
+        DirectedEdge* de = (*dirEdgeList)[i];
+        assert(de);
+        if(!de->isForward()) {
+            continue;
+        }
+        checkForRightmostCoordinate(de);
 #ifndef NDEBUG
-		++checked;
+        ++checked;
 #endif
-	}
+    }
 
-  if ( ! minDe ) {
-    // I don't know why, but it looks like this can happen
-    // (invalid PlanarGraph, I think)
-    // See http://trac.osgeo.org/geos/ticket/605#comment:17
-    //
-    throw util::TopologyException("No forward edges found in buffer subgraph");
-  }
+    if(! minDe) {
+        // I don't know why, but it looks like this can happen
+        // (invalid PlanarGraph, I think)
+        // See http://trac.osgeo.org/geos/ticket/605#comment:17
+        //
+        throw util::TopologyException("No forward edges found in buffer subgraph");
+    }
 
 #ifndef NDEBUG
-	assert(checked>0);
-	assert(minIndex>=0);
-	assert(minDe);
+    assert(checked > 0);
+    assert(minIndex >= 0);
+    assert(minDe);
 #endif
 
-	/*
-	 * If the rightmost point is a node, we need to identify which of
-	 * the incident edges is rightmost.
-	 */
-	assert(minIndex!=0 || minCoord==minDe->getCoordinate());
-	// inconsistency in rightmost processing
-
-	if (minIndex==0 ) {
-		findRightmostEdgeAtNode();
-	} else {
-		findRightmostEdgeAtVertex();
-	}
-
-	/*
-	 * now check that the extreme side is the R side.
-	 * If not, use the sym instead.
-	 */
-	orientedDe=minDe;
-	int rightmostSide=getRightmostSide(minDe, minIndex);
-	if (rightmostSide==Position::LEFT) {
-		orientedDe=minDe->getSym();
-	}
+    /*
+     * If the rightmost point is a node, we need to identify which of
+     * the incident edges is rightmost.
+     */
+    assert(minIndex != 0 || minCoord == minDe->getCoordinate());
+    // inconsistency in rightmost processing
+
+    if(minIndex == 0) {
+        findRightmostEdgeAtNode();
+    }
+    else {
+        findRightmostEdgeAtVertex();
+    }
+
+    /*
+     * now check that the extreme side is the R side.
+     * If not, use the sym instead.
+     */
+    orientedDe = minDe;
+    int rightmostSide = getRightmostSide(minDe, minIndex);
+    if(rightmostSide == Position::LEFT) {
+        orientedDe = minDe->getSym();
+    }
 }
 
 /*private*/
 void
 RightmostEdgeFinder::findRightmostEdgeAtNode()
 {
-	Node *node=minDe->getNode();
-	assert(node);
+    Node* node = minDe->getNode();
+    assert(node);
 
-	assert(dynamic_cast<DirectedEdgeStar*>(node->getEdges()));
-	DirectedEdgeStar *star=static_cast<DirectedEdgeStar*>(node->getEdges());
+    assert(dynamic_cast<DirectedEdgeStar*>(node->getEdges()));
+    DirectedEdgeStar* star = static_cast<DirectedEdgeStar*>(node->getEdges());
 
-	// Warning! NULL could be returned if the star is empty!
-	minDe=star->getRightmostEdge();
-	assert(minDe);
+    // Warning! NULL could be returned if the star is empty!
+    minDe = star->getRightmostEdge();
+    assert(minDe);
 
-	// the DirectedEdge returned by the previous call is not
-	// necessarily in the forward direction. Use the sym edge if it isn't.
-	if (!minDe->isForward())
-	{
-		minDe=minDe->getSym();
+    // the DirectedEdge returned by the previous call is not
+    // necessarily in the forward direction. Use the sym edge if it isn't.
+    if(!minDe->isForward()) {
+        minDe = minDe->getSym();
 
-		const Edge* minEdge=minDe->getEdge();
-		assert(minEdge);
+        const Edge* minEdge = minDe->getEdge();
+        assert(minEdge);
 
-		const CoordinateSequence* minEdgeCoords =
-				minEdge->getCoordinates();
-		assert(minEdgeCoords);
+        const CoordinateSequence* minEdgeCoords =
+            minEdge->getCoordinates();
+        assert(minEdgeCoords);
 
-		minIndex=(int)(minEdgeCoords->getSize())-1;
-		assert(minIndex>=0);
-	}
+        minIndex = (int)(minEdgeCoords->getSize()) - 1;
+        assert(minIndex >= 0);
+    }
 }
 
 /*private*/
 void
 RightmostEdgeFinder::findRightmostEdgeAtVertex()
 {
-	/*
-	 * The rightmost point is an interior vertex, so it has
-	 * a segment on either side of it.
-	 * If these segments are both above or below the rightmost
-	 * point, we need to determine their relative orientation
-	 * to decide which is rightmost.
-	 */
-
-	Edge* minEdge=minDe->getEdge();
-	assert(minEdge);
-	const CoordinateSequence *pts=minEdge->getCoordinates();
-	assert(pts);
-
-	// rightmost point expected to be interior vertex of edge
-	assert(minIndex>0);
-	assert((size_t)minIndex<pts->getSize());
-
-	const Coordinate& pPrev=pts->getAt(minIndex-1);
-	const Coordinate& pNext=pts->getAt(minIndex+1);
-	int orientation=Orientation::index(
-			minCoord,
-			pNext,
-			pPrev);
-	bool usePrev=false;
-
-	// both segments are below min point
-	if ( pPrev.y < minCoord.y && pNext.y < minCoord.y
-		&& orientation == Orientation::COUNTERCLOCKWISE)
-	{
-			usePrev=true;
-	}
-	else if ( pPrev.y > minCoord.y && pNext.y > minCoord.y
-		&& orientation == Orientation::CLOCKWISE)
-	{
-			usePrev=true;
-	}
-
-	// if both segments are on the same side, do nothing - either is safe
-	// to select as a rightmost segment
-	if (usePrev) {
-		minIndex=minIndex-1;
-	}
+    /*
+     * The rightmost point is an interior vertex, so it has
+     * a segment on either side of it.
+     * If these segments are both above or below the rightmost
+     * point, we need to determine their relative orientation
+     * to decide which is rightmost.
+     */
+
+    Edge* minEdge = minDe->getEdge();
+    assert(minEdge);
+    const CoordinateSequence* pts = minEdge->getCoordinates();
+    assert(pts);
+
+    // rightmost point expected to be interior vertex of edge
+    assert(minIndex > 0);
+    assert((size_t)minIndex < pts->getSize());
+
+    const Coordinate& pPrev = pts->getAt(minIndex - 1);
+    const Coordinate& pNext = pts->getAt(minIndex + 1);
+    int orientation = Orientation::index(
+                          minCoord,
+                          pNext,
+                          pPrev);
+    bool usePrev = false;
+
+    // both segments are below min point
+    if(pPrev.y < minCoord.y && pNext.y < minCoord.y
+            && orientation == Orientation::COUNTERCLOCKWISE) {
+        usePrev = true;
+    }
+    else if(pPrev.y > minCoord.y && pNext.y > minCoord.y
+            && orientation == Orientation::CLOCKWISE) {
+        usePrev = true;
+    }
+
+    // if both segments are on the same side, do nothing - either is safe
+    // to select as a rightmost segment
+    if(usePrev) {
+        minIndex = minIndex - 1;
+    }
 }
 
 /*private*/
 void
-RightmostEdgeFinder::checkForRightmostCoordinate(DirectedEdge *de)
+RightmostEdgeFinder::checkForRightmostCoordinate(DirectedEdge* de)
 {
-	const Edge* deEdge=de->getEdge();
-	assert(deEdge);
-
-	const CoordinateSequence *coord=deEdge->getCoordinates();
-	assert(coord);
-
-	// only check vertices which are the starting point of
-	// a non-horizontal segment
-	size_t n=coord->getSize()-1;
-	for(size_t i=0; i<n; i++)
-	{
-     // only check vertices which are the start or end point
-     // of a non-horizontal segment
-     // <FIX> MD 19 Sep 03 - NO!  we can test all vertices,
-     // since the rightmost must have a non-horiz segment adjacent to it
-		if (minCoord.isNull() ||
-			coord->getAt(i).x > minCoord.x )
-		{
-			minDe = de;
-			minIndex = (int)i;
-			minCoord = coord->getAt(i);
-		}
-	}
+    const Edge* deEdge = de->getEdge();
+    assert(deEdge);
+
+    const CoordinateSequence* coord = deEdge->getCoordinates();
+    assert(coord);
+
+    // only check vertices which are the starting point of
+    // a non-horizontal segment
+    size_t n = coord->getSize() - 1;
+    for(size_t i = 0; i < n; i++) {
+        // only check vertices which are the start or end point
+        // of a non-horizontal segment
+        // <FIX> MD 19 Sep 03 - NO!  we can test all vertices,
+        // since the rightmost must have a non-horiz segment adjacent to it
+        if(minCoord.isNull() ||
+                coord->getAt(i).x > minCoord.x) {
+            minDe = de;
+            minIndex = (int)i;
+            minCoord = coord->getAt(i);
+        }
+    }
 }
 
 /*private*/
 int
-RightmostEdgeFinder::getRightmostSide(DirectedEdge *de, int index)
+RightmostEdgeFinder::getRightmostSide(DirectedEdge* de, int index)
 {
-	int side = getRightmostSideOfSegment(de, index);
+    int side = getRightmostSideOfSegment(de, index);
 
-	if (side<0) side=getRightmostSideOfSegment(de, index-1);
+    if(side < 0) {
+        side = getRightmostSideOfSegment(de, index - 1);
+    }
 
-	if (side<0)
-	{
-		// reaching here can indicate that segment is horizontal
-		// Assert::shouldNeverReachHere(
-		//	"problem with finding rightmost side of segment");
+    if(side < 0) {
+        // reaching here can indicate that segment is horizontal
+        // Assert::shouldNeverReachHere(
+        //	"problem with finding rightmost side of segment");
 
-		minCoord=Coordinate::getNull();
-		checkForRightmostCoordinate(de);
-	}
+        minCoord = Coordinate::getNull();
+        checkForRightmostCoordinate(de);
+    }
 
-	return side;
+    return side;
 }
 
 /*private*/
 int
-RightmostEdgeFinder::getRightmostSideOfSegment(DirectedEdge *de, int i)
+RightmostEdgeFinder::getRightmostSideOfSegment(DirectedEdge* de, int i)
 {
-	assert(de);
+    assert(de);
 
-	const Edge *e=de->getEdge();
-	assert(e);
+    const Edge* e = de->getEdge();
+    assert(e);
 
-	const CoordinateSequence *coord=e->getCoordinates();
-	assert(coord);
+    const CoordinateSequence* coord = e->getCoordinates();
+    assert(coord);
 
-	if ( i < 0 || i+1 >= (int)coord->getSize() ) return -1;
+    if(i < 0 || i + 1 >= (int)coord->getSize()) {
+        return -1;
+    }
 
-	// indicates edge is parallel to x-axis
-	if (coord->getAt(i).y == coord->getAt(i+1).y) return -1;
+    // indicates edge is parallel to x-axis
+    if(coord->getAt(i).y == coord->getAt(i + 1).y) {
+        return -1;
+    }
 
-	int pos=Position::LEFT;
-	if (coord->getAt(i).y < coord->getAt(i+1).y) pos=Position::RIGHT;
-	return pos;
+    int pos = Position::LEFT;
+    if(coord->getAt(i).y < coord->getAt(i + 1).y) {
+        pos = Position::RIGHT;
+    }
+    return pos;
 }
 
 } // namespace geos.operation.buffer
diff --git a/src/operation/buffer/SubgraphDepthLocater.cpp b/src/operation/buffer/SubgraphDepthLocater.cpp
index 50bdd72..496117a 100644
--- a/src/operation/buffer/SubgraphDepthLocater.cpp
+++ b/src/operation/buffer/SubgraphDepthLocater.cpp
@@ -54,88 +54,99 @@ class DepthSegment {
 
 private:
 
-	geom::LineSegment upwardSeg;
-
-	/*
-	 * Compare two collinear segments for left-most ordering.
-	 * If segs are vertical, use vertical ordering for comparison.
-	 * If segs are equal, return 0.
-	 * Segments are assumed to be directed so that the second
-	 * coordinate is >= to the first
-	 * (e.g. up and to the right).
-	 *
-	 * @param seg0 a segment to compare
-	 * @param seg1 a segment to compare
-	 * @return
-	 */
-	static int compareX(const geom::LineSegment *seg0, const geom::LineSegment *seg1)
-	{
-		int compare0=seg0->p0.compareTo(seg1->p0);
-		if (compare0!=0) return compare0;
-		return seg0->p1.compareTo(seg1->p1);
-	}
+    geom::LineSegment upwardSeg;
+
+    /*
+     * Compare two collinear segments for left-most ordering.
+     * If segs are vertical, use vertical ordering for comparison.
+     * If segs are equal, return 0.
+     * Segments are assumed to be directed so that the second
+     * coordinate is >= to the first
+     * (e.g. up and to the right).
+     *
+     * @param seg0 a segment to compare
+     * @param seg1 a segment to compare
+     * @return
+     */
+    static int
+    compareX(const geom::LineSegment* seg0, const geom::LineSegment* seg1)
+    {
+        int compare0 = seg0->p0.compareTo(seg1->p0);
+        if(compare0 != 0) {
+            return compare0;
+        }
+        return seg0->p1.compareTo(seg1->p1);
+    }
 
 public:
 
-	int leftDepth;
-
-	/// @param seg will be copied to private space
-	DepthSegment(const geom::LineSegment &seg, int depth)
-		:
-		upwardSeg(seg),
-		leftDepth(depth)
-	{
-		// input seg is assumed to be normalized
-		//upwardSeg.normalize();
-	}
-
-	/**
-	 * Defines a comparision operation on DepthSegments
-	 * which orders them left to right
-	 *
-	 * <pre>
-	 * DS1 < DS2   if   DS1.seg is left of DS2.seg
-	 * DS1 > DS2   if   DS1.seg is right of DS2.seg
-	 * </pre>
-	 *
-	 * @param obj
-	 * @return
-	 */
-	int compareTo(const DepthSegment& other) const
-	{
-		/**
-		 * try and compute a determinate orientation for the segments.
-		 * Test returns 1 if other is left of this (i.e. this > other)
-		 */
-		int orientIndex=upwardSeg.orientationIndex(&(other.upwardSeg));
-
-		/**
-		 * If comparison between this and other is indeterminate,
-		 * try the opposite call order.
-		 * orientationIndex value is 1 if this is left of other,
-		 * so have to flip sign to get proper comparison value of
-		 * -1 if this is leftmost
-		 */
-		if (orientIndex==0)
-			orientIndex=-1 * other.upwardSeg.orientationIndex(&upwardSeg);
-
-		// if orientation is determinate, return it
-		if (orientIndex != 0)
-			return orientIndex;
-
-		// otherwise, segs must be collinear - sort based on minimum X value
-		return compareX(&upwardSeg, &(other.upwardSeg));
-	}
+    int leftDepth;
+
+    /// @param seg will be copied to private space
+    DepthSegment(const geom::LineSegment& seg, int depth)
+        :
+        upwardSeg(seg),
+        leftDepth(depth)
+    {
+        // input seg is assumed to be normalized
+        //upwardSeg.normalize();
+    }
+
+    /**
+     * Defines a comparision operation on DepthSegments
+     * which orders them left to right
+     *
+     * <pre>
+     * DS1 < DS2   if   DS1.seg is left of DS2.seg
+     * DS1 > DS2   if   DS1.seg is right of DS2.seg
+     * </pre>
+     *
+     * @param obj
+     * @return
+     */
+    int
+    compareTo(const DepthSegment& other) const
+    {
+        /**
+         * try and compute a determinate orientation for the segments.
+         * Test returns 1 if other is left of this (i.e. this > other)
+         */
+        int orientIndex = upwardSeg.orientationIndex(&(other.upwardSeg));
+
+        /**
+         * If comparison between this and other is indeterminate,
+         * try the opposite call order.
+         * orientationIndex value is 1 if this is left of other,
+         * so have to flip sign to get proper comparison value of
+         * -1 if this is leftmost
+         */
+        if(orientIndex == 0) {
+            orientIndex = -1 * other.upwardSeg.orientationIndex(&upwardSeg);
+        }
+
+        // if orientation is determinate, return it
+        if(orientIndex != 0) {
+            return orientIndex;
+        }
+
+        // otherwise, segs must be collinear - sort based on minimum X value
+        return compareX(&upwardSeg, &(other.upwardSeg));
+    }
 };
 
 struct DepthSegmentLessThen {
-	bool operator() (const DepthSegment* first, const DepthSegment* second)
-	{
-		assert(first);
-		assert(second);
-		if (first->compareTo(*second)<0) return true;
-		else return false;
-	}
+    bool
+    operator()(const DepthSegment* first, const DepthSegment* second)
+    {
+        assert(first);
+        assert(second);
+        if(first->compareTo(*second) < 0) {
+            return true;
+        }
+        else {
+            return false;
+        }
+    }
 };
 
 
@@ -144,86 +155,86 @@ struct DepthSegmentLessThen {
 int
 SubgraphDepthLocater::getDepth(const Coordinate& p)
 {
-	vector<DepthSegment*> stabbedSegments;
-	findStabbedSegments(p, stabbedSegments);
+    vector<DepthSegment*> stabbedSegments;
+    findStabbedSegments(p, stabbedSegments);
 
-	// if no segments on stabbing line subgraph must be outside all others
-	if (stabbedSegments.empty()) return 0;
+    // if no segments on stabbing line subgraph must be outside all others
+    if(stabbedSegments.empty()) {
+        return 0;
+    }
 
-	sort(stabbedSegments.begin(), stabbedSegments.end(), DepthSegmentLessThen());
+    sort(stabbedSegments.begin(), stabbedSegments.end(), DepthSegmentLessThen());
 
-	DepthSegment *ds=stabbedSegments[0];
-	int ret = ds->leftDepth;
+    DepthSegment* ds = stabbedSegments[0];
+    int ret = ds->leftDepth;
 
 #if GEOS_DEBUG
-	cerr<<"SubgraphDepthLocater::getDepth("<<p.toString()<<"): "<<ret<<endl;
+    cerr << "SubgraphDepthLocater::getDepth(" << p.toString() << "): " << ret << endl;
 #endif
 
-	for (vector<DepthSegment *>::iterator
-		it=stabbedSegments.begin(), itEnd=stabbedSegments.end();
-		it != itEnd;
-		++it)
-	{
-		delete *it;
-	}
+    for(vector<DepthSegment*>::iterator
+            it = stabbedSegments.begin(), itEnd = stabbedSegments.end();
+            it != itEnd;
+            ++it) {
+        delete *it;
+    }
 
-	return ret;
+    return ret;
 }
 
 /*private*/
 void
-SubgraphDepthLocater::findStabbedSegments(const Coordinate &stabbingRayLeftPt,
-			std::vector<DepthSegment*>& stabbedSegments)
+SubgraphDepthLocater::findStabbedSegments(const Coordinate& stabbingRayLeftPt,
+        std::vector<DepthSegment*>& stabbedSegments)
 {
-	size_t size = subgraphs->size();
-	for (size_t i=0; i<size; ++i)
-	{
-		BufferSubgraph *bsg=(*subgraphs)[i];
-
-		// optimization - don't bother checking subgraphs
-		// which the ray does not intersect
-		Envelope *env = bsg->getEnvelope();
-		if ( stabbingRayLeftPt.y < env->getMinY()
-			|| stabbingRayLeftPt.y > env->getMaxY()
-                        || stabbingRayLeftPt.x < env->getMinX()
-                        || stabbingRayLeftPt.x > env->getMaxX())
-		{
-				continue;
-		}
-
-		findStabbedSegments(stabbingRayLeftPt, bsg->getDirectedEdges(),
-			stabbedSegments);
-	}
+    size_t size = subgraphs->size();
+    for(size_t i = 0; i < size; ++i) {
+        BufferSubgraph* bsg = (*subgraphs)[i];
+
+        // optimization - don't bother checking subgraphs
+        // which the ray does not intersect
+        Envelope* env = bsg->getEnvelope();
+        if(stabbingRayLeftPt.y < env->getMinY()
+                || stabbingRayLeftPt.y > env->getMaxY()
+                || stabbingRayLeftPt.x < env->getMinX()
+                || stabbingRayLeftPt.x > env->getMaxX()) {
+            continue;
+        }
+
+        findStabbedSegments(stabbingRayLeftPt, bsg->getDirectedEdges(),
+                            stabbedSegments);
+    }
 }
 
 /*private*/
 void
 SubgraphDepthLocater::findStabbedSegments(
-	const Coordinate &stabbingRayLeftPt,
-	vector<DirectedEdge*>* dirEdges,
-	vector<DepthSegment*>& stabbedSegments)
+    const Coordinate& stabbingRayLeftPt,
+    vector<DirectedEdge*>* dirEdges,
+    vector<DepthSegment*>& stabbedSegments)
 {
 
-	/**
-	 * Check all forward DirectedEdges only. This is still general,
-	 * because each Edge has a forward DirectedEdge.
-	 */
-	for (size_t i=0, n=dirEdges->size(); i<n; ++i)
-	{
-		DirectedEdge *de=(*dirEdges)[i];
-		if (!de->isForward()) continue;
-		findStabbedSegments(stabbingRayLeftPt, de, stabbedSegments);
-	}
+    /**
+     * Check all forward DirectedEdges only. This is still general,
+     * because each Edge has a forward DirectedEdge.
+     */
+    for(size_t i = 0, n = dirEdges->size(); i < n; ++i) {
+        DirectedEdge* de = (*dirEdges)[i];
+        if(!de->isForward()) {
+            continue;
+        }
+        findStabbedSegments(stabbingRayLeftPt, de, stabbedSegments);
+    }
 }
 
 /*private*/
 void
 SubgraphDepthLocater::findStabbedSegments(
-	const Coordinate &stabbingRayLeftPt,
-	DirectedEdge *dirEdge,
-	vector<DepthSegment*>& stabbedSegments)
+    const Coordinate& stabbingRayLeftPt,
+    DirectedEdge* dirEdge,
+    vector<DepthSegment*>& stabbedSegments)
 {
-	const CoordinateSequence *pts=dirEdge->getEdge()->getCoordinates();
+    const CoordinateSequence* pts = dirEdge->getEdge()->getCoordinates();
 
 // It seems that LineSegment is *very* slow... undef this
 // to see yourself
@@ -234,124 +245,121 @@ SubgraphDepthLocater::findStabbedSegments(
 //
 #define SKIP_LS 1
 
-	auto n = pts->getSize() - 1;
-	for (size_t i = 0; i < n; ++i) {
+    auto n = pts->getSize() - 1;
+    for(size_t i = 0; i < n; ++i) {
 #ifndef SKIP_LS
-		seg.p0=pts->getAt(i);
-		seg.p1=pts->getAt(i + 1);
+        seg.p0 = pts->getAt(i);
+        seg.p1 = pts->getAt(i + 1);
 #if GEOS_DEBUG
-		cerr << " SubgraphDepthLocater::findStabbedSegments: segment " << i
-			<< " (" << seg << ") ";
+        cerr << " SubgraphDepthLocater::findStabbedSegments: segment " << i
+             << " (" << seg << ") ";
 #endif
 
 #else
-		const Coordinate *low=&(pts->getAt(i));
-		const Coordinate *high=&(pts->getAt(i+1));
-		const Coordinate *swap=nullptr;
+        const Coordinate* low = &(pts->getAt(i));
+        const Coordinate* high = &(pts->getAt(i + 1));
+        const Coordinate* swap = nullptr;
 
 #endif
 
 #ifndef SKIP_LS
-		// ensure segment always points upwards
-		//if (seg.p0.y > seg.p1.y)
-		{
-			seg.reverse();
+        // ensure segment always points upwards
+        //if (seg.p0.y > seg.p1.y)
+        {
+            seg.reverse();
 #if GEOS_DEBUG
-			cerr << " reverse (" << seg << ") ";
+            cerr << " reverse (" << seg << ") ";
 #endif
-		}
+        }
 #else
-		if (low->y > high->y)
-		{
-			swap=low;
-			low=high;
-			high=swap;
-		}
+        if(low->y > high->y) {
+            swap = low;
+            low = high;
+            high = swap;
+        }
 #endif
 
-		// skip segment if it is left of the stabbing line
-		// skip if segment is above or below stabbing line
+        // skip segment if it is left of the stabbing line
+        // skip if segment is above or below stabbing line
 #ifndef SKIP_LS
-		double maxx=max(seg.p0.x, seg.p1.x);
+        double maxx = max(seg.p0.x, seg.p1.x);
 #else
-		double maxx=max(low->x, high->x);
+        double maxx = max(low->x, high->x);
 #endif
-		if (maxx < stabbingRayLeftPt.x)
-		{
+        if(maxx < stabbingRayLeftPt.x) {
 #if GEOS_DEBUG
-			cerr<<" segment is left to stabbing line, skipping "<<endl;
+            cerr << " segment is left to stabbing line, skipping " << endl;
 #endif
-			continue;
-		}
+            continue;
+        }
 
-		// skip horizontal segments (there will be a non-horizontal
-		// one carrying the same depth info
+        // skip horizontal segments (there will be a non-horizontal
+        // one carrying the same depth info
 #ifndef SKIP_LS
-		if (seg.isHorizontal())
+        if(seg.isHorizontal())
 #else
-		if (low->y == high->y)
+        if(low->y == high->y)
 #endif
-		{
+        {
 #if GEOS_DEBUG
-			cerr<<" segment is horizontal, skipping "<<endl;
+            cerr << " segment is horizontal, skipping " << endl;
 #endif
-			continue;
-		}
+            continue;
+        }
 
-		// skip if segment is above or below stabbing line
+        // skip if segment is above or below stabbing line
 #ifndef SKIP_LS
-		if (stabbingRayLeftPt.y < seg.p0.y ||
-			stabbingRayLeftPt.y > seg.p1.y)
+        if(stabbingRayLeftPt.y < seg.p0.y ||
+                stabbingRayLeftPt.y > seg.p1.y)
 #else
-		if (stabbingRayLeftPt.y < low->y ||
-			stabbingRayLeftPt.y > high->y)
+        if(stabbingRayLeftPt.y < low->y ||
+                stabbingRayLeftPt.y > high->y)
 #endif
-		{
+        {
 #if GEOS_DEBUG
-			cerr<<" segment above or below stabbing line, skipping "<<endl;
+            cerr << " segment above or below stabbing line, skipping " << endl;
 #endif
-			continue;
-		}
+            continue;
+        }
 
-		// skip if stabbing ray is right of the segment
+        // skip if stabbing ray is right of the segment
 #ifndef SKIP_LS
-		if (Orientation::index(seg.p0, seg.p1,
+        if(Orientation::index(seg.p0, seg.p1,
 #else
-		if (Orientation::index(*low, *high,
+        if(Orientation::index(*low, *high,
 #endif
-				stabbingRayLeftPt)==Orientation::RIGHT)
-		{
+                              stabbingRayLeftPt) == Orientation::RIGHT) {
 #if GEOS_DEBUG
-			cerr<<" stabbing ray right of segment, skipping"<<endl;
+            cerr << " stabbing ray right of segment, skipping" << endl;
 #endif
-			continue;
-		}
+            continue;
+        }
 
 #ifndef SKIP_LS
-		// stabbing line cuts this segment, so record it
-		int depth=dirEdge->getDepth(Position::LEFT);
-		// if segment direction was flipped, use RHS depth instead
-		if (! (seg.p0==pts->getAt(i)))
-			depth=dirEdge->getDepth(Position::RIGHT);
+        // stabbing line cuts this segment, so record it
+        int depth = dirEdge->getDepth(Position::LEFT);
+        // if segment direction was flipped, use RHS depth instead
+        if(!(seg.p0 == pts->getAt(i)))
+            depth = dirEdge->getDepth(Position::RIGHT);
 #else
-		int depth = swap ?
-			dirEdge->getDepth(Position::RIGHT)
-			:
-			dirEdge->getDepth(Position::LEFT);
+        int depth = swap ?
+                    dirEdge->getDepth(Position::RIGHT)
+                    :
+                    dirEdge->getDepth(Position::LEFT);
 #endif
 
 #if GEOS_DEBUG
-	cerr<<" depth: "<<depth<<endl;
+        cerr << " depth: " << depth << endl;
 #endif
 
 #ifdef SKIP_LS
-		seg.p0 = *low;
-		seg.p1 = *high;
+        seg.p0 = *low;
+        seg.p1 = *high;
 #endif
 
-		DepthSegment *ds=new DepthSegment(seg, depth);
-		stabbedSegments.push_back(ds);
-	}
+        DepthSegment* ds = new DepthSegment(seg, depth);
+        stabbedSegments.push_back(ds);
+    }
 }
 
 } // namespace geos.operation.buffer
diff --git a/src/operation/distance/ConnectedElementLocationFilter.cpp b/src/operation/distance/ConnectedElementLocationFilter.cpp
index c95028e..08822b6 100644
--- a/src/operation/distance/ConnectedElementLocationFilter.cpp
+++ b/src/operation/distance/ConnectedElementLocationFilter.cpp
@@ -36,32 +36,34 @@ namespace distance { // geos.operation.distance
 
 /*public*/
 vector<GeometryLocation*>*
-ConnectedElementLocationFilter::getLocations(const Geometry *geom)
+ConnectedElementLocationFilter::getLocations(const Geometry* geom)
 {
-	vector<GeometryLocation*> *loc=new vector<GeometryLocation*>();
-	ConnectedElementLocationFilter c(loc);
-	geom->apply_ro(&c);
-	return loc;
+    vector<GeometryLocation*>* loc = new vector<GeometryLocation*>();
+    ConnectedElementLocationFilter c(loc);
+    geom->apply_ro(&c);
+    return loc;
 }
 
 void
-ConnectedElementLocationFilter::filter_ro(const Geometry *geom)
+ConnectedElementLocationFilter::filter_ro(const Geometry* geom)
 {
-	if ((typeid(*geom)==typeid(Point)) ||
-		(typeid(*geom)==typeid(LineString)) ||
-		(typeid(*geom)==typeid(LinearRing)) ||
-		(typeid(*geom)==typeid(Polygon)))
-	{
-		locations->push_back(new GeometryLocation(geom, 0, *(geom->getCoordinate())));
-	}
+    if((typeid(*geom) == typeid(Point)) ||
+            (typeid(*geom) == typeid(LineString)) ||
+            (typeid(*geom) == typeid(LinearRing)) ||
+            (typeid(*geom) == typeid(Polygon))) {
+        locations->push_back(new GeometryLocation(geom, 0, *(geom->getCoordinate())));
+    }
 }
 
-void ConnectedElementLocationFilter::filter_rw(Geometry *geom){
-	if ((typeid(*geom)==typeid(Point)) ||
-		(typeid(*geom)==typeid(LineString)) ||
-		(typeid(*geom)==typeid(LinearRing)) ||
-		(typeid(*geom)==typeid(Polygon)))
-			locations->push_back(new GeometryLocation(geom, 0, *(geom->getCoordinate())));
+void
+ConnectedElementLocationFilter::filter_rw(Geometry* geom)
+{
+    if((typeid(*geom) == typeid(Point)) ||
+            (typeid(*geom) == typeid(LineString)) ||
+            (typeid(*geom) == typeid(LinearRing)) ||
+            (typeid(*geom) == typeid(Polygon))) {
+        locations->push_back(new GeometryLocation(geom, 0, *(geom->getCoordinate())));
+    }
 }
 
 } // namespace geos.operation.distance
diff --git a/src/operation/distance/ConnectedElementPointFilter.cpp b/src/operation/distance/ConnectedElementPointFilter.cpp
index a2176c7..d0ef70c 100644
--- a/src/operation/distance/ConnectedElementPointFilter.cpp
+++ b/src/operation/distance/ConnectedElementPointFilter.cpp
@@ -38,19 +38,22 @@ namespace distance { // geos.operation.distance
 * not a GeometryCollection, an empty list will be returned.
 */
 vector<const Coordinate*>*
-ConnectedElementPointFilter::getCoordinates(const Geometry *geom)
+ConnectedElementPointFilter::getCoordinates(const Geometry* geom)
 {
-	vector<const Coordinate*> *points=new vector<const Coordinate*>();
-	ConnectedElementPointFilter c(points);
-	geom->apply_ro(&c);
-	return points;
+    vector<const Coordinate*>* points = new vector<const Coordinate*>();
+    ConnectedElementPointFilter c(points);
+    geom->apply_ro(&c);
+    return points;
 }
 
-void ConnectedElementPointFilter::filter_ro(const Geometry *geom) {
-	if ((typeid(*geom)==typeid(Point)) ||
-		(typeid(*geom)==typeid(LineString)) ||
-		(typeid(*geom)==typeid(Polygon)))
-			pts->push_back(geom->getCoordinate());
+void
+ConnectedElementPointFilter::filter_ro(const Geometry* geom)
+{
+    if((typeid(*geom) == typeid(Point)) ||
+            (typeid(*geom) == typeid(LineString)) ||
+            (typeid(*geom) == typeid(Polygon))) {
+        pts->push_back(geom->getCoordinate());
+    }
 }
 
 } // namespace geos.operation.distance
diff --git a/src/operation/distance/DistanceOp.cpp b/src/operation/distance/DistanceOp.cpp
index 93a2e5e..b3f38bd 100644
--- a/src/operation/distance/DistanceOp.cpp
+++ b/src/operation/distance/DistanceOp.cpp
@@ -57,70 +57,70 @@ using namespace geom;
 
 /*public static (deprecated)*/
 double
-DistanceOp::distance(const Geometry *g0, const Geometry *g1)
+DistanceOp::distance(const Geometry* g0, const Geometry* g1)
 {
-	DistanceOp distOp(g0,g1);
-	return distOp.distance();
+    DistanceOp distOp(g0, g1);
+    return distOp.distance();
 }
 
 /*public static*/
 double
 DistanceOp::distance(const Geometry& g0, const Geometry& g1)
 {
-	DistanceOp distOp(g0,g1);
-	return distOp.distance();
+    DistanceOp distOp(g0, g1);
+    return distOp.distance();
 }
 
 /*public static deprecated*/
 CoordinateSequence*
-DistanceOp::closestPoints(const Geometry *g0, const Geometry *g1)
+DistanceOp::closestPoints(const Geometry* g0, const Geometry* g1)
 {
-	DistanceOp distOp(g0,g1);
-	return distOp.nearestPoints();
+    DistanceOp distOp(g0, g1);
+    return distOp.nearestPoints();
 }
 
 /*public static*/
 CoordinateSequence*
-DistanceOp::nearestPoints(const Geometry *g0, const Geometry *g1)
+DistanceOp::nearestPoints(const Geometry* g0, const Geometry* g1)
 {
-	DistanceOp distOp(g0,g1);
-	return distOp.nearestPoints();
+    DistanceOp distOp(g0, g1);
+    return distOp.nearestPoints();
 }
 
-DistanceOp::DistanceOp(const Geometry *g0, const Geometry *g1):
-	geom{g0, g1},
-	terminateDistance(0.0),
-	minDistanceLocation(nullptr),
-	minDistance(DoubleMax)
+DistanceOp::DistanceOp(const Geometry* g0, const Geometry* g1):
+    geom{g0, g1},
+    terminateDistance(0.0),
+    minDistanceLocation(nullptr),
+    minDistance(DoubleMax)
 {}
 
 DistanceOp::DistanceOp(const Geometry& g0, const Geometry& g1):
-	geom{&g0, &g1},
-	terminateDistance(0.0),
-	minDistanceLocation(nullptr),
-	minDistance(DoubleMax)
+    geom{&g0, &g1},
+    terminateDistance(0.0),
+    minDistanceLocation(nullptr),
+    minDistance(DoubleMax)
 {}
 
 DistanceOp::DistanceOp(const Geometry& g0, const Geometry& g1, double tdist)
-	:
-	geom{&g0, &g1},
-	terminateDistance(tdist),
-	minDistanceLocation(nullptr),
-	minDistance(DoubleMax)
+    :
+    geom{&g0, &g1},
+    terminateDistance(tdist),
+    minDistanceLocation(nullptr),
+    minDistance(DoubleMax)
 {}
 
 DistanceOp::~DistanceOp()
 {
-	size_t i;
-	for (i=0; i<newCoords.size(); i++) delete newCoords[i];
-	if ( minDistanceLocation )
-	{
-		for (i=0; i<minDistanceLocation->size(); i++)
-		{
-			delete (*minDistanceLocation)[i];
-		}
-		delete minDistanceLocation;
-	}
+    size_t i;
+    for(i = 0; i < newCoords.size(); i++) {
+        delete newCoords[i];
+    }
+    if(minDistanceLocation) {
+        for(i = 0; i < minDistanceLocation->size(); i++) {
+            delete(*minDistanceLocation)[i];
+        }
+        delete minDistanceLocation;
+    }
 }
 
 /**
@@ -131,20 +131,23 @@ DistanceOp::~DistanceOp()
 double
 DistanceOp::distance()
 {
-	using geos::util::IllegalArgumentException;
-
-	if ( geom[0] == nullptr || geom[1] == nullptr )
-		throw IllegalArgumentException("null geometries are not supported");
-	if ( geom[0]->isEmpty() || geom[1]->isEmpty() ) return 0.0;
-	computeMinDistance();
-	return minDistance;
+    using geos::util::IllegalArgumentException;
+
+    if(geom[0] == nullptr || geom[1] == nullptr) {
+        throw IllegalArgumentException("null geometries are not supported");
+    }
+    if(geom[0]->isEmpty() || geom[1]->isEmpty()) {
+        return 0.0;
+    }
+    computeMinDistance();
+    return minDistance;
 }
 
 /* public */
 CoordinateSequence*
 DistanceOp::closestPoints()
 {
-	return nearestPoints();
+    return nearestPoints();
 }
 
 
@@ -152,89 +155,91 @@ DistanceOp::closestPoints()
 CoordinateSequence*
 DistanceOp::nearestPoints()
 {
-	// lazily creates minDistanceLocation
-	computeMinDistance();
+    // lazily creates minDistanceLocation
+    computeMinDistance();
 
-	assert(nullptr != minDistanceLocation);
-	std::vector<GeometryLocation*>& locs = *minDistanceLocation;
+    assert(nullptr != minDistanceLocation);
+    std::vector<GeometryLocation*>& locs = *minDistanceLocation;
 
-	// Empty input geometries result in this behaviour
-	if ( locs[0] == nullptr || locs[1] == nullptr )
-	{
-		// either both or none are set..
-		assert(locs[0] == nullptr && locs[1] == nullptr);
+    // Empty input geometries result in this behaviour
+    if(locs[0] == nullptr || locs[1] == nullptr) {
+        // either both or none are set..
+        assert(locs[0] == nullptr && locs[1] == nullptr);
 
-		return nullptr;
-	}
+        return nullptr;
+    }
 
-	GeometryLocation* loc0 = locs[0];
-	GeometryLocation* loc1 = locs[1];
-	const Coordinate& c0 = loc0->getCoordinate();
-	const Coordinate& c1 = loc1->getCoordinate();
+    GeometryLocation* loc0 = locs[0];
+    GeometryLocation* loc1 = locs[1];
+    const Coordinate& c0 = loc0->getCoordinate();
+    const Coordinate& c1 = loc1->getCoordinate();
 
-	CoordinateSequence* nearestPts = new CoordinateArraySequence();
-	nearestPts->add(c0);
-	nearestPts->add(c1);
+    CoordinateSequence* nearestPts = new CoordinateArraySequence();
+    nearestPts->add(c0);
+    nearestPts->add(c1);
 
-	return nearestPts;
+    return nearestPts;
 }
 
 /*private, unused!*/
-vector<GeometryLocation*>* DistanceOp::nearestLocations(){
-	computeMinDistance();
-	return minDistanceLocation;
+vector<GeometryLocation*>*
+DistanceOp::nearestLocations()
+{
+    computeMinDistance();
+    return minDistanceLocation;
 }
 
 void
 DistanceOp::updateMinDistance(vector<GeometryLocation*>& locGeom, bool flip)
 {
-	assert(minDistanceLocation);
+    assert(minDistanceLocation);
 
-	// if not set then don't update
-	if (locGeom[0]==nullptr)
-	{
+    // if not set then don't update
+    if(locGeom[0] == nullptr) {
 #if GEOS_DEBUG
-std::cerr << "updateMinDistance called with loc[0] == null and loc[1] == " << locGeom[1] << std::endl;
+        std::cerr << "updateMinDistance called with loc[0] == null and loc[1] == " << locGeom[1] << std::endl;
 #endif
-		assert(locGeom[1] == nullptr);
-		return;
-	}
-
-	delete (*minDistanceLocation)[0];
-	delete (*minDistanceLocation)[1];
-	if (flip) {
-		(*minDistanceLocation)[0]=locGeom[1];
-		(*minDistanceLocation)[1]=locGeom[0];
-	} else {
-		(*minDistanceLocation)[0]=locGeom[0];
-		(*minDistanceLocation)[1]=locGeom[1];
-	}
+        assert(locGeom[1] == nullptr);
+        return;
+    }
+
+    delete(*minDistanceLocation)[0];
+    delete(*minDistanceLocation)[1];
+    if(flip) {
+        (*minDistanceLocation)[0] = locGeom[1];
+        (*minDistanceLocation)[1] = locGeom[0];
+    }
+    else {
+        (*minDistanceLocation)[0] = locGeom[0];
+        (*minDistanceLocation)[1] = locGeom[1];
+    }
 }
 
 /*private*/
 void
 DistanceOp::computeMinDistance()
 {
-	// only compute once!
-	if (minDistanceLocation) return;
+    // only compute once!
+    if(minDistanceLocation) {
+        return;
+    }
 
 #if GEOS_DEBUG
-	std::cerr << "---Start: " << geom[0]->toString() << " - " << geom[1]->toString() << std::endl;
+    std::cerr << "---Start: " << geom[0]->toString() << " - " << geom[1]->toString() << std::endl;
 #endif
 
-	minDistanceLocation = new vector<GeometryLocation*>(2);
+    minDistanceLocation = new vector<GeometryLocation*>(2);
 
-	computeContainmentDistance();
+    computeContainmentDistance();
 
-	if (minDistance <= terminateDistance)
-	{
-		return;
-	}
+    if(minDistance <= terminateDistance) {
+        return;
+    }
 
-	computeFacetDistance();
+    computeFacetDistance();
 
 #if GEOS_DEBUG
-	std::cerr << "---End " << std::endl;
+    std::cerr << "---End " << std::endl;
 #endif
 }
 
@@ -242,379 +247,375 @@ DistanceOp::computeMinDistance()
 void
 DistanceOp::computeContainmentDistance()
 {
-	using geom::util::PolygonExtracter;
+    using geom::util::PolygonExtracter;
 
-	Polygon::ConstVect polys1;
-	PolygonExtracter::getPolygons(*(geom[1]), polys1);
+    Polygon::ConstVect polys1;
+    PolygonExtracter::getPolygons(*(geom[1]), polys1);
 
 
 #if GEOS_DEBUG
-	std::cerr << "PolygonExtracter found " << polys1.size() << " polygons in geometry 2" << std::endl;
+    std::cerr << "PolygonExtracter found " << polys1.size() << " polygons in geometry 2" << std::endl;
 #endif
 
-	// NOTE:
-	// Expected to fill minDistanceLocation items
-	// if minDistance <= terminateDistance
-
-	vector<GeometryLocation*> *locPtPoly = new vector<GeometryLocation*>(2);
-	// test if either geometry has a vertex inside the other
-	if ( ! polys1.empty() )
-	{
-		vector<GeometryLocation*> *insideLocs0 =
-			ConnectedElementLocationFilter::getLocations(geom[0]);
-		computeInside(insideLocs0, polys1, locPtPoly);
-		if (minDistance <= terminateDistance) {
-			assert( (*locPtPoly)[0] );
-			assert( (*locPtPoly)[1] );
-			(*minDistanceLocation)[0] = (*locPtPoly)[0];
-			(*minDistanceLocation)[1] = (*locPtPoly)[1];
-			delete locPtPoly;
-			for (size_t i=0; i<insideLocs0->size(); i++)
-			{
-				GeometryLocation *l = (*insideLocs0)[i];
-				if ( l != (*minDistanceLocation)[0] &&
-					l != (*minDistanceLocation)[1] )
-				{
-					delete l;
-				}
-			}
-			delete insideLocs0;
-			return;
-		}
-		for (size_t i=0; i<insideLocs0->size(); i++)
-			delete (*insideLocs0)[i];
-		delete insideLocs0;
-	}
-
-	Polygon::ConstVect polys0;
-	PolygonExtracter::getPolygons(*(geom[0]), polys0);
+    // NOTE:
+    // Expected to fill minDistanceLocation items
+    // if minDistance <= terminateDistance
+
+    vector<GeometryLocation*>* locPtPoly = new vector<GeometryLocation*>(2);
+    // test if either geometry has a vertex inside the other
+    if(! polys1.empty()) {
+        vector<GeometryLocation*>* insideLocs0 =
+            ConnectedElementLocationFilter::getLocations(geom[0]);
+        computeInside(insideLocs0, polys1, locPtPoly);
+        if(minDistance <= terminateDistance) {
+            assert((*locPtPoly)[0]);
+            assert((*locPtPoly)[1]);
+            (*minDistanceLocation)[0] = (*locPtPoly)[0];
+            (*minDistanceLocation)[1] = (*locPtPoly)[1];
+            delete locPtPoly;
+            for(size_t i = 0; i < insideLocs0->size(); i++) {
+                GeometryLocation* l = (*insideLocs0)[i];
+                if(l != (*minDistanceLocation)[0] &&
+                        l != (*minDistanceLocation)[1]) {
+                    delete l;
+                }
+            }
+            delete insideLocs0;
+            return;
+        }
+        for(size_t i = 0; i < insideLocs0->size(); i++) {
+            delete(*insideLocs0)[i];
+        }
+        delete insideLocs0;
+    }
+
+    Polygon::ConstVect polys0;
+    PolygonExtracter::getPolygons(*(geom[0]), polys0);
 
 #if GEOS_DEBUG
-	std::cerr << "PolygonExtracter found " << polys0.size() << " polygons in geometry 1" << std::endl;
+    std::cerr << "PolygonExtracter found " << polys0.size() << " polygons in geometry 1" << std::endl;
 #endif
 
 
-	if ( ! polys0.empty() )
-	{
-		vector<GeometryLocation*> *insideLocs1 = ConnectedElementLocationFilter::getLocations(geom[1]);
-		computeInside(insideLocs1, polys0, locPtPoly);
-		if (minDistance <= terminateDistance) {
+    if(! polys0.empty()) {
+        vector<GeometryLocation*>* insideLocs1 = ConnectedElementLocationFilter::getLocations(geom[1]);
+        computeInside(insideLocs1, polys0, locPtPoly);
+        if(minDistance <= terminateDistance) {
 // flip locations, since we are testing geom 1 VS geom 0
-			assert( (*locPtPoly)[0] );
-			assert( (*locPtPoly)[1] );
-			(*minDistanceLocation)[0] = (*locPtPoly)[1];
-			(*minDistanceLocation)[1] = (*locPtPoly)[0];
-			delete locPtPoly;
-			for (size_t i=0; i<insideLocs1->size(); i++)
-			{
-				GeometryLocation *l = (*insideLocs1)[i];
-				if ( l != (*minDistanceLocation)[0] &&
-					l != (*minDistanceLocation)[1] )
-				{
-					delete l;
-				}
-			}
-			delete insideLocs1;
-			return;
-		}
-		for (size_t i=0; i<insideLocs1->size(); i++)
-			delete (*insideLocs1)[i];
-		delete insideLocs1;
-	}
-
-	delete locPtPoly;
-
-	// If minDistance <= terminateDistance we must have
-	// set minDistanceLocations to some non-null item
-	assert( minDistance > terminateDistance ||
-	        ( (*minDistanceLocation)[0] && (*minDistanceLocation)[1] ) );
+            assert((*locPtPoly)[0]);
+            assert((*locPtPoly)[1]);
+            (*minDistanceLocation)[0] = (*locPtPoly)[1];
+            (*minDistanceLocation)[1] = (*locPtPoly)[0];
+            delete locPtPoly;
+            for(size_t i = 0; i < insideLocs1->size(); i++) {
+                GeometryLocation* l = (*insideLocs1)[i];
+                if(l != (*minDistanceLocation)[0] &&
+                        l != (*minDistanceLocation)[1]) {
+                    delete l;
+                }
+            }
+            delete insideLocs1;
+            return;
+        }
+        for(size_t i = 0; i < insideLocs1->size(); i++) {
+            delete(*insideLocs1)[i];
+        }
+        delete insideLocs1;
+    }
+
+    delete locPtPoly;
+
+    // If minDistance <= terminateDistance we must have
+    // set minDistanceLocations to some non-null item
+    assert(minDistance > terminateDistance ||
+           ((*minDistanceLocation)[0] && (*minDistanceLocation)[1]));
 }
 
 
 /*private*/
 void
-DistanceOp::computeInside(vector<GeometryLocation*> *locs,
-		const Polygon::ConstVect& polys,
-		vector<GeometryLocation*> *locPtPoly)
+DistanceOp::computeInside(vector<GeometryLocation*>* locs,
+                          const Polygon::ConstVect& polys,
+                          vector<GeometryLocation*>* locPtPoly)
 {
-	for (size_t i=0, ni=locs->size(); i<ni; ++i)
-	{
-		GeometryLocation *loc=(*locs)[i];
-		for (size_t j=0, nj=polys.size(); j<nj; ++j)
-		{
-			computeInside(loc, polys[j], locPtPoly);
-			if (minDistance<=terminateDistance) return;
-		}
-	}
+    for(size_t i = 0, ni = locs->size(); i < ni; ++i) {
+        GeometryLocation* loc = (*locs)[i];
+        for(size_t j = 0, nj = polys.size(); j < nj; ++j) {
+            computeInside(loc, polys[j], locPtPoly);
+            if(minDistance <= terminateDistance) {
+                return;
+            }
+        }
+    }
 }
 
 /*private*/
 void
-DistanceOp::computeInside(GeometryLocation *ptLoc,
-		const Polygon *poly,
-		vector<GeometryLocation*> *locPtPoly)
+DistanceOp::computeInside(GeometryLocation* ptLoc,
+                          const Polygon* poly,
+                          vector<GeometryLocation*>* locPtPoly)
 {
-	const Coordinate &pt=ptLoc->getCoordinate();
-
-	// if pt is not in exterior, distance to geom is 0
-	if (Location::EXTERIOR!=ptLocator.locate(pt, static_cast<const Geometry *>(poly)))
-	{
-		minDistance = 0.0;
-		(*locPtPoly)[0] = ptLoc;
-		GeometryLocation *locPoly = new GeometryLocation(poly, pt);
-		(*locPtPoly)[1] = locPoly;
-		return;
-	}
+    const Coordinate& pt = ptLoc->getCoordinate();
+
+    // if pt is not in exterior, distance to geom is 0
+    if(Location::EXTERIOR != ptLocator.locate(pt, static_cast<const Geometry*>(poly))) {
+        minDistance = 0.0;
+        (*locPtPoly)[0] = ptLoc;
+        GeometryLocation* locPoly = new GeometryLocation(poly, pt);
+        (*locPtPoly)[1] = locPoly;
+        return;
+    }
 }
 
 /*private*/
 void
 DistanceOp::computeFacetDistance()
 {
-	using geom::util::LinearComponentExtracter;
-	using geom::util::PointExtracter;
+    using geom::util::LinearComponentExtracter;
+    using geom::util::PointExtracter;
 
-	vector<GeometryLocation*> locGeom(2);
+    vector<GeometryLocation*> locGeom(2);
 
-	/**
-	 * Geometries are not wholely inside, so compute distance from lines
-	 * and points
-	 * of one to lines and points of the other
-	 */
-	LineString::ConstVect lines0;
-	LineString::ConstVect lines1;
-	LinearComponentExtracter::getLines(*(geom[0]), lines0);
-	LinearComponentExtracter::getLines(*(geom[1]), lines1);
+    /**
+     * Geometries are not wholely inside, so compute distance from lines
+     * and points
+     * of one to lines and points of the other
+     */
+    LineString::ConstVect lines0;
+    LineString::ConstVect lines1;
+    LinearComponentExtracter::getLines(*(geom[0]), lines0);
+    LinearComponentExtracter::getLines(*(geom[1]), lines1);
 
 #if GEOS_DEBUG
-	std::cerr << "LinearComponentExtracter found "
-	          << lines0.size() << " lines in geometry 1 and "
-	          << lines1.size() << " lines in geometry 2 "
-	          << std::endl;
+    std::cerr << "LinearComponentExtracter found "
+              << lines0.size() << " lines in geometry 1 and "
+              << lines1.size() << " lines in geometry 2 "
+              << std::endl;
 #endif
 
-	Point::ConstVect pts0;
-	Point::ConstVect pts1;
-	PointExtracter::getPoints(*(geom[0]), pts0);
-	PointExtracter::getPoints(*(geom[1]), pts1);
+    Point::ConstVect pts0;
+    Point::ConstVect pts1;
+    PointExtracter::getPoints(*(geom[0]), pts0);
+    PointExtracter::getPoints(*(geom[1]), pts1);
 
 #if GEOS_DEBUG
-	std::cerr << "PointExtracter found "
-	          << pts0.size() << " points in geometry 1 and "
-	          << pts1.size() << " points in geometry 2 "
-	          << std::endl;
+    std::cerr << "PointExtracter found "
+              << pts0.size() << " points in geometry 1 and "
+              << pts1.size() << " points in geometry 2 "
+              << std::endl;
 #endif
 
-	// exit whenever minDistance goes LE than terminateDistance
-	computeMinDistanceLines(lines0, lines1, locGeom);
-	updateMinDistance(locGeom, false);
-	if (minDistance <= terminateDistance) {
+    // exit whenever minDistance goes LE than terminateDistance
+    computeMinDistanceLines(lines0, lines1, locGeom);
+    updateMinDistance(locGeom, false);
+    if(minDistance <= terminateDistance) {
 #if GEOS_DEBUG
-		std::cerr << "Early termination after line-line distance" << std::endl;
+        std::cerr << "Early termination after line-line distance" << std::endl;
 #endif
-		return;
-	};
-
-	locGeom[0]=nullptr;
-	locGeom[1]=nullptr;
-	computeMinDistanceLinesPoints(lines0, pts1, locGeom);
-	updateMinDistance(locGeom, false);
-	if (minDistance <= terminateDistance) {
+        return;
+    };
+
+    locGeom[0] = nullptr;
+    locGeom[1] = nullptr;
+    computeMinDistanceLinesPoints(lines0, pts1, locGeom);
+    updateMinDistance(locGeom, false);
+    if(minDistance <= terminateDistance) {
 #if GEOS_DEBUG
-		std::cerr << "Early termination after lines0-points1 distance" << std::endl;
+        std::cerr << "Early termination after lines0-points1 distance" << std::endl;
 #endif
-		return;
-	};
-
-	locGeom[0]=nullptr;
-	locGeom[1]=nullptr;
-	computeMinDistanceLinesPoints(lines1, pts0, locGeom);
-	updateMinDistance(locGeom, true);
-	if (minDistance <= terminateDistance){
+        return;
+    };
+
+    locGeom[0] = nullptr;
+    locGeom[1] = nullptr;
+    computeMinDistanceLinesPoints(lines1, pts0, locGeom);
+    updateMinDistance(locGeom, true);
+    if(minDistance <= terminateDistance) {
 #if GEOS_DEBUG
-		std::cerr << "Early termination after lines1-points0 distance" << std::endl;
+        std::cerr << "Early termination after lines1-points0 distance" << std::endl;
 #endif
-		return;
-	};
+        return;
+    };
 
-	locGeom[0]=nullptr;
-	locGeom[1]=nullptr;
-	computeMinDistancePoints(pts0, pts1, locGeom);
-	updateMinDistance(locGeom, false);
+    locGeom[0] = nullptr;
+    locGeom[1] = nullptr;
+    computeMinDistancePoints(pts0, pts1, locGeom);
+    updateMinDistance(locGeom, false);
 
 #if GEOS_DEBUG
-	std::cerr << "termination after pts-pts distance" << std::endl;
+    std::cerr << "termination after pts-pts distance" << std::endl;
 #endif
 }
 
 /*private*/
 void
 DistanceOp::computeMinDistanceLines(
-		const LineString::ConstVect& lines0,
-		const LineString::ConstVect& lines1,
-		vector<GeometryLocation*>& locGeom)
+    const LineString::ConstVect& lines0,
+    const LineString::ConstVect& lines1,
+    vector<GeometryLocation*>& locGeom)
 {
-	for (size_t i=0, ni=lines0.size(); i<ni; ++i)
-	{
-		const LineString *line0=lines0[i];
-		for (size_t j=0, nj=lines1.size(); j<nj; ++j) {
-			const LineString *line1=lines1[j];
-			computeMinDistance(line0, line1, locGeom);
-			if (minDistance<=terminateDistance) return;
-		}
-	}
+    for(size_t i = 0, ni = lines0.size(); i < ni; ++i) {
+        const LineString* line0 = lines0[i];
+        for(size_t j = 0, nj = lines1.size(); j < nj; ++j) {
+            const LineString* line1 = lines1[j];
+            computeMinDistance(line0, line1, locGeom);
+            if(minDistance <= terminateDistance) {
+                return;
+            }
+        }
+    }
 }
 
 /*private*/
 void
 DistanceOp::computeMinDistancePoints(
-		const Point::ConstVect& points0,
-		const Point::ConstVect& points1,
-		vector<GeometryLocation*>& locGeom)
+    const Point::ConstVect& points0,
+    const Point::ConstVect& points1,
+    vector<GeometryLocation*>& locGeom)
 {
-	for (size_t i=0, ni=points0.size(); i<ni; ++i)
-	{
-		const Point *pt0 = points0[i];
-		for (size_t j=0, nj=points1.size(); j<nj; ++j)
-		{
-			const Point *pt1 = points1[j];
-			double dist = pt0->getCoordinate()->distance(*(pt1->getCoordinate()));
+    for(size_t i = 0, ni = points0.size(); i < ni; ++i) {
+        const Point* pt0 = points0[i];
+        for(size_t j = 0, nj = points1.size(); j < nj; ++j) {
+            const Point* pt1 = points1[j];
+            double dist = pt0->getCoordinate()->distance(*(pt1->getCoordinate()));
 
 #if GEOS_DEBUG
-	std::cerr << "Distance "
-	          << pt0->toString() << " - "
-	          << pt1->toString() << ": "
-	          << dist << ", minDistance: " << minDistance
-	          << std::endl;
+            std::cerr << "Distance "
+                      << pt0->toString() << " - "
+                      << pt1->toString() << ": "
+                      << dist << ", minDistance: " << minDistance
+                      << std::endl;
 #endif
 
-			if (dist < minDistance)
-			{
-				minDistance = dist;
-				// this is wrong - need to determine closest points on both segments!!!
-				delete locGeom[0];
-				locGeom[0] = new GeometryLocation(pt0, 0, *(pt0->getCoordinate()));
-				delete locGeom[1];
-				locGeom[1] = new GeometryLocation(pt1, 0, *(pt1->getCoordinate()));
-			}
-
-			if (minDistance<=terminateDistance) return;
-		}
-	}
+            if(dist < minDistance) {
+                minDistance = dist;
+                // this is wrong - need to determine closest points on both segments!!!
+                delete locGeom[0];
+                locGeom[0] = new GeometryLocation(pt0, 0, *(pt0->getCoordinate()));
+                delete locGeom[1];
+                locGeom[1] = new GeometryLocation(pt1, 0, *(pt1->getCoordinate()));
+            }
+
+            if(minDistance <= terminateDistance) {
+                return;
+            }
+        }
+    }
 }
 
 /*private*/
 void
 DistanceOp::computeMinDistanceLinesPoints(
-		const LineString::ConstVect& lines,
-		const Point::ConstVect& points,
-		vector<GeometryLocation*>& locGeom)
+    const LineString::ConstVect& lines,
+    const Point::ConstVect& points,
+    vector<GeometryLocation*>& locGeom)
 {
-	for (size_t i=0;i<lines.size();i++)
-	{
-		const LineString *line=lines[i];
-		for (size_t j=0;j<points.size();j++)
-		{
-			const Point *pt=points[j];
-			computeMinDistance(line,pt,locGeom);
-			if (minDistance<=terminateDistance) return;
-		}
-	}
+    for(size_t i = 0; i < lines.size(); i++) {
+        const LineString* line = lines[i];
+        for(size_t j = 0; j < points.size(); j++) {
+            const Point* pt = points[j];
+            computeMinDistance(line, pt, locGeom);
+            if(minDistance <= terminateDistance) {
+                return;
+            }
+        }
+    }
 }
 
 /*private*/
 void
 DistanceOp::computeMinDistance(
-		const LineString *line0,
-		const LineString *line1,
-		vector<GeometryLocation*>& locGeom)
+    const LineString* line0,
+    const LineString* line1,
+    vector<GeometryLocation*>& locGeom)
 {
-	using geos::algorithm::Distance;
-
-	const Envelope *env0=line0->getEnvelopeInternal();
-	const Envelope *env1=line1->getEnvelopeInternal();
-	if (env0->distance(env1)>minDistance) {
-		return;
-	}
-
-	const CoordinateSequence *coord0=line0->getCoordinatesRO();
-	const CoordinateSequence *coord1=line1->getCoordinatesRO();
-	size_t npts0=coord0->getSize();
-	size_t npts1=coord1->getSize();
-
-	// brute force approach!
-	for(size_t i=0; i<npts0-1; ++i)
-	{
-		for(size_t j=0; j<npts1-1; ++j)
-		{
-			double dist = Distance::segmentToSegment(coord0->getAt(i),coord0->getAt(i+1),
-				coord1->getAt(j),coord1->getAt(j+1));
-			if (dist < minDistance) {
-				minDistance = dist;
-				LineSegment seg0(coord0->getAt(i), coord0->getAt(i + 1));
-				LineSegment seg1(coord1->getAt(j), coord1->getAt(j + 1));
-				CoordinateSequence* closestPt = seg0.closestPoints(seg1);
-				Coordinate *c1 = new Coordinate(closestPt->getAt(0));
-				Coordinate *c2 = new Coordinate(closestPt->getAt(1));
-				newCoords.push_back(c1);
-				newCoords.push_back(c2);
-				delete closestPt;
-
-				delete locGeom[0];
-				locGeom[0] = new GeometryLocation(line0, i, *c1);
-				delete locGeom[1];
-				locGeom[1] = new GeometryLocation(line1, j, *c2);
-			}
-			if (minDistance<=terminateDistance) return;
-		}
-	}
+    using geos::algorithm::Distance;
+
+    const Envelope* env0 = line0->getEnvelopeInternal();
+    const Envelope* env1 = line1->getEnvelopeInternal();
+    if(env0->distance(env1) > minDistance) {
+        return;
+    }
+
+    const CoordinateSequence* coord0 = line0->getCoordinatesRO();
+    const CoordinateSequence* coord1 = line1->getCoordinatesRO();
+    size_t npts0 = coord0->getSize();
+    size_t npts1 = coord1->getSize();
+
+    // brute force approach!
+    for(size_t i = 0; i < npts0 - 1; ++i) {
+        for(size_t j = 0; j < npts1 - 1; ++j) {
+            double dist = Distance::segmentToSegment(coord0->getAt(i), coord0->getAt(i + 1),
+                          coord1->getAt(j), coord1->getAt(j + 1));
+            if(dist < minDistance) {
+                minDistance = dist;
+                LineSegment seg0(coord0->getAt(i), coord0->getAt(i + 1));
+                LineSegment seg1(coord1->getAt(j), coord1->getAt(j + 1));
+                CoordinateSequence* closestPt = seg0.closestPoints(seg1);
+                Coordinate* c1 = new Coordinate(closestPt->getAt(0));
+                Coordinate* c2 = new Coordinate(closestPt->getAt(1));
+                newCoords.push_back(c1);
+                newCoords.push_back(c2);
+                delete closestPt;
+
+                delete locGeom[0];
+                locGeom[0] = new GeometryLocation(line0, i, *c1);
+                delete locGeom[1];
+                locGeom[1] = new GeometryLocation(line1, j, *c2);
+            }
+            if(minDistance <= terminateDistance) {
+                return;
+            }
+        }
+    }
 }
 
 /*private*/
 void
-DistanceOp::computeMinDistance(const LineString *line,
-		const Point *pt,
-		vector<GeometryLocation*>& locGeom)
+DistanceOp::computeMinDistance(const LineString* line,
+                               const Point* pt,
+                               vector<GeometryLocation*>& locGeom)
 {
-	using geos::algorithm::Distance;
-
-	const Envelope *env0=line->getEnvelopeInternal();
-	const Envelope *env1=pt->getEnvelopeInternal();
-	if (env0->distance(env1)>minDistance) {
-		return;
-	}
-	const CoordinateSequence *coord0=line->getCoordinatesRO();
-	Coordinate *coord=new Coordinate(*(pt->getCoordinate()));
-	newCoords.push_back(coord);
-
-	// brute force approach!
-	size_t npts0=coord0->getSize();
-	for(size_t i=0; i<npts0-1; ++i)
-	{
-		double dist = Distance::pointToSegment(*coord, coord0->getAt(i), coord0->getAt(i+1));
-        	if (dist < minDistance) {
-          		minDistance = dist;
-			LineSegment seg(coord0->getAt(i), coord0->getAt(i + 1));
-			Coordinate segClosestPoint;
-			seg.closestPoint(*coord, segClosestPoint);
-
-			delete locGeom[0];
-			locGeom[0] = new GeometryLocation(line, i, segClosestPoint);
-			delete locGeom[1];
-			locGeom[1] = new GeometryLocation(pt, 0, *coord);
-        	}
-		if (minDistance<=terminateDistance) return;
-	}
+    using geos::algorithm::Distance;
+
+    const Envelope* env0 = line->getEnvelopeInternal();
+    const Envelope* env1 = pt->getEnvelopeInternal();
+    if(env0->distance(env1) > minDistance) {
+        return;
+    }
+    const CoordinateSequence* coord0 = line->getCoordinatesRO();
+    Coordinate* coord = new Coordinate(*(pt->getCoordinate()));
+    newCoords.push_back(coord);
+
+    // brute force approach!
+    size_t npts0 = coord0->getSize();
+    for(size_t i = 0; i < npts0 - 1; ++i) {
+        double dist = Distance::pointToSegment(*coord, coord0->getAt(i), coord0->getAt(i + 1));
+        if(dist < minDistance) {
+            minDistance = dist;
+            LineSegment seg(coord0->getAt(i), coord0->getAt(i + 1));
+            Coordinate segClosestPoint;
+            seg.closestPoint(*coord, segClosestPoint);
+
+            delete locGeom[0];
+            locGeom[0] = new GeometryLocation(line, i, segClosestPoint);
+            delete locGeom[1];
+            locGeom[1] = new GeometryLocation(pt, 0, *coord);
+        }
+        if(minDistance <= terminateDistance) {
+            return;
+        }
+    }
 }
 
 /* public static */
 bool
 DistanceOp::isWithinDistance(const geom::Geometry& g0,
-	                     const geom::Geometry& g1,
-	                     double distance)
+                             const geom::Geometry& g1,
+                             double distance)
 {
-	DistanceOp distOp(g0, g1, distance);
-	return distOp.distance() <= distance;
+    DistanceOp distOp(g0, g1, distance);
+    return distOp.distance() <= distance;
 }
 
 } // namespace geos.operation.distance
diff --git a/src/operation/distance/FacetSequence.cpp b/src/operation/distance/FacetSequence.cpp
index 0ae949f..fc15b1c 100644
--- a/src/operation/distance/FacetSequence.cpp
+++ b/src/operation/distance/FacetSequence.cpp
@@ -24,33 +24,42 @@ using namespace geos::operation::distance;
 using namespace geos::algorithm;
 
 FacetSequence::FacetSequence(const CoordinateSequence* p_pts, size_t p_start, size_t p_end) :
-        pts(p_pts),
-        start(p_start),
-        end(p_end) {
+    pts(p_pts),
+    start(p_start),
+    end(p_end)
+{
     computeEnvelope();
 }
 
-size_t FacetSequence::size() const {
+size_t
+FacetSequence::size() const
+{
     return end - start;
 }
 
-bool FacetSequence::isPoint() const {
+bool
+FacetSequence::isPoint() const
+{
     return end - start == 1;
 }
 
-double FacetSequence::distance(const FacetSequence & facetSeq) const {
+double
+FacetSequence::distance(const FacetSequence& facetSeq) const
+{
     bool isPointThis = isPoint();
     bool isPointOther = facetSeq.isPoint();
 
-    if (isPointThis && isPointOther) {
+    if(isPointThis && isPointOther) {
         Coordinate pt = pts->getAt(start);
         Coordinate seqPt = facetSeq.pts->getAt(facetSeq.start);
         return pt.distance(seqPt);
 
-    } else if (isPointThis) {
+    }
+    else if(isPointThis) {
         Coordinate pt = pts->getAt(start);
         return computePointLineDistance(pt, facetSeq);
-    } else if (isPointOther) {
+    }
+    else if(isPointOther) {
         Coordinate seqPt = facetSeq.pts->getAt(facetSeq.start);
         return computePointLineDistance(seqPt, *this);
     }
@@ -58,61 +67,75 @@ double FacetSequence::distance(const FacetSequence & facetSeq) const {
     return computeLineLineDistance(facetSeq);
 }
 
-double FacetSequence::computePointLineDistance(const Coordinate & pt, const FacetSequence & facetSeq) const {
+double
+FacetSequence::computePointLineDistance(const Coordinate& pt, const FacetSequence& facetSeq) const
+{
     double minDistance = std::numeric_limits<double>::infinity();
     double dist;
     Coordinate q0;
     Coordinate q1;
 
-    for (size_t i = facetSeq.start; i < facetSeq.end - 1; i++) {
+    for(size_t i = facetSeq.start; i < facetSeq.end - 1; i++) {
         facetSeq.pts->getAt(i, q0);
         facetSeq.pts->getAt(i + 1, q1);
         dist = Distance::pointToSegment(pt, q0, q1);
-        if (dist == 0.0)
+        if(dist == 0.0) {
             return dist;
-        if (dist < minDistance)
+        }
+        if(dist < minDistance) {
             minDistance = dist;
+        }
     }
 
     return minDistance;
 }
 
-double FacetSequence::computeLineLineDistance(const FacetSequence & facetSeq) const {
+double
+FacetSequence::computeLineLineDistance(const FacetSequence& facetSeq) const
+{
     double minDistance = std::numeric_limits<double>::infinity();
     double dist;
     Coordinate p0, p1, q0, q1;
 
-    for (size_t i = start; i < end - 1; i++) {
+    for(size_t i = start; i < end - 1; i++) {
         pts->getAt(i, p0);
         pts->getAt(i + 1, p1);
 
-        for (size_t j = facetSeq.start; j < facetSeq.end - 1; j++) {
+        for(size_t j = facetSeq.start; j < facetSeq.end - 1; j++) {
             facetSeq.pts->getAt(j, q0);
             facetSeq.pts->getAt(j + 1, q1);
 
             dist = Distance::segmentToSegment(p0, p1, q0, q1);
-            if (dist == 0.0)
+            if(dist == 0.0) {
                 return dist;
-            if (dist < minDistance)
+            }
+            if(dist < minDistance) {
                 minDistance = dist;
+            }
         }
     }
 
     return minDistance;
 }
 
-void FacetSequence::computeEnvelope() {
+void
+FacetSequence::computeEnvelope()
+{
     env = Envelope();
-    for (size_t i = start; i < end; i++) {
+    for(size_t i = start; i < end; i++) {
         env.expandToInclude(pts->getX(i), pts->getY(i));
     }
 }
 
-const Envelope * FacetSequence::getEnvelope() const {
+const Envelope*
+FacetSequence::getEnvelope() const
+{
     return &env;
 }
 
-const Coordinate * FacetSequence::getCoordinate(size_t index) const {
+const Coordinate*
+FacetSequence::getCoordinate(size_t index) const
+{
     return &(pts->getAt(start + index));
 }
 
diff --git a/src/operation/distance/FacetSequenceTreeBuilder.cpp b/src/operation/distance/FacetSequenceTreeBuilder.cpp
index d7456c2..5ebf85f 100644
--- a/src/operation/distance/FacetSequenceTreeBuilder.cpp
+++ b/src/operation/distance/FacetSequenceTreeBuilder.cpp
@@ -27,10 +27,12 @@ namespace geos {
 namespace operation {
 namespace distance {
 
-STRtree* FacetSequenceTreeBuilder::build(const Geometry* g) {
+STRtree*
+FacetSequenceTreeBuilder::build(const Geometry* g)
+{
     std::unique_ptr<STRtree> tree(new STRtree(STR_TREE_NODE_CAPACITY));
     std::unique_ptr<std::vector<FacetSequence*> > sections(computeFacetSequences(g));
-    for (std::vector<FacetSequence*>::iterator it = sections->begin(); it != sections->end(); ++it) {
+    for(std::vector<FacetSequence*>::iterator it = sections->begin(); it != sections->end(); ++it) {
         FacetSequence* section = *it;
         tree->insert(section->getEnvelope(), section);
     }
@@ -39,7 +41,9 @@ STRtree* FacetSequenceTreeBuilder::build(const Geometry* g) {
     return tree.release();
 }
 
-std::vector<FacetSequence*> * FacetSequenceTreeBuilder::computeFacetSequences(const Geometry* g) {
+std::vector<FacetSequence*>*
+FacetSequenceTreeBuilder::computeFacetSequences(const Geometry* g)
+{
     std::unique_ptr<std::vector<FacetSequence*> > sections(new std::vector<FacetSequence*>());
 
     class FacetSequenceAdder;
@@ -47,13 +51,16 @@ std::vector<FacetSequence*> * FacetSequenceTreeBuilder::computeFacetSequences(co
         std::vector<FacetSequence*>*  m_sections;
 
     public :
-        FacetSequenceAdder(std::vector<FacetSequence*> * p_sections) :
+        FacetSequenceAdder(std::vector<FacetSequence*>* p_sections) :
             m_sections(p_sections) {}
-        void filter_ro(const Geometry* geom) override {
-            if (const LineString* ls = dynamic_cast<const LineString*>(geom)) {
+        void
+        filter_ro(const Geometry* geom) override
+        {
+            if(const LineString* ls = dynamic_cast<const LineString*>(geom)) {
                 const CoordinateSequence* seq = ls->getCoordinatesRO();
                 addFacetSequences(seq, *m_sections);
-            } else if (const Point* pt = dynamic_cast<const Point*>(geom)) {
+            }
+            else if(const Point* pt = dynamic_cast<const Point*>(geom)) {
                 const CoordinateSequence* seq = pt->getCoordinatesRO();
                 addFacetSequences(seq, *m_sections);
             }
@@ -66,16 +73,19 @@ std::vector<FacetSequence*> * FacetSequenceTreeBuilder::computeFacetSequences(co
     return sections.release();
 }
 
-void FacetSequenceTreeBuilder::addFacetSequences(const CoordinateSequence* pts, std::vector<FacetSequence*> & sections) {
+void
+FacetSequenceTreeBuilder::addFacetSequences(const CoordinateSequence* pts, std::vector<FacetSequence*>& sections)
+{
     size_t i = 0;
     size_t size = pts->size();
 
-    while (i <= size - 1) {
+    while(i <= size - 1) {
         size_t end = i + FACET_SEQUENCE_SIZE + 1;
         // if only one point remains after this section, include it in this
         // section
-        if (end >= size - 1)
+        if(end >= size - 1) {
             end = size;
+        }
         FacetSequence* sect = new FacetSequence(pts, i, end);
         sections.push_back(sect);
         i += FACET_SEQUENCE_SIZE;
diff --git a/src/operation/distance/GeometryLocation.cpp b/src/operation/distance/GeometryLocation.cpp
index 4a8116c..185b54e 100644
--- a/src/operation/distance/GeometryLocation.cpp
+++ b/src/operation/distance/GeometryLocation.cpp
@@ -29,30 +29,32 @@ namespace distance { // geos.operation.distance
 * Constructs a GeometryLocation specifying a point on a geometry, as well as the
 * segment that the point is on (or INSIDE_AREA if the point is not on a segment).
 */
-GeometryLocation::GeometryLocation(const Geometry *newComponent, size_t newSegIndex, const Coordinate &newPt)
+GeometryLocation::GeometryLocation(const Geometry* newComponent, size_t newSegIndex, const Coordinate& newPt)
 {
-	component = newComponent;
-	segIndex = newSegIndex;
-	inside_area = false;
-	pt = newPt;
+    component = newComponent;
+    segIndex = newSegIndex;
+    inside_area = false;
+    pt = newPt;
 }
 
 /**
 * Constructs a GeometryLocation specifying a point inside an area geometry.
 */
-GeometryLocation::GeometryLocation(const Geometry *newComponent, const Coordinate &newPt)
+GeometryLocation::GeometryLocation(const Geometry* newComponent, const Coordinate& newPt)
 {
-	component = newComponent;
-	inside_area = true;
-	segIndex = INSIDE_AREA;
-	pt = newPt;
+    component = newComponent;
+    inside_area = true;
+    segIndex = INSIDE_AREA;
+    pt = newPt;
 }
 
 /**
 * Returns the geometry associated with this location.
 */
-const Geometry* GeometryLocation::getGeometryComponent() {
-	return component;
+const Geometry*
+GeometryLocation::getGeometryComponent()
+{
+    return component;
 }
 /**
 * Returns the segment index for this location. If the location is inside an
@@ -63,7 +65,7 @@ const Geometry* GeometryLocation::getGeometryComponent() {
 size_t
 GeometryLocation::getSegmentIndex()
 {
-	return segIndex;
+    return segIndex;
 }
 /**
 * Returns the location.
@@ -71,11 +73,13 @@ GeometryLocation::getSegmentIndex()
 Coordinate&
 GeometryLocation::getCoordinate()
 {
-	return pt;
+    return pt;
 }
 
-bool GeometryLocation::isInsideArea() {
-	return inside_area;
+bool
+GeometryLocation::isInsideArea()
+{
+    return inside_area;
 }
 
 } // namespace geos.operation.distance
diff --git a/src/operation/distance/IndexedFacetDistance.cpp b/src/operation/distance/IndexedFacetDistance.cpp
index 8385226..ca3ea38 100644
--- a/src/operation/distance/IndexedFacetDistance.cpp
+++ b/src/operation/distance/IndexedFacetDistance.cpp
@@ -24,40 +24,52 @@ using namespace geos::geom;
 using namespace geos::index::strtree;
 
 namespace geos {
-    namespace operation {
-        namespace distance {
-            struct Deleter : public index::ItemVisitor {
-                void visitItem(void * item) override {
-                    delete static_cast<FacetSequence*>(item);
-                }
-            } deleter;
+namespace operation {
+namespace distance {
+struct Deleter : public index::ItemVisitor {
+    void
+    visitItem(void* item) override
+    {
+        delete static_cast<FacetSequence*>(item);
+    }
+} deleter;
 
-            double IndexedFacetDistance::distance(const Geometry * g1, const Geometry * g2) {
-                IndexedFacetDistance ifd(g1);
-                return ifd.getDistance(g2);
-            }
+double
+IndexedFacetDistance::distance(const Geometry* g1, const Geometry* g2)
+{
+    IndexedFacetDistance ifd(g1);
+    return ifd.getDistance(g2);
+}
 
-            double IndexedFacetDistance::getDistance(const Geometry * g) const {
-                struct : public ItemDistance {
-                    double distance(const ItemBoundable* item1, const ItemBoundable* item2) override {
-                        return static_cast<const FacetSequence*>(item1->getItem())->distance(*static_cast<const FacetSequence*>(item2->getItem()));
-                    }
-                } itemDistance;
+double
+IndexedFacetDistance::getDistance(const Geometry* g) const
+{
+    struct : public ItemDistance {
+        double
+        distance(const ItemBoundable* item1, const ItemBoundable* item2) override
+        {
+            return static_cast<const FacetSequence*>(item1->getItem())->distance(*static_cast<const FacetSequence*>
+                    (item2->getItem()));
+        }
+    } itemDistance;
 
-                std::unique_ptr<STRtree> tree2(FacetSequenceTreeBuilder::build(g));
+    std::unique_ptr<STRtree> tree2(FacetSequenceTreeBuilder::build(g));
 
-                std::pair<const void*, const void*> obj = cachedTree->nearestNeighbour(tree2.get(), dynamic_cast<ItemDistance*>(&itemDistance));
+    std::pair<const void*, const void*> obj = cachedTree->nearestNeighbour(tree2.get(),
+            dynamic_cast<ItemDistance*>(&itemDistance));
 
-                double p_distance = static_cast<const FacetSequence*>(obj.first)->distance(*static_cast<const FacetSequence*>(obj.second));
+    double p_distance = static_cast<const FacetSequence*>(obj.first)->distance(*static_cast<const FacetSequence*>
+                        (obj.second));
 
-                tree2->iterate(deleter);
+    tree2->iterate(deleter);
 
-                return p_distance;
-            }
+    return p_distance;
+}
 
-            IndexedFacetDistance::~IndexedFacetDistance() {
-                cachedTree->iterate(deleter);
-            }
-        }
-    }
+IndexedFacetDistance::~IndexedFacetDistance()
+{
+    cachedTree->iterate(deleter);
+}
+}
+}
 }
diff --git a/src/operation/intersection/Rectangle.cpp b/src/operation/intersection/Rectangle.cpp
index 46e4253..ebc7c04 100644
--- a/src/operation/intersection/Rectangle.cpp
+++ b/src/operation/intersection/Rectangle.cpp
@@ -24,41 +24,40 @@ namespace geos {
 namespace operation { // geos::operation
 namespace intersection { // geos::operation::intersection
 
-  /*
-   * Create a clipping rectangle
-   */
+/*
+ * Create a clipping rectangle
+ */
 
-  Rectangle::Rectangle(double x1, double y1, double x2, double y2)
-	: xMin(x1)
-	, yMin(y1)
-	, xMax(x2)
-	, yMax(y2)
-  {
-	if(xMin >= xMax || yMin >= yMax)
-	  {
-		throw util::IllegalArgumentException("Clipping rectangle must be non-empty");
-	  }
-  }
+Rectangle::Rectangle(double x1, double y1, double x2, double y2)
+    : xMin(x1)
+    , yMin(y1)
+    , xMax(x2)
+    , yMax(y2)
+{
+    if(xMin >= xMax || yMin >= yMax) {
+        throw util::IllegalArgumentException("Clipping rectangle must be non-empty");
+    }
+}
 
-  geom::Polygon*
-  Rectangle::toPolygon(const geom::GeometryFactory &f) const
-  {
+geom::Polygon*
+Rectangle::toPolygon(const geom::GeometryFactory& f) const
+{
     geom::LinearRing* ls = toLinearRing(f);
     return f.createPolygon(ls, nullptr);
-  }
+}
 
-  geom::LinearRing*
-  Rectangle::toLinearRing(const geom::GeometryFactory &f) const
-  {
-    const geom::CoordinateSequenceFactory *csf = f.getCoordinateSequenceFactory();
-    geom::CoordinateSequence *seq = csf->create(5, 2);
+geom::LinearRing*
+Rectangle::toLinearRing(const geom::GeometryFactory& f) const
+{
+    const geom::CoordinateSequenceFactory* csf = f.getCoordinateSequenceFactory();
+    geom::CoordinateSequence* seq = csf->create(5, 2);
     seq->setAt(geom::Coordinate(xMin, yMin), 0);
     seq->setAt(geom::Coordinate(xMin, yMax), 1);
     seq->setAt(geom::Coordinate(xMax, yMax), 2);
     seq->setAt(geom::Coordinate(xMax, yMin), 3);
     seq->setAt(seq->getAt(0), 4); // close
     return f.createLinearRing(seq);
-  }
+}
 
 } // namespace geos::operation::intersection
 } // namespace geos::operation
diff --git a/src/operation/intersection/RectangleIntersection.cpp b/src/operation/intersection/RectangleIntersection.cpp
index 217d250..e9a84e1 100644
--- a/src/operation/intersection/RectangleIntersection.cpp
+++ b/src/operation/intersection/RectangleIntersection.cpp
@@ -45,9 +45,10 @@ namespace intersection { // geos::operation::intersection
  */
 
 inline
-bool different(double x1, double y1, double x2, double y2)
+bool
+different(double x1, double y1, double x2, double y2)
 {
-  return !(x1==x2 && y1==y2);
+    return !(x1 == x2 && y1 == y2);
 }
 
 /**
@@ -60,18 +61,18 @@ bool different(double x1, double y1, double x2, double y2)
  */
 
 inline
-void clip_one_edge(double & x1, double & y1, double x2, double y2, double limit)
+void
+clip_one_edge(double& x1, double& y1, double x2, double y2, double limit)
 {
-  if (x2 == limit) {
-  	y1 = y2;
-    x1 = x2;
-  }
-
-  if(x1 != x2)
-	{
-	  y1 += (y2-y1)*(limit-x1)/(x2-x1);
-	  x1 = limit;
-	}
+    if(x2 == limit) {
+        y1 = y2;
+        x1 = x2;
+    }
+
+    if(x1 != x2) {
+        y1 += (y2 - y1) * (limit - x1) / (x2 - x1);
+        x1 = limit;
+    }
 }
 
 /**
@@ -84,19 +85,24 @@ void clip_one_edge(double & x1, double & y1, double x2, double y2, double limit)
  *       the rectangle would be very difficult.
  */
 
-void clip_to_edges(double & x1, double & y1,
-				   double x2, double y2,
-				   const Rectangle & rect)
+void
+clip_to_edges(double& x1, double& y1,
+              double x2, double y2,
+              const Rectangle& rect)
 {
-  if(x1 < rect.xmin())
-	clip_one_edge(x1,y1,x2,y2,rect.xmin());
-  else if(x1 > rect.xmax())
-	clip_one_edge(x1,y1,x2,y2,rect.xmax());
-
-  if(y1<rect.ymin())
-	clip_one_edge(y1,x1,y2,x2,rect.ymin());
-  else if(y1>rect.ymax())
-	clip_one_edge(y1,x1,y2,x2,rect.ymax());
+    if(x1 < rect.xmin()) {
+        clip_one_edge(x1, y1, x2, y2, rect.xmin());
+    }
+    else if(x1 > rect.xmax()) {
+        clip_one_edge(x1, y1, x2, y2, rect.xmax());
+    }
+
+    if(y1 < rect.ymin()) {
+        clip_one_edge(y1, x1, y2, x2, rect.ymin());
+    }
+    else if(y1 > rect.ymax()) {
+        clip_one_edge(y1, x1, y2, x2, rect.ymax());
+    }
 }
 
 
@@ -107,268 +113,258 @@ void clip_to_edges(double & x1, double & y1,
  */
 
 void
-RectangleIntersection::clip_point(const geom::Point * g,
-				RectangleIntersectionBuilder & parts,
-				const Rectangle & rect)
+RectangleIntersection::clip_point(const geom::Point* g,
+                                  RectangleIntersectionBuilder& parts,
+                                  const Rectangle& rect)
 {
-  if(g == nullptr)
-	return;
+    if(g == nullptr) {
+        return;
+    }
 
-  double x = g->getX();
-  double y = g->getY();
+    double x = g->getX();
+    double y = g->getY();
 
-  if(rect.position(x,y) == Rectangle::Inside)
-	parts.add(dynamic_cast<geom::Point*>(g->clone()));
+    if(rect.position(x, y) == Rectangle::Inside) {
+        parts.add(dynamic_cast<geom::Point*>(g->clone()));
+    }
 }
 
 bool
-RectangleIntersection::clip_linestring_parts(const geom::LineString * gi,
-						   RectangleIntersectionBuilder & parts,
-						   const Rectangle & rect)
+RectangleIntersection::clip_linestring_parts(const geom::LineString* gi,
+        RectangleIntersectionBuilder& parts,
+        const Rectangle& rect)
 {
-  auto n = gi->getNumPoints();
-
-  if(gi == nullptr || n<1)
-	return false;
-
-  // For shorthand code
-
-  std::vector<Coordinate> cs;
-  gi->getCoordinatesRO()->toVector(cs);
-  //const geom::CoordinateSequence &cs = *(gi->getCoordinatesRO());
-
-  // Keep a record of the point where a line segment entered
-  // the rectangle. If the boolean is set, we must insert
-  // the point to the beginning of the linestring which then
-  // continues inside the rectangle.
-
-  double x0 = 0;
-  double y0 = 0;
-  bool add_start = false;
-
-  // Start iterating
-
-  size_t i = 0;
-
-  while(i<n)
-	{
-	  // Establish initial position
-
-	  double x = cs[i].x;
-	  double y = cs[i].y;
-	  Rectangle::Position pos = rect.position(x,y);
-
-	  if(pos == Rectangle::Outside)
-		{
-		  // Skip points as fast as possible until something has to be checked
-		  // in more detail.
-
-		  ++i;	// we already know it is outside
-
-		  if(x < rect.xmin())
-			while(i < n && cs[i].x < rect.xmin())
-			  ++i;
-
-		  else if(x > rect.xmax())
-			while(i < n && cs[i].x > rect.xmax())
-			  ++i;
-
-		  else if(y < rect.ymin())
-			while(i < n && cs[i].y < rect.ymin())
-			  ++i;
-
-		  else if(y > rect.ymax())
-			while(i < n && cs[i].y > rect.ymax())
-			  ++i;
-
-		  if(i >= n)
-			return false;
-
-		  // Establish new position
-		  x = cs[i].x;
-		  y = cs[i].y;
-		  pos = rect.position(x,y);
-
-		  // Handle all possible cases
-		  x0 = cs[i-1].x;
-		  y0 = cs[i-1].y;
-		  clip_to_edges(x0,y0,x,y,rect);
-
-		  if(pos == Rectangle::Inside)
-			{
-			  add_start = true;	// x0,y0 must have clipped the rectangle
-			  // Main loop will enter the Inside/Edge section
-
-			}
-		  else if(pos == Rectangle::Outside)
-			{
-			  // From Outside to Outside. We need to check whether
-			  // we created a line segment inside the box. In any
-			  // case, we will continue the main loop after this
-			  // which will then enter the Outside section.
-
-			  // Clip the other end too
-			  clip_to_edges(x,y,x0,y0,rect);
-
-			  Rectangle::Position prev_pos = rect.position(x0,y0);
-			  pos = rect.position(x,y);
-
-			  if( different(x0,y0,x,y) &&		// discard corners etc
-				  Rectangle::onEdge(prev_pos) &&		// discard if does not intersect rect
-				  Rectangle::onEdge(pos) &&
-				  !Rectangle::onSameEdge(prev_pos,pos)	// discard if travels along edge
-				  )
-				{
-          std::vector<Coordinate> *coords = new std::vector<Coordinate>(2);
-				  (*coords)[0] = Coordinate(x0,y0);
-				  (*coords)[1] = Coordinate(x,y);
-          CoordinateSequence *seq = _csf->create(coords);
-				  geom::LineString * line = _gf->createLineString(seq);
-				  parts.add(line);
-				}
-
-			  // Continue main loop outside the rect
-
-			}
-		  else
-			{
-			  // From outside to edge. If the edge we hit first when
-			  // following the line is not the edge we end at, then
-			  // clearly we must go through the rectangle and hence
-			  // a start point must be set.
-
-			  Rectangle::Position newpos = rect.position(x0,y0);
-			  if(!Rectangle::onSameEdge(pos,newpos))
-				{
-				  add_start = true;
-				}
-			  else
-				{
-				  // we ignore the travel along the edge and continue
-				  // the main loop at the last edge point
-				}
-			}
-		}
-
-	  else
-		{
-		  // The point is now stricly inside or on the edge.
-		  // Keep iterating until the end or the point goes
-		  // outside. We may have to output partial linestrings
-		  // while iterating until we go strictly outside
-
-		  auto start_index = i;			// 1st valid original point
-		  bool go_outside = false;
-
-		  while(!go_outside && ++i<n)
-			{
-			  x = cs[i].x;
-			  y = cs[i].y;
-
-			  Rectangle::Position prev_pos = pos;
-			  pos = rect.position(x,y);
-
-			  if(pos == Rectangle::Inside)
-				{
-				  // Just keep going
-				}
-			  else if(pos == Rectangle::Outside)
-				{
-				  go_outside = true;
-
-				  // Clip the outside point to edges
-				  clip_to_edges(x, y, cs[i-1].x, cs[i-1].y, rect);
-				  pos = rect.position(x,y);
-
-				  // Does the line exit through the inside of the box?
-
-				  bool through_box = (different(x,y,cs[i].x,cs[i].y) &&
-									  !Rectangle::onSameEdge(prev_pos,pos));
-
-				  // Output a LineString if it at least one segment long
-
-				  if(start_index < i-1 || add_start || through_box)
-					{
-            std::vector<Coordinate> *coords = new std::vector<Coordinate>();
-					  if(add_start)
-						{
-						  coords->push_back(Coordinate(x0, y0));
-						  add_start = false;
-						}
-					  //line->addSubLineString(&g, start_index, i-1);
-            coords->insert(coords->end(), cs.begin()+start_index, cs.begin()+i);
-
-					  if(through_box) coords->push_back(Coordinate(x,y));
-
-            CoordinateSequence *seq = _csf->create(coords);
-            geom::LineString * line = _gf->createLineString(seq);
-					  parts.add(line);
-					}
-				  // And continue main loop on the outside
-				}
-			  else
-				{
-				  // on same edge?
-				  if(Rectangle::onSameEdge(prev_pos,pos))
-					{
-					  // Nothing to output if we haven't been elsewhere
-					  if(start_index < i-1 || add_start)
-						{
-              std::vector<Coordinate> *coords = new std::vector<Coordinate>();
-						  //geom::LineString * line = new geom::LineString();
-						  if(add_start)
-							{
-							  //line->addPoint(x0,y0);
-						    coords->push_back(Coordinate(x0, y0));
-							  add_start = false;
-							}
-						  //line->addSubLineString(&g, start_index, i-1);
-              coords->insert(coords->end(), cs.begin()+start_index, cs.begin()+i);
-
-              CoordinateSequence *seq = _csf->create(coords);
-              geom::LineString * line = _gf->createLineString(seq);
-						  parts.add(line);
-						}
-					  start_index = i;
-					}
-				  else
-					{
-					  // On different edge. Must have gone through the box
-					  // then - keep collecting points that generate inside
-					  // line segments
-					}
-				}
-			}
-
-		  // Was everything in? If so, generate no output but return true in this case only
-		  if(start_index == 0 && i >= n)
-			return true;
-
-		  // Flush the last line segment if data ended and there is something to flush
-
-		  if(!go_outside &&						// meaning data ended
-			 (start_index < i-1 || add_start))	// meaning something has to be generated
-			{
-        std::vector<Coordinate> *coords = new std::vector<Coordinate>();
-			  //geom::LineString * line = new geom::LineString();
-			  if(add_start)
-				{
-				  //line->addPoint(x0,y0);
-					coords->push_back(Coordinate(x0, y0));
-				  add_start = false;
-				}
-			  //line->addSubLineString(&g, start_index, i-1);
-        coords->insert(coords->end(), cs.begin()+start_index, cs.begin()+i);
-
-        CoordinateSequence *seq = _csf->create(coords);
-        geom::LineString * line = _gf->createLineString(seq);
-			  parts.add(line);
-			}
-
-		}
-	}
-
-  return false;
+    auto n = gi->getNumPoints();
+
+    if(gi == nullptr || n < 1) {
+        return false;
+    }
+
+    // For shorthand code
+
+    std::vector<Coordinate> cs;
+    gi->getCoordinatesRO()->toVector(cs);
+    //const geom::CoordinateSequence &cs = *(gi->getCoordinatesRO());
+
+    // Keep a record of the point where a line segment entered
+    // the rectangle. If the boolean is set, we must insert
+    // the point to the beginning of the linestring which then
+    // continues inside the rectangle.
+
+    double x0 = 0;
+    double y0 = 0;
+    bool add_start = false;
+
+    // Start iterating
+
+    size_t i = 0;
+
+    while(i < n) {
+        // Establish initial position
+
+        double x = cs[i].x;
+        double y = cs[i].y;
+        Rectangle::Position pos = rect.position(x, y);
+
+        if(pos == Rectangle::Outside) {
+            // Skip points as fast as possible until something has to be checked
+            // in more detail.
+
+            ++i;	// we already know it is outside
+
+            if(x < rect.xmin())
+                while(i < n && cs[i].x < rect.xmin()) {
+                    ++i;
+                }
+
+            else if(x > rect.xmax())
+                while(i < n && cs[i].x > rect.xmax()) {
+                    ++i;
+                }
+
+            else if(y < rect.ymin())
+                while(i < n && cs[i].y < rect.ymin()) {
+                    ++i;
+                }
+
+            else if(y > rect.ymax())
+                while(i < n && cs[i].y > rect.ymax()) {
+                    ++i;
+                }
+
+            if(i >= n) {
+                return false;
+            }
+
+            // Establish new position
+            x = cs[i].x;
+            y = cs[i].y;
+            pos = rect.position(x, y);
+
+            // Handle all possible cases
+            x0 = cs[i - 1].x;
+            y0 = cs[i - 1].y;
+            clip_to_edges(x0, y0, x, y, rect);
+
+            if(pos == Rectangle::Inside) {
+                add_start = true;	// x0,y0 must have clipped the rectangle
+                // Main loop will enter the Inside/Edge section
+
+            }
+            else if(pos == Rectangle::Outside) {
+                // From Outside to Outside. We need to check whether
+                // we created a line segment inside the box. In any
+                // case, we will continue the main loop after this
+                // which will then enter the Outside section.
+
+                // Clip the other end too
+                clip_to_edges(x, y, x0, y0, rect);
+
+                Rectangle::Position prev_pos = rect.position(x0, y0);
+                pos = rect.position(x, y);
+
+                if(different(x0, y0, x, y) &&		// discard corners etc
+                        Rectangle::onEdge(prev_pos) &&		// discard if does not intersect rect
+                        Rectangle::onEdge(pos) &&
+                        !Rectangle::onSameEdge(prev_pos, pos)	// discard if travels along edge
+                  ) {
+                    std::vector<Coordinate>* coords = new std::vector<Coordinate>(2);
+                    (*coords)[0] = Coordinate(x0, y0);
+                    (*coords)[1] = Coordinate(x, y);
+                    CoordinateSequence* seq = _csf->create(coords);
+                    geom::LineString* line = _gf->createLineString(seq);
+                    parts.add(line);
+                }
+
+                // Continue main loop outside the rect
+
+            }
+            else {
+                // From outside to edge. If the edge we hit first when
+                // following the line is not the edge we end at, then
+                // clearly we must go through the rectangle and hence
+                // a start point must be set.
+
+                Rectangle::Position newpos = rect.position(x0, y0);
+                if(!Rectangle::onSameEdge(pos, newpos)) {
+                    add_start = true;
+                }
+                else {
+                    // we ignore the travel along the edge and continue
+                    // the main loop at the last edge point
+                }
+            }
+        }
+
+        else {
+            // The point is now stricly inside or on the edge.
+            // Keep iterating until the end or the point goes
+            // outside. We may have to output partial linestrings
+            // while iterating until we go strictly outside
+
+            auto start_index = i;			// 1st valid original point
+            bool go_outside = false;
+
+            while(!go_outside && ++i < n) {
+                x = cs[i].x;
+                y = cs[i].y;
+
+                Rectangle::Position prev_pos = pos;
+                pos = rect.position(x, y);
+
+                if(pos == Rectangle::Inside) {
+                    // Just keep going
+                }
+                else if(pos == Rectangle::Outside) {
+                    go_outside = true;
+
+                    // Clip the outside point to edges
+                    clip_to_edges(x, y, cs[i - 1].x, cs[i - 1].y, rect);
+                    pos = rect.position(x, y);
+
+                    // Does the line exit through the inside of the box?
+
+                    bool through_box = (different(x, y, cs[i].x, cs[i].y) &&
+                                        !Rectangle::onSameEdge(prev_pos, pos));
+
+                    // Output a LineString if it at least one segment long
+
+                    if(start_index < i - 1 || add_start || through_box) {
+                        std::vector<Coordinate>* coords = new std::vector<Coordinate>();
+                        if(add_start) {
+                            coords->push_back(Coordinate(x0, y0));
+                            add_start = false;
+                        }
+                        //line->addSubLineString(&g, start_index, i-1);
+                        coords->insert(coords->end(), cs.begin() + start_index, cs.begin() + i);
+
+                        if(through_box) {
+                            coords->push_back(Coordinate(x, y));
+                        }
+
+                        CoordinateSequence* seq = _csf->create(coords);
+                        geom::LineString* line = _gf->createLineString(seq);
+                        parts.add(line);
+                    }
+                    // And continue main loop on the outside
+                }
+                else {
+                    // on same edge?
+                    if(Rectangle::onSameEdge(prev_pos, pos)) {
+                        // Nothing to output if we haven't been elsewhere
+                        if(start_index < i - 1 || add_start) {
+                            std::vector<Coordinate>* coords = new std::vector<Coordinate>();
+                            //geom::LineString * line = new geom::LineString();
+                            if(add_start) {
+                                //line->addPoint(x0,y0);
+                                coords->push_back(Coordinate(x0, y0));
+                                add_start = false;
+                            }
+                            //line->addSubLineString(&g, start_index, i-1);
+                            coords->insert(coords->end(), cs.begin() + start_index, cs.begin() + i);
+
+                            CoordinateSequence* seq = _csf->create(coords);
+                            geom::LineString* line = _gf->createLineString(seq);
+                            parts.add(line);
+                        }
+                        start_index = i;
+                    }
+                    else {
+                        // On different edge. Must have gone through the box
+                        // then - keep collecting points that generate inside
+                        // line segments
+                    }
+                }
+            }
+
+            // Was everything in? If so, generate no output but return true in this case only
+            if(start_index == 0 && i >= n) {
+                return true;
+            }
+
+            // Flush the last line segment if data ended and there is something to flush
+
+            if(!go_outside &&						// meaning data ended
+                    (start_index < i - 1 || add_start)) {	// meaning something has to be generated
+                std::vector<Coordinate>* coords = new std::vector<Coordinate>();
+                //geom::LineString * line = new geom::LineString();
+                if(add_start) {
+                    //line->addPoint(x0,y0);
+                    coords->push_back(Coordinate(x0, y0));
+                    add_start = false;
+                }
+                //line->addSubLineString(&g, start_index, i-1);
+                coords->insert(coords->end(), cs.begin() + start_index, cs.begin() + i);
+
+                CoordinateSequence* seq = _csf->create(coords);
+                geom::LineString* line = _gf->createLineString(seq);
+                parts.add(line);
+            }
+
+        }
+    }
+
+    return false;
 
 }
 
@@ -377,68 +373,64 @@ RectangleIntersection::clip_linestring_parts(const geom::LineString * gi,
  */
 
 void
-RectangleIntersection::clip_polygon_to_linestrings(const geom::Polygon * g,
-								 RectangleIntersectionBuilder & toParts,
-								 const Rectangle & rect)
+RectangleIntersection::clip_polygon_to_linestrings(const geom::Polygon* g,
+        RectangleIntersectionBuilder& toParts,
+        const Rectangle& rect)
 {
-  if(g == nullptr || g->isEmpty())
-	return;
-
-  // Clip the exterior first to see what's going on
-
-  RectangleIntersectionBuilder parts(*_gf);
-
-  // If everything was in, just clone the original
-
-  if(clip_linestring_parts(g->getExteriorRing(), parts, rect))
-	{
-	  toParts.add(dynamic_cast<geom::Polygon *>(g->clone()));
-	  return;
-	}
-
-  // Now, if parts is empty, our rectangle may be inside the polygon
-  // If not, holes are outside too
-
-  if(parts.empty())
-	{
-	  // We could now check whether the rectangle is inside the outer
-	  // ring to avoid checking the holes. However, if holes are much
-	  // smaller than the exterior ring just checking the holes
-	  // separately could be faster.
-
-	  if(g->getNumInteriorRing() == 0)
-		return;
-
-	}
-  else
-	{
-	  // The exterior must have been clipped into linestrings.
-	  // Move them to the actual parts collector, clearing parts.
-
-	  parts.reconnect();
-	  parts.release(toParts);
-	}
-
-  // Handle the holes now:
-  // - Clipped ones become linestrings
-  // - Intact ones become new polygons without holes
-
-  for(size_t i = 0, n = g->getNumInteriorRing(); i < n; ++i)
-	{
-	  if(clip_linestring_parts(g->getInteriorRingN(i), parts, rect))
-		{
-      // clones
-		  LinearRing *hole = dynamic_cast<LinearRing*>(g->getInteriorRingN(i)->clone());
-      // becomes exterior
-		  Polygon *poly = _gf->createPolygon(hole, nullptr);
-		  toParts.add(poly);
-		}
-	  else if(!parts.empty())
-		{
-		  parts.reconnect();
-		  parts.release(toParts);
-		}
-	}
+    if(g == nullptr || g->isEmpty()) {
+        return;
+    }
+
+    // Clip the exterior first to see what's going on
+
+    RectangleIntersectionBuilder parts(*_gf);
+
+    // If everything was in, just clone the original
+
+    if(clip_linestring_parts(g->getExteriorRing(), parts, rect)) {
+        toParts.add(dynamic_cast<geom::Polygon*>(g->clone()));
+        return;
+    }
+
+    // Now, if parts is empty, our rectangle may be inside the polygon
+    // If not, holes are outside too
+
+    if(parts.empty()) {
+        // We could now check whether the rectangle is inside the outer
+        // ring to avoid checking the holes. However, if holes are much
+        // smaller than the exterior ring just checking the holes
+        // separately could be faster.
+
+        if(g->getNumInteriorRing() == 0) {
+            return;
+        }
+
+    }
+    else {
+        // The exterior must have been clipped into linestrings.
+        // Move them to the actual parts collector, clearing parts.
+
+        parts.reconnect();
+        parts.release(toParts);
+    }
+
+    // Handle the holes now:
+    // - Clipped ones become linestrings
+    // - Intact ones become new polygons without holes
+
+    for(size_t i = 0, n = g->getNumInteriorRing(); i < n; ++i) {
+        if(clip_linestring_parts(g->getInteriorRingN(i), parts, rect)) {
+            // clones
+            LinearRing* hole = dynamic_cast<LinearRing*>(g->getInteriorRingN(i)->clone());
+            // becomes exterior
+            Polygon* poly = _gf->createPolygon(hole, nullptr);
+            toParts.add(poly);
+        }
+        else if(!parts.empty()) {
+            parts.reconnect();
+            parts.release(toParts);
+        }
+    }
 }
 
 /**
@@ -446,99 +438,90 @@ RectangleIntersection::clip_polygon_to_linestrings(const geom::Polygon * g,
  */
 
 void
-RectangleIntersection::clip_polygon_to_polygons(const geom::Polygon * g,
-							  RectangleIntersectionBuilder & toParts,
-							  const Rectangle & rect)
+RectangleIntersection::clip_polygon_to_polygons(const geom::Polygon* g,
+        RectangleIntersectionBuilder& toParts,
+        const Rectangle& rect)
 {
-  if(g == nullptr || g->isEmpty())
-	return;
-
-  // Clip the exterior first to see what's going on
-
-  RectangleIntersectionBuilder parts(*_gf);
-
-  // If everything was in, just clone the original
-
-  const LineString *shell = g->getExteriorRing();
-  if(clip_linestring_parts(shell, parts, rect))
-	{
-	  toParts.add(dynamic_cast<geom::Polygon *>(g->clone()));
-	  return;
-	}
-
-  // If there were no intersections, the outer ring might be
-  // completely outside.
-
-  using geos::algorithm::Orientation;
-  if( parts.empty() )
-  {
-    Coordinate rectCenter(rect.xmin(), rect.ymin());
-    rectCenter.x += (rect.xmax()-rect.xmin())/2;
-    rectCenter.y += (rect.ymax()-rect.ymin())/2;
-    if ( PointLocation::locateInRing(rectCenter,
-                          *g->getExteriorRing()->getCoordinatesRO())
-         != Location::INTERIOR )
-    {
-      return;
-    }
-  }
-  else
-  {
-    // TODO: make CCW checking part of clip_linestring_parts ?
-    if ( Orientation::isCCW(shell->getCoordinatesRO()) ) {
-      parts.reverseLines();
-    }
-  }
-
-  // Must do this to make sure all end points are on the edges
-
-  parts.reconnect();
-
-  // Handle the holes now:
-  // - Clipped ones become part of the exterior
-  // - Intact ones become holes in new polygons formed by exterior parts
-
-
-  for(size_t i = 0, n = g->getNumInteriorRing(); i < n; ++i)
-	{
-	  RectangleIntersectionBuilder holeparts(*_gf);
-    const LineString *hole = g->getInteriorRingN(i);
-	  if(clip_linestring_parts(hole, holeparts, rect))
-		{
-      // becomes exterior
-		  LinearRing *cloned = dynamic_cast<LinearRing*>(hole->clone());
-		  Polygon *poly = _gf->createPolygon(cloned, nullptr);
-		  parts.add(poly);
-		}
-	  else
-		{
-		  if(!holeparts.empty())
-			{
+    if(g == nullptr || g->isEmpty()) {
+        return;
+    }
+
+    // Clip the exterior first to see what's going on
+
+    RectangleIntersectionBuilder parts(*_gf);
+
+    // If everything was in, just clone the original
+
+    const LineString* shell = g->getExteriorRing();
+    if(clip_linestring_parts(shell, parts, rect)) {
+        toParts.add(dynamic_cast<geom::Polygon*>(g->clone()));
+        return;
+    }
+
+    // If there were no intersections, the outer ring might be
+    // completely outside.
+
+    using geos::algorithm::Orientation;
+    if(parts.empty()) {
+        Coordinate rectCenter(rect.xmin(), rect.ymin());
+        rectCenter.x += (rect.xmax() - rect.xmin()) / 2;
+        rectCenter.y += (rect.ymax() - rect.ymin()) / 2;
+        if(PointLocation::locateInRing(rectCenter,
+                                       *g->getExteriorRing()->getCoordinatesRO())
+                != Location::INTERIOR) {
+            return;
+        }
+    }
+    else {
         // TODO: make CCW checking part of clip_linestring_parts ?
-        if ( ! Orientation::isCCW(hole->getCoordinatesRO()) ) {
-          holeparts.reverseLines();
+        if(Orientation::isCCW(shell->getCoordinatesRO())) {
+            parts.reverseLines();
         }
-			  holeparts.reconnect();
-			  holeparts.release(parts);
-			}
-		  else
-			{
+    }
 
-        Coordinate rectCenter(rect.xmin(), rect.ymin());
-        rectCenter.x += (rect.xmax()-rect.xmin())/2;
-        rectCenter.y += (rect.ymax()-rect.ymin())/2;
-			  if( PointLocation::isInRing(rectCenter,
-            g->getInteriorRingN(i)->getCoordinatesRO()) )
-				{
-				  // Completely inside the hole
-				  return;
-				}
-			}
-		}
-	}
-
-  parts.reconnectPolygons(rect);
-  parts.release(toParts);
+    // Must do this to make sure all end points are on the edges
+
+    parts.reconnect();
+
+    // Handle the holes now:
+    // - Clipped ones become part of the exterior
+    // - Intact ones become holes in new polygons formed by exterior parts
+
+
+    for(size_t i = 0, n = g->getNumInteriorRing(); i < n; ++i) {
+        RectangleIntersectionBuilder holeparts(*_gf);
+        const LineString* hole = g->getInteriorRingN(i);
+        if(clip_linestring_parts(hole, holeparts, rect)) {
+            // becomes exterior
+            LinearRing* cloned = dynamic_cast<LinearRing*>(hole->clone());
+            Polygon* poly = _gf->createPolygon(cloned, nullptr);
+            parts.add(poly);
+        }
+        else {
+            if(!holeparts.empty()) {
+                // TODO: make CCW checking part of clip_linestring_parts ?
+                if(! Orientation::isCCW(hole->getCoordinatesRO())) {
+                    holeparts.reverseLines();
+                }
+                holeparts.reconnect();
+                holeparts.release(parts);
+            }
+            else {
+
+                Coordinate rectCenter(rect.xmin(), rect.ymin());
+                rectCenter.x += (rect.xmax() - rect.xmin()) / 2;
+                rectCenter.y += (rect.ymax() - rect.ymin()) / 2;
+                if(PointLocation::isInRing(rectCenter,
+                                           g->getInteriorRingN(i)->getCoordinatesRO())) {
+                    // Completely inside the hole
+                    return;
+                }
+            }
+        }
+    }
+
+    parts.reconnectPolygons(rect);
+    parts.release(toParts);
 
 }
 
@@ -547,15 +530,17 @@ RectangleIntersection::clip_polygon_to_polygons(const geom::Polygon * g,
  */
 
 void
-RectangleIntersection::clip_polygon(const geom::Polygon * g,
-				  RectangleIntersectionBuilder & parts,
-				  const Rectangle & rect,
-				  bool keep_polygons)
+RectangleIntersection::clip_polygon(const geom::Polygon* g,
+                                    RectangleIntersectionBuilder& parts,
+                                    const Rectangle& rect,
+                                    bool keep_polygons)
 {
-  if(keep_polygons)
-	clip_polygon_to_polygons(g, parts, rect);
-  else
-	clip_polygon_to_linestrings(g, parts, rect);
+    if(keep_polygons) {
+        clip_polygon_to_polygons(g, parts, rect);
+    }
+    else {
+        clip_polygon_to_linestrings(g, parts, rect);
+    }
 }
 
 /**
@@ -563,149 +548,159 @@ RectangleIntersection::clip_polygon(const geom::Polygon * g,
  */
 
 void
-RectangleIntersection::clip_linestring(const geom::LineString * g,
-					 RectangleIntersectionBuilder & parts,
-					 const Rectangle & rect)
+RectangleIntersection::clip_linestring(const geom::LineString* g,
+                                       RectangleIntersectionBuilder& parts,
+                                       const Rectangle& rect)
 {
-  if(g == nullptr || g->isEmpty())
-	return;
+    if(g == nullptr || g->isEmpty()) {
+        return;
+    }
 
-  // If everything was in, just clone the original
+    // If everything was in, just clone the original
 
-  if(clip_linestring_parts(g, parts, rect))
-	parts.add(dynamic_cast<geom::LineString *>(g->clone()));
+    if(clip_linestring_parts(g, parts, rect)) {
+        parts.add(dynamic_cast<geom::LineString*>(g->clone()));
+    }
 
 }
 
 void
-RectangleIntersection::clip_multipoint(const geom::MultiPoint * g,
-					 RectangleIntersectionBuilder & parts,
-					 const Rectangle & rect)
+RectangleIntersection::clip_multipoint(const geom::MultiPoint* g,
+                                       RectangleIntersectionBuilder& parts,
+                                       const Rectangle& rect)
 {
-  if(g == nullptr || g->isEmpty())
-	return;
-  for(size_t i = 0, n = g->getNumGeometries(); i < n; ++i)
-	{
-	  clip_point(dynamic_cast<const geom::Point *>(g->getGeometryN(i)),
-				 parts, rect);
-	}
+    if(g == nullptr || g->isEmpty()) {
+        return;
+    }
+    for(size_t i = 0, n = g->getNumGeometries(); i < n; ++i) {
+        clip_point(dynamic_cast<const geom::Point*>(g->getGeometryN(i)),
+                   parts, rect);
+    }
 }
 
 void
-RectangleIntersection::clip_multilinestring(const geom::MultiLineString * g,
-						  RectangleIntersectionBuilder & parts,
-						  const Rectangle & rect)
+RectangleIntersection::clip_multilinestring(const geom::MultiLineString* g,
+        RectangleIntersectionBuilder& parts,
+        const Rectangle& rect)
 {
-  if(g == nullptr || g->isEmpty())
-	return;
-
-  for(size_t i = 0, n = g->getNumGeometries(); i < n; ++i)
-	{
-	  clip_linestring(dynamic_cast<const geom::LineString *>(g->getGeometryN(i)),
-					  parts, rect);
-	}
+    if(g == nullptr || g->isEmpty()) {
+        return;
+    }
+
+    for(size_t i = 0, n = g->getNumGeometries(); i < n; ++i) {
+        clip_linestring(dynamic_cast<const geom::LineString*>(g->getGeometryN(i)),
+                        parts, rect);
+    }
 }
 
 void
-RectangleIntersection::clip_multipolygon(const geom::MultiPolygon * g,
-					   RectangleIntersectionBuilder & parts,
-					   const Rectangle & rect,
-					   bool keep_polygons)
+RectangleIntersection::clip_multipolygon(const geom::MultiPolygon* g,
+        RectangleIntersectionBuilder& parts,
+        const Rectangle& rect,
+        bool keep_polygons)
 {
-  if(g == nullptr || g->isEmpty())
-	return;
-
-  for(size_t i = 0, n = g->getNumGeometries(); i < n; ++i)
-	{
-	  clip_polygon(dynamic_cast<const geom::Polygon *>(g->getGeometryN(i)),
-				   parts, rect, keep_polygons);
-	}
+    if(g == nullptr || g->isEmpty()) {
+        return;
+    }
+
+    for(size_t i = 0, n = g->getNumGeometries(); i < n; ++i) {
+        clip_polygon(dynamic_cast<const geom::Polygon*>(g->getGeometryN(i)),
+                     parts, rect, keep_polygons);
+    }
 }
 
 void
 RectangleIntersection::clip_geometrycollection(
-               const geom::GeometryCollection * g,
-							 RectangleIntersectionBuilder & parts,
-							 const Rectangle & rect,
-							 bool keep_polygons)
+    const geom::GeometryCollection* g,
+    RectangleIntersectionBuilder& parts,
+    const Rectangle& rect,
+    bool keep_polygons)
 {
-  if(g == nullptr || g->isEmpty()) return;
+    if(g == nullptr || g->isEmpty()) {
+        return;
+    }
 
-  for(size_t i = 0, n = g->getNumGeometries(); i < n; ++i)
-	{
-	  clip_geom(g->getGeometryN(i),
-				parts, rect, keep_polygons);
-	}
+    for(size_t i = 0, n = g->getNumGeometries(); i < n; ++i) {
+        clip_geom(g->getGeometryN(i),
+                  parts, rect, keep_polygons);
+    }
 }
 
 void
-RectangleIntersection::clip_geom(const geom::Geometry * g,
-			   RectangleIntersectionBuilder & parts,
-			   const Rectangle & rect,
-			   bool keep_polygons)
+RectangleIntersection::clip_geom(const geom::Geometry* g,
+                                 RectangleIntersectionBuilder& parts,
+                                 const Rectangle& rect,
+                                 bool keep_polygons)
 {
-	if ( const Point* p1 = dynamic_cast<const geom::Point *>(g) )
-	  return clip_point(p1, parts, rect);
-	else if ( const MultiPoint* p2 = dynamic_cast<const geom::MultiPoint *>(g) )
-	  return clip_multipoint(p2, parts, rect);
-	else if ( const LineString* p3 = dynamic_cast<const geom::LineString *>(g) )
-	  return clip_linestring(p3, parts, rect);
-	else if ( const MultiLineString* p4 = dynamic_cast<const geom::MultiLineString *>(g) )
-	  return clip_multilinestring(p4, parts, rect);
-	else if ( const Polygon* p5 = dynamic_cast<const geom::Polygon *>(g) )
-	  return clip_polygon(p5, parts, rect, keep_polygons);
-	else if ( const MultiPolygon* p6 = dynamic_cast<const geom::MultiPolygon *>(g) )
-	  return clip_multipolygon(p6, parts, rect, keep_polygons);
-	else if ( const GeometryCollection* p7 = dynamic_cast<const geom::GeometryCollection *>(g) )
-	  return clip_geometrycollection(p7, parts, rect, keep_polygons);
-  else {
-    throw util::UnsupportedOperationException("Encountered an unknown geometry component when clipping polygons");
-  }
+    if(const Point* p1 = dynamic_cast<const geom::Point*>(g)) {
+        return clip_point(p1, parts, rect);
+    }
+    else if(const MultiPoint* p2 = dynamic_cast<const geom::MultiPoint*>(g)) {
+        return clip_multipoint(p2, parts, rect);
+    }
+    else if(const LineString* p3 = dynamic_cast<const geom::LineString*>(g)) {
+        return clip_linestring(p3, parts, rect);
+    }
+    else if(const MultiLineString* p4 = dynamic_cast<const geom::MultiLineString*>(g)) {
+        return clip_multilinestring(p4, parts, rect);
+    }
+    else if(const Polygon* p5 = dynamic_cast<const geom::Polygon*>(g)) {
+        return clip_polygon(p5, parts, rect, keep_polygons);
+    }
+    else if(const MultiPolygon* p6 = dynamic_cast<const geom::MultiPolygon*>(g)) {
+        return clip_multipolygon(p6, parts, rect, keep_polygons);
+    }
+    else if(const GeometryCollection* p7 = dynamic_cast<const geom::GeometryCollection*>(g)) {
+        return clip_geometrycollection(p7, parts, rect, keep_polygons);
+    }
+    else {
+        throw util::UnsupportedOperationException("Encountered an unknown geometry component when clipping polygons");
+    }
 }
 
 /* public static */
 std::unique_ptr<geom::Geometry>
-RectangleIntersection::clipBoundary(const geom::Geometry & g, const Rectangle & rect)
+RectangleIntersection::clipBoundary(const geom::Geometry& g, const Rectangle& rect)
 {
-  RectangleIntersection ri(g,rect);
-  return ri.clipBoundary();
+    RectangleIntersection ri(g, rect);
+    return ri.clipBoundary();
 }
 
 std::unique_ptr<geom::Geometry>
 RectangleIntersection::clipBoundary()
 {
-  RectangleIntersectionBuilder parts(*_gf);
+    RectangleIntersectionBuilder parts(*_gf);
 
-  bool keep_polygons = false;
-  clip_geom(&_geom, parts, _rect, keep_polygons);
+    bool keep_polygons = false;
+    clip_geom(&_geom, parts, _rect, keep_polygons);
 
-  return parts.build();
+    return parts.build();
 }
 
 /* public static */
 std::unique_ptr<geom::Geometry>
-RectangleIntersection::clip(const geom::Geometry & g, const Rectangle & rect)
+RectangleIntersection::clip(const geom::Geometry& g, const Rectangle& rect)
 {
-  RectangleIntersection ri(g,rect);
-  return ri.clip();
+    RectangleIntersection ri(g, rect);
+    return ri.clip();
 }
 
 std::unique_ptr<geom::Geometry>
 RectangleIntersection::clip()
 {
-  RectangleIntersectionBuilder parts(*_gf);
+    RectangleIntersectionBuilder parts(*_gf);
 
-  bool keep_polygons = true;
-  clip_geom(&_geom, parts, _rect, keep_polygons);
+    bool keep_polygons = true;
+    clip_geom(&_geom, parts, _rect, keep_polygons);
 
-  return parts.build();
+    return parts.build();
 }
 
 RectangleIntersection::RectangleIntersection(const geom::Geometry& geom, const Rectangle& rect)
-  : _geom(geom), _rect(rect),
-    _gf(geom.getFactory())
+    : _geom(geom), _rect(rect),
+      _gf(geom.getFactory())
 {
-  _csf = _gf->getCoordinateSequenceFactory();
+    _csf = _gf->getCoordinateSequenceFactory();
 }
 
 } // namespace geos::operation::intersection
diff --git a/src/operation/intersection/RectangleIntersectionBuilder.cpp b/src/operation/intersection/RectangleIntersectionBuilder.cpp
index a80cb5e..f0f4984 100644
--- a/src/operation/intersection/RectangleIntersectionBuilder.cpp
+++ b/src/operation/intersection/RectangleIntersectionBuilder.cpp
@@ -34,141 +34,161 @@ using namespace geos::geom;
 
 RectangleIntersectionBuilder::~RectangleIntersectionBuilder()
 {
-  for (std::list<geom::Polygon *>::iterator i=polygons.begin(), e=polygons.end(); i!=e; ++i)
-	  delete *i;
-  for (std::list<geom::LineString *>::iterator i=lines.begin(), e=lines.end(); i!=e; ++i)
-	  delete *i;
-  for (std::list<geom::Point *>::iterator i=points.begin(), e=points.end(); i!=e; ++i)
-	  delete *i;
+    for(std::list<geom::Polygon*>::iterator i = polygons.begin(), e = polygons.end(); i != e; ++i) {
+        delete *i;
+    }
+    for(std::list<geom::LineString*>::iterator i = lines.begin(), e = lines.end(); i != e; ++i) {
+        delete *i;
+    }
+    for(std::list<geom::Point*>::iterator i = points.begin(), e = points.end(); i != e; ++i) {
+        delete *i;
+    }
 }
 
 void
 RectangleIntersectionBuilder::reconnect()
 {
-  // Nothing to reconnect if there aren't at least two lines
-  if(lines.size() < 2)
-       return;
+    // Nothing to reconnect if there aren't at least two lines
+    if(lines.size() < 2) {
+        return;
+    }
 
-  geom::LineString * line1 = lines.front();
-  const geom::CoordinateSequence &cs1 = *line1->getCoordinatesRO();
+    geom::LineString* line1 = lines.front();
+    const geom::CoordinateSequence& cs1 = *line1->getCoordinatesRO();
 
-  geom::LineString * line2 = lines.back();
-  const geom::CoordinateSequence &cs2 = *line2->getCoordinatesRO();
+    geom::LineString* line2 = lines.back();
+    const geom::CoordinateSequence& cs2 = *line2->getCoordinatesRO();
 
-  const auto n1 = cs1.size();
-  const auto n2 = cs2.size();
+    const auto n1 = cs1.size();
+    const auto n2 = cs2.size();
 
-  // Safety check against bad input to prevent segfaults
-  if(n1==0 || n2==0)
-       return;
+    // Safety check against bad input to prevent segfaults
+    if(n1 == 0 || n2 == 0) {
+        return;
+    }
 
-  if (cs1[0] != cs2[n2-1]) return;
+    if(cs1[0] != cs2[n2 - 1]) {
+        return;
+    }
 
-  // Merge the two linestrings
+    // Merge the two linestrings
 
-  CoordinateSequence *ncs = CoordinateSequence::removeRepeatedPoints(&cs2);
-  ncs->add(&cs1, false, true);
+    CoordinateSequence* ncs = CoordinateSequence::removeRepeatedPoints(&cs2);
+    ncs->add(&cs1, false, true);
 
-  delete line1;
-  delete line2;
+    delete line1;
+    delete line2;
 
-  LineString * nline = _gf.createLineString(ncs);
-  lines.pop_front();
-  lines.pop_back();
+    LineString* nline = _gf.createLineString(ncs);
+    lines.pop_front();
+    lines.pop_back();
 
-  lines.push_front(nline);
+    lines.push_front(nline);
 }
 
 
-void RectangleIntersectionBuilder::release(RectangleIntersectionBuilder & theParts)
+void
+RectangleIntersectionBuilder::release(RectangleIntersectionBuilder& theParts)
 {
-  for (std::list<geom::Polygon *>::iterator i=polygons.begin(), e=polygons.end(); i!=e; ++i)
-	  theParts.add(*i);
+    for(std::list<geom::Polygon*>::iterator i = polygons.begin(), e = polygons.end(); i != e; ++i) {
+        theParts.add(*i);
+    }
 
-  for (std::list<geom::LineString *>::iterator i=lines.begin(), e=lines.end(); i!=e; ++i)
-	  theParts.add(*i);
+    for(std::list<geom::LineString*>::iterator i = lines.begin(), e = lines.end(); i != e; ++i) {
+        theParts.add(*i);
+    }
 
-  for (std::list<geom::Point *>::iterator i=points.begin(), e=points.end(); i!=e; ++i)
-	  theParts.add(*i);
+    for(std::list<geom::Point*>::iterator i = points.begin(), e = points.end(); i != e; ++i) {
+        theParts.add(*i);
+    }
 
-  clear();
+    clear();
 }
 
 /**
  * \brief Clear the parts having transferred ownership elsewhere
  */
 
-void RectangleIntersectionBuilder::clear()
+void
+RectangleIntersectionBuilder::clear()
 {
-  polygons.clear();
-  lines.clear();
-  points.clear();
+    polygons.clear();
+    lines.clear();
+    points.clear();
 }
 
 /**
  * \brief Test if there are no parts at all
  */
 
-bool RectangleIntersectionBuilder::empty() const
+bool
+RectangleIntersectionBuilder::empty() const
 {
-  return polygons.empty() && lines.empty() && points.empty();
+    return polygons.empty() && lines.empty() && points.empty();
 }
 
 /**
  * \brief Add intermediate Polygon
  */
 
-void RectangleIntersectionBuilder::add(geom::Polygon * thePolygon)
+void
+RectangleIntersectionBuilder::add(geom::Polygon* thePolygon)
 {
-  polygons.push_back(thePolygon);
+    polygons.push_back(thePolygon);
 }
 
 /**
  * \brief Add intermediate LineString
  */
 
-void RectangleIntersectionBuilder::add(geom::LineString * theLine)
+void
+RectangleIntersectionBuilder::add(geom::LineString* theLine)
 {
-  lines.push_back(theLine);
+    lines.push_back(theLine);
 }
 
 /**
  * \brief Add intermediate Point
  */
 
-void RectangleIntersectionBuilder::add(geom::Point * thePoint)
+void
+RectangleIntersectionBuilder::add(geom::Point* thePoint)
 {
-  points.push_back(thePoint);
+    points.push_back(thePoint);
 }
 
 std::unique_ptr<geom::Geometry>
 RectangleIntersectionBuilder::build()
 {
-  // Total number of objects
+    // Total number of objects
 
-  std::size_t n = polygons.size() + lines.size() + points.size();
+    std::size_t n = polygons.size() + lines.size() + points.size();
 
-  if(n == 0)
-	return std::unique_ptr<Geometry>(_gf.createGeometryCollection());
+    if(n == 0) {
+        return std::unique_ptr<Geometry>(_gf.createGeometryCollection());
+    }
 
-  std::vector<Geometry *> *geoms = new std::vector<Geometry *>;
-  geoms->reserve(n);
+    std::vector<Geometry*>* geoms = new std::vector<Geometry*>;
+    geoms->reserve(n);
 
-  for (std::list<geom::Polygon *>::iterator i=polygons.begin(), e=polygons.end(); i!=e; ++i)
-      geoms->push_back(*i);
-  polygons.clear();
+    for(std::list<geom::Polygon*>::iterator i = polygons.begin(), e = polygons.end(); i != e; ++i) {
+        geoms->push_back(*i);
+    }
+    polygons.clear();
 
-  for (std::list<geom::LineString *>::iterator i=lines.begin(), e=lines.end(); i!=e; ++i)
-      geoms->push_back(*i);
-  lines.clear();
+    for(std::list<geom::LineString*>::iterator i = lines.begin(), e = lines.end(); i != e; ++i) {
+        geoms->push_back(*i);
+    }
+    lines.clear();
 
-  for (std::list<geom::Point *>::iterator i=points.begin(), e=points.end(); i!=e; ++i)
-      geoms->push_back(*i);
-  points.clear();
+    for(std::list<geom::Point*>::iterator i = points.begin(), e = points.end(); i != e; ++i) {
+        geoms->push_back(*i);
+    }
+    points.clear();
 
-  return std::unique_ptr<Geometry>(
-    (*geoms)[0]->getFactory()->buildGeometry(geoms)
-  );
+    return std::unique_ptr<Geometry>(
+               (*geoms)[0]->getFactory()->buildGeometry(geoms)
+           );
 }
 
 /**
@@ -176,346 +196,336 @@ RectangleIntersectionBuilder::build()
  * along rectangle edges
  */
 
-double distance(const Rectangle & rect,
-				double x1, double y1,
-				double x2, double y2)
+double
+distance(const Rectangle& rect,
+         double x1, double y1,
+         double x2, double y2)
 {
-  double dist = 0;
-
-  Rectangle::Position pos = rect.position(x1,y1);
-  Rectangle::Position endpos = rect.position(x2,y2);
-
-  if (pos & Rectangle::Position::Outside ||
-      endpos & Rectangle::Position::Outside ||
-	  pos & Rectangle::Position::Inside ||
-	  endpos & Rectangle::Position::Inside) {
-  	throw geos::util::IllegalArgumentException("Can't compute distance to non-boundary position.");
-  }
-
-  while(true)
-	{
-	  // Close up when we have the same edge and the
-	  // points are in the correct clockwise order
-	  if((pos & endpos) != 0 &&
-		 (
-		  (x1==rect.xmin() && y2>=y1) ||
-		  (y1==rect.ymax() && x2>=x1) ||
-		  (x1==rect.xmax() && y2<=y1) ||
-		  (y1==rect.ymin() && x2<=x1))
-		  )
-		{
-		  dist += fabs(x2-x1) + fabs(y2-y1);
-		  break;
-		}
-
-	  pos = Rectangle::nextEdge(pos);
-	  if(pos & Rectangle::Left)
-		{
-		  dist += x1-rect.xmin();
-		  x1 = rect.xmin();
-		}
-	  else if(pos & Rectangle::Top)
-		{
-		  dist += rect.ymax()-y1;
-		  y1 = rect.ymax();
-		}
-	  else if(pos & Rectangle::Right)
-		{
-		  dist += rect.xmax()-x1;
-		  x1 = rect.xmax();
-		}
-	  else
-		{
-		  dist += y1-rect.ymin();
-		  y1 = rect.ymin();
-		}
-	}
-  return dist;
+    double dist = 0;
+
+    Rectangle::Position pos = rect.position(x1, y1);
+    Rectangle::Position endpos = rect.position(x2, y2);
+
+    if(pos & Rectangle::Position::Outside ||
+            endpos & Rectangle::Position::Outside ||
+            pos & Rectangle::Position::Inside ||
+            endpos & Rectangle::Position::Inside) {
+        throw geos::util::IllegalArgumentException("Can't compute distance to non-boundary position.");
+    }
+
+    while(true) {
+        // Close up when we have the same edge and the
+        // points are in the correct clockwise order
+        if((pos & endpos) != 0 &&
+                (
+                    (x1 == rect.xmin() && y2 >= y1) ||
+                    (y1 == rect.ymax() && x2 >= x1) ||
+                    (x1 == rect.xmax() && y2 <= y1) ||
+                    (y1 == rect.ymin() && x2 <= x1))
+          ) {
+            dist += fabs(x2 - x1) + fabs(y2 - y1);
+            break;
+        }
+
+        pos = Rectangle::nextEdge(pos);
+        if(pos & Rectangle::Left) {
+            dist += x1 - rect.xmin();
+            x1 = rect.xmin();
+        }
+        else if(pos & Rectangle::Top) {
+            dist += rect.ymax() - y1;
+            y1 = rect.ymax();
+        }
+        else if(pos & Rectangle::Right) {
+            dist += rect.xmax() - x1;
+            x1 = rect.xmax();
+        }
+        else {
+            dist += y1 - rect.ymin();
+            y1 = rect.ymin();
+        }
+    }
+    return dist;
 }
 
-double distance(const Rectangle & rect,
-				const std::vector<Coordinate> &ring,
-				const geom::LineString * line)
+double
+distance(const Rectangle& rect,
+         const std::vector<Coordinate>& ring,
+         const geom::LineString* line)
 {
-  auto nr = ring.size();
-  const Coordinate &c1 = ring[nr-1];
+    auto nr = ring.size();
+    const Coordinate& c1 = ring[nr - 1];
 
-  const CoordinateSequence * linecs = line->getCoordinatesRO();
-  const Coordinate &c2 = linecs->getAt(0);
+    const CoordinateSequence* linecs = line->getCoordinatesRO();
+    const Coordinate& c2 = linecs->getAt(0);
 
-  return distance(rect,c1.x,c1.y,c2.x,c2.y);
+    return distance(rect, c1.x, c1.y, c2.x, c2.y);
 }
 
-double distance(const Rectangle & rect,
-				const std::vector<Coordinate> &ring)
+double
+distance(const Rectangle& rect,
+         const std::vector<Coordinate>& ring)
 {
-  auto nr = ring.size();
-  const Coordinate& c1 = ring[nr-1]; // TODO: ring.back() ?
-  const Coordinate& c2 = ring[0]; // TODO: ring.front() ?
-  return distance(rect, c1.x, c1.y, c2.x, c2.y);
+    auto nr = ring.size();
+    const Coordinate& c1 = ring[nr - 1]; // TODO: ring.back() ?
+    const Coordinate& c2 = ring[0]; // TODO: ring.front() ?
+    return distance(rect, c1.x, c1.y, c2.x, c2.y);
 }
 
 /**
  * \brief Reverse given segment in a coordinate vector
  */
-void reverse_points(std::vector<Coordinate> &v, size_t start, size_t end)
+void
+reverse_points(std::vector<Coordinate>& v, size_t start, size_t end)
 {
-  geom::Coordinate p1;
-  geom::Coordinate p2;
-  while(start < end)
-	{
-    p1 = v[start];
-    p2 = v[end];
-    v[start] = p2;
-    v[end] = p1;
-	  ++start;
-	  --end;
-	}
+    geom::Coordinate p1;
+    geom::Coordinate p2;
+    while(start < end) {
+        p1 = v[start];
+        p2 = v[end];
+        v[start] = p2;
+        v[end] = p1;
+        ++start;
+        --end;
+    }
 }
 
 /**
  * \brief Normalize a ring into lexicographic order
  */
 void
-normalize_ring(std::vector<Coordinate> &ring)
+normalize_ring(std::vector<Coordinate>& ring)
 {
-  if(ring.empty())
-	return;
-
-  // Find the "smallest" coordinate
-
-  size_t best_pos = 0;
-  auto n = ring.size();
-  for(size_t pos = 0; pos < n; ++pos)
-	{
-    // TODO: use CoordinateLessThan ?
-	  if(ring[pos].x < ring[best_pos].x)
-		best_pos = pos;
-	  else if(ring[pos].x == ring[best_pos].x &&
-			  ring[pos].y < ring[best_pos].y )
-		best_pos = pos;
-	}
-
-  // Quick exit if the ring is already normalized
-  if(best_pos == 0) return;
-
-  // Flip hands -algorithm to the part without the
-  // duplicate last coordinate at n-1:
-
-  reverse_points(ring,0, best_pos - 1);
-  reverse_points(ring,best_pos, n - 2);
-	reverse_points(ring,0, n - 2);
-
-  // And make sure the ring is valid by duplicating the first coordinate
-  // at the end:
-
-  geom::Coordinate c;
-  c = ring[0];
-  ring[n-1] = c;
+    if(ring.empty()) {
+        return;
+    }
+
+    // Find the "smallest" coordinate
+
+    size_t best_pos = 0;
+    auto n = ring.size();
+    for(size_t pos = 0; pos < n; ++pos) {
+        // TODO: use CoordinateLessThan ?
+        if(ring[pos].x < ring[best_pos].x) {
+            best_pos = pos;
+        }
+        else if(ring[pos].x == ring[best_pos].x &&
+                ring[pos].y < ring[best_pos].y) {
+            best_pos = pos;
+        }
+    }
+
+    // Quick exit if the ring is already normalized
+    if(best_pos == 0) {
+        return;
+    }
+
+    // Flip hands -algorithm to the part without the
+    // duplicate last coordinate at n-1:
+
+    reverse_points(ring, 0, best_pos - 1);
+    reverse_points(ring, best_pos, n - 2);
+    reverse_points(ring, 0, n - 2);
+
+    // And make sure the ring is valid by duplicating the first coordinate
+    // at the end:
+
+    geom::Coordinate c;
+    c = ring[0];
+    ring[n - 1] = c;
 }
 
 void
 RectangleIntersectionBuilder::close_boundary(
-          const Rectangle & rect,
-					std::vector<Coordinate> * ring,
-					double x1, double y1,
-					double x2, double y2)
+    const Rectangle& rect,
+    std::vector<Coordinate>* ring,
+    double x1, double y1,
+    double x2, double y2)
 {
-  Rectangle::Position endpos = rect.position(x2,y2);
-  Rectangle::Position pos = rect.position(x1,y1);
-
-  while(true)
-	{
-	  // Close up when we have the same edge and the
-	  // points are in the correct clockwise order
-	  if((pos & endpos) != 0 &&
-		 (
-		  (x1==rect.xmin() && y2>=y1) ||
-		  (y1==rect.ymax() && x2>=x1) ||
-		  (x1==rect.xmax() && y2<=y1) ||
-		  (y1==rect.ymin() && x2<=x1))
-		  )
-		{
-		  if(x1!=x2 || y1!=y2)		// the polygon may have started at a corner
-			ring->push_back(Coordinate(x2,y2));
-		  break;
-		}
-
-	  pos = Rectangle::nextEdge(pos);
-	  if(pos & Rectangle::Left)
-		x1 = rect.xmin();
-	  else if(pos & Rectangle::Top)
-		y1 = rect.ymax();
-	  else if(pos & Rectangle::Right)
-		x1 = rect.xmax();
-	  else
-		y1 = rect.ymin();
-
-	  ring->push_back(Coordinate(x1,y1));
-
-	}
+    Rectangle::Position endpos = rect.position(x2, y2);
+    Rectangle::Position pos = rect.position(x1, y1);
+
+    while(true) {
+        // Close up when we have the same edge and the
+        // points are in the correct clockwise order
+        if((pos & endpos) != 0 &&
+                (
+                    (x1 == rect.xmin() && y2 >= y1) ||
+                    (y1 == rect.ymax() && x2 >= x1) ||
+                    (x1 == rect.xmax() && y2 <= y1) ||
+                    (y1 == rect.ymin() && x2 <= x1))
+          ) {
+            if(x1 != x2 || y1 != y2) {	// the polygon may have started at a corner
+                ring->push_back(Coordinate(x2, y2));
+            }
+            break;
+        }
+
+        pos = Rectangle::nextEdge(pos);
+        if(pos & Rectangle::Left) {
+            x1 = rect.xmin();
+        }
+        else if(pos & Rectangle::Top) {
+            y1 = rect.ymax();
+        }
+        else if(pos & Rectangle::Right) {
+            x1 = rect.xmax();
+        }
+        else {
+            y1 = rect.ymin();
+        }
+
+        ring->push_back(Coordinate(x1, y1));
+
+    }
 }
 
 void
-RectangleIntersectionBuilder::close_ring(const Rectangle & rect,
-				std::vector<Coordinate> * ring)
+RectangleIntersectionBuilder::close_ring(const Rectangle& rect,
+        std::vector<Coordinate>* ring)
 {
-  auto nr = ring->size();
-  Coordinate &c2 = (*ring)[0];
-  Coordinate &c1 = (*ring)[nr-1];
-  double x2 = c2.x;
-  double y2 = c2.y;
-  double x1 = c1.x;
-  double y1 = c1.y;
+    auto nr = ring->size();
+    Coordinate& c2 = (*ring)[0];
+    Coordinate& c1 = (*ring)[nr - 1];
+    double x2 = c2.x;
+    double y2 = c2.y;
+    double x1 = c1.x;
+    double y1 = c1.y;
 
-  close_boundary(rect, ring, x1, y1, x2, y2);
+    close_boundary(rect, ring, x1, y1, x2, y2);
 
 }
 
 
 void
-RectangleIntersectionBuilder::reconnectPolygons(const Rectangle & rect)
+RectangleIntersectionBuilder::reconnectPolygons(const Rectangle& rect)
 {
-  // Build the exterior rings first
-
-  typedef std::vector< geom::Geometry *> LinearRingVect;
-  typedef std::pair< geom::LinearRing *, LinearRingVect * > ShellAndHoles;
-  typedef std::list< ShellAndHoles > ShellAndHolesList;
-
-  ShellAndHolesList exterior;
-
-  const CoordinateSequenceFactory &_csf = *_gf.getCoordinateSequenceFactory();
-
-  // If there are no lines, the rectangle must have been
-  // inside the exterior ring.
-
-  if(lines.empty())
-	{
-	  geom::LinearRing * ring = rect.toLinearRing(_gf);
-	  exterior.push_back(make_pair(ring, new LinearRingVect()));
-	}
-  else
-	{
-	  // Reconnect all lines into one or more linearrings
-	  // using box boundaries if necessary
-
-    std::vector<Coordinate> *ring = nullptr;
-
-	  while(!lines.empty() || ring != nullptr)
-		{
-		  if(ring == nullptr)
-			{
-			  ring = new std::vector<Coordinate>();
-			  LineString *line = lines.front();
-			  lines.pop_front();
-        line->getCoordinatesRO()->toVector(*ring);
-			  delete line;
-			}
-
-		  // Distance to own endpoint
-		  double own_distance = distance(rect, *ring);
-
-		  // Find line to connect to
-      // TODO: should we use LineMerge op ?
-		  double best_distance = -1;
-		  std::list<LineString*>::iterator best_pos = lines.begin();
-		  for(std::list<LineString*>::iterator iter=lines.begin(); iter!=lines.end(); ++iter)
-			{
-			  double d = distance(rect, *ring, *iter);
-			  if(best_distance < 0 || d<best_distance)
-				{
-				  best_distance = d;
-				  best_pos = iter;
-				}
-			}
-
-		  // If own end point is closest, close the ring and continue
-		  if(best_distance < 0 || own_distance < best_distance)
-			{
-			  close_ring(rect,ring);
-			  normalize_ring(*ring);
-        geom::CoordinateSequence *shell_cs = _csf.create(ring);
-        geom::LinearRing *shell = _gf.createLinearRing(shell_cs);
-	      exterior.push_back(make_pair(shell, new LinearRingVect()));
-			  ring = nullptr;
-			}
-		  else
-			{
-			  LineString * line = *best_pos;
-			  auto nr = ring->size();
-        const CoordinateSequence& cs = *line->getCoordinatesRO();
-			  close_boundary(rect, ring,
-							 (*ring)[nr-1].x,
-							 (*ring)[nr-1].y,
-							 cs[0].x,
-               cs[0].y);
-        // above function adds the 1st point
-        for (size_t i=1; i<cs.size(); ++i)
-          ring->push_back(cs[i]);
-			  //ring->addSubLineString(line,1);
-			  delete line;
-			  lines.erase(best_pos);
-			}
-		}
-	}
-
-  // Attach holes to polygons
-
-  for (std::list<geom::Polygon *>::iterator i=polygons.begin(), e=polygons.end(); i!=e; ++i)
-	{
-    geom::Polygon *poly = *i;
-    const geom::LineString *hole = poly->getExteriorRing();
-
-	  if(exterior.size() == 1)
-    {
-		  exterior.front().second->push_back( hole->clone() );
+    // Build the exterior rings first
+
+    typedef std::vector< geom::Geometry*> LinearRingVect;
+    typedef std::pair< geom::LinearRing*, LinearRingVect* > ShellAndHoles;
+    typedef std::list< ShellAndHoles > ShellAndHolesList;
+
+    ShellAndHolesList exterior;
+
+    const CoordinateSequenceFactory& _csf = *_gf.getCoordinateSequenceFactory();
+
+    // If there are no lines, the rectangle must have been
+    // inside the exterior ring.
+
+    if(lines.empty()) {
+        geom::LinearRing* ring = rect.toLinearRing(_gf);
+        exterior.push_back(make_pair(ring, new LinearRingVect()));
+    }
+    else {
+        // Reconnect all lines into one or more linearrings
+        // using box boundaries if necessary
+
+        std::vector<Coordinate>* ring = nullptr;
+
+        while(!lines.empty() || ring != nullptr) {
+            if(ring == nullptr) {
+                ring = new std::vector<Coordinate>();
+                LineString* line = lines.front();
+                lines.pop_front();
+                line->getCoordinatesRO()->toVector(*ring);
+                delete line;
+            }
+
+            // Distance to own endpoint
+            double own_distance = distance(rect, *ring);
+
+            // Find line to connect to
+            // TODO: should we use LineMerge op ?
+            double best_distance = -1;
+            std::list<LineString*>::iterator best_pos = lines.begin();
+            for(std::list<LineString*>::iterator iter = lines.begin(); iter != lines.end(); ++iter) {
+                double d = distance(rect, *ring, *iter);
+                if(best_distance < 0 || d < best_distance) {
+                    best_distance = d;
+                    best_pos = iter;
+                }
+            }
+
+            // If own end point is closest, close the ring and continue
+            if(best_distance < 0 || own_distance < best_distance) {
+                close_ring(rect, ring);
+                normalize_ring(*ring);
+                geom::CoordinateSequence* shell_cs = _csf.create(ring);
+                geom::LinearRing* shell = _gf.createLinearRing(shell_cs);
+                exterior.push_back(make_pair(shell, new LinearRingVect()));
+                ring = nullptr;
+            }
+            else {
+                LineString* line = *best_pos;
+                auto nr = ring->size();
+                const CoordinateSequence& cs = *line->getCoordinatesRO();
+                close_boundary(rect, ring,
+                               (*ring)[nr - 1].x,
+                               (*ring)[nr - 1].y,
+                               cs[0].x,
+                               cs[0].y);
+                // above function adds the 1st point
+                for(size_t i = 1; i < cs.size(); ++i) {
+                    ring->push_back(cs[i]);
+                }
+                //ring->addSubLineString(line,1);
+                delete line;
+                lines.erase(best_pos);
+            }
+        }
     }
-	  else
-		{
-      using geos::algorithm::PointLocation;
-		  geom::Coordinate c;
-		  hole->getCoordinatesRO()->getAt(0, c);
-      for (ShellAndHolesList::iterator p_i=exterior.begin(), p_e=exterior.end(); p_i!=p_e; ++p_i)
-			{
-        ShellAndHoles &p = *p_i;
-        const CoordinateSequence *shell_cs = p.first->getCoordinatesRO();
-        if( PointLocation::isInRing(c, shell_cs) )
-        {
-          // add hole to shell
-          p.second->push_back(hole->clone());
-				  break;
+
+    // Attach holes to polygons
+
+    for(std::list<geom::Polygon*>::iterator i = polygons.begin(), e = polygons.end(); i != e; ++i) {
+        geom::Polygon* poly = *i;
+        const geom::LineString* hole = poly->getExteriorRing();
+
+        if(exterior.size() == 1) {
+            exterior.front().second->push_back(hole->clone());
+        }
+        else {
+            using geos::algorithm::PointLocation;
+            geom::Coordinate c;
+            hole->getCoordinatesRO()->getAt(0, c);
+            for(ShellAndHolesList::iterator p_i = exterior.begin(), p_e = exterior.end(); p_i != p_e; ++p_i) {
+                ShellAndHoles& p = *p_i;
+                const CoordinateSequence* shell_cs = p.first->getCoordinatesRO();
+                if(PointLocation::isInRing(c, shell_cs)) {
+                    // add hole to shell
+                    p.second->push_back(hole->clone());
+                    break;
+                }
+            }
         }
-			}
-		}
 
-		delete poly;
-	}
+        delete poly;
+    }
 
-  // Build the result polygons
+    // Build the result polygons
 
-  std::list<geom::Polygon *> new_polygons;
-  for (ShellAndHolesList::iterator i=exterior.begin(), e=exterior.end(); i!=e; ++i)
-  {
-    ShellAndHoles &p = *i;
-	  geom::Polygon * poly = _gf.createPolygon(p.first, p.second);
-	  new_polygons.push_back(poly);
-  }
+    std::list<geom::Polygon*> new_polygons;
+    for(ShellAndHolesList::iterator i = exterior.begin(), e = exterior.end(); i != e; ++i) {
+        ShellAndHoles& p = *i;
+        geom::Polygon* poly = _gf.createPolygon(p.first, p.second);
+        new_polygons.push_back(poly);
+    }
 
-  clear();
-  polygons = new_polygons;
+    clear();
+    polygons = new_polygons;
 }
 
 void
 RectangleIntersectionBuilder::reverseLines()
 {
-  std::list<geom::LineString *> new_lines;
-  for (std::list<geom::LineString *>::reverse_iterator i=lines.rbegin(), e=lines.rend(); i!=e; ++i)
-  {
-    LineString *ol = *i;
-    new_lines.push_back(dynamic_cast<LineString*>(ol->reverse()));
-    delete ol;
-  }
-  lines = new_lines;
+    std::list<geom::LineString*> new_lines;
+    for(std::list<geom::LineString*>::reverse_iterator i = lines.rbegin(), e = lines.rend(); i != e; ++i) {
+        LineString* ol = *i;
+        new_lines.push_back(dynamic_cast<LineString*>(ol->reverse()));
+        delete ol;
+    }
+    lines = new_lines;
 }
 
 
diff --git a/src/operation/linemerge/EdgeString.cpp b/src/operation/linemerge/EdgeString.cpp
index e59e1fd..65123b0 100644
--- a/src/operation/linemerge/EdgeString.cpp
+++ b/src/operation/linemerge/EdgeString.cpp
@@ -40,52 +40,54 @@ namespace linemerge { // geos.operation.linemerge
  * Constructs an EdgeString with the given factory used to convert
  * this EdgeString to a LineString
  */
-EdgeString::EdgeString(const GeometryFactory *newFactory):
-	factory(newFactory),
-	directedEdges(),
-	coordinates(nullptr)
+EdgeString::EdgeString(const GeometryFactory* newFactory):
+    factory(newFactory),
+    directedEdges(),
+    coordinates(nullptr)
 {
 }
 
-EdgeString::~EdgeString() {
+EdgeString::~EdgeString()
+{
 }
 
 /**
  * Adds a directed edge which is known to form part of this line.
  */
 void
-EdgeString::add(LineMergeDirectedEdge *directedEdge)
+EdgeString::add(LineMergeDirectedEdge* directedEdge)
 {
-	directedEdges.push_back(directedEdge);
+    directedEdges.push_back(directedEdge);
 }
 
-CoordinateSequence *
+CoordinateSequence*
 EdgeString::getCoordinates()
 {
-	if (coordinates==nullptr) {
-		int forwardDirectedEdges = 0;
-		int reverseDirectedEdges = 0;
-		coordinates=factory->getCoordinateSequenceFactory()->create();
-		for (std::size_t i=0, e=directedEdges.size(); i<e; ++i) {
-			LineMergeDirectedEdge* directedEdge = directedEdges[i];
-			if (directedEdge->getEdgeDirection()) {
-				forwardDirectedEdges++;
-			} else {
-				reverseDirectedEdges++;
-			}
+    if(coordinates == nullptr) {
+        int forwardDirectedEdges = 0;
+        int reverseDirectedEdges = 0;
+        coordinates = factory->getCoordinateSequenceFactory()->create();
+        for(std::size_t i = 0, e = directedEdges.size(); i < e; ++i) {
+            LineMergeDirectedEdge* directedEdge = directedEdges[i];
+            if(directedEdge->getEdgeDirection()) {
+                forwardDirectedEdges++;
+            }
+            else {
+                reverseDirectedEdges++;
+            }
 
-			assert(dynamic_cast<LineMergeEdge*>(directedEdge->getEdge()));
-			LineMergeEdge* lme=static_cast<LineMergeEdge*>( directedEdge->getEdge());
+            assert(dynamic_cast<LineMergeEdge*>(directedEdge->getEdge()));
+            LineMergeEdge* lme = static_cast<LineMergeEdge*>(directedEdge->getEdge());
 
-			coordinates->add(lme->getLine()->getCoordinatesRO(),
-					false,
-					directedEdge->getEdgeDirection());
-		}
-		if (reverseDirectedEdges > forwardDirectedEdges) {
-			CoordinateSequence::reverse(coordinates);
-		}
-	}
-	return coordinates;
+            coordinates->add(lme->getLine()->getCoordinatesRO(),
+                             false,
+                             directedEdge->getEdgeDirection());
+        }
+        if(reverseDirectedEdges > forwardDirectedEdges) {
+            CoordinateSequence::reverse(coordinates);
+        }
+    }
+    return coordinates;
 }
 
 /*
@@ -94,7 +96,7 @@ EdgeString::getCoordinates()
 LineString*
 EdgeString::toLineString()
 {
-	return factory->createLineString(getCoordinates());
+    return factory->createLineString(getCoordinates());
 }
 
 } // namespace geos.operation.linemerge
diff --git a/src/operation/linemerge/LineMergeDirectedEdge.cpp b/src/operation/linemerge/LineMergeDirectedEdge.cpp
index 0016826..4d54002 100644
--- a/src/operation/linemerge/LineMergeDirectedEdge.cpp
+++ b/src/operation/linemerge/LineMergeDirectedEdge.cpp
@@ -31,13 +31,13 @@ namespace operation { // geos.operation
 namespace linemerge { // geos.operation.linemerge
 
 LineMergeDirectedEdge::LineMergeDirectedEdge(
-		planargraph::Node *newFrom,
-		planargraph::Node *newTo,
-		const Coordinate& newDirectionPt,
-		bool nEdgeDirection)
-	:
-	planargraph::DirectedEdge(newFrom, newTo,
-			newDirectionPt, nEdgeDirection)
+    planargraph::Node* newFrom,
+    planargraph::Node* newTo,
+    const Coordinate& newDirectionPt,
+    bool nEdgeDirection)
+    :
+    planargraph::DirectedEdge(newFrom, newTo,
+                              newDirectionPt, nEdgeDirection)
 {}
 
 /**
@@ -48,18 +48,18 @@ LineMergeDirectedEdge::LineMergeDirectedEdge(
 LineMergeDirectedEdge*
 LineMergeDirectedEdge::getNext()
 {
-	if (getToNode()->getDegree()!=2) {
-		return nullptr;
-	}
-	if (getToNode()->getOutEdges()->getEdges()[0]==getSym()) {
-		return (LineMergeDirectedEdge*) getToNode()->getOutEdges()->getEdges()[1];
-	}
-	assert(getToNode()->getOutEdges()->getEdges()[1]==getSym());
+    if(getToNode()->getDegree() != 2) {
+        return nullptr;
+    }
+    if(getToNode()->getOutEdges()->getEdges()[0] == getSym()) {
+        return (LineMergeDirectedEdge*) getToNode()->getOutEdges()->getEdges()[1];
+    }
+    assert(getToNode()->getOutEdges()->getEdges()[1] == getSym());
 
-	LineMergeDirectedEdge* nextedge = dynamic_cast<LineMergeDirectedEdge*>(getToNode()->getOutEdges()->getEdges()[0]);
-	assert(nextedge);
+    LineMergeDirectedEdge* nextedge = dynamic_cast<LineMergeDirectedEdge*>(getToNode()->getOutEdges()->getEdges()[0]);
+    assert(nextedge);
 
-	return nextedge;
+    return nextedge;
 }
 
 } // namespace geos.operation.linemerge
diff --git a/src/operation/linemerge/LineMergeEdge.cpp b/src/operation/linemerge/LineMergeEdge.cpp
index 81c8248..28b5b5f 100644
--- a/src/operation/linemerge/LineMergeEdge.cpp
+++ b/src/operation/linemerge/LineMergeEdge.cpp
@@ -28,18 +28,19 @@ namespace linemerge { // geos.operation.linemerge
 /**
 * Constructs a LineMergeEdge with vertices given by the specified LineString.
 */
-LineMergeEdge::LineMergeEdge(const LineString *newLine):
-	line(newLine)
+LineMergeEdge::LineMergeEdge(const LineString* newLine):
+    line(newLine)
 {
-	//line=newLine;
+    //line=newLine;
 }
 
 /**
  * Returns the LineString specifying the vertices of this edge.
  */
-const LineString *
-LineMergeEdge::getLine() const {
-	return line;
+const LineString*
+LineMergeEdge::getLine() const
+{
+    return line;
 }
 
 } // namespace geos.operation.linemerge
diff --git a/src/operation/linemerge/LineMergeGraph.cpp b/src/operation/linemerge/LineMergeGraph.cpp
index 4d5f9b5..7585087 100644
--- a/src/operation/linemerge/LineMergeGraph.cpp
+++ b/src/operation/linemerge/LineMergeGraph.cpp
@@ -46,82 +46,89 @@ namespace operation { // geos.operation
 namespace linemerge { // geos.operation.linemerge
 
 void
-LineMergeGraph::addEdge(const LineString *lineString)
+LineMergeGraph::addEdge(const LineString* lineString)
 {
-	if (lineString->isEmpty()) return;
+    if(lineString->isEmpty()) {
+        return;
+    }
 
 #if GEOS_DEBUG
-	cerr<<"Adding LineString "<<lineString->toString()<<endl;
+    cerr << "Adding LineString " << lineString->toString() << endl;
 #endif
 
-	std::unique_ptr<CoordinateSequence> coordinates (
-		CoordinateSequence::removeRepeatedPoints(lineString->getCoordinatesRO())
-	);
+    std::unique_ptr<CoordinateSequence> coordinates(
+        CoordinateSequence::removeRepeatedPoints(lineString->getCoordinatesRO())
+    );
 
-	std::size_t nCoords = coordinates->size(); // virtual call..
+    std::size_t nCoords = coordinates->size(); // virtual call..
 
-	// don't add lines with all coordinates equal
-	if ( nCoords <= 1 ) return;
+    // don't add lines with all coordinates equal
+    if(nCoords <= 1) {
+        return;
+    }
 
-	const Coordinate& startCoordinate = coordinates->getAt(0);
-	const Coordinate& endCoordinate = coordinates->getAt(nCoords-1);
+    const Coordinate& startCoordinate = coordinates->getAt(0);
+    const Coordinate& endCoordinate = coordinates->getAt(nCoords - 1);
 
-	planargraph::Node* startNode=getNode(startCoordinate);
-	planargraph::Node* endNode=getNode(endCoordinate);
+    planargraph::Node* startNode = getNode(startCoordinate);
+    planargraph::Node* endNode = getNode(endCoordinate);
 #if GEOS_DEBUG
-	cerr<<" startNode: "<<*startNode<<endl;
-	cerr<<" endNode: "<<*endNode<<endl;
+    cerr << " startNode: " << *startNode << endl;
+    cerr << " endNode: " << *endNode << endl;
 #endif
 
-	planargraph::DirectedEdge *directedEdge0=new LineMergeDirectedEdge(startNode,
-			endNode,coordinates->getAt(1),
-			true);
-	newDirEdges.push_back(directedEdge0);
+    planargraph::DirectedEdge* directedEdge0 = new LineMergeDirectedEdge(startNode,
+            endNode, coordinates->getAt(1),
+            true);
+    newDirEdges.push_back(directedEdge0);
 
-	planargraph::DirectedEdge *directedEdge1=new LineMergeDirectedEdge(endNode,
-			startNode,coordinates->getAt(nCoords - 2),
-			false);
-	newDirEdges.push_back(directedEdge1);
+    planargraph::DirectedEdge* directedEdge1 = new LineMergeDirectedEdge(endNode,
+            startNode, coordinates->getAt(nCoords - 2),
+            false);
+    newDirEdges.push_back(directedEdge1);
 
-	planargraph::Edge *edge=new LineMergeEdge(lineString);
-	newEdges.push_back(edge);
-	edge->setDirectedEdges(directedEdge0, directedEdge1);
+    planargraph::Edge* edge = new LineMergeEdge(lineString);
+    newEdges.push_back(edge);
+    edge->setDirectedEdges(directedEdge0, directedEdge1);
 
 #if GEOS_DEBUG
-	cerr<<" planargraph::Edge: "<<*edge<<endl;
+    cerr << " planargraph::Edge: " << *edge << endl;
 #endif
 
-	add(edge);
+    add(edge);
 
 #if GEOS_DEBUG
-	cerr<<" After addition to the graph:"<<endl;
-	cerr<<"  startNode: "<<*startNode<<endl;
-	cerr<<"  endNode: "<<*endNode<<endl;
+    cerr << " After addition to the graph:" << endl;
+    cerr << "  startNode: " << *startNode << endl;
+    cerr << "  endNode: " << *endNode << endl;
 #endif
 
 }
 
-planargraph::Node *
-LineMergeGraph::getNode(const Coordinate &coordinate)
+planargraph::Node*
+LineMergeGraph::getNode(const Coordinate& coordinate)
 {
-	planargraph::Node *node=findNode(coordinate);
-	if (node==nullptr) {
-		node=new planargraph::Node(coordinate);
-		newNodes.push_back(node);
-		add(node);
-	}
-	return node;
+    planargraph::Node* node = findNode(coordinate);
+    if(node == nullptr) {
+        node = new planargraph::Node(coordinate);
+        newNodes.push_back(node);
+        add(node);
+    }
+    return node;
 }
 
 LineMergeGraph::~LineMergeGraph()
 {
-	unsigned int i;
-	for (i=0; i<newNodes.size(); i++)
-		delete newNodes[i];
-	for (i=0; i<newEdges.size(); i++)
-		delete newEdges[i];
-	for (i=0; i<newDirEdges.size(); i++)
-		delete newDirEdges[i];
+    unsigned int i;
+    for(i = 0; i < newNodes.size(); i++) {
+        delete newNodes[i];
+    }
+    for(i = 0; i < newEdges.size(); i++) {
+        delete newEdges[i];
+    }
+    for(i = 0; i < newDirEdges.size(); i++) {
+        delete newDirEdges[i];
+    }
 }
 
 } // namespace geos.operation.linemerge
diff --git a/src/operation/linemerge/LineMerger.cpp b/src/operation/linemerge/LineMerger.cpp
index e1fdc88..c3e3388 100644
--- a/src/operation/linemerge/LineMerger.cpp
+++ b/src/operation/linemerge/LineMerger.cpp
@@ -44,37 +44,41 @@ namespace operation { // geos.operation
 namespace linemerge { // geos.operation.linemerge
 
 void
-LineMerger::add(vector<Geometry*> *geometries)
+LineMerger::add(vector<Geometry*>* geometries)
 {
-	for(size_t i=0, n=geometries->size(); i<n; i++) {
-		Geometry *geometry=(*geometries)[i];
-		add(geometry);
-	}
+    for(size_t i = 0, n = geometries->size(); i < n; i++) {
+        Geometry* geometry = (*geometries)[i];
+        add(geometry);
+    }
 }
 
 LineMerger::LineMerger():
-	mergedLineStrings(nullptr),
-	factory(nullptr)
+    mergedLineStrings(nullptr),
+    factory(nullptr)
 {
 }
 
 LineMerger::~LineMerger()
 {
-	for (size_t i=0, n=edgeStrings.size(); i<n; ++i) {
-		delete edgeStrings[i];
-	}
+    for(size_t i = 0, n = edgeStrings.size(); i < n; ++i) {
+        delete edgeStrings[i];
+    }
 }
 
 
 struct LMGeometryComponentFilter: public GeometryComponentFilter {
-	LineMerger *lm;
-
-	LMGeometryComponentFilter(LineMerger *newLm): lm(newLm) {}
-
-	void filter(const Geometry *geom) {
-		const LineString *ls = dynamic_cast<const LineString *>(geom);
-		if ( ls ) lm->add(ls);
-	}
+    LineMerger* lm;
+
+    LMGeometryComponentFilter(LineMerger* newLm): lm(newLm) {}
+
+    void
+    filter(const Geometry* geom)
+    {
+        const LineString* ls = dynamic_cast<const LineString*>(geom);
+        if(ls) {
+            lm->add(ls);
+        }
+    }
 };
 
 
@@ -84,137 +88,141 @@ struct LMGeometryComponentFilter: public GeometryComponentFilter {
  * extracted.
  */
 void
-LineMerger::add(const Geometry *geometry)
+LineMerger::add(const Geometry* geometry)
 {
-	LMGeometryComponentFilter lmgcf(this);
-	geometry->applyComponentFilter(lmgcf);
+    LMGeometryComponentFilter lmgcf(this);
+    geometry->applyComponentFilter(lmgcf);
 }
 
 void
-LineMerger::add(const LineString *lineString)
+LineMerger::add(const LineString* lineString)
 {
-	if (factory==nullptr) factory=lineString->getFactory();
-	graph.addEdge(lineString);
+    if(factory == nullptr) {
+        factory = lineString->getFactory();
+    }
+    graph.addEdge(lineString);
 }
 
 void
 LineMerger::merge()
 {
-	if (mergedLineStrings!=nullptr) return;
-
-	// reset marks (this allows incremental processing)
-	GraphComponent::setMarkedMap(graph.nodeIterator(), graph.nodeEnd(),
-	                                                              false);
-	GraphComponent::setMarked(graph.edgeIterator(), graph.edgeEnd(),
-	                                                              false);
-
-	for (size_t i=0, n=edgeStrings.size(); i<n; ++i)
-		delete edgeStrings[i];
-	edgeStrings.clear();
-
-	buildEdgeStringsForObviousStartNodes();
-	buildEdgeStringsForIsolatedLoops();
-
-	auto numEdgeStrings = edgeStrings.size();
-	mergedLineStrings=new vector<LineString*>(numEdgeStrings);
-	for (size_t i=0; i<numEdgeStrings; ++i)
-	{
-		EdgeString *edgeString=edgeStrings[i];
-		(*mergedLineStrings)[i]=edgeString->toLineString();
-	}
+    if(mergedLineStrings != nullptr) {
+        return;
+    }
+
+    // reset marks (this allows incremental processing)
+    GraphComponent::setMarkedMap(graph.nodeIterator(), graph.nodeEnd(),
+                                 false);
+    GraphComponent::setMarked(graph.edgeIterator(), graph.edgeEnd(),
+                              false);
+
+    for(size_t i = 0, n = edgeStrings.size(); i < n; ++i) {
+        delete edgeStrings[i];
+    }
+    edgeStrings.clear();
+
+    buildEdgeStringsForObviousStartNodes();
+    buildEdgeStringsForIsolatedLoops();
+
+    auto numEdgeStrings = edgeStrings.size();
+    mergedLineStrings = new vector<LineString*>(numEdgeStrings);
+    for(size_t i = 0; i < numEdgeStrings; ++i) {
+        EdgeString* edgeString = edgeStrings[i];
+        (*mergedLineStrings)[i] = edgeString->toLineString();
+    }
 }
 
 void
 LineMerger::buildEdgeStringsForObviousStartNodes()
 {
-	buildEdgeStringsForNonDegree2Nodes();
+    buildEdgeStringsForNonDegree2Nodes();
 }
 
 void
 LineMerger::buildEdgeStringsForIsolatedLoops()
 {
-	buildEdgeStringsForUnprocessedNodes();
+    buildEdgeStringsForUnprocessedNodes();
 }
 
 void
 LineMerger::buildEdgeStringsForUnprocessedNodes()
 {
 #if GEOS_DEBUG
-	cerr<<__FUNCTION__<<endl;
+    cerr << __FUNCTION__ << endl;
 #endif
-	typedef std::vector<Node*> Nodes;
+    typedef std::vector<Node*> Nodes;
 
-	Nodes nodes;
-	graph.getNodes(nodes);
-	for (Nodes::size_type i=0, in=nodes.size(); i<in; ++i) {
-		Node *node=nodes[i];
+    Nodes nodes;
+    graph.getNodes(nodes);
+    for(Nodes::size_type i = 0, in = nodes.size(); i < in; ++i) {
+        Node* node = nodes[i];
 #if GEOS_DEBUG
-		cerr<<"Node "<<i<<": "<<*node<<endl;
+        cerr << "Node " << i << ": " << *node << endl;
 #endif
-		if (!node->isMarked()) {
-			assert(node->getDegree()==2);
-			buildEdgeStringsStartingAt(node);
-			node->setMarked(true);
+        if(!node->isMarked()) {
+            assert(node->getDegree() == 2);
+            buildEdgeStringsStartingAt(node);
+            node->setMarked(true);
 #if GEOS_DEBUG
-			cerr<<" setMarked(true) : "<<*node<<endl;
+            cerr << " setMarked(true) : " << *node << endl;
 #endif
-		}
-	}
+        }
+    }
 }
 
 void
 LineMerger::buildEdgeStringsForNonDegree2Nodes()
 {
 #if GEOS_DEBUG
-	cerr<<__FUNCTION__<<endl;
+    cerr << __FUNCTION__ << endl;
 #endif
-	typedef std::vector<Node*> Nodes;
+    typedef std::vector<Node*> Nodes;
 
-	Nodes nodes;
-	graph.getNodes(nodes);
-	for (Nodes::size_type i=0, in=nodes.size(); i<in; ++i) {
-		Node *node=nodes[i];
+    Nodes nodes;
+    graph.getNodes(nodes);
+    for(Nodes::size_type i = 0, in = nodes.size(); i < in; ++i) {
+        Node* node = nodes[i];
 #if GEOS_DEBUG
-		cerr<<"Node "<<i<<": "<<*node<<endl;
+        cerr << "Node " << i << ": " << *node << endl;
 #endif
-		if (node->getDegree()!=2) {
-			buildEdgeStringsStartingAt(node);
-			node->setMarked(true);
+        if(node->getDegree() != 2) {
+            buildEdgeStringsStartingAt(node);
+            node->setMarked(true);
 #if GEOS_DEBUG
-			cerr<<" setMarked(true) : "<<*node<<endl;
+            cerr << " setMarked(true) : " << *node << endl;
 #endif
-		}
-	}
+        }
+    }
 }
 
 void
-LineMerger::buildEdgeStringsStartingAt(Node *node)
+LineMerger::buildEdgeStringsStartingAt(Node* node)
 {
-	vector<planargraph::DirectedEdge*> &edges=node->getOutEdges()->getEdges();
-	size_t size = edges.size();
-	for (size_t i=0; i<size; i++)
-	{
-		assert(dynamic_cast<LineMergeDirectedEdge*>(edges[i]));
-		LineMergeDirectedEdge *directedEdge=\
-			static_cast<LineMergeDirectedEdge*> (edges[i]);
-		if (directedEdge->getEdge()->isMarked()) {
-			continue;
-		}
-		edgeStrings.push_back(buildEdgeStringStartingWith(directedEdge));
-	}
+    vector<planargraph::DirectedEdge*>& edges = node->getOutEdges()->getEdges();
+    size_t size = edges.size();
+    for(size_t i = 0; i < size; i++) {
+        assert(dynamic_cast<LineMergeDirectedEdge*>(edges[i]));
+        LineMergeDirectedEdge* directedEdge = \
+                                              static_cast<LineMergeDirectedEdge*>(edges[i]);
+        if(directedEdge->getEdge()->isMarked()) {
+            continue;
+        }
+        edgeStrings.push_back(buildEdgeStringStartingWith(directedEdge));
+    }
 }
 
 EdgeString*
-LineMerger::buildEdgeStringStartingWith(LineMergeDirectedEdge *start)
+LineMerger::buildEdgeStringStartingWith(LineMergeDirectedEdge* start)
 {
-	EdgeString *edgeString = new EdgeString(factory);
-	LineMergeDirectedEdge *current=start;
-	do {
-		edgeString->add(current);
-		current->getEdge()->setMarked(true);
-		current=current->getNext();
-	} while (current!=nullptr && current!=start);
-	return edgeString;
+    EdgeString* edgeString = new EdgeString(factory);
+    LineMergeDirectedEdge* current = start;
+    do {
+        edgeString->add(current);
+        current->getEdge()->setMarked(true);
+        current = current->getNext();
+    }
+    while(current != nullptr && current != start);
+    return edgeString;
 }
 
 /**
@@ -223,12 +231,12 @@ LineMerger::buildEdgeStringStartingWith(LineMergeDirectedEdge *start)
 vector<LineString*>*
 LineMerger::getMergedLineStrings()
 {
-	merge();
+    merge();
 
-	// Explicitly give ownership to the caller.
-	vector<LineString*>* ret = mergedLineStrings;
-	mergedLineStrings = nullptr;
-	return ret;
+    // Explicitly give ownership to the caller.
+    vector<LineString*>* ret = mergedLineStrings;
+    mergedLineStrings = nullptr;
+    return ret;
 }
 
 } // namespace geos.operation.linemerge
diff --git a/src/operation/linemerge/LineSequencer.cpp b/src/operation/linemerge/LineSequencer.cpp
index 6ec3415..9827d1d 100644
--- a/src/operation/linemerge/LineSequencer.cpp
+++ b/src/operation/linemerge/LineSequencer.cpp
@@ -52,282 +52,280 @@ namespace linemerge { // geos.operation.linemerge
 bool
 LineSequencer::isSequenced(const Geometry* geom)
 {
-	const MultiLineString *mls;
-
-	if ( nullptr == (mls=dynamic_cast<const MultiLineString *>(geom)) )
-	{
-		return true;
-	}
-
-	// the nodes in all subgraphs which have been completely scanned
-	Coordinate::ConstSet prevSubgraphNodes;
-	Coordinate::ConstVect currNodes;
-
-	const Coordinate* lastNode = nullptr;
-
-	for (std::size_t i=0, n=mls->getNumGeometries(); i<n; ++i)
-	{
-		const LineString* lineptr = \
-			dynamic_cast<const LineString*>(mls->getGeometryN(i));
-		assert(lineptr);
-		const LineString& line = *lineptr;
-
-
-		const Coordinate* startNode = &(line.getCoordinateN(0));
-		const Coordinate* endNode = &(line.getCoordinateN(line.getNumPoints() - 1));
-
-		/**
-		 * If this linestring is connected to a previous subgraph,
-		 * geom is not sequenced
-		 */
-		if (prevSubgraphNodes.find(startNode) != prevSubgraphNodes.end())
-		{
-			return false;
-		}
-		if (prevSubgraphNodes.find(endNode) != prevSubgraphNodes.end())
-		{
-			return false;
-		}
-
-		if (lastNode != nullptr)
-		{
-			if (! startNode->equals2D(*lastNode))
-			{
-				// start new connected sequence
-				prevSubgraphNodes.insert(currNodes.begin(),
-						currNodes.end());
-				currNodes.clear();
-			}
-		}
-		currNodes.push_back(startNode);
-		currNodes.push_back(endNode);
-		lastNode = endNode;
-	}
-	return true;
+    const MultiLineString* mls;
+
+    if(nullptr == (mls = dynamic_cast<const MultiLineString*>(geom))) {
+        return true;
+    }
+
+    // the nodes in all subgraphs which have been completely scanned
+    Coordinate::ConstSet prevSubgraphNodes;
+    Coordinate::ConstVect currNodes;
+
+    const Coordinate* lastNode = nullptr;
+
+    for(std::size_t i = 0, n = mls->getNumGeometries(); i < n; ++i) {
+        const LineString* lineptr = \
+                                    dynamic_cast<const LineString*>(mls->getGeometryN(i));
+        assert(lineptr);
+        const LineString& line = *lineptr;
+
+
+        const Coordinate* startNode = &(line.getCoordinateN(0));
+        const Coordinate* endNode = &(line.getCoordinateN(line.getNumPoints() - 1));
+
+        /**
+         * If this linestring is connected to a previous subgraph,
+         * geom is not sequenced
+         */
+        if(prevSubgraphNodes.find(startNode) != prevSubgraphNodes.end()) {
+            return false;
+        }
+        if(prevSubgraphNodes.find(endNode) != prevSubgraphNodes.end()) {
+            return false;
+        }
+
+        if(lastNode != nullptr) {
+            if(! startNode->equals2D(*lastNode)) {
+                // start new connected sequence
+                prevSubgraphNodes.insert(currNodes.begin(),
+                                         currNodes.end());
+                currNodes.clear();
+            }
+        }
+        currNodes.push_back(startNode);
+        currNodes.push_back(endNode);
+        lastNode = endNode;
+    }
+    return true;
 }
 
 /* private */
 bool
 LineSequencer::hasSequence(planargraph::Subgraph& p_graph)
 {
-	int oddDegreeCount = 0;
-	for (planargraph::NodeMap::container::const_iterator
-		it=p_graph.nodeBegin(), endIt=p_graph.nodeEnd();
-		it!=endIt;
-		++it)
-	{
-		planargraph::Node* node = it->second;
-		if (node->getDegree() % 2 == 1)
-		oddDegreeCount++;
-	}
-	return oddDegreeCount <= 2;
+    int oddDegreeCount = 0;
+    for(planargraph::NodeMap::container::const_iterator
+            it = p_graph.nodeBegin(), endIt = p_graph.nodeEnd();
+            it != endIt;
+            ++it) {
+        planargraph::Node* node = it->second;
+        if(node->getDegree() % 2 == 1) {
+            oddDegreeCount++;
+        }
+    }
+    return oddDegreeCount <= 2;
 }
 
 void
-LineSequencer::delAll( LineSequencer::Sequences& s)
+LineSequencer::delAll(LineSequencer::Sequences& s)
 {
-  for ( Sequences::iterator i=s.begin(), e=s.end(); i!=e; ++i )
-  {
-    delete *i;
-  }
+    for(Sequences::iterator i = s.begin(), e = s.end(); i != e; ++i) {
+        delete *i;
+    }
 }
 
 /*private*/
 LineSequencer::Sequences*
 LineSequencer::findSequences()
 {
-	Sequences *sequences = new Sequences();
-	planargraph::algorithm::ConnectedSubgraphFinder csFinder(graph);
-	vector<planargraph::Subgraph*> subgraphs;
-	csFinder.getConnectedSubgraphs(subgraphs);
-	for (vector<planargraph::Subgraph*>::const_iterator
-		it=subgraphs.begin(), endIt=subgraphs.end();
-		it!=endIt;
-		++it )
-	{
-		planargraph::Subgraph* subgraph = *it;
-		if (hasSequence(*subgraph)) {
-			planargraph::DirectedEdge::NonConstList* seq=findSequence(*subgraph);
-			sequences->push_back(seq);
-		}
-		else {
-			// if any subgraph cannot be sequenced, abort
-			delete subgraph;
-			delAll(*sequences);
-			delete sequences;
-			return nullptr;
-		}
-		delete subgraph;
-	}
-	return sequences;
+    Sequences* sequences = new Sequences();
+    planargraph::algorithm::ConnectedSubgraphFinder csFinder(graph);
+    vector<planargraph::Subgraph*> subgraphs;
+    csFinder.getConnectedSubgraphs(subgraphs);
+    for(vector<planargraph::Subgraph*>::const_iterator
+            it = subgraphs.begin(), endIt = subgraphs.end();
+            it != endIt;
+            ++it) {
+        planargraph::Subgraph* subgraph = *it;
+        if(hasSequence(*subgraph)) {
+            planargraph::DirectedEdge::NonConstList* seq = findSequence(*subgraph);
+            sequences->push_back(seq);
+        }
+        else {
+            // if any subgraph cannot be sequenced, abort
+            delete subgraph;
+            delAll(*sequences);
+            delete sequences;
+            return nullptr;
+        }
+        delete subgraph;
+    }
+    return sequences;
 }
 
 /*private*/
 void
-LineSequencer::addLine(const LineString *lineString)
+LineSequencer::addLine(const LineString* lineString)
 {
-	if (factory == nullptr) {
-		factory = lineString->getFactory();
-	}
-	graph.addEdge(lineString);
-	++lineCount;
+    if(factory == nullptr) {
+        factory = lineString->getFactory();
+    }
+    graph.addEdge(lineString);
+    ++lineCount;
 }
 
 /* private */
 void
 LineSequencer::computeSequence()
 {
-	if (isRun) return;
-	isRun = true;
+    if(isRun) {
+        return;
+    }
+    isRun = true;
 
-	Sequences* sequences = findSequences();
-	if (sequences == nullptr) return;
+    Sequences* sequences = findSequences();
+    if(sequences == nullptr) {
+        return;
+    }
 
-	sequencedGeometry = unique_ptr<Geometry>(buildSequencedGeometry(*sequences));
-	isSequenceableVar = true;
+    sequencedGeometry = unique_ptr<Geometry>(buildSequencedGeometry(*sequences));
+    isSequenceableVar = true;
 
-	delAll(*sequences);
-	delete sequences;
+    delAll(*sequences);
+    delete sequences;
 
-	// Lines were missing from result
-	assert(lineCount == sequencedGeometry->getNumGeometries());
+    // Lines were missing from result
+    assert(lineCount == sequencedGeometry->getNumGeometries());
 
-	// Result is not linear
-	assert(dynamic_cast<LineString *>(sequencedGeometry.get())
-		|| dynamic_cast<MultiLineString *>(sequencedGeometry.get()));
+    // Result is not linear
+    assert(dynamic_cast<LineString*>(sequencedGeometry.get())
+           || dynamic_cast<MultiLineString*>(sequencedGeometry.get()));
 }
 
 /*private*/
 Geometry*
 LineSequencer::buildSequencedGeometry(const Sequences& sequences)
 {
-	unique_ptr<Geometry::NonConstVect> lines(new Geometry::NonConstVect);
-
-	for (Sequences::const_iterator
-		i1=sequences.begin(), i1End=sequences.end();
-		i1 != i1End;
-		++i1)
-	{
-		planargraph::DirectedEdge::NonConstList& seq = *(*i1);
-		for(planargraph::DirectedEdge::NonConstList::iterator i2=seq.begin(),
-			i2End=seq.end(); i2 != i2End; ++i2)
-		{
-			const planargraph::DirectedEdge* de = *i2;
-			assert(dynamic_cast<LineMergeEdge* >(de->getEdge()));
-			LineMergeEdge* e = static_cast<LineMergeEdge* >(de->getEdge());
-			const LineString* line = e->getLine();
-
-			// lineToAdd will be a *copy* of input things
-			LineString* lineToAdd;
-
-			if ( ! de->getEdgeDirection() && ! line->isClosed() ) {
-				lineToAdd = reverse(line);
-			} else {
-				Geometry* lineClone = line->clone();
-				lineToAdd = dynamic_cast<LineString *>(lineClone);
-				assert(lineToAdd);
-			}
-
-			lines->push_back(lineToAdd);
-		}
-	}
-
-	if ( lines->empty() ) {
-		return nullptr;
-	} else {
-		Geometry::NonConstVect *l=lines.get();
-		lines.release();
-		return factory->buildGeometry(l);
-	}
+    unique_ptr<Geometry::NonConstVect> lines(new Geometry::NonConstVect);
+
+    for(Sequences::const_iterator
+            i1 = sequences.begin(), i1End = sequences.end();
+            i1 != i1End;
+            ++i1) {
+        planargraph::DirectedEdge::NonConstList& seq = *(*i1);
+        for(planargraph::DirectedEdge::NonConstList::iterator i2 = seq.begin(),
+                i2End = seq.end(); i2 != i2End; ++i2) {
+            const planargraph::DirectedEdge* de = *i2;
+            assert(dynamic_cast<LineMergeEdge* >(de->getEdge()));
+            LineMergeEdge* e = static_cast<LineMergeEdge* >(de->getEdge());
+            const LineString* line = e->getLine();
+
+            // lineToAdd will be a *copy* of input things
+            LineString* lineToAdd;
+
+            if(! de->getEdgeDirection() && ! line->isClosed()) {
+                lineToAdd = reverse(line);
+            }
+            else {
+                Geometry* lineClone = line->clone();
+                lineToAdd = dynamic_cast<LineString*>(lineClone);
+                assert(lineToAdd);
+            }
+
+            lines->push_back(lineToAdd);
+        }
+    }
+
+    if(lines->empty()) {
+        return nullptr;
+    }
+    else {
+        Geometry::NonConstVect* l = lines.get();
+        lines.release();
+        return factory->buildGeometry(l);
+    }
 }
 
 /*static private*/
-LineString *
-LineSequencer::reverse(const LineString *line)
+LineString*
+LineSequencer::reverse(const LineString* line)
 {
-	CoordinateSequence* cs=line->getCoordinates();
-	CoordinateSequence::reverse(cs);
-	return line->getFactory()->createLineString(cs);
+    CoordinateSequence* cs = line->getCoordinates();
+    CoordinateSequence::reverse(cs);
+    return line->getFactory()->createLineString(cs);
 }
 
 /*private static*/
 const planargraph::Node*
 LineSequencer::findLowestDegreeNode(const planargraph::Subgraph& graph)
 {
-	size_t minDegree = numeric_limits<size_t>::max();
-	const planargraph::Node* minDegreeNode = nullptr;
-	for (planargraph::NodeMap::container::const_iterator
-		it = graph.nodeBegin(), itEnd = graph.nodeEnd();
-		it != itEnd;
-		++it )
-	{
-		const planargraph::Node* node = (*it).second;
-		if (minDegreeNode == nullptr || node->getDegree() < minDegree)
-		{
-			minDegree = node->getDegree();
-			minDegreeNode = node;
-		}
-	}
-	return minDegreeNode;
+    size_t minDegree = numeric_limits<size_t>::max();
+    const planargraph::Node* minDegreeNode = nullptr;
+    for(planargraph::NodeMap::container::const_iterator
+            it = graph.nodeBegin(), itEnd = graph.nodeEnd();
+            it != itEnd;
+            ++it) {
+        const planargraph::Node* node = (*it).second;
+        if(minDegreeNode == nullptr || node->getDegree() < minDegree) {
+            minDegree = node->getDegree();
+            minDegreeNode = node;
+        }
+    }
+    return minDegreeNode;
 }
 
 /*private static*/
 const planargraph::DirectedEdge*
 LineSequencer::findUnvisitedBestOrientedDE(const planargraph::Node* node)
 {
-	using planargraph::DirectedEdge;
-	using planargraph::DirectedEdgeStar;
-
-	const DirectedEdge* wellOrientedDE = nullptr;
-	const DirectedEdge* unvisitedDE = nullptr;
-	const DirectedEdgeStar* des=node->getOutEdges();
-	for (DirectedEdge::NonConstVect::const_iterator i=des->begin(),
-		e=des->end();
-		i!=e;
-		++i)
-	{
-		planargraph::DirectedEdge* de = *i;
-		if (! de->getEdge()->isVisited()) {
-			unvisitedDE = de;
-			if (de->getEdgeDirection()) wellOrientedDE = de;
-		}
-	}
-	if (wellOrientedDE != nullptr)
-		return wellOrientedDE;
-	return unvisitedDE;
+    using planargraph::DirectedEdge;
+    using planargraph::DirectedEdgeStar;
+
+    const DirectedEdge* wellOrientedDE = nullptr;
+    const DirectedEdge* unvisitedDE = nullptr;
+    const DirectedEdgeStar* des = node->getOutEdges();
+    for(DirectedEdge::NonConstVect::const_iterator i = des->begin(),
+            e = des->end();
+            i != e;
+            ++i) {
+        planargraph::DirectedEdge* de = *i;
+        if(! de->getEdge()->isVisited()) {
+            unvisitedDE = de;
+            if(de->getEdgeDirection()) {
+                wellOrientedDE = de;
+            }
+        }
+    }
+    if(wellOrientedDE != nullptr) {
+        return wellOrientedDE;
+    }
+    return unvisitedDE;
 }
 
 
 /*private*/
 void
-LineSequencer::addReverseSubpath(const planargraph::DirectedEdge *de,
-		planargraph::DirectedEdge::NonConstList& deList,
-		planargraph::DirectedEdge::NonConstList::iterator lit,
-		bool expectedClosed)
+LineSequencer::addReverseSubpath(const planargraph::DirectedEdge* de,
+                                 planargraph::DirectedEdge::NonConstList& deList,
+                                 planargraph::DirectedEdge::NonConstList::iterator lit,
+                                 bool expectedClosed)
 {
-	using planargraph::Node;
-	using planargraph::DirectedEdge;
-
-	// trace an unvisited path *backwards* from this de
-	Node* endNode = de->getToNode();
-
-	Node* fromNode = nullptr;
-	while (true) {
-		deList.insert(lit, de->getSym());
-		de->getEdge()->setVisited(true);
-		fromNode = de->getFromNode();
-		const DirectedEdge* unvisitedOutDE = findUnvisitedBestOrientedDE(fromNode);
-
-		// this must terminate, since we are continually marking edges as visited
-		if (unvisitedOutDE == nullptr) break;
-		de = unvisitedOutDE->getSym();
-	}
-	if ( expectedClosed ) {
-		// the path should end at the toNode of this de,
-		// otherwise we have an error
-		util::Assert::isTrue(fromNode == endNode, "path not contiguos");
-		//assert(fromNode == endNode);
-	}
+    using planargraph::Node;
+    using planargraph::DirectedEdge;
+
+    // trace an unvisited path *backwards* from this de
+    Node* endNode = de->getToNode();
+
+    Node* fromNode = nullptr;
+    while(true) {
+        deList.insert(lit, de->getSym());
+        de->getEdge()->setVisited(true);
+        fromNode = de->getFromNode();
+        const DirectedEdge* unvisitedOutDE = findUnvisitedBestOrientedDE(fromNode);
+
+        // this must terminate, since we are continually marking edges as visited
+        if(unvisitedOutDE == nullptr) {
+            break;
+        }
+        de = unvisitedOutDE->getSym();
+    }
+    if(expectedClosed) {
+        // the path should end at the toNode of this de,
+        // otherwise we have an error
+        util::Assert::isTrue(fromNode == endNode, "path not contiguos");
+        //assert(fromNode == endNode);
+    }
 
 }
 
@@ -335,114 +333,113 @@ LineSequencer::addReverseSubpath(const planargraph::DirectedEdge *de,
 planargraph::DirectedEdge::NonConstList*
 LineSequencer::findSequence(planargraph::Subgraph& p_graph)
 {
-	using planargraph::DirectedEdge;
-	using planargraph::Node;
-	using planargraph::GraphComponent;
+    using planargraph::DirectedEdge;
+    using planargraph::Node;
+    using planargraph::GraphComponent;
 
-	GraphComponent::setVisited(p_graph.edgeBegin(),
-			p_graph.edgeEnd(), false);
+    GraphComponent::setVisited(p_graph.edgeBegin(),
+                               p_graph.edgeEnd(), false);
 
-	const Node* startNode = findLowestDegreeNode(p_graph);
+    const Node* startNode = findLowestDegreeNode(p_graph);
 
-	const DirectedEdge *startDE = *(startNode->getOutEdges()->begin());
-	const DirectedEdge *startDESym = startDE->getSym();
+    const DirectedEdge* startDE = *(startNode->getOutEdges()->begin());
+    const DirectedEdge* startDESym = startDE->getSym();
 
-	DirectedEdge::NonConstList *seq = new DirectedEdge::NonConstList();
+    DirectedEdge::NonConstList* seq = new DirectedEdge::NonConstList();
 
-	DirectedEdge::NonConstList::iterator lit=seq->begin();
-	addReverseSubpath(startDESym, *seq, lit, false);
+    DirectedEdge::NonConstList::iterator lit = seq->begin();
+    addReverseSubpath(startDESym, *seq, lit, false);
 
-	lit=seq->end();
-	while (lit != seq->begin()) {
-		const DirectedEdge* prev = *(--lit);
-		const DirectedEdge* unvisitedOutDE = findUnvisitedBestOrientedDE(prev->getFromNode());
-		if (unvisitedOutDE != nullptr)
-			addReverseSubpath(unvisitedOutDE->getSym(), *seq, lit, true);
-	}
+    lit = seq->end();
+    while(lit != seq->begin()) {
+        const DirectedEdge* prev = *(--lit);
+        const DirectedEdge* unvisitedOutDE = findUnvisitedBestOrientedDE(prev->getFromNode());
+        if(unvisitedOutDE != nullptr) {
+            addReverseSubpath(unvisitedOutDE->getSym(), *seq, lit, true);
+        }
+    }
 
-	// At this point, we have a valid sequence of graph DirectedEdges,
-	// but it is not necessarily appropriately oriented relative to
-	// the underlying geometry.
-	DirectedEdge::NonConstList* orientedSeq = orient(seq);
+    // At this point, we have a valid sequence of graph DirectedEdges,
+    // but it is not necessarily appropriately oriented relative to
+    // the underlying geometry.
+    DirectedEdge::NonConstList* orientedSeq = orient(seq);
 
-	if (orientedSeq != seq) delete seq;
+    if(orientedSeq != seq) {
+        delete seq;
+    }
 
-	return orientedSeq;
+    return orientedSeq;
 }
 
 /* private */
 planargraph::DirectedEdge::NonConstList*
 LineSequencer::orient(planargraph::DirectedEdge::NonConstList* seq)
 {
-	using namespace geos::planargraph;
-
-	const DirectedEdge* startEdge = seq->front();
-	const DirectedEdge* endEdge = seq->back();
-	Node* startNode = startEdge->getFromNode();
-	Node* endNode = endEdge->getToNode();
-
-	bool flipSeq = false;
-	bool hasDegree1Node = \
-		startNode->getDegree() == 1 || endNode->getDegree() == 1;
-
-	if (hasDegree1Node)
-	{
-		bool hasObviousStartNode = false;
-
-		// test end edge before start edge, to make result stable
-		// (ie. if both are good starts, pick the actual start
-		if (endEdge->getToNode()->getDegree() == 1 &&
-				endEdge->getEdgeDirection() == false)
-		{
-			hasObviousStartNode = true;
-			flipSeq = true;
-		}
-		if (startEdge->getFromNode()->getDegree() == 1 &&
-				startEdge->getEdgeDirection() == true)
-		{
-			hasObviousStartNode = true;
-			flipSeq = false;
-		}
-
-		// since there is no obvious start node,
-		// use any node of degree 1
-		if (! hasObviousStartNode)
-		{
-			// check if the start node should actually
-			// be the end node
-			if (startEdge->getFromNode()->getDegree() == 1)
-				flipSeq = true;
-			// if the end node is of degree 1, it is
-			// properly the end node
-		}
-
-	}
-
-
-	// if there is no degree 1 node, just use the sequence as is
-	// (Could insert heuristic of taking direction of majority of
-	// lines as overall direction)
-
-	if (flipSeq)
-	{
-		return reverse(*seq);
-	}
-	return seq;
+    using namespace geos::planargraph;
+
+    const DirectedEdge* startEdge = seq->front();
+    const DirectedEdge* endEdge = seq->back();
+    Node* startNode = startEdge->getFromNode();
+    Node* endNode = endEdge->getToNode();
+
+    bool flipSeq = false;
+    bool hasDegree1Node = \
+                          startNode->getDegree() == 1 || endNode->getDegree() == 1;
+
+    if(hasDegree1Node) {
+        bool hasObviousStartNode = false;
+
+        // test end edge before start edge, to make result stable
+        // (ie. if both are good starts, pick the actual start
+        if(endEdge->getToNode()->getDegree() == 1 &&
+                endEdge->getEdgeDirection() == false) {
+            hasObviousStartNode = true;
+            flipSeq = true;
+        }
+        if(startEdge->getFromNode()->getDegree() == 1 &&
+                startEdge->getEdgeDirection() == true) {
+            hasObviousStartNode = true;
+            flipSeq = false;
+        }
+
+        // since there is no obvious start node,
+        // use any node of degree 1
+        if(! hasObviousStartNode) {
+            // check if the start node should actually
+            // be the end node
+            if(startEdge->getFromNode()->getDegree() == 1) {
+                flipSeq = true;
+            }
+            // if the end node is of degree 1, it is
+            // properly the end node
+        }
+
+    }
+
+
+    // if there is no degree 1 node, just use the sequence as is
+    // (Could insert heuristic of taking direction of majority of
+    // lines as overall direction)
+
+    if(flipSeq) {
+        return reverse(*seq);
+    }
+    return seq;
 }
 
 /* private */
 planargraph::DirectedEdge::NonConstList*
 LineSequencer::reverse(planargraph::DirectedEdge::NonConstList& seq)
 {
-	using namespace geos::planargraph;
-
-	DirectedEdge::NonConstList* newSeq = new DirectedEdge::NonConstList();
-	DirectedEdge::NonConstList::iterator it=seq.begin(), itEnd=seq.end();
-	for (; it!=itEnd; ++it) {
-		const DirectedEdge *de = *it;
-		newSeq->push_front(de->getSym());
-	}
-	return newSeq;
+    using namespace geos::planargraph;
+
+    DirectedEdge::NonConstList* newSeq = new DirectedEdge::NonConstList();
+    DirectedEdge::NonConstList::iterator it = seq.begin(), itEnd = seq.end();
+    for(; it != itEnd; ++it) {
+        const DirectedEdge* de = *it;
+        newSeq->push_front(de->getSym());
+    }
+    return newSeq;
 }
 
 
diff --git a/src/operation/overlay/EdgeSetNoder.cpp b/src/operation/overlay/EdgeSetNoder.cpp
index fe76150..27a78c5 100644
--- a/src/operation/overlay/EdgeSetNoder.cpp
+++ b/src/operation/overlay/EdgeSetNoder.cpp
@@ -36,24 +36,24 @@ namespace overlay { // geos.operation.overlay
 
 
 void
-EdgeSetNoder::addEdges(vector<Edge*> *edges)
+EdgeSetNoder::addEdges(vector<Edge*>* edges)
 {
-	inputEdges->insert(inputEdges->end(),edges->begin(),edges->end());
+    inputEdges->insert(inputEdges->end(), edges->begin(), edges->end());
 }
 
 vector<Edge*>*
 EdgeSetNoder::getNodedEdges()
 {
-	EdgeSetIntersector *esi=new SimpleMCSweepLineIntersector();
-	SegmentIntersector *si=new SegmentIntersector(li,true,false);
-	esi->computeIntersections(inputEdges,si,true);
-	//Debug.println("has proper int = " + si.hasProperIntersection());
-	vector<Edge*> *splitEdges=new vector<Edge*>();
-	for(int i=0;i<(int)inputEdges->size();i++) {
-		Edge* e=(*inputEdges)[i];
-		e->getEdgeIntersectionList().addSplitEdges(splitEdges);
-	}
-	return splitEdges;
+    EdgeSetIntersector* esi = new SimpleMCSweepLineIntersector();
+    SegmentIntersector* si = new SegmentIntersector(li, true, false);
+    esi->computeIntersections(inputEdges, si, true);
+    //Debug.println("has proper int = " + si.hasProperIntersection());
+    vector<Edge*>* splitEdges = new vector<Edge*>();
+    for(int i = 0; i < (int)inputEdges->size(); i++) {
+        Edge* e = (*inputEdges)[i];
+        e->getEdgeIntersectionList().addSplitEdges(splitEdges);
+    }
+    return splitEdges;
 }
 
 } // namespace geos.operation.overlay
diff --git a/src/operation/overlay/ElevationMatrix.cpp b/src/operation/overlay/ElevationMatrix.cpp
index 1bffeef..6fcfd4a 100644
--- a/src/operation/overlay/ElevationMatrix.cpp
+++ b/src/operation/overlay/ElevationMatrix.cpp
@@ -45,61 +45,70 @@ namespace geos {
 namespace operation { // geos.operation
 namespace overlay { // geos.operation.overlay
 
-ElevationMatrixFilter::ElevationMatrixFilter(ElevationMatrix &newEm):
-	em(newEm)
+ElevationMatrixFilter::ElevationMatrixFilter(ElevationMatrix& newEm):
+    em(newEm)
 { }
 
 ElevationMatrixFilter::~ElevationMatrixFilter()
 { }
 
 void
-ElevationMatrixFilter::filter_rw(Coordinate *c) const
+ElevationMatrixFilter::filter_rw(Coordinate* c) const
 {
 #if GEOS_DEBUG
-	cerr<<"ElevationMatrixFilter::filter_rw("<<c->toString()<<") called"
-		<<endl;
+    cerr << "ElevationMatrixFilter::filter_rw(" << c->toString() << ") called"
+         << endl;
 #endif
 
-	// already has a Z value, nothing to do
-	if ( ! std::isnan(c->z) ) return;
+    // already has a Z value, nothing to do
+    if(! std::isnan(c->z)) {
+        return;
+    }
 
-	double p_avgElevation = em.getAvgElevation();
+    double p_avgElevation = em.getAvgElevation();
 
-	try {
-		const ElevationMatrixCell &emc = em.getCell(*c);
-		c->z = emc.getAvg();
-		if ( std::isnan(c->z) ) c->z = p_avgElevation;
+    try {
+        const ElevationMatrixCell& emc = em.getCell(*c);
+        c->z = emc.getAvg();
+        if(std::isnan(c->z)) {
+            c->z = p_avgElevation;
+        }
 #if GEOS_DEBUG
-		cerr<<"  z set to "<<c->z<<endl;
+        cerr << "  z set to " << c->z << endl;
 #endif
-	} catch (const util::IllegalArgumentException& /* ex */) {
-		c->z = avgElevation;
-	}
+    }
+    catch(const util::IllegalArgumentException& /* ex */) {
+        c->z = avgElevation;
+    }
 }
 
 void
-ElevationMatrixFilter::filter_ro(const Coordinate *c)
+ElevationMatrixFilter::filter_ro(const Coordinate* c)
 {
 #if GEOS_DEBUG
-	cerr<<"ElevationMatrixFilter::filter_ro("<<c->toString()<<") called"
-		<<endl;
+    cerr << "ElevationMatrixFilter::filter_ro(" << c->toString() << ") called"
+         << endl;
 #endif
-	em.add(*c);
+    em.add(*c);
 }
 
 
-ElevationMatrix::ElevationMatrix(const Envelope &newEnv,
-		unsigned int newRows, unsigned int newCols):
-	filter(*this),
-	env(newEnv), cols(newCols), rows(newRows),
-	avgElevationComputed(false),
-	avgElevation(DoubleNotANumber),
- 	cells(newRows*newCols)
+ElevationMatrix::ElevationMatrix(const Envelope& newEnv,
+                                 unsigned int newRows, unsigned int newCols):
+    filter(*this),
+    env(newEnv), cols(newCols), rows(newRows),
+    avgElevationComputed(false),
+    avgElevation(DoubleNotANumber),
+    cells(newRows * newCols)
 {
-	cellwidth=env.getWidth()/cols;
-	cellheight=env.getHeight()/rows;
-	if ( ! cellwidth ) cols=1;
-	if ( ! cellheight ) rows=1;
+    cellwidth = env.getWidth() / cols;
+    cellheight = env.getHeight() / rows;
+    if(! cellwidth) {
+        cols = 1;
+    }
+    if(! cellheight) {
+        rows = 1;
+    }
 }
 
 ElevationMatrix::~ElevationMatrix()
@@ -107,138 +116,149 @@ ElevationMatrix::~ElevationMatrix()
 }
 
 void
-ElevationMatrix::add(const Geometry *geom)
+ElevationMatrix::add(const Geometry* geom)
 {
 #if GEOS_DEBUG
-	cerr<<"ElevationMatrix::add(Geometry *) called"<<endl;
+    cerr << "ElevationMatrix::add(Geometry *) called" << endl;
 #endif // GEOS_DEBUG
 
-	// Cannot add Geometries to an ElevationMatrix after it's average
-	// elevation has been computed
-	assert(!avgElevationComputed);
+    // Cannot add Geometries to an ElevationMatrix after it's average
+    // elevation has been computed
+    assert(!avgElevationComputed);
 
-	//ElevationMatrixFilter filter(this);
-	geom->apply_ro(&filter);
+    //ElevationMatrixFilter filter(this);
+    geom->apply_ro(&filter);
 
 }
 
 #if 0
 void
-ElevationMatrix::add(const CoordinateSequence *cs)
+ElevationMatrix::add(const CoordinateSequence* cs)
 {
-	unsigned int ncoords = cs->getSize();
-	for (unsigned int i=0; i<ncoords; i++)
-	{
-		add(cs->getAt(i));
-	}
+    unsigned int ncoords = cs->getSize();
+    for(unsigned int i = 0; i < ncoords; i++) {
+        add(cs->getAt(i));
+    }
 }
 #endif
 
 void
-ElevationMatrix::add(const Coordinate &c)
+ElevationMatrix::add(const Coordinate& c)
 {
-	if ( std::isnan(c.z) ) return;
-	try {
-		ElevationMatrixCell &emc = getCell(c);
-		emc.add(c);
-	} catch (const util::IllegalArgumentException& exp) {
-		// coordinate do not overlap matrix
-		cerr << "ElevationMatrix::add(" << c.toString()
-		     << "): Coordinate does not overlap grid extent: "
-		     << exp.what() << endl;
-		return;
-	}
+    if(std::isnan(c.z)) {
+        return;
+    }
+    try {
+        ElevationMatrixCell& emc = getCell(c);
+        emc.add(c);
+    }
+    catch(const util::IllegalArgumentException& exp) {
+        // coordinate do not overlap matrix
+        cerr << "ElevationMatrix::add(" << c.toString()
+             << "): Coordinate does not overlap grid extent: "
+             << exp.what() << endl;
+        return;
+    }
 }
 
-ElevationMatrixCell &
-ElevationMatrix::getCell(const Coordinate &c)
+ElevationMatrixCell&
+ElevationMatrix::getCell(const Coordinate& c)
 {
-	int col, row;
-
-	if ( ! cellwidth ) col=0;
-	else
-	{
-		double xoffset = c.x - env.getMinX();
-		col = (int)(xoffset/cellwidth);
-		if ( col == (int)cols ) col = cols-1;
-	}
-	if ( ! cellheight ) row=0;
-	else
-	{
-		double yoffset = c.y - env.getMinY();
-		row = (int)(yoffset/cellheight);
-		if ( row == (int)rows ) row = rows-1;
-	}
-	int celloffset = (cols*row)+col;
-
-	if  (celloffset<0 || celloffset >= (int)(cols*rows))
-	{
-		ostringstream s;
-		s<<"ElevationMatrix::getCell got a Coordinate out of grid extent ("<<env.toString()<<") - cols:"<<cols<<" rows:"<<rows;
-		throw util::IllegalArgumentException(s.str());
-	}
-
-	return cells[celloffset];
+    int col, row;
+
+    if(! cellwidth) {
+        col = 0;
+    }
+    else {
+        double xoffset = c.x - env.getMinX();
+        col = (int)(xoffset / cellwidth);
+        if(col == (int)cols) {
+            col = cols - 1;
+        }
+    }
+    if(! cellheight) {
+        row = 0;
+    }
+    else {
+        double yoffset = c.y - env.getMinY();
+        row = (int)(yoffset / cellheight);
+        if(row == (int)rows) {
+            row = rows - 1;
+        }
+    }
+    int celloffset = (cols * row) + col;
+
+    if(celloffset < 0 || celloffset >= (int)(cols * rows)) {
+        ostringstream s;
+        s << "ElevationMatrix::getCell got a Coordinate out of grid extent (" << env.toString() << ") - cols:" << cols <<
+          " rows:" << rows;
+        throw util::IllegalArgumentException(s.str());
+    }
+
+    return cells[celloffset];
 }
 
-const ElevationMatrixCell &
-ElevationMatrix::getCell(const Coordinate &c) const
+const ElevationMatrixCell&
+ElevationMatrix::getCell(const Coordinate& c) const
 {
-	return (const ElevationMatrixCell &)
-		((ElevationMatrix *)this)->getCell(c);
+    return (const ElevationMatrixCell&)
+           ((ElevationMatrix*)this)->getCell(c);
 }
 
 double
 ElevationMatrix::getAvgElevation() const
 {
-	if ( avgElevationComputed ) return avgElevation;
-	double ztot=0;
-	int zvals=0;
-	for (unsigned int r=0; r<rows; r++)
-	{
-		for(unsigned int c=0; c<cols; c++)
-		{
-			const ElevationMatrixCell &cell = cells[(r*cols)+c];
-			double e = cell.getAvg();
-			if ( !std::isnan(e) )
-			{
-				zvals++;
-				ztot+=e;
-			}
-		}
-	}
-	if ( zvals ) avgElevation = ztot/zvals;
-	else avgElevation = DoubleNotANumber;
-
-	avgElevationComputed = true;
-
-	return avgElevation;
+    if(avgElevationComputed) {
+        return avgElevation;
+    }
+    double ztot = 0;
+    int zvals = 0;
+    for(unsigned int r = 0; r < rows; r++) {
+        for(unsigned int c = 0; c < cols; c++) {
+            const ElevationMatrixCell& cell = cells[(r * cols) + c];
+            double e = cell.getAvg();
+            if(!std::isnan(e)) {
+                zvals++;
+                ztot += e;
+            }
+        }
+    }
+    if(zvals) {
+        avgElevation = ztot / zvals;
+    }
+    else {
+        avgElevation = DoubleNotANumber;
+    }
+
+    avgElevationComputed = true;
+
+    return avgElevation;
 }
 
 string
 ElevationMatrix::print() const
 {
-	ostringstream ret;
-	ret << "Cols:"<<cols<<" Rows:"<<rows<<" AvgElevation:"<<getAvgElevation()<<endl;
-	for (unsigned int r=0; r<rows; r++)
-	{
-		for (unsigned int c=0; c<cols; c++)
-		{
-			ret << cells[(r*cols)+c].print() << '\t';
-		}
-		ret << endl;
-	}
-	return ret.str();
+    ostringstream ret;
+    ret << "Cols:" << cols << " Rows:" << rows << " AvgElevation:" << getAvgElevation() << endl;
+    for(unsigned int r = 0; r < rows; r++) {
+        for(unsigned int c = 0; c < cols; c++) {
+            ret << cells[(r * cols) + c].print() << '\t';
+        }
+        ret << endl;
+    }
+    return ret.str();
 }
 
 void
-ElevationMatrix::elevate(Geometry *g) const
+ElevationMatrix::elevate(Geometry* g) const
 {
 
-	// Nothing to do if no elevation info in matrix
-	if ( std::isnan(getAvgElevation()) ) return;
+    // Nothing to do if no elevation info in matrix
+    if(std::isnan(getAvgElevation())) {
+        return;
+    }
 
-	g->apply_rw(&filter);
+    g->apply_rw(&filter);
 }
 
 } // namespace geos.operation.overlay
diff --git a/src/operation/overlay/ElevationMatrixCell.cpp b/src/operation/overlay/ElevationMatrixCell.cpp
index e1b5548..112bc7e 100644
--- a/src/operation/overlay/ElevationMatrixCell.cpp
+++ b/src/operation/overlay/ElevationMatrixCell.cpp
@@ -41,50 +41,46 @@ ElevationMatrixCell::~ElevationMatrixCell()
 }
 
 void
-ElevationMatrixCell::add(const Coordinate &c)
+ElevationMatrixCell::add(const Coordinate& c)
 {
-	if ( !std::isnan(c.z) )
-	{
-		if ( zvals.insert(c.z).second )
-		{
-			ztot+=c.z;
-		}
-	}
+    if(!std::isnan(c.z)) {
+        if(zvals.insert(c.z).second) {
+            ztot += c.z;
+        }
+    }
 }
 
 void
 ElevationMatrixCell::add(double z)
 {
-	if ( !std::isnan(z) )
-	{
-		if ( zvals.insert(z).second )
-		{
-			ztot+=z;
-		}
-	}
+    if(!std::isnan(z)) {
+        if(zvals.insert(z).second) {
+            ztot += z;
+        }
+    }
 }
 
 double
 ElevationMatrixCell::getTotal() const
 {
-	return ztot;
+    return ztot;
 }
 
 double
 ElevationMatrixCell::getAvg() const
 {
-	return  zvals.size() ?
-		ztot / static_cast<double>(zvals.size()) :
-		DoubleNotANumber;
+    return  zvals.size() ?
+            ztot / static_cast<double>(zvals.size()) :
+            DoubleNotANumber;
 }
 
 string
 ElevationMatrixCell::print() const
 {
-	ostringstream ret;
-	//ret<<"["<<ztot<<"/"<<zvals.size()<<"]";
-	ret << "[" << getAvg() << "]";
-	return ret.str();
+    ostringstream ret;
+    //ret<<"["<<ztot<<"/"<<zvals.size()<<"]";
+    ret << "[" << getAvg() << "]";
+    return ret.str();
 }
 
 } // namespace geos.operation.overlay
diff --git a/src/operation/overlay/LineBuilder.cpp b/src/operation/overlay/LineBuilder.cpp
index c39de10..4312cf7 100644
--- a/src/operation/overlay/LineBuilder.cpp
+++ b/src/operation/overlay/LineBuilder.cpp
@@ -45,14 +45,14 @@ namespace geos {
 namespace operation { // geos.operation
 namespace overlay { // geos.operation.overlay
 
-LineBuilder::LineBuilder(OverlayOp *newOp,
-		const GeometryFactory *newGeometryFactory,
-		PointLocator *newPtLocator):
-	op(newOp),
-	geometryFactory(newGeometryFactory),
-	ptLocator(newPtLocator),
-	//lineEdgesList(new vector<Edge *>()),
-	resultLineList(new vector<LineString *>())
+LineBuilder::LineBuilder(OverlayOp* newOp,
+                         const GeometryFactory* newGeometryFactory,
+                         PointLocator* newPtLocator):
+    op(newOp),
+    geometryFactory(newGeometryFactory),
+    ptLocator(newPtLocator),
+    //lineEdgesList(new vector<Edge *>()),
+    resultLineList(new vector<LineString *>())
 {
 }
 
@@ -67,11 +67,11 @@ LineBuilder::~LineBuilder()
 vector<LineString*>*
 LineBuilder::build(OverlayOp::OpCode opCode)
 {
-	findCoveredLineEdges();
-	collectLines(opCode);
-	//labelIsolatedLines(&lineEdgesList);
-	buildLines(opCode);
-	return resultLineList;
+    findCoveredLineEdges();
+    collectLines(opCode);
+    //labelIsolatedLines(&lineEdgesList);
+    buildLines(opCode);
+    return resultLineList;
 }
 
 /*
@@ -85,119 +85,121 @@ void
 LineBuilder::findCoveredLineEdges()
 {
 // first set covered for all L edges at nodes which have A edges too
-	map<Coordinate*,Node*,CoordinateLessThen> &nodeMap=op->getGraph().getNodeMap()->nodeMap;
-	map<Coordinate*,Node*,CoordinateLessThen>::iterator it=nodeMap.begin();
-	map<Coordinate*,Node*,CoordinateLessThen>::iterator endIt=nodeMap.end();
-	for ( ; it!=endIt; ++it)
-	{
-		Node *node=it->second;
-		//node.print(System.out);
-		assert(dynamic_cast<DirectedEdgeStar*>(node->getEdges()));
-		DirectedEdgeStar* des=static_cast<DirectedEdgeStar*>(node->getEdges());
-		des->findCoveredLineEdges();
-		//((DirectedEdgeStar*)node->getEdges())->findCoveredLineEdges();
-	}
-
-	/*
-	 * For all L edges which weren't handled by the above,
-	 * use a point-in-poly test to determine whether they are covered
-	 */
-	vector<EdgeEnd*> *ee=op->getGraph().getEdgeEnds();
-	for(size_t i=0, s=ee->size(); i<s; ++i)
-	{
-		assert(dynamic_cast<DirectedEdge*>((*ee)[i]));
-		DirectedEdge *de=static_cast<DirectedEdge*>((*ee)[i]);
-		Edge *e=de->getEdge();
-		if (de->isLineEdge() && !e->isCoveredSet()) {
-			bool isCovered=op->isCoveredByA(de->getCoordinate());
-			e->setCovered(isCovered);
-		}
-	}
+    map<Coordinate*, Node*, CoordinateLessThen>& nodeMap = op->getGraph().getNodeMap()->nodeMap;
+    map<Coordinate*, Node*, CoordinateLessThen>::iterator it = nodeMap.begin();
+    map<Coordinate*, Node*, CoordinateLessThen>::iterator endIt = nodeMap.end();
+    for(; it != endIt; ++it) {
+        Node* node = it->second;
+        //node.print(System.out);
+        assert(dynamic_cast<DirectedEdgeStar*>(node->getEdges()));
+        DirectedEdgeStar* des = static_cast<DirectedEdgeStar*>(node->getEdges());
+        des->findCoveredLineEdges();
+        //((DirectedEdgeStar*)node->getEdges())->findCoveredLineEdges();
+    }
+
+    /*
+     * For all L edges which weren't handled by the above,
+     * use a point-in-poly test to determine whether they are covered
+     */
+    vector<EdgeEnd*>* ee = op->getGraph().getEdgeEnds();
+    for(size_t i = 0, s = ee->size(); i < s; ++i) {
+        assert(dynamic_cast<DirectedEdge*>((*ee)[i]));
+        DirectedEdge* de = static_cast<DirectedEdge*>((*ee)[i]);
+        Edge* e = de->getEdge();
+        if(de->isLineEdge() && !e->isCoveredSet()) {
+            bool isCovered = op->isCoveredByA(de->getCoordinate());
+            e->setCovered(isCovered);
+        }
+    }
 }
 
 void
 LineBuilder::collectLines(OverlayOp::OpCode opCode)
 {
-	vector<EdgeEnd*> *ee=op->getGraph().getEdgeEnds();
-	for(size_t i=0, s=ee->size(); i<s; ++i)
-	{
-		assert(dynamic_cast<DirectedEdge*>((*ee)[i]));
-		DirectedEdge *de=static_cast<DirectedEdge*>((*ee)[i]);
-		collectLineEdge(de, opCode, &lineEdgesList);
-		collectBoundaryTouchEdge(de, opCode, &lineEdgesList);
-	}
+    vector<EdgeEnd*>* ee = op->getGraph().getEdgeEnds();
+    for(size_t i = 0, s = ee->size(); i < s; ++i) {
+        assert(dynamic_cast<DirectedEdge*>((*ee)[i]));
+        DirectedEdge* de = static_cast<DirectedEdge*>((*ee)[i]);
+        collectLineEdge(de, opCode, &lineEdgesList);
+        collectBoundaryTouchEdge(de, opCode, &lineEdgesList);
+    }
 }
 
 void
-LineBuilder::collectLineEdge(DirectedEdge *de, OverlayOp::OpCode opCode,
-		vector<Edge*> *edges)
+LineBuilder::collectLineEdge(DirectedEdge* de, OverlayOp::OpCode opCode,
+                             vector<Edge*>* edges)
 {
 
-  // include L edges which are in the result
-  if (de->isLineEdge()) {
+    // include L edges which are in the result
+    if(de->isLineEdge()) {
 
-    const Label& label = de->getLabel();
+        const Label& label = de->getLabel();
 
-    Edge *e = de->getEdge();
+        Edge* e = de->getEdge();
 
-    if (!de->isVisited()
-          && OverlayOp::isResultOfOp(label, opCode)
-          && !e->isCovered() )
-		{
-			//Debug.println("de: "+de.getLabel());
-			//Debug.println("edge: "+e.getLabel());
-			edges->push_back(e);
-			de->setVisitedEdge(true);
-		}
+        if(!de->isVisited()
+                && OverlayOp::isResultOfOp(label, opCode)
+                && !e->isCovered()) {
+            //Debug.println("de: "+de.getLabel());
+            //Debug.println("edge: "+e.getLabel());
+            edges->push_back(e);
+            de->setVisitedEdge(true);
+        }
 
-	}
+    }
 
 }
 
 /*private*/
 void
-LineBuilder::collectBoundaryTouchEdge(DirectedEdge *de,
-		OverlayOp::OpCode opCode, vector<Edge*> *edges)
+LineBuilder::collectBoundaryTouchEdge(DirectedEdge* de,
+                                      OverlayOp::OpCode opCode, vector<Edge*>* edges)
 {
-	if (de->isLineEdge()) return;  // only interested in area edges
-	if (de->isVisited()) return;  // already processed
-
-	// added to handle dimensional collapses
-	if (de->isInteriorAreaEdge()) return;
-
-	// if the edge linework is already included, don't include it again
-	if (de->getEdge()->isInResult()) return;
-
-	// sanity check for labelling of result edgerings
-	assert( ! ( de->isInResult() || de->getSym()->isInResult() )
-		||
-	        ! de->getEdge()->isInResult() );
-
-
-	// include the linework if it's in the result of the operation
-	const Label& label = de->getLabel();
-	if ( OverlayOp::isResultOfOp(label, opCode)
-		&& opCode == OverlayOp::opINTERSECTION )
-	{
-		edges->push_back(de->getEdge());
-		de->setVisitedEdge(true);
-	}
+    if(de->isLineEdge()) {
+        return;    // only interested in area edges
+    }
+    if(de->isVisited()) {
+        return;    // already processed
+    }
+
+    // added to handle dimensional collapses
+    if(de->isInteriorAreaEdge()) {
+        return;
+    }
+
+    // if the edge linework is already included, don't include it again
+    if(de->getEdge()->isInResult()) {
+        return;
+    }
+
+    // sanity check for labelling of result edgerings
+    assert(!(de->isInResult() || de->getSym()->isInResult())
+           ||
+           ! de->getEdge()->isInResult());
+
+
+    // include the linework if it's in the result of the operation
+    const Label& label = de->getLabel();
+    if(OverlayOp::isResultOfOp(label, opCode)
+            && opCode == OverlayOp::opINTERSECTION) {
+        edges->push_back(de->getEdge());
+        de->setVisitedEdge(true);
+    }
 }
 
 void
 LineBuilder::buildLines(OverlayOp::OpCode /* opCode */)
 {
-	for(size_t i=0, s=lineEdgesList.size(); i<s; ++i)
-	{
-		Edge *e=lineEdgesList[i];
-		CoordinateSequence *cs = e->getCoordinates()->clone();
+    for(size_t i = 0, s = lineEdgesList.size(); i < s; ++i) {
+        Edge* e = lineEdgesList[i];
+        CoordinateSequence* cs = e->getCoordinates()->clone();
 #if COMPUTE_Z
-		propagateZ(cs);
+        propagateZ(cs);
 #endif
-		LineString *line=geometryFactory->createLineString(cs);
-		resultLineList->push_back(line);
-		e->setInResult(true);
-	}
+        LineString* line = geometryFactory->createLineString(cs);
+        resultLineList->push_back(line);
+        e->setInResult(true);
+    }
 }
 
 /*
@@ -207,111 +209,105 @@ LineBuilder::buildLines(OverlayOp::OpCode /* opCode */)
  * from a 3d vertex to the end.
  */
 void
-LineBuilder::propagateZ(CoordinateSequence *cs)
+LineBuilder::propagateZ(CoordinateSequence* cs)
 {
 #if GEOS_DEBUG
-	cerr<<"LineBuilder::propagateZ() called"<<endl;
+    cerr << "LineBuilder::propagateZ() called" << endl;
 #endif
 
-	vector<size_t> v3d; // vertex 3d
-	size_t cssize = cs->getSize();
-	for (size_t i = 0; i < cssize; ++i)
-	{
-		if ( !std::isnan(cs->getAt(i).z) ) v3d.push_back(i);
-	}
+    vector<size_t> v3d; // vertex 3d
+    size_t cssize = cs->getSize();
+    for(size_t i = 0; i < cssize; ++i) {
+        if(!std::isnan(cs->getAt(i).z)) {
+            v3d.push_back(i);
+        }
+    }
 
 #if GEOS_DEBUG
-	cerr<<"  found "<<v3d.size()<<" 3d vertexes"<<endl;
+    cerr << "  found " << v3d.size() << " 3d vertexes" << endl;
 #endif
 
-	if ( v3d.empty() )
-	{
+    if(v3d.empty()) {
 #if GEOS_DEBUG
-		cerr<<"  nothing to do"<<endl;
+        cerr << "  nothing to do" << endl;
 #endif
-		return;
-	}
-
-	Coordinate buf;
-
-	// fill initial part
-	if ( v3d[0] != 0 )
-	{
-		double z = cs->getAt(v3d[0]).z;
-		for (size_t j = 0; j < v3d[0]; ++j)
-		{
-			buf = cs->getAt(j);
-			buf.z = z;
-			cs->setAt(buf, j);
-		}
-	}
-
-	// interpolate inbetweens
-	size_t prev=v3d[0];
-	for (size_t i = 1; i < v3d.size(); ++i)
-	{
-		auto curr = v3d[i];
-		auto dist = curr - prev;
-		if (dist > 1)
-		{
-			const Coordinate &cto = cs->getAt(curr);
-			const Coordinate &cfrom = cs->getAt(prev);
-			double gap = cto.z - cfrom.z;
-			double zstep = gap / static_cast<double>(dist);
-			double z = cfrom.z;
-			for (size_t j = prev+1; j < curr; ++j)
-			{
-				buf = cs->getAt(j);
-				z+=zstep;
-				buf.z = z;
-				cs->setAt(buf, j);
-			}
-		}
-		prev = curr;
-	}
-
-	// fill final part
-	if ( prev < cssize-1 )
-	{
-		double z = cs->getAt(prev).z;
-		for (size_t j=prev+1; j<cssize; j++)
-		{
-			buf = cs->getAt(j);
-			buf.z = z;
-			cs->setAt(buf, j);
-		}
-	}
+        return;
+    }
+
+    Coordinate buf;
+
+    // fill initial part
+    if(v3d[0] != 0) {
+        double z = cs->getAt(v3d[0]).z;
+        for(size_t j = 0; j < v3d[0]; ++j) {
+            buf = cs->getAt(j);
+            buf.z = z;
+            cs->setAt(buf, j);
+        }
+    }
+
+    // interpolate inbetweens
+    size_t prev = v3d[0];
+    for(size_t i = 1; i < v3d.size(); ++i) {
+        auto curr = v3d[i];
+        auto dist = curr - prev;
+        if(dist > 1) {
+            const Coordinate& cto = cs->getAt(curr);
+            const Coordinate& cfrom = cs->getAt(prev);
+            double gap = cto.z - cfrom.z;
+            double zstep = gap / static_cast<double>(dist);
+            double z = cfrom.z;
+            for(size_t j = prev + 1; j < curr; ++j) {
+                buf = cs->getAt(j);
+                z += zstep;
+                buf.z = z;
+                cs->setAt(buf, j);
+            }
+        }
+        prev = curr;
+    }
+
+    // fill final part
+    if(prev < cssize - 1) {
+        double z = cs->getAt(prev).z;
+        for(size_t j = prev + 1; j < cssize; j++) {
+            buf = cs->getAt(j);
+            buf.z = z;
+            cs->setAt(buf, j);
+        }
+    }
 
 }
 
 
 
 void
-LineBuilder::labelIsolatedLines(vector<Edge*> *edgesList)
+LineBuilder::labelIsolatedLines(vector<Edge*>* edgesList)
 {
-	for(size_t i=0, s=edgesList->size(); i<s; ++i)
-	{
-		Edge *e=(*edgesList)[i];
-		const Label& label = e->getLabel();
-		//n.print(System.out);
-		if (e->isIsolated()) {
-			if (label.isNull(0))
-				labelIsolatedLine(e, 0);
-			else
-				labelIsolatedLine(e, 1);
-		}
-	}
+    for(size_t i = 0, s = edgesList->size(); i < s; ++i) {
+        Edge* e = (*edgesList)[i];
+        const Label& label = e->getLabel();
+        //n.print(System.out);
+        if(e->isIsolated()) {
+            if(label.isNull(0)) {
+                labelIsolatedLine(e, 0);
+            }
+            else {
+                labelIsolatedLine(e, 1);
+            }
+        }
+    }
 }
 
 /*
  * Label an isolated node with its relationship to the target geometry.
  */
 void
-LineBuilder::labelIsolatedLine(Edge *e, int targetIndex)
+LineBuilder::labelIsolatedLine(Edge* e, int targetIndex)
 {
-  int loc = ptLocator->locate( e->getCoordinate(),
-                               op->getArgGeometry(targetIndex) );
-	e->getLabel().setLocation(targetIndex,loc);
+    int loc = ptLocator->locate(e->getCoordinate(),
+                                op->getArgGeometry(targetIndex));
+    e->getLabel().setLocation(targetIndex, loc);
 }
 
 } // namespace geos.operation.overlay
diff --git a/src/operation/overlay/MaximalEdgeRing.cpp b/src/operation/overlay/MaximalEdgeRing.cpp
index cb69c98..2f4c1f2 100644
--- a/src/operation/overlay/MaximalEdgeRing.cpp
+++ b/src/operation/overlay/MaximalEdgeRing.cpp
@@ -45,16 +45,16 @@ namespace operation { // geos.operation
 namespace overlay { // geos.operation.overlay
 
 /*public*/
-MaximalEdgeRing::MaximalEdgeRing(DirectedEdge *start,
-		const GeometryFactory *p_geometryFactory)
-	// throw(const TopologyException &)
-	:
-	EdgeRing(start, p_geometryFactory)
+MaximalEdgeRing::MaximalEdgeRing(DirectedEdge* start,
+                                 const GeometryFactory* p_geometryFactory)
+// throw(const TopologyException &)
+    :
+    EdgeRing(start, p_geometryFactory)
 {
-	computePoints(start);
-	computeRing();
+    computePoints(start);
+    computeRing();
 #if GEOS_DEBUG
-	cerr << "MaximalEdgeRing[" << this << "] ctor" << endl;
+    cerr << "MaximalEdgeRing[" << this << "] ctor" << endl;
 #endif
 }
 
@@ -62,78 +62,81 @@ MaximalEdgeRing::MaximalEdgeRing(DirectedEdge *start,
 MaximalEdgeRing::~MaximalEdgeRing()
 {
 #if GEOS_DEBUG
-	cerr << "MaximalEdgeRing[" << this << "] dtor" << endl;
+    cerr << "MaximalEdgeRing[" << this << "] dtor" << endl;
 #endif
 }
 
 /*public*/
 DirectedEdge*
-MaximalEdgeRing::getNext(DirectedEdge *de)
+MaximalEdgeRing::getNext(DirectedEdge* de)
 {
-	return de->getNext();
+    return de->getNext();
 }
 
 /*public*/
 void
-MaximalEdgeRing::setEdgeRing(DirectedEdge *de,EdgeRing *er)
+MaximalEdgeRing::setEdgeRing(DirectedEdge* de, EdgeRing* er)
 {
-	de->setEdgeRing(er);
+    de->setEdgeRing(er);
 }
 
 /*public*/
 void
 MaximalEdgeRing::linkDirectedEdgesForMinimalEdgeRings()
 {
-	DirectedEdge* de=startDe;
-	do {
-		Node* node=de->getNode();
-		EdgeEndStar* ees = node->getEdges();
+    DirectedEdge* de = startDe;
+    do {
+        Node* node = de->getNode();
+        EdgeEndStar* ees = node->getEdges();
 
-		assert(dynamic_cast<DirectedEdgeStar*>(ees));
-		DirectedEdgeStar* des = static_cast<DirectedEdgeStar*>(ees);
+        assert(dynamic_cast<DirectedEdgeStar*>(ees));
+        DirectedEdgeStar* des = static_cast<DirectedEdgeStar*>(ees);
 
-		des->linkMinimalDirectedEdges(this);
+        des->linkMinimalDirectedEdges(this);
 
-		de=de->getNext();
+        de = de->getNext();
 
-	} while (de!=startDe);
+    }
+    while(de != startDe);
 }
 
 /*public*/
 vector<MinimalEdgeRing*>*
 MaximalEdgeRing::buildMinimalRings()
 {
-	vector<MinimalEdgeRing*> *minEdgeRings=new vector<MinimalEdgeRing*>;
-	buildMinimalRings(*minEdgeRings);
-	return minEdgeRings;
+    vector<MinimalEdgeRing*>* minEdgeRings = new vector<MinimalEdgeRing*>;
+    buildMinimalRings(*minEdgeRings);
+    return minEdgeRings;
 }
 
 /*public*/
 void
 MaximalEdgeRing::buildMinimalRings(vector<MinimalEdgeRing*>& minEdgeRings)
 {
-	DirectedEdge *de=startDe;
-	do {
-		if(de->getMinEdgeRing()==nullptr) {
-			MinimalEdgeRing *minEr=new MinimalEdgeRing(de, geometryFactory);
-			minEdgeRings.push_back(minEr);
-		}
-		de=de->getNext();
-	} while(de!=startDe);
+    DirectedEdge* de = startDe;
+    do {
+        if(de->getMinEdgeRing() == nullptr) {
+            MinimalEdgeRing* minEr = new MinimalEdgeRing(de, geometryFactory);
+            minEdgeRings.push_back(minEr);
+        }
+        de = de->getNext();
+    }
+    while(de != startDe);
 }
 
 /*public*/
 void
 MaximalEdgeRing::buildMinimalRings(vector<EdgeRing*>& minEdgeRings)
 {
-	DirectedEdge *de=startDe;
-	do {
-		if(de->getMinEdgeRing()==nullptr) {
-			MinimalEdgeRing *minEr=new MinimalEdgeRing(de, geometryFactory);
-			minEdgeRings.push_back(minEr);
-		}
-		de=de->getNext();
-	} while(de!=startDe);
+    DirectedEdge* de = startDe;
+    do {
+        if(de->getMinEdgeRing() == nullptr) {
+            MinimalEdgeRing* minEr = new MinimalEdgeRing(de, geometryFactory);
+            minEdgeRings.push_back(minEr);
+        }
+        de = de->getNext();
+    }
+    while(de != startDe);
 }
 
 } // namespace geos.operation.overlay
diff --git a/src/operation/overlay/MinimalEdgeRing.cpp b/src/operation/overlay/MinimalEdgeRing.cpp
index 197433f..fff434b 100644
--- a/src/operation/overlay/MinimalEdgeRing.cpp
+++ b/src/operation/overlay/MinimalEdgeRing.cpp
@@ -36,15 +36,15 @@ namespace geos {
 namespace operation { // geos.operation
 namespace overlay { // geos.operation.overlay
 
-MinimalEdgeRing::MinimalEdgeRing(geomgraph::DirectedEdge *start,
-		const geom::GeometryFactory *p_geometryFactory)
-	:
-	geomgraph::EdgeRing(start, p_geometryFactory)
+MinimalEdgeRing::MinimalEdgeRing(geomgraph::DirectedEdge* start,
+                                 const geom::GeometryFactory* p_geometryFactory)
+    :
+    geomgraph::EdgeRing(start, p_geometryFactory)
 {
-	computePoints(start);
-	computeRing();
+    computePoints(start);
+    computeRing();
 #if GEOS_DEBUG
-	std::cerr << "MinimalEdgeRing[" << this << "] ctor" << std::endl;
+    std::cerr << "MinimalEdgeRing[" << this << "] ctor" << std::endl;
 #endif
 }
 
diff --git a/src/operation/overlay/OverlayNodeFactory.cpp b/src/operation/overlay/OverlayNodeFactory.cpp
index 88fe681..095008d 100644
--- a/src/operation/overlay/OverlayNodeFactory.cpp
+++ b/src/operation/overlay/OverlayNodeFactory.cpp
@@ -28,16 +28,16 @@ namespace operation { // geos.operation
 namespace overlay { // geos.operation.overlay
 
 Node*
-OverlayNodeFactory::createNode(const geom::Coordinate &coord) const
+OverlayNodeFactory::createNode(const geom::Coordinate& coord) const
 {
-	return new Node(coord, new DirectedEdgeStar());
+    return new Node(coord, new DirectedEdgeStar());
 }
 
-const NodeFactory &
+const NodeFactory&
 OverlayNodeFactory::instance()
 {
-  static OverlayNodeFactory onf;
-	return onf;
+    static OverlayNodeFactory onf;
+    return onf;
 }
 
 } // namespace geos.operation.overlay
diff --git a/src/operation/overlay/OverlayOp.cpp b/src/operation/overlay/OverlayOp.cpp
index 1621d3b..65274a6 100644
--- a/src/operation/overlay/OverlayOp.cpp
+++ b/src/operation/overlay/OverlayOp.cpp
@@ -85,21 +85,21 @@ namespace overlay { // geos.operation.overlay
 
 /* static public */
 Geometry*
-OverlayOp::overlayOp(const Geometry *geom0, const Geometry *geom1,
-		OverlayOp::OpCode opCode)
-	// throw(TopologyException *)
+OverlayOp::overlayOp(const Geometry* geom0, const Geometry* geom1,
+                     OverlayOp::OpCode opCode)
+// throw(TopologyException *)
 {
-	OverlayOp gov(geom0, geom1);
-	return gov.getResultGeometry(opCode);
+    OverlayOp gov(geom0, geom1);
+    return gov.getResultGeometry(opCode);
 }
 
 /* static public */
 bool
 OverlayOp::isResultOfOp(const Label& label, OverlayOp::OpCode opCode)
 {
-	int loc0 = label.getLocation(0);
-	int loc1 = label.getLocation(1);
-	return isResultOfOp(loc0, loc1, opCode);
+    int loc0 = label.getLocation(0);
+    int loc1 = label.getLocation(1);
+    return isResultOfOp(loc0, loc1, opCode);
 }
 
 
@@ -107,60 +107,64 @@ OverlayOp::isResultOfOp(const Label& label, OverlayOp::OpCode opCode)
 bool
 OverlayOp::isResultOfOp(int loc0, int loc1, OverlayOp::OpCode opCode)
 {
-	if (loc0==Location::BOUNDARY) loc0=Location::INTERIOR;
-	if (loc1==Location::BOUNDARY) loc1=Location::INTERIOR;
-	switch (opCode) {
-		case opINTERSECTION:
-			return loc0==Location::INTERIOR && loc1==Location::INTERIOR;
-		case opUNION:
-			return loc0==Location::INTERIOR || loc1==Location::INTERIOR;
-		case opDIFFERENCE:
-			return loc0==Location::INTERIOR && loc1!=Location::INTERIOR;
-		case opSYMDIFFERENCE:
-			return (loc0==Location::INTERIOR && loc1!=Location::INTERIOR)
-				|| (loc0!=Location::INTERIOR && loc1==Location::INTERIOR);
-	}
-	return false;
+    if(loc0 == Location::BOUNDARY) {
+        loc0 = Location::INTERIOR;
+    }
+    if(loc1 == Location::BOUNDARY) {
+        loc1 = Location::INTERIOR;
+    }
+    switch(opCode) {
+    case opINTERSECTION:
+        return loc0 == Location::INTERIOR && loc1 == Location::INTERIOR;
+    case opUNION:
+        return loc0 == Location::INTERIOR || loc1 == Location::INTERIOR;
+    case opDIFFERENCE:
+        return loc0 == Location::INTERIOR && loc1 != Location::INTERIOR;
+    case opSYMDIFFERENCE:
+        return (loc0 == Location::INTERIOR && loc1 != Location::INTERIOR)
+               || (loc0 != Location::INTERIOR && loc1 == Location::INTERIOR);
+    }
+    return false;
 }
 
-OverlayOp::OverlayOp(const Geometry *g0, const Geometry *g1)
+OverlayOp::OverlayOp(const Geometry* g0, const Geometry* g1)
 
-	:
+    :
 
-	// this builds graphs in arg[0] and arg[1]
-	GeometryGraphOperation(g0, g1),
+    // this builds graphs in arg[0] and arg[1]
+    GeometryGraphOperation(g0, g1),
 
-	/*
-	 * Use factory of primary geometry.
-	 * Note that this does NOT handle mixed-precision arguments
-	 * where the second arg has greater precision than the first.
-	 */
-	geomFact(g0->getFactory()),
+    /*
+     * Use factory of primary geometry.
+     * Note that this does NOT handle mixed-precision arguments
+     * where the second arg has greater precision than the first.
+     */
+    geomFact(g0->getFactory()),
 
-	resultGeom(nullptr),
-	graph(OverlayNodeFactory::instance()),
-	resultPolyList(nullptr),
-	resultLineList(nullptr),
-	resultPointList(nullptr)
+    resultGeom(nullptr),
+    graph(OverlayNodeFactory::instance()),
+    resultPolyList(nullptr),
+    resultLineList(nullptr),
+    resultPointList(nullptr)
 
 {
 
 #if COMPUTE_Z
 #if USE_INPUT_AVGZ
-	avgz[0] = DoubleNotANumber;
-	avgz[1] = DoubleNotANumber;
-	avgzcomputed[0] = false;
-	avgzcomputed[1] = false;
+    avgz[0] = DoubleNotANumber;
+    avgz[1] = DoubleNotANumber;
+    avgzcomputed[0] = false;
+    avgzcomputed[1] = false;
 #endif // USE_INPUT_AVGZ
 
-	Envelope env(*(g0->getEnvelopeInternal()));
-	env.expandToInclude(g1->getEnvelopeInternal());
+    Envelope env(*(g0->getEnvelopeInternal()));
+    env.expandToInclude(g1->getEnvelopeInternal());
 #if USE_ELEVATION_MATRIX
-	elevationMatrix = new ElevationMatrix(env, 3, 3);
-	elevationMatrix->add(g0);
-	elevationMatrix->add(g1);
+    elevationMatrix = new ElevationMatrix(env, 3, 3);
+    elevationMatrix->add(g0);
+    elevationMatrix->add(g1);
 #if GEOS_DEBUG
-	cerr<<elevationMatrix->print()<<endl;
+    cerr << elevationMatrix->print() << endl;
 #endif
 #endif // USE_ELEVATION_MATRIX
 #endif // COMPUTE_Z
@@ -168,143 +172,142 @@ OverlayOp::OverlayOp(const Geometry *g0, const Geometry *g1)
 
 OverlayOp::~OverlayOp()
 {
-	//delete edgeList;
-	delete resultPolyList;
-	delete resultLineList;
-	delete resultPointList;
-	for (size_t i=0; i<dupEdges.size(); i++)
-		delete dupEdges[i];
+    //delete edgeList;
+    delete resultPolyList;
+    delete resultLineList;
+    delete resultPointList;
+    for(size_t i = 0; i < dupEdges.size(); i++) {
+        delete dupEdges[i];
+    }
 #if USE_ELEVATION_MATRIX
-	delete elevationMatrix;
+    delete elevationMatrix;
 #endif
 }
 
 /*public*/
 Geometry*
 OverlayOp::getResultGeometry(OverlayOp::OpCode funcCode)
-	//throw(TopologyException *)
+//throw(TopologyException *)
 {
-	computeOverlay(funcCode);
-	return resultGeom;
+    computeOverlay(funcCode);
+    return resultGeom;
 }
 
 /*private*/
 void
-OverlayOp::insertUniqueEdges(vector<Edge*> *edges, const Envelope *env)
+OverlayOp::insertUniqueEdges(vector<Edge*>* edges, const Envelope* env)
 {
-  for(size_t i=0, n=edges->size(); i<n; ++i) {
-    Edge *e = (*edges)[i];
-		if ( env && ! env->intersects(e->getEnvelope()) ) {
-		  dupEdges.push_back(e); // or could it be deleted directly ?
-      continue;
-    }
+    for(size_t i = 0, n = edges->size(); i < n; ++i) {
+        Edge* e = (*edges)[i];
+        if(env && ! env->intersects(e->getEnvelope())) {
+            dupEdges.push_back(e); // or could it be deleted directly ?
+            continue;
+        }
 #if GEOS_DEBUG
-		cerr <<" "<< e->print() << endl;
+        cerr << " " << e->print() << endl;
 #endif
-    insertUniqueEdge(e);
-  }
-/*
-	for_each(edges->begin(), edges->end(),
-			bind1st(mem_fun(&OverlayOp::insertUniqueEdge), this));
-*/
+        insertUniqueEdge(e);
+    }
+    /*
+    	for_each(edges->begin(), edges->end(),
+    			bind1st(mem_fun(&OverlayOp::insertUniqueEdge), this));
+    */
 }
 
 /*private*/
 void
 OverlayOp::replaceCollapsedEdges()
 {
-	vector<Edge*>& edges=edgeList.getEdges();
-
-	for(size_t i=0, nedges=edges.size(); i<nedges; ++i)
-	{
-		Edge *e=edges[i];
-		assert(e);
-		if (e->isCollapsed())
-		{
+    vector<Edge*>& edges = edgeList.getEdges();
+
+    for(size_t i = 0, nedges = edges.size(); i < nedges; ++i) {
+        Edge* e = edges[i];
+        assert(e);
+        if(e->isCollapsed()) {
 #if GEOS_DEBUG
-		cerr << " replacing collapsed edge " << i << endl;
+            cerr << " replacing collapsed edge " << i << endl;
 #endif // GEOS_DEBUG
-			//Debug.print(e);
-			edges[i]=e->getCollapsedEdge();
+            //Debug.print(e);
+            edges[i] = e->getCollapsedEdge();
 
-			// should we keep this alive some more ?
-			delete e;
-		}
-	}
+            // should we keep this alive some more ?
+            delete e;
+        }
+    }
 }
 
 /*private*/
 void
-OverlayOp::copyPoints(int argIndex, const Envelope *env)
+OverlayOp::copyPoints(int argIndex, const Envelope* env)
 {
 //#define GEOS_DEBUG_COPY_POINTS 1
 
 #ifdef GEOS_DEBUG_COPY_POINTS
-	int copied = 0;
+    int copied = 0;
 #endif
 
-	//env = 0; // WARNING: uncomment to disable env-optimization
+    //env = 0; // WARNING: uncomment to disable env-optimization
 
-	// TODO: set env to null if it covers arg geometry envelope
+    // TODO: set env to null if it covers arg geometry envelope
 
-	NodeMap::container& nodeMap=arg[argIndex]->getNodeMap()->nodeMap;
-	for ( NodeMap::const_iterator it=nodeMap.begin(), itEnd=nodeMap.end();
-			it != itEnd; ++it )
-	{
-		Node* graphNode=it->second;
-		assert(graphNode);
-		const Coordinate &coord = graphNode->getCoordinate();
+    NodeMap::container& nodeMap = arg[argIndex]->getNodeMap()->nodeMap;
+    for(NodeMap::const_iterator it = nodeMap.begin(), itEnd = nodeMap.end();
+            it != itEnd; ++it) {
+        Node* graphNode = it->second;
+        assert(graphNode);
+        const Coordinate& coord = graphNode->getCoordinate();
 
-		if ( env && ! env->covers(coord) ) continue;
+        if(env && ! env->covers(coord)) {
+            continue;
+        }
 
 #ifdef GEOS_DEBUG_COPY_POINTS
-		++copied;
+        ++copied;
 #endif
-		Node* newNode=graph.addNode(coord);
-		assert(newNode);
+        Node* newNode = graph.addNode(coord);
+        assert(newNode);
 
-		newNode->setLabel(argIndex, graphNode->getLabel().getLocation(argIndex));
-	}
+        newNode->setLabel(argIndex, graphNode->getLabel().getLocation(argIndex));
+    }
 
 #ifdef GEOS_DEBUG_COPY_POINTS
-	cerr << "Copied " << copied << " nodes out of " << nodeMap.size() << " for geom " << argIndex << endl;
+    cerr << "Copied " << copied << " nodes out of " << nodeMap.size() << " for geom " << argIndex << endl;
 #endif
 }
 
 /*private*/
 void
 OverlayOp::computeLabelling()
-	//throw(TopologyException *) // and what else ?
+//throw(TopologyException *) // and what else ?
 {
-	NodeMap::container& nodeMap=graph.getNodeMap()->nodeMap;
+    NodeMap::container& nodeMap = graph.getNodeMap()->nodeMap;
 
 #if GEOS_DEBUG
-	cerr<<"OverlayOp::computeLabelling(): at call time: "<<edgeList.print()<<endl;
+    cerr << "OverlayOp::computeLabelling(): at call time: " << edgeList.print() << endl;
 #endif
 
 #if GEOS_DEBUG
-	cerr<<"OverlayOp::computeLabelling() scanning "<<nodeMap.size()<<" nodes from map:"<<endl;
+    cerr << "OverlayOp::computeLabelling() scanning " << nodeMap.size() << " nodes from map:" << endl;
 #endif
 
-	for ( NodeMap::const_iterator it=nodeMap.begin(), itEnd=nodeMap.end();
-			it != itEnd; ++it )
-	{
-		Node *node=it->second;
+    for(NodeMap::const_iterator it = nodeMap.begin(), itEnd = nodeMap.end();
+            it != itEnd; ++it) {
+        Node* node = it->second;
 #if GEOS_DEBUG
-		cerr<<"     "<<node->print()<<" has "<<node->getEdges()->getEdges().size()<<" edgeEnds"<<endl;
+        cerr << "     " << node->print() << " has " << node->getEdges()->getEdges().size() << " edgeEnds" << endl;
 #endif
-		node->getEdges()->computeLabelling(&arg);
-	}
+        node->getEdges()->computeLabelling(&arg);
+    }
 #if GEOS_DEBUG
-	cerr<<"OverlayOp::computeLabelling(): after edge labelling: "<<edgeList.print()<<endl;
+    cerr << "OverlayOp::computeLabelling(): after edge labelling: " << edgeList.print() << endl;
 #endif
-	mergeSymLabels();
+    mergeSymLabels();
 #if GEOS_DEBUG
-	cerr<<"OverlayOp::computeLabelling(): after labels sym merging: "<<edgeList.print()<<endl;
+    cerr << "OverlayOp::computeLabelling(): after labels sym merging: " << edgeList.print() << endl;
 #endif
-	updateNodeLabelling();
+    updateNodeLabelling();
 #if GEOS_DEBUG
-	cerr<<"OverlayOp::computeLabelling(): after node labeling update: "<<edgeList.print()<<endl;
+    cerr << "OverlayOp::computeLabelling(): after node labeling update: " << edgeList.print() << endl;
 #endif
 }
 
@@ -312,726 +315,716 @@ OverlayOp::computeLabelling()
 void
 OverlayOp::mergeSymLabels()
 {
-	NodeMap::container& nodeMap=graph.getNodeMap()->nodeMap;
+    NodeMap::container& nodeMap = graph.getNodeMap()->nodeMap;
 
 #if GEOS_DEBUG
-	cerr<<"OverlayOp::mergeSymLabels() scanning "<<nodeMap.size()<<" nodes from map:"<<endl;
+    cerr << "OverlayOp::mergeSymLabels() scanning " << nodeMap.size() << " nodes from map:" << endl;
 #endif
 
-	for ( NodeMap::const_iterator it=nodeMap.begin(), itEnd=nodeMap.end();
-			it != itEnd; ++it )
-	{
-		Node *node=it->second;
-		EdgeEndStar* ees=node->getEdges();
-		assert(dynamic_cast<DirectedEdgeStar*>(ees));
-		static_cast<DirectedEdgeStar*>(ees)->mergeSymLabels();
-		//((DirectedEdgeStar*)node->getEdges())->mergeSymLabels();
+    for(NodeMap::const_iterator it = nodeMap.begin(), itEnd = nodeMap.end();
+            it != itEnd; ++it) {
+        Node* node = it->second;
+        EdgeEndStar* ees = node->getEdges();
+        assert(dynamic_cast<DirectedEdgeStar*>(ees));
+        static_cast<DirectedEdgeStar*>(ees)->mergeSymLabels();
+        //((DirectedEdgeStar*)node->getEdges())->mergeSymLabels();
 #if GEOS_DEBUG
-		cerr<<"     "<<node->print()<<endl;
+        cerr << "     " << node->print() << endl;
 #endif
-		//node.print(System.out);
-	}
+        //node.print(System.out);
+    }
 }
 
 /*private*/
 void
 OverlayOp::updateNodeLabelling()
 {
-	// update the labels for nodes
-	// The label for a node is updated from the edges incident on it
-	// (Note that a node may have already been labelled
-	// because it is a point in one of the input geometries)
+    // update the labels for nodes
+    // The label for a node is updated from the edges incident on it
+    // (Note that a node may have already been labelled
+    // because it is a point in one of the input geometries)
 
-	NodeMap::container& nodeMap=graph.getNodeMap()->nodeMap;
+    NodeMap::container& nodeMap = graph.getNodeMap()->nodeMap;
 
 #if GEOS_DEBUG
-	cerr << "OverlayOp::updateNodeLabelling() scanning "
-	     << nodeMap.size() << " nodes from map:" << endl;
+    cerr << "OverlayOp::updateNodeLabelling() scanning "
+         << nodeMap.size() << " nodes from map:" << endl;
 #endif
 
-	for ( NodeMap::const_iterator it=nodeMap.begin(), itEnd=nodeMap.end();
-			it != itEnd; ++it )
-	{
-		Node *node=it->second;
-		EdgeEndStar* ees = node->getEdges();
-		assert( dynamic_cast<DirectedEdgeStar*>(ees) );
-		DirectedEdgeStar* des = static_cast<DirectedEdgeStar*>(ees);
-		Label &lbl = des->getLabel();
-		node->getLabel().merge(lbl);
+    for(NodeMap::const_iterator it = nodeMap.begin(), itEnd = nodeMap.end();
+            it != itEnd; ++it) {
+        Node* node = it->second;
+        EdgeEndStar* ees = node->getEdges();
+        assert(dynamic_cast<DirectedEdgeStar*>(ees));
+        DirectedEdgeStar* des = static_cast<DirectedEdgeStar*>(ees);
+        Label& lbl = des->getLabel();
+        node->getLabel().merge(lbl);
 #if GEOS_DEBUG
-		cerr<<"     "<<node->print()<<endl;
+        cerr << "     " << node->print() << endl;
 #endif
-	}
+    }
 }
 
 /*private*/
 void
 OverlayOp::labelIncompleteNodes()
 {
-	NodeMap::container& nodeMap=graph.getNodeMap()->nodeMap;
+    NodeMap::container& nodeMap = graph.getNodeMap()->nodeMap;
 
 #if GEOS_DEBUG
-	cerr<<"OverlayOp::labelIncompleteNodes() scanning "<<nodeMap.size()<<" nodes from map:"<<endl;
+    cerr << "OverlayOp::labelIncompleteNodes() scanning " << nodeMap.size() << " nodes from map:" << endl;
 #endif
 
-	for ( NodeMap::const_iterator it=nodeMap.begin(), itEnd=nodeMap.end();
-			it != itEnd; ++it )
-	{
-		Node *n=it->second;
-		const Label& label = n->getLabel();
-		if (n->isIsolated())
-		{
-			if (label.isNull(0))
-			{
-				labelIncompleteNode(n,0);
-			}
-			else
-			{
-				labelIncompleteNode(n, 1);
-			}
-		}
-		// now update the labelling for the DirectedEdges incident on this node
-		EdgeEndStar* ees = n->getEdges();
-		assert( dynamic_cast<DirectedEdgeStar*>(ees) );
-		DirectedEdgeStar* des = static_cast<DirectedEdgeStar*>(ees);
-
-		des->updateLabelling(label);
-		//((DirectedEdgeStar*)n->getEdges())->updateLabelling(label);
-		//n.print(System.out);
-	}
+    for(NodeMap::const_iterator it = nodeMap.begin(), itEnd = nodeMap.end();
+            it != itEnd; ++it) {
+        Node* n = it->second;
+        const Label& label = n->getLabel();
+        if(n->isIsolated()) {
+            if(label.isNull(0)) {
+                labelIncompleteNode(n, 0);
+            }
+            else {
+                labelIncompleteNode(n, 1);
+            }
+        }
+        // now update the labelling for the DirectedEdges incident on this node
+        EdgeEndStar* ees = n->getEdges();
+        assert(dynamic_cast<DirectedEdgeStar*>(ees));
+        DirectedEdgeStar* des = static_cast<DirectedEdgeStar*>(ees);
+
+        des->updateLabelling(label);
+        //((DirectedEdgeStar*)n->getEdges())->updateLabelling(label);
+        //n.print(System.out);
+    }
 }
 
 /*private*/
 void
-OverlayOp::labelIncompleteNode(Node *n, int targetIndex)
+OverlayOp::labelIncompleteNode(Node* n, int targetIndex)
 {
 #if GEOS_DEBUG
-	cerr<<"OverlayOp::labelIncompleteNode("<<n->print()<<", "<<targetIndex<<")"<<endl;
+    cerr << "OverlayOp::labelIncompleteNode(" << n->print() << ", " << targetIndex << ")" << endl;
 #endif
-	const Geometry *targetGeom = arg[targetIndex]->getGeometry();
-	int loc=ptLocator.locate(n->getCoordinate(), targetGeom);
-	n->getLabel().setLocation(targetIndex, loc);
+    const Geometry* targetGeom = arg[targetIndex]->getGeometry();
+    int loc = ptLocator.locate(n->getCoordinate(), targetGeom);
+    n->getLabel().setLocation(targetIndex, loc);
 
 #if GEOS_DEBUG
-	cerr<<"   after location set: "<<n->print()<<endl;
+    cerr << "   after location set: " << n->print() << endl;
 #endif
 
 #if COMPUTE_Z
-	/*
-	 * If this node has been labeled INTERIOR of a line
-	 * or BOUNDARY of a polygon we must merge
-	 * Z values of the intersected segment.
-	 * The intersection point has been already computed
-	 * by LineIntersector invoked by PointLocator.
-	 */
-
-	// Only do this if input does have Z
-	// See https://trac.osgeo.org/geos/ticket/811
-	if(targetGeom->getCoordinateDimension() < 3 ) return;
-
-	const LineString *line = dynamic_cast<const LineString *>(targetGeom);
-	if ( loc == Location::INTERIOR && line )
-	{
-		mergeZ(n, line);
-	}
-	const Polygon *poly = dynamic_cast<const Polygon *>(targetGeom);
-	if ( loc == Location::BOUNDARY && poly )
-	{
-		mergeZ(n, poly);
-	}
+    /*
+     * If this node has been labeled INTERIOR of a line
+     * or BOUNDARY of a polygon we must merge
+     * Z values of the intersected segment.
+     * The intersection point has been already computed
+     * by LineIntersector invoked by PointLocator.
+     */
+
+    // Only do this if input does have Z
+    // See https://trac.osgeo.org/geos/ticket/811
+    if(targetGeom->getCoordinateDimension() < 3) {
+        return;
+    }
+
+    const LineString* line = dynamic_cast<const LineString*>(targetGeom);
+    if(loc == Location::INTERIOR && line) {
+        mergeZ(n, line);
+    }
+    const Polygon* poly = dynamic_cast<const Polygon*>(targetGeom);
+    if(loc == Location::BOUNDARY && poly) {
+        mergeZ(n, poly);
+    }
 #if USE_INPUT_AVGZ
-	if ( loc == Location::INTERIOR && poly )
-	{
-		n->addZ(getAverageZ(targetIndex));
-	}
+    if(loc == Location::INTERIOR && poly) {
+        n->addZ(getAverageZ(targetIndex));
+    }
 #endif // USE_INPUT_AVGZ
 #endif // COMPUTE_Z
 }
 
 /*static private*/
 double
-OverlayOp::getAverageZ(const Polygon *poly)
+OverlayOp::getAverageZ(const Polygon* poly)
 {
-	double totz = 0.0;
-	int zcount = 0;
-
-	const CoordinateSequence *pts =
-		poly->getExteriorRing()->getCoordinatesRO();
-	size_t npts=pts->getSize();
-	for (size_t i=0; i<npts; ++i)
-	{
-		const Coordinate &c = pts->getAt(i);
-		if ( !std::isnan(c.z) )
-		{
-			totz += c.z;
-			zcount++;
-		}
-	}
-
-	if ( zcount ) return totz/zcount;
-	else return DoubleNotANumber;
+    double totz = 0.0;
+    int zcount = 0;
+
+    const CoordinateSequence* pts =
+        poly->getExteriorRing()->getCoordinatesRO();
+    size_t npts = pts->getSize();
+    for(size_t i = 0; i < npts; ++i) {
+        const Coordinate& c = pts->getAt(i);
+        if(!std::isnan(c.z)) {
+            totz += c.z;
+            zcount++;
+        }
+    }
+
+    if(zcount) {
+        return totz / zcount;
+    }
+    else {
+        return DoubleNotANumber;
+    }
 }
 
 /*private*/
 double
 OverlayOp::getAverageZ(int targetIndex)
 {
-	if ( avgzcomputed[targetIndex] ) return avgz[targetIndex];
+    if(avgzcomputed[targetIndex]) {
+        return avgz[targetIndex];
+    }
 
-	const Geometry *targetGeom = arg[targetIndex]->getGeometry();
+    const Geometry* targetGeom = arg[targetIndex]->getGeometry();
 
-	// OverlayOp::getAverageZ(int) called with a ! polygon
-	assert(targetGeom->getGeometryTypeId() == GEOS_POLYGON);
+    // OverlayOp::getAverageZ(int) called with a ! polygon
+    assert(targetGeom->getGeometryTypeId() == GEOS_POLYGON);
 
-	const Polygon* p = dynamic_cast<const Polygon*>(targetGeom);
-	avgz[targetIndex] = getAverageZ(p);
-	avgzcomputed[targetIndex] = true;
-	return avgz[targetIndex];
+    const Polygon* p = dynamic_cast<const Polygon*>(targetGeom);
+    avgz[targetIndex] = getAverageZ(p);
+    avgzcomputed[targetIndex] = true;
+    return avgz[targetIndex];
 }
 
 /*private*/
 int
-OverlayOp::mergeZ(Node *n, const Polygon *poly) const
+OverlayOp::mergeZ(Node* n, const Polygon* poly) const
 {
-	const LineString *ls;
-	int found = 0;
-	ls = poly->getExteriorRing();
-	found = mergeZ(n, ls);
-	if ( found ) return 1;
-	for (size_t i=0, nr=poly->getNumInteriorRing(); i<nr; ++i)
-	{
-		ls = poly->getInteriorRingN(i);
-		found = mergeZ(n, ls);
-		if ( found ) return 1;
-	}
-	return 0;
+    const LineString* ls;
+    int found = 0;
+    ls = poly->getExteriorRing();
+    found = mergeZ(n, ls);
+    if(found) {
+        return 1;
+    }
+    for(size_t i = 0, nr = poly->getNumInteriorRing(); i < nr; ++i) {
+        ls = poly->getInteriorRingN(i);
+        found = mergeZ(n, ls);
+        if(found) {
+            return 1;
+        }
+    }
+    return 0;
 }
 
 /*private*/
 int
-OverlayOp::mergeZ(Node *n, const LineString *line) const
+OverlayOp::mergeZ(Node* n, const LineString* line) const
 {
-	const CoordinateSequence *pts = line->getCoordinatesRO();
-	const Coordinate &p = n->getCoordinate();
-	LineIntersector p_li;
-	for(size_t i=1, size=pts->size(); i<size; ++i)
-	{
-		const Coordinate &p0=pts->getAt(i-1);
-		const Coordinate &p1=pts->getAt(i);
-		p_li.computeIntersection(p, p0, p1);
-		if (p_li.hasIntersection())
-		{
-			if ( p == p0 )
-			{
-				n->addZ(p0.z);
-			}
-			else if ( p == p1 )
-			{
-				n->addZ(p1.z);
-			}
-			else
-			{
-				n->addZ(LineIntersector::interpolateZ(p,
-					p0, p1));
-			}
-			return 1;
-		}
-	}
-	return 0;
+    const CoordinateSequence* pts = line->getCoordinatesRO();
+    const Coordinate& p = n->getCoordinate();
+    LineIntersector p_li;
+    for(size_t i = 1, size = pts->size(); i < size; ++i) {
+        const Coordinate& p0 = pts->getAt(i - 1);
+        const Coordinate& p1 = pts->getAt(i);
+        p_li.computeIntersection(p, p0, p1);
+        if(p_li.hasIntersection()) {
+            if(p == p0) {
+                n->addZ(p0.z);
+            }
+            else if(p == p1) {
+                n->addZ(p1.z);
+            }
+            else {
+                n->addZ(LineIntersector::interpolateZ(p,
+                                                      p0, p1));
+            }
+            return 1;
+        }
+    }
+    return 0;
 }
 
 /*private*/
 void
 OverlayOp::findResultAreaEdges(OverlayOp::OpCode opCode)
 {
-	vector<EdgeEnd*> *ee=graph.getEdgeEnds();
-	for(size_t i=0, e=ee->size(); i<e; ++i)
-	{
-		DirectedEdge *de=(DirectedEdge*) (*ee)[i];
-		// mark all dirEdges with the appropriate label
-		const Label& label = de->getLabel();
-		if ( label.isArea()
-			&& !de->isInteriorAreaEdge()
-			&& isResultOfOp(label.getLocation(0,Position::RIGHT),
-					label.getLocation(1,Position::RIGHT),
-					opCode)
-			)
-		{
-				de->setInResult(true);
-				//Debug.print("in result "); Debug.println(de);
-		}
-	}
+    vector<EdgeEnd*>* ee = graph.getEdgeEnds();
+    for(size_t i = 0, e = ee->size(); i < e; ++i) {
+        DirectedEdge* de = (DirectedEdge*)(*ee)[i];
+        // mark all dirEdges with the appropriate label
+        const Label& label = de->getLabel();
+        if(label.isArea()
+                && !de->isInteriorAreaEdge()
+                && isResultOfOp(label.getLocation(0, Position::RIGHT),
+                                label.getLocation(1, Position::RIGHT),
+                                opCode)
+          ) {
+            de->setInResult(true);
+            //Debug.print("in result "); Debug.println(de);
+        }
+    }
 }
 
 /*private*/
 void
 OverlayOp::cancelDuplicateResultEdges()
 {
-	// remove any dirEdges whose sym is also included
-	// (they "cancel each other out")
-	vector<EdgeEnd*> *ee=graph.getEdgeEnds();
-	for(size_t i=0, eesize=ee->size(); i<eesize; ++i)
-	{
-		DirectedEdge *de=static_cast<DirectedEdge*>( (*ee)[i] );
-		DirectedEdge *sym=de->getSym();
-		if (de->isInResult() && sym->isInResult()) {
-			de->setInResult(false);
-			sym->setInResult(false);
-			//Debug.print("cancelled "); Debug.println(de); Debug.println(sym);
-		}
-	}
+    // remove any dirEdges whose sym is also included
+    // (they "cancel each other out")
+    vector<EdgeEnd*>* ee = graph.getEdgeEnds();
+    for(size_t i = 0, eesize = ee->size(); i < eesize; ++i) {
+        DirectedEdge* de = static_cast<DirectedEdge*>((*ee)[i]);
+        DirectedEdge* sym = de->getSym();
+        if(de->isInResult() && sym->isInResult()) {
+            de->setInResult(false);
+            sym->setInResult(false);
+            //Debug.print("cancelled "); Debug.println(de); Debug.println(sym);
+        }
+    }
 }
 
 /*public*/
 bool
 OverlayOp::isCoveredByLA(const Coordinate& coord)
 {
-	if (isCovered(coord,resultLineList)) return true;
-	if (isCovered(coord,resultPolyList)) return true;
-	return false;
+    if(isCovered(coord, resultLineList)) {
+        return true;
+    }
+    if(isCovered(coord, resultPolyList)) {
+        return true;
+    }
+    return false;
 }
 
 /*public*/
 bool
 OverlayOp::isCoveredByA(const Coordinate& coord)
 {
-	if (isCovered(coord,resultPolyList)) return true;
-	return false;
+    if(isCovered(coord, resultPolyList)) {
+        return true;
+    }
+    return false;
 }
 
 /*private*/
 bool
-OverlayOp::isCovered(const Coordinate& coord,vector<Geometry*> *geomList)
+OverlayOp::isCovered(const Coordinate& coord, vector<Geometry*>* geomList)
 {
-	for(size_t i=0, n=geomList->size(); i<n; ++i)
-	{
-		Geometry *geom=(*geomList)[i];
-		int loc=ptLocator.locate(coord,geom);
-		if (loc!=Location::EXTERIOR) return true;
-	}
-	return false;
+    for(size_t i = 0, n = geomList->size(); i < n; ++i) {
+        Geometry* geom = (*geomList)[i];
+        int loc = ptLocator.locate(coord, geom);
+        if(loc != Location::EXTERIOR) {
+            return true;
+        }
+    }
+    return false;
 }
 
 /*private*/
 bool
-OverlayOp::isCovered(const Coordinate& coord,vector<LineString*> *geomList)
+OverlayOp::isCovered(const Coordinate& coord, vector<LineString*>* geomList)
 {
-	for(size_t i=0, n=geomList->size(); i<n; ++i)
-	{
-		Geometry *geom=(Geometry*)(*geomList)[i];
-		int loc=ptLocator.locate(coord,geom);
-		if (loc!=Location::EXTERIOR) return true;
-	}
-	return false;
+    for(size_t i = 0, n = geomList->size(); i < n; ++i) {
+        Geometry* geom = (Geometry*)(*geomList)[i];
+        int loc = ptLocator.locate(coord, geom);
+        if(loc != Location::EXTERIOR) {
+            return true;
+        }
+    }
+    return false;
 }
 
 /*private*/
 bool
-OverlayOp::isCovered(const Coordinate& coord,vector<Polygon*> *geomList)
+OverlayOp::isCovered(const Coordinate& coord, vector<Polygon*>* geomList)
 {
-	for(size_t i=0, n=geomList->size(); i<n; ++i)
-	{
-		Geometry *geom=(Geometry*)(*geomList)[i];
-		int loc=ptLocator.locate(coord,geom);
-		if (loc!=Location::EXTERIOR) return true;
-	}
-	return false;
+    for(size_t i = 0, n = geomList->size(); i < n; ++i) {
+        Geometry* geom = (Geometry*)(*geomList)[i];
+        int loc = ptLocator.locate(coord, geom);
+        if(loc != Location::EXTERIOR) {
+            return true;
+        }
+    }
+    return false;
 }
 
 Dimension::DimensionType
 OverlayOp::resultDimension(OverlayOp::OpCode overlayOpCode,
-                const Geometry *g0, const Geometry *g1)
+                           const Geometry* g0, const Geometry* g1)
 {
-	Dimension::DimensionType dim0 = g0->getDimension();
-	Dimension::DimensionType dim1 = g1->getDimension();
-
-	Dimension::DimensionType resultDimension = Dimension::False;
-	switch (overlayOpCode)
-	{
-		case OverlayOp::opINTERSECTION:
-			resultDimension = min(dim0, dim1);
-			break;
-		case OverlayOp::opUNION:
-			resultDimension = max(dim0, dim1);
-			break;
-		case OverlayOp::opDIFFERENCE:
-			resultDimension = dim0;
-			break;
-		case OverlayOp::opSYMDIFFERENCE:
-			resultDimension = max(dim0, dim1);
-			break;
-	}
-	return resultDimension;
+    Dimension::DimensionType dim0 = g0->getDimension();
+    Dimension::DimensionType dim1 = g1->getDimension();
+
+    Dimension::DimensionType resultDimension = Dimension::False;
+    switch(overlayOpCode) {
+    case OverlayOp::opINTERSECTION:
+        resultDimension = min(dim0, dim1);
+        break;
+    case OverlayOp::opUNION:
+        resultDimension = max(dim0, dim1);
+        break;
+    case OverlayOp::opDIFFERENCE:
+        resultDimension = dim0;
+        break;
+    case OverlayOp::opSYMDIFFERENCE:
+        resultDimension = max(dim0, dim1);
+        break;
+    }
+    return resultDimension;
 }
 
 geom::Geometry*
 OverlayOp::createEmptyResult(OverlayOp::OpCode overlayOpCode,
-                             const geom::Geometry *a, const geom::Geometry *b,
-                             const GeometryFactory *geomFact)
+                             const geom::Geometry* a, const geom::Geometry* b,
+                             const GeometryFactory* geomFact)
 {
-	geom::Geometry *result = nullptr;
-	switch (resultDimension(overlayOpCode, a, b))
-	{
-		case Dimension::P:
-			result = geomFact->createPoint();
-			break;
-		case Dimension::L:
-			result = geomFact->createLineString();
-			break;
-		case Dimension::A:
-			result = geomFact->createPolygon();
-			break;
-		default:
-			result = geomFact->createGeometryCollection();
-			break;
-	}
-	return result;
+    geom::Geometry* result = nullptr;
+    switch(resultDimension(overlayOpCode, a, b)) {
+    case Dimension::P:
+        result = geomFact->createPoint();
+        break;
+    case Dimension::L:
+        result = geomFact->createLineString();
+        break;
+    case Dimension::A:
+        result = geomFact->createPolygon();
+        break;
+    default:
+        result = geomFact->createGeometryCollection();
+        break;
+    }
+    return result;
 }
 
 /*private*/
 Geometry*
-OverlayOp::computeGeometry(vector<Point*> *nResultPointList,
-                           vector<LineString*> *nResultLineList,
-                           vector<Polygon*> *nResultPolyList,
+OverlayOp::computeGeometry(vector<Point*>* nResultPointList,
+                           vector<LineString*>* nResultLineList,
+                           vector<Polygon*>* nResultPolyList,
                            OverlayOp::OpCode opCode)
 {
-	size_t nPoints=nResultPointList->size();
-	size_t nLines=nResultLineList->size();
-	size_t nPolys=nResultPolyList->size();
-
-	std::unique_ptr<vector<Geometry*>> geomList{new vector<Geometry*>()};
-	geomList->reserve(nPoints+nLines+nPolys);
-
-	// element geometries of the result are always in the order P,L,A
-	geomList->insert(geomList->end(),
-			nResultPointList->begin(),
-			nResultPointList->end());
-
-	geomList->insert(geomList->end(),
-			nResultLineList->begin(),
-			nResultLineList->end());
-
-	geomList->insert(geomList->end(),
-			nResultPolyList->begin(),
-			nResultPolyList->end());
-
-
-	if (geomList->empty())
-	{
-		return createEmptyResult(opCode, arg[0]->getGeometry(),
-		                         arg[1]->getGeometry(), geomFact);
-	}
-	// build the most specific geometry possible
-	Geometry *g=geomFact->buildGeometry(geomList.release());
-	return g;
+    size_t nPoints = nResultPointList->size();
+    size_t nLines = nResultLineList->size();
+    size_t nPolys = nResultPolyList->size();
+
+    std::unique_ptr<vector<Geometry*>> geomList{new vector<Geometry*>()};
+    geomList->reserve(nPoints + nLines + nPolys);
+
+    // element geometries of the result are always in the order P,L,A
+    geomList->insert(geomList->end(),
+                     nResultPointList->begin(),
+                     nResultPointList->end());
+
+    geomList->insert(geomList->end(),
+                     nResultLineList->begin(),
+                     nResultLineList->end());
+
+    geomList->insert(geomList->end(),
+                     nResultPolyList->begin(),
+                     nResultPolyList->end());
+
+
+    if(geomList->empty()) {
+        return createEmptyResult(opCode, arg[0]->getGeometry(),
+                                 arg[1]->getGeometry(), geomFact);
+    }
+    // build the most specific geometry possible
+    Geometry* g = geomFact->buildGeometry(geomList.release());
+    return g;
 }
 
 /*private*/
 void
 OverlayOp::computeOverlay(OverlayOp::OpCode opCode)
-	//throw(TopologyException *)
+//throw(TopologyException *)
 {
 
-	// Compute the target envelope
-	const Envelope *env = nullptr;
-	const Envelope *env0 = getArgGeometry(0)->getEnvelopeInternal();
-	const Envelope *env1 = getArgGeometry(1)->getEnvelopeInternal();
-	Envelope opEnv;
-	if ( resultPrecisionModel->isFloating() )
-	{
-		// Envelope-based optimization only works in floating precision
-		switch (opCode) {
-			case opINTERSECTION:
-				env0->intersection(*env1, opEnv);
-				env = &opEnv;
-				break;
-			case opDIFFERENCE:
-				opEnv = *env0;
-				env = &opEnv;
-				break;
-			default:
-				break;
-		}
-	}
-	//env = 0; // WARNING: uncomment to disable env-optimization
-
-	// copy points from input Geometries.
-	// This ensures that any Point geometries
-	// in the input are considered for inclusion in the result set
-	copyPoints(0, env);
-	copyPoints(1, env);
-
-	GEOS_CHECK_FOR_INTERRUPTS();
-
-	// node the input Geometries
-	delete arg[0]->computeSelfNodes(li, false, env);
-	GEOS_CHECK_FOR_INTERRUPTS();
-	delete arg[1]->computeSelfNodes(li, false, env);
+    // Compute the target envelope
+    const Envelope* env = nullptr;
+    const Envelope* env0 = getArgGeometry(0)->getEnvelopeInternal();
+    const Envelope* env1 = getArgGeometry(1)->getEnvelopeInternal();
+    Envelope opEnv;
+    if(resultPrecisionModel->isFloating()) {
+        // Envelope-based optimization only works in floating precision
+        switch(opCode) {
+        case opINTERSECTION:
+            env0->intersection(*env1, opEnv);
+            env = &opEnv;
+            break;
+        case opDIFFERENCE:
+            opEnv = *env0;
+            env = &opEnv;
+            break;
+        default:
+            break;
+        }
+    }
+    //env = 0; // WARNING: uncomment to disable env-optimization
+
+    // copy points from input Geometries.
+    // This ensures that any Point geometries
+    // in the input are considered for inclusion in the result set
+    copyPoints(0, env);
+    copyPoints(1, env);
+
+    GEOS_CHECK_FOR_INTERRUPTS();
+
+    // node the input Geometries
+    delete arg[0]->computeSelfNodes(li, false, env);
+    GEOS_CHECK_FOR_INTERRUPTS();
+    delete arg[1]->computeSelfNodes(li, false, env);
 
 #if GEOS_DEBUG
-	cerr<<"OverlayOp::computeOverlay: computed SelfNodes"<<endl;
+    cerr << "OverlayOp::computeOverlay: computed SelfNodes" << endl;
 #endif
 
-	GEOS_CHECK_FOR_INTERRUPTS();
+    GEOS_CHECK_FOR_INTERRUPTS();
 
-	// compute intersections between edges of the two input geometries
-	delete arg[0]->computeEdgeIntersections(arg[1], &li, true, env);
+    // compute intersections between edges of the two input geometries
+    delete arg[0]->computeEdgeIntersections(arg[1], &li, true, env);
 
 #if GEOS_DEBUG
-	cerr<<"OverlayOp::computeOverlay: computed EdgeIntersections"<<endl;
-	cerr<<"OverlayOp::computeOverlay: li: "<<li.toString()<<endl;
+    cerr << "OverlayOp::computeOverlay: computed EdgeIntersections" << endl;
+    cerr << "OverlayOp::computeOverlay: li: " << li.toString() << endl;
 #endif
 
 
-	GEOS_CHECK_FOR_INTERRUPTS();
+    GEOS_CHECK_FOR_INTERRUPTS();
 
-	vector<Edge*> baseSplitEdges;
-	arg[0]->computeSplitEdges(&baseSplitEdges);
-	GEOS_CHECK_FOR_INTERRUPTS();
-	arg[1]->computeSplitEdges(&baseSplitEdges);
+    vector<Edge*> baseSplitEdges;
+    arg[0]->computeSplitEdges(&baseSplitEdges);
+    GEOS_CHECK_FOR_INTERRUPTS();
+    arg[1]->computeSplitEdges(&baseSplitEdges);
 
-	GEOS_CHECK_FOR_INTERRUPTS();
+    GEOS_CHECK_FOR_INTERRUPTS();
 
-	// add the noded edges to this result graph
-	insertUniqueEdges(&baseSplitEdges, env);
-	computeLabelsFromDepths();
-	replaceCollapsedEdges();
-	//Debug.println(edgeList);
+    // add the noded edges to this result graph
+    insertUniqueEdges(&baseSplitEdges, env);
+    computeLabelsFromDepths();
+    replaceCollapsedEdges();
+    //Debug.println(edgeList);
 
-	GEOS_CHECK_FOR_INTERRUPTS();
+    GEOS_CHECK_FOR_INTERRUPTS();
 
 #ifdef ENABLE_EDGE_NODING_VALIDATOR // {
-	/**
-	 * Check that the noding completed correctly.
-	 *
-	 * This test is slow, but necessary in order to catch
-	 * robustness failure situations.
-	 * If an exception is thrown because of a noding failure,
-	 * then snapping will be performed, which will hopefully avoid
-	 * the problem.
-	 * In the future hopefully a faster check can be developed.
-	 *
-	 */
-  try
-  {
+    /**
+     * Check that the noding completed correctly.
+     *
+     * This test is slow, but necessary in order to catch
+     * robustness failure situations.
+     * If an exception is thrown because of a noding failure,
+     * then snapping will be performed, which will hopefully avoid
+     * the problem.
+     * In the future hopefully a faster check can be developed.
+     *
+     */
+    try {
 #ifdef GEOS_DEBUG_VALIDATION
-		cout << "EdgeNodingValidator about to evaluate " << edgeList.getEdges().size() << " edges" << endl;
+        cout << "EdgeNodingValidator about to evaluate " << edgeList.getEdges().size() << " edges" << endl;
 #endif
-    // Will throw TopologyException if noding is
-    // found to be invalid
-    EdgeNodingValidator::checkValid(edgeList.getEdges());
+        // Will throw TopologyException if noding is
+        // found to be invalid
+        EdgeNodingValidator::checkValid(edgeList.getEdges());
 #ifdef GEOS_DEBUG_VALIDATION
-		cout << "EdgeNodingValidator accepted the noding" << endl;
+        cout << "EdgeNodingValidator accepted the noding" << endl;
 #endif
-  }
-  catch (const util::TopologyException& ex)
-  {
+    }
+    catch(const util::TopologyException& ex) {
 #ifdef GEOS_DEBUG_VALIDATION
-    cout << "EdgeNodingValidator found noding invalid: " << ex.what() << endl;
+        cout << "EdgeNodingValidator found noding invalid: " << ex.what() << endl;
 #endif
 
-    // In the error scenario, the edgeList is not properly
-    // deleted. Cannot add to the destructor of EdgeList
-    // (as it should) because
-    // "graph.addEdges(edgeList.getEdges());" below
-    // takes over edgeList ownership in the success case.
-    edgeList.clearList();
+        // In the error scenario, the edgeList is not properly
+        // deleted. Cannot add to the destructor of EdgeList
+        // (as it should) because
+        // "graph.addEdges(edgeList.getEdges());" below
+        // takes over edgeList ownership in the success case.
+        edgeList.clearList();
 
-    throw ex;
-  }
+        throw ex;
+    }
 
 #endif // ENABLE_EDGE_NODING_VALIDATOR }
 
-	GEOS_CHECK_FOR_INTERRUPTS();
+    GEOS_CHECK_FOR_INTERRUPTS();
 
-	graph.addEdges(edgeList.getEdges());
+    graph.addEdges(edgeList.getEdges());
 
-	GEOS_CHECK_FOR_INTERRUPTS();
+    GEOS_CHECK_FOR_INTERRUPTS();
 
-	// this can throw TopologyException *
-	computeLabelling();
+    // this can throw TopologyException *
+    computeLabelling();
 
-	//Debug.printWatch();
-	labelIncompleteNodes();
-	//Debug.printWatch();
-	//nodeMap.print(System.out);
+    //Debug.printWatch();
+    labelIncompleteNodes();
+    //Debug.printWatch();
+    //nodeMap.print(System.out);
 
-	GEOS_CHECK_FOR_INTERRUPTS();
+    GEOS_CHECK_FOR_INTERRUPTS();
 
-	/*
-	 * The ordering of building the result Geometries is important.
-	 * Areas must be built before lines, which must be built
-	 * before points.
-	 * This is so that lines which are covered by areas are not
-	 * included explicitly, and similarly for points.
-	 */
-	findResultAreaEdges(opCode);
-	cancelDuplicateResultEdges();
+    /*
+     * The ordering of building the result Geometries is important.
+     * Areas must be built before lines, which must be built
+     * before points.
+     * This is so that lines which are covered by areas are not
+     * included explicitly, and similarly for points.
+     */
+    findResultAreaEdges(opCode);
+    cancelDuplicateResultEdges();
 
-	GEOS_CHECK_FOR_INTERRUPTS();
+    GEOS_CHECK_FOR_INTERRUPTS();
 
-	PolygonBuilder polyBuilder(geomFact);
+    PolygonBuilder polyBuilder(geomFact);
 
-	// might throw a TopologyException *
-	polyBuilder.add(&graph);
+    // might throw a TopologyException *
+    polyBuilder.add(&graph);
 
-	vector<Geometry*> *gv=polyBuilder.getPolygons();
-	size_t gvsize=gv->size();
-	resultPolyList=new vector<Polygon*>(gvsize);
-	for(size_t i=0; i<gvsize; ++i) {
-		Polygon* p = dynamic_cast<Polygon*>((*gv)[i]);
-		(*resultPolyList)[i]=p;
-	}
-	delete gv;
+    vector<Geometry*>* gv = polyBuilder.getPolygons();
+    size_t gvsize = gv->size();
+    resultPolyList = new vector<Polygon*>(gvsize);
+    for(size_t i = 0; i < gvsize; ++i) {
+        Polygon* p = dynamic_cast<Polygon*>((*gv)[i]);
+        (*resultPolyList)[i] = p;
+    }
+    delete gv;
 
-	LineBuilder lineBuilder(this,geomFact,&ptLocator);
-	resultLineList=lineBuilder.build(opCode);
+    LineBuilder lineBuilder(this, geomFact, &ptLocator);
+    resultLineList = lineBuilder.build(opCode);
 
-	PointBuilder pointBuilder(this,geomFact,&ptLocator);
-	resultPointList=pointBuilder.build(opCode);
+    PointBuilder pointBuilder(this, geomFact, &ptLocator);
+    resultPointList = pointBuilder.build(opCode);
 
-	// gather the results from all calculations into a single
-	// Geometry for the result set
-	resultGeom=computeGeometry(resultPointList,resultLineList,resultPolyList,opCode);
+    // gather the results from all calculations into a single
+    // Geometry for the result set
+    resultGeom = computeGeometry(resultPointList, resultLineList, resultPolyList, opCode);
 
-	checkObviouslyWrongResult(opCode);
+    checkObviouslyWrongResult(opCode);
 
 
 #if USE_ELEVATION_MATRIX
-	elevationMatrix->elevate(resultGeom);
+    elevationMatrix->elevate(resultGeom);
 #endif // USE_ELEVATION_MATRIX
 
 }
 
 /*protected*/
 void
-OverlayOp::insertUniqueEdge(Edge *e)
+OverlayOp::insertUniqueEdge(Edge* e)
 {
-	//Debug.println(e);
+    //Debug.println(e);
 #if GEOS_DEBUG
-	cerr<<"OverlayOp::insertUniqueEdge("<<e->print()<<")"<<endl;
+    cerr << "OverlayOp::insertUniqueEdge(" << e->print() << ")" << endl;
 #endif
 
-	//<FIX> MD 8 Oct 03  speed up identical edge lookup
-	// fast lookup
-	Edge *existingEdge = edgeList.findEqualEdge(e);
+    //<FIX> MD 8 Oct 03  speed up identical edge lookup
+    // fast lookup
+    Edge* existingEdge = edgeList.findEqualEdge(e);
 
-	// If an identical edge already exists, simply update its label
-	if (existingEdge)
-	{
+    // If an identical edge already exists, simply update its label
+    if(existingEdge) {
 
 #if GEOS_DEBUG
-		cerr<<"  found identical edge, should merge Z"<<endl;
+        cerr << "  found identical edge, should merge Z" << endl;
 #endif
 
-		Label& existingLabel = existingEdge->getLabel();
+        Label& existingLabel = existingEdge->getLabel();
 
-		Label labelToMerge = e->getLabel();
+        Label labelToMerge = e->getLabel();
 
-		// check if new edge is in reverse direction to existing edge
-		// if so, must flip the label before merging it
-		if (!existingEdge->isPointwiseEqual(e))
-		{
-			labelToMerge.flip();
-		}
-		Depth &depth = existingEdge->getDepth();
+        // check if new edge is in reverse direction to existing edge
+        // if so, must flip the label before merging it
+        if(!existingEdge->isPointwiseEqual(e)) {
+            labelToMerge.flip();
+        }
+        Depth& depth = existingEdge->getDepth();
 
-		// if this is the first duplicate found for this edge,
-		// initialize the depths
-		if (depth.isNull())
-		{
-			depth.add(existingLabel);
-		}
+        // if this is the first duplicate found for this edge,
+        // initialize the depths
+        if(depth.isNull()) {
+            depth.add(existingLabel);
+        }
 
-		depth.add(labelToMerge);
+        depth.add(labelToMerge);
 
-		existingLabel.merge(labelToMerge);
+        existingLabel.merge(labelToMerge);
 
-		//Debug.print("inserted edge: "); Debug.println(e);
-		//Debug.print("existing edge: "); Debug.println(existingEdge);
-		dupEdges.push_back(e);
-	}
-	else
-	{  // no matching existing edge was found
+        //Debug.print("inserted edge: "); Debug.println(e);
+        //Debug.print("existing edge: "); Debug.println(existingEdge);
+        dupEdges.push_back(e);
+    }
+    else {
+        // no matching existing edge was found
 #if GEOS_DEBUG
-		cerr<<"  no matching existing edge"<<endl;
+        cerr << "  no matching existing edge" << endl;
 #endif
-		// add this new edge to the list of edges in this graph
-		//e.setName(name+edges.size());
-		//e.getDepth().add(e.getLabel());
-		edgeList.add(e);
-	}
+        // add this new edge to the list of edges in this graph
+        //e.setName(name+edges.size());
+        //e.getDepth().add(e.getLabel());
+        edgeList.add(e);
+    }
 }
 
 /*private*/
 void
 OverlayOp::computeLabelsFromDepths()
 {
-	for(auto &e : edgeList.getEdges())
-	{
-		Label& lbl = e->getLabel();
-		Depth &depth = e->getDepth();
-
-		/*
-		 * Only check edges for which there were duplicates,
-		 * since these are the only ones which might
-		 * be the result of dimensional collapses.
-		 */
-		if (depth.isNull()) continue;
-
-		depth.normalize();
-		for (int i=0;i<2;i++)
-		{
-			if (!lbl.isNull(i) && lbl.isArea() && !depth.isNull(i))
-			{
-				/*
-				 * if the depths are equal, this edge is the result of
-				 * the dimensional collapse of two or more edges.
-				 * It has the same location on both sides of the edge,
-				 * so it has collapsed to a line.
-				 */
-				if (depth.getDelta(i)==0) {
-					lbl.toLine(i);
-				} else {
-					/*
-					 * This edge may be the result of a dimensional collapse,
-					 * but it still has different locations on both sides.  The
-					 * label of the edge must be updated to reflect the resultant
-					 * side locations indicated by the depth values.
-					 */
-					assert(!depth.isNull(i,Position::LEFT)); // depth of LEFT side has not been initialized
-					lbl.setLocation(i,Position::LEFT,depth.getLocation(i,Position::LEFT));
-					assert(!depth.isNull(i,Position::RIGHT)); // depth of RIGHT side has not been initialized
-					lbl.setLocation(i,Position::RIGHT,depth.getLocation(i,Position::RIGHT));
-				}
-			}
-		}
-	}
+    for(auto& e : edgeList.getEdges()) {
+        Label& lbl = e->getLabel();
+        Depth& depth = e->getDepth();
+
+        /*
+         * Only check edges for which there were duplicates,
+         * since these are the only ones which might
+         * be the result of dimensional collapses.
+         */
+        if(depth.isNull()) {
+            continue;
+        }
+
+        depth.normalize();
+        for(int i = 0; i < 2; i++) {
+            if(!lbl.isNull(i) && lbl.isArea() && !depth.isNull(i)) {
+                /*
+                 * if the depths are equal, this edge is the result of
+                 * the dimensional collapse of two or more edges.
+                 * It has the same location on both sides of the edge,
+                 * so it has collapsed to a line.
+                 */
+                if(depth.getDelta(i) == 0) {
+                    lbl.toLine(i);
+                }
+                else {
+                    /*
+                     * This edge may be the result of a dimensional collapse,
+                     * but it still has different locations on both sides.  The
+                     * label of the edge must be updated to reflect the resultant
+                     * side locations indicated by the depth values.
+                     */
+                    assert(!depth.isNull(i, Position::LEFT)); // depth of LEFT side has not been initialized
+                    lbl.setLocation(i, Position::LEFT, depth.getLocation(i, Position::LEFT));
+                    assert(!depth.isNull(i, Position::RIGHT)); // depth of RIGHT side has not been initialized
+                    lbl.setLocation(i, Position::RIGHT, depth.getLocation(i, Position::RIGHT));
+                }
+            }
+        }
+    }
 }
 
-struct PointCoveredByAny: public geom::CoordinateFilter
-{
-	const vector<const Geometry*>& geoms;
-	PointLocator locator;
-	PointCoveredByAny(const vector<const Geometry*>& nGeoms)
-		: geoms(nGeoms)
-	{}
-
-	void filter_ro(const Coordinate* coord) override
-	{
-		for (size_t i=0, n=geoms.size(); i<n; ++i)
-		{
-			int loc = locator.locate(*coord, geoms[i]);
-			if ( loc == Location::INTERIOR ||
-				loc == Location::BOUNDARY )
-			{
-				return;
-			}
-		}
-		throw util::TopologyException("Obviously wrong result: "
-			"A point on first geom boundary isn't covered "
-			"by either result or second geom");
-	}
+struct PointCoveredByAny: public geom::CoordinateFilter {
+    const vector<const Geometry*>& geoms;
+    PointLocator locator;
+    PointCoveredByAny(const vector<const Geometry*>& nGeoms)
+        : geoms(nGeoms)
+    {}
+
+    void
+    filter_ro(const Coordinate* coord) override
+    {
+        for(size_t i = 0, n = geoms.size(); i < n; ++i) {
+            int loc = locator.locate(*coord, geoms[i]);
+            if(loc == Location::INTERIOR ||
+                    loc == Location::BOUNDARY) {
+                return;
+            }
+        }
+        throw util::TopologyException("Obviously wrong result: "
+                                      "A point on first geom boundary isn't covered "
+                                      "by either result or second geom");
+    }
 
 private:
     // Declare type as noncopyable
@@ -1042,97 +1035,90 @@ private:
 void
 OverlayOp::checkObviouslyWrongResult(OverlayOp::OpCode opCode)
 {
-	using std::cerr;
-	using std::endl;
+    using std::cerr;
+    using std::endl;
 
-	assert(resultGeom);
+    assert(resultGeom);
 
 #ifdef ENABLE_OTHER_OVERLAY_RESULT_VALIDATORS
 
-	if ( opCode == opINTERSECTION
-		&& arg[0]->getGeometry()->getDimension() == Dimension::A
-		&& arg[1]->getGeometry()->getDimension() == Dimension::A )
-	{
-		// Area of result must be less or equal area of smaller geom
-		double area0 = arg[0]->getGeometry()->getArea();
-		double area1 = arg[1]->getGeometry()->getArea();
-		double minarea = min(area0, area1);
-		double resultArea = resultGeom->getArea();
-
-		if ( resultArea > minarea )
-		{
-			throw util::TopologyException("Obviously wrong result: "
-				"area of intersection "
-				"result is bigger then minimum area between "
-				"input geometries");
-		}
-	}
-
-	else if ( opCode == opDIFFERENCE
-		&& arg[0]->getGeometry()->getDimension() == Dimension::A
-		&& arg[1]->getGeometry()->getDimension() == Dimension::A )
-	{
-		// Area of result must be less or equal area of first geom
-		double area0 = arg[0]->getGeometry()->getArea();
-		double resultArea = resultGeom->getArea();
-
-		if ( resultArea > area0 )
-		{
-			throw util::TopologyException("Obviously wrong result: "
-				"area of difference "
-				"result is bigger then area of first "
-				"input geometry");
-		}
-
-		// less obvious check:
-		// each vertex in first geom must be either covered by
-		// result or second geom
-		vector<const Geometry*> testGeoms; testGeoms.reserve(2);
-		testGeoms.push_back(resultGeom);
-		testGeoms.push_back(arg[1]->getGeometry());
-		PointCoveredByAny tester(testGeoms);
-		arg[0]->getGeometry()->apply_ro(&tester);
-	}
-
-	// Add your tests here
+    if(opCode == opINTERSECTION
+            && arg[0]->getGeometry()->getDimension() == Dimension::A
+            && arg[1]->getGeometry()->getDimension() == Dimension::A) {
+        // Area of result must be less or equal area of smaller geom
+        double area0 = arg[0]->getGeometry()->getArea();
+        double area1 = arg[1]->getGeometry()->getArea();
+        double minarea = min(area0, area1);
+        double resultArea = resultGeom->getArea();
+
+        if(resultArea > minarea) {
+            throw util::TopologyException("Obviously wrong result: "
+                                          "area of intersection "
+                                          "result is bigger then minimum area between "
+                                          "input geometries");
+        }
+    }
+
+    else if(opCode == opDIFFERENCE
+            && arg[0]->getGeometry()->getDimension() == Dimension::A
+            && arg[1]->getGeometry()->getDimension() == Dimension::A) {
+        // Area of result must be less or equal area of first geom
+        double area0 = arg[0]->getGeometry()->getArea();
+        double resultArea = resultGeom->getArea();
+
+        if(resultArea > area0) {
+            throw util::TopologyException("Obviously wrong result: "
+                                          "area of difference "
+                                          "result is bigger then area of first "
+                                          "input geometry");
+        }
+
+        // less obvious check:
+        // each vertex in first geom must be either covered by
+        // result or second geom
+        vector<const Geometry*> testGeoms;
+        testGeoms.reserve(2);
+        testGeoms.push_back(resultGeom);
+        testGeoms.push_back(arg[1]->getGeometry());
+        PointCoveredByAny tester(testGeoms);
+        arg[0]->getGeometry()->apply_ro(&tester);
+    }
+
+    // Add your tests here
 
 #else
     ::geos::ignore_unused_variable_warning(opCode);
 #endif
 
 #ifdef ENABLE_OVERLAY_RESULT_VALIDATOR
-	// This only work for FLOATING precision
-	if ( resultPrecisionModel->isFloating() )
-	{
-		validate::OverlayResultValidator validator( *(arg[0]->getGeometry()),
-			*(arg[1]->getGeometry()), *(resultGeom));
-		bool isvalid = validator.isValid(opCode);
-		if ( ! isvalid )
-		{
+    // This only work for FLOATING precision
+    if(resultPrecisionModel->isFloating()) {
+        validate::OverlayResultValidator validator(*(arg[0]->getGeometry()),
+                *(arg[1]->getGeometry()), *(resultGeom));
+        bool isvalid = validator.isValid(opCode);
+        if(! isvalid) {
 #ifdef GEOS_DEBUG_VALIDATION
-			cout << "OverlayResultValidator considered result INVALID" << endl;
+            cout << "OverlayResultValidator considered result INVALID" << endl;
 #endif
-			throw util::TopologyException(
-				"Obviously wrong result: "
-				"OverlayResultValidator didn't like "
-				"the result: \n"
-				"Invalid point: " +
-				validator.getInvalidLocation().toString() +
-				string("\nInvalid result: ") +
-				resultGeom->toString());
-		}
+            throw util::TopologyException(
+                "Obviously wrong result: "
+                "OverlayResultValidator didn't like "
+                "the result: \n"
+                "Invalid point: " +
+                validator.getInvalidLocation().toString() +
+                string("\nInvalid result: ") +
+                resultGeom->toString());
+        }
 #ifdef GEOS_DEBUG_VALIDATION
-		else
-		{
-			cout << "OverlayResultValidator considered result valid" << endl;
-		}
+        else {
+            cout << "OverlayResultValidator considered result valid" << endl;
+        }
 #endif
-	}
+    }
 #ifdef GEOS_DEBUG_VALIDATION
-	else
-	{
-		cout << "Did not run OverlayResultValidator as the precision model is not floating" << endl;
-	}
+    else {
+        cout << "Did not run OverlayResultValidator as the precision model is not floating" << endl;
+    }
 #endif // ndef GEOS_DEBUG
 #endif
 }
diff --git a/src/operation/overlay/PointBuilder.cpp b/src/operation/overlay/PointBuilder.cpp
index 04525ee..6ff6aac 100644
--- a/src/operation/overlay/PointBuilder.cpp
+++ b/src/operation/overlay/PointBuilder.cpp
@@ -46,8 +46,8 @@ namespace overlay { // geos.operation.overlay
 vector<Point*>*
 PointBuilder::build(OverlayOp::OpCode opCode)
 {
-	extractNonCoveredResultNodes(opCode);
-	return resultPointList;
+    extractNonCoveredResultNodes(opCode);
+    return resultPointList;
 }
 
 /*
@@ -61,44 +61,47 @@ PointBuilder::build(OverlayOp::OpCode opCode)
 void
 PointBuilder::extractNonCoveredResultNodes(OverlayOp::OpCode opCode)
 {
-	map<Coordinate*,Node*,CoordinateLessThen> &nodeMap =
-		op->getGraph().getNodeMap()->nodeMap;
-	map<Coordinate*,Node*,CoordinateLessThen>::iterator it=nodeMap.begin();
-	for (; it!=nodeMap.end(); ++it)
-	{
-		Node *n=it->second;
-
-		// filter out nodes which are known to be in the result
-		if (n->isInResult()) continue;
-
-		// if an incident edge is in the result, then
-		// the node coordinate is included already
-		if (n->isIncidentEdgeInResult()) continue;
-
-		if ( n->getEdges()->getDegree() == 0 ||
-			opCode == OverlayOp::opINTERSECTION )
-		{
-
-			/**
-			 * For nodes on edges, only INTERSECTION can result
-			 * in edge nodes being included even
-			 * if none of their incident edges are included
-			 */
-			const Label& label=n->getLabel();
-			if (OverlayOp::isResultOfOp(label, opCode))
-				filterCoveredNodeToPoint(n);
-		}
-	}
+    map<Coordinate*, Node*, CoordinateLessThen>& nodeMap =
+        op->getGraph().getNodeMap()->nodeMap;
+    map<Coordinate*, Node*, CoordinateLessThen>::iterator it = nodeMap.begin();
+    for(; it != nodeMap.end(); ++it) {
+        Node* n = it->second;
+
+        // filter out nodes which are known to be in the result
+        if(n->isInResult()) {
+            continue;
+        }
+
+        // if an incident edge is in the result, then
+        // the node coordinate is included already
+        if(n->isIncidentEdgeInResult()) {
+            continue;
+        }
+
+        if(n->getEdges()->getDegree() == 0 ||
+                opCode == OverlayOp::opINTERSECTION) {
+
+            /**
+             * For nodes on edges, only INTERSECTION can result
+             * in edge nodes being included even
+             * if none of their incident edges are included
+             */
+            const Label& label = n->getLabel();
+            if(OverlayOp::isResultOfOp(label, opCode)) {
+                filterCoveredNodeToPoint(n);
+            }
+        }
+    }
 }
 
 void
-PointBuilder::filterCoveredNodeToPoint(const Node *n)
+PointBuilder::filterCoveredNodeToPoint(const Node* n)
 {
-	const Coordinate& coord=n->getCoordinate();
-	if(!op->isCoveredByLA(coord)) {
-		Point *pt=geometryFactory->createPoint(coord);
-		resultPointList->push_back(pt);
-	}
+    const Coordinate& coord = n->getCoordinate();
+    if(!op->isCoveredByLA(coord)) {
+        Point* pt = geometryFactory->createPoint(coord);
+        resultPointList->push_back(pt);
+    }
 }
 
 } // namespace geos.operation.overlay
diff --git a/src/operation/overlay/PolygonBuilder.cpp b/src/operation/overlay/PolygonBuilder.cpp
index d61a4f2..38a12d8 100644
--- a/src/operation/overlay/PolygonBuilder.cpp
+++ b/src/operation/overlay/PolygonBuilder.cpp
@@ -49,328 +49,314 @@ namespace geos {
 namespace operation { // geos.operation
 namespace overlay { // geos.operation.overlay
 
-PolygonBuilder::PolygonBuilder(const GeometryFactory *newGeometryFactory)
-	:
-	geometryFactory(newGeometryFactory)
+PolygonBuilder::PolygonBuilder(const GeometryFactory* newGeometryFactory)
+    :
+    geometryFactory(newGeometryFactory)
 {
 }
 
 PolygonBuilder::~PolygonBuilder()
 {
-	for(size_t i=0, n=shellList.size(); i<n; ++i)
-	{
-		delete shellList[i];
-	}
+    for(size_t i = 0, n = shellList.size(); i < n; ++i) {
+        delete shellList[i];
+    }
 }
 
 /*public*/
 void
-PolygonBuilder::add(PlanarGraph *graph)
-	//throw(TopologyException *)
+PolygonBuilder::add(PlanarGraph* graph)
+//throw(TopologyException *)
 {
-	const vector<EdgeEnd*>* eeptr=graph->getEdgeEnds();
-	assert(eeptr);
-	const vector<EdgeEnd*>& ee = *eeptr;
+    const vector<EdgeEnd*>* eeptr = graph->getEdgeEnds();
+    assert(eeptr);
+    const vector<EdgeEnd*>& ee = *eeptr;
 
-	size_t eeSize=ee.size();
+    size_t eeSize = ee.size();
 
 #if GEOS_DEBUG
-	cerr << __FUNCTION__ << ": PlanarGraph has " << eeSize << " EdgeEnds" << endl;
+    cerr << __FUNCTION__ << ": PlanarGraph has " << eeSize << " EdgeEnds" << endl;
 #endif
 
-	vector<DirectedEdge*> dirEdges(eeSize);
-	for(size_t i=0; i<eeSize; ++i)
-	{
-		assert(dynamic_cast<DirectedEdge*>(ee[i]));
-		DirectedEdge* de = static_cast<DirectedEdge*>(ee[i]);
-		dirEdges[i]=de;
-	}
-
-	NodeMap::container &nodeMap=graph->getNodeMap()->nodeMap;
-	vector<Node*> nodes;
-	nodes.reserve(nodeMap.size());
-	for ( NodeMap::iterator it=nodeMap.begin(), itEnd=nodeMap.end();
-		it != itEnd; ++it )
-	{
-		Node *node=it->second;
-		nodes.push_back(node);
-	}
-
-	add(&dirEdges, &nodes); // might throw a TopologyException *
+    vector<DirectedEdge*> dirEdges(eeSize);
+    for(size_t i = 0; i < eeSize; ++i) {
+        assert(dynamic_cast<DirectedEdge*>(ee[i]));
+        DirectedEdge* de = static_cast<DirectedEdge*>(ee[i]);
+        dirEdges[i] = de;
+    }
+
+    NodeMap::container& nodeMap = graph->getNodeMap()->nodeMap;
+    vector<Node*> nodes;
+    nodes.reserve(nodeMap.size());
+    for(NodeMap::iterator it = nodeMap.begin(), itEnd = nodeMap.end();
+            it != itEnd; ++it) {
+        Node* node = it->second;
+        nodes.push_back(node);
+    }
+
+    add(&dirEdges, &nodes); // might throw a TopologyException *
 }
 
 /*public*/
 void
-PolygonBuilder::add(const vector<DirectedEdge*> *dirEdges,
-		const vector<Node*> *nodes)
-	//throw(TopologyException *)
+PolygonBuilder::add(const vector<DirectedEdge*>* dirEdges,
+                    const vector<Node*>* nodes)
+//throw(TopologyException *)
 {
-	PlanarGraph::linkResultDirectedEdges(nodes->begin(), nodes->end());
+    PlanarGraph::linkResultDirectedEdges(nodes->begin(), nodes->end());
 
-	vector<MaximalEdgeRing*> maxEdgeRings;
-	buildMaximalEdgeRings(dirEdges, maxEdgeRings);
+    vector<MaximalEdgeRing*> maxEdgeRings;
+    buildMaximalEdgeRings(dirEdges, maxEdgeRings);
 
-	vector<EdgeRing*> freeHoleList;
-	vector<MaximalEdgeRing*> edgeRings;
-	buildMinimalEdgeRings(maxEdgeRings, shellList, freeHoleList, edgeRings);
+    vector<EdgeRing*> freeHoleList;
+    vector<MaximalEdgeRing*> edgeRings;
+    buildMinimalEdgeRings(maxEdgeRings, shellList, freeHoleList, edgeRings);
 
-	sortShellsAndHoles(edgeRings, shellList, freeHoleList);
+    sortShellsAndHoles(edgeRings, shellList, freeHoleList);
 
-	vector<FastPIPRing> indexedshellist;
-	for (auto const& shell : shellList)
-	{
-		FastPIPRing pipRing { shell,new geos::algorithm::locate::IndexedPointInAreaLocator(*shell->getLinearRing()) };
-		indexedshellist.push_back(pipRing);
-	}
-	placeFreeHoles(indexedshellist, freeHoleList);
-	//Assert: every hole on freeHoleList has a shell assigned to it
+    vector<FastPIPRing> indexedshellist;
+    for(auto const& shell : shellList) {
+        FastPIPRing pipRing { shell, new geos::algorithm::locate::IndexedPointInAreaLocator(*shell->getLinearRing()) };
+        indexedshellist.push_back(pipRing);
+    }
+    placeFreeHoles(indexedshellist, freeHoleList);
+    //Assert: every hole on freeHoleList has a shell assigned to it
 
-	for (auto const& shell : indexedshellist)
-		delete shell.pipLocator;
+    for(auto const& shell : indexedshellist) {
+        delete shell.pipLocator;
+    }
 }
 
 /*public*/
 vector<Geometry*>*
 PolygonBuilder::getPolygons()
 {
-	vector<Geometry*> *resultPolyList=computePolygons(shellList);
-	return resultPolyList;
+    vector<Geometry*>* resultPolyList = computePolygons(shellList);
+    return resultPolyList;
 }
 
 
 /*private*/
 void
-PolygonBuilder::buildMaximalEdgeRings(const vector<DirectedEdge*> *dirEdges,
-  vector<MaximalEdgeRing*> &maxEdgeRings)
-	// throw(const TopologyException &)
+PolygonBuilder::buildMaximalEdgeRings(const vector<DirectedEdge*>* dirEdges,
+                                      vector<MaximalEdgeRing*>& maxEdgeRings)
+// throw(const TopologyException &)
 {
 #if GEOS_DEBUG
-	cerr<<"PolygonBuilder::buildMaximalEdgeRings got "<<dirEdges->size()<<" dirEdges"<<endl;
+    cerr << "PolygonBuilder::buildMaximalEdgeRings got " << dirEdges->size() << " dirEdges" << endl;
 #endif
 
-	vector<MaximalEdgeRing*>::size_type oldSize = maxEdgeRings.size();
+    vector<MaximalEdgeRing*>::size_type oldSize = maxEdgeRings.size();
 
-	for(size_t i=0, n=dirEdges->size(); i<n; i++)
-	{
-		DirectedEdge *de=(*dirEdges)[i];
+    for(size_t i = 0, n = dirEdges->size(); i < n; i++) {
+        DirectedEdge* de = (*dirEdges)[i];
 #if GEOS_DEBUG
-	cerr << "  dirEdge " << i << endl
-		 << de->printEdge() << endl
-		 << " inResult:" << de->isInResult() << endl
-		 << " isArea:" << de->getLabel().isArea() << endl;
+        cerr << "  dirEdge " << i << endl
+             << de->printEdge() << endl
+             << " inResult:" << de->isInResult() << endl
+             << " isArea:" << de->getLabel().isArea() << endl;
 #endif
-		if (de->isInResult() && de->getLabel().isArea())
-		{
-			// if this edge has not yet been processed
-			if (de->getEdgeRing() == nullptr)
-			{
-				MaximalEdgeRing *er;
-	try
-	{ // MaximalEdgeRing constructor may throw
-				er=new MaximalEdgeRing(de,geometryFactory);
-	}
-	catch (util::GEOSException&)
-	{ // cleanup if that happens (see stmlf-cases-20061020.xml)
-		for(size_t p_i=oldSize, p_n=maxEdgeRings.size(); p_i<p_n; p_i++)
-			delete maxEdgeRings[p_i];
-		//cerr << "Exception! " << e.what() << endl;
-		throw;
-	}
-				maxEdgeRings.push_back(er);
-				er->setInResult();
-				//System.out.println("max node degree=" + er.getMaxDegree());
-			}
-		}
-	}
+        if(de->isInResult() && de->getLabel().isArea()) {
+            // if this edge has not yet been processed
+            if(de->getEdgeRing() == nullptr) {
+                MaximalEdgeRing* er;
+                try {
+                    // MaximalEdgeRing constructor may throw
+                    er = new MaximalEdgeRing(de, geometryFactory);
+                }
+                catch(util::GEOSException&) {
+                    // cleanup if that happens (see stmlf-cases-20061020.xml)
+                    for(size_t p_i = oldSize, p_n = maxEdgeRings.size(); p_i < p_n; p_i++) {
+                        delete maxEdgeRings[p_i];
+                    }
+                    //cerr << "Exception! " << e.what() << endl;
+                    throw;
+                }
+                maxEdgeRings.push_back(er);
+                er->setInResult();
+                //System.out.println("max node degree=" + er.getMaxDegree());
+            }
+        }
+    }
 #if GEOS_DEBUG
-	cerr<<"  pushed "<<maxEdgeRings.size()-oldSize<<" maxEdgeRings"<<endl;
+    cerr << "  pushed " << maxEdgeRings.size() - oldSize << " maxEdgeRings" << endl;
 #endif
 }
 
 /*private*/
 void
 PolygonBuilder::buildMinimalEdgeRings(
-  vector<MaximalEdgeRing*> &maxEdgeRings,
-	vector<EdgeRing*> &newShellList, vector<EdgeRing*> &freeHoleList,
-	vector<MaximalEdgeRing*> &edgeRings)
+    vector<MaximalEdgeRing*>& maxEdgeRings,
+    vector<EdgeRing*>& newShellList, vector<EdgeRing*>& freeHoleList,
+    vector<MaximalEdgeRing*>& edgeRings)
 {
-	for(size_t i=0, n=maxEdgeRings.size(); i<n; ++i)
-	{
-		MaximalEdgeRing *er = maxEdgeRings[i];
+    for(size_t i = 0, n = maxEdgeRings.size(); i < n; ++i) {
+        MaximalEdgeRing* er = maxEdgeRings[i];
 #if GEOS_DEBUG
-	cerr<<"buildMinimalEdgeRings: maxEdgeRing "<<i<<" has "<<er->getMaxNodeDegree()<<" maxNodeDegree"<<endl;
+        cerr << "buildMinimalEdgeRings: maxEdgeRing " << i << " has " << er->getMaxNodeDegree() << " maxNodeDegree" << endl;
 #endif
-		if (er->getMaxNodeDegree()>2)
-		{
-			er->linkDirectedEdgesForMinimalEdgeRings();
-			vector<MinimalEdgeRing*> minEdgeRings;
-			er->buildMinimalRings(minEdgeRings);
-			// at this point we can go ahead and attempt to place
-			// holes, if this EdgeRing is a polygon
-			EdgeRing *shell=findShell(&minEdgeRings);
-			if(shell != nullptr)
-			{
-				placePolygonHoles(shell, &minEdgeRings);
-				newShellList.push_back(shell);
-			}
-			else
-			{
-				freeHoleList.insert(freeHoleList.end(),
-						minEdgeRings.begin(),
-						minEdgeRings.end() );
-			}
-			delete er;
-		}
-		else
-		{
-			edgeRings.push_back(er);
-		}
-	}
+        if(er->getMaxNodeDegree() > 2) {
+            er->linkDirectedEdgesForMinimalEdgeRings();
+            vector<MinimalEdgeRing*> minEdgeRings;
+            er->buildMinimalRings(minEdgeRings);
+            // at this point we can go ahead and attempt to place
+            // holes, if this EdgeRing is a polygon
+            EdgeRing* shell = findShell(&minEdgeRings);
+            if(shell != nullptr) {
+                placePolygonHoles(shell, &minEdgeRings);
+                newShellList.push_back(shell);
+            }
+            else {
+                freeHoleList.insert(freeHoleList.end(),
+                                    minEdgeRings.begin(),
+                                    minEdgeRings.end());
+            }
+            delete er;
+        }
+        else {
+            edgeRings.push_back(er);
+        }
+    }
 }
 
 /*private*/
 EdgeRing*
-PolygonBuilder::findShell(vector<MinimalEdgeRing*> *minEdgeRings)
+PolygonBuilder::findShell(vector<MinimalEdgeRing*>* minEdgeRings)
 {
-	int shellCount=0;
-	EdgeRing *shell=nullptr;
+    int shellCount = 0;
+    EdgeRing* shell = nullptr;
 
 #if GEOS_DEBUG
-	cerr<<"PolygonBuilder::findShell got "<<minEdgeRings->size()<<" minEdgeRings"<<endl;
+    cerr << "PolygonBuilder::findShell got " << minEdgeRings->size() << " minEdgeRings" << endl;
 #endif
 
-	for (size_t i=0, n=minEdgeRings->size(); i<n; ++i)
-	{
-		EdgeRing *er=(*minEdgeRings)[i];
-		if ( ! er->isHole() )
-		{
-			shell=er;
-			++shellCount;
-		}
-	}
-
-	if ( shellCount > 1 ) {
-		throw util::TopologyException("found two shells in MinimalEdgeRing list");
-	}
-
-	return shell;
+    for(size_t i = 0, n = minEdgeRings->size(); i < n; ++i) {
+        EdgeRing* er = (*minEdgeRings)[i];
+        if(! er->isHole()) {
+            shell = er;
+            ++shellCount;
+        }
+    }
+
+    if(shellCount > 1) {
+        throw util::TopologyException("found two shells in MinimalEdgeRing list");
+    }
+
+    return shell;
 }
 
 /*private*/
 void
-PolygonBuilder::placePolygonHoles(EdgeRing *shell,
-	vector<MinimalEdgeRing*> *minEdgeRings)
+PolygonBuilder::placePolygonHoles(EdgeRing* shell,
+                                  vector<MinimalEdgeRing*>* minEdgeRings)
 {
-	for (size_t i=0, n=minEdgeRings->size(); i<n; ++i)
-	{
-		MinimalEdgeRing *er=(*minEdgeRings)[i];
-		if ( er->isHole() )
-		{
-			er->setShell(shell);
-		}
-	}
+    for(size_t i = 0, n = minEdgeRings->size(); i < n; ++i) {
+        MinimalEdgeRing* er = (*minEdgeRings)[i];
+        if(er->isHole()) {
+            er->setShell(shell);
+        }
+    }
 }
 
 /*private*/
 void
-PolygonBuilder::sortShellsAndHoles(vector<MaximalEdgeRing*> &edgeRings,
-	vector<EdgeRing*> &newShellList, vector<EdgeRing*> &freeHoleList)
+PolygonBuilder::sortShellsAndHoles(vector<MaximalEdgeRing*>& edgeRings,
+                                   vector<EdgeRing*>& newShellList, vector<EdgeRing*>& freeHoleList)
 {
-	for(size_t i=0, n=edgeRings.size(); i<n; i++)
-	{
-		EdgeRing *er = edgeRings[i];
-		//er->setInResult();
-		if (er->isHole() ) {
-			freeHoleList.push_back(er);
-		}
-		else {
-			newShellList.push_back(er);
-		}
-	}
+    for(size_t i = 0, n = edgeRings.size(); i < n; i++) {
+        EdgeRing* er = edgeRings[i];
+        //er->setInResult();
+        if(er->isHole()) {
+            freeHoleList.push_back(er);
+        }
+        else {
+            newShellList.push_back(er);
+        }
+    }
 }
 
 /*private*/
 void
 PolygonBuilder::placeFreeHoles(vector<FastPIPRing>& newShellList,
-	std::vector<EdgeRing*>& freeHoleList)
+                               std::vector<EdgeRing*>& freeHoleList)
 {
-	for(std::vector<EdgeRing*>::iterator
-			it=freeHoleList.begin(), itEnd=freeHoleList.end();
-			it != itEnd;
-			++it)
-	{
-		EdgeRing *hole=*it;
-		// only place this hole if it doesn't yet have a shell
-		if (hole->getShell()==nullptr) {
-			EdgeRing *shell=findEdgeRingContaining(hole, newShellList);
-			if ( shell == nullptr )
-			{
+    for(std::vector<EdgeRing*>::iterator
+            it = freeHoleList.begin(), itEnd = freeHoleList.end();
+            it != itEnd;
+            ++it) {
+        EdgeRing* hole = *it;
+        // only place this hole if it doesn't yet have a shell
+        if(hole->getShell() == nullptr) {
+            EdgeRing* shell = findEdgeRingContaining(hole, newShellList);
+            if(shell == nullptr) {
 #if GEOS_DEBUG
-				Geometry* geom;
-				std::cerr << "CREATE TABLE shells (g geometry);" << std::endl;
-				std::cerr << "CREATE TABLE hole (g geometry);" << std::endl;
-				for (std::vector<EdgeRing*>::iterator rIt=newShellList.begin(),
-					rEnd=newShellList.end(); rIt!=rEnd; rIt++)
-				{
-					geom = (*rIt)->toPolygon(geometryFactory);
-					std::cerr << "INSERT INTO shells VALUES ('"
-							  << *geom
-							  << "');" << std::endl;
-					delete geom;
-				}
-				geom = hole->toPolygon(geometryFactory);
-				std::cerr << "INSERT INTO hole VALUES ('"
-						  << *geom
-						  << "');" << std::endl;
-				delete geom;
+                Geometry* geom;
+                std::cerr << "CREATE TABLE shells (g geometry);" << std::endl;
+                std::cerr << "CREATE TABLE hole (g geometry);" << std::endl;
+                for(std::vector<EdgeRing*>::iterator rIt = newShellList.begin(),
+                        rEnd = newShellList.end(); rIt != rEnd; rIt++) {
+                    geom = (*rIt)->toPolygon(geometryFactory);
+                    std::cerr << "INSERT INTO shells VALUES ('"
+                              << *geom
+                              << "');" << std::endl;
+                    delete geom;
+                }
+                geom = hole->toPolygon(geometryFactory);
+                std::cerr << "INSERT INTO hole VALUES ('"
+                          << *geom
+                          << "');" << std::endl;
+                delete geom;
 #endif
-				//assert(shell!=NULL); // unable to assign hole to a shell
-				throw util::TopologyException("unable to assign hole to a shell");
-			}
+                //assert(shell!=NULL); // unable to assign hole to a shell
+                throw util::TopologyException("unable to assign hole to a shell");
+            }
 
-			hole->setShell(shell);
-		}
-	}
+            hole->setShell(shell);
+        }
+    }
 }
 
 /*private*/
 EdgeRing*
-PolygonBuilder::findEdgeRingContaining(EdgeRing *testEr,
-	vector<FastPIPRing>& newShellList)
+PolygonBuilder::findEdgeRingContaining(EdgeRing* testEr,
+                                       vector<FastPIPRing>& newShellList)
 {
-	LinearRing *testRing=testEr->getLinearRing();
-	const Envelope *testEnv=testRing->getEnvelopeInternal();
-	EdgeRing *minShell=nullptr;
-	const Envelope *minShellEnv=nullptr;
-
-	for(auto const& tryShell: newShellList)
-	{
-		LinearRing *tryShellRing = tryShell.edgeRing->getLinearRing();
-		const Envelope *tryShellEnv=tryShellRing->getEnvelopeInternal();
-		// the hole envelope cannot equal the shell envelope
-		// (also guards against testing rings against themselves)
-		if (tryShellEnv->equals(testEnv)) continue;
-		// hole must be contained in shell
-		if (!tryShellEnv->contains(testEnv)) continue;
-
-		const CoordinateSequence *tsrcs = tryShellRing->getCoordinatesRO();
-		Coordinate testPt = operation::polygonize::EdgeRing::ptNotInList(testRing->getCoordinatesRO(), tsrcs);
-
-		bool isContained = false;
-        if (tryShell.pipLocator->locate(&testPt) != Location::EXTERIOR)
-			isContained = true;
-
-		// check if this new containing ring is smaller than
-		// the current minimum ring
-		if (isContained) {
-			if (minShell==nullptr
-				|| minShellEnv->contains(tryShellEnv)) {
-					minShell = tryShell.edgeRing;
-					minShellEnv = minShell->getLinearRing()->getEnvelopeInternal();
-			}
-		}
-	}
-	return minShell;
+    LinearRing* testRing = testEr->getLinearRing();
+    const Envelope* testEnv = testRing->getEnvelopeInternal();
+    EdgeRing* minShell = nullptr;
+    const Envelope* minShellEnv = nullptr;
+
+    for(auto const& tryShell : newShellList) {
+        LinearRing* tryShellRing = tryShell.edgeRing->getLinearRing();
+        const Envelope* tryShellEnv = tryShellRing->getEnvelopeInternal();
+        // the hole envelope cannot equal the shell envelope
+        // (also guards against testing rings against themselves)
+        if(tryShellEnv->equals(testEnv)) {
+            continue;
+        }
+        // hole must be contained in shell
+        if(!tryShellEnv->contains(testEnv)) {
+            continue;
+        }
+
+        const CoordinateSequence* tsrcs = tryShellRing->getCoordinatesRO();
+        Coordinate testPt = operation::polygonize::EdgeRing::ptNotInList(testRing->getCoordinatesRO(), tsrcs);
+
+        bool isContained = false;
+        if(tryShell.pipLocator->locate(&testPt) != Location::EXTERIOR) {
+            isContained = true;
+        }
+
+        // check if this new containing ring is smaller than
+        // the current minimum ring
+        if(isContained) {
+            if(minShell == nullptr
+                    || minShellEnv->contains(tryShellEnv)) {
+                minShell = tryShell.edgeRing;
+                minShellEnv = minShell->getLinearRing()->getEnvelopeInternal();
+            }
+        }
+    }
+    return minShell;
 }
 
 /*private*/
@@ -378,18 +364,17 @@ vector<Geometry*>*
 PolygonBuilder::computePolygons(vector<EdgeRing*>& newShellList)
 {
 #if GEOS_DEBUG
-	cerr<<"PolygonBuilder::computePolygons: got "<<newShellList.size()<<" shells"<<endl;
+    cerr << "PolygonBuilder::computePolygons: got " << newShellList.size() << " shells" << endl;
 #endif
-	vector<Geometry*> *resultPolyList=new vector<Geometry*>();
-
-	// add Polygons for all shells
-	for(size_t i=0, n=newShellList.size(); i<n; i++)
-	{
-		EdgeRing *er=newShellList[i];
-		Polygon *poly=er->toPolygon(geometryFactory);
-		resultPolyList->push_back(poly);
-	}
-	return resultPolyList;
+    vector<Geometry*>* resultPolyList = new vector<Geometry*>();
+
+    // add Polygons for all shells
+    for(size_t i = 0, n = newShellList.size(); i < n; i++) {
+        EdgeRing* er = newShellList[i];
+        Polygon* poly = er->toPolygon(geometryFactory);
+        resultPolyList->push_back(poly);
+    }
+    return resultPolyList;
 }
 
 
diff --git a/src/operation/overlay/snap/GeometrySnapper.cpp b/src/operation/overlay/snap/GeometrySnapper.cpp
index 53b3ed5..36b7e6b 100644
--- a/src/operation/overlay/snap/GeometrySnapper.cpp
+++ b/src/operation/overlay/snap/GeometrySnapper.cpp
@@ -48,41 +48,43 @@ class SnapTransformer: public geos::geom::util::GeometryTransformer {
 
 private:
 
-	double snapTol;
+    double snapTol;
 
-	const Coordinate::ConstVect& snapPts;
+    const Coordinate::ConstVect& snapPts;
 
-	CoordinateSequence::Ptr snapLine(
-			const CoordinateSequence* srcPts)
-	{
-		using std::unique_ptr;
+    CoordinateSequence::Ptr
+    snapLine(
+        const CoordinateSequence* srcPts)
+    {
+        using std::unique_ptr;
 
-		assert(srcPts);
-		assert(srcPts->toVector());
-		LineStringSnapper snapper(*(srcPts->toVector()), snapTol);
-		unique_ptr<Coordinate::Vect> newPts = snapper.snapTo(snapPts);
+        assert(srcPts);
+        assert(srcPts->toVector());
+        LineStringSnapper snapper(*(srcPts->toVector()), snapTol);
+        unique_ptr<Coordinate::Vect> newPts = snapper.snapTo(snapPts);
 
-		const CoordinateSequenceFactory* cfact = factory->getCoordinateSequenceFactory();
-		return unique_ptr<CoordinateSequence>(cfact->create(newPts.release()));
-	}
+        const CoordinateSequenceFactory* cfact = factory->getCoordinateSequenceFactory();
+        return unique_ptr<CoordinateSequence>(cfact->create(newPts.release()));
+    }
 
 public:
 
-	SnapTransformer(double nSnapTol,
-			const Coordinate::ConstVect& nSnapPts)
-		:
-		snapTol(nSnapTol),
-		snapPts(nSnapPts)
-	{
-	}
-
-	CoordinateSequence::Ptr transformCoordinates(
-			const CoordinateSequence* coords,
-			const Geometry* parent) override
-	{
+    SnapTransformer(double nSnapTol,
+                    const Coordinate::ConstVect& nSnapPts)
+        :
+        snapTol(nSnapTol),
+        snapPts(nSnapPts)
+    {
+    }
+
+    CoordinateSequence::Ptr
+    transformCoordinates(
+        const CoordinateSequence* coords,
+        const Geometry* parent) override
+    {
         ::geos::ignore_unused_variable_warning(parent);
-		return snapLine(coords);
-	}
+        return snapLine(coords);
+    }
 
 
 };
@@ -91,12 +93,12 @@ public:
 std::unique_ptr<Coordinate::ConstVect>
 GeometrySnapper::extractTargetCoordinates(const Geometry& g)
 {
-	std::unique_ptr<Coordinate::ConstVect> snapPts(new Coordinate::ConstVect());
-	util::UniqueCoordinateArrayFilter filter(*snapPts);
-	g.apply_ro(&filter);
-	// integrity check
-	assert( snapPts->size() <= g.getNumPoints() );
-	return snapPts;
+    std::unique_ptr<Coordinate::ConstVect> snapPts(new Coordinate::ConstVect());
+    util::UniqueCoordinateArrayFilter filter(*snapPts);
+    g.apply_ro(&filter);
+    // integrity check
+    assert(snapPts->size() <= g.getNumPoints());
+    return snapPts;
 }
 
 /*public*/
@@ -104,16 +106,16 @@ std::unique_ptr<geom::Geometry>
 GeometrySnapper::snapTo(const geom::Geometry& g, double snapTolerance)
 {
 
-	using std::unique_ptr;
-	using geom::util::GeometryTransformer;
+    using std::unique_ptr;
+    using geom::util::GeometryTransformer;
 
-	// Get snap points
-	unique_ptr<Coordinate::ConstVect> snapPts=extractTargetCoordinates(g);
+    // Get snap points
+    unique_ptr<Coordinate::ConstVect> snapPts = extractTargetCoordinates(g);
 
-	// Apply a SnapTransformer to source geometry
-	// (we need a pointer for dynamic polymorphism)
-	unique_ptr<GeometryTransformer> snapTrans(new SnapTransformer(snapTolerance, *snapPts));
-	return snapTrans->transform(&srcGeom);
+    // Apply a SnapTransformer to source geometry
+    // (we need a pointer for dynamic polymorphism)
+    unique_ptr<GeometryTransformer> snapTrans(new SnapTransformer(snapTolerance, *snapPts));
+    return snapTrans->transform(&srcGeom);
 }
 
 /*public*/
@@ -121,70 +123,69 @@ std::unique_ptr<geom::Geometry>
 GeometrySnapper::snapToSelf(double snapTolerance, bool cleanResult)
 {
 
-	using std::unique_ptr;
-	using geom::util::GeometryTransformer;
+    using std::unique_ptr;
+    using geom::util::GeometryTransformer;
 
-	// Get snap points
-	unique_ptr<Coordinate::ConstVect> snapPts=extractTargetCoordinates(srcGeom);
+    // Get snap points
+    unique_ptr<Coordinate::ConstVect> snapPts = extractTargetCoordinates(srcGeom);
 
-	// Apply a SnapTransformer to source geometry
-	// (we need a pointer for dynamic polymorphism)
-	unique_ptr<GeometryTransformer> snapTrans(new SnapTransformer(snapTolerance, *snapPts));
+    // Apply a SnapTransformer to source geometry
+    // (we need a pointer for dynamic polymorphism)
+    unique_ptr<GeometryTransformer> snapTrans(new SnapTransformer(snapTolerance, *snapPts));
 
-	GeomPtr result = snapTrans->transform(&srcGeom);
+    GeomPtr result = snapTrans->transform(&srcGeom);
 
-	if (cleanResult && ( dynamic_cast<const Polygon*>(result.get()) ||
-	                     dynamic_cast<const MultiPolygon*>(result.get()) ) )
-	{
-		// TODO: use better cleaning approach
-		result.reset(result->buffer(0));
-	}
+    if(cleanResult && (dynamic_cast<const Polygon*>(result.get()) ||
+                       dynamic_cast<const MultiPolygon*>(result.get()))) {
+        // TODO: use better cleaning approach
+        result.reset(result->buffer(0));
+    }
 
-	return result;
+    return result;
 }
 
 /*public static*/
 double
 GeometrySnapper::computeSizeBasedSnapTolerance(const geom::Geometry& g)
 {
-	const Envelope* env = g.getEnvelopeInternal();
-	double minDimension = std::min(env->getHeight(), env->getWidth());
-	double snapTol = minDimension * snapPrecisionFactor;
-	return snapTol;
+    const Envelope* env = g.getEnvelopeInternal();
+    double minDimension = std::min(env->getHeight(), env->getWidth());
+    double snapTol = minDimension * snapPrecisionFactor;
+    return snapTol;
 }
 
 /*public static*/
 double
 GeometrySnapper::computeOverlaySnapTolerance(const geom::Geometry& g)
 {
-	double snapTolerance = computeSizeBasedSnapTolerance(g);
-
-	/**
-	 * Overlay is carried out in the precision model
-	 * of the two inputs.
-	 * If this precision model is of type FIXED, then the snap tolerance
-	 * must reflect the precision grid size.
-	 * Specifically, the snap tolerance should be at least
-	 * the distance from a corner of a precision grid cell
-	 * to the centre point of the cell.
-	 */
-	assert(g.getPrecisionModel());
-	const PrecisionModel& pm = *(g.getPrecisionModel());
-	if (pm.getType() == PrecisionModel::FIXED)
-	{
-		double fixedSnapTol = (1 / pm.getScale()) * 2 / 1.415;
-		if ( fixedSnapTol > snapTolerance )
-			snapTolerance = fixedSnapTol;
-	}
-	return snapTolerance;
+    double snapTolerance = computeSizeBasedSnapTolerance(g);
+
+    /**
+     * Overlay is carried out in the precision model
+     * of the two inputs.
+     * If this precision model is of type FIXED, then the snap tolerance
+     * must reflect the precision grid size.
+     * Specifically, the snap tolerance should be at least
+     * the distance from a corner of a precision grid cell
+     * to the centre point of the cell.
+     */
+    assert(g.getPrecisionModel());
+    const PrecisionModel& pm = *(g.getPrecisionModel());
+    if(pm.getType() == PrecisionModel::FIXED) {
+        double fixedSnapTol = (1 / pm.getScale()) * 2 / 1.415;
+        if(fixedSnapTol > snapTolerance) {
+            snapTolerance = fixedSnapTol;
+        }
+    }
+    return snapTolerance;
 }
 
 /*public static*/
 double
 GeometrySnapper::computeOverlaySnapTolerance(const geom::Geometry& g1,
-		const geom::Geometry& g2)
+        const geom::Geometry& g2)
 {
-        return std::min(computeOverlaySnapTolerance(g1), computeOverlaySnapTolerance(g2));
+    return std::min(computeOverlaySnapTolerance(g1), computeOverlaySnapTolerance(g2));
 }
 
 /* public static */
@@ -194,16 +195,16 @@ GeometrySnapper::snap(const geom::Geometry& g0,
                       double snapTolerance,
                       geom::GeomPtrPair& snapGeom)
 {
-	GeometrySnapper snapper0(g0);
-	snapGeom.first = snapper0.snapTo(g1, snapTolerance);
+    GeometrySnapper snapper0(g0);
+    snapGeom.first = snapper0.snapTo(g1, snapTolerance);
 
-	/**
-	 * Snap the second geometry to the snapped first geometry
-	 * (this strategy minimizes the number of possible different
-	 * points in the result)
-	 */
-	GeometrySnapper snapper1(g1);
-	snapGeom.second = snapper1.snapTo(*snapGeom.first, snapTolerance);
+    /**
+     * Snap the second geometry to the snapped first geometry
+     * (this strategy minimizes the number of possible different
+     * points in the result)
+     */
+    GeometrySnapper snapper1(g1);
+    snapGeom.second = snapper1.snapTo(*snapGeom.first, snapTolerance);
 
 //	cout << *snapGeom.first << endl;
 //	cout << *snapGeom.second << endl;
@@ -213,11 +214,11 @@ GeometrySnapper::snap(const geom::Geometry& g0,
 /* public static */
 GeometrySnapper::GeomPtr
 GeometrySnapper::snapToSelf(const geom::Geometry& g,
-                      double snapTolerance,
-                      bool cleanResult)
+                            double snapTolerance,
+                            bool cleanResult)
 {
-	GeometrySnapper snapper0(g);
-	return snapper0.snapToSelf(snapTolerance, cleanResult);
+    GeometrySnapper snapper0(g);
+    return snapper0.snapToSelf(snapTolerance, cleanResult);
 }
 
 } // namespace geos.operation.snap
diff --git a/src/operation/overlay/snap/LineStringSnapper.cpp b/src/operation/overlay/snap/LineStringSnapper.cpp
index a3c8ab9..a06b99d 100644
--- a/src/operation/overlay/snap/LineStringSnapper.cpp
+++ b/src/operation/overlay/snap/LineStringSnapper.cpp
@@ -54,121 +54,124 @@ namespace snap { // geos.operation.overlay.snap
 std::unique_ptr<Coordinate::Vect>
 LineStringSnapper::snapTo(const geom::Coordinate::ConstVect& snapPts)
 {
-	geom::CoordinateList coordList(srcPts);
+    geom::CoordinateList coordList(srcPts);
 
-	snapVertices(coordList, snapPts);
-	snapSegments(coordList, snapPts);
+    snapVertices(coordList, snapPts);
+    snapSegments(coordList, snapPts);
 
-	return coordList.toCoordinateArray();
+    return coordList.toCoordinateArray();
 }
 
 /*private*/
 CoordinateList::iterator
 LineStringSnapper::findVertexToSnap(
-			const Coordinate& snapPt,
-			CoordinateList::iterator from,
-			CoordinateList::iterator too_far)
+    const Coordinate& snapPt,
+    CoordinateList::iterator from,
+    CoordinateList::iterator too_far)
 {
-	double minDist = snapTolerance; // make sure the first closer then
-	                                // snapTolerance is accepted
-	CoordinateList::iterator match=too_far;
+    double minDist = snapTolerance; // make sure the first closer then
+    // snapTolerance is accepted
+    CoordinateList::iterator match = too_far;
 
-	for ( ; from != too_far; ++from)
-	{
-    Coordinate& c0 = *from;
+    for(; from != too_far; ++from) {
+        Coordinate& c0 = *from;
 
 #if GEOS_DEBUG
-cerr << " Checking vertex " << c0 << endl;
+        cerr << " Checking vertex " << c0 << endl;
 #endif
 
-		double dist = c0.distance(snapPt);
-		if ( dist >= minDist) {
+        double dist = c0.distance(snapPt);
+        if(dist >= minDist) {
 #if GEOS_DEBUG
-cerr << "   snap point distance " << dist
-     << " not smaller than tolerance "
-     << snapTolerance << " or previous closest "
-     << minDist << endl;
+            cerr << "   snap point distance " << dist
+                 << " not smaller than tolerance "
+                 << snapTolerance << " or previous closest "
+                 << minDist << endl;
 #endif
-      continue;
-    }
+            continue;
+        }
 
 #if GEOS_DEBUG
-    cerr << "   snap point distance " << dist << " within tolerance "
-         << snapTolerance << " and closer than previous candidate "
-         << minDist << endl;
+        cerr << "   snap point distance " << dist << " within tolerance "
+             << snapTolerance << " and closer than previous candidate "
+             << minDist << endl;
 #endif
 
-    if ( dist == 0.0 ) return from; // can't find any closer
+        if(dist == 0.0) {
+            return from;    // can't find any closer
+        }
 
-    match = from;
-    minDist = dist;
+        match = from;
+        minDist = dist;
 
-	}
+    }
 
-	return match;
+    return match;
 }
 
 
 /*private*/
 void
 LineStringSnapper::snapVertices(geom::CoordinateList& srcCoords,
-			const geom::Coordinate::ConstVect& snapPts)
+                                const geom::Coordinate::ConstVect& snapPts)
 {
-  // nothing to do if there are no source coords..
-  if ( srcCoords.empty() ) return;
+    // nothing to do if there are no source coords..
+    if(srcCoords.empty()) {
+        return;
+    }
 
 #if GEOS_DEBUG
-cerr << "Snapping vertices of: " << srcCoords << endl;
+    cerr << "Snapping vertices of: " << srcCoords << endl;
 #endif
 
-	for ( Coordinate::ConstVect::const_iterator
-			it=snapPts.begin(), end=snapPts.end();
-			it != end;
-			++it)
-	{
-	    GEOS_CHECK_FOR_INTERRUPTS();
-		assert(*it);
-		const Coordinate& snapPt = *(*it);
+    for(Coordinate::ConstVect::const_iterator
+            it = snapPts.begin(), end = snapPts.end();
+            it != end;
+            ++it) {
+        GEOS_CHECK_FOR_INTERRUPTS();
+        assert(*it);
+        const Coordinate& snapPt = *(*it);
 
 #if GEOS_DEBUG
-cerr << "Checking for a vertex to snap to snapPt " << snapPt << endl;
+        cerr << "Checking for a vertex to snap to snapPt " << snapPt << endl;
 #endif
 
-		CoordinateList::iterator too_far = srcCoords.end();
-    if ( isClosed ) --too_far;
-		CoordinateList::iterator vertpos =
-			findVertexToSnap(snapPt, srcCoords.begin(), too_far);
-		if ( vertpos == too_far)
-		{
+        CoordinateList::iterator too_far = srcCoords.end();
+        if(isClosed) {
+            --too_far;
+        }
+        CoordinateList::iterator vertpos =
+            findVertexToSnap(snapPt, srcCoords.begin(), too_far);
+        if(vertpos == too_far) {
 #if GEOS_DEBUG
-cerr << " No vertex to snap" << endl;
+            cerr << " No vertex to snap" << endl;
 #endif
-			continue;
-		}
+            continue;
+        }
 
 #if GEOS_DEBUG
-cerr << " Vertex to be snapped found, snapping" << endl;
+        cerr << " Vertex to be snapped found, snapping" << endl;
 #endif
-    *vertpos = snapPt;
+        *vertpos = snapPt;
 
-    // keep final closing point in synch (rings only)
-    if (vertpos == srcCoords.begin() && isClosed)
-    {
-      vertpos = srcCoords.end(); --vertpos;
+        // keep final closing point in synch (rings only)
+        if(vertpos == srcCoords.begin() && isClosed) {
+            vertpos = srcCoords.end();
+            --vertpos;
 #if GEOS_DEBUG
-cerr << " Snapped vertex was first in a closed line, also snapping last" << endl;
+            cerr << " Snapped vertex was first in a closed line, also snapping last" << endl;
 #endif
-      *vertpos = snapPt;
-    }
+            *vertpos = snapPt;
+        }
 
 #if GEOS_DEBUG
-cerr << " After snapping of vertex " << snapPt << ", srcCoors are: " << srcCoords << endl;
+        cerr << " After snapping of vertex " << snapPt << ", srcCoors are: " << srcCoords << endl;
 #endif
 
-	}
+    }
 
 #if GEOS_DEBUG
-cerr << " After vertices snapping, srcCoors are: " << srcCoords << endl;
+    cerr << " After vertices snapping, srcCoors are: " << srcCoords << endl;
 #endif
 
 }
@@ -176,201 +179,205 @@ cerr << " After vertices snapping, srcCoors are: " << srcCoords << endl;
 /*private*/
 Coordinate::ConstVect::const_iterator
 LineStringSnapper::findSnapForVertex(const Coordinate& pt,
-			const Coordinate::ConstVect& snapPts)
+                                     const Coordinate::ConstVect& snapPts)
 {
-	Coordinate::ConstVect::const_iterator end = snapPts.end();
-	Coordinate::ConstVect::const_iterator candidate = end;
-	double minDist = snapTolerance;
+    Coordinate::ConstVect::const_iterator end = snapPts.end();
+    Coordinate::ConstVect::const_iterator candidate = end;
+    double minDist = snapTolerance;
 
-	// TODO: use std::find_if
-	for ( Coordinate::ConstVect::const_iterator
-			it=snapPts.begin();
-			it != end;
-			++it)
-	{
-		assert(*it);
-		const Coordinate& snapPt = *(*it);
+    // TODO: use std::find_if
+    for(Coordinate::ConstVect::const_iterator
+            it = snapPts.begin();
+            it != end;
+            ++it) {
+        assert(*it);
+        const Coordinate& snapPt = *(*it);
 
-		if ( snapPt.equals2D(pt) )
-		{
+        if(snapPt.equals2D(pt)) {
 #if GEOS_DEBUG
-cerr << " points are equal, returning not-found " << endl;
+            cerr << " points are equal, returning not-found " << endl;
 #endif
-			return end;
-		}
+            return end;
+        }
 
-		double dist = snapPt.distance(pt);
+        double dist = snapPt.distance(pt);
 #if GEOS_DEBUG
-cerr << " distance from snap point " << snapPt << ": " << dist << endl;
+        cerr << " distance from snap point " << snapPt << ": " << dist << endl;
 #endif
 
-		if ( dist < minDist )
-		{
-      minDist = dist;
-      candidate = it;
-		}
-	}
+        if(dist < minDist) {
+            minDist = dist;
+            candidate = it;
+        }
+    }
 
 #if GEOS_DEBUG
-  if ( candidate == end ) {
-cerr << " no snap point within distance, returning not-found" << endl;
-  }
+    if(candidate == end) {
+        cerr << " no snap point within distance, returning not-found" << endl;
+    }
 #endif
 
-	return candidate;
+    return candidate;
 }
 
 
 /*private*/
 void
 LineStringSnapper::snapSegments(geom::CoordinateList& srcCoords,
-			const geom::Coordinate::ConstVect& snapPts)
+                                const geom::Coordinate::ConstVect& snapPts)
 {
 
-  // nothing to do if there are no source coords..
-  if ( srcCoords.empty() ) return;
+    // nothing to do if there are no source coords..
+    if(srcCoords.empty()) {
+        return;
+    }
 
-	GEOS_CHECK_FOR_INTERRUPTS();
+    GEOS_CHECK_FOR_INTERRUPTS();
 
 #if GEOS_DEBUG
-cerr << "Snapping segments of: " << srcCoords << endl;
+    cerr << "Snapping segments of: " << srcCoords << endl;
 #endif
 
-	for ( Coordinate::ConstVect::const_iterator
-			it=snapPts.begin(), end=snapPts.end();
-			it != end;
-			++it)
-	{
-		assert(*it);
-		const Coordinate& snapPt = *(*it);
+    for(Coordinate::ConstVect::const_iterator
+            it = snapPts.begin(), end = snapPts.end();
+            it != end;
+            ++it) {
+        assert(*it);
+        const Coordinate& snapPt = *(*it);
 
 #if GEOS_DEBUG
-cerr << "Checking for a segment to snap to snapPt " << snapPt << endl;
+        cerr << "Checking for a segment to snap to snapPt " << snapPt << endl;
 #endif
 
-		CoordinateList::iterator too_far = srcCoords.end(); --too_far;
-		CoordinateList::iterator segpos =
-			findSegmentToSnap(snapPt, srcCoords.begin(), too_far);
-		if ( segpos == too_far)
-		{
+        CoordinateList::iterator too_far = srcCoords.end();
+        --too_far;
+        CoordinateList::iterator segpos =
+            findSegmentToSnap(snapPt, srcCoords.begin(), too_far);
+        if(segpos == too_far) {
 #if GEOS_DEBUG
-cerr << " No segment to snap" << endl;
+            cerr << " No segment to snap" << endl;
 #endif
-			continue;
-		}
+            continue;
+        }
 
-    /* Check if the snap point falls outside of the segment */
-    // If the snap point is outside, this means that an endpoint
-    // was not snap where it should have been
-    // so what we should do is re-snap the endpoint to this
-    // snapPt and then snap the closest between this and
-    // previous (for pf < 0.0) or next (for pf > 1.0) segment
-    // to the old endpoint.
-    //     --strk May 2013
-    //
-    // TODO: simplify this code, make more readable
-    //
-    CoordinateList::iterator to = segpos; ++to;
-    LineSegment seg(*segpos, *to);
-    double pf = seg.projectionFactor(snapPt);
-    if ( pf >= 1.0 ) {
-#if GEOS_DEBUG
-      cerr << " Segment to be snapped is closer on his end point" << endl;
-#endif
-      Coordinate newSnapPt = seg.p1;
-      *to = seg.p1 = snapPt;
-      // now snap from-to (segpos) or to-next (segpos++) to newSnapPt
-      if ( to == too_far ) {
-        if ( isClosed ) {
-#if GEOS_DEBUG
-          cerr << " His end point is the last one, but is closed " << endl;
-#endif
-          *(srcCoords.begin()) = snapPt; // sync to start point
-          to = srcCoords.begin();
-        } else {
-#if GEOS_DEBUG
-          cerr << " His end point is the last one, inserting " << newSnapPt << " before it" << endl;
-#endif
-          srcCoords.insert(to, newSnapPt);
-          continue;
+        /* Check if the snap point falls outside of the segment */
+        // If the snap point is outside, this means that an endpoint
+        // was not snap where it should have been
+        // so what we should do is re-snap the endpoint to this
+        // snapPt and then snap the closest between this and
+        // previous (for pf < 0.0) or next (for pf > 1.0) segment
+        // to the old endpoint.
+        //     --strk May 2013
+        //
+        // TODO: simplify this code, make more readable
+        //
+        CoordinateList::iterator to = segpos;
+        ++to;
+        LineSegment seg(*segpos, *to);
+        double pf = seg.projectionFactor(snapPt);
+        if(pf >= 1.0) {
+#if GEOS_DEBUG
+            cerr << " Segment to be snapped is closer on his end point" << endl;
+#endif
+            Coordinate newSnapPt = seg.p1;
+            *to = seg.p1 = snapPt;
+            // now snap from-to (segpos) or to-next (segpos++) to newSnapPt
+            if(to == too_far) {
+                if(isClosed) {
+#if GEOS_DEBUG
+                    cerr << " His end point is the last one, but is closed " << endl;
+#endif
+                    *(srcCoords.begin()) = snapPt; // sync to start point
+                    to = srcCoords.begin();
+                }
+                else {
+#if GEOS_DEBUG
+                    cerr << " His end point is the last one, inserting " << newSnapPt << " before it" << endl;
+#endif
+                    srcCoords.insert(to, newSnapPt);
+                    continue;
+                }
+            }
+            ++to;
+            LineSegment nextSeg(seg.p1, *to);
+            if(nextSeg.distance(newSnapPt) < seg.distance(newSnapPt)) {
+#if GEOS_DEBUG
+                cerr << " Next segment closer, inserting " << newSnapPt << " into " << nextSeg << endl;
+#endif
+                // insert into next segment
+                srcCoords.insert(to, newSnapPt);
+            }
+            else {
+#if GEOS_DEBUG
+                cerr << " This segment closer, inserting " << newSnapPt << " into " << seg << endl;
+#endif
+                // insert must happen one-past first point (before next point)
+                ++segpos;
+                srcCoords.insert(segpos, newSnapPt);
+            }
         }
-      }
-      ++to;
-      LineSegment nextSeg(seg.p1, *to);
-      if ( nextSeg.distance(newSnapPt) < seg.distance(newSnapPt) ) {
-#if GEOS_DEBUG
-        cerr << " Next segment closer, inserting " << newSnapPt << " into " << nextSeg << endl;
-#endif
-        // insert into next segment
-        srcCoords.insert(to, newSnapPt);
-      } else {
-#if GEOS_DEBUG
-        cerr << " This segment closer, inserting " << newSnapPt << " into " << seg << endl;
-#endif
-        // insert must happen one-past first point (before next point)
-        ++segpos;
-        srcCoords.insert(segpos, newSnapPt);
-      }
-    }
-    else if ( pf <= 0.0 ) {
+        else if(pf <= 0.0) {
 #if GEOS_DEBUG
-      cerr << " Segment to be snapped is closer on his start point" << endl;
+            cerr << " Segment to be snapped is closer on his start point" << endl;
 #endif
-      Coordinate newSnapPt = seg.p0;
-      *segpos = seg.p0 = snapPt;
-      // now snap prev-from (--segpos) or from-to (segpos) to newSnapPt
-      if ( segpos == srcCoords.begin() ) {
-        if ( isClosed ) {
+            Coordinate newSnapPt = seg.p0;
+            *segpos = seg.p0 = snapPt;
+            // now snap prev-from (--segpos) or from-to (segpos) to newSnapPt
+            if(segpos == srcCoords.begin()) {
+                if(isClosed) {
 #if GEOS_DEBUG
-          cerr << " His start point is the first one, but is closed " << endl;
+                    cerr << " His start point is the first one, but is closed " << endl;
 #endif
-          segpos = srcCoords.end(); --segpos;
-          *segpos = snapPt; // sync to end point
-        } else {
+                    segpos = srcCoords.end();
+                    --segpos;
+                    *segpos = snapPt; // sync to end point
+                }
+                else {
 #if GEOS_DEBUG
-          cerr << " His start point is the first one, inserting " << newSnapPt << " before it" << endl;
+                    cerr << " His start point is the first one, inserting " << newSnapPt << " before it" << endl;
 #endif
-          ++segpos;
-          srcCoords.insert(segpos, newSnapPt);
-          continue;
-        }
-      }
+                    ++segpos;
+                    srcCoords.insert(segpos, newSnapPt);
+                    continue;
+                }
+            }
 
 #if GEOS_DEBUG
-cerr << " Before seg-snapping, srcCoors are: " << srcCoords << endl;
+            cerr << " Before seg-snapping, srcCoors are: " << srcCoords << endl;
 #endif
 
-      --segpos;
-      LineSegment prevSeg(*segpos, seg.p0);
-      if ( prevSeg.distance(newSnapPt) < seg.distance(newSnapPt) ) {
+            --segpos;
+            LineSegment prevSeg(*segpos, seg.p0);
+            if(prevSeg.distance(newSnapPt) < seg.distance(newSnapPt)) {
 #if GEOS_DEBUG
-        cerr << " Prev segment closer, inserting " << newSnapPt << " into "
-             << prevSeg << endl;
+                cerr << " Prev segment closer, inserting " << newSnapPt << " into "
+                     << prevSeg << endl;
 #endif
-        // insert into prev segment
-        ++segpos;
-        srcCoords.insert(segpos, newSnapPt);
-      } else {
+                // insert into prev segment
+                ++segpos;
+                srcCoords.insert(segpos, newSnapPt);
+            }
+            else {
 #if GEOS_DEBUG
-        cerr << " This segment closer, inserting " << newSnapPt << " into " << seg << endl;
+                cerr << " This segment closer, inserting " << newSnapPt << " into " << seg << endl;
 #endif
-        // insert must happen one-past first point (before next point)
-        srcCoords.insert(to, newSnapPt);
-      }
-    }
-    else {
-      //assert(pf != 0.0);
+                // insert must happen one-past first point (before next point)
+                srcCoords.insert(to, newSnapPt);
+            }
+        }
+        else {
+            //assert(pf != 0.0);
 #if GEOS_DEBUG
-cerr << " Segment to be snapped found, projection factor is " << pf << ", inserting point" << endl;
+            cerr << " Segment to be snapped found, projection factor is " << pf << ", inserting point" << endl;
 #endif
-      // insert must happen one-past first point (before next point)
-      ++segpos;
-      srcCoords.insert(segpos, snapPt);
+            // insert must happen one-past first point (before next point)
+            ++segpos;
+            srcCoords.insert(segpos, snapPt);
+        }
     }
-	}
 
 #if GEOS_DEBUG
-cerr << " After segment snapping, srcCoors are: " << srcCoords << endl;
+    cerr << " After segment snapping, srcCoors are: " << srcCoords << endl;
 #endif
 
 }
@@ -379,77 +386,78 @@ cerr << " After segment snapping, srcCoors are: " << srcCoords << endl;
 /* NOTE: this is called findSegmentIndexToSnap in JTS */
 CoordinateList::iterator
 LineStringSnapper::findSegmentToSnap(
-			const Coordinate& snapPt,
-			CoordinateList::iterator from,
-			CoordinateList::iterator too_far)
+    const Coordinate& snapPt,
+    CoordinateList::iterator from,
+    CoordinateList::iterator too_far)
 {
-	LineSegment seg;
-	double minDist = snapTolerance; // make sure the first closer then
-	                                // snapTolerance is accepted
-	CoordinateList::iterator match=too_far;
+    LineSegment seg;
+    double minDist = snapTolerance; // make sure the first closer then
+    // snapTolerance is accepted
+    CoordinateList::iterator match = too_far;
 
-	// TODO: use std::find_if
-	for ( ; from != too_far; ++from)
-	{
-		seg.p0 = *from;
-		CoordinateList::iterator to = from;
-		++to;
-		seg.p1 = *to;
+    // TODO: use std::find_if
+    for(; from != too_far; ++from) {
+        seg.p0 = *from;
+        CoordinateList::iterator to = from;
+        ++to;
+        seg.p1 = *to;
 
 #if GEOS_DEBUG
-cerr << " Checking segment " << seg << endl;
+        cerr << " Checking segment " << seg << endl;
 #endif
 
-		/**
-		 * Check if the snap pt is equal to one of
-		 * the segment endpoints.
-		 *
-		 * If the snap pt is already in the src list,
-		 * don't snap at all (unless allowSnappingToSourceVertices
-		 * is set to true)
-		 */
-		if ( seg.p0.equals2D(snapPt) || seg.p1.equals2D(snapPt) )
-		{
+        /**
+         * Check if the snap pt is equal to one of
+         * the segment endpoints.
+         *
+         * If the snap pt is already in the src list,
+         * don't snap at all (unless allowSnappingToSourceVertices
+         * is set to true)
+         */
+        if(seg.p0.equals2D(snapPt) || seg.p1.equals2D(snapPt)) {
 
-			if (allowSnappingToSourceVertices) {
+            if(allowSnappingToSourceVertices) {
 #if GEOS_DEBUG
-cerr << "   snap point matches a segment endpoint, checking next segment"
-     << endl;
+                cerr << "   snap point matches a segment endpoint, checking next segment"
+                     << endl;
 #endif
-				continue;
-			} else {
+                continue;
+            }
+            else {
 #if GEOS_DEBUG
-cerr << "   snap point matches a segment endpoint, giving up seek" << endl;
+                cerr << "   snap point matches a segment endpoint, giving up seek" << endl;
 #endif
-				return too_far;
-			}
-		}
+                return too_far;
+            }
+        }
 
-		double dist = seg.distance(snapPt);
-		if ( dist >= minDist) {
+        double dist = seg.distance(snapPt);
+        if(dist >= minDist) {
 #if GEOS_DEBUG
-cerr << "   snap point distance " << dist
-     << " not smaller than tolerance "
-     << snapTolerance << " or previous closest "
-     << minDist << endl;
+            cerr << "   snap point distance " << dist
+                 << " not smaller than tolerance "
+                 << snapTolerance << " or previous closest "
+                 << minDist << endl;
 #endif
-      continue;
-    }
+            continue;
+        }
 
 #if GEOS_DEBUG
-    cerr << "   snap point distance " << dist << " within tolerance "
-         << snapTolerance << " and closer than previous candidate "
-         << minDist << endl;
+        cerr << "   snap point distance " << dist << " within tolerance "
+             << snapTolerance << " and closer than previous candidate "
+             << minDist << endl;
 #endif
 
-    if ( dist == 0.0 ) return from; // can't find any closer
+        if(dist == 0.0) {
+            return from;    // can't find any closer
+        }
 
-    match = from;
-    minDist = dist;
+        match = from;
+        minDist = dist;
 
-	}
+    }
 
-	return match;
+    return match;
 }
 
 } // namespace geos.operation.snap
diff --git a/src/operation/overlay/snap/SnapIfNeededOverlayOp.cpp b/src/operation/overlay/snap/SnapIfNeededOverlayOp.cpp
index 9da6254..6834343 100644
--- a/src/operation/overlay/snap/SnapIfNeededOverlayOp.cpp
+++ b/src/operation/overlay/snap/SnapIfNeededOverlayOp.cpp
@@ -42,36 +42,36 @@ namespace snap { // geos.operation.overlay.snap
 unique_ptr<Geometry>
 SnapIfNeededOverlayOp::getResultGeometry(OverlayOp::OpCode opCode)
 {
-	using geos::util::TopologyException;
+    using geos::util::TopologyException;
 
-	unique_ptr<Geometry> result;
+    unique_ptr<Geometry> result;
 
-	TopologyException origEx;
+    TopologyException origEx;
 
-	// Try with original input
-	try {
-		result.reset( OverlayOp::overlayOp(&geom0, &geom1, opCode) );
-		return result;
-	}
-	catch (const TopologyException& ex) {
-		origEx = ex; // save original exception
+    // Try with original input
+    try {
+        result.reset(OverlayOp::overlayOp(&geom0, &geom1, opCode));
+        return result;
+    }
+    catch(const TopologyException& ex) {
+        origEx = ex; // save original exception
 #if GEOS_DEBUG
-		std::cerr << "Overlay op threw " << ex.what() << ". Will try snapping now" << std::endl;
+        std::cerr << "Overlay op threw " << ex.what() << ". Will try snapping now" << std::endl;
 #endif
-	}
+    }
 
-	// Try snapping
-	try {
-		result = SnapOverlayOp::overlayOp(geom0, geom1, opCode);
-		return result;
-	}
-	catch (const TopologyException& ex) {
-		::geos::ignore_unused_variable_warning(ex);
+    // Try snapping
+    try {
+        result = SnapOverlayOp::overlayOp(geom0, geom1, opCode);
+        return result;
+    }
+    catch(const TopologyException& ex) {
+        ::geos::ignore_unused_variable_warning(ex);
 #if GEOS_DEBUG
-		std::cerr << "Overlay op on snapped geoms threw " << ex.what() << ". Will try snapping now" << std::endl;
+        std::cerr << "Overlay op on snapped geoms threw " << ex.what() << ". Will try snapping now" << std::endl;
 #endif
-	 	throw origEx;
-	}
+        throw origEx;
+    }
 }
 
 
diff --git a/src/operation/overlay/snap/SnapOverlayOp.cpp b/src/operation/overlay/snap/SnapOverlayOp.cpp
index 302bd3f..8b36380 100644
--- a/src/operation/overlay/snap/SnapOverlayOp.cpp
+++ b/src/operation/overlay/snap/SnapOverlayOp.cpp
@@ -41,33 +41,33 @@ namespace snap { // geos.operation.overlay.snap
 void
 SnapOverlayOp::computeSnapTolerance()
 {
-	snapTolerance = GeometrySnapper::computeOverlaySnapTolerance(geom0,
-	                                                             geom1);
+    snapTolerance = GeometrySnapper::computeOverlaySnapTolerance(geom0,
+                    geom1);
 
-	// cout << "Snap tol = " <<  snapTolerance << endl;
+    // cout << "Snap tol = " <<  snapTolerance << endl;
 }
 
 /* public */
 unique_ptr<Geometry>
 SnapOverlayOp::getResultGeometry(OverlayOp::OpCode opCode)
 {
-	geom::GeomPtrPair prepGeom;
-	snap(prepGeom);
-	GeomPtr result ( OverlayOp::overlayOp(prepGeom.first.get(),
-	                                      prepGeom.second.get(), opCode) );
-	prepareResult(*result);
-	return result;
+    geom::GeomPtrPair prepGeom;
+    snap(prepGeom);
+    GeomPtr result(OverlayOp::overlayOp(prepGeom.first.get(),
+                                        prepGeom.second.get(), opCode));
+    prepareResult(*result);
+    return result;
 }
 
 /* private */
 void
 SnapOverlayOp::snap(geom::GeomPtrPair& snapGeom)
 {
-	geom::GeomPtrPair remGeom;
-	removeCommonBits(geom0, geom1, remGeom);
+    geom::GeomPtrPair remGeom;
+    removeCommonBits(geom0, geom1, remGeom);
 
-	GeometrySnapper::snap(*remGeom.first, *remGeom.second,
-	                      snapTolerance, snapGeom);
+    GeometrySnapper::snap(*remGeom.first, *remGeom.second,
+                          snapTolerance, snapGeom);
 
     // MD - may want to do this at some point, but it adds cycles
 //    checkValid(snapGeom[0]);
@@ -85,14 +85,14 @@ SnapOverlayOp::snap(geom::GeomPtrPair& snapGeom)
 void
 SnapOverlayOp::removeCommonBits(const geom::Geometry& p_geom0,
                                 const geom::Geometry& p_geom1,
-				geom::GeomPtrPair& remGeom)
+                                geom::GeomPtrPair& remGeom)
 {
-	cbr.reset(new precision::CommonBitsRemover());
-	cbr->add(&p_geom0);
-	cbr->add(&p_geom1);
+    cbr.reset(new precision::CommonBitsRemover());
+    cbr->add(&p_geom0);
+    cbr->add(&p_geom1);
 
-	remGeom.first.reset( cbr->removeCommonBits(p_geom0.clone()) );
-	remGeom.second.reset( cbr->removeCommonBits(p_geom1.clone()) );
+    remGeom.first.reset(cbr->removeCommonBits(p_geom0.clone()));
+    remGeom.second.reset(cbr->removeCommonBits(p_geom1.clone()));
 }
 
 /*private*/
diff --git a/src/operation/overlay/validate/FuzzyPointLocator.cpp b/src/operation/overlay/validate/FuzzyPointLocator.cpp
index 5e6db07..6422ff4 100644
--- a/src/operation/overlay/validate/FuzzyPointLocator.cpp
+++ b/src/operation/overlay/validate/FuzzyPointLocator.cpp
@@ -47,12 +47,12 @@ namespace overlay { // geos.operation.overlay
 namespace validate { // geos.operation.overlay.validate
 
 FuzzyPointLocator::FuzzyPointLocator(const geom::Geometry& geom,
-		double nTolerance)
-	:
-	g(geom),
-	tolerance(nTolerance),
-	ptLocator(),
-	linework(extractLineWork(g))
+                                     double nTolerance)
+    :
+    g(geom),
+    tolerance(nTolerance),
+    ptLocator(),
+    linework(extractLineWork(g))
 {
 }
 
@@ -62,30 +62,29 @@ FuzzyPointLocator::extractLineWork(const geom::Geometry& geom)
 {
     ::geos::ignore_unused_variable_warning(geom);
 
-	vector<Geometry*>* lineGeoms = new vector<Geometry*>();
-	try { // geoms array will leak if an exception is thrown
-
-	for (size_t i=0, n=g.getNumGeometries(); i<n; ++i)
-	{
-		const Geometry* gComp = g.getGeometryN(i);
-		Geometry* lineGeom = nullptr;
-
-		// only get linework for polygonal components
-		if (gComp->getDimension() == 2) {
-			lineGeom = gComp->getBoundary();
-			lineGeoms->push_back(lineGeom);
-		}
-	}
-	return std::unique_ptr<Geometry>(g.getFactory()->buildGeometry(lineGeoms));
-
-	} catch (...) { // avoid leaks
-		for (size_t i=0, n=lineGeoms->size(); i<n; ++i)
-		{
-			delete (*lineGeoms)[i];
-		}
-		delete lineGeoms;
-		throw;
-	}
+    vector<Geometry*>* lineGeoms = new vector<Geometry*>();
+    try { // geoms array will leak if an exception is thrown
+
+        for(size_t i = 0, n = g.getNumGeometries(); i < n; ++i) {
+            const Geometry* gComp = g.getGeometryN(i);
+            Geometry* lineGeom = nullptr;
+
+            // only get linework for polygonal components
+            if(gComp->getDimension() == 2) {
+                lineGeom = gComp->getBoundary();
+                lineGeoms->push_back(lineGeom);
+            }
+        }
+        return std::unique_ptr<Geometry>(g.getFactory()->buildGeometry(lineGeoms));
+
+    }
+    catch(...) {    // avoid leaks
+        for(size_t i = 0, n = lineGeoms->size(); i < n; ++i) {
+            delete(*lineGeoms)[i];
+        }
+        delete lineGeoms;
+        throw;
+    }
 
 }
 
@@ -95,32 +94,31 @@ FuzzyPointLocator::getLineWork(const geom::Geometry& geom)
 {
     ::geos::ignore_unused_variable_warning(geom);
 
-	vector<Geometry*>* lineGeoms = new vector<Geometry*>();
-	try { // geoms array will leak if an exception is thrown
-
-	for (size_t i=0, n=g.getNumGeometries(); i<n; ++i)
-	{
-		const Geometry* gComp = g.getGeometryN(i);
-		Geometry* lineGeom;
-		if (gComp->getDimension() == 2) {
-			lineGeom = gComp->getBoundary();
-		}
-		else {
-			lineGeom = gComp->clone();
-		}
-		lineGeoms->push_back(lineGeom);
-	}
-	return std::unique_ptr<Geometry>(g.getFactory()->buildGeometry(lineGeoms));
-
-	} catch (...) { // avoid leaks
-		for (size_t i=0, n=lineGeoms->size(); i<n; ++i)
-		{
-
-			delete (*lineGeoms)[i];
-		}
-		delete lineGeoms;
-		throw;
-	}
+    vector<Geometry*>* lineGeoms = new vector<Geometry*>();
+    try { // geoms array will leak if an exception is thrown
+
+        for(size_t i = 0, n = g.getNumGeometries(); i < n; ++i) {
+            const Geometry* gComp = g.getGeometryN(i);
+            Geometry* lineGeom;
+            if(gComp->getDimension() == 2) {
+                lineGeom = gComp->getBoundary();
+            }
+            else {
+                lineGeom = gComp->clone();
+            }
+            lineGeoms->push_back(lineGeom);
+        }
+        return std::unique_ptr<Geometry>(g.getFactory()->buildGeometry(lineGeoms));
+
+    }
+    catch(...) {    // avoid leaks
+        for(size_t i = 0, n = lineGeoms->size(); i < n; ++i) {
+
+            delete(*lineGeoms)[i];
+        }
+        delete lineGeoms;
+        throw;
+    }
 
 }
 
@@ -128,21 +126,22 @@ FuzzyPointLocator::getLineWork(const geom::Geometry& geom)
 Location::Value
 FuzzyPointLocator::getLocation(const Coordinate& pt)
 {
-	unique_ptr<Geometry> point(g.getFactory()->createPoint(pt));
+    unique_ptr<Geometry> point(g.getFactory()->createPoint(pt));
 
-	double dist = linework->distance(point.get());
+    double dist = linework->distance(point.get());
 
-	// if point is close to boundary, it is considered
-	// to be on the boundary
-	if (dist < tolerance)
-		return Location::BOUNDARY;
+    // if point is close to boundary, it is considered
+    // to be on the boundary
+    if(dist < tolerance) {
+        return Location::BOUNDARY;
+    }
 
-	// now we know point must be clearly inside or outside geometry,
-	// so return actual location value
+    // now we know point must be clearly inside or outside geometry,
+    // so return actual location value
 
-	// (the static_cast is needed because PointLocator doesn't cleanly
-	// return a Location::Value - it should !!)
-	return static_cast<Location::Value>(ptLocator.locate(pt, &g));
+    // (the static_cast is needed because PointLocator doesn't cleanly
+    // return a Location::Value - it should !!)
+    return static_cast<Location::Value>(ptLocator.locate(pt, &g));
 }
 
 } // namespace geos.operation.overlay.validate
diff --git a/src/operation/overlay/validate/OffsetPointGenerator.cpp b/src/operation/overlay/validate/OffsetPointGenerator.cpp
index 3501366..b07ca84 100644
--- a/src/operation/overlay/validate/OffsetPointGenerator.cpp
+++ b/src/operation/overlay/validate/OffsetPointGenerator.cpp
@@ -46,10 +46,10 @@ namespace validate { // geos.operation.overlay.validate
 
 /*public*/
 OffsetPointGenerator::OffsetPointGenerator(const geom::Geometry& geom,
-		double offset)
-	:
-	g(geom),
-	offsetDistance(offset)
+        double offset)
+    :
+    g(geom),
+    offsetDistance(offset)
 {
 }
 
@@ -57,53 +57,52 @@ OffsetPointGenerator::OffsetPointGenerator(const geom::Geometry& geom,
 std::unique_ptr< std::vector<geom::Coordinate> >
 OffsetPointGenerator::getPoints()
 {
-	assert (offsetPts.get() == nullptr);
-	offsetPts.reset(new vector<Coordinate>());
+    assert(offsetPts.get() == nullptr);
+    offsetPts.reset(new vector<Coordinate>());
 
-	vector<const LineString*> lines;
-	geos::geom::util::LinearComponentExtracter::getLines(g, lines);
-	for_each(lines.begin(), lines.end(),
-		bind1st(mem_fun(&OffsetPointGenerator::extractPoints), this));
+    vector<const LineString*> lines;
+    geos::geom::util::LinearComponentExtracter::getLines(g, lines);
+    for_each(lines.begin(), lines.end(),
+             bind1st(mem_fun(&OffsetPointGenerator::extractPoints), this));
 
-	// NOTE: Apparently, this is 'source' method giving up the object resource.
-	return std::move(offsetPts);
+    // NOTE: Apparently, this is 'source' method giving up the object resource.
+    return std::move(offsetPts);
 }
 
 /*private*/
 void
 OffsetPointGenerator::extractPoints(const LineString* line)
 {
-	const CoordinateSequence& pts = *(line->getCoordinatesRO());
-	assert(pts.size() > 1 );
+    const CoordinateSequence& pts = *(line->getCoordinatesRO());
+    assert(pts.size() > 1);
 
-	for (size_t i=0, n=pts.size()-1; i<n; ++i)
-	{
-		computeOffsets(pts[i], pts[i + 1]);
-	}
+    for(size_t i = 0, n = pts.size() - 1; i < n; ++i) {
+        computeOffsets(pts[i], pts[i + 1]);
+    }
 }
 
 /*private*/
 void
 OffsetPointGenerator::computeOffsets(const Coordinate& p0,
-		const Coordinate& p1)
+                                     const Coordinate& p1)
 {
-	double dx = p1.x - p0.x;
-	double dy = p1.y - p0.y;
-	double len = sqrt(dx * dx + dy * dy);
+    double dx = p1.x - p0.x;
+    double dy = p1.y - p0.y;
+    double len = sqrt(dx * dx + dy * dy);
 
-	// u is the vector that is the length of the offset,
-	// in the direction of the segment
-	double ux = offsetDistance * dx / len;
-	double uy = offsetDistance * dy / len;
+    // u is the vector that is the length of the offset,
+    // in the direction of the segment
+    double ux = offsetDistance * dx / len;
+    double uy = offsetDistance * dy / len;
 
-	double midX = (p1.x + p0.x) / 2;
-	double midY = (p1.y + p0.y) / 2;
+    double midX = (p1.x + p0.x) / 2;
+    double midY = (p1.y + p0.y) / 2;
 
-	Coordinate offsetLeft(midX - uy, midY + ux);
-	Coordinate offsetRight(midX + uy, midY - ux);
+    Coordinate offsetLeft(midX - uy, midY + ux);
+    Coordinate offsetRight(midX + uy, midY - ux);
 
-	offsetPts->push_back(offsetLeft);
-	offsetPts->push_back(offsetRight);
+    offsetPts->push_back(offsetLeft);
+    offsetPts->push_back(offsetRight);
 }
 
 } // namespace geos.operation.overlay.validate
diff --git a/src/operation/overlay/validate/OverlayResultValidator.cpp b/src/operation/overlay/validate/OverlayResultValidator.cpp
index 537442b..2cee56e 100644
--- a/src/operation/overlay/validate/OverlayResultValidator.cpp
+++ b/src/operation/overlay/validate/OverlayResultValidator.cpp
@@ -59,16 +59,16 @@ namespace { // anonymous namespace
 unique_ptr<MultiPoint>
 toMultiPoint(vector<Coordinate>& coords)
 {
-	const GeometryFactory& gf = *(GeometryFactory::getDefaultInstance());
-	const CoordinateSequenceFactory& csf =
-			*(gf.getCoordinateSequenceFactory());
+    const GeometryFactory& gf = *(GeometryFactory::getDefaultInstance());
+    const CoordinateSequenceFactory& csf =
+        *(gf.getCoordinateSequenceFactory());
 
-	unique_ptr< vector<Coordinate> > nc ( new vector<Coordinate>(coords) );
-	unique_ptr<CoordinateSequence> cs(csf.create(nc.release()));
+    unique_ptr< vector<Coordinate> > nc(new vector<Coordinate>(coords));
+    unique_ptr<CoordinateSequence> cs(csf.create(nc.release()));
 
-	unique_ptr<MultiPoint> mp ( gf.createMultiPoint(*cs) );
+    unique_ptr<MultiPoint> mp(gf.createMultiPoint(*cs));
 
-	return mp;
+    return mp;
 }
 #endif
 
@@ -78,29 +78,29 @@ toMultiPoint(vector<Coordinate>& coords)
 /* static public */
 bool
 OverlayResultValidator::isValid(const Geometry& geom0, const Geometry& geom1,
-		OverlayOp::OpCode opCode,
-		const Geometry& result)
+                                OverlayOp::OpCode opCode,
+                                const Geometry& result)
 {
-	OverlayResultValidator validator(geom0, geom1, result);
-	return validator.isValid(opCode);
+    OverlayResultValidator validator(geom0, geom1, result);
+    return validator.isValid(opCode);
 }
 
 /*public*/
 OverlayResultValidator::OverlayResultValidator(
-		const Geometry& geom0,
-		const Geometry& geom1,
-		const Geometry& result)
-	:
-	boundaryDistanceTolerance(
-		computeBoundaryDistanceTolerance(geom0, geom1)
-	),
-	g0(geom0),
-	g1(geom1),
-	gres(result),
-	fpl0(g0, boundaryDistanceTolerance),
-	fpl1(g1, boundaryDistanceTolerance),
-	fplres(gres, boundaryDistanceTolerance),
-	invalidLocation()
+    const Geometry& geom0,
+    const Geometry& geom1,
+    const Geometry& result)
+    :
+    boundaryDistanceTolerance(
+        computeBoundaryDistanceTolerance(geom0, geom1)
+    ),
+    g0(geom0),
+    g1(geom1),
+    gres(result),
+    fpl0(g0, boundaryDistanceTolerance),
+    fpl1(g1, boundaryDistanceTolerance),
+    fplres(gres, boundaryDistanceTolerance),
+    invalidLocation()
 {
 }
 
@@ -109,109 +109,107 @@ bool
 OverlayResultValidator::isValid(OverlayOp::OpCode overlayOp)
 {
 
-	addTestPts(g0);
-	addTestPts(g1);
-	addTestPts(gres);
+    addTestPts(g0);
+    addTestPts(g1);
+    addTestPts(gres);
 
-	if (! testValid(overlayOp) )
-	{
+    if(! testValid(overlayOp)) {
 #if GEOS_DEBUG
-	cerr << "OverlayResultValidator:" << endl
-		<< "Points:" << *toMultiPoint(testCoords) << endl
-		<< "Geom0: " << g0 << endl
-		<< "Geom1: " << g1 << endl
-		<< "Reslt: " << gres << endl
-		<< "Locat: " << getInvalidLocation()
-		<< endl;
+        cerr << "OverlayResultValidator:" << endl
+             << "Points:" << *toMultiPoint(testCoords) << endl
+             << "Geom0: " << g0 << endl
+             << "Geom1: " << g1 << endl
+             << "Reslt: " << gres << endl
+             << "Locat: " << getInvalidLocation()
+             << endl;
 #endif
-		return false;
-	}
+        return false;
+    }
 
 
-	return true;
+    return true;
 }
 
 /*private*/
 void
 OverlayResultValidator::addTestPts(const Geometry& g)
 {
-	OffsetPointGenerator ptGen(g, 5 * boundaryDistanceTolerance);
-	unique_ptr< vector<geom::Coordinate> > pts = ptGen.getPoints();
-	testCoords.insert(testCoords.end(), pts->begin(), pts->end());
+    OffsetPointGenerator ptGen(g, 5 * boundaryDistanceTolerance);
+    unique_ptr< vector<geom::Coordinate> > pts = ptGen.getPoints();
+    testCoords.insert(testCoords.end(), pts->begin(), pts->end());
 }
 
 /*private*/
 void
 OverlayResultValidator::addVertices(const Geometry& g)
 {
-	// TODO: optimize this by not copying coordinates
-	//       and pre-allocating memory
-	unique_ptr<CoordinateSequence> cs ( g.getCoordinates() );
-	const vector<Coordinate>* coords = cs->toVector();
-	testCoords.insert(testCoords.end(), coords->begin(), coords->end());
+    // TODO: optimize this by not copying coordinates
+    //       and pre-allocating memory
+    unique_ptr<CoordinateSequence> cs(g.getCoordinates());
+    const vector<Coordinate>* coords = cs->toVector();
+    testCoords.insert(testCoords.end(), coords->begin(), coords->end());
 }
 
 /*private*/
 bool
 OverlayResultValidator::testValid(OverlayOp::OpCode overlayOp)
 {
-	for (size_t i=0, n=testCoords.size(); i<n; ++i)
-	{
-		Coordinate& pt = testCoords[i];
-		if (! testValid(overlayOp, pt)) {
-			invalidLocation = pt;
-			return false;
-		}
-	}
-	return true;
+    for(size_t i = 0, n = testCoords.size(); i < n; ++i) {
+        Coordinate& pt = testCoords[i];
+        if(! testValid(overlayOp, pt)) {
+            invalidLocation = pt;
+            return false;
+        }
+    }
+    return true;
 }
 
 /*private*/
 bool
 OverlayResultValidator::testValid(OverlayOp::OpCode overlayOp,
-		const Coordinate& pt)
+                                  const Coordinate& pt)
 {
-	std::vector<geom::Location::Value> location(3);
+    std::vector<geom::Location::Value> location(3);
 
-	location[0] = fpl0.getLocation(pt);
-	location[1] = fpl1.getLocation(pt);
-	location[2] = fplres.getLocation(pt);
+    location[0] = fpl0.getLocation(pt);
+    location[1] = fpl1.getLocation(pt);
+    location[2] = fplres.getLocation(pt);
 
 #if GEOS_DEBUG
-	cerr << setprecision(10) << "Point " << pt << endl
-		<< "Loc0: " << location[0] << endl
-		<< "Loc1: " << location[1] << endl
-		<< "Locr: " << location[2] << endl;
+    cerr << setprecision(10) << "Point " << pt << endl
+         << "Loc0: " << location[0] << endl
+         << "Loc1: " << location[1] << endl
+         << "Locr: " << location[2] << endl;
 #endif
 
-	/*
-	 * If any location is on the Boundary, can't deduce anything,
-	 * so just return true
-	 */
-	if ( find(location.begin(), location.end(), Location::BOUNDARY) != location.end() )
-	{
+    /*
+     * If any location is on the Boundary, can't deduce anything,
+     * so just return true
+     */
+    if(find(location.begin(), location.end(), Location::BOUNDARY) != location.end()) {
 #if GEOS_DEBUG
-		cerr << "OverlayResultValidator: testpoint " << pt << " is on the boundary, blindly returning a positive answer (is valid)" << endl;
+        cerr << "OverlayResultValidator: testpoint " << pt <<
+             " is on the boundary, blindly returning a positive answer (is valid)" << endl;
 #endif
-		return true;
-	}
+        return true;
+    }
 
-	return isValidResult(overlayOp, location);
+    return isValidResult(overlayOp, location);
 }
 
 /* private */
 bool
 OverlayResultValidator::isValidResult(OverlayOp::OpCode overlayOp,
-	std::vector<geom::Location::Value>& location)
+                                      std::vector<geom::Location::Value>& location)
 {
-	bool expectedInterior = OverlayOp::isResultOfOp(location[0],
-			location[1], overlayOp);
+    bool expectedInterior = OverlayOp::isResultOfOp(location[0],
+                            location[1], overlayOp);
 
-	bool resultInInterior = (location[2] == Location::INTERIOR);
+    bool resultInInterior = (location[2] == Location::INTERIOR);
 
-	bool p_isValid = ! (expectedInterior ^ resultInInterior);
+    bool p_isValid = !(expectedInterior ^ resultInInterior);
 
-	return p_isValid;
+    return p_isValid;
 }
 
 /*private static*/
@@ -222,7 +220,7 @@ OverlayResultValidator::computeBoundaryDistanceTolerance(
     using geos::operation::overlay::snap::GeometrySnapper;
 
     return std::min(GeometrySnapper::computeSizeBasedSnapTolerance(g0),
-                      GeometrySnapper::computeSizeBasedSnapTolerance(g1));
+                    GeometrySnapper::computeSizeBasedSnapTolerance(g1));
 }
 
 } // namespace geos.operation.overlay.validate
diff --git a/src/operation/polygonize/EdgeRing.cpp b/src/operation/polygonize/EdgeRing.cpp
index 437d302..f81e5f1 100644
--- a/src/operation/polygonize/EdgeRing.cpp
+++ b/src/operation/polygonize/EdgeRing.cpp
@@ -47,48 +47,54 @@ namespace operation { // geos.operation
 namespace polygonize { // geos.operation.polygonize
 
 /*public*/
-EdgeRing *
-EdgeRing::findEdgeRingContaining(EdgeRing *testEr,
-    vector<EdgeRing*> *shellList)
+EdgeRing*
+EdgeRing::findEdgeRingContaining(EdgeRing* testEr,
+                                 vector<EdgeRing*>* shellList)
 {
-    const LinearRing *testRing=testEr->getRingInternal();
-    if ( ! testRing ) return nullptr;
-    const Envelope *testEnv=testRing->getEnvelopeInternal();
-    Coordinate testPt=testRing->getCoordinateN(0);
-    EdgeRing *minShell=nullptr;
-    const Envelope *minEnv=nullptr;
+    const LinearRing* testRing = testEr->getRingInternal();
+    if(! testRing) {
+        return nullptr;
+    }
+    const Envelope* testEnv = testRing->getEnvelopeInternal();
+    Coordinate testPt = testRing->getCoordinateN(0);
+    EdgeRing* minShell = nullptr;
+    const Envelope* minEnv = nullptr;
 
     typedef std::vector<EdgeRing*> ERList;
-    for(ERList::size_type i=0, e=shellList->size(); i<e; ++i) {
-        EdgeRing *tryShell=(*shellList)[i];
-        LinearRing *tryRing=tryShell->getRingInternal();
-        const Envelope *tryEnv=tryRing->getEnvelopeInternal();
-        if (minShell!=nullptr) minEnv=minShell->getRingInternal()->getEnvelopeInternal();
-        bool isContained=false;
+    for(ERList::size_type i = 0, e = shellList->size(); i < e; ++i) {
+        EdgeRing* tryShell = (*shellList)[i];
+        LinearRing* tryRing = tryShell->getRingInternal();
+        const Envelope* tryEnv = tryRing->getEnvelopeInternal();
+        if(minShell != nullptr) {
+            minEnv = minShell->getRingInternal()->getEnvelopeInternal();
+        }
+        bool isContained = false;
 
         // the hole envelope cannot equal the shell envelope
 
-        if (tryEnv->equals(testEnv)) continue;
+        if(tryEnv->equals(testEnv)) {
+            continue;
+        }
 
-        const CoordinateSequence *tryCoords =
+        const CoordinateSequence* tryCoords =
             tryRing->getCoordinatesRO();
 
-        if ( tryEnv->contains(testEnv) ) {
+        if(tryEnv->contains(testEnv)) {
 
             // TODO: don't copy testPt !
             testPt = ptNotInList(testRing->getCoordinatesRO(), tryCoords);
 
-            if ( PointLocation::isInRing(testPt, tryCoords) ) {
-                isContained=true;
+            if(PointLocation::isInRing(testPt, tryCoords)) {
+                isContained = true;
             }
 
-    }
+        }
 
         // check if this new containing ring is smaller
         // than the current minimum ring
-        if (isContained) {
-            if (minShell==nullptr || minEnv->contains(tryEnv)) {
-                minShell=tryShell;
+        if(isContained) {
+            if(minShell == nullptr || minEnv->contains(tryEnv)) {
+                minShell = tryShell;
             }
         }
     }
@@ -97,15 +103,15 @@ EdgeRing::findEdgeRingContaining(EdgeRing *testEr,
 
 /*public static*/
 const Coordinate&
-EdgeRing::ptNotInList(const CoordinateSequence *testPts,
-                      const CoordinateSequence *pts)
+EdgeRing::ptNotInList(const CoordinateSequence* testPts,
+                      const CoordinateSequence* pts)
 {
     const std::size_t npts = testPts->getSize();
-    for (std::size_t i = 0; i < npts; ++i)
-    {
+    for(std::size_t i = 0; i < npts; ++i) {
         const Coordinate& testPt = testPts->getAt(i);
-        if (!isInList(testPt, pts))
+        if(!isInList(testPt, pts)) {
             return testPt;
+        }
     }
     return Coordinate::getNull();
 }
@@ -113,19 +119,19 @@ EdgeRing::ptNotInList(const CoordinateSequence *testPts,
 /*public static*/
 bool
 EdgeRing::isInList(const Coordinate& pt,
-                   const CoordinateSequence *pts)
+                   const CoordinateSequence* pts)
 {
     const std::size_t npts = pts->getSize();
-    for (std::size_t i = 0; i < npts; ++i)
-    {
-        if (pt == pts->getAt(i))
+    for(std::size_t i = 0; i < npts; ++i) {
+        if(pt == pts->getAt(i)) {
             return true;
+        }
     }
     return false;
 }
 
 /*public*/
-EdgeRing::EdgeRing(const GeometryFactory *newFactory)
+EdgeRing::EdgeRing(const GeometryFactory* newFactory)
     :
     factory(newFactory),
     ring(nullptr),
@@ -133,19 +139,19 @@ EdgeRing::EdgeRing(const GeometryFactory *newFactory)
     holes(nullptr)
 {
 #ifdef DEBUG_ALLOC
-    cerr<<"["<<this<<"] EdgeRing(factory)"<<endl;
+    cerr << "[" << this << "] EdgeRing(factory)" << endl;
 #endif // DEBUG_ALLOC
 }
 
 EdgeRing::~EdgeRing()
 {
 #ifdef DEBUG_ALLOC
-    cerr<<"["<<this<<"] ~EdgeRing()"<<endl;
+    cerr << "[" << this << "] ~EdgeRing()" << endl;
 #endif // DEBUG_ALLOC
-    if ( holes )
-    {
-        for (GeomVect::size_type i=0, e=holes->size(); i<e; ++i)
-            delete (*holes)[i];
+    if(holes) {
+        for(GeomVect::size_type i = 0, e = holes->size(); i < e; ++i) {
+            delete(*holes)[i];
+        }
         delete holes;
     }
     delete ring;
@@ -154,23 +160,26 @@ EdgeRing::~EdgeRing()
 
 /*public*/
 void
-EdgeRing::add(const DirectedEdge *de){
+EdgeRing::add(const DirectedEdge* de)
+{
     deList.push_back(de);
 }
 
 /*public*/
 bool
-EdgeRing::isHole(){
+EdgeRing::isHole()
+{
     getRingInternal();
     return Orientation::isCCW(ring->getCoordinatesRO());
 }
 
 /*public*/
 void
-EdgeRing::addHole(LinearRing *hole)
+EdgeRing::addHole(LinearRing* hole)
 {
-    if (holes==nullptr)
-        holes=new vector<Geometry*>();
+    if(holes == nullptr) {
+        holes = new vector<Geometry*>();
+    }
     holes->push_back(hole);
 }
 
@@ -178,9 +187,9 @@ EdgeRing::addHole(LinearRing *hole)
 Polygon*
 EdgeRing::getPolygon()
 {
-    Polygon *poly=factory->createPolygon(ring, holes);
-    ring=nullptr;
-    holes=nullptr;
+    Polygon* poly = factory->createPolygon(ring, holes);
+    ring = nullptr;
+    holes = nullptr;
     return poly;
 }
 
@@ -188,7 +197,9 @@ EdgeRing::getPolygon()
 bool
 EdgeRing::isValid()
 {
-    if ( ! getRingInternal() ) return false; // computes cached ring
+    if(! getRingInternal()) {
+        return false;    // computes cached ring
+    }
     return ring->isValid();
 }
 
@@ -196,15 +207,14 @@ EdgeRing::isValid()
 CoordinateSequence*
 EdgeRing::getCoordinates()
 {
-    if (ringPts==nullptr)
-    {
-        ringPts=factory->getCoordinateSequenceFactory()->create();
-        for (DeList::size_type i=0, e=deList.size(); i<e; ++i) {
-            const DirectedEdge *de=deList[i];
+    if(ringPts == nullptr) {
+        ringPts = factory->getCoordinateSequenceFactory()->create();
+        for(DeList::size_type i = 0, e = deList.size(); i < e; ++i) {
+            const DirectedEdge* de = deList[i];
             assert(dynamic_cast<PolygonizeEdge*>(de->getEdge()));
-            PolygonizeEdge *edge=static_cast<PolygonizeEdge*>(de->getEdge());
+            PolygonizeEdge* edge = static_cast<PolygonizeEdge*>(de->getEdge());
             addEdge(edge->getLine()->getCoordinatesRO(),
-                de->getEdgeDirection(), ringPts);
+                    de->getEdgeDirection(), ringPts);
         }
     }
     return ringPts;
@@ -219,15 +229,18 @@ EdgeRing::getLineString()
 }
 
 /*public*/
-LinearRing *
+LinearRing*
 EdgeRing::getRingInternal()
 {
-    if (ring!=nullptr) return ring;
+    if(ring != nullptr) {
+        return ring;
+    }
 
     getCoordinates();
     try {
-        ring=factory->createLinearRing(*ringPts);
-    } catch (const geos::util::IllegalArgumentException& e) {
+        ring = factory->createLinearRing(*ringPts);
+    }
+    catch(const geos::util::IllegalArgumentException& e) {
 #if GEOS_DEBUG
         // FIXME: print also ringPts
         std::cerr << "EdgeRing::getRingInternal: "
@@ -240,32 +253,28 @@ EdgeRing::getRingInternal()
 }
 
 /*public*/
-LinearRing *
+LinearRing*
 EdgeRing::getRingOwnership()
 {
-    LinearRing *ret = getRingInternal();
+    LinearRing* ret = getRingInternal();
     ring = nullptr;
     return ret;
 }
 
 /*private*/
 void
-EdgeRing::addEdge(const CoordinateSequence *coords, bool isForward,
-                  CoordinateSequence *coordList)
+EdgeRing::addEdge(const CoordinateSequence* coords, bool isForward,
+                  CoordinateSequence* coordList)
 {
-    const std::size_t npts=coords->getSize();
-    if (isForward)
-    {
-        for (std::size_t i = 0; i < npts; ++i)
-        {
+    const std::size_t npts = coords->getSize();
+    if(isForward) {
+        for(std::size_t i = 0; i < npts; ++i) {
             coordList->add(coords->getAt(i), false);
         }
     }
-    else
-    {
-        for (std::size_t i = npts; i > 0; --i)
-        {
-            coordList->add(coords->getAt(i-1), false);
+    else {
+        for(std::size_t i = npts; i > 0; --i) {
+            coordList->add(coords->getAt(i - 1), false);
         }
     }
 }
diff --git a/src/operation/polygonize/PolygonizeDirectedEdge.cpp b/src/operation/polygonize/PolygonizeDirectedEdge.cpp
index dbd5f52..bfc2d78 100644
--- a/src/operation/polygonize/PolygonizeDirectedEdge.cpp
+++ b/src/operation/polygonize/PolygonizeDirectedEdge.cpp
@@ -38,16 +38,16 @@ namespace polygonize { // geos.operation.polygonize
  *        whether this DirectedEdge's direction is the same as or
  *        opposite to that of the parent Edge (if any)
  */
-PolygonizeDirectedEdge::PolygonizeDirectedEdge(Node *newFrom,
-		Node *newTo, const Coordinate& newDirectionPt,
-		bool nEdgeDirection)
-	:
-	DirectedEdge(newFrom, newTo,
-		newDirectionPt, nEdgeDirection)
+PolygonizeDirectedEdge::PolygonizeDirectedEdge(Node* newFrom,
+        Node* newTo, const Coordinate& newDirectionPt,
+        bool nEdgeDirection)
+    :
+    DirectedEdge(newFrom, newTo,
+                 newDirectionPt, nEdgeDirection)
 {
-	edgeRing=nullptr;
-	next=nullptr;
-	label=-1;
+    edgeRing = nullptr;
+    next = nullptr;
+    label = -1;
 }
 
 /*
@@ -56,24 +56,26 @@ PolygonizeDirectedEdge::PolygonizeDirectedEdge(Node *newFrom,
 long
 PolygonizeDirectedEdge::getLabel() const
 {
-	return label;
+    return label;
 }
 
 /*
  * Attaches an identifier to this directed edge.
  */
-void PolygonizeDirectedEdge::setLabel(long newLabel) {
-	label=newLabel;
+void
+PolygonizeDirectedEdge::setLabel(long newLabel)
+{
+    label = newLabel;
 }
 
 /*
  * Returns the next directed edge in the EdgeRing that this directed
  * edge is a member of.
  */
-PolygonizeDirectedEdge *
+PolygonizeDirectedEdge*
 PolygonizeDirectedEdge::getNext() const
 {
-	return next;
+    return next;
 }
 
 /*
@@ -81,9 +83,9 @@ PolygonizeDirectedEdge::getNext() const
  * edge is a member of.
  */
 void
-PolygonizeDirectedEdge::setNext(PolygonizeDirectedEdge *newNext)
+PolygonizeDirectedEdge::setNext(PolygonizeDirectedEdge* newNext)
 {
-	next=newNext;
+    next = newNext;
 }
 
 /*
@@ -94,7 +96,7 @@ PolygonizeDirectedEdge::setNext(PolygonizeDirectedEdge *newNext)
 bool
 PolygonizeDirectedEdge::isInRing() const
 {
-	return edgeRing!=nullptr;
+    return edgeRing != nullptr;
 }
 
 /*
@@ -102,9 +104,9 @@ PolygonizeDirectedEdge::isInRing() const
  * a member of.
  */
 void
-PolygonizeDirectedEdge::setRing(EdgeRing *newEdgeRing)
+PolygonizeDirectedEdge::setRing(EdgeRing* newEdgeRing)
 {
-	edgeRing=newEdgeRing;
+    edgeRing = newEdgeRing;
 }
 
 } // namespace geos.operation.polygonize
diff --git a/src/operation/polygonize/PolygonizeEdge.cpp b/src/operation/polygonize/PolygonizeEdge.cpp
index fd20415..a224ec2 100644
--- a/src/operation/polygonize/PolygonizeEdge.cpp
+++ b/src/operation/polygonize/PolygonizeEdge.cpp
@@ -26,13 +26,15 @@ namespace geos {
 namespace operation { // geos.operation
 namespace polygonize { // geos.operation.polygonize
 
-PolygonizeEdge::PolygonizeEdge(const LineString *newLine) {
-	line=newLine;
+PolygonizeEdge::PolygonizeEdge(const LineString* newLine)
+{
+    line = newLine;
 }
 
-const LineString *
-PolygonizeEdge::getLine() {
-	return line;
+const LineString*
+PolygonizeEdge::getLine()
+{
+    return line;
 }
 
 } // namespace geos.operation.polygonize
diff --git a/src/operation/polygonize/PolygonizeGraph.cpp b/src/operation/polygonize/PolygonizeGraph.cpp
index ea305b3..63df2d9 100644
--- a/src/operation/polygonize/PolygonizeGraph.cpp
+++ b/src/operation/polygonize/PolygonizeGraph.cpp
@@ -43,51 +43,55 @@ namespace operation { // geos.operation
 namespace polygonize { // geos.operation.polygonize
 
 int
-PolygonizeGraph::getDegreeNonDeleted(Node *node)
+PolygonizeGraph::getDegreeNonDeleted(Node* node)
 {
-	std::vector<DirectedEdge*> &edges=node->getOutEdges()->getEdges();
-	int degree=0;
-	for(unsigned int i=0; i<edges.size(); ++i) {
-		PolygonizeDirectedEdge *de=(PolygonizeDirectedEdge*)edges[i];
-		if (!de->isMarked()) ++degree;
-	}
-	return degree;
+    std::vector<DirectedEdge*>& edges = node->getOutEdges()->getEdges();
+    int degree = 0;
+    for(unsigned int i = 0; i < edges.size(); ++i) {
+        PolygonizeDirectedEdge* de = (PolygonizeDirectedEdge*)edges[i];
+        if(!de->isMarked()) {
+            ++degree;
+        }
+    }
+    return degree;
 }
 
 int
-PolygonizeGraph::getDegree(Node *node, long label)
+PolygonizeGraph::getDegree(Node* node, long label)
 {
-	std::vector<DirectedEdge*> &edges=node->getOutEdges()->getEdges();
-	int degree=0;
-	for(unsigned int i=0; i<edges.size(); ++i)
-	{
-		PolygonizeDirectedEdge *de=(PolygonizeDirectedEdge*)edges[i];
-		if (de->getLabel()==label) ++degree;
-	}
-	return degree;
+    std::vector<DirectedEdge*>& edges = node->getOutEdges()->getEdges();
+    int degree = 0;
+    for(unsigned int i = 0; i < edges.size(); ++i) {
+        PolygonizeDirectedEdge* de = (PolygonizeDirectedEdge*)edges[i];
+        if(de->getLabel() == label) {
+            ++degree;
+        }
+    }
+    return degree;
 }
 
 /**
  * Deletes all edges at a node
  */
 void
-PolygonizeGraph::deleteAllEdges(Node *node)
+PolygonizeGraph::deleteAllEdges(Node* node)
 {
-	std::vector<DirectedEdge*> &edges=node->getOutEdges()->getEdges();
-	for(unsigned int i=0; i<edges.size(); ++i) {
-		PolygonizeDirectedEdge *de=(PolygonizeDirectedEdge*)edges[i];
-		de->setMarked(true);
-		PolygonizeDirectedEdge *sym=(PolygonizeDirectedEdge*) de->getSym();
-		if (sym!=nullptr)
-			sym->setMarked(true);
-	}
+    std::vector<DirectedEdge*>& edges = node->getOutEdges()->getEdges();
+    for(unsigned int i = 0; i < edges.size(); ++i) {
+        PolygonizeDirectedEdge* de = (PolygonizeDirectedEdge*)edges[i];
+        de->setMarked(true);
+        PolygonizeDirectedEdge* sym = (PolygonizeDirectedEdge*) de->getSym();
+        if(sym != nullptr) {
+            sym->setMarked(true);
+        }
+    }
 }
 
 /*
  * Create a new polygonization graph.
  */
-PolygonizeGraph::PolygonizeGraph(const GeometryFactory *newFactory):
-	factory(newFactory)
+PolygonizeGraph::PolygonizeGraph(const GeometryFactory* newFactory):
+    factory(newFactory)
 {
 }
 
@@ -96,16 +100,22 @@ PolygonizeGraph::PolygonizeGraph(const GeometryFactory *newFactory):
  */
 PolygonizeGraph::~PolygonizeGraph()
 {
-	unsigned int i;
-	for (i=0; i<newEdges.size(); i++)
-		delete newEdges[i];
-	for (i=0; i<newDirEdges.size(); i++)
-		delete newDirEdges[i];
-	for (i=0; i<newNodes.size(); i++)
-		delete newNodes[i];
-	for (i=0; i<newEdgeRings.size(); i++)
-		delete newEdgeRings[i];
-	for (i=0; i<newCoords.size(); i++) delete newCoords[i];
+    unsigned int i;
+    for(i = 0; i < newEdges.size(); i++) {
+        delete newEdges[i];
+    }
+    for(i = 0; i < newDirEdges.size(); i++) {
+        delete newDirEdges[i];
+    }
+    for(i = 0; i < newNodes.size(); i++) {
+        delete newNodes[i];
+    }
+    for(i = 0; i < newEdgeRings.size(); i++) {
+        delete newEdgeRings[i];
+    }
+    for(i = 0; i < newCoords.size(); i++) {
+        delete newCoords[i];
+    }
 }
 
 /*
@@ -113,253 +123,262 @@ PolygonizeGraph::~PolygonizeGraph()
  * @param line the line to add
  */
 void
-PolygonizeGraph::addEdge(const LineString *line)
+PolygonizeGraph::addEdge(const LineString* line)
 {
-	if (line->isEmpty()) return;
-
-	CoordinateSequence *linePts=CoordinateSequence::removeRepeatedPoints(line->getCoordinatesRO());
-
-	/*
-	 * This would catch invalid linestrings
-	 * (containing duplicated points only)
-	 */
-	if ( linePts->getSize() < 2 )
-	{
-		delete linePts;
-		return;
-	}
-
-	const Coordinate& startPt=linePts->getAt(0);
-	const Coordinate& endPt=linePts->getAt(linePts->getSize()-1);
-	Node *nStart=getNode(startPt);
-	Node *nEnd=getNode(endPt);
-	DirectedEdge *de0=new PolygonizeDirectedEdge(nStart, nEnd, linePts->getAt(1), true);
-	newDirEdges.push_back(de0);
-	DirectedEdge *de1=new PolygonizeDirectedEdge(nEnd, nStart,
-			linePts->getAt(linePts->getSize()-2), false);
-	newDirEdges.push_back(de1);
-	Edge *edge=new PolygonizeEdge(line);
-	newEdges.push_back(edge);
-	edge->setDirectedEdges(de0, de1);
-	add(edge);
-
-	newCoords.push_back(linePts);
+    if(line->isEmpty()) {
+        return;
+    }
+
+    CoordinateSequence* linePts = CoordinateSequence::removeRepeatedPoints(line->getCoordinatesRO());
+
+    /*
+     * This would catch invalid linestrings
+     * (containing duplicated points only)
+     */
+    if(linePts->getSize() < 2) {
+        delete linePts;
+        return;
+    }
+
+    const Coordinate& startPt = linePts->getAt(0);
+    const Coordinate& endPt = linePts->getAt(linePts->getSize() - 1);
+    Node* nStart = getNode(startPt);
+    Node* nEnd = getNode(endPt);
+    DirectedEdge* de0 = new PolygonizeDirectedEdge(nStart, nEnd, linePts->getAt(1), true);
+    newDirEdges.push_back(de0);
+    DirectedEdge* de1 = new PolygonizeDirectedEdge(nEnd, nStart,
+            linePts->getAt(linePts->getSize() - 2), false);
+    newDirEdges.push_back(de1);
+    Edge* edge = new PolygonizeEdge(line);
+    newEdges.push_back(edge);
+    edge->setDirectedEdges(de0, de1);
+    add(edge);
+
+    newCoords.push_back(linePts);
 }
 
-Node *
+Node*
 PolygonizeGraph::getNode(const Coordinate& pt)
 {
-	Node *node=findNode(pt);
-	if (node==nullptr) {
-		node=new Node(pt);
-		newNodes.push_back(node);
-		// ensure node is only added once to graph
-		add(node);
-	}
-	return node;
+    Node* node = findNode(pt);
+    if(node == nullptr) {
+        node = new Node(pt);
+        newNodes.push_back(node);
+        // ensure node is only added once to graph
+        add(node);
+    }
+    return node;
 }
 
 void
 PolygonizeGraph::computeNextCWEdges()
 {
-	typedef std::vector<Node*> Nodes;
-	Nodes pns; getNodes(pns);
-	// set the next pointers for the edges around each node
-	for(Nodes::size_type i=0, in=pns.size(); i<in; ++i) {
-		Node *node=pns[i];
-		computeNextCWEdges(node);
-	}
+    typedef std::vector<Node*> Nodes;
+    Nodes pns;
+    getNodes(pns);
+    // set the next pointers for the edges around each node
+    for(Nodes::size_type i = 0, in = pns.size(); i < in; ++i) {
+        Node* node = pns[i];
+        computeNextCWEdges(node);
+    }
 }
 
 /* private */
 void
 PolygonizeGraph::convertMaximalToMinimalEdgeRings(
-		std::vector<PolygonizeDirectedEdge*> &ringEdges)
+    std::vector<PolygonizeDirectedEdge*>& ringEdges)
 {
-	typedef std::vector<Node*> IntersectionNodes;
-	typedef std::vector<PolygonizeDirectedEdge*> RingEdges;
-
-	IntersectionNodes intNodes;
-	for(RingEdges::size_type i=0, in=ringEdges.size();
-			i<in; ++i)
-	{
-		PolygonizeDirectedEdge *de = ringEdges[i];
-		long p_label=de->getLabel();
-		findIntersectionNodes(de, p_label, intNodes);
-
-		// set the next pointers for the edges around each node
-		for(IntersectionNodes::size_type j=0, jn=intNodes.size();
-				j<jn; ++j)
-		{
-			Node *node=intNodes[j];
-			computeNextCCWEdges(node, p_label);
-		}
-
-		intNodes.clear();
-	}
+    typedef std::vector<Node*> IntersectionNodes;
+    typedef std::vector<PolygonizeDirectedEdge*> RingEdges;
+
+    IntersectionNodes intNodes;
+    for(RingEdges::size_type i = 0, in = ringEdges.size();
+            i < in; ++i) {
+        PolygonizeDirectedEdge* de = ringEdges[i];
+        long p_label = de->getLabel();
+        findIntersectionNodes(de, p_label, intNodes);
+
+        // set the next pointers for the edges around each node
+        for(IntersectionNodes::size_type j = 0, jn = intNodes.size();
+                j < jn; ++j) {
+            Node* node = intNodes[j];
+            computeNextCCWEdges(node, p_label);
+        }
+
+        intNodes.clear();
+    }
 }
 
 /* private static */
 void
-PolygonizeGraph::findIntersectionNodes(PolygonizeDirectedEdge *startDE,
-		long label, std::vector<Node*>& intNodes)
+PolygonizeGraph::findIntersectionNodes(PolygonizeDirectedEdge* startDE,
+                                       long label, std::vector<Node*>& intNodes)
 {
-	PolygonizeDirectedEdge *de=startDE;
-	do {
-		Node *node=de->getFromNode();
-		if (getDegree(node, label) > 1) {
-			intNodes.push_back(node);
-		}
-		de=de->getNext();
-		assert(de!=nullptr); // found NULL DE in ring
-		assert(de==startDE || !de->isInRing()); // found DE already in ring
-	} while (de!=startDE);
+    PolygonizeDirectedEdge* de = startDE;
+    do {
+        Node* node = de->getFromNode();
+        if(getDegree(node, label) > 1) {
+            intNodes.push_back(node);
+        }
+        de = de->getNext();
+        assert(de != nullptr); // found NULL DE in ring
+        assert(de == startDE || !de->isInRing()); // found DE already in ring
+    }
+    while(de != startDE);
 }
 
 /* public */
 void
 PolygonizeGraph::getEdgeRings(std::vector<EdgeRing*>& edgeRingList)
 {
-	// maybe could optimize this, since most of these pointers should
-	// be set correctly already
-	// by deleteCutEdges()
-	computeNextCWEdges();
-
-	// clear labels of all edges in graph
-	label(dirEdges, -1);
-	std::vector<PolygonizeDirectedEdge*> maximalRings;
-	findLabeledEdgeRings(dirEdges, maximalRings);
-	convertMaximalToMinimalEdgeRings(maximalRings);
-	maximalRings.clear(); // not needed anymore
-
-	// find all edgerings
-	for(unsigned int i=0; i<dirEdges.size(); ++i)
-	{
-		PolygonizeDirectedEdge *de=(PolygonizeDirectedEdge*)dirEdges[i];
-		if (de->isMarked()) continue;
-		if (de->isInRing()) continue;
-		EdgeRing *er=findEdgeRing(de);
-		edgeRingList.push_back(er);
-	}
+    // maybe could optimize this, since most of these pointers should
+    // be set correctly already
+    // by deleteCutEdges()
+    computeNextCWEdges();
+
+    // clear labels of all edges in graph
+    label(dirEdges, -1);
+    std::vector<PolygonizeDirectedEdge*> maximalRings;
+    findLabeledEdgeRings(dirEdges, maximalRings);
+    convertMaximalToMinimalEdgeRings(maximalRings);
+    maximalRings.clear(); // not needed anymore
+
+    // find all edgerings
+    for(unsigned int i = 0; i < dirEdges.size(); ++i) {
+        PolygonizeDirectedEdge* de = (PolygonizeDirectedEdge*)dirEdges[i];
+        if(de->isMarked()) {
+            continue;
+        }
+        if(de->isInRing()) {
+            continue;
+        }
+        EdgeRing* er = findEdgeRing(de);
+        edgeRingList.push_back(er);
+    }
 }
 
 /* static private */
 void
-PolygonizeGraph::findLabeledEdgeRings(std::vector<DirectedEdge*> &dirEdges,
-		std::vector<PolygonizeDirectedEdge*> &edgeRingStarts)
+PolygonizeGraph::findLabeledEdgeRings(std::vector<DirectedEdge*>& dirEdges,
+                                      std::vector<PolygonizeDirectedEdge*>& edgeRingStarts)
 {
-	typedef std::vector<DirectedEdge*> Edges;
+    typedef std::vector<DirectedEdge*> Edges;
 
-	Edges edges;
+    Edges edges;
 
-	// label the edge rings formed
-	long currLabel=1;
-	for(Edges::size_type i=0, n=dirEdges.size(); i<n; ++i)
-	{
+    // label the edge rings formed
+    long currLabel = 1;
+    for(Edges::size_type i = 0, n = dirEdges.size(); i < n; ++i) {
 #ifdef GEOS_CAST_PARANOIA
-		assert(dynamic_cast<PolygonizeDirectedEdge*>(dirEdges[i]));
+        assert(dynamic_cast<PolygonizeDirectedEdge*>(dirEdges[i]));
 #endif
-		PolygonizeDirectedEdge *de =
-			static_cast<PolygonizeDirectedEdge*>(dirEdges[i]);
-
-		if (de->isMarked()) continue;
-		if (de->getLabel() >= 0) continue;
-		edgeRingStarts.push_back(de);
-
-		findDirEdgesInRing(de, edges);
-		label(edges, currLabel);
-		edges.clear();
-
-		++currLabel;
-	}
+        PolygonizeDirectedEdge* de =
+            static_cast<PolygonizeDirectedEdge*>(dirEdges[i]);
+
+        if(de->isMarked()) {
+            continue;
+        }
+        if(de->getLabel() >= 0) {
+            continue;
+        }
+        edgeRingStarts.push_back(de);
+
+        findDirEdgesInRing(de, edges);
+        label(edges, currLabel);
+        edges.clear();
+
+        ++currLabel;
+    }
 }
 
 /* public */
 void
-PolygonizeGraph::deleteCutEdges(std::vector<const LineString*> &cutLines)
+PolygonizeGraph::deleteCutEdges(std::vector<const LineString*>& cutLines)
 {
-	computeNextCWEdges();
-
-	typedef std::vector<PolygonizeDirectedEdge*> DirEdges;
-
-	// label the current set of edgerings
-	DirEdges junk;
-	findLabeledEdgeRings(dirEdges, junk);
-	junk.clear(); // not needed anymore
-
-	/*
-	 * Cut Edges are edges where both dirEdges have the same label.
-	 * Delete them, and record them
-	 */
-	for (DirEdges::size_type i=0, in=dirEdges.size(); i<in; ++i)
-	{
-		DirectedEdge *de_ = dirEdges[i];
+    computeNextCWEdges();
+
+    typedef std::vector<PolygonizeDirectedEdge*> DirEdges;
+
+    // label the current set of edgerings
+    DirEdges junk;
+    findLabeledEdgeRings(dirEdges, junk);
+    junk.clear(); // not needed anymore
+
+    /*
+     * Cut Edges are edges where both dirEdges have the same label.
+     * Delete them, and record them
+     */
+    for(DirEdges::size_type i = 0, in = dirEdges.size(); i < in; ++i) {
+        DirectedEdge* de_ = dirEdges[i];
 #ifdef GEOS_CAST_PARANOIA
-		assert(dynamic_cast<PolygonizeDirectedEdge*>(de_));
+        assert(dynamic_cast<PolygonizeDirectedEdge*>(de_));
 #endif
-		PolygonizeDirectedEdge *de =
-			static_cast<PolygonizeDirectedEdge*>(de_);
+        PolygonizeDirectedEdge* de =
+            static_cast<PolygonizeDirectedEdge*>(de_);
 
-		if (de->isMarked()) continue;
+        if(de->isMarked()) {
+            continue;
+        }
 
-		DirectedEdge *sym_ = de->getSym();
+        DirectedEdge* sym_ = de->getSym();
 #ifdef GEOS_CAST_PARANOIA
-		assert(dynamic_cast<PolygonizeDirectedEdge*>(sym_));
+        assert(dynamic_cast<PolygonizeDirectedEdge*>(sym_));
 #endif
-		PolygonizeDirectedEdge *sym =
-			static_cast<PolygonizeDirectedEdge*>(sym_);
+        PolygonizeDirectedEdge* sym =
+            static_cast<PolygonizeDirectedEdge*>(sym_);
 
-		if (de->getLabel()==sym->getLabel())
-		{
-			de->setMarked(true);
-			sym->setMarked(true);
+        if(de->getLabel() == sym->getLabel()) {
+            de->setMarked(true);
+            sym->setMarked(true);
 
-			// save the line as a cut edge
-			Edge *e_ = de->getEdge();
+            // save the line as a cut edge
+            Edge* e_ = de->getEdge();
 #ifdef GEOS_CAST_PARANOIA
-			assert(dynamic_cast<PolygonizeEdge*>(e_));
+            assert(dynamic_cast<PolygonizeEdge*>(e_));
 #endif
-			PolygonizeEdge *e = static_cast<PolygonizeEdge*>(e_);
+            PolygonizeEdge* e = static_cast<PolygonizeEdge*>(e_);
 
-			cutLines.push_back(e->getLine());
-		}
-	}
+            cutLines.push_back(e->getLine());
+        }
+    }
 }
 
 void
-PolygonizeGraph::label(std::vector<DirectedEdge*> &dirEdges, long label)
+PolygonizeGraph::label(std::vector<DirectedEdge*>& dirEdges, long label)
 {
-	for(unsigned int i=0; i<dirEdges.size(); ++i)
-	{
-		PolygonizeDirectedEdge *de=(PolygonizeDirectedEdge*)dirEdges[i];
-		de->setLabel(label);
-	}
+    for(unsigned int i = 0; i < dirEdges.size(); ++i) {
+        PolygonizeDirectedEdge* de = (PolygonizeDirectedEdge*)dirEdges[i];
+        de->setLabel(label);
+    }
 }
 
 void
-PolygonizeGraph::computeNextCWEdges(Node *node)
+PolygonizeGraph::computeNextCWEdges(Node* node)
 {
-	DirectedEdgeStar *deStar=node->getOutEdges();
-	PolygonizeDirectedEdge *startDE=nullptr;
-	PolygonizeDirectedEdge *prevDE=nullptr;
-
-	// the edges are stored in CCW order around the star
-	std::vector<DirectedEdge*> &pde=deStar->getEdges();
-	for(unsigned int i=0; i<pde.size(); ++i) {
-		PolygonizeDirectedEdge *outDE=(PolygonizeDirectedEdge*)pde[i];
-		if (outDE->isMarked()) continue;
-		if (startDE==nullptr)
-			startDE=outDE;
-		if (prevDE!=nullptr) {
-			PolygonizeDirectedEdge *sym=(PolygonizeDirectedEdge*) prevDE->getSym();
-			sym->setNext(outDE);
-		}
-		prevDE=outDE;
-	}
-	if (prevDE!=nullptr) {
-		PolygonizeDirectedEdge *sym=(PolygonizeDirectedEdge*) prevDE->getSym();
-		sym->setNext(startDE);
-	}
+    DirectedEdgeStar* deStar = node->getOutEdges();
+    PolygonizeDirectedEdge* startDE = nullptr;
+    PolygonizeDirectedEdge* prevDE = nullptr;
+
+    // the edges are stored in CCW order around the star
+    std::vector<DirectedEdge*>& pde = deStar->getEdges();
+    for(unsigned int i = 0; i < pde.size(); ++i) {
+        PolygonizeDirectedEdge* outDE = (PolygonizeDirectedEdge*)pde[i];
+        if(outDE->isMarked()) {
+            continue;
+        }
+        if(startDE == nullptr) {
+            startDE = outDE;
+        }
+        if(prevDE != nullptr) {
+            PolygonizeDirectedEdge* sym = (PolygonizeDirectedEdge*) prevDE->getSym();
+            sym->setNext(outDE);
+        }
+        prevDE = outDE;
+    }
+    if(prevDE != nullptr) {
+        PolygonizeDirectedEdge* sym = (PolygonizeDirectedEdge*) prevDE->getSym();
+        sym->setNext(startDE);
+    }
 }
 
 /**
@@ -369,111 +388,121 @@ PolygonizeGraph::computeNextCWEdges(Node *node)
  * minimal edgerings
  */
 void
-PolygonizeGraph::computeNextCCWEdges(Node *node, long label)
+PolygonizeGraph::computeNextCCWEdges(Node* node, long label)
 {
-	DirectedEdgeStar *deStar=node->getOutEdges();
-	PolygonizeDirectedEdge *firstOutDE=nullptr;
-	PolygonizeDirectedEdge *prevInDE=nullptr;
-
-	// the edges are stored in CCW order around the star
-	std::vector<DirectedEdge*> &edges=deStar->getEdges();
-
-	/*
-	 * Must use a SIGNED int here to allow for beak condition
-	 * to be true.
-	 */
-	for(auto i = edges.size(); i > 0; --i)
-	{
-		PolygonizeDirectedEdge *de=(PolygonizeDirectedEdge*)edges[i - 1];
-		PolygonizeDirectedEdge *sym=(PolygonizeDirectedEdge*) de->getSym();
-		PolygonizeDirectedEdge *outDE=nullptr;
-		if (de->getLabel()==label) outDE=de;
-		PolygonizeDirectedEdge *inDE=nullptr;
-		if (sym->getLabel()==label) inDE= sym;
-		if (outDE==nullptr && inDE==nullptr) continue; // this edge is not in edgering
-		if (inDE != nullptr) {
-			prevInDE=inDE;
-		}
-		if (outDE != nullptr) {
-			if (prevInDE != nullptr) {
-				prevInDE->setNext(outDE);
-				prevInDE=nullptr;
-			}
-			if (firstOutDE==nullptr)
-				firstOutDE=outDE;
-		}
-	}
-	if (prevInDE != nullptr) {
-		assert(firstOutDE != nullptr);
-		prevInDE->setNext(firstOutDE);
-	}
+    DirectedEdgeStar* deStar = node->getOutEdges();
+    PolygonizeDirectedEdge* firstOutDE = nullptr;
+    PolygonizeDirectedEdge* prevInDE = nullptr;
+
+    // the edges are stored in CCW order around the star
+    std::vector<DirectedEdge*>& edges = deStar->getEdges();
+
+    /*
+     * Must use a SIGNED int here to allow for beak condition
+     * to be true.
+     */
+    for(auto i = edges.size(); i > 0; --i) {
+        PolygonizeDirectedEdge* de = (PolygonizeDirectedEdge*)edges[i - 1];
+        PolygonizeDirectedEdge* sym = (PolygonizeDirectedEdge*) de->getSym();
+        PolygonizeDirectedEdge* outDE = nullptr;
+        if(de->getLabel() == label) {
+            outDE = de;
+        }
+        PolygonizeDirectedEdge* inDE = nullptr;
+        if(sym->getLabel() == label) {
+            inDE = sym;
+        }
+        if(outDE == nullptr && inDE == nullptr) {
+            continue;    // this edge is not in edgering
+        }
+        if(inDE != nullptr) {
+            prevInDE = inDE;
+        }
+        if(outDE != nullptr) {
+            if(prevInDE != nullptr) {
+                prevInDE->setNext(outDE);
+                prevInDE = nullptr;
+            }
+            if(firstOutDE == nullptr) {
+                firstOutDE = outDE;
+            }
+        }
+    }
+    if(prevInDE != nullptr) {
+        assert(firstOutDE != nullptr);
+        prevInDE->setNext(firstOutDE);
+    }
 }
 
 /* static private */
 void
-PolygonizeGraph::findDirEdgesInRing(PolygonizeDirectedEdge *startDE,
-		std::vector<DirectedEdge*>& edges)
+PolygonizeGraph::findDirEdgesInRing(PolygonizeDirectedEdge* startDE,
+                                    std::vector<DirectedEdge*>& edges)
 {
-	PolygonizeDirectedEdge *de=startDE;
-	do {
-		edges.push_back(de);
-		de=de->getNext();
-		assert(de != nullptr); // found NULL DE in ring
-		assert(de==startDE || !de->isInRing()); // found DE already in ring
-	} while (de != startDE);
+    PolygonizeDirectedEdge* de = startDE;
+    do {
+        edges.push_back(de);
+        de = de->getNext();
+        assert(de != nullptr); // found NULL DE in ring
+        assert(de == startDE || !de->isInRing()); // found DE already in ring
+    }
+    while(de != startDE);
 }
 
-EdgeRing *
-PolygonizeGraph::findEdgeRing(PolygonizeDirectedEdge *startDE)
+EdgeRing*
+PolygonizeGraph::findEdgeRing(PolygonizeDirectedEdge* startDE)
 {
-	PolygonizeDirectedEdge *de=startDE;
-	EdgeRing *er=new EdgeRing(factory);
-	// Now, when will we delete those EdgeRings ?
-	newEdgeRings.push_back(er);
-	do {
-		er->add(de);
-		de->setRing(er);
-		de=de->getNext();
-		assert(de != nullptr); // found NULL DE in ring
-		assert(de==startDE || ! de->isInRing()); // found DE already in ring
-	} while (de != startDE);
-	return er;
+    PolygonizeDirectedEdge* de = startDE;
+    EdgeRing* er = new EdgeRing(factory);
+    // Now, when will we delete those EdgeRings ?
+    newEdgeRings.push_back(er);
+    do {
+        er->add(de);
+        de->setRing(er);
+        de = de->getNext();
+        assert(de != nullptr); // found NULL DE in ring
+        assert(de == startDE || ! de->isInRing()); // found DE already in ring
+    }
+    while(de != startDE);
+    return er;
 }
 
 /* public */
 void
 PolygonizeGraph::deleteDangles(std::vector<const LineString*>& dangleLines)
 {
-	std::vector<Node*> nodeStack;
-	findNodesOfDegree(1, nodeStack);
-
-	std::set<const LineString*> uniqueDangles;
-
-	while (!nodeStack.empty()) {
-		Node *node=nodeStack.back();
-		nodeStack.pop_back();
-		deleteAllEdges(node);
-		std::vector<DirectedEdge*> &nodeOutEdges=node->getOutEdges()->getEdges();
-		for(unsigned int j=0; j<nodeOutEdges.size(); ++j)
-		{
-			PolygonizeDirectedEdge *de=(PolygonizeDirectedEdge*)nodeOutEdges[j];
-			// delete this edge and its sym
-			de->setMarked(true);
-			PolygonizeDirectedEdge *sym=(PolygonizeDirectedEdge*) de->getSym();
-			if (sym != nullptr)
-				sym->setMarked(true);
-			// save the line as a dangle
-			PolygonizeEdge *e=(PolygonizeEdge*) de->getEdge();
-			const LineString* ls = e->getLine();
-			if ( uniqueDangles.insert(ls).second )
-				dangleLines.push_back(ls);
-			Node *toNode=de->getToNode();
-			// add the toNode to the list to be processed,
-			// if it is now a dangle
-			if (getDegreeNonDeleted(toNode)==1)
-				nodeStack.push_back(toNode);
-		}
-	}
+    std::vector<Node*> nodeStack;
+    findNodesOfDegree(1, nodeStack);
+
+    std::set<const LineString*> uniqueDangles;
+
+    while(!nodeStack.empty()) {
+        Node* node = nodeStack.back();
+        nodeStack.pop_back();
+        deleteAllEdges(node);
+        std::vector<DirectedEdge*>& nodeOutEdges = node->getOutEdges()->getEdges();
+        for(unsigned int j = 0; j < nodeOutEdges.size(); ++j) {
+            PolygonizeDirectedEdge* de = (PolygonizeDirectedEdge*)nodeOutEdges[j];
+            // delete this edge and its sym
+            de->setMarked(true);
+            PolygonizeDirectedEdge* sym = (PolygonizeDirectedEdge*) de->getSym();
+            if(sym != nullptr) {
+                sym->setMarked(true);
+            }
+            // save the line as a dangle
+            PolygonizeEdge* e = (PolygonizeEdge*) de->getEdge();
+            const LineString* ls = e->getLine();
+            if(uniqueDangles.insert(ls).second) {
+                dangleLines.push_back(ls);
+            }
+            Node* toNode = de->getToNode();
+            // add the toNode to the list to be processed,
+            // if it is now a dangle
+            if(getDegreeNonDeleted(toNode) == 1) {
+                nodeStack.push_back(toNode);
+            }
+        }
+    }
 
 }
 
diff --git a/src/operation/polygonize/Polygonizer.cpp b/src/operation/polygonize/Polygonizer.cpp
index ac91286..1b84e57 100644
--- a/src/operation/polygonize/Polygonizer.cpp
+++ b/src/operation/polygonize/Polygonizer.cpp
@@ -43,16 +43,18 @@ namespace geos {
 namespace operation { // geos.operation
 namespace polygonize { // geos.operation.polygonize
 
-Polygonizer::LineStringAdder::LineStringAdder(Polygonizer *p):
-	pol(p)
+Polygonizer::LineStringAdder::LineStringAdder(Polygonizer* p):
+    pol(p)
 {
 }
 
 void
-Polygonizer::LineStringAdder::filter_ro(const Geometry *g)
+Polygonizer::LineStringAdder::filter_ro(const Geometry* g)
 {
-	const LineString *ls = dynamic_cast<const LineString *>(g);
-	if ( ls ) pol->add(ls);
+    const LineString* ls = dynamic_cast<const LineString*>(g);
+    if(ls) {
+        pol->add(ls);
+    }
 }
 
 
@@ -61,28 +63,31 @@ Polygonizer::LineStringAdder::filter_ro(const Geometry *g)
  * as the input Geometry
  */
 Polygonizer::Polygonizer():
-	lineStringAdder(this),
-	graph(nullptr),
-	dangles(),
-	cutEdges(),
-	invalidRingLines(),
-	holeList(),
-	shellList(),
-	polyList(nullptr)
+    lineStringAdder(this),
+    graph(nullptr),
+    dangles(),
+    cutEdges(),
+    invalidRingLines(),
+    holeList(),
+    shellList(),
+    polyList(nullptr)
 {
 }
 
 Polygonizer::~Polygonizer()
 {
-	delete graph;
-
-	for (auto &r : invalidRingLines) delete r;
-
-	if ( polyList )
-	{
-		for (auto &p : (*polyList)) delete p;
-		delete polyList;
-	}
+    delete graph;
+
+    for(auto& r : invalidRingLines) {
+        delete r;
+    }
+
+    if(polyList) {
+        for(auto& p : (*polyList)) {
+            delete p;
+        }
+        delete polyList;
+    }
 }
 
 /*
@@ -94,9 +99,11 @@ Polygonizer::~Polygonizer()
  * @param geomList a list of {@link Geometry}s with linework to be polygonized
  */
 void
-Polygonizer::add(vector<Geometry*> *geomList)
+Polygonizer::add(vector<Geometry*>* geomList)
 {
-	for (auto &g : (*geomList)) add(g);
+    for(auto& g : (*geomList)) {
+        add(g);
+    }
 }
 
 /*
@@ -108,9 +115,11 @@ Polygonizer::add(vector<Geometry*> *geomList)
  * @param geomList a list of {@link Geometry}s with linework to be polygonized
  */
 void
-Polygonizer::add(vector<const Geometry*> *geomList)
+Polygonizer::add(vector<const Geometry*>* geomList)
 {
-	for (auto &g : (*geomList)) add(g);
+    for(auto& g : (*geomList)) {
+        add(g);
+    }
 }
 
 /*
@@ -122,9 +131,9 @@ Polygonizer::add(vector<const Geometry*> *geomList)
  * @param g a Geometry with linework to be polygonized
  */
 void
-Polygonizer::add(Geometry *g)
+Polygonizer::add(Geometry* g)
 {
-	g->apply_ro(&lineStringAdder);
+    g->apply_ro(&lineStringAdder);
 }
 
 /*
@@ -136,9 +145,9 @@ Polygonizer::add(Geometry *g)
  * @param g a Geometry with linework to be polygonized
  */
 void
-Polygonizer::add(const Geometry *g)
+Polygonizer::add(const Geometry* g)
 {
-	g->apply_ro(&lineStringAdder);
+    g->apply_ro(&lineStringAdder);
 }
 
 /*
@@ -147,12 +156,13 @@ Polygonizer::add(const Geometry *g)
  * @param line the LineString to add
  */
 void
-Polygonizer::add(const LineString *line)
+Polygonizer::add(const LineString* line)
 {
-	// create a new graph using the factory from the input Geometry
-	if (graph==nullptr)
-		graph=new PolygonizeGraph(line->getFactory());
-	graph->addEdge(line);
+    // create a new graph using the factory from the input Geometry
+    if(graph == nullptr) {
+        graph = new PolygonizeGraph(line->getFactory());
+    }
+    graph->addEdge(line);
 }
 
 /*
@@ -162,136 +172,139 @@ Polygonizer::add(const LineString *line)
 vector<Polygon*>*
 Polygonizer::getPolygons()
 {
-	polygonize();
-	vector<Polygon *> *ret = polyList;
-	polyList = nullptr;
-	return ret;
+    polygonize();
+    vector<Polygon*>* ret = polyList;
+    polyList = nullptr;
+    return ret;
 }
 
 /* public */
 const vector<const LineString*>&
 Polygonizer::getDangles()
 {
-	polygonize();
-	return dangles;
+    polygonize();
+    return dangles;
 }
 
 /* public */
 const vector<const LineString*>&
 Polygonizer::getCutEdges()
 {
-	polygonize();
-	return cutEdges;
+    polygonize();
+    return cutEdges;
 }
 
 /* public */
 const vector<LineString*>&
 Polygonizer::getInvalidRingLines()
 {
-	polygonize();
-	return invalidRingLines;
+    polygonize();
+    return invalidRingLines;
 }
 
 /* public */
 void
 Polygonizer::polygonize()
 {
-	// check if already computed
-	if (polyList!=nullptr) return;
+    // check if already computed
+    if(polyList != nullptr) {
+        return;
+    }
 
-	polyList=new vector<Polygon*>();
+    polyList = new vector<Polygon*>();
 
-	// if no geometries were supplied it's possible graph could be null
-	if (graph==nullptr) return;
+    // if no geometries were supplied it's possible graph could be null
+    if(graph == nullptr) {
+        return;
+    }
 
-	graph->deleteDangles(dangles);
+    graph->deleteDangles(dangles);
 
-	graph->deleteCutEdges(cutEdges);
+    graph->deleteCutEdges(cutEdges);
 
-	vector<EdgeRing*> edgeRingList;
-	graph->getEdgeRings(edgeRingList);
+    vector<EdgeRing*> edgeRingList;
+    graph->getEdgeRings(edgeRingList);
 #if GEOS_DEBUG
-	cerr<<"Polygonizer::polygonize(): "<<edgeRingList.size()<<" edgeRings in graph"<<endl;
+    cerr << "Polygonizer::polygonize(): " << edgeRingList.size() << " edgeRings in graph" << endl;
 #endif
-	vector<EdgeRing*> validEdgeRingList;
-	invalidRingLines.clear(); /* what if it was populated already ? we should clean ! */
-	findValidRings(edgeRingList, validEdgeRingList, invalidRingLines);
+    vector<EdgeRing*> validEdgeRingList;
+    invalidRingLines.clear(); /* what if it was populated already ? we should clean ! */
+    findValidRings(edgeRingList, validEdgeRingList, invalidRingLines);
 #if GEOS_DEBUG
-	cerr<<"                           "<<validEdgeRingList.size()<<" valid"<<endl;
-	cerr<<"                           "<<invalidRingLines.size()<<" invalid"<<endl;
+    cerr << "                           " << validEdgeRingList.size() << " valid" << endl;
+    cerr << "                           " << invalidRingLines.size() << " invalid" << endl;
 #endif
 
-	findShellsAndHoles(validEdgeRingList);
+    findShellsAndHoles(validEdgeRingList);
 #if GEOS_DEBUG
-	cerr<<"                           "<<holeList.size()<<" holes"<<endl;
-	cerr<<"                           "<<shellList.size()<<" shells"<<endl;
+    cerr << "                           " << holeList.size() << " holes" << endl;
+    cerr << "                           " << shellList.size() << " shells" << endl;
 #endif
 
-	assignHolesToShells(holeList, shellList);
+    assignHolesToShells(holeList, shellList);
 
-	for (const auto &er : shellList)
-	{
-		polyList->push_back(er->getPolygon());
-	}
+    for(const auto& er : shellList) {
+        polyList->push_back(er->getPolygon());
+    }
 }
 
 /* private */
 void
 Polygonizer::findValidRings(const vector<EdgeRing*>& edgeRingList,
-	vector<EdgeRing*>& validEdgeRingList,
-	vector<LineString*>& invalidRingList)
+                            vector<EdgeRing*>& validEdgeRingList,
+                            vector<LineString*>& invalidRingList)
 {
-	for (const auto &er : edgeRingList)
-	{
-		if (er->isValid())
-		{
-			validEdgeRingList.push_back(er);
-		}
-		else
-		{
-			// NOTE: polygonize::EdgeRing::getLineString
-			// returned LineString ownership is transferred.
-			invalidRingList.push_back(er->getLineString());
-		}
-		GEOS_CHECK_FOR_INTERRUPTS();
-	}
+    for(const auto& er : edgeRingList) {
+        if(er->isValid()) {
+            validEdgeRingList.push_back(er);
+        }
+        else {
+            // NOTE: polygonize::EdgeRing::getLineString
+            // returned LineString ownership is transferred.
+            invalidRingList.push_back(er->getLineString());
+        }
+        GEOS_CHECK_FOR_INTERRUPTS();
+    }
 }
 
 /* private */
 void
 Polygonizer::findShellsAndHoles(const vector<EdgeRing*>& edgeRingList)
 {
-	holeList.clear();
-	shellList.clear();
-	for (const auto &er : edgeRingList) {
-		if (er->isHole())
-			holeList.push_back(er);
-		else
-			shellList.push_back(er);
-
-		GEOS_CHECK_FOR_INTERRUPTS();
-	}
+    holeList.clear();
+    shellList.clear();
+    for(const auto& er : edgeRingList) {
+        if(er->isHole()) {
+            holeList.push_back(er);
+        }
+        else {
+            shellList.push_back(er);
+        }
+
+        GEOS_CHECK_FOR_INTERRUPTS();
+    }
 }
 
 /* private */
 void
 Polygonizer::assignHolesToShells(const vector<EdgeRing*>& holeList, vector<EdgeRing*>& shellList)
 {
-	for (const auto &holeER : holeList) {
-		assignHoleToShell(holeER, shellList);
-		GEOS_CHECK_FOR_INTERRUPTS();
-	}
+    for(const auto& holeER : holeList) {
+        assignHoleToShell(holeER, shellList);
+        GEOS_CHECK_FOR_INTERRUPTS();
+    }
 }
 
 /* private */
 void
-Polygonizer::assignHoleToShell(EdgeRing *holeER,
-		vector<EdgeRing*>& shellList)
+Polygonizer::assignHoleToShell(EdgeRing* holeER,
+                               vector<EdgeRing*>& shellList)
 {
-	EdgeRing *shell = EdgeRing::findEdgeRingContaining(holeER, &shellList);
+    EdgeRing* shell = EdgeRing::findEdgeRingContaining(holeER, &shellList);
 
-	if (shell!=nullptr)
-		shell->addHole(holeER->getRingOwnership());
+    if(shell != nullptr) {
+        shell->addHole(holeER->getRingOwnership());
+    }
 }
 
 
diff --git a/src/operation/predicate/RectangleContains.cpp b/src/operation/predicate/RectangleContains.cpp
index fedc255..adb1c83 100644
--- a/src/operation/predicate/RectangleContains.cpp
+++ b/src/operation/predicate/RectangleContains.cpp
@@ -34,109 +34,115 @@ namespace predicate { // geos.operation.predicate
 bool
 RectangleContains::contains(const Geometry& geom)
 {
-	if ( ! rectEnv.contains(geom.getEnvelopeInternal()) )
-		return false;
+    if(! rectEnv.contains(geom.getEnvelopeInternal())) {
+        return false;
+    }
 
-	// check that geom is not contained entirely in the rectangle boundary
-	if (isContainedInBoundary(geom))
-		return false;
+    // check that geom is not contained entirely in the rectangle boundary
+    if(isContainedInBoundary(geom)) {
+        return false;
+    }
 
-	return true;
+    return true;
 }
 
 /*private*/
 bool
 RectangleContains::isContainedInBoundary(const Geometry& geom)
 {
-	// polygons can never be wholely contained in the boundary
-	if (dynamic_cast<const geom::Polygon *>(&geom)) return false;
-	if (const Point *p=dynamic_cast<const Point *>(&geom))
-		return isPointContainedInBoundary(*p);
-	if (const LineString *l=dynamic_cast<const LineString *>(&geom))
-		return isLineStringContainedInBoundary(*l);
-
-	for (size_t i = 0, n = geom.getNumGeometries(); i < n; ++i)
-	{
-		const Geometry &comp = *(geom.getGeometryN(i));
-		if ( !isContainedInBoundary(comp) )
-			return false;
-	}
-
-	return true;
+    // polygons can never be wholely contained in the boundary
+    if(dynamic_cast<const geom::Polygon*>(&geom)) {
+        return false;
+    }
+    if(const Point* p = dynamic_cast<const Point*>(&geom)) {
+        return isPointContainedInBoundary(*p);
+    }
+    if(const LineString* l = dynamic_cast<const LineString*>(&geom)) {
+        return isLineStringContainedInBoundary(*l);
+    }
+
+    for(size_t i = 0, n = geom.getNumGeometries(); i < n; ++i) {
+        const Geometry& comp = *(geom.getGeometryN(i));
+        if(!isContainedInBoundary(comp)) {
+            return false;
+        }
+    }
+
+    return true;
 }
 
 /*private*/
 bool
 RectangleContains::isPointContainedInBoundary(const Point& point)
 {
-	return isPointContainedInBoundary(*(point.getCoordinate()));
+    return isPointContainedInBoundary(*(point.getCoordinate()));
 }
 
 /*private*/
 bool
 RectangleContains::isPointContainedInBoundary(const Coordinate& pt)
 {
-	/**
-	 * contains = false iff the point is properly contained
-	 * in the rectangle.
-	 *
-	 * This code assumes that the point lies in the rectangle envelope
-	 */
-	return pt.x == rectEnv.getMinX()
-		|| pt.x == rectEnv.getMaxX()
-		|| pt.y == rectEnv.getMinY()
-		|| pt.y == rectEnv.getMaxY();
+    /**
+     * contains = false iff the point is properly contained
+     * in the rectangle.
+     *
+     * This code assumes that the point lies in the rectangle envelope
+     */
+    return pt.x == rectEnv.getMinX()
+           || pt.x == rectEnv.getMaxX()
+           || pt.y == rectEnv.getMinY()
+           || pt.y == rectEnv.getMaxY();
 }
 
 /*private*/
 bool
 RectangleContains::isLineStringContainedInBoundary(const LineString& line)
 {
-	const CoordinateSequence &seq = *(line.getCoordinatesRO());
-	for (size_t i = 0, n =seq.size() - 1; i < n; ++i) {
-		const Coordinate& p0=seq.getAt(i);
-		const Coordinate& p1=seq.getAt(i+1);
-		if (! isLineSegmentContainedInBoundary(p0, p1))
-			return false;
-	}
-	return true;
+    const CoordinateSequence& seq = *(line.getCoordinatesRO());
+    for(size_t i = 0, n = seq.size() - 1; i < n; ++i) {
+        const Coordinate& p0 = seq.getAt(i);
+        const Coordinate& p1 = seq.getAt(i + 1);
+        if(! isLineSegmentContainedInBoundary(p0, p1)) {
+            return false;
+        }
+    }
+    return true;
 }
 
 /*private*/
 bool
 RectangleContains::isLineSegmentContainedInBoundary(const Coordinate& p0,
-		const Coordinate& p1)
+        const Coordinate& p1)
 {
-	if (p0.equals2D(p1))
-		return isPointContainedInBoundary(p0);
-
-	// we already know that the segment is contained in
-	// the rectangle envelope
-	if (p0.x == p1.x) {
-		if (p0.x == rectEnv.getMinX() ||
-			p0.x == rectEnv.getMaxX() )
-		{
-			return true;
-		}
-	}
-	else if (p0.y == p1.y) {
-		if (p0.y == rectEnv.getMinY() ||
-			p0.y == rectEnv.getMaxY() )
-		{
-			return true;
-		}
-	}
-
-	/**
-	 * Either
-	 *   both x and y values are different
-	 * or
-	 *   one of x and y are the same, but the other ordinate
-	 *   is not the same as a boundary ordinate
-	 *
-	 * In either case, the segment is not wholely in the boundary
-	 */
-	return false;
+    if(p0.equals2D(p1)) {
+        return isPointContainedInBoundary(p0);
+    }
+
+    // we already know that the segment is contained in
+    // the rectangle envelope
+    if(p0.x == p1.x) {
+        if(p0.x == rectEnv.getMinX() ||
+                p0.x == rectEnv.getMaxX()) {
+            return true;
+        }
+    }
+    else if(p0.y == p1.y) {
+        if(p0.y == rectEnv.getMinY() ||
+                p0.y == rectEnv.getMaxY()) {
+            return true;
+        }
+    }
+
+    /**
+     * Either
+     *   both x and y values are different
+     * or
+     *   one of x and y are the same, but the other ordinate
+     *   is not the same as a boundary ordinate
+     *
+     * In either case, the segment is not wholely in the boundary
+     */
+    return false;
 }
 
 
diff --git a/src/operation/predicate/RectangleIntersects.cpp b/src/operation/predicate/RectangleIntersects.cpp
index db7036e..e4dd758 100644
--- a/src/operation/predicate/RectangleIntersects.cpp
+++ b/src/operation/predicate/RectangleIntersects.cpp
@@ -44,12 +44,11 @@ namespace predicate { // geos.operation.predicate
 // EnvelopeIntersectsVisitor
 //----------------------------------------------------------------
 
-class EnvelopeIntersectsVisitor: public geom::util::ShortCircuitedGeometryVisitor
-{
+class EnvelopeIntersectsVisitor: public geom::util::ShortCircuitedGeometryVisitor {
 private:
 
-	const geom::Envelope &rectEnv;
-	bool intersectsVar;
+    const geom::Envelope& rectEnv;
+    bool intersectsVar;
 
     // Declare type as noncopyable
     EnvelopeIntersectsVisitor(const EnvelopeIntersectsVisitor& other) = delete;
@@ -57,62 +56,71 @@ private:
 
 protected:
 
-	/**
-	 * Reports whether it can be concluded that an intersection occurs,
-	 * or whether further testing is required.
-	 *
-	 * @return <code>true</code> if an intersection must occur
-	 * <code>false</code> if no conclusion can be made
-	 */
-	void visit(const geom::Geometry &element) override
-	{
-		const geom::Envelope &elementEnv = *(element.getEnvelopeInternal());
-
-		// skip if envelopes do not intersect
-		if ( ! rectEnv.intersects(elementEnv) ) return;
-
-		// fully contained - must intersect
-		if ( rectEnv.contains(elementEnv) ) {
-			intersectsVar = true;
-			return;
-		}
-
-		/*
-		 * Since the envelopes intersect and the test element is
-		 * connected, if the test envelope is completely bisected by
-		 * an edge of the rectangle the element and the rectangle
-		 * must touch (This is basically an application of the
-		 * Jordan Curve Theorem).  The alternative situation
-		 * is that the test envelope is "on a corner" of the
-		 * rectangle envelope, i.e. is not completely bisected.
-		 * In this case it is not possible to make a conclusion
-		 * about the presence of an intersection.
-		 */
-		if (elementEnv.getMinX() >= rectEnv.getMinX()
-			&& elementEnv.getMaxX() <= rectEnv.getMaxX())
-		{
-			intersectsVar=true;
-			return;
-		}
-		if (elementEnv.getMinY() >= rectEnv.getMinY()
-			&& elementEnv.getMaxY() <= rectEnv.getMaxY())
-		{
-			intersectsVar = true;
-			return;
-		}
-	}
-
-	bool isDone() override { return intersectsVar==true; }
+    /**
+     * Reports whether it can be concluded that an intersection occurs,
+     * or whether further testing is required.
+     *
+     * @return <code>true</code> if an intersection must occur
+     * <code>false</code> if no conclusion can be made
+     */
+    void
+    visit(const geom::Geometry& element) override
+    {
+        const geom::Envelope& elementEnv = *(element.getEnvelopeInternal());
+
+        // skip if envelopes do not intersect
+        if(! rectEnv.intersects(elementEnv)) {
+            return;
+        }
+
+        // fully contained - must intersect
+        if(rectEnv.contains(elementEnv)) {
+            intersectsVar = true;
+            return;
+        }
+
+        /*
+         * Since the envelopes intersect and the test element is
+         * connected, if the test envelope is completely bisected by
+         * an edge of the rectangle the element and the rectangle
+         * must touch (This is basically an application of the
+         * Jordan Curve Theorem).  The alternative situation
+         * is that the test envelope is "on a corner" of the
+         * rectangle envelope, i.e. is not completely bisected.
+         * In this case it is not possible to make a conclusion
+         * about the presence of an intersection.
+         */
+        if(elementEnv.getMinX() >= rectEnv.getMinX()
+                && elementEnv.getMaxX() <= rectEnv.getMaxX()) {
+            intersectsVar = true;
+            return;
+        }
+        if(elementEnv.getMinY() >= rectEnv.getMinY()
+                && elementEnv.getMaxY() <= rectEnv.getMaxY()) {
+            intersectsVar = true;
+            return;
+        }
+    }
+
+    bool
+    isDone() override
+    {
+        return intersectsVar == true;
+    }
 
 public:
 
-	EnvelopeIntersectsVisitor(const geom::Envelope &env)
-		:
-		rectEnv(env),
-		intersectsVar(false)
-		{}
+    EnvelopeIntersectsVisitor(const geom::Envelope& env)
+        :
+        rectEnv(env),
+        intersectsVar(false)
+    {}
 
-	bool intersects() { return intersectsVar; }
+    bool
+    intersects()
+    {
+        return intersectsVar;
+    }
 
 };
 
@@ -124,13 +132,12 @@ public:
  * Tests whether it can be concluded
  * that a geometry contains a corner point of a rectangle.
  */
-class ContainsPointVisitor: public geom::util::ShortCircuitedGeometryVisitor
-{
+class ContainsPointVisitor: public geom::util::ShortCircuitedGeometryVisitor {
 private:
 
-	const geom::Envelope &rectEnv;
-	bool containsPointVar;
-	const geom::CoordinateSequence &rectSeq;
+    const geom::Envelope& rectEnv;
+    bool containsPointVar;
+    const geom::CoordinateSequence& rectSeq;
 
     // Declare type as noncopyable
     ContainsPointVisitor(const ContainsPointVisitor& other);
@@ -138,55 +145,62 @@ private:
 
 protected:
 
-	void visit(const geom::Geometry &geom) override
-	{
-		using geos::algorithm::locate::SimplePointInAreaLocator;
+    void
+    visit(const geom::Geometry& geom) override
+    {
+        using geos::algorithm::locate::SimplePointInAreaLocator;
 
-		const geom::Polygon *poly;
+        const geom::Polygon* poly;
 
-		// if test geometry is not polygonal this check is not needed
-		if ( nullptr == (poly=dynamic_cast<const geom::Polygon *>(&geom)) ) {
-			return;
-		}
+        // if test geometry is not polygonal this check is not needed
+        if(nullptr == (poly = dynamic_cast<const geom::Polygon*>(&geom))) {
+            return;
+        }
 
-		const geom::Envelope &elementEnv = *(geom.getEnvelopeInternal());
+        const geom::Envelope& elementEnv = *(geom.getEnvelopeInternal());
 
-		if ( !rectEnv.intersects(elementEnv) ) {
-			return;
-		}
+        if(!rectEnv.intersects(elementEnv)) {
+            return;
+        }
 
-		// test each corner of rectangle for inclusion
-		for (int i=0; i<4; i++)
-		{
+        // test each corner of rectangle for inclusion
+        for(int i = 0; i < 4; i++) {
 
-			const geom::Coordinate &rectPt=rectSeq.getAt(i);
+            const geom::Coordinate& rectPt = rectSeq.getAt(i);
 
-			if ( !elementEnv.contains(rectPt) ) {
-				continue;
-			}
+            if(!elementEnv.contains(rectPt)) {
+                continue;
+            }
 
-			// check rect point in poly (rect is known not to
-			// touch polygon at this point)
-			if (SimplePointInAreaLocator::locatePointInPolygon(rectPt, poly) != geom::Location::EXTERIOR)
-			{
-				containsPointVar=true;
-				return;
-			}
-		}
-	}
+            // check rect point in poly (rect is known not to
+            // touch polygon at this point)
+            if(SimplePointInAreaLocator::locatePointInPolygon(rectPt, poly) != geom::Location::EXTERIOR) {
+                containsPointVar = true;
+                return;
+            }
+        }
+    }
 
-	bool isDone() override { return containsPointVar; }
+    bool
+    isDone() override
+    {
+        return containsPointVar;
+    }
 
 public:
 
-	ContainsPointVisitor(const geom::Polygon &rect)
-		:
-		rectEnv(*(rect.getEnvelopeInternal())),
-		containsPointVar(false),
-		rectSeq(*(rect.getExteriorRing()->getCoordinatesRO()))
-		{}
+    ContainsPointVisitor(const geom::Polygon& rect)
+        :
+        rectEnv(*(rect.getEnvelopeInternal())),
+        containsPointVar(false),
+        rectSeq(*(rect.getExteriorRing()->getCoordinatesRO()))
+    {}
 
-	bool containsPoint() { return containsPointVar; }
+    bool
+    containsPoint()
+    {
+        return containsPointVar;
+    }
 
 };
 
@@ -194,31 +208,30 @@ public:
 // LineIntersectsVisitor
 //----------------------------------------------------------------
 
-class LineIntersectsVisitor: public geom::util::ShortCircuitedGeometryVisitor
-{
+class LineIntersectsVisitor: public geom::util::ShortCircuitedGeometryVisitor {
 private:
 
-	//const geom::Polygon& rectangle;
-	const geom::Envelope& rectEnv;
-	const geom::LineString& rectLine;
-	bool intersectsVar;
-	//const geom::CoordinateSequence &rectSeq;
-
-	void computeSegmentIntersection(const geom::Geometry &geom)
-	{
-		using geos::geom::util::LinearComponentExtracter;
-
-		// check segment intersection
-		// get all lines from geom (e.g. if it's a multi-ring polygon)
-		geom::LineString::ConstVect lines;
-		LinearComponentExtracter::getLines(geom, lines);
-		SegmentIntersectionTester si;
-		if ( si.hasIntersectionWithLineStrings(rectLine, lines) )
-		{
-			intersectsVar = true;
-			return;
-		}
-	}
+    //const geom::Polygon& rectangle;
+    const geom::Envelope& rectEnv;
+    const geom::LineString& rectLine;
+    bool intersectsVar;
+    //const geom::CoordinateSequence &rectSeq;
+
+    void
+    computeSegmentIntersection(const geom::Geometry& geom)
+    {
+        using geos::geom::util::LinearComponentExtracter;
+
+        // check segment intersection
+        // get all lines from geom (e.g. if it's a multi-ring polygon)
+        geom::LineString::ConstVect lines;
+        LinearComponentExtracter::getLines(geom, lines);
+        SegmentIntersectionTester si;
+        if(si.hasIntersectionWithLineStrings(rectLine, lines)) {
+            intersectsVar = true;
+            return;
+        }
+    }
 
     // Declare type as noncopyable
     LineIntersectsVisitor(const LineIntersectsVisitor& other);
@@ -226,36 +239,47 @@ private:
 
 protected:
 
-	void visit(const geom::Geometry &geom) override
-	{
-		const geom::Envelope &elementEnv = *(geom.getEnvelopeInternal());
+    void
+    visit(const geom::Geometry& geom) override
+    {
+        const geom::Envelope& elementEnv = *(geom.getEnvelopeInternal());
 
-		// check for envelope intersection
-		if (! rectEnv.intersects(elementEnv) ) return;
+        // check for envelope intersection
+        if(! rectEnv.intersects(elementEnv)) {
+            return;
+        }
 
-		computeSegmentIntersection(geom);
-	}
+        computeSegmentIntersection(geom);
+    }
 
-	bool isDone() override { return intersectsVar; }
+    bool
+    isDone() override
+    {
+        return intersectsVar;
+    }
 
 public:
 
-	LineIntersectsVisitor(const geom::Polygon &rect)
-		:
-		//rectangle(rect),
-		rectEnv(*(rect.getEnvelopeInternal())),
-		rectLine(*(rect.getExteriorRing())),
-		intersectsVar(false)
-		//rectSeq(*(rect.getExteriorRing()->getCoordinatesRO()))
-		{}
-
-	/**
-	 * Reports whether any segment intersection exists.
-	 *
-	 * @return <code>true</code> if a segment intersection exists
-	 * <code>false</code> if no segment intersection exists
-	 */
-	bool intersects() const { return intersectsVar; }
+    LineIntersectsVisitor(const geom::Polygon& rect)
+        :
+        //rectangle(rect),
+        rectEnv(*(rect.getEnvelopeInternal())),
+        rectLine(*(rect.getExteriorRing())),
+        intersectsVar(false)
+        //rectSeq(*(rect.getExteriorRing()->getCoordinatesRO()))
+    {}
+
+    /**
+     * Reports whether any segment intersection exists.
+     *
+     * @return <code>true</code> if a segment intersection exists
+     * <code>false</code> if no segment intersection exists
+     */
+    bool
+    intersects() const
+    {
+        return intersectsVar;
+    }
 
 };
 
@@ -266,27 +290,32 @@ public:
 bool
 RectangleIntersects::intersects(const geom::Geometry& geom)
 {
-	if (!rectEnv.intersects(geom.getEnvelopeInternal()))
-		return false;
-
-	// test envelope relationships
-	EnvelopeIntersectsVisitor visitor(rectEnv);
-	visitor.applyTo(geom);
-	if (visitor.intersects()) return true;
-
-	// test if any rectangle corner is contained in the target
-	ContainsPointVisitor ecpVisitor(rectangle);
-	ecpVisitor.applyTo(geom);
-	if (ecpVisitor.containsPoint())
-		return true;
-
-	// test if any lines intersect
-	LineIntersectsVisitor liVisitor(rectangle);
-	liVisitor.applyTo(geom);
-	if (liVisitor.intersects())
-		return true;
-
-	return false;
+    if(!rectEnv.intersects(geom.getEnvelopeInternal())) {
+        return false;
+    }
+
+    // test envelope relationships
+    EnvelopeIntersectsVisitor visitor(rectEnv);
+    visitor.applyTo(geom);
+    if(visitor.intersects()) {
+        return true;
+    }
+
+    // test if any rectangle corner is contained in the target
+    ContainsPointVisitor ecpVisitor(rectangle);
+    ecpVisitor.applyTo(geom);
+    if(ecpVisitor.containsPoint()) {
+        return true;
+    }
+
+    // test if any lines intersect
+    LineIntersectsVisitor liVisitor(rectangle);
+    liVisitor.applyTo(geom);
+    if(liVisitor.intersects()) {
+        return true;
+    }
+
+    return false;
 }
 
 } // namespace geos.operation.predicate
diff --git a/src/operation/predicate/SegmentIntersectionTester.cpp b/src/operation/predicate/SegmentIntersectionTester.cpp
index 45be698..1b503d3 100644
--- a/src/operation/predicate/SegmentIntersectionTester.cpp
+++ b/src/operation/predicate/SegmentIntersectionTester.cpp
@@ -30,84 +30,87 @@ namespace predicate {
 
 bool
 SegmentIntersectionTester::hasIntersectionWithLineStrings(
-	const LineString &line,
-	const LineString::ConstVect& lines)
+    const LineString& line,
+    const LineString::ConstVect& lines)
 {
-  hasIntersectionVar = false;
-	for (size_t i=0, n=lines.size(); i<n; ++i )
-	{
-		const LineString *testLine = lines[i];
-		hasIntersection(line, *testLine);
-		if (hasIntersectionVar) break;
-	}
-	return hasIntersectionVar;
+    hasIntersectionVar = false;
+    for(size_t i = 0, n = lines.size(); i < n; ++i) {
+        const LineString* testLine = lines[i];
+        hasIntersection(line, *testLine);
+        if(hasIntersectionVar) {
+            break;
+        }
+    }
+    return hasIntersectionVar;
 }
 
 bool
 SegmentIntersectionTester::hasIntersection(
-	const LineString &line, const LineString &testLine)
+    const LineString& line, const LineString& testLine)
 {
-  typedef std::size_t size_type;
+    typedef std::size_t size_type;
 
-	const CoordinateSequence &seq0 = *(line.getCoordinatesRO());
-  size_type seq0size = seq0.getSize();
+    const CoordinateSequence& seq0 = *(line.getCoordinatesRO());
+    size_type seq0size = seq0.getSize();
 
-  const CoordinateSequence &seq1 = *(testLine.getCoordinatesRO());
-  size_type seq1size = seq1.getSize();
+    const CoordinateSequence& seq1 = *(testLine.getCoordinatesRO());
+    size_type seq1size = seq1.getSize();
 
-  for (size_type i = 1; i<seq0size && !hasIntersectionVar; ++i)
-	{
-    seq0.getAt(i - 1, pt00);
-    seq0.getAt(i, pt01);
+    for(size_type i = 1; i < seq0size && !hasIntersectionVar; ++i) {
+        seq0.getAt(i - 1, pt00);
+        seq0.getAt(i, pt01);
 
-    for (size_type j = 1; j < seq1size && !hasIntersectionVar; ++j)
-		{
-      seq1.getAt(j-1, pt10);
-      seq1.getAt(j, pt11);
+        for(size_type j = 1; j < seq1size && !hasIntersectionVar; ++j) {
+            seq1.getAt(j - 1, pt10);
+            seq1.getAt(j, pt11);
 
-			li.computeIntersection(pt00, pt01, pt10, pt11);
-			if (li.hasIntersection()) hasIntersectionVar = true;
-		}
-	}
+            li.computeIntersection(pt00, pt01, pt10, pt11);
+            if(li.hasIntersection()) {
+                hasIntersectionVar = true;
+            }
+        }
+    }
 
-	return hasIntersectionVar;
+    return hasIntersectionVar;
 }
 
 bool
 SegmentIntersectionTester::hasIntersectionWithEnvelopeFilter(
-	const LineString &line, const LineString &testLine)
+    const LineString& line, const LineString& testLine)
 {
-  typedef std::size_t size_type;
+    typedef std::size_t size_type;
 
-	const CoordinateSequence &seq0 = *(line.getCoordinatesRO());
-  size_type seq0size = seq0.getSize();
+    const CoordinateSequence& seq0 = *(line.getCoordinatesRO());
+    size_type seq0size = seq0.getSize();
 
-  const CoordinateSequence &seq1 = *(testLine.getCoordinatesRO());
-  size_type seq1size = seq1.getSize();
+    const CoordinateSequence& seq1 = *(testLine.getCoordinatesRO());
+    size_type seq1size = seq1.getSize();
 
-  const Envelope* lineEnv = line.getEnvelopeInternal();
+    const Envelope* lineEnv = line.getEnvelopeInternal();
 
-  typedef std::size_t size_type;
+    typedef std::size_t size_type;
 
-  for (size_type i = 1; i<seq1size && !hasIntersectionVar; ++i)
-	{
-    seq1.getAt(i-1, pt10);
-    seq1.getAt(i, pt11);
+    for(size_type i = 1; i < seq1size && !hasIntersectionVar; ++i) {
+        seq1.getAt(i - 1, pt10);
+        seq1.getAt(i, pt11);
 
-    // skip test if segment does not intersect query envelope
-    if (! lineEnv->intersects(Envelope(pt10, pt11))) continue;
+        // skip test if segment does not intersect query envelope
+        if(! lineEnv->intersects(Envelope(pt10, pt11))) {
+            continue;
+        }
 
-    for (size_type j = 1; j < seq0size && !hasIntersectionVar; ++j)
-		{
-      seq0.getAt(j - 1, pt00);
-      seq0.getAt(j, pt01);
+        for(size_type j = 1; j < seq0size && !hasIntersectionVar; ++j) {
+            seq0.getAt(j - 1, pt00);
+            seq0.getAt(j, pt01);
 
-			li.computeIntersection(pt00, pt01, pt10, pt11);
-			if (li.hasIntersection()) hasIntersectionVar = true;
-		}
-	}
+            li.computeIntersection(pt00, pt01, pt10, pt11);
+            if(li.hasIntersection()) {
+                hasIntersectionVar = true;
+            }
+        }
+    }
 
-	return hasIntersectionVar;
+    return hasIntersectionVar;
 }
 
 } // namespace predicate
diff --git a/src/operation/relate/EdgeEndBuilder.cpp b/src/operation/relate/EdgeEndBuilder.cpp
index ca171dd..62f38fe 100644
--- a/src/operation/relate/EdgeEndBuilder.cpp
+++ b/src/operation/relate/EdgeEndBuilder.cpp
@@ -34,15 +34,15 @@ namespace geos {
 namespace operation { // geos.operation
 namespace relate { // geos.operation.relate
 
-vector<EdgeEnd*> *
-EdgeEndBuilder::computeEdgeEnds(vector<Edge*> *edges)
+vector<EdgeEnd*>*
+EdgeEndBuilder::computeEdgeEnds(vector<Edge*>* edges)
 {
-	vector<EdgeEnd*> *l=new vector<EdgeEnd*>();
-	for(vector<Edge*>::iterator i=edges->begin();i<edges->end();i++) {
-		Edge *e=*i;
-		computeEdgeEnds(e,l);
-	}
-	return l;
+    vector<EdgeEnd*>* l = new vector<EdgeEnd*>();
+    for(vector<Edge*>::iterator i = edges->begin(); i < edges->end(); i++) {
+        Edge* e = *i;
+        computeEdgeEnds(e, l);
+    }
+    return l;
 }
 
 /**
@@ -50,35 +50,38 @@ EdgeEndBuilder::computeEdgeEnds(vector<Edge*> *edges)
  * Edge (if any) and inserts them into the graph.
  */
 void
-EdgeEndBuilder::computeEdgeEnds(Edge *edge, vector<EdgeEnd*> *l)
+EdgeEndBuilder::computeEdgeEnds(Edge* edge, vector<EdgeEnd*>* l)
 {
-	EdgeIntersectionList &eiList=edge->getEdgeIntersectionList();
-	//Debug.print(eiList);
-	// ensure that the list has entries for the first and last point of the edge
-	eiList.addEndpoints();
+    EdgeIntersectionList& eiList = edge->getEdgeIntersectionList();
+    //Debug.print(eiList);
+    // ensure that the list has entries for the first and last point of the edge
+    eiList.addEndpoints();
 
-	EdgeIntersectionList::iterator it=eiList.begin();
-	// no intersections, so there is nothing to do
-	if (it==eiList.end()) return;
+    EdgeIntersectionList::iterator it = eiList.begin();
+    // no intersections, so there is nothing to do
+    if(it == eiList.end()) {
+        return;
+    }
 
-	EdgeIntersection *eiPrev=nullptr;
-	EdgeIntersection *eiCurr=nullptr;
+    EdgeIntersection* eiPrev = nullptr;
+    EdgeIntersection* eiCurr = nullptr;
 
-	EdgeIntersection *eiNext=*it;
-	it++;
-	do {
-		eiPrev=eiCurr;
-		eiCurr=eiNext;
-		eiNext=nullptr;
-		if (it!=eiList.end()) {
-			eiNext=*it;
-			it++;
-		}
-		if (eiCurr!=nullptr) {
-			createEdgeEndForPrev(edge,l,eiCurr,eiPrev);
-			createEdgeEndForNext(edge,l,eiCurr,eiNext);
-		}
-	} while (eiCurr!=nullptr);
+    EdgeIntersection* eiNext = *it;
+    it++;
+    do {
+        eiPrev = eiCurr;
+        eiCurr = eiNext;
+        eiNext = nullptr;
+        if(it != eiList.end()) {
+            eiNext = *it;
+            it++;
+        }
+        if(eiCurr != nullptr) {
+            createEdgeEndForPrev(edge, l, eiCurr, eiPrev);
+            createEdgeEndForNext(edge, l, eiCurr, eiNext);
+        }
+    }
+    while(eiCurr != nullptr);
 }
 
 /**
@@ -90,25 +93,28 @@ EdgeEndBuilder::computeEdgeEnds(Edge *edge, vector<EdgeEnd*> *l)
  * eiCurr will always be an EdgeIntersection, but eiPrev may be null.
  */
 void
-EdgeEndBuilder::createEdgeEndForPrev(Edge *edge, vector<EdgeEnd*> *l,
-		EdgeIntersection *eiCurr, EdgeIntersection *eiPrev)
+EdgeEndBuilder::createEdgeEndForPrev(Edge* edge, vector<EdgeEnd*>* l,
+                                     EdgeIntersection* eiCurr, EdgeIntersection* eiPrev)
 {
-	auto iPrev = eiCurr->segmentIndex;
-	if (eiCurr->dist==0.0) {
-		// if at the start of the edge there is no previous edge
-		if (iPrev==0) return;
-		iPrev--;
-	}
-	Coordinate pPrev(edge->getCoordinate(iPrev));
-	// if prev intersection is past the previous vertex, use it instead
-	if (eiPrev!=nullptr && eiPrev->segmentIndex>=iPrev)
-		pPrev=eiPrev->coord;
-	Label label( edge->getLabel() );
-	// since edgeStub is oriented opposite to it's parent edge, have to flip sides for edge label
-	label.flip();
-	EdgeEnd *e=new EdgeEnd(edge,eiCurr->coord,pPrev,label);
-	//e.print(System.out);  System.out.println();
-	l->push_back(e);
+    auto iPrev = eiCurr->segmentIndex;
+    if(eiCurr->dist == 0.0) {
+        // if at the start of the edge there is no previous edge
+        if(iPrev == 0) {
+            return;
+        }
+        iPrev--;
+    }
+    Coordinate pPrev(edge->getCoordinate(iPrev));
+    // if prev intersection is past the previous vertex, use it instead
+    if(eiPrev != nullptr && eiPrev->segmentIndex >= iPrev) {
+        pPrev = eiPrev->coord;
+    }
+    Label label(edge->getLabel());
+    // since edgeStub is oriented opposite to it's parent edge, have to flip sides for edge label
+    label.flip();
+    EdgeEnd* e = new EdgeEnd(edge, eiCurr->coord, pPrev, label);
+    //e.print(System.out);  System.out.println();
+    l->push_back(e);
 }
 
 /**
@@ -120,19 +126,22 @@ EdgeEndBuilder::createEdgeEndForPrev(Edge *edge, vector<EdgeEnd*> *l,
  * eiCurr will always be an EdgeIntersection, but eiNext may be null.
  */
 void
-EdgeEndBuilder::createEdgeEndForNext(Edge *edge, vector<EdgeEnd*> *l,
-		EdgeIntersection *eiCurr, EdgeIntersection *eiNext)
+EdgeEndBuilder::createEdgeEndForNext(Edge* edge, vector<EdgeEnd*>* l,
+                                     EdgeIntersection* eiCurr, EdgeIntersection* eiNext)
 {
-	size_t iNext = eiCurr->segmentIndex + 1;
-	// if there is no next edge there is nothing to do
-	if (iNext>=edge->getNumPoints() && eiNext==nullptr) return;
-	Coordinate pNext(edge->getCoordinate(iNext));
-	// if the next intersection is in the same segment as the current, use it as the endpoint
-	if (eiNext!=nullptr && eiNext->segmentIndex==eiCurr->segmentIndex)
-		pNext=eiNext->coord;
-	EdgeEnd *e = new EdgeEnd(edge, eiCurr->coord, pNext, edge->getLabel());
-	//Debug.println(e);
-	l->push_back(e);
+    size_t iNext = eiCurr->segmentIndex + 1;
+    // if there is no next edge there is nothing to do
+    if(iNext >= edge->getNumPoints() && eiNext == nullptr) {
+        return;
+    }
+    Coordinate pNext(edge->getCoordinate(iNext));
+    // if the next intersection is in the same segment as the current, use it as the endpoint
+    if(eiNext != nullptr && eiNext->segmentIndex == eiCurr->segmentIndex) {
+        pNext = eiNext->coord;
+    }
+    EdgeEnd* e = new EdgeEnd(edge, eiCurr->coord, pNext, edge->getLabel());
+    //Debug.println(e);
+    l->push_back(e);
 }
 
 } // namespace geos.operation.relate
diff --git a/src/operation/relate/EdgeEndBundle.cpp b/src/operation/relate/EdgeEndBundle.cpp
index 06b93ed..81f3a14 100644
--- a/src/operation/relate/EdgeEndBundle.cpp
+++ b/src/operation/relate/EdgeEndBundle.cpp
@@ -35,33 +35,38 @@ namespace geos {
 namespace operation { // geos.operation
 namespace relate { // geos.operation.relate
 
-EdgeEndBundle::EdgeEndBundle(EdgeEnd *e):
-	EdgeEnd(e->getEdge(),e->getCoordinate(),
-		e->getDirectedCoordinate(),
-		e->getLabel())
+EdgeEndBundle::EdgeEndBundle(EdgeEnd* e):
+    EdgeEnd(e->getEdge(), e->getCoordinate(),
+            e->getDirectedCoordinate(),
+            e->getLabel())
 {
-	edgeEnds=new vector<EdgeEnd*>();
-	insert(e);
+    edgeEnds = new vector<EdgeEnd*>();
+    insert(e);
 }
 
-EdgeEndBundle::~EdgeEndBundle(){
-	for(size_t i=0, n=edgeEnds->size(); i<n; i++) {
-		delete (*edgeEnds)[i];
-	}
-	delete edgeEnds;
+EdgeEndBundle::~EdgeEndBundle()
+{
+    for(size_t i = 0, n = edgeEnds->size(); i < n; i++) {
+        delete(*edgeEnds)[i];
+    }
+    delete edgeEnds;
 }
 
 //Not needed
 //public Iterator iterator() { return edgeEnds.iterator(); }
 
-vector<EdgeEnd*>* EdgeEndBundle::getEdgeEnds() {
-	return edgeEnds;
+vector<EdgeEnd*>*
+EdgeEndBundle::getEdgeEnds()
+{
+    return edgeEnds;
 }
 
-void EdgeEndBundle::insert(EdgeEnd *e){
-	// Assert: start point is the same
-	// Assert: direction is the same
-	edgeEnds->push_back(e);
+void
+EdgeEndBundle::insert(EdgeEnd* e)
+{
+    // Assert: start point is the same
+    // Assert: direction is the same
+    edgeEnds->push_back(e);
 }
 
 
@@ -70,62 +75,74 @@ void EdgeEndBundle::insert(EdgeEnd *e){
 * edges in this EdgeStubBundle.  It essentially merges
 * the ON and side labels for each edge.  These labels must be compatible
 */
-void EdgeEndBundle::computeLabel(
-	const algorithm::BoundaryNodeRule& boundaryNodeRule)
+void
+EdgeEndBundle::computeLabel(
+    const algorithm::BoundaryNodeRule& boundaryNodeRule)
 {
-	// create the label.  If any of the edges belong to areas,
-	// the label must be an area label
-	bool isArea=false;
-
-	for(vector<EdgeEnd*>::iterator it=edgeEnds->begin(), itEnd=edgeEnds->end();
-			it != itEnd; it++)
-	{
-		EdgeEnd *e=*it;
-		if (e->getLabel().isArea()) isArea=true;
-	}
-	if (isArea) {
-		label = Label(Location::UNDEF,Location::UNDEF,Location::UNDEF);
-	} else {
-		label = Label(Location::UNDEF);
-	}
-	// compute the On label, and the side labels if present
-	for(int i=0;i<2;i++) {
-		computeLabelOn(i, boundaryNodeRule);
-		if (isArea)
-			computeLabelSides(i);
-	}
+    // create the label.  If any of the edges belong to areas,
+    // the label must be an area label
+    bool isArea = false;
+
+    for(vector<EdgeEnd*>::iterator it = edgeEnds->begin(), itEnd = edgeEnds->end();
+            it != itEnd; it++) {
+        EdgeEnd* e = *it;
+        if(e->getLabel().isArea()) {
+            isArea = true;
+        }
+    }
+    if(isArea) {
+        label = Label(Location::UNDEF, Location::UNDEF, Location::UNDEF);
+    }
+    else {
+        label = Label(Location::UNDEF);
+    }
+    // compute the On label, and the side labels if present
+    for(int i = 0; i < 2; i++) {
+        computeLabelOn(i, boundaryNodeRule);
+        if(isArea) {
+            computeLabelSides(i);
+        }
+    }
 }
 
 
 void
 EdgeEndBundle::computeLabelOn(int geomIndex, const algorithm::BoundaryNodeRule& boundaryNodeRule)
 {
-	// compute the ON location value
-	int boundaryCount=0;
-	bool foundInterior=false;
-
-	for(vector<EdgeEnd*>::iterator it=edgeEnds->begin();it<edgeEnds->end();it++) {
-		EdgeEnd *e=*it;
-		int loc=e->getLabel().getLocation(geomIndex);
-		if (loc==Location::BOUNDARY) boundaryCount++;
-		if (loc==Location::INTERIOR) foundInterior=true;
-	}
-	int loc=Location::UNDEF;
-	if (foundInterior) loc=Location::INTERIOR;
-	if (boundaryCount>0) {
-		loc = GeometryGraph::determineBoundary(boundaryNodeRule,
-		                                       boundaryCount);
-	}
-	label.setLocation(geomIndex,loc);
+    // compute the ON location value
+    int boundaryCount = 0;
+    bool foundInterior = false;
+
+    for(vector<EdgeEnd*>::iterator it = edgeEnds->begin(); it < edgeEnds->end(); it++) {
+        EdgeEnd* e = *it;
+        int loc = e->getLabel().getLocation(geomIndex);
+        if(loc == Location::BOUNDARY) {
+            boundaryCount++;
+        }
+        if(loc == Location::INTERIOR) {
+            foundInterior = true;
+        }
+    }
+    int loc = Location::UNDEF;
+    if(foundInterior) {
+        loc = Location::INTERIOR;
+    }
+    if(boundaryCount > 0) {
+        loc = GeometryGraph::determineBoundary(boundaryNodeRule,
+                                               boundaryCount);
+    }
+    label.setLocation(geomIndex, loc);
 }
 
 
 /**
 * Compute the labelling for each side
 */
-void EdgeEndBundle::computeLabelSides(int geomIndex) {
-	computeLabelSide(geomIndex,Position::LEFT);
-	computeLabelSide(geomIndex,Position::RIGHT);
+void
+EdgeEndBundle::computeLabelSides(int geomIndex)
+{
+    computeLabelSide(geomIndex, Position::LEFT);
+    computeLabelSide(geomIndex, Position::RIGHT);
 }
 
 /**
@@ -142,33 +159,40 @@ void EdgeEndBundle::computeLabelSides(int geomIndex) {
 *  along an edge.  This is the reason for Interior-primacy rule above - it
 *  results in the summary label having the Geometry interior on <b>both</b> sides.
 */
-void EdgeEndBundle::computeLabelSide(int geomIndex, int side) {
-	for(vector<EdgeEnd*>::iterator it=edgeEnds->begin();it<edgeEnds->end();it++) {
-		EdgeEnd *e=*it;
-		if (e->getLabel().isArea()) {
-			int loc=e->getLabel().getLocation(geomIndex,side);
-			if (loc==Location::INTERIOR) {
-				label.setLocation(geomIndex,side,Location::INTERIOR);
-				return;
-			} else if (loc==Location::EXTERIOR) {
-				label.setLocation(geomIndex,side,Location::EXTERIOR);
-			}
-		}
-	}
+void
+EdgeEndBundle::computeLabelSide(int geomIndex, int side)
+{
+    for(vector<EdgeEnd*>::iterator it = edgeEnds->begin(); it < edgeEnds->end(); it++) {
+        EdgeEnd* e = *it;
+        if(e->getLabel().isArea()) {
+            int loc = e->getLabel().getLocation(geomIndex, side);
+            if(loc == Location::INTERIOR) {
+                label.setLocation(geomIndex, side, Location::INTERIOR);
+                return;
+            }
+            else if(loc == Location::EXTERIOR) {
+                label.setLocation(geomIndex, side, Location::EXTERIOR);
+            }
+        }
+    }
 }
 
-void EdgeEndBundle::updateIM(IntersectionMatrix& im) {
-	Edge::updateIM(label, im);
+void
+EdgeEndBundle::updateIM(IntersectionMatrix& im)
+{
+    Edge::updateIM(label, im);
 }
 
-string EdgeEndBundle::print() const {
-	string out="EdgeEndBundle--> Label: "+label.toString()+"\n";
-	for(vector<EdgeEnd*>::iterator it=edgeEnds->begin();it<edgeEnds->end();it++) {
-		EdgeEnd *e=*it;
-		out+=e->print();
-		out+="\n";
-	}
-	return out;
+string
+EdgeEndBundle::print() const
+{
+    string out = "EdgeEndBundle--> Label: " + label.toString() + "\n";
+    for(vector<EdgeEnd*>::iterator it = edgeEnds->begin(); it < edgeEnds->end(); it++) {
+        EdgeEnd* e = *it;
+        out += e->print();
+        out += "\n";
+    }
+    return out;
 }
 
 } // namespace geos.operation.relate
diff --git a/src/operation/relate/EdgeEndBundleStar.cpp b/src/operation/relate/EdgeEndBundleStar.cpp
index 7efafde..1eddb0c 100644
--- a/src/operation/relate/EdgeEndBundleStar.cpp
+++ b/src/operation/relate/EdgeEndBundleStar.cpp
@@ -30,13 +30,12 @@ namespace relate { // geos.operation.relate
 
 EdgeEndBundleStar::~EdgeEndBundleStar()
 {
-	EdgeEndStar::iterator it=begin();
-	EdgeEndStar::iterator endIt=end();
-	for (; it!=endIt; ++it)
-	{
-		EdgeEndBundle *eeb=static_cast<EdgeEndBundle*>(*it);
-		delete eeb;
-	}
+    EdgeEndStar::iterator it = begin();
+    EdgeEndStar::iterator endIt = end();
+    for(; it != endIt; ++it) {
+        EdgeEndBundle* eeb = static_cast<EdgeEndBundle*>(*it);
+        delete eeb;
+    }
 }
 
 /**
@@ -46,34 +45,31 @@ EdgeEndBundleStar::~EdgeEndBundleStar()
  * to contain the EdgeEnd.
  */
 void
-EdgeEndBundleStar::insert(EdgeEnd *e)
+EdgeEndBundleStar::insert(EdgeEnd* e)
 {
-	EdgeEndBundle *eb;
-	//set<EdgeEnd*,EdgeEndLT>::iterator i=edgeMap->find(e);
-	EdgeEndStar::iterator it=find(e);
-	if (it==end())
-	{
-		eb=new EdgeEndBundle(e);
-		insertEdgeEnd(eb);
-	}
-	else
-	{
-		eb=static_cast<EdgeEndBundle*>(*it);
-		eb->insert(e);
-	}
+    EdgeEndBundle* eb;
+    //set<EdgeEnd*,EdgeEndLT>::iterator i=edgeMap->find(e);
+    EdgeEndStar::iterator it = find(e);
+    if(it == end()) {
+        eb = new EdgeEndBundle(e);
+        insertEdgeEnd(eb);
+    }
+    else {
+        eb = static_cast<EdgeEndBundle*>(*it);
+        eb->insert(e);
+    }
 }
 
 void
 EdgeEndBundleStar::updateIM(IntersectionMatrix& im)
 {
-	//vector<EdgeEnd*> *edges=getEdges();
-	EdgeEndStar::iterator it=begin();
-	EdgeEndStar::iterator endIt=end();
-	for (; it!=endIt; ++it)
-	{
-		EdgeEndBundle *esb=static_cast<EdgeEndBundle*>(*it);
-		esb->updateIM(im);
-	}
+    //vector<EdgeEnd*> *edges=getEdges();
+    EdgeEndStar::iterator it = begin();
+    EdgeEndStar::iterator endIt = end();
+    for(; it != endIt; ++it) {
+        EdgeEndBundle* esb = static_cast<EdgeEndBundle*>(*it);
+        esb->updateIM(im);
+    }
 }
 
 } // namespace geos.operation.relate
diff --git a/src/operation/relate/RelateComputer.cpp b/src/operation/relate/RelateComputer.cpp
index 2144142..2547b48 100644
--- a/src/operation/relate/RelateComputer.cpp
+++ b/src/operation/relate/RelateComputer.cpp
@@ -58,10 +58,10 @@ namespace geos {
 namespace operation { // geos.operation
 namespace relate { // geos.operation.relate
 
-RelateComputer::RelateComputer(std::vector<GeometryGraph*> *newArg):
-	arg(newArg),
-	nodes(RelateNodeFactory::instance()),
-	im(new IntersectionMatrix())
+RelateComputer::RelateComputer(std::vector<GeometryGraph*>* newArg):
+    arg(newArg),
+    nodes(RelateNodeFactory::instance()),
+    im(new IntersectionMatrix())
 {
 }
 
@@ -72,226 +72,239 @@ RelateComputer::~RelateComputer()
 IntersectionMatrix*
 RelateComputer::computeIM()
 {
-	// since Geometries are finite and embedded in a 2-D space, the EE element must always be 2
-	im->set(Location::EXTERIOR,Location::EXTERIOR,2);
-	// if the Geometries don't overlap there is nothing to do
-	const Envelope *e1=(*arg)[0]->getGeometry()->getEnvelopeInternal();
-	const Envelope *e2=(*arg)[1]->getGeometry()->getEnvelopeInternal();
-	if (!e1->intersects(e2)) {
-		computeDisjointIM(im.get());
-		return im.release();
-	}
+    // since Geometries are finite and embedded in a 2-D space, the EE element must always be 2
+    im->set(Location::EXTERIOR, Location::EXTERIOR, 2);
+    // if the Geometries don't overlap there is nothing to do
+    const Envelope* e1 = (*arg)[0]->getGeometry()->getEnvelopeInternal();
+    const Envelope* e2 = (*arg)[1]->getGeometry()->getEnvelopeInternal();
+    if(!e1->intersects(e2)) {
+        computeDisjointIM(im.get());
+        return im.release();
+    }
 
 #if GEOS_DEBUG
-	std::cerr << "RelateComputer::computeIM: "
-            << "computing self nodes 1"
-            << std::endl;
+    std::cerr << "RelateComputer::computeIM: "
+              << "computing self nodes 1"
+              << std::endl;
 #endif
 
-	std::unique_ptr<SegmentIntersector> si1 (
-		(*arg)[0]->computeSelfNodes(&li,false)
-	);
+    std::unique_ptr<SegmentIntersector> si1(
+        (*arg)[0]->computeSelfNodes(&li, false)
+    );
 
-	GEOS_CHECK_FOR_INTERRUPTS();
+    GEOS_CHECK_FOR_INTERRUPTS();
 
 #if GEOS_DEBUG
-	std::cerr << "RelateComputer::computeIM: "
-            << "computing self nodes 2"
-            << std::endl;
+    std::cerr << "RelateComputer::computeIM: "
+              << "computing self nodes 2"
+              << std::endl;
 #endif
 
-	std::unique_ptr<SegmentIntersector> si2 (
-		(*arg)[1]->computeSelfNodes(&li,false)
-	);
+    std::unique_ptr<SegmentIntersector> si2(
+        (*arg)[1]->computeSelfNodes(&li, false)
+    );
 
-	GEOS_CHECK_FOR_INTERRUPTS();
+    GEOS_CHECK_FOR_INTERRUPTS();
 
 #if GEOS_DEBUG
-	std::cerr << "RelateComputer::computeIM: "
-            << "computing edge intersections"
-            << std::endl;
+    std::cerr << "RelateComputer::computeIM: "
+              << "computing edge intersections"
+              << std::endl;
 #endif
 
-	// compute intersections between edges of the two input geometries
-	std::unique_ptr< SegmentIntersector> intersector (
-    (*arg)[0]->computeEdgeIntersections((*arg)[1], &li,false)
-  );
+    // compute intersections between edges of the two input geometries
+    std::unique_ptr< SegmentIntersector> intersector(
+        (*arg)[0]->computeEdgeIntersections((*arg)[1], &li, false)
+    );
 
-	GEOS_CHECK_FOR_INTERRUPTS();
+    GEOS_CHECK_FOR_INTERRUPTS();
 
 #if GEOS_DEBUG
-	std::cerr << "RelateComputer::computeIM: "
-            << "copying intersection nodes"
-            << std::endl;
+    std::cerr << "RelateComputer::computeIM: "
+              << "copying intersection nodes"
+              << std::endl;
 #endif
 
-	computeIntersectionNodes(0);
-	computeIntersectionNodes(1);
+    computeIntersectionNodes(0);
+    computeIntersectionNodes(1);
 
-	GEOS_CHECK_FOR_INTERRUPTS();
+    GEOS_CHECK_FOR_INTERRUPTS();
 
 #if GEOS_DEBUG
-	std::cerr << "RelateComputer::computeIM: "
-            << "copying nodes and labels"
-            << std::endl;
+    std::cerr << "RelateComputer::computeIM: "
+              << "copying nodes and labels"
+              << std::endl;
 #endif
 
-	GEOS_CHECK_FOR_INTERRUPTS();
+    GEOS_CHECK_FOR_INTERRUPTS();
 
-	/*
-	 * Copy the labelling for the nodes in the parent Geometries.
-	 * These override any labels determined by intersections
-	 * between the geometries.
-	 */
-	copyNodesAndLabels(0);
-	copyNodesAndLabels(1);
+    /*
+     * Copy the labelling for the nodes in the parent Geometries.
+     * These override any labels determined by intersections
+     * between the geometries.
+     */
+    copyNodesAndLabels(0);
+    copyNodesAndLabels(1);
 
-	GEOS_CHECK_FOR_INTERRUPTS();
+    GEOS_CHECK_FOR_INTERRUPTS();
 
-	/*
-	 * complete the labelling for any nodes which only have a
-	 * label for a single geometry
-	 */
-	//Debug.addWatch(nodes.find(new Coordinate(110, 200)));
-	//Debug.printWatch();
+    /*
+     * complete the labelling for any nodes which only have a
+     * label for a single geometry
+     */
+    //Debug.addWatch(nodes.find(new Coordinate(110, 200)));
+    //Debug.printWatch();
 #if GEOS_DEBUG
-	std::cerr << "RelateComputer::computeIM: "
-            << "labeling isolated nodes"
-            << std::endl;
+    std::cerr << "RelateComputer::computeIM: "
+              << "labeling isolated nodes"
+              << std::endl;
 #endif
-	labelIsolatedNodes();
-	//Debug.printWatch();
+    labelIsolatedNodes();
+    //Debug.printWatch();
 
 #if GEOS_DEBUG
-	std::cerr << "RelateComputer::computeIM: "
-            << "computing proper intersection matrix"
-            << std::endl;
+    std::cerr << "RelateComputer::computeIM: "
+              << "computing proper intersection matrix"
+              << std::endl;
 #endif
 
-	/*
-	 * If a proper intersection was found, we can set a lower bound
-	 * on the IM.
-	 */
-	computeProperIntersectionIM(intersector.get(), im.get());
+    /*
+     * If a proper intersection was found, we can set a lower bound
+     * on the IM.
+     */
+    computeProperIntersectionIM(intersector.get(), im.get());
 
 #if GEOS_DEBUG
-	std::cerr << "RelateComputer::computeIM: "
-            << "computing improper intersections"
-            << std::endl;
+    std::cerr << "RelateComputer::computeIM: "
+              << "computing improper intersections"
+              << std::endl;
 #endif
 
-	/*
-	 * Now process improper intersections
-	 * (eg where one or other of the geometrys has a vertex at the
-	 * intersection point)
-	 * We need to compute the edge graph at all nodes to determine
-	 * the IM.
-	 */
-	// build EdgeEnds for all intersections
-	EdgeEndBuilder eeBuilder;
-	std::unique_ptr< std::vector<EdgeEnd*> > ee0 (
-		eeBuilder.computeEdgeEnds((*arg)[0]->getEdges())
-  );
-	insertEdgeEnds(ee0.get());
-	std::unique_ptr< std::vector<EdgeEnd*> > ee1 (
-		eeBuilder.computeEdgeEnds((*arg)[1]->getEdges())
-  );
+    /*
+     * Now process improper intersections
+     * (eg where one or other of the geometrys has a vertex at the
+     * intersection point)
+     * We need to compute the edge graph at all nodes to determine
+     * the IM.
+     */
+    // build EdgeEnds for all intersections
+    EdgeEndBuilder eeBuilder;
+    std::unique_ptr< std::vector<EdgeEnd*> > ee0(
+        eeBuilder.computeEdgeEnds((*arg)[0]->getEdges())
+    );
+    insertEdgeEnds(ee0.get());
+    std::unique_ptr< std::vector<EdgeEnd*> > ee1(
+        eeBuilder.computeEdgeEnds((*arg)[1]->getEdges())
+    );
 
 #if GEOS_DEBUG
-	std::cerr << "RelateComputer::computeIM: "
-            << "inserting edge ends"
-            << std::endl;
+    std::cerr << "RelateComputer::computeIM: "
+              << "inserting edge ends"
+              << std::endl;
 #endif
 
-	insertEdgeEnds(ee1.get());
-	//Debug.println("==== NodeList ===");
-	//Debug.print(nodes);
+    insertEdgeEnds(ee1.get());
+    //Debug.println("==== NodeList ===");
+    //Debug.print(nodes);
 
 #if GEOS_DEBUG
-	std::cerr << "RelateComputer::computeIM: "
-            << "labeling node edges"
-            << std::endl;
+    std::cerr << "RelateComputer::computeIM: "
+              << "labeling node edges"
+              << std::endl;
 #endif
 
-	labelNodeEdges();
-
-	/**
-	 * Compute the labeling for isolated components.
-	 * Isolated components are components that do not touch any
-	 * other components in the graph.
-	 * They can be identified by the fact that they will
-	 * contain labels containing ONLY a single element, the one for
-	 * their parent geometry.
-	 * We only need to check components contained in the input graphs,
-	 * since isolated components will not have been replaced by new
-	 * components formed by intersections.
-	 */
+    labelNodeEdges();
+
+    /**
+     * Compute the labeling for isolated components.
+     * Isolated components are components that do not touch any
+     * other components in the graph.
+     * They can be identified by the fact that they will
+     * contain labels containing ONLY a single element, the one for
+     * their parent geometry.
+     * We only need to check components contained in the input graphs,
+     * since isolated components will not have been replaced by new
+     * components formed by intersections.
+     */
 #if GEOS_DEBUG
-	std::cerr << "RelateComputer::computeIM: "
-            << "computing labeling for isolated components"
-            << std::endl;
+    std::cerr << "RelateComputer::computeIM: "
+              << "computing labeling for isolated components"
+              << std::endl;
 #endif
-	//debugPrintln("Graph A isolated edges - ");
-	labelIsolatedEdges(0,1);
-	//debugPrintln("Graph B isolated edges - ");
-	labelIsolatedEdges(1,0);
-	// update the IM from all components
-	updateIM( *im );
-	return im.release();
+    //debugPrintln("Graph A isolated edges - ");
+    labelIsolatedEdges(0, 1);
+    //debugPrintln("Graph B isolated edges - ");
+    labelIsolatedEdges(1, 0);
+    // update the IM from all components
+    updateIM(*im);
+    return im.release();
 }
 
 void
-RelateComputer::insertEdgeEnds(std::vector<EdgeEnd*> *ee)
+RelateComputer::insertEdgeEnds(std::vector<EdgeEnd*>* ee)
 {
-	for(std::vector<EdgeEnd*>::iterator i=ee->begin();i<ee->end();i++) {
-		EdgeEnd *e=*i;
-		nodes.add(e);
-	}
+    for(std::vector<EdgeEnd*>::iterator i = ee->begin(); i < ee->end(); i++) {
+        EdgeEnd* e = *i;
+        nodes.add(e);
+    }
 }
 
 /* private */
 void
-RelateComputer::computeProperIntersectionIM(SegmentIntersector *intersector,IntersectionMatrix *imX)
+RelateComputer::computeProperIntersectionIM(SegmentIntersector* intersector, IntersectionMatrix* imX)
 {
-	// If a proper intersection is found, we can set a lower bound on the IM.
-	int dimA=(*arg)[0]->getGeometry()->getDimension();
-	int dimB=(*arg)[1]->getGeometry()->getDimension();
-	bool hasProper=intersector->hasProperIntersection();
-	bool hasProperInterior=intersector->hasProperInteriorIntersection();
-	// For Geometry's of dim 0 there can never be proper intersections.
-	/**
-	* If edge segments of Areas properly intersect, the areas must properly overlap.
-	*/
-	if (dimA==2 && dimB==2) {
-		if (hasProper) imX->setAtLeast("212101212");
-	}
-	/**
-	* If an Line segment properly intersects an edge segment of an Area,
-	* it follows that the Interior of the Line intersects the Boundary of the Area.
-	* If the intersection is a proper <i>interior</i> intersection, then
-	* there is an Interior-Interior intersection too.
-	* Note that it does not follow that the Interior of the Line intersects the Exterior
-	* of the Area, since there may be another Area component which contains the rest of the Line.
-	*/
-	 else if (dimA==2 && dimB==1) {
-		if (hasProper) imX->setAtLeast("FFF0FFFF2");
-		if (hasProperInterior) imX->setAtLeast("1FFFFF1FF");
-	} else if (dimA==1 && dimB==2) {
-		if (hasProper) imX->setAtLeast("F0FFFFFF2");
-		if (hasProperInterior) imX->setAtLeast("1F1FFFFFF");
-	}
-	/* If edges of LineStrings properly intersect *in an interior point*, all
-	we can deduce is that
-	the interiors intersect.  (We can NOT deduce that the exteriors intersect,
-	since some other segments in the geometries might cover the points in the
-	neighbourhood of the intersection.)
-	It is important that the point be known to be an interior point of
-	both Geometries, since it is possible in a self-intersecting geometry to
-	have a proper intersection on one segment that is also a boundary point of another segment.
-	*/
-	else if (dimA==1 && dimB==1) {
-		if (hasProperInterior) imX->setAtLeast("0FFFFFFFF");
-	}
+    // If a proper intersection is found, we can set a lower bound on the IM.
+    int dimA = (*arg)[0]->getGeometry()->getDimension();
+    int dimB = (*arg)[1]->getGeometry()->getDimension();
+    bool hasProper = intersector->hasProperIntersection();
+    bool hasProperInterior = intersector->hasProperInteriorIntersection();
+    // For Geometry's of dim 0 there can never be proper intersections.
+    /**
+    * If edge segments of Areas properly intersect, the areas must properly overlap.
+    */
+    if(dimA == 2 && dimB == 2) {
+        if(hasProper) {
+            imX->setAtLeast("212101212");
+        }
+    }
+    /**
+    * If an Line segment properly intersects an edge segment of an Area,
+    * it follows that the Interior of the Line intersects the Boundary of the Area.
+    * If the intersection is a proper <i>interior</i> intersection, then
+    * there is an Interior-Interior intersection too.
+    * Note that it does not follow that the Interior of the Line intersects the Exterior
+    * of the Area, since there may be another Area component which contains the rest of the Line.
+    */
+    else if(dimA == 2 && dimB == 1) {
+        if(hasProper) {
+            imX->setAtLeast("FFF0FFFF2");
+        }
+        if(hasProperInterior) {
+            imX->setAtLeast("1FFFFF1FF");
+        }
+    }
+    else if(dimA == 1 && dimB == 2) {
+        if(hasProper) {
+            imX->setAtLeast("F0FFFFFF2");
+        }
+        if(hasProperInterior) {
+            imX->setAtLeast("1F1FFFFFF");
+        }
+    }
+    /* If edges of LineStrings properly intersect *in an interior point*, all
+    we can deduce is that
+    the interiors intersect.  (We can NOT deduce that the exteriors intersect,
+    since some other segments in the geometries might cover the points in the
+    neighbourhood of the intersection.)
+    It is important that the point be known to be an interior point of
+    both Geometries, since it is possible in a self-intersecting geometry to
+    have a proper intersection on one segment that is also a boundary point of another segment.
+    */
+    else if(dimA == 1 && dimB == 1) {
+        if(hasProperInterior) {
+            imX->setAtLeast("0FFFFFFFF");
+        }
+    }
 }
 
 /**
@@ -306,17 +319,16 @@ RelateComputer::computeProperIntersectionIM(SegmentIntersector *intersector,Inte
 void
 RelateComputer::copyNodesAndLabels(int argIndex)
 {
-	const NodeMap* nm = (*arg)[argIndex]->getNodeMap();
-	NodeMap::const_iterator nodeIt=nm->begin(), nodeEnd=nm->end();
-
-	for( ; nodeIt!=nodeEnd; nodeIt++)
-	{
-		Node *graphNode=nodeIt->second;
-		Node *newNode=nodes.addNode(graphNode->getCoordinate());
-		newNode->setLabel(argIndex,
-				graphNode->getLabel().getLocation(argIndex));
-		//node.print(System.out);
-	}
+    const NodeMap* nm = (*arg)[argIndex]->getNodeMap();
+    NodeMap::const_iterator nodeIt = nm->begin(), nodeEnd = nm->end();
+
+    for(; nodeIt != nodeEnd; nodeIt++) {
+        Node* graphNode = nodeIt->second;
+        Node* newNode = nodes.addNode(graphNode->getCoordinate());
+        newNode->setLabel(argIndex,
+                          graphNode->getLabel().getLocation(argIndex));
+        //node.print(System.out);
+    }
 }
 
 
@@ -331,30 +343,27 @@ RelateComputer::copyNodesAndLabels(int argIndex)
 void
 RelateComputer::computeIntersectionNodes(int argIndex)
 {
-	std::vector<Edge*> *edges=(*arg)[argIndex]->getEdges();
-	for(std::vector<Edge*>::iterator i=edges->begin();i<edges->end();i++)
-	{
-		Edge *e=*i;
-		int eLoc=e->getLabel().getLocation(argIndex);
-		EdgeIntersectionList &eiL=e->getEdgeIntersectionList();
-		EdgeIntersectionList::iterator it=eiL.begin();
-		EdgeIntersectionList::iterator end=eiL.end();
-		for( ; it!=end; ++it)
-		{
-			EdgeIntersection *ei=*it;
-			assert(dynamic_cast<RelateNode*>(nodes.addNode(ei->coord)));
-			RelateNode *n=static_cast<RelateNode*>(nodes.addNode(ei->coord));
-			if (eLoc==Location::BOUNDARY)
-			{
-				n->setLabelBoundary(argIndex);
-			}
-			else
-			{
-				if (n->getLabel().isNull(argIndex))
-				  n->setLabel(argIndex,Location::INTERIOR);
-			}
-		}
-	}
+    std::vector<Edge*>* edges = (*arg)[argIndex]->getEdges();
+    for(std::vector<Edge*>::iterator i = edges->begin(); i < edges->end(); i++) {
+        Edge* e = *i;
+        int eLoc = e->getLabel().getLocation(argIndex);
+        EdgeIntersectionList& eiL = e->getEdgeIntersectionList();
+        EdgeIntersectionList::iterator it = eiL.begin();
+        EdgeIntersectionList::iterator end = eiL.end();
+        for(; it != end; ++it) {
+            EdgeIntersection* ei = *it;
+            assert(dynamic_cast<RelateNode*>(nodes.addNode(ei->coord)));
+            RelateNode* n = static_cast<RelateNode*>(nodes.addNode(ei->coord));
+            if(eLoc == Location::BOUNDARY) {
+                n->setLabelBoundary(argIndex);
+            }
+            else {
+                if(n->getLabel().isNull(argIndex)) {
+                    n->setLabel(argIndex, Location::INTERIOR);
+                }
+            }
+        }
+    }
 }
 
 /*
@@ -367,148 +376,149 @@ RelateComputer::computeIntersectionNodes(int argIndex)
 void
 RelateComputer::labelIntersectionNodes(int argIndex)
 {
-	std::vector<Edge*> *edges=(*arg)[argIndex]->getEdges();
-	for(std::vector<Edge*>::iterator i=edges->begin();i<edges->end();i++) {
-		Edge *e=*i;
-		int eLoc=e->getLabel().getLocation(argIndex);
-		EdgeIntersectionList &eiL=e->getEdgeIntersectionList();
-		EdgeIntersectionList::iterator eiIt=eiL.begin();
-		EdgeIntersectionList::iterator eiEnd=eiL.end();
-
-		for( ; eiIt!=eiEnd; ++eiIt)
-		{
-			EdgeIntersection *ei=*eiIt;
-			RelateNode *n=(RelateNode*) nodes.find(ei->coord);
-			if (n->getLabel().isNull(argIndex)) {
-				if (eLoc==Location::BOUNDARY)
-				  n->setLabelBoundary(argIndex);
-				else
-				  n->setLabel(argIndex,Location::INTERIOR);
-			}
-		}
-	}
+    std::vector<Edge*>* edges = (*arg)[argIndex]->getEdges();
+    for(std::vector<Edge*>::iterator i = edges->begin(); i < edges->end(); i++) {
+        Edge* e = *i;
+        int eLoc = e->getLabel().getLocation(argIndex);
+        EdgeIntersectionList& eiL = e->getEdgeIntersectionList();
+        EdgeIntersectionList::iterator eiIt = eiL.begin();
+        EdgeIntersectionList::iterator eiEnd = eiL.end();
+
+        for(; eiIt != eiEnd; ++eiIt) {
+            EdgeIntersection* ei = *eiIt;
+            RelateNode* n = (RelateNode*) nodes.find(ei->coord);
+            if(n->getLabel().isNull(argIndex)) {
+                if(eLoc == Location::BOUNDARY) {
+                    n->setLabelBoundary(argIndex);
+                }
+                else {
+                    n->setLabel(argIndex, Location::INTERIOR);
+                }
+            }
+        }
+    }
 }
 
 /* private */
 void
-RelateComputer::computeDisjointIM(IntersectionMatrix *imX)
+RelateComputer::computeDisjointIM(IntersectionMatrix* imX)
 {
-	const Geometry *ga=(*arg)[0]->getGeometry();
-	if (!ga->isEmpty()) {
-		imX->set(Location::INTERIOR,Location::EXTERIOR,ga->getDimension());
-		imX->set(Location::BOUNDARY,Location::EXTERIOR,ga->getBoundaryDimension());
-	}
-	const Geometry *gb=(*arg)[1]->getGeometry();
-	if (!gb->isEmpty()) {
-		imX->set(Location::EXTERIOR,Location::INTERIOR,gb->getDimension());
-		imX->set(Location::EXTERIOR,Location::BOUNDARY,gb->getBoundaryDimension());
-	}
+    const Geometry* ga = (*arg)[0]->getGeometry();
+    if(!ga->isEmpty()) {
+        imX->set(Location::INTERIOR, Location::EXTERIOR, ga->getDimension());
+        imX->set(Location::BOUNDARY, Location::EXTERIOR, ga->getBoundaryDimension());
+    }
+    const Geometry* gb = (*arg)[1]->getGeometry();
+    if(!gb->isEmpty()) {
+        imX->set(Location::EXTERIOR, Location::INTERIOR, gb->getDimension());
+        imX->set(Location::EXTERIOR, Location::BOUNDARY, gb->getBoundaryDimension());
+    }
 }
 
 
 void
 RelateComputer::labelNodeEdges()
 {
-	std::map<Coordinate*,Node*,CoordinateLessThen> &nMap=nodes.nodeMap;
-	std::map<Coordinate*,Node*,CoordinateLessThen>::iterator nodeIt;
-	for(nodeIt=nMap.begin();nodeIt!=nMap.end();nodeIt++)
-	{
-		assert(dynamic_cast<RelateNode*>(nodeIt->second));
-		RelateNode *node=static_cast<RelateNode*>(nodeIt->second);
+    std::map<Coordinate*, Node*, CoordinateLessThen>& nMap = nodes.nodeMap;
+    std::map<Coordinate*, Node*, CoordinateLessThen>::iterator nodeIt;
+    for(nodeIt = nMap.begin(); nodeIt != nMap.end(); nodeIt++) {
+        assert(dynamic_cast<RelateNode*>(nodeIt->second));
+        RelateNode* node = static_cast<RelateNode*>(nodeIt->second);
 #if GEOS_DEBUG
-    std::cerr << "RelateComputer::labelNodeEdges: "
-              << "node edges: " << *(node->getEdges())
-              << std::endl;
+        std::cerr << "RelateComputer::labelNodeEdges: "
+                  << "node edges: " << *(node->getEdges())
+                  << std::endl;
 #endif
-		node->getEdges()->computeLabelling(arg);
-		//Debug.print(node.getEdges());
-		//node.print(System.out);
-	}
+        node->getEdges()->computeLabelling(arg);
+        //Debug.print(node.getEdges());
+        //node.print(System.out);
+    }
 }
 
 /*private*/
 void
 RelateComputer::updateIM(IntersectionMatrix& imX)
 {
-	//Debug.println(im);
-	std::vector<Edge *>::iterator ei=isolatedEdges.begin();
-	for ( ; ei<isolatedEdges.end(); ++ei)
-	{
-		Edge *e=*ei;
-		e->GraphComponent::updateIM(imX);
-		//Debug.println(im);
-	}
-	std::map<Coordinate*,Node*,CoordinateLessThen> &nMap=nodes.nodeMap;
-	std::map<Coordinate*,Node*,CoordinateLessThen>::iterator nodeIt;
-	for(nodeIt=nMap.begin();nodeIt!=nMap.end();nodeIt++) {
-		RelateNode *node=(RelateNode*) nodeIt->second;
-		node->updateIM(imX);
-		//Debug.println(im);
-		node->updateIMFromEdges(imX);
-		//Debug.println(im);
-		//node.print(System.out);
-	}
+    //Debug.println(im);
+    std::vector<Edge*>::iterator ei = isolatedEdges.begin();
+    for(; ei < isolatedEdges.end(); ++ei) {
+        Edge* e = *ei;
+        e->GraphComponent::updateIM(imX);
+        //Debug.println(im);
+    }
+    std::map<Coordinate*, Node*, CoordinateLessThen>& nMap = nodes.nodeMap;
+    std::map<Coordinate*, Node*, CoordinateLessThen>::iterator nodeIt;
+    for(nodeIt = nMap.begin(); nodeIt != nMap.end(); nodeIt++) {
+        RelateNode* node = (RelateNode*) nodeIt->second;
+        node->updateIM(imX);
+        //Debug.println(im);
+        node->updateIMFromEdges(imX);
+        //Debug.println(im);
+        //node.print(System.out);
+    }
 }
 
 /*private*/
 void
-RelateComputer::labelIsolatedEdges(int thisIndex,int targetIndex)
+RelateComputer::labelIsolatedEdges(int thisIndex, int targetIndex)
 {
-	std::vector<Edge*> *edges=(*arg)[thisIndex]->getEdges();
-	for(std::vector<Edge*>::iterator i=edges->begin();i<edges->end();i++) {
-		Edge *e=*i;
-		if (e->isIsolated()) {
-			labelIsolatedEdge(e,targetIndex,(*arg)[targetIndex]->getGeometry());
-			isolatedEdges.push_back(e);
-		}
-	}
+    std::vector<Edge*>* edges = (*arg)[thisIndex]->getEdges();
+    for(std::vector<Edge*>::iterator i = edges->begin(); i < edges->end(); i++) {
+        Edge* e = *i;
+        if(e->isIsolated()) {
+            labelIsolatedEdge(e, targetIndex, (*arg)[targetIndex]->getGeometry());
+            isolatedEdges.push_back(e);
+        }
+    }
 }
 
 /* private */
 void
-RelateComputer::labelIsolatedEdge(Edge *e, int targetIndex, const Geometry *target)
+RelateComputer::labelIsolatedEdge(Edge* e, int targetIndex, const Geometry* target)
 {
-	// this won't work for GeometryCollections with both dim 2 and 1 geoms
-	if (target->getDimension()>0) {
-		// since edge is not in boundary, may not need the full generality of PointLocator?
-		// Possibly should use ptInArea locator instead?  We probably know here
-		// that the edge does not touch the bdy of the target Geometry
-		int loc=ptLocator.locate(e->getCoordinate(), target);
-		e->getLabel().setAllLocations(targetIndex,loc);
-	} else {
-		e->getLabel().setAllLocations(targetIndex,Location::EXTERIOR);
-	}
-	//System.out.println(e.getLabel());
+    // this won't work for GeometryCollections with both dim 2 and 1 geoms
+    if(target->getDimension() > 0) {
+        // since edge is not in boundary, may not need the full generality of PointLocator?
+        // Possibly should use ptInArea locator instead?  We probably know here
+        // that the edge does not touch the bdy of the target Geometry
+        int loc = ptLocator.locate(e->getCoordinate(), target);
+        e->getLabel().setAllLocations(targetIndex, loc);
+    }
+    else {
+        e->getLabel().setAllLocations(targetIndex, Location::EXTERIOR);
+    }
+    //System.out.println(e.getLabel());
 }
 
 /*private*/
 void
 RelateComputer::labelIsolatedNodes()
 {
-	NodeMap::iterator nodeIt=nodes.begin(), nodeEnd=nodes.end();
-	for( ; nodeIt!=nodeEnd; nodeIt++)
-	{
-		Node *n=nodeIt->second;
-		const Label& label = n->getLabel();
-		// isolated nodes should always have at least one geometry in their label
-		assert(label.getGeometryCount()>0); // node with empty label found
-		if (n->isIsolated()) {
-			if (label.isNull(0))
-				labelIsolatedNode(n,0);
-			else
-				labelIsolatedNode(n,1);
-		}
-	}
+    NodeMap::iterator nodeIt = nodes.begin(), nodeEnd = nodes.end();
+    for(; nodeIt != nodeEnd; nodeIt++) {
+        Node* n = nodeIt->second;
+        const Label& label = n->getLabel();
+        // isolated nodes should always have at least one geometry in their label
+        assert(label.getGeometryCount() > 0); // node with empty label found
+        if(n->isIsolated()) {
+            if(label.isNull(0)) {
+                labelIsolatedNode(n, 0);
+            }
+            else {
+                labelIsolatedNode(n, 1);
+            }
+        }
+    }
 }
 
 /* private */
 void
-RelateComputer::labelIsolatedNode(Node *n,int targetIndex)
+RelateComputer::labelIsolatedNode(Node* n, int targetIndex)
 {
-	int loc=ptLocator.locate(n->getCoordinate(),
-			(*arg)[targetIndex]->getGeometry());
-	n->getLabel().setAllLocations(targetIndex,loc);
-	//debugPrintln(n.getLabel());
+    int loc = ptLocator.locate(n->getCoordinate(),
+                               (*arg)[targetIndex]->getGeometry());
+    n->getLabel().setAllLocations(targetIndex, loc);
+    //debugPrintln(n.getLabel());
 }
 
 } // namespace geos.operation.relate
diff --git a/src/operation/relate/RelateNode.cpp b/src/operation/relate/RelateNode.cpp
index 56d8d6f..6e8d2bd 100644
--- a/src/operation/relate/RelateNode.cpp
+++ b/src/operation/relate/RelateNode.cpp
@@ -32,8 +32,8 @@ namespace geos {
 namespace operation { // geos.operation
 namespace relate { // geos.operation.relate
 
-RelateNode::RelateNode(const Coordinate& p_coord, EdgeEndStar *p_edges):
-	Node(p_coord,p_edges)
+RelateNode::RelateNode(const Coordinate& p_coord, EdgeEndStar* p_edges):
+    Node(p_coord, p_edges)
 {}
 
 RelateNode::~RelateNode()
@@ -47,16 +47,16 @@ RelateNode::~RelateNode()
 void
 RelateNode::computeIM(IntersectionMatrix& im)
 {
-	im.setAtLeastIfValid(label.getLocation(0), label.getLocation(1),0);
+    im.setAtLeastIfValid(label.getLocation(0), label.getLocation(1), 0);
 }
 
 void
 RelateNode::updateIMFromEdges(IntersectionMatrix& im)
 {
-	assert(dynamic_cast<EdgeEndBundleStar*>(edges));
-	EdgeEndBundleStar* eebs=static_cast<EdgeEndBundleStar*>(edges);
+    assert(dynamic_cast<EdgeEndBundleStar*>(edges));
+    EdgeEndBundleStar* eebs = static_cast<EdgeEndBundleStar*>(edges);
 
-	eebs->updateIM(im);
+    eebs->updateIM(im);
 }
 
 } // namespace geos.operation.relate
diff --git a/src/operation/relate/RelateNodeFactory.cpp b/src/operation/relate/RelateNodeFactory.cpp
index 3c6b422..45004e8 100644
--- a/src/operation/relate/RelateNodeFactory.cpp
+++ b/src/operation/relate/RelateNodeFactory.cpp
@@ -29,16 +29,16 @@ namespace operation { // geos.operation
 namespace relate { // geos.operation.relate
 
 Node*
-RelateNodeFactory::createNode(const Coordinate &coord) const
+RelateNodeFactory::createNode(const Coordinate& coord) const
 {
-	return new RelateNode(coord, new EdgeEndBundleStar());
+    return new RelateNode(coord, new EdgeEndBundleStar());
 }
 
-const NodeFactory &
+const NodeFactory&
 RelateNodeFactory::instance()
 {
-	static const RelateNodeFactory rnf;
-	return rnf;
+    static const RelateNodeFactory rnf;
+    return rnf;
 }
 
 
diff --git a/src/operation/relate/RelateNodeGraph.cpp b/src/operation/relate/RelateNodeGraph.cpp
index d28a1e4..28dbd68 100644
--- a/src/operation/relate/RelateNodeGraph.cpp
+++ b/src/operation/relate/RelateNodeGraph.cpp
@@ -41,41 +41,42 @@ namespace relate { // geos.operation.relate
 
 RelateNodeGraph::RelateNodeGraph()
 {
-	nodes=new NodeMap(RelateNodeFactory::instance());
+    nodes = new NodeMap(RelateNodeFactory::instance());
 }
 
-RelateNodeGraph::~RelateNodeGraph() {
-	delete nodes;
+RelateNodeGraph::~RelateNodeGraph()
+{
+    delete nodes;
 }
 
-map<Coordinate*,Node*,CoordinateLessThen>&
+map<Coordinate*, Node*, CoordinateLessThen>&
 RelateNodeGraph::getNodeMap()
 {
-	return nodes->nodeMap;
+    return nodes->nodeMap;
 }
 
 void
-RelateNodeGraph::build(GeometryGraph *geomGraph)
+RelateNodeGraph::build(GeometryGraph* geomGraph)
 {
-	// compute nodes for intersections between previously noded edges
-	computeIntersectionNodes(geomGraph,0);
+    // compute nodes for intersections between previously noded edges
+    computeIntersectionNodes(geomGraph, 0);
 
-	/**
-	 * Copy the labelling for the nodes in the parent Geometry.  These override
-	 * any labels determined by intersections.
-	 */
-	copyNodesAndLabels(geomGraph,0);
+    /**
+     * Copy the labelling for the nodes in the parent Geometry.  These override
+     * any labels determined by intersections.
+     */
+    copyNodesAndLabels(geomGraph, 0);
 
-	/**
-	 * Build EdgeEnds for all intersections.
-	 */
-	EdgeEndBuilder *eeBuilder=new EdgeEndBuilder();
-	vector<EdgeEnd*> *eeList=eeBuilder->computeEdgeEnds(geomGraph->getEdges());
-	insertEdgeEnds(eeList);
-	delete eeBuilder;
-	delete eeList;
-	//Debug.println("==== NodeList ===");
-	//Debug.print(nodes);
+    /**
+     * Build EdgeEnds for all intersections.
+     */
+    EdgeEndBuilder* eeBuilder = new EdgeEndBuilder();
+    vector<EdgeEnd*>* eeList = eeBuilder->computeEdgeEnds(geomGraph->getEdges());
+    insertEdgeEnds(eeList);
+    delete eeBuilder;
+    delete eeList;
+    //Debug.println("==== NodeList ===");
+    //Debug.print(nodes);
 }
 
 /**
@@ -89,29 +90,30 @@ RelateNodeGraph::build(GeometryGraph *geomGraph)
  * Precondition: edge intersections have been computed.
  */
 void
-RelateNodeGraph::computeIntersectionNodes(GeometryGraph *geomGraph,
-	int argIndex)
+RelateNodeGraph::computeIntersectionNodes(GeometryGraph* geomGraph,
+        int argIndex)
 {
-	vector<Edge*> *edges=geomGraph->getEdges();
-	vector<Edge*>::iterator edgeIt=edges->begin();
-	for( ; edgeIt<edges->end(); ++edgeIt)
-	{
-		Edge *e=*edgeIt;
-		int eLoc=e->getLabel().getLocation(argIndex);
-		EdgeIntersectionList &eiL=e->getEdgeIntersectionList();
-		EdgeIntersectionList::iterator eiIt=eiL.begin();
-		EdgeIntersectionList::iterator eiEnd=eiL.end();
-		for( ; eiIt!=eiEnd; ++eiIt) {
-			EdgeIntersection *ei=*eiIt;
-			RelateNode *n=(RelateNode*) nodes->addNode(ei->coord);
-			if (eLoc==Location::BOUNDARY)
-				n->setLabelBoundary(argIndex);
-			else {
-				if (n->getLabel().isNull(argIndex))
-				  n->setLabel(argIndex,Location::INTERIOR);
-			}
-		}
-	}
+    vector<Edge*>* edges = geomGraph->getEdges();
+    vector<Edge*>::iterator edgeIt = edges->begin();
+    for(; edgeIt < edges->end(); ++edgeIt) {
+        Edge* e = *edgeIt;
+        int eLoc = e->getLabel().getLocation(argIndex);
+        EdgeIntersectionList& eiL = e->getEdgeIntersectionList();
+        EdgeIntersectionList::iterator eiIt = eiL.begin();
+        EdgeIntersectionList::iterator eiEnd = eiL.end();
+        for(; eiIt != eiEnd; ++eiIt) {
+            EdgeIntersection* ei = *eiIt;
+            RelateNode* n = (RelateNode*) nodes->addNode(ei->coord);
+            if(eLoc == Location::BOUNDARY) {
+                n->setLabelBoundary(argIndex);
+            }
+            else {
+                if(n->getLabel().isNull(argIndex)) {
+                    n->setLabel(argIndex, Location::INTERIOR);
+                }
+            }
+        }
+    }
 }
 
 /**
@@ -124,25 +126,25 @@ RelateNodeGraph::computeIntersectionNodes(GeometryGraph *geomGraph,
  * in the interior due to the Boundary Determination Rule)
  */
 void
-RelateNodeGraph::copyNodesAndLabels(GeometryGraph *geomGraph,int argIndex)
+RelateNodeGraph::copyNodesAndLabels(GeometryGraph* geomGraph, int argIndex)
 {
-	map<Coordinate*,Node*,CoordinateLessThen> &nMap=geomGraph->getNodeMap()->nodeMap;
-	map<Coordinate*,Node*,CoordinateLessThen>::iterator nodeIt;
-	for(nodeIt=nMap.begin();nodeIt!=nMap.end();nodeIt++) {
-		Node *graphNode=nodeIt->second;
-		Node *newNode=nodes->addNode(graphNode->getCoordinate());
-		newNode->setLabel(argIndex,graphNode->getLabel().getLocation(argIndex));
-		//node.print(System.out);
-	}
+    map<Coordinate*, Node*, CoordinateLessThen>& nMap = geomGraph->getNodeMap()->nodeMap;
+    map<Coordinate*, Node*, CoordinateLessThen>::iterator nodeIt;
+    for(nodeIt = nMap.begin(); nodeIt != nMap.end(); nodeIt++) {
+        Node* graphNode = nodeIt->second;
+        Node* newNode = nodes->addNode(graphNode->getCoordinate());
+        newNode->setLabel(argIndex, graphNode->getLabel().getLocation(argIndex));
+        //node.print(System.out);
+    }
 }
 
 void
-RelateNodeGraph::insertEdgeEnds(vector<EdgeEnd*> *ee)
+RelateNodeGraph::insertEdgeEnds(vector<EdgeEnd*>* ee)
 {
-	for(vector<EdgeEnd*>::iterator i=ee->begin();i<ee->end();i++) {
-		EdgeEnd *e=*i;
-		nodes->add(e);
-	}
+    for(vector<EdgeEnd*>::iterator i = ee->begin(); i < ee->end(); i++) {
+        EdgeEnd* e = *i;
+        nodes->add(e);
+    }
 }
 
 } // namespace geos.operation.relate
diff --git a/src/operation/relate/RelateOp.cpp b/src/operation/relate/RelateOp.cpp
index eec74e3..88b6996 100644
--- a/src/operation/relate/RelateOp.cpp
+++ b/src/operation/relate/RelateOp.cpp
@@ -23,10 +23,10 @@
 
 // Forward declarations
 namespace geos {
-	namespace geom {
-		class IntersectionMatrix;
-		class Geometry;
-	}
+namespace geom {
+class IntersectionMatrix;
+class Geometry;
+}
 }
 
 using namespace geos::geom;
@@ -36,31 +36,31 @@ namespace operation { // geos.operation
 namespace relate { // geos.operation.relate
 
 IntersectionMatrix*
-RelateOp::relate(const Geometry *a, const Geometry *b)
+RelateOp::relate(const Geometry* a, const Geometry* b)
 {
-	RelateOp relOp(a,b);
-	return relOp.getIntersectionMatrix();
+    RelateOp relOp(a, b);
+    return relOp.getIntersectionMatrix();
 }
 
 IntersectionMatrix*
-RelateOp::relate(const Geometry *a, const Geometry *b,
-		const algorithm::BoundaryNodeRule& boundaryNodeRule)
+RelateOp::relate(const Geometry* a, const Geometry* b,
+                 const algorithm::BoundaryNodeRule& boundaryNodeRule)
 {
-	RelateOp relOp(a, b, boundaryNodeRule);
-	return relOp.getIntersectionMatrix();
+    RelateOp relOp(a, b, boundaryNodeRule);
+    return relOp.getIntersectionMatrix();
 }
 
-RelateOp::RelateOp(const Geometry *g0, const Geometry *g1):
-	GeometryGraphOperation(g0, g1),
-	relateComp(&arg)
+RelateOp::RelateOp(const Geometry* g0, const Geometry* g1):
+    GeometryGraphOperation(g0, g1),
+    relateComp(&arg)
 {
 }
 
-RelateOp::RelateOp(const Geometry *g0, const Geometry *g1,
-		const algorithm::BoundaryNodeRule& boundaryNodeRule)
-	:
-	GeometryGraphOperation(g0, g1, boundaryNodeRule),
-	relateComp(&arg)
+RelateOp::RelateOp(const Geometry* g0, const Geometry* g1,
+                   const algorithm::BoundaryNodeRule& boundaryNodeRule)
+    :
+    GeometryGraphOperation(g0, g1, boundaryNodeRule),
+    relateComp(&arg)
 {
 }
 
@@ -71,7 +71,7 @@ RelateOp::~RelateOp()
 IntersectionMatrix*
 RelateOp::getIntersectionMatrix()
 {
-	return relateComp.computeIM();
+    return relateComp.computeIM();
 }
 
 } // namespace geos.operation.relate
diff --git a/src/operation/sharedpaths/SharedPathsOp.cpp b/src/operation/sharedpaths/SharedPathsOp.cpp
index bb6d61f..d06121b 100644
--- a/src/operation/sharedpaths/SharedPathsOp.cpp
+++ b/src/operation/sharedpaths/SharedPathsOp.cpp
@@ -42,127 +42,127 @@ namespace sharedpaths { // geos.operation.sharedpaths
 /* public static */
 void
 SharedPathsOp::sharedPathsOp(const Geometry& g1, const Geometry& g2,
-    PathList& sameDirection,
-    PathList& oppositeDirection)
+                             PathList& sameDirection,
+                             PathList& oppositeDirection)
 {
-  SharedPathsOp sp(g1, g2);
-  sp.getSharedPaths(sameDirection, oppositeDirection);
+    SharedPathsOp sp(g1, g2);
+    sp.getSharedPaths(sameDirection, oppositeDirection);
 }
 
 /* public */
 SharedPathsOp::SharedPathsOp(
     const geom::Geometry& g1, const geom::Geometry& g2)
-  :
-  _g1(g1),
-  _g2(g2),
-  _gf(*g1.getFactory())
+    :
+    _g1(g1),
+    _g2(g2),
+    _gf(*g1.getFactory())
 {
-  checkLinealInput(_g1);
-  checkLinealInput(_g2);
+    checkLinealInput(_g1);
+    checkLinealInput(_g2);
 }
 
 /* private */
 void
 SharedPathsOp::checkLinealInput(const geom::Geometry& g)
 {
-  if ( ! dynamic_cast<const LineString*>(&g) &&
-       ! dynamic_cast<const MultiLineString*>(&g) )
-  {
-    throw util::IllegalArgumentException("Geometry is not lineal");
-  }
+    if(! dynamic_cast<const LineString*>(&g) &&
+            ! dynamic_cast<const MultiLineString*>(&g)) {
+        throw util::IllegalArgumentException("Geometry is not lineal");
+    }
 }
 
 /* public */
 void
 SharedPathsOp::getSharedPaths(PathList& forwDir, PathList& backDir)
 {
-  PathList paths;
-  findLinearIntersections(paths);
-  for (size_t i=0, n=paths.size(); i<n; ++i)
-  {
-    LineString* path = paths[i];
-    if ( isSameDirection(*path) ) forwDir.push_back(path);
-    else backDir.push_back(path);
-  }
+    PathList paths;
+    findLinearIntersections(paths);
+    for(size_t i = 0, n = paths.size(); i < n; ++i) {
+        LineString* path = paths[i];
+        if(isSameDirection(*path)) {
+            forwDir.push_back(path);
+        }
+        else {
+            backDir.push_back(path);
+        }
+    }
 }
 
 /* static private */
 void
 SharedPathsOp::clearEdges(PathList& edges)
 {
-  for (PathList::const_iterator
-        i=edges.begin(), e=edges.end();
-        i!=e; ++i)
-  {
-    delete *i;
-  }
-  edges.clear();
+    for(PathList::const_iterator
+            i = edges.begin(), e = edges.end();
+            i != e; ++i) {
+        delete *i;
+    }
+    edges.clear();
 }
 
 /* private */
 void
 SharedPathsOp::findLinearIntersections(PathList& to)
 {
-  using geos::operation::overlay::OverlayOp;
+    using geos::operation::overlay::OverlayOp;
 
-  // TODO: optionally use the tolerance,
-  //       snapping _g2 over _g1 ?
+    // TODO: optionally use the tolerance,
+    //       snapping _g2 over _g1 ?
 
-  std::unique_ptr<Geometry> full ( OverlayOp::overlayOp(
-    &_g1, &_g2, OverlayOp::opINTERSECTION) );
+    std::unique_ptr<Geometry> full(OverlayOp::overlayOp(
+                                       &_g1, &_g2, OverlayOp::opINTERSECTION));
 
-  // NOTE: intersection of equal lines yelds splitted lines,
-  //       should we sew them back ?
+    // NOTE: intersection of equal lines yelds splitted lines,
+    //       should we sew them back ?
 
-  for (size_t i=0, n=full->getNumGeometries(); i<n; ++i)
-  {
-    const Geometry* sub = full->getGeometryN(i);
-    const LineString* path = dynamic_cast<const LineString*>(sub);
-    if ( path && ! path->isEmpty() ) {
-      // NOTE: we're making a copy here, wouldn't be needed
-      //       for a simple predicate
-      to.push_back(_gf.createLineString(*path).release());
+    for(size_t i = 0, n = full->getNumGeometries(); i < n; ++i) {
+        const Geometry* sub = full->getGeometryN(i);
+        const LineString* path = dynamic_cast<const LineString*>(sub);
+        if(path && ! path->isEmpty()) {
+            // NOTE: we're making a copy here, wouldn't be needed
+            //       for a simple predicate
+            to.push_back(_gf.createLineString(*path).release());
+        }
     }
-  }
 }
 
 /* private */
 bool
 SharedPathsOp::isForward(const geom::LineString& edge,
-                       const geom::Geometry& geom)
+                         const geom::Geometry& geom)
 {
-  using namespace geos::linearref;
-
-  /*
-     ALGO:
-      1. find first point of edge on geom (linearref)
-      2. find second point of edge on geom (linearref)
-      3. if first < second, we're forward
-
-     PRECONDITIONS:
-      1. edge has at least 2 points
-      2. edge first two points are not equal
-      3. geom is simple
-   */
-
-  const Coordinate& pt1 = edge.getCoordinateN(0);
-  const Coordinate& pt2 = edge.getCoordinateN(1);
-
-  /*
-   * We move the coordinate somewhat closer, to avoid
-   * vertices of the geometry being checked (geom).
-   *
-   * This is mostly only needed when one of the two points
-   * of the edge is an endpoint of a _closed_ geom.
-   * We have an unit test for this...
-   */
-  Coordinate pt1i = LinearLocation::pointAlongSegmentByFraction(pt1, pt2, 0.1);
-  Coordinate pt2i = LinearLocation::pointAlongSegmentByFraction(pt1, pt2, 0.9);
-
-  LinearLocation l1 = LocationIndexOfPoint::indexOf(&geom, pt1i);
-  LinearLocation l2 = LocationIndexOfPoint::indexOf(&geom, pt2i);
-
-  return l1.compareTo(l2) < 0;
+    using namespace geos::linearref;
+
+    /*
+       ALGO:
+        1. find first point of edge on geom (linearref)
+        2. find second point of edge on geom (linearref)
+        3. if first < second, we're forward
+
+       PRECONDITIONS:
+        1. edge has at least 2 points
+        2. edge first two points are not equal
+        3. geom is simple
+     */
+
+    const Coordinate& pt1 = edge.getCoordinateN(0);
+    const Coordinate& pt2 = edge.getCoordinateN(1);
+
+    /*
+     * We move the coordinate somewhat closer, to avoid
+     * vertices of the geometry being checked (geom).
+     *
+     * This is mostly only needed when one of the two points
+     * of the edge is an endpoint of a _closed_ geom.
+     * We have an unit test for this...
+     */
+    Coordinate pt1i = LinearLocation::pointAlongSegmentByFraction(pt1, pt2, 0.1);
+    Coordinate pt2i = LinearLocation::pointAlongSegmentByFraction(pt1, pt2, 0.9);
+
+    LinearLocation l1 = LocationIndexOfPoint::indexOf(&geom, pt1i);
+    LinearLocation l2 = LocationIndexOfPoint::indexOf(&geom, pt2i);
+
+    return l1.compareTo(l2) < 0;
 }
 
 } // namespace geos.operation.sharedpaths
diff --git a/src/operation/union/CascadedPolygonUnion.cpp b/src/operation/union/CascadedPolygonUnion.cpp
index 56b43c4..a456095 100644
--- a/src/operation/union/CascadedPolygonUnion.cpp
+++ b/src/operation/union/CascadedPolygonUnion.cpp
@@ -46,50 +46,49 @@
 namespace {
 
 inline bool
-check_valid(const geos::geom::Geometry& g, const std::string& label, bool doThrow=false, bool validOnly=false)
+check_valid(const geos::geom::Geometry& g, const std::string& label, bool doThrow = false, bool validOnly = false)
 {
-  using namespace geos;
-
-  if ( dynamic_cast<const geos::geom::Lineal*>(&g) ) {
-    if ( ! validOnly ) {
-      operation::IsSimpleOp sop(g, algorithm::BoundaryNodeRule::getBoundaryEndPoint());
-      if ( ! sop.isSimple() )
-      {
-        if ( doThrow ) {
-          throw geos::util::TopologyException(
-            label + " is not simple");
+    using namespace geos;
+
+    if(dynamic_cast<const geos::geom::Lineal*>(&g)) {
+        if(! validOnly) {
+            operation::IsSimpleOp sop(g, algorithm::BoundaryNodeRule::getBoundaryEndPoint());
+            if(! sop.isSimple()) {
+                if(doThrow) {
+                    throw geos::util::TopologyException(
+                        label + " is not simple");
+                }
+                return false;
+            }
         }
-        return false;
-      }
     }
-  } else {
-    operation::valid::IsValidOp ivo(&g);
-    if ( ! ivo.isValid() )
-    {
-      using operation::valid::TopologyValidationError;
-      TopologyValidationError* err = ivo.getValidationError();
+    else {
+        operation::valid::IsValidOp ivo(&g);
+        if(! ivo.isValid()) {
+            using operation::valid::TopologyValidationError;
+            TopologyValidationError* err = ivo.getValidationError();
 #ifdef GEOS_DEBUG_CASCADED_UNION
-      std::cerr << label << " is INVALID: "
-        << err->toString()
-        << " (" << std::setprecision(20)
-        << err->getCoordinate() << ")"
-        << std::endl
+            std::cerr << label << " is INVALID: "
+                      << err->toString()
+                      << " (" << std::setprecision(20)
+                      << err->getCoordinate() << ")"
+                      << std::endl
 #ifdef GEOS_DEBUG_CASCADED_UNION_PRINT_INVALID
-        << "<a>" << std::endl
-        << g.toString() << std::endl
-        << "</a>" << std::endl
+                      << "<a>" << std::endl
+                      << g.toString() << std::endl
+                      << "</a>" << std::endl
 #endif
-        ;
+                      ;
 #endif // GEOS_DEBUG_CASCADED_UNION
-      if ( doThrow ) {
-        throw geos::util::TopologyException(
-          label + " is invalid: " + err->toString(),
-                err->getCoordinate());
-      }
-      return false;
+            if(doThrow) {
+                throw geos::util::TopologyException(
+                    label + " is invalid: " + err->toString(),
+                    err->getCoordinate());
+            }
+            return false;
+        }
     }
-  }
-  return true;
+    return true;
 }
 
 } // anonymous namespace
@@ -99,35 +98,41 @@ namespace operation { // geos.operation
 namespace geounion {  // geos.operation.geounion
 
 ///////////////////////////////////////////////////////////////////////////////
-void GeometryListHolder::deleteItem(geom::Geometry* item)
+void
+GeometryListHolder::deleteItem(geom::Geometry* item)
 {
     delete item;
 }
 
 ///////////////////////////////////////////////////////////////////////////////
-geom::Geometry* CascadedPolygonUnion::Union(std::vector<geom::Polygon*>* polys)
+geom::Geometry*
+CascadedPolygonUnion::Union(std::vector<geom::Polygon*>* polys)
 {
-    CascadedPolygonUnion op (polys);
+    CascadedPolygonUnion op(polys);
     return op.Union();
 }
 
-geom::Geometry* CascadedPolygonUnion::Union(const geom::MultiPolygon* multipoly)
+geom::Geometry*
+CascadedPolygonUnion::Union(const geom::MultiPolygon* multipoly)
 {
     std::vector<geom::Polygon*> polys;
 
     typedef geom::MultiPolygon::const_iterator iterator;
     iterator end = multipoly->end();
-    for (iterator i = multipoly->begin(); i != end; ++i)
+    for(iterator i = multipoly->begin(); i != end; ++i) {
         polys.push_back(dynamic_cast<geom::Polygon*>(*i));
+    }
 
-    CascadedPolygonUnion op (&polys);
+    CascadedPolygonUnion op(&polys);
     return op.Union();
 }
 
-geom::Geometry* CascadedPolygonUnion::Union()
+geom::Geometry*
+CascadedPolygonUnion::Union()
 {
-    if (inputPolys->empty())
+    if(inputPolys->empty()) {
         return nullptr;
+    }
 
     geomFactory = inputPolys->front()->getFactory();
 
@@ -141,17 +146,18 @@ geom::Geometry* CascadedPolygonUnion::Union()
 
     typedef std::vector<geom::Polygon*>::iterator iterator_type;
     iterator_type end = inputPolys->end();
-    for (iterator_type i = inputPolys->begin(); i != end; ++i) {
+    for(iterator_type i = inputPolys->begin(); i != end; ++i) {
         geom::Geometry* g = dynamic_cast<geom::Geometry*>(*i);
         index.insert(g->getEnvelopeInternal(), g);
     }
 
-    std::unique_ptr<index::strtree::ItemsList> itemTree (index.itemsTree());
+    std::unique_ptr<index::strtree::ItemsList> itemTree(index.itemsTree());
 
     return unionTree(itemTree.get());
 }
 
-geom::Geometry* CascadedPolygonUnion::unionTree(
+geom::Geometry*
+CascadedPolygonUnion::unionTree(
     index::strtree::ItemsList* geomTree)
 {
     /**
@@ -162,25 +168,27 @@ geom::Geometry* CascadedPolygonUnion::unionTree(
     return binaryUnion(geoms.get());
 }
 
-geom::Geometry* CascadedPolygonUnion::binaryUnion(GeometryListHolder* geoms)
+geom::Geometry*
+CascadedPolygonUnion::binaryUnion(GeometryListHolder* geoms)
 {
     return binaryUnion(geoms, 0, geoms->size());
 }
 
-geom::Geometry* CascadedPolygonUnion::binaryUnion(GeometryListHolder* geoms,
-    std::size_t start, std::size_t end)
+geom::Geometry*
+CascadedPolygonUnion::binaryUnion(GeometryListHolder* geoms,
+                                  std::size_t start, std::size_t end)
 {
-    if (end - start <= 1) {
+    if(end - start <= 1) {
         return unionSafe(geoms->getGeometry(start), nullptr);
     }
-    else if (end - start == 2) {
+    else if(end - start == 2) {
         return unionSafe(geoms->getGeometry(start), geoms->getGeometry(start + 1));
     }
     else {
         // recurse on both halves of the list
         std::size_t mid = (end + start) / 2;
-        std::unique_ptr<geom::Geometry> g0 (binaryUnion(geoms, start, mid));
-        std::unique_ptr<geom::Geometry> g1 (binaryUnion(geoms, mid, end));
+        std::unique_ptr<geom::Geometry> g0(binaryUnion(geoms, start, mid));
+        std::unique_ptr<geom::Geometry> g1(binaryUnion(geoms, mid, end));
         return unionSafe(g0.get(), g1.get());
     }
 }
@@ -188,17 +196,17 @@ geom::Geometry* CascadedPolygonUnion::binaryUnion(GeometryListHolder* geoms,
 GeometryListHolder*
 CascadedPolygonUnion::reduceToGeometries(index::strtree::ItemsList* geomTree)
 {
-    std::unique_ptr<GeometryListHolder> geoms (new GeometryListHolder());
+    std::unique_ptr<GeometryListHolder> geoms(new GeometryListHolder());
 
     typedef index::strtree::ItemsList::iterator iterator_type;
     iterator_type end = geomTree->end();
-    for (iterator_type i = geomTree->begin(); i != end; ++i) {
-        if ((*i).get_type() == index::strtree::ItemsListItem::item_is_list) {
-            std::unique_ptr<geom::Geometry> geom (unionTree((*i).get_itemslist()));
+    for(iterator_type i = geomTree->begin(); i != end; ++i) {
+        if((*i).get_type() == index::strtree::ItemsListItem::item_is_list) {
+            std::unique_ptr<geom::Geometry> geom(unionTree((*i).get_itemslist()));
             geoms->push_back_owned(geom.get());
             geom.release();
         }
-        else if ((*i).get_type() == index::strtree::ItemsListItem::item_is_geometry) {
+        else if((*i).get_type() == index::strtree::ItemsListItem::item_is_geometry) {
             geoms->push_back(reinterpret_cast<geom::Geometry*>((*i).get_geometry()));
         }
         else {
@@ -212,13 +220,16 @@ CascadedPolygonUnion::reduceToGeometries(index::strtree::ItemsList* geomTree)
 geom::Geometry*
 CascadedPolygonUnion::unionSafe(geom::Geometry* g0, geom::Geometry* g1)
 {
-    if (g0 == nullptr && g1 == nullptr)
+    if(g0 == nullptr && g1 == nullptr) {
         return nullptr;
+    }
 
-    if (g0 == nullptr)
+    if(g0 == nullptr) {
         return g1->clone();
-    if (g1 == nullptr)
+    }
+    if(g1 == nullptr) {
         return g0->clone();
+    }
 
     return unionOptimized(g0, g1);
 }
@@ -229,11 +240,13 @@ CascadedPolygonUnion::unionOptimized(geom::Geometry* g0, geom::Geometry* g1)
     geom::Envelope const* g0Env = g0->getEnvelopeInternal();
     geom::Envelope const* g1Env = g1->getEnvelopeInternal();
 
-    if (!g0Env->intersects(g1Env))
+    if(!g0Env->intersects(g1Env)) {
         return geom::util::GeometryCombiner::combine(g0, g1);
+    }
 
-    if (g0->getNumGeometries() <= 1 && g1->getNumGeometries() <= 1)
+    if(g0->getNumGeometries() <= 1 && g1->getNumGeometries() <= 1) {
         return unionActual(g0, g1);
+    }
 
     geom::Envelope commonEnv;
     g0Env->intersection(*g1Env, commonEnv);
@@ -243,7 +256,7 @@ CascadedPolygonUnion::unionOptimized(geom::Geometry* g0, geom::Geometry* g1)
 /* private */
 geom::Geometry*
 CascadedPolygonUnion::unionUsingEnvelopeIntersection(geom::Geometry* g0,
-    geom::Geometry* g1, geom::Envelope const& common)
+        geom::Geometry* g1, geom::Envelope const& common)
 {
     std::vector<geom::Geometry*> disjointPolys;
 
@@ -263,28 +276,29 @@ CascadedPolygonUnion::unionUsingEnvelopeIntersection(geom::Geometry* g0,
     std::unique_ptr<geom::Geometry> u(unionActual(g0Int.get(), g1Int.get()));
 
 #if GEOS_DEBUG_CASCADED_UNION
-    if ( ! check_valid(*u, "unionUsingEnvelopeIntersection unionActual return") )
-    {
+    if(! check_valid(*u, "unionUsingEnvelopeIntersection unionActual return")) {
 #if GEOS_DEBUG_CASCADED_UNION_PRINT_INVALID
-      std::cerr << " union between the following is invalid"
-        << "<a>" << std::endl
-        << *g0Int << std::endl
-        << "</a>" << std::endl
-        << "<b>" << std::endl
-        << *g1Int << std::endl
-        << "</b>" << std::endl
-        ;
+        std::cerr << " union between the following is invalid"
+                  << "<a>" << std::endl
+                  << *g0Int << std::endl
+                  << "</a>" << std::endl
+                  << "<b>" << std::endl
+                  << *g1Int << std::endl
+                  << "</b>" << std::endl
+                  ;
 #endif
     }
 #endif
 
-    if ( disjointPolys.empty() ) return u.release();
+    if(disjointPolys.empty()) {
+        return u.release();
+    }
 
 #if GEOS_DEBUG_CASCADED_UNION
-    for ( size_t i=0; i<disjointPolys.size(); ++i )
-    {
-      std::ostringstream os; os << "dp"<< i;
-      check_valid(*(disjointPolys[i]), os.str());
+    for(size_t i = 0; i < disjointPolys.size(); ++i) {
+        std::ostringstream os;
+        os << "dp" << i;
+        check_valid(*(disjointPolys[i]), os.str());
     }
 #endif
 
@@ -297,19 +311,21 @@ CascadedPolygonUnion::unionUsingEnvelopeIntersection(geom::Geometry* g0,
     geom::Envelope const* uEnv = u->getEnvelopeInternal(); // TODO: check for EMPTY ?
     extractByEnvelope(*uEnv, disjointPolys, polysOn, polysOff);
 #if GEOS_DEBUG_CASCADED_UNION
-    std::cerr << "unionUsingEnvelopeIntersection: " << polysOn.size() << "/" << disjointPolys.size() << " polys intersect union of final thing" << std::endl;
+    std::cerr << "unionUsingEnvelopeIntersection: " << polysOn.size() << "/" << disjointPolys.size() <<
+              " polys intersect union of final thing" << std::endl;
 #endif
 
     std::unique_ptr<geom::Geometry> ret;
-    if ( polysOn.empty() ) {
-      disjointPolys.push_back(u.get());
-      ret.reset( geom::util::GeometryCombiner::combine(disjointPolys));
-    } else {
-      // TODO: could be further tweaked to only union with polysOn
-      //       and combine with polysOff, but then it'll need again to
-      //       recurse in the check for disjoint/intersecting
-      ret.reset( geom::util::GeometryCombiner::combine(disjointPolys) );
-      ret.reset( unionActual(ret.get(), u.get()) );
+    if(polysOn.empty()) {
+        disjointPolys.push_back(u.get());
+        ret.reset(geom::util::GeometryCombiner::combine(disjointPolys));
+    }
+    else {
+        // TODO: could be further tweaked to only union with polysOn
+        //       and combine with polysOff, but then it'll need again to
+        //       recurse in the check for disjoint/intersecting
+        ret.reset(geom::util::GeometryCombiner::combine(disjointPolys));
+        ret.reset(unionActual(ret.get(), u.get()));
     }
 
 #if GEOS_DEBUG_CASCADED_UNION
@@ -322,41 +338,44 @@ CascadedPolygonUnion::unionUsingEnvelopeIntersection(geom::Geometry* g0,
 /* private */
 void
 CascadedPolygonUnion::extractByEnvelope(geom::Envelope const& env,
-    std::vector<geom::Geometry*>& sourceGeoms,
-    std::vector<geom::Geometry*>& intersectingGeoms,
-    std::vector<geom::Geometry*>& disjointGeoms)
+                                        std::vector<geom::Geometry*>& sourceGeoms,
+                                        std::vector<geom::Geometry*>& intersectingGeoms,
+                                        std::vector<geom::Geometry*>& disjointGeoms)
 {
-    for (std::vector<geom::Geometry*>::iterator i=sourceGeoms.begin(),
-         e=sourceGeoms.end(); i!=e; ++i)
-    {
+    for(std::vector<geom::Geometry*>::iterator i = sourceGeoms.begin(),
+            e = sourceGeoms.end(); i != e; ++i) {
         geom::Geometry* elem = *i;
-        if (elem->getEnvelopeInternal()->intersects(env))
+        if(elem->getEnvelopeInternal()->intersects(env)) {
             intersectingGeoms.push_back(elem);
-        else
+        }
+        else {
             disjointGeoms.push_back(elem);
+        }
     }
 }
 
 /* private */
 void
 CascadedPolygonUnion::extractByEnvelope(geom::Envelope const& env,
-    geom::Geometry* geom,
-    std::vector<geom::Geometry*>& intersectingGeoms,
-    std::vector<geom::Geometry*>& disjointGeoms)
+                                        geom::Geometry* geom,
+                                        std::vector<geom::Geometry*>& intersectingGeoms,
+                                        std::vector<geom::Geometry*>& disjointGeoms)
 {
-    for (std::size_t i = 0; i < geom->getNumGeometries(); i++) {
+    for(std::size_t i = 0; i < geom->getNumGeometries(); i++) {
         geom::Geometry* elem = const_cast<geom::Geometry*>(geom->getGeometryN(i));
-        if (elem->getEnvelopeInternal()->intersects(env))
+        if(elem->getEnvelopeInternal()->intersects(env)) {
             intersectingGeoms.push_back(elem);
-        else
+        }
+        else {
             disjointGeoms.push_back(elem);
+        }
     }
 }
 
 /* private */
 geom::Geometry*
 CascadedPolygonUnion::extractByEnvelope(geom::Envelope const& env,
-    geom::Geometry* geom, std::vector<geom::Geometry*>& disjointGeoms)
+                                        geom::Geometry* geom, std::vector<geom::Geometry*>& disjointGeoms)
 {
     std::vector<geom::Geometry*> intersectingGeoms;
     extractByEnvelope(env, geom, intersectingGeoms, disjointGeoms);
@@ -376,26 +395,27 @@ CascadedPolygonUnion::restrictToPolygons(std::unique_ptr<geom::Geometry> g)
     using namespace geom;
     using namespace std;
 
-    if ( dynamic_cast<Polygonal*>(g.get()) ) {
-      return g;
+    if(dynamic_cast<Polygonal*>(g.get())) {
+        return g;
     }
 
     Polygon::ConstVect polygons;
     geom::util::PolygonExtracter::getPolygons(*g, polygons);
 
-    if (polygons.size() == 1)
-      return std::unique_ptr<Geometry>(polygons[0]->clone());
+    if(polygons.size() == 1) {
+        return std::unique_ptr<Geometry>(polygons[0]->clone());
+    }
 
-    typedef vector<Geometry *> GeomVect;
+    typedef vector<Geometry*> GeomVect;
 
     Polygon::ConstVect::size_type n = polygons.size();
     GeomVect* newpolys = new GeomVect(n);
-    for (Polygon::ConstVect::size_type i=0; i<n; ++i) {
+    for(Polygon::ConstVect::size_type i = 0; i < n; ++i) {
         (*newpolys)[i] = polygons[i]->clone();
     }
     return unique_ptr<Geometry>(
-      g->getFactory()->createMultiPolygon(newpolys)
-    );
+               g->getFactory()->createMultiPolygon(newpolys)
+           );
 
 }
 
diff --git a/src/operation/union/CascadedUnion.cpp b/src/operation/union/CascadedUnion.cpp
index 1ac984c..e13d0c4 100644
--- a/src/operation/union/CascadedUnion.cpp
+++ b/src/operation/union/CascadedUnion.cpp
@@ -31,16 +31,19 @@ namespace geos {
 namespace operation { // geos.operation
 namespace geounion {  // geos.operation.geounion
 
-geom::Geometry* CascadedUnion::Union(std::vector<geom::Geometry*>* polys)
+geom::Geometry*
+CascadedUnion::Union(std::vector<geom::Geometry*>* polys)
 {
-    CascadedUnion op (polys);
+    CascadedUnion op(polys);
     return op.Union();
 }
 
-geom::Geometry* CascadedUnion::Union()
+geom::Geometry*
+CascadedUnion::Union()
 {
-    if (inputGeoms->empty())
+    if(inputGeoms->empty()) {
         return nullptr;
+    }
 
     geomFactory = inputGeoms->front()->getFactory();
 
@@ -54,17 +57,18 @@ geom::Geometry* CascadedUnion::Union()
 
     typedef std::vector<geom::Geometry*>::const_iterator iterator_type;
     iterator_type end = inputGeoms->end();
-    for (iterator_type i = inputGeoms->begin(); i != end; ++i) {
+    for(iterator_type i = inputGeoms->begin(); i != end; ++i) {
         geom::Geometry* g = *i;
         index.insert(g->getEnvelopeInternal(), g);
     }
 
-    std::unique_ptr<index::strtree::ItemsList> itemTree (index.itemsTree());
+    std::unique_ptr<index::strtree::ItemsList> itemTree(index.itemsTree());
 
     return unionTree(itemTree.get());
 }
 
-geom::Geometry* CascadedUnion::unionTree(
+geom::Geometry*
+CascadedUnion::unionTree(
     index::strtree::ItemsList* geomTree)
 {
     /**
@@ -75,25 +79,27 @@ geom::Geometry* CascadedUnion::unionTree(
     return binaryUnion(geoms.get());
 }
 
-geom::Geometry* CascadedUnion::binaryUnion(GeometryListHolder* geoms)
+geom::Geometry*
+CascadedUnion::binaryUnion(GeometryListHolder* geoms)
 {
     return binaryUnion(geoms, 0, geoms->size());
 }
 
-geom::Geometry* CascadedUnion::binaryUnion(GeometryListHolder* geoms,
-    std::size_t start, std::size_t end)
+geom::Geometry*
+CascadedUnion::binaryUnion(GeometryListHolder* geoms,
+                           std::size_t start, std::size_t end)
 {
-    if (end - start <= 1) {
+    if(end - start <= 1) {
         return unionSafe(geoms->getGeometry(start), nullptr);
     }
-    else if (end - start == 2) {
+    else if(end - start == 2) {
         return unionSafe(geoms->getGeometry(start), geoms->getGeometry(start + 1));
     }
     else {
         // recurse on both halves of the list
         std::size_t mid = (end + start) / 2;
-        std::unique_ptr<geom::Geometry> g0 (binaryUnion(geoms, start, mid));
-        std::unique_ptr<geom::Geometry> g1 (binaryUnion(geoms, mid, end));
+        std::unique_ptr<geom::Geometry> g0(binaryUnion(geoms, start, mid));
+        std::unique_ptr<geom::Geometry> g1(binaryUnion(geoms, mid, end));
         return unionSafe(g0.get(), g1.get());
     }
 }
@@ -101,17 +107,17 @@ geom::Geometry* CascadedUnion::binaryUnion(GeometryListHolder* geoms,
 GeometryListHolder*
 CascadedUnion::reduceToGeometries(index::strtree::ItemsList* geomTree)
 {
-    std::unique_ptr<GeometryListHolder> geoms (new GeometryListHolder());
+    std::unique_ptr<GeometryListHolder> geoms(new GeometryListHolder());
 
     typedef index::strtree::ItemsList::iterator iterator_type;
     iterator_type end = geomTree->end();
-    for (iterator_type i = geomTree->begin(); i != end; ++i) {
-        if ((*i).get_type() == index::strtree::ItemsListItem::item_is_list) {
-            std::unique_ptr<geom::Geometry> geom (unionTree((*i).get_itemslist()));
+    for(iterator_type i = geomTree->begin(); i != end; ++i) {
+        if((*i).get_type() == index::strtree::ItemsListItem::item_is_list) {
+            std::unique_ptr<geom::Geometry> geom(unionTree((*i).get_itemslist()));
             geoms->push_back_owned(geom.get());
             geom.release();
         }
-        else if ((*i).get_type() == index::strtree::ItemsListItem::item_is_geometry) {
+        else if((*i).get_type() == index::strtree::ItemsListItem::item_is_geometry) {
             geoms->push_back(reinterpret_cast<geom::Geometry*>((*i).get_geometry()));
         }
         else {
@@ -125,13 +131,16 @@ CascadedUnion::reduceToGeometries(index::strtree::ItemsList* geomTree)
 geom::Geometry*
 CascadedUnion::unionSafe(geom::Geometry* g0, geom::Geometry* g1)
 {
-    if (g0 == nullptr && g1 == nullptr)
+    if(g0 == nullptr && g1 == nullptr) {
         return nullptr;
+    }
 
-    if (g0 == nullptr)
+    if(g0 == nullptr) {
         return g1->clone();
-    if (g1 == nullptr)
+    }
+    if(g1 == nullptr) {
         return g0->clone();
+    }
 
     return unionOptimized(g0, g1);
 }
@@ -142,11 +151,13 @@ CascadedUnion::unionOptimized(geom::Geometry* g0, geom::Geometry* g1)
     geom::Envelope const* g0Env = g0->getEnvelopeInternal();
     geom::Envelope const* g1Env = g1->getEnvelopeInternal();
 
-    if (!g0Env->intersects(g1Env))
+    if(!g0Env->intersects(g1Env)) {
         return geom::util::GeometryCombiner::combine(g0, g1);
+    }
 
-    if (g0->getNumGeometries() <= 1 && g1->getNumGeometries() <= 1)
+    if(g0->getNumGeometries() <= 1 && g1->getNumGeometries() <= 1) {
         return unionActual(g0, g1);
+    }
 
     geom::Envelope commonEnv;
     g0Env->intersection(*g1Env, commonEnv);
@@ -155,7 +166,7 @@ CascadedUnion::unionOptimized(geom::Geometry* g0, geom::Geometry* g1)
 
 geom::Geometry*
 CascadedUnion::unionUsingEnvelopeIntersection(geom::Geometry* g0,
-    geom::Geometry* g1, geom::Envelope const& common)
+        geom::Geometry* g1, geom::Envelope const& common)
 {
     std::vector<geom::Geometry*> disjointPolys;
 
@@ -170,16 +181,18 @@ CascadedUnion::unionUsingEnvelopeIntersection(geom::Geometry* g0,
 
 geom::Geometry*
 CascadedUnion::extractByEnvelope(geom::Envelope const& env,
-    geom::Geometry* geom, std::vector<geom::Geometry*>& disjointGeoms)
+                                 geom::Geometry* geom, std::vector<geom::Geometry*>& disjointGeoms)
 {
     std::vector<geom::Geometry*> intersectingGeoms;
 
-    for (std::size_t i = 0; i < geom->getNumGeometries(); i++) {
+    for(std::size_t i = 0; i < geom->getNumGeometries(); i++) {
         geom::Geometry* elem = const_cast<geom::Geometry*>(geom->getGeometryN(i));
-        if (elem->getEnvelopeInternal()->intersects(env))
+        if(elem->getEnvelopeInternal()->intersects(env)) {
             intersectingGeoms.push_back(elem);
-        else
+        }
+        else {
             disjointGeoms.push_back(elem);
+        }
     }
 
     return geomFactory->buildGeometry(intersectingGeoms);
diff --git a/src/operation/union/PointGeometryUnion.cpp b/src/operation/union/PointGeometryUnion.cpp
index 5bc7988..baa6382 100644
--- a/src/operation/union/PointGeometryUnion.cpp
+++ b/src/operation/union/PointGeometryUnion.cpp
@@ -38,63 +38,64 @@ namespace geounion {  // geos::operation::geounion
 std::unique_ptr<geom::Geometry>
 PointGeometryUnion::Union() const
 {
-  using namespace geom;
-  using algorithm::PointLocator;
-  using geom::util::GeometryCombiner;
+    using namespace geom;
+    using algorithm::PointLocator;
+    using geom::util::GeometryCombiner;
 
-  PointLocator locater;
-  // use a set to eliminate duplicates, as required for union
-  std::set<Coordinate> exteriorCoords;
+    PointLocator locater;
+    // use a set to eliminate duplicates, as required for union
+    std::set<Coordinate> exteriorCoords;
 
-  for (std::size_t i=0, n=pointGeom.getNumGeometries(); i<n; ++i) {
-      const Point* point = dynamic_cast<const Point*>(pointGeom.getGeometryN(i));
-      assert(point);
-      const Coordinate* coord = point->getCoordinate();
-      int loc = locater.locate(*coord, &otherGeom);
-      if (loc == Location::EXTERIOR)
-              exteriorCoords.insert(*coord);
-  }
+    for(std::size_t i = 0, n = pointGeom.getNumGeometries(); i < n; ++i) {
+        const Point* point = dynamic_cast<const Point*>(pointGeom.getGeometryN(i));
+        assert(point);
+        const Coordinate* coord = point->getCoordinate();
+        int loc = locater.locate(*coord, &otherGeom);
+        if(loc == Location::EXTERIOR) {
+            exteriorCoords.insert(*coord);
+        }
+    }
 
-  // if no points are in exterior, return the other geom
-  if (exteriorCoords.empty())
-          return std::unique_ptr<Geometry>(otherGeom.clone());
+    // if no points are in exterior, return the other geom
+    if(exteriorCoords.empty()) {
+        return std::unique_ptr<Geometry>(otherGeom.clone());
+    }
 
-  // make a puntal geometry of appropriate size
-  std::unique_ptr<Geometry> ptComp;
+    // make a puntal geometry of appropriate size
+    std::unique_ptr<Geometry> ptComp;
 
-  if (exteriorCoords.size() == 1) {
-    ptComp.reset( geomFact->createPoint(*(exteriorCoords.begin())) );
-  }
-  else
-  {
-    std::vector<Coordinate> coords(exteriorCoords.size());
-    std::copy(exteriorCoords.begin(), exteriorCoords.end(), coords.begin());
-    ptComp.reset( geomFact->createMultiPoint(coords) );
-  }
+    if(exteriorCoords.size() == 1) {
+        ptComp.reset(geomFact->createPoint(*(exteriorCoords.begin())));
+    }
+    else {
+        std::vector<Coordinate> coords(exteriorCoords.size());
+        std::copy(exteriorCoords.begin(), exteriorCoords.end(), coords.begin());
+        ptComp.reset(geomFact->createMultiPoint(coords));
+    }
 
-  // add point component to the other geometry
-  return std::unique_ptr<Geometry> (
-    GeometryCombiner::combine(ptComp.get(), &otherGeom)
-  );
+    // add point component to the other geometry
+    return std::unique_ptr<Geometry> (
+               GeometryCombiner::combine(ptComp.get(), &otherGeom)
+           );
 }
 
 /* public  static */
 std::unique_ptr<geom::Geometry>
 PointGeometryUnion::Union(const geom::Puntal& pointGeom,
-      const geom::Geometry& otherGeom)
+                          const geom::Geometry& otherGeom)
 {
-  PointGeometryUnion unioner(pointGeom, otherGeom);
-  return unioner.Union();
+    PointGeometryUnion unioner(pointGeom, otherGeom);
+    return unioner.Union();
 }
 
 /* public */
 PointGeometryUnion::PointGeometryUnion(const geom::Puntal& pointGeom_,
-                     const geom::Geometry& otherGeom_)
-  :
-  pointGeom ( pointGeom_ ),
-  otherGeom ( otherGeom_ )
+                                       const geom::Geometry& otherGeom_)
+    :
+    pointGeom(pointGeom_),
+    otherGeom(otherGeom_)
 {
-  geomFact = otherGeom.getFactory();
+    geomFact = otherGeom.getFactory();
 }
 
 } // namespace geos::operation::union
diff --git a/src/operation/union/UnaryUnionOp.cpp b/src/operation/union/UnaryUnionOp.cpp
index 98ef035..aa1ec63 100644
--- a/src/operation/union/UnaryUnionOp.cpp
+++ b/src/operation/union/UnaryUnionOp.cpp
@@ -46,90 +46,99 @@ std::unique_ptr<geom::Geometry>
 UnaryUnionOp::unionWithNull(std::unique_ptr<geom::Geometry> g0,
                             std::unique_ptr<geom::Geometry> g1)
 {
-  std::unique_ptr<geom::Geometry> ret;
-  if ( ( ! g0.get() ) && ( ! g1.get() ) ) return ret;
-
-  if ( ! g0.get() ) return g1;
-  if ( ! g1.get() ) return g0;
-
-  ret.reset( g0->Union(g1.get()) );
-  return ret;
+    std::unique_ptr<geom::Geometry> ret;
+    if((! g0.get()) && (! g1.get())) {
+        return ret;
+    }
+
+    if(! g0.get()) {
+        return g1;
+    }
+    if(! g1.get()) {
+        return g0;
+    }
+
+    ret.reset(g0->Union(g1.get()));
+    return ret;
 }
 
 /*public*/
 std::unique_ptr<geom::Geometry>
 UnaryUnionOp::Union()
 {
-  using geom::Puntal;
-  typedef std::unique_ptr<geom::Geometry> GeomPtr;
-
-  GeomPtr ret;
-  if ( ! geomFact ) return ret;
-
-  /**
-   * For points and lines, only a single union operation is
-   * required, since the OGC model allowings self-intersecting
-   * MultiPoint and MultiLineStrings.
-   * This is not the case for polygons, so Cascaded Union is required.
-   */
-
-  GeomPtr unionPoints;
-  if (!points.empty()) {
-      GeomPtr ptGeom = geomFact->buildGeometry( points.begin(),
-                                                    points.end()    );
-      unionPoints = unionNoOpt(*ptGeom);
-  }
-
-  GeomPtr unionLines;
-  if (!lines.empty()) {
-      /* JTS compatibility NOTE:
-       * we use cascaded here for robustness [1]
-       * but also add a final unionNoOpt step to deal with
-       * self-intersecting lines [2]
-       *
-       * [1](http://trac.osgeo.org/geos/ticket/392
-       * [2](http://trac.osgeo.org/geos/ticket/482
-       *
-       */
-      unionLines.reset( CascadedUnion::Union( lines.begin(),
-                                              lines.end()   ) );
-      if (unionLines.get()) {
-          unionLines = unionNoOpt(*unionLines);
-      }
-  }
-
-  GeomPtr unionPolygons;
-  if (!polygons.empty()) {
-      unionPolygons.reset( CascadedPolygonUnion::Union( polygons.begin(),
-                                                        polygons.end()   ) );
-  }
-
-  /**
-   * Performing two unions is somewhat inefficient,
-   * but is mitigated by unioning lines and points first
-   */
-
-  GeomPtr unionLA = unionWithNull(std::move(unionLines), std::move(unionPolygons));
-  assert(!unionLines.get()); assert(!unionPolygons.get());
-
-  if ( ! unionPoints.get() ) {
-    ret = std::move(unionLA);
-    assert(!unionLA.get());
-  }
-  else if ( ! unionLA.get() ) {
-    ret = std::move(unionPoints);
-    assert(!unionPoints.get());
-  }
-  else {
-    Puntal& up = dynamic_cast<Puntal&>(*unionPoints);
-    ret = PointGeometryUnion::Union(up, *unionLA);
-  }
-
-  if ( ! ret.get() ) {
-          ret.reset( geomFact->createGeometryCollection() );
-  }
-
-  return ret;
+    using geom::Puntal;
+    typedef std::unique_ptr<geom::Geometry> GeomPtr;
+
+    GeomPtr ret;
+    if(! geomFact) {
+        return ret;
+    }
+
+    /**
+     * For points and lines, only a single union operation is
+     * required, since the OGC model allowings self-intersecting
+     * MultiPoint and MultiLineStrings.
+     * This is not the case for polygons, so Cascaded Union is required.
+     */
+
+    GeomPtr unionPoints;
+    if(!points.empty()) {
+        GeomPtr ptGeom = geomFact->buildGeometry(points.begin(),
+                         points.end());
+        unionPoints = unionNoOpt(*ptGeom);
+    }
+
+    GeomPtr unionLines;
+    if(!lines.empty()) {
+        /* JTS compatibility NOTE:
+         * we use cascaded here for robustness [1]
+         * but also add a final unionNoOpt step to deal with
+         * self-intersecting lines [2]
+         *
+         * [1](http://trac.osgeo.org/geos/ticket/392
+         * [2](http://trac.osgeo.org/geos/ticket/482
+         *
+         */
+        unionLines.reset(CascadedUnion::Union(lines.begin(),
+                                              lines.end()));
+        if(unionLines.get()) {
+            unionLines = unionNoOpt(*unionLines);
+        }
+    }
+
+    GeomPtr unionPolygons;
+    if(!polygons.empty()) {
+        unionPolygons.reset(CascadedPolygonUnion::Union(polygons.begin(),
+                            polygons.end()));
+    }
+
+    /**
+     * Performing two unions is somewhat inefficient,
+     * but is mitigated by unioning lines and points first
+     */
+
+    GeomPtr unionLA = unionWithNull(std::move(unionLines), std::move(unionPolygons));
+    assert(!unionLines.get());
+    assert(!unionPolygons.get());
+
+    if(! unionPoints.get()) {
+        ret = std::move(unionLA);
+        assert(!unionLA.get());
+    }
+    else if(! unionLA.get()) {
+        ret = std::move(unionPoints);
+        assert(!unionPoints.get());
+    }
+    else {
+        Puntal& up = dynamic_cast<Puntal&>(*unionPoints);
+        ret = PointGeometryUnion::Union(up, *unionLA);
+    }
+
+    if(! ret.get()) {
+        ret.reset(geomFact->createGeometryCollection());
+    }
+
+    return ret;
 
 }
 
diff --git a/src/operation/valid/ConnectedInteriorTester.cpp b/src/operation/valid/ConnectedInteriorTester.cpp
index 6ca5b1a..f977874 100644
--- a/src/operation/valid/ConnectedInteriorTester.cpp
+++ b/src/operation/valid/ConnectedInteriorTester.cpp
@@ -67,10 +67,10 @@ namespace geos {
 namespace operation { // geos.operation
 namespace valid { // geos.operation.valid
 
-ConnectedInteriorTester::ConnectedInteriorTester(GeometryGraph &newGeomGraph):
-	geometryFactory(GeometryFactory::create()),
-	geomGraph(newGeomGraph),
-	disconnectedRingcoord()
+ConnectedInteriorTester::ConnectedInteriorTester(GeometryGraph& newGeomGraph):
+    geometryFactory(GeometryFactory::create()),
+    geomGraph(newGeomGraph),
+    disconnectedRingcoord()
 {
 }
 
@@ -81,21 +81,21 @@ ConnectedInteriorTester::~ConnectedInteriorTester()
 Coordinate&
 ConnectedInteriorTester::getCoordinate()
 {
-	return disconnectedRingcoord;
+    return disconnectedRingcoord;
 }
 
 const Coordinate&
-ConnectedInteriorTester::findDifferentPoint(const CoordinateSequence *coord,
-		const Coordinate& pt)
+ConnectedInteriorTester::findDifferentPoint(const CoordinateSequence* coord,
+        const Coordinate& pt)
 {
-	assert(coord);
-	size_t npts=coord->getSize();
-	for(size_t i=0; i<npts; ++i)
-	{
-		if(!(coord->getAt(i)==pt))
-			return coord->getAt(i);
-	}
-	return Coordinate::getNull();
+    assert(coord);
+    size_t npts = coord->getSize();
+    for(size_t i = 0; i < npts; ++i) {
+        if(!(coord->getAt(i) == pt)) {
+            return coord->getAt(i);
+        }
+    }
+    return Coordinate::getNull();
 }
 
 /*public*/
@@ -103,134 +103,128 @@ bool
 ConnectedInteriorTester::isInteriorsConnected()
 {
 
-	// node the edges, in case holes touch the shell
-	std::vector<Edge*> splitEdges;
-	geomGraph.computeSplitEdges(&splitEdges);
+    // node the edges, in case holes touch the shell
+    std::vector<Edge*> splitEdges;
+    geomGraph.computeSplitEdges(&splitEdges);
 
-	// form the edges into rings
-	PlanarGraph graph(operation::overlay::OverlayNodeFactory::instance());
+    // form the edges into rings
+    PlanarGraph graph(operation::overlay::OverlayNodeFactory::instance());
 
-	graph.addEdges(splitEdges);
-	setInteriorEdgesInResult(graph);
-	graph.linkResultDirectedEdges();
+    graph.addEdges(splitEdges);
+    setInteriorEdgesInResult(graph);
+    graph.linkResultDirectedEdges();
 
-	std::vector<EdgeRing*> edgeRings;
-	buildEdgeRings(graph.getEdgeEnds(), edgeRings);
+    std::vector<EdgeRing*> edgeRings;
+    buildEdgeRings(graph.getEdgeEnds(), edgeRings);
 
 #if GEOS_DEBUG
-	cerr << "buildEdgeRings constructed " << edgeRings.size() << " edgeRings." << endl;
+    cerr << "buildEdgeRings constructed " << edgeRings.size() << " edgeRings." << endl;
 #endif
 
-	/*
-	 * Mark all the edges for the edgeRings corresponding to the shells
-	 * of the input polygons.
-	 *
-	 * Only ONE ring gets marked for each shell - if there are others
-	 * which remain unmarked this indicates a disconnected interior.
-	 */
-	visitShellInteriors(geomGraph.getGeometry(), graph);
+    /*
+     * Mark all the edges for the edgeRings corresponding to the shells
+     * of the input polygons.
+     *
+     * Only ONE ring gets marked for each shell - if there are others
+     * which remain unmarked this indicates a disconnected interior.
+     */
+    visitShellInteriors(geomGraph.getGeometry(), graph);
 
 #if GEOS_DEBUG
-	cerr << "after visitShellInteriors edgeRings are " << edgeRings.size() << " edgeRings." << endl;
+    cerr << "after visitShellInteriors edgeRings are " << edgeRings.size() << " edgeRings." << endl;
 #endif
 
-	/*
-	 * If there are any unvisited shell edges
-	 * (i.e. a ring which is not a hole and which has the interior
-	 * of the parent area on the RHS)
-	 * this means that one or more holes must have split the interior of the
-	 * polygon into at least two pieces.  The polygon is thus invalid.
-	 */
-	bool res=!hasUnvisitedShellEdge(&edgeRings);
+    /*
+     * If there are any unvisited shell edges
+     * (i.e. a ring which is not a hole and which has the interior
+     * of the parent area on the RHS)
+     * this means that one or more holes must have split the interior of the
+     * polygon into at least two pieces.  The polygon is thus invalid.
+     */
+    bool res = !hasUnvisitedShellEdge(&edgeRings);
 
 #if GEOS_DEBUG
-	cerr << "releasing " << edgeRings.size() << " edgeRings." << endl;
+    cerr << "releasing " << edgeRings.size() << " edgeRings." << endl;
 #endif
-	// Release memory allocated by buildEdgeRings
-	for(size_t i=0, n=edgeRings.size(); i<n; ++i)
-	{
-		EdgeRing* er = edgeRings[i];
+    // Release memory allocated by buildEdgeRings
+    for(size_t i = 0, n = edgeRings.size(); i < n; ++i) {
+        EdgeRing* er = edgeRings[i];
 #if GEOS_DEBUG
-		cerr<<*er<<endl;
+        cerr << *er << endl;
 #endif
-		assert(er);
-		delete er;
+        assert(er);
+        delete er;
 #if GEOS_DEBUG
-	cerr << "releasing edgeRing at " << er << endl;
+        cerr << "releasing edgeRing at " << er << endl;
 #endif
-	}
-	edgeRings.clear();
-
-	// Release memory allocated by MaximalEdgeRings
-	// There should be no more references to this object
-	// how to check this ? boost::shared_ptr<> comes to mind.
-	//
-	for (size_t i=0, n=maximalEdgeRings.size(); i<n; i++)
-	{
-		delete maximalEdgeRings[i];
-	}
-	maximalEdgeRings.clear();
-
-	return res;
+    }
+    edgeRings.clear();
+
+    // Release memory allocated by MaximalEdgeRings
+    // There should be no more references to this object
+    // how to check this ? boost::shared_ptr<> comes to mind.
+    //
+    for(size_t i = 0, n = maximalEdgeRings.size(); i < n; i++) {
+        delete maximalEdgeRings[i];
+    }
+    maximalEdgeRings.clear();
+
+    return res;
 }
 
 void
-ConnectedInteriorTester::setInteriorEdgesInResult(PlanarGraph &graph)
+ConnectedInteriorTester::setInteriorEdgesInResult(PlanarGraph& graph)
 {
-	std::vector<EdgeEnd*> *ee=graph.getEdgeEnds();
-	for(size_t i=0, n=ee->size(); i<n; ++i)
-	{
-		// Unexpected non DirectedEdge in graphEdgeEnds
-		assert(dynamic_cast<DirectedEdge*>((*ee)[i]));
-		DirectedEdge *de=static_cast<DirectedEdge*>((*ee)[i]);
-		if ( de->getLabel().getLocation(0, Position::RIGHT) == Location::INTERIOR)
-		{
-			de->setInResult(true);
-		}
-	}
+    std::vector<EdgeEnd*>* ee = graph.getEdgeEnds();
+    for(size_t i = 0, n = ee->size(); i < n; ++i) {
+        // Unexpected non DirectedEdge in graphEdgeEnds
+        assert(dynamic_cast<DirectedEdge*>((*ee)[i]));
+        DirectedEdge* de = static_cast<DirectedEdge*>((*ee)[i]);
+        if(de->getLabel().getLocation(0, Position::RIGHT) == Location::INTERIOR) {
+            de->setInResult(true);
+        }
+    }
 }
 
 /*private*/
 void
-ConnectedInteriorTester::buildEdgeRings(std::vector<EdgeEnd*> *dirEdges,
+ConnectedInteriorTester::buildEdgeRings(std::vector<EdgeEnd*>* dirEdges,
                                         std::vector<EdgeRing*>& minEdgeRings)
 {
 #if GEOS_DEBUG
-	cerr << __FUNCTION__ << " got " << dirEdges->size() << " EdgeEnd vector" << endl;
+    cerr << __FUNCTION__ << " got " << dirEdges->size() << " EdgeEnd vector" << endl;
 #endif
 
-	typedef std::vector<EdgeEnd*> EdgeEnds;
+    typedef std::vector<EdgeEnd*> EdgeEnds;
 
-	//std::vector<MinimalEdgeRing*> minEdgeRings;
-	for(EdgeEnds::size_type i=0, n=dirEdges->size(); i<n; ++i)
-	{
+    //std::vector<MinimalEdgeRing*> minEdgeRings;
+    for(EdgeEnds::size_type i = 0, n = dirEdges->size(); i < n; ++i) {
 #ifdef GEOS_CAST_PARANOIA
-		assert(dynamic_cast<DirectedEdge*>((*dirEdges)[i]));
+        assert(dynamic_cast<DirectedEdge*>((*dirEdges)[i]));
 #endif
-		DirectedEdge *de=static_cast<DirectedEdge*>((*dirEdges)[i]);
+        DirectedEdge* de = static_cast<DirectedEdge*>((*dirEdges)[i]);
 
 #if GEOS_DEBUG
-		cerr << "DirectedEdge " << i << ": " << de->print() << endl;
+        cerr << "DirectedEdge " << i << ": " << de->print() << endl;
 #endif
 
-		// if this edge has not yet been processed
-		if(de->isInResult() && de->getEdgeRing()==nullptr)
-		{
-			MaximalEdgeRing* er = new MaximalEdgeRing(de,
-			                                   geometryFactory.get());
-			// We track MaximalEdgeRings allocations
-			// using the private maximalEdgeRings vector
-			maximalEdgeRings.push_back(er);
-
-			er->linkDirectedEdgesForMinimalEdgeRings();
-			er->buildMinimalRings(minEdgeRings);
-		}
-	}
-/*
-	std::vector<EdgeRing*> *edgeRings=new std::vector<EdgeRing*>();
-	edgeRings->assign(minEdgeRings.begin(), minEdgeRings.end());
-	return edgeRings;
-*/
+        // if this edge has not yet been processed
+        if(de->isInResult() && de->getEdgeRing() == nullptr) {
+            MaximalEdgeRing* er = new MaximalEdgeRing(de,
+                    geometryFactory.get());
+            // We track MaximalEdgeRings allocations
+            // using the private maximalEdgeRings vector
+            maximalEdgeRings.push_back(er);
+
+            er->linkDirectedEdgesForMinimalEdgeRings();
+            er->buildMinimalRings(minEdgeRings);
+        }
+    }
+    /*
+    	std::vector<EdgeRing*> *edgeRings=new std::vector<EdgeRing*>();
+    	edgeRings->assign(minEdgeRings.begin(), minEdgeRings.end());
+    	return edgeRings;
+    */
 }
 
 /**
@@ -238,115 +232,119 @@ ConnectedInteriorTester::buildEdgeRings(std::vector<EdgeEnd*> *dirEdges,
  * of the input polygons.  Note only ONE ring gets marked for each shell.
  */
 void
-ConnectedInteriorTester::visitShellInteriors(const Geometry *g, PlanarGraph &graph)
+ConnectedInteriorTester::visitShellInteriors(const Geometry* g, PlanarGraph& graph)
 {
-	if (const Polygon* p=dynamic_cast<const Polygon*>(g))
-	{
-		visitInteriorRing(p->getExteriorRing(), graph);
-	}
-
-	if (const MultiPolygon* mp=dynamic_cast<const MultiPolygon*>(g))
-	{
-		for (size_t i=0, n=mp->getNumGeometries(); i<n; i++) {
-			const Polygon *p=dynamic_cast<const Polygon*>(mp->getGeometryN(i));
-			visitInteriorRing(p->getExteriorRing(), graph);
-		}
-	}
+    if(const Polygon* p = dynamic_cast<const Polygon*>(g)) {
+        visitInteriorRing(p->getExteriorRing(), graph);
+    }
+
+    if(const MultiPolygon* mp = dynamic_cast<const MultiPolygon*>(g)) {
+        for(size_t i = 0, n = mp->getNumGeometries(); i < n; i++) {
+            const Polygon* p = dynamic_cast<const Polygon*>(mp->getGeometryN(i));
+            visitInteriorRing(p->getExteriorRing(), graph);
+        }
+    }
 }
 
 void
-ConnectedInteriorTester::visitInteriorRing(const LineString *ring, PlanarGraph &graph)
+ConnectedInteriorTester::visitInteriorRing(const LineString* ring, PlanarGraph& graph)
 {
-	// can't visit an empty ring
-	if(ring->isEmpty()) return;
-
-	const CoordinateSequence *pts=ring->getCoordinatesRO();
-	const Coordinate& pt0=pts->getAt(0);
-
-	/**
-	 * Find first point in coord list different to initial point.
-	 * Need special check since the first point may be repeated.
-	 */
-    	const Coordinate& pt1=findDifferentPoint(pts, pt0);
-	Edge *e=graph.findEdgeInSameDirection(pt0, pt1);
-	DirectedEdge *de=static_cast<DirectedEdge*>(graph.findEdgeEnd(e));
-	DirectedEdge *intDe=nullptr;
-	if (de->getLabel().getLocation(0,Position::RIGHT)==Location::INTERIOR) {
-		intDe=de;
-	} else if (de->getSym()->getLabel().getLocation(0,Position::RIGHT)==Location::INTERIOR) {
-		intDe=de->getSym();
-	}
-	assert(intDe!=nullptr); // unable to find dirEdge with Interior on RHS
-	visitLinkedDirectedEdges(intDe);
+    // can't visit an empty ring
+    if(ring->isEmpty()) {
+        return;
+    }
+
+    const CoordinateSequence* pts = ring->getCoordinatesRO();
+    const Coordinate& pt0 = pts->getAt(0);
+
+    /**
+     * Find first point in coord list different to initial point.
+     * Need special check since the first point may be repeated.
+     */
+    const Coordinate& pt1 = findDifferentPoint(pts, pt0);
+    Edge* e = graph.findEdgeInSameDirection(pt0, pt1);
+    DirectedEdge* de = static_cast<DirectedEdge*>(graph.findEdgeEnd(e));
+    DirectedEdge* intDe = nullptr;
+    if(de->getLabel().getLocation(0, Position::RIGHT) == Location::INTERIOR) {
+        intDe = de;
+    }
+    else if(de->getSym()->getLabel().getLocation(0, Position::RIGHT) == Location::INTERIOR) {
+        intDe = de->getSym();
+    }
+    assert(intDe != nullptr); // unable to find dirEdge with Interior on RHS
+    visitLinkedDirectedEdges(intDe);
 }
 
 
 void
-ConnectedInteriorTester::visitLinkedDirectedEdges(DirectedEdge *start)
+ConnectedInteriorTester::visitLinkedDirectedEdges(DirectedEdge* start)
 {
-	DirectedEdge *startDe=start;
-	DirectedEdge *de=start;
-	//Debug.println(de);
-	do {
-		// found null Directed Edge
-		assert(de!=nullptr);
-
-		de->setVisited(true);
-		de=de->getNext();
-		//Debug.println(de);
-	} while (de!=startDe);
+    DirectedEdge* startDe = start;
+    DirectedEdge* de = start;
+    //Debug.println(de);
+    do {
+        // found null Directed Edge
+        assert(de != nullptr);
+
+        de->setVisited(true);
+        de = de->getNext();
+        //Debug.println(de);
+    }
+    while(de != startDe);
 }
 
 /*private*/
 bool
-ConnectedInteriorTester::hasUnvisitedShellEdge(std::vector<EdgeRing*> *edgeRings)
+ConnectedInteriorTester::hasUnvisitedShellEdge(std::vector<EdgeRing*>* edgeRings)
 {
 
 #if GEOS_DEBUG
-	cerr << "hasUnvisitedShellEdge called with " << edgeRings->size() << " edgeRings." << endl;
+    cerr << "hasUnvisitedShellEdge called with " << edgeRings->size() << " edgeRings." << endl;
 #endif
 
-	for(std::vector<EdgeRing*>::iterator
-		it=edgeRings->begin(), itEnd=edgeRings->end();
-		it != itEnd;
-		++it)
-	{
-		EdgeRing *er=*it;
-		assert(er);
-
-		// don't check hole rings
-		if (er->isHole()) continue;
-
-		std::vector<DirectedEdge*>& edges=er->getEdges();
-		DirectedEdge *de=edges[0];
-		assert(de);
-
-		// don't check CW rings which are holes
-		// (MD - this check may now be irrelevant - 2006-03-09)
-		if (de->getLabel().getLocation(0, Position::RIGHT) != Location::INTERIOR) continue;
-
-		/*
-		 * the edgeRing is CW ring which surrounds the INT
-		 * of the area, so check all edges have been visited.
-		 * If any are unvisited, this is a disconnected part
-		 * of the interior
-		 */
-		for(std::vector<DirectedEdge*>::iterator
-			jt=edges.begin(), jtEnd=edges.end();
-			jt != jtEnd;
-			++jt)
-		{
-			de=*jt;
-			assert(de);
-			//Debug.print("visted? "); Debug.println(de);
-			if (!de->isVisited()) {
-				//Debug.print("not visited "); Debug.println(de);
-				disconnectedRingcoord=de->getCoordinate();
-				return true;
-			}
-		}
-	}
-	return false;
+    for(std::vector<EdgeRing*>::iterator
+            it = edgeRings->begin(), itEnd = edgeRings->end();
+            it != itEnd;
+            ++it) {
+        EdgeRing* er = *it;
+        assert(er);
+
+        // don't check hole rings
+        if(er->isHole()) {
+            continue;
+        }
+
+        std::vector<DirectedEdge*>& edges = er->getEdges();
+        DirectedEdge* de = edges[0];
+        assert(de);
+
+        // don't check CW rings which are holes
+        // (MD - this check may now be irrelevant - 2006-03-09)
+        if(de->getLabel().getLocation(0, Position::RIGHT) != Location::INTERIOR) {
+            continue;
+        }
+
+        /*
+         * the edgeRing is CW ring which surrounds the INT
+         * of the area, so check all edges have been visited.
+         * If any are unvisited, this is a disconnected part
+         * of the interior
+         */
+        for(std::vector<DirectedEdge*>::iterator
+                jt = edges.begin(), jtEnd = edges.end();
+                jt != jtEnd;
+                ++jt) {
+            de = *jt;
+            assert(de);
+            //Debug.print("visted? "); Debug.println(de);
+            if(!de->isVisited()) {
+                //Debug.print("not visited "); Debug.println(de);
+                disconnectedRingcoord = de->getCoordinate();
+                return true;
+            }
+        }
+    }
+    return false;
 }
 
 } // namespace geos.operation.valid
diff --git a/src/operation/valid/ConsistentAreaTester.cpp b/src/operation/valid/ConsistentAreaTester.cpp
index 451e5b9..852df55 100644
--- a/src/operation/valid/ConsistentAreaTester.cpp
+++ b/src/operation/valid/ConsistentAreaTester.cpp
@@ -41,12 +41,12 @@ namespace geos {
 namespace operation { // geos.operation
 namespace valid { // geos.operation.valid
 
-ConsistentAreaTester::ConsistentAreaTester(GeometryGraph *newGeomGraph)
-	:
-	li(),
-	geomGraph(newGeomGraph),
-	nodeGraph(),
-	invalidPoint()
+ConsistentAreaTester::ConsistentAreaTester(GeometryGraph* newGeomGraph)
+    :
+    li(),
+    geomGraph(newGeomGraph),
+    nodeGraph(),
+    invalidPoint()
 {
 }
 
@@ -57,71 +57,69 @@ ConsistentAreaTester::~ConsistentAreaTester()
 Coordinate&
 ConsistentAreaTester::getInvalidPoint()
 {
-	return invalidPoint;
+    return invalidPoint;
 }
 
 bool
 ConsistentAreaTester::isNodeConsistentArea()
 {
-	using geomgraph::index::SegmentIntersector;
+    using geomgraph::index::SegmentIntersector;
 
-	/**
-	 * To fully check validity, it is necessary to
-	 * compute ALL intersections, including self-intersections within a single edge.
-	 */
-	unique_ptr<SegmentIntersector> intersector(geomGraph->computeSelfNodes(&li, true, true));
-	/**
-	* A proper intersection means that the area is not consistent.
-	*/
-	if (intersector->hasProperIntersection()) {
-		invalidPoint=intersector->getProperIntersectionPoint();
-		return false;
-	}
-	nodeGraph.build(geomGraph);
-	return isNodeEdgeAreaLabelsConsistent();
+    /**
+     * To fully check validity, it is necessary to
+     * compute ALL intersections, including self-intersections within a single edge.
+     */
+    unique_ptr<SegmentIntersector> intersector(geomGraph->computeSelfNodes(&li, true, true));
+    /**
+    * A proper intersection means that the area is not consistent.
+    */
+    if(intersector->hasProperIntersection()) {
+        invalidPoint = intersector->getProperIntersectionPoint();
+        return false;
+    }
+    nodeGraph.build(geomGraph);
+    return isNodeEdgeAreaLabelsConsistent();
 }
 
 /*private*/
 bool
 ConsistentAreaTester::isNodeEdgeAreaLabelsConsistent()
 {
-	assert(geomGraph);
+    assert(geomGraph);
 
-	map<Coordinate*,Node*,CoordinateLessThen>& nMap=nodeGraph.getNodeMap();
-	map<Coordinate*,Node*,CoordinateLessThen>::iterator nodeIt;
-	for(nodeIt=nMap.begin();nodeIt!=nMap.end();nodeIt++) {
-		relate::RelateNode *node=static_cast<relate::RelateNode*>(nodeIt->second);
-		if (!node->getEdges()->isAreaLabelsConsistent(*geomGraph)) {
-			invalidPoint=node->getCoordinate();
-			return false;
-		}
-	}
-	return true;
+    map<Coordinate*, Node*, CoordinateLessThen>& nMap = nodeGraph.getNodeMap();
+    map<Coordinate*, Node*, CoordinateLessThen>::iterator nodeIt;
+    for(nodeIt = nMap.begin(); nodeIt != nMap.end(); nodeIt++) {
+        relate::RelateNode* node = static_cast<relate::RelateNode*>(nodeIt->second);
+        if(!node->getEdges()->isAreaLabelsConsistent(*geomGraph)) {
+            invalidPoint = node->getCoordinate();
+            return false;
+        }
+    }
+    return true;
 }
 
 /*public*/
 bool
 ConsistentAreaTester::hasDuplicateRings()
 {
-	map<Coordinate*,Node*,CoordinateLessThen>& nMap=nodeGraph.getNodeMap();
-	map<Coordinate*,Node*,CoordinateLessThen>::iterator nodeIt;
-	for(nodeIt=nMap.begin(); nodeIt!=nMap.end(); ++nodeIt)
-	{
-		assert(dynamic_cast<relate::RelateNode*>(nodeIt->second));
-		relate::RelateNode *node=static_cast<relate::RelateNode*>(nodeIt->second);
-		EdgeEndStar *ees=node->getEdges();
-		EdgeEndStar::iterator endIt=ees->end();
-		for(EdgeEndStar::iterator it=ees->begin(); it!=endIt; ++it)
-		{
-			assert(dynamic_cast<relate::EdgeEndBundle*>(*it));
-			relate::EdgeEndBundle *eeb=static_cast<relate::EdgeEndBundle*>(*it);
-			if (eeb->getEdgeEnds()->size()>1) {
-				invalidPoint=eeb->getEdge()->getCoordinate(0);
-				return true;
-			}
-		}
-	}
-	return false;
+    map<Coordinate*, Node*, CoordinateLessThen>& nMap = nodeGraph.getNodeMap();
+    map<Coordinate*, Node*, CoordinateLessThen>::iterator nodeIt;
+    for(nodeIt = nMap.begin(); nodeIt != nMap.end(); ++nodeIt) {
+        assert(dynamic_cast<relate::RelateNode*>(nodeIt->second));
+        relate::RelateNode* node = static_cast<relate::RelateNode*>(nodeIt->second);
+        EdgeEndStar* ees = node->getEdges();
+        EdgeEndStar::iterator endIt = ees->end();
+        for(EdgeEndStar::iterator it = ees->begin(); it != endIt; ++it) {
+            assert(dynamic_cast<relate::EdgeEndBundle*>(*it));
+            relate::EdgeEndBundle* eeb = static_cast<relate::EdgeEndBundle*>(*it);
+            if(eeb->getEdgeEnds()->size() > 1) {
+                invalidPoint = eeb->getEdge()->getCoordinate(0);
+                return true;
+            }
+        }
+    }
+    return false;
 }
 
 } // namespace geos.operation.valid
diff --git a/src/operation/valid/IndexedNestedRingTester.cpp b/src/operation/valid/IndexedNestedRingTester.cpp
index c0bd588..ee33478 100644
--- a/src/operation/valid/IndexedNestedRingTester.cpp
+++ b/src/operation/valid/IndexedNestedRingTester.cpp
@@ -25,10 +25,10 @@
 
 // Forward declarations
 namespace geos {
-	namespace geom {
-		class CoordinateSequence;
-		class Envelope;
-	}
+namespace geom {
+class CoordinateSequence;
+class Envelope;
+}
 }
 
 namespace geos {
@@ -38,81 +38,80 @@ namespace valid { // geos.operation.valid
 bool
 IndexedNestedRingTester::isNonNested()
 {
-	buildIndex();
-
-	for (size_t i=0, n=rings.size(); i<n; ++i)
-	{
-		const geom::LinearRing* innerRing = rings[i];
-		const geom::CoordinateSequence *innerRingPts=innerRing->getCoordinatesRO();
-		std::vector<void*> results;
-		index->query(innerRing->getEnvelopeInternal(), results);
-		for (size_t j=0, jn=results.size(); j<jn; ++j)
-		{
-			const geom::LinearRing* searchRing = static_cast<const geom::LinearRing*>(results[j]);
-			const geom::CoordinateSequence *searchRingPts=searchRing->getCoordinatesRO();
-
-			if (innerRing==searchRing)
-				continue;
-
-			if (!innerRing->getEnvelopeInternal()->intersects(
-				searchRing->getEnvelopeInternal()))
-			{
-				continue;
-			}
-
-                        const geom::Coordinate *innerRingPt =
-				IsValidOp::findPtNotNode(innerRingPts,
-							 searchRing,
-							 graph);
-
-        /**
-         * If no non-node pts can be found, this means
-         * that the searchRing touches ALL of the innerRing vertices.
-         * This indicates an invalid polygon, since either
-         * the two holes create a disconnected interior,
-         * or they touch in an infinite number of points
-         * (i.e. along a line segment).
-         * Both of these cases are caught by other tests,
-         * so it is safe to simply skip this situation here.
-         */
-        if ( ! innerRingPt ) continue;
-
-                        // Unable to find a ring point not a node of
-			// the search ring
-			assert(innerRingPt!=nullptr);
-
-			bool isInside = algorithm::PointLocation::isInRing(
-					*innerRingPt, searchRingPts);
-
-			if (isInside) {
-				nestedPt = innerRingPt;
-				return false;
-			}
-
-		}
-	}
-
-	return true;
+    buildIndex();
+
+    for(size_t i = 0, n = rings.size(); i < n; ++i) {
+        const geom::LinearRing* innerRing = rings[i];
+        const geom::CoordinateSequence* innerRingPts = innerRing->getCoordinatesRO();
+        std::vector<void*> results;
+        index->query(innerRing->getEnvelopeInternal(), results);
+        for(size_t j = 0, jn = results.size(); j < jn; ++j) {
+            const geom::LinearRing* searchRing = static_cast<const geom::LinearRing*>(results[j]);
+            const geom::CoordinateSequence* searchRingPts = searchRing->getCoordinatesRO();
+
+            if(innerRing == searchRing) {
+                continue;
+            }
+
+            if(!innerRing->getEnvelopeInternal()->intersects(
+                        searchRing->getEnvelopeInternal())) {
+                continue;
+            }
+
+            const geom::Coordinate* innerRingPt =
+                IsValidOp::findPtNotNode(innerRingPts,
+                                         searchRing,
+                                         graph);
+
+            /**
+             * If no non-node pts can be found, this means
+             * that the searchRing touches ALL of the innerRing vertices.
+             * This indicates an invalid polygon, since either
+             * the two holes create a disconnected interior,
+             * or they touch in an infinite number of points
+             * (i.e. along a line segment).
+             * Both of these cases are caught by other tests,
+             * so it is safe to simply skip this situation here.
+             */
+            if(! innerRingPt) {
+                continue;
+            }
+
+            // Unable to find a ring point not a node of
+            // the search ring
+            assert(innerRingPt != nullptr);
+
+            bool isInside = algorithm::PointLocation::isInRing(
+                                *innerRingPt, searchRingPts);
+
+            if(isInside) {
+                nestedPt = innerRingPt;
+                return false;
+            }
+
+        }
+    }
+
+    return true;
 }
 
 IndexedNestedRingTester::~IndexedNestedRingTester()
 {
-	delete index;
-	//delete totalEnv;
+    delete index;
+    //delete totalEnv;
 }
 
 void
 IndexedNestedRingTester::buildIndex()
 {
-	delete index;
-
-	index = new index::strtree::STRtree();
-	for (size_t i=0, n=rings.size(); i<n; ++i)
-	{
-		const geom::LinearRing* ring = rings[i];
-		const geom::Envelope* env = ring->getEnvelopeInternal();
-		index->insert(env, (void*)ring);
-	}
+    delete index;
+
+    index = new index::strtree::STRtree();
+    for(size_t i = 0, n = rings.size(); i < n; ++i) {
+        const geom::LinearRing* ring = rings[i];
+        const geom::Envelope* env = ring->getEnvelopeInternal();
+        index->insert(env, (void*)ring);
+    }
 }
 
 } // namespace geos.operation.valid
diff --git a/src/operation/valid/IndexedNestedRingTester.h b/src/operation/valid/IndexedNestedRingTester.h
index a7a7568..c72e514 100644
--- a/src/operation/valid/IndexedNestedRingTester.h
+++ b/src/operation/valid/IndexedNestedRingTester.h
@@ -23,17 +23,17 @@
 
 // Forward declarations
 namespace geos {
-	namespace geom {
-		//class Envelope;
-		class Coordinate;
-		class LinearRing;
-	}
-	namespace index {
-		class SpatialIndex;
-	}
-	namespace geomgraph {
-		class GeometryGraph;
-	}
+namespace geom {
+//class Envelope;
+class Coordinate;
+class LinearRing;
+}
+namespace index {
+class SpatialIndex;
+}
+namespace geomgraph {
+class GeometryGraph;
+}
 }
 
 namespace geos {
@@ -46,58 +46,59 @@ namespace valid { // geos.operation.valid
  * index to speed up the comparisons.
  *
  */
-class IndexedNestedRingTester
-{
+class IndexedNestedRingTester {
 public:
-	// @param newGraph : ownership retained by caller
-	IndexedNestedRingTester(geomgraph::GeometryGraph* newGraph)
-		:
-		graph(newGraph),
-		//totalEnv(0),
-		index(nullptr),
-		nestedPt(nullptr)
-	{
-	}
-
-	~IndexedNestedRingTester();
-
-	/*
-	 * Be aware that the returned Coordinate (if != NULL)
-	 * will point to storage owned by one of the LinearRing
-	 * previously added. If you destroy them, this
-	 * will point to an invalid memory address.
-	 */
-	const geom::Coordinate* getNestedPoint() const
-	{
-		return nestedPt;
-	}
-
-	/// @param ring : ownership retained by caller
-	void add(const geom::LinearRing* ring)
-	{
-		rings.push_back(ring);
-	}
-
-	bool isNonNested();
+    // @param newGraph : ownership retained by caller
+    IndexedNestedRingTester(geomgraph::GeometryGraph* newGraph)
+        :
+        graph(newGraph),
+        //totalEnv(0),
+        index(nullptr),
+        nestedPt(nullptr)
+    {
+    }
+
+    ~IndexedNestedRingTester();
+
+    /*
+     * Be aware that the returned Coordinate (if != NULL)
+     * will point to storage owned by one of the LinearRing
+     * previously added. If you destroy them, this
+     * will point to an invalid memory address.
+     */
+    const geom::Coordinate*
+    getNestedPoint() const
+    {
+        return nestedPt;
+    }
+
+    /// @param ring : ownership retained by caller
+    void
+    add(const geom::LinearRing* ring)
+    {
+        rings.push_back(ring);
+    }
+
+    bool isNonNested();
 
 private:
 
-	/// Externally owned
-	geomgraph::GeometryGraph* graph;
+    /// Externally owned
+    geomgraph::GeometryGraph* graph;
 
-	/// Ownership of this vector elements are externally owned
-	std::vector<const geom::LinearRing*> rings;
+    /// Ownership of this vector elements are externally owned
+    std::vector<const geom::LinearRing*> rings;
 
-	// CHECK: Owned by (seems unused)?
-	//geom::Envelope* totalEnv;
+    // CHECK: Owned by (seems unused)?
+    //geom::Envelope* totalEnv;
 
-	// Owned by us (use unique_ptr ?)
-	geos::index::SpatialIndex* index; // 'index' in JTS
+    // Owned by us (use unique_ptr ?)
+    geos::index::SpatialIndex* index; // 'index' in JTS
 
-	// Externally owned, if not null
-	const geom::Coordinate *nestedPt;
+    // Externally owned, if not null
+    const geom::Coordinate* nestedPt;
 
-	void buildIndex();
+    void buildIndex();
 };
 
 } // namespace geos.operation.valid
diff --git a/src/operation/valid/IsValidOp.cpp b/src/operation/valid/IsValidOp.cpp
index 9d9a47e..7e3f1cc 100644
--- a/src/operation/valid/IsValidOp.cpp
+++ b/src/operation/valid/IsValidOp.cpp
@@ -64,19 +64,19 @@ namespace valid { // geos.operation.valid
  *
  * @return the point found, or <code>null</code> if none found
  */
-const Coordinate *
-IsValidOp::findPtNotNode(const CoordinateSequence *testCoords,
-                         const LinearRing *searchRing, GeometryGraph *graph)
+const Coordinate*
+IsValidOp::findPtNotNode(const CoordinateSequence* testCoords,
+                         const LinearRing* searchRing, GeometryGraph* graph)
 {
     // find edge corresponding to searchRing.
-    Edge *searchEdge=graph->findEdge(searchRing);
+    Edge* searchEdge = graph->findEdge(searchRing);
     // find a point in the testCoords which is not a node of the searchRing
-    EdgeIntersectionList &eiList=searchEdge->getEdgeIntersectionList();
+    EdgeIntersectionList& eiList = searchEdge->getEdgeIntersectionList();
     // somewhat inefficient - is there a better way? (Use a node map, for instance?)
     auto npts = testCoords->getSize();
-    for(unsigned int i=0; i<npts; ++i) {
-        const Coordinate& pt=testCoords->getAt(i);
-        if (!eiList.isIntersection(pt)) {
+    for(unsigned int i = 0; i < npts; ++i) {
+        const Coordinate& pt = testCoords->getAt(i);
+        if(!eiList.isIntersection(pt)) {
             return &pt;
         }
     }
@@ -88,27 +88,31 @@ bool
 IsValidOp::isValid()
 {
     checkValid();
-    return validErr==nullptr;
+    return validErr == nullptr;
 }
 
 /* static public */
 bool
-IsValidOp::isValid(const Coordinate &coord)
+IsValidOp::isValid(const Coordinate& coord)
 {
-    if (! std::isfinite(coord.x) ) return false;
-    if (! std::isfinite(coord.y) ) return false;
+    if(! std::isfinite(coord.x)) {
+        return false;
+    }
+    if(! std::isfinite(coord.y)) {
+        return false;
+    }
     return true;
 }
 
 /* static public */
 bool
-IsValidOp::isValid(const Geometry &g)
+IsValidOp::isValid(const Geometry& g)
 {
     IsValidOp op(&g);
     return op.isValid();
 }
 
-TopologyValidationError *
+TopologyValidationError*
 IsValidOp::getValidationError()
 {
     checkValid();
@@ -118,45 +122,57 @@ IsValidOp::getValidationError()
 void
 IsValidOp::checkValid()
 {
-    if (isChecked) return;
+    if(isChecked) {
+        return;
+    }
     checkValid(parentGeometry);
-    isChecked=true;
+    isChecked = true;
 }
 
 void
-IsValidOp::checkValid(const Geometry *g)
+IsValidOp::checkValid(const Geometry* g)
 {
-    assert( validErr == nullptr );
+    assert(validErr == nullptr);
 
-    if (nullptr == g)
+    if(nullptr == g) {
         return;
+    }
 
     // empty geometries are always valid!
-    if (g->isEmpty()) return;
+    if(g->isEmpty()) {
+        return;
+    }
 
-    if ( const Point* x1 = dynamic_cast<const Point*>(g) )
+    if(const Point* x1 = dynamic_cast<const Point*>(g)) {
         checkValid(x1);
+    }
     // LineString also handles LinearRings, so we check LinearRing first
-    else if ( const LinearRing* x2 = dynamic_cast<const LinearRing*>(g) )
+    else if(const LinearRing* x2 = dynamic_cast<const LinearRing*>(g)) {
         checkValid(x2);
-    else if ( const LineString* x3 = dynamic_cast<const LineString*>(g) )
+    }
+    else if(const LineString* x3 = dynamic_cast<const LineString*>(g)) {
         checkValid(x3);
-    else if ( const Polygon* x4 = dynamic_cast<const Polygon*>(g) )
+    }
+    else if(const Polygon* x4 = dynamic_cast<const Polygon*>(g)) {
         checkValid(x4);
-    else if ( const MultiPolygon* x5 = dynamic_cast<const MultiPolygon*>(g) )
+    }
+    else if(const MultiPolygon* x5 = dynamic_cast<const MultiPolygon*>(g)) {
         checkValid(x5);
-    else if ( const GeometryCollection* x6 =
-                  dynamic_cast<const GeometryCollection*>(g) ) {
+    }
+    else if(const GeometryCollection* x6 =
+                dynamic_cast<const GeometryCollection*>(g)) {
         checkValid(x6);
     }
-    else throw util::UnsupportedOperationException();
+    else {
+        throw util::UnsupportedOperationException();
+    }
 }
 
 /*
  * Checks validity of a Point.
  */
 void
-IsValidOp::checkValid(const Point *g)
+IsValidOp::checkValid(const Point* g)
 {
     checkInvalidCoordinates(g->getCoordinatesRO());
 }
@@ -165,10 +181,12 @@ IsValidOp::checkValid(const Point *g)
  * Checks validity of a LineString.  Almost anything goes for linestrings!
  */
 void
-IsValidOp::checkValid(const LineString *g)
+IsValidOp::checkValid(const LineString* g)
 {
     checkInvalidCoordinates(g->getCoordinatesRO());
-    if (validErr != nullptr) return;
+    if(validErr != nullptr) {
+        return;
+    }
 
     GeometryGraph graph(0, g);
     checkTooFewPoints(&graph);
@@ -178,17 +196,23 @@ IsValidOp::checkValid(const LineString *g)
  * Checks validity of a LinearRing.
  */
 void
-IsValidOp::checkValid(const LinearRing *g)
+IsValidOp::checkValid(const LinearRing* g)
 {
     checkInvalidCoordinates(g->getCoordinatesRO());
-    if (validErr != nullptr) return;
+    if(validErr != nullptr) {
+        return;
+    }
 
     checkClosedRing(g);
-    if (validErr != nullptr) return;
+    if(validErr != nullptr) {
+        return;
+    }
 
     GeometryGraph graph(0, g);
     checkTooFewPoints(&graph);
-    if (validErr!=nullptr) return;
+    if(validErr != nullptr) {
+        return;
+    }
 
     LineIntersector li;
     delete graph.computeSelfNodes(&li, true, true);
@@ -200,100 +224,132 @@ IsValidOp::checkValid(const LinearRing *g)
  * Sets the validErr flag.
  */
 void
-IsValidOp::checkValid(const Polygon *g)
+IsValidOp::checkValid(const Polygon* g)
 {
     checkInvalidCoordinates(g);
-    if (validErr != nullptr) return;
+    if(validErr != nullptr) {
+        return;
+    }
 
     checkClosedRings(g);
-    if (validErr != nullptr) return;
+    if(validErr != nullptr) {
+        return;
+    }
 
     GeometryGraph graph(0, g);
 
     checkTooFewPoints(&graph);
-    if (validErr!=nullptr) return;
+    if(validErr != nullptr) {
+        return;
+    }
 
     checkConsistentArea(&graph);
-    if (validErr!=nullptr) return;
+    if(validErr != nullptr) {
+        return;
+    }
 
-    if (!isSelfTouchingRingFormingHoleValid) {
+    if(!isSelfTouchingRingFormingHoleValid) {
         checkNoSelfIntersectingRings(&graph);
-        if (validErr!=nullptr) return;
+        if(validErr != nullptr) {
+            return;
+        }
     }
 
     checkHolesInShell(g, &graph);
-    if (validErr!=nullptr) return;
+    if(validErr != nullptr) {
+        return;
+    }
 
     checkHolesNotNested(g, &graph);
-    if (validErr!=nullptr) return;
+    if(validErr != nullptr) {
+        return;
+    }
 
     checkConnectedInteriors(graph);
 }
 
 void
-IsValidOp::checkValid(const MultiPolygon *g)
+IsValidOp::checkValid(const MultiPolygon* g)
 {
     auto ngeoms = g->getNumGeometries();
-    vector<const Polygon *>polys(ngeoms);
+    vector<const Polygon*>polys(ngeoms);
 
-    for (size_t i=0; i < ngeoms; ++i) {
-        const Polygon *p = dynamic_cast<const Polygon *>(g->getGeometryN(i));
+    for(size_t i = 0; i < ngeoms; ++i) {
+        const Polygon* p = dynamic_cast<const Polygon*>(g->getGeometryN(i));
 
         checkInvalidCoordinates(p);
-        if (validErr != nullptr) return;
+        if(validErr != nullptr) {
+            return;
+        }
 
         checkClosedRings(p);
-        if (validErr != nullptr) return;
+        if(validErr != nullptr) {
+            return;
+        }
 
-        polys[i]=p;
+        polys[i] = p;
     }
 
     GeometryGraph graph(0, g);
 
     checkTooFewPoints(&graph);
-    if (validErr!=nullptr) return;
+    if(validErr != nullptr) {
+        return;
+    }
 
     checkConsistentArea(&graph);
-    if (validErr!=nullptr) return;
+    if(validErr != nullptr) {
+        return;
+    }
 
-    if (!isSelfTouchingRingFormingHoleValid) {
+    if(!isSelfTouchingRingFormingHoleValid) {
         checkNoSelfIntersectingRings(&graph);
-        if (validErr!=nullptr) return;
+        if(validErr != nullptr) {
+            return;
+        }
     }
 
-    for(unsigned int i=0; i<ngeoms; ++i) {
-        const Polygon *p=polys[i];
+    for(unsigned int i = 0; i < ngeoms; ++i) {
+        const Polygon* p = polys[i];
         checkHolesInShell(p, &graph);
-        if (validErr!=nullptr) return;
+        if(validErr != nullptr) {
+            return;
+        }
     }
 
-    for(unsigned int i=0; i<ngeoms; ++i) {
-        const Polygon *p=polys[i];
+    for(unsigned int i = 0; i < ngeoms; ++i) {
+        const Polygon* p = polys[i];
         checkHolesNotNested(p, &graph);
-        if (validErr!=nullptr) return;
+        if(validErr != nullptr) {
+            return;
+        }
     }
 
     checkShellsNotNested(g, &graph);
-    if (validErr!=nullptr) return;
+    if(validErr != nullptr) {
+        return;
+    }
 
     checkConnectedInteriors(graph);
 }
 
 void
-IsValidOp::checkValid(const GeometryCollection *gc)
+IsValidOp::checkValid(const GeometryCollection* gc)
 {
-    for(size_t i = 0, ngeoms=gc->getNumGeometries(); i < ngeoms; ++i) {
-        const Geometry *g=gc->getGeometryN(i);
+    for(size_t i = 0, ngeoms = gc->getNumGeometries(); i < ngeoms; ++i) {
+        const Geometry* g = gc->getGeometryN(i);
         checkValid(g);
-        if (validErr!=nullptr) return;
+        if(validErr != nullptr) {
+            return;
+        }
     }
 }
 
 void
-IsValidOp::checkTooFewPoints(GeometryGraph *graph)
+IsValidOp::checkTooFewPoints(GeometryGraph* graph)
 {
-    if (graph->hasTooFewPoints()) {
-        validErr=new TopologyValidationError(
+    if(graph->hasTooFewPoints()) {
+        validErr = new TopologyValidationError(
             TopologyValidationError::eTooFewPoints,
             graph->getInvalidPoint());
         return;
@@ -309,20 +365,20 @@ IsValidOp::checkTooFewPoints(GeometryGraph *graph)
  * @see ConsistentAreaTester
  */
 void
-IsValidOp::checkConsistentArea(GeometryGraph *graph)
+IsValidOp::checkConsistentArea(GeometryGraph* graph)
 {
     ConsistentAreaTester cat(graph);
-    bool isValidArea=cat.isNodeConsistentArea();
+    bool isValidArea = cat.isNodeConsistentArea();
 
-    if (!isValidArea) {
-        validErr=new TopologyValidationError(
+    if(!isValidArea) {
+        validErr = new TopologyValidationError(
             TopologyValidationError::eSelfIntersection,
             cat.getInvalidPoint());
         return;
     }
 
-    if (cat.hasDuplicateRings()) {
-        validErr=new TopologyValidationError(
+    if(cat.hasDuplicateRings()) {
+        validErr = new TopologyValidationError(
             TopologyValidationError::eDuplicatedRings,
             cat.getInvalidPoint());
     }
@@ -331,32 +387,34 @@ IsValidOp::checkConsistentArea(GeometryGraph *graph)
 
 /*private*/
 void
-IsValidOp::checkNoSelfIntersectingRings(GeometryGraph *graph)
+IsValidOp::checkNoSelfIntersectingRings(GeometryGraph* graph)
 {
-    vector<Edge*> *edges=graph->getEdges();
-    for(unsigned int i=0; i<edges->size(); ++i) {
-        Edge *e=(*edges)[i];
+    vector<Edge*>* edges = graph->getEdges();
+    for(unsigned int i = 0; i < edges->size(); ++i) {
+        Edge* e = (*edges)[i];
         checkNoSelfIntersectingRing(e->getEdgeIntersectionList());
-        if(validErr!=nullptr) return;
+        if(validErr != nullptr) {
+            return;
+        }
     }
 }
 
 /*private*/
 void
-IsValidOp::checkNoSelfIntersectingRing(EdgeIntersectionList &eiList)
+IsValidOp::checkNoSelfIntersectingRing(EdgeIntersectionList& eiList)
 {
     set<const Coordinate*, CoordinateLessThen>nodeSet;
-    bool isFirst=true;
-    EdgeIntersectionList::iterator it=eiList.begin();
-    EdgeIntersectionList::iterator end=eiList.end();
-    for(; it!=end; ++it) {
-        EdgeIntersection *ei=*it;
-        if (isFirst) {
-            isFirst=false;
+    bool isFirst = true;
+    EdgeIntersectionList::iterator it = eiList.begin();
+    EdgeIntersectionList::iterator end = eiList.end();
+    for(; it != end; ++it) {
+        EdgeIntersection* ei = *it;
+        if(isFirst) {
+            isFirst = false;
             continue;
         }
-        if (nodeSet.find(&ei->coord)!=nodeSet.end()) {
-            validErr=new TopologyValidationError(
+        if(nodeSet.find(&ei->coord) != nodeSet.end()) {
+            validErr = new TopologyValidationError(
                 TopologyValidationError::eRingSelfIntersection,
                 ei->coord);
             return;
@@ -369,14 +427,14 @@ IsValidOp::checkNoSelfIntersectingRing(EdgeIntersectionList &eiList)
 
 /*private*/
 void
-IsValidOp::checkHolesInShell(const Polygon *p, GeometryGraph *graph)
+IsValidOp::checkHolesInShell(const Polygon* p, GeometryGraph* graph)
 {
     assert(dynamic_cast<const LinearRing*>(p->getExteriorRing()));
 
-    const LinearRing *shell = static_cast<const LinearRing*>(
+    const LinearRing* shell = static_cast<const LinearRing*>(
                                   p->getExteriorRing());
 
-    const Geometry *shellgeom = static_cast<const Geometry*>(shell);
+    const Geometry* shellgeom = static_cast<const Geometry*>(shell);
 
     auto nholes = p->getNumInteriorRing();
 
@@ -385,11 +443,11 @@ IsValidOp::checkHolesInShell(const Polygon *p, GeometryGraph *graph)
             assert(dynamic_cast<const LinearRing*>(
                        p->getInteriorRingN(i)));
 
-            const LinearRing *hole=static_cast<const LinearRing*>(
-                                       p->getInteriorRingN(i));
+            const LinearRing* hole = static_cast<const LinearRing*>(
+                                         p->getInteriorRingN(i));
 
             if(!hole->isEmpty()) {
-                validErr=new TopologyValidationError(
+                validErr = new TopologyValidationError(
                     TopologyValidationError::eHoleOutsideShell);
                 return;
             }
@@ -404,22 +462,24 @@ IsValidOp::checkHolesInShell(const Polygon *p, GeometryGraph *graph)
         assert(dynamic_cast<const LinearRing*>(
                    p->getInteriorRingN(i)));
 
-        const LinearRing *hole=static_cast<const LinearRing*>(
-                                   p->getInteriorRingN(i));
+        const LinearRing* hole = static_cast<const LinearRing*>(
+                                     p->getInteriorRingN(i));
 
-        const Coordinate *holePt=findPtNotNode(
-                                     hole->getCoordinatesRO(), shell, graph);
+        const Coordinate* holePt = findPtNotNode(
+                                       hole->getCoordinatesRO(), shell, graph);
 
         /**
          * If no non-node hole vertex can be found, the hole must
          * split the polygon into disconnected interiors.
          * This will be caught by a subsequent check.
          */
-        if (holePt == nullptr) return;
+        if(holePt == nullptr) {
+            return;
+        }
 
         bool outside = (geom::Location::EXTERIOR == ipial.locate(holePt));
-        if (outside) {
-            validErr=new TopologyValidationError(
+        if(outside) {
+            validErr = new TopologyValidationError(
                 TopologyValidationError::eHoleOutsideShell,
                 *holePt);
             return;
@@ -429,7 +489,7 @@ IsValidOp::checkHolesInShell(const Polygon *p, GeometryGraph *graph)
 
 /*private*/
 void
-IsValidOp::checkHolesNotNested(const Polygon *p, GeometryGraph *graph)
+IsValidOp::checkHolesNotNested(const Polygon* p, GeometryGraph* graph)
 {
     //SimpleNestedRingTester nestedTester(graph);
     //SweeplineNestedRingTester nestedTester(graph);
@@ -441,18 +501,20 @@ IsValidOp::checkHolesNotNested(const Polygon *p, GeometryGraph *graph)
         assert(dynamic_cast<const LinearRing*>(
                    p->getInteriorRingN(i)));
 
-        const LinearRing *innerHole=static_cast<const LinearRing*>(
-                                        p->getInteriorRingN(i));
+        const LinearRing* innerHole = static_cast<const LinearRing*>(
+                                          p->getInteriorRingN(i));
 
         //empty holes always pass
-        if(innerHole->isEmpty()) continue;
+        if(innerHole->isEmpty()) {
+            continue;
+        }
 
         nestedTester.add(innerHole);
     }
 
-    bool isNonNested=nestedTester.isNonNested();
-    if (!isNonNested) {
-        validErr=new TopologyValidationError(
+    bool isNonNested = nestedTester.isNonNested();
+    if(!isNonNested) {
+        validErr = new TopologyValidationError(
             TopologyValidationError::eNestedHoles,
             *(nestedTester.getNestedPoint()));
     }
@@ -460,59 +522,69 @@ IsValidOp::checkHolesNotNested(const Polygon *p, GeometryGraph *graph)
 
 /*private*/
 void
-IsValidOp::checkShellsNotNested(const MultiPolygon *mp, GeometryGraph *graph)
+IsValidOp::checkShellsNotNested(const MultiPolygon* mp, GeometryGraph* graph)
 {
     for(size_t i = 0, ngeoms = mp->getNumGeometries(); i < ngeoms; ++i) {
-        const Polygon *p=dynamic_cast<const Polygon *>(
-                             mp->getGeometryN(i));
+        const Polygon* p = dynamic_cast<const Polygon*>(
+                               mp->getGeometryN(i));
         assert(p);
 
-        const LinearRing *shell=dynamic_cast<const LinearRing*>(
-                                    p->getExteriorRing());
+        const LinearRing* shell = dynamic_cast<const LinearRing*>(
+                                      p->getExteriorRing());
         assert(shell);
 
         for(size_t j = 0; j < ngeoms; ++j) {
-            if (i==j) continue;
+            if(i == j) {
+                continue;
+            }
 
-            const Polygon *p2 = dynamic_cast<const Polygon *>(
+            const Polygon* p2 = dynamic_cast<const Polygon*>(
                                     mp->getGeometryN(j));
             assert(p2);
 
-            if (shell->isEmpty() || p2->isEmpty()) continue;
+            if(shell->isEmpty() || p2->isEmpty()) {
+                continue;
+            }
 
             checkShellNotNested(shell, p2, graph);
 
-            if (validErr!=nullptr) return;
+            if(validErr != nullptr) {
+                return;
+            }
         }
     }
 }
 
 /*private*/
 void
-IsValidOp::checkShellNotNested(const LinearRing *shell, const Polygon *p,
-                               GeometryGraph *graph)
+IsValidOp::checkShellNotNested(const LinearRing* shell, const Polygon* p,
+                               GeometryGraph* graph)
 {
-    const CoordinateSequence *shellPts=shell->getCoordinatesRO();
+    const CoordinateSequence* shellPts = shell->getCoordinatesRO();
 
     // test if shell is inside polygon shell
     assert(dynamic_cast<const LinearRing*>(
                p->getExteriorRing()));
-    const LinearRing *polyShell=static_cast<const LinearRing*>(
-                                    p->getExteriorRing());
-    const CoordinateSequence *polyPts=polyShell->getCoordinatesRO();
-    const Coordinate *shellPt=findPtNotNode(shellPts, polyShell, graph);
+    const LinearRing* polyShell = static_cast<const LinearRing*>(
+                                      p->getExteriorRing());
+    const CoordinateSequence* polyPts = polyShell->getCoordinatesRO();
+    const Coordinate* shellPt = findPtNotNode(shellPts, polyShell, graph);
 
     // if no point could be found, we can assume that the shell
     // is outside the polygon
-    if (shellPt==nullptr) return;
+    if(shellPt == nullptr) {
+        return;
+    }
 
-    bool insidePolyShell=PointLocation::isInRing(*shellPt, polyPts);
-    if (!insidePolyShell) return;
+    bool insidePolyShell = PointLocation::isInRing(*shellPt, polyPts);
+    if(!insidePolyShell) {
+        return;
+    }
 
     // if no holes, this is an error!
     auto nholes = p->getNumInteriorRing();
-    if (nholes<=0) {
-        validErr=new TopologyValidationError(
+    if(nholes <= 0) {
+        validErr = new TopologyValidationError(
             TopologyValidationError::eNestedShells,
             *shellPt);
         return;
@@ -525,47 +597,53 @@ IsValidOp::checkShellNotNested(const LinearRing *shell, const Polygon *p,
      * Otherwise, the shell is not properly contained in a hole, which is
      * an error.
      */
-    const Coordinate *badNestedPt=nullptr;
+    const Coordinate* badNestedPt = nullptr;
     for(size_t i = 0; i < nholes; ++i) {
         assert(dynamic_cast<const LinearRing*>(
                    p->getInteriorRingN(i)));
-        const LinearRing *hole=static_cast<const LinearRing*>(
-                                   p->getInteriorRingN(i));
+        const LinearRing* hole = static_cast<const LinearRing*>(
+                                     p->getInteriorRingN(i));
         badNestedPt = checkShellInsideHole(shell, hole, graph);
-        if (badNestedPt==nullptr) return;
+        if(badNestedPt == nullptr) {
+            return;
+        }
     }
-    validErr=new TopologyValidationError(
+    validErr = new TopologyValidationError(
         TopologyValidationError::eNestedShells, *badNestedPt
     );
 }
 
 /*private*/
-const Coordinate *
-IsValidOp::checkShellInsideHole(const LinearRing *shell,
-                                const LinearRing *hole,
-                                GeometryGraph *graph)
+const Coordinate*
+IsValidOp::checkShellInsideHole(const LinearRing* shell,
+                                const LinearRing* hole,
+                                GeometryGraph* graph)
 {
-    const CoordinateSequence *shellPts=shell->getCoordinatesRO();
-    const CoordinateSequence *holePts=hole->getCoordinatesRO();
+    const CoordinateSequence* shellPts = shell->getCoordinatesRO();
+    const CoordinateSequence* holePts = hole->getCoordinatesRO();
 
     // TODO: improve performance of this - by sorting pointlists
     // for instance?
-    const Coordinate *shellPt=findPtNotNode(shellPts, hole, graph);
+    const Coordinate* shellPt = findPtNotNode(shellPts, hole, graph);
 
     // if point is on shell but not hole, check that the shell is
     // inside the hole
-    if (shellPt) {
-        bool insideHole=PointLocation::isInRing(*shellPt, holePts);
-        if (!insideHole) return shellPt;
+    if(shellPt) {
+        bool insideHole = PointLocation::isInRing(*shellPt, holePts);
+        if(!insideHole) {
+            return shellPt;
+        }
     }
 
-    const Coordinate *holePt=findPtNotNode(holePts, shell, graph);
+    const Coordinate* holePt = findPtNotNode(holePts, shell, graph);
 
     // if point is on hole but not shell, check that the hole is
     // outside the shell
-    if (holePt) {
-        bool insideShell=PointLocation::isInRing(*holePt, shellPts);
-        if (insideShell) return holePt;
+    if(holePt) {
+        bool insideShell = PointLocation::isInRing(*holePt, shellPts);
+        if(insideShell) {
+            return holePt;
+        }
         return nullptr;
     }
     assert(0); // points in shell and hole appear to be equal
@@ -574,11 +652,11 @@ IsValidOp::checkShellInsideHole(const LinearRing *shell,
 
 /*private*/
 void
-IsValidOp::checkConnectedInteriors(GeometryGraph &graph)
+IsValidOp::checkConnectedInteriors(GeometryGraph& graph)
 {
     ConnectedInteriorTester cit(graph);
-    if (!cit.isInteriorsConnected()) {
-        validErr=new TopologyValidationError(
+    if(!cit.isInteriorsConnected()) {
+        validErr = new TopologyValidationError(
             TopologyValidationError::eDisconnectedInterior,
             cit.getCoordinate());
     }
@@ -587,11 +665,11 @@ IsValidOp::checkConnectedInteriors(GeometryGraph &graph)
 
 /*private*/
 void
-IsValidOp::checkInvalidCoordinates(const CoordinateSequence *cs)
+IsValidOp::checkInvalidCoordinates(const CoordinateSequence* cs)
 {
     auto size = cs->size();
-    for (size_t i = 0; i < size; ++i) {
-        if (! isValid(cs->getAt(i)) ) {
+    for(size_t i = 0; i < size; ++i) {
+        if(! isValid(cs->getAt(i))) {
             validErr = new TopologyValidationError(
                 TopologyValidationError::eInvalidCoordinate,
                 cs->getAt(i));
@@ -603,41 +681,49 @@ IsValidOp::checkInvalidCoordinates(const CoordinateSequence *cs)
 
 /*private*/
 void
-IsValidOp::checkInvalidCoordinates(const Polygon *poly)
+IsValidOp::checkInvalidCoordinates(const Polygon* poly)
 {
     checkInvalidCoordinates(poly->getExteriorRing()->getCoordinatesRO());
-    if (validErr != nullptr) return;
+    if(validErr != nullptr) {
+        return;
+    }
 
     auto nholes = poly->getNumInteriorRing();
-    for (size_t i = 0; i < nholes; ++i) {
+    for(size_t i = 0; i < nholes; ++i) {
         checkInvalidCoordinates(
             poly->getInteriorRingN(i)->getCoordinatesRO()
         );
-        if (validErr != nullptr) return;
+        if(validErr != nullptr) {
+            return;
+        }
     }
 }
 
 /*private*/
 void
-IsValidOp::checkClosedRings(const Polygon *poly)
+IsValidOp::checkClosedRings(const Polygon* poly)
 {
-    const LinearRing *lr=(const LinearRing *)poly->getExteriorRing();
+    const LinearRing* lr = (const LinearRing*)poly->getExteriorRing();
     checkClosedRing(lr);
-    if (validErr) return;
+    if(validErr) {
+        return;
+    }
 
     auto nholes = poly->getNumInteriorRing();
-    for (size_t i = 0; i < nholes; ++i) {
-        lr=(const LinearRing *)poly->getInteriorRingN(i);
+    for(size_t i = 0; i < nholes; ++i) {
+        lr = (const LinearRing*)poly->getInteriorRingN(i);
         checkClosedRing(lr);
-        if (validErr) return;
+        if(validErr) {
+            return;
+        }
     }
 }
 
 /*private*/
 void
-IsValidOp::checkClosedRing(const LinearRing *ring)
+IsValidOp::checkClosedRing(const LinearRing* ring)
 {
-    if ( ! ring->isClosed() && ! ring->isEmpty() ) {
+    if(! ring->isClosed() && ! ring->isEmpty()) {
         validErr = new TopologyValidationError(
             TopologyValidationError::eRingNotClosed,
             ring->getCoordinateN(0));
diff --git a/src/operation/valid/QuadtreeNestedRingTester.cpp b/src/operation/valid/QuadtreeNestedRingTester.cpp
index e8889e5..ecad166 100644
--- a/src/operation/valid/QuadtreeNestedRingTester.cpp
+++ b/src/operation/valid/QuadtreeNestedRingTester.cpp
@@ -38,92 +38,93 @@ namespace geos {
 namespace operation { // geos.operation
 namespace valid { // geos.operation.valid
 
-QuadtreeNestedRingTester::QuadtreeNestedRingTester(GeometryGraph *newGraph):
-	graph(newGraph),
-	rings(),
-	totalEnv(),
-	qt(nullptr),
-	nestedPt(nullptr)
+QuadtreeNestedRingTester::QuadtreeNestedRingTester(GeometryGraph* newGraph):
+    graph(newGraph),
+    rings(),
+    totalEnv(),
+    qt(nullptr),
+    nestedPt(nullptr)
 {
 }
 
 QuadtreeNestedRingTester::~QuadtreeNestedRingTester()
 {
-	//delete rings;
-	//delete totalEnv;
-	delete qt;
+    //delete rings;
+    //delete totalEnv;
+    delete qt;
 }
 
-Coordinate *
+Coordinate*
 QuadtreeNestedRingTester::getNestedPoint()
 {
-	return nestedPt;
+    return nestedPt;
 }
 
 void
-QuadtreeNestedRingTester::add(const LinearRing *ring)
+QuadtreeNestedRingTester::add(const LinearRing* ring)
 {
-	rings.push_back(ring);
-	const Envelope *envi=ring->getEnvelopeInternal();
-	totalEnv.expandToInclude(envi);
+    rings.push_back(ring);
+    const Envelope* envi = ring->getEnvelopeInternal();
+    totalEnv.expandToInclude(envi);
 }
 
 bool
 QuadtreeNestedRingTester::isNonNested()
 {
-	buildQuadtree();
-	for(size_t i=0, ni=rings.size(); i<ni; ++i)
-	{
-		const LinearRing *innerRing=rings[i];
-		const CoordinateSequence *innerRingPts=innerRing->getCoordinatesRO();
-		const Envelope *envi=innerRing->getEnvelopeInternal();
-
-		vector<void*> results;
-		qt->query(envi, results);
-		for(size_t j=0, nj=results.size(); j<nj; ++j)
-		{
-			LinearRing *searchRing=(LinearRing*)results[j];
-			const CoordinateSequence *searchRingPts=searchRing->getCoordinatesRO();
-
-			if (innerRing==searchRing) continue;
-
-			const Envelope *e1=innerRing->getEnvelopeInternal();
-			const Envelope *e2=searchRing->getEnvelopeInternal();
-			if (!e1->intersects(e2)) continue;
-
-			const Coordinate *innerRingPt=IsValidOp::findPtNotNode(innerRingPts,
-					searchRing, graph);
-
-			// Unable to find a ring point not a node of the search ring
-			assert(innerRingPt!=nullptr);
-
-			bool isInside=PointLocation::isInRing(*innerRingPt,searchRingPts);
-			if (isInside) {
-				/*
-				 * innerRingPt is const just because the input
-				 * CoordinateSequence is const. If the input
-				 * Polygon survives lifetime of this object
-				 * we are safe.
-				 */
-				nestedPt=const_cast<Coordinate *>(innerRingPt);
-				return false;
-			}
-		}
-	}
-	return true;
+    buildQuadtree();
+    for(size_t i = 0, ni = rings.size(); i < ni; ++i) {
+        const LinearRing* innerRing = rings[i];
+        const CoordinateSequence* innerRingPts = innerRing->getCoordinatesRO();
+        const Envelope* envi = innerRing->getEnvelopeInternal();
+
+        vector<void*> results;
+        qt->query(envi, results);
+        for(size_t j = 0, nj = results.size(); j < nj; ++j) {
+            LinearRing* searchRing = (LinearRing*)results[j];
+            const CoordinateSequence* searchRingPts = searchRing->getCoordinatesRO();
+
+            if(innerRing == searchRing) {
+                continue;
+            }
+
+            const Envelope* e1 = innerRing->getEnvelopeInternal();
+            const Envelope* e2 = searchRing->getEnvelopeInternal();
+            if(!e1->intersects(e2)) {
+                continue;
+            }
+
+            const Coordinate* innerRingPt = IsValidOp::findPtNotNode(innerRingPts,
+                                            searchRing, graph);
+
+            // Unable to find a ring point not a node of the search ring
+            assert(innerRingPt != nullptr);
+
+            bool isInside = PointLocation::isInRing(*innerRingPt, searchRingPts);
+            if(isInside) {
+                /*
+                 * innerRingPt is const just because the input
+                 * CoordinateSequence is const. If the input
+                 * Polygon survives lifetime of this object
+                 * we are safe.
+                 */
+                nestedPt = const_cast<Coordinate*>(innerRingPt);
+                return false;
+            }
+        }
+    }
+    return true;
 }
 
 void
 QuadtreeNestedRingTester::buildQuadtree()
 {
-	qt=new Quadtree();
-	for(size_t i=0, n=rings.size(); i<n; ++i)
-	{
-		const LinearRing *ring=rings[i];
-		const Envelope *env=ring->getEnvelopeInternal();
-
-		qt->insert(env, (void*)ring);
-	}
+    qt = new Quadtree();
+    for(size_t i = 0, n = rings.size(); i < n; ++i) {
+        const LinearRing* ring = rings[i];
+        const Envelope* env = ring->getEnvelopeInternal();
+
+        qt->insert(env, (void*)ring);
+    }
 }
 
 } // namespace geos.operation.valid
diff --git a/src/operation/valid/RepeatedPointTester.cpp b/src/operation/valid/RepeatedPointTester.cpp
index d128a54..7947fc0 100644
--- a/src/operation/valid/RepeatedPointTester.cpp
+++ b/src/operation/valid/RepeatedPointTester.cpp
@@ -40,109 +40,109 @@ namespace valid { // geos.operation.valid
 Coordinate&
 RepeatedPointTester::getCoordinate()
 {
-	return repeatedCoord;
+    return repeatedCoord;
 }
 
 bool
-RepeatedPointTester::hasRepeatedPoint(const Geometry *g)
+RepeatedPointTester::hasRepeatedPoint(const Geometry* g)
 {
-	if (g->isEmpty()) return false;
-
-	if ( dynamic_cast<const Point*>(g) ) return false;
-	if ( dynamic_cast<const MultiPoint*>(g) ) return false;
-
-	// LineString also handles LinearRings
-	if ( const LineString* x = dynamic_cast<const LineString*>(g) )
-  {
-    return hasRepeatedPoint(x->getCoordinatesRO());
-  }
-
-	if ( const Polygon* x = dynamic_cast<const Polygon*>(g) )
-  {
-    return hasRepeatedPoint(x);
-  }
-
-	if ( const MultiPolygon* x = dynamic_cast<const MultiPolygon*>(g) )
-  {
-    return hasRepeatedPoint(x);
-  }
-
-	if ( const MultiLineString* x = dynamic_cast<const MultiLineString*>(g) )
-  {
-    return hasRepeatedPoint(x);
-  }
-
-	if ( const GeometryCollection* x = dynamic_cast<const GeometryCollection*>(g) )
-  {
-    return hasRepeatedPoint(x);
-  }
-
-	throw util::UnsupportedOperationException(typeid(*g).name());
+    if(g->isEmpty()) {
+        return false;
+    }
+
+    if(dynamic_cast<const Point*>(g)) {
+        return false;
+    }
+    if(dynamic_cast<const MultiPoint*>(g)) {
+        return false;
+    }
+
+    // LineString also handles LinearRings
+    if(const LineString* x = dynamic_cast<const LineString*>(g)) {
+        return hasRepeatedPoint(x->getCoordinatesRO());
+    }
+
+    if(const Polygon* x = dynamic_cast<const Polygon*>(g)) {
+        return hasRepeatedPoint(x);
+    }
+
+    if(const MultiPolygon* x = dynamic_cast<const MultiPolygon*>(g)) {
+        return hasRepeatedPoint(x);
+    }
+
+    if(const MultiLineString* x = dynamic_cast<const MultiLineString*>(g)) {
+        return hasRepeatedPoint(x);
+    }
+
+    if(const GeometryCollection* x = dynamic_cast<const GeometryCollection*>(g)) {
+        return hasRepeatedPoint(x);
+    }
+
+    throw util::UnsupportedOperationException(typeid(*g).name());
 }
 
 bool
-RepeatedPointTester::hasRepeatedPoint(const CoordinateSequence *coord)
+RepeatedPointTester::hasRepeatedPoint(const CoordinateSequence* coord)
 {
-	auto npts=coord->getSize();
-	for(size_t i=1; i<npts; ++i)
-	{
-		if (coord->getAt(i - 1)==coord->getAt(i)) {
-			repeatedCoord=coord->getAt(i);
-			return true;
-		}
-	}
-	return false;
+    auto npts = coord->getSize();
+    for(size_t i = 1; i < npts; ++i) {
+        if(coord->getAt(i - 1) == coord->getAt(i)) {
+            repeatedCoord = coord->getAt(i);
+            return true;
+        }
+    }
+    return false;
 }
 
 bool
-RepeatedPointTester::hasRepeatedPoint(const Polygon *p)
+RepeatedPointTester::hasRepeatedPoint(const Polygon* p)
 {
-	if (hasRepeatedPoint(p->getExteriorRing()->getCoordinates()))
-	{
-		return true;
-	}
-
-	for(size_t i=0, n=p->getNumInteriorRing(); i<n; ++i)
-	{
-		if (hasRepeatedPoint(p->getInteriorRingN(i)->getCoordinates()))
-		{
-			return true;
-		}
-	}
-	return false;
+    if(hasRepeatedPoint(p->getExteriorRing()->getCoordinates())) {
+        return true;
+    }
+
+    for(size_t i = 0, n = p->getNumInteriorRing(); i < n; ++i) {
+        if(hasRepeatedPoint(p->getInteriorRingN(i)->getCoordinates())) {
+            return true;
+        }
+    }
+    return false;
 }
 
 bool
-RepeatedPointTester::hasRepeatedPoint(const GeometryCollection *gc)
+RepeatedPointTester::hasRepeatedPoint(const GeometryCollection* gc)
 {
-	for(size_t i=0, n=gc->getNumGeometries(); i<n; ++i)
-	{
-		const Geometry *g=gc->getGeometryN(i);
-		if (hasRepeatedPoint(g)) return true;
-	}
-	return false;
+    for(size_t i = 0, n = gc->getNumGeometries(); i < n; ++i) {
+        const Geometry* g = gc->getGeometryN(i);
+        if(hasRepeatedPoint(g)) {
+            return true;
+        }
+    }
+    return false;
 }
 
 bool
-RepeatedPointTester::hasRepeatedPoint(const MultiPolygon *gc)
+RepeatedPointTester::hasRepeatedPoint(const MultiPolygon* gc)
 {
-	for(size_t i=0, n=gc->getNumGeometries(); i<n; ++i)
-	{
-		const Geometry *g=gc->getGeometryN(i);
-		if (hasRepeatedPoint(g)) return true;
-	}
-	return false;
+    for(size_t i = 0, n = gc->getNumGeometries(); i < n; ++i) {
+        const Geometry* g = gc->getGeometryN(i);
+        if(hasRepeatedPoint(g)) {
+            return true;
+        }
+    }
+    return false;
 }
 
 bool
-RepeatedPointTester::hasRepeatedPoint(const MultiLineString *gc)
+RepeatedPointTester::hasRepeatedPoint(const MultiLineString* gc)
 {
-	for(size_t i=0, n=gc->getNumGeometries(); i<n; ++i)
-	{
-		const Geometry *g=gc->getGeometryN(i);
-		if (hasRepeatedPoint(g)) return true;
-	}
-	return false;
+    for(size_t i = 0, n = gc->getNumGeometries(); i < n; ++i) {
+        const Geometry* g = gc->getGeometryN(i);
+        if(hasRepeatedPoint(g)) {
+            return true;
+        }
+    }
+    return false;
 }
 
 } // namespace geos.operation.valid
diff --git a/src/operation/valid/SimpleNestedRingTester.cpp b/src/operation/valid/SimpleNestedRingTester.cpp
index 31aa8f0..06e22e3 100644
--- a/src/operation/valid/SimpleNestedRingTester.cpp
+++ b/src/operation/valid/SimpleNestedRingTester.cpp
@@ -35,34 +35,36 @@ namespace valid { // geos.operation.valid
 bool
 SimpleNestedRingTester::isNonNested()
 {
-	for(size_t i=0, ni=rings.size(); i<ni; i++) {
-		LinearRing* innerRing=rings[i];
-		CoordinateSequence *innerRingPts=innerRing->getCoordinates();
-		for(size_t j=0, nj=rings.size(); j<nj; j++) {
-			LinearRing* searchRing=rings[j];
-			CoordinateSequence *searchRingPts=searchRing->getCoordinates();
-			if (innerRing==searchRing)
-				continue;
-			if (!innerRing->getEnvelopeInternal()->intersects(searchRing->getEnvelopeInternal()))
-				continue;
-			const Coordinate *innerRingPt=IsValidOp::findPtNotNode(innerRingPts,searchRing,graph);
-			// Unable to find a ring point not a node of the search ring
-			assert(innerRingPt!=nullptr);
+    for(size_t i = 0, ni = rings.size(); i < ni; i++) {
+        LinearRing* innerRing = rings[i];
+        CoordinateSequence* innerRingPts = innerRing->getCoordinates();
+        for(size_t j = 0, nj = rings.size(); j < nj; j++) {
+            LinearRing* searchRing = rings[j];
+            CoordinateSequence* searchRingPts = searchRing->getCoordinates();
+            if(innerRing == searchRing) {
+                continue;
+            }
+            if(!innerRing->getEnvelopeInternal()->intersects(searchRing->getEnvelopeInternal())) {
+                continue;
+            }
+            const Coordinate* innerRingPt = IsValidOp::findPtNotNode(innerRingPts, searchRing, graph);
+            // Unable to find a ring point not a node of the search ring
+            assert(innerRingPt != nullptr);
 
-			bool isInside=PointLocation::isInRing(*innerRingPt,searchRingPts);
-			if (isInside) {
-				/*
-				 * innerRingPt is const just because the input
-				 * CoordinateSequence is const. If the input
-				 * Polygon survives lifetime of this object
-				 * we are safe.
-				 */
-				nestedPt=const_cast<Coordinate *>(innerRingPt);
-				return false;
-			}
-		}
-	}
-	return true;
+            bool isInside = PointLocation::isInRing(*innerRingPt, searchRingPts);
+            if(isInside) {
+                /*
+                 * innerRingPt is const just because the input
+                 * CoordinateSequence is const. If the input
+                 * Polygon survives lifetime of this object
+                 * we are safe.
+                 */
+                nestedPt = const_cast<Coordinate*>(innerRingPt);
+                return false;
+            }
+        }
+    }
+    return true;
 }
 
 } // namespace geos.operation.valid
diff --git a/src/operation/valid/SweeplineNestedRingTester.cpp b/src/operation/valid/SweeplineNestedRingTester.cpp
index 298f66e..33a6157 100644
--- a/src/operation/valid/SweeplineNestedRingTester.cpp
+++ b/src/operation/valid/SweeplineNestedRingTester.cpp
@@ -34,69 +34,73 @@ namespace geos {
 namespace operation { // geos.operation
 namespace valid { // geos.operation.valid
 
-SweeplineNestedRingTester::OverlapAction::OverlapAction(SweeplineNestedRingTester *p)
+SweeplineNestedRingTester::OverlapAction::OverlapAction(SweeplineNestedRingTester* p)
 {
-	isNonNested=true;
-	parent=p;
+    isNonNested = true;
+    parent = p;
 }
 
 void
-SweeplineNestedRingTester::OverlapAction::overlap(SweepLineInterval *s0, SweepLineInterval *s1)
+SweeplineNestedRingTester::OverlapAction::overlap(SweepLineInterval* s0, SweepLineInterval* s1)
 {
-	LinearRing *innerRing=(LinearRing*) s0->getItem();
-	LinearRing *searchRing=(LinearRing*) s1->getItem();
-	if (innerRing==searchRing) return;
-	if (parent->isInside(innerRing, searchRing))
-		isNonNested=false;
+    LinearRing* innerRing = (LinearRing*) s0->getItem();
+    LinearRing* searchRing = (LinearRing*) s1->getItem();
+    if(innerRing == searchRing) {
+        return;
+    }
+    if(parent->isInside(innerRing, searchRing)) {
+        isNonNested = false;
+    }
 }
 
 
 bool
 SweeplineNestedRingTester::isNonNested()
 {
-	buildIndex();
-	OverlapAction *action=new OverlapAction(this);
-	sweepLine->computeOverlaps(action);
-	return action->isNonNested;
+    buildIndex();
+    OverlapAction* action = new OverlapAction(this);
+    sweepLine->computeOverlaps(action);
+    return action->isNonNested;
 }
 
 void
 SweeplineNestedRingTester::buildIndex()
 {
-	sweepLine=new SweepLineIndex();
-	for(size_t i=0, n=rings.size(); i<n; i++) {
-		LinearRing *ring=rings[i];
-		const Envelope *env=ring->getEnvelopeInternal();
-		SweepLineInterval *sweepInt=new SweepLineInterval(env->getMinX(),env->getMaxX(),ring);
-		sweepLine->add(sweepInt);
-	}
+    sweepLine = new SweepLineIndex();
+    for(size_t i = 0, n = rings.size(); i < n; i++) {
+        LinearRing* ring = rings[i];
+        const Envelope* env = ring->getEnvelopeInternal();
+        SweepLineInterval* sweepInt = new SweepLineInterval(env->getMinX(), env->getMaxX(), ring);
+        sweepLine->add(sweepInt);
+    }
 }
 
 bool
-SweeplineNestedRingTester::isInside(LinearRing *innerRing,LinearRing *searchRing)
+SweeplineNestedRingTester::isInside(LinearRing* innerRing, LinearRing* searchRing)
 {
-	CoordinateSequence *innerRingPts=innerRing->getCoordinates();
-	CoordinateSequence *searchRingPts=searchRing->getCoordinates();
+    CoordinateSequence* innerRingPts = innerRing->getCoordinates();
+    CoordinateSequence* searchRingPts = searchRing->getCoordinates();
 
-	if (!innerRing->getEnvelopeInternal()->intersects(searchRing->getEnvelopeInternal()))
-		return false;
-	const Coordinate *innerRingPt=IsValidOp::findPtNotNode(innerRingPts, searchRing, graph);
+    if(!innerRing->getEnvelopeInternal()->intersects(searchRing->getEnvelopeInternal())) {
+        return false;
+    }
+    const Coordinate* innerRingPt = IsValidOp::findPtNotNode(innerRingPts, searchRing, graph);
 
-	// Unable to find a ring point not a node of the search ring
-	assert(innerRingPt!=nullptr);
+    // Unable to find a ring point not a node of the search ring
+    assert(innerRingPt != nullptr);
 
-	bool p_isInside = PointLocation::isInRing(*innerRingPt,searchRingPts);
-	if (p_isInside) {
-		/*
-		 * innerRingPt is const just because the input
-		 * CoordinateSequence is const. If the input
-		 * Polygon survives lifetime of this object
-		 * we are safe.
-		 */
-		nestedPt=const_cast<Coordinate *>(innerRingPt);
-		return true;
-	}
-	return false;
+    bool p_isInside = PointLocation::isInRing(*innerRingPt, searchRingPts);
+    if(p_isInside) {
+        /*
+         * innerRingPt is const just because the input
+         * CoordinateSequence is const. If the input
+         * Polygon survives lifetime of this object
+         * we are safe.
+         */
+        nestedPt = const_cast<Coordinate*>(innerRingPt);
+        return true;
+    }
+    return false;
 }
 
 } // namespace geos.operation.valid
diff --git a/src/operation/valid/TopologyValidationError.cpp b/src/operation/valid/TopologyValidationError.cpp
index 07b97de..b1422be 100644
--- a/src/operation/valid/TopologyValidationError.cpp
+++ b/src/operation/valid/TopologyValidationError.cpp
@@ -29,58 +29,58 @@ namespace geos {
 namespace operation { // geos.operation
 namespace valid { // geos.operation.valid
 
-const char* TopologyValidationError::errMsg[]={
-	"Topology Validation Error",
-	"Repeated Point",
-	"Hole lies outside shell",
-	"Holes are nested",
-	"Interior is disconnected",
-	"Self-intersection",
-	"Ring Self-intersection",
-	"Nested shells",
-	"Duplicate Rings",
-	"Too few points in geometry component",
-	"Invalid Coordinate",
-	"Ring is not closed"
+const char* TopologyValidationError::errMsg[] = {
+    "Topology Validation Error",
+    "Repeated Point",
+    "Hole lies outside shell",
+    "Holes are nested",
+    "Interior is disconnected",
+    "Self-intersection",
+    "Ring Self-intersection",
+    "Nested shells",
+    "Duplicate Rings",
+    "Too few points in geometry component",
+    "Invalid Coordinate",
+    "Ring is not closed"
 };
 
 TopologyValidationError::TopologyValidationError(int newErrorType,
-		const Coordinate& newPt)
-	:
-	errorType(newErrorType),
-	pt(newPt)
+        const Coordinate& newPt)
+    :
+    errorType(newErrorType),
+    pt(newPt)
 {
 }
 
 TopologyValidationError::TopologyValidationError(int newErrorType)
-	:
-	errorType(newErrorType),
-	pt(Coordinate::getNull())
+    :
+    errorType(newErrorType),
+    pt(Coordinate::getNull())
 {
 }
 
 int
 TopologyValidationError::getErrorType()
 {
-	return errorType;
+    return errorType;
 }
 
 Coordinate&
 TopologyValidationError::getCoordinate()
 {
-	return pt;
+    return pt;
 }
 
 string
 TopologyValidationError::getMessage()
 {
-	return string(errMsg[errorType]);
+    return string(errMsg[errorType]);
 }
 
 string
 TopologyValidationError::toString()
 {
-	return getMessage().append(" at or near point ").append(pt.toString());
+    return getMessage().append(" at or near point ").append(pt.toString());
 }
 
 } // namespace geos.operation.valid
diff --git a/src/planargraph/DirectedEdge.cpp b/src/planargraph/DirectedEdge.cpp
index 5987359..8b8a4ba 100644
--- a/src/planargraph/DirectedEdge.cpp
+++ b/src/planargraph/DirectedEdge.cpp
@@ -32,105 +32,104 @@ namespace planargraph {
 void
 DirectedEdge::toEdges(vector<DirectedEdge*>& dirEdges, vector<Edge*>& edges)
 {
-	for (size_t i=0, n=dirEdges.size(); i<n; ++i)
-	{
-		edges.push_back(dirEdges[i]->parentEdge);
-	}
+    for(size_t i = 0, n = dirEdges.size(); i < n; ++i) {
+        edges.push_back(dirEdges[i]->parentEdge);
+    }
 }
 
 /*public*/
 vector<Edge*>*
 DirectedEdge::toEdges(vector<DirectedEdge*>& dirEdges)
 {
-	vector<Edge*> *edges=new vector<Edge*>();
-	toEdges(dirEdges, *edges);
-	return edges;
+    vector<Edge*>* edges = new vector<Edge*>();
+    toEdges(dirEdges, *edges);
+    return edges;
 }
 
 /*public*/
 DirectedEdge::DirectedEdge(Node* newFrom, Node* newTo,
-	const Coordinate &directionPt, bool newEdgeDirection)
+                           const Coordinate& directionPt, bool newEdgeDirection)
 {
-	from=newFrom;
-	to=newTo;
-	edgeDirection=newEdgeDirection;
-	p0=from->getCoordinate();
-	p1=directionPt;
-	double dx = p1.x - p0.x;
-	double dy = p1.y - p0.y;
-	quadrant = geomgraph::Quadrant::quadrant(dx, dy);
-	angle=atan2(dy, dx);
-	//Assert.isTrue(! (dx == 0 && dy == 0), "EdgeEnd with identical endpoints found");
+    from = newFrom;
+    to = newTo;
+    edgeDirection = newEdgeDirection;
+    p0 = from->getCoordinate();
+    p1 = directionPt;
+    double dx = p1.x - p0.x;
+    double dy = p1.y - p0.y;
+    quadrant = geomgraph::Quadrant::quadrant(dx, dy);
+    angle = atan2(dy, dx);
+    //Assert.isTrue(! (dx == 0 && dy == 0), "EdgeEnd with identical endpoints found");
 }
 
 /*public*/
 Edge*
 DirectedEdge::getEdge() const
 {
-	return parentEdge;
+    return parentEdge;
 }
 
 /*public*/
 void
 DirectedEdge::setEdge(Edge* newParentEdge)
 {
-	parentEdge=newParentEdge;
+    parentEdge = newParentEdge;
 }
 
 /*public*/
 int
 DirectedEdge::getQuadrant() const
 {
-	return quadrant;
+    return quadrant;
 }
 
 /*public*/
 const Coordinate&
 DirectedEdge::getDirectionPt() const
 {
-	return p1;
+    return p1;
 }
 
 /*public*/
 bool
 DirectedEdge::getEdgeDirection() const
 {
-	return edgeDirection;
+    return edgeDirection;
 }
 
 /*public*/
 Node*
 DirectedEdge::getFromNode() const
 {
-	return from;
+    return from;
 }
 
 /*public*/
 Node*
 DirectedEdge::getToNode() const
 {
-	return to;
+    return to;
 }
 
 /*public*/
 Coordinate&
 DirectedEdge::getCoordinate() const
 {
-	return from->getCoordinate();
+    return from->getCoordinate();
 }
 
 /*public*/
 double
 DirectedEdge::getAngle() const
 {
-	return angle;
+    return angle;
 }
 
 /*public*/
 DirectedEdge*
 DirectedEdge::getSym() const
 {
-	return sym;
+    return sym;
 }
 
 /*
@@ -138,45 +137,49 @@ DirectedEdge::getSym() const
  * which runs in the opposite direction.
  */
 void
-DirectedEdge::setSym(DirectedEdge *newSym)
+DirectedEdge::setSym(DirectedEdge* newSym)
 {
-	sym = newSym;
+    sym = newSym;
 }
 
 /*public*/
 int
 DirectedEdge::compareTo(const DirectedEdge* de) const
 {
-	return compareDirection(de);
+    return compareDirection(de);
 }
 
 /*public*/
 int
-DirectedEdge::compareDirection(const DirectedEdge *e) const
+DirectedEdge::compareDirection(const DirectedEdge* e) const
 {
 // if the rays are in different quadrants, determining the ordering is trivial
-	if (quadrant > e->quadrant) return 1;
-	if (quadrant < e->quadrant) return -1;
-	// vectors are in the same quadrant - check relative orientation of direction vectors
-	// this is > e if it is CCW of e
-	return algorithm::Orientation::index(e->p0,e->p1,p1);
+    if(quadrant > e->quadrant) {
+        return 1;
+    }
+    if(quadrant < e->quadrant) {
+        return -1;
+    }
+    // vectors are in the same quadrant - check relative orientation of direction vectors
+    // this is > e if it is CCW of e
+    return algorithm::Orientation::index(e->p0, e->p1, p1);
 }
 
 /*public*/
 string
 DirectedEdge::print() const
 {
-	ostringstream s;
-  s << *this;
-	return s.str();
+    ostringstream s;
+    s << *this;
+    return s.str();
 }
 
 std::ostream&
 operator << (std::ostream& s, const DirectedEdge& de)
 {
-  s << typeid(de).name() << ": " << de.p0 << " - " << de.p1;
-  s << " " << de.quadrant << ":" << de.angle;
-  return s;
+    s << typeid(de).name() << ": " << de.p0 << " - " << de.p1;
+    s << " " << de.quadrant << ":" << de.angle;
+    return s;
 }
 
 } // namespace planargraph
diff --git a/src/planargraph/DirectedEdgeStar.cpp b/src/planargraph/DirectedEdgeStar.cpp
index a0f0ac8..5342bd5 100644
--- a/src/planargraph/DirectedEdgeStar.cpp
+++ b/src/planargraph/DirectedEdgeStar.cpp
@@ -30,50 +30,52 @@ namespace planargraph {
  * Adds a new member to this DirectedEdgeStar.
  */
 void
-DirectedEdgeStar::add(DirectedEdge *de)
+DirectedEdgeStar::add(DirectedEdge* de)
 {
-	outEdges.push_back(de);
-	sorted=false;
+    outEdges.push_back(de);
+    sorted = false;
 }
 
 /*
  * Drops a member of this DirectedEdgeStar.
  */
 void
-DirectedEdgeStar::remove(DirectedEdge *de)
+DirectedEdgeStar::remove(DirectedEdge* de)
 {
-	for(unsigned int i=0; i<outEdges.size(); ++i)
-	{
-		if(outEdges[i]==de)
-		{
-			outEdges.erase(outEdges.begin()+i);
-			--i;
-		}
-	}
+    for(unsigned int i = 0; i < outEdges.size(); ++i) {
+        if(outEdges[i] == de) {
+            outEdges.erase(outEdges.begin() + i);
+            --i;
+        }
+    }
 }
 
 vector<DirectedEdge*>::iterator
-DirectedEdgeStar::begin() {
-	sortEdges();
-	return outEdges.begin();
+DirectedEdgeStar::begin()
+{
+    sortEdges();
+    return outEdges.begin();
 }
 
 vector<DirectedEdge*>::iterator
-DirectedEdgeStar::end() {
-	sortEdges();
-	return outEdges.end();
+DirectedEdgeStar::end()
+{
+    sortEdges();
+    return outEdges.end();
 }
 
 vector<DirectedEdge*>::const_iterator
-DirectedEdgeStar::begin() const {
-	sortEdges();
-	return outEdges.begin();
+DirectedEdgeStar::begin() const
+{
+    sortEdges();
+    return outEdges.begin();
 }
 
 vector<DirectedEdge*>::const_iterator
-DirectedEdgeStar::end() const {
-	sortEdges();
-	return outEdges.end();
+DirectedEdgeStar::end() const
+{
+    sortEdges();
+    return outEdges.end();
 }
 
 /*
@@ -82,10 +84,11 @@ DirectedEdgeStar::end() const {
 Coordinate&
 DirectedEdgeStar::getCoordinate() const
 {
-	if (outEdges.empty())
-		return Coordinate::getNull();
-	DirectedEdge *e=outEdges[0];
-	return e->getCoordinate();
+    if(outEdges.empty()) {
+        return Coordinate::getNull();
+    }
+    DirectedEdge* e = outEdges[0];
+    return e->getCoordinate();
 }
 
 /*
@@ -95,27 +98,29 @@ DirectedEdgeStar::getCoordinate() const
 vector<DirectedEdge*>&
 DirectedEdgeStar::getEdges()
 {
-	sortEdges();
-	return outEdges;
+    sortEdges();
+    return outEdges;
 }
 
 bool
-pdeLessThan(DirectedEdge *first, DirectedEdge * second)
+pdeLessThan(DirectedEdge* first, DirectedEdge* second)
 {
-	if (first->compareTo(second)<0)
-		return true;
-	else
-		return false;
+    if(first->compareTo(second) < 0) {
+        return true;
+    }
+    else {
+        return false;
+    }
 }
 
 /*private*/
 void
 DirectedEdgeStar::sortEdges() const
 {
-	if (!sorted) {
-		sort(outEdges.begin(), outEdges.end(), pdeLessThan);
-		sorted=true;
-	}
+    if(!sorted) {
+        sort(outEdges.begin(), outEdges.end(), pdeLessThan);
+        sorted = true;
+    }
 }
 
 /*
@@ -123,16 +128,16 @@ DirectedEdgeStar::sortEdges() const
  * ascending order by angle with the positive x-axis.
  */
 int
-DirectedEdgeStar::getIndex(const Edge *edge)
+DirectedEdgeStar::getIndex(const Edge* edge)
 {
-	sortEdges();
-	for (unsigned int i = 0; i<outEdges.size(); ++i)
-	{
-		DirectedEdge *de =outEdges[i];
-		if (de->getEdge() == edge)
-		return i;
-	}
-	return -1;
+    sortEdges();
+    for(unsigned int i = 0; i < outEdges.size(); ++i) {
+        DirectedEdge* de = outEdges[i];
+        if(de->getEdge() == edge) {
+            return i;
+        }
+    }
+    return -1;
 }
 
 /*
@@ -140,16 +145,16 @@ DirectedEdgeStar::getIndex(const Edge *edge)
  * in ascending order by angle with the positive x-axis.
  */
 int
-DirectedEdgeStar::getIndex(const DirectedEdge *dirEdge)
+DirectedEdgeStar::getIndex(const DirectedEdge* dirEdge)
 {
-	sortEdges();
-	for (unsigned int i = 0; i <outEdges.size(); ++i)
-	{
-		DirectedEdge *de =outEdges[i];
-		if (de == dirEdge)
-		return i;
-	}
-	return -1;
+    sortEdges();
+    for(unsigned int i = 0; i < outEdges.size(); ++i) {
+        DirectedEdge* de = outEdges[i];
+        if(de == dirEdge) {
+            return i;
+        }
+    }
+    return -1;
 }
 
 /*
@@ -159,10 +164,12 @@ DirectedEdgeStar::getIndex(const DirectedEdge *dirEdge)
 int
 DirectedEdgeStar::getIndex(int i) const
 {
-	int modi = i % (int)outEdges.size();
-	//I don't think modi can be 0 (assuming i is positive) [Jon Aquino 10/28/2003]
-	if (modi < 0) modi += (int)outEdges.size();
-	return modi;
+    int modi = i % (int)outEdges.size();
+    //I don't think modi can be 0 (assuming i is positive) [Jon Aquino 10/28/2003]
+    if(modi < 0) {
+        modi += (int)outEdges.size();
+    }
+    return modi;
 }
 
 /*
@@ -170,10 +177,10 @@ DirectedEdgeStar::getIndex(int i) const
  * DirectedEdge (which must be a member of this DirectedEdgeStar).
  */
 DirectedEdge*
-DirectedEdgeStar::getNextEdge(DirectedEdge *dirEdge)
+DirectedEdgeStar::getNextEdge(DirectedEdge* dirEdge)
 {
-	int i = getIndex(dirEdge);
-	return outEdges[getIndex(i + 1)];
+    int i = getIndex(dirEdge);
+    return outEdges[getIndex(i + 1)];
 }
 
 } // namespace planargraph
diff --git a/src/planargraph/Edge.cpp b/src/planargraph/Edge.cpp
index 782c950..9e84e13 100644
--- a/src/planargraph/Edge.cpp
+++ b/src/planargraph/Edge.cpp
@@ -29,40 +29,44 @@ namespace planargraph {
  *  adds this Edge to its from-Node.
  */
 void
-Edge::setDirectedEdges(DirectedEdge *de0, DirectedEdge *de1)
+Edge::setDirectedEdges(DirectedEdge* de0, DirectedEdge* de1)
 {
-	dirEdge.push_back(de0);
-	dirEdge.push_back(de1);
-	de0->setEdge(this);
-	de1->setEdge(this);
-	de0->setSym(de1);
-	de1->setSym(de0);
-	de0->getFromNode()->addOutEdge(de0);
-	de1->getFromNode()->addOutEdge(de1);
+    dirEdge.push_back(de0);
+    dirEdge.push_back(de1);
+    de0->setEdge(this);
+    de1->setEdge(this);
+    de0->setSym(de1);
+    de1->setSym(de0);
+    de0->getFromNode()->addOutEdge(de0);
+    de1->getFromNode()->addOutEdge(de1);
 }
 
 /**
 * Returns one of the DirectedEdges associated with this Edge.
 * @param i 0 or 1
 */
-DirectedEdge *
+DirectedEdge*
 Edge::getDirEdge(int i)
 {
-	return dirEdge[i];
+    return dirEdge[i];
 }
 
 /*
  * Returns the DirectedEdge that starts from the given node, or null if the
  * node is not one of the two nodes associated with this Edge.
  */
-DirectedEdge *
-Edge::getDirEdge(Node *fromNode)
+DirectedEdge*
+Edge::getDirEdge(Node* fromNode)
 {
-	if (dirEdge[0]->getFromNode()==fromNode) return dirEdge[0];
-	if (dirEdge[1]->getFromNode()==fromNode) return dirEdge[1];
-	// node not found
-	// possibly should throw an exception here?
-	return nullptr;
+    if(dirEdge[0]->getFromNode() == fromNode) {
+        return dirEdge[0];
+    }
+    if(dirEdge[1]->getFromNode() == fromNode) {
+        return dirEdge[1];
+    }
+    // node not found
+    // possibly should throw an exception here?
+    return nullptr;
 }
 
 /**
@@ -70,20 +74,30 @@ Edge::getDirEdge(Node *fromNode)
 * returns the other node; otherwise returns null.
 */
 Node*
-Edge::getOppositeNode(Node *node)
+Edge::getOppositeNode(Node* node)
 {
-	if (dirEdge[0]->getFromNode()==node) return dirEdge[0]->getToNode();
-	if (dirEdge[1]->getFromNode()==node) return dirEdge[1]->getToNode();
-	// node not found
-	// possibly should throw an exception here?
-	return nullptr;
+    if(dirEdge[0]->getFromNode() == node) {
+        return dirEdge[0]->getToNode();
+    }
+    if(dirEdge[1]->getFromNode() == node) {
+        return dirEdge[1]->getToNode();
+    }
+    // node not found
+    // possibly should throw an exception here?
+    return nullptr;
 }
 
-std::ostream& operator<<(std::ostream& os, const Edge& n) {
-	os << "Edge ";
-	if ( n.isMarked() ) os << " Marked ";
-	if ( n.isVisited() ) os << " Visited ";
-	return os;
+std::ostream&
+operator<<(std::ostream& os, const Edge& n)
+{
+    os << "Edge ";
+    if(n.isMarked()) {
+        os << " Marked ";
+    }
+    if(n.isVisited()) {
+        os << " Visited ";
+    }
+    return os;
 }
 
 } // namespace planargraph
diff --git a/src/planargraph/Node.cpp b/src/planargraph/Node.cpp
index 4f49bab..26739f3 100644
--- a/src/planargraph/Node.cpp
+++ b/src/planargraph/Node.cpp
@@ -27,36 +27,42 @@ namespace planargraph {
 /* static public */
 /* UNUSED */
 vector<Edge*>*
-Node::getEdgesBetween(Node *node0, Node *node1)
+Node::getEdgesBetween(Node* node0, Node* node1)
 {
-	std::vector<Edge*> edges0;
-	DirectedEdge::toEdges(node0->getOutEdges()->getEdges(), edges0);
+    std::vector<Edge*> edges0;
+    DirectedEdge::toEdges(node0->getOutEdges()->getEdges(), edges0);
 
-	std::vector<Edge*> edges1;
-	DirectedEdge::toEdges(node1->getOutEdges()->getEdges(), edges1);
+    std::vector<Edge*> edges1;
+    DirectedEdge::toEdges(node1->getOutEdges()->getEdges(), edges1);
 
-	// Sort edge lists (needed for set_intersection below
-	std::sort( edges0.begin(), edges0.end() );
-	std::sort( edges1.begin(), edges1.end() );
+    // Sort edge lists (needed for set_intersection below
+    std::sort(edges0.begin(), edges0.end());
+    std::sort(edges1.begin(), edges1.end());
 
-	std::vector<Edge*>* commonEdges = new std::vector<Edge*>();
+    std::vector<Edge*>* commonEdges = new std::vector<Edge*>();
 
-	// Intersect the two sets
-	std::set_intersection(
-		edges0.begin(), edges0.end(),
-		edges1.begin(), edges1.end(),
-		commonEdges->end()
-		);
+    // Intersect the two sets
+    std::set_intersection(
+        edges0.begin(), edges0.end(),
+        edges1.begin(), edges1.end(),
+        commonEdges->end()
+    );
 
-	return commonEdges;
+    return commonEdges;
 
 }
 
-std::ostream& operator<<(std::ostream& os, const Node& n) {
-	os << "Node " << n.pt << " with degree " << n.getDegree();
-	if ( n.isMarked() ) os << " Marked ";
-	if ( n.isVisited() ) os << " Visited ";
-	return os;
+std::ostream&
+operator<<(std::ostream& os, const Node& n)
+{
+    os << "Node " << n.pt << " with degree " << n.getDegree();
+    if(n.isMarked()) {
+        os << " Marked ";
+    }
+    if(n.isVisited()) {
+        os << " Visited ";
+    }
+    return os;
 }
 
 } // namespace planargraph
diff --git a/src/planargraph/NodeMap.cpp b/src/planargraph/NodeMap.cpp
index a05902a..0cfaf2e 100644
--- a/src/planargraph/NodeMap.cpp
+++ b/src/planargraph/NodeMap.cpp
@@ -37,7 +37,7 @@ NodeMap::~NodeMap()
 NodeMap::container&
 NodeMap::getNodeMap()
 {
-	return nodeMap;
+    return nodeMap;
 }
 
 /**
@@ -45,33 +45,33 @@ NodeMap::getNodeMap()
  * @return the added node
  */
 Node*
-NodeMap::add(Node *n)
+NodeMap::add(Node* n)
 {
-	nodeMap.insert(pair<geom::Coordinate, Node*>(n->getCoordinate(),n));
-	return n;
+    nodeMap.insert(pair<geom::Coordinate, Node*>(n->getCoordinate(), n));
+    return n;
 }
 
 /**
  * Removes the Node at the given location, and returns it
  * (or null if no Node was there).
  */
-Node *
+Node*
 NodeMap::remove(geom::Coordinate& pt)
 {
-	Node *n=find(pt);
-	nodeMap.erase(pt);
-	return n;
+    Node* n = find(pt);
+    nodeMap.erase(pt);
+    return n;
 }
 
 /* public */
 void
 NodeMap::getNodes(vector<Node*>& values)
 {
-	NodeMap::container::iterator it=nodeMap.begin(), itE=nodeMap.end();
-	while (it != itE) {
-		values.push_back(it->second);
-		++it;
-	}
+    NodeMap::container::iterator it = nodeMap.begin(), itE = nodeMap.end();
+    while(it != itE) {
+        values.push_back(it->second);
+        ++it;
+    }
 }
 
 /**
@@ -80,11 +80,13 @@ NodeMap::getNodes(vector<Node*>& values)
 Node*
 NodeMap::find(const geom::Coordinate& coord)
 {
-	container::iterator found=nodeMap.find(coord);
-	if (found==nodeMap.end())
-		return nullptr;
-	else
-		return found->second;
+    container::iterator found = nodeMap.find(coord);
+    if(found == nodeMap.end()) {
+        return nullptr;
+    }
+    else {
+        return found->second;
+    }
 }
 
 } //namespace planargraph
diff --git a/src/planargraph/PlanarGraph.cpp b/src/planargraph/PlanarGraph.cpp
index 6150475..8671d1c 100644
--- a/src/planargraph/PlanarGraph.cpp
+++ b/src/planargraph/PlanarGraph.cpp
@@ -40,11 +40,11 @@ namespace planargraph {
  * the right class.
  */
 void
-PlanarGraph::add(Edge *edge)
+PlanarGraph::add(Edge* edge)
 {
-	edges.push_back(edge);
-	add(edge->getDirEdge(0));
-	add(edge->getDirEdge(1));
+    edges.push_back(edge);
+    add(edge->getDirEdge(0));
+    add(edge->getDirEdge(1));
 }
 
 
@@ -55,17 +55,16 @@ PlanarGraph::add(Edge *edge)
  * Node to zero.
  */
 void
-PlanarGraph::remove(Edge *edge)
+PlanarGraph::remove(Edge* edge)
 {
-	remove(edge->getDirEdge(0));
-	remove(edge->getDirEdge(1));
-	for(unsigned int i=0; i<edges.size();++i)
-	{
-		if(edges[i]==edge) {
-			edges.erase(edges.begin()+i);
-			--i;
-		}
-	}
+    remove(edge->getDirEdge(0));
+    remove(edge->getDirEdge(1));
+    for(unsigned int i = 0; i < edges.size(); ++i) {
+        if(edges[i] == edge) {
+            edges.erase(edges.begin() + i);
+            --i;
+        }
+    }
 }
 
 /*
@@ -75,17 +74,19 @@ PlanarGraph::remove(Edge *edge)
  * zero.
  */
 void
-PlanarGraph::remove(DirectedEdge *de)
+PlanarGraph::remove(DirectedEdge* de)
 {
-	DirectedEdge *sym = de->getSym();
-	if (sym!=nullptr) sym->setSym(nullptr);
-	de->getFromNode()->getOutEdges()->remove(de);
-	for(unsigned int i=0; i<dirEdges.size(); ++i) {
-		if(dirEdges[i]==de) {
-			dirEdges.erase(dirEdges.begin()+i);
-			--i;
-		}
-	}
+    DirectedEdge* sym = de->getSym();
+    if(sym != nullptr) {
+        sym->setSym(nullptr);
+    }
+    de->getFromNode()->getOutEdges()->remove(de);
+    for(unsigned int i = 0; i < dirEdges.size(); ++i) {
+        if(dirEdges[i] == de) {
+            dirEdges.erase(dirEdges.begin() + i);
+            --i;
+        }
+    }
 }
 
 /*
@@ -93,57 +94,60 @@ PlanarGraph::remove(DirectedEdge *de)
  * DirectedEdges and Edges.
  */
 void
-PlanarGraph::remove(Node *node)
+PlanarGraph::remove(Node* node)
 {
-	// unhook all directed edges
-	vector<DirectedEdge*> &outEdges=node->getOutEdges()->getEdges();
-	for(unsigned int i=0; i<outEdges.size(); ++i) {
-		DirectedEdge *de =outEdges[i];
-		DirectedEdge *sym = de->getSym();
-		// remove the diredge that points to this node
-		if (sym!=nullptr) remove(sym);
-		// remove this diredge from the graph collection
-		for(unsigned int j=0; j<dirEdges.size(); ++j) {
-			if (dirEdges[j]==de) {
-				dirEdges.erase(dirEdges.begin()+j);
-				--j;
-			}
-		}
-		Edge *edge=de->getEdge();
-		if (edge!=nullptr) {
-			for(unsigned int k=0; k<edges.size(); ++k) {
-				if(edges[k]==edge) {
-					edges.erase(edges.begin()+k);
-					--k;
-				}
-			}
-		}
-	}
-	// remove the node from the graph
-	nodeMap.remove(node->getCoordinate());
-	//nodes.remove(node);
+    // unhook all directed edges
+    vector<DirectedEdge*>& outEdges = node->getOutEdges()->getEdges();
+    for(unsigned int i = 0; i < outEdges.size(); ++i) {
+        DirectedEdge* de = outEdges[i];
+        DirectedEdge* sym = de->getSym();
+        // remove the diredge that points to this node
+        if(sym != nullptr) {
+            remove(sym);
+        }
+        // remove this diredge from the graph collection
+        for(unsigned int j = 0; j < dirEdges.size(); ++j) {
+            if(dirEdges[j] == de) {
+                dirEdges.erase(dirEdges.begin() + j);
+                --j;
+            }
+        }
+        Edge* edge = de->getEdge();
+        if(edge != nullptr) {
+            for(unsigned int k = 0; k < edges.size(); ++k) {
+                if(edges[k] == edge) {
+                    edges.erase(edges.begin() + k);
+                    --k;
+                }
+            }
+        }
+    }
+    // remove the node from the graph
+    nodeMap.remove(node->getCoordinate());
+    //nodes.remove(node);
 }
 
 /*public*/
 vector<Node*>*
 PlanarGraph::findNodesOfDegree(size_t degree)
 {
-	vector<Node*> *nodesFound=new vector<Node*>();
-	findNodesOfDegree(degree, *nodesFound);
-	return nodesFound;
+    vector<Node*>* nodesFound = new vector<Node*>();
+    findNodesOfDegree(degree, *nodesFound);
+    return nodesFound;
 }
 
 /*public*/
 void
 PlanarGraph::findNodesOfDegree(size_t degree, vector<Node*>& nodesFound)
 {
-	NodeMap::container &nm=nodeMap.getNodeMap();
-	for (NodeMap::container::iterator it=nm.begin(), itEnd=nm.end();
-			it!=itEnd; ++it)
-	{
-		Node *node=it->second;
-		if (node->getDegree()==degree) nodesFound.push_back(node);
-	}
+    NodeMap::container& nm = nodeMap.getNodeMap();
+    for(NodeMap::container::iterator it = nm.begin(), itEnd = nm.end();
+            it != itEnd; ++it) {
+        Node* node = it->second;
+        if(node->getDegree() == degree) {
+            nodesFound.push_back(node);
+        }
+    }
 }
 
 } // namespace planargraph
diff --git a/src/planargraph/Subgraph.cpp b/src/planargraph/Subgraph.cpp
index 695f681..4d418a3 100644
--- a/src/planargraph/Subgraph.cpp
+++ b/src/planargraph/Subgraph.cpp
@@ -27,17 +27,19 @@ namespace geos {
 namespace planargraph {
 
 pair<Edge::NonConstSet::iterator, bool>
-Subgraph::add(Edge *e)
+Subgraph::add(Edge* e)
 {
-	pair<Edge::NonConstSet::iterator,bool> p = edges.insert(e);
-	if (!p.second) return p;
+    pair<Edge::NonConstSet::iterator, bool> p = edges.insert(e);
+    if(!p.second) {
+        return p;
+    }
 
-	dirEdges.push_back(e->getDirEdge(0));
-	dirEdges.push_back(e->getDirEdge(1));
-	nodeMap.add(e->getDirEdge(0)->getFromNode());
-	nodeMap.add(e->getDirEdge(1)->getFromNode());
+    dirEdges.push_back(e->getDirEdge(0));
+    dirEdges.push_back(e->getDirEdge(1));
+    nodeMap.add(e->getDirEdge(0)->getFromNode());
+    nodeMap.add(e->getDirEdge(1)->getFromNode());
 
-	return p;
+    return p;
 }
 
 } // namespace planargraph
diff --git a/src/planargraph/algorithm/ConnectedSubgraphFinder.cpp b/src/planargraph/algorithm/ConnectedSubgraphFinder.cpp
index 8e9f932..e6d8b3e 100644
--- a/src/planargraph/algorithm/ConnectedSubgraphFinder.cpp
+++ b/src/planargraph/algorithm/ConnectedSubgraphFinder.cpp
@@ -31,22 +31,21 @@ namespace planargraph {
 namespace algorithm {
 
 void
-ConnectedSubgraphFinder::getConnectedSubgraphs(vector<Subgraph *>& subgraphs)
+ConnectedSubgraphFinder::getConnectedSubgraphs(vector<Subgraph*>& subgraphs)
 {
-	GraphComponent::setVisitedMap(graph.nodeBegin(),
-			graph.nodeEnd(), false);
+    GraphComponent::setVisitedMap(graph.nodeBegin(),
+                                  graph.nodeEnd(), false);
 
-	for (PlanarGraph::EdgeIterator
-			it=graph.edgeBegin(),
-			itEnd=graph.edgeEnd();
-			it!=itEnd; ++it)
-	{
-		Edge *e = *it;
-		Node *node = e->getDirEdge(0)->getFromNode();
-		if (! node->isVisited()) {
-			subgraphs.push_back(findSubgraph(node));
-		}
-	}
+    for(PlanarGraph::EdgeIterator
+            it = graph.edgeBegin(),
+            itEnd = graph.edgeEnd();
+            it != itEnd; ++it) {
+        Edge* e = *it;
+        Node* node = e->getDirEdge(0)->getFromNode();
+        if(! node->isVisited()) {
+            subgraphs.push_back(findSubgraph(node));
+        }
+    }
 
 }
 
@@ -54,41 +53,41 @@ ConnectedSubgraphFinder::getConnectedSubgraphs(vector<Subgraph *>& subgraphs)
 Subgraph*
 ConnectedSubgraphFinder::findSubgraph(Node* node)
 {
-	Subgraph* subgraph = new Subgraph(graph);
-	addReachable(node, subgraph);
-	return subgraph;
+    Subgraph* subgraph = new Subgraph(graph);
+    addReachable(node, subgraph);
+    return subgraph;
 }
 
 /*private*/
 void
 ConnectedSubgraphFinder::addReachable(Node* startNode,
-		Subgraph* subgraph)
+                                      Subgraph* subgraph)
 {
-	stack<Node *> nodeStack;
-	nodeStack.push(startNode);
-	while ( !nodeStack.empty() )
-	{
-		Node* node = nodeStack.top();
-		nodeStack.pop();
-		addEdges(node, nodeStack, subgraph);
-	}
+    stack<Node*> nodeStack;
+    nodeStack.push(startNode);
+    while(!nodeStack.empty()) {
+        Node* node = nodeStack.top();
+        nodeStack.pop();
+        addEdges(node, nodeStack, subgraph);
+    }
 }
 
 /*private*/
 void
 ConnectedSubgraphFinder::addEdges(Node* node,
-		stack<Node *>& nodeStack, Subgraph* subgraph)
+                                  stack<Node*>& nodeStack, Subgraph* subgraph)
 {
-	node->setVisited(true);
-	DirectedEdgeStar *des=node->getOutEdges();
-	for (DirectedEdge::Vect::iterator i=des->begin(), iEnd=des->end();
-			i!=iEnd; ++i)
-	{
-		DirectedEdge *de=*i;
-		subgraph->add(de->getEdge());
-		Node *toNode = de->getToNode();
-		if ( ! toNode->isVisited() ) nodeStack.push(toNode);
-	}
+    node->setVisited(true);
+    DirectedEdgeStar* des = node->getOutEdges();
+    for(DirectedEdge::Vect::iterator i = des->begin(), iEnd = des->end();
+            i != iEnd; ++i) {
+        DirectedEdge* de = *i;
+        subgraph->add(de->getEdge());
+        Node* toNode = de->getToNode();
+        if(! toNode->isVisited()) {
+            nodeStack.push(toNode);
+        }
+    }
 }
 
 
diff --git a/src/precision/CommonBits.cpp b/src/precision/CommonBits.cpp
index a435a92..784a07e 100644
--- a/src/precision/CommonBits.cpp
+++ b/src/precision/CommonBits.cpp
@@ -23,75 +23,77 @@ namespace precision { // geos.precision
 int64
 CommonBits::signExpBits(int64 num)
 {
-	return num >> 52;
+    return num >> 52;
 }
 
 /*static public*/
 int
 CommonBits::numCommonMostSigMantissaBits(int64 num1, int64 num2)
 {
-	int count = 0;
-	for (int i = 52; i >= 0; i--){
-		if (getBit(num1, i) != getBit(num2, i))
-			return count;
-		count++;
-	}
-	return 52;
+    int count = 0;
+    for(int i = 52; i >= 0; i--) {
+        if(getBit(num1, i) != getBit(num2, i)) {
+            return count;
+        }
+        count++;
+    }
+    return 52;
 }
 
 /*static public*/
 int64
 CommonBits::zeroLowerBits(int64 bits, int nBits)
 {
-	int64 invMask = (1<< nBits)-1;
-	int64 mask = ~ invMask;
-	int64 zeroed = bits & mask;
-	return zeroed;
+    int64 invMask = (1 << nBits) - 1;
+    int64 mask = ~ invMask;
+    int64 zeroed = bits & mask;
+    return zeroed;
 }
 
 /*static public*/
 int
 CommonBits::getBit(int64 bits, int i)
 {
-	int64 mask = (1ull << i);
-	return (bits & mask) != 0 ? 1 : 0;
+    int64 mask = (1ull << i);
+    return (bits & mask) != 0 ? 1 : 0;
 }
 
 /*public*/
-CommonBits::CommonBits() {
-	isFirst = true;
-	commonMantissaBitsCount = 53;
-	commonBits = 0;
+CommonBits::CommonBits()
+{
+    isFirst = true;
+    commonMantissaBitsCount = 53;
+    commonBits = 0;
 }
 
 /*public*/
 void
 CommonBits::add(double num)
 {
-	int64 numBits=(int64)num;
-	if (isFirst) {
-		commonBits = numBits;
-		commonSignExp = signExpBits(commonBits);
-		isFirst = false;
-		return;
-	}
-	int64 numSignExp = signExpBits(numBits);
-	if (numSignExp != commonSignExp) {
-		commonBits = 0;
-		return;
-	}
-	//    System.out.println(toString(commonBits));
-	//    System.out.println(toString(numBits));
-	commonMantissaBitsCount = numCommonMostSigMantissaBits(commonBits, numBits);
-	commonBits = zeroLowerBits(commonBits, 64 - (12 + commonMantissaBitsCount));
-	//    System.out.println(toString(commonBits));
+    int64 numBits = (int64)num;
+    if(isFirst) {
+        commonBits = numBits;
+        commonSignExp = signExpBits(commonBits);
+        isFirst = false;
+        return;
+    }
+    int64 numSignExp = signExpBits(numBits);
+    if(numSignExp != commonSignExp) {
+        commonBits = 0;
+        return;
+    }
+    //    System.out.println(toString(commonBits));
+    //    System.out.println(toString(numBits));
+    commonMantissaBitsCount = numCommonMostSigMantissaBits(commonBits, numBits);
+    commonBits = zeroLowerBits(commonBits, 64 - (12 + commonMantissaBitsCount));
+    //    System.out.println(toString(commonBits));
 }
 
 /*public*/
 double
 CommonBits::getCommon()
 {
-	return (double)commonBits;
+    return (double)commonBits;
 }
 
 } // namespace geos.precision
diff --git a/src/precision/CommonBitsOp.cpp b/src/precision/CommonBitsOp.cpp
index e8549c8..5aa5650 100644
--- a/src/precision/CommonBitsOp.cpp
+++ b/src/precision/CommonBitsOp.cpp
@@ -38,132 +38,133 @@ namespace precision { // geos.precision
 
 /*public*/
 CommonBitsOp::CommonBitsOp()
-	:
-	returnToOriginalPrecision(true)
+    :
+    returnToOriginalPrecision(true)
 
 {
 #if GEOS_DEBUG
-	std::cerr << "CommonBitsOp[" << this
-	          << "]::CommonBitsOp()" << std::endl;
+    std::cerr << "CommonBitsOp[" << this
+              << "]::CommonBitsOp()" << std::endl;
 #endif
 }
 
 /*public*/
 CommonBitsOp::CommonBitsOp(bool nReturnToOriginalPrecision)
-	:
-	returnToOriginalPrecision(nReturnToOriginalPrecision)
+    :
+    returnToOriginalPrecision(nReturnToOriginalPrecision)
 {
 #if GEOS_DEBUG
-	std::cerr << "CommonBitsOp[" << this
-	          << "]::CommonBitsOp(bool "
-		  << nReturnToOriginalPrecision << ")"
-		  << std::endl;
+    std::cerr << "CommonBitsOp[" << this
+              << "]::CommonBitsOp(bool "
+              << nReturnToOriginalPrecision << ")"
+              << std::endl;
 #endif
 }
 
 /*public*/
 Geometry*
 CommonBitsOp::intersection(
-		const Geometry* geom0,
-		const Geometry* geom1)
+    const Geometry* geom0,
+    const Geometry* geom1)
 {
-	unique_ptr<Geometry> rgeom0;
-	unique_ptr<Geometry> rgeom1;
-	removeCommonBits(geom0, geom1, rgeom0, rgeom1);
-	return computeResultPrecision(rgeom0->intersection(rgeom1.get()));
+    unique_ptr<Geometry> rgeom0;
+    unique_ptr<Geometry> rgeom1;
+    removeCommonBits(geom0, geom1, rgeom0, rgeom1);
+    return computeResultPrecision(rgeom0->intersection(rgeom1.get()));
 }
 
 /*public*/
 Geometry*
 CommonBitsOp::Union(
-		const Geometry* geom0,
-		const Geometry* geom1)
+    const Geometry* geom0,
+    const Geometry* geom1)
 {
-	unique_ptr<Geometry> rgeom0;
-	unique_ptr<Geometry> rgeom1;
-	removeCommonBits(geom0, geom1, rgeom0, rgeom1);
-	return computeResultPrecision(rgeom0->Union(rgeom1.get()));
+    unique_ptr<Geometry> rgeom0;
+    unique_ptr<Geometry> rgeom1;
+    removeCommonBits(geom0, geom1, rgeom0, rgeom1);
+    return computeResultPrecision(rgeom0->Union(rgeom1.get()));
 }
 
 /*public*/
 Geometry*
 CommonBitsOp::difference(
-		const Geometry* geom0,
-		const Geometry* geom1)
+    const Geometry* geom0,
+    const Geometry* geom1)
 {
-	unique_ptr<Geometry> rgeom0;
-	unique_ptr<Geometry> rgeom1;
-	removeCommonBits(geom0, geom1, rgeom0, rgeom1);
-	return computeResultPrecision(rgeom0->difference(rgeom1.get()));
+    unique_ptr<Geometry> rgeom0;
+    unique_ptr<Geometry> rgeom1;
+    removeCommonBits(geom0, geom1, rgeom0, rgeom1);
+    return computeResultPrecision(rgeom0->difference(rgeom1.get()));
 }
 
 /*public*/
 Geometry*
 CommonBitsOp::symDifference(
-		const Geometry* geom0,
-		const Geometry* geom1)
+    const Geometry* geom0,
+    const Geometry* geom1)
 {
-	unique_ptr<Geometry> rgeom0;
-	unique_ptr<Geometry> rgeom1;
-	removeCommonBits(geom0, geom1, rgeom0, rgeom1);
-	return computeResultPrecision(rgeom0->symDifference(rgeom1.get()));
+    unique_ptr<Geometry> rgeom0;
+    unique_ptr<Geometry> rgeom1;
+    removeCommonBits(geom0, geom1, rgeom0, rgeom1);
+    return computeResultPrecision(rgeom0->symDifference(rgeom1.get()));
 }
 
 /*public*/
 Geometry*
 CommonBitsOp::buffer(const Geometry* geom0, double distance)
 {
-	unique_ptr<Geometry> rgeom0(removeCommonBits(geom0));
-	return computeResultPrecision(rgeom0->buffer(distance));
+    unique_ptr<Geometry> rgeom0(removeCommonBits(geom0));
+    return computeResultPrecision(rgeom0->buffer(distance));
 }
 
 /*public*/
 Geometry*
 CommonBitsOp::computeResultPrecision(Geometry* result)
 {
-	assert(cbr.get());
-	if (returnToOriginalPrecision)
-		cbr->addCommonBits(result);
-	return result;
+    assert(cbr.get());
+    if(returnToOriginalPrecision) {
+        cbr->addCommonBits(result);
+    }
+    return result;
 }
 
 /*private*/
 Geometry*
 CommonBitsOp::removeCommonBits(const Geometry* geom0)
 {
-	cbr.reset(new CommonBitsRemover());
-	cbr->add(geom0);
+    cbr.reset(new CommonBitsRemover());
+    cbr->add(geom0);
 
 #if GEOS_DEBUG
-	const Coordinate& commonCoord = cbr->getCommonCoordinate();
-	cerr << "CommonBitsRemover bits: " << commonCoord.x << ", " << commonCoord.y << endl;
+    const Coordinate& commonCoord = cbr->getCommonCoordinate();
+    cerr << "CommonBitsRemover bits: " << commonCoord.x << ", " << commonCoord.y << endl;
 #endif
 
-	Geometry* geom=cbr->removeCommonBits(geom0->clone());
-	return geom;
+    Geometry* geom = cbr->removeCommonBits(geom0->clone());
+    return geom;
 }
 
 /*private*/
 void
 CommonBitsOp::removeCommonBits(
-		const geom::Geometry* geom0,
-		const geom::Geometry* geom1,
-		std::unique_ptr<geom::Geometry>& rgeom0,
-		std::unique_ptr<geom::Geometry>& rgeom1)
+    const geom::Geometry* geom0,
+    const geom::Geometry* geom1,
+    std::unique_ptr<geom::Geometry>& rgeom0,
+    std::unique_ptr<geom::Geometry>& rgeom1)
 
 {
-	cbr.reset(new CommonBitsRemover());
+    cbr.reset(new CommonBitsRemover());
 
-	cbr->add(geom0);
-	cbr->add(geom1);
+    cbr->add(geom0);
+    cbr->add(geom1);
 
 #if GEOS_DEBUG
-	const Coordinate& commonCoord = cbr->getCommonCoordinate();
-	cerr << "CommonBitsRemover bits: " << commonCoord.x << ", " << commonCoord.y << endl;
+    const Coordinate& commonCoord = cbr->getCommonCoordinate();
+    cerr << "CommonBitsRemover bits: " << commonCoord.x << ", " << commonCoord.y << endl;
 #endif
 
-	rgeom0.reset(cbr->removeCommonBits(geom0->clone()));
-	rgeom1.reset(cbr->removeCommonBits(geom1->clone()));
+    rgeom0.reset(cbr->removeCommonBits(geom0->clone()));
+    rgeom1.reset(cbr->removeCommonBits(geom1->clone()));
 
 }
 
diff --git a/src/precision/CommonBitsRemover.cpp b/src/precision/CommonBitsRemover.cpp
index d72b6af..1289e6e 100644
--- a/src/precision/CommonBitsRemover.cpp
+++ b/src/precision/CommonBitsRemover.cpp
@@ -40,65 +40,70 @@ class Translater: public geom::CoordinateFilter {
 
 private:
 
-	geom::Coordinate trans;
+    geom::Coordinate trans;
 
 public:
 
-	Translater(geom::Coordinate &newTrans)
-		:
-		trans(newTrans)
-	{}
+    Translater(geom::Coordinate& newTrans)
+        :
+        trans(newTrans)
+    {}
 
-	void filter_ro(const geom::Coordinate *coord) override  //Not used
+    void
+    filter_ro(const geom::Coordinate* coord) override  //Not used
     {
         ::geos::ignore_unused_variable_warning(coord);
         assert(0);
     }
 
-	void filter_rw(geom::Coordinate *coord) const override
-	{
-		coord->x += trans.x;
-		coord->y += trans.y;
-	}
+    void
+    filter_rw(geom::Coordinate* coord) const override
+    {
+        coord->x += trans.x;
+        coord->y += trans.y;
+    }
 };
 
 
 class CommonCoordinateFilter: public geom::CoordinateFilter {
 private:
-	CommonBits commonBitsX;
-	CommonBits commonBitsY;
+    CommonBits commonBitsX;
+    CommonBits commonBitsY;
 public:
 
-	void filter_rw(geom::Coordinate *coord) const override
-	{
+    void
+    filter_rw(geom::Coordinate* coord) const override
+    {
         // CommonCoordinateFilter is a read-only filter
         ::geos::ignore_unused_variable_warning(coord);
-		assert(0);
-	}
+        assert(0);
+    }
 
-	void filter_ro(const geom::Coordinate *coord) override
-	{
-		commonBitsX.add(coord->x);
-		commonBitsY.add(coord->y);
-	}
+    void
+    filter_ro(const geom::Coordinate* coord) override
+    {
+        commonBitsX.add(coord->x);
+        commonBitsY.add(coord->y);
+    }
 
-	void getCommonCoordinate(geom::Coordinate& c)
-	{
-		c=Coordinate(commonBitsX.getCommon(),
-			commonBitsY.getCommon());
-	}
+    void
+    getCommonCoordinate(geom::Coordinate& c)
+    {
+        c = Coordinate(commonBitsX.getCommon(),
+                       commonBitsY.getCommon());
+    }
 
 };
 
 
 CommonBitsRemover::CommonBitsRemover()
 {
-	ccFilter=new CommonCoordinateFilter();
+    ccFilter = new CommonCoordinateFilter();
 }
 
 CommonBitsRemover::~CommonBitsRemover()
 {
-	delete ccFilter;
+    delete ccFilter;
 }
 
 /**
@@ -110,10 +115,10 @@ CommonBitsRemover::~CommonBitsRemover()
  * @param geom a Geometry to test for common bits
  */
 void
-CommonBitsRemover::add(const Geometry *geom)
+CommonBitsRemover::add(const Geometry* geom)
 {
-	geom->apply_ro(ccFilter);
-	ccFilter->getCommonCoordinate(commonCoord);
+    geom->apply_ro(ccFilter);
+    ccFilter->getCommonCoordinate(commonCoord);
 }
 
 /**
@@ -122,7 +127,7 @@ CommonBitsRemover::add(const Geometry *geom)
 Coordinate&
 CommonBitsRemover::getCommonCoordinate()
 {
-	return commonCoord;
+    return commonCoord;
 }
 
 /**
@@ -133,24 +138,25 @@ CommonBitsRemover::getCommonCoordinate()
  * @return the shifted Geometry
  */
 Geometry*
-CommonBitsRemover::removeCommonBits(Geometry *geom)
+CommonBitsRemover::removeCommonBits(Geometry* geom)
 {
-	if (commonCoord.x == 0.0 && commonCoord.y == 0.0)
-		return geom;
+    if(commonCoord.x == 0.0 && commonCoord.y == 0.0) {
+        return geom;
+    }
 
-	Coordinate invCoord(commonCoord);
-	invCoord.x = -invCoord.x;
-	invCoord.y = -invCoord.y;
+    Coordinate invCoord(commonCoord);
+    invCoord.x = -invCoord.x;
+    invCoord.y = -invCoord.y;
 
-	Translater trans(invCoord);
-	geom->apply_rw(&trans);
-	geom->geometryChanged();
+    Translater trans(invCoord);
+    geom->apply_rw(&trans);
+    geom->geometryChanged();
 
 #if GEOS_DEBUG
-	std::cerr << "CommonBits removed: " << *geom << std::endl;
+    std::cerr << "CommonBits removed: " << *geom << std::endl;
 #endif
 
-	return geom;
+    return geom;
 }
 
 /**
@@ -161,22 +167,22 @@ CommonBitsRemover::removeCommonBits(Geometry *geom)
  * @return the shifted Geometry
  */
 Geometry*
-CommonBitsRemover::addCommonBits(Geometry *geom)
+CommonBitsRemover::addCommonBits(Geometry* geom)
 {
 #if GEOS_DEBUG
-	std::cerr << "CommonBits before add: " << *geom << std::endl;
+    std::cerr << "CommonBits before add: " << *geom << std::endl;
 #endif
 
-	Translater trans(commonCoord);
+    Translater trans(commonCoord);
 
-	geom->apply_rw(&trans);
-	geom->geometryChanged();
+    geom->apply_rw(&trans);
+    geom->geometryChanged();
 
 #if GEOS_DEBUG
-	std::cerr << "CommonBits added: " << *geom << std::endl;
+    std::cerr << "CommonBits added: " << *geom << std::endl;
 #endif
 
-	return geom;
+    return geom;
 }
 
 } // namespace geos.precision
diff --git a/src/precision/EnhancedPrecisionOp.cpp b/src/precision/EnhancedPrecisionOp.cpp
index abba62e..974541e 100644
--- a/src/precision/EnhancedPrecisionOp.cpp
+++ b/src/precision/EnhancedPrecisionOp.cpp
@@ -39,208 +39,191 @@ namespace precision { // geos.precision
 /*public static*/
 Geometry*
 EnhancedPrecisionOp::intersection(
-		const Geometry *geom0,
-		const Geometry *geom1)
+    const Geometry* geom0,
+    const Geometry* geom1)
 {
-	util::GEOSException originalEx;
-
-	try
-	{
-		Geometry *result = geom0->intersection(geom1);
-		return result;
-	}
-	catch (const util::GEOSException& ex)
-	{
-		originalEx = ex;
-	}
-
-	/*
-	 * If we are here, the original op encountered a precision problem
-	 * (or some other problem). Retry the operation with
-	 * enhanced precision to see if it succeeds
-	 */
-	try
-	{
-		CommonBitsOp cbo(true);
-		Geometry *resultEP = cbo.intersection(geom0, geom1);
-
-		// check that result is a valid geometry after
-		// the reshift to orginal precision
-		if (! resultEP->isValid())
-		{
+    util::GEOSException originalEx;
+
+    try {
+        Geometry* result = geom0->intersection(geom1);
+        return result;
+    }
+    catch(const util::GEOSException& ex) {
+        originalEx = ex;
+    }
+
+    /*
+     * If we are here, the original op encountered a precision problem
+     * (or some other problem). Retry the operation with
+     * enhanced precision to see if it succeeds
+     */
+    try {
+        CommonBitsOp cbo(true);
+        Geometry* resultEP = cbo.intersection(geom0, geom1);
+
+        // check that result is a valid geometry after
+        // the reshift to orginal precision
+        if(! resultEP->isValid()) {
 #if GEOS_DEBUG
-			std::cerr << "Reduced operation result is invalid"
-			          << std::endl;
+            std::cerr << "Reduced operation result is invalid"
+                      << std::endl;
 #endif
-			throw originalEx;
-		}
-		return resultEP;
-	}
-	catch (const util::GEOSException& ex2 )
-	{
+            throw originalEx;
+        }
+        return resultEP;
+    }
+    catch(const util::GEOSException& ex2) {
 #if GEOS_DEBUG
-		std::cerr << "Reduced operation exception: "
-		          << ex2.what() << std::endl;
+        std::cerr << "Reduced operation exception: "
+                  << ex2.what() << std::endl;
 #else
         (void)ex2;
 #endif
-		throw originalEx;
-	}
+        throw originalEx;
+    }
 }
 
 /*public static*/
 Geometry*
 EnhancedPrecisionOp::Union(
-		const Geometry *geom0,
-		const Geometry *geom1)
+    const Geometry* geom0,
+    const Geometry* geom1)
 {
-	util::GEOSException originalEx;
-	try
-	{
-		Geometry* result = geom0->Union(geom1);
-		return result;
-	}
-	catch (const util::GEOSException& ex)
-	{
-		originalEx = ex;
-	}
-
-	/*
-	 * If we are here, the original op encountered a precision problem
-	 * (or some other problem)->  Retry the operation with
-	 * enhanced precision to see if it succeeds
-	 */
-	try
-	{
-		CommonBitsOp cbo(true);
-		Geometry *resultEP = cbo.Union(geom0, geom1);
-
-		// check that result is a valid geometry after
-		// the reshift to orginal precision
-		if (! resultEP->isValid())
-			throw originalEx;
-		return resultEP;
-	}
-	catch (const util::GEOSException& /* ex2 */)
-	{
-		throw originalEx;
-	}
+    util::GEOSException originalEx;
+    try {
+        Geometry* result = geom0->Union(geom1);
+        return result;
+    }
+    catch(const util::GEOSException& ex) {
+        originalEx = ex;
+    }
+
+    /*
+     * If we are here, the original op encountered a precision problem
+     * (or some other problem)->  Retry the operation with
+     * enhanced precision to see if it succeeds
+     */
+    try {
+        CommonBitsOp cbo(true);
+        Geometry* resultEP = cbo.Union(geom0, geom1);
+
+        // check that result is a valid geometry after
+        // the reshift to orginal precision
+        if(! resultEP->isValid()) {
+            throw originalEx;
+        }
+        return resultEP;
+    }
+    catch(const util::GEOSException& /* ex2 */) {
+        throw originalEx;
+    }
 }
 
 /*public static*/
 Geometry*
 EnhancedPrecisionOp::difference(
-		const Geometry *geom0,
-		const Geometry *geom1)
+    const Geometry* geom0,
+    const Geometry* geom1)
 {
-	util::GEOSException originalEx;
-
-	try
-	{
-		Geometry *result = geom0->difference(geom1);
-		return result;
-	}
-	catch (const util::GEOSException& ex)
-	{
-		originalEx = ex;
-	}
-
-	/*
-	 * If we are here, the original op encountered a precision problem
-	 * (or some other problem).  Retry the operation with
-	 * enhanced precision to see if it succeeds
-	 */
-	try
-	{
-		CommonBitsOp cbo(true);
-		Geometry *resultEP = cbo.difference(geom0, geom1);
-
-		// check that result is a valid geometry after
-		// the reshift to orginal precision
-		if (! resultEP->isValid())
-			throw originalEx;
-		return resultEP;
-	}
-	catch (const util::GEOSException& /* ex2 */)
-	{
-		throw originalEx;
-	}
+    util::GEOSException originalEx;
+
+    try {
+        Geometry* result = geom0->difference(geom1);
+        return result;
+    }
+    catch(const util::GEOSException& ex) {
+        originalEx = ex;
+    }
+
+    /*
+     * If we are here, the original op encountered a precision problem
+     * (or some other problem).  Retry the operation with
+     * enhanced precision to see if it succeeds
+     */
+    try {
+        CommonBitsOp cbo(true);
+        Geometry* resultEP = cbo.difference(geom0, geom1);
+
+        // check that result is a valid geometry after
+        // the reshift to orginal precision
+        if(! resultEP->isValid()) {
+            throw originalEx;
+        }
+        return resultEP;
+    }
+    catch(const util::GEOSException& /* ex2 */) {
+        throw originalEx;
+    }
 }
 
 /*public static*/
 Geometry*
 EnhancedPrecisionOp::symDifference(
-		const Geometry *geom0,
-		const Geometry *geom1)
+    const Geometry* geom0,
+    const Geometry* geom1)
 {
-	util::GEOSException originalEx;
-	try
-	{
-		Geometry *result = geom0->symDifference(geom1);
-		return result;
-	}
-	catch (const util::GEOSException& ex)
-	{
-		originalEx = ex;
-	}
-
-	/*
-	 * If we are here, the original op encountered a precision problem
-	 * (or some other problem).  Retry the operation with
-	 * enhanced precision to see if it succeeds
-	 */
-	try
-	{
-		CommonBitsOp cbo(true);
-		Geometry* resultEP = cbo.symDifference(geom0, geom1);
-
-		// check that result is a valid geometry after
-		// the reshift to orginal precision
-		if (! resultEP->isValid())
-			throw originalEx;
-		return resultEP;
-	}
-	catch (const util::GEOSException& /* ex2 */)
-	{
-		throw originalEx;
-	}
+    util::GEOSException originalEx;
+    try {
+        Geometry* result = geom0->symDifference(geom1);
+        return result;
+    }
+    catch(const util::GEOSException& ex) {
+        originalEx = ex;
+    }
+
+    /*
+     * If we are here, the original op encountered a precision problem
+     * (or some other problem).  Retry the operation with
+     * enhanced precision to see if it succeeds
+     */
+    try {
+        CommonBitsOp cbo(true);
+        Geometry* resultEP = cbo.symDifference(geom0, geom1);
+
+        // check that result is a valid geometry after
+        // the reshift to orginal precision
+        if(! resultEP->isValid()) {
+            throw originalEx;
+        }
+        return resultEP;
+    }
+    catch(const util::GEOSException& /* ex2 */) {
+        throw originalEx;
+    }
 }
 
 /*public static*/
 Geometry*
-EnhancedPrecisionOp::buffer(const Geometry *geom, double distance)
+EnhancedPrecisionOp::buffer(const Geometry* geom, double distance)
 {
-	util::GEOSException originalEx;
-	try
-	{
-		Geometry *result = geom->buffer(distance);
-		return result;
-	}
-	catch (const util::GEOSException& ex)
-	{
-		originalEx = ex;
-	}
-
-	/*
-	 * If we are here, the original op encountered a precision problem
-	 * (or some other problem)->  Retry the operation with
-	 * enhanced precision to see if it succeeds
-	 */
-	try
-	{
-		CommonBitsOp cbo(true);
-		Geometry *resultEP = cbo.buffer(geom, distance);
-
-		// check that result is a valid geometry
-		// after the reshift to orginal precision
-		if (! resultEP->isValid())
-			throw originalEx;
-		return resultEP;
-	}
-	catch (const util::GEOSException& /* ex2 */)
-	{
-		throw originalEx;
-	}
+    util::GEOSException originalEx;
+    try {
+        Geometry* result = geom->buffer(distance);
+        return result;
+    }
+    catch(const util::GEOSException& ex) {
+        originalEx = ex;
+    }
+
+    /*
+     * If we are here, the original op encountered a precision problem
+     * (or some other problem)->  Retry the operation with
+     * enhanced precision to see if it succeeds
+     */
+    try {
+        CommonBitsOp cbo(true);
+        Geometry* resultEP = cbo.buffer(geom, distance);
+
+        // check that result is a valid geometry
+        // after the reshift to orginal precision
+        if(! resultEP->isValid()) {
+            throw originalEx;
+        }
+        return resultEP;
+    }
+    catch(const util::GEOSException& /* ex2 */) {
+        throw originalEx;
+    }
 }
 
 } // namespace geos.precision
diff --git a/src/precision/GeometryPrecisionReducer.cpp b/src/precision/GeometryPrecisionReducer.cpp
index 6af8ac8..80997e3 100644
--- a/src/precision/GeometryPrecisionReducer.cpp
+++ b/src/precision/GeometryPrecisionReducer.cpp
@@ -42,102 +42,109 @@ namespace precision { // geos.precision
 
 /* private */
 unique_ptr<Geometry>
-GeometryPrecisionReducer::reducePointwise(const Geometry &geom)
+GeometryPrecisionReducer::reducePointwise(const Geometry& geom)
 {
-	unique_ptr<GeometryEditor> geomEdit;
+    unique_ptr<GeometryEditor> geomEdit;
 
-  if ( newFactory ) {
-      geomEdit.reset( new GeometryEditor(newFactory) );
-  } else {
-      geomEdit.reset( new GeometryEditor() );
-  }
+    if(newFactory) {
+        geomEdit.reset(new GeometryEditor(newFactory));
+    }
+    else {
+        geomEdit.reset(new GeometryEditor());
+    }
 
-  /**
-   * For polygonal geometries, collapses are always removed, in order
-   * to produce correct topology
-   */
-  bool finalRemoveCollapsed = removeCollapsed;
-  if (geom.getDimension() >= 2)
-    finalRemoveCollapsed = true;
+    /**
+     * For polygonal geometries, collapses are always removed, in order
+     * to produce correct topology
+     */
+    bool finalRemoveCollapsed = removeCollapsed;
+    if(geom.getDimension() >= 2) {
+        finalRemoveCollapsed = true;
+    }
 
-	PrecisionReducerCoordinateOperation prco(targetPM, finalRemoveCollapsed);
+    PrecisionReducerCoordinateOperation prco(targetPM, finalRemoveCollapsed);
 
-	std::unique_ptr<Geometry> g ( geomEdit->edit(&geom, &prco) );
+    std::unique_ptr<Geometry> g(geomEdit->edit(&geom, &prco));
 
-	return g;
+    return g;
 }
 
 /* public */
 unique_ptr<Geometry>
-GeometryPrecisionReducer::reduce(const Geometry &geom)
+GeometryPrecisionReducer::reduce(const Geometry& geom)
 {
-  unique_ptr<Geometry> reducePW = reducePointwise(geom);
+    unique_ptr<Geometry> reducePW = reducePointwise(geom);
 
-  if ( isPointwise ) return reducePW;
+    if(isPointwise) {
+        return reducePW;
+    }
 
-  //TODO: handle GeometryCollections containing polys
-  if (! (dynamic_cast<const Polygonal*>(reducePW.get())) )
-    return reducePW;
+    //TODO: handle GeometryCollections containing polys
+    if(!(dynamic_cast<const Polygonal*>(reducePW.get()))) {
+        return reducePW;
+    }
 
-  // Geometry is polygonal - test if topology needs to be fixed
-  if (reducePW->isValid()) return reducePW;
+    // Geometry is polygonal - test if topology needs to be fixed
+    if(reducePW->isValid()) {
+        return reducePW;
+    }
 
-  // hack to fix topology.
-  // TODO: implement snap-rounding and use that.
-  return fixPolygonalTopology(*reducePW);
+    // hack to fix topology.
+    // TODO: implement snap-rounding and use that.
+    return fixPolygonalTopology(*reducePW);
 
 }
 
 
 /* public */
-GeometryPrecisionReducer::GeometryPrecisionReducer(const GeometryFactory &changeFactory)
-      :
-      newFactory(&changeFactory),
-      targetPM(*(changeFactory.getPrecisionModel())),
-      removeCollapsed(true),
-      isPointwise(false)
+GeometryPrecisionReducer::GeometryPrecisionReducer(const GeometryFactory& changeFactory)
+    :
+    newFactory(&changeFactory),
+    targetPM(*(changeFactory.getPrecisionModel())),
+    removeCollapsed(true),
+    isPointwise(false)
 {}
 
 /* private */
 unique_ptr<Geometry>
-GeometryPrecisionReducer::fixPolygonalTopology(const geom::Geometry& geom )
+GeometryPrecisionReducer::fixPolygonalTopology(const geom::Geometry& geom)
 {
-  /**
-   * If precision model was *not* changed, need to flip
-   * geometry to targetPM, buffer in that model, then flip back
-   */
-  unique_ptr<Geometry> tmp;
-  GeometryFactory::Ptr tmpFactory;
+    /**
+     * If precision model was *not* changed, need to flip
+     * geometry to targetPM, buffer in that model, then flip back
+     */
+    unique_ptr<Geometry> tmp;
+    GeometryFactory::Ptr tmpFactory;
 
-  const Geometry* geomToBuffer = &geom;
+    const Geometry* geomToBuffer = &geom;
 
-  if ( ! newFactory ) {
-    tmpFactory = createFactory(*geom.getFactory(), targetPM);
-    tmp.reset( tmpFactory->createGeometry(&geom) );
-    geomToBuffer = tmp.get();
-  }
+    if(! newFactory) {
+        tmpFactory = createFactory(*geom.getFactory(), targetPM);
+        tmp.reset(tmpFactory->createGeometry(&geom));
+        geomToBuffer = tmp.get();
+    }
 
-  unique_ptr<Geometry> bufGeom ( geomToBuffer->buffer(0) );
+    unique_ptr<Geometry> bufGeom(geomToBuffer->buffer(0));
 
-  if ( ! newFactory ) {
-    // a slick way to copy the geometry with the original precision factory
-    bufGeom.reset( geom.getFactory()->createGeometry(bufGeom.get()) );
-  }
+    if(! newFactory) {
+        // a slick way to copy the geometry with the original precision factory
+        bufGeom.reset(geom.getFactory()->createGeometry(bufGeom.get()));
+    }
 
-  return bufGeom;
+    return bufGeom;
 }
 
 /* private */
 GeometryFactory::Ptr
-GeometryPrecisionReducer::createFactory( const GeometryFactory& oldGF,
-                                         const PrecisionModel& newPM )
+GeometryPrecisionReducer::createFactory(const GeometryFactory& oldGF,
+                                        const PrecisionModel& newPM)
 {
-  GeometryFactory::Ptr p_newFactory(
-    GeometryFactory::create(&newPM,
-                        oldGF.getSRID(),
-                        const_cast<CoordinateSequenceFactory*>(oldGF.getCoordinateSequenceFactory()))
-  );
-  return p_newFactory;
+    GeometryFactory::Ptr p_newFactory(
+        GeometryFactory::create(&newPM,
+                                oldGF.getSRID(),
+                                const_cast<CoordinateSequenceFactory*>(oldGF.getCoordinateSequenceFactory()))
+    );
+    return p_newFactory;
 }
 
 } // namespace geos.precision
diff --git a/src/precision/MinimumClearance.cpp b/src/precision/MinimumClearance.cpp
index efc8b13..0553a3c 100644
--- a/src/precision/MinimumClearance.cpp
+++ b/src/precision/MinimumClearance.cpp
@@ -34,28 +34,37 @@ namespace precision {
 
 MinimumClearance::MinimumClearance(const Geometry* g) : inputGeom(g) {}
 
-double MinimumClearance::getDistance() {
+double
+MinimumClearance::getDistance()
+{
     compute();
     return minClearance;
 }
 
-std::unique_ptr<LineString> MinimumClearance::getLine() {
+std::unique_ptr<LineString>
+MinimumClearance::getLine()
+{
     compute();
 
     // return empty line string if no min pts were found
-    if (minClearance == std::numeric_limits<double>::infinity())
+    if(minClearance == std::numeric_limits<double>::infinity()) {
         return std::unique_ptr<LineString>(inputGeom->getFactory()->createLineString());
+    }
 
     return std::unique_ptr<LineString>(inputGeom->getFactory()->createLineString(minClearancePts->clone()));
 }
 
-void MinimumClearance::compute() {
+void
+MinimumClearance::compute()
+{
     class MinClearanceDistance : public ItemDistance {
     private:
         double minDist;
         std::vector<Coordinate> minPts;
 
-        void updatePts(const Coordinate & p, const Coordinate & seg0, const Coordinate & seg1) {
+        void
+        updatePts(const Coordinate& p, const Coordinate& seg0, const Coordinate& seg1)
+        {
             LineSegment seg(seg0, seg1);
 
             minPts[0] = p;
@@ -64,15 +73,19 @@ void MinimumClearance::compute() {
 
     public:
         MinClearanceDistance() :
-                minDist(std::numeric_limits<double>::infinity()),
-                minPts(std::vector<Coordinate>(2))
+            minDist(std::numeric_limits<double>::infinity()),
+            minPts(std::vector<Coordinate>(2))
         {}
 
-        const std::vector<Coordinate> * getCoordinates() {
+        const std::vector<Coordinate>*
+        getCoordinates()
+        {
             return &minPts;
         }
 
-        double distance(const ItemBoundable* b1, const ItemBoundable* b2) override {
+        double
+        distance(const ItemBoundable* b1, const ItemBoundable* b2) override
+        {
             FacetSequence* fs1 = static_cast<FacetSequence*>(b1->getItem());
             FacetSequence* fs2 = static_cast<FacetSequence*>(b2->getItem());
 
@@ -81,36 +94,44 @@ void MinimumClearance::compute() {
             return distance(fs1, fs2);
         }
 
-        double distance(const FacetSequence* fs1, const FacetSequence* fs2) {
+        double
+        distance(const FacetSequence* fs1, const FacetSequence* fs2)
+        {
             // Compute MinClearance distance metric
 
             vertexDistance(fs1, fs2);
-            if (fs1->size() == 1 && fs2->size() == 1)
+            if(fs1->size() == 1 && fs2->size() == 1) {
                 return minDist;
-            if (minDist <= 0.0)
+            }
+            if(minDist <= 0.0) {
                 return minDist;
+            }
 
             segmentDistance(fs1, fs2);
-            if (minDist <= 0.0)
+            if(minDist <= 0.0) {
                 return minDist;
+            }
 
             segmentDistance(fs2, fs1);
             return minDist;
         }
 
-        double vertexDistance(const FacetSequence* fs1, const FacetSequence* fs2) {
-            for (size_t i1 = 0; i1 < fs1->size(); i1++) {
-                for (size_t i2 = 0; i2 < fs2->size(); i2++) {
+        double
+        vertexDistance(const FacetSequence* fs1, const FacetSequence* fs2)
+        {
+            for(size_t i1 = 0; i1 < fs1->size(); i1++) {
+                for(size_t i2 = 0; i2 < fs2->size(); i2++) {
                     const Coordinate* p1 = fs1->getCoordinate(i1);
                     const Coordinate* p2 = fs2->getCoordinate(i2);
-                    if (!p1->equals2D(*p2)) {
+                    if(!p1->equals2D(*p2)) {
                         double d = p1->distance(*p2);
-                        if (d < minDist) {
+                        if(d < minDist) {
                             minDist = d;
                             minPts[0] = *p1;
                             minPts[1] = *p2;
-                            if (d == 0.0)
+                            if(d == 0.0) {
                                 return d;
+                            }
                         }
                     }
                 }
@@ -118,21 +139,24 @@ void MinimumClearance::compute() {
             return minDist;
         }
 
-        double segmentDistance(const FacetSequence* fs1, const FacetSequence* fs2) {
-            for (size_t i1 = 0; i1 < fs1->size(); i1++) {
-                for (size_t i2 = 1; i2 < fs2->size(); i2++) {
+        double
+        segmentDistance(const FacetSequence* fs1, const FacetSequence* fs2)
+        {
+            for(size_t i1 = 0; i1 < fs1->size(); i1++) {
+                for(size_t i2 = 1; i2 < fs2->size(); i2++) {
                     const Coordinate* p = fs1->getCoordinate(i1);
 
                     const Coordinate* seg0 = fs2->getCoordinate(i2 - 1);
                     const Coordinate* seg1 = fs2->getCoordinate(i2);
 
-                    if (! (p->equals2D(*seg0) || p->equals2D(*seg1))) {
+                    if(!(p->equals2D(*seg0) || p->equals2D(*seg1))) {
                         double d = geos::algorithm::Distance::pointToSegment(*p, *seg0, *seg1);
-                        if (d < minDist) {
+                        if(d < minDist) {
                             minDist = d;
                             updatePts(*p, *seg0, *seg1);
-                            if (d == 0.0)
+                            if(d == 0.0) {
                                 return d;
+                            }
                         }
                     }
                 }
@@ -142,7 +166,9 @@ void MinimumClearance::compute() {
     };
 
     struct ItemDeleter : public index::ItemVisitor {
-        void visitItem(void * item) override {
+        void
+        visitItem(void* item) override
+        {
             delete static_cast<FacetSequence*>(item);
         }
     };
@@ -150,9 +176,10 @@ void MinimumClearance::compute() {
     struct ManagedResourceSTRtree {
         STRtree* m_tree;
 
-        ManagedResourceSTRtree(STRtree * p_tree) : m_tree(p_tree) {}
+        ManagedResourceSTRtree(STRtree* p_tree) : m_tree(p_tree) {}
 
-        ~ManagedResourceSTRtree() {
+        ~ManagedResourceSTRtree()
+        {
             ItemDeleter id;
             m_tree->iterate(id);
 
@@ -161,24 +188,27 @@ void MinimumClearance::compute() {
     };
 
     // already computed
-    if (minClearancePts.get() != nullptr)
+    if(minClearancePts.get() != nullptr) {
         return;
+    }
 
     // initialize to "No Distance Exists" state
-    minClearancePts = std::unique_ptr<CoordinateSequence>(inputGeom->getFactory()->getCoordinateSequenceFactory()->create(2, 2));
+    minClearancePts = std::unique_ptr<CoordinateSequence>(inputGeom->getFactory()->getCoordinateSequenceFactory()->create(2,
+                      2));
     minClearance = std::numeric_limits<double>::infinity();
 
     // handle empty geometries
-    if (inputGeom->isEmpty())
+    if(inputGeom->isEmpty()) {
         return;
+    }
 
     ManagedResourceSTRtree tree(FacetSequenceTreeBuilder::build(inputGeom));
     MinClearanceDistance mcd;
-    std::pair<const void *, const void *> nearest = tree.m_tree->nearestNeighbour(&mcd);
+    std::pair<const void*, const void*> nearest = tree.m_tree->nearestNeighbour(&mcd);
 
     minClearance = mcd.distance(
-            static_cast<const FacetSequence *>(nearest.first),
-            static_cast<const FacetSequence *>(nearest.second));
+                       static_cast<const FacetSequence*>(nearest.first),
+                       static_cast<const FacetSequence*>(nearest.second));
 
     const std::vector<Coordinate>* minClearancePtsVec = mcd.getCoordinates();
     minClearancePts->setAt((*minClearancePtsVec)[0], 0);
diff --git a/src/precision/PrecisionReducerCoordinateOperation.cpp b/src/precision/PrecisionReducerCoordinateOperation.cpp
index 211d9db..20de484 100644
--- a/src/precision/PrecisionReducerCoordinateOperation.cpp
+++ b/src/precision/PrecisionReducerCoordinateOperation.cpp
@@ -34,62 +34,68 @@ namespace geos {
 namespace precision { // geos.precision
 
 CoordinateSequence*
-PrecisionReducerCoordinateOperation::edit(const CoordinateSequence *cs,
-                                          const Geometry *geom)
+PrecisionReducerCoordinateOperation::edit(const CoordinateSequence* cs,
+        const Geometry* geom)
 {
-	auto csSize = cs->size();
-
-	if ( csSize == 0 ) return nullptr;
-
-	vector<Coordinate> *vc = new vector<Coordinate>(csSize);
-
-	// copy coordinates and reduce
-	for (size_t i = 0; i < csSize; ++i) {
-		Coordinate coord=cs->getAt(i);
-		targetPM.makePrecise(&coord);
-		(*vc)[i] = coord;
-	}
-
-	// reducedCoords take ownership of 'vc'
-	CoordinateSequence *reducedCoords =
-		geom->getFactory()->getCoordinateSequenceFactory()->create(vc);
-
-	// remove repeated points, to simplify returned geometry as
-	// much as possible.
-	//
-	CoordinateSequence *noRepeatedCoords=CoordinateSequence::removeRepeatedPoints(reducedCoords);
-
-	/**
-	 * Check to see if the removal of repeated points
-	 * collapsed the coordinate List to an invalid length
-	 * for the type of the parent geometry.
-	 * It is not necessary to check for Point collapses,
-	 * since the coordinate list can
-	 * never collapse to less than one point.
-	 * If the length is invalid, return the full-length coordinate array
-	 * first computed, or null if collapses are being removed.
-	 * (This may create an invalid geometry - the client must handle this.)
-	 */
-	unsigned int minLength = 0;
-	if ( dynamic_cast<const LineString*>(geom) ) minLength = 2;
-	if ( dynamic_cast<const LinearRing*>(geom) ) minLength = 4;
-
-	CoordinateSequence *collapsedCoords = reducedCoords;
-	if ( removeCollapsed )
-	{
-		delete reducedCoords; reducedCoords=nullptr;
-		collapsedCoords=nullptr;
-	}
-
-	// return null or orginal length coordinate array
-	if ( noRepeatedCoords->getSize() < minLength ) {
-		delete noRepeatedCoords;
-		return collapsedCoords;
-	}
-
-	// ok to return shorter coordinate array
-	delete reducedCoords;
-	return noRepeatedCoords;
+    auto csSize = cs->size();
+
+    if(csSize == 0) {
+        return nullptr;
+    }
+
+    vector<Coordinate>* vc = new vector<Coordinate>(csSize);
+
+    // copy coordinates and reduce
+    for(size_t i = 0; i < csSize; ++i) {
+        Coordinate coord = cs->getAt(i);
+        targetPM.makePrecise(&coord);
+        (*vc)[i] = coord;
+    }
+
+    // reducedCoords take ownership of 'vc'
+    CoordinateSequence* reducedCoords =
+        geom->getFactory()->getCoordinateSequenceFactory()->create(vc);
+
+    // remove repeated points, to simplify returned geometry as
+    // much as possible.
+    //
+    CoordinateSequence* noRepeatedCoords = CoordinateSequence::removeRepeatedPoints(reducedCoords);
+
+    /**
+     * Check to see if the removal of repeated points
+     * collapsed the coordinate List to an invalid length
+     * for the type of the parent geometry.
+     * It is not necessary to check for Point collapses,
+     * since the coordinate list can
+     * never collapse to less than one point.
+     * If the length is invalid, return the full-length coordinate array
+     * first computed, or null if collapses are being removed.
+     * (This may create an invalid geometry - the client must handle this.)
+     */
+    unsigned int minLength = 0;
+    if(dynamic_cast<const LineString*>(geom)) {
+        minLength = 2;
+    }
+    if(dynamic_cast<const LinearRing*>(geom)) {
+        minLength = 4;
+    }
+
+    CoordinateSequence* collapsedCoords = reducedCoords;
+    if(removeCollapsed) {
+        delete reducedCoords;
+        reducedCoords = nullptr;
+        collapsedCoords = nullptr;
+    }
+
+    // return null or orginal length coordinate array
+    if(noRepeatedCoords->getSize() < minLength) {
+        delete noRepeatedCoords;
+        return collapsedCoords;
+    }
+
+    // ok to return shorter coordinate array
+    delete reducedCoords;
+    return noRepeatedCoords;
 }
 
 
diff --git a/src/precision/SimpleGeometryPrecisionReducer.cpp b/src/precision/SimpleGeometryPrecisionReducer.cpp
index 8cc2757..33a2cf2 100644
--- a/src/precision/SimpleGeometryPrecisionReducer.cpp
+++ b/src/precision/SimpleGeometryPrecisionReducer.cpp
@@ -41,84 +41,89 @@ namespace precision { // geos.precision
 namespace {
 
 class PrecisionReducerCoordinateOperation :
-		public geom::util::CoordinateOperation
-{
-using CoordinateOperation::edit;
+    public geom::util::CoordinateOperation {
+    using CoordinateOperation::edit;
 private:
 
-	SimpleGeometryPrecisionReducer *sgpr;
+    SimpleGeometryPrecisionReducer* sgpr;
 
 public:
 
-	PrecisionReducerCoordinateOperation(
-		SimpleGeometryPrecisionReducer *newSgpr);
+    PrecisionReducerCoordinateOperation(
+        SimpleGeometryPrecisionReducer* newSgpr);
 
-	/// Ownership of returned CoordinateSequence to caller
-	CoordinateSequence* edit(const CoordinateSequence *coordinates,
-	                         const Geometry *geom) override;
+    /// Ownership of returned CoordinateSequence to caller
+    CoordinateSequence* edit(const CoordinateSequence* coordinates,
+                             const Geometry* geom) override;
 };
 
 PrecisionReducerCoordinateOperation::PrecisionReducerCoordinateOperation(
-		SimpleGeometryPrecisionReducer *newSgpr)
+    SimpleGeometryPrecisionReducer* newSgpr)
 {
-	sgpr=newSgpr;
+    sgpr = newSgpr;
 }
 
 CoordinateSequence*
-PrecisionReducerCoordinateOperation::edit(const CoordinateSequence *cs,
-                                          const Geometry *geom)
+PrecisionReducerCoordinateOperation::edit(const CoordinateSequence* cs,
+        const Geometry* geom)
 {
-	if (cs->getSize()==0) return nullptr;
-
-	auto csSize = cs->size();
-
-	vector<Coordinate> *vc = new vector<Coordinate>(csSize);
-
-	// copy coordinates and reduce
-	for (unsigned int i=0; i<csSize; ++i) {
-		Coordinate coord=cs->getAt(i);
-		sgpr->getPrecisionModel()->makePrecise(&coord);
-		//reducedCoords->setAt(*coord,i);
-		(*vc)[i] = coord;
-	}
-
-	// reducedCoords take ownership of 'vc'
-	CoordinateSequence *reducedCoords =
-		geom->getFactory()->getCoordinateSequenceFactory()->create(vc);
-
-	// remove repeated points, to simplify returned geometry as
-	// much as possible.
-	//
-	CoordinateSequence *noRepeatedCoords=CoordinateSequence::removeRepeatedPoints(reducedCoords);
-
-	/**
-	 * Check to see if the removal of repeated points
-	 * collapsed the coordinate List to an invalid length
-	 * for the type of the parent geometry.
-	 * It is not necessary to check for Point collapses,
-	 * since the coordinate list can
-	 * never collapse to less than one point.
-	 * If the length is invalid, return the full-length coordinate array
-	 * first computed, or null if collapses are being removed.
-	 * (This may create an invalid geometry - the client must handle this.)
-	 */
-	unsigned int minLength = 0;
-	if (typeid(*geom)==typeid(LineString)) minLength = 2;
-	if (typeid(*geom)==typeid(LinearRing)) minLength = 4;
-	CoordinateSequence *collapsedCoords = reducedCoords;
-	if (sgpr->getRemoveCollapsed())
-	{
-		delete reducedCoords; reducedCoords=nullptr;
-		collapsedCoords=nullptr;
-	}
-	// return null or orginal length coordinate array
-	if (noRepeatedCoords->getSize()<minLength) {
-		delete noRepeatedCoords;
-		return collapsedCoords;
-	}
-	// ok to return shorter coordinate array
-	delete reducedCoords;
-	return noRepeatedCoords;
+    if(cs->getSize() == 0) {
+        return nullptr;
+    }
+
+    auto csSize = cs->size();
+
+    vector<Coordinate>* vc = new vector<Coordinate>(csSize);
+
+    // copy coordinates and reduce
+    for(unsigned int i = 0; i < csSize; ++i) {
+        Coordinate coord = cs->getAt(i);
+        sgpr->getPrecisionModel()->makePrecise(&coord);
+        //reducedCoords->setAt(*coord,i);
+        (*vc)[i] = coord;
+    }
+
+    // reducedCoords take ownership of 'vc'
+    CoordinateSequence* reducedCoords =
+        geom->getFactory()->getCoordinateSequenceFactory()->create(vc);
+
+    // remove repeated points, to simplify returned geometry as
+    // much as possible.
+    //
+    CoordinateSequence* noRepeatedCoords = CoordinateSequence::removeRepeatedPoints(reducedCoords);
+
+    /**
+     * Check to see if the removal of repeated points
+     * collapsed the coordinate List to an invalid length
+     * for the type of the parent geometry.
+     * It is not necessary to check for Point collapses,
+     * since the coordinate list can
+     * never collapse to less than one point.
+     * If the length is invalid, return the full-length coordinate array
+     * first computed, or null if collapses are being removed.
+     * (This may create an invalid geometry - the client must handle this.)
+     */
+    unsigned int minLength = 0;
+    if(typeid(*geom) == typeid(LineString)) {
+        minLength = 2;
+    }
+    if(typeid(*geom) == typeid(LinearRing)) {
+        minLength = 4;
+    }
+    CoordinateSequence* collapsedCoords = reducedCoords;
+    if(sgpr->getRemoveCollapsed()) {
+        delete reducedCoords;
+        reducedCoords = nullptr;
+        collapsedCoords = nullptr;
+    }
+    // return null or orginal length coordinate array
+    if(noRepeatedCoords->getSize() < minLength) {
+        delete noRepeatedCoords;
+        return collapsedCoords;
+    }
+    // ok to return shorter coordinate array
+    delete reducedCoords;
+    return noRepeatedCoords;
 }
 
 } // anonymous namespace
@@ -127,14 +132,14 @@ PrecisionReducerCoordinateOperation::edit(const CoordinateSequence *cs,
 
 
 SimpleGeometryPrecisionReducer::SimpleGeometryPrecisionReducer(
-		const PrecisionModel *pm)
-	:
-	newPrecisionModel(pm),
-	removeCollapsed(true)
+    const PrecisionModel* pm)
+    :
+    newPrecisionModel(pm),
+    removeCollapsed(true)
 {
-	//removeCollapsed = true;
-	//changePrecisionModel = false;
-	//newPrecisionModel = pm;
+    //removeCollapsed = true;
+    //changePrecisionModel = false;
+    //newPrecisionModel = pm;
 }
 
 /**
@@ -147,28 +152,28 @@ SimpleGeometryPrecisionReducer::SimpleGeometryPrecisionReducer(
 void
 SimpleGeometryPrecisionReducer::setRemoveCollapsedComponents(bool nRemoveCollapsed)
 {
-	removeCollapsed=nRemoveCollapsed;
+    removeCollapsed = nRemoveCollapsed;
 }
 
 const PrecisionModel*
 SimpleGeometryPrecisionReducer::getPrecisionModel()
 {
-	return newPrecisionModel;
+    return newPrecisionModel;
 }
 
 bool
 SimpleGeometryPrecisionReducer::getRemoveCollapsed()
 {
-	return removeCollapsed;
+    return removeCollapsed;
 }
 
 Geometry*
-SimpleGeometryPrecisionReducer::reduce(const Geometry *geom)
+SimpleGeometryPrecisionReducer::reduce(const Geometry* geom)
 {
-	GeometryEditor geomEdit;
-	PrecisionReducerCoordinateOperation prco(this);
-	Geometry *g=geomEdit.edit(geom, &prco);
-	return g;
+    GeometryEditor geomEdit;
+    PrecisionReducerCoordinateOperation prco(this);
+    Geometry* g = geomEdit.edit(geom, &prco);
+    return g;
 }
 
 } // namespace geos.precision
diff --git a/src/simplify/DouglasPeuckerLineSimplifier.cpp b/src/simplify/DouglasPeuckerLineSimplifier.cpp
index d10c022..bcd0418 100644
--- a/src/simplify/DouglasPeuckerLineSimplifier.cpp
+++ b/src/simplify/DouglasPeuckerLineSimplifier.cpp
@@ -31,86 +31,86 @@ namespace simplify { // geos::simplify
 /*public static*/
 DouglasPeuckerLineSimplifier::CoordsVectAutoPtr
 DouglasPeuckerLineSimplifier::simplify(
-		const DouglasPeuckerLineSimplifier::CoordsVect& nPts,
-		double distanceTolerance)
+    const DouglasPeuckerLineSimplifier::CoordsVect& nPts,
+    double distanceTolerance)
 {
-	DouglasPeuckerLineSimplifier simp(nPts);
-	simp.setDistanceTolerance(distanceTolerance);
-	return simp.simplify();
+    DouglasPeuckerLineSimplifier simp(nPts);
+    simp.setDistanceTolerance(distanceTolerance);
+    return simp.simplify();
 }
 
 /*public*/
 DouglasPeuckerLineSimplifier::DouglasPeuckerLineSimplifier(
-		const DouglasPeuckerLineSimplifier::CoordsVect& nPts)
-	:
-	pts(nPts)
+    const DouglasPeuckerLineSimplifier::CoordsVect& nPts)
+    :
+    pts(nPts)
 {
 }
 
 /*public*/
 void
 DouglasPeuckerLineSimplifier::setDistanceTolerance(
-		double nDistanceTolerance)
+    double nDistanceTolerance)
 {
-	distanceTolerance=nDistanceTolerance;
+    distanceTolerance = nDistanceTolerance;
 }
 
 /*public*/
 DouglasPeuckerLineSimplifier::CoordsVectAutoPtr
 DouglasPeuckerLineSimplifier::simplify()
 {
-	CoordsVectAutoPtr coordList(new CoordsVect());
+    CoordsVectAutoPtr coordList(new CoordsVect());
 
-	// empty coordlist is the simplest, won't simplify further
-	if ( ! pts.size() ) return coordList;
+    // empty coordlist is the simplest, won't simplify further
+    if(! pts.size()) {
+        return coordList;
+    }
 
-	usePt = BoolVectAutoPtr(new BoolVect(pts.size(), true));
-	simplifySection(0, pts.size() - 1);
+    usePt = BoolVectAutoPtr(new BoolVect(pts.size(), true));
+    simplifySection(0, pts.size() - 1);
 
-	for (std::size_t i=0, n=pts.size(); i<n; ++i)
-	{
-		if ( usePt->operator[](i) )
-		{
-			coordList->push_back(pts[i]);
-		}
-	}
+    for(std::size_t i = 0, n = pts.size(); i < n; ++i) {
+        if(usePt->operator[](i)) {
+            coordList->push_back(pts[i]);
+        }
+    }
 
-	// unique_ptr transfer ownership to its
-	// returned copy
-	return coordList;
+    // unique_ptr transfer ownership to its
+    // returned copy
+    return coordList;
 }
 
 /*private*/
 void
 DouglasPeuckerLineSimplifier::simplifySection(
-		std::size_t i,
-		std::size_t j)
+    std::size_t i,
+    std::size_t j)
 {
-	if ( (i+1) == j ) return;
-
-	geos::geom::LineSegment seg(pts[i], pts[j]);
-	double maxDistance = -1.0;
-
-	std::size_t maxIndex = i;
-
-	for (std::size_t k=i+1; k<j; k++)
-	{
-		double distance = seg.distance(pts[k]);
-		if (distance > maxDistance) {
-			maxDistance = distance;
-			maxIndex = k;
-		}
-	}
-	if (maxDistance <= distanceTolerance) {
-		for(std::size_t k =i+1; k<j; k++)
-		{
-			usePt->operator[](k) = false;
-		}
-	}
-	else {
-		simplifySection(i, maxIndex);
-		simplifySection(maxIndex, j);
-	}
+    if((i + 1) == j) {
+        return;
+    }
+
+    geos::geom::LineSegment seg(pts[i], pts[j]);
+    double maxDistance = -1.0;
+
+    std::size_t maxIndex = i;
+
+    for(std::size_t k = i + 1; k < j; k++) {
+        double distance = seg.distance(pts[k]);
+        if(distance > maxDistance) {
+            maxDistance = distance;
+            maxIndex = k;
+        }
+    }
+    if(maxDistance <= distanceTolerance) {
+        for(std::size_t k = i + 1; k < j; k++) {
+            usePt->operator[](k) = false;
+        }
+    }
+    else {
+        simplifySection(i, maxIndex);
+        simplifySection(maxIndex, j);
+    }
 }
 
 } // namespace geos::simplify
diff --git a/src/simplify/DouglasPeuckerSimplifier.cpp b/src/simplify/DouglasPeuckerSimplifier.cpp
index 48bd6dd..d76030f 100644
--- a/src/simplify/DouglasPeuckerSimplifier.cpp
+++ b/src/simplify/DouglasPeuckerSimplifier.cpp
@@ -47,108 +47,108 @@ class DPTransformer: public geom::util::GeometryTransformer {
 
 public:
 
-	DPTransformer(double tolerance);
+    DPTransformer(double tolerance);
 
 protected:
 
-	CoordinateSequence::Ptr transformCoordinates(
-			const CoordinateSequence* coords,
-			const Geometry* parent) override;
+    CoordinateSequence::Ptr transformCoordinates(
+        const CoordinateSequence* coords,
+        const Geometry* parent) override;
 
-	Geometry::Ptr transformPolygon(
-			const Polygon* geom,
-			const Geometry* parent) override;
+    Geometry::Ptr transformPolygon(
+        const Polygon* geom,
+        const Geometry* parent) override;
 
-	Geometry::Ptr transformMultiPolygon(
-			const MultiPolygon* geom,
-			const Geometry* parent) override;
+    Geometry::Ptr transformMultiPolygon(
+        const MultiPolygon* geom,
+        const Geometry* parent) override;
 
 private:
 
-	/*
-	 * Creates a valid area geometry from one that possibly has
-	 * bad topology (i.e. self-intersections).
-	 * Since buffer can handle invalid topology, but always returns
-	 * valid geometry, constructing a 0-width buffer "corrects" the
-	 * topology.
-	 * Note this only works for area geometries, since buffer always returns
-	 * areas.  This also may return empty geometries, if the input
-	 * has no actual area.
-	 *
-	 * @param roughAreaGeom an area geometry possibly containing
-	 *        self-intersections
-	 * @return a valid area geometry
-	 */
-	Geometry::Ptr createValidArea(const Geometry* roughAreaGeom);
-
-	double distanceTolerance;
+    /*
+     * Creates a valid area geometry from one that possibly has
+     * bad topology (i.e. self-intersections).
+     * Since buffer can handle invalid topology, but always returns
+     * valid geometry, constructing a 0-width buffer "corrects" the
+     * topology.
+     * Note this only works for area geometries, since buffer always returns
+     * areas.  This also may return empty geometries, if the input
+     * has no actual area.
+     *
+     * @param roughAreaGeom an area geometry possibly containing
+     *        self-intersections
+     * @return a valid area geometry
+     */
+    Geometry::Ptr createValidArea(const Geometry* roughAreaGeom);
+
+    double distanceTolerance;
 
 };
 
 DPTransformer::DPTransformer(double t)
-	:
-	distanceTolerance(t)
+    :
+    distanceTolerance(t)
 {
-	setSkipTransformedInvalidInteriorRings(true);
+    setSkipTransformedInvalidInteriorRings(true);
 }
 
 Geometry::Ptr
 DPTransformer::createValidArea(const Geometry* roughAreaGeom)
 {
-	return Geometry::Ptr(roughAreaGeom->buffer(0.0));
+    return Geometry::Ptr(roughAreaGeom->buffer(0.0));
 }
 
 CoordinateSequence::Ptr
 DPTransformer::transformCoordinates(
-		const CoordinateSequence* coords,
-		const Geometry* parent)
+    const CoordinateSequence* coords,
+    const Geometry* parent)
 {
     ::geos::ignore_unused_variable_warning(parent);
 
-	const Coordinate::Vect* inputPts = coords->toVector();
-	assert(inputPts);
+    const Coordinate::Vect* inputPts = coords->toVector();
+    assert(inputPts);
 
-	std::unique_ptr<Coordinate::Vect> newPts =
-			DouglasPeuckerLineSimplifier::simplify(*inputPts,
-				distanceTolerance);
+    std::unique_ptr<Coordinate::Vect> newPts =
+        DouglasPeuckerLineSimplifier::simplify(*inputPts,
+                distanceTolerance);
 
-	return CoordinateSequence::Ptr(
-		factory->getCoordinateSequenceFactory()->create(
-			newPts.release()
-		));
+    return CoordinateSequence::Ptr(
+               factory->getCoordinateSequenceFactory()->create(
+                   newPts.release()
+               ));
 }
 
 Geometry::Ptr
 DPTransformer::transformPolygon(
-		const Polygon* geom,
-		const Geometry* parent)
+    const Polygon* geom,
+    const Geometry* parent)
 {
 
 #if GEOS_DEBUG
-	std::cerr << "DPTransformer::transformPolygon(Polygon " << geom << ", Geometry " << parent << ");" << std::endl;
+    std::cerr << "DPTransformer::transformPolygon(Polygon " << geom << ", Geometry " << parent << ");" << std::endl;
 #endif
 
-	Geometry::Ptr roughGeom(GeometryTransformer::transformPolygon(geom, parent));
+    Geometry::Ptr roughGeom(GeometryTransformer::transformPolygon(geom, parent));
 
-        // don't try and correct if the parent is going to do this
-	if ( dynamic_cast<const MultiPolygon*>(parent) )
-	{
-		return roughGeom;
-	}
+    // don't try and correct if the parent is going to do this
+    if(dynamic_cast<const MultiPolygon*>(parent)) {
+        return roughGeom;
+    }
 
-	return createValidArea(roughGeom.get());
+    return createValidArea(roughGeom.get());
 }
 
 Geometry::Ptr
 DPTransformer::transformMultiPolygon(
-		const MultiPolygon* geom,
-		const Geometry* parent)
+    const MultiPolygon* geom,
+    const Geometry* parent)
 {
 #if GEOS_DEBUG
-	std::cerr << "DPTransformer::transformMultiPolygon(MultiPolygon " << geom << ", Geometry " << parent << ");" << std::endl;
+    std::cerr << "DPTransformer::transformMultiPolygon(MultiPolygon " << geom << ", Geometry " << parent << ");" <<
+              std::endl;
 #endif
-	Geometry::Ptr roughGeom(GeometryTransformer::transformMultiPolygon(geom, parent));
-        return createValidArea(roughGeom.get());
+    Geometry::Ptr roughGeom(GeometryTransformer::transformMultiPolygon(geom, parent));
+    return createValidArea(roughGeom.get());
 }
 
 /************************************************************************/
@@ -160,17 +160,17 @@ DPTransformer::transformMultiPolygon(
 /*public static*/
 Geometry::Ptr
 DouglasPeuckerSimplifier::simplify(const Geometry* geom,
-		double tolerance)
+                                   double tolerance)
 {
-	DouglasPeuckerSimplifier tss(geom);
-	tss.setDistanceTolerance(tolerance);
-	return tss.getResultGeometry();
+    DouglasPeuckerSimplifier tss(geom);
+    tss.setDistanceTolerance(tolerance);
+    return tss.getResultGeometry();
 }
 
 /*public*/
 DouglasPeuckerSimplifier::DouglasPeuckerSimplifier(const Geometry* geom)
-	:
-	inputGeom(geom)
+    :
+    inputGeom(geom)
 {
 }
 
@@ -178,16 +178,17 @@ DouglasPeuckerSimplifier::DouglasPeuckerSimplifier(const Geometry* geom)
 void
 DouglasPeuckerSimplifier::setDistanceTolerance(double tol)
 {
-	if (tol < 0.0)
-		throw util::IllegalArgumentException("Tolerance must be non-negative");
-	distanceTolerance = tol;
+    if(tol < 0.0) {
+        throw util::IllegalArgumentException("Tolerance must be non-negative");
+    }
+    distanceTolerance = tol;
 }
 
 Geometry::Ptr
 DouglasPeuckerSimplifier::getResultGeometry()
 {
-	DPTransformer t(distanceTolerance);
-	return t.transform(inputGeom);
+    DPTransformer t(distanceTolerance);
+    return t.transform(inputGeom);
 
 }
 
diff --git a/src/simplify/LineSegmentIndex.cpp b/src/simplify/LineSegmentIndex.cpp
index 04efda0..2395495 100644
--- a/src/simplify/LineSegmentIndex.cpp
+++ b/src/simplify/LineSegmentIndex.cpp
@@ -52,55 +52,59 @@ class LineSegmentVisitor: public index::ItemVisitor {
 
 private:
 
-	const LineSegment* querySeg;
+    const LineSegment* querySeg;
 
-	unique_ptr< vector<LineSegment*> > items;
+    unique_ptr< vector<LineSegment*> > items;
 
 public:
 
-	LineSegmentVisitor(const LineSegment* s)
-		:
-		ItemVisitor(),
-		querySeg(s),
-		items(new vector<LineSegment*>())
-	{}
-
-	~LineSegmentVisitor() override
-	{
-		// nothing to do, LineSegments are not owned by us
-	}
-
-	LineSegmentVisitor(const LineSegmentVisitor& o)
-		:
-		ItemVisitor(),
-		querySeg(o.querySeg),
-		items(new vector<LineSegment*>(*(o.items.get())))
-	{
-	}
-
-	LineSegmentVisitor& operator=(const LineSegmentVisitor& o)
-	{
-		if ( this == &o ) return *this;
-		querySeg = o.querySeg;
-		items.reset(new vector<LineSegment*>(*(o.items.get())));
-		return *this;
-	}
-
-	void visitItem(void* item) override
-	{
-		LineSegment* seg = (LineSegment*) item;
-		if ( Envelope::intersects(seg->p0, seg->p1,
-				querySeg->p0, querySeg->p1) )
-		{
-			items->push_back(seg);
-		}
-	}
-
-	unique_ptr< vector<LineSegment*> > getItems()
-	{
-		// NOTE: Apparently, this is 'source' method giving up the object resource.
-		return std::move(items);
-	}
+    LineSegmentVisitor(const LineSegment* s)
+        :
+        ItemVisitor(),
+        querySeg(s),
+        items(new vector<LineSegment*>())
+    {}
+
+    ~LineSegmentVisitor() override
+    {
+        // nothing to do, LineSegments are not owned by us
+    }
+
+    LineSegmentVisitor(const LineSegmentVisitor& o)
+        :
+        ItemVisitor(),
+        querySeg(o.querySeg),
+        items(new vector<LineSegment*>(*(o.items.get())))
+    {
+    }
+
+    LineSegmentVisitor&
+    operator=(const LineSegmentVisitor& o)
+    {
+        if(this == &o) {
+            return *this;
+        }
+        querySeg = o.querySeg;
+        items.reset(new vector<LineSegment*>(*(o.items.get())));
+        return *this;
+    }
+
+    void
+    visitItem(void* item) override
+    {
+        LineSegment* seg = (LineSegment*) item;
+        if(Envelope::intersects(seg->p0, seg->p1,
+                                querySeg->p0, querySeg->p1)) {
+            items->push_back(seg);
+        }
+    }
+
+    unique_ptr< vector<LineSegment*> >
+    getItems()
+    {
+        // NOTE: Apparently, this is 'source' method giving up the object resource.
+        return std::move(items);
+    }
 
 
 };
@@ -110,47 +114,47 @@ public:
 void
 LineSegmentIndex::add(const TaggedLineString& line)
 {
-	for (const LineSegment* seg : line.getSegments()) {
-		add(seg);
-	}
+    for(const LineSegment* seg : line.getSegments()) {
+        add(seg);
+    }
 }
 
 /*public*/
 void
 LineSegmentIndex::add(const LineSegment* seg)
 {
-	std::unique_ptr<Envelope> env{new Envelope(seg->p0, seg->p1)};
+    std::unique_ptr<Envelope> env{new Envelope(seg->p0, seg->p1)};
 
-	// We need a cast because index wants a non-const,
-	// although it won't change the argument
-	index.insert(env.get(), const_cast<LineSegment*>(seg));
+    // We need a cast because index wants a non-const,
+    // although it won't change the argument
+    index.insert(env.get(), const_cast<LineSegment*>(seg));
 
-	newEnvelopes.push_back(std::move(env));
+    newEnvelopes.push_back(std::move(env));
 }
 
 /*public*/
 void
 LineSegmentIndex::remove(const LineSegment* seg)
 {
-	Envelope env(seg->p0, seg->p1);
+    Envelope env(seg->p0, seg->p1);
 
-	// We need a cast because index wants a non-const
-	// although it won't change the argument
-	index.remove(&env, const_cast<LineSegment*>(seg));
+    // We need a cast because index wants a non-const
+    // although it won't change the argument
+    index.remove(&env, const_cast<LineSegment*>(seg));
 }
 
 /*public*/
 unique_ptr< vector<LineSegment*> >
 LineSegmentIndex::query(const LineSegment* querySeg)
 {
-	Envelope env(querySeg->p0, querySeg->p1);
+    Envelope env(querySeg->p0, querySeg->p1);
 
-	LineSegmentVisitor visitor(querySeg);
-	index.query(&env, visitor);
+    LineSegmentVisitor visitor(querySeg);
+    index.query(&env, visitor);
 
-	unique_ptr< vector<LineSegment*> > itemsFound = visitor.getItems();
+    unique_ptr< vector<LineSegment*> > itemsFound = visitor.getItems();
 
-	return itemsFound;
+    return itemsFound;
 }
 
 } // namespace geos::simplify
diff --git a/src/simplify/TaggedLineSegment.cpp b/src/simplify/TaggedLineSegment.cpp
index 142eeef..fccd44f 100644
--- a/src/simplify/TaggedLineSegment.cpp
+++ b/src/simplify/TaggedLineSegment.cpp
@@ -32,43 +32,43 @@ namespace geos {
 namespace simplify { // geos::simplify
 
 TaggedLineSegment::TaggedLineSegment(const geom::Coordinate& p_p0,
-			const geom::Coordinate& p_p1,
-			const geom::Geometry* nParent,
-			size_t nIndex)
-	:
-	LineSegment(p_p0, p_p1),
-	parent(nParent),
-	index(nIndex)
+                                     const geom::Coordinate& p_p1,
+                                     const geom::Geometry* nParent,
+                                     size_t nIndex)
+    :
+    LineSegment(p_p0, p_p1),
+    parent(nParent),
+    index(nIndex)
 {
 }
 
 TaggedLineSegment::TaggedLineSegment(const geom::Coordinate& p_p0,
-			const geom::Coordinate& p_p1)
-	:
-	LineSegment(p_p0, p_p1),
-	parent(nullptr),
-	index(0)
+                                     const geom::Coordinate& p_p1)
+    :
+    LineSegment(p_p0, p_p1),
+    parent(nullptr),
+    index(0)
 {
 }
 
 TaggedLineSegment::TaggedLineSegment(const TaggedLineSegment& ls)
-	:
-	LineSegment(ls),
-	parent(ls.parent),
-	index(ls.index)
+    :
+    LineSegment(ls),
+    parent(ls.parent),
+    index(ls.index)
 {
 }
 
 const geom::Geometry*
 TaggedLineSegment::getParent() const
 {
-	return parent;
+    return parent;
 }
 
 size_t
 TaggedLineSegment::getIndex() const
 {
-	return index;
+    return index;
 }
 
 } // namespace geos::simplify
diff --git a/src/simplify/TaggedLineString.cpp b/src/simplify/TaggedLineString.cpp
index f7b94fa..5de6932 100644
--- a/src/simplify/TaggedLineString.cpp
+++ b/src/simplify/TaggedLineString.cpp
@@ -43,63 +43,63 @@ namespace simplify { // geos::simplify
 
 /*public*/
 TaggedLineString::TaggedLineString(const geom::LineString* nParentLine,
-			std::size_t nMinimumSize)
-	:
-	parentLine(nParentLine),
-	minimumSize(nMinimumSize)
+                                   std::size_t nMinimumSize)
+    :
+    parentLine(nParentLine),
+    minimumSize(nMinimumSize)
 {
-	init();
+    init();
 }
 
 /*public*/
 TaggedLineString::~TaggedLineString()
 {
 #if GEOS_DEBUG
-	cerr << "TaggedLineString[" << this << "] destructor"
-	     << endl;
+    cerr << "TaggedLineString[" << this << "] destructor"
+         << endl;
 #endif
 
-	for (std::size_t i=0, n=segs.size(); i<n; i++)
-		delete segs[i];
+    for(std::size_t i = 0, n = segs.size(); i < n; i++) {
+        delete segs[i];
+    }
 
-	for (std::size_t i=0, n=resultSegs.size(); i<n; i++)
-		delete resultSegs[i];
+    for(std::size_t i = 0, n = resultSegs.size(); i < n; i++) {
+        delete resultSegs[i];
+    }
 }
 
 /*private*/
 void
 TaggedLineString::init()
 {
-	assert(parentLine);
-	const CoordinateSequence* pts = parentLine->getCoordinatesRO();
+    assert(parentLine);
+    const CoordinateSequence* pts = parentLine->getCoordinatesRO();
 
 #if GEOS_DEBUG
-	cerr << "TaggedLineString[" << this << "] pts.size() " << pts->size()
-	     << endl;
+    cerr << "TaggedLineString[" << this << "] pts.size() " << pts->size()
+         << endl;
 #endif
 
-	if ( pts->size() )
-	{
+    if(pts->size()) {
 
-		segs.reserve(pts->size()-1);
+        segs.reserve(pts->size() - 1);
 
-		for (std::size_t i=0, n=pts->size()-1; i<n; i++)
-		{
-			TaggedLineSegment* seg = new TaggedLineSegment(
-					pts->getAt(i),
-					pts->getAt(i+1),
-					parentLine, i);
+        for(std::size_t i = 0, n = pts->size() - 1; i < n; i++) {
+            TaggedLineSegment* seg = new TaggedLineSegment(
+                pts->getAt(i),
+                pts->getAt(i + 1),
+                parentLine, i);
 
-			segs.push_back(seg);
-		}
+            segs.push_back(seg);
+        }
 
-	}
+    }
 
 #if GEOS_DEBUG
-	cerr << "TaggedLineString[" << this << "] segs.size " << segs.size()
-	    << endl;
-	cerr << "TaggedLineString[" << this << "] resultSegs.size " << resultSegs.size()
-	    << endl;
+    cerr << "TaggedLineString[" << this << "] segs.size " << segs.size()
+         << endl;
+    cerr << "TaggedLineString[" << this << "] resultSegs.size " << resultSegs.size()
+         << endl;
 #endif
 }
 
@@ -107,22 +107,22 @@ TaggedLineString::init()
 std::size_t
 TaggedLineString::getMinimumSize() const
 {
-	return minimumSize;
+    return minimumSize;
 }
 
 /*public*/
 const geom::LineString*
 TaggedLineString::getParent() const
 {
-	return parentLine;
+    return parentLine;
 }
 
 /*public*/
 const CoordinateSequence*
 TaggedLineString::getParentCoordinates() const
 {
-	assert(parentLine);
-	return parentLine->getCoordinatesRO();
+    assert(parentLine);
+    return parentLine->getCoordinatesRO();
 }
 
 /*public*/
@@ -131,102 +131,101 @@ TaggedLineString::getResultCoordinates() const
 {
 
 #if GEOS_DEBUG
-	cerr << __FUNCTION__ << " resultSegs.size: "
-	     << resultSegs.size() << endl;
+    cerr << __FUNCTION__ << " resultSegs.size: "
+         << resultSegs.size() << endl;
 #endif
 
-	CoordVectPtr pts = extractCoordinates(resultSegs);
+    CoordVectPtr pts = extractCoordinates(resultSegs);
 
 #if GEOS_DEBUG
-	cerr << __FUNCTION__ << " extracted Coords.size: "
-	     << pts->size() << endl;
+    cerr << __FUNCTION__ << " extracted Coords.size: "
+         << pts->size() << endl;
 #endif
 
 
-	CoordVect* v = pts.release();
-	return CoordinateSequence::Ptr(parentLine->getFactory()->getCoordinateSequenceFactory()->create(v));
+    CoordVect* v = pts.release();
+    return CoordinateSequence::Ptr(parentLine->getFactory()->getCoordinateSequenceFactory()->create(v));
 
 }
 
 /*private static*/
 TaggedLineString::CoordVectPtr
 TaggedLineString::extractCoordinates(
-		const std::vector<TaggedLineSegment*>& segs)
+    const std::vector<TaggedLineSegment*>& segs)
 {
-	CoordVectPtr pts(new CoordVect());
+    CoordVectPtr pts(new CoordVect());
 
 #if GEOS_DEBUG
-	cerr << __FUNCTION__ << " segs.size: " << segs.size() << endl;
+    cerr << __FUNCTION__ << " segs.size: " << segs.size() << endl;
 #endif
 
-	std::size_t i=0, size=segs.size();
+    std::size_t i = 0, size = segs.size();
 
-	if ( size ) {
-		for (; i<size; i++)
-		{
-			TaggedLineSegment* seg = segs[i];
-			assert(seg);
-			pts->push_back(seg->p0);
-		}
+    if(size) {
+        for(; i < size; i++) {
+            TaggedLineSegment* seg = segs[i];
+            assert(seg);
+            pts->push_back(seg->p0);
+        }
 
-		// add last point
-		pts->push_back(segs[size-1]->p1);
-	}
+        // add last point
+        pts->push_back(segs[size - 1]->p1);
+    }
 
-	return pts;
+    return pts;
 }
 
 /*public*/
 std::size_t
 TaggedLineString::getResultSize() const
 {
-	auto resultSegsSize = resultSegs.size();
-	return resultSegsSize == 0 ? 0 : resultSegsSize + 1;
+    auto resultSegsSize = resultSegs.size();
+    return resultSegsSize == 0 ? 0 : resultSegsSize + 1;
 }
 
 /*public*/
 TaggedLineSegment*
 TaggedLineString::getSegment(std::size_t i)
 {
-	return segs[i];
+    return segs[i];
 }
 
 /*public*/
 const TaggedLineSegment*
 TaggedLineString::getSegment(std::size_t i) const
 {
-	return segs[i];
+    return segs[i];
 }
 
 /*public*/
 vector<TaggedLineSegment*>&
 TaggedLineString::getSegments()
 {
-	assert(0);
-	return segs;
+    assert(0);
+    return segs;
 }
 
 /*public*/
 const vector<TaggedLineSegment*>&
 TaggedLineString::getSegments() const
 {
-	return segs;
+    return segs;
 }
 
 /*public*/
 unique_ptr<Geometry>
 TaggedLineString::asLineString() const
 {
-	return parentLine->getFactory()->createLineString(
-			getResultCoordinates());
+    return parentLine->getFactory()->createLineString(
+               getResultCoordinates());
 }
 
 /*public*/
 unique_ptr<Geometry>
 TaggedLineString::asLinearRing() const
 {
-	return parentLine->getFactory()->createLinearRing(
-			getResultCoordinates());
+    return parentLine->getFactory()->createLinearRing(
+               getResultCoordinates());
 }
 
 /*public*/
@@ -234,15 +233,15 @@ void
 TaggedLineString::addToResult(unique_ptr<TaggedLineSegment> seg)
 {
 #if GEOS_DEBUG
-	cerr << "TaggedLineString[" << this << "] adding "
-	     << " seg " << seg.get() << " to result"
-	     << endl;
+    cerr << "TaggedLineString[" << this << "] adding "
+         << " seg " << seg.get() << " to result"
+         << endl;
 #endif
-	resultSegs.push_back(seg.release());
+    resultSegs.push_back(seg.release());
 #if GEOS_DEBUG
-	cerr << "TaggedLineString[" << this << "] adding "
-	     << " seg " << seg.get() << " to result"
-	     << endl;
+    cerr << "TaggedLineString[" << this << "] adding "
+         << " seg " << seg.get() << " to result"
+         << endl;
 #endif
 }
 
diff --git a/src/simplify/TaggedLineStringSimplifier.cpp b/src/simplify/TaggedLineStringSimplifier.cpp
index 95218c0..b97d9b1 100644
--- a/src/simplify/TaggedLineStringSimplifier.cpp
+++ b/src/simplify/TaggedLineStringSimplifier.cpp
@@ -47,15 +47,15 @@ namespace simplify { // geos::simplify
 
 /*public*/
 TaggedLineStringSimplifier::TaggedLineStringSimplifier(
-		LineSegmentIndex* nInputIndex,
-		LineSegmentIndex* nOutputIndex)
-	:
-	inputIndex(nInputIndex),
-	outputIndex(nOutputIndex),
-	li(new algorithm::LineIntersector()),
-	line(nullptr),
-	linePts(nullptr),
-	distanceTolerance(0.0)
+    LineSegmentIndex* nInputIndex,
+    LineSegmentIndex* nOutputIndex)
+    :
+    inputIndex(nInputIndex),
+    outputIndex(nOutputIndex),
+    li(new algorithm::LineIntersector()),
+    line(nullptr),
+    linePts(nullptr),
+    distanceTolerance(0.0)
 {
 }
 
@@ -63,21 +63,23 @@ TaggedLineStringSimplifier::TaggedLineStringSimplifier(
 void
 TaggedLineStringSimplifier::simplify(TaggedLineString* nLine)
 {
-	assert(nLine);
-	line = nLine;
+    assert(nLine);
+    line = nLine;
 
-	linePts = line->getParentCoordinates();
-	assert(linePts);
+    linePts = line->getParentCoordinates();
+    assert(linePts);
 
 #if GEOS_DEBUG
-	std::cerr << "TaggedLineStringSimplifier[" << this << "] "
-	     << " TaggedLineString[" << line << "] "
-	     << " has " << linePts->size() << " coords in input"
-	     << std::endl;
+    std::cerr << "TaggedLineStringSimplifier[" << this << "] "
+              << " TaggedLineString[" << line << "] "
+              << " has " << linePts->size() << " coords in input"
+              << std::endl;
 #endif
 
-	if ( ! linePts->size() ) return;
-	simplifySection(0, linePts->size() - 1, 0);
+    if(! linePts->size()) {
+        return;
+    }
+    simplifySection(0, linePts->size() - 1, 0);
 
 }
 
@@ -85,86 +87,87 @@ TaggedLineStringSimplifier::simplify(TaggedLineString* nLine)
 /*private*/
 void
 TaggedLineStringSimplifier::simplifySection(std::size_t i,
-		std::size_t j, std::size_t depth)
+        std::size_t j, std::size_t depth)
 {
-	depth += 1;
+    depth += 1;
 
 #if GEOS_DEBUG
-	std::cerr << "TaggedLineStringSimplifier[" << this << "] "
-	          << " simplifying section " << i << "-" << j
-	          << std::endl;
+    std::cerr << "TaggedLineStringSimplifier[" << this << "] "
+              << " simplifying section " << i << "-" << j
+              << std::endl;
 #endif
 
-	if((i+1) == j)
-	{
+    if((i + 1) == j) {
 
 #if GEOS_DEBUG
-		std::cerr << "single segment, no flattening"
-		          << std::endl;
+        std::cerr << "single segment, no flattening"
+                  << std::endl;
 #endif
-		unique_ptr<TaggedLineSegment> newSeg(new
-			TaggedLineSegment(*(line->getSegment(i))));
-
-		line->addToResult(std::move(newSeg));
-		// leave this segment in the input index, for efficiency
-		return;
-	}
-
-	bool isValidToSimplify = true;
-
-	/**
-	 * Following logic ensures that there is enough points in the
-	 * output line.
-	 * If there is already more points than the minimum, there's
-	 * nothing to check.
-	 * Otherwise, if in the worst case there wouldn't be enough points,
-	 * don't flatten this segment (which avoids the worst case scenario)
-	 */
-	if (line->getResultSize() < line->getMinimumSize())
-	{
-		std::size_t worstCaseSize = depth + 1;
-		if (worstCaseSize < line->getMinimumSize())
-			isValidToSimplify = false;
-	}
-
-	double distance;
-
-	// pass distance by ref
-	std::size_t furthestPtIndex = findFurthestPoint(linePts, i, j, distance);
+        unique_ptr<TaggedLineSegment> newSeg(new
+                                             TaggedLineSegment(*(line->getSegment(i))));
+
+        line->addToResult(std::move(newSeg));
+        // leave this segment in the input index, for efficiency
+        return;
+    }
+
+    bool isValidToSimplify = true;
+
+    /**
+     * Following logic ensures that there is enough points in the
+     * output line.
+     * If there is already more points than the minimum, there's
+     * nothing to check.
+     * Otherwise, if in the worst case there wouldn't be enough points,
+     * don't flatten this segment (which avoids the worst case scenario)
+     */
+    if(line->getResultSize() < line->getMinimumSize()) {
+        std::size_t worstCaseSize = depth + 1;
+        if(worstCaseSize < line->getMinimumSize()) {
+            isValidToSimplify = false;
+        }
+    }
+
+    double distance;
+
+    // pass distance by ref
+    std::size_t furthestPtIndex = findFurthestPoint(linePts, i, j, distance);
 
 #if GEOS_DEBUG
-	std::cerr << "furthest point " << furthestPtIndex
-	          << " at distance " << distance
-	          << std::endl;
+    std::cerr << "furthest point " << furthestPtIndex
+              << " at distance " << distance
+              << std::endl;
 #endif
 
-	// flattening must be less than distanceTolerance
-	if ( distance > distanceTolerance ) isValidToSimplify = false;
+    // flattening must be less than distanceTolerance
+    if(distance > distanceTolerance) {
+        isValidToSimplify = false;
+    }
 
-	// test if flattened section would cause intersection
-	LineSegment candidateSeg(linePts->getAt(i), linePts->getAt(j));
+    // test if flattened section would cause intersection
+    LineSegment candidateSeg(linePts->getAt(i), linePts->getAt(j));
 
-	if (hasBadIntersection(line, std::make_pair(i, j), candidateSeg))
-			isValidToSimplify = false;
+    if(hasBadIntersection(line, std::make_pair(i, j), candidateSeg)) {
+        isValidToSimplify = false;
+    }
 
-	if (isValidToSimplify)
-	{
+    if(isValidToSimplify) {
 
-		unique_ptr<TaggedLineSegment> newSeg = flatten(i, j);
+        unique_ptr<TaggedLineSegment> newSeg = flatten(i, j);
 
 #if GEOS_DEBUG
-		std::cerr << "isValidToSimplify, adding seg "
-			  << newSeg->p0 << ", " << newSeg->p1
-			  << " to TaggedLineSegment["<<line<<"] result "
-			  << std::endl;
+        std::cerr << "isValidToSimplify, adding seg "
+                  << newSeg->p0 << ", " << newSeg->p1
+                  << " to TaggedLineSegment[" << line << "] result "
+                  << std::endl;
 #endif
 
-		line->addToResult(std::move(newSeg));
-		return;
-	}
+        line->addToResult(std::move(newSeg));
+        return;
+    }
 
-	simplifySection(i, furthestPtIndex, depth);
-	simplifySection(furthestPtIndex, j, depth);
+    simplifySection(i, furthestPtIndex, depth);
+    simplifySection(furthestPtIndex, j, depth);
 
 }
 
@@ -173,153 +176,151 @@ TaggedLineStringSimplifier::simplifySection(std::size_t i,
 unique_ptr<TaggedLineSegment>
 TaggedLineStringSimplifier::flatten(std::size_t start, std::size_t end)
 {
-	// make a new segment for the simplified geometry
-	const Coordinate& p0 = linePts->getAt(start);
-	const Coordinate& p1 = linePts->getAt(end);
-	unique_ptr<TaggedLineSegment> newSeg(new TaggedLineSegment(p0, p1));
-	// update the indexes
-	remove(line, start, end);
-	outputIndex->add(newSeg.get());
-	return newSeg;
+    // make a new segment for the simplified geometry
+    const Coordinate& p0 = linePts->getAt(start);
+    const Coordinate& p1 = linePts->getAt(end);
+    unique_ptr<TaggedLineSegment> newSeg(new TaggedLineSegment(p0, p1));
+    // update the indexes
+    remove(line, start, end);
+    outputIndex->add(newSeg.get());
+    return newSeg;
 }
 
 /*private*/
 bool
 TaggedLineStringSimplifier::hasBadIntersection(
-		const TaggedLineString* parentLine,
-		const pair<size_t, size_t>& sectionIndex,
-		const LineSegment& candidateSeg)
+    const TaggedLineString* parentLine,
+    const pair<size_t, size_t>& sectionIndex,
+    const LineSegment& candidateSeg)
 {
-	if (hasBadOutputIntersection(candidateSeg))
-		return true;
+    if(hasBadOutputIntersection(candidateSeg)) {
+        return true;
+    }
 
-	if (hasBadInputIntersection(parentLine, sectionIndex, candidateSeg))
-		return true;
+    if(hasBadInputIntersection(parentLine, sectionIndex, candidateSeg)) {
+        return true;
+    }
 
-	return false;
+    return false;
 }
 
 /*private*/
 bool
 TaggedLineStringSimplifier::hasBadOutputIntersection(
-		const LineSegment& candidateSeg)
+    const LineSegment& candidateSeg)
 {
-	unique_ptr< vector<LineSegment*> > querySegs =
-		outputIndex->query(&candidateSeg);
-
-	for (const LineSegment* querySeg : *querySegs)
-	{
-		if (hasInteriorIntersection(*querySeg, candidateSeg))
-		{
-			return true;
-		}
-	}
-
-	return false;
+    unique_ptr< vector<LineSegment*> > querySegs =
+        outputIndex->query(&candidateSeg);
+
+    for(const LineSegment* querySeg : *querySegs) {
+        if(hasInteriorIntersection(*querySeg, candidateSeg)) {
+            return true;
+        }
+    }
+
+    return false;
 }
 
 /*private*/
 bool
 TaggedLineStringSimplifier::hasInteriorIntersection(
-			const LineSegment& seg0,
-			const LineSegment& seg1) const
+    const LineSegment& seg0,
+    const LineSegment& seg1) const
 {
-	li->computeIntersection(seg0.p0, seg0.p1, seg1.p0, seg1.p1);
-	return li->isInteriorIntersection();
+    li->computeIntersection(seg0.p0, seg0.p1, seg1.p0, seg1.p1);
+    return li->isInteriorIntersection();
 }
 
 /*private*/
 bool
 TaggedLineStringSimplifier::hasBadInputIntersection(
-		const TaggedLineString* parentLine,
-		const pair<std::size_t, std::size_t>& sectionIndex,
-		const LineSegment& candidateSeg)
+    const TaggedLineString* parentLine,
+    const pair<std::size_t, std::size_t>& sectionIndex,
+    const LineSegment& candidateSeg)
 {
-	unique_ptr< vector<LineSegment*> > querySegs =
-		inputIndex->query(&candidateSeg);
+    unique_ptr< vector<LineSegment*> > querySegs =
+        inputIndex->query(&candidateSeg);
 
-	for (const LineSegment* ls : *querySegs)
-	{
-		const TaggedLineSegment* querySeg = static_cast<const TaggedLineSegment*>(ls);
+    for(const LineSegment* ls : *querySegs) {
+        const TaggedLineSegment* querySeg = static_cast<const TaggedLineSegment*>(ls);
 
-		if (!isInLineSection(parentLine, sectionIndex, querySeg) && hasInteriorIntersection(*querySeg, candidateSeg))
-		{
+        if(!isInLineSection(parentLine, sectionIndex, querySeg) && hasInteriorIntersection(*querySeg, candidateSeg)) {
 
-			return true;
-		}
-	}
+            return true;
+        }
+    }
 
-	return false;
+    return false;
 }
 
 /*static private*/
 bool
 TaggedLineStringSimplifier::isInLineSection(
-		const TaggedLineString* line,
-		const pair<size_t, size_t>& sectionIndex,
-		const TaggedLineSegment* seg)
+    const TaggedLineString* line,
+    const pair<size_t, size_t>& sectionIndex,
+    const TaggedLineSegment* seg)
 {
-	// not in this line
-	if (seg->getParent() != line->getParent())
-		return false;
+    // not in this line
+    if(seg->getParent() != line->getParent()) {
+        return false;
+    }
 
-	std::size_t segIndex = seg->getIndex();
-	if (segIndex >= sectionIndex.first && segIndex < sectionIndex.second)
-		return true;
+    std::size_t segIndex = seg->getIndex();
+    if(segIndex >= sectionIndex.first && segIndex < sectionIndex.second) {
+        return true;
+    }
 
-	return false;
+    return false;
 }
 
 /*private*/
 void
 TaggedLineStringSimplifier::remove(const TaggedLineString* p_line,
-		std::size_t start,
-		std::size_t end)
+                                   std::size_t start,
+                                   std::size_t end)
 {
-	assert(end <= p_line->getSegments().size() );
-	assert(start < end); // I'm not sure this should always be true
-
-	for (std::size_t i = start; i < end; i++)
-	{
-		const TaggedLineSegment* seg = p_line->getSegment(i);
-		inputIndex->remove(seg);
-	}
+    assert(end <= p_line->getSegments().size());
+    assert(start < end); // I'm not sure this should always be true
+
+    for(std::size_t i = start; i < end; i++) {
+        const TaggedLineSegment* seg = p_line->getSegment(i);
+        inputIndex->remove(seg);
+    }
 }
 
 /*private static*/
 std::size_t
 TaggedLineStringSimplifier::findFurthestPoint(
-		const geom::CoordinateSequence* pts,
-		std::size_t i, std::size_t j,
-		double& maxDistance)
+    const geom::CoordinateSequence* pts,
+    std::size_t i, std::size_t j,
+    double& maxDistance)
 {
-	LineSegment seg(pts->getAt(i), pts->getAt(j));
+    LineSegment seg(pts->getAt(i), pts->getAt(j));
 #if GEOS_DEBUG
-	std::cerr << __FUNCTION__ << "segment " << seg
-	          << std::endl;
+    std::cerr << __FUNCTION__ << "segment " << seg
+              << std::endl;
 #endif
-	double maxDist = -1.0;
-	std::size_t maxIndex = i;
-	for (std::size_t k = i + 1; k < j; k++)
-	{
-		const Coordinate& midPt = pts->getAt(k);
-		double distance = seg.distance(midPt);
+    double maxDist = -1.0;
+    std::size_t maxIndex = i;
+    for(std::size_t k = i + 1; k < j; k++) {
+        const Coordinate& midPt = pts->getAt(k);
+        double distance = seg.distance(midPt);
 #if GEOS_DEBUG
-		std::cerr << "dist to " << midPt
-			  << ": " << distance
-			  << std::endl;
+        std::cerr << "dist to " << midPt
+                  << ": " << distance
+                  << std::endl;
 #endif
-		if (distance > maxDist) {
+        if(distance > maxDist) {
 #if GEOS_DEBUG
-			std::cerr << "this is max"
-				  << std::endl;
+            std::cerr << "this is max"
+                      << std::endl;
 #endif
-			maxDist = distance;
-			maxIndex = k;
-		}
-	}
-	maxDistance = maxDist;
-	return maxIndex;
+            maxDist = distance;
+            maxIndex = k;
+        }
+    }
+    maxDistance = maxDist;
+    return maxIndex;
 
 }
 
diff --git a/src/simplify/TaggedLinesSimplifier.cpp b/src/simplify/TaggedLinesSimplifier.cpp
index e33f5f1..21a49f2 100644
--- a/src/simplify/TaggedLinesSimplifier.cpp
+++ b/src/simplify/TaggedLinesSimplifier.cpp
@@ -41,11 +41,11 @@ namespace simplify { // geos::simplify
 
 /*public*/
 TaggedLinesSimplifier::TaggedLinesSimplifier()
-	:
-	inputIndex(new LineSegmentIndex()),
-	outputIndex(new LineSegmentIndex()),
-	taggedlineSimplifier(new TaggedLineStringSimplifier(inputIndex.get(),
-		outputIndex.get()))
+    :
+    inputIndex(new LineSegmentIndex()),
+    outputIndex(new LineSegmentIndex()),
+    taggedlineSimplifier(new TaggedLineStringSimplifier(inputIndex.get(),
+                         outputIndex.get()))
 {
 }
 
@@ -53,14 +53,14 @@ TaggedLinesSimplifier::TaggedLinesSimplifier()
 void
 TaggedLinesSimplifier::setDistanceTolerance(double d)
 {
-	taggedlineSimplifier->setDistanceTolerance(d);
+    taggedlineSimplifier->setDistanceTolerance(d);
 }
 
 /*private*/
 void
 TaggedLinesSimplifier::simplify(TaggedLineString& tls)
 {
-	taggedlineSimplifier->simplify(&tls);
+    taggedlineSimplifier->simplify(&tls);
 }
 
 } // namespace geos::simplify
diff --git a/src/simplify/TopologyPreservingSimplifier.cpp b/src/simplify/TopologyPreservingSimplifier.cpp
index c82935d..4e9b8bc 100644
--- a/src/simplify/TopologyPreservingSimplifier.cpp
+++ b/src/simplify/TopologyPreservingSimplifier.cpp
@@ -46,26 +46,25 @@ using LinesMap = std::unordered_map<const geom::Geometry*, TaggedLineString*>;
 
 namespace { // module-statics
 
-class LineStringTransformer: public geom::util::GeometryTransformer
-{
+class LineStringTransformer: public geom::util::GeometryTransformer {
 
 public:
 
-	/**
-	 * User's constructor.
-	 * @param nMap - reference to LinesMap instance.
-	 */
-	LineStringTransformer(LinesMap& simp);
+    /**
+     * User's constructor.
+     * @param nMap - reference to LinesMap instance.
+     */
+    LineStringTransformer(LinesMap& simp);
 
 protected:
 
-	CoordinateSequence::Ptr transformCoordinates(
-			const CoordinateSequence* coords,
-			const Geometry* parent) override;
+    CoordinateSequence::Ptr transformCoordinates(
+        const CoordinateSequence* coords,
+        const Geometry* parent) override;
 
 private:
 
-	LinesMap& linestringMap;
+    LinesMap& linestringMap;
 
 };
 
@@ -77,93 +76,97 @@ private:
  */
 class LinesMapValueIterator {
 
-	LinesMap::iterator _iter;
+    LinesMap::iterator _iter;
 
 public:
 
-	LinesMapValueIterator(LinesMap::iterator iter)
-		:
-		_iter(iter)
-	{
-	}
-
-	// copy ctor
-	LinesMapValueIterator(const LinesMapValueIterator& o)
-		:
-		_iter(o._iter)
-	{
-	}
-
-	// assignment
-	LinesMapValueIterator& operator=(const LinesMapValueIterator& o)
-	{
-		_iter=o._iter;
-		return *this;
-	}
-
-	// postfix++
-	void operator++(int)
-	{
-		_iter++;
-	}
-
-	// ++suffix
-	void operator++()
-	{
-		++_iter;
-	}
-
-	// inequality operator
-	bool operator!=(const LinesMapValueIterator& other) const
-	{
-		return _iter != other._iter;
-	}
-
-	TaggedLineString* operator*()
-	{
-		return _iter->second;
-	}
+    LinesMapValueIterator(LinesMap::iterator iter)
+        :
+        _iter(iter)
+    {
+    }
+
+    // copy ctor
+    LinesMapValueIterator(const LinesMapValueIterator& o)
+        :
+        _iter(o._iter)
+    {
+    }
+
+    // assignment
+    LinesMapValueIterator&
+    operator=(const LinesMapValueIterator& o)
+    {
+        _iter = o._iter;
+        return *this;
+    }
+
+    // postfix++
+    void
+    operator++(int)
+    {
+        _iter++;
+    }
+
+    // ++suffix
+    void
+    operator++()
+    {
+        ++_iter;
+    }
+
+    // inequality operator
+    bool
+    operator!=(const LinesMapValueIterator& other) const
+    {
+        return _iter != other._iter;
+    }
+
+    TaggedLineString*
+    operator*()
+    {
+        return _iter->second;
+    }
 };
 
 
 /*public*/
 LineStringTransformer::LineStringTransformer(LinesMap& nMap)
-	:
-	linestringMap(nMap)
+    :
+    linestringMap(nMap)
 {
 }
 
 /*protected*/
 CoordinateSequence::Ptr
 LineStringTransformer::transformCoordinates(
-		const CoordinateSequence* coords,
-		const Geometry* parent)
+    const CoordinateSequence* coords,
+    const Geometry* parent)
 {
 #ifdef GEOS_DEBUG
-	std::cerr << __FUNCTION__ << ": parent: " << parent
-	          << std::endl;
+    std::cerr << __FUNCTION__ << ": parent: " << parent
+              << std::endl;
 #endif
-	if ( dynamic_cast<const LineString*>(parent) )
-	{
-		LinesMap::iterator it = linestringMap.find(parent);
-		assert( it != linestringMap.end() );
+    if(dynamic_cast<const LineString*>(parent)) {
+        LinesMap::iterator it = linestringMap.find(parent);
+        assert(it != linestringMap.end());
 
-		TaggedLineString* taggedLine = it->second;
+        TaggedLineString* taggedLine = it->second;
 #ifdef GEOS_DEBUG
-		std::cerr << "LineStringTransformer[" << this << "] "
-		     << " getting result Coordinates from "
-		     << " TaggedLineString[" << taggedLine << "]"
-		     << std::endl;
+        std::cerr << "LineStringTransformer[" << this << "] "
+                  << " getting result Coordinates from "
+                  << " TaggedLineString[" << taggedLine << "]"
+                  << std::endl;
 #endif
 
-		assert(taggedLine);
-		assert(taggedLine->getParent() == parent);
+        assert(taggedLine);
+        assert(taggedLine->getParent() == parent);
 
-		return taggedLine->getResultCoordinates();
-	}
+        return taggedLine->getResultCoordinates();
+    }
 
-	// for anything else (e.g. points) just copy the coordinates
-	return GeometryTransformer::transformCoordinates(coords, parent);
+    // for anything else (e.g. points) just copy the coordinates
+    return GeometryTransformer::transformCoordinates(coords, parent);
 }
 
 //----------------------------------------------------------------------
@@ -182,31 +185,30 @@ LineStringTransformer::transformCoordinates(
  * TODO: Consider container of unique_ptr
  *
  */
-class LineStringMapBuilderFilter: public geom::GeometryComponentFilter
-{
+class LineStringMapBuilderFilter: public geom::GeometryComponentFilter {
 
 public:
 
-	// no more needed
-	//friend class TopologyPreservingSimplifier;
+    // no more needed
+    //friend class TopologyPreservingSimplifier;
 
-	/**
-	 * Filters linear geometries.
-	 *
-	 * geom a geometry of any type
-	 */
-	void filter_ro(const Geometry* geom) override;
+    /**
+     * Filters linear geometries.
+     *
+     * geom a geometry of any type
+     */
+    void filter_ro(const Geometry* geom) override;
 
 
-	/**
-	 * User's constructor.
-	 * @param nMap - reference to LinesMap instance.
-	 */
-	LineStringMapBuilderFilter(LinesMap& nMap);
+    /**
+     * User's constructor.
+     * @param nMap - reference to LinesMap instance.
+     */
+    LineStringMapBuilderFilter(LinesMap& nMap);
 
 private:
 
-	LinesMap& linestringMap;
+    LinesMap& linestringMap;
 
     // Declare type as noncopyable
     LineStringMapBuilderFilter(const LineStringMapBuilderFilter& other) = delete;
@@ -215,8 +217,8 @@ private:
 
 /*public*/
 LineStringMapBuilderFilter::LineStringMapBuilderFilter(LinesMap& nMap)
-	:
-	linestringMap(nMap)
+    :
+    linestringMap(nMap)
 {
 }
 
@@ -224,28 +226,25 @@ LineStringMapBuilderFilter::LineStringMapBuilderFilter(LinesMap& nMap)
 void
 LineStringMapBuilderFilter::filter_ro(const Geometry* geom)
 {
-	TaggedLineString* taggedLine;
-
-	if ( const LineString* ls =
-			dynamic_cast<const LineString*>(geom) )
-	{
-    int minSize = ls->isClosed() ? 4 : 2;
-		taggedLine = new TaggedLineString(ls, minSize);
-	}
-	else
-	{
-		return;
-	}
-
-	// Duplicated Geometry pointers shouldn't happen
-	if ( ! linestringMap.insert(std::make_pair(geom, taggedLine)).second )
-	{
-		std::cerr << __FILE__ << ":" << __LINE__
-		     << "Duplicated Geometry components detected"
-		     << std::endl;
-
-		delete taggedLine;
-	}
+    TaggedLineString* taggedLine;
+
+    if(const LineString* ls =
+                dynamic_cast<const LineString*>(geom)) {
+        int minSize = ls->isClosed() ? 4 : 2;
+        taggedLine = new TaggedLineString(ls, minSize);
+    }
+    else {
+        return;
+    }
+
+    // Duplicated Geometry pointers shouldn't happen
+    if(! linestringMap.insert(std::make_pair(geom, taggedLine)).second) {
+        std::cerr << __FILE__ << ":" << __LINE__
+                  << "Duplicated Geometry components detected"
+                  << std::endl;
+
+        delete taggedLine;
+    }
 }
 
 
@@ -254,19 +253,19 @@ LineStringMapBuilderFilter::filter_ro(const Geometry* geom)
 /*public static*/
 std::unique_ptr<geom::Geometry>
 TopologyPreservingSimplifier::simplify(
-		const geom::Geometry* geom,
-		double tolerance)
+    const geom::Geometry* geom,
+    double tolerance)
 {
-	TopologyPreservingSimplifier tss(geom);
-        tss.setDistanceTolerance(tolerance);
-	return tss.getResultGeometry();
+    TopologyPreservingSimplifier tss(geom);
+    tss.setDistanceTolerance(tolerance);
+    return tss.getResultGeometry();
 }
 
 /*public*/
 TopologyPreservingSimplifier::TopologyPreservingSimplifier(const Geometry* geom)
-	:
-	inputGeom(geom),
-	lineSimplifier(new TaggedLinesSimplifier())
+    :
+    inputGeom(geom),
+    lineSimplifier(new TaggedLinesSimplifier())
 {
 }
 
@@ -274,12 +273,13 @@ TopologyPreservingSimplifier::TopologyPreservingSimplifier(const Geometry* geom)
 void
 TopologyPreservingSimplifier::setDistanceTolerance(double d)
 {
-	using geos::util::IllegalArgumentException;
+    using geos::util::IllegalArgumentException;
 
-	if ( d < 0.0 )
-		throw IllegalArgumentException("Tolerance must be non-negative");
+    if(d < 0.0) {
+        throw IllegalArgumentException("Tolerance must be non-negative");
+    }
 
-	lineSimplifier->setDistanceTolerance(d);
+    lineSimplifier->setDistanceTolerance(d);
 }
 
 
@@ -288,66 +288,67 @@ std::unique_ptr<geom::Geometry>
 TopologyPreservingSimplifier::getResultGeometry()
 {
 
-	// empty input produces an empty result
-	if (inputGeom->isEmpty()) return std::unique_ptr<Geometry>(inputGeom->clone());
+    // empty input produces an empty result
+    if(inputGeom->isEmpty()) {
+        return std::unique_ptr<Geometry>(inputGeom->clone());
+    }
 
-	LinesMap linestringMap;
+    LinesMap linestringMap;
 
-	std::unique_ptr<geom::Geometry> result;
+    std::unique_ptr<geom::Geometry> result;
 
-	try {
-		LineStringMapBuilderFilter lsmbf(linestringMap);
-		inputGeom->apply_ro(&lsmbf);
+    try {
+        LineStringMapBuilderFilter lsmbf(linestringMap);
+        inputGeom->apply_ro(&lsmbf);
 
 #ifdef GEOS_DEBUG
-	std::cerr << "LineStringMapBuilderFilter applied, "
-	          << " lineStringMap contains "
-	          << linestringMap.size() << " elements\n";
+        std::cerr << "LineStringMapBuilderFilter applied, "
+                  << " lineStringMap contains "
+                  << linestringMap.size() << " elements\n";
 #endif
 
-		LinesMapValueIterator begin(linestringMap.begin());
-		LinesMapValueIterator end(linestringMap.end());
-		lineSimplifier->simplify(begin, end);
+        LinesMapValueIterator begin(linestringMap.begin());
+        LinesMapValueIterator end(linestringMap.end());
+        lineSimplifier->simplify(begin, end);
 
 
 #ifdef GEOS_DEBUG
-	std::cerr << "all TaggedLineString simplified\n";
+        std::cerr << "all TaggedLineString simplified\n";
 #endif
 
-		LineStringTransformer trans(linestringMap);
-		result = trans.transform(inputGeom);
+        LineStringTransformer trans(linestringMap);
+        result = trans.transform(inputGeom);
 
 #ifdef GEOS_DEBUG
-	std::cerr << "inputGeom transformed\n";
+        std::cerr << "inputGeom transformed\n";
 #endif
 
-	} catch (...) {
-		for (LinesMap::iterator
-				it = linestringMap.begin(),
-				itEnd = linestringMap.end();
-				it != itEnd;
-				++it)
-		{
-			delete it->second;
-		}
-
-		throw;
-	}
-
-	for (LinesMap::iterator
-			it = linestringMap.begin(),
-			itEnd = linestringMap.end();
-			it != itEnd;
-			++it)
-	{
-		delete it->second;
-	}
+    }
+    catch(...) {
+        for(LinesMap::iterator
+                it = linestringMap.begin(),
+                itEnd = linestringMap.end();
+                it != itEnd;
+                ++it) {
+            delete it->second;
+        }
+
+        throw;
+    }
+
+    for(LinesMap::iterator
+            it = linestringMap.begin(),
+            itEnd = linestringMap.end();
+            it != itEnd;
+            ++it) {
+        delete it->second;
+    }
 
 #ifdef GEOS_DEBUG
-	std::cerr << "returning result\n";
+    std::cerr << "returning result\n";
 #endif
 
-	return result;
+    return result;
 }
 
 } // namespace geos::simplify
diff --git a/src/triangulate/DelaunayTriangulationBuilder.cpp b/src/triangulate/DelaunayTriangulationBuilder.cpp
index 2df4578..f219bea 100644
--- a/src/triangulate/DelaunayTriangulationBuilder.cpp
+++ b/src/triangulate/DelaunayTriangulationBuilder.cpp
@@ -33,119 +33,122 @@ using namespace geos::geom;
 
 CoordinateSequence*
 DelaunayTriangulationBuilder::extractUniqueCoordinates(
-		const Geometry& geom)
+    const Geometry& geom)
 {
-	geom::CoordinateSequence *coords = geom.getCoordinates();
-	unique(*coords);
-	return coords;
+    geom::CoordinateSequence* coords = geom.getCoordinates();
+    unique(*coords);
+    return coords;
 }
 
 void
 DelaunayTriangulationBuilder::unique(CoordinateSequence& coords)
 {
-	std::vector<Coordinate> coordVector;
-	coords.toVector(coordVector);
-	std::sort(coordVector.begin(), coordVector.end(), geos::geom::CoordinateLessThen());
-	coords.setPoints(coordVector);
-	coords.removeRepeatedPoints();
+    std::vector<Coordinate> coordVector;
+    coords.toVector(coordVector);
+    std::sort(coordVector.begin(), coordVector.end(), geos::geom::CoordinateLessThen());
+    coords.setPoints(coordVector);
+    coords.removeRepeatedPoints();
 }
 
 IncrementalDelaunayTriangulator::VertexList*
 DelaunayTriangulationBuilder::toVertices(
-		const CoordinateSequence &coords)
+    const CoordinateSequence& coords)
 {
-	IncrementalDelaunayTriangulator::VertexList* vertexList =
-		new IncrementalDelaunayTriangulator::VertexList();
-
-	for(size_t iter=0; iter < coords.size(); ++iter)
-	{
-		vertexList->push_back(quadedge::Vertex(coords.getAt(iter)));
-	}
-	return vertexList;
+    IncrementalDelaunayTriangulator::VertexList* vertexList =
+        new IncrementalDelaunayTriangulator::VertexList();
+
+    for(size_t iter = 0; iter < coords.size(); ++iter) {
+        vertexList->push_back(quadedge::Vertex(coords.getAt(iter)));
+    }
+    return vertexList;
 }
 
 DelaunayTriangulationBuilder::DelaunayTriangulationBuilder() :
-	siteCoords(nullptr), tolerance(0.0), subdiv(nullptr)
+    siteCoords(nullptr), tolerance(0.0), subdiv(nullptr)
 {
 }
 
 DelaunayTriangulationBuilder::~DelaunayTriangulationBuilder()
 {
-	if(siteCoords)
-		delete siteCoords;
-	if(subdiv)
-		delete subdiv;
+    if(siteCoords) {
+        delete siteCoords;
+    }
+    if(subdiv) {
+        delete subdiv;
+    }
 }
 
 void
 DelaunayTriangulationBuilder::setSites(const Geometry& geom)
 {
-	if(siteCoords)
-		delete siteCoords;
-	// remove any duplicate points (they will cause the triangulation to fail)
-	siteCoords = extractUniqueCoordinates(geom);
+    if(siteCoords) {
+        delete siteCoords;
+    }
+    // remove any duplicate points (they will cause the triangulation to fail)
+    siteCoords = extractUniqueCoordinates(geom);
 }
 
 void
 DelaunayTriangulationBuilder::setSites(const CoordinateSequence& coords)
 {
-	if(siteCoords)
-		delete siteCoords;
-	siteCoords = coords.clone();
-	// remove any duplicate points (they will cause the triangulation to fail)
-	unique(*siteCoords);
+    if(siteCoords) {
+        delete siteCoords;
+    }
+    siteCoords = coords.clone();
+    // remove any duplicate points (they will cause the triangulation to fail)
+    unique(*siteCoords);
 }
 
 void
 DelaunayTriangulationBuilder::create()
 {
-	if(subdiv != nullptr || siteCoords == nullptr)
-		return;
-
-	Envelope siteEnv;
-	siteCoords ->expandEnvelope(siteEnv);
-	IncrementalDelaunayTriangulator::VertexList* vertices = toVertices(*siteCoords);
-	subdiv = new quadedge::QuadEdgeSubdivision(siteEnv, tolerance);
-	IncrementalDelaunayTriangulator triangulator = IncrementalDelaunayTriangulator(subdiv);
-	triangulator.insertSites(*vertices);
-	delete vertices;
+    if(subdiv != nullptr || siteCoords == nullptr) {
+        return;
+    }
+
+    Envelope siteEnv;
+    siteCoords ->expandEnvelope(siteEnv);
+    IncrementalDelaunayTriangulator::VertexList* vertices = toVertices(*siteCoords);
+    subdiv = new quadedge::QuadEdgeSubdivision(siteEnv, tolerance);
+    IncrementalDelaunayTriangulator triangulator = IncrementalDelaunayTriangulator(subdiv);
+    triangulator.insertSites(*vertices);
+    delete vertices;
 }
 
 quadedge::QuadEdgeSubdivision&
 DelaunayTriangulationBuilder::getSubdivision()
 {
-	create();
-	return *subdiv;
+    create();
+    return *subdiv;
 }
 
 std::unique_ptr<MultiLineString>
 DelaunayTriangulationBuilder::getEdges(
     const GeometryFactory& geomFact)
 {
-	create();
-	return subdiv->getEdges(geomFact);
+    create();
+    return subdiv->getEdges(geomFact);
 }
 
 std::unique_ptr<geom::GeometryCollection>
 DelaunayTriangulationBuilder::getTriangles(
-		const geom::GeometryFactory& geomFact)
+    const geom::GeometryFactory& geomFact)
 {
-	create();
-	return subdiv->getTriangles(geomFact);
+    create();
+    return subdiv->getTriangles(geomFact);
 }
 
 geom::Envelope
 DelaunayTriangulationBuilder::envelope(const geom::CoordinateSequence& coords)
 {
-	Envelope env;
-	std::vector<Coordinate> coord_vector;
-	coords.toVector(coord_vector);
-	for(std::vector<Coordinate>::iterator it= coord_vector.begin() ; it!=coord_vector.end() ; ++it)
-	{
-		const Coordinate& coord = *it;
-		env.expandToInclude(coord);
-	}
-	return env;
+    Envelope env;
+    std::vector<Coordinate> coord_vector;
+    coords.toVector(coord_vector);
+    for(std::vector<Coordinate>::iterator it = coord_vector.begin() ; it != coord_vector.end() ; ++it) {
+        const Coordinate& coord = *it;
+        env.expandToInclude(coord);
+    }
+    return env;
 }
 
 
diff --git a/src/triangulate/IncrementalDelaunayTriangulator.cpp b/src/triangulate/IncrementalDelaunayTriangulator.cpp
index 26c3139..8ca0d0b 100644
--- a/src/triangulate/IncrementalDelaunayTriangulator.cpp
+++ b/src/triangulate/IncrementalDelaunayTriangulator.cpp
@@ -28,20 +28,22 @@ namespace triangulate { //geos.triangulate
 using namespace quadedge;
 
 IncrementalDelaunayTriangulator::IncrementalDelaunayTriangulator(
-        QuadEdgeSubdivision *p_subdiv) :
+    QuadEdgeSubdivision* p_subdiv) :
     subdiv(p_subdiv), isUsingTolerance(p_subdiv->getTolerance() > 0.0)
 {
 }
 
-void IncrementalDelaunayTriangulator::insertSites(const VertexList& vertices)
+void
+IncrementalDelaunayTriangulator::insertSites(const VertexList& vertices)
 {
-    for (VertexList::const_iterator x=vertices.begin();
+    for(VertexList::const_iterator x = vertices.begin();
             x != vertices.end(); ++x) {
         insertSite(*x);
     }
 }
 
-QuadEdge& IncrementalDelaunayTriangulator::insertSite(const Vertex &v)
+QuadEdge&
+IncrementalDelaunayTriangulator::insertSite(const Vertex& v)
 {
     /**
      * This code is based on Guibas and Stolfi (1985), with minor modifications
@@ -50,17 +52,17 @@ QuadEdge& IncrementalDelaunayTriangulator::insertSite(const Vertex &v)
      * existing edge. Without this test zero-width triangles have been observed
      * to be created)
      */
-    QuadEdge *e = subdiv->locate(v);
+    QuadEdge* e = subdiv->locate(v);
 
     if(!e) {
         throw LocateFailureException("");
     }
 
-    if (subdiv->isVertexOfEdge(*e, v)) {
+    if(subdiv->isVertexOfEdge(*e, v)) {
         // point is already in subdivision.
         return *e;
     }
-    else if (subdiv->isOnEdge(*e, v.getCoordinate())) {
+    else if(subdiv->isOnEdge(*e, v.getCoordinate())) {
         // the point lies exactly on an edge, so delete the edge
         // (it will be replaced by a pair of edges which have the point as a vertex)
         e = &e->oPrev();
@@ -74,25 +76,27 @@ QuadEdge& IncrementalDelaunayTriangulator::insertSite(const Vertex &v)
     QuadEdge* base = &subdiv->makeEdge(e->orig(), v);
 
     QuadEdge::splice(*base, *e);
-    QuadEdge *startEdge = base;
+    QuadEdge* startEdge = base;
     do {
         base = &subdiv->connect(*e, base->sym());
         e = &base->oPrev();
-    } while (&e->lNext() != startEdge);
+    }
+    while(&e->lNext() != startEdge);
 
 
     // Examine suspect edges to ensure that the Delaunay condition
     // is satisfied.
-    for (;;)
-    {
+    for(;;) {
         QuadEdge* t = &e->oPrev();
-        if (t->dest().rightOf(*e) &&
+        if(t->dest().rightOf(*e) &&
                 v.isInCircle(e->orig(), t->dest(), e->dest())) {
             QuadEdge::swap(*e);
             e = &e->oPrev();
-        } else if (&e->oNext() == startEdge) {
+        }
+        else if(&e->oNext() == startEdge) {
             return *base; // no more suspect edges.
-        } else {
+        }
+        else {
             e = &e->oNext().lPrev();
         }
     }
diff --git a/src/triangulate/VoronoiDiagramBuilder.cpp b/src/triangulate/VoronoiDiagramBuilder.cpp
index 8d79c1e..0b36554 100644
--- a/src/triangulate/VoronoiDiagramBuilder.cpp
+++ b/src/triangulate/VoronoiDiagramBuilder.cpp
@@ -38,7 +38,7 @@ using namespace geos::geom;
 
 
 VoronoiDiagramBuilder::VoronoiDiagramBuilder() :
-	tolerance(0.0), clipEnv(nullptr)
+    tolerance(0.0), clipEnv(nullptr)
 {
 }
 
@@ -49,103 +49,104 @@ VoronoiDiagramBuilder::~VoronoiDiagramBuilder()
 void
 VoronoiDiagramBuilder::setSites(const geom::Geometry& geom)
 {
-	siteCoords.reset( DelaunayTriangulationBuilder::extractUniqueCoordinates(geom) );
+    siteCoords.reset(DelaunayTriangulationBuilder::extractUniqueCoordinates(geom));
 }
 
 void
 VoronoiDiagramBuilder::setSites(const geom::CoordinateSequence& coords)
 {
-	siteCoords.reset( coords.clone() );
-	DelaunayTriangulationBuilder::unique(*siteCoords);
+    siteCoords.reset(coords.clone());
+    DelaunayTriangulationBuilder::unique(*siteCoords);
 }
 
 void
 VoronoiDiagramBuilder::setClipEnvelope(const geom::Envelope* nClipEnv)
 {
-	clipEnv = nClipEnv;
+    clipEnv = nClipEnv;
 }
 
 void
 VoronoiDiagramBuilder::setTolerance(double nTolerance)
 {
-	tolerance = nTolerance;
+    tolerance = nTolerance;
 }
 
 void
 VoronoiDiagramBuilder::create()
 {
-	if( subdiv.get() ) return;
-
-	diagramEnv = DelaunayTriangulationBuilder::envelope(*siteCoords);
-	//adding buffer around the final envelope
-	double expandBy = std::max(diagramEnv.getWidth() , diagramEnv.getHeight());
-	diagramEnv.expandBy(expandBy);
-	if(clipEnv)
-		diagramEnv.expandToInclude(clipEnv);
-
-	std::unique_ptr<IncrementalDelaunayTriangulator::VertexList> vertices (
-    DelaunayTriangulationBuilder::toVertices(*siteCoords)
-  );
-
-	subdiv.reset( new quadedge::QuadEdgeSubdivision(diagramEnv,tolerance) );
-	IncrementalDelaunayTriangulator triangulator(subdiv.get());
-	triangulator.insertSites(*vertices);
+    if(subdiv.get()) {
+        return;
+    }
+
+    diagramEnv = DelaunayTriangulationBuilder::envelope(*siteCoords);
+    //adding buffer around the final envelope
+    double expandBy = std::max(diagramEnv.getWidth(), diagramEnv.getHeight());
+    diagramEnv.expandBy(expandBy);
+    if(clipEnv) {
+        diagramEnv.expandToInclude(clipEnv);
+    }
+
+    std::unique_ptr<IncrementalDelaunayTriangulator::VertexList> vertices(
+        DelaunayTriangulationBuilder::toVertices(*siteCoords)
+    );
+
+    subdiv.reset(new quadedge::QuadEdgeSubdivision(diagramEnv, tolerance));
+    IncrementalDelaunayTriangulator triangulator(subdiv.get());
+    triangulator.insertSites(*vertices);
 }
 
 std::unique_ptr<quadedge::QuadEdgeSubdivision>
 VoronoiDiagramBuilder::getSubdivision()
 {
-	create();
-	// NOTE: Apparently, this is 'source' method giving up the object resource.
-	return std::move(subdiv);
+    create();
+    // NOTE: Apparently, this is 'source' method giving up the object resource.
+    return std::move(subdiv);
 }
 
 std::unique_ptr<geom::GeometryCollection>
 VoronoiDiagramBuilder::getDiagram(const geom::GeometryFactory& geomFact)
 {
-	create();
-	std::unique_ptr<geom::GeometryCollection> polys = subdiv->getVoronoiDiagram(geomFact);
-	return clipGeometryCollection(*polys,diagramEnv);
+    create();
+    std::unique_ptr<geom::GeometryCollection> polys = subdiv->getVoronoiDiagram(geomFact);
+    return clipGeometryCollection(*polys, diagramEnv);
 }
 
 std::unique_ptr<geom::Geometry>
 VoronoiDiagramBuilder::getDiagramEdges(const geom::GeometryFactory& geomFact)
 {
-	create();
-	std::unique_ptr<geom::MultiLineString> edges = subdiv->getVoronoiDiagramEdges(geomFact);
-  if ( edges->isEmpty() ) return std::unique_ptr<Geometry>(edges.release());
-  std::unique_ptr<geom::Geometry> clipPoly ( geomFact.toGeometry(&diagramEnv) );
-  std::unique_ptr<Geometry> clipped( clipPoly->intersection(edges.get()) );
-	return clipped;
+    create();
+    std::unique_ptr<geom::MultiLineString> edges = subdiv->getVoronoiDiagramEdges(geomFact);
+    if(edges->isEmpty()) {
+        return std::unique_ptr<Geometry>(edges.release());
+    }
+    std::unique_ptr<geom::Geometry> clipPoly(geomFact.toGeometry(&diagramEnv));
+    std::unique_ptr<Geometry> clipped(clipPoly->intersection(edges.get()));
+    return clipped;
 }
 
 std::unique_ptr<geom::GeometryCollection>
 VoronoiDiagramBuilder::clipGeometryCollection(const geom::GeometryCollection& geom, const geom::Envelope& clipEnv)
 {
-	std::unique_ptr<geom::Geometry> clipPoly ( geom.getFactory()->toGeometry(&clipEnv) );
-	std::unique_ptr< std::vector<Geometry*> >clipped(new std::vector<Geometry*>);
-	for(std::size_t i=0 ; i < geom.getNumGeometries() ; i++)
-	{
-		const Geometry* g = geom.getGeometryN(i);
-		std::unique_ptr<Geometry> result;
-		// don't clip unless necessary
-		if(clipEnv.contains(g->getEnvelopeInternal()))
-		{
-			result.reset( g->clone() );
-      // TODO: check if userData is correctly cloned here?
-		}
-		else if(clipEnv.intersects(g->getEnvelopeInternal()))
-		{
-			result.reset( clipPoly->intersection(g) );
-			result->setUserData(((Geometry*)g)->getUserData()); // TODO: needed ?
-		}
-
-		if(result.get() && !result->isEmpty() )
-		{
-			clipped->push_back(result.release());
-		}
-	}
-	return std::unique_ptr<GeometryCollection>(geom.getFactory()->createGeometryCollection(clipped.release()));
+    std::unique_ptr<geom::Geometry> clipPoly(geom.getFactory()->toGeometry(&clipEnv));
+    std::unique_ptr< std::vector<Geometry*> >clipped(new std::vector<Geometry*>);
+    for(std::size_t i = 0 ; i < geom.getNumGeometries() ; i++) {
+        const Geometry* g = geom.getGeometryN(i);
+        std::unique_ptr<Geometry> result;
+        // don't clip unless necessary
+        if(clipEnv.contains(g->getEnvelopeInternal())) {
+            result.reset(g->clone());
+            // TODO: check if userData is correctly cloned here?
+        }
+        else if(clipEnv.intersects(g->getEnvelopeInternal())) {
+            result.reset(clipPoly->intersection(g));
+            result->setUserData(((Geometry*)g)->getUserData()); // TODO: needed ?
+        }
+
+        if(result.get() && !result->isEmpty()) {
+            clipped->push_back(result.release());
+        }
+    }
+    return std::unique_ptr<GeometryCollection>(geom.getFactory()->createGeometryCollection(clipped.release()));
 }
 
 } //namespace geos.triangulate
diff --git a/src/triangulate/quadedge/LastFoundQuadEdgeLocator.cpp b/src/triangulate/quadedge/LastFoundQuadEdgeLocator.cpp
index 241439b..12b2c0c 100644
--- a/src/triangulate/quadedge/LastFoundQuadEdgeLocator.cpp
+++ b/src/triangulate/quadedge/LastFoundQuadEdgeLocator.cpp
@@ -23,34 +23,34 @@ namespace geos {
 namespace triangulate { //geos.triangulate
 namespace quadedge { //geos.triangulate.quadedge
 
-LastFoundQuadEdgeLocator::LastFoundQuadEdgeLocator(QuadEdgeSubdivision *p_subdiv) :
-	subdiv(p_subdiv), lastEdge(nullptr)
+LastFoundQuadEdgeLocator::LastFoundQuadEdgeLocator(QuadEdgeSubdivision* p_subdiv) :
+    subdiv(p_subdiv), lastEdge(nullptr)
 {
 }
 
 void
 LastFoundQuadEdgeLocator::init()
 {
-	lastEdge = findEdge();
+    lastEdge = findEdge();
 }
 
 QuadEdge*
 LastFoundQuadEdgeLocator::findEdge()
 {
-	// assume there is an edge
-	return *(subdiv->getEdges().begin());
+    // assume there is an edge
+    return *(subdiv->getEdges().begin());
 }
 
 QuadEdge*
-LastFoundQuadEdgeLocator::locate(const Vertex &v)
+LastFoundQuadEdgeLocator::locate(const Vertex& v)
 {
-	if (!lastEdge || !lastEdge->isLive()) {
-		init();
-	}
+    if(!lastEdge || !lastEdge->isLive()) {
+        init();
+    }
 
-	QuadEdge *e = subdiv->locateFromEdge(v, *lastEdge);
-	lastEdge = e;
-	return e;
+    QuadEdge* e = subdiv->locateFromEdge(v, *lastEdge);
+    lastEdge = e;
+    return e;
 }
 
 } //namespace geos.triangulate.quadedge
diff --git a/src/triangulate/quadedge/LocateFailureException.cpp b/src/triangulate/quadedge/LocateFailureException.cpp
index 2cd4b4b..3c0d75f 100644
--- a/src/triangulate/quadedge/LocateFailureException.cpp
+++ b/src/triangulate/quadedge/LocateFailureException.cpp
@@ -22,9 +22,9 @@ namespace geos {
 namespace triangulate { //geos.triangulate
 namespace quadedge { //geos.triangulate.quadedge
 
-LocateFailureException::LocateFailureException(std::string const&msg)
+LocateFailureException::LocateFailureException(std::string const& msg)
 {
-	util::GEOSException("LocateFailureException", msg);
+    util::GEOSException("LocateFailureException", msg);
 }
 
 } //namespace geos.triangulate.quadedge
diff --git a/src/triangulate/quadedge/QuadEdge.cpp b/src/triangulate/quadedge/QuadEdge.cpp
index d19dd61..2ab36c3 100644
--- a/src/triangulate/quadedge/QuadEdge.cpp
+++ b/src/triangulate/quadedge/QuadEdge.cpp
@@ -25,68 +25,68 @@ namespace quadedge { //geos.triangulate.quadedge
 using namespace geos::geom;
 
 std::unique_ptr<QuadEdge>
-QuadEdge::makeEdge(const Vertex &o, const Vertex &d)
+QuadEdge::makeEdge(const Vertex& o, const Vertex& d)
 {
-	QuadEdge *q0 = new QuadEdge();
-	//q1-q3 are free()'d by q0
-	QuadEdge *q1 = new QuadEdge();
-	QuadEdge *q2 = new QuadEdge();
-	QuadEdge *q3 = new QuadEdge();
-
-	q0->_rot = q1;
-	q1->_rot = q2;
-	q2->_rot = q3;
-	q3->_rot = q0;
-
-	q0->setNext(q0);
-	q1->setNext(q3);
-	q2->setNext(q2);
-	q3->setNext(q1);
-
-	QuadEdge *base = q0;
-	base->setOrig(o);
-	base->setDest(d);
-
-	return std::unique_ptr<QuadEdge>(base);
+    QuadEdge* q0 = new QuadEdge();
+    //q1-q3 are free()'d by q0
+    QuadEdge* q1 = new QuadEdge();
+    QuadEdge* q2 = new QuadEdge();
+    QuadEdge* q3 = new QuadEdge();
+
+    q0->_rot = q1;
+    q1->_rot = q2;
+    q2->_rot = q3;
+    q3->_rot = q0;
+
+    q0->setNext(q0);
+    q1->setNext(q3);
+    q2->setNext(q2);
+    q3->setNext(q1);
+
+    QuadEdge* base = q0;
+    base->setOrig(o);
+    base->setDest(d);
+
+    return std::unique_ptr<QuadEdge>(base);
 }
 
 std::unique_ptr<QuadEdge>
-QuadEdge::connect(QuadEdge &a, QuadEdge &b)
+QuadEdge::connect(QuadEdge& a, QuadEdge& b)
 {
-	std::unique_ptr<QuadEdge> q0 = makeEdge(a.dest(), b.orig());
-	splice(*q0, a.lNext());
-	splice(q0->sym(), b);
-	return q0;
+    std::unique_ptr<QuadEdge> q0 = makeEdge(a.dest(), b.orig());
+    splice(*q0, a.lNext());
+    splice(q0->sym(), b);
+    return q0;
 }
 
 void
-QuadEdge::splice(QuadEdge &a, QuadEdge &b)
+QuadEdge::splice(QuadEdge& a, QuadEdge& b)
 {
-	QuadEdge &alpha = a.oNext().rot();
-	QuadEdge &beta = b.oNext().rot();
-
-	QuadEdge &t1 = b.oNext();
-	QuadEdge &t2 = a.oNext();
-	QuadEdge &t3 = beta.oNext();
-	QuadEdge &t4 = alpha.oNext();
-
-	a.setNext(&t1);
-	b.setNext(&t2);
-	alpha.setNext(&t3);
-	beta.setNext(&t4);
+    QuadEdge& alpha = a.oNext().rot();
+    QuadEdge& beta = b.oNext().rot();
+
+    QuadEdge& t1 = b.oNext();
+    QuadEdge& t2 = a.oNext();
+    QuadEdge& t3 = beta.oNext();
+    QuadEdge& t4 = alpha.oNext();
+
+    a.setNext(&t1);
+    b.setNext(&t2);
+    alpha.setNext(&t3);
+    beta.setNext(&t4);
 }
 
 void
-QuadEdge::swap(QuadEdge &e)
+QuadEdge::swap(QuadEdge& e)
 {
-	QuadEdge &a = e.oPrev();
-	QuadEdge &b = e.sym().oPrev();
-	splice(e, a);
-	splice(e.sym(), b);
-	splice(e, a.lNext());
-	splice(e.sym(), b.lNext());
-	e.setOrig(a.dest());
-	e.setDest(b.dest());
+    QuadEdge& a = e.oPrev();
+    QuadEdge& b = e.sym().oPrev();
+    splice(e, a);
+    splice(e.sym(), b);
+    splice(e, a.lNext());
+    splice(e.sym(), b.lNext());
+    e.setOrig(a.dest());
+    e.setDest(b.dest());
 }
 
 QuadEdge::QuadEdge() : _rot(nullptr), vertex(), next(nullptr), data(nullptr), isAlive(true)
@@ -99,77 +99,79 @@ QuadEdge::~QuadEdge()
 void
 QuadEdge::free()
 {
-	if(_rot)
-	{
-		if(_rot->_rot)
-		{
-			if(_rot->_rot->_rot)
-			{
-				delete _rot->_rot->_rot;
-				_rot->_rot->_rot = nullptr;
-			}
-			delete _rot->_rot;
-			_rot->_rot = nullptr;
-		}
-		delete _rot;
-		_rot = nullptr;
-	}
+    if(_rot) {
+        if(_rot->_rot) {
+            if(_rot->_rot->_rot) {
+                delete _rot->_rot->_rot;
+                _rot->_rot->_rot = nullptr;
+            }
+            delete _rot->_rot;
+            _rot->_rot = nullptr;
+        }
+        delete _rot;
+        _rot = nullptr;
+    }
 }
 
 const QuadEdge&
 QuadEdge::getPrimary() const
 {
-	if (orig().getCoordinate().compareTo(dest().getCoordinate()) <= 0)
-		return *this;
-	else
-		return sym();
+    if(orig().getCoordinate().compareTo(dest().getCoordinate()) <= 0) {
+        return *this;
+    }
+    else {
+        return sym();
+    }
 }
 
 void
 QuadEdge::setData(void* p_data)
 {
-	this->data = p_data;
+    this->data = p_data;
 }
 
 void*
 QuadEdge::getData()
 {
-	return data;
+    return data;
 }
 
 void
 QuadEdge::remove()
 {
-	rot().rot().rot().isAlive = false;
-	rot().rot().isAlive = false;
-	rot().isAlive = false;
-	isAlive = false;
+    rot().rot().rot().isAlive = false;
+    rot().rot().isAlive = false;
+    rot().isAlive = false;
+    isAlive = false;
 }
 
 bool
-QuadEdge::equalsNonOriented(const QuadEdge &qe) const
+QuadEdge::equalsNonOriented(const QuadEdge& qe) const
 {
-	if (equalsOriented(qe))
-		return true;
-	if (equalsOriented(qe.sym()))
-		return true;
-	return false;
+    if(equalsOriented(qe)) {
+        return true;
+    }
+    if(equalsOriented(qe.sym())) {
+        return true;
+    }
+    return false;
 }
 
 bool
-QuadEdge::equalsOriented(const QuadEdge &qe) const
+QuadEdge::equalsOriented(const QuadEdge& qe) const
 {
-	if (orig().getCoordinate().equals2D(qe.orig().getCoordinate())
-			&& dest().getCoordinate().equals2D(qe.dest().getCoordinate()))
-		return true;
-	return false;
+    if(orig().getCoordinate().equals2D(qe.orig().getCoordinate())
+            && dest().getCoordinate().equals2D(qe.dest().getCoordinate())) {
+        return true;
+    }
+    return false;
 }
 
 std::unique_ptr<LineSegment>
 QuadEdge::toLineSegment() const
 {
-	return std::unique_ptr<geom::LineSegment>(
-			new geom::LineSegment(vertex.getCoordinate(), dest().getCoordinate()));
+    return std::unique_ptr<geom::LineSegment>(
+               new geom::LineSegment(vertex.getCoordinate(), dest().getCoordinate()));
 }
 
 } //namespace geos.triangulate.quadedge
diff --git a/src/triangulate/quadedge/QuadEdgeSubdivision.cpp b/src/triangulate/quadedge/QuadEdgeSubdivision.cpp
index 219f4e0..961375f 100644
--- a/src/triangulate/quadedge/QuadEdgeSubdivision.cpp
+++ b/src/triangulate/quadedge/QuadEdgeSubdivision.cpp
@@ -49,20 +49,20 @@ namespace triangulate { //geos.triangulate
 namespace quadedge { //geos.triangulate.quadedge
 
 void
-QuadEdgeSubdivision::getTriangleEdges(const QuadEdge &startQE,
-        const QuadEdge* triEdge[3])
+QuadEdgeSubdivision::getTriangleEdges(const QuadEdge& startQE,
+                                      const QuadEdge* triEdge[3])
 {
     triEdge[0] = &startQE;
     triEdge[1] = &triEdge[0]->lNext();
     triEdge[2] = &triEdge[1]->lNext();
-    if (&triEdge[2]->lNext() != triEdge[0]) {
+    if(&triEdge[2]->lNext() != triEdge[0]) {
         throw util::IllegalArgumentException("Edges do not form a triangle");
     }
 }
 
-QuadEdgeSubdivision::QuadEdgeSubdivision(const geom::Envelope &env, double p_tolerance) :
-        tolerance(p_tolerance),
-        locator(new LastFoundQuadEdgeLocator(this))
+QuadEdgeSubdivision::QuadEdgeSubdivision(const geom::Envelope& env, double p_tolerance) :
+    tolerance(p_tolerance),
+    locator(new LastFoundQuadEdgeLocator(this))
 {
     edgeCoincidenceTolerance = tolerance / EDGE_COINCIDENCE_TOL_FACTOR;
     createFrame(env);
@@ -77,32 +77,32 @@ QuadEdgeSubdivision::QuadEdgeSubdivision(const geom::Envelope &env, double p_tol
 
 QuadEdgeSubdivision::~QuadEdgeSubdivision()
 {
-    for(QuadEdgeList::iterator iter=createdEdges.begin(); iter!=createdEdges.end(); ++iter)
-    {
+    for(QuadEdgeList::iterator iter = createdEdges.begin(); iter != createdEdges.end(); ++iter) {
         (*iter)->free();
         delete *iter;
     }
 }
 
 void
-QuadEdgeSubdivision::createFrame(const geom::Envelope &env)
+QuadEdgeSubdivision::createFrame(const geom::Envelope& env)
 {
     double deltaX = env.getWidth();
     double deltaY = env.getHeight();
     double offset = 0.0;
-    if (deltaX > deltaY) {
+    if(deltaX > deltaY) {
         offset = deltaX * 10.0;
-    } else {
+    }
+    else {
         offset = deltaY * 10.0;
     }
 
     frameVertex[0] = Vertex((env.getMaxX() + env.getMinX()) / 2.0, env
-            .getMaxY() + offset);
+                            .getMaxY() + offset);
     frameVertex[1] = Vertex(env.getMinX() - offset, env.getMinY() - offset);
     frameVertex[2] = Vertex(env.getMaxX() + offset, env.getMinY() - offset);
 
     frameEnv = Envelope(frameVertex[0].getCoordinate(), frameVertex[1]
-            .getCoordinate());
+                        .getCoordinate());
     frameEnv.expandToInclude(frameVertex[2].getCoordinate());
 }
 void
@@ -130,10 +130,10 @@ QuadEdgeSubdivision::initSubdiv(QuadEdge* initEdges[3])
 }
 
 QuadEdge&
-QuadEdgeSubdivision::makeEdge(const Vertex &o, const Vertex &d)
+QuadEdgeSubdivision::makeEdge(const Vertex& o, const Vertex& d)
 {
     std::unique_ptr<QuadEdge> q0 = QuadEdge::makeEdge(o, d);
-    QuadEdge *q0_ptr = q0.get();
+    QuadEdge* q0_ptr = q0.get();
     q0.release();
 
     createdEdges.push_back(q0_ptr);
@@ -142,10 +142,10 @@ QuadEdgeSubdivision::makeEdge(const Vertex &o, const Vertex &d)
 }
 
 QuadEdge&
-QuadEdgeSubdivision::connect(QuadEdge &a, QuadEdge &b)
+QuadEdgeSubdivision::connect(QuadEdge& a, QuadEdge& b)
 {
     std::unique_ptr<QuadEdge> q0 = QuadEdge::connect(a, b);
-    QuadEdge *q0_ptr = q0.get();
+    QuadEdge* q0_ptr = q0.get();
     q0.release();
 
     createdEdges.push_back(q0_ptr);
@@ -154,7 +154,7 @@ QuadEdgeSubdivision::connect(QuadEdge &a, QuadEdge &b)
 }
 
 void
-QuadEdgeSubdivision::remove(QuadEdge &e)
+QuadEdgeSubdivision::remove(QuadEdge& e)
 {
     QuadEdge::splice(e, e.oPrev());
     QuadEdge::splice(e.sym(), e.sym().oPrev());
@@ -168,18 +168,17 @@ QuadEdgeSubdivision::remove(QuadEdge &e)
 }
 
 QuadEdge*
-QuadEdgeSubdivision::locateFromEdge(const Vertex &v,
-        const QuadEdge &startEdge) const
+QuadEdgeSubdivision::locateFromEdge(const Vertex& v,
+                                    const QuadEdge& startEdge) const
 {
     ::geos::ignore_unused_variable_warning(startEdge);
 
     size_t iter = 0;
     auto maxIter = quadEdges.size();
 
-    QuadEdge *e = startingEdges[0];
+    QuadEdge* e = startingEdges[0];
 
-    for (;;)
-    {
+    for(;;) {
         ++iter;
         /**
          * So far it has always been the case that failure to locate indicates an
@@ -190,19 +189,23 @@ QuadEdgeSubdivision::locateFromEdge(const Vertex &v,
          * This can also happen if two vertices are located very close together,
          * since the orientation predicates may experience precision failures.
          */
-        if (iter > maxIter) {
+        if(iter > maxIter) {
             throw LocateFailureException("");
         }
 
-        if ((v.equals(e->orig())) || (v.equals(e->dest()))) {
+        if((v.equals(e->orig())) || (v.equals(e->dest()))) {
             break;
-        } else if (v.rightOf(*e)) {
+        }
+        else if(v.rightOf(*e)) {
             e = &e->sym();
-        } else if (!v.rightOf(e->oNext())) {
+        }
+        else if(!v.rightOf(e->oNext())) {
             e = &e->oNext();
-        } else if (!v.rightOf(e->dPrev())) {
+        }
+        else if(!v.rightOf(e->dPrev())) {
             e = &e->dPrev();
-        } else {
+        }
+        else {
             // on edge or in triangle containing edge
             break;
         }
@@ -211,87 +214,98 @@ QuadEdgeSubdivision::locateFromEdge(const Vertex &v,
 }
 
 QuadEdge*
-QuadEdgeSubdivision::locate(const Coordinate &p0, const Coordinate &p1)
+QuadEdgeSubdivision::locate(const Coordinate& p0, const Coordinate& p1)
 {
     // find an edge containing one of the points
-    QuadEdge *e = locator->locate(Vertex(p0));
-    if (e == nullptr)
+    QuadEdge* e = locator->locate(Vertex(p0));
+    if(e == nullptr) {
         return nullptr;
+    }
 
     // normalize so that p0 is origin of base edge
-    QuadEdge *base = e;
-    if (e->dest().getCoordinate().equals2D(p0))
+    QuadEdge* base = e;
+    if(e->dest().getCoordinate().equals2D(p0)) {
         base = &e->sym();
+    }
     // check all edges around origin of base edge
-    QuadEdge *locEdge = base;
+    QuadEdge* locEdge = base;
     do {
-        if (locEdge->dest().getCoordinate().equals2D(p1))
+        if(locEdge->dest().getCoordinate().equals2D(p1)) {
             return locEdge;
+        }
         locEdge = &locEdge->oNext();
-    } while (locEdge != base);
+    }
+    while(locEdge != base);
     return nullptr;
 }
 
 QuadEdge&
-QuadEdgeSubdivision::insertSite(const Vertex &v)
+QuadEdgeSubdivision::insertSite(const Vertex& v)
 {
-    QuadEdge *e = locate(v);
+    QuadEdge* e = locate(v);
 
-    if ((v.equals(e->orig(), tolerance)) || (v.equals(e->dest(), tolerance))) {
+    if((v.equals(e->orig(), tolerance)) || (v.equals(e->dest(), tolerance))) {
         return *e; // point already in subdivision.
     }
 
     // Connect the new point to the vertices of the containing
     // triangle (or quadrilateral, if the new point fell on an
     // existing edge.)
-    QuadEdge *base = &makeEdge(e->orig(), v);
+    QuadEdge* base = &makeEdge(e->orig(), v);
     QuadEdge::splice(*base, *e);
-    QuadEdge *startEdge = base;
+    QuadEdge* startEdge = base;
     do {
         base = &connect(*e, base->sym());
         e = &base->oPrev();
-    } while (&e->lNext() != startEdge);
+    }
+    while(&e->lNext() != startEdge);
 
     return *startEdge;
 }
 
 bool
-QuadEdgeSubdivision::isFrameEdge(const QuadEdge &e) const
+QuadEdgeSubdivision::isFrameEdge(const QuadEdge& e) const
 {
-    if (isFrameVertex(e.orig()) || isFrameVertex(e.dest()))
+    if(isFrameVertex(e.orig()) || isFrameVertex(e.dest())) {
         return true;
+    }
     return false;
 }
 
 bool
-QuadEdgeSubdivision::isFrameBorderEdge(const QuadEdge &e) const
+QuadEdgeSubdivision::isFrameBorderEdge(const QuadEdge& e) const
 {
     // check other vertex of triangle to left of edge
     Vertex vLeftTriOther = e.lNext().dest();
-    if (isFrameVertex(vLeftTriOther))
+    if(isFrameVertex(vLeftTriOther)) {
         return true;
+    }
     // check other vertex of triangle to right of edge
     Vertex vRightTriOther = e.sym().lNext().dest();
-    if (isFrameVertex(vRightTriOther))
+    if(isFrameVertex(vRightTriOther)) {
         return true;
+    }
 
     return false;
 }
 
 bool
-QuadEdgeSubdivision::isFrameVertex(const Vertex &v) const
+QuadEdgeSubdivision::isFrameVertex(const Vertex& v) const
 {
-    if (v.equals(frameVertex[0]))
+    if(v.equals(frameVertex[0])) {
         return true;
-    if (v.equals(frameVertex[1]))
+    }
+    if(v.equals(frameVertex[1])) {
         return true;
-    if (v.equals(frameVertex[2]))
+    }
+    if(v.equals(frameVertex[2])) {
         return true;
+    }
     return false;
 }
 
 bool
-QuadEdgeSubdivision::isOnEdge(const QuadEdge &e, const Coordinate &p) const
+QuadEdgeSubdivision::isOnEdge(const QuadEdge& e, const Coordinate& p) const
 {
     geom::LineSegment seg;
     seg.setCoordinates(e.orig().getCoordinate(), e.dest().getCoordinate());
@@ -301,9 +315,9 @@ QuadEdgeSubdivision::isOnEdge(const QuadEdge &e, const Coordinate &p) const
 }
 
 bool
-QuadEdgeSubdivision::isVertexOfEdge(const QuadEdge &e, const Vertex &v) const
+QuadEdgeSubdivision::isVertexOfEdge(const QuadEdge& e, const Vertex& v) const
 {
-    if ((v.equals(e.orig(), tolerance)) || (v.equals(e.dest(), tolerance))) {
+    if((v.equals(e.orig(), tolerance)) || (v.equals(e.dest(), tolerance))) {
         return true;
     }
     return false;
@@ -312,22 +326,21 @@ QuadEdgeSubdivision::isVertexOfEdge(const QuadEdge &e, const Vertex &v) const
 std::unique_ptr<QuadEdgeSubdivision::QuadEdgeList>
 QuadEdgeSubdivision::getPrimaryEdges(bool includeFrame)
 {
-    QuadEdgeList *edges = new QuadEdgeList();
+    QuadEdgeList* edges = new QuadEdgeList();
     QuadEdgeStack edgeStack;
     QuadEdgeSet visitedEdges;
 
     edgeStack.push(startingEdges[0]);
 
-    while (!edgeStack.empty())
-    {
-        QuadEdge *edge = edgeStack.top();
+    while(!edgeStack.empty()) {
+        QuadEdge* edge = edgeStack.top();
         edgeStack.pop();
-        if (visitedEdges.find(edge) == visitedEdges.end())
-        {
+        if(visitedEdges.find(edge) == visitedEdges.end()) {
             QuadEdge* priQE = (QuadEdge*)&edge->getPrimary();
 
-            if (includeFrame || ! isFrameEdge(*priQE))
+            if(includeFrame || ! isFrameEdge(*priQE)) {
                 edges->push_back(priQE);
+            }
 
             edgeStack.push(&edge->oNext());
             edgeStack.push(&edge->sym().oNext());
@@ -340,23 +353,24 @@ QuadEdgeSubdivision::getPrimaryEdges(bool includeFrame)
 }
 
 QuadEdge**
-QuadEdgeSubdivision::fetchTriangleToVisit(QuadEdge *edge,
-        QuadEdgeStack &edgeStack, bool includeFrame, QuadEdgeSet &visitedEdges)
+QuadEdgeSubdivision::fetchTriangleToVisit(QuadEdge* edge,
+        QuadEdgeStack& edgeStack, bool includeFrame, QuadEdgeSet& visitedEdges)
 {
-    QuadEdge *curr = edge;
+    QuadEdge* curr = edge;
     int edgeCount = 0;
     bool isFrame = false;
-    do
-    {
+    do {
         triEdges[edgeCount] = curr;
 
-        if (isFrameEdge(*curr))
+        if(isFrameEdge(*curr)) {
             isFrame = true;
+        }
 
         // push sym edges to visit next
-        QuadEdge *sym = &curr->sym();
-        if (visitedEdges.find(sym) == visitedEdges.end())
+        QuadEdge* sym = &curr->sym();
+        if(visitedEdges.find(sym) == visitedEdges.end()) {
             edgeStack.push(sym);
+        }
 
         // mark this edge as visited
         visitedEdges.insert(curr);
@@ -364,28 +378,31 @@ QuadEdgeSubdivision::fetchTriangleToVisit(QuadEdge *edge,
         edgeCount++;
         curr = &curr->lNext();
 
-    } while (curr != edge);
+    }
+    while(curr != edge);
 
-    if (isFrame && !includeFrame)
+    if(isFrame && !includeFrame) {
         return nullptr;
+    }
     return triEdges;
 }
 
 class
-QuadEdgeSubdivision::TriangleCoordinatesVisitor : public TriangleVisitor {
+    QuadEdgeSubdivision::TriangleCoordinatesVisitor : public TriangleVisitor {
 private:
-    QuadEdgeSubdivision::TriList *triCoords;
+    QuadEdgeSubdivision::TriList* triCoords;
     CoordinateArraySequenceFactory coordSeqFact;
 
 public:
-    TriangleCoordinatesVisitor(QuadEdgeSubdivision::TriList *p_triCoords): triCoords(p_triCoords)
+    TriangleCoordinatesVisitor(QuadEdgeSubdivision::TriList* p_triCoords): triCoords(p_triCoords)
     {
     }
 
-    void visit(QuadEdge* triEdges[3]) override
+    void
+    visit(QuadEdge* triEdges[3]) override
     {
-        geom::CoordinateSequence *coordSeq = coordSeqFact.create(4,0);
-        for (int i = 0; i < 3; i++) {
+        geom::CoordinateSequence* coordSeq = coordSeqFact.create(4, 0);
+        for(int i = 0; i < 3; i++) {
             Vertex v = triEdges[i]->orig();
             coordSeq->setAt(v.getCoordinate(), i);
         }
@@ -396,22 +413,22 @@ public:
 
 
 class
-QuadEdgeSubdivision::TriangleCircumcentreVisitor : public TriangleVisitor
-{
+    QuadEdgeSubdivision::TriangleCircumcentreVisitor : public TriangleVisitor {
 public:
-	void visit(QuadEdge* triEdges[3]) override
-	{
-		Triangle triangle(triEdges[0]->orig().getCoordinate(),
-				triEdges[1]->orig().getCoordinate(), triEdges[2]->orig().getCoordinate());
-		Coordinate cc;
-		triangle.circumcentre(cc);
-
-		Vertex ccVertex(cc);
-
-		for(int i=0 ; i<3 ; i++){
-			triEdges[i]->rot().setOrig(ccVertex);
-		}
-	}
+    void
+    visit(QuadEdge* triEdges[3]) override
+    {
+        Triangle triangle(triEdges[0]->orig().getCoordinate(),
+                          triEdges[1]->orig().getCoordinate(), triEdges[2]->orig().getCoordinate());
+        Coordinate cc;
+        triangle.circumcentre(cc);
+
+        Vertex ccVertex(cc);
+
+        for(int i = 0 ; i < 3 ; i++) {
+            triEdges[i]->rot().setOrig(ccVertex);
+        }
+    }
 };
 
 
@@ -423,7 +440,7 @@ QuadEdgeSubdivision::getTriangleCoordinates(QuadEdgeSubdivision::TriList* triLis
 }
 
 void
-QuadEdgeSubdivision::visitTriangles(TriangleVisitor *triVisitor, bool includeFrame)
+QuadEdgeSubdivision::visitTriangles(TriangleVisitor* triVisitor, bool includeFrame)
 {
 
     QuadEdgeStack edgeStack;
@@ -431,14 +448,15 @@ QuadEdgeSubdivision::visitTriangles(TriangleVisitor *triVisitor, bool includeFra
 
     QuadEdgeSet visitedEdges;
 
-    while (!edgeStack.empty()) {
-        QuadEdge *edge = edgeStack.top();
+    while(!edgeStack.empty()) {
+        QuadEdge* edge = edgeStack.top();
         edgeStack.pop();
-        if (visitedEdges.find(edge) == visitedEdges.end()) {
-            QuadEdge **p_triEdges = fetchTriangleToVisit(edge, edgeStack,
-                    includeFrame, visitedEdges);
-            if (p_triEdges != nullptr)
+        if(visitedEdges.find(edge) == visitedEdges.end()) {
+            QuadEdge** p_triEdges = fetchTriangleToVisit(edge, edgeStack,
+                                    includeFrame, visitedEdges);
+            if(p_triEdges != nullptr) {
                 triVisitor->visit(p_triEdges);
+            }
         }
     }
 }
@@ -447,13 +465,12 @@ std::unique_ptr<geom::MultiLineString>
 QuadEdgeSubdivision::getEdges(const geom::GeometryFactory& geomFact)
 {
     std::unique_ptr<QuadEdgeList> p_quadEdges(getPrimaryEdges(false));
-    std::vector<Geometry *> edges(p_quadEdges->size());
-    const CoordinateSequenceFactory *coordSeqFact = geomFact.getCoordinateSequenceFactory();
+    std::vector<Geometry*> edges(p_quadEdges->size());
+    const CoordinateSequenceFactory* coordSeqFact = geomFact.getCoordinateSequenceFactory();
     int i = 0;
-    for (QuadEdgeSubdivision::QuadEdgeList::iterator it = p_quadEdges->begin(); it != p_quadEdges->end(); ++it)
-    {
-        QuadEdge *qe = *it;
-        CoordinateSequence *coordSeq = coordSeqFact->create((std::vector<geom::Coordinate>*)nullptr);;
+    for(QuadEdgeSubdivision::QuadEdgeList::iterator it = p_quadEdges->begin(); it != p_quadEdges->end(); ++it) {
+        QuadEdge* qe = *it;
+        CoordinateSequence* coordSeq = coordSeqFact->create((std::vector<geom::Coordinate>*)nullptr);;
 
         coordSeq->add(qe->orig().getCoordinate());
         coordSeq->add(qe->dest().getCoordinate());
@@ -465,32 +482,33 @@ QuadEdgeSubdivision::getEdges(const geom::GeometryFactory& geomFact)
 
     geom::MultiLineString* result = geomFact.createMultiLineString(edges);
 
-    for(std::vector<Geometry*>::iterator it=edges.begin(); it!=edges.end(); ++it)
+    for(std::vector<Geometry*>::iterator it = edges.begin(); it != edges.end(); ++it) {
         delete *it;
+    }
 
     return std::unique_ptr<MultiLineString>(result);
 }
 
 std::unique_ptr<GeometryCollection>
-QuadEdgeSubdivision::getTriangles( const GeometryFactory &geomFact)
+QuadEdgeSubdivision::getTriangles(const GeometryFactory& geomFact)
 {
     TriList triPtsList;
     getTriangleCoordinates(&triPtsList, false);
     std::vector<Geometry*> tris;
 
     for(TriList::const_iterator it = triPtsList.begin();
-            it != triPtsList.end(); ++it)
-    {
-        CoordinateSequence *coordSeq = *it;
-        Polygon *tri = geomFact.createPolygon(
-                geomFact.createLinearRing(coordSeq), nullptr);
+            it != triPtsList.end(); ++it) {
+        CoordinateSequence* coordSeq = *it;
+        Polygon* tri = geomFact.createPolygon(
+                           geomFact.createLinearRing(coordSeq), nullptr);
         tris.push_back(static_cast<Geometry*>(tri));
     }
     GeometryCollection* ret =  geomFact.createGeometryCollection(tris);
 
     //release memory
-    for(std::vector<Geometry*>::iterator it=tris.begin(); it!=tris.end(); ++it)
+    for(std::vector<Geometry*>::iterator it = tris.begin(); it != tris.end(); ++it) {
         delete *it;
+    }
     tris.clear();
 
     return std::unique_ptr<GeometryCollection>(ret);
@@ -501,153 +519,151 @@ QuadEdgeSubdivision::getTriangles( const GeometryFactory &geomFact)
 std::unique_ptr<geom::GeometryCollection>
 QuadEdgeSubdivision::getVoronoiDiagram(const geom::GeometryFactory& geomFact)
 {
-	std::unique_ptr< std::vector<geom::Geometry*> > vorCells = getVoronoiCellPolygons(geomFact);
-	return std::unique_ptr<GeometryCollection>(geomFact.createGeometryCollection(vorCells.release()));
+    std::unique_ptr< std::vector<geom::Geometry*> > vorCells = getVoronoiCellPolygons(geomFact);
+    return std::unique_ptr<GeometryCollection>(geomFact.createGeometryCollection(vorCells.release()));
 }
 
 std::unique_ptr<geom::MultiLineString>
 QuadEdgeSubdivision::getVoronoiDiagramEdges(const geom::GeometryFactory& geomFact)
 {
-	std::unique_ptr< std::vector<geom::Geometry*> > vorCells = getVoronoiCellEdges(geomFact);
-	return std::unique_ptr<MultiLineString>(geomFact.createMultiLineString(vorCells.release()));
+    std::unique_ptr< std::vector<geom::Geometry*> > vorCells = getVoronoiCellEdges(geomFact);
+    return std::unique_ptr<MultiLineString>(geomFact.createMultiLineString(vorCells.release()));
 }
 
 std::unique_ptr< std::vector<geom::Geometry*> >
 QuadEdgeSubdivision::getVoronoiCellPolygons(const geom::GeometryFactory& geomFact)
 {
-	std::unique_ptr< std::vector<geom::Geometry*> > cells(new std::vector<geom::Geometry*>);
-	TriangleCircumcentreVisitor* tricircumVisitor = new TriangleCircumcentreVisitor();
-	visitTriangles((TriangleVisitor*)tricircumVisitor, true);
+    std::unique_ptr< std::vector<geom::Geometry*> > cells(new std::vector<geom::Geometry*>);
+    TriangleCircumcentreVisitor* tricircumVisitor = new TriangleCircumcentreVisitor();
+    visitTriangles((TriangleVisitor*)tricircumVisitor, true);
 
-	std::unique_ptr<QuadEdgeSubdivision::QuadEdgeList> edges = getVertexUniqueEdges(false);
+    std::unique_ptr<QuadEdgeSubdivision::QuadEdgeList> edges = getVertexUniqueEdges(false);
 
-	for(QuadEdgeSubdivision::QuadEdgeList::iterator it=edges->begin() ; it!=edges->end() ; ++it)
-	{
-		QuadEdge *qe = *it;
-		std::unique_ptr<geom::Geometry> poly = getVoronoiCellPolygon(qe,geomFact);
+    for(QuadEdgeSubdivision::QuadEdgeList::iterator it = edges->begin() ; it != edges->end() ; ++it) {
+        QuadEdge* qe = *it;
+        std::unique_ptr<geom::Geometry> poly = getVoronoiCellPolygon(qe, geomFact);
 
-		cells->push_back(poly.release());
-	}
-	delete tricircumVisitor;
-	return cells;
+        cells->push_back(poly.release());
+    }
+    delete tricircumVisitor;
+    return cells;
 }
 
 std::unique_ptr< std::vector<geom::Geometry*> >
 QuadEdgeSubdivision::getVoronoiCellEdges(const geom::GeometryFactory& geomFact)
 {
-	std::unique_ptr< std::vector<geom::Geometry*> > cells(new std::vector<geom::Geometry*>);
-	TriangleCircumcentreVisitor* tricircumVisitor = new TriangleCircumcentreVisitor();
-	visitTriangles((TriangleVisitor*)tricircumVisitor, true);
+    std::unique_ptr< std::vector<geom::Geometry*> > cells(new std::vector<geom::Geometry*>);
+    TriangleCircumcentreVisitor* tricircumVisitor = new TriangleCircumcentreVisitor();
+    visitTriangles((TriangleVisitor*)tricircumVisitor, true);
 
-	std::unique_ptr<QuadEdgeSubdivision::QuadEdgeList> edges = getVertexUniqueEdges(false);
+    std::unique_ptr<QuadEdgeSubdivision::QuadEdgeList> edges = getVertexUniqueEdges(false);
 
-	for(QuadEdgeSubdivision::QuadEdgeList::iterator it=edges->begin() ; it!=edges->end() ; ++it)
-	{
-		QuadEdge *qe = *it;
-		std::unique_ptr<geom::Geometry> poly = getVoronoiCellEdge(qe,geomFact);
+    for(QuadEdgeSubdivision::QuadEdgeList::iterator it = edges->begin() ; it != edges->end() ; ++it) {
+        QuadEdge* qe = *it;
+        std::unique_ptr<geom::Geometry> poly = getVoronoiCellEdge(qe, geomFact);
 
-		cells->push_back(poly.release());
-	}
-	delete tricircumVisitor;
-	return cells;
+        cells->push_back(poly.release());
+    }
+    delete tricircumVisitor;
+    return cells;
 }
 
 std::unique_ptr<geom::Geometry>
-QuadEdgeSubdivision::getVoronoiCellPolygon(QuadEdge* qe ,const geom::GeometryFactory& geomFact)
+QuadEdgeSubdivision::getVoronoiCellPolygon(QuadEdge* qe, const geom::GeometryFactory& geomFact)
 {
-	std::vector<Coordinate> cellPts;
-	QuadEdge *startQE = qe;
-	do{
-		Coordinate cc = qe->rot().orig().getCoordinate();
-		if ( cellPts.empty() || cellPts.back() != cc ) // no duplicates
-			cellPts.push_back(cc);
-		qe = &qe->oPrev();
-
-	}while ( qe != startQE);
-
-
-	//CoordList from a vector of Coordinates.
-	geom::CoordinateList coordList(cellPts);
-	//for checking close ring in CoordList class:
-	coordList.closeRing();
-
-	if(coordList.size() < 4)
-	{
-		coordList.insert(coordList.end(),*(coordList.end()),true);
-	}
-
-	std::unique_ptr<Coordinate::Vect> pts = coordList.toCoordinateArray();
-	std::unique_ptr<geom::Geometry> cellPoly(
-		geomFact.createPolygon(geomFact.createLinearRing(new geom::CoordinateArraySequence(pts.release())),nullptr));
-
-	Vertex v = startQE->orig();
-	Coordinate c(0,0);
-	c = v.getCoordinate();
-	cellPoly->setUserData(reinterpret_cast<void*>(&c));
-	return cellPoly;
+    std::vector<Coordinate> cellPts;
+    QuadEdge* startQE = qe;
+    do {
+        Coordinate cc = qe->rot().orig().getCoordinate();
+        if(cellPts.empty() || cellPts.back() != cc) {  // no duplicates
+            cellPts.push_back(cc);
+        }
+        qe = &qe->oPrev();
+
+    }
+    while(qe != startQE);
+
+
+    //CoordList from a vector of Coordinates.
+    geom::CoordinateList coordList(cellPts);
+    //for checking close ring in CoordList class:
+    coordList.closeRing();
+
+    if(coordList.size() < 4) {
+        coordList.insert(coordList.end(), *(coordList.end()), true);
+    }
+
+    std::unique_ptr<Coordinate::Vect> pts = coordList.toCoordinateArray();
+    std::unique_ptr<geom::Geometry> cellPoly(
+        geomFact.createPolygon(geomFact.createLinearRing(new geom::CoordinateArraySequence(pts.release())), nullptr));
+
+    Vertex v = startQE->orig();
+    Coordinate c(0, 0);
+    c = v.getCoordinate();
+    cellPoly->setUserData(reinterpret_cast<void*>(&c));
+    return cellPoly;
 }
 
 std::unique_ptr<geom::Geometry>
-QuadEdgeSubdivision::getVoronoiCellEdge(QuadEdge* qe ,const geom::GeometryFactory& geomFact)
+QuadEdgeSubdivision::getVoronoiCellEdge(QuadEdge* qe, const geom::GeometryFactory& geomFact)
 {
-	std::vector<Coordinate> cellPts;
-	QuadEdge *startQE = qe;
-	do{
-		Coordinate cc = qe->rot().orig().getCoordinate();
-		if ( cellPts.empty() || cellPts.back() != cc ) // no duplicates
-			cellPts.push_back(cc);
-		qe = &qe->oPrev();
-
-	}while ( qe != startQE);
-
-
-	//CoordList from a vector of Coordinates.
-	geom::CoordinateList coordList(cellPts);
-	//for checking close ring in CoordList class:
-	coordList.closeRing();
-
-	std::unique_ptr<Coordinate::Vect> pts = coordList.toCoordinateArray();
-	std::unique_ptr<geom::Geometry> cellEdge(
-		geomFact.createLineString(new geom::CoordinateArraySequence(pts.release())));
-
-	Vertex v = startQE->orig();
-	Coordinate c(0,0);
-	c = v.getCoordinate();
-	cellEdge->setUserData(reinterpret_cast<void*>(&c));
-	return cellEdge;
+    std::vector<Coordinate> cellPts;
+    QuadEdge* startQE = qe;
+    do {
+        Coordinate cc = qe->rot().orig().getCoordinate();
+        if(cellPts.empty() || cellPts.back() != cc) {  // no duplicates
+            cellPts.push_back(cc);
+        }
+        qe = &qe->oPrev();
+
+    }
+    while(qe != startQE);
+
+
+    //CoordList from a vector of Coordinates.
+    geom::CoordinateList coordList(cellPts);
+    //for checking close ring in CoordList class:
+    coordList.closeRing();
+
+    std::unique_ptr<Coordinate::Vect> pts = coordList.toCoordinateArray();
+    std::unique_ptr<geom::Geometry> cellEdge(
+        geomFact.createLineString(new geom::CoordinateArraySequence(pts.release())));
+
+    Vertex v = startQE->orig();
+    Coordinate c(0, 0);
+    c = v.getCoordinate();
+    cellEdge->setUserData(reinterpret_cast<void*>(&c));
+    return cellEdge;
 }
 
 std::unique_ptr<QuadEdgeSubdivision::QuadEdgeList>
 QuadEdgeSubdivision::getVertexUniqueEdges(bool includeFrame)
 {
-	std::unique_ptr<QuadEdgeSubdivision::QuadEdgeList> edges(new QuadEdgeList());
-	std::set<Vertex> visitedVertices;
-	for(QuadEdgeSubdivision::QuadEdgeList::iterator it=quadEdges.begin() ; it!=quadEdges.end() ; ++it)
-	{
-		QuadEdge *qe = (QuadEdge*)(*it);
-		Vertex v = qe->orig();
-
-
-		if(visitedVertices.find(v) == visitedVertices.end())	//if v not found
-		{
-			visitedVertices.insert(v);
-			if(includeFrame || ! QuadEdgeSubdivision::isFrameVertex(v))
-			{
-				edges->push_back(qe);
-			}
-		}
-		QuadEdge *qd = &(qe->sym());
-		Vertex vd = qd->orig();
-
-
-		if(visitedVertices.find(vd) == visitedVertices.end()){
-			visitedVertices.insert(vd);
-			if(includeFrame || ! QuadEdgeSubdivision::isFrameVertex(vd)){
-				edges->push_back(qd);
-			}
-		}
-	}
-	return edges;
+    std::unique_ptr<QuadEdgeSubdivision::QuadEdgeList> edges(new QuadEdgeList());
+    std::set<Vertex> visitedVertices;
+    for(QuadEdgeSubdivision::QuadEdgeList::iterator it = quadEdges.begin() ; it != quadEdges.end() ; ++it) {
+        QuadEdge* qe = (QuadEdge*)(*it);
+        Vertex v = qe->orig();
+
+
+        if(visitedVertices.find(v) == visitedVertices.end()) {	//if v not found
+            visitedVertices.insert(v);
+            if(includeFrame || ! QuadEdgeSubdivision::isFrameVertex(v)) {
+                edges->push_back(qe);
+            }
+        }
+        QuadEdge* qd = &(qe->sym());
+        Vertex vd = qd->orig();
+
+
+        if(visitedVertices.find(vd) == visitedVertices.end()) {
+            visitedVertices.insert(vd);
+            if(includeFrame || ! QuadEdgeSubdivision::isFrameVertex(vd)) {
+                edges->push_back(qd);
+            }
+        }
+    }
+    return edges;
 }
 
 } //namespace geos.triangulate.quadedge
diff --git a/src/triangulate/quadedge/TrianglePredicate.cpp b/src/triangulate/quadedge/TrianglePredicate.cpp
index 2030ad2..c943407 100644
--- a/src/triangulate/quadedge/TrianglePredicate.cpp
+++ b/src/triangulate/quadedge/TrianglePredicate.cpp
@@ -25,64 +25,64 @@ namespace geom { // geos.geom
 
 bool
 TrianglePredicate::isInCircleNonRobust(
-		const Coordinate &a, const Coordinate &b, const Coordinate &c,
-		const Coordinate &p)
+    const Coordinate& a, const Coordinate& b, const Coordinate& c,
+    const Coordinate& p)
 {
-	bool isInCircle =
-		(a.x * a.x + a.y * a.y) * triArea(b, c, p)
-		- (b.x * b.x + b.y * b.y) * triArea(a, c, p)
-		+ (c.x * c.x + c.y * c.y) * triArea(a, b, p)
-		- (p.x * p.x + p.y * p.y) * triArea(a, b, c)
-		> 0;
-	return isInCircle;
+    bool isInCircle =
+        (a.x * a.x + a.y * a.y) * triArea(b, c, p)
+        - (b.x * b.x + b.y * b.y) * triArea(a, c, p)
+        + (c.x * c.x + c.y * c.y) * triArea(a, b, p)
+        - (p.x * p.x + p.y * p.y) * triArea(a, b, c)
+        > 0;
+    return isInCircle;
 }
 
 bool
 TrianglePredicate::isInCircleNormalized(
-		const Coordinate &a, const Coordinate &b, const Coordinate &c,
-		const Coordinate &p)
+    const Coordinate& a, const Coordinate& b, const Coordinate& c,
+    const Coordinate& p)
 {
-	// Unfortunately this implementation is not robust either. For robust one see:
-	// https://www.cs.cmu.edu/~quake/robust.html
-	// https://www.cs.cmu.edu/afs/cs/project/quake/public/code/predicates.c
+    // Unfortunately this implementation is not robust either. For robust one see:
+    // https://www.cs.cmu.edu/~quake/robust.html
+    // https://www.cs.cmu.edu/afs/cs/project/quake/public/code/predicates.c
 
-	long double adx = a.x - p.x;
-	long double ady = a.y - p.y;
-	long double bdx = b.x - p.x;
-	long double bdy = b.y - p.y;
-	long double cdx = c.x - p.x;
-	long double cdy = c.y - p.y;
+    long double adx = a.x - p.x;
+    long double ady = a.y - p.y;
+    long double bdx = b.x - p.x;
+    long double bdy = b.y - p.y;
+    long double cdx = c.x - p.x;
+    long double cdy = c.y - p.y;
 
-	long double bdxcdy = bdx * cdy;
-	long double cdxbdy = cdx * bdy;
-	long double alift = adx * adx + ady * ady;
+    long double bdxcdy = bdx * cdy;
+    long double cdxbdy = cdx * bdy;
+    long double alift = adx * adx + ady * ady;
 
-	long double cdxady = cdx * ady;
-	long double adxcdy = adx * cdy;
-	long double blift = bdx * bdx + bdy * bdy;
+    long double cdxady = cdx * ady;
+    long double adxcdy = adx * cdy;
+    long double blift = bdx * bdx + bdy * bdy;
 
-	long double adxbdy = adx * bdy;
-	long double bdxady = bdx * ady;
-	long double clift = cdx * cdx + cdy * cdy;
-	return (alift * bdxcdy + blift * cdxady + clift * adxbdy) >
-		(alift * cdxbdy + blift * adxcdy + clift * bdxady);
+    long double adxbdy = adx * bdy;
+    long double bdxady = bdx * ady;
+    long double clift = cdx * cdx + cdy * cdy;
+    return (alift * bdxcdy + blift * cdxady + clift * adxbdy) >
+           (alift * cdxbdy + blift * adxcdy + clift * bdxady);
 }
 
 double
-TrianglePredicate::triArea(const Coordinate &a,
-		const Coordinate &b, const Coordinate &c)
+TrianglePredicate::triArea(const Coordinate& a,
+                           const Coordinate& b, const Coordinate& c)
 {
-	return (b.x - a.x) * (c.y - a.y)
-		- (b.y - a.y) * (c.x - a.x);
+    return (b.x - a.x) * (c.y - a.y)
+           - (b.y - a.y) * (c.x - a.x);
 }
 
 bool
 TrianglePredicate::isInCircleRobust(
-		const Coordinate &a, const Coordinate &b, const Coordinate &c,
-		const Coordinate &p)
+    const Coordinate& a, const Coordinate& b, const Coordinate& c,
+    const Coordinate& p)
 {
-	// This implementation is not robust, name is ported from JTS.
-	return isInCircleNormalized(a, b, c, p);
+    // This implementation is not robust, name is ported from JTS.
+    return isInCircleNormalized(a, b, c, p);
 }
 
 } // namespace geos.geom
diff --git a/src/triangulate/quadedge/Vertex.cpp b/src/triangulate/quadedge/Vertex.cpp
index 04287f7..4875734 100644
--- a/src/triangulate/quadedge/Vertex.cpp
+++ b/src/triangulate/quadedge/Vertex.cpp
@@ -34,157 +34,176 @@ Vertex::Vertex(double _x, double _y) : p(_x, _y)
 {
 }
 
-Vertex::Vertex(double _x, double _y, double _z): p( _x, _y, _z)
+Vertex::Vertex(double _x, double _y, double _z): p(_x, _y, _z)
 {
 }
 
-Vertex::Vertex(const Coordinate &_p) : p(_p)
+Vertex::Vertex(const Coordinate& _p) : p(_p)
 {
 }
 
-Vertex::Vertex() : p() {
+Vertex::Vertex() : p()
+{
 }
 
-int Vertex::classify(const Vertex &p0, const Vertex &p1)
+int
+Vertex::classify(const Vertex& p0, const Vertex& p1)
 {
-	Vertex &p2 = *this;
-	std::unique_ptr<Vertex> a = p1.sub(p0);
-	std::unique_ptr<Vertex> b = p2.sub(p0);
-	double sa = a->crossProduct(*b);
-
-	if (sa > 0.0)
-		return LEFT;
-	if (sa < 0.0)
-		return RIGHT;
-	if ((a->getX() * b->getX() < 0.0) || (a->getY() * b->getY() < 0.0))
-		return BEHIND;
-	if (a->magn() < b->magn())
-		return BEYOND;
-	if (p0.equals(p2))
-		return ORIGIN;
-	if (p1.equals(p2))
-		return DESTINATION;
-	else
-		return BETWEEN;
+    Vertex& p2 = *this;
+    std::unique_ptr<Vertex> a = p1.sub(p0);
+    std::unique_ptr<Vertex> b = p2.sub(p0);
+    double sa = a->crossProduct(*b);
+
+    if(sa > 0.0) {
+        return LEFT;
+    }
+    if(sa < 0.0) {
+        return RIGHT;
+    }
+    if((a->getX() * b->getX() < 0.0) || (a->getY() * b->getY() < 0.0)) {
+        return BEHIND;
+    }
+    if(a->magn() < b->magn()) {
+        return BEYOND;
+    }
+    if(p0.equals(p2)) {
+        return ORIGIN;
+    }
+    if(p1.equals(p2)) {
+        return DESTINATION;
+    }
+    else {
+        return BETWEEN;
+    }
 }
 
-bool Vertex::isInCircle(const Vertex &a, const Vertex &b, const Vertex &c) const
+bool
+Vertex::isInCircle(const Vertex& a, const Vertex& b, const Vertex& c) const
 {
-	return TrianglePredicate::isInCircleRobust(a.p, b.p, c.p, this->p);
-	// non-robust - best to not use
-	//return TrianglePredicate.isInCircle(a.p, b.p, c.p, this->p);
+    return TrianglePredicate::isInCircleRobust(a.p, b.p, c.p, this->p);
+    // non-robust - best to not use
+    //return TrianglePredicate.isInCircle(a.p, b.p, c.p, this->p);
 }
 
-bool Vertex::rightOf(const QuadEdge &e) const {
-	return isCCW(e.dest(), e.orig());
+bool
+Vertex::rightOf(const QuadEdge& e) const
+{
+    return isCCW(e.dest(), e.orig());
 }
 
-bool Vertex::leftOf(const QuadEdge &e) const {
-	return isCCW(e.orig(), e.dest());
+bool
+Vertex::leftOf(const QuadEdge& e) const
+{
+    return isCCW(e.orig(), e.dest());
 }
 
-std::unique_ptr<HCoordinate> Vertex::bisector(const Vertex &a, const Vertex &b)
+std::unique_ptr<HCoordinate>
+Vertex::bisector(const Vertex& a, const Vertex& b)
 {
-	// returns the perpendicular bisector of the line segment ab
-	double dx = b.getX() - a.getX();
-	double dy = b.getY() - a.getY();
-	HCoordinate l1 = HCoordinate(a.getX() + dx / 2.0, a.getY() + dy / 2.0, 1.0);
-	HCoordinate l2 = HCoordinate(a.getX() - dy + dx / 2.0, a.getY() + dx + dy / 2.0, 1.0);
+    // returns the perpendicular bisector of the line segment ab
+    double dx = b.getX() - a.getX();
+    double dy = b.getY() - a.getY();
+    HCoordinate l1 = HCoordinate(a.getX() + dx / 2.0, a.getY() + dy / 2.0, 1.0);
+    HCoordinate l2 = HCoordinate(a.getX() - dy + dx / 2.0, a.getY() + dx + dy / 2.0, 1.0);
 
-	return std::unique_ptr<HCoordinate>(new HCoordinate(l1, l2));
+    return std::unique_ptr<HCoordinate>(new HCoordinate(l1, l2));
 }
 
-double Vertex::circumRadiusRatio(const Vertex &b, const Vertex &c)
+double
+Vertex::circumRadiusRatio(const Vertex& b, const Vertex& c)
 {
-	std::unique_ptr<Vertex> x(circleCenter(b, c));
-	double radius = distance(*x, b);
-	double edgeLength = distance(*this, b);
-	double el = distance(b, c);
-	if (el < edgeLength)
-	{
-		edgeLength = el;
-	}
-	el = distance(c, *this);
-	if (el < edgeLength)
-	{
-		edgeLength = el;
-	}
-
-	return radius / edgeLength;
+    std::unique_ptr<Vertex> x(circleCenter(b, c));
+    double radius = distance(*x, b);
+    double edgeLength = distance(*this, b);
+    double el = distance(b, c);
+    if(el < edgeLength) {
+        edgeLength = el;
+    }
+    el = distance(c, *this);
+    if(el < edgeLength) {
+        edgeLength = el;
+    }
+
+    return radius / edgeLength;
 }
 
-std::unique_ptr<Vertex> Vertex::midPoint(const Vertex &a)
+std::unique_ptr<Vertex>
+Vertex::midPoint(const Vertex& a)
 {
-	double xm = (p.x + a.getX()) / 2.0;
-	double ym = (p.y + a.getY()) / 2.0;
-	double zm = (p.z + a.getZ()) / 2.0;
-	return std::unique_ptr<Vertex>(new Vertex(xm, ym, zm));
+    double xm = (p.x + a.getX()) / 2.0;
+    double ym = (p.y + a.getY()) / 2.0;
+    double zm = (p.z + a.getZ()) / 2.0;
+    return std::unique_ptr<Vertex>(new Vertex(xm, ym, zm));
 }
 
-std::unique_ptr<Vertex> Vertex::circleCenter(const Vertex &b, const Vertex &c) const
+std::unique_ptr<Vertex>
+Vertex::circleCenter(const Vertex& b, const Vertex& c) const
 {
-	std::unique_ptr<Vertex> a(new Vertex(getX(), getY()));
-	// compute the perpendicular bisector of cord ab
-	std::unique_ptr<HCoordinate> cab = bisector(*a, b);
-	// compute the perpendicular bisector of cord bc
-	std::unique_ptr<HCoordinate> cbc = bisector(b, c);
-	// compute the intersection of the bisectors (circle radii)
-	std::unique_ptr<HCoordinate> hcc(new HCoordinate(*cab, *cbc));
-	std::unique_ptr<Vertex> cc;
-
-	try
-	{
-		cc.reset(new Vertex(hcc->getX(), hcc->getY()));
-	} catch (NotRepresentableException nre) {
-	}
-
-	return cc;
+    std::unique_ptr<Vertex> a(new Vertex(getX(), getY()));
+    // compute the perpendicular bisector of cord ab
+    std::unique_ptr<HCoordinate> cab = bisector(*a, b);
+    // compute the perpendicular bisector of cord bc
+    std::unique_ptr<HCoordinate> cbc = bisector(b, c);
+    // compute the intersection of the bisectors (circle radii)
+    std::unique_ptr<HCoordinate> hcc(new HCoordinate(*cab, *cbc));
+    std::unique_ptr<Vertex> cc;
+
+    try {
+        cc.reset(new Vertex(hcc->getX(), hcc->getY()));
+    }
+    catch(NotRepresentableException nre) {
+    }
+
+    return cc;
 }
 
-double Vertex::interpolateZValue(const Vertex &v0, const Vertex &v1,
-		const Vertex &v2) const
+double
+Vertex::interpolateZValue(const Vertex& v0, const Vertex& v1,
+                          const Vertex& v2) const
 {
-	double x0 = v0.getX();
-	double y0 = v0.getY();
-	double a = v1.getX() - x0;
-	double b = v2.getX() - x0;
-	double c = v1.getY() - y0;
-	double d = v2.getY() - y0;
-	double det = a * d - b * c;
-	double dx = this->getX() - x0;
-	double dy = this->getY() - y0;
-	double t = (d * dx - b * dy) / det;
-	double u = (-c * dx + a * dy) / det;
-	double z = v0.getZ() + t * (v1.getZ() - v0.getZ()) + u * (v2.getZ() - v0.getZ());
-	return z;
+    double x0 = v0.getX();
+    double y0 = v0.getY();
+    double a = v1.getX() - x0;
+    double b = v2.getX() - x0;
+    double c = v1.getY() - y0;
+    double d = v2.getY() - y0;
+    double det = a * d - b * c;
+    double dx = this->getX() - x0;
+    double dy = this->getY() - y0;
+    double t = (d * dx - b * dy) / det;
+    double u = (-c * dx + a * dy) / det;
+    double z = v0.getZ() + t * (v1.getZ() - v0.getZ()) + u * (v2.getZ() - v0.getZ());
+    return z;
 }
 
-double Vertex::interpolateZ(const Coordinate &p, const Coordinate &v0,
-		const Coordinate &v1, const Coordinate &v2)
+double
+Vertex::interpolateZ(const Coordinate& p, const Coordinate& v0,
+                     const Coordinate& v1, const Coordinate& v2)
 {
-	double x0 = v0.x;
-	double y0 = v0.y;
-	double a = v1.x - x0;
-	double b = v2.x - x0;
-	double c = v1.y - y0;
-	double d = v2.y - y0;
-	double det = a * d - b * c;
-	double dx = p.x - x0;
-	double dy = p.y - y0;
-	double t = (d * dx - b * dy) / det;
-	double u = (-c * dx + a * dy) / det;
-	double z = v0.z + t * (v1.z - v0.z) + u * (v2.z - v0.z);
-	return z;
+    double x0 = v0.x;
+    double y0 = v0.y;
+    double a = v1.x - x0;
+    double b = v2.x - x0;
+    double c = v1.y - y0;
+    double d = v2.y - y0;
+    double det = a * d - b * c;
+    double dx = p.x - x0;
+    double dy = p.y - y0;
+    double t = (d * dx - b * dy) / det;
+    double u = (-c * dx + a * dy) / det;
+    double z = v0.z + t * (v1.z - v0.z) + u * (v2.z - v0.z);
+    return z;
 }
 
-double Vertex::interpolateZ(const Coordinate &p, const Coordinate &p0,
-		const Coordinate &p1)
+double
+Vertex::interpolateZ(const Coordinate& p, const Coordinate& p0,
+                     const Coordinate& p1)
 {
-	double segLen = p0.distance(p1);
-	double ptLen = p.distance(p0);
-	double dz = p1.z - p0.z;
-	double pz = p0.z + dz * (ptLen / segLen);
-	return pz;
+    double segLen = p0.distance(p1);
+    double ptLen = p.distance(p0);
+    double dz = p1.z - p0.z;
+    double pz = p0.z + dz * (ptLen / segLen);
+    return pz;
 }
 
 } //namespace geos.triangulate.quadedge
diff --git a/src/util/Assert.cpp b/src/util/Assert.cpp
index 8240377..4fbf2d6 100644
--- a/src/util/Assert.cpp
+++ b/src/util/Assert.cpp
@@ -27,29 +27,32 @@ namespace util { // geos.util
 void
 Assert::isTrue(bool assertion, const string& message)
 {
-	if (!assertion) {
-		if (message.empty()) {
-			throw  AssertionFailedException();
-		} else {
-			throw  AssertionFailedException(message);
-		}
-	}
+    if(!assertion) {
+        if(message.empty()) {
+            throw  AssertionFailedException();
+        }
+        else {
+            throw  AssertionFailedException(message);
+        }
+    }
 }
 
 void
 Assert::equals(const Coordinate& expectedValue,
-		const Coordinate& actualValue, const string& message)
+               const Coordinate& actualValue, const string& message)
 {
-	if (!(actualValue==expectedValue)) {
-		throw  AssertionFailedException("Expected " + expectedValue.toString() + " but encountered "
-			+ actualValue.toString() + (!message.empty() ? ": " + message : ""));
-	}
+    if(!(actualValue == expectedValue)) {
+        throw  AssertionFailedException("Expected " + expectedValue.toString() + " but encountered "
+                                        + actualValue.toString() + (!message.empty() ? ": " + message : ""));
+    }
 }
 
 
-void Assert::shouldNeverReachHere(const string& message) {
-	throw  AssertionFailedException("Should never reach here"
-		+ (!message.empty() ? ": " + message : ""));
+void
+Assert::shouldNeverReachHere(const string& message)
+{
+    throw  AssertionFailedException("Should never reach here"
+                                    + (!message.empty() ? ": " + message : ""));
 }
 
 } // namespace geos.util
diff --git a/src/util/GeometricShapeFactory.cpp b/src/util/GeometricShapeFactory.cpp
index bfc80f7..bf5ba29 100644
--- a/src/util/GeometricShapeFactory.cpp
+++ b/src/util/GeometricShapeFactory.cpp
@@ -37,234 +37,239 @@ namespace geos {
 namespace util { // geos.util
 
 GeometricShapeFactory::GeometricShapeFactory(const GeometryFactory* factory)
-	:
-	geomFact(factory),
-	precModel(factory->getPrecisionModel()),
-	nPts(100)
+    :
+    geomFact(factory),
+    precModel(factory->getPrecisionModel()),
+    nPts(100)
 {
 }
 
 void
 GeometricShapeFactory::setBase(const Coordinate& base)
 {
-	dim.setBase(base);
+    dim.setBase(base);
 }
 
 void
 GeometricShapeFactory::setCentre(const Coordinate& centre)
 {
-	dim.setCentre(centre);
+    dim.setCentre(centre);
 }
 
 void
 GeometricShapeFactory::setNumPoints(int nNPts)
 {
-	nPts=nNPts;
+    nPts = nNPts;
 }
 
 void
 GeometricShapeFactory::setSize(double size)
 {
-	dim.setSize(size);
+    dim.setSize(size);
 }
 
 void
 GeometricShapeFactory::setWidth(double width)
 {
-	dim.setWidth(width);
+    dim.setWidth(width);
 }
 
 void
 GeometricShapeFactory::setHeight(double height)
 {
-	dim.setHeight(height);
+    dim.setHeight(height);
 }
 
 Polygon*
 GeometricShapeFactory::createRectangle()
 {
-	int i;
-	int ipt = 0;
-	int nSide = nPts / 4;
-	if (nSide < 1) nSide = 1;
-	std::unique_ptr<Envelope> env ( dim.getEnvelope() );
-	double XsegLen = env->getWidth() / nSide;
-	double YsegLen = env->getHeight() / nSide;
-
-	vector<Coordinate> *vc = new vector<Coordinate>(4*nSide+1);
-	//CoordinateSequence* pts=new CoordinateArraySequence(4*nSide+1);
-
-	for (i = 0; i < nSide; i++) {
-		double x = env->getMinX() + i * XsegLen;
-		double y = env->getMinY();
-		(*vc)[ipt++] = coord(x, y);
-	}
-	for (i = 0; i < nSide; i++) {
-		double x = env->getMaxX();
-		double y = env->getMinY() + i * YsegLen;
-		(*vc)[ipt++] = coord(x, y);
-	}
-	for (i = 0; i < nSide; i++) {
-		double x = env->getMaxX() - i * XsegLen;
-		double y = env->getMaxY();
-		(*vc)[ipt++] = coord(x, y);
-	}
-	for (i = 0; i < nSide; i++) {
-		double x = env->getMinX();
-		double y = env->getMaxY() - i * YsegLen;
-		(*vc)[ipt++] = coord(x, y);
-	}
-	(*vc)[ipt++] = (*vc)[0];
-	CoordinateSequence *cs = geomFact->getCoordinateSequenceFactory()->create(vc);
-	LinearRing* ring=geomFact->createLinearRing(cs);
-	Polygon* poly=geomFact->createPolygon(ring, nullptr);
-	return poly;
+    int i;
+    int ipt = 0;
+    int nSide = nPts / 4;
+    if(nSide < 1) {
+        nSide = 1;
+    }
+    std::unique_ptr<Envelope> env(dim.getEnvelope());
+    double XsegLen = env->getWidth() / nSide;
+    double YsegLen = env->getHeight() / nSide;
+
+    vector<Coordinate>* vc = new vector<Coordinate>(4 * nSide + 1);
+    //CoordinateSequence* pts=new CoordinateArraySequence(4*nSide+1);
+
+    for(i = 0; i < nSide; i++) {
+        double x = env->getMinX() + i * XsegLen;
+        double y = env->getMinY();
+        (*vc)[ipt++] = coord(x, y);
+    }
+    for(i = 0; i < nSide; i++) {
+        double x = env->getMaxX();
+        double y = env->getMinY() + i * YsegLen;
+        (*vc)[ipt++] = coord(x, y);
+    }
+    for(i = 0; i < nSide; i++) {
+        double x = env->getMaxX() - i * XsegLen;
+        double y = env->getMaxY();
+        (*vc)[ipt++] = coord(x, y);
+    }
+    for(i = 0; i < nSide; i++) {
+        double x = env->getMinX();
+        double y = env->getMaxY() - i * YsegLen;
+        (*vc)[ipt++] = coord(x, y);
+    }
+    (*vc)[ipt++] = (*vc)[0];
+    CoordinateSequence* cs = geomFact->getCoordinateSequenceFactory()->create(vc);
+    LinearRing* ring = geomFact->createLinearRing(cs);
+    Polygon* poly = geomFact->createPolygon(ring, nullptr);
+    return poly;
 }
 
 Polygon*
 GeometricShapeFactory::createCircle()
 {
-	std::unique_ptr<Envelope> env ( dim.getEnvelope() );
-	double xRadius = env->getWidth() / 2.0;
-	double yRadius = env->getHeight() / 2.0;
-
-	double centreX = env->getMinX() + xRadius;
-	double centreY = env->getMinY() + yRadius;
-	env.reset();
-
-	vector<Coordinate>*pts=new vector<Coordinate>(nPts+1);
-	int iPt = 0;
-	for (int i = 0; i < nPts; i++) {
-		double ang = i * (2 * 3.14159265358979 / nPts);
-		double x = xRadius * cos(ang) + centreX;
-		double y = yRadius * sin(ang) + centreY;
-		(*pts)[iPt++] = coord(x, y);
-	}
-	(*pts)[iPt++] = (*pts)[0];
-	CoordinateSequence *cs=geomFact->getCoordinateSequenceFactory()->create(pts);
-	LinearRing* ring = geomFact->createLinearRing(cs);
-	Polygon* poly=geomFact->createPolygon(ring,nullptr);
-	return poly;
+    std::unique_ptr<Envelope> env(dim.getEnvelope());
+    double xRadius = env->getWidth() / 2.0;
+    double yRadius = env->getHeight() / 2.0;
+
+    double centreX = env->getMinX() + xRadius;
+    double centreY = env->getMinY() + yRadius;
+    env.reset();
+
+    vector<Coordinate>* pts = new vector<Coordinate>(nPts + 1);
+    int iPt = 0;
+    for(int i = 0; i < nPts; i++) {
+        double ang = i * (2 * 3.14159265358979 / nPts);
+        double x = xRadius * cos(ang) + centreX;
+        double y = yRadius * sin(ang) + centreY;
+        (*pts)[iPt++] = coord(x, y);
+    }
+    (*pts)[iPt++] = (*pts)[0];
+    CoordinateSequence* cs = geomFact->getCoordinateSequenceFactory()->create(pts);
+    LinearRing* ring = geomFact->createLinearRing(cs);
+    Polygon* poly = geomFact->createPolygon(ring, nullptr);
+    return poly;
 }
 
 LineString*
 GeometricShapeFactory::createArc(double startAng, double angExtent)
 {
-	std::unique_ptr<Envelope> env ( dim.getEnvelope() );
-	double xRadius = env->getWidth() / 2.0;
-	double yRadius = env->getHeight() / 2.0;
-
-	double centreX = env->getMinX() + xRadius;
-	double centreY = env->getMinY() + yRadius;
-	env.reset();
-
-	double angSize = angExtent;
-	if (angSize <= 0.0 || angSize > 2 * M_PI)
-		angSize = 2 * M_PI;
-	double angInc = angSize / ( nPts - 1 );
-
-	vector<Coordinate> *pts = new vector<Coordinate>(nPts);
-	int iPt = 0;
-	for (int i = 0; i < nPts; i++) {
-		double ang = startAng + i * angInc;
-		double x = xRadius * cos(ang) + centreX;
-		double y = yRadius * sin(ang) + centreY;
-		(*pts)[iPt++] = coord(x, y);
-	}
-	CoordinateSequence *cs = geomFact->getCoordinateSequenceFactory()->create(pts);
-	LineString* line = geomFact->createLineString(cs);
-	return line;
+    std::unique_ptr<Envelope> env(dim.getEnvelope());
+    double xRadius = env->getWidth() / 2.0;
+    double yRadius = env->getHeight() / 2.0;
+
+    double centreX = env->getMinX() + xRadius;
+    double centreY = env->getMinY() + yRadius;
+    env.reset();
+
+    double angSize = angExtent;
+    if(angSize <= 0.0 || angSize > 2 * M_PI) {
+        angSize = 2 * M_PI;
+    }
+    double angInc = angSize / (nPts - 1);
+
+    vector<Coordinate>* pts = new vector<Coordinate>(nPts);
+    int iPt = 0;
+    for(int i = 0; i < nPts; i++) {
+        double ang = startAng + i * angInc;
+        double x = xRadius * cos(ang) + centreX;
+        double y = yRadius * sin(ang) + centreY;
+        (*pts)[iPt++] = coord(x, y);
+    }
+    CoordinateSequence* cs = geomFact->getCoordinateSequenceFactory()->create(pts);
+    LineString* line = geomFact->createLineString(cs);
+    return line;
 }
 
 Polygon*
 GeometricShapeFactory::createArcPolygon(double startAng, double angExtent)
 {
-	std::unique_ptr<Envelope> env ( dim.getEnvelope() );
-	double xRadius = env->getWidth() / 2.0;
-	double yRadius = env->getHeight() / 2.0;
-
-	double centreX = env->getMinX() + xRadius;
-	double centreY = env->getMinY() + yRadius;
-	env.reset();
-
-	double angSize = angExtent;
-	if (angSize <= 0.0 || angSize > 2 * M_PI)
-		angSize = 2 * M_PI;
-	double angInc = angSize / ( nPts - 1 );
-
-	vector<Coordinate> *pts = new vector<Coordinate>(nPts + 2);
-	int iPt = 0;
-	(*pts)[iPt++] = coord(centreX, centreY);
-	for (int i = 0; i < nPts; i++) {
-		double ang = startAng + i * angInc;
-		double x = xRadius * cos(ang) + centreX;
-		double y = yRadius * sin(ang) + centreY;
-		(*pts)[iPt++] = coord(x, y);
-	}
-	(*pts)[iPt++] = coord(centreX, centreY);
-
-	CoordinateSequence *cs = geomFact->getCoordinateSequenceFactory()->create(pts);
-	LinearRing* ring = geomFact->createLinearRing(cs);
-	Polygon* geom = geomFact->createPolygon(ring, nullptr);
-	return geom;
+    std::unique_ptr<Envelope> env(dim.getEnvelope());
+    double xRadius = env->getWidth() / 2.0;
+    double yRadius = env->getHeight() / 2.0;
+
+    double centreX = env->getMinX() + xRadius;
+    double centreY = env->getMinY() + yRadius;
+    env.reset();
+
+    double angSize = angExtent;
+    if(angSize <= 0.0 || angSize > 2 * M_PI) {
+        angSize = 2 * M_PI;
+    }
+    double angInc = angSize / (nPts - 1);
+
+    vector<Coordinate>* pts = new vector<Coordinate>(nPts + 2);
+    int iPt = 0;
+    (*pts)[iPt++] = coord(centreX, centreY);
+    for(int i = 0; i < nPts; i++) {
+        double ang = startAng + i * angInc;
+        double x = xRadius * cos(ang) + centreX;
+        double y = yRadius * sin(ang) + centreY;
+        (*pts)[iPt++] = coord(x, y);
+    }
+    (*pts)[iPt++] = coord(centreX, centreY);
+
+    CoordinateSequence* cs = geomFact->getCoordinateSequenceFactory()->create(pts);
+    LinearRing* ring = geomFact->createLinearRing(cs);
+    Polygon* geom = geomFact->createPolygon(ring, nullptr);
+    return geom;
 }
 
 GeometricShapeFactory::Dimensions::Dimensions()
-	:
-	base(Coordinate::getNull()),
-	centre(Coordinate::getNull())
+    :
+    base(Coordinate::getNull()),
+    centre(Coordinate::getNull())
 {
 }
 
 void
 GeometricShapeFactory::Dimensions::setBase(const Coordinate& newBase)
 {
-	base=newBase;
+    base = newBase;
 }
 
 void
 GeometricShapeFactory::Dimensions::setCentre(const Coordinate& newCentre)
 {
-	centre=newCentre;
+    centre = newCentre;
 }
 
 void
 GeometricShapeFactory::Dimensions::setSize(double size)
 {
-	height = size;
-	width = size;
+    height = size;
+    width = size;
 }
 
 void
 GeometricShapeFactory::Dimensions::setWidth(double nWidth)
 {
-	width=nWidth;
+    width = nWidth;
 }
 
-void GeometricShapeFactory::Dimensions::setHeight(double nHeight)
+void
+GeometricShapeFactory::Dimensions::setHeight(double nHeight)
 {
-	height=nHeight;
+    height = nHeight;
 }
 
 Envelope*
 GeometricShapeFactory::Dimensions::getEnvelope() const
 {
-	if (!base.isNull()) {
-		return new Envelope(base.x, base.x + width, base.y, base.y + height);
-	}
-	if (!centre.isNull()) {
-		return new Envelope(centre.x - width/2, centre.x + width/2,centre.y - height/2, centre.y + height/2);
-	}
-	return new Envelope(0, width, 0, height);
+    if(!base.isNull()) {
+        return new Envelope(base.x, base.x + width, base.y, base.y + height);
+    }
+    if(!centre.isNull()) {
+        return new Envelope(centre.x - width / 2, centre.x + width / 2, centre.y - height / 2, centre.y + height / 2);
+    }
+    return new Envelope(0, width, 0, height);
 }
 
 /*protected*/
 Coordinate
 GeometricShapeFactory::coord(double x, double y) const
 {
-	Coordinate ret(x, y);
-	precModel->makePrecise(&ret);
-	return ret;
+    Coordinate ret(x, y);
+    precModel->makePrecise(&ret);
+    return ret;
 }
 
 } // namespace geos.util
diff --git a/src/util/Interrupt.cpp b/src/util/Interrupt.cpp
index 01b0c2c..0bc9882 100644
--- a/src/util/Interrupt.cpp
+++ b/src/util/Interrupt.cpp
@@ -16,10 +16,10 @@
 #include <geos/util/GEOSException.h> // for inheritance
 
 namespace {
-  /* Could these be portably stored in thread-specific space ? */
-  bool requested = false;
+/* Could these be portably stored in thread-specific space ? */
+bool requested = false;
 
-  geos::util::Interrupt::Callback *callback = nullptr;
+geos::util::Interrupt::Callback* callback = nullptr;
 }
 
 namespace geos {
@@ -31,21 +31,39 @@ public:
         GEOSException("InterruptedException", "Interrupted!") {}
 };
 
-void Interrupt::request() { requested = true; }
+void
+Interrupt::request()
+{
+    requested = true;
+}
 
-void Interrupt::cancel() { requested = false; }
+void
+Interrupt::cancel()
+{
+    requested = false;
+}
 
-bool Interrupt::check() { return requested; }
+bool
+Interrupt::check()
+{
+    return requested;
+}
 
-Interrupt::Callback* Interrupt::registerCallback(Interrupt::Callback *cb) {
+Interrupt::Callback*
+Interrupt::registerCallback(Interrupt::Callback* cb)
+{
     Callback* prev = callback;
     callback = cb;
     return prev;
-  }
+}
 
-void Interrupt::process() {
-    if ( callback ) (*callback)();
-    if ( requested ) {
+void
+Interrupt::process()
+{
+    if(callback) {
+        (*callback)();
+    }
+    if(requested) {
         requested = false;
         interrupt();
     }
@@ -53,9 +71,10 @@ void Interrupt::process() {
 
 
 void
-Interrupt::interrupt() {
-  requested = false;
-  throw InterruptedException();
+Interrupt::interrupt()
+{
+    requested = false;
+    throw InterruptedException();
 }
 
 
diff --git a/src/util/Profiler.cpp b/src/util/Profiler.cpp
index 9b85f0f..f3b7ca2 100644
--- a/src/util/Profiler.cpp
+++ b/src/util/Profiler.cpp
@@ -25,9 +25,9 @@ namespace util { // geos.util
 
 Profile::Profile(string newname)
 {
-	name = newname;
-	totaltime = 0;
-	min = max = avg = 0;
+    name = newname;
+    totaltime = 0;
+    min = max = avg = 0;
 }
 
 Profile::~Profile()
@@ -37,31 +37,31 @@ Profile::~Profile()
 double
 Profile::getMax() const
 {
-	return max;
+    return max;
 }
 
 double
 Profile::getMin() const
 {
-	return min;
+    return min;
 }
 
 double
 Profile::getAvg() const
 {
-	return avg;
+    return avg;
 }
 
 double
 Profile::getTot() const
 {
-	return totaltime;
+    return totaltime;
 }
 
 size_t
 Profile::getNumTimings() const
 {
-	return timings.size();
+    return timings.size();
 }
 
 Profiler::Profiler()
@@ -70,72 +70,71 @@ Profiler::Profiler()
 
 Profiler::~Profiler()
 {
-	map<string, Profile *>::const_iterator it;
-	for ( it=profs.begin(); it != profs.end(); ++it )
-	{
-		delete it->second;
-	}
+    map<string, Profile*>::const_iterator it;
+    for(it = profs.begin(); it != profs.end(); ++it) {
+        delete it->second;
+    }
 }
 
 void
 Profiler::start(string name)
 {
-	Profile *prof = get(name);
-	prof->start();
+    Profile* prof = get(name);
+    prof->start();
 }
 
 void
 Profiler::stop(string name)
 {
-	map<string, Profile *>::iterator iter = profs.find(name);
-	if ( iter == profs.end() ) {
-		cerr<<name<<": no such Profile started";
-		return;
-	}
-	iter->second->stop();
+    map<string, Profile*>::iterator iter = profs.find(name);
+    if(iter == profs.end()) {
+        cerr << name << ": no such Profile started";
+        return;
+    }
+    iter->second->stop();
 }
 
-Profile *
+Profile*
 Profiler::get(string name)
 {
-	Profile *prof;
-	map<string, Profile *>::iterator iter = profs.find(name);
-	if ( iter == profs.end() ) {
-		prof = new Profile(name);
-		profs.insert(pair<string, Profile *>(name, prof));
-	} else {
-		prof = iter->second;
-	}
-	return prof;
+    Profile* prof;
+    map<string, Profile*>::iterator iter = profs.find(name);
+    if(iter == profs.end()) {
+        prof = new Profile(name);
+        profs.insert(pair<string, Profile*>(name, prof));
+    }
+    else {
+        prof = iter->second;
+    }
+    return prof;
 }
 
-Profiler *
+Profiler*
 Profiler::instance()
 {
-	static Profiler internal_profiler;
-	return &internal_profiler;
+    static Profiler internal_profiler;
+    return &internal_profiler;
 }
 
 
 ostream&
-operator<< (ostream &os, const Profile &prof)
+operator<< (ostream& os, const Profile& prof)
 {
-	os << " num:"<<prof.getNumTimings()<<" min:"<<
-		prof.getMin()<<" max:"<<prof.getMax()<<
-		" avg:"<<prof.getAvg()<<" tot:"<<prof.getTot()<<
-		" ["<<prof.name<<"]";
-	return os;
+    os << " num:" << prof.getNumTimings() << " min:" <<
+       prof.getMin() << " max:" << prof.getMax() <<
+       " avg:" << prof.getAvg() << " tot:" << prof.getTot() <<
+       " [" << prof.name << "]";
+    return os;
 }
 
 ostream&
-operator<< (ostream &os, const Profiler &prof)
+operator<< (ostream& os, const Profiler& prof)
 {
-	map<string, Profile *>::const_iterator it;
-	for ( it=prof.profs.begin(); it != prof.profs.end(); ++it )
-	{
-		os<<*(it->second)<<endl;
-	}
-	return os;
+    map<string, Profile*>::const_iterator it;
+    for(it = prof.profs.begin(); it != prof.profs.end(); ++it) {
+        os << *(it->second) << endl;
+    }
+    return os;
 }
 
 
diff --git a/src/util/math.cpp b/src/util/math.cpp
index 2c5e417..3931dc3 100644
--- a/src/util/math.cpp
+++ b/src/util/math.cpp
@@ -24,53 +24,63 @@ namespace util { // geos.util
 double
 sym_round(double val)
 {
-        double n;
-        double f = std::fabs(std::modf(val, &n));
-        if (val >= 0) {
-                if (f < 0.5) {
-                        return std::floor(val);
-                } else if (f > 0.5) {
-                        return std::ceil(val);
-                } else {
-                        return (n + 1.0);
-                }
-        } else {
-                if (f < 0.5) {
-                        return std::ceil(val);
-                } else if (f > 0.5) {
-                        return std::floor(val);
-                } else {
-                        return (n - 1.0);
-                }
+    double n;
+    double f = std::fabs(std::modf(val, &n));
+    if(val >= 0) {
+        if(f < 0.5) {
+            return std::floor(val);
         }
+        else if(f > 0.5) {
+            return std::ceil(val);
+        }
+        else {
+            return (n + 1.0);
+        }
+    }
+    else {
+        if(f < 0.5) {
+            return std::ceil(val);
+        }
+        else if(f > 0.5) {
+            return std::floor(val);
+        }
+        else {
+            return (n - 1.0);
+        }
+    }
 }
 
 /*
  * Asymmetric Rounding Algorithm  - equivalent to Java Math.round()
  */
-double java_math_round(double val)
+double
+java_math_round(double val)
 {
-	double n;
-	double f = std::fabs(std::modf(val, &n));
+    double n;
+    double f = std::fabs(std::modf(val, &n));
 
-	if (val >= 0)
-	{
-		if (f < 0.5) {
-			return std::floor(val);
-		} else if (f > 0.5) {
-			return std::ceil(val);
-		} else {
-			return (n + 1.0);
-		}
-	} else {
-		if (f < 0.5) {
-			return std::ceil(val);
-		} else if (f > 0.5) {
-			return std::floor(val);
-		} else {
-			return n;
-		}
-	}
+    if(val >= 0) {
+        if(f < 0.5) {
+            return std::floor(val);
+        }
+        else if(f > 0.5) {
+            return std::ceil(val);
+        }
+        else {
+            return (n + 1.0);
+        }
+    }
+    else {
+        if(f < 0.5) {
+            return std::ceil(val);
+        }
+        else if(f > 0.5) {
+            return std::floor(val);
+        }
+        else {
+            return n;
+        }
+    }
 } // java_math_round
 
 /*
@@ -79,25 +89,30 @@ double java_math_round(double val)
 double
 rint_vc(double val)
 {
-	double n;
-	double f=std::fabs(std::modf(val,&n));
-	if (val>=0) {
-		if (f<0.5) {
-			return std::floor(val);
-		} else if (f>0.5) {
-			return std::ceil(val);
-		} else {
-			return(std::floor(n/2)==n/2)?n:n+1.0;
-		}
-	} else {
-		if (f<0.5) {
-			return std::ceil(val);
-		} else if (f>0.5) {
-			return std::floor(val);
-		} else {
-			return(std::floor(n/2)==n/2)?n:n-1.0;
-		}
-	}
+    double n;
+    double f = std::fabs(std::modf(val, &n));
+    if(val >= 0) {
+        if(f < 0.5) {
+            return std::floor(val);
+        }
+        else if(f > 0.5) {
+            return std::ceil(val);
+        }
+        else {
+            return(std::floor(n / 2) == n / 2) ? n : n + 1.0;
+        }
+    }
+    else {
+        if(f < 0.5) {
+            return std::ceil(val);
+        }
+        else if(f > 0.5) {
+            return std::floor(val);
+        }
+        else {
+            return(std::floor(n / 2) == n / 2) ? n : n - 1.0;
+        }
+    }
 }
 
 } // namespace geos.util
diff --git a/tests/bigtest/GeometryTestFactory.cpp b/tests/bigtest/GeometryTestFactory.cpp
index 7989dfc..59907dd 100644
--- a/tests/bigtest/GeometryTestFactory.cpp
+++ b/tests/bigtest/GeometryTestFactory.cpp
@@ -23,110 +23,127 @@
 
 using namespace geos::geom;
 
-Polygon* GeometryTestFactory::createBox(GeometryFactory *fact,double minx,double miny,int nSide,double segLen) {
-	CoordinateSequence *pts=createBox(minx, miny, nSide, segLen);
-    return fact->createPolygon(fact->createLinearRing(pts),nullptr);
+Polygon*
+GeometryTestFactory::createBox(GeometryFactory* fact, double minx, double miny, int nSide, double segLen)
+{
+    CoordinateSequence* pts = createBox(minx, miny, nSide, segLen);
+    return fact->createPolygon(fact->createLinearRing(pts), nullptr);
 }
 
-CoordinateSequence* GeometryTestFactory::createBox(double minx, double miny,int nSide,double segLen) {
-	int i;
-	CoordinateSequence *pts=new CoordinateArraySequence();
-	double maxx=minx+nSide*segLen;
-	double maxy=miny+nSide*segLen;
-
-	for(i=0;i<nSide;i++) {
-		double x=minx+i*segLen;
-		double y=miny;
-		pts->add(Coordinate(x,y));
-	}
-	for(i=0;i<nSide;i++) {
-		double x=maxx;
-		double y=miny+i*segLen;
-		pts->add(Coordinate(x,y));
-	}
-	for(i=0;i<nSide;i++) {
-		double x=maxx-i*segLen;
-		double y=maxy;
-		pts->add(Coordinate(x,y));
-	}
-	for(i=0;i<nSide;i++) {
-		double x=minx;
-		double y=maxy-i*segLen;
-		pts->add(Coordinate(x,y));
-	}
-	pts->add(pts->getAt(0));
-	return pts;
+CoordinateSequence*
+GeometryTestFactory::createBox(double minx, double miny, int nSide, double segLen)
+{
+    int i;
+    CoordinateSequence* pts = new CoordinateArraySequence();
+    double maxx = minx + nSide * segLen;
+    double maxy = miny + nSide * segLen;
+
+    for(i = 0; i < nSide; i++) {
+        double x = minx + i * segLen;
+        double y = miny;
+        pts->add(Coordinate(x, y));
+    }
+    for(i = 0; i < nSide; i++) {
+        double x = maxx;
+        double y = miny + i * segLen;
+        pts->add(Coordinate(x, y));
+    }
+    for(i = 0; i < nSide; i++) {
+        double x = maxx - i * segLen;
+        double y = maxy;
+        pts->add(Coordinate(x, y));
+    }
+    for(i = 0; i < nSide; i++) {
+        double x = minx;
+        double y = maxy - i * segLen;
+        pts->add(Coordinate(x, y));
+    }
+    pts->add(pts->getAt(0));
+    return pts;
 }
 
-	/**
-	* Creates a circle
-	* @param x the centre x coord
-	* @param y the centre y coord
-	* @param size the size of the envelope of the star
-	* @param nPts the number of points in the star
-	*/
-CoordinateSequence* GeometryTestFactory::createCircle(double basex,double basey,double size,int nPts) {
-	CoordinateSequence *pts=new CoordinateArraySequence(nPts+1);
-	double len=size/2.0;
-
-	for(int i=0;i<nPts;i++) {
-		double ang=i*(2*PI/nPts);
-		double x=len*cos(ang)+basex;
-		double y=len*sin(ang)+basey;
-		pts->add(Coordinate(x,y));
-	}
-	pts->add(Coordinate(pts->getAt(0)));
-	return pts;
+/**
+* Creates a circle
+* @param x the centre x coord
+* @param y the centre y coord
+* @param size the size of the envelope of the star
+* @param nPts the number of points in the star
+*/
+CoordinateSequence*
+GeometryTestFactory::createCircle(double basex, double basey, double size, int nPts)
+{
+    CoordinateSequence* pts = new CoordinateArraySequence(nPts + 1);
+    double len = size / 2.0;
+
+    for(int i = 0; i < nPts; i++) {
+        double ang = i * (2 * PI / nPts);
+        double x = len * cos(ang) + basex;
+        double y = len * sin(ang) + basey;
+        pts->add(Coordinate(x, y));
+    }
+    pts->add(Coordinate(pts->getAt(0)));
+    return pts;
 }
 
-Polygon* GeometryTestFactory::createCircle(GeometryFactory *fact,double basex,double basey,double size,int nPts) {
-	CoordinateSequence *pts=createCircle(basex, basey, size, nPts);
-    return fact->createPolygon(fact->createLinearRing(pts),nullptr);
+Polygon*
+GeometryTestFactory::createCircle(GeometryFactory* fact, double basex, double basey, double size, int nPts)
+{
+    CoordinateSequence* pts = createCircle(basex, basey, size, nPts);
+    return fact->createPolygon(fact->createLinearRing(pts), nullptr);
 }
 
-	/**
-	* Creates a star from a "circular" sine wave
-	* @param basex the centre x coord
-	* @param basey the centre y coord
-	* @param size the size of the envelope of the star
-	* @param armLen the length of an arm of the star
-	* @param nArms the number of arms of the star
-	* @param nPts the number of points in the star
-	*/
-CoordinateSequence* GeometryTestFactory::createSineStar(double basex,double basey,double size,double armLen,int nArms,int nPts) {
-	double armBaseLen=size/2-armLen;
-	if (armBaseLen<0) armBaseLen=0.5;
-
-	double angInc=2*PI/nArms;
-	int nArmPt=nPts/nArms;
-	if (nArmPt<5) nArmPt=5;
-
-	//int nPts2=nArmPt*nArms;
-	CoordinateSequence *pts=new CoordinateArraySequence();
-
-	double starAng=0.0;
-
-	for(int iArm=0;iArm<nArms;iArm++) {
-		for(int iArmPt=0;iArmPt<nArmPt;iArmPt++) {
-			double ang=iArmPt*(2*PI/nArmPt);
-			double len=armLen*(1-cos(ang)/2)+armBaseLen;
-			double x=len*cos(starAng+iArmPt*angInc/nArmPt)+basex;
-			double y=len*sin(starAng+iArmPt*angInc/nArmPt)+basey;
+/**
+* Creates a star from a "circular" sine wave
+* @param basex the centre x coord
+* @param basey the centre y coord
+* @param size the size of the envelope of the star
+* @param armLen the length of an arm of the star
+* @param nArms the number of arms of the star
+* @param nPts the number of points in the star
+*/
+CoordinateSequence*
+GeometryTestFactory::createSineStar(double basex, double basey, double size, double armLen, int nArms, int nPts)
+{
+    double armBaseLen = size / 2 - armLen;
+    if(armBaseLen < 0) {
+        armBaseLen = 0.5;
+    }
+
+    double angInc = 2 * PI / nArms;
+    int nArmPt = nPts / nArms;
+    if(nArmPt < 5) {
+        nArmPt = 5;
+    }
+
+    //int nPts2=nArmPt*nArms;
+    CoordinateSequence* pts = new CoordinateArraySequence();
+
+    double starAng = 0.0;
+
+    for(int iArm = 0; iArm < nArms; iArm++) {
+        for(int iArmPt = 0; iArmPt < nArmPt; iArmPt++) {
+            double ang = iArmPt * (2 * PI / nArmPt);
+            double len = armLen * (1 - cos(ang) / 2) + armBaseLen;
+            double x = len * cos(starAng + iArmPt * angInc / nArmPt) + basex;
+            double y = len * sin(starAng + iArmPt * angInc / nArmPt) + basey;
 
             // FIXME - mloskot: Number of problems here:
             // - new'd Coordinate definitely leaks
             // - add() method makes a copy
             // - why temporarily used Coordinate is allocated on the heap?!?
-			pts->add(*(new Coordinate(x,y)));
-		}
-		starAng+=angInc;
-	}
+            pts->add(*(new Coordinate(x, y)));
+        }
+        starAng += angInc;
+    }
     // FIXME - mloskot: The same problems as above
-	pts->add(*(new Coordinate(pts->getAt(0))));
-	return pts;
+    pts->add(*(new Coordinate(pts->getAt(0))));
+    return pts;
 }
 
-Polygon* GeometryTestFactory::createSineStar(GeometryFactory *fact,double basex,double basey,double size,double armLen,int nArms,int nPts){
-	CoordinateSequence *pts=createSineStar(basex, basey, size, armLen, nArms, nPts);
-	return fact->createPolygon(fact->createLinearRing(pts),nullptr);
+Polygon*
+GeometryTestFactory::createSineStar(GeometryFactory* fact, double basex, double basey, double size, double armLen,
+                                    int nArms, int nPts)
+{
+    CoordinateSequence* pts = createSineStar(basex, basey, size, armLen, nArms, nPts);
+    return fact->createPolygon(fact->createLinearRing(pts), nullptr);
 }
diff --git a/tests/bigtest/TestSweepLineSpeed.cpp b/tests/bigtest/TestSweepLineSpeed.cpp
index f4b02f0..2a418d4 100644
--- a/tests/bigtest/TestSweepLineSpeed.cpp
+++ b/tests/bigtest/TestSweepLineSpeed.cpp
@@ -32,45 +32,49 @@ using namespace geos::geom;
  * of the sweepline intersection detection algorithm
 */
 
-void run(int nPts, GeometryFactory *fact) {
-	clock_t startTime, endTime;
-	double size=100.0;
-	double armLen=50.0;
-	int nArms=10;
-	Polygon *poly=GeometryTestFactory::createSineStar(fact,0.0,0.0,size,armLen,nArms,nPts);
-	Polygon *box=GeometryTestFactory::createSineStar(fact,0.0,size/2,size,armLen,nArms,nPts);
+void
+run(int nPts, GeometryFactory* fact)
+{
+    clock_t startTime, endTime;
+    double size = 100.0;
+    double armLen = 50.0;
+    int nArms = 10;
+    Polygon* poly = GeometryTestFactory::createSineStar(fact, 0.0, 0.0, size, armLen, nArms, nPts);
+    Polygon* box = GeometryTestFactory::createSineStar(fact, 0.0, size / 2, size, armLen, nArms, nPts);
     //Polygon *box=GeometryTestFactory::createBox(fact,0,0,1,100.0);
 
-	startTime=clock();
+    startTime = clock();
     poly->intersects(box);
-    endTime=clock();
-	double totalTime=(double)(endTime-startTime);
-	printf( "n Pts: %i  Executed in %6.0f ms.\n",nPts,totalTime);
+    endTime = clock();
+    double totalTime = (double)(endTime - startTime);
+    printf("n Pts: %i  Executed in %6.0f ms.\n", nPts, totalTime);
     //cout << "n Pts: " << nPts << "   Executed in " << totalTime << endl;
 
     // FIXME - mloskot: Why generated test geometries are not destroyed?"
 }
 
-int main(int /* argc */, char** /* argv[] */) {
+int
+main(int /* argc */, char** /* argv[] */)
+{
 
-	GeometryFactory::Ptr factptr = GeometryFactory::create();
-	GeometryFactory* fact = factptr.get();
+    GeometryFactory::Ptr factptr = GeometryFactory::create();
+    GeometryFactory* fact = factptr.get();
 
-	run(1000,fact);
-	run(2000,fact);
-	run(4000,fact);
-	run(8000,fact);
-	run(16000,fact);
-	run(32000,fact);
-	run(64000,fact);
-	run(128000,fact);
-	run(256000,fact);
-	run(512000,fact);
-	run(1024000,fact);
+    run(1000, fact);
+    run(2000, fact);
+    run(4000, fact);
+    run(8000, fact);
+    run(16000, fact);
+    run(32000, fact);
+    run(64000, fact);
+    run(128000, fact);
+    run(256000, fact);
+    run(512000, fact);
+    run(1024000, fact);
 
 //	_CrtDumpMemoryLeaks();
 
-	cout << "Done" << endl;
+    cout << "Done" << endl;
 
-	return 0;
+    return 0;
 }
diff --git a/tests/bigtest/bigtest.h b/tests/bigtest/bigtest.h
index 01eb662..dcc2924 100644
--- a/tests/bigtest/bigtest.h
+++ b/tests/bigtest/bigtest.h
@@ -24,21 +24,23 @@ using namespace geos;
 
 // Forward declaration
 namespace geos {
-	namespace geom {
-		class Polygon;
-		class CoordinateSequence;
-		class GeometryFactory;
-	}
+namespace geom {
+class Polygon;
+class CoordinateSequence;
+class GeometryFactory;
+}
 }
 
 class GeometryTestFactory {
 public:
-	static geom::Polygon* createBox(geom::GeometryFactory *fact,double minx,double miny,int nSide,double segLen);
-	static geom::CoordinateSequence* createBox(double minx,double miny,int nSide,double segLen);
-	static geom::CoordinateSequence* createCircle(double basex,double basey,double size,int nPts);
-	static geom::Polygon* createCircle(geom::GeometryFactory *fact,double basex,double basey,double size,int nPts);
-	static geom::CoordinateSequence* createSineStar(double basex,double basey,double size,double armLen,int nArms,int nPts);
-	static geom::Polygon* createSineStar(geom::GeometryFactory *fact,double basex,double basey,double size,double armLen,int nArms,int nPts);
+    static geom::Polygon* createBox(geom::GeometryFactory* fact, double minx, double miny, int nSide, double segLen);
+    static geom::CoordinateSequence* createBox(double minx, double miny, int nSide, double segLen);
+    static geom::CoordinateSequence* createCircle(double basex, double basey, double size, int nPts);
+    static geom::Polygon* createCircle(geom::GeometryFactory* fact, double basex, double basey, double size, int nPts);
+    static geom::CoordinateSequence* createSineStar(double basex, double basey, double size, double armLen, int nArms,
+            int nPts);
+    static geom::Polygon* createSineStar(geom::GeometryFactory* fact, double basex, double basey, double size,
+                                         double armLen, int nArms, int nPts);
 };
 
 #endif
diff --git a/tests/bigtest/bug234.cpp b/tests/bigtest/bug234.cpp
index 6a2d0b1..79b75e8 100644
--- a/tests/bigtest/bug234.cpp
+++ b/tests/bigtest/bug234.cpp
@@ -11,39 +11,41 @@
 using namespace geos::geom;
 using namespace std;
 
-int main() {
- GeometryFactory::Ptr factory = GeometryFactory::create();
-
- vector< Geometry * > *polys1 = new vector<Geometry*>();
- vector< Geometry * > *polys2 = new vector<Geometry*>();
- vector< Geometry * > *holes1 = new vector<Geometry*>();
-
- CoordinateArraySequence coords1;
- coords1.add(Coordinate(1, 1));
- coords1.add(Coordinate(1, 5));
- coords1.add(Coordinate(5, 5));
- coords1.add(Coordinate(5, 1));
- coords1.add(Coordinate(1, 1));
- holes1->push_back( factory->createLinearRing() );
- polys1->push_back( factory->createPolygon(factory->createLinearRing(coords1), holes1) );
-
- CoordinateArraySequence coords2;
- coords2.add(Coordinate(3, 3));
- coords2.add(Coordinate(3, 4));
- coords2.add(Coordinate(4, 4));
- coords2.add(Coordinate(4, 3));
- coords2.add(Coordinate(3, 3));
- polys2->push_back( factory->createPolygon(factory->createLinearRing(coords2), new vector<Geometry*>) );
-
- MultiPolygon *mpoly1 = factory->createMultiPolygon(polys1);
- MultiPolygon *mpoly2 = factory->createMultiPolygon(polys2);
-
- cout << "      Mpoly1: " << mpoly1->toString() << endl;
- cout << "      Mpoly2: " << mpoly2->toString() << endl;
- Geometry *intersection = mpoly1->intersection(mpoly2);
- cout << "Intersection: " << intersection->toString() << endl;
-
- delete mpoly1;
- delete mpoly2;
- delete intersection;
+int
+main()
+{
+    GeometryFactory::Ptr factory = GeometryFactory::create();
+
+    vector< Geometry* >* polys1 = new vector<Geometry*>();
+    vector< Geometry* >* polys2 = new vector<Geometry*>();
+    vector< Geometry* >* holes1 = new vector<Geometry*>();
+
+    CoordinateArraySequence coords1;
+    coords1.add(Coordinate(1, 1));
+    coords1.add(Coordinate(1, 5));
+    coords1.add(Coordinate(5, 5));
+    coords1.add(Coordinate(5, 1));
+    coords1.add(Coordinate(1, 1));
+    holes1->push_back(factory->createLinearRing());
+    polys1->push_back(factory->createPolygon(factory->createLinearRing(coords1), holes1));
+
+    CoordinateArraySequence coords2;
+    coords2.add(Coordinate(3, 3));
+    coords2.add(Coordinate(3, 4));
+    coords2.add(Coordinate(4, 4));
+    coords2.add(Coordinate(4, 3));
+    coords2.add(Coordinate(3, 3));
+    polys2->push_back(factory->createPolygon(factory->createLinearRing(coords2), new vector<Geometry*>));
+
+    MultiPolygon* mpoly1 = factory->createMultiPolygon(polys1);
+    MultiPolygon* mpoly2 = factory->createMultiPolygon(polys2);
+
+    cout << "      Mpoly1: " << mpoly1->toString() << endl;
+    cout << "      Mpoly2: " << mpoly2->toString() << endl;
+    Geometry* intersection = mpoly1->intersection(mpoly2);
+    cout << "Intersection: " << intersection->toString() << endl;
+
+    delete mpoly1;
+    delete mpoly2;
+    delete intersection;
 }
diff --git a/tests/perf/ClassSizes.cpp b/tests/perf/ClassSizes.cpp
index 09ab4a9..63a211b 100644
--- a/tests/perf/ClassSizes.cpp
+++ b/tests/perf/ClassSizes.cpp
@@ -37,10 +37,10 @@ using namespace geos;
 int
 main()
 {
-	check(geomgraph::PlanarGraph);
-	check(geomgraph::EdgeEnd);
-	check(geomgraph::DirectedEdge);
-	check(noding::NodedSegmentString);
-	check(int64);
+    check(geomgraph::PlanarGraph);
+    check(geomgraph::EdgeEnd);
+    check(geomgraph::DirectedEdge);
+    check(noding::NodedSegmentString);
+    check(int64);
 }
 
diff --git a/tests/perf/operation/buffer/IteratedBufferStressTest.cpp b/tests/perf/operation/buffer/IteratedBufferStressTest.cpp
index 06e5710..52910f3 100644
--- a/tests/perf/operation/buffer/IteratedBufferStressTest.cpp
+++ b/tests/perf/operation/buffer/IteratedBufferStressTest.cpp
@@ -32,54 +32,59 @@ using namespace std;
 
 typedef unique_ptr<Geometry> GeomPtr;
 
-GeomPtr doBuffer(const Geometry& g, double dist)
+GeomPtr
+doBuffer(const Geometry& g, double dist)
 {
- cout << "Buffering with dist = " << dist << endl;
- GeomPtr buf ( g.buffer(dist) );
- cout << "Buffer result has " <<  buf->getNumPoints() << " vertices" << endl;
+    cout << "Buffering with dist = " << dist << endl;
+    GeomPtr buf(g.buffer(dist));
+    cout << "Buffer result has " <<  buf->getNumPoints() << " vertices" << endl;
 
- //cout << *buf << endl;
+//cout << *buf << endl;
 
- return buf;
+    return buf;
 }
 
 // throws Exception
-void run(const Geometry* base)
+void
+run(const Geometry* base)
 {
-	GeomPtr tmp;
+    GeomPtr tmp;
 
-	// profile here
-	geos::util::Profile totalSW("buffer");
-	double dist = 1.0;
-	while (true) {
+    // profile here
+    geos::util::Profile totalSW("buffer");
+    double dist = 1.0;
+    while(true) {
 
-		totalSW.start();
+        totalSW.start();
 
-		GeomPtr b1 = doBuffer(*base, dist);
-		GeomPtr b2 = doBuffer(*b1, -dist);
+        GeomPtr b1 = doBuffer(*base, dist);
+        GeomPtr b2 = doBuffer(*b1, -dist);
 
-		totalSW.stop();
-		cout << "----------------------  "
-		     << totalSW << endl; // totalSW.getTimeString() << endl;
+        totalSW.stop();
+        cout << "----------------------  "
+             << totalSW << endl; // totalSW.getTimeString() << endl;
 
-		dist += 1;
-		base = b2.get(); tmp = std::move(b2); // move as anti-optimisation?
+        dist += 1;
+        base = b2.get();
+        tmp = std::move(b2); // move as anti-optimisation?
 
-		if ( ! base->getNumPoints() ) break;
-	}
+        if(! base->getNumPoints()) {
+            break;
+        }
+    }
 }
 
 int
 main()
 {
-	PrecisionModel pm;
-	GeometryFactory::Ptr gf = GeometryFactory::create(&pm);
-	WKTReader rdr(gf.get());
+    PrecisionModel pm;
+    GeometryFactory::Ptr gf = GeometryFactory::create(&pm);
+    WKTReader rdr(gf.get());
 
-	string inputWKT =
+    string inputWKT =
         "POLYGON ((110 320, 190 220, 60 200, 180 120, 120 40, 290 150, 410 40, 410 230, 500 340, 320 310, 260 370, 220 310, 110 320), (220 260, 250 180, 290 220, 360 150, 350 250, 260 280, 220 260))";
 
-        GeomPtr base ( rdr.read(inputWKT) );
-	run(base.get());
+    GeomPtr base(rdr.read(inputWKT));
+    run(base.get());
 }
 
diff --git a/tests/perf/operation/predicate/RectangleIntersectsPerfTest.cpp b/tests/perf/operation/predicate/RectangleIntersectsPerfTest.cpp
index 2b54a2e..5dcf9b2 100644
--- a/tests/perf/operation/predicate/RectangleIntersectsPerfTest.cpp
+++ b/tests/perf/operation/predicate/RectangleIntersectsPerfTest.cpp
@@ -35,113 +35,119 @@ using namespace geos::geom;
 using namespace geos::io;
 using namespace std;
 
-class RectangleIntersectsPerfTest
-{
+class RectangleIntersectsPerfTest {
 public:
-  RectangleIntersectsPerfTest()
-    :
-    pm(),
-    fact(GeometryFactory::create(&pm, 0))
-  {}
-
-  void test(int nPts)
-  {
-    double size = 100;
-    Coordinate origin(0, 0);
-    Geometry::Ptr sinePoly (
-      createSineStar(origin, size, nPts)->getBoundary()
-    );
-
-    /**
-     * Make the geometry "crinkly" by rounding off the points.
-     * This defeats the  MonotoneChain optimization in the full relate
-     * algorithm, and provides a more realistic test.
-     */
-    using geos::precision::SimpleGeometryPrecisionReducer;
-    PrecisionModel p_pm(size/10);
-    SimpleGeometryPrecisionReducer reducer(&p_pm);
-    Geometry::Ptr sinePolyCrinkly ( reducer.reduce(sinePoly.get()) );
-    sinePoly.reset();
-
-    Geometry& target = *sinePolyCrinkly;
-
-    testRectangles(target, 30, 5);
-  }
+    RectangleIntersectsPerfTest()
+        :
+        pm(),
+        fact(GeometryFactory::create(&pm, 0))
+    {}
+
+    void
+    test(int nPts)
+    {
+        double size = 100;
+        Coordinate origin(0, 0);
+        Geometry::Ptr sinePoly(
+            createSineStar(origin, size, nPts)->getBoundary()
+        );
+
+        /**
+         * Make the geometry "crinkly" by rounding off the points.
+         * This defeats the  MonotoneChain optimization in the full relate
+         * algorithm, and provides a more realistic test.
+         */
+        using geos::precision::SimpleGeometryPrecisionReducer;
+        PrecisionModel p_pm(size / 10);
+        SimpleGeometryPrecisionReducer reducer(&p_pm);
+        Geometry::Ptr sinePolyCrinkly(reducer.reduce(sinePoly.get()));
+        sinePoly.reset();
+
+        Geometry& target = *sinePolyCrinkly;
+
+        testRectangles(target, 30, 5);
+    }
 
 
 private:
 
-  static const int MAX_ITER = 10;
-
-  static const int NUM_AOI_PTS = 2000;
-  static const int NUM_LINES = 5000;
-  static const int NUM_LINE_PTS = 1000;
+    static const int MAX_ITER = 10;
+
+    static const int NUM_AOI_PTS = 2000;
+    static const int NUM_LINES = 5000;
+    static const int NUM_LINE_PTS = 1000;
+
+    PrecisionModel pm;
+    GeometryFactory::Ptr fact;
+
+    void
+    testRectangles(const Geometry& target, int nRect, double rectSize)
+    {
+        vector<const Geometry*> rects;
+        createRectangles(*target.getEnvelopeInternal(), nRect, rectSize, rects);
+        test(rects, target);
+        for(vector<const Geometry*>::iterator i = rects.begin(), n = rects.end();
+                i != n; ++i) {
+            delete *i;
+        }
+    }
 
-  PrecisionModel pm;
-  GeometryFactory::Ptr fact;
+    void
+    test(vector<const Geometry*>& rect, const Geometry& g)
+    {
+        typedef vector<const Geometry*>::size_type size_type;
 
-  void testRectangles(const Geometry& target, int nRect, double rectSize)
-  {
-    vector<const Geometry*> rects;
-    createRectangles(*target.getEnvelopeInternal(), nRect, rectSize, rects);
-    test(rects, target);
-    for (vector<const Geometry*>::iterator i=rects.begin(), n=rects.end();
-      i!=n; ++i) delete *i;
-  }
+        geos::util::Profile sw("");
+        sw.start();
 
-  void test(vector<const Geometry*>& rect, const Geometry& g)
-  {
-    typedef vector<const Geometry*>::size_type size_type;
+        for(int i = 0; i < MAX_ITER; i++) {
+            for(size_type j = 0; j < rect.size(); j++) {
+                rect[j]->intersects(&g);
+            }
+        }
 
-    geos::util::Profile sw("");
-		sw.start();
+        sw.stop();
+        cout << g.getNumPoints() << " points: " << sw.getTot() << " usecs" << endl;
 
-    for (int i = 0; i < MAX_ITER; i++) {
-      for (size_type j = 0; j < rect.size(); j++) {
-        rect[j]->intersects(&g);
-      }
     }
 
-		sw.stop();
-		cout << g.getNumPoints() << " points: " << sw.getTot() << " usecs" << endl;
-
-  }
-
-  // Push newly created geoms to rectLit
-  void createRectangles(const Envelope& env, int nRect, double,
-                        vector<const Geometry*>& rectList)
-  {
-    int nSide =  1 + (int)sqrt((double) nRect);
-    double dx = env.getWidth() / nSide;
-    double dy = env.getHeight() / nSide;
-
-    for (int i = 0; i < nSide; i++) {
-      for (int j = 0; j < nSide; j++) {
-        double baseX = env.getMinX() + i * dx;
-        double baseY = env.getMinY() + j * dy;
-        Envelope envRect(
-            baseX, baseX + dx,
-            baseY, baseY + dy);
-        Geometry* rect = fact->toGeometry(&envRect);
-        rectList.push_back(rect);
-      }
+    // Push newly created geoms to rectLit
+    void
+    createRectangles(const Envelope& env, int nRect, double,
+                     vector<const Geometry*>& rectList)
+    {
+        int nSide =  1 + (int)sqrt((double) nRect);
+        double dx = env.getWidth() / nSide;
+        double dy = env.getHeight() / nSide;
+
+        for(int i = 0; i < nSide; i++) {
+            for(int j = 0; j < nSide; j++) {
+                double baseX = env.getMinX() + i * dx;
+                double baseY = env.getMinY() + j * dy;
+                Envelope envRect(
+                    baseX, baseX + dx,
+                    baseY, baseY + dy);
+                Geometry* rect = fact->toGeometry(&envRect);
+                rectList.push_back(rect);
+            }
+        }
     }
-  }
-
-  Polygon::Ptr createSineStar(const Coordinate& origin,
-                                    double size, int nPts)
-  {
-      using geos::geom::util::SineStarFactory;
 
-      SineStarFactory gsf(fact.get());
-      gsf.setCentre(origin);
-      gsf.setSize(size);
-      gsf.setNumPoints(nPts);
-      gsf.setArmLengthRatio(2);
-      gsf.setNumArms(20);
-      Polygon::Ptr poly = gsf.createSineStar();
-      return poly;
-  }
+    Polygon::Ptr
+    createSineStar(const Coordinate& origin,
+                   double size, int nPts)
+    {
+        using geos::geom::util::SineStarFactory;
+
+        SineStarFactory gsf(fact.get());
+        gsf.setCentre(origin);
+        gsf.setSize(size);
+        gsf.setNumPoints(nPts);
+        gsf.setArmLengthRatio(2);
+        gsf.setNumArms(20);
+        Polygon::Ptr poly = gsf.createSineStar();
+        return poly;
+    }
 
 
 };
@@ -150,9 +156,9 @@ int
 main()
 {
 
-  RectangleIntersectsPerfTest tester;
+    RectangleIntersectsPerfTest tester;
 
-  tester.test(500);
-  tester.test(100000);
+    tester.test(500);
+    tester.test(100000);
 }
 
diff --git a/tests/unit/algorithm/AngleTest.cpp b/tests/unit/algorithm/AngleTest.cpp
index c3ce1c9..2858b30 100644
--- a/tests/unit/algorithm/AngleTest.cpp
+++ b/tests/unit/algorithm/AngleTest.cpp
@@ -11,116 +11,119 @@
 #include <string>
 #include <memory>
 
-namespace tut
-{
-	//
-	// Test Group
-	//
+namespace tut {
+//
+// Test Group
+//
 
-	// dummy data, not used
-	struct test_angle_data {
+// dummy data, not used
+struct test_angle_data {
     typedef geos::geom::Coordinate Coordinate;
     typedef geos::algorithm::Angle Angle;
 
     double TOL;
-	  double PI;
+    double PI;
 
-	  test_angle_data()
-      :
-      TOL (1e-5),
-	    PI  ( 3.14159265358979323846 )
+    test_angle_data()
+        :
+        TOL(1e-5),
+        PI(3.14159265358979323846)
     {}
 
-	};
-
-	typedef test_group<test_angle_data> group;
-	typedef group::object object;
-
-	group test_angle_group("geos::algorithm::Angle");
-
-	//
-	// Test Cases
-	//
-
-	// testAngle()
-	template<>
-	template<>
-	void object::test<1>()
-	{
-    ensure_equals("1", Angle::angle(Coordinate(10,0)), 0.0, TOL);
-    ensure_equals("2", Angle::angle(Coordinate(10,10)), PI/4, TOL);
-    ensure_equals("3", Angle::angle(Coordinate(0,10)), PI/2, TOL);
-    ensure_equals("4", Angle::angle(Coordinate(-10,10)), 0.75*PI, TOL);
-    ensure_equals("5", Angle::angle(Coordinate(-10,0)), PI, TOL);
-    ensure_equals("6", Angle::angle(Coordinate(-10,-0.1)), -3.131592987, TOL);
-    ensure_equals("7", Angle::angle(Coordinate(-10,-10)), -0.75*PI, TOL);
-	}
-
-	// testIsAcute()
-	template<>
-	template<>
-	void object::test<2>()
-	{
+};
+
+typedef test_group<test_angle_data> group;
+typedef group::object object;
+
+group test_angle_group("geos::algorithm::Angle");
+
+//
+// Test Cases
+//
+
+// testAngle()
+template<>
+template<>
+void object::test<1>
+()
+{
+    ensure_equals("1", Angle::angle(Coordinate(10, 0)), 0.0, TOL);
+    ensure_equals("2", Angle::angle(Coordinate(10, 10)), PI / 4, TOL);
+    ensure_equals("3", Angle::angle(Coordinate(0, 10)), PI / 2, TOL);
+    ensure_equals("4", Angle::angle(Coordinate(-10, 10)), 0.75 * PI, TOL);
+    ensure_equals("5", Angle::angle(Coordinate(-10, 0)), PI, TOL);
+    ensure_equals("6", Angle::angle(Coordinate(-10, -0.1)), -3.131592987, TOL);
+    ensure_equals("7", Angle::angle(Coordinate(-10, -10)), -0.75 * PI, TOL);
+}
+
+// testIsAcute()
+template<>
+template<>
+void object::test<2>
+()
+{
     ensure(Angle::isAcute(
-      Coordinate(10,0), Coordinate(0,0), Coordinate(5,10)));
+               Coordinate(10, 0), Coordinate(0, 0), Coordinate(5, 10)));
     ensure(Angle::isAcute(
-      Coordinate(10,0), Coordinate(0,0), Coordinate(5,-10)));
+               Coordinate(10, 0), Coordinate(0, 0), Coordinate(5, -10)));
     // angle of 0
     ensure(Angle::isAcute(
-      Coordinate(10,0), Coordinate(0,0), Coordinate(10,0)));
+               Coordinate(10, 0), Coordinate(0, 0), Coordinate(10, 0)));
     ensure_not(Angle::isAcute(
-      Coordinate(10,0), Coordinate(0,0), Coordinate(-5,10)));
+                   Coordinate(10, 0), Coordinate(0, 0), Coordinate(-5, 10)));
     ensure_not(Angle::isAcute(
-      Coordinate(10,0), Coordinate(0,0), Coordinate(-5,-10)));
-	}
-
-	// testNormalizePositive()
-	template<>
-	template<>
-	void object::test<3>()
-	{
+                   Coordinate(10, 0), Coordinate(0, 0), Coordinate(-5, -10)));
+}
+
+// testNormalizePositive()
+template<>
+template<>
+void object::test<3>
+()
+{
     ensure_equals("", Angle::normalizePositive(0.0), 0.0, TOL);
 
-    ensure_equals("", Angle::normalizePositive(-0.5*PI), 1.5*PI, TOL);
+    ensure_equals("", Angle::normalizePositive(-0.5 * PI), 1.5 * PI, TOL);
     ensure_equals("", Angle::normalizePositive(-PI), PI, TOL);
-    ensure_equals("", Angle::normalizePositive(-1.5*PI), .5*PI, TOL);
-    ensure_equals("", Angle::normalizePositive(-2*PI), 0.0, TOL);
-    ensure_equals("", Angle::normalizePositive(-2.5*PI), 1.5*PI, TOL);
-    ensure_equals("", Angle::normalizePositive(-3*PI), PI, TOL);
+    ensure_equals("", Angle::normalizePositive(-1.5 * PI), .5 * PI, TOL);
+    ensure_equals("", Angle::normalizePositive(-2 * PI), 0.0, TOL);
+    ensure_equals("", Angle::normalizePositive(-2.5 * PI), 1.5 * PI, TOL);
+    ensure_equals("", Angle::normalizePositive(-3 * PI), PI, TOL);
     ensure_equals("", Angle::normalizePositive(-4 * PI), 0.0, TOL);
 
-    ensure_equals("", Angle::normalizePositive(0.5*PI), 0.5*PI, TOL);
+    ensure_equals("", Angle::normalizePositive(0.5 * PI), 0.5 * PI, TOL);
     ensure_equals("", Angle::normalizePositive(PI), PI, TOL);
-    ensure_equals("", Angle::normalizePositive(1.5*PI), 1.5*PI, TOL);
-    ensure_equals("", Angle::normalizePositive(2*PI), 0.0, TOL);
-    ensure_equals("", Angle::normalizePositive(2.5*PI), 0.5*PI, TOL);
-    ensure_equals("", Angle::normalizePositive(3*PI), PI, TOL);
+    ensure_equals("", Angle::normalizePositive(1.5 * PI), 1.5 * PI, TOL);
+    ensure_equals("", Angle::normalizePositive(2 * PI), 0.0, TOL);
+    ensure_equals("", Angle::normalizePositive(2.5 * PI), 0.5 * PI, TOL);
+    ensure_equals("", Angle::normalizePositive(3 * PI), PI, TOL);
     ensure_equals("", Angle::normalizePositive(4 * PI), 0.0, TOL);
-	}
+}
 
-	// testNormalize()
-	template<>
-	template<>
-	void object::test<4>()
-	{
+// testNormalize()
+template<>
+template<>
+void object::test<4>
+()
+{
     ensure_equals("1", Angle::normalize(0.0), 0.0, TOL);
 
-    ensure_equals("2", Angle::normalize(-0.5*PI), -0.5*PI, TOL);
+    ensure_equals("2", Angle::normalize(-0.5 * PI), -0.5 * PI, TOL);
     ensure_equals("3", Angle::normalize(-PI), PI, TOL);
-    ensure_equals("4", Angle::normalize(-1.5*PI), .5*PI, TOL);
-    ensure_equals("5", Angle::normalize(-2*PI), 0.0, TOL);
-    ensure_equals("6", Angle::normalize(-2.5*PI), -0.5*PI, TOL);
-    ensure_equals("7", Angle::normalize(-3*PI), PI, TOL);
+    ensure_equals("4", Angle::normalize(-1.5 * PI), .5 * PI, TOL);
+    ensure_equals("5", Angle::normalize(-2 * PI), 0.0, TOL);
+    ensure_equals("6", Angle::normalize(-2.5 * PI), -0.5 * PI, TOL);
+    ensure_equals("7", Angle::normalize(-3 * PI), PI, TOL);
     ensure_equals("8", Angle::normalize(-4 * PI), 0.0, TOL);
 
-    ensure_equals("9", Angle::normalize(0.5*PI), 0.5*PI, TOL);
+    ensure_equals("9", Angle::normalize(0.5 * PI), 0.5 * PI, TOL);
     ensure_equals("10", Angle::normalize(PI), PI, TOL);
-    ensure_equals("11", Angle::normalize(1.5*PI), -0.5*PI, TOL);
-    ensure_equals("12", Angle::normalize(2*PI), 0.0, TOL);
-    ensure_equals("13", Angle::normalize(2.5*PI), 0.5*PI, TOL);
-    ensure_equals("14", Angle::normalize(3*PI), PI, TOL);
+    ensure_equals("11", Angle::normalize(1.5 * PI), -0.5 * PI, TOL);
+    ensure_equals("12", Angle::normalize(2 * PI), 0.0, TOL);
+    ensure_equals("13", Angle::normalize(2.5 * PI), 0.5 * PI, TOL);
+    ensure_equals("14", Angle::normalize(3 * PI), PI, TOL);
     ensure_equals("15", Angle::normalize(4 * PI), 0.0, TOL);
-	}
+}
 
 
 
diff --git a/tests/unit/algorithm/AreaTest.cpp b/tests/unit/algorithm/AreaTest.cpp
index bc8cc65..843335f 100644
--- a/tests/unit/algorithm/AreaTest.cpp
+++ b/tests/unit/algorithm/AreaTest.cpp
@@ -21,94 +21,100 @@
 using namespace geos;
 using namespace geos::geom;
 
-namespace tut
-{
-	//
-	// Test Group
-	//
-
-	// dummy data, not used
-	struct test_area_data {
-        geos::geom::Geometry *geom_;
-        geos::geom::PrecisionModel pm_;
-        geos::geom::GeometryFactory::Ptr factory_;
-        geos::io::WKTReader reader_;
-        test_area_data():
-            geom_(nullptr),
-            pm_(1),
-            factory_(GeometryFactory::create(&pm_, 0)), reader_(factory_.get())
-        {
-            assert(nullptr == geom_);
-        }
-
-        ~test_area_data()
-        {
-            factory_->destroyGeometry(geom_);
-            geom_ = nullptr;
-        }
-
-        void checkAreaOfRing(std::string wkt, double expectedArea) {
-            std::unique_ptr<Geometry> lineGeom(reader_.read(wkt));
-            std::unique_ptr<LineString> line(dynamic_cast<LineString*>(lineGeom.release()));
-            ensure(nullptr != line.get());
-            const CoordinateSequence *ringSeq = line->getCoordinatesRO();
-
-            std::vector<Coordinate> ringCoords;
-            ringSeq->toVector(ringCoords);
-
-            double actual1 = algorithm::Area::ofRing(ringCoords);
-            double actual2 = algorithm::Area::ofRing(ringSeq);
-
-            ensure_equals(actual1, expectedArea);
-            ensure_equals(actual2, expectedArea);
-        }
-
-        void checkAreaOfRingSigned(std::string wkt, double expectedArea) {
-            std::unique_ptr<Geometry> lineGeom(reader_.read(wkt));
-            std::unique_ptr<LineString> line(dynamic_cast<LineString*>(lineGeom.release()));
-            ensure(nullptr != line.get());
-            const CoordinateSequence *ringSeq = line->getCoordinatesRO();
-
-            std::vector<Coordinate> ringCoords;
-            ringSeq->toVector(ringCoords);
-
-            double actual1 = algorithm::Area::ofRingSigned(ringCoords);
-            double actual2 = algorithm::Area::ofRingSigned(ringSeq);
-
-            ensure_equals(actual1, expectedArea);
-            ensure_equals(actual2, expectedArea);
-        }
-    };
-
-    typedef test_group<test_area_data> group;
-    typedef group::object object;
-
-    group test_area_group("geos::algorithm::Area");
-
-
-    //
-    // Test Cases
-    //
-    template<>
-    template<>
-    void object::test<1>()
+namespace tut {
+//
+// Test Group
+//
+
+// dummy data, not used
+struct test_area_data {
+    geos::geom::Geometry* geom_;
+    geos::geom::PrecisionModel pm_;
+    geos::geom::GeometryFactory::Ptr factory_;
+    geos::io::WKTReader reader_;
+    test_area_data():
+        geom_(nullptr),
+        pm_(1),
+        factory_(GeometryFactory::create(&pm_, 0)), reader_(factory_.get())
+    {
+        assert(nullptr == geom_);
+    }
+
+    ~test_area_data()
     {
-        checkAreaOfRing("LINESTRING (100 200, 200 200, 200 100, 100 100, 100 200)", 10000.0);
+        factory_->destroyGeometry(geom_);
+        geom_ = nullptr;
     }
 
-    template<>
-    template<>
-    void object::test<2>()
+    void
+    checkAreaOfRing(std::string wkt, double expectedArea)
     {
-        checkAreaOfRingSigned("LINESTRING (100 200, 200 200, 200 100, 100 100, 100 200)", 10000.0);
+        std::unique_ptr<Geometry> lineGeom(reader_.read(wkt));
+        std::unique_ptr<LineString> line(dynamic_cast<LineString*>(lineGeom.release()));
+        ensure(nullptr != line.get());
+        const CoordinateSequence* ringSeq = line->getCoordinatesRO();
+
+        std::vector<Coordinate> ringCoords;
+        ringSeq->toVector(ringCoords);
+
+        double actual1 = algorithm::Area::ofRing(ringCoords);
+        double actual2 = algorithm::Area::ofRing(ringSeq);
+
+        ensure_equals(actual1, expectedArea);
+        ensure_equals(actual2, expectedArea);
     }
 
-    template<>
-    template<>
-    void object::test<3>()
+    void
+    checkAreaOfRingSigned(std::string wkt, double expectedArea)
     {
-        checkAreaOfRingSigned("LINESTRING (100 200, 100 100, 200 100, 200 200, 100 200)", -10000.0);
+        std::unique_ptr<Geometry> lineGeom(reader_.read(wkt));
+        std::unique_ptr<LineString> line(dynamic_cast<LineString*>(lineGeom.release()));
+        ensure(nullptr != line.get());
+        const CoordinateSequence* ringSeq = line->getCoordinatesRO();
+
+        std::vector<Coordinate> ringCoords;
+        ringSeq->toVector(ringCoords);
+
+        double actual1 = algorithm::Area::ofRingSigned(ringCoords);
+        double actual2 = algorithm::Area::ofRingSigned(ringSeq);
+
+        ensure_equals(actual1, expectedArea);
+        ensure_equals(actual2, expectedArea);
     }
+};
+
+typedef test_group<test_area_data> group;
+typedef group::object object;
+
+group test_area_group("geos::algorithm::Area");
+
+
+//
+// Test Cases
+//
+template<>
+template<>
+void object::test<1>
+()
+{
+    checkAreaOfRing("LINESTRING (100 200, 200 200, 200 100, 100 100, 100 200)", 10000.0);
+}
+
+template<>
+template<>
+void object::test<2>
+()
+{
+    checkAreaOfRingSigned("LINESTRING (100 200, 200 200, 200 100, 100 100, 100 200)", 10000.0);
+}
+
+template<>
+template<>
+void object::test<3>
+()
+{
+    checkAreaOfRingSigned("LINESTRING (100 200, 100 100, 200 100, 200 200, 100 200)", -10000.0);
+}
 
 
 } // namespace tut
diff --git a/tests/unit/algorithm/CGAlgorithms/computeOrientationTest.cpp b/tests/unit/algorithm/CGAlgorithms/computeOrientationTest.cpp
index 5590878..da8d076 100644
--- a/tests/unit/algorithm/CGAlgorithms/computeOrientationTest.cpp
+++ b/tests/unit/algorithm/CGAlgorithms/computeOrientationTest.cpp
@@ -19,94 +19,96 @@
 using namespace geos::geom;
 using namespace geos::algorithm;
 
-namespace tut
+namespace tut {
+//
+// Test Group
+//
+
+struct test_computeorientation_data {
+    geos::io::WKTReader reader_;
+
+    test_computeorientation_data() {}
+};
+
+typedef test_group<test_computeorientation_data> group;
+typedef group::object object;
+
+group test_computeorientation_group("geos::algorithm::Orientation::index");
+
+//
+// Test Cases
+//
+
+// 1 - Test CCW orientation
+template<>
+template<>
+void object::test<1>
+()
+{
+    const std::string wkt("LINESTRING ( 0 0, 0 1, 1 1)");
+    Geometry::Ptr geom(reader_.read(wkt));
+
+    CoordinateSequence::Ptr pts(geom->getCoordinates());
+
+    int const a = Orientation::index(pts->getAt(0), pts->getAt(1), pts->getAt(2));
+    int const b = Orientation::index(pts->getAt(0), pts->getAt(1), pts->getAt(2));
+    int const c = Orientation::index(pts->getAt(0), pts->getAt(1), pts->getAt(2));
+
+    ensure_equals(a, b);
+    ensure_equals(a, c);
+}
+
+// 2 - Test CCW orientation
+template<>
+template<>
+void object::test<2>
+()
+{
+    Coordinate c1(1.0000000000004998, -7.989685402102996);
+    Coordinate c2(10.0, -7.004368924503866);
+    Coordinate c3(1.0000000000005, -7.989685402102996);
+
+    CoordinateArraySequence pts;
+    pts.add(c1);
+    pts.add(c2);
+    pts.add(c3);
+
+    int const a = Orientation::index(pts[0], pts[1], pts[2]);
+    int const b = Orientation::index(pts[0], pts[1], pts[2]);
+    int const c = Orientation::index(pts[0], pts[1], pts[2]);
+
+    ensure_equals(a, b);
+    ensure_equals(a, c);
+}
+
+// 3 - Test orientation for the original JTS test case
+// jts/java/src/com/vividsolutions/jts/algorithm/RobustDeterminant.java, r626
+// http://sourceforge.net/p/jts-topo-suite/code/626/
+template<>
+template<>
+void object::test<3>
+()
+{
+    Coordinate p0(219.3649559090992, 140.84159161824724);
+    Coordinate p1(168.9018919682399, -5.713787599646864);
+    Coordinate p(186.80814046338352, 46.28973405831556);
+    // CGAlgorithms::orientationIndex gives both the same!!!
+    // First case of doubledouble robustness improvement
+    int orient = Orientation::index(p0, p1, p);
+    int orientInv = Orientation::index(p1, p0, p);
+    ensure(orient != orientInv);
+}
+
+// 4 - make sure CGAlgorithmsDD::checkSignOfDet2x2 isn't
+// busted
+template<>
+template<>
+void object::test<4>
+()
 {
-    //
-    // Test Group
-    //
-
-    struct test_computeorientation_data
-    {
-        geos::io::WKTReader reader_;
-
-        test_computeorientation_data() {}
-    };
-
-    typedef test_group<test_computeorientation_data> group;
-    typedef group::object object;
-
-    group test_computeorientation_group("geos::algorithm::Orientation::index");
-
-    //
-    // Test Cases
-    //
-
-    // 1 - Test CCW orientation
-    template<>
-    template<>
-    void object::test<1>()
-    {
-        const std::string wkt("LINESTRING ( 0 0, 0 1, 1 1)");
-        Geometry::Ptr geom(reader_.read(wkt));
-
-        CoordinateSequence::Ptr pts(geom->getCoordinates());
-
-        int const a = Orientation::index(pts->getAt(0), pts->getAt(1), pts->getAt(2));
-        int const b = Orientation::index(pts->getAt(0), pts->getAt(1), pts->getAt(2));
-        int const c = Orientation::index(pts->getAt(0), pts->getAt(1), pts->getAt(2));
-
-        ensure_equals( a, b );
-        ensure_equals( a, c );
-    }
-
-    // 2 - Test CCW orientation
-    template<>
-    template<>
-    void object::test<2>()
-    {
-        Coordinate c1(1.0000000000004998, -7.989685402102996);
-        Coordinate c2(10.0, -7.004368924503866);
-        Coordinate c3(1.0000000000005, -7.989685402102996);
-
-        CoordinateArraySequence pts;
-        pts.add(c1);
-        pts.add(c2);
-        pts.add(c3);
-
-        int const a = Orientation::index(pts[0], pts[1], pts[2]);
-        int const b = Orientation::index(pts[0], pts[1], pts[2]);
-        int const c = Orientation::index(pts[0], pts[1], pts[2]);
-
-        ensure_equals( a, b );
-        ensure_equals( a, c );
-    }
-
-    // 3 - Test orientation for the original JTS test case
-    // jts/java/src/com/vividsolutions/jts/algorithm/RobustDeterminant.java, r626
-    // http://sourceforge.net/p/jts-topo-suite/code/626/
-    template<>
-    template<>
-    void object::test<3>()
-    {
-        Coordinate p0(219.3649559090992, 140.84159161824724);
-        Coordinate p1(168.9018919682399, -5.713787599646864);
-        Coordinate p(186.80814046338352, 46.28973405831556);
-        // CGAlgorithms::orientationIndex gives both the same!!!
-        // First case of doubledouble robustness improvement
-        int orient = Orientation::index(p0, p1, p);
-        int orientInv = Orientation::index(p1, p0, p);
-        ensure( orient != orientInv );
-    }
-
-    // 4 - make sure CGAlgorithmsDD::checkSignOfDet2x2 isn't
-    // busted
-    template<>
-    template<>
-    void object::test<4>()
-    {
-        ensure( 0 == CGAlgorithmsDD::signOfDet2x2(1.0, 1.0, 2.0, 2.0));
-        ensure( 1 == CGAlgorithmsDD::signOfDet2x2(1.0, 1.0, 2.0, 3.0));
-        ensure( -1 == CGAlgorithmsDD::signOfDet2x2(1.0, 1.0, 3.0, 2.0));
-    }
+    ensure(0 == CGAlgorithmsDD::signOfDet2x2(1.0, 1.0, 2.0, 2.0));
+    ensure(1 == CGAlgorithmsDD::signOfDet2x2(1.0, 1.0, 2.0, 3.0));
+    ensure(-1 == CGAlgorithmsDD::signOfDet2x2(1.0, 1.0, 3.0, 2.0));
+}
 
 } // namespace tut
diff --git a/tests/unit/algorithm/CGAlgorithms/isCCWTest.cpp b/tests/unit/algorithm/CGAlgorithms/isCCWTest.cpp
index df842fc..8a4b30c 100644
--- a/tests/unit/algorithm/CGAlgorithms/isCCWTest.cpp
+++ b/tests/unit/algorithm/CGAlgorithms/isCCWTest.cpp
@@ -20,111 +20,116 @@
 
 using namespace geos::algorithm;
 
-namespace tut
-{
-    //
-    // Test Group
-    //
+namespace tut {
+//
+// Test Group
+//
 
-    struct test_isccw_data
-    {
-	    typedef std::unique_ptr<geos::geom::Geometry> GeometryPtr;
-
-        geos::geom::CoordinateSequence* cs_;
-        geos::io::WKTReader reader_;
-        geos::io::WKBReader breader_;
-
-        test_isccw_data()
-            : cs_(nullptr)
-        {
-            assert(nullptr == cs_);
-        }
-
-        ~test_isccw_data()
-        {
-            delete cs_;
-            cs_ = nullptr;
-        }
-    };
-
-    typedef test_group<test_isccw_data> group;
-    typedef group::object object;
-
-    group test_isccw_group("geos::algorithm::Orientation::isCCW");
-
-    //
-    // Test Cases
-    //
-
-    // 1 - Test if coordinates of polygon are counter-clockwise oriented
-    template<>
-    template<>
-    void object::test<1>()
-    {
-        const std::string wkt("POLYGON ((60 180, 140 240, 140 240, 140 240, 200 180, 120 120, 60 180))");
-		GeometryPtr geom(reader_.read(wkt));
+struct test_isccw_data {
+    typedef std::unique_ptr<geos::geom::Geometry> GeometryPtr;
 
-        cs_ = geom->getCoordinates();
-        bool isCCW = Orientation::isCCW(cs_);
+    geos::geom::CoordinateSequence* cs_;
+    geos::io::WKTReader reader_;
+    geos::io::WKBReader breader_;
 
-        ensure_equals( false, isCCW );
+    test_isccw_data()
+        : cs_(nullptr)
+    {
+        assert(nullptr == cs_);
     }
 
-    // 2 - Test if coordinates of polygon are counter-clockwise oriented
-    template<>
-    template<>
-    void object::test<2>()
+    ~test_isccw_data()
     {
-        const std::string wkt("POLYGON ((60 180, 140 120, 100 180, 140 240, 60 180))");
-		GeometryPtr geom(reader_.read(wkt));
+        delete cs_;
+        cs_ = nullptr;
+    }
+};
 
-        cs_ = geom->getCoordinates();
-        bool isCCW = Orientation::isCCW(cs_);
+typedef test_group<test_isccw_data> group;
+typedef group::object object;
 
-        ensure_equals( true, isCCW );
-    }
+group test_isccw_group("geos::algorithm::Orientation::isCCW");
 
-    // 3 - Test the same polygon as in test No 2 but with duplicated top point
-    template<>
-    template<>
-    void object::test<3>()
-    {
-        const std::string wkt("POLYGON ((60 180, 140 120, 100 180, 140 240, 140 240, 60 180))");
-		GeometryPtr geom(reader_.read(wkt));
+//
+// Test Cases
+//
+
+// 1 - Test if coordinates of polygon are counter-clockwise oriented
+template<>
+template<>
+void object::test<1>
+()
+{
+    const std::string wkt("POLYGON ((60 180, 140 240, 140 240, 140 240, 200 180, 120 120, 60 180))");
+    GeometryPtr geom(reader_.read(wkt));
 
-        cs_ = geom->getCoordinates();
-        bool isCCW = Orientation::isCCW(cs_);
+    cs_ = geom->getCoordinates();
+    bool isCCW = Orientation::isCCW(cs_);
 
-        ensure_equals( true, isCCW );
-    }
+    ensure_equals(false, isCCW);
+}
 
-    // 4 - Test orientation the narrow (almost collapsed) ring
-    //     resulting in GEOS during execution of the union described
-    //     in http://trac.osgeo.org/geos/ticket/398
-    template<>
-    template<>
-    void object::test<4>()
-    {
-        std::istringstream wkt("0102000000040000000000000000000000841D588465963540F56BFB214F0341408F26B714B2971B40F66BFB214F0341408C26B714B2971B400000000000000000841D588465963540");
-        GeometryPtr geom(breader_.readHEX(wkt));
-        cs_ = geom->getCoordinates();
-        bool isCCW = Orientation::isCCW(cs_);
-        ensure_equals( isCCW, true );
-    }
+// 2 - Test if coordinates of polygon are counter-clockwise oriented
+template<>
+template<>
+void object::test<2>
+()
+{
+    const std::string wkt("POLYGON ((60 180, 140 120, 100 180, 140 240, 60 180))");
+    GeometryPtr geom(reader_.read(wkt));
 
-    // 5 - Test orientation the narrow (almost collapsed) ring
-    //     resulting in JTS during execution of the union described
-    //     in http://trac.osgeo.org/geos/ticket/398
-    template<>
-    template<>
-    void object::test<5>()
-    {
-        std::istringstream wkt("0102000000040000000000000000000000841D588465963540F56BFB214F0341408F26B714B2971B40F66BFB214F0341408E26B714B2971B400000000000000000841D588465963540");
-        GeometryPtr geom(breader_.readHEX(wkt));
-        cs_ = geom->getCoordinates();
-        bool isCCW = Orientation::isCCW(cs_);
-        ensure_equals( isCCW, true );
-    }
+    cs_ = geom->getCoordinates();
+    bool isCCW = Orientation::isCCW(cs_);
+
+    ensure_equals(true, isCCW);
+}
+
+// 3 - Test the same polygon as in test No 2 but with duplicated top point
+template<>
+template<>
+void object::test<3>
+()
+{
+    const std::string wkt("POLYGON ((60 180, 140 120, 100 180, 140 240, 140 240, 60 180))");
+    GeometryPtr geom(reader_.read(wkt));
+
+    cs_ = geom->getCoordinates();
+    bool isCCW = Orientation::isCCW(cs_);
+
+    ensure_equals(true, isCCW);
+}
+
+// 4 - Test orientation the narrow (almost collapsed) ring
+//     resulting in GEOS during execution of the union described
+//     in http://trac.osgeo.org/geos/ticket/398
+template<>
+template<>
+void object::test<4>
+()
+{
+    std::istringstream
+    wkt("0102000000040000000000000000000000841D588465963540F56BFB214F0341408F26B714B2971B40F66BFB214F0341408C26B714B2971B400000000000000000841D588465963540");
+    GeometryPtr geom(breader_.readHEX(wkt));
+    cs_ = geom->getCoordinates();
+    bool isCCW = Orientation::isCCW(cs_);
+    ensure_equals(isCCW, true);
+}
+
+// 5 - Test orientation the narrow (almost collapsed) ring
+//     resulting in JTS during execution of the union described
+//     in http://trac.osgeo.org/geos/ticket/398
+template<>
+template<>
+void object::test<5>
+()
+{
+    std::istringstream
+    wkt("0102000000040000000000000000000000841D588465963540F56BFB214F0341408F26B714B2971B40F66BFB214F0341408E26B714B2971B400000000000000000841D588465963540");
+    GeometryPtr geom(breader_.readHEX(wkt));
+    cs_ = geom->getCoordinates();
+    bool isCCW = Orientation::isCCW(cs_);
+    ensure_equals(isCCW, true);
+}
 
 } // namespace tut
 
diff --git a/tests/unit/algorithm/CGAlgorithms/isPointInRingTest.cpp b/tests/unit/algorithm/CGAlgorithms/isPointInRingTest.cpp
index 2007ae3..da7af8e 100644
--- a/tests/unit/algorithm/CGAlgorithms/isPointInRingTest.cpp
+++ b/tests/unit/algorithm/CGAlgorithms/isPointInRingTest.cpp
@@ -16,74 +16,74 @@
 
 using namespace geos::algorithm;
 
-namespace tut
-{
-    //
-    // Test Group
-    //
+namespace tut {
+//
+// Test Group
+//
 
-    struct test_ispointinring_data
-    {
-	    typedef std::unique_ptr<geos::geom::Geometry> GeomPtr;
+struct test_ispointinring_data {
+    typedef std::unique_ptr<geos::geom::Geometry> GeomPtr;
 
-        geos::geom::CoordinateSequence* cs_;
-        geos::io::WKTReader reader_;
+    geos::geom::CoordinateSequence* cs_;
+    geos::io::WKTReader reader_;
 
-        test_ispointinring_data()
-            : cs_(nullptr)
-        {
-            assert(nullptr == cs_);
-        }
+    test_ispointinring_data()
+        : cs_(nullptr)
+    {
+        assert(nullptr == cs_);
+    }
 
-        ~test_ispointinring_data()
-        {
-            delete cs_;
-            cs_ = nullptr;
-        }
-    };
+    ~test_ispointinring_data()
+    {
+        delete cs_;
+        cs_ = nullptr;
+    }
+};
 
-    typedef test_group<test_ispointinring_data> group;
-    typedef group::object object;
+typedef test_group<test_ispointinring_data> group;
+typedef group::object object;
 
-    group test_ispointintring_group("geos::algorithm::PointLocation::isInRing");
+group test_ispointintring_group("geos::algorithm::PointLocation::isInRing");
 
-    //
-    // Test Cases
-    //
+//
+// Test Cases
+//
 
-    // Test of point in simple Polygon
-    template<>
-    template<>
-    void object::test<1>()
-    {
-        const std::string wkt("POLYGON ((0 0, 0 20, 20 20, 20 0, 0 0))");
-		GeomPtr geom(reader_.read(wkt));
+// Test of point in simple Polygon
+template<>
+template<>
+void object::test<1>
+()
+{
+    const std::string wkt("POLYGON ((0 0, 0 20, 20 20, 20 0, 0 0))");
+    GeomPtr geom(reader_.read(wkt));
 
-        geos::geom::Coordinate pt(10, 10);
+    geos::geom::Coordinate pt(10, 10);
 
-        cs_ = geom->getCoordinates();
-        bool isInRing = PointLocation::isInRing(pt, cs_);
+    cs_ = geom->getCoordinates();
+    bool isInRing = PointLocation::isInRing(pt, cs_);
 
-        ensure_equals( true, isInRing );
-    }
+    ensure_equals(true, isInRing);
+}
 
-    // Test of point in bigger Polygon
-    template<>
-    template<>
-    void object::test<2>()
-    {
-        const std::string wkt("POLYGON ((-40 80, -40 -80, 20 0, 20 -100, 40 40, \
+// Test of point in bigger Polygon
+template<>
+template<>
+void object::test<2>
+()
+{
+    const std::string wkt("POLYGON ((-40 80, -40 -80, 20 0, 20 -100, 40 40, \
                                80 -80, 100 80, 140 -20, 120 140, 40 180, 60 40, \
                                0 120, -20 -20, -40 80))");
-		GeomPtr geom(reader_.read(wkt));
+    GeomPtr geom(reader_.read(wkt));
 
-        geos::geom::Coordinate pt(0, 0);
+    geos::geom::Coordinate pt(0, 0);
 
-        cs_ = geom->getCoordinates();
-        bool isInRing = PointLocation::isInRing(pt, cs_);
+    cs_ = geom->getCoordinates();
+    bool isInRing = PointLocation::isInRing(pt, cs_);
 
-        ensure_equals( true, isInRing );
-    }
+    ensure_equals(true, isInRing);
+}
 
 } // namespace tut
 
diff --git a/tests/unit/algorithm/CGAlgorithms/signedAreaTest.cpp b/tests/unit/algorithm/CGAlgorithms/signedAreaTest.cpp
index 0f9718a..91caacd 100644
--- a/tests/unit/algorithm/CGAlgorithms/signedAreaTest.cpp
+++ b/tests/unit/algorithm/CGAlgorithms/signedAreaTest.cpp
@@ -19,83 +19,84 @@
 
 using namespace geos::algorithm;
 
-namespace tut
-{
-    //
-    // Test Group
-    //
+namespace tut {
+//
+// Test Group
+//
 
-    struct test_signedarea_data
-    {
-	    typedef std::unique_ptr<geos::geom::Geometry> GeometryPtr;
-
-        geos::geom::CoordinateSequence* cs_;
-        geos::io::WKTReader reader_;
-        geos::io::WKBReader breader_;
-
-        test_signedarea_data()
-            : cs_(nullptr)
-        {
-            assert(nullptr == cs_);
-        }
-
-        ~test_signedarea_data()
-        {
-            delete cs_;
-            cs_ = nullptr;
-        }
-    };
-
-    typedef test_group<test_signedarea_data> group;
-    typedef group::object object;
-
-    group test_signedarea_group("geos::algorithm::Area::ofRingSigned");
-
-    //
-    // Test Cases
-    //
-
-    // 1 - clockwise oriented
-    template<>
-    template<>
-    void object::test<1>()
-    {
-        const std::string wkt("POLYGON ((60 180, 140 240, 140 240, 140 240, 200 180, 120 120, 60 180))");
-        GeometryPtr geom(reader_.read(wkt));
+struct test_signedarea_data {
+    typedef std::unique_ptr<geos::geom::Geometry> GeometryPtr;
 
-        cs_ = geom->getCoordinates();
-        double area = Area::ofRingSigned(cs_);
+    geos::geom::CoordinateSequence* cs_;
+    geos::io::WKTReader reader_;
+    geos::io::WKBReader breader_;
 
-        ensure_equals( area, 8400 );
+    test_signedarea_data()
+        : cs_(nullptr)
+    {
+        assert(nullptr == cs_);
     }
 
-    // 2 - counter-clockwise oriented
-    template<>
-    template<>
-    void object::test<2>()
+    ~test_signedarea_data()
     {
-        const std::string wkt("POLYGON ((60 180, 140 120, 100 180, 140 240, 60 180))");
-        GeometryPtr geom(reader_.read(wkt));
+        delete cs_;
+        cs_ = nullptr;
+    }
+};
 
-        cs_ = geom->getCoordinates();
-        double area = Area::ofRingSigned(cs_);
+typedef test_group<test_signedarea_data> group;
+typedef group::object object;
 
-        ensure_equals( area, -2400 );
-    }
+group test_signedarea_group("geos::algorithm::Area::ofRingSigned");
 
-    // 3 - Test the same polygon as in test No 2 but with duplicated top point
-    template<>
-    template<>
-    void object::test<3>()
-    {
-        const std::string wkt("POLYGON ((60 180, 140 120, 100 180, 140 240, 140 240, 60 180))");
-		GeometryPtr geom(reader_.read(wkt));
+//
+// Test Cases
+//
 
-        cs_ = geom->getCoordinates();
-        double area = Area::ofRingSigned(cs_);
+// 1 - clockwise oriented
+template<>
+template<>
+void object::test<1>
+()
+{
+    const std::string wkt("POLYGON ((60 180, 140 240, 140 240, 140 240, 200 180, 120 120, 60 180))");
+    GeometryPtr geom(reader_.read(wkt));
 
-        ensure_equals( area, -2400 );
-    }
+    cs_ = geom->getCoordinates();
+    double area = Area::ofRingSigned(cs_);
+
+    ensure_equals(area, 8400);
+}
+
+// 2 - counter-clockwise oriented
+template<>
+template<>
+void object::test<2>
+()
+{
+    const std::string wkt("POLYGON ((60 180, 140 120, 100 180, 140 240, 60 180))");
+    GeometryPtr geom(reader_.read(wkt));
+
+    cs_ = geom->getCoordinates();
+    double area = Area::ofRingSigned(cs_);
+
+    ensure_equals(area, -2400);
+}
+
+// 3 - Test the same polygon as in test No 2 but with duplicated top point
+template<>
+template<>
+void object::test<3>
+()
+{
+    const std::string wkt("POLYGON ((60 180, 140 120, 100 180, 140 240, 140 240, 60 180))");
+    GeometryPtr geom(reader_.read(wkt));
+
+    cs_ = geom->getCoordinates();
+    double area = Area::ofRingSigned(cs_);
+
+    ensure_equals(area, -2400);
+}
 
 
 } // namespace tut
diff --git a/tests/unit/algorithm/ConvexHullTest.cpp b/tests/unit/algorithm/ConvexHullTest.cpp
index ec05784..8116308 100644
--- a/tests/unit/algorithm/ConvexHullTest.cpp
+++ b/tests/unit/algorithm/ConvexHullTest.cpp
@@ -20,176 +20,181 @@
 #include <cassert>
 
 namespace geos {
-	namespace geom {
-		class Geometry;
-	}
+namespace geom {
+class Geometry;
+}
 }
 
 using namespace geos::geom; // for Location
 
-namespace tut
-{
-	//
-	// Test Group
-	//
+namespace tut {
+//
+// Test Group
+//
+
+// dummy data, not used
+struct test_convexhull_data {
+    GeometryPtr geom_;
+    geos::geom::PrecisionModel pm_;
+    geos::geom::GeometryFactory::Ptr factory_;
+    geos::io::WKTReader reader_;
 
-	// dummy data, not used
-	struct test_convexhull_data
+    test_convexhull_data()
+        : geom_(nullptr), pm_(1), factory_(GeometryFactory::create(&pm_, 0)), reader_(factory_.get())
     {
-        GeometryPtr geom_;
-        geos::geom::PrecisionModel pm_;
-        geos::geom::GeometryFactory::Ptr factory_;
-        geos::io::WKTReader reader_;
-
-        test_convexhull_data()
-			: geom_(nullptr), pm_(1), factory_(GeometryFactory::create(&pm_, 0)), reader_(factory_.get())
-        {
-            assert(nullptr == geom_);
-        }
-
-        ~test_convexhull_data()
-        {
-            factory_->destroyGeometry(geom_);
-            geom_ = nullptr;
-        }
-    };
-
-	typedef test_group<test_convexhull_data> group;
-	typedef group::object object;
-
-    group test_convexhull_group("geos::algorithm::ConvexHull");
-
-	//
-	// Test Cases
-	//
-
-	// 1 - Test convex hull of linestring
-	template<>
-    template<>
-    void object::test<1>()
+        assert(nullptr == geom_);
+    }
+
+    ~test_convexhull_data()
     {
-        using geos::geom::LineString;
+        factory_->destroyGeometry(geom_);
+        geom_ = nullptr;
+    }
+};
 
-        Geometry::Ptr lineGeom(reader_.read("LINESTRING (30 220, 240 220, 240 220)"));
-        LineString::Ptr line(dynamic_cast<LineString*>(lineGeom.release()));
-        ensure(nullptr != line.get());
+typedef test_group<test_convexhull_data> group;
+typedef group::object object;
 
-        Geometry::Ptr hullGeom(reader_.read("LINESTRING (30 220, 240 220)"));
-        LineString::Ptr convexHull(dynamic_cast<LineString*>(hullGeom.release()));
-        ensure(nullptr != convexHull.get());
+group test_convexhull_group("geos::algorithm::ConvexHull");
 
-        geom_ = line->convexHull();
-        ensure( convexHull->equalsExact(geom_) );
-    }
+//
+// Test Cases
+//
 
-	// 2 - Test convex hull of multipoint
-	template<>
-    template<>
-    void object::test<2>()
-    {
-        using geos::geom::LineString;
+// 1 - Test convex hull of linestring
+template<>
+template<>
+void object::test<1>
+()
+{
+    using geos::geom::LineString;
 
-        Geometry::Ptr geom(reader_.read("MULTIPOINT (130 240, 130 240, 130 240, 570 240, 570 240, 570 240, 650 240)"));
-        ensure(nullptr != geom.get());
+    Geometry::Ptr lineGeom(reader_.read("LINESTRING (30 220, 240 220, 240 220)"));
+    LineString::Ptr line(dynamic_cast<LineString*>(lineGeom.release()));
+    ensure(nullptr != line.get());
 
-        Geometry::Ptr hullGeom(reader_.read("LINESTRING (130 240, 650 240)"));
-        LineString::Ptr convexHull(dynamic_cast<LineString*>(hullGeom.release()));
-        ensure(nullptr != convexHull.get());
+    Geometry::Ptr hullGeom(reader_.read("LINESTRING (30 220, 240 220)"));
+    LineString::Ptr convexHull(dynamic_cast<LineString*>(hullGeom.release()));
+    ensure(nullptr != convexHull.get());
 
-        geom_ = geom->convexHull();
-        ensure( convexHull->equalsExact(geom_) );
-    }
+    geom_ = line->convexHull();
+    ensure(convexHull->equalsExact(geom_));
+}
 
-	// 3 - Test convex hull of multipoint
-	template<>
-    template<>
-    void object::test<3>()
-    {
-        using geos::geom::LineString;
+// 2 - Test convex hull of multipoint
+template<>
+template<>
+void object::test<2>
+()
+{
+    using geos::geom::LineString;
 
-        Geometry::Ptr geom(reader_.read("MULTIPOINT (0 0, 0 0, 10 0)"));
-        ensure(nullptr != geom.get());
+    Geometry::Ptr geom(reader_.read("MULTIPOINT (130 240, 130 240, 130 240, 570 240, 570 240, 570 240, 650 240)"));
+    ensure(nullptr != geom.get());
 
-        Geometry::Ptr hullGeom(reader_.read("LINESTRING (0 0, 10 0)"));
-        LineString::Ptr convexHull(dynamic_cast<LineString*>(hullGeom.release()));
-        ensure(nullptr != convexHull.get());
+    Geometry::Ptr hullGeom(reader_.read("LINESTRING (130 240, 650 240)"));
+    LineString::Ptr convexHull(dynamic_cast<LineString*>(hullGeom.release()));
+    ensure(nullptr != convexHull.get());
 
-        geom_ = geom->convexHull();
-        ensure( convexHull->equalsExact(geom_) );
-    }
+    geom_ = geom->convexHull();
+    ensure(convexHull->equalsExact(geom_));
+}
 
-	// 4 - Test convex hull of multipoint
-	template<>
-    template<>
-    void object::test<4>()
-    {
-        using geos::geom::LineString;
+// 3 - Test convex hull of multipoint
+template<>
+template<>
+void object::test<3>
+()
+{
+    using geos::geom::LineString;
 
-        Geometry::Ptr geom(reader_.read("MULTIPOINT (0 0, 10 0, 10 0)"));
-        ensure(nullptr != geom.get());
+    Geometry::Ptr geom(reader_.read("MULTIPOINT (0 0, 0 0, 10 0)"));
+    ensure(nullptr != geom.get());
 
-        Geometry::Ptr hullGeom(reader_.read("LINESTRING (0 0, 10 0)"));
-        LineString::Ptr convexHull(dynamic_cast<LineString*>(hullGeom.release()));
-        ensure(nullptr != convexHull.get());
+    Geometry::Ptr hullGeom(reader_.read("LINESTRING (0 0, 10 0)"));
+    LineString::Ptr convexHull(dynamic_cast<LineString*>(hullGeom.release()));
+    ensure(nullptr != convexHull.get());
 
-        geom_ = geom->convexHull();
-        ensure( convexHull->equalsExact(geom_) );
-    }
+    geom_ = geom->convexHull();
+    ensure(convexHull->equalsExact(geom_));
+}
 
-	// 5 - Test convex hull of multipoint
-	template<>
-    template<>
-    void object::test<5>()
-    {
-        using geos::geom::LineString;
+// 4 - Test convex hull of multipoint
+template<>
+template<>
+void object::test<4>
+()
+{
+    using geos::geom::LineString;
 
-        Geometry::Ptr geom(reader_.read("MULTIPOINT (0 0, 5 0, 10 0)"));
-        ensure(nullptr != geom.get());
+    Geometry::Ptr geom(reader_.read("MULTIPOINT (0 0, 10 0, 10 0)"));
+    ensure(nullptr != geom.get());
 
-        Geometry::Ptr hullGeom(reader_.read("LINESTRING (0 0, 10 0)"));
-        LineString::Ptr convexHull(dynamic_cast<LineString*>(hullGeom.release()));
-        ensure(nullptr != convexHull.get());
+    Geometry::Ptr hullGeom(reader_.read("LINESTRING (0 0, 10 0)"));
+    LineString::Ptr convexHull(dynamic_cast<LineString*>(hullGeom.release()));
+    ensure(nullptr != convexHull.get());
 
-        geom_ = geom->convexHull();
-        ensure( convexHull->equalsExact(geom_) );
-    }
+    geom_ = geom->convexHull();
+    ensure(convexHull->equalsExact(geom_));
+}
 
-	// 6 - Test convex hull of multipoint exported to string form
-	template<>
-    template<>
-    void object::test<6>()
-    {
-        using geos::geom::LineString;
+// 5 - Test convex hull of multipoint
+template<>
+template<>
+void object::test<5>
+()
+{
+    using geos::geom::LineString;
 
-        Geometry::Ptr geom(reader_.read("MULTIPOINT (0 0, 5 1, 10 0)"));
-        ensure(nullptr != geom.get());
+    Geometry::Ptr geom(reader_.read("MULTIPOINT (0 0, 5 0, 10 0)"));
+    ensure(nullptr != geom.get());
 
-        Geometry::Ptr hullGeom(geom->convexHull());
-        ensure(nullptr != hullGeom.get());
+    Geometry::Ptr hullGeom(reader_.read("LINESTRING (0 0, 10 0)"));
+    LineString::Ptr convexHull(dynamic_cast<LineString*>(hullGeom.release()));
+    ensure(nullptr != convexHull.get());
 
-        Geometry::Ptr expectedHull(reader_.read("POLYGON ((0 0, 5 1, 10 0, 0 0))"));
-        ensure(nullptr != expectedHull.get());
+    geom_ = geom->convexHull();
+    ensure(convexHull->equalsExact(geom_));
+}
 
-        ensure_equals( hullGeom->toString(), expectedHull->toString() );
-    }
+// 6 - Test convex hull of multipoint exported to string form
+template<>
+template<>
+void object::test<6>
+()
+{
+    using geos::geom::LineString;
 
-	// 7 - Test convex hull of multipoint
-	template<>
-    template<>
-    void object::test<7>()
-    {
-        using geos::geom::LineString;
+    Geometry::Ptr geom(reader_.read("MULTIPOINT (0 0, 5 1, 10 0)"));
+    ensure(nullptr != geom.get());
 
-        Geometry::Ptr geom(reader_.read("MULTIPOINT (0 0, 0 0, 5 0, 5 0, 10 0, 10 0)"));
-        ensure(nullptr != geom.get());
+    Geometry::Ptr hullGeom(geom->convexHull());
+    ensure(nullptr != hullGeom.get());
 
-        Geometry::Ptr hullGeom(reader_.read("LINESTRING (0 0, 10 0)"));
-        LineString::Ptr convexHull(dynamic_cast<LineString*>(hullGeom.release()));
-        ensure(nullptr != convexHull.get());
+    Geometry::Ptr expectedHull(reader_.read("POLYGON ((0 0, 5 1, 10 0, 0 0))"));
+    ensure(nullptr != expectedHull.get());
 
-        geom_ = geom->convexHull();
-        ensure( convexHull->equalsExact(geom_) );
-    }
+    ensure_equals(hullGeom->toString(), expectedHull->toString());
+}
+
+// 7 - Test convex hull of multipoint
+template<>
+template<>
+void object::test<7>
+()
+{
+    using geos::geom::LineString;
+
+    Geometry::Ptr geom(reader_.read("MULTIPOINT (0 0, 0 0, 5 0, 5 0, 10 0, 10 0)"));
+    ensure(nullptr != geom.get());
+
+    Geometry::Ptr hullGeom(reader_.read("LINESTRING (0 0, 10 0)"));
+    LineString::Ptr convexHull(dynamic_cast<LineString*>(hullGeom.release()));
+    ensure(nullptr != convexHull.get());
+
+    geom_ = geom->convexHull();
+    ensure(convexHull->equalsExact(geom_));
+}
 
 } // namespace tut
 
diff --git a/tests/unit/algorithm/InteriorPointAreaTest.cpp b/tests/unit/algorithm/InteriorPointAreaTest.cpp
index 1542817..fa9a82c 100644
--- a/tests/unit/algorithm/InteriorPointAreaTest.cpp
+++ b/tests/unit/algorithm/InteriorPointAreaTest.cpp
@@ -26,59 +26,59 @@
 #include <string>
 #include <memory>
 
-namespace tut
-{
-    //
-    // Test Group
-    //
+namespace tut {
+//
+// Test Group
+//
 
-    // dummy data, not used
-    struct test_interiorpointarea_data {
-      typedef geos::geom::Geometry Geometry;
-      typedef geos::geom::Coordinate Coordinate;
-      typedef geos::algorithm::InteriorPointArea InteriorPointArea;
+// dummy data, not used
+struct test_interiorpointarea_data {
+    typedef geos::geom::Geometry Geometry;
+    typedef geos::geom::Coordinate Coordinate;
+    typedef geos::algorithm::InteriorPointArea InteriorPointArea;
 
-      geos::io::WKTReader reader;
-      std::unique_ptr<Geometry> geom;
+    geos::io::WKTReader reader;
+    std::unique_ptr<Geometry> geom;
 
-      test_interiorpointarea_data()
-      {}
+    test_interiorpointarea_data()
+    {}
 
-    };
+};
 
-    typedef test_group<test_interiorpointarea_data> group;
-    typedef group::object object;
+typedef test_group<test_interiorpointarea_data> group;
+typedef group::object object;
 
-    group test_interiorpointarea_group("geos::algorithm::InteriorPointArea");
+group test_interiorpointarea_group("geos::algorithm::InteriorPointArea");
 
-    //
-    // Test Cases
-    //
+//
+// Test Cases
+//
 
-    // http://trac.osgeo.org/geos/ticket/475
-    // This is a test for a memory leak more than anything else
-    template<>
-    template<>
-    void object::test<1>()
-    {
-      Coordinate centroid;
+// http://trac.osgeo.org/geos/ticket/475
+// This is a test for a memory leak more than anything else
+template<>
+template<>
+void object::test<1>
+()
+{
+    Coordinate centroid;
 
-      // this polygon is a typical hourglass-shape with a self intersection
-      // without a node
-      geom.reset( reader.read("POLYGON((6 54, 15 54, 6 47, 15 47, 6 54))") );
+    // this polygon is a typical hourglass-shape with a self intersection
+    // without a node
+    geom.reset(reader.read("POLYGON((6 54, 15 54, 6 47, 15 47, 6 54))"));
 
-      bool threw = false;
+    bool threw = false;
 
-      try {
+    try {
         InteriorPointArea interior_builder(geom.get());
         interior_builder.getInteriorPoint(centroid);
-      }
-      catch(...) {
+    }
+    catch(...) {
         threw = true;
-      }
-
-      ensure(threw);
     }
 
+    ensure(threw);
+}
+
 } // namespace tut
 
diff --git a/tests/unit/algorithm/LengthTest.cpp b/tests/unit/algorithm/LengthTest.cpp
index 8b277f7..226c27d 100644
--- a/tests/unit/algorithm/LengthTest.cpp
+++ b/tests/unit/algorithm/LengthTest.cpp
@@ -21,70 +21,72 @@
 using namespace geos;
 using namespace geos::geom;
 
-namespace tut
-{
-	//
-	// Test Group
-	//
-
-	// dummy data, not used
-	struct test_length_data {
-        geos::geom::Geometry *geom_;
-        geos::geom::PrecisionModel pm_;
-        geos::geom::GeometryFactory::Ptr factory_;
-        geos::io::WKTReader reader_;
-        test_length_data():
-            geom_(nullptr),
-            pm_(1),
-            factory_(GeometryFactory::create(&pm_, 0)), reader_(factory_.get())
-        {
-            assert(nullptr == geom_);
-        }
-
-        ~test_length_data()
-        {
-            factory_->destroyGeometry(geom_);
-            geom_ = nullptr;
-        }
-
-        void checkLengthOfLine(std::string wkt, double expectedLength) {
-            std::unique_ptr<Geometry> lineGeom(reader_.read(wkt));
-            std::unique_ptr<LineString> line(dynamic_cast<LineString*>(lineGeom.release()));
-            ensure(nullptr != line.get());
-            const CoordinateSequence *lineSeq = line->getCoordinatesRO();
-            double actual = algorithm::Length::ofLine(lineSeq);
-            ensure_equals(actual, expectedLength);
-        }
-
-    };
-
- // void checkLengthOfLine(String wkt, double expectedLen) {
- //    LineString ring = (LineString) read(wkt);
-
- //    CoordinateSequence pts = ring.getCoordinateSequence();
- //    double actual = Length.ofLine(pts);
- //    assertEquals(actual, expectedLen);
- //  }
-
-
-
-
-    typedef test_group<test_length_data> group;
-    typedef group::object object;
-
-    group test_length_group("geos::algorithm::Length");
-
-
-    //
-    // Test Cases
-    //
-    template<>
-    template<>
-    void object::test<1>()
+namespace tut {
+//
+// Test Group
+//
+
+// dummy data, not used
+struct test_length_data {
+    geos::geom::Geometry* geom_;
+    geos::geom::PrecisionModel pm_;
+    geos::geom::GeometryFactory::Ptr factory_;
+    geos::io::WKTReader reader_;
+    test_length_data():
+        geom_(nullptr),
+        pm_(1),
+        factory_(GeometryFactory::create(&pm_, 0)), reader_(factory_.get())
+    {
+        assert(nullptr == geom_);
+    }
+
+    ~test_length_data()
+    {
+        factory_->destroyGeometry(geom_);
+        geom_ = nullptr;
+    }
+
+    void
+    checkLengthOfLine(std::string wkt, double expectedLength)
     {
-        checkLengthOfLine("LINESTRING (100 200, 200 200, 200 100, 100 100, 100 200)", 400.0);
+        std::unique_ptr<Geometry> lineGeom(reader_.read(wkt));
+        std::unique_ptr<LineString> line(dynamic_cast<LineString*>(lineGeom.release()));
+        ensure(nullptr != line.get());
+        const CoordinateSequence* lineSeq = line->getCoordinatesRO();
+        double actual = algorithm::Length::ofLine(lineSeq);
+        ensure_equals(actual, expectedLength);
     }
 
+};
+
+// void checkLengthOfLine(String wkt, double expectedLen) {
+//    LineString ring = (LineString) read(wkt);
+
+//    CoordinateSequence pts = ring.getCoordinateSequence();
+//    double actual = Length.ofLine(pts);
+//    assertEquals(actual, expectedLen);
+//  }
+
+
+
+
+typedef test_group<test_length_data> group;
+typedef group::object object;
+
+group test_length_group("geos::algorithm::Length");
+
+
+//
+// Test Cases
+//
+template<>
+template<>
+void object::test<1>
+()
+{
+    checkLengthOfLine("LINESTRING (100 200, 200 200, 200 100, 100 100, 100 200)", 400.0);
+}
+
 
 
 } // namespace tut
diff --git a/tests/unit/algorithm/LocatePointInRingTest.cpp b/tests/unit/algorithm/LocatePointInRingTest.cpp
index 49c054f..7edde30 100644
--- a/tests/unit/algorithm/LocatePointInRingTest.cpp
+++ b/tests/unit/algorithm/LocatePointInRingTest.cpp
@@ -20,158 +20,168 @@
 #include <memory>
 
 namespace geos {
-	namespace geom {
-		class Geometry;
-	}
+namespace geom {
+class Geometry;
+}
 }
 
 using namespace geos::geom; // for Location
 using namespace geos::algorithm; // for Location
 
-namespace tut
+namespace tut {
+//
+// Test Group
+//
+
+// dummy data, not used
+struct test_locatepointinring_data {};
+
+typedef test_group<test_locatepointinring_data> group;
+typedef group::object object;
+
+group test_locatepointinring_group("geos::algorithm::LocatePointInRing");
+
+// These are static to avoid namespace pollution
+// The struct test_*_data above is probably there
+// for the same reason...
+//
+static PrecisionModel pm;
+static GeometryFactory::Ptr gf = GeometryFactory::create(&pm);
+static geos::io::WKTReader reader(gf.get());
+
+static void
+runPtLocator(int expected, const Coordinate& pt,
+             const std::string& wkt)
+{
+    std::unique_ptr<Geometry> geom(reader.read(wkt));
+    const Polygon* poly = dynamic_cast<Polygon*>(geom.get());
+    const CoordinateSequence* cs = poly->getExteriorRing()->getCoordinatesRO();
+    int loc = PointLocation::locateInRing(pt, *cs);
+    ensure_equals(loc, expected);
+}
+
+static void
+runPtLocatorDD(int expected, const Coordinate& pt,
+               const std::string& wkt)
+{
+    std::unique_ptr<Geometry> geom(reader.read(wkt));
+    const Polygon* poly = dynamic_cast<Polygon*>(geom.get());
+    const CoordinateSequence* cs = poly->getExteriorRing()->getCoordinatesRO();
+    int loc = RayCrossingCounterDD::locatePointInRing(pt, *cs);
+    ensure_equals(loc, expected);
+}
+
+const std::string
+wkt_comb("POLYGON ((0 0, 0 10, 4 5, 6 10, 7 5, 9 10, 10 5, 13 5, 15 10, 16 3, 17 10, 18 3, 25 10, 30 10, 30 0, 15 0, 14 5, 13 0, 9 0, 8 5, 6 0, 0 0))");
+const std::string
+wkt_rpts("POLYGON ((0 0, 0 10, 2 5, 2 5, 2 5, 2 5, 2 5, 3 10, 6 10, 8 5, 8 5, 8 5, 8 5, 10 10, 10 5, 10 5, 10 5, 10 5, 10 0, 0 0))");
+
+//
+// Test Cases
+//
+
+// 1 - Test box
+template<>
+template<>
+void object::test<1>
+()
 {
-	//
-	// Test Group
-	//
-
-	// dummy data, not used
-	struct test_locatepointinring_data {};
-
-	typedef test_group<test_locatepointinring_data> group;
-	typedef group::object object;
-
-	group test_locatepointinring_group("geos::algorithm::LocatePointInRing");
-
-	// These are static to avoid namespace pollution
-	// The struct test_*_data above is probably there
-	// for the same reason...
-	//
-	static PrecisionModel pm;
-	static GeometryFactory::Ptr gf = GeometryFactory::create(&pm);
-	static geos::io::WKTReader reader(gf.get());
-
-	static void runPtLocator(int expected, const Coordinate& pt,
-			const std::string& wkt)
-	{
-        std::unique_ptr<Geometry> geom(reader.read(wkt));
-        const Polygon *poly = dynamic_cast<Polygon*>(geom.get());
-        const CoordinateSequence* cs = poly->getExteriorRing()->getCoordinatesRO();
-		int loc = PointLocation::locateInRing(pt, *cs);
-		ensure_equals(loc, expected);
-	}
-
-    static void runPtLocatorDD(int expected, const Coordinate& pt,
-            const std::string& wkt)
-    {
-        std::unique_ptr<Geometry> geom(reader.read(wkt));
-        const Polygon *poly = dynamic_cast<Polygon*>(geom.get());
-        const CoordinateSequence* cs = poly->getExteriorRing()->getCoordinatesRO();
-        int loc = RayCrossingCounterDD::locatePointInRing(pt, *cs);
-        ensure_equals(loc, expected);
-    }
-
-    const std::string wkt_comb("POLYGON ((0 0, 0 10, 4 5, 6 10, 7 5, 9 10, 10 5, 13 5, 15 10, 16 3, 17 10, 18 3, 25 10, 30 10, 30 0, 15 0, 14 5, 13 0, 9 0, 8 5, 6 0, 0 0))");
-    const std::string wkt_rpts("POLYGON ((0 0, 0 10, 2 5, 2 5, 2 5, 2 5, 2 5, 3 10, 6 10, 8 5, 8 5, 8 5, 8 5, 10 10, 10 5, 10 5, 10 5, 10 5, 10 0, 0 0))");
-
-	//
-	// Test Cases
-	//
-
-	// 1 - Test box
-	template<>
-	template<>
-	void object::test<1>()
-	{
-        runPtLocator(
-            Location::INTERIOR,
-            Coordinate(10, 10),
-		    "POLYGON ((0 0, 0 20, 20 20, 20 0, 0 0))");
-	}
-
-	// 2 - Test complex ring
-	template<>
-	template<>
-	void object::test<2>()
-	{
-		runPtLocator(
-            Location::INTERIOR,
-            Coordinate(0, 0),
-			"POLYGON ((-40 80, -40 -80, 20 0, 20 -100, 40 40, 80 -80, 100 80, 140 -20, 120 140, 40 180,     60 40, 0 120, -20 -20, -40 80))");
-	}
-
-	// 3 - Comb tests
-	template<>
-	template<>
-	void object::test<3>()
-	{
-        runPtLocator(Location::BOUNDARY, Coordinate(0, 0), wkt_comb);
-        runPtLocator(Location::BOUNDARY, Coordinate(0, 1), wkt_comb);
-        // at vertex
-        runPtLocator(Location::BOUNDARY, Coordinate(4, 5), wkt_comb);
-        runPtLocator(Location::BOUNDARY, Coordinate(8, 5), wkt_comb);
-
-        // on horizontal segment
-        runPtLocator(Location::BOUNDARY, Coordinate(11, 5), wkt_comb);
-        // on vertical segment
-        runPtLocator(Location::BOUNDARY, Coordinate(30, 5), wkt_comb);
-        // on angled segment
-        runPtLocator(Location::BOUNDARY, Coordinate(22, 7), wkt_comb);
-
-        runPtLocator(Location::INTERIOR, Coordinate(1, 5), wkt_comb);
-        runPtLocator(Location::INTERIOR, Coordinate(5, 5), wkt_comb);
-        runPtLocator(Location::INTERIOR, Coordinate(1, 7), wkt_comb);
-
-        runPtLocator(Location::EXTERIOR, Coordinate(12, 10), wkt_comb);
-        runPtLocator(Location::EXTERIOR, Coordinate(16, 5), wkt_comb);
-        runPtLocator(Location::EXTERIOR, Coordinate(35, 5), wkt_comb);
-	}
-
-
-	// 4 - repeated points
-	template<>
-	template<>
-	void object::test<4>()
-	{
-        runPtLocator(Location::BOUNDARY, Coordinate(0, 0), wkt_rpts);
-        runPtLocator(Location::BOUNDARY, Coordinate(0, 1), wkt_rpts);
-        // at vertex
-        runPtLocator(Location::BOUNDARY, Coordinate(2, 5), wkt_rpts);
-        runPtLocator(Location::BOUNDARY, Coordinate(8, 5), wkt_rpts);
-        runPtLocator(Location::BOUNDARY, Coordinate(10, 5), wkt_rpts);
-
-        runPtLocator(Location::INTERIOR, Coordinate(1, 5), wkt_rpts);
-        runPtLocator(Location::INTERIOR, Coordinate(3, 5), wkt_rpts);
-	}
-
-    // 5 - robustness
-    template<>
-    template<>
-    void object::test<5>()
-    {
-        runPtLocatorDD(Location::EXTERIOR,
-            Coordinate(25.374625374625374, 128.35564435564436),
-            "POLYGON ((0.0 0.0, 0.0 172.0, 100.0 0.0, 0.0 0.0))");
-    }
-
-    // 6 - robustness
-    template<>
-    template<>
-    void object::test<6>()
-    {
-        runPtLocatorDD(Location::INTERIOR,
-            Coordinate(97.96039603960396, 782.0),
-            "POLYGON ((642.0 815.0, 69.0 764.0, 394.0 966.0, 642.0 815.0))");
-    }
-
-    // 7 - robustness
-    template<>
-    template<>
-    void object::test<7>()
-    {
-        runPtLocatorDD(Location::EXTERIOR,
-            Coordinate(3.166572116932842, 48.5390194687463),
-            "POLYGON ((2.152214146946829 50.470470727186765, 18.381941666723034 19.567250592139274, 2.390837642830135 49.228045261718165, 2.152214146946829 50.470470727186765))");
-    }
+    runPtLocator(
+        Location::INTERIOR,
+        Coordinate(10, 10),
+        "POLYGON ((0 0, 0 20, 20 20, 20 0, 0 0))");
+}
+
+// 2 - Test complex ring
+template<>
+template<>
+void object::test<2>
+()
+{
+    runPtLocator(
+        Location::INTERIOR,
+        Coordinate(0, 0),
+        "POLYGON ((-40 80, -40 -80, 20 0, 20 -100, 40 40, 80 -80, 100 80, 140 -20, 120 140, 40 180,     60 40, 0 120, -20 -20, -40 80))");
+}
+
+// 3 - Comb tests
+template<>
+template<>
+void object::test<3>
+()
+{
+    runPtLocator(Location::BOUNDARY, Coordinate(0, 0), wkt_comb);
+    runPtLocator(Location::BOUNDARY, Coordinate(0, 1), wkt_comb);
+    // at vertex
+    runPtLocator(Location::BOUNDARY, Coordinate(4, 5), wkt_comb);
+    runPtLocator(Location::BOUNDARY, Coordinate(8, 5), wkt_comb);
+
+    // on horizontal segment
+    runPtLocator(Location::BOUNDARY, Coordinate(11, 5), wkt_comb);
+    // on vertical segment
+    runPtLocator(Location::BOUNDARY, Coordinate(30, 5), wkt_comb);
+    // on angled segment
+    runPtLocator(Location::BOUNDARY, Coordinate(22, 7), wkt_comb);
+
+    runPtLocator(Location::INTERIOR, Coordinate(1, 5), wkt_comb);
+    runPtLocator(Location::INTERIOR, Coordinate(5, 5), wkt_comb);
+    runPtLocator(Location::INTERIOR, Coordinate(1, 7), wkt_comb);
+
+    runPtLocator(Location::EXTERIOR, Coordinate(12, 10), wkt_comb);
+    runPtLocator(Location::EXTERIOR, Coordinate(16, 5), wkt_comb);
+    runPtLocator(Location::EXTERIOR, Coordinate(35, 5), wkt_comb);
+}
+
+
+// 4 - repeated points
+template<>
+template<>
+void object::test<4>
+()
+{
+    runPtLocator(Location::BOUNDARY, Coordinate(0, 0), wkt_rpts);
+    runPtLocator(Location::BOUNDARY, Coordinate(0, 1), wkt_rpts);
+    // at vertex
+    runPtLocator(Location::BOUNDARY, Coordinate(2, 5), wkt_rpts);
+    runPtLocator(Location::BOUNDARY, Coordinate(8, 5), wkt_rpts);
+    runPtLocator(Location::BOUNDARY, Coordinate(10, 5), wkt_rpts);
+
+    runPtLocator(Location::INTERIOR, Coordinate(1, 5), wkt_rpts);
+    runPtLocator(Location::INTERIOR, Coordinate(3, 5), wkt_rpts);
+}
+
+// 5 - robustness
+template<>
+template<>
+void object::test<5>
+()
+{
+    runPtLocatorDD(Location::EXTERIOR,
+                   Coordinate(25.374625374625374, 128.35564435564436),
+                   "POLYGON ((0.0 0.0, 0.0 172.0, 100.0 0.0, 0.0 0.0))");
+}
+
+// 6 - robustness
+template<>
+template<>
+void object::test<6>
+()
+{
+    runPtLocatorDD(Location::INTERIOR,
+                   Coordinate(97.96039603960396, 782.0),
+                   "POLYGON ((642.0 815.0, 69.0 764.0, 394.0 966.0, 642.0 815.0))");
+}
+
+// 7 - robustness
+template<>
+template<>
+void object::test<7>
+()
+{
+    runPtLocatorDD(Location::EXTERIOR,
+                   Coordinate(3.166572116932842, 48.5390194687463),
+                   "POLYGON ((2.152214146946829 50.470470727186765, 18.381941666723034 19.567250592139274, 2.390837642830135 49.228045261718165, 2.152214146946829 50.470470727186765))");
+}
 
 
 
diff --git a/tests/unit/algorithm/MinimumBoundingCircleTest.cpp b/tests/unit/algorithm/MinimumBoundingCircleTest.cpp
index bcc4185..17176b1 100644
--- a/tests/unit/algorithm/MinimumBoundingCircleTest.cpp
+++ b/tests/unit/algorithm/MinimumBoundingCircleTest.cpp
@@ -29,168 +29,177 @@
 #include <string>
 #include <memory>
 
-namespace tut
-{
-    //
-    // Test Group
-    //
-
-    // dummy data, not used
-    struct test_minimumboundingcircle_data {
-        typedef geos::geom::Geometry Geometry;
-        typedef geos::geom::Coordinate Coordinate;
-        typedef geos::geom::PrecisionModel PrecisionModel;
-        typedef geos::geom::GeometryFactory GeometryFactory;
-        typedef geos::algorithm::MinimumBoundingCircle MinimumBoundingCircle;
-
-        geos::io::WKTReader reader;
-        std::unique_ptr<Geometry> geom;
-        std::unique_ptr<Geometry> geomOut;
-        GeometryFactory::Ptr geomFact = GeometryFactory::create();
-
-        test_minimumboundingcircle_data()
-        {}
-
-        void doMinimumBoundingCircleTest(std::string wktIn, std::string wktOut,
-            geos::geom::Coordinate &centreOut, double radiusOut)
-        {
-
-            geom.reset(reader.read(wktIn));
-            MinimumBoundingCircle mbc(geom.get());
-            std::vector<Coordinate> exPts = mbc.getExtremalPoints();
-            std::unique_ptr<Geometry> actual(geomFact->createMultiPoint(exPts));
-            double actualRadius = mbc.getRadius();
-            geos::geom::Coordinate actualCentre = mbc.getCentre();
-
-            geomOut.reset(reader.read(wktOut));
-            bool isEqual = actual->equals(geomOut.get());
-
-            // need this hack because apparently equals does not work for MULTIPOINT EMPTY
-            if (geomOut->isEmpty() && geom->isEmpty())
-                isEqual = true;
-            if (!isEqual) {
-                std::cout << "Centre = " << actualCentre << " Radius = " << actualRadius << " isEqual = " << isEqual << std::endl;
-                std::cout << "Actual:"   << std::endl << actual->toString() << std::endl;
-                std::cout << "Expected:" << std::endl << geomOut->toString() << std::endl;
-            }
-            ensure(isEqual);
-
-            if (centreOut.isNull()) {
-                ensure(centreOut.distance(actualCentre) < 0.0001);
-            }
-            if (radiusOut >= 0) {
-                ensure(fabs(radiusOut - actualRadius) < 0.0001);
-            }
-        }
-
-        void doMinimumBoundingCircleTest(std::string wktIn, std::string wktOut)
-        {
-            geos::geom::Coordinate c;
-            c.setNull();
-            doMinimumBoundingCircleTest(wktIn, wktOut, c, -1.0);
-        }
-
-    };
+namespace tut {
+//
+// Test Group
+//
 
-    typedef test_group<test_minimumboundingcircle_data> group;
-    typedef group::object object;
+// dummy data, not used
+struct test_minimumboundingcircle_data {
+    typedef geos::geom::Geometry Geometry;
+    typedef geos::geom::Coordinate Coordinate;
+    typedef geos::geom::PrecisionModel PrecisionModel;
+    typedef geos::geom::GeometryFactory GeometryFactory;
+    typedef geos::algorithm::MinimumBoundingCircle MinimumBoundingCircle;
+
+    geos::io::WKTReader reader;
+    std::unique_ptr<Geometry> geom;
+    std::unique_ptr<Geometry> geomOut;
+    GeometryFactory::Ptr geomFact = GeometryFactory::create();
+
+    test_minimumboundingcircle_data()
+    {}
+
+    void
+    doMinimumBoundingCircleTest(std::string wktIn, std::string wktOut,
+                                geos::geom::Coordinate& centreOut, double radiusOut)
+    {
 
-    group test_minimumboundingcircle_group("geos::algorithm::MinimumBoundingCircle");
+        geom.reset(reader.read(wktIn));
+        MinimumBoundingCircle mbc(geom.get());
+        std::vector<Coordinate> exPts = mbc.getExtremalPoints();
+        std::unique_ptr<Geometry> actual(geomFact->createMultiPoint(exPts));
+        double actualRadius = mbc.getRadius();
+        geos::geom::Coordinate actualCentre = mbc.getCentre();
 
+        geomOut.reset(reader.read(wktOut));
+        bool isEqual = actual->equals(geomOut.get());
 
+        // need this hack because apparently equals does not work for MULTIPOINT EMPTY
+        if(geomOut->isEmpty() && geom->isEmpty()) {
+            isEqual = true;
+        }
+        if(!isEqual) {
+            std::cout << "Centre = " << actualCentre << " Radius = " << actualRadius << " isEqual = " << isEqual << std::endl;
+            std::cout << "Actual:"   << std::endl << actual->toString() << std::endl;
+            std::cout << "Expected:" << std::endl << geomOut->toString() << std::endl;
+        }
+        ensure(isEqual);
 
+        if(centreOut.isNull()) {
+            ensure(centreOut.distance(actualCentre) < 0.0001);
+        }
+        if(radiusOut >= 0) {
+            ensure(fabs(radiusOut - actualRadius) < 0.0001);
+        }
+    }
 
+    void
+    doMinimumBoundingCircleTest(std::string wktIn, std::string wktOut)
+    {
+        geos::geom::Coordinate c;
+        c.setNull();
+        doMinimumBoundingCircleTest(wktIn, wktOut, c, -1.0);
+    }
 
+};
 
-    //
-    // Test Cases
-    //
+typedef test_group<test_minimumboundingcircle_data> group;
+typedef group::object object;
 
+group test_minimumboundingcircle_group("geos::algorithm::MinimumBoundingCircle");
 
-    template<>
-    template<>
-    void object::test<1>()
-    {
-        Coordinate c(10, 10);
-        doMinimumBoundingCircleTest(
-            "POINT (10 10)",
-            "POINT (10 10)",
-            c,
-            0);
 
-    }
 
-    template<>
-    template<>
-    void object::test<2>()
-    {
-        Coordinate c(15, 15);
-        doMinimumBoundingCircleTest(
-            "MULTIPOINT ((10 10), (20 20))",
-            "MULTIPOINT ((10 10), (20 20))",
-            c,
-            7.0710678118654755);
-    }
 
-    template<>
-    template<>
-    void object::test<3>()
-    {
-        Coordinate c(20, 20);
-        doMinimumBoundingCircleTest(
-            "MULTIPOINT ((10 10), (20 20), (30 30))",
-            "MULTIPOINT ((10 10), (30 30))",
-            c,
-            14.142135623730951);
-    }
 
-    template<>
-    template<>
-    void object::test<4>()
-    {
-        Coordinate c(15, 15);
-        doMinimumBoundingCircleTest(
-            "MULTIPOINT ((10 10), (20 20), (10 20))",
-            "MULTIPOINT ((10 10), (20 20), (10 20))",
-            c,
-            7.0710678118654755);
-    }
 
-    template<>
-    template<>
-    void object::test<5>()
-    {
-        Coordinate c(150, 100);
-        doMinimumBoundingCircleTest(
-            "POLYGON ((100 100, 200 100, 150 90, 100 100))",
-            "MULTIPOINT ((100 100), (200 100))",
-            c,
-            50);
-    }
+//
+// Test Cases
+//
 
-    template<>
-    template<>
-    void object::test<6>()
-    {
-        Coordinate c(15, 15);
-        doMinimumBoundingCircleTest(
-            "MULTIPOINT ((10 10), (20 20), (10 20), (15 19))",
-            "MULTIPOINT ((10 10), (20 20), (10 20))",
-            c,
-            7.0710678118654755);
-    }
 
-    template<>
-    template<>
-    void object::test<7>()
-    {
-        Coordinate c(26284.84180271327, 65267.114509082545);
-        doMinimumBoundingCircleTest(
-            "POLYGON ((26426 65078, 26531 65242, 26096 65427, 26075 65136, 26426 65078))",
-            "MULTIPOINT ((26531 65242), (26075 65136), (26096 65427))",
-            c,
-            247.4360455914027);
-    }
+template<>
+template<>
+void object::test<1>
+()
+{
+    Coordinate c(10, 10);
+    doMinimumBoundingCircleTest(
+        "POINT (10 10)",
+        "POINT (10 10)",
+        c,
+        0);
+
+}
+
+template<>
+template<>
+void object::test<2>
+()
+{
+    Coordinate c(15, 15);
+    doMinimumBoundingCircleTest(
+        "MULTIPOINT ((10 10), (20 20))",
+        "MULTIPOINT ((10 10), (20 20))",
+        c,
+        7.0710678118654755);
+}
+
+template<>
+template<>
+void object::test<3>
+()
+{
+    Coordinate c(20, 20);
+    doMinimumBoundingCircleTest(
+        "MULTIPOINT ((10 10), (20 20), (30 30))",
+        "MULTIPOINT ((10 10), (30 30))",
+        c,
+        14.142135623730951);
+}
+
+template<>
+template<>
+void object::test<4>
+()
+{
+    Coordinate c(15, 15);
+    doMinimumBoundingCircleTest(
+        "MULTIPOINT ((10 10), (20 20), (10 20))",
+        "MULTIPOINT ((10 10), (20 20), (10 20))",
+        c,
+        7.0710678118654755);
+}
+
+template<>
+template<>
+void object::test<5>
+()
+{
+    Coordinate c(150, 100);
+    doMinimumBoundingCircleTest(
+        "POLYGON ((100 100, 200 100, 150 90, 100 100))",
+        "MULTIPOINT ((100 100), (200 100))",
+        c,
+        50);
+}
+
+template<>
+template<>
+void object::test<6>
+()
+{
+    Coordinate c(15, 15);
+    doMinimumBoundingCircleTest(
+        "MULTIPOINT ((10 10), (20 20), (10 20), (15 19))",
+        "MULTIPOINT ((10 10), (20 20), (10 20))",
+        c,
+        7.0710678118654755);
+}
+
+template<>
+template<>
+void object::test<7>
+()
+{
+    Coordinate c(26284.84180271327, 65267.114509082545);
+    doMinimumBoundingCircleTest(
+        "POLYGON ((26426 65078, 26531 65242, 26096 65427, 26075 65136, 26426 65078))",
+        "MULTIPOINT ((26531 65242), (26075 65136), (26096 65427))",
+        c,
+        247.4360455914027);
+}
 
 
 
diff --git a/tests/unit/algorithm/MinimumDiameterTest.cpp b/tests/unit/algorithm/MinimumDiameterTest.cpp
index d05470c..bf36579 100644
--- a/tests/unit/algorithm/MinimumDiameterTest.cpp
+++ b/tests/unit/algorithm/MinimumDiameterTest.cpp
@@ -27,210 +27,220 @@
 #include <string>
 #include <memory>
 
-namespace tut
+namespace tut {
+//
+// Test Group
+//
+
+// dummy data, not used
+struct test_minimumdiameter_data {
+    typedef geos::geom::Geometry Geometry;
+    typedef std::unique_ptr<geos::geom::Geometry> GeomPtr;
+
+    typedef geos::geom::Coordinate Coordinate;
+    typedef geos::algorithm::MinimumDiameter MinimumDiameter;
+
+    geos::io::WKTReader reader;
+    std::unique_ptr<Geometry> geom;
+
+    test_minimumdiameter_data()
+    {}
+
+};
+
+typedef test_group<test_minimumdiameter_data> group;
+typedef group::object object;
+
+group test_minimumdiameter_data_group("geos::algorithm::MinimumDiameter");
+
+//
+// Test Cases
+//
+
+// Test of getMinimumRectangle
+template<>
+template<>
+void object::test<1>
+()
 {
-    //
-    // Test Group
-    //
-
-    // dummy data, not used
-    struct test_minimumdiameter_data {
-      typedef geos::geom::Geometry Geometry;
-      typedef std::unique_ptr<geos::geom::Geometry> GeomPtr;
-
-      typedef geos::geom::Coordinate Coordinate;
-      typedef geos::algorithm::MinimumDiameter MinimumDiameter;
-
-      geos::io::WKTReader reader;
-      std::unique_ptr<Geometry> geom;
-
-      test_minimumdiameter_data()
-      {}
-
-    };
-
-    typedef test_group<test_minimumdiameter_data> group;
-    typedef group::object object;
-
-    group test_minimumdiameter_data_group("geos::algorithm::MinimumDiameter");
-
-    //
-    // Test Cases
-    //
-
-    // Test of getMinimumRectangle
-    template<>
-    template<>
-    void object::test<1>()
-    {
-        GeomPtr p_geom(reader.read("POLYGON ((0 0, 0 20, 20 20, 20 0, 0 0))"));
-        ensure(nullptr != p_geom.get());
-
-        geos::algorithm::MinimumDiameter m(p_geom.get());
-        GeomPtr minRect( m.getMinimumRectangle() );
-        ensure(nullptr != minRect.get());
-
-        GeomPtr expectedGeom(reader.read("POLYGON ((0 0, 20 0, 20 20, 0 20, 0 0))"));
-        ensure(nullptr != expectedGeom.get());
-
-        ensure( minRect.get()->equalsExact(expectedGeom.get()) );
-    }
-
-    // Test with expected rotated rectangle
-    template<>
-    template<>
-    void object::test<2>()
-    {
-        GeomPtr p_geom(reader.read("POLYGON ((0 5, 5 10, 10 5, 5 0, 0 5))"));
-        ensure(nullptr != p_geom.get());
-
-        geos::algorithm::MinimumDiameter m(p_geom.get());
-        GeomPtr minRect( m.getMinimumRectangle() );
-        ensure(nullptr != minRect.get());
-
-        GeomPtr expectedGeom(reader.read("POLYGON ((5 0, 10 5, 5 10, 0 5, 5 0))"));
-        ensure(nullptr != expectedGeom.get());
-
-        ensure( minRect.get()->equalsExact(expectedGeom.get()) );
-    }
-
-    // Test with EMPTY input
-    template<>
-    template<>
-    void object::test<3>()
-    {
-        GeomPtr p_geom(reader.read("POLYGON EMPTY"));
-        ensure(nullptr != p_geom.get());
-
-        geos::algorithm::MinimumDiameter m(p_geom.get());
-        GeomPtr minRect( m.getMinimumRectangle() );
-        ensure(nullptr != minRect.get());
-
-        GeomPtr expectedGeom(reader.read("POLYGON EMPTY"));
-        ensure(nullptr != expectedGeom.get());
-
-        ensure( minRect.get()->equalsExact(expectedGeom.get()) );
-    }
-
-    // Test with Point input
-    template<>
-    template<>
-    void object::test<4>()
-    {
-        GeomPtr p_geom(reader.read("Point(1 2)"));
-        ensure(nullptr != p_geom.get());
-
-        geos::algorithm::MinimumDiameter m(p_geom.get());
-        GeomPtr minRect( m.getMinimumRectangle() );
-        ensure(nullptr != minRect.get());
-
-        GeomPtr expectedGeom(reader.read("Point(1 2)"));
-        ensure(nullptr != expectedGeom.get());
-
-        ensure( minRect.get()->equalsExact(expectedGeom.get()) );
-    }
-
-    // Test with LineString input
-    template<>
-    template<>
-    void object::test<5>()
-    {
-        GeomPtr p_geom(reader.read("LineString(1 2, 2 4)"));
-        ensure(nullptr != p_geom.get());
-
-        geos::algorithm::MinimumDiameter m(p_geom.get());
-        GeomPtr minRect( m.getMinimumRectangle() );
-        ensure(nullptr != minRect.get());
-
-        GeomPtr expectedGeom(reader.read("LineString(1 2, 2 4)"));
-        ensure(nullptr != expectedGeom.get());
-
-        ensure( minRect.get()->equalsExact(expectedGeom.get()) );
-    }
-
-    // Test minimumDiameter with Point input
-    template<>
-    template<>
-    void object::test<6>()
-    {
-        GeomPtr p_geom(reader.read("POINT (0 240)"));
-        ensure(nullptr != p_geom.get());
-
-        GeomPtr minDiameter( geos::algorithm::MinimumDiameter::getMinimumDiameter( p_geom.get() ) );
-        ensure(nullptr != minDiameter.get());
-
-        GeomPtr expectedGeom(reader.read("LineString (0 240, 0 240)"));
-        ensure(nullptr != expectedGeom.get());
-
-        ensure( minDiameter.get()->equalsExact(expectedGeom.get()) );
-    }
-
-    // Test minimumDiameter with LineString input
-    template<>
-    template<>
-    void object::test<7>()
-    {
-        GeomPtr p_geom(reader.read("LINESTRING (0 240, 220 240)"));
-        ensure(nullptr != p_geom.get());
-
-        GeomPtr minDiameter( geos::algorithm::MinimumDiameter::getMinimumDiameter( p_geom.get() ) );
-        ensure(nullptr != minDiameter.get());
-
-        GeomPtr expectedGeom(reader.read("LINESTRING (0 240, 0 240)"));
-        ensure(nullptr != expectedGeom.get());
-
-        ensure( minDiameter.get()->equalsExact(expectedGeom.get()) );
-    }
-
-    // Test minimumDiameter with Polygon input
-    template<>
-    template<>
-    void object::test<8>()
-    {
-        GeomPtr p_geom(reader.read("POLYGON ((0 240, 220 240, 220 0, 0 0, 0 240))"));
-        ensure(nullptr != p_geom.get());
-
-        GeomPtr minDiameter( geos::algorithm::MinimumDiameter::getMinimumDiameter( p_geom.get() ) );
-        ensure(nullptr != minDiameter.get());
-
-        GeomPtr expectedGeom(reader.read("LINESTRING (0 0, 220 0)"));
-        ensure(nullptr != expectedGeom.get());
-
-        ensure( minDiameter.get()->equalsExact(expectedGeom.get()) );
-    }
-
-    // Test minimumDiameter with Polygon input
-    template<>
-    template<>
-    void object::test<9>()
-    {
-        GeomPtr p_geom(reader.read("POLYGON ((0 240, 160 140, 220 0, 0 0, 0 240))"));
-        ensure(nullptr != p_geom.get());
-
-        GeomPtr minDiameter( geos::algorithm::MinimumDiameter::getMinimumDiameter( p_geom.get() ) );
-        ensure(nullptr != minDiameter.get());
-
-        GeomPtr expectedGeom(reader.read("LINESTRING (185.86206896551724 79.65517241379311, 0 0)"));
-        ensure(nullptr != expectedGeom.get());
-
-        ensure( minDiameter.get()->equalsExact(expectedGeom.get(), 0.00000000001) );
-    }
-
-    // Test minimumDiameter with complex LineString
-    template<>
-    template<>
-    void object::test<10>()
-    {
-        GeomPtr p_geom(reader.read("LINESTRING ( 39 119, 162 197, 135 70, 95 35, 33 66, 111 82, 97 131, 48 160, -4 182, 57 195, 94 202, 90 174, 75 134, 47 114, 0 100, 59 81, 123 60, 136 43, 163 75, 145 114, 93 136, 92 159, 105 175 )"));
-        ensure(nullptr != p_geom.get());
-
-        GeomPtr minDiameter( geos::algorithm::MinimumDiameter::getMinimumDiameter( p_geom.get() ) );
-        ensure(nullptr != minDiameter.get());
-
-        GeomPtr expectedGeom(reader.read("LINESTRING (64.46262341325811 196.41184767277855, 95 35)"));
-        ensure(nullptr != expectedGeom.get());
-
-        ensure( minDiameter.get()->equalsExact(expectedGeom.get(), 0.00000000001) );
-    }
+    GeomPtr p_geom(reader.read("POLYGON ((0 0, 0 20, 20 20, 20 0, 0 0))"));
+    ensure(nullptr != p_geom.get());
+
+    geos::algorithm::MinimumDiameter m(p_geom.get());
+    GeomPtr minRect(m.getMinimumRectangle());
+    ensure(nullptr != minRect.get());
+
+    GeomPtr expectedGeom(reader.read("POLYGON ((0 0, 20 0, 20 20, 0 20, 0 0))"));
+    ensure(nullptr != expectedGeom.get());
+
+    ensure(minRect.get()->equalsExact(expectedGeom.get()));
+}
+
+// Test with expected rotated rectangle
+template<>
+template<>
+void object::test<2>
+()
+{
+    GeomPtr p_geom(reader.read("POLYGON ((0 5, 5 10, 10 5, 5 0, 0 5))"));
+    ensure(nullptr != p_geom.get());
+
+    geos::algorithm::MinimumDiameter m(p_geom.get());
+    GeomPtr minRect(m.getMinimumRectangle());
+    ensure(nullptr != minRect.get());
+
+    GeomPtr expectedGeom(reader.read("POLYGON ((5 0, 10 5, 5 10, 0 5, 5 0))"));
+    ensure(nullptr != expectedGeom.get());
+
+    ensure(minRect.get()->equalsExact(expectedGeom.get()));
+}
+
+// Test with EMPTY input
+template<>
+template<>
+void object::test<3>
+()
+{
+    GeomPtr p_geom(reader.read("POLYGON EMPTY"));
+    ensure(nullptr != p_geom.get());
+
+    geos::algorithm::MinimumDiameter m(p_geom.get());
+    GeomPtr minRect(m.getMinimumRectangle());
+    ensure(nullptr != minRect.get());
+
+    GeomPtr expectedGeom(reader.read("POLYGON EMPTY"));
+    ensure(nullptr != expectedGeom.get());
+
+    ensure(minRect.get()->equalsExact(expectedGeom.get()));
+}
+
+// Test with Point input
+template<>
+template<>
+void object::test<4>
+()
+{
+    GeomPtr p_geom(reader.read("Point(1 2)"));
+    ensure(nullptr != p_geom.get());
+
+    geos::algorithm::MinimumDiameter m(p_geom.get());
+    GeomPtr minRect(m.getMinimumRectangle());
+    ensure(nullptr != minRect.get());
+
+    GeomPtr expectedGeom(reader.read("Point(1 2)"));
+    ensure(nullptr != expectedGeom.get());
+
+    ensure(minRect.get()->equalsExact(expectedGeom.get()));
+}
+
+// Test with LineString input
+template<>
+template<>
+void object::test<5>
+()
+{
+    GeomPtr p_geom(reader.read("LineString(1 2, 2 4)"));
+    ensure(nullptr != p_geom.get());
+
+    geos::algorithm::MinimumDiameter m(p_geom.get());
+    GeomPtr minRect(m.getMinimumRectangle());
+    ensure(nullptr != minRect.get());
+
+    GeomPtr expectedGeom(reader.read("LineString(1 2, 2 4)"));
+    ensure(nullptr != expectedGeom.get());
+
+    ensure(minRect.get()->equalsExact(expectedGeom.get()));
+}
+
+// Test minimumDiameter with Point input
+template<>
+template<>
+void object::test<6>
+()
+{
+    GeomPtr p_geom(reader.read("POINT (0 240)"));
+    ensure(nullptr != p_geom.get());
+
+    GeomPtr minDiameter(geos::algorithm::MinimumDiameter::getMinimumDiameter(p_geom.get()));
+    ensure(nullptr != minDiameter.get());
+
+    GeomPtr expectedGeom(reader.read("LineString (0 240, 0 240)"));
+    ensure(nullptr != expectedGeom.get());
+
+    ensure(minDiameter.get()->equalsExact(expectedGeom.get()));
+}
+
+// Test minimumDiameter with LineString input
+template<>
+template<>
+void object::test<7>
+()
+{
+    GeomPtr p_geom(reader.read("LINESTRING (0 240, 220 240)"));
+    ensure(nullptr != p_geom.get());
+
+    GeomPtr minDiameter(geos::algorithm::MinimumDiameter::getMinimumDiameter(p_geom.get()));
+    ensure(nullptr != minDiameter.get());
+
+    GeomPtr expectedGeom(reader.read("LINESTRING (0 240, 0 240)"));
+    ensure(nullptr != expectedGeom.get());
+
+    ensure(minDiameter.get()->equalsExact(expectedGeom.get()));
+}
+
+// Test minimumDiameter with Polygon input
+template<>
+template<>
+void object::test<8>
+()
+{
+    GeomPtr p_geom(reader.read("POLYGON ((0 240, 220 240, 220 0, 0 0, 0 240))"));
+    ensure(nullptr != p_geom.get());
+
+    GeomPtr minDiameter(geos::algorithm::MinimumDiameter::getMinimumDiameter(p_geom.get()));
+    ensure(nullptr != minDiameter.get());
+
+    GeomPtr expectedGeom(reader.read("LINESTRING (0 0, 220 0)"));
+    ensure(nullptr != expectedGeom.get());
+
+    ensure(minDiameter.get()->equalsExact(expectedGeom.get()));
+}
+
+// Test minimumDiameter with Polygon input
+template<>
+template<>
+void object::test<9>
+()
+{
+    GeomPtr p_geom(reader.read("POLYGON ((0 240, 160 140, 220 0, 0 0, 0 240))"));
+    ensure(nullptr != p_geom.get());
+
+    GeomPtr minDiameter(geos::algorithm::MinimumDiameter::getMinimumDiameter(p_geom.get()));
+    ensure(nullptr != minDiameter.get());
+
+    GeomPtr expectedGeom(reader.read("LINESTRING (185.86206896551724 79.65517241379311, 0 0)"));
+    ensure(nullptr != expectedGeom.get());
+
+    ensure(minDiameter.get()->equalsExact(expectedGeom.get(), 0.00000000001));
+}
+
+// Test minimumDiameter with complex LineString
+template<>
+template<>
+void object::test<10>
+()
+{
+    GeomPtr p_geom(
+        reader.read("LINESTRING ( 39 119, 162 197, 135 70, 95 35, 33 66, 111 82, 97 131, 48 160, -4 182, 57 195, 94 202, 90 174, 75 134, 47 114, 0 100, 59 81, 123 60, 136 43, 163 75, 145 114, 93 136, 92 159, 105 175 )"));
+    ensure(nullptr != p_geom.get());
+
+    GeomPtr minDiameter(geos::algorithm::MinimumDiameter::getMinimumDiameter(p_geom.get()));
+    ensure(nullptr != minDiameter.get());
+
+    GeomPtr expectedGeom(reader.read("LINESTRING (64.46262341325811 196.41184767277855, 95 35)"));
+    ensure(nullptr != expectedGeom.get());
+
+    ensure(minDiameter.get()->equalsExact(expectedGeom.get(), 0.00000000001));
+}
 
 } // namespace tut
diff --git a/tests/unit/algorithm/OrientationIndexFailureTest.cpp b/tests/unit/algorithm/OrientationIndexFailureTest.cpp
index ddd20c2..c941933 100644
--- a/tests/unit/algorithm/OrientationIndexFailureTest.cpp
+++ b/tests/unit/algorithm/OrientationIndexFailureTest.cpp
@@ -14,117 +14,125 @@
 using namespace geos::geom;
 using namespace geos::algorithm;
 
-namespace tut
-{
-	//
-	// Test Group
-	//
-	struct test_orientation_data {
-		Coordinate c1;
-		Coordinate c2;
-		Coordinate c3;
+namespace tut {
+//
+// Test Group
+//
+struct test_orientation_data {
+    Coordinate c1;
+    Coordinate c2;
+    Coordinate c3;
 
-		test_orientation_data() {};
+    test_orientation_data() {};
 
-	};
+};
 
-	static int checkOrientation(Coordinate &c1, Coordinate &c2, Coordinate &c3)
-	{
-        int orient0 = Orientation::index(c1, c2, c3);
-        int orient1 = Orientation::index(c2, c3, c1);
-        int orient2 = Orientation::index(c3, c1, c2);
-        return (orient0 == orient1) && (orient0 == orient2);
-	}
+static int
+checkOrientation(Coordinate& c1, Coordinate& c2, Coordinate& c3)
+{
+    int orient0 = Orientation::index(c1, c2, c3);
+    int orient1 = Orientation::index(c2, c3, c1);
+    int orient2 = Orientation::index(c3, c1, c2);
+    return (orient0 == orient1) && (orient0 == orient2);
+}
 
 
-	typedef test_group<test_orientation_data> group;
-	typedef group::object object;
+typedef test_group<test_orientation_data> group;
+typedef group::object object;
 
-	group test_orientation_group("geos::algorithm::OrientationIndexFailure");
+group test_orientation_group("geos::algorithm::OrientationIndexFailure");
 
-	//
-	// Test Cases
-	//
+//
+// Test Cases
+//
 
-	template<>
-	template<>
-	void object::test<1>()
-	{
+template<>
+template<>
+void object::test<1>
+()
+{
     c1 = Coordinate(1.4540766091864998, -7.989685402102996);
     c2 = Coordinate(23.131039116367354, -7.004368924503866);
     c3 = Coordinate(1.4540766091865, -7.989685402102996);
     ensure_equals("ring orientation test 1 failed", checkOrientation(c1, c2, c3), 1);
-	}
-
-	template<>
-	template<>
-	void object::test<2>()
-	{
-		c1 = Coordinate(219.3649559090992, 140.84159161824724);
-		c2 = Coordinate(168.9018919682399, -5.713787599646864);
-		c3 = Coordinate(186.80814046338352, 46.28973405831556);
+}
+
+template<>
+template<>
+void object::test<2>
+()
+{
+    c1 = Coordinate(219.3649559090992, 140.84159161824724);
+    c2 = Coordinate(168.9018919682399, -5.713787599646864);
+    c3 = Coordinate(186.80814046338352, 46.28973405831556);
     ensure_equals("ring orientation test 2 failed", checkOrientation(c1, c2, c3), 1);
-	}
+}
 
-	template<>
-	template<>
-	void object::test<3>()
-	{
+template<>
+template<>
+void object::test<3>
+()
+{
     c1 = Coordinate(279.56857838488514, -186.3790522565901);
     c2 = Coordinate(-20.43142161511487, 13.620947743409914);
     c3 = Coordinate(0, 0);
     ensure_equals("ring orientation test 3 failed", checkOrientation(c1, c2, c3), 1);
-	}
+}
 
-	template<>
-	template<>
-	void object::test<4>()
-	{
+template<>
+template<>
+void object::test<4>
+()
+{
     c1 = Coordinate(-26.2, 188.7);
     c2 = Coordinate(37.0, 290.7);
     c3 = Coordinate(21.2, 265.2);
     ensure_equals("ring orientation test 4 failed", checkOrientation(c1, c2, c3), 1);
-	}
+}
 
-	template<>
-	template<>
-	void object::test<5>()
-	{
+template<>
+template<>
+void object::test<5>
+()
+{
     c1 = Coordinate(-5.9, 163.1);
     c2 = Coordinate(76.1, 250.7);
     c3 = Coordinate(14.6, 185);
     ensure_equals("ring orientation test 5 failed", checkOrientation(c1, c2, c3), 1);
-	}
+}
 
-	template<>
-	template<>
-	void object::test<6>()
-	{
+template<>
+template<>
+void object::test<6>
+()
+{
     c1 = Coordinate(-0.9575, 0.4511);
     c2 = Coordinate(-0.9295, 0.3291);
     c3 = Coordinate(-0.8945, 0.1766);
     ensure_equals("ring orientation test 6 failed", checkOrientation(c1, c2, c3), 1);
-	}
+}
 
-	template<>
-	template<>
-	void object::test<7>()
-	{
+template<>
+template<>
+void object::test<7>
+()
+{
     c1 = Coordinate(-9575, 4511);
     c2 = Coordinate(-9295, 3291);
     c3 = Coordinate(-8945, 1766);
     ensure_equals("ring orientation test 7 failed", checkOrientation(c1, c2, c3), 1);
-	}
+}
 
-	template<>
-	template<>
-	void object::test<8>()
-	{
+template<>
+template<>
+void object::test<8>
+()
+{
     c1 = Coordinate(-140.8859438214298, 140.88594382142983);
     c2 = Coordinate(-57.309236848216706, 57.30923684821671);
     c3 = Coordinate(-190.9188309203678, 190.91883092036784);
     ensure_equals("ring orientation test 8 failed", checkOrientation(c1, c2, c3), 1);
-	}
+}
 
 
 } // namespace tut
diff --git a/tests/unit/algorithm/PointLocatorTest.cpp b/tests/unit/algorithm/PointLocatorTest.cpp
index 25e0e28..5168448 100644
--- a/tests/unit/algorithm/PointLocatorTest.cpp
+++ b/tests/unit/algorithm/PointLocatorTest.cpp
@@ -16,95 +16,100 @@
 #include <memory>
 
 namespace geos {
-	namespace geom {
-		class Geometry;
-	}
+namespace geom {
+class Geometry;
+}
 }
 
 using namespace geos::geom; // for Location
 
-namespace tut
+namespace tut {
+//
+// Test Group
+//
+
+// dummy data, not used
+struct test_pointlocator_data {};
+
+typedef test_group<test_pointlocator_data> group;
+typedef group::object object;
+
+group test_pointlocator_group("geos::algorithm::PointLocator");
+
+// These are static to avoid namespace pollution
+// The struct test_*_data above is probably there
+// for the same reason...
+//
+static PrecisionModel pm;
+static GeometryFactory::Ptr gf = GeometryFactory::create(&pm);
+static geos::io::WKTReader reader(gf.get());
+
+typedef std::unique_ptr<Geometry> GeomPtr;
+
+void
+runPtLocator(int expected, const Coordinate& pt,
+             const std::string& wkt)
+{
+    GeomPtr geom(reader.read(wkt));
+    geos::algorithm::PointLocator pointLocator;
+    int loc = pointLocator.locate(pt, geom.get());
+    ensure_equals(loc, expected);
+}
+
+
+//
+// Test Cases
+//
+
+// 1 - Test box
+template<>
+template<>
+void object::test<1>
+()
+{
+    runPtLocator(Location::INTERIOR, Coordinate(10, 10),
+                 "POLYGON ((0 0, 0 20, 20 20, 20 0, 0 0))");
+}
+
+// 2 - Test complex ring
+template<>
+template<>
+void object::test<2>
+()
+{
+    runPtLocator(Location::INTERIOR, Coordinate(0, 0),
+                 "POLYGON ((-40 80, -40 -80, 20 0, 20 -100, 40 40, 80 -80, 100 80, 140 -20, 120 140, 40 180,     60 40, 0 120, -20 -20, -40 80))");
+}
+
+// 3 - Test PointLocator LinearRing LineString
+template<>
+template<>
+void object::test<3>
+()
 {
-	//
-	// Test Group
-	//
-
-	// dummy data, not used
-	struct test_pointlocator_data {};
-
-	typedef test_group<test_pointlocator_data> group;
-	typedef group::object object;
-
-	group test_pointlocator_group("geos::algorithm::PointLocator");
-
-	// These are static to avoid namespace pollution
-	// The struct test_*_data above is probably there
-	// for the same reason...
-	//
-	static PrecisionModel pm;
-	static GeometryFactory::Ptr gf = GeometryFactory::create(&pm);
-	static geos::io::WKTReader reader(gf.get());
-
-	typedef std::unique_ptr<Geometry> GeomPtr;
-
-	void runPtLocator(int expected, const Coordinate& pt,
-			const std::string& wkt)
-	{
-		GeomPtr geom(reader.read(wkt));
-		geos::algorithm::PointLocator pointLocator;
-		int loc = pointLocator.locate(pt, geom.get());
-		ensure_equals(loc, expected);
-	}
-
-
-	//
-	// Test Cases
-	//
-
-	// 1 - Test box
-	template<>
-	template<>
-	void object::test<1>()
-	{
-		runPtLocator(Location::INTERIOR, Coordinate(10, 10),
-		    "POLYGON ((0 0, 0 20, 20 20, 20 0, 0 0))");
-	}
-
-	// 2 - Test complex ring
-	template<>
-	template<>
-	void object::test<2>()
-	{
-		runPtLocator(Location::INTERIOR, Coordinate(0, 0),
-			"POLYGON ((-40 80, -40 -80, 20 0, 20 -100, 40 40, 80 -80, 100 80, 140 -20, 120 140, 40 180,     60 40, 0 120, -20 -20, -40 80))");
-	}
-
-	// 3 - Test PointLocator LinearRing LineString
-	template<>
-	template<>
-	void object::test<3>()
-	{
-		runPtLocator(Location::BOUNDARY, Coordinate(0, 0),
-                     "GEOMETRYCOLLECTION( LINESTRING(0 0, 10 10), LINEARRING(10 10, 10 20, 20 10, 10 10))");
-	}
-
-	// 4 - Test PointLocator Point inside LinearRing
-	template<>
-	template<>
-	void object::test<4>()
-	{
-	    runPtLocator(Location::EXTERIOR, Coordinate(11, 11),
-	                     "LINEARRING(10 10, 10 20, 20 10, 10 10)");
-	}
-
-	// 5 - TestPointLocator Point inside MultiPoint
-	template<>
-	template<>
-	void object::test<5>()
-	{
-		runPtLocator(Location::INTERIOR, Coordinate(0, 0),
-				"MULTIPOINT ((1 1), (0 0))");
-	}
+    runPtLocator(Location::BOUNDARY, Coordinate(0, 0),
+                 "GEOMETRYCOLLECTION( LINESTRING(0 0, 10 10), LINEARRING(10 10, 10 20, 20 10, 10 10))");
+}
+
+// 4 - Test PointLocator Point inside LinearRing
+template<>
+template<>
+void object::test<4>
+()
+{
+    runPtLocator(Location::EXTERIOR, Coordinate(11, 11),
+                 "LINEARRING(10 10, 10 20, 20 10, 10 10)");
+}
+
+// 5 - TestPointLocator Point inside MultiPoint
+template<>
+template<>
+void object::test<5>
+()
+{
+    runPtLocator(Location::INTERIOR, Coordinate(0, 0),
+                 "MULTIPOINT ((1 1), (0 0))");
+}
 
 } // namespace tut
 
diff --git a/tests/unit/algorithm/RobustLineIntersectionTest.cpp b/tests/unit/algorithm/RobustLineIntersectionTest.cpp
index f3c248d..d637139 100644
--- a/tests/unit/algorithm/RobustLineIntersectionTest.cpp
+++ b/tests/unit/algorithm/RobustLineIntersectionTest.cpp
@@ -16,452 +16,468 @@
 #include <memory>
 
 namespace geos {
-	namespace geom {
-		class Geometry;
-	}
+namespace geom {
+class Geometry;
+}
 }
 
 using namespace geos::geom; //
 
-namespace tut
-{
-	//
-	// Test Group
-	//
-
-	struct test_robustlineintersection_data
-	{
-	typedef std::unique_ptr<Geometry> GeomPtr;
-
-	bool equals(const Coordinate& p0, const Coordinate& p1,
-	            double distanceTolerance)
-        {
-                return p0.distance(p1) <= distanceTolerance;
-        }
+namespace tut {
+//
+// Test Group
+//
+
+struct test_robustlineintersection_data {
+    typedef std::unique_ptr<Geometry> GeomPtr;
 
-	void checkIntPoints(const Coordinate& p, const Coordinate& q,
-	                   double distanceTolerance)
-        {
-                bool isEqual = equals(p, q, distanceTolerance);
-		ensure("checkIntPoints: expected: " + p.toString() + " obtained " + q.toString(), isEqual);
+    bool
+    equals(const Coordinate& p0, const Coordinate& p1,
+           double distanceTolerance)
+    {
+        return p0.distance(p1) <= distanceTolerance;
+    }
+
+    void
+    checkIntPoints(const Coordinate& p, const Coordinate& q,
+                   double distanceTolerance)
+    {
+        bool isEqual = equals(p, q, distanceTolerance);
+        ensure("checkIntPoints: expected: " + p.toString() + " obtained " + q.toString(), isEqual);
+    }
+
+    /**
+     *
+     * @param pt array of 4 Coordinates
+     * @param expectedIntersectionNum
+     * @param intPt the expected intersection points
+     *              (maybe null if not tested)
+     *              must contain at least expectedIntersectionNum
+     *              elements
+     */
+    void
+    checkIntersection(const std::vector<Coordinate>& pt,
+                      size_t expectedIntersectionNum,
+                      const std::vector<Coordinate>& intPt,
+                      double distanceTolerance)
+    {
+        geos::algorithm::LineIntersector li;
+        li.computeIntersection(pt[0], pt[1], pt[2], pt[3]);
+
+        auto intNum = li.getIntersectionNum();
+        ensure_equals(intNum, expectedIntersectionNum);
+
+        if(intPt.empty()) {
+            return;
         }
 
-	/**
-	 *
-	 * @param pt array of 4 Coordinates
-	 * @param expectedIntersectionNum
-	 * @param intPt the expected intersection points
-	 *              (maybe null if not tested)
-	 *              must contain at least expectedIntersectionNum
-	 *              elements
-	 */
-	void checkIntersection(const std::vector<Coordinate>& pt,
-	                         size_t expectedIntersectionNum,
-	                         const std::vector<Coordinate>& intPt,
-	                         double distanceTolerance)
-	{
-		geos::algorithm::LineIntersector li;
-		li.computeIntersection(pt[0], pt[1], pt[2], pt[3]);
-
-		auto intNum = li.getIntersectionNum();
-		ensure_equals(intNum, expectedIntersectionNum);
-
-		if ( intPt.empty() ) return;
-
-		ensure_equals(intPt.size(), intNum);
-
-		// test that both points are represented here
-		//bool isIntPointsCorrect = true;
-		if (intNum == 1)
-		{
-			checkIntPoints(intPt[0], li.getIntersection(0),
-			              distanceTolerance);
-		}
-		else if (intNum == 2)
-		{
-			checkIntPoints(intPt[0], li.getIntersection(0),
-			                        distanceTolerance);
-			checkIntPoints(intPt[1], li.getIntersection(0),
-			                        distanceTolerance);
-
-			if ( !(
-		equals(intPt[0],li.getIntersection(0), distanceTolerance)
-			        ||
-		equals(intPt[0],li.getIntersection(1), distanceTolerance) ) )
-			{
-				checkIntPoints(intPt[0], li.getIntersection(0),
-				              distanceTolerance);
-				checkIntPoints(intPt[0], li.getIntersection(1),
-				              distanceTolerance);
-			}
-
-			else if ( !(
-		equals(intPt[1],li.getIntersection(0), distanceTolerance)
-				||
-		equals(intPt[1],li.getIntersection(1), distanceTolerance) ) )
-			{
-				checkIntPoints(intPt[1], li.getIntersection(0),
-				              distanceTolerance);
-				checkIntPoints(intPt[1], li.getIntersection(1),
-				              distanceTolerance);
-			}
-		}
-		//assertTrue("Int Pts not equal", isIntPointsCorrect);
-	}
-
-	void checkIntersection(const std::string& wkt1,
-	                         const std::string& wkt2,
-	                         int expectedIntersectionNum,
-	                         const std::string& expectedWKT,
-	                         double distanceTolerance)
-                //throws ParseException
-        {
-		GeomPtr g1(reader.read(wkt1));
-		GeomPtr g2(reader.read(wkt2));
-
-		LineString* l1ptr = dynamic_cast<LineString*>(g1.get());
-		LineString* l2ptr = dynamic_cast<LineString*>(g2.get());
-
-		ensure(nullptr != l1ptr);
-		ensure(nullptr != l2ptr);
-
-		LineString& l1 = *l1ptr;
-		LineString& l2 = *l2ptr;
-
-	        std::vector<Coordinate> pt;
-		pt.push_back(l1.getCoordinateN(0));
-		pt.push_back(l1.getCoordinateN(1));
-		pt.push_back(l2.getCoordinateN(0));
-		pt.push_back(l2.getCoordinateN(1));
-
-                GeomPtr g(reader.read(expectedWKT));
-
-		std::unique_ptr<CoordinateSequence> cs ( g->getCoordinates() );
-
-	        std::vector<Coordinate> intPt;
-		for (size_t i=0; i<cs->size(); ++i)
-			intPt.push_back(cs->getAt(i));
-
-                checkIntersection(pt, expectedIntersectionNum,
-		                    intPt, distanceTolerance);
+        ensure_equals(intPt.size(), intNum);
+
+        // test that both points are represented here
+        //bool isIntPointsCorrect = true;
+        if(intNum == 1) {
+            checkIntPoints(intPt[0], li.getIntersection(0),
+                           distanceTolerance);
         }
+        else if(intNum == 2) {
+            checkIntPoints(intPt[0], li.getIntersection(0),
+                           distanceTolerance);
+            checkIntPoints(intPt[1], li.getIntersection(0),
+                           distanceTolerance);
+
+            if(!(
+                        equals(intPt[0], li.getIntersection(0), distanceTolerance)
+                        ||
+                        equals(intPt[0], li.getIntersection(1), distanceTolerance))) {
+                checkIntPoints(intPt[0], li.getIntersection(0),
+                               distanceTolerance);
+                checkIntPoints(intPt[0], li.getIntersection(1),
+                               distanceTolerance);
+            }
+
+            else if(!(
+                        equals(intPt[1], li.getIntersection(0), distanceTolerance)
+                        ||
+                        equals(intPt[1], li.getIntersection(1), distanceTolerance))) {
+                checkIntPoints(intPt[1], li.getIntersection(0),
+                               distanceTolerance);
+                checkIntPoints(intPt[1], li.getIntersection(1),
+                               distanceTolerance);
+            }
+        }
+        //assertTrue("Int Pts not equal", isIntPointsCorrect);
+    }
+
+    void
+    checkIntersection(const std::string& wkt1,
+                      const std::string& wkt2,
+                      int expectedIntersectionNum,
+                      const std::string& expectedWKT,
+                      double distanceTolerance)
+    //throws ParseException
+    {
+        GeomPtr g1(reader.read(wkt1));
+        GeomPtr g2(reader.read(wkt2));
+
+        LineString* l1ptr = dynamic_cast<LineString*>(g1.get());
+        LineString* l2ptr = dynamic_cast<LineString*>(g2.get());
+
+        ensure(nullptr != l1ptr);
+        ensure(nullptr != l2ptr);
+
+        LineString& l1 = *l1ptr;
+        LineString& l2 = *l2ptr;
 
-	void checkIntersection(const std::string& wkt1,
-	                         const std::string& wkt2,
-	                         int expectedIntersectionNum,
-	                         const std::vector<Coordinate>& intPt,
-	                         double distanceTolerance)
-                // throws ParseException
-        {
-		GeomPtr g1(reader.read(wkt1));
-		GeomPtr g2(reader.read(wkt2));
-
-		LineString* l1ptr = dynamic_cast<LineString*>(g1.get());
-		LineString* l2ptr = dynamic_cast<LineString*>(g2.get());
-
-		ensure(nullptr != l1ptr);
-		ensure(nullptr != l2ptr);
-
-		LineString& l1 = *l1ptr;
-		LineString& l2 = *l2ptr;
-
-	        std::vector<Coordinate> pt;
-		pt.push_back(l1.getCoordinateN(0));
-		pt.push_back(l1.getCoordinateN(1));
-		pt.push_back(l2.getCoordinateN(0));
-		pt.push_back(l2.getCoordinateN(1));
-
-		checkIntersection(pt, expectedIntersectionNum,
-		                    intPt, distanceTolerance);
+        std::vector<Coordinate> pt;
+        pt.push_back(l1.getCoordinateN(0));
+        pt.push_back(l1.getCoordinateN(1));
+        pt.push_back(l2.getCoordinateN(0));
+        pt.push_back(l2.getCoordinateN(1));
+
+        GeomPtr g(reader.read(expectedWKT));
+
+        std::unique_ptr<CoordinateSequence> cs(g->getCoordinates());
+
+        std::vector<Coordinate> intPt;
+        for(size_t i = 0; i < cs->size(); ++i) {
+            intPt.push_back(cs->getAt(i));
         }
 
-	void checkIntersectionNone(const std::string& wkt1,
-	                         const std::string& wkt2)
-                // throws ParseException
-        {
-		GeomPtr g1(reader.read(wkt1));
-		GeomPtr g2(reader.read(wkt2));
+        checkIntersection(pt, expectedIntersectionNum,
+                          intPt, distanceTolerance);
+    }
+
+    void
+    checkIntersection(const std::string& wkt1,
+                      const std::string& wkt2,
+                      int expectedIntersectionNum,
+                      const std::vector<Coordinate>& intPt,
+                      double distanceTolerance)
+    // throws ParseException
+    {
+        GeomPtr g1(reader.read(wkt1));
+        GeomPtr g2(reader.read(wkt2));
+
+        LineString* l1ptr = dynamic_cast<LineString*>(g1.get());
+        LineString* l2ptr = dynamic_cast<LineString*>(g2.get());
+
+        ensure(nullptr != l1ptr);
+        ensure(nullptr != l2ptr);
+
+        LineString& l1 = *l1ptr;
+        LineString& l2 = *l2ptr;
+
+        std::vector<Coordinate> pt;
+        pt.push_back(l1.getCoordinateN(0));
+        pt.push_back(l1.getCoordinateN(1));
+        pt.push_back(l2.getCoordinateN(0));
+        pt.push_back(l2.getCoordinateN(1));
+
+        checkIntersection(pt, expectedIntersectionNum,
+                          intPt, distanceTolerance);
+    }
+
+    void
+    checkIntersectionNone(const std::string& wkt1,
+                          const std::string& wkt2)
+    // throws ParseException
+    {
+        GeomPtr g1(reader.read(wkt1));
+        GeomPtr g2(reader.read(wkt2));
+
+        LineString* l1ptr = dynamic_cast<LineString*>(g1.get());
+        LineString* l2ptr = dynamic_cast<LineString*>(g2.get());
+
+        ensure(nullptr != l1ptr);
+        ensure(nullptr != l2ptr);
+
+        LineString& l1 = *l1ptr;
+        LineString& l2 = *l2ptr;
+
+        std::vector<Coordinate> pt;
+        pt.push_back(l1.getCoordinateN(0));
+        pt.push_back(l1.getCoordinateN(1));
+        pt.push_back(l2.getCoordinateN(0));
+        pt.push_back(l2.getCoordinateN(1));
+
+        std::vector<Coordinate> intPt;
+        checkIntersection(pt, 0, intPt, 0);
+    }
+
+    void
+    checkInputNotAltered(const std::string& wkt1, const std::string& wkt2, int scaleFactor)
+    {
+        GeomPtr g1(reader.read(wkt1));
+        GeomPtr g2(reader.read(wkt2));
+
+        LineString* l1ptr = dynamic_cast<LineString*>(g1.get());
+        LineString* l2ptr = dynamic_cast<LineString*>(g2.get());
+
+        ensure(nullptr != l1ptr);
+        ensure(nullptr != l2ptr);
 
-		LineString* l1ptr = dynamic_cast<LineString*>(g1.get());
-		LineString* l2ptr = dynamic_cast<LineString*>(g2.get());
+        LineString& l1 = *l1ptr;
+        LineString& l2 = *l2ptr;
 
-		ensure(nullptr != l1ptr);
-		ensure(nullptr != l2ptr);
+        std::vector<Coordinate> pt;
+        pt.push_back(l1.getCoordinateN(0));
+        pt.push_back(l1.getCoordinateN(1));
+        pt.push_back(l2.getCoordinateN(0));
+        pt.push_back(l2.getCoordinateN(1));
+        checkInputNotAltered(pt, scaleFactor);
+    }
 
-		LineString& l1 = *l1ptr;
-		LineString& l2 = *l2ptr;
+    void
+    checkInputNotAltered(const std::vector<Coordinate>& pt, int scaleFactor)
+    {
+        // save input points
+        std::vector<Coordinate> savePt = pt;
 
-	        std::vector<Coordinate> pt;
-		pt.push_back(l1.getCoordinateN(0));
-		pt.push_back(l1.getCoordinateN(1));
-		pt.push_back(l2.getCoordinateN(0));
-		pt.push_back(l2.getCoordinateN(1));
+        geos::algorithm::LineIntersector li;
+        PrecisionModel lpm(scaleFactor);
+        li.setPrecisionModel(&lpm);
+        li.computeIntersection(pt[0], pt[1], pt[2], pt[3]);
 
-	  std::vector<Coordinate> intPt;
-		checkIntersection(pt, 0, intPt, 0);
+        // check that input points are unchanged
+        for(int i = 0; i < 4; i++) {
+            ensure_equals(savePt[i], pt[i]);
         }
+    }
+
 
-  void checkInputNotAltered(const std::string& wkt1, const std::string& wkt2, int scaleFactor)
-  {
-		GeomPtr g1(reader.read(wkt1));
-		GeomPtr g2(reader.read(wkt2));
-
-		LineString* l1ptr = dynamic_cast<LineString*>(g1.get());
-		LineString* l2ptr = dynamic_cast<LineString*>(g2.get());
-
-		ensure(nullptr != l1ptr);
-		ensure(nullptr != l2ptr);
-
-		LineString& l1 = *l1ptr;
-		LineString& l2 = *l2ptr;
-
-	  std::vector<Coordinate> pt;
-		pt.push_back(l1.getCoordinateN(0));
-		pt.push_back(l1.getCoordinateN(1));
-		pt.push_back(l2.getCoordinateN(0));
-		pt.push_back(l2.getCoordinateN(1));
-    checkInputNotAltered(pt, scaleFactor);
-  }
-
-  void checkInputNotAltered(const std::vector<Coordinate>& pt, int scaleFactor)
-  {
-    // save input points
-    std::vector<Coordinate> savePt = pt;
-
-		geos::algorithm::LineIntersector li;
-    PrecisionModel lpm(scaleFactor);
-    li.setPrecisionModel(&lpm);
-    li.computeIntersection(pt[0], pt[1], pt[2], pt[3]);
-
-    // check that input points are unchanged
-    for (int i = 0; i < 4; i++) {
-      ensure_equals(savePt[i], pt[i]);
+
+    test_robustlineintersection_data()
+        :
+        pm(),
+        gf(GeometryFactory::create(&pm)),
+        reader(gf.get())
+    {
     }
-  }
-
-
-
-	test_robustlineintersection_data()
-		:
-		pm(),
-		gf(GeometryFactory::create(&pm)),
-		reader(gf.get())
-	{
-	}
-
-	PrecisionModel pm;
-	GeometryFactory::Ptr gf;
-  geos::io::WKTReader reader;
-
-	};
-
-	typedef test_group<test_robustlineintersection_data> group;
-	typedef group::object object;
-
-	group test_robustlineintersection_group(
-		"geos::algorithm::RobustLineIntersection");
-
-
-	//
-	// Test Cases
-	//
-
-	// 1 - Test from strk which is bad in GEOS (2009-04-14).
-	template<>
-	template<>
-	void object::test<1>()
-	{
-                checkIntersection(
-                                "LINESTRING (588750.7429703881 4518950.493668233, 588748.2060409798 4518933.9452804085)",
-                                "LINESTRING (588745.824857241 4518940.742239175, 588748.2060437313 4518933.9452791475)",
-                                1,
-                                "POINT (588748.2060416829 4518933.945284994)",
-                                0);
-	}
-
-	// 2 - Test from strk which is bad in GEOS (2009-04-14).
-	template<>
-	template<>
-	void object::test<2>()
-	{
-                checkIntersection(
-                                "LINESTRING (588743.626135934 4518924.610969561, 588732.2822865889 4518925.4314047815)",
-                                "LINESTRING (588739.1191384895 4518927.235700594, 588731.7854614238 4518924.578370095)",
-                                1,
-                                "POINT (588733.8306132929 4518925.319423238)",
-                                0);
-	}
-
-	// 3 - DaveSkeaCase
-	//
-	// This used to be a failure case (exception),
-	// but apparently works now.
-	// Possibly normalization has fixed this?
-	//
+
+    PrecisionModel pm;
+    GeometryFactory::Ptr gf;
+    geos::io::WKTReader reader;
+
+};
+
+typedef test_group<test_robustlineintersection_data> group;
+typedef group::object object;
+
+group test_robustlineintersection_group(
+    "geos::algorithm::RobustLineIntersection");
+
+
+//
+// Test Cases
+//
+
+// 1 - Test from strk which is bad in GEOS (2009-04-14).
+template<>
+template<>
+void object::test<1>
+()
+{
+    checkIntersection(
+        "LINESTRING (588750.7429703881 4518950.493668233, 588748.2060409798 4518933.9452804085)",
+        "LINESTRING (588745.824857241 4518940.742239175, 588748.2060437313 4518933.9452791475)",
+        1,
+        "POINT (588748.2060416829 4518933.945284994)",
+        0);
+}
+
+// 2 - Test from strk which is bad in GEOS (2009-04-14).
+template<>
+template<>
+void object::test<2>
+()
+{
+    checkIntersection(
+        "LINESTRING (588743.626135934 4518924.610969561, 588732.2822865889 4518925.4314047815)",
+        "LINESTRING (588739.1191384895 4518927.235700594, 588731.7854614238 4518924.578370095)",
+        1,
+        "POINT (588733.8306132929 4518925.319423238)",
+        0);
+}
+
+// 3 - DaveSkeaCase
+//
+// This used to be a failure case (exception),
+// but apparently works now.
+// Possibly normalization has fixed this?
+//
 #if 0 // fails: finds 1 intersection rather then two
-	template<>
-	template<>
-	void object::test<3>()
-	{
-	   std::vector<Coordinate> intPt;
-	   intPt.push_back(Coordinate(2089426.5233462777, 1180182.3877339689));
-	   intPt.push_back(Coordinate(2085646.6891757075, 1195618.7333999649));
-
-           checkIntersection(
-                                "LINESTRING ( 2089426.5233462777 1180182.3877339689, 2085646.6891757075 1195618.7333999649 )",
-                                "LINESTRING ( 1889281.8148903656 1997547.0560044837, 2259977.3672235999 483675.17050843034 )",
-                                2,
-                                intPt, 0);
-	}
+template<>
+template<>
+void object::test<3>
+()
+{
+    std::vector<Coordinate> intPt;
+    intPt.push_back(Coordinate(2089426.5233462777, 1180182.3877339689));
+    intPt.push_back(Coordinate(2085646.6891757075, 1195618.7333999649));
+
+    checkIntersection(
+        "LINESTRING ( 2089426.5233462777 1180182.3877339689, 2085646.6891757075 1195618.7333999649 )",
+        "LINESTRING ( 1889281.8148903656 1997547.0560044837, 2259977.3672235999 483675.17050843034 )",
+        2,
+        intPt, 0);
+}
 #endif // fails
 
 #if 0 // fails: the intersection point doesn't match
-	// 4 - Outside envelope using HCoordinate method (testCmp5CaseWKT)
-	template<>
-	template<>
-	void object::test<4>()
-	{
-	   std::vector<Coordinate> intPt;
-	   intPt.push_back(Coordinate(4348437.0557510145, 5552597.375203926));
-
-                checkIntersection(
-                                "LINESTRING (4348433.262114629 5552595.478385733, 4348440.849387404 5552599.272022122 )",
-                                "LINESTRING (4348433.26211463  5552595.47838573,  4348440.8493874   5552599.27202212  )",
-                                1,
-                                intPt, 0);
-	}
+// 4 - Outside envelope using HCoordinate method (testCmp5CaseWKT)
+template<>
+template<>
+void object::test<4>
+()
+{
+    std::vector<Coordinate> intPt;
+    intPt.push_back(Coordinate(4348437.0557510145, 5552597.375203926));
+
+    checkIntersection(
+        "LINESTRING (4348433.262114629 5552595.478385733, 4348440.849387404 5552599.272022122 )",
+        "LINESTRING (4348433.26211463  5552595.47838573,  4348440.8493874   5552599.27202212  )",
+        1,
+        intPt, 0);
+}
 #endif // fails
 
 #if 0 // fails: the intersection point doesn't match
-	// 5 - Result of this test should be the same as the WKT one!
-	//     (testCmp5CaseRaw)
-	template<>
-	template<>
-	void object::test<5>()
-	{
-	   std::vector<Coordinate> pt;
-	   pt.push_back(Coordinate(4348433.262114629, 5552595.478385733));
-	   pt.push_back(Coordinate(4348440.849387404, 5552599.272022122));
-	   pt.push_back(Coordinate(4348433.26211463,  5552595.47838573));
-	   pt.push_back(Coordinate(4348440.8493874,   5552599.27202212));
-
-	   std::vector<Coordinate> intPt;
-	   intPt.push_back(Coordinate(4348437.0557510145, 5552597.375203926));
-
-	   checkIntersection( pt, 1, intPt, 0);
-	}
+// 5 - Result of this test should be the same as the WKT one!
+//     (testCmp5CaseRaw)
+template<>
+template<>
+void object::test<5>
+()
+{
+    std::vector<Coordinate> pt;
+    pt.push_back(Coordinate(4348433.262114629, 5552595.478385733));
+    pt.push_back(Coordinate(4348440.849387404, 5552599.272022122));
+    pt.push_back(Coordinate(4348433.26211463,  5552595.47838573));
+    pt.push_back(Coordinate(4348440.8493874,   5552599.27202212));
+
+    std::vector<Coordinate> intPt;
+    intPt.push_back(Coordinate(4348437.0557510145, 5552597.375203926));
+
+    checkIntersection(pt, 1, intPt, 0);
+}
 #endif // fails
 
-  /**
-   * Test involving two non-almost-parallel lines.
-   * Does not seem to cause problems with basic line intersection algorithm.
-   *
-   */
-	//     (testLeduc_1)
-	template<>
-	template<>
-	void object::test<6>()
-	{
+/**
+ * Test involving two non-almost-parallel lines.
+ * Does not seem to cause problems with basic line intersection algorithm.
+ *
+ */
+//     (testLeduc_1)
+template<>
+template<>
+void object::test<6>
+()
+{
     checkIntersection(
         "LINESTRING (305690.0434123494 254176.46578338774, 305601.9999843455 254243.19999846347)",
         "LINESTRING (305689.6153764265 254177.33102743194, 305692.4999844298 254171.4999983967)",
         1,
         "POINT (305690.0434123494 254176.46578338774)",
         0);
-	}
+}
 
 #if 0 // fails: finds an intersection (we don't have DD)
-  /**
-   * Test from Tomas Fa - JTS list 6/13/2012
-   *
-   * Fails using original JTS DeVillers determine orientation test.
-   * Succeeds using DD and Shewchuk orientation
-   *
-   */
-  // testTomasFa_2
-	template<>
-	template<>
-	void object::test<7>()
-	{
+/**
+ * Test from Tomas Fa - JTS list 6/13/2012
+ *
+ * Fails using original JTS DeVillers determine orientation test.
+ * Succeeds using DD and Shewchuk orientation
+ *
+ */
+// testTomasFa_2
+template<>
+template<>
+void object::test<7>
+()
+{
     checkIntersectionNone(
         "LINESTRING (-5.9 163.1, 76.1 250.7)",
         "LINESTRING (14.6 185.0, 96.6 272.6)");
-	}
+}
 #endif // fails
 
 #if 0 // fails: finds an intersection (we don't have DD)
-  /**
-   * Test from Tomas Fa - JTS list 6/13/2012
-   *
-   * Fails using original JTS DeVillers determine orientation test.
-   * Succeeds using DD and Shewchuk orientation
-   *
-   */
-  // testTomasFa_1
-	template<>
-	template<>
-	void object::test<8>()
-	{
+/**
+ * Test from Tomas Fa - JTS list 6/13/2012
+ *
+ * Fails using original JTS DeVillers determine orientation test.
+ * Succeeds using DD and Shewchuk orientation
+ *
+ */
+// testTomasFa_1
+template<>
+template<>
+void object::test<8>
+()
+{
     checkIntersectionNone(
         "LINESTRING (-42.0 163.2, 21.2 265.2)",
         "LINESTRING (-26.2 188.7, 37.0 290.7)");
-	}
+}
 #endif // fails
 
-  /**
-   * Following cases were failures when using the CentralEndpointIntersector heuristic.
-   * This is because one segment lies at a significant angle to the other,
-   * with only one endpoint is close to the other segment.
-   * The CE heuristic chose the wrong endpoint to return.
-   * The fix is to use a new heuristic which out of the 4 endpoints
-   * chooses the one which is closest to the other segment.
-   * This works in all known failure cases.
-   *
-   */
-  // public void testCentralEndpointHeuristicFailure()
-  template<>
-	template<>
-	void object::test<9>()
-  {
+/**
+ * Following cases were failures when using the CentralEndpointIntersector heuristic.
+ * This is because one segment lies at a significant angle to the other,
+ * with only one endpoint is close to the other segment.
+ * The CE heuristic chose the wrong endpoint to return.
+ * The fix is to use a new heuristic which out of the 4 endpoints
+ * chooses the one which is closest to the other segment.
+ * This works in all known failure cases.
+ *
+ */
+// public void testCentralEndpointHeuristicFailure()
+template<>
+template<>
+void object::test<9>
+()
+{
     checkIntersection(
         "LINESTRING (163.81867067 -211.31840378, 165.9174252 -214.1665075)",
         "LINESTRING (2.84139601 -57.95412726, 469.59990601 -502.63851732)",
         1,
         "POINT (163.81867067 -211.31840378)",
         0);
-  }
+}
 
-  // public void testCentralEndpointHeuristicFailure2()
-  template<>
-	template<>
-	void object::test<10>()
-  {
+// public void testCentralEndpointHeuristicFailure2()
+template<>
+template<>
+void object::test<10>
+()
+{
     checkIntersection(
         "LINESTRING (-58.00593335955 -1.43739086465, -513.86101637525 -457.29247388035)",
         "LINESTRING (-215.22279674875 -158.65425425385, -218.1208801283 -160.68343590235)",
         1,
         "POINT ( -215.22279674875 -158.65425425385 )",
         0);
-  }
-
-  /**
-   * Tests a case where intersection point is rounded,
-   * and it is computed as a nearest endpoint.
-   * Exposed a bug due to aliasing of endpoint.
-   *
-   * MD 8 Mar 2013
-   *
-   */
-  // testRoundedPointsNotAltered()
-  template<>
-	template<>
-	void object::test<11>()
-  {
+}
+
+/**
+ * Tests a case where intersection point is rounded,
+ * and it is computed as a nearest endpoint.
+ * Exposed a bug due to aliasing of endpoint.
+ *
+ * MD 8 Mar 2013
+ *
+ */
+// testRoundedPointsNotAltered()
+template<>
+template<>
+void object::test<11>
+()
+{
     checkInputNotAltered(
-       "LINESTRING (-58.00593335955 -1.43739086465, -513.86101637525 -457.29247388035)",
-       "LINESTRING (-215.22279674875 -158.65425425385, -218.1208801283 -160.68343590235)",
-       100000 );
-  }
+        "LINESTRING (-58.00593335955 -1.43739086465, -513.86101637525 -457.29247388035)",
+        "LINESTRING (-215.22279674875 -158.65425425385, -218.1208801283 -160.68343590235)",
+        100000);
+}
 
 
 
diff --git a/tests/unit/algorithm/RobustLineIntersectorTest.cpp b/tests/unit/algorithm/RobustLineIntersectorTest.cpp
index 68763ac..8828429 100644
--- a/tests/unit/algorithm/RobustLineIntersectorTest.cpp
+++ b/tests/unit/algorithm/RobustLineIntersectorTest.cpp
@@ -28,38 +28,38 @@ using geos::algorithm::PointLocation;
 using geos::algorithm::Orientation;
 
 
-namespace tut
-{
-	//
-	// Test Group
-	//
+namespace tut {
+//
+// Test Group
+//
 
-	struct test_robustlineintersector_data {
+struct test_robustlineintersector_data {
 
-	typedef std::unique_ptr<Geometry> GeomPtr;
+    typedef std::unique_ptr<Geometry> GeomPtr;
 
-	LineIntersector i;
+    LineIntersector i;
 
-	};
+};
 
-	typedef test_group<test_robustlineintersector_data> group;
-	typedef group::object object;
+typedef test_group<test_robustlineintersector_data> group;
+typedef group::object object;
 
-	group test_robustlineintersector_group(
-		"geos::algorithm::RobustLineIntersector");
+group test_robustlineintersector_group(
+    "geos::algorithm::RobustLineIntersector");
 
 
 
 
-	//
-	// Test Cases
-	//
+//
+// Test Cases
+//
 
-	// 1 - test2Lines
-	template<>
-	template<>
-	void object::test<1>()
-	{
+// 1 - test2Lines
+template<>
+template<>
+void object::test<1>
+()
+{
     Coordinate p1(10, 10);
     Coordinate p2(20, 20);
     Coordinate q1(20, 10);
@@ -72,13 +72,14 @@ namespace tut
     ensure_equals(i.getIntersection(0), x);
     ensure("isProper", i.isProper());
     ensure("hasIntersection", i.hasIntersection());
-	}
+}
 
-	// 2 - testCollinear1
-	template<>
-	template<>
-	void object::test<2>()
-	{
+// 2 - testCollinear1
+template<>
+template<>
+void object::test<2>
+()
+{
     Coordinate p1(10, 10);
     Coordinate p2(20, 10);
     Coordinate q1(22, 10);
@@ -89,13 +90,14 @@ namespace tut
     ensure_equals(i.getIntersectionNum(), 0UL);
     ensure("!isProper", !i.isProper());
     ensure("!hasIntersection", !i.hasIntersection());
-	}
+}
 
-	// 3 - testCollinear2
-	template<>
-	template<>
-	void object::test<3>()
-	{
+// 3 - testCollinear2
+template<>
+template<>
+void object::test<3>
+()
+{
     Coordinate p1(10, 10);
     Coordinate p2(20, 10);
     Coordinate q1(20, 10);
@@ -106,13 +108,14 @@ namespace tut
     ensure_equals(i.getIntersectionNum(), 1UL);
     ensure("!isProper", !i.isProper());
     ensure("hasIntersection", i.hasIntersection());
-	}
+}
 
-	// 4 - testCollinear3
-	template<>
-	template<>
-	void object::test<4>()
-	{
+// 4 - testCollinear3
+template<>
+template<>
+void object::test<4>
+()
+{
     Coordinate p1(10, 10);
     Coordinate p2(20, 10);
     Coordinate q1(15, 10);
@@ -123,13 +126,14 @@ namespace tut
     ensure_equals(i.getIntersectionNum(), 2UL);
     ensure("!isProper", !i.isProper());
     ensure("hasIntersection", i.hasIntersection());
-	}
+}
 
-	// 5 - testCollinear4
-	template<>
-	template<>
-	void object::test<5>()
-	{
+// 5 - testCollinear4
+template<>
+template<>
+void object::test<5>
+()
+{
     Coordinate p1(10, 10);
     Coordinate p2(20, 10);
     Coordinate q1(10, 10);
@@ -140,93 +144,101 @@ namespace tut
     ensure_equals(i.getIntersectionNum(), 2UL);
     ensure("!isProper", !i.isProper());
     ensure("hasIntersection", i.hasIntersection());
-	}
+}
 
-	// 6 - testEndpointIntersection
-	template<>
-	template<>
-	void object::test<6>()
-	{
+// 6 - testEndpointIntersection
+template<>
+template<>
+void object::test<6>
+()
+{
     i.computeIntersection(Coordinate(100, 100), Coordinate(10, 100),
-        Coordinate(100, 10), Coordinate(100, 100));
+                          Coordinate(100, 10), Coordinate(100, 100));
     ensure("hasIntersection", i.hasIntersection());
     ensure_equals(i.getIntersectionNum(), 1UL);
-	}
+}
 
-	// 7 - testEndpointIntersection2
-	template<>
-	template<>
-	void object::test<7>()
-	{
+// 7 - testEndpointIntersection2
+template<>
+template<>
+void object::test<7>
+()
+{
     i.computeIntersection(Coordinate(190, 50), Coordinate(120, 100),
-        Coordinate(120, 100), Coordinate(50, 150));
+                          Coordinate(120, 100), Coordinate(50, 150));
     ensure("hasIntersection", i.hasIntersection());
     ensure_equals(i.getIntersectionNum(), 1UL);
     ensure_equals(i.getIntersection(1), Coordinate(120, 100));
-	}
+}
 
-	// 8 - testOverlap
-	template<>
-	template<>
-	void object::test<8>()
-	{
+// 8 - testOverlap
+template<>
+template<>
+void object::test<8>
+()
+{
     i.computeIntersection(Coordinate(180, 200), Coordinate(160, 180),
-        Coordinate(220, 240), Coordinate(140, 160));
+                          Coordinate(220, 240), Coordinate(140, 160));
     ensure("hasIntersection", i.hasIntersection());
     ensure_equals(i.getIntersectionNum(), 2UL);
-	}
+}
 
-	// 9 - testIsProper1
-	template<>
-	template<>
-	void object::test<9>()
-	{
+// 9 - testIsProper1
+template<>
+template<>
+void object::test<9>
+()
+{
     i.computeIntersection(Coordinate(30, 10), Coordinate(30, 30),
-        Coordinate(10, 10), Coordinate(90, 11));
+                          Coordinate(10, 10), Coordinate(90, 11));
     ensure("hasIntersection", i.hasIntersection());
     ensure_equals(i.getIntersectionNum(), 1UL);
     ensure("isProper", i.isProper());
-	}
+}
 
-	// 10 - testIsProper2
-	template<>
-	template<>
-	void object::test<10>()
-	{
+// 10 - testIsProper2
+template<>
+template<>
+void object::test<10>
+()
+{
     i.computeIntersection(Coordinate(10, 30), Coordinate(10, 0),
-        Coordinate(11, 90), Coordinate(10, 10));
+                          Coordinate(11, 90), Coordinate(10, 10));
     ensure("hasIntersection", i.hasIntersection());
     ensure_equals(i.getIntersectionNum(), 1UL);
     ensure("!isProper", !i.isProper());
-	}
-
-	// 11 - testIsCCW
-	template<>
-	template<>
-	void object::test<11>()
-	{
-	    ensure_equals(Orientation::index(
-		Coordinate(-123456789, -40),
-		Coordinate(0, 0),
-		Coordinate(381039468754763.0, 123456789)), 1);
-	}
-
-	// 12 - testIsCCW2
-	template<>
-	template<>
-	void object::test<12>()
-	{
-	    ensure_equals(Orientation::index(
-		Coordinate(10, 10),
-		Coordinate(20, 20),
-		Coordinate(0, 0)), 0);
-	}
-
-	// 13 - testA
-	template<>
-	template<>
-	void object::test<13>()
-	{
+}
+
+// 11 - testIsCCW
+template<>
+template<>
+void object::test<11>
+()
+{
+    ensure_equals(Orientation::index(
+                      Coordinate(-123456789, -40),
+                      Coordinate(0, 0),
+                      Coordinate(381039468754763.0, 123456789)), 1);
+}
+
+// 12 - testIsCCW2
+template<>
+template<>
+void object::test<12>
+()
+{
+    ensure_equals(Orientation::index(
+                      Coordinate(10, 10),
+                      Coordinate(20, 20),
+                      Coordinate(0, 0)), 0);
+}
+
+// 13 - testA
+template<>
+template<>
+void object::test<13>
+()
+{
     Coordinate p1(-123456789, -40);
     Coordinate p2(381039468754763.0, 123456789);
     Coordinate q(0, 0);
@@ -240,78 +252,82 @@ namespace tut
     cs->add(p1);
     cs->add(p2);
 
-    GeomPtr l ( factory->createLineString(cs) );
-    GeomPtr p ( factory->createPoint(q) );
+    GeomPtr l(factory->createLineString(cs));
+    GeomPtr p(factory->createPoint(q));
     ensure(!l->intersects(p.get()));
 
     ensure(!PointLocation::isOnLine(q, cs));
     ensure_equals(Orientation::index(p1, p2, q), -1);
 
-	}
-
-    // Test intersects: point on segment with FLOAT PM
-    // X coordinate of 3rd and 4th vertises of the line are not
-    // float-point exact with X coordinate of the point.
-    // The X values differ after 14th decimal place:
-    // POINT (-23.1094689600055080 50.5195368635957180)
-    // --------------------^^^^^^^------------^^^^^^^^
-    // LINESTRING 3rd and 4th points
-    //        -23.1094689600055150 50.5223376452201340,
-    //        -23.1094689600055010 50.5169177629559480,
-    // --------------------^^^^^^^------------^^^^^^^^
-    // So, in float-point precision model, the point does DOES NOT intersect the segment.
-    template<>
-    template<>
-    void object::test<14>()
-    {
-        geos::io::WKBReader reader;
-
-        // POINT located between 3rd and 4th vertex of LINESTRING
-        // POINT(-23.1094689600055080 50.5195368635957180)
-        std::string point("01010000009a266328061c37c0e21a172f80424940");
-        // LINESTRING(-23.122057005539 50.5201976774794,-23.1153476966995 50.5133404815199,-23.1094689600055150 50.5223376452201340,-23.1094689600055010 50.5169177629559480,-23.0961967920942 50.5330464848094,-23.0887991006034 50.5258515213185,-23.0852302622362 50.5264582238409)
-        std::string line("0102000000070000009909bf203f1f37c05c1d66d6954249404afe386d871d37c0a7eb1124b54149409c266328061c37c056d8bff5db42494098266328061c37c0034f7b5c2a42494060065c5aa01837c08ac001de3a4449408401b189bb1637c0b04e471a4f43494014ef84a6d11537c0b20dabfb62434940");
-        std::stringstream sPoint(point);
-        GeomPtr gPoint(reader.readHEX(sPoint));
-        std::stringstream sLine(line);
-        GeomPtr gLine(reader.readHEX(sLine));
-        int ret = gLine->intersects(gPoint.get());
-        ensure_equals(ret, 0);
-    }
-
-    // Test intersects: point on segment with FIXED PM
-    // X coordinate of 3rd and 4th vertises of the line are not
-    // float-point exact with X coordinate of the point.
-    // The X values differ after 14th decimal place:
-    // POINT (-23.1094689600055080 50.5195368635957180)
-    // --------------------^^^^^^^------------^^^^^^^^
-    // LINESTRING 3rd and 4th points
-    //        -23.1094689600055150 50.5223376452201340,
-    //        -23.1094689600055010 50.5169177629559480,
-    // --------------------^^^^^^^------------^^^^^^^^
-    // So, if float-point values are trimmed up to 14 decimal digits, the point DOES intersect the segment.
-
-    template<>
-    template<>
-    void object::test<15>()
-    {
-        using geos::geom::GeometryFactory;
-        geos::geom::PrecisionModel pm(1e+13);
-        GeometryFactory::Ptr factory = GeometryFactory::create(&pm);
-        geos::io::WKBReader reader(*factory);
-
-        // POINT located between 3rd and 4th vertex of LINESTRING
-        // POINT(-23.1094689600055080 50.5195368635957180)
-        std::string point("01010000009a266328061c37c0e21a172f80424940");
-        // LINESTRING(-23.122057005539 50.5201976774794,-23.1153476966995 50.5133404815199,-23.1094689600055150 50.5223376452201340,-23.1094689600055010 50.5169177629559480,-23.0961967920942 50.5330464848094,-23.0887991006034 50.5258515213185,-23.0852302622362 50.5264582238409)
-        std::string line("0102000000070000009909bf203f1f37c05c1d66d6954249404afe386d871d37c0a7eb1124b54149409c266328061c37c056d8bff5db42494098266328061c37c0034f7b5c2a42494060065c5aa01837c08ac001de3a4449408401b189bb1637c0b04e471a4f43494014ef84a6d11537c0b20dabfb62434940");
-        std::stringstream sPoint(point);
-        GeomPtr gPoint(reader.readHEX(sPoint));
-        std::stringstream sLine(line);
-        GeomPtr gLine(reader.readHEX(sLine));
-        int ret = gLine->intersects(gPoint.get());
-        ensure_equals(ret, 1);
-    }
+}
+
+// Test intersects: point on segment with FLOAT PM
+// X coordinate of 3rd and 4th vertises of the line are not
+// float-point exact with X coordinate of the point.
+// The X values differ after 14th decimal place:
+// POINT (-23.1094689600055080 50.5195368635957180)
+// --------------------^^^^^^^------------^^^^^^^^
+// LINESTRING 3rd and 4th points
+//        -23.1094689600055150 50.5223376452201340,
+//        -23.1094689600055010 50.5169177629559480,
+// --------------------^^^^^^^------------^^^^^^^^
+// So, in float-point precision model, the point does DOES NOT intersect the segment.
+template<>
+template<>
+void object::test<14>
+()
+{
+    geos::io::WKBReader reader;
+
+    // POINT located between 3rd and 4th vertex of LINESTRING
+    // POINT(-23.1094689600055080 50.5195368635957180)
+    std::string point("01010000009a266328061c37c0e21a172f80424940");
+    // LINESTRING(-23.122057005539 50.5201976774794,-23.1153476966995 50.5133404815199,-23.1094689600055150 50.5223376452201340,-23.1094689600055010 50.5169177629559480,-23.0961967920942 50.5330464848094,-23.0887991006034 50.5258515213185,-23.0852302622362 50.5264582238409)
+    std::string
+    line("0102000000070000009909bf203f1f37c05c1d66d6954249404afe386d871d37c0a7eb1124b54149409c266328061c37c056d8bff5db42494098266328061c37c0034f7b5c2a42494060065c5aa01837c08ac001de3a4449408401b189bb1637c0b04e471a4f43494014ef84a6d11537c0b20dabfb62434940");
+    std::stringstream sPoint(point);
+    GeomPtr gPoint(reader.readHEX(sPoint));
+    std::stringstream sLine(line);
+    GeomPtr gLine(reader.readHEX(sLine));
+    int ret = gLine->intersects(gPoint.get());
+    ensure_equals(ret, 0);
+}
+
+// Test intersects: point on segment with FIXED PM
+// X coordinate of 3rd and 4th vertises of the line are not
+// float-point exact with X coordinate of the point.
+// The X values differ after 14th decimal place:
+// POINT (-23.1094689600055080 50.5195368635957180)
+// --------------------^^^^^^^------------^^^^^^^^
+// LINESTRING 3rd and 4th points
+//        -23.1094689600055150 50.5223376452201340,
+//        -23.1094689600055010 50.5169177629559480,
+// --------------------^^^^^^^------------^^^^^^^^
+// So, if float-point values are trimmed up to 14 decimal digits, the point DOES intersect the segment.
+
+template<>
+template<>
+void object::test<15>
+()
+{
+    using geos::geom::GeometryFactory;
+    geos::geom::PrecisionModel pm(1e+13);
+    GeometryFactory::Ptr factory = GeometryFactory::create(&pm);
+    geos::io::WKBReader reader(*factory);
+
+    // POINT located between 3rd and 4th vertex of LINESTRING
+    // POINT(-23.1094689600055080 50.5195368635957180)
+    std::string point("01010000009a266328061c37c0e21a172f80424940");
+    // LINESTRING(-23.122057005539 50.5201976774794,-23.1153476966995 50.5133404815199,-23.1094689600055150 50.5223376452201340,-23.1094689600055010 50.5169177629559480,-23.0961967920942 50.5330464848094,-23.0887991006034 50.5258515213185,-23.0852302622362 50.5264582238409)
+    std::string
+    line("0102000000070000009909bf203f1f37c05c1d66d6954249404afe386d871d37c0a7eb1124b54149409c266328061c37c056d8bff5db42494098266328061c37c0034f7b5c2a42494060065c5aa01837c08ac001de3a4449408401b189bb1637c0b04e471a4f43494014ef84a6d11537c0b20dabfb62434940");
+    std::stringstream sPoint(point);
+    GeomPtr gPoint(reader.readHEX(sPoint));
+    std::stringstream sLine(line);
+    GeomPtr gLine(reader.readHEX(sLine));
+    int ret = gLine->intersects(gPoint.get());
+    ensure_equals(ret, 1);
+}
 
 } // namespace tut
 
diff --git a/tests/unit/algorithm/distance/DiscreteFrechetDistanceTest.cpp b/tests/unit/algorithm/distance/DiscreteFrechetDistanceTest.cpp
index a1e74be..039045f 100644
--- a/tests/unit/algorithm/distance/DiscreteFrechetDistanceTest.cpp
+++ b/tests/unit/algorithm/distance/DiscreteFrechetDistanceTest.cpp
@@ -18,113 +18,118 @@
 #include <memory>
 
 namespace geos {
-	namespace geom {
-		class Geometry;
-	}
+namespace geom {
+class Geometry;
+}
 }
 
 using namespace geos::geom;
 using namespace geos::algorithm::distance; // for Location
 
-namespace tut
+namespace tut {
+//
+// Test Group
+//
+
+// Test data, not used
+struct test_DiscreteFrechetDistance_data {
+
+    typedef std::unique_ptr<Geometry> GeomPtr;
+
+    test_DiscreteFrechetDistance_data()
+        :
+        pm(),
+        gf(GeometryFactory::create(&pm)),
+        reader(gf.get())
+    {}
+
+    static const double TOLERANCE;
+
+    void
+    runTest(const std::string& wkt1, const std::string& wkt2,
+            double expectedDistance)
+    {
+        GeomPtr g1(reader.read(wkt1));
+        GeomPtr g2(reader.read(wkt2));
+
+        double distance = DiscreteFrechetDistance::distance(*g1, *g2);
+        double diff = std::fabs(distance - expectedDistance);
+        //std::cerr << "expectedDistance:" << expectedDistance << " actual distance:" << distance << std::endl;
+        ensure(diff <= TOLERANCE);
+    }
+
+    void
+    runTest(const std::string& wkt1, const std::string& wkt2,
+            double densifyFactor, double expectedDistance)
+    {
+        GeomPtr g1(reader.read(wkt1));
+        GeomPtr g2(reader.read(wkt2));
+
+        double distance = DiscreteFrechetDistance::distance(*g1,
+                          *g2, densifyFactor);
+        double diff = std::fabs(distance - expectedDistance);
+        //std::cerr << "expectedDistance:" << expectedDistance << " actual distance:" << distance << std::endl;
+        ensure(diff <= TOLERANCE);
+    }
+
+    PrecisionModel pm;
+    GeometryFactory::Ptr gf;
+    geos::io::WKTReader reader;
+
+};
+const double test_DiscreteFrechetDistance_data::TOLERANCE = 0.00001;
+
+typedef test_group<test_DiscreteFrechetDistance_data> group;
+typedef group::object object;
+
+group test_DiscreteFrechetDistance_group("geos::algorithm::distace::DiscreteFrechetDistance");
+
+
+
+//
+// Test Cases
+//
+
+// 1 - testLineSegments
+template<>
+template<>
+void object::test<1>
+()
+{
+    runTest("LINESTRING (0 0, 2 1)", "LINESTRING (0 0, 2 0)", 1.0);
+}
+
+// 2 - testLineSegments2
+template<>
+template<>
+void object::test<2>
+()
+{
+    runTest("LINESTRING (0 0, 2 0)", "LINESTRING (0 1, 1 2, 2 1)", 2.23606797749979);
+}
+
+// 3 - testLinePoints
+template<>
+template<>
+void object::test<3>
+()
+{
+    runTest("LINESTRING (0 0, 2 0)", "MULTIPOINT (0 1, 1 0, 2 1)", 1.0);
+}
+
+// 4 - testLinesShowingDiscretenessEffect
+//
+// Shows effects of limiting FD to vertices
+// Answer is not true Frechet distance.
+//
+template<>
+template<>
+void object::test<4>
+()
 {
-	//
-	// Test Group
-	//
-
-	// Test data, not used
-	struct test_DiscreteFrechetDistance_data {
-
-	typedef std::unique_ptr<Geometry> GeomPtr;
-
-	test_DiscreteFrechetDistance_data()
-		:
-		pm(),
-		gf(GeometryFactory::create(&pm)),
-		reader(gf.get())
-	{}
-
-	static const double TOLERANCE;
-
-	void runTest(const std::string& wkt1, const std::string& wkt2,
-		     double expectedDistance)
-	{
-		GeomPtr g1 ( reader.read(wkt1) );
-		GeomPtr g2 ( reader.read(wkt2) );
-
-		double distance = DiscreteFrechetDistance::distance(*g1, *g2);
-		double diff = std::fabs(distance-expectedDistance);
-		//std::cerr << "expectedDistance:" << expectedDistance << " actual distance:" << distance << std::endl;
-		ensure( diff <= TOLERANCE );
-	}
-
-	void runTest(const std::string& wkt1, const std::string& wkt2,
-		     double densifyFactor, double expectedDistance)
-	{
-		GeomPtr g1 ( reader.read(wkt1) );
-		GeomPtr g2 ( reader.read(wkt2) );
-
-		double distance = DiscreteFrechetDistance::distance(*g1,
-			*g2, densifyFactor);
-		double diff = std::fabs(distance-expectedDistance);
-		//std::cerr << "expectedDistance:" << expectedDistance << " actual distance:" << distance << std::endl;
-		ensure( diff <= TOLERANCE );
-	}
-
-	PrecisionModel pm;
-	GeometryFactory::Ptr gf;
-	geos::io::WKTReader reader;
-
-	};
-	const double test_DiscreteFrechetDistance_data::TOLERANCE = 0.00001;
-
-	typedef test_group<test_DiscreteFrechetDistance_data> group;
-	typedef group::object object;
-
-	group test_DiscreteFrechetDistance_group("geos::algorithm::distace::DiscreteFrechetDistance");
-
-
-
-	//
-	// Test Cases
-	//
-
-	// 1 - testLineSegments
-	template<>
-	template<>
-	void object::test<1>()
-	{
-runTest("LINESTRING (0 0, 2 1)", "LINESTRING (0 0, 2 0)", 1.0);
-	}
-
-	// 2 - testLineSegments2
-	template<>
-	template<>
-	void object::test<2>()
-	{
-runTest("LINESTRING (0 0, 2 0)", "LINESTRING (0 1, 1 2, 2 1)", 2.23606797749979);
-	}
-
-	// 3 - testLinePoints
-	template<>
-	template<>
-	void object::test<3>()
-	{
-runTest("LINESTRING (0 0, 2 0)", "MULTIPOINT (0 1, 1 0, 2 1)", 1.0);
-	}
-
-	// 4 - testLinesShowingDiscretenessEffect
-	//
-	// Shows effects of limiting FD to vertices
-	// Answer is not true Frechet distance.
-	//
-	template<>
-	template<>
-	void object::test<4>()
-	{
-runTest("LINESTRING (0 0, 100 0)", "LINESTRING (0 0, 50 50, 100 0)", 70.7106781186548);
+    runTest("LINESTRING (0 0, 100 0)", "LINESTRING (0 0, 50 50, 100 0)", 70.7106781186548);
 // densifying provides accurate HD
-runTest("LINESTRING (0 0, 100 0)", "LINESTRING (0 0, 50 50, 100 0)", 0.5, 50.0);
-	}
+    runTest("LINESTRING (0 0, 100 0)", "LINESTRING (0 0, 50 50, 100 0)", 0.5, 50.0);
+}
 
 } // namespace tut
diff --git a/tests/unit/algorithm/distance/DiscreteHausdorffDistanceTest.cpp b/tests/unit/algorithm/distance/DiscreteHausdorffDistanceTest.cpp
index 15f01fe..4c9aa94 100644
--- a/tests/unit/algorithm/distance/DiscreteHausdorffDistanceTest.cpp
+++ b/tests/unit/algorithm/distance/DiscreteHausdorffDistanceTest.cpp
@@ -19,114 +19,119 @@
 #include <memory>
 
 namespace geos {
-	namespace geom {
-		class Geometry;
-	}
+namespace geom {
+class Geometry;
+}
 }
 
 using namespace geos::geom;
 using namespace geos::algorithm::distance; // for Location
 
-namespace tut
+namespace tut {
+//
+// Test Group
+//
+
+// Test data, not used
+struct test_DiscreteHausdorffDistance_data {
+
+    typedef std::unique_ptr<Geometry> GeomPtr;
+
+    test_DiscreteHausdorffDistance_data()
+        :
+        pm(),
+        gf(GeometryFactory::create(&pm)),
+        reader(gf.get())
+    {}
+
+    static const double TOLERANCE;
+
+    void
+    runTest(const std::string& wkt1, const std::string& wkt2,
+            double expectedDistance)
+    {
+        GeomPtr g1(reader.read(wkt1));
+        GeomPtr g2(reader.read(wkt2));
+
+        double distance = DiscreteHausdorffDistance::distance(*g1, *g2);
+        double diff = std::fabs(distance - expectedDistance);
+        //std::cerr << "expectedDistance:" << expectedDistance << " actual distance:" << distance << std::endl;
+        ensure(diff <= TOLERANCE);
+    }
+
+    void
+    runTest(const std::string& wkt1, const std::string& wkt2,
+            double densifyFactor, double expectedDistance)
+    {
+        GeomPtr g1(reader.read(wkt1));
+        GeomPtr g2(reader.read(wkt2));
+
+        double distance = DiscreteHausdorffDistance::distance(*g1,
+                          *g2, densifyFactor);
+        double diff = std::fabs(distance - expectedDistance);
+        //std::cerr << "expectedDistance:" << expectedDistance << " actual distance:" << distance << std::endl;
+        ensure(diff <= TOLERANCE);
+    }
+
+    PrecisionModel pm;
+    GeometryFactory::Ptr gf;
+    geos::io::WKTReader reader;
+
+};
+const double test_DiscreteHausdorffDistance_data::TOLERANCE = 0.00001;
+
+typedef test_group<test_DiscreteHausdorffDistance_data> group;
+typedef group::object object;
+
+group test_DiscreteHausdorffDistance_group("geos::algorithm::distace::DiscreteHausdorffDistance");
+
+
+
+//
+// Test Cases
+//
+
+// 1 - testLineSegments
+template<>
+template<>
+void object::test<1>
+()
+{
+    runTest("LINESTRING (0 0, 2 1)", "LINESTRING (0 0, 2 0)", 1.0);
+}
+
+// 2 - testLineSegments2
+template<>
+template<>
+void object::test<2>
+()
+{
+    runTest("LINESTRING (0 0, 2 0)", "LINESTRING (0 1, 1 2, 2 1)", 2.0);
+}
+
+// 3 - testLinePoints
+template<>
+template<>
+void object::test<3>
+()
+{
+    runTest("LINESTRING (0 0, 2 0)", "MULTIPOINT (0 1, 1 0, 2 1)", 1.0);
+}
+
+// 4 - testLinesShowingDiscretenessEffect
+//
+// Shows effects of limiting HD to vertices
+// Answer is not true Hausdorff distance.
+//
+template<>
+template<>
+void object::test<4>
+()
 {
-	//
-	// Test Group
-	//
-
-	// Test data, not used
-	struct test_DiscreteHausdorffDistance_data {
-
-	typedef std::unique_ptr<Geometry> GeomPtr;
-
-	test_DiscreteHausdorffDistance_data()
-		:
-		pm(),
-		gf(GeometryFactory::create(&pm)),
-		reader(gf.get())
-	{}
-
-	static const double TOLERANCE;
-
-	void runTest(const std::string& wkt1, const std::string& wkt2,
-	             double expectedDistance)
-	{
-		GeomPtr g1 ( reader.read(wkt1) );
-		GeomPtr g2 ( reader.read(wkt2) );
-
-		double distance = DiscreteHausdorffDistance::distance(*g1, *g2);
-		double diff = std::fabs(distance-expectedDistance);
-		//std::cerr << "expectedDistance:" << expectedDistance << " actual distance:" << distance << std::endl;
-		ensure( diff <= TOLERANCE );
-	}
-
-	void runTest(const std::string& wkt1, const std::string& wkt2,
-	             double densifyFactor, double expectedDistance)
-	{
-		GeomPtr g1 ( reader.read(wkt1) );
-		GeomPtr g2 ( reader.read(wkt2) );
-
-		double distance = DiscreteHausdorffDistance::distance(*g1,
-			*g2, densifyFactor);
-		double diff = std::fabs(distance-expectedDistance);
-		//std::cerr << "expectedDistance:" << expectedDistance << " actual distance:" << distance << std::endl;
-		ensure( diff <= TOLERANCE );
-	}
-
-	PrecisionModel pm;
-	GeometryFactory::Ptr gf;
-  geos::io::WKTReader reader;
-
-	};
-	const double test_DiscreteHausdorffDistance_data::TOLERANCE = 0.00001;
-
-	typedef test_group<test_DiscreteHausdorffDistance_data> group;
-	typedef group::object object;
-
-	group test_DiscreteHausdorffDistance_group("geos::algorithm::distace::DiscreteHausdorffDistance");
-
-
-
-	//
-	// Test Cases
-	//
-
-	// 1 - testLineSegments
-	template<>
-	template<>
-	void object::test<1>()
-	{
-runTest("LINESTRING (0 0, 2 1)", "LINESTRING (0 0, 2 0)", 1.0);
-	}
-
-	// 2 - testLineSegments2
-	template<>
-	template<>
-	void object::test<2>()
-	{
-runTest("LINESTRING (0 0, 2 0)", "LINESTRING (0 1, 1 2, 2 1)", 2.0);
-	}
-
-	// 3 - testLinePoints
-	template<>
-	template<>
-	void object::test<3>()
-	{
-runTest("LINESTRING (0 0, 2 0)", "MULTIPOINT (0 1, 1 0, 2 1)", 1.0);
-	}
-
-	// 4 - testLinesShowingDiscretenessEffect
-	//
-	// Shows effects of limiting HD to vertices
-	// Answer is not true Hausdorff distance.
-	//
-	template<>
-	template<>
-	void object::test<4>()
-	{
-runTest("LINESTRING (130 0, 0 0, 0 150)", "LINESTRING (10 10, 10 150, 130 10)", 14.142135623730951);
+    runTest("LINESTRING (130 0, 0 0, 0 150)", "LINESTRING (10 10, 10 150, 130 10)", 14.142135623730951);
 // densifying provides accurate HD
-runTest("LINESTRING (130 0, 0 0, 0 150)", "LINESTRING (10 10, 10 150, 130 10)", 0.5, 70.0);
-	}
+    runTest("LINESTRING (130 0, 0 0, 0 150)", "LINESTRING (10 10, 10 150, 130 10)", 0.5, 70.0);
+}
 
 } // namespace tut
 
diff --git a/tests/unit/capi/GEOSBufferTest.cpp b/tests/unit/capi/GEOSBufferTest.cpp
index 26ab0e1..38b9624 100644
--- a/tests/unit/capi/GEOSBufferTest.cpp
+++ b/tests/unit/capi/GEOSBufferTest.cpp
@@ -10,542 +10,561 @@
 #include <cstdlib>
 #include <cstring>
 
-namespace tut
-{
-    //
-    // Test Group
-    //
+namespace tut {
+//
+// Test Group
+//
 
-    // Common data used in test cases.
-    struct test_capigeosbuffer_data
+// Common data used in test cases.
+struct test_capigeosbuffer_data {
+    GEOSGeometry* geom1_;
+    GEOSGeometry* geom2_;
+    char* wkt_;
+    GEOSBufferParams* bp_;
+    GEOSWKTWriter* wktw_;
+    double area_;
+
+    static void
+    notice(const char* fmt, ...)
     {
-        GEOSGeometry* geom1_;
-        GEOSGeometry* geom2_;
-        char* wkt_;
-        GEOSBufferParams* bp_;
-        GEOSWKTWriter* wktw_;
-        double area_;
-
-        static void notice(const char *fmt, ...)
-        {
-            std::fprintf( stdout, "NOTICE: ");
-
-            va_list ap;
-            va_start(ap, fmt);
-            std::vfprintf(stdout, fmt, ap);
-            va_end(ap);
-
-            std::fprintf(stdout, "\n");
-        }
-
-        test_capigeosbuffer_data()
-            : geom1_(nullptr), geom2_(nullptr), wkt_(nullptr), bp_(nullptr)
-        {
-            initGEOS(notice, notice);
-            wktw_ = GEOSWKTWriter_create();
-            GEOSWKTWriter_setTrim(wktw_, 1);
-        }
-
-        ~test_capigeosbuffer_data()
-        {
-            GEOSGeom_destroy(geom1_);
-            GEOSGeom_destroy(geom2_);
-            GEOSWKTWriter_destroy(wktw_);
-            GEOSBufferParams_destroy(bp_);
-            GEOSFree(wkt_);
-            geom1_ = nullptr;
-            geom2_ = nullptr;
-            wkt_ = nullptr;
-            finishGEOS();
-        }
-
-    };
-
-    typedef test_group<test_capigeosbuffer_data> group;
-    typedef group::object object;
-
-    group test_capigeosbuffer_group("capi::GEOSBuffer");
-
-    //
-    // Test Cases
-    //
-
-
-    // Buffer against empty point
-    template<>
-    template<>
-    void object::test<1>()
+        std::fprintf(stdout, "NOTICE: ");
+
+        va_list ap;
+        va_start(ap, fmt);
+        std::vfprintf(stdout, fmt, ap);
+        va_end(ap);
+
+        std::fprintf(stdout, "\n");
+    }
+
+    test_capigeosbuffer_data()
+        : geom1_(nullptr), geom2_(nullptr), wkt_(nullptr), bp_(nullptr)
     {
-        geom1_ = GEOSGeomFromWKT("POINT EMPTY");
+        initGEOS(notice, notice);
+        wktw_ = GEOSWKTWriter_create();
+        GEOSWKTWriter_setTrim(wktw_, 1);
+    }
 
-        ensure( nullptr != geom1_ );
+    ~test_capigeosbuffer_data()
+    {
+        GEOSGeom_destroy(geom1_);
+        GEOSGeom_destroy(geom2_);
+        GEOSWKTWriter_destroy(wktw_);
+        GEOSBufferParams_destroy(bp_);
+        GEOSFree(wkt_);
+        geom1_ = nullptr;
+        geom2_ = nullptr;
+        wkt_ = nullptr;
+        finishGEOS();
+    }
 
-        geom2_ = GEOSBufferWithStyle(geom1_, 1, 8,
-                                     GEOSBUF_CAP_ROUND,
-                                     GEOSBUF_JOIN_BEVEL,
-                                     5.0);
+};
 
-        ensure( nullptr != geom2_ );
+typedef test_group<test_capigeosbuffer_data> group;
+typedef group::object object;
 
-        wkt_ = GEOSGeomToWKT(geom2_);
+group test_capigeosbuffer_group("capi::GEOSBuffer");
 
-        ensure_equals(std::string(wkt_), std::string("POLYGON EMPTY"));
-    }
+//
+// Test Cases
+//
 
-    // Buffer against empty linestring
-    template<>
-    template<>
-    void object::test<2>()
-    {
-        geom1_ = GEOSGeomFromWKT("LINESTRING EMPTY");
 
-        ensure( nullptr != geom1_ );
+// Buffer against empty point
+template<>
+template<>
+void object::test<1>
+()
+{
+    geom1_ = GEOSGeomFromWKT("POINT EMPTY");
 
-        geom2_ = GEOSBufferWithStyle(geom1_, 1, 8,
-                                     GEOSBUF_CAP_ROUND,
-                                     GEOSBUF_JOIN_BEVEL,
-                                     5.0);
+    ensure(nullptr != geom1_);
 
-        ensure( nullptr != geom2_ );
+    geom2_ = GEOSBufferWithStyle(geom1_, 1, 8,
+                                 GEOSBUF_CAP_ROUND,
+                                 GEOSBUF_JOIN_BEVEL,
+                                 5.0);
 
-        wkt_ = GEOSGeomToWKT(geom2_);
+    ensure(nullptr != geom2_);
 
-        ensure_equals(std::string(wkt_), std::string("POLYGON EMPTY"));
-    }
+    wkt_ = GEOSGeomToWKT(geom2_);
 
-    // Buffer against empty polygon
-    template<>
-    template<>
-    void object::test<3>()
-    {
-        geom1_ = GEOSGeomFromWKT("POLYGON EMPTY");
+    ensure_equals(std::string(wkt_), std::string("POLYGON EMPTY"));
+}
 
-        ensure( nullptr != geom1_ );
+// Buffer against empty linestring
+template<>
+template<>
+void object::test<2>
+()
+{
+    geom1_ = GEOSGeomFromWKT("LINESTRING EMPTY");
 
-        geom2_ = GEOSBufferWithStyle(geom1_, 1, 8,
-                                     GEOSBUF_CAP_ROUND,
-                                     GEOSBUF_JOIN_BEVEL,
-                                     5.0);
+    ensure(nullptr != geom1_);
 
-        ensure( nullptr != geom2_ );
+    geom2_ = GEOSBufferWithStyle(geom1_, 1, 8,
+                                 GEOSBUF_CAP_ROUND,
+                                 GEOSBUF_JOIN_BEVEL,
+                                 5.0);
 
-        wkt_ = GEOSGeomToWKT(geom2_);
+    ensure(nullptr != geom2_);
 
-        ensure_equals(std::string(wkt_), std::string("POLYGON EMPTY"));
-    }
+    wkt_ = GEOSGeomToWKT(geom2_);
 
-    // Simple Buffer on a 2-vertices line (quadSegs: 1)
-    template<>
-    template<>
-    void object::test<4>()
-    {
-        geom1_ = GEOSGeomFromWKT("LINESTRING(5 10, 10 20)");
+    ensure_equals(std::string(wkt_), std::string("POLYGON EMPTY"));
+}
 
-        ensure( nullptr != geom1_ );
+// Buffer against empty polygon
+template<>
+template<>
+void object::test<3>
+()
+{
+    geom1_ = GEOSGeomFromWKT("POLYGON EMPTY");
 
-        geom2_ = GEOSBuffer(geom1_, 5, 1);
+    ensure(nullptr != geom1_);
 
-        ensure( nullptr != geom2_ );
+    geom2_ = GEOSBufferWithStyle(geom1_, 1, 8,
+                                 GEOSBUF_CAP_ROUND,
+                                 GEOSBUF_JOIN_BEVEL,
+                                 5.0);
 
-        wkt_ = GEOSGeomToWKT(geom2_);
+    ensure(nullptr != geom2_);
 
-        ensure_equals(GEOSGetNumCoordinates(geom2_), 7);
+    wkt_ = GEOSGeomToWKT(geom2_);
 
-        ensure(0 != GEOSArea(geom2_, &area_));
-        ensure_area(area_, 161.803, 0.001);
+    ensure_equals(std::string(wkt_), std::string("POLYGON EMPTY"));
+}
 
-    }
+// Simple Buffer on a 2-vertices line (quadSegs: 1)
+template<>
+template<>
+void object::test<4>
+()
+{
+    geom1_ = GEOSGeomFromWKT("LINESTRING(5 10, 10 20)");
 
-    // Simple Buffer on a 2-vertices line (quadSegs: 2)
-    template<>
-    template<>
-    void object::test<5>()
-    {
-        geom1_ = GEOSGeomFromWKT("LINESTRING(5 10, 10 20)");
+    ensure(nullptr != geom1_);
 
-        ensure( nullptr != geom1_ );
+    geom2_ = GEOSBuffer(geom1_, 5, 1);
 
-        geom2_ = GEOSBuffer(geom1_, 5, 2);
+    ensure(nullptr != geom2_);
 
-        ensure( nullptr != geom2_ );
+    wkt_ = GEOSGeomToWKT(geom2_);
 
-        wkt_ = GEOSGeomToWKT(geom2_);
+    ensure_equals(GEOSGetNumCoordinates(geom2_), 7);
 
-        ensure_equals(GEOSGetNumCoordinates(geom2_), 11);
+    ensure(0 != GEOSArea(geom2_, &area_));
+    ensure_area(area_, 161.803, 0.001);
 
-        ensure(0 != GEOSArea(geom2_, &area_));
-        ensure_area(area_, 182.514, 0.001);
-    }
+}
 
-    // Buffer with square end caps on a 2-vertices line (no matter quadSegs)
-    template<>
-    template<>
-    void object::test<6>()
-    {
-        geom1_ = GEOSGeomFromWKT("LINESTRING(5 10, 10 20)");
+// Simple Buffer on a 2-vertices line (quadSegs: 2)
+template<>
+template<>
+void object::test<5>
+()
+{
+    geom1_ = GEOSGeomFromWKT("LINESTRING(5 10, 10 20)");
 
-        ensure( nullptr != geom1_ );
+    ensure(nullptr != geom1_);
 
-        geom2_ = GEOSBufferWithStyle(geom1_, 5, 20, GEOSBUF_CAP_SQUARE,
-                                     GEOSBUF_JOIN_ROUND, 5.0);
+    geom2_ = GEOSBuffer(geom1_, 5, 2);
 
-        ensure( nullptr != geom2_ );
+    ensure(nullptr != geom2_);
 
-        wkt_ = GEOSGeomToWKT(geom2_);
+    wkt_ = GEOSGeomToWKT(geom2_);
 
-        ensure_equals(GEOSGetNumCoordinates(geom2_), 7);
+    ensure_equals(GEOSGetNumCoordinates(geom2_), 11);
 
-        ensure(0 != GEOSArea(geom2_, &area_));
-        ensure_area(area_, 211.803, 0.001);
+    ensure(0 != GEOSArea(geom2_, &area_));
+    ensure_area(area_, 182.514, 0.001);
+}
 
-    }
+// Buffer with square end caps on a 2-vertices line (no matter quadSegs)
+template<>
+template<>
+void object::test<6>
+()
+{
+    geom1_ = GEOSGeomFromWKT("LINESTRING(5 10, 10 20)");
 
-    // Buffer with flat end caps on a 2-vertices line (no matter quadSegs)
-    template<>
-    template<>
-    void object::test<7>()
-    {
-        geom1_ = GEOSGeomFromWKT("LINESTRING(5 10, 10 20)");
+    ensure(nullptr != geom1_);
 
-        ensure( nullptr != geom1_ );
+    geom2_ = GEOSBufferWithStyle(geom1_, 5, 20, GEOSBUF_CAP_SQUARE,
+                                 GEOSBUF_JOIN_ROUND, 5.0);
 
-        geom2_ = GEOSBufferWithStyle(geom1_, 5, 20, GEOSBUF_CAP_FLAT,
-                                     GEOSBUF_JOIN_ROUND, 5.0);
+    ensure(nullptr != geom2_);
 
-        ensure( nullptr != geom2_ );
+    wkt_ = GEOSGeomToWKT(geom2_);
 
-        wkt_ = GEOSGeomToWKT(geom2_);
+    ensure_equals(GEOSGetNumCoordinates(geom2_), 7);
 
-        ensure_equals(GEOSGetNumCoordinates(geom2_), 5);
+    ensure(0 != GEOSArea(geom2_, &area_));
+    ensure_area(area_, 211.803, 0.001);
 
-        ensure(0 != GEOSArea(geom2_, &area_));
-        ensure_area(area_, 111.803, 0.001);
-    }
+}
 
-    // Buffer with flat end cap on a 2-vertices horizontal line
-    template<>
-    template<>
-    void object::test<8>()
-    {
-        geom1_ = GEOSGeomFromWKT("LINESTRING(5 10, 10 10)");
+// Buffer with flat end caps on a 2-vertices line (no matter quadSegs)
+template<>
+template<>
+void object::test<7>
+()
+{
+    geom1_ = GEOSGeomFromWKT("LINESTRING(5 10, 10 20)");
 
-        ensure( nullptr != geom1_ );
+    ensure(nullptr != geom1_);
 
-        geom2_ = GEOSBufferWithStyle(geom1_, 5, 20, GEOSBUF_CAP_FLAT,
-                                     GEOSBUF_JOIN_ROUND, 5.0);
+    geom2_ = GEOSBufferWithStyle(geom1_, 5, 20, GEOSBUF_CAP_FLAT,
+                                 GEOSBUF_JOIN_ROUND, 5.0);
 
-        ensure( nullptr != geom2_ );
+    ensure(nullptr != geom2_);
 
-        wkt_ = GEOSGeomToWKT(geom2_);
+    wkt_ = GEOSGeomToWKT(geom2_);
 
-        ensure_equals(GEOSGetNumCoordinates(geom2_), 5);
+    ensure_equals(GEOSGetNumCoordinates(geom2_), 5);
 
-        ensure(0 != GEOSArea(geom2_, &area_));
-        ensure_area(area_, 50.0, 0.001);
+    ensure(0 != GEOSArea(geom2_, &area_));
+    ensure_area(area_, 111.803, 0.001);
+}
 
-        ensure_equals(std::string(wkt_), std::string(
-"POLYGON ((10.0000000000000000 15.0000000000000000, 10.0000000000000000 5.0000000000000000, 5.0000000000000000 5.0000000000000000, 5.0000000000000000 15.0000000000000000, 10.0000000000000000 15.0000000000000000))"
-        ));
-    }
+// Buffer with flat end cap on a 2-vertices horizontal line
+template<>
+template<>
+void object::test<8>
+()
+{
+    geom1_ = GEOSGeomFromWKT("LINESTRING(5 10, 10 10)");
 
-    // Buffer with square end cap on a 2-vertices horizontal line
-    template<>
-    template<>
-    void object::test<9>()
-    {
-        geom1_ = GEOSGeomFromWKT("LINESTRING(5 10, 10 10)");
+    ensure(nullptr != geom1_);
 
-        ensure( nullptr != geom1_ );
+    geom2_ = GEOSBufferWithStyle(geom1_, 5, 20, GEOSBUF_CAP_FLAT,
+                                 GEOSBUF_JOIN_ROUND, 5.0);
 
-        geom2_ = GEOSBufferWithStyle(geom1_, 5, 20, GEOSBUF_CAP_SQUARE,
-                                     GEOSBUF_JOIN_ROUND, 5.0);
+    ensure(nullptr != geom2_);
 
-        ensure( nullptr != geom2_ );
+    wkt_ = GEOSGeomToWKT(geom2_);
 
-        wkt_ = GEOSGeomToWKT(geom2_);
+    ensure_equals(GEOSGetNumCoordinates(geom2_), 5);
 
-        ensure_equals(GEOSGetNumCoordinates(geom2_), 7);
+    ensure(0 != GEOSArea(geom2_, &area_));
+    ensure_area(area_, 50.0, 0.001);
 
-        ensure(0 != GEOSArea(geom2_, &area_));
-        ensure_area(area_, 150.0, 0.001);
+    ensure_equals(std::string(wkt_), std::string(
+                      "POLYGON ((10.0000000000000000 15.0000000000000000, 10.0000000000000000 5.0000000000000000, 5.0000000000000000 5.0000000000000000, 5.0000000000000000 15.0000000000000000, 10.0000000000000000 15.0000000000000000))"
+                  ));
+}
 
-        ensure_equals(std::string(wkt_), std::string(
-"POLYGON ((10.0000000000000000 15.0000000000000000, 15.0000000000000000 15.0000000000000000, 15.0000000000000000 5.0000000000000000, 5.0000000000000000 5.0000000000000000, 0.0000000000000000 5.0000000000000009, 0.0000000000000000 15.0000000000000000, 10.0000000000000000 15.0000000000000000))"
-        ));
-    }
+// Buffer with square end cap on a 2-vertices horizontal line
+template<>
+template<>
+void object::test<9>
+()
+{
+    geom1_ = GEOSGeomFromWKT("LINESTRING(5 10, 10 10)");
 
-    // Buffer with flat end cap and round join style
-    // on an L-shaped simple line
-    template<>
-    template<>
-    void object::test<10>()
-    {
-        geom1_ = GEOSGeomFromWKT("LINESTRING(5 10, 10 10, 10 20)");
+    ensure(nullptr != geom1_);
 
-        ensure( nullptr != geom1_ );
+    geom2_ = GEOSBufferWithStyle(geom1_, 5, 20, GEOSBUF_CAP_SQUARE,
+                                 GEOSBUF_JOIN_ROUND, 5.0);
 
-        geom2_ = GEOSBufferWithStyle(geom1_, 5, 20, GEOSBUF_CAP_SQUARE,
-                                     GEOSBUF_JOIN_ROUND, 5.0);
+    ensure(nullptr != geom2_);
 
-        ensure( nullptr != geom2_ );
+    wkt_ = GEOSGeomToWKT(geom2_);
 
-        wkt_ = GEOSGeomToWKT(geom2_);
+    ensure_equals(GEOSGetNumCoordinates(geom2_), 7);
 
-        ensure_equals(GEOSGetNumCoordinates(geom2_), 29);
+    ensure(0 != GEOSArea(geom2_, &area_));
+    ensure_area(area_, 150.0, 0.001);
 
-        ensure(0 != GEOSArea(geom2_, &area_));
-        ensure_area(area_, 244.615, 0.001);
+    ensure_equals(std::string(wkt_), std::string(
+                      "POLYGON ((10.0000000000000000 15.0000000000000000, 15.0000000000000000 15.0000000000000000, 15.0000000000000000 5.0000000000000000, 5.0000000000000000 5.0000000000000000, 0.0000000000000000 5.0000000000000009, 0.0000000000000000 15.0000000000000000, 10.0000000000000000 15.0000000000000000))"
+                  ));
+}
 
-    }
+// Buffer with flat end cap and round join style
+// on an L-shaped simple line
+template<>
+template<>
+void object::test<10>
+()
+{
+    geom1_ = GEOSGeomFromWKT("LINESTRING(5 10, 10 10, 10 20)");
 
-    // Buffer with flat end cap and mitre join style
-    // on an L-shaped simple line
-    template<>
-    template<>
-    void object::test<11>()
-    {
-        geom1_ = GEOSGeomFromWKT("LINESTRING(5 10, 10 10, 10 20)");
+    ensure(nullptr != geom1_);
 
-        ensure( nullptr != geom1_ );
+    geom2_ = GEOSBufferWithStyle(geom1_, 5, 20, GEOSBUF_CAP_SQUARE,
+                                 GEOSBUF_JOIN_ROUND, 5.0);
 
-        geom2_ = GEOSBufferWithStyle(geom1_, 5, 20, GEOSBUF_CAP_SQUARE,
-                                     GEOSBUF_JOIN_MITRE, 5.0);
+    ensure(nullptr != geom2_);
 
-        ensure( nullptr != geom2_ );
+    wkt_ = GEOSGeomToWKT(geom2_);
 
-        wkt_ = GEOSGeomToWKT(geom2_);
+    ensure_equals(GEOSGetNumCoordinates(geom2_), 29);
 
-        ensure_equals(GEOSGetNumCoordinates(geom2_), 9);
+    ensure(0 != GEOSArea(geom2_, &area_));
+    ensure_area(area_, 244.615, 0.001);
 
-        ensure(0 != GEOSArea(geom2_, &area_));
-        ensure_area(area_, 250.0, 0.001);
+}
 
-        ensure_equals(std::string(wkt_), std::string(
-"POLYGON ((5.0000000000000000 15.0000000000000000, 5.0000000000000000 20.0000000000000000, 5.0000000000000000 25.0000000000000000, 15.0000000000000000 25.0000000000000000, 15.0000000000000000 5.0000000000000000, 5.0000000000000000 5.0000000000000000, 0.0000000000000000 5.0000000000000009, 0.0000000000000000 15.0000000000000000, 5.0000000000000000 15.0000000000000000))"
-        ));
-    }
+// Buffer with flat end cap and mitre join style
+// on an L-shaped simple line
+template<>
+template<>
+void object::test<11>
+()
+{
+    geom1_ = GEOSGeomFromWKT("LINESTRING(5 10, 10 10, 10 20)");
 
-    // Buffer with flat end cap and bevel join style
-    // on an L-shaped simple line
-    template<>
-    template<>
-    void object::test<12>()
-    {
-        geom1_ = GEOSGeomFromWKT("LINESTRING(5 10, 10 10, 10 20)");
+    ensure(nullptr != geom1_);
 
-        ensure( nullptr != geom1_ );
+    geom2_ = GEOSBufferWithStyle(geom1_, 5, 20, GEOSBUF_CAP_SQUARE,
+                                 GEOSBUF_JOIN_MITRE, 5.0);
 
-        geom2_ = GEOSBufferWithStyle(geom1_, 5, 20, GEOSBUF_CAP_SQUARE,
-                                     GEOSBUF_JOIN_BEVEL, 5.0);
+    ensure(nullptr != geom2_);
 
-        ensure( nullptr != geom2_ );
+    wkt_ = GEOSGeomToWKT(geom2_);
 
-        wkt_ = GEOSGeomToWKT(geom2_);
+    ensure_equals(GEOSGetNumCoordinates(geom2_), 9);
 
-        ensure_equals(GEOSGetNumCoordinates(geom2_), 10);
+    ensure(0 != GEOSArea(geom2_, &area_));
+    ensure_area(area_, 250.0, 0.001);
 
-        ensure(0 != GEOSArea(geom2_, &area_));
-        ensure_area(area_, 237.5, 0.001);
+    ensure_equals(std::string(wkt_), std::string(
+                      "POLYGON ((5.0000000000000000 15.0000000000000000, 5.0000000000000000 20.0000000000000000, 5.0000000000000000 25.0000000000000000, 15.0000000000000000 25.0000000000000000, 15.0000000000000000 5.0000000000000000, 5.0000000000000000 5.0000000000000000, 0.0000000000000000 5.0000000000000009, 0.0000000000000000 15.0000000000000000, 5.0000000000000000 15.0000000000000000))"
+                  ));
+}
 
-        ensure_equals(std::string(wkt_), std::string(
-"POLYGON ((5.0000000000000000 15.0000000000000000, 5.0000000000000000 20.0000000000000000, 5.0000000000000000 25.0000000000000000, 15.0000000000000000 25.0000000000000000, 15.0000000000000000 10.0000000000000000, 10.0000000000000000 5.0000000000000000, 5.0000000000000000 5.0000000000000000, 0.0000000000000000 5.0000000000000009, 0.0000000000000000 15.0000000000000000, 5.0000000000000000 15.0000000000000000))"
-        ));
-    }
+// Buffer with flat end cap and bevel join style
+// on an L-shaped simple line
+template<>
+template<>
+void object::test<12>
+()
+{
+    geom1_ = GEOSGeomFromWKT("LINESTRING(5 10, 10 10, 10 20)");
 
-    // Buffer with flat end cap and bevel join style
-    // on an L-shaped simple line with different quadSegs and mitreLimit
-    // (result unaffected)
-    template<>
-    template<>
-    void object::test<13>()
-    {
-        geom1_ = GEOSGeomFromWKT("LINESTRING(5 10, 10 10, 10 20)");
+    ensure(nullptr != geom1_);
 
-        ensure( nullptr != geom1_ );
+    geom2_ = GEOSBufferWithStyle(geom1_, 5, 20, GEOSBUF_CAP_SQUARE,
+                                 GEOSBUF_JOIN_BEVEL, 5.0);
 
-        geom2_ = GEOSBufferWithStyle(geom1_, 5, 200, GEOSBUF_CAP_SQUARE,
-                                     GEOSBUF_JOIN_BEVEL, 10.0);
+    ensure(nullptr != geom2_);
 
-        ensure( nullptr != geom2_ );
+    wkt_ = GEOSGeomToWKT(geom2_);
 
-        wkt_ = GEOSGeomToWKT(geom2_);
+    ensure_equals(GEOSGetNumCoordinates(geom2_), 10);
 
-        ensure_equals(GEOSGetNumCoordinates(geom2_), 10);
+    ensure(0 != GEOSArea(geom2_, &area_));
+    ensure_area(area_, 237.5, 0.001);
 
-        ensure(0 != GEOSArea(geom2_, &area_));
-        ensure_area(area_, 237.5, 0.001);
+    ensure_equals(std::string(wkt_), std::string(
+                      "POLYGON ((5.0000000000000000 15.0000000000000000, 5.0000000000000000 20.0000000000000000, 5.0000000000000000 25.0000000000000000, 15.0000000000000000 25.0000000000000000, 15.0000000000000000 10.0000000000000000, 10.0000000000000000 5.0000000000000000, 5.0000000000000000 5.0000000000000000, 0.0000000000000000 5.0000000000000009, 0.0000000000000000 15.0000000000000000, 5.0000000000000000 15.0000000000000000))"
+                  ));
+}
 
-        ensure_equals(std::string(wkt_), std::string(
-"POLYGON ((5.0000000000000000 15.0000000000000000, 5.0000000000000000 20.0000000000000000, 5.0000000000000000 25.0000000000000000, 15.0000000000000000 25.0000000000000000, 15.0000000000000000 10.0000000000000000, 10.0000000000000000 5.0000000000000000, 5.0000000000000000 5.0000000000000000, 0.0000000000000000 5.0000000000000009, 0.0000000000000000 15.0000000000000000, 5.0000000000000000 15.0000000000000000))"
-        ));
-    }
+// Buffer with flat end cap and bevel join style
+// on an L-shaped simple line with different quadSegs and mitreLimit
+// (result unaffected)
+template<>
+template<>
+void object::test<13>
+()
+{
+    geom1_ = GEOSGeomFromWKT("LINESTRING(5 10, 10 10, 10 20)");
 
-    // Buffer with limited mitre  (1)
-    template<>
-    template<>
-    void object::test<14>()
-    {
-        geom1_ = GEOSGeomFromWKT("POLYGON((0 0, 10 0, 10 10, 0 0))");
+    ensure(nullptr != geom1_);
 
-        ensure( nullptr != geom1_ );
+    geom2_ = GEOSBufferWithStyle(geom1_, 5, 200, GEOSBUF_CAP_SQUARE,
+                                 GEOSBUF_JOIN_BEVEL, 10.0);
 
-        geom2_ = GEOSBufferWithStyle(geom1_, 2, 200, GEOSBUF_CAP_FLAT,
-                                     GEOSBUF_JOIN_MITRE, 1);
+    ensure(nullptr != geom2_);
 
-        ensure( nullptr != geom2_ );
+    wkt_ = GEOSGeomToWKT(geom2_);
 
-        wkt_ = GEOSGeomToWKT(geom2_);
+    ensure_equals(GEOSGetNumCoordinates(geom2_), 10);
 
-        ensure_equals(GEOSGetNumCoordinates(geom2_), 7);
+    ensure(0 != GEOSArea(geom2_, &area_));
+    ensure_area(area_, 237.5, 0.001);
 
-        ensure(0 != GEOSArea(geom2_, &area_));
-        ensure_area(area_, 127.452, 0.001);
+    ensure_equals(std::string(wkt_), std::string(
+                      "POLYGON ((5.0000000000000000 15.0000000000000000, 5.0000000000000000 20.0000000000000000, 5.0000000000000000 25.0000000000000000, 15.0000000000000000 25.0000000000000000, 15.0000000000000000 10.0000000000000000, 10.0000000000000000 5.0000000000000000, 5.0000000000000000 5.0000000000000000, 0.0000000000000000 5.0000000000000009, 0.0000000000000000 15.0000000000000000, 5.0000000000000000 15.0000000000000000))"
+                  ));
+}
 
-    }
+// Buffer with limited mitre  (1)
+template<>
+template<>
+void object::test<14>
+()
+{
+    geom1_ = GEOSGeomFromWKT("POLYGON((0 0, 10 0, 10 10, 0 0))");
 
-    // Buffer with limited mitre  (2)
-    template<>
-    template<>
-    void object::test<15>()
-    {
-        geom1_ = GEOSGeomFromWKT("POLYGON((0 0, 10 0, 10 10, 0 0))");
+    ensure(nullptr != geom1_);
 
-        ensure( nullptr != geom1_ );
+    geom2_ = GEOSBufferWithStyle(geom1_, 2, 200, GEOSBUF_CAP_FLAT,
+                                 GEOSBUF_JOIN_MITRE, 1);
 
-        geom2_ = GEOSBufferWithStyle(geom1_, 2, 200, GEOSBUF_CAP_FLAT,
-                                     GEOSBUF_JOIN_MITRE, 2);
+    ensure(nullptr != geom2_);
 
-        ensure( nullptr != geom2_ );
+    wkt_ = GEOSGeomToWKT(geom2_);
 
-        wkt_ = GEOSGeomToWKT(geom2_);
+    ensure_equals(GEOSGetNumCoordinates(geom2_), 7);
 
-        ensure_equals(GEOSGetNumCoordinates(geom2_), 6);
+    ensure(0 != GEOSArea(geom2_, &area_));
+    ensure_area(area_, 127.452, 0.001);
 
-        ensure(0 != GEOSArea(geom2_, &area_));
-        ensure_area(area_, 139.043, 0.001);
+}
 
-    }
+// Buffer with limited mitre  (2)
+template<>
+template<>
+void object::test<15>
+()
+{
+    geom1_ = GEOSGeomFromWKT("POLYGON((0 0, 10 0, 10 10, 0 0))");
 
-    // Buffer with limited mitre  (3)
-    template<>
-    template<>
-    void object::test<16>()
-    {
-        geom1_ = GEOSGeomFromWKT("POLYGON((0 0, 10 0, 10 10, 0 0))");
+    ensure(nullptr != geom1_);
 
-        ensure( nullptr != geom1_ );
+    geom2_ = GEOSBufferWithStyle(geom1_, 2, 200, GEOSBUF_CAP_FLAT,
+                                 GEOSBUF_JOIN_MITRE, 2);
 
-        geom2_ = GEOSBufferWithStyle(geom1_, 2, 200, GEOSBUF_CAP_FLAT,
-                                     GEOSBUF_JOIN_MITRE, 3);
+    ensure(nullptr != geom2_);
 
-        ensure( nullptr != geom2_ );
+    wkt_ = GEOSGeomToWKT(geom2_);
 
-        wkt_ = GEOSGeomToWKT(geom2_);
+    ensure_equals(GEOSGetNumCoordinates(geom2_), 6);
 
-        ensure_equals(GEOSGetNumCoordinates(geom2_), 4);
+    ensure(0 != GEOSArea(geom2_, &area_));
+    ensure_area(area_, 139.043, 0.001);
 
-        ensure(0 != GEOSArea(geom2_, &area_));
-        ensure_area(area_, 141.598, 0.001);
+}
 
-    }
+// Buffer with limited mitre  (3)
+template<>
+template<>
+void object::test<16>
+()
+{
+    geom1_ = GEOSGeomFromWKT("POLYGON((0 0, 10 0, 10 10, 0 0))");
 
-    // Buffer with params:
-    // flat end cap on a straight line
-    template<>
-    template<>
-    void object::test<17>()
-    {
-        geom1_ = GEOSGeomFromWKT("LINESTRING(5 10, 10 10)");
+    ensure(nullptr != geom1_);
 
-        ensure( nullptr != geom1_ );
+    geom2_ = GEOSBufferWithStyle(geom1_, 2, 200, GEOSBUF_CAP_FLAT,
+                                 GEOSBUF_JOIN_MITRE, 3);
 
-        bp_ = GEOSBufferParams_create();
+    ensure(nullptr != geom2_);
 
-        GEOSBufferParams_setEndCapStyle(bp_, GEOSBUF_CAP_SQUARE);
-        geom2_ = GEOSBufferWithParams(geom1_, bp_, 2);
+    wkt_ = GEOSGeomToWKT(geom2_);
 
-        ensure( nullptr != geom2_ );
+    ensure_equals(GEOSGetNumCoordinates(geom2_), 4);
 
-        wkt_ = GEOSWKTWriter_write(wktw_, geom2_);
+    ensure(0 != GEOSArea(geom2_, &area_));
+    ensure_area(area_, 141.598, 0.001);
 
-        ensure_equals(std::string(wkt_), std::string(
-"POLYGON ((10 12, 12 12, 12 8, 5 8, 3 8, 3 12, 10 12))"
-));
-    }
+}
 
-    // Buffer with params:
-    // flat end cap on a straight line
-    // Single sided (left)
-    template<>
-    template<>
-    void object::test<18>()
-    {
-        geom1_ = GEOSGeomFromWKT("LINESTRING(5 10, 10 10)");
+// Buffer with params:
+// flat end cap on a straight line
+template<>
+template<>
+void object::test<17>
+()
+{
+    geom1_ = GEOSGeomFromWKT("LINESTRING(5 10, 10 10)");
 
-        ensure( nullptr != geom1_ );
+    ensure(nullptr != geom1_);
 
-        bp_ = GEOSBufferParams_create();
+    bp_ = GEOSBufferParams_create();
 
-        GEOSBufferParams_setEndCapStyle(bp_, GEOSBUF_CAP_SQUARE);
-        GEOSBufferParams_setSingleSided(bp_, 1);
-        geom2_ = GEOSBufferWithParams(geom1_, bp_, 2);
+    GEOSBufferParams_setEndCapStyle(bp_, GEOSBUF_CAP_SQUARE);
+    geom2_ = GEOSBufferWithParams(geom1_, bp_, 2);
 
-        ensure( nullptr != geom2_ );
+    ensure(nullptr != geom2_);
 
-        wkt_ = GEOSWKTWriter_write(wktw_, geom2_);
+    wkt_ = GEOSWKTWriter_write(wktw_, geom2_);
 
-        ensure_equals(std::string(wkt_), std::string(
-"POLYGON ((10 10, 5 10, 5 12, 10 12, 10 10))"
-));
-    }
+    ensure_equals(std::string(wkt_), std::string(
+                      "POLYGON ((10 12, 12 12, 12 8, 5 8, 3 8, 3 12, 10 12))"
+                  ));
+}
 
-    // Buffer with params:
-    // flat end cap on a straight line
-    // Single sided (right)
-    template<>
-    template<>
-    void object::test<19>()
-    {
-        geom1_ = GEOSGeomFromWKT("LINESTRING(5 10, 10 10)");
+// Buffer with params:
+// flat end cap on a straight line
+// Single sided (left)
+template<>
+template<>
+void object::test<18>
+()
+{
+    geom1_ = GEOSGeomFromWKT("LINESTRING(5 10, 10 10)");
 
-        ensure( nullptr != geom1_ );
+    ensure(nullptr != geom1_);
 
-        bp_ = GEOSBufferParams_create();
+    bp_ = GEOSBufferParams_create();
 
-        GEOSBufferParams_setEndCapStyle(bp_, GEOSBUF_CAP_SQUARE);
-        GEOSBufferParams_setSingleSided(bp_, 1);
-        geom2_ = GEOSBufferWithParams(geom1_, bp_, -2);
+    GEOSBufferParams_setEndCapStyle(bp_, GEOSBUF_CAP_SQUARE);
+    GEOSBufferParams_setSingleSided(bp_, 1);
+    geom2_ = GEOSBufferWithParams(geom1_, bp_, 2);
 
-        ensure( nullptr != geom2_ );
+    ensure(nullptr != geom2_);
 
-        wkt_ = GEOSWKTWriter_write(wktw_, geom2_);
+    wkt_ = GEOSWKTWriter_write(wktw_, geom2_);
 
-        ensure_equals(std::string(wkt_), std::string(
-"POLYGON ((5 10, 10 10, 10 8, 5 8, 5 10))"
-));
-    }
+    ensure_equals(std::string(wkt_), std::string(
+                      "POLYGON ((10 10, 5 10, 5 12, 10 12, 10 10))"
+                  ));
+}
 
-    // Single-sided buffer  (3)
-    // http://trac.osgeo.org/geos/ticket/455
-    template<>
-    template<>
-    void object::test<20>()
-    {
-        geom1_ = GEOSGeomFromWKT("LINESTRING(0 0, 10 0, 10 10)', -10)");
+// Buffer with params:
+// flat end cap on a straight line
+// Single sided (right)
+template<>
+template<>
+void object::test<19>
+()
+{
+    geom1_ = GEOSGeomFromWKT("LINESTRING(5 10, 10 10)");
 
-        ensure( nullptr != geom1_ );
+    ensure(nullptr != geom1_);
 
-        geom2_ = GEOSSingleSidedBuffer(geom1_, 10, 8, GEOSBUF_JOIN_BEVEL, 0, 0);
+    bp_ = GEOSBufferParams_create();
 
-        ensure( nullptr != geom2_ );
+    GEOSBufferParams_setEndCapStyle(bp_, GEOSBUF_CAP_SQUARE);
+    GEOSBufferParams_setSingleSided(bp_, 1);
+    geom2_ = GEOSBufferWithParams(geom1_, bp_, -2);
 
-        wkt_ = GEOSGeomToWKT(geom2_);
+    ensure(nullptr != geom2_);
 
-        ensure_equals(std::string(wkt_), std::string(
-"LINESTRING (20.0000000000000000 10.0000000000000000, 20.0000000000000000 0.0000000000000000, 10.0000000000000000 -10.0000000000000000, 0.0000000000000000 -10.0000000000000000)"
-        ));
+    wkt_ = GEOSWKTWriter_write(wktw_, geom2_);
 
-    }
+    ensure_equals(std::string(wkt_), std::string(
+                      "POLYGON ((5 10, 10 10, 10 8, 5 8, 5 10))"
+                  ));
+}
+
+// Single-sided buffer  (3)
+// http://trac.osgeo.org/geos/ticket/455
+template<>
+template<>
+void object::test<20>
+()
+{
+    geom1_ = GEOSGeomFromWKT("LINESTRING(0 0, 10 0, 10 10)', -10)");
+
+    ensure(nullptr != geom1_);
+
+    geom2_ = GEOSSingleSidedBuffer(geom1_, 10, 8, GEOSBUF_JOIN_BEVEL, 0, 0);
+
+    ensure(nullptr != geom2_);
+
+    wkt_ = GEOSGeomToWKT(geom2_);
+
+    ensure_equals(std::string(wkt_), std::string(
+                      "LINESTRING (20.0000000000000000 10.0000000000000000, 20.0000000000000000 0.0000000000000000, 10.0000000000000000 -10.0000000000000000, 0.0000000000000000 -10.0000000000000000)"
+                  ));
+
+}
 
 } // namespace tut
 
diff --git a/tests/unit/capi/GEOSCAPIDefinesTest.cpp b/tests/unit/capi/GEOSCAPIDefinesTest.cpp
index c82e7f1..4f72373 100644
--- a/tests/unit/capi/GEOSCAPIDefinesTest.cpp
+++ b/tests/unit/capi/GEOSCAPIDefinesTest.cpp
@@ -13,44 +13,47 @@
 #define QUOTE(x) #x
 #define EXPAND_AND_QUOTE(y) QUOTE(y)
 
-namespace tut
+namespace tut {
+//
+// Test Group
+//
+
+struct basic {};
+
+typedef test_group<basic> group;
+typedef group::object object;
+
+group test_capidefines_group("capi::defines");
+
+// Make sure version elements all defined
+template<>
+template<>
+void object::test<1>
+()
+{
+    ensure(std::string(EXPAND_AND_QUOTE(GEOS_VERSION_MAJOR)).length() > 0);
+    ensure(std::string(EXPAND_AND_QUOTE(GEOS_VERSION_MINOR)).length() > 0);
+    ensure(std::string(EXPAND_AND_QUOTE(GEOS_VERSION_PATCH)).length() > 0);
+    ensure(std::string(GEOS_VERSION).length() > 0);
+
+    ensure(std::string(EXPAND_AND_QUOTE(GEOS_CAPI_VERSION_MAJOR)).length() > 0);
+    ensure(std::string(EXPAND_AND_QUOTE(GEOS_CAPI_VERSION_MINOR)).length() > 0);
+    ensure(std::string(EXPAND_AND_QUOTE(GEOS_CAPI_VERSION_PATCH)).length() > 0);
+    ensure(std::string(GEOS_CAPI_VERSION).length() > 0);
+}
+
+// Make sure version representations agree
+template<>
+template<>
+void object::test<2>
+()
 {
-    //
-    // Test Group
-    //
-
-    struct basic {};
-
-    typedef test_group<basic> group;
-    typedef group::object object;
-
-    group test_capidefines_group("capi::defines");
-
-    // Make sure version elements all defined
-    template<>
-    template<>
-    void object::test<1>() {
-        ensure(std::string(EXPAND_AND_QUOTE(GEOS_VERSION_MAJOR)).length() > 0);
-        ensure(std::string(EXPAND_AND_QUOTE(GEOS_VERSION_MINOR)).length() > 0);
-        ensure(std::string(EXPAND_AND_QUOTE(GEOS_VERSION_PATCH)).length() > 0);
-        ensure(std::string(GEOS_VERSION).length() > 0);
-
-        ensure(std::string(EXPAND_AND_QUOTE(GEOS_CAPI_VERSION_MAJOR)).length() > 0);
-        ensure(std::string(EXPAND_AND_QUOTE(GEOS_CAPI_VERSION_MINOR)).length() > 0);
-        ensure(std::string(EXPAND_AND_QUOTE(GEOS_CAPI_VERSION_PATCH)).length() > 0);
-        ensure(std::string(GEOS_CAPI_VERSION).length() > 0);
-    }
-
-    // Make sure version representations agree
-    template<>
-    template<>
-    void object::test<2>() {
-        ensure_equals(
-                GEOS_VERSION,
-                std::string(EXPAND_AND_QUOTE(GEOS_VERSION_MAJOR)) + "." +
-                std::string(EXPAND_AND_QUOTE(GEOS_VERSION_MINOR)) + "." +
-                std::string(EXPAND_AND_QUOTE(GEOS_VERSION_PATCH)));
-    }
+    ensure_equals(
+        GEOS_VERSION,
+        std::string(EXPAND_AND_QUOTE(GEOS_VERSION_MAJOR)) + "." +
+        std::string(EXPAND_AND_QUOTE(GEOS_VERSION_MINOR)) + "." +
+        std::string(EXPAND_AND_QUOTE(GEOS_VERSION_PATCH)));
+}
 
 } // namespace tut
 
diff --git a/tests/unit/capi/GEOSClipByRectTest.cpp b/tests/unit/capi/GEOSClipByRectTest.cpp
index b0eb02f..fe66fca 100644
--- a/tests/unit/capi/GEOSClipByRectTest.cpp
+++ b/tests/unit/capi/GEOSClipByRectTest.cpp
@@ -10,182 +10,195 @@
 #include <cstdlib>
 #include <memory>
 
-namespace tut
-{
-  //
-  // Test Group
-  //
+namespace tut {
+//
+// Test Group
+//
 
-  // Common data used in test cases.
-  struct test_capigeosclipbyrect_data
-  {
+// Common data used in test cases.
+struct test_capigeosclipbyrect_data {
     GEOSGeometry* geom1_;
     GEOSGeometry* geom2_;
     GEOSGeometry* geom3_;
     GEOSWKTWriter* w_;
 
-    static void notice(const char *fmt, ...)
+    static void
+    notice(const char* fmt, ...)
     {
-      std::fprintf( stdout, "NOTICE: ");
+        std::fprintf(stdout, "NOTICE: ");
 
-      va_list ap;
-      va_start(ap, fmt);
-      std::vfprintf(stdout, fmt, ap);
-      va_end(ap);
+        va_list ap;
+        va_start(ap, fmt);
+        std::vfprintf(stdout, fmt, ap);
+        va_end(ap);
 
-      std::fprintf(stdout, "\n");
+        std::fprintf(stdout, "\n");
     }
 
-    void isEqual(GEOSGeom g, const char *exp_wkt)
+    void
+    isEqual(GEOSGeom g, const char* exp_wkt)
     {
-      geom3_ = GEOSGeomFromWKT(exp_wkt);
-      bool eq = GEOSEquals(geom3_, g);
-      if ( ! eq ) {
-        std::printf("EXP: %s\n", exp_wkt);
-        char *obt_wkt = GEOSWKTWriter_write(w_, g);
-        std::printf("OBT: %s\n", obt_wkt);
-        free(obt_wkt);
-      }
-      ensure(eq);
+        geom3_ = GEOSGeomFromWKT(exp_wkt);
+        bool eq = GEOSEquals(geom3_, g);
+        if(! eq) {
+            std::printf("EXP: %s\n", exp_wkt);
+            char* obt_wkt = GEOSWKTWriter_write(w_, g);
+            std::printf("OBT: %s\n", obt_wkt);
+            free(obt_wkt);
+        }
+        ensure(eq);
     }
 
     test_capigeosclipbyrect_data()
-      : geom1_(nullptr), geom2_(nullptr), geom3_(nullptr), w_(nullptr)
+        : geom1_(nullptr), geom2_(nullptr), geom3_(nullptr), w_(nullptr)
     {
-      initGEOS(notice, notice);
-      w_ = GEOSWKTWriter_create();
-      GEOSWKTWriter_setTrim(w_, 1);
-      GEOSWKTWriter_setRoundingPrecision(w_, 8);
+        initGEOS(notice, notice);
+        w_ = GEOSWKTWriter_create();
+        GEOSWKTWriter_setTrim(w_, 1);
+        GEOSWKTWriter_setRoundingPrecision(w_, 8);
     }
 
     ~test_capigeosclipbyrect_data()
     {
-      GEOSGeom_destroy(geom1_);
-      GEOSGeom_destroy(geom2_);
-      GEOSGeom_destroy(geom3_);
-      GEOSWKTWriter_destroy(w_);
-      geom1_ = nullptr;
-      geom2_ = nullptr;
-      geom3_ = nullptr;
-      finishGEOS();
+        GEOSGeom_destroy(geom1_);
+        GEOSGeom_destroy(geom2_);
+        GEOSGeom_destroy(geom3_);
+        GEOSWKTWriter_destroy(w_);
+        geom1_ = nullptr;
+        geom2_ = nullptr;
+        geom3_ = nullptr;
+        finishGEOS();
     }
 
-  };
+};
 
-  typedef test_group<test_capigeosclipbyrect_data> group;
-  typedef group::object object;
+typedef test_group<test_capigeosclipbyrect_data> group;
+typedef group::object object;
 
-  group test_capigeosclipbyrect_group("capi::GEOSClipByRect");
+group test_capigeosclipbyrect_group("capi::GEOSClipByRect");
 
-  //
-  // Test Cases
-  //
+//
+// Test Cases
+//
 
-  /// Point outside
-  template<> template<> void object::test<1>()
-  {
+/// Point outside
+template<> template<> void object::test<1>
+()
+{
     geom1_ = GEOSGeomFromWKT("POINT(0 0)");
     geom2_ = GEOSClipByRect(geom1_, 10, 10, 20, 20);
     isEqual(geom2_, "POINT EMPTY");
-  }
+}
 
-  /// Point inside
-  template<> template<> void object::test<2>()
-  {
+/// Point inside
+template<> template<> void object::test<2>
+()
+{
     geom1_ = GEOSGeomFromWKT("POINT(15 15)");
     geom2_ = GEOSClipByRect(geom1_, 10, 10, 20, 20);
     isEqual(geom2_, "POINT(15 15)");
-  }
+}
 
-  /// Point on boundary
-  template<> template<> void object::test<3>()
-  {
+/// Point on boundary
+template<> template<> void object::test<3>
+()
+{
     geom1_ = GEOSGeomFromWKT("POINT(15 10)");
     geom2_ = GEOSClipByRect(geom1_, 10, 10, 20, 20);
     isEqual(geom2_, "POINT EMPTY");
-  }
+}
 
-  /// Line outside
-  template<> template<> void object::test<4>()
-  {
+/// Line outside
+template<> template<> void object::test<4>
+()
+{
     geom1_ = GEOSGeomFromWKT("LINESTRING(0 0, -5 5)");
     geom2_ = GEOSClipByRect(geom1_, 10, 10, 20, 20);
     isEqual(geom2_, "LINESTRING EMPTY");
-  }
+}
 
-  /// Line inside
-  template<> template<> void object::test<5>()
-  {
+/// Line inside
+template<> template<> void object::test<5>
+()
+{
     geom1_ = GEOSGeomFromWKT("LINESTRING(15 15, 16 15)");
     geom2_ = GEOSClipByRect(geom1_, 10, 10, 20, 20);
     isEqual(geom2_, "LINESTRING(15 15, 16 15)");
-  }
+}
 
-  /// Line on boundary
-  template<> template<> void object::test<6>()
-  {
+/// Line on boundary
+template<> template<> void object::test<6>
+()
+{
     geom1_ = GEOSGeomFromWKT("LINESTRING(10 15, 10 10, 15 10)");
     geom2_ = GEOSClipByRect(geom1_, 10, 10, 20, 20);
     isEqual(geom2_, "LINESTRING EMPTY");
-  }
+}
 
-  /// Line splitting rectangle
-  template<> template<> void object::test<7>()
-  {
+/// Line splitting rectangle
+template<> template<> void object::test<7>
+()
+{
     geom1_ = GEOSGeomFromWKT("LINESTRING(10 5, 25 20)");
     geom2_ = GEOSClipByRect(geom1_, 10, 10, 20, 20);
     isEqual(geom2_, "LINESTRING (15 10, 20 15)");
-  }
+}
 
-  /// Polygon shell (CCW) fully on rectangle boundary
-  template<> template<> void object::test<8>()
-  {
+/// Polygon shell (CCW) fully on rectangle boundary
+template<> template<> void object::test<8>
+()
+{
     geom1_ = GEOSGeomFromWKT("POLYGON((10 10, 20 10, 20 20, 10 20, 10 10))");
     geom2_ = GEOSClipByRect(geom1_, 10, 10, 20, 20);
     isEqual(geom2_, "POLYGON((10 10, 20 10, 20 20, 10 20, 10 10))");
-  }
+}
 
-  /// Polygon shell (CW) fully on rectangle boundary
-  template<> template<> void object::test<9>()
-  {
+/// Polygon shell (CW) fully on rectangle boundary
+template<> template<> void object::test<9>
+()
+{
     geom1_ = GEOSGeomFromWKT("POLYGON((10 10, 10 20, 20 20, 20 10, 10 10))");
     geom2_ = GEOSClipByRect(geom1_, 10, 10, 20, 20);
     isEqual(geom2_, "POLYGON((10 10, 20 10, 20 20, 10 20, 10 10))");
-  }
+}
 
-  /// Polygon hole (CCW) fully on rectangle boundary
-  template<> template<> void object::test<10>()
-  {
+/// Polygon hole (CCW) fully on rectangle boundary
+template<> template<> void object::test<10>
+()
+{
     geom1_ = GEOSGeomFromWKT("POLYGON((0 0, 0 30, 30 30, 30 0, 0 0),(10 10, 20 10, 20 20, 10 20, 10 10))");
     geom2_ = GEOSClipByRect(geom1_, 10, 10, 20, 20);
     isEqual(geom2_, "POLYGON EMPTY");
-  }
+}
 
-  /// Polygon hole (CW) fully on rectangle boundary
-  template<> template<> void object::test<11>()
-  {
+/// Polygon hole (CW) fully on rectangle boundary
+template<> template<> void object::test<11>
+()
+{
     geom1_ = GEOSGeomFromWKT("POLYGON((0 0, 0 30, 30 30, 30 0, 0 0),(10 10, 10 20, 20 20, 20 10, 10 10))");
     geom2_ = GEOSClipByRect(geom1_, 10, 10, 20, 20);
     isEqual(geom2_, "POLYGON EMPTY");
-  }
+}
 
-  /// Polygon fully within rectangle
-  template<> template<> void object::test<12>()
-  {
-    const char *wkt = "POLYGON((1 1, 1 30, 30 30, 30 1, 1 1),(10 10, 20 10, 20 20, 10 20, 10 10))";
+/// Polygon fully within rectangle
+template<> template<> void object::test<12>
+()
+{
+    const char* wkt = "POLYGON((1 1, 1 30, 30 30, 30 1, 1 1),(10 10, 20 10, 20 20, 10 20, 10 10))";
     geom1_ = GEOSGeomFromWKT(wkt);
     geom2_ = GEOSClipByRect(geom1_, 0, 0, 40, 40);
     isEqual(geom2_, wkt);
-  }
+}
 
-  /// Polygon overlapping rectangle
-  template<> template<> void object::test<13>()
-  {
-    const char *wkt = "POLYGON((0 0, 0 30, 30 30, 30 0, 0 0),(10 10, 20 10, 20 20, 10 20, 10 10))";
+/// Polygon overlapping rectangle
+template<> template<> void object::test<13>
+()
+{
+    const char* wkt = "POLYGON((0 0, 0 30, 30 30, 30 0, 0 0),(10 10, 20 10, 20 20, 10 20, 10 10))";
     geom1_ = GEOSGeomFromWKT(wkt);
     geom2_ = GEOSClipByRect(geom1_, 5, 5, 15, 15);
     isEqual(geom2_, "POLYGON ((5 5, 5 15, 10 15, 10 10, 15 10, 15 5, 5 5))");
-  }
+}
 
 } // namespace tut
 
diff --git a/tests/unit/capi/GEOSContainsTest.cpp b/tests/unit/capi/GEOSContainsTest.cpp
index ef0a508..4b54e4c 100644
--- a/tests/unit/capi/GEOSContainsTest.cpp
+++ b/tests/unit/capi/GEOSContainsTest.cpp
@@ -11,220 +11,228 @@
 #include <cstdio>
 #include <cstdlib>
 
-namespace tut
-{
-    //
-    // Test Group
-    //
+namespace tut {
+//
+// Test Group
+//
+
+// Common data used in test cases.
+struct test_capigeoscontains_data {
+    GEOSGeometry* geom1_;
+    GEOSGeometry* geom2_;
 
-    // Common data used in test cases.
-    struct test_capigeoscontains_data
+    static void
+    notice(const char* fmt, ...)
     {
-        GEOSGeometry* geom1_;
-        GEOSGeometry* geom2_;
-
-        static void notice(const char *fmt, ...)
-        {
-            std::fprintf( stdout, "NOTICE: ");
-
-            va_list ap;
-            va_start(ap, fmt);
-            std::vfprintf(stdout, fmt, ap);
-            va_end(ap);
-
-            std::fprintf(stdout, "\n");
-        }
-
-        test_capigeoscontains_data()
-            : geom1_(nullptr), geom2_(nullptr)
-        {
-            initGEOS(notice, notice);
-        }
-
-        ~test_capigeoscontains_data()
-        {
-            GEOSGeom_destroy(geom1_);
-            GEOSGeom_destroy(geom2_);
-            geom1_ = nullptr;
-            geom2_ = nullptr;
-            finishGEOS();
-        }
-
-    };
-
-    typedef test_group<test_capigeoscontains_data> group;
-    typedef group::object object;
-
-    group test_capigeoscontains_group("capi::GEOSContains");
-
-    //
-    // Test Cases
-    //
-
-    template<>
-    template<>
-    void object::test<1>()
+        std::fprintf(stdout, "NOTICE: ");
+
+        va_list ap;
+        va_start(ap, fmt);
+        std::vfprintf(stdout, fmt, ap);
+        va_end(ap);
+
+        std::fprintf(stdout, "\n");
+    }
+
+    test_capigeoscontains_data()
+        : geom1_(nullptr), geom2_(nullptr)
     {
-        geom1_ = GEOSGeomFromWKT("POLYGON EMPTY");
-        geom2_ = GEOSGeomFromWKT("POLYGON EMPTY");
+        initGEOS(notice, notice);
+    }
 
-        ensure( nullptr != geom1_ );
-        ensure( nullptr != geom2_ );
+    ~test_capigeoscontains_data()
+    {
+        GEOSGeom_destroy(geom1_);
+        GEOSGeom_destroy(geom2_);
+        geom1_ = nullptr;
+        geom2_ = nullptr;
+        finishGEOS();
+    }
 
-        char const r1 = GEOSContains(geom1_, geom2_);
+};
 
-        ensure_equals(r1, 0);
+typedef test_group<test_capigeoscontains_data> group;
+typedef group::object object;
 
-        char const r2 = GEOSContains(geom2_, geom1_);
+group test_capigeoscontains_group("capi::GEOSContains");
 
-        ensure_equals(r2, 0);
-    }
+//
+// Test Cases
+//
 
-    template<>
-    template<>
-    void object::test<2>()
-    {
-        geom1_ = GEOSGeomFromWKT("POLYGON((1 1,1 5,5 5,5 1,1 1))");
-        geom2_ = GEOSGeomFromWKT("POINT(2 2)");
+template<>
+template<>
+void object::test<1>
+()
+{
+    geom1_ = GEOSGeomFromWKT("POLYGON EMPTY");
+    geom2_ = GEOSGeomFromWKT("POLYGON EMPTY");
 
-        ensure( nullptr != geom1_ );
-        ensure( nullptr != geom2_ );
+    ensure(nullptr != geom1_);
+    ensure(nullptr != geom2_);
 
-        char const r1 = GEOSContains(geom1_, geom2_);
+    char const r1 = GEOSContains(geom1_, geom2_);
 
-        ensure_equals(int(r1), 1);
+    ensure_equals(r1, 0);
 
-        char const r2 = GEOSContains(geom2_, geom1_);
+    char const r2 = GEOSContains(geom2_, geom1_);
 
-        ensure_equals(int(r2), 0);
-    }
+    ensure_equals(r2, 0);
+}
 
-    template<>
-    template<>
-    void object::test<3>()
-    {
-        geom1_ = GEOSGeomFromWKT("MULTIPOLYGON(((0 0,0 10,10 10,10 0,0 0)))");
-        geom2_ = GEOSGeomFromWKT("POLYGON((1 1,1 2,2 2,2 1,1 1))");
+template<>
+template<>
+void object::test<2>
+()
+{
+    geom1_ = GEOSGeomFromWKT("POLYGON((1 1,1 5,5 5,5 1,1 1))");
+    geom2_ = GEOSGeomFromWKT("POINT(2 2)");
+
+    ensure(nullptr != geom1_);
+    ensure(nullptr != geom2_);
+
+    char const r1 = GEOSContains(geom1_, geom2_);
+
+    ensure_equals(int(r1), 1);
+
+    char const r2 = GEOSContains(geom2_, geom1_);
+
+    ensure_equals(int(r2), 0);
+}
 
-        ensure( nullptr != geom1_ );
-        ensure( nullptr != geom2_ );
+template<>
+template<>
+void object::test<3>
+()
+{
+    geom1_ = GEOSGeomFromWKT("MULTIPOLYGON(((0 0,0 10,10 10,10 0,0 0)))");
+    geom2_ = GEOSGeomFromWKT("POLYGON((1 1,1 2,2 2,2 1,1 1))");
+
+    ensure(nullptr != geom1_);
+    ensure(nullptr != geom2_);
 
-        char const r1 = GEOSContains(geom1_, geom2_);
+    char const r1 = GEOSContains(geom1_, geom2_);
 
-        ensure_equals(int(r1), 1);
+    ensure_equals(int(r1), 1);
 
-        char const r2 = GEOSContains(geom2_, geom1_);
+    char const r2 = GEOSContains(geom2_, geom1_);
 
-        ensure_equals(int(r2), 0);
+    ensure_equals(int(r2), 0);
+}
+
+// Test outer polygon contains inner polygon with two coincident vertices
+// with results compared depending on precision used with FIXED PMs.
+template<>
+template<>
+void object::test<4>
+()
+{
+    // Coincident vertives of both polygons at
+    // -700.67089999181 93743.4218587986, -713.450135807349 93754.1677576647,
+    std::string const
+    outer("01030000800100000009000000af9dd0005ee585c0f802efbff6e2f6400000000000000000955acde0994b86c039a922afa2e3f64000000000000000002af6fb4f5d1887c07adb1c4071e3f6400000000000000000e5962b388d4f87c0bd3aeda7bae2f640000000000000000087c61344030887c07d585e6ff6e1f6400000000000000000fc8a31b5166186c0230588b20ae1f640000000000000000034733daf050186c0ed9f3ac98ae1f6400000000000000000f190aef659b385c0df2876538ce2f6400000000000000000af9dd0005ee585c0f802efbff6e2f6400000000000000000");
+    std::string const
+    inner("0103000080010000000a000000ac21f88bbaff86c05f45d8c7b4e2f6400000000000000000467f1177ebf386c05de1971187e2f6400000000000000000fcf677888fc886c04e855a544be2f6400000000000000000c61226e540b686c0c0662d1fe7e1f640000000000000000042dc1bece8a486c09b85529f8ae1f6400000000000000000891047cde55e86c038cfa59c4ee1f6400000000000000000ae9dd0005ee585c0fa02efbff6e2f6400000000000000000975acde0994b86c038a922afa2e3f6400000000000000000287e339b09f986c01b1a083a10e3f6400000000000000000ac21f88bbaff86c05f45d8c7b4e2f6400000000000000000");
+
+    // A contains B if precision is limited to 1e+10
+    {
+        geos::geom::PrecisionModel pm(1e+10);
+        geos::geom::GeometryFactory::Ptr factory = geos::geom::GeometryFactory::create(&pm);
+        geos::io::WKBReader reader(*factory);
+
+        std::istringstream sOuter(outer);
+        geom1_ = reinterpret_cast<GEOSGeometry*>(reader.readHEX(sOuter));
+        std::istringstream sInner(inner);
+        geom2_ = reinterpret_cast<GEOSGeometry*>(reader.readHEX(sInner));
+        ensure(nullptr != geom1_);
+        ensure(nullptr != geom2_);
+
+        int ret = GEOSContains(geom1_, geom2_);
+        ensure_equals(ret, 1);
+        ret = GEOSContains(geom2_, geom1_);
+        ensure_equals(ret, 0);
+        GEOSGeom_destroy(geom1_);
+        GEOSGeom_destroy(geom2_);
     }
 
-    // Test outer polygon contains inner polygon with two coincident vertices
-    // with results compared depending on precision used with FIXED PMs.
-    template<>
-    template<>
-    void object::test<4>()
+    // A does NOT contain B if precision is extended to 1e+11 or beyond
+    {
+        geos::geom::PrecisionModel pm(1e+11);
+        geos::geom::GeometryFactory::Ptr factory = geos::geom::GeometryFactory::create(&pm);
+        geos::io::WKBReader reader(*factory);
+
+        std::istringstream sOuter(outer);
+        geom1_ = reinterpret_cast<GEOSGeometry*>(reader.readHEX(sOuter));
+        std::istringstream sInner(inner);
+        geom2_ = reinterpret_cast<GEOSGeometry*>(reader.readHEX(sInner));
+        ensure(nullptr != geom1_);
+        ensure(nullptr != geom2_);
+
+        int ret = GEOSContains(geom1_, geom2_);
+        ensure_equals(ret, 0);
+        ret = GEOSContains(geom2_, geom1_);
+        ensure_equals(ret, 0);
+    }
+}
+
+// Test outer rectangle contains inner rectangle with one coincident vertex
+// and two vertices of the inner rectangle are on the boundary (lay on segments)
+// of the outer rectangle.
+// Precision model should not affect the containment test result.
+template<>
+template<>
+void object::test<5>
+()
+{
+    // Coincident vertex at -753.167968418005 93709.4279185742
+    //POLYGON ((-753.167968418005 93754.0955183194,-816.392328351464 93754.0955183194,-816.392328351464 93709.4279185742,-753.167968418005 93709.4279185742,-753.167968418005 93754.0955183194))
+    std::string const
+    outer("01030000800100000005000000bd70d3ff578987c09e373e87a1e3f6400000000000000000a9f60b7d238389c09e373e87a1e3f6400000000000000000a9f60b7d238389c09625c1d8d6e0f6400000000000000000bd70d3ff578987c09625c1d8d6e0f6400000000000000000bd70d3ff578987c09e373e87a1e3f6400000000000000000");
+    //POLYGON ((-753.167968418005 93747.6909727677,-799.641978447015 93747.6909727677,-799.641978447015 93709.4279185742,-753.167968418005 93709.4279185742,-753.167968418005 93747.6909727677))
+    std::string const
+    inner("01030000800100000005000000bd70d3ff578987c0f875390e3be3f6400000000000000000579598c522fd88c0f875390e3be3f6400000000000000000579598c522fd88c09625c1d8d6e0f6400000000000000000bd70d3ff578987c09625c1d8d6e0f6400000000000000000bd70d3ff578987c0f875390e3be3f6400000000000000000");
+
+    // A contains B if precision is limited to 1e+10
     {
-        // Coincident vertives of both polygons at
-        // -700.67089999181 93743.4218587986, -713.450135807349 93754.1677576647,
-        std::string const outer("01030000800100000009000000af9dd0005ee585c0f802efbff6e2f6400000000000000000955acde0994b86c039a922afa2e3f64000000000000000002af6fb4f5d1887c07adb1c4071e3f6400000000000000000e5962b388d4f87c0bd3aeda7bae2f640000000000000000087c61344030887c07d585e6ff6e1f6400000000000000000fc8a31b5166186c0230588b20ae1f640000000000000000034733daf050186c0ed9f3ac98ae1f6400000000000000000f190aef659b385c0df2876538ce2f6400000000000000000af9dd0005ee585c0f802efbff6e2f6400000000000000000");
-        std::string const inner("0103000080010000000a000000ac21f88bbaff86c05f45d8c7b4e2f6400000000000000000467f1177ebf386c05de1971187e2f6400000000000000000fcf677888fc886c04e855a544be2f6400000000000000000c61226e540b686c0c0662d1fe7e1f640000000000000000042dc1bece8a486c09b85529f8ae1f6400000000000000000891047cde55e86c038cfa59c4ee1f6400000000000000000ae9dd0005ee585c0fa02efbff6e2f6400000000000000000975acde0994b86c038a922afa2e3f6400000000000000000287e339b09f986c01b1a083a10e3f6400000000000000000ac21f88bbaff86c05f45d8c7b4e2f6400000000000000000");
-
-        // A contains B if precision is limited to 1e+10
-        {
-            geos::geom::PrecisionModel pm(1e+10);
-            geos::geom::GeometryFactory::Ptr factory = geos::geom::GeometryFactory::create(&pm);
-            geos::io::WKBReader reader(*factory);
-
-            std::istringstream sOuter(outer);
-            geom1_ = reinterpret_cast<GEOSGeometry*>(reader.readHEX(sOuter));
-            std::istringstream sInner(inner);
-            geom2_ = reinterpret_cast<GEOSGeometry*>(reader.readHEX(sInner));
-            ensure(nullptr != geom1_);
-            ensure(nullptr != geom2_);
-
-            int ret = GEOSContains(geom1_, geom2_);
-            ensure_equals(ret, 1);
-            ret = GEOSContains(geom2_, geom1_);
-            ensure_equals(ret, 0);
-            GEOSGeom_destroy(geom1_);
-            GEOSGeom_destroy(geom2_);
-        }
-
-        // A does NOT contain B if precision is extended to 1e+11 or beyond
-        {
-            geos::geom::PrecisionModel pm(1e+11);
-            geos::geom::GeometryFactory::Ptr factory = geos::geom::GeometryFactory::create(&pm);
-            geos::io::WKBReader reader(*factory);
-
-            std::istringstream sOuter(outer);
-            geom1_ = reinterpret_cast<GEOSGeometry*>(reader.readHEX(sOuter));
-            std::istringstream sInner(inner);
-            geom2_ = reinterpret_cast<GEOSGeometry*>(reader.readHEX(sInner));
-            ensure(nullptr != geom1_);
-            ensure(nullptr != geom2_);
-
-            int ret = GEOSContains(geom1_, geom2_);
-            ensure_equals(ret, 0);
-            ret = GEOSContains(geom2_, geom1_);
-            ensure_equals(ret, 0);
-        }
+        geos::geom::PrecisionModel pm(1e+10);
+        geos::geom::GeometryFactory::Ptr factory = geos::geom::GeometryFactory::create(&pm);
+        geos::io::WKBReader reader(*factory);
+
+        std::istringstream sOuter(outer);
+        geom1_ = reinterpret_cast<GEOSGeometry*>(reader.readHEX(sOuter));
+        std::istringstream sInner(inner);
+        geom2_ = reinterpret_cast<GEOSGeometry*>(reader.readHEX(sInner));
+        ensure(nullptr != geom1_);
+        ensure(nullptr != geom2_);
+
+        int ret = GEOSContains(geom1_, geom2_);
+        ensure_equals(ret, 1);
+        ret = GEOSContains(geom2_, geom1_);
+        ensure_equals(ret, 0);
+
+        GEOSGeom_destroy(geom1_);
+        GEOSGeom_destroy(geom2_);
     }
 
-    // Test outer rectangle contains inner rectangle with one coincident vertex
-    // and two vertices of the inner rectangle are on the boundary (lay on segments)
-    // of the outer rectangle.
-    // Precision model should not affect the containment test result.
-    template<>
-    template<>
-    void object::test<5>()
+    // A contains B if FLOATING PM is used with extended precision
     {
-        // Coincident vertex at -753.167968418005 93709.4279185742
-        //POLYGON ((-753.167968418005 93754.0955183194,-816.392328351464 93754.0955183194,-816.392328351464 93709.4279185742,-753.167968418005 93709.4279185742,-753.167968418005 93754.0955183194))
-        std::string const outer("01030000800100000005000000bd70d3ff578987c09e373e87a1e3f6400000000000000000a9f60b7d238389c09e373e87a1e3f6400000000000000000a9f60b7d238389c09625c1d8d6e0f6400000000000000000bd70d3ff578987c09625c1d8d6e0f6400000000000000000bd70d3ff578987c09e373e87a1e3f6400000000000000000");
-        //POLYGON ((-753.167968418005 93747.6909727677,-799.641978447015 93747.6909727677,-799.641978447015 93709.4279185742,-753.167968418005 93709.4279185742,-753.167968418005 93747.6909727677))
-        std::string const inner("01030000800100000005000000bd70d3ff578987c0f875390e3be3f6400000000000000000579598c522fd88c0f875390e3be3f6400000000000000000579598c522fd88c09625c1d8d6e0f6400000000000000000bd70d3ff578987c09625c1d8d6e0f6400000000000000000bd70d3ff578987c0f875390e3be3f6400000000000000000");
-
-        // A contains B if precision is limited to 1e+10
-        {
-            geos::geom::PrecisionModel pm(1e+10);
-            geos::geom::GeometryFactory::Ptr factory = geos::geom::GeometryFactory::create(&pm);
-            geos::io::WKBReader reader(*factory);
-
-            std::istringstream sOuter(outer);
-            geom1_ = reinterpret_cast<GEOSGeometry*>(reader.readHEX(sOuter));
-            std::istringstream sInner(inner);
-            geom2_ = reinterpret_cast<GEOSGeometry*>(reader.readHEX(sInner));
-            ensure(nullptr != geom1_);
-            ensure(nullptr != geom2_);
-
-            int ret = GEOSContains(geom1_, geom2_);
-            ensure_equals(ret, 1);
-            ret = GEOSContains(geom2_, geom1_);
-            ensure_equals(ret, 0);
-
-            GEOSGeom_destroy(geom1_);
-            GEOSGeom_destroy(geom2_);
-        }
-
-        // A contains B if FLOATING PM is used with extended precision
-        {
-            geos::geom::PrecisionModel pm;
-            geos::geom::GeometryFactory::Ptr factory = geos::geom::GeometryFactory::create(&pm);
-            geos::io::WKBReader reader(*factory);
-
-            std::istringstream sOuter(outer);
-            geom1_ = reinterpret_cast<GEOSGeometry*>(reader.readHEX(sOuter));
-            std::istringstream sInner(inner);
-            geom2_ = reinterpret_cast<GEOSGeometry*>(reader.readHEX(sInner));
-            ensure(nullptr != geom1_);
-            ensure(nullptr != geom2_);
-
-            int ret = GEOSContains(geom1_, geom2_);
-            ensure_equals(ret, 1);
-            ret = GEOSContains(geom2_, geom1_);
-            ensure_equals(ret, 0);
-        }
+        geos::geom::PrecisionModel pm;
+        geos::geom::GeometryFactory::Ptr factory = geos::geom::GeometryFactory::create(&pm);
+        geos::io::WKBReader reader(*factory);
+
+        std::istringstream sOuter(outer);
+        geom1_ = reinterpret_cast<GEOSGeometry*>(reader.readHEX(sOuter));
+        std::istringstream sInner(inner);
+        geom2_ = reinterpret_cast<GEOSGeometry*>(reader.readHEX(sInner));
+        ensure(nullptr != geom1_);
+        ensure(nullptr != geom2_);
+
+        int ret = GEOSContains(geom1_, geom2_);
+        ensure_equals(ret, 1);
+        ret = GEOSContains(geom2_, geom1_);
+        ensure_equals(ret, 0);
     }
+}
 
 } // namespace tut
 
diff --git a/tests/unit/capi/GEOSConvexHullTest.cpp b/tests/unit/capi/GEOSConvexHullTest.cpp
index 18b7fc3..417694c 100644
--- a/tests/unit/capi/GEOSConvexHullTest.cpp
+++ b/tests/unit/capi/GEOSConvexHullTest.cpp
@@ -9,73 +9,73 @@
 #include <cstdio>
 #include <cstdlib>
 
-namespace tut
-{
-    //
-    // Test Group
-    //
+namespace tut {
+//
+// Test Group
+//
 
-    // Common data used in test cases.
-    struct test_capigeosconvexhull_data
+// Common data used in test cases.
+struct test_capigeosconvexhull_data {
+    GEOSGeometry* input_;
+    GEOSGeometry* expected_;
+
+    static void
+    notice(const char* fmt, ...)
     {
-        GEOSGeometry* input_;
-        GEOSGeometry* expected_;
-
-        static void notice(const char *fmt, ...)
-        {
-            std::fprintf( stdout, "NOTICE: ");
-
-            va_list ap;
-            va_start(ap, fmt);
-            std::vfprintf(stdout, fmt, ap);
-            va_end(ap);
-
-            std::fprintf(stdout, "\n");
-        }
-
-        test_capigeosconvexhull_data()
-            : input_(nullptr), expected_(nullptr)
-        {
-            initGEOS(notice, notice);
-        }
-
-        ~test_capigeosconvexhull_data()
-        {
-            GEOSGeom_destroy(input_);
-            GEOSGeom_destroy(expected_);
-            input_ = nullptr;
-            expected_ = nullptr;
-            finishGEOS();
-        }
-
-    };
-
-    typedef test_group<test_capigeosconvexhull_data> group;
-    typedef group::object object;
-
-    group test_capigeosconvexhull_group("capi::GEOSConvexHull");
-
-    //
-    // Test Cases
-    //
-
-    template<>
-    template<>
-    void object::test<1>()
+        std::fprintf(stdout, "NOTICE: ");
+
+        va_list ap;
+        va_start(ap, fmt);
+        std::vfprintf(stdout, fmt, ap);
+        va_end(ap);
+
+        std::fprintf(stdout, "\n");
+    }
+
+    test_capigeosconvexhull_data()
+        : input_(nullptr), expected_(nullptr)
     {
-        input_ = GEOSGeomFromWKT("MULTIPOINT (130 240, 130 240, 130 240, 570 240, 570 240, 570 240, 650 240)");
-        ensure( nullptr != input_ );
-
-        expected_ = GEOSGeomFromWKT("LINESTRING (130 240, 650 240, 130 240)");
-        ensure( nullptr != expected_ );
-
-        GEOSGeometry* output = GEOSConvexHull(input_);
-        ensure( nullptr != output );
-        ensure( 0 == GEOSisEmpty(output) );
-        // TODO
-        //ensure( 0 != GEOSEquals(output, expected_));
-        GEOSGeom_destroy(output);
+        initGEOS(notice, notice);
     }
 
+    ~test_capigeosconvexhull_data()
+    {
+        GEOSGeom_destroy(input_);
+        GEOSGeom_destroy(expected_);
+        input_ = nullptr;
+        expected_ = nullptr;
+        finishGEOS();
+    }
+
+};
+
+typedef test_group<test_capigeosconvexhull_data> group;
+typedef group::object object;
+
+group test_capigeosconvexhull_group("capi::GEOSConvexHull");
+
+//
+// Test Cases
+//
+
+template<>
+template<>
+void object::test<1>
+()
+{
+    input_ = GEOSGeomFromWKT("MULTIPOINT (130 240, 130 240, 130 240, 570 240, 570 240, 570 240, 650 240)");
+    ensure(nullptr != input_);
+
+    expected_ = GEOSGeomFromWKT("LINESTRING (130 240, 650 240, 130 240)");
+    ensure(nullptr != expected_);
+
+    GEOSGeometry* output = GEOSConvexHull(input_);
+    ensure(nullptr != output);
+    ensure(0 == GEOSisEmpty(output));
+    // TODO
+    //ensure( 0 != GEOSEquals(output, expected_));
+    GEOSGeom_destroy(output);
+}
+
 } // namespace tut
 
diff --git a/tests/unit/capi/GEOSCoordSeqTest.cpp b/tests/unit/capi/GEOSCoordSeqTest.cpp
index ff9324a..fc7d343 100644
--- a/tests/unit/capi/GEOSCoordSeqTest.cpp
+++ b/tests/unit/capi/GEOSCoordSeqTest.cpp
@@ -10,327 +10,339 @@
 #include <cstdlib>
 #include <memory>
 
-namespace tut
-{
-    //
-    // Test Group
-    //
+namespace tut {
+//
+// Test Group
+//
 
-    // Common data used in test cases.
-    struct test_capigeoscoordseq_data
-    {
+// Common data used in test cases.
+struct test_capigeoscoordseq_data {
 
-        GEOSCoordSequence* cs_;
+    GEOSCoordSequence* cs_;
 
-        static void notice(const char *fmt, ...)
-        {
-            std::fprintf( stdout, "NOTICE: ");
+    static void
+    notice(const char* fmt, ...)
+    {
+        std::fprintf(stdout, "NOTICE: ");
 
-            va_list ap;
-            va_start(ap, fmt);
-            std::vfprintf(stdout, fmt, ap);
-            va_end(ap);
+        va_list ap;
+        va_start(ap, fmt);
+        std::vfprintf(stdout, fmt, ap);
+        va_end(ap);
 
-            std::fprintf(stdout, "\n");
-        }
+        std::fprintf(stdout, "\n");
+    }
 
-        test_capigeoscoordseq_data() : cs_(nullptr)
-        {
-            initGEOS(notice, notice);
-        }
+    test_capigeoscoordseq_data() : cs_(nullptr)
+    {
+        initGEOS(notice, notice);
+    }
 
-        ~test_capigeoscoordseq_data()
-        {
-            GEOSCoordSeq_destroy(cs_);
-            cs_ = nullptr;
-            finishGEOS();
-        }
+    ~test_capigeoscoordseq_data()
+    {
+        GEOSCoordSeq_destroy(cs_);
+        cs_ = nullptr;
+        finishGEOS();
+    }
 
-    };
+};
 
-    typedef test_group<test_capigeoscoordseq_data> group;
-    typedef group::object object;
+typedef test_group<test_capigeoscoordseq_data> group;
+typedef group::object object;
 
-    group test_capigeoscoordseq_group("capi::GEOSCoordSeq");
+group test_capigeoscoordseq_group("capi::GEOSCoordSeq");
 
-    //
-    // Test Cases
-    //
+//
+// Test Cases
+//
 
-    // Test construction and fill of a 3D CoordinateSequence
-    template<>
-    template<>
-    void object::test<1>()
-    {
-        cs_ = GEOSCoordSeq_create(5, 3);
+// Test construction and fill of a 3D CoordinateSequence
+template<>
+template<>
+void object::test<1>
+()
+{
+    cs_ = GEOSCoordSeq_create(5, 3);
 
-        unsigned int size;
-        unsigned int dims;
+    unsigned int size;
+    unsigned int dims;
 
-        ensure ( 0 != GEOSCoordSeq_getSize(cs_, &size) );
-        ensure_equals( size, 5u );
+    ensure(0 != GEOSCoordSeq_getSize(cs_, &size));
+    ensure_equals(size, 5u);
 
-        ensure ( 0 != GEOSCoordSeq_getDimensions(cs_, &dims) );
-        ensure_equals( dims, 3u );
+    ensure(0 != GEOSCoordSeq_getDimensions(cs_, &dims));
+    ensure_equals(dims, 3u);
 
-        for (unsigned int i=0; i<5; ++i)
-        {
-            double x = i*10;
-            double y = i*10+1;
-            double z = i*10+2;
+    for(unsigned int i = 0; i < 5; ++i) {
+        double x = i * 10;
+        double y = i * 10 + 1;
+        double z = i * 10 + 2;
 
-            GEOSCoordSeq_setX(cs_, i, x);
-            GEOSCoordSeq_setY(cs_, i, y);
-            GEOSCoordSeq_setZ(cs_, i, z);
+        GEOSCoordSeq_setX(cs_, i, x);
+        GEOSCoordSeq_setY(cs_, i, y);
+        GEOSCoordSeq_setZ(cs_, i, z);
 
-            double xcheck, ycheck, zcheck;
-            ensure( 0 != GEOSCoordSeq_getX(cs_, i, &xcheck) );
-            ensure( 0 != GEOSCoordSeq_getY(cs_, i, &ycheck) );
-            ensure( 0 != GEOSCoordSeq_getZ(cs_, i, &zcheck) );
+        double xcheck, ycheck, zcheck;
+        ensure(0 != GEOSCoordSeq_getX(cs_, i, &xcheck));
+        ensure(0 != GEOSCoordSeq_getY(cs_, i, &ycheck));
+        ensure(0 != GEOSCoordSeq_getZ(cs_, i, &zcheck));
 
-            ensure_equals( xcheck, x );
-            ensure_equals( ycheck, y );
-            ensure_equals( zcheck, z );
-        }
+        ensure_equals(xcheck, x);
+        ensure_equals(ycheck, y);
+        ensure_equals(zcheck, z);
     }
+}
 
-    // Test not swapped setX/setY calls (see bug #133, fixed)
-    template<>
-    template<>
-    void object::test<2>()
-    {
-        cs_ = GEOSCoordSeq_create(1, 3);
+// Test not swapped setX/setY calls (see bug #133, fixed)
+template<>
+template<>
+void object::test<2>
+()
+{
+    cs_ = GEOSCoordSeq_create(1, 3);
 
-        unsigned int size;
-        unsigned int dims;
+    unsigned int size;
+    unsigned int dims;
 
-        ensure ( 0 != GEOSCoordSeq_getSize(cs_, &size) );
-        ensure_equals( size, 1u );
+    ensure(0 != GEOSCoordSeq_getSize(cs_, &size));
+    ensure_equals(size, 1u);
 
-        ensure ( 0 != GEOSCoordSeq_getDimensions(cs_, &dims) );
-        ensure_equals( dims, 3u );
+    ensure(0 != GEOSCoordSeq_getDimensions(cs_, &dims));
+    ensure_equals(dims, 3u);
 
-        double x = 10;
-        double y = 11;
-        double z = 12;
+    double x = 10;
+    double y = 11;
+    double z = 12;
 
-        // X, Y, Z
-        GEOSCoordSeq_setX(cs_, 0, x);
-        GEOSCoordSeq_setY(cs_, 0, y);
-        GEOSCoordSeq_setZ(cs_, 0, z);
+    // X, Y, Z
+    GEOSCoordSeq_setX(cs_, 0, x);
+    GEOSCoordSeq_setY(cs_, 0, y);
+    GEOSCoordSeq_setZ(cs_, 0, z);
 
-        double xcheck, ycheck, zcheck;
-        ensure( 0 != GEOSCoordSeq_getY(cs_, 0, &ycheck) );
-        ensure( 0 != GEOSCoordSeq_getX(cs_, 0, &xcheck) );
-        ensure( 0 != GEOSCoordSeq_getZ(cs_, 0, &zcheck) );
+    double xcheck, ycheck, zcheck;
+    ensure(0 != GEOSCoordSeq_getY(cs_, 0, &ycheck));
+    ensure(0 != GEOSCoordSeq_getX(cs_, 0, &xcheck));
+    ensure(0 != GEOSCoordSeq_getZ(cs_, 0, &zcheck));
 
-        ensure_equals( xcheck, x );
-        ensure_equals( ycheck, y );
-        ensure_equals( zcheck, z );
-    }
+    ensure_equals(xcheck, x);
+    ensure_equals(ycheck, y);
+    ensure_equals(zcheck, z);
+}
 
-    // Test not swapped setOrdinate calls (see bug #133, fixed)
-    template<>
-    template<>
-    void object::test<3>()
-    {
-        cs_ = GEOSCoordSeq_create(1, 3);
+// Test not swapped setOrdinate calls (see bug #133, fixed)
+template<>
+template<>
+void object::test<3>
+()
+{
+    cs_ = GEOSCoordSeq_create(1, 3);
 
-        unsigned int size;
-        unsigned int dims;
+    unsigned int size;
+    unsigned int dims;
 
-        ensure ( 0 != GEOSCoordSeq_getSize(cs_, &size) );
-        ensure_equals( size, 1u );
+    ensure(0 != GEOSCoordSeq_getSize(cs_, &size));
+    ensure_equals(size, 1u);
 
-        ensure ( 0 != GEOSCoordSeq_getDimensions(cs_, &dims) );
-        ensure_equals( dims, 3u );
+    ensure(0 != GEOSCoordSeq_getDimensions(cs_, &dims));
+    ensure_equals(dims, 3u);
 
-        double x = 10;
-        double y = 11;
-        double z = 12;
+    double x = 10;
+    double y = 11;
+    double z = 12;
 
-        // X, Y, Z
-        GEOSCoordSeq_setOrdinate(cs_, 0, 0, x);
-        GEOSCoordSeq_setOrdinate(cs_, 0, 1, y);
-        GEOSCoordSeq_setOrdinate(cs_, 0, 2, z);
+    // X, Y, Z
+    GEOSCoordSeq_setOrdinate(cs_, 0, 0, x);
+    GEOSCoordSeq_setOrdinate(cs_, 0, 1, y);
+    GEOSCoordSeq_setOrdinate(cs_, 0, 2, z);
 
-        double xcheck, ycheck, zcheck;
-        ensure( 0 != GEOSCoordSeq_getOrdinate(cs_, 0, 1, &ycheck) );
-        ensure( 0 != GEOSCoordSeq_getOrdinate(cs_, 0, 0, &xcheck) );
-        ensure( 0 != GEOSCoordSeq_getOrdinate(cs_, 0, 2, &zcheck) );
+    double xcheck, ycheck, zcheck;
+    ensure(0 != GEOSCoordSeq_getOrdinate(cs_, 0, 1, &ycheck));
+    ensure(0 != GEOSCoordSeq_getOrdinate(cs_, 0, 0, &xcheck));
+    ensure(0 != GEOSCoordSeq_getOrdinate(cs_, 0, 2, &zcheck));
 
-        ensure_equals( xcheck, x );
-        ensure_equals( ycheck, y );
-        ensure_equals( zcheck, z );
-    }
+    ensure_equals(xcheck, x);
+    ensure_equals(ycheck, y);
+    ensure_equals(zcheck, z);
+}
 
-    // Test swapped setX calls (see bug #133, fixed)
-    template<>
-    template<>
-    void object::test<4>()
-    {
-        cs_ = GEOSCoordSeq_create(1, 3);
+// Test swapped setX calls (see bug #133, fixed)
+template<>
+template<>
+void object::test<4>
+()
+{
+    cs_ = GEOSCoordSeq_create(1, 3);
 
-        unsigned int size;
-        unsigned int dims;
+    unsigned int size;
+    unsigned int dims;
 
-        ensure ( 0 != GEOSCoordSeq_getSize(cs_, &size) );
-        ensure_equals( size, 1u );
+    ensure(0 != GEOSCoordSeq_getSize(cs_, &size));
+    ensure_equals(size, 1u);
 
-        ensure ( 0 != GEOSCoordSeq_getDimensions(cs_, &dims) );
-        ensure_equals( dims, 3u );
+    ensure(0 != GEOSCoordSeq_getDimensions(cs_, &dims));
+    ensure_equals(dims, 3u);
 
-        double x = 10;
-        double y = 11;
-        double z = 12;
+    double x = 10;
+    double y = 11;
+    double z = 12;
 
-        // Y, X, Z
-        GEOSCoordSeq_setY(cs_, 0, y);
-        GEOSCoordSeq_setX(cs_, 0, x);
-        GEOSCoordSeq_setZ(cs_, 0, z);
+    // Y, X, Z
+    GEOSCoordSeq_setY(cs_, 0, y);
+    GEOSCoordSeq_setX(cs_, 0, x);
+    GEOSCoordSeq_setZ(cs_, 0, z);
 
-        double xcheck, ycheck, zcheck;
-        ensure( 0 != GEOSCoordSeq_getY(cs_, 0, &ycheck) );
-        ensure( 0 != GEOSCoordSeq_getX(cs_, 0, &xcheck) );
-        ensure( 0 != GEOSCoordSeq_getZ(cs_, 0, &zcheck) );
+    double xcheck, ycheck, zcheck;
+    ensure(0 != GEOSCoordSeq_getY(cs_, 0, &ycheck));
+    ensure(0 != GEOSCoordSeq_getX(cs_, 0, &xcheck));
+    ensure(0 != GEOSCoordSeq_getZ(cs_, 0, &zcheck));
 
-        ensure_equals( xcheck, x );
-        ensure_equals( ycheck, y );
-        ensure_equals( zcheck, z );
-    }
+    ensure_equals(xcheck, x);
+    ensure_equals(ycheck, y);
+    ensure_equals(zcheck, z);
+}
 
-    // Test swapped setOrdinate calls (see bug #133, fixed)
-    template<>
-    template<>
-    void object::test<5>()
-    {
-        cs_ = GEOSCoordSeq_create(1, 3);
+// Test swapped setOrdinate calls (see bug #133, fixed)
+template<>
+template<>
+void object::test<5>
+()
+{
+    cs_ = GEOSCoordSeq_create(1, 3);
 
-        unsigned int size;
-        unsigned int dims;
+    unsigned int size;
+    unsigned int dims;
 
-        ensure ( 0 != GEOSCoordSeq_getSize(cs_, &size) );
-        ensure_equals( size, 1u );
+    ensure(0 != GEOSCoordSeq_getSize(cs_, &size));
+    ensure_equals(size, 1u);
 
-        ensure ( 0 != GEOSCoordSeq_getDimensions(cs_, &dims) );
-        ensure_equals( dims, 3u );
+    ensure(0 != GEOSCoordSeq_getDimensions(cs_, &dims));
+    ensure_equals(dims, 3u);
 
-        double x = 10;
-        double y = 11;
-        double z = 12;
+    double x = 10;
+    double y = 11;
+    double z = 12;
 
-        // Y, X, Z
-        GEOSCoordSeq_setOrdinate(cs_, 0, 1, y);
-        GEOSCoordSeq_setOrdinate(cs_, 0, 0, x);
-        GEOSCoordSeq_setOrdinate(cs_, 0, 2, z);
+    // Y, X, Z
+    GEOSCoordSeq_setOrdinate(cs_, 0, 1, y);
+    GEOSCoordSeq_setOrdinate(cs_, 0, 0, x);
+    GEOSCoordSeq_setOrdinate(cs_, 0, 2, z);
 
-        double xcheck, ycheck, zcheck;
-        ensure( 0 != GEOSCoordSeq_getOrdinate(cs_, 0, 1, &ycheck) );
-        ensure( 0 != GEOSCoordSeq_getOrdinate(cs_, 0, 0, &xcheck) );
-        ensure( 0 != GEOSCoordSeq_getOrdinate(cs_, 0, 2, &zcheck) );
+    double xcheck, ycheck, zcheck;
+    ensure(0 != GEOSCoordSeq_getOrdinate(cs_, 0, 1, &ycheck));
+    ensure(0 != GEOSCoordSeq_getOrdinate(cs_, 0, 0, &xcheck));
+    ensure(0 != GEOSCoordSeq_getOrdinate(cs_, 0, 2, &zcheck));
 
-        ensure_equals( xcheck, x );
-        ensure_equals( ycheck, y );
-        ensure_equals( zcheck, z );
-    }
+    ensure_equals(xcheck, x);
+    ensure_equals(ycheck, y);
+    ensure_equals(zcheck, z);
+}
 
-    // Test getDimensions call (see bug #135)
-    template<>
-    template<>
-    void object::test<6>()
-    {
-        cs_ = GEOSCoordSeq_create(1, 2);
+// Test getDimensions call (see bug #135)
+template<>
+template<>
+void object::test<6>
+()
+{
+    cs_ = GEOSCoordSeq_create(1, 2);
 
-        unsigned int size;
-        unsigned int dims;
+    unsigned int size;
+    unsigned int dims;
 
-        ensure ( 0 != GEOSCoordSeq_getSize(cs_, &size) );
-        ensure_equals( size, 1u );
+    ensure(0 != GEOSCoordSeq_getSize(cs_, &size));
+    ensure_equals(size, 1u);
 
-        ensure ( 0 != GEOSCoordSeq_getDimensions(cs_, &dims) );
+    ensure(0 != GEOSCoordSeq_getDimensions(cs_, &dims));
 
-	// The dimension passed to GEOSCoordSeq_create()
-	// is a request for a minimum, not a strict mandate
-	// for changing actual size.
-	//
-        ensure ( dims >= 2u );
+    // The dimension passed to GEOSCoordSeq_create()
+    // is a request for a minimum, not a strict mandate
+    // for changing actual size.
+    //
+    ensure(dims >= 2u);
 
-    }
+}
 
-    template<>
-    template<>
-    void object::test<7>() {
-        // ccw orientation
-        cs_ = GEOSCoordSeq_create(4, 2);
-        char ccw;
+template<>
+template<>
+void object::test<7>
+()
+{
+    // ccw orientation
+    cs_ = GEOSCoordSeq_create(4, 2);
+    char ccw;
 
-        GEOSCoordSeq_setX(cs_, 0, 0);
-        GEOSCoordSeq_setY(cs_, 0, 0);
+    GEOSCoordSeq_setX(cs_, 0, 0);
+    GEOSCoordSeq_setY(cs_, 0, 0);
 
-        GEOSCoordSeq_setX(cs_, 1, 1);
-        GEOSCoordSeq_setY(cs_, 1, 0);
+    GEOSCoordSeq_setX(cs_, 1, 1);
+    GEOSCoordSeq_setY(cs_, 1, 0);
 
-        GEOSCoordSeq_setX(cs_, 2, 1);
-        GEOSCoordSeq_setY(cs_, 2, 1);
+    GEOSCoordSeq_setX(cs_, 2, 1);
+    GEOSCoordSeq_setY(cs_, 2, 1);
 
-        GEOSCoordSeq_setX(cs_, 3, 0);
-        GEOSCoordSeq_setY(cs_, 3, 0);
+    GEOSCoordSeq_setX(cs_, 3, 0);
+    GEOSCoordSeq_setY(cs_, 3, 0);
 
-        ensure_equals(GEOSCoordSeq_isCCW(cs_, &ccw), 1);
-        ensure(ccw);
-    }
+    ensure_equals(GEOSCoordSeq_isCCW(cs_, &ccw), 1);
+    ensure(ccw);
+}
 
-    template<>
-    template<>
-    void object::test<8>() {
-        // cw orientation
-        cs_ = GEOSCoordSeq_create(4, 2);
-        char ccw;
+template<>
+template<>
+void object::test<8>
+()
+{
+    // cw orientation
+    cs_ = GEOSCoordSeq_create(4, 2);
+    char ccw;
 
-        GEOSCoordSeq_setX(cs_, 0, 0);
-        GEOSCoordSeq_setY(cs_, 0, 0);
+    GEOSCoordSeq_setX(cs_, 0, 0);
+    GEOSCoordSeq_setY(cs_, 0, 0);
 
-        GEOSCoordSeq_setX(cs_, 1, 1);
-        GEOSCoordSeq_setY(cs_, 1, 1);
+    GEOSCoordSeq_setX(cs_, 1, 1);
+    GEOSCoordSeq_setY(cs_, 1, 1);
 
-        GEOSCoordSeq_setX(cs_, 2, 1);
-        GEOSCoordSeq_setY(cs_, 2, 0);
+    GEOSCoordSeq_setX(cs_, 2, 1);
+    GEOSCoordSeq_setY(cs_, 2, 0);
 
-        GEOSCoordSeq_setX(cs_, 3, 0);
-        GEOSCoordSeq_setY(cs_, 3, 0);
+    GEOSCoordSeq_setX(cs_, 3, 0);
+    GEOSCoordSeq_setY(cs_, 3, 0);
 
-        ensure_equals(GEOSCoordSeq_isCCW(cs_, &ccw), 1);
-        ensure(!ccw );
-    }
+    ensure_equals(GEOSCoordSeq_isCCW(cs_, &ccw), 1);
+    ensure(!ccw);
+}
 
-    template<>
-    template<>
-    void object::test<9>() {
-        // no orientation
-        cs_ = GEOSCoordSeq_create(3, 2);
-        char ccw;
+template<>
+template<>
+void object::test<9>
+()
+{
+    // no orientation
+    cs_ = GEOSCoordSeq_create(3, 2);
+    char ccw;
 
-        GEOSCoordSeq_setX(cs_, 0, 0);
-        GEOSCoordSeq_setY(cs_, 0, 0);
+    GEOSCoordSeq_setX(cs_, 0, 0);
+    GEOSCoordSeq_setY(cs_, 0, 0);
 
-        GEOSCoordSeq_setX(cs_, 1, 1);
-        GEOSCoordSeq_setY(cs_, 1, 1);
+    GEOSCoordSeq_setX(cs_, 1, 1);
+    GEOSCoordSeq_setY(cs_, 1, 1);
 
-        GEOSCoordSeq_setX(cs_, 2, 1);
-        GEOSCoordSeq_setY(cs_, 2, 0);
+    GEOSCoordSeq_setX(cs_, 2, 1);
+    GEOSCoordSeq_setY(cs_, 2, 0);
 
-        ensure_equals(GEOSCoordSeq_isCCW(cs_, &ccw), 0);
-    }
+    ensure_equals(GEOSCoordSeq_isCCW(cs_, &ccw), 0);
+}
 
-    template<>
-    template<>
-    void object::test<10>() {
-        // no orientation
-        cs_ = GEOSCoordSeq_create(0, 0);
-        char ccw;
+template<>
+template<>
+void object::test<10>
+()
+{
+    // no orientation
+    cs_ = GEOSCoordSeq_create(0, 0);
+    char ccw;
 
-        ensure_equals(GEOSCoordSeq_isCCW(cs_, &ccw), 0);
-    }
+    ensure_equals(GEOSCoordSeq_isCCW(cs_, &ccw), 0);
+}
 
 } // namespace tut
 
diff --git a/tests/unit/capi/GEOSDelaunayTriangulationTest.cpp b/tests/unit/capi/GEOSDelaunayTriangulationTest.cpp
index d9ea416..50c931e 100644
--- a/tests/unit/capi/GEOSDelaunayTriangulationTest.cpp
+++ b/tests/unit/capi/GEOSDelaunayTriangulationTest.cpp
@@ -10,179 +10,185 @@
 #include <cstdlib>
 #include <memory>
 
-namespace tut
-{
-    //
-    // Test Group
-    //
-
-    // Common data used in test cases.
-    struct test_capigeosdelaunaytriangulation_data
-    {
-        GEOSGeometry* geom1_;
-        GEOSGeometry* geom2_;
-        GEOSWKTWriter* w_;
-
-        static void notice(const char *fmt, ...)
-        {
-            std::fprintf( stdout, "NOTICE: ");
-
-            va_list ap;
-            va_start(ap, fmt);
-            std::vfprintf(stdout, fmt, ap);
-            va_end(ap);
-
-            std::fprintf(stdout, "\n");
-        }
-
-        test_capigeosdelaunaytriangulation_data()
-            : geom1_(nullptr), geom2_(nullptr)
-        {
-            initGEOS(notice, notice);
-            w_ = GEOSWKTWriter_create();
-            GEOSWKTWriter_setTrim(w_, 1);
-        }
-
-        void ensure_equals_wkt(GEOSGeometry* g, const std::string& exp)
-        {
-          GEOSNormalize(g);
-          char* wkt_c = GEOSWKTWriter_write(w_, g);
-          std::string out(wkt_c);
-          free(wkt_c);
-          ensure_equals(out, exp);
-        }
-
-        ~test_capigeosdelaunaytriangulation_data()
-        {
-            GEOSGeom_destroy(geom1_);
-            GEOSGeom_destroy(geom2_);
-            GEOSWKTWriter_destroy(w_);
-            geom1_ = nullptr;
-            geom2_ = nullptr;
-            finishGEOS();
-        }
-
-    };
-
-    typedef test_group<test_capigeosdelaunaytriangulation_data> group;
-    typedef group::object object;
-
-    group test_capigeosdelaunaytriangulation_group("capi::GEOSDelaunayTriangulation");
-
-    //
-    // Test Cases
-    //
-
-    // Empty polygon
-    template<>
-    template<>
-    void object::test<1>()
-    {
-        geom1_ = GEOSGeomFromWKT("POLYGON EMPTY");
-
-        ensure_equals ( GEOSisEmpty(geom1_), 1 );
+namespace tut {
+//
+// Test Group
+//
 
-        geom2_ = GEOSDelaunayTriangulation(geom1_, 0, 0);
-        ensure_equals ( GEOSisEmpty(geom2_), 1 );
-        ensure_equals ( GEOSGeomTypeId(geom2_), GEOS_GEOMETRYCOLLECTION );
+// Common data used in test cases.
+struct test_capigeosdelaunaytriangulation_data {
+    GEOSGeometry* geom1_;
+    GEOSGeometry* geom2_;
+    GEOSWKTWriter* w_;
 
-        GEOSGeom_destroy(geom2_);
-        geom2_ = GEOSDelaunayTriangulation(geom1_, 0, 1);
-        ensure_equals ( GEOSisEmpty(geom2_), 1 );
-        ensure_equals ( GEOSGeomTypeId(geom2_), GEOS_MULTILINESTRING );
+    static void
+    notice(const char* fmt, ...)
+    {
+        std::fprintf(stdout, "NOTICE: ");
 
+        va_list ap;
+        va_start(ap, fmt);
+        std::vfprintf(stdout, fmt, ap);
+        va_end(ap);
 
+        std::fprintf(stdout, "\n");
     }
 
-    // Single point
-    template<>
-    template<>
-    void object::test<2>()
+    test_capigeosdelaunaytriangulation_data()
+        : geom1_(nullptr), geom2_(nullptr)
     {
-        geom1_ = GEOSGeomFromWKT("POINT(0 0)");
-
-        geom2_ = GEOSDelaunayTriangulation(geom1_, 0, 0);
-        ensure_equals ( GEOSisEmpty(geom2_), 1 );
-        ensure_equals ( GEOSGeomTypeId(geom2_), GEOS_GEOMETRYCOLLECTION );
-
-        GEOSGeom_destroy(geom2_);
-        geom2_ = GEOSDelaunayTriangulation(geom1_, 0, 1);
-        ensure_equals ( GEOSisEmpty(geom2_), 1 );
-        ensure_equals ( GEOSGeomTypeId(geom2_), GEOS_MULTILINESTRING );
+        initGEOS(notice, notice);
+        w_ = GEOSWKTWriter_create();
+        GEOSWKTWriter_setTrim(w_, 1);
     }
 
-    // Three collinear points
-    template<>
-    template<>
-    void object::test<3>()
+    void
+    ensure_equals_wkt(GEOSGeometry* g, const std::string& exp)
     {
-        geom1_ = GEOSGeomFromWKT("MULTIPOINT(0 0, 5 0, 10 0)");
-
-        geom2_ = GEOSDelaunayTriangulation(geom1_, 0, 0);
-        ensure_equals ( GEOSisEmpty(geom2_), 1 );
-        ensure_equals ( GEOSGeomTypeId(geom2_), GEOS_GEOMETRYCOLLECTION );
-
-        GEOSGeom_destroy(geom2_);
-        geom2_ = GEOSDelaunayTriangulation(geom1_, 0, 1);
-        char* wkt_c = GEOSWKTWriter_write(w_, geom2_);
+        GEOSNormalize(g);
+        char* wkt_c = GEOSWKTWriter_write(w_, g);
         std::string out(wkt_c);
         free(wkt_c);
-        ensure_equals(out, "MULTILINESTRING ((5 0, 10 0), (0 0, 5 0))");
+        ensure_equals(out, exp);
     }
 
-    // Three points
-    template<>
-    template<>
-    void object::test<4>()
+    ~test_capigeosdelaunaytriangulation_data()
     {
-        geom1_ = GEOSGeomFromWKT("MULTIPOINT(0 0, 5 0, 10 10)");
-
-        geom2_ = GEOSDelaunayTriangulation(geom1_, 0, 0);
-        ensure(geom2_ != nullptr);
-        ensure_equals_wkt(geom2_,
-          "GEOMETRYCOLLECTION (POLYGON ((0 0, 10 10, 5 0, 0 0)))"
-        );
-
+        GEOSGeom_destroy(geom1_);
         GEOSGeom_destroy(geom2_);
-        geom2_ = GEOSDelaunayTriangulation(geom1_, 0, 1);
-        ensure_equals_wkt(geom2_,
-          "MULTILINESTRING ((5 0, 10 10), (0 0, 10 10), (0 0, 5 0))"
-        );
+        GEOSWKTWriter_destroy(w_);
+        geom1_ = nullptr;
+        geom2_ = nullptr;
+        finishGEOS();
     }
 
-    // A polygon with an hole
-    template<>
-    template<>
-    void object::test<5>()
-    {
-        geom1_ = GEOSGeomFromWKT("POLYGON((0 0, 8.5 1, 10 10, 0.5 9, 0 0),(2 2, 3 8, 7 8, 8 2, 2 2)))");
+};
 
-        geom2_ = GEOSDelaunayTriangulation(geom1_, 0, 0);
-        ensure(geom2_ != nullptr);
-        ensure_equals_wkt(geom2_,
-"GEOMETRYCOLLECTION (POLYGON ((8 2, 10 10, 8.5 1, 8 2)), POLYGON ((7 8, 10 10, 8 2, 7 8)), POLYGON ((3 8, 10 10, 7 8, 3 8)), POLYGON ((2 2, 8 2, 8.5 1, 2 2)), POLYGON ((2 2, 7 8, 8 2, 2 2)), POLYGON ((2 2, 3 8, 7 8, 2 2)), POLYGON ((0.5 9, 10 10, 3 8, 0.5 9)), POLYGON ((0.5 9, 3 8, 2 2, 0.5 9)), POLYGON ((0 0, 2 2, 8.5 1, 0 0)), POLYGON ((0 0, 0.5 9, 2 2, 0 0)))"
-        );
+typedef test_group<test_capigeosdelaunaytriangulation_data> group;
+typedef group::object object;
 
-        GEOSGeom_destroy(geom2_);
-        geom2_ = GEOSDelaunayTriangulation(geom1_, 0, 1);
-        ensure_equals_wkt(geom2_,
-"MULTILINESTRING ((8.5 1, 10 10), (8 2, 10 10), (8 2, 8.5 1), (7 8, 10 10), (7 8, 8 2), (3 8, 10 10), (3 8, 7 8), (2 2, 8.5 1), (2 2, 8 2), (2 2, 7 8), (2 2, 3 8), (0.5 9, 10 10), (0.5 9, 3 8), (0.5 9, 2 2), (0 0, 8.5 1), (0 0, 2 2), (0 0, 0.5 9))"
-        );
-    }
+group test_capigeosdelaunaytriangulation_group("capi::GEOSDelaunayTriangulation");
 
-    // Four points with a tolerance making one collapse
-    template<>
-    template<>
-    void object::test<6>()
-    {
-        geom1_ = GEOSGeomFromWKT("MULTIPOINT(0 0, 10 0, 10 10, 11 10)");
+//
+// Test Cases
+//
 
-        GEOSGeom_destroy(geom2_);
-        geom2_ = GEOSDelaunayTriangulation(geom1_, 2, 1);
-        ensure_equals_wkt(geom2_,
-"MULTILINESTRING ((10 0, 10 10), (0 0, 10 10), (0 0, 10 0))"
-        );
-    }
+// Empty polygon
+template<>
+template<>
+void object::test<1>
+()
+{
+    geom1_ = GEOSGeomFromWKT("POLYGON EMPTY");
+
+    ensure_equals(GEOSisEmpty(geom1_), 1);
+
+    geom2_ = GEOSDelaunayTriangulation(geom1_, 0, 0);
+    ensure_equals(GEOSisEmpty(geom2_), 1);
+    ensure_equals(GEOSGeomTypeId(geom2_), GEOS_GEOMETRYCOLLECTION);
+
+    GEOSGeom_destroy(geom2_);
+    geom2_ = GEOSDelaunayTriangulation(geom1_, 0, 1);
+    ensure_equals(GEOSisEmpty(geom2_), 1);
+    ensure_equals(GEOSGeomTypeId(geom2_), GEOS_MULTILINESTRING);
+
+
+}
+
+// Single point
+template<>
+template<>
+void object::test<2>
+()
+{
+    geom1_ = GEOSGeomFromWKT("POINT(0 0)");
+
+    geom2_ = GEOSDelaunayTriangulation(geom1_, 0, 0);
+    ensure_equals(GEOSisEmpty(geom2_), 1);
+    ensure_equals(GEOSGeomTypeId(geom2_), GEOS_GEOMETRYCOLLECTION);
+
+    GEOSGeom_destroy(geom2_);
+    geom2_ = GEOSDelaunayTriangulation(geom1_, 0, 1);
+    ensure_equals(GEOSisEmpty(geom2_), 1);
+    ensure_equals(GEOSGeomTypeId(geom2_), GEOS_MULTILINESTRING);
+}
+
+// Three collinear points
+template<>
+template<>
+void object::test<3>
+()
+{
+    geom1_ = GEOSGeomFromWKT("MULTIPOINT(0 0, 5 0, 10 0)");
+
+    geom2_ = GEOSDelaunayTriangulation(geom1_, 0, 0);
+    ensure_equals(GEOSisEmpty(geom2_), 1);
+    ensure_equals(GEOSGeomTypeId(geom2_), GEOS_GEOMETRYCOLLECTION);
+
+    GEOSGeom_destroy(geom2_);
+    geom2_ = GEOSDelaunayTriangulation(geom1_, 0, 1);
+    char* wkt_c = GEOSWKTWriter_write(w_, geom2_);
+    std::string out(wkt_c);
+    free(wkt_c);
+    ensure_equals(out, "MULTILINESTRING ((5 0, 10 0), (0 0, 5 0))");
+}
+
+// Three points
+template<>
+template<>
+void object::test<4>
+()
+{
+    geom1_ = GEOSGeomFromWKT("MULTIPOINT(0 0, 5 0, 10 10)");
+
+    geom2_ = GEOSDelaunayTriangulation(geom1_, 0, 0);
+    ensure(geom2_ != nullptr);
+    ensure_equals_wkt(geom2_,
+                      "GEOMETRYCOLLECTION (POLYGON ((0 0, 10 10, 5 0, 0 0)))"
+                     );
+
+    GEOSGeom_destroy(geom2_);
+    geom2_ = GEOSDelaunayTriangulation(geom1_, 0, 1);
+    ensure_equals_wkt(geom2_,
+                      "MULTILINESTRING ((5 0, 10 10), (0 0, 10 10), (0 0, 5 0))"
+                     );
+}
+
+// A polygon with an hole
+template<>
+template<>
+void object::test<5>
+()
+{
+    geom1_ = GEOSGeomFromWKT("POLYGON((0 0, 8.5 1, 10 10, 0.5 9, 0 0),(2 2, 3 8, 7 8, 8 2, 2 2)))");
+
+    geom2_ = GEOSDelaunayTriangulation(geom1_, 0, 0);
+    ensure(geom2_ != nullptr);
+    ensure_equals_wkt(geom2_,
+                      "GEOMETRYCOLLECTION (POLYGON ((8 2, 10 10, 8.5 1, 8 2)), POLYGON ((7 8, 10 10, 8 2, 7 8)), POLYGON ((3 8, 10 10, 7 8, 3 8)), POLYGON ((2 2, 8 2, 8.5 1, 2 2)), POLYGON ((2 2, 7 8, 8 2, 2 2)), POLYGON ((2 2, 3 8, 7 8, 2 2)), POLYGON ((0.5 9, 10 10, 3 8, 0.5 9)), POLYGON ((0.5 9, 3 8, 2 2, 0.5 9)), POLYGON ((0 0, 2 2, 8.5 1, 0 0)), POLYGON ((0 0, 0.5 9, 2 2, 0 0)))"
+                     );
+
+    GEOSGeom_destroy(geom2_);
+    geom2_ = GEOSDelaunayTriangulation(geom1_, 0, 1);
+    ensure_equals_wkt(geom2_,
+                      "MULTILINESTRING ((8.5 1, 10 10), (8 2, 10 10), (8 2, 8.5 1), (7 8, 10 10), (7 8, 8 2), (3 8, 10 10), (3 8, 7 8), (2 2, 8.5 1), (2 2, 8 2), (2 2, 7 8), (2 2, 3 8), (0.5 9, 10 10), (0.5 9, 3 8), (0.5 9, 2 2), (0 0, 8.5 1), (0 0, 2 2), (0 0, 0.5 9))"
+                     );
+}
+
+// Four points with a tolerance making one collapse
+template<>
+template<>
+void object::test<6>
+()
+{
+    geom1_ = GEOSGeomFromWKT("MULTIPOINT(0 0, 10 0, 10 10, 11 10)");
+
+    GEOSGeom_destroy(geom2_);
+    geom2_ = GEOSDelaunayTriangulation(geom1_, 2, 1);
+    ensure_equals_wkt(geom2_,
+                      "MULTILINESTRING ((10 0, 10 10), (0 0, 10 10), (0 0, 10 0))"
+                     );
+}
 
 } // namespace tut
 
diff --git a/tests/unit/capi/GEOSDistanceTest.cpp b/tests/unit/capi/GEOSDistanceTest.cpp
index 1a2dae4..ea6dc74 100644
--- a/tests/unit/capi/GEOSDistanceTest.cpp
+++ b/tests/unit/capi/GEOSDistanceTest.cpp
@@ -12,125 +12,126 @@
 #include <memory>
 #include <math.h>
 
-namespace tut
-{
-    //
-    // Test Group
-    //
+namespace tut {
+//
+// Test Group
+//
 
-    // Common data used in test cases.
-    struct test_capigeosdistance_data
-    {
-        GEOSGeometry* geom1_;
-        GEOSGeometry* geom2_;
-        GEOSGeometry* geom3_;
-        GEOSWKTWriter* w_;
-
-        static void notice(const char *fmt, ...)
-        {
-            std::fprintf( stdout, "NOTICE: ");
-
-            va_list ap;
-            va_start(ap, fmt);
-            std::vfprintf(stdout, fmt, ap);
-            va_end(ap);
-
-            std::fprintf(stdout, "\n");
-        }
-
-        test_capigeosdistance_data()
-            : geom1_(nullptr), geom2_(nullptr), geom3_(nullptr), w_(nullptr)
-        {
-            initGEOS(notice, notice);
-            w_ = GEOSWKTWriter_create();
-            GEOSWKTWriter_setTrim(w_, 1);
-        }
-
-        ~test_capigeosdistance_data()
-        {
-            GEOSGeom_destroy(geom1_);
-            GEOSGeom_destroy(geom2_);
-            GEOSGeom_destroy(geom3_);
-            GEOSWKTWriter_destroy(w_);
-            geom1_ = nullptr;
-            geom2_ = nullptr;
-            geom3_ = nullptr;
-            finishGEOS();
-        }
-
-    };
-
-    typedef test_group<test_capigeosdistance_data> group;
-    typedef group::object object;
-
-    group test_capigeosdistance_group("capi::GEOSDistance");
-
-    //
-    // Test Cases
-    //
-
-    /// See http://trac.osgeo.org/geos/ticket/377
-    template<>
-    template<>
-    void object::test<1>()
+// Common data used in test cases.
+struct test_capigeosdistance_data {
+    GEOSGeometry* geom1_;
+    GEOSGeometry* geom2_;
+    GEOSGeometry* geom3_;
+    GEOSWKTWriter* w_;
+
+    static void
+    notice(const char* fmt, ...)
     {
-        geom1_ = GEOSGeomFromWKT("POINT(10 10)");
-        geom2_ = GEOSGeomFromWKT("POINT(3 6)");
+        std::fprintf(stdout, "NOTICE: ");
 
-        double dist;
-        int ret = GEOSDistance(geom1_, geom2_, &dist);
+        va_list ap;
+        va_start(ap, fmt);
+        std::vfprintf(stdout, fmt, ap);
+        va_end(ap);
 
-        ensure_equals(ret, 1);
-        ensure_distance(dist, 8.06225774829855, 1e-12);
+        std::fprintf(stdout, "\n");
     }
 
-    GEOSGeometry* random_polygon(double x, double y, double r, size_t num_points)
+    test_capigeosdistance_data()
+        : geom1_(nullptr), geom2_(nullptr), geom3_(nullptr), w_(nullptr)
     {
-        std::vector<double> angle(num_points);
-        std::vector<double> radius(num_points);
+        initGEOS(notice, notice);
+        w_ = GEOSWKTWriter_create();
+        GEOSWKTWriter_setTrim(w_, 1);
+    }
 
+    ~test_capigeosdistance_data()
+    {
+        GEOSGeom_destroy(geom1_);
+        GEOSGeom_destroy(geom2_);
+        GEOSGeom_destroy(geom3_);
+        GEOSWKTWriter_destroy(w_);
+        geom1_ = nullptr;
+        geom2_ = nullptr;
+        geom3_ = nullptr;
+        finishGEOS();
+    }
 
-        for (size_t i = 0; i < num_points; i++) {
-            angle[i] = 2 * geos::M_PI * std::rand() / RAND_MAX;
-            radius[i] = r*std::rand() / RAND_MAX;
-        }
+};
 
-        std::sort(angle.begin(), angle.end());
+typedef test_group<test_capigeosdistance_data> group;
+typedef group::object object;
 
-        GEOSCoordSequence* seq_1 = GEOSCoordSeq_create(static_cast<unsigned int>(num_points), 2);
-        for (unsigned int i = 0; i < num_points; i++)
-        {
-            auto idx = i == (num_points - 1) ? 0 : i;
+group test_capigeosdistance_group("capi::GEOSDistance");
 
-            GEOSCoordSeq_setX(seq_1, i, x + radius[idx] * cos(angle[idx]));
-            GEOSCoordSeq_setY(seq_1, i, y + radius[idx] * sin(angle[idx]));
-        }
+//
+// Test Cases
+//
 
-        return GEOSGeom_createPolygon(GEOSGeom_createLinearRing(seq_1), nullptr, 0);
-    }
+/// See http://trac.osgeo.org/geos/ticket/377
+template<>
+template<>
+void object::test<1>
+()
+{
+    geom1_ = GEOSGeomFromWKT("POINT(10 10)");
+    geom2_ = GEOSGeomFromWKT("POINT(3 6)");
 
-    /* Generate two complex polygons and verify that GEOSDistance and GEOSDistanceIndexed
-     * return identical results.
-     */
-    template<>
-    template<>
-    void object::test<2>()
-    {
-        std::srand(12345);
+    double dist;
+    int ret = GEOSDistance(geom1_, geom2_, &dist);
 
-        GEOSGeometry* g1 = random_polygon(-3, -8, 7, 1000);
-        GEOSGeometry* g2 = random_polygon(14, 22, 6, 500);
+    ensure_equals(ret, 1);
+    ensure_distance(dist, 8.06225774829855, 1e-12);
+}
 
-        double d_raw, d_indexed;
-        ensure(GEOSDistance(g1, g2, &d_raw));
-        ensure(GEOSDistanceIndexed(g1, g2, &d_indexed));
+GEOSGeometry*
+random_polygon(double x, double y, double r, size_t num_points)
+{
+    std::vector<double> angle(num_points);
+    std::vector<double> radius(num_points);
+
+
+    for(size_t i = 0; i < num_points; i++) {
+        angle[i] = 2 * geos::M_PI * std::rand() / RAND_MAX;
+        radius[i] = r * std::rand() / RAND_MAX;
+    }
+
+    std::sort(angle.begin(), angle.end());
 
-        ensure_equals(d_indexed, d_raw);
+    GEOSCoordSequence* seq_1 = GEOSCoordSeq_create(static_cast<unsigned int>(num_points), 2);
+    for(unsigned int i = 0; i < num_points; i++) {
+        auto idx = i == (num_points - 1) ? 0 : i;
 
-        GEOSGeom_destroy(g1);
-        GEOSGeom_destroy(g2);
+        GEOSCoordSeq_setX(seq_1, i, x + radius[idx] * cos(angle[idx]));
+        GEOSCoordSeq_setY(seq_1, i, y + radius[idx] * sin(angle[idx]));
     }
 
+    return GEOSGeom_createPolygon(GEOSGeom_createLinearRing(seq_1), nullptr, 0);
+}
+
+/* Generate two complex polygons and verify that GEOSDistance and GEOSDistanceIndexed
+ * return identical results.
+ */
+template<>
+template<>
+void object::test<2>
+()
+{
+    std::srand(12345);
+
+    GEOSGeometry* g1 = random_polygon(-3, -8, 7, 1000);
+    GEOSGeometry* g2 = random_polygon(14, 22, 6, 500);
+
+    double d_raw, d_indexed;
+    ensure(GEOSDistance(g1, g2, &d_raw));
+    ensure(GEOSDistanceIndexed(g1, g2, &d_indexed));
+
+    ensure_equals(d_indexed, d_raw);
+
+    GEOSGeom_destroy(g1);
+    GEOSGeom_destroy(g2);
+}
+
 
 } // namespace tut
 
diff --git a/tests/unit/capi/GEOSEqualsTest.cpp b/tests/unit/capi/GEOSEqualsTest.cpp
index d10a3d3..b056240 100644
--- a/tests/unit/capi/GEOSEqualsTest.cpp
+++ b/tests/unit/capi/GEOSEqualsTest.cpp
@@ -10,175 +10,183 @@
 #include <cstdlib>
 #include <cstring>
 
-namespace tut
-{
-    //
-    // Test Group
-    //
+namespace tut {
+//
+// Test Group
+//
 
-    // Common data used in test cases.
-    struct test_capigeosequals_data
+// Common data used in test cases.
+struct test_capigeosequals_data {
+    GEOSGeometry* geom1_;
+    GEOSGeometry* geom2_;
+
+    static void
+    notice(const char* fmt, ...)
     {
-        GEOSGeometry* geom1_;
-        GEOSGeometry* geom2_;
-
-        static void notice(const char *fmt, ...)
-        {
-            std::fprintf( stdout, "NOTICE: ");
-
-            va_list ap;
-            va_start(ap, fmt);
-            std::vfprintf(stdout, fmt, ap);
-            va_end(ap);
-
-            std::fprintf(stdout, "\n");
-        }
-
-        test_capigeosequals_data()
-            : geom1_(nullptr), geom2_(nullptr)
-        {
-            initGEOS(notice, notice);
-        }
-
-        ~test_capigeosequals_data()
-        {
-            GEOSGeom_destroy(geom1_);
-            GEOSGeom_destroy(geom2_);
-            geom1_ = nullptr;
-            geom2_ = nullptr;
-            finishGEOS();
-        }
-
-    };
-
-    typedef test_group<test_capigeosequals_data> group;
-    typedef group::object object;
-
-    group test_capigeosequals_group("capi::GEOSEquals");
-
-    //
-    // Test Cases
-    //
-
-    template<>
-    template<>
-    void object::test<1>()
+        std::fprintf(stdout, "NOTICE: ");
+
+        va_list ap;
+        va_start(ap, fmt);
+        std::vfprintf(stdout, fmt, ap);
+        va_end(ap);
+
+        std::fprintf(stdout, "\n");
+    }
+
+    test_capigeosequals_data()
+        : geom1_(nullptr), geom2_(nullptr)
     {
-        geom1_ = GEOSGeomFromWKT("POLYGON EMPTY");
-        geom2_ = GEOSGeomFromWKT("POLYGON EMPTY");
+        initGEOS(notice, notice);
+    }
 
-        ensure( nullptr != geom1_ );
-        ensure( nullptr != geom2_ );
+    ~test_capigeosequals_data()
+    {
+        GEOSGeom_destroy(geom1_);
+        GEOSGeom_destroy(geom2_);
+        geom1_ = nullptr;
+        geom2_ = nullptr;
+        finishGEOS();
+    }
 
-        char const r1 = GEOSEquals(geom1_, geom2_);
+};
 
-        ensure_equals(r1, 1);
+typedef test_group<test_capigeosequals_data> group;
+typedef group::object object;
 
-        char const r2 = GEOSEquals(geom2_, geom1_);
+group test_capigeosequals_group("capi::GEOSEquals");
 
-        ensure_equals(r2, 1);
-    }
+//
+// Test Cases
+//
 
-    template<>
-    template<>
-    void object::test<2>()
-    {
-        geom1_ = GEOSGeomFromWKT("POINT(2 3)");
-        geom2_ = GEOSGeomFromWKT("POINT(2 2)");
+template<>
+template<>
+void object::test<1>
+()
+{
+    geom1_ = GEOSGeomFromWKT("POLYGON EMPTY");
+    geom2_ = GEOSGeomFromWKT("POLYGON EMPTY");
 
-        ensure( nullptr != geom1_ );
-        ensure( nullptr != geom2_ );
+    ensure(nullptr != geom1_);
+    ensure(nullptr != geom2_);
 
-        char const r1 = GEOSEquals(geom1_, geom2_);
+    char const r1 = GEOSEquals(geom1_, geom2_);
 
-        ensure_equals(int(r1), 0);
+    ensure_equals(r1, 1);
 
-        char const r2 = GEOSEquals(geom2_, geom1_);
+    char const r2 = GEOSEquals(geom2_, geom1_);
 
-        ensure_equals(int(r2), 0);
-    }
+    ensure_equals(r2, 1);
+}
 
-    template<>
-    template<>
-    void object::test<3>()
-    {
-        geom1_ = GEOSGeomFromWKT("MULTIPOLYGON(((0 0,0 10,10 10,10 0,0 0)))");
-        geom2_ = GEOSGeomFromWKT("POLYGON((0 0,0 10,10 10,10 0,0 0))");
+template<>
+template<>
+void object::test<2>
+()
+{
+    geom1_ = GEOSGeomFromWKT("POINT(2 3)");
+    geom2_ = GEOSGeomFromWKT("POINT(2 2)");
 
-        ensure( nullptr != geom1_ );
-        ensure( nullptr != geom2_ );
+    ensure(nullptr != geom1_);
+    ensure(nullptr != geom2_);
 
-        char const r1 = GEOSEquals(geom1_, geom2_);
+    char const r1 = GEOSEquals(geom1_, geom2_);
 
-        ensure_equals(int(r1), 1);
+    ensure_equals(int(r1), 0);
 
-        char const r2 = GEOSEquals(geom2_, geom1_);
+    char const r2 = GEOSEquals(geom2_, geom1_);
 
-        ensure_equals(int(r2), 1);
-    }
+    ensure_equals(int(r2), 0);
+}
 
-    // This is a test for bug #357 (GEOSEquals with nan coords)
-    template<>
-    template<>
-    void object::test<4>()
-    {
-        GEOSCoordSequence* cs = GEOSCoordSeq_create(5, 2);
+template<>
+template<>
+void object::test<3>
+()
+{
+    geom1_ = GEOSGeomFromWKT("MULTIPOLYGON(((0 0,0 10,10 10,10 0,0 0)))");
+    geom2_ = GEOSGeomFromWKT("POLYGON((0 0,0 10,10 10,10 0,0 0))");
 
-        double nan = std::numeric_limits<double>::quiet_NaN();
-        GEOSCoordSeq_setX(cs, 0, 1); GEOSCoordSeq_setY(cs, 0, 1);
-        for (unsigned int i=1; i<4; ++i) {
-            GEOSCoordSeq_setX(cs, i, nan);
-            GEOSCoordSeq_setY(cs, i, nan);
-        }
-        GEOSCoordSeq_setX(cs, 4, 1); GEOSCoordSeq_setY(cs, 4, 1);
+    ensure(nullptr != geom1_);
+    ensure(nullptr != geom2_);
 
-        geom1_ = GEOSGeom_createPolygon(GEOSGeom_createLinearRing(cs),
-                                        nullptr, 0);
+    char const r1 = GEOSEquals(geom1_, geom2_);
 
-        char const r1 = GEOSEquals(geom1_, geom1_);
+    ensure_equals(int(r1), 1);
 
-        ensure_equals(int(r1), 2);
+    char const r2 = GEOSEquals(geom2_, geom1_);
 
+    ensure_equals(int(r2), 1);
+}
+
+// This is a test for bug #357 (GEOSEquals with nan coords)
+template<>
+template<>
+void object::test<4>
+()
+{
+    GEOSCoordSequence* cs = GEOSCoordSeq_create(5, 2);
+
+    double nan = std::numeric_limits<double>::quiet_NaN();
+    GEOSCoordSeq_setX(cs, 0, 1);
+    GEOSCoordSeq_setY(cs, 0, 1);
+    for(unsigned int i = 1; i < 4; ++i) {
+        GEOSCoordSeq_setX(cs, i, nan);
+        GEOSCoordSeq_setY(cs, i, nan);
     }
+    GEOSCoordSeq_setX(cs, 4, 1);
+    GEOSCoordSeq_setY(cs, 4, 1);
 
-    // This is a test for bug #357 (GEOSEquals with inf coords)
-    template<>
-    template<>
-    void object::test<5>()
-    {
-        const char *hex = "0103000020E61000000100000005000000737979F3DDCC2CC0F92154F9E7534540000000000000F07F000000000000F07F8F806E993F7E55C0304B29FFEA8554400634E8D1DD424540B5FEE6A37FCD4540737979F3DDCC2CC0F92154F9E7534540";
+    geom1_ = GEOSGeom_createPolygon(GEOSGeom_createLinearRing(cs),
+                                    nullptr, 0);
 
-        geom1_ = GEOSGeomFromHEX_buf((unsigned char*)hex, std::strlen(hex));
+    char const r1 = GEOSEquals(geom1_, geom1_);
 
-        ensure( nullptr != geom1_ );
+    ensure_equals(int(r1), 2);
 
-        char const r1 = GEOSEquals(geom1_, geom1_);
+}
 
-        ensure_equals(int(r1), 2);
+// This is a test for bug #357 (GEOSEquals with inf coords)
+template<>
+template<>
+void object::test<5>
+()
+{
+    const char* hex =
+        "0103000020E61000000100000005000000737979F3DDCC2CC0F92154F9E7534540000000000000F07F000000000000F07F8F806E993F7E55C0304B29FFEA8554400634E8D1DD424540B5FEE6A37FCD4540737979F3DDCC2CC0F92154F9E7534540";
 
-    }
+    geom1_ = GEOSGeomFromHEX_buf((unsigned char*)hex, std::strlen(hex));
+
+    ensure(nullptr != geom1_);
+
+    char const r1 = GEOSEquals(geom1_, geom1_);
+
+    ensure_equals(int(r1), 2);
+
+}
 
 #if 0 // fails
-    // This is a test for bug #752 (GEOSEquals with collection)
-    template<>
-    template<>
-    void object::test<6>()
-    {
-        const char *wkt1 = "GEOMETRYCOLLECTION(POLYGON ("
-          "(0 0, 0 4, 4 4, 4 0, 0 0)"
-          "),"
-          "POLYGON ("
-          "(3 3, 3 4, 4 4, 4 3, 3 3)"
-          "))";
+// This is a test for bug #752 (GEOSEquals with collection)
+template<>
+template<>
+void object::test<6>
+()
+{
+    const char* wkt1 = "GEOMETRYCOLLECTION(POLYGON ("
+                       "(0 0, 0 4, 4 4, 4 0, 0 0)"
+                       "),"
+                       "POLYGON ("
+                       "(3 3, 3 4, 4 4, 4 3, 3 3)"
+                       "))";
 
-        geom1_ = GEOSGeomFromWKT(wkt1);
+    geom1_ = GEOSGeomFromWKT(wkt1);
 
-        ensure( 0 != geom1_ );
+    ensure(0 != geom1_);
 
-        char const r1 = GEOSEquals(geom1_, geom1_);
+    char const r1 = GEOSEquals(geom1_, geom1_);
 
-        ensure_equals(int(r1), 1);
-    }
+    ensure_equals(int(r1), 1);
+}
 #endif
 
 
diff --git a/tests/unit/capi/GEOSFrechetDistanceTest.cpp b/tests/unit/capi/GEOSFrechetDistanceTest.cpp
index 7df0c65..11042a1 100644
--- a/tests/unit/capi/GEOSFrechetDistanceTest.cpp
+++ b/tests/unit/capi/GEOSFrechetDistanceTest.cpp
@@ -11,89 +11,90 @@
 #include <memory>
 #include <math.h>
 
-namespace tut
-{
-    //
-    // Test Group
-    //
+namespace tut {
+//
+// Test Group
+//
 
-    // Common data used in test cases.
-    struct test_capigeosfrechetdistance_data
-    {
-        GEOSGeometry* geom1_;
-        GEOSGeometry* geom2_;
-        GEOSGeometry* geom3_;
-        GEOSWKTWriter* w_;
-
-        static void notice(const char *fmt, ...)
-        {
-            std::fprintf( stdout, "NOTICE: ");
-
-            va_list ap;
-            va_start(ap, fmt);
-            std::vfprintf(stdout, fmt, ap);
-            va_end(ap);
-
-            std::fprintf(stdout, "\n");
-        }
-
-        test_capigeosfrechetdistance_data()
-            : geom1_(nullptr), geom2_(nullptr), geom3_(nullptr), w_(nullptr)
-        {
-            initGEOS(notice, notice);
-            w_ = GEOSWKTWriter_create();
-            GEOSWKTWriter_setTrim(w_, 1);
-        }
-
-        ~test_capigeosfrechetdistance_data()
-        {
-            GEOSGeom_destroy(geom1_);
-            GEOSGeom_destroy(geom2_);
-            GEOSGeom_destroy(geom3_);
-            GEOSWKTWriter_destroy(w_);
-            geom1_ = nullptr;
-            geom2_ = nullptr;
-            geom3_ = nullptr;
-            finishGEOS();
-        }
-
-    };
-
-    typedef test_group<test_capigeosfrechetdistance_data> group;
-    typedef group::object object;
-
-    group test_capigeosfrechetdistance_group("capi::GEOSFrechetDistance");
-
-    //
-    // Test Cases
-    //
-
-    template<>
-    template<>
-    void object::test<1>()
+// Common data used in test cases.
+struct test_capigeosfrechetdistance_data {
+    GEOSGeometry* geom1_;
+    GEOSGeometry* geom2_;
+    GEOSGeometry* geom3_;
+    GEOSWKTWriter* w_;
+
+    static void
+    notice(const char* fmt, ...)
     {
-        geom1_ = GEOSGeomFromWKT("LINESTRING (0 0, 100 0)");
-        geom2_ = GEOSGeomFromWKT("LINESTRING (0 0, 50 50, 100 0)");
+        std::fprintf(stdout, "NOTICE: ");
 
-        double dist;
-        int ret = GEOSFrechetDistance(geom1_, geom2_, &dist);
+        va_list ap;
+        va_start(ap, fmt);
+        std::vfprintf(stdout, fmt, ap);
+        va_end(ap);
 
-        ensure_equals(ret, 1);
-        ensure_distance(dist, 70.7106781186548, 1e-12);
+        std::fprintf(stdout, "\n");
     }
 
-    template<>
-    template<>
-    void object::test<2>()
+    test_capigeosfrechetdistance_data()
+        : geom1_(nullptr), geom2_(nullptr), geom3_(nullptr), w_(nullptr)
     {
-        geom1_ = GEOSGeomFromWKT("LINESTRING (0 0, 100 0)");
-        geom2_ = GEOSGeomFromWKT("LINESTRING (0 0, 50 50, 100 0)");
-
-        double dist;
-        int ret = GEOSFrechetDistanceDensify(geom1_, geom2_, 0.5, &dist);
+        initGEOS(notice, notice);
+        w_ = GEOSWKTWriter_create();
+        GEOSWKTWriter_setTrim(w_, 1);
+    }
 
-        ensure_equals(ret, 1);
-        ensure_distance(dist, 50., 1e-12);
+    ~test_capigeosfrechetdistance_data()
+    {
+        GEOSGeom_destroy(geom1_);
+        GEOSGeom_destroy(geom2_);
+        GEOSGeom_destroy(geom3_);
+        GEOSWKTWriter_destroy(w_);
+        geom1_ = nullptr;
+        geom2_ = nullptr;
+        geom3_ = nullptr;
+        finishGEOS();
     }
 
+};
+
+typedef test_group<test_capigeosfrechetdistance_data> group;
+typedef group::object object;
+
+group test_capigeosfrechetdistance_group("capi::GEOSFrechetDistance");
+
+//
+// Test Cases
+//
+
+template<>
+template<>
+void object::test<1>
+()
+{
+    geom1_ = GEOSGeomFromWKT("LINESTRING (0 0, 100 0)");
+    geom2_ = GEOSGeomFromWKT("LINESTRING (0 0, 50 50, 100 0)");
+
+    double dist;
+    int ret = GEOSFrechetDistance(geom1_, geom2_, &dist);
+
+    ensure_equals(ret, 1);
+    ensure_distance(dist, 70.7106781186548, 1e-12);
+}
+
+template<>
+template<>
+void object::test<2>
+()
+{
+    geom1_ = GEOSGeomFromWKT("LINESTRING (0 0, 100 0)");
+    geom2_ = GEOSGeomFromWKT("LINESTRING (0 0, 50 50, 100 0)");
+
+    double dist;
+    int ret = GEOSFrechetDistanceDensify(geom1_, geom2_, 0.5, &dist);
+
+    ensure_equals(ret, 1);
+    ensure_distance(dist, 50., 1e-12);
+}
+
 } // namespace tut
diff --git a/tests/unit/capi/GEOSGeomFromWKBTest.cpp b/tests/unit/capi/GEOSGeomFromWKBTest.cpp
index 4accac6..5d1b428 100644
--- a/tests/unit/capi/GEOSGeomFromWKBTest.cpp
+++ b/tests/unit/capi/GEOSGeomFromWKBTest.cpp
@@ -12,136 +12,142 @@
 #include <cstdlib>
 #include <memory>
 
-namespace tut
-{
-    //
-    // Test Group
-    //
+namespace tut {
+//
+// Test Group
+//
 
-    // Common data used in test cases.
-    struct test_capigeosgeomfromwkb_data
-    {
-        GEOSGeometry* geom1_;
-        GEOSGeometry* geom2_;
-        GEOSWKTReader* reader_;
-
-        static void notice(const char *fmt, ...)
-        {
-            std::fprintf( stdout, "NOTICE: ");
-
-            va_list ap;
-            va_start(ap, fmt);
-            std::vfprintf(stdout, fmt, ap);
-            va_end(ap);
-
-            std::fprintf(stdout, "\n");
-        }
-
-        test_capigeosgeomfromwkb_data()
-            : geom1_(nullptr), geom2_(nullptr), reader_(nullptr)
-        {
-            initGEOS(notice, notice);
-            reader_ = GEOSWKTReader_create();
-        }
-
-        ~test_capigeosgeomfromwkb_data()
-        {
-            GEOSGeom_destroy(geom2_);
-            geom2_ = nullptr;
-            GEOSGeom_destroy(geom1_);
-            geom1_ = nullptr;
-            GEOSWKTReader_destroy(reader_);
-            reader_ = nullptr;
-            finishGEOS();
-        }
-
-        void test_wkb(std::string const& wkbhex, std::string const& wkt)
-        {
-            wkb_hex_decoder::binary_type wkb;
-            wkb_hex_decoder::decode(wkbhex, wkb);
-
-            geom1_ = GEOSGeomFromWKB_buf(&wkb[0], wkb.size());
-            ensure("GEOSGeomFromWKB_buf failed to create geometry", nullptr != geom1_ );
-
-            // TODO: Update test to compare with WKT-based geometry
-            (void)wkt;
-            //       ATM, some XYZ and XYZM geometries fail
-            //geom2_ = GEOSWKTReader_read(reader_, wkt.c_str());
-            //ensure ( 0 != geom2_ );
-            //char result = GEOSEquals(geom1_, geom2_);
-            //ensure_equals(result, char(1));
-        }
-    };
-
-    typedef test_group<test_capigeosgeomfromwkb_data> group;
-    typedef group::object object;
-
-    group test_capigeosgeomfromwkb_group("capi::GEOSGeomFromWKB");
-
-    //
-    // Test Cases
-    //
-
-    template<>
-    template<>
-    void object::test<1>()
-    {
-        // POINT(1.234 5.678)
-        std::string wkt("POINT (1.234 5.678)");
-        std::string wkb("01010000005839B4C876BEF33F83C0CAA145B61640");
-        test_wkb(wkb, wkt);
-    }
+// Common data used in test cases.
+struct test_capigeosgeomfromwkb_data {
+    GEOSGeometry* geom1_;
+    GEOSGeometry* geom2_;
+    GEOSWKTReader* reader_;
 
-    template<>
-    template<>
-    void object::test<2>()
+    static void
+    notice(const char* fmt, ...)
     {
-        // SRID=4;POINT(0 0)
-        std::string wkt("POINT(0 0)");
-        std::string ewkb("01010000200400000000000000000000000000000000000000");
-        test_wkb(ewkb, wkt);
+        std::fprintf(stdout, "NOTICE: ");
+
+        va_list ap;
+        va_start(ap, fmt);
+        std::vfprintf(stdout, fmt, ap);
+        va_end(ap);
+
+        std::fprintf(stdout, "\n");
     }
 
-    template<>
-    template<>
-    void object::test<3>()
+    test_capigeosgeomfromwkb_data()
+        : geom1_(nullptr), geom2_(nullptr), reader_(nullptr)
     {
-        // SRID=32632;POINT(1.234 5.678)
-        std::string wkt("POINT (1.234 5.678)");
-        std::string ewkb("0101000020787F00005839B4C876BEF33F83C0CAA145B61640");
-        test_wkb(ewkb, wkt);
+        initGEOS(notice, notice);
+        reader_ = GEOSWKTReader_create();
     }
 
-    template<>
-    template<>
-    void object::test<4>()
+    ~test_capigeosgeomfromwkb_data()
     {
-        // POINT (1.234 5.678 15 79) -- XYZM
-        std::string wkt("POINT (1.234 5.678 15 79)");
-        std::string ewkb("01010000C05839B4C876BEF33F83C0CAA145B616400000000000002E400000000000C05340");
-        test_wkb(ewkb, wkt);
+        GEOSGeom_destroy(geom2_);
+        geom2_ = nullptr;
+        GEOSGeom_destroy(geom1_);
+        geom1_ = nullptr;
+        GEOSWKTReader_destroy(reader_);
+        reader_ = nullptr;
+        finishGEOS();
     }
 
-    template<>
-    template<>
-    void object::test<5>()
+    void
+    test_wkb(std::string const& wkbhex, std::string const& wkt)
     {
-        std::string wkt("MULTIPOINT (1.123 1.456, 2.123 2.456, 3.123 3.456)");
-        std::string ewkb("01040000000300000001010000002b8716d9cef7f13fb29defa7c64bf73f010100000096438b6ce7fb0040d9cef753e3a50340010100000096438b6ce7fb0840d9cef753e3a50b40");
-        test_wkb(ewkb, wkt);
+        wkb_hex_decoder::binary_type wkb;
+        wkb_hex_decoder::decode(wkbhex, wkb);
+
+        geom1_ = GEOSGeomFromWKB_buf(&wkb[0], wkb.size());
+        ensure("GEOSGeomFromWKB_buf failed to create geometry", nullptr != geom1_);
+
+        // TODO: Update test to compare with WKT-based geometry
+        (void)wkt;
+        //       ATM, some XYZ and XYZM geometries fail
+        //geom2_ = GEOSWKTReader_read(reader_, wkt.c_str());
+        //ensure ( 0 != geom2_ );
+        //char result = GEOSEquals(geom1_, geom2_);
+        //ensure_equals(result, char(1));
     }
+};
+
+typedef test_group<test_capigeosgeomfromwkb_data> group;
+typedef group::object object;
 
-    // TODO: Does GEOSGeomFromWKB_buf accept EWKB or WKB only?
-    //       The cases below test EWKB input and they are failing.
-    //template<>
-    //template<>
-    //void object::test<6>()
-    //{
-    //    // SELECT st_geomfromewkt('MULTIPOINT((0 0 1 1), (3 2 2 1))') ;
-    //    std::string wkt("MULTIPOINT((0 0 1 1), (3 2 2 1))");
-    //    std::string ewkb("01040000C00200000001010000C000000000000000000000000000000000000000000000F03F000000000000F03F01010000C0000000000000084000000000000000400000000000000040000000000000F03F");
-    //    test_wkb(ewkb, wkt);
-    //}
+group test_capigeosgeomfromwkb_group("capi::GEOSGeomFromWKB");
+
+//
+// Test Cases
+//
+
+template<>
+template<>
+void object::test<1>
+()
+{
+    // POINT(1.234 5.678)
+    std::string wkt("POINT (1.234 5.678)");
+    std::string wkb("01010000005839B4C876BEF33F83C0CAA145B61640");
+    test_wkb(wkb, wkt);
+}
+
+template<>
+template<>
+void object::test<2>
+()
+{
+    // SRID=4;POINT(0 0)
+    std::string wkt("POINT(0 0)");
+    std::string ewkb("01010000200400000000000000000000000000000000000000");
+    test_wkb(ewkb, wkt);
+}
+
+template<>
+template<>
+void object::test<3>
+()
+{
+    // SRID=32632;POINT(1.234 5.678)
+    std::string wkt("POINT (1.234 5.678)");
+    std::string ewkb("0101000020787F00005839B4C876BEF33F83C0CAA145B61640");
+    test_wkb(ewkb, wkt);
+}
+
+template<>
+template<>
+void object::test<4>
+()
+{
+    // POINT (1.234 5.678 15 79) -- XYZM
+    std::string wkt("POINT (1.234 5.678 15 79)");
+    std::string ewkb("01010000C05839B4C876BEF33F83C0CAA145B616400000000000002E400000000000C05340");
+    test_wkb(ewkb, wkt);
+}
+
+template<>
+template<>
+void object::test<5>
+()
+{
+    std::string wkt("MULTIPOINT (1.123 1.456, 2.123 2.456, 3.123 3.456)");
+    std::string
+    ewkb("01040000000300000001010000002b8716d9cef7f13fb29defa7c64bf73f010100000096438b6ce7fb0040d9cef753e3a50340010100000096438b6ce7fb0840d9cef753e3a50b40");
+    test_wkb(ewkb, wkt);
+}
+
+// TODO: Does GEOSGeomFromWKB_buf accept EWKB or WKB only?
+//       The cases below test EWKB input and they are failing.
+//template<>
+//template<>
+//void object::test<6>()
+//{
+//    // SELECT st_geomfromewkt('MULTIPOINT((0 0 1 1), (3 2 2 1))') ;
+//    std::string wkt("MULTIPOINT((0 0 1 1), (3 2 2 1))");
+//    std::string ewkb("01040000C00200000001010000C000000000000000000000000000000000000000000000F03F000000000000F03F01010000C0000000000000084000000000000000400000000000000040000000000000F03F");
+//    test_wkb(ewkb, wkt);
+//}
 
 } // namespace tut
 
diff --git a/tests/unit/capi/GEOSGeomToWKTTest.cpp b/tests/unit/capi/GEOSGeomToWKTTest.cpp
index 82c4bc4..b634c7a 100644
--- a/tests/unit/capi/GEOSGeomToWKTTest.cpp
+++ b/tests/unit/capi/GEOSGeomToWKTTest.cpp
@@ -11,194 +11,209 @@
 #include <cstdlib>
 #include <memory>
 
-namespace tut
-{
-    //
-    // Test Group
-    //
-
-    // Common data used in test cases.
-    struct test_capigeosgeomtowkt_data
-    {
-        GEOSGeometry* geom1_;
-
-        static void notice(const char *fmt, ...)
-        {
-            std::fprintf( stdout, "NOTICE: ");
-
-            va_list ap;
-            va_start(ap, fmt);
-            std::vfprintf(stdout, fmt, ap);
-            va_end(ap);
-
-            std::fprintf(stdout, "\n");
-        }
-
-        test_capigeosgeomtowkt_data()
-            : geom1_(nullptr)
-        {
-            initGEOS(notice, notice);
-        }
-
-        ~test_capigeosgeomtowkt_data()
-        {
-            GEOSGeom_destroy(geom1_);
-            geom1_ = nullptr;
-            finishGEOS();
-        }
-
-        void test_wkt(std::string const& wkt)
-        {
-            geom1_ = GEOSGeomFromWKT(wkt.c_str());
-            ensure ( nullptr != geom1_ );
-
-            char* wkt_c = GEOSGeomToWKT(geom1_);
-            std::string out(wkt_c);
-        free(wkt_c);
-
-            ensure_equals(out, wkt);
-        }
-
-        void test_wkt(std::string const& wkt, std::string::size_type n)
-        {
-            geom1_ = GEOSGeomFromWKT(wkt.c_str());
-            ensure ( nullptr != geom1_ );
-
-            char* wkt_c = GEOSGeomToWKT(geom1_);
-            std::string out(wkt_c);
-        free(wkt_c);
-
-            ensure_equals(out.substr(0, n), wkt.substr(0, n));
-        }
-
-        void test_writer_wkt(GEOSWKTWriter *writer, std::string const& wkt)
-        {
-            geom1_ = GEOSGeomFromWKT(wkt.c_str());
-            ensure ( nullptr != geom1_ );
-
-            char* wkt_c = GEOSWKTWriter_write(writer,geom1_);
-            std::string out(wkt_c);
-            free(wkt_c);
-
-            ensure_equals(out, wkt);
-        }
-    };
+namespace tut {
+//
+// Test Group
+//
 
-    typedef test_group<test_capigeosgeomtowkt_data> group;
-    typedef group::object object;
+// Common data used in test cases.
+struct test_capigeosgeomtowkt_data {
+    GEOSGeometry* geom1_;
 
-    group test_capigeosgeomtowkt_group("capi::GEOSGeomToWKT");
+    static void
+    notice(const char* fmt, ...)
+    {
+        std::fprintf(stdout, "NOTICE: ");
 
-    //
-    // Test Cases
-    //
+        va_list ap;
+        va_start(ap, fmt);
+        std::vfprintf(stdout, fmt, ap);
+        va_end(ap);
 
-    template<>
-    template<>
-    void object::test<1>()
-    {
-        test_wkt("POINT EMPTY");
+        std::fprintf(stdout, "\n");
     }
 
-    template<>
-    template<>
-    void object::test<2>()
+    test_capigeosgeomtowkt_data()
+        : geom1_(nullptr)
     {
-        test_wkt("LINESTRING EMPTY");
+        initGEOS(notice, notice);
     }
 
-    template<>
-    template<>
-    void object::test<3>()
+    ~test_capigeosgeomtowkt_data()
     {
-        test_wkt("POLYGON EMPTY");
+        GEOSGeom_destroy(geom1_);
+        geom1_ = nullptr;
+        finishGEOS();
     }
 
-    template<>
-    template<>
-    void object::test<4>()
+    void
+    test_wkt(std::string const& wkt)
     {
-        test_wkt("MULTIPOINT EMPTY");
-    }
+        geom1_ = GEOSGeomFromWKT(wkt.c_str());
+        ensure(nullptr != geom1_);
 
-    template<>
-    template<>
-    void object::test<5>()
-    {
-        test_wkt("MULTILINESTRING EMPTY");
+        char* wkt_c = GEOSGeomToWKT(geom1_);
+        std::string out(wkt_c);
+        free(wkt_c);
+
+        ensure_equals(out, wkt);
     }
 
-    template<>
-    template<>
-    void object::test<6>()
+    void
+    test_wkt(std::string const& wkt, std::string::size_type n)
     {
-        test_wkt("MULTIPOLYGON EMPTY");
-    }
+        geom1_ = GEOSGeomFromWKT(wkt.c_str());
+        ensure(nullptr != geom1_);
 
-    // Comparing string based on float-point numbers does not make sense,
-    // so make poor-man comparison of WKT type tag.
+        char* wkt_c = GEOSGeomToWKT(geom1_);
+        std::string out(wkt_c);
+        free(wkt_c);
 
-    template<>
-    template<>
-    void object::test<7>()
-    {
-        test_wkt("POINT (1.234 5.678)", 7);
+        ensure_equals(out.substr(0, n), wkt.substr(0, n));
     }
 
-    template<>
-    template<>
-    void object::test<8>()
+    void
+    test_writer_wkt(GEOSWKTWriter* writer, std::string const& wkt)
     {
-        test_wkt("LINESTRING (0 0, 5 5, 10 5, 10 10)", 13);
-    }
+        geom1_ = GEOSGeomFromWKT(wkt.c_str());
+        ensure(nullptr != geom1_);
 
-    template<>
-    template<>
-    void object::test<9>()
-    {
-        test_wkt("POLYGON ((0 10, 5 5, 10 5, 15 10, 10 15, 5 15, 0 10))", 11);
-    }
+        char* wkt_c = GEOSWKTWriter_write(writer, geom1_);
+        std::string out(wkt_c);
+        free(wkt_c);
 
-    template<>
-    template<>
-    void object::test<10>()
-    {
-        test_wkt("MULTIPOINT (0 0, 5 5, 10 10, 15 15, 20 20)", 13);
+        ensure_equals(out, wkt);
     }
+};
 
-    template<>
-    template<>
-    void object::test<11>()
-    {
-        test_wkt("MULTILINESTRING ((0 0, 10 0, 10 10, 0 10, 10 20),(2 2, 2 6, 6 4, 20 2))", 19);
-    }
+typedef test_group<test_capigeosgeomtowkt_data> group;
+typedef group::object object;
 
-    template<>
-    template<>
-    void object::test<12>()
-    {
-        test_wkt("MULTIPOLYGON (((0 0, 10 0, 10 10, 0 10, 0 0),(2 2, 2 6, 6 4, 2 2)),((60 60, 60 50, 70 40, 60 60)))", 17);
-    }
+group test_capigeosgeomtowkt_group("capi::GEOSGeomToWKT");
 
-    // Test the WKTWriter API instead of the quicky function.
+//
+// Test Cases
+//
 
-    template<>
-    template<>
-    void object::test<13>()
-    {
-        GEOSWKTWriter *writer = GEOSWKTWriter_create();
+template<>
+template<>
+void object::test<1>
+()
+{
+    test_wkt("POINT EMPTY");
+}
 
-        ensure( "getOutputDimension_1",
-                GEOSWKTWriter_getOutputDimension(writer) == 2 );
+template<>
+template<>
+void object::test<2>
+()
+{
+    test_wkt("LINESTRING EMPTY");
+}
 
-        GEOSWKTWriter_setTrim( writer, 1 );
-        GEOSWKTWriter_setOutputDimension( writer, 3 );
-        ensure( "getOutputDimension_2",
-                GEOSWKTWriter_getOutputDimension(writer) == 3 );
+template<>
+template<>
+void object::test<3>
+()
+{
+    test_wkt("POLYGON EMPTY");
+}
 
-        test_writer_wkt(writer, "POINT Z (10 13 3)");
-        GEOSWKTWriter_destroy( writer );
-    }
+template<>
+template<>
+void object::test<4>
+()
+{
+    test_wkt("MULTIPOINT EMPTY");
+}
+
+template<>
+template<>
+void object::test<5>
+()
+{
+    test_wkt("MULTILINESTRING EMPTY");
+}
+
+template<>
+template<>
+void object::test<6>
+()
+{
+    test_wkt("MULTIPOLYGON EMPTY");
+}
+
+// Comparing string based on float-point numbers does not make sense,
+// so make poor-man comparison of WKT type tag.
+
+template<>
+template<>
+void object::test<7>
+()
+{
+    test_wkt("POINT (1.234 5.678)", 7);
+}
+
+template<>
+template<>
+void object::test<8>
+()
+{
+    test_wkt("LINESTRING (0 0, 5 5, 10 5, 10 10)", 13);
+}
+
+template<>
+template<>
+void object::test<9>
+()
+{
+    test_wkt("POLYGON ((0 10, 5 5, 10 5, 15 10, 10 15, 5 15, 0 10))", 11);
+}
+
+template<>
+template<>
+void object::test<10>
+()
+{
+    test_wkt("MULTIPOINT (0 0, 5 5, 10 10, 15 15, 20 20)", 13);
+}
+
+template<>
+template<>
+void object::test<11>
+()
+{
+    test_wkt("MULTILINESTRING ((0 0, 10 0, 10 10, 0 10, 10 20),(2 2, 2 6, 6 4, 20 2))", 19);
+}
+
+template<>
+template<>
+void object::test<12>
+()
+{
+    test_wkt("MULTIPOLYGON (((0 0, 10 0, 10 10, 0 10, 0 0),(2 2, 2 6, 6 4, 2 2)),((60 60, 60 50, 70 40, 60 60)))", 17);
+}
+
+// Test the WKTWriter API instead of the quicky function.
+
+template<>
+template<>
+void object::test<13>
+()
+{
+    GEOSWKTWriter* writer = GEOSWKTWriter_create();
+
+    ensure("getOutputDimension_1",
+           GEOSWKTWriter_getOutputDimension(writer) == 2);
+
+    GEOSWKTWriter_setTrim(writer, 1);
+    GEOSWKTWriter_setOutputDimension(writer, 3);
+    ensure("getOutputDimension_2",
+           GEOSWKTWriter_getOutputDimension(writer) == 3);
+
+    test_writer_wkt(writer, "POINT Z (10 13 3)");
+    GEOSWKTWriter_destroy(writer);
+}
 
 } // namespace tut
 
diff --git a/tests/unit/capi/GEOSGeom_create.cpp b/tests/unit/capi/GEOSGeom_create.cpp
index b8cb4af..b2a2d73 100644
--- a/tests/unit/capi/GEOSGeom_create.cpp
+++ b/tests/unit/capi/GEOSGeom_create.cpp
@@ -11,129 +11,143 @@
 #include <cstdlib>
 #include <memory>
 
-namespace tut
-{
-    //
-    // Test Group
-    //
-
-    // Common data used in test cases.
-    struct test_capigeosgeom_create_data
-    {
-        GEOSGeometry* geom1_;
-	GEOSContextHandle_t handle_;
-
-        static void notice(const char *fmt, ...)
-        {
-            std::fprintf( stdout, "NOTICE: ");
-
-            va_list ap;
-            va_start(ap, fmt);
-            std::vfprintf(stdout, fmt, ap);
-            va_end(ap);
-
-            std::fprintf(stdout, "\n");
-        }
-
-        test_capigeosgeom_create_data()
-            : geom1_(nullptr), handle_(initGEOS_r(notice, notice))
-        {
-        }
-
-        ~test_capigeosgeom_create_data()
-        {
-            GEOSGeom_destroy(geom1_); geom1_ = nullptr;
-            finishGEOS_r(handle_);
-        }
-
-    };
+namespace tut {
+//
+// Test Group
+//
 
-    typedef test_group<test_capigeosgeom_create_data> group;
-    typedef group::object object;
+// Common data used in test cases.
+struct test_capigeosgeom_create_data {
+    GEOSGeometry* geom1_;
+    GEOSContextHandle_t handle_;
 
-    group test_capigeosgeom_create_group("capi::GEOSGeom_create");
+    static void
+    notice(const char* fmt, ...)
+    {
+        std::fprintf(stdout, "NOTICE: ");
 
-    //
-    // Test Cases
-    //
+        va_list ap;
+        va_start(ap, fmt);
+        std::vfprintf(stdout, fmt, ap);
+        va_end(ap);
 
-    // EMPTY point
-    template<>
-    template<>
-    void object::test<1>()
-    {
-        geom1_ = GEOSGeom_createEmptyPoint_r(handle_);
-        ensure(0 != GEOSisEmpty_r(handle_, geom1_));
-        ensure_equals(GEOSGeomTypeId_r(handle_, geom1_), GEOS_POINT);
-        GEOSGeom_destroy(geom1_); geom1_=nullptr;
+        std::fprintf(stdout, "\n");
     }
 
-    // EMPTY linestring
-    template<>
-    template<>
-    void object::test<2>()
+    test_capigeosgeom_create_data()
+        : geom1_(nullptr), handle_(initGEOS_r(notice, notice))
     {
-        geom1_ = GEOSGeom_createEmptyLineString_r(handle_);
-        ensure(0 != GEOSisEmpty_r(handle_, geom1_));
-        ensure_equals(GEOSGeomTypeId_r(handle_, geom1_), GEOS_LINESTRING);
-        GEOSGeom_destroy(geom1_); geom1_=nullptr;
     }
 
-
-    // EMPTY polygon
-    template<>
-    template<>
-    void object::test<3>()
+    ~test_capigeosgeom_create_data()
     {
-        geom1_ = GEOSGeom_createEmptyPolygon_r(handle_);
-        ensure(0 != GEOSisEmpty_r(handle_, geom1_));
-        ensure_equals(GEOSGeomTypeId_r(handle_, geom1_), GEOS_POLYGON);
-        GEOSGeom_destroy(geom1_); geom1_=nullptr;
+        GEOSGeom_destroy(geom1_);
+        geom1_ = nullptr;
+        finishGEOS_r(handle_);
     }
 
-    // EMPTY multipoint
-    template<>
-    template<>
-    void object::test<4>()
-    {
-        geom1_ = GEOSGeom_createEmptyCollection_r(handle_, GEOS_MULTIPOINT);
-        ensure(0 != GEOSisEmpty_r(handle_, geom1_));
-        ensure_equals(GEOSGeomTypeId_r(handle_, geom1_), GEOS_MULTIPOINT);
-        GEOSGeom_destroy(geom1_); geom1_=nullptr;
-    }
+};
 
-    // EMPTY multilinestring
-    template<>
-    template<>
-    void object::test<5>()
-    {
-        geom1_ = GEOSGeom_createEmptyCollection_r(handle_, GEOS_MULTILINESTRING);
-        ensure(0 != GEOSisEmpty_r(handle_, geom1_));
-        ensure_equals(GEOSGeomTypeId_r(handle_, geom1_), GEOS_MULTILINESTRING);
-        GEOSGeom_destroy(geom1_); geom1_=nullptr;
-    }
+typedef test_group<test_capigeosgeom_create_data> group;
+typedef group::object object;
 
-    // EMPTY multipolygon
-    template<>
-    template<>
-    void object::test<6>()
-    {
-        geom1_ = GEOSGeom_createEmptyCollection_r(handle_, GEOS_MULTIPOLYGON);
-        ensure(0 != GEOSisEmpty_r(handle_, geom1_));
-        ensure_equals(GEOSGeomTypeId_r(handle_, geom1_), GEOS_MULTIPOLYGON);
-        GEOSGeom_destroy(geom1_); geom1_=nullptr;
-    }
+group test_capigeosgeom_create_group("capi::GEOSGeom_create");
 
-    // EMPTY collection
-    template<>
-    template<>
-    void object::test<7>()
-    {
-        geom1_ = GEOSGeom_createEmptyCollection_r(handle_, GEOS_GEOMETRYCOLLECTION);
-        ensure(0 != GEOSisEmpty_r(handle_, geom1_));
-        ensure_equals(GEOSGeomTypeId_r(handle_, geom1_), GEOS_GEOMETRYCOLLECTION);
-        GEOSGeom_destroy(geom1_); geom1_=nullptr;
-    }
+//
+// Test Cases
+//
+
+// EMPTY point
+template<>
+template<>
+void object::test<1>
+()
+{
+    geom1_ = GEOSGeom_createEmptyPoint_r(handle_);
+    ensure(0 != GEOSisEmpty_r(handle_, geom1_));
+    ensure_equals(GEOSGeomTypeId_r(handle_, geom1_), GEOS_POINT);
+    GEOSGeom_destroy(geom1_);
+    geom1_ = nullptr;
+}
+
+// EMPTY linestring
+template<>
+template<>
+void object::test<2>
+()
+{
+    geom1_ = GEOSGeom_createEmptyLineString_r(handle_);
+    ensure(0 != GEOSisEmpty_r(handle_, geom1_));
+    ensure_equals(GEOSGeomTypeId_r(handle_, geom1_), GEOS_LINESTRING);
+    GEOSGeom_destroy(geom1_);
+    geom1_ = nullptr;
+}
+
+
+// EMPTY polygon
+template<>
+template<>
+void object::test<3>
+()
+{
+    geom1_ = GEOSGeom_createEmptyPolygon_r(handle_);
+    ensure(0 != GEOSisEmpty_r(handle_, geom1_));
+    ensure_equals(GEOSGeomTypeId_r(handle_, geom1_), GEOS_POLYGON);
+    GEOSGeom_destroy(geom1_);
+    geom1_ = nullptr;
+}
+
+// EMPTY multipoint
+template<>
+template<>
+void object::test<4>
+()
+{
+    geom1_ = GEOSGeom_createEmptyCollection_r(handle_, GEOS_MULTIPOINT);
+    ensure(0 != GEOSisEmpty_r(handle_, geom1_));
+    ensure_equals(GEOSGeomTypeId_r(handle_, geom1_), GEOS_MULTIPOINT);
+    GEOSGeom_destroy(geom1_);
+    geom1_ = nullptr;
+}
+
+// EMPTY multilinestring
+template<>
+template<>
+void object::test<5>
+()
+{
+    geom1_ = GEOSGeom_createEmptyCollection_r(handle_, GEOS_MULTILINESTRING);
+    ensure(0 != GEOSisEmpty_r(handle_, geom1_));
+    ensure_equals(GEOSGeomTypeId_r(handle_, geom1_), GEOS_MULTILINESTRING);
+    GEOSGeom_destroy(geom1_);
+    geom1_ = nullptr;
+}
+
+// EMPTY multipolygon
+template<>
+template<>
+void object::test<6>
+()
+{
+    geom1_ = GEOSGeom_createEmptyCollection_r(handle_, GEOS_MULTIPOLYGON);
+    ensure(0 != GEOSisEmpty_r(handle_, geom1_));
+    ensure_equals(GEOSGeomTypeId_r(handle_, geom1_), GEOS_MULTIPOLYGON);
+    GEOSGeom_destroy(geom1_);
+    geom1_ = nullptr;
+}
+
+// EMPTY collection
+template<>
+template<>
+void object::test<7>
+()
+{
+    geom1_ = GEOSGeom_createEmptyCollection_r(handle_, GEOS_GEOMETRYCOLLECTION);
+    ensure(0 != GEOSisEmpty_r(handle_, geom1_));
+    ensure_equals(GEOSGeomTypeId_r(handle_, geom1_), GEOS_GEOMETRYCOLLECTION);
+    GEOSGeom_destroy(geom1_);
+    geom1_ = nullptr;
+}
 
 
 } // namespace tut
diff --git a/tests/unit/capi/GEOSGeom_createCollection.cpp b/tests/unit/capi/GEOSGeom_createCollection.cpp
index cf9d255..9f850de 100644
--- a/tests/unit/capi/GEOSGeom_createCollection.cpp
+++ b/tests/unit/capi/GEOSGeom_createCollection.cpp
@@ -15,100 +15,103 @@
 #include <string>
 #include <vector>
 
-namespace tut
-{
-    //
-    // Test Group
-    //
+namespace tut {
+//
+// Test Group
+//
 
-    // Common data used in test cases.
-    struct test_capigeosgeom_createcollection_data
+// Common data used in test cases.
+struct test_capigeosgeom_createcollection_data {
+    GEOSContextHandle_t handle_;
+    GEOSGeom geom_; // collection result
+    enum { geom_size = 3 };
+
+    static void
+    notice(const char* fmt, ...)
     {
-        GEOSContextHandle_t handle_;
-        GEOSGeom geom_; // collection result
-        enum { geom_size = 3 };
-
-        static void notice(const char *fmt, ...)
-        {
-            std::fprintf( stdout, "NOTICE: ");
-
-            va_list ap;
-            va_start(ap, fmt);
-            std::vfprintf(stdout, fmt, ap);
-            va_end(ap);
-
-            std::fprintf(stdout, "\n");
-        }
-
-        test_capigeosgeom_createcollection_data()
-            : handle_(initGEOS_r(notice, notice)), geom_(nullptr)
-        {
-        }
-
-        ~test_capigeosgeom_createcollection_data()
-        {
-            GEOSGeom_destroy(geom_); geom_ = nullptr;
-            finishGEOS_r(handle_);
-        }
-    };
+        std::fprintf(stdout, "NOTICE: ");
 
-    typedef test_group<test_capigeosgeom_createcollection_data> group;
-    typedef group::object object;
+        va_list ap;
+        va_start(ap, fmt);
+        std::vfprintf(stdout, fmt, ap);
+        va_end(ap);
 
-    group test_capigeosgeom_createcollection_group("capi::GEOSGeom_createCollection");
+        std::fprintf(stdout, "\n");
+    }
 
-    //
-    // Test Cases
-    //
+    test_capigeosgeom_createcollection_data()
+        : handle_(initGEOS_r(notice, notice)), geom_(nullptr)
+    {
+    }
 
-    // Create collection from constant length C-array
-    template<>
-    template<>
-    void object::test<1>()
+    ~test_capigeosgeom_createcollection_data()
     {
-        GEOSGeom geoms[geom_size];
-        geoms[0] = GEOSGeom_createEmptyPoint_r(handle_);
-        geoms[1] = GEOSGeom_createEmptyPoint_r(handle_);
-        geoms[2] = GEOSGeom_createEmptyPoint_r(handle_);
-        // takes ownership of individual geometries
-        geom_ = GEOSGeom_createCollection_r(handle_, GEOS_MULTIPOINT, geoms, geom_size);
-        ensure_equals(GEOSGetNumGeometries_r(handle_, geom_), (int)geom_size);
+        GEOSGeom_destroy(geom_);
+        geom_ = nullptr;
+        finishGEOS_r(handle_);
     }
+};
+
+typedef test_group<test_capigeosgeom_createcollection_data> group;
+typedef group::object object;
+
+group test_capigeosgeom_createcollection_group("capi::GEOSGeom_createCollection");
+
+//
+// Test Cases
+//
+
+// Create collection from constant length C-array
+template<>
+template<>
+void object::test<1>
+()
+{
+    GEOSGeom geoms[geom_size];
+    geoms[0] = GEOSGeom_createEmptyPoint_r(handle_);
+    geoms[1] = GEOSGeom_createEmptyPoint_r(handle_);
+    geoms[2] = GEOSGeom_createEmptyPoint_r(handle_);
+    // takes ownership of individual geometries
+    geom_ = GEOSGeom_createCollection_r(handle_, GEOS_MULTIPOINT, geoms, geom_size);
+    ensure_equals(GEOSGetNumGeometries_r(handle_, geom_), (int)geom_size);
+}
 
 #if (defined(_MSC_VER) && _MSC_VER >= 1600) || __cplusplus > 199711L || defined(__GXX_EXPERIMENTAL_CXX0X__)
-    // Create collection from constant length std::array
-    template<>
-    template<>
-    void object::test<2>()
-    {
-        std::array<GEOSGeom, geom_size> geoms = {
+// Create collection from constant length std::array
+template<>
+template<>
+void object::test<2>
+()
+{
+    std::array<GEOSGeom, geom_size> geoms = {
         GEOSGeom_createEmptyPoint_r(handle_),
         GEOSGeom_createEmptyPoint_r(handle_),
         GEOSGeom_createEmptyPoint_r(handle_)
-        };
-        // takes ownership of individual geometries
-        geom_ = GEOSGeom_createCollection_r(handle_, GEOS_MULTIPOINT,
-            geoms.data(), static_cast<int>(geoms.size()));
-        ensure_equals(GEOSGetNumGeometries_r(handle_, geom_), geom_size);
-    }
+    };
+    // takes ownership of individual geometries
+    geom_ = GEOSGeom_createCollection_r(handle_, GEOS_MULTIPOINT,
+                                        geoms.data(), static_cast<int>(geoms.size()));
+    ensure_equals(GEOSGetNumGeometries_r(handle_, geom_), geom_size);
+}
 #endif
 
-    // Create collection from dynamic length std::vector of geometries
-    template<>
-    template<>
-    void object::test<3>()
-    {
-        std::vector<GEOSGeom> geoms;
-        geoms.push_back(GEOSGeom_createEmptyPoint_r(handle_));
-        geoms.push_back(GEOSGeom_createEmptyPoint_r(handle_));
-        geoms.push_back(GEOSGeom_createEmptyPoint_r(handle_));
-        geoms.push_back(GEOSGeom_createEmptyPoint_r(handle_));
-        geoms.push_back(GEOSGeom_createEmptyPoint_r(handle_));
-        // takes ownership of individual geometries
-        geom_ = GEOSGeom_createCollection_r(handle_, GEOS_MULTIPOINT,
-            geoms.data(), static_cast<int>(geoms.size()));
-        ensure_equals(static_cast<size_t>(GEOSGetNumGeometries_r(handle_, geom_)), geoms.size());
-    }
+// Create collection from dynamic length std::vector of geometries
+template<>
+template<>
+void object::test<3>
+()
+{
+    std::vector<GEOSGeom> geoms;
+    geoms.push_back(GEOSGeom_createEmptyPoint_r(handle_));
+    geoms.push_back(GEOSGeom_createEmptyPoint_r(handle_));
+    geoms.push_back(GEOSGeom_createEmptyPoint_r(handle_));
+    geoms.push_back(GEOSGeom_createEmptyPoint_r(handle_));
+    geoms.push_back(GEOSGeom_createEmptyPoint_r(handle_));
+    // takes ownership of individual geometries
+    geom_ = GEOSGeom_createCollection_r(handle_, GEOS_MULTIPOINT,
+                                        geoms.data(), static_cast<int>(geoms.size()));
+    ensure_equals(static_cast<size_t>(GEOSGetNumGeometries_r(handle_, geom_)), geoms.size());
+}
 
 } // namespace tut
 
diff --git a/tests/unit/capi/GEOSGeom_extentTest.cpp b/tests/unit/capi/GEOSGeom_extentTest.cpp
index 787c601..637c20c 100644
--- a/tests/unit/capi/GEOSGeom_extentTest.cpp
+++ b/tests/unit/capi/GEOSGeom_extentTest.cpp
@@ -9,74 +9,76 @@
 #include <cstdio>
 #include <cstdlib>
 
-namespace tut
-{
-    struct test_capigeosgeom_extent {
-        static void notice(const char *fmt, ...)
-        {
-            std::fprintf( stdout, "NOTICE: ");
+namespace tut {
+struct test_capigeosgeom_extent {
+    static void
+    notice(const char* fmt, ...)
+    {
+        std::fprintf(stdout, "NOTICE: ");
 
-            va_list ap;
-            va_start(ap, fmt);
-            std::vfprintf(stdout, fmt, ap);
-            va_end(ap);
+        va_list ap;
+        va_start(ap, fmt);
+        std::vfprintf(stdout, fmt, ap);
+        va_end(ap);
 
-            std::fprintf(stdout, "\n");
-        }
+        std::fprintf(stdout, "\n");
+    }
 
-        test_capigeosgeom_extent()
-        {
-            initGEOS(notice, notice);
-        }
+    test_capigeosgeom_extent()
+    {
+        initGEOS(notice, notice);
+    }
 
-        ~test_capigeosgeom_extent()
-        {
-            finishGEOS();
-        }
+    ~test_capigeosgeom_extent()
+    {
+        finishGEOS();
+    }
 
-    };
+};
 
-    typedef test_group<test_capigeosgeom_extent> group;
-    typedef group::object object;
+typedef test_group<test_capigeosgeom_extent> group;
+typedef group::object object;
 
-    group test_capigeosgeom_extent_group("capi::GEOSGeom_getXYMinMax");
+group test_capigeosgeom_extent_group("capi::GEOSGeom_getXYMinMax");
 
-    template<>
-    template<>
-    void object::test<1>()
-    {
-        GEOSGeometry* g = GEOSGeomFromWKT("LINESTRING (3 8, -12 -4)");
+template<>
+template<>
+void object::test<1>
+()
+{
+    GEOSGeometry* g = GEOSGeomFromWKT("LINESTRING (3 8, -12 -4)");
 
-        double xmin, ymin, xmax, ymax;
+    double xmin, ymin, xmax, ymax;
 
-        ensure( GEOSGeom_getXMin(g, &xmin) );
-        ensure( GEOSGeom_getYMin(g, &ymin) );
-        ensure( GEOSGeom_getXMax(g, &xmax) );
-        ensure( GEOSGeom_getYMax(g, &ymax) );
+    ensure(GEOSGeom_getXMin(g, &xmin));
+    ensure(GEOSGeom_getYMin(g, &ymin));
+    ensure(GEOSGeom_getXMax(g, &xmax));
+    ensure(GEOSGeom_getYMax(g, &ymax));
 
-        ensure_equals(xmin, -12);
-        ensure_equals(xmax, 3);
-        ensure_equals(ymin, -4);
-        ensure_equals(ymax, 8);
+    ensure_equals(xmin, -12);
+    ensure_equals(xmax, 3);
+    ensure_equals(ymin, -4);
+    ensure_equals(ymax, 8);
 
-        GEOSGeom_destroy(g);
-    }
+    GEOSGeom_destroy(g);
+}
 
-    template<>
-    template<>
-    void object::test<2>()
-    {
-        GEOSGeometry* g = GEOSGeomFromWKT("POLYGON EMPTY");
+template<>
+template<>
+void object::test<2>
+()
+{
+    GEOSGeometry* g = GEOSGeomFromWKT("POLYGON EMPTY");
 
-        double d;
+    double d;
 
-        ensure_equals( GEOSGeom_getXMax(g, &d), 0 );
-        ensure_equals( GEOSGeom_getYMax(g, &d), 0 );
-        ensure_equals( GEOSGeom_getXMin(g, &d), 0 );
-        ensure_equals( GEOSGeom_getYMin(g, &d), 0 );
+    ensure_equals(GEOSGeom_getXMax(g, &d), 0);
+    ensure_equals(GEOSGeom_getYMax(g, &d), 0);
+    ensure_equals(GEOSGeom_getXMin(g, &d), 0);
+    ensure_equals(GEOSGeom_getYMin(g, &d), 0);
 
-        GEOSGeom_destroy(g);
-    }
+    GEOSGeom_destroy(g);
+}
 
 } // namespace tut
 
diff --git a/tests/unit/capi/GEOSGeom_extractUniquePointsTest.cpp b/tests/unit/capi/GEOSGeom_extractUniquePointsTest.cpp
index 2777cdb..e3bd6d7 100644
--- a/tests/unit/capi/GEOSGeom_extractUniquePointsTest.cpp
+++ b/tests/unit/capi/GEOSGeom_extractUniquePointsTest.cpp
@@ -9,93 +9,97 @@
 #include <cstdio>
 #include <cstdlib>
 
-namespace tut
-{
-    //
-    // Test Group
-    //
+namespace tut {
+//
+// Test Group
+//
 
-    // Common data used in test cases.
-    struct test_capigeosextractuniquepoints_data
-    {
-        GEOSGeometry* geom1_;
-        GEOSGeometry* geom2_;
-        GEOSGeometry* geom3_;
-        GEOSContextHandle_t handle_;
+// Common data used in test cases.
+struct test_capigeosextractuniquepoints_data {
+    GEOSGeometry* geom1_;
+    GEOSGeometry* geom2_;
+    GEOSGeometry* geom3_;
+    GEOSContextHandle_t handle_;
 
-        static void notice(const char *fmt, ...)
-        {
-            std::fprintf( stdout, "NOTICE: ");
+    static void
+    notice(const char* fmt, ...)
+    {
+        std::fprintf(stdout, "NOTICE: ");
 
-            va_list ap;
-            va_start(ap, fmt);
-            std::vfprintf(stdout, fmt, ap);
-            va_end(ap);
+        va_list ap;
+        va_start(ap, fmt);
+        std::vfprintf(stdout, fmt, ap);
+        va_end(ap);
 
-            std::fprintf(stdout, "\n");
-        }
+        std::fprintf(stdout, "\n");
+    }
 
-        test_capigeosextractuniquepoints_data()
-                : geom1_(nullptr), geom2_(nullptr), geom3_(nullptr)
-        {
-            handle_ = initGEOS_r(notice, notice);
-        }
+    test_capigeosextractuniquepoints_data()
+        : geom1_(nullptr), geom2_(nullptr), geom3_(nullptr)
+    {
+        handle_ = initGEOS_r(notice, notice);
+    }
 
-        ~test_capigeosextractuniquepoints_data()
-        {
-            GEOSGeom_destroy_r(handle_, geom1_);
-            GEOSGeom_destroy_r(handle_, geom2_);
-            if( geom3_ )
-                GEOSGeom_destroy_r(handle_, geom3_);
-
-            geom1_ = nullptr;
-            geom2_ = nullptr;
-            geom3_ = nullptr;
-            finishGEOS_r(handle_);
+    ~test_capigeosextractuniquepoints_data()
+    {
+        GEOSGeom_destroy_r(handle_, geom1_);
+        GEOSGeom_destroy_r(handle_, geom2_);
+        if(geom3_) {
+            GEOSGeom_destroy_r(handle_, geom3_);
         }
 
-    };
-
-    typedef test_group<test_capigeosextractuniquepoints_data> group;
-    typedef group::object object;
+        geom1_ = nullptr;
+        geom2_ = nullptr;
+        geom3_ = nullptr;
+        finishGEOS_r(handle_);
+    }
 
-    group test_capigeosextractuniquepoints_group("capi::GEOSGeom_extractUniquePoints");
+};
 
-    //
-    // Test Cases
-    //
+typedef test_group<test_capigeosextractuniquepoints_data> group;
+typedef group::object object;
 
-    template<>
-    template<>
-    void object::test<1>()
-    {
-        geom1_ = GEOSGeomFromWKT_r(handle_, "POLYGON EMPTY");
-        /* ensure_equals(GEOSGetNumGeometries_r(handle_, geom2_), 0); */
-        geom3_ = GEOSGeom_extractUniquePoints_r(handle_, geom1_);
-        ensure(0 != GEOSisEmpty_r(handle_, geom3_));
-    }
+group test_capigeosextractuniquepoints_group("capi::GEOSGeom_extractUniquePoints");
 
-    template<>
-    template<>
-    void object::test<2>()
-    {
-        geom1_ = GEOSGeomFromWKT_r(handle_, "MULTIPOINT(0 0, 0 0, 1 1)");
-        geom2_ = GEOSGeomFromWKT_r(handle_, "MULTIPOINT(0 0, 1 1)");
-        /* ensure_equals(GEOSGetNumGeometries_r(handle_, geom2_), 0); */
-        geom3_ = GEOSGeom_extractUniquePoints_r(handle_, geom1_);
-        ensure(0 != GEOSEquals_r(handle_, geom3_, geom2_));
-    }
+//
+// Test Cases
+//
 
-    template<>
-    template<>
-    void object::test<3>()
-    {
-        geom1_ = GEOSGeomFromWKT_r(handle_, "GEOMETRYCOLLECTION(MULTIPOINT(0 0, 0 0, 1 1),LINESTRING(1 1, 2 2, 2 2, 0 0),POLYGON((5 5, 0 0, 0 2, 2 2, 5 5)))");
-        geom2_ = GEOSGeomFromWKT_r(handle_, "MULTIPOINT(0 0, 1 1, 2 2, 5 5, 0 2)");
-        geom3_ = GEOSGeom_extractUniquePoints_r(handle_, geom1_);
-        /* ensure_equals(GEOSGetNumGeometries_r(handle_, geom2_), 0); */
-        ensure(0 != GEOSEquals_r(handle_, geom3_, geom2_));
-    }
+template<>
+template<>
+void object::test<1>
+()
+{
+    geom1_ = GEOSGeomFromWKT_r(handle_, "POLYGON EMPTY");
+    /* ensure_equals(GEOSGetNumGeometries_r(handle_, geom2_), 0); */
+    geom3_ = GEOSGeom_extractUniquePoints_r(handle_, geom1_);
+    ensure(0 != GEOSisEmpty_r(handle_, geom3_));
+}
+
+template<>
+template<>
+void object::test<2>
+()
+{
+    geom1_ = GEOSGeomFromWKT_r(handle_, "MULTIPOINT(0 0, 0 0, 1 1)");
+    geom2_ = GEOSGeomFromWKT_r(handle_, "MULTIPOINT(0 0, 1 1)");
+    /* ensure_equals(GEOSGetNumGeometries_r(handle_, geom2_), 0); */
+    geom3_ = GEOSGeom_extractUniquePoints_r(handle_, geom1_);
+    ensure(0 != GEOSEquals_r(handle_, geom3_, geom2_));
+}
+
+template<>
+template<>
+void object::test<3>
+()
+{
+    geom1_ = GEOSGeomFromWKT_r(handle_,
+                               "GEOMETRYCOLLECTION(MULTIPOINT(0 0, 0 0, 1 1),LINESTRING(1 1, 2 2, 2 2, 0 0),POLYGON((5 5, 0 0, 0 2, 2 2, 5 5)))");
+    geom2_ = GEOSGeomFromWKT_r(handle_, "MULTIPOINT(0 0, 1 1, 2 2, 5 5, 0 2)");
+    geom3_ = GEOSGeom_extractUniquePoints_r(handle_, geom1_);
+    /* ensure_equals(GEOSGetNumGeometries_r(handle_, geom2_), 0); */
+    ensure(0 != GEOSEquals_r(handle_, geom3_, geom2_));
+}
 
 
 } // namespace tut
diff --git a/tests/unit/capi/GEOSGeom_setPrecisionTest.cpp b/tests/unit/capi/GEOSGeom_setPrecisionTest.cpp
index 8b7a0a7..74082e0 100644
--- a/tests/unit/capi/GEOSGeom_setPrecisionTest.cpp
+++ b/tests/unit/capi/GEOSGeom_setPrecisionTest.cpp
@@ -9,178 +9,191 @@
 #include <cstdio>
 #include <cstdlib>
 
-namespace tut
-{
-    //
-    // Test Group
-    //
-
-    // Common data used in test cases.
-    struct test_capigeosgeomsetprecision_data
-    {
-        GEOSWKTWriter* wktw_;
-        GEOSGeometry* geom1_;
-        GEOSGeometry* geom2_;
-        GEOSGeometry* geom3_;
-
-        static void notice(const char *fmt, ...)
-        {
-            std::fprintf( stdout, "NOTICE: ");
-
-            va_list ap;
-            va_start(ap, fmt);
-            std::vfprintf(stdout, fmt, ap);
-            va_end(ap);
-
-            std::fprintf(stdout, "\n");
-        }
-
-        GEOSGeometry *fromWKT(const char *wkt)
-        {
-          GEOSGeometry *g = GEOSGeomFromWKT(wkt);
-          ensure(g);
-          return g;
-        }
-        std::string toWKT(GEOSGeometry* g)
-        {
-          char* wkt = GEOSWKTWriter_write(wktw_, g);
-          std::string ret (wkt);
-          GEOSFree(wkt);
-          return ret;
-        }
-
-        test_capigeosgeomsetprecision_data()
-                : geom1_(nullptr), geom2_(nullptr), geom3_(nullptr)
-        {
-            initGEOS(notice, notice);
-            wktw_ = GEOSWKTWriter_create();
-            GEOSWKTWriter_setTrim(wktw_, 1);
-            GEOSWKTWriter_setRoundingPrecision(wktw_, 10);
-            //GEOSWKTWriter_setOutputDimension(wktw_, 3);
-        }
-
-        ~test_capigeosgeomsetprecision_data()
-        {
-            GEOSGeom_destroy(geom1_);
-            GEOSGeom_destroy(geom2_);
-            if( geom3_ )
-                GEOSGeom_destroy(geom3_);
-            GEOSWKTWriter_destroy(wktw_);
-
-            geom1_ = nullptr;
-            geom2_ = nullptr;
-            geom3_ = nullptr;
-            finishGEOS();
-        }
-
-    };
+namespace tut {
+//
+// Test Group
+//
 
-    typedef test_group<test_capigeosgeomsetprecision_data> group;
-    typedef group::object object;
+// Common data used in test cases.
+struct test_capigeosgeomsetprecision_data {
+    GEOSWKTWriter* wktw_;
+    GEOSGeometry* geom1_;
+    GEOSGeometry* geom2_;
+    GEOSGeometry* geom3_;
 
-    group test_capigeosgeomsetprecision_group("capi::GEOSGeom_setPrecision");
+    static void
+    notice(const char* fmt, ...)
+    {
+        std::fprintf(stdout, "NOTICE: ");
 
-    //
-    // Test Cases
-    //
+        va_list ap;
+        va_start(ap, fmt);
+        std::vfprintf(stdout, fmt, ap);
+        va_end(ap);
 
-    template<>
-    template<>
-    void object::test<1>()
-    {
-        geom1_ = fromWKT("POLYGON EMPTY");
-        ensure(geom1_);
-        double scale = GEOSGeom_getPrecision(geom1_);
-        ensure_equals(scale, 0.0);
-        geom3_ = GEOSGeom_setPrecision(geom1_, 2.0, 0);
-        ensure(geom3_);
-        ensure_equals(toWKT(geom3_), std::string("POLYGON EMPTY"));
-        scale = GEOSGeom_getPrecision(geom3_);
-        ensure_equals(scale, 2.0);
+        std::fprintf(stdout, "\n");
     }
 
-    template<>
-    template<>
-    void object::test<2>()
+    GEOSGeometry*
+    fromWKT(const char* wkt)
     {
-        geom1_ = fromWKT("LINESTRING(-3 6, 9 1)");
-        ensure(geom1_);
-        geom3_ = GEOSGeom_setPrecision(geom1_, 2.0, 0);
-        ensure(geom3_);
-        ensure_equals(toWKT(geom3_), std::string("LINESTRING (-2 6, 10 2)"));
+        GEOSGeometry* g = GEOSGeomFromWKT(wkt);
+        ensure(g);
+        return g;
     }
-
-    // See effects of precision reduction on intersection operation
-    template<>
-    template<>
-    void object::test<3>()
+    std::string
+    toWKT(GEOSGeometry* g)
     {
-        geom1_ = fromWKT("LINESTRING(2 10, 4 30)");
-        ensure(geom1_);
-        geom2_ = fromWKT("LINESTRING(4 10, 2 30)");
-        ensure(geom2_);
-        geom3_ = GEOSIntersection(geom1_, geom2_);
-        ensure(geom3_);
-        ensure_equals(toWKT(geom3_), std::string("POINT (3 20)"));
-
-        GEOSGeometry* g;
-
-        // Both inputs with precision grid of 2.0
-        g = GEOSGeom_setPrecision(geom1_, 2.0, 0); ensure(g);
-        GEOSGeom_destroy(geom1_); geom1_ = g;
-        g = GEOSGeom_setPrecision(geom2_, 2.0, 0); ensure(g);
-        GEOSGeom_destroy(geom2_); geom2_ = g;
-        GEOSGeom_destroy(geom3_);
-        geom3_ = GEOSIntersection(geom1_, geom2_);
-        ensure(geom3_);
-        ensure_equals(toWKT(geom3_), std::string("POINT (4 20)"));
-
-        // One input with precision grid of 0.5, the other of 2.0
-        g = GEOSGeom_setPrecision(geom1_, 0.5, 0); ensure(g);
-        GEOSGeom_destroy(geom1_); geom1_ = g;
-        GEOSGeom_destroy(geom3_);
-        geom3_ = GEOSIntersection(geom1_, geom2_);
-        ensure(geom3_);
-        ensure_equals(toWKT(geom3_), std::string("POINT (3 20)"));
-        double scale = GEOSGeom_getPrecision(geom1_);
-        ensure_equals(scale, 0.5);
-        scale = GEOSGeom_getPrecision(geom2_);
-        ensure_equals(scale, 2.0);
+        char* wkt = GEOSWKTWriter_write(wktw_, g);
+        std::string ret(wkt);
+        GEOSFree(wkt);
+        return ret;
     }
 
-    // Retain (or not) topology
-    template<>
-    template<>
-    void object::test<4>()
+    test_capigeosgeomsetprecision_data()
+        : geom1_(nullptr), geom2_(nullptr), geom3_(nullptr)
     {
-        geom1_ = fromWKT("POLYGON((10 10,20 10,16 15,20 20, 10 20, 14 15, 10 10))");
-        ensure(geom1_);
-        geom2_ = GEOSGeom_setPrecision(geom1_, 5.0, 0);
-        ensure_equals(toWKT(geom2_), std::string(
-          "MULTIPOLYGON (((10 10, 15 15, 20 10, 10 10)), ((15 15, 10 20, 20 20, 15 15)))"
-        ));
-        geom3_ = GEOSGeom_setPrecision(geom1_, 5.0, GEOS_PREC_NO_TOPO);
-        ensure_equals(toWKT(geom3_), std::string(
-          "POLYGON ((10 10, 20 10, 15 15, 20 20, 10 20, 15 15, 10 10))"
-        ));
+        initGEOS(notice, notice);
+        wktw_ = GEOSWKTWriter_create();
+        GEOSWKTWriter_setTrim(wktw_, 1);
+        GEOSWKTWriter_setRoundingPrecision(wktw_, 10);
+        //GEOSWKTWriter_setOutputDimension(wktw_, 3);
     }
 
-    // Retain (or not) collapsed elements
-    template<>
-    template<>
-    void object::test<5>()
+    ~test_capigeosgeomsetprecision_data()
     {
-        geom1_ = fromWKT("LINESTRING(1 0, 2 0)");
-        ensure(geom1_);
-        geom2_ = GEOSGeom_setPrecision(geom1_, 5.0, 0);
-        ensure_equals(toWKT(geom2_), std::string(
-          "LINESTRING EMPTY"
-        ));
-        geom3_ = GEOSGeom_setPrecision(geom1_, 5.0, GEOS_PREC_KEEP_COLLAPSED);
-        ensure_equals(toWKT(geom3_), std::string(
-          "LINESTRING (0 0, 0 0)"
-        ));
+        GEOSGeom_destroy(geom1_);
+        GEOSGeom_destroy(geom2_);
+        if(geom3_) {
+            GEOSGeom_destroy(geom3_);
+        }
+        GEOSWKTWriter_destroy(wktw_);
+
+        geom1_ = nullptr;
+        geom2_ = nullptr;
+        geom3_ = nullptr;
+        finishGEOS();
     }
 
+};
+
+typedef test_group<test_capigeosgeomsetprecision_data> group;
+typedef group::object object;
+
+group test_capigeosgeomsetprecision_group("capi::GEOSGeom_setPrecision");
+
+//
+// Test Cases
+//
+
+template<>
+template<>
+void object::test<1>
+()
+{
+    geom1_ = fromWKT("POLYGON EMPTY");
+    ensure(geom1_);
+    double scale = GEOSGeom_getPrecision(geom1_);
+    ensure_equals(scale, 0.0);
+    geom3_ = GEOSGeom_setPrecision(geom1_, 2.0, 0);
+    ensure(geom3_);
+    ensure_equals(toWKT(geom3_), std::string("POLYGON EMPTY"));
+    scale = GEOSGeom_getPrecision(geom3_);
+    ensure_equals(scale, 2.0);
+}
+
+template<>
+template<>
+void object::test<2>
+()
+{
+    geom1_ = fromWKT("LINESTRING(-3 6, 9 1)");
+    ensure(geom1_);
+    geom3_ = GEOSGeom_setPrecision(geom1_, 2.0, 0);
+    ensure(geom3_);
+    ensure_equals(toWKT(geom3_), std::string("LINESTRING (-2 6, 10 2)"));
+}
+
+// See effects of precision reduction on intersection operation
+template<>
+template<>
+void object::test<3>
+()
+{
+    geom1_ = fromWKT("LINESTRING(2 10, 4 30)");
+    ensure(geom1_);
+    geom2_ = fromWKT("LINESTRING(4 10, 2 30)");
+    ensure(geom2_);
+    geom3_ = GEOSIntersection(geom1_, geom2_);
+    ensure(geom3_);
+    ensure_equals(toWKT(geom3_), std::string("POINT (3 20)"));
+
+    GEOSGeometry* g;
+
+    // Both inputs with precision grid of 2.0
+    g = GEOSGeom_setPrecision(geom1_, 2.0, 0);
+    ensure(g);
+    GEOSGeom_destroy(geom1_);
+    geom1_ = g;
+    g = GEOSGeom_setPrecision(geom2_, 2.0, 0);
+    ensure(g);
+    GEOSGeom_destroy(geom2_);
+    geom2_ = g;
+    GEOSGeom_destroy(geom3_);
+    geom3_ = GEOSIntersection(geom1_, geom2_);
+    ensure(geom3_);
+    ensure_equals(toWKT(geom3_), std::string("POINT (4 20)"));
+
+    // One input with precision grid of 0.5, the other of 2.0
+    g = GEOSGeom_setPrecision(geom1_, 0.5, 0);
+    ensure(g);
+    GEOSGeom_destroy(geom1_);
+    geom1_ = g;
+    GEOSGeom_destroy(geom3_);
+    geom3_ = GEOSIntersection(geom1_, geom2_);
+    ensure(geom3_);
+    ensure_equals(toWKT(geom3_), std::string("POINT (3 20)"));
+    double scale = GEOSGeom_getPrecision(geom1_);
+    ensure_equals(scale, 0.5);
+    scale = GEOSGeom_getPrecision(geom2_);
+    ensure_equals(scale, 2.0);
+}
+
+// Retain (or not) topology
+template<>
+template<>
+void object::test<4>
+()
+{
+    geom1_ = fromWKT("POLYGON((10 10,20 10,16 15,20 20, 10 20, 14 15, 10 10))");
+    ensure(geom1_);
+    geom2_ = GEOSGeom_setPrecision(geom1_, 5.0, 0);
+    ensure_equals(toWKT(geom2_), std::string(
+                      "MULTIPOLYGON (((10 10, 15 15, 20 10, 10 10)), ((15 15, 10 20, 20 20, 15 15)))"
+                  ));
+    geom3_ = GEOSGeom_setPrecision(geom1_, 5.0, GEOS_PREC_NO_TOPO);
+    ensure_equals(toWKT(geom3_), std::string(
+                      "POLYGON ((10 10, 20 10, 15 15, 20 20, 10 20, 15 15, 10 10))"
+                  ));
+}
+
+// Retain (or not) collapsed elements
+template<>
+template<>
+void object::test<5>
+()
+{
+    geom1_ = fromWKT("LINESTRING(1 0, 2 0)");
+    ensure(geom1_);
+    geom2_ = GEOSGeom_setPrecision(geom1_, 5.0, 0);
+    ensure_equals(toWKT(geom2_), std::string(
+                      "LINESTRING EMPTY"
+                  ));
+    geom3_ = GEOSGeom_setPrecision(geom1_, 5.0, GEOS_PREC_KEEP_COLLAPSED);
+    ensure_equals(toWKT(geom3_), std::string(
+                      "LINESTRING (0 0, 0 0)"
+                  ));
+}
+
 } // namespace tut
 
diff --git a/tests/unit/capi/GEOSGetCentroidTest.cpp b/tests/unit/capi/GEOSGetCentroidTest.cpp
index 9dd2cd9..72989ce 100644
--- a/tests/unit/capi/GEOSGetCentroidTest.cpp
+++ b/tests/unit/capi/GEOSGetCentroidTest.cpp
@@ -11,164 +11,168 @@
 #include <cstdlib>
 #include <cstring>
 
-namespace tut
-{
-    //
-    // Test Group
-    //
+namespace tut {
+//
+// Test Group
+//
 
-    // Common data used in test cases.
-    struct test_capicentroid_data
+// Common data used in test cases.
+struct test_capicentroid_data {
+    GEOSGeometry* geom1_;
+    GEOSGeometry* geom2_;
+    GEOSWKTWriter* wktw_;
+    char* wkt_;
+    double area_;
+
+    static void
+    notice(const char* fmt, ...)
     {
-        GEOSGeometry* geom1_;
-        GEOSGeometry* geom2_;
-        GEOSWKTWriter* wktw_;
-        char* wkt_;
-        double area_;
-
-        static void notice(const char *fmt, ...)
-        {
-            std::fprintf( stdout, "NOTICE: ");
-
-            va_list ap;
-            va_start(ap, fmt);
-            std::vfprintf(stdout, fmt, ap);
-            va_end(ap);
-
-            std::fprintf(stdout, "\n");
-        }
-
-        test_capicentroid_data()
-            : geom1_(nullptr), geom2_(nullptr), wkt_(nullptr)
-        {
-            initGEOS(notice, notice);
-            wktw_ = GEOSWKTWriter_create();
-            GEOSWKTWriter_setTrim(wktw_, 1);
-            GEOSWKTWriter_setRoundingPrecision(wktw_, 8);
-        }
-
-        ~test_capicentroid_data()
-        {
-            GEOSGeom_destroy(geom1_);
-            GEOSGeom_destroy(geom2_);
-            GEOSWKTWriter_destroy(wktw_);
-            GEOSFree(wkt_);
-            geom1_ = nullptr;
-            geom2_ = nullptr;
-            wkt_ = nullptr;
-            finishGEOS();
-        }
-
-    };
-
-    typedef test_group<test_capicentroid_data> group;
-    typedef group::object object;
-
-    group test_capicentroid_group("capi::GEOSGetCentroid");
-
-    //
-    // Test Cases
-    //
-
-    // Single point
-    template<>
-    template<>
-    void object::test<1>()
+        std::fprintf(stdout, "NOTICE: ");
+
+        va_list ap;
+        va_start(ap, fmt);
+        std::vfprintf(stdout, fmt, ap);
+        va_end(ap);
+
+        std::fprintf(stdout, "\n");
+    }
+
+    test_capicentroid_data()
+        : geom1_(nullptr), geom2_(nullptr), wkt_(nullptr)
     {
-        geom1_ = GEOSGeomFromWKT("POINT(10 0)");
+        initGEOS(notice, notice);
+        wktw_ = GEOSWKTWriter_create();
+        GEOSWKTWriter_setTrim(wktw_, 1);
+        GEOSWKTWriter_setRoundingPrecision(wktw_, 8);
+    }
 
-        ensure( nullptr != geom1_ );
+    ~test_capicentroid_data()
+    {
+        GEOSGeom_destroy(geom1_);
+        GEOSGeom_destroy(geom2_);
+        GEOSWKTWriter_destroy(wktw_);
+        GEOSFree(wkt_);
+        geom1_ = nullptr;
+        geom2_ = nullptr;
+        wkt_ = nullptr;
+        finishGEOS();
+    }
 
-        geom2_ = GEOSGetCentroid(geom1_);
+};
 
-        ensure( nullptr != geom2_ );
+typedef test_group<test_capicentroid_data> group;
+typedef group::object object;
 
-        wkt_ = GEOSWKTWriter_write(wktw_, geom2_);
+group test_capicentroid_group("capi::GEOSGetCentroid");
 
-        ensure_equals(std::string(wkt_), std::string( "POINT (10 0)"));
+//
+// Test Cases
+//
 
-    }
+// Single point
+template<>
+template<>
+void object::test<1>
+()
+{
+    geom1_ = GEOSGeomFromWKT("POINT(10 0)");
 
-    // line
-    template<>
-    template<>
-    void object::test<2>()
-    {
-        geom1_ = GEOSGeomFromWKT("LINESTRING(0 0, 10 0)");
+    ensure(nullptr != geom1_);
 
-        ensure( nullptr != geom1_ );
+    geom2_ = GEOSGetCentroid(geom1_);
 
-        geom2_ = GEOSGetCentroid(geom1_);
+    ensure(nullptr != geom2_);
 
-        ensure( nullptr != geom2_ );
+    wkt_ = GEOSWKTWriter_write(wktw_, geom2_);
 
-        wkt_ = GEOSWKTWriter_write(wktw_, geom2_);
+    ensure_equals(std::string(wkt_), std::string("POINT (10 0)"));
 
-        ensure_equals(std::string(wkt_), std::string( "POINT (5 0)"));
+}
 
-    }
+// line
+template<>
+template<>
+void object::test<2>
+()
+{
+    geom1_ = GEOSGeomFromWKT("LINESTRING(0 0, 10 0)");
 
-    // polygon
-    template<>
-    template<>
-    void object::test<3>()
-    {
-        geom1_ = GEOSGeomFromWKT("POLYGON((0 0, 10 0, 10 10, 0 10, 0 0))");
+    ensure(nullptr != geom1_);
 
-        ensure( nullptr != geom1_ );
+    geom2_ = GEOSGetCentroid(geom1_);
 
-        geom2_ = GEOSGetCentroid(geom1_);
+    ensure(nullptr != geom2_);
 
-        ensure( nullptr != geom2_ );
+    wkt_ = GEOSWKTWriter_write(wktw_, geom2_);
 
-        wkt_ = GEOSWKTWriter_write(wktw_, geom2_);
+    ensure_equals(std::string(wkt_), std::string("POINT (5 0)"));
 
-        ensure_equals(std::string(wkt_), std::string( "POINT (5 5)"));
+}
 
-    }
+// polygon
+template<>
+template<>
+void object::test<3>
+()
+{
+    geom1_ = GEOSGeomFromWKT("POLYGON((0 0, 10 0, 10 10, 0 10, 0 0))");
 
-    // Tiny triangle, see http://trac.osgeo.org/geos/ticket/559
-    template<>
-    template<>
-    void object::test<4>()
-    {
-        geom1_ = GEOSGeomFromWKT(
-"POLYGON(( \
+    ensure(nullptr != geom1_);
+
+    geom2_ = GEOSGetCentroid(geom1_);
+
+    ensure(nullptr != geom2_);
+
+    wkt_ = GEOSWKTWriter_write(wktw_, geom2_);
+
+    ensure_equals(std::string(wkt_), std::string("POINT (5 5)"));
+
+}
+
+// Tiny triangle, see http://trac.osgeo.org/geos/ticket/559
+template<>
+template<>
+void object::test<4>
+()
+{
+    geom1_ = GEOSGeomFromWKT(
+                 "POLYGON(( \
 56.528666666700 25.2101666667, \
 56.529000000000 25.2105000000, \
 56.528833333300 25.2103333333, \
 56.528666666700 25.2101666667))");
 
-        ensure( nullptr != geom1_ );
+    ensure(nullptr != geom1_);
 
-        geom2_ = GEOSGetCentroid(geom1_);
+    geom2_ = GEOSGetCentroid(geom1_);
 
-        ensure( nullptr != geom2_ );
+    ensure(nullptr != geom2_);
 
-        wkt_ = GEOSWKTWriter_write(wktw_, geom2_);
+    wkt_ = GEOSWKTWriter_write(wktw_, geom2_);
 
-        ensure_equals(std::string(wkt_), std::string( "POINT (56.528833 25.210333)" ) );
+    ensure_equals(std::string(wkt_), std::string("POINT (56.528833 25.210333)"));
 
-    }
+}
 
-    // Empty geometry -- see http://trac.osgeo.org/geos/ticket/560
-    template<>
-    template<>
-    void object::test<5>()
-    {
-        geom1_ = GEOSGeomFromWKT("LINESTRING EMPTY");
+// Empty geometry -- see http://trac.osgeo.org/geos/ticket/560
+template<>
+template<>
+void object::test<5>
+()
+{
+    geom1_ = GEOSGeomFromWKT("LINESTRING EMPTY");
 
-        ensure( nullptr != geom1_ );
+    ensure(nullptr != geom1_);
 
-        geom2_ = GEOSGetCentroid(geom1_);
+    geom2_ = GEOSGetCentroid(geom1_);
 
-        ensure( nullptr != geom2_ );
+    ensure(nullptr != geom2_);
 
-        wkt_ = GEOSWKTWriter_write(wktw_, geom2_);
+    wkt_ = GEOSWKTWriter_write(wktw_, geom2_);
 
-        ensure_equals(std::string(wkt_), std::string( "POINT EMPTY"));
+    ensure_equals(std::string(wkt_), std::string("POINT EMPTY"));
 
-    }
+}
 
 } // namespace tut
 
diff --git a/tests/unit/capi/GEOSHausdorffDistanceTest.cpp b/tests/unit/capi/GEOSHausdorffDistanceTest.cpp
index fbc9bd9..19b7d2a 100644
--- a/tests/unit/capi/GEOSHausdorffDistanceTest.cpp
+++ b/tests/unit/capi/GEOSHausdorffDistanceTest.cpp
@@ -11,89 +11,90 @@
 #include <memory>
 #include <math.h>
 
-namespace tut
-{
-    //
-    // Test Group
-    //
+namespace tut {
+//
+// Test Group
+//
 
-    // Common data used in test cases.
-    struct test_capigeoshausdorffdistance_data
-    {
-        GEOSGeometry* geom1_;
-        GEOSGeometry* geom2_;
-        GEOSGeometry* geom3_;
-        GEOSWKTWriter* w_;
-
-        static void notice(const char *fmt, ...)
-        {
-            std::fprintf( stdout, "NOTICE: ");
-
-            va_list ap;
-            va_start(ap, fmt);
-            std::vfprintf(stdout, fmt, ap);
-            va_end(ap);
-
-            std::fprintf(stdout, "\n");
-        }
-
-        test_capigeoshausdorffdistance_data()
-            : geom1_(nullptr), geom2_(nullptr), geom3_(nullptr), w_(nullptr)
-        {
-            initGEOS(notice, notice);
-            w_ = GEOSWKTWriter_create();
-            GEOSWKTWriter_setTrim(w_, 1);
-        }
-
-        ~test_capigeoshausdorffdistance_data()
-        {
-            GEOSGeom_destroy(geom1_);
-            GEOSGeom_destroy(geom2_);
-            GEOSGeom_destroy(geom3_);
-            GEOSWKTWriter_destroy(w_);
-            geom1_ = nullptr;
-            geom2_ = nullptr;
-            geom3_ = nullptr;
-            finishGEOS();
-        }
-
-    };
-
-    typedef test_group<test_capigeoshausdorffdistance_data> group;
-    typedef group::object object;
-
-    group test_capigeoshausdorffdistance_group("capi::GEOSHausdorffDistance");
-
-    //
-    // Test Cases
-    //
-
-    template<>
-    template<>
-    void object::test<1>()
+// Common data used in test cases.
+struct test_capigeoshausdorffdistance_data {
+    GEOSGeometry* geom1_;
+    GEOSGeometry* geom2_;
+    GEOSGeometry* geom3_;
+    GEOSWKTWriter* w_;
+
+    static void
+    notice(const char* fmt, ...)
     {
-        geom1_ = GEOSGeomFromWKT("LINESTRING (130 0, 0 0, 0 150)");
-        geom2_ = GEOSGeomFromWKT("LINESTRING (10 10, 10 150, 130 10)");
+        std::fprintf(stdout, "NOTICE: ");
 
-        double dist;
-        int ret = GEOSHausdorffDistance(geom1_, geom2_, &dist);
+        va_list ap;
+        va_start(ap, fmt);
+        std::vfprintf(stdout, fmt, ap);
+        va_end(ap);
 
-        ensure_equals(ret, 1);
-        ensure_distance(dist, 14.142135623730951, 1e-12);
+        std::fprintf(stdout, "\n");
     }
 
-    template<>
-    template<>
-    void object::test<2>()
+    test_capigeoshausdorffdistance_data()
+        : geom1_(nullptr), geom2_(nullptr), geom3_(nullptr), w_(nullptr)
     {
-        geom1_ = GEOSGeomFromWKT("LINESTRING (130 0, 0 0, 0 150)");
-        geom2_ = GEOSGeomFromWKT("LINESTRING (10 10, 10 150, 130 10)");
-
-        double dist;
-        int ret = GEOSHausdorffDistanceDensify(geom1_, geom2_, 0.5, &dist);
+        initGEOS(notice, notice);
+        w_ = GEOSWKTWriter_create();
+        GEOSWKTWriter_setTrim(w_, 1);
+    }
 
-        ensure_equals(ret, 1);
-        ensure_distance(dist, 70., 1e-12);
+    ~test_capigeoshausdorffdistance_data()
+    {
+        GEOSGeom_destroy(geom1_);
+        GEOSGeom_destroy(geom2_);
+        GEOSGeom_destroy(geom3_);
+        GEOSWKTWriter_destroy(w_);
+        geom1_ = nullptr;
+        geom2_ = nullptr;
+        geom3_ = nullptr;
+        finishGEOS();
     }
 
+};
+
+typedef test_group<test_capigeoshausdorffdistance_data> group;
+typedef group::object object;
+
+group test_capigeoshausdorffdistance_group("capi::GEOSHausdorffDistance");
+
+//
+// Test Cases
+//
+
+template<>
+template<>
+void object::test<1>
+()
+{
+    geom1_ = GEOSGeomFromWKT("LINESTRING (130 0, 0 0, 0 150)");
+    geom2_ = GEOSGeomFromWKT("LINESTRING (10 10, 10 150, 130 10)");
+
+    double dist;
+    int ret = GEOSHausdorffDistance(geom1_, geom2_, &dist);
+
+    ensure_equals(ret, 1);
+    ensure_distance(dist, 14.142135623730951, 1e-12);
+}
+
+template<>
+template<>
+void object::test<2>
+()
+{
+    geom1_ = GEOSGeomFromWKT("LINESTRING (130 0, 0 0, 0 150)");
+    geom2_ = GEOSGeomFromWKT("LINESTRING (10 10, 10 150, 130 10)");
+
+    double dist;
+    int ret = GEOSHausdorffDistanceDensify(geom1_, geom2_, 0.5, &dist);
+
+    ensure_equals(ret, 1);
+    ensure_distance(dist, 70., 1e-12);
+}
+
 } // namespace tut
diff --git a/tests/unit/capi/GEOSInterpolateTest.cpp b/tests/unit/capi/GEOSInterpolateTest.cpp
index b5cacc2..c51c905 100644
--- a/tests/unit/capi/GEOSInterpolateTest.cpp
+++ b/tests/unit/capi/GEOSInterpolateTest.cpp
@@ -9,60 +9,60 @@
 #include <cstdlib>
 #include <cmath>
 
-namespace tut
-{
-    //
-    // Test Group
-    //
+namespace tut {
+//
+// Test Group
+//
 
-    // Common data used in test cases.
-    struct test_capiinterpolate_data
-    {
-        GEOSGeometry* geom1_;
+// Common data used in test cases.
+struct test_capiinterpolate_data {
+    GEOSGeometry* geom1_;
 
-        static void notice(const char *fmt, ...)
-        {
-            std::fprintf( stdout, "NOTICE: ");
+    static void
+    notice(const char* fmt, ...)
+    {
+        std::fprintf(stdout, "NOTICE: ");
 
-            va_list ap;
-            va_start(ap, fmt);
-            std::vfprintf(stdout, fmt, ap);
-            va_end(ap);
+        va_list ap;
+        va_start(ap, fmt);
+        std::vfprintf(stdout, fmt, ap);
+        va_end(ap);
 
-            std::fprintf(stdout, "\n");
-        }
+        std::fprintf(stdout, "\n");
+    }
 
-        test_capiinterpolate_data()
-            : geom1_(nullptr)
-        {
-            initGEOS(notice, notice);
-        }
+    test_capiinterpolate_data()
+        : geom1_(nullptr)
+    {
+        initGEOS(notice, notice);
+    }
 
-        ~test_capiinterpolate_data()
-        {
-            GEOSGeom_destroy(geom1_);
-            geom1_ = nullptr;
-            finishGEOS();
-        }
+    ~test_capiinterpolate_data()
+    {
+        GEOSGeom_destroy(geom1_);
+        geom1_ = nullptr;
+        finishGEOS();
+    }
 
-    };
+};
 
-    typedef test_group<test_capiinterpolate_data> group;
-    typedef group::object object;
+typedef test_group<test_capiinterpolate_data> group;
+typedef group::object object;
 
-    group test_capiinterpolate_group("capi::GEOSInterpolate");
+group test_capiinterpolate_group("capi::GEOSInterpolate");
 
-    //
-    // Test Cases
-    //
+//
+// Test Cases
+//
 
-    template<>
-    template<>
-    void object::test<1>()
-    {
-        geom1_ = GEOSGeomFromWKT("LINESTRING EMPTY");
-        GEOSGeometry *geom2 = GEOSInterpolate(geom1_, 1);
-        ensure_equals(GEOSisEmpty(geom2), 1);
-        GEOSGeom_destroy(geom2);
-    }
+template<>
+template<>
+void object::test<1>
+()
+{
+    geom1_ = GEOSGeomFromWKT("LINESTRING EMPTY");
+    GEOSGeometry* geom2 = GEOSInterpolate(geom1_, 1);
+    ensure_equals(GEOSisEmpty(geom2), 1);
+    GEOSGeom_destroy(geom2);
+}
 } // namespace tut
diff --git a/tests/unit/capi/GEOSInterruptTest.cpp b/tests/unit/capi/GEOSInterruptTest.cpp
index a38253e..0bd0301 100644
--- a/tests/unit/capi/GEOSInterruptTest.cpp
+++ b/tests/unit/capi/GEOSInterruptTest.cpp
@@ -10,207 +10,215 @@
 #include <cstdlib>
 #include <memory>
 
-namespace tut
-{
-    //
-    // Test Group
-    //
+namespace tut {
+//
+// Test Group
+//
 
-    // Common data used in test cases.
-    struct test_capiinterrupt_data
-    {
-        static int numcalls;
-        static GEOSInterruptCallback* nextcb;
+// Common data used in test cases.
+struct test_capiinterrupt_data {
+    static int numcalls;
+    static GEOSInterruptCallback* nextcb;
 
-        static void notice(const char *fmt, ...)
-        {
-            std::fprintf( stdout, "NOTICE: ");
+    static void
+    notice(const char* fmt, ...)
+    {
+        std::fprintf(stdout, "NOTICE: ");
 
-            va_list ap;
-            va_start(ap, fmt);
-            std::vfprintf(stdout, fmt, ap);
-            va_end(ap);
+        va_list ap;
+        va_start(ap, fmt);
+        std::vfprintf(stdout, fmt, ap);
+        va_end(ap);
 
-            std::fprintf(stdout, "\n");
-        }
+        std::fprintf(stdout, "\n");
+    }
 
-        test_capiinterrupt_data()
-        {
-        }
+    test_capiinterrupt_data()
+    {
+    }
 
-        ~test_capiinterrupt_data()
-        {
-        }
+    ~test_capiinterrupt_data()
+    {
+    }
 
-        static void interruptNow()
-        {
-          GEOS_interruptRequest();
-        }
+    static void
+    interruptNow()
+    {
+        GEOS_interruptRequest();
+    }
 
-        static void countCalls()
-        {
-          ++numcalls;
-          if ( nextcb ) (*nextcb)();
+    static void
+    countCalls()
+    {
+        ++numcalls;
+        if(nextcb) {
+            (*nextcb)();
         }
+    }
 
-    };
+};
 
-    int test_capiinterrupt_data::numcalls = 0;
-    GEOSInterruptCallback* test_capiinterrupt_data::nextcb = nullptr;
+int test_capiinterrupt_data::numcalls = 0;
+GEOSInterruptCallback* test_capiinterrupt_data::nextcb = nullptr;
 
-    typedef test_group<test_capiinterrupt_data> group;
-    typedef group::object object;
+typedef test_group<test_capiinterrupt_data> group;
+typedef group::object object;
 
-    group test_capiinterrupt_group("capi::GEOSInterrupt");
+group test_capiinterrupt_group("capi::GEOSInterrupt");
 
-    //
-    // Test Cases
-    //
+//
+// Test Cases
+//
 
-    /// Test interrupt callback being called
-    template<>
-    template<>
-    void object::test<1>()
-    {
-        numcalls = 0;
+/// Test interrupt callback being called
+template<>
+template<>
+void object::test<1>
+()
+{
+    numcalls = 0;
 
-        initGEOS(notice, notice);
+    initGEOS(notice, notice);
 
-        GEOS_interruptRegisterCallback(countCalls);
+    GEOS_interruptRegisterCallback(countCalls);
 
-        ensure_equals(numcalls, 0);
+    ensure_equals(numcalls, 0);
 
-        GEOSGeometry *geom1 = GEOSGeomFromWKT("LINESTRING(0 0, 1 0)");
+    GEOSGeometry* geom1 = GEOSGeomFromWKT("LINESTRING(0 0, 1 0)");
 
-        ensure("GEOSGeomFromWKT failed", nullptr != geom1);
+    ensure("GEOSGeomFromWKT failed", nullptr != geom1);
 
-        GEOSGeometry *geom2 = GEOSBuffer(geom1, 1, 8);
+    GEOSGeometry* geom2 = GEOSBuffer(geom1, 1, 8);
 
-        ensure("GEOSBufferWithStyle failed", nullptr != geom2);
+    ensure("GEOSBufferWithStyle failed", nullptr != geom2);
 
-        ensure("interrupt callback never called", numcalls > 0);
+    ensure("interrupt callback never called", numcalls > 0);
 
-        GEOSGeom_destroy(geom1);
-        GEOSGeom_destroy(geom2);
+    GEOSGeom_destroy(geom1);
+    GEOSGeom_destroy(geom2);
 
-        GEOS_interruptRegisterCallback(nullptr); /* unregister */
+    GEOS_interruptRegisterCallback(nullptr); /* unregister */
 
 
-        finishGEOS();
-    }
+    finishGEOS();
+}
 
-    /// Test interrupt callback being called XXX
-    template<>
-    template<>
-    void object::test<2>()
-    {
-        numcalls = 0;
+/// Test interrupt callback being called XXX
+template<>
+template<>
+void object::test<2>
+()
+{
+    numcalls = 0;
 
-        initGEOS(notice, notice);
+    initGEOS(notice, notice);
 
-        GEOS_interruptRegisterCallback(countCalls);
+    GEOS_interruptRegisterCallback(countCalls);
 
-        ensure_equals(numcalls, 0);
+    ensure_equals(numcalls, 0);
 
-        GEOSGeometry *geom1 = GEOSGeomFromWKT("LINESTRING(0 0, 1 1, 2 2, 4 4)");
-        GEOSGeometry *geom2 = GEOSGeomFromWKT("LINESTRING(0 0, 1 1.01, 4 4.001)");
+    GEOSGeometry* geom1 = GEOSGeomFromWKT("LINESTRING(0 0, 1 1, 2 2, 4 4)");
+    GEOSGeometry* geom2 = GEOSGeomFromWKT("LINESTRING(0 0, 1 1.01, 4 4.001)");
 
-        ensure("GEOSGeomFromWKT failed", nullptr != geom1);
+    ensure("GEOSGeomFromWKT failed", nullptr != geom1);
 
-		GEOSGeometry *geom3 = GEOSSnap(geom1, geom2, 0.1);
+    GEOSGeometry* geom3 = GEOSSnap(geom1, geom2, 0.1);
 
-        ensure("GEOSSnap failed", nullptr != geom3);
+    ensure("GEOSSnap failed", nullptr != geom3);
 
-        ensure("interrupt callback never called", numcalls > 0);
+    ensure("interrupt callback never called", numcalls > 0);
 
-        GEOSGeom_destroy(geom1);
-        GEOSGeom_destroy(geom2);
-        GEOSGeom_destroy(geom3);
+    GEOSGeom_destroy(geom1);
+    GEOSGeom_destroy(geom2);
+    GEOSGeom_destroy(geom3);
 
-        GEOS_interruptRegisterCallback(nullptr); /* unregister */
+    GEOS_interruptRegisterCallback(nullptr); /* unregister */
 
-        finishGEOS();
-    }
+    finishGEOS();
+}
 
-    /// Test interrupt callback being NOT reset by initGEOS
-    template<>
-    template<>
-    void object::test<3>()
-    {
-        numcalls = 0;
+/// Test interrupt callback being NOT reset by initGEOS
+template<>
+template<>
+void object::test<3>
+()
+{
+    numcalls = 0;
 
-        GEOS_interruptRegisterCallback(countCalls);
+    GEOS_interruptRegisterCallback(countCalls);
 
-        initGEOS(notice, notice);
+    initGEOS(notice, notice);
 
-        ensure_equals(numcalls, 0);
+    ensure_equals(numcalls, 0);
 
-        GEOSGeometry *geom1 = GEOSGeomFromWKT("LINESTRING(0 0, 1 0)");
+    GEOSGeometry* geom1 = GEOSGeomFromWKT("LINESTRING(0 0, 1 0)");
 
-        ensure("GEOSGeomFromWKT failed", nullptr != geom1);
+    ensure("GEOSGeomFromWKT failed", nullptr != geom1);
 
-        GEOSGeometry *geom2 = GEOSBuffer(geom1, 1, 8);
+    GEOSGeometry* geom2 = GEOSBuffer(geom1, 1, 8);
 
-        ensure("GEOSBufferWithStyle failed", nullptr != geom2);
+    ensure("GEOSBufferWithStyle failed", nullptr != geom2);
 
-        ensure("interrupt callback never called", numcalls > 0);
+    ensure("interrupt callback never called", numcalls > 0);
 
-        GEOSGeom_destroy(geom1);
-        GEOSGeom_destroy(geom2);
+    GEOSGeom_destroy(geom1);
+    GEOSGeom_destroy(geom2);
 
-        GEOS_interruptRegisterCallback(nullptr);
+    GEOS_interruptRegisterCallback(nullptr);
 
-        finishGEOS();
-    }
+    finishGEOS();
+}
 
-    /// Test interrupting from callback
-    template<>
-    template<>
-    void object::test<4>()
-    {
-        initGEOS(notice, notice);
+/// Test interrupting from callback
+template<>
+template<>
+void object::test<4>
+()
+{
+    initGEOS(notice, notice);
 
-        GEOSGeometry *geom1 = GEOSGeomFromWKT("LINESTRING(0 0, 1 0)");
+    GEOSGeometry* geom1 = GEOSGeomFromWKT("LINESTRING(0 0, 1 0)");
 
-        ensure("GEOSGeomFromWKT failed", nullptr != geom1);
+    ensure("GEOSGeomFromWKT failed", nullptr != geom1);
 
-        GEOS_interruptRegisterCallback(interruptNow);
-        GEOSGeometry *geom2 = GEOSBuffer(geom1, 1, 8);
-        ensure("GEOSBuffer wasn't interrupted", nullptr == geom2);
-        GEOS_interruptRegisterCallback(nullptr);  /* unregister */
+    GEOS_interruptRegisterCallback(interruptNow);
+    GEOSGeometry* geom2 = GEOSBuffer(geom1, 1, 8);
+    ensure("GEOSBuffer wasn't interrupted", nullptr == geom2);
+    GEOS_interruptRegisterCallback(nullptr);  /* unregister */
 
-        // TODO: check the actual exception ? (sent to notice() callback)
+    // TODO: check the actual exception ? (sent to notice() callback)
 
-        GEOSGeom_destroy(geom1);
+    GEOSGeom_destroy(geom1);
 
-        finishGEOS();
-    }
+    finishGEOS();
+}
 
-    /// Test chaining interrupt callbacks
-    template<>
-    template<>
-    void object::test<5>()
-    {
-        numcalls = 0;
+/// Test chaining interrupt callbacks
+template<>
+template<>
+void object::test<5>
+()
+{
+    numcalls = 0;
 
-        initGEOS(notice, notice);
+    initGEOS(notice, notice);
 
-        GEOSGeometry *geom1 = GEOSGeomFromWKT("LINESTRING(0 0, 1 0)");
+    GEOSGeometry* geom1 = GEOSGeomFromWKT("LINESTRING(0 0, 1 0)");
 
-        ensure("GEOSGeomFromWKT failed", nullptr != geom1);
+    ensure("GEOSGeomFromWKT failed", nullptr != geom1);
 
-        GEOS_interruptRegisterCallback(interruptNow);
-        nextcb = GEOS_interruptRegisterCallback(countCalls);
-        GEOSGeometry *geom2 = GEOSBuffer(geom1, 1, 8);
-        ensure("GEOSBuffer wasn't interrupted", nullptr == geom2);
-        ensure_equals(numcalls, 1);
-        GEOS_interruptRegisterCallback(nullptr);  /* unregister */
-        nextcb = nullptr;
+    GEOS_interruptRegisterCallback(interruptNow);
+    nextcb = GEOS_interruptRegisterCallback(countCalls);
+    GEOSGeometry* geom2 = GEOSBuffer(geom1, 1, 8);
+    ensure("GEOSBuffer wasn't interrupted", nullptr == geom2);
+    ensure_equals(numcalls, 1);
+    GEOS_interruptRegisterCallback(nullptr);  /* unregister */
+    nextcb = nullptr;
 
-        GEOSGeom_destroy(geom1);
+    GEOSGeom_destroy(geom1);
 
-        finishGEOS();
-    }
+    finishGEOS();
+}
 
 
 } // namespace tut
diff --git a/tests/unit/capi/GEOSIntersectionTest.cpp b/tests/unit/capi/GEOSIntersectionTest.cpp
index 6c51ab2..48a4c9a 100644
--- a/tests/unit/capi/GEOSIntersectionTest.cpp
+++ b/tests/unit/capi/GEOSIntersectionTest.cpp
@@ -9,134 +9,139 @@
 #include <cstdio>
 #include <cstdlib>
 
-namespace tut
+namespace tut {
+//
+// Test Group
+//
+
+// Common data used in test cases.
+struct test_capigeosintersection_data {
+    GEOSWKTWriter* wktw_;
+    GEOSGeometry* geom1_;
+    GEOSGeometry* geom2_;
+    GEOSGeometry* geom3_;
+
+    static void
+    notice(const char* fmt, ...)
+    {
+        std::fprintf(stdout, "NOTICE: ");
+
+        va_list ap;
+        va_start(ap, fmt);
+        std::vfprintf(stdout, fmt, ap);
+        va_end(ap);
+
+        std::fprintf(stdout, "\n");
+    }
+
+    test_capigeosintersection_data()
+        : geom1_(nullptr), geom2_(nullptr), geom3_(nullptr)
+    {
+        initGEOS(notice, notice);
+        wktw_ = GEOSWKTWriter_create();
+        GEOSWKTWriter_setTrim(wktw_, 1);
+        GEOSWKTWriter_setOutputDimension(wktw_, 3);
+    }
+
+    std::string
+    toWKT(GEOSGeometry* g)
+    {
+        char* wkt = GEOSWKTWriter_write(wktw_, g);
+        std::string ret(wkt);
+        GEOSFree(wkt);
+        return ret;
+    }
+
+    ~test_capigeosintersection_data()
+    {
+        GEOSWKTWriter_destroy(wktw_);
+        GEOSGeom_destroy(geom1_);
+        GEOSGeom_destroy(geom2_);
+        GEOSGeom_destroy(geom3_);
+        geom1_ = nullptr;
+        geom2_ = nullptr;
+        geom3_ = nullptr;
+        finishGEOS();
+    }
+
+};
+
+typedef test_group<test_capigeosintersection_data> group;
+typedef group::object object;
+
+group test_capigeosintersection_group("capi::GEOSIntersection");
+
+//
+// Test Cases
+//
+
+template<>
+template<>
+void object::test<1>
+()
+{
+    geom1_ = GEOSGeomFromWKT("POLYGON EMPTY");
+    geom2_ = GEOSGeomFromWKT("POLYGON EMPTY");
+
+    ensure(nullptr != geom1_);
+    ensure(nullptr != geom2_);
+
+    geom3_ = GEOSIntersection(geom1_, geom2_);
+    ensure(nullptr != geom3_);
+    ensure_equals(toWKT(geom3_), std::string("GEOMETRYCOLLECTION EMPTY"));
+}
+
+template<>
+template<>
+void object::test<2>
+()
 {
-	//
-	// Test Group
-	//
-
-	// Common data used in test cases.
-	struct test_capigeosintersection_data
-	{
-		GEOSWKTWriter* wktw_;
-		GEOSGeometry* geom1_;
-		GEOSGeometry* geom2_;
-		GEOSGeometry* geom3_;
-
-		static void notice(const char *fmt, ...)
-		{
-			std::fprintf(stdout, "NOTICE: ");
-
-			va_list ap;
-			va_start(ap, fmt);
-			std::vfprintf(stdout, fmt, ap);
-			va_end(ap);
-
-			std::fprintf(stdout, "\n");
-		}
-
-		test_capigeosintersection_data()
-			: geom1_(nullptr), geom2_(nullptr), geom3_(nullptr)
-		{
-			initGEOS(notice, notice);
-			wktw_ = GEOSWKTWriter_create();
-			GEOSWKTWriter_setTrim(wktw_, 1);
-			GEOSWKTWriter_setOutputDimension(wktw_, 3);
-		}
-
-		std::string toWKT(GEOSGeometry* g)
-		{
-			char* wkt = GEOSWKTWriter_write(wktw_, g);
-			std::string ret(wkt);
-			GEOSFree(wkt);
-			return ret;
-		}
-
-		~test_capigeosintersection_data()
-		{
-			GEOSWKTWriter_destroy(wktw_);
-			GEOSGeom_destroy(geom1_);
-			GEOSGeom_destroy(geom2_);
-			GEOSGeom_destroy(geom3_);
-			geom1_ = nullptr;
-			geom2_ = nullptr;
-			geom3_ = nullptr;
-			finishGEOS();
-		}
-
-	};
-
-	typedef test_group<test_capigeosintersection_data> group;
-	typedef group::object object;
-
-	group test_capigeosintersection_group("capi::GEOSIntersection");
-
-	//
-	// Test Cases
-	//
-
-	template<>
-	template<>
-	void object::test<1>()
-	{
-		geom1_ = GEOSGeomFromWKT("POLYGON EMPTY");
-		geom2_ = GEOSGeomFromWKT("POLYGON EMPTY");
-
-		ensure(nullptr != geom1_);
-		ensure(nullptr != geom2_);
-
-		geom3_ = GEOSIntersection(geom1_, geom2_);
-		ensure(nullptr != geom3_);
-		ensure_equals(toWKT(geom3_), std::string("GEOMETRYCOLLECTION EMPTY"));
-	}
-
-	template<>
-	template<>
-	void object::test<2>()
-	{
-		geom1_ = GEOSGeomFromWKT("POLYGON((1 1,1 5,5 5,5 1,1 1))");
-		geom2_ = GEOSGeomFromWKT("POINT(2 2)");
-
-		ensure(nullptr != geom1_);
-		ensure(nullptr != geom2_);
-
-		geom3_ = GEOSIntersection(geom1_, geom2_);
-		ensure(nullptr != geom3_);
-		ensure_equals(toWKT(geom3_), std::string("POINT (2 2)"));
-	}
-
-	template<>
-	template<>
-	void object::test<3>()
-	{
-		geom1_ = GEOSGeomFromWKT("MULTIPOLYGON(((0 0,0 10,10 10,10 0,0 0)))");
-		geom2_ = GEOSGeomFromWKT("POLYGON((-1 1,-1 2,2 2,2 1,-1 1))");
-
-		ensure(nullptr != geom1_);
-		ensure(nullptr != geom2_);
-
-		geom3_ = GEOSIntersection(geom1_, geom2_);
-
-		ensure(nullptr != geom3_);
-		ensure_equals(toWKT(geom3_), std::string("POLYGON ((0 1, 0 2, 2 2, 2 1, 0 1))"));
-	}
-
-  /* See http://trac.osgeo.org/geos/ticket/719 */
-	template<>
-	template<>
-	void object::test<4>()
-	{
-		geom1_ = GEOSGeomFromWKT("MULTIPOLYGON(((0 0,5 10,10 0,0 0),(1 1,1 2,2 2,2 1,1 1),(100 100,100 102,102 102,102 100,100 100)))");
-		geom2_ = GEOSGeomFromWKT("POLYGON((0 1,0 2,10 2,10 1,0 1))");
-
-		ensure(nullptr != geom1_);
-		ensure(nullptr != geom2_);
-
-		geom3_ = GEOSIntersection(geom1_, geom2_);
-
-		ensure(nullptr != geom3_);
-		ensure_equals(toWKT(geom3_), std::string("GEOMETRYCOLLECTION (LINESTRING (1 2, 2 2), LINESTRING (2 1, 1 1), POLYGON ((0.5 1, 1 2, 1 1, 0.5 1)), POLYGON ((9 2, 9.5 1, 2 1, 2 2, 9 2)))"));
-	}
+    geom1_ = GEOSGeomFromWKT("POLYGON((1 1,1 5,5 5,5 1,1 1))");
+    geom2_ = GEOSGeomFromWKT("POINT(2 2)");
+
+    ensure(nullptr != geom1_);
+    ensure(nullptr != geom2_);
+
+    geom3_ = GEOSIntersection(geom1_, geom2_);
+    ensure(nullptr != geom3_);
+    ensure_equals(toWKT(geom3_), std::string("POINT (2 2)"));
+}
+
+template<>
+template<>
+void object::test<3>
+()
+{
+    geom1_ = GEOSGeomFromWKT("MULTIPOLYGON(((0 0,0 10,10 10,10 0,0 0)))");
+    geom2_ = GEOSGeomFromWKT("POLYGON((-1 1,-1 2,2 2,2 1,-1 1))");
+
+    ensure(nullptr != geom1_);
+    ensure(nullptr != geom2_);
+
+    geom3_ = GEOSIntersection(geom1_, geom2_);
+
+    ensure(nullptr != geom3_);
+    ensure_equals(toWKT(geom3_), std::string("POLYGON ((0 1, 0 2, 2 2, 2 1, 0 1))"));
+}
+
+/* See http://trac.osgeo.org/geos/ticket/719 */
+template<>
+template<>
+void object::test<4>
+()
+{
+    geom1_ = GEOSGeomFromWKT("MULTIPOLYGON(((0 0,5 10,10 0,0 0),(1 1,1 2,2 2,2 1,1 1),(100 100,100 102,102 102,102 100,100 100)))");
+    geom2_ = GEOSGeomFromWKT("POLYGON((0 1,0 2,10 2,10 1,0 1))");
+
+    ensure(nullptr != geom1_);
+    ensure(nullptr != geom2_);
+
+    geom3_ = GEOSIntersection(geom1_, geom2_);
+
+    ensure(nullptr != geom3_);
+    ensure_equals(toWKT(geom3_),
+                  std::string("GEOMETRYCOLLECTION (LINESTRING (1 2, 2 2), LINESTRING (2 1, 1 1), POLYGON ((0.5 1, 1 2, 1 1, 0.5 1)), POLYGON ((9 2, 9.5 1, 2 1, 2 2, 9 2)))"));
+}
 
 } // namespace tut
 
diff --git a/tests/unit/capi/GEOSIntersectsTest.cpp b/tests/unit/capi/GEOSIntersectsTest.cpp
index bda143a..fa2a1b4 100644
--- a/tests/unit/capi/GEOSIntersectsTest.cpp
+++ b/tests/unit/capi/GEOSIntersectsTest.cpp
@@ -10,166 +10,174 @@
 #include <cstdlib>
 #include <cstring>
 
-namespace tut
-{
-    //
-    // Test Group
-    //
+namespace tut {
+//
+// Test Group
+//
 
-    // Common data used in test cases.
-    struct test_capigeosintersects_data
+// Common data used in test cases.
+struct test_capigeosintersects_data {
+    GEOSGeometry* geom1_;
+    GEOSGeometry* geom2_;
+
+    static void
+    notice(const char* fmt, ...)
     {
-        GEOSGeometry* geom1_;
-        GEOSGeometry* geom2_;
-
-        static void notice(const char *fmt, ...)
-        {
-            std::fprintf( stdout, "NOTICE: ");
-
-            va_list ap;
-            va_start(ap, fmt);
-            std::vfprintf(stdout, fmt, ap);
-            va_end(ap);
-
-            std::fprintf(stdout, "\n");
-        }
-
-        test_capigeosintersects_data()
-            : geom1_(nullptr), geom2_(nullptr)
-        {
-            initGEOS(notice, notice);
-        }
-
-        ~test_capigeosintersects_data()
-        {
-            GEOSGeom_destroy(geom1_);
-            GEOSGeom_destroy(geom2_);
-            geom1_ = nullptr;
-            geom2_ = nullptr;
-            finishGEOS();
-        }
-
-    };
-
-    typedef test_group<test_capigeosintersects_data> group;
-    typedef group::object object;
-
-    group test_capigeosintersects_group("capi::GEOSIntersects");
-
-    //
-    // Test Cases
-    //
-
-    template<>
-    template<>
-    void object::test<1>()
+        std::fprintf(stdout, "NOTICE: ");
+
+        va_list ap;
+        va_start(ap, fmt);
+        std::vfprintf(stdout, fmt, ap);
+        va_end(ap);
+
+        std::fprintf(stdout, "\n");
+    }
+
+    test_capigeosintersects_data()
+        : geom1_(nullptr), geom2_(nullptr)
     {
-        geom1_ = GEOSGeomFromWKT("POLYGON EMPTY");
-        geom2_ = GEOSGeomFromWKT("POLYGON EMPTY");
+        initGEOS(notice, notice);
+    }
 
-        ensure( nullptr != geom1_ );
-        ensure( nullptr != geom2_ );
+    ~test_capigeosintersects_data()
+    {
+        GEOSGeom_destroy(geom1_);
+        GEOSGeom_destroy(geom2_);
+        geom1_ = nullptr;
+        geom2_ = nullptr;
+        finishGEOS();
+    }
 
-        char const r1 = GEOSIntersects(geom1_, geom2_);
+};
 
-        ensure_equals(r1, 0);
+typedef test_group<test_capigeosintersects_data> group;
+typedef group::object object;
 
-        char const r2 = GEOSIntersects(geom2_, geom1_);
+group test_capigeosintersects_group("capi::GEOSIntersects");
 
-        ensure_equals(r2, 0);
-    }
+//
+// Test Cases
+//
 
-    template<>
-    template<>
-    void object::test<2>()
-    {
-        geom1_ = GEOSGeomFromWKT("POLYGON((1 1,1 5,5 5,5 1,1 1))");
-        geom2_ = GEOSGeomFromWKT("POINT(2 2)");
+template<>
+template<>
+void object::test<1>
+()
+{
+    geom1_ = GEOSGeomFromWKT("POLYGON EMPTY");
+    geom2_ = GEOSGeomFromWKT("POLYGON EMPTY");
 
-        ensure( nullptr != geom1_ );
-        ensure( nullptr != geom2_ );
+    ensure(nullptr != geom1_);
+    ensure(nullptr != geom2_);
 
-        char const r1 = GEOSIntersects(geom1_, geom2_);
+    char const r1 = GEOSIntersects(geom1_, geom2_);
 
-        ensure_equals(int(r1), 1);
+    ensure_equals(r1, 0);
 
-        char const r2 = GEOSIntersects(geom2_, geom1_);
+    char const r2 = GEOSIntersects(geom2_, geom1_);
 
-        ensure_equals(int(r2), 1);
-    }
+    ensure_equals(r2, 0);
+}
 
-    template<>
-    template<>
-    void object::test<3>()
-    {
-        geom1_ = GEOSGeomFromWKT("MULTIPOLYGON(((0 0,0 10,10 10,10 0,0 0)))");
-        geom2_ = GEOSGeomFromWKT("POLYGON((1 1,1 2,2 2,2 1,1 1))");
+template<>
+template<>
+void object::test<2>
+()
+{
+    geom1_ = GEOSGeomFromWKT("POLYGON((1 1,1 5,5 5,5 1,1 1))");
+    geom2_ = GEOSGeomFromWKT("POINT(2 2)");
 
-        ensure( nullptr != geom1_ );
-        ensure( nullptr != geom2_ );
+    ensure(nullptr != geom1_);
+    ensure(nullptr != geom2_);
 
-        char const r1 = GEOSIntersects(geom1_, geom2_);
+    char const r1 = GEOSIntersects(geom1_, geom2_);
 
-        ensure_equals(int(r1), 1);
+    ensure_equals(int(r1), 1);
 
-        char const r2 = GEOSIntersects(geom2_, geom1_);
+    char const r2 = GEOSIntersects(geom2_, geom1_);
 
-        ensure_equals(int(r2), 1);
-    }
+    ensure_equals(int(r2), 1);
+}
 
-    // This is a test for bug #357 (GEOSIntersects with nan coords)
-    template<>
-    template<>
-    void object::test<4>()
-    {
-        GEOSCoordSequence* cs = GEOSCoordSeq_create(5, 2);
+template<>
+template<>
+void object::test<3>
+()
+{
+    geom1_ = GEOSGeomFromWKT("MULTIPOLYGON(((0 0,0 10,10 10,10 0,0 0)))");
+    geom2_ = GEOSGeomFromWKT("POLYGON((1 1,1 2,2 2,2 1,1 1))");
 
-        double nan = std::numeric_limits<double>::quiet_NaN();
-        GEOSCoordSeq_setX(cs, 0, 1); GEOSCoordSeq_setY(cs, 0, 1);
-        for (unsigned int i=1; i<4; ++i) {
-            GEOSCoordSeq_setX(cs, i, nan);
-            GEOSCoordSeq_setY(cs, i, nan);
-        }
-        GEOSCoordSeq_setX(cs, 4, 1); GEOSCoordSeq_setY(cs, 4, 1);
+    ensure(nullptr != geom1_);
+    ensure(nullptr != geom2_);
 
-        geom1_ = GEOSGeom_createPolygon(GEOSGeom_createLinearRing(cs),
-                                        nullptr, 0);
+    char const r1 = GEOSIntersects(geom1_, geom2_);
 
-        char const r1 = GEOSIntersects(geom1_, geom1_);
+    ensure_equals(int(r1), 1);
 
-        ensure_equals(int(r1), 2);
+    char const r2 = GEOSIntersects(geom2_, geom1_);
 
+    ensure_equals(int(r2), 1);
+}
+
+// This is a test for bug #357 (GEOSIntersects with nan coords)
+template<>
+template<>
+void object::test<4>
+()
+{
+    GEOSCoordSequence* cs = GEOSCoordSeq_create(5, 2);
+
+    double nan = std::numeric_limits<double>::quiet_NaN();
+    GEOSCoordSeq_setX(cs, 0, 1);
+    GEOSCoordSeq_setY(cs, 0, 1);
+    for(unsigned int i = 1; i < 4; ++i) {
+        GEOSCoordSeq_setX(cs, i, nan);
+        GEOSCoordSeq_setY(cs, i, nan);
     }
+    GEOSCoordSeq_setX(cs, 4, 1);
+    GEOSCoordSeq_setY(cs, 4, 1);
 
-    // This is a test for bug #357 (GEOSIntersects with inf coords)
-    template<>
-    template<>
-    void object::test<5>()
-    {
-        const char *hex = "0103000020E61000000100000005000000737979F3DDCC2CC0F92154F9E7534540000000000000F07F000000000000F07F8F806E993F7E55C0304B29FFEA8554400634E8D1DD424540B5FEE6A37FCD4540737979F3DDCC2CC0F92154F9E7534540";
+    geom1_ = GEOSGeom_createPolygon(GEOSGeom_createLinearRing(cs),
+                                    nullptr, 0);
 
-        geom1_ = GEOSGeomFromHEX_buf((unsigned char*)hex, std::strlen(hex));
+    char const r1 = GEOSIntersects(geom1_, geom1_);
 
-        ensure( nullptr != geom1_ );
+    ensure_equals(int(r1), 2);
 
-        char const r1 = GEOSIntersects(geom1_, geom1_);
+}
 
-        ensure_equals(int(r1), 2);
+// This is a test for bug #357 (GEOSIntersects with inf coords)
+template<>
+template<>
+void object::test<5>
+()
+{
+    const char* hex =
+        "0103000020E61000000100000005000000737979F3DDCC2CC0F92154F9E7534540000000000000F07F000000000000F07F8F806E993F7E55C0304B29FFEA8554400634E8D1DD424540B5FEE6A37FCD4540737979F3DDCC2CC0F92154F9E7534540";
 
-    }
+    geom1_ = GEOSGeomFromHEX_buf((unsigned char*)hex, std::strlen(hex));
 
-    // Test for #782 (collection with empty components)
-    template<>
-    template<>
-    void object::test<6>()
-    {
-        geom1_ = GEOSGeomFromWKT("LINESTRING(10 0, 0 0, 0 10)");
-        geom2_ = GEOSGeomFromWKT("MULTILINESTRING((10 -1,-1 10),EMPTY)");
+    ensure(nullptr != geom1_);
 
-        char r1 = GEOSIntersects(geom1_, geom2_);
+    char const r1 = GEOSIntersects(geom1_, geom1_);
 
-        ensure_equals(r1, 1);
-    }
+    ensure_equals(int(r1), 2);
+
+}
+
+// Test for #782 (collection with empty components)
+template<>
+template<>
+void object::test<6>
+()
+{
+    geom1_ = GEOSGeomFromWKT("LINESTRING(10 0, 0 0, 0 10)");
+    geom2_ = GEOSGeomFromWKT("MULTILINESTRING((10 -1,-1 10),EMPTY)");
+
+    char r1 = GEOSIntersects(geom1_, geom2_);
+
+    ensure_equals(r1, 1);
+}
 
 } // namespace tut
 
diff --git a/tests/unit/capi/GEOSLineString_PointTest.cpp b/tests/unit/capi/GEOSLineString_PointTest.cpp
index 8db60fe..1c57f9c 100644
--- a/tests/unit/capi/GEOSLineString_PointTest.cpp
+++ b/tests/unit/capi/GEOSLineString_PointTest.cpp
@@ -9,137 +9,140 @@
 #include <cstdlib>
 #include <cmath>
 
-namespace tut
-{
-    //
-    // Test Group
-    //
-
-    // Common data used in test cases.
-    struct test_capilinestringpoint_data
-    {
-        GEOSGeometry* geom1_;
-
-        static void notice(const char *fmt, ...)
-        {
-            std::fprintf( stdout, "NOTICE: ");
-
-            va_list ap;
-            va_start(ap, fmt);
-            std::vfprintf(stdout, fmt, ap);
-            va_end(ap);
-
-            std::fprintf(stdout, "\n");
-        }
+namespace tut {
+//
+// Test Group
+//
 
-        test_capilinestringpoint_data()
-            : geom1_(nullptr)
-        {
-            initGEOS(notice, notice);
-        }
+// Common data used in test cases.
+struct test_capilinestringpoint_data {
+    GEOSGeometry* geom1_;
 
-        ~test_capilinestringpoint_data()
-        {
-            GEOSGeom_destroy(geom1_);
-            geom1_ = nullptr;
-            finishGEOS();
-        }
-
-    };
+    static void
+    notice(const char* fmt, ...)
+    {
+        std::fprintf(stdout, "NOTICE: ");
 
-    typedef test_group<test_capilinestringpoint_data> group;
-    typedef group::object object;
+        va_list ap;
+        va_start(ap, fmt);
+        std::vfprintf(stdout, fmt, ap);
+        va_end(ap);
 
-    group test_capilinestringpoint_group("capi::GEOSLineStringPoint");
+        std::fprintf(stdout, "\n");
+    }
 
-    //
-    // Test Cases
-    //
+    test_capilinestringpoint_data()
+        : geom1_(nullptr)
+    {
+        initGEOS(notice, notice);
+    }
 
-    template<>
-    template<>
-    void object::test<1>()
+    ~test_capilinestringpoint_data()
     {
-        geom1_ = GEOSGeomFromWKT("LINESTRING(0 0, 5 5, 10 10)");
-        GEOSGeometry *geom2;
-        double x, y, z;
-        ensure( nullptr != geom1_ );
+        GEOSGeom_destroy(geom1_);
+        geom1_ = nullptr;
+        finishGEOS();
+    }
 
-        char const r1 = GEOSisClosed(geom1_);
+};
 
-        ensure_equals(r1, 0);
+typedef test_group<test_capilinestringpoint_data> group;
+typedef group::object object;
 
-        geom2 = GEOSGeomGetPointN(geom1_, 0);
-        GEOSGeomGetX(geom2, &x);
-        GEOSGeomGetY(geom2, &y);
-        GEOSGeomGetZ(geom2, &z);
+group test_capilinestringpoint_group("capi::GEOSLineStringPoint");
 
-        ensure_equals(x, 0);
-        ensure_equals(y, 0);
-        ensure(std::isnan(z));
+//
+// Test Cases
+//
 
-        GEOSGeom_destroy(geom2);
+template<>
+template<>
+void object::test<1>
+()
+{
+    geom1_ = GEOSGeomFromWKT("LINESTRING(0 0, 5 5, 10 10)");
+    GEOSGeometry* geom2;
+    double x, y, z;
+    ensure(nullptr != geom1_);
 
-        geom2 = GEOSGeomGetStartPoint(geom1_);
-        GEOSGeomGetX(geom2, &x);
-        GEOSGeomGetY(geom2, &y);
-        GEOSGeomGetZ(geom2, &z);
+    char const r1 = GEOSisClosed(geom1_);
 
-        ensure_equals(x, 0);
-        ensure_equals(y, 0);
-        ensure(std::isnan(z));
+    ensure_equals(r1, 0);
 
-        GEOSGeom_destroy(geom2);
+    geom2 = GEOSGeomGetPointN(geom1_, 0);
+    GEOSGeomGetX(geom2, &x);
+    GEOSGeomGetY(geom2, &y);
+    GEOSGeomGetZ(geom2, &z);
 
-        geom2 = GEOSGeomGetEndPoint(geom1_);
-        GEOSGeomGetX(geom2, &x);
-        GEOSGeomGetY(geom2, &y);
-        GEOSGeomGetZ(geom2, &z);
+    ensure_equals(x, 0);
+    ensure_equals(y, 0);
+    ensure(std::isnan(z));
 
-        ensure_equals(x, 10);
-        ensure_equals(y, 10);
-        ensure(std::isnan(z));
+    GEOSGeom_destroy(geom2);
 
-        GEOSGeom_destroy(geom2);
-    }
+    geom2 = GEOSGeomGetStartPoint(geom1_);
+    GEOSGeomGetX(geom2, &x);
+    GEOSGeomGetY(geom2, &y);
+    GEOSGeomGetZ(geom2, &z);
 
-    template<>
-    template<>
-    void object::test<2>()
-    {
-        geom1_ = GEOSGeomFromWKT("LINESTRING(0 0, 5 5, 10 10)");
-        double length;
-        ensure( nullptr != geom1_ );
+    ensure_equals(x, 0);
+    ensure_equals(y, 0);
+    ensure(std::isnan(z));
 
-        GEOSGeomGetLength(geom1_, &length);
-        ensure(length != 0.0);
-    }
+    GEOSGeom_destroy(geom2);
 
-    template<>
-    template<>
-    void object::test<3>()
-    {
-        geom1_ = GEOSGeomFromWKT("LINESTRING(0 0, 5 5, 10 10)");
-        int points;
-        ensure( nullptr != geom1_ );
+    geom2 = GEOSGeomGetEndPoint(geom1_);
+    GEOSGeomGetX(geom2, &x);
+    GEOSGeomGetY(geom2, &y);
+    GEOSGeomGetZ(geom2, &z);
 
-        points = GEOSGeomGetNumPoints(geom1_);
-        ensure_equals(points, 3);
-    }
+    ensure_equals(x, 10);
+    ensure_equals(y, 10);
+    ensure(std::isnan(z));
 
-    template<>
-    template<>
-    void object::test<4>()
-    {
-        geom1_ = GEOSGeomFromWKT("POINT Z(0 10 20)");
-        double x, y, z;
+    GEOSGeom_destroy(geom2);
+}
+
+template<>
+template<>
+void object::test<2>
+()
+{
+    geom1_ = GEOSGeomFromWKT("LINESTRING(0 0, 5 5, 10 10)");
+    double length;
+    ensure(nullptr != geom1_);
+
+    GEOSGeomGetLength(geom1_, &length);
+    ensure(length != 0.0);
+}
+
+template<>
+template<>
+void object::test<3>
+()
+{
+    geom1_ = GEOSGeomFromWKT("LINESTRING(0 0, 5 5, 10 10)");
+    int points;
+    ensure(nullptr != geom1_);
+
+    points = GEOSGeomGetNumPoints(geom1_);
+    ensure_equals(points, 3);
+}
+
+template<>
+template<>
+void object::test<4>
+()
+{
+    geom1_ = GEOSGeomFromWKT("POINT Z(0 10 20)");
+    double x, y, z;
 
-        GEOSGeomGetX(geom1_, &x);
-        GEOSGeomGetY(geom1_, &y);
-        GEOSGeomGetZ(geom1_, &z);
+    GEOSGeomGetX(geom1_, &x);
+    GEOSGeomGetY(geom1_, &y);
+    GEOSGeomGetZ(geom1_, &z);
 
-        ensure_equals(x, 0);
-        ensure_equals(y, 10);
-        ensure_equals(z, 20);
-    }
+    ensure_equals(x, 0);
+    ensure_equals(y, 10);
+    ensure_equals(z, 20);
+}
 } // namespace tut
diff --git a/tests/unit/capi/GEOSMinimumClearanceTest.cpp b/tests/unit/capi/GEOSMinimumClearanceTest.cpp
index 2696b75..5d72ff7 100644
--- a/tests/unit/capi/GEOSMinimumClearanceTest.cpp
+++ b/tests/unit/capi/GEOSMinimumClearanceTest.cpp
@@ -8,125 +8,136 @@
 #include <cstdio>
 #include <cstdlib>
 
-namespace tut
-{
-    //
-    // Test Group
-    //
+namespace tut {
+//
+// Test Group
+//
 
-    // Common data used in test cases.
-    struct test_capigeosminimumclearance_data
+// Common data used in test cases.
+struct test_capigeosminimumclearance_data {
+    static void
+    notice(const char* fmt, ...)
     {
-        static void notice(const char *fmt, ...)
-        {
-            std::fprintf( stdout, "NOTICE: ");
+        std::fprintf(stdout, "NOTICE: ");
 
-            va_list ap;
-            va_start(ap, fmt);
-            std::vfprintf(stdout, fmt, ap);
-            va_end(ap);
+        va_list ap;
+        va_start(ap, fmt);
+        std::vfprintf(stdout, fmt, ap);
+        va_end(ap);
 
-            std::fprintf(stdout, "\n");
-        }
+        std::fprintf(stdout, "\n");
+    }
 
-        test_capigeosminimumclearance_data()
-        {
-            initGEOS(notice, notice);
-        }
+    test_capigeosminimumclearance_data()
+    {
+        initGEOS(notice, notice);
+    }
 
-        ~test_capigeosminimumclearance_data()
-        {
-            finishGEOS();
+    ~test_capigeosminimumclearance_data()
+    {
+        finishGEOS();
+    }
+
+    void
+    testClearance(const std::string& wkx_input,
+                  const std::string& wkx_expected,
+                  double clearance)
+    {
+
+        GEOSGeometry* input;
+        GEOSGeometry* expected_result;
+        if(wkx_input[0] == '0') {
+            input = GEOSGeomFromHEX_buf((const unsigned char*) wkx_input.c_str(), wkx_input.length());
+        }
+        else {
+            input = GEOSGeomFromWKT(wkx_input.c_str());
         }
 
-        void testClearance(const std::string & wkx_input,
-                           const std::string & wkx_expected,
-                           double clearance) {
-
-            GEOSGeometry* input;
-            GEOSGeometry* expected_result;
-            if (wkx_input[0] == '0')
-                input = GEOSGeomFromHEX_buf((const unsigned char*) wkx_input.c_str(), wkx_input.length());
-            else
-                input = GEOSGeomFromWKT(wkx_input.c_str());
-
-            if (wkx_expected[0] == '0')
-                expected_result = GEOSGeomFromHEX_buf((const unsigned char*) wkx_expected.c_str(), wkx_expected.length());
-            else
-                expected_result = GEOSGeomFromWKT(wkx_expected.c_str());
-
-            double d;
-            int error = GEOSMinimumClearance(input, &d);
-
-            ensure(!error);
-            if (clearance == std::numeric_limits<double>::infinity()) {
-                ensure(d == clearance);
-            } else {
-                ensure_equals("clearance", d, clearance, 1e-12);
-            }
-
-            GEOSGeometry* result = GEOSMinimumClearanceLine(input);
-            ensure(result != nullptr);
-            ensure_equals(1, GEOSEquals(result, expected_result));
-
-            GEOSGeom_destroy(input);
-            GEOSGeom_destroy(expected_result);
-            GEOSGeom_destroy(result);
+        if(wkx_expected[0] == '0') {
+            expected_result = GEOSGeomFromHEX_buf((const unsigned char*) wkx_expected.c_str(), wkx_expected.length());
+        }
+        else {
+            expected_result = GEOSGeomFromWKT(wkx_expected.c_str());
         }
 
-    };
+        double d;
+        int error = GEOSMinimumClearance(input, &d);
 
-    typedef test_group<test_capigeosminimumclearance_data> group;
-    typedef group::object object;
+        ensure(!error);
+        if(clearance == std::numeric_limits<double>::infinity()) {
+            ensure(d == clearance);
+        }
+        else {
+            ensure_equals("clearance", d, clearance, 1e-12);
+        }
 
-    group test_capigeosminimumclearance_group("capi::GEOSMinimumClearance");
+        GEOSGeometry* result = GEOSMinimumClearanceLine(input);
+        ensure(result != nullptr);
+        ensure_equals(1, GEOSEquals(result, expected_result));
 
-    //
-    // Test Cases
-    //
-    template<>
-    template<>
-    void object::test<1>()
-    {
-        testClearance("MULTIPOINT ((100 100), (100 100))",
-                      "LINESTRING EMPTY",
-                      std::numeric_limits<double>::infinity());
+        GEOSGeom_destroy(input);
+        GEOSGeom_destroy(expected_result);
+        GEOSGeom_destroy(result);
     }
 
-    template<>
-    template<>
-    void object::test<2>()
-    {
-        testClearance("MULTIPOINT ((100 100), (10 100), (30 100))",
-                      "LINESTRING (30 100, 10 100)",
-                      20);
-    }
+};
 
-    template<>
-    template<>
-    void object::test<3>()
-    {
-        testClearance("POLYGON ((100 100, 300 100, 200 200, 100 100))",
-                      "LINESTRING (200 200, 200 100)",
-                      100);
-    }
+typedef test_group<test_capigeosminimumclearance_data> group;
+typedef group::object object;
 
-    template<>
-    template<>
-    void object::test<4>()
-    {
-        testClearance("0106000000010000000103000000010000001a00000035d42824992d5cc01b834e081dca404073b9c150872d5cc03465a71fd4c940400ec00644882d5cc03b8a73d4d1c94040376dc669882d5cc0bf9cd9aed0c940401363997e892d5cc002f4fbfecdc94040ca4e3fa88b2d5cc0a487a1d5c9c940408f1ce90c8c2d5cc0698995d1c8c94040fab836548c2d5cc0bd175fb4c7c940409f1f46088f2d5cc0962023a0c2c940407b15191d902d5cc068041bd7bfc940400397c79a912d5cc0287d21e4bcc940403201bf46922d5cc065e3c116bbc940409d9d0c8e922d5cc0060fd3beb9c940400ef7915b932d5cc09012bbb6b7c940404fe61f7d932d5cc0e4a08499b6c94040fc71fbe5932d5cc0ea9106b7b5c94040eaec6470942d5cc0c2323674b3c94040601dc70f952d5cc043588d25acc94040aea06989952d5cc03ecf9f36aac94040307f85cc952d5cc0e5eb32fca7c94040dd0a6135962d5cc01b615111a7c9404048a7ae7c962d5cc00a2aaa7ea5c94040f4328ae5962d5cc05eb87361a4c94040c49448a2972d5cc04d81cccea2c940407c80eecb992d5cc06745d4449fc9404035d42824992d5cc01b834e081dca4040",
-                      "LINESTRING (-112.712119 33.575919, -112.712127 33.575885)",
-                      3.49284983912134e-05);
-    }
+group test_capigeosminimumclearance_group("capi::GEOSMinimumClearance");
 
-    template<>
-    template<>
-    void object::test<5>()
-    {
-        testClearance("POLYGON EMPTY",
-                      "LINESTRING EMPTY",
-                      std::numeric_limits<double>::infinity());
-    }
+//
+// Test Cases
+//
+template<>
+template<>
+void object::test<1>
+()
+{
+    testClearance("MULTIPOINT ((100 100), (100 100))",
+                  "LINESTRING EMPTY",
+                  std::numeric_limits<double>::infinity());
+}
+
+template<>
+template<>
+void object::test<2>
+()
+{
+    testClearance("MULTIPOINT ((100 100), (10 100), (30 100))",
+                  "LINESTRING (30 100, 10 100)",
+                  20);
+}
+
+template<>
+template<>
+void object::test<3>
+()
+{
+    testClearance("POLYGON ((100 100, 300 100, 200 200, 100 100))",
+                  "LINESTRING (200 200, 200 100)",
+                  100);
+}
+
+template<>
+template<>
+void object::test<4>
+()
+{
+    testClearance("0106000000010000000103000000010000001a00000035d42824992d5cc01b834e081dca404073b9c150872d5cc03465a71fd4c940400ec00644882d5cc03b8a73d4d1c94040376dc669882d5cc0bf9cd9aed0c940401363997e892d5cc002f4fbfecdc94040ca4e3fa88b2d5cc0a487a1d5c9c940408f1ce90c8c2d5cc0698995d1c8c94040fab836548c2d5cc0bd175fb4c7c940409f1f46088f2d5cc0962023a0c2c940407b15191d902d5cc068041bd7bfc940400397c79a912d5cc0287d21e4bcc940403201bf46922d5cc065e3c116bbc940409d9d0c8e922d5cc0060fd3beb9c940400ef7915b932d5cc09012bbb6b7c940404fe61f7d932d5cc0e4a08499b6c94040fc71fbe5932d5cc0ea9106b7b5c94040eaec6470942d5cc0c2323674b3c94040601dc70f952d5cc043588d25acc94040aea06989952d5cc03ecf9f36aac94040307f85cc952d5cc0e5eb32fca7c94040dd0a6135962d5cc01b615111a7c9404048a7ae7c962d5cc00a2aaa7ea5c94040f4328ae5962d5cc05eb87361a4c94040c49448a2972d5cc04d81cccea2c940407c80eecb992d5cc06745d4449fc9404035d42824992d5cc01b834e081dca4040",
+                  "LINESTRING (-112.712119 33.575919, -112.712127 33.575885)",
+                  3.49284983912134e-05);
+}
+
+template<>
+template<>
+void object::test<5>
+()
+{
+    testClearance("POLYGON EMPTY",
+                  "LINESTRING EMPTY",
+                  std::numeric_limits<double>::infinity());
+}
 
 } // namespace tut
diff --git a/tests/unit/capi/GEOSMinimumRectangleTest.cpp b/tests/unit/capi/GEOSMinimumRectangleTest.cpp
index 53843e8..49fed1f 100644
--- a/tests/unit/capi/GEOSMinimumRectangleTest.cpp
+++ b/tests/unit/capi/GEOSMinimumRectangleTest.cpp
@@ -9,76 +9,76 @@
 #include <cstdio>
 #include <cstdlib>
 
-namespace tut
-{
-    //
-    // Test Group
-    //
+namespace tut {
+//
+// Test Group
+//
 
-    // Common data used in test cases.
-    struct test_capigeosminimumrectangle_data
-    {
-        GEOSGeometry* input_;
-        GEOSWKTWriter* wktw_;
-        char* wkt_;
-
-        static void notice(const char *fmt, ...)
-        {
-            std::fprintf( stdout, "NOTICE: ");
-
-            va_list ap;
-            va_start(ap, fmt);
-            std::vfprintf(stdout, fmt, ap);
-            va_end(ap);
-
-            std::fprintf(stdout, "\n");
-        }
-
-        test_capigeosminimumrectangle_data()
-            : input_(nullptr), wkt_(nullptr)
-        {
-            initGEOS(notice, notice);
-            wktw_ = GEOSWKTWriter_create();
-            GEOSWKTWriter_setTrim(wktw_, 1);
-            GEOSWKTWriter_setRoundingPrecision(wktw_, 8);
-        }
-
-        ~test_capigeosminimumrectangle_data()
-        {
-            GEOSGeom_destroy(input_);
-            input_ = nullptr;
-            GEOSWKTWriter_destroy(wktw_);
-            GEOSFree(wkt_);
-            wkt_ = nullptr;
-            finishGEOS();
-        }
-
-    };
-
-    typedef test_group<test_capigeosminimumrectangle_data> group;
-    typedef group::object object;
-
-    group test_capigeosminimumrectangle_group("capi::GEOSMinimumRotatedRectangle");
-
-    //
-    // Test Cases
-    //
-
-    template<>
-    template<>
-    void object::test<1>()
+// Common data used in test cases.
+struct test_capigeosminimumrectangle_data {
+    GEOSGeometry* input_;
+    GEOSWKTWriter* wktw_;
+    char* wkt_;
+
+    static void
+    notice(const char* fmt, ...)
     {
-        input_ = GEOSGeomFromWKT("POLYGON ((1 6, 6 11, 11 6, 6 1, 1 6))");
-        ensure( nullptr != input_ );
+        std::fprintf(stdout, "NOTICE: ");
 
-        GEOSGeometry* output = GEOSMinimumRotatedRectangle(input_);
-        ensure( nullptr != output );
-        ensure( 0 == GEOSisEmpty(output) );
+        va_list ap;
+        va_start(ap, fmt);
+        std::vfprintf(stdout, fmt, ap);
+        va_end(ap);
 
-        wkt_ = GEOSWKTWriter_write(wktw_, output);
-        ensure_equals(std::string(wkt_), std::string( "POLYGON ((6 1, 11 6, 6 11, 1 6, 6 1))"));
+        std::fprintf(stdout, "\n");
+    }
 
-        GEOSGeom_destroy(output);
+    test_capigeosminimumrectangle_data()
+        : input_(nullptr), wkt_(nullptr)
+    {
+        initGEOS(notice, notice);
+        wktw_ = GEOSWKTWriter_create();
+        GEOSWKTWriter_setTrim(wktw_, 1);
+        GEOSWKTWriter_setRoundingPrecision(wktw_, 8);
     }
 
+    ~test_capigeosminimumrectangle_data()
+    {
+        GEOSGeom_destroy(input_);
+        input_ = nullptr;
+        GEOSWKTWriter_destroy(wktw_);
+        GEOSFree(wkt_);
+        wkt_ = nullptr;
+        finishGEOS();
+    }
+
+};
+
+typedef test_group<test_capigeosminimumrectangle_data> group;
+typedef group::object object;
+
+group test_capigeosminimumrectangle_group("capi::GEOSMinimumRotatedRectangle");
+
+//
+// Test Cases
+//
+
+template<>
+template<>
+void object::test<1>
+()
+{
+    input_ = GEOSGeomFromWKT("POLYGON ((1 6, 6 11, 11 6, 6 1, 1 6))");
+    ensure(nullptr != input_);
+
+    GEOSGeometry* output = GEOSMinimumRotatedRectangle(input_);
+    ensure(nullptr != output);
+    ensure(0 == GEOSisEmpty(output));
+
+    wkt_ = GEOSWKTWriter_write(wktw_, output);
+    ensure_equals(std::string(wkt_), std::string("POLYGON ((6 1, 11 6, 6 11, 1 6, 6 1))"));
+
+    GEOSGeom_destroy(output);
+}
+
 } // namespace tut
diff --git a/tests/unit/capi/GEOSMinimumWidthTest.cpp b/tests/unit/capi/GEOSMinimumWidthTest.cpp
index 0cea2bb..cfef4b6 100644
--- a/tests/unit/capi/GEOSMinimumWidthTest.cpp
+++ b/tests/unit/capi/GEOSMinimumWidthTest.cpp
@@ -8,92 +8,93 @@
 #include <cstdio>
 #include <cstdlib>
 
-namespace tut
-{
-    //
-    // Test Group
-    //
+namespace tut {
+//
+// Test Group
+//
 
-    // Common data used in test cases.
-    struct test_capigeosminimumwidth_data
-    {
-        GEOSGeometry* input_;
-        GEOSWKTWriter* wktw_;
-        char* wkt_;
-
-        static void notice(const char *fmt, ...)
-        {
-            std::fprintf( stdout, "NOTICE: ");
-
-            va_list ap;
-            va_start(ap, fmt);
-            std::vfprintf(stdout, fmt, ap);
-            va_end(ap);
-
-            std::fprintf(stdout, "\n");
-        }
-
-        test_capigeosminimumwidth_data()
-            : input_(nullptr), wkt_(nullptr)
-        {
-            initGEOS(notice, notice);
-            wktw_ = GEOSWKTWriter_create();
-            GEOSWKTWriter_setTrim(wktw_, 1);
-            GEOSWKTWriter_setRoundingPrecision(wktw_, 8);
-        }
-
-        ~test_capigeosminimumwidth_data()
-        {
-            GEOSGeom_destroy(input_);
-            input_ = nullptr;
-            GEOSWKTWriter_destroy(wktw_);
-            GEOSFree(wkt_);
-            wkt_ = nullptr;
-            finishGEOS();
-        }
-
-    };
-
-    typedef test_group<test_capigeosminimumwidth_data> group;
-    typedef group::object object;
-
-    group test_capigeosminimumwidth_group("capi::GEOSMinimumWidth");
-
-    //
-    // Test Cases
-    //
-
-    template<>
-    template<>
-    void object::test<1>()
+// Common data used in test cases.
+struct test_capigeosminimumwidth_data {
+    GEOSGeometry* input_;
+    GEOSWKTWriter* wktw_;
+    char* wkt_;
+
+    static void
+    notice(const char* fmt, ...)
     {
-        input_ = GEOSGeomFromWKT("POLYGON ((0 0, 0 15, 5 10, 5 0, 0 0))");
-        ensure( nullptr != input_ );
+        std::fprintf(stdout, "NOTICE: ");
 
-        GEOSGeometry* output = GEOSMinimumWidth(input_);
-        ensure( nullptr != output );
-        ensure( 0 == GEOSisEmpty(output) );
+        va_list ap;
+        va_start(ap, fmt);
+        std::vfprintf(stdout, fmt, ap);
+        va_end(ap);
 
-        wkt_ = GEOSWKTWriter_write(wktw_, output);
-        ensure_equals(std::string(wkt_), std::string( "LINESTRING (0 0, 5 0)"));
+        std::fprintf(stdout, "\n");
+    }
 
-        GEOSGeom_destroy(output);
+    test_capigeosminimumwidth_data()
+        : input_(nullptr), wkt_(nullptr)
+    {
+        initGEOS(notice, notice);
+        wktw_ = GEOSWKTWriter_create();
+        GEOSWKTWriter_setTrim(wktw_, 1);
+        GEOSWKTWriter_setRoundingPrecision(wktw_, 8);
     }
 
-    template<>
-    template<>
-    void object::test<2>()
+    ~test_capigeosminimumwidth_data()
     {
-        input_ = GEOSGeomFromWKT("LINESTRING (0 0,0 10, 10 10)");
-        ensure( nullptr != input_ );
+        GEOSGeom_destroy(input_);
+        input_ = nullptr;
+        GEOSWKTWriter_destroy(wktw_);
+        GEOSFree(wkt_);
+        wkt_ = nullptr;
+        finishGEOS();
+    }
 
-        GEOSGeometry* output = GEOSMinimumWidth(input_);
-        ensure( nullptr != output );
-        ensure( 0 == GEOSisEmpty(output) );
+};
 
-        wkt_ = GEOSWKTWriter_write(wktw_, output);
-        ensure_equals(std::string(wkt_), std::string( "LINESTRING (5 5, 0 10)"));
-        GEOSGeom_destroy(output);
-    }
+typedef test_group<test_capigeosminimumwidth_data> group;
+typedef group::object object;
+
+group test_capigeosminimumwidth_group("capi::GEOSMinimumWidth");
+
+//
+// Test Cases
+//
+
+template<>
+template<>
+void object::test<1>
+()
+{
+    input_ = GEOSGeomFromWKT("POLYGON ((0 0, 0 15, 5 10, 5 0, 0 0))");
+    ensure(nullptr != input_);
+
+    GEOSGeometry* output = GEOSMinimumWidth(input_);
+    ensure(nullptr != output);
+    ensure(0 == GEOSisEmpty(output));
+
+    wkt_ = GEOSWKTWriter_write(wktw_, output);
+    ensure_equals(std::string(wkt_), std::string("LINESTRING (0 0, 5 0)"));
+
+    GEOSGeom_destroy(output);
+}
+
+template<>
+template<>
+void object::test<2>
+()
+{
+    input_ = GEOSGeomFromWKT("LINESTRING (0 0,0 10, 10 10)");
+    ensure(nullptr != input_);
+
+    GEOSGeometry* output = GEOSMinimumWidth(input_);
+    ensure(nullptr != output);
+    ensure(0 == GEOSisEmpty(output));
+
+    wkt_ = GEOSWKTWriter_write(wktw_, output);
+    ensure_equals(std::string(wkt_), std::string("LINESTRING (5 5, 0 10)"));
+    GEOSGeom_destroy(output);
+}
 
 } // namespace tut
diff --git a/tests/unit/capi/GEOSNearestPointsTest.cpp b/tests/unit/capi/GEOSNearestPointsTest.cpp
index 8f4777c..c170459 100644
--- a/tests/unit/capi/GEOSNearestPointsTest.cpp
+++ b/tests/unit/capi/GEOSNearestPointsTest.cpp
@@ -10,111 +10,112 @@
 #include <cstdio>
 #include <cstdlib>
 
-namespace tut
-{
-    //
-    // Test Group
-    //
+namespace tut {
+//
+// Test Group
+//
 
-    // Common data used in test cases.
-    struct test_capigeosnearestpoints_data
-    {
-        GEOSGeometry *geom1_;
-        GEOSGeometry *geom2_;
-
-        static void notice(const char *fmt, ...)
-        {
-            std::fprintf( stdout, "NOTICE: ");
-
-            va_list ap;
-            va_start(ap, fmt);
-            std::vfprintf(stdout, fmt, ap);
-            va_end(ap);
-
-            std::fprintf(stdout, "\n");
-        }
-
-        test_capigeosnearestpoints_data()
-            : geom1_(nullptr), geom2_(nullptr)
-        {
-            initGEOS(notice, notice);
-        }
-
-        ~test_capigeosnearestpoints_data()
-        {
-            GEOSGeom_destroy(geom1_);
-            GEOSGeom_destroy(geom2_);
-            geom1_ = nullptr;
-            geom2_ = nullptr;
-            finishGEOS();
-        }
-
-    };
-
-    typedef test_group<test_capigeosnearestpoints_data> group;
-    typedef group::object object;
-
-    group test_capigeosnearestpoints_group("capi::GEOSNearestPoints");
-
-    //
-    // Test Cases
-    //
-
-    template<>
-    template<>
-    void object::test<1>()
+// Common data used in test cases.
+struct test_capigeosnearestpoints_data {
+    GEOSGeometry* geom1_;
+    GEOSGeometry* geom2_;
+
+    static void
+    notice(const char* fmt, ...)
     {
-        geom1_ = GEOSGeomFromWKT("POLYGON EMPTY");
-        geom2_ = GEOSGeomFromWKT("POLYGON EMPTY");
+        std::fprintf(stdout, "NOTICE: ");
 
-        ensure( nullptr != geom1_ );
-        ensure( nullptr != geom2_ );
+        va_list ap;
+        va_start(ap, fmt);
+        std::vfprintf(stdout, fmt, ap);
+        va_end(ap);
 
-        GEOSCoordSequence *coords_;
-        coords_ = GEOSNearestPoints(geom1_, geom2_);
+        std::fprintf(stdout, "\n");
+    }
 
-        ensure( nullptr == coords_ );
+    test_capigeosnearestpoints_data()
+        : geom1_(nullptr), geom2_(nullptr)
+    {
+        initGEOS(notice, notice);
     }
 
-    template<>
-    template<>
-    void object::test<2>()
+    ~test_capigeosnearestpoints_data()
     {
-        geom1_ = GEOSGeomFromWKT("POLYGON((1 1,1 5,5 5,5 1,1 1))");
-        // geom2_ = GEOSGeomFromWKT("POINT(8 8)");
-        geom2_ = GEOSGeomFromWKT("POLYGON((8 8, 9 9, 9 10, 8 8))");
+        GEOSGeom_destroy(geom1_);
+        GEOSGeom_destroy(geom2_);
+        geom1_ = nullptr;
+        geom2_ = nullptr;
+        finishGEOS();
+    }
+
+};
+
+typedef test_group<test_capigeosnearestpoints_data> group;
+typedef group::object object;
+
+group test_capigeosnearestpoints_group("capi::GEOSNearestPoints");
 
-        ensure( nullptr != geom1_ );
-        ensure( nullptr != geom2_ );
+//
+// Test Cases
+//
+
+template<>
+template<>
+void object::test<1>
+()
+{
+    geom1_ = GEOSGeomFromWKT("POLYGON EMPTY");
+    geom2_ = GEOSGeomFromWKT("POLYGON EMPTY");
 
-        GEOSCoordSequence *coords_;
-        coords_ = GEOSNearestPoints(geom1_, geom2_);
+    ensure(nullptr != geom1_);
+    ensure(nullptr != geom2_);
 
-        ensure( nullptr != coords_ );
+    GEOSCoordSequence* coords_;
+    coords_ = GEOSNearestPoints(geom1_, geom2_);
 
-        unsigned int size;
-        GEOSCoordSeq_getSize(coords_, &size);
-        ensure( 2 == size );
+    ensure(nullptr == coords_);
+}
 
-        double  x1, x2, y1, y2;
+template<>
+template<>
+void object::test<2>
+()
+{
+    geom1_ = GEOSGeomFromWKT("POLYGON((1 1,1 5,5 5,5 1,1 1))");
+    // geom2_ = GEOSGeomFromWKT("POINT(8 8)");
+    geom2_ = GEOSGeomFromWKT("POLYGON((8 8, 9 9, 9 10, 8 8))");
 
-        /* Point in geom1_
-         */
-        GEOSCoordSeq_getOrdinate(coords_, 0, 0, &x1);
-        GEOSCoordSeq_getOrdinate(coords_, 0, 1, &y1);
+    ensure(nullptr != geom1_);
+    ensure(nullptr != geom2_);
 
-        /* Point in geom2_
-         */
-        GEOSCoordSeq_getOrdinate(coords_, 1, 0, &x2);
-        GEOSCoordSeq_getOrdinate(coords_, 1, 1, &y2);
+    GEOSCoordSequence* coords_;
+    coords_ = GEOSNearestPoints(geom1_, geom2_);
 
-        ensure( 5 == x1 );
-        ensure( 5 == y1 );
-        ensure( 8 == x2 );
-        ensure( 8 == y2 );
+    ensure(nullptr != coords_);
 
-        GEOSCoordSeq_destroy(coords_);
-    }
+    unsigned int size;
+    GEOSCoordSeq_getSize(coords_, &size);
+    ensure(2 == size);
+
+    double  x1, x2, y1, y2;
+
+    /* Point in geom1_
+     */
+    GEOSCoordSeq_getOrdinate(coords_, 0, 0, &x1);
+    GEOSCoordSeq_getOrdinate(coords_, 0, 1, &y1);
+
+    /* Point in geom2_
+     */
+    GEOSCoordSeq_getOrdinate(coords_, 1, 0, &x2);
+    GEOSCoordSeq_getOrdinate(coords_, 1, 1, &y2);
+
+    ensure(5 == x1);
+    ensure(5 == y1);
+    ensure(8 == x2);
+    ensure(8 == y2);
+
+    GEOSCoordSeq_destroy(coords_);
+}
 
 } // namespace tut
 
diff --git a/tests/unit/capi/GEOSNodeTest.cpp b/tests/unit/capi/GEOSNodeTest.cpp
index 70c80c1..5d08407 100644
--- a/tests/unit/capi/GEOSNodeTest.cpp
+++ b/tests/unit/capi/GEOSNodeTest.cpp
@@ -10,117 +10,119 @@
 #include <cstdlib>
 #include <memory>
 
-namespace tut
-{
-    //
-    // Test Group
-    //
+namespace tut {
+//
+// Test Group
+//
 
-    // Common data used in test cases.
-    struct test_capigeosnode_data
-    {
-        GEOSGeometry* geom1_;
-        GEOSGeometry* geom2_;
-        GEOSWKTWriter* w_;
-
-        static void notice(const char *fmt, ...)
-        {
-            std::fprintf( stdout, "NOTICE: ");
-
-            va_list ap;
-            va_start(ap, fmt);
-            std::vfprintf(stdout, fmt, ap);
-            va_end(ap);
-
-            std::fprintf(stdout, "\n");
-        }
-
-        test_capigeosnode_data()
-            : geom1_(nullptr), geom2_(nullptr), w_(nullptr)
-        {
-            initGEOS(notice, notice);
-            w_ = GEOSWKTWriter_create();
-            GEOSWKTWriter_setTrim(w_, 1);
-        }
-
-        ~test_capigeosnode_data()
-        {
-            GEOSGeom_destroy(geom1_);
-            GEOSGeom_destroy(geom2_);
-            GEOSWKTWriter_destroy(w_);
-            geom1_ = nullptr;
-            geom2_ = nullptr;
-            finishGEOS();
-        }
-
-    };
-
-    typedef test_group<test_capigeosnode_data> group;
-    typedef group::object object;
-
-    group test_capigeosnode_group("capi::GEOSNode");
-
-    //
-    // Test Cases
-    //
-
-    /// Self-intersecting line
-    template<>
-    template<>
-    void object::test<1>()
+// Common data used in test cases.
+struct test_capigeosnode_data {
+    GEOSGeometry* geom1_;
+    GEOSGeometry* geom2_;
+    GEOSWKTWriter* w_;
+
+    static void
+    notice(const char* fmt, ...)
     {
-        geom1_ = GEOSGeomFromWKT("LINESTRING(0 0, 10 10, 10 0, 0 10)");
-        geom2_ = GEOSNode(geom1_);
-        ensure(nullptr != geom2_);
-
-        GEOSNormalize(geom2_);
-        char* wkt_c = GEOSWKTWriter_write(w_, geom2_);
-        std::string out(wkt_c);
-        free(wkt_c);
-
-        ensure_equals(out,
-          "MULTILINESTRING ((5 5, 10 0, 10 10, 5 5), (0 10, 5 5), (0 0, 5 5))"
-        );
+        std::fprintf(stdout, "NOTICE: ");
+
+        va_list ap;
+        va_start(ap, fmt);
+        std::vfprintf(stdout, fmt, ap);
+        va_end(ap);
+
+        std::fprintf(stdout, "\n");
     }
 
-    /// Overlapping lines
-    template<>
-    template<>
-    void object::test<2>()
+    test_capigeosnode_data()
+        : geom1_(nullptr), geom2_(nullptr), w_(nullptr)
     {
-        geom1_ = GEOSGeomFromWKT("MULTILINESTRING((0 0, 2 0, 4 0),(5 0, 3 0, 1 0))");
-        geom2_ = GEOSNode(geom1_);
-        ensure(nullptr != geom2_);
-
-        GEOSNormalize(geom2_);
-        char* wkt_c = GEOSWKTWriter_write(w_, geom2_);
-        std::string out(wkt_c);
-        free(wkt_c);
-
-        ensure_equals(out,
-          "MULTILINESTRING ((4 0, 5 0), (3 0, 4 0), (2 0, 3 0), (1 0, 2 0), (0 0, 1 0))"
-        );
+        initGEOS(notice, notice);
+        w_ = GEOSWKTWriter_create();
+        GEOSWKTWriter_setTrim(w_, 1);
     }
 
-    /// Equal lines
-    template<>
-    template<>
-    void object::test<3>()
+    ~test_capigeosnode_data()
     {
-        geom1_ = GEOSGeomFromWKT("MULTILINESTRING((0 0, 2 0, 4 0),(0 0, 2 0, 4 0))");
-        geom2_ = GEOSNode(geom1_);
-        ensure(nullptr != geom2_);
-
-        GEOSNormalize(geom2_);
-        char* wkt_c = GEOSWKTWriter_write(w_, geom2_);
-        std::string out(wkt_c);
-        free(wkt_c);
-
-        ensure_equals(out,
-          "MULTILINESTRING ((2 0, 4 0), (0 0, 2 0))"
-        );
+        GEOSGeom_destroy(geom1_);
+        GEOSGeom_destroy(geom2_);
+        GEOSWKTWriter_destroy(w_);
+        geom1_ = nullptr;
+        geom2_ = nullptr;
+        finishGEOS();
     }
 
+};
+
+typedef test_group<test_capigeosnode_data> group;
+typedef group::object object;
+
+group test_capigeosnode_group("capi::GEOSNode");
+
+//
+// Test Cases
+//
+
+/// Self-intersecting line
+template<>
+template<>
+void object::test<1>
+()
+{
+    geom1_ = GEOSGeomFromWKT("LINESTRING(0 0, 10 10, 10 0, 0 10)");
+    geom2_ = GEOSNode(geom1_);
+    ensure(nullptr != geom2_);
+
+    GEOSNormalize(geom2_);
+    char* wkt_c = GEOSWKTWriter_write(w_, geom2_);
+    std::string out(wkt_c);
+    free(wkt_c);
+
+    ensure_equals(out,
+                  "MULTILINESTRING ((5 5, 10 0, 10 10, 5 5), (0 10, 5 5), (0 0, 5 5))"
+                 );
+}
+
+/// Overlapping lines
+template<>
+template<>
+void object::test<2>
+()
+{
+    geom1_ = GEOSGeomFromWKT("MULTILINESTRING((0 0, 2 0, 4 0),(5 0, 3 0, 1 0))");
+    geom2_ = GEOSNode(geom1_);
+    ensure(nullptr != geom2_);
+
+    GEOSNormalize(geom2_);
+    char* wkt_c = GEOSWKTWriter_write(w_, geom2_);
+    std::string out(wkt_c);
+    free(wkt_c);
+
+    ensure_equals(out,
+                  "MULTILINESTRING ((4 0, 5 0), (3 0, 4 0), (2 0, 3 0), (1 0, 2 0), (0 0, 1 0))"
+                 );
+}
+
+/// Equal lines
+template<>
+template<>
+void object::test<3>
+()
+{
+    geom1_ = GEOSGeomFromWKT("MULTILINESTRING((0 0, 2 0, 4 0),(0 0, 2 0, 4 0))");
+    geom2_ = GEOSNode(geom1_);
+    ensure(nullptr != geom2_);
+
+    GEOSNormalize(geom2_);
+    char* wkt_c = GEOSWKTWriter_write(w_, geom2_);
+    std::string out(wkt_c);
+    free(wkt_c);
+
+    ensure_equals(out,
+                  "MULTILINESTRING ((2 0, 4 0), (0 0, 2 0))"
+                 );
+}
+
 
 } // namespace tut
 
diff --git a/tests/unit/capi/GEOSOffsetCurveTest.cpp b/tests/unit/capi/GEOSOffsetCurveTest.cpp
index cd647d4..70840d8 100644
--- a/tests/unit/capi/GEOSOffsetCurveTest.cpp
+++ b/tests/unit/capi/GEOSOffsetCurveTest.cpp
@@ -10,274 +10,283 @@
 #include <cstdlib>
 #include <cstring>
 
-namespace tut
-{
-    //
-    // Test Group
-    //
+namespace tut {
+//
+// Test Group
+//
+
+// Common data used in test cases.
+struct test_capioffsetcurve_data {
+    GEOSGeometry* geom1_;
+    GEOSGeometry* geom2_;
+    GEOSWKTWriter* wktw_;
+    char* wkt_;
+    double area_;
 
-    // Common data used in test cases.
-    struct test_capioffsetcurve_data
+    static void
+    notice(const char* fmt, ...)
     {
-        GEOSGeometry* geom1_;
-        GEOSGeometry* geom2_;
-        GEOSWKTWriter* wktw_;
-        char* wkt_;
-        double area_;
-
-        static void notice(const char *fmt, ...)
-        {
-            std::fprintf( stdout, "NOTICE: ");
-
-            va_list ap;
-            va_start(ap, fmt);
-            std::vfprintf(stdout, fmt, ap);
-            va_end(ap);
-
-            std::fprintf(stdout, "\n");
-        }
-
-        test_capioffsetcurve_data()
-            : geom1_(nullptr), geom2_(nullptr), wkt_(nullptr)
-        {
-            initGEOS(notice, notice);
-            wktw_ = GEOSWKTWriter_create();
-            GEOSWKTWriter_setTrim(wktw_, 1);
-        }
-
-        ~test_capioffsetcurve_data()
-        {
-            GEOSGeom_destroy(geom1_);
-            GEOSGeom_destroy(geom2_);
-            GEOSWKTWriter_destroy(wktw_);
-            GEOSFree(wkt_);
-            geom1_ = nullptr;
-            geom2_ = nullptr;
-            wkt_ = nullptr;
-            finishGEOS();
-        }
-
-    };
-
-    typedef test_group<test_capioffsetcurve_data> group;
-    typedef group::object object;
-
-    group test_capioffsetcurve_group("capi::GEOSOffsetCurve");
-
-    //
-    // Test Cases
-    //
-
-    // Straight, left
-    template<>
-    template<>
-    void object::test<1>()
+        std::fprintf(stdout, "NOTICE: ");
+
+        va_list ap;
+        va_start(ap, fmt);
+        std::vfprintf(stdout, fmt, ap);
+        va_end(ap);
+
+        std::fprintf(stdout, "\n");
+    }
+
+    test_capioffsetcurve_data()
+        : geom1_(nullptr), geom2_(nullptr), wkt_(nullptr)
     {
-        geom1_ = GEOSGeomFromWKT("LINESTRING(0 0, 10 0)");
+        initGEOS(notice, notice);
+        wktw_ = GEOSWKTWriter_create();
+        GEOSWKTWriter_setTrim(wktw_, 1);
+    }
 
-        ensure( nullptr != geom1_ );
+    ~test_capioffsetcurve_data()
+    {
+        GEOSGeom_destroy(geom1_);
+        GEOSGeom_destroy(geom2_);
+        GEOSWKTWriter_destroy(wktw_);
+        GEOSFree(wkt_);
+        geom1_ = nullptr;
+        geom2_ = nullptr;
+        wkt_ = nullptr;
+        finishGEOS();
+    }
 
-        geom2_ = GEOSOffsetCurve(geom1_, 2, 0, GEOSBUF_JOIN_ROUND, 2);
+};
 
-        ensure( nullptr != geom2_ );
+typedef test_group<test_capioffsetcurve_data> group;
+typedef group::object object;
 
-        wkt_ = GEOSWKTWriter_write(wktw_, geom2_);
+group test_capioffsetcurve_group("capi::GEOSOffsetCurve");
 
-        ensure_equals(std::string(wkt_), std::string( "LINESTRING (0 2, 10 2)"));
+//
+// Test Cases
+//
 
-    }
+// Straight, left
+template<>
+template<>
+void object::test<1>
+()
+{
+    geom1_ = GEOSGeomFromWKT("LINESTRING(0 0, 10 0)");
 
-    // Straight, right
-    template<>
-    template<>
-    void object::test<2>()
-    {
-        geom1_ = GEOSGeomFromWKT("LINESTRING(0 0, 10 0)");
+    ensure(nullptr != geom1_);
 
-        ensure( nullptr != geom1_ );
+    geom2_ = GEOSOffsetCurve(geom1_, 2, 0, GEOSBUF_JOIN_ROUND, 2);
 
-        geom2_ = GEOSOffsetCurve(geom1_, -2, 0, GEOSBUF_JOIN_ROUND, 2);
+    ensure(nullptr != geom2_);
 
-        ensure( nullptr != geom2_ );
+    wkt_ = GEOSWKTWriter_write(wktw_, geom2_);
 
-        wkt_ = GEOSWKTWriter_write(wktw_, geom2_);
+    ensure_equals(std::string(wkt_), std::string("LINESTRING (0 2, 10 2)"));
 
-        ensure_equals(std::string(wkt_), std::string(
-"LINESTRING (10 -2, 0 -2)"
-        ));
-    }
+}
 
-    // Outside curve
-    template<>
-    template<>
-    void object::test<3>()
-    {
-        geom1_ = GEOSGeomFromWKT("LINESTRING(0 0, 10 0, 10 10)");
+// Straight, right
+template<>
+template<>
+void object::test<2>
+()
+{
+    geom1_ = GEOSGeomFromWKT("LINESTRING(0 0, 10 0)");
 
-        ensure( nullptr != geom1_ );
+    ensure(nullptr != geom1_);
 
-        geom2_ = GEOSOffsetCurve(geom1_, -2, 1, GEOSBUF_JOIN_ROUND, 2);
+    geom2_ = GEOSOffsetCurve(geom1_, -2, 0, GEOSBUF_JOIN_ROUND, 2);
 
-        ensure( nullptr != geom2_ );
+    ensure(nullptr != geom2_);
 
-        wkt_ = GEOSWKTWriter_write(wktw_, geom2_);
+    wkt_ = GEOSWKTWriter_write(wktw_, geom2_);
 
-        ensure_equals(std::string(wkt_), std::string(
-"LINESTRING (12 10, 12 0, 10 -2, 0 -2)"
-        ));
-    }
+    ensure_equals(std::string(wkt_), std::string(
+                      "LINESTRING (10 -2, 0 -2)"
+                  ));
+}
 
-    // Inside curve
-    template<>
-    template<>
-    void object::test<4>()
-    {
-        geom1_ = GEOSGeomFromWKT("LINESTRING(0 0, 10 0, 10 10)");
+// Outside curve
+template<>
+template<>
+void object::test<3>
+()
+{
+    geom1_ = GEOSGeomFromWKT("LINESTRING(0 0, 10 0, 10 10)");
 
-        ensure( nullptr != geom1_ );
+    ensure(nullptr != geom1_);
 
-        geom2_ = GEOSOffsetCurve(geom1_, 2, 1, GEOSBUF_JOIN_ROUND, 2);
+    geom2_ = GEOSOffsetCurve(geom1_, -2, 1, GEOSBUF_JOIN_ROUND, 2);
 
-        ensure( nullptr != geom2_ );
+    ensure(nullptr != geom2_);
 
-        wkt_ = GEOSWKTWriter_write(wktw_, geom2_);
+    wkt_ = GEOSWKTWriter_write(wktw_, geom2_);
 
-        ensure_equals(std::string(wkt_), std::string(
-"LINESTRING (0 2, 8 2, 8 10)"
-        ));
-    }
+    ensure_equals(std::string(wkt_), std::string(
+                      "LINESTRING (12 10, 12 0, 10 -2, 0 -2)"
+                  ));
+}
 
-    // See http://trac.osgeo.org/postgis/ticket/413
-    template<>
-    template<>
-    void object::test<5>()
-    {
-        geom1_ = GEOSGeomFromWKT("LINESTRING(33282908 6005055,33282900 6005050,33282892 6005042,33282876 6005007,33282863 6004982,33282866 6004971,33282876 6004975,33282967 6005018,33282999 6005031)");
+// Inside curve
+template<>
+template<>
+void object::test<4>
+()
+{
+    geom1_ = GEOSGeomFromWKT("LINESTRING(0 0, 10 0, 10 10)");
 
-        ensure( nullptr != geom1_ );
+    ensure(nullptr != geom1_);
 
-        geom2_ = GEOSOffsetCurve(geom1_, 44, 1, GEOSBUF_JOIN_MITRE, 1);
+    geom2_ = GEOSOffsetCurve(geom1_, 2, 1, GEOSBUF_JOIN_ROUND, 2);
 
-        ensure( nullptr != geom2_ );
+    ensure(nullptr != geom2_);
 
-        wkt_ = GEOSWKTWriter_write(wktw_, geom2_);
+    wkt_ = GEOSWKTWriter_write(wktw_, geom2_);
 
-        ensure_equals(std::string(wkt_), std::string(
-"LINESTRING EMPTY"
-        ));
-    }
+    ensure_equals(std::string(wkt_), std::string(
+                      "LINESTRING (0 2, 8 2, 8 10)"
+                  ));
+}
 
-    // 0 distance
-    // See http://trac.osgeo.org/postgis/ticket/454
-    template<>
-    template<>
-    void object::test<6>()
-    {
-        geom1_ = GEOSGeomFromWKT("LINESTRING(0 0, 10 0)");
+// See http://trac.osgeo.org/postgis/ticket/413
+template<>
+template<>
+void object::test<5>
+()
+{
+    geom1_ = GEOSGeomFromWKT("LINESTRING(33282908 6005055,33282900 6005050,33282892 6005042,33282876 6005007,33282863 6004982,33282866 6004971,33282876 6004975,33282967 6005018,33282999 6005031)");
 
-        ensure( nullptr != geom1_ );
+    ensure(nullptr != geom1_);
 
-        geom2_ = GEOSOffsetCurve(geom1_, 0, 0, GEOSBUF_JOIN_ROUND, 2);
+    geom2_ = GEOSOffsetCurve(geom1_, 44, 1, GEOSBUF_JOIN_MITRE, 1);
 
-        ensure( nullptr != geom2_ );
+    ensure(nullptr != geom2_);
 
-        wkt_ = GEOSWKTWriter_write(wktw_, geom2_);
+    wkt_ = GEOSWKTWriter_write(wktw_, geom2_);
 
-        ensure_equals(std::string(wkt_), std::string(
-          "LINESTRING (0 0, 10 0)"
-        ));
-    }
+    ensure_equals(std::string(wkt_), std::string(
+                      "LINESTRING EMPTY"
+                  ));
+}
 
-    // left-side and right-side curve
-    // See http://trac.osgeo.org/postgis/ticket/633
-    template<>
-    template<>
-    void object::test<7>()
-    {
-        std::string wkt0("LINESTRING ("
-            "665.7317504882812500 133.0762634277343700,"
-            "1774.4752197265625000 19.9391822814941410,"
-            "756.2413940429687500 466.8306579589843700,"
-            "626.1337890625000000 1898.0147705078125000,"
-            "433.8007202148437500 404.6052856445312500)");
-
-        geom1_ = GEOSGeomFromWKT(wkt0.c_str());
-        ensure( nullptr != geom1_ );
-
-        double width = 57.164000837203;
-
-        // left-sided
-        {
-            geom2_ = GEOSOffsetCurve(geom1_, width, 8, GEOSBUF_JOIN_MITRE, 5.57);
-            ensure( nullptr != geom2_ );
-            // likely, 5 >= 5
-            ensure(GEOSGeomGetNumPoints(geom2_) >= GEOSGeomGetNumPoints(geom1_));
-            wkt_ = GEOSWKTWriter_write(wktw_, geom2_);
-            GEOSGeom_destroy(geom2_);
-            GEOSFree(wkt_);
-            //ensure_equals(std::string(wkt_), ...);
-        }
-
-        // right-sided
-        {
-            width = -width;
-            geom2_ = GEOSOffsetCurve(geom1_, width, 8, GEOSBUF_JOIN_MITRE, 5.57);
-            ensure( nullptr != geom2_ );
-            // likely, 5 >= 7
-            ensure(GEOSGeomGetNumPoints(geom2_) >= GEOSGeomGetNumPoints(geom1_));
-            wkt_ = GEOSWKTWriter_write(wktw_, geom2_);
-            //ensure_equals(std::string(wkt_), ...);
-        }
-    }
+// 0 distance
+// See http://trac.osgeo.org/postgis/ticket/454
+template<>
+template<>
+void object::test<6>
+()
+{
+    geom1_ = GEOSGeomFromWKT("LINESTRING(0 0, 10 0)");
 
-    // Test duplicated inner vertex in input
-    // See http://trac.osgeo.org/postgis/ticket/602
-    template<>
-    template<>
-    void object::test<8>()
-    {
-        double width = -1;
+    ensure(nullptr != geom1_);
 
-        geom1_ = GEOSGeomFromWKT("LINESTRING(0 0,0 10,0 10,10 10)");
-        ensure( nullptr != geom1_ );
+    geom2_ = GEOSOffsetCurve(geom1_, 0, 0, GEOSBUF_JOIN_ROUND, 2);
 
-        geom2_ = GEOSOffsetCurve(geom1_, width, 8, GEOSBUF_JOIN_ROUND, 0);
-        ensure( "Unexpected exception", nullptr != geom2_ );
-        wkt_ = GEOSWKTWriter_write(wktw_, geom2_);
-        ensure_equals(std::string(wkt_), "LINESTRING (10 9, 1 9, 1 0)");
-    }
+    ensure(nullptr != geom2_);
 
-    // Test duplicated final vertex in input
-    // See http://trac.osgeo.org/postgis/ticket/602
-    template<>
-    template<>
-    void object::test<9>()
-    {
-        double width = -1;
+    wkt_ = GEOSWKTWriter_write(wktw_, geom2_);
 
-        geom1_ = GEOSGeomFromWKT("LINESTRING(0 0,0 10,0 10)");
-        ensure( nullptr != geom1_ );
+    ensure_equals(std::string(wkt_), std::string(
+                      "LINESTRING (0 0, 10 0)"
+                  ));
+}
+
+// left-side and right-side curve
+// See http://trac.osgeo.org/postgis/ticket/633
+template<>
+template<>
+void object::test<7>
+()
+{
+    std::string wkt0("LINESTRING ("
+                     "665.7317504882812500 133.0762634277343700,"
+                     "1774.4752197265625000 19.9391822814941410,"
+                     "756.2413940429687500 466.8306579589843700,"
+                     "626.1337890625000000 1898.0147705078125000,"
+                     "433.8007202148437500 404.6052856445312500)");
 
-        geom2_ = GEOSOffsetCurve(geom1_, width, 8, GEOSBUF_JOIN_ROUND, 0);
-        ensure( "Unexpected exception", nullptr != geom2_ );
+    geom1_ = GEOSGeomFromWKT(wkt0.c_str());
+    ensure(nullptr != geom1_);
+
+    double width = 57.164000837203;
+
+    // left-sided
+    {
+        geom2_ = GEOSOffsetCurve(geom1_, width, 8, GEOSBUF_JOIN_MITRE, 5.57);
+        ensure(nullptr != geom2_);
+        // likely, 5 >= 5
+        ensure(GEOSGeomGetNumPoints(geom2_) >= GEOSGeomGetNumPoints(geom1_));
         wkt_ = GEOSWKTWriter_write(wktw_, geom2_);
-        ensure_equals(std::string(wkt_), "LINESTRING (1 10, 1 0)");
+        GEOSGeom_destroy(geom2_);
+        GEOSFree(wkt_);
+        //ensure_equals(std::string(wkt_), ...);
     }
 
-    // Test only duplicated vertex in input
-    // See http://trac.osgeo.org/postgis/ticket/602
-    template<>
-    template<>
-    void object::test<10>()
+    // right-sided
     {
-        double width = -1;
+        width = -width;
+        geom2_ = GEOSOffsetCurve(geom1_, width, 8, GEOSBUF_JOIN_MITRE, 5.57);
+        ensure(nullptr != geom2_);
+        // likely, 5 >= 7
+        ensure(GEOSGeomGetNumPoints(geom2_) >= GEOSGeomGetNumPoints(geom1_));
+        wkt_ = GEOSWKTWriter_write(wktw_, geom2_);
+        //ensure_equals(std::string(wkt_), ...);
+    }
+}
+
+// Test duplicated inner vertex in input
+// See http://trac.osgeo.org/postgis/ticket/602
+template<>
+template<>
+void object::test<8>
+()
+{
+    double width = -1;
+
+    geom1_ = GEOSGeomFromWKT("LINESTRING(0 0,0 10,0 10,10 10)");
+    ensure(nullptr != geom1_);
+
+    geom2_ = GEOSOffsetCurve(geom1_, width, 8, GEOSBUF_JOIN_ROUND, 0);
+    ensure("Unexpected exception", nullptr != geom2_);
+    wkt_ = GEOSWKTWriter_write(wktw_, geom2_);
+    ensure_equals(std::string(wkt_), "LINESTRING (10 9, 1 9, 1 0)");
+}
+
+// Test duplicated final vertex in input
+// See http://trac.osgeo.org/postgis/ticket/602
+template<>
+template<>
+void object::test<9>
+()
+{
+    double width = -1;
+
+    geom1_ = GEOSGeomFromWKT("LINESTRING(0 0,0 10,0 10)");
+    ensure(nullptr != geom1_);
+
+    geom2_ = GEOSOffsetCurve(geom1_, width, 8, GEOSBUF_JOIN_ROUND, 0);
+    ensure("Unexpected exception", nullptr != geom2_);
+    wkt_ = GEOSWKTWriter_write(wktw_, geom2_);
+    ensure_equals(std::string(wkt_), "LINESTRING (1 10, 1 0)");
+}
+
+// Test only duplicated vertex in input
+// See http://trac.osgeo.org/postgis/ticket/602
+template<>
+template<>
+void object::test<10>
+()
+{
+    double width = -1;
 
-        geom1_ = GEOSGeomFromWKT("LINESTRING(0 10,0 10,0 10)");
-        ensure( nullptr != geom1_ );
+    geom1_ = GEOSGeomFromWKT("LINESTRING(0 10,0 10,0 10)");
+    ensure(nullptr != geom1_);
 
-        geom2_ = GEOSOffsetCurve(geom1_, width, 8, GEOSBUF_JOIN_ROUND, 0);
-        ensure( "Missing expected exception", nullptr == geom2_ );
-    }
+    geom2_ = GEOSOffsetCurve(geom1_, width, 8, GEOSBUF_JOIN_ROUND, 0);
+    ensure("Missing expected exception", nullptr == geom2_);
+}
 
 } // namespace tut
 
diff --git a/tests/unit/capi/GEOSOrientationIndex.cpp b/tests/unit/capi/GEOSOrientationIndex.cpp
index bd69a7e..5a22939 100644
--- a/tests/unit/capi/GEOSOrientationIndex.cpp
+++ b/tests/unit/capi/GEOSOrientationIndex.cpp
@@ -11,148 +11,158 @@
 #include <cstdlib>
 #include <memory>
 
-namespace tut
-{
-    //
-    // Test Group
-    //
-
-    // Common data used in test cases.
-    struct test_capigeosorientationindex_data
-    {
-	GEOSContextHandle_t handle_;
-
-        static void notice(const char *fmt, ...)
-        {
-            std::fprintf( stdout, "NOTICE: ");
-
-            va_list ap;
-            va_start(ap, fmt);
-            std::vfprintf(stdout, fmt, ap);
-            va_end(ap);
-
-            std::fprintf(stdout, "\n");
-        }
-
-        test_capigeosorientationindex_data()
-            : handle_(initGEOS_r(notice, notice))
-        {
-        }
-
-        ~test_capigeosorientationindex_data()
-        {
-            finishGEOS_r(handle_);
-        }
-
-    };
-
-    typedef test_group<test_capigeosorientationindex_data> group;
-    typedef group::object object;
-
-    group test_capigeosorientationindex_group("capi::GEOSOrientationIndex");
+namespace tut {
+//
+// Test Group
+//
 
-    //
-    // Test Cases
-    //
+// Common data used in test cases.
+struct test_capigeosorientationindex_data {
+    GEOSContextHandle_t handle_;
 
-    // Interior, collinear
-    template<>
-    template<>
-    void object::test<1>()
+    static void
+    notice(const char* fmt, ...)
     {
-	int ret = GEOSOrientationIndex_r(handle_, 0, 0, 10, 0, 5, 0);
-	ensure_equals(ret, 0);
-    }
+        std::fprintf(stdout, "NOTICE: ");
 
-    // Boundary (last point), collinear
-    template<>
-    template<>
-    void object::test<2>()
-    {
-	int ret = GEOSOrientationIndex_r(handle_, 0, 0, 10, 0, 10, 0);
-	ensure_equals(ret, 0);
-    }
+        va_list ap;
+        va_start(ap, fmt);
+        std::vfprintf(stdout, fmt, ap);
+        va_end(ap);
 
-    // Boundary (first point), collinear
-    template<>
-    template<>
-    void object::test<3>()
-    {
-	int ret = GEOSOrientationIndex_r(handle_, 0, 0, 10, 0, 0, 0);
-	ensure_equals(ret, 0);
+        std::fprintf(stdout, "\n");
     }
 
-    // Exterior, before first point, collinear
-    template<>
-    template<>
-    void object::test<4>()
+    test_capigeosorientationindex_data()
+        : handle_(initGEOS_r(notice, notice))
     {
-	int ret = GEOSOrientationIndex_r(handle_, 0, 0, 10, 0, -5, 0);
-	ensure_equals(ret, 0);
     }
 
-    // Exterior, after last point, collinear
-    template<>
-    template<>
-    void object::test<5>()
+    ~test_capigeosorientationindex_data()
     {
-	int ret = GEOSOrientationIndex_r(handle_, 0, 0, 10, 0, 20, 0);
-	ensure_equals(ret, 0);
+        finishGEOS_r(handle_);
     }
 
-    // Exterior, in bounding box, turn left
-    template<>
-    template<>
-    void object::test<6>()
-    {
-	int ret = GEOSOrientationIndex_r(handle_, 0, 0, 10, 10, 5, 6);
-	ensure_equals(ret, 1);
-    }
+};
 
-    // Exterior, outside bounding box, turn left
-    template<>
-    template<>
-    void object::test<7>()
-    {
-	int ret = GEOSOrientationIndex_r(handle_, 0, 0, 10, 10, 5, 20);
-	ensure_equals(ret, 1);
-    }
+typedef test_group<test_capigeosorientationindex_data> group;
+typedef group::object object;
 
-    // Exterior, in bounding box, turn right
-    template<>
-    template<>
-    void object::test<8>()
-    {
-	int ret = GEOSOrientationIndex_r(handle_, 0, 0, 10, 10, 5, 3);
-	ensure_equals(ret, -1);
-    }
-
-    // Exterior, outside bounding box, turn left
-    template<>
-    template<>
-    void object::test<9>()
-    {
-	int ret = GEOSOrientationIndex_r(handle_, 0, 0, 10, 10, 5, -2);
-	ensure_equals(ret, -1);
-    }
+group test_capigeosorientationindex_group("capi::GEOSOrientationIndex");
 
-    // Exterior, outside bounding box, very close to collinear, turn left
-    template<>
-    template<>
-    void object::test<10>()
-    {
-	int ret = GEOSOrientationIndex_r(handle_, 0, 0, 10, 10, 1000000, 1000001);
-	ensure_equals(ret, 1);
-    }
+//
+// Test Cases
+//
 
-    // Exterior, outside bounding box, very close to collinear, turn right
-    template<>
-    template<>
-    void object::test<11>()
-    {
-	int ret = GEOSOrientationIndex_r(handle_, 0, 0, 10, 10, 1000000,  999999);
-	ensure_equals(ret, -1);
-    }
+// Interior, collinear
+template<>
+template<>
+void object::test<1>
+()
+{
+    int ret = GEOSOrientationIndex_r(handle_, 0, 0, 10, 0, 5, 0);
+    ensure_equals(ret, 0);
+}
+
+// Boundary (last point), collinear
+template<>
+template<>
+void object::test<2>
+()
+{
+    int ret = GEOSOrientationIndex_r(handle_, 0, 0, 10, 0, 10, 0);
+    ensure_equals(ret, 0);
+}
+
+// Boundary (first point), collinear
+template<>
+template<>
+void object::test<3>
+()
+{
+    int ret = GEOSOrientationIndex_r(handle_, 0, 0, 10, 0, 0, 0);
+    ensure_equals(ret, 0);
+}
+
+// Exterior, before first point, collinear
+template<>
+template<>
+void object::test<4>
+()
+{
+    int ret = GEOSOrientationIndex_r(handle_, 0, 0, 10, 0, -5, 0);
+    ensure_equals(ret, 0);
+}
+
+// Exterior, after last point, collinear
+template<>
+template<>
+void object::test<5>
+()
+{
+    int ret = GEOSOrientationIndex_r(handle_, 0, 0, 10, 0, 20, 0);
+    ensure_equals(ret, 0);
+}
+
+// Exterior, in bounding box, turn left
+template<>
+template<>
+void object::test<6>
+()
+{
+    int ret = GEOSOrientationIndex_r(handle_, 0, 0, 10, 10, 5, 6);
+    ensure_equals(ret, 1);
+}
+
+// Exterior, outside bounding box, turn left
+template<>
+template<>
+void object::test<7>
+()
+{
+    int ret = GEOSOrientationIndex_r(handle_, 0, 0, 10, 10, 5, 20);
+    ensure_equals(ret, 1);
+}
+
+// Exterior, in bounding box, turn right
+template<>
+template<>
+void object::test<8>
+()
+{
+    int ret = GEOSOrientationIndex_r(handle_, 0, 0, 10, 10, 5, 3);
+    ensure_equals(ret, -1);
+}
+
+// Exterior, outside bounding box, turn left
+template<>
+template<>
+void object::test<9>
+()
+{
+    int ret = GEOSOrientationIndex_r(handle_, 0, 0, 10, 10, 5, -2);
+    ensure_equals(ret, -1);
+}
+
+// Exterior, outside bounding box, very close to collinear, turn left
+template<>
+template<>
+void object::test<10>
+()
+{
+    int ret = GEOSOrientationIndex_r(handle_, 0, 0, 10, 10, 1000000, 1000001);
+    ensure_equals(ret, 1);
+}
+
+// Exterior, outside bounding box, very close to collinear, turn right
+template<>
+template<>
+void object::test<11>
+()
+{
+    int ret = GEOSOrientationIndex_r(handle_, 0, 0, 10, 10, 1000000,  999999);
+    ensure_equals(ret, -1);
+}
 
 
 
diff --git a/tests/unit/capi/GEOSPointOnSurfaceTest.cpp b/tests/unit/capi/GEOSPointOnSurfaceTest.cpp
index 4f48141..e4899c0 100644
--- a/tests/unit/capi/GEOSPointOnSurfaceTest.cpp
+++ b/tests/unit/capi/GEOSPointOnSurfaceTest.cpp
@@ -11,242 +11,252 @@
 #include <cstdlib>
 #include <cstring>
 
-namespace tut
-{
-    //
-    // Test Group
-    //
+namespace tut {
+//
+// Test Group
+//
 
-    // Common data used in test cases.
-    struct test_capipointonsurface_data
+// Common data used in test cases.
+struct test_capipointonsurface_data {
+    GEOSGeometry* geom1_;
+    GEOSGeometry* geom2_;
+    GEOSWKTWriter* wktw_;
+    char* wkt_;
+    double area_;
+
+    static void
+    notice(const char* fmt, ...)
     {
-        GEOSGeometry* geom1_;
-        GEOSGeometry* geom2_;
-        GEOSWKTWriter* wktw_;
-        char* wkt_;
-        double area_;
-
-        static void notice(const char *fmt, ...)
-        {
-            std::fprintf( stdout, "NOTICE: ");
-
-            va_list ap;
-            va_start(ap, fmt);
-            std::vfprintf(stdout, fmt, ap);
-            va_end(ap);
-
-            std::fprintf(stdout, "\n");
-        }
-
-        test_capipointonsurface_data()
-            : geom1_(nullptr), geom2_(nullptr), wkt_(nullptr)
-        {
-            initGEOS(notice, notice);
-            wktw_ = GEOSWKTWriter_create();
-            GEOSWKTWriter_setTrim(wktw_, 1);
-            GEOSWKTWriter_setRoundingPrecision(wktw_, 8);
-        }
-
-        ~test_capipointonsurface_data()
-        {
-            GEOSGeom_destroy(geom1_);
-            GEOSGeom_destroy(geom2_);
-            GEOSWKTWriter_destroy(wktw_);
-            GEOSFree(wkt_);
-            geom1_ = nullptr;
-            geom2_ = nullptr;
-            wkt_ = nullptr;
-            finishGEOS();
-        }
-
-    };
-
-    typedef test_group<test_capipointonsurface_data> group;
-    typedef group::object object;
-
-    group test_capipointonsurface_group("capi::GEOSPointOnSurface");
-
-    //
-    // Test Cases
-    //
-
-    // Single point
-    template<>
-    template<>
-    void object::test<1>()
+        std::fprintf(stdout, "NOTICE: ");
+
+        va_list ap;
+        va_start(ap, fmt);
+        std::vfprintf(stdout, fmt, ap);
+        va_end(ap);
+
+        std::fprintf(stdout, "\n");
+    }
+
+    test_capipointonsurface_data()
+        : geom1_(nullptr), geom2_(nullptr), wkt_(nullptr)
     {
-        geom1_ = GEOSGeomFromWKT("POINT(10 0)");
+        initGEOS(notice, notice);
+        wktw_ = GEOSWKTWriter_create();
+        GEOSWKTWriter_setTrim(wktw_, 1);
+        GEOSWKTWriter_setRoundingPrecision(wktw_, 8);
+    }
 
-        ensure( nullptr != geom1_ );
+    ~test_capipointonsurface_data()
+    {
+        GEOSGeom_destroy(geom1_);
+        GEOSGeom_destroy(geom2_);
+        GEOSWKTWriter_destroy(wktw_);
+        GEOSFree(wkt_);
+        geom1_ = nullptr;
+        geom2_ = nullptr;
+        wkt_ = nullptr;
+        finishGEOS();
+    }
 
-        geom2_ = GEOSPointOnSurface(geom1_);
+};
 
-        ensure( nullptr != geom2_ );
+typedef test_group<test_capipointonsurface_data> group;
+typedef group::object object;
 
-        wkt_ = GEOSWKTWriter_write(wktw_, geom2_);
+group test_capipointonsurface_group("capi::GEOSPointOnSurface");
 
-        ensure_equals(std::string(wkt_), std::string( "POINT (10 0)"));
+//
+// Test Cases
+//
 
-    }
+// Single point
+template<>
+template<>
+void object::test<1>
+()
+{
+    geom1_ = GEOSGeomFromWKT("POINT(10 0)");
 
-    // line
-    template<>
-    template<>
-    void object::test<2>()
-    {
-        geom1_ = GEOSGeomFromWKT("LINESTRING(0 0, 5 0, 10 0)");
+    ensure(nullptr != geom1_);
 
-        ensure( nullptr != geom1_ );
+    geom2_ = GEOSPointOnSurface(geom1_);
 
-        geom2_ = GEOSPointOnSurface(geom1_);
+    ensure(nullptr != geom2_);
 
-        ensure( nullptr != geom2_ );
+    wkt_ = GEOSWKTWriter_write(wktw_, geom2_);
 
-        wkt_ = GEOSWKTWriter_write(wktw_, geom2_);
+    ensure_equals(std::string(wkt_), std::string("POINT (10 0)"));
 
-        ensure_equals(std::string(wkt_), std::string( "POINT (5 0)"));
+}
 
-    }
+// line
+template<>
+template<>
+void object::test<2>
+()
+{
+    geom1_ = GEOSGeomFromWKT("LINESTRING(0 0, 5 0, 10 0)");
 
-    // polygon
-    template<>
-    template<>
-    void object::test<3>()
-    {
-        geom1_ = GEOSGeomFromWKT("POLYGON((0 0, 10 0, 10 10, 0 10, 0 0))");
+    ensure(nullptr != geom1_);
 
-        ensure( nullptr != geom1_ );
+    geom2_ = GEOSPointOnSurface(geom1_);
 
-        geom2_ = GEOSPointOnSurface(geom1_);
+    ensure(nullptr != geom2_);
 
-        ensure( nullptr != geom2_ );
+    wkt_ = GEOSWKTWriter_write(wktw_, geom2_);
 
-        wkt_ = GEOSWKTWriter_write(wktw_, geom2_);
+    ensure_equals(std::string(wkt_), std::string("POINT (5 0)"));
 
-        ensure_equals(std::string(wkt_), std::string( "POINT (5 5)"));
+}
 
-    }
+// polygon
+template<>
+template<>
+void object::test<3>
+()
+{
+    geom1_ = GEOSGeomFromWKT("POLYGON((0 0, 10 0, 10 10, 0 10, 0 0))");
 
-    // Tiny triangle, see http://trac.osgeo.org/geos/ticket/559
-    template<>
-    template<>
-    void object::test<4>()
-    {
-        geom1_ = GEOSGeomFromWKT(
-"POLYGON(( \
+    ensure(nullptr != geom1_);
+
+    geom2_ = GEOSPointOnSurface(geom1_);
+
+    ensure(nullptr != geom2_);
+
+    wkt_ = GEOSWKTWriter_write(wktw_, geom2_);
+
+    ensure_equals(std::string(wkt_), std::string("POINT (5 5)"));
+
+}
+
+// Tiny triangle, see http://trac.osgeo.org/geos/ticket/559
+template<>
+template<>
+void object::test<4>
+()
+{
+    geom1_ = GEOSGeomFromWKT(
+                 "POLYGON(( \
 56.528666666700 25.2101666667, \
 56.529000000000 25.2105000000, \
 56.528833333300 25.2103333333, \
 56.528666666700 25.2101666667))");
 
-        ensure( nullptr != geom1_ );
+    ensure(nullptr != geom1_);
 
-        geom2_ = GEOSPointOnSurface(geom1_);
+    geom2_ = GEOSPointOnSurface(geom1_);
 
-        ensure( nullptr != geom2_ );
+    ensure(nullptr != geom2_);
 
-        wkt_ = GEOSWKTWriter_write(wktw_, geom2_);
+    wkt_ = GEOSWKTWriter_write(wktw_, geom2_);
 
-        ensure_equals(std::string(wkt_), std::string( "POINT (56.528917 25.210417)" ) );
+    ensure_equals(std::string(wkt_), std::string("POINT (56.528917 25.210417)"));
 
-    }
-
-    // Empty geometry -- see http://trac.osgeo.org/geos/ticket/560
-    template<>
-    template<>
-    void object::test<5>()
-    {
-        geom1_ = GEOSGeomFromWKT("LINESTRING EMPTY");
+}
 
-        ensure( nullptr != geom1_ );
-
-        geom2_ = GEOSPointOnSurface(geom1_);
+// Empty geometry -- see http://trac.osgeo.org/geos/ticket/560
+template<>
+template<>
+void object::test<5>
+()
+{
+    geom1_ = GEOSGeomFromWKT("LINESTRING EMPTY");
 
-        ensure( nullptr != geom2_ );
+    ensure(nullptr != geom1_);
 
-        wkt_ = GEOSWKTWriter_write(wktw_, geom2_);
+    geom2_ = GEOSPointOnSurface(geom1_);
 
-        ensure_equals(std::string(wkt_), std::string( "POINT EMPTY"));
-    }
+    ensure(nullptr != geom2_);
 
-    // Single point linestring -- see http://trac.osgeo.org/geos/ticket/609
-    template<>
-    template<>
-    void object::test<6>()
-    {
-        geom1_ = GEOSGeomFromWKT("LINESTRING(0 0, 0 0)");
+    wkt_ = GEOSWKTWriter_write(wktw_, geom2_);
 
-        ensure( nullptr != geom1_ );
+    ensure_equals(std::string(wkt_), std::string("POINT EMPTY"));
+}
 
-        geom2_ = GEOSPointOnSurface(geom1_);
+// Single point linestring -- see http://trac.osgeo.org/geos/ticket/609
+template<>
+template<>
+void object::test<6>
+()
+{
+    geom1_ = GEOSGeomFromWKT("LINESTRING(0 0, 0 0)");
 
-        ensure( nullptr != geom2_ );
+    ensure(nullptr != geom1_);
 
-        wkt_ = GEOSWKTWriter_write(wktw_, geom2_);
+    geom2_ = GEOSPointOnSurface(geom1_);
 
-        ensure_equals(std::string(wkt_), std::string( "POINT (0 0)"));
+    ensure(nullptr != geom2_);
 
-    }
+    wkt_ = GEOSWKTWriter_write(wktw_, geom2_);
 
-    // Check point on surface for three similar polygons (shapes)
-    // https://trac.osgeo.org/geos/ticket/840
-    template<>
-    template<>
-    void object::test<7>()
-    {
-      // Polygon A
-        geom1_ = GEOSGeomFromWKT("POLYGON(("
-          "182111.031940953 141935.935903267,181944.315698016 141813.663222482,"
-          "181993.426552077 141735.161360171,182025.215323227 141755.058841504,"
-          "182042.126877935 141723.338145732,182089.035943744 141755.453352846,"
-          "182096.699289843 141744.892410235,182142.107084301 141773.967727472,"
-          "182140.268233846 141825.482203511,182123.233970367 141827.369156254,"
-          "182111.031940953 141935.935903267))");
-        ensure(nullptr != geom1_);
-        geom2_ = GEOSPointOnSurface(geom1_);
-        ensure(nullptr != geom2_);
-
-        wkt_ = GEOSWKTWriter_write(wktw_, geom2_);
-        ensure_equals(std::string(wkt_), std::string("POINT (182077.08 141881.65)"));
-    }
+    ensure_equals(std::string(wkt_), std::string("POINT (0 0)"));
 
-    template<>
-    template<>
-    void object::test<8>() {
-        // Polygon B from ticket #840
-        geom1_ = GEOSGeomFromWKT("POLYGON(("
-          "182512.231897141 141935.935903267,182344.315698016 141813.663222482,"
-          "182393.426552077 141735.161360171,182425.215323227 141755.058841504,"
-          "182442.126877935 141723.338145732,182489.035943744 141755.453352846,"
-          "182496.699289843 141744.892410235,182542.107084301 141773.967727472,"
-          "182540.268233846 141825.482203511,182522.034014178 141825.369229273,"
-          "182512.231897141 141935.935903267))");
-        ensure(nullptr != geom1_);
-        geom2_ = GEOSPointOnSurface(geom1_);
-        ensure(nullptr != geom2_);
-
-        wkt_ = GEOSWKTWriter_write(wktw_, geom2_);
-        ensure_equals(std::string(wkt_), std::string("POINT (182476.76 141880.71)"));
-    }
+}
 
-    template<>
-    template<>
-    void object::test<9>() {
-        // Polygon C from ticket #840
-        geom1_ = GEOSGeomFromWKT("POLYGON(("
-          "182635.760119718 141846.477712277,182826.153168283 141974.473039044,"
-          "182834.952846998 141857.67730337,182862.151853936 141851.277537031,"
-          "182860.551912351 141779.280165725,182824.553226698 141748.881275618,"
-          "182814.953577191 141758.480925126,182766.155358861 141721.682268681,"
-          "182742.156235092 141744.881421657,182692.558045971 141716.882443927,"
-          "182635.760119718 141846.477712277))");
-        ensure(nullptr != geom1_);
-        geom2_ = GEOSPointOnSurface(geom1_);
-        ensure(nullptr != geom2_);
-
-        wkt_ = GEOSWKTWriter_write(wktw_, geom2_);
-        ensure_equals(std::string(wkt_), std::string("POINT (182755.89 141812.88)"));
-    }
+// Check point on surface for three similar polygons (shapes)
+// https://trac.osgeo.org/geos/ticket/840
+template<>
+template<>
+void object::test<7>
+()
+{
+    // Polygon A
+    geom1_ = GEOSGeomFromWKT("POLYGON(("
+                             "182111.031940953 141935.935903267,181944.315698016 141813.663222482,"
+                             "181993.426552077 141735.161360171,182025.215323227 141755.058841504,"
+                             "182042.126877935 141723.338145732,182089.035943744 141755.453352846,"
+                             "182096.699289843 141744.892410235,182142.107084301 141773.967727472,"
+                             "182140.268233846 141825.482203511,182123.233970367 141827.369156254,"
+                             "182111.031940953 141935.935903267))");
+    ensure(nullptr != geom1_);
+    geom2_ = GEOSPointOnSurface(geom1_);
+    ensure(nullptr != geom2_);
+
+    wkt_ = GEOSWKTWriter_write(wktw_, geom2_);
+    ensure_equals(std::string(wkt_), std::string("POINT (182077.08 141881.65)"));
+}
+
+template<>
+template<>
+void object::test<8>
+()
+{
+    // Polygon B from ticket #840
+    geom1_ = GEOSGeomFromWKT("POLYGON(("
+                             "182512.231897141 141935.935903267,182344.315698016 141813.663222482,"
+                             "182393.426552077 141735.161360171,182425.215323227 141755.058841504,"
+                             "182442.126877935 141723.338145732,182489.035943744 141755.453352846,"
+                             "182496.699289843 141744.892410235,182542.107084301 141773.967727472,"
+                             "182540.268233846 141825.482203511,182522.034014178 141825.369229273,"
+                             "182512.231897141 141935.935903267))");
+    ensure(nullptr != geom1_);
+    geom2_ = GEOSPointOnSurface(geom1_);
+    ensure(nullptr != geom2_);
+
+    wkt_ = GEOSWKTWriter_write(wktw_, geom2_);
+    ensure_equals(std::string(wkt_), std::string("POINT (182476.76 141880.71)"));
+}
+
+template<>
+template<>
+void object::test<9>
+()
+{
+    // Polygon C from ticket #840
+    geom1_ = GEOSGeomFromWKT("POLYGON(("
+                             "182635.760119718 141846.477712277,182826.153168283 141974.473039044,"
+                             "182834.952846998 141857.67730337,182862.151853936 141851.277537031,"
+                             "182860.551912351 141779.280165725,182824.553226698 141748.881275618,"
+                             "182814.953577191 141758.480925126,182766.155358861 141721.682268681,"
+                             "182742.156235092 141744.881421657,182692.558045971 141716.882443927,"
+                             "182635.760119718 141846.477712277))");
+    ensure(nullptr != geom1_);
+    geom2_ = GEOSPointOnSurface(geom1_);
+    ensure(nullptr != geom2_);
+
+    wkt_ = GEOSWKTWriter_write(wktw_, geom2_);
+    ensure_equals(std::string(wkt_), std::string("POINT (182755.89 141812.88)"));
+}
 
 } // namespace tut
 
diff --git a/tests/unit/capi/GEOSPolygonizer_getCutEdgesTest.cpp b/tests/unit/capi/GEOSPolygonizer_getCutEdgesTest.cpp
index f6bf936..f791b04 100644
--- a/tests/unit/capi/GEOSPolygonizer_getCutEdgesTest.cpp
+++ b/tests/unit/capi/GEOSPolygonizer_getCutEdgesTest.cpp
@@ -10,96 +10,97 @@
 #include <cstdlib>
 #include <memory>
 
-namespace tut
-{
-    //
-    // Test Group
-    //
+namespace tut {
+//
+// Test Group
+//
 
-    // Common data used in test cases.
-    struct test_capigeospolygonizegetcutedges_data
+// Common data used in test cases.
+struct test_capigeospolygonizegetcutedges_data {
+    static void
+    notice(const char* fmt, ...)
     {
-        static void notice(const char *fmt, ...)
-        {
-            std::fprintf( stdout, "NOTICE: ");
+        std::fprintf(stdout, "NOTICE: ");
 
-            va_list ap;
-            va_start(ap, fmt);
-            std::vfprintf(stdout, fmt, ap);
-            va_end(ap);
+        va_list ap;
+        va_start(ap, fmt);
+        std::vfprintf(stdout, fmt, ap);
+        va_end(ap);
 
-            std::fprintf(stdout, "\n");
-        }
+        std::fprintf(stdout, "\n");
+    }
 
-        test_capigeospolygonizegetcutedges_data()
-        {
-            initGEOS(notice, notice);
-        }
+    test_capigeospolygonizegetcutedges_data()
+    {
+        initGEOS(notice, notice);
+    }
 
-        ~test_capigeospolygonizegetcutedges_data()
-        {
-            finishGEOS();
-        }
+    ~test_capigeospolygonizegetcutedges_data()
+    {
+        finishGEOS();
+    }
 
-    };
+};
 
-    typedef test_group<test_capigeospolygonizegetcutedges_data> group;
-    typedef group::object object;
+typedef test_group<test_capigeospolygonizegetcutedges_data> group;
+typedef group::object object;
 
-    group test_capigeospolygonizegetcutedges_group("capi::GEOSPolygonizeGetCutEdges");
+group test_capigeospolygonizegetcutedges_group("capi::GEOSPolygonizeGetCutEdges");
 
-    //
-    // Test Cases
-    //
+//
+// Test Cases
+//
 
-    template<>
-    template<>
-    void object::test<1>()
-    {
-        const int size = 2;
-        GEOSGeometry* geoms[size] = { nullptr };
+template<>
+template<>
+void object::test<1>
+()
+{
+    const int size = 2;
+    GEOSGeometry* geoms[size] = { nullptr };
 
-        geoms[0] = GEOSGeomFromWKT("LINESTRING(1 3, 3 3, 3 1, 1 1, 1 3)");
-        geoms[1] = GEOSGeomFromWKT("LINESTRING(1 3, 3 3, 3 1, 1 1, 1 3)");
+    geoms[0] = GEOSGeomFromWKT("LINESTRING(1 3, 3 3, 3 1, 1 1, 1 3)");
+    geoms[1] = GEOSGeomFromWKT("LINESTRING(1 3, 3 3, 3 1, 1 1, 1 3)");
 
-        GEOSGeometry* g = GEOSPolygonizer_getCutEdges(geoms, size);
+    GEOSGeometry* g = GEOSPolygonizer_getCutEdges(geoms, size);
 
-        ensure(nullptr != g);
-        ensure_equals(GEOSGetNumGeometries(g), size);
+    ensure(nullptr != g);
+    ensure_equals(GEOSGetNumGeometries(g), size);
 
-        GEOSGeom_destroy(g);
-        GEOSGeom_destroy(geoms[0]);
-        GEOSGeom_destroy(geoms[1]);
-    }
+    GEOSGeom_destroy(g);
+    GEOSGeom_destroy(geoms[0]);
+    GEOSGeom_destroy(geoms[1]);
+}
 
-    template<>
-    template<>
-    void object::test<2>()
-    {
-        const int size = 6;
-        GEOSGeometry* geoms[size] = { nullptr };
+template<>
+template<>
+void object::test<2>
+()
+{
+    const int size = 6;
+    GEOSGeometry* geoms[size] = { nullptr };
 
-        // Example from JTS Developer's Guide, Chapter 6 - Polygonization
-        geoms[0] = GEOSGeomFromWKT("LINESTRING(0 0, 10 10)"); // isolated edge
-        geoms[1] = GEOSGeomFromWKT("LINESTRING(185 221, 100 100)"); // dangling edge
-        geoms[2] = GEOSGeomFromWKT("LINESTRING(185 221, 88 275, 180 316)");
-        geoms[3] = GEOSGeomFromWKT("LINESTRING(185 221, 292 281, 180 316)");
-        geoms[4] = GEOSGeomFromWKT("LINESTRING(189 98, 83 187, 185 221)");
-        geoms[5] = GEOSGeomFromWKT("LINESTRING(189 98, 325 168, 185 221)");
+    // Example from JTS Developer's Guide, Chapter 6 - Polygonization
+    geoms[0] = GEOSGeomFromWKT("LINESTRING(0 0, 10 10)"); // isolated edge
+    geoms[1] = GEOSGeomFromWKT("LINESTRING(185 221, 100 100)"); // dangling edge
+    geoms[2] = GEOSGeomFromWKT("LINESTRING(185 221, 88 275, 180 316)");
+    geoms[3] = GEOSGeomFromWKT("LINESTRING(185 221, 292 281, 180 316)");
+    geoms[4] = GEOSGeomFromWKT("LINESTRING(189 98, 83 187, 185 221)");
+    geoms[5] = GEOSGeomFromWKT("LINESTRING(189 98, 325 168, 185 221)");
 
-        GEOSGeometry* g = GEOSPolygonizer_getCutEdges(geoms, size);
+    GEOSGeometry* g = GEOSPolygonizer_getCutEdges(geoms, size);
 
-        ensure(nullptr != g);
-        ensure_equals(GEOSGetNumGeometries(g), 0);
+    ensure(nullptr != g);
+    ensure_equals(GEOSGetNumGeometries(g), 0);
 
-        GEOSGeom_destroy(g);
+    GEOSGeom_destroy(g);
 
-        for (int i = 0; i < size; ++i)
-        {
-            if (nullptr != geoms[i])
-                GEOSGeom_destroy(geoms[i]);
+    for(int i = 0; i < size; ++i) {
+        if(nullptr != geoms[i]) {
+            GEOSGeom_destroy(geoms[i]);
         }
     }
+}
 
 } // namespace tut
 
diff --git a/tests/unit/capi/GEOSPreparedGeometryTest.cpp b/tests/unit/capi/GEOSPreparedGeometryTest.cpp
index 98b4145..918d29a 100644
--- a/tests/unit/capi/GEOSPreparedGeometryTest.cpp
+++ b/tests/unit/capi/GEOSPreparedGeometryTest.cpp
@@ -12,85 +12,86 @@
 #include <cstdlib>
 #include <memory>
 
-namespace tut
-{
-    //
-    // Test Group
-    //
+namespace tut {
+//
+// Test Group
+//
 
-    // Common data used in test cases.
-    struct test_capigeospreparedgeometry_data
-    {
-        GEOSGeometry* geom1_;
-        GEOSGeometry* geom2_;
+// Common data used in test cases.
+struct test_capigeospreparedgeometry_data {
+    GEOSGeometry* geom1_;
+    GEOSGeometry* geom2_;
 
-        const GEOSPreparedGeometry* prepGeom1_;
-        const GEOSPreparedGeometry* prepGeom2_;
+    const GEOSPreparedGeometry* prepGeom1_;
+    const GEOSPreparedGeometry* prepGeom2_;
 
 
 
-        static void notice(const char *fmt, ...)
-        {
-            std::fprintf( stdout, "NOTICE: ");
+    static void
+    notice(const char* fmt, ...)
+    {
+        std::fprintf(stdout, "NOTICE: ");
 
-            va_list ap;
-            va_start(ap, fmt);
-            std::vfprintf(stdout, fmt, ap);
-            va_end(ap);
+        va_list ap;
+        va_start(ap, fmt);
+        std::vfprintf(stdout, fmt, ap);
+        va_end(ap);
 
-            std::fprintf(stdout, "\n");
-        }
+        std::fprintf(stdout, "\n");
+    }
 
-        test_capigeospreparedgeometry_data()
-            : geom1_(nullptr), geom2_(nullptr), prepGeom1_(nullptr), prepGeom2_(nullptr)
-        {
-            initGEOS(notice, notice);
-        }
+    test_capigeospreparedgeometry_data()
+        : geom1_(nullptr), geom2_(nullptr), prepGeom1_(nullptr), prepGeom2_(nullptr)
+    {
+        initGEOS(notice, notice);
+    }
 
-        ~test_capigeospreparedgeometry_data()
-        {
-            GEOSGeom_destroy(geom1_);
-            GEOSGeom_destroy(geom2_);
+    ~test_capigeospreparedgeometry_data()
+    {
+        GEOSGeom_destroy(geom1_);
+        GEOSGeom_destroy(geom2_);
         GEOSPreparedGeom_destroy(prepGeom1_);
         GEOSPreparedGeom_destroy(prepGeom2_);
-            geom1_ = nullptr;
-            geom2_ = nullptr;
-            prepGeom1_ = nullptr;
-            prepGeom2_ = nullptr;
-            finishGEOS();
-        }
+        geom1_ = nullptr;
+        geom2_ = nullptr;
+        prepGeom1_ = nullptr;
+        prepGeom2_ = nullptr;
+        finishGEOS();
+    }
 
-    };
+};
 
-    typedef test_group<test_capigeospreparedgeometry_data> group;
-    typedef group::object object;
+typedef test_group<test_capigeospreparedgeometry_data> group;
+typedef group::object object;
 
-    group test_capigeospreparedgeometry_group("capi::GEOSPreparedGeometry");
+group test_capigeospreparedgeometry_group("capi::GEOSPreparedGeometry");
 
-    //
-    // Test Cases
-    //
+//
+// Test Cases
+//
 
-    // Test geometry preparation
-    template<>
-    template<>
-    void object::test<1>()
-    {
-            geom1_ = GEOSGeomFromWKT("POLYGON EMPTY");
-        prepGeom1_ = GEOSPrepare(geom1_);
+// Test geometry preparation
+template<>
+template<>
+void object::test<1>
+()
+{
+    geom1_ = GEOSGeomFromWKT("POLYGON EMPTY");
+    prepGeom1_ = GEOSPrepare(geom1_);
 
-        ensure(nullptr != prepGeom1_);
+    ensure(nullptr != prepGeom1_);
 
-    }
+}
 
-    // Test PreparedContainsProperly
-    // Taken from regress/regress_ogc_prep.sql of postgis
-    // as of revno 3936
-    // ref: containsproperly200 (a)
-    template<>
-    template<>
-    void object::test<2>()
-    {
+// Test PreparedContainsProperly
+// Taken from regress/regress_ogc_prep.sql of postgis
+// as of revno 3936
+// ref: containsproperly200 (a)
+template<>
+template<>
+void object::test<2>
+()
+{
     geom1_ = GEOSGeomFromWKT("POLYGON((0 0, 0 10, 10 10, 10 0, 0 0))");
     geom2_ = GEOSGeomFromWKT("POLYGON((2 2, 2 3, 3 3, 3 2, 2 2))");
     prepGeom1_ = GEOSPrepare(geom1_);
@@ -100,16 +101,17 @@ namespace tut
     int ret = GEOSPreparedContainsProperly(prepGeom1_, geom2_);
     ensure_equals(ret, 1);
 
-    }
+}
 
-    // Test PreparedContainsProperly
-    // Taken from regress/regress_ogc_prep.sql of postgis
-    // as of revno 3936
-    // ref: containsproperly200 (b)
-    template<>
-    template<>
-    void object::test<3>()
-    {
+// Test PreparedContainsProperly
+// Taken from regress/regress_ogc_prep.sql of postgis
+// as of revno 3936
+// ref: containsproperly200 (b)
+template<>
+template<>
+void object::test<3>
+()
+{
     geom1_ = GEOSGeomFromWKT("POLYGON((2 2, 2 3, 3 3, 3 2, 2 2))");
     geom2_ = GEOSGeomFromWKT("POLYGON((0 0, 0 10, 10 10, 10 0, 0 0))");
     prepGeom1_ = GEOSPrepare(geom1_);
@@ -119,16 +121,17 @@ namespace tut
     int ret = GEOSPreparedContainsProperly(prepGeom1_, geom2_);
     ensure_equals(ret, 0);
 
-    }
+}
 
-    // Test PreparedIntersects
-    // Also used as a linestring leakage reported
-    // by http://trac.osgeo.org/geos/ticket/305
-    //
-    template<>
-    template<>
-    void object::test<4>()
-    {
+// Test PreparedIntersects
+// Also used as a linestring leakage reported
+// by http://trac.osgeo.org/geos/ticket/305
+//
+template<>
+template<>
+void object::test<4>
+()
+{
     geom1_ = GEOSGeomFromWKT("LINESTRING(0 0, 10 10)");
     geom2_ = GEOSGeomFromWKT("LINESTRING(0 10, 10 0)");
     prepGeom1_ = GEOSPrepare(geom1_);
@@ -138,13 +141,14 @@ namespace tut
     int ret = GEOSPreparedIntersects(prepGeom1_, geom2_);
     ensure_equals(ret, 1);
 
-    }
+}
 
-    // Test PreparedCovers
-    template<>
-    template<>
-    void object::test<5>()
-    {
+// Test PreparedCovers
+template<>
+template<>
+void object::test<5>
+()
+{
     geom1_ = GEOSGeomFromWKT("POLYGON((0 0, 0 10, 10 11, 10 0, 0 0))");
     geom2_ = GEOSGeomFromWKT("POLYGON((0 0, 2 0, 2 2, 0 2, 0 0))");
     prepGeom1_ = GEOSPrepare(geom1_);
@@ -154,13 +158,14 @@ namespace tut
     int ret = GEOSPreparedCovers(prepGeom1_, geom2_);
     ensure_equals(ret, 1);
 
-    }
+}
 
-    // Test PreparedContains
-    template<>
-    template<>
-    void object::test<6>()
-    {
+// Test PreparedContains
+template<>
+template<>
+void object::test<6>
+()
+{
     geom1_ = GEOSGeomFromWKT("POLYGON((0 0, 0 10, 10 11, 10 0, 0 0))");
     geom2_ = GEOSGeomFromWKT("POLYGON((0 0, 2 0, 2 2, 0 2, 0 0))");
     prepGeom1_ = GEOSPrepare(geom1_);
@@ -170,210 +175,222 @@ namespace tut
     int ret = GEOSPreparedContains(prepGeom1_, geom2_);
     ensure_equals(ret, 1);
 
-    }
+}
+
+// Test PreparedIntersects: point on segment with FLOAT PM
+// X coordinate of 3rd and 4th vertises of the line are not
+// float-point exact with X coordinate of the point.
+// The X values differ after 14th decimal place:
+// POINT (-23.1094689600055080 50.5195368635957180)
+// --------------------^^^^^^^------------^^^^^^^^
+// LINESTRING 3rd and 4th points
+//        -23.1094689600055150 50.5223376452201340,
+//        -23.1094689600055010 50.5169177629559480,
+// --------------------^^^^^^^------------^^^^^^^^
+// So, in float-point precision model, the point does DOES NOT intersect the segment.
+// See RobustLineIntersectorTest.cpp for similar test cases.
+template<>
+template<>
+void object::test<7>
+()
+{
+    // POINT located between 3rd and 4th vertex of LINESTRING
+    // POINT(-23.1094689600055080 50.5195368635957180)
+    std::string point("01010000009a266328061c37c0e21a172f80424940");
+    // LINESTRING(-23.122057005539 50.5201976774794,-23.1153476966995 50.5133404815199,-23.1094689600055150 50.5223376452201340,-23.1094689600055010 50.5169177629559480,-23.0961967920942 50.5330464848094,-23.0887991006034 50.5258515213185,-23.0852302622362 50.5264582238409)
+    std::string
+    line("0102000000070000009909bf203f1f37c05c1d66d6954249404afe386d871d37c0a7eb1124b54149409c266328061c37c056d8bff5db42494098266328061c37c0034f7b5c2a42494060065c5aa01837c08ac001de3a4449408401b189bb1637c0b04e471a4f43494014ef84a6d11537c0b20dabfb62434940");
+    geom1_ = GEOSGeomFromHEX_buf(reinterpret_cast<const unsigned char*>(line.data()), line.size());
+    geom2_ = GEOSGeomFromHEX_buf(reinterpret_cast<const unsigned char*>(point.data()), point.size());
+
+    prepGeom1_ = GEOSPrepare(geom1_);
+    ensure(nullptr != prepGeom1_);
+    int ret = GEOSPreparedIntersects(prepGeom1_, geom2_);
+    ensure_equals(ret, 0);
+}
+
+// Test PreparedIntersects: point on segment with FIXED PM
+// X coordinate of 3rd and 4th vertices of the line are not
+// float-point exact with X coordinate of the point.
+// The X values differ after 14th decimal place:
+// POINT (-23.1094689600055080 50.5195368635957180)
+// --------------------^^^^^^^------------^^^^^^^^
+// LINESTRING 3rd and 4th points
+//        -23.1094689600055150 50.5223376452201340,
+//        -23.1094689600055010 50.5169177629559480,
+// --------------------^^^^^^^------------^^^^^^^^
+// So, if float-point values are trimmed up to 14 decimal digits, the point DOES intersect the segment.
+// See RobustLineIntersectorTest.cpp for similar test cases.
+template<>
+template<>
+void object::test<8>
+()
+{
+    geos::geom::PrecisionModel pm(1e+13);
+    geos::geom::GeometryFactory::Ptr factory = geos::geom::GeometryFactory::create(&pm);
+    geos::io::WKBReader reader(*factory);
+
+    // POINT located between 3rd and 4th vertex of LINESTRING
+    // POINT(-23.1094689600055080 50.5195368635957180)
+    std::string point("01010000009a266328061c37c0e21a172f80424940");
+    // LINESTRING(-23.122057005539 50.5201976774794,-23.1153476966995 50.5133404815199,-23.1094689600055150 50.5223376452201340,-23.1094689600055010 50.5169177629559480,-23.0961967920942 50.5330464848094,-23.0887991006034 50.5258515213185,-23.0852302622362 50.5264582238409)
+    std::string
+    line("0102000000070000009909bf203f1f37c05c1d66d6954249404afe386d871d37c0a7eb1124b54149409c266328061c37c056d8bff5db42494098266328061c37c0034f7b5c2a42494060065c5aa01837c08ac001de3a4449408401b189bb1637c0b04e471a4f43494014ef84a6d11537c0b20dabfb62434940");
+    std::stringstream sPoint(point);
+    geom2_ = reinterpret_cast<GEOSGeometry*>(reader.readHEX(sPoint));
+    std::stringstream sLine(line);
+    geom1_ = reinterpret_cast<GEOSGeometry*>(reader.readHEX(sLine));
+
+    prepGeom1_ = GEOSPrepare(geom1_);
+    ensure(nullptr != prepGeom1_);
+    int ret = GEOSPreparedIntersects(prepGeom1_, geom2_);
+    ensure_equals(ret, 1);
+}
 
-    // Test PreparedIntersects: point on segment with FLOAT PM
-    // X coordinate of 3rd and 4th vertises of the line are not
-    // float-point exact with X coordinate of the point.
-    // The X values differ after 14th decimal place:
-    // POINT (-23.1094689600055080 50.5195368635957180)
-    // --------------------^^^^^^^------------^^^^^^^^
-    // LINESTRING 3rd and 4th points
-    //        -23.1094689600055150 50.5223376452201340,
-    //        -23.1094689600055010 50.5169177629559480,
-    // --------------------^^^^^^^------------^^^^^^^^
-    // So, in float-point precision model, the point does DOES NOT intersect the segment.
-    // See RobustLineIntersectorTest.cpp for similar test cases.
-    template<>
-    template<>
-    void object::test<7>()
+// Test PreparedIntersects: point on vertex (default FLOAT PM)
+template<>
+template<>
+void object::test<9>
+()
+{
+    // POINT located on the 3rd vertex of LINESTRING
+    // POINT(-23.1094689600055 50.5223376452201)
+    std::string point("01010000009c266328061c37c056d8bff5db424940");
+    // LINESTRING(-23.122057005539 50.5201976774794,-23.1153476966995 50.5133404815199,-23.1094689600055 50.5223376452201,-23.1094689600055 50.5169177629559,-23.0961967920942 50.5330464848094,-23.0887991006034 50.5258515213185,-23.0852302622362 50.5264582238409)
+    std::string
+    line("0102000000070000009909bf203f1f37c05c1d66d6954249404afe386d871d37c0a7eb1124b54149409c266328061c37c056d8bff5db42494098266328061c37c0034f7b5c2a42494060065c5aa01837c08ac001de3a4449408401b189bb1637c0b04e471a4f43494014ef84a6d11537c0b20dabfb62434940");
+    geom1_ = GEOSGeomFromHEX_buf(reinterpret_cast<const unsigned char*>(line.data()), line.size());
+    geom2_ = GEOSGeomFromHEX_buf(reinterpret_cast<const unsigned char*>(point.data()), point.size());
+    prepGeom1_ = GEOSPrepare(geom1_);
+    ensure(nullptr != prepGeom1_);
+
+    int ret = GEOSPreparedIntersects(prepGeom1_, geom2_);
+    ensure_equals(ret, 1);
+}
+
+// Test outer polygon contains inner polygon with two coincident vertices
+// with results compared depending on precision used with FIXED PMs.
+template<>
+template<>
+void object::test<10>
+()
+{
+    // Coincident vertives of both polygons at
+    // -700.67089999181 93743.4218587986, -713.450135807349 93754.1677576647,
+    std::string const
+    outer("01030000800100000009000000af9dd0005ee585c0f802efbff6e2f6400000000000000000955acde0994b86c039a922afa2e3f64000000000000000002af6fb4f5d1887c07adb1c4071e3f6400000000000000000e5962b388d4f87c0bd3aeda7bae2f640000000000000000087c61344030887c07d585e6ff6e1f6400000000000000000fc8a31b5166186c0230588b20ae1f640000000000000000034733daf050186c0ed9f3ac98ae1f6400000000000000000f190aef659b385c0df2876538ce2f6400000000000000000af9dd0005ee585c0f802efbff6e2f6400000000000000000");
+    std::string const
+    inner("0103000080010000000a000000ac21f88bbaff86c05f45d8c7b4e2f6400000000000000000467f1177ebf386c05de1971187e2f6400000000000000000fcf677888fc886c04e855a544be2f6400000000000000000c61226e540b686c0c0662d1fe7e1f640000000000000000042dc1bece8a486c09b85529f8ae1f6400000000000000000891047cde55e86c038cfa59c4ee1f6400000000000000000ae9dd0005ee585c0fa02efbff6e2f6400000000000000000975acde0994b86c038a922afa2e3f6400000000000000000287e339b09f986c01b1a083a10e3f6400000000000000000ac21f88bbaff86c05f45d8c7b4e2f6400000000000000000");
+
+    // A contains B if precision is limited to 1e+10
     {
-        // POINT located between 3rd and 4th vertex of LINESTRING
-        // POINT(-23.1094689600055080 50.5195368635957180)
-        std::string point("01010000009a266328061c37c0e21a172f80424940");
-        // LINESTRING(-23.122057005539 50.5201976774794,-23.1153476966995 50.5133404815199,-23.1094689600055150 50.5223376452201340,-23.1094689600055010 50.5169177629559480,-23.0961967920942 50.5330464848094,-23.0887991006034 50.5258515213185,-23.0852302622362 50.5264582238409)
-        std::string line("0102000000070000009909bf203f1f37c05c1d66d6954249404afe386d871d37c0a7eb1124b54149409c266328061c37c056d8bff5db42494098266328061c37c0034f7b5c2a42494060065c5aa01837c08ac001de3a4449408401b189bb1637c0b04e471a4f43494014ef84a6d11537c0b20dabfb62434940");
-        geom1_ = GEOSGeomFromHEX_buf(reinterpret_cast<const unsigned char*>(line.data()), line.size());
-        geom2_ = GEOSGeomFromHEX_buf(reinterpret_cast<const unsigned char*>(point.data()), point.size());
+        geos::geom::PrecisionModel pm(1e+10); // NOTE: higher precision fails this test case
+        geos::geom::GeometryFactory::Ptr factory = geos::geom::GeometryFactory::create(&pm);
+        geos::io::WKBReader reader(*factory);
 
+        std::istringstream sOuter(outer);
+        geom1_ = reinterpret_cast<GEOSGeometry*>(reader.readHEX(sOuter));
+        std::istringstream sInner(inner);
+        geom2_ = reinterpret_cast<GEOSGeometry*>(reader.readHEX(sInner));
+        ensure(nullptr != geom1_);
+        ensure(nullptr != geom2_);
         prepGeom1_ = GEOSPrepare(geom1_);
         ensure(nullptr != prepGeom1_);
-        int ret = GEOSPreparedIntersects(prepGeom1_, geom2_);
+
+        int ret = GEOSPreparedContains(prepGeom1_, geom2_);
+        ensure_equals(ret, 1);
+        ret = GEOSPreparedContainsProperly(prepGeom1_, geom2_);
         ensure_equals(ret, 0);
+
+        GEOSGeom_destroy(geom1_);
+        GEOSGeom_destroy(geom2_);
+        GEOSPreparedGeom_destroy(prepGeom1_);
     }
 
-    // Test PreparedIntersects: point on segment with FIXED PM
-    // X coordinate of 3rd and 4th vertices of the line are not
-    // float-point exact with X coordinate of the point.
-    // The X values differ after 14th decimal place:
-    // POINT (-23.1094689600055080 50.5195368635957180)
-    // --------------------^^^^^^^------------^^^^^^^^
-    // LINESTRING 3rd and 4th points
-    //        -23.1094689600055150 50.5223376452201340,
-    //        -23.1094689600055010 50.5169177629559480,
-    // --------------------^^^^^^^------------^^^^^^^^
-    // So, if float-point values are trimmed up to 14 decimal digits, the point DOES intersect the segment.
-    // See RobustLineIntersectorTest.cpp for similar test cases.
-    template<>
-    template<>
-    void object::test<8>()
+    // A does NOT contain B if precision is extended to 1e+11 or beyond
     {
-        geos::geom::PrecisionModel pm(1e+13);
+        geos::geom::PrecisionModel pm(1e+11);
         geos::geom::GeometryFactory::Ptr factory = geos::geom::GeometryFactory::create(&pm);
         geos::io::WKBReader reader(*factory);
 
-        // POINT located between 3rd and 4th vertex of LINESTRING
-        // POINT(-23.1094689600055080 50.5195368635957180)
-        std::string point("01010000009a266328061c37c0e21a172f80424940");
-        // LINESTRING(-23.122057005539 50.5201976774794,-23.1153476966995 50.5133404815199,-23.1094689600055150 50.5223376452201340,-23.1094689600055010 50.5169177629559480,-23.0961967920942 50.5330464848094,-23.0887991006034 50.5258515213185,-23.0852302622362 50.5264582238409)
-        std::string line("0102000000070000009909bf203f1f37c05c1d66d6954249404afe386d871d37c0a7eb1124b54149409c266328061c37c056d8bff5db42494098266328061c37c0034f7b5c2a42494060065c5aa01837c08ac001de3a4449408401b189bb1637c0b04e471a4f43494014ef84a6d11537c0b20dabfb62434940");
-        std::stringstream sPoint(point);
-        geom2_ = reinterpret_cast<GEOSGeometry*>(reader.readHEX(sPoint));
-        std::stringstream sLine(line);
-        geom1_ = reinterpret_cast<GEOSGeometry*>(reader.readHEX(sLine));
-
+        std::istringstream sOuter(outer);
+        geom1_ = reinterpret_cast<GEOSGeometry*>(reader.readHEX(sOuter));
+        std::istringstream sInner(inner);
+        geom2_ = reinterpret_cast<GEOSGeometry*>(reader.readHEX(sInner));
+        ensure(nullptr != geom1_);
+        ensure(nullptr != geom2_);
         prepGeom1_ = GEOSPrepare(geom1_);
         ensure(nullptr != prepGeom1_);
-        int ret = GEOSPreparedIntersects(prepGeom1_, geom2_);
-        ensure_equals(ret, 1);
-    }
 
-    // Test PreparedIntersects: point on vertex (default FLOAT PM)
-    template<>
-    template<>
-    void object::test<9>()
+        int ret = GEOSPreparedContains(prepGeom1_, geom2_);
+        ensure_equals(ret, 0);
+        ret = GEOSPreparedContainsProperly(prepGeom1_, geom2_);
+        ensure_equals(ret, 0);
+    }
+}
+
+// Test outer rectangle contains inner rectangle with one coincident vertex
+// and two vertices of the inner rectangle are on the boundary (lay on segments)
+// of the outer rectangle.
+// Precision model should not affect the containment test result.
+template<>
+template<>
+void object::test<11>
+()
+{
+    // Coincident vertext at -753.167968418005 93709.4279185742
+    //POLYGON ((-753.167968418005 93754.0955183194,-816.392328351464 93754.0955183194,-816.392328351464 93709.4279185742,-753.167968418005 93709.4279185742,-753.167968418005 93754.0955183194))
+    std::string const
+    outer("01030000800100000005000000bd70d3ff578987c09e373e87a1e3f6400000000000000000a9f60b7d238389c09e373e87a1e3f6400000000000000000a9f60b7d238389c09625c1d8d6e0f6400000000000000000bd70d3ff578987c09625c1d8d6e0f6400000000000000000bd70d3ff578987c09e373e87a1e3f6400000000000000000");
+    //POLYGON ((-753.167968418005 93747.6909727677,-799.641978447015 93747.6909727677,-799.641978447015 93709.4279185742,-753.167968418005 93709.4279185742,-753.167968418005 93747.6909727677))
+    std::string const
+    inner("01030000800100000005000000bd70d3ff578987c0f875390e3be3f6400000000000000000579598c522fd88c0f875390e3be3f6400000000000000000579598c522fd88c09625c1d8d6e0f6400000000000000000bd70d3ff578987c09625c1d8d6e0f6400000000000000000bd70d3ff578987c0f875390e3be3f6400000000000000000");
+
+    // A contains B if precision is limited to 1e+10
     {
-        // POINT located on the 3rd vertex of LINESTRING
-        // POINT(-23.1094689600055 50.5223376452201)
-        std::string point("01010000009c266328061c37c056d8bff5db424940");
-        // LINESTRING(-23.122057005539 50.5201976774794,-23.1153476966995 50.5133404815199,-23.1094689600055 50.5223376452201,-23.1094689600055 50.5169177629559,-23.0961967920942 50.5330464848094,-23.0887991006034 50.5258515213185,-23.0852302622362 50.5264582238409)
-        std::string line("0102000000070000009909bf203f1f37c05c1d66d6954249404afe386d871d37c0a7eb1124b54149409c266328061c37c056d8bff5db42494098266328061c37c0034f7b5c2a42494060065c5aa01837c08ac001de3a4449408401b189bb1637c0b04e471a4f43494014ef84a6d11537c0b20dabfb62434940");
-        geom1_ = GEOSGeomFromHEX_buf(reinterpret_cast<const unsigned char*>(line.data()), line.size());
-        geom2_ = GEOSGeomFromHEX_buf(reinterpret_cast<const unsigned char*>(point.data()), point.size());
+        geos::geom::PrecisionModel pm(1e+10);
+        geos::geom::GeometryFactory::Ptr factory = geos::geom::GeometryFactory::create(&pm);
+        geos::io::WKBReader reader(*factory);
+
+        std::istringstream sOuter(outer);
+        geom1_ = reinterpret_cast<GEOSGeometry*>(reader.readHEX(sOuter));
+        std::istringstream sInner(inner);
+        geom2_ = reinterpret_cast<GEOSGeometry*>(reader.readHEX(sInner));
+        ensure(nullptr != geom1_);
+        ensure(nullptr != geom2_);
         prepGeom1_ = GEOSPrepare(geom1_);
         ensure(nullptr != prepGeom1_);
 
-        int ret = GEOSPreparedIntersects(prepGeom1_, geom2_);
+        int ret = GEOSPreparedContains(prepGeom1_, geom2_);
         ensure_equals(ret, 1);
-    }
+        ret = GEOSPreparedContainsProperly(prepGeom1_, geom2_);
+        ensure_equals(ret, 0);
 
-    // Test outer polygon contains inner polygon with two coincident vertices
-    // with results compared depending on precision used with FIXED PMs.
-    template<>
-    template<>
-    void object::test<10>()
-    {
-        // Coincident vertives of both polygons at
-        // -700.67089999181 93743.4218587986, -713.450135807349 93754.1677576647,
-        std::string const outer("01030000800100000009000000af9dd0005ee585c0f802efbff6e2f6400000000000000000955acde0994b86c039a922afa2e3f64000000000000000002af6fb4f5d1887c07adb1c4071e3f6400000000000000000e5962b388d4f87c0bd3aeda7bae2f640000000000000000087c61344030887c07d585e6ff6e1f6400000000000000000fc8a31b5166186c0230588b20ae1f640000000000000000034733daf050186c0ed9f3ac98ae1f6400000000000000000f190aef659b385c0df2876538ce2f6400000000000000000af9dd0005ee585c0f802efbff6e2f6400000000000000000");
-        std::string const inner("0103000080010000000a000000ac21f88bbaff86c05f45d8c7b4e2f6400000000000000000467f1177ebf386c05de1971187e2f6400000000000000000fcf677888fc886c04e855a544be2f6400000000000000000c61226e540b686c0c0662d1fe7e1f640000000000000000042dc1bece8a486c09b85529f8ae1f6400000000000000000891047cde55e86c038cfa59c4ee1f6400000000000000000ae9dd0005ee585c0fa02efbff6e2f6400000000000000000975acde0994b86c038a922afa2e3f6400000000000000000287e339b09f986c01b1a083a10e3f6400000000000000000ac21f88bbaff86c05f45d8c7b4e2f6400000000000000000");
-
-        // A contains B if precision is limited to 1e+10
-        {
-            geos::geom::PrecisionModel pm(1e+10); // NOTE: higher precision fails this test case
-            geos::geom::GeometryFactory::Ptr factory = geos::geom::GeometryFactory::create(&pm);
-            geos::io::WKBReader reader(*factory);
-
-            std::istringstream sOuter(outer);
-            geom1_ = reinterpret_cast<GEOSGeometry*>(reader.readHEX(sOuter));
-            std::istringstream sInner(inner);
-            geom2_ = reinterpret_cast<GEOSGeometry*>(reader.readHEX(sInner));
-            ensure(nullptr != geom1_);
-            ensure(nullptr != geom2_);
-            prepGeom1_ = GEOSPrepare(geom1_);
-            ensure(nullptr != prepGeom1_);
-
-            int ret = GEOSPreparedContains(prepGeom1_, geom2_);
-            ensure_equals(ret, 1);
-            ret = GEOSPreparedContainsProperly(prepGeom1_, geom2_);
-            ensure_equals(ret, 0);
-
-            GEOSGeom_destroy(geom1_);
-            GEOSGeom_destroy(geom2_);
-            GEOSPreparedGeom_destroy(prepGeom1_);
-        }
-
-        // A does NOT contain B if precision is extended to 1e+11 or beyond
-        {
-            geos::geom::PrecisionModel pm(1e+11);
-            geos::geom::GeometryFactory::Ptr factory = geos::geom::GeometryFactory::create(&pm);
-            geos::io::WKBReader reader(*factory);
-
-            std::istringstream sOuter(outer);
-            geom1_ = reinterpret_cast<GEOSGeometry*>(reader.readHEX(sOuter));
-            std::istringstream sInner(inner);
-            geom2_ = reinterpret_cast<GEOSGeometry*>(reader.readHEX(sInner));
-            ensure(nullptr != geom1_);
-            ensure(nullptr != geom2_);
-            prepGeom1_ = GEOSPrepare(geom1_);
-            ensure(nullptr != prepGeom1_);
-
-            int ret = GEOSPreparedContains(prepGeom1_, geom2_);
-            ensure_equals(ret, 0);
-            ret = GEOSPreparedContainsProperly(prepGeom1_, geom2_);
-            ensure_equals(ret, 0);
-        }
+        GEOSGeom_destroy(geom1_);
+        GEOSGeom_destroy(geom2_);
+        GEOSPreparedGeom_destroy(prepGeom1_);
     }
 
-    // Test outer rectangle contains inner rectangle with one coincident vertex
-    // and two vertices of the inner rectangle are on the boundary (lay on segments)
-    // of the outer rectangle.
-    // Precision model should not affect the containment test result.
-    template<>
-    template<>
-    void object::test<11>()
+    // A contains B if FLOATING PM is used with extended precision
     {
-        // Coincident vertext at -753.167968418005 93709.4279185742
-        //POLYGON ((-753.167968418005 93754.0955183194,-816.392328351464 93754.0955183194,-816.392328351464 93709.4279185742,-753.167968418005 93709.4279185742,-753.167968418005 93754.0955183194))
-        std::string const outer("01030000800100000005000000bd70d3ff578987c09e373e87a1e3f6400000000000000000a9f60b7d238389c09e373e87a1e3f6400000000000000000a9f60b7d238389c09625c1d8d6e0f6400000000000000000bd70d3ff578987c09625c1d8d6e0f6400000000000000000bd70d3ff578987c09e373e87a1e3f6400000000000000000");
-        //POLYGON ((-753.167968418005 93747.6909727677,-799.641978447015 93747.6909727677,-799.641978447015 93709.4279185742,-753.167968418005 93709.4279185742,-753.167968418005 93747.6909727677))
-        std::string const inner("01030000800100000005000000bd70d3ff578987c0f875390e3be3f6400000000000000000579598c522fd88c0f875390e3be3f6400000000000000000579598c522fd88c09625c1d8d6e0f6400000000000000000bd70d3ff578987c09625c1d8d6e0f6400000000000000000bd70d3ff578987c0f875390e3be3f6400000000000000000");
-
-        // A contains B if precision is limited to 1e+10
-        {
-            geos::geom::PrecisionModel pm(1e+10);
-            geos::geom::GeometryFactory::Ptr factory = geos::geom::GeometryFactory::create(&pm);
-            geos::io::WKBReader reader(*factory);
-
-            std::istringstream sOuter(outer);
-            geom1_ = reinterpret_cast<GEOSGeometry*>(reader.readHEX(sOuter));
-            std::istringstream sInner(inner);
-            geom2_ = reinterpret_cast<GEOSGeometry*>(reader.readHEX(sInner));
-            ensure(nullptr != geom1_);
-            ensure(nullptr != geom2_);
-            prepGeom1_ = GEOSPrepare(geom1_);
-            ensure(nullptr != prepGeom1_);
-
-            int ret = GEOSPreparedContains(prepGeom1_, geom2_);
-            ensure_equals(ret, 1);
-            ret = GEOSPreparedContainsProperly(prepGeom1_, geom2_);
-            ensure_equals(ret, 0);
-
-            GEOSGeom_destroy(geom1_);
-            GEOSGeom_destroy(geom2_);
-            GEOSPreparedGeom_destroy(prepGeom1_);
-        }
-
-        // A contains B if FLOATING PM is used with extended precision
-        {
-            geos::geom::PrecisionModel pm;
-            geos::geom::GeometryFactory::Ptr factory = geos::geom::GeometryFactory::create(&pm);
-            geos::io::WKBReader reader(*factory);
-
-            std::istringstream sOuter(outer);
-            geom1_ = reinterpret_cast<GEOSGeometry*>(reader.readHEX(sOuter));
-            std::istringstream sInner(inner);
-            geom2_ = reinterpret_cast<GEOSGeometry*>(reader.readHEX(sInner));
-            ensure(nullptr != geom1_);
-            ensure(nullptr != geom2_);
-            prepGeom1_ = GEOSPrepare(geom1_);
-            ensure(nullptr != prepGeom1_);
-
-            int ret = GEOSPreparedContains(prepGeom1_, geom2_);
-            ensure_equals(ret, 1);
-            ret = GEOSPreparedContainsProperly(prepGeom1_, geom2_);
-            ensure_equals(ret, 0);
-        }
+        geos::geom::PrecisionModel pm;
+        geos::geom::GeometryFactory::Ptr factory = geos::geom::GeometryFactory::create(&pm);
+        geos::io::WKBReader reader(*factory);
+
+        std::istringstream sOuter(outer);
+        geom1_ = reinterpret_cast<GEOSGeometry*>(reader.readHEX(sOuter));
+        std::istringstream sInner(inner);
+        geom2_ = reinterpret_cast<GEOSGeometry*>(reader.readHEX(sInner));
+        ensure(nullptr != geom1_);
+        ensure(nullptr != geom2_);
+        prepGeom1_ = GEOSPrepare(geom1_);
+        ensure(nullptr != prepGeom1_);
+
+        int ret = GEOSPreparedContains(prepGeom1_, geom2_);
+        ensure_equals(ret, 1);
+        ret = GEOSPreparedContainsProperly(prepGeom1_, geom2_);
+        ensure_equals(ret, 0);
     }
+}
 } // namespace tut
 
diff --git a/tests/unit/capi/GEOSRelateBoundaryNodeRuleTest.cpp b/tests/unit/capi/GEOSRelateBoundaryNodeRuleTest.cpp
index 95ecf35..de08067 100644
--- a/tests/unit/capi/GEOSRelateBoundaryNodeRuleTest.cpp
+++ b/tests/unit/capi/GEOSRelateBoundaryNodeRuleTest.cpp
@@ -9,149 +9,156 @@
 #include <cstdio>
 #include <cstdlib>
 
-namespace tut
-{
-    //
-    // Test Group
-    //
+namespace tut {
+//
+// Test Group
+//
 
-    // Common data used in test cases.
-    struct test_capigeosrelateboundarynoderule_data
-    {
-        GEOSGeometry* geom1_;
-        GEOSGeometry* geom2_;
-	char* pat_;
-
-        static void notice(const char *fmt, ...)
-        {
-            std::fprintf( stdout, "NOTICE: ");
-
-            va_list ap;
-            va_start(ap, fmt);
-            std::vfprintf(stdout, fmt, ap);
-            va_end(ap);
-
-            std::fprintf(stdout, "\n");
-        }
-
-        test_capigeosrelateboundarynoderule_data()
-            : geom1_(nullptr), geom2_(nullptr), pat_(nullptr)
-        {
-            initGEOS(notice, notice);
-        }
-
-        ~test_capigeosrelateboundarynoderule_data()
-        {
-            GEOSGeom_destroy(geom1_);
-            GEOSGeom_destroy(geom2_);
-            GEOSFree(pat_);
-            finishGEOS();
-        }
-
-    };
-
-    typedef test_group<test_capigeosrelateboundarynoderule_data> group;
-    typedef group::object object;
-
-    group test_capigeosrelateboundarynoderule_group("capi::GEOSRelateBoundaryNodeRule");
-
-    //
-    // Test Cases
-    //
-
-    // Closed line touching open line on endpoint with OGC rule
-    template<>
-    template<>
-    void object::test<1>()
-    {
-        geom1_ = GEOSGeomFromWKT("LINESTRING(0 0, 10 0, 10 10, 0 0)");
-        geom2_ = GEOSGeomFromWKT("LINESTRING(0 0, 0 -10)");
-        pat_ = GEOSRelateBoundaryNodeRule(geom1_, geom2_, GEOSRELATE_BNR_OGC);
-	ensure_equals(std::string(pat_), std::string("F01FFF102"));
-    }
+// Common data used in test cases.
+struct test_capigeosrelateboundarynoderule_data {
+    GEOSGeometry* geom1_;
+    GEOSGeometry* geom2_;
+    char* pat_;
 
-    // Closed line touching open line on endpoint with MOD2 rule
-    template<>
-    template<>
-    void object::test<2>()
+    static void
+    notice(const char* fmt, ...)
     {
-        geom1_ = GEOSGeomFromWKT("LINESTRING(0 0, 10 0, 10 10, 0 0)");
-        geom2_ = GEOSGeomFromWKT("LINESTRING(0 0, 0 -10)");
-        pat_ = GEOSRelateBoundaryNodeRule(geom1_, geom2_, GEOSRELATE_BNR_MOD2);
-	ensure_equals(std::string(pat_), std::string("F01FFF102"));
-    }
+        std::fprintf(stdout, "NOTICE: ");
 
-    // Closed line touching open line on endpoint with ENDPOINT rule
-    template<>
-    template<>
-    void object::test<3>()
-    {
-        geom1_ = GEOSGeomFromWKT("LINESTRING(0 0, 10 0, 10 10, 0 0)");
-        geom2_ = GEOSGeomFromWKT("LINESTRING(0 0, 0 -10)");
-        pat_ = GEOSRelateBoundaryNodeRule(geom1_, geom2_,
-		GEOSRELATE_BNR_ENDPOINT);
-	ensure_equals(std::string(pat_), std::string("FF1F0F102"));
-    }
+        va_list ap;
+        va_start(ap, fmt);
+        std::vfprintf(stdout, fmt, ap);
+        va_end(ap);
 
-    // Noded multiline touching line on node , MOD2 rule
-    template<>
-    template<>
-    void object::test<4>()
-    {
-        geom1_ = GEOSGeomFromWKT("MULTILINESTRING((0 0, 10 0),(10 0, 10 10))");
-        geom2_ = GEOSGeomFromWKT("LINESTRING(10 0, 10 -10)");
-        pat_ = GEOSRelateBoundaryNodeRule(geom1_, geom2_,
-		GEOSRELATE_BNR_MOD2);
-	ensure_equals(std::string(pat_), std::string("F01FF0102"));
+        std::fprintf(stdout, "\n");
     }
 
-    // Noded multiline touching line on node , ENDPOINT rule
-    template<>
-    template<>
-    void object::test<5>()
+    test_capigeosrelateboundarynoderule_data()
+        : geom1_(nullptr), geom2_(nullptr), pat_(nullptr)
     {
-        geom1_ = GEOSGeomFromWKT("MULTILINESTRING((0 0, 10 0),(10 0, 10 10))");
-        geom2_ = GEOSGeomFromWKT("LINESTRING(10 0, 10 -10)");
-        pat_ = GEOSRelateBoundaryNodeRule(geom1_, geom2_,
-		GEOSRELATE_BNR_ENDPOINT);
-	ensure_equals(std::string(pat_), std::string("FF1F00102"));
+        initGEOS(notice, notice);
     }
 
-    // Noded multiline touching line on node , MULTIVALENT ENDPOINT rule
-    // NOTE: the single line has no boundary !
-    template<>
-    template<>
-    void object::test<6>()
+    ~test_capigeosrelateboundarynoderule_data()
     {
-        geom1_ = GEOSGeomFromWKT("MULTILINESTRING((0 0, 10 0),(10 0, 10 10))");
-        geom2_ = GEOSGeomFromWKT("LINESTRING(10 0, 10 -10)");
-        pat_ = GEOSRelateBoundaryNodeRule(geom1_, geom2_,
-		GEOSRELATE_BNR_MULTIVALENT_ENDPOINT);
-	ensure_equals(std::string(pat_), std::string("0F1FFF1F2"));
+        GEOSGeom_destroy(geom1_);
+        GEOSGeom_destroy(geom2_);
+        GEOSFree(pat_);
+        finishGEOS();
     }
 
-    // Noded multiline touching line on node , MONOVALENT ENDPOINT rule
-    template<>
-    template<>
-    void object::test<7>()
-    {
-        geom1_ = GEOSGeomFromWKT("MULTILINESTRING((0 0, 10 0),(10 0, 10 10))");
-        geom2_ = GEOSGeomFromWKT("LINESTRING(10 0, 10 -10)");
-        pat_ = GEOSRelateBoundaryNodeRule(geom1_, geom2_,
-		GEOSRELATE_BNR_MONOVALENT_ENDPOINT);
-	ensure_equals(std::string(pat_), std::string("F01FF0102"));
-    }
+};
 
-    // Invalid/unknown rule
-    template<>
-    template<>
-    void object::test<8>()
-    {
-        geom1_ = GEOSGeomFromWKT("MULTILINESTRING((0 0, 10 0),(10 0, 10 10))");
-        geom2_ = GEOSGeomFromWKT("LINESTRING(10 0, 10 -10)");
-        pat_ = GEOSRelateBoundaryNodeRule(geom1_, geom2_, 5);
-	ensure(nullptr == pat_);
-    }
+typedef test_group<test_capigeosrelateboundarynoderule_data> group;
+typedef group::object object;
+
+group test_capigeosrelateboundarynoderule_group("capi::GEOSRelateBoundaryNodeRule");
+
+//
+// Test Cases
+//
+
+// Closed line touching open line on endpoint with OGC rule
+template<>
+template<>
+void object::test<1>
+()
+{
+    geom1_ = GEOSGeomFromWKT("LINESTRING(0 0, 10 0, 10 10, 0 0)");
+    geom2_ = GEOSGeomFromWKT("LINESTRING(0 0, 0 -10)");
+    pat_ = GEOSRelateBoundaryNodeRule(geom1_, geom2_, GEOSRELATE_BNR_OGC);
+    ensure_equals(std::string(pat_), std::string("F01FFF102"));
+}
+
+// Closed line touching open line on endpoint with MOD2 rule
+template<>
+template<>
+void object::test<2>
+()
+{
+    geom1_ = GEOSGeomFromWKT("LINESTRING(0 0, 10 0, 10 10, 0 0)");
+    geom2_ = GEOSGeomFromWKT("LINESTRING(0 0, 0 -10)");
+    pat_ = GEOSRelateBoundaryNodeRule(geom1_, geom2_, GEOSRELATE_BNR_MOD2);
+    ensure_equals(std::string(pat_), std::string("F01FFF102"));
+}
+
+// Closed line touching open line on endpoint with ENDPOINT rule
+template<>
+template<>
+void object::test<3>
+()
+{
+    geom1_ = GEOSGeomFromWKT("LINESTRING(0 0, 10 0, 10 10, 0 0)");
+    geom2_ = GEOSGeomFromWKT("LINESTRING(0 0, 0 -10)");
+    pat_ = GEOSRelateBoundaryNodeRule(geom1_, geom2_,
+                                      GEOSRELATE_BNR_ENDPOINT);
+    ensure_equals(std::string(pat_), std::string("FF1F0F102"));
+}
+
+// Noded multiline touching line on node , MOD2 rule
+template<>
+template<>
+void object::test<4>
+()
+{
+    geom1_ = GEOSGeomFromWKT("MULTILINESTRING((0 0, 10 0),(10 0, 10 10))");
+    geom2_ = GEOSGeomFromWKT("LINESTRING(10 0, 10 -10)");
+    pat_ = GEOSRelateBoundaryNodeRule(geom1_, geom2_,
+                                      GEOSRELATE_BNR_MOD2);
+    ensure_equals(std::string(pat_), std::string("F01FF0102"));
+}
+
+// Noded multiline touching line on node , ENDPOINT rule
+template<>
+template<>
+void object::test<5>
+()
+{
+    geom1_ = GEOSGeomFromWKT("MULTILINESTRING((0 0, 10 0),(10 0, 10 10))");
+    geom2_ = GEOSGeomFromWKT("LINESTRING(10 0, 10 -10)");
+    pat_ = GEOSRelateBoundaryNodeRule(geom1_, geom2_,
+                                      GEOSRELATE_BNR_ENDPOINT);
+    ensure_equals(std::string(pat_), std::string("FF1F00102"));
+}
+
+// Noded multiline touching line on node , MULTIVALENT ENDPOINT rule
+// NOTE: the single line has no boundary !
+template<>
+template<>
+void object::test<6>
+()
+{
+    geom1_ = GEOSGeomFromWKT("MULTILINESTRING((0 0, 10 0),(10 0, 10 10))");
+    geom2_ = GEOSGeomFromWKT("LINESTRING(10 0, 10 -10)");
+    pat_ = GEOSRelateBoundaryNodeRule(geom1_, geom2_,
+                                      GEOSRELATE_BNR_MULTIVALENT_ENDPOINT);
+    ensure_equals(std::string(pat_), std::string("0F1FFF1F2"));
+}
+
+// Noded multiline touching line on node , MONOVALENT ENDPOINT rule
+template<>
+template<>
+void object::test<7>
+()
+{
+    geom1_ = GEOSGeomFromWKT("MULTILINESTRING((0 0, 10 0),(10 0, 10 10))");
+    geom2_ = GEOSGeomFromWKT("LINESTRING(10 0, 10 -10)");
+    pat_ = GEOSRelateBoundaryNodeRule(geom1_, geom2_,
+                                      GEOSRELATE_BNR_MONOVALENT_ENDPOINT);
+    ensure_equals(std::string(pat_), std::string("F01FF0102"));
+}
+
+// Invalid/unknown rule
+template<>
+template<>
+void object::test<8>
+()
+{
+    geom1_ = GEOSGeomFromWKT("MULTILINESTRING((0 0, 10 0),(10 0, 10 10))");
+    geom2_ = GEOSGeomFromWKT("LINESTRING(10 0, 10 -10)");
+    pat_ = GEOSRelateBoundaryNodeRule(geom1_, geom2_, 5);
+    ensure(nullptr == pat_);
+}
 
 
 
diff --git a/tests/unit/capi/GEOSRelatePatternMatchTest.cpp b/tests/unit/capi/GEOSRelatePatternMatchTest.cpp
index c7b1937..90549d4 100644
--- a/tests/unit/capi/GEOSRelatePatternMatchTest.cpp
+++ b/tests/unit/capi/GEOSRelatePatternMatchTest.cpp
@@ -9,93 +9,97 @@
 #include <cstdio>
 #include <cstdlib>
 
-namespace tut
-{
-    //
-    // Test Group
-    //
-
-    // Common data used in test cases.
-    struct test_capigeosrelatepatternmatch_data
-    {
-
-        static void notice(const char *fmt, ...)
-        {
-            std::fprintf( stdout, "NOTICE: ");
-
-            va_list ap;
-            va_start(ap, fmt);
-            std::vfprintf(stdout, fmt, ap);
-            va_end(ap);
-
-            std::fprintf(stdout, "\n");
-        }
-
-        test_capigeosrelatepatternmatch_data()
-        {
-            initGEOS(notice, notice);
-        }
-
-        ~test_capigeosrelatepatternmatch_data()
-        {
-            finishGEOS();
-        }
-
-    };
+namespace tut {
+//
+// Test Group
+//
 
-    typedef test_group<test_capigeosrelatepatternmatch_data> group;
-    typedef group::object object;
+// Common data used in test cases.
+struct test_capigeosrelatepatternmatch_data {
 
-    group test_capigeosrelatepatternmatch_group("capi::GEOSRelatePatternMatch");
+    static void
+    notice(const char* fmt, ...)
+    {
+        std::fprintf(stdout, "NOTICE: ");
 
-    //
-    // Test Cases
-    //
+        va_list ap;
+        va_start(ap, fmt);
+        std::vfprintf(stdout, fmt, ap);
+        va_end(ap);
 
-    template<>
-    template<>
-    void object::test<1>()
-    {
-        char ret = GEOSRelatePatternMatch("000000000", "*********");
-	ensure_equals(ret, char(1));
+        std::fprintf(stdout, "\n");
     }
 
-    template<>
-    template<>
-    void object::test<2>()
+    test_capigeosrelatepatternmatch_data()
     {
-        char ret = GEOSRelatePatternMatch("000000000", "TTTTTTTTT");
-	ensure_equals(ret, char(1));
+        initGEOS(notice, notice);
     }
 
-    template<>
-    template<>
-    void object::test<3>()
+    ~test_capigeosrelatepatternmatch_data()
     {
-        char ret = GEOSRelatePatternMatch("000000000", "000000000");
-	ensure_equals(ret, char(1));
+        finishGEOS();
     }
 
-    template<>
-    template<>
-    void object::test<4>()
-    {
-        char ret = GEOSRelatePatternMatch("000000000", "FFFFFFFFF");
-	ensure_equals(ret, char(0));
-    }
+};
 
-    template<>
-    template<>
-    void object::test<5>()
-    {
-        const char* mat = "012TF012F";
+typedef test_group<test_capigeosrelatepatternmatch_data> group;
+typedef group::object object;
 
-        char ret = GEOSRelatePatternMatch(mat, "TTTTFTTTF");
-	ensure_equals(ret, char(1));
+group test_capigeosrelatepatternmatch_group("capi::GEOSRelatePatternMatch");
 
-        ret = GEOSRelatePatternMatch(mat, "TT1TFTTTF");
-	ensure_equals(ret, char(0));
-    }
+//
+// Test Cases
+//
+
+template<>
+template<>
+void object::test<1>
+()
+{
+    char ret = GEOSRelatePatternMatch("000000000", "*********");
+    ensure_equals(ret, char(1));
+}
+
+template<>
+template<>
+void object::test<2>
+()
+{
+    char ret = GEOSRelatePatternMatch("000000000", "TTTTTTTTT");
+    ensure_equals(ret, char(1));
+}
+
+template<>
+template<>
+void object::test<3>
+()
+{
+    char ret = GEOSRelatePatternMatch("000000000", "000000000");
+    ensure_equals(ret, char(1));
+}
+
+template<>
+template<>
+void object::test<4>
+()
+{
+    char ret = GEOSRelatePatternMatch("000000000", "FFFFFFFFF");
+    ensure_equals(ret, char(0));
+}
+
+template<>
+template<>
+void object::test<5>
+()
+{
+    const char* mat = "012TF012F";
+
+    char ret = GEOSRelatePatternMatch(mat, "TTTTFTTTF");
+    ensure_equals(ret, char(1));
+
+    ret = GEOSRelatePatternMatch(mat, "TT1TFTTTF");
+    ensure_equals(ret, char(0));
+}
 
 } // namespace tut
 
diff --git a/tests/unit/capi/GEOSReverseTest.cpp b/tests/unit/capi/GEOSReverseTest.cpp
index 30d629d..76c60d4 100644
--- a/tests/unit/capi/GEOSReverseTest.cpp
+++ b/tests/unit/capi/GEOSReverseTest.cpp
@@ -8,131 +8,139 @@
 #include <cstdio>
 #include <cstdlib>
 
-namespace tut
-{
-    //
-    // Test Group
-    //
-
-    // Common data used in test cases.
-    struct test_capigeosreverse
-    {
-        static void notice(const char *fmt, ...)
-        {
-            std::fprintf( stdout, "NOTICE: ");
-
-            va_list ap;
-            va_start(ap, fmt);
-            std::vfprintf(stdout, fmt, ap);
-            va_end(ap);
-
-            std::fprintf(stdout, "\n");
-        }
-
-        test_capigeosreverse()
-        {
-            initGEOS(notice, notice);
-        }
-
-        ~test_capigeosreverse()
-        {
-            finishGEOS();
-        }
-    };
-
-    typedef test_group<test_capigeosreverse> group;
-    typedef group::object object;
-
-    group test_capigeosreverse_group("capi::GEOSReverse");
+namespace tut {
+//
+// Test Group
+//
 
-    void testReverse(const std::string & wkt_input,
-                     const std::string & wkt_output)
+// Common data used in test cases.
+struct test_capigeosreverse {
+    static void
+    notice(const char* fmt, ...)
     {
-        GEOSGeometry* input = GEOSGeomFromWKT(wkt_input.c_str());
-        GEOSGeometry* expected_result = GEOSGeomFromWKT(wkt_output.c_str());
-        GEOSGeometry* result = GEOSReverse(input);
+        std::fprintf(stdout, "NOTICE: ");
 
-        ensure(result != nullptr);
-        ensure_equals(1, GEOSEqualsExact(result, expected_result, 0.0));
+        va_list ap;
+        va_start(ap, fmt);
+        std::vfprintf(stdout, fmt, ap);
+        va_end(ap);
 
-        GEOSGeom_destroy(input);
-        GEOSGeom_destroy(expected_result);
-        GEOSGeom_destroy(result);
+        std::fprintf(stdout, "\n");
     }
 
-    //
-    // Test Cases
-    //
-    template<>
-    template<>
-    void object::test<1>()
+    test_capigeosreverse()
     {
-        testReverse("POINT (3 5)", "POINT (3 5)");
+        initGEOS(notice, notice);
     }
 
-    template<>
-    template<>
-    void object::test<2>()
+    ~test_capigeosreverse()
     {
-        testReverse("MULTIPOINT ((100 100), (10 100), (30 100))",
-                    "MULTIPOINT ((100 100), (10 100), (30 100))");
+        finishGEOS();
     }
+};
 
-    template<>
-    template<>
-    void object::test<3>()
-    {
-        testReverse("LINESTRING (200 200, 200 100)",
-                    "LINESTRING (200 100, 200 200)");
-    }
+typedef test_group<test_capigeosreverse> group;
+typedef group::object object;
 
-    template<>
-    template<>
-    void object::test<4>()
-    {
-        testReverse("MULTILINESTRING ((1 1, 2 2), (3 3, 4 4))",
-                    "MULTILINESTRING ((4 4, 3 3), (2 2, 1 1))");
-    }
+group test_capigeosreverse_group("capi::GEOSReverse");
 
-    template<>
-    template<>
-    void object::test<5>()
-    {
-        testReverse("POLYGON ((0 0, 10 0, 10 10, 0 10, 0 0), (1 1, 2 1, 2 2, 1 2, 1 1))",
-                    "POLYGON ((0 0, 0 10, 10 10, 10 0, 0 0), (1 1, 1 2, 2 2, 2 1, 1 1))");
+void
+testReverse(const std::string& wkt_input,
+            const std::string& wkt_output)
+{
+    GEOSGeometry* input = GEOSGeomFromWKT(wkt_input.c_str());
+    GEOSGeometry* expected_result = GEOSGeomFromWKT(wkt_output.c_str());
+    GEOSGeometry* result = GEOSReverse(input);
 
-    }
+    ensure(result != nullptr);
+    ensure_equals(1, GEOSEqualsExact(result, expected_result, 0.0));
 
-    template<>
-    template<>
-    void object::test<6>()
-    {
-        testReverse("MULTIPOLYGON (((0 0, 10 0, 10 10, 0 10, 0 0), (1 1, 2 1, 2 2, 1 2, 1 1)), ((100 100, 100 200, 200 200, 100 100)))",
-                    "MULTIPOLYGON (((0 0, 0 10, 10 10, 10 0, 0 0), (1 1, 1 2, 2 2, 2 1, 1 1)), ((100 100, 200 200, 100 200, 100 100)))");
+    GEOSGeom_destroy(input);
+    GEOSGeom_destroy(expected_result);
+    GEOSGeom_destroy(result);
+}
 
-    }
+//
+// Test Cases
+//
+template<>
+template<>
+void object::test<1>
+()
+{
+    testReverse("POINT (3 5)", "POINT (3 5)");
+}
 
-    template<>
-    template<>
-    void object::test<7>()
-    {
-        testReverse("GEOMETRYCOLLECTION (LINESTRING (1 1, 2 2), GEOMETRYCOLLECTION(LINESTRING (3 5, 2 9)))",
-                    "GEOMETRYCOLLECTION (LINESTRING (2 2, 1 1), GEOMETRYCOLLECTION(LINESTRING (2 9, 3 5)))");
+template<>
+template<>
+void object::test<2>
+()
+{
+    testReverse("MULTIPOINT ((100 100), (10 100), (30 100))",
+                "MULTIPOINT ((100 100), (10 100), (30 100))");
+}
+
+template<>
+template<>
+void object::test<3>
+()
+{
+    testReverse("LINESTRING (200 200, 200 100)",
+                "LINESTRING (200 100, 200 200)");
+}
+
+template<>
+template<>
+void object::test<4>
+()
+{
+    testReverse("MULTILINESTRING ((1 1, 2 2), (3 3, 4 4))",
+                "MULTILINESTRING ((4 4, 3 3), (2 2, 1 1))");
+}
+
+template<>
+template<>
+void object::test<5>
+()
+{
+    testReverse("POLYGON ((0 0, 10 0, 10 10, 0 10, 0 0), (1 1, 2 1, 2 2, 1 2, 1 1))",
+                "POLYGON ((0 0, 0 10, 10 10, 10 0, 0 0), (1 1, 1 2, 2 2, 2 1, 1 1))");
 
-    }
+}
 
-    template<>
-    template<>
-    void object::test<8>()
-    {
-        testReverse("POINT EMPTY",              "POINT EMPTY");
-        testReverse("LINESTRING EMPTY",         "LINESTRING EMPTY");
-        testReverse("LINEARRING EMPTY",         "LINEARRING EMPTY");
-        testReverse("POLYGON EMPTY",            "POLYGON EMPTY");
-        testReverse("MULTIPOINT EMPTY",         "MULTIPOINT EMPTY");
-        testReverse("MULTILINESTRING EMPTY",    "MULTILINESTRING EMPTY");
-        testReverse("MULTIPOLYGON EMPTY",       "MULTIPOLYGON EMPTY");
-        testReverse("GEOMETRYCOLLECTION EMPTY", "GEOMETRYCOLLECTION EMPTY");
-    }
+template<>
+template<>
+void object::test<6>
+()
+{
+    testReverse("MULTIPOLYGON (((0 0, 10 0, 10 10, 0 10, 0 0), (1 1, 2 1, 2 2, 1 2, 1 1)), ((100 100, 100 200, 200 200, 100 100)))",
+                "MULTIPOLYGON (((0 0, 0 10, 10 10, 10 0, 0 0), (1 1, 1 2, 2 2, 2 1, 1 1)), ((100 100, 200 200, 100 200, 100 100)))");
+
+}
+
+template<>
+template<>
+void object::test<7>
+()
+{
+    testReverse("GEOMETRYCOLLECTION (LINESTRING (1 1, 2 2), GEOMETRYCOLLECTION(LINESTRING (3 5, 2 9)))",
+                "GEOMETRYCOLLECTION (LINESTRING (2 2, 1 1), GEOMETRYCOLLECTION(LINESTRING (2 9, 3 5)))");
+
+}
+
+template<>
+template<>
+void object::test<8>
+()
+{
+    testReverse("POINT EMPTY",              "POINT EMPTY");
+    testReverse("LINESTRING EMPTY",         "LINESTRING EMPTY");
+    testReverse("LINEARRING EMPTY",         "LINEARRING EMPTY");
+    testReverse("POLYGON EMPTY",            "POLYGON EMPTY");
+    testReverse("MULTIPOINT EMPTY",         "MULTIPOINT EMPTY");
+    testReverse("MULTILINESTRING EMPTY",    "MULTILINESTRING EMPTY");
+    testReverse("MULTIPOLYGON EMPTY",       "MULTIPOLYGON EMPTY");
+    testReverse("GEOMETRYCOLLECTION EMPTY", "GEOMETRYCOLLECTION EMPTY");
+}
 
 } // namespace tut
diff --git a/tests/unit/capi/GEOSSTRtreeTest.cpp b/tests/unit/capi/GEOSSTRtreeTest.cpp
index 66d4ced..fd41083 100644
--- a/tests/unit/capi/GEOSSTRtreeTest.cpp
+++ b/tests/unit/capi/GEOSSTRtreeTest.cpp
@@ -11,239 +11,253 @@
 #include <cmath>
 
 struct INTPOINT {
-	INTPOINT(int p_x, int p_y) : x(p_x), y(p_y) {}
-	int x;
-	int y;
+    INTPOINT(int p_x, int p_y) : x(p_x), y(p_y) {}
+    int x;
+    int y;
 };
 
-static GEOSGeometry* INTPOINT2GEOS(INTPOINT* p) {
-	GEOSCoordSequence* seq = GEOSCoordSeq_create(1, 2);
-	GEOSCoordSeq_setX(seq, 0, p->x);
-	GEOSCoordSeq_setY(seq, 0, p->y);
-	return GEOSGeom_createPoint(seq);
+static GEOSGeometry*
+INTPOINT2GEOS(INTPOINT* p)
+{
+    GEOSCoordSequence* seq = GEOSCoordSeq_create(1, 2);
+    GEOSCoordSeq_setX(seq, 0, p->x);
+    GEOSCoordSeq_setY(seq, 0, p->y);
+    return GEOSGeom_createPoint(seq);
 }
 
-static int INTPOINT_dist(const void* a, const void* b, double* distance, void*) {
-	INTPOINT* p1 = (INTPOINT*) a;
-	INTPOINT* p2 = (INTPOINT*) b;
+static int
+INTPOINT_dist(const void* a, const void* b, double* distance, void*)
+{
+    INTPOINT* p1 = (INTPOINT*) a;
+    INTPOINT* p2 = (INTPOINT*) b;
 
-	int dx = p2->x - p1->x;
-	int dy = p2->y - p1->y;
+    int dx = p2->x - p1->x;
+    int dy = p2->y - p1->y;
 
-	*distance = sqrt(static_cast<double>(dx*dx) + dy*dy);
-	return 1;
+    *distance = sqrt(static_cast<double>(dx * dx) + dy * dy);
+    return 1;
 }
 
-namespace tut
+namespace tut {
+//
+// Test Group
+//
+
+// Common data used in test cases.
+struct test_capistrtree_data {
+    test_capistrtree_data()
+    {
+        initGEOS(notice, notice);
+    }
+
+    static void
+    notice(const char* fmt, ...)
+    {
+        std::fprintf(stdout, "NOTICE: ");
+
+        va_list ap;
+        va_start(ap, fmt);
+        std::vfprintf(stdout, fmt, ap);
+        va_end(ap);
+
+        std::fprintf(stdout, "\n");
+    }
+
+};
+
+typedef test_group<test_capistrtree_data> group;
+typedef group::object object;
+
+group test_capistrtree_group("capi::GEOSSTRtree");
+
+//
+// Test Cases
+//
+
+// Test GEOSSTRtree_nearest with a couple of points
+template<>
+template<>
+void object::test<1>
+()
 {
-	//
-	// Test Group
-	//
-
-	// Common data used in test cases.
-	struct test_capistrtree_data
-	{
-		test_capistrtree_data() {
-			initGEOS(notice, notice);
-		}
-
-		static void notice(const char *fmt, ...)
-		{
-			std::fprintf( stdout, "NOTICE: ");
-
-			va_list ap;
-			va_start(ap, fmt);
-			std::vfprintf(stdout, fmt, ap);
-			va_end(ap);
-
-			std::fprintf(stdout, "\n");
-		}
-
-	};
-
-	typedef test_group<test_capistrtree_data> group;
-	typedef group::object object;
-
-	group test_capistrtree_group("capi::GEOSSTRtree");
-
-	//
-	// Test Cases
-	//
-
-	// Test GEOSSTRtree_nearest with a couple of points
-	template<>
-	template<>
-	void object::test<1>()
-	{
-		GEOSGeometry* g1 = GEOSGeomFromWKT("POINT (3 3)");
-		GEOSGeometry* g2 = GEOSGeomFromWKT("POINT (2 7)");
-		GEOSGeometry* g3 = GEOSGeomFromWKT("POINT (5 4)");
-		GEOSGeometry* g4 = GEOSGeomFromWKT("POINT (3 8)");
-
-		GEOSSTRtree* tree = GEOSSTRtree_create(2);
-		GEOSSTRtree_insert(tree, g1, g1);
-		GEOSSTRtree_insert(tree, g2, g2);
-		GEOSSTRtree_insert(tree, g3, g3);
-
-		const GEOSGeometry* g5 = GEOSSTRtree_nearest(tree, g4);
-		ensure(g5 == g2);
-
-		GEOSGeom_destroy(g1);
-		GEOSGeom_destroy(g2);
-		GEOSGeom_destroy(g3);
-		GEOSGeom_destroy(g4);
-		GEOSSTRtree_destroy(tree);
-	}
-
-	// Test GEOSSTRtree_nearest with more points.  This is important because we need to make sure the tree
-	// actually has a couple of layers of depth.
-	template<>
-	template<>
-	void object::test<2>()
-	{
-		size_t ngeoms = 100;
-		std::vector<GEOSGeometry*> geoms;
-		std::vector<GEOSGeometry*> queryPoints;
-		GEOSSTRtree* tree = GEOSSTRtree_create(8);
-
-		for (size_t i = 0; i < ngeoms; i++) {
-			GEOSCoordSequence* seq = GEOSCoordSeq_create(1, 2);
-			GEOSCoordSeq_setX(seq, 0, std::rand());
-			GEOSCoordSeq_setY(seq, 0, std::rand());
-			geoms.push_back(GEOSGeom_createPoint(seq));
-			GEOSSTRtree_insert(tree, geoms[i], geoms[i]);
-		}
-
-		for (size_t i = 0; i < ngeoms; i++) {
-			GEOSCoordSequence* seq = GEOSCoordSeq_create(1, 2);
-			GEOSCoordSeq_setX(seq, 0, std::rand());
-			GEOSCoordSeq_setY(seq, 0, std::rand());
-			queryPoints.push_back(GEOSGeom_createPoint(seq));
-		}
-
-		for (size_t i = 0; i < ngeoms; i++) {
-			const GEOSGeometry* nearest = GEOSSTRtree_nearest(tree, queryPoints[i]);
-			const GEOSGeometry* nearestBruteForce = nullptr;
-			double nearestBruteForceDistance = std::numeric_limits<double>::max();
-			for (size_t j = 0; j < ngeoms; j++) {
-				double distance;
-				GEOSDistance(queryPoints[i], geoms[j], &distance);
-
-				if (nearestBruteForce == nullptr || distance < nearestBruteForceDistance) {
-					nearestBruteForce = geoms[j];
-					nearestBruteForceDistance = distance;
-				}
-			}
-
-			ensure(nearest == nearestBruteForce || GEOSEquals(nearest, nearestBruteForce));
-		}
-
-		for (size_t i = 0; i < ngeoms; i++) {
-			GEOSGeom_destroy(geoms[i]);
-			GEOSGeom_destroy(queryPoints[i]);
-		}
-
-		GEOSSTRtree_destroy(tree);
-	}
-
-	// GEOSSTRtree_nearest returns NULL on empty tree
-	template<>
-	template<>
-	void object::test<3>()
-	{
-		GEOSSTRtree* tree = GEOSSTRtree_create(10);
-		GEOSGeometry* g1 = GEOSGeomFromWKT("POINT (3 3)");
-		const GEOSGeometry* g2 = GEOSSTRtree_nearest(tree, g1);
-
-		ensure(g2 == nullptr);
-
-		GEOSGeom_destroy(g1);
-		GEOSSTRtree_destroy(tree);
-	}
-
-	// GEOSSTRtree_nearest with a user-defined type
-	template<>
-	template<>
-	void object::test<4>()
-	{
-		INTPOINT p1(1, 1);
-		INTPOINT p2(4, 4);
-		INTPOINT p3(3, 3);
-
-		GEOSGeometry* g1 = INTPOINT2GEOS(&p1);
-		GEOSGeometry* g2 = INTPOINT2GEOS(&p2);
-		GEOSGeometry* g3 = INTPOINT2GEOS(&p3);
-
-		GEOSSTRtree* tree = GEOSSTRtree_create(4);
-		GEOSSTRtree_insert(tree, g1, &p1);
-		GEOSSTRtree_insert(tree, g2, &p2);
-
-		const INTPOINT* p4 = (const INTPOINT*) GEOSSTRtree_nearest_generic(tree, &p3, g3, &INTPOINT_dist, nullptr);
-
-		ensure (p4 == &p2);
-
-		GEOSGeom_destroy(g1);
-		GEOSGeom_destroy(g2);
-		GEOSGeom_destroy(g3);
-		GEOSSTRtree_destroy(tree);
-	}
-
-	// GEOSSTRtree_nearest with a tree of empty geometries
-	template<>
-	template<>
-	void object::test<5>() {
-		GEOSGeometry* g1 = GEOSGeomFromWKT("LINESTRING EMPTY");
-		GEOSGeometry* g2 = GEOSGeomFromWKT("POINT (2 7)");
-
-		GEOSSTRtree* tree = GEOSSTRtree_create(4);
-		GEOSSTRtree_insert(tree, g1, g1);
-
-		const GEOSGeometry* g3 = GEOSSTRtree_nearest(tree, g2);
-		ensure(g3 == nullptr);
-
-		GEOSGeom_destroy(g1);
-		GEOSGeom_destroy(g2);
-		GEOSSTRtree_destroy(tree);
-	}
-
-	// GEOSSTRtree_nearest with a tree containing some empty geometries
-	template<>
-	template<>
-	void object::test<6>() {
-		GEOSGeometry* g1 = GEOSGeomFromWKT("LINESTRING EMPTY");
-		GEOSGeometry* g2 = GEOSGeomFromWKT("POINT (2 7)");
-		GEOSGeometry* g3 = GEOSGeomFromWKT("POINT (12 97)");
-		GEOSGeometry* g4 = GEOSGeomFromWKT("LINESTRING (3 8, 4 8)");
-
-		GEOSSTRtree* tree = GEOSSTRtree_create(4);
-		GEOSSTRtree_insert(tree, g1, g1);
-		GEOSSTRtree_insert(tree, g2, g2);
-		GEOSSTRtree_insert(tree, g3, g3);
-
-		const GEOSGeometry* g5 = (const GEOSGeometry*) GEOSSTRtree_nearest(tree, g4);
-		ensure(g5 == g2);
-
-		GEOSGeom_destroy(g1);
-		GEOSGeom_destroy(g2);
-		GEOSGeom_destroy(g3);
-		GEOSGeom_destroy(g4);
-		GEOSSTRtree_destroy(tree);
-	}
-
-	// querying empty tree should not crash (see #730)
-    template<>
-    template<>
-    void object::test<7>() {
-	    GEOSSTRtree* tree = GEOSSTRtree_create(16);
-	    GEOSGeometry* q = GEOSGeomFromWKT("POLYGON ((0 0, 1 0, 1 1, 0 1, 0 0))");
-	    GEOSSTRtree_query(tree, q, [](void* item, void* userdata) {
-	   		assert(item); // make unused parameter warning go away
-			assert(userdata);
-        }, nullptr);
-
-		GEOSGeom_destroy(q);
-		GEOSSTRtree_destroy(tree);
-	}
+    GEOSGeometry* g1 = GEOSGeomFromWKT("POINT (3 3)");
+    GEOSGeometry* g2 = GEOSGeomFromWKT("POINT (2 7)");
+    GEOSGeometry* g3 = GEOSGeomFromWKT("POINT (5 4)");
+    GEOSGeometry* g4 = GEOSGeomFromWKT("POINT (3 8)");
+
+    GEOSSTRtree* tree = GEOSSTRtree_create(2);
+    GEOSSTRtree_insert(tree, g1, g1);
+    GEOSSTRtree_insert(tree, g2, g2);
+    GEOSSTRtree_insert(tree, g3, g3);
+
+    const GEOSGeometry* g5 = GEOSSTRtree_nearest(tree, g4);
+    ensure(g5 == g2);
+
+    GEOSGeom_destroy(g1);
+    GEOSGeom_destroy(g2);
+    GEOSGeom_destroy(g3);
+    GEOSGeom_destroy(g4);
+    GEOSSTRtree_destroy(tree);
+}
+
+// Test GEOSSTRtree_nearest with more points.  This is important because we need to make sure the tree
+// actually has a couple of layers of depth.
+template<>
+template<>
+void object::test<2>
+()
+{
+    size_t ngeoms = 100;
+    std::vector<GEOSGeometry*> geoms;
+    std::vector<GEOSGeometry*> queryPoints;
+    GEOSSTRtree* tree = GEOSSTRtree_create(8);
+
+    for(size_t i = 0; i < ngeoms; i++) {
+        GEOSCoordSequence* seq = GEOSCoordSeq_create(1, 2);
+        GEOSCoordSeq_setX(seq, 0, std::rand());
+        GEOSCoordSeq_setY(seq, 0, std::rand());
+        geoms.push_back(GEOSGeom_createPoint(seq));
+        GEOSSTRtree_insert(tree, geoms[i], geoms[i]);
+    }
+
+    for(size_t i = 0; i < ngeoms; i++) {
+        GEOSCoordSequence* seq = GEOSCoordSeq_create(1, 2);
+        GEOSCoordSeq_setX(seq, 0, std::rand());
+        GEOSCoordSeq_setY(seq, 0, std::rand());
+        queryPoints.push_back(GEOSGeom_createPoint(seq));
+    }
+
+    for(size_t i = 0; i < ngeoms; i++) {
+        const GEOSGeometry* nearest = GEOSSTRtree_nearest(tree, queryPoints[i]);
+        const GEOSGeometry* nearestBruteForce = nullptr;
+        double nearestBruteForceDistance = std::numeric_limits<double>::max();
+        for(size_t j = 0; j < ngeoms; j++) {
+            double distance;
+            GEOSDistance(queryPoints[i], geoms[j], &distance);
+
+            if(nearestBruteForce == nullptr || distance < nearestBruteForceDistance) {
+                nearestBruteForce = geoms[j];
+                nearestBruteForceDistance = distance;
+            }
+        }
+
+        ensure(nearest == nearestBruteForce || GEOSEquals(nearest, nearestBruteForce));
+    }
+
+    for(size_t i = 0; i < ngeoms; i++) {
+        GEOSGeom_destroy(geoms[i]);
+        GEOSGeom_destroy(queryPoints[i]);
+    }
+
+    GEOSSTRtree_destroy(tree);
+}
+
+// GEOSSTRtree_nearest returns NULL on empty tree
+template<>
+template<>
+void object::test<3>
+()
+{
+    GEOSSTRtree* tree = GEOSSTRtree_create(10);
+    GEOSGeometry* g1 = GEOSGeomFromWKT("POINT (3 3)");
+    const GEOSGeometry* g2 = GEOSSTRtree_nearest(tree, g1);
+
+    ensure(g2 == nullptr);
+
+    GEOSGeom_destroy(g1);
+    GEOSSTRtree_destroy(tree);
+}
+
+// GEOSSTRtree_nearest with a user-defined type
+template<>
+template<>
+void object::test<4>
+()
+{
+    INTPOINT p1(1, 1);
+    INTPOINT p2(4, 4);
+    INTPOINT p3(3, 3);
+
+    GEOSGeometry* g1 = INTPOINT2GEOS(&p1);
+    GEOSGeometry* g2 = INTPOINT2GEOS(&p2);
+    GEOSGeometry* g3 = INTPOINT2GEOS(&p3);
+
+    GEOSSTRtree* tree = GEOSSTRtree_create(4);
+    GEOSSTRtree_insert(tree, g1, &p1);
+    GEOSSTRtree_insert(tree, g2, &p2);
+
+    const INTPOINT* p4 = (const INTPOINT*) GEOSSTRtree_nearest_generic(tree, &p3, g3, &INTPOINT_dist, nullptr);
+
+    ensure(p4 == &p2);
+
+    GEOSGeom_destroy(g1);
+    GEOSGeom_destroy(g2);
+    GEOSGeom_destroy(g3);
+    GEOSSTRtree_destroy(tree);
+}
+
+// GEOSSTRtree_nearest with a tree of empty geometries
+template<>
+template<>
+void object::test<5>
+()
+{
+    GEOSGeometry* g1 = GEOSGeomFromWKT("LINESTRING EMPTY");
+    GEOSGeometry* g2 = GEOSGeomFromWKT("POINT (2 7)");
+
+    GEOSSTRtree* tree = GEOSSTRtree_create(4);
+    GEOSSTRtree_insert(tree, g1, g1);
+
+    const GEOSGeometry* g3 = GEOSSTRtree_nearest(tree, g2);
+    ensure(g3 == nullptr);
+
+    GEOSGeom_destroy(g1);
+    GEOSGeom_destroy(g2);
+    GEOSSTRtree_destroy(tree);
+}
+
+// GEOSSTRtree_nearest with a tree containing some empty geometries
+template<>
+template<>
+void object::test<6>
+()
+{
+    GEOSGeometry* g1 = GEOSGeomFromWKT("LINESTRING EMPTY");
+    GEOSGeometry* g2 = GEOSGeomFromWKT("POINT (2 7)");
+    GEOSGeometry* g3 = GEOSGeomFromWKT("POINT (12 97)");
+    GEOSGeometry* g4 = GEOSGeomFromWKT("LINESTRING (3 8, 4 8)");
+
+    GEOSSTRtree* tree = GEOSSTRtree_create(4);
+    GEOSSTRtree_insert(tree, g1, g1);
+    GEOSSTRtree_insert(tree, g2, g2);
+    GEOSSTRtree_insert(tree, g3, g3);
+
+    const GEOSGeometry* g5 = (const GEOSGeometry*) GEOSSTRtree_nearest(tree, g4);
+    ensure(g5 == g2);
+
+    GEOSGeom_destroy(g1);
+    GEOSGeom_destroy(g2);
+    GEOSGeom_destroy(g3);
+    GEOSGeom_destroy(g4);
+    GEOSSTRtree_destroy(tree);
+}
+
+// querying empty tree should not crash (see #730)
+template<>
+template<>
+void object::test<7>
+()
+{
+    GEOSSTRtree* tree = GEOSSTRtree_create(16);
+    GEOSGeometry* q = GEOSGeomFromWKT("POLYGON ((0 0, 1 0, 1 1, 0 1, 0 0))");
+    GEOSSTRtree_query(tree, q, [](void* item, void* userdata) {
+        assert(item); // make unused parameter warning go away
+        assert(userdata);
+    }, nullptr);
+
+    GEOSGeom_destroy(q);
+    GEOSSTRtree_destroy(tree);
+}
 
 } // namespace tut
 
diff --git a/tests/unit/capi/GEOSSegmentIntersectionTest.cpp b/tests/unit/capi/GEOSSegmentIntersectionTest.cpp
index a8ca8e3..a08c4b7 100644
--- a/tests/unit/capi/GEOSSegmentIntersectionTest.cpp
+++ b/tests/unit/capi/GEOSSegmentIntersectionTest.cpp
@@ -8,76 +8,77 @@
 #include <cstdio>
 #include <cstdlib>
 
-namespace tut
-{
-    //
-    // Test Group
-    //
+namespace tut {
+//
+// Test Group
+//
 
-    // Common data used in test cases.
-    struct test_capigeossegmentintersection
+// Common data used in test cases.
+struct test_capigeossegmentintersection {
+    static void
+    notice(const char* fmt, ...)
     {
-        static void notice(const char *fmt, ...)
-        {
-            std::fprintf( stdout, "NOTICE: ");
+        std::fprintf(stdout, "NOTICE: ");
 
-            va_list ap;
-            va_start(ap, fmt);
-            std::vfprintf(stdout, fmt, ap);
-            va_end(ap);
+        va_list ap;
+        va_start(ap, fmt);
+        std::vfprintf(stdout, fmt, ap);
+        va_end(ap);
 
-            std::fprintf(stdout, "\n");
-        }
+        std::fprintf(stdout, "\n");
+    }
 
-        test_capigeossegmentintersection()
-        {
-            initGEOS(notice, notice);
-        }
+    test_capigeossegmentintersection()
+    {
+        initGEOS(notice, notice);
+    }
 
-        ~test_capigeossegmentintersection()
-        {
-            finishGEOS();
-        }
-    };
+    ~test_capigeossegmentintersection()
+    {
+        finishGEOS();
+    }
+};
 
-    typedef test_group<test_capigeossegmentintersection> group;
-    typedef group::object object;
+typedef test_group<test_capigeossegmentintersection> group;
+typedef group::object object;
 
-    group test_capigeossegmentintersection_group("capi::GEOSSegmentIntersection");
+group test_capigeossegmentintersection_group("capi::GEOSSegmentIntersection");
 
-    //
-    // Test Cases
-    //
-    template<>
-    template<>
-    void object::test<1>()
-    {
-        // plain old intersection
-        int result;
-        double x,y;
+//
+// Test Cases
+//
+template<>
+template<>
+void object::test<1>
+()
+{
+    // plain old intersection
+    int result;
+    double x, y;
 
-        result = GEOSSegmentIntersection(0, 0, 10, 10,
-                                         8, 0, 8, 10,
-                                         &x, &y);
+    result = GEOSSegmentIntersection(0, 0, 10, 10,
+                                     8, 0, 8, 10,
+                                     &x, &y);
 
-        ensure_equals(result, 1);
-        ensure_equals(x, 8);
-        ensure_equals(y, 8);
-    }
+    ensure_equals(result, 1);
+    ensure_equals(x, 8);
+    ensure_equals(y, 8);
+}
 
-    template<>
-    template<>
-    void object::test<2>()
-    {
-        // no intersection
-        int result;
-        double x,y;
+template<>
+template<>
+void object::test<2>
+()
+{
+    // no intersection
+    int result;
+    double x, y;
 
-        result = GEOSSegmentIntersection(0, 0, 10, 10,
-                                         8, 0, 8,  2,
-                                         &x, &y);
+    result = GEOSSegmentIntersection(0, 0, 10, 10,
+                                     8, 0, 8,  2,
+                                     &x, &y);
 
-        ensure_equals(result, -1);
-    }
+    ensure_equals(result, -1);
+}
 
 } // namespace tut
diff --git a/tests/unit/capi/GEOSSharedPathsTest.cpp b/tests/unit/capi/GEOSSharedPathsTest.cpp
index 5662b74..69413e1 100644
--- a/tests/unit/capi/GEOSSharedPathsTest.cpp
+++ b/tests/unit/capi/GEOSSharedPathsTest.cpp
@@ -10,114 +10,116 @@
 #include <cstdlib>
 #include <memory>
 
-namespace tut
-{
-    //
-    // Test Group
-    //
+namespace tut {
+//
+// Test Group
+//
 
-    // Common data used in test cases.
-    struct test_capigeossharedpaths_data
-    {
-        GEOSGeometry* geom1_;
-        GEOSGeometry* geom2_;
-        GEOSGeometry* geom3_;
-        GEOSWKTWriter* w_;
-
-        static void notice(const char *fmt, ...)
-        {
-            std::fprintf( stdout, "NOTICE: ");
-
-            va_list ap;
-            va_start(ap, fmt);
-            std::vfprintf(stdout, fmt, ap);
-            va_end(ap);
-
-            std::fprintf(stdout, "\n");
-        }
-
-        test_capigeossharedpaths_data()
-            : geom1_(nullptr), geom2_(nullptr), geom3_(nullptr), w_(nullptr)
-        {
-            initGEOS(notice, notice);
-            w_ = GEOSWKTWriter_create();
-            GEOSWKTWriter_setTrim(w_, 1);
-        }
-
-        ~test_capigeossharedpaths_data()
-        {
-            GEOSGeom_destroy(geom1_);
-            GEOSGeom_destroy(geom2_);
-            GEOSGeom_destroy(geom3_);
-            GEOSWKTWriter_destroy(w_);
-            geom1_ = nullptr;
-            geom2_ = nullptr;
-            geom3_ = nullptr;
-            finishGEOS();
-        }
-
-    };
-
-    typedef test_group<test_capigeossharedpaths_data> group;
-    typedef group::object object;
-
-    group test_capigeossharedpaths_group("capi::GEOSSharedPaths");
-
-    //
-    // Test Cases
-    //
-
-    /// Illegal case (point-poly)
-    template<>
-    template<>
-    void object::test<1>()
+// Common data used in test cases.
+struct test_capigeossharedpaths_data {
+    GEOSGeometry* geom1_;
+    GEOSGeometry* geom2_;
+    GEOSGeometry* geom3_;
+    GEOSWKTWriter* w_;
+
+    static void
+    notice(const char* fmt, ...)
     {
-        geom1_ = GEOSGeomFromWKT("POLYGON ((0 0, 10 0, 10 10, 0 10, 0 0))");
-        geom2_ = GEOSGeomFromWKT("POINT(0.5 0)");
-        geom3_ = GEOSSharedPaths(geom1_, geom2_);
+        std::fprintf(stdout, "NOTICE: ");
 
-        ensure(!geom3_);
+        va_list ap;
+        va_start(ap, fmt);
+        std::vfprintf(stdout, fmt, ap);
+        va_end(ap);
+
+        std::fprintf(stdout, "\n");
     }
 
-    /// Line to line sharing
-    template<>
-    template<>
-    void object::test<2>()
+    test_capigeossharedpaths_data()
+        : geom1_(nullptr), geom2_(nullptr), geom3_(nullptr), w_(nullptr)
     {
-        geom1_ = GEOSGeomFromWKT("LINESTRING (-30 -20, 50 60, 50 70, 50 0)");
-        geom2_ = GEOSGeomFromWKT("LINESTRING (-29 -20, 50 60, 50 70, 51 0)");
-        geom3_ = GEOSSharedPaths(geom1_, geom2_);
-
-        char* wkt_c = GEOSWKTWriter_write(w_, geom3_);
-        std::string out(wkt_c);
-        free(wkt_c);
-
-        ensure_equals(out,
-"GEOMETRYCOLLECTION (MULTILINESTRING ((50 60, 50 70)), MULTILINESTRING EMPTY)"
-        );
+        initGEOS(notice, notice);
+        w_ = GEOSWKTWriter_create();
+        GEOSWKTWriter_setTrim(w_, 1);
     }
 
-    /// http://trac.osgeo.org/postgis/ticket/670#comment:3
-    template<>
-    template<>
-    void object::test<3>()
+    ~test_capigeossharedpaths_data()
     {
-        // NOTE: in ticket #670 both geoms were in SRID=4326
+        GEOSGeom_destroy(geom1_);
+        GEOSGeom_destroy(geom2_);
+        GEOSGeom_destroy(geom3_);
+        GEOSWKTWriter_destroy(w_);
+        geom1_ = nullptr;
+        geom2_ = nullptr;
+        geom3_ = nullptr;
+        finishGEOS();
+    }
 
-        geom1_ = GEOSGeomFromWKT(
-"POINT(-11.1111111 40)"
-        );
-        geom2_ = GEOSGeomFromWKT(
-"POLYGON((-8.1111111 60,-8.16875525879031 59.4147290339516,-8.33947250246614 58.8519497029047,-8.61670226309236 58.3332893009412,-8.98979075644036 57.8786796564404,-9.44440040094119 57.5055911630924,-9.96306080290473 57.2283614024661,-10.5258401339516 57.0576441587903,-11.1111111 57,-11.6963820660484 57.0576441587903,-12.2591613970953 57.2283614024661,-12.7778217990588 57.5055911630924,-13.2324314435596 57.8786796564404,-13.6055199369076 58.3332893009412,-13.8827496975339 58.8519497029047,-14.0534669412097 59.4147290339516,-14.1111111 60,-14.0534669412097 60.5852709660484,-13.8827496975339 61.1480502970953,-13.6055199369076 61.6667106990588,-13.2324314435597 62.1213203435596,-12.7778217990588 62.4944088369076,-12.2591613970953 62.7716385975339,-11.6963820660484 62.9423558412097,-11.1111111 63,-10.5258401339516 62.9423558412097,-9.96306080290474 62.7716385975339,-9.4444004009412 62.4944088369076,-8.98979075644036 62.1213203435596,-8.61670226309237 61.6667106990588,-8.33947250246614 6
 1.1480502970953,-8.16875525879031 60.5852709660484,-8.1111111 60))"
-        );
+};
 
-        ensure(nullptr != geom1_);
-        ensure(nullptr != geom2_);
+typedef test_group<test_capigeossharedpaths_data> group;
+typedef group::object object;
 
-        geom3_ = GEOSSharedPaths(geom1_, geom2_);
+group test_capigeossharedpaths_group("capi::GEOSSharedPaths");
 
-        ensure(!geom3_);
-    }
+//
+// Test Cases
+//
+
+/// Illegal case (point-poly)
+template<>
+template<>
+void object::test<1>
+()
+{
+    geom1_ = GEOSGeomFromWKT("POLYGON ((0 0, 10 0, 10 10, 0 10, 0 0))");
+    geom2_ = GEOSGeomFromWKT("POINT(0.5 0)");
+    geom3_ = GEOSSharedPaths(geom1_, geom2_);
+
+    ensure(!geom3_);
+}
+
+/// Line to line sharing
+template<>
+template<>
+void object::test<2>
+()
+{
+    geom1_ = GEOSGeomFromWKT("LINESTRING (-30 -20, 50 60, 50 70, 50 0)");
+    geom2_ = GEOSGeomFromWKT("LINESTRING (-29 -20, 50 60, 50 70, 51 0)");
+    geom3_ = GEOSSharedPaths(geom1_, geom2_);
+
+    char* wkt_c = GEOSWKTWriter_write(w_, geom3_);
+    std::string out(wkt_c);
+    free(wkt_c);
+
+    ensure_equals(out,
+                  "GEOMETRYCOLLECTION (MULTILINESTRING ((50 60, 50 70)), MULTILINESTRING EMPTY)"
+                 );
+}
+
+/// http://trac.osgeo.org/postgis/ticket/670#comment:3
+template<>
+template<>
+void object::test<3>
+()
+{
+    // NOTE: in ticket #670 both geoms were in SRID=4326
+
+    geom1_ = GEOSGeomFromWKT(
+                 "POINT(-11.1111111 40)"
+             );
+    geom2_ = GEOSGeomFromWKT(
+                 "POLYGON((-8.1111111 60,-8.16875525879031 59.4147290339516,-8.33947250246614 58.8519497029047,-8.61670226309236 58.3332893009412,-8.98979075644036 57.8786796564404,-9.44440040094119 57.5055911630924,-9.96306080290473 57.2283614024661,-10.5258401339516 57.0576441587903,-11.1111111 57,-11.6963820660484 57.0576441587903,-12.2591613970953 57.2283614024661,-12.7778217990588 57.5055911630924,-13.2324314435596 57.8786796564404,-13.6055199369076 58.3332893009412,-13.8827496975339 58.8519497029047,-14.0534669412097 59.4147290339516,-14.1111111 60,-14.0534669412097 60.5852709660484,-13.8827496975339 61.1480502970953,-13.6055199369076 61.6667106990588,-13.2324314435597 62.1213203435596,-12.7778217990588 62.4944088369076,-12.2591613970953 62.7716385975339,-11.6963820660484 62.9423558412097,-11.1111111 63,-10.5258401339516 62.9423558412097,-9.96306080290474 62.7716385975339,-9.4444004009412 62.4944088369076,-8.98979075644036 62.1213203435596,-8.61670226309237 61.6667106990588,-8
 .33947250246614 61.1480502970953,-8.16875525879031 60.5852709660484,-8.1111111 60))"
+             );
+
+    ensure(nullptr != geom1_);
+    ensure(nullptr != geom2_);
+
+    geom3_ = GEOSSharedPaths(geom1_, geom2_);
+
+    ensure(!geom3_);
+}
 
 } // namespace tut
 
diff --git a/tests/unit/capi/GEOSSimplifyTest.cpp b/tests/unit/capi/GEOSSimplifyTest.cpp
index b3a22ed..42edfaf 100644
--- a/tests/unit/capi/GEOSSimplifyTest.cpp
+++ b/tests/unit/capi/GEOSSimplifyTest.cpp
@@ -10,69 +10,69 @@
 #include <cstdlib>
 #include <memory>
 
-namespace tut
-{
-    //
-    // Test Group
-    //
+namespace tut {
+//
+// Test Group
+//
 
-    // Common data used in test cases.
-    struct test_capigeossimplify_data
-    {
-        GEOSGeometry* geom1_;
-        GEOSGeometry* geom2_;
-
-        static void notice(const char *fmt, ...)
-        {
-            std::fprintf( stdout, "NOTICE: ");
-
-            va_list ap;
-            va_start(ap, fmt);
-            std::vfprintf(stdout, fmt, ap);
-            va_end(ap);
-
-            std::fprintf(stdout, "\n");
-        }
-
-        test_capigeossimplify_data()
-            : geom1_(nullptr), geom2_(nullptr)
-        {
-            initGEOS(notice, notice);
-        }
-
-        ~test_capigeossimplify_data()
-        {
-            GEOSGeom_destroy(geom1_);
-            GEOSGeom_destroy(geom2_);
-            geom1_ = nullptr;
-            geom2_ = nullptr;
-            finishGEOS();
-        }
-
-    };
-
-    typedef test_group<test_capigeossimplify_data> group;
-    typedef group::object object;
-
-    group test_capigeossimplify_group("capi::GEOSSimplify");
-
-    //
-    // Test Cases
-    //
-
-    // Test GEOSSimplify
-    template<>
-    template<>
-    void object::test<1>()
+// Common data used in test cases.
+struct test_capigeossimplify_data {
+    GEOSGeometry* geom1_;
+    GEOSGeometry* geom2_;
+
+    static void
+    notice(const char* fmt, ...)
     {
-        geom1_ = GEOSGeomFromWKT("POLYGON EMPTY");
+        std::fprintf(stdout, "NOTICE: ");
 
-        ensure ( 0 != GEOSisEmpty(geom1_) );
+        va_list ap;
+        va_start(ap, fmt);
+        std::vfprintf(stdout, fmt, ap);
+        va_end(ap);
 
-        geom2_ = GEOSSimplify(geom1_, 43.2);
+        std::fprintf(stdout, "\n");
+    }
 
-        ensure ( 0 != GEOSisEmpty(geom2_) );
+    test_capigeossimplify_data()
+        : geom1_(nullptr), geom2_(nullptr)
+    {
+        initGEOS(notice, notice);
     }
 
+    ~test_capigeossimplify_data()
+    {
+        GEOSGeom_destroy(geom1_);
+        GEOSGeom_destroy(geom2_);
+        geom1_ = nullptr;
+        geom2_ = nullptr;
+        finishGEOS();
+    }
+
+};
+
+typedef test_group<test_capigeossimplify_data> group;
+typedef group::object object;
+
+group test_capigeossimplify_group("capi::GEOSSimplify");
+
+//
+// Test Cases
+//
+
+// Test GEOSSimplify
+template<>
+template<>
+void object::test<1>
+()
+{
+    geom1_ = GEOSGeomFromWKT("POLYGON EMPTY");
+
+    ensure(0 != GEOSisEmpty(geom1_));
+
+    geom2_ = GEOSSimplify(geom1_, 43.2);
+
+    ensure(0 != GEOSisEmpty(geom2_));
+}
+
 } // namespace tut
 
diff --git a/tests/unit/capi/GEOSSnapTest.cpp b/tests/unit/capi/GEOSSnapTest.cpp
index bc46f15..29a99e9 100644
--- a/tests/unit/capi/GEOSSnapTest.cpp
+++ b/tests/unit/capi/GEOSSnapTest.cpp
@@ -10,228 +10,237 @@
 #include <cstdlib>
 #include <memory>
 
-namespace tut
-{
-    //
-    // Test Group
-    //
-
-    // Common data used in test cases.
-    struct test_capigeossnap_data
-    {
-        GEOSGeometry* geom1_;
-        GEOSGeometry* geom2_;
-        GEOSGeometry* geom3_;
-        GEOSWKTWriter* w_;
-
-        static void notice(const char *fmt, ...)
-        {
-            std::fprintf( stdout, "NOTICE: ");
-
-            va_list ap;
-            va_start(ap, fmt);
-            std::vfprintf(stdout, fmt, ap);
-            va_end(ap);
-
-            std::fprintf(stdout, "\n");
-        }
-
-        test_capigeossnap_data()
-            : geom1_(nullptr), geom2_(nullptr), geom3_(nullptr), w_(nullptr)
-        {
-            initGEOS(notice, notice);
-            w_ = GEOSWKTWriter_create();
-            GEOSWKTWriter_setTrim(w_, 1);
-            GEOSWKTWriter_setRoundingPrecision(w_, 8);
-        }
-
-        ~test_capigeossnap_data()
-        {
-            GEOSGeom_destroy(geom1_);
-            GEOSGeom_destroy(geom2_);
-            GEOSGeom_destroy(geom3_);
-            GEOSWKTWriter_destroy(w_);
-            geom1_ = nullptr;
-            geom2_ = nullptr;
-            geom3_ = nullptr;
-            finishGEOS();
-        }
-
-    };
-
-    typedef test_group<test_capigeossnap_data> group;
-    typedef group::object object;
-
-    group test_capigeossnap_group("capi::GEOSSnap");
-
-    //
-    // Test Cases
-    //
-
-    /// Polygon snapped to point
-    template<>
-    template<>
-    void object::test<1>()
-    {
-        geom1_ = GEOSGeomFromWKT("POLYGON ((0 0, 10 0, 10 10, 0 10, 0 0))");
-        geom2_ = GEOSGeomFromWKT("POINT(0.5 0)");
-        geom3_ = GEOSSnap(geom1_, geom2_, 1);
-
-        char* wkt_c = GEOSWKTWriter_write(w_, geom3_);
-        std::string out(wkt_c);
-        free(wkt_c);
-
-        ensure_equals(out, "POLYGON ((0.5 0, 10 0, 10 10, 0 10, 0.5 0))");
-    }
-
-    /// Line snapped to line (vertex)
-    template<>
-    template<>
-    void object::test<2>()
-    {
-        geom1_ = GEOSGeomFromWKT("LINESTRING (-30 -20, 50 60, 50 0)");
-        geom2_ = GEOSGeomFromWKT("LINESTRING (-29 -20, 40 60, 51 0)");
-        geom3_ = GEOSSnap(geom1_, geom2_, 2);
-
-        char* wkt_c = GEOSWKTWriter_write(w_, geom3_);
-        std::string out(wkt_c);
-        free(wkt_c);
-
-        ensure_equals(out, "LINESTRING (-29 -20, 50 60, 51 0)");
-    }
-
-    /// Line snapped to line (segment)
-    template<>
-    template<>
-    void object::test<3>()
-    {
-        geom1_ = GEOSGeomFromWKT("LINESTRING (-20 -20, 50 50, 100 100)");
-        geom2_ = GEOSGeomFromWKT("LINESTRING (-10 -9, 40 20, 80 79)");
-        geom3_ = GEOSSnap(geom1_, geom2_, 2);
+namespace tut {
+//
+// Test Group
+//
 
-        char* wkt_c = GEOSWKTWriter_write(w_, geom3_);
-        std::string out(wkt_c);
-        free(wkt_c);
+// Common data used in test cases.
+struct test_capigeossnap_data {
+    GEOSGeometry* geom1_;
+    GEOSGeometry* geom2_;
+    GEOSGeometry* geom3_;
+    GEOSWKTWriter* w_;
 
-        ensure_equals(out,
-          "LINESTRING (-20 -20, -10 -9, 50 50, 80 79, 100 100)"
-        );
-    }
-
-    /// Another single segment
-    template<>
-    template<>
-    void object::test<4>()
+    static void
+    notice(const char* fmt, ...)
     {
-        geom1_ = GEOSGeomFromWKT("LINESTRING(0 0, 10 0)");
-        geom2_ = GEOSGeomFromWKT("LINESTRING(0 0, 9 0)");
-        geom3_ = GEOSSnap(geom1_, geom2_, 2);
+        std::fprintf(stdout, "NOTICE: ");
 
-        char* wkt_c = GEOSWKTWriter_write(w_, geom3_);
-        std::string out(wkt_c);
-        free(wkt_c);
+        va_list ap;
+        va_start(ap, fmt);
+        std::vfprintf(stdout, fmt, ap);
+        va_end(ap);
 
-        ensure_equals(out, "LINESTRING (0 0, 9 0)");
+        std::fprintf(stdout, "\n");
     }
 
-    /// See http://trac.osgeo.org/geos/ticket/501
-    template<>
-    template<>
-    void object::test<5>()
+    test_capigeossnap_data()
+        : geom1_(nullptr), geom2_(nullptr), geom3_(nullptr), w_(nullptr)
     {
-        geom1_ = GEOSGeomFromWKT("LINESTRING(0 0, 10 0)");
-        geom2_ = GEOSGeomFromWKT("LINESTRING(0 0, 9 0, 10 0, 11 0)");
-        geom3_ = GEOSSnap(geom1_, geom2_, 2);
-
-        char* wkt_c = GEOSWKTWriter_write(w_, geom3_);
-        std::string out(wkt_c);
-        free(wkt_c);
-
-        //ensure_equals(out, "LINESTRING (0 0, 9 0, 10 0)");
-        ensure_equals(out, "LINESTRING (0 0, 9 0, 10 0, 11 0)");
+        initGEOS(notice, notice);
+        w_ = GEOSWKTWriter_create();
+        GEOSWKTWriter_setTrim(w_, 1);
+        GEOSWKTWriter_setRoundingPrecision(w_, 8);
     }
 
-    /// Test snapping of equidistant segments to outlyers snap point
-    template<>
-    template<>
-    void object::test<6>()
+    ~test_capigeossnap_data()
     {
-        geom1_ = GEOSGeomFromWKT("LINESTRING(0 3,4 1,0 1)");
-        geom2_ = GEOSGeomFromWKT("MULTIPOINT(5 0,4 1)");
-        geom3_ = GEOSSnap(geom1_, geom2_, 2);
-
-        char* wkt_c = GEOSWKTWriter_write(w_, geom3_);
-        std::string out(wkt_c);
-        free(wkt_c);
-
-        ensure_equals(out, "LINESTRING (0 3, 4 1, 5 0, 0 1)");
-        //ensure_equals(out, "LINESTRING (0 3, 4 1, 0 1)");
+        GEOSGeom_destroy(geom1_);
+        GEOSGeom_destroy(geom2_);
+        GEOSGeom_destroy(geom3_);
+        GEOSWKTWriter_destroy(w_);
+        geom1_ = nullptr;
+        geom2_ = nullptr;
+        geom3_ = nullptr;
+        finishGEOS();
     }
 
-    /// Test snapping of equidistant segments to outlyers snap point
-    /// Same as the above but with the snap points order reversed
-    template<>
-    template<>
-    void object::test<7>()
-    {
-        geom1_ = GEOSGeomFromWKT("LINESTRING(0 3,4 1,0 1)");
-        geom2_ = GEOSGeomFromWKT("MULTIPOINT(4 1,5 0)");
-        geom3_ = GEOSSnap(geom1_, geom2_, 2);
-
-        char* wkt_c = GEOSWKTWriter_write(w_, geom3_);
-        std::string out(wkt_c);
-        free(wkt_c);
-
-        ensure_equals(out, "LINESTRING (0 3, 4 1, 5 0, 0 1)");
-        //ensure_equals(out, "LINESTRING (0 3, 4 1, 0 1)");
-    }
+};
 
-    /// Test snapping of closed ring to outlyers snap point
-    template<>
-    template<>
-    void object::test<8>()
-    {
-        geom1_ = GEOSGeomFromWKT("LINESTRING(0 0,10 0,10 10,0 10,0 0)");
-        geom2_ = GEOSGeomFromWKT("MULTIPOINT(0 0,-1 0)");
-        geom3_ = GEOSSnap(geom1_, geom2_, 3);
+typedef test_group<test_capigeossnap_data> group;
+typedef group::object object;
 
-        char* wkt_c = GEOSWKTWriter_write(w_, geom3_);
-        std::string out(wkt_c);
-        free(wkt_c);
+group test_capigeossnap_group("capi::GEOSSnap");
 
-        ensure_equals(out, "LINESTRING (-1 0, 0 0, 10 0, 10 10, 0 10, -1 0)");
-    }
+//
+// Test Cases
+//
 
-    template<>
-    template<>
-    void object::test<9>()
-    {
-        geom1_ = GEOSGeomFromWKT("LINESTRING(0 2,5 2,9 2,5 0)");
-        geom2_ = GEOSGeomFromWKT("POINT(5 0)");
-        geom3_ = GEOSSnap(geom1_, geom2_, 3);
+/// Polygon snapped to point
+template<>
+template<>
+void object::test<1>
+()
+{
+    geom1_ = GEOSGeomFromWKT("POLYGON ((0 0, 10 0, 10 10, 0 10, 0 0))");
+    geom2_ = GEOSGeomFromWKT("POINT(0.5 0)");
+    geom3_ = GEOSSnap(geom1_, geom2_, 1);
+
+    char* wkt_c = GEOSWKTWriter_write(w_, geom3_);
+    std::string out(wkt_c);
+    free(wkt_c);
+
+    ensure_equals(out, "POLYGON ((0.5 0, 10 0, 10 10, 0 10, 0.5 0))");
+}
+
+/// Line snapped to line (vertex)
+template<>
+template<>
+void object::test<2>
+()
+{
+    geom1_ = GEOSGeomFromWKT("LINESTRING (-30 -20, 50 60, 50 0)");
+    geom2_ = GEOSGeomFromWKT("LINESTRING (-29 -20, 40 60, 51 0)");
+    geom3_ = GEOSSnap(geom1_, geom2_, 2);
+
+    char* wkt_c = GEOSWKTWriter_write(w_, geom3_);
+    std::string out(wkt_c);
+    free(wkt_c);
+
+    ensure_equals(out, "LINESTRING (-29 -20, 50 60, 51 0)");
+}
+
+/// Line snapped to line (segment)
+template<>
+template<>
+void object::test<3>
+()
+{
+    geom1_ = GEOSGeomFromWKT("LINESTRING (-20 -20, 50 50, 100 100)");
+    geom2_ = GEOSGeomFromWKT("LINESTRING (-10 -9, 40 20, 80 79)");
+    geom3_ = GEOSSnap(geom1_, geom2_, 2);
+
+    char* wkt_c = GEOSWKTWriter_write(w_, geom3_);
+    std::string out(wkt_c);
+    free(wkt_c);
+
+    ensure_equals(out,
+                  "LINESTRING (-20 -20, -10 -9, 50 50, 80 79, 100 100)"
+                 );
+}
+
+/// Another single segment
+template<>
+template<>
+void object::test<4>
+()
+{
+    geom1_ = GEOSGeomFromWKT("LINESTRING(0 0, 10 0)");
+    geom2_ = GEOSGeomFromWKT("LINESTRING(0 0, 9 0)");
+    geom3_ = GEOSSnap(geom1_, geom2_, 2);
+
+    char* wkt_c = GEOSWKTWriter_write(w_, geom3_);
+    std::string out(wkt_c);
+    free(wkt_c);
+
+    ensure_equals(out, "LINESTRING (0 0, 9 0)");
+}
+
+/// See http://trac.osgeo.org/geos/ticket/501
+template<>
+template<>
+void object::test<5>
+()
+{
+    geom1_ = GEOSGeomFromWKT("LINESTRING(0 0, 10 0)");
+    geom2_ = GEOSGeomFromWKT("LINESTRING(0 0, 9 0, 10 0, 11 0)");
+    geom3_ = GEOSSnap(geom1_, geom2_, 2);
+
+    char* wkt_c = GEOSWKTWriter_write(w_, geom3_);
+    std::string out(wkt_c);
+    free(wkt_c);
+
+    //ensure_equals(out, "LINESTRING (0 0, 9 0, 10 0)");
+    ensure_equals(out, "LINESTRING (0 0, 9 0, 10 0, 11 0)");
+}
+
+/// Test snapping of equidistant segments to outlyers snap point
+template<>
+template<>
+void object::test<6>
+()
+{
+    geom1_ = GEOSGeomFromWKT("LINESTRING(0 3,4 1,0 1)");
+    geom2_ = GEOSGeomFromWKT("MULTIPOINT(5 0,4 1)");
+    geom3_ = GEOSSnap(geom1_, geom2_, 2);
+
+    char* wkt_c = GEOSWKTWriter_write(w_, geom3_);
+    std::string out(wkt_c);
+    free(wkt_c);
+
+    ensure_equals(out, "LINESTRING (0 3, 4 1, 5 0, 0 1)");
+    //ensure_equals(out, "LINESTRING (0 3, 4 1, 0 1)");
+}
+
+/// Test snapping of equidistant segments to outlyers snap point
+/// Same as the above but with the snap points order reversed
+template<>
+template<>
+void object::test<7>
+()
+{
+    geom1_ = GEOSGeomFromWKT("LINESTRING(0 3,4 1,0 1)");
+    geom2_ = GEOSGeomFromWKT("MULTIPOINT(4 1,5 0)");
+    geom3_ = GEOSSnap(geom1_, geom2_, 2);
+
+    char* wkt_c = GEOSWKTWriter_write(w_, geom3_);
+    std::string out(wkt_c);
+    free(wkt_c);
+
+    ensure_equals(out, "LINESTRING (0 3, 4 1, 5 0, 0 1)");
+    //ensure_equals(out, "LINESTRING (0 3, 4 1, 0 1)");
+}
+
+/// Test snapping of closed ring to outlyers snap point
+template<>
+template<>
+void object::test<8>
+()
+{
+    geom1_ = GEOSGeomFromWKT("LINESTRING(0 0,10 0,10 10,0 10,0 0)");
+    geom2_ = GEOSGeomFromWKT("MULTIPOINT(0 0,-1 0)");
+    geom3_ = GEOSSnap(geom1_, geom2_, 3);
 
-        char* wkt_c = GEOSWKTWriter_write(w_, geom3_);
-        std::string out(wkt_c);
-        free(wkt_c);
+    char* wkt_c = GEOSWKTWriter_write(w_, geom3_);
+    std::string out(wkt_c);
+    free(wkt_c);
 
-        ensure_equals(out, "LINESTRING (0 2, 5 2, 9 2, 5 0)");
-    }
+    ensure_equals(out, "LINESTRING (-1 0, 0 0, 10 0, 10 10, 0 10, -1 0)");
+}
 
-    // See http://trac.osgeo.org/geos/ticket/649
-    template<>
-    template<>
-    void object::test<10>()
-    {
-        geom1_ = GEOSGeomFromWKT("LINESTRING(-71.1317 42.2511,-71.1317 42.2509)");
-        geom2_ = GEOSGeomFromWKT("MULTIPOINT(-71.1261 42.2703,-71.1257 42.2703,-71.1261 42.2702)");
-        geom3_ = GEOSSnap(geom1_, geom2_, 0.5);
+template<>
+template<>
+void object::test<9>
+()
+{
+    geom1_ = GEOSGeomFromWKT("LINESTRING(0 2,5 2,9 2,5 0)");
+    geom2_ = GEOSGeomFromWKT("POINT(5 0)");
+    geom3_ = GEOSSnap(geom1_, geom2_, 3);
+
+    char* wkt_c = GEOSWKTWriter_write(w_, geom3_);
+    std::string out(wkt_c);
+    free(wkt_c);
+
+    ensure_equals(out, "LINESTRING (0 2, 5 2, 9 2, 5 0)");
+}
+
+// See http://trac.osgeo.org/geos/ticket/649
+template<>
+template<>
+void object::test<10>
+()
+{
+    geom1_ = GEOSGeomFromWKT("LINESTRING(-71.1317 42.2511,-71.1317 42.2509)");
+    geom2_ = GEOSGeomFromWKT("MULTIPOINT(-71.1261 42.2703,-71.1257 42.2703,-71.1261 42.2702)");
+    geom3_ = GEOSSnap(geom1_, geom2_, 0.5);
 
-        char* wkt_c = GEOSWKTWriter_write(w_, geom3_);
-        std::string out(wkt_c);
-        free(wkt_c);
+    char* wkt_c = GEOSWKTWriter_write(w_, geom3_);
+    std::string out(wkt_c);
+    free(wkt_c);
 
-        ensure_equals(out, "LINESTRING (-71.1257 42.2703, -71.1261 42.2703, -71.1261 42.2702, -71.1317 42.2509)");
-    }
+    ensure_equals(out, "LINESTRING (-71.1257 42.2703, -71.1261 42.2703, -71.1261 42.2702, -71.1317 42.2509)");
+}
 
 } // namespace tut
 
diff --git a/tests/unit/capi/GEOSUnaryUnionTest.cpp b/tests/unit/capi/GEOSUnaryUnionTest.cpp
index 85d690f..79cbdd3 100644
--- a/tests/unit/capi/GEOSUnaryUnionTest.cpp
+++ b/tests/unit/capi/GEOSUnaryUnionTest.cpp
@@ -10,215 +10,226 @@
 #include <cstdlib>
 #include <cstring>
 
-namespace tut
-{
-    //
-    // Test Group
-    //
+namespace tut {
+//
+// Test Group
+//
 
-    // Common data used in test cases.
-    struct test_capiunaryunion_data
-    {
-        GEOSWKTWriter* wktw_;
-        GEOSGeometry* geom1_;
-        GEOSGeometry* geom2_;
-
-        static void notice(const char *fmt, ...)
-        {
-            std::fprintf( stdout, "NOTICE: ");
-
-            va_list ap;
-            va_start(ap, fmt);
-            std::vfprintf(stdout, fmt, ap);
-            va_end(ap);
-
-            std::fprintf(stdout, "\n");
-        }
-
-        test_capiunaryunion_data()
-            : geom1_(nullptr), geom2_(nullptr)
-        {
-            initGEOS(notice, notice);
-            wktw_ = GEOSWKTWriter_create();
-            GEOSWKTWriter_setTrim(wktw_, 1);
-            GEOSWKTWriter_setOutputDimension(wktw_, 3);
-        }
-
-        std::string toWKT(GEOSGeometry* g)
-        {
-          char* wkt = GEOSWKTWriter_write(wktw_, g);
-          std::string ret (wkt);
-          GEOSFree(wkt);
-          return ret;
-        }
-
-        ~test_capiunaryunion_data()
-        {
-            GEOSGeom_destroy(geom1_);
-            GEOSGeom_destroy(geom2_);
-            GEOSWKTWriter_destroy(wktw_);
-            geom1_ = nullptr;
-            geom2_ = nullptr;
-            finishGEOS();
-        }
-
-    };
-
-    typedef test_group<test_capiunaryunion_data> group;
-    typedef group::object object;
-
-    group test_capiunaryunion_group("capi::GEOSUnaryUnion");
-
-    //
-    // Test Cases
-    //
-
-
-    // Self-union an empty point
-    template<>
-    template<>
-    void object::test<1>()
+// Common data used in test cases.
+struct test_capiunaryunion_data {
+    GEOSWKTWriter* wktw_;
+    GEOSGeometry* geom1_;
+    GEOSGeometry* geom2_;
+
+    static void
+    notice(const char* fmt, ...)
     {
-        geom1_ = GEOSGeomFromWKT("POINT EMPTY");
-        ensure( nullptr != geom1_ );
+        std::fprintf(stdout, "NOTICE: ");
 
-        geom2_ = GEOSUnaryUnion(geom1_);
-        ensure( nullptr != geom2_ );
+        va_list ap;
+        va_start(ap, fmt);
+        std::vfprintf(stdout, fmt, ap);
+        va_end(ap);
 
-        ensure_equals(toWKT(geom2_), std::string("POINT EMPTY"));
+        std::fprintf(stdout, "\n");
     }
 
-    // Self-union a 2d point
-    template<>
-    template<>
-    void object::test<2>()
+    test_capiunaryunion_data()
+        : geom1_(nullptr), geom2_(nullptr)
     {
-        geom1_ = GEOSGeomFromWKT("POINT (6 3)");
-        ensure( nullptr != geom1_ );
-
-        geom2_ = GEOSUnaryUnion(geom1_);
-        ensure( nullptr != geom2_ );
+        initGEOS(notice, notice);
+        wktw_ = GEOSWKTWriter_create();
+        GEOSWKTWriter_setTrim(wktw_, 1);
+        GEOSWKTWriter_setOutputDimension(wktw_, 3);
+    }
 
-        ensure_equals(toWKT(geom2_), std::string("POINT (6 3)"));
+    std::string
+    toWKT(GEOSGeometry* g)
+    {
+        char* wkt = GEOSWKTWriter_write(wktw_, g);
+        std::string ret(wkt);
+        GEOSFree(wkt);
+        return ret;
     }
 
-    // Self-union a 3d point
-    template<>
-    template<>
-    void object::test<3>()
+    ~test_capiunaryunion_data()
     {
-        geom1_ = GEOSGeomFromWKT("POINT (4 5 6)");
-        ensure( nullptr != geom1_ );
+        GEOSGeom_destroy(geom1_);
+        GEOSGeom_destroy(geom2_);
+        GEOSWKTWriter_destroy(wktw_);
+        geom1_ = nullptr;
+        geom2_ = nullptr;
+        finishGEOS();
+    }
 
-        geom2_ = GEOSUnaryUnion(geom1_);
-        ensure( nullptr != geom2_ );
+};
 
-        ensure_equals(toWKT(geom2_), std::string("POINT Z (4 5 6)"));
-    }
+typedef test_group<test_capiunaryunion_data> group;
+typedef group::object object;
 
-    // Self-union a multipoint with duplicated points
-    template<>
-    template<>
-    void object::test<4>()
-    {
-        geom1_ = GEOSGeomFromWKT("MULTIPOINT (4 5, 6 7, 4 5, 6 5, 6 7)");
-        ensure( nullptr != geom1_ );
+group test_capiunaryunion_group("capi::GEOSUnaryUnion");
 
-        geom2_ = GEOSUnaryUnion(geom1_);
-        ensure( nullptr != geom2_ );
+//
+// Test Cases
+//
 
-        ensure_equals(toWKT(geom2_), std::string("MULTIPOINT (4 5, 6 5, 6 7)"));
-    }
 
-    // Self-union a collection of puntal and lineal geometries
-    template<>
-    template<>
-    void object::test<5>()
-    {
-        geom1_ = GEOSGeomFromWKT("GEOMETRYCOLLECTION (POINT(4 5), MULTIPOINT(6 7, 6 5, 6 7), LINESTRING(0 5, 10 5), LINESTRING(4 -10, 4 10))");
-        ensure( nullptr != geom1_ );
+// Self-union an empty point
+template<>
+template<>
+void object::test<1>
+()
+{
+    geom1_ = GEOSGeomFromWKT("POINT EMPTY");
+    ensure(nullptr != geom1_);
 
-        geom2_ = GEOSUnaryUnion(geom1_);
-        ensure( nullptr != geom2_ );
+    geom2_ = GEOSUnaryUnion(geom1_);
+    ensure(nullptr != geom2_);
 
-        ensure_equals(toWKT(geom2_), std::string("GEOMETRYCOLLECTION (POINT (6 7), LINESTRING (4 -10, 4 5), LINESTRING (4 5, 4 10), LINESTRING (0 5, 4 5), LINESTRING (4 5, 10 5))"));
-    }
+    ensure_equals(toWKT(geom2_), std::string("POINT EMPTY"));
+}
 
-    // Self-union a collection of puntal and polygonal geometries
-    template<>
-    template<>
-    void object::test<6>()
-    {
-        geom1_ = GEOSGeomFromWKT("GEOMETRYCOLLECTION (POINT(4 5), MULTIPOINT(6 7, 6 5, 6 7), POLYGON((0 0, 10 0, 10 10, 0 10, 0 0),(5 6, 7 6, 7 8, 5 8, 5 6)))");
-        ensure( nullptr != geom1_ );
+// Self-union a 2d point
+template<>
+template<>
+void object::test<2>
+()
+{
+    geom1_ = GEOSGeomFromWKT("POINT (6 3)");
+    ensure(nullptr != geom1_);
 
-        geom2_ = GEOSUnaryUnion(geom1_);
-        ensure( nullptr != geom2_ );
+    geom2_ = GEOSUnaryUnion(geom1_);
+    ensure(nullptr != geom2_);
 
-        ensure_equals(toWKT(geom2_), std::string(
-"GEOMETRYCOLLECTION (POINT (6 7), POLYGON ((0 0, 10 0, 10 10, 0 10, 0 0), (5 6, 7 6, 7 8, 5 8, 5 6)))"
-));
-    }
+    ensure_equals(toWKT(geom2_), std::string("POINT (6 3)"));
+}
 
-    // Self-union a collection of lineal and polygonal geometries
-    template<>
-    template<>
-    void object::test<7>()
-    {
-        geom1_ = GEOSGeomFromWKT("GEOMETRYCOLLECTION (MULTILINESTRING((5 7, 12 7), (4 5, 6 5), (5.5 7.5, 6.5 7.5)), POLYGON((0 0, 10 0, 10 10, 0 10, 0 0),(5 6, 7 6, 7 8, 5 8, 5 6)))");
-        ensure( nullptr != geom1_ );
+// Self-union a 3d point
+template<>
+template<>
+void object::test<3>
+()
+{
+    geom1_ = GEOSGeomFromWKT("POINT (4 5 6)");
+    ensure(nullptr != geom1_);
 
-        geom2_ = GEOSUnaryUnion(geom1_);
-        ensure( nullptr != geom2_ );
+    geom2_ = GEOSUnaryUnion(geom1_);
+    ensure(nullptr != geom2_);
 
-        ensure_equals(toWKT(geom2_), std::string(
-"GEOMETRYCOLLECTION (LINESTRING (5 7, 7 7), LINESTRING (10 7, 12 7), LINESTRING (5.5 7.5, 6.5 7.5), POLYGON ((10 7, 10 0, 0 0, 0 10, 10 10, 10 7), (5 6, 7 6, 7 7, 7 8, 5 8, 5 7, 5 6)))"
-));
-    }
+    ensure_equals(toWKT(geom2_), std::string("POINT Z (4 5 6)"));
+}
 
-    // Self-union a collection of puntal, lineal and polygonal geometries
-    template<>
-    template<>
-    void object::test<8>()
-    {
-        geom1_ = GEOSGeomFromWKT("GEOMETRYCOLLECTION (MULTILINESTRING((5 7, 12 7), (4 5, 6 5), (5.5 7.5, 6.5 7.5)), POLYGON((0 0, 10 0, 10 10, 0 10, 0 0),(5 6, 7 6, 7 8, 5 8, 5 6)), MULTIPOINT(6 6.5, 6 1, 12 2, 6 1))");
-        ensure( nullptr != geom1_ );
+// Self-union a multipoint with duplicated points
+template<>
+template<>
+void object::test<4>
+()
+{
+    geom1_ = GEOSGeomFromWKT("MULTIPOINT (4 5, 6 7, 4 5, 6 5, 6 7)");
+    ensure(nullptr != geom1_);
 
-        geom2_ = GEOSUnaryUnion(geom1_);
-        ensure( nullptr != geom2_ );
+    geom2_ = GEOSUnaryUnion(geom1_);
+    ensure(nullptr != geom2_);
 
-        ensure_equals(toWKT(geom2_), std::string(
-"GEOMETRYCOLLECTION (POINT (6 6.5), POINT (12 2), LINESTRING (5 7, 7 7), LINESTRING (10 7, 12 7), LINESTRING (5.5 7.5, 6.5 7.5), POLYGON ((10 7, 10 0, 0 0, 0 10, 10 10, 10 7), (5 6, 7 6, 7 7, 7 8, 5 8, 5 7, 5 6)))"
-));
-    }
+    ensure_equals(toWKT(geom2_), std::string("MULTIPOINT (4 5, 6 5, 6 7)"));
+}
 
-    // Self-union a geometry with NaN coordinates
-    // See http://trac.osgeo.org/geos/ticket/530
-    template<>
-    template<>
-    void object::test<9>()
-    {
-        const char* hexwkb = "010200000002000000000000000000F8FF000000000000F8FF0000000000000000000000000000F03F";
-        geom1_ = GEOSGeomFromHEX_buf((const unsigned char*)hexwkb, std::strlen(hexwkb));
-        ensure( nullptr != geom1_ );
+// Self-union a collection of puntal and lineal geometries
+template<>
+template<>
+void object::test<5>
+()
+{
+    geom1_ = GEOSGeomFromWKT("GEOMETRYCOLLECTION (POINT(4 5), MULTIPOINT(6 7, 6 5, 6 7), LINESTRING(0 5, 10 5), LINESTRING(4 -10, 4 10))");
+    ensure(nullptr != geom1_);
 
-        geom2_ = GEOSUnaryUnion(geom1_);
-        ensure( nullptr == geom2_ );
+    geom2_ = GEOSUnaryUnion(geom1_);
+    ensure(nullptr != geom2_);
 
-    }
+    ensure_equals(toWKT(geom2_),
+                  std::string("GEOMETRYCOLLECTION (POINT (6 7), LINESTRING (4 -10, 4 5), LINESTRING (4 5, 4 10), LINESTRING (0 5, 4 5), LINESTRING (4 5, 10 5))"));
+}
 
-    // Self-union an empty linestring
-    template<>
-    template<>
-    void object::test<10>()
-    {
-        geom1_ = GEOSGeomFromWKT("LINESTRING EMPTY");
-        ensure( nullptr != geom1_ );
+// Self-union a collection of puntal and polygonal geometries
+template<>
+template<>
+void object::test<6>
+()
+{
+    geom1_ = GEOSGeomFromWKT("GEOMETRYCOLLECTION (POINT(4 5), MULTIPOINT(6 7, 6 5, 6 7), POLYGON((0 0, 10 0, 10 10, 0 10, 0 0),(5 6, 7 6, 7 8, 5 8, 5 6)))");
+    ensure(nullptr != geom1_);
+
+    geom2_ = GEOSUnaryUnion(geom1_);
+    ensure(nullptr != geom2_);
+
+    ensure_equals(toWKT(geom2_), std::string(
+                      "GEOMETRYCOLLECTION (POINT (6 7), POLYGON ((0 0, 10 0, 10 10, 0 10, 0 0), (5 6, 7 6, 7 8, 5 8, 5 6)))"
+                  ));
+}
+
+// Self-union a collection of lineal and polygonal geometries
+template<>
+template<>
+void object::test<7>
+()
+{
+    geom1_ = GEOSGeomFromWKT("GEOMETRYCOLLECTION (MULTILINESTRING((5 7, 12 7), (4 5, 6 5), (5.5 7.5, 6.5 7.5)), POLYGON((0 0, 10 0, 10 10, 0 10, 0 0),(5 6, 7 6, 7 8, 5 8, 5 6)))");
+    ensure(nullptr != geom1_);
+
+    geom2_ = GEOSUnaryUnion(geom1_);
+    ensure(nullptr != geom2_);
+
+    ensure_equals(toWKT(geom2_), std::string(
+                      "GEOMETRYCOLLECTION (LINESTRING (5 7, 7 7), LINESTRING (10 7, 12 7), LINESTRING (5.5 7.5, 6.5 7.5), POLYGON ((10 7, 10 0, 0 0, 0 10, 10 10, 10 7), (5 6, 7 6, 7 7, 7 8, 5 8, 5 7, 5 6)))"
+                  ));
+}
+
+// Self-union a collection of puntal, lineal and polygonal geometries
+template<>
+template<>
+void object::test<8>
+()
+{
+    geom1_ = GEOSGeomFromWKT("GEOMETRYCOLLECTION (MULTILINESTRING((5 7, 12 7), (4 5, 6 5), (5.5 7.5, 6.5 7.5)), POLYGON((0 0, 10 0, 10 10, 0 10, 0 0),(5 6, 7 6, 7 8, 5 8, 5 6)), MULTIPOINT(6 6.5, 6 1, 12 2, 6 1))");
+    ensure(nullptr != geom1_);
+
+    geom2_ = GEOSUnaryUnion(geom1_);
+    ensure(nullptr != geom2_);
+
+    ensure_equals(toWKT(geom2_), std::string(
+                      "GEOMETRYCOLLECTION (POINT (6 6.5), POINT (12 2), LINESTRING (5 7, 7 7), LINESTRING (10 7, 12 7), LINESTRING (5.5 7.5, 6.5 7.5), POLYGON ((10 7, 10 0, 0 0, 0 10, 10 10, 10 7), (5 6, 7 6, 7 7, 7 8, 5 8, 5 7, 5 6)))"
+                  ));
+}
+
+// Self-union a geometry with NaN coordinates
+// See http://trac.osgeo.org/geos/ticket/530
+template<>
+template<>
+void object::test<9>
+()
+{
+    const char* hexwkb = "010200000002000000000000000000F8FF000000000000F8FF0000000000000000000000000000F03F";
+    geom1_ = GEOSGeomFromHEX_buf((const unsigned char*)hexwkb, std::strlen(hexwkb));
+    ensure(nullptr != geom1_);
 
-        geom2_ = GEOSUnaryUnion(geom1_);
-        ensure( nullptr != geom2_ );
+    geom2_ = GEOSUnaryUnion(geom1_);
+    ensure(nullptr == geom2_);
 
-        ensure_equals(toWKT(geom2_), std::string("GEOMETRYCOLLECTION EMPTY"));
-    }
+}
+
+// Self-union an empty linestring
+template<>
+template<>
+void object::test<10>
+()
+{
+    geom1_ = GEOSGeomFromWKT("LINESTRING EMPTY");
+    ensure(nullptr != geom1_);
+
+    geom2_ = GEOSUnaryUnion(geom1_);
+    ensure(nullptr != geom2_);
+
+    ensure_equals(toWKT(geom2_), std::string("GEOMETRYCOLLECTION EMPTY"));
+}
 } // namespace tut
 
diff --git a/tests/unit/capi/GEOSUserDataTest.cpp b/tests/unit/capi/GEOSUserDataTest.cpp
index 5f0889e..3c1588a 100644
--- a/tests/unit/capi/GEOSUserDataTest.cpp
+++ b/tests/unit/capi/GEOSUserDataTest.cpp
@@ -10,96 +10,96 @@
 #include <cstdlib>
 #include <memory>
 
-namespace tut
-{
-    //
-    // Test Group
-    //
+namespace tut {
+//
+// Test Group
+//
 
-    // Common data used in test cases.
-    struct test_capigeouserdata_data
-    {
-        GEOSGeometry* geom_;
+// Common data used in test cases.
+struct test_capigeouserdata_data {
+    GEOSGeometry* geom_;
 
-        static void notice(const char *fmt, ...)
-        {
-            std::fprintf( stdout, "NOTICE: ");
+    static void
+    notice(const char* fmt, ...)
+    {
+        std::fprintf(stdout, "NOTICE: ");
 
-            va_list ap;
-            va_start(ap, fmt);
-            std::vfprintf(stdout, fmt, ap);
-            va_end(ap);
+        va_list ap;
+        va_start(ap, fmt);
+        std::vfprintf(stdout, fmt, ap);
+        va_end(ap);
 
-            std::fprintf(stdout, "\n");
-        }
+        std::fprintf(stdout, "\n");
+    }
 
-        test_capigeouserdata_data()
-            : geom_(nullptr)
-        {
-            initGEOS(notice, notice);
-        }
+    test_capigeouserdata_data()
+        : geom_(nullptr)
+    {
+        initGEOS(notice, notice);
+    }
 
-        ~test_capigeouserdata_data()
-        {
-            GEOSGeom_destroy(geom_);
-            geom_ = nullptr;
-            finishGEOS();
-        }
+    ~test_capigeouserdata_data()
+    {
+        GEOSGeom_destroy(geom_);
+        geom_ = nullptr;
+        finishGEOS();
+    }
 
-    };
+};
 
-    typedef test_group<test_capigeouserdata_data> group;
-    typedef group::object object;
+typedef test_group<test_capigeouserdata_data> group;
+typedef group::object object;
 
-    group test_capigeosuserdata_group("capi::GEOSUserData");
+group test_capigeosuserdata_group("capi::GEOSUserData");
 
-    //
-    // Test Cases
-    //
+//
+// Test Cases
+//
 
-    // Test GEOSUserData
-    template<>
-    template<>
-    void object::test<1>()
-    {
-        geom_ = GEOSGeomFromWKT("POLYGON EMPTY");
+// Test GEOSUserData
+template<>
+template<>
+void object::test<1>
+()
+{
+    geom_ = GEOSGeomFromWKT("POLYGON EMPTY");
 
-        ensure ( 0 != GEOSisEmpty(geom_) );
+    ensure(0 != GEOSisEmpty(geom_));
 
-        int in = 1;
-        GEOSGeom_setUserData(geom_, &in);
+    int in = 1;
+    GEOSGeom_setUserData(geom_, &in);
 
-        int* out = (int *)GEOSGeom_getUserData(geom_);
+    int* out = (int*)GEOSGeom_getUserData(geom_);
 
-        ensure_equals(*out, 1);
-    }
+    ensure_equals(*out, 1);
+}
 
-    struct UserData
-    {
-        int a;
-        int b;
-    } ;
+struct UserData {
+    int a;
+    int b;
+} ;
 
-    template<>
-    template<>
-    void object::test<2>()
-    {
-        geom_ = GEOSGeomFromWKT("POLYGON EMPTY");
+template<>
+template<>
+void object::test<2>
+()
+{
+    geom_ = GEOSGeomFromWKT("POLYGON EMPTY");
 
-        ensure ( 0 != GEOSisEmpty(geom_) );
+    ensure(0 != GEOSisEmpty(geom_));
 
-        UserData in;
-        in.a = 1;
-        in.b = 2;
+    UserData in;
+    in.a = 1;
+    in.b = 2;
 
-        GEOSGeom_setUserData(geom_, &in);
+    GEOSGeom_setUserData(geom_, &in);
 
-        struct UserData* out = (struct UserData* )GEOSGeom_getUserData(geom_);
+    struct UserData* out = (struct UserData*)GEOSGeom_getUserData(geom_);
 
-        ensure_equals(in.a, out->a);
-        ensure_equals(in.b, out->b);
-        ensure_equals(&in, out);
-    }
+    ensure_equals(in.a, out->a);
+    ensure_equals(in.b, out->b);
+    ensure_equals(&in, out);
+}
 
 } // namespace tut
 
diff --git a/tests/unit/capi/GEOSVoronoiDiagramTest.cpp b/tests/unit/capi/GEOSVoronoiDiagramTest.cpp
index 59d7285..59e5204 100644
--- a/tests/unit/capi/GEOSVoronoiDiagramTest.cpp
+++ b/tests/unit/capi/GEOSVoronoiDiagramTest.cpp
@@ -10,167 +10,178 @@
 #include <cstdlib>
 #include <memory>
 
-namespace tut
-{
-    //
-    // Test Group
-    //
+namespace tut {
+//
+// Test Group
+//
 
-    // Common data used in test cases.
-    struct test_capigeosvoronoidiagram_data
-    {
-        GEOSGeometry* geom1_;
-        GEOSGeometry* geom2_;
-        GEOSWKTWriter* w_;
+// Common data used in test cases.
+struct test_capigeosvoronoidiagram_data {
+    GEOSGeometry* geom1_;
+    GEOSGeometry* geom2_;
+    GEOSWKTWriter* w_;
 
-        static void notice(const char *fmt, ...)
-        {
-            std::fprintf( stdout, "NOTICE: ");
+    static void
+    notice(const char* fmt, ...)
+    {
+        std::fprintf(stdout, "NOTICE: ");
 
-            va_list ap;
-            va_start(ap, fmt);
-            std::vfprintf(stdout, fmt, ap);
-            va_end(ap);
+        va_list ap;
+        va_start(ap, fmt);
+        std::vfprintf(stdout, fmt, ap);
+        va_end(ap);
 
-            std::fprintf(stdout, "\n");
-        }
+        std::fprintf(stdout, "\n");
+    }
 
-        test_capigeosvoronoidiagram_data()
-            : geom1_(nullptr), geom2_(nullptr)
-        {
-            initGEOS(notice, notice);
-            w_ = GEOSWKTWriter_create();
-            GEOSWKTWriter_setTrim(w_, 1);
-        }
+    test_capigeosvoronoidiagram_data()
+        : geom1_(nullptr), geom2_(nullptr)
+    {
+        initGEOS(notice, notice);
+        w_ = GEOSWKTWriter_create();
+        GEOSWKTWriter_setTrim(w_, 1);
+    }
 
-        void ensure_equals_wkt(GEOSGeometry* g, const char* exp)
-        {
-          GEOSGeometry* exp_g = GEOSGeomFromWKT(exp);
+    void
+    ensure_equals_wkt(GEOSGeometry* g, const char* exp)
+    {
+        GEOSGeometry* exp_g = GEOSGeomFromWKT(exp);
 
-          GEOSNormalize(g);
-          GEOSNormalize(exp_g);
-          bool eq = GEOSEqualsExact(g, exp_g, 1e-10);
-          if ( ! eq ) {
+        GEOSNormalize(g);
+        GEOSNormalize(exp_g);
+        bool eq = GEOSEqualsExact(g, exp_g, 1e-10);
+        if(! eq) {
             using namespace std;
-            char *wkt_exp = GEOSWKTWriter_write(w_, exp_g);
-            char *wkt_obt = GEOSWKTWriter_write(w_, g);
+            char* wkt_exp = GEOSWKTWriter_write(w_, exp_g);
+            char* wkt_obt = GEOSWKTWriter_write(w_, g);
             cout << "Expected: " << wkt_exp << endl;
             cout << "Obtained: " << wkt_obt << endl;
             free(wkt_exp);
             free(wkt_obt);
-          }
-
-          ensure(eq);
-          GEOSGeom_destroy(exp_g);
         }
 
-        ~test_capigeosvoronoidiagram_data()
-        {
-            GEOSGeom_destroy(geom1_);
-            GEOSGeom_destroy(geom2_);
-            GEOSWKTWriter_destroy(w_);
-            geom1_ = nullptr;
-            geom2_ = nullptr;
-            finishGEOS();
-        }
-
-    };
-
-    typedef test_group<test_capigeosvoronoidiagram_data> group;
-    typedef group::object object;
-
-    group test_capigeosvoronoidiagram_group("capi::GEOSVoronoiDiagram");
-
-    //
-    // Test Cases
-    //
-
-    // Single point
-    template<>
-    template<>
-    void object::test<1>()
-    {
-	    geom1_ = GEOSGeomFromWKT("POINT(10 20)");
-
-	    geom2_ = GEOSVoronoiDiagram(geom1_, nullptr, 0, 0);
-	    ensure_equals ( GEOSisEmpty(geom2_), 1 );
-	    ensure_equals ( GEOSGeomTypeId(geom2_), GEOS_GEOMETRYCOLLECTION );
-
-	    GEOSGeom_destroy(geom2_);
-	    geom2_ = GEOSVoronoiDiagram(geom1_, nullptr, 0, 1);
-	    ensure_equals_wkt(geom2_,"MULTILINESTRING EMPTY");
+        ensure(eq);
+        GEOSGeom_destroy(exp_g);
     }
 
-    //More points:
-    template<>
-    template<>
-    void object::test<2>()
+    ~test_capigeosvoronoidiagram_data()
     {
-	    geom1_ = GEOSGeomFromWKT("MULTIPOINT ((280 300), (420 330), (380 230), (320 160))");
-
-	    geom2_ = GEOSVoronoiDiagram(geom1_, nullptr, 0, 0);
-	    ensure_equals_wkt(geom2_ ,"GEOMETRYCOLLECTION (POLYGON ((110 175.71428571428572, 110 500, 310.35714285714283 500, 353.515625 298.59375, 306.875 231.96428571428572, 110 175.71428571428572)), POLYGON ((590 204, 590 -10, 589.1666666666666 -10, 306.875 231.96428571428572, 353.515625 298.59375, 590 204)), POLYGON ((110 -10, 110 175.71428571428572, 306.875 231.96428571428572, 589.1666666666666 -10, 110 -10)), POLYGON ((310.35714285714283 500, 590 500, 590 204, 353.515625 298.59375, 310.35714285714283 500)))" );
-
-	    GEOSGeom_destroy(geom2_);
-	    geom2_ = GEOSVoronoiDiagram(geom1_, nullptr, 0, 1);
-	    ensure_equals_wkt(geom2_, "MULTILINESTRING ((310.3571428571428 500, 353.515625 298.59375), (353.515625 298.59375, 306.875 231.9642857142857), (306.875 231.9642857142857, 110 175.7142857142857), (589.1666666666666 -10, 306.875 231.9642857142857), (353.515625 298.59375, 590 204))");
+        GEOSGeom_destroy(geom1_);
+        GEOSGeom_destroy(geom2_);
+        GEOSWKTWriter_destroy(w_);
+        geom1_ = nullptr;
+        geom2_ = nullptr;
+        finishGEOS();
     }
-    //Larger number of points:
-    template<>
-    template<>
-    void object::test<3>()
-    {
-	    geom1_ = GEOSGeomFromWKT("MULTIPOINT ((170 270), (270 270), (230 310), (180 330), (250 340), (315 318), (330 260), (240 170), (220 220), (270 220))");
-
-	    geom2_ = GEOSVoronoiDiagram(geom1_, nullptr, 0, 0);
-	    ensure_equals_wkt(geom2_,"GEOMETRYCOLLECTION (POLYGON ((0 329.1666666666667, 0 510, 190 510, 213.94736842105263 342.36842105263156, 195.625 296.5625, 0 329.1666666666667)), POLYGON ((0 76.50000000000001, 0 329.1666666666667, 195.625 296.5625, 216 266, 88.33333333333333 138.33333333333334, 0 76.50000000000001)), POLYGON ((216 266, 195.625 296.5625, 213.94736842105263 342.36842105263156, 267 307, 225 265, 216 266)), POLYGON ((245 245, 225 265, 267 307, 275.9160583941606 309.54744525547443, 303.1666666666667 284, 296.6666666666667 245, 245 245)), POLYGON ((225 265, 245 245, 245 201, 88.33333333333333 138.33333333333334, 216 266, 225 265)), POLYGON ((0 0, 0 76.50000000000001, 88.33333333333333 138.33333333333334, 245 201, 380 120, 500 0, 0 0)), POLYGON ((190 510, 343.76153846153846 510, 275.9160583941606 309.54744525547443, 267 307, 213.94736842105263 342.36842105263156, 190 510)), POLYGON ((245 201, 245 245, 296.6666666666667 245, 380 120, 245 201)), POLYGON ((343.76153846153846 5
 10, 500 510, 500 334.9051724137931, 303.1666666666667 284, 275.9160583941606 309.54744525547443, 343.76153846153846 510)), POLYGON ((500 334.9051724137931, 500 0, 380 120, 296.6666666666667 245, 303.1666666666667 284, 500 334.9051724137931)))");
 
-	    GEOSGeom_destroy(geom2_);
-	    geom2_ = GEOSVoronoiDiagram(geom1_, nullptr, 0, 1);
-	    ensure_equals_wkt(geom2_,
-"MULTILINESTRING ((190 510, 213.9473684210526 342.3684210526316), (213.9473684210526 342.3684210526316, 195.625 296.5625), (195.625 296.5625, 0 329.1666666666667), (195.625 296.5625, 216 266), (216 266, 88.33333333333333 138.3333333333333), (88.33333333333333 138.3333333333333, 0 76.50000000000001), (213.9473684210526 342.3684210526316, 267 307), (267 307, 225 265), (225 265, 216 266), (245 245, 225 265), (267 307, 275.9160583941606 309.5474452554744), (275.9160583941606 309.5474452554744, 303.1666666666667 284), (303.1666666666667 284, 296.6666666666667 245), (296.6666666666667 245, 245 245), (245 245, 245 201), (245 201, 88.33333333333333 138.3333333333333), (245 201, 380 120), (380 120, 500 0), (343.7615384615385 510, 275.9160583941606 309.5474452554744), (296.6666666666667 245, 380 120), (500 334.9051724137931, 303.1666666666667 284))"
-      );
-    }
-    //Test with non-zero Tolerance value
-    template<>
-    template<>
-    void object::test<4>()
-    {
-	    geom1_ = GEOSGeomFromWKT("MULTIPOINT ((150 210), (210 270), (150 220), (220 210), (215 269))");
+};
 
-	    geom2_ = GEOSVoronoiDiagram(geom1_, nullptr, 10, 0);
-	    ensure_equals_wkt(geom2_,"GEOMETRYCOLLECTION (POLYGON ((290 252.5, 290 140, 185 140, 185 215, 187.9268292682927 235.4878048780488, 290 252.5)), POLYGON ((80 215, 80 340, 100.83333333333336 340, 187.9268292682927 235.4878048780488, 185 215, 80 215)), POLYGON ((80 140, 80 215, 185 215, 185 140, 80 140)), POLYGON ((100.83333333333336 340, 290 340, 290 252.5, 187.9268292682927 235.4878048780488, 100.83333333333336 340)))");
+typedef test_group<test_capigeosvoronoidiagram_data> group;
+typedef group::object object;
 
-	    GEOSGeom_destroy(geom2_);
-	    geom2_ = GEOSVoronoiDiagram(geom1_, nullptr, 10, 1);
-	    ensure_equals_wkt(geom2_,
-"MULTILINESTRING ((185 215, 187.9268292682927 235.4878048780488), (187.9268292682927 235.4878048780488, 290 252.5), (185 140, 185 215), (185 215, 80 215), (100.8333333333334 340, 187.9268292682927 235.4878048780488))"
-      );
-    }
-    template<>
-    template<>
-    void object::test<5>()
-    {
-	    geom1_ = GEOSGeomFromWKT("MULTIPOINT ((40 420), (50 420), (210 290), (300 360), (350 150), (170 70), (134 135) ,(305 359), (351 145), (175 71))");
+group test_capigeosvoronoidiagram_group("capi::GEOSVoronoiDiagram");
 
-	    geom2_ = GEOSVoronoiDiagram(geom1_, nullptr, 10, 0);
-	    ensure_equals_wkt(geom2_, "GEOMETRYCOLLECTION (POLYGON ((-310 146.559649122807, -310 770, 45 770, 45 263.64736842105265, -310 146.559649122807)), POLYGON ((-310 -153.37692307692305, -310 146.559649122807, 45 263.64736842105265, 59.16911764705881 267.8235294117647, 239.43506493506493 179.43506493506493, 241.34156378600824 151.98148148148147, -310 -153.37692307692305)), POLYGON ((45 770, 266.20000000000005 770, 181.94323144104806 418.9301310043668, 59.16911764705881 267.8235294117647, 45 263.64736842105265, 45 770)), POLYGON ((59.16911764705881 267.8235294117647, 181.94323144104806 418.9301310043668, 311.875 251.875, 239.43506493506493 179.43506493506493, 59.16911764705881 267.8235294117647)), POLYGON ((-310 -280, -310 -153.37692307692305, 241.34156378600824 151.98148148148147, 433.3333333333333 -280, -310 -280)), POLYGON ((266.20000000000005 770, 701 770, 701 344.5238095238096, 311.875 251.875, 181.94323144104806 418.9301310043668, 266.20000000000005 770)), POLYGON ((701 344.523
 8095238096, 701 -280, 433.3333333333333 -280, 241.34156378600824 151.98148148148147, 239.43506493506493 179.43506493506493, 311.875 251.875, 701 344.5238095238096)))");
+//
+// Test Cases
+//
 
-	    GEOSGeom_destroy(geom2_);
-	    geom2_ = GEOSVoronoiDiagram(geom1_, nullptr, 10, 1);
-	    ensure_equals_wkt(geom2_,
-"MULTILINESTRING ((45 770, 45 263.6473684210526), (45 263.6473684210526, -310 146.559649122807), (45 263.6473684210526, 59.16911764705881 267.8235294117647), (59.16911764705881 267.8235294117647, 239.4350649350649 179.4350649350649), (239.4350649350649 179.4350649350649, 241.3415637860082 151.9814814814815), (241.3415637860082 151.9814814814815, -310 -153.376923076923), (266.2 770, 181.9432314410481 418.9301310043668), (181.9432314410481 418.9301310043668, 59.16911764705881 267.8235294117647), (181.9432314410481 418.9301310043668, 311.875 251.875), (311.875 251.875, 239.4350649350649 179.4350649350649), (241.3415637860082 151.9814814814815, 433.3333333333333 -280), (701 344.5238095238096, 311.875 251.875))"
-	    );
-    }
-    template<>
-    template<>
-    void object::test<6>()
-    {
-	    geom1_ = GEOSGeomFromWKT("MULTIPOINT ((123 245), (165 313), (240 310), (260 260), (180 210), (240 210))");
-	    geom2_ = GEOSVoronoiDiagram(geom1_, nullptr, 0, 1);
-	    ensure_equals_wkt(geom2_,
-"MULTILINESTRING ((-14 376.5882352941176, 172.3651328095773 261.4803591470258), (172.3651328095773 261.4803591470258, 56.63157894736844 73), (172.3651328095773 261.4803591470258, 200.6640625 265.6015625), (200.6640625 265.6015625, 201 265.4), (201 265.4, 210 251), (210 251, 210 73), (208.04 450, 200.6640625 265.6015625), (397 343.8, 201 265.4), (210 251, 397 176.2))"
-	    );
-    }
+// Single point
+template<>
+template<>
+void object::test<1>
+()
+{
+    geom1_ = GEOSGeomFromWKT("POINT(10 20)");
+
+    geom2_ = GEOSVoronoiDiagram(geom1_, nullptr, 0, 0);
+    ensure_equals(GEOSisEmpty(geom2_), 1);
+    ensure_equals(GEOSGeomTypeId(geom2_), GEOS_GEOMETRYCOLLECTION);
+
+    GEOSGeom_destroy(geom2_);
+    geom2_ = GEOSVoronoiDiagram(geom1_, nullptr, 0, 1);
+    ensure_equals_wkt(geom2_, "MULTILINESTRING EMPTY");
+}
+
+//More points:
+template<>
+template<>
+void object::test<2>
+()
+{
+    geom1_ = GEOSGeomFromWKT("MULTIPOINT ((280 300), (420 330), (380 230), (320 160))");
+
+    geom2_ = GEOSVoronoiDiagram(geom1_, nullptr, 0, 0);
+    ensure_equals_wkt(geom2_,
+                      "GEOMETRYCOLLECTION (POLYGON ((110 175.71428571428572, 110 500, 310.35714285714283 500, 353.515625 298.59375, 306.875 231.96428571428572, 110 175.71428571428572)), POLYGON ((590 204, 590 -10, 589.1666666666666 -10, 306.875 231.96428571428572, 353.515625 298.59375, 590 204)), POLYGON ((110 -10, 110 175.71428571428572, 306.875 231.96428571428572, 589.1666666666666 -10, 110 -10)), POLYGON ((310.35714285714283 500, 590 500, 590 204, 353.515625 298.59375, 310.35714285714283 500)))");
+
+    GEOSGeom_destroy(geom2_);
+    geom2_ = GEOSVoronoiDiagram(geom1_, nullptr, 0, 1);
+    ensure_equals_wkt(geom2_,
+                      "MULTILINESTRING ((310.3571428571428 500, 353.515625 298.59375), (353.515625 298.59375, 306.875 231.9642857142857), (306.875 231.9642857142857, 110 175.7142857142857), (589.1666666666666 -10, 306.875 231.9642857142857), (353.515625 298.59375, 590 204))");
+}
+//Larger number of points:
+template<>
+template<>
+void object::test<3>
+()
+{
+    geom1_ = GEOSGeomFromWKT("MULTIPOINT ((170 270), (270 270), (230 310), (180 330), (250 340), (315 318), (330 260), (240 170), (220 220), (270 220))");
+
+    geom2_ = GEOSVoronoiDiagram(geom1_, nullptr, 0, 0);
+    ensure_equals_wkt(geom2_,
+                      "GEOMETRYCOLLECTION (POLYGON ((0 329.1666666666667, 0 510, 190 510, 213.94736842105263 342.36842105263156, 195.625 296.5625, 0 329.1666666666667)), POLYGON ((0 76.50000000000001, 0 329.1666666666667, 195.625 296.5625, 216 266, 88.33333333333333 138.33333333333334, 0 76.50000000000001)), POLYGON ((216 266, 195.625 296.5625, 213.94736842105263 342.36842105263156, 267 307, 225 265, 216 266)), POLYGON ((245 245, 225 265, 267 307, 275.9160583941606 309.54744525547443, 303.1666666666667 284, 296.6666666666667 245, 245 245)), POLYGON ((225 265, 245 245, 245 201, 88.33333333333333 138.33333333333334, 216 266, 225 265)), POLYGON ((0 0, 0 76.50000000000001, 88.33333333333333 138.33333333333334, 245 201, 380 120, 500 0, 0 0)), POLYGON ((190 510, 343.76153846153846 510, 275.9160583941606 309.54744525547443, 267 307, 213.94736842105263 342.36842105263156, 190 510)), POLYGON ((245 201, 245 245, 296.6666666666667 245, 380 120, 245 201)), POLYGON ((343.76153846153846 510, 500 
 510, 500 334.9051724137931, 303.1666666666667 284, 275.9160583941606 309.54744525547443, 343.76153846153846 510)), POLYGON ((500 334.9051724137931, 500 0, 380 120, 296.6666666666667 245, 303.1666666666667 284, 500 334.9051724137931)))");
+
+    GEOSGeom_destroy(geom2_);
+    geom2_ = GEOSVoronoiDiagram(geom1_, nullptr, 0, 1);
+    ensure_equals_wkt(geom2_,
+                      "MULTILINESTRING ((190 510, 213.9473684210526 342.3684210526316), (213.9473684210526 342.3684210526316, 195.625 296.5625), (195.625 296.5625, 0 329.1666666666667), (195.625 296.5625, 216 266), (216 266, 88.33333333333333 138.3333333333333), (88.33333333333333 138.3333333333333, 0 76.50000000000001), (213.9473684210526 342.3684210526316, 267 307), (267 307, 225 265), (225 265, 216 266), (245 245, 225 265), (267 307, 275.9160583941606 309.5474452554744), (275.9160583941606 309.5474452554744, 303.1666666666667 284), (303.1666666666667 284, 296.6666666666667 245), (296.6666666666667 245, 245 245), (245 245, 245 201), (245 201, 88.33333333333333 138.3333333333333), (245 201, 380 120), (380 120, 500 0), (343.7615384615385 510, 275.9160583941606 309.5474452554744), (296.6666666666667 245, 380 120), (500 334.9051724137931, 303.1666666666667 284))"
+                     );
+}
+//Test with non-zero Tolerance value
+template<>
+template<>
+void object::test<4>
+()
+{
+    geom1_ = GEOSGeomFromWKT("MULTIPOINT ((150 210), (210 270), (150 220), (220 210), (215 269))");
+
+    geom2_ = GEOSVoronoiDiagram(geom1_, nullptr, 10, 0);
+    ensure_equals_wkt(geom2_,
+                      "GEOMETRYCOLLECTION (POLYGON ((290 252.5, 290 140, 185 140, 185 215, 187.9268292682927 235.4878048780488, 290 252.5)), POLYGON ((80 215, 80 340, 100.83333333333336 340, 187.9268292682927 235.4878048780488, 185 215, 80 215)), POLYGON ((80 140, 80 215, 185 215, 185 140, 80 140)), POLYGON ((100.83333333333336 340, 290 340, 290 252.5, 187.9268292682927 235.4878048780488, 100.83333333333336 340)))");
+
+    GEOSGeom_destroy(geom2_);
+    geom2_ = GEOSVoronoiDiagram(geom1_, nullptr, 10, 1);
+    ensure_equals_wkt(geom2_,
+                      "MULTILINESTRING ((185 215, 187.9268292682927 235.4878048780488), (187.9268292682927 235.4878048780488, 290 252.5), (185 140, 185 215), (185 215, 80 215), (100.8333333333334 340, 187.9268292682927 235.4878048780488))"
+                     );
+}
+template<>
+template<>
+void object::test<5>
+()
+{
+    geom1_ = GEOSGeomFromWKT("MULTIPOINT ((40 420), (50 420), (210 290), (300 360), (350 150), (170 70), (134 135) ,(305 359), (351 145), (175 71))");
+
+    geom2_ = GEOSVoronoiDiagram(geom1_, nullptr, 10, 0);
+    ensure_equals_wkt(geom2_,
+                      "GEOMETRYCOLLECTION (POLYGON ((-310 146.559649122807, -310 770, 45 770, 45 263.64736842105265, -310 146.559649122807)), POLYGON ((-310 -153.37692307692305, -310 146.559649122807, 45 263.64736842105265, 59.16911764705881 267.8235294117647, 239.43506493506493 179.43506493506493, 241.34156378600824 151.98148148148147, -310 -153.37692307692305)), POLYGON ((45 770, 266.20000000000005 770, 181.94323144104806 418.9301310043668, 59.16911764705881 267.8235294117647, 45 263.64736842105265, 45 770)), POLYGON ((59.16911764705881 267.8235294117647, 181.94323144104806 418.9301310043668, 311.875 251.875, 239.43506493506493 179.43506493506493, 59.16911764705881 267.8235294117647)), POLYGON ((-310 -280, -310 -153.37692307692305, 241.34156378600824 151.98148148148147, 433.3333333333333 -280, -310 -280)), POLYGON ((266.20000000000005 770, 701 770, 701 344.5238095238096, 311.875 251.875, 181.94323144104806 418.9301310043668, 266.20000000000005 770)), POLYGON ((701 344.523809523809
 6, 701 -280, 433.3333333333333 -280, 241.34156378600824 151.98148148148147, 239.43506493506493 179.43506493506493, 311.875 251.875, 701 344.5238095238096)))");
+
+    GEOSGeom_destroy(geom2_);
+    geom2_ = GEOSVoronoiDiagram(geom1_, nullptr, 10, 1);
+    ensure_equals_wkt(geom2_,
+                      "MULTILINESTRING ((45 770, 45 263.6473684210526), (45 263.6473684210526, -310 146.559649122807), (45 263.6473684210526, 59.16911764705881 267.8235294117647), (59.16911764705881 267.8235294117647, 239.4350649350649 179.4350649350649), (239.4350649350649 179.4350649350649, 241.3415637860082 151.9814814814815), (241.3415637860082 151.9814814814815, -310 -153.376923076923), (266.2 770, 181.9432314410481 418.9301310043668), (181.9432314410481 418.9301310043668, 59.16911764705881 267.8235294117647), (181.9432314410481 418.9301310043668, 311.875 251.875), (311.875 251.875, 239.4350649350649 179.4350649350649), (241.3415637860082 151.9814814814815, 433.3333333333333 -280), (701 344.5238095238096, 311.875 251.875))"
+                     );
+}
+template<>
+template<>
+void object::test<6>
+()
+{
+    geom1_ = GEOSGeomFromWKT("MULTIPOINT ((123 245), (165 313), (240 310), (260 260), (180 210), (240 210))");
+    geom2_ = GEOSVoronoiDiagram(geom1_, nullptr, 0, 1);
+    ensure_equals_wkt(geom2_,
+                      "MULTILINESTRING ((-14 376.5882352941176, 172.3651328095773 261.4803591470258), (172.3651328095773 261.4803591470258, 56.63157894736844 73), (172.3651328095773 261.4803591470258, 200.6640625 265.6015625), (200.6640625 265.6015625, 201 265.4), (201 265.4, 210 251), (210 251, 210 73), (208.04 450, 200.6640625 265.6015625), (397 343.8, 201 265.4), (210 251, 397 176.2))"
+                     );
+}
 } // namespace tut
 
diff --git a/tests/unit/capi/GEOSWithinTest.cpp b/tests/unit/capi/GEOSWithinTest.cpp
index 15f41ad..9165deb 100644
--- a/tests/unit/capi/GEOSWithinTest.cpp
+++ b/tests/unit/capi/GEOSWithinTest.cpp
@@ -9,112 +9,114 @@
 #include <cstdio>
 #include <cstdlib>
 
-namespace tut
-{
-    //
-    // Test Group
-    //
+namespace tut {
+//
+// Test Group
+//
+
+// Common data used in test cases.
+struct test_capigeoswithin_data {
+    GEOSGeometry* geom1_;
+    GEOSGeometry* geom2_;
 
-    // Common data used in test cases.
-    struct test_capigeoswithin_data
+    static void
+    notice(const char* fmt, ...)
     {
-        GEOSGeometry* geom1_;
-        GEOSGeometry* geom2_;
-
-        static void notice(const char *fmt, ...)
-        {
-            std::fprintf( stdout, "NOTICE: ");
-
-            va_list ap;
-            va_start(ap, fmt);
-            std::vfprintf(stdout, fmt, ap);
-            va_end(ap);
-
-            std::fprintf(stdout, "\n");
-        }
-
-        test_capigeoswithin_data()
-            : geom1_(nullptr), geom2_(nullptr)
-        {
-            initGEOS(notice, notice);
-        }
-
-        ~test_capigeoswithin_data()
-        {
-            GEOSGeom_destroy(geom1_);
-            GEOSGeom_destroy(geom2_);
-            geom1_ = nullptr;
-            geom2_ = nullptr;
-            finishGEOS();
-        }
-
-    };
-
-    typedef test_group<test_capigeoswithin_data> group;
-    typedef group::object object;
-
-    group test_capigeoswithin_group("capi::GEOSWithin");
-
-    //
-    // Test Cases
-    //
-
-    template<>
-    template<>
-    void object::test<1>()
+        std::fprintf(stdout, "NOTICE: ");
+
+        va_list ap;
+        va_start(ap, fmt);
+        std::vfprintf(stdout, fmt, ap);
+        va_end(ap);
+
+        std::fprintf(stdout, "\n");
+    }
+
+    test_capigeoswithin_data()
+        : geom1_(nullptr), geom2_(nullptr)
     {
-        geom1_ = GEOSGeomFromWKT("POLYGON EMPTY");
-        geom2_ = GEOSGeomFromWKT("POLYGON EMPTY");
+        initGEOS(notice, notice);
+    }
 
-        ensure( nullptr != geom1_ );
-        ensure( nullptr != geom2_ );
+    ~test_capigeoswithin_data()
+    {
+        GEOSGeom_destroy(geom1_);
+        GEOSGeom_destroy(geom2_);
+        geom1_ = nullptr;
+        geom2_ = nullptr;
+        finishGEOS();
+    }
 
-        char const r1 = GEOSWithin(geom1_, geom2_);
+};
 
-        ensure_equals(r1, 0);
+typedef test_group<test_capigeoswithin_data> group;
+typedef group::object object;
 
-        char const r2 = GEOSWithin(geom2_, geom1_);
+group test_capigeoswithin_group("capi::GEOSWithin");
 
-        ensure_equals(r2, 0);
-    }
+//
+// Test Cases
+//
 
-    template<>
-    template<>
-    void object::test<2>()
-    {
-        geom1_ = GEOSGeomFromWKT("POLYGON((1 1,1 5,5 5,5 1,1 1))");
-        geom2_ = GEOSGeomFromWKT("POINT(2 2)");
+template<>
+template<>
+void object::test<1>
+()
+{
+    geom1_ = GEOSGeomFromWKT("POLYGON EMPTY");
+    geom2_ = GEOSGeomFromWKT("POLYGON EMPTY");
 
-        ensure( nullptr != geom1_ );
-        ensure( nullptr != geom2_ );
+    ensure(nullptr != geom1_);
+    ensure(nullptr != geom2_);
 
-        char const r1 = GEOSWithin(geom1_, geom2_);
+    char const r1 = GEOSWithin(geom1_, geom2_);
 
-        ensure_equals(int(r1), 0);
+    ensure_equals(r1, 0);
 
-        char const r2 = GEOSWithin(geom2_, geom1_);
+    char const r2 = GEOSWithin(geom2_, geom1_);
 
-        ensure_equals(int(r2), 1);
-    }
+    ensure_equals(r2, 0);
+}
 
-    template<>
-    template<>
-    void object::test<3>()
-    {
-        geom1_ = GEOSGeomFromWKT("MULTIPOLYGON(((0 0,0 10,10 10,10 0,0 0)))");
-        geom2_ = GEOSGeomFromWKT("POLYGON((1 1,1 2,2 2,2 1,1 1))");
+template<>
+template<>
+void object::test<2>
+()
+{
+    geom1_ = GEOSGeomFromWKT("POLYGON((1 1,1 5,5 5,5 1,1 1))");
+    geom2_ = GEOSGeomFromWKT("POINT(2 2)");
 
-        ensure( nullptr != geom1_ );
-        ensure( nullptr != geom2_ );
+    ensure(nullptr != geom1_);
+    ensure(nullptr != geom2_);
 
-        char const r1 = GEOSWithin(geom1_, geom2_);
+    char const r1 = GEOSWithin(geom1_, geom2_);
 
-        ensure_equals(int(r1), 0);
+    ensure_equals(int(r1), 0);
 
-        char const r2 = GEOSWithin(geom2_, geom1_);
+    char const r2 = GEOSWithin(geom2_, geom1_);
 
-        ensure_equals(int(r2), 1);
-    }
+    ensure_equals(int(r2), 1);
+}
+
+template<>
+template<>
+void object::test<3>
+()
+{
+    geom1_ = GEOSGeomFromWKT("MULTIPOLYGON(((0 0,0 10,10 10,10 0,0 0)))");
+    geom2_ = GEOSGeomFromWKT("POLYGON((1 1,1 2,2 2,2 1,1 1))");
+
+    ensure(nullptr != geom1_);
+    ensure(nullptr != geom2_);
+
+    char const r1 = GEOSWithin(geom1_, geom2_);
+
+    ensure_equals(int(r1), 0);
+
+    char const r2 = GEOSWithin(geom2_, geom1_);
+
+    ensure_equals(int(r2), 1);
+}
 
 } // namespace tut
 
diff --git a/tests/unit/capi/GEOSisClosedTest.cpp b/tests/unit/capi/GEOSisClosedTest.cpp
index 1fcdf93..37d4f90 100644
--- a/tests/unit/capi/GEOSisClosedTest.cpp
+++ b/tests/unit/capi/GEOSisClosedTest.cpp
@@ -11,85 +11,88 @@
 #include <cstdlib>
 #include <cstring>
 
-namespace tut
-{
-    //
-    // Test Group
-    //
-
-    // Common data used in test cases.
-    struct test_capiisclosed_data
-    {
-        GEOSGeometry* geom_;
-
-        static void notice(const char *fmt, ...)
-        {
-            std::fprintf( stdout, "NOTICE: ");
-
-            va_list ap;
-            va_start(ap, fmt);
-            std::vfprintf(stdout, fmt, ap);
-            va_end(ap);
-
-            std::fprintf(stdout, "\n");
-        }
-
-        test_capiisclosed_data() : geom_(nullptr)
-        {
-            initGEOS(notice, notice);
-        }
-
-        ~test_capiisclosed_data()
-        {
-            GEOSGeom_destroy(geom_);
-            finishGEOS();
-        }
-
-    };
+namespace tut {
+//
+// Test Group
+//
 
-    typedef test_group<test_capiisclosed_data> group;
-    typedef group::object object;
+// Common data used in test cases.
+struct test_capiisclosed_data {
+    GEOSGeometry* geom_;
 
-    group test_capiisclosed_group("capi::GEOSisClosed");
+    static void
+    notice(const char* fmt, ...)
+    {
+        std::fprintf(stdout, "NOTICE: ");
 
-    //
-    // Test Cases
-    //
+        va_list ap;
+        va_start(ap, fmt);
+        std::vfprintf(stdout, fmt, ap);
+        va_end(ap);
 
-    template<>
-    template<>
-    void object::test<1>()
-    {
-        geom_ = GEOSGeomFromWKT("LINESTRING(0 0, 1 0, 1 1)");
-        int r = GEOSisClosed(geom_);
-        ensure_equals(r, 0);
+        std::fprintf(stdout, "\n");
     }
 
-    template<>
-    template<>
-    void object::test<2>()
+    test_capiisclosed_data() : geom_(nullptr)
     {
-        geom_ = GEOSGeomFromWKT("LINESTRING(0 0, 0 1, 1 1, 0 0)");
-        int r = GEOSisClosed(geom_);
-        ensure_equals(r, 1);
+        initGEOS(notice, notice);
     }
 
-    template<>
-    template<>
-    void object::test<3>()
+    ~test_capiisclosed_data()
     {
-        geom_ = GEOSGeomFromWKT("MULTILINESTRING ((1 1, 1 2, 2 2, 1 1), (0 0, 0 1, 1 1))");
-        int r = GEOSisClosed(geom_);
-        ensure_equals(r, 0);
+        GEOSGeom_destroy(geom_);
+        finishGEOS();
     }
 
-    template<>
-    template<>
-    void object::test<4>()
-    {
-        geom_ = GEOSGeomFromWKT("MULTILINESTRING ((1 1, 1 2, 2 2, 1 1), (0 0, 0 1, 1 1, 0 0))");
-        int r = GEOSisClosed(geom_);
-        ensure_equals(r, 1);
-    }
+};
+
+typedef test_group<test_capiisclosed_data> group;
+typedef group::object object;
+
+group test_capiisclosed_group("capi::GEOSisClosed");
+
+//
+// Test Cases
+//
+
+template<>
+template<>
+void object::test<1>
+()
+{
+    geom_ = GEOSGeomFromWKT("LINESTRING(0 0, 1 0, 1 1)");
+    int r = GEOSisClosed(geom_);
+    ensure_equals(r, 0);
+}
+
+template<>
+template<>
+void object::test<2>
+()
+{
+    geom_ = GEOSGeomFromWKT("LINESTRING(0 0, 0 1, 1 1, 0 0)");
+    int r = GEOSisClosed(geom_);
+    ensure_equals(r, 1);
+}
+
+template<>
+template<>
+void object::test<3>
+()
+{
+    geom_ = GEOSGeomFromWKT("MULTILINESTRING ((1 1, 1 2, 2 2, 1 1), (0 0, 0 1, 1 1))");
+    int r = GEOSisClosed(geom_);
+    ensure_equals(r, 0);
+}
+
+template<>
+template<>
+void object::test<4>
+()
+{
+    geom_ = GEOSGeomFromWKT("MULTILINESTRING ((1 1, 1 2, 2 2, 1 1), (0 0, 0 1, 1 1, 0 0))");
+    int r = GEOSisClosed(geom_);
+    ensure_equals(r, 1);
+}
 
 } // namespace tut
diff --git a/tests/unit/capi/GEOSisValidDetailTest.cpp b/tests/unit/capi/GEOSisValidDetailTest.cpp
index a6c9af8..ae554e7 100644
--- a/tests/unit/capi/GEOSisValidDetailTest.cpp
+++ b/tests/unit/capi/GEOSisValidDetailTest.cpp
@@ -11,160 +11,168 @@
 #include <cstdlib>
 #include <cstring>
 
-namespace tut
-{
-    //
-    // Test Group
-    //
-
-    // Common data used in test cases.
-    struct test_capiisvaliddetail_data
-    {
-        GEOSWKTWriter* wktw_;
-        GEOSGeometry* geom_;
-        GEOSGeometry* loc_;
-        char* reason_;
-
-        static void notice(const char *fmt, ...)
-        {
-            std::fprintf( stdout, "NOTICE: ");
-
-            va_list ap;
-            va_start(ap, fmt);
-            std::vfprintf(stdout, fmt, ap);
-            va_end(ap);
-
-            std::fprintf(stdout, "\n");
-        }
-
-        test_capiisvaliddetail_data()
-            : geom_(nullptr), loc_(nullptr), reason_(nullptr)
-        {
-            initGEOS(notice, notice);
-            wktw_ = GEOSWKTWriter_create();
-            GEOSWKTWriter_setTrim(wktw_, 1);
-            GEOSWKTWriter_setOutputDimension(wktw_, 3);
-        }
-
-        std::string toWKT(GEOSGeometry* g)
-        {
-          char* wkt = GEOSWKTWriter_write(wktw_, g);
-          std::string ret (wkt);
-          GEOSFree(wkt);
-          return ret;
-        }
-
-        void strToUpper(std::string &str)
-        {
-            using std::toupper;
-            using std::string;
-
-            for(string::size_type i = 0, len = str.size(); i < len; ++i)
-                str[i] = static_cast<string::value_type>(toupper(str[i]));
-        }
-
-        ~test_capiisvaliddetail_data()
-        {
-            GEOSGeom_destroy(geom_);
-            GEOSGeom_destroy(loc_);
-            GEOSFree(reason_);
-            GEOSWKTWriter_destroy(wktw_);
-            finishGEOS();
-        }
-
-    };
+namespace tut {
+//
+// Test Group
+//
 
-    typedef test_group<test_capiisvaliddetail_data> group;
-    typedef group::object object;
+// Common data used in test cases.
+struct test_capiisvaliddetail_data {
+    GEOSWKTWriter* wktw_;
+    GEOSGeometry* geom_;
+    GEOSGeometry* loc_;
+    char* reason_;
 
-    group test_capiisvaliddetail_group("capi::GEOSisValidDetail");
+    static void
+    notice(const char* fmt, ...)
+    {
+        std::fprintf(stdout, "NOTICE: ");
 
-    //
-    // Test Cases
-    //
+        va_list ap;
+        va_start(ap, fmt);
+        std::vfprintf(stdout, fmt, ap);
+        va_end(ap);
 
+        std::fprintf(stdout, "\n");
+    }
 
-    // Flag values
-    template<>
-    template<>
-    void object::test<1>()
+    test_capiisvaliddetail_data()
+        : geom_(nullptr), loc_(nullptr), reason_(nullptr)
     {
-      ensure_equals(GEOSVALID_ALLOW_SELFTOUCHING_RING_FORMING_HOLE, 1);
+        initGEOS(notice, notice);
+        wktw_ = GEOSWKTWriter_create();
+        GEOSWKTWriter_setTrim(wktw_, 1);
+        GEOSWKTWriter_setOutputDimension(wktw_, 3);
     }
 
-    // Valid case
-    template<>
-    template<>
-    void object::test<2>()
+    std::string
+    toWKT(GEOSGeometry* g)
     {
-      // Looks invalid (self-intersecting) but isn't
-      // (is non-simple though)
-      geom_ = GEOSGeomFromWKT("LINESTRING(0 0, 10 0, 5 -5, 5 5)");
-      int r = GEOSisValidDetail(geom_, 0, &reason_, &loc_);
-      ensure_equals(r, 1); // valid
-      ensure_equals(reason_, (void*)nullptr);
-      ensure_equals(loc_, (void*)nullptr);
+        char* wkt = GEOSWKTWriter_write(wktw_, g);
+        std::string ret(wkt);
+        GEOSFree(wkt);
+        return ret;
     }
 
-    // Invalid coordinate
-    template<>
-    template<>
-    void object::test<3>()
+    void
+    strToUpper(std::string& str)
     {
-      geom_ = GEOSGeomFromWKT("LINESTRING(0 0, 10 0, NaN -5)");
-      ensure(nullptr != geom_);
-      int r = GEOSisValidDetail(geom_, 0, &reason_, &loc_);
-      std::string wkt = toWKT(loc_);
-      strToUpper(wkt);
-      ensure_equals(r, 0); // invalid
-      ensure_equals(std::string(reason_), std::string("Invalid Coordinate"));
-      std::string exp1 = "POINT (NAN -5)";
-      std::string exp2 = "POINT (-1#IND -5)";
-      // http://trac.osgeo.org/geos/ticket/656
-      std::string exp3 = "POINT (1.#QNAN -5)";
-      std::stringstream ss;
-      ss << "Expected '" << exp1 << "' or '" << exp2 << "' or '" << exp3 << "', Obtained '" << wkt;
-      ensure(ss.str(),
-        wkt == exp1 ||
-        wkt == exp2 ||
-        wkt == exp3);
+        using std::toupper;
+        using std::string;
+
+        for(string::size_type i = 0, len = str.size(); i < len; ++i) {
+            str[i] = static_cast<string::value_type>(toupper(str[i]));
+        }
     }
 
-    // Self intersecting ring forming hole
-    template<>
-    template<>
-    void object::test<4>()
+    ~test_capiisvaliddetail_data()
     {
-      geom_ = GEOSGeomFromWKT("POLYGON((0 1, -10 10, 10 10, 0 1, 4 6, -4 6, 0 1))");
-      int r = GEOSisValidDetail(geom_, 0, &reason_, &loc_);
-      ensure_equals(r, 0); // invalid
-      ensure_equals(std::string(reason_), std::string("Ring Self-intersection"));
-      ensure_equals(toWKT(loc_), "POINT (0 1)");
+        GEOSGeom_destroy(geom_);
+        GEOSGeom_destroy(loc_);
+        GEOSFree(reason_);
+        GEOSWKTWriter_destroy(wktw_);
+        finishGEOS();
     }
 
-    // Self intersecting ring forming hole (with ESRI flag)
-    template<>
-    template<>
-    void object::test<5>()
-    {
-      geom_ = GEOSGeomFromWKT("POLYGON((0 1, -10 10, 10 10, 0 1, 4 6, -4 6, 0 1))");
-      int flags = GEOSVALID_ALLOW_SELFTOUCHING_RING_FORMING_HOLE;
+};
 
-      int r = GEOSisValidDetail(geom_, flags, &reason_, &loc_);
-      ensure_equals(r, 1); // valid
-      ensure_equals(reason_, (void*)nullptr);
-      ensure_equals(loc_, (void*)nullptr);
-    }
+typedef test_group<test_capiisvaliddetail_data> group;
+typedef group::object object;
 
-    // Check it is possible to not request details
-    template<>
-    template<>
-    void object::test<6>()
-    {
-      geom_ = GEOSGeomFromWKT("POLYGON((0 1, -10 10, 10 10, 0 1, 4 6, -4 6, 0 1))");
-      int r = GEOSisValidDetail(geom_, 0, nullptr, nullptr);
-      ensure_equals(r, 0); // invalid
-    }
+group test_capiisvaliddetail_group("capi::GEOSisValidDetail");
+
+//
+// Test Cases
+//
+
+
+// Flag values
+template<>
+template<>
+void object::test<1>
+()
+{
+    ensure_equals(GEOSVALID_ALLOW_SELFTOUCHING_RING_FORMING_HOLE, 1);
+}
+
+// Valid case
+template<>
+template<>
+void object::test<2>
+()
+{
+    // Looks invalid (self-intersecting) but isn't
+    // (is non-simple though)
+    geom_ = GEOSGeomFromWKT("LINESTRING(0 0, 10 0, 5 -5, 5 5)");
+    int r = GEOSisValidDetail(geom_, 0, &reason_, &loc_);
+    ensure_equals(r, 1); // valid
+    ensure_equals(reason_, (void*)nullptr);
+    ensure_equals(loc_, (void*)nullptr);
+}
+
+// Invalid coordinate
+template<>
+template<>
+void object::test<3>
+()
+{
+    geom_ = GEOSGeomFromWKT("LINESTRING(0 0, 10 0, NaN -5)");
+    ensure(nullptr != geom_);
+    int r = GEOSisValidDetail(geom_, 0, &reason_, &loc_);
+    std::string wkt = toWKT(loc_);
+    strToUpper(wkt);
+    ensure_equals(r, 0); // invalid
+    ensure_equals(std::string(reason_), std::string("Invalid Coordinate"));
+    std::string exp1 = "POINT (NAN -5)";
+    std::string exp2 = "POINT (-1#IND -5)";
+    // http://trac.osgeo.org/geos/ticket/656
+    std::string exp3 = "POINT (1.#QNAN -5)";
+    std::stringstream ss;
+    ss << "Expected '" << exp1 << "' or '" << exp2 << "' or '" << exp3 << "', Obtained '" << wkt;
+    ensure(ss.str(),
+           wkt == exp1 ||
+           wkt == exp2 ||
+           wkt == exp3);
+}
+
+// Self intersecting ring forming hole
+template<>
+template<>
+void object::test<4>
+()
+{
+    geom_ = GEOSGeomFromWKT("POLYGON((0 1, -10 10, 10 10, 0 1, 4 6, -4 6, 0 1))");
+    int r = GEOSisValidDetail(geom_, 0, &reason_, &loc_);
+    ensure_equals(r, 0); // invalid
+    ensure_equals(std::string(reason_), std::string("Ring Self-intersection"));
+    ensure_equals(toWKT(loc_), "POINT (0 1)");
+}
+
+// Self intersecting ring forming hole (with ESRI flag)
+template<>
+template<>
+void object::test<5>
+()
+{
+    geom_ = GEOSGeomFromWKT("POLYGON((0 1, -10 10, 10 10, 0 1, 4 6, -4 6, 0 1))");
+    int flags = GEOSVALID_ALLOW_SELFTOUCHING_RING_FORMING_HOLE;
+
+    int r = GEOSisValidDetail(geom_, flags, &reason_, &loc_);
+    ensure_equals(r, 1); // valid
+    ensure_equals(reason_, (void*)nullptr);
+    ensure_equals(loc_, (void*)nullptr);
+}
+
+// Check it is possible to not request details
+template<>
+template<>
+void object::test<6>
+()
+{
+    geom_ = GEOSGeomFromWKT("POLYGON((0 1, -10 10, 10 10, 0 1, 4 6, -4 6, 0 1))");
+    int r = GEOSisValidDetail(geom_, 0, nullptr, nullptr);
+    ensure_equals(r, 0); // invalid
+}
 
 } // namespace tut
 
diff --git a/tests/unit/geom/CoordinateArraySequenceFactoryTest.cpp b/tests/unit/geom/CoordinateArraySequenceFactoryTest.cpp
index ccc056f..e31da6b 100644
--- a/tests/unit/geom/CoordinateArraySequenceFactoryTest.cpp
+++ b/tests/unit/geom/CoordinateArraySequenceFactoryTest.cpp
@@ -11,187 +11,180 @@
 #include <exception>
 #include <vector>
 
-namespace tut
+namespace tut {
+//
+// Test Group
+//
+
+// Common data used by tests
+struct test_coordinatearraysequencefactory_data {
+    typedef geos::geom::CoordinateSequence* CoordinateSequencePtr;
+    typedef geos::geom::CoordinateSequenceFactory const* CoordinateFactoryCPtr;
+    typedef geos::geom::CoordinateArraySequenceFactory const* CoordinateArrayFactoryCPtr;
+
+    test_coordinatearraysequencefactory_data() {}
+};
+
+typedef test_group<test_coordinatearraysequencefactory_data> group;
+typedef group::object object;
+
+group test_coordinatearraysequencefactory_group("geos::geom::CoordinateArraySequenceFactory");
+
+//
+// Test Cases
+//
+
+// Test of instance()
+template<>
+template<>
+void object::test<1>
+()
+{
+    try {
+        CoordinateFactoryCPtr base = geos::geom::CoordinateArraySequenceFactory::instance();
+        ensure(nullptr != base);
+
+        ensure(typeid(base).name(), typeid(base) == typeid(CoordinateFactoryCPtr));
+        ensure(typeid(base).name(), typeid(base) != typeid(CoordinateArrayFactoryCPtr));
+
+        CoordinateArrayFactoryCPtr derived;
+        derived = dynamic_cast<CoordinateArrayFactoryCPtr>(base);
+        ensure(nullptr != derived);
+        ensure(typeid(derived).name(), typeid(derived) == typeid(CoordinateArrayFactoryCPtr));
+    }
+    catch(std::exception& e) {
+        /** ignore failure.  TODO figure out why this fails on BSD/Clang
+        *  https://trac.osgeo.org/geos/ticket/894 and then put back**/
+        //fail( e.what() );
+    }
+}
+
+
+// Test of first version of create() with empty sequence
+template<>
+template<>
+void object::test<2>
+()
 {
-	//
-	// Test Group
-	//
-
-	// Common data used by tests
-	struct test_coordinatearraysequencefactory_data
-	{
-		typedef geos::geom::CoordinateSequence* CoordinateSequencePtr;
-		typedef geos::geom::CoordinateSequenceFactory const* CoordinateFactoryCPtr;
-		typedef geos::geom::CoordinateArraySequenceFactory const* CoordinateArrayFactoryCPtr;
-
-		test_coordinatearraysequencefactory_data() {}
-	};
-
-	typedef test_group<test_coordinatearraysequencefactory_data> group;
-	typedef group::object object;
-
-	group test_coordinatearraysequencefactory_group("geos::geom::CoordinateArraySequenceFactory");
-
-	//
-	// Test Cases
-	//
-
-	// Test of instance()
-	template<>
-	template<>
-	void object::test<1>()
-	{
-		try
-		{
-			CoordinateFactoryCPtr base = geos::geom::CoordinateArraySequenceFactory::instance();
-			ensure( nullptr != base );
-
-			ensure(typeid(base).name(), typeid(base) == typeid(CoordinateFactoryCPtr) );
-			ensure(typeid(base).name(), typeid(base) != typeid(CoordinateArrayFactoryCPtr) );
-
-			CoordinateArrayFactoryCPtr derived;
-			derived = dynamic_cast<CoordinateArrayFactoryCPtr>(base);
-			ensure( nullptr != derived );
-			ensure(typeid(derived).name(), typeid(derived) == typeid(CoordinateArrayFactoryCPtr) );
-		}
-		catch (std::exception& e)
-		{
-		/** ignore failure.  TODO figure out why this fails on BSD/Clang
-		*  https://trac.osgeo.org/geos/ticket/894 and then put back**/
-			//fail( e.what() );
-		}
-	}
-
-
-	// Test of first version of create() with empty sequence
-	template<>
-	template<>
-	void object::test<2>()
-	{
-		using geos::geom::Coordinate;
-
-		try
-		{
-			CoordinateFactoryCPtr factory = geos::geom::CoordinateArraySequenceFactory::instance();
-
-			ensure( nullptr != factory );
-
-			std::vector<Coordinate>* col = new std::vector<Coordinate>();
-
-			ensure( nullptr != col);
-
-			const size_t size0 = 0;
-			CoordinateSequencePtr sequence = factory->create(col);
-
-			ensure( nullptr != sequence);
-			ensure( sequence->isEmpty() );
-			ensure_equals( sequence->size(), size0 );
-
-			// FREE MEMORY
-			delete sequence;
-		}
-		catch (std::exception& e)
-		{
-			fail( e.what() );
-		}
-	}
-
-	// Test of first version of create() with non-empty sequence
-	template<>
-	template<>
-	void object::test<3>()
-	{
-		using geos::geom::Coordinate;
-
-		try
-		{
-			CoordinateFactoryCPtr factory = geos::geom::CoordinateArraySequenceFactory::instance();
-			ensure( nullptr != factory );
-
-			std::vector<Coordinate>* col = new std::vector<Coordinate>();
-
-			ensure( nullptr != col);
-
-			col->push_back(Coordinate(1, 2, 3));
-			col->push_back(Coordinate(5, 10, 15));
-
-			const size_t size2 = 2;
-			CoordinateSequencePtr sequence = factory->create(col);
-
-			ensure( nullptr != sequence);
-			ensure( !sequence->isEmpty() );
-			ensure_equals( sequence->size(), size2 );
-			ensure( sequence->getAt(0) != sequence->getAt(1) );
-
-			// FREE MEMORY
-			delete sequence;
-		}
-		catch (std::exception& e)
-		{
-			fail( e.what() );
-		}
-	}
-
-	// Test of second version of create()
-	template<>
-	template<>
-	void object::test<4>()
-	{
-		using geos::geom::Coordinate;
-
-		try
-		{
-			CoordinateFactoryCPtr factory = geos::geom::CoordinateArraySequenceFactory::instance();
-
-			ensure( nullptr != factory );
-
-			const size_t size1000 = 1000;
-			CoordinateSequencePtr sequence = factory->create(size1000, 3);
-
-			ensure( nullptr != sequence);
-			ensure( !sequence->isEmpty() );
-			ensure_equals( sequence->size(), size1000 );
-			ensure( sequence->hasRepeatedPoints() );
-			ensure_equals( sequence->getAt(0), sequence->getAt(size1000 - 1) );
-			ensure_equals( sequence->getAt(0), sequence->getAt(size1000 / 2) );
-
-			// FREE MEMORY
-			delete sequence;
-		}
-		catch (std::exception& e)
-		{
-			fail( e.what() );
-		}
-	}
-
-	// Test of create() without arguments
-	template<>
-	template<>
-	void object::test<5>()
-	{
-		using geos::geom::Coordinate;
-
-		try
-		{
-			CoordinateFactoryCPtr factory = geos::geom::CoordinateArraySequenceFactory::instance();
-
-			ensure( nullptr != factory );
-
-			const size_t size0 = 0;
-			CoordinateSequencePtr sequence = factory->create();
-
-			ensure( nullptr != sequence);
-			ensure( sequence->isEmpty() );
-			ensure_equals( sequence->size(), size0 );
-
-			// FREE MEMORY
-			delete sequence;
-		}
-		catch (std::exception& e)
-		{
-			fail( e.what() );
-		}
-	}
+    using geos::geom::Coordinate;
+
+    try {
+        CoordinateFactoryCPtr factory = geos::geom::CoordinateArraySequenceFactory::instance();
+
+        ensure(nullptr != factory);
+
+        std::vector<Coordinate>* col = new std::vector<Coordinate>();
+
+        ensure(nullptr != col);
+
+        const size_t size0 = 0;
+        CoordinateSequencePtr sequence = factory->create(col);
+
+        ensure(nullptr != sequence);
+        ensure(sequence->isEmpty());
+        ensure_equals(sequence->size(), size0);
+
+        // FREE MEMORY
+        delete sequence;
+    }
+    catch(std::exception& e) {
+        fail(e.what());
+    }
+}
+
+// Test of first version of create() with non-empty sequence
+template<>
+template<>
+void object::test<3>
+()
+{
+    using geos::geom::Coordinate;
+
+    try {
+        CoordinateFactoryCPtr factory = geos::geom::CoordinateArraySequenceFactory::instance();
+        ensure(nullptr != factory);
+
+        std::vector<Coordinate>* col = new std::vector<Coordinate>();
+
+        ensure(nullptr != col);
+
+        col->push_back(Coordinate(1, 2, 3));
+        col->push_back(Coordinate(5, 10, 15));
+
+        const size_t size2 = 2;
+        CoordinateSequencePtr sequence = factory->create(col);
+
+        ensure(nullptr != sequence);
+        ensure(!sequence->isEmpty());
+        ensure_equals(sequence->size(), size2);
+        ensure(sequence->getAt(0) != sequence->getAt(1));
+
+        // FREE MEMORY
+        delete sequence;
+    }
+    catch(std::exception& e) {
+        fail(e.what());
+    }
+}
+
+// Test of second version of create()
+template<>
+template<>
+void object::test<4>
+()
+{
+    using geos::geom::Coordinate;
+
+    try {
+        CoordinateFactoryCPtr factory = geos::geom::CoordinateArraySequenceFactory::instance();
+
+        ensure(nullptr != factory);
+
+        const size_t size1000 = 1000;
+        CoordinateSequencePtr sequence = factory->create(size1000, 3);
+
+        ensure(nullptr != sequence);
+        ensure(!sequence->isEmpty());
+        ensure_equals(sequence->size(), size1000);
+        ensure(sequence->hasRepeatedPoints());
+        ensure_equals(sequence->getAt(0), sequence->getAt(size1000 - 1));
+        ensure_equals(sequence->getAt(0), sequence->getAt(size1000 / 2));
+
+        // FREE MEMORY
+        delete sequence;
+    }
+    catch(std::exception& e) {
+        fail(e.what());
+    }
+}
+
+// Test of create() without arguments
+template<>
+template<>
+void object::test<5>
+()
+{
+    using geos::geom::Coordinate;
+
+    try {
+        CoordinateFactoryCPtr factory = geos::geom::CoordinateArraySequenceFactory::instance();
+
+        ensure(nullptr != factory);
+
+        const size_t size0 = 0;
+        CoordinateSequencePtr sequence = factory->create();
+
+        ensure(nullptr != sequence);
+        ensure(sequence->isEmpty());
+        ensure_equals(sequence->size(), size0);
+
+        // FREE MEMORY
+        delete sequence;
+    }
+    catch(std::exception& e) {
+        fail(e.what());
+    }
+}
 
 
 } // namespace tut
diff --git a/tests/unit/geom/CoordinateArraySequenceTest.cpp b/tests/unit/geom/CoordinateArraySequenceTest.cpp
index 71f9893..19bcefe 100644
--- a/tests/unit/geom/CoordinateArraySequenceTest.cpp
+++ b/tests/unit/geom/CoordinateArraySequenceTest.cpp
@@ -13,625 +13,659 @@
 #include <iostream>
 #include <cmath>
 
-namespace tut
-{
-    //
-    // Test Group
-    //
+namespace tut {
+//
+// Test Group
+//
 
-    // Common data used by tests
-    struct test_coordinatearraysequence_data
-    {
-        test_coordinatearraysequence_data() {}
+// Common data used by tests
+struct test_coordinatearraysequence_data {
+    test_coordinatearraysequence_data() {}
 
-        struct Filter : public geos::geom::CoordinateFilter
+    struct Filter : public geos::geom::CoordinateFilter {
+        bool is3d;
+        Filter() : is3d(false) {}
+        void
+        filter_rw(geos::geom::Coordinate* c) const override
         {
-          bool is3d;
-          Filter() : is3d(false) {}
-          void filter_rw(geos::geom::Coordinate* c) const override {
-            if ( is3d ) {
-              if ( std::isnan(c->z) ) c->z = 0.0;
+            if(is3d) {
+                if(std::isnan(c->z)) {
+                    c->z = 0.0;
+                }
+            }
+            else {
+                c->z = geos::DoubleNotANumber;
             }
-            else c->z = geos::DoubleNotANumber;
-          }
-        };
+        }
     };
+};
 
-    typedef test_group<test_coordinatearraysequence_data> group;
-    typedef group::object object;
-
-    group test_coordinatearraysequence_group("geos::geom::CoordinateArraySequence");
+typedef test_group<test_coordinatearraysequence_data> group;
+typedef group::object object;
 
-    //
-    // Test Cases
-    //
+group test_coordinatearraysequence_group("geos::geom::CoordinateArraySequence");
 
-    // Test of default constructor
-    template<>
-    template<>
-    void object::test<1>()
-    {
-		const size_t size = 0;
-        geos::geom::CoordinateArraySequence sequence;
-
-        ensure( sequence.isEmpty() );
-        ensure_equals( sequence.getSize(), size );
-		ensure_equals( sequence.size(), size );
-
-		ensure_equals( sequence.toString(), std::string("()") );
-
-		const size_t dim = 3;
-		ensure_equals( sequence.getDimension() , dim);
-    }
-
-    // Test of overriden constructor
-    template<>
-    template<>
-    void object::test<2>()
-    {
-		const size_t size = 3;
-        geos::geom::CoordinateArraySequence sequence(size);
-
-        ensure( !sequence.isEmpty() );
-        ensure_equals( sequence.getSize(), size );
-		ensure_equals( sequence.size(), size );
-
-		ensure( sequence.toString() != std::string("()") );
-
-		ensure("Every coodinate in the default sequence should be same.", sequence.hasRepeatedPoints() );
-
-		const size_t dim = 2; // default/empty coordinates now 2D.
-		ensure_equals( sequence.getDimension(), dim );
-    }
-
-    // Test of overriden constructor taking vector of coordiantes
-    template<>
-    template<>
-    void object::test<3>()
-    {
-		using geos::geom::Coordinate;
-
-		const size_t size = 3;
-		const double a = 0;
-		const double b = 5.0;
-		const double c = 10.0;
-
-		std::vector<Coordinate>* col = new std::vector<Coordinate>();
-		col->push_back(Coordinate(a, a, a));
-		col->push_back(Coordinate(b, b, b));
-		col->push_back(Coordinate(c, c, c));
-
-		// sequence takes ownership of the col
-		geos::geom::CoordinateArraySequence sequence(col);
-
-		ensure( !sequence.isEmpty() );
-        ensure_equals( sequence.getSize(), size );
-		ensure_equals( sequence.size(), size );
-
-		ensure( sequence.toString() != std::string("()") );
-
-		ensure("Coordinate sequence should contain unique coordinates.", !sequence.hasRepeatedPoints() );
-	}
-
-    // Test of copy constructor
-    template<>
-    template<>
-    void object::test<4>()
-    {
-		using geos::geom::Coordinate;
-
-		// Create empty sequence
-		const size_t sizeEmpty = 0;
-        geos::geom::CoordinateArraySequence empty_original;
-
-		ensure( empty_original.isEmpty() );
-		ensure_equals( empty_original.size(), sizeEmpty );
-		ensure_equals( empty_original.toString(), std::string("()") );
-
-		// Create copy of empty sequence
-		geos::geom::CoordinateArraySequence empty_copy(empty_original);
-
-		ensure( empty_copy.isEmpty() );
-		ensure_equals( empty_copy.size(), sizeEmpty );
-		ensure_equals( empty_copy.toString(), std::string("()") );
-
-		// Create non-empty sequence
-		const size_t sizeNonEmpty = 2;
-		std::vector<Coordinate>* col = new std::vector<Coordinate>();
-		col->push_back(Coordinate(1, 2, 3));
-		col->push_back(Coordinate(5, 10, 15));
-		geos::geom::CoordinateArraySequence non_empty_original(col);
-
-		ensure( !non_empty_original.isEmpty() );
-		ensure_equals( non_empty_original.size(), sizeNonEmpty );
-
-		// Create copy of non-empty sequence
-		geos::geom::CoordinateArraySequence non_empty_copy(non_empty_original);
-
-		ensure( !non_empty_copy.isEmpty() );
-		ensure_equals( non_empty_copy.size(), sizeNonEmpty );
-
-		// Compare non-empty original and copy using equality operators
-		ensure_equals( non_empty_original.getAt(0), non_empty_copy.getAt(0) );
-		ensure_equals( non_empty_original.getAt(1), non_empty_copy.getAt(1) );
-		ensure( non_empty_original.getAt(0) != non_empty_copy.getAt(1) );
-	}
-
-    // Test of getX() and getY()
-    template<>
-    template<>
-    void object::test<5>()
-    {
-		using geos::geom::Coordinate;
-
-		// Create non-empty sequence
-		std::vector<Coordinate>* col = new std::vector<Coordinate>();
-		col->push_back(Coordinate(1, 2));
-		col->push_back(Coordinate(5, 10));
-
-		const size_t size = 2;
-		geos::geom::CoordinateArraySequence sequence(col);
-
-		ensure( !sequence.isEmpty() );
-		ensure_equals( sequence.size(), size );
-
-		ensure_equals( sequence.getX(0), 1 );
-		ensure_equals( sequence.getY(0), 2 );
-		ensure_equals( sequence.getX(1), 5 );
-		ensure_equals( sequence.getY(1), 10 );
-	}
-
-    // Test of getAt()
-    template<>
-    template<>
-    void object::test<6>()
-    {
-		using geos::geom::Coordinate;
-
-		// Create non-empty sequence
-		std::vector<Coordinate>* col = new std::vector<Coordinate>();
-		col->push_back(Coordinate(1, 2, 3));
-		col->push_back(Coordinate(5, 10, 15));
-
-		const size_t size = 2;
-		geos::geom::CoordinateArraySequence sequence(col);
-
-		ensure( !sequence.isEmpty() );
-		ensure_equals( sequence.size(), size );
-		ensure( sequence.getAt(0) != sequence.getAt(1) );
-
-		// First version of getAt()
-		ensure_equals( sequence.getAt(0).x, 1 );
-		ensure_equals( sequence.getAt(0).y, 2 );
-		ensure_equals( sequence.getAt(0).z, 3 );
-		ensure_equals( sequence.getAt(1).x, 5 );
-		ensure_equals( sequence.getAt(1).y, 10 );
-		ensure_equals( sequence.getAt(1).z, 15 );
-
-		// Second version of getAt()
-		Coordinate buf;
-
-		sequence.getAt(0, buf);
-		ensure_equals( buf.x, 1 );
-		ensure_equals( buf.y, 2 );
-		ensure_equals( buf.z, 3 );
-
-		sequence.getAt(1, buf);
-		ensure_equals( buf.x, 5 );
-		ensure_equals( buf.y, 10 );
-		ensure_equals( buf.z, 15 );
-	}
-
-    // Test of add()
-    template<>
-    template<>
-    void object::test<7>()
-    {
-		using geos::geom::Coordinate;
-
-		// Create empty sequence to fill with coordinates
-		const size_t size = 0;
-		geos::geom::CoordinateArraySequence sequence;
-
-		ensure( sequence.isEmpty() );
-		ensure_equals( sequence.size(), size );
-
-		// Add coordinates
-		Coordinate tmp(1, 2, 3);
-		sequence.add(tmp); // insert copy of tmp
-		const size_t sizeOne = 1;
-
-		ensure( !sequence.isEmpty() );
-		ensure_equals( sequence.size(), sizeOne );
-
-		tmp.x = 5;
-		tmp.y = 10;
-		tmp.z = 15;
-		sequence.add(tmp); // insert copy of tmp
-		const size_t sizeTwo = 2;
-
-		ensure( !sequence.isEmpty() );
-		ensure_equals( sequence.size(), sizeTwo );
-
-		ensure( !sequence.hasRepeatedPoints() );
-
-		// Check elements of sequence
-		ensure( sequence.getAt(0) != sequence.getAt(1) );
-
-		ensure_equals( sequence.getAt(0).x, 1 );
-		ensure_equals( sequence.getAt(0).y, 2 );
-		ensure_equals( sequence.getAt(0).z, 3 );
-		ensure_equals( sequence.getAt(1).x, 5 );
-		ensure_equals( sequence.getAt(1).y, 10 );
-		ensure_equals( sequence.getAt(1).z, 15 );
-	}
-
-    // Test of setAt()
-    template<>
-    template<>
-    void object::test<8>()
-    {
-		using geos::geom::Coordinate;
-
-		// Create sequence with 2 default coordinates
-		const size_t size = 2;
-		geos::geom::CoordinateArraySequence sequence(size);
-
-		ensure( !sequence.isEmpty() );
-		ensure_equals( sequence.size(), size );
-		ensure( sequence.hasRepeatedPoints() );
-
-		// Set new values to first coordinate
-		Coordinate first(1, 2, 3);
-		sequence.setAt(first, 0);
-
-		ensure_equals( sequence.size(), size );
-		ensure_equals( sequence.getAt(0).x, 1 );
-		ensure_equals( sequence.getAt(0).y, 2 );
-		ensure_equals( sequence.getAt(0).z, 3 );
-
-
-		// Set new values to second coordinate
-		Coordinate second(5, 10, 15);
-		sequence.setAt(second, 1);
-
-		ensure_equals( sequence.size(), size );
-
-		ensure_equals( sequence.getAt(1).x, 5 );
-		ensure_equals( sequence.getAt(1).y, 10 );
-		ensure_equals( sequence.getAt(1).z, 15 );
-
-		ensure( !sequence.hasRepeatedPoints() );
-	}
-
-    // Test of deleteAt()
-    template<>
-    template<>
-    void object::test<9>()
-    {
-		using geos::geom::Coordinate;
-
-		// Create sequence with only 1 default coordinate
-		const size_t sizeOne = 1;
-		geos::geom::CoordinateArraySequence sequence(1);
-
-		ensure( !sequence.isEmpty() );
-		ensure_equals( sequence.size(), sizeOne );
-
-		// Delete the only coordinate in the sequence
-		sequence.deleteAt(0);
-		const size_t sizeZero = 0;
-
-		ensure( sequence.isEmpty() );
-		ensure_equals( sequence.size(), sizeZero );
-
-		// Add new 3 coordinates
-		Coordinate first(1, 2, 3);
-		sequence.add(first);
-		Coordinate second(5, 10, 15);
-		sequence.add(second);
-		Coordinate third(9, 18, 27);
-		sequence.add(third);
-		const size_t sizeThree = 3;
-
-		ensure( !sequence.isEmpty() );
-		ensure_equals( sequence.size(), sizeThree );
-
-		// Delete coordinate in the middle of sequence - the second one.
-		sequence.deleteAt(1); // (5, 10, 15)
-		const size_t sizeTwo = 2;
-
-		ensure( !sequence.isEmpty() );
-		ensure_equals( sequence.size(), sizeTwo );
-
-		ensure( sequence.getAt(0) != sequence.getAt(1) );
-		ensure_equals( sequence.getAt(0), first );
-		ensure( "deleteAt() did not remove coordinate.", sequence.getAt(1) != second );
-		ensure_equals( sequence.getAt(1), third );
-	}
-
-	// Test of setPoints()
-    template<>
-    template<>
-    void object::test<10>()
-    {
-		using geos::geom::Coordinate;
-
-		// Create empty sequence
-		const size_t size = 0;
-		geos::geom::CoordinateArraySequence sequence;
-
-		ensure( sequence.isEmpty() );
-		ensure_equals( sequence.size(), size );
-
-		// Create collection of points
-		const std::vector<Coordinate>::size_type sizeCol = 3;
-		std::vector<Coordinate> col;
-		col.push_back(Coordinate(1, 2, 3));
-		col.push_back(Coordinate(5, 10, 15));
-		col.push_back(Coordinate(9, 18, 27));
+//
+// Test Cases
+//
 
-		ensure( "std::vector bug assumed!", !col.empty() );
-		ensure_equals( "std::vector bug assumed!", col.size(), sizeCol );
-
-		// Use setPoints()
-		sequence.setPoints(col);
-
-		ensure( !sequence.isEmpty() );
-		ensure_equals( sequence.size(), col.size() );
-		ensure( !sequence.hasRepeatedPoints() );
+// Test of default constructor
+template<>
+template<>
+void object::test<1>
+()
+{
+    const size_t size = 0;
+    geos::geom::CoordinateArraySequence sequence;
 
-		// Check inserted points
-		ensure_equals( sequence.getAt(0).x, 1 );
-		ensure_equals( sequence.getAt(0).y, 2 );
-		ensure_equals( sequence.getAt(0).z, 3 );
+    ensure(sequence.isEmpty());
+    ensure_equals(sequence.getSize(), size);
+    ensure_equals(sequence.size(), size);
 
-		ensure_equals( sequence.getAt(1).x, 5 );
-		ensure_equals( sequence.getAt(1).y, 10 );
-		ensure_equals( sequence.getAt(1).z, 15 );
+    ensure_equals(sequence.toString(), std::string("()"));
 
-		ensure_equals( sequence.getAt(2).x, 9 );
-		ensure_equals( sequence.getAt(2).y, 18 );
-		ensure_equals( sequence.getAt(2).z, 27 );
-	}
+    const size_t dim = 3;
+    ensure_equals(sequence.getDimension(), dim);
+}
 
-	// Test of removeRepeatedPoints
-	template<>
-	template<>
-	void object::test<11>()
-	{
-		using geos::geom::Coordinate;
+// Test of overriden constructor
+template<>
+template<>
+void object::test<2>
+()
+{
+    const size_t size = 3;
+    geos::geom::CoordinateArraySequence sequence(size);
 
-		geos::geom::CoordinateArraySequence sequence;
+    ensure(!sequence.isEmpty());
+    ensure_equals(sequence.getSize(), size);
+    ensure_equals(sequence.size(), size);
 
-		// Add new 3 equal coordinates
-		Coordinate c(1, 2, 3);
-		sequence.add(c);
-		sequence.add(c);
-		sequence.add(c);
+    ensure(sequence.toString() != std::string("()"));
 
-		Coordinate c2(5, 10, 15);
-		sequence.add(c2);
-		sequence.add(c2);
+    ensure("Every coodinate in the default sequence should be same.", sequence.hasRepeatedPoints());
 
-		sequence.add(c);
+    const size_t dim = 2; // default/empty coordinates now 2D.
+    ensure_equals(sequence.getDimension(), dim);
+}
 
-		ensure_equals( sequence.size(), 6u );
-		sequence.removeRepeatedPoints();
+// Test of overriden constructor taking vector of coordiantes
+template<>
+template<>
+void object::test<3>
+()
+{
+    using geos::geom::Coordinate;
 
-		ensure_equals( sequence.size(), 3u );
-	}
+    const size_t size = 3;
+    const double a = 0;
+    const double b = 5.0;
+    const double c = 10.0;
 
-	// Test of equality and inequality operators
-	template<>
-	template<>
-	void object::test<12>()
-	{
-		using geos::geom::Coordinate;
-		using geos::geom::CoordinateArraySequence;
-		using geos::geom::CoordinateSequence;
+    std::vector<Coordinate>* col = new std::vector<Coordinate>();
+    col->push_back(Coordinate(a, a, a));
+    col->push_back(Coordinate(b, b, b));
+    col->push_back(Coordinate(c, c, c));
 
-		Coordinate c1(1, 2, 3);
-		Coordinate c2(5, 10, 15);
-		Coordinate c3(6, 9, 10);
+    // sequence takes ownership of the col
+    geos::geom::CoordinateArraySequence sequence(col);
 
-		CoordinateArraySequence sequence1;
-		CoordinateArraySequence sequence2;
+    ensure(!sequence.isEmpty());
+    ensure_equals(sequence.getSize(), size);
+    ensure_equals(sequence.size(), size);
 
-		sequence1.add(c1);
-		sequence1.add(c2);
-		sequence1.add(c3);
+    ensure(sequence.toString() != std::string("()"));
 
-		sequence2.add(c1);
-		sequence2.add(c2);
-		sequence2.add(c3);
+    ensure("Coordinate sequence should contain unique coordinates.", !sequence.hasRepeatedPoints());
+}
 
-		ensure_equals( sequence1, sequence2 );
-		ensure_equals( sequence2, sequence1 );
+// Test of copy constructor
+template<>
+template<>
+void object::test<4>
+()
+{
+    using geos::geom::Coordinate;
+
+    // Create empty sequence
+    const size_t sizeEmpty = 0;
+    geos::geom::CoordinateArraySequence empty_original;
+
+    ensure(empty_original.isEmpty());
+    ensure_equals(empty_original.size(), sizeEmpty);
+    ensure_equals(empty_original.toString(), std::string("()"));
+
+    // Create copy of empty sequence
+    geos::geom::CoordinateArraySequence empty_copy(empty_original);
+
+    ensure(empty_copy.isEmpty());
+    ensure_equals(empty_copy.size(), sizeEmpty);
+    ensure_equals(empty_copy.toString(), std::string("()"));
+
+    // Create non-empty sequence
+    const size_t sizeNonEmpty = 2;
+    std::vector<Coordinate>* col = new std::vector<Coordinate>();
+    col->push_back(Coordinate(1, 2, 3));
+    col->push_back(Coordinate(5, 10, 15));
+    geos::geom::CoordinateArraySequence non_empty_original(col);
+
+    ensure(!non_empty_original.isEmpty());
+    ensure_equals(non_empty_original.size(), sizeNonEmpty);
+
+    // Create copy of non-empty sequence
+    geos::geom::CoordinateArraySequence non_empty_copy(non_empty_original);
+
+    ensure(!non_empty_copy.isEmpty());
+    ensure_equals(non_empty_copy.size(), sizeNonEmpty);
+
+    // Compare non-empty original and copy using equality operators
+    ensure_equals(non_empty_original.getAt(0), non_empty_copy.getAt(0));
+    ensure_equals(non_empty_original.getAt(1), non_empty_copy.getAt(1));
+    ensure(non_empty_original.getAt(0) != non_empty_copy.getAt(1));
+}
+
+// Test of getX() and getY()
+template<>
+template<>
+void object::test<5>
+()
+{
+    using geos::geom::Coordinate;
+
+    // Create non-empty sequence
+    std::vector<Coordinate>* col = new std::vector<Coordinate>();
+    col->push_back(Coordinate(1, 2));
+    col->push_back(Coordinate(5, 10));
+
+    const size_t size = 2;
+    geos::geom::CoordinateArraySequence sequence(col);
+
+    ensure(!sequence.isEmpty());
+    ensure_equals(sequence.size(), size);
+
+    ensure_equals(sequence.getX(0), 1);
+    ensure_equals(sequence.getY(0), 2);
+    ensure_equals(sequence.getX(1), 5);
+    ensure_equals(sequence.getY(1), 10);
+}
+
+// Test of getAt()
+template<>
+template<>
+void object::test<6>
+()
+{
+    using geos::geom::Coordinate;
+
+    // Create non-empty sequence
+    std::vector<Coordinate>* col = new std::vector<Coordinate>();
+    col->push_back(Coordinate(1, 2, 3));
+    col->push_back(Coordinate(5, 10, 15));
+
+    const size_t size = 2;
+    geos::geom::CoordinateArraySequence sequence(col);
+
+    ensure(!sequence.isEmpty());
+    ensure_equals(sequence.size(), size);
+    ensure(sequence.getAt(0) != sequence.getAt(1));
+
+    // First version of getAt()
+    ensure_equals(sequence.getAt(0).x, 1);
+    ensure_equals(sequence.getAt(0).y, 2);
+    ensure_equals(sequence.getAt(0).z, 3);
+    ensure_equals(sequence.getAt(1).x, 5);
+    ensure_equals(sequence.getAt(1).y, 10);
+    ensure_equals(sequence.getAt(1).z, 15);
+
+    // Second version of getAt()
+    Coordinate buf;
+
+    sequence.getAt(0, buf);
+    ensure_equals(buf.x, 1);
+    ensure_equals(buf.y, 2);
+    ensure_equals(buf.z, 3);
+
+    sequence.getAt(1, buf);
+    ensure_equals(buf.x, 5);
+    ensure_equals(buf.y, 10);
+    ensure_equals(buf.z, 15);
+}
+
+// Test of add()
+template<>
+template<>
+void object::test<7>
+()
+{
+    using geos::geom::Coordinate;
+
+    // Create empty sequence to fill with coordinates
+    const size_t size = 0;
+    geos::geom::CoordinateArraySequence sequence;
+
+    ensure(sequence.isEmpty());
+    ensure_equals(sequence.size(), size);
+
+    // Add coordinates
+    Coordinate tmp(1, 2, 3);
+    sequence.add(tmp); // insert copy of tmp
+    const size_t sizeOne = 1;
+
+    ensure(!sequence.isEmpty());
+    ensure_equals(sequence.size(), sizeOne);
+
+    tmp.x = 5;
+    tmp.y = 10;
+    tmp.z = 15;
+    sequence.add(tmp); // insert copy of tmp
+    const size_t sizeTwo = 2;
+
+    ensure(!sequence.isEmpty());
+    ensure_equals(sequence.size(), sizeTwo);
+
+    ensure(!sequence.hasRepeatedPoints());
+
+    // Check elements of sequence
+    ensure(sequence.getAt(0) != sequence.getAt(1));
+
+    ensure_equals(sequence.getAt(0).x, 1);
+    ensure_equals(sequence.getAt(0).y, 2);
+    ensure_equals(sequence.getAt(0).z, 3);
+    ensure_equals(sequence.getAt(1).x, 5);
+    ensure_equals(sequence.getAt(1).y, 10);
+    ensure_equals(sequence.getAt(1).z, 15);
+}
+
+// Test of setAt()
+template<>
+template<>
+void object::test<8>
+()
+{
+    using geos::geom::Coordinate;
 
-		// Add a new coordinate to sequence2
-		sequence2.add(c3);
+    // Create sequence with 2 default coordinates
+    const size_t size = 2;
+    geos::geom::CoordinateArraySequence sequence(size);
 
-		ensure( sequence1 != sequence2 );
-		ensure( sequence2 != sequence1 );
+    ensure(!sequence.isEmpty());
+    ensure_equals(sequence.size(), size);
+    ensure(sequence.hasRepeatedPoints());
 
-		// Add a new coordinate to sequence1
-		sequence1.add(c3);
+    // Set new values to first coordinate
+    Coordinate first(1, 2, 3);
+    sequence.setAt(first, 0);
 
-		ensure_equals( sequence1, sequence2 );
-		ensure_equals( sequence2, sequence1 );
+    ensure_equals(sequence.size(), size);
+    ensure_equals(sequence.getAt(0).x, 1);
+    ensure_equals(sequence.getAt(0).y, 2);
+    ensure_equals(sequence.getAt(0).z, 3);
 
-		// Add a new coordinate to sequence1
-		sequence1.add(c3);
-		sequence2.add(c2);
 
-		ensure( sequence1 != sequence2 );
-		ensure( sequence2 != sequence1 );
+    // Set new values to second coordinate
+    Coordinate second(5, 10, 15);
+    sequence.setAt(second, 1);
 
-	}
+    ensure_equals(sequence.size(), size);
 
-	// Test setOrdinate
-	template<>
-	template<>
-	void object::test<13>()
-	{
-		using geos::geom::Coordinate;
-		using geos::geom::CoordinateArraySequence;
-		using geos::geom::CoordinateSequence;
+    ensure_equals(sequence.getAt(1).x, 5);
+    ensure_equals(sequence.getAt(1).y, 10);
+    ensure_equals(sequence.getAt(1).z, 15);
 
-		Coordinate c1(1, 2, 3);
+    ensure(!sequence.hasRepeatedPoints());
+}
 
-		CoordinateArraySequence sequence1;
+// Test of deleteAt()
+template<>
+template<>
+void object::test<9>
+()
+{
+    using geos::geom::Coordinate;
+
+    // Create sequence with only 1 default coordinate
+    const size_t sizeOne = 1;
+    geos::geom::CoordinateArraySequence sequence(1);
+
+    ensure(!sequence.isEmpty());
+    ensure_equals(sequence.size(), sizeOne);
+
+    // Delete the only coordinate in the sequence
+    sequence.deleteAt(0);
+    const size_t sizeZero = 0;
+
+    ensure(sequence.isEmpty());
+    ensure_equals(sequence.size(), sizeZero);
+
+    // Add new 3 coordinates
+    Coordinate first(1, 2, 3);
+    sequence.add(first);
+    Coordinate second(5, 10, 15);
+    sequence.add(second);
+    Coordinate third(9, 18, 27);
+    sequence.add(third);
+    const size_t sizeThree = 3;
+
+    ensure(!sequence.isEmpty());
+    ensure_equals(sequence.size(), sizeThree);
+
+    // Delete coordinate in the middle of sequence - the second one.
+    sequence.deleteAt(1); // (5, 10, 15)
+    const size_t sizeTwo = 2;
+
+    ensure(!sequence.isEmpty());
+    ensure_equals(sequence.size(), sizeTwo);
+
+    ensure(sequence.getAt(0) != sequence.getAt(1));
+    ensure_equals(sequence.getAt(0), first);
+    ensure("deleteAt() did not remove coordinate.", sequence.getAt(1) != second);
+    ensure_equals(sequence.getAt(1), third);
+}
+
+// Test of setPoints()
+template<>
+template<>
+void object::test<10>
+()
+{
+    using geos::geom::Coordinate;
+
+    // Create empty sequence
+    const size_t size = 0;
+    geos::geom::CoordinateArraySequence sequence;
+
+    ensure(sequence.isEmpty());
+    ensure_equals(sequence.size(), size);
+
+    // Create collection of points
+    const std::vector<Coordinate>::size_type sizeCol = 3;
+    std::vector<Coordinate> col;
+    col.push_back(Coordinate(1, 2, 3));
+    col.push_back(Coordinate(5, 10, 15));
+    col.push_back(Coordinate(9, 18, 27));
+
+    ensure("std::vector bug assumed!", !col.empty());
+    ensure_equals("std::vector bug assumed!", col.size(), sizeCol);
+
+    // Use setPoints()
+    sequence.setPoints(col);
+
+    ensure(!sequence.isEmpty());
+    ensure_equals(sequence.size(), col.size());
+    ensure(!sequence.hasRepeatedPoints());
+
+    // Check inserted points
+    ensure_equals(sequence.getAt(0).x, 1);
+    ensure_equals(sequence.getAt(0).y, 2);
+    ensure_equals(sequence.getAt(0).z, 3);
+
+    ensure_equals(sequence.getAt(1).x, 5);
+    ensure_equals(sequence.getAt(1).y, 10);
+    ensure_equals(sequence.getAt(1).z, 15);
+
+    ensure_equals(sequence.getAt(2).x, 9);
+    ensure_equals(sequence.getAt(2).y, 18);
+    ensure_equals(sequence.getAt(2).z, 27);
+}
+
+// Test of removeRepeatedPoints
+template<>
+template<>
+void object::test<11>
+()
+{
+    using geos::geom::Coordinate;
 
-		sequence1.add(c1);
+    geos::geom::CoordinateArraySequence sequence;
 
-		ensure_equals( sequence1[0], c1 );
+    // Add new 3 equal coordinates
+    Coordinate c(1, 2, 3);
+    sequence.add(c);
+    sequence.add(c);
+    sequence.add(c);
 
-		sequence1.setOrdinate(0, CoordinateSequence::X, 4);
-		ensure_equals( sequence1[0].x, 4 );
+    Coordinate c2(5, 10, 15);
+    sequence.add(c2);
+    sequence.add(c2);
 
-		sequence1.setOrdinate(0, CoordinateSequence::Y, 5);
-		ensure_equals( sequence1[0].y, 5 );
+    sequence.add(c);
 
-		sequence1.setOrdinate(0, CoordinateSequence::Z, 6);
-		ensure_equals( sequence1[0].z, 6 );
+    ensure_equals(sequence.size(), 6u);
+    sequence.removeRepeatedPoints();
 
-	}
+    ensure_equals(sequence.size(), 3u);
+}
 
-	// Test setOrdinate setting ordinates in arbitrary order
-	template<>
-	template<>
-	void object::test<14>()
-	{
-		using geos::geom::Coordinate;
-		using geos::geom::CoordinateArraySequence;
-		using geos::geom::CoordinateSequence;
+// Test of equality and inequality operators
+template<>
+template<>
+void object::test<12>
+()
+{
+    using geos::geom::Coordinate;
+    using geos::geom::CoordinateArraySequence;
+    using geos::geom::CoordinateSequence;
 
-		Coordinate c1(1, 2, 3);
+    Coordinate c1(1, 2, 3);
+    Coordinate c2(5, 10, 15);
+    Coordinate c3(6, 9, 10);
 
-		CoordinateArraySequence sequence1;
+    CoordinateArraySequence sequence1;
+    CoordinateArraySequence sequence2;
 
-		sequence1.add(c1);
+    sequence1.add(c1);
+    sequence1.add(c2);
+    sequence1.add(c3);
 
-		ensure_equals( sequence1[0], c1 );
+    sequence2.add(c1);
+    sequence2.add(c2);
+    sequence2.add(c3);
 
-		// Order: Y, X, Z
+    ensure_equals(sequence1, sequence2);
+    ensure_equals(sequence2, sequence1);
 
-		sequence1.setOrdinate(0, CoordinateSequence::Y, 5);
-		ensure_equals( sequence1[0].y, 5 );
+    // Add a new coordinate to sequence2
+    sequence2.add(c3);
 
-		sequence1.setOrdinate(0, CoordinateSequence::X, 4);
-		ensure_equals( sequence1[0].x, 4 );
+    ensure(sequence1 != sequence2);
+    ensure(sequence2 != sequence1);
 
-		sequence1.setOrdinate(0, CoordinateSequence::Z, 6);
-		ensure_equals( sequence1[0].z, 6 );
+    // Add a new coordinate to sequence1
+    sequence1.add(c3);
 
-	}
+    ensure_equals(sequence1, sequence2);
+    ensure_equals(sequence2, sequence1);
 
-	// Test setOrdinate setting ordinates in arbitrary order
-	// against a non-initialized CoordinateSequence
-	template<>
-	template<>
-	void object::test<15>()
-	{
-		using geos::geom::Coordinate;
-		using geos::geom::CoordinateArraySequence;
-		using geos::geom::CoordinateSequence;
+    // Add a new coordinate to sequence1
+    sequence1.add(c3);
+    sequence2.add(c2);
 
-		typedef geos::geom::CoordinateSequenceFactory const* CoordinateFactoryCPtr;
-		CoordinateFactoryCPtr factory = geos::geom::CoordinateArraySequenceFactory::instance();
+    ensure(sequence1 != sequence2);
+    ensure(sequence2 != sequence1);
 
-		std::unique_ptr<CoordinateSequence> sequence1ptr(factory->create(4, 2));
-		CoordinateSequence& seq = *sequence1ptr;
+}
 
-		// Index: 0 - Order: Y, X, Z
+// Test setOrdinate
+template<>
+template<>
+void object::test<13>
+()
+{
+    using geos::geom::Coordinate;
+    using geos::geom::CoordinateArraySequence;
+    using geos::geom::CoordinateSequence;
 
-		seq.setOrdinate(0, CoordinateSequence::Y,  5); ensure_equals( seq[0].y, 5 );
-		seq.setOrdinate(0, CoordinateSequence::Z,  6); ensure_equals( seq[0].z, 6 );
-		seq.setOrdinate(0, CoordinateSequence::X,  4); ensure_equals( seq[0].x, 4 );
+    Coordinate c1(1, 2, 3);
 
-		// Index: 1 - Order: Z, X, Y
+    CoordinateArraySequence sequence1;
 
-		seq.setOrdinate(1, CoordinateSequence::Z,  9); ensure_equals( seq[1].z, 9 );
-		seq.setOrdinate(1, CoordinateSequence::X,  8); ensure_equals( seq[1].x, 8 );
-		seq.setOrdinate(1, CoordinateSequence::Y,  7); ensure_equals( seq[1].y, 7 );
+    sequence1.add(c1);
 
-		// Index: 2 - Order: X, Y, Z
+    ensure_equals(sequence1[0], c1);
 
-		seq.setOrdinate(2, CoordinateSequence::X,  34); ensure_equals( seq[2].x, 34 );
-		seq.setOrdinate(2, CoordinateSequence::Y,  -45); ensure_equals( seq[2].y, -45 );
-		seq.setOrdinate(2, CoordinateSequence::Z,  152); ensure_equals( seq[2].z, 152 );
+    sequence1.setOrdinate(0, CoordinateSequence::X, 4);
+    ensure_equals(sequence1[0].x, 4);
 
-		// Index: 3 - Order: Y, Z, X
+    sequence1.setOrdinate(0, CoordinateSequence::Y, 5);
+    ensure_equals(sequence1[0].y, 5);
 
-		seq.setOrdinate(3, CoordinateSequence::Y,  63); ensure_equals( seq[3].y, 63 );
-		seq.setOrdinate(3, CoordinateSequence::Z,  13); ensure_equals( seq[3].z, 13 );
-		seq.setOrdinate(3, CoordinateSequence::X,  -65); ensure_equals( seq[3].x, -65 );
+    sequence1.setOrdinate(0, CoordinateSequence::Z, 6);
+    ensure_equals(sequence1[0].z, 6);
 
-	}
+}
 
-    // Test of add() in the middle
-    template<>
-    template<>
-    void object::test<16>()
-    {
-		using geos::geom::Coordinate;
-		using geos::geom::CoordinateArraySequence;
+// Test setOrdinate setting ordinates in arbitrary order
+template<>
+template<>
+void object::test<14>
+()
+{
+    using geos::geom::Coordinate;
+    using geos::geom::CoordinateArraySequence;
+    using geos::geom::CoordinateSequence;
 
-		// Create empty sequence to fill with coordinates
-		CoordinateArraySequence sequence;
+    Coordinate c1(1, 2, 3);
 
-		sequence.add(Coordinate(0,0));
-		sequence.add(Coordinate(1,1));
-		sequence.add(Coordinate(2,2));
+    CoordinateArraySequence sequence1;
 
-		ensure_equals( sequence.size(), std::size_t(3));
+    sequence1.add(c1);
 
-		sequence.add(0, Coordinate(4,4), false); // don't alow repeated
-		ensure_equals( sequence.size(), std::size_t(4) );
-		ensure_equals( sequence.getAt(0).x, 4.0 );
+    ensure_equals(sequence1[0], c1);
 
-		// do not allow repeated
-		sequence.add(0, Coordinate(4,4), false);
-		ensure_equals( sequence.size(), std::size_t(4) );
+    // Order: Y, X, Z
 
-		// allow repeated
-		sequence.add(0, Coordinate(4,4), true);
-		ensure_equals( sequence.size(), std::size_t(5) );
+    sequence1.setOrdinate(0, CoordinateSequence::Y, 5);
+    ensure_equals(sequence1[0].y, 5);
 
-		// Now looks like this: 4,4,0,1,2
-		// we'll add at position 4 a 2 (equals to the one after)
-		sequence.add(4, Coordinate(2,2), false);
-		ensure_equals( sequence.size(), std::size_t(5) );
+    sequence1.setOrdinate(0, CoordinateSequence::X, 4);
+    ensure_equals(sequence1[0].x, 4);
 
-		// we'll add at position 4 a 1 (equals to the one before)
-		sequence.add(4, Coordinate(1,1), false);
-		ensure_equals( sequence.size(), std::size_t(5) );
+    sequence1.setOrdinate(0, CoordinateSequence::Z, 6);
+    ensure_equals(sequence1[0].z, 6);
 
-		// we'll add at position 4 a 1 (equals to the one before)
-		// but allowing duplicates
-		sequence.add(4, Coordinate(1,1), true);
-		ensure_equals( sequence.size(), std::size_t(6) );
-		ensure_equals( sequence.getAt(3).x, 1 );
-		ensure_equals( sequence.getAt(4).x, 1 );
-		ensure_equals( sequence.getAt(5).x, 2 );
-	}
+}
 
-	// Test getDimension and filtering (http://trac.osgeo.org/geos/ticket/435)
-	template<>
-	template<>
-	void object::test<17>()
-	{
+// Test setOrdinate setting ordinates in arbitrary order
+// against a non-initialized CoordinateSequence
+template<>
+template<>
+void object::test<15>
+()
+{
+    using geos::geom::Coordinate;
+    using geos::geom::CoordinateArraySequence;
+    using geos::geom::CoordinateSequence;
+
+    typedef geos::geom::CoordinateSequenceFactory const* CoordinateFactoryCPtr;
+    CoordinateFactoryCPtr factory = geos::geom::CoordinateArraySequenceFactory::instance();
+
+    std::unique_ptr<CoordinateSequence> sequence1ptr(factory->create(4, 2));
+    CoordinateSequence& seq = *sequence1ptr;
+
+    // Index: 0 - Order: Y, X, Z
+
+    seq.setOrdinate(0, CoordinateSequence::Y,  5);
+    ensure_equals(seq[0].y, 5);
+    seq.setOrdinate(0, CoordinateSequence::Z,  6);
+    ensure_equals(seq[0].z, 6);
+    seq.setOrdinate(0, CoordinateSequence::X,  4);
+    ensure_equals(seq[0].x, 4);
+
+    // Index: 1 - Order: Z, X, Y
+
+    seq.setOrdinate(1, CoordinateSequence::Z,  9);
+    ensure_equals(seq[1].z, 9);
+    seq.setOrdinate(1, CoordinateSequence::X,  8);
+    ensure_equals(seq[1].x, 8);
+    seq.setOrdinate(1, CoordinateSequence::Y,  7);
+    ensure_equals(seq[1].y, 7);
+
+    // Index: 2 - Order: X, Y, Z
+
+    seq.setOrdinate(2, CoordinateSequence::X,  34);
+    ensure_equals(seq[2].x, 34);
+    seq.setOrdinate(2, CoordinateSequence::Y,  -45);
+    ensure_equals(seq[2].y, -45);
+    seq.setOrdinate(2, CoordinateSequence::Z,  152);
+    ensure_equals(seq[2].z, 152);
+
+    // Index: 3 - Order: Y, Z, X
+
+    seq.setOrdinate(3, CoordinateSequence::Y,  63);
+    ensure_equals(seq[3].y, 63);
+    seq.setOrdinate(3, CoordinateSequence::Z,  13);
+    ensure_equals(seq[3].z, 13);
+    seq.setOrdinate(3, CoordinateSequence::X,  -65);
+    ensure_equals(seq[3].x, -65);
+
+}
+
+// Test of add() in the middle
+template<>
+template<>
+void object::test<16>
+()
+{
+    using geos::geom::Coordinate;
+    using geos::geom::CoordinateArraySequence;
+
+    // Create empty sequence to fill with coordinates
+    CoordinateArraySequence sequence;
+
+    sequence.add(Coordinate(0, 0));
+    sequence.add(Coordinate(1, 1));
+    sequence.add(Coordinate(2, 2));
+
+    ensure_equals(sequence.size(), std::size_t(3));
+
+    sequence.add(0, Coordinate(4, 4), false); // don't alow repeated
+    ensure_equals(sequence.size(), std::size_t(4));
+    ensure_equals(sequence.getAt(0).x, 4.0);
+
+    // do not allow repeated
+    sequence.add(0, Coordinate(4, 4), false);
+    ensure_equals(sequence.size(), std::size_t(4));
+
+    // allow repeated
+    sequence.add(0, Coordinate(4, 4), true);
+    ensure_equals(sequence.size(), std::size_t(5));
+
+    // Now looks like this: 4,4,0,1,2
+    // we'll add at position 4 a 2 (equals to the one after)
+    sequence.add(4, Coordinate(2, 2), false);
+    ensure_equals(sequence.size(), std::size_t(5));
+
+    // we'll add at position 4 a 1 (equals to the one before)
+    sequence.add(4, Coordinate(1, 1), false);
+    ensure_equals(sequence.size(), std::size_t(5));
+
+    // we'll add at position 4 a 1 (equals to the one before)
+    // but allowing duplicates
+    sequence.add(4, Coordinate(1, 1), true);
+    ensure_equals(sequence.size(), std::size_t(6));
+    ensure_equals(sequence.getAt(3).x, 1);
+    ensure_equals(sequence.getAt(4).x, 1);
+    ensure_equals(sequence.getAt(5).x, 2);
+}
+
+// Test getDimension and filtering (http://trac.osgeo.org/geos/ticket/435)
+template<>
+template<>
+void object::test<17>
+()
+{
     geos::geom::CoordinateArraySequence seq(1);
     ensure_equals(seq.getDimension(), 2u);
 
     Filter f;
 
-    f.is3d = true; seq.apply_rw(&f);
+    f.is3d = true;
+    seq.apply_rw(&f);
     ensure_equals(seq.getDimension(), 3u);
 
-    f.is3d = false; seq.apply_rw(&f);
+    f.is3d = false;
+    seq.apply_rw(&f);
     ensure_equals(seq.getDimension(), 2u);
-	}
+}
 
 } // namespace tut
diff --git a/tests/unit/geom/CoordinateListTest.cpp b/tests/unit/geom/CoordinateListTest.cpp
index 372d3a9..d90c9b6 100644
--- a/tests/unit/geom/CoordinateListTest.cpp
+++ b/tests/unit/geom/CoordinateListTest.cpp
@@ -12,159 +12,164 @@
 #include <string>
 #include <vector>
 
-namespace tut
-{
-    //
-    // Test Group
-    //
+namespace tut {
+//
+// Test Group
+//
 
-    // Common data used by tests
-    struct test_coordinatelist_data
-    {
+// Common data used by tests
+struct test_coordinatelist_data {
 
-        test_coordinatelist_data() {}
-    };
+    test_coordinatelist_data() {}
+};
 
-    typedef test_group<test_coordinatelist_data> group;
-    typedef group::object object;
+typedef test_group<test_coordinatelist_data> group;
+typedef group::object object;
 
-    group test_coordinatelist_group("geos::geom::CoordinateList");
+group test_coordinatelist_group("geos::geom::CoordinateList");
 
-    //
-    // Test Cases
-    //
+//
+// Test Cases
+//
 
-    // Test insert and erase
-    template<>
-    template<>
-    void object::test<1>()
-    {
-		using geos::geom::Coordinate;
+// Test insert and erase
+template<>
+template<>
+void object::test<1>
+()
+{
+    using geos::geom::Coordinate;
 
-		const Coordinate a(0, 0);
-		const Coordinate b(10, 10);
-		const Coordinate c(20, 20);
-		const Coordinate d(5, 5);
+    const Coordinate a(0, 0);
+    const Coordinate b(10, 10);
+    const Coordinate c(20, 20);
+    const Coordinate d(5, 5);
 
-		geos::geom::CoordinateList::iterator it, it2;
+    geos::geom::CoordinateList::iterator it, it2;
 
-		std::unique_ptr< std::vector<Coordinate> > col( new std::vector<Coordinate>() );
-		col->push_back(a);
-		col->push_back(b);
-		col->push_back(c);
+    std::unique_ptr< std::vector<Coordinate> > col(new std::vector<Coordinate>());
+    col->push_back(a);
+    col->push_back(b);
+    col->push_back(c);
 
-		// coordinates are copied
-		geos::geom::CoordinateList clist(*col);
+    // coordinates are copied
+    geos::geom::CoordinateList clist(*col);
 
-		ensure_equals( clist.size(), 3u );
+    ensure_equals(clist.size(), 3u);
 
-		it = clist.begin();
-		clist.insert(++it, d);
+    it = clist.begin();
+    clist.insert(++it, d);
 
-		ensure_equals( clist.size(), 4u );
+    ensure_equals(clist.size(), 4u);
 
-		it = clist.begin();
-		ensure_equals(*it, a);
-		++it;
-		ensure_equals(*it, d);
-		++it;
-		ensure_equals(*it, b);
-		++it;
-		ensure_equals(*it, c);
+    it = clist.begin();
+    ensure_equals(*it, a);
+    ++it;
+    ensure_equals(*it, d);
+    ++it;
+    ensure_equals(*it, b);
+    ++it;
+    ensure_equals(*it, c);
 
 
-		it = clist.begin();
-		++it; ++it;
-		clist.erase(it);
-		ensure_equals( clist.size(), 3u );
+    it = clist.begin();
+    ++it;
+    ++it;
+    clist.erase(it);
+    ensure_equals(clist.size(), 3u);
 
-		it = clist.begin();
-		ensure_equals(*it, a);
-		++it;
-		ensure_equals(*it, d);
-		++it;
-		ensure_equals(*it, c);
+    it = clist.begin();
+    ensure_equals(*it, a);
+    ++it;
+    ensure_equals(*it, d);
+    ++it;
+    ensure_equals(*it, c);
 
-		clist.insert(clist.end(), b);
+    clist.insert(clist.end(), b);
 
-		ensure_equals( clist.size(), 4u );
+    ensure_equals(clist.size(), 4u);
 
-		it = clist.begin(); ++it;
-		it2 = it; ++it2; ++it2;
-		clist.erase(it, it2);
+    it = clist.begin();
+    ++it;
+    it2 = it;
+    ++it2;
+    ++it2;
+    clist.erase(it, it2);
 
-		ensure_equals( clist.size(), 2u );
+    ensure_equals(clist.size(), 2u);
 
-		it = clist.begin();
-		ensure_equals(*it, a);
-		++it;
-		ensure_equals(*it, b);
+    it = clist.begin();
+    ensure_equals(*it, a);
+    ++it;
+    ensure_equals(*it, b);
 
-	}
+}
 
-  // Test insert with and without duplicates
-  template<>
-  template<>
-  void object::test<2>()
-  {
+// Test insert with and without duplicates
+template<>
+template<>
+void object::test<2>
+()
+{
     using geos::geom::Coordinate;
 
     geos::geom::CoordinateList clist;
-    ensure_equals( clist.size(), 0u );
+    ensure_equals(clist.size(), 0u);
 
     clist.insert(clist.end(), Coordinate(0, 0));
-    ensure_equals( clist.size(), 1u );
+    ensure_equals(clist.size(), 1u);
 
     clist.insert(clist.end(), Coordinate(0, 0), false);
-    ensure_equals( clist.size(), 1u );
+    ensure_equals(clist.size(), 1u);
 
     clist.insert(clist.end(), Coordinate(0, 0), true);
-    ensure_equals( clist.size(), 2u );
+    ensure_equals(clist.size(), 2u);
 
     clist.insert(clist.end(), Coordinate(1, 1), true);
-    ensure_equals( clist.size(), 3u );
+    ensure_equals(clist.size(), 3u);
 
     geos::geom::CoordinateList::iterator it = clist.end();
     --it;
     clist.insert(it, Coordinate(0, 0), false);
-    ensure_equals( clist.size(), 3u );
-  }
-  //Test to check the functioning of closeRing() method.
-  template<>
-  template<>
-  void object::test<3>()
-  {
-	  using geos::geom::Coordinate;
-
-	  const Coordinate a(0,0);
-	  const Coordinate b(10,10);
-	  const Coordinate c(45,60);
-	  const Coordinate d(100,0);
-
-	  std::unique_ptr< std::vector<Coordinate> > v( new std::vector<Coordinate>() );
-	  v->push_back(a);
-	  v->push_back(b);
-	  v->push_back(c);
-	  v->push_back(d);
-	  geos::geom::CoordinateList coordlist(*v);
-
-	  coordlist.closeRing();
-
-	  geos::geom::CoordinateList::iterator it1,it2;
-	  it1 = coordlist.begin();
-	  it2 = --coordlist.end();
-	  ensure_equals(*it1,*it2);
-
-	  /* for(CoordinateList::iterator it=coordlist.begin() ; it!=coordlist.end() ; ++it)
-	     {
-	     cout << (*it).x << " " << (*it).y << endl;
-	     }*/
-
-
-	  //If the list is empty::
-	  coordlist.erase(coordlist.begin(),coordlist.end());
-	  coordlist.closeRing();
-	  ensure_equals(coordlist.empty(), true);
-
-  }
+    ensure_equals(clist.size(), 3u);
+}
+//Test to check the functioning of closeRing() method.
+template<>
+template<>
+void object::test<3>
+()
+{
+    using geos::geom::Coordinate;
+
+    const Coordinate a(0, 0);
+    const Coordinate b(10, 10);
+    const Coordinate c(45, 60);
+    const Coordinate d(100, 0);
+
+    std::unique_ptr< std::vector<Coordinate> > v(new std::vector<Coordinate>());
+    v->push_back(a);
+    v->push_back(b);
+    v->push_back(c);
+    v->push_back(d);
+    geos::geom::CoordinateList coordlist(*v);
+
+    coordlist.closeRing();
+
+    geos::geom::CoordinateList::iterator it1, it2;
+    it1 = coordlist.begin();
+    it2 = --coordlist.end();
+    ensure_equals(*it1, *it2);
+
+    /* for(CoordinateList::iterator it=coordlist.begin() ; it!=coordlist.end() ; ++it)
+       {
+       cout << (*it).x << " " << (*it).y << endl;
+       }*/
+
+
+    //If the list is empty::
+    coordlist.erase(coordlist.begin(), coordlist.end());
+    coordlist.closeRing();
+    ensure_equals(coordlist.empty(), true);
+
+}
 } // namespace tut
diff --git a/tests/unit/geom/CoordinateTest.cpp b/tests/unit/geom/CoordinateTest.cpp
index e7ba1db..1b28c3b 100644
--- a/tests/unit/geom/CoordinateTest.cpp
+++ b/tests/unit/geom/CoordinateTest.cpp
@@ -7,187 +7,194 @@
 // std
 #include <cmath>
 
-namespace tut
+namespace tut {
+//
+// Test Group
+//
+
+// Common data used by tests
+struct test_coordinate_data {
+    const double x;
+    const double y;
+    const double z;
+
+    test_coordinate_data()
+        : x(1.234), y(2.345), z(3.456)
+    {}
+private:
+    // Declare type as noncopyable
+    test_coordinate_data(test_coordinate_data const& other) = delete;
+    test_coordinate_data& operator=(test_coordinate_data const& rhs) = delete;
+};
+
+typedef test_group<test_coordinate_data> group;
+typedef group::object object;
+
+group test_coordinate_group("geos::geom::Coordinate");
+
+//
+// Test Cases
+//
+
+// Test of default constructor
+template<>
+template<>
+void object::test<1>
+()
+{
+    // TODO - mloskot - discuss about adding default constructor
+    ensure("NOTE: Coordinate has no default constructor.", true);
+}
+
+// Test of overriden constructor
+template<>
+template<>
+void object::test<2>
+()
+{
+    geos::geom::Coordinate coord;
+    ensure_equals(coord.x, 0.0);
+    ensure_equals(coord.y, 0.0);
+    ensure(0 != std::isnan(coord.z));
+}
+
+// Test of copy constructor and assignment operator
+template<>
+template<>
+void object::test<3>
+()
+{
+    // Create exemplar object
+    geos::geom::Coordinate original(x, y, z);
+    ensure_equals(original.x, x);
+    ensure_equals(original.y, y);
+    ensure_equals(original.z, z);
+
+    // Use copy ctor
+    geos::geom::Coordinate copy(original);
+    ensure_equals(copy.x, x);
+    ensure_equals(copy.y, y);
+    ensure_equals(copy.z, z);
+
+    // Use assignment operator
+    geos::geom::Coordinate assigned; // uses default ctor
+    assigned = original;
+    ensure_equals(assigned.x, x);
+    ensure_equals(assigned.y, y);
+    ensure_equals(assigned.z, z);
+}
+
+// Test of equality operators
+template<>
+template<>
+void object::test<4>
+()
+{
+    geos::geom::Coordinate original(x, y, z);
+    ensure_equals(original.x, x);
+    ensure_equals(original.y, y);
+    ensure_equals(original.z, z);
+
+    // Use copy ctor
+    geos::geom::Coordinate copy(original);
+
+    // Compare copy with original
+    ensure_equals(original, copy);
+
+    copy.x += 3.14; // permutation
+    ensure(original != copy);
+}
+
+// Test of equals()
+template<>
+template<>
+void object::test<5>
+()
+{
+    geos::geom::Coordinate first(x, y);
+    geos::geom::Coordinate second(x, y);
+
+    ensure(first.equals(second));
+}
+
+// Test of equals2D()
+template<>
+template<>
+void object::test<6>
+()
+{
+    geos::geom::Coordinate first(x, y);
+    geos::geom::Coordinate second(x, y);
+
+    ensure(first.equals2D(second));
+}
+
+// Test of equals3D()
+template<>
+template<>
+void object::test<7>
+()
+{
+    geos::geom::Coordinate first(x, y);
+    geos::geom::Coordinate second(x, y);
+
+    // Test with z = NaN
+    ensure(first.equals3D(second));
+
+    // Test all valid coordinates
+    first.z = second.z = z;
+    ensure(first.equals3D(second));
+}
+
+// Test of distance()
+template<>
+template<>
+void object::test<8>
+()
+{
+    geos::geom::Coordinate first(x, y, z);
+    geos::geom::Coordinate second(x, y, z);
+
+    // Both coordinates are same
+    ensure_equals(first.distance(second), 0);
+    ensure_equals(first.distance(second), second.distance(first));
+
+    // Move second coordinate
+    second.x += 10.0;
+    second.y += 10.0;
+    second.z += 10.0;
+    ensure(first.distance(second) != 0);
+    ensure_equals(first.distance(second), second.distance(first));
+    // TODO - mloskot - I'm not sure if this will work on every platform.
+    // In case of any problems, just remove it.
+    ensure_equals(first.distance(second), 14.142135623730951);
+}
+
+// Test of set/getNull()
+template<>
+template<>
+void object::test<9>
+()
 {
-    //
-    // Test Group
-    //
-
-    // Common data used by tests
-    struct test_coordinate_data
-    {
-        const double x;
-        const double y;
-        const double z;
-
-        test_coordinate_data()
-            : x(1.234), y(2.345), z(3.456)
-        {}
-    private:
-        // Declare type as noncopyable
-        test_coordinate_data(test_coordinate_data const& other) = delete;
-        test_coordinate_data& operator=(test_coordinate_data const& rhs) = delete;
-    };
-
-    typedef test_group<test_coordinate_data> group;
-    typedef group::object object;
-
-    group test_coordinate_group("geos::geom::Coordinate");
-
-    //
-    // Test Cases
-    //
-
-    // Test of default constructor
-    template<>
-    template<>
-    void object::test<1>()
-    {
-        // TODO - mloskot - discuss about adding default constructor
-        ensure("NOTE: Coordinate has no default constructor.", true);
-    }
-
-    // Test of overriden constructor
-    template<>
-    template<>
-    void object::test<2>()
-    {
-        geos::geom::Coordinate coord;
-        ensure_equals( coord.x, 0.0 );
-        ensure_equals( coord.y, 0.0 );
-        ensure(0 != std::isnan( coord.z ) );
-    }
-
-    // Test of copy constructor and assignment operator
-    template<>
-    template<>
-    void object::test<3>()
-    {
-        // Create exemplar object
-        geos::geom::Coordinate original(x, y, z);
-        ensure_equals( original.x, x );
-        ensure_equals( original.y, y );
-        ensure_equals( original.z, z );
-
-        // Use copy ctor
-        geos::geom::Coordinate copy(original);
-        ensure_equals( copy.x, x );
-        ensure_equals( copy.y, y );
-        ensure_equals( copy.z, z );
-
-        // Use assignment operator
-        geos::geom::Coordinate assigned; // uses default ctor
-        assigned = original;
-        ensure_equals( assigned.x, x );
-        ensure_equals( assigned.y, y );
-        ensure_equals( assigned.z, z );
-    }
-
-    // Test of equality operators
-    template<>
-    template<>
-    void object::test<4>()
-    {
-        geos::geom::Coordinate original(x, y, z);
-        ensure_equals( original.x, x );
-        ensure_equals( original.y, y );
-        ensure_equals( original.z, z );
-
-        // Use copy ctor
-        geos::geom::Coordinate copy(original);
-
-        // Compare copy with original
-        ensure_equals( original, copy );
-
-        copy.x += 3.14; // permutation
-        ensure( original != copy );
-    }
-
-    // Test of equals()
-    template<>
-    template<>
-    void object::test<5>()
-    {
-        geos::geom::Coordinate first(x, y);
-        geos::geom::Coordinate second(x, y);
-
-        ensure( first.equals( second ) );
-    }
-
-    // Test of equals2D()
-    template<>
-    template<>
-    void object::test<6>()
-    {
-        geos::geom::Coordinate first(x, y);
-        geos::geom::Coordinate second(x, y);
-
-        ensure( first.equals2D( second ) );
-    }
-
-    // Test of equals3D()
-    template<>
-    template<>
-    void object::test<7>()
-    {
-        geos::geom::Coordinate first(x, y);
-        geos::geom::Coordinate second(x, y);
-
-        // Test with z = NaN
-        ensure( first.equals3D( second ) );
-
-        // Test all valid coordinates
-        first.z = second.z = z;
-        ensure( first.equals3D( second ) );
-    }
-
-    // Test of distance()
-    template<>
-    template<>
-    void object::test<8>()
-    {
-        geos::geom::Coordinate first(x, y, z);
-        geos::geom::Coordinate second(x, y, z);
-
-        // Both coordinates are same
-        ensure_equals( first.distance( second ), 0 );
-        ensure_equals( first.distance( second ), second.distance( first ) );
-
-        // Move second coordinate
-        second.x += 10.0;
-        second.y += 10.0;
-        second.z += 10.0;
-        ensure( first.distance( second ) != 0 );
-        ensure_equals( first.distance( second ), second.distance( first ) );
-        // TODO - mloskot - I'm not sure if this will work on every platform.
-        // In case of any problems, just remove it.
-        ensure_equals( first.distance( second ), 14.142135623730951);
-    }
-
-    // Test of set/getNull()
-    template<>
-    template<>
-    void object::test<9>()
-    {
-        // Create not null coordinate
-        geos::geom::Coordinate not_null_coord(x, y, z);
-        ensure_equals( not_null_coord.x, x );
-        ensure_equals( not_null_coord.y, y );
-        ensure_equals( not_null_coord.z, z );
-
-        // Make it null and check
-        not_null_coord.setNull();
-        ensure( 0 != std::isnan( not_null_coord.x ) );
-        ensure( 0 != std::isnan( not_null_coord.y ) );
-        ensure( 0 != std::isnan( not_null_coord.z ) );
-
-        // Build in static null instance
-        geos::geom::Coordinate null_coord;
-        null_coord = geos::geom::Coordinate::getNull();
-        ensure( 0 != std::isnan( null_coord.x ) );
-        ensure( 0 != std::isnan( null_coord.y ) );
-        ensure( 0 != std::isnan( null_coord.z ) );
-    }
+    // Create not null coordinate
+    geos::geom::Coordinate not_null_coord(x, y, z);
+    ensure_equals(not_null_coord.x, x);
+    ensure_equals(not_null_coord.y, y);
+    ensure_equals(not_null_coord.z, z);
+
+    // Make it null and check
+    not_null_coord.setNull();
+    ensure(0 != std::isnan(not_null_coord.x));
+    ensure(0 != std::isnan(not_null_coord.y));
+    ensure(0 != std::isnan(not_null_coord.z));
+
+    // Build in static null instance
+    geos::geom::Coordinate null_coord;
+    null_coord = geos::geom::Coordinate::getNull();
+    ensure(0 != std::isnan(null_coord.x));
+    ensure(0 != std::isnan(null_coord.y));
+    ensure(0 != std::isnan(null_coord.z));
+}
 
 } // namespace tut
 
diff --git a/tests/unit/geom/DimensionTest.cpp b/tests/unit/geom/DimensionTest.cpp
index e30112b..c37d54f 100644
--- a/tests/unit/geom/DimensionTest.cpp
+++ b/tests/unit/geom/DimensionTest.cpp
@@ -8,139 +8,134 @@
 #include <geos/util/IllegalArgumentException.h>
 #include <geos/util.h>
 
-namespace tut
+namespace tut {
+//
+// Test Group
+//
+
+// Common data used by tests
+struct test_dimension_data {
+    int nomatter;
+    int yes;
+    int no;
+    int point;
+    int curve;
+    int surface;
+
+    test_dimension_data()
+        :
+        nomatter(geos::geom::Dimension::DONTCARE),
+        yes(geos::geom::Dimension::True),
+        no(geos::geom::Dimension::False),
+        point(geos::geom::Dimension::P),
+        curve(geos::geom::Dimension::L),
+        surface(geos::geom::Dimension::A)
+    {}
+};
+
+typedef test_group<test_dimension_data> group;
+typedef group::object object;
+
+group test_dimension_group("geos::geom::Dimension");
+
+//
+// Test Cases
+//
+
+// Test of default constructor
+template<>
+template<>
+void object::test<1>
+()
+{
+    // Just compile-time test
+    geos::geom::Dimension dim;
+    ::geos::ignore_unused_variable_warning(dim);
+}
+
+// Test of toDimensionSymbol()
+template<>
+template<>
+void object::test<2>
+()
 {
-    //
-    // Test Group
-    //
-
-    // Common data used by tests
-    struct test_dimension_data
-    {
-		int nomatter;
-		int yes;
-		int no;
-		int point;
-		int curve;
-		int surface;
-
-		test_dimension_data()
-			:
-			nomatter(geos::geom::Dimension::DONTCARE),
-			yes(geos::geom::Dimension::True),
-			no(geos::geom::Dimension::False),
-			point(geos::geom::Dimension::P),
-			curve(geos::geom::Dimension::L),
-			surface(geos::geom::Dimension::A)
-		{}
-	};
-
-    typedef test_group<test_dimension_data> group;
-    typedef group::object object;
-
-    group test_dimension_group("geos::geom::Dimension");
-
-    //
-    // Test Cases
-    //
-
-    // Test of default constructor
-    template<>
-    template<>
-    void object::test<1>()
-    {
-		// Just compile-time test
-		geos::geom::Dimension dim;
-        ::geos::ignore_unused_variable_warning(dim);
+    using geos::geom::Dimension;
+
+    try {
+        ensure_equals(Dimension::toDimensionSymbol(nomatter), '*');
+        ensure_equals(Dimension::toDimensionSymbol(yes), 'T');
+        ensure_equals(Dimension::toDimensionSymbol(no), 'F');
+        ensure_equals(Dimension::toDimensionSymbol(point), '0');
+        ensure_equals(Dimension::toDimensionSymbol(curve), '1');
+        ensure_equals(Dimension::toDimensionSymbol(surface), '2');
     }
-
-    // Test of toDimensionSymbol()
-    template<>
-    template<>
-    void object::test<2>()
-    {
-		using geos::geom::Dimension;
-
-		try
-		{
-			ensure_equals( Dimension::toDimensionSymbol(nomatter), '*' );
-			ensure_equals( Dimension::toDimensionSymbol(yes), 'T' );
-			ensure_equals( Dimension::toDimensionSymbol(no), 'F' );
-			ensure_equals( Dimension::toDimensionSymbol(point), '0' );
-			ensure_equals( Dimension::toDimensionSymbol(curve), '1' );
-			ensure_equals( Dimension::toDimensionSymbol(surface), '2' );
-		}
-		catch ( geos::util::IllegalArgumentException const& e )
-		{
-			fail( e.what() );
-		}
+    catch(geos::util::IllegalArgumentException const& e) {
+        fail(e.what());
     }
+}
 
-    // Test of toDimensionSymbol() throwing IllegalArgumentException
-    template<>
-    template<>
-    void object::test<3>()
-    {
-		using geos::geom::Dimension;
-
-		try
-		{
-			Dimension::toDimensionSymbol(101);
-			Dimension::toDimensionSymbol(-101);
-
-			fail("IllegalArgumentException expected");
-		}
-		catch ( geos::util::IllegalArgumentException const& e )
-		{
-			const char* msg = e.what(); // ok
-			ensure( msg != nullptr );
-		}
+// Test of toDimensionSymbol() throwing IllegalArgumentException
+template<>
+template<>
+void object::test<3>
+()
+{
+    using geos::geom::Dimension;
+
+    try {
+        Dimension::toDimensionSymbol(101);
+        Dimension::toDimensionSymbol(-101);
+
+        fail("IllegalArgumentException expected");
+    }
+    catch(geos::util::IllegalArgumentException const& e) {
+        const char* msg = e.what(); // ok
+        ensure(msg != nullptr);
     }
+}
 
-    // Test of toDimensionValue()
-    template<>
-    template<>
-    void object::test<4>()
-    {
-		using geos::geom::Dimension;
-
-		try
-		{
-			ensure_equals( Dimension::toDimensionValue('*'), nomatter );
-			ensure_equals( Dimension::toDimensionValue('F'), no );
-			ensure_equals( Dimension::toDimensionValue('f'), no );
-			ensure_equals( Dimension::toDimensionValue('T') , yes );
-			ensure_equals( Dimension::toDimensionValue('t') , yes );
-			ensure_equals( Dimension::toDimensionValue('0'), point );
-			ensure_equals( Dimension::toDimensionValue('1'), curve );
-			ensure_equals( Dimension::toDimensionValue('2'), surface );
-		}
-		catch ( geos::util::IllegalArgumentException const& e )
-		{
-			fail( e.what() );
-		}
+// Test of toDimensionValue()
+template<>
+template<>
+void object::test<4>
+()
+{
+    using geos::geom::Dimension;
+
+    try {
+        ensure_equals(Dimension::toDimensionValue('*'), nomatter);
+        ensure_equals(Dimension::toDimensionValue('F'), no);
+        ensure_equals(Dimension::toDimensionValue('f'), no);
+        ensure_equals(Dimension::toDimensionValue('T'), yes);
+        ensure_equals(Dimension::toDimensionValue('t'), yes);
+        ensure_equals(Dimension::toDimensionValue('0'), point);
+        ensure_equals(Dimension::toDimensionValue('1'), curve);
+        ensure_equals(Dimension::toDimensionValue('2'), surface);
+    }
+    catch(geos::util::IllegalArgumentException const& e) {
+        fail(e.what());
     }
+}
 
-    // Test of toDimensionValue() throwing IllegalArgumentException
-    template<>
-    template<>
-    void object::test<5>()
-    {
-		using geos::geom::Dimension;
-
-		try
-		{
-			Dimension::toDimensionValue('X');
-			Dimension::toDimensionValue('9');
-
-			fail("IllegalArgumentException expected");
-		}
-		catch ( geos::util::IllegalArgumentException const& e )
-		{
-			const char* msg = e.what(); // ok
-			ensure( msg != nullptr );
-		}
+// Test of toDimensionValue() throwing IllegalArgumentException
+template<>
+template<>
+void object::test<5>
+()
+{
+    using geos::geom::Dimension;
+
+    try {
+        Dimension::toDimensionValue('X');
+        Dimension::toDimensionValue('9');
+
+        fail("IllegalArgumentException expected");
+    }
+    catch(geos::util::IllegalArgumentException const& e) {
+        const char* msg = e.what(); // ok
+        ensure(msg != nullptr);
     }
+}
 
 } // namespace tut
 
diff --git a/tests/unit/geom/EnvelopeTest.cpp b/tests/unit/geom/EnvelopeTest.cpp
index c9fff87..a68c1c6 100644
--- a/tests/unit/geom/EnvelopeTest.cpp
+++ b/tests/unit/geom/EnvelopeTest.cpp
@@ -7,232 +7,240 @@
 #include <geos/geom/Envelope.h>
 #include <geos/geom/Coordinate.h>
 
-namespace tut
+namespace tut {
+//
+// Test Group
+//
+
+// dummy data, not used
+struct test_envelope_data {};
+
+typedef test_group<test_envelope_data> group;
+typedef group::object object;
+
+group test_envelope_group("geos::geom::Envelope");
+
+//
+// Test Cases
+//
+
+// 1 - Test of default constructor
+template<>
+template<>
+void object::test<1>
+()
+{
+    geos::geom::Envelope empty;
+
+    ensure(empty.isNull());
+
+    ensure_equals(empty.getWidth(), 0);
+    ensure_equals(empty.getHeight(), 0);
+}
+
+// 2 - Test of overriden constructor
+template<>
+template<>
+void object::test<2>
+()
+{
+    geos::geom::Envelope box(0, 100, 0, 100);
+
+    ensure(!box.isNull());
+
+    ensure_equals(box.getMinX(), 0);
+    ensure_equals(box.getMaxX(), 100);
+    ensure_equals(box.getMinY(), 0);
+    ensure_equals(box.getMaxY(), 100);
+
+    ensure_equals(box.getMinX(), box.getMinY());
+    ensure_equals(box.getMaxX(), box.getMaxY());
+
+    ensure_equals(box.getWidth(), box.getHeight());
+}
+
+// 3 - Test of copy constructor
+template<>
+template<>
+void object::test<3>
+()
+{
+    geos::geom::Envelope box(0, 100, 0, 100);
+
+    ensure(!box.isNull());
+    ensure_equals(box.getWidth(), box.getHeight());
+
+    geos::geom::Envelope copied(box);
+
+    ensure(!copied.isNull());
+    ensure(copied == box);
+    ensure_equals(copied.getWidth(), copied.getHeight());
+}
+
+// 4 - Test of setToNull()
+template<>
+template<>
+void object::test<4>
+()
+{
+    geos::geom::Envelope e(100, 200, 100, 200);
+
+    ensure(!e.isNull());
+    e.setToNull();
+    ensure(e.isNull());
+}
+
+// 5 - Test of equals()
+template<>
+template<>
+void object::test<5>
+()
+{
+    geos::geom::Envelope empty;
+    geos::geom::Envelope zero(0, 0, 0, 0);
+    geos::geom::Envelope zero2(0, 0, 0, 0);
+    geos::geom::Envelope box(0, 100, 0, 100);
+
+    ensure(empty.isNull());
+    ensure(!zero.isNull());
+    ensure(!zero2.isNull());
+    ensure(!box.isNull());
+
+    /* See http://trac.osgeo.org/geos/ticket/703 */
+    ensure(empty.equals(&empty));
+
+    ensure(!empty.equals(&zero));
+    ensure(!zero.equals(&empty));
+
+    ensure(zero.equals(&zero2));
+    ensure(zero2.equals(&zero));
+
+    ensure(!box.equals(&empty));
+    ensure(!box.equals(&zero));
+}
+
+// 6 - Test of contains()
+template<>
+template<>
+void object::test<6>
+()
+{
+    geos::geom::Envelope empty;
+    geos::geom::Envelope small(-1, 1, -1, 1);
+    geos::geom::Envelope big(-5, 5, -5, 5);
+
+    ensure(empty.isNull());
+    ensure(!small.isNull());
+    ensure(!big.isNull());
+
+    // Test empty envelope by reference
+    ensure("empty envelope is not empty!", !empty.contains(small));
+    ensure("empty envelope is not empty!", !small.contains(empty));
+
+    // Test empty envelope by pointer
+    ensure("empty envelope is not empty!", !empty.contains(&small));
+    ensure("empty envelope is not empty!", !small.contains(&empty));
+
+    // Test non-empty envelope by reference
+    ensure(!small.contains(big));
+    ensure(big.contains(small));
+
+    // Test raw point
+    ensure(small.contains(0, 0));
+    ensure(small.contains(-1, -1));
+    ensure(!small.contains(5, 5));
+
+    // Test coordinate
+    geos::geom::Coordinate origin(0, 0, 0);
+
+    ensure_equals(origin.x, 0);
+    ensure_equals(origin.y, 0);
+    ensure_equals(origin.z, 0);
+    ensure(small.contains(origin));
+}
+
+// Test of intersects()
+template<>
+template<>
+void object::test<7>
+()
+{
+    geos::geom::Envelope empty;
+    geos::geom::Envelope with_origin(-100, 100, -100, 100);
+    geos::geom::Envelope moved(50, 150, 50, 150);
+
+    ensure(empty.isNull());
+    ensure(!with_origin.isNull());
+    ensure(!moved.isNull());
+
+    // Test empty envelope by reference
+    ensure("empty envelope seems not empty!", !empty.intersects(with_origin));
+    ensure("empty envelope seems not empty!", !with_origin.intersects(empty));
+
+    // Test empty envelope by pointer
+    ensure("empty envelope seems not empty!", !empty.intersects(&with_origin));
+    ensure("empty envelope seems not empty!", !with_origin.intersects(&empty));
+
+    // Test non-empty envelope by reference
+    ensure(with_origin.intersects(moved));
+    ensure(moved.intersects(with_origin));
+
+    // Test intersection with raw point
+    ensure(with_origin.intersects(0, 0));
+    ensure(with_origin.intersects(-100, 100));
+    ensure(!with_origin.intersects(-200, 200));
+
+    // Test intersection with coordinate
+    geos::geom::Coordinate origin(0, 0, 0);
+
+    ensure_equals(origin.x, 0);
+    ensure_equals(origin.y, 0);
+    ensure_equals(origin.z, 0);
+    ensure(with_origin.intersects(origin));
+
+}
+
+// Test of expand()
+template<>
+template<>
+void object::test<8>
+()
+{
+    geos::geom::Envelope empty;
+    geos::geom::Envelope box(-5, 5, -5, 5); // Includes (0,0) point
+    const geos::geom::Envelope exemplar(-5, 5, -5, 5);
+
+    ensure(empty.isNull());
+    ensure(!box.isNull());
+    ensure(!exemplar.isNull());
+
+    // Expand box envelope to include null envelope
+    box.expandToInclude(&empty);
+    ensure(box == exemplar);   // no change expected
+
+    // Expand null envelope to include box envelope
+    empty.expandToInclude(&box);
+    ensure(empty == exemplar);
+}
+
+// Second test of expand()
+template<>
+template<>
+void object::test<9>
+()
 {
-    //
-    // Test Group
-    //
-
-    // dummy data, not used
-    struct test_envelope_data {};
-
-    typedef test_group<test_envelope_data> group;
-    typedef group::object object;
-
-    group test_envelope_group("geos::geom::Envelope");
-
-    //
-    // Test Cases
-    //
-
-    // 1 - Test of default constructor
-    template<>
-    template<>
-    void object::test<1>()
-    {
-        geos::geom::Envelope empty;
-
-        ensure( empty.isNull() );
-
-        ensure_equals( empty.getWidth(), 0 );
-        ensure_equals( empty.getHeight(), 0 );
-    }
-
-    // 2 - Test of overriden constructor
-    template<>
-    template<>
-    void object::test<2>()
-    {
-        geos::geom::Envelope box(0, 100, 0, 100);
-
-        ensure( !box.isNull() );
-
-        ensure_equals( box.getMinX(), 0 );
-        ensure_equals( box.getMaxX(), 100 );
-        ensure_equals( box.getMinY(), 0 );
-        ensure_equals( box.getMaxY(), 100 );
-
-        ensure_equals( box.getMinX(), box.getMinY() );
-        ensure_equals( box.getMaxX(), box.getMaxY() );
-
-        ensure_equals( box.getWidth(), box.getHeight() );
-    }
-
-    // 3 - Test of copy constructor
-    template<>
-    template<>
-    void object::test<3>()
-    {
-        geos::geom::Envelope box(0, 100, 0, 100);
-
-        ensure( !box.isNull() );
-        ensure_equals( box.getWidth(), box.getHeight() );
-
-        geos::geom::Envelope copied(box);
-
-        ensure( !copied.isNull() );
-        ensure( copied == box );
-        ensure_equals( copied.getWidth(), copied.getHeight() );
-    }
-
-    // 4 - Test of setToNull()
-    template<>
-    template<>
-    void object::test<4>()
-    {
-        geos::geom::Envelope e(100, 200, 100, 200);
-
-        ensure( !e.isNull() );
-        e.setToNull();
-        ensure( e.isNull() );
-    }
-
-    // 5 - Test of equals()
-    template<>
-    template<>
-    void object::test<5>()
-    {
-        geos::geom::Envelope empty;
-        geos::geom::Envelope zero(0, 0, 0, 0);
-        geos::geom::Envelope zero2(0, 0, 0, 0);
-        geos::geom::Envelope box(0, 100, 0, 100);
-
-        ensure( empty.isNull() );
-        ensure( !zero.isNull() );
-        ensure( !zero2.isNull() );
-        ensure( !box.isNull() );
-
-        /* See http://trac.osgeo.org/geos/ticket/703 */
-        ensure( empty.equals( &empty ) );
-
-        ensure( !empty.equals( &zero ) );
-        ensure( !zero.equals( &empty ) );
-
-        ensure( zero.equals( &zero2 ) );
-        ensure( zero2.equals( &zero ) );
-
-        ensure( !box.equals( &empty ) );
-        ensure( !box.equals( &zero ) );
-    }
-
-    // 6 - Test of contains()
-    template<>
-    template<>
-    void object::test<6>()
-    {
-        geos::geom::Envelope empty;
-        geos::geom::Envelope small(-1, 1, -1, 1);
-        geos::geom::Envelope big(-5, 5, -5, 5);
-
-        ensure( empty.isNull() );
-        ensure( !small.isNull() );
-        ensure( !big.isNull() );
-
-        // Test empty envelope by reference
-        ensure( "empty envelope is not empty!", !empty.contains( small ) );
-        ensure( "empty envelope is not empty!", !small.contains( empty ) );
-
-        // Test empty envelope by pointer
-        ensure( "empty envelope is not empty!", !empty.contains( &small ) );
-        ensure( "empty envelope is not empty!", !small.contains( &empty ) );
-
-        // Test non-empty envelope by reference
-        ensure( !small.contains( big ) );
-        ensure( big.contains( small ) );
-
-        // Test raw point
-        ensure( small.contains( 0, 0 ) );
-        ensure( small.contains( -1, -1 ) );
-        ensure( !small.contains( 5, 5 ) );
-
-        // Test coordinate
-        geos::geom::Coordinate origin(0, 0, 0);
-
-        ensure_equals( origin.x, 0 );
-        ensure_equals( origin.y, 0 );
-        ensure_equals( origin.z, 0 );
-        ensure( small.contains( origin ) );
-    }
-
-    // Test of intersects()
-    template<>
-    template<>
-    void object::test<7>()
-    {
-        geos::geom::Envelope empty;
-        geos::geom::Envelope with_origin(-100, 100, -100, 100);
-        geos::geom::Envelope moved(50, 150, 50, 150);
-
-        ensure( empty.isNull() );
-        ensure( !with_origin.isNull() );
-        ensure( !moved.isNull() );
-
-        // Test empty envelope by reference
-        ensure( "empty envelope seems not empty!", !empty.intersects( with_origin ) );
-        ensure( "empty envelope seems not empty!", !with_origin.intersects( empty ) );
-
-        // Test empty envelope by pointer
-        ensure( "empty envelope seems not empty!", !empty.intersects( &with_origin ) );
-        ensure( "empty envelope seems not empty!", !with_origin.intersects( &empty ) );
-
-        // Test non-empty envelope by reference
-        ensure( with_origin.intersects( moved ) );
-        ensure( moved.intersects( with_origin ) );
-
-        // Test intersection with raw point
-        ensure( with_origin.intersects( 0, 0 ) );
-        ensure( with_origin.intersects( -100, 100 ) );
-        ensure( !with_origin.intersects( -200, 200 ) );
-
-        // Test intersection with coordinate
-        geos::geom::Coordinate origin(0, 0, 0);
-
-        ensure_equals( origin.x, 0 );
-        ensure_equals( origin.y, 0 );
-        ensure_equals( origin.z, 0 );
-        ensure( with_origin.intersects( origin ) );
-
-    }
-
-    // Test of expand()
-    template<>
-    template<>
-    void object::test<8>()
-    {
-        geos::geom::Envelope empty;
-        geos::geom::Envelope box(-5, 5, -5, 5); // Includes (0,0) point
-        const geos::geom::Envelope exemplar(-5, 5, -5, 5);
-
-        ensure( empty.isNull() );
-        ensure( !box.isNull() );
-        ensure( !exemplar.isNull() );
-
-        // Expand box envelope to include null envelope
-        box.expandToInclude(&empty);
-        ensure( box == exemplar ); // no change expected
-
-        // Expand null envelope to include box envelope
-        empty.expandToInclude(&box);
-        ensure( empty == exemplar );
-    }
-
-    // Second test of expand()
-    template<>
-    template<>
-    void object::test<9>()
-    {
-        geos::geom::Envelope empty;
-        geos::geom::Envelope box(100, 101, 100, 101); // Does not include (0,0) point
-        const geos::geom::Envelope exemplar(100, 101, 100, 101);
-
-        // Expand box envelope to include null envelope
-        box.expandToInclude(&empty);
-        ensure( box == exemplar ); // no change expected
-
-        // Expand empty envelope to include bigger envelope
-        empty.expandToInclude(&box);
-        ensure( empty == exemplar );
-    }
+    geos::geom::Envelope empty;
+    geos::geom::Envelope box(100, 101, 100, 101); // Does not include (0,0) point
+    const geos::geom::Envelope exemplar(100, 101, 100, 101);
+
+    // Expand box envelope to include null envelope
+    box.expandToInclude(&empty);
+    ensure(box == exemplar);   // no change expected
+
+    // Expand empty envelope to include bigger envelope
+    empty.expandToInclude(&box);
+    ensure(empty == exemplar);
+}
 
 } // namespace tut
 
diff --git a/tests/unit/geom/Geometry/clone.cpp b/tests/unit/geom/Geometry/clone.cpp
index 9fca572..ff0545c 100644
--- a/tests/unit/geom/Geometry/clone.cpp
+++ b/tests/unit/geom/Geometry/clone.cpp
@@ -18,17 +18,16 @@ namespace tut {
 // Test Group
 //
 
-struct test_geometry_clone_data
-{
-	typedef std::unique_ptr<geos::geom::Geometry> GeomPtr;
-	typedef geos::geom::GeometryFactory GeometryFactory;
-	GeometryFactory::Ptr factory;
-	geos::io::WKTReader reader;
-
-	test_geometry_clone_data()
-	    : factory(GeometryFactory::create())
-	    , reader(factory.get())
-	{}
+struct test_geometry_clone_data {
+    typedef std::unique_ptr<geos::geom::Geometry> GeomPtr;
+    typedef geos::geom::GeometryFactory GeometryFactory;
+    GeometryFactory::Ptr factory;
+    geos::io::WKTReader reader;
+
+    test_geometry_clone_data()
+        : factory(GeometryFactory::create())
+        , reader(factory.get())
+    {}
 };
 
 typedef test_group<test_geometry_clone_data> group;
@@ -42,110 +41,117 @@ group test_geometry_clone_data("geos::geom::Geometry::clone");
 
 template<>
 template<>
-void object::test<1>()
+void object::test<1>
+()
 {
-	GeomPtr g1(reader.read(
-		"POINT (0 100)"
-	));
-	g1->setSRID(66);
-	GeomPtr g2(g1->clone());
+    GeomPtr g1(reader.read(
+                   "POINT (0 100)"
+               ));
+    g1->setSRID(66);
+    GeomPtr g2(g1->clone());
 
-	ensure( g1->equalsExact(g2.get()) );
-	ensure_equals( g1->getSRID(), 66 );
-	ensure_equals( g1->getSRID(), g2->getSRID() );
+    ensure(g1->equalsExact(g2.get()));
+    ensure_equals(g1->getSRID(), 66);
+    ensure_equals(g1->getSRID(), g2->getSRID());
 
 }
 
 template<>
 template<>
-void object::test<2>()
+void object::test<2>
+()
 {
-	GeomPtr g1(reader.read(
-		"LINESTRING (0 0, 0 100, 100 100, 100 0)"
-	));
-	g1->setSRID(66);
-	GeomPtr g2(g1->clone());
+    GeomPtr g1(reader.read(
+                   "LINESTRING (0 0, 0 100, 100 100, 100 0)"
+               ));
+    g1->setSRID(66);
+    GeomPtr g2(g1->clone());
 
-	ensure( g1->equalsExact(g2.get()) );
-	ensure_equals( g1->getSRID(), 66 );
-	ensure_equals( g1->getSRID(), g2->getSRID() );
+    ensure(g1->equalsExact(g2.get()));
+    ensure_equals(g1->getSRID(), 66);
+    ensure_equals(g1->getSRID(), g2->getSRID());
 
 }
 
 template<>
 template<>
-void object::test<3>()
+void object::test<3>
+()
 {
-	GeomPtr g1(reader.read(
-		"POLYGON ((0 0, 0 100, 100 100, 100 0, 0 0))"
-	));
-	g1->setSRID(66);
-	GeomPtr g2(g1->clone());
+    GeomPtr g1(reader.read(
+                   "POLYGON ((0 0, 0 100, 100 100, 100 0, 0 0))"
+               ));
+    g1->setSRID(66);
+    GeomPtr g2(g1->clone());
 
-	ensure( g1->equalsExact(g2.get()) );
-	ensure_equals( g1->getSRID(), 66 );
-	ensure_equals( g1->getSRID(), g2->getSRID() );
+    ensure(g1->equalsExact(g2.get()));
+    ensure_equals(g1->getSRID(), 66);
+    ensure_equals(g1->getSRID(), g2->getSRID());
 
 }
 
 template<>
 template<>
-void object::test<4>()
+void object::test<4>
+()
 {
-	GeomPtr g1(reader.read(
-		"MULTIPOINT (0 100, 5 6)"
-	));
-	g1->setSRID(66);
-	GeomPtr g2(g1->clone());
+    GeomPtr g1(reader.read(
+                   "MULTIPOINT (0 100, 5 6)"
+               ));
+    g1->setSRID(66);
+    GeomPtr g2(g1->clone());
 
-	ensure( g1->equalsExact(g2.get()) );
-	ensure_equals( g1->getSRID(), 66 );
-	ensure_equals( g1->getSRID(), g2->getSRID() );
+    ensure(g1->equalsExact(g2.get()));
+    ensure_equals(g1->getSRID(), 66);
+    ensure_equals(g1->getSRID(), g2->getSRID());
 
 }
 
 template<>
 template<>
-void object::test<5>()
+void object::test<5>
+()
 {
-	GeomPtr g1(reader.read(
-		"MULTILINESTRING ((0 0, 0 100, 100 100, 100 0), (15 25, 25 52))"
-	));
-	g1->setSRID(66);
-	GeomPtr g2(g1->clone());
+    GeomPtr g1(reader.read(
+                   "MULTILINESTRING ((0 0, 0 100, 100 100, 100 0), (15 25, 25 52))"
+               ));
+    g1->setSRID(66);
+    GeomPtr g2(g1->clone());
 
-	ensure( g1->equalsExact(g2.get()) );
-	ensure_equals( g1->getSRID(), 66 );
-	ensure_equals( g1->getSRID(), g2->getSRID() );
+    ensure(g1->equalsExact(g2.get()));
+    ensure_equals(g1->getSRID(), 66);
+    ensure_equals(g1->getSRID(), g2->getSRID());
 
 }
 
 template<>
 template<>
-void object::test<6>()
+void object::test<6>
+()
 {
-	GeomPtr g1(reader.read(
-		"MULTIPOLYGON (((0 0, 0 100, 100 100, 100 0, 0 0)))"
-	));
-	g1->setSRID(66);
-	GeomPtr g2(g1->clone());
-	ensure( g1->equalsExact(g2.get()) );
-	ensure_equals( g1->getSRID(), 66 );
-	ensure_equals( g1->getSRID(), g2->getSRID() );
+    GeomPtr g1(reader.read(
+                   "MULTIPOLYGON (((0 0, 0 100, 100 100, 100 0, 0 0)))"
+               ));
+    g1->setSRID(66);
+    GeomPtr g2(g1->clone());
+    ensure(g1->equalsExact(g2.get()));
+    ensure_equals(g1->getSRID(), 66);
+    ensure_equals(g1->getSRID(), g2->getSRID());
 }
 
 template<>
 template<>
-void object::test<7>()
+void object::test<7>
+()
 {
-	GeomPtr g1(reader.read(
-		"GEOMETRYCOLLECTION(MULTIPOLYGON (((0 0, 0 100, 100 100, 100 0, 0 0))),POINT(3 4))"
-	));
-	g1->setSRID(66);
-	GeomPtr g2(g1->clone());
-	ensure( g1->equalsExact(g2.get()) );
-	ensure_equals( g1->getSRID(), 66 );
-	ensure_equals( g1->getSRID(), g2->getSRID() );
+    GeomPtr g1(reader.read(
+                   "GEOMETRYCOLLECTION(MULTIPOLYGON (((0 0, 0 100, 100 100, 100 0, 0 0))),POINT(3 4))"
+               ));
+    g1->setSRID(66);
+    GeomPtr g2(g1->clone());
+    ensure(g1->equalsExact(g2.get()));
+    ensure_equals(g1->getSRID(), 66);
+    ensure_equals(g1->getSRID(), g2->getSRID());
 }
 
 
diff --git a/tests/unit/geom/Geometry/coversTest.cpp b/tests/unit/geom/Geometry/coversTest.cpp
index 992800c..8134892 100644
--- a/tests/unit/geom/Geometry/coversTest.cpp
+++ b/tests/unit/geom/Geometry/coversTest.cpp
@@ -18,18 +18,17 @@ namespace tut {
 // Test Group
 //
 
-struct test_contains_data
-{
-	typedef std::unique_ptr<geos::geom::Geometry> GeomPtr;
-	typedef geos::geom::GeometryFactory GeometryFactory;
+struct test_contains_data {
+    typedef std::unique_ptr<geos::geom::Geometry> GeomPtr;
+    typedef geos::geom::GeometryFactory GeometryFactory;
 
-	geos::geom::GeometryFactory::Ptr factory;
-	geos::io::WKTReader reader;
+    geos::geom::GeometryFactory::Ptr factory;
+    geos::io::WKTReader reader;
 
-	test_contains_data()
-	    : factory(GeometryFactory::create())
-	    , reader(factory.get())
-	{}
+    test_contains_data()
+        : factory(GeometryFactory::create())
+        , reader(factory.get())
+    {}
 };
 
 typedef test_group<test_contains_data> group;
@@ -44,79 +43,83 @@ group test_contains_data("geos::geom::Geometry::covers");
 // 1 - Boundaries touch, still g1 covers g2
 template<>
 template<>
-void object::test<1>()
+void object::test<1>
+()
 {
-	GeomPtr g1(reader.read(
-		"POLYGON ((0 0, 0 100, 100 100, 100 0, 0 0))"
-	));
-	GeomPtr g2(reader.read(
-		"POLYGON ((0 0, 0 100, 90 90, 90 0, 0 0))"
-	));
+    GeomPtr g1(reader.read(
+                   "POLYGON ((0 0, 0 100, 100 100, 100 0, 0 0))"
+               ));
+    GeomPtr g2(reader.read(
+                   "POLYGON ((0 0, 0 100, 90 90, 90 0, 0 0))"
+               ));
 
-	ensure( g1->covers(g2.get()) );
-	ensure( g2->coveredBy(g1.get()) );
+    ensure(g1->covers(g2.get()));
+    ensure(g2->coveredBy(g1.get()));
 
 }
 
 // 2 - Polygon covers line (laying on it's boundary)
 template<>
 template<>
-void object::test<2>()
+void object::test<2>
+()
 {
-	GeomPtr g1(reader.read(
-		"POLYGON ((0 0, 0 100, 100 100, 100 0, 0 0))"
-	));
-	GeomPtr g2(reader.read(
-		"LINESTRING (0 0, 0 100)"
-	));
+    GeomPtr g1(reader.read(
+                   "POLYGON ((0 0, 0 100, 100 100, 100 0, 0 0))"
+               ));
+    GeomPtr g2(reader.read(
+                   "LINESTRING (0 0, 0 100)"
+               ));
 
-	ensure( g1->covers(g2.get()) );
-	ensure( g2->coveredBy(g1.get()) );
-	ensure( ! g1->contains(g2.get()) );
+    ensure(g1->covers(g2.get()));
+    ensure(g2->coveredBy(g1.get()));
+    ensure(! g1->contains(g2.get()));
 
 }
 
 // 3 - Line covers point (laying on it's boundary or interior)
 template<>
 template<>
-void object::test<3>()
+void object::test<3>
+()
 {
-	GeomPtr g1(reader.read(
-		"LINESTRING (0 0, 0 100)"
-	));
-	GeomPtr g2(reader.read(
-		"POINT(0 0)"
-	));
+    GeomPtr g1(reader.read(
+                   "LINESTRING (0 0, 0 100)"
+               ));
+    GeomPtr g2(reader.read(
+                   "POINT(0 0)"
+               ));
 
-	ensure( g1->covers(g2.get()) );
-	ensure( g2->coveredBy(g1.get()) );
-	ensure( ! g1->contains(g2.get()) );
+    ensure(g1->covers(g2.get()));
+    ensure(g2->coveredBy(g1.get()));
+    ensure(! g1->contains(g2.get()));
 
-	g2.reset(reader.read(
-		"POINT(0 2)"
-	));
+    g2.reset(reader.read(
+                 "POINT(0 2)"
+             ));
 
-	ensure( g1->covers(g2.get()) );
-	ensure( g2->coveredBy(g1.get()) );
-	ensure( g1->contains(g2.get()) );
+    ensure(g1->covers(g2.get()));
+    ensure(g2->coveredBy(g1.get()));
+    ensure(g1->contains(g2.get()));
 
 }
 
 // 4 - http://trac.osgeo.org/geos/ticket/580
 template<>
 template<>
-void object::test<4>()
+void object::test<4>
+()
 {
-	GeomPtr g1(reader.read(
-		"POLYGON ((-1.183864 52.951915, -1.183862 52.951903, -1.183890 52.951900, -1.183924 52.951897, -1.183958 52.951894, -1.183954 52.951880, -1.183954 52.951878, -1.183932 52.951841, -1.183904 52.951844, -1.183870 52.951847, -1.183832 52.951852, -1.183824 52.951838, -1.183820 52.951830, -1.183870 52.951819, -1.183886 52.951815, -1.183890 52.951819, -1.183929 52.951810, -1.183909 52.951776, -1.183861 52.951787, -1.183853 52.951788, -1.183842 52.951770, -1.183970 52.951742, -1.183983 52.951763, -1.183963 52.951768, -1.183975 52.951788, -1.183994 52.951785, -1.184009 52.951807, -1.184002 52.951808, -1.184009 52.951835, -1.183990 52.951836, -1.183990 52.951836, -1.183990 52.951838, -1.184001 52.951880, -1.184018 52.951954, -1.184020 52.951956, -1.183998 52.951957, -1.183998 52.951956, -1.183996 52.951948, -1.183970 52.951906, -1.183936 52.951909, -1.183864 52.951915))"
-	));
-	GeomPtr g2(reader.read(
-		"POINT (-1.183972 52.951871)"
-	));
-
-	ensure( g1->covers(g2.get()) );
-	ensure( g2->coveredBy(g1.get()) );
-	ensure( g1->contains(g2.get()) );
+    GeomPtr g1(reader.read(
+                   "POLYGON ((-1.183864 52.951915, -1.183862 52.951903, -1.183890 52.951900, -1.183924 52.951897, -1.183958 52.951894, -1.183954 52.951880, -1.183954 52.951878, -1.183932 52.951841, -1.183904 52.951844, -1.183870 52.951847, -1.183832 52.951852, -1.183824 52.951838, -1.183820 52.951830, -1.183870 52.951819, -1.183886 52.951815, -1.183890 52.951819, -1.183929 52.951810, -1.183909 52.951776, -1.183861 52.951787, -1.183853 52.951788, -1.183842 52.951770, -1.183970 52.951742, -1.183983 52.951763, -1.183963 52.951768, -1.183975 52.951788, -1.183994 52.951785, -1.184009 52.951807, -1.184002 52.951808, -1.184009 52.951835, -1.183990 52.951836, -1.183990 52.951836, -1.183990 52.951838, -1.184001 52.951880, -1.184018 52.951954, -1.184020 52.951956, -1.183998 52.951957, -1.183998 52.951956, -1.183996 52.951948, -1.183970 52.951906, -1.183936 52.951909, -1.183864 52.951915))"
+               ));
+    GeomPtr g2(reader.read(
+                   "POINT (-1.183972 52.951871)"
+               ));
+
+    ensure(g1->covers(g2.get()));
+    ensure(g2->coveredBy(g1.get()));
+    ensure(g1->contains(g2.get()));
 
 }
 
diff --git a/tests/unit/geom/Geometry/equalsTest.cpp b/tests/unit/geom/Geometry/equalsTest.cpp
index a060767..21f783f 100644
--- a/tests/unit/geom/Geometry/equalsTest.cpp
+++ b/tests/unit/geom/Geometry/equalsTest.cpp
@@ -18,14 +18,13 @@ namespace tut {
 // Test Group
 //
 
-struct test_equals_data
-{
-	typedef std::unique_ptr<geos::geom::Geometry> GeomPtr;
-	geos::io::WKTReader reader;
+struct test_equals_data {
+    typedef std::unique_ptr<geos::geom::Geometry> GeomPtr;
+    geos::io::WKTReader reader;
 
-	test_equals_data()
-	    : reader()
-	{}
+    test_equals_data()
+        : reader()
+    {}
 };
 
 typedef test_group<test_equals_data> group;
@@ -40,25 +39,27 @@ group test_equals_data("geos::geom::Geometry::equals");
 // Empty equals empty
 // See http://trac.osgeo.org/geos/ticket/703
 
-template<> template<> void object::test<1>() {
+template<> template<> void object::test<1>
+()
+{
 
-	GeomPtr g1(reader.read("POINT EMPTY"));
-	ensure( g1->equals(g1.get()) );
+    GeomPtr g1(reader.read("POINT EMPTY"));
+    ensure(g1->equals(g1.get()));
 
-	GeomPtr g2(reader.read("LINESTRING EMPTY"));
-	ensure( g2->equals(g2.get()) );
-	ensure( g2->equals(g1.get()) );
+    GeomPtr g2(reader.read("LINESTRING EMPTY"));
+    ensure(g2->equals(g2.get()));
+    ensure(g2->equals(g1.get()));
 
-	GeomPtr g3(reader.read("POLYGON EMPTY"));
-	ensure( g3->equals(g3.get()) );
-	ensure( g3->equals(g2.get()) );
-	ensure( g3->equals(g1.get()) );
+    GeomPtr g3(reader.read("POLYGON EMPTY"));
+    ensure(g3->equals(g3.get()));
+    ensure(g3->equals(g2.get()));
+    ensure(g3->equals(g1.get()));
 
-	GeomPtr g4(reader.read("GEOMETRYCOLLECTION EMPTY"));
-	ensure( g4->equals(g4.get()) );
-	ensure( g4->equals(g3.get()) );
-	ensure( g4->equals(g2.get()) );
-	ensure( g4->equals(g1.get()) );
+    GeomPtr g4(reader.read("GEOMETRYCOLLECTION EMPTY"));
+    ensure(g4->equals(g4.get()));
+    ensure(g4->equals(g3.get()));
+    ensure(g4->equals(g2.get()));
+    ensure(g4->equals(g1.get()));
 
 }
 
diff --git a/tests/unit/geom/Geometry/isRectangleTest.cpp b/tests/unit/geom/Geometry/isRectangleTest.cpp
index 5cdb9fd..0572c0c 100644
--- a/tests/unit/geom/Geometry/isRectangleTest.cpp
+++ b/tests/unit/geom/Geometry/isRectangleTest.cpp
@@ -10,134 +10,139 @@
 // std
 #include <string>
 
-namespace tut
+namespace tut {
+//
+// Test Group
+//
+
+struct test_isrectangle_data {
+    geos::io::WKTReader reader;
+
+    test_isrectangle_data()
+    {}
+};
+
+typedef test_group<test_isrectangle_data> group;
+typedef group::object object;
+
+group test_isrectangle_group("geos::geom::Geometry::isRectangle");
+
+//
+// Test Cases
+//
+
+// 1 - Test of valid rectangle
+template<>
+template<>
+void object::test<1>
+()
+{
+    const std::string wkt("POLYGON ((0 0, 0 100, 100 100, 100 0, 0 0))");
+    geos::geom::Geometry* g = reader.read(wkt);
+
+    geos::geom::Polygon* poly = dynamic_cast<geos::geom::Polygon*>(g);
+    ensure("Geometry is not a Polygon: " + wkt, poly != nullptr);
+    ensure(poly->isRectangle());
+
+    delete g;
+}
+
+// 2 - Test of another valid rectangle
+template<>
+template<>
+void object::test<2>
+()
+{
+    const std::string wkt("POLYGON ((0 0, 0 200, 100 200, 100 0, 0 0))");
+    geos::geom::Geometry* g = reader.read(wkt);
+
+    geos::geom::Polygon* poly = dynamic_cast<geos::geom::Polygon*>(g);
+    ensure("Geometry is not a Polygon: " + wkt, poly != nullptr);
+    ensure(poly->isRectangle());
+
+    delete g;
+}
+
+// 3 - Test of rectangle with hole
+template<>
+template<>
+void object::test<3>
+()
 {
-    //
-    // Test Group
-    //
-
-    struct test_isrectangle_data
-    {
-        geos::io::WKTReader reader;
-
-        test_isrectangle_data()
-        {}
-    };
-
-    typedef test_group<test_isrectangle_data> group;
-    typedef group::object object;
-
-    group test_isrectangle_group("geos::geom::Geometry::isRectangle");
-
-    //
-    // Test Cases
-    //
-
-    // 1 - Test of valid rectangle
-    template<>
-    template<>
-    void object::test<1>()
-    {
-        const std::string wkt("POLYGON ((0 0, 0 100, 100 100, 100 0, 0 0))");
-        geos::geom::Geometry* g = reader.read(wkt);
-
-        geos::geom::Polygon* poly = dynamic_cast<geos::geom::Polygon*>(g);
-        ensure( "Geometry is not a Polygon: " + wkt, poly != nullptr );
-        ensure( poly->isRectangle() );
-
-        delete g;
-    }
-
-    // 2 - Test of another valid rectangle
-    template<>
-    template<>
-    void object::test<2>()
-    {
-        const std::string wkt("POLYGON ((0 0, 0 200, 100 200, 100 0, 0 0))");
-        geos::geom::Geometry* g = reader.read(wkt);
-
-        geos::geom::Polygon* poly = dynamic_cast<geos::geom::Polygon*>(g);
-        ensure( "Geometry is not a Polygon: " + wkt, poly != nullptr );
-        ensure( poly->isRectangle() );
-
-        delete g;
-    }
-
-    // 3 - Test of rectangle with hole
-    template<>
-    template<>
-    void object::test<3>()
-    {
-        const std::string wkt("POLYGON ((0 0, 0 100, 100 100, 100 0, 0 0), \
+    const std::string wkt("POLYGON ((0 0, 0 100, 100 100, 100 0, 0 0), \
                               (10 10, 10 90, 90 90, 90 10, 10 10) ))");
-        geos::geom::Geometry* g = reader.read(wkt);
-
-        geos::geom::Polygon* poly = dynamic_cast<geos::geom::Polygon*>(g);
-        ensure( "Geometry is not a Polygon: " + wkt, poly != nullptr );
-        ensure( !poly->isRectangle() );
-
-        delete g;
-    }
-
-    // 4 - Test of non-rectilinear rectangle
-    template<>
-    template<>
-    void object::test<4>()
-    {
-        const std::string wkt("POLYGON ((0 0, 0 100, 99 100, 100 0, 0 0))");
-        geos::geom::Geometry* g = reader.read(wkt);
-
-        geos::geom::Polygon* poly = dynamic_cast<geos::geom::Polygon*>(g);
-        ensure( "Geometry is not a Polygon: " + wkt, poly != nullptr );
-        ensure( !poly->isRectangle() );
-
-        delete g;
-    }
-
-    // 5 - Test of rectangle with too many points
-    template<>
-    template<>
-    void object::test<5>()
-    {
-        const std::string wkt("POLYGON ((0 0, 0 100, 100 50, 100 100, 100 0, 0 0))");
-        geos::geom::Geometry* g = reader.read(wkt);
-
-        geos::geom::Polygon* poly = dynamic_cast<geos::geom::Polygon*>(g);
-        ensure( "Geometry is not a Polygon: " + wkt, poly != nullptr );
-        ensure( !poly->isRectangle() );
-
-        delete g;
-    }
-
-    // 6 - Test of rectangle with too few points
-    template<>
-    template<>
-    void object::test<6>()
-    {
-        const std::string wkt("POLYGON ((0 0, 0 100, 100 0, 0 0))");
-        geos::geom::Geometry* g = reader.read(wkt);
-
-        geos::geom::Polygon* poly = dynamic_cast<geos::geom::Polygon*>(g);
-        ensure( "Geometry is not a Polygon: " + wkt, poly != nullptr );
-        ensure( !poly->isRectangle() );
-
-        delete g;
-    }
-
-    // 7 - Test of rectangle with points in wrong order
-    template<>
-    template<>
-    void object::test<7>()
-    {
-        const std::string wkt("POLYGON ((0 0, 0 100, 100 0, 100 100, 0 0))");
-        geos::geom::Geometry* g = reader.read(wkt);
-
-        geos::geom::Polygon* poly = dynamic_cast<geos::geom::Polygon*>(g);
-        ensure( "Geometry is not a Polygon: " + wkt, poly != nullptr );
-        ensure( !poly->isRectangle() );
-
-        delete g;
-    }
+    geos::geom::Geometry* g = reader.read(wkt);
+
+    geos::geom::Polygon* poly = dynamic_cast<geos::geom::Polygon*>(g);
+    ensure("Geometry is not a Polygon: " + wkt, poly != nullptr);
+    ensure(!poly->isRectangle());
+
+    delete g;
+}
+
+// 4 - Test of non-rectilinear rectangle
+template<>
+template<>
+void object::test<4>
+()
+{
+    const std::string wkt("POLYGON ((0 0, 0 100, 99 100, 100 0, 0 0))");
+    geos::geom::Geometry* g = reader.read(wkt);
+
+    geos::geom::Polygon* poly = dynamic_cast<geos::geom::Polygon*>(g);
+    ensure("Geometry is not a Polygon: " + wkt, poly != nullptr);
+    ensure(!poly->isRectangle());
+
+    delete g;
+}
+
+// 5 - Test of rectangle with too many points
+template<>
+template<>
+void object::test<5>
+()
+{
+    const std::string wkt("POLYGON ((0 0, 0 100, 100 50, 100 100, 100 0, 0 0))");
+    geos::geom::Geometry* g = reader.read(wkt);
+
+    geos::geom::Polygon* poly = dynamic_cast<geos::geom::Polygon*>(g);
+    ensure("Geometry is not a Polygon: " + wkt, poly != nullptr);
+    ensure(!poly->isRectangle());
+
+    delete g;
+}
+
+// 6 - Test of rectangle with too few points
+template<>
+template<>
+void object::test<6>
+()
+{
+    const std::string wkt("POLYGON ((0 0, 0 100, 100 0, 0 0))");
+    geos::geom::Geometry* g = reader.read(wkt);
+
+    geos::geom::Polygon* poly = dynamic_cast<geos::geom::Polygon*>(g);
+    ensure("Geometry is not a Polygon: " + wkt, poly != nullptr);
+    ensure(!poly->isRectangle());
+
+    delete g;
+}
+
+// 7 - Test of rectangle with points in wrong order
+template<>
+template<>
+void object::test<7>
+()
+{
+    const std::string wkt("POLYGON ((0 0, 0 100, 100 0, 100 100, 0 0))");
+    geos::geom::Geometry* g = reader.read(wkt);
+
+    geos::geom::Polygon* poly = dynamic_cast<geos::geom::Polygon*>(g);
+    ensure("Geometry is not a Polygon: " + wkt, poly != nullptr);
+    ensure(!poly->isRectangle());
+
+    delete g;
+}
 
 } // namespace tut
 
diff --git a/tests/unit/geom/Geometry/normalize.cpp b/tests/unit/geom/Geometry/normalize.cpp
index 05668c4..599baa7 100644
--- a/tests/unit/geom/Geometry/normalize.cpp
+++ b/tests/unit/geom/Geometry/normalize.cpp
@@ -19,42 +19,41 @@ namespace tut {
 // Test Group
 //
 
-struct test_geometry_normalize_data
-{
-  typedef std::unique_ptr<geos::geom::Geometry> GeomPtr;
-  geos::io::WKTReader reader;
-  geos::io::WKTWriter writer;
-
-  test_geometry_normalize_data()
-      : reader(), writer()
-  {
-    writer.setTrim(true);
-  }
-
-  void
-  runTest(const char *from, const char *exp)
-  {
-    GeomPtr g1(reader.read(from));
-    ensure(g1.get());
-    GeomPtr g2(g1->clone());
-    ensure(g2.get());
-    g2->normalize();
-
-    GeomPtr ge(reader.read(exp));
-    bool eq = g2->equalsExact(ge.get());
-    if ( ! eq ) {
-      using namespace std;
-      cout << endl;
-      cout << "Expected: " << exp << endl;
-      cout << "Obtained: " << writer.write(g2.get()) << endl;
+struct test_geometry_normalize_data {
+    typedef std::unique_ptr<geos::geom::Geometry> GeomPtr;
+    geos::io::WKTReader reader;
+    geos::io::WKTWriter writer;
+
+    test_geometry_normalize_data()
+        : reader(), writer()
+    {
+        writer.setTrim(true);
     }
-    ensure( eq );
 
-    // Clone and re-normalize, check it doesn't change anymore
-    ge.reset( g2->clone() );
-    g2->normalize();
-    ensure( g2->equalsExact(ge.get()) );
-  }
+    void
+    runTest(const char* from, const char* exp)
+    {
+        GeomPtr g1(reader.read(from));
+        ensure(g1.get());
+        GeomPtr g2(g1->clone());
+        ensure(g2.get());
+        g2->normalize();
+
+        GeomPtr ge(reader.read(exp));
+        bool eq = g2->equalsExact(ge.get());
+        if(! eq) {
+            using namespace std;
+            cout << endl;
+            cout << "Expected: " << exp << endl;
+            cout << "Obtained: " << writer.write(g2.get()) << endl;
+        }
+        ensure(eq);
+
+        // Clone and re-normalize, check it doesn't change anymore
+        ge.reset(g2->clone());
+        g2->normalize();
+        ensure(g2->equalsExact(ge.get()));
+    }
 };
 
 typedef test_group<test_geometry_normalize_data> group;
@@ -68,144 +67,151 @@ group test_geometry_normalize_data("geos::geom::Geometry::normalize");
 
 template<>
 template<>
-void object::test<1>()
+void object::test<1>
+()
 {
-  const char *inp = "POINT (0 100)";
-  const char *exp = inp; // point does not normalize to anything else
-  runTest(inp, exp);
+    const char* inp = "POINT (0 100)";
+    const char* exp = inp; // point does not normalize to anything else
+    runTest(inp, exp);
 }
 
 template<>
 template<>
-void object::test<2>()
+void object::test<2>
+()
 {
-  const char *inp =
-    "LINESTRING(100 0,100 100,0 100,0 0)";
-  const char *exp =
-    "LINESTRING (0 0, 0 100, 100 100, 100 0)";
-  runTest(inp, exp);
+    const char* inp =
+        "LINESTRING(100 0,100 100,0 100,0 0)";
+    const char* exp =
+        "LINESTRING (0 0, 0 100, 100 100, 100 0)";
+    runTest(inp, exp);
 }
 
 template<>
 template<>
-void object::test<3>()
+void object::test<3>
+()
 {
-  const char *inp =
-    "POLYGON ("
-      "(0 0,100 0,100 100,0 100,0 0)," // CCW
-      "(10 10,20 10,20 20,10 20,10 10)," // CCW, leftmost
-      "(40 10,40 20,60 20,60 10,40 10)" // CW, rightmost
-    ")" ;
-  const char *exp =
-    "POLYGON("
-      "(0 0,0 100,100 100,100 0,0 0)," // CW
-      "(40 10,60 10,60 20,40 20,40 10)," // CCW, rightmost
-      "(10 10,20 10,20 20,10 20,10 10)" // CCW, leftmost
-    ")";
-
-  runTest(inp, exp);
+    const char* inp =
+        "POLYGON ("
+        "(0 0,100 0,100 100,0 100,0 0)," // CCW
+        "(10 10,20 10,20 20,10 20,10 10)," // CCW, leftmost
+        "(40 10,40 20,60 20,60 10,40 10)" // CW, rightmost
+        ")" ;
+    const char* exp =
+        "POLYGON("
+        "(0 0,0 100,100 100,100 0,0 0)," // CW
+        "(40 10,60 10,60 20,40 20,40 10)," // CCW, rightmost
+        "(10 10,20 10,20 20,10 20,10 10)" // CCW, leftmost
+        ")";
+
+    runTest(inp, exp);
 }
 
 template<>
 template<>
-void object::test<4>()
+void object::test<4>
+()
 {
-  const char *inp =
-    "MULTIPOINT ("
-      "0 100," // leftmost
-      "5 6"    // rightmost
-    ")";
-  const char *exp =
-    "MULTIPOINT ("
-      "5 6,"   // rightmost
-      "0 100"  // leftmost
-    ")";
-  runTest(inp, exp);
+    const char* inp =
+        "MULTIPOINT ("
+        "0 100," // leftmost
+        "5 6"    // rightmost
+        ")";
+    const char* exp =
+        "MULTIPOINT ("
+        "5 6,"   // rightmost
+        "0 100"  // leftmost
+        ")";
+    runTest(inp, exp);
 }
 
 template<>
 template<>
-void object::test<5>()
+void object::test<5>
+()
 {
-  const char *inp =
-    "MULTILINESTRING("
-      "(15 25, 25 52),"               // rightmost vertex @ 25
-      "(0 0, 0 100, 100 100, 100 0)"  // rightmost vertex @ 100
-    ")";
-  const char *exp =
-    "MULTILINESTRING("
-      "(0 0, 0 100, 100 100, 100 0)," // rightmost vertex @ 100
-      "(15 25, 25 52)"                // rightmost vertex @ 25
-    ")";
-  runTest(inp, exp);
+    const char* inp =
+        "MULTILINESTRING("
+        "(15 25, 25 52),"               // rightmost vertex @ 25
+        "(0 0, 0 100, 100 100, 100 0)"  // rightmost vertex @ 100
+        ")";
+    const char* exp =
+        "MULTILINESTRING("
+        "(0 0, 0 100, 100 100, 100 0)," // rightmost vertex @ 100
+        "(15 25, 25 52)"                // rightmost vertex @ 25
+        ")";
+    runTest(inp, exp);
 }
 
 template<>
 template<>
-void object::test<6>()
+void object::test<6>
+()
 {
-  const char *inp =
-    "MULTIPOLYGON("
-      "((0 0, 0 1, 1 1, 1 0, 0 0))," // leftmost
-      "((2 0, 2 1, 3 1, 3 0, 2 0))"  // rightmost
-    ")";
-  const char *exp =
-    "MULTIPOLYGON("
-      "((2 0, 2 1, 3 1, 3 0, 2 0))," // rightmost
-      "((0 0, 0 1, 1 1, 1 0, 0 0))"  // leftmost
-    ")";
-  runTest(inp, exp);
+    const char* inp =
+        "MULTIPOLYGON("
+        "((0 0, 0 1, 1 1, 1 0, 0 0))," // leftmost
+        "((2 0, 2 1, 3 1, 3 0, 2 0))"  // rightmost
+        ")";
+    const char* exp =
+        "MULTIPOLYGON("
+        "((2 0, 2 1, 3 1, 3 0, 2 0))," // rightmost
+        "((0 0, 0 1, 1 1, 1 0, 0 0))"  // leftmost
+        ")";
+    runTest(inp, exp);
 }
 
 template<>
 template<>
-void object::test<7>()
+void object::test<7>
+()
 {
-  const char *inp =
-    "GEOMETRYCOLLECTION("
-      "MULTIPOINT ("
+    const char* inp =
+        "GEOMETRYCOLLECTION("
+        "MULTIPOINT ("
         "0 100," // leftmost
         "5 6"    // rightmost
-      "),"
-      "POINT(10 4)," // more on the right than the multipoint
-      "MULTILINESTRING("
+        "),"
+        "POINT(10 4)," // more on the right than the multipoint
+        "MULTILINESTRING("
         "(15 25, 25 52),"               // rightmost vertex @ 25
         "(0 0, 0 100, 100 100, 100 0)"  // rightmost vertex @ 100
-      "),"
-      "LINESTRING(100 0,100 100,0 100,0 0),"
-      "MULTIPOLYGON("
+        "),"
+        "LINESTRING(100 0,100 100,0 100,0 0),"
+        "MULTIPOLYGON("
         "((0 0, 0 1, 1 1, 1 0, 0 0))," // leftmost
         "((2 0, 2 1, 3 1, 3 0, 2 0))"  // rightmost
-      "),"
-      "POLYGON ("
+        "),"
+        "POLYGON ("
         "(0 0,100 0,100 100,0 100,0 0)," // CCW
         "(10 10,20 10,20 20,10 20,10 10)," // CCW, leftmost
         "(40 10,40 20,60 20,60 10,40 10)" // CW, rightmost
-      ")"
-    ")";
-  const char *exp =
-    "GEOMETRYCOLLECTION("
-      "MULTIPOLYGON("
+        ")"
+        ")";
+    const char* exp =
+        "GEOMETRYCOLLECTION("
+        "MULTIPOLYGON("
         "((2 0, 2 1, 3 1, 3 0, 2 0))," // rightmost
         "((0 0, 0 1, 1 1, 1 0, 0 0))"  // leftmost
-      "),"
-      "POLYGON("
+        "),"
+        "POLYGON("
         "(0 0,0 100,100 100,100 0,0 0)," // CW
         "(40 10,60 10,60 20,40 20,40 10)," // CCW, rightmost
         "(10 10,20 10,20 20,10 20,10 10)" // CCW, leftmost
-      "),"
-      "MULTILINESTRING("
+        "),"
+        "MULTILINESTRING("
         "(0 0, 0 100, 100 100, 100 0)," // rightmost vertex @ 100
         "(15 25, 25 52)"                // rightmost vertex @ 25
-      "),"
-      "LINESTRING (0 0, 0 100, 100 100, 100 0),"
-      "MULTIPOINT ("
+        "),"
+        "LINESTRING (0 0, 0 100, 100 100, 100 0),"
+        "MULTIPOINT ("
         "5 6,"   // rightmost
         "0 100"  // leftmost
-      "),"
-      "POINT(10 4)" // more on the right than the multipoint
-    ")";
-  runTest(inp, exp);
+        "),"
+        "POINT(10 4)" // more on the right than the multipoint
+        ")";
+    runTest(inp, exp);
 }
 
 
diff --git a/tests/unit/geom/Geometry/touchesTest.cpp b/tests/unit/geom/Geometry/touchesTest.cpp
index 3e23c4a..29fbcfa 100644
--- a/tests/unit/geom/Geometry/touchesTest.cpp
+++ b/tests/unit/geom/Geometry/touchesTest.cpp
@@ -18,8 +18,7 @@ namespace tut {
 // Test Group
 //
 
-struct test_touches_data
-{
+struct test_touches_data {
     typedef std::unique_ptr<geos::geom::Geometry> GeomPtr;
     typedef geos::geom::GeometryFactory GeometryFactory;
 
@@ -46,15 +45,16 @@ group test_touches_data("geos::geom::Geometry::touches");
 // 1 - Point/Point do not touch
 template<>
 template<>
-void object::test<1>()
+void object::test<1>
+()
 {
     GeomPtr g1(reader.read(
-        "POINT (0 0)"
-        ));
+                   "POINT (0 0)"
+               ));
 
     GeomPtr g2(reader.read(
-        "POINT (0 0)"
-        ));
+                   "POINT (0 0)"
+               ));
 
     ensure(!g1->touches(g2.get()));
     ensure(!g2->touches(g1.get()));
@@ -63,15 +63,16 @@ void object::test<1>()
 // 2 - Line/Point do not touch if point is not on boundary
 template<>
 template<>
-void object::test<2>()
+void object::test<2>
+()
 {
     GeomPtr g1(reader.read(
-        "LINESTRING(0 0, 1 1, 0 2)"
-        ));
+                   "LINESTRING(0 0, 1 1, 0 2)"
+               ));
 
     GeomPtr g2(reader.read(
-        "POINT (1 1)"
-        ));
+                   "POINT (1 1)"
+               ));
 
     ensure(!g1->touches(g2.get()));
     ensure(!g2->touches(g1.get()));
@@ -80,15 +81,16 @@ void object::test<2>()
 // 3 - Line/Point touch
 template<>
 template<>
-void object::test<3>()
+void object::test<3>
+()
 {
     GeomPtr g1(reader.read(
-        "LINESTRING(0 0, 1 1, 0 2)"
-        ));
+                   "LINESTRING(0 0, 1 1, 0 2)"
+               ));
 
     GeomPtr g2(reader.read(
-        "POINT (0 2)"
-        ));
+                   "POINT (0 2)"
+               ));
 
     ensure(g1->touches(g2.get()));
     ensure(g2->touches(g1.get()));
@@ -97,15 +99,16 @@ void object::test<3>()
 // 4 - Line/Point touch (FP coordinates)
 template<>
 template<>
-void object::test<4>()
+void object::test<4>
+()
 {
     GeomPtr g1(reader.read(
-        "LINESTRING (-612844.96290006 279079.117329031,-257704.820935236 574364.179187424)"
-        ));
+                   "LINESTRING (-612844.96290006 279079.117329031,-257704.820935236 574364.179187424)"
+               ));
 
     GeomPtr g2(reader.read(
-        "POINT (-257704.820935236 574364.179187424)"
-        ));
+                   "POINT (-257704.820935236 574364.179187424)"
+               ));
 
     ensure(g1->touches(g2.get()));
     ensure(g2->touches(g1.get()));
@@ -113,7 +116,8 @@ void object::test<4>()
 
 template<>
 template<>
-void object::test<5>()
+void object::test<5>
+()
 {
     // Two T-like segments, A (horizontal), B (vertical)
     // A: LINESTRING(-3511.75501903694 4257.47493284327,-877.546556856658 4257.47493284327)
@@ -130,12 +134,14 @@ void object::test<5>()
 
 template<>
 template<>
-void object::test<6>()
+void object::test<6>
+()
 {
     // Two Y-like segments, A (V-part), B (|-part)
     // A: LINESTRING(-428.533750803201 4467.01424233489,1098.10978977856 4137.73818456235,1621.95806350759 5544.64497686319)
     // B: LINESTRING(1098.10978977856 4137.73818456235,1921.2999342099 2177.04893146225)
-    std::stringstream wkbA("010200000003000000603f483e8ac87ac092ba62a50373b1405851bb6c70289140b6d9a9f9bc29b04060a2990ed55799401226341da5a8b540");
+    std::stringstream
+    wkbA("010200000003000000603f483e8ac87ac092ba62a50373b1405851bb6c70289140b6d9a9f9bc29b04060a2990ed55799401226341da5a8b540");
     std::stringstream wkbB("0102000000020000005851bb6c70289140b6d9a9f9bc29b040d019f42133059e40406c8b0d1902a140");
     GeomPtr a(breader.readHEX(wkbA));
     GeomPtr b(breader.readHEX(wkbB));
@@ -147,7 +153,8 @@ void object::test<6>()
 
 template<>
 template<>
-void object::test<7>()
+void object::test<7>
+()
 {
     // Two T-like two segments rotated ~55 degrees counter-clockwise; A (horizontal), B (vertical)
     // A: LINESTRING(3343.17382004585 2521.2920827699,4959.61992183829 5125.56635787996)
diff --git a/tests/unit/geom/GeometryCollectionTest.cpp b/tests/unit/geom/GeometryCollectionTest.cpp
index 2f28ea1..cda9259 100644
--- a/tests/unit/geom/GeometryCollectionTest.cpp
+++ b/tests/unit/geom/GeometryCollectionTest.cpp
@@ -6,75 +6,77 @@
 
 
 namespace tut {
-	//
-	// Test Group
-	//
-
-	// Common data used by tests
-	struct test_geometry_collection_data {
-		typedef geos::geom::GeometryFactory GeometryFactory;
-
-		geos::geom::PrecisionModel pm_;
-		GeometryFactory::Ptr factory_;
-
-		test_geometry_collection_data()
-			: pm_(1000), factory_(GeometryFactory::create(&pm_, 0))
-		{
-		}
-	};
-
-	typedef test_group<test_geometry_collection_data> group;
-	typedef group::object object;
+//
+// Test Group
+//
 
-	group test_geometry_collection_group("geos::geom::GeometryCollection");
+// Common data used by tests
+struct test_geometry_collection_data {
+    typedef geos::geom::GeometryFactory GeometryFactory;
 
-	//
-	// Test Cases
-	//
+    geos::geom::PrecisionModel pm_;
+    GeometryFactory::Ptr factory_;
 
-	// Test of user's constructor to build empty Point
-	template<>
-    template<>
-    void object::test<1>()
+    test_geometry_collection_data()
+        : pm_(1000), factory_(GeometryFactory::create(&pm_, 0))
     {
-        GeometryPtr empty_point = factory_->createPoint();
-        ensure( empty_point != nullptr );
+    }
+};
 
-        geos::geom::Coordinate coord(1, 2);
-        GeometryPtr point = factory_->createPoint(coord);
-        ensure( point != nullptr );
+typedef test_group<test_geometry_collection_data> group;
+typedef group::object object;
 
-        std::vector<GeometryPtr> geoms{empty_point, point};
-        GeometryColPtr col = factory_->createGeometryCollection(geoms);
-        ensure( col != nullptr );
+group test_geometry_collection_group("geos::geom::GeometryCollection");
 
-        ensure( col->getCoordinate() != nullptr );
-        ensure_equals( col->getCoordinate()->x, 1 );
-        ensure_equals( col->getCoordinate()->y, 2 );
-    }
+//
+// Test Cases
+//
 
-	// Test of default constructor
-	template<>
-	template<>
-	void object::test<2>()
-	{
-		geos::geom::PrecisionModel pm;
-		auto gf = GeometryFactory::create(&pm, 1);
-		auto g = gf->createEmptyGeometry();
-
-		g->setSRID(0);
-		std::vector<decltype(g)> v = {g};
-		auto geom_col = gf->createGeometryCollection(v);
-		ensure_equals(geom_col->getGeometryN(0)->getSRID(), 1);
-
-		geom_col->setSRID(2);
-		ensure_equals(geom_col->getGeometryN(0)->getSRID(), 2);
-
-		auto clone = geom_col->clone();
-		ensure_equals(clone->getGeometryN(0)->getSRID(), 2);
-
-		// FREE MEMORY
-		gf->destroyGeometry(geom_col);
-		gf->destroyGeometry(clone);
-	}
+// Test of user's constructor to build empty Point
+template<>
+template<>
+void object::test<1>
+()
+{
+    GeometryPtr empty_point = factory_->createPoint();
+    ensure(empty_point != nullptr);
+
+    geos::geom::Coordinate coord(1, 2);
+    GeometryPtr point = factory_->createPoint(coord);
+    ensure(point != nullptr);
+
+    std::vector<GeometryPtr> geoms{empty_point, point};
+    GeometryColPtr col = factory_->createGeometryCollection(geoms);
+    ensure(col != nullptr);
+
+    ensure(col->getCoordinate() != nullptr);
+    ensure_equals(col->getCoordinate()->x, 1);
+    ensure_equals(col->getCoordinate()->y, 2);
+}
+
+// Test of default constructor
+template<>
+template<>
+void object::test<2>
+()
+{
+    geos::geom::PrecisionModel pm;
+    auto gf = GeometryFactory::create(&pm, 1);
+    auto g = gf->createEmptyGeometry();
+
+    g->setSRID(0);
+    std::vector<decltype(g)> v = {g};
+    auto geom_col = gf->createGeometryCollection(v);
+    ensure_equals(geom_col->getGeometryN(0)->getSRID(), 1);
+
+    geom_col->setSRID(2);
+    ensure_equals(geom_col->getGeometryN(0)->getSRID(), 2);
+
+    auto clone = geom_col->clone();
+    ensure_equals(clone->getGeometryN(0)->getSRID(), 2);
+
+    // FREE MEMORY
+    gf->destroyGeometry(geom_col);
+    gf->destroyGeometry(clone);
+}
 } // namespace tut
diff --git a/tests/unit/geom/GeometryComponentFilterTest.cpp b/tests/unit/geom/GeometryComponentFilterTest.cpp
index 74a87b3..7af0830 100644
--- a/tests/unit/geom/GeometryComponentFilterTest.cpp
+++ b/tests/unit/geom/GeometryComponentFilterTest.cpp
@@ -11,11 +11,9 @@
 #include <memory>
 #include <vector>
 
-namespace tut
-{
+namespace tut {
 
-struct test_geometrycomponentfilter_data
-{
+struct test_geometrycomponentfilter_data {
     typedef geos::geom::Geometry::Ptr GeometryPtr; // owner
     typedef std::vector<geos::geom::Geometry const*> GeometryRefArray; // observer
 
@@ -40,17 +38,17 @@ group test_geometrycomponentfilter_group("geos::geom::GeometryComponentFilter");
 // Split components into two categories: Lineal and all other types
 template<>
 template<>
-void object::test<1>()
+void object::test<1>
+()
 {
     // collection of 4 geometries
     GeometryPtr g(reader.read("GEOMETRYCOLLECTION("
-        "POINT(0 0),"
-        "LINESTRING(0 0,1 1,1 2),"
-        "POLYGON((0 0,4 0,4 4,0 4,0 0)),"
-        "MULTILINESTRING((0 0,1 1,1 2),(2 3,3 2,5 4)))"));
+                              "POINT(0 0),"
+                              "LINESTRING(0 0,1 1,1 2),"
+                              "POLYGON((0 0,4 0,4 4,0 4,0 0)),"
+                              "MULTILINESTRING((0 0,1 1,1 2),(2 3,3 2,5 4)))"));
 
-    struct GeometryComponentSplitter : public geos::geom::GeometryComponentFilter
-    {
+    struct GeometryComponentSplitter : public geos::geom::GeometryComponentFilter {
         GeometryRefArray& lineal;
         GeometryRefArray& nonlineal;
         GeometryComponentSplitter(GeometryRefArray& p_lineal, GeometryRefArray& p_nonlineal)
@@ -59,14 +57,18 @@ void object::test<1>()
             ensure(lineal.empty());
             ensure(nonlineal.empty());
         }
-        void filter_ro(geos::geom::Geometry const* g) override
+        void
+        filter_ro(geos::geom::Geometry const* g) override
         {
-            if (dynamic_cast<geos::geom::Lineal const*>(g))
+            if(dynamic_cast<geos::geom::Lineal const*>(g)) {
                 lineal.push_back(g);
-            else
+            }
+            else {
                 nonlineal.push_back(g);
+            }
         }
-        void filter_rw(geos::geom::Geometry*) override {}
+        void
+        filter_rw(geos::geom::Geometry*) override {}
     };
 
     GeometryRefArray lineal;
diff --git a/tests/unit/geom/GeometryFactoryTest.cpp b/tests/unit/geom/GeometryFactoryTest.cpp
index bb127d8..7a8b041 100644
--- a/tests/unit/geom/GeometryFactoryTest.cpp
+++ b/tests/unit/geom/GeometryFactoryTest.cpp
@@ -38,1240 +38,1267 @@
  * \see
  * Separate items with the '|' character.
  */
-namespace tut
+namespace tut {
+//
+// Test Group
+//
+
+// Common data used by tests
+struct test_geometryfactory_data {
+    // Test data
+    const int x_;
+    const int y_;
+    const int z_;
+
+    const int srid_;
+    geos::geom::PrecisionModel pm_;
+    geos::geom::GeometryFactory::Ptr factory_;
+    geos::io::WKTReader reader_;
+
+    test_geometryfactory_data()
+        : x_(5), y_(10), z_(15), srid_(666), pm_(1.0),
+          factory_(geos::geom::GeometryFactory::create(&pm_, srid_)),
+          reader_(factory_.get())
+    {}
+private:
+    // Declare type as noncopyable
+    test_geometryfactory_data(const test_geometryfactory_data& other) = delete;
+    test_geometryfactory_data& operator=(const test_geometryfactory_data& rhs) = delete;
+};
+
+typedef test_group<test_geometryfactory_data> group;
+typedef group::object object;
+
+group test_geometryfactory_group("geos::geom::GeometryFactory");
+
+//
+// Test Cases
+//
+
+// Test of default constructor
+template<>
+template<>
+void object::test<1>
+()
+{
+    using geos::geom::GeometryFactory;
+    GeometryFactory::Ptr gf = GeometryFactory::create();
+
+    ensure_equals(gf->getSRID(), 0);
+    ensure_equals(gf->getPrecisionModel()->getType(), geos::geom::PrecisionModel::FLOATING);
+
+    geos::geom::Geometry* geo = gf->createEmptyGeometry();
+    ensure("createEmptyGeometry() returned null pointer.", geo != nullptr);
+    ensure_equals(geo->getSRID(), gf->getSRID());
+    ensure_equals(geo->getPrecisionModel()->getType(), geos::geom::PrecisionModel::FLOATING);
+
+    // FREE MEMORY
+    gf->destroyGeometry(geo);
+}
+
+// Test of user's constructor
+template<>
+template<>
+void object::test<2>
+()
 {
-	//
-	// Test Group
-	//
+    using geos::geom::GeometryFactory;
+    using geos::geom::PrecisionModel;
+    using geos::geom::CoordinateArraySequenceFactory;
+
+    CoordinateArraySequenceFactory csf;
 
-	// Common data used by tests
-    struct test_geometryfactory_data
     {
-        // Test data
-        const int x_;
-        const int y_;
-        const int z_;
-
-        const int srid_;
-        geos::geom::PrecisionModel pm_;
-        geos::geom::GeometryFactory::Ptr factory_;
-        geos::io::WKTReader reader_;
-
-        test_geometryfactory_data()
-            : x_(5), y_(10), z_(15), srid_(666), pm_(1.0),
-factory_(geos::geom::GeometryFactory::create(&pm_, srid_)),
-reader_(factory_.get())
-        {}
-    private:
-        // Declare type as noncopyable
-        test_geometryfactory_data(const test_geometryfactory_data& other) = delete;
-        test_geometryfactory_data& operator=(const test_geometryfactory_data& rhs) = delete;
-    };
-
-	typedef test_group<test_geometryfactory_data> group;
-	typedef group::object object;
-
-	group test_geometryfactory_group("geos::geom::GeometryFactory");
-
-	//
-	// Test Cases
-	//
-
-	// Test of default constructor
-	template<>
-	template<>
-	void object::test<1>()
-	{
-		using geos::geom::GeometryFactory;
-		GeometryFactory::Ptr gf = GeometryFactory::create();
-
-		ensure_equals( gf->getSRID(), 0 );
-		ensure_equals( gf->getPrecisionModel()->getType(), geos::geom::PrecisionModel::FLOATING );
-
-		geos::geom::Geometry* geo = gf->createEmptyGeometry();
-		ensure( "createEmptyGeometry() returned null pointer.", geo != nullptr );
-		ensure_equals( geo->getSRID() , gf->getSRID() );
-		ensure_equals( geo->getPrecisionModel()->getType(), geos::geom::PrecisionModel::FLOATING );
-
-		// FREE MEMORY
-		gf->destroyGeometry(geo);
-	}
-
-	// Test of user's constructor
-	template<>
-	template<>
-	void object::test<2>()
-	{
-		using geos::geom::GeometryFactory;
-		using geos::geom::PrecisionModel;
-		using geos::geom::CoordinateArraySequenceFactory;
-
-		CoordinateArraySequenceFactory csf;
-
-		{
-			PrecisionModel pm(1.0);
-			GeometryFactory::Ptr gf = GeometryFactory::create(&pm, srid_, &csf);
-
-			ensure_equals( gf->getSRID(), srid_ );
-			ensure_equals( gf->getPrecisionModel()->getType(), geos::geom::PrecisionModel::FIXED );
-
-			ensure_equals( &csf, gf->getCoordinateSequenceFactory() );
-
-			GeometryPtr geo = gf->createEmptyGeometry();
-			ensure( "createEmptyGeometry() returned null pointer.", geo != nullptr );
-			ensure_equals( geo->getSRID() , gf->getSRID() );
-			ensure_equals( geo->getPrecisionModel()->getType(), geos::geom::PrecisionModel::FIXED );
-
-			// FREE MEMORY
-			gf->destroyGeometry(geo);
-		}
-		// csf lifetime must exceed lifetime of the GeometryFactory instance
-
-	} // test<2>
-
-	// Test of user's constructor
-	template<>
-	template<>
-	void object::test<3>()
-	{
-		using geos::geom::GeometryFactory;
-		using geos::geom::CoordinateArraySequenceFactory;
-
-		CoordinateArraySequenceFactory csf;
-
-		{
-			GeometryFactory::Ptr gf = GeometryFactory::create(&csf);
-
-			ensure_equals( gf->getSRID(), 0 );
-			ensure_equals( gf->getPrecisionModel()->getType(), geos::geom::PrecisionModel::FLOATING );
-
-			GeometryPtr geo = gf->createEmptyGeometry();
-			ensure( "createEmptyGeometry() returned null pointer.", geo != nullptr );
-			ensure_equals( geo->getSRID() , gf->getSRID() );
-			ensure_equals( geo->getPrecisionModel()->getType(), geos::geom::PrecisionModel::FLOATING );
-
-			// FREE MEMORY
-			gf->destroyGeometry(geo);
-		}
-		// csf lifetime must exceed lifetime of the GeometryFactory instance
-	}
-
-	// Test of user's constructor
-	template<>
-	template<>
-	void object::test<4>()
-	{
-		using geos::geom::PrecisionModel;
-		using geos::geom::GeometryFactory;
-
-		PrecisionModel pm(PrecisionModel::FIXED);
-		GeometryFactory::Ptr gf(GeometryFactory::create(&pm));
-
-		ensure_equals( gf->getSRID(), 0 );
-		ensure_equals( gf->getPrecisionModel()->getType(), PrecisionModel::FIXED );
-
-		GeometryPtr geo = gf->createEmptyGeometry();
-		ensure( "createEmptyGeometry() returned null pointer.", geo != nullptr );
-		ensure_equals( geo->getSRID() , gf->getSRID() );
-		ensure_equals( geo->getPrecisionModel()->getType(), PrecisionModel::FIXED );
-
-		// FREE MEMORY
-		gf->destroyGeometry(geo);
-	}
-
-	// Test of user's constructor
-	template<>
-	template<>
-	void object::test<5>()
-	{
-		using geos::geom::PrecisionModel;
-		using geos::geom::GeometryFactory;
-
-		PrecisionModel pm(PrecisionModel::FIXED);
-		GeometryFactory::Ptr gf(GeometryFactory::create(&pm, srid_));
-
-		ensure_equals( gf->getSRID(), srid_ );
-		ensure_equals( gf->getPrecisionModel()->getType(), PrecisionModel::FIXED );
-
-		GeometryPtr geo = gf->createEmptyGeometry();
-		ensure( "createEmptyGeometry() returned null pointer.", geo != nullptr );
-		ensure_equals( geo->getSRID() , gf->getSRID() );
-		ensure_equals( geo->getPrecisionModel()->getType(), PrecisionModel::FIXED );
-
-		// FREE MEMORY
-		gf->destroyGeometry(geo);
-	}
-
-	// Test of copy constructor
-	template<>
-	template<>
-	void object::test<6>()
-	{
-		using geos::geom::GeometryFactory;
-		GeometryFactory::Ptr gf(GeometryFactory::create(*factory_));
-
-		ensure_equals( factory_->getSRID(), gf->getSRID() );
-		ensure_equals( factory_->getPrecisionModel()->getType(), gf->getPrecisionModel()->getType() );
-	}
-
-	// Test of createEmptyGeometry() const
-	template<>
-	template<>
-	void object::test<7>()
-	{
-		GeometryPtr geo = factory_->createEmptyGeometry();
-
-		ensure( "createEmptyGeometry() returned null pointer.", geo != nullptr );
-		ensure( "createEmptyGeometry() returned non-empty geometry.", geo->isEmpty() );
-
-		// TODO - mloskot
-		// http://geos.osgeo.org/pipermail/geos-devel/2006-March/001960.html
-		/*
-		ensure( geo->isSimple() );
-		ensure( geo->isValid() );
-
-		ensure( geo->getCentroid() == 0 );
-		ensure( geo->getCoordinate() == 0 );
-		*/
-
-		// FREE MEMORY
-		factory_->destroyGeometry(geo);
-	}
-
-	// Test of createPoint() const
-	template<>
-	template<>
-	void object::test<8>()
-	{
-		PointPtr pt = factory_->createPoint();
-
-		ensure( "createPoint() returned null pointer.", pt != nullptr );
-		ensure( "createPoint() returned non-empty point.", pt->isEmpty() );
-		ensure( pt->isSimple() );
-		ensure( pt->isValid() );
-		ensure( pt->getCentroid() == nullptr );
-		ensure( pt->getCoordinate() == nullptr );
-
-		GeometryPtr geo = nullptr;
-		geo = pt->getEnvelope();
-		ensure( geo != nullptr );
-		ensure( geo->isEmpty() );
-		factory_->destroyGeometry(geo);
-
-		geo = pt->getBoundary();
-		ensure( geo != nullptr );
-		ensure( geo->isEmpty() );
-		factory_->destroyGeometry(geo);
-
-		geo = pt->convexHull();
-		ensure( geo != nullptr );
-		ensure( geo->isEmpty() );
-		factory_->destroyGeometry(geo);
-
-		ensure_equals( pt->getGeometryTypeId(), geos::geom::GEOS_POINT );
-		ensure_equals( pt->getDimension(), geos::geom::Dimension::P );
-		ensure_equals( pt->getBoundaryDimension(), geos::geom::Dimension::False );
-		ensure_equals( pt->getNumPoints(), 0u );
-		ensure_equals( pt->getLength(), 0.0 );
-		ensure_equals( pt->getArea(), 0.0 );
-
-		// FREE MEMORY
-		factory_->destroyGeometry(pt);
-	}
-
-	// Test of createPoint(const Coordinate &coordinate) const
-	template<>
-	template<>
-	void object::test<9>()
-	{
-		geos::geom::Coordinate coord(x_, y_, z_);
-
-		PointPtr pt = factory_->createPoint(coord);
-
-		ensure( "createPoint() returned null pointer.", pt != nullptr );
-		ensure( "createPoint() returned empty point.", !pt->isEmpty() );
-		ensure( pt->isSimple() );
-		ensure( pt->isValid() );
-		ensure( pt->getCoordinate() != nullptr );
-
-		CoordinateCPtr pcoord = pt->getCoordinate();
-		ensure( pcoord != nullptr );
-		ensure_equals( pcoord->x, x_ );
-		ensure_equals( pcoord->y, y_ );
-		ensure_equals( pcoord->z, z_ );
-
-		GeometryPtr geo = nullptr;
-		geo = pt->getEnvelope();
-		ensure( geo != nullptr );
-		ensure( !geo->isEmpty() );
-		factory_->destroyGeometry(geo);
-
-		geo = pt->getCentroid();
-		ensure( geo != nullptr );
-		ensure( !geo->isEmpty() );
-		factory_->destroyGeometry(geo);
-
-		geo = pt->getBoundary();
-		ensure( geo != nullptr );
-		ensure( geo->isEmpty() );
-		factory_->destroyGeometry(geo);
-
-		geo = pt->convexHull();
-		ensure( geo != nullptr );
-		ensure( !geo->isEmpty() );
-		factory_->destroyGeometry(geo);
-
-		ensure_equals( pt->getGeometryTypeId(), geos::geom::GEOS_POINT );
-		ensure_equals( pt->getDimension(), geos::geom::Dimension::P );
-		ensure_equals( pt->getBoundaryDimension(), geos::geom::Dimension::False );
-		ensure_equals( pt->getNumPoints(), 1u );
-		ensure_equals( pt->getLength(), 0.0 );
-		ensure_equals( pt->getArea(), 0.0 );
-
-		// FREE MEMORY
-		factory_->destroyGeometry(pt);
-	}
-
-	// Test of createPoint(CoordinateSequence *coordinates) const
-	template<>
-	template<>
-	void object::test<10>()
-	{
-		geos::geom::Coordinate coord(x_, y_, z_);
-
-		CoordArrayPtr sequence = new geos::geom::CoordinateArraySequence();
-
-		ensure( "sequence is null pointer.", sequence != nullptr );
-		sequence->add(coord);
-
-		PointPtr pt = factory_->createPoint(sequence);
-
-		ensure( "createPoint() returned null pointer.", pt != nullptr );
-		ensure( "createPoint() returned empty point.", !pt->isEmpty() );
-		ensure( pt->isSimple() );
-		ensure( pt->isValid() );
-		ensure( pt->getCoordinate() != nullptr );
-
-		CoordinateCPtr pcoord = pt->getCoordinate();
-		ensure( pcoord != nullptr );
-		ensure_equals( pcoord->x, x_ );
-		ensure_equals( pcoord->y, y_ );
-		ensure_equals( pcoord->z, z_ );
-
-		GeometryPtr geo = nullptr;
-		geo = pt->getEnvelope();
-		ensure( geo != nullptr );
-		ensure( !geo->isEmpty() );
-		factory_->destroyGeometry(geo);
-
-		geo = pt->getCentroid();
-		ensure( geo != nullptr );
-		ensure( !geo->isEmpty() );
-		factory_->destroyGeometry(geo);
-
-		geo = pt->getBoundary();
-		ensure( geo != nullptr );
-		ensure( geo->isEmpty() );
-		factory_->destroyGeometry(geo);
-
-		geo = pt->convexHull();
-		ensure( geo != nullptr );
-		ensure( !geo->isEmpty() );
-		factory_->destroyGeometry(geo);
-
-		ensure_equals( pt->getGeometryTypeId(), geos::geom::GEOS_POINT );
-		ensure_equals( pt->getDimension(), geos::geom::Dimension::P );
-		ensure_equals( pt->getBoundaryDimension(), geos::geom::Dimension::False );
-		ensure_equals( pt->getNumPoints(), 1u );
-		ensure_equals( pt->getLength(), 0.0 );
-		ensure_equals( pt->getArea(), 0.0 );
-
-		// FREE MEMORY
-		factory_->destroyGeometry(pt);
-	}
-
-	// Test of createPoint(const CoordinateSequence &coordinates) const
-	template<>
-	template<>
-	void object::test<11>()
-	{
-		geos::geom::Coordinate coord(x_, y_, z_);
-
-		geos::geom::CoordinateArraySequence sequence;
-		sequence.add(coord);
-
-		PointPtr pt = factory_->createPoint(sequence);
-
-		ensure( "createPoint() returned null pointer.", pt != nullptr );
-		ensure( "createPoint() returned empty point.", !pt->isEmpty() );
-		ensure( pt->isSimple() );
-		ensure( pt->isValid() );
-		ensure( pt->getCoordinate() != nullptr );
-
-		CoordinateCPtr pcoord = pt->getCoordinate();
-		ensure( pcoord != nullptr );
-		ensure_equals( pcoord->x, x_ );
-		ensure_equals( pcoord->y, y_ );
-		ensure_equals( pcoord->z, z_ );
-
-		GeometryPtr geo = nullptr;
-		geo = pt->getEnvelope();
-		ensure( geo != nullptr );
-		ensure( !geo->isEmpty() );
-		factory_->destroyGeometry(geo);
-
-		geo = pt->getCentroid();
-		ensure( geo != nullptr );
-		ensure( !geo->isEmpty() );
-		factory_->destroyGeometry(geo);
-
-		geo = pt->getBoundary();
-		ensure( geo != nullptr );
-		ensure( geo->isEmpty() );
-		factory_->destroyGeometry(geo);
-
-		geo = pt->convexHull();
-		ensure( geo != nullptr );
-		ensure( !geo->isEmpty() );
-		factory_->destroyGeometry(geo);
-
-		ensure_equals( pt->getGeometryTypeId(), geos::geom::GEOS_POINT );
-		ensure_equals( pt->getDimension(), geos::geom::Dimension::P );
-		ensure_equals( pt->getBoundaryDimension(), geos::geom::Dimension::False );
-		ensure_equals( pt->getNumPoints(), 1u );
-		ensure_equals( pt->getLength(), 0.0 );
-		ensure_equals( pt->getArea(), 0.0 );
-
-		// FREE MEMORY
-		factory_->destroyGeometry(pt);
-	}
-
-	// Test of createLinearRing() const
-	template<>
-	template<>
-	void object::test<12>()
-	{
-		LinearRingPtr lr = factory_->createLinearRing();
-
-		ensure( "createLinearRing() returned null pointer.", lr != nullptr );
-		ensure( "createLinearRing() returned non-empty point.", lr->isEmpty() );
-		ensure( lr->isEmpty() );
-		ensure( lr->isSimple() );
-		ensure( lr->isValid() );
-		ensure( lr->getCoordinate() == nullptr );
-
-		// TODO - mloskot
-		//http://geos.osgeo.org/pipermail/geos-devel/2006-March/001961.html
-		//ensure( lr->isClosed() );
-
-		// TODO - mloskot
-		//http://geos.osgeo.org/pipermail/geos-devel/2006-March/001962.html
-		//ensure_equals( lr->getStartPoint(), lr->getEndPoint() );
-
-		ensure_equals( lr->getGeometryTypeId(), geos::geom::GEOS_LINEARRING );
-		ensure_equals( lr->getDimension(), geos::geom::Dimension::L );
-		ensure_equals( lr->getBoundaryDimension(), geos::geom::Dimension::False );
-		ensure_equals( lr->getNumPoints(), 0u );
-		ensure_equals( lr->getLength(), 0.0 );
-		ensure_equals( lr->getArea(), 0.0 );
-
-		// FREE MEMORY
-		factory_->destroyGeometry(lr);
-	}
-
-	// Test of createLinearRing(CoordinateSequence* newCoords) const
-	template<>
-	template<>
-	void object::test<13>()
-	{
-		const std::size_t size = 5;
-		CoordArrayPtr coords = new geos::geom::CoordinateArraySequence(size);
-		ensure( coords != nullptr );
-		ensure_equals( coords->getSize(), size );
-
-		LinearRingPtr lr = factory_->createLinearRing(coords);
-		ensure( "createLinearRing() returned null pointer.", lr != nullptr );
-		ensure( "createLinearRing() returned empty point.", !lr->isEmpty() );
-		ensure( lr->isSimple() );
-		ensure( lr->getCoordinate() != nullptr );
-
-		// TODO - mloskot - is this correct?
-		//ensure( !lr->isValid() );
-
-		ensure_equals( lr->getGeometryTypeId(), geos::geom::GEOS_LINEARRING );
-		ensure_equals( lr->getDimension(), geos::geom::Dimension::L );
-		ensure_equals( lr->getBoundaryDimension(), geos::geom::Dimension::False );
-		ensure_equals( lr->getNumPoints(), size );
-		ensure_equals( lr->getLength(), 0.0 );
-		ensure_equals( lr->getArea(), 0.0 );
-
-		// FREE MEMORY
-		factory_->destroyGeometry(lr);
-	}
-
-	// Test of createLinearRing(const CoordinateSequence& coordinates) const
-	template<>
-	template<>
-	void object::test<14>()
-	{
-		const std::size_t size = 5;
-		geos::geom::CoordinateArraySequence coords(size);
-		ensure_equals( coords.getSize(), size );
-
-		LinearRingPtr lr = factory_->createLinearRing(coords);
-		ensure( "createLinearRing() returned empty point.", !lr->isEmpty() );
-		ensure_equals( lr->getNumPoints(), size );
-		ensure( lr->isSimple() );
-		ensure( lr->getCoordinate() != nullptr );
-
-		ensure_equals( lr->getGeometryTypeId(), geos::geom::GEOS_LINEARRING );
-		ensure_equals( lr->getDimension(), geos::geom::Dimension::L );
-		ensure_equals( lr->getBoundaryDimension(), geos::geom::Dimension::False );
-		ensure_equals( lr->getNumPoints(), size );
-		ensure_equals( lr->getLength(), 0.0 );
-		ensure_equals( lr->getArea(), 0.0 );
-
-		// FREE MEMORY
-		factory_->destroyGeometry(lr);
-	}
-
-	// Test of createLineString() const
-	template<>
-	template<>
-	void object::test<15>()
-	{
-		LineStringPtr line = factory_->createLineString();
-
-		ensure( "createLineString() returned null pointer.", line != nullptr );
-		ensure( "createLineString() returned non-empty point.", line->isEmpty() );
-		ensure( line->isSimple() );
-		ensure( line->isValid() );
-		ensure( line->getCentroid() == nullptr );
-
-		// TODO - mloskot - waiting for some decision
-		// http://geos.osgeo.org/pipermail/geos-devel/2006-March/002006.html
-		//ensure( line->getCoordinate() == 0 );
-
-		GeometryPtr geo = nullptr;
-		geo = line->getEnvelope();
-		ensure( geo != nullptr );
-		ensure( geo->isEmpty() );
-		factory_->destroyGeometry(geo);
-
-		geo = line->getBoundary();
-		ensure( geo != nullptr );
-		ensure( geo->isEmpty() );
-		factory_->destroyGeometry(geo);
-
-		geo = line->convexHull();
-		ensure( geo != nullptr );
-		ensure( geo->isEmpty() );
-		factory_->destroyGeometry(geo);
-
-		ensure_equals( line->getGeometryTypeId(), geos::geom::GEOS_LINESTRING );
-		ensure_equals( line->getDimension(), geos::geom::Dimension::L );
-		ensure_equals( line->getBoundaryDimension(), geos::geom::Dimension::P ); // empty linestring
-		ensure_equals( line->getNumPoints(), 0u );
-		ensure_equals( line->getLength(), 0.0 );
-		ensure_equals( line->getArea(), 0.0 );
-
-		// FREE MEMORY
-		factory_->destroyGeometry(line);
-	}
-
-	// Test of createLineString(CoordinateSequence* coordinates) const
-	template<>
-	template<>
-	void object::test<16>()
-	{
-		const std::size_t size = 5;
-		CoordArrayPtr coords = new geos::geom::CoordinateArraySequence(size);
-		ensure( coords != nullptr );
-		ensure_equals( coords->getSize(), size );
-
-		LineStringPtr line = factory_->createLineString(coords);
-		ensure( "createLineString() returned null pointer.", line != nullptr );
-		ensure( "createLineString() returned empty point.", !line->isEmpty() );
-		ensure( line->isSimple() );
-		ensure( line->getCoordinate() != nullptr );
-
-		// TODO - mloskot - is this correct?
-		//ensure( line->isValid() );
-
-		ensure_equals( line->getGeometryTypeId(), geos::geom::GEOS_LINESTRING );
-		ensure_equals( line->getDimension(), geos::geom::Dimension::L );
-		ensure_equals( line->getBoundaryDimension(), geos::geom::Dimension::False );
-		ensure_equals( line->getNumPoints(), size );
-		ensure_equals( line->getLength(), 0.0 );
-		ensure_equals( line->getArea(), 0.0 );
-
-		// FREE MEMORY
-		factory_->destroyGeometry(line);
-	}
-
-	// Test of createLineString(const CoordinateSequence& coordinates) const
-	template<>
-	template<>
-	void object::test<17>()
-	{
-		const std::size_t size = 5;
-		geos::geom::CoordinateArraySequence coords(size);
-		ensure_equals( coords.getSize(), size );
-
-		LineStringPtr line = factory_->createLineString(coords);
-		ensure( "createLineString() returned empty point.", !line->isEmpty() );
-		ensure_equals( line->getNumPoints(), size );
-		ensure( line->isSimple() );
-		ensure( line->getCoordinate() != nullptr );
-
-		ensure_equals( line->getGeometryTypeId(), geos::geom::GEOS_LINESTRING );
-		ensure_equals( line->getDimension(), geos::geom::Dimension::L );
-		ensure_equals( line->getBoundaryDimension(), geos::geom::Dimension::False );
-		ensure_equals( line->getNumPoints(), size );
-		ensure_equals( line->getLength(), 0.0 );
-		ensure_equals( line->getArea(), 0.0 );
-
-		// FREE MEMORY
-		factory_->destroyGeometry(line);
-	}
-	// Test of createPolygon() const
-	template<>
-	template<>
-	void object::test<18>()
-	{
-		PolygonPtr poly = factory_->createPolygon();
-
-		ensure( "createPolygon() returned null pointer.", poly != nullptr );
-		ensure( "createPolygon() returned non-empty point.", poly->isEmpty() );
-		ensure( poly->isSimple() );
-		ensure( poly->isValid() );
-		ensure( poly->getCentroid() == nullptr );
-
-		// TODO - mloskot - waiting for some decision
-		// http://geos.osgeo.org/pipermail/geos-devel/2006-March/002006.html
-		//ensure( poly->getCoordinate() == 0 );
-
-		GeometryPtr geo = nullptr;
-		// TODO - mloskot - waiting for resolution
-		// http://geos.osgeo.org/pipermail/geos-devel/2006-March/002011.html
-		//geo = poly->getEnvelope();
-		//ensure( geo != 0 );
-		//ensure( geo->isEmpty() );
-		//factory_->destroyGeometry(geo);
-
-		geo = poly->getBoundary();
-		ensure( geo != nullptr );
-		ensure( geo->isEmpty() );
-		factory_->destroyGeometry(geo);
-
-		geo = poly->convexHull();
-		ensure( geo != nullptr );
-		ensure( geo->isEmpty() );
-		factory_->destroyGeometry(geo);
-
-		ensure_equals( poly->getGeometryTypeId(), geos::geom::GEOS_POLYGON );
-		ensure_equals( poly->getDimension(), geos::geom::Dimension::A );
-		ensure_equals( poly->getBoundaryDimension(), geos::geom::Dimension::L );
-		ensure_equals( poly->getNumPoints(), 0u );
-		ensure_equals( poly->getLength(), 0.0 );
-		ensure_equals( poly->getArea(), 0.0 );
-
-		// FREE MEMORY
-		factory_->destroyGeometry(poly);
-	}
-
-	// Test of createPolygon(LinearRing* shell, std::vector<Geometry*>* holes) const
-	template<>
-	template<>
-	void object::test<19>()
-	{
-		using geos::geom::Coordinate;
-		const std::size_t size = 7;
-
-		// Create sequence of coordiantes
-		CoordArrayPtr coords = new geos::geom::CoordinateArraySequence(size);
-		ensure( coords != nullptr );
-		coords->setAt(Coordinate(0, 10), 0);
-		coords->setAt(Coordinate(5, 5), 1);
-		coords->setAt(Coordinate(10, 5), 2);
-		coords->setAt(Coordinate(15, 10), 3);
-		coords->setAt(Coordinate(10, 15), 4);
-		coords->setAt(Coordinate(5, 15), 5);
-		coords->setAt(Coordinate(0, 10), 6);
-		ensure_equals( coords->getSize(), size );
-
-		// Create exterior ring
-		LinearRingPtr exterior = factory_->createLinearRing(coords);
-		ensure( "createLinearRing returned null pointer.", exterior != nullptr );
-		ensure( "createLinearRing() returned empty point.", !exterior->isEmpty() );
-		ensure( exterior->isSimple() );
-		ensure_equals( exterior->getGeometryTypeId(), geos::geom::GEOS_LINEARRING );
-		ensure_equals( exterior->getDimension(), geos::geom::Dimension::L );
-		ensure_equals( exterior->getBoundaryDimension(), geos::geom::Dimension::False );
-		ensure_equals( exterior->getNumPoints(), size );
-		ensure_equals( exterior->getArea(), 0.0 );
-		ensure( exterior->getLength() != 0.0 );
-
-		// Create polygon
-		PolygonPtr poly = factory_->createPolygon(exterior, nullptr);
-		ensure( "createPolygon returned null pointer.", poly != nullptr );
-		ensure( "createPolygon() returned empty point.", !poly->isEmpty() );
-		ensure( poly->isSimple() );
-		ensure_equals( poly->getGeometryTypeId(), geos::geom::GEOS_POLYGON );
-		ensure_equals( poly->getDimension(), geos::geom::Dimension::A );
-		ensure_equals( poly->getBoundaryDimension(), geos::geom::Dimension::L );
-		ensure_equals( poly->getNumPoints(), size );
-		ensure( poly->getArea() != 0.0 );
-		ensure( poly->getLength() != 0.0 );
-
-		// FREE MEMORY
-		factory_->destroyGeometry(poly);
-	}
-
-	// Test of createPolygon(const LinearRing& shell, const std::vector<Geometry*>& holes) const
-	template<>
-	template<>
-	void object::test<20>()
-	{
-		using geos::geom::Coordinate;
-		const std::size_t exteriorSize = 7;
-		const std::size_t interiorSize = 5;
-
-		// Create sequence of coordiantes
-		CoordArrayPtr coords = new geos::geom::CoordinateArraySequence(exteriorSize);
-		ensure( coords != nullptr );
-		coords->setAt(Coordinate(0, 10), 0);
-		coords->setAt(Coordinate(5, 5), 1);
-		coords->setAt(Coordinate(10, 5), 2);
-		coords->setAt(Coordinate(15, 10), 3);
-		coords->setAt(Coordinate(10, 15), 4);
-		coords->setAt(Coordinate(5, 15), 5);
-		coords->setAt(Coordinate(0, 10), 6);
-		ensure_equals( coords->getSize(), exteriorSize );
-
-		// Create exterior ring
-		LinearRingPtr exterior = factory_->createLinearRing(coords);
-		ensure( "createLinearRing returned null pointer.", exterior != nullptr );
-		ensure( "createLinearRing() returned empty point.", !exterior->isEmpty() );
-		ensure( exterior->isSimple() );
-		ensure_equals( exterior->getGeometryTypeId(), geos::geom::GEOS_LINEARRING );
-		ensure_equals( exterior->getDimension(), geos::geom::Dimension::L );
-		ensure_equals( exterior->getBoundaryDimension(), geos::geom::Dimension::False );
-		ensure_equals( exterior->getNumPoints(), exteriorSize );
-		ensure_equals( exterior->getArea(), 0.0 );
-		ensure( exterior->getLength() != 0.0 );
-
-		// Create collection of holes
-		GeometryPtr geo = reader_.read(("LINEARRING(7 7, 12 7, 12 12, 7 12, 7 7)"));
-		ensure( geo != nullptr );
-
-		LinearRingPtr hole = dynamic_cast<LinearRingPtr>(geo);
-		ensure( hole != nullptr );
-		ensure( hole->isRing() );
-		ensure_equals( hole->getNumPoints(), interiorSize );
-
-		// REMEMBER TO DEALLOCATE THIS COLLECTION
-		std::vector<GeometryPtr> holes;
-		holes.push_back(hole);
-
-		// Create polygon using copy ctor
-		PolygonPtr poly = factory_->createPolygon((*exterior), holes);
-		ensure( "createPolygon returned null pointer.", poly != nullptr );
-		ensure( "createPolygon() returned empty point.", !poly->isEmpty() );
-		ensure( poly->isSimple() );
-		ensure_equals( poly->getGeometryTypeId(), geos::geom::GEOS_POLYGON );
-		ensure_equals( poly->getDimension(), geos::geom::Dimension::A );
-		ensure_equals( poly->getBoundaryDimension(), geos::geom::Dimension::L );
-		ensure_equals( poly->getNumPoints(), exteriorSize + interiorSize );
-		ensure( poly->getArea() != 0.0 );
-		ensure( poly->getLength() != 0.0 );
-
-		ensure_equals( poly->getNumGeometries(), 1u );
-		ensure_equals( poly->getNumInteriorRing(), 1u );
-
-		// FREE MEMORY
-		std::vector<GeometryPtr>::const_iterator it;
-		for (it = holes.begin(); it != holes.end(); ++it)
-		{
-			delete (*it);
-		}
-		holes.clear();
-
-		factory_->destroyGeometry(exterior);
-		factory_->destroyGeometry(poly);
-	}
-
-	// Test of createGeometryCollection() const
-	template<>
-	template<>
-	void object::test<21>()
-	{
-		GeometryColPtr col = factory_->createGeometryCollection();
-
-		ensure( "createGeometryCollection() returned null pointer.", col != nullptr );
-		ensure( col->isEmpty() );
-		ensure( col->isValid() );
-		ensure( col->getCentroid() == nullptr );
-		ensure_equals( col->getGeometryTypeId(), geos::geom::GEOS_GEOMETRYCOLLECTION );
-		ensure_equals( col->getDimension(), geos::geom::Dimension::False );
-		ensure_equals( col->getBoundaryDimension(), geos::geom::Dimension::False );
-		ensure_equals( col->getNumPoints(), 0u );
-		ensure_equals( col->getLength(), 0.0 );
-		ensure_equals( col->getArea(), 0.0 );
-
-		// FREE MEMORY
-		factory_->destroyGeometry(col);
-	}
-
-	// Test of createGeometryCollection(std::vector<Geometry*>* newGeoms) const
-	template<>
-	template<>
-	void object::test<22>()
-	{
-		using geos::geom::Coordinate;
-
-		// Buffer for geometries
-		std::vector<GeometryPtr>* vec = new std::vector<GeometryPtr>();
-
-		// Add single point
-		Coordinate coord(x_, y_, z_);
-		GeometryPtr point = factory_->createPoint(coord);
-		ensure( point != nullptr );
-		vec->push_back(point);
-
-		// Add single LineString
-		CoordArrayPtr coords = new geos::geom::CoordinateArraySequence(3);
-		ensure( coords != nullptr );
-		coords->setAt(Coordinate(0, 0), 0);
-		coords->setAt(Coordinate(5, 5), 1);
-		coords->setAt(Coordinate(10, 5), 2);
-		ensure_equals( coords->getSize(), 3u );
-		GeometryPtr line = factory_->createLineString(coords);
-		vec->push_back(line);
-
-		// Create geometry collection
-		GeometryColPtr col = factory_->createGeometryCollection(vec);
-		ensure( coords != nullptr );
-		ensure_equals( col->getGeometryTypeId(), geos::geom::GEOS_GEOMETRYCOLLECTION );
-		ensure_equals( col->getNumGeometries(), 2u );
-
-		// FREE MEMORY
-		factory_->destroyGeometry(col);
-	}
-
-	// Test of createGeometryCollection(const std::vector<Geometry*>& newGeoms) const
-	template<>
-	template<>
-	void object::test<23>()
-	{
-		const std::size_t size = 3;
-		geos::geom::Coordinate coord(x_, y_, z_);
-
-		std::vector<GeometryPtr> vec;
-
-		GeometryPtr geo = nullptr;
-		geo = factory_->createPoint(coord);
-		vec.push_back(geo);
-
-		coord.x *= 2;
-		coord.y *= 2;
-		coord.z *= 2;
-		geo = factory_->createPoint(coord);
-		vec.push_back(geo);
-
-		coord.x *= 3;
-		coord.y *= 3;
-		coord.z *= 3;
-		geo = factory_->createPoint(coord);
-		vec.push_back(geo);
-
-		// Factory creates copy of the vec collection
-		GeometryColPtr col = factory_->createGeometryCollection(vec);
-		ensure( col != nullptr );
-		ensure_equals( col->getGeometryTypeId() , geos::geom::GEOS_GEOMETRYCOLLECTION );
-		ensure_equals( col->getNumGeometries() , size );
-
-		// FREE MEMORY
-		factory_->destroyGeometry(col);
-		std::vector<GeometryPtr>::const_iterator it;
-		for (it = vec.begin(); it != vec.end(); ++it)
-		{
-			delete (*it);
-		}
-	}
-
-	// Test of createMultiPoint() const
-	template<>
-	template<>
-	void object::test<24>()
-	{
-		MultiPointPtr mp = factory_->createMultiPoint();
-
-		ensure( "createMultiPoint() returned null pointer.", mp != nullptr );
-		ensure( "createMultiPoint() returned non-empty point.", mp->isEmpty() );
-		ensure( mp->isSimple() );
-		ensure( mp->isValid() );
-		ensure( mp->getCentroid() == nullptr );
-
-		GeometryPtr geo = nullptr;
-
-		// TODO - mloskot - waiting for resolution
-		// http://geos.osgeo.org/pipermail/geos-devel/2006-March/002011.html
-		//geo = poly->getEnvelope();
-		//ensure( geo != 0 );
-		//ensure( geo->isEmpty() );
-		//factory_->destroyGeometry(geo);
-
-		geo = mp->getBoundary();
-		ensure( geo != nullptr );
-		ensure( geo->isEmpty() );
-		factory_->destroyGeometry(geo);
-
-		geo = mp->convexHull();
-		ensure( geo != nullptr );
-		ensure( geo->isEmpty() );
-		factory_->destroyGeometry(geo);
-
-		ensure_equals( mp->getGeometryTypeId(), geos::geom::GEOS_MULTIPOINT );
-		ensure_equals( mp->getDimension(), geos::geom::Dimension::P );
-		ensure_equals( mp->getBoundaryDimension(), geos::geom::Dimension::False );
-		ensure_equals( mp->getNumPoints(), 0u );
-		ensure_equals( mp->getLength(), 0.0 );
-		ensure_equals( mp->getArea(), 0.0 );
-
-		// FREE MEMORY
-		factory_->destroyGeometry(mp);
-	}
-
-	// Test of createMultiPoint(std::vector<Geometry*>* newPoints) const
-	template<>
-	template<>
-	void object::test<25>()
-	{
-		const std::size_t size = 3;
-		geos::geom::Coordinate coord(x_, y_, z_);
-
-		std::vector<GeometryPtr>* vec = new std::vector<GeometryPtr>();
-
-		GeometryPtr geo = nullptr;
-		geo = factory_->createPoint(coord);
-		ensure( geo != nullptr );
-		vec->push_back(geo);
-
-		coord.x *= 2;
-		coord.y *= 2;
-		coord.z *= 2;
-		geo = factory_->createPoint(coord);
-		ensure( geo != nullptr );
-		vec->push_back(geo);
-
-		coord.x *= 3;
-		coord.y *= 3;
-		coord.z *= 3;
-		geo = factory_->createPoint(coord);
-		ensure( geo != nullptr );
-		vec->push_back(geo);
-
-		// Factory creates copy of the vec collection
-		MultiPointPtr mp = factory_->createMultiPoint(vec);
-		ensure( mp != nullptr );
-		ensure( mp->isValid() );
-		ensure( mp->isSimple() );
-		ensure_equals( mp->getNumGeometries(), size );
-		ensure_equals( mp->getGeometryTypeId(), geos::geom::GEOS_MULTIPOINT );
-
-		// FREE MEMORY
-		factory_->destroyGeometry(mp);
-	}
-
-	// Test of createMultiPoint(const std::vector<Geometry*>& fromPoints) const
-	template<>
-	template<>
-	void object::test<26>()
-	{
-		const std::size_t size = 3;
-		geos::geom::Coordinate coord(x_, y_, z_);
-
-		std::vector<GeometryPtr> vec;
-
-		GeometryPtr geo = nullptr;
-		geo = factory_->createPoint(coord);
-		vec.push_back(geo);
-
-		coord.x *= 2;
-		coord.y *= 2;
-		coord.z *= 2;
-		geo = factory_->createPoint(coord);
-		vec.push_back(geo);
-
-		coord.x *= 3;
-		coord.y *= 3;
-		coord.z *= 3;
-		geo = factory_->createPoint(coord);
-		vec.push_back(geo);
-
-		// Factory creates copy of the vec collection
-		MultiPointPtr mp = factory_->createMultiPoint(vec);
-		ensure( mp != nullptr );
-		ensure( mp->isValid() );
-		ensure( mp->isSimple() );
-		ensure_equals( mp->getNumGeometries(), size );
-		ensure_equals( mp->getGeometryTypeId(), geos::geom::GEOS_MULTIPOINT );
-
-		// FREE MEMORY
-		factory_->destroyGeometry(mp);
-		std::vector<GeometryPtr>::const_iterator it;
-		for (it = vec.begin(); it != vec.end(); ++it)
-		{
-			delete (*it);
-		}
-	}
-
-	// Test of createMultiPoint(const CoordinateSequence& fromCoords) const
-	template<>
-	template<>
-	void object::test<27>()
-	{
-		using geos::geom::Coordinate;
-		const std::size_t size = 3;
-
-		// Add collection of coordinates
-		geos::geom::CoordinateArraySequence coords(size);
-		coords.setAt(Coordinate(0, 0), 0);
-		coords.setAt(Coordinate(5, 5), 1);
-		coords.setAt(Coordinate(10, 5), 2);
-		ensure_equals( coords.getSize(), size );
-
-		MultiPointPtr mp = factory_->createMultiPoint(coords);
-		ensure( mp != nullptr );
-		ensure( mp->isValid() );
-		ensure( mp->isSimple() );
-		ensure_equals( mp->getNumGeometries(), size );
-		ensure_equals( mp->getGeometryTypeId(), geos::geom::GEOS_MULTIPOINT );
-
-		// FREE MEMORY
-		factory_->destroyGeometry(mp);
-	}
-
-	// Test of createMultiLineString() const
-	template<>
-	template<>
-	void object::test<28>()
-	{
-		MultiLineStringPtr mls = factory_->createMultiLineString();
-
-		ensure( "createMultiLineString() returned null pointer.", mls != nullptr );
-		ensure( "createMultiLineString() returned non-empty point.", mls->isEmpty() );
-		ensure( mls->isSimple() );
-		ensure( mls->isValid() );
-		ensure( mls->getCentroid() == nullptr );
-
-		GeometryPtr geo = nullptr;
-
-		// TODO - mloskot - waiting for resolution
-		// http://geos.osgeo.org/pipermail/geos-devel/2006-March/002011.html
-		//geo = poly->getEnvelope();
-		//ensure( geo != 0 );
-		//ensure( geo->isEmpty() );
-		//factory_->destroyGeometry(geo);
-
-		geo = mls->getBoundary();
-		ensure( geo != nullptr );
-		ensure( geo->isEmpty() );
-		factory_->destroyGeometry(geo);
-
-		geo = mls->convexHull();
-		ensure( geo != nullptr );
-		ensure( geo->isEmpty() );
-		factory_->destroyGeometry(geo);
-
-		ensure_equals( mls->getGeometryTypeId(), geos::geom::GEOS_MULTILINESTRING );
-		ensure_equals( mls->getDimension(), geos::geom::Dimension::L );
-		ensure_equals( mls->getBoundaryDimension(), geos::geom::Dimension::P );
-		ensure_equals( mls->getNumPoints(), 0u );
-		ensure_equals( mls->getLength(), 0.0 );
-		ensure_equals( mls->getArea(), 0.0 );
-
-		// FREE MEMORY
-		factory_->destroyGeometry(mls);
-	}
-
-	// Test of createMultiLineString(std::vector<Geometry*>* newLines) const
-	template<>
-	template<>
-	void object::test<29>()
-	{
-		using geos::geom::Coordinate;
-
-		const std::size_t size = 5;
-		const std::size_t lineSize = 2;
-
-		std::vector<GeometryPtr>* lines = new std::vector<GeometryPtr>();
-
-		for (std::size_t i = 0; i < size; ++i)
-		{
-			const double factor = static_cast<double>(i * i);
-			CoordArrayPtr coords = new geos::geom::CoordinateArraySequence(lineSize);
-			ensure( coords != nullptr );
-			coords->setAt(Coordinate(0. + factor, 0. + factor), 0);
-			coords->setAt(Coordinate(5. + factor, 5. + factor), 1);
-			ensure_equals( coords->getSize(), lineSize );
-
-			LineStringPtr line = factory_->createLineString(coords);
-			ensure( "createLineString() returned empty point.", !line->isEmpty() );
-			ensure_equals( line->getNumPoints(), lineSize );
-			ensure( line->isSimple() );
-			ensure( line->getCoordinate() != nullptr );
-			ensure_equals( line->getGeometryTypeId(), geos::geom::GEOS_LINESTRING );
-
-			lines->push_back(line);
-		}
-
-		MultiLineStringPtr mls = factory_->createMultiLineString(lines);
-		ensure( mls != nullptr );
-		// TODO - mloskot - why isValid() returns false?
-		//ensure( mls->isValid() );
-		ensure_equals( mls->getNumGeometries(), size );
-		ensure_equals( mls->getGeometryTypeId(), geos::geom::GEOS_MULTILINESTRING );
-
-		// FREE MEMORY
-		factory_->destroyGeometry(mls);
-	}
-
-	// Test of createMultiLineString(const std::vector<Geometry*>& fromLines) const
-	template<>
-	template<>
-	void object::test<30>()
-	{
-		using geos::geom::Coordinate;
-
-		const std::size_t size = 5;
-		const std::size_t lineSize = 2;
-
-		std::vector<GeometryPtr> lines;
-
-		for (std::size_t i = 0; i < size; ++i)
-		{
-			const double factor = static_cast<double>(i * i);
-			CoordArrayPtr coords = new geos::geom::CoordinateArraySequence(lineSize);
-			ensure( coords != nullptr );
-			coords->setAt(Coordinate(0. + factor, 0. + factor), 0);
-			coords->setAt(Coordinate(5. + factor, 5. + factor), 1);
-			ensure_equals( coords->getSize(), lineSize );
-
-			LineStringPtr line = factory_->createLineString(coords);
-			ensure( "createLineString() returned empty point.", !line->isEmpty() );
-			ensure_equals( line->getNumPoints(), lineSize );
-			ensure( line->isSimple() );
-			ensure( line->getCoordinate() != nullptr );
-			ensure_equals( line->getGeometryTypeId(), geos::geom::GEOS_LINESTRING );
-
-			lines.push_back(line);
-		}
-
-		MultiLineStringPtr mls = factory_->createMultiLineString(lines);
-		ensure( mls != nullptr );
-		// TODO - mloskot - why isValid() returns false?
-		//ensure( mls->isValid() );
-		ensure_equals( mls->getNumGeometries(), size );
-		ensure_equals( mls->getGeometryTypeId(), geos::geom::GEOS_MULTILINESTRING );
-
-		// FREE MEMORY
-		factory_->destroyGeometry(mls);
-		std::vector<GeometryPtr>::const_iterator it;
-		for (it = lines.begin(); it != lines.end(); ++it)
-		{
-			delete (*it);
-		}
-	}
-
-	// Test of createMultiPolygon() const
-	template<>
-	template<>
-	void object::test<31>()
-	{
-		// TODO - mloskot
-		//inform("Test not implemented!");
-	}
-
-	// Test of createMultiPolygon(std::vector<Geometry>* newPolys) const
-	template<>
-	template<>
-	void object::test<32>()
-	{
-		// TODO - mloskot
-		//inform("Test not implemented!");
-	}
-
-	// Test of createMultiPolygon(const std::vector<Geometry*>& fromPolys) const
-	template<>
-	template<>
-	void object::test<33>()
-	{
-		// TODO - mloskot
-		//inform("Test not implemented!");
-	}
-
-	// Test of buildGeometry(std::vector<Geometry*>* geoms) const
-	template<>
-	template<>
-	void object::test<34>()
-	{
-		// TODO - mloskot
-		//inform("Test not implemented!");
-	}
-
-	// Test of buildGeometry(const std::vector<Geometry*>& geoms)
-	template<>
-	template<>
-	void object::test<35>()
-	{
-		// TODO - mloskot
-		//inform("Test not implemented!");
-	}
-
-	// Test of
-  // buildGeometry(from, to, takeOwnership) const
-	template<>
-	template<>
-	void object::test<36>()
-	{
+        PrecisionModel pm(1.0);
+        GeometryFactory::Ptr gf = GeometryFactory::create(&pm, srid_, &csf);
+
+        ensure_equals(gf->getSRID(), srid_);
+        ensure_equals(gf->getPrecisionModel()->getType(), geos::geom::PrecisionModel::FIXED);
+
+        ensure_equals(&csf, gf->getCoordinateSequenceFactory());
+
+        GeometryPtr geo = gf->createEmptyGeometry();
+        ensure("createEmptyGeometry() returned null pointer.", geo != nullptr);
+        ensure_equals(geo->getSRID(), gf->getSRID());
+        ensure_equals(geo->getPrecisionModel()->getType(), geos::geom::PrecisionModel::FIXED);
+
+        // FREE MEMORY
+        gf->destroyGeometry(geo);
+    }
+    // csf lifetime must exceed lifetime of the GeometryFactory instance
+
+} // test<2>
+
+// Test of user's constructor
+template<>
+template<>
+void object::test<3>
+()
+{
+    using geos::geom::GeometryFactory;
+    using geos::geom::CoordinateArraySequenceFactory;
+
+    CoordinateArraySequenceFactory csf;
+
+    {
+        GeometryFactory::Ptr gf = GeometryFactory::create(&csf);
+
+        ensure_equals(gf->getSRID(), 0);
+        ensure_equals(gf->getPrecisionModel()->getType(), geos::geom::PrecisionModel::FLOATING);
+
+        GeometryPtr geo = gf->createEmptyGeometry();
+        ensure("createEmptyGeometry() returned null pointer.", geo != nullptr);
+        ensure_equals(geo->getSRID(), gf->getSRID());
+        ensure_equals(geo->getPrecisionModel()->getType(), geos::geom::PrecisionModel::FLOATING);
+
+        // FREE MEMORY
+        gf->destroyGeometry(geo);
+    }
+    // csf lifetime must exceed lifetime of the GeometryFactory instance
+}
+
+// Test of user's constructor
+template<>
+template<>
+void object::test<4>
+()
+{
+    using geos::geom::PrecisionModel;
+    using geos::geom::GeometryFactory;
+
+    PrecisionModel pm(PrecisionModel::FIXED);
+    GeometryFactory::Ptr gf(GeometryFactory::create(&pm));
+
+    ensure_equals(gf->getSRID(), 0);
+    ensure_equals(gf->getPrecisionModel()->getType(), PrecisionModel::FIXED);
+
+    GeometryPtr geo = gf->createEmptyGeometry();
+    ensure("createEmptyGeometry() returned null pointer.", geo != nullptr);
+    ensure_equals(geo->getSRID(), gf->getSRID());
+    ensure_equals(geo->getPrecisionModel()->getType(), PrecisionModel::FIXED);
+
+    // FREE MEMORY
+    gf->destroyGeometry(geo);
+}
+
+// Test of user's constructor
+template<>
+template<>
+void object::test<5>
+()
+{
+    using geos::geom::PrecisionModel;
+    using geos::geom::GeometryFactory;
+
+    PrecisionModel pm(PrecisionModel::FIXED);
+    GeometryFactory::Ptr gf(GeometryFactory::create(&pm, srid_));
+
+    ensure_equals(gf->getSRID(), srid_);
+    ensure_equals(gf->getPrecisionModel()->getType(), PrecisionModel::FIXED);
+
+    GeometryPtr geo = gf->createEmptyGeometry();
+    ensure("createEmptyGeometry() returned null pointer.", geo != nullptr);
+    ensure_equals(geo->getSRID(), gf->getSRID());
+    ensure_equals(geo->getPrecisionModel()->getType(), PrecisionModel::FIXED);
+
+    // FREE MEMORY
+    gf->destroyGeometry(geo);
+}
+
+// Test of copy constructor
+template<>
+template<>
+void object::test<6>
+()
+{
+    using geos::geom::GeometryFactory;
+    GeometryFactory::Ptr gf(GeometryFactory::create(*factory_));
+
+    ensure_equals(factory_->getSRID(), gf->getSRID());
+    ensure_equals(factory_->getPrecisionModel()->getType(), gf->getPrecisionModel()->getType());
+}
+
+// Test of createEmptyGeometry() const
+template<>
+template<>
+void object::test<7>
+()
+{
+    GeometryPtr geo = factory_->createEmptyGeometry();
+
+    ensure("createEmptyGeometry() returned null pointer.", geo != nullptr);
+    ensure("createEmptyGeometry() returned non-empty geometry.", geo->isEmpty());
+
+    // TODO - mloskot
+    // http://geos.osgeo.org/pipermail/geos-devel/2006-March/001960.html
+    /*
+    ensure( geo->isSimple() );
+    ensure( geo->isValid() );
+
+    ensure( geo->getCentroid() == 0 );
+    ensure( geo->getCoordinate() == 0 );
+    */
+
+    // FREE MEMORY
+    factory_->destroyGeometry(geo);
+}
+
+// Test of createPoint() const
+template<>
+template<>
+void object::test<8>
+()
+{
+    PointPtr pt = factory_->createPoint();
+
+    ensure("createPoint() returned null pointer.", pt != nullptr);
+    ensure("createPoint() returned non-empty point.", pt->isEmpty());
+    ensure(pt->isSimple());
+    ensure(pt->isValid());
+    ensure(pt->getCentroid() == nullptr);
+    ensure(pt->getCoordinate() == nullptr);
+
+    GeometryPtr geo = nullptr;
+    geo = pt->getEnvelope();
+    ensure(geo != nullptr);
+    ensure(geo->isEmpty());
+    factory_->destroyGeometry(geo);
+
+    geo = pt->getBoundary();
+    ensure(geo != nullptr);
+    ensure(geo->isEmpty());
+    factory_->destroyGeometry(geo);
+
+    geo = pt->convexHull();
+    ensure(geo != nullptr);
+    ensure(geo->isEmpty());
+    factory_->destroyGeometry(geo);
+
+    ensure_equals(pt->getGeometryTypeId(), geos::geom::GEOS_POINT);
+    ensure_equals(pt->getDimension(), geos::geom::Dimension::P);
+    ensure_equals(pt->getBoundaryDimension(), geos::geom::Dimension::False);
+    ensure_equals(pt->getNumPoints(), 0u);
+    ensure_equals(pt->getLength(), 0.0);
+    ensure_equals(pt->getArea(), 0.0);
+
+    // FREE MEMORY
+    factory_->destroyGeometry(pt);
+}
+
+// Test of createPoint(const Coordinate &coordinate) const
+template<>
+template<>
+void object::test<9>
+()
+{
+    geos::geom::Coordinate coord(x_, y_, z_);
+
+    PointPtr pt = factory_->createPoint(coord);
+
+    ensure("createPoint() returned null pointer.", pt != nullptr);
+    ensure("createPoint() returned empty point.", !pt->isEmpty());
+    ensure(pt->isSimple());
+    ensure(pt->isValid());
+    ensure(pt->getCoordinate() != nullptr);
+
+    CoordinateCPtr pcoord = pt->getCoordinate();
+    ensure(pcoord != nullptr);
+    ensure_equals(pcoord->x, x_);
+    ensure_equals(pcoord->y, y_);
+    ensure_equals(pcoord->z, z_);
+
+    GeometryPtr geo = nullptr;
+    geo = pt->getEnvelope();
+    ensure(geo != nullptr);
+    ensure(!geo->isEmpty());
+    factory_->destroyGeometry(geo);
+
+    geo = pt->getCentroid();
+    ensure(geo != nullptr);
+    ensure(!geo->isEmpty());
+    factory_->destroyGeometry(geo);
+
+    geo = pt->getBoundary();
+    ensure(geo != nullptr);
+    ensure(geo->isEmpty());
+    factory_->destroyGeometry(geo);
+
+    geo = pt->convexHull();
+    ensure(geo != nullptr);
+    ensure(!geo->isEmpty());
+    factory_->destroyGeometry(geo);
+
+    ensure_equals(pt->getGeometryTypeId(), geos::geom::GEOS_POINT);
+    ensure_equals(pt->getDimension(), geos::geom::Dimension::P);
+    ensure_equals(pt->getBoundaryDimension(), geos::geom::Dimension::False);
+    ensure_equals(pt->getNumPoints(), 1u);
+    ensure_equals(pt->getLength(), 0.0);
+    ensure_equals(pt->getArea(), 0.0);
+
+    // FREE MEMORY
+    factory_->destroyGeometry(pt);
+}
+
+// Test of createPoint(CoordinateSequence *coordinates) const
+template<>
+template<>
+void object::test<10>
+()
+{
+    geos::geom::Coordinate coord(x_, y_, z_);
+
+    CoordArrayPtr sequence = new geos::geom::CoordinateArraySequence();
+
+    ensure("sequence is null pointer.", sequence != nullptr);
+    sequence->add(coord);
+
+    PointPtr pt = factory_->createPoint(sequence);
+
+    ensure("createPoint() returned null pointer.", pt != nullptr);
+    ensure("createPoint() returned empty point.", !pt->isEmpty());
+    ensure(pt->isSimple());
+    ensure(pt->isValid());
+    ensure(pt->getCoordinate() != nullptr);
+
+    CoordinateCPtr pcoord = pt->getCoordinate();
+    ensure(pcoord != nullptr);
+    ensure_equals(pcoord->x, x_);
+    ensure_equals(pcoord->y, y_);
+    ensure_equals(pcoord->z, z_);
+
+    GeometryPtr geo = nullptr;
+    geo = pt->getEnvelope();
+    ensure(geo != nullptr);
+    ensure(!geo->isEmpty());
+    factory_->destroyGeometry(geo);
+
+    geo = pt->getCentroid();
+    ensure(geo != nullptr);
+    ensure(!geo->isEmpty());
+    factory_->destroyGeometry(geo);
+
+    geo = pt->getBoundary();
+    ensure(geo != nullptr);
+    ensure(geo->isEmpty());
+    factory_->destroyGeometry(geo);
+
+    geo = pt->convexHull();
+    ensure(geo != nullptr);
+    ensure(!geo->isEmpty());
+    factory_->destroyGeometry(geo);
+
+    ensure_equals(pt->getGeometryTypeId(), geos::geom::GEOS_POINT);
+    ensure_equals(pt->getDimension(), geos::geom::Dimension::P);
+    ensure_equals(pt->getBoundaryDimension(), geos::geom::Dimension::False);
+    ensure_equals(pt->getNumPoints(), 1u);
+    ensure_equals(pt->getLength(), 0.0);
+    ensure_equals(pt->getArea(), 0.0);
+
+    // FREE MEMORY
+    factory_->destroyGeometry(pt);
+}
+
+// Test of createPoint(const CoordinateSequence &coordinates) const
+template<>
+template<>
+void object::test<11>
+()
+{
+    geos::geom::Coordinate coord(x_, y_, z_);
+
+    geos::geom::CoordinateArraySequence sequence;
+    sequence.add(coord);
+
+    PointPtr pt = factory_->createPoint(sequence);
+
+    ensure("createPoint() returned null pointer.", pt != nullptr);
+    ensure("createPoint() returned empty point.", !pt->isEmpty());
+    ensure(pt->isSimple());
+    ensure(pt->isValid());
+    ensure(pt->getCoordinate() != nullptr);
+
+    CoordinateCPtr pcoord = pt->getCoordinate();
+    ensure(pcoord != nullptr);
+    ensure_equals(pcoord->x, x_);
+    ensure_equals(pcoord->y, y_);
+    ensure_equals(pcoord->z, z_);
+
+    GeometryPtr geo = nullptr;
+    geo = pt->getEnvelope();
+    ensure(geo != nullptr);
+    ensure(!geo->isEmpty());
+    factory_->destroyGeometry(geo);
+
+    geo = pt->getCentroid();
+    ensure(geo != nullptr);
+    ensure(!geo->isEmpty());
+    factory_->destroyGeometry(geo);
+
+    geo = pt->getBoundary();
+    ensure(geo != nullptr);
+    ensure(geo->isEmpty());
+    factory_->destroyGeometry(geo);
+
+    geo = pt->convexHull();
+    ensure(geo != nullptr);
+    ensure(!geo->isEmpty());
+    factory_->destroyGeometry(geo);
+
+    ensure_equals(pt->getGeometryTypeId(), geos::geom::GEOS_POINT);
+    ensure_equals(pt->getDimension(), geos::geom::Dimension::P);
+    ensure_equals(pt->getBoundaryDimension(), geos::geom::Dimension::False);
+    ensure_equals(pt->getNumPoints(), 1u);
+    ensure_equals(pt->getLength(), 0.0);
+    ensure_equals(pt->getArea(), 0.0);
+
+    // FREE MEMORY
+    factory_->destroyGeometry(pt);
+}
+
+// Test of createLinearRing() const
+template<>
+template<>
+void object::test<12>
+()
+{
+    LinearRingPtr lr = factory_->createLinearRing();
+
+    ensure("createLinearRing() returned null pointer.", lr != nullptr);
+    ensure("createLinearRing() returned non-empty point.", lr->isEmpty());
+    ensure(lr->isEmpty());
+    ensure(lr->isSimple());
+    ensure(lr->isValid());
+    ensure(lr->getCoordinate() == nullptr);
+
+    // TODO - mloskot
+    //http://geos.osgeo.org/pipermail/geos-devel/2006-March/001961.html
+    //ensure( lr->isClosed() );
+
+    // TODO - mloskot
+    //http://geos.osgeo.org/pipermail/geos-devel/2006-March/001962.html
+    //ensure_equals( lr->getStartPoint(), lr->getEndPoint() );
+
+    ensure_equals(lr->getGeometryTypeId(), geos::geom::GEOS_LINEARRING);
+    ensure_equals(lr->getDimension(), geos::geom::Dimension::L);
+    ensure_equals(lr->getBoundaryDimension(), geos::geom::Dimension::False);
+    ensure_equals(lr->getNumPoints(), 0u);
+    ensure_equals(lr->getLength(), 0.0);
+    ensure_equals(lr->getArea(), 0.0);
+
+    // FREE MEMORY
+    factory_->destroyGeometry(lr);
+}
+
+// Test of createLinearRing(CoordinateSequence* newCoords) const
+template<>
+template<>
+void object::test<13>
+()
+{
+    const std::size_t size = 5;
+    CoordArrayPtr coords = new geos::geom::CoordinateArraySequence(size);
+    ensure(coords != nullptr);
+    ensure_equals(coords->getSize(), size);
+
+    LinearRingPtr lr = factory_->createLinearRing(coords);
+    ensure("createLinearRing() returned null pointer.", lr != nullptr);
+    ensure("createLinearRing() returned empty point.", !lr->isEmpty());
+    ensure(lr->isSimple());
+    ensure(lr->getCoordinate() != nullptr);
+
+    // TODO - mloskot - is this correct?
+    //ensure( !lr->isValid() );
+
+    ensure_equals(lr->getGeometryTypeId(), geos::geom::GEOS_LINEARRING);
+    ensure_equals(lr->getDimension(), geos::geom::Dimension::L);
+    ensure_equals(lr->getBoundaryDimension(), geos::geom::Dimension::False);
+    ensure_equals(lr->getNumPoints(), size);
+    ensure_equals(lr->getLength(), 0.0);
+    ensure_equals(lr->getArea(), 0.0);
+
+    // FREE MEMORY
+    factory_->destroyGeometry(lr);
+}
+
+// Test of createLinearRing(const CoordinateSequence& coordinates) const
+template<>
+template<>
+void object::test<14>
+()
+{
+    const std::size_t size = 5;
+    geos::geom::CoordinateArraySequence coords(size);
+    ensure_equals(coords.getSize(), size);
+
+    LinearRingPtr lr = factory_->createLinearRing(coords);
+    ensure("createLinearRing() returned empty point.", !lr->isEmpty());
+    ensure_equals(lr->getNumPoints(), size);
+    ensure(lr->isSimple());
+    ensure(lr->getCoordinate() != nullptr);
+
+    ensure_equals(lr->getGeometryTypeId(), geos::geom::GEOS_LINEARRING);
+    ensure_equals(lr->getDimension(), geos::geom::Dimension::L);
+    ensure_equals(lr->getBoundaryDimension(), geos::geom::Dimension::False);
+    ensure_equals(lr->getNumPoints(), size);
+    ensure_equals(lr->getLength(), 0.0);
+    ensure_equals(lr->getArea(), 0.0);
+
+    // FREE MEMORY
+    factory_->destroyGeometry(lr);
+}
+
+// Test of createLineString() const
+template<>
+template<>
+void object::test<15>
+()
+{
+    LineStringPtr line = factory_->createLineString();
+
+    ensure("createLineString() returned null pointer.", line != nullptr);
+    ensure("createLineString() returned non-empty point.", line->isEmpty());
+    ensure(line->isSimple());
+    ensure(line->isValid());
+    ensure(line->getCentroid() == nullptr);
+
+    // TODO - mloskot - waiting for some decision
+    // http://geos.osgeo.org/pipermail/geos-devel/2006-March/002006.html
+    //ensure( line->getCoordinate() == 0 );
+
+    GeometryPtr geo = nullptr;
+    geo = line->getEnvelope();
+    ensure(geo != nullptr);
+    ensure(geo->isEmpty());
+    factory_->destroyGeometry(geo);
+
+    geo = line->getBoundary();
+    ensure(geo != nullptr);
+    ensure(geo->isEmpty());
+    factory_->destroyGeometry(geo);
+
+    geo = line->convexHull();
+    ensure(geo != nullptr);
+    ensure(geo->isEmpty());
+    factory_->destroyGeometry(geo);
+
+    ensure_equals(line->getGeometryTypeId(), geos::geom::GEOS_LINESTRING);
+    ensure_equals(line->getDimension(), geos::geom::Dimension::L);
+    ensure_equals(line->getBoundaryDimension(), geos::geom::Dimension::P);   // empty linestring
+    ensure_equals(line->getNumPoints(), 0u);
+    ensure_equals(line->getLength(), 0.0);
+    ensure_equals(line->getArea(), 0.0);
+
+    // FREE MEMORY
+    factory_->destroyGeometry(line);
+}
+
+// Test of createLineString(CoordinateSequence* coordinates) const
+template<>
+template<>
+void object::test<16>
+()
+{
+    const std::size_t size = 5;
+    CoordArrayPtr coords = new geos::geom::CoordinateArraySequence(size);
+    ensure(coords != nullptr);
+    ensure_equals(coords->getSize(), size);
+
+    LineStringPtr line = factory_->createLineString(coords);
+    ensure("createLineString() returned null pointer.", line != nullptr);
+    ensure("createLineString() returned empty point.", !line->isEmpty());
+    ensure(line->isSimple());
+    ensure(line->getCoordinate() != nullptr);
+
+    // TODO - mloskot - is this correct?
+    //ensure( line->isValid() );
+
+    ensure_equals(line->getGeometryTypeId(), geos::geom::GEOS_LINESTRING);
+    ensure_equals(line->getDimension(), geos::geom::Dimension::L);
+    ensure_equals(line->getBoundaryDimension(), geos::geom::Dimension::False);
+    ensure_equals(line->getNumPoints(), size);
+    ensure_equals(line->getLength(), 0.0);
+    ensure_equals(line->getArea(), 0.0);
+
+    // FREE MEMORY
+    factory_->destroyGeometry(line);
+}
+
+// Test of createLineString(const CoordinateSequence& coordinates) const
+template<>
+template<>
+void object::test<17>
+()
+{
+    const std::size_t size = 5;
+    geos::geom::CoordinateArraySequence coords(size);
+    ensure_equals(coords.getSize(), size);
+
+    LineStringPtr line = factory_->createLineString(coords);
+    ensure("createLineString() returned empty point.", !line->isEmpty());
+    ensure_equals(line->getNumPoints(), size);
+    ensure(line->isSimple());
+    ensure(line->getCoordinate() != nullptr);
+
+    ensure_equals(line->getGeometryTypeId(), geos::geom::GEOS_LINESTRING);
+    ensure_equals(line->getDimension(), geos::geom::Dimension::L);
+    ensure_equals(line->getBoundaryDimension(), geos::geom::Dimension::False);
+    ensure_equals(line->getNumPoints(), size);
+    ensure_equals(line->getLength(), 0.0);
+    ensure_equals(line->getArea(), 0.0);
+
+    // FREE MEMORY
+    factory_->destroyGeometry(line);
+}
+// Test of createPolygon() const
+template<>
+template<>
+void object::test<18>
+()
+{
+    PolygonPtr poly = factory_->createPolygon();
+
+    ensure("createPolygon() returned null pointer.", poly != nullptr);
+    ensure("createPolygon() returned non-empty point.", poly->isEmpty());
+    ensure(poly->isSimple());
+    ensure(poly->isValid());
+    ensure(poly->getCentroid() == nullptr);
+
+    // TODO - mloskot - waiting for some decision
+    // http://geos.osgeo.org/pipermail/geos-devel/2006-March/002006.html
+    //ensure( poly->getCoordinate() == 0 );
+
+    GeometryPtr geo = nullptr;
+    // TODO - mloskot - waiting for resolution
+    // http://geos.osgeo.org/pipermail/geos-devel/2006-March/002011.html
+    //geo = poly->getEnvelope();
+    //ensure( geo != 0 );
+    //ensure( geo->isEmpty() );
+    //factory_->destroyGeometry(geo);
+
+    geo = poly->getBoundary();
+    ensure(geo != nullptr);
+    ensure(geo->isEmpty());
+    factory_->destroyGeometry(geo);
+
+    geo = poly->convexHull();
+    ensure(geo != nullptr);
+    ensure(geo->isEmpty());
+    factory_->destroyGeometry(geo);
+
+    ensure_equals(poly->getGeometryTypeId(), geos::geom::GEOS_POLYGON);
+    ensure_equals(poly->getDimension(), geos::geom::Dimension::A);
+    ensure_equals(poly->getBoundaryDimension(), geos::geom::Dimension::L);
+    ensure_equals(poly->getNumPoints(), 0u);
+    ensure_equals(poly->getLength(), 0.0);
+    ensure_equals(poly->getArea(), 0.0);
+
+    // FREE MEMORY
+    factory_->destroyGeometry(poly);
+}
+
+// Test of createPolygon(LinearRing* shell, std::vector<Geometry*>* holes) const
+template<>
+template<>
+void object::test<19>
+()
+{
+    using geos::geom::Coordinate;
+    const std::size_t size = 7;
+
+    // Create sequence of coordiantes
+    CoordArrayPtr coords = new geos::geom::CoordinateArraySequence(size);
+    ensure(coords != nullptr);
+    coords->setAt(Coordinate(0, 10), 0);
+    coords->setAt(Coordinate(5, 5), 1);
+    coords->setAt(Coordinate(10, 5), 2);
+    coords->setAt(Coordinate(15, 10), 3);
+    coords->setAt(Coordinate(10, 15), 4);
+    coords->setAt(Coordinate(5, 15), 5);
+    coords->setAt(Coordinate(0, 10), 6);
+    ensure_equals(coords->getSize(), size);
+
+    // Create exterior ring
+    LinearRingPtr exterior = factory_->createLinearRing(coords);
+    ensure("createLinearRing returned null pointer.", exterior != nullptr);
+    ensure("createLinearRing() returned empty point.", !exterior->isEmpty());
+    ensure(exterior->isSimple());
+    ensure_equals(exterior->getGeometryTypeId(), geos::geom::GEOS_LINEARRING);
+    ensure_equals(exterior->getDimension(), geos::geom::Dimension::L);
+    ensure_equals(exterior->getBoundaryDimension(), geos::geom::Dimension::False);
+    ensure_equals(exterior->getNumPoints(), size);
+    ensure_equals(exterior->getArea(), 0.0);
+    ensure(exterior->getLength() != 0.0);
+
+    // Create polygon
+    PolygonPtr poly = factory_->createPolygon(exterior, nullptr);
+    ensure("createPolygon returned null pointer.", poly != nullptr);
+    ensure("createPolygon() returned empty point.", !poly->isEmpty());
+    ensure(poly->isSimple());
+    ensure_equals(poly->getGeometryTypeId(), geos::geom::GEOS_POLYGON);
+    ensure_equals(poly->getDimension(), geos::geom::Dimension::A);
+    ensure_equals(poly->getBoundaryDimension(), geos::geom::Dimension::L);
+    ensure_equals(poly->getNumPoints(), size);
+    ensure(poly->getArea() != 0.0);
+    ensure(poly->getLength() != 0.0);
+
+    // FREE MEMORY
+    factory_->destroyGeometry(poly);
+}
+
+// Test of createPolygon(const LinearRing& shell, const std::vector<Geometry*>& holes) const
+template<>
+template<>
+void object::test<20>
+()
+{
+    using geos::geom::Coordinate;
+    const std::size_t exteriorSize = 7;
+    const std::size_t interiorSize = 5;
+
+    // Create sequence of coordiantes
+    CoordArrayPtr coords = new geos::geom::CoordinateArraySequence(exteriorSize);
+    ensure(coords != nullptr);
+    coords->setAt(Coordinate(0, 10), 0);
+    coords->setAt(Coordinate(5, 5), 1);
+    coords->setAt(Coordinate(10, 5), 2);
+    coords->setAt(Coordinate(15, 10), 3);
+    coords->setAt(Coordinate(10, 15), 4);
+    coords->setAt(Coordinate(5, 15), 5);
+    coords->setAt(Coordinate(0, 10), 6);
+    ensure_equals(coords->getSize(), exteriorSize);
+
+    // Create exterior ring
+    LinearRingPtr exterior = factory_->createLinearRing(coords);
+    ensure("createLinearRing returned null pointer.", exterior != nullptr);
+    ensure("createLinearRing() returned empty point.", !exterior->isEmpty());
+    ensure(exterior->isSimple());
+    ensure_equals(exterior->getGeometryTypeId(), geos::geom::GEOS_LINEARRING);
+    ensure_equals(exterior->getDimension(), geos::geom::Dimension::L);
+    ensure_equals(exterior->getBoundaryDimension(), geos::geom::Dimension::False);
+    ensure_equals(exterior->getNumPoints(), exteriorSize);
+    ensure_equals(exterior->getArea(), 0.0);
+    ensure(exterior->getLength() != 0.0);
+
+    // Create collection of holes
+    GeometryPtr geo = reader_.read(("LINEARRING(7 7, 12 7, 12 12, 7 12, 7 7)"));
+    ensure(geo != nullptr);
+
+    LinearRingPtr hole = dynamic_cast<LinearRingPtr>(geo);
+    ensure(hole != nullptr);
+    ensure(hole->isRing());
+    ensure_equals(hole->getNumPoints(), interiorSize);
+
+    // REMEMBER TO DEALLOCATE THIS COLLECTION
+    std::vector<GeometryPtr> holes;
+    holes.push_back(hole);
+
+    // Create polygon using copy ctor
+    PolygonPtr poly = factory_->createPolygon((*exterior), holes);
+    ensure("createPolygon returned null pointer.", poly != nullptr);
+    ensure("createPolygon() returned empty point.", !poly->isEmpty());
+    ensure(poly->isSimple());
+    ensure_equals(poly->getGeometryTypeId(), geos::geom::GEOS_POLYGON);
+    ensure_equals(poly->getDimension(), geos::geom::Dimension::A);
+    ensure_equals(poly->getBoundaryDimension(), geos::geom::Dimension::L);
+    ensure_equals(poly->getNumPoints(), exteriorSize + interiorSize);
+    ensure(poly->getArea() != 0.0);
+    ensure(poly->getLength() != 0.0);
+
+    ensure_equals(poly->getNumGeometries(), 1u);
+    ensure_equals(poly->getNumInteriorRing(), 1u);
+
+    // FREE MEMORY
+    std::vector<GeometryPtr>::const_iterator it;
+    for(it = holes.begin(); it != holes.end(); ++it) {
+        delete(*it);
+    }
+    holes.clear();
+
+    factory_->destroyGeometry(exterior);
+    factory_->destroyGeometry(poly);
+}
+
+// Test of createGeometryCollection() const
+template<>
+template<>
+void object::test<21>
+()
+{
+    GeometryColPtr col = factory_->createGeometryCollection();
+
+    ensure("createGeometryCollection() returned null pointer.", col != nullptr);
+    ensure(col->isEmpty());
+    ensure(col->isValid());
+    ensure(col->getCentroid() == nullptr);
+    ensure_equals(col->getGeometryTypeId(), geos::geom::GEOS_GEOMETRYCOLLECTION);
+    ensure_equals(col->getDimension(), geos::geom::Dimension::False);
+    ensure_equals(col->getBoundaryDimension(), geos::geom::Dimension::False);
+    ensure_equals(col->getNumPoints(), 0u);
+    ensure_equals(col->getLength(), 0.0);
+    ensure_equals(col->getArea(), 0.0);
+
+    // FREE MEMORY
+    factory_->destroyGeometry(col);
+}
+
+// Test of createGeometryCollection(std::vector<Geometry*>* newGeoms) const
+template<>
+template<>
+void object::test<22>
+()
+{
+    using geos::geom::Coordinate;
+
+    // Buffer for geometries
+    std::vector<GeometryPtr>* vec = new std::vector<GeometryPtr>();
+
+    // Add single point
+    Coordinate coord(x_, y_, z_);
+    GeometryPtr point = factory_->createPoint(coord);
+    ensure(point != nullptr);
+    vec->push_back(point);
+
+    // Add single LineString
+    CoordArrayPtr coords = new geos::geom::CoordinateArraySequence(3);
+    ensure(coords != nullptr);
+    coords->setAt(Coordinate(0, 0), 0);
+    coords->setAt(Coordinate(5, 5), 1);
+    coords->setAt(Coordinate(10, 5), 2);
+    ensure_equals(coords->getSize(), 3u);
+    GeometryPtr line = factory_->createLineString(coords);
+    vec->push_back(line);
+
+    // Create geometry collection
+    GeometryColPtr col = factory_->createGeometryCollection(vec);
+    ensure(coords != nullptr);
+    ensure_equals(col->getGeometryTypeId(), geos::geom::GEOS_GEOMETRYCOLLECTION);
+    ensure_equals(col->getNumGeometries(), 2u);
+
+    // FREE MEMORY
+    factory_->destroyGeometry(col);
+}
+
+// Test of createGeometryCollection(const std::vector<Geometry*>& newGeoms) const
+template<>
+template<>
+void object::test<23>
+()
+{
+    const std::size_t size = 3;
+    geos::geom::Coordinate coord(x_, y_, z_);
+
+    std::vector<GeometryPtr> vec;
+
+    GeometryPtr geo = nullptr;
+    geo = factory_->createPoint(coord);
+    vec.push_back(geo);
+
+    coord.x *= 2;
+    coord.y *= 2;
+    coord.z *= 2;
+    geo = factory_->createPoint(coord);
+    vec.push_back(geo);
+
+    coord.x *= 3;
+    coord.y *= 3;
+    coord.z *= 3;
+    geo = factory_->createPoint(coord);
+    vec.push_back(geo);
+
+    // Factory creates copy of the vec collection
+    GeometryColPtr col = factory_->createGeometryCollection(vec);
+    ensure(col != nullptr);
+    ensure_equals(col->getGeometryTypeId(), geos::geom::GEOS_GEOMETRYCOLLECTION);
+    ensure_equals(col->getNumGeometries(), size);
+
+    // FREE MEMORY
+    factory_->destroyGeometry(col);
+    std::vector<GeometryPtr>::const_iterator it;
+    for(it = vec.begin(); it != vec.end(); ++it) {
+        delete(*it);
+    }
+}
+
+// Test of createMultiPoint() const
+template<>
+template<>
+void object::test<24>
+()
+{
+    MultiPointPtr mp = factory_->createMultiPoint();
+
+    ensure("createMultiPoint() returned null pointer.", mp != nullptr);
+    ensure("createMultiPoint() returned non-empty point.", mp->isEmpty());
+    ensure(mp->isSimple());
+    ensure(mp->isValid());
+    ensure(mp->getCentroid() == nullptr);
+
+    GeometryPtr geo = nullptr;
+
+    // TODO - mloskot - waiting for resolution
+    // http://geos.osgeo.org/pipermail/geos-devel/2006-March/002011.html
+    //geo = poly->getEnvelope();
+    //ensure( geo != 0 );
+    //ensure( geo->isEmpty() );
+    //factory_->destroyGeometry(geo);
+
+    geo = mp->getBoundary();
+    ensure(geo != nullptr);
+    ensure(geo->isEmpty());
+    factory_->destroyGeometry(geo);
+
+    geo = mp->convexHull();
+    ensure(geo != nullptr);
+    ensure(geo->isEmpty());
+    factory_->destroyGeometry(geo);
+
+    ensure_equals(mp->getGeometryTypeId(), geos::geom::GEOS_MULTIPOINT);
+    ensure_equals(mp->getDimension(), geos::geom::Dimension::P);
+    ensure_equals(mp->getBoundaryDimension(), geos::geom::Dimension::False);
+    ensure_equals(mp->getNumPoints(), 0u);
+    ensure_equals(mp->getLength(), 0.0);
+    ensure_equals(mp->getArea(), 0.0);
+
+    // FREE MEMORY
+    factory_->destroyGeometry(mp);
+}
+
+// Test of createMultiPoint(std::vector<Geometry*>* newPoints) const
+template<>
+template<>
+void object::test<25>
+()
+{
+    const std::size_t size = 3;
+    geos::geom::Coordinate coord(x_, y_, z_);
+
+    std::vector<GeometryPtr>* vec = new std::vector<GeometryPtr>();
+
+    GeometryPtr geo = nullptr;
+    geo = factory_->createPoint(coord);
+    ensure(geo != nullptr);
+    vec->push_back(geo);
+
+    coord.x *= 2;
+    coord.y *= 2;
+    coord.z *= 2;
+    geo = factory_->createPoint(coord);
+    ensure(geo != nullptr);
+    vec->push_back(geo);
+
+    coord.x *= 3;
+    coord.y *= 3;
+    coord.z *= 3;
+    geo = factory_->createPoint(coord);
+    ensure(geo != nullptr);
+    vec->push_back(geo);
+
+    // Factory creates copy of the vec collection
+    MultiPointPtr mp = factory_->createMultiPoint(vec);
+    ensure(mp != nullptr);
+    ensure(mp->isValid());
+    ensure(mp->isSimple());
+    ensure_equals(mp->getNumGeometries(), size);
+    ensure_equals(mp->getGeometryTypeId(), geos::geom::GEOS_MULTIPOINT);
+
+    // FREE MEMORY
+    factory_->destroyGeometry(mp);
+}
+
+// Test of createMultiPoint(const std::vector<Geometry*>& fromPoints) const
+template<>
+template<>
+void object::test<26>
+()
+{
+    const std::size_t size = 3;
+    geos::geom::Coordinate coord(x_, y_, z_);
+
+    std::vector<GeometryPtr> vec;
+
+    GeometryPtr geo = nullptr;
+    geo = factory_->createPoint(coord);
+    vec.push_back(geo);
+
+    coord.x *= 2;
+    coord.y *= 2;
+    coord.z *= 2;
+    geo = factory_->createPoint(coord);
+    vec.push_back(geo);
+
+    coord.x *= 3;
+    coord.y *= 3;
+    coord.z *= 3;
+    geo = factory_->createPoint(coord);
+    vec.push_back(geo);
+
+    // Factory creates copy of the vec collection
+    MultiPointPtr mp = factory_->createMultiPoint(vec);
+    ensure(mp != nullptr);
+    ensure(mp->isValid());
+    ensure(mp->isSimple());
+    ensure_equals(mp->getNumGeometries(), size);
+    ensure_equals(mp->getGeometryTypeId(), geos::geom::GEOS_MULTIPOINT);
+
+    // FREE MEMORY
+    factory_->destroyGeometry(mp);
+    std::vector<GeometryPtr>::const_iterator it;
+    for(it = vec.begin(); it != vec.end(); ++it) {
+        delete(*it);
+    }
+}
+
+// Test of createMultiPoint(const CoordinateSequence& fromCoords) const
+template<>
+template<>
+void object::test<27>
+()
+{
+    using geos::geom::Coordinate;
+    const std::size_t size = 3;
+
+    // Add collection of coordinates
+    geos::geom::CoordinateArraySequence coords(size);
+    coords.setAt(Coordinate(0, 0), 0);
+    coords.setAt(Coordinate(5, 5), 1);
+    coords.setAt(Coordinate(10, 5), 2);
+    ensure_equals(coords.getSize(), size);
+
+    MultiPointPtr mp = factory_->createMultiPoint(coords);
+    ensure(mp != nullptr);
+    ensure(mp->isValid());
+    ensure(mp->isSimple());
+    ensure_equals(mp->getNumGeometries(), size);
+    ensure_equals(mp->getGeometryTypeId(), geos::geom::GEOS_MULTIPOINT);
+
+    // FREE MEMORY
+    factory_->destroyGeometry(mp);
+}
+
+// Test of createMultiLineString() const
+template<>
+template<>
+void object::test<28>
+()
+{
+    MultiLineStringPtr mls = factory_->createMultiLineString();
+
+    ensure("createMultiLineString() returned null pointer.", mls != nullptr);
+    ensure("createMultiLineString() returned non-empty point.", mls->isEmpty());
+    ensure(mls->isSimple());
+    ensure(mls->isValid());
+    ensure(mls->getCentroid() == nullptr);
+
+    GeometryPtr geo = nullptr;
+
+    // TODO - mloskot - waiting for resolution
+    // http://geos.osgeo.org/pipermail/geos-devel/2006-March/002011.html
+    //geo = poly->getEnvelope();
+    //ensure( geo != 0 );
+    //ensure( geo->isEmpty() );
+    //factory_->destroyGeometry(geo);
+
+    geo = mls->getBoundary();
+    ensure(geo != nullptr);
+    ensure(geo->isEmpty());
+    factory_->destroyGeometry(geo);
+
+    geo = mls->convexHull();
+    ensure(geo != nullptr);
+    ensure(geo->isEmpty());
+    factory_->destroyGeometry(geo);
+
+    ensure_equals(mls->getGeometryTypeId(), geos::geom::GEOS_MULTILINESTRING);
+    ensure_equals(mls->getDimension(), geos::geom::Dimension::L);
+    ensure_equals(mls->getBoundaryDimension(), geos::geom::Dimension::P);
+    ensure_equals(mls->getNumPoints(), 0u);
+    ensure_equals(mls->getLength(), 0.0);
+    ensure_equals(mls->getArea(), 0.0);
+
+    // FREE MEMORY
+    factory_->destroyGeometry(mls);
+}
+
+// Test of createMultiLineString(std::vector<Geometry*>* newLines) const
+template<>
+template<>
+void object::test<29>
+()
+{
+    using geos::geom::Coordinate;
+
+    const std::size_t size = 5;
+    const std::size_t lineSize = 2;
+
+    std::vector<GeometryPtr>* lines = new std::vector<GeometryPtr>();
+
+    for(std::size_t i = 0; i < size; ++i) {
+        const double factor = static_cast<double>(i * i);
+        CoordArrayPtr coords = new geos::geom::CoordinateArraySequence(lineSize);
+        ensure(coords != nullptr);
+        coords->setAt(Coordinate(0. + factor, 0. + factor), 0);
+        coords->setAt(Coordinate(5. + factor, 5. + factor), 1);
+        ensure_equals(coords->getSize(), lineSize);
+
+        LineStringPtr line = factory_->createLineString(coords);
+        ensure("createLineString() returned empty point.", !line->isEmpty());
+        ensure_equals(line->getNumPoints(), lineSize);
+        ensure(line->isSimple());
+        ensure(line->getCoordinate() != nullptr);
+        ensure_equals(line->getGeometryTypeId(), geos::geom::GEOS_LINESTRING);
+
+        lines->push_back(line);
+    }
+
+    MultiLineStringPtr mls = factory_->createMultiLineString(lines);
+    ensure(mls != nullptr);
+    // TODO - mloskot - why isValid() returns false?
+    //ensure( mls->isValid() );
+    ensure_equals(mls->getNumGeometries(), size);
+    ensure_equals(mls->getGeometryTypeId(), geos::geom::GEOS_MULTILINESTRING);
+
+    // FREE MEMORY
+    factory_->destroyGeometry(mls);
+}
+
+// Test of createMultiLineString(const std::vector<Geometry*>& fromLines) const
+template<>
+template<>
+void object::test<30>
+()
+{
+    using geos::geom::Coordinate;
+
+    const std::size_t size = 5;
+    const std::size_t lineSize = 2;
+
+    std::vector<GeometryPtr> lines;
+
+    for(std::size_t i = 0; i < size; ++i) {
+        const double factor = static_cast<double>(i * i);
+        CoordArrayPtr coords = new geos::geom::CoordinateArraySequence(lineSize);
+        ensure(coords != nullptr);
+        coords->setAt(Coordinate(0. + factor, 0. + factor), 0);
+        coords->setAt(Coordinate(5. + factor, 5. + factor), 1);
+        ensure_equals(coords->getSize(), lineSize);
+
+        LineStringPtr line = factory_->createLineString(coords);
+        ensure("createLineString() returned empty point.", !line->isEmpty());
+        ensure_equals(line->getNumPoints(), lineSize);
+        ensure(line->isSimple());
+        ensure(line->getCoordinate() != nullptr);
+        ensure_equals(line->getGeometryTypeId(), geos::geom::GEOS_LINESTRING);
+
+        lines.push_back(line);
+    }
+
+    MultiLineStringPtr mls = factory_->createMultiLineString(lines);
+    ensure(mls != nullptr);
+    // TODO - mloskot - why isValid() returns false?
+    //ensure( mls->isValid() );
+    ensure_equals(mls->getNumGeometries(), size);
+    ensure_equals(mls->getGeometryTypeId(), geos::geom::GEOS_MULTILINESTRING);
+
+    // FREE MEMORY
+    factory_->destroyGeometry(mls);
+    std::vector<GeometryPtr>::const_iterator it;
+    for(it = lines.begin(); it != lines.end(); ++it) {
+        delete(*it);
+    }
+}
+
+// Test of createMultiPolygon() const
+template<>
+template<>
+void object::test<31>
+()
+{
+    // TODO - mloskot
+    //inform("Test not implemented!");
+}
+
+// Test of createMultiPolygon(std::vector<Geometry>* newPolys) const
+template<>
+template<>
+void object::test<32>
+()
+{
+    // TODO - mloskot
+    //inform("Test not implemented!");
+}
+
+// Test of createMultiPolygon(const std::vector<Geometry*>& fromPolys) const
+template<>
+template<>
+void object::test<33>
+()
+{
+    // TODO - mloskot
+    //inform("Test not implemented!");
+}
+
+// Test of buildGeometry(std::vector<Geometry*>* geoms) const
+template<>
+template<>
+void object::test<34>
+()
+{
+    // TODO - mloskot
+    //inform("Test not implemented!");
+}
+
+// Test of buildGeometry(const std::vector<Geometry*>& geoms)
+template<>
+template<>
+void object::test<35>
+()
+{
+    // TODO - mloskot
+    //inform("Test not implemented!");
+}
+
+// Test of
+// buildGeometry(from, to, takeOwnership) const
+template<>
+template<>
+void object::test<36>
+()
+{
     typedef std::unique_ptr<geos::geom::Geometry> GeometryAutoPtr;
-		typedef std::vector<PointPtr> PointVect;
-
-		const std::size_t size = 3;
-		geos::geom::Coordinate coord(x_, y_, z_);
-
-		PointVect vec;
-
-		PointPtr geo = nullptr;
-		geo = factory_->createPoint(coord);
-		vec.push_back(geo);
-
-		coord.x *= 2;
-		coord.y *= 2;
-		coord.z *= 2;
-		geo = factory_->createPoint(coord);
-		vec.push_back(geo);
-
-		coord.x *= 3;
-		coord.y *= 3;
-		coord.z *= 3;
-		geo = factory_->createPoint(coord);
-		vec.push_back(geo);
-
-		// Factory creates copy of the vec collection
-		GeometryAutoPtr g = factory_->buildGeometry(vec.begin(), vec.end());
-		ensure( g.get() != nullptr );
-		ensure_equals( g->getGeometryTypeId(), geos::geom::GEOS_MULTIPOINT );
-		ensure_equals( g->getNumGeometries(), size );
-
-		// FREE MEMORY
-		PointVect::const_iterator it;
-		for (it = vec.begin(); it != vec.end(); ++it)
-		{
-			delete (*it);
-		}
-	}
+    typedef std::vector<PointPtr> PointVect;
+
+    const std::size_t size = 3;
+    geos::geom::Coordinate coord(x_, y_, z_);
+
+    PointVect vec;
+
+    PointPtr geo = nullptr;
+    geo = factory_->createPoint(coord);
+    vec.push_back(geo);
+
+    coord.x *= 2;
+    coord.y *= 2;
+    coord.z *= 2;
+    geo = factory_->createPoint(coord);
+    vec.push_back(geo);
+
+    coord.x *= 3;
+    coord.y *= 3;
+    coord.z *= 3;
+    geo = factory_->createPoint(coord);
+    vec.push_back(geo);
+
+    // Factory creates copy of the vec collection
+    GeometryAutoPtr g = factory_->buildGeometry(vec.begin(), vec.end());
+    ensure(g.get() != nullptr);
+    ensure_equals(g->getGeometryTypeId(), geos::geom::GEOS_MULTIPOINT);
+    ensure_equals(g->getNumGeometries(), size);
+
+    // FREE MEMORY
+    PointVect::const_iterator it;
+    for(it = vec.begin(); it != vec.end(); ++it) {
+        delete(*it);
+    }
+}
 
 } // namespace tut
diff --git a/tests/unit/geom/GeometryFilterTest.cpp b/tests/unit/geom/GeometryFilterTest.cpp
index 5f29260..ea2f434 100644
--- a/tests/unit/geom/GeometryFilterTest.cpp
+++ b/tests/unit/geom/GeometryFilterTest.cpp
@@ -11,11 +11,9 @@
 #include <memory>
 #include <vector>
 
-namespace tut
-{
+namespace tut {
 
-struct test_geometryfilter_data
-{
+struct test_geometryfilter_data {
     typedef geos::geom::Geometry::Ptr GeometryPtr; // owner
     typedef std::vector<geos::geom::Geometry const*> GeometryRefArray; // observer
 
@@ -40,17 +38,17 @@ group test_geometryfilter_group("geos::geom::GeometryFilter");
 // Split geometries into two categories: Lineal and all other types
 template<>
 template<>
-void object::test<1>()
+void object::test<1>
+()
 {
     // collection of 4 geometries
     GeometryPtr g(reader.read("GEOMETRYCOLLECTION("
-        "POINT(0 0),"
-        "LINESTRING(0 0,1 1,1 2),"
-        "POLYGON((0 0,4 0,4 4,0 4,0 0)),"
-        "MULTILINESTRING((0 0,1 1,1 2),(2 3,3 2,5 4)))"));
+                              "POINT(0 0),"
+                              "LINESTRING(0 0,1 1,1 2),"
+                              "POLYGON((0 0,4 0,4 4,0 4,0 0)),"
+                              "MULTILINESTRING((0 0,1 1,1 2),(2 3,3 2,5 4)))"));
 
-    struct GeometrySplitter : public geos::geom::GeometryFilter
-    {
+    struct GeometrySplitter : public geos::geom::GeometryFilter {
         GeometryRefArray& lineal;
         GeometryRefArray& nonlineal;
         GeometrySplitter(GeometryRefArray& p_lineal, GeometryRefArray& p_nonlineal)
@@ -59,14 +57,18 @@ void object::test<1>()
             ensure(lineal.empty());
             ensure(nonlineal.empty());
         }
-        void filter_ro(geos::geom::Geometry const* g) override
+        void
+        filter_ro(geos::geom::Geometry const* g) override
         {
-            if (dynamic_cast<geos::geom::Lineal const*>(g))
+            if(dynamic_cast<geos::geom::Lineal const*>(g)) {
                 lineal.push_back(g);
-            else
+            }
+            else {
                 nonlineal.push_back(g);
+            }
         }
-        void filter_rw(geos::geom::Geometry*) override {}
+        void
+        filter_rw(geos::geom::Geometry*) override {}
     };
 
     GeometryRefArray lineal;
diff --git a/tests/unit/geom/IntersectionMatrixTest.cpp b/tests/unit/geom/IntersectionMatrixTest.cpp
index 19b5c03..c6bdeae 100644
--- a/tests/unit/geom/IntersectionMatrixTest.cpp
+++ b/tests/unit/geom/IntersectionMatrixTest.cpp
@@ -10,535 +10,562 @@
 #include <string>
 #include <sstream>
 
-namespace tut
+namespace tut {
+//
+// Test Group
+//
+
+// Common data used by test cases
+struct test_intersectionmatrix_data {
+    typedef geos::geom::IntersectionMatrix* MatrixPtr;
+    typedef geos::geom::IntersectionMatrix const* MatrixCPtr;
+
+    const std::string pattern_false_;
+    geos::geom::IntersectionMatrix im_;
+
+    test_intersectionmatrix_data()
+        : pattern_false_("FFFFFFFFF"), im_(pattern_false_)
+    {}
+private:
+    // Declare type as noncopyable
+    test_intersectionmatrix_data(const test_intersectionmatrix_data& other) = delete;
+    test_intersectionmatrix_data& operator=(const test_intersectionmatrix_data& rhs) = delete;
+};
+
+typedef test_group<test_intersectionmatrix_data> group;
+typedef group::object object;
+
+group test_intersectionmatrix_group("geos::geom::IntersectionMatrix");
+
+//
+// Test Cases
+//
+
+// Test of default constructor
+template<>
+template<>
+void object::test<1>
+()
+{
+    ensure_equals(im_.toString(), pattern_false_);
+}
+
+// Test of user's constructor
+template<>
+template<>
+void object::test<2>
+()
+{
+    const std::string pattern("012*TF012");
+    geos::geom::IntersectionMatrix im(pattern);
+
+    ensure_equals(im.toString(), pattern);
+}
+
+// Test of copy constructor
+template<>
+template<>
+void object::test<3>
+()
+{
+    geos::geom::IntersectionMatrix copy(im_);
+
+    ensure_equals(copy.toString(), im_.toString());
+}
+
+// Test nr 2 of copy constructor
+template<>
+template<>
+void object::test<4>
+()
+{
+    const std::string pattern("012*TF012");
+    geos::geom::IntersectionMatrix examplar(pattern);
+
+    ensure_equals(examplar.toString(), pattern);
+
+    geos::geom::IntersectionMatrix copy(examplar);
+
+    ensure_equals(copy.toString(), examplar.toString());
+}
+
+// Test of matches(int actualDimensionValue, char requiredDimensionSymbol)
+template<>
+template<>
+void object::test<5>
+()
+{
+    const int dummyAny = 999;
+    ensure(im_.matches(dummyAny, '*'));
+
+    ensure(im_.matches(geos::geom::Dimension::P, '0'));
+
+    ensure(im_.matches(geos::geom::Dimension::True, 'T'));
+    ensure(!im_.matches(geos::geom::Dimension::False, 'T'));
+    ensure(!im_.matches(geos::geom::Dimension::DONTCARE, 'T'));
+}
+
+// Test of matches(const std::string& requiredDimensionSymbols)
+template<>
+template<>
+void object::test<6>
+()
+{
+    const std::string pattern("012*TF012");
+    ensure(im_.matches(pattern_false_));
+    ensure(!im_.matches(pattern));
+}
+
+// Test of matches(const std::string& actualDimensionSymbols,
+//				   const std::string& requiredDimensionSymbols)
+template<>
+template<>
+void object::test<7>
+()
+{
+    ensure(im_.matches(pattern_false_, pattern_false_));
+}
+
+// Test of matches(const std::string& actualDimensionSymbols,
+//				   const std::string& requiredDimensionSymbols)
+template<>
+template<>
+void object::test<8>
+()
+{
+    const std::string pattern("012*TF012");
+    ensure(!im_.matches(pattern_false_, pattern));
+}
+
+// Test of matches(const std::string& actualDimensionSymbols,
+//				   const std::string& requiredDimensionSymbols)
+template<>
+template<>
+void object::test<9>
+()
+{
+    const std::string pattern("012*TF012");
+    ensure(im_.matches(pattern, pattern));
+}
+
+// add(IntersectionMatrix *im)
+template<>
+template<>
+void object::test<10>
+()
+{
+    // Create local matrix
+    const std::string pattern("012*TF012");
+    geos::geom::IntersectionMatrix im_local(pattern);
+
+    ensure_equals(im_local.toString(), pattern);
+
+    // Add local matrix to the matrix with 'FFFFFFFFF' pattern
+    im_local.add(&im_);
+
+    // Check pattern of local matrix after addition
+    const std::string pattern_result("012FFF012");
+    ensure_equals(im_local.toString(), pattern_result);
+    ensure(im_local.matches(pattern_result));
+}
+
+
+// Test of set(int row, int column, int dimensionValue);
+template<>
+template<>
+void object::test<11>
+()
 {
-    //
-    // Test Group
-    //
-
-    // Common data used by test cases
-    struct test_intersectionmatrix_data
-    {
-        typedef geos::geom::IntersectionMatrix* MatrixPtr;
-        typedef geos::geom::IntersectionMatrix const* MatrixCPtr;
-
-        const std::string pattern_false_;
-        geos::geom::IntersectionMatrix im_;
-
-        test_intersectionmatrix_data()
-            : pattern_false_("FFFFFFFFF"),im_(pattern_false_)
-        {}
-    private:
-        // Declare type as noncopyable
-        test_intersectionmatrix_data(const test_intersectionmatrix_data& other) = delete;
-        test_intersectionmatrix_data& operator=(const test_intersectionmatrix_data& rhs) = delete;
-    };
-
-    typedef test_group<test_intersectionmatrix_data> group;
-    typedef group::object object;
-
-    group test_intersectionmatrix_group("geos::geom::IntersectionMatrix");
-
-    //
-    // Test Cases
-    //
-
-    // Test of default constructor
-    template<>
-    template<>
-    void object::test<1>()
-    {
-		ensure_equals( im_.toString(), pattern_false_ );
-	}
-
-    // Test of user's constructor
-    template<>
-    template<>
-    void object::test<2>()
-	{
-		const std::string pattern("012*TF012");
-		geos::geom::IntersectionMatrix im(pattern);
-
-		ensure_equals( im.toString(), pattern );
-	}
-
-    // Test of copy constructor
-    template<>
-    template<>
-    void object::test<3>()
-	{
-		geos::geom::IntersectionMatrix copy(im_);
-
-		ensure_equals( copy.toString(), im_.toString() );
-	}
-
-    // Test nr 2 of copy constructor
-    template<>
-    template<>
-	void object::test<4>()
-	{
-		const std::string pattern("012*TF012");
-		geos::geom::IntersectionMatrix examplar(pattern);
-
-		ensure_equals( examplar.toString(), pattern );
-
-		geos::geom::IntersectionMatrix copy(examplar);
-
-		ensure_equals( copy.toString(), examplar.toString() );
-	}
-
-	// Test of matches(int actualDimensionValue, char requiredDimensionSymbol)
-    template<>
-    template<>
-	void object::test<5>()
-	{
-		const int dummyAny = 999;
-		ensure( im_.matches(dummyAny, '*') );
-
-		ensure( im_.matches(geos::geom::Dimension::P, '0') );
-
-		ensure( im_.matches(geos::geom::Dimension::True , 'T') );
-		ensure( !im_.matches(geos::geom::Dimension::False , 'T') );
-		ensure( !im_.matches(geos::geom::Dimension::DONTCARE , 'T') );
-	}
-
-	// Test of matches(const std::string& requiredDimensionSymbols)
-    template<>
-    template<>
-	void object::test<6>()
-	{
-		const std::string pattern("012*TF012");
-		ensure( im_.matches(pattern_false_) );
-		ensure( !im_.matches(pattern) );
-	}
-
-	// Test of matches(const std::string& actualDimensionSymbols,
-	//				   const std::string& requiredDimensionSymbols)
-    template<>
-    template<>
-	void object::test<7>()
-	{
-		ensure( im_.matches(pattern_false_, pattern_false_) );
-	}
-
-	// Test of matches(const std::string& actualDimensionSymbols,
-	//				   const std::string& requiredDimensionSymbols)
-	template<>
-	template<>
-	void object::test<8>()
-	{
-		const std::string pattern("012*TF012");
-		ensure( !im_.matches(pattern_false_, pattern) );
-	}
-
-	// Test of matches(const std::string& actualDimensionSymbols,
-	//				   const std::string& requiredDimensionSymbols)
-	template<>
-	template<>
-	void object::test<9>()
-	{
-		const std::string pattern("012*TF012");
-		ensure( im_.matches(pattern, pattern) );
-	}
-
-	// add(IntersectionMatrix *im)
-    template<>
-    template<>
-	void object::test<10>()
-	{
-		// Create local matrix
-		const std::string pattern("012*TF012");
-		geos::geom::IntersectionMatrix im_local(pattern);
-
-		ensure_equals( im_local.toString(), pattern );
-
-		// Add local matrix to the matrix with 'FFFFFFFFF' pattern
-		im_local.add(&im_);
-
-		// Check pattern of local matrix after addition
-		const std::string pattern_result("012FFF012");
-		ensure_equals( im_local.toString(), pattern_result );
-		ensure( im_local.matches(pattern_result) );
-	}
-
-
-	// Test of set(int row, int column, int dimensionValue);
-    template<>
-    template<>
-	void object::test<11>()
-	{
-		// 'im_' is initialized with 'FFFFFFFFF'
-		ensure_equals( im_.toString(), pattern_false_);
-
-		// Do some changes and checks
-		im_.set(0, 0, geos::geom::Dimension::P);
-
-		ensure_equals( im_.toString(), "0FFFFFFFF" );
-
-	}
-
-	// Test of set(const std::string& dimensionSymbols);
-    template<>
-    template<>
-	void object::test<12>()
-	{
-		// 'im_' is initialized with 'FFFFFFFFF'
-		ensure_equals( im_.toString(), pattern_false_);
-
-		const std::string pattern("012*TF012");
-		im_.set(pattern);
-
-		ensure_equals( im_.toString(), pattern);
-	}
-
-	// Test of setAll(int dimensionValue);
-    template<>
-    template<>
-	void object::test<13>()
-	{
-		// 'im_' is initialized with 'FFFFFFFFF'
-		ensure_equals( im_.toString(), pattern_false_);
-
-		const std::string pattern("000000000");
-		im_.setAll(geos::geom::Dimension::P);
-
-		ensure_equals( im_.toString(), pattern);
-	}
-
-	// Test of setAtLeast(std::string minimumDimensionSymbols)
-    template<>
-    template<>
-	void object::test<14>()
-	{
-		// 'im_' is initialized with 'FFFFFFFFF'
-		ensure_equals( im_.toString(), pattern_false_);
-
-		// 1. No change expected
-		im_.setAtLeast(pattern_false_);
-		ensure_equals( im_.toString(), pattern_false_);
-
-		// 2. Set new pattern
-		const std::string pattern_new("FT*012FT*");
-		const std::string pattern_expected("FFF012FFF");
-
-		im_.setAtLeast(pattern_new);
-		ensure( im_.toString() != pattern_false_);
-		ensure_equals( im_.toString(), pattern_expected);
-
-		// 3. Set old pattern, no change expected
-		im_.setAtLeast(pattern_false_);
-		ensure_equals( im_.toString(), pattern_expected);
-	}
-
-	// Test of setAtLeast(int row, int column, int minimumDimensionValue);
-    template<>
-    template<>
-	void object::test<15>()
-	{
-		// 'im_' is initialized with 'FFFFFFFFF'
-		ensure_equals( im_.toString(), pattern_false_);
-
-		// 1. No change expected
-		im_.setAtLeast(0, 0, geos::geom::Dimension::False);
-		ensure_equals( im_.toString(), pattern_false_);
-
-		// 2. Change is expected
-		im_.setAtLeast(0, 0, geos::geom::Dimension::A);
-		ensure_equals( im_.toString(), "2FFFFFFFF");
-	}
-
-
-	// Test of setAtLeastIfValid(int row, int column, int minimumDimensionValue)
-	template<>
-	template<>
-	void object::test<16>()
-	{
-		// 'im_' is initialized with 'FFFFFFFFF'
-		ensure_equals( im_.toString(), pattern_false_);
-
-		// 1. No change expected
-		im_.setAtLeast(0, 0, geos::geom::Dimension::A);
-		ensure( im_.toString() != pattern_false_);
-		ensure_equals( im_.get(0, 0), geos::geom::Dimension::A);
-	}
-
-	// Test of get(int row, int column)
-    template<>
-    template<>
-	void object::test<17>()
-	{
-		// Test on the original pattern 'FFFFFFFFF' of the 'im_' object
-		ensure_equals( im_.toString(), pattern_false_);
-		ensure_equals( im_.get(0, 0), geos::geom::Dimension::False );
-
-		// Change first value and test again
- 		im_.setAtLeast(0, 0, geos::geom::Dimension::A);
-		ensure_equals( im_.get(0, 0), geos::geom::Dimension::A );
-
-		// Change last value and test again
-		im_.setAtLeast(2, 2, geos::geom::Dimension::L);
-		ensure_equals( im_.get(2, 2), geos::geom::Dimension::L );
-	}
-
-
-	// Test of isContains()
-    template<>
-    template<>
-	void object::test<18>()
-	{
-		// Test on the FALSE matrix
-		ensure_equals( im_.toString(),  pattern_false_);
-		ensure( !im_.isContains() );
-
-		// 1. Test 'minimum' version of 'contains' matrix
-		const std::string pattern_minimum("T*****FF*");
-		geos::geom::IntersectionMatrix minimum(pattern_minimum);
-		ensure_equals( minimum.toString(), pattern_minimum );
-		ensure( minimum.isContains() );
-
-		// 2. Test other version of  valid 'contains' matrix
-		const std::string pattern_contains("T00000FF0");
-		geos::geom::IntersectionMatrix contains(pattern_contains);
-		ensure_equals( contains.toString(),  pattern_contains );
-		ensure( contains.isContains() );
-
-		// 3. Test 'not-contains' version of 'contains' matrix
-		const std::string pattern_notcontains("T0F00F000");
-		geos::geom::IntersectionMatrix notcontains(pattern_notcontains);
-		ensure_equals( notcontains.toString(),  pattern_notcontains );
-		ensure( !notcontains.isContains() );
-	}
-
-	// Test of isCrosses(int dimensionOfGeometryA, int dimensionOfGeometryB)
-    template<>
-    template<>
-	void object::test<19>()
-	{
-		using geos::geom::Dimension;
-
-		// Test on the FALSE matrix
-		ensure_equals( im_.toString(),  pattern_false_);
-		ensure( !im_.isCrosses(Dimension::L, Dimension::L) );
-
-		// P/L: dim(I(a) * I(b)) AND dim(I(a) * E(b))
-		im_.set("TFTFFFFFF");
-		ensure( im_.isCrosses(Dimension::P, Dimension::L) );
-
-		// L/P: dim(I(a) * I(b)) AND dim(I(a) * E(b))
-		im_.set("TFTFFFFFF");
-		ensure( !im_.isCrosses(Dimension::L, Dimension::P) );
-
-		// P/L: dim(I(a) * I(b)) AND dim(E(a) * I(b))
-		im_.set("TFFFFFTFF");
-		ensure( !im_.isCrosses(Dimension::P, Dimension::L) );
-
-		// L/P: dim(I(a) * I(b)) AND dim(E(a) * I(b))
-		im_.set("TFFFFFTFF");
-		ensure( im_.isCrosses(Dimension::L, Dimension::P) );
-
-		// L/L: dim(I(a) * I(b)) == 0
-		im_.set("0FFFFFFFF");
-		ensure( im_.isCrosses(Dimension::L, Dimension::L) );
-
-		// L/L: dim(I(a) * I(b)) == 1
-		im_.set("1FFFFFFFF");
-		ensure( !im_.isCrosses(Dimension::L, Dimension::L) );
-	}
-
-	// Test of isDisjoint()
-    template<>
-    template<>
-	void object::test<20>()
-	{
-		// Test on the FALSE matrix
-		ensure_equals( im_.toString(),  pattern_false_);
-		ensure( im_.isDisjoint() );
-
-		im_.set("FF*FF****");
-		ensure( im_.isDisjoint() );
-
-		im_.set("FF1FF2T*0");
-		ensure( im_.isDisjoint() );
-
-		im_.set("*F*FF****");
-		ensure( !im_.isDisjoint() );
-	}
-
-	// Test of isEquals(int dimensionOfGeometryA, int dimensionOfGeometryB)
-    template<>
-    template<>
-	void object::test<21>()
-	{
-		using geos::geom::Dimension;
-
-		// Test on the FALSE matrix
-		ensure_equals( im_.toString(),  pattern_false_);
-		ensure( !im_.isEquals(Dimension::L, Dimension::L) );
-
-		// Test geometries with all dimensions
-		im_.set("0FFFFFFF2");
-		ensure( im_.isEquals(Dimension::P, Dimension::P) );
-		im_.set("1FFF0FFF2");
-		ensure( im_.isEquals(Dimension::L, Dimension::L) );
-		im_.set("2FFF1FFF2");
-		ensure( im_.isEquals(Dimension::A, Dimension::A) );
-		im_.set("0F0FFFFF2");
-		ensure( !im_.isEquals(Dimension::P, Dimension::P) );
-		im_.set("1FFF1FFF2");
-		ensure( im_.isEquals(Dimension::L, Dimension::L) );
-		im_.set("2FFF1*FF2");
-		ensure( !im_.isEquals(Dimension::A, Dimension::A) );
-		im_.set("0FFFFFFF2");
-		ensure( !im_.isEquals(Dimension::P, Dimension::L) );
-		im_.set("1FFF0FFF2");
-		ensure( !im_.isEquals(Dimension::L, Dimension::A) );
-		im_.set("2FFF1FFF2");
-		ensure( !im_.isEquals(Dimension::A, Dimension::P) );
-	}
-
-	// Test of isIntersects()
-    template<>
-    template<>
-	void object::test<22>()
-	{
-		// Test on the FALSE matrix
-		ensure_equals( im_.toString(),  pattern_false_);
-		ensure( !im_.isIntersects() );
-
-		im_.set("FF*FF****");
-		ensure( !im_.isIntersects() );
-		im_.set("FF1FF2T*0");
-		ensure( !im_.isIntersects() );
-		im_.set("*F*FF****");
-		ensure( im_.isIntersects() );
-	}
-
-	// Test of isOverlaps(int dimensionOfGeometryA, int dimensionOfGeometryB)
-    template<>
-    template<>
-	void object::test<23>()
-	{
-		using geos::geom::Dimension;
-
-		// Test on the FALSE matrix
-		ensure_equals( im_.toString(),  pattern_false_);
-		ensure( !im_.isEquals(Dimension::L, Dimension::L) );
-
-		im_.set("2*2***2**");
-		ensure( im_.isOverlaps(Dimension::P, Dimension::P) );
-		im_.set("2*2***2**");
-		ensure( im_.isOverlaps(Dimension::A, Dimension::A) );
-		im_.set("2*2***2**");
-		ensure( !im_.isOverlaps(Dimension::P, Dimension::A) );
-		im_.set("2*2***2**");
-		ensure( !im_.isOverlaps(Dimension::L, Dimension::L) );
-		im_.set("1*2***2**");
-		ensure( im_.isOverlaps(Dimension::L, Dimension::L) );
-		im_.set("0FFFFFFF2");
-		ensure( !im_.isOverlaps(Dimension::P, Dimension::P) );
-		im_.set("1FFF0FFF2");
-		ensure( !im_.isOverlaps(Dimension::L, Dimension::L) );
-		im_.set("2FFF1FFF2");
-		ensure( !im_.isOverlaps(Dimension::A, Dimension::A) );
-	}
-
-	// Test of isTouches(int dimensionOfGeometryA, int dimensionOfGeometryB)
-    template<>
-    template<>
-	void object::test<24>()
-	{
-		using geos::geom::Dimension;
-
-		// Test on the FALSE matrix
-		ensure_equals( im_.toString(),  pattern_false_);
-		ensure( !im_.isTouches(Dimension::P, Dimension::P) );
-
-		im_.set("FT*******");
-		ensure( im_.isTouches(Dimension::P, Dimension::A) );
-		im_.set("FT*******");
-		ensure( im_.isTouches(Dimension::A, Dimension::P) );
-		im_.set("FT*******");
-		ensure( !im_.isTouches(Dimension::P, Dimension::P));
-	}
-
-	// Test of isWithin()
-    template<>
-    template<>
-	void object::test<25>()
-	{
-		// Test on the FALSE matrix
-		ensure_equals( im_.toString(),  pattern_false_);
-		ensure( !im_.isWithin() );
-
-		im_.set("T0F00F000");
-		ensure( im_.isWithin() );
-		im_.set("T00000FF0");
-		ensure( !im_.isWithin() );
-	}
-
-
-	// Test of IntersectionMatrix* transpose()
-    template<>
-    template<>
-	void object::test<26>()
-	{
-		using geos::geom::IntersectionMatrix;
-
-		IntersectionMatrix input("012*TF012");
-		IntersectionMatrix transposed(input);
-
-		// transpose() returns 'this' pointer to transposed object
-		MatrixCPtr output = transposed.transpose();
-		ensure( output != nullptr );
-
-		// TODO - mloskot - waiting for equality operators
-		//ensure_equals( (*output), input );
-
-		ensure_equals( "0*01T12F2", transposed.toString() );
-
-		ensure_equals( "012*TF012", input.toString() );
-	}
-
-	// Test of toString() and output operator
-    template<>
-    template<>
-	void object::test<27>()
-	{
-		ensure( im_.toString() != "0*01T12F2" );
-		ensure_equals( "FFFFFFFFF", im_.toString() );
-
-		std::stringstream ss;
-		ss << im_;
-
-		ensure( ss.str() != "0*01T12F2" );
-		ensure_equals( "FFFFFFFFF", ss.str() );
-	}
-
-	// Test of isCovers()
-    template<>
-    template<>
-	void object::test<28>()
-	{
-		using geos::geom::IntersectionMatrix;
-
-		ensure( IntersectionMatrix("T*****FF*").isCovers() );
-		ensure( IntersectionMatrix("*T****FF*").isCovers() );
-		ensure( IntersectionMatrix("***T**FF*").isCovers() );
-		ensure( IntersectionMatrix("****T*FF*").isCovers() );
-	}
-
-	// Test of isCoveredBy()
-    template<>
-    template<>
-	void object::test<29>()
-	{
-		using geos::geom::IntersectionMatrix;
-
-		ensure( IntersectionMatrix("T*F**F***").isCoveredBy() );
-		ensure( IntersectionMatrix("*TF**F***").isCoveredBy() );
-		ensure( IntersectionMatrix("**FT*F***").isCoveredBy() );
-		ensure( IntersectionMatrix("**F*TF***").isCoveredBy() );
-	}
+    // 'im_' is initialized with 'FFFFFFFFF'
+    ensure_equals(im_.toString(), pattern_false_);
+
+    // Do some changes and checks
+    im_.set(0, 0, geos::geom::Dimension::P);
+
+    ensure_equals(im_.toString(), "0FFFFFFFF");
+
+}
+
+// Test of set(const std::string& dimensionSymbols);
+template<>
+template<>
+void object::test<12>
+()
+{
+    // 'im_' is initialized with 'FFFFFFFFF'
+    ensure_equals(im_.toString(), pattern_false_);
+
+    const std::string pattern("012*TF012");
+    im_.set(pattern);
+
+    ensure_equals(im_.toString(), pattern);
+}
+
+// Test of setAll(int dimensionValue);
+template<>
+template<>
+void object::test<13>
+()
+{
+    // 'im_' is initialized with 'FFFFFFFFF'
+    ensure_equals(im_.toString(), pattern_false_);
+
+    const std::string pattern("000000000");
+    im_.setAll(geos::geom::Dimension::P);
+
+    ensure_equals(im_.toString(), pattern);
+}
+
+// Test of setAtLeast(std::string minimumDimensionSymbols)
+template<>
+template<>
+void object::test<14>
+()
+{
+    // 'im_' is initialized with 'FFFFFFFFF'
+    ensure_equals(im_.toString(), pattern_false_);
+
+    // 1. No change expected
+    im_.setAtLeast(pattern_false_);
+    ensure_equals(im_.toString(), pattern_false_);
+
+    // 2. Set new pattern
+    const std::string pattern_new("FT*012FT*");
+    const std::string pattern_expected("FFF012FFF");
+
+    im_.setAtLeast(pattern_new);
+    ensure(im_.toString() != pattern_false_);
+    ensure_equals(im_.toString(), pattern_expected);
+
+    // 3. Set old pattern, no change expected
+    im_.setAtLeast(pattern_false_);
+    ensure_equals(im_.toString(), pattern_expected);
+}
+
+// Test of setAtLeast(int row, int column, int minimumDimensionValue);
+template<>
+template<>
+void object::test<15>
+()
+{
+    // 'im_' is initialized with 'FFFFFFFFF'
+    ensure_equals(im_.toString(), pattern_false_);
+
+    // 1. No change expected
+    im_.setAtLeast(0, 0, geos::geom::Dimension::False);
+    ensure_equals(im_.toString(), pattern_false_);
+
+    // 2. Change is expected
+    im_.setAtLeast(0, 0, geos::geom::Dimension::A);
+    ensure_equals(im_.toString(), "2FFFFFFFF");
+}
+
+
+// Test of setAtLeastIfValid(int row, int column, int minimumDimensionValue)
+template<>
+template<>
+void object::test<16>
+()
+{
+    // 'im_' is initialized with 'FFFFFFFFF'
+    ensure_equals(im_.toString(), pattern_false_);
+
+    // 1. No change expected
+    im_.setAtLeast(0, 0, geos::geom::Dimension::A);
+    ensure(im_.toString() != pattern_false_);
+    ensure_equals(im_.get(0, 0), geos::geom::Dimension::A);
+}
+
+// Test of get(int row, int column)
+template<>
+template<>
+void object::test<17>
+()
+{
+    // Test on the original pattern 'FFFFFFFFF' of the 'im_' object
+    ensure_equals(im_.toString(), pattern_false_);
+    ensure_equals(im_.get(0, 0), geos::geom::Dimension::False);
+
+    // Change first value and test again
+    im_.setAtLeast(0, 0, geos::geom::Dimension::A);
+    ensure_equals(im_.get(0, 0), geos::geom::Dimension::A);
+
+    // Change last value and test again
+    im_.setAtLeast(2, 2, geos::geom::Dimension::L);
+    ensure_equals(im_.get(2, 2), geos::geom::Dimension::L);
+}
+
+
+// Test of isContains()
+template<>
+template<>
+void object::test<18>
+()
+{
+    // Test on the FALSE matrix
+    ensure_equals(im_.toString(),  pattern_false_);
+    ensure(!im_.isContains());
+
+    // 1. Test 'minimum' version of 'contains' matrix
+    const std::string pattern_minimum("T*****FF*");
+    geos::geom::IntersectionMatrix minimum(pattern_minimum);
+    ensure_equals(minimum.toString(), pattern_minimum);
+    ensure(minimum.isContains());
+
+    // 2. Test other version of  valid 'contains' matrix
+    const std::string pattern_contains("T00000FF0");
+    geos::geom::IntersectionMatrix contains(pattern_contains);
+    ensure_equals(contains.toString(),  pattern_contains);
+    ensure(contains.isContains());
+
+    // 3. Test 'not-contains' version of 'contains' matrix
+    const std::string pattern_notcontains("T0F00F000");
+    geos::geom::IntersectionMatrix notcontains(pattern_notcontains);
+    ensure_equals(notcontains.toString(),  pattern_notcontains);
+    ensure(!notcontains.isContains());
+}
+
+// Test of isCrosses(int dimensionOfGeometryA, int dimensionOfGeometryB)
+template<>
+template<>
+void object::test<19>
+()
+{
+    using geos::geom::Dimension;
+
+    // Test on the FALSE matrix
+    ensure_equals(im_.toString(),  pattern_false_);
+    ensure(!im_.isCrosses(Dimension::L, Dimension::L));
+
+    // P/L: dim(I(a) * I(b)) AND dim(I(a) * E(b))
+    im_.set("TFTFFFFFF");
+    ensure(im_.isCrosses(Dimension::P, Dimension::L));
+
+    // L/P: dim(I(a) * I(b)) AND dim(I(a) * E(b))
+    im_.set("TFTFFFFFF");
+    ensure(!im_.isCrosses(Dimension::L, Dimension::P));
+
+    // P/L: dim(I(a) * I(b)) AND dim(E(a) * I(b))
+    im_.set("TFFFFFTFF");
+    ensure(!im_.isCrosses(Dimension::P, Dimension::L));
+
+    // L/P: dim(I(a) * I(b)) AND dim(E(a) * I(b))
+    im_.set("TFFFFFTFF");
+    ensure(im_.isCrosses(Dimension::L, Dimension::P));
+
+    // L/L: dim(I(a) * I(b)) == 0
+    im_.set("0FFFFFFFF");
+    ensure(im_.isCrosses(Dimension::L, Dimension::L));
+
+    // L/L: dim(I(a) * I(b)) == 1
+    im_.set("1FFFFFFFF");
+    ensure(!im_.isCrosses(Dimension::L, Dimension::L));
+}
+
+// Test of isDisjoint()
+template<>
+template<>
+void object::test<20>
+()
+{
+    // Test on the FALSE matrix
+    ensure_equals(im_.toString(),  pattern_false_);
+    ensure(im_.isDisjoint());
+
+    im_.set("FF*FF****");
+    ensure(im_.isDisjoint());
+
+    im_.set("FF1FF2T*0");
+    ensure(im_.isDisjoint());
+
+    im_.set("*F*FF****");
+    ensure(!im_.isDisjoint());
+}
+
+// Test of isEquals(int dimensionOfGeometryA, int dimensionOfGeometryB)
+template<>
+template<>
+void object::test<21>
+()
+{
+    using geos::geom::Dimension;
+
+    // Test on the FALSE matrix
+    ensure_equals(im_.toString(),  pattern_false_);
+    ensure(!im_.isEquals(Dimension::L, Dimension::L));
+
+    // Test geometries with all dimensions
+    im_.set("0FFFFFFF2");
+    ensure(im_.isEquals(Dimension::P, Dimension::P));
+    im_.set("1FFF0FFF2");
+    ensure(im_.isEquals(Dimension::L, Dimension::L));
+    im_.set("2FFF1FFF2");
+    ensure(im_.isEquals(Dimension::A, Dimension::A));
+    im_.set("0F0FFFFF2");
+    ensure(!im_.isEquals(Dimension::P, Dimension::P));
+    im_.set("1FFF1FFF2");
+    ensure(im_.isEquals(Dimension::L, Dimension::L));
+    im_.set("2FFF1*FF2");
+    ensure(!im_.isEquals(Dimension::A, Dimension::A));
+    im_.set("0FFFFFFF2");
+    ensure(!im_.isEquals(Dimension::P, Dimension::L));
+    im_.set("1FFF0FFF2");
+    ensure(!im_.isEquals(Dimension::L, Dimension::A));
+    im_.set("2FFF1FFF2");
+    ensure(!im_.isEquals(Dimension::A, Dimension::P));
+}
+
+// Test of isIntersects()
+template<>
+template<>
+void object::test<22>
+()
+{
+    // Test on the FALSE matrix
+    ensure_equals(im_.toString(),  pattern_false_);
+    ensure(!im_.isIntersects());
+
+    im_.set("FF*FF****");
+    ensure(!im_.isIntersects());
+    im_.set("FF1FF2T*0");
+    ensure(!im_.isIntersects());
+    im_.set("*F*FF****");
+    ensure(im_.isIntersects());
+}
+
+// Test of isOverlaps(int dimensionOfGeometryA, int dimensionOfGeometryB)
+template<>
+template<>
+void object::test<23>
+()
+{
+    using geos::geom::Dimension;
+
+    // Test on the FALSE matrix
+    ensure_equals(im_.toString(),  pattern_false_);
+    ensure(!im_.isEquals(Dimension::L, Dimension::L));
+
+    im_.set("2*2***2**");
+    ensure(im_.isOverlaps(Dimension::P, Dimension::P));
+    im_.set("2*2***2**");
+    ensure(im_.isOverlaps(Dimension::A, Dimension::A));
+    im_.set("2*2***2**");
+    ensure(!im_.isOverlaps(Dimension::P, Dimension::A));
+    im_.set("2*2***2**");
+    ensure(!im_.isOverlaps(Dimension::L, Dimension::L));
+    im_.set("1*2***2**");
+    ensure(im_.isOverlaps(Dimension::L, Dimension::L));
+    im_.set("0FFFFFFF2");
+    ensure(!im_.isOverlaps(Dimension::P, Dimension::P));
+    im_.set("1FFF0FFF2");
+    ensure(!im_.isOverlaps(Dimension::L, Dimension::L));
+    im_.set("2FFF1FFF2");
+    ensure(!im_.isOverlaps(Dimension::A, Dimension::A));
+}
+
+// Test of isTouches(int dimensionOfGeometryA, int dimensionOfGeometryB)
+template<>
+template<>
+void object::test<24>
+()
+{
+    using geos::geom::Dimension;
+
+    // Test on the FALSE matrix
+    ensure_equals(im_.toString(),  pattern_false_);
+    ensure(!im_.isTouches(Dimension::P, Dimension::P));
+
+    im_.set("FT*******");
+    ensure(im_.isTouches(Dimension::P, Dimension::A));
+    im_.set("FT*******");
+    ensure(im_.isTouches(Dimension::A, Dimension::P));
+    im_.set("FT*******");
+    ensure(!im_.isTouches(Dimension::P, Dimension::P));
+}
+
+// Test of isWithin()
+template<>
+template<>
+void object::test<25>
+()
+{
+    // Test on the FALSE matrix
+    ensure_equals(im_.toString(),  pattern_false_);
+    ensure(!im_.isWithin());
+
+    im_.set("T0F00F000");
+    ensure(im_.isWithin());
+    im_.set("T00000FF0");
+    ensure(!im_.isWithin());
+}
+
+
+// Test of IntersectionMatrix* transpose()
+template<>
+template<>
+void object::test<26>
+()
+{
+    using geos::geom::IntersectionMatrix;
+
+    IntersectionMatrix input("012*TF012");
+    IntersectionMatrix transposed(input);
+
+    // transpose() returns 'this' pointer to transposed object
+    MatrixCPtr output = transposed.transpose();
+    ensure(output != nullptr);
+
+    // TODO - mloskot - waiting for equality operators
+    //ensure_equals( (*output), input );
+
+    ensure_equals("0*01T12F2", transposed.toString());
+
+    ensure_equals("012*TF012", input.toString());
+}
+
+// Test of toString() and output operator
+template<>
+template<>
+void object::test<27>
+()
+{
+    ensure(im_.toString() != "0*01T12F2");
+    ensure_equals("FFFFFFFFF", im_.toString());
+
+    std::stringstream ss;
+    ss << im_;
+
+    ensure(ss.str() != "0*01T12F2");
+    ensure_equals("FFFFFFFFF", ss.str());
+}
+
+// Test of isCovers()
+template<>
+template<>
+void object::test<28>
+()
+{
+    using geos::geom::IntersectionMatrix;
+
+    ensure(IntersectionMatrix("T*****FF*").isCovers());
+    ensure(IntersectionMatrix("*T****FF*").isCovers());
+    ensure(IntersectionMatrix("***T**FF*").isCovers());
+    ensure(IntersectionMatrix("****T*FF*").isCovers());
+}
+
+// Test of isCoveredBy()
+template<>
+template<>
+void object::test<29>
+()
+{
+    using geos::geom::IntersectionMatrix;
+
+    ensure(IntersectionMatrix("T*F**F***").isCoveredBy());
+    ensure(IntersectionMatrix("*TF**F***").isCoveredBy());
+    ensure(IntersectionMatrix("**FT*F***").isCoveredBy());
+    ensure(IntersectionMatrix("**F*TF***").isCoveredBy());
+}
 
 } // namespace tut
 
diff --git a/tests/unit/geom/LineSegmentTest.cpp b/tests/unit/geom/LineSegmentTest.cpp
index d1a6f9b..701d2e2 100644
--- a/tests/unit/geom/LineSegmentTest.cpp
+++ b/tests/unit/geom/LineSegmentTest.cpp
@@ -8,110 +8,114 @@
 // std
 #include <iostream>
 
-namespace tut
+namespace tut {
+//
+// Test Group
+//
+
+struct test_lineseg_data {
+    geos::geom::Coordinate ph1;
+    geos::geom::Coordinate ph2;
+    geos::geom::Coordinate pv1;
+    geos::geom::Coordinate pv2;
+    geos::geom::LineSegment h1;
+    geos::geom::LineSegment v1;
+
+    test_lineseg_data()
+        : ph1(0, 2), ph2(10, 2), pv1(0, 0), pv2(0, 10), h1(ph1, ph2), v1(pv1, pv2)
+    {}
+};
+
+typedef test_group<test_lineseg_data> group;
+typedef group::object object;
+
+group test_lineseg_group("geos::geom::LineSegment");
+
+//
+// Test Cases
+//
+
+// 1 - Test reverse()
+template<>
+template<>
+void object::test<1>
+()
+{
+    ensure(v1[0] == pv1);
+    ensure(v1[1] == pv2);
+    v1.reverse();
+    ensure(v1[1] == pv1);
+    ensure(v1[0] == pv2);
+
+    ensure(h1[0] == ph1);
+    ensure(h1[1] == ph2);
+    h1.reverse();
+    ensure(h1[1] == ph1);
+    ensure(h1[0] == ph2);
+}
+
+
+// 2 - Horizontal LineSegment test
+template<>
+template<>
+void object::test<2>
+()
+{
+    ensure(h1.isHorizontal());
+    v1.reverse();
+    ensure(h1.isHorizontal());
+}
+
+// 3 - Vertical LineSegment test
+template<>
+template<>
+void object::test<3>
+()
+{
+    ensure(v1.isVertical());
+    v1.reverse();
+    ensure(v1.isVertical());
+}
+
+// 4 - Test distance()
+template<>
+template<>
+void object::test<4>
+()
+{
+    ensure_equals(h1.distance(v1), 0);
+    v1.reverse();
+    ensure_equals(h1.distance(v1), 0);
+    h1.reverse();
+    ensure_equals(h1.distance(v1), 0);
+}
+
+// 5 - Test getLength()
+template<>
+template<>
+void object::test<5>
+()
+{
+    ensure_equals(v1.getLength(), 10);
+    v1.reverse();
+    ensure_equals(v1.getLength(), 10);
+
+    ensure_equals(h1.getLength(), 10);
+    h1.reverse();
+    ensure_equals(h1.getLength(), 10);
+}
+
+// 6 - Test distance again()
+template<>
+template<>
+void object::test<6>
+()
 {
-	//
-	// Test Group
-	//
-
-	struct test_lineseg_data
-    {
-        geos::geom::Coordinate ph1;
-        geos::geom::Coordinate ph2;
-        geos::geom::Coordinate pv1;
-        geos::geom::Coordinate pv2;
-        geos::geom::LineSegment h1;
-        geos::geom::LineSegment v1;
-
-        test_lineseg_data()
-            : ph1(0, 2), ph2(10, 2), pv1(0, 0), pv2(0, 10), h1(ph1, ph2), v1(pv1, pv2)
-        {}
-    };
-
-	typedef test_group<test_lineseg_data> group;
-	typedef group::object object;
-
-	group test_lineseg_group("geos::geom::LineSegment");
-
-	//
-	// Test Cases
-	//
-
-	// 1 - Test reverse()
-	template<>
-	template<>
-	void object::test<1>()
-	{
-		ensure(v1[0] == pv1);
-		ensure(v1[1] == pv2);
-		v1.reverse();
-		ensure(v1[1] == pv1);
-		ensure(v1[0] == pv2);
-
-		ensure(h1[0] == ph1);
-		ensure(h1[1] == ph2);
-		h1.reverse();
-		ensure(h1[1] == ph1);
-		ensure(h1[0] == ph2);
-	}
-
-
-	// 2 - Horizontal LineSegment test
-	template<>
-	template<>
-	void object::test<2>()
-	{
-		ensure( h1.isHorizontal() );
-		v1.reverse();
-		ensure( h1.isHorizontal() );
-	}
-
-	// 3 - Vertical LineSegment test
-	template<>
-	template<>
-	void object::test<3>()
-	{
-		ensure( v1.isVertical() );
-		v1.reverse();
-		ensure( v1.isVertical() );
-	}
-
-	// 4 - Test distance()
-	template<>
-	template<>
-	void object::test<4>()
-	{
-		ensure_equals( h1.distance(v1), 0 );
-		v1.reverse();
-		ensure_equals( h1.distance(v1), 0 );
-		h1.reverse();
-		ensure_equals( h1.distance(v1), 0 );
-	}
-
-	// 5 - Test getLength()
-	template<>
-	template<>
-	void object::test<5>()
-	{
-		ensure_equals( v1.getLength(), 10 );
-		v1.reverse();
-		ensure_equals( v1.getLength(), 10 );
-
-		ensure_equals( h1.getLength(), 10 );
-		h1.reverse();
-		ensure_equals( h1.getLength(), 10 );
-	}
-
-	// 6 - Test distance again()
-	template<>
-	template<>
-	void object::test<6>()
-	{
-		geos::geom::Coordinate p(1, 1);
-		ensure_equals( v1.distance(p), 1 );
-		v1.reverse();
-		ensure_equals( v1.distance(p), 1 );
-	}
+    geos::geom::Coordinate p(1, 1);
+    ensure_equals(v1.distance(p), 1);
+    v1.reverse();
+    ensure_equals(v1.distance(p), 1);
+}
 
 } // namespace tut
 
diff --git a/tests/unit/geom/LineStringTest.cpp b/tests/unit/geom/LineStringTest.cpp
index af3cfd9..ed4bfd8 100644
--- a/tests/unit/geom/LineStringTest.cpp
+++ b/tests/unit/geom/LineStringTest.cpp
@@ -20,492 +20,513 @@
 #include <cmath>
 #include <cassert>
 
-namespace tut
-{
-    //
-    // Test Group
-    //
+namespace tut {
+//
+// Test Group
+//
+
+// Common data used by tests
+struct test_linestring_data {
+    // Typedefs used as short names by test cases
+    typedef std::unique_ptr<geos::geom::LineString> LineStringAutoPtr;
+
+    geos::geom::PrecisionModel pm_;
+    geos::geom::GeometryFactory::Ptr factory_;
+    geos::io::WKTReader reader_;
+
+    LineStringPtr empty_line_;
 
-    // Common data used by tests
-    struct test_linestring_data
+    test_linestring_data()
+        : pm_(1000)
+        , factory_(geos::geom::GeometryFactory::create(&pm_, 0))
+        , reader_(factory_.get())
+        , empty_line_(factory_->createLineString(new geos::geom::CoordinateArraySequence()))
     {
-		// Typedefs used as short names by test cases
-		typedef std::unique_ptr<geos::geom::LineString> LineStringAutoPtr;
-
-		geos::geom::PrecisionModel pm_;
-		geos::geom::GeometryFactory::Ptr factory_;
-		geos::io::WKTReader reader_;
-
-		LineStringPtr empty_line_;
-
-		test_linestring_data()
-			: pm_(1000)
-      , factory_(geos::geom::GeometryFactory::create(&pm_, 0))
-      , reader_(factory_.get())
-      , empty_line_(factory_->createLineString(new geos::geom::CoordinateArraySequence()))
-		{
-            assert(nullptr != empty_line_);
-        }
-
-        ~test_linestring_data()
-        {
-            factory_->destroyGeometry(empty_line_);
-            empty_line_ = nullptr;
-        }
-    };
-
-    typedef test_group<test_linestring_data> group;
-    typedef group::object object;
-
-    group test_linestring_group("geos::geom::LineString");
-
-    //
-    // Test Cases
-    //
-
-    // Test of empty LineString created with user's constructor
-    template<>
-    template<>
-    void object::test<1>()
+        assert(nullptr != empty_line_);
+    }
+
+    ~test_linestring_data()
     {
-		using geos::geom::Coordinate;
+        factory_->destroyGeometry(empty_line_);
+        empty_line_ = nullptr;
+    }
+};
+
+typedef test_group<test_linestring_data> group;
+typedef group::object object;
+
+group test_linestring_group("geos::geom::LineString");
 
-		// Empty sequence of coordiantes
-		CoordArrayPtr pseq = new geos::geom::CoordinateArraySequence();
-		ensure( "sequence is null pointer.", pseq != nullptr );
+//
+// Test Cases
+//
+
+// Test of empty LineString created with user's constructor
+template<>
+template<>
+void object::test<1>
+()
+{
+    using geos::geom::Coordinate;
+
+    // Empty sequence of coordiantes
+    CoordArrayPtr pseq = new geos::geom::CoordinateArraySequence();
+    ensure("sequence is null pointer.", pseq != nullptr);
+
+    // Create empty linstring instance
+    LineStringAutoPtr ls(factory_->createLineString(pseq));
 
-		// Create empty linstring instance
-		LineStringAutoPtr ls(factory_->createLineString(pseq));
+    ensure(ls->isEmpty());
+    ensure(ls->isSimple());
+    ensure(ls->isValid());
+}
 
-		ensure( ls->isEmpty() );
-		ensure( ls->isSimple() );
-		ensure( ls->isValid() );
+// Test of non-tempty LineString created with user's constructor
+template<>
+template<>
+void object::test<2>
+()
+{
+    using geos::geom::Coordinate;
+
+    // Non-empty sequence of coordiantes
+    const size_t size3 = 3;
+
+    CoordArrayPtr pseq = new geos::geom::CoordinateArraySequence();
+    ensure("sequence is null pointer.", pseq != nullptr);
+
+    pseq->add(Coordinate(0, 0, 0));
+    pseq->add(Coordinate(5, 5, 5));
+    pseq->add(Coordinate(10, 10, 10));
+
+    ensure_equals(pseq->size(), size3);
+
+    // Create non-empty linstring instance
+    LineStringAutoPtr ls(factory_->createLineString(pseq));
+
+    ensure(!ls->isEmpty());
+    ensure(ls->isSimple());
+    ensure(ls->isValid());
+
+    ensure(!ls->isClosed());
+    ensure(!ls->isRing());
+
+    GeometryPtr geo = nullptr;
+    geo = ls->getEnvelope();
+    ensure(geo != nullptr);
+    ensure(!geo->isEmpty());
+    factory_->destroyGeometry(geo);
+
+    geo = ls->getBoundary();
+    ensure(geo != nullptr);
+    ensure(!geo->isEmpty());
+    factory_->destroyGeometry(geo);
+
+    geo = ls->convexHull();
+    ensure(geo != nullptr);
+    ensure(!geo->isEmpty());
+    factory_->destroyGeometry(geo);
+
+    ensure_equals(ls->getGeometryTypeId(), geos::geom::GEOS_LINESTRING);
+    ensure_equals(ls->getDimension(), geos::geom::Dimension::L);
+    ensure_equals(ls->getBoundaryDimension(), geos::geom::Dimension::P);
+    ensure_equals(ls->getCoordinateDimension(), 3);
+    ensure_equals(ls->getNumPoints(), size3);
+    ensure_equals(ls->getArea(), 0.0);
+    ensure(ls->getLength() != 0.0);
+}
+
+// Test of incomplete LineString user's constructor throwing the IllegalArgumentException
+template<>
+template<>
+void object::test<3>
+()
+{
+    // Single-element sequence of coordiantes
+    CoordArrayPtr pseq = nullptr;
+    try {
+        pseq = new geos::geom::CoordinateArraySequence();
+        ensure("sequence is null pointer.", pseq != nullptr);
+        pseq->add(geos::geom::Coordinate(0, 0, 0));
+        ensure_equals(pseq->size(), 1u);
+
+        // Create incomplete linstring
+        LineStringAutoPtr ls(factory_->createLineString(pseq));
+        fail("IllegalArgumentException expected.");
     }
+    catch(geos::util::IllegalArgumentException const& e) {
+        // TODO - mloskot - is waiting for "exception-safety" and bugs resolution
+        // If removed, memory 3 leaks occur
+        //delete pseq;
 
-    // Test of non-tempty LineString created with user's constructor
-    template<>
-    template<>
-    void object::test<2>()
-    {
-		using geos::geom::Coordinate;
-
-		// Non-empty sequence of coordiantes
-		const size_t size3 = 3;
-
-		CoordArrayPtr pseq = new geos::geom::CoordinateArraySequence();
-		ensure( "sequence is null pointer.", pseq != nullptr );
-
-		pseq->add(Coordinate(0, 0, 0));
-		pseq->add(Coordinate(5, 5, 5));
-		pseq->add(Coordinate(10, 10, 10));
-
-		ensure_equals( pseq->size(), size3 );
-
-		// Create non-empty linstring instance
-		LineStringAutoPtr ls(factory_->createLineString(pseq));
-
-		ensure( !ls->isEmpty() );
-		ensure( ls->isSimple() );
-		ensure( ls->isValid() );
-
-		ensure( !ls->isClosed() );
-		ensure( !ls->isRing() );
-
-		GeometryPtr geo = nullptr;
-		geo = ls->getEnvelope();
-		ensure( geo != nullptr );
-		ensure( !geo->isEmpty() );
-		factory_->destroyGeometry(geo);
-
-		geo = ls->getBoundary();
-		ensure( geo != nullptr );
-		ensure( !geo->isEmpty() );
-		factory_->destroyGeometry(geo);
-
-		geo = ls->convexHull();
-		ensure( geo != nullptr );
-		ensure( !geo->isEmpty() );
-		factory_->destroyGeometry(geo);
-
-		ensure_equals( ls->getGeometryTypeId(), geos::geom::GEOS_LINESTRING );
-		ensure_equals( ls->getDimension(), geos::geom::Dimension::L );
-		ensure_equals( ls->getBoundaryDimension(), geos::geom::Dimension::P );
-        ensure_equals( ls->getCoordinateDimension(), 3 );
-		ensure_equals( ls->getNumPoints(), size3 );
-		ensure_equals( ls->getArea(), 0.0 );
-		ensure( ls->getLength() != 0.0 );
-	}
-
-	// Test of incomplete LineString user's constructor throwing the IllegalArgumentException
-    template<>
-    template<>
-    void object::test<3>()
-    {
-		// Single-element sequence of coordiantes
-		CoordArrayPtr pseq = nullptr;
-		try
-		{
-			pseq = new geos::geom::CoordinateArraySequence();
-			ensure( "sequence is null pointer.", pseq != nullptr );
-			pseq->add(geos::geom::Coordinate(0, 0, 0));
-			ensure_equals( pseq->size(), 1u );
-
-			// Create incomplete linstring
-			LineStringAutoPtr ls(factory_->createLineString(pseq));
-			fail("IllegalArgumentException expected.");
-		}
-		catch (geos::util::IllegalArgumentException const& e)
-		{
-			// TODO - mloskot - is waiting for "exception-safety" and bugs resolution
-			// If removed, memory 3 leaks occur
-			//delete pseq;
-
-			const char* msg = e.what(); // OK
-			ensure( msg != nullptr );
-		}
-	}
-
-    // Test of copy constructor
-    template<>
-    template<>
-    void object::test<4>()
-    {
-		using geos::geom::Coordinate;
-
-		// Non-empty sequence of coordiantes
-		const size_t size = 3;
-
-		CoordArrayPtr pseq = new geos::geom::CoordinateArraySequence();
-		ensure( "sequence is null pointer.", pseq != nullptr );
-
-		pseq->add(Coordinate(0, 0, 0));
-		pseq->add(Coordinate(5, 5, 5));
-		pseq->add(Coordinate(10, 10, 10));
-
-		ensure_equals( pseq->size(), size );
-
-		// Create examplar of linstring instance
-		LineStringAutoPtr examplar(factory_->createLineString(pseq));
-
-		// Create copy
-		LineStringAutoPtr copy(dynamic_cast<geos::geom::LineString*>(examplar->clone()));
-
-		ensure( nullptr != copy.get() );
-
-		ensure( !copy->isEmpty() );
-		ensure( copy->isSimple() );
-		ensure( copy->isValid() );
-
-		ensure( !copy->isClosed() );
-		ensure( !copy->isRing() );
-
-		GeometryPtr geo = nullptr;
-		geo = copy->getEnvelope();
-		ensure( geo != nullptr );
-		ensure( !geo->isEmpty() );
-		factory_->destroyGeometry(geo);
-
-		geo = copy->getBoundary();
-		ensure( geo != nullptr );
-		ensure( !geo->isEmpty() );
-		factory_->destroyGeometry(geo);
-
-		geo = copy->convexHull();
-		ensure( geo != nullptr );
-		ensure( !geo->isEmpty() );
-		factory_->destroyGeometry(geo);
-
-		ensure_equals( copy->getGeometryTypeId(), geos::geom::GEOS_LINESTRING );
-		ensure_equals( copy->getDimension(), geos::geom::Dimension::L );
-		ensure_equals( copy->getBoundaryDimension(), geos::geom::Dimension::P );
-		ensure_equals( copy->getNumPoints(), size );
-		ensure_equals( copy->getArea(), 0.0 );
-		ensure( copy->getLength() != 0.0 );
-	}
-
-    // Test of isClosed() and isRing() for empty linestring
-    template<>
-    template<>
-    void object::test<5>()
-	{
-		ensure( !empty_line_->isClosed() );
-		ensure( !empty_line_->isRing() );
-	}
-
-    // Test of getEnvelope() for empty linestring
-    template<>
-    template<>
-    void object::test<6>()
-	{
-		GeometryPtr geo = nullptr;
-		geo = empty_line_->getEnvelope();
-		ensure( geo != nullptr );
-		ensure( geo->isEmpty() );
-		factory_->destroyGeometry(geo);
-	}
-
-    // Test of getBoundary() for empty linestring
-    template<>
-    template<>
-    void object::test<7>()
-	{
-		GeometryPtr geo = nullptr;
-		geo = empty_line_->getBoundary();
-		ensure( geo != nullptr );
-		ensure( geo->isEmpty() );
-		factory_->destroyGeometry(geo);
-	}
-
-    // Test of convexHull() for empty linestring
-    template<>
-    template<>
-    void object::test<8>()
-	{
-		GeometryPtr geo = nullptr;
-		geo = empty_line_->convexHull();
-		ensure( geo != nullptr );
-		ensure( geo->isEmpty() );
-		factory_->destroyGeometry(geo);
-	}
-
-    // Test of getGeometryTypeId() for empty linestring
-    template<>
-    template<>
-    void object::test<9>()
-	{
-		ensure_equals( empty_line_->getGeometryTypeId(), geos::geom::GEOS_LINESTRING );
-	}
-
-	// Test of getDimension() for empty linestring
-    template<>
-    template<>
-    void object::test<10>()
-	{
-		ensure_equals( empty_line_->getDimension(), geos::geom::Dimension::L );
-	}
-
-	// Test of getBoundaryDimension() for empty linestring
-    template<>
-    template<>
-    void object::test<11>()
-	{
-		ensure_equals( empty_line_->getBoundaryDimension(), geos::geom::Dimension::P );
-	}
-
-	// Test of getNumPoints() for empty linestring
-    template<>
-    template<>
-    void object::test<12>()
-	{
-		ensure_equals( empty_line_->getNumPoints(), 0u );
-	}
-
-	// Test of getLength() for empty linestring
-    template<>
-    template<>
-    void object::test<13>()
-	{
-		ensure_equals( empty_line_->getLength(), 0.0 );
-	}
-
-	// Test of getArea() for empty linestring
-    template<>
-    template<>
-    void object::test<14>()
-	{
-		ensure_equals( empty_line_->getArea(), 0.0 );
-	}
-
-    // Test of isClosed() and isRing() for non-empty linestring
-    template<>
-    template<>
-    void object::test<15>()
-	{
-		GeometryPtr geo = reader_.read("LINESTRING (0 0, 5 5, 10 5, 10 10)");
-		ensure( geo != nullptr );
-
-		LineStringPtr line = dynamic_cast<LineStringPtr>(geo);
-		ensure(line != nullptr);
-
-		ensure( !line->isEmpty() );
-		ensure( !line->isClosed() );
-		ensure( !line->isRing() );
-        ensure( line->getCoordinateDimension() == 2 );
-
-		// FREE TESTED LINESTRING
-		factory_->destroyGeometry(line);
-	}
-
-    // Test of getEnvelope() for non-empty linestring
-    template<>
-    template<>
-    void object::test<16>()
-	{
-		GeometryPtr geo = reader_.read("LINESTRING (0 0, 5 5, 10 5, 10 10)");
-		ensure( geo != nullptr );
-
-		LineStringPtr line = dynamic_cast<LineStringPtr>(geo);
-		ensure(line != nullptr);
-
-		GeometryPtr envelope = line->getEnvelope();
-		ensure( envelope != nullptr );
-		ensure( !envelope->isEmpty() );
-		ensure_equals( envelope->getDimension(), geos::geom::Dimension::A );
-
-		factory_->destroyGeometry(envelope);
-
-		// FREE TESTED LINESTRING
-		factory_->destroyGeometry(line);
-	}
-
-	// Test of getBoundary() for non-empty linestring
-    template<>
-    template<>
-    void object::test<17>()
-	{
-		GeometryPtr geo = reader_.read("LINESTRING (0 0, 5 5, 10 5, 10 10)");
-		ensure( geo != nullptr );
-
-		LineStringPtr line = dynamic_cast<LineStringPtr>(geo);
-		ensure(line != nullptr);
-
-		GeometryPtr boundary = line->getBoundary();
-		ensure( boundary != nullptr );
-		ensure( !boundary->isEmpty() );
-		ensure_equals( boundary->getGeometryTypeId(), geos::geom::GEOS_MULTIPOINT );
-		ensure_equals( boundary->getDimension(), geos::geom::Dimension::P );
-		factory_->destroyGeometry(boundary);
-
-		// FREE TESTED LINESTRING
-		factory_->destroyGeometry(line);
-	}
-
-	// Test of convexHull() for non-empty linestring
-    template<>
-    template<>
-    void object::test<18>()
-	{
-		GeometryPtr geo = reader_.read("LINESTRING (0 0, 5 5, 10 5, 10 10)");
-		ensure( geo != nullptr );
-
-		LineStringPtr line = dynamic_cast<LineStringPtr>(geo);
-		ensure(line != nullptr);
-
-		GeometryPtr hull = line->convexHull();
-		ensure( hull != nullptr );
-		ensure( !hull->isEmpty() );
-		ensure_equals( hull->getGeometryTypeId(), geos::geom::GEOS_POLYGON );
-		ensure_equals( hull->getDimension(), geos::geom::Dimension::A );
-		factory_->destroyGeometry(hull);
-
-		// FREE TESTED LINESTRING
-		factory_->destroyGeometry(line);
-	}
-
-	// Test of getGeometryTypeId() for non-empty linestring
-    template<>
-    template<>
-    void object::test<19>()
-	{
-		GeometryPtr geo = reader_.read("LINESTRING (0 0, 5 5, 10 5, 10 10)");
-		ensure( geo != nullptr );
-
-		ensure_equals( geo->getGeometryTypeId(), geos::geom::GEOS_LINESTRING );
-
-		// FREE TESTED LINESTRING
-		factory_->destroyGeometry(geo);
-	}
-
-	// Test of getDimension() for non-empty linestring
-    template<>
-    template<>
-    void object::test<20>()
-	{
-		GeometryPtr geo = reader_.read("LINESTRING (0 0, 5 5, 10 5, 10 10)");
-		ensure( geo != nullptr );
-
-		ensure_equals( geo->getDimension(), geos::geom::Dimension::L );
-
-		// FREE TESTED LINESTRING
-		factory_->destroyGeometry(geo);
-	}
-
-	// Test of getBoundaryDimension() for non-empty linestring
-    template<>
-    template<>
-    void object::test<21>()
-	{
-		GeometryPtr geo = reader_.read("LINESTRING (0 0, 5 5, 10 5, 10 10)");
-		ensure( geo != nullptr );
-
-		ensure_equals( geo->getBoundaryDimension(), geos::geom::Dimension::P );
-
-		// FREE TESTED LINESTRING
-		factory_->destroyGeometry(geo);
-	}
-
-	// Test of getNumPoints() for non-empty linestring
-    template<>
-    template<>
-    void object::test<22>()
-	{
-		const size_t size = 4;
-		GeometryPtr geo = reader_.read("LINESTRING (0 0, 5 5, 10 5, 10 10)");
-		ensure( geo != nullptr );
-
-		ensure_equals( geo->getNumPoints(), size );
-
-		// FREE TESTED LINESTRING
-		factory_->destroyGeometry(geo);
-	}
-
-	// Test of getLength() for non-empty linestring
-    template<>
-    template<>
-    void object::test<23>()
-	{
-		const double tolerance = 0.0001;
-		const double expected = 2 * 14.142135600000000;
-		GeometryPtr geo = reader_.read("LINESTRING (0 0, 10 10, 20 0)");
-		ensure( geo != nullptr );
-
-		ensure( geo->getLength() != 0.0 );
-
-		const double diff = std::fabs(geo->getLength() - expected);
-		ensure( diff <= tolerance );
-
-		// FREE TESTED LINESTRING
-		factory_->destroyGeometry(geo);
-	}
-
-	// Test of getArea() for non-empty linestring
-    template<>
-    template<>
-    void object::test<24>()
-	{
-		GeometryPtr geo = reader_.read("LINESTRING (0 0, 10 10, 20 0)");
-		ensure( geo != nullptr );
-
-		ensure_equals( geo->getArea(), 0.0 );
-
-		// FREE TESTED LINESTRING
-		factory_->destroyGeometry(geo);
-	}
-
-	// Test of getGeometryType() for non-empty Polygon
-    template<>
-    template<>
-    void object::test<25>()
-	{
-		GeometryPtr geo = reader_.read("LINESTRING (0 0, 10 10, 20 0)");
-		ensure( geo != nullptr );
-
-		const std::string type("LineString");
-		ensure_equals( geo->getGeometryType(), type );
-
-		// FREE MEMORY
-		factory_->destroyGeometry(geo);
-	}
+        const char* msg = e.what(); // OK
+        ensure(msg != nullptr);
+    }
+}
+
+// Test of copy constructor
+template<>
+template<>
+void object::test<4>
+()
+{
+    using geos::geom::Coordinate;
+
+    // Non-empty sequence of coordiantes
+    const size_t size = 3;
+
+    CoordArrayPtr pseq = new geos::geom::CoordinateArraySequence();
+    ensure("sequence is null pointer.", pseq != nullptr);
+
+    pseq->add(Coordinate(0, 0, 0));
+    pseq->add(Coordinate(5, 5, 5));
+    pseq->add(Coordinate(10, 10, 10));
+
+    ensure_equals(pseq->size(), size);
+
+    // Create examplar of linstring instance
+    LineStringAutoPtr examplar(factory_->createLineString(pseq));
+
+    // Create copy
+    LineStringAutoPtr copy(dynamic_cast<geos::geom::LineString*>(examplar->clone()));
+
+    ensure(nullptr != copy.get());
+
+    ensure(!copy->isEmpty());
+    ensure(copy->isSimple());
+    ensure(copy->isValid());
+
+    ensure(!copy->isClosed());
+    ensure(!copy->isRing());
+
+    GeometryPtr geo = nullptr;
+    geo = copy->getEnvelope();
+    ensure(geo != nullptr);
+    ensure(!geo->isEmpty());
+    factory_->destroyGeometry(geo);
+
+    geo = copy->getBoundary();
+    ensure(geo != nullptr);
+    ensure(!geo->isEmpty());
+    factory_->destroyGeometry(geo);
+
+    geo = copy->convexHull();
+    ensure(geo != nullptr);
+    ensure(!geo->isEmpty());
+    factory_->destroyGeometry(geo);
+
+    ensure_equals(copy->getGeometryTypeId(), geos::geom::GEOS_LINESTRING);
+    ensure_equals(copy->getDimension(), geos::geom::Dimension::L);
+    ensure_equals(copy->getBoundaryDimension(), geos::geom::Dimension::P);
+    ensure_equals(copy->getNumPoints(), size);
+    ensure_equals(copy->getArea(), 0.0);
+    ensure(copy->getLength() != 0.0);
+}
+
+// Test of isClosed() and isRing() for empty linestring
+template<>
+template<>
+void object::test<5>
+()
+{
+    ensure(!empty_line_->isClosed());
+    ensure(!empty_line_->isRing());
+}
+
+// Test of getEnvelope() for empty linestring
+template<>
+template<>
+void object::test<6>
+()
+{
+    GeometryPtr geo = nullptr;
+    geo = empty_line_->getEnvelope();
+    ensure(geo != nullptr);
+    ensure(geo->isEmpty());
+    factory_->destroyGeometry(geo);
+}
+
+// Test of getBoundary() for empty linestring
+template<>
+template<>
+void object::test<7>
+()
+{
+    GeometryPtr geo = nullptr;
+    geo = empty_line_->getBoundary();
+    ensure(geo != nullptr);
+    ensure(geo->isEmpty());
+    factory_->destroyGeometry(geo);
+}
+
+// Test of convexHull() for empty linestring
+template<>
+template<>
+void object::test<8>
+()
+{
+    GeometryPtr geo = nullptr;
+    geo = empty_line_->convexHull();
+    ensure(geo != nullptr);
+    ensure(geo->isEmpty());
+    factory_->destroyGeometry(geo);
+}
+
+// Test of getGeometryTypeId() for empty linestring
+template<>
+template<>
+void object::test<9>
+()
+{
+    ensure_equals(empty_line_->getGeometryTypeId(), geos::geom::GEOS_LINESTRING);
+}
+
+// Test of getDimension() for empty linestring
+template<>
+template<>
+void object::test<10>
+()
+{
+    ensure_equals(empty_line_->getDimension(), geos::geom::Dimension::L);
+}
+
+// Test of getBoundaryDimension() for empty linestring
+template<>
+template<>
+void object::test<11>
+()
+{
+    ensure_equals(empty_line_->getBoundaryDimension(), geos::geom::Dimension::P);
+}
+
+// Test of getNumPoints() for empty linestring
+template<>
+template<>
+void object::test<12>
+()
+{
+    ensure_equals(empty_line_->getNumPoints(), 0u);
+}
+
+// Test of getLength() for empty linestring
+template<>
+template<>
+void object::test<13>
+()
+{
+    ensure_equals(empty_line_->getLength(), 0.0);
+}
+
+// Test of getArea() for empty linestring
+template<>
+template<>
+void object::test<14>
+()
+{
+    ensure_equals(empty_line_->getArea(), 0.0);
+}
+
+// Test of isClosed() and isRing() for non-empty linestring
+template<>
+template<>
+void object::test<15>
+()
+{
+    GeometryPtr geo = reader_.read("LINESTRING (0 0, 5 5, 10 5, 10 10)");
+    ensure(geo != nullptr);
+
+    LineStringPtr line = dynamic_cast<LineStringPtr>(geo);
+    ensure(line != nullptr);
+
+    ensure(!line->isEmpty());
+    ensure(!line->isClosed());
+    ensure(!line->isRing());
+    ensure(line->getCoordinateDimension() == 2);
+
+    // FREE TESTED LINESTRING
+    factory_->destroyGeometry(line);
+}
+
+// Test of getEnvelope() for non-empty linestring
+template<>
+template<>
+void object::test<16>
+()
+{
+    GeometryPtr geo = reader_.read("LINESTRING (0 0, 5 5, 10 5, 10 10)");
+    ensure(geo != nullptr);
+
+    LineStringPtr line = dynamic_cast<LineStringPtr>(geo);
+    ensure(line != nullptr);
+
+    GeometryPtr envelope = line->getEnvelope();
+    ensure(envelope != nullptr);
+    ensure(!envelope->isEmpty());
+    ensure_equals(envelope->getDimension(), geos::geom::Dimension::A);
+
+    factory_->destroyGeometry(envelope);
+
+    // FREE TESTED LINESTRING
+    factory_->destroyGeometry(line);
+}
+
+// Test of getBoundary() for non-empty linestring
+template<>
+template<>
+void object::test<17>
+()
+{
+    GeometryPtr geo = reader_.read("LINESTRING (0 0, 5 5, 10 5, 10 10)");
+    ensure(geo != nullptr);
+
+    LineStringPtr line = dynamic_cast<LineStringPtr>(geo);
+    ensure(line != nullptr);
+
+    GeometryPtr boundary = line->getBoundary();
+    ensure(boundary != nullptr);
+    ensure(!boundary->isEmpty());
+    ensure_equals(boundary->getGeometryTypeId(), geos::geom::GEOS_MULTIPOINT);
+    ensure_equals(boundary->getDimension(), geos::geom::Dimension::P);
+    factory_->destroyGeometry(boundary);
+
+    // FREE TESTED LINESTRING
+    factory_->destroyGeometry(line);
+}
+
+// Test of convexHull() for non-empty linestring
+template<>
+template<>
+void object::test<18>
+()
+{
+    GeometryPtr geo = reader_.read("LINESTRING (0 0, 5 5, 10 5, 10 10)");
+    ensure(geo != nullptr);
+
+    LineStringPtr line = dynamic_cast<LineStringPtr>(geo);
+    ensure(line != nullptr);
+
+    GeometryPtr hull = line->convexHull();
+    ensure(hull != nullptr);
+    ensure(!hull->isEmpty());
+    ensure_equals(hull->getGeometryTypeId(), geos::geom::GEOS_POLYGON);
+    ensure_equals(hull->getDimension(), geos::geom::Dimension::A);
+    factory_->destroyGeometry(hull);
+
+    // FREE TESTED LINESTRING
+    factory_->destroyGeometry(line);
+}
+
+// Test of getGeometryTypeId() for non-empty linestring
+template<>
+template<>
+void object::test<19>
+()
+{
+    GeometryPtr geo = reader_.read("LINESTRING (0 0, 5 5, 10 5, 10 10)");
+    ensure(geo != nullptr);
+
+    ensure_equals(geo->getGeometryTypeId(), geos::geom::GEOS_LINESTRING);
+
+    // FREE TESTED LINESTRING
+    factory_->destroyGeometry(geo);
+}
+
+// Test of getDimension() for non-empty linestring
+template<>
+template<>
+void object::test<20>
+()
+{
+    GeometryPtr geo = reader_.read("LINESTRING (0 0, 5 5, 10 5, 10 10)");
+    ensure(geo != nullptr);
+
+    ensure_equals(geo->getDimension(), geos::geom::Dimension::L);
+
+    // FREE TESTED LINESTRING
+    factory_->destroyGeometry(geo);
+}
+
+// Test of getBoundaryDimension() for non-empty linestring
+template<>
+template<>
+void object::test<21>
+()
+{
+    GeometryPtr geo = reader_.read("LINESTRING (0 0, 5 5, 10 5, 10 10)");
+    ensure(geo != nullptr);
+
+    ensure_equals(geo->getBoundaryDimension(), geos::geom::Dimension::P);
+
+    // FREE TESTED LINESTRING
+    factory_->destroyGeometry(geo);
+}
+
+// Test of getNumPoints() for non-empty linestring
+template<>
+template<>
+void object::test<22>
+()
+{
+    const size_t size = 4;
+    GeometryPtr geo = reader_.read("LINESTRING (0 0, 5 5, 10 5, 10 10)");
+    ensure(geo != nullptr);
+
+    ensure_equals(geo->getNumPoints(), size);
+
+    // FREE TESTED LINESTRING
+    factory_->destroyGeometry(geo);
+}
+
+// Test of getLength() for non-empty linestring
+template<>
+template<>
+void object::test<23>
+()
+{
+    const double tolerance = 0.0001;
+    const double expected = 2 * 14.142135600000000;
+    GeometryPtr geo = reader_.read("LINESTRING (0 0, 10 10, 20 0)");
+    ensure(geo != nullptr);
+
+    ensure(geo->getLength() != 0.0);
+
+    const double diff = std::fabs(geo->getLength() - expected);
+    ensure(diff <= tolerance);
+
+    // FREE TESTED LINESTRING
+    factory_->destroyGeometry(geo);
+}
+
+// Test of getArea() for non-empty linestring
+template<>
+template<>
+void object::test<24>
+()
+{
+    GeometryPtr geo = reader_.read("LINESTRING (0 0, 10 10, 20 0)");
+    ensure(geo != nullptr);
+
+    ensure_equals(geo->getArea(), 0.0);
+
+    // FREE TESTED LINESTRING
+    factory_->destroyGeometry(geo);
+}
+
+// Test of getGeometryType() for non-empty Polygon
+template<>
+template<>
+void object::test<25>
+()
+{
+    GeometryPtr geo = reader_.read("LINESTRING (0 0, 10 10, 20 0)");
+    ensure(geo != nullptr);
+
+    const std::string type("LineString");
+    ensure_equals(geo->getGeometryType(), type);
+
+    // FREE MEMORY
+    factory_->destroyGeometry(geo);
+}
 
 } // namespace tut
 
diff --git a/tests/unit/geom/LinearRingTest.cpp b/tests/unit/geom/LinearRingTest.cpp
index 6404d8f..08717aa 100644
--- a/tests/unit/geom/LinearRingTest.cpp
+++ b/tests/unit/geom/LinearRingTest.cpp
@@ -17,425 +17,447 @@
 #include <memory>
 #include <string>
 
-namespace tut
+namespace tut {
+//
+// Test Group
+//
+
+// Common data used by tests
+struct test_linearring_data {
+    // Typedefs used as short names by test cases
+    typedef geos::geom::Geometry* GeometryPtr;
+    typedef geos::geom::Geometry const* GeometryCPtr;
+
+    typedef geos::geom::Coordinate* CoordinatePtr;
+    typedef geos::geom::Coordinate const* CoordinateCPtr;
+
+    typedef geos::geom::CoordinateArraySequence* CoordArrayPtr;
+    typedef geos::geom::CoordinateArraySequence const* CoordArrayCPtr;
+
+    typedef geos::geom::LinearRing* LinearRingPtr;
+    typedef geos::geom::LinearRing const* LinearRingCPtr;
+
+    geos::geom::PrecisionModel pm_;
+    geos::geom::GeometryFactory::Ptr factory_;
+    geos::io::WKTReader reader_;
+
+    geos::geom::LinearRing empty_ring_;
+    LinearRingPtr ring_;
+    const size_t ring_size_;
+
+    test_linearring_data()
+        : pm_(1000), factory_(geos::geom::GeometryFactory::create(&pm_, 0))
+        , reader_(factory_.get())
+        , empty_ring_(new geos::geom::CoordinateArraySequence(), factory_.get()),
+          ring_size_(7)
+    {
+        // Create non-empty LinearRing
+        GeometryPtr geo = nullptr;
+        geo = reader_.read("LINEARRING(0 10, 5 5, 10 5, 15 10, 10 15, 5 15, 0 10)");
+        ring_ = dynamic_cast<LinearRingPtr>(geo);
+    }
+
+    ~test_linearring_data()
+    {
+        factory_->destroyGeometry(ring_);
+    }
+
+private:
+    // Declare type as noncopyable
+    test_linearring_data(const test_linearring_data& other) = delete;
+    test_linearring_data& operator=(const test_linearring_data& rhs) = delete;
+};
+
+typedef test_group<test_linearring_data> group;
+typedef group::object object;
+
+group test_linearring_group("geos::geom::LinearRing");
+
+//
+// Test Cases
+//
+
+// Test of user's constructor to create non-empty LinearRing
+template<>
+template<>
+void object::test<1>
+()
+{
+    using geos::geom::Coordinate;
+
+    // Non-empty sequence of coordiantes
+    const size_t size7 = 7;
+    CoordArrayPtr coords = new geos::geom::CoordinateArraySequence();
+    ensure("sequence is null pointer.", coords != nullptr);
+
+    coords->add(Coordinate(0, 10));
+    coords->add(Coordinate(5, 5));
+    coords->add(Coordinate(10, 5));
+    coords->add(Coordinate(15, 10));
+    coords->add(Coordinate(10, 15));
+    coords->add(Coordinate(5, 15));
+    coords->add(Coordinate(0, 10));
+
+    ensure_equals(coords->size(), size7);
+
+    try {
+        // Create non-empty linearring instance
+        geos::geom::LinearRing ring(coords, factory_.get());
+        ensure(!ring.isEmpty());
+        ensure(ring.isClosed());
+        ensure(ring.isRing());
+        ensure(ring.isSimple());
+        ensure(ring.isValid());
+        //ensure_equals( rint.getNumPoints(), 7u );
+    }
+    catch(geos::util::IllegalArgumentException const& e) {
+        fail(e.what());
+    }
+}
+
+// Test of copy contructor
+template<>
+template<>
+void object::test<2>
+()
+{
+    geos::geom::LinearRing copy(empty_ring_);
+
+    ensure(copy.isEmpty());
+}
+
+// Test of isEmpty() for empty LinearRing
+template<>
+template<>
+void object::test<3>
+()
+{
+    ensure(empty_ring_.isEmpty());
+}
+
+// Test of isClosed() for empty LinearRing
+template<>
+template<>
+void object::test<4>
+()
+{
+    ensure(empty_ring_.isClosed());
+}
+
+// Test of isRing() for empty LinearRing
+template<>
+template<>
+void object::test<5>
+()
+{
+    ensure(empty_ring_.isRing());
+}
+
+// Test of isSimple() for empty LinearRing
+template<>
+template<>
+void object::test<6>
+()
+{
+    ensure(empty_ring_.isSimple());
+}
+
+// Test of isValid() for empty LinearRing
+template<>
+template<>
+void object::test<7>
+()
+{
+    ensure(empty_ring_.isValid());
+}
+
+
+// Test of getEnvelope() for empty LinearRing
+template<>
+template<>
+void object::test<8>
+()
+{
+    GeometryPtr envelope = empty_ring_.getEnvelope();
+    ensure(envelope != nullptr);
+    ensure(envelope->isEmpty());
+    factory_->destroyGeometry(envelope);
+}
+
+// Test of getBoundary() for empty LinearRing
+template<>
+template<>
+void object::test<9>
+()
+{
+    GeometryPtr boundary = empty_ring_.getBoundary();
+    ensure(boundary != nullptr);
+    ensure(boundary->isEmpty());
+    factory_->destroyGeometry(boundary);
+}
+
+// Test of convexHull() for empty LinearRing
+template<>
+template<>
+void object::test<10>
+()
+{
+    GeometryPtr hull = empty_ring_.convexHull();
+    ensure(hull != nullptr);
+    ensure(hull->isEmpty());
+    factory_->destroyGeometry(hull);
+}
+
+// Test of getGeometryTypeId() for empty LinearRing
+template<>
+template<>
+void object::test<11>
+()
+{
+    ensure_equals(empty_ring_.getGeometryTypeId(), geos::geom::GEOS_LINEARRING);
+}
+
+// Test of getDimension() for empty LinearRing
+template<>
+template<>
+void object::test<12>
+()
+{
+    ensure_equals(empty_ring_.getDimension(), geos::geom::Dimension::L);
+}
+
+// Test of getBoundaryDimension() for empty LinearRing
+template<>
+template<>
+void object::test<13>
+()
 {
-	//
-	// Test Group
-	//
-
-	// Common data used by tests
-	struct test_linearring_data
-	{
-		// Typedefs used as short names by test cases
-		typedef geos::geom::Geometry* GeometryPtr;
-		typedef geos::geom::Geometry const* GeometryCPtr;
-
-		typedef geos::geom::Coordinate* CoordinatePtr;
-		typedef geos::geom::Coordinate const* CoordinateCPtr;
-
-		typedef geos::geom::CoordinateArraySequence* CoordArrayPtr;
-		typedef geos::geom::CoordinateArraySequence const* CoordArrayCPtr;
-
-		typedef geos::geom::LinearRing* LinearRingPtr;
-		typedef geos::geom::LinearRing const* LinearRingCPtr;
-
-		geos::geom::PrecisionModel pm_;
-		geos::geom::GeometryFactory::Ptr factory_;
-		geos::io::WKTReader reader_;
-
-		geos::geom::LinearRing empty_ring_;
-		LinearRingPtr ring_;
-		const size_t ring_size_;
-
-		test_linearring_data()
-			: pm_(1000), factory_(geos::geom::GeometryFactory::create(&pm_, 0))
-      , reader_(factory_.get())
-      , empty_ring_(new geos::geom::CoordinateArraySequence(), factory_.get()),
-			ring_size_(7)
-		{
-			// Create non-empty LinearRing
-			GeometryPtr geo = nullptr;
-			geo = reader_.read("LINEARRING(0 10, 5 5, 10 5, 15 10, 10 15, 5 15, 0 10)");
-			ring_ = dynamic_cast<LinearRingPtr>(geo);
-		}
-
-		~test_linearring_data()
-		{
-			factory_->destroyGeometry(ring_);
-        }
-
-    private:
-        // Declare type as noncopyable
-        test_linearring_data(const test_linearring_data& other) = delete;
-        test_linearring_data& operator=(const test_linearring_data& rhs) = delete;
-	};
-
-	typedef test_group<test_linearring_data> group;
-	typedef group::object object;
-
-	group test_linearring_group("geos::geom::LinearRing");
-
-	//
-	// Test Cases
-	//
-
-	// Test of user's constructor to create non-empty LinearRing
-	template<>
-	template<>
-	void object::test<1>()
-	{
-		using geos::geom::Coordinate;
-
-		// Non-empty sequence of coordiantes
-		const size_t size7 = 7;
-		CoordArrayPtr coords = new geos::geom::CoordinateArraySequence();
-		ensure( "sequence is null pointer.", coords != nullptr );
-
-		coords->add(Coordinate(0, 10));
-		coords->add(Coordinate(5, 5));
-		coords->add(Coordinate(10, 5));
-		coords->add(Coordinate(15, 10));
-		coords->add(Coordinate(10, 15));
-		coords->add(Coordinate(5, 15));
-		coords->add(Coordinate(0, 10));
-
-		ensure_equals( coords->size(), size7 );
-
-		try
-		{
-			// Create non-empty linearring instance
-			geos::geom::LinearRing ring(coords, factory_.get());
-			ensure( !ring.isEmpty() );
-			ensure( ring.isClosed() );
-			ensure( ring.isRing() );
-			ensure( ring.isSimple() );
-			ensure( ring.isValid() );
-			//ensure_equals( rint.getNumPoints(), 7u );
-		}
-		catch (geos::util::IllegalArgumentException const& e)
-		{
-			fail(e.what());
-		}
-	}
-
-	// Test of copy contructor
-	template<>
-	template<>
-	void object::test<2>()
-	{
-		geos::geom::LinearRing copy(empty_ring_);
-
-		ensure( copy.isEmpty() );
-	}
-
-	// Test of isEmpty() for empty LinearRing
-	template<>
-	template<>
-	void object::test<3>()
-	{
-		ensure( empty_ring_.isEmpty() );
-	}
-
-	// Test of isClosed() for empty LinearRing
-	template<>
-	template<>
-	void object::test<4>()
-	{
-		ensure( empty_ring_.isClosed() );
-	}
-
-	// Test of isRing() for empty LinearRing
-	template<>
-	template<>
-	void object::test<5>()
-	{
-		ensure( empty_ring_.isRing() );
-	}
-
-	// Test of isSimple() for empty LinearRing
-	template<>
-	template<>
-	void object::test<6>()
-	{
-		ensure( empty_ring_.isSimple() );
-	}
-
-	// Test of isValid() for empty LinearRing
-	template<>
-	template<>
-	void object::test<7>()
-	{
-		ensure( empty_ring_.isValid() );
-	}
-
-
-	// Test of getEnvelope() for empty LinearRing
-	template<>
-	template<>
-	void object::test<8>()
-	{
-		GeometryPtr envelope = empty_ring_.getEnvelope();
-		ensure( envelope != nullptr );
-		ensure( envelope->isEmpty() );
-		factory_->destroyGeometry(envelope);
-	}
-
-	// Test of getBoundary() for empty LinearRing
-	template<>
-	template<>
-	void object::test<9>()
-	{
-		GeometryPtr boundary = empty_ring_.getBoundary();
-		ensure( boundary != nullptr );
-		ensure( boundary->isEmpty() );
-		factory_->destroyGeometry(boundary);
-	}
-
-	// Test of convexHull() for empty LinearRing
-	template<>
-	template<>
-	void object::test<10>()
-	{
-		GeometryPtr hull = empty_ring_.convexHull();
-		ensure( hull != nullptr );
-		ensure( hull->isEmpty() );
-		factory_->destroyGeometry(hull);
-	}
-
-	// Test of getGeometryTypeId() for empty LinearRing
-	template<>
-	template<>
-	void object::test<11>()
-	{
-		ensure_equals( empty_ring_.getGeometryTypeId(), geos::geom::GEOS_LINEARRING );
-	}
-
-	// Test of getDimension() for empty LinearRing
-	template<>
-	template<>
-	void object::test<12>()
-	{
-		ensure_equals( empty_ring_.getDimension(), geos::geom::Dimension::L );
-	}
-
-	// Test of getBoundaryDimension() for empty LinearRing
-	template<>
-	template<>
-	void object::test<13>()
-	{
-		ensure_equals( empty_ring_.getBoundaryDimension(), geos::geom::Dimension::False );
-	}
-
-	// Test of getNumPoints() for empty LinearRing
-	template<>
-	template<>
-	void object::test<14>()
-	{
-		ensure_equals( empty_ring_.getNumPoints(), 0u );
-	}
-
-	// Test of getLength() for empty LinearRing
-	template<>
-	template<>
-	void object::test<15>()
-	{
-		ensure_equals( empty_ring_.getLength(), 0.0 );
-	}
-
-	// Test of getArea() for empty LinearRing
-	template<>
-	template<>
-	void object::test<16>()
-	{
-		ensure_equals( empty_ring_.getArea(), 0.0 );
-	}
-
-    // Test of isEmpty() for non-empty LinearRing
-    template<>
-    template<>
-    void object::test<17>()
-	{
-		ensure(ring_ != nullptr);
-		ensure( !ring_->isEmpty() );
-	}
-
-    // Test of isClosed() and isRing() for non-empty LinearRing
-    template<>
-    template<>
-    void object::test<18>()
-	{
-		ensure(ring_ != nullptr);
-		ensure( ring_->isClosed() );
-		ensure( ring_->isRing() );
-	}
-
-    // Test of getEnvelope() for non-empty LinearRing
-    template<>
-    template<>
-    void object::test<19>()
-	{
-		ensure(ring_ != nullptr);
-
-		GeometryPtr envelope = ring_->getEnvelope();
-		ensure( envelope != nullptr );
-		ensure( !envelope->isEmpty() );
-		ensure_equals( envelope->getDimension(), geos::geom::Dimension::A );
-
-		// FREE MEMORY
-		factory_->destroyGeometry(envelope);
-	}
-
-	// Test of getBoundary() for non-empty LinearRing
-    template<>
-    template<>
-    void object::test<20>()
-	{
-		ensure(ring_ != nullptr);
-
-		GeometryPtr boundary = ring_->getBoundary();
-		ensure( boundary != nullptr );
-
-		// OGC 05-126, Version: 1.1.0, Chapter 6.1.6 Curve
-		ensure( "[OGC] The boundary of a closed Curve must be empty.", boundary->isEmpty() );
-
-		// FREE MEMORY
-		factory_->destroyGeometry(boundary);
-	}
-
-	// Test of convexHull() for non-empty LinearRing
-    template<>
-    template<>
-    void object::test<21>()
-	{
-		ensure(ring_ != nullptr);
-
-		GeometryPtr hull = ring_->convexHull();
-		ensure( hull != nullptr );
-		ensure( !hull->isEmpty() );
-		ensure_equals( hull->getGeometryTypeId(), geos::geom::GEOS_POLYGON );
-		ensure_equals( hull->getDimension(), geos::geom::Dimension::A );
-
-		// FREE MEMORY
-		factory_->destroyGeometry(hull);
-	}
-
-	// Test of getGeometryTypeId() for non-empty LinearRing
-    template<>
-    template<>
-    void object::test<22>()
-	{
-		ensure(ring_ != nullptr);
-		ensure_equals( ring_->getGeometryTypeId(), geos::geom::GEOS_LINEARRING );
-	}
-
-	// Test of getDimension() for non-empty LinearRing
-    template<>
-    template<>
-    void object::test<23>()
-	{
-		ensure(ring_ != nullptr);
-		ensure_equals( ring_->getDimension(), geos::geom::Dimension::L );
-	}
-
-	// Test of getBoundaryDimension() for non-empty LinearRing
-    template<>
-    template<>
-    void object::test<24>()
-	{
-		ensure(ring_ != nullptr);
-		ensure_equals( ring_->getBoundaryDimension(), geos::geom::Dimension::False );
-	}
-
-	// Test of getNumPoints() for non-empty LinearRing
-    template<>
-    template<>
-    void object::test<25>()
-	{
-		ensure(ring_ != nullptr);
-		ensure_equals( ring_->getNumPoints(), ring_size_ );
-	}
-
-	// Test of getLength() for non-empty LinearRing
-    template<>
-    template<>
-    void object::test<26>()
-	{
-		ensure(ring_ != nullptr);
-		ensure( ring_->getLength() != 0.0 );
-
-		const double tolerance = 0.0001;
-		const double expected = 38.284271247461902;
-		const double diff = std::fabs(ring_->getLength() - expected);
-		ensure( diff <= tolerance );
-	}
-
-	// Test of getArea() for non-empty LinearRing
-    template<>
-    template<>
-    void object::test<27>()
-	{
-		ensure(ring_ != nullptr);
-		ensure_equals( ring_->getArea(), 0.0 );
-	}
-
-	// Test of exception thrown when constructing non-empty and non-closed LinearRing
-    template<>
-	template<>
-	void object::test<28>()
-	{
-		try
-		{
-			GeometryPtr geo = reader_.read("LINEARRING(0 0, 5 5, 10 10)");
-			ensure(geo != nullptr);
-
-			// FREE TESTED LINEARRING
-			factory_->destroyGeometry(geo);
-
-			fail("IllegalArgumentException expected.");
-		}
-		catch (geos::util::IllegalArgumentException const& e)
-		{
-			const char* msg = e.what(); // ok
-			ensure( msg != nullptr );
-		}
-	}
-
-	// TTest of exception thrown when constructing a self-intersecting LinearRing
-	template<>
-	template<>
-	void object::test<29>()
-	{
-		try
-		{
-			// Construct LinearRing self-intersecting in point (5,5)
-			GeometryPtr geo = reader_.read("LINEARRING(0 0, 5 5, 10 10, 15 5, 5 5, 0 10)");
-			ensure(geo != nullptr);
-
-			LinearRingPtr ring = dynamic_cast<LinearRingPtr>(geo);
-			ensure(ring != nullptr);
-
-			ensure( !ring->isValid() );
-
-			// FREE TESTED LINEARRING
-			factory_->destroyGeometry(geo);
-
-			fail("IllegalArgumentException expected.");
-		}
-		catch (geos::util::IllegalArgumentException const& e)
-		{
-			const char* msg = e.what(); // ok
-			ensure( msg != nullptr );
-		}
-	}
-
-	// Test of getGeometryType() for non-empty LinearRing
-    template<>
-    template<>
-    void object::test<30>()
-	{
-		ensure( ring_ != nullptr );
-
-		const std::string type("LinearRing");
-		ensure_equals( ring_->getGeometryType(), type );
-	}
+    ensure_equals(empty_ring_.getBoundaryDimension(), geos::geom::Dimension::False);
+}
+
+// Test of getNumPoints() for empty LinearRing
+template<>
+template<>
+void object::test<14>
+()
+{
+    ensure_equals(empty_ring_.getNumPoints(), 0u);
+}
+
+// Test of getLength() for empty LinearRing
+template<>
+template<>
+void object::test<15>
+()
+{
+    ensure_equals(empty_ring_.getLength(), 0.0);
+}
+
+// Test of getArea() for empty LinearRing
+template<>
+template<>
+void object::test<16>
+()
+{
+    ensure_equals(empty_ring_.getArea(), 0.0);
+}
+
+// Test of isEmpty() for non-empty LinearRing
+template<>
+template<>
+void object::test<17>
+()
+{
+    ensure(ring_ != nullptr);
+    ensure(!ring_->isEmpty());
+}
+
+// Test of isClosed() and isRing() for non-empty LinearRing
+template<>
+template<>
+void object::test<18>
+()
+{
+    ensure(ring_ != nullptr);
+    ensure(ring_->isClosed());
+    ensure(ring_->isRing());
+}
+
+// Test of getEnvelope() for non-empty LinearRing
+template<>
+template<>
+void object::test<19>
+()
+{
+    ensure(ring_ != nullptr);
+
+    GeometryPtr envelope = ring_->getEnvelope();
+    ensure(envelope != nullptr);
+    ensure(!envelope->isEmpty());
+    ensure_equals(envelope->getDimension(), geos::geom::Dimension::A);
+
+    // FREE MEMORY
+    factory_->destroyGeometry(envelope);
+}
+
+// Test of getBoundary() for non-empty LinearRing
+template<>
+template<>
+void object::test<20>
+()
+{
+    ensure(ring_ != nullptr);
+
+    GeometryPtr boundary = ring_->getBoundary();
+    ensure(boundary != nullptr);
+
+    // OGC 05-126, Version: 1.1.0, Chapter 6.1.6 Curve
+    ensure("[OGC] The boundary of a closed Curve must be empty.", boundary->isEmpty());
+
+    // FREE MEMORY
+    factory_->destroyGeometry(boundary);
+}
+
+// Test of convexHull() for non-empty LinearRing
+template<>
+template<>
+void object::test<21>
+()
+{
+    ensure(ring_ != nullptr);
+
+    GeometryPtr hull = ring_->convexHull();
+    ensure(hull != nullptr);
+    ensure(!hull->isEmpty());
+    ensure_equals(hull->getGeometryTypeId(), geos::geom::GEOS_POLYGON);
+    ensure_equals(hull->getDimension(), geos::geom::Dimension::A);
+
+    // FREE MEMORY
+    factory_->destroyGeometry(hull);
+}
+
+// Test of getGeometryTypeId() for non-empty LinearRing
+template<>
+template<>
+void object::test<22>
+()
+{
+    ensure(ring_ != nullptr);
+    ensure_equals(ring_->getGeometryTypeId(), geos::geom::GEOS_LINEARRING);
+}
+
+// Test of getDimension() for non-empty LinearRing
+template<>
+template<>
+void object::test<23>
+()
+{
+    ensure(ring_ != nullptr);
+    ensure_equals(ring_->getDimension(), geos::geom::Dimension::L);
+}
+
+// Test of getBoundaryDimension() for non-empty LinearRing
+template<>
+template<>
+void object::test<24>
+()
+{
+    ensure(ring_ != nullptr);
+    ensure_equals(ring_->getBoundaryDimension(), geos::geom::Dimension::False);
+}
+
+// Test of getNumPoints() for non-empty LinearRing
+template<>
+template<>
+void object::test<25>
+()
+{
+    ensure(ring_ != nullptr);
+    ensure_equals(ring_->getNumPoints(), ring_size_);
+}
+
+// Test of getLength() for non-empty LinearRing
+template<>
+template<>
+void object::test<26>
+()
+{
+    ensure(ring_ != nullptr);
+    ensure(ring_->getLength() != 0.0);
+
+    const double tolerance = 0.0001;
+    const double expected = 38.284271247461902;
+    const double diff = std::fabs(ring_->getLength() - expected);
+    ensure(diff <= tolerance);
+}
+
+// Test of getArea() for non-empty LinearRing
+template<>
+template<>
+void object::test<27>
+()
+{
+    ensure(ring_ != nullptr);
+    ensure_equals(ring_->getArea(), 0.0);
+}
+
+// Test of exception thrown when constructing non-empty and non-closed LinearRing
+template<>
+template<>
+void object::test<28>
+()
+{
+    try {
+        GeometryPtr geo = reader_.read("LINEARRING(0 0, 5 5, 10 10)");
+        ensure(geo != nullptr);
+
+        // FREE TESTED LINEARRING
+        factory_->destroyGeometry(geo);
+
+        fail("IllegalArgumentException expected.");
+    }
+    catch(geos::util::IllegalArgumentException const& e) {
+        const char* msg = e.what(); // ok
+        ensure(msg != nullptr);
+    }
+}
+
+// TTest of exception thrown when constructing a self-intersecting LinearRing
+template<>
+template<>
+void object::test<29>
+()
+{
+    try {
+        // Construct LinearRing self-intersecting in point (5,5)
+        GeometryPtr geo = reader_.read("LINEARRING(0 0, 5 5, 10 10, 15 5, 5 5, 0 10)");
+        ensure(geo != nullptr);
+
+        LinearRingPtr ring = dynamic_cast<LinearRingPtr>(geo);
+        ensure(ring != nullptr);
+
+        ensure(!ring->isValid());
+
+        // FREE TESTED LINEARRING
+        factory_->destroyGeometry(geo);
+
+        fail("IllegalArgumentException expected.");
+    }
+    catch(geos::util::IllegalArgumentException const& e) {
+        const char* msg = e.what(); // ok
+        ensure(msg != nullptr);
+    }
+}
+
+// Test of getGeometryType() for non-empty LinearRing
+template<>
+template<>
+void object::test<30>
+()
+{
+    ensure(ring_ != nullptr);
+
+    const std::string type("LinearRing");
+    ensure_equals(ring_->getGeometryType(), type);
+}
 } // namespace tut
diff --git a/tests/unit/geom/LocationTest.cpp b/tests/unit/geom/LocationTest.cpp
index 05ab483..cdde19d 100644
--- a/tests/unit/geom/LocationTest.cpp
+++ b/tests/unit/geom/LocationTest.cpp
@@ -7,77 +7,76 @@
 #include <geos/geom/Location.h>
 #include <geos/util/IllegalArgumentException.h>
 
-namespace tut
-{
-    //
-    // Test Group
-    //
+namespace tut {
+//
+// Test Group
+//
 
-    // Common data used by tests
-    struct test_location_data
-    {
-		int undef;
-		int interior;
-		int boundary;
-		int exterior;
-		test_location_data()
-			: undef(geos::geom::Location::UNDEF),
-			interior(geos::geom::Location::INTERIOR),
-			boundary(geos::geom::Location::BOUNDARY),
-			exterior(geos::geom::Location::EXTERIOR)
-		{}
-	};
+// Common data used by tests
+struct test_location_data {
+    int undef;
+    int interior;
+    int boundary;
+    int exterior;
+    test_location_data()
+        : undef(geos::geom::Location::UNDEF),
+          interior(geos::geom::Location::INTERIOR),
+          boundary(geos::geom::Location::BOUNDARY),
+          exterior(geos::geom::Location::EXTERIOR)
+    {}
+};
 
-    typedef test_group<test_location_data> group;
-    typedef group::object object;
+typedef test_group<test_location_data> group;
+typedef group::object object;
 
-    group test_location_group("geos::geom::Location");
+group test_location_group("geos::geom::Location");
 
-    //
-    // Test Cases
-    //
+//
+// Test Cases
+//
 
-    // Test of default constructor
-    template<>
-    template<>
-    void object::test<1>()
-    {
-		ensure("NOTE: Location has no default constructor.", true);
-    }
+// Test of default constructor
+template<>
+template<>
+void object::test<1>
+()
+{
+    ensure("NOTE: Location has no default constructor.", true);
+}
 
-    // Test of toLocationSymbol()
-    template<>
-    template<>
-    void object::test<2>()
-    {
-		using geos::geom::Location;
+// Test of toLocationSymbol()
+template<>
+template<>
+void object::test<2>
+()
+{
+    using geos::geom::Location;
 
-		ensure_equals( Location::toLocationSymbol(exterior), 'e' );
-		ensure_equals( Location::toLocationSymbol(boundary), 'b' );
-		ensure_equals( Location::toLocationSymbol(interior), 'i' );
-		ensure_equals( Location::toLocationSymbol(undef), '-' );
-    }
+    ensure_equals(Location::toLocationSymbol(exterior), 'e');
+    ensure_equals(Location::toLocationSymbol(boundary), 'b');
+    ensure_equals(Location::toLocationSymbol(interior), 'i');
+    ensure_equals(Location::toLocationSymbol(undef), '-');
+}
 
-    // Test of toLocationSymbol() throwing IllegalArgumentException
-    template<>
-    template<>
-    void object::test<3>()
-    {
-		using geos::geom::Location;
+// Test of toLocationSymbol() throwing IllegalArgumentException
+template<>
+template<>
+void object::test<3>
+()
+{
+    using geos::geom::Location;
 
-		try
-		{
-			Location::toLocationSymbol(101);
-			Location::toLocationSymbol(-101);
+    try {
+        Location::toLocationSymbol(101);
+        Location::toLocationSymbol(-101);
 
-			fail("IllegalArgumentException expected");
-		}
-		catch ( geos::util::IllegalArgumentException const& e )
-		{
-			const char* msg = e.what(); // ok
-			ensure( msg != nullptr );
-		}
+        fail("IllegalArgumentException expected");
+    }
+    catch(geos::util::IllegalArgumentException const& e) {
+        const char* msg = e.what(); // ok
+        ensure(msg != nullptr);
     }
+}
 
 } // namespace tut
 
diff --git a/tests/unit/geom/MultiLineStringTest.cpp b/tests/unit/geom/MultiLineStringTest.cpp
index eb2d117..0d25f87 100644
--- a/tests/unit/geom/MultiLineStringTest.cpp
+++ b/tests/unit/geom/MultiLineStringTest.cpp
@@ -5,34 +5,33 @@
 // geos
 #include <geos/geom/MultiLineString.h>
 
-namespace tut
+namespace tut {
+//
+// Test Group
+//
+
+// Common data used by tests
+struct test_multilinestring_data {
+    test_multilinestring_data() {}
+};
+
+typedef test_group<test_multilinestring_data> group;
+typedef group::object object;
+
+group test_multilinestring_group("geos::geom::MultiLineString");
+
+//
+// Test Cases
+//
+
+// Test of default constructor
+template<>
+template<>
+void object::test<1>
+()
 {
-    //
-    // Test Group
-    //
-
-    // Common data used by tests
-    struct test_multilinestring_data
-    {
-        test_multilinestring_data() {}
-    };
-
-    typedef test_group<test_multilinestring_data> group;
-    typedef group::object object;
-
-    group test_multilinestring_group("geos::geom::MultiLineString");
-
-    //
-    // Test Cases
-    //
-
-    // Test of default constructor
-    template<>
-    template<>
-    void object::test<1>()
-    {
-	    //inform("Test not implemented!");
-    }
+    //inform("Test not implemented!");
+}
 
 } // namespace tut
 
diff --git a/tests/unit/geom/MultiPointTest.cpp b/tests/unit/geom/MultiPointTest.cpp
index 0416c80..f6a9751 100644
--- a/tests/unit/geom/MultiPointTest.cpp
+++ b/tests/unit/geom/MultiPointTest.cpp
@@ -15,370 +15,394 @@
 // std
 #include <cmath>
 
-namespace tut
+namespace tut {
+//
+// Test Group
+//
+
+// Common data used by tests
+struct test_multipoint_data {
+    typedef std::unique_ptr<geos::geom::MultiPoint> MultiPointAutoPtr;
+    typedef geos::geom::GeometryFactory GeometryFactory;
+
+    geos::geom::PrecisionModel pm_;
+    geos::geom::GeometryFactory::Ptr factory_;
+    geos::io::WKTReader reader_;
+
+    MultiPointAutoPtr empty_mp_;
+    MultiPointPtr mp_;
+    const size_t mp_size_;
+
+    test_multipoint_data()
+        :
+        pm_(1.0), factory_(GeometryFactory::create(&pm_, 0))
+        , reader_(factory_.get())
+        , empty_mp_(factory_->createMultiPoint()), mp_size_(5)
+    {
+        // Create non-empty MultiPoint
+        GeometryPtr geo = nullptr;
+        geo = reader_.read("MULTIPOINT(0 0, 5 5, 10 10, 15 15, 20 20)");
+        mp_ = dynamic_cast<MultiPointPtr>(geo);
+    }
+
+    ~test_multipoint_data()
+    {
+        factory_->destroyGeometry(mp_);
+    }
+
+private:
+    // Declare type as noncopyable
+    test_multipoint_data(const test_multipoint_data& other) = delete;
+    test_multipoint_data& operator=(const test_multipoint_data& rhs) = delete;
+};
+
+typedef test_group<test_multipoint_data> group;
+typedef group::object object;
+
+group test_multipoint_group("geos::geom::MultiPoint");
+
+//
+// Test Cases
+//
+
+// Test of user's constructor
+template<>
+template<>
+void object::test<1>
+()
+{
+    const size_t size0 = 0;
+    MultiPointAutoPtr mp(factory_->createMultiPoint());
+
+    ensure(mp->isEmpty());
+    ensure(mp->isSimple());
+    ensure(mp->isValid());
+    ensure(mp->getCentroid() == nullptr);
+    ensure_equals(mp->getNumPoints(), size0);
+    ensure_equals(mp->getNumGeometries(), size0);
+}
+
+// Test of copy constructor
+template<>
+template<>
+void object::test<2>
+()
+{
+    const size_t size0 = 0;
+    MultiPointAutoPtr copy(dynamic_cast<geos::geom::MultiPoint*>(empty_mp_->clone()));
+    ensure(nullptr != copy.get());
+
+    ensure(copy->isEmpty());
+    ensure(copy->isSimple());
+    ensure(copy->isValid());
+    ensure(copy->getCentroid() == nullptr);
+    ensure_equals(copy->getNumPoints(), size0);
+    ensure_equals(copy->getNumGeometries(), size0);
+}
+
+// Test of empty MultiPoint constructed by WKTReader
+template<>
+template<>
+void object::test<3>
+()
+{
+    const size_t size0 = 0;
+    GeometryPtr geo = reader_.read("MULTIPOINT EMPTY");
+    MultiPointPtr mp = dynamic_cast<MultiPointPtr>(geo);
+
+    ensure(mp->isEmpty());
+    ensure(mp->isSimple());
+    ensure(mp->isValid());
+    ensure(mp->getCentroid() == nullptr);
+    ensure_equals(mp->getNumPoints(), size0);
+    ensure_equals(mp->getNumGeometries(), size0);
+
+    // FREE MEMORY
+    factory_->destroyGeometry(geo);
+}
+
+// Test of isEmpty() for empty MultiPoint
+template<>
+template<>
+void object::test<4>
+()
+{
+    ensure(empty_mp_->isEmpty());
+}
+
+// Test of isSimple() for empty MultiPoint
+template<>
+template<>
+void object::test<5>
+()
+{
+    ensure(empty_mp_->isSimple());
+}
+
+// Test of isValid() for empty MultiPoint
+template<>
+template<>
+void object::test<6>
+()
+{
+    ensure(empty_mp_->isValid());
+}
+
+// Test of getEnvelope() for empty MultiPoint
+template<>
+template<>
+void object::test<7>
+()
+{
+    GeometryPtr envelope = empty_mp_->getEnvelope();
+    ensure(envelope != nullptr);
+    ensure(envelope->isEmpty());
+    factory_->destroyGeometry(envelope);
+}
+
+// Test of getBoundary() for empty MultiPoint
+template<>
+template<>
+void object::test<8>
+()
+{
+    GeometryPtr boundary = empty_mp_->getBoundary();
+    ensure(boundary != nullptr);
+    ensure(boundary->isEmpty());
+    factory_->destroyGeometry(boundary);
+}
+
+// Test of convexHull() for empty MultiPoint
+template<>
+template<>
+void object::test<9>
+()
+{
+    GeometryPtr hull = empty_mp_->convexHull();
+    ensure(hull != nullptr);
+    ensure(hull->isEmpty());
+    factory_->destroyGeometry(hull);
+}
+
+// Test of getGeometryTypeId() for empty MultiPoint
+template<>
+template<>
+void object::test<10>
+()
+{
+    ensure_equals(empty_mp_->getGeometryTypeId(), geos::geom::GEOS_MULTIPOINT);
+}
+
+// Test of getGeometryType() for empty MultiPoint
+template<>
+template<>
+void object::test<11>
+()
+{
+    const std::string type("MultiPoint");
+    ensure_equals(empty_mp_->getGeometryType(), type);
+}
+
+// Test of getDimension() for empty MultiPoint
+template<>
+template<>
+void object::test<12>
+()
+{
+    ensure_equals(empty_mp_->getDimension(), geos::geom::Dimension::P);
+}
+
+// Test of getBoundaryDimension() for empty MultiPoint
+template<>
+template<>
+void object::test<13>
+()
+{
+    ensure_equals(empty_mp_->getBoundaryDimension(), geos::geom::Dimension::False);
+}
+
+// Test of getNumPoints() for empty MultiPoint
+template<>
+template<>
+void object::test<14>
+()
+{
+    ensure_equals(empty_mp_->getNumPoints(), 0u);
+}
+
+// Test of getLength() for empty MultiPoint
+template<>
+template<>
+void object::test<15>
+()
+{
+    ensure_equals(empty_mp_->getLength(), 0.0);
+}
+
+// Test of getArea() for empty MultiPoint
+template<>
+template<>
+void object::test<16>
+()
+{
+    ensure_equals(empty_mp_->getArea(), 0.0);
+}
+
+// Test of isEmpty() for non-empty LinearRing
+template<>
+template<>
+void object::test<17>
+()
+{
+    ensure(mp_ != nullptr);
+    ensure(!mp_->isEmpty());
+}
+
+// Test of getEnvelope() for non-empty LinearRing
+template<>
+template<>
+void object::test<18>
+()
+{
+    ensure(mp_ != nullptr);
+
+    GeometryPtr envelope = mp_->getEnvelope();
+    ensure(envelope != nullptr);
+    ensure(!envelope->isEmpty());
+    ensure_equals(envelope->getDimension(), geos::geom::Dimension::A);
+
+    // FREE MEMORY
+    factory_->destroyGeometry(envelope);
+}
+
+// Test of getBoundary() for non-empty LinearRing
+template<>
+template<>
+void object::test<19>
+()
+{
+    ensure(mp_ != nullptr);
+
+    GeometryPtr boundary = mp_->getBoundary();
+    ensure(boundary != nullptr);
+
+    // OGC 05-126, Version: 1.1.0, Chapter 6.1.5 MultiPoint
+    ensure("[OGC] The boundary of a MultiPoint is the empty set.", boundary->isEmpty());
+
+    // FREE MEMORY
+    factory_->destroyGeometry(boundary);
+}
+
+// Test of convexHull() for non-empty LinearRing
+template<>
+template<>
+void object::test<20>
+()
+{
+    ensure(mp_ != nullptr);
+
+    GeometryPtr hull = mp_->convexHull();
+    ensure(hull != nullptr);
+    ensure(!hull->isEmpty());
+    ensure_equals(hull->getGeometryTypeId(), geos::geom::GEOS_LINESTRING);
+    ensure_equals(hull->getDimension(), geos::geom::Dimension::L);
+
+    // FREE MEMORY
+    factory_->destroyGeometry(hull);
+}
+
+// Test of getGeometryTypeId() for non-empty LinearRing
+template<>
+template<>
+void object::test<21>
+()
+{
+    ensure(mp_ != nullptr);
+    ensure_equals(mp_->getGeometryTypeId(), geos::geom::GEOS_MULTIPOINT);
+}
+
+// Test of getGeometryType() for non-empty Polygon
+template<>
+template<>
+void object::test<22>
+()
+{
+    ensure(mp_ != nullptr);
+
+    const std::string type("MultiPoint");
+    ensure_equals(mp_->getGeometryType(), type);
+}
+
+// Test of getDimension() for non-empty LinearRing
+template<>
+template<>
+void object::test<23>
+()
+{
+    ensure(mp_ != nullptr);
+    ensure_equals(mp_->getDimension(), geos::geom::Dimension::P);
+}
+
+// Test of getBoundaryDimension() for non-empty LinearRing
+template<>
+template<>
+void object::test<24>
+()
+{
+    ensure(mp_ != nullptr);
+    ensure_equals(mp_->getBoundaryDimension(), geos::geom::Dimension::False);
+}
+
+// Test of getNumPoints() for non-empty LinearRing
+template<>
+template<>
+void object::test<25>
+()
+{
+    ensure(mp_ != nullptr);
+    ensure_equals(mp_->getNumPoints(), mp_size_);
+}
+
+// Test of getLength() for non-empty LinearRing
+template<>
+template<>
+void object::test<26>
+()
+{
+    ensure(mp_ != nullptr);
+    ensure_equals(mp_->getLength(), 0.0);
+}
+
+// Test of getArea() for non-empty LinearRing
+template<>
+template<>
+void object::test<27>
+()
+{
+    ensure(mp_ != nullptr);
+    ensure_equals(mp_->getArea(), 0.0);
+}
+
+// Test of ParseException thrown when constructing MultiPoint from invalind WKT
+template<>
+template<>
+void object::test<28>
+()
 {
-	//
-	// Test Group
-	//
-
-	// Common data used by tests
-	struct test_multipoint_data
-	{
-		typedef std::unique_ptr<geos::geom::MultiPoint> MultiPointAutoPtr;
-		typedef geos::geom::GeometryFactory GeometryFactory;
-
-		geos::geom::PrecisionModel pm_;
-		geos::geom::GeometryFactory::Ptr factory_;
-		geos::io::WKTReader reader_;
-
-		MultiPointAutoPtr empty_mp_;
-		MultiPointPtr mp_;
-		const size_t mp_size_;
-
-		test_multipoint_data()
-			:
-			pm_(1.0), factory_(GeometryFactory::create(&pm_, 0))
-      , reader_(factory_.get())
-      , empty_mp_(factory_->createMultiPoint()), mp_size_(5)
-		{
-			// Create non-empty MultiPoint
-			GeometryPtr geo = nullptr;
-			geo = reader_.read("MULTIPOINT(0 0, 5 5, 10 10, 15 15, 20 20)");
-			mp_ = dynamic_cast<MultiPointPtr>(geo);
-		}
-
-		~test_multipoint_data()
-		{
-			factory_->destroyGeometry(mp_);
-		}
-
-    private:
-        // Declare type as noncopyable
-        test_multipoint_data(const test_multipoint_data& other) = delete;
-        test_multipoint_data& operator=(const test_multipoint_data& rhs) = delete;
-	};
-
-	typedef test_group<test_multipoint_data> group;
-	typedef group::object object;
-
-	group test_multipoint_group("geos::geom::MultiPoint");
-
-	//
-	// Test Cases
-	//
-
-	// Test of user's constructor
-	template<>
-	template<>
-	void object::test<1>()
-	{
-		const size_t size0 = 0;
-		MultiPointAutoPtr mp(factory_->createMultiPoint());
-
-		ensure( mp->isEmpty() );
-		ensure( mp->isSimple() );
-		ensure( mp->isValid() );
-		ensure( mp->getCentroid() == nullptr );
-		ensure_equals( mp->getNumPoints(), size0 );
-		ensure_equals( mp->getNumGeometries(), size0 );
-	}
-
-	// Test of copy constructor
-	template<>
-	template<>
-	void object::test<2>()
-	{
-		const size_t size0 = 0;
-		MultiPointAutoPtr copy(dynamic_cast<geos::geom::MultiPoint*>(empty_mp_->clone()));
-		ensure( nullptr != copy.get() );
-
-		ensure( copy->isEmpty() );
-		ensure( copy->isSimple() );
-		ensure( copy->isValid() );
-		ensure( copy->getCentroid() == nullptr );
-		ensure_equals( copy->getNumPoints(), size0 );
-		ensure_equals( copy->getNumGeometries(), size0 );
-	}
-
-	// Test of empty MultiPoint constructed by WKTReader
-	template<>
-	template<>
-	void object::test<3>()
-	{
-		const size_t size0 = 0;
-		GeometryPtr geo = reader_.read("MULTIPOINT EMPTY");
-		MultiPointPtr mp = dynamic_cast<MultiPointPtr>(geo);
-
-		ensure( mp->isEmpty() );
-		ensure( mp->isSimple() );
-		ensure( mp->isValid() );
-		ensure( mp->getCentroid() == nullptr );
-		ensure_equals( mp->getNumPoints(), size0 );
-		ensure_equals( mp->getNumGeometries(), size0 );
-
-		// FREE MEMORY
-		factory_->destroyGeometry(geo);
-	}
-
-	// Test of isEmpty() for empty MultiPoint
-	template<>
-	template<>
-	void object::test<4>()
-	{
-		ensure( empty_mp_->isEmpty() );
-	}
-
-	// Test of isSimple() for empty MultiPoint
-	template<>
-	template<>
-	void object::test<5>()
-	{
-		ensure( empty_mp_->isSimple() );
-	}
-
-	// Test of isValid() for empty MultiPoint
-	template<>
-	template<>
-	void object::test<6>()
-	{
-		ensure( empty_mp_->isValid() );
-	}
-
-	// Test of getEnvelope() for empty MultiPoint
-	template<>
-	template<>
-	void object::test<7>()
-	{
-		GeometryPtr envelope = empty_mp_->getEnvelope();
-		ensure( envelope != nullptr );
-		ensure( envelope->isEmpty() );
-		factory_->destroyGeometry(envelope);
-	}
-
-	// Test of getBoundary() for empty MultiPoint
-	template<>
-	template<>
-	void object::test<8>()
-	{
-		GeometryPtr boundary = empty_mp_->getBoundary();
-		ensure( boundary != nullptr );
-		ensure( boundary->isEmpty() );
-		factory_->destroyGeometry(boundary);
-	}
-
-	// Test of convexHull() for empty MultiPoint
-	template<>
-	template<>
-	void object::test<9>()
-	{
-		GeometryPtr hull = empty_mp_->convexHull();
-		ensure( hull != nullptr );
-		ensure( hull->isEmpty() );
-		factory_->destroyGeometry(hull);
-	}
-
-	// Test of getGeometryTypeId() for empty MultiPoint
-	template<>
-	template<>
-	void object::test<10>()
-	{
-		ensure_equals( empty_mp_->getGeometryTypeId(), geos::geom::GEOS_MULTIPOINT );
-	}
-
-	// Test of getGeometryType() for empty MultiPoint
-	template<>
-	template<>
-	void object::test<11>()
-	{
-		const std::string type("MultiPoint");
-		ensure_equals( empty_mp_->getGeometryType(), type );
-	}
-
-	// Test of getDimension() for empty MultiPoint
-	template<>
-	template<>
-	void object::test<12>()
-	{
-		ensure_equals( empty_mp_->getDimension(), geos::geom::Dimension::P );
-	}
-
-	// Test of getBoundaryDimension() for empty MultiPoint
-	template<>
-	template<>
-	void object::test<13>()
-	{
-		ensure_equals( empty_mp_->getBoundaryDimension(), geos::geom::Dimension::False );
-	}
-
-	// Test of getNumPoints() for empty MultiPoint
-	template<>
-	template<>
-	void object::test<14>()
-	{
-		ensure_equals( empty_mp_->getNumPoints(), 0u );
-	}
-
-	// Test of getLength() for empty MultiPoint
-	template<>
-	template<>
-	void object::test<15>()
-	{
-		ensure_equals( empty_mp_->getLength(), 0.0 );
-	}
-
-	// Test of getArea() for empty MultiPoint
-	template<>
-	template<>
-	void object::test<16>()
-	{
-		ensure_equals( empty_mp_->getArea(), 0.0 );
-	}
-
-	// Test of isEmpty() for non-empty LinearRing
-	template<>
-	template<>
-	void object::test<17>()
-	{
-		ensure(mp_ != nullptr);
-		ensure( !mp_->isEmpty() );
-	}
-
-	// Test of getEnvelope() for non-empty LinearRing
-	template<>
-	template<>
-	void object::test<18>()
-	{
-		ensure(mp_ != nullptr);
-
-		GeometryPtr envelope = mp_->getEnvelope();
-		ensure( envelope != nullptr );
-		ensure( !envelope->isEmpty() );
-		ensure_equals( envelope->getDimension(), geos::geom::Dimension::A );
-
-		// FREE MEMORY
-		factory_->destroyGeometry(envelope);
-	}
-
-	// Test of getBoundary() for non-empty LinearRing
-	template<>
-	template<>
-	void object::test<19>()
-	{
-		ensure(mp_ != nullptr);
-
-		GeometryPtr boundary = mp_->getBoundary();
-		ensure( boundary != nullptr );
-
-		// OGC 05-126, Version: 1.1.0, Chapter 6.1.5 MultiPoint
-		ensure( "[OGC] The boundary of a MultiPoint is the empty set.", boundary->isEmpty() );
-
-		// FREE MEMORY
-		factory_->destroyGeometry(boundary);
-	}
-
-	// Test of convexHull() for non-empty LinearRing
-	template<>
-	template<>
-	void object::test<20>()
-	{
-		ensure(mp_ != nullptr);
-
-		GeometryPtr hull = mp_->convexHull();
-		ensure( hull != nullptr );
-		ensure( !hull->isEmpty() );
-		ensure_equals( hull->getGeometryTypeId(), geos::geom::GEOS_LINESTRING );
-		ensure_equals( hull->getDimension(), geos::geom::Dimension::L );
-
-		// FREE MEMORY
-		factory_->destroyGeometry(hull);
-	}
-
-	// Test of getGeometryTypeId() for non-empty LinearRing
-	template<>
-	template<>
-	void object::test<21>()
-	{
-		ensure(mp_ != nullptr);
-		ensure_equals( mp_->getGeometryTypeId(), geos::geom::GEOS_MULTIPOINT );
-	}
-
-	// Test of getGeometryType() for non-empty Polygon
-	template<>
-	template<>
-	void object::test<22>()
-	{
-		ensure( mp_ != nullptr );
-
-		const std::string type("MultiPoint");
-		ensure_equals( mp_->getGeometryType(), type );
-	}
-
-	// Test of getDimension() for non-empty LinearRing
-	template<>
-	template<>
-	void object::test<23>()
-	{
-		ensure(mp_ != nullptr);
-		ensure_equals( mp_->getDimension(), geos::geom::Dimension::P );
-	}
-
-	// Test of getBoundaryDimension() for non-empty LinearRing
-	template<>
-	template<>
-	void object::test<24>()
-	{
-		ensure(mp_ != nullptr);
-		ensure_equals( mp_->getBoundaryDimension(), geos::geom::Dimension::False );
-	}
-
-	// Test of getNumPoints() for non-empty LinearRing
-	template<>
-	template<>
-	void object::test<25>()
-	{
-		ensure(mp_ != nullptr);
-		ensure_equals( mp_->getNumPoints(), mp_size_ );
-	}
-
-	// Test of getLength() for non-empty LinearRing
-	template<>
-	template<>
-	void object::test<26>()
-	{
-		ensure(mp_ != nullptr);
-		ensure_equals( mp_->getLength(), 0.0 );
-	}
-
-	// Test of getArea() for non-empty LinearRing
-	template<>
-	template<>
-	void object::test<27>()
-	{
-		ensure(mp_ != nullptr);
-		ensure_equals( mp_->getArea(), 0.0 );
-	}
-
-	// Test of ParseException thrown when constructing MultiPoint from invalind WKT
-	template<>
-	template<>
-	void object::test<28>()
-	{
-		try
-		{
-			GeometryPtr geo = reader_.read("MULTIPOINT(0 0, 5)");
-			ensure(geo != nullptr);
-
-			// FREE TESTED LINEARRING
-			factory_->destroyGeometry(geo);
-
-			fail("ParseException expected.");
-		}
-		catch (geos::io::ParseException const& e)
-		{
-			const char* msg = e.what(); // ok
-			ensure( msg != nullptr );
-		}
-	}
+    try {
+        GeometryPtr geo = reader_.read("MULTIPOINT(0 0, 5)");
+        ensure(geo != nullptr);
+
+        // FREE TESTED LINEARRING
+        factory_->destroyGeometry(geo);
+
+        fail("ParseException expected.");
+    }
+    catch(geos::io::ParseException const& e) {
+        const char* msg = e.what(); // ok
+        ensure(msg != nullptr);
+    }
+}
 
 } // namespace tut
 
diff --git a/tests/unit/geom/MultiPolygonTest.cpp b/tests/unit/geom/MultiPolygonTest.cpp
index 3c81ccb..12ba16a 100644
--- a/tests/unit/geom/MultiPolygonTest.cpp
+++ b/tests/unit/geom/MultiPolygonTest.cpp
@@ -5,33 +5,32 @@
 // geos
 #include <geos/geom/MultiPolygon.h>
 
-namespace tut
+namespace tut {
+//
+// Test Group
+//
+
+// Common data used by tests
+struct test_multipolygon_data {
+    test_multipolygon_data() {}
+};
+
+typedef test_group<test_multipolygon_data> group;
+typedef group::object object;
+
+group test_multipolygon_group("geos::geom::MultiPolygon");
+
+//
+// Test Cases
+//
+
+// Test of default constructor
+template<>
+template<>
+void object::test<1>
+()
 {
-    //
-    // Test Group
-    //
-
-    // Common data used by tests
-    struct test_multipolygon_data
-    {
-        test_multipolygon_data() {}
-    };
-
-    typedef test_group<test_multipolygon_data> group;
-    typedef group::object object;
-
-    group test_multipolygon_group("geos::geom::MultiPolygon");
-
-    //
-    // Test Cases
-    //
-
-    // Test of default constructor
-    template<>
-    template<>
-    void object::test<1>()
-    {
-	    //inform("Test not implemented!");
-    }
+    //inform("Test not implemented!");
+}
 
 } // namespace tut
diff --git a/tests/unit/geom/PointTest.cpp b/tests/unit/geom/PointTest.cpp
index c9ab71d..3334c0c 100644
--- a/tests/unit/geom/PointTest.cpp
+++ b/tests/unit/geom/PointTest.cpp
@@ -17,521 +17,557 @@
 #include <string>
 
 
-namespace tut
-{
-    //
-    // Test Group
-    //
+namespace tut {
+//
+// Test Group
+//
 
-    // Common data used by tests
-    struct test_point_data
-    {
-	typedef geos::geom::Coordinate* CoordinatePtr;
-	typedef geos::geom::Coordinate const* CoordinateCPtr;
-
-	typedef geos::geom::Geometry* GeometryPtr;
-	typedef std::unique_ptr<geos::geom::Geometry> GeometryAutoPtr;
-	typedef geos::geom::Geometry const* GeometryCPtr;
-
-	typedef geos::geom::Point* PointPtr;
-	typedef std::unique_ptr<geos::geom::Point> PointAutoPtr;
-	typedef geos::geom::Point const* PointCPtr;
-	typedef geos::geom::GeometryFactory GeometryFactory;
-
-	geos::geom::PrecisionModel pm_;
-	GeometryFactory::Ptr factory_;
-	geos::io::WKTReader reader_;
-	PointAutoPtr empty_point_;
-	PointPtr point_;
-
-	test_point_data()
-	    : pm_(1000), factory_(GeometryFactory::create(&pm_, 0))
-      , reader_(factory_.get()), empty_point_(factory_->createPoint())
-	{
-	    // Create non-empty Point
-	    GeometryPtr geo = nullptr;
-	    geo = reader_.read("POINT(1.234 5.678)");
-	    point_ = dynamic_cast<PointPtr>(geo);
-	}
-
-	~test_point_data()
-	{
-	    factory_->destroyGeometry(point_);
-	}
-    };
-
-    typedef test_group<test_point_data> group;
-    typedef group::object object;
-
-    group test_point_group("geos::geom::Point");
-
-    //
-    // Test Cases
-    //
-
-    // Test of user's constructor to build empty Point
-    template<>
-    template<>
-    void object::test<1>()
+// Common data used by tests
+struct test_point_data {
+    typedef geos::geom::Coordinate* CoordinatePtr;
+    typedef geos::geom::Coordinate const* CoordinateCPtr;
+
+    typedef geos::geom::Geometry* GeometryPtr;
+    typedef std::unique_ptr<geos::geom::Geometry> GeometryAutoPtr;
+    typedef geos::geom::Geometry const* GeometryCPtr;
+
+    typedef geos::geom::Point* PointPtr;
+    typedef std::unique_ptr<geos::geom::Point> PointAutoPtr;
+    typedef geos::geom::Point const* PointCPtr;
+    typedef geos::geom::GeometryFactory GeometryFactory;
+
+    geos::geom::PrecisionModel pm_;
+    GeometryFactory::Ptr factory_;
+    geos::io::WKTReader reader_;
+    PointAutoPtr empty_point_;
+    PointPtr point_;
+
+    test_point_data()
+        : pm_(1000), factory_(GeometryFactory::create(&pm_, 0))
+        , reader_(factory_.get()), empty_point_(factory_->createPoint())
     {
-		PointAutoPtr point(factory_->createPoint());
-		ensure( point->isEmpty() );
+        // Create non-empty Point
+        GeometryPtr geo = nullptr;
+        geo = reader_.read("POINT(1.234 5.678)");
+        point_ = dynamic_cast<PointPtr>(geo);
     }
 
-    // Test of user's constructor to build non-empty Point
-    template<>
-    template<>
-    void object::test<2>()
+    ~test_point_data()
     {
-		using geos::geom::Coordinate;
-		using geos::geom::CoordinateArraySequence;
+        factory_->destroyGeometry(point_);
+    }
+};
 
-		CoordinateArraySequence* coords = new CoordinateArraySequence();
-		ensure( coords != nullptr );
-		coords->add(Coordinate(1.234, 5.678));
+typedef test_group<test_point_data> group;
+typedef group::object object;
 
-		PointAutoPtr point(factory_->createPoint(coords));
-		ensure( !point->isEmpty() );
+group test_point_group("geos::geom::Point");
 
-        // currently the empty CoordinateArraySequence constructor
-        // produces a dimension 3 sequence.
-        ensure( point->getCoordinateDimension() == 3 );
-    }
+//
+// Test Cases
+//
 
-    // Test of user's constructor throwing IllegalArgumentException
-    template<>
-    template<>
-    void object::test<3>()
-    {
-		using geos::geom::Coordinate;
-		using geos::geom::CoordinateArraySequence;
-
-		// TODO - mloskot - temporary solution of Bug #89
-		CoordinateArraySequence* coords = nullptr;
-		try
-		{
-			coords = new CoordinateArraySequence();
-			ensure( coords != nullptr );
-			coords->add(Coordinate(1.234, 5.678));
-			coords->add(Coordinate(4.321, 8.765));
-
-			PointAutoPtr point(factory_->createPoint(coords));
-
-			fail("IllegalArgumentException expected.");
-		}
-		catch (geos::util::IllegalArgumentException const& e)
-		{
-			// TODO - mloskot - Bug #89: Possible memory leaks caused by Point constructor
-			//delete coords;
-
-			const char* msg = e.what(); // ok
-			ensure( msg != nullptr );
-		}
+// Test of user's constructor to build empty Point
+template<>
+template<>
+void object::test<1>
+()
+{
+    PointAutoPtr point(factory_->createPoint());
+    ensure(point->isEmpty());
+}
+
+// Test of user's constructor to build non-empty Point
+template<>
+template<>
+void object::test<2>
+()
+{
+    using geos::geom::Coordinate;
+    using geos::geom::CoordinateArraySequence;
+
+    CoordinateArraySequence* coords = new CoordinateArraySequence();
+    ensure(coords != nullptr);
+    coords->add(Coordinate(1.234, 5.678));
+
+    PointAutoPtr point(factory_->createPoint(coords));
+    ensure(!point->isEmpty());
+
+    // currently the empty CoordinateArraySequence constructor
+    // produces a dimension 3 sequence.
+    ensure(point->getCoordinateDimension() == 3);
+}
+
+// Test of user's constructor throwing IllegalArgumentException
+template<>
+template<>
+void object::test<3>
+()
+{
+    using geos::geom::Coordinate;
+    using geos::geom::CoordinateArraySequence;
+
+    // TODO - mloskot - temporary solution of Bug #89
+    CoordinateArraySequence* coords = nullptr;
+    try {
+        coords = new CoordinateArraySequence();
+        ensure(coords != nullptr);
+        coords->add(Coordinate(1.234, 5.678));
+        coords->add(Coordinate(4.321, 8.765));
+
+        PointAutoPtr point(factory_->createPoint(coords));
+
+        fail("IllegalArgumentException expected.");
     }
+    catch(geos::util::IllegalArgumentException const& e) {
+        // TODO - mloskot - Bug #89: Possible memory leaks caused by Point constructor
+        //delete coords;
 
-	// Test of copy constructor
-	template<>
-	template<>
-	void object::test<4>()
-	{
-		GeometryAutoPtr copy(empty_point_->clone());
-		ensure( copy->isEmpty() );
-	}
-
-	// Test of isEmpty() for empty Point
-	template<>
-	template<>
-	void object::test<5>()
-	{
-		ensure( empty_point_->isEmpty() );
-	}
-
-	// Test of isSimple() for empty Point
-	template<>
-	template<>
-	void object::test<6>()
-	{
-		ensure( empty_point_->isSimple() );
-	}
-
-	// Test of isValid() for empty Point
-	template<>
-	template<>
-	void object::test<7>()
-	{
-		ensure( empty_point_->isValid() );
-	}
-
-	// Test of getEnvelope() for empty Point
-	template<>
-	template<>
-	void object::test<8>()
-	{
-		GeometryPtr envelope = empty_point_->getEnvelope();
-		ensure( envelope != nullptr );
-		ensure( envelope->isEmpty() );
-		factory_->destroyGeometry(envelope);
-	}
-
-	// Test of getBoundary() for empty Point
-	template<>
-	template<>
-	void object::test<9>()
-	{
-		GeometryPtr boundary = empty_point_->getBoundary();
-		ensure( boundary != nullptr );
-		ensure( boundary->isEmpty() );
-		factory_->destroyGeometry(boundary);
-	}
-
-	// Test of convexHull() for empty Point
-	template<>
-	template<>
-	void object::test<10>()
-	{
-		GeometryPtr hull = empty_point_->convexHull();
-		ensure( hull != nullptr );
-		ensure( hull->isEmpty() );
-		factory_->destroyGeometry(hull);
-	}
-
-	// Test of getGeometryTypeId() for empty Point
-	template<>
-	template<>
-	void object::test<11>()
-	{
-		ensure_equals( empty_point_->getGeometryTypeId(), geos::geom::GEOS_POINT );
-	}
-
-	// Test of getGeometryType() for empty Polygon
-	template<>
-	template<>
-	void object::test<12>()
-	{
-		const std::string type("Point");
-		ensure_equals( empty_point_->getGeometryType(), type );
-	}
-
-	// Test of getDimension() for empty Point
-	template<>
-	template<>
-	void object::test<13>()
-	{
-		ensure_equals( empty_point_->getDimension(), geos::geom::Dimension::P );
-	}
-
-	// Test of getBoundaryDimension() for empty Point
-	template<>
-	template<>
-	void object::test<14>()
-	{
-		ensure_equals( empty_point_->getBoundaryDimension(), geos::geom::Dimension::False );
-	}
-
-	// Test of getNumPoints() for empty Point
-	template<>
-	template<>
-	void object::test<15>()
-	{
-		ensure_equals( empty_point_->getNumPoints(), (size_t)0 );
-	}
-
-	// Test of getLength() for empty Point
-	template<>
-	template<>
-	void object::test<16>()
-	{
-		ensure_equals( empty_point_->getLength(), 0 );
-	}
-
-	// Test of getArea() for empty Point
-	template<>
-	template<>
-	void object::test<17>()
-	{
-		ensure_equals( empty_point_->getArea(), 0 );
-	}
-
-	// Test of isEmpty() for non-empty Point
-	template<>
-	template<>
-	void object::test<18>()
-	{
-		ensure( !point_->isEmpty() );
-	}
-
-	// Test of isSimple() for non-empty Point
-	template<>
-	template<>
-	void object::test<19>()
-	{
-		ensure( point_->isSimple() );
-	}
-
-	// Test of isValid() for non-empty Point
-	template<>
-	template<>
-	void object::test<20>()
-	{
-		ensure( point_->isValid() );
-	}
-
-	// Test of getEnvelope() for non-empty Point
-	template<>
-	template<>
-	void object::test<21>()
-	{
-		GeometryPtr envelope = point_->getEnvelope();
-		ensure( envelope != nullptr );
-		ensure( !envelope->isEmpty() );
-		factory_->destroyGeometry(envelope);
-	}
-
-	// Test of getBoundary() for non-empty Point
-	template<>
-	template<>
-	void object::test<22>()
-	{
-		GeometryPtr boundary = point_->getBoundary();
-		ensure( boundary != nullptr );
-		ensure( boundary->isEmpty() );
-		factory_->destroyGeometry(boundary);
-	}
-
-	// Test of convexHull() for non-empty Point
-	template<>
-	template<>
-	void object::test<23>()
-	{
-		GeometryPtr hull = point_->convexHull();
-		ensure( hull != nullptr );
-		ensure( !hull->isEmpty() );
-		factory_->destroyGeometry(hull);
-	}
-
-	// Test of getGeometryTypeId() for non-empty Point
-	template<>
-	template<>
-	void object::test<24>()
-	{
-		ensure_equals( point_->getGeometryTypeId(), geos::geom::GEOS_POINT );
-	}
-
-	// Test of getGeometryType() for non-empty Polygon
-	template<>
-	template<>
-	void object::test<25>()
-	{
-		const std::string type("Point");
-		ensure_equals( point_->getGeometryType(), type );
-	}
-
-	// Test of getDimension() for non-empty Point
-	template<>
-	template<>
-	void object::test<26>()
-	{
-		ensure_equals( point_->getDimension(), geos::geom::Dimension::P );
-	}
-
-	// Test of getBoundaryDimension() for non-empty Point
-	template<>
-	template<>
-	void object::test<27>()
-	{
-		ensure_equals( empty_point_->getBoundaryDimension(), geos::geom::Dimension::False );
-	}
-
-	// Test of getNumPoints() for non-empty Point
-	template<>
-	template<>
-	void object::test<28>()
-	{
-		ensure_equals( point_->getNumPoints(), (size_t)1 );
-	}
-
-	// Test of getLength() for non-empty Point
-	template<>
-	template<>
-	void object::test<29>()
-	{
-		ensure_equals( point_->getLength(), 0 );
-	}
-
-	// Test of getArea() for non-empty Point
-	template<>
-	template<>
-	void object::test<30>()
-	{
-		ensure_equals( point_->getArea(), 0 );
-	}
-
-	// Test of equals() for empty Point
-	template<>
-	template<>
-	void object::test<31>()
-	{
-		GeometryAutoPtr geo(empty_point_->clone());
-
-		ensure( empty_point_->equals(geo.get()) );
-	}
-
-	// Test of equals() for non-empty Point (1.234,5.678)
-	template<>
-	template<>
-	void object::test<32>()
-	{
-		GeometryPtr p1 = reader_.read("POINT(1.234 5.678)");
-		GeometryPtr p2 = reader_.read("POINT(1.234 5.678)");
-
-		// WARNING! If test fails, memory leaks occur.
-		ensure( p1->equals(p2) );
-
-		// FREE MEMORY
-		factory_->destroyGeometry(p1);
-		factory_->destroyGeometry(p2);
-	}
-
-	// Test of equals() for non-empty Point (1.23 5.67)
-	template<>
-	template<>
-	void object::test<33>()
-	{
-		GeometryPtr p1 = reader_.read("POINT(1.23 5.67)");
-		GeometryPtr p2 = reader_.read("POINT(1.23 5.67)");
-
-		// WARNING! If test fails, memory leaks occur.
-		ensure( p1->equals(p2) );
-
-		// FREE MEMORY
-		factory_->destroyGeometry(p1);
-		factory_->destroyGeometry(p2);
-	}
-
-	// Test of equals() for non-empty Points (1.235 5.678) and (1.234 5.678)
-	template<>
-	template<>
-	void object::test<34>()
-	{
-		GeometryPtr p1 = reader_.read("POINT(1.235 5.678)");
-		GeometryPtr p2 = reader_.read("POINT(1.234 5.678)");
-
-		// WARNING! If test fails, memory leaks occur.
-		ensure( !p1->equals(p2) );
-
-		// FREE MEMORY
-		factory_->destroyGeometry(p1);
-		factory_->destroyGeometry(p2);
-	}
-
-	// Test of equals() for non-empty Points (1.2334 5.678) and (1.2333 5.678)
-	template<>
-	template<>
-	void object::test<35>()
-	{
-		GeometryPtr p1 = reader_.read("POINT(1.2334 5.678)");
-		GeometryPtr p2 = reader_.read("POINT(1.2333 5.678)");
-
-		// WARNING! If test fails, memory leaks occur.
-		ensure( p1->equals(p2) );
-
-		// FREE MEMORY
-		factory_->destroyGeometry(p1);
-		factory_->destroyGeometry(p2);
-	}
-
-	// Test of equals() for non-empty Points (1.2334 5.678) and (1.2335 5.678)
-	template<>
-	template<>
-	void object::test<36>()
-	{
-		GeometryPtr p1 = reader_.read("POINT(1.2334 5.678)");
-		GeometryPtr p2 = reader_.read("POINT(1.2335 5.678)");
-
-		// WARNING! If test fails, memory leaks occur.
-		ensure( !p1->equals(p2) );
-
-		// FREE MEMORY
-		factory_->destroyGeometry(p1);
-		factory_->destroyGeometry(p2);
-	}
-
-	// Test of equals() for non-empty Points (1.2324 5.678) and (1.2325 5.678)
-	template<>
-	template<>
-	void object::test<37>()
-	{
-		GeometryPtr p1 = reader_.read("POINT(1.2324 5.678)");
-		GeometryPtr p2 = reader_.read("POINT(1.2325 5.678)");
-
-		// WARNING! If test fails, memory leaks occur.
-		ensure( !p1->equals(p2) );
-
-		// FREE MEMORY
-		factory_->destroyGeometry(p1);
-		factory_->destroyGeometry(p2);
-	}
-
-	// Test of equals() for non-empty Points (1.2324 5.678) and (EMPTY)
-	template<>
-	template<>
-	void object::test<38>()
-	{
-		GeometryPtr p1 = reader_.read("POINT(1.2324 5.678)");
-		GeometryPtr p2 = reader_.read("POINT EMPTY");
-
-		// WARNING! If test fails, memory leaks occur.
-		ensure( !p1->equals(p2) );
-
-		// FREE MEMORY
-		factory_->destroyGeometry(p1);
-		factory_->destroyGeometry(p2);
-	}
-
-	// Test of equals() for non-empty Points with negative coordiantes
-	template<>
-	template<>
-	void object::test<39>()
-	{
-		GeometryPtr pLo = reader_.read("POINT(-1.233 5.678)");
-		GeometryPtr pHi = reader_.read("POINT(-1.232 5.678)");
-
-		GeometryPtr p1 = reader_.read("POINT(-1.2326 5.678)");
-		GeometryPtr p2 = reader_.read("POINT(-1.2325 5.678)");
-		GeometryPtr p3 = reader_.read("POINT(-1.2324 5.678)");
-
-		ensure( !p1->equals(p2) );
-		ensure( p3->equals(p2) );
-
-		ensure( p1->equals(pLo) );
-		ensure( p2->equals(pHi) );
-		ensure( p3->equals(pHi) );
-
-		// FREE MEMORY
-		factory_->destroyGeometry(pLo);
-		factory_->destroyGeometry(pHi);
-		factory_->destroyGeometry(p1);
-		factory_->destroyGeometry(p2);
-		factory_->destroyGeometry(p3);
-	}
-
-	// Test of getCoordinateDimension() for 2d/3d.
-	template<>
-	template<>
-	void object::test<40>()
-	{
-		GeometryPtr p = reader_.read("POINT(-1.233 5.678 1.0)");
-
-        ensure( p->getCoordinateDimension() == 3 );
-
-        delete p;
-
-		p = reader_.read("POINT(-1.233 5.678)");
-
-        ensure( p->getCoordinateDimension() == 2 );
-
-        delete p;
+        const char* msg = e.what(); // ok
+        ensure(msg != nullptr);
     }
+}
+
+// Test of copy constructor
+template<>
+template<>
+void object::test<4>
+()
+{
+    GeometryAutoPtr copy(empty_point_->clone());
+    ensure(copy->isEmpty());
+}
+
+// Test of isEmpty() for empty Point
+template<>
+template<>
+void object::test<5>
+()
+{
+    ensure(empty_point_->isEmpty());
+}
+
+// Test of isSimple() for empty Point
+template<>
+template<>
+void object::test<6>
+()
+{
+    ensure(empty_point_->isSimple());
+}
+
+// Test of isValid() for empty Point
+template<>
+template<>
+void object::test<7>
+()
+{
+    ensure(empty_point_->isValid());
+}
+
+// Test of getEnvelope() for empty Point
+template<>
+template<>
+void object::test<8>
+()
+{
+    GeometryPtr envelope = empty_point_->getEnvelope();
+    ensure(envelope != nullptr);
+    ensure(envelope->isEmpty());
+    factory_->destroyGeometry(envelope);
+}
+
+// Test of getBoundary() for empty Point
+template<>
+template<>
+void object::test<9>
+()
+{
+    GeometryPtr boundary = empty_point_->getBoundary();
+    ensure(boundary != nullptr);
+    ensure(boundary->isEmpty());
+    factory_->destroyGeometry(boundary);
+}
+
+// Test of convexHull() for empty Point
+template<>
+template<>
+void object::test<10>
+()
+{
+    GeometryPtr hull = empty_point_->convexHull();
+    ensure(hull != nullptr);
+    ensure(hull->isEmpty());
+    factory_->destroyGeometry(hull);
+}
+
+// Test of getGeometryTypeId() for empty Point
+template<>
+template<>
+void object::test<11>
+()
+{
+    ensure_equals(empty_point_->getGeometryTypeId(), geos::geom::GEOS_POINT);
+}
+
+// Test of getGeometryType() for empty Polygon
+template<>
+template<>
+void object::test<12>
+()
+{
+    const std::string type("Point");
+    ensure_equals(empty_point_->getGeometryType(), type);
+}
+
+// Test of getDimension() for empty Point
+template<>
+template<>
+void object::test<13>
+()
+{
+    ensure_equals(empty_point_->getDimension(), geos::geom::Dimension::P);
+}
+
+// Test of getBoundaryDimension() for empty Point
+template<>
+template<>
+void object::test<14>
+()
+{
+    ensure_equals(empty_point_->getBoundaryDimension(), geos::geom::Dimension::False);
+}
+
+// Test of getNumPoints() for empty Point
+template<>
+template<>
+void object::test<15>
+()
+{
+    ensure_equals(empty_point_->getNumPoints(), (size_t)0);
+}
+
+// Test of getLength() for empty Point
+template<>
+template<>
+void object::test<16>
+()
+{
+    ensure_equals(empty_point_->getLength(), 0);
+}
+
+// Test of getArea() for empty Point
+template<>
+template<>
+void object::test<17>
+()
+{
+    ensure_equals(empty_point_->getArea(), 0);
+}
+
+// Test of isEmpty() for non-empty Point
+template<>
+template<>
+void object::test<18>
+()
+{
+    ensure(!point_->isEmpty());
+}
+
+// Test of isSimple() for non-empty Point
+template<>
+template<>
+void object::test<19>
+()
+{
+    ensure(point_->isSimple());
+}
+
+// Test of isValid() for non-empty Point
+template<>
+template<>
+void object::test<20>
+()
+{
+    ensure(point_->isValid());
+}
+
+// Test of getEnvelope() for non-empty Point
+template<>
+template<>
+void object::test<21>
+()
+{
+    GeometryPtr envelope = point_->getEnvelope();
+    ensure(envelope != nullptr);
+    ensure(!envelope->isEmpty());
+    factory_->destroyGeometry(envelope);
+}
+
+// Test of getBoundary() for non-empty Point
+template<>
+template<>
+void object::test<22>
+()
+{
+    GeometryPtr boundary = point_->getBoundary();
+    ensure(boundary != nullptr);
+    ensure(boundary->isEmpty());
+    factory_->destroyGeometry(boundary);
+}
+
+// Test of convexHull() for non-empty Point
+template<>
+template<>
+void object::test<23>
+()
+{
+    GeometryPtr hull = point_->convexHull();
+    ensure(hull != nullptr);
+    ensure(!hull->isEmpty());
+    factory_->destroyGeometry(hull);
+}
+
+// Test of getGeometryTypeId() for non-empty Point
+template<>
+template<>
+void object::test<24>
+()
+{
+    ensure_equals(point_->getGeometryTypeId(), geos::geom::GEOS_POINT);
+}
+
+// Test of getGeometryType() for non-empty Polygon
+template<>
+template<>
+void object::test<25>
+()
+{
+    const std::string type("Point");
+    ensure_equals(point_->getGeometryType(), type);
+}
+
+// Test of getDimension() for non-empty Point
+template<>
+template<>
+void object::test<26>
+()
+{
+    ensure_equals(point_->getDimension(), geos::geom::Dimension::P);
+}
+
+// Test of getBoundaryDimension() for non-empty Point
+template<>
+template<>
+void object::test<27>
+()
+{
+    ensure_equals(empty_point_->getBoundaryDimension(), geos::geom::Dimension::False);
+}
+
+// Test of getNumPoints() for non-empty Point
+template<>
+template<>
+void object::test<28>
+()
+{
+    ensure_equals(point_->getNumPoints(), (size_t)1);
+}
+
+// Test of getLength() for non-empty Point
+template<>
+template<>
+void object::test<29>
+()
+{
+    ensure_equals(point_->getLength(), 0);
+}
+
+// Test of getArea() for non-empty Point
+template<>
+template<>
+void object::test<30>
+()
+{
+    ensure_equals(point_->getArea(), 0);
+}
+
+// Test of equals() for empty Point
+template<>
+template<>
+void object::test<31>
+()
+{
+    GeometryAutoPtr geo(empty_point_->clone());
+
+    ensure(empty_point_->equals(geo.get()));
+}
+
+// Test of equals() for non-empty Point (1.234,5.678)
+template<>
+template<>
+void object::test<32>
+()
+{
+    GeometryPtr p1 = reader_.read("POINT(1.234 5.678)");
+    GeometryPtr p2 = reader_.read("POINT(1.234 5.678)");
+
+    // WARNING! If test fails, memory leaks occur.
+    ensure(p1->equals(p2));
+
+    // FREE MEMORY
+    factory_->destroyGeometry(p1);
+    factory_->destroyGeometry(p2);
+}
+
+// Test of equals() for non-empty Point (1.23 5.67)
+template<>
+template<>
+void object::test<33>
+()
+{
+    GeometryPtr p1 = reader_.read("POINT(1.23 5.67)");
+    GeometryPtr p2 = reader_.read("POINT(1.23 5.67)");
+
+    // WARNING! If test fails, memory leaks occur.
+    ensure(p1->equals(p2));
+
+    // FREE MEMORY
+    factory_->destroyGeometry(p1);
+    factory_->destroyGeometry(p2);
+}
+
+// Test of equals() for non-empty Points (1.235 5.678) and (1.234 5.678)
+template<>
+template<>
+void object::test<34>
+()
+{
+    GeometryPtr p1 = reader_.read("POINT(1.235 5.678)");
+    GeometryPtr p2 = reader_.read("POINT(1.234 5.678)");
+
+    // WARNING! If test fails, memory leaks occur.
+    ensure(!p1->equals(p2));
+
+    // FREE MEMORY
+    factory_->destroyGeometry(p1);
+    factory_->destroyGeometry(p2);
+}
+
+// Test of equals() for non-empty Points (1.2334 5.678) and (1.2333 5.678)
+template<>
+template<>
+void object::test<35>
+()
+{
+    GeometryPtr p1 = reader_.read("POINT(1.2334 5.678)");
+    GeometryPtr p2 = reader_.read("POINT(1.2333 5.678)");
+
+    // WARNING! If test fails, memory leaks occur.
+    ensure(p1->equals(p2));
+
+    // FREE MEMORY
+    factory_->destroyGeometry(p1);
+    factory_->destroyGeometry(p2);
+}
+
+// Test of equals() for non-empty Points (1.2334 5.678) and (1.2335 5.678)
+template<>
+template<>
+void object::test<36>
+()
+{
+    GeometryPtr p1 = reader_.read("POINT(1.2334 5.678)");
+    GeometryPtr p2 = reader_.read("POINT(1.2335 5.678)");
+
+    // WARNING! If test fails, memory leaks occur.
+    ensure(!p1->equals(p2));
+
+    // FREE MEMORY
+    factory_->destroyGeometry(p1);
+    factory_->destroyGeometry(p2);
+}
+
+// Test of equals() for non-empty Points (1.2324 5.678) and (1.2325 5.678)
+template<>
+template<>
+void object::test<37>
+()
+{
+    GeometryPtr p1 = reader_.read("POINT(1.2324 5.678)");
+    GeometryPtr p2 = reader_.read("POINT(1.2325 5.678)");
+
+    // WARNING! If test fails, memory leaks occur.
+    ensure(!p1->equals(p2));
+
+    // FREE MEMORY
+    factory_->destroyGeometry(p1);
+    factory_->destroyGeometry(p2);
+}
+
+// Test of equals() for non-empty Points (1.2324 5.678) and (EMPTY)
+template<>
+template<>
+void object::test<38>
+()
+{
+    GeometryPtr p1 = reader_.read("POINT(1.2324 5.678)");
+    GeometryPtr p2 = reader_.read("POINT EMPTY");
+
+    // WARNING! If test fails, memory leaks occur.
+    ensure(!p1->equals(p2));
+
+    // FREE MEMORY
+    factory_->destroyGeometry(p1);
+    factory_->destroyGeometry(p2);
+}
+
+// Test of equals() for non-empty Points with negative coordiantes
+template<>
+template<>
+void object::test<39>
+()
+{
+    GeometryPtr pLo = reader_.read("POINT(-1.233 5.678)");
+    GeometryPtr pHi = reader_.read("POINT(-1.232 5.678)");
+
+    GeometryPtr p1 = reader_.read("POINT(-1.2326 5.678)");
+    GeometryPtr p2 = reader_.read("POINT(-1.2325 5.678)");
+    GeometryPtr p3 = reader_.read("POINT(-1.2324 5.678)");
+
+    ensure(!p1->equals(p2));
+    ensure(p3->equals(p2));
+
+    ensure(p1->equals(pLo));
+    ensure(p2->equals(pHi));
+    ensure(p3->equals(pHi));
+
+    // FREE MEMORY
+    factory_->destroyGeometry(pLo);
+    factory_->destroyGeometry(pHi);
+    factory_->destroyGeometry(p1);
+    factory_->destroyGeometry(p2);
+    factory_->destroyGeometry(p3);
+}
+
+// Test of getCoordinateDimension() for 2d/3d.
+template<>
+template<>
+void object::test<40>
+()
+{
+    GeometryPtr p = reader_.read("POINT(-1.233 5.678 1.0)");
+
+    ensure(p->getCoordinateDimension() == 3);
+
+    delete p;
+
+    p = reader_.read("POINT(-1.233 5.678)");
+
+    ensure(p->getCoordinateDimension() == 2);
+
+    delete p;
+}
 
 } // namespace tut
 
diff --git a/tests/unit/geom/PolygonTest.cpp b/tests/unit/geom/PolygonTest.cpp
index a186a73..9cd146f 100644
--- a/tests/unit/geom/PolygonTest.cpp
+++ b/tests/unit/geom/PolygonTest.cpp
@@ -22,561 +22,595 @@
 #include <memory>
 #include <string>
 
-namespace tut
-{
-    //
-    // Test Group
-    //
+namespace tut {
+//
+// Test Group
+//
 
-    // Common data used by tests
-    struct test_polygon_data
+// Common data used by tests
+struct test_polygon_data {
+    // Typedefs used as short names by test cases
+    typedef std::unique_ptr<geos::geom::Geometry> GeometryAutoPtr;
+    typedef std::unique_ptr<geos::geom::Polygon> PolygonAutoPtr;
+    typedef geos::geom::GeometryFactory GeometryFactory;
+
+    geos::geom::PrecisionModel pm_;
+    GeometryFactory::Ptr factory_;
+    geos::io::WKTReader reader_;
+
+    PolygonAutoPtr empty_poly_;
+    PolygonPtr poly_;
+    const size_t poly_size_;
+
+    test_polygon_data()
+        : pm_(1)
+        , factory_(GeometryFactory::create(&pm_, 0))
+        , reader_(factory_.get())
+        , empty_poly_(factory_->createPolygon()), poly_size_(7)
     {
-		// Typedefs used as short names by test cases
-		typedef std::unique_ptr<geos::geom::Geometry> GeometryAutoPtr;
-		typedef std::unique_ptr<geos::geom::Polygon> PolygonAutoPtr;
-		typedef geos::geom::GeometryFactory GeometryFactory;
-
-		geos::geom::PrecisionModel pm_;
-		GeometryFactory::Ptr factory_;
-		geos::io::WKTReader reader_;
-
-		PolygonAutoPtr empty_poly_;
-		PolygonPtr poly_;
-		const size_t poly_size_;
-
-		test_polygon_data()
-			: pm_(1)
-      , factory_(GeometryFactory::create(&pm_, 0))
-      , reader_(factory_.get())
-      , empty_poly_(factory_->createPolygon()), poly_size_(7)
-		{
-			// Create non-empty LinearRing
-			GeometryPtr geo = nullptr;
-			geo = reader_.read("POLYGON((0 10, 5 5, 10 5, 15 10, 10 15, 5 15, 0 10))");
-			poly_ = dynamic_cast<PolygonPtr>(geo);
-		}
-
-        ~test_polygon_data()
-        {
-            // FREE MEMORY
-            factory_->destroyGeometry(poly_);
-        }
-
-    private:
-        // Declare type as noncopyable
-        test_polygon_data(const test_polygon_data& other) = delete;
-        test_polygon_data& operator=(const test_polygon_data& rhs) = delete;
-    };
-
-    typedef test_group<test_polygon_data> group;
-    typedef group::object object;
-
-    group test_polygon_group("geos::geom::Polygon");
-
-    //
-    // Test Cases
-    //
-
-    // Test of user's constructor to create non-empty valid Polygon
-    template<>
-    template<>
-    void object::test<1>()
-    {
-		using geos::geom::Coordinate;
-
-		// Create non-empty Coordiantes sequence for Exterior LinearRing
-		const size_t size = 7;
-		CoordArrayPtr coords = new geos::geom::CoordinateArraySequence();
-		ensure( "sequence is null pointer.", coords != nullptr );
-
-		coords->add(Coordinate(0, 10));
-		coords->add(Coordinate(5, 5));
-		coords->add(Coordinate(10, 5));
-		coords->add(Coordinate(15, 10));
-		coords->add(Coordinate(10, 15));
-		coords->add(Coordinate(5, 15));
-		coords->add(Coordinate(0, 10));
-
-		ensure_equals( coords->size(), size );
-
-		try
-		{
-			// Create non-empty LinearRing instance
-			geos::geom::LinearRing ring(coords, factory_.get());
-			ensure( !ring.isEmpty() );
-			ensure( ring.isClosed() );
-			ensure( ring.isRing() );
-			ensure( ring.isSimple() );
-
-			// Exterior (clone is required here because Polygon takes ownership)
-			GeometryPtr geo = ring.clone();
-			LinearRingPtr exterior = dynamic_cast<LinearRingPtr>(geo);
-
-			// Create non-empty Polygon
-			//geos::geom::Polygon poly(exterior, 0, &factory_);
-			PolygonAutoPtr poly(factory_->createPolygon(exterior, nullptr));
-
-			ensure( !poly->isEmpty() );
-			ensure( poly->isSimple() );
-			ensure( poly->isValid() );
-
-			ensure_equals( poly->getNumGeometries(), 1u );
-			ensure_equals( poly->getNumInteriorRing(), 0u );
-			ensure_equals( poly->getNumPoints(), size );
-		}
-		catch (geos::util::IllegalArgumentException const& e)
-		{
-			fail(e.what());
-		}
-
+        // Create non-empty LinearRing
+        GeometryPtr geo = nullptr;
+        geo = reader_.read("POLYGON((0 10, 5 5, 10 5, 15 10, 10 15, 5 15, 0 10))");
+        poly_ = dynamic_cast<PolygonPtr>(geo);
     }
 
-    // Test of copy constructor
-    template<>
-    template<>
-    void object::test<2>()
+    ~test_polygon_data()
     {
-		GeometryAutoPtr copy(empty_poly_->clone());
+        // FREE MEMORY
+        factory_->destroyGeometry(poly_);
+    }
+
+private:
+    // Declare type as noncopyable
+    test_polygon_data(const test_polygon_data& other) = delete;
+    test_polygon_data& operator=(const test_polygon_data& rhs) = delete;
+};
+
+typedef test_group<test_polygon_data> group;
+typedef group::object object;
+
+group test_polygon_group("geos::geom::Polygon");
 
-		ensure( copy->isEmpty() );
+//
+// Test Cases
+//
+
+// Test of user's constructor to create non-empty valid Polygon
+template<>
+template<>
+void object::test<1>
+()
+{
+    using geos::geom::Coordinate;
+
+    // Create non-empty Coordiantes sequence for Exterior LinearRing
+    const size_t size = 7;
+    CoordArrayPtr coords = new geos::geom::CoordinateArraySequence();
+    ensure("sequence is null pointer.", coords != nullptr);
+
+    coords->add(Coordinate(0, 10));
+    coords->add(Coordinate(5, 5));
+    coords->add(Coordinate(10, 5));
+    coords->add(Coordinate(15, 10));
+    coords->add(Coordinate(10, 15));
+    coords->add(Coordinate(5, 15));
+    coords->add(Coordinate(0, 10));
+
+    ensure_equals(coords->size(), size);
+
+    try {
+        // Create non-empty LinearRing instance
+        geos::geom::LinearRing ring(coords, factory_.get());
+        ensure(!ring.isEmpty());
+        ensure(ring.isClosed());
+        ensure(ring.isRing());
+        ensure(ring.isSimple());
+
+        // Exterior (clone is required here because Polygon takes ownership)
+        GeometryPtr geo = ring.clone();
+        LinearRingPtr exterior = dynamic_cast<LinearRingPtr>(geo);
+
+        // Create non-empty Polygon
+        //geos::geom::Polygon poly(exterior, 0, &factory_);
+        PolygonAutoPtr poly(factory_->createPolygon(exterior, nullptr));
+
+        ensure(!poly->isEmpty());
+        ensure(poly->isSimple());
+        ensure(poly->isValid());
+
+        ensure_equals(poly->getNumGeometries(), 1u);
+        ensure_equals(poly->getNumInteriorRing(), 0u);
+        ensure_equals(poly->getNumPoints(), size);
+    }
+    catch(geos::util::IllegalArgumentException const& e) {
+        fail(e.what());
     }
 
-	// Test of isEmpty() for empty Polygon
-	template<>
-	template<>
-	void object::test<3>()
-	{
-		ensure( empty_poly_->isEmpty() );
-	}
-
-	// Test of isSimple() for empty Polygon
-	template<>
-	template<>
-	void object::test<4>()
-	{
-		ensure( empty_poly_->isSimple() );
-	}
-
-	// Test of isValid() for empty Polygon
-	template<>
-	template<>
-	void object::test<5>()
-	{
-		//inform("Test is waiting for Bug #87 resolution.");
-
-		// TODO - mloskot - is empty valid or not?
-		//ensure( !ring.isValid() );
-	}
-
-
-	// Test of getEnvelope() for empty Polygon
-	template<>
-	template<>
-	void object::test<6>()
-	{
-		//inform( "Test waiting for resolution of getEnvelope() issue." );
-		//http://geos.osgeo.org/pipermail/geos-devel/2006-April/002123.html
-
-		//EnvelopeCPtr envelope = empty_poly_->getEnvelopeInternal();
-		//ensure( envelope != 0 );
-		//ensure( envelope->isNull() );
-	}
-
-	// Test of getBoundary() for empty Polygon
-	template<>
-	template<>
-	void object::test<7>()
-	{
-		GeometryPtr boundary = empty_poly_->getBoundary();
-		ensure( boundary != nullptr );
-		ensure( boundary->isEmpty() );
-		factory_->destroyGeometry(boundary);
-	}
-
-	// Test of convexHull() for empty Polygon
-	template<>
-	template<>
-	void object::test<8>()
-	{
-		GeometryPtr hull = empty_poly_->convexHull();
-		ensure( hull != nullptr );
-		ensure( hull->isEmpty() );
-		factory_->destroyGeometry(hull);
-	}
-
-	// Test of getGeometryTypeId() for empty Polygon
-	template<>
-	template<>
-	void object::test<9>()
-	{
-		ensure_equals( empty_poly_->getGeometryTypeId(), geos::geom::GEOS_POLYGON );
-	}
-
-	// Test of getDimension() for empty Polygon
-	template<>
-	template<>
-	void object::test<10>()
-	{
-		ensure_equals( empty_poly_->getDimension(), geos::geom::Dimension::A );
-	}
-
-	// Test of getBoundaryDimension() for empty Polygon
-	template<>
-	template<>
-	void object::test<11>()
-	{
-		ensure_equals( empty_poly_->getBoundaryDimension(), geos::geom::Dimension::L );
-	}
-
-	// Test of getNumPoints() for empty Polygon
-	template<>
-	template<>
-	void object::test<12>()
-	{
-		ensure_equals( empty_poly_->getNumPoints(), 0u );
-	}
-
-	// Test of getLength() for empty Polygon
-	template<>
-	template<>
-	void object::test<13>()
-	{
-		ensure_equals( empty_poly_->getLength(), 0.0 );
-	}
-
-	// Test of getArea() for empty Polygon
-	template<>
-	template<>
-	void object::test<14>()
-	{
-		ensure_equals( empty_poly_->getArea(), 0.0 );
-	}
-
-    // Test of isEmpty() for non-empty Polygon
-    template<>
-    template<>
-    void object::test<15>()
-	{
-		ensure( poly_ != nullptr );
-		ensure( !poly_->isEmpty() );
-	}
-
-    // Test of getEnvelope() for non-empty Polygon
-    template<>
-    template<>
-    void object::test<17>()
-	{
-		ensure( poly_ != nullptr );
-
-		GeometryPtr envelope = poly_->getEnvelope();
-		ensure( envelope != nullptr );
-		ensure( !envelope->isEmpty() );
-		ensure_equals( envelope->getDimension(), geos::geom::Dimension::A );
-
-		// FREE MEMORY
-		factory_->destroyGeometry(envelope);
-	}
-
-	// Test of getBoundary() for non-empty Polygon
-    template<>
-    template<>
-    void object::test<18>()
-	{
-		ensure( poly_ != nullptr );
-
-		GeometryPtr boundary = poly_->getBoundary();
-		ensure( boundary != nullptr );
-
-		// OGC 05-126, Version: 1.1.0, Chapter 6.1.10 Surface
-		ensure( "[OGC] The boundary of Polygin is the set of closed Curves.", !boundary->isEmpty() );
-
-		// FREE MEMORY
-		factory_->destroyGeometry(boundary);
-	}
-
-	// Test of convexHull() for non-empty Polygon
-    template<>
-    template<>
-    void object::test<19>()
-	{
-		ensure( poly_ != nullptr );
-
-		GeometryPtr hull = poly_->convexHull();
-		ensure( hull != nullptr );
-		ensure( !hull->isEmpty() );
-		ensure_equals( hull->getGeometryTypeId(), geos::geom::GEOS_POLYGON );
-		ensure_equals( hull->getDimension(), geos::geom::Dimension::A );
-
-		// FREE MEMORY
-		factory_->destroyGeometry(hull);
-	}
-
-	// Test of getGeometryTypeId() for non-empty Polygon
-    template<>
-    template<>
-    void object::test<20>()
-	{
-		ensure( poly_ != nullptr );
-		ensure_equals( poly_->getGeometryTypeId(), geos::geom::GEOS_POLYGON );
-	}
-
-	// Test of getDimension() for non-empty Polygon
-    template<>
-    template<>
-    void object::test<21>()
-	{
-		ensure( poly_ != nullptr );
-		ensure_equals( poly_->getDimension(), geos::geom::Dimension::A );
-	}
-
-	// Test of getBoundaryDimension() for non-empty Polygon
-    template<>
-    template<>
-    void object::test<22>()
-	{
-		ensure( poly_ != nullptr );
-		ensure_equals( poly_->getBoundaryDimension(), geos::geom::Dimension::L );
-	}
-
-	// Test of getNumPoints() for non-empty Polygon
-    template<>
-    template<>
-    void object::test<23>()
-	{
-		ensure( poly_ != nullptr );
-		ensure_equals( poly_->getNumPoints(), poly_size_ );
-	}
-
-	// Test of getLength() for non-empty Polygon
-    template<>
-    template<>
-    void object::test<24>()
-	{
-		ensure( poly_ != nullptr );
-		ensure( poly_->getLength() != 0.0 );
-
-		const double tolerance = 0.0001;
-		const double expected = 38.284271247461902;
-		const double diff = std::fabs(poly_->getLength() - expected);
-		ensure( diff <= tolerance );
-	}
-
-	// Test of getArea() for non-empty Polygon
-    template<>
-    template<>
-    void object::test<25>()
-	{
-		ensure( poly_ != nullptr );
-		ensure( poly_->getArea() != 0.0 );
-	}
-
-	// Test of getCoordinates() for non-empty Polygon
-    template<>
-    template<>
-    void object::test<26>()
-	{
-		ensure( poly_ != nullptr );
-
-		// Caller takes ownership of 'coords'
-		CoordSeqPtr coords = poly_->getCoordinates();
-		ensure( coords != nullptr );
-		ensure( !coords->isEmpty() );
-		ensure_equals( coords->getSize(), poly_->getNumPoints() );
-
-		// FREE MEMORY
-		delete coords;
-	}
-
-	// Test of clone() and equals() for non-empty Polygon
-    template<>
-    template<>
-    void object::test<27>()
-	{
-		ensure( poly_ != nullptr );
-
-		GeometryPtr geo = poly_->clone();
-		ensure( geo != nullptr );
-		ensure( geo->equals(poly_) );
-
-		factory_->destroyGeometry(geo);
-	}
-
-	// Test of getExteriorRing() for non-empty Polygon
-    template<>
-    template<>
-    void object::test<28>()
-	{
-		ensure( poly_ != nullptr );
-
-		LineStringCPtr ring = poly_->getExteriorRing();
-		ensure( ring != nullptr );
-		ensure( ring->isRing() );
-		ensure_equals( ring->getNumPoints(), poly_size_ );
-	}
-
-	// Test of getNumInteriorRing() for non-empty Polygon but without interior rings
-    template<>
-    template<>
-    void object::test<29>()
-	{
-		ensure( poly_ != nullptr );
-		ensure_equals( poly_->getNumInteriorRing(), 0u );
-	}
-
-	// Test of getInteriorRingN() for non-empty Polygon with interior rings
-    template<>
-    template<>
-    void object::test<30>()
-	{
-		const size_t holesNum = 1;
-
-		GeometryPtr geo = nullptr;
-		geo = reader_.read("POLYGON ((0 0, 100 0, 100 100, 0 100, 0 0), (1 1, 1 10, 10 10, 10 1, 1 1) )");
-		ensure( geo != nullptr );
-		ensure_equals( geo->getGeometryTypeId(), geos::geom::GEOS_POLYGON );
-
-		PolygonPtr poly = dynamic_cast<PolygonPtr>(geo);
-		ensure( poly != nullptr );
-		ensure_equals( poly->getNumInteriorRing(), holesNum );
-
-		LineStringCPtr interior = poly->getInteriorRingN(0);
-		ensure( interior != nullptr );
-		ensure( interior->isRing() );
-
-		ensure_equals( interior->getGeometryTypeId(), geos::geom::GEOS_LINEARRING );
-
-		factory_->destroyGeometry(geo);
-	}
-
-	// Test of getCoordiante() for non-empty Polygon
-    template<>
-    template<>
-    void object::test<31>()
-	{
-		ensure( poly_ != nullptr );
-		// "POLYGON((0 10, 5 5, 10 5, 15 10, 10 15, 5 15, 0 10))"
-
-		CoordinateCPtr coord = poly_->getCoordinate();
-		ensure( coord != nullptr );
-		ensure_equals( coord->x, 0 );
-		ensure_equals( coord->y, 10 );
-	}
-
-	// Test of getCoordiantes() for non-empty Polygon
-    template<>
-    template<>
-    void object::test<32>()
-	{
-		ensure( poly_ != nullptr );
-		// "POLYGON((0 10, 5 5, 10 5, 15 10, 10 15, 5 15, 0 10))"
-
-		CoordSeqPtr coords = poly_->getCoordinates();
-		ensure( coords != nullptr );
-		ensure_equals( coords->getSize(), poly_size_ );
-
-		// Check first and last coordinates
-		const size_t lastPos = poly_size_ - 1;
-		ensure_equals( coords->getAt(0), coords->getAt(lastPos) );
-
-		// Check coordinate	from the middle of ring
-		const int middlePos = 3;
-		ensure_equals( coords->getAt(middlePos).x, 15 );
-		ensure_equals( coords->getAt(middlePos).y, 10 );
-
-		// FREE MEMORY
-		delete coords;
-	}
-
-	// Test of getGeometryType() for non-empty Polygon
-    template<>
-    template<>
-    void object::test<33>()
-	{
-		ensure( poly_ != nullptr );
-
-		const std::string type("Polygon");
-		ensure_equals( poly_->getGeometryType(), type );
-	}
-
-	// Test of Point* getCentroid() const for empty Polygon
-    template<>
-    template<>
-    void object::test<34>()
-	{
-		PointPtr point = empty_poly_->getCentroid();
-		ensure( point == nullptr );
-	}
-
-	// Test of Geometry::getCentroid(Coordinate& ret) const for empty Polygon
-    template<>
-    template<>
-    void object::test<35>()
-	{
-		geos::geom::Coordinate centroid;
-		bool isCentroid = empty_poly_->getCentroid(centroid);
-		ensure( !isCentroid );
-	}
-
-	// Test of getCentroid() for non-empty Polygon
-    template<>
-    template<>
-    void object::test<36>()
-	{
-		PointPtr point = poly_->getCentroid();
-		ensure( point != nullptr );
-		ensure( !point->isEmpty() );
-		ensure_equals( point->getGeometryTypeId(), geos::geom::GEOS_POINT );
-
-		// FREE MEMORY
-		factory_->destroyGeometry(point);
-	}
-
-	// Test of Geometry::getCentroid(Coordinate& ret) const for non-empty Polygon
-    template<>
-    template<>
-    void object::test<37>()
-	{
-		geos::geom::Coordinate centroid;
-		bool isCentroid = poly_->getCentroid(centroid);
-		ensure( isCentroid );
-	}
-
-	// Test of comparison of centroids returned by two versions of getCentroid() for non-empty Polygon
-    template<>
-    template<>
-    void object::test<38>()
-	{
-		// First centroid
-		PointPtr point = poly_->getCentroid();
-		ensure( point != nullptr );
-		ensure( !point->isEmpty() );
-		ensure_equals( point->getGeometryTypeId(), geos::geom::GEOS_POINT );
-
-		CoordinateCPtr pointCoord = point->getCoordinate();
-		ensure( pointCoord != nullptr );
-		geos::geom::Coordinate pointCentr(*pointCoord);
-		// FREE MEMORY
-		factory_->destroyGeometry(point);
-
-		// Second centroid
-		geos::geom::Coordinate coordCentr;
-		bool isCentroid = poly_->getCentroid(coordCentr);
-		ensure( isCentroid );
-
-		// Comparison of two centroids
-		ensure_equals( "Check Polygon::getCentroid() functions.", coordCentr, pointCentr );
-	}
-
-	// Test of Geometry::buffer(0) with convex polygon
-    template<>
-    template<>
-    void object::test<39>()
-	{
-		std::unique_ptr<geos::geom::Geometry> gBuffer(poly_->buffer(0));
-        ensure_not(gBuffer->isEmpty());
-        ensure(gBuffer->isValid());
-        ensure_equals(gBuffer->getGeometryTypeId(), geos::geom::GEOS_POLYGON);
-        ensure(gBuffer->getNumPoints() == poly_->getNumPoints());
-	}
+}
+
+// Test of copy constructor
+template<>
+template<>
+void object::test<2>
+()
+{
+    GeometryAutoPtr copy(empty_poly_->clone());
+
+    ensure(copy->isEmpty());
+}
+
+// Test of isEmpty() for empty Polygon
+template<>
+template<>
+void object::test<3>
+()
+{
+    ensure(empty_poly_->isEmpty());
+}
+
+// Test of isSimple() for empty Polygon
+template<>
+template<>
+void object::test<4>
+()
+{
+    ensure(empty_poly_->isSimple());
+}
+
+// Test of isValid() for empty Polygon
+template<>
+template<>
+void object::test<5>
+()
+{
+    //inform("Test is waiting for Bug #87 resolution.");
+
+    // TODO - mloskot - is empty valid or not?
+    //ensure( !ring.isValid() );
+}
+
+
+// Test of getEnvelope() for empty Polygon
+template<>
+template<>
+void object::test<6>
+()
+{
+    //inform( "Test waiting for resolution of getEnvelope() issue." );
+    //http://geos.osgeo.org/pipermail/geos-devel/2006-April/002123.html
+
+    //EnvelopeCPtr envelope = empty_poly_->getEnvelopeInternal();
+    //ensure( envelope != 0 );
+    //ensure( envelope->isNull() );
+}
+
+// Test of getBoundary() for empty Polygon
+template<>
+template<>
+void object::test<7>
+()
+{
+    GeometryPtr boundary = empty_poly_->getBoundary();
+    ensure(boundary != nullptr);
+    ensure(boundary->isEmpty());
+    factory_->destroyGeometry(boundary);
+}
+
+// Test of convexHull() for empty Polygon
+template<>
+template<>
+void object::test<8>
+()
+{
+    GeometryPtr hull = empty_poly_->convexHull();
+    ensure(hull != nullptr);
+    ensure(hull->isEmpty());
+    factory_->destroyGeometry(hull);
+}
+
+// Test of getGeometryTypeId() for empty Polygon
+template<>
+template<>
+void object::test<9>
+()
+{
+    ensure_equals(empty_poly_->getGeometryTypeId(), geos::geom::GEOS_POLYGON);
+}
+
+// Test of getDimension() for empty Polygon
+template<>
+template<>
+void object::test<10>
+()
+{
+    ensure_equals(empty_poly_->getDimension(), geos::geom::Dimension::A);
+}
+
+// Test of getBoundaryDimension() for empty Polygon
+template<>
+template<>
+void object::test<11>
+()
+{
+    ensure_equals(empty_poly_->getBoundaryDimension(), geos::geom::Dimension::L);
+}
+
+// Test of getNumPoints() for empty Polygon
+template<>
+template<>
+void object::test<12>
+()
+{
+    ensure_equals(empty_poly_->getNumPoints(), 0u);
+}
+
+// Test of getLength() for empty Polygon
+template<>
+template<>
+void object::test<13>
+()
+{
+    ensure_equals(empty_poly_->getLength(), 0.0);
+}
+
+// Test of getArea() for empty Polygon
+template<>
+template<>
+void object::test<14>
+()
+{
+    ensure_equals(empty_poly_->getArea(), 0.0);
+}
+
+// Test of isEmpty() for non-empty Polygon
+template<>
+template<>
+void object::test<15>
+()
+{
+    ensure(poly_ != nullptr);
+    ensure(!poly_->isEmpty());
+}
+
+// Test of getEnvelope() for non-empty Polygon
+template<>
+template<>
+void object::test<17>
+()
+{
+    ensure(poly_ != nullptr);
+
+    GeometryPtr envelope = poly_->getEnvelope();
+    ensure(envelope != nullptr);
+    ensure(!envelope->isEmpty());
+    ensure_equals(envelope->getDimension(), geos::geom::Dimension::A);
+
+    // FREE MEMORY
+    factory_->destroyGeometry(envelope);
+}
+
+// Test of getBoundary() for non-empty Polygon
+template<>
+template<>
+void object::test<18>
+()
+{
+    ensure(poly_ != nullptr);
+
+    GeometryPtr boundary = poly_->getBoundary();
+    ensure(boundary != nullptr);
+
+    // OGC 05-126, Version: 1.1.0, Chapter 6.1.10 Surface
+    ensure("[OGC] The boundary of Polygin is the set of closed Curves.", !boundary->isEmpty());
+
+    // FREE MEMORY
+    factory_->destroyGeometry(boundary);
+}
+
+// Test of convexHull() for non-empty Polygon
+template<>
+template<>
+void object::test<19>
+()
+{
+    ensure(poly_ != nullptr);
+
+    GeometryPtr hull = poly_->convexHull();
+    ensure(hull != nullptr);
+    ensure(!hull->isEmpty());
+    ensure_equals(hull->getGeometryTypeId(), geos::geom::GEOS_POLYGON);
+    ensure_equals(hull->getDimension(), geos::geom::Dimension::A);
+
+    // FREE MEMORY
+    factory_->destroyGeometry(hull);
+}
+
+// Test of getGeometryTypeId() for non-empty Polygon
+template<>
+template<>
+void object::test<20>
+()
+{
+    ensure(poly_ != nullptr);
+    ensure_equals(poly_->getGeometryTypeId(), geos::geom::GEOS_POLYGON);
+}
+
+// Test of getDimension() for non-empty Polygon
+template<>
+template<>
+void object::test<21>
+()
+{
+    ensure(poly_ != nullptr);
+    ensure_equals(poly_->getDimension(), geos::geom::Dimension::A);
+}
+
+// Test of getBoundaryDimension() for non-empty Polygon
+template<>
+template<>
+void object::test<22>
+()
+{
+    ensure(poly_ != nullptr);
+    ensure_equals(poly_->getBoundaryDimension(), geos::geom::Dimension::L);
+}
+
+// Test of getNumPoints() for non-empty Polygon
+template<>
+template<>
+void object::test<23>
+()
+{
+    ensure(poly_ != nullptr);
+    ensure_equals(poly_->getNumPoints(), poly_size_);
+}
+
+// Test of getLength() for non-empty Polygon
+template<>
+template<>
+void object::test<24>
+()
+{
+    ensure(poly_ != nullptr);
+    ensure(poly_->getLength() != 0.0);
+
+    const double tolerance = 0.0001;
+    const double expected = 38.284271247461902;
+    const double diff = std::fabs(poly_->getLength() - expected);
+    ensure(diff <= tolerance);
+}
+
+// Test of getArea() for non-empty Polygon
+template<>
+template<>
+void object::test<25>
+()
+{
+    ensure(poly_ != nullptr);
+    ensure(poly_->getArea() != 0.0);
+}
+
+// Test of getCoordinates() for non-empty Polygon
+template<>
+template<>
+void object::test<26>
+()
+{
+    ensure(poly_ != nullptr);
+
+    // Caller takes ownership of 'coords'
+    CoordSeqPtr coords = poly_->getCoordinates();
+    ensure(coords != nullptr);
+    ensure(!coords->isEmpty());
+    ensure_equals(coords->getSize(), poly_->getNumPoints());
+
+    // FREE MEMORY
+    delete coords;
+}
+
+// Test of clone() and equals() for non-empty Polygon
+template<>
+template<>
+void object::test<27>
+()
+{
+    ensure(poly_ != nullptr);
+
+    GeometryPtr geo = poly_->clone();
+    ensure(geo != nullptr);
+    ensure(geo->equals(poly_));
+
+    factory_->destroyGeometry(geo);
+}
+
+// Test of getExteriorRing() for non-empty Polygon
+template<>
+template<>
+void object::test<28>
+()
+{
+    ensure(poly_ != nullptr);
+
+    LineStringCPtr ring = poly_->getExteriorRing();
+    ensure(ring != nullptr);
+    ensure(ring->isRing());
+    ensure_equals(ring->getNumPoints(), poly_size_);
+}
+
+// Test of getNumInteriorRing() for non-empty Polygon but without interior rings
+template<>
+template<>
+void object::test<29>
+()
+{
+    ensure(poly_ != nullptr);
+    ensure_equals(poly_->getNumInteriorRing(), 0u);
+}
+
+// Test of getInteriorRingN() for non-empty Polygon with interior rings
+template<>
+template<>
+void object::test<30>
+()
+{
+    const size_t holesNum = 1;
+
+    GeometryPtr geo = nullptr;
+    geo = reader_.read("POLYGON ((0 0, 100 0, 100 100, 0 100, 0 0), (1 1, 1 10, 10 10, 10 1, 1 1) )");
+    ensure(geo != nullptr);
+    ensure_equals(geo->getGeometryTypeId(), geos::geom::GEOS_POLYGON);
+
+    PolygonPtr poly = dynamic_cast<PolygonPtr>(geo);
+    ensure(poly != nullptr);
+    ensure_equals(poly->getNumInteriorRing(), holesNum);
+
+    LineStringCPtr interior = poly->getInteriorRingN(0);
+    ensure(interior != nullptr);
+    ensure(interior->isRing());
+
+    ensure_equals(interior->getGeometryTypeId(), geos::geom::GEOS_LINEARRING);
+
+    factory_->destroyGeometry(geo);
+}
+
+// Test of getCoordiante() for non-empty Polygon
+template<>
+template<>
+void object::test<31>
+()
+{
+    ensure(poly_ != nullptr);
+    // "POLYGON((0 10, 5 5, 10 5, 15 10, 10 15, 5 15, 0 10))"
+
+    CoordinateCPtr coord = poly_->getCoordinate();
+    ensure(coord != nullptr);
+    ensure_equals(coord->x, 0);
+    ensure_equals(coord->y, 10);
+}
+
+// Test of getCoordiantes() for non-empty Polygon
+template<>
+template<>
+void object::test<32>
+()
+{
+    ensure(poly_ != nullptr);
+    // "POLYGON((0 10, 5 5, 10 5, 15 10, 10 15, 5 15, 0 10))"
+
+    CoordSeqPtr coords = poly_->getCoordinates();
+    ensure(coords != nullptr);
+    ensure_equals(coords->getSize(), poly_size_);
+
+    // Check first and last coordinates
+    const size_t lastPos = poly_size_ - 1;
+    ensure_equals(coords->getAt(0), coords->getAt(lastPos));
+
+    // Check coordinate	from the middle of ring
+    const int middlePos = 3;
+    ensure_equals(coords->getAt(middlePos).x, 15);
+    ensure_equals(coords->getAt(middlePos).y, 10);
+
+    // FREE MEMORY
+    delete coords;
+}
+
+// Test of getGeometryType() for non-empty Polygon
+template<>
+template<>
+void object::test<33>
+()
+{
+    ensure(poly_ != nullptr);
+
+    const std::string type("Polygon");
+    ensure_equals(poly_->getGeometryType(), type);
+}
+
+// Test of Point* getCentroid() const for empty Polygon
+template<>
+template<>
+void object::test<34>
+()
+{
+    PointPtr point = empty_poly_->getCentroid();
+    ensure(point == nullptr);
+}
+
+// Test of Geometry::getCentroid(Coordinate& ret) const for empty Polygon
+template<>
+template<>
+void object::test<35>
+()
+{
+    geos::geom::Coordinate centroid;
+    bool isCentroid = empty_poly_->getCentroid(centroid);
+    ensure(!isCentroid);
+}
+
+// Test of getCentroid() for non-empty Polygon
+template<>
+template<>
+void object::test<36>
+()
+{
+    PointPtr point = poly_->getCentroid();
+    ensure(point != nullptr);
+    ensure(!point->isEmpty());
+    ensure_equals(point->getGeometryTypeId(), geos::geom::GEOS_POINT);
+
+    // FREE MEMORY
+    factory_->destroyGeometry(point);
+}
+
+// Test of Geometry::getCentroid(Coordinate& ret) const for non-empty Polygon
+template<>
+template<>
+void object::test<37>
+()
+{
+    geos::geom::Coordinate centroid;
+    bool isCentroid = poly_->getCentroid(centroid);
+    ensure(isCentroid);
+}
+
+// Test of comparison of centroids returned by two versions of getCentroid() for non-empty Polygon
+template<>
+template<>
+void object::test<38>
+()
+{
+    // First centroid
+    PointPtr point = poly_->getCentroid();
+    ensure(point != nullptr);
+    ensure(!point->isEmpty());
+    ensure_equals(point->getGeometryTypeId(), geos::geom::GEOS_POINT);
+
+    CoordinateCPtr pointCoord = point->getCoordinate();
+    ensure(pointCoord != nullptr);
+    geos::geom::Coordinate pointCentr(*pointCoord);
+    // FREE MEMORY
+    factory_->destroyGeometry(point);
+
+    // Second centroid
+    geos::geom::Coordinate coordCentr;
+    bool isCentroid = poly_->getCentroid(coordCentr);
+    ensure(isCentroid);
+
+    // Comparison of two centroids
+    ensure_equals("Check Polygon::getCentroid() functions.", coordCentr, pointCentr);
+}
+
+// Test of Geometry::buffer(0) with convex polygon
+template<>
+template<>
+void object::test<39>
+()
+{
+    std::unique_ptr<geos::geom::Geometry> gBuffer(poly_->buffer(0));
+    ensure_not(gBuffer->isEmpty());
+    ensure(gBuffer->isValid());
+    ensure_equals(gBuffer->getGeometryTypeId(), geos::geom::GEOS_POLYGON);
+    ensure(gBuffer->getNumPoints() == poly_->getNumPoints());
+}
 
 } // namespace tut
diff --git a/tests/unit/geom/PrecisionModelTest.cpp b/tests/unit/geom/PrecisionModelTest.cpp
index 6a760ee..0f7789f 100644
--- a/tests/unit/geom/PrecisionModelTest.cpp
+++ b/tests/unit/geom/PrecisionModelTest.cpp
@@ -7,136 +7,144 @@
 #include <geos/geom/PrecisionModel.h>
 #include <geos/geom/Coordinate.h>
 
-namespace tut
-{
-    //
-    // Test Group
-    //
-
-    // Common data used by tests
-    struct test_precisionmodel_data
-    {
-        typedef geos::geom::PrecisionModel PrecisionModel;
-        typedef geos::geom::Coordinate Coordinate;
-        test_precisionmodel_data() {}
-
-        void preciseCoordinateTester(const PrecisionModel& pm,
-                      double x1, double y1,
-                      double x2, double y2)
-        {
-              Coordinate p(x1, y1);
-
-              pm.makePrecise(p);
-
-              Coordinate pPrecise(x2, y2);
-              ensure(p.equals2D(pPrecise));
-        }
-
-
-    };
-
-    typedef test_group<test_precisionmodel_data> group;
-    typedef group::object object;
-
-    group test_precisionmodel_group("geos::geom::PrecisionModel");
+namespace tut {
+//
+// Test Group
+//
 
-    //
-    // Test Cases
-    //
+// Common data used by tests
+struct test_precisionmodel_data {
+    typedef geos::geom::PrecisionModel PrecisionModel;
+    typedef geos::geom::Coordinate Coordinate;
+    test_precisionmodel_data() {}
 
-    // Test of default constructor
-    template<>
-    template<>
-    void object::test<1>()
+    void
+    preciseCoordinateTester(const PrecisionModel& pm,
+                            double x1, double y1,
+                            double x2, double y2)
     {
-        PrecisionModel pm;
-        ensure(pm.isFloating());
-        ensure_equals(pm.getMaximumSignificantDigits(), 16);
-        ensure_equals(pm.getScale(), 0);
-    }
+        Coordinate p(x1, y1);
 
-    // Test FLOAT_SINGLE model
-    template<>
-    template<>
-    void object::test<2>()
-    {
-        PrecisionModel pm(PrecisionModel::FLOATING_SINGLE);
-        ensure(pm.isFloating());
-        ensure_equals(pm.getType(), PrecisionModel::FLOATING_SINGLE);
-        ensure_equals(pm.getMaximumSignificantDigits(), 6);
-    }
+        pm.makePrecise(p);
 
-    // Test default FIXED model
-    template<>
-    template<>
-    void object::test<3>()
-    {
-        PrecisionModel pm(PrecisionModel::FIXED);
-        ensure(!pm.isFloating());
-        ensure_equals(pm.getType(), PrecisionModel::FIXED);
-        ensure_equals(pm.getMaximumSignificantDigits(), 0);
+        Coordinate pPrecise(x2, y2);
+        ensure(p.equals2D(pPrecise));
     }
 
-    // Test maximum significant digits (1:0)
-    template<>
-    template<>
-    void object::test<4>()
-    {
-        PrecisionModel pm(1);
-        ensure(!pm.isFloating());
-        ensure_equals(pm.getType(), PrecisionModel::FIXED);
-        ensure_equals(pm.getMaximumSignificantDigits(), 0);
-    }
 
-    // Test maximum significant digits (10:1)
-    template<>
-    template<>
-    void object::test<5>()
-    {
-        PrecisionModel pm(10);
-        ensure_equals(pm.getType(), PrecisionModel::FIXED);
-        ensure_equals(pm.getMaximumSignificantDigits(), 1);
-    }
+};
 
-    // Test maximum significant digits (1000:3)
-    template<>
-    template<>
-    void object::test<6>()
-    {
-        PrecisionModel pm(1000);
-        ensure_equals(pm.getType(), PrecisionModel::FIXED);
-        ensure_equals(pm.getMaximumSignificantDigits(), 3);
-    }
+typedef test_group<test_precisionmodel_data> group;
+typedef group::object object;
 
-    // Test maximum significant digits (0.1:-1)
-    template<>
-    template<>
-    void object::test<7>()
-    {
-        PrecisionModel pm(0.1);
-        ensure_equals(pm.getType(), PrecisionModel::FIXED);
-        ensure_equals(pm.getMaximumSignificantDigits(), -1);
-    }
+group test_precisionmodel_group("geos::geom::PrecisionModel");
 
-    // Test maximum significant digits (0.001:-3)
-    template<>
-    template<>
-    void object::test<8>()
-    {
-        PrecisionModel pm(0.001);
-        ensure_equals(pm.getType(), PrecisionModel::FIXED);
-        ensure_equals(pm.getMaximumSignificantDigits(), -3);
-    }
+//
+// Test Cases
+//
 
-    // Test makePrecise
-    template<>
-    template<>
-    void object::test<9>()
-    {
-        PrecisionModel pm_10(0.1);
-        preciseCoordinateTester(pm_10, 1200.4, 1240.4, 1200, 1240);
-        preciseCoordinateTester(pm_10, 1209.4, 1240.4, 1210, 1240);
-    }
+// Test of default constructor
+template<>
+template<>
+void object::test<1>
+()
+{
+    PrecisionModel pm;
+    ensure(pm.isFloating());
+    ensure_equals(pm.getMaximumSignificantDigits(), 16);
+    ensure_equals(pm.getScale(), 0);
+}
+
+// Test FLOAT_SINGLE model
+template<>
+template<>
+void object::test<2>
+()
+{
+    PrecisionModel pm(PrecisionModel::FLOATING_SINGLE);
+    ensure(pm.isFloating());
+    ensure_equals(pm.getType(), PrecisionModel::FLOATING_SINGLE);
+    ensure_equals(pm.getMaximumSignificantDigits(), 6);
+}
+
+// Test default FIXED model
+template<>
+template<>
+void object::test<3>
+()
+{
+    PrecisionModel pm(PrecisionModel::FIXED);
+    ensure(!pm.isFloating());
+    ensure_equals(pm.getType(), PrecisionModel::FIXED);
+    ensure_equals(pm.getMaximumSignificantDigits(), 0);
+}
+
+// Test maximum significant digits (1:0)
+template<>
+template<>
+void object::test<4>
+()
+{
+    PrecisionModel pm(1);
+    ensure(!pm.isFloating());
+    ensure_equals(pm.getType(), PrecisionModel::FIXED);
+    ensure_equals(pm.getMaximumSignificantDigits(), 0);
+}
+
+// Test maximum significant digits (10:1)
+template<>
+template<>
+void object::test<5>
+()
+{
+    PrecisionModel pm(10);
+    ensure_equals(pm.getType(), PrecisionModel::FIXED);
+    ensure_equals(pm.getMaximumSignificantDigits(), 1);
+}
+
+// Test maximum significant digits (1000:3)
+template<>
+template<>
+void object::test<6>
+()
+{
+    PrecisionModel pm(1000);
+    ensure_equals(pm.getType(), PrecisionModel::FIXED);
+    ensure_equals(pm.getMaximumSignificantDigits(), 3);
+}
+
+// Test maximum significant digits (0.1:-1)
+template<>
+template<>
+void object::test<7>
+()
+{
+    PrecisionModel pm(0.1);
+    ensure_equals(pm.getType(), PrecisionModel::FIXED);
+    ensure_equals(pm.getMaximumSignificantDigits(), -1);
+}
+
+// Test maximum significant digits (0.001:-3)
+template<>
+template<>
+void object::test<8>
+()
+{
+    PrecisionModel pm(0.001);
+    ensure_equals(pm.getType(), PrecisionModel::FIXED);
+    ensure_equals(pm.getMaximumSignificantDigits(), -3);
+}
+
+// Test makePrecise
+template<>
+template<>
+void object::test<9>
+()
+{
+    PrecisionModel pm_10(0.1);
+    preciseCoordinateTester(pm_10, 1200.4, 1240.4, 1200, 1240);
+    preciseCoordinateTester(pm_10, 1209.4, 1240.4, 1210, 1240);
+}
 
 } // namespace tut
 
diff --git a/tests/unit/geom/TriangleTest.cpp b/tests/unit/geom/TriangleTest.cpp
index 31552ff..0ab6511 100644
--- a/tests/unit/geom/TriangleTest.cpp
+++ b/tests/unit/geom/TriangleTest.cpp
@@ -9,164 +9,168 @@
 // std
 #include <cmath>
 
-namespace tut
+namespace tut {
+//
+// Test Group
+//
+
+// Common data used by tests
+struct test_triangle_data {
+    // Coordiantes of simple triangle: ABC
+    geos::geom::Coordinate a;
+    geos::geom::Coordinate b;
+    geos::geom::Coordinate c;
+
+    geos::geom::Coordinate d;
+    geos::geom::Coordinate e;
+    geos::geom::Coordinate f;
+
+    test_triangle_data()
+        : a(3, 3), b(9, 3), c(6, 6), d(-4, -2), e(-8, -2), f(-4, -4)
+    {}
+};
+
+typedef test_group<test_triangle_data> group;
+typedef group::object object;
+
+group test_triangle_group("geos::geom::Triangle");
+
+//
+// Test Cases
+//
+
+// Test of default constructor
+template<>
+template<>
+void object::test<1>
+()
+{
+    // TODO - mloskot - discuss about adding default constructor
+    ensure("NOTE: Triangle has no default constructor.", true);
+}
+
+// Test of overriden ctor
+template<>
+template<>
+void object::test<2>
+()
+{
+    geos::geom::Triangle abc(a, b, c);
+
+    ensure_equals(abc.p0, a);
+    ensure_equals(abc.p1, b);
+    ensure_equals(abc.p2, c);
+}
+
+// Test of copy ctor
+template<>
+template<>
+void object::test<3>
+()
+{
+    geos::geom::Triangle abc(a, b, c);
+    geos::geom::Triangle copy(abc);
+
+    ensure_equals(copy.p0, a);
+    ensure_equals(copy.p1, b);
+    ensure_equals(copy.p2, c);
+}
+
+// Test of assignment operator
+template<>
+template<>
+void object::test<4>
+()
 {
-    //
-    // Test Group
-    //
-
-    // Common data used by tests
-    struct test_triangle_data
-    {
-		// Coordiantes of simple triangle: ABC
-		geos::geom::Coordinate a;
-		geos::geom::Coordinate b;
-		geos::geom::Coordinate c;
-
-		geos::geom::Coordinate d;
-		geos::geom::Coordinate e;
-		geos::geom::Coordinate f;
-
-        test_triangle_data()
-			: a(3, 3), b(9, 3), c(6, 6), d(-4, -2), e(-8, -2), f(-4, -4)
-		{}
-    };
-
-    typedef test_group<test_triangle_data> group;
-    typedef group::object object;
-
-    group test_triangle_group("geos::geom::Triangle");
-
-    //
-    // Test Cases
-    //
-
-    // Test of default constructor
-    template<>
-    template<>
-    void object::test<1>()
-    {
-        // TODO - mloskot - discuss about adding default constructor
-        ensure("NOTE: Triangle has no default constructor.", true);
-    }
-
-    // Test of overriden ctor
-    template<>
-    template<>
-    void object::test<2>()
-    {
-		geos::geom::Triangle abc(a, b, c);
-
-		ensure_equals( abc.p0, a );
-		ensure_equals( abc.p1, b );
-		ensure_equals( abc.p2, c );
-    }
-
-	// Test of copy ctor
-    template<>
-    template<>
-    void object::test<3>()
-    {
-		geos::geom::Triangle abc(a, b, c);
-		geos::geom::Triangle copy(abc);
-
-		ensure_equals( copy.p0, a );
-		ensure_equals( copy.p1, b );
-		ensure_equals( copy.p2, c );
-	}
-
-	// Test of assignment operator
-    template<>
-    template<>
-    void object::test<4>()
-    {
-		geos::geom::Triangle abc(a, b, c);
-		geos::geom::Triangle copy(d, e, f);
-
-		ensure_equals( abc.p0, a );
-		ensure_equals( abc.p1, b );
-		ensure_equals( abc.p2, c );
-		ensure_equals( copy.p0, d );
-		ensure_equals( copy.p1, e );
-		ensure_equals( copy.p2, f );
-
-		copy = abc;
-
-		ensure_equals( copy.p0, a );
-		ensure_equals( copy.p1, b );
-		ensure_equals( copy.p2, c );
-		ensure( copy.p0 != d );
-		ensure( copy.p1 != e );
-		ensure( copy.p2 != f );
-	}
-
-    // Test of inCenter()
-    template<>
-    template<>
-    void object::test<5>()
-    {
-		geos::geom::Coordinate center;
-		geos::geom::Triangle abc(a, b, c);
-
-		// Expected: ~4.2426406871192857
-		abc.inCentre(center);
-		// 1e-16 fails sometimes
-		ensure( std::fabs(center.x - 6.0) < 1e-15 );
-		ensure( center.y > 4.2 );
-		ensure( center.y < 4.3 );
-		ensure( 0 != std::isnan( center.z ) );
-    }
-    // Test circumcentre()
-        template<>
-	template<>
-	void object::test<6>()
-	{
-		using geos::geom::Triangle;
-		using geos::geom::Coordinate;
-
-		Coordinate x1(5,7);
-		Coordinate x2(6,6);
-		Coordinate x3(2,-2);
-
-		Coordinate y1(3,3);
-		Coordinate y2(9,10);
-		Coordinate y3(6,7);
-
-		Coordinate a1(5,10);
-		Coordinate a2(11,23);
-		Coordinate a3(22,19);
-
-		Triangle t1(x1,x2,x3);
-
-		Triangle t2(y1,y2,y3);
-
-		Triangle t3(a1,a2,a3);
-
-		// For t1:
-		Coordinate c1(0,0);
-		t1.circumcentre(c1);
-		ensure_equals(c1.x ,2 );
-		ensure_equals(c1.y ,3 );
-		ensure( 0 != std::isnan( c1.z ) );
-
-		//For t2:
-		Coordinate c2(0,0);
-		t2.circumcentre(c2);
-		ensure_equals(c2.x ,30.5 );
-		ensure_equals(c2.y ,- 14.5 );
-		ensure( 0 != std::isnan( c2.z ) );
-
-
-		//For t3:
-		Coordinate c3(0,0);
-		t3.circumcentre(c3);
-		ensure( std::fabs(c3.x - 13.0) < 1 );
-		ensure( c3.y > 13.7 );
-		ensure( c3.y < 13.8 );
-		ensure( 0 != std::isnan( c3.z ) );
-		// cout << "CicumCenter of triangle ABC:: " << c1.x << " " << c1.y << endl;
-
-		//  std::cout << "CicumCenter of triangle DEF:: " << c2.x << " " << c2.y << std::endl;
-	}
+    geos::geom::Triangle abc(a, b, c);
+    geos::geom::Triangle copy(d, e, f);
+
+    ensure_equals(abc.p0, a);
+    ensure_equals(abc.p1, b);
+    ensure_equals(abc.p2, c);
+    ensure_equals(copy.p0, d);
+    ensure_equals(copy.p1, e);
+    ensure_equals(copy.p2, f);
+
+    copy = abc;
+
+    ensure_equals(copy.p0, a);
+    ensure_equals(copy.p1, b);
+    ensure_equals(copy.p2, c);
+    ensure(copy.p0 != d);
+    ensure(copy.p1 != e);
+    ensure(copy.p2 != f);
+}
+
+// Test of inCenter()
+template<>
+template<>
+void object::test<5>
+()
+{
+    geos::geom::Coordinate center;
+    geos::geom::Triangle abc(a, b, c);
+
+    // Expected: ~4.2426406871192857
+    abc.inCentre(center);
+    // 1e-16 fails sometimes
+    ensure(std::fabs(center.x - 6.0) < 1e-15);
+    ensure(center.y > 4.2);
+    ensure(center.y < 4.3);
+    ensure(0 != std::isnan(center.z));
+}
+// Test circumcentre()
+template<>
+template<>
+void object::test<6>
+()
+{
+    using geos::geom::Triangle;
+    using geos::geom::Coordinate;
+
+    Coordinate x1(5, 7);
+    Coordinate x2(6, 6);
+    Coordinate x3(2, -2);
+
+    Coordinate y1(3, 3);
+    Coordinate y2(9, 10);
+    Coordinate y3(6, 7);
+
+    Coordinate a1(5, 10);
+    Coordinate a2(11, 23);
+    Coordinate a3(22, 19);
+
+    Triangle t1(x1, x2, x3);
+
+    Triangle t2(y1, y2, y3);
+
+    Triangle t3(a1, a2, a3);
+
+    // For t1:
+    Coordinate c1(0, 0);
+    t1.circumcentre(c1);
+    ensure_equals(c1.x, 2);
+    ensure_equals(c1.y, 3);
+    ensure(0 != std::isnan(c1.z));
+
+    //For t2:
+    Coordinate c2(0, 0);
+    t2.circumcentre(c2);
+    ensure_equals(c2.x, 30.5);
+    ensure_equals(c2.y, - 14.5);
+    ensure(0 != std::isnan(c2.z));
+
+
+    //For t3:
+    Coordinate c3(0, 0);
+    t3.circumcentre(c3);
+    ensure(std::fabs(c3.x - 13.0) < 1);
+    ensure(c3.y > 13.7);
+    ensure(c3.y < 13.8);
+    ensure(0 != std::isnan(c3.z));
+    // cout << "CicumCenter of triangle ABC:: " << c1.x << " " << c1.y << endl;
+
+    //  std::cout << "CicumCenter of triangle DEF:: " << c2.x << " " << c2.y << std::endl;
+}
 
 } // namespace tut
diff --git a/tests/unit/geom/prep/PreparedGeometry/touchesTest.cpp b/tests/unit/geom/prep/PreparedGeometry/touchesTest.cpp
index 97c2c3b..6d99264 100644
--- a/tests/unit/geom/prep/PreparedGeometry/touchesTest.cpp
+++ b/tests/unit/geom/prep/PreparedGeometry/touchesTest.cpp
@@ -21,8 +21,7 @@ namespace tut {
 // Test Group
 //
 
-struct test_preparedgeometrytouches_data
-{
+struct test_preparedgeometrytouches_data {
     typedef std::unique_ptr<geos::geom::prep::PreparedGeometry> PrepGeomAutoPtr;
     typedef geos::geom::GeometryFactory GeometryFactory;
 
@@ -62,14 +61,15 @@ group test_preparedgeometrytouches_data("geos::geom::prep::PreparedGeometry::tou
 // 1 - Point/Point do not touch
 template<>
 template<>
-void object::test<1>()
+void object::test<1>
+()
 {
     g1 = reader.read(
-        "POINT (0 0)"
-        );
+             "POINT (0 0)"
+         );
     g2 = reader.read(
-        "POINT (0 0)"
-        );
+             "POINT (0 0)"
+         );
     pg1 = prep::PreparedGeometryFactory::prepare(g1);
     pg2 = prep::PreparedGeometryFactory::prepare(g2);
 
@@ -80,14 +80,15 @@ void object::test<1>()
 // 2 - Line/Point do not touch if point is not on boundary
 template<>
 template<>
-void object::test<2>()
+void object::test<2>
+()
 {
     g1 = reader.read(
-        "LINESTRING(0 0, 1 1, 0 2)"
-        );
+             "LINESTRING(0 0, 1 1, 0 2)"
+         );
     g2 = reader.read(
-        "POINT (1 1)"
-        );
+             "POINT (1 1)"
+         );
     pg1 = prep::PreparedGeometryFactory::prepare(g1);
     pg2 = prep::PreparedGeometryFactory::prepare(g2);
 
@@ -98,14 +99,15 @@ void object::test<2>()
 // 3 - Line/Point touch
 template<>
 template<>
-void object::test<3>()
+void object::test<3>
+()
 {
     g1 = reader.read(
-        "LINESTRING(0 0, 1 1, 0 2)"
-        );
+             "LINESTRING(0 0, 1 1, 0 2)"
+         );
     g2 = reader.read(
-        "POINT (0 2)"
-        );
+             "POINT (0 2)"
+         );
     pg1 = prep::PreparedGeometryFactory::prepare(g1);
     pg2 = prep::PreparedGeometryFactory::prepare(g2);
 
@@ -116,14 +118,15 @@ void object::test<3>()
 // 4 - Line/Point touch (FP coordinates)
 template<>
 template<>
-void object::test<4>()
+void object::test<4>
+()
 {
     g1 = reader.read(
-        "LINESTRING (-612844.96290006 279079.117329031,-257704.820935236 574364.179187424)"
-        );
+             "LINESTRING (-612844.96290006 279079.117329031,-257704.820935236 574364.179187424)"
+         );
     g2 = reader.read(
-        "POINT (-257704.820935236 574364.179187424)"
-        );
+             "POINT (-257704.820935236 574364.179187424)"
+         );
     pg1 = prep::PreparedGeometryFactory::prepare(g1);
     pg2 = prep::PreparedGeometryFactory::prepare(g2);
 
diff --git a/tests/unit/geom/prep/PreparedGeometryFactoryTest.cpp b/tests/unit/geom/prep/PreparedGeometryFactoryTest.cpp
index 8338943..f6369fe 100644
--- a/tests/unit/geom/prep/PreparedGeometryFactoryTest.cpp
+++ b/tests/unit/geom/prep/PreparedGeometryFactoryTest.cpp
@@ -18,476 +18,499 @@
 
 using namespace geos::geom;
 
-namespace tut
-{
-    //
-    // Test Group
-    //
+namespace tut {
+//
+// Test Group
+//
 
-    // Common data used by tests
-    struct test_preparedgeometryfactory_data
-    {
-        typedef geos::geom::GeometryFactory GeometryFactory;
-        GeometryPtr g_;
-        PreparedGeometryPtr pg_;
-        geos::geom::PrecisionModel pm_;
-        geos::geom::GeometryFactory::Ptr factory_;
-        geos::io::WKTReader reader_;
-
-        test_preparedgeometryfactory_data()
-            : g_(nullptr), pg_(nullptr), pm_(1.0)
-            , factory_(GeometryFactory::create(&pm_))
-            , reader_(factory_.get())
-        {
-            assert(nullptr == g_);
-            assert(nullptr == pg_);
-        }
-
-        ~test_preparedgeometryfactory_data()
-        {
-            // FREE MEMORY per test case
-            prep::PreparedGeometryFactory::destroy(pg_);
-            factory_->destroyGeometry(g_);
-            pg_ = nullptr;
-            g_ = nullptr;
-        }
-
-    };
-
-    typedef test_group<test_preparedgeometryfactory_data> group;
-    typedef group::object object;
-
-    group test_preparedgeometryfactory_data("geos::geom::prep::PreparedGeometryFactory");
-
-    //
-    // Test Cases
-    //
-
-    // Test of default constructor
-    template<>
-    template<>
-    void object::test<1>()
+// Common data used by tests
+struct test_preparedgeometryfactory_data {
+    typedef geos::geom::GeometryFactory GeometryFactory;
+    GeometryPtr g_;
+    PreparedGeometryPtr pg_;
+    geos::geom::PrecisionModel pm_;
+    geos::geom::GeometryFactory::Ptr factory_;
+    geos::io::WKTReader reader_;
+
+    test_preparedgeometryfactory_data()
+        : g_(nullptr), pg_(nullptr), pm_(1.0)
+        , factory_(GeometryFactory::create(&pm_))
+        , reader_(factory_.get())
     {
-        prep::PreparedGeometryFactory pgf;
-        ::geos::ignore_unused_variable_warning(pgf);
+        assert(nullptr == g_);
+        assert(nullptr == pg_);
     }
 
-    // Test passing null-pointer to prepare static method
-    template<>
-    template<>
-    void object::test<2>()
+    ~test_preparedgeometryfactory_data()
     {
-        try
-        {
-            GeometryPtr nullgeom = nullptr; // intentionally nullptr
-
-            prep::PreparedGeometryFactory::prepare(nullgeom);
-
-            fail("IllegalArgumentException expected");
-        }
-        catch (geos::util::IllegalArgumentException const& e)
-        {
-            const char* msg = e.what(); // ok
-            ensure( msg != nullptr );
-        }
+        // FREE MEMORY per test case
+        prep::PreparedGeometryFactory::destroy(pg_);
+        factory_->destroyGeometry(g_);
+        pg_ = nullptr;
+        g_ = nullptr;
     }
 
-    // Test passing null-pointer to create method
-    template<>
-    template<>
-    void object::test<3>()
-    {
-        try
-        {
-            GeometryPtr nullgeom = nullptr; // intentionally nullptr
-
-            prep::PreparedGeometryFactory pgf;
-            pgf.create(nullgeom);
-
-            fail("IllegalArgumentException expected");
-        }
-        catch (geos::util::IllegalArgumentException const& e)
-        {
-            const char* msg = e.what(); // ok
-            ensure( msg != nullptr );
-        }
-    }
+};
 
-    // Test prepare empty GEOMETRY
-    template<>
-    template<>
-    void object::test<4>()
-    {
-        g_ = factory_->createEmptyGeometry();
-        ensure( nullptr != g_ );
+typedef test_group<test_preparedgeometryfactory_data> group;
+typedef group::object object;
+
+group test_preparedgeometryfactory_data("geos::geom::prep::PreparedGeometryFactory");
+
+//
+// Test Cases
+//
+
+// Test of default constructor
+template<>
+template<>
+void object::test<1>
+()
+{
+    prep::PreparedGeometryFactory pgf;
+    ::geos::ignore_unused_variable_warning(pgf);
+}
+
+// Test passing null-pointer to prepare static method
+template<>
+template<>
+void object::test<2>
+()
+{
+    try {
+        GeometryPtr nullgeom = nullptr; // intentionally nullptr
 
-        pg_ = prep::PreparedGeometryFactory::prepare(g_);
-        ensure( nullptr != pg_ );
+        prep::PreparedGeometryFactory::prepare(nullgeom);
 
-        ensure_equals_geometry( g_, pg_ );
+        fail("IllegalArgumentException expected");
+    }
+    catch(geos::util::IllegalArgumentException const& e) {
+        const char* msg = e.what(); // ok
+        ensure(msg != nullptr);
     }
+}
 
-    // Test create empty GEOMETRY
-    template<>
-    template<>
-    void object::test<5>()
-    {
-        g_ = factory_->createEmptyGeometry();
-        ensure( nullptr != g_ );
+// Test passing null-pointer to create method
+template<>
+template<>
+void object::test<3>
+()
+{
+    try {
+        GeometryPtr nullgeom = nullptr; // intentionally nullptr
 
         prep::PreparedGeometryFactory pgf;
-        pg_ = pgf.create(g_);
-        ensure( nullptr != pg_ );
+        pgf.create(nullgeom);
 
-        ensure_equals_geometry( g_, pg_ );
+        fail("IllegalArgumentException expected");
     }
+    catch(geos::util::IllegalArgumentException const& e) {
+        const char* msg = e.what(); // ok
+        ensure(msg != nullptr);
+    }
+}
 
-    // Test prepare empty POINT
-    template<>
-    template<>
-    void object::test<6>()
-    {
-        g_ = factory_->createPoint();
-        ensure( nullptr != g_ );
+// Test prepare empty GEOMETRY
+template<>
+template<>
+void object::test<4>
+()
+{
+    g_ = factory_->createEmptyGeometry();
+    ensure(nullptr != g_);
 
-        pg_ = prep::PreparedGeometryFactory::prepare(g_);
-        ensure( nullptr != pg_ );
+    pg_ = prep::PreparedGeometryFactory::prepare(g_);
+    ensure(nullptr != pg_);
 
-        ensure_equals_geometry( g_, pg_ );
-    }
+    ensure_equals_geometry(g_, pg_);
+}
 
-    // Test create empty POINT
-    template<>
-    template<>
-    void object::test<7>()
-    {
-        g_ = factory_->createPoint();
-        ensure( nullptr != g_ );
+// Test create empty GEOMETRY
+template<>
+template<>
+void object::test<5>
+()
+{
+    g_ = factory_->createEmptyGeometry();
+    ensure(nullptr != g_);
 
-        prep::PreparedGeometryFactory pgf;
-        pg_ = pgf.create(g_);
-        ensure( nullptr != pg_ );
+    prep::PreparedGeometryFactory pgf;
+    pg_ = pgf.create(g_);
+    ensure(nullptr != pg_);
 
-        ensure_equals_geometry( g_, pg_ );
-    }
+    ensure_equals_geometry(g_, pg_);
+}
 
-    // Test prepare empty LINESTRING
-    template<>
-    template<>
-    void object::test<8>()
-    {
-        g_ = factory_->createLineString();
-        ensure( nullptr != g_ );
+// Test prepare empty POINT
+template<>
+template<>
+void object::test<6>
+()
+{
+    g_ = factory_->createPoint();
+    ensure(nullptr != g_);
 
-        pg_ = prep::PreparedGeometryFactory::prepare(g_);
-        ensure( nullptr != pg_ );
+    pg_ = prep::PreparedGeometryFactory::prepare(g_);
+    ensure(nullptr != pg_);
 
-        ensure_equals_geometry( g_, pg_ );
-    }
+    ensure_equals_geometry(g_, pg_);
+}
 
-    // Test create empty LINESTRING
-    template<>
-    template<>
-    void object::test<9>()
-    {
-        g_ = factory_->createLineString();
-        ensure( nullptr != g_ );
+// Test create empty POINT
+template<>
+template<>
+void object::test<7>
+()
+{
+    g_ = factory_->createPoint();
+    ensure(nullptr != g_);
 
-        prep::PreparedGeometryFactory pgf;
-        pg_ = pgf.create(g_);
+    prep::PreparedGeometryFactory pgf;
+    pg_ = pgf.create(g_);
+    ensure(nullptr != pg_);
 
-        ensure_equals_geometry( g_, pg_ );
-    }
+    ensure_equals_geometry(g_, pg_);
+}
 
-    // Test prepare empty POLYGON
-    template<>
-    template<>
-    void object::test<10>()
-    {
-        g_ = factory_->createPolygon();
-        ensure( nullptr != g_ );
+// Test prepare empty LINESTRING
+template<>
+template<>
+void object::test<8>
+()
+{
+    g_ = factory_->createLineString();
+    ensure(nullptr != g_);
 
-        pg_ = prep::PreparedGeometryFactory::prepare(g_);
-        ensure( nullptr != pg_ );
+    pg_ = prep::PreparedGeometryFactory::prepare(g_);
+    ensure(nullptr != pg_);
 
-        ensure_equals_geometry( g_, pg_ );
-    }
+    ensure_equals_geometry(g_, pg_);
+}
 
-    // Test create empty POLYGON
-    template<>
-    template<>
-    void object::test<11>()
-    {
-        g_ = factory_->createPolygon();
-        ensure( nullptr != g_ );
+// Test create empty LINESTRING
+template<>
+template<>
+void object::test<9>
+()
+{
+    g_ = factory_->createLineString();
+    ensure(nullptr != g_);
 
-        prep::PreparedGeometryFactory pgf;
-        pg_ = pgf.create(g_);
-        ensure( nullptr != pg_ );
+    prep::PreparedGeometryFactory pgf;
+    pg_ = pgf.create(g_);
 
-        ensure_equals_geometry( g_, pg_ );
-    }
+    ensure_equals_geometry(g_, pg_);
+}
 
-    // Test prepare empty MULTIPOINT
-    template<>
-    template<>
-    void object::test<12>()
-    {
-        g_ = factory_->createMultiPoint();
-        ensure( nullptr != g_ );
+// Test prepare empty POLYGON
+template<>
+template<>
+void object::test<10>
+()
+{
+    g_ = factory_->createPolygon();
+    ensure(nullptr != g_);
 
-        pg_ = prep::PreparedGeometryFactory::prepare(g_);
-        ensure( nullptr != pg_ );
+    pg_ = prep::PreparedGeometryFactory::prepare(g_);
+    ensure(nullptr != pg_);
 
-        ensure_equals_geometry( g_, pg_ );
-    }
+    ensure_equals_geometry(g_, pg_);
+}
 
-    // Test create empty MULTIPOINT
-    template<>
-    template<>
-    void object::test<13>()
-    {
-        g_ = factory_->createMultiPoint();
-        ensure( nullptr != g_ );
+// Test create empty POLYGON
+template<>
+template<>
+void object::test<11>
+()
+{
+    g_ = factory_->createPolygon();
+    ensure(nullptr != g_);
 
-        prep::PreparedGeometryFactory pgf;
-        pg_ = pgf.create(g_);
-        ensure( nullptr != pg_ );
+    prep::PreparedGeometryFactory pgf;
+    pg_ = pgf.create(g_);
+    ensure(nullptr != pg_);
 
-        ensure_equals_geometry( g_, pg_ );
-    }
+    ensure_equals_geometry(g_, pg_);
+}
 
-    // Test prepare empty MULTILINESTRING
-    template<>
-    template<>
-    void object::test<14>()
-    {
-        g_ = factory_->createMultiLineString();
-        ensure( nullptr != g_ );
+// Test prepare empty MULTIPOINT
+template<>
+template<>
+void object::test<12>
+()
+{
+    g_ = factory_->createMultiPoint();
+    ensure(nullptr != g_);
 
-        pg_ = prep::PreparedGeometryFactory::prepare(g_);
-        ensure( nullptr != pg_ );
+    pg_ = prep::PreparedGeometryFactory::prepare(g_);
+    ensure(nullptr != pg_);
 
-        ensure_equals_geometry( g_, pg_ );
-    }
+    ensure_equals_geometry(g_, pg_);
+}
 
-    // Test create empty MULTILINESTRING
-    template<>
-    template<>
-    void object::test<15>()
-    {
-        g_ = factory_->createMultiLineString();
-        ensure( nullptr != g_ );
+// Test create empty MULTIPOINT
+template<>
+template<>
+void object::test<13>
+()
+{
+    g_ = factory_->createMultiPoint();
+    ensure(nullptr != g_);
 
-        prep::PreparedGeometryFactory pgf;
-        pg_ = pgf.create(g_);
-        ensure( nullptr != pg_ );
+    prep::PreparedGeometryFactory pgf;
+    pg_ = pgf.create(g_);
+    ensure(nullptr != pg_);
 
-        ensure_equals_geometry( g_, pg_ );
-    }
+    ensure_equals_geometry(g_, pg_);
+}
 
-    // Test prepare empty MULTIPOLYGON
-    template<>
-    template<>
-    void object::test<16>()
-    {
-        g_ = factory_->createMultiPolygon();
-        ensure( nullptr != g_ );
+// Test prepare empty MULTILINESTRING
+template<>
+template<>
+void object::test<14>
+()
+{
+    g_ = factory_->createMultiLineString();
+    ensure(nullptr != g_);
 
-        pg_ = prep::PreparedGeometryFactory::prepare(g_);
-        ensure( nullptr != pg_ );
+    pg_ = prep::PreparedGeometryFactory::prepare(g_);
+    ensure(nullptr != pg_);
 
-        ensure_equals_geometry( g_, pg_ );
-    }
+    ensure_equals_geometry(g_, pg_);
+}
 
-    // Test create empty MULTIPOLYGON
-    template<>
-    template<>
-    void object::test<17>()
-    {
-        g_ = factory_->createMultiPolygon();
-        ensure( nullptr != g_ );
+// Test create empty MULTILINESTRING
+template<>
+template<>
+void object::test<15>
+()
+{
+    g_ = factory_->createMultiLineString();
+    ensure(nullptr != g_);
 
-        prep::PreparedGeometryFactory pgf;
-        pg_ = pgf.create(g_);
-        ensure( nullptr != pg_ );
+    prep::PreparedGeometryFactory pgf;
+    pg_ = pgf.create(g_);
+    ensure(nullptr != pg_);
 
-        ensure_equals_geometry( g_, pg_ );
-    }
+    ensure_equals_geometry(g_, pg_);
+}
 
-    // Test prepare non-empty POINT
-    template<>
-    template<>
-    void object::test<18>()
-    {
-        g_ = reader_.read("POINT(1.234 5.678)");
-        ensure( nullptr != g_ );
+// Test prepare empty MULTIPOLYGON
+template<>
+template<>
+void object::test<16>
+()
+{
+    g_ = factory_->createMultiPolygon();
+    ensure(nullptr != g_);
 
-        pg_ = prep::PreparedGeometryFactory::prepare(g_);
-        ensure( nullptr != pg_ );
+    pg_ = prep::PreparedGeometryFactory::prepare(g_);
+    ensure(nullptr != pg_);
 
-        ensure_equals_geometry( g_, pg_ );
-    }
+    ensure_equals_geometry(g_, pg_);
+}
 
-    // Test create non-empty POINT
-    template<>
-    template<>
-    void object::test<19>()
-    {
-        g_ = reader_.read("POINT(1.234 5.678)");
-        ensure( nullptr != g_ );
+// Test create empty MULTIPOLYGON
+template<>
+template<>
+void object::test<17>
+()
+{
+    g_ = factory_->createMultiPolygon();
+    ensure(nullptr != g_);
 
-        prep::PreparedGeometryFactory pgf;
-        pg_ = pgf.create(g_);
-        ensure( nullptr != pg_ );
+    prep::PreparedGeometryFactory pgf;
+    pg_ = pgf.create(g_);
+    ensure(nullptr != pg_);
 
-        ensure_equals_geometry( g_, pg_ );
-    }
+    ensure_equals_geometry(g_, pg_);
+}
 
-    // Test prepare non-empty LINESTRING
-    template<>
-    template<>
-    void object::test<20>()
-    {
-		g_ = reader_.read("LINESTRING (0 0, 5 5, 10 5, 10 10)");
-        ensure( nullptr != g_ );
+// Test prepare non-empty POINT
+template<>
+template<>
+void object::test<18>
+()
+{
+    g_ = reader_.read("POINT(1.234 5.678)");
+    ensure(nullptr != g_);
 
-        pg_ = prep::PreparedGeometryFactory::prepare(g_);
-        ensure( nullptr != pg_ );
+    pg_ = prep::PreparedGeometryFactory::prepare(g_);
+    ensure(nullptr != pg_);
 
-        ensure_equals_geometry( g_, pg_ );
-    }
+    ensure_equals_geometry(g_, pg_);
+}
 
-    // Test create non-empty LINESTRING
-    template<>
-    template<>
-    void object::test<21>()
-    {
-		g_ = reader_.read("LINESTRING (0 0, 5 5, 10 5, 10 10)");
-        ensure( nullptr != g_ );
+// Test create non-empty POINT
+template<>
+template<>
+void object::test<19>
+()
+{
+    g_ = reader_.read("POINT(1.234 5.678)");
+    ensure(nullptr != g_);
 
-        prep::PreparedGeometryFactory pgf;
-        pg_ = pgf.create(g_);
-        ensure( nullptr != pg_ );
+    prep::PreparedGeometryFactory pgf;
+    pg_ = pgf.create(g_);
+    ensure(nullptr != pg_);
 
-        ensure_equals_geometry( g_, pg_ );
-    }
+    ensure_equals_geometry(g_, pg_);
+}
 
-    // Test prepare non-empty LINESTRING
-    template<>
-    template<>
-    void object::test<22>()
-    {
-        g_ = reader_.read("POLYGON((0 10, 5 5, 10 5, 15 10, 10 15, 5 15, 0 10))");
-        ensure( nullptr != g_ );
+// Test prepare non-empty LINESTRING
+template<>
+template<>
+void object::test<20>
+()
+{
+    g_ = reader_.read("LINESTRING (0 0, 5 5, 10 5, 10 10)");
+    ensure(nullptr != g_);
 
-        pg_ = prep::PreparedGeometryFactory::prepare(g_);
-        ensure( nullptr != pg_ );
+    pg_ = prep::PreparedGeometryFactory::prepare(g_);
+    ensure(nullptr != pg_);
 
-        ensure_equals_geometry( g_, pg_ );
-    }
+    ensure_equals_geometry(g_, pg_);
+}
 
-    // Test create non-empty LINESTRING
-    template<>
-    template<>
-    void object::test<23>()
-    {
-        g_ = reader_.read("POLYGON((0 10, 5 5, 10 5, 15 10, 10 15, 5 15, 0 10))");
-        ensure( nullptr != g_ );
+// Test create non-empty LINESTRING
+template<>
+template<>
+void object::test<21>
+()
+{
+    g_ = reader_.read("LINESTRING (0 0, 5 5, 10 5, 10 10)");
+    ensure(nullptr != g_);
 
-        prep::PreparedGeometryFactory pgf;
-        pg_ = pgf.create(g_);
-        ensure( nullptr != pg_ );
+    prep::PreparedGeometryFactory pgf;
+    pg_ = pgf.create(g_);
+    ensure(nullptr != pg_);
 
-        ensure_equals_geometry( g_, pg_ );
-    }
+    ensure_equals_geometry(g_, pg_);
+}
 
-    // Test prepare non-empty MULTIPOINT
-    template<>
-    template<>
-    void object::test<24>()
-    {
-        g_ = reader_.read("MULTIPOINT(0 0, 5 5, 10 10, 15 15, 20 20)");
-        ensure( nullptr != g_ );
+// Test prepare non-empty LINESTRING
+template<>
+template<>
+void object::test<22>
+()
+{
+    g_ = reader_.read("POLYGON((0 10, 5 5, 10 5, 15 10, 10 15, 5 15, 0 10))");
+    ensure(nullptr != g_);
 
-        pg_ = prep::PreparedGeometryFactory::prepare(g_);
-        ensure( nullptr != pg_ );
+    pg_ = prep::PreparedGeometryFactory::prepare(g_);
+    ensure(nullptr != pg_);
 
-        ensure_equals_geometry( g_, pg_ );
-    }
+    ensure_equals_geometry(g_, pg_);
+}
 
-    // Test create non-empty MULTIPOINT
-    template<>
-    template<>
-    void object::test<25>()
-    {
-        g_ = reader_.read("MULTIPOINT(0 0, 5 5, 10 10, 15 15, 20 20)");
-        ensure( nullptr != g_ );
+// Test create non-empty LINESTRING
+template<>
+template<>
+void object::test<23>
+()
+{
+    g_ = reader_.read("POLYGON((0 10, 5 5, 10 5, 15 10, 10 15, 5 15, 0 10))");
+    ensure(nullptr != g_);
 
-        prep::PreparedGeometryFactory pgf;
-        pg_ = pgf.create(g_);
-        ensure( nullptr != pg_ );
+    prep::PreparedGeometryFactory pgf;
+    pg_ = pgf.create(g_);
+    ensure(nullptr != pg_);
 
-        ensure_equals_geometry( g_, pg_ );
-    }
+    ensure_equals_geometry(g_, pg_);
+}
 
-    // Test prepare non-empty MULTILINESTRING
-    template<>
-    template<>
-    void object::test<26>()
-    {
-		g_ = reader_.read("MULTILINESTRING ((20 120, 120 20), (20 20, 120 120))");
-        ensure( nullptr != g_ );
+// Test prepare non-empty MULTIPOINT
+template<>
+template<>
+void object::test<24>
+()
+{
+    g_ = reader_.read("MULTIPOINT(0 0, 5 5, 10 10, 15 15, 20 20)");
+    ensure(nullptr != g_);
 
-        pg_ = prep::PreparedGeometryFactory::prepare(g_);
-        ensure( nullptr != pg_ );
+    pg_ = prep::PreparedGeometryFactory::prepare(g_);
+    ensure(nullptr != pg_);
 
-        ensure_equals_geometry( g_, pg_ );
-    }
+    ensure_equals_geometry(g_, pg_);
+}
 
-    // Test create non-empty MULTILINESTRING
-    template<>
-    template<>
-    void object::test<27>()
-    {
-		g_ = reader_.read("MULTILINESTRING ((20 120, 120 20), (20 20, 120 120))");
-        ensure( nullptr != g_ );
+// Test create non-empty MULTIPOINT
+template<>
+template<>
+void object::test<25>
+()
+{
+    g_ = reader_.read("MULTIPOINT(0 0, 5 5, 10 10, 15 15, 20 20)");
+    ensure(nullptr != g_);
 
-        prep::PreparedGeometryFactory pgf;
-        pg_ = pgf.create(g_);
-        ensure( nullptr != pg_ );
+    prep::PreparedGeometryFactory pgf;
+    pg_ = pgf.create(g_);
+    ensure(nullptr != pg_);
 
-        ensure_equals_geometry( g_, pg_ );
-    }
+    ensure_equals_geometry(g_, pg_);
+}
 
-    // Test prepare non-empty POLYGON
-    template<>
-    template<>
-    void object::test<28>()
-    {
-        g_ = reader_.read("MULTIPOLYGON(((0 0, 10 0, 10 10, 0 10, 0 0),(2 2, 2 6, 6 4, 2 2)),((60 60, 60 50, 70 40, 60 60)))");
-        ensure( nullptr != g_ );
+// Test prepare non-empty MULTILINESTRING
+template<>
+template<>
+void object::test<26>
+()
+{
+    g_ = reader_.read("MULTILINESTRING ((20 120, 120 20), (20 20, 120 120))");
+    ensure(nullptr != g_);
 
-        pg_ = prep::PreparedGeometryFactory::prepare(g_);
-        ensure( nullptr != pg_ );
+    pg_ = prep::PreparedGeometryFactory::prepare(g_);
+    ensure(nullptr != pg_);
 
-        ensure_equals_geometry( g_, pg_ );
-    }
+    ensure_equals_geometry(g_, pg_);
+}
 
-    // Test create non-empty POLYGON
-    template<>
-    template<>
-    void object::test<29>()
-    {
-        g_ = reader_.read("MULTIPOLYGON(((0 0, 10 0, 10 10, 0 10, 0 0),(2 2, 2 6, 6 4, 2 2)),((60 60, 60 50, 70 40, 60 60)))");
-        ensure( nullptr != g_ );
+// Test create non-empty MULTILINESTRING
+template<>
+template<>
+void object::test<27>
+()
+{
+    g_ = reader_.read("MULTILINESTRING ((20 120, 120 20), (20 20, 120 120))");
+    ensure(nullptr != g_);
 
-        prep::PreparedGeometryFactory pgf;
-        pg_ = pgf.create(g_);
-        ensure( nullptr != pg_ );
+    prep::PreparedGeometryFactory pgf;
+    pg_ = pgf.create(g_);
+    ensure(nullptr != pg_);
 
-        ensure_equals_geometry( g_, pg_ );
-    }
+    ensure_equals_geometry(g_, pg_);
+}
+
+// Test prepare non-empty POLYGON
+template<>
+template<>
+void object::test<28>
+()
+{
+    g_ = reader_.read("MULTIPOLYGON(((0 0, 10 0, 10 10, 0 10, 0 0),(2 2, 2 6, 6 4, 2 2)),((60 60, 60 50, 70 40, 60 60)))");
+    ensure(nullptr != g_);
+
+    pg_ = prep::PreparedGeometryFactory::prepare(g_);
+    ensure(nullptr != pg_);
+
+    ensure_equals_geometry(g_, pg_);
+}
+
+// Test create non-empty POLYGON
+template<>
+template<>
+void object::test<29>
+()
+{
+    g_ = reader_.read("MULTIPOLYGON(((0 0, 10 0, 10 10, 0 10, 0 0),(2 2, 2 6, 6 4, 2 2)),((60 60, 60 50, 70 40, 60 60)))");
+    ensure(nullptr != g_);
+
+    prep::PreparedGeometryFactory pgf;
+    pg_ = pgf.create(g_);
+    ensure(nullptr != pg_);
+
+    ensure_equals_geometry(g_, pg_);
+}
 
 } // namespace tut
 
diff --git a/tests/unit/geom/util/GeometryExtracterTest.cpp b/tests/unit/geom/util/GeometryExtracterTest.cpp
index 6c0cbdd..6543565 100644
--- a/tests/unit/geom/util/GeometryExtracterTest.cpp
+++ b/tests/unit/geom/util/GeometryExtracterTest.cpp
@@ -16,83 +16,84 @@
 // std
 #include <vector>
 
-namespace tut
-{
-    //
-    // Test Group
-    //
+namespace tut {
+//
+// Test Group
+//
 
-    // Common data used by tests
-    struct test_geometryextracter_data
-    {
-      geos::geom::PrecisionModel pm;
-      geos::geom::GeometryFactory::Ptr gf;
-      geos::io::WKTReader wktreader;
-      geos::io::WKTWriter wktwriter;
+// Common data used by tests
+struct test_geometryextracter_data {
+    geos::geom::PrecisionModel pm;
+    geos::geom::GeometryFactory::Ptr gf;
+    geos::io::WKTReader wktreader;
+    geos::io::WKTWriter wktwriter;
 
-		  typedef std::unique_ptr<geos::geom::Geometry> GeomPtr;
+    typedef std::unique_ptr<geos::geom::Geometry> GeomPtr;
 
-      typedef geos::io::WKTReader WKTReader;
-      typedef geos::io::WKTWriter WKTWriter;
+    typedef geos::io::WKTReader WKTReader;
+    typedef geos::io::WKTWriter WKTWriter;
 
-      test_geometryextracter_data()
+    test_geometryextracter_data()
         :
         pm(1.0),
         gf(geos::geom::GeometryFactory::create(&pm)),
         wktreader(gf.get())
-      {
-      }
-    };
+    {
+    }
+};
 
-    typedef test_group<test_geometryextracter_data> group;
-    typedef group::object object;
+typedef test_group<test_geometryextracter_data> group;
+typedef group::object object;
 
-    group test_geometryextracter_group("geos::geom::util::GeometryExtracter");
+group test_geometryextracter_group("geos::geom::util::GeometryExtracter");
 
-    //
-    // Test Cases
-    //
+//
+// Test Cases
+//
 
-    // Test extraction of single point
-    template<>
-    template<>
-    void object::test<1>()
-    {
-      using namespace geos::geom::util;
-      using namespace geos::geom;
+// Test extraction of single point
+template<>
+template<>
+void object::test<1>
+()
+{
+    using namespace geos::geom::util;
+    using namespace geos::geom;
 
-      GeomPtr geom(wktreader.read("POINT(-117 33)"));
-      std::vector<const Point*> lst_points;
-      std::vector<const LineString*> lst_lines;
+    GeomPtr geom(wktreader.read("POINT(-117 33)"));
+    std::vector<const Point*> lst_points;
+    std::vector<const LineString*> lst_lines;
 
-      GeometryExtracter::extract<Point>(*geom, lst_points);
-      GeometryExtracter::extract<LineString>(*geom, lst_lines);
+    GeometryExtracter::extract<Point>(*geom, lst_points);
+    GeometryExtracter::extract<LineString>(*geom, lst_lines);
 
-      ensure_equals( lst_points.size(), 1u );
-      ensure_equals( lst_lines.size(), 0u );
-    }
+    ensure_equals(lst_points.size(), 1u);
+    ensure_equals(lst_lines.size(), 0u);
+}
 
-    // Test extraction of multiple types
-    template<>
-    template<>
-    void object::test<2>()
-    {
-      using namespace geos::geom::util;
-      using namespace geos::geom;
+// Test extraction of multiple types
+template<>
+template<>
+void object::test<2>
+()
+{
+    using namespace geos::geom::util;
+    using namespace geos::geom;
 
-      GeomPtr geom(wktreader.read("GEOMETRYCOLLECTION(POINT(-117 33),LINESTRING(0 0, 10 0),POINT(0 0),POLYGON((0 0, 10 0, 10 10, 0 10, 0 0)),LINESTRING(10 0, 23 30),POINT(20 20))"));
+    GeomPtr geom(
+        wktreader.read("GEOMETRYCOLLECTION(POINT(-117 33),LINESTRING(0 0, 10 0),POINT(0 0),POLYGON((0 0, 10 0, 10 10, 0 10, 0 0)),LINESTRING(10 0, 23 30),POINT(20 20))"));
 
-      std::vector<const Point*> lst_points;
-      std::vector<const LineString*> lst_lines;
-      std::vector<const Polygon*> lst_polys;
+    std::vector<const Point*> lst_points;
+    std::vector<const LineString*> lst_lines;
+    std::vector<const Polygon*> lst_polys;
 
-      GeometryExtracter::extract<Point>(*geom, lst_points);
-      GeometryExtracter::extract<LineString>(*geom, lst_lines);
-      GeometryExtracter::extract<Polygon>(*geom, lst_polys);
+    GeometryExtracter::extract<Point>(*geom, lst_points);
+    GeometryExtracter::extract<LineString>(*geom, lst_lines);
+    GeometryExtracter::extract<Polygon>(*geom, lst_polys);
 
-      ensure_equals( lst_points.size(), 3u );
-      ensure_equals( lst_lines.size(), 2u );
-      ensure_equals( lst_polys.size(), 1u );
-    }
+    ensure_equals(lst_points.size(), 3u);
+    ensure_equals(lst_lines.size(), 2u);
+    ensure_equals(lst_polys.size(), 1u);
+}
 
 } // namespace tut
diff --git a/tests/unit/geos_unit.cpp b/tests/unit/geos_unit.cpp
index 192521a..e4cf7c5 100644
--- a/tests/unit/geos_unit.cpp
+++ b/tests/unit/geos_unit.cpp
@@ -17,12 +17,12 @@
 #include <iomanip>
 #include <iostream>
 
-namespace tut
-{
-    test_runner_singleton runner;
+namespace tut {
+test_runner_singleton runner;
 }
 
-void usage()
+void
+usage()
 {
     using std::cout;
     using std::endl;
@@ -31,33 +31,33 @@ void usage()
 
     //[list] | [ group] [test]
     cout << "Usage: " << module << " [OPTION] [TARGET]\n"
-        << endl
-        << "Targets:\n"
-        << "  <none>                          run all tests in all groups\n"
-        << "  <group name>                    run all tests from given group\n"
-        << "  <group name> <test nr>          run single test with given number from given group\n"
-        << endl
-        << "Options:\n"
-        << "  --list                          list all registered test groups\n"
-        << "  --verbose                       run unit tests verbosely; displays non-error information\n"
-        << "  --version                       print version information and exit\n"
-        << "  --help                          print this message and exit\n"
-        << endl
-        << "Examples:\n"
-        << "  " << module << " -v\n"
-        << "  " << module << " list\n"
-        << "  " << module << " geos::geom::Envelope\n"
-        << "  " << module << " geos::geom::Envelope 2\n"
-        << endl
-        << "GEOS homepage: http://geos.osgeo.org" << endl;
+         << endl
+         << "Targets:\n"
+         << "  <none>                          run all tests in all groups\n"
+         << "  <group name>                    run all tests from given group\n"
+         << "  <group name> <test nr>          run single test with given number from given group\n"
+         << endl
+         << "Options:\n"
+         << "  --list                          list all registered test groups\n"
+         << "  --verbose                       run unit tests verbosely; displays non-error information\n"
+         << "  --version                       print version information and exit\n"
+         << "  --help                          print this message and exit\n"
+         << endl
+         << "Examples:\n"
+         << "  " << module << " -v\n"
+         << "  " << module << " list\n"
+         << "  " << module << " geos::geom::Envelope\n"
+         << "  " << module << " geos::geom::Envelope 2\n"
+         << endl
+         << "GEOS homepage: http://geos.osgeo.org" << endl;
 }
 
-int main(int argc, const char* argv[])
+int
+main(int argc, const char* argv[])
 {
     tut::reporter visi;
 
-    if ( (argc == 2 && std::string(argv[1]) == "--help") || argc > 3 )
-    {
+    if((argc == 2 && std::string(argv[1]) == "--help") || argc > 3) {
         usage();
         return 0;
     }
@@ -68,14 +68,11 @@ int main(int argc, const char* argv[])
 
     tut::runner.get().set_callback(&visi);
 
-    try
-    {
-        if ( argc == 1 )
-        {
+    try {
+        if(argc == 1) {
             tut::runner.get().run_tests();
         }
-        else if ( argc == 2 && std::string(argv[1]) == "--list" )
-        {
+        else if(argc == 2 && std::string(argv[1]) == "--list") {
             tut::groupnames gl = tut::runner.get().list_groups();
             tut::groupnames::const_iterator b = gl.begin();
             tut::groupnames::const_iterator e = gl.end();
@@ -84,30 +81,27 @@ int main(int argc, const char* argv[])
 
             std::cout << "Registered " << d << " test groups:\n" << std::endl;
 
-            while ( b != e )
-            {
+            while(b != e) {
                 std::cout << "  " << *b << std::endl;
                 ++b;
             }
         }
-        else if ( argc == 2 && std::string(argv[1]) != "--list" )
-        {
+        else if(argc == 2 && std::string(argv[1]) != "--list") {
             tut::runner.get().run_tests(argv[1]);
         }
-        else if( argc == 3 )
-        {
+        else if(argc == 3) {
             // TODO - mloskot - check if test group with given name exists
             // TODO - mloskot - check if test case with given number exists
             std::string grpname(argv[1]);
-            if (grpname.empty())
+            if(grpname.empty()) {
                 throw std::runtime_error("missing test group name");
+            }
 
             tut::test_result result;
             tut::runner.get().run_test(grpname, std::atoi(argv[2]), result);
         }
     }
-    catch( const std::exception& ex )
-    {
+    catch(const std::exception& ex) {
         std::cerr << "!!! GEOS Test Suite raised exception: " << ex.what() << std::endl;
     }
 
diff --git a/tests/unit/index/quadtree/DoubleBitsTest.cpp b/tests/unit/index/quadtree/DoubleBitsTest.cpp
index 560e08a..338c69e 100644
--- a/tests/unit/index/quadtree/DoubleBitsTest.cpp
+++ b/tests/unit/index/quadtree/DoubleBitsTest.cpp
@@ -7,29 +7,29 @@
 
 using namespace geos::index::quadtree;
 
-namespace tut
+namespace tut {
+// dummy data, not used
+struct test_doublebits_data {};
+
+typedef test_group<test_doublebits_data> group;
+typedef group::object object;
+
+group test_doublebits_group("geos::index::quadtree::DoubleBits");
+
+//
+// Test Cases
+//
+
+// 1 - Test exponent()
+template<>
+template<>
+void object::test<1>
+()
 {
-	// dummy data, not used
-	struct test_doublebits_data {};
-
-	typedef test_group<test_doublebits_data> group;
-	typedef group::object object;
-
-	group test_doublebits_group("geos::index::quadtree::DoubleBits");
-
-	//
-	// Test Cases
-	//
-
-	// 1 - Test exponent()
-	template<>
-	template<>
-	void object::test<1>()
-	{
-		ensure_equals(DoubleBits::exponent(-1), 0);
-		ensure_equals(DoubleBits::exponent(8.0), 3);
-		ensure_equals(DoubleBits::exponent(128.0), 7);
-	}
+    ensure_equals(DoubleBits::exponent(-1), 0);
+    ensure_equals(DoubleBits::exponent(8.0), 3);
+    ensure_equals(DoubleBits::exponent(128.0), 7);
+}
 
 
 } // namespace tut
diff --git a/tests/unit/index/strtree/SIRtreeTest.cpp b/tests/unit/index/strtree/SIRtreeTest.cpp
index 0ae842e..55dc1d4 100644
--- a/tests/unit/index/strtree/SIRtreeTest.cpp
+++ b/tests/unit/index/strtree/SIRtreeTest.cpp
@@ -4,30 +4,30 @@
 
 using namespace geos::index::strtree;
 
-namespace tut
+namespace tut {
+// dummy data, not used
+struct test_sirtree_data {};
+
+using group = test_group<test_sirtree_data>;
+using object = group::object;
+
+group test_sirtree_group("geos::index::strtree::SIRtree");
+
+//
+// Test Cases
+//
+
+// Make sure no memory is leaked.
+// See https://trac.osgeo.org/geos/ticket/919
+template<>
+template<>
+void object::test<1>
+()
 {
-    // dummy data, not used
-    struct test_sirtree_data {};
-
-    using group = test_group<test_sirtree_data>;
-    using object = group::object;
-
-    group test_sirtree_group("geos::index::strtree::SIRtree");
-
-    //
-    // Test Cases
-    //
-
-    // Make sure no memory is leaked.
-    // See https://trac.osgeo.org/geos/ticket/919
-    template<>
-    template<>
-    void object::test<1>()
-    {
-        SIRtree t;
-        double value = 3;
-        t.insert(1, 5, &value);
-    }
+    SIRtree t;
+    double value = 3;
+    t.insert(1, 5, &value);
+}
 
 
 } // namespace tut
diff --git a/tests/unit/io/ByteOrderValuesTest.cpp b/tests/unit/io/ByteOrderValuesTest.cpp
index 3ef25df..b867550 100644
--- a/tests/unit/io/ByteOrderValuesTest.cpp
+++ b/tests/unit/io/ByteOrderValuesTest.cpp
@@ -10,140 +10,141 @@
 #include <sstream>
 #include <memory>
 
-namespace tut
+namespace tut {
+//
+// Test Group
+//
+
+// dummy data, not used
+struct test_byteordervalues_data {
+};
+
+typedef test_group<test_byteordervalues_data> group;
+typedef group::object object;
+
+group test_byteordervalues_group("geos::io::ByteOrderValues");
+
+
+//
+// Test Cases
+//
+
+// 1 - Read/write an int
+template<>
+template<>
+void object::test<1>
+()
+{
+    using geos::io::ByteOrderValues;
+
+    unsigned char buf[4];
+    int in = 1;
+    int out;
+
+    ByteOrderValues::putInt(in, buf, ByteOrderValues::ENDIAN_BIG);
+    ensure("putInt big endian[0]", buf[0] == 0);
+    ensure("putInt big endian[1]", buf[1] == 0);
+    ensure("putInt big endian[2]", buf[2] == 0);
+    ensure("putInt big endian[3]", buf[3] == 1);
+
+    out = ByteOrderValues::getInt(buf,
+                                  geos::io::ByteOrderValues::ENDIAN_BIG);
+    ensure_equals("getInt big endian", out, in);
+
+    ByteOrderValues::putInt(1, buf, geos::io::ByteOrderValues::ENDIAN_LITTLE);
+    ensure("putInt little endian[0]", buf[0] == 1);
+    ensure("putInt little endian[1]", buf[1] == 0);
+    ensure("putInt little endian[2]", buf[2] == 0);
+    ensure("putInt little endian[3]", buf[3] == 0);
+
+    out = ByteOrderValues::getInt(buf,
+                                  ByteOrderValues::ENDIAN_LITTLE);
+    ensure_equals("getInt little endian", out, in);
+}
+
+// 2 - Read/write a double
+template<>
+template<>
+void object::test<2>
+()
+{
+    using geos::io::ByteOrderValues;
+
+    unsigned char buf[8];
+    double in = 2;
+    double out;
+
+    ByteOrderValues::putDouble(in, buf,
+                               ByteOrderValues::ENDIAN_BIG);
+    ensure("putDouble big endian[0]", buf[0] == 64);
+    ensure("putDouble big endian[1]", buf[1] == 0);
+    ensure("putDouble big endian[2]", buf[2] == 0);
+    ensure("putDouble big endian[3]", buf[3] == 0);
+    ensure("putDouble big endian[4]", buf[4] == 0);
+    ensure("putDouble big endian[5]", buf[5] == 0);
+    ensure("putDouble big endian[6]", buf[6] == 0);
+    ensure("putDouble big endian[7]", buf[7] == 0);
+
+    out = ByteOrderValues::getDouble(buf,
+                                     ByteOrderValues::ENDIAN_BIG);
+    ensure_equals("getDouble big endian", out, in);
+
+    ByteOrderValues::putDouble(in, buf,
+                               ByteOrderValues::ENDIAN_LITTLE);
+    ensure("putDouble little endian[0]", buf[0] == 0);
+    ensure("putDouble little endian[1]", buf[1] == 0);
+    ensure("putDouble little endian[2]", buf[2] == 0);
+    ensure("putDouble little endian[3]", buf[3] == 0);
+    ensure("putDouble little endian[4]", buf[4] == 0);
+    ensure("putDouble little endian[5]", buf[5] == 0);
+    ensure("putDouble little endian[6]", buf[6] == 0);
+    ensure("putDouble little endian[7]", buf[7] == 64);
+
+    out = ByteOrderValues::getDouble(buf,
+                                     ByteOrderValues::ENDIAN_LITTLE);
+    ensure_equals("getDouble little endian", out, in);
+}
+
+// 3 - Read/write a long
+template<>
+template<>
+void object::test<3>
+()
 {
-	//
-	// Test Group
-	//
-
-	// dummy data, not used
-	struct test_byteordervalues_data
-	{
-	};
-
-	typedef test_group<test_byteordervalues_data> group;
-	typedef group::object object;
-
-	group test_byteordervalues_group("geos::io::ByteOrderValues");
-
-
-	//
-	// Test Cases
-	//
-
-	// 1 - Read/write an int
-	template<>
-	template<>
-	void object::test<1>()
-	{
-		using geos::io::ByteOrderValues;
-
-		unsigned char buf[4];
-		int in = 1;
-		int out;
-
-		ByteOrderValues::putInt(in, buf, ByteOrderValues::ENDIAN_BIG);
-		ensure("putInt big endian[0]", buf[0] == 0);
-		ensure("putInt big endian[1]", buf[1] == 0);
-		ensure("putInt big endian[2]", buf[2] == 0);
-		ensure("putInt big endian[3]", buf[3] == 1);
-
-		out = ByteOrderValues::getInt(buf,
-				geos::io::ByteOrderValues::ENDIAN_BIG);
-		ensure_equals("getInt big endian", out, in);
-
-		ByteOrderValues::putInt(1, buf, geos::io::ByteOrderValues::ENDIAN_LITTLE);
-		ensure("putInt little endian[0]", buf[0] == 1);
-		ensure("putInt little endian[1]", buf[1] == 0);
-		ensure("putInt little endian[2]", buf[2] == 0);
-		ensure("putInt little endian[3]", buf[3] == 0);
-
-		out = ByteOrderValues::getInt(buf,
-				ByteOrderValues::ENDIAN_LITTLE);
-		ensure_equals("getInt little endian", out, in);
-	}
-
-	// 2 - Read/write a double
-	template<>
-	template<>
-	void object::test<2>()
-	{
-		using geos::io::ByteOrderValues;
-
-		unsigned char buf[8];
-		double in = 2;
-		double out;
-
-		ByteOrderValues::putDouble(in, buf,
-				ByteOrderValues::ENDIAN_BIG);
-		ensure("putDouble big endian[0]", buf[0] == 64);
-		ensure("putDouble big endian[1]", buf[1] == 0);
-		ensure("putDouble big endian[2]", buf[2] == 0);
-		ensure("putDouble big endian[3]", buf[3] == 0);
-		ensure("putDouble big endian[4]", buf[4] == 0);
-		ensure("putDouble big endian[5]", buf[5] == 0);
-		ensure("putDouble big endian[6]", buf[6] == 0);
-		ensure("putDouble big endian[7]", buf[7] == 0);
-
-		out = ByteOrderValues::getDouble(buf,
-				ByteOrderValues::ENDIAN_BIG);
-		ensure_equals("getDouble big endian", out, in);
-
-		ByteOrderValues::putDouble(in, buf,
-				ByteOrderValues::ENDIAN_LITTLE);
-		ensure("putDouble little endian[0]", buf[0] == 0);
-		ensure("putDouble little endian[1]", buf[1] == 0);
-		ensure("putDouble little endian[2]", buf[2] == 0);
-		ensure("putDouble little endian[3]", buf[3] == 0);
-		ensure("putDouble little endian[4]", buf[4] == 0);
-		ensure("putDouble little endian[5]", buf[5] == 0);
-		ensure("putDouble little endian[6]", buf[6] == 0);
-		ensure("putDouble little endian[7]", buf[7] == 64);
-
-		out = ByteOrderValues::getDouble(buf,
-				ByteOrderValues::ENDIAN_LITTLE);
-		ensure_equals("getDouble little endian", out, in);
-	}
-
-	// 3 - Read/write a long
-	template<>
-	template<>
-	void object::test<3>()
-	{
-		using geos::io::ByteOrderValues;
-
-		unsigned char buf[8];
-		long in = 2;
-		long out;
-
-		ByteOrderValues::putLong(in, buf,
-				ByteOrderValues::ENDIAN_BIG);
-		ensure("putLong big endian[0]", buf[0] == 0);
-		ensure("putLong big endian[1]", buf[1] == 0);
-		ensure("putLong big endian[2]", buf[2] == 0);
-		ensure("putLong big endian[3]", buf[3] == 0);
-		ensure("putLong big endian[4]", buf[4] == 0);
-		ensure("putLong big endian[5]", buf[5] == 0);
-		ensure("putLong big endian[6]", buf[6] == 0);
-		ensure("putLong big endian[7]", buf[7] == 2);
-
-		out = static_cast<long>(ByteOrderValues::getLong(buf, ByteOrderValues::ENDIAN_BIG));
-		ensure_equals("getLong big endian", out, in);
-
-		ByteOrderValues::putLong(in, buf,
-				ByteOrderValues::ENDIAN_LITTLE);
-		ensure("putLong little endian[0]", buf[0] == 2);
-		ensure("putLong little endian[1]", buf[1] == 0);
-		ensure("putLong little endian[2]", buf[2] == 0);
-		ensure("putLong little endian[3]", buf[3] == 0);
-		ensure("putLong little endian[4]", buf[4] == 0);
-		ensure("putLong little endian[5]", buf[5] == 0);
-		ensure("putLong little endian[6]", buf[6] == 0);
-		ensure("putLong little endian[7]", buf[7] == 0);
-
-		out = static_cast<long>(ByteOrderValues::getLong(buf, ByteOrderValues::ENDIAN_LITTLE));
-		ensure_equals("getLong little endian", out, in);
-	}
+    using geos::io::ByteOrderValues;
+
+    unsigned char buf[8];
+    long in = 2;
+    long out;
+
+    ByteOrderValues::putLong(in, buf,
+                             ByteOrderValues::ENDIAN_BIG);
+    ensure("putLong big endian[0]", buf[0] == 0);
+    ensure("putLong big endian[1]", buf[1] == 0);
+    ensure("putLong big endian[2]", buf[2] == 0);
+    ensure("putLong big endian[3]", buf[3] == 0);
+    ensure("putLong big endian[4]", buf[4] == 0);
+    ensure("putLong big endian[5]", buf[5] == 0);
+    ensure("putLong big endian[6]", buf[6] == 0);
+    ensure("putLong big endian[7]", buf[7] == 2);
+
+    out = static_cast<long>(ByteOrderValues::getLong(buf, ByteOrderValues::ENDIAN_BIG));
+    ensure_equals("getLong big endian", out, in);
+
+    ByteOrderValues::putLong(in, buf,
+                             ByteOrderValues::ENDIAN_LITTLE);
+    ensure("putLong little endian[0]", buf[0] == 2);
+    ensure("putLong little endian[1]", buf[1] == 0);
+    ensure("putLong little endian[2]", buf[2] == 0);
+    ensure("putLong little endian[3]", buf[3] == 0);
+    ensure("putLong little endian[4]", buf[4] == 0);
+    ensure("putLong little endian[5]", buf[5] == 0);
+    ensure("putLong little endian[6]", buf[6] == 0);
+    ensure("putLong little endian[7]", buf[7] == 0);
+
+    out = static_cast<long>(ByteOrderValues::getLong(buf, ByteOrderValues::ENDIAN_LITTLE));
+    ensure_equals("getLong little endian", out, in);
+}
 
 
 } // namespace tut
diff --git a/tests/unit/io/WKBReaderTest.cpp b/tests/unit/io/WKBReaderTest.cpp
index c555d27..0bf32e1 100644
--- a/tests/unit/io/WKBReaderTest.cpp
+++ b/tests/unit/io/WKBReaderTest.cpp
@@ -21,349 +21,365 @@
 #include <string>
 #include <memory>
 
-namespace tut
-{
-	//
-	// Test Group
-	//
-
-	// dummy data, not used
-	struct test_wkbreader_data
-	{
-		geos::geom::PrecisionModel pm;
-		geos::geom::GeometryFactory::Ptr gf;
-		geos::io::WKBReader wkbreader;
-		geos::io::WKBWriter xdrwkbwriter;
-		geos::io::WKBWriter ndrwkbwriter;
-		geos::io::WKTReader wktreader;
-
-		typedef std::unique_ptr<geos::geom::Geometry> GeomPtr;
-
-		test_wkbreader_data()
-			:
-			pm(1.0),
-			gf(geos::geom::GeometryFactory::create(&pm)),
-			wkbreader(*gf),
-			// 2D only, XDR (big endian)
-			xdrwkbwriter(2, geos::io::WKBConstants::wkbXDR),
-			// 2D only, NDR (little endian)
-			ndrwkbwriter(2, geos::io::WKBConstants::wkbNDR),
-			wktreader(gf.get())
-		{}
-
-		void testInputNdr(const std::string& WKT,
-				const std::string& ndrWKB)
-		{
-			GeomPtr gWKT(wktreader.read(WKT));
-			// NDR input
-			std::stringstream ndr_in(ndrWKB);
-			GeomPtr gWKB_ndr(wkbreader.readHEX(ndr_in));
-			ensure("NDR input", gWKB_ndr->equalsExact(gWKT.get()) );
-		}
-
-		void testInputOutput(const std::string& WKT,
-				const std::string& ndrWKB,
-				const std::string& xdrWKB)
-		{
-			GeomPtr gWKT(wktreader.read(WKT));
-
-			// NDR input
-			std::stringstream ndr_in(ndrWKB);
-			GeomPtr gWKB_ndr(wkbreader.readHEX(ndr_in));
-			ensure("NDR input",
-				gWKB_ndr->equalsExact(gWKT.get()) );
-
-			// XDR input
-			std::stringstream xdr_in(xdrWKB);
-			GeomPtr gWKB_xdr(wkbreader.readHEX(xdr_in));
-			ensure("XDR input",
-				gWKB_xdr->equalsExact(gWKT.get()) );
-
-			// Compare geoms read from NDR and XDR
-			ensure( gWKB_xdr->equalsExact(gWKB_ndr.get()) );
+namespace tut {
+//
+// Test Group
+//
 
-			// NDR output
-			std::stringstream ndr_out;
-			ndrwkbwriter.writeHEX(*gWKT, ndr_out);
-			ensure_equals("NDR output",
-				ndr_out.str(), ndr_in.str());
+// dummy data, not used
+struct test_wkbreader_data {
+    geos::geom::PrecisionModel pm;
+    geos::geom::GeometryFactory::Ptr gf;
+    geos::io::WKBReader wkbreader;
+    geos::io::WKBWriter xdrwkbwriter;
+    geos::io::WKBWriter ndrwkbwriter;
+    geos::io::WKTReader wktreader;
+
+    typedef std::unique_ptr<geos::geom::Geometry> GeomPtr;
+
+    test_wkbreader_data()
+        :
+        pm(1.0),
+        gf(geos::geom::GeometryFactory::create(&pm)),
+        wkbreader(*gf),
+        // 2D only, XDR (big endian)
+        xdrwkbwriter(2, geos::io::WKBConstants::wkbXDR),
+        // 2D only, NDR (little endian)
+        ndrwkbwriter(2, geos::io::WKBConstants::wkbNDR),
+        wktreader(gf.get())
+    {}
+
+    void
+    testInputNdr(const std::string& WKT,
+                 const std::string& ndrWKB)
+    {
+        GeomPtr gWKT(wktreader.read(WKT));
+        // NDR input
+        std::stringstream ndr_in(ndrWKB);
+        GeomPtr gWKB_ndr(wkbreader.readHEX(ndr_in));
+        ensure("NDR input", gWKB_ndr->equalsExact(gWKT.get()));
+    }
 
-			// XDR output
-			std::stringstream xdr_out;
-			xdrwkbwriter.writeHEX(*gWKT, xdr_out);
-			ensure_equals("XDR output",
-				xdr_out.str(), xdr_in.str());
+    void
+    testInputOutput(const std::string& WKT,
+                    const std::string& ndrWKB,
+                    const std::string& xdrWKB)
+    {
+        GeomPtr gWKT(wktreader.read(WKT));
+
+        // NDR input
+        std::stringstream ndr_in(ndrWKB);
+        GeomPtr gWKB_ndr(wkbreader.readHEX(ndr_in));
+        ensure("NDR input",
+               gWKB_ndr->equalsExact(gWKT.get()));
+
+        // XDR input
+        std::stringstream xdr_in(xdrWKB);
+        GeomPtr gWKB_xdr(wkbreader.readHEX(xdr_in));
+        ensure("XDR input",
+               gWKB_xdr->equalsExact(gWKT.get()));
+
+        // Compare geoms read from NDR and XDR
+        ensure(gWKB_xdr->equalsExact(gWKB_ndr.get()));
+
+        // NDR output
+        std::stringstream ndr_out;
+        ndrwkbwriter.writeHEX(*gWKT, ndr_out);
+        ensure_equals("NDR output",
+                      ndr_out.str(), ndr_in.str());
+
+        // XDR output
+        std::stringstream xdr_out;
+        xdrwkbwriter.writeHEX(*gWKT, xdr_out);
+        ensure_equals("XDR output",
+                      xdr_out.str(), xdr_in.str());
 
-		}
+    }
 
-	};
+};
 
-	typedef test_group<test_wkbreader_data> group;
-	typedef group::object object;
+typedef test_group<test_wkbreader_data> group;
+typedef group::object object;
 
-	group test_wkbreader_group("geos::io::WKBReader");
+group test_wkbreader_group("geos::io::WKBReader");
 
 
-	//
-	// Test Cases
-	//
+//
+// Test Cases
+//
 
-	// 1 - Read/write a point in XDR and NDR format
-	template<>
-	template<>
-	void object::test<1>()
-	{
-		testInputOutput(
+// 1 - Read/write a point in XDR and NDR format
+template<>
+template<>
+void object::test<1>
+()
+{
+    testInputOutput(
 
-			// WKT
-			"POINT(0 0)",
+        // WKT
+        "POINT(0 0)",
 
-			// NDR HEXWKB
-			"010100000000000000000000000000000000000000",
+        // NDR HEXWKB
+        "010100000000000000000000000000000000000000",
 
-			// XDR HEXWKB
-			"000000000100000000000000000000000000000000"
+        // XDR HEXWKB
+        "000000000100000000000000000000000000000000"
 
-		);
-	}
+    );
+}
 
-	// 2 - Read a linestring
-	template<>
-	template<>
-	void object::test<2>()
-	{
+// 2 - Read a linestring
+template<>
+template<>
+void object::test<2>
+()
+{
 
-		testInputOutput(
+    testInputOutput(
 
-			// WKT
-			"LINESTRING(1 2, 3 4)",
+        // WKT
+        "LINESTRING(1 2, 3 4)",
 
-			// NDR HEXWKB
-			"010200000002000000000000000000F03F000000000000004000000000000008400000000000001040",
+        // NDR HEXWKB
+        "010200000002000000000000000000F03F000000000000004000000000000008400000000000001040",
 
-			// XDR HEXWKB
-			"0000000002000000023FF0000000000000400000000000000040080000000000004010000000000000"
+        // XDR HEXWKB
+        "0000000002000000023FF0000000000000400000000000000040080000000000004010000000000000"
 
-		);
+    );
 
-	}
+}
 
-	// 3 - Read a polygon
-	template<>
-	template<>
-	void object::test<3>()
-	{
-		testInputOutput(
+// 3 - Read a polygon
+template<>
+template<>
+void object::test<3>
+()
+{
+    testInputOutput(
 
-			// WKT
-			"POLYGON((0 0, 10 0, 10 10, 0 10, 0 0),(2 2, 2 6, 6 4, 2 2))",
+        // WKT
+        "POLYGON((0 0, 10 0, 10 10, 0 10, 0 0),(2 2, 2 6, 6 4, 2 2))",
 
-			// NDR HEXWKB
-			"0103000000020000000500000000000000000000000000000000000000000000000000244000000000000000000000000000002440000000000000244000000000000000000000000000002440000000000000000000000000000000000400000000000000000000400000000000000040000000000000004000000000000018400000000000001840000000000000104000000000000000400000000000000040",
+        // NDR HEXWKB
+        "0103000000020000000500000000000000000000000000000000000000000000000000244000000000000000000000000000002440000000000000244000000000000000000000000000002440000000000000000000000000000000000400000000000000000000400000000000000040000000000000004000000000000018400000000000001840000000000000104000000000000000400000000000000040",
 
-			// XDR HEXWKB
-			"0000000003000000020000000500000000000000000000000000000000402400000000000000000000000000004024000000000000402400000000000000000000000000004024000000000000000000000000000000000000000000000000000440000000000000004000000000000000400000000000000040180000000000004018000000000000401000000000000040000000000000004000000000000000"
+        // XDR HEXWKB
+        "0000000003000000020000000500000000000000000000000000000000402400000000000000000000000000004024000000000000402400000000000000000000000000004024000000000000000000000000000000000000000000000000000440000000000000004000000000000000400000000000000040180000000000004018000000000000401000000000000040000000000000004000000000000000"
 
-		);
+    );
 
-	}
+}
 
-	// 4 - Read a multipoint
-	template<>
-	template<>
-	void object::test<4>()
-	{
+// 4 - Read a multipoint
+template<>
+template<>
+void object::test<4>
+()
+{
 
-		testInputOutput(
+    testInputOutput(
 
-			// WKT
-			"MULTIPOINT(0 0, 10 0, 10 10, 0 10, 0 0)",
+        // WKT
+        "MULTIPOINT(0 0, 10 0, 10 10, 0 10, 0 0)",
 
-			// NDR HEXWKB
-			"010400000005000000010100000000000000000000000000000000000000010100000000000000000024400000000000000000010100000000000000000024400000000000002440010100000000000000000000000000000000002440010100000000000000000000000000000000000000",
+        // NDR HEXWKB
+        "010400000005000000010100000000000000000000000000000000000000010100000000000000000024400000000000000000010100000000000000000024400000000000002440010100000000000000000000000000000000002440010100000000000000000000000000000000000000",
 
-			// XDR HEXWKB
-			"000000000400000005000000000100000000000000000000000000000000000000000140240000000000000000000000000000000000000140240000000000004024000000000000000000000100000000000000004024000000000000000000000100000000000000000000000000000000"
+        // XDR HEXWKB
+        "000000000400000005000000000100000000000000000000000000000000000000000140240000000000000000000000000000000000000140240000000000004024000000000000000000000100000000000000004024000000000000000000000100000000000000000000000000000000"
 
-		);
+    );
 
-	}
+}
 
-	// 5 - Read a multilinestring
-	template<>
-	template<>
-	void object::test<5>()
-	{
+// 5 - Read a multilinestring
+template<>
+template<>
+void object::test<5>
+()
+{
 
-		testInputOutput(
+    testInputOutput(
 
-			// WKT
-			"MULTILINESTRING((0 0, 10 0, 10 10, 0 10, 10 20),(2 2, 2 6, 6 4, 20 2))",
+        // WKT
+        "MULTILINESTRING((0 0, 10 0, 10 10, 0 10, 10 20),(2 2, 2 6, 6 4, 20 2))",
 
-			// NDR HEXWKB
-			"010500000002000000010200000005000000000000000000000000000000000000000000000000002440000000000000000000000000000024400000000000002440000000000000000000000000000024400000000000002440000000000000344001020000000400000000000000000000400000000000000040000000000000004000000000000018400000000000001840000000000000104000000000000034400000000000000040",
+        // NDR HEXWKB
+        "010500000002000000010200000005000000000000000000000000000000000000000000000000002440000000000000000000000000000024400000000000002440000000000000000000000000000024400000000000002440000000000000344001020000000400000000000000000000400000000000000040000000000000004000000000000018400000000000001840000000000000104000000000000034400000000000000040",
 
-			// XDR HEXWKB
-			"000000000500000002000000000200000005000000000000000000000000000000004024000000000000000000000000000040240000000000004024000000000000000000000000000040240000000000004024000000000000403400000000000000000000020000000440000000000000004000000000000000400000000000000040180000000000004018000000000000401000000000000040340000000000004000000000000000"
+        // XDR HEXWKB
+        "000000000500000002000000000200000005000000000000000000000000000000004024000000000000000000000000000040240000000000004024000000000000000000000000000040240000000000004024000000000000403400000000000000000000020000000440000000000000004000000000000000400000000000000040180000000000004018000000000000401000000000000040340000000000004000000000000000"
 
-		);
+    );
 
-	}
+}
 
-	// 6 - Read a multipolygon
-	template<>
-	template<>
-	void object::test<6>()
-	{
+// 6 - Read a multipolygon
+template<>
+template<>
+void object::test<6>
+()
+{
 
-		testInputOutput(
+    testInputOutput(
 
-			// WKT
-			"MULTIPOLYGON(((0 0, 10 0, 10 10, 0 10, 0 0),(2 2, 2 6, 6 4, 2 2)),((60 60, 60 50, 70 40, 60 60)))",
+        // WKT
+        "MULTIPOLYGON(((0 0, 10 0, 10 10, 0 10, 0 0),(2 2, 2 6, 6 4, 2 2)),((60 60, 60 50, 70 40, 60 60)))",
 
-			// NDR HEXWKB
-			"0106000000020000000103000000020000000500000000000000000000000000000000000000000000000000244000000000000000000000000000002440000000000000244000000000000000000000000000002440000000000000000000000000000000000400000000000000000000400000000000000040000000000000004000000000000018400000000000001840000000000000104000000000000000400000000000000040010300000001000000040000000000000000004E400000000000004E400000000000004E400000000000004940000000000080514000000000000044400000000000004E400000000000004E40",
+        // NDR HEXWKB
+        "0106000000020000000103000000020000000500000000000000000000000000000000000000000000000000244000000000000000000000000000002440000000000000244000000000000000000000000000002440000000000000000000000000000000000400000000000000000000400000000000000040000000000000004000000000000018400000000000001840000000000000104000000000000000400000000000000040010300000001000000040000000000000000004E400000000000004E400000000000004E400000000000004940000000000080514000000000000044400000000000004E400000000000004E40",
 
-			// XDR HEXWKB
-			"000000000600000002000000000300000002000000050000000000000000000000000000000040240000000000000000000000000000402400000000000040240000000000000000000000000000402400000000000000000000000000000000000000000000000000044000000000000000400000000000000040000000000000004018000000000000401800000000000040100000000000004000000000000000400000000000000000000000030000000100000004404E000000000000404E000000000000404E000000000000404900000000000040518000000000004044000000000000404E000000000000404E000000000000"
+        // XDR HEXWKB
+        "000000000600000002000000000300000002000000050000000000000000000000000000000040240000000000000000000000000000402400000000000040240000000000000000000000000000402400000000000000000000000000000000000000000000000000044000000000000000400000000000000040000000000000004018000000000000401800000000000040100000000000004000000000000000400000000000000000000000030000000100000004404E000000000000404E000000000000404E000000000000404900000000000040518000000000004044000000000000404E000000000000404E000000000000"
 
-		);
+    );
 
-	}
+}
 
-	// 7 - Read a collection
-	template<>
-	template<>
-	void object::test<7>()
-	{
+// 7 - Read a collection
+template<>
+template<>
+void object::test<7>
+()
+{
 
-		testInputOutput(
+    testInputOutput(
 
-			// WKT
-			"GEOMETRYCOLLECTION(POINT(0 0),LINESTRING(1 2,3 4),POLYGON((0 0,10 0,10 10,0 10,0 0),(2 2,2 6,6 4,2 2)),MULTIPOINT(0 0,10 0,10 10,0 10,0 0),MULTILINESTRING((0 0,10 0,10 10,0 10,10 20),(2 2,2 6,6 4,20 2)),MULTIPOLYGON(((0 0,10 0,10 10,0 10,0 0),(2 2,2 6,6 4,2 2)),((60 60,60 50,70 40,60 60))))",
+        // WKT
+        "GEOMETRYCOLLECTION(POINT(0 0),LINESTRING(1 2,3 4),POLYGON((0 0,10 0,10 10,0 10,0 0),(2 2,2 6,6 4,2 2)),MULTIPOINT(0 0,10 0,10 10,0 10,0 0),MULTILINESTRING((0 0,10 0,10 10,0 10,10 20),(2 2,2 6,6 4,20 2)),MULTIPOLYGON(((0 0,10 0,10 10,0 10,0 0),(2 2,2 6,6 4,2 2)),((60 60,60 50,70 40,60 60))))",
 
-			// NDR HEXWKB
-			"010700000006000000010100000000000000000000000000000000000000010200000002000000000000000000F03F00000000000000400000000000000840000000000000104001030000000200000005000000000000000000000000000000000000000000000000002440000000000000000000000000000024400000000000002440000000000000000000000000000024400000000000000000000000000000000004000000000000000000004000000000000000400000000000000040000000000000184000000000000018400000000000001040000000000000004000000000000000400104000000050000000101000000000000000000000000000000000000000101000000000000000000244000000000000000000101000000000000000000244000000000000024400101000000000000000000000000000000000024400101000000000000000000000000000000000000000105000000020000000102000000050000000000000000000000000000000000000000000000000024400000000000000000000000000000244000000000000024400000000000000000000000000000244000000000000024400000000000003440010200000004000000000000000000004000000000000000400000000000000040000000000000184000000000000018400000000
 000001040000000000000344000000000000000400106000000020000000103000000020000000500000000000000000000000000000000000000000000000000244000000000000000000000000000002440000000000000244000000000000000000000000000002440000000000000000000000000000000000400000000000000000000400000000000000040000000000000004000000000000018400000000000001840000000000000104000000000000000400000000000000040010300000001000000040000000000000000004E400000000000004E400000000000004E400000000000004940000000000080514000000000000044400000000000004E400000000000004E40",
+        // NDR HEXWKB
+        "010700000006000000010100000000000000000000000000000000000000010200000002000000000000000000F03F000000000000004000000000000008400000000000001040010300000002000000050000000000000000000000000000000000000000000000000024400000000000000000000000000000244000000000000024400000000000000000000000000000244000000000000000000000000000000000040000000000000000000040000000000000004000000000000000400000000000001840000000000000184000000000000010400000000000000040000000000000004001040000000500000001010000000000000000000000000000000000000001010000000000000000002440000000000000000001010000000000000000002440000000000000244001010000000000000000000000000000000000244001010000000000000000000000000000000000000001050000000200000001020000000500000000000000000000000000000000000000000000000000244000000000000000000000000000002440000000000000244000000000000000000000000000002440000000000000244000000000000034400102000000040000000000000000000040000000000000004000000000000000400000000000001840000000000000184000
 00000000001040000000000000344000000000000000400106000000020000000103000000020000000500000000000000000000000000000000000000000000000000244000000000000000000000000000002440000000000000244000000000000000000000000000002440000000000000000000000000000000000400000000000000000000400000000000000040000000000000004000000000000018400000000000001840000000000000104000000000000000400000000000000040010300000001000000040000000000000000004E400000000000004E400000000000004E400000000000004940000000000080514000000000000044400000000000004E400000000000004E40",
 
-			// XDR HEXWKB
-			"0000000007000000060000000001000000000000000000000000000000000000000002000000023FF000000000000040000000000000004008000000000000401000000000000000000000030000000200000005000000000000000000000000000000004024000000000000000000000000000040240000000000004024000000000000000000000000000040240000000000000000000000000000000000000000000000000004400000000000000040000000000000004000000000000000401800000000000040180000000000004010000000000000400000000000000040000000000000000000000004000000050000000001000000000000000000000000000000000000000001402400000000000000000000000000000000000001402400000000000040240000000000000000000001000000000000000040240000000000000000000001000000000000000000000000000000000000000005000000020000000002000000050000000000000000000000000000000040240000000000000000000000000000402400000000000040240000000000000000000000000000402400000000000040240000000000004034000000000000000000000200000004400000000000000040000000000000004000000000000000401800000000000040180000000000004010000
 00000000040340000000000004000000000000000000000000600000002000000000300000002000000050000000000000000000000000000000040240000000000000000000000000000402400000000000040240000000000000000000000000000402400000000000000000000000000000000000000000000000000044000000000000000400000000000000040000000000000004018000000000000401800000000000040100000000000004000000000000000400000000000000000000000030000000100000004404E000000000000404E000000000000404E000000000000404900000000000040518000000000004044000000000000404E000000000000404E000000000000"
+        // XDR HEXWKB
+        "0000000007000000060000000001000000000000000000000000000000000000000002000000023FF0000000000000400000000000000040080000000000004010000000000000000000000300000002000000050000000000000000000000000000000040240000000000000000000000000000402400000000000040240000000000000000000000000000402400000000000000000000000000000000000000000000000000044000000000000000400000000000000040000000000000004018000000000000401800000000000040100000000000004000000000000000400000000000000000000000040000000500000000010000000000000000000000000000000000000000014024000000000000000000000000000000000000014024000000000000402400000000000000000000010000000000000000402400000000000000000000010000000000000000000000000000000000000000050000000200000000020000000500000000000000000000000000000000402400000000000000000000000000004024000000000000402400000000000000000000000000004024000000000000402400000000000040340000000000000000000002000000044000000000000000400000000000000040000000000000004018000000000000401800000000000040
 1000000000000040340000000000004000000000000000000000000600000002000000000300000002000000050000000000000000000000000000000040240000000000000000000000000000402400000000000040240000000000000000000000000000402400000000000000000000000000000000000000000000000000044000000000000000400000000000000040000000000000004018000000000000401800000000000040100000000000004000000000000000400000000000000000000000030000000100000004404E000000000000404E000000000000404E000000000000404900000000000040518000000000004044000000000000404E000000000000404E000000000000"
 
-		);
+    );
 
-	}
+}
 
-  // 8 - Invalid HEXWKB for missing HEX char (#675)
-  template<>
-  template<>
-  void object::test<8>()
-  {
+// 8 - Invalid HEXWKB for missing HEX char (#675)
+template<>
+template<>
+void object::test<8>
+()
+{
     std::stringstream hexwkb;
     // NOTE: add a 0 to make valid
     hexwkb << "01010000000000000000000000000000000000000";
     //hexwkb << "0";
     std::string err;
     try {
-    GeomPtr gWKB_ndr(wkbreader.readHEX(hexwkb));
-    } catch (const geos::util::GEOSException& ex) {
-      err = ex.what();
+        GeomPtr gWKB_ndr(wkbreader.readHEX(hexwkb));
+    }
+    catch(const geos::util::GEOSException& ex) {
+        err = ex.what();
     }
     ensure("Missing expected error", !err.empty());
     ensure_equals(err, "ParseException: Premature end of HEX string");
-  }
+}
 
-  // 9 - Extended HEXWKB (3dZ + srid)
-  template<>
-  template<>
-  void object::test<9>()
-  {
+// 9 - Extended HEXWKB (3dZ + srid)
+template<>
+template<>
+void object::test<9>
+()
+{
     std::stringstream hexwkb;
     hexwkb <<
 // SRID=4326;POINT(1 2 3)
 // NDR HEXEWKB
-"01010000A0E6100000000000000000F03F00000000000000400000000000000840";
+           "01010000A0E6100000000000000000F03F00000000000000400000000000000840";
     std::string err;
     GeomPtr gWKB(wkbreader.readHEX(hexwkb));
     ensure_equals(gWKB->getSRID(), 4326);
     ensure_equals(gWKB->getCoordinateDimension(), 3);
-  }
-
-	// 10 - Extended WKB with Z
-	template<>
-	template<>
-	void object::test<10>()
-	{
-		testInputNdr(
-			// WKT
-			"POINT Z(1 2 3)",
-			// NDR HEXWKB
-			"01010000A0E6100000000000000000F03F00000000000000400000000000000840"
-		);
-	}
-
-	// 11 - Extended WKB with Z
-	template<>
-	template<>
-	void object::test<11>()
-	{
-		testInputNdr(
-			// WKT
-			"LINESTRING Z(1 2 3, 4 5 6)",
-			// NDR HEXWKB
-			"01020000A0E610000002000000000000000000F03F00000000000000400000000000000840000000000000104000000000000014400000000000001840"
-		);
-	}
-
-	// 12 - Extended WKB with Z
-	template<>
-	template<>
-	void object::test<12>()
-	{
-		testInputNdr(
-			// WKT
-			"POLYGON Z((0 0 100,0 10 100,10 10 100,10 0 100,0 0 100),(1 1 100,1 9 100,9 9 100,9 1 100,1 1 100))",
-			// NDR HEXWKB
-			"01030000A0E6100000020000000500000000000000000000000000000000000000000000000000594000000000000000000000000000002440000000000000594000000000000024400000000000002440000000000000594000000000000024400000000000000000000000000000594000000000000000000000000000000000000000000000594005000000000000000000F03F000000000000F03F0000000000005940000000000000F03F000000000000224000000000000059400000000000002240000000000000224000000000000059400000000000002240000000000000F03F0000000000005940000000000000F03F000000000000F03F0000000000005940"
-		);
-	}
-
-	// 13 - Extended WKB with Z
-	template<>
-	template<>
-	void object::test<13>()
-	{
-		testInputNdr(
-			// WKT
-			"MULTIPOINT Z(0 1 2, 3 4 5)",
-			// NDR HEXWKB
-			"01040000A0E61000000200000001010000800000000000000000000000000000F03F00000000000000400101000080000000000000084000000000000010400000000000001440"
-		);
-	}
-
-	// 14 - Extended WKB with Z
-	template<>
-	template<>
-	void object::test<14>()
-	{
-		testInputNdr(
-			// WKT
-			"MULTILINESTRING Z((0 1 2,3 4 5),(6 7 8,9 10 11))",
-			// NDR HEXWKB
-			"01050000A0E6100000020000000102000080020000000000000000000000000000000000F03F000000000000004000000000000008400000000000001040000000000000144001020000800200000000000000000018400000000000001C400000000000002040000000000000224000000000000024400000000000002640"
-		);
-	}
-
-	// 15 - Extended WKB with Z
-	template<>
-	template<>
-	void object::test<15>()
-	{
-		testInputNdr(
-			// WKT
-			"MULTIPOLYGON Z(((0 0 100,0 10 100,10 10 100,10 0 100,0 0 100),(1 1 100,1 9 100,9 9 100,9 1 100,1 1 100)),((-9 0 50,-9 10 50,-1 10 50,-1 0 50,-9 0 50)))",
-			// NDR HEXWKB
-			"01060000A0E6100000020000000103000080020000000500000000000000000000000000000000000000000000000000594000000000000000000000000000002440000000000000594000000000000024400000000000002440000000000000594000000000000024400000000000000000000000000000594000000000000000000000000000000000000000000000594005000000000000000000F03F000000000000F03F0000000000005940000000000000F03F000000000000224000000000000059400000000000002240000000000000224000000000000059400000000000002240000000000000F03F0000000000005940000000000000F03F000000000000F03F00000000000059400103000080010000000500000000000000000022C00000000000000000000000000000494000000000000022C000000000000024400000000000004940000000000000F0BF00000000000024400000000000004940000000000000F0BF0000000000000000000000000000494000000000000022C000000000000000000000000000004940"
-		);
-	}
+}
+
+// 10 - Extended WKB with Z
+template<>
+template<>
+void object::test<10>
+()
+{
+    testInputNdr(
+        // WKT
+        "POINT Z(1 2 3)",
+        // NDR HEXWKB
+        "01010000A0E6100000000000000000F03F00000000000000400000000000000840"
+    );
+}
+
+// 11 - Extended WKB with Z
+template<>
+template<>
+void object::test<11>
+()
+{
+    testInputNdr(
+        // WKT
+        "LINESTRING Z(1 2 3, 4 5 6)",
+        // NDR HEXWKB
+        "01020000A0E610000002000000000000000000F03F00000000000000400000000000000840000000000000104000000000000014400000000000001840"
+    );
+}
+
+// 12 - Extended WKB with Z
+template<>
+template<>
+void object::test<12>
+()
+{
+    testInputNdr(
+        // WKT
+        "POLYGON Z((0 0 100,0 10 100,10 10 100,10 0 100,0 0 100),(1 1 100,1 9 100,9 9 100,9 1 100,1 1 100))",
+        // NDR HEXWKB
+        "01030000A0E6100000020000000500000000000000000000000000000000000000000000000000594000000000000000000000000000002440000000000000594000000000000024400000000000002440000000000000594000000000000024400000000000000000000000000000594000000000000000000000000000000000000000000000594005000000000000000000F03F000000000000F03F0000000000005940000000000000F03F000000000000224000000000000059400000000000002240000000000000224000000000000059400000000000002240000000000000F03F0000000000005940000000000000F03F000000000000F03F0000000000005940"
+    );
+}
+
+// 13 - Extended WKB with Z
+template<>
+template<>
+void object::test<13>
+()
+{
+    testInputNdr(
+        // WKT
+        "MULTIPOINT Z(0 1 2, 3 4 5)",
+        // NDR HEXWKB
+        "01040000A0E61000000200000001010000800000000000000000000000000000F03F00000000000000400101000080000000000000084000000000000010400000000000001440"
+    );
+}
+
+// 14 - Extended WKB with Z
+template<>
+template<>
+void object::test<14>
+()
+{
+    testInputNdr(
+        // WKT
+        "MULTILINESTRING Z((0 1 2,3 4 5),(6 7 8,9 10 11))",
+        // NDR HEXWKB
+        "01050000A0E6100000020000000102000080020000000000000000000000000000000000F03F000000000000004000000000000008400000000000001040000000000000144001020000800200000000000000000018400000000000001C400000000000002040000000000000224000000000000024400000000000002640"
+    );
+}
+
+// 15 - Extended WKB with Z
+template<>
+template<>
+void object::test<15>
+()
+{
+    testInputNdr(
+        // WKT
+        "MULTIPOLYGON Z(((0 0 100,0 10 100,10 10 100,10 0 100,0 0 100),(1 1 100,1 9 100,9 9 100,9 1 100,1 1 100)),((-9 0 50,-9 10 50,-1 10 50,-1 0 50,-9 0 50)))",
+        // NDR HEXWKB
+        "01060000A0E6100000020000000103000080020000000500000000000000000000000000000000000000000000000000594000000000000000000000000000002440000000000000594000000000000024400000000000002440000000000000594000000000000024400000000000000000000000000000594000000000000000000000000000000000000000000000594005000000000000000000F03F000000000000F03F0000000000005940000000000000F03F000000000000224000000000000059400000000000002240000000000000224000000000000059400000000000002240000000000000F03F0000000000005940000000000000F03F000000000000F03F00000000000059400103000080010000000500000000000000000022C00000000000000000000000000000494000000000000022C000000000000024400000000000004940000000000000F0BF00000000000024400000000000004940000000000000F0BF0000000000000000000000000000494000000000000022C000000000000000000000000000004940"
+    );
+}
 
 } // namespace tut
 
diff --git a/tests/unit/io/WKBWriterTest.cpp b/tests/unit/io/WKBWriterTest.cpp
index 8eb89d5..793e1a3 100644
--- a/tests/unit/io/WKBWriterTest.cpp
+++ b/tests/unit/io/WKBWriterTest.cpp
@@ -17,172 +17,176 @@
 #include <memory>
 #include <cmath>
 
-namespace tut
+namespace tut {
+//
+// Test Group
+//
+
+// dummy data, not used
+struct test_wkbwriter_data {
+    geos::geom::PrecisionModel pm;
+    geos::geom::GeometryFactory::Ptr gf;
+    geos::io::WKTReader wktreader;
+    geos::io::WKTWriter wktwriter;
+    geos::io::WKBReader wkbreader;
+    geos::io::WKBWriter wkbwriter;
+
+    test_wkbwriter_data()
+        :
+        pm(1000.0),
+        gf(geos::geom::GeometryFactory::create(&pm)),
+        wktreader(gf.get()),
+        wkbreader(*gf)
+    {}
+
+};
+
+typedef test_group<test_wkbwriter_data> group;
+typedef group::object object;
+
+group test_wkbwriter_group("geos::io::WKBWriter");
+
+
+//
+// Test Cases
+//
+
+// 1 - Test writing a 2D geometry with the WKBWriter in 3D output dimension.
+template<>
+template<>
+void object::test<1>
+()
+{
+    geos::geom::Geometry* geom = wktreader.read("POINT(-117 33)");
+    std::stringstream result_stream;
+
+    wkbwriter.setOutputDimension(3);
+    wkbwriter.write(*geom, result_stream);
+    delete geom;
+    geom = nullptr;
+
+    ensure(result_stream.str().length() == 21);
+
+    result_stream.seekg(0);
+    geom = wkbreader.read(result_stream);
+
+    ensure(geom != nullptr);
+
+    ensure(geom->getCoordinateDimension() == 2);
+    ensure(geom->getCoordinate()->x == -117.0);
+    ensure(geom->getCoordinate()->y == 33.0);
+    ensure(std::isnan(geom->getCoordinate()->z) != 0);
+
+    delete geom;
+}
+
+// 2 - Test writing a 3D geometry with the WKBWriter in 3D output dimension.
+template<>
+template<>
+void object::test<2>
+()
+{
+    geos::geom::Geometry* geom = wktreader.read("POINT(-117 33 11)");
+    std::stringstream result_stream;
+
+    wkbwriter.setOutputDimension(3);
+    wkbwriter.write(*geom, result_stream);
+    delete geom;
+    geom = nullptr;
+
+    ensure(result_stream.str().length() == 29);
+
+    result_stream.seekg(0);
+    geom = wkbreader.read(result_stream);
+
+    ensure(geom->getCoordinateDimension() == 3);
+    ensure(geom->getCoordinate()->x == -117.0);
+    ensure(geom->getCoordinate()->y == 33.0);
+    ensure(geom->getCoordinate()->z == 11.0);
+
+    delete geom;
+}
+
+// 3 - Test writing a 3D geometry with the WKBWriter in 2D output dimension.
+template<>
+template<>
+void object::test<3>
+()
 {
-	//
-	// Test Group
-	//
-
-	// dummy data, not used
-	struct test_wkbwriter_data
-	{
-		geos::geom::PrecisionModel pm;
-		geos::geom::GeometryFactory::Ptr gf;
-		geos::io::WKTReader wktreader;
-		geos::io::WKTWriter wktwriter;
-		geos::io::WKBReader wkbreader;
-		geos::io::WKBWriter wkbwriter;
-
-		test_wkbwriter_data()
-			:
-			pm(1000.0),
-			gf(geos::geom::GeometryFactory::create(&pm)),
-      wktreader(gf.get()),
-      wkbreader(*gf)
-		{}
-
-	};
-
-	typedef test_group<test_wkbwriter_data> group;
-	typedef group::object object;
-
-	group test_wkbwriter_group("geos::io::WKBWriter");
-
-
-	//
-	// Test Cases
-	//
-
-	// 1 - Test writing a 2D geometry with the WKBWriter in 3D output dimension.
-	template<>
-	template<>
-	void object::test<1>()
-	{
-            geos::geom::Geometry *geom = wktreader.read("POINT(-117 33)");
-			std::stringstream result_stream;
-
-            wkbwriter.setOutputDimension( 3 );
-            wkbwriter.write( *geom, result_stream );
-            delete geom;
-            geom = nullptr;
-
-            ensure( result_stream.str().length() == 21 );
-
-            result_stream.seekg( 0 );
-            geom = wkbreader.read( result_stream );
-
-            ensure( geom != nullptr );
-
-            ensure( geom->getCoordinateDimension() == 2 );
-            ensure( geom->getCoordinate()->x == -117.0 );
-            ensure( geom->getCoordinate()->y == 33.0 );
-            ensure( std::isnan(geom->getCoordinate()->z) != 0 );
-
-            delete geom;
-    }
-
-	// 2 - Test writing a 3D geometry with the WKBWriter in 3D output dimension.
-	template<>
-	template<>
-	void object::test<2>()
-	{
-            geos::geom::Geometry *geom = wktreader.read("POINT(-117 33 11)");
-			std::stringstream result_stream;
-
-            wkbwriter.setOutputDimension( 3 );
-            wkbwriter.write( *geom, result_stream );
-            delete geom;
-            geom = nullptr;
-
-            ensure( result_stream.str().length() == 29 );
-
-            result_stream.seekg( 0 );
-            geom = wkbreader.read( result_stream );
-
-            ensure( geom->getCoordinateDimension() == 3 );
-            ensure( geom->getCoordinate()->x == -117.0 );
-            ensure( geom->getCoordinate()->y == 33.0 );
-            ensure( geom->getCoordinate()->z == 11.0 );
-
-            delete geom;
-    }
-
-	// 3 - Test writing a 3D geometry with the WKBWriter in 2D output dimension.
-	template<>
-	template<>
-	void object::test<3>()
-	{
-            geos::geom::Geometry *geom = wktreader.read("POINT(-117 33 11)");
-			std::stringstream result_stream;
-
-            wkbwriter.setOutputDimension( 2 );
-            wkbwriter.write( *geom, result_stream );
-            delete geom;
-            geom = nullptr;
-
-            ensure( result_stream.str().length() == 21 );
-
-            result_stream.seekg( 0 );
-            geom = wkbreader.read( result_stream );
-
-            ensure( geom->getCoordinateDimension() == 2 );
-            ensure( geom->getCoordinate()->x == -117.0 );
-            ensure( geom->getCoordinate()->y == 33.0 );
-            ensure( std::isnan(geom->getCoordinate()->z) != 0);
-
-            delete geom;
-    }
+    geos::geom::Geometry* geom = wktreader.read("POINT(-117 33 11)");
+    std::stringstream result_stream;
+
+    wkbwriter.setOutputDimension(2);
+    wkbwriter.write(*geom, result_stream);
+    delete geom;
+    geom = nullptr;
+
+    ensure(result_stream.str().length() == 21);
+
+    result_stream.seekg(0);
+    geom = wkbreader.read(result_stream);
+
+    ensure(geom->getCoordinateDimension() == 2);
+    ensure(geom->getCoordinate()->x == -117.0);
+    ensure(geom->getCoordinate()->y == 33.0);
+    ensure(std::isnan(geom->getCoordinate()->z) != 0);
 
-	// 4 - Test that SRID is output only once
-  // See http://trac.osgeo.org/geos/ticket/583
-	template<>
-	template<>
-	void object::test<4>()
-	{
+    delete geom;
+}
+
+// 4 - Test that SRID is output only once
+// See http://trac.osgeo.org/geos/ticket/583
+template<>
+template<>
+void object::test<4>
+()
+{
     typedef geos::geom::Geometry Geom;
-    typedef std::vector<Geom *> GeomVect;
-    GeomVect *geoms = new GeomVect;
-    geoms->push_back( wktreader.read("POLYGON((0 0,1 0,1 1,0 1,0 0))") );
+    typedef std::vector<Geom*> GeomVect;
+    GeomVect* geoms = new GeomVect;
+    geoms->push_back(wktreader.read("POLYGON((0 0,1 0,1 1,0 1,0 0))"));
     geoms->back()->setSRID(4326);
-    Geom *geom = gf->createGeometryCollection(geoms);
+    Geom* geom = gf->createGeometryCollection(geoms);
     geom->setSRID(4326);
     std::stringstream result_stream;
 
-    wkbwriter.setOutputDimension( 2 );
-    wkbwriter.setByteOrder( 1 );
-    wkbwriter.setIncludeSRID( 1 );
-    wkbwriter.writeHEX( *geom, result_stream );
+    wkbwriter.setOutputDimension(2);
+    wkbwriter.setByteOrder(1);
+    wkbwriter.setIncludeSRID(1);
+    wkbwriter.writeHEX(*geom, result_stream);
     delete geom;
 
     std::string actual = result_stream.str();
-    ensure_equals( actual, "0107000020E6100000010000000103000000010000000500000000000000000000000000000000000000000000000000F03F0000000000000000000000000000F03F000000000000F03F0000000000000000000000000000F03F00000000000000000000000000000000" );
-
-  }
-
-    // 5 - Check WKB representation of empty polygon
-    // See http://trac.osgeo.org/geos/ticket/680
-    template<>
-    template<>
-    void object::test<5>()
-    {
-        geos::geom::Geometry *geom = wktreader.read("POLYGON EMPTY");
-        geom->setSRID(4326);
-        std::stringstream result_stream;
-
-        wkbwriter.setOutputDimension( 2 );
-        wkbwriter.setByteOrder( 1 );
-        wkbwriter.setIncludeSRID( 1 );
-        wkbwriter.writeHEX( *geom, result_stream );
-
-        std::string actual = result_stream.str();
-        ensure_equals( actual, "0103000020E610000000000000" );
-
-        geos::geom::Geometry *geom2 = wkbreader.readHEX(result_stream);
-        assert( geom->equals(geom2) );
-
-        delete geom;
-        delete geom2;
-    }
+    ensure_equals(actual,
+                  "0107000020E6100000010000000103000000010000000500000000000000000000000000000000000000000000000000F03F0000000000000000000000000000F03F000000000000F03F0000000000000000000000000000F03F00000000000000000000000000000000");
+
+}
+
+// 5 - Check WKB representation of empty polygon
+// See http://trac.osgeo.org/geos/ticket/680
+template<>
+template<>
+void object::test<5>
+()
+{
+    geos::geom::Geometry* geom = wktreader.read("POLYGON EMPTY");
+    geom->setSRID(4326);
+    std::stringstream result_stream;
+
+    wkbwriter.setOutputDimension(2);
+    wkbwriter.setByteOrder(1);
+    wkbwriter.setIncludeSRID(1);
+    wkbwriter.writeHEX(*geom, result_stream);
+
+    std::string actual = result_stream.str();
+    ensure_equals(actual, "0103000020E610000000000000");
+
+    geos::geom::Geometry* geom2 = wkbreader.readHEX(result_stream);
+    assert(geom->equals(geom2));
+
+    delete geom;
+    delete geom2;
+}
 
 } // namespace tut
 
diff --git a/tests/unit/io/WKTReaderTest.cpp b/tests/unit/io/WKTReaderTest.cpp
index da307a3..efc46d9 100644
--- a/tests/unit/io/WKTReaderTest.cpp
+++ b/tests/unit/io/WKTReaderTest.cpp
@@ -16,182 +16,188 @@
 #include <string>
 #include <memory>
 
-namespace tut
-{
-	//
-	// Test Group
-	//
-
-	// dummy data, not used
-	struct test_wktreader_data
-	{
-		geos::geom::PrecisionModel pm;
-		geos::geom::GeometryFactory::Ptr gf;
-		geos::io::WKTReader wktreader;
-		geos::io::WKTWriter wktwriter;
-
-		typedef std::unique_ptr<geos::geom::Geometry> GeomPtr;
-
-		test_wktreader_data()
-			:
-			pm(1.0),
-			gf(geos::geom::GeometryFactory::create(&pm)),
-			wktreader(gf.get())
-		{
-            wktwriter.setOutputDimension( 3 );
-        }
-
-	};
+namespace tut {
+//
+// Test Group
+//
 
-	typedef test_group<test_wktreader_data> group;
-	typedef group::object object;
+// dummy data, not used
+struct test_wktreader_data {
+    geos::geom::PrecisionModel pm;
+    geos::geom::GeometryFactory::Ptr gf;
+    geos::io::WKTReader wktreader;
+    geos::io::WKTWriter wktwriter;
 
-	group test_wktreader_group("geos::io::WKTReader");
+    typedef std::unique_ptr<geos::geom::Geometry> GeomPtr;
 
+    test_wktreader_data()
+        :
+        pm(1.0),
+        gf(geos::geom::GeometryFactory::create(&pm)),
+        wktreader(gf.get())
+    {
+        wktwriter.setOutputDimension(3);
+    }
 
-	//
-	// Test Cases
-	//
+};
 
-	// 1 - Read a point, confirm 2D.
-	template<>
-	template<>
-	void object::test<1>()
-	{
-            GeomPtr geom(wktreader.read("POINT(-117 33)"));
-            geos::geom::CoordinateSequence *coords = geom->getCoordinates();
+typedef test_group<test_wktreader_data> group;
+typedef group::object object;
 
-            ensure( coords->getDimension() == 2 );
-            ensure( coords->getX(0) == -117 );
-            ensure( coords->getY(0) == 33 );
-            delete coords;
-    }
+group test_wktreader_group("geos::io::WKTReader");
 
-	// 2 - Read a point, confirm 3D.
-	template<>
-	template<>
-	void object::test<2>()
-	{
-            GeomPtr geom(wktreader.read("POINT(-117 33 10)"));
-            geos::geom::CoordinateSequence *coords = geom->getCoordinates();
-
-            ensure( coords->getDimension() == 3 );
-            ensure( coords->getOrdinate(0,geos::geom::CoordinateSequence::Z) == 10.0 );
-            delete coords;
-    }
 
-	// 3 - Linestring dimension preserved.
-	template<>
-	template<>
-	void object::test<3>()
-	{
-            GeomPtr geom(wktreader.read("LINESTRING(-117 33, -116 34)"));
-            geos::geom::CoordinateSequence *coords = geom->getCoordinates();
+//
+// Test Cases
+//
 
-            ensure( coords->getDimension() == 2 );
+// 1 - Read a point, confirm 2D.
+template<>
+template<>
+void object::test<1>
+()
+{
+    GeomPtr geom(wktreader.read("POINT(-117 33)"));
+    geos::geom::CoordinateSequence* coords = geom->getCoordinates();
+
+    ensure(coords->getDimension() == 2);
+    ensure(coords->getX(0) == -117);
+    ensure(coords->getY(0) == 33);
+    delete coords;
+}
+
+// 2 - Read a point, confirm 3D.
+template<>
+template<>
+void object::test<2>
+()
+{
+    GeomPtr geom(wktreader.read("POINT(-117 33 10)"));
+    geos::geom::CoordinateSequence* coords = geom->getCoordinates();
+
+    ensure(coords->getDimension() == 3);
+    ensure(coords->getOrdinate(0, geos::geom::CoordinateSequence::Z) == 10.0);
+    delete coords;
+}
+
+// 3 - Linestring dimension preserved.
+template<>
+template<>
+void object::test<3>
+()
+{
+    GeomPtr geom(wktreader.read("LINESTRING(-117 33, -116 34)"));
+    geos::geom::CoordinateSequence* coords = geom->getCoordinates();
 
-            delete coords;
-    }
+    ensure(coords->getDimension() == 2);
 
-	// 4 - Ensure we can read ZM geometries, just discarding the M.
-	template<>
-	template<>
-	void object::test<4>()
-	{
-            GeomPtr geom(wktreader.read("LINESTRING ZM (-117 33 2 3, -116 34 4 5)"));
-            geos::geom::CoordinateSequence *coords = geom->getCoordinates();
+    delete coords;
+}
 
-            ensure( coords->getDimension() == 3 );
+// 4 - Ensure we can read ZM geometries, just discarding the M.
+template<>
+template<>
+void object::test<4>
+()
+{
+    GeomPtr geom(wktreader.read("LINESTRING ZM (-117 33 2 3, -116 34 4 5)"));
+    geos::geom::CoordinateSequence* coords = geom->getCoordinates();
 
-            ensure_equals( wktwriter.write(geom.get()),
-                           std::string("LINESTRING Z (-117 33 2, -116 34 4)") );
+    ensure(coords->getDimension() == 3);
 
-            delete coords;
-    }
+    ensure_equals(wktwriter.write(geom.get()),
+                  std::string("LINESTRING Z (-117 33 2, -116 34 4)"));
 
-	// 5 - Check support for mixed case keywords (and old style 3D)
-	template<>
-	template<>
-	void object::test<5>()
-	{
-            GeomPtr geom(wktreader.read("LineString (-117 33 2, -116 34 4)"));
-            ensure_equals( wktwriter.write(geom.get()),
-                           std::string("LINESTRING Z (-117 33 2, -116 34 4)") );
-    }
+    delete coords;
+}
 
-    // 6 - invalid WKT (see http://trac.osgeo.org/geos/ticket/361)
-    template<>
-    template<>
-    void object::test<6>()
-    {
-        GeomPtr geom;
+// 5 - Check support for mixed case keywords (and old style 3D)
+template<>
+template<>
+void object::test<5>
+()
+{
+    GeomPtr geom(wktreader.read("LineString (-117 33 2, -116 34 4)"));
+    ensure_equals(wktwriter.write(geom.get()),
+                  std::string("LINESTRING Z (-117 33 2, -116 34 4)"));
+}
+
+// 6 - invalid WKT (see http://trac.osgeo.org/geos/ticket/361)
+template<>
+template<>
+void object::test<6>
+()
+{
+    GeomPtr geom;
 
-        try {
-            geom.reset(wktreader.read("POLYGON( EMPTY, (1 1,2 2,1 2,1 1))"));
-            ensure( !"Didn't get expected exception" );
-        } catch (const geos::util::IllegalArgumentException& ex) {
-            ensure( "Did get expected exception" );
-            ex.what();
-        } catch (...) {
-            ensure( !"Got unexpected exception" );
-        }
+    try {
+        geom.reset(wktreader.read("POLYGON( EMPTY, (1 1,2 2,1 2,1 1))"));
+        ensure(!"Didn't get expected exception");
     }
+    catch(const geos::util::IllegalArgumentException& ex) {
+        ensure("Did get expected exception");
+        ex.what();
+    }
+    catch(...) {
+        ensure(!"Got unexpected exception");
+    }
+}
 
-    // POINT(0 0) http://trac.osgeo.org/geos/ticket/610
-    template<>
-    template<>
-    void object::test<7>()
-    {
-        GeomPtr geom;
-
-        try
-        {
-            // use FLOATING model
-            namespace ggm = geos::geom;
-            namespace gio = geos::io;
-            ggm::PrecisionModel p_pm(ggm::PrecisionModel::FLOATING);
-            ggm::GeometryFactory::Ptr p_gf = ggm::GeometryFactory::create(&p_pm);
-            gio::WKTReader wktReader(p_gf.get());
-            const std::string str = " POINT (0 0) ";
-            geom.reset(wktReader.read(str)); //HERE IT FAILS
-
-            geos::geom::CoordinateSequence *coords = geom->getCoordinates();
-            ensure_equals(coords->getDimension(), 2U);
-            ensure_distance(coords->getX(0), 0.0, 1e-12);
-            ensure_distance( coords->getY(0), 0.0, 1e-12);
-            delete coords;
-        }
-        catch (const geos::util::IllegalArgumentException& ex)
-        {
-            ensure( "Did get expected exception" );
-            ex.what();
-        }
-        catch (...)
-        {
-            ensure( !"Got unexpected exception" );
-        }
+// POINT(0 0) http://trac.osgeo.org/geos/ticket/610
+template<>
+template<>
+void object::test<7>
+()
+{
+    GeomPtr geom;
+
+    try {
+        // use FLOATING model
+        namespace ggm = geos::geom;
+        namespace gio = geos::io;
+        ggm::PrecisionModel p_pm(ggm::PrecisionModel::FLOATING);
+        ggm::GeometryFactory::Ptr p_gf = ggm::GeometryFactory::create(&p_pm);
+        gio::WKTReader wktReader(p_gf.get());
+        const std::string str = " POINT (0 0) ";
+        geom.reset(wktReader.read(str)); //HERE IT FAILS
+
+        geos::geom::CoordinateSequence* coords = geom->getCoordinates();
+        ensure_equals(coords->getDimension(), 2U);
+        ensure_distance(coords->getX(0), 0.0, 1e-12);
+        ensure_distance(coords->getY(0), 0.0, 1e-12);
+        delete coords;
+    }
+    catch(const geos::util::IllegalArgumentException& ex) {
+        ensure("Did get expected exception");
+        ex.what();
+    }
+    catch(...) {
+        ensure(!"Got unexpected exception");
     }
+}
 
-    // 8 - invalid WKT (see https://trac.osgeo.org/geos/ticket/830)
-    template<>
-    template<>
-    void object::test<8>()
-    {
-        // All of these strings cause an exception during read().
-        std::vector<std::string> wkt;
-        wkt.push_back("MULTILINESTRING(");
-        wkt.push_back("MULTIPOLYGON(");
-        wkt.push_back("MULTIPOLYGON(EMPTY(");
-        wkt.push_back("GEOMETRYCOLLECTION(");
-        wkt.push_back("GEOMETRYCOLLECTION(LINEARRING(");
-        for (size_t i = 0; i < wkt.size(); i++) {
-            try {
-                wktreader.read(wkt[i]);
-                ensure( !"Didn't get expected exception" );
-            } catch (...) {
-                ensure( "Did get expected exception" );
-            }
+// 8 - invalid WKT (see https://trac.osgeo.org/geos/ticket/830)
+template<>
+template<>
+void object::test<8>
+()
+{
+    // All of these strings cause an exception during read().
+    std::vector<std::string> wkt;
+    wkt.push_back("MULTILINESTRING(");
+    wkt.push_back("MULTIPOLYGON(");
+    wkt.push_back("MULTIPOLYGON(EMPTY(");
+    wkt.push_back("GEOMETRYCOLLECTION(");
+    wkt.push_back("GEOMETRYCOLLECTION(LINEARRING(");
+    for(size_t i = 0; i < wkt.size(); i++) {
+        try {
+            wktreader.read(wkt[i]);
+            ensure(!"Didn't get expected exception");
+        }
+        catch(...) {
+            ensure("Did get expected exception");
         }
     }
+}
 
 } // namespace tut
diff --git a/tests/unit/io/WKTWriterTest.cpp b/tests/unit/io/WKTWriterTest.cpp
index 94be2b0..9b88cf4 100644
--- a/tests/unit/io/WKTWriterTest.cpp
+++ b/tests/unit/io/WKTWriterTest.cpp
@@ -14,137 +14,140 @@
 #include <string>
 #include <memory>
 
-namespace tut
-{
-	//
-	// Test Group
-	//
+namespace tut {
+//
+// Test Group
+//
 
-	// dummy data, not used
-	struct test_wktwriter_data
-	{
-		typedef geos::geom::PrecisionModel PrecisionModel;
-		typedef geos::geom::GeometryFactory GeometryFactory;
-		typedef geos::io::WKTReader WKTReader;
-		typedef geos::io::WKTWriter WKTWriter;
-		typedef std::unique_ptr<geos::geom::Geometry> GeomPtr;
+// dummy data, not used
+struct test_wktwriter_data {
+    typedef geos::geom::PrecisionModel PrecisionModel;
+    typedef geos::geom::GeometryFactory GeometryFactory;
+    typedef geos::io::WKTReader WKTReader;
+    typedef geos::io::WKTWriter WKTWriter;
+    typedef std::unique_ptr<geos::geom::Geometry> GeomPtr;
 
-		PrecisionModel pm;
-		GeometryFactory::Ptr gf;
-		WKTReader wktreader;
-		WKTWriter wktwriter;
+    PrecisionModel pm;
+    GeometryFactory::Ptr gf;
+    WKTReader wktreader;
+    WKTWriter wktwriter;
 
-		test_wktwriter_data()
-                :
-                pm(1000.0),
-                gf(GeometryFactory::create(&pm)),
-                wktreader(gf.get())
-            {}
+    test_wktwriter_data()
+        :
+        pm(1000.0),
+        gf(GeometryFactory::create(&pm)),
+        wktreader(gf.get())
+    {}
 
-	};
+};
 
-	typedef test_group<test_wktwriter_data> group;
-	typedef group::object object;
+typedef test_group<test_wktwriter_data> group;
+typedef group::object object;
 
-	group test_wktwriter_group("geos::io::WKTWriter");
+group test_wktwriter_group("geos::io::WKTWriter");
 
 
-	//
-	// Test Cases
-	//
+//
+// Test Cases
+//
 
-	// 1 - Test the trim capability.
-	template<>
-	template<>
-	void object::test<1>()
-	{
-        GeomPtr geom ( wktreader.read("POINT(-117 33)") );
-        std::string  result;
+// 1 - Test the trim capability.
+template<>
+template<>
+void object::test<1>
+()
+{
+    GeomPtr geom(wktreader.read("POINT(-117 33)"));
+    std::string  result;
 
-        wktwriter.setTrim(false);
-        result = wktwriter.write( geom.get() );
+    wktwriter.setTrim(false);
+    result = wktwriter.write(geom.get());
 
-        ensure_equals( result , "POINT (-117.000 33.000)" );
+    ensure_equals(result, "POINT (-117.000 33.000)");
 
-        wktwriter.setTrim(true);
-        result = wktwriter.write( geom.get() );
+    wktwriter.setTrim(true);
+    result = wktwriter.write(geom.get());
 
-        ensure_equals( result , "POINT (-117 33)" );
-    }
+    ensure_equals(result, "POINT (-117 33)");
+}
 
-	// 2 - Test the output precision capability
-	template<>
-	template<>
-	void object::test<2>()
-	{
-        GeomPtr geom ( wktreader.read("POINT(-117.1234567 33.1234567)") );
-        std::string  result;
+// 2 - Test the output precision capability
+template<>
+template<>
+void object::test<2>
+()
+{
+    GeomPtr geom(wktreader.read("POINT(-117.1234567 33.1234567)"));
+    std::string  result;
 
-        wktwriter.setTrim(false);
-        result = wktwriter.write( geom.get() );
+    wktwriter.setTrim(false);
+    result = wktwriter.write(geom.get());
 
-        ensure_equals( result , "POINT (-117.123 33.123)" );
+    ensure_equals(result, "POINT (-117.123 33.123)");
 
-        wktwriter.setRoundingPrecision(2);
-        result = wktwriter.write( geom.get() );
+    wktwriter.setRoundingPrecision(2);
+    result = wktwriter.write(geom.get());
 
-        ensure_equals( result , "POINT (-117.12 33.12)" );
+    ensure_equals(result, "POINT (-117.12 33.12)");
 
-    }
+}
 
-	// 3 - Test 3D generation from a 3D geometry.
-	template<>
-	template<>
-	void object::test<3>()
-	{
-        GeomPtr geom ( wktreader.read("POINT Z (-117 33 120)") );
-        std::string  result;
+// 3 - Test 3D generation from a 3D geometry.
+template<>
+template<>
+void object::test<3>
+()
+{
+    GeomPtr geom(wktreader.read("POINT Z (-117 33 120)"));
+    std::string  result;
 
-        wktwriter.setOutputDimension(3);
-        wktwriter.setTrim( true );
-        wktwriter.setOld3D( false );
+    wktwriter.setOutputDimension(3);
+    wktwriter.setTrim(true);
+    wktwriter.setOld3D(false);
 
-        result = wktwriter.write( geom.get() );
+    result = wktwriter.write(geom.get());
 
-        ensure_equals( result, std::string("POINT Z (-117 33 120)") );
+    ensure_equals(result, std::string("POINT Z (-117 33 120)"));
 
-        wktwriter.setOld3D( true );
-        result = wktwriter.write( geom.get() );
+    wktwriter.setOld3D(true);
+    result = wktwriter.write(geom.get());
 
-        ensure_equals( result, std::string("POINT (-117 33 120)") );
+    ensure_equals(result, std::string("POINT (-117 33 120)"));
 
-    }
+}
 
-	// 4 - Test 2D generation from a 3D geometry.
-	template<>
-	template<>
-	void object::test<4>()
-	{
-        GeomPtr geom ( wktreader.read("POINT(-117 33 120)") );
-        std::string  result;
+// 4 - Test 2D generation from a 3D geometry.
+template<>
+template<>
+void object::test<4>
+()
+{
+    GeomPtr geom(wktreader.read("POINT(-117 33 120)"));
+    std::string  result;
 
-        wktwriter.setOutputDimension(2);
-        wktwriter.setTrim( true );
-        wktwriter.setOld3D( false );
+    wktwriter.setOutputDimension(2);
+    wktwriter.setTrim(true);
+    wktwriter.setOld3D(false);
 
-        result = wktwriter.write( geom.get() );
+    result = wktwriter.write(geom.get());
 
-        ensure_equals( result, std::string("POINT (-117 33)") );
-    }
+    ensure_equals(result, std::string("POINT (-117 33)"));
+}
 
-  // 5 - Test negative number of digits in precision model
-  template<>
-  template<>
-  void object::test<5>()
-  {
+// 5 - Test negative number of digits in precision model
+template<>
+template<>
+void object::test<5>
+()
+{
     PrecisionModel pm3(0.001);
     GeometryFactory::Ptr gf3(GeometryFactory::create(&pm3));
     WKTReader wktreader3(gf3.get());
-    GeomPtr geom ( wktreader3.read("POINT(123456 654321)") );
+    GeomPtr geom(wktreader3.read("POINT(123456 654321)"));
 
-    std::string  result = wktwriter.write( geom.get() );
-    ensure_equals( result, std::string("POINT (123000 654000)") );
-  }
+    std::string  result = wktwriter.write(geom.get());
+    ensure_equals(result, std::string("POINT (123000 654000)"));
+}
 
 } // namespace tut
 
diff --git a/tests/unit/io/WriterTest.cpp b/tests/unit/io/WriterTest.cpp
index 2590f0e..d616e41 100644
--- a/tests/unit/io/WriterTest.cpp
+++ b/tests/unit/io/WriterTest.cpp
@@ -10,76 +10,78 @@
 #include <string>
 #include <memory>
 
-namespace tut
-{
-	//
-	// Test Group
-	//
-
-	// dummy data, not used
-	struct test_writer_data
-	{
-		test_writer_data()
+namespace tut {
+//
+// Test Group
+//
+
+// dummy data, not used
+struct test_writer_data {
+    test_writer_data()
     {
     }
-	};
+};
 
-	typedef test_group<test_writer_data> group;
-	typedef group::object object;
+typedef test_group<test_writer_data> group;
+typedef group::object object;
 
-	group test_writer_group("geos::io::Writer");
+group test_writer_group("geos::io::Writer");
 
 
-	//
-	// Test Cases
-	//
+//
+// Test Cases
+//
 
-	template<>
-	template<>
-	void object::test<1>()
-	{
+template<>
+template<>
+void object::test<1>
+()
+{
     geos::io::Writer writer;
 
     writer.write("Hello ");
     writer.write("World!");
     ensure_equals(writer.toString(), "Hello World!");
-  }
+}
 
-	template<>
-	template<>
-	void object::test<2>()
-	{
+template<>
+template<>
+void object::test<2>
+()
+{
     geos::io::Writer writer;
 
     writer.reserve(512);
     writer.write("Hello ");
     writer.write("World!");
     ensure_equals(writer.toString(), "Hello World!");
-  }
+}
 
-	template<>
-	template<>
-	void object::test<3>()
-	{
+template<>
+template<>
+void object::test<3>
+()
+{
     geos::io::Writer writer;
 
     writer.reserve(1);
     writer.write("Hello ");
     writer.write("World!");
     ensure_equals(writer.toString(), "Hello World!");
-  }
+}
 
-	template<>
-	template<>
-	void object::test<4>()
-	{
+template<>
+template<>
+void object::test<4>
+()
+{
     geos::io::Writer writer;
 
     writer.reserve(512);
     writer.write("Hello World!");
     writer.reserve(1);
     ensure_equals(writer.toString(), "Hello World!");
-  }
+}
 
 } // namespace tut
 
diff --git a/tests/unit/linearref/LengthIndexedLineTest.cpp b/tests/unit/linearref/LengthIndexedLineTest.cpp
index df494aa..61fce59 100644
--- a/tests/unit/linearref/LengthIndexedLineTest.cpp
+++ b/tests/unit/linearref/LengthIndexedLineTest.cpp
@@ -32,30 +32,32 @@ namespace tut {
 typedef unique_ptr<Geometry> GeomPtr;
 static const double TOLERANCE_DIST = 0.001;
 
-struct test_lengthindexedline_data
-{
+struct test_lengthindexedline_data {
     test_lengthindexedline_data()
         : reader(), writer()
     {
-      writer.setTrim(true);
+        writer.setTrim(true);
     }
 
     geos::io::WKTReader reader;
     geos::io::WKTWriter writer;
 
-    void checkExpected(Geometry* result, string const& expected)
+    void
+    checkExpected(Geometry* result, string const& expected)
     {
         GeomPtr subLine(reader.read(expected));
         checkExpected(result, subLine.get());
     }
 
-    void checkExpected(Geometry* result, const Geometry* expected)
+    void
+    checkExpected(Geometry* result, const Geometry* expected)
     {
-      bool isEqual = result->equalsExact(expected, 1.0e-5);
-      ensure_equals("Expect: "+writer.write(expected)+" Obtained: "+writer.write(result), isEqual, true);
+        bool isEqual = result->equalsExact(expected, 1.0e-5);
+        ensure_equals("Expect: " + writer.write(expected) + " Obtained: " + writer.write(result), isEqual, true);
     }
 
-    void runIndicesOfThenExtract(string const& inputStr, string const& subLineStr)
+    void
+    runIndicesOfThenExtract(string const& inputStr, string const& subLineStr)
     {
         GeomPtr input(reader.read(inputStr));
         GeomPtr subLine(reader.read(subLineStr));
@@ -64,25 +66,33 @@ struct test_lengthindexedline_data
         checkExpected(result.get(), subLine.get());
     }
 
-    bool indexOfAfterCheck(Geometry* linearGeom, Coordinate testPt)
+    bool
+    indexOfAfterCheck(Geometry* linearGeom, Coordinate testPt)
     {
         LengthIndexedLine indexedLine(linearGeom);
 
         // check locations are consecutive
         double loc1 = indexedLine.indexOf(testPt);
         double loc2 = indexedLine.indexOfAfter(testPt, loc1);
-        if (loc2 <= loc1) return false;
+        if(loc2 <= loc1) {
+            return false;
+        }
 
         // check extracted points are the same as the input
         Coordinate pt1 = indexedLine.extractPoint(loc1);
         Coordinate pt2 = indexedLine.extractPoint(loc2);
-        if (! pt1.equals2D(testPt)) return false;
-        if (! pt2.equals2D(testPt)) return false;
+        if(! pt1.equals2D(testPt)) {
+            return false;
+        }
+        if(! pt2.equals2D(testPt)) {
+            return false;
+        }
 
         return true;
     }
 
-    void runIndexOfAfterTest(string const& inputStr, string const& testPtWKT)
+    void
+    runIndexOfAfterTest(string const& inputStr, string const& testPtWKT)
     {
         GeomPtr input(reader.read(inputStr));
         GeomPtr testPoint(reader.read(testPtWKT));
@@ -91,8 +101,9 @@ struct test_lengthindexedline_data
         ensure(resultOK);
     }
 
-    void runOffsetTest(string const& inputWKT, string const& testPtWKT,
-                       double offsetDistance, string const& expectedPtWKT)
+    void
+    runOffsetTest(string const& inputWKT, string const& testPtWKT,
+                  double offsetDistance, string const& expectedPtWKT)
     {
         GeomPtr input(reader.read(inputWKT));
         GeomPtr testPoint(reader.read(testPtWKT));
@@ -102,19 +113,22 @@ struct test_lengthindexedline_data
         Coordinate offsetPt = extractOffsetAt(input.get(), *testPt, offsetDistance);
 
         bool isOk = offsetPt.distance(*expectedPt) < TOLERANCE_DIST;
-        if (! isOk)
+        if(! isOk) {
             cout << "Expected = " << *expectedPoint << "  Actual = " << offsetPt << endl;
+        }
         ensure(isOk);
     }
 
-    Coordinate extractOffsetAt(Geometry* linearGeom, Coordinate testPt, double offsetDistance)
+    Coordinate
+    extractOffsetAt(Geometry* linearGeom, Coordinate testPt, double offsetDistance)
     {
         LengthIndexedLine indexedLine(linearGeom);
         double index = indexedLine.indexOf(testPt);
         return indexedLine.extractPoint(index, offsetDistance);
     }
 
-    void checkExtractLine(const char* wkt, double start, double end, const char* expected)
+    void
+    checkExtractLine(const char* wkt, double start, double end, const char* expected)
     {
         string wktstr(wkt);
         GeomPtr linearGeom(reader.read(wktstr));
@@ -124,7 +138,8 @@ struct test_lengthindexedline_data
     }
 
 
-    Geometry* indicesOfThenExtract(Geometry* linearGeom, Geometry* subLine)
+    Geometry*
+    indicesOfThenExtract(Geometry* linearGeom, Geometry* subLine)
     {
         LengthIndexedLine indexedLine(linearGeom);
         double* loc = indexedLine.indicesOf(subLine);
@@ -143,7 +158,8 @@ group test_lengthindexedline_group("geos::linearref::LocationIndexedLine");
 // testML
 template<>
 template<>
-void object::test<1>()
+void object::test<1>
+()
 {
     runIndicesOfThenExtract("MULTILINESTRING ((0 0, 10 10), (20 20, 30 30))",
                             "MULTILINESTRING ((1 1, 10 10), (20 20, 25 25))");
@@ -152,7 +168,8 @@ void object::test<1>()
 // testPartOfSegmentNoVertex
 template<>
 template<>
-void object::test<2>()
+void object::test<2>
+()
 {
     runIndicesOfThenExtract("LINESTRING (0 0, 10 10, 20 20)",
                             "LINESTRING (1 1, 9 9)");
@@ -161,7 +178,8 @@ void object::test<2>()
 // testPartOfSegmentContainingVertex()
 template<>
 template<>
-void object::test<3>()
+void object::test<3>
+()
 {
     runIndicesOfThenExtract("LINESTRING (0 0, 10 10, 20 20)",
                             "LINESTRING (5 5, 10 10, 15 15)");
@@ -175,7 +193,8 @@ void object::test<3>()
 // testPartOfSegmentContainingDuplicateCoords
 template<>
 template<>
-void object::test<4>()
+void object::test<4>
+()
 {
     runIndicesOfThenExtract("LINESTRING (0 0, 10 10, 10 10, 20 20)",
                             "LINESTRING (5 5, 10 10, 10 10, 15 15)");
@@ -189,7 +208,8 @@ void object::test<4>()
 // testLoopWithStartSubLine
 template<>
 template<>
-void object::test<5>()
+void object::test<5>
+()
 {
     runIndicesOfThenExtract("LINESTRING (0 0, 0 10, 10 10, 10 0, 0 0)",
                             "LINESTRING (0 0, 0 10, 10 10)");
@@ -198,7 +218,8 @@ void object::test<5>()
 // testLoopWithEndingSubLine()
 template<>
 template<>
-void object::test<6>()
+void object::test<6>
+()
 {
     runIndicesOfThenExtract("LINESTRING (0 0, 0 10, 10 10, 10 0, 0 0)",
                             "LINESTRING (10 10, 10 0, 0 0)");
@@ -208,7 +229,8 @@ void object::test<6>()
 // testLoopWithIdenticalSubLine()
 template<>
 template<>
-void object::test<7>()
+void object::test<7>
+()
 {
     runIndicesOfThenExtract("LINESTRING (0 0, 0 10, 10 10, 10 0, 0 0)",
                             "LINESTRING (0 0, 0 10, 10 10, 10 0, 0 0)");
@@ -218,7 +240,8 @@ void object::test<7>()
 // testZeroLenSubLineAtStart()
 template<>
 template<>
-void object::test<8>()
+void object::test<8>
+()
 {
     runIndicesOfThenExtract("LINESTRING (0 0, 0 10, 10 10, 10 0, 0 0)",
                             "LINESTRING (0 0, 0 0)");
@@ -228,7 +251,8 @@ void object::test<8>()
 // testZeroLenSubLineAtMidVertex()
 template<>
 template<>
-void object::test<9>()
+void object::test<9>
+()
 {
     runIndicesOfThenExtract("LINESTRING (0 0, 0 10, 10 10, 10 0, 0 0)",
                             "LINESTRING (10 10, 10 10)");
@@ -237,7 +261,8 @@ void object::test<9>()
 // testIndexOfAfterSquare()
 template<>
 template<>
-void object::test<10>()
+void object::test<10>
+()
 {
     runIndexOfAfterTest("LINESTRING (0 0, 0 10, 10 10, 10 0, 0 0)",
                         "POINT (0 0)");
@@ -246,7 +271,8 @@ void object::test<10>()
 // testIndexOfAfterRibbon()
 template<>
 template<>
-void object::test<11>()
+void object::test<11>
+()
 {
     runIndexOfAfterTest("LINESTRING (0 0, 0 60, 50 60, 50 20, -20 20)",
                         "POINT (0 20)");
@@ -255,29 +281,36 @@ void object::test<11>()
 // testOffsetStartPoint()
 template<>
 template<>
-void object::test<12>()
+void object::test<12>
+()
 {
-    runOffsetTest("LINESTRING (0 0, 10 10, 10 10, 20 20)", "POINT(0 0)", 1.0, "POINT (-0.7071067811865475 0.7071067811865475)");
-    runOffsetTest("LINESTRING (0 0, 10 10, 10 10, 20 20)", "POINT(0 0)", -1.0, "POINT (0.7071067811865475 -0.7071067811865475)");
-    runOffsetTest("LINESTRING (0 0, 10 10, 10 10, 20 20)", "POINT(10 10)", 5.0, "POINT (6.464466094067262 13.535533905932738)");
-    runOffsetTest("LINESTRING (0 0, 10 10, 10 10, 20 20)", "POINT(10 10)", -5.0, "POINT (13.535533905932738 6.464466094067262)");
+    runOffsetTest("LINESTRING (0 0, 10 10, 10 10, 20 20)", "POINT(0 0)", 1.0,
+                  "POINT (-0.7071067811865475 0.7071067811865475)");
+    runOffsetTest("LINESTRING (0 0, 10 10, 10 10, 20 20)", "POINT(0 0)", -1.0,
+                  "POINT (0.7071067811865475 -0.7071067811865475)");
+    runOffsetTest("LINESTRING (0 0, 10 10, 10 10, 20 20)", "POINT(10 10)", 5.0,
+                  "POINT (6.464466094067262 13.535533905932738)");
+    runOffsetTest("LINESTRING (0 0, 10 10, 10 10, 20 20)", "POINT(10 10)", -5.0,
+                  "POINT (13.535533905932738 6.464466094067262)");
 }
 
 // testExtractLineBothIndicesAtEndpointXXX()
 template<>
 template<>
-void object::test<13>()
+void object::test<13>
+()
 {
-  checkExtractLine(
-    "MULTILINESTRING ((0 0, 10 0), (20 0, 25 0, 30 0))",
-    -10, 10, "LINESTRING (10 0, 10 0)"
-  );
+    checkExtractLine(
+        "MULTILINESTRING ((0 0, 10 0), (20 0, 25 0, 30 0))",
+        -10, 10, "LINESTRING (10 0, 10 0)"
+    );
 }
 
 
 // testExtractLineBeyondRange()
 template<> template<>
-void object::test<14>()
+void object::test<14>
+()
 {
     checkExtractLine("LINESTRING (0 0, 10 10)", -100, 100, "LINESTRING (0 0, 10 10)");
 }
@@ -285,7 +318,8 @@ void object::test<14>()
 // testExtractLineReverse()
 template<>
 template<>
-void object::test<15>()
+void object::test<15>
+()
 {
     checkExtractLine("LINESTRING (0 0, 10 0)", 9, 1, "LINESTRING (9 0, 1 0)");
 }
@@ -293,7 +327,8 @@ void object::test<15>()
 // testExtractLineReverseMulti()
 template<>
 template<>
-void object::test<16>()
+void object::test<16>
+()
 {
     checkExtractLine("MULTILINESTRING ((0 0, 10 0), (20 0, 25 0, 30 0))",
                      19, 1, "MULTILINESTRING ((29 0, 25 0, 20 0), (10 0, 1 0))");
@@ -302,7 +337,8 @@ void object::test<16>()
 // testExtractLineNegative()
 template<>
 template<>
-void object::test<17>()
+void object::test<17>
+()
 {
     checkExtractLine("LINESTRING (0 0, 10 0)", -9, -1, "LINESTRING (1 0, 9 0)");
 }
@@ -310,7 +346,8 @@ void object::test<17>()
 // testExtractLineNegativeReverse()
 template<>
 template<>
-void object::test<18>()
+void object::test<18>
+()
 {
     checkExtractLine("LINESTRING (0 0, 10 0)", -1, -9, "LINESTRING (9 0, 1 0)");
 }
@@ -318,7 +355,8 @@ void object::test<18>()
 // testExtractLineIndexAtEndpoint()
 template<>
 template<>
-void object::test<19>()
+void object::test<19>
+()
 {
     checkExtractLine("MULTILINESTRING ((0 0, 10 0), (20 0, 25 0, 30 0))",
                      10, -1, "LINESTRING (20 0, 25 0, 29 0)");
@@ -327,7 +365,8 @@ void object::test<19>()
 // testExtractLineBothIndicesAtEndpoint()
 template<>
 template<>
-void object::test<20>()
+void object::test<20>
+()
 {
     checkExtractLine("MULTILINESTRING ((0 0, 10 0), (20 0, 25 0, 30 0))",
                      10, 10, "LINESTRING (10 0, 10 0)");
@@ -336,7 +375,8 @@ void object::test<20>()
 // testExtractLineBothIndicesAtEndpointNegative()
 template<>
 template<>
-void object::test<21>()
+void object::test<21>
+()
 {
     checkExtractLine("MULTILINESTRING ((0 0, 10 0), (20 0, 25 0, 30 0))",
                      -10, 10, "LINESTRING (10 0, 10 0)");
@@ -345,7 +385,8 @@ void object::test<21>()
 // testExtractPointBeyondRange()
 template<>
 template<>
-void object::test<22>()
+void object::test<22>
+()
 {
     GeomPtr linearGeom(reader.read("LINESTRING (0 0, 10 10)"));
     LengthIndexedLine indexedLine(linearGeom.get());
@@ -359,7 +400,8 @@ void object::test<22>()
 // testProjectPointWithDuplicateCoords()
 template<>
 template<>
-void object::test<23>()
+void object::test<23>
+()
 {
     GeomPtr linearGeom(reader.read("LINESTRING (0 0, 10 0, 10 0, 20 0)"));
     LengthIndexedLine indexedLine(linearGeom.get());
@@ -374,7 +416,8 @@ void object::test<23>()
 // testComputeZ()
 template<>
 template<>
-void object::test<24>()
+void object::test<24>
+()
 {
     GeomPtr linearGeom(reader.read("LINESTRING (0 0 0, 10 10 10)"));
     LengthIndexedLine indexedLine(linearGeom.get());
@@ -391,7 +434,8 @@ void object::test<24>()
 // testComputeZNaN()
 template<>
 template<>
-void object::test<25>()
+void object::test<25>
+()
 {
 
     GeomPtr linearGeom(reader.read("LINESTRING (0 0, 10 10 10)"));
@@ -407,13 +451,14 @@ void object::test<25>()
 // testProjectExtractPoint()
 template<>
 template<>
-void object::test<26>()
+void object::test<26>
+()
 {
-  GeomPtr linearGeom(reader.read("MULTILINESTRING ((0 2, 0 0), (-1 1, 1 1))"));
-  LengthIndexedLine indexedLine(linearGeom.get());
-  double index = indexedLine.project(Coordinate(1, 0));
-  Coordinate pt = indexedLine.extractPoint(index);
-  ensure_equals(pt, Coordinate(0, 0));
+    GeomPtr linearGeom(reader.read("MULTILINESTRING ((0 2, 0 0), (-1 1, 1 1))"));
+    LengthIndexedLine indexedLine(linearGeom.get());
+    double index = indexedLine.project(Coordinate(1, 0));
+    Coordinate pt = indexedLine.extractPoint(index);
+    ensure_equals(pt, Coordinate(0, 0));
 }
 
 /**
@@ -423,23 +468,24 @@ void object::test<26>()
  */
 // testExtractLineIndexAtEndpointWithZeroLenComponents()
 template<> template<>
-void object::test<27>()
+void object::test<27>
+()
 {
-  checkExtractLine(
-    "MULTILINESTRING ((0 0, 10 0), (10 0, 10 0), (20 0, 25 0, 30 0))",
-    10, -1, "LINESTRING (20 0, 25 0, 29 0)");
+    checkExtractLine(
+        "MULTILINESTRING ((0 0, 10 0), (10 0, 10 0), (20 0, 25 0, 30 0))",
+        10, -1, "LINESTRING (20 0, 25 0, 29 0)");
 
-  checkExtractLine(
-    "MULTILINESTRING ((0 0, 10 0), (10 0, 10 0), (20 0, 25 0, 30 0))",
-    5, 10, "LINESTRING (5 0, 10 0)");
+    checkExtractLine(
+        "MULTILINESTRING ((0 0, 10 0), (10 0, 10 0), (20 0, 25 0, 30 0))",
+        5, 10, "LINESTRING (5 0, 10 0)");
 
-  checkExtractLine(
-    "MULTILINESTRING ((0 0,10 0),(10 0,10 0),(10 0,10 0),(20 0,25 0,30 0))",
-    10, 10, "LINESTRING (10 0, 10 0)");
+    checkExtractLine(
+        "MULTILINESTRING ((0 0,10 0),(10 0,10 0),(10 0,10 0),(20 0,25 0,30 0))",
+        10, 10, "LINESTRING (10 0, 10 0)");
 
-  checkExtractLine(
-    "MULTILINESTRING((0 0,10 0),(10 0,10 0),(10 0,10 0),(10 0,10 0),(20 0,25 0,30 0))",
-    10, -10, "LINESTRING (10 0, 10 0)");
+    checkExtractLine(
+        "MULTILINESTRING((0 0,10 0),(10 0,10 0),(10 0,10 0),(10 0,10 0),(20 0,25 0,30 0))",
+        10, -10, "LINESTRING (10 0, 10 0)");
 }
 
 
@@ -449,29 +495,31 @@ void object::test<27>()
 #if 0
 template<>
 template<>
-void object::test<28>()
+void object::test<28>
+()
 {
 
-  GeomPtr linearGeom(reader.read(
-"MULTILINESTRING ((0 -2, 0 2),(-2 0, 2 0))"
-));
-  LengthIndexedLine indexedLine(linearGeom.get());
+    GeomPtr linearGeom(reader.read(
+                           "MULTILINESTRING ((0 -2, 0 2),(-2 0, 2 0))"
+                       ));
+    LengthIndexedLine indexedLine(linearGeom.get());
 
-  double projIndex = indexedLine.project(Coordinate(2, 1.9));
-  ensure_equals(projIndex, 8);
-  Coordinate projPt = indexedLine.extractPoint(projIndex);
-  ensure_equals(projPt, Coordinate(2, 0));
+    double projIndex = indexedLine.project(Coordinate(2, 1.9));
+    ensure_equals(projIndex, 8);
+    Coordinate projPt = indexedLine.extractPoint(projIndex);
+    ensure_equals(projPt, Coordinate(2, 0));
 
-  projIndex = indexedLine.project(Coordinate(2, 2.1));
-  ensure_equals(projIndex, 4);
-  projPt = indexedLine.extractPoint(projIndex);
-  ensure_equals(projPt, Coordinate(0, 2));
+    projIndex = indexedLine.project(Coordinate(2, 2.1));
+    ensure_equals(projIndex, 4);
+    projPt = indexedLine.extractPoint(projIndex);
+    ensure_equals(projPt, Coordinate(0, 2));
 }
 #endif
 
 template<>
 template<>
-void object::test<29>()
+void object::test<29>
+()
 {
     GeomPtr linearGeom(reader.read("LINESTRING EMPTY"));
     LengthIndexedLine indexedLine(linearGeom.get());
diff --git a/tests/unit/noding/BasicSegmentStringTest.cpp b/tests/unit/noding/BasicSegmentStringTest.cpp
index e773514..0efb635 100644
--- a/tests/unit/noding/BasicSegmentStringTest.cpp
+++ b/tests/unit/noding/BasicSegmentStringTest.cpp
@@ -11,199 +11,202 @@
 // std
 #include <memory>
 
-namespace tut
-{
-    //
-    // Test Group
-    //
-
-    // Common data used by tests
-    struct test_basicsegmentstring_data
-    {
+namespace tut {
+//
+// Test Group
+//
 
-    	typedef std::unique_ptr<geos::geom::CoordinateSequence> \
-		CoordinateSequenceAutoPtr;
+// Common data used by tests
+struct test_basicsegmentstring_data {
 
-    	typedef std::unique_ptr<geos::noding::BasicSegmentString> \
-		SegmentStringAutoPtr;
+    typedef std::unique_ptr<geos::geom::CoordinateSequence> \
+    CoordinateSequenceAutoPtr;
 
-	const geos::geom::CoordinateSequenceFactory* csFactory;
+    typedef std::unique_ptr<geos::noding::BasicSegmentString> \
+    SegmentStringAutoPtr;
 
-	SegmentStringAutoPtr
-	makeSegmentString(geos::geom::CoordinateSequence* cs, void *d = nullptr)
-	{
-		return SegmentStringAutoPtr(
-			new geos::noding::BasicSegmentString(cs, d)
-			);
-	}
+    const geos::geom::CoordinateSequenceFactory* csFactory;
 
-	test_basicsegmentstring_data()
-		:
-		csFactory(geos::geom::CoordinateArraySequenceFactory::instance())
-	{
-	}
+    SegmentStringAutoPtr
+    makeSegmentString(geos::geom::CoordinateSequence* cs, void* d = nullptr)
+    {
+        return SegmentStringAutoPtr(
+                   new geos::noding::BasicSegmentString(cs, d)
+               );
+    }
 
-	~test_basicsegmentstring_data()
-	{
-	}
+    test_basicsegmentstring_data()
+        :
+        csFactory(geos::geom::CoordinateArraySequenceFactory::instance())
+    {
+    }
 
-    };
+    ~test_basicsegmentstring_data()
+    {
+    }
 
-    typedef test_group<test_basicsegmentstring_data> group;
-    typedef group::object object;
+};
 
-    group test_basicsegmentstring_group("geos::noding::BasicSegmentString");
+typedef test_group<test_basicsegmentstring_data> group;
+typedef group::object object;
 
-    //
-    // Test Cases
-    //
+group test_basicsegmentstring_group("geos::noding::BasicSegmentString");
 
-    // test constructor with 2 equal points
-    template<>
-    template<>
-    void object::test<1>()
-    {
-    	CoordinateSequenceAutoPtr cs(csFactory->create((size_t)0, 2));
+//
+// Test Cases
+//
 
-	ensure(nullptr != cs.get());
+// test constructor with 2 equal points
+template<>
+template<>
+void object::test<1>
+()
+{
+    CoordinateSequenceAutoPtr cs(csFactory->create((size_t)0, 2));
 
-	geos::geom::Coordinate c0(0, 0);
-	geos::geom::Coordinate c1(0, 0);
+    ensure(nullptr != cs.get());
 
-	cs->add(c0);
-	cs->add(c1);
+    geos::geom::Coordinate c0(0, 0);
+    geos::geom::Coordinate c1(0, 0);
 
-	ensure_equals(cs->size(), 2u);
+    cs->add(c0);
+    cs->add(c1);
 
-	SegmentStringAutoPtr ss(makeSegmentString(cs.get()));
-	ensure(nullptr != ss.get());
+    ensure_equals(cs->size(), 2u);
 
-	ensure_equals(ss->size(), 2u);
+    SegmentStringAutoPtr ss(makeSegmentString(cs.get()));
+    ensure(nullptr != ss.get());
 
-	ensure_equals(ss->getData(), (void*)nullptr);
+    ensure_equals(ss->size(), 2u);
 
-	ensure_equals(ss->getCoordinates(), cs.get());
+    ensure_equals(ss->getData(), (void*)nullptr);
 
-	ensure_equals(ss->getCoordinate(0), c0);
+    ensure_equals(ss->getCoordinates(), cs.get());
 
-	ensure_equals(ss->getCoordinate(1), c1);
+    ensure_equals(ss->getCoordinate(0), c0);
 
-	ensure_equals(ss->isClosed(), true);
+    ensure_equals(ss->getCoordinate(1), c1);
 
-	// this would throw an exception
-	bool octant_failed=false;
-	try {
-		ss->getSegmentOctant(0);
-	} catch (...) {
-		octant_failed=true;
-	}
-	ensure(octant_failed);
+    ensure_equals(ss->isClosed(), true);
 
+    // this would throw an exception
+    bool octant_failed = false;
+    try {
+        ss->getSegmentOctant(0);
     }
+    catch(...) {
+        octant_failed = true;
+    }
+    ensure(octant_failed);
 
-    // test constructor with 2 different points
-    template<>
-    template<>
-    void object::test<2>()
-    {
-    	CoordinateSequenceAutoPtr cs(csFactory->create((size_t)0, 2));
+}
 
-	ensure(nullptr != cs.get());
+// test constructor with 2 different points
+template<>
+template<>
+void object::test<2>
+()
+{
+    CoordinateSequenceAutoPtr cs(csFactory->create((size_t)0, 2));
 
-	geos::geom::Coordinate c0(0, 0);
-	geos::geom::Coordinate c1(1, 0);
+    ensure(nullptr != cs.get());
 
-	cs->add(c0);
-	cs->add(c1);
+    geos::geom::Coordinate c0(0, 0);
+    geos::geom::Coordinate c1(1, 0);
 
-	ensure_equals(cs->size(), 2u);
+    cs->add(c0);
+    cs->add(c1);
 
-	SegmentStringAutoPtr ss(makeSegmentString(cs.get()));
-	ensure(nullptr != ss.get());
+    ensure_equals(cs->size(), 2u);
 
-	ensure_equals(ss->size(), 2u);
+    SegmentStringAutoPtr ss(makeSegmentString(cs.get()));
+    ensure(nullptr != ss.get());
 
-	ensure_equals(ss->getData(), (void*)nullptr);
+    ensure_equals(ss->size(), 2u);
 
-	ensure_equals(ss->getCoordinates(), cs.get());
+    ensure_equals(ss->getData(), (void*)nullptr);
 
-	ensure_equals(ss->getCoordinate(0), c0);
+    ensure_equals(ss->getCoordinates(), cs.get());
 
-	ensure_equals(ss->getCoordinate(1), c1);
+    ensure_equals(ss->getCoordinate(0), c0);
 
-	ensure_equals(ss->isClosed(), false);
+    ensure_equals(ss->getCoordinate(1), c1);
 
-	ensure_equals(ss->getSegmentOctant(0), 0);
+    ensure_equals(ss->isClosed(), false);
 
-    }
+    ensure_equals(ss->getSegmentOctant(0), 0);
 
-    // test constructor with 4 different points forming a ring
-    template<>
-    template<>
-    void object::test<3>()
-    {
-    	CoordinateSequenceAutoPtr cs(csFactory->create((size_t)0, 2));
+}
 
-	ensure(nullptr != cs.get());
+// test constructor with 4 different points forming a ring
+template<>
+template<>
+void object::test<3>
+()
+{
+    CoordinateSequenceAutoPtr cs(csFactory->create((size_t)0, 2));
 
-	geos::geom::Coordinate c0(0, 0);
-	geos::geom::Coordinate c1(1, 0);
-	geos::geom::Coordinate c2(1, 1);
+    ensure(nullptr != cs.get());
 
-	cs->add(c0);
-	cs->add(c1);
-	cs->add(c2);
-	cs->add(c0);
+    geos::geom::Coordinate c0(0, 0);
+    geos::geom::Coordinate c1(1, 0);
+    geos::geom::Coordinate c2(1, 1);
 
-	ensure_equals(cs->size(), 4u);
+    cs->add(c0);
+    cs->add(c1);
+    cs->add(c2);
+    cs->add(c0);
 
-	SegmentStringAutoPtr ss(makeSegmentString(cs.get()));
-	ensure(nullptr != ss.get());
+    ensure_equals(cs->size(), 4u);
 
-	ensure_equals(ss->size(), 4u);
+    SegmentStringAutoPtr ss(makeSegmentString(cs.get()));
+    ensure(nullptr != ss.get());
 
-	ensure_equals(ss->getData(), (void*)nullptr);
+    ensure_equals(ss->size(), 4u);
 
-	ensure_equals(ss->getCoordinates(), cs.get());
+    ensure_equals(ss->getData(), (void*)nullptr);
 
-	ensure_equals(ss->getCoordinate(0), c0);
+    ensure_equals(ss->getCoordinates(), cs.get());
 
-	ensure_equals(ss->getCoordinate(1), c1);
+    ensure_equals(ss->getCoordinate(0), c0);
 
-	ensure_equals(ss->getCoordinate(2), c2);
+    ensure_equals(ss->getCoordinate(1), c1);
 
-	ensure_equals(ss->getCoordinate(3), c0);
+    ensure_equals(ss->getCoordinate(2), c2);
 
-	ensure_equals(ss->isClosed(), true);
+    ensure_equals(ss->getCoordinate(3), c0);
 
-	ensure_equals(ss->getSegmentOctant(2), 4);
+    ensure_equals(ss->isClosed(), true);
 
-	ensure_equals(ss->getSegmentOctant(1), 1);
+    ensure_equals(ss->getSegmentOctant(2), 4);
 
-	ensure_equals(ss->getSegmentOctant(0), 0);
+    ensure_equals(ss->getSegmentOctant(1), 1);
 
-    }
+    ensure_equals(ss->getSegmentOctant(0), 0);
+
+}
 
-	// test Octant class
-	template<>
-	template<>
-	void object::test<4>()
-	{
-		geos::geom::Coordinate p0(0, 0);
-		geos::geom::Coordinate p1(5,-5);
-		int octant_rc1 = 0;
-		int octant_rc2 = 0;
-		int testPassed = true;
-		try {
-			octant_rc1 = geos::noding::Octant::octant(p0,p1);
-			octant_rc2 = geos::noding::Octant::octant(&p0,&p1);
-			testPassed = (octant_rc1 == octant_rc2);
-		}
-		catch (...) {
-			testPassed = false;
-		}
-		ensure( 0 != testPassed);
-	}
+// test Octant class
+template<>
+template<>
+void object::test<4>
+()
+{
+    geos::geom::Coordinate p0(0, 0);
+    geos::geom::Coordinate p1(5, -5);
+    int octant_rc1 = 0;
+    int octant_rc2 = 0;
+    int testPassed = true;
+    try {
+        octant_rc1 = geos::noding::Octant::octant(p0, p1);
+        octant_rc2 = geos::noding::Octant::octant(&p0, &p1);
+        testPassed = (octant_rc1 == octant_rc2);
+    }
+    catch(...) {
+        testPassed = false;
+    }
+    ensure(0 != testPassed);
+}
 
 
 } // namespace tut
diff --git a/tests/unit/noding/NodedSegmentStringTest.cpp b/tests/unit/noding/NodedSegmentStringTest.cpp
index 8c17ce1..6886ad0 100644
--- a/tests/unit/noding/NodedSegmentStringTest.cpp
+++ b/tests/unit/noding/NodedSegmentStringTest.cpp
@@ -11,30 +11,28 @@
 // std
 #include <memory>
 
-namespace tut
-{
-    //
-    // Test Group
-    //
+namespace tut {
+//
+// Test Group
+//
 
-    // Common data used by tests
-    struct test_nodedsegmentstring_data
-    {
+// Common data used by tests
+struct test_nodedsegmentstring_data {
 
-        typedef std::unique_ptr<geos::geom::CoordinateSequence> \
-        CoordinateSequenceAutoPtr;
+    typedef std::unique_ptr<geos::geom::CoordinateSequence> \
+    CoordinateSequenceAutoPtr;
 
-        typedef std::unique_ptr<geos::noding::NodedSegmentString> \
-        SegmentStringAutoPtr;
+    typedef std::unique_ptr<geos::noding::NodedSegmentString> \
+    SegmentStringAutoPtr;
 
     const geos::geom::CoordinateSequenceFactory* csFactory;
 
     SegmentStringAutoPtr
-    makeSegmentString(geos::geom::CoordinateSequence* cs, void *d = nullptr)
+    makeSegmentString(geos::geom::CoordinateSequence* cs, void* d = nullptr)
     {
         return SegmentStringAutoPtr(
-            new geos::noding::NodedSegmentString(cs, d)
-            );
+                   new geos::noding::NodedSegmentString(cs, d)
+               );
     }
 
     test_nodedsegmentstring_data()
@@ -47,58 +45,60 @@ namespace tut
     {
     }
 
-    };
+};
 
-    typedef test_group<test_nodedsegmentstring_data> group;
-    typedef group::object object;
+typedef test_group<test_nodedsegmentstring_data> group;
+typedef group::object object;
 
-    group test_nodedsegmentstring_group("geos::noding::NodedSegmentString");
+group test_nodedsegmentstring_group("geos::noding::NodedSegmentString");
 
-    //
-    // Test Cases
-    //
+//
+// Test Cases
+//
 
-    // test constructor with 2 equal points
-    template<>
-    template<>
-    void object::test<1>()
-    {
-        CoordinateSequenceAutoPtr cs(csFactory->create((size_t)0, 2));
+// test constructor with 2 equal points
+template<>
+template<>
+void object::test<1>
+()
+{
+    CoordinateSequenceAutoPtr cs(csFactory->create((size_t)0, 2));
 
-        ensure(nullptr != cs.get());
+    ensure(nullptr != cs.get());
 
-        geos::geom::Coordinate c0(0, 0);
-        geos::geom::Coordinate c1(0, 0);
+    geos::geom::Coordinate c0(0, 0);
+    geos::geom::Coordinate c1(0, 0);
 
-        cs->add(c0);
-        cs->add(c1);
+    cs->add(c0);
+    cs->add(c1);
 
-        ensure_equals(cs->size(), 2u);
+    ensure_equals(cs->size(), 2u);
 
-        SegmentStringAutoPtr ss(makeSegmentString(cs.release()));
-        ensure(nullptr != ss.get());
+    SegmentStringAutoPtr ss(makeSegmentString(cs.release()));
+    ensure(nullptr != ss.get());
 
-        ensure_equals(ss->size(), 2u);
+    ensure_equals(ss->size(), 2u);
 
-        ensure_equals(ss->getData(), (void*)nullptr);
+    ensure_equals(ss->getData(), (void*)nullptr);
 
-        ensure_equals(ss->getCoordinate(0), c0);
+    ensure_equals(ss->getCoordinate(0), c0);
 
-        ensure_equals(ss->getCoordinate(1), c1);
+    ensure_equals(ss->getCoordinate(1), c1);
 
-        ensure_equals(ss->isClosed(), true);
+    ensure_equals(ss->isClosed(), true);
 
-        ensure_equals(ss->getNodeList().size(), 0u);
+    ensure_equals(ss->getNodeList().size(), 0u);
 
-        ensure_equals(ss->getSegmentOctant(0), 0);
-    }
+    ensure_equals(ss->getSegmentOctant(0), 0);
+}
 
-    // test constructor with 2 different points
-    template<>
-    template<>
-    void object::test<2>()
-    {
-        CoordinateSequenceAutoPtr cs(csFactory->create((size_t)0, 2));
+// test constructor with 2 different points
+template<>
+template<>
+void object::test<2>
+()
+{
+    CoordinateSequenceAutoPtr cs(csFactory->create((size_t)0, 2));
 
     ensure(nullptr != cs.get());
 
@@ -126,14 +126,15 @@ namespace tut
     ensure_equals(ss->getSegmentOctant(0), 0);
 
     ensure_equals(ss->getNodeList().size(), 0u);
-    }
+}
 
-    // test constructor with 4 different points forming a ring
-    template<>
-    template<>
-    void object::test<3>()
-    {
-        CoordinateSequenceAutoPtr cs(csFactory->create((size_t)0, 2));
+// test constructor with 4 different points forming a ring
+template<>
+template<>
+void object::test<3>
+()
+{
+    CoordinateSequenceAutoPtr cs(csFactory->create((size_t)0, 2));
 
     ensure(nullptr != cs.get());
 
@@ -172,67 +173,69 @@ namespace tut
     ensure_equals(ss->getSegmentOctant(0), 0);
 
     ensure_equals(ss->getNodeList().size(), 0u);
-    }
+}
 
-    // test Octant class
-    template<>
-    template<>
-    void object::test<4>()
-    {
-        geos::geom::Coordinate p0(0, 0);
-        geos::geom::Coordinate p1(5,-5);
-        int octant_rc1 = 0;
-        int octant_rc2 = 0;
-        int testPassed = true;
-        try {
-            octant_rc1 = geos::noding::Octant::octant(p0,p1);
-            octant_rc2 = geos::noding::Octant::octant(&p0,&p1);
-            testPassed = (octant_rc1 == octant_rc2);
-        }
-        catch (...) {
-            testPassed = false;
-        }
-        ensure( 0 != testPassed);
+// test Octant class
+template<>
+template<>
+void object::test<4>
+()
+{
+    geos::geom::Coordinate p0(0, 0);
+    geos::geom::Coordinate p1(5, -5);
+    int octant_rc1 = 0;
+    int octant_rc2 = 0;
+    int testPassed = true;
+    try {
+        octant_rc1 = geos::noding::Octant::octant(p0, p1);
+        octant_rc2 = geos::noding::Octant::octant(&p0, &p1);
+        testPassed = (octant_rc1 == octant_rc2);
     }
-
-    // test adding intersections
-    template<>
-    template<>
-    void object::test<5>()
-    {
-        geos::geom::Coordinate p0(0, 0);
-        geos::geom::Coordinate p1(10, 0);
+    catch(...) {
+        testPassed = false;
+    }
+    ensure(0 != testPassed);
+}
+
+// test adding intersections
+template<>
+template<>
+void object::test<5>
+()
+{
+    geos::geom::Coordinate p0(0, 0);
+    geos::geom::Coordinate p1(10, 0);
 
 
-        CoordinateSequenceAutoPtr cs(csFactory->create((size_t)0, 2));
-        cs->add(p0);
-        cs->add(p1);
+    CoordinateSequenceAutoPtr cs(csFactory->create((size_t)0, 2));
+    cs->add(p0);
+    cs->add(p1);
 
-        SegmentStringAutoPtr ss(makeSegmentString(cs.release()));
+    SegmentStringAutoPtr ss(makeSegmentString(cs.release()));
 
-        ensure_equals(ss->getNodeList().size(), 0u);
+    ensure_equals(ss->getNodeList().size(), 0u);
 
-        // the intersection is invalid, but SegmentString trusts us
-        ss->addIntersection(p0, 0);
-        ensure_equals(ss->getNodeList().size(), 1u);
+    // the intersection is invalid, but SegmentString trusts us
+    ss->addIntersection(p0, 0);
+    ensure_equals(ss->getNodeList().size(), 1u);
 
-        // This node is already present, so shouldn't be
-        // accepted as a new one
-        ss->addIntersection(p0, 0);
-        ensure_equals(ss->getNodeList().size(), 1u);
+    // This node is already present, so shouldn't be
+    // accepted as a new one
+    ss->addIntersection(p0, 0);
+    ensure_equals(ss->getNodeList().size(), 1u);
 
-        ss->addIntersection(p1, 0);
-        ensure_equals(ss->getNodeList().size(), 2u);
+    ss->addIntersection(p1, 0);
+    ensure_equals(ss->getNodeList().size(), 2u);
 
-        ss->addIntersection(p1, 0);
-        ensure_equals(ss->getNodeList().size(), 2u);
+    ss->addIntersection(p1, 0);
+    ensure_equals(ss->getNodeList().size(), 2u);
 
-        ss->addIntersection(p0, 0);
-        ensure_equals(ss->getNodeList().size(), 2u);
+    ss->addIntersection(p0, 0);
+    ensure_equals(ss->getNodeList().size(), 2u);
 
-    }
+}
 
-    // TODO: test getting noded substrings
+// TODO: test getting noded substrings
 //  template<>
 //  template<>
 //  void object::test<6>()
diff --git a/tests/unit/noding/OrientedCoordinateArray.cpp b/tests/unit/noding/OrientedCoordinateArray.cpp
index fa9c42e..0ff0c61 100644
--- a/tests/unit/noding/OrientedCoordinateArray.cpp
+++ b/tests/unit/noding/OrientedCoordinateArray.cpp
@@ -17,110 +17,115 @@
 using namespace geos::geom;
 using namespace geos::noding;
 
-namespace tut
-{
-    //
-    // Test Group
-    //
-
-    // Common data used by all tests
-    struct test_orientedcoordinatearray_data
-    {
-        typedef geos::geom::GeometryFactory GeometryFactory;
-
-        geos::geom::PrecisionModel pm_;
-        GeometryFactory::Ptr factory_;
-        geos::io::WKTReader reader_;
-
-        typedef std::unique_ptr<CoordinateSequence> CoordSeqPtr;
-        typedef std::unique_ptr<Geometry> GeomPtr;
-
-        test_orientedcoordinatearray_data()
-          : pm_()
-          , factory_(GeometryFactory::create(&pm_))
-          , reader_(factory_.get()) {}
+namespace tut {
+//
+// Test Group
+//
 
-        CoordSeqPtr coords_from_wkt(const char *wkt) {
-          GeomPtr g ( reader_.read(wkt) );
-          CoordSeqPtr cs ( g->getCoordinates() );
-          return cs;
-        }
-    };
+// Common data used by all tests
+struct test_orientedcoordinatearray_data {
+    typedef geos::geom::GeometryFactory GeometryFactory;
 
-    typedef test_group<test_orientedcoordinatearray_data> group;
-    typedef group::object object;
+    geos::geom::PrecisionModel pm_;
+    GeometryFactory::Ptr factory_;
+    geos::io::WKTReader reader_;
 
-    group test_orientedcoordinatearray_group("geos::noding::OrientedCoordinateArray");
+    typedef std::unique_ptr<CoordinateSequence> CoordSeqPtr;
+    typedef std::unique_ptr<Geometry> GeomPtr;
 
-    //
-    // Test Cases
-    //
+    test_orientedcoordinatearray_data()
+        : pm_()
+        , factory_(GeometryFactory::create(&pm_))
+        , reader_(factory_.get()) {}
 
-    // Compare to self, closed
-    template<>
-    template<>
-    void object::test<1>()
+    CoordSeqPtr
+    coords_from_wkt(const char* wkt)
     {
-      const char *coords = "LINESTRING(361600 6126500, 361620 6126560, 361630 6126550, 361620 6126530, 361600 6126500)";
-      CoordSeqPtr cs = coords_from_wkt(coords);
-      OrientedCoordinateArray oca1(*cs);
-      OrientedCoordinateArray oca2(*cs);
-      ensure_equals(oca1.compareTo(oca2), 0);
+        GeomPtr g(reader_.read(wkt));
+        CoordSeqPtr cs(g->getCoordinates());
+        return cs;
     }
+};
 
-    // Compare to reverse of self, closed
-    template<>
-    template<>
-    void object::test<2>()
-    {
-      const char *coords1 = "LINESTRING(361600 6126500, 361620 6126560, 361630 6126550, 361620 6126530, 361600 6126500)";
-      const char *coords2 = "LINESTRING(361600 6126500, 361620 6126530, 361630 6126550, 361620 6126560, 361600 6126500)";
-      CoordSeqPtr cs1 = coords_from_wkt(coords1);
-      OrientedCoordinateArray oca1(*cs1);
-      CoordSeqPtr cs2 = coords_from_wkt(coords2);
-      OrientedCoordinateArray oca2(*cs2);
-      ensure_equals(oca1.compareTo(oca2), 0);
-    }
+typedef test_group<test_orientedcoordinatearray_data> group;
+typedef group::object object;
 
-    // Compare to self, not closed
-    template<>
-    template<>
-    void object::test<3>()
-    {
-      const char *coords = "LINESTRING(361620 6126560, 361630 6126550, 361620 6126530, 361600 6126500)";
-      CoordSeqPtr cs = coords_from_wkt(coords);
-      OrientedCoordinateArray oca1(*cs);
-      OrientedCoordinateArray oca2(*cs);
-      ensure_equals(oca1.compareTo(oca2), 0);
-    }
+group test_orientedcoordinatearray_group("geos::noding::OrientedCoordinateArray");
 
-    // Compare to reverse of self, not closed
-    template<>
-    template<>
-    void object::test<4>()
-    {
-      const char *coords1 = "LINESTRING(361620 6126560, 361630 6126550, 361620 6126530, 361600 6126500)";
-      const char *coords2 = "LINESTRING(361600 6126500, 361620 6126530, 361630 6126550, 361620 6126560)";
-      CoordSeqPtr cs1 = coords_from_wkt(coords1);
-      OrientedCoordinateArray oca1(*cs1);
-      CoordSeqPtr cs2 = coords_from_wkt(coords2);
-      OrientedCoordinateArray oca2(*cs2);
-      ensure_equals(oca1.compareTo(oca2), 0);
-    }
+//
+// Test Cases
+//
 
-    // Compare both ways
-    template<>
-    template<>
-    void object::test<5>()
-    {
-      const char *coords1 = "LINESTRING(0 0, 10 0)";
-      const char *coords2 = "LINESTRING(0 0, 10 0, 11 0)";
-      CoordSeqPtr cs1 = coords_from_wkt(coords1);
-      OrientedCoordinateArray oca1(*cs1);
-      CoordSeqPtr cs2 = coords_from_wkt(coords2);
-      OrientedCoordinateArray oca2(*cs2);
-      ensure_equals(oca1.compareTo(oca2), -1);
-      ensure_equals(oca2.compareTo(oca1), 1);
-    }
+// Compare to self, closed
+template<>
+template<>
+void object::test<1>
+()
+{
+    const char* coords = "LINESTRING(361600 6126500, 361620 6126560, 361630 6126550, 361620 6126530, 361600 6126500)";
+    CoordSeqPtr cs = coords_from_wkt(coords);
+    OrientedCoordinateArray oca1(*cs);
+    OrientedCoordinateArray oca2(*cs);
+    ensure_equals(oca1.compareTo(oca2), 0);
+}
+
+// Compare to reverse of self, closed
+template<>
+template<>
+void object::test<2>
+()
+{
+    const char* coords1 = "LINESTRING(361600 6126500, 361620 6126560, 361630 6126550, 361620 6126530, 361600 6126500)";
+    const char* coords2 = "LINESTRING(361600 6126500, 361620 6126530, 361630 6126550, 361620 6126560, 361600 6126500)";
+    CoordSeqPtr cs1 = coords_from_wkt(coords1);
+    OrientedCoordinateArray oca1(*cs1);
+    CoordSeqPtr cs2 = coords_from_wkt(coords2);
+    OrientedCoordinateArray oca2(*cs2);
+    ensure_equals(oca1.compareTo(oca2), 0);
+}
+
+// Compare to self, not closed
+template<>
+template<>
+void object::test<3>
+()
+{
+    const char* coords = "LINESTRING(361620 6126560, 361630 6126550, 361620 6126530, 361600 6126500)";
+    CoordSeqPtr cs = coords_from_wkt(coords);
+    OrientedCoordinateArray oca1(*cs);
+    OrientedCoordinateArray oca2(*cs);
+    ensure_equals(oca1.compareTo(oca2), 0);
+}
+
+// Compare to reverse of self, not closed
+template<>
+template<>
+void object::test<4>
+()
+{
+    const char* coords1 = "LINESTRING(361620 6126560, 361630 6126550, 361620 6126530, 361600 6126500)";
+    const char* coords2 = "LINESTRING(361600 6126500, 361620 6126530, 361630 6126550, 361620 6126560)";
+    CoordSeqPtr cs1 = coords_from_wkt(coords1);
+    OrientedCoordinateArray oca1(*cs1);
+    CoordSeqPtr cs2 = coords_from_wkt(coords2);
+    OrientedCoordinateArray oca2(*cs2);
+    ensure_equals(oca1.compareTo(oca2), 0);
+}
+
+// Compare both ways
+template<>
+template<>
+void object::test<5>
+()
+{
+    const char* coords1 = "LINESTRING(0 0, 10 0)";
+    const char* coords2 = "LINESTRING(0 0, 10 0, 11 0)";
+    CoordSeqPtr cs1 = coords_from_wkt(coords1);
+    OrientedCoordinateArray oca1(*cs1);
+    CoordSeqPtr cs2 = coords_from_wkt(coords2);
+    OrientedCoordinateArray oca2(*cs2);
+    ensure_equals(oca1.compareTo(oca2), -1);
+    ensure_equals(oca2.compareTo(oca1), 1);
+}
 
 } // namespace tut
diff --git a/tests/unit/noding/SegmentNodeTest.cpp b/tests/unit/noding/SegmentNodeTest.cpp
index b9a87d8..6459055 100644
--- a/tests/unit/noding/SegmentNodeTest.cpp
+++ b/tests/unit/noding/SegmentNodeTest.cpp
@@ -11,211 +11,213 @@
 // std
 #include <memory>
 
-namespace tut
-{
-    //
-    // Test Group
-    //
-
-    // Common data used by all tests
-    struct test_segmentnode_data
-    {
+namespace tut {
+//
+// Test Group
+//
 
-    	typedef std::unique_ptr<geos::geom::CoordinateSequence>
-            CoordSeqPtr;
+// Common data used by all tests
+struct test_segmentnode_data {
 
-    	typedef std::unique_ptr<geos::noding::SegmentString>
-            SegmentStringPtr;
+    typedef std::unique_ptr<geos::geom::CoordinateSequence>
+    CoordSeqPtr;
 
-        const geos::geom::CoordinateSequenceFactory* factory_;
+    typedef std::unique_ptr<geos::noding::SegmentString>
+    SegmentStringPtr;
 
-        test_segmentnode_data()
-            : factory_(geos::geom::CoordinateArraySequenceFactory::instance())
-	    {}
-    };
+    const geos::geom::CoordinateSequenceFactory* factory_;
 
-    typedef test_group<test_segmentnode_data> group;
-    typedef group::object object;
+    test_segmentnode_data()
+        : factory_(geos::geom::CoordinateArraySequenceFactory::instance())
+    {}
+};
 
-    group test_segmentnode_group("geos::noding::SegmentNode");
+typedef test_group<test_segmentnode_data> group;
+typedef group::object object;
 
-    //
-    // Test Cases
-    //
+group test_segmentnode_group("geos::noding::SegmentNode");
 
-    // Test of overriden constructor
-    template<>
-    template<>
-    void object::test<1>()
-    {
-        using geos::geom::Coordinate;
-        using geos::noding::NodedSegmentString;
-        using geos::noding::SegmentNode;
+//
+// Test Cases
+//
 
-        // Create coordinates sequence
-        const size_t coords_size = 2;
-        CoordSeqPtr cs( factory_->create((size_t)0, coords_size) );
+// Test of overriden constructor
+template<>
+template<>
+void object::test<1>
+()
+{
+    using geos::geom::Coordinate;
+    using geos::noding::NodedSegmentString;
+    using geos::noding::SegmentNode;
 
-        ensure( nullptr != cs.get() );
+    // Create coordinates sequence
+    const size_t coords_size = 2;
+    CoordSeqPtr cs(factory_->create((size_t)0, coords_size));
 
-        Coordinate c0(0, 0);
-        Coordinate c1(3, 3);
-        cs->add(c0);
-        cs->add(c1);
+    ensure(nullptr != cs.get());
 
-        ensure_equals( cs->size(), coords_size );
+    Coordinate c0(0, 0);
+    Coordinate c1(3, 3);
+    cs->add(c0);
+    cs->add(c1);
 
-        // Create SegmentString instance
+    ensure_equals(cs->size(), coords_size);
 
-        NodedSegmentString segment(cs.release(), nullptr);
+    // Create SegmentString instance
 
-        ensure_equals( segment.size(), coords_size );
+    NodedSegmentString segment(cs.release(), nullptr);
 
-        // Construct a node on the given NodedSegmentString
-        {
-            const size_t segment_index = 0;
-            SegmentNode node( segment, Coordinate(3,3), segment_index,
-                              segment.getSegmentOctant(segment_index) );
+    ensure_equals(segment.size(), coords_size);
 
-            ensure_equals( node.segmentIndex, segment_index );
+    // Construct a node on the given NodedSegmentString
+    {
+        const size_t segment_index = 0;
+        SegmentNode node(segment, Coordinate(3, 3), segment_index,
+                         segment.getSegmentOctant(segment_index));
 
-            // only first endpoint is considered interior
-            ensure( node.isInterior() );
+        ensure_equals(node.segmentIndex, segment_index);
 
-            //
-            // TODO - mloskot
-            //  1. What's the purpose of isEndPoint() and how to test it?
-            //  2. Add new test cases
-            //
+        // only first endpoint is considered interior
+        ensure(node.isInterior());
 
-        }
+        //
+        // TODO - mloskot
+        //  1. What's the purpose of isEndPoint() and how to test it?
+        //  2. Add new test cases
+        //
 
     }
 
-    template<>
-    template<>
-    void object::test<2>()
-    {
-        using geos::geom::Coordinate;
-        using geos::noding::NodedSegmentString;
-        using geos::noding::SegmentNode;
+}
 
-        // Create coordinates sequence
-        const size_t coords_size = 2;
-        CoordSeqPtr cs( factory_->create((size_t)0, coords_size) );
+template<>
+template<>
+void object::test<2>
+()
+{
+    using geos::geom::Coordinate;
+    using geos::noding::NodedSegmentString;
+    using geos::noding::SegmentNode;
 
-        ensure( nullptr != cs.get() );
+    // Create coordinates sequence
+    const size_t coords_size = 2;
+    CoordSeqPtr cs(factory_->create((size_t)0, coords_size));
 
-        Coordinate c0(0, 0);
-        Coordinate c1(3, 3);
-        cs->add(c0);
-        cs->add(c1);
+    ensure(nullptr != cs.get());
 
-        ensure_equals( cs->size(), coords_size );
+    Coordinate c0(0, 0);
+    Coordinate c1(3, 3);
+    cs->add(c0);
+    cs->add(c1);
 
-        // Create SegmentString instance
+    ensure_equals(cs->size(), coords_size);
 
-        NodedSegmentString segment(cs.release(), nullptr);
+    // Create SegmentString instance
 
-        ensure_equals( segment.size(), coords_size );
+    NodedSegmentString segment(cs.release(), nullptr);
 
-        // Construct an interior node on the given NodedSegmentString
-        {
-            const size_t segment_index = 0;
-            SegmentNode node( segment, Coordinate(0,0), segment_index,
-                              segment.getSegmentOctant(segment_index) );
+    ensure_equals(segment.size(), coords_size);
 
-            ensure_equals( node.segmentIndex, segment_index );
+    // Construct an interior node on the given NodedSegmentString
+    {
+        const size_t segment_index = 0;
+        SegmentNode node(segment, Coordinate(0, 0), segment_index,
+                         segment.getSegmentOctant(segment_index));
 
-            // on first endpoint ...
-            ensure( ! node.isInterior() );
+        ensure_equals(node.segmentIndex, segment_index);
 
-        }
+        // on first endpoint ...
+        ensure(! node.isInterior());
 
     }
 
-    template<>
-    template<>
-    void object::test<3>()
-    {
-        using geos::geom::Coordinate;
-        using geos::noding::NodedSegmentString;
-        using geos::noding::SegmentNode;
+}
 
-        // Create coordinates sequence
-        const size_t coords_size = 2;
-        CoordSeqPtr cs( factory_->create((size_t)0, coords_size) );
+template<>
+template<>
+void object::test<3>
+()
+{
+    using geos::geom::Coordinate;
+    using geos::noding::NodedSegmentString;
+    using geos::noding::SegmentNode;
 
-        ensure( nullptr != cs.get() );
+    // Create coordinates sequence
+    const size_t coords_size = 2;
+    CoordSeqPtr cs(factory_->create((size_t)0, coords_size));
 
-        Coordinate c0(0, 0);
-        Coordinate c1(3, 3);
-        cs->add(c0);
-        cs->add(c1);
+    ensure(nullptr != cs.get());
 
-        ensure_equals( cs->size(), coords_size );
+    Coordinate c0(0, 0);
+    Coordinate c1(3, 3);
+    cs->add(c0);
+    cs->add(c1);
 
-        // Create SegmentString instance
+    ensure_equals(cs->size(), coords_size);
 
-        NodedSegmentString segment(cs.release(), nullptr);
+    // Create SegmentString instance
 
-        ensure_equals( segment.size(), coords_size );
+    NodedSegmentString segment(cs.release(), nullptr);
 
-        // Construct an interior node on the given NodedSegmentString
-        {
-            const size_t segment_index = 0;
-            SegmentNode node( segment, Coordinate(2,2), segment_index,
-                              segment.getSegmentOctant(segment_index) );
+    ensure_equals(segment.size(), coords_size);
 
-            ensure_equals( node.segmentIndex, segment_index );
+    // Construct an interior node on the given NodedSegmentString
+    {
+        const size_t segment_index = 0;
+        SegmentNode node(segment, Coordinate(2, 2), segment_index,
+                         segment.getSegmentOctant(segment_index));
 
-            // on first endpoint ...
-            ensure( node.isInterior() );
+        ensure_equals(node.segmentIndex, segment_index);
 
-        }
+        // on first endpoint ...
+        ensure(node.isInterior());
 
     }
 
-    template<>
-    template<>
-    void object::test<4>()
-    {
-        using geos::geom::Coordinate;
-        using geos::noding::NodedSegmentString;
-        using geos::noding::SegmentNode;
+}
 
-        // Create coordinates sequence
-        const size_t coords_size = 2;
-        CoordSeqPtr cs( factory_->create((size_t)0, coords_size) );
+template<>
+template<>
+void object::test<4>
+()
+{
+    using geos::geom::Coordinate;
+    using geos::noding::NodedSegmentString;
+    using geos::noding::SegmentNode;
 
-        ensure( nullptr != cs.get() );
+    // Create coordinates sequence
+    const size_t coords_size = 2;
+    CoordSeqPtr cs(factory_->create((size_t)0, coords_size));
 
-        Coordinate c0(0, 0);
-        Coordinate c1(3, 3);
-        cs->add(c0);
-        cs->add(c1);
+    ensure(nullptr != cs.get());
 
-        ensure_equals( cs->size(), coords_size );
+    Coordinate c0(0, 0);
+    Coordinate c1(3, 3);
+    cs->add(c0);
+    cs->add(c1);
 
-        // Create SegmentString instance
+    ensure_equals(cs->size(), coords_size);
 
-        NodedSegmentString segment(cs.release(), nullptr);
+    // Create SegmentString instance
 
-        ensure_equals( segment.size(), coords_size );
+    NodedSegmentString segment(cs.release(), nullptr);
 
-        // Construct a node that doesn't even intersect !!
-        {
-            const size_t segment_index = 0;
-            SegmentNode node( segment, Coordinate(1,2), segment_index,
-                              segment.getSegmentOctant(segment_index) );
+    ensure_equals(segment.size(), coords_size);
 
-            ensure_equals( node.segmentIndex, segment_index );
+    // Construct a node that doesn't even intersect !!
+    {
+        const size_t segment_index = 0;
+        SegmentNode node(segment, Coordinate(1, 2), segment_index,
+                         segment.getSegmentOctant(segment_index));
 
-            // on first endpoint ...
-            ensure( node.isInterior() );
+        ensure_equals(node.segmentIndex, segment_index);
 
-        }
+        // on first endpoint ...
+        ensure(node.isInterior());
 
     }
 
+}
+
 } // namespace tut
diff --git a/tests/unit/noding/SegmentPointComparatorTest.cpp b/tests/unit/noding/SegmentPointComparatorTest.cpp
index 9fb1f06..6c9af91 100644
--- a/tests/unit/noding/SegmentPointComparatorTest.cpp
+++ b/tests/unit/noding/SegmentPointComparatorTest.cpp
@@ -18,89 +18,92 @@
 // std
 #include <memory>
 
-namespace tut
-{
-    //
-    // Test Group
-    //
+namespace tut {
+//
+// Test Group
+//
 
-    // Common data used by tests
-    struct test_segmentpointcomparator_data
-    {
+// Common data used by tests
+struct test_segmentpointcomparator_data {
 
-        typedef std::unique_ptr<geos::geom::CoordinateSequence>
-            CoordinateSequenceAutoPtr;
+    typedef std::unique_ptr<geos::geom::CoordinateSequence>
+    CoordinateSequenceAutoPtr;
 
-        typedef std::unique_ptr<geos::noding::SegmentString>
-            SegmentStringAutoPtr;
+    typedef std::unique_ptr<geos::noding::SegmentString>
+    SegmentStringAutoPtr;
 
-        typedef geos::geom::Coordinate Coordinate;
-        typedef geos::geom::LineSegment LineSegment;
-        typedef geos::geom::PrecisionModel PrecisionModel;
+    typedef geos::geom::Coordinate Coordinate;
+    typedef geos::geom::LineSegment LineSegment;
+    typedef geos::geom::PrecisionModel PrecisionModel;
 
-        PrecisionModel pm;
+    PrecisionModel pm;
 
-        test_segmentpointcomparator_data()
-            : pm(1.0)
-        {}
+    test_segmentpointcomparator_data()
+        : pm(1.0)
+    {}
 
-        void checkNodePosition(int octant, double x0, double y0,
-                               double x1, double y1, int
-                               expectedPositionValue)
-        {
-            using geos::noding::SegmentPointComparator;
+    void
+    checkNodePosition(int octant, double x0, double y0,
+                      double x1, double y1, int
+                      expectedPositionValue)
+    {
+        using geos::noding::SegmentPointComparator;
 
-            int posValue = SegmentPointComparator::compare(octant,
-                Coordinate(x0, y0),
-                Coordinate(x1, y1)
-              );
-            ensure( posValue == expectedPositionValue );
-        }
+        int posValue = SegmentPointComparator::compare(octant,
+                       Coordinate(x0, y0),
+                       Coordinate(x1, y1)
+                                                      );
+        ensure(posValue == expectedPositionValue);
+    }
 
-        void checkNodePosition(const LineSegment& seg, const Coordinate& p0,
-                               const Coordinate& p1, int expectedPositionValue)
-        {
-            using geos::noding::Octant;
-            using geos::noding::SegmentPointComparator;
+    void
+    checkNodePosition(const LineSegment& seg, const Coordinate& p0,
+                      const Coordinate& p1, int expectedPositionValue)
+    {
+        using geos::noding::Octant;
+        using geos::noding::SegmentPointComparator;
 
-            int octant = Octant::octant(seg.p0, seg.p1);
-            int posValue = SegmentPointComparator::compare(octant, p0, p1);
+        int octant = Octant::octant(seg.p0, seg.p1);
+        int posValue = SegmentPointComparator::compare(octant, p0, p1);
 
-            ensure( posValue == expectedPositionValue );
-        }
+        ensure(posValue == expectedPositionValue);
+    }
 
-        Coordinate computePoint(const LineSegment& seg, double dist)
-        {
-          double dx = seg.p1.x - seg.p0.x;
-          double dy = seg.p1.y - seg.p0.y;
-          double len = seg.getLength();
-          Coordinate pt(dist * dx / len, dist * dy / len);
-          pm.makePrecise(pt);
-          return pt;
-        }
+    Coordinate
+    computePoint(const LineSegment& seg, double dist)
+    {
+        double dx = seg.p1.x - seg.p0.x;
+        double dy = seg.p1.y - seg.p0.y;
+        double len = seg.getLength();
+        Coordinate pt(dist * dx / len, dist * dy / len);
+        pm.makePrecise(pt);
+        return pt;
+    }
 
-        void checkPointsAtDistance(const LineSegment& seg,
-                                   double dist0, double dist1)
-        {
-          using geos::geom::Coordinate;
-          Coordinate p0 = computePoint(seg, dist0);
-          Coordinate p1 = computePoint(seg, dist1);
-          if (p0.equals(p1)) {
+    void
+    checkPointsAtDistance(const LineSegment& seg,
+                          double dist0, double dist1)
+    {
+        using geos::geom::Coordinate;
+        Coordinate p0 = computePoint(seg, dist0);
+        Coordinate p1 = computePoint(seg, dist1);
+        if(p0.equals(p1)) {
             checkNodePosition(seg, p0, p1, 0);
-          }
-          else {
+        }
+        else {
             checkNodePosition(seg, p0, p1, -1);
             checkNodePosition(seg, p1, p0, 1);
-          }
         }
+    }
 
-        void checkSegment(double x, double y)
-        {
-          Coordinate seg0(0, 0);
-          Coordinate seg1(x, y);
-          LineSegment seg(seg0, seg1);
+    void
+    checkSegment(double x, double y)
+    {
+        Coordinate seg0(0, 0);
+        Coordinate seg1(x, y);
+        LineSegment seg(seg0, seg1);
 
-          for (int i = 0; i < 4; i++) {
+        for(int i = 0; i < 4; i++) {
             double dist = i;
 
             double gridSize = 1 / pm.getScale();
@@ -109,73 +112,78 @@ namespace tut
             checkPointsAtDistance(seg, dist, dist + 2.0 * gridSize);
             checkPointsAtDistance(seg, dist, dist + 3.0 * gridSize);
             checkPointsAtDistance(seg, dist, dist + 4.0 * gridSize);
-          }
         }
+    }
 
 
-    };
-
-    typedef test_group<test_segmentpointcomparator_data> group;
-    typedef group::object object;
-
-    group test_segmentpointcomparator_group("geos::noding::SegmentPointComparator");
-
-    //
-    // Test Cases
-    //
+};
 
-    // testOctant0 (from simple unit test)
-    template<>
-    template<>
-    void object::test<1>()
-    {
-        checkNodePosition(0, 1, 1, 2, 2, -1);
-        checkNodePosition(0, 1, 0, 1, 1, -1);
-    }
-
-    // testQuadrant0
-    template<>
-    template<>
-    void object::test<2>()
-    {
-        checkSegment(100, 0);
-        checkSegment(100, 50);
-        checkSegment(100, 100);
-        checkSegment(100, 150);
-        checkSegment(0, 100);
-    }
+typedef test_group<test_segmentpointcomparator_data> group;
+typedef group::object object;
 
-    // testQuadrant4
-    template<>
-    template<>
-    void object::test<3>()
-    {
-      checkSegment(100, -50);
-      checkSegment(100, -100);
-      checkSegment(100, -150);
-      checkSegment(0, -100);
-    }
+group test_segmentpointcomparator_group("geos::noding::SegmentPointComparator");
 
-    // testQuadrant1
-    template<>
-    template<>
-    void object::test<4>()
-    {
-      checkSegment(-100, 0);
-      checkSegment(-100, 50);
-      checkSegment(-100, 100);
-      checkSegment(-100, 150);
-    }
+//
+// Test Cases
+//
 
-    // testQuadrant2
-    template<>
-    template<>
-    void object::test<5>()
-    {
-      checkSegment(-100, 0);
-      checkSegment(-100, -50);
-      checkSegment(-100, -100);
-      checkSegment(-100, -150);
-    }
+// testOctant0 (from simple unit test)
+template<>
+template<>
+void object::test<1>
+()
+{
+    checkNodePosition(0, 1, 1, 2, 2, -1);
+    checkNodePosition(0, 1, 0, 1, 1, -1);
+}
+
+// testQuadrant0
+template<>
+template<>
+void object::test<2>
+()
+{
+    checkSegment(100, 0);
+    checkSegment(100, 50);
+    checkSegment(100, 100);
+    checkSegment(100, 150);
+    checkSegment(0, 100);
+}
+
+// testQuadrant4
+template<>
+template<>
+void object::test<3>
+()
+{
+    checkSegment(100, -50);
+    checkSegment(100, -100);
+    checkSegment(100, -150);
+    checkSegment(0, -100);
+}
+
+// testQuadrant1
+template<>
+template<>
+void object::test<4>
+()
+{
+    checkSegment(-100, 0);
+    checkSegment(-100, 50);
+    checkSegment(-100, 100);
+    checkSegment(-100, 150);
+}
+
+// testQuadrant2
+template<>
+template<>
+void object::test<5>
+()
+{
+    checkSegment(-100, 0);
+    checkSegment(-100, -50);
+    checkSegment(-100, -100);
+    checkSegment(-100, -150);
+}
 
 } // namespace tut
diff --git a/tests/unit/noding/snapround/HotPixelTest.cpp b/tests/unit/noding/snapround/HotPixelTest.cpp
index 9881577..e904bb9 100644
--- a/tests/unit/noding/snapround/HotPixelTest.cpp
+++ b/tests/unit/noding/snapround/HotPixelTest.cpp
@@ -11,15 +11,13 @@
 // std
 #include <memory>
 
-namespace tut
-{
-  //
-  // Test Group
-  //
+namespace tut {
+//
+// Test Group
+//
 
-  // Common data used by all tests
-  struct test_hotpixel_data
-  {
+// Common data used by all tests
+struct test_hotpixel_data {
 
     typedef geos::geom::Coordinate Coordinate;
     typedef geos::geom::Envelope Envelope;
@@ -28,22 +26,23 @@ namespace tut
     typedef geos::noding::snapround::HotPixel HotPixel;
 
     test_hotpixel_data() {}
-  };
+};
 
-  typedef test_group<test_hotpixel_data> group;
-  typedef group::object object;
+typedef test_group<test_hotpixel_data> group;
+typedef group::object object;
 
-  group test_hotpixel_group("geos::noding::snapround::HotPixel");
+group test_hotpixel_group("geos::noding::snapround::HotPixel");
 
-  //
-  // Test Cases
-  //
+//
+// Test Cases
+//
 
-  // Test with scaleFactor=1
-  template<>
-  template<>
-  void object::test<1>()
-  {
+// Test with scaleFactor=1
+template<>
+template<>
+void object::test<1>
+()
+{
 
     LineIntersector li;
     Coordinate pt(10, 10);
@@ -56,22 +55,23 @@ namespace tut
 
     Coordinate p0(0, 10);
     Coordinate p1(20, 10);
-    ensure( "hp.intersects 0 10, 20 10", hp.intersects(p0, p1) );
+    ensure("hp.intersects 0 10, 20 10", hp.intersects(p0, p1));
 
     p1.y = 11; // intersection point within 0.75 distance
-    ensure( "hp.intersects(0 10, 20 11)", hp.intersects(p0, p1));
+    ensure("hp.intersects(0 10, 20 11)", hp.intersects(p0, p1));
 
     p1.y = 20;
-    ensure_not( "!hp.intersects(0 10, 20 20)", hp.intersects(p0, p1));
+    ensure_not("!hp.intersects(0 10, 20 20)", hp.intersects(p0, p1));
 
-  }
+}
 
-  // Test with scaleFactor=10
-  // See http://trac.osgeo.org/geos/ticket/498
-  template<>
-  template<>
-  void object::test<2>()
-  {
+// Test with scaleFactor=10
+// See http://trac.osgeo.org/geos/ticket/498
+template<>
+template<>
+void object::test<2>
+()
+{
 
     LineIntersector li;
     Coordinate pt(10, 10);
@@ -84,34 +84,35 @@ namespace tut
 
     Coordinate p0(0, 10);
     Coordinate p1(20, 10);
-    ensure( "hp.intersects 0 10, 20 10", hp.intersects(p0, p1) );
+    ensure("hp.intersects 0 10, 20 10", hp.intersects(p0, p1));
 
     p1.y = 11; // intersection point not within 0.075 distance
-    ensure_not( "hp.intersects(0 10, 20 11)", hp.intersects(p0, p1));
+    ensure_not("hp.intersects(0 10, 20 11)", hp.intersects(p0, p1));
 
-  }
+}
 
-  // Test intersects
-  // See http://trac.osgeo.org/geos/ticket/635
-  template<>
-  template<>
-  void object::test<3>()
-  {
+// Test intersects
+// See http://trac.osgeo.org/geos/ticket/635
+template<>
+template<>
+void object::test<3>
+()
+{
 
     double scale = 1.0;
-    Coordinate p1(0,0);
-    Coordinate p2(3,2);
-    Coordinate p3(1,1);
+    Coordinate p1(0, 0);
+    Coordinate p2(3, 2);
+    Coordinate p3(1, 1);
 
     PrecisionModel pm(scale);
     LineIntersector li(&pm);
     HotPixel hp(p3, scale, li);
 
-    ensure(hp.intersects(p1,p2));
+    ensure(hp.intersects(p1, p2));
 
-  }
+}
 
-  // TODO: test addSnappedNode !
+// TODO: test addSnappedNode !
 
 
 } // namespace tut
diff --git a/tests/unit/noding/snapround/MCIndexSnapRounderTest.cpp b/tests/unit/noding/snapround/MCIndexSnapRounderTest.cpp
index 6edc913..d021c8d 100644
--- a/tests/unit/noding/snapround/MCIndexSnapRounderTest.cpp
+++ b/tests/unit/noding/snapround/MCIndexSnapRounderTest.cpp
@@ -27,122 +27,128 @@
 #include <iostream>
 
 
-namespace tut
-{
-    //
-    // Test Group
-    //
+namespace tut {
+//
+// Test Group
+//
 
-    // Common data used by all tests
-    struct test_mcidxsnprndr_data
-    {
+// Common data used by all tests
+struct test_mcidxsnprndr_data {
+
+    typedef geos::noding::SegmentString SegmentString;
+    typedef geos::noding::NodedSegmentString NodedSegmentString;
+    typedef geos::noding::snapround::MCIndexSnapRounder MCIndexSnapRounder;
+    typedef geos::noding::Noder Noder;
+    typedef geos::io::WKTReader WKTReader;
+    typedef geos::io::WKBReader WKBReader;
+    typedef geos::io::WKTWriter WKTWriter;
+    typedef geos::io::WKBWriter WKBWriter;
+    typedef geos::geom::Geometry Geometry;
+    typedef geos::geom::PrecisionModel PrecisionModel;
+    typedef geos::geom::CoordinateSequence CoordinateSequence;
+
+    typedef std::unique_ptr<CoordinateSequence> CoordSeqPtr;
+    typedef std::unique_ptr<Geometry> GeomPtr;
+
+    typedef std::vector<SegmentString*> SegStrVct;
+    typedef std::vector<Geometry*> GeomVct;
 
-      typedef geos::noding::SegmentString SegmentString;
-      typedef geos::noding::NodedSegmentString NodedSegmentString;
-      typedef geos::noding::snapround::MCIndexSnapRounder MCIndexSnapRounder;
-      typedef geos::noding::Noder Noder;
-      typedef geos::io::WKTReader WKTReader;
-      typedef geos::io::WKBReader WKBReader;
-      typedef geos::io::WKTWriter WKTWriter;
-      typedef geos::io::WKBWriter WKBWriter;
-      typedef geos::geom::Geometry Geometry;
-      typedef geos::geom::PrecisionModel PrecisionModel;
-      typedef geos::geom::CoordinateSequence CoordinateSequence;
-
-      typedef std::unique_ptr<CoordinateSequence> CoordSeqPtr;
-      typedef std::unique_ptr<Geometry> GeomPtr;
-
-      typedef std::vector<SegmentString*> SegStrVct;
-      typedef std::vector<Geometry*> GeomVct;
-
-      const geos::geom::GeometryFactory *gf_;
-
-      test_mcidxsnprndr_data()
-            : gf_(geos::geom::GeometryFactory::getDefaultInstance())
-      {}
-
-      GeomPtr getGeometry(SegStrVct& vct)
-      {
-        GeomVct *lines = new GeomVct;
-        for (SegStrVct::size_type i=0, n=vct.size(); i<n; ++i)
-        {
-          SegmentString* ss = vct[i];
-          lines->push_back( gf_->createLineString(*(ss->getCoordinates())) );
+    const geos::geom::GeometryFactory* gf_;
+
+    test_mcidxsnprndr_data()
+        : gf_(geos::geom::GeometryFactory::getDefaultInstance())
+    {}
+
+    GeomPtr
+    getGeometry(SegStrVct& vct)
+    {
+        GeomVct* lines = new GeomVct;
+        for(SegStrVct::size_type i = 0, n = vct.size(); i < n; ++i) {
+            SegmentString* ss = vct[i];
+            lines->push_back(gf_->createLineString(*(ss->getCoordinates())));
         }
         return GeomPtr(gf_->createMultiLineString(lines));
-      }
+    }
 
-      void getSegmentStrings(const Geometry& g, SegStrVct& vct)
-      {
-        CoordSeqPtr s ( g.getCoordinates() );
-        vct.push_back( new NodedSegmentString(s.release(), nullptr) );
-      }
+    void
+    getSegmentStrings(const Geometry& g, SegStrVct& vct)
+    {
+        CoordSeqPtr s(g.getCoordinates());
+        vct.push_back(new NodedSegmentString(s.release(), nullptr));
+    }
 
-      GeomPtr readGeometry(const std::string& wkt)
-      {
+    GeomPtr
+    readGeometry(const std::string& wkt)
+    {
         GeomPtr g;
-        if ( wkt[0] == '0' || wkt[0] == '1' ) {
-          WKBReader r;
-          std::istringstream is(wkt);
-          g.reset( r.readHEX(is) );
-        } else {
-          WKTReader r;
-          g.reset( r.read(wkt) );
+        if(wkt[0] == '0' || wkt[0] == '1') {
+            WKBReader r;
+            std::istringstream is(wkt);
+            g.reset(r.readHEX(is));
+        }
+        else {
+            WKTReader r;
+            g.reset(r.read(wkt));
         }
         return g;
-      }
+    }
 
-      void getSegmentStrings(const std::string& wkt, SegStrVct& vct)
-      {
+    void
+    getSegmentStrings(const std::string& wkt, SegStrVct& vct)
+    {
         GeomPtr g = readGeometry(wkt);
         getSegmentStrings(*g, vct);
-      }
+    }
 
-      void freeSegmentStrings(SegStrVct& vct)
-      {
-        for (SegStrVct::size_type i=0, n=vct.size(); i<n; ++i)
-          delete vct[i];
-      }
+    void
+    freeSegmentStrings(SegStrVct& vct)
+    {
+        for(SegStrVct::size_type i = 0, n = vct.size(); i < n; ++i) {
+            delete vct[i];
+        }
+    }
 
-    private:
-        test_mcidxsnprndr_data(test_mcidxsnprndr_data const&); // = delete
-        test_mcidxsnprndr_data& operator=(test_mcidxsnprndr_data const&); // = delete
-    };
+private:
+    test_mcidxsnprndr_data(test_mcidxsnprndr_data const&); // = delete
+    test_mcidxsnprndr_data& operator=(test_mcidxsnprndr_data const&); // = delete
+};
 
 
-    typedef test_group<test_mcidxsnprndr_data> group;
-    typedef group::object object;
+typedef test_group<test_mcidxsnprndr_data> group;
+typedef group::object object;
 
-    group test_mcidxsnprndr_group(
-      "geos::noding::snapround::MCIndexSnapRounder"
-    );
+group test_mcidxsnprndr_group(
+    "geos::noding::snapround::MCIndexSnapRounder"
+);
 
-    //
-    // Test Cases
-    //
+//
+// Test Cases
+//
 
-    // This test would fail before fix in r3528
-    template<>
-    template<>
-    void object::test<1>()
-    {
-      std::string wkt0("LINESTRING(99739.70596 -2239218.0625,99739.85604 -2239218.21258,99739.85605 -2239218.21258, 99739.85605 -2239218.21258,99739.86851 -2239218.21258,99739.86851 -2239218.20012, 99739.86851 -2239218.20012,99739.86851 -2239218.04, 99739.95848 -2239218.11015,99739.86851 -2239218.20012, 99739.86851 -2239218.20012,99739.85605 -2239218.21258, 99739.85605 -2239218.21258,99739.80901 -2239218.25961, 99739.80901 -2239218.25961,99739.68863 -2239218.38, 99739.86204 -2239218.31264,99739.80901 -2239218.25961, 99739.80901 -2239218.25961,99739.66841 -2239218.11901)");
-      SegStrVct nodable;
-      getSegmentStrings(wkt0, nodable);
-      ensure_equals( nodable.size(), 1u );
+// This test would fail before fix in r3528
+template<>
+template<>
+void object::test<1>
+()
+{
+    std::string
+    wkt0("LINESTRING(99739.70596 -2239218.0625,99739.85604 -2239218.21258,99739.85605 -2239218.21258, 99739.85605 -2239218.21258,99739.86851 -2239218.21258,99739.86851 -2239218.20012, 99739.86851 -2239218.20012,99739.86851 -2239218.04, 99739.95848 -2239218.11015,99739.86851 -2239218.20012, 99739.86851 -2239218.20012,99739.85605 -2239218.21258, 99739.85605 -2239218.21258,99739.80901 -2239218.25961, 99739.80901 -2239218.25961,99739.68863 -2239218.38, 99739.86204 -2239218.31264,99739.80901 -2239218.25961, 99739.80901 -2239218.25961,99739.66841 -2239218.11901)");
+    SegStrVct nodable;
+    getSegmentStrings(wkt0, nodable);
+    ensure_equals(nodable.size(), 1u);
 
-      PrecisionModel pm(1e-5);
-      MCIndexSnapRounder noder(pm);
+    PrecisionModel pm(1e-5);
+    MCIndexSnapRounder noder(pm);
 
-      ensure_equals( nodable.size(), 1u );
-      noder.computeNodes(&nodable);
-      std::unique_ptr<SegStrVct> noded ( noder.getNodedSubstrings() );
+    ensure_equals(nodable.size(), 1u);
+    noder.computeNodes(&nodable);
+    std::unique_ptr<SegStrVct> noded(noder.getNodedSubstrings());
 
-      ensure_equals( "1e-5", noded->size(), 178u );
+    ensure_equals("1e-5", noded->size(), 178u);
 
-      freeSegmentStrings(*noded);
-      freeSegmentStrings(nodable);
-    }
+    freeSegmentStrings(*noded);
+    freeSegmentStrings(nodable);
+}
 
 
 } // namespace tut
diff --git a/tests/unit/operation/IsSimpleOpTest.cpp b/tests/unit/operation/IsSimpleOpTest.cpp
index 03cd68b..284ccf1 100644
--- a/tests/unit/operation/IsSimpleOpTest.cpp
+++ b/tests/unit/operation/IsSimpleOpTest.cpp
@@ -18,87 +18,88 @@
 using namespace geos::geom;
 using namespace geos::operation;
 
-namespace tut
-{
-    //
-    // Test Group
-    //
+namespace tut {
+//
+// Test Group
+//
 
-    struct test_issimpleop_data
-    {
-        typedef geos::geom::GeometryFactory GeometryFactory;
-        geos::geom::PrecisionModel pm_;
-        GeometryFactory::Ptr factory_;
-        geos::io::WKTReader reader_;
-        double tolerance_;
+struct test_issimpleop_data {
+    typedef geos::geom::GeometryFactory GeometryFactory;
+    geos::geom::PrecisionModel pm_;
+    GeometryFactory::Ptr factory_;
+    geos::io::WKTReader reader_;
+    double tolerance_;
 
-        test_issimpleop_data()
-			: pm_(1)
-      , factory_(GeometryFactory::create(&pm_, 0))
-      , reader_(factory_.get())
-      , tolerance_(0.00005)
-        {}
-    };
+    test_issimpleop_data()
+        : pm_(1)
+        , factory_(GeometryFactory::create(&pm_, 0))
+        , reader_(factory_.get())
+        , tolerance_(0.00005)
+    {}
+};
 
-    typedef test_group<test_issimpleop_data> group;
-    typedef group::object object;
+typedef test_group<test_issimpleop_data> group;
+typedef group::object object;
 
-    group test_issimpleop_group("geos::operation::IsSimpleOp");
+group test_issimpleop_group("geos::operation::IsSimpleOp");
 
+//
+// Test Cases
+//
+
+// 1 - Test cross
+template<>
+template<>
+void object::test<1>
+()
+{
+    const std::string wkt("MULTILINESTRING ((20 120, 120 20), (20 20, 120 120))");
+    const Geometry::Ptr geom(reader_.read(wkt));
+
+    // TODO - mloskot: What about support of new features of BoundaryNodeRule, in JTS
+
+    IsSimpleOp op;
+    bool simple = op.isSimpleLinearGeometry(geom.get());
+
+    ensure(false == simple);
+
+    // TODO - mloskot:
+    // There are missing features not (re)implemented in IsSimpleOp, in GEOS.
+    // So, all tests in this suite have been simplified in comparison to original JTS tests.
     //
-    // Test Cases
-    //
+    //Coordinate loc(70, 70);
+    //Coordinate nonSimpleLoc = op.getNonSimpleLocation();
+    //loc.distance(nonSimpleLoc) < TOLERANCE
+}
+
+// 2 - Test MultiLineString with ring touching at the end point
+template<>
+template<>
+void object::test<2>
+()
+{
+    const std::string wkt("MULTILINESTRING ((100 100, 20 20, 200 20, 100 100), (100 200, 100 100))");
+    const Geometry::Ptr geom(reader_.read(wkt));
+
+    IsSimpleOp op;
+    bool simple = op.isSimpleLinearGeometry(geom.get());
+
+    ensure(false == simple);
+}
+
+// 3 - Test simple LineString
+template<>
+template<>
+void object::test<3>
+()
+{
+    const std::string wkt("LINESTRING (100 100, 20 20, 200 20, 100 100)");
+    const Geometry::Ptr geom(reader_.read(wkt));
+
+    IsSimpleOp op;
+    bool simple = op.isSimpleLinearGeometry(geom.get());
 
-    // 1 - Test cross
-    template<>
-    template<>
-    void object::test<1>()
-    {
-        const std::string wkt("MULTILINESTRING ((20 120, 120 20), (20 20, 120 120))");
-        const Geometry::Ptr geom(reader_.read(wkt));
-
-        // TODO - mloskot: What about support of new features of BoundaryNodeRule, in JTS
-
-        IsSimpleOp op;
-        bool simple = op.isSimpleLinearGeometry(geom.get());
-
-        ensure( false == simple );
-
-        // TODO - mloskot:
-        // There are missing features not (re)implemented in IsSimpleOp, in GEOS.
-        // So, all tests in this suite have been simplified in comparison to original JTS tests.
-        //
-        //Coordinate loc(70, 70);
-        //Coordinate nonSimpleLoc = op.getNonSimpleLocation();
-        //loc.distance(nonSimpleLoc) < TOLERANCE
-    }
-
-    // 2 - Test MultiLineString with ring touching at the end point
-    template<>
-    template<>
-    void object::test<2>()
-    {
-        const std::string wkt("MULTILINESTRING ((100 100, 20 20, 200 20, 100 100), (100 200, 100 100))");
-        const Geometry::Ptr geom(reader_.read(wkt));
-
-        IsSimpleOp op;
-        bool simple = op.isSimpleLinearGeometry(geom.get());
-
-        ensure( false == simple );
-    }
-
-    // 3 - Test simple LineString
-    template<>
-    template<>
-    void object::test<3>()
-    {
-        const std::string wkt("LINESTRING (100 100, 20 20, 200 20, 100 100)");
-        const Geometry::Ptr geom(reader_.read(wkt));
-
-        IsSimpleOp op;
-        bool simple = op.isSimpleLinearGeometry(geom.get());
-
-        ensure( true == simple );
-    }
+    ensure(true == simple);
+}
 
 } // namespace tut
diff --git a/tests/unit/operation/buffer/BufferBuilderTest.cpp b/tests/unit/operation/buffer/BufferBuilderTest.cpp
index 259d141..d8f9b04 100644
--- a/tests/unit/operation/buffer/BufferBuilderTest.cpp
+++ b/tests/unit/operation/buffer/BufferBuilderTest.cpp
@@ -20,111 +20,110 @@
 #include <string>
 #include <vector>
 
-namespace tut
-{
-    //
-    // Test Group
-    //
+namespace tut {
+//
+// Test Group
+//
+
+// Common data used by tests
+struct test_bufferbuilder_data {
+    const geos::geom::GeometryFactory& gf;
+    geos::io::WKTReader wktreader;
+    int const default_quadrant_segments;
+
+    typedef geos::geom::Geometry::Ptr GeomPtr;
+    typedef std::unique_ptr<geos::geom::CoordinateSequence> CSPtr;
+
+    test_bufferbuilder_data()
+        : gf(*geos::geom::GeometryFactory::getDefaultInstance())
+        , wktreader(&gf)
+        , default_quadrant_segments(geos::operation::buffer::BufferParameters::DEFAULT_QUADRANT_SEGMENTS)
+    {
+        ensure_equals(default_quadrant_segments, int(8));
+    }
+private:
+    // noncopyable
+    test_bufferbuilder_data(test_bufferbuilder_data const& other) = delete;
+    test_bufferbuilder_data& operator=(test_bufferbuilder_data const& rhs) = delete;
+};
 
-    // Common data used by tests
-    struct test_bufferbuilder_data
+typedef test_group<test_bufferbuilder_data> group;
+typedef group::object object;
+
+group test_bufferbuilder_group("geos::operation::buffer::BufferBuilder");
+
+//
+// Test Cases
+//
+
+// Left-side and right-side offset curve
+// See http://trac.osgeo.org/geos/ticket/633
+template<>
+template<>
+void object::test<1>
+()
+{
+    using geos::operation::buffer::BufferBuilder;
+    using geos::operation::buffer::BufferParameters;
+    using geos::algorithm::Orientation;
+    using geos::geom::LineString;
+
+    // Original input from test in ticket #633
+    //std::string wkt0("LINESTRING ("
+    //    "665.7317504882812500 133.0762634277343700,"
+    //    "1774.4752197265625000 19.9391822814941410,"
+    //    "756.2413940429687500 466.8306579589843700,"
+    //    "626.1337890625000000 1898.0147705078125000,"
+    //    "433.8007202148437500 404.6052856445312500)");
+    //double const distance = 57.164000837203;
+
+    // Simplified equivalent input
+    std::string wkt0("LINESTRING(0 0, 50 -10, 10 10, 0 50, -10 10)");
+    double const distance = 5;
+
+    GeomPtr g0(wktreader.read(wkt0));
+    ensure(nullptr != g0.get());
+    ensure_equals(g0->getNumPoints(), std::size_t(5));
+
+    BufferParameters params;
+    params.setEndCapStyle(BufferParameters::CAP_FLAT);
+    params.setQuadrantSegments(8);
+    params.setJoinStyle(BufferParameters::JOIN_MITRE);
+    params.setMitreLimit(5.57F);
+    //params.setSingleSided(true); // DO NOT switch for non-areal input, see ticket #633
+    BufferBuilder builder(params);
+    ensure(distance > 0);
+
+    // left-side
     {
-        const geos::geom::GeometryFactory &gf;
-        geos::io::WKTReader wktreader;
-        int const default_quadrant_segments;
-
-        typedef geos::geom::Geometry::Ptr GeomPtr;
-        typedef std::unique_ptr<geos::geom::CoordinateSequence> CSPtr;
-
-        test_bufferbuilder_data()
-            : gf(*geos::geom::GeometryFactory::getDefaultInstance())
-            , wktreader(&gf)
-            , default_quadrant_segments(geos::operation::buffer::BufferParameters::DEFAULT_QUADRANT_SEGMENTS)
-        {
-            ensure_equals(default_quadrant_segments, int(8));
-        }
-    private:
-        // noncopyable
-        test_bufferbuilder_data(test_bufferbuilder_data const& other) = delete;
-        test_bufferbuilder_data& operator=(test_bufferbuilder_data const& rhs) = delete;
-    };
-
-    typedef test_group<test_bufferbuilder_data> group;
-    typedef group::object object;
-
-    group test_bufferbuilder_group("geos::operation::buffer::BufferBuilder");
-
-    //
-    // Test Cases
-    //
-
-    // Left-side and right-side offset curve
-    // See http://trac.osgeo.org/geos/ticket/633
-    template<>
-    template<>
-    void object::test<1>()
+        GeomPtr gB(builder.bufferLineSingleSided(g0.get(), distance, true));
+        ensure(nullptr != gB.get());
+        ensure_equals(gB->getGeometryTypeId(), geos::geom::GEOS_LINESTRING);
+        // Left-side offset curve expected with 5+ vertices
+        ensure(gB->getNumPoints() >= g0->getNumPoints());
+
+        // For left-side offset curve, the offset will be at the left side of the input line
+        // and retain the same direction.
+        ensure_equals(
+            Orientation::isCCW(dynamic_cast<LineString*>(g0.get())->getCoordinatesRO()),
+            Orientation::isCCW(dynamic_cast<LineString*>(gB.get())->getCoordinatesRO()));
+    }
+
+    // right-side
     {
-        using geos::operation::buffer::BufferBuilder;
-        using geos::operation::buffer::BufferParameters;
-        using geos::algorithm::Orientation;
-        using geos::geom::LineString;
-
-        // Original input from test in ticket #633
-        //std::string wkt0("LINESTRING ("
-        //    "665.7317504882812500 133.0762634277343700,"
-        //    "1774.4752197265625000 19.9391822814941410,"
-        //    "756.2413940429687500 466.8306579589843700,"
-        //    "626.1337890625000000 1898.0147705078125000,"
-        //    "433.8007202148437500 404.6052856445312500)");
-        //double const distance = 57.164000837203;
-
-        // Simplified equivalent input
-        std::string wkt0("LINESTRING(0 0, 50 -10, 10 10, 0 50, -10 10)");
-        double const distance = 5;
-
-        GeomPtr g0(wktreader.read(wkt0));
-        ensure(nullptr != g0.get());
-        ensure_equals(g0->getNumPoints(), std::size_t(5));
-
-        BufferParameters params;
-        params.setEndCapStyle(BufferParameters::CAP_FLAT);
-        params.setQuadrantSegments(8);
-        params.setJoinStyle(BufferParameters::JOIN_MITRE);
-        params.setMitreLimit(5.57F);
-        //params.setSingleSided(true); // DO NOT switch for non-areal input, see ticket #633
-        BufferBuilder builder(params);
-        ensure(distance > 0);
-
-        // left-side
-        {
-            GeomPtr gB(builder.bufferLineSingleSided(g0.get(), distance, true));
-            ensure(nullptr != gB.get());
-            ensure_equals(gB->getGeometryTypeId(), geos::geom::GEOS_LINESTRING);
-            // Left-side offset curve expected with 5+ vertices
-            ensure(gB->getNumPoints() >= g0->getNumPoints());
-
-            // For left-side offset curve, the offset will be at the left side of the input line
-            // and retain the same direction.
-            ensure_equals(
-                Orientation::isCCW(dynamic_cast<LineString*>(g0.get())->getCoordinatesRO()),
-                Orientation::isCCW(dynamic_cast<LineString*>(gB.get())->getCoordinatesRO()));
-        }
-
-        // right-side
-        {
-            GeomPtr gB(builder.bufferLineSingleSided(g0.get(), distance, false));
-            ensure(nullptr != gB.get());
-            ensure_equals(gB->getGeometryTypeId(), geos::geom::GEOS_LINESTRING);
-            // Right-side offset curve expected with 5+ vertices
-            ensure(gB->getNumPoints() >= g0->getNumPoints());
-
-            // For right-side offset curve, it'll be at the right side
-            // and in the opposite direction.
-            ensure_equals(
-                Orientation::isCCW(dynamic_cast<LineString*>(g0.get())->getCoordinatesRO()),
-                !Orientation::isCCW(dynamic_cast<LineString*>(gB.get())->getCoordinatesRO()));
-        }
+        GeomPtr gB(builder.bufferLineSingleSided(g0.get(), distance, false));
+        ensure(nullptr != gB.get());
+        ensure_equals(gB->getGeometryTypeId(), geos::geom::GEOS_LINESTRING);
+        // Right-side offset curve expected with 5+ vertices
+        ensure(gB->getNumPoints() >= g0->getNumPoints());
+
+        // For right-side offset curve, it'll be at the right side
+        // and in the opposite direction.
+        ensure_equals(
+            Orientation::isCCW(dynamic_cast<LineString*>(g0.get())->getCoordinatesRO()),
+            !Orientation::isCCW(dynamic_cast<LineString*>(gB.get())->getCoordinatesRO()));
     }
+}
 
 } // namespace tut
 
diff --git a/tests/unit/operation/buffer/BufferOpTest.cpp b/tests/unit/operation/buffer/BufferOpTest.cpp
index 21370de..d8599bf 100644
--- a/tests/unit/operation/buffer/BufferOpTest.cpp
+++ b/tests/unit/operation/buffer/BufferOpTest.cpp
@@ -18,304 +18,320 @@
 #include <string>
 #include <vector>
 
-namespace tut
-{
-    //
-    // Test Group
-    //
-
-    // Common data used by tests
-    struct test_bufferop_data
-    {
-        const geos::geom::GeometryFactory &gf;
-        geos::io::WKTReader wktreader;
-        int const default_quadrant_segments;
-
-        typedef geos::geom::Geometry::Ptr GeomPtr;
-        typedef std::unique_ptr<geos::geom::CoordinateSequence> CSPtr;
-
-        test_bufferop_data()
-            : gf(*geos::geom::GeometryFactory::getDefaultInstance())
-            , wktreader(&gf)
-            , default_quadrant_segments(geos::operation::buffer::BufferParameters::DEFAULT_QUADRANT_SEGMENTS)
-        {
-            ensure_equals(default_quadrant_segments, int(8));
-        }
-    private:
-        // noncopyable
-        test_bufferop_data(test_bufferop_data const& other) = delete;
-        test_bufferop_data& operator=(test_bufferop_data const& rhs) = delete;
-    };
-
-    typedef test_group<test_bufferop_data> group;
-    typedef group::object object;
-
-    group test_bufferop_group("geos::operation::buffer::BufferOp");
-
-    //
-    // Test Cases
-    //
-    template<>
-    template<>
-    void object::test<1>()
-    {
-        using geos::operation::buffer::BufferOp;
-
-        std::string wkt0("POINT(0 0)");
-        GeomPtr g0(wktreader.read(wkt0));
+namespace tut {
+//
+// Test Group
+//
 
-        double const distance = 0.0;
-        BufferOp op(g0.get());
-        GeomPtr gBuffer(op.getResultGeometry(distance));
+// Common data used by tests
+struct test_bufferop_data {
+    const geos::geom::GeometryFactory& gf;
+    geos::io::WKTReader wktreader;
+    int const default_quadrant_segments;
 
-        ensure(gBuffer->isEmpty());
-        ensure(gBuffer->isValid());
-        ensure_equals(gBuffer->getGeometryTypeId(), geos::geom::GEOS_POLYGON);
-        ensure_equals(gBuffer->getNumPoints(), std::size_t(0));
-    }
+    typedef geos::geom::Geometry::Ptr GeomPtr;
+    typedef std::unique_ptr<geos::geom::CoordinateSequence> CSPtr;
 
-    template<>
-    template<>
-    void object::test<2>()
+    test_bufferop_data()
+        : gf(*geos::geom::GeometryFactory::getDefaultInstance())
+        , wktreader(&gf)
+        , default_quadrant_segments(geos::operation::buffer::BufferParameters::DEFAULT_QUADRANT_SEGMENTS)
     {
-        using geos::operation::buffer::BufferOp;
-
-        std::string wkt0("POINT(0 0)");
-        GeomPtr g0(wktreader.read(wkt0));
-
-        // Buffer point with default buffering parameters
-        double const distance = 1.0;
-        BufferOp op(g0.get());
-        GeomPtr gBuffer(op.getResultGeometry(distance));
-
-        ensure_not(gBuffer->isEmpty());
-        ensure(gBuffer->isValid());
-        ensure_equals(gBuffer->getGeometryTypeId(), geos::geom::GEOS_POLYGON);
-        ensure(gBuffer->getNumPoints() > std::size_t(32));
+        ensure_equals(default_quadrant_segments, int(8));
     }
+private:
+    // noncopyable
+    test_bufferop_data(test_bufferop_data const& other) = delete;
+    test_bufferop_data& operator=(test_bufferop_data const& rhs) = delete;
+};
 
-    template<>
-    template<>
-    void object::test<3>()
-    {
-        using geos::operation::buffer::BufferOp;
-        using geos::operation::buffer::BufferParameters;
-
-        std::string wkt0("POINT(0 0)");
-        GeomPtr g0(wktreader.read(wkt0));
+typedef test_group<test_bufferop_data> group;
+typedef group::object object;
 
-        // Buffer point with custom parameters: 32 quadrant segments
-        int const segments = 32;
-        BufferParameters params(segments);
-
-        BufferOp op(g0.get(), params);
+group test_bufferop_group("geos::operation::buffer::BufferOp");
 
-        double const distance = 1.0;
-        GeomPtr gBuffer(op.getResultGeometry(distance));
+//
+// Test Cases
+//
+template<>
+template<>
+void object::test<1>
+()
+{
+    using geos::operation::buffer::BufferOp;
 
-        ensure_not(gBuffer->isEmpty());
-        ensure(gBuffer->isValid());
-        ensure_equals(gBuffer->getGeometryTypeId(), geos::geom::GEOS_POLYGON);
-        ensure(gBuffer->getNumPoints() > std::size_t(129));
-    }
+    std::string wkt0("POINT(0 0)");
+    GeomPtr g0(wktreader.read(wkt0));
 
-    template<>
-    template<>
-    void object::test<4>()
-    {
-        using geos::operation::buffer::BufferOp;
-        using geos::operation::buffer::BufferParameters;
-
-        // Geometry from XMLTester's buffer.xml, test case #25
-        std::string wkt0("MULTIPOLYGON(((708258.754920656 2402197.91172757,708257.029447455 2402206.56901508,708652.961095455 2402312.65463437,708657.068786251 2402304.6356364,708258.754920656 2402197.91172757)),((708653.498611049 2402311.54647056,708708.895756966 2402203.47250014,708280.326454234 2402089.6337791,708247.896591321 2402252.48269854,708367.379593851 2402324.00761653,708248.882609455 2402253.07294874,708249.523621829 2402244.3124463,708261.854734465 2402182.39086576,708262.818392579 2402183.35452387,708653.498611049 2402311.54647056)))");
-        GeomPtr g0(wktreader.read(wkt0));
-
-        // Buffer point with custom parameters: 24 quadrant segments
-        {
-            int const segments = default_quadrant_segments * 3;
-            BufferParameters params(segments);
-            BufferOp op(g0.get(), params);
-            double const distance = 0.0001;
-            GeomPtr gBuffer(op.getResultGeometry(distance));
-            ensure_not(gBuffer->isEmpty());
-            ensure(gBuffer->isValid());
-            ensure_equals(gBuffer->getGeometryTypeId(), geos::geom::GEOS_POLYGON);
-            ensure(gBuffer->getNumPoints() >= std::size_t(245));
-        }
-
-        // Buffer point with custom parameters: 32 quadrant segments
-        {
-            int const segments = default_quadrant_segments * 4;
-            BufferParameters params(segments);
-            BufferOp op(g0.get(), params);
-            double const distance = 0.0001;
-            GeomPtr gBuffer(op.getResultGeometry(distance));
-            ensure_not(gBuffer->isEmpty());
-            ensure(gBuffer->isValid());
-            ensure_equals(gBuffer->getGeometryTypeId(), geos::geom::GEOS_POLYGON);
-            ensure(gBuffer->getNumPoints() >= std::size_t(318));
-        }
-    }
+    double const distance = 0.0;
+    BufferOp op(g0.get());
+    GeomPtr gBuffer(op.getResultGeometry(distance));
 
-    template<>
-    template<>
-    void object::test<5>()
-    {
-        using geos::operation::buffer::BufferOp;
-        using geos::operation::buffer::BufferParameters;
+    ensure(gBuffer->isEmpty());
+    ensure(gBuffer->isValid());
+    ensure_equals(gBuffer->getGeometryTypeId(), geos::geom::GEOS_POLYGON);
+    ensure_equals(gBuffer->getNumPoints(), std::size_t(0));
+}
 
-        // Geometry from XMLTester's TestBufferExternal2.xml, test case #31
-        std::string wkt0("POLYGON((167187.935985 527215.129985,167246.663985 527205.580985,167280.107985 527210.602985,167314.083985 527213.149985,167354.196985 527218.563985,167363.609985 527204.834985,167358.459985 527177.204985,167344.405985 527172.240985,167323.325985 527164.793985,167304.557985 527167.748985,167285.789985 527170.703985,167260.854985 527176.007985,167211.198985 527149.591985,167165.408985 527140.439985,167141.660985 527146.308985,167119.062985 527137.503985,167119.967985 527139.010985,167078.296985 527188.560985,167105.238985 527267.140985,167090.957985 527316.213985,167094.770985 527321.819985,167082.593985 527377.599985,167065.952985 527417.668985,167056.312985 527449.383985,167043.546985 527485.510985,167019.927985 527525.916985,166982.769985 527539.710985,166961.717985 527606.388985,166933.263985 527657.009985,166899.206985 527710.191985,166916.325985 527722.287985,166973.067985 527744.810985,166978.160985 527695.099985,167043.308985 527684.770985,167080.550
 985 527644.941985,167101.716985 527610.077985,167109.672985 527576.692985,167099.068985 527561.394985,167097.537985 527527.027985,167105.044985 527510.384985,167137.888985 527502.771985,167160.386985 527500.228985,167174.041985 527468.108985,167205.365985 527466.936985,167200.090985 527446.692985,167182.286985 527416.893985,167214.905985 527399.163985,167245.980985 527379.346985,167258.755985 527325.736985,167261.469985 527296.920985,167237.119985 527273.314985,167201.524985 527264.407985,167192.491985 527252.494985,167172.090985 527216.630985,167187.935985 527215.129985))");
-        GeomPtr g0(wktreader.read(wkt0));
+template<>
+template<>
+void object::test<2>
+()
+{
+    using geos::operation::buffer::BufferOp;
+
+    std::string wkt0("POINT(0 0)");
+    GeomPtr g0(wktreader.read(wkt0));
+
+    // Buffer point with default buffering parameters
+    double const distance = 1.0;
+    BufferOp op(g0.get());
+    GeomPtr gBuffer(op.getResultGeometry(distance));
+
+    ensure_not(gBuffer->isEmpty());
+    ensure(gBuffer->isValid());
+    ensure_equals(gBuffer->getGeometryTypeId(), geos::geom::GEOS_POLYGON);
+    ensure(gBuffer->getNumPoints() > std::size_t(32));
+}
+
+template<>
+template<>
+void object::test<3>
+()
+{
+    using geos::operation::buffer::BufferOp;
+    using geos::operation::buffer::BufferParameters;
 
-        // Buffer point with quadrant segments value (x4)
-        BufferParameters params(default_quadrant_segments * 4);
-        BufferOp op(g0.get(), params);
-        double const distance = -75.0;
-        GeomPtr gBuffer(op.getResultGeometry(distance));
-        ensure_not(gBuffer->isEmpty());
-        ensure(gBuffer->isValid());
-        ensure_equals(gBuffer->getGeometryTypeId(), geos::geom::GEOS_POLYGON);
-        ensure(gBuffer->getNumPoints() >= std::size_t(8));
-    }
+    std::string wkt0("POINT(0 0)");
+    GeomPtr g0(wktreader.read(wkt0));
 
-    template<>
-    template<>
-    void object::test<6>()
-    {
-        using geos::operation::buffer::BufferOp;
-        using geos::operation::buffer::BufferParameters;
+    // Buffer point with custom parameters: 32 quadrant segments
+    int const segments = 32;
+    BufferParameters params(segments);
 
-        // Geometry from XMLTester's TestBufferExternal2.xml, test case #41
-        std::string wkt0("POLYGON((148410.699985 522834.902985,148442.757985 522825.725985,148460.309985 522827.514985,148487.864985 522844.888985,148500.821985 522849.224985,148522.555985 522842.060985,148549.245985 522836.360985,148568.572985 522826.852985,148584.252985 522812.743985,148609.816985 522787.145985,148614.009985 522767.881985,148612.795985 522752.758985,148612.563985 522743.189985,148618.720985 522735.053985,148625.781585 522726.296485,148618.662985 522724.739985,148612.278985 522723.775985,148605.112985 522714.525985,148611.687985 522677.987985,148611.797985 522647.963985,148594.739985 522625.727985,148584.565985 522622.805985,148562.730985 522628.324985,148543.283985 522615.292985,148536.597985 522557.684985,148536.223985 522555.223985,148534.274985 522546.378985,148533.665985 522541.970985,148533.794985 522540.094985,148535.172985 522535.741985,148538.094985 522529.403985,148538.611985 522526.777985,148539.936985 522513.990985,148540.169985 522509.496985,148540.192
 985 522500.589985,148540.851985 522495.877985,148540.474985 522491.607985,148539.391985 522489.734985,148536.121985 522486.259985,148532.239985 522483.953985,148529.487985 522487.690985,148527.557985 522489.161985,148523.269985 522490.157985,148512.547985 522491.130985,148508.089985 522491.855985,148503.708985 522492.860985,148499.171985 522494.926985,148493.577985 522498.401985,148488.746985 522500.495985,148483.626985 522501.803985,148480.736985 522503.655985,148464.117985 522534.086985,148427.843985 522552.590985,148408.790985 522571.476985,148398.223985 522596.340985,148407.833985 522615.400985,148416.753985 522662.875985,148420.236985 522689.856985,148421.081985 522713.013985,148415.508985 522722.819985,148391.177985 522725.213985,148358.228985 522724.834985,148355.953985 522741.826985,148341.696985 522767.846985,148328.778985 522795.425985,148312.269985 522806.114985,148322.213985 522836.436985,148339.137985 522884.626985,148351.181985 522896.189985,148376.682985 522893.652985
 ,148389.158985 522851.634985,148410.699985 522834.902985))");
-        GeomPtr g0(wktreader.read(wkt0));
+    BufferOp op(g0.get(), params);
 
-        // Buffer point with quadrant segments value (x4)
-        int const segments = default_quadrant_segments * 4;
-        BufferParameters params(segments);
-        BufferOp op(g0.get(), params);
-        double const distance = -75.0;
-        GeomPtr gBuffer(op.getResultGeometry(distance));
-        ensure_not(gBuffer->isEmpty());
-        ensure(gBuffer->isValid());
-        ensure_equals(gBuffer->getGeometryTypeId(), geos::geom::GEOS_POLYGON);
-        ensure(gBuffer->getNumPoints() >= std::size_t(51));
-    }
+    double const distance = 1.0;
+    GeomPtr gBuffer(op.getResultGeometry(distance));
 
-    template<>
-    template<>
-    void object::test<7>()
-    {
-        using geos::operation::buffer::BufferOp;
-        using geos::operation::buffer::BufferParameters;
+    ensure_not(gBuffer->isEmpty());
+    ensure(gBuffer->isValid());
+    ensure_equals(gBuffer->getGeometryTypeId(), geos::geom::GEOS_POLYGON);
+    ensure(gBuffer->getNumPoints() > std::size_t(129));
+}
 
-        // Geometry from XMLTester's TestBufferExternal2.xml, test case #42
-        std::string wkt0("POLYGON((150213.068985 524020.273985,150226.206985 524020.218985,150245.019985 524022.421985,150248.570985 524017.633985,150243.628985 523991.402985,150233.942985 523969.968985,150203.852985 523929.546985,150189.509985 523905.746985,150179.578985 523905.795985,150163.996985 523891.573985,150150.529985 523872.591985,150158.960985 523848.710985,150150.727985 523827.265985,150129.075985 523796.394985,150110.126985 523782.119985,150064.853985 523787.149985,150051.774985 523791.993985,150035.273985 523796.784985,150034.124985 523803.948985,150047.317985 523842.088985,150048.538985 523846.850985,150048.758985 523856.362985,150044.002985 523858.774985,150033.285985 523861.216985,150022.584985 523866.044985,150013.239985 523875.626985,150010.897985 523882.801985,150007.322985 523904.295985,150015.725985 523913.798985,150028.883985 523920.894985,150036.292985 523937.604985,150033.171985 523964.012985,150028.264985 524013.973985,150020.417985 524042.804985,150014.532
 985 524064.428985,150004.476985 524083.491985,149987.717985 524115.262985,149981.881985 524139.242985,149991.382985 524146.196985,150012.547985 524165.288985,150017.553385 524169.126585,150024.575985 524166.982985,150037.645985 524157.385985,150054.301985 524147.777985,150067.231985 524142.754985,150080.313985 524135.548985,150096.808985 524132.911985,150108.662985 524120.938985,150113.586985 524111.551985,150113.285985 524097.054985,150114.403985 524085.116985,150121.501985 524075.543985,150134.308985 524061.036985,150143.802985 524053.844985,150159.042985 524051.270985,150177.151985 524046.558985,150188.764985 524039.234985,150195.842985 524027.285985,150213.068985 524020.273985))");
-        GeomPtr g0(wktreader.read(wkt0));
+template<>
+template<>
+void object::test<4>
+()
+{
+    using geos::operation::buffer::BufferOp;
+    using geos::operation::buffer::BufferParameters;
 
-        // Buffer point with quadrant segments value (x4)
-        int const segments = default_quadrant_segments * 4;
-        BufferParameters params(segments);
-        BufferOp op(g0.get(), params);
-        double const distance = -75.0;
-        GeomPtr gBuffer(op.getResultGeometry(distance));
-        ensure_not(gBuffer->isEmpty());
-        ensure(gBuffer->isValid());
-        ensure_equals(gBuffer->getGeometryTypeId(), geos::geom::GEOS_POLYGON);
-        ensure(gBuffer->getNumPoints() >= std::size_t(24));
-    }
+    // Geometry from XMLTester's buffer.xml, test case #25
+    std::string
+    wkt0("MULTIPOLYGON(((708258.754920656 2402197.91172757,708257.029447455 2402206.56901508,708652.961095455 2402312.65463437,708657.068786251 2402304.6356364,708258.754920656 2402197.91172757)),((708653.498611049 2402311.54647056,708708.895756966 2402203.47250014,708280.326454234 2402089.6337791,708247.896591321 2402252.48269854,708367.379593851 2402324.00761653,708248.882609455 2402253.07294874,708249.523621829 2402244.3124463,708261.854734465 2402182.39086576,708262.818392579 2402183.35452387,708653.498611049 2402311.54647056)))");
+    GeomPtr g0(wktreader.read(wkt0));
 
-    template<>
-    template<>
-    void object::test<8>()
+    // Buffer point with custom parameters: 24 quadrant segments
     {
-        using geos::operation::buffer::BufferOp;
-        using geos::operation::buffer::BufferParameters;
-
-        // Geometry from XMLTester's TestBufferExternal2.xml, test case #98
-        std::string wkt0("POLYGON((146978.395985 514128.105985,146993.088985 514109.724985,146990.935985 514109.919985,146986.515985 514108.676985,146984.834985 514107.491985,146981.559985 514104.355985,146978.605985 514100.856985,146976.054985 514097.475985,146971.011985 514090.004985,146967.745985 514085.474985,146964.701985 514082.154985,146959.542985 514075.969985,146956.337985 514072.894985,146952.680985 514071.027985,146947.749985 514069.211985,146939.485985 514065.648985,146927.297985 514062.022985,146919.855985 514059.063985,146915.584985 514057.875985,146911.533985 514057.834985,146907.047985 514058.932985,146902.995985 514060.801985,146899.081985 514063.093985,146893.310985 514066.882985,146889.708985 514069.594985,146885.365985 514073.314985,146874.977985 514084.255985,146871.396985 514088.322985,146864.758985 514096.561985,146858.269985 514103.545985,146851.525985 514109.507985,146845.834985 514113.792985,146843.682985 514115.048985,146833.562985 514120.296985,146827.089
 985 514122.419985,146822.686985 514123.116985,146818.808985 514122.219985,146814.499985 514120.648985,146810.509985 514118.510985,146805.983985 514115.339985,146799.004985 514109.608985,146789.184985 514100.497985,146782.878985 514094.071985,146773.731985 514084.130985,146772.704985 514082.828985,146770.140985 514078.765985,146767.239985 514075.730985,146765.038985 514075.353985,146760.639985 514077.133985,146756.696985 514093.552985,146755.166985 514104.428985,146754.236985 514107.679985,146747.054985 514128.282985,146745.452985 514132.485985,146740.637985 514142.592985,146736.292985 514152.151985,146732.113985 514160.830985,146729.632985 514165.603985,146720.451985 514182.099985,146718.255985 514185.582985,146715.669985 514189.265985,146708.041985 514198.572985,146700.623985 514208.288985,146697.764985 514212.325985,146695.357985 514216.136985,146693.225985 514220.099985,146691.843985 514223.389985,146688.846985 514231.402985,146687.411985 514235.659985,146686.889985 514238.098985
 ,146686.285985 514244.852985,146686.270985 514253.857985,146686.450985 514255.277985,146686.301985 514260.300985,146683.033985 514264.144985,146683.155985 514265.983985,146682.338985 514271.113985,146682.374985 514276.109985,146680.337985 514280.147985,146677.579985 514283.544985,146668.796985 514293.186985,146665.431985 514297.393985,146661.798985 514300.600985,146659.382985 514304.403985,146657.401985 514310.058985,146656.451985 514315.110985,146657.862985 514320.479985,146660.328985 514325.311985,146664.346985 514327.493985,146671.146985 514330.078985,146674.727985 514332.813985,146678.721985 514337.242985,146681.490985 514340.795985,146686.032985 514347.673985,146690.888985 514355.863985,146692.808985 514359.916985,146693.698985 514363.305985,146695.616985 514373.416985,146698.231985 514382.035985,146699.836985 514386.527985,146701.571985 514390.707985,146703.974985 514394.998985,146706.750985 514398.590985,146710.002985 514401.691985,146712.889985 514403.299985,146717.072985 51
 4405.089985,146726.061985 514410.373985,146734.615985 514414.500985,146745.317985 514418.731985,146749.574985 514420.166985,146751.177985 514420.590985,146755.638985 514421.241985,146756.964985 514414.062985,146760.786985 514395.658985,146762.453985 514390.190985,146763.644985 514384.449985,146765.274985 514379.265985,146767.350985 514375.290985,146772.077985 514367.066985,146782.052985 514344.326985,146787.377985 514332.973985,146796.553985 514316.678985,146800.956985 514309.903985,146805.131985 514302.406985,146810.612985 514294.080985,146815.038985 514286.445985,146817.815985 514282.583985,146823.033985 514277.958985,146826.565985 514274.275985,146829.279985 514270.683985,146831.879985 514268.007985,146838.691985 514261.283985,146846.154985 514255.376985,146849.511985 514252.379985,146854.426985 514246.995985,146866.975985 514234.461985,146873.174985 514227.718985,146875.892985 514224.130985,146883.032985 514216.049985,146888.426985 514211.137985,146895.661985 514205.813985,14689
 8.228985 514203.079985,146900.862985 514199.416985,146903.718985 514196.294985,146910.227985 514189.724985,146918.475985 514180.160985,146921.638985 514177.199985,146925.123985 514174.344985,146929.916985 514170.920985,146942.656985 514162.441985,146948.828985 514158.846985,146952.598985 514156.414985,146955.585985 514153.824985,146964.483985 514144.873985,146967.826985 514140.249985,146969.666985 514137.975985,146978.395985 514128.105985))");
-        GeomPtr g0(wktreader.read(wkt0));
-
-        // Buffer point with quadrant segments value (x4)
-        int const segments = default_quadrant_segments * 4;
+        int const segments = default_quadrant_segments * 3;
         BufferParameters params(segments);
         BufferOp op(g0.get(), params);
-        double const distance = -75.0;
+        double const distance = 0.0001;
         GeomPtr gBuffer(op.getResultGeometry(distance));
         ensure_not(gBuffer->isEmpty());
         ensure(gBuffer->isValid());
         ensure_equals(gBuffer->getGeometryTypeId(), geos::geom::GEOS_POLYGON);
-        ensure(gBuffer->getNumPoints() >= std::size_t(7));
+        ensure(gBuffer->getNumPoints() >= std::size_t(245));
     }
 
-    template<>
-    template<>
-    void object::test<9>()
+    // Buffer point with custom parameters: 32 quadrant segments
     {
-        using geos::operation::buffer::BufferOp;
-        using geos::operation::buffer::BufferParameters;
-
-        // Geometry from XMLTester's TestBufferExternal2.xml, test case #99
-        std::string wkt0("POLYGON((144130.790985 514542.589985,144136.106985 514541.268985,144140.618985 514541.819985,144146.580985 514542.271985,144155.308985 514545.689985,144159.779985 514546.073985,144165.774985 514546.027985,144170.614985 514545.336985,144174.457985 514542.248985,144180.591985 514535.602985,144185.031985 514531.945985,144188.930985 514529.699985,144202.240985 514526.170985,144204.522985 514525.434985,144208.647985 514523.675985,144209.506985 514523.064985,144212.582985 514519.733985,144214.710985 514516.736985,144217.305985 514512.269985,144225.821985 514492.742985,144230.222985 514479.998985,144238.048985 514458.756985,144239.749985 514453.779985,144242.237985 514445.130985,144246.840985 514428.052985,144247.696985 514425.401985,144249.538985 514420.578985,144253.385985 514411.927985,144260.058985 514394.218985,144264.745985 514384.187985,144266.213985 514379.927985,144267.402985 514375.585985,144266.909985 514372.870985,144264.565985 514368.375985,144255.527
 985 514363.949985,144249.852985 514362.074985,144245.934985 514359.844985,144246.620985 514355.223985,144248.164985 514351.697985,144250.544985 514347.859985,144251.479985 514346.801985,144258.417985 514340.953985,144264.816985 514336.013985,144266.807985 514330.309985,144266.470985 514325.834985,144264.754985 514315.479985,144263.754985 514311.093985,144261.914985 514304.532985,144260.268985 514300.367985,144258.258985 514296.998985,144255.314985 514293.564985,144253.224985 514291.582985,144249.714985 514288.669985,144245.918985 514286.308985,144244.887985 514285.843985,144240.548985 514284.624985,144234.199985 514283.756985,144225.189985 514283.542985,144216.921985 514283.099985,144200.074985 514283.128985,144195.587985 514283.291985,144186.779985 514284.886985,144177.834985 514285.878985,144169.973985 514286.948985,144165.504985 514287.444985,144158.597985 514287.500985,144150.714985 514288.363985,144146.268985 514289.065985,144138.749985 514290.519985,144129.998985 514292.618985
 ,144122.836985 514294.931985,144118.663985 514296.619985,144116.254985 514315.702985,144113.154985 514338.329985,144110.932985 514350.449985,144109.642985 514359.358985,144103.633985 514384.235985,144100.698985 514392.568985,144099.732985 514399.419985,144098.307985 514417.516985,144097.345985 514425.834985,144096.877985 514434.147985,144095.446985 514450.289985,144095.470985 514467.498985,144095.977985 514472.854985,144095.698985 514478.235985,144090.849985 514512.499985,144086.867985 514532.967985,144086.837985 514540.297985,144083.986985 514558.486985,144082.564985 514573.165985,144082.617985 514579.549985,144083.019985 514582.853985,144084.070985 514587.218985,144088.382985 514601.055985,144090.700985 514599.014985,144094.407985 514596.448985,144099.296985 514594.867985,144103.775985 514594.417985,144104.772985 514593.932985,144108.205985 514590.960985,144109.332985 514588.480985,144110.651985 514584.097985,144115.058985 514573.308985,144115.953985 514570.340985,144117.115985 51
 4565.480985,144117.981985 514561.064985,144120.043985 514555.351985,144121.899985 514551.257985,144123.475985 514548.300985,144126.738985 514544.570985,144130.790985 514542.589985))");
-        GeomPtr g0(wktreader.read(wkt0));
-
-        // Buffer point with quadrant segments value (x4)
         int const segments = default_quadrant_segments * 4;
         BufferParameters params(segments);
         BufferOp op(g0.get(), params);
-        double const distance = -75.0;
+        double const distance = 0.0001;
         GeomPtr gBuffer(op.getResultGeometry(distance));
         ensure_not(gBuffer->isEmpty());
         ensure(gBuffer->isValid());
         ensure_equals(gBuffer->getGeometryTypeId(), geos::geom::GEOS_POLYGON);
-        ensure(gBuffer->getNumPoints() >= std::size_t(5));
+        ensure(gBuffer->getNumPoints() >= std::size_t(318));
     }
+}
 
-    // Test two ways of executing buffer operation
-    // Problems with BufferOp when using BufferParameters by Markus Meyer
-    // http://lists.osgeo.org/pipermail/geos-devel/2011-October/005507.html
-    template<>
-    template<>
-    void object::test<10>()
-    {
-        using geos::operation::buffer::BufferOp;
-        using geos::operation::buffer::BufferParameters;
-
-        // TODO: Replace with Markus Meyer's test geometry once received
-        std::string wkt0("POLYGON((144130.790985 514542.589985,144136.106985 514541.268985,144140.618985 514541.819985,144146.580985 514542.271985,144155.308985 514545.689985,144159.779985 514546.073985,144165.774985 514546.027985,144170.614985 514545.336985,144174.457985 514542.248985,144180.591985 514535.602985,144185.031985 514531.945985,144188.930985 514529.699985,144202.240985 514526.170985,144204.522985 514525.434985,144208.647985 514523.675985,144209.506985 514523.064985,144212.582985 514519.733985,144214.710985 514516.736985,144217.305985 514512.269985,144225.821985 514492.742985,144230.222985 514479.998985,144238.048985 514458.756985,144239.749985 514453.779985,144242.237985 514445.130985,144246.840985 514428.052985,144247.696985 514425.401985,144249.538985 514420.578985,144253.385985 514411.927985,144260.058985 514394.218985,144264.745985 514384.187985,144266.213985 514379.927985,144267.402985 514375.585985,144266.909985 514372.870985,144264.565985 514368.375985,144255.527
 985 514363.949985,144249.852985 514362.074985,144245.934985 514359.844985,144246.620985 514355.223985,144248.164985 514351.697985,144250.544985 514347.859985,144251.479985 514346.801985,144258.417985 514340.953985,144264.816985 514336.013985,144266.807985 514330.309985,144266.470985 514325.834985,144264.754985 514315.479985,144263.754985 514311.093985,144261.914985 514304.532985,144260.268985 514300.367985,144258.258985 514296.998985,144255.314985 514293.564985,144253.224985 514291.582985,144249.714985 514288.669985,144245.918985 514286.308985,144244.887985 514285.843985,144240.548985 514284.624985,144234.199985 514283.756985,144225.189985 514283.542985,144216.921985 514283.099985,144200.074985 514283.128985,144195.587985 514283.291985,144186.779985 514284.886985,144177.834985 514285.878985,144169.973985 514286.948985,144165.504985 514287.444985,144158.597985 514287.500985,144150.714985 514288.363985,144146.268985 514289.065985,144138.749985 514290.519985,144129.998985 514292.618985
 ,144122.836985 514294.931985,144118.663985 514296.619985,144116.254985 514315.702985,144113.154985 514338.329985,144110.932985 514350.449985,144109.642985 514359.358985,144103.633985 514384.235985,144100.698985 514392.568985,144099.732985 514399.419985,144098.307985 514417.516985,144097.345985 514425.834985,144096.877985 514434.147985,144095.446985 514450.289985,144095.470985 514467.498985,144095.977985 514472.854985,144095.698985 514478.235985,144090.849985 514512.499985,144086.867985 514532.967985,144086.837985 514540.297985,144083.986985 514558.486985,144082.564985 514573.165985,144082.617985 514579.549985,144083.019985 514582.853985,144084.070985 514587.218985,144088.382985 514601.055985,144090.700985 514599.014985,144094.407985 514596.448985,144099.296985 514594.867985,144103.775985 514594.417985,144104.772985 514593.932985,144108.205985 514590.960985,144109.332985 514588.480985,144110.651985 514584.097985,144115.058985 514573.308985,144115.953985 514570.340985,144117.115985 51
 4565.480985,144117.981985 514561.064985,144120.043985 514555.351985,144121.899985 514551.257985,144123.475985 514548.300985,144126.738985 514544.570985,144130.790985 514542.589985))");
-        GeomPtr g0(wktreader.read(wkt0));
-        ensure_equals(g0->getNumPoints(), std::size_t(112));
-
-        double const distance = -75.0;
-        int const segments = 16;
-
-        BufferParameters params1(segments, BufferParameters::CAP_ROUND);
-        BufferOp op1(g0.get(), params1);
-        GeomPtr gBuffer1(op1.getResultGeometry(distance));
-        ensure_not(gBuffer1->isEmpty());
-        ensure(gBuffer1->isValid());
-        ensure_equals(gBuffer1->getGeometryTypeId(), geos::geom::GEOS_POLYGON);
-        ensure(gBuffer1->getNumPoints() >= std::size_t(5));
-
-        GeomPtr gBuffer2(BufferOp::bufferOp(g0.get(), distance, segments, BufferParameters::CAP_ROUND));
-        ensure_not(gBuffer2->isEmpty());
-        ensure(gBuffer2->isValid());
-        ensure_equals(gBuffer2->getGeometryTypeId(), geos::geom::GEOS_POLYGON);
-        ensure(gBuffer2->getNumPoints() >= std::size_t(5));
-
-        ensure(gBuffer1->equals(gBuffer2.get()));
-        ensure(gBuffer2->equals(gBuffer1.get()));
-    }
-
-    // Test for ticket #473
-    template<>
-    template<>
-    void object::test<11>()
-    {
-        using geos::operation::buffer::BufferOp;
-        using geos::operation::buffer::BufferParameters;
+template<>
+template<>
+void object::test<5>
+()
+{
+    using geos::operation::buffer::BufferOp;
+    using geos::operation::buffer::BufferParameters;
+
+    // Geometry from XMLTester's TestBufferExternal2.xml, test case #31
+    std::string
+    wkt0("POLYGON((167187.935985 527215.129985,167246.663985 527205.580985,167280.107985 527210.602985,167314.083985 527213.149985,167354.196985 527218.563985,167363.609985 527204.834985,167358.459985 527177.204985,167344.405985 527172.240985,167323.325985 527164.793985,167304.557985 527167.748985,167285.789985 527170.703985,167260.854985 527176.007985,167211.198985 527149.591985,167165.408985 527140.439985,167141.660985 527146.308985,167119.062985 527137.503985,167119.967985 527139.010985,167078.296985 527188.560985,167105.238985 527267.140985,167090.957985 527316.213985,167094.770985 527321.819985,167082.593985 527377.599985,167065.952985 527417.668985,167056.312985 527449.383985,167043.546985 527485.510985,167019.927985 527525.916985,166982.769985 527539.710985,166961.717985 527606.388985,166933.263985 527657.009985,166899.206985 527710.191985,166916.325985 527722.287985,166973.067985 527744.810985,166978.160985 527695.099985,167043.308985 527684.770985,167080.550985 527644.94198
 5,167101.716985 527610.077985,167109.672985 527576.692985,167099.068985 527561.394985,167097.537985 527527.027985,167105.044985 527510.384985,167137.888985 527502.771985,167160.386985 527500.228985,167174.041985 527468.108985,167205.365985 527466.936985,167200.090985 527446.692985,167182.286985 527416.893985,167214.905985 527399.163985,167245.980985 527379.346985,167258.755985 527325.736985,167261.469985 527296.920985,167237.119985 527273.314985,167201.524985 527264.407985,167192.491985 527252.494985,167172.090985 527216.630985,167187.935985 527215.129985))");
+    GeomPtr g0(wktreader.read(wkt0));
+
+    // Buffer point with quadrant segments value (x4)
+    BufferParameters params(default_quadrant_segments * 4);
+    BufferOp op(g0.get(), params);
+    double const distance = -75.0;
+    GeomPtr gBuffer(op.getResultGeometry(distance));
+    ensure_not(gBuffer->isEmpty());
+    ensure(gBuffer->isValid());
+    ensure_equals(gBuffer->getGeometryTypeId(), geos::geom::GEOS_POLYGON);
+    ensure(gBuffer->getNumPoints() >= std::size_t(8));
+}
+
+template<>
+template<>
+void object::test<6>
+()
+{
+    using geos::operation::buffer::BufferOp;
+    using geos::operation::buffer::BufferParameters;
+
+    // Geometry from XMLTester's TestBufferExternal2.xml, test case #41
+    std::string
+    wkt0("POLYGON((148410.699985 522834.902985,148442.757985 522825.725985,148460.309985 522827.514985,148487.864985 522844.888985,148500.821985 522849.224985,148522.555985 522842.060985,148549.245985 522836.360985,148568.572985 522826.852985,148584.252985 522812.743985,148609.816985 522787.145985,148614.009985 522767.881985,148612.795985 522752.758985,148612.563985 522743.189985,148618.720985 522735.053985,148625.781585 522726.296485,148618.662985 522724.739985,148612.278985 522723.775985,148605.112985 522714.525985,148611.687985 522677.987985,148611.797985 522647.963985,148594.739985 522625.727985,148584.565985 522622.805985,148562.730985 522628.324985,148543.283985 522615.292985,148536.597985 522557.684985,148536.223985 522555.223985,148534.274985 522546.378985,148533.665985 522541.970985,148533.794985 522540.094985,148535.172985 522535.741985,148538.094985 522529.403985,148538.611985 522526.777985,148539.936985 522513.990985,148540.169985 522509.496985,148540.192985 522500.58998
 5,148540.851985 522495.877985,148540.474985 522491.607985,148539.391985 522489.734985,148536.121985 522486.259985,148532.239985 522483.953985,148529.487985 522487.690985,148527.557985 522489.161985,148523.269985 522490.157985,148512.547985 522491.130985,148508.089985 522491.855985,148503.708985 522492.860985,148499.171985 522494.926985,148493.577985 522498.401985,148488.746985 522500.495985,148483.626985 522501.803985,148480.736985 522503.655985,148464.117985 522534.086985,148427.843985 522552.590985,148408.790985 522571.476985,148398.223985 522596.340985,148407.833985 522615.400985,148416.753985 522662.875985,148420.236985 522689.856985,148421.081985 522713.013985,148415.508985 522722.819985,148391.177985 522725.213985,148358.228985 522724.834985,148355.953985 522741.826985,148341.696985 522767.846985,148328.778985 522795.425985,148312.269985 522806.114985,148322.213985 522836.436985,148339.137985 522884.626985,148351.181985 522896.189985,148376.682985 522893.652985,148389.158985 5
 22851.634985,148410.699985 522834.902985))");
+    GeomPtr g0(wktreader.read(wkt0));
+
+    // Buffer point with quadrant segments value (x4)
+    int const segments = default_quadrant_segments * 4;
+    BufferParameters params(segments);
+    BufferOp op(g0.get(), params);
+    double const distance = -75.0;
+    GeomPtr gBuffer(op.getResultGeometry(distance));
+    ensure_not(gBuffer->isEmpty());
+    ensure(gBuffer->isValid());
+    ensure_equals(gBuffer->getGeometryTypeId(), geos::geom::GEOS_POLYGON);
+    ensure(gBuffer->getNumPoints() >= std::size_t(51));
+}
+
+template<>
+template<>
+void object::test<7>
+()
+{
+    using geos::operation::buffer::BufferOp;
+    using geos::operation::buffer::BufferParameters;
+
+    // Geometry from XMLTester's TestBufferExternal2.xml, test case #42
+    std::string
+    wkt0("POLYGON((150213.068985 524020.273985,150226.206985 524020.218985,150245.019985 524022.421985,150248.570985 524017.633985,150243.628985 523991.402985,150233.942985 523969.968985,150203.852985 523929.546985,150189.509985 523905.746985,150179.578985 523905.795985,150163.996985 523891.573985,150150.529985 523872.591985,150158.960985 523848.710985,150150.727985 523827.265985,150129.075985 523796.394985,150110.126985 523782.119985,150064.853985 523787.149985,150051.774985 523791.993985,150035.273985 523796.784985,150034.124985 523803.948985,150047.317985 523842.088985,150048.538985 523846.850985,150048.758985 523856.362985,150044.002985 523858.774985,150033.285985 523861.216985,150022.584985 523866.044985,150013.239985 523875.626985,150010.897985 523882.801985,150007.322985 523904.295985,150015.725985 523913.798985,150028.883985 523920.894985,150036.292985 523937.604985,150033.171985 523964.012985,150028.264985 524013.973985,150020.417985 524042.804985,150014.532985 524064.42898
 5,150004.476985 524083.491985,149987.717985 524115.262985,149981.881985 524139.242985,149991.382985 524146.196985,150012.547985 524165.288985,150017.553385 524169.126585,150024.575985 524166.982985,150037.645985 524157.385985,150054.301985 524147.777985,150067.231985 524142.754985,150080.313985 524135.548985,150096.808985 524132.911985,150108.662985 524120.938985,150113.586985 524111.551985,150113.285985 524097.054985,150114.403985 524085.116985,150121.501985 524075.543985,150134.308985 524061.036985,150143.802985 524053.844985,150159.042985 524051.270985,150177.151985 524046.558985,150188.764985 524039.234985,150195.842985 524027.285985,150213.068985 524020.273985))");
+    GeomPtr g0(wktreader.read(wkt0));
+
+    // Buffer point with quadrant segments value (x4)
+    int const segments = default_quadrant_segments * 4;
+    BufferParameters params(segments);
+    BufferOp op(g0.get(), params);
+    double const distance = -75.0;
+    GeomPtr gBuffer(op.getResultGeometry(distance));
+    ensure_not(gBuffer->isEmpty());
+    ensure(gBuffer->isValid());
+    ensure_equals(gBuffer->getGeometryTypeId(), geos::geom::GEOS_POLYGON);
+    ensure(gBuffer->getNumPoints() >= std::size_t(24));
+}
+
+template<>
+template<>
+void object::test<8>
+()
+{
+    using geos::operation::buffer::BufferOp;
+    using geos::operation::buffer::BufferParameters;
+
+    // Geometry from XMLTester's TestBufferExternal2.xml, test case #98
+    std::string
+    wkt0("POLYGON((146978.395985 514128.105985,146993.088985 514109.724985,146990.935985 514109.919985,146986.515985 514108.676985,146984.834985 514107.491985,146981.559985 514104.355985,146978.605985 514100.856985,146976.054985 514097.475985,146971.011985 514090.004985,146967.745985 514085.474985,146964.701985 514082.154985,146959.542985 514075.969985,146956.337985 514072.894985,146952.680985 514071.027985,146947.749985 514069.211985,146939.485985 514065.648985,146927.297985 514062.022985,146919.855985 514059.063985,146915.584985 514057.875985,146911.533985 514057.834985,146907.047985 514058.932985,146902.995985 514060.801985,146899.081985 514063.093985,146893.310985 514066.882985,146889.708985 514069.594985,146885.365985 514073.314985,146874.977985 514084.255985,146871.396985 514088.322985,146864.758985 514096.561985,146858.269985 514103.545985,146851.525985 514109.507985,146845.834985 514113.792985,146843.682985 514115.048985,146833.562985 514120.296985,146827.089985 514122.41998
 5,146822.686985 514123.116985,146818.808985 514122.219985,146814.499985 514120.648985,146810.509985 514118.510985,146805.983985 514115.339985,146799.004985 514109.608985,146789.184985 514100.497985,146782.878985 514094.071985,146773.731985 514084.130985,146772.704985 514082.828985,146770.140985 514078.765985,146767.239985 514075.730985,146765.038985 514075.353985,146760.639985 514077.133985,146756.696985 514093.552985,146755.166985 514104.428985,146754.236985 514107.679985,146747.054985 514128.282985,146745.452985 514132.485985,146740.637985 514142.592985,146736.292985 514152.151985,146732.113985 514160.830985,146729.632985 514165.603985,146720.451985 514182.099985,146718.255985 514185.582985,146715.669985 514189.265985,146708.041985 514198.572985,146700.623985 514208.288985,146697.764985 514212.325985,146695.357985 514216.136985,146693.225985 514220.099985,146691.843985 514223.389985,146688.846985 514231.402985,146687.411985 514235.659985,146686.889985 514238.098985,146686.285985 5
 14244.852985,146686.270985 514253.857985,146686.450985 514255.277985,146686.301985 514260.300985,146683.033985 514264.144985,146683.155985 514265.983985,146682.338985 514271.113985,146682.374985 514276.109985,146680.337985 514280.147985,146677.579985 514283.544985,146668.796985 514293.186985,146665.431985 514297.393985,146661.798985 514300.600985,146659.382985 514304.403985,146657.401985 514310.058985,146656.451985 514315.110985,146657.862985 514320.479985,146660.328985 514325.311985,146664.346985 514327.493985,146671.146985 514330.078985,146674.727985 514332.813985,146678.721985 514337.242985,146681.490985 514340.795985,146686.032985 514347.673985,146690.888985 514355.863985,146692.808985 514359.916985,146693.698985 514363.305985,146695.616985 514373.416985,146698.231985 514382.035985,146699.836985 514386.527985,146701.571985 514390.707985,146703.974985 514394.998985,146706.750985 514398.590985,146710.002985 514401.691985,146712.889985 514403.299985,146717.072985 514405.089985,1467
 26.061985 514410.373985,146734.615985 514414.500985,146745.317985 514418.731985,146749.574985 514420.166985,146751.177985 514420.590985,146755.638985 514421.241985,146756.964985 514414.062985,146760.786985 514395.658985,146762.453985 514390.190985,146763.644985 514384.449985,146765.274985 514379.265985,146767.350985 514375.290985,146772.077985 514367.066985,146782.052985 514344.326985,146787.377985 514332.973985,146796.553985 514316.678985,146800.956985 514309.903985,146805.131985 514302.406985,146810.612985 514294.080985,146815.038985 514286.445985,146817.815985 514282.583985,146823.033985 514277.958985,146826.565985 514274.275985,146829.279985 514270.683985,146831.879985 514268.007985,146838.691985 514261.283985,146846.154985 514255.376985,146849.511985 514252.379985,146854.426985 514246.995985,146866.975985 514234.461985,146873.174985 514227.718985,146875.892985 514224.130985,146883.032985 514216.049985,146888.426985 514211.137985,146895.661985 514205.813985,146898.228985 514203.
 079985,146900.862985 514199.416985,146903.718985 514196.294985,146910.227985 514189.724985,146918.475985 514180.160985,146921.638985 514177.199985,146925.123985 514174.344985,146929.916985 514170.920985,146942.656985 514162.441985,146948.828985 514158.846985,146952.598985 514156.414985,146955.585985 514153.824985,146964.483985 514144.873985,146967.826985 514140.249985,146969.666985 514137.975985,146978.395985 514128.105985))");
+    GeomPtr g0(wktreader.read(wkt0));
+
+    // Buffer point with quadrant segments value (x4)
+    int const segments = default_quadrant_segments * 4;
+    BufferParameters params(segments);
+    BufferOp op(g0.get(), params);
+    double const distance = -75.0;
+    GeomPtr gBuffer(op.getResultGeometry(distance));
+    ensure_not(gBuffer->isEmpty());
+    ensure(gBuffer->isValid());
+    ensure_equals(gBuffer->getGeometryTypeId(), geos::geom::GEOS_POLYGON);
+    ensure(gBuffer->getNumPoints() >= std::size_t(7));
+}
+
+template<>
+template<>
+void object::test<9>
+()
+{
+    using geos::operation::buffer::BufferOp;
+    using geos::operation::buffer::BufferParameters;
+
+    // Geometry from XMLTester's TestBufferExternal2.xml, test case #99
+    std::string
+    wkt0("POLYGON((144130.790985 514542.589985,144136.106985 514541.268985,144140.618985 514541.819985,144146.580985 514542.271985,144155.308985 514545.689985,144159.779985 514546.073985,144165.774985 514546.027985,144170.614985 514545.336985,144174.457985 514542.248985,144180.591985 514535.602985,144185.031985 514531.945985,144188.930985 514529.699985,144202.240985 514526.170985,144204.522985 514525.434985,144208.647985 514523.675985,144209.506985 514523.064985,144212.582985 514519.733985,144214.710985 514516.736985,144217.305985 514512.269985,144225.821985 514492.742985,144230.222985 514479.998985,144238.048985 514458.756985,144239.749985 514453.779985,144242.237985 514445.130985,144246.840985 514428.052985,144247.696985 514425.401985,144249.538985 514420.578985,144253.385985 514411.927985,144260.058985 514394.218985,144264.745985 514384.187985,144266.213985 514379.927985,144267.402985 514375.585985,144266.909985 514372.870985,144264.565985 514368.375985,144255.527985 514363.94998
 5,144249.852985 514362.074985,144245.934985 514359.844985,144246.620985 514355.223985,144248.164985 514351.697985,144250.544985 514347.859985,144251.479985 514346.801985,144258.417985 514340.953985,144264.816985 514336.013985,144266.807985 514330.309985,144266.470985 514325.834985,144264.754985 514315.479985,144263.754985 514311.093985,144261.914985 514304.532985,144260.268985 514300.367985,144258.258985 514296.998985,144255.314985 514293.564985,144253.224985 514291.582985,144249.714985 514288.669985,144245.918985 514286.308985,144244.887985 514285.843985,144240.548985 514284.624985,144234.199985 514283.756985,144225.189985 514283.542985,144216.921985 514283.099985,144200.074985 514283.128985,144195.587985 514283.291985,144186.779985 514284.886985,144177.834985 514285.878985,144169.973985 514286.948985,144165.504985 514287.444985,144158.597985 514287.500985,144150.714985 514288.363985,144146.268985 514289.065985,144138.749985 514290.519985,144129.998985 514292.618985,144122.836985 5
 14294.931985,144118.663985 514296.619985,144116.254985 514315.702985,144113.154985 514338.329985,144110.932985 514350.449985,144109.642985 514359.358985,144103.633985 514384.235985,144100.698985 514392.568985,144099.732985 514399.419985,144098.307985 514417.516985,144097.345985 514425.834985,144096.877985 514434.147985,144095.446985 514450.289985,144095.470985 514467.498985,144095.977985 514472.854985,144095.698985 514478.235985,144090.849985 514512.499985,144086.867985 514532.967985,144086.837985 514540.297985,144083.986985 514558.486985,144082.564985 514573.165985,144082.617985 514579.549985,144083.019985 514582.853985,144084.070985 514587.218985,144088.382985 514601.055985,144090.700985 514599.014985,144094.407985 514596.448985,144099.296985 514594.867985,144103.775985 514594.417985,144104.772985 514593.932985,144108.205985 514590.960985,144109.332985 514588.480985,144110.651985 514584.097985,144115.058985 514573.308985,144115.953985 514570.340985,144117.115985 514565.480985,1441
 17.981985 514561.064985,144120.043985 514555.351985,144121.899985 514551.257985,144123.475985 514548.300985,144126.738985 514544.570985,144130.790985 514542.589985))");
+    GeomPtr g0(wktreader.read(wkt0));
+
+    // Buffer point with quadrant segments value (x4)
+    int const segments = default_quadrant_segments * 4;
+    BufferParameters params(segments);
+    BufferOp op(g0.get(), params);
+    double const distance = -75.0;
+    GeomPtr gBuffer(op.getResultGeometry(distance));
+    ensure_not(gBuffer->isEmpty());
+    ensure(gBuffer->isValid());
+    ensure_equals(gBuffer->getGeometryTypeId(), geos::geom::GEOS_POLYGON);
+    ensure(gBuffer->getNumPoints() >= std::size_t(5));
+}
+
+// Test two ways of executing buffer operation
+// Problems with BufferOp when using BufferParameters by Markus Meyer
+// http://lists.osgeo.org/pipermail/geos-devel/2011-October/005507.html
+template<>
+template<>
+void object::test<10>
+()
+{
+    using geos::operation::buffer::BufferOp;
+    using geos::operation::buffer::BufferParameters;
+
+    // TODO: Replace with Markus Meyer's test geometry once received
+    std::string
+    wkt0("POLYGON((144130.790985 514542.589985,144136.106985 514541.268985,144140.618985 514541.819985,144146.580985 514542.271985,144155.308985 514545.689985,144159.779985 514546.073985,144165.774985 514546.027985,144170.614985 514545.336985,144174.457985 514542.248985,144180.591985 514535.602985,144185.031985 514531.945985,144188.930985 514529.699985,144202.240985 514526.170985,144204.522985 514525.434985,144208.647985 514523.675985,144209.506985 514523.064985,144212.582985 514519.733985,144214.710985 514516.736985,144217.305985 514512.269985,144225.821985 514492.742985,144230.222985 514479.998985,144238.048985 514458.756985,144239.749985 514453.779985,144242.237985 514445.130985,144246.840985 514428.052985,144247.696985 514425.401985,144249.538985 514420.578985,144253.385985 514411.927985,144260.058985 514394.218985,144264.745985 514384.187985,144266.213985 514379.927985,144267.402985 514375.585985,144266.909985 514372.870985,144264.565985 514368.375985,144255.527985 514363.94998
 5,144249.852985 514362.074985,144245.934985 514359.844985,144246.620985 514355.223985,144248.164985 514351.697985,144250.544985 514347.859985,144251.479985 514346.801985,144258.417985 514340.953985,144264.816985 514336.013985,144266.807985 514330.309985,144266.470985 514325.834985,144264.754985 514315.479985,144263.754985 514311.093985,144261.914985 514304.532985,144260.268985 514300.367985,144258.258985 514296.998985,144255.314985 514293.564985,144253.224985 514291.582985,144249.714985 514288.669985,144245.918985 514286.308985,144244.887985 514285.843985,144240.548985 514284.624985,144234.199985 514283.756985,144225.189985 514283.542985,144216.921985 514283.099985,144200.074985 514283.128985,144195.587985 514283.291985,144186.779985 514284.886985,144177.834985 514285.878985,144169.973985 514286.948985,144165.504985 514287.444985,144158.597985 514287.500985,144150.714985 514288.363985,144146.268985 514289.065985,144138.749985 514290.519985,144129.998985 514292.618985,144122.836985 5
 14294.931985,144118.663985 514296.619985,144116.254985 514315.702985,144113.154985 514338.329985,144110.932985 514350.449985,144109.642985 514359.358985,144103.633985 514384.235985,144100.698985 514392.568985,144099.732985 514399.419985,144098.307985 514417.516985,144097.345985 514425.834985,144096.877985 514434.147985,144095.446985 514450.289985,144095.470985 514467.498985,144095.977985 514472.854985,144095.698985 514478.235985,144090.849985 514512.499985,144086.867985 514532.967985,144086.837985 514540.297985,144083.986985 514558.486985,144082.564985 514573.165985,144082.617985 514579.549985,144083.019985 514582.853985,144084.070985 514587.218985,144088.382985 514601.055985,144090.700985 514599.014985,144094.407985 514596.448985,144099.296985 514594.867985,144103.775985 514594.417985,144104.772985 514593.932985,144108.205985 514590.960985,144109.332985 514588.480985,144110.651985 514584.097985,144115.058985 514573.308985,144115.953985 514570.340985,144117.115985 514565.480985,1441
 17.981985 514561.064985,144120.043985 514555.351985,144121.899985 514551.257985,144123.475985 514548.300985,144126.738985 514544.570985,144130.790985 514542.589985))");
+    GeomPtr g0(wktreader.read(wkt0));
+    ensure_equals(g0->getNumPoints(), std::size_t(112));
+
+    double const distance = -75.0;
+    int const segments = 16;
+
+    BufferParameters params1(segments, BufferParameters::CAP_ROUND);
+    BufferOp op1(g0.get(), params1);
+    GeomPtr gBuffer1(op1.getResultGeometry(distance));
+    ensure_not(gBuffer1->isEmpty());
+    ensure(gBuffer1->isValid());
+    ensure_equals(gBuffer1->getGeometryTypeId(), geos::geom::GEOS_POLYGON);
+    ensure(gBuffer1->getNumPoints() >= std::size_t(5));
+
+    GeomPtr gBuffer2(BufferOp::bufferOp(g0.get(), distance, segments, BufferParameters::CAP_ROUND));
+    ensure_not(gBuffer2->isEmpty());
+    ensure(gBuffer2->isValid());
+    ensure_equals(gBuffer2->getGeometryTypeId(), geos::geom::GEOS_POLYGON);
+    ensure(gBuffer2->getNumPoints() >= std::size_t(5));
+
+    ensure(gBuffer1->equals(gBuffer2.get()));
+    ensure(gBuffer2->equals(gBuffer1.get()));
+}
+
+// Test for ticket #473
+template<>
+template<>
+void object::test<11>
+()
+{
+    using geos::operation::buffer::BufferOp;
+    using geos::operation::buffer::BufferParameters;
 
-        std::string wkt0("\
+    std::string wkt0("\
 MULTILINESTRING(  \
  (-22720.6801580484 130376.223341197, \
   -22620.6136206117 130339.222540348, \
@@ -336,20 +352,20 @@ MULTILINESTRING(  \
 )  \
       ");
 
-        GeomPtr g0(wktreader.read(wkt0));
+    GeomPtr g0(wktreader.read(wkt0));
 
-        BufferParameters params(8, BufferParameters::CAP_SQUARE,
-                              BufferParameters::JOIN_MITRE,
-                              1.0);
-        const double distance = 5.0;
-        BufferOp op(g0.get(), params);
-        GeomPtr gBuffer(op.getResultGeometry(distance));
+    BufferParameters params(8, BufferParameters::CAP_SQUARE,
+                            BufferParameters::JOIN_MITRE,
+                            1.0);
+    const double distance = 5.0;
+    BufferOp op(g0.get(), params);
+    GeomPtr gBuffer(op.getResultGeometry(distance));
 
-        // We're basically only interested an rough sense of a
-        // meaningful result.
-        ensure_equals(gBuffer->getNumPoints(), std::size_t(47));
-        ensure_equals(int(gBuffer->getArea()), 3520);
-    }
+    // We're basically only interested an rough sense of a
+    // meaningful result.
+    ensure_equals(gBuffer->getNumPoints(), std::size_t(47));
+    ensure_equals(int(gBuffer->getArea()), 3520);
+}
 
 } // namespace tut
 
diff --git a/tests/unit/operation/buffer/BufferParametersTest.cpp b/tests/unit/operation/buffer/BufferParametersTest.cpp
index 322aabd..16e8a2f 100644
--- a/tests/unit/operation/buffer/BufferParametersTest.cpp
+++ b/tests/unit/operation/buffer/BufferParametersTest.cpp
@@ -9,195 +9,203 @@
 // std
 #include <memory>
 
-namespace tut
+namespace tut {
+//
+// Test Group
+//
+
+// Common data used by tests
+struct test_bufferparameters_data {
+    typedef geos::operation::buffer::BufferParameters BufferParameters;
+
+    test_bufferparameters_data() { }
+
+private:
+    // noncopyable
+    test_bufferparameters_data(test_bufferparameters_data const& other) = delete;
+    test_bufferparameters_data& operator=(test_bufferparameters_data const& rhs) = delete;
+};
+
+typedef test_group<test_bufferparameters_data> group;
+typedef group::object object;
+
+group test_bufferparameters_group("geos::operation::buffer::BufferParameters");
+
+//
+// Test Cases
+//
+
+// Default constructor
+template<>
+template<>
+void object::test<1>
+()
+{
+    BufferParameters bp;
+
+    ensure_equals(bp.getEndCapStyle(), BufferParameters::CAP_ROUND);
+    ensure_equals(bp.getJoinStyle(), BufferParameters::JOIN_ROUND);
+    ensure_equals(bp.getMitreLimit(), 5.0);
+    ensure_equals(bp.getQuadrantSegments(), int(8));
+    ensure(! bp.isSingleSided());
+}
+
+// Constructor with single integer argument
+template<>
+template<>
+void object::test<2>
+()
+{
+    BufferParameters bp(16);
+
+    ensure_equals(bp.getEndCapStyle(), BufferParameters::CAP_ROUND);
+    ensure_equals(bp.getJoinStyle(), BufferParameters::JOIN_ROUND);
+    ensure_equals(bp.getMitreLimit(), 5.0);
+    ensure_equals(bp.getQuadrantSegments(), int(16));
+    ensure(! bp.isSingleSided());
+}
+
+// Constructor with quadrantSegments and EndCapStyle
+template<>
+template<>
+void object::test<3>
+()
+{
+    BufferParameters bp(16, BufferParameters::CAP_FLAT);
+
+    ensure_equals(bp.getEndCapStyle(), BufferParameters::CAP_FLAT);
+    ensure_equals(bp.getJoinStyle(), BufferParameters::JOIN_ROUND);
+    ensure_equals(bp.getMitreLimit(), 5.0);
+    ensure_equals(bp.getQuadrantSegments(), int(16));
+    ensure(! bp.isSingleSided());
+}
+
+// Constructor with quadrantSegments and EndCapStyle (2)
+template<>
+template<>
+void object::test<4>
+()
+{
+    BufferParameters bp(16, BufferParameters::CAP_ROUND);
+
+    ensure_equals(bp.getEndCapStyle(), BufferParameters::CAP_ROUND);
+    ensure_equals(bp.getJoinStyle(), BufferParameters::JOIN_ROUND);
+    ensure_equals(bp.getMitreLimit(), 5.0);
+    ensure_equals(bp.getQuadrantSegments(), int(16));
+    ensure(! bp.isSingleSided());
+}
+
+// Constructor with quadrantSegments, EndCapStyle, JoinStyle and mitreLimit
+template<>
+template<>
+void object::test<5>
+()
+{
+    BufferParameters bp(31, BufferParameters::CAP_SQUARE,
+                        BufferParameters::JOIN_MITRE,
+                        2.0);
+
+    ensure_equals(bp.getEndCapStyle(), BufferParameters::CAP_SQUARE);
+    ensure_equals(bp.getJoinStyle(), BufferParameters::JOIN_MITRE);
+    ensure_equals(bp.getMitreLimit(), 2.0);
+    ensure_equals(bp.getQuadrantSegments(), int(31));
+    ensure(! bp.isSingleSided());
+}
+
+// setQuadrantSegments and getQuadrantSegments
+template<>
+template<>
+void object::test<6>
+()
+{
+    BufferParameters bp;
+    ensure_equals(bp.getQuadrantSegments(), int(8));
+    bp.setQuadrantSegments(16);
+    ensure_equals(bp.getQuadrantSegments(), int(16));
+    bp.setQuadrantSegments(3);
+    ensure_equals(bp.getQuadrantSegments(), int(3));
+
+    ensure_equals(bp.getEndCapStyle(), BufferParameters::CAP_ROUND);
+    ensure_equals(bp.getJoinStyle(), BufferParameters::JOIN_ROUND);
+    ensure_equals(bp.getMitreLimit(), 5.0);
+    ensure(! bp.isSingleSided());
+}
+
+// setEndCapStyle and getEndCapStyle
+template<>
+template<>
+void object::test<7>
+()
+{
+    BufferParameters bp;
+    ensure_equals(bp.getEndCapStyle(), BufferParameters::CAP_ROUND);
+    bp.setEndCapStyle(BufferParameters::CAP_FLAT);
+    ensure_equals(bp.getEndCapStyle(), BufferParameters::CAP_FLAT);
+    bp.setEndCapStyle(BufferParameters::CAP_SQUARE);
+    ensure_equals(bp.getEndCapStyle(), BufferParameters::CAP_SQUARE);
+
+    ensure_equals(bp.getJoinStyle(), BufferParameters::JOIN_ROUND);
+    ensure_equals(bp.getMitreLimit(), 5.0);
+    ensure_equals(bp.getQuadrantSegments(), int(8));
+    ensure(! bp.isSingleSided());
+}
+
+// setJoinStyle and getJoinStyle
+template<>
+template<>
+void object::test<8>
+()
+{
+    BufferParameters bp;
+    ensure_equals(bp.getJoinStyle(), BufferParameters::JOIN_ROUND);
+    bp.setJoinStyle(BufferParameters::JOIN_MITRE);
+    ensure_equals(bp.getJoinStyle(), BufferParameters::JOIN_MITRE);
+    bp.setJoinStyle(BufferParameters::JOIN_BEVEL);
+    ensure_equals(bp.getJoinStyle(), BufferParameters::JOIN_BEVEL);
+
+    ensure_equals(bp.getEndCapStyle(), BufferParameters::CAP_ROUND);
+    ensure_equals(bp.getMitreLimit(), 5.0);
+    ensure_equals(bp.getQuadrantSegments(), int(8));
+    ensure(! bp.isSingleSided());
+}
+
+// setMitreLimit and getMitreLimit
+template<>
+template<>
+void object::test<9>
+()
+{
+    BufferParameters bp;
+    ensure_equals(bp.getMitreLimit(), 5.0);
+    bp.setMitreLimit(2.0);
+    ensure_equals(bp.getMitreLimit(), 2.0);
+    bp.setMitreLimit(10.12);
+    ensure_equals(bp.getMitreLimit(), 10.12);
+
+    ensure_equals(bp.getEndCapStyle(), BufferParameters::CAP_ROUND);
+    ensure_equals(bp.getJoinStyle(), BufferParameters::JOIN_ROUND);
+    ensure_equals(bp.getQuadrantSegments(), int(8));
+    ensure(! bp.isSingleSided());
+}
+
+// setSingleSided and getSingleSided
+template<>
+template<>
+void object::test<10>
+()
 {
-    //
-    // Test Group
-    //
-
-    // Common data used by tests
-    struct test_bufferparameters_data
-    {
-        typedef geos::operation::buffer::BufferParameters BufferParameters;
-
-        test_bufferparameters_data() { }
-
-    private:
-        // noncopyable
-        test_bufferparameters_data(test_bufferparameters_data const& other) = delete;
-        test_bufferparameters_data& operator=(test_bufferparameters_data const& rhs) = delete;
-    };
-
-    typedef test_group<test_bufferparameters_data> group;
-    typedef group::object object;
-
-    group test_bufferparameters_group("geos::operation::buffer::BufferParameters");
-
-    //
-    // Test Cases
-    //
-
-    // Default constructor
-    template<>
-    template<>
-    void object::test<1>()
-    {
-      BufferParameters bp;
-
-      ensure_equals( bp.getEndCapStyle(), BufferParameters::CAP_ROUND );
-      ensure_equals( bp.getJoinStyle(), BufferParameters::JOIN_ROUND );
-      ensure_equals( bp.getMitreLimit(), 5.0 );
-      ensure_equals( bp.getQuadrantSegments(), int(8) );
-      ensure( ! bp.isSingleSided() );
-    }
-
-    // Constructor with single integer argument
-    template<>
-    template<>
-    void object::test<2>()
-    {
-      BufferParameters bp(16);
-
-      ensure_equals( bp.getEndCapStyle(), BufferParameters::CAP_ROUND );
-      ensure_equals( bp.getJoinStyle(), BufferParameters::JOIN_ROUND );
-      ensure_equals( bp.getMitreLimit(), 5.0 );
-      ensure_equals( bp.getQuadrantSegments(), int(16) );
-      ensure( ! bp.isSingleSided() );
-    }
-
-    // Constructor with quadrantSegments and EndCapStyle
-    template<>
-    template<>
-    void object::test<3>()
-    {
-      BufferParameters bp(16, BufferParameters::CAP_FLAT);
-
-      ensure_equals( bp.getEndCapStyle(), BufferParameters::CAP_FLAT );
-      ensure_equals( bp.getJoinStyle(), BufferParameters::JOIN_ROUND );
-      ensure_equals( bp.getMitreLimit(), 5.0 );
-      ensure_equals( bp.getQuadrantSegments(), int(16) );
-      ensure( ! bp.isSingleSided() );
-    }
-
-    // Constructor with quadrantSegments and EndCapStyle (2)
-    template<>
-    template<>
-    void object::test<4>()
-    {
-      BufferParameters bp(16, BufferParameters::CAP_ROUND);
-
-      ensure_equals( bp.getEndCapStyle(), BufferParameters::CAP_ROUND );
-      ensure_equals( bp.getJoinStyle(), BufferParameters::JOIN_ROUND );
-      ensure_equals( bp.getMitreLimit(), 5.0 );
-      ensure_equals( bp.getQuadrantSegments(), int(16) );
-      ensure( ! bp.isSingleSided() );
-    }
-
-    // Constructor with quadrantSegments, EndCapStyle, JoinStyle and mitreLimit
-    template<>
-    template<>
-    void object::test<5>()
-    {
-      BufferParameters bp(31, BufferParameters::CAP_SQUARE,
-                              BufferParameters::JOIN_MITRE,
-                              2.0);
-
-      ensure_equals( bp.getEndCapStyle(), BufferParameters::CAP_SQUARE );
-      ensure_equals( bp.getJoinStyle(), BufferParameters::JOIN_MITRE );
-      ensure_equals( bp.getMitreLimit(), 2.0 );
-      ensure_equals( bp.getQuadrantSegments(), int(31) );
-      ensure( ! bp.isSingleSided() );
-    }
-
-    // setQuadrantSegments and getQuadrantSegments
-    template<>
-    template<>
-    void object::test<6>()
-    {
-      BufferParameters bp;
-      ensure_equals( bp.getQuadrantSegments(), int(8) );
-      bp.setQuadrantSegments(16);
-      ensure_equals( bp.getQuadrantSegments(), int(16) );
-      bp.setQuadrantSegments(3);
-      ensure_equals( bp.getQuadrantSegments(), int(3) );
-
-      ensure_equals( bp.getEndCapStyle(), BufferParameters::CAP_ROUND );
-      ensure_equals( bp.getJoinStyle(), BufferParameters::JOIN_ROUND );
-      ensure_equals( bp.getMitreLimit(), 5.0 );
-      ensure( ! bp.isSingleSided() );
-    }
-
-    // setEndCapStyle and getEndCapStyle
-    template<>
-    template<>
-    void object::test<7>()
-    {
-      BufferParameters bp;
-      ensure_equals( bp.getEndCapStyle(), BufferParameters::CAP_ROUND );
-      bp.setEndCapStyle( BufferParameters::CAP_FLAT );
-      ensure_equals( bp.getEndCapStyle(), BufferParameters::CAP_FLAT );
-      bp.setEndCapStyle( BufferParameters::CAP_SQUARE );
-      ensure_equals( bp.getEndCapStyle(), BufferParameters::CAP_SQUARE );
-
-      ensure_equals( bp.getJoinStyle(), BufferParameters::JOIN_ROUND );
-      ensure_equals( bp.getMitreLimit(), 5.0 );
-      ensure_equals( bp.getQuadrantSegments(), int(8) );
-      ensure( ! bp.isSingleSided() );
-    }
-
-    // setJoinStyle and getJoinStyle
-    template<>
-    template<>
-    void object::test<8>()
-    {
-      BufferParameters bp;
-      ensure_equals( bp.getJoinStyle(), BufferParameters::JOIN_ROUND );
-      bp.setJoinStyle( BufferParameters::JOIN_MITRE );
-      ensure_equals( bp.getJoinStyle(), BufferParameters::JOIN_MITRE );
-      bp.setJoinStyle( BufferParameters::JOIN_BEVEL );
-      ensure_equals( bp.getJoinStyle(), BufferParameters::JOIN_BEVEL );
-
-      ensure_equals( bp.getEndCapStyle(), BufferParameters::CAP_ROUND );
-      ensure_equals( bp.getMitreLimit(), 5.0 );
-      ensure_equals( bp.getQuadrantSegments(), int(8) );
-      ensure( ! bp.isSingleSided() );
-    }
-
-    // setMitreLimit and getMitreLimit
-    template<>
-    template<>
-    void object::test<9>()
-    {
-      BufferParameters bp;
-      ensure_equals( bp.getMitreLimit(), 5.0 );
-      bp.setMitreLimit( 2.0 );
-      ensure_equals( bp.getMitreLimit(), 2.0 );
-      bp.setMitreLimit( 10.12 );
-      ensure_equals( bp.getMitreLimit(), 10.12 );
-
-      ensure_equals( bp.getEndCapStyle(), BufferParameters::CAP_ROUND );
-      ensure_equals( bp.getJoinStyle(), BufferParameters::JOIN_ROUND );
-      ensure_equals( bp.getQuadrantSegments(), int(8) );
-      ensure( ! bp.isSingleSided() );
-    }
-
-    // setSingleSided and getSingleSided
-    template<>
-    template<>
-    void object::test<10>()
-    {
-      BufferParameters bp;
-      ensure( ! bp.isSingleSided() );
-      bp.setSingleSided( true );
-      ensure( bp.isSingleSided() );
-      bp.setSingleSided( false );
-      ensure( ! bp.isSingleSided() );
-
-      ensure_equals( bp.getEndCapStyle(), BufferParameters::CAP_ROUND );
-      ensure_equals( bp.getJoinStyle(), BufferParameters::JOIN_ROUND );
-      ensure_equals( bp.getQuadrantSegments(), int(8) );
-      ensure_equals( bp.getMitreLimit(), 5.0 );
-    }
+    BufferParameters bp;
+    ensure(! bp.isSingleSided());
+    bp.setSingleSided(true);
+    ensure(bp.isSingleSided());
+    bp.setSingleSided(false);
+    ensure(! bp.isSingleSided());
+
+    ensure_equals(bp.getEndCapStyle(), BufferParameters::CAP_ROUND);
+    ensure_equals(bp.getJoinStyle(), BufferParameters::JOIN_ROUND);
+    ensure_equals(bp.getQuadrantSegments(), int(8));
+    ensure_equals(bp.getMitreLimit(), 5.0);
+}
 
 } // namespace tut
 
diff --git a/tests/unit/operation/distance/DistanceOpTest.cpp b/tests/unit/operation/distance/DistanceOpTest.cpp
index f136da2..6408c87 100644
--- a/tests/unit/operation/distance/DistanceOpTest.cpp
+++ b/tests/unit/operation/distance/DistanceOpTest.cpp
@@ -19,471 +19,492 @@
 #include <string>
 #include <vector>
 
-namespace tut
-{
-	//
-	// Test Group
-	//
+namespace tut {
+//
+// Test Group
+//
 
-	// Common data used by tests
-	struct test_distanceop_data
-	{
-		geos::io::WKTReader wktreader;
+// Common data used by tests
+struct test_distanceop_data {
+    geos::io::WKTReader wktreader;
 
-		typedef geos::geom::Geometry::Ptr GeomPtr;
-		typedef std::unique_ptr<geos::geom::CoordinateSequence> CSPtr;
+    typedef geos::geom::Geometry::Ptr GeomPtr;
+    typedef std::unique_ptr<geos::geom::CoordinateSequence> CSPtr;
 
-		test_distanceop_data()
-            : wktreader()
-		{}
-	};
+    test_distanceop_data()
+        : wktreader()
+    {}
+};
 
-	typedef test_group<test_distanceop_data> group;
-	typedef group::object object;
+typedef test_group<test_distanceop_data> group;
+typedef group::object object;
 
-	group test_distanceop_group("geos::operation::distance::DistanceOp");
+group test_distanceop_group("geos::operation::distance::DistanceOp");
 
-	//
-	// Test Cases
-	//
-	template<>
-	template<>
-	void object::test<1>()
-	{
-		using geos::operation::distance::DistanceOp;
-		using geos::geom::Coordinate;
+//
+// Test Cases
+//
+template<>
+template<>
+void object::test<1>
+()
+{
+    using geos::operation::distance::DistanceOp;
+    using geos::geom::Coordinate;
 
-		std::string wkt0("POINT(0 0)");
-		std::string wkt1("POINT(10 0)");
-		GeomPtr g0(wktreader.read(wkt0));
-		GeomPtr g1(wktreader.read(wkt1));
+    std::string wkt0("POINT(0 0)");
+    std::string wkt1("POINT(10 0)");
+    GeomPtr g0(wktreader.read(wkt0));
+    GeomPtr g1(wktreader.read(wkt1));
 
-		DistanceOp dist(g0.get(), g1.get());
+    DistanceOp dist(g0.get(), g1.get());
 
-		ensure_equals(dist.distance(), 10);
+    ensure_equals(dist.distance(), 10);
 
-        	CSPtr cs ( dist.closestPoints());
-        	ensure_equals(cs->getAt(0), Coordinate(0, 0));
-        	ensure_equals(cs->getAt(1), Coordinate(10, 0));
-	}
+    CSPtr cs(dist.closestPoints());
+    ensure_equals(cs->getAt(0), Coordinate(0, 0));
+    ensure_equals(cs->getAt(1), Coordinate(10, 0));
+}
 
-	template<>
-	template<>
-	void object::test<2>()
-	{
-		using geos::operation::distance::DistanceOp;
-		using geos::geom::Coordinate;
+template<>
+template<>
+void object::test<2>
+()
+{
+    using geos::operation::distance::DistanceOp;
+    using geos::geom::Coordinate;
 
-		std::string wkt0("POINT(0 0)");
-		std::string wkt1("MULTIPOINT(10 0, 50 30)");
-		GeomPtr g0(wktreader.read(wkt0));
-		GeomPtr g1(wktreader.read(wkt1));
+    std::string wkt0("POINT(0 0)");
+    std::string wkt1("MULTIPOINT(10 0, 50 30)");
+    GeomPtr g0(wktreader.read(wkt0));
+    GeomPtr g1(wktreader.read(wkt1));
 
-		DistanceOp dist(g0.get(), g1.get());
+    DistanceOp dist(g0.get(), g1.get());
 
-		ensure_equals(dist.distance(), 10);
+    ensure_equals(dist.distance(), 10);
 
-        	CSPtr cs ( dist.closestPoints());
-        	ensure_equals(cs->getAt(0), Coordinate(0, 0));
-        	ensure_equals(cs->getAt(1), Coordinate(10, 0));
+    CSPtr cs(dist.closestPoints());
+    ensure_equals(cs->getAt(0), Coordinate(0, 0));
+    ensure_equals(cs->getAt(1), Coordinate(10, 0));
 
-	}
+}
 
-	template<>
-	template<>
-	void object::test<3>()
-	{
-		using geos::operation::distance::DistanceOp;
-		using geos::geom::Coordinate;
+template<>
+template<>
+void object::test<3>
+()
+{
+    using geos::operation::distance::DistanceOp;
+    using geos::geom::Coordinate;
 
-		std::string wkt0("POINT(3 0)");
-		std::string wkt1("LINESTRING(0 10, 50 10, 100 50)");
-		GeomPtr g0(wktreader.read(wkt0));
-		GeomPtr g1(wktreader.read(wkt1));
+    std::string wkt0("POINT(3 0)");
+    std::string wkt1("LINESTRING(0 10, 50 10, 100 50)");
+    GeomPtr g0(wktreader.read(wkt0));
+    GeomPtr g1(wktreader.read(wkt1));
 
-		DistanceOp dist(g0.get(), g1.get());
+    DistanceOp dist(g0.get(), g1.get());
 
-		ensure_equals(dist.distance(), 10);
+    ensure_equals(dist.distance(), 10);
 
-        	CSPtr cs ( dist.closestPoints());
-        	ensure_equals(cs->getAt(0), Coordinate(3, 0));
-        	ensure_equals(cs->getAt(1), Coordinate(3, 10));
+    CSPtr cs(dist.closestPoints());
+    ensure_equals(cs->getAt(0), Coordinate(3, 0));
+    ensure_equals(cs->getAt(1), Coordinate(3, 10));
 
-	}
+}
 
-	template<>
-	template<>
-	void object::test<4>()
-	{
-		using geos::operation::distance::DistanceOp;
-		using geos::geom::Coordinate;
+template<>
+template<>
+void object::test<4>
+()
+{
+    using geos::operation::distance::DistanceOp;
+    using geos::geom::Coordinate;
 
-		std::string wkt0("POINT(3 0)");
-		std::string wkt1("MULTILINESTRING((34 54, 60 34),(0 10, 50 10, 100 50))");
-		GeomPtr g0(wktreader.read(wkt0));
-		GeomPtr g1(wktreader.read(wkt1));
+    std::string wkt0("POINT(3 0)");
+    std::string wkt1("MULTILINESTRING((34 54, 60 34),(0 10, 50 10, 100 50))");
+    GeomPtr g0(wktreader.read(wkt0));
+    GeomPtr g1(wktreader.read(wkt1));
 
-		DistanceOp dist(g0.get(), g1.get());
+    DistanceOp dist(g0.get(), g1.get());
 
-		ensure_equals(dist.distance(), 10);
+    ensure_equals(dist.distance(), 10);
 
-        	CSPtr cs ( dist.closestPoints());
-        	ensure_equals(cs->getAt(0), Coordinate(3, 0));
-        	ensure_equals(cs->getAt(1), Coordinate(3, 10));
+    CSPtr cs(dist.closestPoints());
+    ensure_equals(cs->getAt(0), Coordinate(3, 0));
+    ensure_equals(cs->getAt(1), Coordinate(3, 10));
 
-	}
+}
 
-	template<>
-	template<>
-	void object::test<5>()
-	{
-		using geos::operation::distance::DistanceOp;
-		using geos::geom::Coordinate;
+template<>
+template<>
+void object::test<5>
+()
+{
+    using geos::operation::distance::DistanceOp;
+    using geos::geom::Coordinate;
 
-		std::string wkt0("POINT(35 60)");
-		std::string wkt1("POLYGON((34 54, 60 34, 60 54, 34 54),(50 50, 52 50, 52 48, 50 48, 50 50))");
-		GeomPtr g0(wktreader.read(wkt0));
-		GeomPtr g1(wktreader.read(wkt1));
+    std::string wkt0("POINT(35 60)");
+    std::string wkt1("POLYGON((34 54, 60 34, 60 54, 34 54),(50 50, 52 50, 52 48, 50 48, 50 50))");
+    GeomPtr g0(wktreader.read(wkt0));
+    GeomPtr g1(wktreader.read(wkt1));
 
-		DistanceOp dist(g0.get(), g1.get());
+    DistanceOp dist(g0.get(), g1.get());
 
-		ensure_equals(dist.distance(), 6);
+    ensure_equals(dist.distance(), 6);
 
-        	CSPtr cs ( dist.closestPoints());
-        	ensure_equals(cs->getAt(0), Coordinate(35, 60));
-        	ensure_equals(cs->getAt(1), Coordinate(35, 54));
+    CSPtr cs(dist.closestPoints());
+    ensure_equals(cs->getAt(0), Coordinate(35, 60));
+    ensure_equals(cs->getAt(1), Coordinate(35, 54));
 
-	}
+}
 
-	template<>
-	template<>
-	void object::test<6>()
-	{
-		using geos::operation::distance::DistanceOp;
-		using geos::geom::Coordinate;
+template<>
+template<>
+void object::test<6>
+()
+{
+    using geos::operation::distance::DistanceOp;
+    using geos::geom::Coordinate;
 
-		std::string wkt0("POINT(35 60)");
-		std::string wkt1("MULTIPOLYGON(((34 54, 60 34, 60 54, 34 54),(50 50, 52 50, 52 48, 50 48, 50 50)),( (100 100, 150 100, 150 150, 100 150, 100 100),(120 120, 120 130, 130 130, 130 120, 120 120)) ))");
-		GeomPtr g0(wktreader.read(wkt0));
-		GeomPtr g1(wktreader.read(wkt1));
+    std::string wkt0("POINT(35 60)");
+    std::string
+    wkt1("MULTIPOLYGON(((34 54, 60 34, 60 54, 34 54),(50 50, 52 50, 52 48, 50 48, 50 50)),( (100 100, 150 100, 150 150, 100 150, 100 100),(120 120, 120 130, 130 130, 130 120, 120 120)) ))");
+    GeomPtr g0(wktreader.read(wkt0));
+    GeomPtr g1(wktreader.read(wkt1));
 
-		DistanceOp dist(g0.get(), g1.get());
+    DistanceOp dist(g0.get(), g1.get());
 
-		ensure_equals(dist.distance(), 6);
+    ensure_equals(dist.distance(), 6);
 
-        	CSPtr cs ( dist.closestPoints());
-        	ensure_equals(cs->getAt(0), Coordinate(35, 60));
-        	ensure_equals(cs->getAt(1), Coordinate(35, 54));
+    CSPtr cs(dist.closestPoints());
+    ensure_equals(cs->getAt(0), Coordinate(35, 60));
+    ensure_equals(cs->getAt(1), Coordinate(35, 54));
 
-	}
+}
 
-	template<>
-	template<>
-	void object::test<7>()
-	{
-		using geos::operation::distance::DistanceOp;
-		using geos::geom::Coordinate;
+template<>
+template<>
+void object::test<7>
+()
+{
+    using geos::operation::distance::DistanceOp;
+    using geos::geom::Coordinate;
 
-		std::string wkt0("POINT(35 60)");
+    std::string wkt0("POINT(35 60)");
 
-		// This is an invalid geom... anyway
-		std::string wkt1("GEOMETRYCOLLECTION(MULTIPOLYGON(((34 54, 60 34, 60 54, 34 54),(50 50, 52 50, 52 48, 50 48, 50 50)),( (100 100, 150 100, 150 150, 100 150, 100 100),(120 120, 120 130, 130 130, 130 120, 120 120)) )), POLYGON((34 54, 60 34, 60 54, 34 54),(50 50, 52 50, 52 48, 50 48, 50 50)), MULTILINESTRING((34 54, 60 34),(0 10, 50 10, 100 50)), LINESTRING(0 10, 50 10, 100 50), MULTIPOINT(10 0, 50 30), POINT(10 0))");
+    // This is an invalid geom... anyway
+    std::string
+    wkt1("GEOMETRYCOLLECTION(MULTIPOLYGON(((34 54, 60 34, 60 54, 34 54),(50 50, 52 50, 52 48, 50 48, 50 50)),( (100 100, 150 100, 150 150, 100 150, 100 100),(120 120, 120 130, 130 130, 130 120, 120 120)) )), POLYGON((34 54, 60 34, 60 54, 34 54),(50 50, 52 50, 52 48, 50 48, 50 50)), MULTILINESTRING((34 54, 60 34),(0 10, 50 10, 100 50)), LINESTRING(0 10, 50 10, 100 50), MULTIPOINT(10 0, 50 30), POINT(10 0))");
 
-		GeomPtr g0(wktreader.read(wkt0));
-		GeomPtr g1(wktreader.read(wkt1));
+    GeomPtr g0(wktreader.read(wkt0));
+    GeomPtr g1(wktreader.read(wkt1));
 
-		DistanceOp dist(g0.get(), g1.get());
+    DistanceOp dist(g0.get(), g1.get());
 
-		ensure_equals(dist.distance(), 6);
+    ensure_equals(dist.distance(), 6);
 
-        	CSPtr cs ( dist.closestPoints());
-        	ensure_equals(cs->getAt(0), Coordinate(35, 60));
-        	ensure_equals(cs->getAt(1), Coordinate(35, 54));
-	}
+    CSPtr cs(dist.closestPoints());
+    ensure_equals(cs->getAt(0), Coordinate(35, 60));
+    ensure_equals(cs->getAt(1), Coordinate(35, 54));
+}
 
-	template<>
-	template<>
-	void object::test<8>()
-	{
-		using geos::operation::distance::DistanceOp;
-		using geos::geom::Coordinate;
+template<>
+template<>
+void object::test<8>
+()
+{
+    using geos::operation::distance::DistanceOp;
+    using geos::geom::Coordinate;
 
-		std::string wkt0("POINT(35 60)");
+    std::string wkt0("POINT(35 60)");
 
-		// This is an invalid geom... anyway
-		std::string wkt1("GEOMETRYCOLLECTION EMPTY");
+    // This is an invalid geom... anyway
+    std::string wkt1("GEOMETRYCOLLECTION EMPTY");
 
-		GeomPtr g0(wktreader.read(wkt0));
-		GeomPtr g1(wktreader.read(wkt1));
+    GeomPtr g0(wktreader.read(wkt0));
+    GeomPtr g1(wktreader.read(wkt1));
 
-		DistanceOp dist(g0.get(), g1.get());
+    DistanceOp dist(g0.get(), g1.get());
 
-		ensure_equals(dist.distance(), 0);
+    ensure_equals(dist.distance(), 0);
 
-		ensure_equals(dist.closestPoints(), (void*)nullptr);
-	}
+    ensure_equals(dist.closestPoints(), (void*)nullptr);
+}
 
-	template<>
-	template<>
-	void object::test<9>()
-	{
-		using geos::operation::distance::DistanceOp;
-		using geos::geom::Coordinate;
+template<>
+template<>
+void object::test<9>
+()
+{
+    using geos::operation::distance::DistanceOp;
+    using geos::geom::Coordinate;
 
-		std::string wkt0("MULTIPOINT(10 0, 50 30)");
-		std::string wkt1("POINT(10 0)");
-		GeomPtr g0(wktreader.read(wkt0));
-		GeomPtr g1(wktreader.read(wkt1));
+    std::string wkt0("MULTIPOINT(10 0, 50 30)");
+    std::string wkt1("POINT(10 0)");
+    GeomPtr g0(wktreader.read(wkt0));
+    GeomPtr g1(wktreader.read(wkt1));
 
-		DistanceOp dist(g0.get(), g1.get());
+    DistanceOp dist(g0.get(), g1.get());
 
-		ensure_equals(dist.distance(), 0);
+    ensure_equals(dist.distance(), 0);
 
-        	CSPtr cs ( dist.closestPoints());
-        	ensure_equals(cs->getAt(0), Coordinate(10, 0));
-        	ensure_equals(cs->getAt(1), Coordinate(10, 0));
+    CSPtr cs(dist.closestPoints());
+    ensure_equals(cs->getAt(0), Coordinate(10, 0));
+    ensure_equals(cs->getAt(1), Coordinate(10, 0));
 
-	}
+}
 
-	template<>
-	template<>
-	void object::test<10>()
-	{
-		using geos::operation::distance::DistanceOp;
-		using geos::geom::Coordinate;
+template<>
+template<>
+void object::test<10>
+()
+{
+    using geos::operation::distance::DistanceOp;
+    using geos::geom::Coordinate;
 
-		std::string wkt0("MULTIPOINT(10 0, 50 30)");
-		std::string wkt1("MULTIPOINT(0 0, 150 30)");
-		GeomPtr g0(wktreader.read(wkt0));
-		GeomPtr g1(wktreader.read(wkt1));
+    std::string wkt0("MULTIPOINT(10 0, 50 30)");
+    std::string wkt1("MULTIPOINT(0 0, 150 30)");
+    GeomPtr g0(wktreader.read(wkt0));
+    GeomPtr g1(wktreader.read(wkt1));
 
-		DistanceOp dist(g0.get(), g1.get());
+    DistanceOp dist(g0.get(), g1.get());
 
-		ensure_equals(dist.distance(), 10);
+    ensure_equals(dist.distance(), 10);
 
-        	CSPtr cs ( dist.closestPoints());
-        	ensure_equals(cs->getAt(0), Coordinate(10, 0));
-        	ensure_equals(cs->getAt(1), Coordinate(0, 0));
+    CSPtr cs(dist.closestPoints());
+    ensure_equals(cs->getAt(0), Coordinate(10, 0));
+    ensure_equals(cs->getAt(1), Coordinate(0, 0));
 
-	}
+}
 
-	template<>
-	template<>
-	void object::test<11>()
-	{
-		using geos::operation::distance::DistanceOp;
-		using geos::geom::Coordinate;
+template<>
+template<>
+void object::test<11>
+()
+{
+    using geos::operation::distance::DistanceOp;
+    using geos::geom::Coordinate;
+
+    std::string wkt0("MULTIPOINT(3 0, 200 30)");
+    std::string wkt1("LINESTRING(0 10, 50 10, 100 50)");
+    GeomPtr g0(wktreader.read(wkt0));
+    GeomPtr g1(wktreader.read(wkt1));
+
+    DistanceOp dist(g0.get(), g1.get());
+
+    ensure_equals(dist.distance(), 10);
 
-		std::string wkt0("MULTIPOINT(3 0, 200 30)");
-		std::string wkt1("LINESTRING(0 10, 50 10, 100 50)");
-		GeomPtr g0(wktreader.read(wkt0));
-		GeomPtr g1(wktreader.read(wkt1));
+    CSPtr cs(dist.closestPoints());
+    ensure_equals(cs->getAt(0), Coordinate(3, 0));
+    ensure_equals(cs->getAt(1), Coordinate(3, 10));
+
+}
+
+template<>
+template<>
+void object::test<12>
+()
+{
+    using geos::operation::distance::DistanceOp;
+    using geos::geom::Coordinate;
 
-		DistanceOp dist(g0.get(), g1.get());
+    std::string wkt0("MULTIPOINT(3 0, -50 30)");
+    std::string wkt1("MULTILINESTRING((34 54, 60 34),(0 10, 50 10, 100 50))");
+    GeomPtr g0(wktreader.read(wkt0));
+    GeomPtr g1(wktreader.read(wkt1));
 
-		ensure_equals(dist.distance(), 10);
+    DistanceOp dist(g0.get(), g1.get());
 
-        	CSPtr cs ( dist.closestPoints());
-        	ensure_equals(cs->getAt(0), Coordinate(3, 0));
-        	ensure_equals(cs->getAt(1), Coordinate(3, 10));
+    ensure_equals(dist.distance(), 10);
 
-	}
+    CSPtr cs(dist.closestPoints());
+    ensure_equals(cs->getAt(0), Coordinate(3, 0));
+    ensure_equals(cs->getAt(1), Coordinate(3, 10));
 
-	template<>
-	template<>
-	void object::test<12>()
-	{
-		using geos::operation::distance::DistanceOp;
-		using geos::geom::Coordinate;
+}
 
-		std::string wkt0("MULTIPOINT(3 0, -50 30)");
-		std::string wkt1("MULTILINESTRING((34 54, 60 34),(0 10, 50 10, 100 50))");
-		GeomPtr g0(wktreader.read(wkt0));
-		GeomPtr g1(wktreader.read(wkt1));
+template<>
+template<>
+void object::test<13>
+()
+{
+    using geos::operation::distance::DistanceOp;
+    using geos::geom::Coordinate;
 
-		DistanceOp dist(g0.get(), g1.get());
+    std::string wkt0("MULTIPOINT(-100 0, 35 60)");
+    std::string wkt1("POLYGON((34 54, 60 34, 60 54, 34 54),(50 50, 52 50, 52 48, 50 48, 50 50))");
+    GeomPtr g0(wktreader.read(wkt0));
+    GeomPtr g1(wktreader.read(wkt1));
 
-		ensure_equals(dist.distance(), 10);
+    DistanceOp dist(g0.get(), g1.get());
 
-        	CSPtr cs ( dist.closestPoints());
-        	ensure_equals(cs->getAt(0), Coordinate(3, 0));
-        	ensure_equals(cs->getAt(1), Coordinate(3, 10));
+    ensure_equals(dist.distance(), 6);
 
-	}
+    CSPtr cs(dist.closestPoints());
+    ensure_equals(cs->getAt(0), Coordinate(35, 60));
+    ensure_equals(cs->getAt(1), Coordinate(35, 54));
 
-	template<>
-	template<>
-	void object::test<13>()
-	{
-		using geos::operation::distance::DistanceOp;
-		using geos::geom::Coordinate;
+}
 
-		std::string wkt0("MULTIPOINT(-100 0, 35 60)");
-		std::string wkt1("POLYGON((34 54, 60 34, 60 54, 34 54),(50 50, 52 50, 52 48, 50 48, 50 50))");
-		GeomPtr g0(wktreader.read(wkt0));
-		GeomPtr g1(wktreader.read(wkt1));
+template<>
+template<>
+void object::test<14>
+()
+{
+    using geos::operation::distance::DistanceOp;
+    using geos::geom::Coordinate;
 
-		DistanceOp dist(g0.get(), g1.get());
+    std::string wkt0("MULTIPOINT(-100 0, 35 60)");
+    std::string
+    wkt1("MULTIPOLYGON(((34 54, 60 34, 60 54, 34 54),(50 50, 52 50, 52 48, 50 48, 50 50)),( (100 100, 150 100, 150 150, 100 150, 100 100),(120 120, 120 130, 130 130, 130 120, 120 120)) ))");
+    GeomPtr g0(wktreader.read(wkt0));
+    GeomPtr g1(wktreader.read(wkt1));
 
-		ensure_equals(dist.distance(), 6);
+    DistanceOp dist(g0.get(), g1.get());
 
-        	CSPtr cs ( dist.closestPoints());
-        	ensure_equals(cs->getAt(0), Coordinate(35, 60));
-        	ensure_equals(cs->getAt(1), Coordinate(35, 54));
+    ensure_equals(dist.distance(), 6);
 
-	}
+    CSPtr cs(dist.closestPoints());
+    ensure_equals(cs->getAt(0), Coordinate(35, 60));
+    ensure_equals(cs->getAt(1), Coordinate(35, 54));
+}
 
-	template<>
-	template<>
-	void object::test<14>()
-	{
-		using geos::operation::distance::DistanceOp;
-		using geos::geom::Coordinate;
+template<>
+template<>
+void object::test<15>
+()
+{
+    using geos::operation::distance::DistanceOp;
+    using geos::geom::Coordinate;
 
-		std::string wkt0("MULTIPOINT(-100 0, 35 60)");
-		std::string wkt1("MULTIPOLYGON(((34 54, 60 34, 60 54, 34 54),(50 50, 52 50, 52 48, 50 48, 50 50)),( (100 100, 150 100, 150 150, 100 150, 100 100),(120 120, 120 130, 130 130, 130 120, 120 120)) ))");
-		GeomPtr g0(wktreader.read(wkt0));
-		GeomPtr g1(wktreader.read(wkt1));
+    std::string wkt0("MULTIPOINT(-100 0, 35 60)");
 
-		DistanceOp dist(g0.get(), g1.get());
+    // This is an invalid geom... anyway
+    std::string
+    wkt1("GEOMETRYCOLLECTION(MULTIPOLYGON(((34 54, 60 34, 60 54, 34 54),(50 50, 52 50, 52 48, 50 48, 50 50)),( (100 100, 150 100, 150 150, 100 150, 100 100),(120 120, 120 130, 130 130, 130 120, 120 120)) )), POLYGON((34 54, 60 34, 60 54, 34 54),(50 50, 52 50, 52 48, 50 48, 50 50)), MULTILINESTRING((34 54, 60 34),(0 10, 50 10, 100 50)), LINESTRING(0 10, 50 10, 100 50), MULTIPOINT(10 0, 50 30), POINT(10 0))");
 
-		ensure_equals(dist.distance(), 6);
+    GeomPtr g0(wktreader.read(wkt0));
+    GeomPtr g1(wktreader.read(wkt1));
 
-        	CSPtr cs ( dist.closestPoints());
-        	ensure_equals(cs->getAt(0), Coordinate(35, 60));
-        	ensure_equals(cs->getAt(1), Coordinate(35, 54));
-	}
+    DistanceOp dist(g0.get(), g1.get());
 
-	template<>
-	template<>
-	void object::test<15>()
-	{
-		using geos::operation::distance::DistanceOp;
-		using geos::geom::Coordinate;
+    ensure_equals(dist.distance(), 6);
 
-		std::string wkt0("MULTIPOINT(-100 0, 35 60)");
+    CSPtr cs(dist.closestPoints());
+    ensure_equals(cs->getAt(0), Coordinate(35, 60));
+    ensure_equals(cs->getAt(1), Coordinate(35, 54));
 
-		// This is an invalid geom... anyway
-		std::string wkt1("GEOMETRYCOLLECTION(MULTIPOLYGON(((34 54, 60 34, 60 54, 34 54),(50 50, 52 50, 52 48, 50 48, 50 50)),( (100 100, 150 100, 150 150, 100 150, 100 100),(120 120, 120 130, 130 130, 130 120, 120 120)) )), POLYGON((34 54, 60 34, 60 54, 34 54),(50 50, 52 50, 52 48, 50 48, 50 50)), MULTILINESTRING((34 54, 60 34),(0 10, 50 10, 100 50)), LINESTRING(0 10, 50 10, 100 50), MULTIPOINT(10 0, 50 30), POINT(10 0))");
+}
 
-		GeomPtr g0(wktreader.read(wkt0));
-		GeomPtr g1(wktreader.read(wkt1));
+template<>
+template<>
+void object::test<16>
+()
+{
+    using geos::operation::distance::DistanceOp;
+    using geos::geom::Coordinate;
 
-		DistanceOp dist(g0.get(), g1.get());
+    std::string wkt0("MULTIPOINT(-100 0, 35 60)");
 
-		ensure_equals(dist.distance(), 6);
+    // This is an invalid geom... anyway
+    std::string wkt1("GEOMETRYCOLLECTION EMPTY");
 
-        	CSPtr cs ( dist.closestPoints());
-        	ensure_equals(cs->getAt(0), Coordinate(35, 60));
-        	ensure_equals(cs->getAt(1), Coordinate(35, 54));
+    GeomPtr g0(wktreader.read(wkt0));
+    GeomPtr g1(wktreader.read(wkt1));
 
-	}
+    DistanceOp dist(g0.get(), g1.get());
 
-	template<>
-	template<>
-	void object::test<16>()
-	{
-		using geos::operation::distance::DistanceOp;
-		using geos::geom::Coordinate;
+    ensure_equals(dist.distance(), 0);
 
-		std::string wkt0("MULTIPOINT(-100 0, 35 60)");
+    ensure_equals(dist.closestPoints(), (void*)nullptr);
 
-		// This is an invalid geom... anyway
-		std::string wkt1("GEOMETRYCOLLECTION EMPTY");
+}
 
-		GeomPtr g0(wktreader.read(wkt0));
-		GeomPtr g1(wktreader.read(wkt1));
+// Test for crash reported in Ticket #236:
+// http://trac.osgeo.org/geos/ticket/236
+template<>
+template<>
+void object::test<17>
+()
+{
+    using geos::operation::distance::DistanceOp;
+    using geos::geom::Coordinate;
 
-		DistanceOp dist(g0.get(), g1.get());
+    std::string wkt0("POLYGON((0 0, 0 1, 1 1, 1 0, 0 0))");
+    std::string wkt1("POLYGON((1.25 0.25, 1.25 0.75, 1.75 0.75, 1.75 0.25, 1.25 0.25))");
 
-		ensure_equals(dist.distance(), 0);
+    GeomPtr g0(wktreader.read(wkt0));
+    GeomPtr g1(wktreader.read(wkt1));
 
-        	ensure_equals(dist.closestPoints(), (void*)nullptr);
+    DistanceOp dist(g0.get(), g1.get());
+    ensure_equals(dist.distance(), 0.25);
 
-	}
+    CSPtr cs(dist.closestPoints());
+    ensure_equals(cs->getAt(0), Coordinate(1, 0.25));
+    ensure_equals(cs->getAt(1), Coordinate(1.25, 0.25));
+}
 
-    // Test for crash reported in Ticket #236:
-    // http://trac.osgeo.org/geos/ticket/236
-	template<>
-	template<>
-	void object::test<17>()
-	{
-		using geos::operation::distance::DistanceOp;
-		using geos::geom::Coordinate;
+// Test for isWithinDistance
+template<>
+template<>
+void object::test<18>
+()
+{
+    using geos::operation::distance::DistanceOp;
+    using geos::geom::Coordinate;
 
-		std::string wkt0("POLYGON((0 0, 0 1, 1 1, 1 0, 0 0))");
-		std::string wkt1("POLYGON((1.25 0.25, 1.25 0.75, 1.75 0.75, 1.75 0.25, 1.25 0.25))");
+    std::string wkt0("POLYGON((0 0, 0 1, 1 1, 1 0, 0 0))");
+    std::string wkt1("POLYGON((1.25 0.25, 1.25 0.75, 1.75 0.75, 1.75 0.25, 1.25 0.25))");
 
-		GeomPtr g0(wktreader.read(wkt0));
-		GeomPtr g1(wktreader.read(wkt1));
+    GeomPtr g0(wktreader.read(wkt0));
+    GeomPtr g1(wktreader.read(wkt1));
 
-		DistanceOp dist(g0.get(), g1.get());
-		ensure_equals(dist.distance(), 0.25);
+    ensure_equals(DistanceOp::distance(*g0, *g1), 0.25);
+    ensure(DistanceOp::isWithinDistance(*g0, *g1, 0.26));
+    ensure(!DistanceOp::isWithinDistance(*g0, *g1, 0.24));
 
-        	CSPtr cs ( dist.closestPoints());
-		ensure_equals(cs->getAt(0), Coordinate(1, 0.25));
-		ensure_equals(cs->getAt(1), Coordinate(1.25, 0.25));
-	}
+    wkt0 = "LINESTRING(0 0, 0 1, 1 1, 1 0, 0 0)";
+    wkt1 = "LINESTRING(2 0, 10 1, 10 10)";
+    g0.reset(wktreader.read(wkt0));
+    g1.reset(wktreader.read(wkt1));
 
-	// Test for isWithinDistance
-	template<>
-	template<>
-	void object::test<18>()
-	{
-		using geos::operation::distance::DistanceOp;
-		using geos::geom::Coordinate;
-
-		std::string wkt0("POLYGON((0 0, 0 1, 1 1, 1 0, 0 0))");
-		std::string wkt1("POLYGON((1.25 0.25, 1.25 0.75, 1.75 0.75, 1.75 0.25, 1.25 0.25))");
-
-		GeomPtr g0(wktreader.read(wkt0));
-		GeomPtr g1(wktreader.read(wkt1));
+    ensure_equals(DistanceOp::distance(*g0, *g1), 1);
+    ensure(DistanceOp::isWithinDistance(*g0, *g1, 2));
+    ensure(!DistanceOp::isWithinDistance(*g0, *g1, 0.8));
 
-		ensure_equals(DistanceOp::distance(*g0, *g1), 0.25);
-		ensure(DistanceOp::isWithinDistance(*g0, *g1, 0.26));
-		ensure(!DistanceOp::isWithinDistance(*g0, *g1, 0.24));
+    // TODO: test closestPoints
+}
 
-		wkt0 = "LINESTRING(0 0, 0 1, 1 1, 1 0, 0 0)";
-		wkt1 = "LINESTRING(2 0, 10 1, 10 10)";
-		g0.reset(wktreader.read(wkt0));
-		g1.reset(wktreader.read(wkt1));
-
-		ensure_equals(DistanceOp::distance(*g0, *g1), 1);
-		ensure(DistanceOp::isWithinDistance(*g0, *g1, 2));
-		ensure(!DistanceOp::isWithinDistance(*g0, *g1, 0.8));
-
-		// TODO: test closestPoints
-	}
-
-    // Test case submitted to Ticket #367
-    // http://trac.osgeo.org/geos/ticket/367/
-	template<>
-	template<>
-	void object::test<19>()
-	{
-        using geos::geom::GeometryFactory;
-        const char* wkb_geom1 = "01060000000100000001030000000100000000000000";
-        const char* wkb_geom2 = "010100000000000000000000000000000000000000";
-
-        geos::geom::PrecisionModel precision(geos::geom::PrecisionModel::FLOATING);
-        GeometryFactory::Ptr f(GeometryFactory::create(&precision));
-        std::istringstream istr1(wkb_geom1);
-        std::istringstream istr2(wkb_geom2);
-        geos::io::WKBReader wkb(*f);
-        GeomPtr g1(wkb.readHEX(istr1));
-        GeomPtr g2(wkb.readHEX(istr2));
-        ensure(g1->isValid());
-        ensure(g2->isValid());
-
-        ensure_equals(g1->distance(g2.get()), 0);
-    }
-
-	// TODO: finish the tests by adding:
-	// 	LINESTRING - *all*
-	// 	MULTILINESTRING - *all*
-	// 	POLYGON - *all*
-	// 	MULTIPOLYGON - *all*
-	// 	COLLECTION - *all*
+// Test case submitted to Ticket #367
+// http://trac.osgeo.org/geos/ticket/367/
+template<>
+template<>
+void object::test<19>
+()
+{
+    using geos::geom::GeometryFactory;
+    const char* wkb_geom1 = "01060000000100000001030000000100000000000000";
+    const char* wkb_geom2 = "010100000000000000000000000000000000000000";
+
+    geos::geom::PrecisionModel precision(geos::geom::PrecisionModel::FLOATING);
+    GeometryFactory::Ptr f(GeometryFactory::create(&precision));
+    std::istringstream istr1(wkb_geom1);
+    std::istringstream istr2(wkb_geom2);
+    geos::io::WKBReader wkb(*f);
+    GeomPtr g1(wkb.readHEX(istr1));
+    GeomPtr g2(wkb.readHEX(istr2));
+    ensure(g1->isValid());
+    ensure(g2->isValid());
+
+    ensure_equals(g1->distance(g2.get()), 0);
+}
+
+// TODO: finish the tests by adding:
+// 	LINESTRING - *all*
+// 	MULTILINESTRING - *all*
+// 	POLYGON - *all*
+// 	MULTIPOLYGON - *all*
+// 	COLLECTION - *all*
 
 } // namespace tut
 
diff --git a/tests/unit/operation/intersection/RectangleIntersectionTest.cpp b/tests/unit/operation/intersection/RectangleIntersectionTest.cpp
index 89c60ed..e9280b1 100644
--- a/tests/unit/operation/intersection/RectangleIntersectionTest.cpp
+++ b/tests/unit/operation/intersection/RectangleIntersectionTest.cpp
@@ -17,1515 +17,1665 @@
 #include <vector>
 #include <iostream>
 
-namespace tut
-{
-    //
-    // Test Group
-    //
+namespace tut {
+//
+// Test Group
+//
 
-    // Common data used by tests
-    struct test_rectangleintersectiontest_data
+// Common data used by tests
+struct test_rectangleintersectiontest_data {
+    geos::io::WKTReader wktreader;
+    geos::io::WKTWriter wktwriter;
+
+    typedef geos::geom::Geometry::Ptr GeomPtr;
+    typedef geos::geom::Geometry Geom;
+    typedef geos::operation::intersection::Rectangle Rectangle;
+    typedef geos::operation::intersection::RectangleIntersection RectangleIntersection;
+
+    test_rectangleintersectiontest_data()
+        : wktreader()
     {
-        geos::io::WKTReader wktreader;
-        geos::io::WKTWriter wktwriter;
-
-        typedef geos::geom::Geometry::Ptr GeomPtr;
-        typedef geos::geom::Geometry Geom;
-        typedef geos::operation::intersection::Rectangle Rectangle;
-        typedef geos::operation::intersection::RectangleIntersection RectangleIntersection;
-
-        test_rectangleintersectiontest_data()
-          : wktreader()
-        {
-          wktwriter.setTrim(true);
-        }
+        wktwriter.setTrim(true);
+    }
 
-        GeomPtr readWKT(const std::string& inputWKT)
-        {
-            return GeomPtr(wktreader.read(inputWKT));
-        }
+    GeomPtr
+    readWKT(const std::string& inputWKT)
+    {
+        return GeomPtr(wktreader.read(inputWKT));
+    }
 
-        static GeomPtr normalize(const Geom& g)
-        {
-          GeomPtr g2 ( g.clone() );
-          g2->normalize();
-          return g2;
-        }
+    static GeomPtr
+    normalize(const Geom& g)
+    {
+        GeomPtr g2(g.clone());
+        g2->normalize();
+        return g2;
+    }
 
-        bool isEqual(const Geom& a, const Geom& b, double tolerance=0)
-        {
-          using std::cout;
-          using std::endl;
-          bool eq;
-          // TODO: use HausdorffDistance ?
-          GeomPtr a2 = normalize(a);
-          GeomPtr b2 = normalize(b);
-          eq = a2->equalsExact(b2.get(), tolerance);
-          if  ( ! eq ) {
+    bool
+    isEqual(const Geom& a, const Geom& b, double tolerance = 0)
+    {
+        using std::cout;
+        using std::endl;
+        bool eq;
+        // TODO: use HausdorffDistance ?
+        GeomPtr a2 = normalize(a);
+        GeomPtr b2 = normalize(b);
+        eq = a2->equalsExact(b2.get(), tolerance);
+        if(! eq) {
             cout << "OBTAINED: " << wktwriter.write(b2.get()) << endl;
-          }
-          return eq;
         }
+        return eq;
+    }
 
-        void doLineClipTest(const char* inputWKT, const std::string& expectedWKT, const Rectangle& rect, double tolerance=0)
-        {
-          GeomPtr g = readWKT(inputWKT);
-          ensure(g.get());
-          GeomPtr obt = RectangleIntersection::clipBoundary(*g,rect);
-          ensure(obt.get());
-          bool ok = isEqual(*readWKT(expectedWKT), *obt, tolerance);
-          ensure(ok);
-        }
+    void
+    doLineClipTest(const char* inputWKT, const std::string& expectedWKT, const Rectangle& rect, double tolerance = 0)
+    {
+        GeomPtr g = readWKT(inputWKT);
+        ensure(g.get());
+        GeomPtr obt = RectangleIntersection::clipBoundary(*g, rect);
+        ensure(obt.get());
+        bool ok = isEqual(*readWKT(expectedWKT), *obt, tolerance);
+        ensure(ok);
+    }
 
-        void doClipTest(const char* inputWKT, const std::string& expectedWKT, const Rectangle& rect, double tolerance=0)
-        {
-          GeomPtr g = readWKT(inputWKT);
-          ensure(g.get());
-          GeomPtr obt = RectangleIntersection::clip(*g,rect);
-          ensure(obt.get());
-          bool ok = isEqual(*readWKT(expectedWKT), *obt, tolerance);
-          ensure(ok);
+    void
+    doClipTest(const char* inputWKT, const std::string& expectedWKT, const Rectangle& rect, double tolerance = 0)
+    {
+        GeomPtr g = readWKT(inputWKT);
+        ensure(g.get());
+        GeomPtr obt = RectangleIntersection::clip(*g, rect);
+        ensure(obt.get());
+        bool ok = isEqual(*readWKT(expectedWKT), *obt, tolerance);
+        ensure(ok);
 // Compare with GEOSIntersection output
 #if 0
-          GeomPtr g2 ( rect.toPolygon(*g->getFactory()) );
-          obt.reset(g->intersection(g2.get()));
-          ensure(obt.get());
-          ok = isEqual(*readWKT(expectedWKT), *obt, tolerance);
-          ensure(ok);
+        GeomPtr g2(rect.toPolygon(*g->getFactory()));
+        obt.reset(g->intersection(g2.get()));
+        ensure(obt.get());
+        ok = isEqual(*readWKT(expectedWKT), *obt, tolerance);
+        ensure(ok);
 #endif
-        }
+    }
 
-    };
+};
 
-    typedef test_group<test_rectangleintersectiontest_data, 255> group;
-    typedef group::object object;
+typedef test_group<test_rectangleintersectiontest_data, 255> group;
+typedef group::object object;
 
-    group test_rectangleintersectiontest_group("geos::operation::intersection::RectangleIntersection");
-    // inside
-    template<> template<> void object::test<1>()
-    {
-      doLineClipTest(
+group test_rectangleintersectiontest_group("geos::operation::intersection::RectangleIntersection");
+// inside
+template<> template<> void object::test<1>
+()
+{
+    doLineClipTest(
         "LINESTRING (1 1,1 9,9 9,9 1)",
         "LINESTRING (1 1,1 9,9 9,9 1)",
-        Rectangle(0,0,10,10)
-      );
-    }
+        Rectangle(0, 0, 10, 10)
+    );
+}
 
-    // outside
-    template<> template<> void object::test<2>()
-    {
-      doLineClipTest(
+// outside
+template<> template<> void object::test<2>
+()
+{
+    doLineClipTest(
         "LINESTRING (-1 -9,-1 11,9 11)",
         "GEOMETRYCOLLECTION EMPTY",
-        Rectangle(0,0,10,10)
-      );
-    }
+        Rectangle(0, 0, 10, 10)
+    );
+}
 
-    // go in from left
-    template<> template<> void object::test<3>()
-    {
-      doLineClipTest(
+// go in from left
+template<> template<> void object::test<3>
+()
+{
+    doLineClipTest(
         "LINESTRING (-1 5,5 5,9 9)",
         "LINESTRING (0 5,5 5,9 9)",
-        Rectangle(0,0,10,10)
-      );
-    }
+        Rectangle(0, 0, 10, 10)
+    );
+}
 
-    // go out from right
-    template<> template<> void object::test<4>()
-    {
-      doLineClipTest(
+// go out from right
+template<> template<> void object::test<4>
+()
+{
+    doLineClipTest(
         "LINESTRING (5 5,8 5,12 5)",
         "LINESTRING (5 5,8 5,10 5)",
-        Rectangle(0,0,10,10)
-      );
-    }
+        Rectangle(0, 0, 10, 10)
+    );
+}
 
-    // go in and out
-    template<> template<> void object::test<5>()
-    {
-      doLineClipTest(
+// go in and out
+template<> template<> void object::test<5>
+()
+{
+    doLineClipTest(
         "LINESTRING (5 -1,5 5,1 2,-3 2,1 6)",
         "MULTILINESTRING ((5 0,5 5,1 2,0 2),(0 5,1 6))",
-        Rectangle(0,0,10,10)
-      );
-    }
+        Rectangle(0, 0, 10, 10)
+    );
+}
 
-    // go along left edge
-    template<> template<> void object::test<6>()
-    {
-      doLineClipTest(
+// go along left edge
+template<> template<> void object::test<6>
+()
+{
+    doLineClipTest(
         "LINESTRING (0 3,0 5,0 7)",
         "GEOMETRYCOLLECTION EMPTY",
-        Rectangle(0,0,10,10)
-      );
-    }
+        Rectangle(0, 0, 10, 10)
+    );
+}
 
-    // go out from left edge
-    template<> template<> void object::test<7>()
-    {
-      doLineClipTest(
+// go out from left edge
+template<> template<> void object::test<7>
+()
+{
+    doLineClipTest(
         "LINESTRING (0 3,0 5,-1 7)",
         "GEOMETRYCOLLECTION EMPTY",
-        Rectangle(0,0,10,10)
-      );
-    }
+        Rectangle(0, 0, 10, 10)
+    );
+}
 
-    // go in from left edge
-    template<> template<> void object::test<8>()
-    {
-      doLineClipTest(
+// go in from left edge
+template<> template<> void object::test<8>
+()
+{
+    doLineClipTest(
         "LINESTRING (0 3,0 5,2 7)",
         "LINESTRING (0 5,2 7)",
-        Rectangle(0,0,10,10)
-      );
-    }
+        Rectangle(0, 0, 10, 10)
+    );
+}
 
-    // triangle corner at bottom left corner
-    template<> template<> void object::test<9>()
-    {
-      doLineClipTest(
+// triangle corner at bottom left corner
+template<> template<> void object::test<9>
+()
+{
+    doLineClipTest(
         "LINESTRING (2 1,0 0,1 2)",
         "LINESTRING (2 1,0 0,1 2)",
-        Rectangle(0,0,10,10)
-      );
-    }
+        Rectangle(0, 0, 10, 10)
+    );
+}
 
-    // go from in to edge and back in
-    template<> template<> void object::test<10>()
-    {
-      doLineClipTest(
+// go from in to edge and back in
+template<> template<> void object::test<10>
+()
+{
+    doLineClipTest(
         "LINESTRING (3 3,0 3,0 5,2 7)",
         "MULTILINESTRING ((3 3,0 3),(0 5,2 7))",
-        Rectangle(0,0,10,10)
-      );
-    }
+        Rectangle(0, 0, 10, 10)
+    );
+}
 
-    // go from in to edge and then straight out
-    template<> template<> void object::test<11>()
-    {
-      doLineClipTest(
+// go from in to edge and then straight out
+template<> template<> void object::test<11>
+()
+{
+    doLineClipTest(
         "LINESTRING (5 5,10 5,20 5)",
         "LINESTRING (5 5,10 5)",
-        Rectangle(0,0,10,10)
-      );
-    }
+        Rectangle(0, 0, 10, 10)
+    );
+}
 
-    // triangle corner at left edge
-    template<> template<> void object::test<12>()
-    {
-      doLineClipTest(
+// triangle corner at left edge
+template<> template<> void object::test<12>
+()
+{
+    doLineClipTest(
         "LINESTRING (3 3,0 6,3 9)",
         "LINESTRING (3 3,0 6,3 9)",
-        Rectangle(0,0,10,10)
-      );
-    }
+        Rectangle(0, 0, 10, 10)
+    );
+}
 
-    // polygon completely inside
-    template<> template<> void object::test<13>()
-    {
-      doLineClipTest(
+// polygon completely inside
+template<> template<> void object::test<13>
+()
+{
+    doLineClipTest(
         "POLYGON ((5 5,5 6,6 6,6 5,5 5))",
         "POLYGON ((5 5,5 6,6 6,6 5,5 5))",
-        Rectangle(0,0,10,10)
-      );
-    }
+        Rectangle(0, 0, 10, 10)
+    );
+}
 
-    // polygon completely outside
-    template<> template<> void object::test<14>()
-    {
-      doLineClipTest(
+// polygon completely outside
+template<> template<> void object::test<14>
+()
+{
+    doLineClipTest(
         "POLYGON ((15 15,15 16,16 16,16 15,15 15))",
         "GEOMETRYCOLLECTION EMPTY",
-        Rectangle(0,0,10,10)
-      );
-    }
+        Rectangle(0, 0, 10, 10)
+    );
+}
 
-    // polygon surrounds the rectangle
-    template<> template<> void object::test<15>()
-    {
-      doLineClipTest(
+// polygon surrounds the rectangle
+template<> template<> void object::test<15>
+()
+{
+    doLineClipTest(
         "POLYGON ((-1 -1,-1 11,11 11,11 -1,-1 -1))",
         "GEOMETRYCOLLECTION EMPTY",
-        Rectangle(0,0,10,10)
-      );
-    }
+        Rectangle(0, 0, 10, 10)
+    );
+}
 
-    // polygon cuts the rectangle
-    template<> template<> void object::test<16>()
-    {
-      doLineClipTest(
+// polygon cuts the rectangle
+template<> template<> void object::test<16>
+()
+{
+    doLineClipTest(
         "POLYGON ((-1 -1,-1 5,5 5,5 -1,-1 -1))",
         "LINESTRING (0 5,5 5,5 0)",
-        Rectangle(0,0,10,10)
-      );
-    }
+        Rectangle(0, 0, 10, 10)
+    );
+}
 
-    // polygon with hole cuts the rectangle
-    template<> template<> void object::test<17>()
-    {
-      doLineClipTest(
+// polygon with hole cuts the rectangle
+template<> template<> void object::test<17>
+()
+{
+    doLineClipTest(
         "POLYGON ((-2 -2,-2 5,5 5,5 -2,-2 -2), (3 3,4 4,4 2,3 3))",
         "GEOMETRYCOLLECTION (POLYGON ((3 3,4 4,4 2,3 3)),LINESTRING (0 5,5 5,5 0))",
-        Rectangle(0,0,10,10)
-      );
-    }
+        Rectangle(0, 0, 10, 10)
+    );
+}
 
-    // rectangle cuts both the polygon and the hole
-    template<> template<> void object::test<18>()
-    {
-      doLineClipTest(
+// rectangle cuts both the polygon and the hole
+template<> template<> void object::test<18>
+()
+{
+    doLineClipTest(
         "POLYGON ((-2 -2,-2 5,5 5,5 -2,-2 -2), (-1 -1,3 1,3 3,-1 -1))",
         "MULTILINESTRING ((0 5,5 5,5 0),(1 0,3 1,3 3,0 0))",
-        Rectangle(0,0,10,10)
-      );
-    }
+        Rectangle(0, 0, 10, 10)
+    );
+}
 
-    // Triangle at two corners and one edge
-    template<> template<> void object::test<19>()
-    {
-      doLineClipTest(
+// Triangle at two corners and one edge
+template<> template<> void object::test<19>
+()
+{
+    doLineClipTest(
         "POLYGON ((0 0,10 0,5 10,0 0))",
         "LINESTRING (10 0,5 10,0 0)",
-        Rectangle(0,0,10,10)
-      );
-    }
+        Rectangle(0, 0, 10, 10)
+    );
+}
 
-    // Same triangle with another starting point
-    template<> template<> void object::test<20>()
-    {
-      doLineClipTest(
+// Same triangle with another starting point
+template<> template<> void object::test<20>
+()
+{
+    doLineClipTest(
         "POLYGON ((5 10,0 0,10 0,5 10))",
         "LINESTRING (10 0,5 10,0 0)",
-        Rectangle(0,0,10,10)
-      );
-    }
+        Rectangle(0, 0, 10, 10)
+    );
+}
 
-    // Triangle intersection at corner and edge
-    template<> template<> void object::test<21>()
-    {
-      doLineClipTest(
+// Triangle intersection at corner and edge
+template<> template<> void object::test<21>
+()
+{
+    doLineClipTest(
         "POLYGON ((-5 -5,5 5,5 -5,-5 -5))",
         "LINESTRING (0 0,5 5,5 0)",
-        Rectangle(0,0,10,10)
-      );
-    }
+        Rectangle(0, 0, 10, 10)
+    );
+}
 
-    // Triangle intersection at adjacent edges
-    template<> template<> void object::test<22>()
-    {
-      doLineClipTest(
+// Triangle intersection at adjacent edges
+template<> template<> void object::test<22>
+()
+{
+    doLineClipTest(
         "POLYGON ((-1 5,5 11,5 5,-1 5))",
         "MULTILINESTRING ((0 6,4 10),(5 10,5 5,0 5))",
-        Rectangle(0,0,10,10)
-      );
-    }
+        Rectangle(0, 0, 10, 10)
+    );
+}
 
-    // One triangle intersection and one inside edge
-    template<> template<> void object::test<23>()
-    {
-      doLineClipTest(
+// One triangle intersection and one inside edge
+template<> template<> void object::test<23>
+()
+{
+    doLineClipTest(
         "POLYGON ((-5 5,5 10,5 5,-5 5))",
         "LINESTRING (0.0 7.5,5 10,5 5,0 5)",
-        Rectangle(0,0,10,10)
-      );
-    }
+        Rectangle(0, 0, 10, 10)
+    );
+}
 
-    // Triangle intersection at center and end of the same edge
-    template<> template<> void object::test<24>()
-    {
-      doLineClipTest(
+// Triangle intersection at center and end of the same edge
+template<> template<> void object::test<24>
+()
+{
+    doLineClipTest(
         "POLYGON ((-10 5,10 10,10 5,-10 5))",
         "MULTILINESTRING ((0.0 7.5,10 10),(10 5,0 5))",
-        Rectangle(0,0,10,10)
-      );
-    }
+        Rectangle(0, 0, 10, 10)
+    );
+}
 
-    // Two different edges clips
-    template<> template<> void object::test<25>()
-    {
-      doLineClipTest(
+// Two different edges clips
+template<> template<> void object::test<25>
+()
+{
+    doLineClipTest(
         "POLYGON ((-5 5,15 15,15 5,-5 5))",
         "MULTILINESTRING ((0.0 7.5,5 10),(10 5,0 5))",
-        Rectangle(0,0,10,10)
-      );
-    }
+        Rectangle(0, 0, 10, 10)
+    );
+}
 
-    // Inside triangle with all corners at edges
-    template<> template<> void object::test<26>()
-    {
-      doLineClipTest(
+// Inside triangle with all corners at edges
+template<> template<> void object::test<26>
+()
+{
+    doLineClipTest(
         "POLYGON ((0 5,5 10,10 5,0 5))",
         "POLYGON ((0 5,5 10,10 5,0 5))",
-        Rectangle(0,0,10,10)
-      );
-    }
+        Rectangle(0, 0, 10, 10)
+    );
+}
 
-    // Inside triangle whose base is one of the edges
-    template<> template<> void object::test<27>()
-    {
-      doLineClipTest(
+// Inside triangle whose base is one of the edges
+template<> template<> void object::test<27>
+()
+{
+    doLineClipTest(
         "POLYGON ((0 0,5 5,10 0,0 0))",
         "LINESTRING (0 0,5 5,10 0)",
-        Rectangle(0,0,10,10)
-      );
-    }
+        Rectangle(0, 0, 10, 10)
+    );
+}
 
-    // Triangle touching two corners on the outside
-    template<> template<> void object::test<28>()
-    {
-      doLineClipTest(
+// Triangle touching two corners on the outside
+template<> template<> void object::test<28>
+()
+{
+    doLineClipTest(
         "POLYGON ((-5 5,5 15,15 5,-5 5))",
         "LINESTRING (10 5,0 5)",
-        Rectangle(0,0,10,10)
-      );
-    }
+        Rectangle(0, 0, 10, 10)
+    );
+}
 
-    // Triangle with a diagonal and sharing two edges
-    template<> template<> void object::test<29>()
-    {
-      doLineClipTest(
+// Triangle with a diagonal and sharing two edges
+template<> template<> void object::test<29>
+()
+{
+    doLineClipTest(
         "POLYGON ((0 0,10 10,10 0,0 0))",
         "LINESTRING (0 0,10 10)",
-        Rectangle(0,0,10,10)
-      );
-    }
+        Rectangle(0, 0, 10, 10)
+    );
+}
 
-    // Triangle exits edge at a corner
-    template<> template<> void object::test<30>()
-    {
-      doLineClipTest(
+// Triangle exits edge at a corner
+template<> template<> void object::test<30>
+()
+{
+    doLineClipTest(
         "POLYGON ((-5 0,5 10,5 0,-5 0))",
         "LINESTRING (0 5,5 10,5 0)",
-        Rectangle(0,0,10,10)
-      );
-    }
+        Rectangle(0, 0, 10, 10)
+    );
+}
 
-    // Triangle enters edge at a corner
-    template<> template<> void object::test<31>()
-    {
-      doLineClipTest(
+// Triangle enters edge at a corner
+template<> template<> void object::test<31>
+()
+{
+    doLineClipTest(
         "POLYGON ((-5 10,5 10,0 0,-5 10))",
         "LINESTRING (5 10,0 0)",
-        Rectangle(0,0,10,10)
-      );
-    }
+        Rectangle(0, 0, 10, 10)
+    );
+}
 
-    // Triangle enters and exits the same edge
-    template<> template<> void object::test<32>()
-    {
-      doLineClipTest(
+// Triangle enters and exits the same edge
+template<> template<> void object::test<32>
+()
+{
+    doLineClipTest(
         "POLYGON ((-5 0,5 10,15 0,-5 0))",
         "LINESTRING (0 5,5 10,10 5)",
-        Rectangle(0,0,10,10)
-      );
-    }
+        Rectangle(0, 0, 10, 10)
+    );
+}
 
-    // Triangle enters at a corner and exits at another
-    template<> template<> void object::test<33>()
-    {
-      doLineClipTest(
+// Triangle enters at a corner and exits at another
+template<> template<> void object::test<33>
+()
+{
+    doLineClipTest(
         "POLYGON ((-5 -5,15 15,15 -5,-5 -5))",
         "LINESTRING (0 0,10 10)",
-        Rectangle(0,0,10,10)
-      );
-    }
+        Rectangle(0, 0, 10, 10)
+    );
+}
 
-    // From outside to nearest edge etc
-    template<> template<> void object::test<34>()
-    {
-      doLineClipTest(
+// From outside to nearest edge etc
+template<> template<> void object::test<34>
+()
+{
+    doLineClipTest(
         "POLYGON ((-5 -5,0 5,5 0,-5 -5))",
         "LINESTRING (0 5,5 0)",
-        Rectangle(0,0,10,10)
-      );
-    }
+        Rectangle(0, 0, 10, 10)
+    );
+}
 
-    // From outside to opposite edge etc
-    template<> template<> void object::test<35>()
-    {
-      doLineClipTest(
+// From outside to opposite edge etc
+template<> template<> void object::test<35>
+()
+{
+    doLineClipTest(
         "POLYGON ((-10 5,10 5,0 -5,-10 5))",
         "LINESTRING (0 5,10 5,5 0)",
-        Rectangle(0,0,10,10)
-      );
-    }
+        Rectangle(0, 0, 10, 10)
+    );
+}
 
-    // Drew all combinations I could imagine on paper, and added the following.
-    // All triangles fully inside
-    template<> template<> void object::test<36>()
-    {
-      doLineClipTest(
+// Drew all combinations I could imagine on paper, and added the following.
+// All triangles fully inside
+template<> template<> void object::test<36>
+()
+{
+    doLineClipTest(
         "POLYGON ((0 0,0 10,10 10,0 0))",
         "LINESTRING (10 10,0 0)",
-        Rectangle(0,0,10,10)
-      );
-    }
+        Rectangle(0, 0, 10, 10)
+    );
+}
 
-    template<> template<> void object::test<37>()
-    {
-      doLineClipTest(
+template<> template<> void object::test<37>
+()
+{
+    doLineClipTest(
         "POLYGON ((0 5,0 10,10 10,0 5))",
         "LINESTRING (10 10,0 5)",
-        Rectangle(0,0,10,10)
-      );
-    }
+        Rectangle(0, 0, 10, 10)
+    );
+}
 
-    template<> template<> void object::test<38>()
-    {
-      doLineClipTest(
+template<> template<> void object::test<38>
+()
+{
+    doLineClipTest(
         "POLYGON ((0 10,10 10,5 0,0 10))",
         "LINESTRING (10 10,5 0,0 10)",
-        Rectangle(0,0,10,10)
-      );
-    }
+        Rectangle(0, 0, 10, 10)
+    );
+}
 
-    template<> template<> void object::test<39>()
-    {
-      doLineClipTest(
+template<> template<> void object::test<39>
+()
+{
+    doLineClipTest(
         "POLYGON ((0 10,10 10,5 5,0 10))",
         "LINESTRING (10 10,5 5,0 10)",
-        Rectangle(0,0,10,10)
-      );
-    }
+        Rectangle(0, 0, 10, 10)
+    );
+}
 
-    template<> template<> void object::test<40>()
-    {
-      doLineClipTest(
+template<> template<> void object::test<40>
+()
+{
+    doLineClipTest(
         "POLYGON ((0 10,5 10,0 5,0 10))",
         "LINESTRING (5 10,0 5)",
-        Rectangle(0,0,10,10)
-      );
-    }
+        Rectangle(0, 0, 10, 10)
+    );
+}
 
-    template<> template<> void object::test<41>()
-    {
-      doLineClipTest(
+template<> template<> void object::test<41>
+()
+{
+    doLineClipTest(
         "POLYGON ((0 10,10 5,0 5,0 10))",
         "LINESTRING (0 10,10 5,0 5)",
-        Rectangle(0,0,10,10)
-      );
-    }
+        Rectangle(0, 0, 10, 10)
+    );
+}
 
-    template<> template<> void object::test<42>()
-    {
-      doLineClipTest(
+template<> template<> void object::test<42>
+()
+{
+    doLineClipTest(
         "POLYGON ((0 10,10 0,0 5,0 10))",
         "LINESTRING (0 10,10 0,0 5)",
-        Rectangle(0,0,10,10)
-      );
-    }
+        Rectangle(0, 0, 10, 10)
+    );
+}
 
-    template<> template<> void object::test<43>()
-    {
-      doLineClipTest(
+template<> template<> void object::test<43>
+()
+{
+    doLineClipTest(
         "POLYGON ((0 10,5 0,0 5,0 10))",
         "LINESTRING (0 10,5 0,0 5)",
-        Rectangle(0,0,10,10)
-      );
-    }
+        Rectangle(0, 0, 10, 10)
+    );
+}
 
-    template<> template<> void object::test<44>()
-    {
-      doLineClipTest(
+template<> template<> void object::test<44>
+()
+{
+    doLineClipTest(
         "POLYGON ((0 10,5 5,0 5,0 10))",
         "LINESTRING (0 10,5 5,0 5)",
-        Rectangle(0,0,10,10)
-      );
-    }
+        Rectangle(0, 0, 10, 10)
+    );
+}
 
-    template<> template<> void object::test<45>()
-    {
-      doLineClipTest(
+template<> template<> void object::test<45>
+()
+{
+    doLineClipTest(
         "POLYGON ((0 10,7 7,3 3,0 10))",
         "POLYGON ((0 10,7 7,3 3,0 10))",
-        Rectangle(0,0,10,10)
-      );
-    }
+        Rectangle(0, 0, 10, 10)
+    );
+}
 
-    template<> template<> void object::test<46>()
-    {
-      doLineClipTest(
+template<> template<> void object::test<46>
+()
+{
+    doLineClipTest(
         "POLYGON ((0 10,5 5,5 0,0 10))",
         "POLYGON ((0 10,5 5,5 0,0 10))",
-        Rectangle(0,0,10,10)
-      );
-    }
+        Rectangle(0, 0, 10, 10)
+    );
+}
 
-    template<> template<> void object::test<47>()
-    {
-      doLineClipTest(
+template<> template<> void object::test<47>
+()
+{
+    doLineClipTest(
         "POLYGON ((0 10,10 5,5 0,0 10))",
         "POLYGON ((0 10,10 5,5 0,0 10))",
-        Rectangle(0,0,10,10)
-      );
-    }
+        Rectangle(0, 0, 10, 10)
+    );
+}
 
-    template<> template<> void object::test<48>()
-    {
-      doLineClipTest(
+template<> template<> void object::test<48>
+()
+{
+    doLineClipTest(
         "POLYGON ((2 5,5 7,7 5,2 5))",
         "POLYGON ((2 5,5 7,7 5,2 5))",
-        Rectangle(0,0,10,10)
-      );
-    }
+        Rectangle(0, 0, 10, 10)
+    );
+}
 
-    template<> template<> void object::test<49>()
-    {
-      doLineClipTest(
+template<> template<> void object::test<49>
+()
+{
+    doLineClipTest(
         "POLYGON ((2 5,5 10,7 5,2 5))",
         "POLYGON ((2 5,5 10,7 5,2 5))",
-        Rectangle(0,0,10,10)
-      );
-    }
+        Rectangle(0, 0, 10, 10)
+    );
+}
 
-    template<> template<> void object::test<50>()
-    {
-      doLineClipTest(
+template<> template<> void object::test<50>
+()
+{
+    doLineClipTest(
         "POLYGON ((0 5,5 10,5 5,0 5))",
         "POLYGON ((0 5,5 10,5 5,0 5))",
-        Rectangle(0,0,10,10)
-      );
-    }
+        Rectangle(0, 0, 10, 10)
+    );
+}
 
-    template<> template<> void object::test<51>()
-    {
-      doLineClipTest(
+template<> template<> void object::test<51>
+()
+{
+    doLineClipTest(
         "POLYGON ((0 5,5 10,10 5,0 5))",
         "POLYGON ((0 5,5 10,10 5,0 5))",
-        Rectangle(0,0,10,10)
-      );
-    }
+        Rectangle(0, 0, 10, 10)
+    );
+}
 
-    template<> template<> void object::test<52>()
-    {
-      doLineClipTest(
+template<> template<> void object::test<52>
+()
+{
+    doLineClipTest(
         "POLYGON ((0 5,5 7,10 5,0 5))",
         "POLYGON ((0 5,5 7,10 5,0 5))",
-        Rectangle(0,0,10,10)
-      );
-    }
+        Rectangle(0, 0, 10, 10)
+    );
+}
 
-    // No points inside, one intersection
-    template<> template<> void object::test<53>()
-    {
-      doLineClipTest(
+// No points inside, one intersection
+template<> template<> void object::test<53>
+()
+{
+    doLineClipTest(
         "POLYGON ((-5 10,0 15,0 10,-5 10))",
         "GEOMETRYCOLLECTION EMPTY",
-        Rectangle(0,0,10,10)
-      );
-    }
+        Rectangle(0, 0, 10, 10)
+    );
+}
 
-    template<> template<> void object::test<54>()
-    {
-      doLineClipTest(
+template<> template<> void object::test<54>
+()
+{
+    doLineClipTest(
         "POLYGON ((-5 10,0 5,-5 0,-5 10))",
         "GEOMETRYCOLLECTION EMPTY",
-        Rectangle(0,0,10,10)
-      );
-    }
+        Rectangle(0, 0, 10, 10)
+    );
+}
 
-    // No points inside, two intersections
-    template<> template<> void object::test<55>()
-    {
-      doLineClipTest(
+// No points inside, two intersections
+template<> template<> void object::test<55>
+()
+{
+    doLineClipTest(
         "POLYGON ((-5 5,0 10,0 0,-5 5))",
         "GEOMETRYCOLLECTION EMPTY",
-        Rectangle(0,0,10,10)
-      );
-    }
+        Rectangle(0, 0, 10, 10)
+    );
+}
 
-    template<> template<> void object::test<56>()
-    {
-      doLineClipTest(
+template<> template<> void object::test<56>
+()
+{
+    doLineClipTest(
         "POLYGON ((-5 5,0 10,0 5,-5 5))",
         "GEOMETRYCOLLECTION EMPTY",
-        Rectangle(0,0,10,10)
-      );
-    }
+        Rectangle(0, 0, 10, 10)
+    );
+}
 
-    template<> template<> void object::test<57>()
-    {
-      doLineClipTest(
+template<> template<> void object::test<57>
+()
+{
+    doLineClipTest(
         "POLYGON ((-5 5,0 7,0 3,-5 5))",
         "GEOMETRYCOLLECTION EMPTY",
-        Rectangle(0,0,10,10)
-      );
-    }
+        Rectangle(0, 0, 10, 10)
+    );
+}
 
-    // One point inside
-    template<> template<> void object::test<58>()
-    {
-      doLineClipTest(
+// One point inside
+template<> template<> void object::test<58>
+()
+{
+    doLineClipTest(
         "POLYGON ((5 5,-5 0,-5 10,5 5))",
         "LINESTRING (0.0 7.5,5 5,0.0 2.5)",
-        Rectangle(0,0,10,10)
-      );
-    }
+        Rectangle(0, 0, 10, 10)
+    );
+}
 
-    template<> template<> void object::test<59>()
-    {
-      doLineClipTest(
+template<> template<> void object::test<59>
+()
+{
+    doLineClipTest(
         "POLYGON ((5 0,-5 0,-5 10,5 0))",
         "LINESTRING (0 5,5 0)",
-        Rectangle(0,0,10,10)
-      );
-    }
+        Rectangle(0, 0, 10, 10)
+    );
+}
 
-    template<> template<> void object::test<60>()
-    {
-      doLineClipTest(
+template<> template<> void object::test<60>
+()
+{
+    doLineClipTest(
         "POLYGON((10 0,-10 0,-10 10,10 0))",
         "LINESTRING (0 5,10 0)",
-        Rectangle(0,0,10,10)
-      );
-    }
+        Rectangle(0, 0, 10, 10)
+    );
+}
 
-    template<> template<> void object::test<61>()
-    {
-      doLineClipTest(
+template<> template<> void object::test<61>
+()
+{
+    doLineClipTest(
         "POLYGON ((5 0,-5 5,-5 10,5 0))",
         "LINESTRING (0 5,5 0,0.0 2.5)",
-        Rectangle(0,0,10,10)
-      );
-    }
+        Rectangle(0, 0, 10, 10)
+    );
+}
 
-    template<> template<> void object::test<62>()
-    {
-      doLineClipTest(
+template<> template<> void object::test<62>
+()
+{
+    doLineClipTest(
         "POLYGON ((10 5,-10 0,-10 10,10 5))",
         "LINESTRING (0.0 7.5,10 5,0.0 2.5)",
-        Rectangle(0,0,10,10)
-      );
-    }
+        Rectangle(0, 0, 10, 10)
+    );
+}
 
-    template<> template<> void object::test<63>()
-    {
-      doLineClipTest(
+template<> template<> void object::test<63>
+()
+{
+    doLineClipTest(
         "POLYGON ((10 10,-10 0,-10 5,10 10))",
         "LINESTRING (0.0 7.5,10 10,0 5)",
-        Rectangle(0,0,10,10)
-      );
-    }
+        Rectangle(0, 0, 10, 10)
+    );
+}
 
-    template<> template<> void object::test<64>()
-    {
-      doLineClipTest(
+template<> template<> void object::test<64>
+()
+{
+    doLineClipTest(
         "POLYGON ((5 5,-5 -5,-5 15,5 5))",
         "LINESTRING (0 10,5 5,0 0)",
-        Rectangle(0,0,10,10)
-      );
-    }
+        Rectangle(0, 0, 10, 10)
+    );
+}
 
-    template<> template<> void object::test<65>()
-    {
-      doLineClipTest(
+template<> template<> void object::test<65>
+()
+{
+    doLineClipTest(
         "POLYGON ((10 5,-10 -5,-10 15,10 5))",
         "LINESTRING (0 10,10 5,0 0)",
-        Rectangle(0,0,10,10)
-      );
-    }
+        Rectangle(0, 0, 10, 10)
+    );
+}
 
-    template<> template<> void object::test<66>()
-    {
-      doLineClipTest(
+template<> template<> void object::test<66>
+()
+{
+    doLineClipTest(
         "POLYGON ((5 0,-5 0,-5 20,5 0))",
         "LINESTRING (0 10,5 0)",
-        Rectangle(0,0,10,10)
-      );
-    }
+        Rectangle(0, 0, 10, 10)
+    );
+}
 
-    template<> template<> void object::test<67>()
-    {
-      doLineClipTest(
+template<> template<> void object::test<67>
+()
+{
+    doLineClipTest(
         "POLYGON ((10 0,-10 0,-10 20,10 0))",
         "LINESTRING (0 10,10 0)",
-        Rectangle(0,0,10,10)
-      );
-    }
+        Rectangle(0, 0, 10, 10)
+    );
+}
 
-    template<> template<> void object::test<68>()
-    {
-      doLineClipTest(
+template<> template<> void object::test<68>
+()
+{
+    doLineClipTest(
         "POLYGON ((5 5,-10 5,0 15,5 5))",
         "LINESTRING (2.5 10.0,5 5,0 5)",
-        Rectangle(0,0,10,10)
-      );
-    }
+        Rectangle(0, 0, 10, 10)
+    );
+}
 
-    template<> template<> void object::test<69>()
-    {
-      doLineClipTest(
+template<> template<> void object::test<69>
+()
+{
+    doLineClipTest(
         "POLYGON ((5 5,-5 -5,0 15,5 5))",
         "LINESTRING (2.5 10.0,5 5,0 0)",
-        Rectangle(0,0,10,10)
-      );
-    }
+        Rectangle(0, 0, 10, 10)
+    );
+}
 
-    template<> template<> void object::test<70>()
-    {
-      doLineClipTest(
+template<> template<> void object::test<70>
+()
+{
+    doLineClipTest(
         "POLYGON ((5 5,-15 -20,-15 30,5 5))",
         "LINESTRING (1 10,5 5,1 0)",
-        Rectangle(0,0,10,10)
-      );
-    }
+        Rectangle(0, 0, 10, 10)
+    );
+}
 
-    // Two points inside
-    template<> template<> void object::test<71>()
-    {
-      doLineClipTest(
+// Two points inside
+template<> template<> void object::test<71>
+()
+{
+    doLineClipTest(
         "POLYGON ((5 7,5 3,-5 5,5 7))",
         "LINESTRING (0 6,5 7,5 3,0 4)",
-        Rectangle(0,0,10,10)
-      );
-    }
+        Rectangle(0, 0, 10, 10)
+    );
+}
 
-    template<> template<> void object::test<72>()
-    {
-      doLineClipTest(
+template<> template<> void object::test<72>
+()
+{
+    doLineClipTest(
         "POLYGON ((5 7,5 3,-5 13,5 7))",
         "LINESTRING (0 10,5 7,5 3,0 8)",
-        Rectangle(0,0,10,10)
-      );
-    }
+        Rectangle(0, 0, 10, 10)
+    );
+}
 
-    template<> template<> void object::test<73>()
-    {
-      doLineClipTest(
+template<> template<> void object::test<73>
+()
+{
+    doLineClipTest(
         "POLYGON ((6 6,4 4,-4 14,6 6))",
         "LINESTRING (1.0 10.0,6 6,4 4,0 9)",
-        Rectangle(0,0,10,10), 1e-12
-      );
-    }
+        Rectangle(0, 0, 10, 10), 1e-12
+    );
+}
 
-    // Polygon with hole which surrounds the rectangle
-    template<> template<> void object::test<74>()
-    {
-      doLineClipTest(
+// Polygon with hole which surrounds the rectangle
+template<> template<> void object::test<74>
+()
+{
+    doLineClipTest(
         "POLYGON ((-2 -2,-2 12,12 12,12 -2,-2 -2),(-1 -1,11 -1,11 11,-1 11,-1 -1))",
         "GEOMETRYCOLLECTION EMPTY",
-        Rectangle(0,0,10,10)
-      );
-    }
+        Rectangle(0, 0, 10, 10)
+    );
+}
 
-    // Polygon surrounding the rect, but with a hole inside the rect
-    template<> template<> void object::test<75>()
-    {
-      doLineClipTest(
+// Polygon surrounding the rect, but with a hole inside the rect
+template<> template<> void object::test<75>
+()
+{
+    doLineClipTest(
         "POLYGON ((-2 -2,-2 12,12 12,12 -2,-2 -2),(1 1,9 1,9 9,1 9,1 1))",
         "POLYGON ((1 1,9 1,9 9,1 9,1 1))",
-        Rectangle(0,0,10,10)
-      );
-    }
+        Rectangle(0, 0, 10, 10)
+    );
+}
 
 
-    // inside
-    template<> template<> void object::test<76>()
-    {
-      doClipTest(
+// inside
+template<> template<> void object::test<76>
+()
+{
+    doClipTest(
         "LINESTRING (1 1,1 9,9 9,9 1)",
         "LINESTRING (1 1,1 9,9 9,9 1)",
-        Rectangle(0,0,10,10)
-      );
-    }
+        Rectangle(0, 0, 10, 10)
+    );
+}
 
-    // outside
-    template<> template<> void object::test<77>()
-    {
-      doClipTest(
+// outside
+template<> template<> void object::test<77>
+()
+{
+    doClipTest(
         "LINESTRING (-1 -9,-1 11,9 11)",
         "GEOMETRYCOLLECTION EMPTY",
-        Rectangle(0,0,10,10)
-      );
-    }
+        Rectangle(0, 0, 10, 10)
+    );
+}
 
-    // go in from left
-    template<> template<> void object::test<78>()
-    {
-      doClipTest(
+// go in from left
+template<> template<> void object::test<78>
+()
+{
+    doClipTest(
         "LINESTRING (-1 5,5 5,9 9)",
         "LINESTRING (0 5,5 5,9 9)",
-        Rectangle(0,0,10,10)
-      );
-    }
+        Rectangle(0, 0, 10, 10)
+    );
+}
 
-    // go out from right
-    template<> template<> void object::test<79>()
-    {
-      doClipTest(
+// go out from right
+template<> template<> void object::test<79>
+()
+{
+    doClipTest(
         "LINESTRING (5 5,8 5,12 5)",
         "LINESTRING (5 5,8 5,10 5)",
-        Rectangle(0,0,10,10)
-      );
-    }
+        Rectangle(0, 0, 10, 10)
+    );
+}
 
-    // go in and out
-    template<> template<> void object::test<80>()
-    {
-      doClipTest(
+// go in and out
+template<> template<> void object::test<80>
+()
+{
+    doClipTest(
         "LINESTRING (5 -1,5 5,1 2,-3 2,1 6)",
         "MULTILINESTRING ((5 0,5 5,1 2,0 2),(0 5,1 6))",
-        Rectangle(0,0,10,10)
-      );
-    }
+        Rectangle(0, 0, 10, 10)
+    );
+}
 
-    // go along left edge
-    template<> template<> void object::test<81>()
-    {
-      doClipTest(
+// go along left edge
+template<> template<> void object::test<81>
+()
+{
+    doClipTest(
         "LINESTRING (0 3,0 5,0 7)",
         "GEOMETRYCOLLECTION EMPTY",
-        Rectangle(0,0,10,10)
-      );
-    }
+        Rectangle(0, 0, 10, 10)
+    );
+}
 
-    // go out from left edge
-    template<> template<> void object::test<82>()
-    {
-      doClipTest(
+// go out from left edge
+template<> template<> void object::test<82>
+()
+{
+    doClipTest(
         "LINESTRING (0 3,0 5,-1 7)",
         "GEOMETRYCOLLECTION EMPTY",
-        Rectangle(0,0,10,10)
-      );
-    }
+        Rectangle(0, 0, 10, 10)
+    );
+}
 
-    // go in from left edge
-    template<> template<> void object::test<83>()
-    {
-      doClipTest(
+// go in from left edge
+template<> template<> void object::test<83>
+()
+{
+    doClipTest(
         "LINESTRING (0 3,0 5,2 7)",
         "LINESTRING (0 5,2 7)",
-        Rectangle(0,0,10,10)
-      );
-    }
+        Rectangle(0, 0, 10, 10)
+    );
+}
 
-    // triangle corner at bottom left corner
-    template<> template<> void object::test<84>()
-    {
-      doClipTest(
+// triangle corner at bottom left corner
+template<> template<> void object::test<84>
+()
+{
+    doClipTest(
         "LINESTRING (2 1,0 0,1 2)",
         "LINESTRING (2 1,0 0,1 2)",
-        Rectangle(0,0,10,10)
-      );
-    }
+        Rectangle(0, 0, 10, 10)
+    );
+}
 
-    // go from in to edge and back in
-    template<> template<> void object::test<85>()
-    {
-      doClipTest(
+// go from in to edge and back in
+template<> template<> void object::test<85>
+()
+{
+    doClipTest(
         "LINESTRING (3 3,0 3,0 5,2 7)",
         "MULTILINESTRING ((3 3,0 3),(0 5,2 7))",
-        Rectangle(0,0,10,10)
-      );
-    }
+        Rectangle(0, 0, 10, 10)
+    );
+}
 
-    // go from in to edge and then straight out
-    template<> template<> void object::test<86>()
-    {
-      doClipTest(
+// go from in to edge and then straight out
+template<> template<> void object::test<86>
+()
+{
+    doClipTest(
         "LINESTRING (5 5,10 5,20 5)",
         "LINESTRING (5 5,10 5)",
-        Rectangle(0,0,10,10)
-      );
-    }
+        Rectangle(0, 0, 10, 10)
+    );
+}
 
-    // triangle corner at left edge
-    template<> template<> void object::test<87>()
-    {
-      doClipTest(
+// triangle corner at left edge
+template<> template<> void object::test<87>
+()
+{
+    doClipTest(
         "LINESTRING (3 3,0 6,3 9)",
         "LINESTRING (3 3,0 6,3 9)",
-        Rectangle(0,0,10,10)
-      );
-    }
+        Rectangle(0, 0, 10, 10)
+    );
+}
 
-    // polygon completely inside
-    template<> template<> void object::test<88>()
-    {
-      doClipTest(
+// polygon completely inside
+template<> template<> void object::test<88>
+()
+{
+    doClipTest(
         "POLYGON ((5 5,5 6,6 6,6 5,5 5))",
         "POLYGON ((5 5,5 6,6 6,6 5,5 5))",
-        Rectangle(0,0,10,10)
-      );
-    }
+        Rectangle(0, 0, 10, 10)
+    );
+}
 
-    // polygon completely outside
-    template<> template<> void object::test<89>()
-    {
-      doClipTest(
+// polygon completely outside
+template<> template<> void object::test<89>
+()
+{
+    doClipTest(
         "POLYGON ((15 15,15 16,16 16,16 15,15 15))",
         "GEOMETRYCOLLECTION EMPTY",
-        Rectangle(0,0,10,10)
-      );
-    }
+        Rectangle(0, 0, 10, 10)
+    );
+}
 
-    // polygon surrounds the rectangle
-    template<> template<> void object::test<90>()
-    {
-      doClipTest(
+// polygon surrounds the rectangle
+template<> template<> void object::test<90>
+()
+{
+    doClipTest(
         "POLYGON ((-1 -1,-1 11,11 11,11 -1,-1 -1))",
         "POLYGON ((0 0,0 10,10 10,10 0,0 0))",
-        Rectangle(0,0,10,10)
-      );
-    }
+        Rectangle(0, 0, 10, 10)
+    );
+}
 
-    // polygon cuts the rectangle
-    template<> template<> void object::test<91>()
-    {
-      doClipTest(
+// polygon cuts the rectangle
+template<> template<> void object::test<91>
+()
+{
+    doClipTest(
         "POLYGON ((-1 -1,-1 5,5 5,5 -1,-1 -1))",
         "POLYGON ((0 0,0 5,5 5,5 0,0 0))",
-        Rectangle(0,0,10,10)
-      );
-    }
+        Rectangle(0, 0, 10, 10)
+    );
+}
 
-    // polygon with hole cuts the rectangle
-    template<> template<> void object::test<92>()
-    {
-      doClipTest(
+// polygon with hole cuts the rectangle
+template<> template<> void object::test<92>
+()
+{
+    doClipTest(
         "POLYGON ((-2 -2,-2 5,5 5,5 -2,-2 -2), (3 3,4 4,4 2,3 3))",
         "POLYGON ((0 0,0 5,5 5,5 0,0 0),(3 3,4 4,4 2,3 3))",
-        Rectangle(0,0,10,10)
-      );
-    }
+        Rectangle(0, 0, 10, 10)
+    );
+}
 
-    // rectangle cuts both the polygon and the hole
-    template<> template<> void object::test<93>()
-    {
-      doClipTest(
+// rectangle cuts both the polygon and the hole
+template<> template<> void object::test<93>
+()
+{
+    doClipTest(
         "POLYGON ((-2 -2,-2 5,5 5,5 -2,-2 -2), (-1 -1,3 1,3 3,-1 -1))",
         "POLYGON ((0 0,0 5,5 5,5 0,1 0,3 1,3 3,0 0))",
-        Rectangle(0,0,10,10)
-      );
-    }
+        Rectangle(0, 0, 10, 10)
+    );
+}
 
-    // Triangle at two corners and one edge
-    template<> template<> void object::test<94>()
-    {
-      doClipTest(
+// Triangle at two corners and one edge
+template<> template<> void object::test<94>
+()
+{
+    doClipTest(
         "POLYGON ((0 0,10 0,5 10,0 0))",
         "POLYGON ((0 0,10 0,5 10,0 0))",
-        Rectangle(0,0,10,10)
-      );
-    }
+        Rectangle(0, 0, 10, 10)
+    );
+}
 
-    // Same triangle with another starting point
-    template<> template<> void object::test<95>()
-    {
-      doClipTest(
+// Same triangle with another starting point
+template<> template<> void object::test<95>
+()
+{
+    doClipTest(
         "POLYGON ((5 10,0 0,10 0,5 10))",
         "POLYGON ((0 0,10 0,5 10,0 0))",
-        Rectangle(0,0,10,10)
-      );
-    }
+        Rectangle(0, 0, 10, 10)
+    );
+}
 
-    // Triangle intersection at corner and edge
-    template<> template<> void object::test<96>()
-    {
-      doClipTest(
+// Triangle intersection at corner and edge
+template<> template<> void object::test<96>
+()
+{
+    doClipTest(
         "POLYGON ((-5 -5,5 5,5 -5,-5 -5))",
         "POLYGON ((0 0,5 5,5 0,0 0))",
-        Rectangle(0,0,10,10)
-      );
-    }
+        Rectangle(0, 0, 10, 10)
+    );
+}
 
-    // All triangles fully inside
-    template<> template<> void object::test<97>()
-    {
-      doClipTest(
+// All triangles fully inside
+template<> template<> void object::test<97>
+()
+{
+    doClipTest(
         "POLYGON ((0 0,0 10,10 10,0 0))",
         "POLYGON ((0 0,0 10,10 10,0 0))",
-        Rectangle(0,0,10,10)
-      );
-    }
+        Rectangle(0, 0, 10, 10)
+    );
+}
 
-    template<> template<> void object::test<98>()
-    {
-      doClipTest(
+template<> template<> void object::test<98>
+()
+{
+    doClipTest(
         "POLYGON ((0 5,0 10,10 10,0 5))",
         "POLYGON ((0 5,0 10,10 10,0 5))",
-        Rectangle(0,0,10,10)
-      );
-    }
+        Rectangle(0, 0, 10, 10)
+    );
+}
 
-    template<> template<> void object::test<99>()
-    {
-      doClipTest(
+template<> template<> void object::test<99>
+()
+{
+    doClipTest(
         "POLYGON ((0 10,10 10,5 0,0 10))",
         "POLYGON ((0 10,10 10,5 0,0 10))",
-        Rectangle(0,0,10,10)
-      );
-    }
+        Rectangle(0, 0, 10, 10)
+    );
+}
 
-    template<> template<> void object::test<100>()
-    {
-      doClipTest(
+template<> template<> void object::test<100>
+()
+{
+    doClipTest(
         "POLYGON ((0 10,10 10,5 5,0 10))",
         "POLYGON ((0 10,10 10,5 5,0 10))",
-        Rectangle(0,0,10,10)
-      );
-    }
+        Rectangle(0, 0, 10, 10)
+    );
+}
 
-    template<> template<> void object::test<101>()
-    {
-      doClipTest(
+template<> template<> void object::test<101>
+()
+{
+    doClipTest(
         "POLYGON ((0 10,5 10,0 5,0 10))",
         "POLYGON ((0 5,0 10,5 10,0 5))",
-        Rectangle(0,0,10,10)
-      );
-    }
+        Rectangle(0, 0, 10, 10)
+    );
+}
 
-    template<> template<> void object::test<102>()
-    {
-      doClipTest(
+template<> template<> void object::test<102>
+()
+{
+    doClipTest(
         "POLYGON ((0 10,10 5,0 5,0 10))",
         "POLYGON ((0 5,0 10,10 5,0 5))",
-        Rectangle(0,0,10,10)
-      );
-    }
+        Rectangle(0, 0, 10, 10)
+    );
+}
 
-    template<> template<> void object::test<103>()
-    {
-      doClipTest(
+template<> template<> void object::test<103>
+()
+{
+    doClipTest(
         "POLYGON ((0 10,10 0,0 5,0 10))",
         "POLYGON ((0 5,0 10,10 0,0 5))",
-        Rectangle(0,0,10,10)
-      );
-    }
+        Rectangle(0, 0, 10, 10)
+    );
+}
 
-    template<> template<> void object::test<104>()
-    {
-      doClipTest(
+template<> template<> void object::test<104>
+()
+{
+    doClipTest(
         "POLYGON ((0 10,5 0,0 5,0 10))",
         "POLYGON ((0 5,0 10,5 0,0 5))",
-        Rectangle(0,0,10,10)
-      );
-    }
+        Rectangle(0, 0, 10, 10)
+    );
+}
 
-    template<> template<> void object::test<105>()
-    {
-      doClipTest(
+template<> template<> void object::test<105>
+()
+{
+    doClipTest(
         "POLYGON ((0 10,5 5,0 5,0 10))",
         "POLYGON ((0 5,0 10,5 5,0 5))",
-        Rectangle(0,0,10,10)
-      );
-    }
+        Rectangle(0, 0, 10, 10)
+    );
+}
 
-    template<> template<> void object::test<106>()
-    {
-      doClipTest(
+template<> template<> void object::test<106>
+()
+{
+    doClipTest(
         "POLYGON ((0 10,7 7,3 3,0 10))",
         "POLYGON ((0 10,7 7,3 3,0 10))",
-        Rectangle(0,0,10,10)
-      );
-    }
+        Rectangle(0, 0, 10, 10)
+    );
+}
 
-    template<> template<> void object::test<107>()
-    {
-      doClipTest(
+template<> template<> void object::test<107>
+()
+{
+    doClipTest(
         "POLYGON ((0 10,5 5,5 0,0 10))",
         "POLYGON ((0 10,5 5,5 0,0 10))",
-        Rectangle(0,0,10,10)
-      );
-    }
+        Rectangle(0, 0, 10, 10)
+    );
+}
 
-    template<> template<> void object::test<108>()
-    {
-      doClipTest(
+template<> template<> void object::test<108>
+()
+{
+    doClipTest(
         "POLYGON ((0 10,10 5,5 0,0 10))",
         "POLYGON ((0 10,10 5,5 0,0 10))",
-        Rectangle(0,0,10,10)
-      );
-    }
+        Rectangle(0, 0, 10, 10)
+    );
+}
 
-    template<> template<> void object::test<109>()
-    {
-      doClipTest(
+template<> template<> void object::test<109>
+()
+{
+    doClipTest(
         "POLYGON ((2 5,5 7,7 5,2 5))",
         "POLYGON ((2 5,5 7,7 5,2 5))",
-        Rectangle(0,0,10,10)
-      );
-    }
+        Rectangle(0, 0, 10, 10)
+    );
+}
 
-    template<> template<> void object::test<110>()
-    {
-      doClipTest(
+template<> template<> void object::test<110>
+()
+{
+    doClipTest(
         "POLYGON ((2 5,5 10,7 5,2 5))",
         "POLYGON ((2 5,5 10,7 5,2 5))",
-        Rectangle(0,0,10,10)
-      );
-    }
+        Rectangle(0, 0, 10, 10)
+    );
+}
 
-    template<> template<> void object::test<111>()
-    {
-      doClipTest(
+template<> template<> void object::test<111>
+()
+{
+    doClipTest(
         "POLYGON ((0 5,5 10,5 5,0 5))",
         "POLYGON ((0 5,5 10,5 5,0 5))",
-        Rectangle(0,0,10,10)
-      );
-    }
+        Rectangle(0, 0, 10, 10)
+    );
+}
 
-    template<> template<> void object::test<112>()
-    {
-      doClipTest(
+template<> template<> void object::test<112>
+()
+{
+    doClipTest(
         "POLYGON ((0 5,5 10,10 5,0 5))",
         "POLYGON ((0 5,5 10,10 5,0 5))",
-        Rectangle(0,0,10,10)
-      );
-    }
+        Rectangle(0, 0, 10, 10)
+    );
+}
 
-    template<> template<> void object::test<113>()
-    {
-      doClipTest(
+template<> template<> void object::test<113>
+()
+{
+    doClipTest(
         "POLYGON ((0 5,5 7,10 5,0 5))",
         "POLYGON ((0 5,5 7,10 5,0 5))",
-        Rectangle(0,0,10,10)
-      );
-    }
+        Rectangle(0, 0, 10, 10)
+    );
+}
 
-    // No points inside, one intersection
-    template<> template<> void object::test<114>()
-    {
-      doClipTest(
+// No points inside, one intersection
+template<> template<> void object::test<114>
+()
+{
+    doClipTest(
         "POLYGON ((-5 10,0 15,0 10,-5 10))",
         "GEOMETRYCOLLECTION EMPTY",
-        Rectangle(0,0,10,10)
-      );
-    }
+        Rectangle(0, 0, 10, 10)
+    );
+}
 
-    template<> template<> void object::test<115>()
-    {
-      doClipTest(
+template<> template<> void object::test<115>
+()
+{
+    doClipTest(
         "POLYGON ((-5 10,0 5,-5 0,-5 10))",
         "GEOMETRYCOLLECTION EMPTY",
-        Rectangle(0,0,10,10)
-      );
-    }
+        Rectangle(0, 0, 10, 10)
+    );
+}
 
-    // No points inside, two intersections
-    template<> template<> void object::test<116>()
-    {
-      doClipTest(
+// No points inside, two intersections
+template<> template<> void object::test<116>
+()
+{
+    doClipTest(
         "POLYGON ((-5 5,0 10,0 0,-5 5))",
         "GEOMETRYCOLLECTION EMPTY",
-        Rectangle(0,0,10,10)
-      );
-    }
+        Rectangle(0, 0, 10, 10)
+    );
+}
 
-    template<> template<> void object::test<117>()
-    {
-      doClipTest(
+template<> template<> void object::test<117>
+()
+{
+    doClipTest(
         "POLYGON ((-5 5,0 10,0 5,-5 5))",
         "GEOMETRYCOLLECTION EMPTY",
-        Rectangle(0,0,10,10)
-      );
-    }
+        Rectangle(0, 0, 10, 10)
+    );
+}
 
-    template<> template<> void object::test<118>()
-    {
-      doClipTest(
+template<> template<> void object::test<118>
+()
+{
+    doClipTest(
         "POLYGON ((-5 5,0 7,0 3,-5 5))",
         "GEOMETRYCOLLECTION EMPTY",
-        Rectangle(0,0,10,10)
-      );
-    }
+        Rectangle(0, 0, 10, 10)
+    );
+}
 
-    // One point inside
-    template<> template<> void object::test<119>()
-    {
-      doClipTest(
+// One point inside
+template<> template<> void object::test<119>
+()
+{
+    doClipTest(
         "POLYGON ((5 5,-5 0,-5 10,5 5))",
         "POLYGON ((0.0 2.5,0.0 7.5,5 5,0.0 2.5))",
-        Rectangle(0,0,10,10)
-      );
-    }
+        Rectangle(0, 0, 10, 10)
+    );
+}
 
-    template<> template<> void object::test<120>()
-    {
-      doClipTest(
+template<> template<> void object::test<120>
+()
+{
+    doClipTest(
         "POLYGON ((5 0,-5 0,-5 10,5 0))",
         "POLYGON ((0 0,0 5,5 0,0 0))",
-        Rectangle(0,0,10,10)
-      );
-    }
+        Rectangle(0, 0, 10, 10)
+    );
+}
 
-    template<> template<> void object::test<121>()
-    {
-      doClipTest(
+template<> template<> void object::test<121>
+()
+{
+    doClipTest(
         "POLYGON ((10 0,-10 0,-10 10,10 0))",
         "POLYGON ((0 0,0 5,10 0,0 0))",
-        Rectangle(0,0,10,10)
-      );
-    }
+        Rectangle(0, 0, 10, 10)
+    );
+}
 
-    template<> template<> void object::test<122>()
-    {
-      doClipTest(
+template<> template<> void object::test<122>
+()
+{
+    doClipTest(
         "POLYGON ((5 0,-5 5,-5 10,5 0))",
         "POLYGON ((0.0 2.5,0 5,5 0,0.0 2.5))",
-        Rectangle(0,0,10,10)
-      );
-    }
+        Rectangle(0, 0, 10, 10)
+    );
+}
 
-    template<> template<> void object::test<123>()
-    {
-      doClipTest(
+template<> template<> void object::test<123>
+()
+{
+    doClipTest(
         "POLYGON ((10 5,-10 0,-10 10,10 5))",
         "POLYGON ((0.0 2.5,0.0 7.5,10 5,0.0 2.5))",
-        Rectangle(0,0,10,10)
-      );
-    }
+        Rectangle(0, 0, 10, 10)
+    );
+}
 
-    template<> template<> void object::test<124>()
-    {
-      doClipTest(
+template<> template<> void object::test<124>
+()
+{
+    doClipTest(
         "POLYGON ((10 10,-10 0,-10 5,10 10))",
         "POLYGON ((0 5,0.0 7.5,10 10,0 5))",
-        Rectangle(0,0,10,10)
-      );
-    }
+        Rectangle(0, 0, 10, 10)
+    );
+}
 
-    template<> template<> void object::test<125>()
-    {
-      doClipTest(
+template<> template<> void object::test<125>
+()
+{
+    doClipTest(
         "POLYGON ((5 5,-5 -5,-5 15,5 5))",
         "POLYGON ((0 0,0 10,5 5,0 0))",
-        Rectangle(0,0,10,10)
-      );
-    }
+        Rectangle(0, 0, 10, 10)
+    );
+}
 
-    template<> template<> void object::test<126>()
-    {
-      doClipTest(
+template<> template<> void object::test<126>
+()
+{
+    doClipTest(
         "POLYGON ((10 5,-10 -5,-10 15,10 5))",
         "POLYGON ((0 0,0 10,10 5,0 0))",
-        Rectangle(0,0,10,10)
-      );
-    }
+        Rectangle(0, 0, 10, 10)
+    );
+}
 
-    template<> template<> void object::test<127>()
-    {
-      doClipTest(
+template<> template<> void object::test<127>
+()
+{
+    doClipTest(
         "POLYGON ((5 0,-5 0,-5 20,5 0))",
         "POLYGON ((0 0,0 10,5 0,0 0))",
-        Rectangle(0,0,10,10)
-      );
-    }
+        Rectangle(0, 0, 10, 10)
+    );
+}
 
-    template<> template<> void object::test<128>()
-    {
-      doClipTest(
+template<> template<> void object::test<128>
+()
+{
+    doClipTest(
         "POLYGON ((10 0,-10 0,-10 20,10 0))",
         "POLYGON ((0 0,0 10,10 0,0 0))",
-        Rectangle(0,0,10,10)
-      );
-    }
+        Rectangle(0, 0, 10, 10)
+    );
+}
 
-    template<> template<> void object::test<129>()
-    {
-      doClipTest(
+template<> template<> void object::test<129>
+()
+{
+    doClipTest(
         "POLYGON ((5 5,-10 5,0 15,5 5))",
         "POLYGON ((0 5,0 10,2.5 10.0,5 5,0 5))",
-        Rectangle(0,0,10,10)
-      );
-    }
+        Rectangle(0, 0, 10, 10)
+    );
+}
 
-    template<> template<> void object::test<130>()
-    {
-      doClipTest(
+template<> template<> void object::test<130>
+()
+{
+    doClipTest(
         "POLYGON ((5 5,-5 -5,0 15,5 5))",
         "POLYGON ((0 0,0 10,2.5 10.0,5 5,0 0))",
-        Rectangle(0,0,10,10)
-      );
-    }
+        Rectangle(0, 0, 10, 10)
+    );
+}
 
-    template<> template<> void object::test<131>()
-    {
-      doClipTest(
+template<> template<> void object::test<131>
+()
+{
+    doClipTest(
         "POLYGON ((5 5,-15 -20,-15 30,5 5))",
         "POLYGON ((0 0,0 10,1 10,5 5,1 0,0 0))",
-        Rectangle(0,0,10,10)
-      );
-    }
+        Rectangle(0, 0, 10, 10)
+    );
+}
 
-    // Two points inside
-    template<> template<> void object::test<132>()
-    {
-      doClipTest(
+// Two points inside
+template<> template<> void object::test<132>
+()
+{
+    doClipTest(
         "POLYGON ((5 7,5 3,-5 5,5 7))",
         "POLYGON ((0 4,0 6,5 7,5 3,0 4))",
-        Rectangle(0,0,10,10)
-      );
-    }
+        Rectangle(0, 0, 10, 10)
+    );
+}
 
-    template<> template<> void object::test<133>()
-    {
-      doClipTest(
+template<> template<> void object::test<133>
+()
+{
+    doClipTest(
         "POLYGON ((5 7,5 3,-5 13,5 7))",
         "POLYGON ((0 8,0 10,5 7,5 3,0 8))",
-        Rectangle(0,0,10,10)
-      );
-    }
+        Rectangle(0, 0, 10, 10)
+    );
+}
 
-    template<> template<> void object::test<134>()
-    {
-      doClipTest(
+template<> template<> void object::test<134>
+()
+{
+    doClipTest(
         "POLYGON ((6 6,4 4,-4 14,6 6))",
         "POLYGON ((0 9,0 10,1.0 10.0,6 6,4 4,0 9))",
-        Rectangle(0,0,10,10), 1e-12
-      );
-    }
+        Rectangle(0, 0, 10, 10), 1e-12
+    );
+}
 
-    // Polygon with hole which surrounds the rectangle
-    template<> template<> void object::test<135>()
-    {
-      doClipTest(
+// Polygon with hole which surrounds the rectangle
+template<> template<> void object::test<135>
+()
+{
+    doClipTest(
         "POLYGON ((-2 -2,-2 12,12 12,12 -2,-2 -2),(-1 -1,11 -1,11 11,-1 11,-1 -1))",
         "GEOMETRYCOLLECTION EMPTY",
-        Rectangle(0,0,10,10)
-      );
-    }
+        Rectangle(0, 0, 10, 10)
+    );
+}
 
-    // Polygon surrounding the rect, but with a hole inside the rect
-    template<> template<> void object::test<136>()
-    {
-      doClipTest(
+// Polygon surrounding the rect, but with a hole inside the rect
+template<> template<> void object::test<136>
+()
+{
+    doClipTest(
         "POLYGON ((-2 -2,-2 12,12 12,12 -2,-2 -2),(1 1,9 1,9 9,1 9,1 1))",
         "POLYGON ((0 0,0 10,10 10,10 0,0 0),(1 1,9 1,9 9,1 9,1 1))",
-        Rectangle(0,0,10,10)
-      );
-    }
+        Rectangle(0, 0, 10, 10)
+    );
+}
 
-    // Polygon with hole cut at the right corner
-    template<> template<> void object::test<137>()
-    {
-      doClipTest(
+// Polygon with hole cut at the right corner
+template<> template<> void object::test<137>
+()
+{
+    doClipTest(
         "POLYGON ((5 5,15 5,15 -5,5 -5,5 5),(8 1,8 -1,9 -1,9 1,8 1))",
         "POLYGON ((5 0,5 5,10 5,10 0,9 0,9 1,8 1,8 0,5 0))",
-        Rectangle(0,0,10,10)
-      );
-    }
+        Rectangle(0, 0, 10, 10)
+    );
+}
 
-    // Polygon going around a corner
-    template<> template<> void object::test<138>()
-    {
-      doClipTest(
+// Polygon going around a corner
+template<> template<> void object::test<138>
+()
+{
+    doClipTest(
         "POLYGON ((-6 5,5 5,5 -6,-6 5))",
         "POLYGON ((0 0,0 5,5 5,5 0,0 0))",
-        Rectangle(0,0,10,10)
-      );
-    }
+        Rectangle(0, 0, 10, 10)
+    );
+}
 
-    // Hole in a corner
-    template<> template<> void object::test<139>()
-    {
-      doClipTest(
+// Hole in a corner
+template<> template<> void object::test<139>
+()
+{
+    doClipTest(
         "POLYGON ((-15 -15,-15 15,15 15,15 -15,-15 -15),(-5 5,-5 -5,5 -5,5 5,-5 5))",
         "POLYGON ((0 5,0 10,10 10,10 0,5 0,5 5,0 5))",
-        Rectangle(0,0,10,10)
-      );
-    }
+        Rectangle(0, 0, 10, 10)
+    );
+}
 
-    // Hole going around a corner
-    template<> template<> void object::test<140>()
-    {
-      doClipTest(
+// Hole going around a corner
+template<> template<> void object::test<140>
+()
+{
+    doClipTest(
         "POLYGON ((-15 -15,-15 15,15 15,15 -15,-15 -15),(-6 5,5 -6,5 5,-6 5))",
         "POLYGON ((0 5,0 10,10 10,10 0,5 0,5 5,0 5))",
-        Rectangle(0,0,10,10)
-      );
-    }
+        Rectangle(0, 0, 10, 10)
+    );
+}
 
-    // Surround the rectangle, hole outside rectangle
-    template<> template<> void object::test<141>()
-    {
-      doClipTest(
+// Surround the rectangle, hole outside rectangle
+template<> template<> void object::test<141>
+()
+{
+    doClipTest(
         "POLYGON ((-15 -15,-15 15,15 15,15 -15,-15 -15),(-5 5,-6 5,-6 6,-5 6,-5 5))",
         "POLYGON ((0 0,0 10,10 10,10 0,0 0))",
-        Rectangle(0,0,10,10)
-      );
-    }
+        Rectangle(0, 0, 10, 10)
+    );
+}
 
-    // Surround the rectangle, hole outside rectangle but shares edge
-    template<> template<> void object::test<142>()
-    {
-      doClipTest(
+// Surround the rectangle, hole outside rectangle but shares edge
+template<> template<> void object::test<142>
+()
+{
+    doClipTest(
         "POLYGON ((-15 -15,-15 15,15 15,15 -15,-15 -15),(0 5,-1 5,-1 6,0 6,0 5))",
         "POLYGON ((0 0,0 10,10 10,10 0,0 0))",
-        Rectangle(0,0,10,10)
-      );
-    }
+        Rectangle(0, 0, 10, 10)
+    );
+}
 
 //-- NEW TESTS HERE
 
-    // Simple overlap, counter-clockwise shell
-    // Found in TestFunctionAA.xml case1 test1
-    template<> template<> void object::test<204>()
-    {
-      Rectangle r(10,10,100,100);
-      const char *inp =
+// Simple overlap, counter-clockwise shell
+// Found in TestFunctionAA.xml case1 test1
+template<> template<> void object::test<204>
+()
+{
+    Rectangle r(10, 10, 100, 100);
+    const char* inp =
         "POLYGON ((50 50,200 50,200 200,50 200,50 50))"; // CCW
-        //"POLYGON((50 50,50 200,200 200,200 50,50 50))"; // CW
-      const char *exp =
+    //"POLYGON((50 50,50 200,200 200,200 50,50 50))"; // CW
+    const char* exp =
         "POLYGON ((50 50, 50 100, 100 100, 100 50, 50 50))";
-      doClipTest(inp, exp, r);
-    }
+    doClipTest(inp, exp, r);
+}
 
-    // Clockwise shell, clockwise hole (both clipped)
-    template<> template<> void object::test<205>()
-    {
-      Rectangle r(0,0,10,10);
-      const char *inp =
+// Clockwise shell, clockwise hole (both clipped)
+template<> template<> void object::test<205>
+()
+{
+    Rectangle r(0, 0, 10, 10);
+    const char* inp =
         "POLYGON ("
-          "(-10 2,-10 8,8 8,8 2,-10 2)," // CW
-          "(-5 6,5 6,5 4,-5 4,-5 6)"     // CW
+        "(-10 2,-10 8,8 8,8 2,-10 2)," // CW
+        "(-5 6,5 6,5 4,-5 4,-5 6)"     // CW
         ")";
-      const char *exp =
+    const char* exp =
         "POLYGON((0 8,8 8, 8 2, 0 2, 0 4, 5 4, 5 6, 0 6, 0 8))";
-      doClipTest(inp, exp, r);
-    }
+    doClipTest(inp, exp, r);
+}
 
-    // Counterclockwise shell, clockwise hole (both clipped)
-    template<> template<> void object::test<206>()
-    {
-      Rectangle r(0,0,10,10);
-      const char *inp =
+// Counterclockwise shell, clockwise hole (both clipped)
+template<> template<> void object::test<206>
+()
+{
+    Rectangle r(0, 0, 10, 10);
+    const char* inp =
         "POLYGON ("
-          "(-10 2,8 2,8 8,-10 8,-10 2)," // CCW
-          "(-5 6,5 6,5 4,-5 4,-5 6)"     // CW
+        "(-10 2,8 2,8 8,-10 8,-10 2)," // CCW
+        "(-5 6,5 6,5 4,-5 4,-5 6)"     // CW
         ")";
-      const char *exp =
+    const char* exp =
         "POLYGON((0 8,8 8, 8 2, 0 2, 0 4, 5 4, 5 6, 0 6, 0 8))";
-      doClipTest(inp, exp, r);
-    }
+    doClipTest(inp, exp, r);
+}
 
-    // Hole outside the rect shares the lower-left corner
-    template<> template<> void object::test<207>()
-    {
-      Rectangle r(0,0,10,10);
-      const char *inp =
+// Hole outside the rect shares the lower-left corner
+template<> template<> void object::test<207>
+()
+{
+    Rectangle r(0, 0, 10, 10);
+    const char* inp =
         "POLYGON ("
-          "(-10 -10,-10 20,20 20,20 -10,-10 -10)," // CW
-          "(-5 -5,0 -5,0 0,-5 0,-5 -5)"     // CCW
+        "(-10 -10,-10 20,20 20,20 -10,-10 -10)," // CW
+        "(-5 -5,0 -5,0 0,-5 0,-5 -5)"     // CCW
         ")";
-      const char *exp =
+    const char* exp =
         "POLYGON((0 0,0 10,10 10,10 0,0 0))";
-      doClipTest(inp, exp, r);
-    }
+    doClipTest(inp, exp, r);
+}
 
-    // PostGIS hanging unit test
-    template<> template<> void object::test<208>()
-    {
-      Rectangle r(3.0481343214686657e-14, -20000000.000000, 20000000.000000, -1.000000);
-      const char *clip =
+// PostGIS hanging unit test
+template<> template<> void object::test<208>
+()
+{
+    Rectangle r(3.0481343214686657e-14, -20000000.000000, 20000000.000000, -1.000000);
+    const char* clip =
         "POLYGON((3.0481343214686657e-14 -20000000, 200000000 -20000000, 200000000 -1, 3.0481343214686657e-14 -1, 3.0481343214686657e-14 -20000000))";
-      const char *inp =
+    const char* inp =
         "POLYGON((3.0481343214686657e-14 -20000000, 3.0481343214686657e-14 -1, 1.570795680861262382313481289e-3 -0.999998766299703523152686557296, 3.141587485909849188081555127e-3 -0.999995065201858102099663483386, 3.0481343214686657e-14 -20000000))";
 
-      GeomPtr isect{readWKT(clip)->intersection(readWKT(inp).get())};
-      std::string exp = wktwriter.write(isect.get());
+    GeomPtr isect{readWKT(clip)->intersection(readWKT(inp).get())};
+    std::string exp = wktwriter.write(isect.get());
 
-      doClipTest(inp, exp, r, 1e-20);
-    }
+    doClipTest(inp, exp, r, 1e-20);
+}
 }
diff --git a/tests/unit/operation/linemerge/LineMergerTest.cpp b/tests/unit/operation/linemerge/LineMergerTest.cpp
index 1f83205..2f71388 100644
--- a/tests/unit/operation/linemerge/LineMergerTest.cpp
+++ b/tests/unit/operation/linemerge/LineMergerTest.cpp
@@ -17,15 +17,13 @@
 #include <string>
 #include <vector>
 
-namespace tut
-{
-  //
-  // Test Group
-  //
+namespace tut {
+//
+// Test Group
+//
 
-  // Common data used by tests
-  struct test_linemerger_data
-  {
+// Common data used by tests
+struct test_linemerger_data {
     typedef geos::operation::linemerge::LineMerger LineMerger;
     typedef std::vector<geos::geom::Geometry*> GeomVect;
     typedef std::vector<geos::geom::LineString*> LineVect;
@@ -41,240 +39,265 @@ namespace tut
     LineVect* mrgGeoms;
 
     test_linemerger_data()
-      : wktreader(), wktwriter(), mrgGeoms(nullptr)
+        : wktreader(), wktwriter(), mrgGeoms(nullptr)
     {
-      wktwriter.setTrim(true);
+        wktwriter.setTrim(true);
     }
 
     ~test_linemerger_data()
     {
-      delAll(inpGeoms);
-      delAll(expGeoms);
-      if ( mrgGeoms ) {
-        delAll(*mrgGeoms);
-        delete mrgGeoms;
-      }
+        delAll(inpGeoms);
+        delAll(expGeoms);
+        if(mrgGeoms) {
+            delAll(*mrgGeoms);
+            delete mrgGeoms;
+        }
     }
 
-    GeomPtr readWKT(const std::string& inputWKT)
+    GeomPtr
+    readWKT(const std::string& inputWKT)
     {
         return GeomPtr(wktreader.read(inputWKT));
     }
 
-    void readWKT(const char* const* inputWKT, std::vector<Geom*>& geoms)
+    void
+    readWKT(const char* const* inputWKT, std::vector<Geom*>& geoms)
     {
-      for (const char* const* ptr=inputWKT; *ptr; ++ptr) {
-        geoms.push_back(readWKT(*ptr).release());
-      }
+        for(const char* const* ptr = inputWKT; *ptr; ++ptr) {
+            geoms.push_back(readWKT(*ptr).release());
+        }
     }
 
-    void doTest(const char * const * inputWKT,
-                const char * const * expectedWKT,
-                bool compareDirections=true)
+    void
+    doTest(const char* const* inputWKT,
+           const char* const* expectedWKT,
+           bool compareDirections = true)
     {
-      LineMerger lineMerger;
+        LineMerger lineMerger;
 
-      readWKT(inputWKT, inpGeoms);
-      readWKT(expectedWKT, expGeoms);
+        readWKT(inputWKT, inpGeoms);
+        readWKT(expectedWKT, expGeoms);
 
-      lineMerger.add(&inpGeoms);
-      mrgGeoms = lineMerger.getMergedLineStrings();
-      compare(expGeoms, *mrgGeoms, compareDirections);
+        lineMerger.add(&inpGeoms);
+        mrgGeoms = lineMerger.getMergedLineStrings();
+        compare(expGeoms, *mrgGeoms, compareDirections);
 
     }
 
     template <class TargetContainer>
-    void delAll(TargetContainer& geoms)
+    void
+    delAll(TargetContainer& geoms)
     {
-      for (typename TargetContainer::const_iterator i = geoms.begin(),
-           e = geoms.end(); i != e; ++i)
-      {
-        Geom* g = dynamic_cast<Geom*>(*i);
-        delete g;
-      }
+        for(typename TargetContainer::const_iterator i = geoms.begin(),
+                e = geoms.end(); i != e; ++i) {
+            Geom* g = dynamic_cast<Geom*>(*i);
+            delete g;
+        }
     }
 
     template <class TargetContainer1, class TargetContainer2>
-    static void compare(TargetContainer1& expectedGeometries,
-                        TargetContainer2& actualGeometries,
-                        bool compareDirections)
+    static void
+    compare(TargetContainer1& expectedGeometries,
+            TargetContainer2& actualGeometries,
+            bool compareDirections)
     {
-      ensure_equals(actualGeometries.size(), expectedGeometries.size());
-      for (typename TargetContainer1::const_iterator
-          i = expectedGeometries.begin(),
-          e = expectedGeometries.end(); i != e; ++i)
-      {
-        Geom* g = dynamic_cast<Geom*>(*i);
-        ensure( contains(actualGeometries, g, compareDirections) );
-      }
+        ensure_equals(actualGeometries.size(), expectedGeometries.size());
+        for(typename TargetContainer1::const_iterator
+                i = expectedGeometries.begin(),
+                e = expectedGeometries.end(); i != e; ++i) {
+            Geom* g = dynamic_cast<Geom*>(*i);
+            ensure(contains(actualGeometries, g, compareDirections));
+        }
     }
 
     template <class TargetContainer>
-    static bool contains(TargetContainer& actualGeometries,
-                         const Geom* g, bool exact)
+    static bool
+    contains(TargetContainer& actualGeometries,
+             const Geom* g, bool exact)
     {
-      for (typename TargetContainer::const_iterator
-           i = actualGeometries.begin(),
-           e = actualGeometries.end(); i != e; ++i)
-      {
-        Geom* element = dynamic_cast<Geom*>(*i);
-        if (exact && element->equalsExact(g)) {
-          return true;
-        }
-        if (!exact && element->equals(g)) {
-          return true;
+        for(typename TargetContainer::const_iterator
+                i = actualGeometries.begin(),
+                e = actualGeometries.end(); i != e; ++i) {
+            Geom* element = dynamic_cast<Geom*>(*i);
+            if(exact && element->equalsExact(g)) {
+                return true;
+            }
+            if(!exact && element->equals(g)) {
+                return true;
+            }
         }
-      }
 
-      return false;
+        return false;
     }
 
 
 
-  private:
+private:
     // noncopyable
     test_linemerger_data(test_linemerger_data const& other) = delete;
     test_linemerger_data& operator=(test_linemerger_data const& rhs) = delete;
-  };
+};
 
-  typedef test_group<test_linemerger_data> group;
-  typedef group::object object;
+typedef test_group<test_linemerger_data> group;
+typedef group::object object;
 
-  group test_linemerger_group("geos::operation::linemerge::LineMerger");
+group test_linemerger_group("geos::operation::linemerge::LineMerger");
 
-  //
-  // Test Cases
-  //
+//
+// Test Cases
+//
 
-  template<> template<>
-  void object::test<1>()
-  {
+template<> template<>
+void object::test<1>
+()
+{
     const char* inpWKT[] = {
-      "LINESTRING (120 120, 180 140)", "LINESTRING (200 180, 180 140)",
-      "LINESTRING (200 180, 240 180)",
-      nullptr };
+        "LINESTRING (120 120, 180 140)", "LINESTRING (200 180, 180 140)",
+        "LINESTRING (200 180, 240 180)",
+        nullptr
+    };
     const char* expWKT[] = {
-      "LINESTRING (120 120, 180 140, 200 180, 240 180)",
-      nullptr };
+        "LINESTRING (120 120, 180 140, 200 180, 240 180)",
+        nullptr
+    };
 
     doTest(inpWKT, expWKT);
-  }
+}
 
-  // Only lines with coincident vertices may be merged.
-  template<> template<>
-  void object::test<2>()
-  {
+// Only lines with coincident vertices may be merged.
+template<> template<>
+void object::test<2>
+()
+{
     const char* inpWKT[] = {
-      "LINESTRING (120 300, 80 340)",
-      "LINESTRING (120 300, 140 320, 160 320)",
-      "LINESTRING (40 320, 20 340, 0 320)",
-      "LINESTRING (0 320, 20 300, 40 320)",
-      "LINESTRING (40 320, 60 320, 80 340)",
-      "LINESTRING (160 320, 180 340, 200 320)",
-      "LINESTRING (200 320, 180 300, 160 320)",
-      nullptr };
+        "LINESTRING (120 300, 80 340)",
+        "LINESTRING (120 300, 140 320, 160 320)",
+        "LINESTRING (40 320, 20 340, 0 320)",
+        "LINESTRING (0 320, 20 300, 40 320)",
+        "LINESTRING (40 320, 60 320, 80 340)",
+        "LINESTRING (160 320, 180 340, 200 320)",
+        "LINESTRING (200 320, 180 300, 160 320)",
+        nullptr
+    };
     const char* expWKT[] = {
-      "LINESTRING (160 320, 180 340, 200 320, 180 300, 160 320)",
-      "LINESTRING (40 320, 20 340, 0 320, 20 300, 40 320)",
-      "LINESTRING (40 320, 60 320, 80 340, 120 300, 140 320, 160 320)",
-      nullptr };
+        "LINESTRING (160 320, 180 340, 200 320, 180 300, 160 320)",
+        "LINESTRING (40 320, 20 340, 0 320, 20 300, 40 320)",
+        "LINESTRING (40 320, 60 320, 80 340, 120 300, 140 320, 160 320)",
+        nullptr
+    };
 
     doTest(inpWKT, expWKT);
-  }
+}
 
-  // Two intersecting/crossing segments must not merge
-  template<> template<>
-  void object::test<3>()
-  {
+// Two intersecting/crossing segments must not merge
+template<> template<>
+void object::test<3>
+()
+{
     const char* inpWKT[] = {
-      "LINESTRING (0 0, 100 100)", "LINESTRING (0 100, 100 0)",
-      nullptr };
+        "LINESTRING (0 0, 100 100)", "LINESTRING (0 100, 100 0)",
+        nullptr
+    };
     const char* expWKT[] = {
-      "LINESTRING (0 0, 100 100)", "LINESTRING (0 100, 100 0)",
-      nullptr };
+        "LINESTRING (0 0, 100 100)", "LINESTRING (0 100, 100 0)",
+        nullptr
+    };
 
     doTest(inpWKT, expWKT);
-  }
+}
 
-  template<> template<>
-  void object::test<4>()
-  {
+template<> template<>
+void object::test<4>
+()
+{
     const char* inpWKT[] = {
-      "LINESTRING EMPTY",
-      "LINESTRING EMPTY",
-      nullptr };
+        "LINESTRING EMPTY",
+        "LINESTRING EMPTY",
+        nullptr
+    };
     const char* expWKT[] = {
-      nullptr };
+        nullptr
+    };
 
     doTest(inpWKT, expWKT);
-  }
+}
 
-  // Don't blame me for this, I'm just copying JTS tests :P
-  template<> template<>
-  void object::test<5>()
-  {
+// Don't blame me for this, I'm just copying JTS tests :P
+template<> template<>
+void object::test<5>
+()
+{
     const char* inpWKT[] = {
-      nullptr };
+        nullptr
+    };
     const char* expWKT[] = {
-      nullptr };
+        nullptr
+    };
 
     doTest(inpWKT, expWKT);
-  }
+}
 
-  // testSingleUniquePoint()
-  template<> template<>
-  void object::test<6>()
-  {
+// testSingleUniquePoint()
+template<> template<>
+void object::test<6>
+()
+{
     const char* inpWKT[] = {
-      "LINESTRING (10642 31441, 10642 31441)",
-      nullptr };
+        "LINESTRING (10642 31441, 10642 31441)",
+        nullptr
+    };
     const char* expWKT[] = {
-      nullptr };
+        nullptr
+    };
 
     doTest(inpWKT, expWKT);
-  }
+}
 
-  // Merge segments of a triangle
-  template<> template<>
-  void object::test<7>()
-  {
-      const char* inpWKT[] = {
+// Merge segments of a triangle
+template<> template<>
+void object::test<7>
+()
+{
+    const char* inpWKT[] = {
         "LINESTRING(0 0, 0 5)",
         "LINESTRING(0 5, 5 5)",
         "LINESTRING(5 5, 5 0)",
         "LINESTRING(5 0, 0 0)",
-        nullptr };
-      const char* expWKT[] = {
+        nullptr
+    };
+    const char* expWKT[] = {
         "LINESTRING(0 0, 0 5, 5 5, 5 0, 0 0)",
-          nullptr };
-
-      doTest(inpWKT, expWKT);
-  }
-
-  // Merge union of segments of a triangle
-  template<> template<>
-  void object::test<8>()
-  {
-      GeomPtr line1(readWKT("LINESTRING(0 0, 0 5)"));
-      GeomPtr line2(readWKT("LINESTRING(0 5, 5 5)"));
-      GeomPtr line3(readWKT("LINESTRING(5 5, 5 0)"));
-      GeomPtr line4(readWKT("LINESTRING(5 0, 0 0)"));
-      // Union segments incrementally
-      GeomPtr lines12(line1->Union(line2.get()));
-      GeomPtr lines123(lines12->Union(line3.get()));
-      GeomPtr lines1234(lines123->Union(line4.get()));
-
-      // MultiLineString expected by design, see corresponding test in OverlayOpUnionTest
-      ensure_equals(lines1234->getGeometryTypeId(), geos::geom::GEOS_MULTILINESTRING);
-
-      // Merge MultiLineString into LineString
-      LineMerger lineMerger;
-      lineMerger.add(lines1234.get());
-      mrgGeoms = lineMerger.getMergedLineStrings();
-
-      GeomPtr expected(readWKT("LINESTRING(0 0, 0 5, 5 5, 5 0, 0 0)"));
-      ensure(contains(*mrgGeoms, expected.get(), true));
-  }
+        nullptr
+    };
+
+    doTest(inpWKT, expWKT);
+}
+
+// Merge union of segments of a triangle
+template<> template<>
+void object::test<8>
+()
+{
+    GeomPtr line1(readWKT("LINESTRING(0 0, 0 5)"));
+    GeomPtr line2(readWKT("LINESTRING(0 5, 5 5)"));
+    GeomPtr line3(readWKT("LINESTRING(5 5, 5 0)"));
+    GeomPtr line4(readWKT("LINESTRING(5 0, 0 0)"));
+    // Union segments incrementally
+    GeomPtr lines12(line1->Union(line2.get()));
+    GeomPtr lines123(lines12->Union(line3.get()));
+    GeomPtr lines1234(lines123->Union(line4.get()));
+
+    // MultiLineString expected by design, see corresponding test in OverlayOpUnionTest
+    ensure_equals(lines1234->getGeometryTypeId(), geos::geom::GEOS_MULTILINESTRING);
+
+    // Merge MultiLineString into LineString
+    LineMerger lineMerger;
+    lineMerger.add(lines1234.get());
+    mrgGeoms = lineMerger.getMergedLineStrings();
+
+    GeomPtr expected(readWKT("LINESTRING(0 0, 0 5, 5 5, 5 0, 0 0)"));
+    ensure(contains(*mrgGeoms, expected.get(), true));
+}
 
 } // namespace tut
 
diff --git a/tests/unit/operation/linemerge/LineSequencerTest.cpp b/tests/unit/operation/linemerge/LineSequencerTest.cpp
index 5da318c..2b9bd95 100644
--- a/tests/unit/operation/linemerge/LineSequencerTest.cpp
+++ b/tests/unit/operation/linemerge/LineSequencerTest.cpp
@@ -17,15 +17,13 @@
 #include <string>
 #include <vector>
 
-namespace tut
-{
-  //
-  // Test Group
-  //
+namespace tut {
+//
+// Test Group
+//
 
-  // Common data used by tests
-  struct test_linesequencer_data
-  {
+// Common data used by tests
+struct test_linesequencer_data {
     typedef geos::operation::linemerge::LineSequencer LineSequencer;
     typedef std::vector<geos::geom::Geometry*> GeomVect;
     typedef std::vector<geos::geom::LineString*> LineVect;
@@ -39,249 +37,275 @@ namespace tut
     GeomVect inpGeoms;
 
     test_linesequencer_data()
-      : wktreader(), wktwriter()
+        : wktreader(), wktwriter()
     {
-      wktwriter.setTrim(true);
+        wktwriter.setTrim(true);
     }
 
     ~test_linesequencer_data()
     {
-      delAll(inpGeoms);
+        delAll(inpGeoms);
     }
 
-    GeomPtr readWKT(const std::string& inputWKT)
+    GeomPtr
+    readWKT(const std::string& inputWKT)
     {
         return GeomPtr(wktreader.read(inputWKT));
     }
 
-    void readWKT(const char* const* inputWKT, std::vector<Geom*>& geoms)
+    void
+    readWKT(const char* const* inputWKT, std::vector<Geom*>& geoms)
     {
-      for (const char* const* ptr=inputWKT; *ptr; ++ptr) {
-        geoms.push_back(readWKT(*ptr).release());
-      }
+        for(const char* const* ptr = inputWKT; *ptr; ++ptr) {
+            geoms.push_back(readWKT(*ptr).release());
+        }
     }
 
-    void runLineSequencer(const char * const * inputWKT,
-                const std::string& expectedWKT)
+    void
+    runLineSequencer(const char* const* inputWKT,
+                     const std::string& expectedWKT)
     {
-      readWKT(inputWKT, inpGeoms);
-
-      LineSequencer sequencer;
-      sequencer.add(inpGeoms);
-
-      if ( ! sequencer.isSequenceable() ) {
-      	ensure( expectedWKT.empty() );
-      } else {
-        GeomPtr expected = readWKT(expectedWKT);
-        GeomPtr result ( sequencer.getSequencedLineStrings() );
-        ensure( expected->equalsExact( result.get() ) );
-
-        bool isSequenced = LineSequencer::isSequenced(result.get());
-        ensure( isSequenced );
-      }
+        readWKT(inputWKT, inpGeoms);
+
+        LineSequencer sequencer;
+        sequencer.add(inpGeoms);
+
+        if(! sequencer.isSequenceable()) {
+            ensure(expectedWKT.empty());
+        }
+        else {
+            GeomPtr expected = readWKT(expectedWKT);
+            GeomPtr result(sequencer.getSequencedLineStrings());
+            ensure(expected->equalsExact(result.get()));
+
+            bool isSequenced = LineSequencer::isSequenced(result.get());
+            ensure(isSequenced);
+        }
     }
 
-    void runIsSequenced(const std::string& inputWKT, bool exp)
+    void
+    runIsSequenced(const std::string& inputWKT, bool exp)
     {
-      GeomPtr g = readWKT(inputWKT);
-      bool isSequenced = LineSequencer::isSequenced(g.get());
-      ensure_equals( isSequenced, exp );
+        GeomPtr g = readWKT(inputWKT);
+        bool isSequenced = LineSequencer::isSequenced(g.get());
+        ensure_equals(isSequenced, exp);
     }
 
     template <class TargetContainer>
-    void delAll(TargetContainer& geoms)
+    void
+    delAll(TargetContainer& geoms)
     {
-      for (typename TargetContainer::const_iterator i = geoms.begin(),
-           e = geoms.end(); i != e; ++i)
-      {
-        Geom* g = dynamic_cast<Geom*>(*i);
-        delete g;
-      }
+        for(typename TargetContainer::const_iterator i = geoms.begin(),
+                e = geoms.end(); i != e; ++i) {
+            Geom* g = dynamic_cast<Geom*>(*i);
+            delete g;
+        }
     }
 
 
-  private:
+private:
     // noncopyable
     test_linesequencer_data(test_linesequencer_data const& other) = delete;
     test_linesequencer_data& operator=(test_linesequencer_data const& rhs) = delete;
-  };
+};
 
-  typedef test_group<test_linesequencer_data> group;
-  typedef group::object object;
+typedef test_group<test_linesequencer_data> group;
+typedef group::object object;
 
-  group test_linesequencer_group("geos::operation::linemerge::LineSequencer");
+group test_linesequencer_group("geos::operation::linemerge::LineSequencer");
 
-  //
-  // Test Cases
-  //
+//
+// Test Cases
+//
 
-  // testSimple
-  template<> template<>
-  void object::test<1>()
-  {
+// testSimple
+template<> template<>
+void object::test<1>
+()
+{
     const char* inpWKT[] = {
-      "LINESTRING ( 0 0, 0 10 )",
-      "LINESTRING ( 0 20, 0 30 )",
-      "LINESTRING ( 0 10, 0 20 )",
-      nullptr };
+        "LINESTRING ( 0 0, 0 10 )",
+        "LINESTRING ( 0 20, 0 30 )",
+        "LINESTRING ( 0 10, 0 20 )",
+        nullptr
+    };
     const char* expWKT =
-      "MULTILINESTRING ((0 0, 0 10), (0 10, 0 20), (0 20, 0 30))";
+        "MULTILINESTRING ((0 0, 0 10), (0 10, 0 20), (0 20, 0 30))";
 
     runLineSequencer(inpWKT, expWKT);
-  }
+}
 
-  // testSimpleLoop
-  template<> template<>
-  void object::test<2>()
-  {
+// testSimpleLoop
+template<> template<>
+void object::test<2>
+()
+{
     const char* inpWKT[] = {
-      "LINESTRING ( 0 0, 0 10 )",
-      "LINESTRING ( 0 10, 0 0 )",
-      nullptr };
+        "LINESTRING ( 0 0, 0 10 )",
+        "LINESTRING ( 0 10, 0 0 )",
+        nullptr
+    };
     const char* expWKT =
-      "MULTILINESTRING ((0 0, 0 10), (0 10, 0 0))";
+        "MULTILINESTRING ((0 0, 0 10), (0 10, 0 0))";
     runLineSequencer(inpWKT, expWKT);
-  }
+}
 
-  // testSimpleBigLoop
-  template<> template<>
-  void object::test<3>()
-  {
+// testSimpleBigLoop
+template<> template<>
+void object::test<3>
+()
+{
     const char* inpWKT[] = {
-      "LINESTRING ( 0 0, 0 10 )",
-      "LINESTRING ( 0 20, 0 30 )",
-      "LINESTRING ( 0 30, 0 00 )",
-      "LINESTRING ( 0 10, 0 20 )",
-      nullptr };
+        "LINESTRING ( 0 0, 0 10 )",
+        "LINESTRING ( 0 20, 0 30 )",
+        "LINESTRING ( 0 30, 0 00 )",
+        "LINESTRING ( 0 10, 0 20 )",
+        nullptr
+    };
     const char* expWKT =
-      "MULTILINESTRING ((0 0, 0 10), (0 10, 0 20), (0 20, 0 30), (0 30, 0 0))";
+        "MULTILINESTRING ((0 0, 0 10), (0 10, 0 20), (0 20, 0 30), (0 30, 0 0))";
     runLineSequencer(inpWKT, expWKT);
-  }
+}
 
-  // test2SimpleLoops
-  template<> template<>
-  void object::test<4>()
-  {
+// test2SimpleLoops
+template<> template<>
+void object::test<4>
+()
+{
     const char* inpWKT[] = {
-      "LINESTRING ( 0 0, 0 10 )",
-      "LINESTRING ( 0 10, 0 0 )",
-      "LINESTRING ( 0 0, 0 20 )",
-      "LINESTRING ( 0 20, 0 0 )",
-      nullptr };
+        "LINESTRING ( 0 0, 0 10 )",
+        "LINESTRING ( 0 10, 0 0 )",
+        "LINESTRING ( 0 0, 0 20 )",
+        "LINESTRING ( 0 20, 0 0 )",
+        nullptr
+    };
     const char* expWKT =
-      "MULTILINESTRING ((0 10, 0 0), (0 0, 0 20), (0 20, 0 0), (0 0, 0 10))";
+        "MULTILINESTRING ((0 10, 0 0), (0 0, 0 20), (0 20, 0 0), (0 0, 0 10))";
     runLineSequencer(inpWKT, expWKT);
-  }
+}
 
-  // testWide8WithTail
-  template<> template<>
-  void object::test<5>()
-  {
+// testWide8WithTail
+template<> template<>
+void object::test<5>
+()
+{
     const char* inpWKT[] = {
-      "LINESTRING ( 0 0, 0 10 )",
-      "LINESTRING ( 10 0, 10 10 )",
-      "LINESTRING ( 0 0, 10 0 )",
-      "LINESTRING ( 0 10, 10 10 )",
-      "LINESTRING ( 0 10, 0 20 )",
-      "LINESTRING ( 10 10, 10 20 )",
-      "LINESTRING ( 0 20, 10 20 )",
-
-      "LINESTRING ( 10 20, 30 30 )",
-      nullptr };
+        "LINESTRING ( 0 0, 0 10 )",
+        "LINESTRING ( 10 0, 10 10 )",
+        "LINESTRING ( 0 0, 10 0 )",
+        "LINESTRING ( 0 10, 10 10 )",
+        "LINESTRING ( 0 10, 0 20 )",
+        "LINESTRING ( 10 10, 10 20 )",
+        "LINESTRING ( 0 20, 10 20 )",
+
+        "LINESTRING ( 10 20, 30 30 )",
+        nullptr
+    };
     const char* expWKT = "";
     runLineSequencer(inpWKT, expWKT);
-  }
+}
 
-  // testSimpleLoopWithTail
-  template<> template<>
-  void object::test<6>()
-  {
+// testSimpleLoopWithTail
+template<> template<>
+void object::test<6>
+()
+{
     const char* inpWKT[] = {
-      "LINESTRING ( 0 0, 0 10 )",
-      "LINESTRING ( 0 10, 10 10 )",
-      "LINESTRING ( 10 10, 10 20, 0 10 )",
-      nullptr };
+        "LINESTRING ( 0 0, 0 10 )",
+        "LINESTRING ( 0 10, 10 10 )",
+        "LINESTRING ( 10 10, 10 20, 0 10 )",
+        nullptr
+    };
     const char* expWKT =
-"MULTILINESTRING ((0 0, 0 10), (0 10, 10 10), (10 10, 10 20, 0 10))";
+        "MULTILINESTRING ((0 0, 0 10), (0 10, 10 10), (10 10, 10 20, 0 10))";
     runLineSequencer(inpWKT, expWKT);
-  }
+}
 
-  // testLineWithRing
-  template<> template<>
-  void object::test<7>()
-  {
+// testLineWithRing
+template<> template<>
+void object::test<7>
+()
+{
     const char* inpWKT[] = {
-      "LINESTRING ( 0 0, 0 10 )",
-      "LINESTRING ( 0 10, 10 10, 10 20, 0 10 )",
-      "LINESTRING ( 0 30, 0 20 )",
-      "LINESTRING ( 0 20, 0 10 )",
-      nullptr };
+        "LINESTRING ( 0 0, 0 10 )",
+        "LINESTRING ( 0 10, 10 10, 10 20, 0 10 )",
+        "LINESTRING ( 0 30, 0 20 )",
+        "LINESTRING ( 0 20, 0 10 )",
+        nullptr
+    };
     const char* expWKT =
         "MULTILINESTRING ((0 0, 0 10), (0 10, 10 10, 10 20, 0 10), (0 10, 0 20), (0 20, 0 30))";
     runLineSequencer(inpWKT, expWKT);
-  }
+}
 
-  // testMultipleGraphsWithRing
-  template<> template<>
-  void object::test<8>()
-  {
+// testMultipleGraphsWithRing
+template<> template<>
+void object::test<8>
+()
+{
     const char* inpWKT[] = {
-      "LINESTRING ( 0 0, 0 10 )",
-      "LINESTRING ( 0 10, 10 10, 10 20, 0 10 )",
-      "LINESTRING ( 0 30, 0 20 )",
-      "LINESTRING ( 0 20, 0 10 )",
-      "LINESTRING ( 0 60, 0 50 )",
-      "LINESTRING ( 0 40, 0 50 )",
-      nullptr };
+        "LINESTRING ( 0 0, 0 10 )",
+        "LINESTRING ( 0 10, 10 10, 10 20, 0 10 )",
+        "LINESTRING ( 0 30, 0 20 )",
+        "LINESTRING ( 0 20, 0 10 )",
+        "LINESTRING ( 0 60, 0 50 )",
+        "LINESTRING ( 0 40, 0 50 )",
+        nullptr
+    };
     const char* expWKT =
-"MULTILINESTRING ((0 0, 0 10), (0 10, 10 10, 10 20, 0 10), (0 10, 0 20), (0 20, 0 30), (0 40, 0 50), (0 50, 0 60))";
+        "MULTILINESTRING ((0 0, 0 10), (0 10, 10 10, 10 20, 0 10), (0 10, 0 20), (0 20, 0 30), (0 40, 0 50), (0 50, 0 60))";
     runLineSequencer(inpWKT, expWKT);
-  }
+}
 
-  // testMultipleGraphsWithMultipeRings
-  template<> template<>
-  void object::test<9>()
-  {
+// testMultipleGraphsWithMultipeRings
+template<> template<>
+void object::test<9>
+()
+{
     const char* inpWKT[] = {
-      "LINESTRING ( 0 0, 0 10 )",
-      "LINESTRING ( 0 10, 10 10, 10 20, 0 10 )",
-      "LINESTRING ( 0 10, 40 40, 40 20, 0 10 )",
-      "LINESTRING ( 0 30, 0 20 )",
-      "LINESTRING ( 0 20, 0 10 )",
-      "LINESTRING ( 0 60, 0 50 )",
-      "LINESTRING ( 0 40, 0 50 )",
-      nullptr };
+        "LINESTRING ( 0 0, 0 10 )",
+        "LINESTRING ( 0 10, 10 10, 10 20, 0 10 )",
+        "LINESTRING ( 0 10, 40 40, 40 20, 0 10 )",
+        "LINESTRING ( 0 30, 0 20 )",
+        "LINESTRING ( 0 20, 0 10 )",
+        "LINESTRING ( 0 60, 0 50 )",
+        "LINESTRING ( 0 40, 0 50 )",
+        nullptr
+    };
     const char* expWKT =
         "MULTILINESTRING ((0 0, 0 10), (0 10, 40 40, 40 20, 0 10), (0 10, 10 10, 10 20, 0 10), (0 10, 0 20), (0 20, 0 30), (0 40, 0 50), (0 50, 0 60))";
 
     runLineSequencer(inpWKT, expWKT);
-  }
+}
 
-  // testLineSequence
-  template<> template<>
-  void object::test<10>()
-  {
+// testLineSequence
+template<> template<>
+void object::test<10>
+()
+{
     const char* expWKT = "LINESTRING ( 0 0, 0 10 )";
     runIsSequenced(expWKT, true);
-  }
+}
 
-  // testSplitLineSequence
-  template<> template<>
-  void object::test<11>()
-  {
+// testSplitLineSequence
+template<> template<>
+void object::test<11>
+()
+{
     const char* expWKT =
-      "MULTILINESTRING ((0 0, 0 1), (0 2, 0 3), (0 3, 0 4) )";
+        "MULTILINESTRING ((0 0, 0 1), (0 2, 0 3), (0 3, 0 4) )";
     runIsSequenced(expWKT, true);
-  }
+}
 
-  // testBadLineSequence
-  template<> template<>
-  void object::test<12>()
-  {
+// testBadLineSequence
+template<> template<>
+void object::test<12>
+()
+{
     const char* expWKT =
-      "MULTILINESTRING ((0 0, 0 1), (0 2, 0 3), (0 1, 0 4) )";
+        "MULTILINESTRING ((0 0, 0 1), (0 2, 0 3), (0 1, 0 4) )";
     runIsSequenced(expWKT, false);
-  }
+}
 
 
 } // namespace tut
diff --git a/tests/unit/operation/overlay/OverlayOpUnionTest.cpp b/tests/unit/operation/overlay/OverlayOpUnionTest.cpp
index 638d1e5..8b2dbfd 100644
--- a/tests/unit/operation/overlay/OverlayOpUnionTest.cpp
+++ b/tests/unit/operation/overlay/OverlayOpUnionTest.cpp
@@ -16,51 +16,50 @@
 using namespace geos::geom;
 using namespace geos::operation;
 
-namespace tut
-{
-    //
-    // Test Group
-    //
+namespace tut {
+//
+// Test Group
+//
 
-    struct test_overlayopunion_data
-    {
-        typedef geos::geom::Geometry::Ptr GeometryPtr;
-        typedef geos::geom::GeometryFactory GeometryFactory;
-        typedef geos::geom::GeometryFactory::Ptr GeometryFactoryPtr;
-    };
+struct test_overlayopunion_data {
+    typedef geos::geom::Geometry::Ptr GeometryPtr;
+    typedef geos::geom::GeometryFactory GeometryFactory;
+    typedef geos::geom::GeometryFactory::Ptr GeometryFactoryPtr;
+};
 
-    typedef test_group<test_overlayopunion_data> group;
-    typedef group::object object;
+typedef test_group<test_overlayopunion_data> group;
+typedef group::object object;
 
-    group test_overlayopunion_group("geos::operation::OverlayOp::UNION");
+group test_overlayopunion_group("geos::operation::OverlayOp::UNION");
 
-    //
-    // Test Cases
-    //
+//
+// Test Cases
+//
 
-    // 1 - Union four connected segments of a square
-    template<>
-    template<>
-    void object::test<1>()
-    {
-        GeometryFactoryPtr factory = geos::geom::GeometryFactory::create();
-        geos::io::WKTReader reader(*factory);
-        GeometryPtr line1(reader.read("LINESTRING(0 0, 0 5)"));
-        GeometryPtr line2(reader.read("LINESTRING(0 5, 5 5)"));
-        GeometryPtr line3(reader.read("LINESTRING(5 5, 5 0)"));
-        GeometryPtr line4(reader.read("LINESTRING(5 0, 0 0)"));
+// 1 - Union four connected segments of a square
+template<>
+template<>
+void object::test<1>
+()
+{
+    GeometryFactoryPtr factory = geos::geom::GeometryFactory::create();
+    geos::io::WKTReader reader(*factory);
+    GeometryPtr line1(reader.read("LINESTRING(0 0, 0 5)"));
+    GeometryPtr line2(reader.read("LINESTRING(0 5, 5 5)"));
+    GeometryPtr line3(reader.read("LINESTRING(5 5, 5 0)"));
+    GeometryPtr line4(reader.read("LINESTRING(5 0, 0 0)"));
 
-        // union segments incrementally
-        GeometryPtr lines12(line1->Union(line2.get()));
-        GeometryPtr lines123(lines12->Union(line3.get()));
-        GeometryPtr lines1234(lines123->Union(line4.get()));
+    // union segments incrementally
+    GeometryPtr lines12(line1->Union(line2.get()));
+    GeometryPtr lines123(lines12->Union(line3.get()));
+    GeometryPtr lines1234(lines123->Union(line4.get()));
 
-        ensure_equals(lines1234->getGeometryTypeId(), geos::geom::GEOS_MULTILINESTRING);
+    ensure_equals(lines1234->getGeometryTypeId(), geos::geom::GEOS_MULTILINESTRING);
 
-        // NOTE: Since the union operation makes no effort to simplify and
-        // drop nodes of degree 2 from the built topology,
-        // do not expect GEOS_LINESTRING.
-        // See LineMergerTest where the test triangle is generated as a single LineString.
-    }
+    // NOTE: Since the union operation makes no effort to simplify and
+    // drop nodes of degree 2 from the built topology,
+    // do not expect GEOS_LINESTRING.
+    // See LineMergerTest where the test triangle is generated as a single LineString.
+}
 
 } // namespace tut
diff --git a/tests/unit/operation/overlay/snap/GeometrySnapperTest.cpp b/tests/unit/operation/overlay/snap/GeometrySnapperTest.cpp
index 5e39148..a898a60 100644
--- a/tests/unit/operation/overlay/snap/GeometrySnapperTest.cpp
+++ b/tests/unit/operation/overlay/snap/GeometrySnapperTest.cpp
@@ -13,85 +13,85 @@
 #include <string>
 #include <vector>
 
-namespace tut
-{
-    //
-    // Test Group
-    //
+namespace tut {
+//
+// Test Group
+//
 
-    // Common data used by tests
-    struct test_geometrysnapper_data
-    {
-        typedef std::unique_ptr<geos::geom::Geometry> GeomPtr;
+// Common data used by tests
+struct test_geometrysnapper_data {
+    typedef std::unique_ptr<geos::geom::Geometry> GeomPtr;
 
-        geos::io::WKTReader reader;
+    geos::io::WKTReader reader;
 
-        typedef geos::operation::overlay::snap::GeometrySnapper GeometrySnapper;
+    typedef geos::operation::overlay::snap::GeometrySnapper GeometrySnapper;
 
-        test_geometrysnapper_data()
-                :
-                reader()
-        {
-        }
-    };
+    test_geometrysnapper_data()
+        :
+        reader()
+    {
+    }
+};
 
-    typedef test_group<test_geometrysnapper_data> group;
-    typedef group::object object;
+typedef test_group<test_geometrysnapper_data> group;
+typedef group::object object;
 
-    group test_geometrysnapper_group("geos::operation::overlay::snap::GeometrySnapper");
+group test_geometrysnapper_group("geos::operation::overlay::snap::GeometrySnapper");
 
-    //
-    // Test Cases
-    //
+//
+// Test Cases
+//
 
-    // Test vertices snapping
-    template<>
-    template<>
-    void object::test<1>()
-    {
-        GeomPtr src(reader.read(
-                "POLYGON ((0 0, 0 100, 100 100, 100 0, 0 0))"
-        ));
+// Test vertices snapping
+template<>
+template<>
+void object::test<1>
+()
+{
+    GeomPtr src(reader.read(
+                    "POLYGON ((0 0, 0 100, 100 100, 100 0, 0 0))"
+                ));
 
-        GeometrySnapper snapper( *(src.get()) );
+    GeometrySnapper snapper(*(src.get()));
 
-        GeomPtr snap(reader.read(
-                "MULTIPOINT ((0 0), (0 100.0000001), (100 100), (100 0))"
-        ));
+    GeomPtr snap(reader.read(
+                     "MULTIPOINT ((0 0), (0 100.0000001), (100 100), (100 0))"
+                 ));
 
-        GeomPtr expected(reader.read(
-                "POLYGON ((0 0, 0 100.0000001, 100 100, 100 0, 0 0))"
-        ));
+    GeomPtr expected(reader.read(
+                         "POLYGON ((0 0, 0 100.0000001, 100 100, 100 0, 0 0))"
+                     ));
 
-        GeomPtr ret(snapper.snapTo( *(snap.get()), 0.000001 ));
+    GeomPtr ret(snapper.snapTo(*(snap.get()), 0.000001));
 
-        ensure( ret->equalsExact(expected.get(),0) );
+    ensure(ret->equalsExact(expected.get(), 0));
 
-    }
+}
 
-    // Test vertices snapping
-    template<>
-    template<>
-    void object::test<2>()
-    {
-        GeomPtr src(reader.read(
-                "POLYGON ((0 0, 0 100, 100 100, 100 0, 0 0))"
-        ));
+// Test vertices snapping
+template<>
+template<>
+void object::test<2>
+()
+{
+    GeomPtr src(reader.read(
+                    "POLYGON ((0 0, 0 100, 100 100, 100 0, 0 0))"
+                ));
 
-        GeometrySnapper snapper( *(src.get()) );
+    GeometrySnapper snapper(*(src.get()));
 
-        GeomPtr snap(reader.read(
-                "MULTIPOINT ((0.0000001 50))"
-        ));
+    GeomPtr snap(reader.read(
+                     "MULTIPOINT ((0.0000001 50))"
+                 ));
 
-        GeomPtr expected(reader.read(
-                "POLYGON ((0 0, 0.0000001 50, 0 100, 100 100, 100 0, 0 0))"
-        ));
+    GeomPtr expected(reader.read(
+                         "POLYGON ((0 0, 0.0000001 50, 0 100, 100 100, 100 0, 0 0))"
+                     ));
 
-        GeomPtr ret(snapper.snapTo( *(snap.get()), 0.000001 ));
+    GeomPtr ret(snapper.snapTo(*(snap.get()), 0.000001));
 
-        ensure( ret->equalsExact(expected.get(),0) );
-    }
+    ensure(ret->equalsExact(expected.get(), 0));
+}
 
 
 
diff --git a/tests/unit/operation/overlay/snap/LineStringSnapperTest.cpp b/tests/unit/operation/overlay/snap/LineStringSnapperTest.cpp
index 72f66f1..8d1d370 100644
--- a/tests/unit/operation/overlay/snap/LineStringSnapperTest.cpp
+++ b/tests/unit/operation/overlay/snap/LineStringSnapperTest.cpp
@@ -12,243 +12,248 @@
 #include <string>
 #include <vector>
 
-namespace tut
-{
-    //
-    // Test Group
-    //
+namespace tut {
+//
+// Test Group
+//
 
-    // Common data used by tests
-    struct test_linestringsnapper_data
-    {
+// Common data used by tests
+struct test_linestringsnapper_data {
 
-        test_linestringsnapper_data() {}
-    };
+    test_linestringsnapper_data() {}
+};
 
-    typedef test_group<test_linestringsnapper_data> group;
-    typedef group::object object;
+typedef test_group<test_linestringsnapper_data> group;
+typedef group::object object;
 
-    group test_linestringsnapper_group("geos::operation::overlay::snap::LineStringSnapper");
+group test_linestringsnapper_group("geos::operation::overlay::snap::LineStringSnapper");
 
-    //
-    // Test Cases
-    //
+//
+// Test Cases
+//
 
-    // Test vertices snapping
-    template<>
-    template<>
-    void object::test<1>()
-    {
-		using geos::geom::Coordinate;
-		using geos::operation::overlay::snap::LineStringSnapper;
+// Test vertices snapping
+template<>
+template<>
+void object::test<1>
+()
+{
+    using geos::geom::Coordinate;
+    using geos::operation::overlay::snap::LineStringSnapper;
 
-		typedef std::unique_ptr<Coordinate::Vect> CoordsVectAptr;
+    typedef std::unique_ptr<Coordinate::Vect> CoordsVectAptr;
 
 
-		// source coordinates
-		Coordinate src_a(0, 0);
-		Coordinate src_b(10, 10);
+    // source coordinates
+    Coordinate src_a(0, 0);
+    Coordinate src_b(10, 10);
 
-		// snap coordinates
-		Coordinate snp_a(0.1, 0);
-		Coordinate snp_b(10, 10.1);
+    // snap coordinates
+    Coordinate snp_a(0.1, 0);
+    Coordinate snp_b(10, 10.1);
 
-		Coordinate::Vect srcCoords;
-		srcCoords.push_back( src_a );
-		srcCoords.push_back( src_b );
+    Coordinate::Vect srcCoords;
+    srcCoords.push_back(src_a);
+    srcCoords.push_back(src_b);
 
-		Coordinate::ConstVect snpCoords;
-		snpCoords.push_back( &snp_a );
-		snpCoords.push_back( &snp_b );
+    Coordinate::ConstVect snpCoords;
+    snpCoords.push_back(&snp_a);
+    snpCoords.push_back(&snp_b);
 
-		LineStringSnapper snapper(srcCoords, 0.4);
+    LineStringSnapper snapper(srcCoords, 0.4);
 
-		CoordsVectAptr ret(snapper.snapTo(snpCoords));
+    CoordsVectAptr ret(snapper.snapTo(snpCoords));
 
-		// both points should have been snapped
-		ensure_equals(ret->size(), 2u);
-		ensure_equals(ret->operator[](0), snp_a);
-		ensure_equals(ret->operator[](1), snp_b);
+    // both points should have been snapped
+    ensure_equals(ret->size(), 2u);
+    ensure_equals(ret->operator[](0), snp_a);
+    ensure_equals(ret->operator[](1), snp_b);
 
-	}
+}
 
-    // Test segment snapping
-    template<>
-    template<>
-    void object::test<2>()
-    {
-		using geos::geom::Coordinate;
-		using geos::operation::overlay::snap::LineStringSnapper;
+// Test segment snapping
+template<>
+template<>
+void object::test<2>
+()
+{
+    using geos::geom::Coordinate;
+    using geos::operation::overlay::snap::LineStringSnapper;
 
-		typedef std::unique_ptr<Coordinate::Vect> CoordsVectAptr;
+    typedef std::unique_ptr<Coordinate::Vect> CoordsVectAptr;
 
 
-		// source coordinates
-		Coordinate src_a(0, 0);
-		Coordinate src_b(10, 10);
+    // source coordinates
+    Coordinate src_a(0, 0);
+    Coordinate src_b(10, 10);
 
-		// snap coordinates
-		Coordinate snp_a(0.4, 0);
-		Coordinate snp_b(10, 10.4);
+    // snap coordinates
+    Coordinate snp_a(0.4, 0);
+    Coordinate snp_b(10, 10.4);
 
-		Coordinate::Vect srcCoords;
-		srcCoords.push_back( src_a );
-		srcCoords.push_back( src_b );
+    Coordinate::Vect srcCoords;
+    srcCoords.push_back(src_a);
+    srcCoords.push_back(src_b);
 
-		Coordinate::ConstVect snpCoords;
-		snpCoords.push_back( &snp_a );
-		snpCoords.push_back( &snp_b );
+    Coordinate::ConstVect snpCoords;
+    snpCoords.push_back(&snp_a);
+    snpCoords.push_back(&snp_b);
 
-		LineStringSnapper snapper(srcCoords, 0.3);
+    LineStringSnapper snapper(srcCoords, 0.3);
 
-		CoordsVectAptr ret(snapper.snapTo(snpCoords));
+    CoordsVectAptr ret(snapper.snapTo(snpCoords));
 
-		// snap point a should be inserted
-		ensure_equals(ret->size(), 3u);
-		ensure_equals(ret->operator[](0), src_a);
-		ensure_equals(ret->operator[](1), snp_a);
-		ensure_equals(ret->operator[](2), src_b);
+    // snap point a should be inserted
+    ensure_equals(ret->size(), 3u);
+    ensure_equals(ret->operator[](0), src_a);
+    ensure_equals(ret->operator[](1), snp_a);
+    ensure_equals(ret->operator[](2), src_b);
 
-	}
+}
 
-  // Test vertices snapping in a closed ring
-  template<>
-  template<>
-  void object::test<3>()
-  {
-		using geos::geom::Coordinate;
-		using geos::operation::overlay::snap::LineStringSnapper;
+// Test vertices snapping in a closed ring
+template<>
+template<>
+void object::test<3>
+()
+{
+    using geos::geom::Coordinate;
+    using geos::operation::overlay::snap::LineStringSnapper;
 
-		typedef std::unique_ptr<Coordinate::Vect> CoordsVectAptr;
+    typedef std::unique_ptr<Coordinate::Vect> CoordsVectAptr;
 
 
-		// source coordinates
+    // source coordinates
 
-		Coordinate src_a(0, 0);
-		Coordinate src_b(10, 10);
-		Coordinate src_c(0, 10);
+    Coordinate src_a(0, 0);
+    Coordinate src_b(10, 10);
+    Coordinate src_c(0, 10);
 
-		Coordinate::Vect srcCoords;
-		srcCoords.push_back( src_a );
-		srcCoords.push_back( src_b );
-		srcCoords.push_back( src_c );
-		srcCoords.push_back( src_a );
+    Coordinate::Vect srcCoords;
+    srcCoords.push_back(src_a);
+    srcCoords.push_back(src_b);
+    srcCoords.push_back(src_c);
+    srcCoords.push_back(src_a);
 
-		// snap coordinates
+    // snap coordinates
 
-		Coordinate snp_a(0.1, 0);
-		Coordinate snp_b(10, 10.1);
+    Coordinate snp_a(0.1, 0);
+    Coordinate snp_b(10, 10.1);
 
-		Coordinate::ConstVect snpCoords;
-		snpCoords.push_back( &snp_a );
-		snpCoords.push_back( &snp_b );
+    Coordinate::ConstVect snpCoords;
+    snpCoords.push_back(&snp_a);
+    snpCoords.push_back(&snp_b);
 
-		LineStringSnapper snapper(srcCoords, 0.4);
+    LineStringSnapper snapper(srcCoords, 0.4);
 
-		CoordsVectAptr ret(snapper.snapTo(snpCoords));
+    CoordsVectAptr ret(snapper.snapTo(snpCoords));
 
-		// Points A and B should be snapped
-		ensure_equals(ret->size(), 4u);
-		ensure_equals(ret->operator[](0), snp_a);
-		ensure_equals(ret->operator[](1), snp_b);
-		ensure_equals(ret->operator[](2), src_c);
-		ensure_equals(ret->operator[](3), snp_a);
+    // Points A and B should be snapped
+    ensure_equals(ret->size(), 4u);
+    ensure_equals(ret->operator[](0), snp_a);
+    ensure_equals(ret->operator[](1), snp_b);
+    ensure_equals(ret->operator[](2), src_c);
+    ensure_equals(ret->operator[](3), snp_a);
 
-	}
+}
 
-  // Test vertices snapping in a short sequence
-  template<>
-  template<>
-  void object::test<4>()
-  {
-		using geos::geom::Coordinate;
-		using geos::operation::overlay::snap::LineStringSnapper;
+// Test vertices snapping in a short sequence
+template<>
+template<>
+void object::test<4>
+()
+{
+    using geos::geom::Coordinate;
+    using geos::operation::overlay::snap::LineStringSnapper;
 
-		typedef std::unique_ptr<Coordinate::Vect> CoordsVectAptr;
+    typedef std::unique_ptr<Coordinate::Vect> CoordsVectAptr;
 
 
-		// source coordinates
+    // source coordinates
 
-		Coordinate src_a(0, 0);
-		Coordinate::Vect srcCoords;
-		srcCoords.push_back( src_a );
+    Coordinate src_a(0, 0);
+    Coordinate::Vect srcCoords;
+    srcCoords.push_back(src_a);
 
-		// snap coordinates
+    // snap coordinates
 
-		Coordinate snp_a(0.1, 0);
-		Coordinate::ConstVect snpCoords;
-		snpCoords.push_back( &snp_a );
+    Coordinate snp_a(0.1, 0);
+    Coordinate::ConstVect snpCoords;
+    snpCoords.push_back(&snp_a);
 
-		LineStringSnapper snapper(srcCoords, 0.4);
+    LineStringSnapper snapper(srcCoords, 0.4);
 
-		CoordsVectAptr ret(snapper.snapTo(snpCoords));
+    CoordsVectAptr ret(snapper.snapTo(snpCoords));
 
-		ensure_equals(ret->size(), 1u);
-		ensure_equals(ret->operator[](0), snp_a);
+    ensure_equals(ret->size(), 1u);
+    ensure_equals(ret->operator[](0), snp_a);
 
-	}
+}
 
-  // Test vertices snapping in an empty sequence
-  template<>
-  template<>
-  void object::test<5>()
-  {
-		using geos::geom::Coordinate;
-		using geos::operation::overlay::snap::LineStringSnapper;
+// Test vertices snapping in an empty sequence
+template<>
+template<>
+void object::test<5>
+()
+{
+    using geos::geom::Coordinate;
+    using geos::operation::overlay::snap::LineStringSnapper;
 
-		typedef std::unique_ptr<Coordinate::Vect> CoordsVectAptr;
+    typedef std::unique_ptr<Coordinate::Vect> CoordsVectAptr;
 
 
-		// source coordinates
+    // source coordinates
 
-		Coordinate::Vect srcCoords;
+    Coordinate::Vect srcCoords;
 
-		// snap coordinates
+    // snap coordinates
 
-		Coordinate::ConstVect snpCoords;
+    Coordinate::ConstVect snpCoords;
 
-		LineStringSnapper snapper(srcCoords, 0.4);
+    LineStringSnapper snapper(srcCoords, 0.4);
 
-		CoordsVectAptr ret(snapper.snapTo(snpCoords));
+    CoordsVectAptr ret(snapper.snapTo(snpCoords));
 
-		ensure_equals(ret->size(), 0u);
+    ensure_equals(ret->size(), 0u);
 
-	}
+}
 
-  // Test snapping an empty sequence
-  template<>
-  template<>
-  void object::test<6>()
-  {
-		using geos::geom::Coordinate;
-		using geos::operation::overlay::snap::LineStringSnapper;
+// Test snapping an empty sequence
+template<>
+template<>
+void object::test<6>
+()
+{
+    using geos::geom::Coordinate;
+    using geos::operation::overlay::snap::LineStringSnapper;
 
-		typedef std::unique_ptr<Coordinate::Vect> CoordsVectAptr;
+    typedef std::unique_ptr<Coordinate::Vect> CoordsVectAptr;
 
 
-		// source coordinates
+    // source coordinates
 
-		Coordinate::Vect srcCoords;
+    Coordinate::Vect srcCoords;
 
-		// snap coordinates
+    // snap coordinates
 
-		Coordinate snp_a(0.1, 0);
-		Coordinate::ConstVect snpCoords;
-		snpCoords.push_back( &snp_a );
+    Coordinate snp_a(0.1, 0);
+    Coordinate::ConstVect snpCoords;
+    snpCoords.push_back(&snp_a);
 
-		LineStringSnapper snapper(srcCoords, 0.4);
+    LineStringSnapper snapper(srcCoords, 0.4);
 
-		CoordsVectAptr ret(snapper.snapTo(snpCoords));
+    CoordsVectAptr ret(snapper.snapTo(snpCoords));
 
-		ensure_equals(ret->size(), 0u);
+    ensure_equals(ret->size(), 0u);
 
-	}
+}
 
-  // Test allow snapping to source vertices
-  template<>
-  template<>
-  void object::test<7>()
-  {
+// Test allow snapping to source vertices
+template<>
+template<>
+void object::test<7>
+()
+{
     using geos::geom::Coordinate;
     using geos::operation::overlay::snap::LineStringSnapper;
 
@@ -267,7 +272,7 @@ namespace tut
     // Snap: (0 0)
     Coordinate snp_a(0, 0);
     Coordinate::ConstVect snpCoords;
-    snpCoords.push_back( &snp_a );
+    snpCoords.push_back(&snp_a);
 
     // Snap with tolerance of 1
     // (both first and second point could be snapped)
@@ -290,13 +295,14 @@ namespace tut
     ensure_equals(ret->operator[](0), src_a);
     ensure_equals(ret->operator[](1), src_b);
     ensure_equals(ret->operator[](2), src_c);
-  }
+}
 
-  // Test two candidate vertices snaps
-  template<>
-  template<>
-  void object::test<8>()
-  {
+// Test two candidate vertices snaps
+template<>
+template<>
+void object::test<8>
+()
+{
     using geos::geom::Coordinate;
     using geos::operation::overlay::snap::LineStringSnapper;
 
@@ -315,7 +321,7 @@ namespace tut
     // Snap: (0.5, 0)
     Coordinate snp_a(0.5, 0);
     Coordinate::ConstVect snpCoords;
-    snpCoords.push_back( &snp_a );
+    snpCoords.push_back(&snp_a);
 
     // Snap with tolerance of 1
     // (both first and second point could be snapped)
@@ -327,14 +333,15 @@ namespace tut
     ensure_equals(ret->operator[](0), snp_a);
     ensure_equals(ret->operator[](1), src_b);
     ensure_equals(ret->operator[](2), src_c);
-  }
-
-  // Snap of last segment in closed linestring
-  // See https://trac.osgeo.org/geos/ticket/758
-  template<>
-  template<>
-  void object::test<9>()
-  {
+}
+
+// Snap of last segment in closed linestring
+// See https://trac.osgeo.org/geos/ticket/758
+template<>
+template<>
+void object::test<9>
+()
+{
     using geos::geom::Coordinate;
     using geos::operation::overlay::snap::LineStringSnapper;
 
@@ -356,9 +363,9 @@ namespace tut
     Coordinate snp_b(10, 0);
     Coordinate snp_c(1, 0.5);
     Coordinate::ConstVect snpCoords;
-    snpCoords.push_back( &snp_a );
-    snpCoords.push_back( &snp_b );
-    snpCoords.push_back( &snp_c );
+    snpCoords.push_back(&snp_a);
+    snpCoords.push_back(&snp_b);
+    snpCoords.push_back(&snp_c);
 
     // Snap with tolerance of 2
     // (both first and second point could be snapped)
@@ -372,6 +379,6 @@ namespace tut
     ensure_equals(ret->operator[](2), snp_b); // 10 0
     ensure_equals(ret->operator[](3), snp_c); //  1 0.5
     ensure_equals(ret->operator[](4), snp_a); //  0 0
-  }
+}
 
 } // namespace tut
diff --git a/tests/unit/operation/overlay/validate/FuzzyPointLocatorTest.cpp b/tests/unit/operation/overlay/validate/FuzzyPointLocatorTest.cpp
index bce5b83..e000220 100644
--- a/tests/unit/operation/overlay/validate/FuzzyPointLocatorTest.cpp
+++ b/tests/unit/operation/overlay/validate/FuzzyPointLocatorTest.cpp
@@ -16,181 +16,189 @@
 #include <memory>
 #include <sstream>
 
-namespace tut
+namespace tut {
+//
+// Test Group
+//
+
+// Common data used by tests
+struct test_fuzzypointlocator_data {
+    geos::io::WKTReader wktreader;
+    geos::io::WKBReader wkbreader;
+
+    typedef geos::geom::Geometry::Ptr GeomPtr;
+
+    GeomPtr g;
+
+    test_fuzzypointlocator_data()
+        :
+        wktreader(),
+        wkbreader()
+    {
+        std::string wkt("POLYGON((0 0, 10 0, 10 10, 0 10, 0 0))");
+        g.reset(wktreader.read(wkt));
+    }
+};
+
+
+typedef test_group<test_fuzzypointlocator_data> group;
+typedef group::object object;
+
+group test_fuzzypointlocator_group("geos::operation::overlay::validate::FuzzyPointLocator");
+
+//
+// Test Cases
+//
+
+template<>
+template<>
+void object::test<1>
+()
 {
-	//
-	// Test Group
-	//
-
-	// Common data used by tests
-	struct test_fuzzypointlocator_data
-	{
-		geos::io::WKTReader wktreader;
-		geos::io::WKBReader wkbreader;
-
-		typedef geos::geom::Geometry::Ptr GeomPtr;
-
-		GeomPtr g;
-
-		test_fuzzypointlocator_data()
-			:
-			wktreader(),
-			wkbreader()
-		{
-			std::string wkt("POLYGON((0 0, 10 0, 10 10, 0 10, 0 0))");
-			g.reset(wktreader.read(wkt));
-		}
-	};
-
-
-	typedef test_group<test_fuzzypointlocator_data> group;
-	typedef group::object object;
-
-	group test_fuzzypointlocator_group("geos::operation::overlay::validate::FuzzyPointLocator");
-
-	//
-	// Test Cases
-	//
-
-	template<>
-	template<>
-	void object::test<1>()
-	{
-		using geos::operation::overlay::validate::FuzzyPointLocator;
-		using geos::geom::Location;
-		using geos::geom::Coordinate;
-
-		FuzzyPointLocator locator(*g, 10);
-
-		ensure_equals(locator.getLocation(Coordinate(10, 0)),
-			Location::BOUNDARY);
-
-		// 8 units away from boundary
-		ensure_equals(locator.getLocation(Coordinate(18, 5)),
-			Location::BOUNDARY);
-	}
-
-	template<>
-	template<>
-	void object::test<2>()
-	{
-		using geos::operation::overlay::validate::FuzzyPointLocator;
-		using geos::geom::Location;
-		using geos::geom::Coordinate;
-
-		FuzzyPointLocator locator(*g, 10);
-
-		//
-		// These are corner cases. I think they should
-		// return Location::BOUNDARY, but need to discuss
-		// this with Martin Davis
-		//
-
-		// 10 units away from boundary
-		ensure_equals(locator.getLocation(Coordinate(20, 2)),
-			Location::EXTERIOR);
-
-		// 10 units away from boundary
-		ensure_equals(locator.getLocation(Coordinate(-10, 5)),
-			Location::EXTERIOR);
-	}
-
-	template<>
-	template<>
-	void object::test<3>()
-	{
-		using geos::operation::overlay::validate::FuzzyPointLocator;
-		using geos::geom::Location;
-		using geos::geom::Coordinate;
-
-		FuzzyPointLocator locator(*g, 8);
-
-		// 5 units away from boundary
-		ensure_equals(locator.getLocation(Coordinate(5, 5)),
-			Location::BOUNDARY);
-
-		// 2 units away from boundary
-		ensure_equals(locator.getLocation(Coordinate(2, 8)),
-			Location::BOUNDARY);
-	}
-
-	template<>
-	template<>
-	void object::test<4>()
-	{
-		using geos::operation::overlay::validate::FuzzyPointLocator;
-		using geos::geom::Location;
-		using geos::geom::Coordinate;
-
-		FuzzyPointLocator locator(*g, 2);
-
-		// 5 units away from boundary
-		ensure_equals(locator.getLocation(Coordinate(5, 5)),
-			Location::INTERIOR);
-
-		// 3 units away from boundary
-		ensure_equals(locator.getLocation(Coordinate(3, 7)),
-			Location::INTERIOR);
-	}
-
-
-	template<>
-	template<>
-	void object::test<5>()
-	{
-		using geos::operation::overlay::validate::FuzzyPointLocator;
-		using geos::geom::Location;
-		geos::geom::Coordinate pt(160.000000125, 119.500004998);
+    using geos::operation::overlay::validate::FuzzyPointLocator;
+    using geos::geom::Location;
+    using geos::geom::Coordinate;
+
+    FuzzyPointLocator locator(*g, 10);
+
+    ensure_equals(locator.getLocation(Coordinate(10, 0)),
+                  Location::BOUNDARY);
+
+    // 8 units away from boundary
+    ensure_equals(locator.getLocation(Coordinate(18, 5)),
+                  Location::BOUNDARY);
+}
+
+template<>
+template<>
+void object::test<2>
+()
+{
+    using geos::operation::overlay::validate::FuzzyPointLocator;
+    using geos::geom::Location;
+    using geos::geom::Coordinate;
+
+    FuzzyPointLocator locator(*g, 10);
+
+    //
+    // These are corner cases. I think they should
+    // return Location::BOUNDARY, but need to discuss
+    // this with Martin Davis
+    //
+
+    // 10 units away from boundary
+    ensure_equals(locator.getLocation(Coordinate(20, 2)),
+                  Location::EXTERIOR);
+
+    // 10 units away from boundary
+    ensure_equals(locator.getLocation(Coordinate(-10, 5)),
+                  Location::EXTERIOR);
+}
+
+template<>
+template<>
+void object::test<3>
+()
+{
+    using geos::operation::overlay::validate::FuzzyPointLocator;
+    using geos::geom::Location;
+    using geos::geom::Coordinate;
+
+    FuzzyPointLocator locator(*g, 8);
+
+    // 5 units away from boundary
+    ensure_equals(locator.getLocation(Coordinate(5, 5)),
+                  Location::BOUNDARY);
+
+    // 2 units away from boundary
+    ensure_equals(locator.getLocation(Coordinate(2, 8)),
+                  Location::BOUNDARY);
+}
+
+template<>
+template<>
+void object::test<4>
+()
+{
+    using geos::operation::overlay::validate::FuzzyPointLocator;
+    using geos::geom::Location;
+    using geos::geom::Coordinate;
+
+    FuzzyPointLocator locator(*g, 2);
+
+    // 5 units away from boundary
+    ensure_equals(locator.getLocation(Coordinate(5, 5)),
+                  Location::INTERIOR);
+
+    // 3 units away from boundary
+    ensure_equals(locator.getLocation(Coordinate(3, 7)),
+                  Location::INTERIOR);
+}
+
+
+template<>
+template<>
+void object::test<5>
+()
+{
+    using geos::operation::overlay::validate::FuzzyPointLocator;
+    using geos::geom::Location;
+    geos::geom::Coordinate pt(160.000000125, 119.500004998);
+
+    std::string
+    wkt0("POLYGON((20 40,20 200,180 200,180 120,140 120,180 119,180 40,20 40),(140 160,80 120,140 80,140 160))");
+    GeomPtr g0(wktreader.read(wkt0));
+
+    FuzzyPointLocator locator(*g0, 0.00001);
+
+    // On the boundary ?
+    ensure_equals(locator.getLocation(pt), Location::BOUNDARY);
+
+}
+
+template<>
+template<>
+void object::test<6>
+()
+{
+    using geos::operation::overlay::validate::FuzzyPointLocator;
+    using geos::geom::Location;
+    // this would return the expected result
+    //geos::geom::Coordinate pt(160, 120);
+    geos::geom::Coordinate pt(160, 120.000005);
+
+    std::stringstream
+    wkb0("0103000000020000000800000000000000000034400000000000004440000000000000344000000000000069400000000000806640000000000000694000000000008066400000000000005E4000000000008061400000000000005E4000000000008066400000000000C05D400000000000806640000000000000444000000000000034400000000000004440040000000000000000806140000000000000644000000000000054400000000000005E400000000000806140000000000000544000000000008061400000000000006440");
+    GeomPtr g0(wkbreader.readHEX(wkb0));
+
+    FuzzyPointLocator locator(*g0, 0.000001);
+
+    // On the boundary ?
+    ensure_equals(locator.getLocation(pt), Location::INTERIOR);
+
+}
+
+template<>
+template<>
+void object::test<7>
+()
+{
+    using geos::operation::overlay::validate::FuzzyPointLocator;
+    using geos::geom::Location;
+    // this would return the expected result
+    //geos::geom::Coordinate pt(160, 120);
+    geos::geom::Coordinate pt(160, 120.000005);
+
+    std::stringstream
+    wkb0("0106000000020000000103000000020000000A000000000000000000344000000000000044400000000000003440000000000000694000000000008066400000000000006940000000000080664000000000000064400000000000C0624000000000000064400000000000C062400000000000005E400000000000C0624000000000000054400000000000806640000000000000544000000000008066400000000000004440000000000000344000000000000044400500000000000000000054400000000000005E400000000000806140000000000000544000000000008061400000000000005E400000000000806140000000000000644000000000000054400000000000005E40010300000001000000080000000000000000C062400000000000005E4000000000008066400000000000005E400000000000806640000000000000644000000000000069400000000000006440000000000000694000000000000054400000000000806640000000000000544000000000008066400000000000C05D400000000000C062400000000000005E40");
+    GeomPtr g0(wkbreader.readHEX(wkb0));
 
-		std::string wkt0("POLYGON((20 40,20 200,180 200,180 120,140 120,180 119,180 40,20 40),(140 160,80 120,140 80,140 160))");
-		GeomPtr g0(wktreader.read(wkt0));
-
-		FuzzyPointLocator locator(*g0, 0.00001);
-
-		// On the boundary ?
-		ensure_equals(locator.getLocation(pt), Location::BOUNDARY);
-
-	}
-
-	template<>
-	template<>
-	void object::test<6>()
-	{
-		using geos::operation::overlay::validate::FuzzyPointLocator;
-		using geos::geom::Location;
-		// this would return the expected result
-		//geos::geom::Coordinate pt(160, 120);
-		geos::geom::Coordinate pt(160, 120.000005);
-
-		std::stringstream wkb0("0103000000020000000800000000000000000034400000000000004440000000000000344000000000000069400000000000806640000000000000694000000000008066400000000000005E4000000000008061400000000000005E4000000000008066400000000000C05D400000000000806640000000000000444000000000000034400000000000004440040000000000000000806140000000000000644000000000000054400000000000005E400000000000806140000000000000544000000000008061400000000000006440");
-		GeomPtr g0(wkbreader.readHEX(wkb0));
-
-		FuzzyPointLocator locator(*g0, 0.000001);
-
-		// On the boundary ?
-		ensure_equals(locator.getLocation(pt), Location::INTERIOR);
-
-	}
-
-	template<>
-	template<>
-	void object::test<7>()
-	{
-		using geos::operation::overlay::validate::FuzzyPointLocator;
-		using geos::geom::Location;
-		// this would return the expected result
-		//geos::geom::Coordinate pt(160, 120);
-		geos::geom::Coordinate pt(160, 120.000005);
-
-		std::stringstream wkb0("0106000000020000000103000000020000000A000000000000000000344000000000000044400000000000003440000000000000694000000000008066400000000000006940000000000080664000000000000064400000000000C0624000000000000064400000000000C062400000000000005E400000000000C0624000000000000054400000000000806640000000000000544000000000008066400000000000004440000000000000344000000000000044400500000000000000000054400000000000005E400000000000806140000000000000544000000000008061400000000000005E400000000000806140000000000000644000000000000054400000000000005E40010300000001000000080000000000000000C062400000000000005E4000000000008066400000000000005E400000000000806640000000000000644000000000000069400000000000006440000000000000694000000000000054400000000000806640000000000000544000000000008066400000000000C05D400000000000C062400000000000005E40");
-		GeomPtr g0(wkbreader.readHEX(wkb0));
+    FuzzyPointLocator locator(*g0, 0.000001);
 
-		FuzzyPointLocator locator(*g0, 0.000001);
-
-		// On the boundary ?
-		ensure_equals(locator.getLocation(pt), Location::EXTERIOR);
+    // On the boundary ?
+    ensure_equals(locator.getLocation(pt), Location::EXTERIOR);
 
-	}
+}
 
 } // namespace tut
 
diff --git a/tests/unit/operation/overlay/validate/OffsetPointGeneratorTest.cpp b/tests/unit/operation/overlay/validate/OffsetPointGeneratorTest.cpp
index cb61fc6..11f3ff8 100644
--- a/tests/unit/operation/overlay/validate/OffsetPointGeneratorTest.cpp
+++ b/tests/unit/operation/overlay/validate/OffsetPointGeneratorTest.cpp
@@ -15,187 +15,188 @@
 #include <memory>
 #include <vector>
 
-namespace tut
-{
-	using namespace std;
-	using namespace geos::geom;
+namespace tut {
+using namespace std;
+using namespace geos::geom;
 
-	//
-	// Test Group
-	//
+//
+// Test Group
+//
 
-	// Common data used by tests
-	struct test_offsetpointgenerator_data
-	{
-		const geos::geom::GeometryFactory& gf;
-		geos::io::WKTReader wktreader;
-		geos::algorithm::PointLocator locator;
-
-		typedef geos::geom::Geometry::Ptr GeomPtr;
-
-		GeomPtr g;
-
-		test_offsetpointgenerator_data()
-			:
-			gf(*GeometryFactory::getDefaultInstance()),
-			wktreader(&gf)
-		{
-		}
+// Common data used by tests
+struct test_offsetpointgenerator_data {
+    const geos::geom::GeometryFactory& gf;
+    geos::io::WKTReader wktreader;
+    geos::algorithm::PointLocator locator;
 
-		bool
-		pointsWithinDistance(vector<Coordinate>& coords, double dist)
-		{
-			// we expect some numerical instability here
-			// OffsetPointGenerator could produce points
-			// at *slightly* farther locations then
-			// requested
-			//
-			dist *= 1.0000001;
+    typedef geos::geom::Geometry::Ptr GeomPtr;
 
-			for (size_t i=0, n=coords.size(); i<n; ++i)
-			{
-				const Coordinate& c = coords[i];
-				unique_ptr<Geometry> pg(gf.createPoint(c));
-				double rdist =  g->distance(pg.get());
-				if ( rdist > dist )
-				{
-					return false;
-				}
-			}
-			return true;
-		}
+    GeomPtr g;
 
-	};
+    test_offsetpointgenerator_data()
+        :
+        gf(*GeometryFactory::getDefaultInstance()),
+        wktreader(&gf)
+    {
+    }
 
+    bool
+    pointsWithinDistance(vector<Coordinate>& coords, double dist)
+    {
+        // we expect some numerical instability here
+        // OffsetPointGenerator could produce points
+        // at *slightly* farther locations then
+        // requested
+        //
+        dist *= 1.0000001;
 
-	typedef test_group<test_offsetpointgenerator_data> group;
-	typedef group::object object;
+        for(size_t i = 0, n = coords.size(); i < n; ++i) {
+            const Coordinate& c = coords[i];
+            unique_ptr<Geometry> pg(gf.createPoint(c));
+            double rdist =  g->distance(pg.get());
+            if(rdist > dist) {
+                return false;
+            }
+        }
+        return true;
+    }
 
-	group test_offsetpointgenerator_group("geos::operation::overlay::validate::OffsetPointGenerator");
+};
 
-	//
-	// Test Cases
-	//
 
-	template<>
-	template<>
-	void object::test<1>()
-	{
-		using geos::operation::overlay::validate::OffsetPointGenerator;
-		using geos::geom::Coordinate;
-		using geos::algorithm::PointLocator;
-		using std::unique_ptr;
-		using std::vector;
+typedef test_group<test_offsetpointgenerator_data> group;
+typedef group::object object;
 
-		std::string wkt("POLYGON((0 0, 10 0, 10 10, 0 10, 0 0))");
-		g.reset(wktreader.read(wkt));
+group test_offsetpointgenerator_group("geos::operation::overlay::validate::OffsetPointGenerator");
 
-		double dist = 10;
-		OffsetPointGenerator gen(*g, dist);
+//
+// Test Cases
+//
 
-		unique_ptr< vector<Coordinate> > coords(gen.getPoints());
+template<>
+template<>
+void object::test<1>
+()
+{
+    using geos::operation::overlay::validate::OffsetPointGenerator;
+    using geos::geom::Coordinate;
+    using geos::algorithm::PointLocator;
+    using std::unique_ptr;
+    using std::vector;
 
-		ensure_equals(coords->size(), (g->getNumPoints()-1)*2);
+    std::string wkt("POLYGON((0 0, 10 0, 10 10, 0 10, 0 0))");
+    g.reset(wktreader.read(wkt));
 
-		ensure(pointsWithinDistance(*coords, dist));
+    double dist = 10;
+    OffsetPointGenerator gen(*g, dist);
 
-	}
+    unique_ptr< vector<Coordinate> > coords(gen.getPoints());
 
-	template<>
-	template<>
-	void object::test<2>()
-	{
-		using geos::operation::overlay::validate::OffsetPointGenerator;
-		using geos::geom::Location;
-		using geos::geom::Coordinate;
-		using std::unique_ptr;
-		using std::vector;
+    ensure_equals(coords->size(), (g->getNumPoints() - 1) * 2);
 
-		std::string wkt("POLYGON((0 0, 10 0, 10 5, 10 10, 0 10, 0 0))");
-		g.reset(wktreader.read(wkt));
+    ensure(pointsWithinDistance(*coords, dist));
 
-		double dist = 0.0003;
+}
 
-		OffsetPointGenerator gen(*g, dist);
+template<>
+template<>
+void object::test<2>
+()
+{
+    using geos::operation::overlay::validate::OffsetPointGenerator;
+    using geos::geom::Location;
+    using geos::geom::Coordinate;
+    using std::unique_ptr;
+    using std::vector;
 
-		unique_ptr< vector<Coordinate> > coords(gen.getPoints());
+    std::string wkt("POLYGON((0 0, 10 0, 10 5, 10 10, 0 10, 0 0))");
+    g.reset(wktreader.read(wkt));
 
-		ensure_equals(coords->size(), 10u);
+    double dist = 0.0003;
 
-		ensure(pointsWithinDistance(*coords, dist));
-	}
+    OffsetPointGenerator gen(*g, dist);
 
-	template<>
-	template<>
-	void object::test<3>()
-	{
-		using geos::operation::overlay::validate::OffsetPointGenerator;
-		using geos::geom::Location;
-		using geos::geom::Coordinate;
-		using std::unique_ptr;
-		using std::vector;
+    unique_ptr< vector<Coordinate> > coords(gen.getPoints());
 
-		std::string wkt("POINT(10 -10)");
-		g.reset(wktreader.read(wkt));
+    ensure_equals(coords->size(), 10u);
 
-		double dist = 0.0003;
+    ensure(pointsWithinDistance(*coords, dist));
+}
 
-		OffsetPointGenerator gen(*g, dist);
+template<>
+template<>
+void object::test<3>
+()
+{
+    using geos::operation::overlay::validate::OffsetPointGenerator;
+    using geos::geom::Location;
+    using geos::geom::Coordinate;
+    using std::unique_ptr;
+    using std::vector;
+
+    std::string wkt("POINT(10 -10)");
+    g.reset(wktreader.read(wkt));
+
+    double dist = 0.0003;
 
-		unique_ptr< vector<Coordinate> > coords(gen.getPoints());
+    OffsetPointGenerator gen(*g, dist);
 
-		ensure_equals(coords->size(), 0u);
+    unique_ptr< vector<Coordinate> > coords(gen.getPoints());
 
-		//ensure(pointsWithinDistance(*coords, dist));
-	}
+    ensure_equals(coords->size(), 0u);
 
-	template<>
-	template<>
-	void object::test<4>()
-	{
-		using geos::operation::overlay::validate::OffsetPointGenerator;
-		using geos::geom::Location;
-		using geos::geom::Coordinate;
-		using std::unique_ptr;
-		using std::vector;
+    //ensure(pointsWithinDistance(*coords, dist));
+}
 
-		std::string wkt("LINESTRING(10 -10, 5 600)");
-		g.reset(wktreader.read(wkt));
+template<>
+template<>
+void object::test<4>
+()
+{
+    using geos::operation::overlay::validate::OffsetPointGenerator;
+    using geos::geom::Location;
+    using geos::geom::Coordinate;
+    using std::unique_ptr;
+    using std::vector;
+
+    std::string wkt("LINESTRING(10 -10, 5 600)");
+    g.reset(wktreader.read(wkt));
 
-		double dist = 0.03;
+    double dist = 0.03;
 
-		OffsetPointGenerator gen(*g, dist);
+    OffsetPointGenerator gen(*g, dist);
 
-		unique_ptr< vector<Coordinate> > coords(gen.getPoints());
+    unique_ptr< vector<Coordinate> > coords(gen.getPoints());
 
-		ensure_equals(coords->size(), 2u);
+    ensure_equals(coords->size(), 2u);
 
-		ensure(pointsWithinDistance(*coords, dist));
-	}
+    ensure(pointsWithinDistance(*coords, dist));
+}
 
-	template<>
-	template<>
-	void object::test<5>()
-	{
-		using geos::operation::overlay::validate::OffsetPointGenerator;
-		using geos::geom::Location;
-		using geos::geom::Coordinate;
-		using std::unique_ptr;
-		using std::vector;
+template<>
+template<>
+void object::test<5>
+()
+{
+    using geos::operation::overlay::validate::OffsetPointGenerator;
+    using geos::geom::Location;
+    using geos::geom::Coordinate;
+    using std::unique_ptr;
+    using std::vector;
 
-		std::string wkt("MULTILINESTRING((10 -10, 5 600), (1045 -12, 0 0, -435 34))");
-		g.reset(wktreader.read(wkt));
+    std::string wkt("MULTILINESTRING((10 -10, 5 600), (1045 -12, 0 0, -435 34))");
+    g.reset(wktreader.read(wkt));
 
-		double dist = 0.2;
+    double dist = 0.2;
 
-		OffsetPointGenerator gen(*g, dist);
+    OffsetPointGenerator gen(*g, dist);
 
-		unique_ptr< vector<Coordinate> > coords(gen.getPoints());
+    unique_ptr< vector<Coordinate> > coords(gen.getPoints());
 
-		ensure_equals(coords->size(), 6u);
+    ensure_equals(coords->size(), 6u);
 
-		ensure(pointsWithinDistance(*coords, dist));
-	}
+    ensure(pointsWithinDistance(*coords, dist));
+}
 
 
 
diff --git a/tests/unit/operation/overlay/validate/OverlayResultValidatorTest.cpp b/tests/unit/operation/overlay/validate/OverlayResultValidatorTest.cpp
index 21bea52..e6b14d1 100644
--- a/tests/unit/operation/overlay/validate/OverlayResultValidatorTest.cpp
+++ b/tests/unit/operation/overlay/validate/OverlayResultValidatorTest.cpp
@@ -15,165 +15,171 @@
 #include <memory>
 #include <vector>
 
-namespace tut
-{
-	using namespace geos::operation::overlay;
-	using namespace geos::operation::overlay::validate;
+namespace tut {
+using namespace geos::operation::overlay;
+using namespace geos::operation::overlay::validate;
 
-	//
-	// Test Group
-	//
+//
+// Test Group
+//
 
-	// Common data used by tests
-	struct test_overlayresultvalidator_data
-	{
-		geos::io::WKTReader wktreader;
-		geos::algorithm::PointLocator locator;
+// Common data used by tests
+struct test_overlayresultvalidator_data {
+    geos::io::WKTReader wktreader;
+    geos::algorithm::PointLocator locator;
 
-		typedef geos::geom::Geometry::Ptr GeomPtr;
+    typedef geos::geom::Geometry::Ptr GeomPtr;
 
-		GeomPtr g0, g1, gres;
+    GeomPtr g0, g1, gres;
 
-		test_overlayresultvalidator_data()
-			:
-			wktreader()
-		{
-		}
+    test_overlayresultvalidator_data()
+        :
+        wktreader()
+    {
+    }
 
-	};
+};
 
 
-	typedef test_group<test_overlayresultvalidator_data> group;
-	typedef group::object object;
+typedef test_group<test_overlayresultvalidator_data> group;
+typedef group::object object;
 
-	group test_overlayresultvalidator_group("geos::operation::overlay::validate::OverlayResultValidator");
+group test_overlayresultvalidator_group("geos::operation::overlay::validate::OverlayResultValidator");
 
-	//
-	// Test Cases
-	//
+//
+// Test Cases
+//
 
-	template<>
-	template<>
-	void object::test<1>()
-	{
+template<>
+template<>
+void object::test<1>
+()
+{
 
-		std::string wkt0("POLYGON((0 0, 10 0, 10 10, 0 10, 0 0))");
-		GeomPtr p_g0(wktreader.read(wkt0));
+    std::string wkt0("POLYGON((0 0, 10 0, 10 10, 0 10, 0 0))");
+    GeomPtr p_g0(wktreader.read(wkt0));
 
-		std::string wkt1("POLYGON((0 0, 10 0, 10 10, 0 10, 0 0))");
-		GeomPtr p_g1(wktreader.read(wkt1));
+    std::string wkt1("POLYGON((0 0, 10 0, 10 10, 0 10, 0 0))");
+    GeomPtr p_g1(wktreader.read(wkt1));
 
-		std::string wktres("POLYGON((0 0, 10 0, 10 10, 0 10, 0 0))");
-		GeomPtr p_gres(wktreader.read(wkt1));
+    std::string wktres("POLYGON((0 0, 10 0, 10 10, 0 10, 0 0))");
+    GeomPtr p_gres(wktreader.read(wkt1));
 
-		OverlayResultValidator validator(*p_g0, *p_g1, *p_gres);
+    OverlayResultValidator validator(*p_g0, *p_g1, *p_gres);
 
-		ensure( validator.isValid(OverlayOp::opUNION) );
-	}
+    ensure(validator.isValid(OverlayOp::opUNION));
+}
 
-	template<>
-	template<>
-	void object::test<2>()
-	{
+template<>
+template<>
+void object::test<2>
+()
+{
 
-		std::string wkt0("POLYGON((0 0, 10 0, 10 10, 0 10, 0 0))");
-		GeomPtr p_g0(wktreader.read(wkt0));
+    std::string wkt0("POLYGON((0 0, 10 0, 10 10, 0 10, 0 0))");
+    GeomPtr p_g0(wktreader.read(wkt0));
 
-		std::string wkt1("POLYGON((0 0, 10 0, 10 10, 0 10, 0 0))");
-		GeomPtr p_g1(wktreader.read(wkt1));
+    std::string wkt1("POLYGON((0 0, 10 0, 10 10, 0 10, 0 0))");
+    GeomPtr p_g1(wktreader.read(wkt1));
 
-		std::string wktres("POLYGON((0 0, 10.001 0, 10 10, 0 10, 0 0))");
-		GeomPtr p_gres(wktreader.read(wktres));
+    std::string wktres("POLYGON((0 0, 10.001 0, 10 10, 0 10, 0 0))");
+    GeomPtr p_gres(wktreader.read(wktres));
 
-		OverlayResultValidator validator(*p_g0, *p_g1, *p_gres);
+    OverlayResultValidator validator(*p_g0, *p_g1, *p_gres);
 
-		ensure (! validator.isValid(OverlayOp::opUNION) );
-	}
+    ensure(! validator.isValid(OverlayOp::opUNION));
+}
 
-	template<>
-	template<>
-	void object::test<3>()
-	{
+template<>
+template<>
+void object::test<3>
+()
+{
 
-		std::string wkt0("POLYGON((0 0, 10 0, 10 10, 0 10, 0 0))");
-		GeomPtr p_g0(wktreader.read(wkt0));
+    std::string wkt0("POLYGON((0 0, 10 0, 10 10, 0 10, 0 0))");
+    GeomPtr p_g0(wktreader.read(wkt0));
 
-		std::string wkt1("POLYGON((0 0, 10 0, 10 10, 0 10, 0 0))");
-		GeomPtr p_g1(wktreader.read(wkt1));
+    std::string wkt1("POLYGON((0 0, 10 0, 10 10, 0 10, 0 0))");
+    GeomPtr p_g1(wktreader.read(wkt1));
 
-		std::string wktres("POLYGON((0 0, 9.999 0, 10 10, 0 10, 0 0))");
-		GeomPtr p_gres(wktreader.read(wktres));
+    std::string wktres("POLYGON((0 0, 9.999 0, 10 10, 0 10, 0 0))");
+    GeomPtr p_gres(wktreader.read(wktres));
 
-		OverlayResultValidator validator(*p_g0, *p_g1, *p_gres);
+    OverlayResultValidator validator(*p_g0, *p_g1, *p_gres);
 
-		ensure (! validator.isValid(OverlayOp::opUNION) );
-	}
+    ensure(! validator.isValid(OverlayOp::opUNION));
+}
 
-	// Result of union has an hole not in input
-	template<>
-	template<>
-	void object::test<4>()
-	{
+// Result of union has an hole not in input
+template<>
+template<>
+void object::test<4>
+()
+{
 
-		std::string wkt0("POLYGON((0 0, 10 0, 10 10, 0 10, 0 0))");
-		GeomPtr p_g0(wktreader.read(wkt0));
+    std::string wkt0("POLYGON((0 0, 10 0, 10 10, 0 10, 0 0))");
+    GeomPtr p_g0(wktreader.read(wkt0));
 
-		std::string wkt1("POLYGON((0 0, 10 0, 10 10, 0 10, 0 0))");
-		GeomPtr p_g1(wktreader.read(wkt1));
+    std::string wkt1("POLYGON((0 0, 10 0, 10 10, 0 10, 0 0))");
+    GeomPtr p_g1(wktreader.read(wkt1));
 
-		std::string wktres("POLYGON((0 0, 10 0, 10 10, 0 10, 0 0),(5 5, 5 6, 6 6, 5 5))");
-		GeomPtr p_gres(wktreader.read(wktres));
+    std::string wktres("POLYGON((0 0, 10 0, 10 10, 0 10, 0 0),(5 5, 5 6, 6 6, 5 5))");
+    GeomPtr p_gres(wktreader.read(wktres));
 
-		OverlayResultValidator validator(*p_g0, *p_g1, *p_gres);
+    OverlayResultValidator validator(*p_g0, *p_g1, *p_gres);
 
-		ensure (! validator.isValid(OverlayOp::opUNION) );
-	}
+    ensure(! validator.isValid(OverlayOp::opUNION));
+}
 
 
-	template<>
-	template<>
-	void object::test<5>()
-	{
+template<>
+template<>
+void object::test<5>
+()
+{
 
-		std::string wkt0("POLYGON((0 0, 10 0, 10 10, 0 10, 0 0))");
-		GeomPtr p_g0(wktreader.read(wkt0));
+    std::string wkt0("POLYGON((0 0, 10 0, 10 10, 0 10, 0 0))");
+    GeomPtr p_g0(wktreader.read(wkt0));
 
-		std::string wkt1("POLYGON((5 0, 1500 0, 1500 10, 5 10, 5 0))");
-		GeomPtr p_g1(wktreader.read(wkt1));
+    std::string wkt1("POLYGON((5 0, 1500 0, 1500 10, 5 10, 5 0))");
+    GeomPtr p_g1(wktreader.read(wkt1));
 
-		// small shift
-		std::string wktres("POLYGON((0 0, 750 0.0001, 150 0, 150 10, 0 10, 0 0))");
-		GeomPtr p_gres(wktreader.read(wktres));
+    // small shift
+    std::string wktres("POLYGON((0 0, 750 0.0001, 150 0, 150 10, 0 10, 0 0))");
+    GeomPtr p_gres(wktreader.read(wktres));
 
-		OverlayResultValidator validator(*p_g0, *p_g1, *p_gres);
+    OverlayResultValidator validator(*p_g0, *p_g1, *p_gres);
 
-		ensure (! validator.isValid(OverlayOp::opUNION) );
-	}
+    ensure(! validator.isValid(OverlayOp::opUNION));
+}
 
-	template<>
-	template<>
-	void object::test<6>()
-	{
+template<>
+template<>
+void object::test<6>
+()
+{
 
-		std::string wkt0("POLYGON ((20.0 40.0, 20.0 200.0, 180.0 200.0, 180.0 120.0, 140.0 120.0, 180.0 119.0, 180.0 40.0, 20.0 40.0), (140.0 160.0, 80.0 120.0, 140.0 80.0, 140.0 160.0))");
-		GeomPtr p_g0(wktreader.read(wkt0));
+    std::string
+    wkt0("POLYGON ((20.0 40.0, 20.0 200.0, 180.0 200.0, 180.0 120.0, 140.0 120.0, 180.0 119.0, 180.0 40.0, 20.0 40.0), (140.0 160.0, 80.0 120.0, 140.0 80.0, 140.0 160.0))");
+    GeomPtr p_g0(wktreader.read(wkt0));
 
-		std::string wkt1("POLYGON ((200.0 160.0, 150.0 160.0, 150.0 80.0, 200.0 80.0, 200.0 160.0))");
-		GeomPtr p_g1(wktreader.read(wkt1));
+    std::string wkt1("POLYGON ((200.0 160.0, 150.0 160.0, 150.0 80.0, 200.0 80.0, 200.0 160.0))");
+    GeomPtr p_g1(wktreader.read(wkt1));
 
-		std::string wktres("MULTIPOLYGON (((20.0 40.0, 20.0 200.0, 180.0 200.0, 180.0 160.0, 150.0 160.0, 150.0 120.0, 150.0 80.0, 180.0 80.0, 180.0 40.0, 20.0 40.0), (80.0 120.0, 140.0 80.0, 140.0 120.0, 140.0 160.0, 80.0 120.0)), ((150.0 120.0, 180.0 120.0, 180.0 160.0, 200.0 160.0, 200.0 80.0, 180.0 80.0, 180.0 119.0, 150.0 120.0)))");
-		GeomPtr p_gres(wktreader.read(wktres));
+    std::string
+    wktres("MULTIPOLYGON (((20.0 40.0, 20.0 200.0, 180.0 200.0, 180.0 160.0, 150.0 160.0, 150.0 120.0, 150.0 80.0, 180.0 80.0, 180.0 40.0, 20.0 40.0), (80.0 120.0, 140.0 80.0, 140.0 120.0, 140.0 160.0, 80.0 120.0)), ((150.0 120.0, 180.0 120.0, 180.0 160.0, 200.0 160.0, 200.0 80.0, 180.0 80.0, 180.0 119.0, 150.0 120.0)))");
+    GeomPtr p_gres(wktreader.read(wktres));
 
-		OverlayResultValidator validator(*p_g0, *p_g1, *p_gres);
+    OverlayResultValidator validator(*p_g0, *p_g1, *p_gres);
 
-		ensure ( ! validator.isValid(OverlayOp::opSYMDIFFERENCE) );
-	}
+    ensure(! validator.isValid(OverlayOp::opSYMDIFFERENCE));
+}
 
 
-	//
-	// TODO: add tests for other operations
-	//       and other geometry types (IFF we drop the limit of the
-	//       class to only work with areal geoms)
+//
+// TODO: add tests for other operations
+//       and other geometry types (IFF we drop the limit of the
+//       class to only work with areal geoms)
 
 
 } // namespace tut
diff --git a/tests/unit/operation/polygonize/PolygonizeTest.cpp b/tests/unit/operation/polygonize/PolygonizeTest.cpp
index f22e354..6528bc9 100644
--- a/tests/unit/operation/polygonize/PolygonizeTest.cpp
+++ b/tests/unit/operation/polygonize/PolygonizeTest.cpp
@@ -20,169 +20,176 @@
 #include <vector>
 #include <iostream>
 
-namespace tut
-{
-    //
-    // Test Group
-    //
+namespace tut {
+//
+// Test Group
+//
+
+// Common data used by tests
+struct test_polygonizetest_data {
+    geos::io::WKTReader wktreader;
+    geos::io::WKTWriter wktwriter;
+
+    typedef geos::geom::Geometry::Ptr GeomPtr;
+    typedef geos::geom::Geometry Geom;
+    typedef geos::geom::Polygon Poly;
+    typedef geos::operation::polygonize::Polygonizer Polygonizer;
 
-    // Common data used by tests
-    struct test_polygonizetest_data
+    test_polygonizetest_data()
+        : wktreader()
     {
-        geos::io::WKTReader wktreader;
-        geos::io::WKTWriter wktwriter;
-
-        typedef geos::geom::Geometry::Ptr GeomPtr;
-        typedef geos::geom::Geometry Geom;
-        typedef geos::geom::Polygon Poly;
-        typedef geos::operation::polygonize::Polygonizer Polygonizer;
-
-        test_polygonizetest_data()
-          : wktreader()
-        {
-          wktwriter.setTrim(true);
-        }
+        wktwriter.setTrim(true);
+    }
 
-        template <class T>
-        void delAll(T& cnt)
-        {
-          for (typename T::iterator i=cnt.begin(), e=cnt.end(); i!=e; ++i) {
+    template <class T>
+    void
+    delAll(T& cnt)
+    {
+        for(typename T::iterator i = cnt.begin(), e = cnt.end(); i != e; ++i) {
             delete *i;
-          }
         }
+    }
 
-        template <class T>
-        void printAll(std::ostream& os, T& cnt)
-        {
-          for (typename T::iterator i=cnt.begin(), e=cnt.end(); i!=e; ++i) {
+    template <class T>
+    void
+    printAll(std::ostream& os, T& cnt)
+    {
+        for(typename T::iterator i = cnt.begin(), e = cnt.end(); i != e; ++i) {
             os << **i;
-          }
         }
+    }
 
-        GeomPtr readWKT(const std::string& inputWKT)
-        {
-            return GeomPtr(wktreader.read(inputWKT));
-        }
+    GeomPtr
+    readWKT(const std::string& inputWKT)
+    {
+        return GeomPtr(wktreader.read(inputWKT));
+    }
 
-        void readWKT(const char* const* inputWKT, std::vector<Geom*>& geoms)
-        {
-          for (const char* const* ptr=inputWKT; *ptr; ++ptr) {
+    void
+    readWKT(const char* const* inputWKT, std::vector<Geom*>& geoms)
+    {
+        for(const char* const* ptr = inputWKT; *ptr; ++ptr) {
             geoms.push_back(readWKT(*ptr).release());
-          }
         }
+    }
 
-        template <class T>
-        bool contains( T& cnt, const Geom* g)
-        {
-          for (typename T::iterator i=cnt.begin(), e=cnt.end(); i!=e; ++i) {
+    template <class T>
+    bool
+    contains(T& cnt, const Geom* g)
+    {
+        for(typename T::iterator i = cnt.begin(), e = cnt.end(); i != e; ++i) {
             const Geom* element = *i;
-            if (element->equalsExact(g)) {
-              return true;
+            if(element->equalsExact(g)) {
+                return true;
             }
-          }
-          return false;
         }
+        return false;
+    }
 
-        template <class T, class S>
-        bool compare( T& ex, S& ob)
-        {
-          using std::cout;
-          using std::endl;
+    template <class T, class S>
+    bool
+    compare(T& ex, S& ob)
+    {
+        using std::cout;
+        using std::endl;
 
-          if ( ex.size() != ob.size() ) {
+        if(ex.size() != ob.size()) {
             cout << "Expected " << ex.size() << " polygons, obtained "
                  << ob.size() << endl;
             return false;
-          }
-          for (typename T::iterator i=ex.begin(), e=ex.end(); i!=e; ++i) {
-            if ( ! contains(ob, *i) ) {
-              cout << "Expected " << wktwriter.write(*i)
-                   << " not found" << endl;
-              return false;
+        }
+        for(typename T::iterator i = ex.begin(), e = ex.end(); i != e; ++i) {
+            if(! contains(ob, *i)) {
+                cout << "Expected " << wktwriter.write(*i)
+                     << " not found" << endl;
+                return false;
             }
-          }
+        }
 
-          return true;
+        return true;
 
-        }
+    }
 
-        bool doTest(const char* const* inputWKT, const char* const* expectWKT)
-        {
-          using std::cout;
-          using std::endl;
+    bool
+    doTest(const char* const* inputWKT, const char* const* expectWKT)
+    {
+        using std::cout;
+        using std::endl;
 
-          std::vector<Geom*> inputGeoms, expectGeoms;
+        std::vector<Geom*> inputGeoms, expectGeoms;
 
-          readWKT(inputWKT, inputGeoms);
-          readWKT(expectWKT, expectGeoms);
+        readWKT(inputWKT, inputGeoms);
+        readWKT(expectWKT, expectGeoms);
 
-          Polygonizer polygonizer;
-          polygonizer.add(&inputGeoms);
+        Polygonizer polygonizer;
+        polygonizer.add(&inputGeoms);
 
-          std::unique_ptr< std::vector<Poly*> > retGeoms;
-          retGeoms.reset( polygonizer.getPolygons() );
+        std::unique_ptr< std::vector<Poly*> > retGeoms;
+        retGeoms.reset(polygonizer.getPolygons());
 
-          delAll(inputGeoms);
+        delAll(inputGeoms);
 
-          bool ok = compare(expectGeoms, *retGeoms);
-          if  ( ! ok ) {
+        bool ok = compare(expectGeoms, *retGeoms);
+        if(! ok) {
             cout << "OBTAINED(" << retGeoms->size() << "): ";
             printAll(cout, *retGeoms);
             cout << endl;
 
-            ensure( "not all expected geometries in the obtained set", 0 );
-          }
+            ensure("not all expected geometries in the obtained set", 0);
+        }
 
-          delAll(expectGeoms);
-          delAll(*retGeoms);
+        delAll(expectGeoms);
+        delAll(*retGeoms);
 
-          return ok;
-        }
+        return ok;
+    }
 
-    };
+};
 
-    typedef test_group<test_polygonizetest_data> group;
-    typedef group::object object;
+typedef test_group<test_polygonizetest_data> group;
+typedef group::object object;
 
-    group test_polygonizetest_group("geos::operation::polygonize::Polygonizer");
+group test_polygonizetest_group("geos::operation::polygonize::Polygonizer");
 
-    // test1() in JTS
-    template<>
-    template<>
-    void object::test<1>()
-    {
-        static char const* const inp[] = {
-            "LINESTRING EMPTY",
-            "LINESTRING EMPTY",
-            nullptr
-        };
+// test1() in JTS
+template<>
+template<>
+void object::test<1>
+()
+{
+    static char const* const inp[] = {
+        "LINESTRING EMPTY",
+        "LINESTRING EMPTY",
+        nullptr
+    };
 
-        static char const* const exp[] = {
-            nullptr
-        };
+    static char const* const exp[] = {
+        nullptr
+    };
 
-        doTest(inp, exp);
-    }
+    doTest(inp, exp);
+}
 
-    // test2() in JTS
-    template<>
-    template<>
-    void object::test<2>()
-    {
-        static char const* const inp[] = {
-            "LINESTRING (100 180, 20 20, 160 20, 100 180)",
-            "LINESTRING (100 180, 80 60, 120 60, 100 180)",
-            nullptr
-        };
-
-        static char const* const exp[] = {
-            "POLYGON ((100 180, 120 60, 80 60, 100 180))",
-            "POLYGON ((100 180, 160 20, 20 20, 100 180), (100 180, 80 60, 120 60, 100 180))",
-            nullptr
-        };
-
-        doTest(inp, exp);
-    }
+// test2() in JTS
+template<>
+template<>
+void object::test<2>
+()
+{
+    static char const* const inp[] = {
+        "LINESTRING (100 180, 20 20, 160 20, 100 180)",
+        "LINESTRING (100 180, 80 60, 120 60, 100 180)",
+        nullptr
+    };
+
+    static char const* const exp[] = {
+        "POLYGON ((100 180, 120 60, 80 60, 100 180))",
+        "POLYGON ((100 180, 160 20, 20 20, 100 180), (100 180, 80 60, 120 60, 100 180))",
+        nullptr
+    };
+
+    doTest(inp, exp);
+}
 
 } // namespace tut
 
diff --git a/tests/unit/operation/sharedpaths/SharedPathsOpTest.cpp b/tests/unit/operation/sharedpaths/SharedPathsOpTest.cpp
index e4f8396..d82bc07 100644
--- a/tests/unit/operation/sharedpaths/SharedPathsOpTest.cpp
+++ b/tests/unit/operation/sharedpaths/SharedPathsOpTest.cpp
@@ -17,15 +17,13 @@
 #include <string>
 #include <vector>
 
-namespace tut
-{
-  //
-  // Test Group
-  //
+namespace tut {
+//
+// Test Group
+//
 
-  // Common data used by tests
-  struct test_shpathop_data
-  {
+// Common data used by tests
+struct test_shpathop_data {
     typedef geos::operation::sharedpaths::SharedPathsOp SharedPathsOp;
 
     geos::io::WKTReader wktreader;
@@ -37,157 +35,177 @@ namespace tut
     SharedPathsOp::PathList backDir;
 
     test_shpathop_data()
-      : wktreader(), wktwriter()
+        : wktreader(), wktwriter()
     {
-      wktwriter.setTrim(true);
+        wktwriter.setTrim(true);
     }
 
-  private:
+private:
     // noncopyable
     test_shpathop_data(test_shpathop_data const& other) = delete;
     test_shpathop_data& operator=(test_shpathop_data const& rhs) = delete;
-  };
+};
 
-  typedef test_group<test_shpathop_data> group;
-  typedef group::object object;
+typedef test_group<test_shpathop_data> group;
+typedef group::object object;
 
-  group test_shpathop_group("geos::operation::sharedpaths::SharedPathsOp");
+group test_shpathop_group("geos::operation::sharedpaths::SharedPathsOp");
 
-  //
-  // Test Cases
-  //
+//
+// Test Cases
+//
 
-  // Point (illegal arg)
-  template<> template<>
-  void object::test<1>()
-  {
+// Point (illegal arg)
+template<> template<>
+void object::test<1>
+()
+{
     GeomPtr g0(wktreader.read("POINT(0 0)"));
     GeomPtr g1(wktreader.read("POINT(1 1)"));
     bool threw = false;
     try {
-      SharedPathsOp::sharedPathsOp(*g0, *g1, forwDir, backDir);
-    } catch (const geos::util::IllegalArgumentException& /*ex*/) {
-      threw = true;
+        SharedPathsOp::sharedPathsOp(*g0, *g1, forwDir, backDir);
+    }
+    catch(const geos::util::IllegalArgumentException& /*ex*/) {
+        threw = true;
     }
     ensure(threw);
-  }
+}
 
-  // Poly (illegal arg)
-  template<> template<>
-  void object::test<2>()
-  {
+// Poly (illegal arg)
+template<> template<>
+void object::test<2>
+()
+{
     GeomPtr g0(wktreader.read("POLYGON((0 0, 10 0, 10 10, 0 10, 0 0))"));
     GeomPtr g1(wktreader.read("LINESTRING(0 0, 10 0)"));
     bool threw = false;
     try {
-      SharedPathsOp::sharedPathsOp(*g0, *g1, forwDir, backDir);
-    } catch (const geos::util::IllegalArgumentException& /*ex*/) {
-      threw = true;
+        SharedPathsOp::sharedPathsOp(*g0, *g1, forwDir, backDir);
+    }
+    catch(const geos::util::IllegalArgumentException& /*ex*/) {
+        threw = true;
     }
     ensure(threw);
-  }
+}
 
-  // Line-Line (disjoint)
-  template<> template<>
-  void object::test<3>()
-  {
+// Line-Line (disjoint)
+template<> template<>
+void object::test<3>
+()
+{
     GeomPtr g0(wktreader.read("LINESTRING(0 0, 10 0)"));
     GeomPtr g1(wktreader.read("LINESTRING(20 0, 20 0)"));
-    forwDir.clear(); backDir.clear();
+    forwDir.clear();
+    backDir.clear();
     SharedPathsOp::sharedPathsOp(*g0, *g1, forwDir, backDir);
     ensure(forwDir.empty());
     ensure(backDir.empty());
-  }
+}
 
-  // Line-Line (crossing)
-  template<> template<>
-  void object::test<4>()
-  {
+// Line-Line (crossing)
+template<> template<>
+void object::test<4>
+()
+{
     GeomPtr g0(wktreader.read("LINESTRING(0 0, 10 0)"));
     GeomPtr g1(wktreader.read("LINESTRING(-10 5, 10 5)"));
-    forwDir.clear(); backDir.clear();
+    forwDir.clear();
+    backDir.clear();
     SharedPathsOp::sharedPathsOp(*g0, *g1, forwDir, backDir);
     ensure(forwDir.empty());
     ensure(backDir.empty());
-  }
+}
 
-  // Line-Line (overlapping, forward)
-  template<> template<>
-  void object::test<5>()
-  {
+// Line-Line (overlapping, forward)
+template<> template<>
+void object::test<5>
+()
+{
     GeomPtr g0(wktreader.read("LINESTRING(0 0, 10 0)"));
     GeomPtr g1(wktreader.read("LINESTRING(5 0, 15 0)"));
-    forwDir.clear(); backDir.clear();
+    forwDir.clear();
+    backDir.clear();
     SharedPathsOp::sharedPathsOp(*g0, *g1, forwDir, backDir);
     ensure(backDir.empty());
     ensure_equals(forwDir.size(), 1u);
     ensure_equals(wktwriter.write(forwDir[0]), "LINESTRING (5 0, 10 0)");
     SharedPathsOp::clearEdges(forwDir);
-  }
+}
 
-  // Line-Line (overlapping, backward)
-  template<> template<>
-  void object::test<6>()
-  {
+// Line-Line (overlapping, backward)
+template<> template<>
+void object::test<6>
+()
+{
     GeomPtr g0(wktreader.read("LINESTRING(0 0, 10 0)"));
     GeomPtr g1(wktreader.read("LINESTRING(15 0, 5 0)"));
-    forwDir.clear(); backDir.clear();
+    forwDir.clear();
+    backDir.clear();
     SharedPathsOp::sharedPathsOp(*g0, *g1, forwDir, backDir);
     ensure(forwDir.empty());
     ensure_equals(backDir.size(), 1u);
     ensure_equals(wktwriter.write(backDir[0]), "LINESTRING (5 0, 10 0)");
     SharedPathsOp::clearEdges(backDir);
-  }
+}
 
-  // Line-Line (overlapping, backward, swapped)
-  template<> template<>
-  void object::test<7>()
-  {
+// Line-Line (overlapping, backward, swapped)
+template<> template<>
+void object::test<7>
+()
+{
     GeomPtr g0(wktreader.read("LINESTRING(15 0, 5 0)"));
     GeomPtr g1(wktreader.read("LINESTRING(0 0, 10 0)"));
-    forwDir.clear(); backDir.clear();
+    forwDir.clear();
+    backDir.clear();
     SharedPathsOp::sharedPathsOp(*g0, *g1, forwDir, backDir);
     ensure(forwDir.empty());
     ensure_equals(backDir.size(), 1u);
     ensure_equals(wktwriter.write(backDir[0]), "LINESTRING (10 0, 5 0)");
     SharedPathsOp::clearEdges(backDir);
-  }
+}
 
-  // Line-Line (contained, forward)
-  template<> template<>
-  void object::test<8>()
-  {
+// Line-Line (contained, forward)
+template<> template<>
+void object::test<8>
+()
+{
     GeomPtr g0(wktreader.read("LINESTRING(-15 0, 15 0)"));
     GeomPtr g1(wktreader.read("LINESTRING(-10 0, 10 0)"));
-    forwDir.clear(); backDir.clear();
+    forwDir.clear();
+    backDir.clear();
     SharedPathsOp::sharedPathsOp(*g0, *g1, forwDir, backDir);
     ensure(backDir.empty());
     ensure_equals(forwDir.size(), 1u);
     ensure_equals(wktwriter.write(forwDir[0]), "LINESTRING (-10 0, 10 0)");
     SharedPathsOp::clearEdges(forwDir);
-  }
+}
 
-  // Line-Line (contained, backward)
-  template<> template<>
-  void object::test<9>()
-  {
+// Line-Line (contained, backward)
+template<> template<>
+void object::test<9>
+()
+{
     GeomPtr g0(wktreader.read("LINESTRING(-15 0, 15 0)"));
     GeomPtr g1(wktreader.read("LINESTRING(10 0, -10 0)"));
-    forwDir.clear(); backDir.clear();
+    forwDir.clear();
+    backDir.clear();
     SharedPathsOp::sharedPathsOp(*g0, *g1, forwDir, backDir);
     ensure(forwDir.empty());
     ensure_equals(backDir.size(), 1u);
     ensure_equals(wktwriter.write(backDir[0]), "LINESTRING (-10 0, 10 0)");
     SharedPathsOp::clearEdges(backDir);
-  }
+}
 
-  // Line-Line (back and forw)
-  template<> template<>
-  void object::test<10>()
-  {
+// Line-Line (back and forw)
+template<> template<>
+void object::test<10>
+()
+{
     GeomPtr g0(wktreader.read("LINESTRING(-15 0, 15 0)"));
     GeomPtr g1(wktreader.read("LINESTRING(-10 0, -5 0, 0 5, 10 0, 5 0)"));
-    forwDir.clear(); backDir.clear();
+    forwDir.clear();
+    backDir.clear();
     SharedPathsOp::sharedPathsOp(*g0, *g1, forwDir, backDir);
 
     ensure_equals(forwDir.size(), 1u);
@@ -197,15 +215,17 @@ namespace tut
     ensure_equals(backDir.size(), 1u);
     ensure_equals(wktwriter.write(backDir[0]), "LINESTRING (5 0, 10 0)");
     SharedPathsOp::clearEdges(backDir);
-  }
+}
 
-  // Line-Line (back and forw, swapped)
-  template<> template<>
-  void object::test<11>()
-  {
+// Line-Line (back and forw, swapped)
+template<> template<>
+void object::test<11>
+()
+{
     GeomPtr g0(wktreader.read("LINESTRING(-10 0, -5 0, 0 5, 10 0, 5 0)"));
     GeomPtr g1(wktreader.read("LINESTRING(-15 0, 15 0)"));
-    forwDir.clear(); backDir.clear();
+    forwDir.clear();
+    backDir.clear();
     SharedPathsOp::sharedPathsOp(*g0, *g1, forwDir, backDir);
 
     ensure_equals(forwDir.size(), 1u);
@@ -215,15 +235,17 @@ namespace tut
     ensure_equals(backDir.size(), 1u);
     ensure_equals(wktwriter.write(backDir[0]), "LINESTRING (10 0, 5 0)");
     SharedPathsOp::clearEdges(backDir);
-  }
+}
 
-  // MultiLine-Line (back and forth)
-  template<> template<>
-  void object::test<12>()
-  {
+// MultiLine-Line (back and forth)
+template<> template<>
+void object::test<12>
+()
+{
     GeomPtr g0(wktreader.read("MULTILINESTRING((-10 0, -5 0),(10 0, 5 0))"));
     GeomPtr g1(wktreader.read("LINESTRING(-15 0, 15 0)"));
-    forwDir.clear(); backDir.clear();
+    forwDir.clear();
+    backDir.clear();
     SharedPathsOp::sharedPathsOp(*g0, *g1, forwDir, backDir);
 
     ensure_equals(forwDir.size(), 1u);
@@ -233,15 +255,17 @@ namespace tut
     ensure_equals(backDir.size(), 1u);
     ensure_equals(wktwriter.write(backDir[0]), "LINESTRING (10 0, 5 0)");
     SharedPathsOp::clearEdges(backDir);
-  }
+}
 
-  // MultiLine-MultiLine (back and forth)
-  template<> template<>
-  void object::test<13>()
-  {
+// MultiLine-MultiLine (back and forth)
+template<> template<>
+void object::test<13>
+()
+{
     GeomPtr g0(wktreader.read("MULTILINESTRING((-10 0, -5 0),(10 0, 5 0))"));
     GeomPtr g1(wktreader.read("MULTILINESTRING((-8 0, -2 0),(6 0, 12 0))"));
-    forwDir.clear(); backDir.clear();
+    forwDir.clear();
+    backDir.clear();
     SharedPathsOp::sharedPathsOp(*g0, *g1, forwDir, backDir);
 
     ensure_equals(forwDir.size(), 1u);
@@ -251,15 +275,17 @@ namespace tut
     ensure_equals(backDir.size(), 1u);
     ensure_equals(wktwriter.write(backDir[0]), "LINESTRING (10 0, 6 0)");
     SharedPathsOp::clearEdges(backDir);
-  }
+}
 
-  // MultiLine-MultiLine (forth and forth)
-  template<> template<>
-  void object::test<14>()
-  {
+// MultiLine-MultiLine (forth and forth)
+template<> template<>
+void object::test<14>
+()
+{
     GeomPtr g0(wktreader.read("MULTILINESTRING((-10 0, -5 0),(10 0, 5 0))"));
     GeomPtr g1(wktreader.read("MULTILINESTRING((-8 0, -2 0),(12 0, 6 0))"));
-    forwDir.clear(); backDir.clear();
+    forwDir.clear();
+    backDir.clear();
     SharedPathsOp::sharedPathsOp(*g0, *g1, forwDir, backDir);
 
     ensure_equals(forwDir.size(), 2u);
@@ -268,15 +294,17 @@ namespace tut
     SharedPathsOp::clearEdges(forwDir);
 
     ensure(backDir.empty());
-  }
+}
 
-  // MultiLine-MultiLine (back and back)
-  template<> template<>
-  void object::test<15>()
-  {
+// MultiLine-MultiLine (back and back)
+template<> template<>
+void object::test<15>
+()
+{
     GeomPtr g0(wktreader.read("MULTILINESTRING((-10 0, -5 0),(10 0, 5 0))"));
     GeomPtr g1(wktreader.read("MULTILINESTRING((6 0, 12 0),(-2 0, -8 0))"));
-    forwDir.clear(); backDir.clear();
+    forwDir.clear();
+    backDir.clear();
     SharedPathsOp::sharedPathsOp(*g0, *g1, forwDir, backDir);
 
     ensure_equals(backDir.size(), 2u);
@@ -285,16 +313,18 @@ namespace tut
     SharedPathsOp::clearEdges(backDir);
 
     ensure(forwDir.empty());
-  }
+}
 
-  // line-line (equals, forward)
-  template<> template<>
-  void object::test<16>()
-  {
+// line-line (equals, forward)
+template<> template<>
+void object::test<16>
+()
+{
     GeomPtr g0(wktreader.read("LINESTRING(0 0, 5 10, 10 10)"));
     GeomPtr g1(wktreader.read("LINESTRING(0 0, 5 10, 10 10)"));
 
-    forwDir.clear(); backDir.clear();
+    forwDir.clear();
+    backDir.clear();
     SharedPathsOp::sharedPathsOp(*g0, *g1, forwDir, backDir);
     ensure_equals(forwDir.size(), 2u);
     ensure_equals(wktwriter.write(forwDir[0]), "LINESTRING (0 0, 5 10)");
@@ -302,16 +332,18 @@ namespace tut
     SharedPathsOp::clearEdges(forwDir);
 
     ensure(backDir.empty());
-  }
+}
 
-  // line-line (equals, backward)
-  template<> template<>
-  void object::test<17>()
-  {
+// line-line (equals, backward)
+template<> template<>
+void object::test<17>
+()
+{
     GeomPtr g0(wktreader.read("LINESTRING( 0  0, 5 10, 10 10)"));
     GeomPtr g1(wktreader.read("LINESTRING(10 10, 5 10,  0  0)"));
 
-    forwDir.clear(); backDir.clear();
+    forwDir.clear();
+    backDir.clear();
     SharedPathsOp::sharedPathsOp(*g0, *g1, forwDir, backDir);
     ensure_equals(backDir.size(), 2u);
     ensure_equals(wktwriter.write(backDir[0]), "LINESTRING (0 0, 5 10)");
@@ -319,71 +351,79 @@ namespace tut
     SharedPathsOp::clearEdges(backDir);
 
     ensure(forwDir.empty());
-  }
+}
 
-  // line - line_closed_no_rhr
-  template<> template<>
-  void object::test<18>()
-  {
+// line - line_closed_no_rhr
+template<> template<>
+void object::test<18>
+()
+{
     GeomPtr g0(wktreader.read("LINESTRING( 0  0, 10 0)"));
     GeomPtr g1(wktreader.read("LINESTRING( 0  0, 10 0, 10 10, 0 10, 0 0 )"));
 
-    forwDir.clear(); backDir.clear();
+    forwDir.clear();
+    backDir.clear();
     SharedPathsOp::sharedPathsOp(*g0, *g1, forwDir, backDir);
     ensure_equals(forwDir.size(), 1u);
     ensure_equals(wktwriter.write(forwDir[0]), "LINESTRING (0 0, 10 0)");
     SharedPathsOp::clearEdges(forwDir);
 
     ensure(backDir.empty());
-  }
+}
 
-  // line_closed_no_rhr - line
-  template<> template<>
-  void object::test<19>()
-  {
+// line_closed_no_rhr - line
+template<> template<>
+void object::test<19>
+()
+{
     GeomPtr g0(wktreader.read("LINESTRING( 0  0, 10 0, 10 10, 0 10, 0 0 )"));
     GeomPtr g1(wktreader.read("LINESTRING( 0  0, 10 0)"));
 
-    forwDir.clear(); backDir.clear();
+    forwDir.clear();
+    backDir.clear();
     SharedPathsOp::sharedPathsOp(*g0, *g1, forwDir, backDir);
     ensure_equals(forwDir.size(), 1u);
     ensure_equals(wktwriter.write(forwDir[0]), "LINESTRING (0 0, 10 0)");
     SharedPathsOp::clearEdges(forwDir);
 
     ensure(backDir.empty());
-  }
+}
 
-  // line - line_closed_rhr (see ticket #391)
-  template<> template<>
-  void object::test<20>()
-  {
+// line - line_closed_rhr (see ticket #391)
+template<> template<>
+void object::test<20>
+()
+{
     GeomPtr g0(wktreader.read("LINESTRING( 0  0, 10 0)"));
     GeomPtr g1(wktreader.read("LINESTRING( 0  0, 0 10, 10 10, 10 0, 0 0 )"));
 
-    forwDir.clear(); backDir.clear();
+    forwDir.clear();
+    backDir.clear();
     SharedPathsOp::sharedPathsOp(*g0, *g1, forwDir, backDir);
     ensure_equals(backDir.size(), 1u);
     ensure_equals(wktwriter.write(backDir[0]), "LINESTRING (0 0, 10 0)");
     SharedPathsOp::clearEdges(backDir);
 
     ensure(forwDir.empty());
-  }
+}
 
-  // line_closed_rhr - line
-  template<> template<>
-  void object::test<21>()
-  {
+// line_closed_rhr - line
+template<> template<>
+void object::test<21>
+()
+{
     GeomPtr g0(wktreader.read("LINESTRING( 0  0, 0 10, 10 10, 10 0, 0 0 )"));
     GeomPtr g1(wktreader.read("LINESTRING( 0  0, 10 0)"));
 
-    forwDir.clear(); backDir.clear();
+    forwDir.clear();
+    backDir.clear();
     SharedPathsOp::sharedPathsOp(*g0, *g1, forwDir, backDir);
     ensure_equals(backDir.size(), 1u);
     ensure_equals(wktwriter.write(backDir[0]), "LINESTRING (10 0, 0 0)");
     SharedPathsOp::clearEdges(backDir);
 
     ensure(forwDir.empty());
-  }
+}
 
 } // namespace tut
 
diff --git a/tests/unit/operation/union/CascadedPolygonUnionTest.cpp b/tests/unit/operation/union/CascadedPolygonUnionTest.cpp
index c95b728..e6e887d 100644
--- a/tests/unit/operation/union/CascadedPolygonUnionTest.cpp
+++ b/tests/unit/operation/union/CascadedPolygonUnionTest.cpp
@@ -16,123 +16,122 @@
 #include <string>
 #include <vector>
 
-namespace tut
+namespace tut {
+//
+// Test Group
+//
+
+// Common data used by tests
+struct test_cascadedpolygonuniontest_data {
+    const geos::geom::GeometryFactory& gf;
+    geos::io::WKTReader wktreader;
+    geos::io::WKTWriter wktwriter;
+
+    typedef geos::geom::Geometry::Ptr GeomPtr;
+
+    test_cascadedpolygonuniontest_data()
+        : gf(*geos::geom::GeometryFactory::getDefaultInstance())
+        , wktreader(&gf)
+    {}
+};
+
+typedef test_group<test_cascadedpolygonuniontest_data> group;
+typedef group::object object;
+
+group test_cascadedpolygonuniontest_group("geos::operation::geounion::CascadedPolygonUnion");
+
+// test runner
+geos::geom::Geometry*
+unionIterated(
+    std::vector<geos::geom::Polygon*>* geoms)
 {
-    //
-    // Test Group
-    //
-
-    // Common data used by tests
-    struct test_cascadedpolygonuniontest_data
-    {
-        const geos::geom::GeometryFactory& gf;
-        geos::io::WKTReader wktreader;
-        geos::io::WKTWriter wktwriter;
-
-        typedef geos::geom::Geometry::Ptr GeomPtr;
-
-        test_cascadedpolygonuniontest_data()
-          : gf(*geos::geom::GeometryFactory::getDefaultInstance())
-          , wktreader(&gf)
-        {}
-    };
+    typedef std::vector<geos::geom::Polygon*>::iterator iterator;
 
-    typedef test_group<test_cascadedpolygonuniontest_data> group;
-    typedef group::object object;
-
-    group test_cascadedpolygonuniontest_group("geos::operation::geounion::CascadedPolygonUnion");
-
-    // test runner
-    geos::geom::Geometry* unionIterated(
-        std::vector<geos::geom::Polygon*>* geoms)
-    {
-        typedef std::vector<geos::geom::Polygon*>::iterator iterator;
-
-        std::unique_ptr<geos::geom::Geometry> unionAll;
-        iterator end = geoms->end();
-        for (iterator i = geoms->begin(); i != end; ++i)
-        {
-            if (!unionAll.get())
-            {
-                unionAll.reset((*i)->clone());
-            }
-            else
-            {
-                unionAll.reset(unionAll->Union(*i));
-            }
+    std::unique_ptr<geos::geom::Geometry> unionAll;
+    iterator end = geoms->end();
+    for(iterator i = geoms->begin(); i != end; ++i) {
+        if(!unionAll.get()) {
+            unionAll.reset((*i)->clone());
+        }
+        else {
+            unionAll.reset(unionAll->Union(*i));
         }
-        return unionAll.release();
     }
+    return unionAll.release();
+}
 
-    geos::geom::Geometry* unionCascaded(
-        std::vector<geos::geom::Polygon*>* geoms)
-    {
-        using geos::operation::geounion::CascadedPolygonUnion;
-        return CascadedPolygonUnion::Union(geoms);
-    }
+geos::geom::Geometry*
+unionCascaded(
+    std::vector<geos::geom::Polygon*>* geoms)
+{
+    using geos::operation::geounion::CascadedPolygonUnion;
+    return CascadedPolygonUnion::Union(geoms);
+}
 
-    void p_test_runner(test_cascadedpolygonuniontest_data& t,
-        std::vector<geos::geom::Polygon*>* geoms)
-    {
-        std::unique_ptr<geos::geom::Geometry> union1(unionIterated(geoms));
-        std::unique_ptr<geos::geom::Geometry> union2(unionCascaded(geoms));
+void
+p_test_runner(test_cascadedpolygonuniontest_data& t,
+              std::vector<geos::geom::Polygon*>* geoms)
+{
+    std::unique_ptr<geos::geom::Geometry> union1(unionIterated(geoms));
+    std::unique_ptr<geos::geom::Geometry> union2(unionCascaded(geoms));
 
-        // For now we compare the WKT representations of the two generated
-        // geometries which works well for simple geometries only.
-        // More complex geometries require to use special similarity measure
-        // criteria instead.
-        std::string iterated(t.wktwriter.writeFormatted(union1.get()));
-        std::string cascaded(t.wktwriter.writeFormatted(union2.get()));
+    // For now we compare the WKT representations of the two generated
+    // geometries which works well for simple geometries only.
+    // More complex geometries require to use special similarity measure
+    // criteria instead.
+    std::string iterated(t.wktwriter.writeFormatted(union1.get()));
+    std::string cascaded(t.wktwriter.writeFormatted(union2.get()));
 
-        ensure_equals(iterated, cascaded);
-    }
+    ensure_equals(iterated, cascaded);
+}
 
-    void delete_geometry(geos::geom::Geometry* g)
-    {
-        delete g;
-    }
+void
+delete_geometry(geos::geom::Geometry* g)
+{
+    delete g;
+}
 
-    //
-    // Test Cases
-    //
-
-    template<>
-    template<>
-    void object::test<1>()
-    {
-        static char const* const polygons[] =
-        {
-            "POLYGON ((80 260, 200 260, 200 30, 80 30, 80 260))",
-            "POLYGON ((30 180, 300 180, 300 110, 30 110, 30 180))",
-            "POLYGON ((30 280, 30 150, 140 150, 140 280, 30 280))",
-            nullptr
-        };
-
-        std::vector<geos::geom::Polygon*> g;
-        for (char const* const* p = polygons; *p != nullptr; ++p)
-        {
-            std::string wkt(*p);
-            geos::geom::Polygon* geom =
-                dynamic_cast<geos::geom::Polygon*>(wktreader.read(wkt));
-            g.push_back(geom);
-        }
+//
+// Test Cases
+//
 
-        p_test_runner(*this, &g);
+template<>
+template<>
+void object::test<1>
+()
+{
+    static char const* const polygons[] = {
+        "POLYGON ((80 260, 200 260, 200 30, 80 30, 80 260))",
+        "POLYGON ((30 180, 300 180, 300 110, 30 110, 30 180))",
+        "POLYGON ((30 280, 30 150, 140 150, 140 280, 30 280))",
+        nullptr
+    };
 
-        for_each(g.begin(), g.end(), delete_geometry);
+    std::vector<geos::geom::Polygon*> g;
+    for(char const * const* p = polygons; *p != nullptr; ++p) {
+        std::string wkt(*p);
+        geos::geom::Polygon* geom =
+            dynamic_cast<geos::geom::Polygon*>(wktreader.read(wkt));
+        g.push_back(geom);
     }
 
-    void create_discs(geos::geom::GeometryFactory& gf, int num, double radius,
-        std::vector<geos::geom::Polygon*>* g)
-    {
-        for (int i = 0; i < num; ++i) {
-            for (int j = 0; j < num; ++j) {
-                std::unique_ptr<geos::geom::Point> pt(
-                    gf.createPoint(geos::geom::Coordinate(i, j)));
-                g->push_back(dynamic_cast<geos::geom::Polygon*>(pt->buffer(radius)));
-            }
+    p_test_runner(*this, &g);
+
+    for_each(g.begin(), g.end(), delete_geometry);
+}
+
+void
+create_discs(geos::geom::GeometryFactory& gf, int num, double radius,
+             std::vector<geos::geom::Polygon*>* g)
+{
+    for(int i = 0; i < num; ++i) {
+        for(int j = 0; j < num; ++j) {
+            std::unique_ptr<geos::geom::Point> pt(
+                gf.createPoint(geos::geom::Coordinate(i, j)));
+            g->push_back(dynamic_cast<geos::geom::Polygon*>(pt->buffer(radius)));
         }
     }
+}
 
 // these tests currently fail because the geometries generated by the different
 // union algoritms are slightly different. In order to make those tests pass
diff --git a/tests/unit/operation/union/UnaryUnionOpTest.cpp b/tests/unit/operation/union/UnaryUnionOpTest.cpp
index 0f2e729..d301e48 100644
--- a/tests/unit/operation/union/UnaryUnionOpTest.cpp
+++ b/tests/unit/operation/union/UnaryUnionOpTest.cpp
@@ -17,179 +17,192 @@
 #include <vector>
 #include <iostream>
 
-namespace tut
-{
-    //
-    // Test Group
-    //
+namespace tut {
+//
+// Test Group
+//
+
+// Common data used by tests
+struct test_unaryuniontest_data {
+    typedef geos::geom::GeometryFactory GeometryFactory;
+    GeometryFactory::Ptr gf;
+    geos::io::WKTReader wktreader;
+    geos::io::WKTWriter wktwriter;
 
-    // Common data used by tests
-    struct test_unaryuniontest_data
+    typedef geos::geom::Geometry::Ptr GeomPtr;
+    typedef geos::geom::Geometry Geom;
+    typedef geos::operation::geounion::UnaryUnionOp UnaryUnionOp;
+
+    test_unaryuniontest_data()
+        : gf(GeometryFactory::create()),
+          wktreader(gf.get())
     {
-        typedef geos::geom::GeometryFactory GeometryFactory;
-        GeometryFactory::Ptr gf;
-        geos::io::WKTReader wktreader;
-        geos::io::WKTWriter wktwriter;
-
-        typedef geos::geom::Geometry::Ptr GeomPtr;
-        typedef geos::geom::Geometry Geom;
-        typedef geos::operation::geounion::UnaryUnionOp UnaryUnionOp;
-
-        test_unaryuniontest_data()
-          : gf(GeometryFactory::create()),
-            wktreader(gf.get())
-        {
-          wktwriter.setTrim(true);
-        }
+        wktwriter.setTrim(true);
+    }
 
-        void delAll(std::vector<Geom*>& geoms)
-        {
-          for (size_t i=0; i<geoms.size(); ++i) delete geoms[i];
+    void
+    delAll(std::vector<Geom*>& geoms)
+    {
+        for(size_t i = 0; i < geoms.size(); ++i) {
+            delete geoms[i];
         }
+    }
 
-        GeomPtr readWKT(const std::string& inputWKT)
-        {
-            return GeomPtr(wktreader.read(inputWKT));
-        }
+    GeomPtr
+    readWKT(const std::string& inputWKT)
+    {
+        return GeomPtr(wktreader.read(inputWKT));
+    }
 
-        void readWKT(const char* const* inputWKT, std::vector<Geom*>& geoms)
-        {
-          for (const char* const* ptr=inputWKT; *ptr; ++ptr) {
+    void
+    readWKT(const char* const* inputWKT, std::vector<Geom*>& geoms)
+    {
+        for(const char* const* ptr = inputWKT; *ptr; ++ptr) {
             geoms.push_back(readWKT(*ptr).release());
-          }
         }
+    }
 
-        static GeomPtr normalize(const Geom& g)
-        {
-          GeomPtr g2 ( g.clone() );
-          g2->normalize();
-          return g2;
-        }
+    static GeomPtr
+    normalize(const Geom& g)
+    {
+        GeomPtr g2(g.clone());
+        g2->normalize();
+        return g2;
+    }
 
-        bool isEqual(const Geom& a, const Geom& b)
-        {
-          using std::cout;
-          using std::endl;
-          GeomPtr a2 = normalize(a);
-          GeomPtr b2 = normalize(b);
-          bool eq = a2->equalsExact(b2.get());
-          if  ( ! eq ) {
+    bool
+    isEqual(const Geom& a, const Geom& b)
+    {
+        using std::cout;
+        using std::endl;
+        GeomPtr a2 = normalize(a);
+        GeomPtr b2 = normalize(b);
+        bool eq = a2->equalsExact(b2.get());
+        if(! eq) {
             cout << "OBTAINED: " << wktwriter.write(b2.get()) << endl;
-          }
-          return eq;
         }
+        return eq;
+    }
 
-        void doTest(const char* const* inputWKT, const std::string& expectedWKT)
-        {
-          std::vector<Geom*> geoms;
-          readWKT(inputWKT, geoms);
+    void
+    doTest(const char* const* inputWKT, const std::string& expectedWKT)
+    {
+        std::vector<Geom*> geoms;
+        readWKT(inputWKT, geoms);
 
-          GeomPtr result;
-          if ( geoms.empty() )
+        GeomPtr result;
+        if(geoms.empty()) {
             result = UnaryUnionOp::Union(geoms, *gf);
-          else
+        }
+        else {
             result = UnaryUnionOp::Union(geoms);
-
-          bool ok = isEqual(*readWKT(expectedWKT), *result);
-          delAll(geoms);
-
-          ensure(ok);
         }
 
-    };
+        bool ok = isEqual(*readWKT(expectedWKT), *result);
+        delAll(geoms);
 
-    typedef test_group<test_unaryuniontest_data> group;
-    typedef group::object object;
+        ensure(ok);
+    }
 
-    group test_unaryuniontest_group("geos::operation::geounion::UnaryUnionOp");
+};
 
-    template<>
-    template<>
-    void object::test<1>()
-    {
-        static char const* const geoms[] = { nullptr };
-        doTest(geoms, "GEOMETRYCOLLECTION EMPTY");
-    }
+typedef test_group<test_unaryuniontest_data> group;
+typedef group::object object;
 
-    template<>
-    template<>
-    void object::test<2>()
-    {
-        static char const* const geoms[] = {
-          "POINT (1 1)", "POINT (2 2)",
-          nullptr
-        };
-        doTest(geoms, "MULTIPOINT ((1 1), (2 2))");
-    }
+group test_unaryuniontest_group("geos::operation::geounion::UnaryUnionOp");
 
-    template<>
-    template<>
-    void object::test<3>()
-    {
-        static char const* const geoms[] = {
-          "GEOMETRYCOLLECTION (POLYGON ((0 0, 0 90, 90 90, 90 0, 0 0)),   POLYGON ((120 0, 120 90, 210 90, 210 0, 120 0)),  LINESTRING (40 50, 40 140),  LINESTRING (160 50, 160 140),  POINT (60 50),  POINT (60 140),  POINT (40 140))",
-          nullptr
-        };
-        doTest(geoms, "GEOMETRYCOLLECTION (POINT (60 140),   LINESTRING (40 90, 40 140), LINESTRING (160 90, 160 140), POLYGON ((0 0, 0 90, 40 90, 90 90, 90 0, 0 0)), POLYGON ((120 0, 120 90, 160 90, 210 90, 210 0, 120 0)))");
-    }
+template<>
+template<>
+void object::test<1>
+()
+{
+    static char const* const geoms[] = { nullptr };
+    doTest(geoms, "GEOMETRYCOLLECTION EMPTY");
+}
+
+template<>
+template<>
+void object::test<2>
+()
+{
+    static char const* const geoms[] = {
+        "POINT (1 1)", "POINT (2 2)",
+        nullptr
+    };
+    doTest(geoms, "MULTIPOINT ((1 1), (2 2))");
+}
 
-    template<>
-    template<>
-    void object::test<4>()
-    {
-        static char const* const geoms[] =
-        {
-            "POLYGON ((0 0, 10 0, 10 10, 0 10, 0 0))",
-            "MULTIPOLYGON (((20 0, 20 10, 40 10, 40 0, 20 0)),((5 5, 5 8, 8 8, 8 5, 5 5)))",
-            "POINT (5 5)",
-            "POINT (-5 5)",
-            "LINESTRING (-10 -10, -10 0, -10 20)",
-            "LINESTRING (-10 2, 10 2)",
-            nullptr
-        };
-        doTest(geoms, "GEOMETRYCOLLECTION (POLYGON ((0 0, 0 2, 0 10, 10 10, 10 2, 10 0, 0 0)), POLYGON ((20 0, 20 10, 40 10, 40 0, 20 0)), LINESTRING (-10 -10, -10 0, -10 2), LINESTRING (-10 2, 0 2), LINESTRING (-10 2, -10 20), POINT (-5 5))");
+template<>
+template<>
+void object::test<3>
+()
+{
+    static char const* const geoms[] = {
+        "GEOMETRYCOLLECTION (POLYGON ((0 0, 0 90, 90 90, 90 0, 0 0)),   POLYGON ((120 0, 120 90, 210 90, 210 0, 120 0)),  LINESTRING (40 50, 40 140),  LINESTRING (160 50, 160 140),  POINT (60 50),  POINT (60 140),  POINT (40 140))",
+        nullptr
+    };
+    doTest(geoms,
+           "GEOMETRYCOLLECTION (POINT (60 140),   LINESTRING (40 90, 40 140), LINESTRING (160 90, 160 140), POLYGON ((0 0, 0 90, 40 90, 90 90, 90 0, 0 0)), POLYGON ((120 0, 120 90, 160 90, 210 90, 210 0, 120 0)))");
+}
+
+template<>
+template<>
+void object::test<4>
+()
+{
+    static char const* const geoms[] = {
+        "POLYGON ((0 0, 10 0, 10 10, 0 10, 0 0))",
+        "MULTIPOLYGON (((20 0, 20 10, 40 10, 40 0, 20 0)),((5 5, 5 8, 8 8, 8 5, 5 5)))",
+        "POINT (5 5)",
+        "POINT (-5 5)",
+        "LINESTRING (-10 -10, -10 0, -10 20)",
+        "LINESTRING (-10 2, 10 2)",
+        nullptr
+    };
+    doTest(geoms,
+           "GEOMETRYCOLLECTION (POLYGON ((0 0, 0 2, 0 10, 10 10, 10 2, 10 0, 0 0)), POLYGON ((20 0, 20 10, 40 10, 40 0, 20 0)), LINESTRING (-10 -10, -10 0, -10 2), LINESTRING (-10 2, 0 2), LINESTRING (-10 2, -10 20), POINT (-5 5))");
 
-    }
+}
 
-    template<>
-    template<>
-    void object::test<5>()
-    {
-        static char const* const geoms[] =
-        {
-            "LINESTRING (40 60, 120 110)",
-            "POINT (120 110)",
-            "POINT (40 60)",
-            "POINT (100 70)",
-            "POINT (80 50)",
-            nullptr
-        };
-        doTest(geoms, "GEOMETRYCOLLECTION (POINT (80 50), POINT (100 70), LINESTRING (40 60, 120 110))");
-    }
+template<>
+template<>
+void object::test<5>
+()
+{
+    static char const* const geoms[] = {
+        "LINESTRING (40 60, 120 110)",
+        "POINT (120 110)",
+        "POINT (40 60)",
+        "POINT (100 70)",
+        "POINT (80 50)",
+        nullptr
+    };
+    doTest(geoms, "GEOMETRYCOLLECTION (POINT (80 50), POINT (100 70), LINESTRING (40 60, 120 110))");
+}
 
-    template<>
-    template<>
-    void object::test<6>()
-    {
-        static char const* const geoms[] =
-        {
-            "LINESTRING (0 0, 10 0, 5 -5, 5 5)",
-            nullptr
-        };
-        doTest(geoms, "MULTILINESTRING ((0 0, 5 0), (5 0, 10 0, 5 -5, 5 0), (5 0, 5 5))");
-    }
+template<>
+template<>
+void object::test<6>
+()
+{
+    static char const* const geoms[] = {
+        "LINESTRING (0 0, 10 0, 5 -5, 5 5)",
+        nullptr
+    };
+    doTest(geoms, "MULTILINESTRING ((0 0, 5 0), (5 0, 10 0, 5 -5, 5 0), (5 0, 5 5))");
+}
 
-    template<>
-    template<>
-    void object::test<7>()
-    {
-        static char const* const geoms[] =
-        {
-            "LINESTRING EMPTY",
-            nullptr
-        };
-        doTest(geoms, "GEOMETRYCOLLECTION EMPTY");
-    }
+template<>
+template<>
+void object::test<7>
+()
+{
+    static char const* const geoms[] = {
+        "LINESTRING EMPTY",
+        nullptr
+    };
+    doTest(geoms, "GEOMETRYCOLLECTION EMPTY");
+}
 
 } // namespace tut
 
diff --git a/tests/unit/operation/valid/IsValidTest.cpp b/tests/unit/operation/valid/IsValidTest.cpp
index 18d3cee..e366eea 100644
--- a/tests/unit/operation/valid/IsValidTest.cpp
+++ b/tests/unit/operation/valid/IsValidTest.cpp
@@ -24,58 +24,57 @@ using namespace geos::geom;
 //using namespace geos::operation;
 using namespace geos::operation::valid;
 
-namespace tut
-{
-    //
-    // Test Group
-    //
+namespace tut {
+//
+// Test Group
+//
 
-    struct test_isvalidop_data
-    {
-	typedef std::unique_ptr<Geometry> GeomPtr;
-        typedef geos::geom::GeometryFactory GeometryFactory;
+struct test_isvalidop_data {
+    typedef std::unique_ptr<Geometry> GeomPtr;
+    typedef geos::geom::GeometryFactory GeometryFactory;
 
-        geos::geom::PrecisionModel pm_;
-        GeometryFactory::Ptr factory_;
+    geos::geom::PrecisionModel pm_;
+    GeometryFactory::Ptr factory_;
 
-        test_isvalidop_data()
-			: pm_(1), factory_(GeometryFactory::create(&pm_, 0))
-        {}
-    };
+    test_isvalidop_data()
+        : pm_(1), factory_(GeometryFactory::create(&pm_, 0))
+    {}
+};
 
-    typedef test_group<test_isvalidop_data> group;
-    typedef group::object object;
+typedef test_group<test_isvalidop_data> group;
+typedef group::object object;
 
-    group test_isvalidop_group("geos::operation::valid::IsValidOp");
+group test_isvalidop_group("geos::operation::valid::IsValidOp");
 
-    //
-    // Test Cases
-    //
+//
+// Test Cases
+//
 
-    // 1 - testInvalidCoordinate
-    template<>
-    template<>
-    void object::test<1>()
-    {
-	CoordinateSequence* cs = new CoordinateArraySequence();
-	cs->add(Coordinate(0.0, 0.0));
-	cs->add(Coordinate(1.0, geos::DoubleNotANumber));
-	GeomPtr line ( factory_->createLineString(cs) );
+// 1 - testInvalidCoordinate
+template<>
+template<>
+void object::test<1>
+()
+{
+    CoordinateSequence* cs = new CoordinateArraySequence();
+    cs->add(Coordinate(0.0, 0.0));
+    cs->add(Coordinate(1.0, geos::DoubleNotANumber));
+    GeomPtr line(factory_->createLineString(cs));
 
 
-	IsValidOp isValidOp(line.get());
-	bool valid = isValidOp.isValid();
+    IsValidOp isValidOp(line.get());
+    bool valid = isValidOp.isValid();
 
-	TopologyValidationError* err = isValidOp.getValidationError();
+    TopologyValidationError* err = isValidOp.getValidationError();
     ensure(nullptr != err);
     const Coordinate& errCoord = err->getCoordinate();
 
-	ensure_equals( err->getErrorType(),
-	               TopologyValidationError::eInvalidCoordinate );
+    ensure_equals(err->getErrorType(),
+                  TopologyValidationError::eInvalidCoordinate);
 
-	ensure(0 != std::isnan(errCoord.y));
-	ensure_equals(valid, false);
-    }
+    ensure(0 != std::isnan(errCoord.y));
+    ensure_equals(valid, false);
+}
 
 
 } // namespace tut
diff --git a/tests/unit/operation/valid/ValidClosedRingTest.cpp b/tests/unit/operation/valid/ValidClosedRingTest.cpp
index 314a2ff..165f818 100644
--- a/tests/unit/operation/valid/ValidClosedRingTest.cpp
+++ b/tests/unit/operation/valid/ValidClosedRingTest.cpp
@@ -29,137 +29,143 @@ using namespace geos::operation::valid;
 using namespace geos::util;
 using namespace std;
 
-namespace tut
-{
-    //
-    // Test Group
-    //
+namespace tut {
+//
+// Test Group
+//
 
-    struct test_validclosedring_data
-    {
-	typedef std::unique_ptr<Geometry> GeomPtr;
-        typedef geos::geom::GeometryFactory GeometryFactory;
-
-        geos::geom::PrecisionModel pm_;
-        GeometryFactory::Ptr factory_;
-        geos::io::WKTReader rdr;
-
-        test_validclosedring_data()
-			: pm_(1)
-      , factory_(GeometryFactory::create(&pm_, 0))
-      , rdr(factory_.get())
-        {}
-
-	GeomPtr fromWKT(const std::string& wkt)
-	{
-		GeomPtr geom;
-		try {
-			geom.reset( rdr.read(wkt) );
-		}
-		catch (const GEOSException& ex) {
-			cerr << ex.what() << endl;
-		}
-		return geom;
-	}
-
-        void updateNonClosedRing(LinearRing& ring)
-	{
-		CoordinateSequence& pts = *(const_cast<CoordinateSequence*>(
-			ring.getCoordinatesRO()
-					    ));
-		Coordinate c = pts[0];
-		c.x += 0.0001;
-		pts.setAt(c, 0);
-	}
-
-	void checkIsValid(Geometry& geom, bool expected)
-	{
-		IsValidOp validator(&geom);
-		bool isValid = validator.isValid();
-		ensure_equals(isValid, expected);
-	}
-
-    };
-
-    typedef test_group<test_validclosedring_data> group;
-    typedef group::object object;
-
-    group test_validclosedring_group("geos::operation::valid::ValidClosedRing");
-
-    //
-    // Test Cases
-    //
-
-    // 1 - testBadLinearRing
-    template<>
-    template<>
-    void object::test<1>()
+struct test_validclosedring_data {
+    typedef std::unique_ptr<Geometry> GeomPtr;
+    typedef geos::geom::GeometryFactory GeometryFactory;
+
+    geos::geom::PrecisionModel pm_;
+    GeometryFactory::Ptr factory_;
+    geos::io::WKTReader rdr;
+
+    test_validclosedring_data()
+        : pm_(1)
+        , factory_(GeometryFactory::create(&pm_, 0))
+        , rdr(factory_.get())
+    {}
+
+    GeomPtr
+    fromWKT(const std::string& wkt)
     {
-	GeomPtr geom = fromWKT("LINEARRING (0 0, 0 10, 10 10, 10 0, 0 0)");
-	LinearRing* ring_chk = dynamic_cast<LinearRing*>(geom.get());
-	ensure(nullptr != ring_chk);
-	LinearRing& ring = *ring_chk;
-	//cout << ring.toString() << endl;
-	updateNonClosedRing(ring);
-	//cout << ring.toString() << endl;
-	checkIsValid(*geom, false);
+        GeomPtr geom;
+        try {
+            geom.reset(rdr.read(wkt));
+        }
+        catch(const GEOSException& ex) {
+            cerr << ex.what() << endl;
+        }
+        return geom;
     }
 
-    // 2 - testGoodLinearRing
-    template<>
-    template<>
-    void object::test<2>()
+    void
+    updateNonClosedRing(LinearRing& ring)
     {
-	GeomPtr geom = fromWKT("LINEARRING (0 0, 0 10, 10 10, 10 0, 0 0)");
-	checkIsValid(*geom, true);
+        CoordinateSequence& pts = *(const_cast<CoordinateSequence*>(
+                                        ring.getCoordinatesRO()
+                                    ));
+        Coordinate c = pts[0];
+        c.x += 0.0001;
+        pts.setAt(c, 0);
     }
 
-    // 3 - testBadPolygonShell
-    template<>
-    template<>
-    void object::test<3>()
+    void
+    checkIsValid(Geometry& geom, bool expected)
     {
-	GeomPtr geom = fromWKT("POLYGON ((0 0, 0 10, 10 10, 10 0, 0 0), (1 1, 2 1, 2 2, 1 2, 1 1) ))");
-	Polygon* poly = dynamic_cast<Polygon*>(geom.get());
-	ensure(nullptr != poly);
-	const LineString* ring = poly->getExteriorRing();
+        IsValidOp validator(&geom);
+        bool isValid = validator.isValid();
+        ensure_equals(isValid, expected);
+    }
 
-	const LinearRing* lr = dynamic_cast<const LinearRing*>(ring);
-	ensure(nullptr != lr);
+};
 
-	LinearRing* nclr = const_cast<LinearRing*>(lr);
+typedef test_group<test_validclosedring_data> group;
+typedef group::object object;
 
-	updateNonClosedRing(*nclr);
-	checkIsValid(*geom, false);
-    }
+group test_validclosedring_group("geos::operation::valid::ValidClosedRing");
 
-    // 4 - testBadPolygonHole
-    template<>
-    template<>
-    void object::test<4>()
-    {
-	GeomPtr geom = fromWKT("POLYGON ((0 0, 0 10, 10 10, 10 0, 0 0), (1 1, 2 1, 2 2, 1 2, 1 1) ))");
-	Polygon* poly = dynamic_cast<Polygon*>(geom.get());
-	ensure(nullptr != poly);
-	const LineString* ring = poly->getInteriorRingN(0);
+//
+// Test Cases
+//
 
-	const LinearRing* lr = dynamic_cast<const LinearRing*>(ring);
-	ensure(nullptr != lr);
+// 1 - testBadLinearRing
+template<>
+template<>
+void object::test<1>
+()
+{
+    GeomPtr geom = fromWKT("LINEARRING (0 0, 0 10, 10 10, 10 0, 0 0)");
+    LinearRing* ring_chk = dynamic_cast<LinearRing*>(geom.get());
+    ensure(nullptr != ring_chk);
+    LinearRing& ring = *ring_chk;
+    //cout << ring.toString() << endl;
+    updateNonClosedRing(ring);
+    //cout << ring.toString() << endl;
+    checkIsValid(*geom, false);
+}
+
+// 2 - testGoodLinearRing
+template<>
+template<>
+void object::test<2>
+()
+{
+    GeomPtr geom = fromWKT("LINEARRING (0 0, 0 10, 10 10, 10 0, 0 0)");
+    checkIsValid(*geom, true);
+}
+
+// 3 - testBadPolygonShell
+template<>
+template<>
+void object::test<3>
+()
+{
+    GeomPtr geom = fromWKT("POLYGON ((0 0, 0 10, 10 10, 10 0, 0 0), (1 1, 2 1, 2 2, 1 2, 1 1) ))");
+    Polygon* poly = dynamic_cast<Polygon*>(geom.get());
+    ensure(nullptr != poly);
+    const LineString* ring = poly->getExteriorRing();
 
-	LinearRing* nclr = const_cast<LinearRing*>(lr);
+    const LinearRing* lr = dynamic_cast<const LinearRing*>(ring);
+    ensure(nullptr != lr);
 
-	updateNonClosedRing(*nclr);
-	checkIsValid(*geom, false);
-    }
+    LinearRing* nclr = const_cast<LinearRing*>(lr);
 
-    // 5 - testGoodPolygon
-    template<>
-    template<>
-    void object::test<5>()
-    {
-	GeomPtr geom = fromWKT("POLYGON ((0 0, 0 10, 10 10, 10 0, 0 0))");
-	checkIsValid(*geom, true);
-    }
+    updateNonClosedRing(*nclr);
+    checkIsValid(*geom, false);
+}
+
+// 4 - testBadPolygonHole
+template<>
+template<>
+void object::test<4>
+()
+{
+    GeomPtr geom = fromWKT("POLYGON ((0 0, 0 10, 10 10, 10 0, 0 0), (1 1, 2 1, 2 2, 1 2, 1 1) ))");
+    Polygon* poly = dynamic_cast<Polygon*>(geom.get());
+    ensure(nullptr != poly);
+    const LineString* ring = poly->getInteriorRingN(0);
+
+    const LinearRing* lr = dynamic_cast<const LinearRing*>(ring);
+    ensure(nullptr != lr);
+
+    LinearRing* nclr = const_cast<LinearRing*>(lr);
+
+    updateNonClosedRing(*nclr);
+    checkIsValid(*geom, false);
+}
+
+// 5 - testGoodPolygon
+template<>
+template<>
+void object::test<5>
+()
+{
+    GeomPtr geom = fromWKT("POLYGON ((0 0, 0 10, 10 10, 10 0, 0 0))");
+    checkIsValid(*geom, true);
+}
 
 
 } // namespace tut
diff --git a/tests/unit/operation/valid/ValidSelfTouchingRingFormingHoleTest.cpp b/tests/unit/operation/valid/ValidSelfTouchingRingFormingHoleTest.cpp
index 122ffaf..8bb1f40 100644
--- a/tests/unit/operation/valid/ValidSelfTouchingRingFormingHoleTest.cpp
+++ b/tests/unit/operation/valid/ValidSelfTouchingRingFormingHoleTest.cpp
@@ -29,161 +29,172 @@ using namespace geos::operation::valid;
 using namespace geos::util;
 using namespace std;
 
-namespace tut
-{
-    //
-    // Test Group
-    //
+namespace tut {
+//
+// Test Group
+//
 
-    struct test_ValidSelfTouchingRingFormingHole_data
-    {
-	typedef std::unique_ptr<Geometry> GeomPtr;
-
-        geos::geom::PrecisionModel pm_;
-        typedef geos::geom::GeometryFactory GeometryFactory;
-        geos::geom::GeometryFactory::Ptr factory_;
-        geos::io::WKTReader rdr;
-
-        test_ValidSelfTouchingRingFormingHole_data()
-      : pm_(1)
-      , factory_(GeometryFactory::create(&pm_, 0))
-      , rdr(factory_.get())
-        {}
-
-	GeomPtr fromWKT(const std::string& wkt)
-	{
-		GeomPtr geom;
-		try {
-			geom.reset( rdr.read(wkt) );
-		}
-		catch (const GEOSException& ex) {
-			cerr << ex.what() << endl;
-		}
-		return geom;
-	}
-
-	void checkIsValidDefault(const std::string& wkt, bool expected)
-	{
-		GeomPtr geom = fromWKT(wkt);
-		IsValidOp validator(geom.get());
-		bool isValid = validator.isValid();
-		ensure(isValid == expected);
-	}
-
-	void checkIsValidSTR(const std::string& wkt, bool expected)
-	{
-		GeomPtr geom = fromWKT(wkt);
-		IsValidOp validator(geom.get());
-		validator.setSelfTouchingRingFormingHoleValid(true);
-		bool isValid = validator.isValid();
-		ensure(isValid == expected);
-	}
-
-    };
-
-    typedef test_group<test_ValidSelfTouchingRingFormingHole_data> group;
-    typedef group::object object;
-
-    group test_ValidSelfTouchingRingFormingHole_group("geos::operation::valid::ValidSelfTouchingRingFormingHole");
-
-    //
-    // Test Cases
-    //
-
-    // 1 - testShellAndHoleSelfTouch
-    //
-    //  Tests a geometry with both a shell self-touch and a hole self=touch.
-    //  This is valid if STR is allowed, but invalid in OGC
-    //
-    template<>
-    template<>
-    void object::test<1>()
+struct test_ValidSelfTouchingRingFormingHole_data {
+    typedef std::unique_ptr<Geometry> GeomPtr;
+
+    geos::geom::PrecisionModel pm_;
+    typedef geos::geom::GeometryFactory GeometryFactory;
+    geos::geom::GeometryFactory::Ptr factory_;
+    geos::io::WKTReader rdr;
+
+    test_ValidSelfTouchingRingFormingHole_data()
+        : pm_(1)
+        , factory_(GeometryFactory::create(&pm_, 0))
+        , rdr(factory_.get())
+    {}
+
+    GeomPtr
+    fromWKT(const std::string& wkt)
     {
-    string wkt = "POLYGON ((0 0, 0 340, 320 340, 320 0, 120 0, 180 100, 60 100, 120 0, 0 0),   (80 300, 80 180, 200 180, 200 240, 280 200, 280 280, 200 240, 200 300, 80 300))";
-    checkIsValidSTR(wkt, true);
-    checkIsValidDefault(wkt, false);
+        GeomPtr geom;
+        try {
+            geom.reset(rdr.read(wkt));
+        }
+        catch(const GEOSException& ex) {
+            cerr << ex.what() << endl;
+        }
+        return geom;
     }
 
-  /*
-   * 2 - testShellHoleAndHoleHoleTouch
-   *
-   * Tests a geometry representing the same area as in
-   * {@link #testShellAndHoleSelfTouch}
-   * but using a shell-hole touch and a hole-hole touch.
-   * This is valid in OGC.
-   */
-    template<>
-    template<>
-    void object::test<2>()
+    void
+    checkIsValidDefault(const std::string& wkt, bool expected)
     {
-    string wkt = "POLYGON ((0 0, 0 340, 320 340, 320 0, 120 0, 0 0),   (120 0, 180 100, 60 100, 120 0),   (80 300, 80 180, 200 180, 200 240, 200 300, 80 300),  (200 240, 280 200, 280 280, 200 240))";
-    checkIsValidSTR(wkt, true);
-    checkIsValidDefault(wkt, true);
+        GeomPtr geom = fromWKT(wkt);
+        IsValidOp validator(geom.get());
+        bool isValid = validator.isValid();
+        ensure(isValid == expected);
     }
 
-  /*
-   * 3 - testShellSelfTouchHoleOverlappingHole
-   *
-   * Tests an overlapping hole condition, where one of the holes is
-   * created by a shell self-touch.
-   * This is never valid.
-   */
-    template<>
-    template<>
-    void object::test<3>()
+    void
+    checkIsValidSTR(const std::string& wkt, bool expected)
     {
-    string wkt = "POLYGON ((0 0, 220 0, 220 200, 120 200, 140 100, 80 100, 120 200, 0 200, 0 0),   (200 80, 20 80, 120 200, 200 80))";
-    checkIsValidSTR(wkt, false);
-    checkIsValidDefault(wkt, false);
+        GeomPtr geom = fromWKT(wkt);
+        IsValidOp validator(geom.get());
+        validator.setSelfTouchingRingFormingHoleValid(true);
+        bool isValid = validator.isValid();
+        ensure(isValid == expected);
     }
 
-  /*
-   * 4 - testDisconnectedInteriorShellSelfTouchAtNonVertex
-   *
-   * Ensure that the Disconnected Interior condition is not validated
-   */
-    template<>
-    template<>
-    void object::test<4>()
-    {
+};
+
+typedef test_group<test_ValidSelfTouchingRingFormingHole_data> group;
+typedef group::object object;
+
+group test_ValidSelfTouchingRingFormingHole_group("geos::operation::valid::ValidSelfTouchingRingFormingHole");
+
+//
+// Test Cases
+//
+
+// 1 - testShellAndHoleSelfTouch
+//
+//  Tests a geometry with both a shell self-touch and a hole self=touch.
+//  This is valid if STR is allowed, but invalid in OGC
+//
+template<>
+template<>
+void object::test<1>
+()
+{
+    string wkt =
+        "POLYGON ((0 0, 0 340, 320 340, 320 0, 120 0, 180 100, 60 100, 120 0, 0 0),   (80 300, 80 180, 200 180, 200 240, 280 200, 280 280, 200 240, 200 300, 80 300))";
+    checkIsValidSTR(wkt, true);
+    checkIsValidDefault(wkt, false);
+}
+
+/*
+ * 2 - testShellHoleAndHoleHoleTouch
+ *
+ * Tests a geometry representing the same area as in
+ * {@link #testShellAndHoleSelfTouch}
+ * but using a shell-hole touch and a hole-hole touch.
+ * This is valid in OGC.
+ */
+template<>
+template<>
+void object::test<2>
+()
+{
+    string wkt =
+        "POLYGON ((0 0, 0 340, 320 340, 320 0, 120 0, 0 0),   (120 0, 180 100, 60 100, 120 0),   (80 300, 80 180, 200 180, 200 240, 200 300, 80 300),  (200 240, 280 200, 280 280, 200 240))";
+    checkIsValidSTR(wkt, true);
+    checkIsValidDefault(wkt, true);
+}
+
+/*
+ * 3 - testShellSelfTouchHoleOverlappingHole
+ *
+ * Tests an overlapping hole condition, where one of the holes is
+ * created by a shell self-touch.
+ * This is never valid.
+ */
+template<>
+template<>
+void object::test<3>
+()
+{
+    string wkt =
+        "POLYGON ((0 0, 220 0, 220 200, 120 200, 140 100, 80 100, 120 200, 0 200, 0 0),   (200 80, 20 80, 120 200, 200 80))";
+    checkIsValidSTR(wkt, false);
+    checkIsValidDefault(wkt, false);
+}
+
+/*
+ * 4 - testDisconnectedInteriorShellSelfTouchAtNonVertex
+ *
+ * Ensure that the Disconnected Interior condition is not validated
+ */
+template<>
+template<>
+void object::test<4>
+()
+{
     string wkt = "POLYGON ((40 180, 40 60, 240 60, 240 180, 140 60, 40 180))";
     checkIsValidSTR(wkt, false);
     checkIsValidDefault(wkt, false);
-    }
-
-  /*
-   * 5 - testDisconnectedInteriorShellSelfTouchAtVertex
-   *
-   * Ensure that the Disconnected Interior condition is not validated
-   */
-    template<>
-    template<>
-    void object::test<5>()
-    {
+}
+
+/*
+ * 5 - testDisconnectedInteriorShellSelfTouchAtVertex
+ *
+ * Ensure that the Disconnected Interior condition is not validated
+ */
+template<>
+template<>
+void object::test<5>
+()
+{
     string wkt = "POLYGON ((20 20, 20 100, 140 100, 140 180, 260 180, 260 100, 140 100, 140 20, 20 20))";
     checkIsValidSTR(wkt, false);
     checkIsValidDefault(wkt, false);
-    }
+}
 
-    /// 6 - testShellCross()
-    template<>
-    template<>
-    void object::test<6>()
-    {
+/// 6 - testShellCross()
+template<>
+template<>
+void object::test<6>
+()
+{
     string wkt = "POLYGON ((20 20, 120 20, 120 220, 240 220, 240 120, 20 120, 20 20))";
     checkIsValidSTR(wkt, false);
     checkIsValidDefault(wkt, false);
-    }
+}
 
-    /// 7 - testShellCrossAndSTR
-    template<>
-    template<>
-    void object::test<7>()
-    {
+/// 7 - testShellCrossAndSTR
+template<>
+template<>
+void object::test<7>
+()
+{
     string wkt = "POLYGON ((20 20, 120 20, 120 220, 180 220, 140 160, 200 160, 180 220, 240 220, 240 120, 20 120,  20 20))";
     checkIsValidSTR(wkt, false);
     checkIsValidDefault(wkt, false);
-    }
+}
 
 
 
diff --git a/tests/unit/precision/CommonBitsTest.cpp b/tests/unit/precision/CommonBitsTest.cpp
index 14fb1ef..02e36df 100644
--- a/tests/unit/precision/CommonBitsTest.cpp
+++ b/tests/unit/precision/CommonBitsTest.cpp
@@ -9,48 +9,48 @@
 
 using geos::precision::CommonBits;
 
-namespace tut
+namespace tut {
+// Common data used by tests
+struct test_commonbits_data {};
+
+typedef test_group<test_commonbits_data> group;
+typedef group::object object;
+
+group test_commonbits_group("geos::precision::CommonBits");
+
+// getBit from zero.
+template<>
+template<>
+void object::test<1>
+()
 {
-    // Common data used by tests
-    struct test_commonbits_data {};
-
-    typedef test_group<test_commonbits_data> group;
-    typedef group::object object;
-
-    group test_commonbits_group("geos::precision::CommonBits");
-
-    // getBit from zero.
-    template<>
-    template<>
-    void object::test<1>()
-    {
-        constexpr int64 val = 0ull;
-        for (int i=0; i < 64; i++)
-        {
-            ensure_equals(CommonBits::getBit(val, i), 0);
-        }
+    constexpr int64 val = 0ull;
+    for(int i = 0; i < 64; i++) {
+        ensure_equals(CommonBits::getBit(val, i), 0);
     }
+}
 
-    // getBit from all ones.
-    template<>
-    template<>
-    void object::test<2>()
-    {
-        constexpr int64 val = 0xffffffffffffffffull;
-        for (int i=0; i < 64; i++)
-        {
-            ensure_equals(CommonBits::getBit(val, i), 1);
-        }
+// getBit from all ones.
+template<>
+template<>
+void object::test<2>
+()
+{
+    constexpr int64 val = 0xffffffffffffffffull;
+    for(int i = 0; i < 64; i++) {
+        ensure_equals(CommonBits::getBit(val, i), 1);
     }
+}
 
-    // getBit check high versus low bits.
-    template<>
-    template<>
-    void object::test<3>()
-    {
-        constexpr int64 val = 0xffffffff00000000ull;
-        ensure_equals(CommonBits::getBit(val, 0), 0);
-        ensure_equals(CommonBits::getBit(val, 63), 1);
-    }
+// getBit check high versus low bits.
+template<>
+template<>
+void object::test<3>
+()
+{
+    constexpr int64 val = 0xffffffff00000000ull;
+    ensure_equals(CommonBits::getBit(val, 0), 0);
+    ensure_equals(CommonBits::getBit(val, 63), 1);
+}
 
 } // namespace tut
diff --git a/tests/unit/precision/GeometryPrecisionReducerTest.cpp b/tests/unit/precision/GeometryPrecisionReducerTest.cpp
index b4a40f2..f82446e 100644
--- a/tests/unit/precision/GeometryPrecisionReducerTest.cpp
+++ b/tests/unit/precision/GeometryPrecisionReducerTest.cpp
@@ -15,179 +15,186 @@
 #include <vector>
 #include <iostream>
 
-namespace tut
-{
-    //
-    // Test Group
-    //
+namespace tut {
+//
+// Test Group
+//
 
-    // Common data used by tests
-    struct test_gpr_data
+// Common data used by tests
+struct test_gpr_data {
+    typedef std::unique_ptr<geos::geom::Geometry> GeometryPtr;
+    typedef geos::geom::GeometryFactory GeometryFactory;
+
+    geos::geom::PrecisionModel pm_float_;
+    geos::geom::PrecisionModel pm_fixed_;
+    GeometryFactory::Ptr factory_;
+    GeometryFactory::Ptr factory_fixed_;
+    geos::io::WKTReader reader_;
+    geos::precision::GeometryPrecisionReducer reducer_;
+    geos::precision::GeometryPrecisionReducer reducerKeepCollapse_; // keep collapse
+    geos::precision::GeometryPrecisionReducer reducerChangePM_; // change precision model
+
+    test_gpr_data() :
+        pm_float_(),
+        pm_fixed_(1),
+        factory_(GeometryFactory::create(&pm_float_, 0)),
+        factory_fixed_(GeometryFactory::create(&pm_fixed_, 0)),
+        reader_(factory_.get()),
+        reducer_(pm_fixed_),
+        reducerKeepCollapse_(pm_fixed_),
+        reducerChangePM_(*factory_fixed_)
     {
-        typedef std::unique_ptr<geos::geom::Geometry> GeometryPtr;
-        typedef geos::geom::GeometryFactory GeometryFactory;
-
-        geos::geom::PrecisionModel pm_float_;
-        geos::geom::PrecisionModel pm_fixed_;
-        GeometryFactory::Ptr factory_;
-        GeometryFactory::Ptr factory_fixed_;
-        geos::io::WKTReader reader_;
-        geos::precision::GeometryPrecisionReducer reducer_;
-        geos::precision::GeometryPrecisionReducer reducerKeepCollapse_; // keep collapse
-        geos::precision::GeometryPrecisionReducer reducerChangePM_; // change precision model
-
-        test_gpr_data() :
-            pm_float_(),
-            pm_fixed_(1),
-            factory_(GeometryFactory::create(&pm_float_, 0)),
-            factory_fixed_(GeometryFactory::create(&pm_fixed_, 0)),
-            reader_(factory_.get()),
-            reducer_(pm_fixed_),
-            reducerKeepCollapse_(pm_fixed_),
-            reducerChangePM_(*factory_fixed_)
-        {
-            reducerKeepCollapse_.setRemoveCollapsedComponents(false);
-        }
+        reducerKeepCollapse_.setRemoveCollapsedComponents(false);
+    }
 };
 
-    typedef test_group<test_gpr_data> group;
-    typedef group::object object;
-
-    group test_gpr_group("geos::precision::GeometryPrecisionReducer");
+typedef test_group<test_gpr_data> group;
+typedef group::object object;
 
-    //
-    // Test Cases
-    //
+group test_gpr_group("geos::precision::GeometryPrecisionReducer");
 
-    // Test square
-    template<>
-    template<>
-    void object::test<1>()
-    {
-        GeometryPtr g1(reader_.read("POLYGON (( 0 0, 0 1.4, 1.4 1.4, 1.4 0, 0 0 ))"));
-        GeometryPtr g2(reader_.read("POLYGON (( 0 0, 0 1, 1 1, 1 0, 0 0 ))"));
-
-        GeometryPtr result(reducer_.reduce(*g1));
-
-        ensure( result->equalsExact(g2.get()) );
-        ensure( result->getFactory() == g2->getFactory() );
-    }
+//
+// Test Cases
+//
 
-    // Test tiny square collapse
-    template<>
-    template<>
-    void object::test<2>()
-    {
-        GeometryPtr g1(reader_.read("POLYGON (( 0 0, 0 .4, .4 .4, .4 0, 0 0 ))"));
-        GeometryPtr g2(reader_.read("POLYGON EMPTY"));
+// Test square
+template<>
+template<>
+void object::test<1>
+()
+{
+    GeometryPtr g1(reader_.read("POLYGON (( 0 0, 0 1.4, 1.4 1.4, 1.4 0, 0 0 ))"));
+    GeometryPtr g2(reader_.read("POLYGON (( 0 0, 0 1, 1 1, 1 0, 0 0 ))"));
 
-        GeometryPtr result(reducer_.reduce(*g1));
+    GeometryPtr result(reducer_.reduce(*g1));
 
-        ensure( result->equalsExact(g2.get()) );
-        ensure( result->getFactory() == g2->getFactory() );
-    }
+    ensure(result->equalsExact(g2.get()));
+    ensure(result->getFactory() == g2->getFactory());
+}
 
-    // Test square collapse
-    template<>
-    template<>
-    void object::test<3>()
-    {
-        GeometryPtr g1(reader_.read("POLYGON (( 0 0, 0 1.4, .4 .4, .4 0, 0 0 ))"));
-        GeometryPtr g2(reader_.read("POLYGON EMPTY"));
+// Test tiny square collapse
+template<>
+template<>
+void object::test<2>
+()
+{
+    GeometryPtr g1(reader_.read("POLYGON (( 0 0, 0 .4, .4 .4, .4 0, 0 0 ))"));
+    GeometryPtr g2(reader_.read("POLYGON EMPTY"));
 
-        GeometryPtr result(reducer_.reduce(*g1));
+    GeometryPtr result(reducer_.reduce(*g1));
 
-        ensure( result->equalsExact(g2.get()) );
-        ensure( result->getFactory() == g2->getFactory() );
-    }
+    ensure(result->equalsExact(g2.get()));
+    ensure(result->getFactory() == g2->getFactory());
+}
 
-    // Test square keep collapse
-    template<>
-    template<>
-    void object::test<4>()
-    {
-        GeometryPtr g1(reader_.read("POLYGON (( 0 0, 0 1.4, .4 .4, .4 0, 0 0 ))"));
-        /**
-         * For polygonal geometries, collapses are always removed, in order
-         * to produce correct topology
-         */
-        GeometryPtr g2(reader_.read("POLYGON EMPTY"));
+// Test square collapse
+template<>
+template<>
+void object::test<3>
+()
+{
+    GeometryPtr g1(reader_.read("POLYGON (( 0 0, 0 1.4, .4 .4, .4 0, 0 0 ))"));
+    GeometryPtr g2(reader_.read("POLYGON EMPTY"));
 
-        GeometryPtr result(reducerKeepCollapse_.reduce(*g1));
+    GeometryPtr result(reducer_.reduce(*g1));
 
-        ensure( result->equalsExact(g2.get()) );
-        ensure( result->getFactory() == g2->getFactory() );
-    }
+    ensure(result->equalsExact(g2.get()));
+    ensure(result->getFactory() == g2->getFactory());
+}
 
-    // Test line
-    template<>
-    template<>
-    void object::test<5>()
-    {
-        GeometryPtr g1(reader_.read("LINESTRING ( 0 0, 0 1.4 )"));
-        GeometryPtr g2(reader_.read("LINESTRING (0 0, 0 1)"));
+// Test square keep collapse
+template<>
+template<>
+void object::test<4>
+()
+{
+    GeometryPtr g1(reader_.read("POLYGON (( 0 0, 0 1.4, .4 .4, .4 0, 0 0 ))"));
+    /**
+     * For polygonal geometries, collapses are always removed, in order
+     * to produce correct topology
+     */
+    GeometryPtr g2(reader_.read("POLYGON EMPTY"));
+
+    GeometryPtr result(reducerKeepCollapse_.reduce(*g1));
+
+    ensure(result->equalsExact(g2.get()));
+    ensure(result->getFactory() == g2->getFactory());
+}
+
+// Test line
+template<>
+template<>
+void object::test<5>
+()
+{
+    GeometryPtr g1(reader_.read("LINESTRING ( 0 0, 0 1.4 )"));
+    GeometryPtr g2(reader_.read("LINESTRING (0 0, 0 1)"));
 
-        GeometryPtr result(reducer_.reduce(*g1));
+    GeometryPtr result(reducer_.reduce(*g1));
 
-        ensure( result->equalsExact(g2.get()) );
-        ensure( result->getFactory() == g2->getFactory() );
-    }
+    ensure(result->equalsExact(g2.get()));
+    ensure(result->getFactory() == g2->getFactory());
+}
 
-    // Test line remove collapse
-    template<>
-    template<>
-    void object::test<6>()
-    {
-        GeometryPtr g1(reader_.read("LINESTRING ( 0 0, 0 .4 )"));
-        GeometryPtr g2(reader_.read("LINESTRING EMPTY"));
+// Test line remove collapse
+template<>
+template<>
+void object::test<6>
+()
+{
+    GeometryPtr g1(reader_.read("LINESTRING ( 0 0, 0 .4 )"));
+    GeometryPtr g2(reader_.read("LINESTRING EMPTY"));
 
-        GeometryPtr result(reducer_.reduce(*g1));
+    GeometryPtr result(reducer_.reduce(*g1));
 
-        ensure( result->equalsExact(g2.get()) );
-        ensure( result->getFactory() == g2->getFactory() );
-    }
+    ensure(result->equalsExact(g2.get()));
+    ensure(result->getFactory() == g2->getFactory());
+}
 
-    // Test line keep collapse
-    template<>
-    template<>
-    void object::test<7>()
-    {
-        GeometryPtr g1(reader_.read("LINESTRING ( 0 0, 0 .4 )"));
-        GeometryPtr g2(reader_.read("LINESTRING ( 0 0, 0 0 )"));
+// Test line keep collapse
+template<>
+template<>
+void object::test<7>
+()
+{
+    GeometryPtr g1(reader_.read("LINESTRING ( 0 0, 0 .4 )"));
+    GeometryPtr g2(reader_.read("LINESTRING ( 0 0, 0 0 )"));
 
-        GeometryPtr result(reducerKeepCollapse_.reduce(*g1));
+    GeometryPtr result(reducerKeepCollapse_.reduce(*g1));
 
-        ensure( result->equalsExact(g2.get()) );
-        ensure( result->getFactory() == g2->getFactory() );
-    }
+    ensure(result->equalsExact(g2.get()));
+    ensure(result->getFactory() == g2->getFactory());
+}
 
-    // Test square with changed PM
-    template<>
-    template<>
-    void object::test<8>()
-    {
-        GeometryPtr g1(reader_.read("POLYGON (( 0 0, 0 1.4, 1.4 1.4, 1.4 0, 0 0 ))"));
-        GeometryPtr g2(reader_.read("POLYGON (( 0 0, 0 1, 1 1, 1 0, 0 0 ))"));
+// Test square with changed PM
+template<>
+template<>
+void object::test<8>
+()
+{
+    GeometryPtr g1(reader_.read("POLYGON (( 0 0, 0 1.4, 1.4 1.4, 1.4 0, 0 0 ))"));
+    GeometryPtr g2(reader_.read("POLYGON (( 0 0, 0 1, 1 1, 1 0, 0 0 ))"));
 
-        GeometryPtr result(reducerChangePM_.reduce(*g1));
+    GeometryPtr result(reducerChangePM_.reduce(*g1));
 
-        ensure( result->equalsExact(g2.get()) );
-        ensure( result->getFactory() == factory_fixed_.get() );
-    }
+    ensure(result->equalsExact(g2.get()));
+    ensure(result->getFactory() == factory_fixed_.get());
+}
 
-    // Test points with changed PM
-    template<>
-    template<>
-    void object::test<9>()
-    {
-        GeometryPtr g1(reader_.read("MULTIPOINT ((0 0), (0 1.4), (1.4 1.4), (1.4 0), (0.9 0) ))"));
-        GeometryPtr g2(reader_.read("MULTIPOINT ((0 0), (0 1), (1 1), (1 0), (1 0) ))"));
+// Test points with changed PM
+template<>
+template<>
+void object::test<9>
+()
+{
+    GeometryPtr g1(reader_.read("MULTIPOINT ((0 0), (0 1.4), (1.4 1.4), (1.4 0), (0.9 0) ))"));
+    GeometryPtr g2(reader_.read("MULTIPOINT ((0 0), (0 1), (1 1), (1 0), (1 0) ))"));
 
-        GeometryPtr result(reducerChangePM_.reduce(*g1));
+    GeometryPtr result(reducerChangePM_.reduce(*g1));
 
-        ensure( result->equalsExact(g2.get()) );
-        ensure( result->getFactory() == factory_fixed_.get() );
-    }
+    ensure(result->equalsExact(g2.get()));
+    ensure(result->getFactory() == factory_fixed_.get());
+}
 
 
 } // namespace tut
diff --git a/tests/unit/precision/SimpleGeometryPrecisionReducerTest.cpp b/tests/unit/precision/SimpleGeometryPrecisionReducerTest.cpp
index 051e3d3..aec43a4 100644
--- a/tests/unit/precision/SimpleGeometryPrecisionReducerTest.cpp
+++ b/tests/unit/precision/SimpleGeometryPrecisionReducerTest.cpp
@@ -13,136 +13,141 @@
 #include <string>
 #include <vector>
 
-namespace tut
-{
-    //
-    // Test Group
-    //
+namespace tut {
+//
+// Test Group
+//
 
-    // Common data used by tests
-    struct test_sgpr_data
+// Common data used by tests
+struct test_sgpr_data {
+    typedef std::unique_ptr<geos::geom::Geometry> GeometryPtr;
+    typedef geos::geom::GeometryFactory GeometryFactory;
+
+    geos::geom::PrecisionModel pm_float_;
+    geos::geom::PrecisionModel pm_fixed_;
+    GeometryFactory::Ptr factory_;
+    geos::io::WKTReader reader_;
+    geos::precision::SimpleGeometryPrecisionReducer reducer_;
+    geos::precision::SimpleGeometryPrecisionReducer reducer2_; // keep collapse
+
+    test_sgpr_data() :
+        pm_float_(),
+        pm_fixed_(1),
+        factory_(GeometryFactory::create(&pm_float_, 0)),
+        reader_(factory_.get()),
+        reducer_(&pm_fixed_),
+        reducer2_(&pm_fixed_)
     {
-        typedef std::unique_ptr<geos::geom::Geometry> GeometryPtr;
-        typedef geos::geom::GeometryFactory GeometryFactory;
-
-        geos::geom::PrecisionModel pm_float_;
-        geos::geom::PrecisionModel pm_fixed_;
-        GeometryFactory::Ptr factory_;
-        geos::io::WKTReader reader_;
-        geos::precision::SimpleGeometryPrecisionReducer reducer_;
-        geos::precision::SimpleGeometryPrecisionReducer reducer2_; // keep collapse
-
-        test_sgpr_data() :
-            pm_float_(),
-            pm_fixed_(1),
-            factory_(GeometryFactory::create(&pm_float_, 0)),
-            reader_(factory_.get()),
-            reducer_(&pm_fixed_),
-            reducer2_(&pm_fixed_)
-        {
-            reducer2_.setRemoveCollapsedComponents(false);
-        }
+        reducer2_.setRemoveCollapsedComponents(false);
+    }
 };
 
-    typedef test_group<test_sgpr_data> group;
-    typedef group::object object;
+typedef test_group<test_sgpr_data> group;
+typedef group::object object;
 
-    group test_sgpr_group("geos::precision::SimpleGeometryPrecisionReducer");
+group test_sgpr_group("geos::precision::SimpleGeometryPrecisionReducer");
 
-    //
-    // Test Cases
-    //
+//
+// Test Cases
+//
 
-    // Test square
-    template<>
-    template<>
-    void object::test<1>()
-    {
-        GeometryPtr g1(reader_.read("POLYGON (( 0 0, 0 1.4, 1.4 1.4, 1.4 0, 0 0 ))"));
-        GeometryPtr g2(reader_.read("POLYGON (( 0 0, 0 1, 1 1, 1 0, 0 0 ))"));
+// Test square
+template<>
+template<>
+void object::test<1>
+()
+{
+    GeometryPtr g1(reader_.read("POLYGON (( 0 0, 0 1.4, 1.4 1.4, 1.4 0, 0 0 ))"));
+    GeometryPtr g2(reader_.read("POLYGON (( 0 0, 0 1, 1 1, 1 0, 0 0 ))"));
 
-        GeometryPtr result(reducer_.reduce(g1.get()));
+    GeometryPtr result(reducer_.reduce(g1.get()));
 
-        ensure( result->equalsExact(g2.get()) );
-    }
+    ensure(result->equalsExact(g2.get()));
+}
 
-    // Test tiny square collapse
-    template<>
-    template<>
-    void object::test<2>()
-    {
-        GeometryPtr g1(reader_.read("POLYGON (( 0 0, 0 .4, .4 .4, .4 0, 0 0 ))"));
-        GeometryPtr g2(reader_.read("POLYGON EMPTY"));
+// Test tiny square collapse
+template<>
+template<>
+void object::test<2>
+()
+{
+    GeometryPtr g1(reader_.read("POLYGON (( 0 0, 0 .4, .4 .4, .4 0, 0 0 ))"));
+    GeometryPtr g2(reader_.read("POLYGON EMPTY"));
 
-        GeometryPtr result(reducer_.reduce(g1.get()));
+    GeometryPtr result(reducer_.reduce(g1.get()));
 
-        ensure( result->equalsExact(g2.get()) );
-    }
+    ensure(result->equalsExact(g2.get()));
+}
 
-    // Test square collapse
-    template<>
-    template<>
-    void object::test<3>()
-    {
-        GeometryPtr g1(reader_.read("POLYGON (( 0 0, 0 1.4, .4 .4, .4 0, 0 0 ))"));
-        GeometryPtr g2(reader_.read("POLYGON EMPTY"));
+// Test square collapse
+template<>
+template<>
+void object::test<3>
+()
+{
+    GeometryPtr g1(reader_.read("POLYGON (( 0 0, 0 1.4, .4 .4, .4 0, 0 0 ))"));
+    GeometryPtr g2(reader_.read("POLYGON EMPTY"));
 
-        GeometryPtr result(reducer_.reduce(g1.get()));
+    GeometryPtr result(reducer_.reduce(g1.get()));
 
-        ensure( result->equalsExact(g2.get()) );
-    }
+    ensure(result->equalsExact(g2.get()));
+}
 
-    // Test square keep collapse
-    template<>
-    template<>
-    void object::test<4>()
-    {
-        GeometryPtr g1(reader_.read("POLYGON (( 0 0, 0 1.4, .4 .4, .4 0, 0 0 ))"));
-        GeometryPtr g2(reader_.read("POLYGON (( 0 0, 0 1, 0 0, 0 0, 0 0 ))"));
+// Test square keep collapse
+template<>
+template<>
+void object::test<4>
+()
+{
+    GeometryPtr g1(reader_.read("POLYGON (( 0 0, 0 1.4, .4 .4, .4 0, 0 0 ))"));
+    GeometryPtr g2(reader_.read("POLYGON (( 0 0, 0 1, 0 0, 0 0, 0 0 ))"));
 
-        GeometryPtr result(reducer2_.reduce(g1.get()));
+    GeometryPtr result(reducer2_.reduce(g1.get()));
 
-        ensure( result->equalsExact(g2.get()) );
-    }
+    ensure(result->equalsExact(g2.get()));
+}
 
-    // Test line
-    template<>
-    template<>
-    void object::test<5>()
-    {
-        GeometryPtr g1(reader_.read("LINESTRING ( 0 0, 0 1.4 )"));
-        GeometryPtr g2(reader_.read("LINESTRING (0 0, 0 1)"));
+// Test line
+template<>
+template<>
+void object::test<5>
+()
+{
+    GeometryPtr g1(reader_.read("LINESTRING ( 0 0, 0 1.4 )"));
+    GeometryPtr g2(reader_.read("LINESTRING (0 0, 0 1)"));
 
-        GeometryPtr result(reducer_.reduce(g1.get()));
+    GeometryPtr result(reducer_.reduce(g1.get()));
 
-        ensure( result->equalsExact(g2.get()) );
-    }
+    ensure(result->equalsExact(g2.get()));
+}
 
-    // Test line remove collapse
-    template<>
-    template<>
-    void object::test<6>()
-    {
-        GeometryPtr g1(reader_.read("LINESTRING ( 0 0, 0 .4 )"));
-        GeometryPtr g2(reader_.read("LINESTRING EMPTY"));
+// Test line remove collapse
+template<>
+template<>
+void object::test<6>
+()
+{
+    GeometryPtr g1(reader_.read("LINESTRING ( 0 0, 0 .4 )"));
+    GeometryPtr g2(reader_.read("LINESTRING EMPTY"));
 
-        GeometryPtr result(reducer_.reduce(g1.get()));
+    GeometryPtr result(reducer_.reduce(g1.get()));
 
-        ensure( result->equalsExact(g2.get()) );
-    }
+    ensure(result->equalsExact(g2.get()));
+}
 
-    // Test line keep collapse
-    template<>
-    template<>
-    void object::test<7>()
-    {
-        GeometryPtr g1(reader_.read("LINESTRING ( 0 0, 0 .4 )"));
-        GeometryPtr g2(reader_.read("LINESTRING ( 0 0, 0 0 )"));
+// Test line keep collapse
+template<>
+template<>
+void object::test<7>
+()
+{
+    GeometryPtr g1(reader_.read("LINESTRING ( 0 0, 0 .4 )"));
+    GeometryPtr g2(reader_.read("LINESTRING ( 0 0, 0 0 )"));
 
-        GeometryPtr result(reducer2_.reduce(g1.get()));
+    GeometryPtr result(reducer2_.reduce(g1.get()));
 
-        ensure( result->equalsExact(g2.get()) );
-    }
+    ensure(result->equalsExact(g2.get()));
+}
 
 } // namespace tut
 
diff --git a/tests/unit/simplify/DouglasPeuckerSimplifierTest.cpp b/tests/unit/simplify/DouglasPeuckerSimplifierTest.cpp
index 2bf63e7..b7e4cd6 100644
--- a/tests/unit/simplify/DouglasPeuckerSimplifierTest.cpp
+++ b/tests/unit/simplify/DouglasPeuckerSimplifierTest.cpp
@@ -16,341 +16,361 @@
 #include <string>
 #include <memory>
 
-namespace tut
-{
-	using namespace geos::simplify;
+namespace tut {
+using namespace geos::simplify;
 
-	//
-	// Test Group
-	//
+//
+// Test Group
+//
 
-	// Common data used by tests
-	struct test_dpsimp_data
-	{
-		geos::io::WKTReader wktreader;
-        geos::io::WKTWriter wktwriter;
+// Common data used by tests
+struct test_dpsimp_data {
+    geos::io::WKTReader wktreader;
+    geos::io::WKTWriter wktwriter;
 
-		typedef geos::geom::Geometry::Ptr GeomPtr;
+    typedef geos::geom::Geometry::Ptr GeomPtr;
 
-		test_dpsimp_data()
-			:
-			wktreader()
-		{}
-	};
+    test_dpsimp_data()
+        :
+        wktreader()
+    {}
+};
 
-	typedef test_group<test_dpsimp_data> group;
-	typedef group::object object;
+typedef test_group<test_dpsimp_data> group;
+typedef group::object object;
 
-	group test_dpsimp_group("geos::simplify::DouglasPeuckerSimplifier");
+group test_dpsimp_group("geos::simplify::DouglasPeuckerSimplifier");
 
-	//
-	// Test Cases
-	//
+//
+// Test Cases
+//
 
-	// 1 - PolygonNoReduction
-	template<>
-	template<>
-	void object::test<1>()
-	{
-		std::string wkt("POLYGON((20 220, 40 220, 60 220, 80 220, 100 220, \
+// 1 - PolygonNoReduction
+template<>
+template<>
+void object::test<1>
+()
+{
+    std::string wkt("POLYGON((20 220, 40 220, 60 220, 80 220, 100 220, \
 					120 220, 140 220, 140 180, 100 180, 60 180, 20 180, 20 220))");
 
-		GeomPtr g(wktreader.read(wkt));
+    GeomPtr g(wktreader.read(wkt));
 
-		GeomPtr simplified = DouglasPeuckerSimplifier::simplify(
-			g.get(), 10.0);
+    GeomPtr simplified = DouglasPeuckerSimplifier::simplify(
+                             g.get(), 10.0);
 
-		ensure( simplified->isValid() );
+    ensure(simplified->isValid());
 
-		// topology is unchanged
-		ensure( simplified->equals(g.get()) );
-	}
+    // topology is unchanged
+    ensure(simplified->equals(g.get()));
+}
 
-	// 2 - PolygonReductionWithSplit
-	template<>
-	template<>
-	void object::test<2>()
-	{
-		std::string wkt_in("POLYGON ((40 240, 160 241, 280 240, 280 160, \
+// 2 - PolygonReductionWithSplit
+template<>
+template<>
+void object::test<2>
+()
+{
+    std::string wkt_in("POLYGON ((40 240, 160 241, 280 240, 280 160, \
 					160 240, 40 140, 40 240))");
 
-		std::string wkt_ex("MULTIPOLYGON (((40.0 240.0, 160.0 240.0, 40.0 140.0, 40.0 240.0)), \
+    std::string wkt_ex("MULTIPOLYGON (((40.0 240.0, 160.0 240.0, 40.0 140.0, 40.0 240.0)), \
 					((160.0 240.0, 280.0 240.0, 280.0 160.0, 160.0 240.0)))");
 
-		GeomPtr g(wktreader.read(wkt_in));
+    GeomPtr g(wktreader.read(wkt_in));
 
-		GeomPtr expected(wktreader.read(wkt_ex));
+    GeomPtr expected(wktreader.read(wkt_ex));
 
-        // TODO: This test blows because if instability of geos.index.strtree::yComparator() predicate
+    // TODO: This test blows because if instability of geos.index.strtree::yComparator() predicate
 
-		GeomPtr simplified = DouglasPeuckerSimplifier::simplify(
-			g.get(), 10.0);
+    GeomPtr simplified = DouglasPeuckerSimplifier::simplify(
+                             g.get(), 10.0);
 
-		ensure( simplified->isValid() );
+    ensure(simplified->isValid());
 
-		ensure( simplified->equalsExact(expected.get()) );
+    ensure(simplified->equalsExact(expected.get()));
 
-	}
+}
 
-	// 3 - PolygonReduction
-	template<>
-	template<>
-	void object::test<3>()
-	{
-		std::string wkt_in("POLYGON ((120 120, 121 121, 122 122, 220 120, \
+// 3 - PolygonReduction
+template<>
+template<>
+void object::test<3>
+()
+{
+    std::string wkt_in("POLYGON ((120 120, 121 121, 122 122, 220 120, \
 					180 199, 160 200, 140 199, 120 120))");
 
-		std::string wkt_ex("POLYGON ((120 120, 140 199, 160 200, 180 199, 220 120, 120 120))");
+    std::string wkt_ex("POLYGON ((120 120, 140 199, 160 200, 180 199, 220 120, 120 120))");
 
-		GeomPtr g(wktreader.read(wkt_in));
+    GeomPtr g(wktreader.read(wkt_in));
 
-		GeomPtr expected(wktreader.read(wkt_ex));
+    GeomPtr expected(wktreader.read(wkt_ex));
 
-		GeomPtr simplified = DouglasPeuckerSimplifier::simplify(
-			g.get(), 10.0);
+    GeomPtr simplified = DouglasPeuckerSimplifier::simplify(
+                             g.get(), 10.0);
 
-		ensure( simplified->isValid() );
+    ensure(simplified->isValid());
 
-		ensure( simplified->equalsExact(expected.get()) );
+    ensure(simplified->equalsExact(expected.get()));
 
-	}
+}
 
-	// 4 - PolygonWithTouchingHole
-	template<>
-	template<>
-	void object::test<4>()
-	{
-		std::string wkt_in("POLYGON ((80 200, 240 200, 240 60, 80 60, 80 200), \
+// 4 - PolygonWithTouchingHole
+template<>
+template<>
+void object::test<4>
+()
+{
+    std::string wkt_in("POLYGON ((80 200, 240 200, 240 60, 80 60, 80 200), \
 					(120 120, 220 120, 180 199, 160 200, 140 199, 120 120))");
 
-		std::string wkt_ex("POLYGON ((80 200, 160 200, 240 200, 240 60, 80 60, 80 200), \
+    std::string wkt_ex("POLYGON ((80 200, 160 200, 240 200, 240 60, 80 60, 80 200), \
 					(160 200, 140 199, 120 120, 220 120, 180 199, 160 200)))");
 
-		GeomPtr g(wktreader.read(wkt_in));
+    GeomPtr g(wktreader.read(wkt_in));
 
-		GeomPtr expected(wktreader.read(wkt_ex));
+    GeomPtr expected(wktreader.read(wkt_ex));
 
-		GeomPtr simplified = DouglasPeuckerSimplifier::simplify(
-			g.get(), 10.0);
+    GeomPtr simplified = DouglasPeuckerSimplifier::simplify(
+                             g.get(), 10.0);
 
-		ensure( simplified->isValid() );
+    ensure(simplified->isValid());
 
-		ensure( simplified->isValid() );
+    ensure(simplified->isValid());
 
-		ensure( simplified->equalsExact(expected.get()) );
+    ensure(simplified->equalsExact(expected.get()));
 
-	}
+}
 
-	// 5 - FlattishPolygon
-	template<>
-	template<>
-	void object::test<5>()
-	{
-		std::string wkt_in("POLYGON ((0 0, 50 0, 53 0, 55 0, 100 0, 70 1, 60 1, 50 1, 40 1, 0 0))");
-		std::string wkt_ex("POLYGON EMPTY");
+// 5 - FlattishPolygon
+template<>
+template<>
+void object::test<5>
+()
+{
+    std::string wkt_in("POLYGON ((0 0, 50 0, 53 0, 55 0, 100 0, 70 1, 60 1, 50 1, 40 1, 0 0))");
+    std::string wkt_ex("POLYGON EMPTY");
 
-		GeomPtr g(wktreader.read(wkt_in));
+    GeomPtr g(wktreader.read(wkt_in));
 
-		GeomPtr expected(wktreader.read(wkt_ex));
+    GeomPtr expected(wktreader.read(wkt_ex));
 
-		GeomPtr simplified = DouglasPeuckerSimplifier::simplify(
-			g.get(), 10.0);
+    GeomPtr simplified = DouglasPeuckerSimplifier::simplify(
+                             g.get(), 10.0);
 
-		ensure( simplified->isValid() );
+    ensure(simplified->isValid());
 
-		ensure( simplified->equalsExact(expected.get()) );
-		//ensure_equals( *simplified, *expected );
+    ensure(simplified->equalsExact(expected.get()));
+    //ensure_equals( *simplified, *expected );
 
-	}
+}
 
-	// 6 - TinySquare
-	template<>
-	template<>
-	void object::test<6>()
-	{
-		std::string wkt_in("POLYGON ((0 5, 5 5, 5 0, 0 0, 0 1, 0 5))");
-		std::string wkt_ex("POLYGON EMPTY");
+// 6 - TinySquare
+template<>
+template<>
+void object::test<6>
+()
+{
+    std::string wkt_in("POLYGON ((0 5, 5 5, 5 0, 0 0, 0 1, 0 5))");
+    std::string wkt_ex("POLYGON EMPTY");
 
 
-		GeomPtr g(wktreader.read(wkt_in));
+    GeomPtr g(wktreader.read(wkt_in));
 
-		GeomPtr expected(wktreader.read(wkt_ex));
+    GeomPtr expected(wktreader.read(wkt_ex));
 
-		GeomPtr simplified = DouglasPeuckerSimplifier::simplify(
-			g.get(), 10.0);
+    GeomPtr simplified = DouglasPeuckerSimplifier::simplify(
+                             g.get(), 10.0);
 
-		ensure( simplified->isValid() );
+    ensure(simplified->isValid());
 
-		ensure( simplified->equalsExact(expected.get()) );
+    ensure(simplified->equalsExact(expected.get()));
 
-	}
+}
 
-	// 7 - TinyLineString
-	template<>
-	template<>
-	void object::test<7>()
-	{
-		std::string wkt_in("LINESTRING (0 5, 1 5, 2 5, 5 5)");
-		std::string wkt_ex("LINESTRING (0 5, 5 5)");
+// 7 - TinyLineString
+template<>
+template<>
+void object::test<7>
+()
+{
+    std::string wkt_in("LINESTRING (0 5, 1 5, 2 5, 5 5)");
+    std::string wkt_ex("LINESTRING (0 5, 5 5)");
 
-		GeomPtr g(wktreader.read(wkt_in));
+    GeomPtr g(wktreader.read(wkt_in));
 
-		GeomPtr expected(wktreader.read(wkt_ex));
+    GeomPtr expected(wktreader.read(wkt_ex));
 
-		GeomPtr simplified = DouglasPeuckerSimplifier::simplify(
-			g.get(), 10.0);
+    GeomPtr simplified = DouglasPeuckerSimplifier::simplify(
+                             g.get(), 10.0);
 
-		ensure( simplified->isValid() );
+    ensure(simplified->isValid());
 
-		ensure( simplified->equalsExact(expected.get()) );
+    ensure(simplified->equalsExact(expected.get()));
 
-	}
+}
 
-	// 8 - MultiPoint
-	template<>
-	template<>
-	void object::test<8>()
-	{
-		std::string wkt_in("MULTIPOINT(80 200, 240 200, 240 60, 80 60, 80 200, 140 199, 120 120)");
+// 8 - MultiPoint
+template<>
+template<>
+void object::test<8>
+()
+{
+    std::string wkt_in("MULTIPOINT(80 200, 240 200, 240 60, 80 60, 80 200, 140 199, 120 120)");
 
-		GeomPtr g(wktreader.read(wkt_in));
+    GeomPtr g(wktreader.read(wkt_in));
 
-		GeomPtr simplified = DouglasPeuckerSimplifier::simplify(
-			g.get(), 10.0);
+    GeomPtr simplified = DouglasPeuckerSimplifier::simplify(
+                             g.get(), 10.0);
 
-		// MultiPoint is *not* simplified
-		ensure( simplified->equalsExact(g.get()) );
-	}
+    // MultiPoint is *not* simplified
+    ensure(simplified->equalsExact(g.get()));
+}
 
-	// 9 - MultiLineString
-	template<>
-	template<>
-	void object::test<9>()
-	{
-		std::string wkt_in("MULTILINESTRING( (0 0, 50 0, 70 0, 80 0, 100 0), \
+// 9 - MultiLineString
+template<>
+template<>
+void object::test<9>
+()
+{
+    std::string wkt_in("MULTILINESTRING( (0 0, 50 0, 70 0, 80 0, 100 0), \
 					(0 0, 50 1, 60 1, 100 0) )");
 
-		std::string wkt_ex("MULTILINESTRING( (0 0, 100 0), (0 0, 100 0) )");
+    std::string wkt_ex("MULTILINESTRING( (0 0, 100 0), (0 0, 100 0) )");
 
-		GeomPtr g(wktreader.read(wkt_in));
+    GeomPtr g(wktreader.read(wkt_in));
 
-		GeomPtr expected(wktreader.read(wkt_ex));
+    GeomPtr expected(wktreader.read(wkt_ex));
 
-		GeomPtr simplified = DouglasPeuckerSimplifier::simplify(
-			g.get(), 10.0);
+    GeomPtr simplified = DouglasPeuckerSimplifier::simplify(
+                             g.get(), 10.0);
 
-		ensure( simplified->isValid() );
+    ensure(simplified->isValid());
 
-		ensure( simplified->equalsExact(expected.get()) );
-	}
+    ensure(simplified->equalsExact(expected.get()));
+}
 
-	// 10 - GeometryCollection
-	template<>
-	template<>
-	void object::test<10>()
-	{
-		std::string wkt_in("GEOMETRYCOLLECTION ( \
+// 10 - GeometryCollection
+template<>
+template<>
+void object::test<10>
+()
+{
+    std::string wkt_in("GEOMETRYCOLLECTION ( \
 					MULTIPOINT (80 200, 240 200, 240 60, 80 60, 80 200, 140 199, 120 120), \
 					POLYGON ((80 200, 240 200, 240 60, 80 60, 80 200)), \
 					LINESTRING (80 200, 240 200, 240 60, 80 60, 80 200, 140 199, 120 120) )");
 
-		std::string wkt_ex("MULTILINESTRING( (0 0, 100 0), (0 0, 100 0) )");
+    std::string wkt_ex("MULTILINESTRING( (0 0, 100 0), (0 0, 100 0) )");
 
-		GeomPtr g(wktreader.read(wkt_in));
+    GeomPtr g(wktreader.read(wkt_in));
 
-		GeomPtr expected(wktreader.read(wkt_ex));
+    GeomPtr expected(wktreader.read(wkt_ex));
 
-		GeomPtr simplified = DouglasPeuckerSimplifier::simplify(
-			g.get(), 10.0);
+    GeomPtr simplified = DouglasPeuckerSimplifier::simplify(
+                             g.get(), 10.0);
 
-		ensure( simplified->isValid() );
+    ensure(simplified->isValid());
 
-		// Non simplification occurs
-		ensure( simplified->equalsExact(g.get()) );
-	}
+    // Non simplification occurs
+    ensure(simplified->equalsExact(g.get()));
+}
 
-    // 11 - A kind of reversed simplification
-    template<>
-	template<>
-	void object::test<11>()
-	{
-        using namespace geos::geom;
+// 11 - A kind of reversed simplification
+template<>
+template<>
+void object::test<11>
+()
+{
+    using namespace geos::geom;
 
-		std::string wkt("MULTIPOLYGON(((0.561648 1,1 1,1 0,0.468083 0,0.52758 0.00800554,0.599683 0.0280924, 0.601611 0.265374, \
+    std::string
+    wkt("MULTIPOLYGON(((0.561648 1,1 1,1 0,0.468083 0,0.52758 0.00800554,0.599683 0.0280924, 0.601611 0.265374, \
                         0.622693 0.316765,0.69507 0.357497,0.695623 0.429711,0.655111 0.502298, 0.696467 0.543147,0.840712 0.593546, \
                         0.882583 0.66546,0.852357 0.748213,0.84264 0.789567,0 .832667 0.841202,0.832667 0.841202,0.740538 0.873004, \
                         0.617349 0.905045,0.566576 0.977697,0.561648 1)),((0 0.801979,0.0308575 0.786234,0.0705513 0.631135, \
                         0.141616 0.527248,0.233985 0.505872,0.264777 0.526263,0.336631 0.505009,0.356603 0.422321,0.355803 0.350038, \
                         0.375252 0.205364,0.415206 0.0709182,0.45479 0,0 0,0 0,0 0.801979)))");
 
-		GeomPtr g(wktreader.read(wkt));
-        std::size_t const gN = g->getNumPoints();
-        ensure_equals(gN, std::size_t(37));
-
-        // 1) Simplify with 1/2048
-        double const d1 = 1/2048.0;
-		GeomPtr simplified1 = DouglasPeuckerSimplifier::simplify(g.get(), d1);
-		ensure(simplified1->isValid());
-		ensure(simplified1->equals(g.get()));
-        std::size_t const simplifiedN1 = simplified1->getNumPoints();
-        ensure_equals(simplifiedN1, std::size_t(36));
-        //std::string const simplifiedWkd = wktwriter.write(simplified1.get());
-
-        // 2) Multiply points by 2047
-        struct Multiplier : public CoordinateSequenceFilter
+    GeomPtr g(wktreader.read(wkt));
+    std::size_t const gN = g->getNumPoints();
+    ensure_equals(gN, std::size_t(37));
+
+    // 1) Simplify with 1/2048
+    double const d1 = 1 / 2048.0;
+    GeomPtr simplified1 = DouglasPeuckerSimplifier::simplify(g.get(), d1);
+    ensure(simplified1->isValid());
+    ensure(simplified1->equals(g.get()));
+    std::size_t const simplifiedN1 = simplified1->getNumPoints();
+    ensure_equals(simplifiedN1, std::size_t(36));
+    //std::string const simplifiedWkd = wktwriter.write(simplified1.get());
+
+    // 2) Multiply points by 2047
+    struct Multiplier : public CoordinateSequenceFilter {
+        double f;
+        Multiplier(double p_f) : f(p_f) {}
+        void
+        filter_rw(CoordinateSequence& seq, std::size_t i) override
+        {
+            seq.setOrdinate(i, CoordinateSequence::X, seq[i].x * f);
+            seq.setOrdinate(i, CoordinateSequence::Y, seq[i].y * f);
+        }
+        void
+        filter_ro(const CoordinateSequence& seq, std::size_t i) override
         {
-            double f;
-            Multiplier(double p_f) : f(p_f) {}
-            void filter_rw(CoordinateSequence& seq, std::size_t i) override
-            {
-                seq.setOrdinate(i, CoordinateSequence::X, seq[i].x * f);
-                seq.setOrdinate(i, CoordinateSequence::Y, seq[i].y * f);
-            }
-            void filter_ro(const CoordinateSequence& seq, std::size_t i) override
-            {
-                ::geos::ignore_unused_variable_warning(seq);
-                ::geos::ignore_unused_variable_warning(i);
-            }
-            bool isDone() const override { return false; }
-            bool isGeometryChanged() const override { return true; }
-        };
-
-        Multiplier m(2047);
-        g->apply_rw(m);
-        std::size_t const multipliedN = g->getNumPoints();
-        ensure_equals(multipliedN, std::size_t(37));
-        //std::string const multipliedWkt = wktwriter.write(g.get());
-
-        // 3) Simplify with 1.0
-        double const d2 = 1.0;
-		GeomPtr simplified2 = DouglasPeuckerSimplifier::simplify(g.get(), d2);
-		ensure(simplified2->isValid());
-	    ensure(simplified2->equals(g.get()));
-        std::size_t const simplifiedN2 = simplified2->getNumPoints();
-        ensure_equals(simplifiedN2, std::size_t(36));
-        //std::string const simplifiedWkt2 = wktwriter.write(simplified2.get());
-	}
-
-	// 13 - Polygon with inner ring whose extent is less than the simplify distance (#741)
-	template<>
-	template<>
-	void object::test<13>()
-	{
-		std::string wkt_in("POLYGON ((0 0,0 1,1 1,0 0),(0.1 0.1,0.2 0.1,0.2 0.2,0.1 0.1))");
-
-		std::string wkt_ex("POLYGON ((0 0,0 1,1 1,0 0))");
-
-		GeomPtr g(wktreader.read(wkt_in));
-
-		GeomPtr expected(wktreader.read(wkt_ex));
-
-		GeomPtr simplified = DouglasPeuckerSimplifier::simplify(
-			g.get(), 0.5);
-
-		ensure( simplified->isValid() );
-
-		ensure( simplified->equalsExact(expected.get()) );
-	}
+            ::geos::ignore_unused_variable_warning(seq);
+            ::geos::ignore_unused_variable_warning(i);
+        }
+        bool
+        isDone() const override
+        {
+            return false;
+        }
+        bool
+        isGeometryChanged() const override
+        {
+            return true;
+        }
+    };
+
+    Multiplier m(2047);
+    g->apply_rw(m);
+    std::size_t const multipliedN = g->getNumPoints();
+    ensure_equals(multipliedN, std::size_t(37));
+    //std::string const multipliedWkt = wktwriter.write(g.get());
+
+    // 3) Simplify with 1.0
+    double const d2 = 1.0;
+    GeomPtr simplified2 = DouglasPeuckerSimplifier::simplify(g.get(), d2);
+    ensure(simplified2->isValid());
+    ensure(simplified2->equals(g.get()));
+    std::size_t const simplifiedN2 = simplified2->getNumPoints();
+    ensure_equals(simplifiedN2, std::size_t(36));
+    //std::string const simplifiedWkt2 = wktwriter.write(simplified2.get());
+}
+
+// 13 - Polygon with inner ring whose extent is less than the simplify distance (#741)
+template<>
+template<>
+void object::test<13>
+()
+{
+    std::string wkt_in("POLYGON ((0 0,0 1,1 1,0 0),(0.1 0.1,0.2 0.1,0.2 0.2,0.1 0.1))");
+
+    std::string wkt_ex("POLYGON ((0 0,0 1,1 1,0 0))");
+
+    GeomPtr g(wktreader.read(wkt_in));
+
+    GeomPtr expected(wktreader.read(wkt_ex));
+
+    GeomPtr simplified = DouglasPeuckerSimplifier::simplify(
+                             g.get(), 0.5);
+
+    ensure(simplified->isValid());
+
+    ensure(simplified->equalsExact(expected.get()));
+}
 
 } // namespace tut
 
diff --git a/tests/unit/simplify/TopologyPreservingSimplifierTest.cpp b/tests/unit/simplify/TopologyPreservingSimplifierTest.cpp
index e54787f..1b28b68 100644
--- a/tests/unit/simplify/TopologyPreservingSimplifierTest.cpp
+++ b/tests/unit/simplify/TopologyPreservingSimplifierTest.cpp
@@ -16,97 +16,99 @@
 #include <string>
 #include <memory>
 
-namespace tut
+namespace tut {
+using namespace geos::simplify;
+
+//
+// Test Group
+//
+
+// Common data used by tests
+struct test_tpsimp_data {
+    geos::geom::PrecisionModel pm;
+    typedef geos::geom::GeometryFactory GeometryFactory;
+    GeometryFactory::Ptr gf;
+    geos::io::WKTReader wktreader;
+    geos::io::WKTWriter wktwriter;
+
+    typedef geos::geom::Geometry::Ptr GeomPtr;
+
+    test_tpsimp_data()
+        : pm(1.0)
+        , gf(GeometryFactory::create(&pm))
+        , wktreader(gf.get())
+        , wktwriter()
+    {
+        //wktwriter.setTrim(1);
+    }
+};
+
+typedef test_group<test_tpsimp_data> group;
+typedef group::object object;
+
+group test_tpsimp_group("geos::simplify::TopologyPreservingSimplifier");
+
+//
+// Test Cases
+//
+
+// EmptyPolygon
+template<>
+template<>
+void object::test<1>
+()
 {
-	using namespace geos::simplify;
-
-	//
-	// Test Group
-	//
-
-	// Common data used by tests
-	struct test_tpsimp_data
-	{
-		geos::geom::PrecisionModel pm;
-		typedef geos::geom::GeometryFactory GeometryFactory;
-		GeometryFactory::Ptr gf;
-		geos::io::WKTReader wktreader;
-		geos::io::WKTWriter wktwriter;
-
-		typedef geos::geom::Geometry::Ptr GeomPtr;
-
-		test_tpsimp_data()
-            : pm(1.0)
-            , gf(GeometryFactory::create(&pm))
-            , wktreader(gf.get())
-            , wktwriter()
-		{
-			//wktwriter.setTrim(1);
-		}
-	};
-
-	typedef test_group<test_tpsimp_data> group;
-	typedef group::object object;
-
-	group test_tpsimp_group("geos::simplify::TopologyPreservingSimplifier");
-
-	//
-	// Test Cases
-	//
-
-  // EmptyPolygon
-  template<>
-  template<>
-  void object::test<1>()
-  {
     std::string wkt("POLYGON EMPTY");
 
     GeomPtr g(wktreader.read(wkt));
     GeomPtr simplified = TopologyPreservingSimplifier::simplify(g.get(), 10.0);
 
-    ensure( "Simplified geometry is invalid!", simplified->isValid() );
-    ensure_equals_geometry(g.get(), simplified.get() );
-  }
+    ensure("Simplified geometry is invalid!", simplified->isValid());
+    ensure_equals_geometry(g.get(), simplified.get());
+}
 
-  // Point
-  template<>
-  template<>
-  void object::test<2>()
-  {
+// Point
+template<>
+template<>
+void object::test<2>
+()
+{
     std::string wkt("POINT (10 10)");
 
     GeomPtr g(wktreader.read(wkt));
     GeomPtr simplified = TopologyPreservingSimplifier::simplify(g.get(), 10.0);
 
-    ensure( "Simplified geometry is invalid!", simplified->isValid() );
-    ensure_equals_geometry(g.get(), simplified.get() );
-  }
+    ensure("Simplified geometry is invalid!", simplified->isValid());
+    ensure_equals_geometry(g.get(), simplified.get());
+}
 
 #if 0 // Fails with JTS too !
-	// MultiPolygonWithSmallComponents
-  // Test is from http://postgis.refractions.net/pipermail/postgis-users/2008-April/019327.html
-	template<>
-	template<>
-	void object::test<3>()
-	{
-		std::string wkt(
-    "MULTIPOLYGON(((13.73095 51.024734,13.7309323 51.0247668,13.7306959 51.0247959,13.7292724 51.0249742,13.7280216 51.0251252,13.7266598 51.0252998,13.7259617 51.0254072,13.7258854 51.0254201,13.7253253 51.0255144,13.725276 51.025492,13.724538 51.025631,13.7230288 51.0259021,13.7223529 51.0260273,13.7223299 51.0260863,13.7222292 51.026391,13.7220002 51.0273366,13.7217875 51.0282094,13.721746 51.028243,13.7217693 51.0282803,13.7215512 51.0291967,13.721513 51.029222,13.7215203 51.0292567,13.7212713 51.0295967,13.7222258 51.0299532,13.722234 51.03,13.7222931 51.0299823,13.7232514 51.0303187,13.7242514 51.0306715,13.724263 51.030714,13.7243024 51.0306951,13.7249934 51.0309315,13.7265097 51.0314552,13.7266116 51.0313952,13.7267988 51.0313334,13.7269952 51.0313243,13.72703 51.0314107,13.7271637 51.0313254,13.7272524 51.0313839,13.72739 51.031449,13.7276768 51.0313074,13.7283793 51.0309944,13.7296654 51.0304157,13.7297572 51.0303637,13.729845 51.0303139,13.7299557 51.0301763,13.7300964 51
 .0300176,13.730252 51.0298919,13.7304615 51.0297932,13.730668 51.0297363,13.730743 51.029783,13.7307859 51.0298398,13.7307094 51.0301388,13.730624 51.030263,13.7306955 51.0303267,13.7301182 51.0325594,13.7300528 51.0325663,13.7301114 51.0327342,13.7301645 51.0329094,13.7300035 51.0327693,13.7299669 51.0327351,13.7299445 51.0327211,13.7298934 51.032814,13.7298539 51.0328585,13.7297737 51.0328321,13.7288526 51.0325639,13.7288201 51.0324367,13.7284426 51.0324383,13.7276461 51.032179,13.7274569 51.0321976,13.7272787 51.0322421,13.7271265 51.0322903,13.7267034 51.0322495,13.7265364 51.0322161,13.7259018 51.0324269,13.7258649 51.03242,13.725733 51.0326646,13.7251933 51.0328876,13.7247918 51.0331374,13.7244439 51.0331106,13.7242967 51.0334273,13.7239131 51.0337529,13.7237035 51.0338511,13.7235429 51.033967,13.7233375 51.0339148,13.7232064 51.0339347,13.7231786 51.0339863,13.7228848 51.0340776,13.7224481 51.0341888,13.7220471 51.0342483,13.7217493 51.0343198,13.721552 51.0343861,13.7214718 
 51.0344095,13.7215108 51.034534,13.7205032 51.0349932,13.7197657 51.0352983,13.7195764 51.0352291,13.7195934 51.0352797,13.7182451 51.0359157,13.7181108 51.0359003,13.7181657 51.0359571,13.717622 51.0361956,13.7159749 51.0369683,13.7159057 51.0369284,13.7158604 51.0370288,13.7157161 51.0370124,13.7157523 51.0370733,13.7153708 51.0372801,13.7150274 51.0374899,13.7144074 51.0379192,13.7138287 51.0383899,13.7137514 51.0383857,13.7137492 51.0384566,13.7134249 51.0387269,13.7130179 51.0390385,13.7125791 51.0393343,13.7120736 51.039611,13.7115839 51.0398558,13.7112945 51.0399894,13.7114637 51.0402313,13.7123153 51.041449,13.7126333 51.0417033,13.713371 51.0421453,13.7138861 51.0424061,13.7142518 51.0425683,13.7164587 51.0435668,13.7167995 51.0437957,13.7170883 51.0439897,13.7190694 51.0451663,13.7196131 51.0458277,13.7197562 51.0461521,13.7198262 51.0464192,13.7198377 51.0467389,13.7205681 51.0455573,13.7210009 51.0450379,13.7214987 51.0445401,13.7220306 51.0442859,13.7227215 51.0439558,1
 3.7237962 51.0434514,13.723979 51.0435278,13.7241448 51.0435041,13.7241052 51.0436042,13.7247987 51.0438896,13.7250186 51.0439093,13.7250579 51.0440386,13.7257225 51.0443545,13.7259312 51.0443456,13.725955 51.0443813,13.7260235 51.0443873,13.7260682 51.0445303,13.7282191 51.0455848,13.7290532 51.045927,13.7292643 51.0458591,13.7292228 51.0459969,13.729706 51.0461854,13.7303185 51.046393,13.7309107 51.0465601,13.731546 51.0466841,13.7321939 51.0467752,13.7332896 51.0468999,13.7333733 51.0469094,13.7334778 51.0468127,13.7335706 51.0469078,13.733651 51.0470684,13.7338458 51.0471508,13.7346109 51.0472333,13.7346367 51.0471474,13.7346922 51.0470697,13.7346666 51.0470056,13.7346564 51.0468714,13.7345552 51.0467095,13.7336001 51.0465496,13.733427 51.046454,13.7335317 51.0464255,13.7347225 51.0465948,13.7348421 51.0466562,13.7349123 51.0466203,13.736811 51.0468537,13.7382043 51.0469796,13.7383487 51.0469803,13.7394909 51.0469005,13.7400899 51.0467949,13.7405051 51.0464739,13.7408331 51.0462
 204,13.7412027 51.0463256,13.741053 51.0466451,13.7407291 51.0469007,13.7405095 51.0469726,13.7400888 51.0470337,13.7393051 51.0471049,13.7393014 51.0472015,13.7393088 51.0473019,13.7395556 51.0473056,13.7404944 51.0472245,13.740932 51.0470192,13.7414421 51.0465652,13.7414893 51.0465576,13.7416494 51.0464916,13.7416003 51.0466074,13.7416246 51.04663,13.741668 51.0466443,13.7417272 51.0467159,13.7417503 51.0466716,13.7423587 51.0468732,13.7426958 51.0470246,13.7429143 51.0471813,13.74318 51.04726,13.7430363 51.0472995,13.7433021 51.047588,13.7434678 51.0475916,13.7433805 51.0477019,13.7436362 51.0479981,13.7446308 51.0491622,13.7447961 51.0491827,13.744722 51.0492509,13.7448536 51.0494078,13.745056 51.0494766,13.7450313 51.0496901,13.7453573 51.0500052,13.7465317 51.0512807,13.7466999 51.0513722,13.746638 51.0514149,13.7468683 51.0516781,13.7470071 51.051777,13.7469985 51.0518746,13.7470732 51.0519866,13.7471316 51.0520528,13.7472989 51.0523089,13.7472368 51.0523858,13.7473063 51.052
 4932,13.7473468 51.0527412,13.7473392 51.0531614,13.7472987 51.0533157,13.7473919 51.0534224,13.7472684 51.0534549,13.7472134 51.0536926,13.7472913 51.0537784,13.7473216 51.053725,13.7474649 51.0537575,13.7474492 51.053833,13.7475625 51.0537839,13.7497379 51.0544435,13.7515333 51.0551019,13.7527693 51.0555438,13.7549766 51.0564993,13.7550622 51.0565364,13.755105 51.0566612,13.7552745 51.0566237,13.7558661 51.0560648,13.7559318 51.0560101,13.755908 51.055897,13.7559252 51.0558292,13.7559566 51.0557055,13.7564494 51.0551377,13.7564124 51.0550457,13.7573213 51.0539813,13.7575007 51.0539933,13.757856 51.0540047,13.7580394 51.054028,13.7580896 51.053984,13.7580949 51.0539463,13.7579963 51.0538534,13.7581294 51.0537147,13.7582346 51.0535957,13.758354 51.053433,13.758363 51.053392,13.7583656 51.0533457,13.758359 51.0532095,13.7583338 51.0530937,13.7582902 51.0529647,13.7580365 51.0522637,13.7577683 51.051463,13.7573182 51.0501993,13.7571595 51.0497164,13.7567579 51.0490095,13.7563383 51.04
 82979,13.7557757 51.0473383,13.7557095 51.0472522,13.7555771 51.0471199,13.7554448 51.0470471,13.7548596 51.0462612,13.7547097 51.046054,13.7549127 51.0460086,13.7548633 51.0459174,13.7548127 51.0458413,13.7547176 51.0457237,13.7538293 51.0449222,13.7530218 51.0441346,13.7526711 51.0437838,13.752446 51.0435522,13.7522297 51.0433547,13.751704 51.042833,13.7513058 51.0424448,13.7505766 51.0417281,13.7499967 51.0411283,13.7497695 51.0408943,13.7493849 51.0405205,13.7486222 51.0397896,13.7478209 51.0390261,13.7477474 51.0389532,13.7477041 51.0389189,13.7476277 51.0388729,13.7475781 51.0388513,13.7472699 51.038726,13.747131 51.0386506,13.7469329 51.0385052,13.7468562 51.0384284,13.7466683 51.0383483,13.7467998 51.038236,13.7473841 51.0380129,13.747838 51.0378277,13.7481801 51.0376558,13.7489728 51.0370285,13.7491313 51.0368016,13.7492665 51.0363477,13.7493166 51.0359389,13.7492966 51.0358087,13.7493888 51.0356942,13.7492867 51.0357016,13.7492855 51.0354359,13.7492829 51.034867,13.7492723
  51.0348311,13.7492455 51.0347398,13.7493034 51.0346612,13.7491987 51.0346142,13.748866 51.034723,13.748791 51.034201,13.748335 51.034159,13.748294 51.034034,13.748205 51.033764,13.7488691 51.0333037,13.748962 51.033245,13.7486777 51.0332252,13.7483008 51.032683,13.7484397 51.0324582,13.7469913 51.0327817,13.7466998 51.0326205,13.7459997 51.0314852,13.7460996 51.0313569,13.745967 51.0314864,13.7449355 51.0317377,13.7447301 51.0316513,13.7446705 51.0318463,13.7420262 51.0323659,13.7419131 51.0322884,13.7418636 51.0322552,13.7416501 51.0321425,13.7415567 51.0317708,13.7414972 51.0314666,13.741484 51.0311492,13.741923 51.031003,13.7418649 51.030884,13.74209 51.0304134,13.7422077 51.0300143,13.7421975 51.0299222,13.742286 51.029835,13.7421463 51.0297533,13.7420951 51.0296254,13.7415933 51.0288452,13.7414906 51.0286855,13.7414437 51.0286127,13.7413482 51.0284642,13.7410545 51.0280777,13.7407158 51.0277229,13.7401513 51.0273842,13.7392803 51.0270293,13.7382744 51.0267844,13.737321 51.0267
 454,13.7365929 51.0267541,13.736556 51.026812,13.7364715 51.026754,13.7357088 51.0268017,13.7353967 51.02678,13.73534 51.02685,13.7352667 51.0267757,13.734907 51.0267324,13.734824 51.02679,13.7347684 51.0267064,13.7342093 51.0266674,13.73409 51.026725,13.7340359 51.0266283,13.7335072 51.0265633,13.733407 51.02663,13.7333208 51.0265373,13.7317087 51.0263813,13.7317173 51.0263119,13.73167 51.026241,13.7317563 51.0261602,13.7318473 51.0258395,13.7318647 51.0254971,13.73183 51.0253281,13.7317736 51.0252414,13.731663 51.025181,13.7316826 51.0251114,13.7310803 51.0247604,13.73095 51.024734)),((13.7368533 51.0470386,13.7368426 51.0471226,13.7368067 51.0472669,13.7368255 51.0473828,13.7369099 51.0474154,13.7376695 51.0474677,13.7382756 51.0474245,13.738513 51.0474297,13.7386105 51.0474065,13.738705 51.0473737,13.7385856 51.0473757,13.7385618 51.0473751,13.7385263 51.0473743,13.7384706 51.0473744,13.7383071 51.0473734,13.7383822 51.0473564,13.7390821 51.047287,13.7390933 51.047209,13.7390933
  51.0471421,13.7368533 51.0470386)),((13.7367293 51.0470057,13.7346615 51.0466892,13.7347551 51.0468411,13.7347754 51.0470359,13.7347106 51.0471899,13.7356421 51.0472919,13.7366963 51.0474074,13.736705 51.047249,13.7367293 51.0470057)))"
-      );
+// MultiPolygonWithSmallComponents
+// Test is from http://postgis.refractions.net/pipermail/postgis-users/2008-April/019327.html
+template<>
+template<>
+void object::test<3>
+()
+{
+    std::string wkt(
+        "MULTIPOLYGON(((13.73095 51.024734,13.7309323 51.0247668,13.7306959 51.0247959,13.7292724 51.0249742,13.7280216 51.0251252,13.7266598 51.0252998,13.7259617 51.0254072,13.7258854 51.0254201,13.7253253 51.0255144,13.725276 51.025492,13.724538 51.025631,13.7230288 51.0259021,13.7223529 51.0260273,13.7223299 51.0260863,13.7222292 51.026391,13.7220002 51.0273366,13.7217875 51.0282094,13.721746 51.028243,13.7217693 51.0282803,13.7215512 51.0291967,13.721513 51.029222,13.7215203 51.0292567,13.7212713 51.0295967,13.7222258 51.0299532,13.722234 51.03,13.7222931 51.0299823,13.7232514 51.0303187,13.7242514 51.0306715,13.724263 51.030714,13.7243024 51.0306951,13.7249934 51.0309315,13.7265097 51.0314552,13.7266116 51.0313952,13.7267988 51.0313334,13.7269952 51.0313243,13.72703 51.0314107,13.7271637 51.0313254,13.7272524 51.0313839,13.72739 51.031449,13.7276768 51.0313074,13.7283793 51.0309944,13.7296654 51.0304157,13.7297572 51.0303637,13.729845 51.0303139,13.7299557 51.0301763,13.730096
 4 51.0300176,13.730252 51.0298919,13.7304615 51.0297932,13.730668 51.0297363,13.730743 51.029783,13.7307859 51.0298398,13.7307094 51.0301388,13.730624 51.030263,13.7306955 51.0303267,13.7301182 51.0325594,13.7300528 51.0325663,13.7301114 51.0327342,13.7301645 51.0329094,13.7300035 51.0327693,13.7299669 51.0327351,13.7299445 51.0327211,13.7298934 51.032814,13.7298539 51.0328585,13.7297737 51.0328321,13.7288526 51.0325639,13.7288201 51.0324367,13.7284426 51.0324383,13.7276461 51.032179,13.7274569 51.0321976,13.7272787 51.0322421,13.7271265 51.0322903,13.7267034 51.0322495,13.7265364 51.0322161,13.7259018 51.0324269,13.7258649 51.03242,13.725733 51.0326646,13.7251933 51.0328876,13.7247918 51.0331374,13.7244439 51.0331106,13.7242967 51.0334273,13.7239131 51.0337529,13.7237035 51.0338511,13.7235429 51.033967,13.7233375 51.0339148,13.7232064 51.0339347,13.7231786 51.0339863,13.7228848 51.0340776,13.7224481 51.0341888,13.7220471 51.0342483,13.7217493 51.0343198,13.721552 51.0343861,13.7214
 718 51.0344095,13.7215108 51.034534,13.7205032 51.0349932,13.7197657 51.0352983,13.7195764 51.0352291,13.7195934 51.0352797,13.7182451 51.0359157,13.7181108 51.0359003,13.7181657 51.0359571,13.717622 51.0361956,13.7159749 51.0369683,13.7159057 51.0369284,13.7158604 51.0370288,13.7157161 51.0370124,13.7157523 51.0370733,13.7153708 51.0372801,13.7150274 51.0374899,13.7144074 51.0379192,13.7138287 51.0383899,13.7137514 51.0383857,13.7137492 51.0384566,13.7134249 51.0387269,13.7130179 51.0390385,13.7125791 51.0393343,13.7120736 51.039611,13.7115839 51.0398558,13.7112945 51.0399894,13.7114637 51.0402313,13.7123153 51.041449,13.7126333 51.0417033,13.713371 51.0421453,13.7138861 51.0424061,13.7142518 51.0425683,13.7164587 51.0435668,13.7167995 51.0437957,13.7170883 51.0439897,13.7190694 51.0451663,13.7196131 51.0458277,13.7197562 51.0461521,13.7198262 51.0464192,13.7198377 51.0467389,13.7205681 51.0455573,13.7210009 51.0450379,13.7214987 51.0445401,13.7220306 51.0442859,13.7227215 51.04395
 58,13.7237962 51.0434514,13.723979 51.0435278,13.7241448 51.0435041,13.7241052 51.0436042,13.7247987 51.0438896,13.7250186 51.0439093,13.7250579 51.0440386,13.7257225 51.0443545,13.7259312 51.0443456,13.725955 51.0443813,13.7260235 51.0443873,13.7260682 51.0445303,13.7282191 51.0455848,13.7290532 51.045927,13.7292643 51.0458591,13.7292228 51.0459969,13.729706 51.0461854,13.7303185 51.046393,13.7309107 51.0465601,13.731546 51.0466841,13.7321939 51.0467752,13.7332896 51.0468999,13.7333733 51.0469094,13.7334778 51.0468127,13.7335706 51.0469078,13.733651 51.0470684,13.7338458 51.0471508,13.7346109 51.0472333,13.7346367 51.0471474,13.7346922 51.0470697,13.7346666 51.0470056,13.7346564 51.0468714,13.7345552 51.0467095,13.7336001 51.0465496,13.733427 51.046454,13.7335317 51.0464255,13.7347225 51.0465948,13.7348421 51.0466562,13.7349123 51.0466203,13.736811 51.0468537,13.7382043 51.0469796,13.7383487 51.0469803,13.7394909 51.0469005,13.7400899 51.0467949,13.7405051 51.0464739,13.7408331 51.
 0462204,13.7412027 51.0463256,13.741053 51.0466451,13.7407291 51.0469007,13.7405095 51.0469726,13.7400888 51.0470337,13.7393051 51.0471049,13.7393014 51.0472015,13.7393088 51.0473019,13.7395556 51.0473056,13.7404944 51.0472245,13.740932 51.0470192,13.7414421 51.0465652,13.7414893 51.0465576,13.7416494 51.0464916,13.7416003 51.0466074,13.7416246 51.04663,13.741668 51.0466443,13.7417272 51.0467159,13.7417503 51.0466716,13.7423587 51.0468732,13.7426958 51.0470246,13.7429143 51.0471813,13.74318 51.04726,13.7430363 51.0472995,13.7433021 51.047588,13.7434678 51.0475916,13.7433805 51.0477019,13.7436362 51.0479981,13.7446308 51.0491622,13.7447961 51.0491827,13.744722 51.0492509,13.7448536 51.0494078,13.745056 51.0494766,13.7450313 51.0496901,13.7453573 51.0500052,13.7465317 51.0512807,13.7466999 51.0513722,13.746638 51.0514149,13.7468683 51.0516781,13.7470071 51.051777,13.7469985 51.0518746,13.7470732 51.0519866,13.7471316 51.0520528,13.7472989 51.0523089,13.7472368 51.0523858,13.7473063 51
 .0524932,13.7473468 51.0527412,13.7473392 51.0531614,13.7472987 51.0533157,13.7473919 51.0534224,13.7472684 51.0534549,13.7472134 51.0536926,13.7472913 51.0537784,13.7473216 51.053725,13.7474649 51.0537575,13.7474492 51.053833,13.7475625 51.0537839,13.7497379 51.0544435,13.7515333 51.0551019,13.7527693 51.0555438,13.7549766 51.0564993,13.7550622 51.0565364,13.755105 51.0566612,13.7552745 51.0566237,13.7558661 51.0560648,13.7559318 51.0560101,13.755908 51.055897,13.7559252 51.0558292,13.7559566 51.0557055,13.7564494 51.0551377,13.7564124 51.0550457,13.7573213 51.0539813,13.7575007 51.0539933,13.757856 51.0540047,13.7580394 51.054028,13.7580896 51.053984,13.7580949 51.0539463,13.7579963 51.0538534,13.7581294 51.0537147,13.7582346 51.0535957,13.758354 51.053433,13.758363 51.053392,13.7583656 51.0533457,13.758359 51.0532095,13.7583338 51.0530937,13.7582902 51.0529647,13.7580365 51.0522637,13.7577683 51.051463,13.7573182 51.0501993,13.7571595 51.0497164,13.7567579 51.0490095,13.7563383 5
 1.0482979,13.7557757 51.0473383,13.7557095 51.0472522,13.7555771 51.0471199,13.7554448 51.0470471,13.7548596 51.0462612,13.7547097 51.046054,13.7549127 51.0460086,13.7548633 51.0459174,13.7548127 51.0458413,13.7547176 51.0457237,13.7538293 51.0449222,13.7530218 51.0441346,13.7526711 51.0437838,13.752446 51.0435522,13.7522297 51.0433547,13.751704 51.042833,13.7513058 51.0424448,13.7505766 51.0417281,13.7499967 51.0411283,13.7497695 51.0408943,13.7493849 51.0405205,13.7486222 51.0397896,13.7478209 51.0390261,13.7477474 51.0389532,13.7477041 51.0389189,13.7476277 51.0388729,13.7475781 51.0388513,13.7472699 51.038726,13.747131 51.0386506,13.7469329 51.0385052,13.7468562 51.0384284,13.7466683 51.0383483,13.7467998 51.038236,13.7473841 51.0380129,13.747838 51.0378277,13.7481801 51.0376558,13.7489728 51.0370285,13.7491313 51.0368016,13.7492665 51.0363477,13.7493166 51.0359389,13.7492966 51.0358087,13.7493888 51.0356942,13.7492867 51.0357016,13.7492855 51.0354359,13.7492829 51.034867,13.749
 2723 51.0348311,13.7492455 51.0347398,13.7493034 51.0346612,13.7491987 51.0346142,13.748866 51.034723,13.748791 51.034201,13.748335 51.034159,13.748294 51.034034,13.748205 51.033764,13.7488691 51.0333037,13.748962 51.033245,13.7486777 51.0332252,13.7483008 51.032683,13.7484397 51.0324582,13.7469913 51.0327817,13.7466998 51.0326205,13.7459997 51.0314852,13.7460996 51.0313569,13.745967 51.0314864,13.7449355 51.0317377,13.7447301 51.0316513,13.7446705 51.0318463,13.7420262 51.0323659,13.7419131 51.0322884,13.7418636 51.0322552,13.7416501 51.0321425,13.7415567 51.0317708,13.7414972 51.0314666,13.741484 51.0311492,13.741923 51.031003,13.7418649 51.030884,13.74209 51.0304134,13.7422077 51.0300143,13.7421975 51.0299222,13.742286 51.029835,13.7421463 51.0297533,13.7420951 51.0296254,13.7415933 51.0288452,13.7414906 51.0286855,13.7414437 51.0286127,13.7413482 51.0284642,13.7410545 51.0280777,13.7407158 51.0277229,13.7401513 51.0273842,13.7392803 51.0270293,13.7382744 51.0267844,13.737321 51.
 0267454,13.7365929 51.0267541,13.736556 51.026812,13.7364715 51.026754,13.7357088 51.0268017,13.7353967 51.02678,13.73534 51.02685,13.7352667 51.0267757,13.734907 51.0267324,13.734824 51.02679,13.7347684 51.0267064,13.7342093 51.0266674,13.73409 51.026725,13.7340359 51.0266283,13.7335072 51.0265633,13.733407 51.02663,13.7333208 51.0265373,13.7317087 51.0263813,13.7317173 51.0263119,13.73167 51.026241,13.7317563 51.0261602,13.7318473 51.0258395,13.7318647 51.0254971,13.73183 51.0253281,13.7317736 51.0252414,13.731663 51.025181,13.7316826 51.0251114,13.7310803 51.0247604,13.73095 51.024734)),((13.7368533 51.0470386,13.7368426 51.0471226,13.7368067 51.0472669,13.7368255 51.0473828,13.7369099 51.0474154,13.7376695 51.0474677,13.7382756 51.0474245,13.738513 51.0474297,13.7386105 51.0474065,13.738705 51.0473737,13.7385856 51.0473757,13.7385618 51.0473751,13.7385263 51.0473743,13.7384706 51.0473744,13.7383071 51.0473734,13.7383822 51.0473564,13.7390821 51.047287,13.7390933 51.047209,13.739
 0933 51.0471421,13.7368533 51.0470386)),((13.7367293 51.0470057,13.7346615 51.0466892,13.7347551 51.0468411,13.7347754 51.0470359,13.7347106 51.0471899,13.7356421 51.0472919,13.7366963 51.0474074,13.736705 51.047249,13.7367293 51.0470057)))"
+    );
 
     GeomPtr g(wktreader.read(wkt));
-		GeomPtr simplified = TopologyPreservingSimplifier::simplify(g.get(), 0.0057);
+    GeomPtr simplified = TopologyPreservingSimplifier::simplify(g.get(), 0.0057);
 
-		ensure( "Simplified geometry is invalid!", simplified->isValid() );
+    ensure("Simplified geometry is invalid!", simplified->isValid());
 
-	}
+}
 #endif // fails with JTS too
 
-	// PolygonWithSpike
-	template<>
-	template<>
-	void object::test<4>()
-	{
-		std::string wkt("POLYGON ((3312459.605 6646878.353, \
+// PolygonWithSpike
+template<>
+template<>
+void object::test<4>
+()
+{
+    std::string wkt("POLYGON ((3312459.605 6646878.353, \
       3312460.524 6646875.969, 3312459.427 6646878.421, \
       3312460.014 6646886.391, 3312465.889 6646887.398, \
       3312470.827 6646884.839, 3312475.4 6646878.027, \
@@ -114,7 +116,7 @@ namespace tut
       3312468.253 6646874.01, 3312463.52 6646875.779, \
       3312459.605 6646878.353))");
 
-		std::string wkt_expected("POLYGON (( \
+    std::string wkt_expected("POLYGON (( \
       3312459.605 6646878.353, \
       3312460.524 6646875.969, \
       3312459.427 6646878.421, \
@@ -126,207 +128,219 @@ namespace tut
       3312459.605 6646878.353))");
 
     GeomPtr g(wktreader.read(wkt));
-		GeomPtr simplified = TopologyPreservingSimplifier::simplify(g.get(), 2.0);
+    GeomPtr simplified = TopologyPreservingSimplifier::simplify(g.get(), 2.0);
 
-		ensure( "Simplified geometry is invalid!", simplified->isValid() );
+    ensure("Simplified geometry is invalid!", simplified->isValid());
 
     GeomPtr g_expected(wktreader.read(wkt_expected));
-    ensure( g_expected->equalsExact(simplified.get()) );
+    ensure(g_expected->equalsExact(simplified.get()));
 
-	}
+}
 
-	// PolygonNoReduction
-	template<>
-	template<>
-	void object::test<5>()
-	{
-		std::string wkt("POLYGON((20 220, 40 220, 60 220, 80 220, \
+// PolygonNoReduction
+template<>
+template<>
+void object::test<5>
+()
+{
+    std::string wkt("POLYGON((20 220, 40 220, 60 220, 80 220, \
                     100 220, 120 220, 140 220, 140 180, 100 180, \
                     60 180, 20 180, 20 220))");
 
-		GeomPtr g(wktreader.read(wkt));
-		GeomPtr simplified = TopologyPreservingSimplifier::simplify(g.get(), 10.0);
+    GeomPtr g(wktreader.read(wkt));
+    GeomPtr simplified = TopologyPreservingSimplifier::simplify(g.get(), 10.0);
 
-		ensure( "Simplified geometry is invalid!", simplified->isValid() );
-		ensure( "Simplified and original geometry inequal", simplified->equals(g.get()) );
-        ensure_equals_geometry( g.get(), simplified.get() );
-	}
+    ensure("Simplified geometry is invalid!", simplified->isValid());
+    ensure("Simplified and original geometry inequal", simplified->equals(g.get()));
+    ensure_equals_geometry(g.get(), simplified.get());
+}
 
-  // PolygonNoReductionWithConflicts
-	template<>
-	template<>
-	void object::test<6>()
-	{
+// PolygonNoReductionWithConflicts
+template<>
+template<>
+void object::test<6>
+()
+{
     std::string wkt("POLYGON ((40 240, 160 241, 280 240, 280 160, \
                         160 240, 40 140, 40 240))");
 
     GeomPtr g(wktreader.read(wkt));
-		GeomPtr simplified = TopologyPreservingSimplifier::simplify(g.get(), 10.0);
+    GeomPtr simplified = TopologyPreservingSimplifier::simplify(g.get(), 10.0);
 
-		ensure( "Simplified geometry is invalid!", simplified->isValid() );
-		ensure( "Topology has been changed by simplification!", simplified->equals(g.get()) );
-        ensure_equals_geometry( g.get(), simplified.get() );
-    }
+    ensure("Simplified geometry is invalid!", simplified->isValid());
+    ensure("Topology has been changed by simplification!", simplified->equals(g.get()));
+    ensure_equals_geometry(g.get(), simplified.get());
+}
 
-    // PolygonWithTouchingHole
-	template<>
-	template<>
-	void object::test<7>()
-	{
-        std::string wkt("POLYGON ((80 200, 240 200, 240 60, 80 60, 80 200), \
+// PolygonWithTouchingHole
+template<>
+template<>
+void object::test<7>
+()
+{
+    std::string wkt("POLYGON ((80 200, 240 200, 240 60, 80 60, 80 200), \
                     (120 120, 220 120, 180 199, 160 200, 140 199, 120 120))");
 
-        std::string wkt_expected("POLYGON ((80 200, 240 200, 240 60, 80 60, 80 200), \
+    std::string wkt_expected("POLYGON ((80 200, 240 200, 240 60, 80 60, 80 200), \
                     (120 120, 220 120, 180 199, 160 200, 140 199, 120 120))");
 
-        GeomPtr g(wktreader.read(wkt));
-		GeomPtr simplified = TopologyPreservingSimplifier::simplify(g.get(), 10.0);
+    GeomPtr g(wktreader.read(wkt));
+    GeomPtr simplified = TopologyPreservingSimplifier::simplify(g.get(), 10.0);
 
-		ensure( "Simplified geometry is invalid!", simplified->isValid() );
-        ensure_equals_geometry( g.get(), simplified.get() );
+    ensure("Simplified geometry is invalid!", simplified->isValid());
+    ensure_equals_geometry(g.get(), simplified.get());
 
-        GeomPtr g_expected(wktreader.read(wkt_expected));
+    GeomPtr g_expected(wktreader.read(wkt_expected));
 
-        ensure( g_expected->equalsExact(simplified.get()) );
-    }
+    ensure(g_expected->equalsExact(simplified.get()));
+}
 
-    // FlattishPolygon
-	template<>
-	template<>
-	void object::test<8>()
-	{
-        std::string wkt("POLYGON ((0 0, 50 0, 53 0, 55 0, 100 0, \
+// FlattishPolygon
+template<>
+template<>
+void object::test<8>
+()
+{
+    std::string wkt("POLYGON ((0 0, 50 0, 53 0, 55 0, 100 0, \
                     70 1, 60 1, 50 1, 40 1, 0 0))");
 
-        GeomPtr g(wktreader.read(wkt));
-		GeomPtr simplified = TopologyPreservingSimplifier::simplify(g.get(), 10.0);
+    GeomPtr g(wktreader.read(wkt));
+    GeomPtr simplified = TopologyPreservingSimplifier::simplify(g.get(), 10.0);
 
-		ensure( "Simplified geometry is invalid!", simplified->isValid() );
-        ensure_equals_geometry( g.get(), simplified.get() );
-    }
+    ensure("Simplified geometry is invalid!", simplified->isValid());
+    ensure_equals_geometry(g.get(), simplified.get());
+}
 
-    // PolygonWithFlattishHole
-    template<>
-	template<>
-	void object::test<9>()
-	{
-        std::string wkt("POLYGON ((0 0, 0 200, 200 200, 200 0, 0 0), \
+// PolygonWithFlattishHole
+template<>
+template<>
+void object::test<9>
+()
+{
+    std::string wkt("POLYGON ((0 0, 0 200, 200 200, 200 0, 0 0), \
                     (140 40, 90 95, 40 160, 95 100, 140 40))");
 
-        GeomPtr g(wktreader.read(wkt));
-        GeomPtr g_expected(wktreader.read(wkt));
+    GeomPtr g(wktreader.read(wkt));
+    GeomPtr g_expected(wktreader.read(wkt));
 
-		GeomPtr simplified = TopologyPreservingSimplifier::simplify(g.get(), 10.0);
+    GeomPtr simplified = TopologyPreservingSimplifier::simplify(g.get(), 10.0);
 
-		ensure( "Simplified geometry is invalid!", simplified->isValid() );
-        ensure_equals_geometry( g.get(), simplified.get() );
-        ensure( g_expected->equalsExact(simplified.get()) );
-    }
+    ensure("Simplified geometry is invalid!", simplified->isValid());
+    ensure_equals_geometry(g.get(), simplified.get());
+    ensure(g_expected->equalsExact(simplified.get()));
+}
 
-    // TinySquare
-    template<>
-	template<>
-	void object::test<10>()
-	{
-        std::string wkt("POLYGON ((0 5, 5 5, 5 0, 0 0, 0 1, 0 5))");
+// TinySquare
+template<>
+template<>
+void object::test<10>
+()
+{
+    std::string wkt("POLYGON ((0 5, 5 5, 5 0, 0 0, 0 1, 0 5))");
 
-        GeomPtr g(wktreader.read(wkt));
-		GeomPtr simplified = TopologyPreservingSimplifier::simplify(g.get(), 10.0);
+    GeomPtr g(wktreader.read(wkt));
+    GeomPtr simplified = TopologyPreservingSimplifier::simplify(g.get(), 10.0);
 
-		ensure( "Simplified geometry is invalid!", simplified->isValid() );
-        ensure_equals_geometry( g.get(), simplified.get() );
-    }
+    ensure("Simplified geometry is invalid!", simplified->isValid());
+    ensure_equals_geometry(g.get(), simplified.get());
+}
 
-  // TinyLineString
-  template<>
-	template<>
-	void object::test<11>()
-	{
+// TinyLineString
+template<>
+template<>
+void object::test<11>
+()
+{
     std::string wkt("LINESTRING (0 5, 1 5, 2 5, 5 5)");
 
     GeomPtr g(wktreader.read(wkt));
-		GeomPtr simplified = TopologyPreservingSimplifier::simplify(g.get(), 10.0);
+    GeomPtr simplified = TopologyPreservingSimplifier::simplify(g.get(), 10.0);
 
-		ensure( "Simplified geometry is invalid!", simplified->isValid() );
-    ensure_equals_geometry(g.get(), simplified.get() );
-  }
+    ensure("Simplified geometry is invalid!", simplified->isValid());
+    ensure_equals_geometry(g.get(), simplified.get());
+}
 
-  // TinyClosedLineString
-  template<>
-  template<>
-  void object::test<12>()
-  {
+// TinyClosedLineString
+template<>
+template<>
+void object::test<12>
+()
+{
     std::string wkt("LINESTRING (0 0, 5 0, 5 5, 0 0)");
 
     GeomPtr g(wktreader.read(wkt));
     GeomPtr simplified = TopologyPreservingSimplifier::simplify(g.get(), 10.0);
 
-    ensure( "Simplified geometry is invalid!", simplified->isValid() );
-    ensure_equals_geometry(g.get(), simplified.get() );
-  }
+    ensure("Simplified geometry is invalid!", simplified->isValid());
+    ensure_equals_geometry(g.get(), simplified.get());
+}
 
-  // MultiPoint
-  template<>
-	template<>
-	void object::test<13>()
-	{
-        std::string wkt("MULTIPOINT(80 200, 240 200, 240 60, \
+// MultiPoint
+template<>
+template<>
+void object::test<13>
+()
+{
+    std::string wkt("MULTIPOINT(80 200, 240 200, 240 60, \
                     80 60, 80 200, 140 199, 120 120)");
 
-        GeomPtr g(wktreader.read(wkt));
-		GeomPtr simplified = TopologyPreservingSimplifier::simplify(g.get(), 10.0);
+    GeomPtr g(wktreader.read(wkt));
+    GeomPtr simplified = TopologyPreservingSimplifier::simplify(g.get(), 10.0);
 
-		ensure( "Simplified geometry is invalid!", simplified->isValid() );
-        ensure_equals_geometry(g.get(), simplified.get() );
-    }
+    ensure("Simplified geometry is invalid!", simplified->isValid());
+    ensure_equals_geometry(g.get(), simplified.get());
+}
 
-    // MultiLineString
-    template<>
-	template<>
-	void object::test<14>()
-	{
-        std::string wkt("MULTILINESTRING((0 0, 50 0, 70 0, 80 0, 100 0), \
+// MultiLineString
+template<>
+template<>
+void object::test<14>
+()
+{
+    std::string wkt("MULTILINESTRING((0 0, 50 0, 70 0, 80 0, 100 0), \
                     (0 0, 50 1, 60 1, 100 0))");
 
-        GeomPtr g(wktreader.read(wkt));
-		GeomPtr simplified = TopologyPreservingSimplifier::simplify(g.get(), 10.0);
+    GeomPtr g(wktreader.read(wkt));
+    GeomPtr simplified = TopologyPreservingSimplifier::simplify(g.get(), 10.0);
 
-		ensure( "Simplified geometry is invalid!", simplified->isValid() );
-        ensure_equals_geometry(g.get(), simplified.get() );
-    }
+    ensure("Simplified geometry is invalid!", simplified->isValid());
+    ensure_equals_geometry(g.get(), simplified.get());
+}
 
-    // GeometryCollection
-    template<>
-	template<>
-	void object::test<15>()
-	{
-        std::string wkt("GEOMETRYCOLLECTION ( \
+// GeometryCollection
+template<>
+template<>
+void object::test<15>
+()
+{
+    std::string wkt("GEOMETRYCOLLECTION ( \
                     MULTIPOINT (80 200, 240 200, 240 60, 80 60, 80 200, 140 199, 120 120), \
                     POLYGON ((80 200, 240 200, 240 60, 80 60, 80 200)), \
                     LINESTRING (80 200, 240 200, 240 60, 80 60, 80 200, 140 199, 120 120))");
 
-        GeomPtr g(wktreader.read(wkt));
-		GeomPtr simplified = TopologyPreservingSimplifier::simplify(g.get(), 10.0);
+    GeomPtr g(wktreader.read(wkt));
+    GeomPtr simplified = TopologyPreservingSimplifier::simplify(g.get(), 10.0);
 
-		ensure( "Simplified geometry is invalid!", simplified->isValid() );
-        ensure_equals_geometry(g.get(), simplified.get() );
-    }
+    ensure("Simplified geometry is invalid!", simplified->isValid());
+    ensure_equals_geometry(g.get(), simplified.get());
+}
 
-    // GeometryCollection with empty elements
-    // See http://trac.osgeo.org/geos/ticket/519
-    template<>
-    template<>
-    void object::test<16>()
-    {
-        std::string wkt("GEOMETRYCOLLECTION ( \
+// GeometryCollection with empty elements
+// See http://trac.osgeo.org/geos/ticket/519
+template<>
+template<>
+void object::test<16>
+()
+{
+    std::string wkt("GEOMETRYCOLLECTION ( \
                     LINESTRING (0 0, 10 0), POLYGON EMPTY)");
 
-        GeomPtr g(wktreader.read(wkt));
-        GeomPtr simp= TopologyPreservingSimplifier::simplify(g.get(), 1);
+    GeomPtr g(wktreader.read(wkt));
+    GeomPtr simp = TopologyPreservingSimplifier::simplify(g.get(), 1);
 
-        ensure( "Simplified geometry is invalid!", simp->isValid() );
-        ensure_equals(wktwriter.write(simp.get()),
-          "GEOMETRYCOLLECTION (LINESTRING (0 0, 10 0))");
-    }
+    ensure("Simplified geometry is invalid!", simp->isValid());
+    ensure_equals(wktwriter.write(simp.get()),
+                  "GEOMETRYCOLLECTION (LINESTRING (0 0, 10 0))");
+}
 } // namespace tut
 
diff --git a/tests/unit/triangulate/DelaunayTest.cpp b/tests/unit/triangulate/DelaunayTest.cpp
index 0467b20..5cdb7d3 100644
--- a/tests/unit/triangulate/DelaunayTest.cpp
+++ b/tests/unit/triangulate/DelaunayTest.cpp
@@ -21,190 +21,214 @@ using namespace geos::triangulate::quadedge;
 using namespace geos::geom;
 using namespace geos::io;
 
-namespace tut
+namespace tut {
+//
+// Test Group
+//
+
+// dummy data, not used
+struct test_incdelaunaytri_data {
+    test_incdelaunaytri_data()
+    {
+    }
+};
+
+typedef test_group<test_incdelaunaytri_data> group;
+typedef group::object object;
+
+group test_incdelaunaytri_group("geos::triangulate::Delaunay");
+
+//helper function for funning triangulation
+void
+runDelaunay(const char* sitesWkt, bool computeTriangles, const char* expectedWkt, double tolerance = 0.0)
 {
-	//
-	// Test Group
-	//
-
-	// dummy data, not used
-	struct test_incdelaunaytri_data
-	{
-		test_incdelaunaytri_data()
-		{
-		}
-	};
-
-	typedef test_group<test_incdelaunaytri_data> group;
-	typedef group::object object;
-
-	group test_incdelaunaytri_group("geos::triangulate::Delaunay");
-
-	//helper function for funning triangulation
-	void runDelaunay(const char *sitesWkt, bool computeTriangles, const char *expectedWkt, double tolerance=0.0)
-	{
-		WKTReader reader;
-		std::unique_ptr<Geometry> results;
-		Geometry *sites = reader.read(sitesWkt);
-		Geometry *expected = reader.read(expectedWkt);
-		DelaunayTriangulationBuilder builder;
-		builder.setTolerance(tolerance);
+    WKTReader reader;
+    std::unique_ptr<Geometry> results;
+    Geometry* sites = reader.read(sitesWkt);
+    Geometry* expected = reader.read(expectedWkt);
+    DelaunayTriangulationBuilder builder;
+    builder.setTolerance(tolerance);
     const GeometryFactory& geomFact(*GeometryFactory::getDefaultInstance());
 
-		builder.setSites(*sites);
-		if(computeTriangles)
-			results=builder.getTriangles(geomFact);
-		else
-			results=builder.getEdges(geomFact);
+    builder.setSites(*sites);
+    if(computeTriangles) {
+        results = builder.getTriangles(geomFact);
+    }
+    else {
+        results = builder.getEdges(geomFact);
+    }
 
-		results->normalize();
-		expected->normalize();
+    results->normalize();
+    expected->normalize();
 
-		ensure(results->toString(), results->equalsExact(expected, 1e-7));
-		ensure_equals(results->getCoordinateDimension(), expected->getCoordinateDimension());
+    ensure(results->toString(), results->equalsExact(expected, 1e-7));
+    ensure_equals(results->getCoordinateDimension(), expected->getCoordinateDimension());
 
-		delete sites;
-		delete expected;
-	}
+    delete sites;
+    delete expected;
+}
 
-	//
-	// Test Cases
-	//
+//
+// Test Cases
+//
 
-	// 1 - Basic function test
-	template<>
-	template<>
-	void object::test<1>()
-	{
-		//Create a subdivision centered at (0,0)
-		QuadEdgeSubdivision sub(Envelope(-100, 100, -100, 100), .00001);
-		//make a triagulaor to work on sub
-		IncrementalDelaunayTriangulator triangulator(&sub);
+// 1 - Basic function test
+template<>
+template<>
+void object::test<1>
+()
+{
+    //Create a subdivision centered at (0,0)
+    QuadEdgeSubdivision sub(Envelope(-100, 100, -100, 100), .00001);
+    //make a triagulaor to work on sub
+    IncrementalDelaunayTriangulator triangulator(&sub);
 
-		triangulator.insertSite(Vertex(0, 0));
+    triangulator.insertSite(Vertex(0, 0));
 
-		//extract the triangles from the subdivision
+    //extract the triangles from the subdivision
     const GeometryFactory& geomFact(*GeometryFactory::getDefaultInstance());
-		std::unique_ptr<GeometryCollection> tris = sub.getTriangles(geomFact);
-	}
-
-	// 2 - Test Triangle
-	template<>
-	template<>
-	void object::test<2>()
-	{
-		const char * wkt = "MULTIPOINT ((10 10), (10 20), (20 20))";
-		const char* expectedEdges = "MULTILINESTRING ((10 20, 20 20), (10 10, 10 20), (10 10, 20 20))";
-		const char * expectedTri = "GEOMETRYCOLLECTION (POLYGON ((10 20, 10 10, 20 20, 10 20)))";
-
-		runDelaunay(wkt, true, expectedTri);
-		runDelaunay(wkt, false, expectedEdges);
-	}
-
-	// 3 - Test Random
-	template<>
-	template<>
-	void object::test<3>()
-	{
-		const char* wkt = "MULTIPOINT ((50 40), (140 70), (80 100), (130 140), (30 150), (70 180), (190 110), (120 20))";
-		const char* expectedEdges = "MULTILINESTRING ((70 180, 190 110), (30 150, 70 180), (30 150, 50 40), (50 40, 120 20), (190 110, 120 20), (120 20, 140 70), (190 110, 140 70), (130 140, 140 70), (130 140, 190 110), (70 180, 130 140), (80 100, 130 140), (70 180, 80 100), (30 150, 80 100), (50 40, 80 100), (80 100, 120 20), (80 100, 140 70))";
-		const char* expectedTri = "GEOMETRYCOLLECTION (POLYGON ((30 150, 50 40, 80 100, 30 150)), POLYGON ((30 150, 80 100, 70 180, 30 150)), POLYGON ((70 180, 80 100, 130 140, 70 180)), POLYGON ((70 180, 130 140, 190 110, 70 180)), POLYGON ((190 110, 130 140, 140 70, 190 110)), POLYGON ((190 110, 140 70, 120 20, 190 110)), POLYGON ((120 20, 140 70, 80 100, 120 20)), POLYGON ((120 20, 80 100, 50 40, 120 20)), POLYGON ((80 100, 140 70, 130 140, 80 100)))";
-
-		runDelaunay(wkt, false, expectedEdges);
-		runDelaunay(wkt, true, expectedTri);
-	}
-
-	// 4 - Test grid
-	template<>
-	template<>
-	void object::test<4>()
-	{
-		const char * wkt = "MULTIPOINT ((10 10), (10 20), (20 20), (20 10), (20 0), (10 0), (0 0), (0 10), (0 20))";
-		const char* expectedEdges = "MULTILINESTRING ((10 20, 20 20), (0 20, 10 20), (0 10, 0 20), (0 0, 0 10), (0 0, 10 0), (10 0, 20 0), (20 0, 20 10), (20 10, 20 20), (10 20, 20 10), (10 10, 20 10), (10 10, 10 20), (10 10, 0 20), (10 10, 0 10), (10 0, 10 10), (0 10, 10 0), (10 10, 20 0))";
-		const char * expectedTri = "GEOMETRYCOLLECTION (POLYGON ((0 20, 0 10, 10 10, 0 20)), POLYGON ((0 20, 10 10, 10 20, 0 20)), POLYGON ((10 20, 10 10, 20 10, 10 20)), POLYGON ((10 20, 20 10, 20 20, 10 20)), POLYGON ((10 0, 20 0, 10 10, 10 0)), POLYGON ((10 0, 10 10, 0 10, 10 0)), POLYGON ((10 0, 0 10, 0 0, 10 0)), POLYGON ((10 10, 20 0, 20 10, 10 10)))";
-
-		runDelaunay(wkt, false, expectedEdges);
-		runDelaunay(wkt, true, expectedTri);
-	}
-
-	// 5 - Test Circle
-	// Added a point inside to ensure single possible solution
-	template<>
-	template<>
-	void object::test<5>()
-	{
-		const char * wkt = "GEOMETRYCOLLECTION(POLYGON ((42 30, 41.96 29.61, 41.85 29.23, 41.66 28.89, 41.41 28.59, 41.11 28.34, 40.77 28.15, 40.39 28.04, 40 28, 39.61 28.04, 39.23 28.15, 38.89 28.34, 38.59 28.59, 38.34 28.89, 38.15 29.23, 38.04 29.61, 38 30, 38.04 30.39, 38.15 30.77, 38.34 31.11, 38.59 31.41, 38.89 31.66, 39.23 31.85, 39.61 31.96, 40 32, 40.39 31.96, 40.77 31.85, 41.11 31.66, 41.41 31.41, 41.66 31.11, 41.85 30.77, 41.96 30.39, 42 30)), POINT(38.6 30))";
-		const char* expectedEdges = "MULTILINESTRING((41.96 30.39,42 30),(41.96 29.61,42 30),(41.85 30.77,41.96 30.39),(41.85 29.23,41.96 29.61),(41.66 31.11,41.85 30.77),(41.66 28.89,41.85 29.23),(41.41 31.41,41.66 31.11),(41.41 28.59,41.66 28.89),(41.11 31.66,41.41 31.41),(41.11 28.34,41.41 28.59),(40.77 31.85,41.11 31.66),(40.77 28.15,41.11 28.34),(40.39 31.96,40.77 31.85),(40.39 28.04,40.77 28.15),(40 32,40.39 31.96),(40 28,40.39 28.04),(39.61 31.96,40 32),(39.61 28.04,40 28),(39.23 31.85,39.61 31.96),(39.23 28.15,39.61 28.04),(38.89 31.66,39.23 31.85),(38.89 28.34,39.23 28.15),(38.6 30,42 30),(38.6 30,41.96 30.39),(38.6 30,41.96 29.61),(38.6 30,41.85 30.77),(38.6 30,41.85 29.23),(38.6 30,41.66 31.11),(38.6 30,41.66 28.89),(38.6 30,41.41 31.41),(38.6 30,41.41 28.59),(38.6 30,41.11 31.66),(38.6 30,41.11 28.34),(38.6 30,40.77 31.85),(38.6 30,40.77 28.15),(38.6 30,40.39 31.96),(38.6 30,40.39 28.04),(38.6 30,40 32),(38.6 30,40 28),(38.6 30,39.61 31.96),(38.6 30,39.61 28.04),(38.6 30,39.23
  31.85),(38.6 30,39.23 28.15),(38.6 30,38.89 31.66),(38.6 30,38.89 28.34),(38.59 31.41,38.89 31.66),(38.59 31.41,38.6 30),(38.59 28.59,38.89 28.34),(38.59 28.59,38.6 30),(38.34 31.11,38.6 30),(38.34 31.11,38.59 31.41),(38.34 28.89,38.6 30),(38.34 28.89,38.59 28.59),(38.15 30.77,38.6 30),(38.15 30.77,38.34 31.11),(38.15 29.23,38.6 30),(38.15 29.23,38.34 28.89),(38.04 30.39,38.6 30),(38.04 30.39,38.15 30.77),(38.04 29.61,38.6 30),(38.04 29.61,38.15 29.23),(38 30,38.6 30),(38 30,38.04 30.39),(38 30,38.04 29.61))";
-
-		runDelaunay(wkt, false, expectedEdges);
-	}
-
-	// 6 - Test Polygon With Chevron Holes
-	template<>
-	template<>
-	void object::test<6>()
-	{
-		const char * wkt = "POLYGON ((0 0, 0 200, 180 200, 180 0, 0 0), (20 180, 160 180, 160 20, 152.625 146.75, 20 180), (30 160, 150 30, 70 90, 30 160))";
-		const char* expectedEdges = "MULTILINESTRING ((0 200, 180 200), (0 0, 0 200), (0 0, 180 0), (180 200, 180 0), (152.625 146.75, 180 0), (152.625 146.75, 180 200), (152.625 146.75, 160 180), (160 180, 180 200), (0 200, 160 180), (20 180, 160 180), (0 200, 20 180), (20 180, 30 160), (30 160, 0 200), (0 0, 30 160), (30 160, 70 90), (0 0, 70 90), (70 90, 150 30), (150 30, 0 0), (150 30, 160 20), (0 0, 160 20), (160 20, 180 0), (152.625 146.75, 160 20), (150 30, 152.625 146.75), (70 90, 152.625 146.75), (30 160, 152.625 146.75), (30 160, 160 180))";
-
-		runDelaunay(wkt, false, expectedEdges);
-	}
-
-	// 7 - Test grid (2.5d)
-	template<>
-	template<>
-	void object::test<7>()
-	{
-		const char * wkt = "MULTIPOINT ((10 10 1), (10 20 2), (20 20 3), (20 10 1.5), (20 0 2.5), (10 0 3.5), (0 0 0), (0 10 .5), (0 20 .25))";
-		const char* expectedEdges = "MULTILINESTRING ((10 20 2, 20 20 3), (0 20 .25, 10 20 2), (0 10 .5, 0 20 .25), (0 0 0, 0 10 .5), (0 0 0, 10 0 3.5), (10 0 3.5, 20 0 2.5), (20 0 2.5, 20 10 1.5), (20 10 1.5, 20 20 3), (10 20 2, 20 10 1.5), (10 10 1, 20 10 1.6), (10 10 1, 10 20 2), (10 10 1, 0 20 .25), (10 10 1, 0 10 .5), (10 0 3.5, 10 10 1), (0 10 .5, 10 0 3.5), (10 10 1, 20 0 2.5))";
-		const char * expectedTri = "GEOMETRYCOLLECTION (POLYGON ((0 20 .25, 0 10 .5, 10 10 1, 0 20 .25)), POLYGON ((0 20 .25, 10 10 1, 10 20 2, 0 20 .25)), POLYGON ((10 20 2, 10 10 1, 20 10 1.5, 10 20 2)), POLYGON ((10 20 2, 20 10 1.5, 20 20 3, 10 20 2)), POLYGON ((10 0 3.5, 20 0 2.5, 10 10 1, 10 0 3.5)), POLYGON ((10 0 3.5, 10 10 1, 0 10 .5, 10 0 3.5)), POLYGON ((10 0 3.5, 0 10 .5, 0 0 0, 10 0 3.5)), POLYGON ((10 10 1, 20 0 2.5, 20 10 1.5, 10 10 1)))";
-
-		runDelaunay(wkt, false, expectedEdges);
-		runDelaunay(wkt, true, expectedTri);
-	}
-
-	// 8 - Tolerance robustness - http://trac.osgeo.org/geos/ticket/604
-	template<>
-	template<>
-	void object::test<8>()
-	{
-		const char * wkt = "MULTIPOINT(-118.3964065 56.0557,-118.396406 56.0475,-118.396407 56.04,-118.3968 56)";
-		const char* expectedEdges = "MULTILINESTRING ((-118.3964065 56.0557, -118.396406 56.0475), (-118.396407 56.04, -118.396406 56.0475), (-118.3968 56, -118.396407 56.04))";
-
-		runDelaunay(wkt, false, expectedEdges, 0.001);
-	}
-
-	// 9 - Test for DelaunayTriangulationBuilder::envelope
-	template<>
-	template<>
-	void object::test<9>()
-	{
-		std::vector<Coordinate>* v = new std::vector<Coordinate>();
-		v->push_back( Coordinate (150,200) );
-		v->push_back( Coordinate (180,270) );
-		v->push_back( Coordinate (275,163) );
-		geos::geom::CoordinateArraySequence seq(v);
-
-		Envelope env = DelaunayTriangulationBuilder::envelope(seq);
-
-		ensure_equals(env.getWidth() , 125);
-		ensure_equals(env.getHeight() , 107);
-	}
-
-	// 10 - Tolerance robustness
-	template<>
-	template<>
-	void object::test<10>()
-	{
-		const char * wkt = "MULTIPOINT(63.547558624186912368 70.904719023616522122,63.547558624186969212 70.904719023616564755,66.103648384371410884 68.588612471664760051,77.882918707497154287 74.870889977331813725,128.47759065022572145 177.65366864730182783)";
-		const char* expectedEdges = "GEOMETRYCOLLECTION (POLYGON ((63.5475586241869692 70.9047190236165648, 128.4775906502257214 177.6536686473018278, 77.8829187074971543 74.8708899773318137, 63.5475586241869692 70.9047190236165648)), POLYGON ((63.5475586241869692 70.9047190236165648, 77.8829187074971543 74.8708899773318137, 66.1036483843714109 68.5886124716647601, 63.5475586241869692 70.9047190236165648)), POLYGON ((63.5475586241869124 70.9047190236165221, 128.4775906502257214 177.6536686473018278, 63.5475586241869692 70.9047190236165648, 63.5475586241869124 70.9047190236165221)), POLYGON ((63.5475586241869124 70.9047190236165221, 63.5475586241869692 70.9047190236165648, 66.1036483843714109 68.5886124716647601, 63.5475586241869124 70.9047190236165221)))";
-
-		// inCircle predicate can't handle it on machines with 64-bit long double
-		if (sizeof(long double) > sizeof(double))
-		{
-			runDelaunay(wkt, true, expectedEdges, 0.0);
-		}
-	}
+    std::unique_ptr<GeometryCollection> tris = sub.getTriangles(geomFact);
+}
+
+// 2 - Test Triangle
+template<>
+template<>
+void object::test<2>
+()
+{
+    const char* wkt = "MULTIPOINT ((10 10), (10 20), (20 20))";
+    const char* expectedEdges = "MULTILINESTRING ((10 20, 20 20), (10 10, 10 20), (10 10, 20 20))";
+    const char* expectedTri = "GEOMETRYCOLLECTION (POLYGON ((10 20, 10 10, 20 20, 10 20)))";
+
+    runDelaunay(wkt, true, expectedTri);
+    runDelaunay(wkt, false, expectedEdges);
+}
+
+// 3 - Test Random
+template<>
+template<>
+void object::test<3>
+()
+{
+    const char* wkt = "MULTIPOINT ((50 40), (140 70), (80 100), (130 140), (30 150), (70 180), (190 110), (120 20))";
+    const char* expectedEdges =
+        "MULTILINESTRING ((70 180, 190 110), (30 150, 70 180), (30 150, 50 40), (50 40, 120 20), (190 110, 120 20), (120 20, 140 70), (190 110, 140 70), (130 140, 140 70), (130 140, 190 110), (70 180, 130 140), (80 100, 130 140), (70 180, 80 100), (30 150, 80 100), (50 40, 80 100), (80 100, 120 20), (80 100, 140 70))";
+    const char* expectedTri =
+        "GEOMETRYCOLLECTION (POLYGON ((30 150, 50 40, 80 100, 30 150)), POLYGON ((30 150, 80 100, 70 180, 30 150)), POLYGON ((70 180, 80 100, 130 140, 70 180)), POLYGON ((70 180, 130 140, 190 110, 70 180)), POLYGON ((190 110, 130 140, 140 70, 190 110)), POLYGON ((190 110, 140 70, 120 20, 190 110)), POLYGON ((120 20, 140 70, 80 100, 120 20)), POLYGON ((120 20, 80 100, 50 40, 120 20)), POLYGON ((80 100, 140 70, 130 140, 80 100)))";
+
+    runDelaunay(wkt, false, expectedEdges);
+    runDelaunay(wkt, true, expectedTri);
+}
+
+// 4 - Test grid
+template<>
+template<>
+void object::test<4>
+()
+{
+    const char* wkt = "MULTIPOINT ((10 10), (10 20), (20 20), (20 10), (20 0), (10 0), (0 0), (0 10), (0 20))";
+    const char* expectedEdges =
+        "MULTILINESTRING ((10 20, 20 20), (0 20, 10 20), (0 10, 0 20), (0 0, 0 10), (0 0, 10 0), (10 0, 20 0), (20 0, 20 10), (20 10, 20 20), (10 20, 20 10), (10 10, 20 10), (10 10, 10 20), (10 10, 0 20), (10 10, 0 10), (10 0, 10 10), (0 10, 10 0), (10 10, 20 0))";
+    const char* expectedTri =
+        "GEOMETRYCOLLECTION (POLYGON ((0 20, 0 10, 10 10, 0 20)), POLYGON ((0 20, 10 10, 10 20, 0 20)), POLYGON ((10 20, 10 10, 20 10, 10 20)), POLYGON ((10 20, 20 10, 20 20, 10 20)), POLYGON ((10 0, 20 0, 10 10, 10 0)), POLYGON ((10 0, 10 10, 0 10, 10 0)), POLYGON ((10 0, 0 10, 0 0, 10 0)), POLYGON ((10 10, 20 0, 20 10, 10 10)))";
+
+    runDelaunay(wkt, false, expectedEdges);
+    runDelaunay(wkt, true, expectedTri);
+}
+
+// 5 - Test Circle
+// Added a point inside to ensure single possible solution
+template<>
+template<>
+void object::test<5>
+()
+{
+    const char* wkt =
+        "GEOMETRYCOLLECTION(POLYGON ((42 30, 41.96 29.61, 41.85 29.23, 41.66 28.89, 41.41 28.59, 41.11 28.34, 40.77 28.15, 40.39 28.04, 40 28, 39.61 28.04, 39.23 28.15, 38.89 28.34, 38.59 28.59, 38.34 28.89, 38.15 29.23, 38.04 29.61, 38 30, 38.04 30.39, 38.15 30.77, 38.34 31.11, 38.59 31.41, 38.89 31.66, 39.23 31.85, 39.61 31.96, 40 32, 40.39 31.96, 40.77 31.85, 41.11 31.66, 41.41 31.41, 41.66 31.11, 41.85 30.77, 41.96 30.39, 42 30)), POINT(38.6 30))";
+    const char* expectedEdges =
+        "MULTILINESTRING((41.96 30.39,42 30),(41.96 29.61,42 30),(41.85 30.77,41.96 30.39),(41.85 29.23,41.96 29.61),(41.66 31.11,41.85 30.77),(41.66 28.89,41.85 29.23),(41.41 31.41,41.66 31.11),(41.41 28.59,41.66 28.89),(41.11 31.66,41.41 31.41),(41.11 28.34,41.41 28.59),(40.77 31.85,41.11 31.66),(40.77 28.15,41.11 28.34),(40.39 31.96,40.77 31.85),(40.39 28.04,40.77 28.15),(40 32,40.39 31.96),(40 28,40.39 28.04),(39.61 31.96,40 32),(39.61 28.04,40 28),(39.23 31.85,39.61 31.96),(39.23 28.15,39.61 28.04),(38.89 31.66,39.23 31.85),(38.89 28.34,39.23 28.15),(38.6 30,42 30),(38.6 30,41.96 30.39),(38.6 30,41.96 29.61),(38.6 30,41.85 30.77),(38.6 30,41.85 29.23),(38.6 30,41.66 31.11),(38.6 30,41.66 28.89),(38.6 30,41.41 31.41),(38.6 30,41.41 28.59),(38.6 30,41.11 31.66),(38.6 30,41.11 28.34),(38.6 30,40.77 31.85),(38.6 30,40.77 28.15),(38.6 30,40.39 31.96),(38.6 30,40.39 28.04),(38.6 30,40 32),(38.6 30,40 28),(38.6 30,39.61 31.96),(38.6 30,39.61 28.04),(38.6 30,39.23 31.85),(38.6 30,39.23
  28.15),(38.6 30,38.89 31.66),(38.6 30,38.89 28.34),(38.59 31.41,38.89 31.66),(38.59 31.41,38.6 30),(38.59 28.59,38.89 28.34),(38.59 28.59,38.6 30),(38.34 31.11,38.6 30),(38.34 31.11,38.59 31.41),(38.34 28.89,38.6 30),(38.34 28.89,38.59 28.59),(38.15 30.77,38.6 30),(38.15 30.77,38.34 31.11),(38.15 29.23,38.6 30),(38.15 29.23,38.34 28.89),(38.04 30.39,38.6 30),(38.04 30.39,38.15 30.77),(38.04 29.61,38.6 30),(38.04 29.61,38.15 29.23),(38 30,38.6 30),(38 30,38.04 30.39),(38 30,38.04 29.61))";
+
+    runDelaunay(wkt, false, expectedEdges);
+}
+
+// 6 - Test Polygon With Chevron Holes
+template<>
+template<>
+void object::test<6>
+()
+{
+    const char* wkt =
+        "POLYGON ((0 0, 0 200, 180 200, 180 0, 0 0), (20 180, 160 180, 160 20, 152.625 146.75, 20 180), (30 160, 150 30, 70 90, 30 160))";
+    const char* expectedEdges =
+        "MULTILINESTRING ((0 200, 180 200), (0 0, 0 200), (0 0, 180 0), (180 200, 180 0), (152.625 146.75, 180 0), (152.625 146.75, 180 200), (152.625 146.75, 160 180), (160 180, 180 200), (0 200, 160 180), (20 180, 160 180), (0 200, 20 180), (20 180, 30 160), (30 160, 0 200), (0 0, 30 160), (30 160, 70 90), (0 0, 70 90), (70 90, 150 30), (150 30, 0 0), (150 30, 160 20), (0 0, 160 20), (160 20, 180 0), (152.625 146.75, 160 20), (150 30, 152.625 146.75), (70 90, 152.625 146.75), (30 160, 152.625 146.75), (30 160, 160 180))";
+
+    runDelaunay(wkt, false, expectedEdges);
+}
+
+// 7 - Test grid (2.5d)
+template<>
+template<>
+void object::test<7>
+()
+{
+    const char* wkt =
+        "MULTIPOINT ((10 10 1), (10 20 2), (20 20 3), (20 10 1.5), (20 0 2.5), (10 0 3.5), (0 0 0), (0 10 .5), (0 20 .25))";
+    const char* expectedEdges =
+        "MULTILINESTRING ((10 20 2, 20 20 3), (0 20 .25, 10 20 2), (0 10 .5, 0 20 .25), (0 0 0, 0 10 .5), (0 0 0, 10 0 3.5), (10 0 3.5, 20 0 2.5), (20 0 2.5, 20 10 1.5), (20 10 1.5, 20 20 3), (10 20 2, 20 10 1.5), (10 10 1, 20 10 1.6), (10 10 1, 10 20 2), (10 10 1, 0 20 .25), (10 10 1, 0 10 .5), (10 0 3.5, 10 10 1), (0 10 .5, 10 0 3.5), (10 10 1, 20 0 2.5))";
+    const char* expectedTri =
+        "GEOMETRYCOLLECTION (POLYGON ((0 20 .25, 0 10 .5, 10 10 1, 0 20 .25)), POLYGON ((0 20 .25, 10 10 1, 10 20 2, 0 20 .25)), POLYGON ((10 20 2, 10 10 1, 20 10 1.5, 10 20 2)), POLYGON ((10 20 2, 20 10 1.5, 20 20 3, 10 20 2)), POLYGON ((10 0 3.5, 20 0 2.5, 10 10 1, 10 0 3.5)), POLYGON ((10 0 3.5, 10 10 1, 0 10 .5, 10 0 3.5)), POLYGON ((10 0 3.5, 0 10 .5, 0 0 0, 10 0 3.5)), POLYGON ((10 10 1, 20 0 2.5, 20 10 1.5, 10 10 1)))";
+
+    runDelaunay(wkt, false, expectedEdges);
+    runDelaunay(wkt, true, expectedTri);
+}
+
+// 8 - Tolerance robustness - http://trac.osgeo.org/geos/ticket/604
+template<>
+template<>
+void object::test<8>
+()
+{
+    const char* wkt = "MULTIPOINT(-118.3964065 56.0557,-118.396406 56.0475,-118.396407 56.04,-118.3968 56)";
+    const char* expectedEdges =
+        "MULTILINESTRING ((-118.3964065 56.0557, -118.396406 56.0475), (-118.396407 56.04, -118.396406 56.0475), (-118.3968 56, -118.396407 56.04))";
+
+    runDelaunay(wkt, false, expectedEdges, 0.001);
+}
+
+// 9 - Test for DelaunayTriangulationBuilder::envelope
+template<>
+template<>
+void object::test<9>
+()
+{
+    std::vector<Coordinate>* v = new std::vector<Coordinate>();
+    v->push_back(Coordinate(150, 200));
+    v->push_back(Coordinate(180, 270));
+    v->push_back(Coordinate(275, 163));
+    geos::geom::CoordinateArraySequence seq(v);
+
+    Envelope env = DelaunayTriangulationBuilder::envelope(seq);
+
+    ensure_equals(env.getWidth(), 125);
+    ensure_equals(env.getHeight(), 107);
+}
+
+// 10 - Tolerance robustness
+template<>
+template<>
+void object::test<10>
+()
+{
+    const char* wkt =
+        "MULTIPOINT(63.547558624186912368 70.904719023616522122,63.547558624186969212 70.904719023616564755,66.103648384371410884 68.588612471664760051,77.882918707497154287 74.870889977331813725,128.47759065022572145 177.65366864730182783)";
+    const char* expectedEdges =
+        "GEOMETRYCOLLECTION (POLYGON ((63.5475586241869692 70.9047190236165648, 128.4775906502257214 177.6536686473018278, 77.8829187074971543 74.8708899773318137, 63.5475586241869692 70.9047190236165648)), POLYGON ((63.5475586241869692 70.9047190236165648, 77.8829187074971543 74.8708899773318137, 66.1036483843714109 68.5886124716647601, 63.5475586241869692 70.9047190236165648)), POLYGON ((63.5475586241869124 70.9047190236165221, 128.4775906502257214 177.6536686473018278, 63.5475586241869692 70.9047190236165648, 63.5475586241869124 70.9047190236165221)), POLYGON ((63.5475586241869124 70.9047190236165221, 63.5475586241869692 70.9047190236165648, 66.1036483843714109 68.5886124716647601, 63.5475586241869124 70.9047190236165221)))";
+
+    // inCircle predicate can't handle it on machines with 64-bit long double
+    if(sizeof(long double) > sizeof(double)) {
+        runDelaunay(wkt, true, expectedEdges, 0.0);
+    }
+}
 
 
 } // namespace tut
diff --git a/tests/unit/triangulate/VoronoiTest.cpp b/tests/unit/triangulate/VoronoiTest.cpp
index 07d8a1c..a7539db 100644
--- a/tests/unit/triangulate/VoronoiTest.cpp
+++ b/tests/unit/triangulate/VoronoiTest.cpp
@@ -24,168 +24,185 @@ using namespace geos::triangulate::quadedge;
 using namespace geos::geom;
 using namespace geos::io;
 
-namespace tut
+namespace tut {
+//
+// Test Group
+//
+
+// dummy data, not used
+struct test_voronoidiag_data {
+    test_voronoidiag_data()
+    {
+    }
+};
+
+typedef test_group<test_voronoidiag_data> group;
+typedef group::object object;
+
+group test_voronoidiag_group("geos::triangulate::Voronoi");
+
+//helper function for funning triangulation
+void
+runVoronoi(const char* sitesWkt, const char* expectedWkt, const double tolerance)
 {
-	//
-	// Test Group
-	//
-
-	// dummy data, not used
-	struct test_voronoidiag_data
-	{
-		test_voronoidiag_data()
-		{
-		}
-	};
-
-	typedef test_group<test_voronoidiag_data> group;
-	typedef group::object object;
-
-	group test_voronoidiag_group("geos::triangulate::Voronoi");
-
-	//helper function for funning triangulation
-	void runVoronoi(const char *sitesWkt, const char *expectedWkt , const double tolerance)
-	{
-		WKTReader reader;
-		WKTWriter writer;
-		geos::triangulate::VoronoiDiagramBuilder builder;
-		std::unique_ptr<Geometry> sites ( reader.read(sitesWkt) );
-		std::unique_ptr<Geometry> expected ( reader.read(expectedWkt) );
-		std::unique_ptr<GeometryCollection> results;
+    WKTReader reader;
+    WKTWriter writer;
+    geos::triangulate::VoronoiDiagramBuilder builder;
+    std::unique_ptr<Geometry> sites(reader.read(sitesWkt));
+    std::unique_ptr<Geometry> expected(reader.read(expectedWkt));
+    std::unique_ptr<GeometryCollection> results;
     const GeometryFactory& geomFact(*GeometryFactory::getDefaultInstance());
-		builder.setSites(*sites);
-
-		//set Tolerance:
-		builder.setTolerance(tolerance);
-		results = builder.getDiagram(geomFact);
-
-		results->normalize();
-		expected->normalize();
-
-		ensure_equals(results->getCoordinateDimension(), expected->getCoordinateDimension());
-		bool eq = results->equalsExact(expected.get(), 1e-7);
-		if ( ! eq ) {
-			writer.setTrim(true);
-			cout << endl;
-			cout << " Expected: " << writer.write(expected.get()) << endl;
-			cout << " Obtained: " << writer.write(results.get()) << endl;
-		}
-		ensure(eq);
-
-	}
-
-	// Test Cases
-	// Basic Tests.
-	template<>
-	template<>
-	void object::test<1>()
-	{
-		using geos::geom::CoordinateSequence;
-		Coordinate a(180,300);
-		Coordinate b(300,290);
-		Coordinate c(230,330);
-		Coordinate d(244,284);
-
-		geos::triangulate::VoronoiDiagramBuilder builder;
-		std::unique_ptr< std::vector<Coordinate> > v(new std::vector<Coordinate>());
-		v->push_back(a);
-		v->push_back(b);
-		v->push_back(c);
-		v->push_back(d);
-
-		geos::geom::CoordinateArraySequence seq(v.release());
-		builder.setSites(seq);
-
-		//getting the subdiv()
-		std::unique_ptr<QuadEdgeSubdivision> subdiv = builder.getSubdivision();
-
-		ensure_equals(subdiv->getTolerance() , 0);
-		ensure_equals(subdiv->getEnvelope().toString(),"Env[-3540:4020,-3436:4050]");
-
-	}
-	// 1 - Case with a single point
-	template<>
-	template<>
-	void object::test<2>()
-	{
-		const char *wkt = "MULTIPOINT ((150 200))";
-		const char *expected = "GEOMETRYCOLLECTION EMPTY";
-		runVoronoi(wkt,expected,0);
-	}
-
-	template<>
-	template<>
-	void object::test<3>()
-	{
-		const char *wkt = "MULTIPOINT ((150 200), (180 270), (275 163))";
-
-		const char *expected = "GEOMETRYCOLLECTION (POLYGON ((25 38, 25 295, 221.20588235294116 210.91176470588235, 170.024 38, 25 38)), POLYGON ((400 369.6542056074766, 400 38, 170.024 38, 221.20588235294116 210.91176470588235, 400 369.6542056074766)), POLYGON ((25 295, 25 395, 400 395, 400 369.6542056074766, 221.20588235294116 210.91176470588235, 25 295)))";
-
-		runVoronoi(wkt,expected,0);
-	}
-
-	template<>
-	template<>
-	void object::test<4>()
-	{
-		const char *wkt = "MULTIPOINT ((280 300), (420 330), (380 230), (320 160))";
-
-		const char *expected = "GEOMETRYCOLLECTION (POLYGON ((110 175.71428571428572, 110 500, 310.35714285714283 500, 353.515625 298.59375, 306.875 231.96428571428572, 110 175.71428571428572)), POLYGON ((590 204, 590 -10, 589.1666666666666 -10, 306.875 231.96428571428572, 353.515625 298.59375, 590 204)), POLYGON ((110 -10, 110 175.71428571428572, 306.875 231.96428571428572, 589.1666666666666 -10, 110 -10)), POLYGON ((310.35714285714283 500, 590 500, 590 204, 353.515625 298.59375, 310.35714285714283 500)))";
-		runVoronoi(wkt,expected,0);
-	}
-
-	template<>
-	template<>
-	void object::test<5>()
-	{
-		const char *wkt = "MULTIPOINT ((320 170), (366 246), (530 230), (530 300), (455 277), (490 160))";
-
-		const char *expected = "GEOMETRYCOLLECTION (POLYGON ((110 -50, 110 349.02631578947364, 405.31091180866963 170.28550074738416, 392.35294117647055 -50, 110 -50)), POLYGON ((740 63.57142857142859, 740 -50, 392.35294117647055 -50, 405.31091180866963 170.28550074738416, 429.9147677857019 205.76082797008175, 470.12061711079946 217.7882187938289, 740 63.57142857142859)), POLYGON ((110 349.02631578947364, 110 510, 323.9438202247191 510, 429.9147677857019 205.76082797008175, 405.31091180866963 170.28550074738416, 110 349.02631578947364)),  POLYGON ((323.9438202247191 510, 424.57333333333327 510, 499.70666666666665 265, 470.12061711079946 217.7882187938289, 429.9147677857019 205.76082797008175, 323.9438202247191 510)),POLYGON ((740 265, 740 63.57142857142859, 470.12061711079946 217.7882187938289, 499.70666666666665 265, 740 265)), POLYGON ((424.57333333333327 510, 740 510, 740 265, 499.70666666666665 265, 424.57333333333327 510)))";
-		runVoronoi(wkt,expected,0);
-	}
-	//6. A little larger number of points
-	template<>
-	template<>
-	void object::test<6>()
-	{
-		const char *wkt = "MULTIPOINT ((280 200), (406 285), (580 280), (550 190), (370 190), (360 90), (480 110), (440 160), (450 180), (480 180), (460 160), (360 210), (360 220), (370 210), (375 227))";
-
-		const char *expected = "GEOMETRYCOLLECTION (POLYGON ((-20 -102.27272727272727, -20 585, 111.9484126984127 585, 293.54906542056074 315.803738317757, 318.75 215, 323.2352941176471 179.11764705882354, 319.3956043956044 144.56043956043956, -20 -102.27272727272727)), POLYGON ((365 200, 365 215, 369.40909090909093 219.4090909090909, 414.2119205298013 206.2317880794702, 411.875 200, 365 200)), POLYGON ((365 215, 365 200, 323.2352941176471 179.11764705882354, 318.75 215, 365 215)), POLYGON ((-20 -210, -20 -102.27272727272727, 319.3956043956044 144.56043956043956, 388.972602739726 137.60273972602738, 419.55882352941177 102.64705882352942, 471.66666666666674 -210, -20 -210)), POLYGON ((319.3956043956044 144.56043956043956, 323.2352941176471 179.11764705882354, 365 200, 411.875 200, 410.29411764705884 187.35294117647058, 388.972602739726 137.60273972602738, 319.3956043956044 144.56043956043956)), POLYGON ((410.29411764705884 187.35294117647058, 411.875 200, 414.2119205298013 206.231788079470
 2, 431.62536593766146 234.01920096435336, 465 248.0047619047619, 465 175, 450 167.5, 410.29411764705884 187.35294117647058)), POLYGON ((365 215, 318.75 215, 293.54906542056074 315.803738317757, 339.6500765696784 283.1784073506891, 369.40909090909093 219.4090909090909, 365 215)), POLYGON ((111.9484126984127 585, 501.69252873563215 585, 492.5670391061452 267.4329608938547, 465 248.0047619047619, 431.62536593766146 234.01920096435336, 339.6500765696784 283.1784073506891, 293.54906542056074 315.803738317757, 111.9484126984127 585)),  POLYGON ((369.40909090909093 219.4090909090909, 339.6500765696784 283.1784073506891, 431.62536593766146 234.01920096435336, 414.2119205298013 206.2317880794702, 369.40909090909093 219.4090909090909)), POLYGON ((388.972602739726 137.60273972602738, 410.29411764705884 187.35294117647058, 450 167.5, 450 127, 419.55882352941177 102.64705882352942, 388.972602739726 137.60273972602738)), POLYGON ((465 175, 465 248.0047619047619, 492.5670391061452 267.432960893854
 7, 505 255, 520.7142857142857 145, 495 145, 465 175)),POLYGON ((880 -169.375, 880 -210, 471.66666666666674 -210, 419.55882352941177 102.64705882352942, 450 127, 495 145, 520.7142857142857 145, 880 -169.375)), POLYGON ((450 167.5, 465 175, 495 145, 450 127, 450 167.5)), POLYGON ((501.69252873563215 585, 880 585, 880 130.00000000000006, 505 255, 492.5670391061452 267.4329608938547, 501.69252873563215 585)), POLYGON ((880 130.00000000000006, 880 -169.375, 520.7142857142857 145, 505 255, 880 130.00000000000006)))";
-
-		runVoronoi(wkt,expected,0);
-	}
-	//Test with case of Tolerance:
-	template<>
-	template<>
-	void object::test<7>()
-	{
-		const char *wkt = "MULTIPOINT ((100 200), (105 202), (110 200), (140 230), (210 240), (220 190), (170 170), (170 260), (213 245), (220 190))";
-
-		const char *expected = "GEOMETRYCOLLECTION (POLYGON ((-20 50, -20 380, -3.75 380, 105 235, 105 115, 77.14285714285714 50, -20 50)), POLYGON ((247 50, 77.14285714285714 50, 105 115, 145 195, 178.33333333333334 211.66666666666666, 183.51851851851853 208.7037037037037, 247 50)), POLYGON ((-3.75 380, 20.000000000000007 380, 176.66666666666666 223.33333333333334, 178.33333333333334 211.66666666666666, 145 195, 105 235, -3.75 380)), POLYGON ((105 115, 105 235, 145 195, 105 115)), POLYGON ((20.000000000000007 380, 255 380, 176.66666666666666 223.33333333333334, 20.000000000000007 380)), POLYGON ((255 380, 340 380, 340 240, 183.51851851851853 208.7037037037037, 178.33333333333334 211.66666666666666, 176.66666666666666 223.33333333333334, 255 380)), POLYGON ((340 240, 340 50, 247 50, 183.51851851851853 208.7037037037037, 340 240)))";
-
-		runVoronoi(wkt,expected,6);
-	}
-	template<>
-	template<>
-	void object::test<8>()
-	{
-		const char *wkt = "MULTIPOINT ((170 270), (177 275), (190 230), (230 250), (210 290), (240 280), (240 250))";
-
-		const char *expected = "GEOMETRYCOLLECTION (POLYGON ((100 210, 100 360, 150 360, 200 260, 100 210)), POLYGON ((150 360, 250 360, 220 270, 200 260, 150 360)), POLYGON ((100 160, 100 210, 200 260, 235 190, 247 160, 100 160)), POLYGON ((220 270, 235 265, 235 190, 200 260, 220 270)), POLYGON ((250 360, 310 360, 310 265, 235 265, 220 270, 250 360)), POLYGON ((310 265, 310 160, 247 160, 235 190, 235 265, 310 265)))";
-
-		runVoronoi(wkt,expected,10);
-	}
-	//Taking tolerance very very high
-	template<>
-	template<>
-	void object::test<9>()
-	{
-		const char *wkt = "MULTIPOINT ((155 271), (150 360), (260 360), (271 265), (280 260), (270 370), (154 354), (150 260))";
-
-		const char *expected = "GEOMETRYCOLLECTION (POLYGON ((20 130, 20 310, 205 310, 215 299, 215 130, 20 130)), POLYGON ((205 500, 410 500, 410 338, 215 299, 205 310, 205 500)), POLYGON ((20 310, 20 500, 205 500, 205 310, 20 310)), POLYGON ((410 338, 410 130, 215 130, 215 299, 410 338)))";
-
-		runVoronoi(wkt,expected,100);
-	}
+    builder.setSites(*sites);
+
+    //set Tolerance:
+    builder.setTolerance(tolerance);
+    results = builder.getDiagram(geomFact);
+
+    results->normalize();
+    expected->normalize();
+
+    ensure_equals(results->getCoordinateDimension(), expected->getCoordinateDimension());
+    bool eq = results->equalsExact(expected.get(), 1e-7);
+    if(! eq) {
+        writer.setTrim(true);
+        cout << endl;
+        cout << " Expected: " << writer.write(expected.get()) << endl;
+        cout << " Obtained: " << writer.write(results.get()) << endl;
+    }
+    ensure(eq);
+
+}
+
+// Test Cases
+// Basic Tests.
+template<>
+template<>
+void object::test<1>
+()
+{
+    using geos::geom::CoordinateSequence;
+    Coordinate a(180, 300);
+    Coordinate b(300, 290);
+    Coordinate c(230, 330);
+    Coordinate d(244, 284);
+
+    geos::triangulate::VoronoiDiagramBuilder builder;
+    std::unique_ptr< std::vector<Coordinate> > v(new std::vector<Coordinate>());
+    v->push_back(a);
+    v->push_back(b);
+    v->push_back(c);
+    v->push_back(d);
+
+    geos::geom::CoordinateArraySequence seq(v.release());
+    builder.setSites(seq);
+
+    //getting the subdiv()
+    std::unique_ptr<QuadEdgeSubdivision> subdiv = builder.getSubdivision();
+
+    ensure_equals(subdiv->getTolerance(), 0);
+    ensure_equals(subdiv->getEnvelope().toString(), "Env[-3540:4020,-3436:4050]");
+
+}
+// 1 - Case with a single point
+template<>
+template<>
+void object::test<2>
+()
+{
+    const char* wkt = "MULTIPOINT ((150 200))";
+    const char* expected = "GEOMETRYCOLLECTION EMPTY";
+    runVoronoi(wkt, expected, 0);
+}
+
+template<>
+template<>
+void object::test<3>
+()
+{
+    const char* wkt = "MULTIPOINT ((150 200), (180 270), (275 163))";
+
+    const char* expected =
+        "GEOMETRYCOLLECTION (POLYGON ((25 38, 25 295, 221.20588235294116 210.91176470588235, 170.024 38, 25 38)), POLYGON ((400 369.6542056074766, 400 38, 170.024 38, 221.20588235294116 210.91176470588235, 400 369.6542056074766)), POLYGON ((25 295, 25 395, 400 395, 400 369.6542056074766, 221.20588235294116 210.91176470588235, 25 295)))";
+
+    runVoronoi(wkt, expected, 0);
+}
+
+template<>
+template<>
+void object::test<4>
+()
+{
+    const char* wkt = "MULTIPOINT ((280 300), (420 330), (380 230), (320 160))";
+
+    const char* expected =
+        "GEOMETRYCOLLECTION (POLYGON ((110 175.71428571428572, 110 500, 310.35714285714283 500, 353.515625 298.59375, 306.875 231.96428571428572, 110 175.71428571428572)), POLYGON ((590 204, 590 -10, 589.1666666666666 -10, 306.875 231.96428571428572, 353.515625 298.59375, 590 204)), POLYGON ((110 -10, 110 175.71428571428572, 306.875 231.96428571428572, 589.1666666666666 -10, 110 -10)), POLYGON ((310.35714285714283 500, 590 500, 590 204, 353.515625 298.59375, 310.35714285714283 500)))";
+    runVoronoi(wkt, expected, 0);
+}
+
+template<>
+template<>
+void object::test<5>
+()
+{
+    const char* wkt = "MULTIPOINT ((320 170), (366 246), (530 230), (530 300), (455 277), (490 160))";
+
+    const char* expected =
+        "GEOMETRYCOLLECTION (POLYGON ((110 -50, 110 349.02631578947364, 405.31091180866963 170.28550074738416, 392.35294117647055 -50, 110 -50)), POLYGON ((740 63.57142857142859, 740 -50, 392.35294117647055 -50, 405.31091180866963 170.28550074738416, 429.9147677857019 205.76082797008175, 470.12061711079946 217.7882187938289, 740 63.57142857142859)), POLYGON ((110 349.02631578947364, 110 510, 323.9438202247191 510, 429.9147677857019 205.76082797008175, 405.31091180866963 170.28550074738416, 110 349.02631578947364)),  POLYGON ((323.9438202247191 510, 424.57333333333327 510, 499.70666666666665 265, 470.12061711079946 217.7882187938289, 429.9147677857019 205.76082797008175, 323.9438202247191 510)),POLYGON ((740 265, 740 63.57142857142859, 470.12061711079946 217.7882187938289, 499.70666666666665 265, 740 265)), POLYGON ((424.57333333333327 510, 740 510, 740 265, 499.70666666666665 265, 424.57333333333327 510)))";
+    runVoronoi(wkt, expected, 0);
+}
+//6. A little larger number of points
+template<>
+template<>
+void object::test<6>
+()
+{
+    const char* wkt =
+        "MULTIPOINT ((280 200), (406 285), (580 280), (550 190), (370 190), (360 90), (480 110), (440 160), (450 180), (480 180), (460 160), (360 210), (360 220), (370 210), (375 227))";
+
+    const char* expected =
+        "GEOMETRYCOLLECTION (POLYGON ((-20 -102.27272727272727, -20 585, 111.9484126984127 585, 293.54906542056074 315.803738317757, 318.75 215, 323.2352941176471 179.11764705882354, 319.3956043956044 144.56043956043956, -20 -102.27272727272727)), POLYGON ((365 200, 365 215, 369.40909090909093 219.4090909090909, 414.2119205298013 206.2317880794702, 411.875 200, 365 200)), POLYGON ((365 215, 365 200, 323.2352941176471 179.11764705882354, 318.75 215, 365 215)), POLYGON ((-20 -210, -20 -102.27272727272727, 319.3956043956044 144.56043956043956, 388.972602739726 137.60273972602738, 419.55882352941177 102.64705882352942, 471.66666666666674 -210, -20 -210)), POLYGON ((319.3956043956044 144.56043956043956, 323.2352941176471 179.11764705882354, 365 200, 411.875 200, 410.29411764705884 187.35294117647058, 388.972602739726 137.60273972602738, 319.3956043956044 144.56043956043956)), POLYGON ((410.29411764705884 187.35294117647058, 411.875 200, 414.2119205298013 206.2317880794702, 431.6253659376
 6146 234.01920096435336, 465 248.0047619047619, 465 175, 450 167.5, 410.29411764705884 187.35294117647058)), POLYGON ((365 215, 318.75 215, 293.54906542056074 315.803738317757, 339.6500765696784 283.1784073506891, 369.40909090909093 219.4090909090909, 365 215)), POLYGON ((111.9484126984127 585, 501.69252873563215 585, 492.5670391061452 267.4329608938547, 465 248.0047619047619, 431.62536593766146 234.01920096435336, 339.6500765696784 283.1784073506891, 293.54906542056074 315.803738317757, 111.9484126984127 585)),  POLYGON ((369.40909090909093 219.4090909090909, 339.6500765696784 283.1784073506891, 431.62536593766146 234.01920096435336, 414.2119205298013 206.2317880794702, 369.40909090909093 219.4090909090909)), POLYGON ((388.972602739726 137.60273972602738, 410.29411764705884 187.35294117647058, 450 167.5, 450 127, 419.55882352941177 102.64705882352942, 388.972602739726 137.60273972602738)), POLYGON ((465 175, 465 248.0047619047619, 492.5670391061452 267.4329608938547, 505 255, 520.7
 142857142857 145, 495 145, 465 175)),POLYGON ((880 -169.375, 880 -210, 471.66666666666674 -210, 419.55882352941177 102.64705882352942, 450 127, 495 145, 520.7142857142857 145, 880 -169.375)), POLYGON ((450 167.5, 465 175, 495 145, 450 127, 450 167.5)), POLYGON ((501.69252873563215 585, 880 585, 880 130.00000000000006, 505 255, 492.5670391061452 267.4329608938547, 501.69252873563215 585)), POLYGON ((880 130.00000000000006, 880 -169.375, 520.7142857142857 145, 505 255, 880 130.00000000000006)))";
+
+    runVoronoi(wkt, expected, 0);
+}
+//Test with case of Tolerance:
+template<>
+template<>
+void object::test<7>
+()
+{
+    const char* wkt =
+        "MULTIPOINT ((100 200), (105 202), (110 200), (140 230), (210 240), (220 190), (170 170), (170 260), (213 245), (220 190))";
+
+    const char* expected =
+        "GEOMETRYCOLLECTION (POLYGON ((-20 50, -20 380, -3.75 380, 105 235, 105 115, 77.14285714285714 50, -20 50)), POLYGON ((247 50, 77.14285714285714 50, 105 115, 145 195, 178.33333333333334 211.66666666666666, 183.51851851851853 208.7037037037037, 247 50)), POLYGON ((-3.75 380, 20.000000000000007 380, 176.66666666666666 223.33333333333334, 178.33333333333334 211.66666666666666, 145 195, 105 235, -3.75 380)), POLYGON ((105 115, 105 235, 145 195, 105 115)), POLYGON ((20.000000000000007 380, 255 380, 176.66666666666666 223.33333333333334, 20.000000000000007 380)), POLYGON ((255 380, 340 380, 340 240, 183.51851851851853 208.7037037037037, 178.33333333333334 211.66666666666666, 176.66666666666666 223.33333333333334, 255 380)), POLYGON ((340 240, 340 50, 247 50, 183.51851851851853 208.7037037037037, 340 240)))";
+
+    runVoronoi(wkt, expected, 6);
+}
+template<>
+template<>
+void object::test<8>
+()
+{
+    const char* wkt = "MULTIPOINT ((170 270), (177 275), (190 230), (230 250), (210 290), (240 280), (240 250))";
+
+    const char* expected =
+        "GEOMETRYCOLLECTION (POLYGON ((100 210, 100 360, 150 360, 200 260, 100 210)), POLYGON ((150 360, 250 360, 220 270, 200 260, 150 360)), POLYGON ((100 160, 100 210, 200 260, 235 190, 247 160, 100 160)), POLYGON ((220 270, 235 265, 235 190, 200 260, 220 270)), POLYGON ((250 360, 310 360, 310 265, 235 265, 220 270, 250 360)), POLYGON ((310 265, 310 160, 247 160, 235 190, 235 265, 310 265)))";
+
+    runVoronoi(wkt, expected, 10);
+}
+//Taking tolerance very very high
+template<>
+template<>
+void object::test<9>
+()
+{
+    const char* wkt = "MULTIPOINT ((155 271), (150 360), (260 360), (271 265), (280 260), (270 370), (154 354), (150 260))";
+
+    const char* expected =
+        "GEOMETRYCOLLECTION (POLYGON ((20 130, 20 310, 205 310, 215 299, 215 130, 20 130)), POLYGON ((205 500, 410 500, 410 338, 215 299, 205 310, 205 500)), POLYGON ((20 310, 20 500, 205 500, 205 310, 20 310)), POLYGON ((410 338, 410 130, 215 130, 215 299, 410 338)))";
+
+    runVoronoi(wkt, expected, 100);
+}
 
 } // namespace tut
 
diff --git a/tests/unit/triangulate/quadedge/QuadEdgeSubdivisionTest.cpp b/tests/unit/triangulate/quadedge/QuadEdgeSubdivisionTest.cpp
index fd3aaf1..23cf51a 100644
--- a/tests/unit/triangulate/quadedge/QuadEdgeSubdivisionTest.cpp
+++ b/tests/unit/triangulate/quadedge/QuadEdgeSubdivisionTest.cpp
@@ -28,138 +28,140 @@ using namespace geos::triangulate;
 using namespace geos::geom;
 using namespace geos::io;
 
-namespace tut
+namespace tut {
+//
+// Test Group
+//
+
+// dummy data, not used
+struct test_quadedgesub_data {
+    geos::io::WKTReader reader;
+    geos::io::WKTWriter writer;
+    test_quadedgesub_data()
+        :
+        reader(),
+        writer()
+    {
+        writer.setTrim(true);
+    }
+};
+
+typedef test_group<test_quadedgesub_data> group;
+typedef group::object object;
+
+group test_quadedgesub_group("geos::triangulate::quadedge::QuadEdgeSubdivision");
+
+
+//
+// Test Cases
+//
+
+// 1 - Basic function test
+template<>
+template<>
+void object::test<1>
+()
+{
+    //create subdivision centered around (0,0)
+    QuadEdgeSubdivision sub(Envelope(-100, 100, -100, 100), .00001);
+    //stick a point in the middle
+    QuadEdge& e = sub.insertSite(Vertex(0, 0));
+    ensure(sub.isFrameEdge(e));
+    ensure(sub.isOnEdge(e, e.orig().getCoordinate()));
+    ensure(sub.isVertexOfEdge(e, e.orig()));
+
+    ensure(!sub.isOnEdge(e, Coordinate(10, 10)));
+    ensure(!sub.isVertexOfEdge(e, Vertex(10, 10)));
+
+    GeometryFactory::Ptr geomFact(GeometryFactory::create());
+    std::unique_ptr<GeometryCollection> tris = sub.getTriangles(*geomFact);
+    tris.reset();
+    //WKTWriter wkt;
+    //printf("%s\n", wkt.writeFormatted(tris).c_str());
+}
+template<>
+template<>
+void object::test<2>
+()
 {
-	//
-	// Test Group
-	//
-
-	// dummy data, not used
-	struct test_quadedgesub_data
-	{
-		geos::io::WKTReader reader;
-		geos::io::WKTWriter writer;
-		test_quadedgesub_data()
-      :
-			reader(),
-			writer()
-		{
-			writer.setTrim(true);
-		}
-	};
-
-	typedef test_group<test_quadedgesub_data> group;
-	typedef group::object object;
-
-	group test_quadedgesub_group("geos::triangulate::quadedge::QuadEdgeSubdivision");
-
-
-	//
-	// Test Cases
-	//
-
-	// 1 - Basic function test
-	template<>
-	template<>
-	void object::test<1>()
-	{
-		//create subdivision centered around (0,0)
-		QuadEdgeSubdivision sub(Envelope(-100, 100, -100, 100), .00001);
-		//stick a point in the middle
-		QuadEdge& e = sub.insertSite(Vertex(0, 0));
-		ensure(sub.isFrameEdge(e));
-		ensure(sub.isOnEdge(e, e.orig().getCoordinate()));
-		ensure(sub.isVertexOfEdge(e, e.orig()));
-
-		ensure(!sub.isOnEdge(e, Coordinate(10, 10)));
-		ensure(!sub.isVertexOfEdge(e, Vertex(10, 10)));
-
-		GeometryFactory::Ptr geomFact(GeometryFactory::create());
-		std::unique_ptr<GeometryCollection> tris = sub.getTriangles(*geomFact);
-		tris.reset();
-		//WKTWriter wkt;
-		//printf("%s\n", wkt.writeFormatted(tris).c_str());
-	}
-	template<>
-	template<>
-	void object::test<2>()
-	{
-		Geometry* sites;
-		QuadEdgeSubdivision* subdiv;
-		sites = reader.read("MULTIPOINT ((150 200), (180 270), (275 163))");
-		CoordinateSequence* siteCoords = DelaunayTriangulationBuilder::extractUniqueCoordinates(*sites);
-		Envelope Env = DelaunayTriangulationBuilder::envelope(*siteCoords);
-
-		double expandBy = std::max(Env.getWidth() , Env.getHeight());
-		Env.expandBy(expandBy);
-
-		IncrementalDelaunayTriangulator::VertexList* vertices = DelaunayTriangulationBuilder::toVertices(*siteCoords);
-		subdiv = new quadedge::QuadEdgeSubdivision(Env,0);
-		IncrementalDelaunayTriangulator triangulator(subdiv);
-		triangulator.insertSites(*vertices);
-
-		//Test for getVoronoiDiagram::
-		const GeometryFactory& geomFact(*GeometryFactory::getDefaultInstance());
-		std::unique_ptr<GeometryCollection> polys = subdiv->getVoronoiDiagram(geomFact);
-		const char *expected_str = "GEOMETRYCOLLECTION (POLYGON ((-5849.974929324658 2268.0517257497568, -4529.9920486948895 2247.139449440667, 221.20588235294116 210.91176470588235, -684.4227119984187 -2848.644297291955, -5849.974929324658 2268.0517257497568)), POLYGON ((212.5 -3774.5, -684.4227119984187 -2848.644297291955, 221.20588235294116 210.91176470588235, 2448.7167655626645 2188.608343256571, 6235.0370264064295 2248.0370264064295, 212.5 -3774.5)), POLYGON ((-4529.9920486948895 2247.139449440667, 2448.7167655626645 2188.608343256571, 221.20588235294116 210.91176470588235, -4529.9920486948895 2247.139449440667)))";
+    Geometry* sites;
+    QuadEdgeSubdivision* subdiv;
+    sites = reader.read("MULTIPOINT ((150 200), (180 270), (275 163))");
+    CoordinateSequence* siteCoords = DelaunayTriangulationBuilder::extractUniqueCoordinates(*sites);
+    Envelope Env = DelaunayTriangulationBuilder::envelope(*siteCoords);
+
+    double expandBy = std::max(Env.getWidth(), Env.getHeight());
+    Env.expandBy(expandBy);
+
+    IncrementalDelaunayTriangulator::VertexList* vertices = DelaunayTriangulationBuilder::toVertices(*siteCoords);
+    subdiv = new quadedge::QuadEdgeSubdivision(Env, 0);
+    IncrementalDelaunayTriangulator triangulator(subdiv);
+    triangulator.insertSites(*vertices);
+
+    //Test for getVoronoiDiagram::
+    const GeometryFactory& geomFact(*GeometryFactory::getDefaultInstance());
+    std::unique_ptr<GeometryCollection> polys = subdiv->getVoronoiDiagram(geomFact);
+    const char* expected_str =
+        "GEOMETRYCOLLECTION (POLYGON ((-5849.974929324658 2268.0517257497568, -4529.9920486948895 2247.139449440667, 221.20588235294116 210.91176470588235, -684.4227119984187 -2848.644297291955, -5849.974929324658 2268.0517257497568)), POLYGON ((212.5 -3774.5, -684.4227119984187 -2848.644297291955, 221.20588235294116 210.91176470588235, 2448.7167655626645 2188.608343256571, 6235.0370264064295 2248.0370264064295, 212.5 -3774.5)), POLYGON ((-4529.9920486948895 2247.139449440667, 2448.7167655626645 2188.608343256571, 221.20588235294116 210.91176470588235, -4529.9920486948895 2247.139449440667)))";
 //		std::cout << polys->toString() << std::endl;
 
-		Geometry *expected = reader.read(expected_str);
-		polys->normalize();
-		expected->normalize();
-		ensure(polys->equalsExact(expected, 1e-7));
-		delete siteCoords;
-		delete sites;
-		delete subdiv;
-		delete vertices;
-		delete expected;
+    Geometry* expected = reader.read(expected_str);
+    polys->normalize();
+    expected->normalize();
+    ensure(polys->equalsExact(expected, 1e-7));
+    delete siteCoords;
+    delete sites;
+    delete subdiv;
+    delete vertices;
+    delete expected;
 //		ensure(polys->getCoordinateDimension() == expected->getCoordinateDimension());
-	}
-
-  // Test that returned polygons do not have duplicated points
-  // See http://trac.osgeo.org/geos/ticket/705
-  template<> template<> void object::test<3>()
-  {
-    const char *wkt =
-      "MULTIPOINT ("
+}
+
+// Test that returned polygons do not have duplicated points
+// See http://trac.osgeo.org/geos/ticket/705
+template<> template<> void object::test<3>
+()
+{
+    const char* wkt =
+        "MULTIPOINT ("
         " (170 270),"
         " (190 230),"
         " (230 250),"
         " (210 290)"
-      ")";
-    std::unique_ptr<Geometry> sites ( reader.read(wkt) );
-    std::unique_ptr<CoordinateSequence> siteCoords (
-      DelaunayTriangulationBuilder::extractUniqueCoordinates(*sites)
+        ")";
+    std::unique_ptr<Geometry> sites(reader.read(wkt));
+    std::unique_ptr<CoordinateSequence> siteCoords(
+        DelaunayTriangulationBuilder::extractUniqueCoordinates(*sites)
     );
 
     Envelope env = DelaunayTriangulationBuilder::envelope(*siteCoords);
-    double expandBy = std::max(env.getWidth() , env.getHeight());
+    double expandBy = std::max(env.getWidth(), env.getHeight());
     env.expandBy(expandBy);
     std::unique_ptr<QuadEdgeSubdivision> subdiv(
-      new quadedge::QuadEdgeSubdivision(env,10)
+        new quadedge::QuadEdgeSubdivision(env, 10)
     );
 
-    std::unique_ptr<IncrementalDelaunayTriangulator::VertexList> vertices (
-      DelaunayTriangulationBuilder::toVertices(*siteCoords)
+    std::unique_ptr<IncrementalDelaunayTriangulator::VertexList> vertices(
+        DelaunayTriangulationBuilder::toVertices(*siteCoords)
     );
 
     IncrementalDelaunayTriangulator triangulator(subdiv.get());
     triangulator.insertSites(*vertices);
 
     //Test for getVoronoiDiagram::
-		const GeometryFactory& geomFact(*GeometryFactory::getDefaultInstance());
+    const GeometryFactory& geomFact(*GeometryFactory::getDefaultInstance());
     std::unique_ptr<GeometryCollection> polys = subdiv->getVoronoiDiagram(geomFact);
-    for (std::size_t i=0; i<polys->getNumGeometries(); ++i) {
-      const Polygon* p = dynamic_cast<const Polygon*>(polys->getGeometryN(i));
-      ensure(p);
-      std::unique_ptr<CoordinateSequence> cs (
-        p->getExteriorRing()->getCoordinates()
-      );
-      size_t from = cs->size();
-      cs->removeRepeatedPoints();
-      ensure_equals(from, cs->size());
+    for(std::size_t i = 0; i < polys->getNumGeometries(); ++i) {
+        const Polygon* p = dynamic_cast<const Polygon*>(polys->getGeometryN(i));
+        ensure(p);
+        std::unique_ptr<CoordinateSequence> cs(
+            p->getExteriorRing()->getCoordinates()
+        );
+        size_t from = cs->size();
+        cs->removeRepeatedPoints();
+        ensure_equals(from, cs->size());
     }
-  }
+}
 
 } // namespace tut
 
diff --git a/tests/unit/triangulate/quadedge/QuadEdgeTest.cpp b/tests/unit/triangulate/quadedge/QuadEdgeTest.cpp
index f9a46bb..1079b09 100644
--- a/tests/unit/triangulate/quadedge/QuadEdgeTest.cpp
+++ b/tests/unit/triangulate/quadedge/QuadEdgeTest.cpp
@@ -11,161 +11,162 @@
 
 using namespace geos::triangulate::quadedge;
 
-namespace tut
+namespace tut {
+//
+// Test Group
+//
+
+// dummy data, not used
+struct test_quadedge_data {
+    test_quadedge_data()
+    {
+    }
+};
+
+typedef test_group<test_quadedge_data> group;
+typedef group::object object;
+
+group test_quadedge_group("geos::triangulate::quadedge::QuadEdge");
+
+
+//
+// Test Cases
+//
+
+// 1 - QuadEdge::connect()
+template<>
+template<>
+void object::test<1>
+()
+{
+    Vertex v1(0, 0);
+    Vertex v2(0, 1);
+
+    Vertex v3(1, 0);
+    Vertex v4(1, 1);
+
+    std::unique_ptr<QuadEdge> q0;
+    std::unique_ptr<QuadEdge> r0;
+    std::unique_ptr<QuadEdge> s0;
+
+    q0 = QuadEdge::makeEdge(v1, v2);
+    r0 = QuadEdge::makeEdge(v3, v4);
+    s0 = QuadEdge::connect(*q0, *r0);
+
+    //verify properties ensured by connect()
+    //the new edge connects q0->orig() and r0->dest()
+    ensure(s0->orig().equals(q0->dest()));
+    ensure(s0->dest().equals(r0->orig()));
+    //q0, r0, and s0 should have the same left face
+    ensure(&q0->lNext() == s0.get());
+    ensure(&s0->lNext() == r0.get());
+
+    q0->free();
+    r0->free();
+    s0->free();
+}
+
+// 2 - QuadEdge::connect(), causing a loop
+template<>
+template<>
+void object::test<2>
+()
+{
+    Vertex v1(0, 0);
+    Vertex v2(0, 1);
+
+    Vertex v3(1, 0);
+    Vertex v4(1, 1);
+
+    std::unique_ptr<QuadEdge> q0;
+    std::unique_ptr<QuadEdge> r0;
+    std::unique_ptr<QuadEdge> s0;
+
+    q0 = QuadEdge::makeEdge(v1, v2);
+    r0 = QuadEdge::makeEdge(v2, v3);
+    s0 = QuadEdge::connect(*q0, *r0);
+
+    //verify properties ensured by connect()
+    //the new edge connects q0->orig() and r0->dest()
+    ensure(s0->orig().equals(q0->dest()));
+    ensure(s0->dest().equals(r0->orig()));
+    //q0, r0, and s0 should have the same left face
+    ensure(&q0->lNext() == s0.get());
+    ensure(&s0->lNext() == r0.get());
+
+    q0->free();
+    r0->free();
+    s0->free();
+}
+
+// 3 - QuadEdge::swap()
+template<>
+template<>
+void object::test<3>
+()
 {
-	//
-	// Test Group
-	//
-
-	// dummy data, not used
-	struct test_quadedge_data
-	{
-		test_quadedge_data()
-		{
-		}
-	};
-
-	typedef test_group<test_quadedge_data> group;
-	typedef group::object object;
-
-	group test_quadedge_group("geos::triangulate::quadedge::QuadEdge");
-
-
-	//
-	// Test Cases
-	//
-
-	// 1 - QuadEdge::connect()
-	template<>
-	template<>
-	void object::test<1>()
-	{
-		Vertex v1(0, 0);
-		Vertex v2(0, 1);
-
-		Vertex v3(1, 0);
-		Vertex v4(1, 1);
-
-		std::unique_ptr<QuadEdge> q0;
-		std::unique_ptr<QuadEdge> r0;
-		std::unique_ptr<QuadEdge> s0;
-
-		q0 = QuadEdge::makeEdge(v1, v2);
-		r0 = QuadEdge::makeEdge(v3, v4);
-		s0 = QuadEdge::connect(*q0, *r0);
-
-		//verify properties ensured by connect()
-		//the new edge connects q0->orig() and r0->dest()
-		ensure(s0->orig().equals(q0->dest()));
-		ensure(s0->dest().equals(r0->orig()));
-		//q0, r0, and s0 should have the same left face
-		ensure(&q0->lNext() == s0.get());
-		ensure(&s0->lNext() == r0.get());
-
-		q0->free();
-		r0->free();
-		s0->free();
-	}
-
-	// 2 - QuadEdge::connect(), causing a loop
-	template<>
-	template<>
-	void object::test<2>()
-	{
-		Vertex v1(0, 0);
-		Vertex v2(0, 1);
-
-		Vertex v3(1, 0);
-		Vertex v4(1, 1);
-
-		std::unique_ptr<QuadEdge> q0;
-		std::unique_ptr<QuadEdge> r0;
-		std::unique_ptr<QuadEdge> s0;
-
-		q0 = QuadEdge::makeEdge(v1, v2);
-		r0 = QuadEdge::makeEdge(v2, v3);
-		s0 = QuadEdge::connect(*q0, *r0);
-
-		//verify properties ensured by connect()
-		//the new edge connects q0->orig() and r0->dest()
-		ensure(s0->orig().equals(q0->dest()));
-		ensure(s0->dest().equals(r0->orig()));
-		//q0, r0, and s0 should have the same left face
-		ensure(&q0->lNext() == s0.get());
-		ensure(&s0->lNext() == r0.get());
-
-		q0->free();
-		r0->free();
-		s0->free();
-	}
-
-	// 3 - QuadEdge::swap()
-	template<>
-	template<>
-	void object::test<3>()
-	{
-		Vertex v1(0, 0);
-		Vertex v2(0, 1);
-
-		Vertex v3(1, 0);
-		Vertex v4(1, 1);
-
-		std::unique_ptr<QuadEdge> q0;
-		std::unique_ptr<QuadEdge> r0;
-		std::unique_ptr<QuadEdge> s0;
-		std::unique_ptr<QuadEdge> t0;
-		std::unique_ptr<QuadEdge> u0;
-
-		//make a quadilateral
-		q0 = QuadEdge::makeEdge(v1, v2);
-		r0 = QuadEdge::makeEdge(v4, v3);
-		s0 = QuadEdge::connect(*q0, *r0);
-		t0 = QuadEdge::connect(*r0, *q0);
-
-		//printf("\n=====================\n");
-		//printf("r0->orig(): %f %f\n", r0->orig().getX(), r0->orig().getY());
-		//printf("r0->dest(): %f %f\n", r0->dest().getX(), r0->dest().getY());
-		//printf("s0->orig(): %f %f\n", s0->orig().getX(), s0->orig().getY());
-		//printf("s0->dest(): %f %f\n", s0->dest().getX(), s0->dest().getY());
-
-		//add an interior edge to make 2 triangles
-		u0 = QuadEdge::connect(*t0, *r0);
-		//printf("\n=====================\n");
-		//printf("q0->orig(): %f %f\n", q0->orig().getX(), q0->orig().getY());
-		//printf("q0->dest(): %f %f\n", q0->dest().getX(), q0->dest().getY());
-		//printf("r0->orig(): %f %f\n", r0->orig().getX(), r0->orig().getY());
-		//printf("r0->dest(): %f %f\n", r0->dest().getX(), r0->dest().getY());
-		//printf("s0->orig(): %f %f\n", s0->orig().getX(), s0->orig().getY());
-		//printf("s0->dest(): %f %f\n", s0->dest().getX(), s0->dest().getY());
-		//printf("t0->orig(): %f %f\n", t0->orig().getX(), t0->orig().getY());
-		//printf("t0->dest(): %f %f\n", t0->dest().getX(), t0->dest().getY());
-		//printf("u0->orig(): %f %f\n", u0->orig().getX(), u0->orig().getY());
-		//printf("u0->dest(): %f %f\n", u0->dest().getX(), u0->dest().getY());
-		ensure(t0->dest().equals(u0->orig()));
-		ensure(u0->dest().equals(r0->orig()));
-
-		//now swap the interior edge
-		QuadEdge::swap(*u0);
-		//printf("\n=====================\n");
-		//printf("q0->orig(): %f %f\n", q0->orig().getX(), q0->orig().getY());
-		//printf("q0->dest(): %f %f\n", q0->dest().getX(), q0->dest().getY());
-		//printf("r0->orig(): %f %f\n", r0->orig().getX(), r0->orig().getY());
-		//printf("r0->dest(): %f %f\n", r0->dest().getX(), r0->dest().getY());
-		//printf("s0->orig(): %f %f\n", s0->orig().getX(), s0->orig().getY());
-		//printf("s0->dest(): %f %f\n", s0->dest().getX(), s0->dest().getY());
-		//printf("t0->orig(): %f %f\n", t0->orig().getX(), t0->orig().getY());
-		//printf("t0->dest(): %f %f\n", t0->dest().getX(), t0->dest().getY());
-		//printf("u0->orig(): %f %f\n", u0->orig().getX(), u0->orig().getY());
-		//printf("u0->dest(): %f %f\n", u0->dest().getX(), u0->dest().getY());
-		ensure(r0->dest().equals(u0->dest()));
-		ensure(u0->orig().equals(q0->dest()));
-
-		q0->free();
-		r0->free();
-		s0->free();
-		t0->free();
-		u0->free();
-	}
+    Vertex v1(0, 0);
+    Vertex v2(0, 1);
+
+    Vertex v3(1, 0);
+    Vertex v4(1, 1);
+
+    std::unique_ptr<QuadEdge> q0;
+    std::unique_ptr<QuadEdge> r0;
+    std::unique_ptr<QuadEdge> s0;
+    std::unique_ptr<QuadEdge> t0;
+    std::unique_ptr<QuadEdge> u0;
+
+    //make a quadilateral
+    q0 = QuadEdge::makeEdge(v1, v2);
+    r0 = QuadEdge::makeEdge(v4, v3);
+    s0 = QuadEdge::connect(*q0, *r0);
+    t0 = QuadEdge::connect(*r0, *q0);
+
+    //printf("\n=====================\n");
+    //printf("r0->orig(): %f %f\n", r0->orig().getX(), r0->orig().getY());
+    //printf("r0->dest(): %f %f\n", r0->dest().getX(), r0->dest().getY());
+    //printf("s0->orig(): %f %f\n", s0->orig().getX(), s0->orig().getY());
+    //printf("s0->dest(): %f %f\n", s0->dest().getX(), s0->dest().getY());
+
+    //add an interior edge to make 2 triangles
+    u0 = QuadEdge::connect(*t0, *r0);
+    //printf("\n=====================\n");
+    //printf("q0->orig(): %f %f\n", q0->orig().getX(), q0->orig().getY());
+    //printf("q0->dest(): %f %f\n", q0->dest().getX(), q0->dest().getY());
+    //printf("r0->orig(): %f %f\n", r0->orig().getX(), r0->orig().getY());
+    //printf("r0->dest(): %f %f\n", r0->dest().getX(), r0->dest().getY());
+    //printf("s0->orig(): %f %f\n", s0->orig().getX(), s0->orig().getY());
+    //printf("s0->dest(): %f %f\n", s0->dest().getX(), s0->dest().getY());
+    //printf("t0->orig(): %f %f\n", t0->orig().getX(), t0->orig().getY());
+    //printf("t0->dest(): %f %f\n", t0->dest().getX(), t0->dest().getY());
+    //printf("u0->orig(): %f %f\n", u0->orig().getX(), u0->orig().getY());
+    //printf("u0->dest(): %f %f\n", u0->dest().getX(), u0->dest().getY());
+    ensure(t0->dest().equals(u0->orig()));
+    ensure(u0->dest().equals(r0->orig()));
+
+    //now swap the interior edge
+    QuadEdge::swap(*u0);
+    //printf("\n=====================\n");
+    //printf("q0->orig(): %f %f\n", q0->orig().getX(), q0->orig().getY());
+    //printf("q0->dest(): %f %f\n", q0->dest().getX(), q0->dest().getY());
+    //printf("r0->orig(): %f %f\n", r0->orig().getX(), r0->orig().getY());
+    //printf("r0->dest(): %f %f\n", r0->dest().getX(), r0->dest().getY());
+    //printf("s0->orig(): %f %f\n", s0->orig().getX(), s0->orig().getY());
+    //printf("s0->dest(): %f %f\n", s0->dest().getX(), s0->dest().getY());
+    //printf("t0->orig(): %f %f\n", t0->orig().getX(), t0->orig().getY());
+    //printf("t0->dest(): %f %f\n", t0->dest().getX(), t0->dest().getY());
+    //printf("u0->orig(): %f %f\n", u0->orig().getX(), u0->orig().getY());
+    //printf("u0->dest(): %f %f\n", u0->dest().getX(), u0->dest().getY());
+    ensure(r0->dest().equals(u0->dest()));
+    ensure(u0->orig().equals(q0->dest()));
+
+    q0->free();
+    r0->free();
+    s0->free();
+    t0->free();
+    u0->free();
+}
 } // namespace tut
 
 
diff --git a/tests/unit/triangulate/quadedge/VertexTest.cpp b/tests/unit/triangulate/quadedge/VertexTest.cpp
index 828c2c8..62c10a0 100644
--- a/tests/unit/triangulate/quadedge/VertexTest.cpp
+++ b/tests/unit/triangulate/quadedge/VertexTest.cpp
@@ -13,47 +13,46 @@
 
 using namespace geos::triangulate::quadedge;
 
-namespace tut
+namespace tut {
+//
+// Test Group
+//
+
+// dummy data, not used
+struct test_vertex_data {
+    test_vertex_data()
+    {
+    }
+};
+
+typedef test_group<test_vertex_data> group;
+typedef group::object object;
+
+group test_vertex_group("geos::triangulate::quadedge::Vertex");
+
+
+//
+// Test Cases
+//
+
+// 1 - Test for operator<
+template<>
+template<>
+void object::test<1>
+()
 {
-	//
-	// Test Group
-	//
-
-	// dummy data, not used
-	struct test_vertex_data
-	{
-		test_vertex_data()
-		{
-		}
-	};
-
-	typedef test_group<test_vertex_data> group;
-	typedef group::object object;
-
-	group test_vertex_group("geos::triangulate::quadedge::Vertex");
-
-
-	//
-	// Test Cases
-	//
-
-	// 1 - Test for operator<
-	template<>
-	template<>
-	void object::test<1>()
-	{
-		Vertex v1(10,20);
-		Vertex v2(20,30);
-		Vertex v3(0,100);
-		Vertex v4(10,30);
-		Vertex v5(10,10);
-
-		ensure(v1<v2);
-		ensure(!(v1<v3));
-		ensure(v1<v4);
-		ensure(!(v1<v5));
-		ensure(!(v4<v5));
-	}
+    Vertex v1(10, 20);
+    Vertex v2(20, 30);
+    Vertex v3(0, 100);
+    Vertex v4(10, 30);
+    Vertex v5(10, 10);
+
+    ensure(v1 < v2);
+    ensure(!(v1 < v3));
+    ensure(v1 < v4);
+    ensure(!(v1 < v5));
+    ensure(!(v4 < v5));
+}
 
 } // namespace tut
 
diff --git a/tests/unit/util/UniqueCoordinateArrayFilterTest.cpp b/tests/unit/util/UniqueCoordinateArrayFilterTest.cpp
index 491683a..6992385 100644
--- a/tests/unit/util/UniqueCoordinateArrayFilterTest.cpp
+++ b/tests/unit/util/UniqueCoordinateArrayFilterTest.cpp
@@ -15,78 +15,77 @@
 #include <memory>
 #include <string>
 
-namespace tut
+namespace tut {
+//
+// Test Group
+//
+
+// Common data used in test cases.
+struct test_uniquecoordinatearrayfilter_data {
+    typedef std::unique_ptr<geos::geom::Geometry> GeometryPtr;
+    typedef geos::geom::GeometryFactory GeometryFactory;
+
+    geos::geom::PrecisionModel pm_;
+    GeometryFactory::Ptr factory_;
+    geos::io::WKTReader reader_;
+
+    test_uniquecoordinatearrayfilter_data()
+        : pm_(1)
+        , factory_(GeometryFactory::create(&pm_, 0))
+        , reader_(factory_.get())
+    {}
+};
+
+typedef test_group<test_uniquecoordinatearrayfilter_data> group;
+typedef group::object object;
+
+group test_uniquecoordinatearrayfilter_group("geos::util::UniqueCoordinateArrayFilter");
+
+//
+// Test Cases
+//
+
+// Test of apply_ro() on MULTIPOINT
+template<>
+template<>
+void object::test<1>
+()
 {
-    //
-    // Test Group
-    //
-
-    // Common data used in test cases.
-    struct test_uniquecoordinatearrayfilter_data
-	{
-		typedef std::unique_ptr<geos::geom::Geometry> GeometryPtr;
-		typedef geos::geom::GeometryFactory GeometryFactory;
-
-		geos::geom::PrecisionModel pm_;
-		GeometryFactory::Ptr factory_;
-		geos::io::WKTReader reader_;
-
-		test_uniquecoordinatearrayfilter_data()
-			: pm_(1)
-      , factory_(GeometryFactory::create(&pm_, 0))
-      , reader_(factory_.get())
-		{}
-	};
-
-	typedef test_group<test_uniquecoordinatearrayfilter_data> group;
-    typedef group::object object;
-
-	group test_uniquecoordinatearrayfilter_group("geos::util::UniqueCoordinateArrayFilter");
-
-    //
-    // Test Cases
-    //
-
-    // Test of apply_ro() on MULTIPOINT
-    template<>
-    template<>
-    void object::test<1>()
-    {
-		using geos::geom::Coordinate;
-
-		// Create geometry from WKT
-		const Coordinate::ConstVect::size_type size5 = 5;
-		const std::string wkt("MULTIPOINT(10 10, 20 20, 30 30, 20 20, 10 10)");
-		GeometryPtr geo(reader_.read(wkt));
-
-		ensure_equals( geo->getGeometryTypeId(), geos::geom::GEOS_MULTIPOINT );
-		std::unique_ptr<geos::geom::CoordinateSequence> cs;
-		cs.reset(geo->getCoordinates());
-		ensure_equals(cs->getSize(), size5 );
-
-		// Create collection buffer for filtered coordinates
-		const Coordinate::ConstVect::size_type size0 = 0;
-		Coordinate::ConstVect coords;
-
-		// Create filtering object
-		geos::util::UniqueCoordinateArrayFilter filter(coords);
-
-		ensure_equals( coords.size(), size0 );
-
-		// Apply filter
-		const Coordinate::ConstVect::size_type size3 = 3;
-		geo->apply_ro(&filter);
-
-		cs.reset(geo->getCoordinates());
-		ensure_equals( cs->getSize(), size5 );
-		ensure_equals( coords.size(), size3 );
-		ensure_equals( coords.at(0)->x, 10 );
-		ensure_equals( coords.at(0)->y, 10 );
-		ensure_equals( coords.at(1)->x, 20 );
-		ensure_equals( coords.at(1)->y, 20 );
-		ensure_equals( coords.at(2)->x, 30 );
-		ensure_equals( coords.at(2)->y, 30 );
-    }
+    using geos::geom::Coordinate;
+
+    // Create geometry from WKT
+    const Coordinate::ConstVect::size_type size5 = 5;
+    const std::string wkt("MULTIPOINT(10 10, 20 20, 30 30, 20 20, 10 10)");
+    GeometryPtr geo(reader_.read(wkt));
+
+    ensure_equals(geo->getGeometryTypeId(), geos::geom::GEOS_MULTIPOINT);
+    std::unique_ptr<geos::geom::CoordinateSequence> cs;
+    cs.reset(geo->getCoordinates());
+    ensure_equals(cs->getSize(), size5);
+
+    // Create collection buffer for filtered coordinates
+    const Coordinate::ConstVect::size_type size0 = 0;
+    Coordinate::ConstVect coords;
+
+    // Create filtering object
+    geos::util::UniqueCoordinateArrayFilter filter(coords);
+
+    ensure_equals(coords.size(), size0);
+
+    // Apply filter
+    const Coordinate::ConstVect::size_type size3 = 3;
+    geo->apply_ro(&filter);
+
+    cs.reset(geo->getCoordinates());
+    ensure_equals(cs->getSize(), size5);
+    ensure_equals(coords.size(), size3);
+    ensure_equals(coords.at(0)->x, 10);
+    ensure_equals(coords.at(0)->y, 10);
+    ensure_equals(coords.at(1)->x, 20);
+    ensure_equals(coords.at(1)->y, 20);
+    ensure_equals(coords.at(2)->x, 30);
+    ensure_equals(coords.at(2)->y, 30);
+}
 
 } // namespace tut
 
diff --git a/tests/unit/utility.h b/tests/unit/utility.h
index 07f7076..087276e 100644
--- a/tests/unit/utility.h
+++ b/tests/unit/utility.h
@@ -32,8 +32,7 @@
 #include <string>
 #include <vector>
 
-namespace tut
-{
+namespace tut {
 
 //
 // Helper typedefs
@@ -77,14 +76,16 @@ typedef geos::geom::prep::PreparedGeometry const* PreparedGeometryPtr;
 //
 
 template<typename Type, typename InstanceType>
-inline bool isInstanceOf(InstanceType const* instance)
+inline bool
+isInstanceOf(InstanceType const* instance)
 {
     assert(nullptr != instance);
-    return (nullptr != dynamic_cast<Type const*>(instance) );
+    return (nullptr != dynamic_cast<Type const*>(instance));
 }
 
 template<typename Type, typename InstanceType>
-inline Type const* instanceOf(InstanceType const* instance)
+inline Type const*
+instanceOf(InstanceType const* instance)
 {
     assert(nullptr != instance);
     return dynamic_cast<Type const*>(instance);
@@ -95,7 +96,8 @@ inline Type const* instanceOf(InstanceType const* instance)
 //
 
 template <typename T1, typename T2>
-inline void ensure_equals_geometry(T1 const* lhs, T2 const* rhs)
+inline void
+ensure_equals_geometry(T1 const* lhs, T2 const* rhs)
 {
     assert(0 != lhs);
     assert(0 != rhs);
@@ -104,7 +106,8 @@ inline void ensure_equals_geometry(T1 const* lhs, T2 const* rhs)
 }
 
 template <typename T>
-inline void ensure_equals_geometry(T const* lhs, T const* rhs)
+inline void
+ensure_equals_geometry(T const* lhs, T const* rhs)
 {
     assert(nullptr != lhs);
     assert(nullptr != rhs);
@@ -118,9 +121,8 @@ inline void ensure_equals_geometry(T const* lhs, T const* rhs)
     ensure_equals("is-empty do not match",
                   lhs->isEmpty(), rhs->isEmpty());
 
-    if (!isInstanceOf<GeometryCollection>(lhs)
-         && !isInstanceOf<GeometryCollection>(rhs))
-    {
+    if(!isInstanceOf<GeometryCollection>(lhs)
+            && !isInstanceOf<GeometryCollection>(rhs)) {
         ensure_equals("is-simple do not match",
                       lhs->isSimple(), rhs->isSimple());
     }
@@ -143,23 +145,22 @@ inline void ensure_equals_geometry(T const* lhs, T const* rhs)
     //              lhs->getNumPoints(), rhs->getNumPoints());
 
     // Dispatch to run more specific testes
-    if (isInstanceOf<Polygon>(lhs)
-        && isInstanceOf<Polygon>(rhs))
-    {
+    if(isInstanceOf<Polygon>(lhs)
+            && isInstanceOf<Polygon>(rhs)) {
         ensure_equals_geometry(instanceOf<Polygon>(lhs),
-                        instanceOf<Polygon>(rhs));
+                               instanceOf<Polygon>(rhs));
     }
-    else if (isInstanceOf<GeometryCollection>(lhs)
-             && isInstanceOf<GeometryCollection>(rhs))
-    {
+    else if(isInstanceOf<GeometryCollection>(lhs)
+            && isInstanceOf<GeometryCollection>(rhs)) {
         ensure_equals_geometry(instanceOf<GeometryCollection>(lhs),
-                        instanceOf<GeometryCollection>(rhs));
+                               instanceOf<GeometryCollection>(rhs));
     }
 }
 
 template <>
-inline void ensure_equals_geometry(geos::geom::Polygon const* lhs,
-                                   geos::geom::Polygon const* rhs)
+inline void
+ensure_equals_geometry(geos::geom::Polygon const* lhs,
+                       geos::geom::Polygon const* rhs)
 {
     assert(nullptr != lhs);
     assert(nullptr != rhs);
@@ -169,8 +170,9 @@ inline void ensure_equals_geometry(geos::geom::Polygon const* lhs,
 }
 
 template <>
-inline void ensure_equals_geometry(geos::geom::GeometryCollection const* lhs,
-                                   geos::geom::GeometryCollection const* rhs)
+inline void
+ensure_equals_geometry(geos::geom::GeometryCollection const* lhs,
+                       geos::geom::GeometryCollection const* rhs)
 {
     assert(nullptr != lhs);
     assert(nullptr != rhs);
@@ -180,8 +182,7 @@ inline void ensure_equals_geometry(geos::geom::GeometryCollection const* lhs,
     ensure_equals("number of geometries do not match",
                   lhs->getNumGeometries(), rhs->getNumGeometries());
 
-    for (std::size_t i = 0, n = lhs->getNumGeometries(); i < n; ++i)
-    {
+    for(std::size_t i = 0, n = lhs->getNumGeometries(); i < n; ++i) {
         Geometry const* g1 = lhs->getGeometryN(i);
         Geometry const* g2 = rhs->getGeometryN(i);
         ensure_equals_geometry(g1, g2); // breaks on failure
@@ -189,8 +190,9 @@ inline void ensure_equals_geometry(geos::geom::GeometryCollection const* lhs,
 }
 
 template <>
-inline void ensure_equals_geometry(geos::geom::Geometry const* lhs,
-                                   geos::geom::prep::PreparedGeometry const* rhs)
+inline void
+ensure_equals_geometry(geos::geom::Geometry const* lhs,
+                       geos::geom::prep::PreparedGeometry const* rhs)
 {
     assert(nullptr != lhs);
     assert(nullptr != rhs);
@@ -204,16 +206,15 @@ inline void ensure_equals_geometry(geos::geom::Geometry const* lhs,
 //
 
 // Decodes hex-encoded WKB/EWKB to raw binary.
-struct wkb_hex_decoder
-{
+struct wkb_hex_decoder {
     typedef std::vector<unsigned char> binary_type;
 
     // bytes [out] - buffer for binary output
-    static void decode(std::string const& hexstr, binary_type& bytes)
+    static void
+    decode(std::string const& hexstr, binary_type& bytes)
     {
         bytes.clear();
-        for(std::string::size_type i = 0; i < hexstr.size() / 2; ++i)
-        {
+        for(std::string::size_type i = 0; i < hexstr.size() / 2; ++i) {
             std::istringstream iss(hexstr.substr(i * 2, 2));
             unsigned int n;
             iss >> std::hex >> n;
diff --git a/tests/xmltester/BufferResultMatcher.cpp b/tests/xmltester/BufferResultMatcher.cpp
index 108575b..735c535 100644
--- a/tests/xmltester/BufferResultMatcher.cpp
+++ b/tests/xmltester/BufferResultMatcher.cpp
@@ -34,98 +34,98 @@ double BufferResultMatcher::MAX_HAUSDORFF_DISTANCE_FACTOR = 100;
 
 bool
 BufferResultMatcher::isBufferResultMatch(const geom::Geometry& actualBuffer,
-	                         const geom::Geometry& expectedBuffer,
-	                         double distance)
+        const geom::Geometry& expectedBuffer,
+        double distance)
 {
-	if (actualBuffer.isEmpty() && expectedBuffer.isEmpty())
-		return true;
-
-	/**
-	 * MD - need some more checks here - symDiffArea won't catch
-	 * very small holes ("tears")
-	 * near the edge of computed buffers (which can happen
-	 * in current version of JTS (1.8)).
-	 * This can probably be handled by testing
-	 * that every point of the actual buffer is at least a certain
-	 * distance away from the geometry boundary.
-	 */
-	if (! isSymDiffAreaInTolerance(actualBuffer, expectedBuffer))
-	{
-std::cerr << "isSymDiffAreaInTolerance failed" << std::endl;
-		return false;
-	}
-
-	if (! isBoundaryHausdorffDistanceInTolerance(actualBuffer,
-	           expectedBuffer, distance))
-	{
-std::cerr << "isBoundaryHasudorffDistanceInTolerance failed" << std::endl;
-		return false;
-	}
-
-	return true;
+    if(actualBuffer.isEmpty() && expectedBuffer.isEmpty()) {
+        return true;
+    }
+
+    /**
+     * MD - need some more checks here - symDiffArea won't catch
+     * very small holes ("tears")
+     * near the edge of computed buffers (which can happen
+     * in current version of JTS (1.8)).
+     * This can probably be handled by testing
+     * that every point of the actual buffer is at least a certain
+     * distance away from the geometry boundary.
+     */
+    if(! isSymDiffAreaInTolerance(actualBuffer, expectedBuffer)) {
+        std::cerr << "isSymDiffAreaInTolerance failed" << std::endl;
+        return false;
+    }
+
+    if(! isBoundaryHausdorffDistanceInTolerance(actualBuffer,
+            expectedBuffer, distance)) {
+        std::cerr << "isBoundaryHasudorffDistanceInTolerance failed" << std::endl;
+        return false;
+    }
+
+    return true;
 }
 
 bool
 BufferResultMatcher::isSymDiffAreaInTolerance(
-	const geom::Geometry& actualBuffer,
-	const geom::Geometry& expectedBuffer)
+    const geom::Geometry& actualBuffer,
+    const geom::Geometry& expectedBuffer)
 {
-	typedef std::unique_ptr<geom::Geometry> GeomPtr;
+    typedef std::unique_ptr<geom::Geometry> GeomPtr;
 
-	using namespace operation::overlay;
-	using geos::geom::BinaryOp;
+    using namespace operation::overlay;
+    using geos::geom::BinaryOp;
 
-	double area = expectedBuffer.getArea();
-	GeomPtr diff = BinaryOp(&actualBuffer, &expectedBuffer,
-	                   overlayOp(OverlayOp::opSYMDIFFERENCE));
+    double area = expectedBuffer.getArea();
+    GeomPtr diff = BinaryOp(&actualBuffer, &expectedBuffer,
+                            overlayOp(OverlayOp::opSYMDIFFERENCE));
 
-	double areaDiff = diff->getArea();
+    double areaDiff = diff->getArea();
 
-	// can't get closer than difference area = 0 !
-	// This also handles case when symDiff is empty
-	if (areaDiff <= 0.0) return true;
+    // can't get closer than difference area = 0 !
+    // This also handles case when symDiff is empty
+    if(areaDiff <= 0.0) {
+        return true;
+    }
 
-	if (area <= 0) return false;
-	double frac = areaDiff / area;
+    if(area <= 0) {
+        return false;
+    }
+    double frac = areaDiff / area;
 
-	bool ret = frac < MAX_RELATIVE_AREA_DIFFERENCE;
-	if ( ! ret )
-	{
-std::cerr << "symDiffArea frac: " << frac << " tolerated " << MAX_RELATIVE_AREA_DIFFERENCE << std::endl;
-	}
-	return ret;
+    bool ret = frac < MAX_RELATIVE_AREA_DIFFERENCE;
+    if(! ret) {
+        std::cerr << "symDiffArea frac: " << frac << " tolerated " << MAX_RELATIVE_AREA_DIFFERENCE << std::endl;
+    }
+    return ret;
 }
 
 bool
 BufferResultMatcher::isBoundaryHausdorffDistanceInTolerance(
-	const geom::Geometry& actualBuffer,
-	const geom::Geometry& expectedBuffer, double distance)
+    const geom::Geometry& actualBuffer,
+    const geom::Geometry& expectedBuffer, double distance)
 {
-	typedef std::unique_ptr<geom::Geometry> GeomPtr;
+    typedef std::unique_ptr<geom::Geometry> GeomPtr;
 
-	using geos::algorithm::distance::DiscreteHausdorffDistance;
+    using geos::algorithm::distance::DiscreteHausdorffDistance;
 
-	GeomPtr actualBdy ( actualBuffer.getBoundary() );
-	GeomPtr expectedBdy ( expectedBuffer.getBoundary() );
+    GeomPtr actualBdy(actualBuffer.getBoundary());
+    GeomPtr expectedBdy(expectedBuffer.getBoundary());
 
-	DiscreteHausdorffDistance haus(*actualBdy, *expectedBdy);
-	haus.setDensifyFraction(0.25);
+    DiscreteHausdorffDistance haus(*actualBdy, *expectedBdy);
+    haus.setDensifyFraction(0.25);
 
-	double maxDistanceFound = haus.orientedDistance();
+    double maxDistanceFound = haus.orientedDistance();
 
-	double expectedDistanceTol = fabs(distance) / MAX_HAUSDORFF_DISTANCE_FACTOR;
-	if (expectedDistanceTol < MIN_DISTANCE_TOLERANCE)
-	{
-		expectedDistanceTol = MIN_DISTANCE_TOLERANCE;
-	}
+    double expectedDistanceTol = fabs(distance) / MAX_HAUSDORFF_DISTANCE_FACTOR;
+    if(expectedDistanceTol < MIN_DISTANCE_TOLERANCE) {
+        expectedDistanceTol = MIN_DISTANCE_TOLERANCE;
+    }
 
-	if (maxDistanceFound > expectedDistanceTol)
-	{
-std::cerr << "maxDistanceFound: " << maxDistanceFound << " tolerated " << expectedDistanceTol << std::endl;
-		return false;
-	}
+    if(maxDistanceFound > expectedDistanceTol) {
+        std::cerr << "maxDistanceFound: " << maxDistanceFound << " tolerated " << expectedDistanceTol << std::endl;
+        return false;
+    }
 
-	return true;
+    return true;
 }
 
 } // namespace geos::xmltester
diff --git a/tests/xmltester/BufferResultMatcher.h b/tests/xmltester/BufferResultMatcher.h
index 2c7847e..f12cc9e 100644
--- a/tests/xmltester/BufferResultMatcher.h
+++ b/tests/xmltester/BufferResultMatcher.h
@@ -21,41 +21,40 @@
 
 // Forward declarations
 namespace geos {
-	namespace geom {
-		class Geometry;
-	}
+namespace geom {
+class Geometry;
+}
 }
 
 namespace geos {
 namespace xmltester {
 
-class BufferResultMatcher
-{
+class BufferResultMatcher {
 public:
-	bool isBufferResultMatch(const geom::Geometry& actualBuffer,
-	                         const geom::Geometry& expectedBuffer,
-	                         double distance);
+    bool isBufferResultMatch(const geom::Geometry& actualBuffer,
+                             const geom::Geometry& expectedBuffer,
+                             double distance);
 
 private:
 
-	static double MAX_RELATIVE_AREA_DIFFERENCE;
+    static double MAX_RELATIVE_AREA_DIFFERENCE;
 
-	static double MAX_HAUSDORFF_DISTANCE_FACTOR;
+    static double MAX_HAUSDORFF_DISTANCE_FACTOR;
 
-	/*
-	 * The minimum distance tolerance which will be used.
-	 * This is required because densified vertices do no lie
-	 * precisely on their parent segment.
-	 */
-	static double MIN_DISTANCE_TOLERANCE;
+    /*
+     * The minimum distance tolerance which will be used.
+     * This is required because densified vertices do no lie
+     * precisely on their parent segment.
+     */
+    static double MIN_DISTANCE_TOLERANCE;
 
-	bool isSymDiffAreaInTolerance(const geom::Geometry& actualBuffer,
-	                              const geom::Geometry& expectedBuffer);
+    bool isSymDiffAreaInTolerance(const geom::Geometry& actualBuffer,
+                                  const geom::Geometry& expectedBuffer);
 
-	bool isBoundaryHausdorffDistanceInTolerance(
-                        const geom::Geometry& actualBuffer,
-	                const geom::Geometry& expectedBuffer,
-	                double distance);
+    bool isBoundaryHausdorffDistanceInTolerance(
+        const geom::Geometry& actualBuffer,
+        const geom::Geometry& expectedBuffer,
+        double distance);
 };
 
 } // namespace geos::xmltester
diff --git a/tests/xmltester/CTS.cpp b/tests/xmltester/CTS.cpp
index b87567d..a405e92 100644
--- a/tests/xmltester/CTS.cpp
+++ b/tests/xmltester/CTS.cpp
@@ -26,17 +26,19 @@
 using namespace std;
 using namespace geos;
 
-int main(int argc, char** argv)
+int
+main(int argc, char** argv)
 {
-	try {
-	cout << "Start:" << endl;
+    try {
+        cout << "Start:" << endl;
 
 
-	cout << "End" << endl;
-	} catch (const GEOSException& ge) {
-		cout << ge->toString() << endl;
-	}
+        cout << "End" << endl;
+    }
+    catch(const GEOSException& ge) {
+        cout << ge->toString() << endl;
+    }
 
-	return 0;
+    return 0;
 }
 
diff --git a/tests/xmltester/SimpleWKTTester.cpp b/tests/xmltester/SimpleWKTTester.cpp
index 44643b7..b9bcc3c 100644
--- a/tests/xmltester/SimpleWKTTester.cpp
+++ b/tests/xmltester/SimpleWKTTester.cpp
@@ -31,39 +31,41 @@ using namespace geos::io;
 using namespace geos::geom;
 using namespace geos::util;
 
-int main(int /*argc*/, char** /*argv*/)
+int
+main(int /*argc*/, char** /*argv*/)
 {
 
-	try {
-		ofstream out("WKTOut");
-		ifstream in("WKTIn");
-		string instr;
-		string outstr;
-		PrecisionModel pm;
-    GeometryFactory::Ptr gf = GeometryFactory::create(&pm, 10);
-		WKTReader *r = new WKTReader(gf.get());
-		WKTWriter *w = new WKTWriter();
-		Geometry *g;
+    try {
+        ofstream out("WKTOut");
+        ifstream in("WKTIn");
+        string instr;
+        string outstr;
+        PrecisionModel pm;
+        GeometryFactory::Ptr gf = GeometryFactory::create(&pm, 10);
+        WKTReader* r = new WKTReader(gf.get());
+        WKTWriter* w = new WKTWriter();
+        Geometry* g;
 
-		cout << "Start Testing:" << endl;
-		while(!in.eof()) {
-			getline(in,instr);
-			if (instr!="") {
-				g=r->read(instr);
-				outstr=w->write(g);
-				out << "----------" << endl;
-				out << instr << endl;
-				out << outstr << endl;
-				out << "----------" << endl << endl;
-			}
-		}
-		out.flush();
-		out.close();
-		cout << "End of Testing" << endl;
+        cout << "Start Testing:" << endl;
+        while(!in.eof()) {
+            getline(in, instr);
+            if(instr != "") {
+                g = r->read(instr);
+                outstr = w->write(g);
+                out << "----------" << endl;
+                out << instr << endl;
+                out << outstr << endl;
+                out << "----------" << endl << endl;
+            }
+        }
+        out.flush();
+        out.close();
+        cout << "End of Testing" << endl;
 
-	} catch (const GEOSException& ge) {
-		cout << ge.what() << endl;
-	}
+    }
+    catch(const GEOSException& ge) {
+        cout << ge.what() << endl;
+    }
 
-	return 0;
+    return 0;
 }
diff --git a/tests/xmltester/SingleSidedBufferResultMatcher.cpp b/tests/xmltester/SingleSidedBufferResultMatcher.cpp
index 8481669..c3a1f92 100644
--- a/tests/xmltester/SingleSidedBufferResultMatcher.cpp
+++ b/tests/xmltester/SingleSidedBufferResultMatcher.cpp
@@ -33,72 +33,69 @@ double SingleSidedBufferResultMatcher::MAX_HAUSDORFF_DISTANCE_FACTOR = 100;
 
 bool
 SingleSidedBufferResultMatcher::isBufferResultMatch(const geom::Geometry& actualBuffer,
-	                         const geom::Geometry& expectedBuffer,
-	                         double distance)
+        const geom::Geometry& expectedBuffer,
+        double distance)
 {
-	bool aEmpty = actualBuffer.isEmpty();
-	bool eEmpty = expectedBuffer.isEmpty();
+    bool aEmpty = actualBuffer.isEmpty();
+    bool eEmpty = expectedBuffer.isEmpty();
 
-	// Both empty succeeds
-	if (aEmpty && eEmpty) return true;
+    // Both empty succeeds
+    if(aEmpty && eEmpty) {
+        return true;
+    }
 
-	// One empty and not the other is a failure
-	if (aEmpty || eEmpty)
-	{
-std::cerr << "isBufferResultMatch failed (one empty and one not)" << std::endl;
-		return false;
-	}
+    // One empty and not the other is a failure
+    if(aEmpty || eEmpty) {
+        std::cerr << "isBufferResultMatch failed (one empty and one not)" << std::endl;
+        return false;
+    }
 
 
-   // NOTE: we need to test hausdorff distance in both directions
+    // NOTE: we need to test hausdorff distance in both directions
 
-	if (! isBoundaryHausdorffDistanceInTolerance(actualBuffer,
-	           expectedBuffer, distance))
-	{
-std::cerr << "isBoundaryHasudorffDistanceInTolerance failed (actual,expected)" << std::endl;
-		return false;
-	}
+    if(! isBoundaryHausdorffDistanceInTolerance(actualBuffer,
+            expectedBuffer, distance)) {
+        std::cerr << "isBoundaryHasudorffDistanceInTolerance failed (actual,expected)" << std::endl;
+        return false;
+    }
 
-	if (! isBoundaryHausdorffDistanceInTolerance(expectedBuffer,
-	           actualBuffer, distance))
-	{
-std::cerr << "isBoundaryHasudorffDistanceInTolerance failed (expected,actual)" << std::endl;
-		return false;
-	}
+    if(! isBoundaryHausdorffDistanceInTolerance(expectedBuffer,
+            actualBuffer, distance)) {
+        std::cerr << "isBoundaryHasudorffDistanceInTolerance failed (expected,actual)" << std::endl;
+        return false;
+    }
 
-	return true;
+    return true;
 }
 
 bool
 SingleSidedBufferResultMatcher::isBoundaryHausdorffDistanceInTolerance(
-	const geom::Geometry& actualBuffer,
-	const geom::Geometry& expectedBuffer, double distance)
+    const geom::Geometry& actualBuffer,
+    const geom::Geometry& expectedBuffer, double distance)
 {
-	typedef std::unique_ptr<geom::Geometry> GeomPtr;
+    typedef std::unique_ptr<geom::Geometry> GeomPtr;
 
-	using geos::algorithm::distance::DiscreteHausdorffDistance;
+    using geos::algorithm::distance::DiscreteHausdorffDistance;
 
-	GeomPtr actualBdy ( actualBuffer.clone() );
-	GeomPtr expectedBdy ( expectedBuffer.clone() );
+    GeomPtr actualBdy(actualBuffer.clone());
+    GeomPtr expectedBdy(expectedBuffer.clone());
 
-	DiscreteHausdorffDistance haus(*actualBdy, *expectedBdy);
-	haus.setDensifyFraction(0.25);
+    DiscreteHausdorffDistance haus(*actualBdy, *expectedBdy);
+    haus.setDensifyFraction(0.25);
 
-	double maxDistanceFound = haus.orientedDistance();
+    double maxDistanceFound = haus.orientedDistance();
 
-	double expectedDistanceTol = fabs(distance) / MAX_HAUSDORFF_DISTANCE_FACTOR;
-	if (expectedDistanceTol < MIN_DISTANCE_TOLERANCE)
-	{
-		expectedDistanceTol = MIN_DISTANCE_TOLERANCE;
-	}
+    double expectedDistanceTol = fabs(distance) / MAX_HAUSDORFF_DISTANCE_FACTOR;
+    if(expectedDistanceTol < MIN_DISTANCE_TOLERANCE) {
+        expectedDistanceTol = MIN_DISTANCE_TOLERANCE;
+    }
 
-	if (maxDistanceFound > expectedDistanceTol)
-	{
-std::cerr << "maxDistanceFound: " << maxDistanceFound << " tolerated " << expectedDistanceTol << std::endl;
-		return false;
-	}
+    if(maxDistanceFound > expectedDistanceTol) {
+        std::cerr << "maxDistanceFound: " << maxDistanceFound << " tolerated " << expectedDistanceTol << std::endl;
+        return false;
+    }
 
-	return true;
+    return true;
 }
 
 } // namespace geos::xmltester
diff --git a/tests/xmltester/SingleSidedBufferResultMatcher.h b/tests/xmltester/SingleSidedBufferResultMatcher.h
index effe85d..a9bd13f 100644
--- a/tests/xmltester/SingleSidedBufferResultMatcher.h
+++ b/tests/xmltester/SingleSidedBufferResultMatcher.h
@@ -21,36 +21,35 @@
 
 // Forward declarations
 namespace geos {
-	namespace geom {
-		class Geometry;
-	}
+namespace geom {
+class Geometry;
+}
 }
 
 namespace geos {
 namespace xmltester {
 
-class SingleSidedBufferResultMatcher
-{
+class SingleSidedBufferResultMatcher {
 public:
-	bool isBufferResultMatch(const geom::Geometry& actualBuffer,
-	                         const geom::Geometry& expectedBuffer,
-	                         double distance);
+    bool isBufferResultMatch(const geom::Geometry& actualBuffer,
+                             const geom::Geometry& expectedBuffer,
+                             double distance);
 
 private:
 
-	static double MAX_HAUSDORFF_DISTANCE_FACTOR;
+    static double MAX_HAUSDORFF_DISTANCE_FACTOR;
 
-	/*
-	 * The minimum distance tolerance which will be used.
-	 * This is required because densified vertices do no lie
-	 * precisely on their parent segment.
-	 */
-	static double MIN_DISTANCE_TOLERANCE;
+    /*
+     * The minimum distance tolerance which will be used.
+     * This is required because densified vertices do no lie
+     * precisely on their parent segment.
+     */
+    static double MIN_DISTANCE_TOLERANCE;
 
-	bool isBoundaryHausdorffDistanceInTolerance(
-                        const geom::Geometry& actualBuffer,
-	                const geom::Geometry& expectedBuffer,
-	                double distance);
+    bool isBoundaryHausdorffDistanceInTolerance(
+        const geom::Geometry& actualBuffer,
+        const geom::Geometry& expectedBuffer,
+        double distance);
 };
 
 } // namespace geos::xmltester
diff --git a/tests/xmltester/XMLTester.cpp b/tests/xmltester/XMLTester.cpp
index a9e4ce4..bd7165f 100644
--- a/tests/xmltester/XMLTester.cpp
+++ b/tests/xmltester/XMLTester.cpp
@@ -93,32 +93,39 @@ using std::runtime_error;
 
 namespace {
 
-std::unique_ptr<const PreparedGeometry> prepare( const geom::Geometry *g ) {
-    return std::unique_ptr<const PreparedGeometry> ( PreparedGeometryFactory::prepare(g) );
+std::unique_ptr<const PreparedGeometry>
+prepare(const geom::Geometry* g)
+{
+    return std::unique_ptr<const PreparedGeometry> (PreparedGeometryFactory::prepare(g));
 }
 
 // Asymmetric Rounding Algorithm  - equivalent to Java Math.round()
 // Copy from geos/util/math.cpp
-double java_math_round(double val)
+double
+java_math_round(double val)
 {
     double n;
     double f = std::fabs(std::modf(val, &n));
 
-    if (val >= 0)
-    {
-        if (f < 0.5) {
+    if(val >= 0) {
+        if(f < 0.5) {
             return std::floor(val);
-        } else if (f > 0.5) {
+        }
+        else if(f > 0.5) {
             return std::ceil(val);
-        } else {
+        }
+        else {
             return (n + 1.0);
         }
-    } else {
-        if (f < 0.5) {
+    }
+    else {
+        if(f < 0.5) {
             return std::ceil(val);
-        } else if (f > 0.5) {
+        }
+        else if(f > 0.5) {
             return std::floor(val);
-        } else {
+        }
+        else {
             return n;
         }
     }
@@ -126,14 +133,17 @@ double java_math_round(double val)
 
 
 // a utility function defining a very simple method to indent a line of text
-const char * getIndent( unsigned int numIndents )
+const char*
+getIndent(unsigned int numIndents)
 {
-    static const char * pINDENT = "                                      + ";
-    static const unsigned int LENGTH = static_cast<unsigned int>(strlen( pINDENT ));
+    static const char* pINDENT = "                                      + ";
+    static const unsigned int LENGTH = static_cast<unsigned int>(strlen(pINDENT));
 
-    if ( numIndents > LENGTH ) numIndents = LENGTH;
+    if(numIndents > LENGTH) {
+        numIndents = LENGTH;
+    }
 
-    return &pINDENT[ LENGTH-numIndents ];
+    return &pINDENT[ LENGTH - numIndents ];
 }
 
 
@@ -163,12 +173,17 @@ normalize_filename(const std::string& str)
     std::string newstring;
 
     std::string::size_type last_slash = str.find_last_of('/', str.size());
-    if ( last_slash == std::string::npos ) newstring = str;
-    else newstring = str.substr(last_slash+1);
+    if(last_slash == std::string::npos) {
+        newstring = str;
+    }
+    else {
+        newstring = str.substr(last_slash + 1);
+    }
 
-    for (std::string::iterator i=newstring.begin(), e=newstring.end(); i!=e; ++i)
-    {
-        if ( *i == '.' ) *i = '_';
+    for(std::string::iterator i = newstring.begin(), e = newstring.end(); i != e; ++i) {
+        if(*i == '.') {
+            *i = '_';
+        }
     }
 
     tolower(newstring);
@@ -180,9 +195,13 @@ static int
 checkOverlaySuccess(geom::Geometry const& gRes, geom::Geometry const& gRealRes)
 {
     double tol = operation::overlay::snap::GeometrySnapper::computeSizeBasedSnapTolerance(gRes);
-    if ( gRes.equals(&gRealRes) ) return 1;
+    if(gRes.equals(&gRealRes)) {
+        return 1;
+    }
     std::cerr << "Using an overlay tolerance of " << tol << std::endl;
-    if ( gRes.equalsExact(&gRealRes, tol) ) return 1;
+    if(gRes.equalsExact(&gRealRes, tol)) {
+        return 1;
+    }
     return 0;
 }
 
@@ -191,23 +210,20 @@ static int
 checkBufferSuccess(geom::Geometry const& gRes, geom::Geometry const& gRealRes, double dist)
 {
     int success = 1;
-    do
-    {
+    do {
 
-        if ( gRes.getGeometryTypeId() != gRealRes.getGeometryTypeId() )
-        {
+        if(gRes.getGeometryTypeId() != gRealRes.getGeometryTypeId()) {
             std::cerr << "Expected result is of type "
                       << gRes.getGeometryType()
                       << "; obtained result is of type "
                       << gRealRes.getGeometryType()
                       << std::endl;
-            success=0;
+            success = 0;
             break;
         }
 
         // Is a buffer always an area ?
-        if ( gRes.getDimension() != 2 )
-        {
+        if(gRes.getDimension() != 2) {
             std::cerr << "Don't know how to validate "
                       << "result of buffer operation "
                       << "when expected result is not an "
@@ -217,17 +233,16 @@ checkBufferSuccess(geom::Geometry const& gRes, geom::Geometry const& gRealRes, d
 
 
         geos::xmltester::BufferResultMatcher matcher;
-        if ( ! matcher.isBufferResultMatch(gRealRes,
-                                           gRes,
-                                           dist) )
-        {
+        if(! matcher.isBufferResultMatch(gRealRes,
+                                         gRes,
+                                         dist)) {
             std::cerr << "BufferResultMatcher FAILED" << std::endl;
-            success=0;
+            success = 0;
             break;
         }
 
     }
-    while (0);
+    while(0);
 
     return success;
 }
@@ -237,32 +252,29 @@ checkSingleSidedBufferSuccess(geom::Geometry& gRes,
                               geom::Geometry& gRealRes, double dist)
 {
     int success = 1;
-    do
-    {
+    do {
 
-        if ( gRes.getGeometryTypeId() != gRealRes.getGeometryTypeId() )
-        {
+        if(gRes.getGeometryTypeId() != gRealRes.getGeometryTypeId()) {
             std::cerr << "Expected result is of type "
                       << gRes.getGeometryType()
                       << "; obtained result is of type "
                       << gRealRes.getGeometryType()
                       << std::endl;
-            success=0;
+            success = 0;
             break;
         }
 
         geos::xmltester::SingleSidedBufferResultMatcher matcher;
-        if ( ! matcher.isBufferResultMatch(gRealRes,
-                                           gRes,
-                                           dist) )
-        {
+        if(! matcher.isBufferResultMatch(gRealRes,
+                                         gRes,
+                                         dist)) {
             std::cerr << "SingleSidedBufferResultMatcher FAILED" << std::endl;
-            success=0;
+            success = 0;
             break;
         }
 
     }
-    while (0);
+    while(0);
 
     return success;
 }
@@ -296,19 +308,19 @@ XMLTester::XMLTester()
 int
 XMLTester::setVerbosityLevel(int value)
 {
-    int old_value=verbose;
+    int old_value = verbose;
 
-    verbose=value;
+    verbose = value;
 
     return old_value;
 }
 
 /*private*/
 void
-XMLTester::printTest(bool success, const std::string& expected_result, const std::string& actual_result, const util::Profile &prof)
+XMLTester::printTest(bool success, const std::string& expected_result, const std::string& actual_result,
+                     const util::Profile& prof)
 {
-    if ( sqlOutput )
-    {
+    if(sqlOutput) {
         std::cout << "INSERT INTO \"" << normalize_filename(*curr_file) << "\" VALUES ("
                   << caseCount << ", "
                   << testCount << ", "
@@ -317,64 +329,68 @@ XMLTester::printTest(bool success, const std::string& expected_result, const std
 
         std::string geomOut;
 
-        if ( gA ) {
+        if(gA) {
             std::cout << "'" << printGeom(gA) << "', ";
-        } else {
+        }
+        else {
             std::cout << "NULL, ";
         }
 
-        if ( gB ) {
+        if(gB) {
             std::cout << "'" << printGeom(gB) << "', ";
-        } else {
+        }
+        else {
             std::cout << "NULL, ";
         }
 
         std::cout << "'" << expected_result << "', "
                   << "'" << actual_result << "', ";
 
-        if ( success ) std::cout << "'t'";
-        else std::cout << "'f'";
+        if(success) {
+            std::cout << "'t'";
+        }
+        else {
+            std::cout << "'f'";
+        }
 
         std::cout << ");" << std::endl;
     }
 
-    else
-    {
-        std::cout << *curr_file <<":";
+    else {
+        std::cout << *curr_file << ":";
         std::cout << " case" << caseCount << ":";
         std::cout << " test" << testCount << ": "
                   << opSignature;
-        std::cout << ": " << (success?"ok.":"failed.");
-        std::cout << " (" << std::setprecision(15) << java_math_round(prof.getTot()/1000) << " ms)" << std::endl;
+        std::cout << ": " << (success ? "ok." : "failed.");
+        std::cout << " (" << std::setprecision(15) << java_math_round(prof.getTot() / 1000) << " ms)" << std::endl;
 
         std::cout << "\tDescription: " << curr_case_desc << std::endl;
 
 
-        if ( gA ) {
+        if(gA) {
             std::cout << "\tGeometry A: ";
             printGeom(std::cout, gA);
             std::cout << std::endl;
         }
 
-        if ( gB ) {
+        if(gB) {
             std::cout << "\tGeometry B: ";
             printGeom(std::cout, gB);
             std::cout << std::endl;
         }
 
-        std::cout << "\tExpected result: "<<expected_result<<std::endl;
-        std::cout << "\tObtained result: "<<actual_result<<std::endl;
-        std::cout <<std::endl;
+        std::cout << "\tExpected result: " << expected_result << std::endl;
+        std::cout << "\tObtained result: " << actual_result << std::endl;
+        std::cout << std::endl;
     }
 }
 
 void
-XMLTester::run(const std::string &source)
+XMLTester::run(const std::string& source)
 {
-    curr_file=&source;
+    curr_file = &source;
 
-    if ( sqlOutput )
-    {
+    if(sqlOutput) {
         std::cout << "CREATE TABLE \"" << normalize_filename(*curr_file) << "\""
                   << "( caseno integer, testno integer, "
                   << " operation varchar, description varchar, "
@@ -392,11 +408,10 @@ XMLTester::run(const std::string &source)
 
     ++testFileCount;
 
-    caseCount=0;
+    caseCount = 0;
 
     tinyxml2::XMLError e = xml.LoadFile(source.c_str());
-    if ( e )
-    {
+    if(e) {
         std::stringstream err;
         err << "Could not load " << source << ": " << e << std::endl;
         xml.~XMLDocument(); // Deallocates various internal pools
@@ -407,26 +422,27 @@ XMLTester::run(const std::string &source)
 
     const tinyxml2::XMLNode* node = xml.FirstChildElement("run");
 
-    if ( ! node )
+    if(! node) {
         throw(runtime_error("Document has no childs"));
+    }
 
     parseRun(node);
 
 }
 
 void
-XMLTester::resultSummary(std::ostream &os) const
+XMLTester::resultSummary(std::ostream& os) const
 {
-    os<<"Files: "<<testFileCount<<std::endl;
-    os<<"Tests: "<<totalTestCount<<std::endl;
-    os<<"Failed: "<<failed<<std::endl;
-    os<<"Succeeded: "<<succeeded<<std::endl;
+    os << "Files: " << testFileCount << std::endl;
+    os << "Tests: " << totalTestCount << std::endl;
+    os << "Failed: " << failed << std::endl;
+    os << "Succeeded: " << succeeded << std::endl;
 }
 
 void
 XMLTester::resetCounters()
 {
-    testFileCount=totalTestCount=failed=succeeded=0;
+    testFileCount = totalTestCount = failed = succeeded = 0;
 }
 
 void
@@ -440,30 +456,36 @@ XMLTester::parseRun(const tinyxml2::XMLNode* node)
 
     // Look for precisionModel element
     const tinyxml2::XMLElement* el = node->FirstChildElement("precisionModel");
-    if ( el ) parsePrecisionModel(el);
-    else pm.reset(new PrecisionModel());
+    if(el) {
+        parsePrecisionModel(el);
+    }
+    else {
+        pm.reset(new PrecisionModel());
+    }
 
     // Look for geometryOperation, if any
     usePrepared = false;
     el = node->FirstChildElement("geometryOperation");
-    if ( el ) {
+    if(el) {
         const tinyxml2::XMLNode* txt = el->FirstChild();
-        if ( txt ) {
+        if(txt) {
             std::string op = trimBlanks(txt->Value());
-            if ( op.find("PreparedGeometryOperation") ) {
+            if(op.find("PreparedGeometryOperation")) {
                 usePrepared = true;
-            } else {
+            }
+            else {
                 std::cerr << *curr_file
-                          <<": WARNING: unknown geometryOperation: "
+                          << ": WARNING: unknown geometryOperation: "
                           << op << std::endl;
             }
         }
     }
 
-    if (verbose > 1)
-    {
-        std::cerr << *curr_file <<": run: Precision Model: " << pm->toString();
-        if ( usePrepared ) std::cerr << " (prepared)";
+    if(verbose > 1) {
+        std::cerr << *curr_file << ": run: Precision Model: " << pm->toString();
+        if(usePrepared) {
+            std::cerr << " (prepared)";
+        }
         std::cerr << std::endl;
     }
 
@@ -475,14 +497,14 @@ XMLTester::parseRun(const tinyxml2::XMLNode* node)
     wkbwriter.reset(new io::WKBWriter());
 
     const tinyxml2::XMLNode* casenode;
-    for ( casenode = node->FirstChildElement("case");
+    for(casenode = node->FirstChildElement("case");
             casenode;
-            casenode = casenode->NextSiblingElement("case") )
-    {
+            casenode = casenode->NextSiblingElement("case")) {
         try {
             parseCase(casenode);
-        } catch (const std::exception& exc) {
-            std::cerr<<exc.what()<<std::endl;
+        }
+        catch(const std::exception& exc) {
+            std::cerr << exc.what() << std::endl;
         }
     }
 
@@ -498,20 +520,21 @@ XMLTester::parsePrecisionModel(const tinyxml2::XMLElement* el)
     /* This does not seem to work... */
     std::string type;
     const char* typeStr = el->Attribute("type");
-    if ( typeStr ) type = typeStr;
+    if(typeStr) {
+        type = typeStr;
+    }
 
     const char* scaleStr = el->Attribute("scale");
 
-    if ( ! scaleStr ) {
-        if ( type == "FLOATING_SINGLE" )
-        {
+    if(! scaleStr) {
+        if(type == "FLOATING_SINGLE") {
             pm.reset(new PrecisionModel(PrecisionModel::FLOATING_SINGLE));
         }
-        else
-        {
+        else {
             pm.reset(new PrecisionModel());
         }
-    } else {
+    }
+    else {
 
         char* stopstring;
 
@@ -519,10 +542,10 @@ XMLTester::parsePrecisionModel(const tinyxml2::XMLElement* el)
         double offsetX = 0;
         double offsetY = 2;
 
-        if ( ! el->QueryDoubleAttribute("offsetx", &offsetX) )
+        if(! el->QueryDoubleAttribute("offsetx", &offsetX))
         {} // std::cerr << "No offsetx" << std::endl;
 
-        if ( ! el->QueryDoubleAttribute("offsety", &offsetY) )
+        if(! el->QueryDoubleAttribute("offsety", &offsetY))
         {} // std::cerr << "No offsety" << std::endl;
 
         // NOTE: PrecisionModel discards offsets anyway...
@@ -535,9 +558,8 @@ XMLTester::testValid(const geom::Geometry* g, const std::string& label)
 {
     operation::valid::IsValidOp ivo(g);
     bool valid = ivo.isValid();
-    if ( ! valid )
-    {
-        operation::valid::TopologyValidationError *err = ivo.getValidationError();
+    if(! valid) {
+        operation::valid::TopologyValidationError* err = ivo.getValidationError();
         std::cerr << *curr_file << ":"
                   << " case" << caseCount << ":"
                   << " test" << testCount << ": "
@@ -551,23 +573,23 @@ XMLTester::testValid(const geom::Geometry* g, const std::string& label)
 /**
  * Parse WKT or HEXWKB
  */
-geom::Geometry *
-XMLTester::parseGeometry(const std::string &in, const char* label)
+geom::Geometry*
+XMLTester::parseGeometry(const std::string& in, const char* label)
 {
-    if ( ( ! wkbreader.get() ) || ( ! wktreader.get() ) )
+    if((! wkbreader.get()) || (! wktreader.get())) {
         throw(runtime_error("No precision model specified"));
+    }
 
     std::stringstream is(in, std::ios_base::in);
     char first_char;
 
     // Remove leading spaces
-    while (is.get(first_char) && std::isspace(first_char));
+    while(is.get(first_char) && std::isspace(first_char));
     is.unget();
 
     geom::Geometry* ret;
 
-    switch (first_char)
-    {
+    switch(first_char) {
     case '0':
     case '1':
     case '2':
@@ -591,7 +613,9 @@ XMLTester::parseGeometry(const std::string &in, const char* label)
         break;
     }
 
-    if ( testValidInput ) testValid(ret, std::string(label));
+    if(testValidInput) {
+        testValid(ret, std::string(label));
+    }
 
     //ret->normalize();
 
@@ -599,13 +623,17 @@ XMLTester::parseGeometry(const std::string &in, const char* label)
 }
 
 std::string
-XMLTester::trimBlanks(const std::string &in)
+XMLTester::trimBlanks(const std::string& in)
 {
     std::string out;
     std::string::size_type pos = in.find_first_not_of(" \t\n\r");
-    if (pos!=std::string::npos) out=in.substr(pos);
+    if(pos != std::string::npos) {
+        out = in.substr(pos);
+    }
     pos = out.find_last_not_of(" \t\n\r");
-    if (pos!=std::string::npos) out=out.substr(0, pos+1);
+    if(pos != std::string::npos) {
+        out = out.substr(0, pos + 1);
+    }
     return out;
 }
 
@@ -618,39 +646,40 @@ XMLTester::parseCase(const tinyxml2::XMLNode* node)
     std::string geomBin;
     std::string thrownException;
 
-    gA=nullptr;
-    gB=nullptr;
+    gA = nullptr;
+    gB = nullptr;
 
 
     //dump_to_stdout(node);
 
     curr_case_desc.clear();
     const tinyxml2::XMLNode* txt = node->FirstChildElement("desc");
-    if ( txt ) {
+    if(txt) {
         txt = txt->FirstChild();
-        if ( txt ) curr_case_desc = trimBlanks(txt->Value());
+        if(txt) {
+            curr_case_desc = trimBlanks(txt->Value());
+        }
     }
 
     //std::cerr << "Desc: " << curr_case_desc << std::endl;
 
 
     try {
-        const tinyxml2::XMLNode *el = node->FirstChildElement("a");
+        const tinyxml2::XMLNode* el = node->FirstChildElement("a");
         geomAin = el->FirstChild()->Value();
         geomAin = trimBlanks(geomAin);
         gA = parseGeometry(geomAin, "Geometry A");
 
-        if ( nullptr != (el = node->FirstChildElement("b")) )
-        {
+        if(nullptr != (el = node->FirstChildElement("b"))) {
             geomBin = el->FirstChild()->Value();
             geomBin = trimBlanks(geomBin);
             gB = parseGeometry(geomBin, "Geometry B");
         }
     }
-    catch (const std::exception &e) {
+    catch(const std::exception& e) {
         thrownException = e.what();
     }
-    catch (...) {
+    catch(...) {
         thrownException = "Unknown exception";
     }
 
@@ -658,26 +687,24 @@ XMLTester::parseCase(const tinyxml2::XMLNode* node)
 //std::cerr << "B: " << geomBin << std::endl;
 
 
-    if ( thrownException != "" )
-    {
-        std::cout << *curr_file <<":";
+    if(thrownException != "") {
+        std::cout << *curr_file << ":";
         std::cout << " case" << caseCount << ":";
-        std::cout << " skipped ("<<thrownException<<")."<<std::endl;
+        std::cout << " skipped (" << thrownException << ")." << std::endl;
         return;
     }
 
     ++caseCount;
-    testCount=0;
+    testCount = 0;
 
     const tinyxml2::XMLNode* testnode;
-    for ( testnode = node->FirstChildElement("test");
+    for(testnode = node->FirstChildElement("test");
             testnode;
-            testnode = testnode->NextSiblingElement("test") )
-    {
+            testnode = testnode->NextSiblingElement("test")) {
         parseTest(testnode);
     }
 
-    totalTestCount+=testCount;
+    totalTestCount += testCount;
 
     delete gA;
     delete gB;
@@ -685,24 +712,22 @@ XMLTester::parseCase(const tinyxml2::XMLNode* node)
 
 /*private*/
 void
-XMLTester::printGeom(std::ostream& os, const geom::Geometry *g)
+XMLTester::printGeom(std::ostream& os, const geom::Geometry* g)
 {
     os << printGeom(g);
 }
 
 std::string
-XMLTester::printGeom(const geom::Geometry *g)
+XMLTester::printGeom(const geom::Geometry* g)
 {
-    if ( HEXWKB_output )
-    {
-        std::stringstream s(std::ios_base::binary|std::ios_base::in|std::ios_base::out);
+    if(HEXWKB_output) {
+        std::stringstream s(std::ios_base::binary | std::ios_base::in | std::ios_base::out);
         wkbwriter->write(*g, s);
         std::stringstream s2;
         wkbreader->printHEX(s, s2);
         return s2.str();
     }
-    else
-    {
+    else {
         return wktwriter->write(g);
     }
 }
@@ -714,7 +739,7 @@ XMLTester::parseTest(const tinyxml2::XMLNode* node)
 
     typedef std::unique_ptr< geom::Geometry > GeomPtr;
 
-    int success=0; // no success by default
+    int success = 0; // no success by default
     std::string opName;
     std::string opArg1;
     std::string opArg2;
@@ -725,30 +750,41 @@ XMLTester::parseTest(const tinyxml2::XMLNode* node)
     ++testCount;
 
     const tinyxml2::XMLNode* opnode = node->FirstChildElement("op");
-    if ( ! opnode ) throw(runtime_error("case has no op"));
+    if(! opnode) {
+        throw(runtime_error("case has no op"));
+    }
 
     //dump_to_stdout(opnode);
 
     const tinyxml2::XMLElement* opel = opnode->ToElement();
 
     const char* tmp = opel->Attribute("name");
-    if ( tmp ) opName = tmp;
+    if(tmp) {
+        opName = tmp;
+    }
 
     tmp = opel->Attribute("arg1");
-    if ( tmp ) opArg1 = tmp;
+    if(tmp) {
+        opArg1 = tmp;
+    }
 
     tmp = opel->Attribute("arg2");
-    if ( tmp ) opArg2 = tmp;
+    if(tmp) {
+        opArg2 = tmp;
+    }
 
     tmp = opel->Attribute("arg3");
-    if ( tmp ) opArg3 = tmp;
+    if(tmp) {
+        opArg3 = tmp;
+    }
 
     tmp = opel->Attribute("arg4");
-    if ( tmp ) opArg4 = tmp;
+    if(tmp) {
+        opArg4 = tmp;
+    }
 
     const tinyxml2::XMLNode* resnode = opnode->FirstChild();
-    if ( ! resnode )
-    {
+    if(! resnode) {
         std::stringstream p_tmp;
         p_tmp << "op of test " << testCount
               << " of case " << caseCount
@@ -758,74 +794,91 @@ XMLTester::parseTest(const tinyxml2::XMLNode* node)
     opRes = resnode->Value();
 
     // trim blanks
-    opRes=trimBlanks(opRes);
-    opName=trimBlanks(opName);
+    opRes = trimBlanks(opRes);
+    opName = trimBlanks(opName);
     tolower(opName);
 
-    std::string opSig="";
+    std::string opSig = "";
 
-    if ( opArg1 != "" ) opSig=opArg1;
-    if ( opArg2 != "" ) {
-        if ( opSig != "" ) opSig += ", ";
+    if(opArg1 != "") {
+        opSig = opArg1;
+    }
+    if(opArg2 != "") {
+        if(opSig != "") {
+            opSig += ", ";
+        }
         opSig += opArg2;
     }
-    if ( opArg3 != "" ) {
-        if ( opSig != "" ) opSig += ", ";
+    if(opArg3 != "") {
+        if(opSig != "") {
+            opSig += ", ";
+        }
         opSig += opArg3;
     }
-    if ( opArg4 != "" ) {
-        if ( opSig != "" ) opSig += ", ";
+    if(opArg4 != "") {
+        if(opSig != "") {
+            opSig += ", ";
+        }
         opSig += opArg4;
     }
 
     opSignature = opName + "(" + opSig + ")";
 
-    std::string actual_result="NONE";
+    std::string actual_result = "NONE";
 
     // expected_result will be modified by specific tests
     // if needed (geometry normalization, for example)
-    std::string expected_result=opRes;
+    std::string expected_result = opRes;
 
     util::Profile profile("op");
 
-    try
-    {
-        if (opName=="relate")
-        {
+    try {
+        if(opName == "relate") {
             std::unique_ptr<geom::IntersectionMatrix> im(gA->relate(gB));
             assert(im.get());
 
-            if (im->matches(opArg3)) actual_result="true";
-            else actual_result="false";
+            if(im->matches(opArg3)) {
+                actual_result = "true";
+            }
+            else {
+                actual_result = "false";
+            }
 
-            if (actual_result==opRes) success=1;
+            if(actual_result == opRes) {
+                success = 1;
+            }
         }
-        else if (opName=="relatestring")
-        {
+        else if(opName == "relatestring") {
             std::unique_ptr<geom::IntersectionMatrix> im(gA->relate(gB));
             assert(im.get());
 
-            actual_result=im->toString();
+            actual_result = im->toString();
 
-            if (actual_result==opRes) success=1;
+            if(actual_result == opRes) {
+                success = 1;
+            }
         }
 
-        else if (opName=="isvalid")
-        {
-            geom::Geometry *p_gT=gA;
-            if ( ( opArg1 == "B" || opArg1 == "b" ) && gB ) {
-                p_gT=gB;
+        else if(opName == "isvalid") {
+            geom::Geometry* p_gT = gA;
+            if((opArg1 == "B" || opArg1 == "b") && gB) {
+                p_gT = gB;
             }
 
-            if (p_gT->isValid()) actual_result="true";
-            else actual_result="false";
+            if(p_gT->isValid()) {
+                actual_result = "true";
+            }
+            else {
+                actual_result = "false";
+            }
 
-            if (actual_result==opRes) success=1;
+            if(actual_result == opRes) {
+                success = 1;
+            }
 
         }
 
-        else if (opName=="intersection")
-        {
+        else if(opName == "intersection") {
 
             GeomPtr gRes(parseGeometry(opRes, "expected"));
             gRes->normalize();
@@ -842,18 +895,20 @@ XMLTester::parseTest(const tinyxml2::XMLNode* node)
 
             gRealRes->normalize();
 
-            if (gRes->compareTo(gRealRes.get())==0) success=1;
+            if(gRes->compareTo(gRealRes.get()) == 0) {
+                success = 1;
+            }
 
-            actual_result=printGeom(gRealRes.get());
-            expected_result=printGeom(gRes.get());
+            actual_result = printGeom(gRealRes.get());
+            expected_result = printGeom(gRes.get());
 
-            if ( testValidOutput )
+            if(testValidOutput) {
                 success &= int(testValid(gRealRes.get(), "result"));
+            }
         }
 
-        else if (opName=="densify")
-        {
-            geom::Geometry *p_gT = gA;
+        else if(opName == "densify") {
+            geom::Geometry* p_gT = gA;
 
             GeomPtr gRes(parseGeometry(opRes, "expected"));
             // gRes->normalize();
@@ -865,41 +920,42 @@ XMLTester::parseTest(const tinyxml2::XMLNode* node)
 
             // gRealRes->normalize();
 
-            if (gRes->compareTo(gRealRes.get())==0)
-                success=1;
+            if(gRes->compareTo(gRealRes.get()) == 0) {
+                success = 1;
+            }
 
-            actual_result=printGeom(gRealRes.get());
-            expected_result=printGeom(gRes.get());
+            actual_result = printGeom(gRealRes.get());
+            expected_result = printGeom(gRes.get());
 
         }
 
 
-        else if (opName=="union")
-        {
+        else if(opName == "union") {
             GeomPtr gRes(parseGeometry(opRes, "expected"));
 
             GeomPtr gRealRes;
-            if ( gB ) {
+            if(gB) {
 #ifndef USE_BINARYOP
                 gRealRes.reset(gA->Union(gB));
 #else
                 gRealRes = BinaryOp(gA, gB, overlayOp(OverlayOp::opUNION));
 #endif
-            } else {
+            }
+            else {
                 gRealRes = gA->Union();
             }
 
             success = checkOverlaySuccess(*gRes, *gRealRes);
 
-            actual_result=printGeom(gRealRes.get());
-            expected_result=printGeom(gRes.get());
+            actual_result = printGeom(gRealRes.get());
+            expected_result = printGeom(gRes.get());
 
-            if ( testValidOutput )
+            if(testValidOutput) {
                 success &= int(testValid(gRealRes.get(), "result"));
+            }
         }
 
-        else if (opName=="difference")
-        {
+        else if(opName == "difference") {
 
             GeomPtr gRes(parseGeometry(opRes, "expected"));
             gRes->normalize();
@@ -912,17 +968,19 @@ XMLTester::parseTest(const tinyxml2::XMLNode* node)
 
             gRealRes->normalize();
 
-            if (gRes->compareTo(gRealRes.get())==0) success=1;
+            if(gRes->compareTo(gRealRes.get()) == 0) {
+                success = 1;
+            }
 
-            actual_result=printGeom(gRealRes.get());
-            expected_result=printGeom(gRes.get());
+            actual_result = printGeom(gRealRes.get());
+            expected_result = printGeom(gRes.get());
 
-            if ( testValidOutput )
+            if(testValidOutput) {
                 success &= int(testValid(gRealRes.get(), "result"));
+            }
         }
 
-        else if (opName=="symdifference")
-        {
+        else if(opName == "symdifference") {
             GeomPtr gRes(parseGeometry(opRes, "expected"));
             gRes->normalize();
 
@@ -934,194 +992,243 @@ XMLTester::parseTest(const tinyxml2::XMLNode* node)
 
             gRealRes->normalize();
 
-            if (gRes->compareTo(gRealRes.get())==0) success=1;
+            if(gRes->compareTo(gRealRes.get()) == 0) {
+                success = 1;
+            }
 
-            actual_result=printGeom(gRealRes.get());
-            expected_result=printGeom(gRes.get());
+            actual_result = printGeom(gRealRes.get());
+            expected_result = printGeom(gRes.get());
 
-            if ( testValidOutput )
+            if(testValidOutput) {
                 success &= int(testValid(gRealRes.get(), "result"));
+            }
         }
 
-        else if (opName=="intersects")
-        {
-            geom::Geometry *g1 = opArg1 == "B" ? gB : gA;
-            geom::Geometry *g2 = opArg2 == "B" ? gB : gA;
+        else if(opName == "intersects") {
+            geom::Geometry* g1 = opArg1 == "B" ? gB : gA;
+            geom::Geometry* g2 = opArg2 == "B" ? gB : gA;
 
-            actual_result="false";
-            if ( usePrepared )
-            {
-                if ( prepare(g1)->intersects(g2) ) actual_result="true";
+            actual_result = "false";
+            if(usePrepared) {
+                if(prepare(g1)->intersects(g2)) {
+                    actual_result = "true";
+                }
+            }
+            else if(g1->intersects(g2)) {
+                actual_result = "true";
             }
-            else if (g1->intersects(g2)) actual_result="true";
 
-            if (actual_result==opRes) success=1;
+            if(actual_result == opRes) {
+                success = 1;
+            }
         }
 
-        else if (opName=="contains")
-        {
-            geom::Geometry *g1 = opArg1 == "B" ? gB : gA;
-            geom::Geometry *g2 = opArg2 == "B" ? gB : gA;
+        else if(opName == "contains") {
+            geom::Geometry* g1 = opArg1 == "B" ? gB : gA;
+            geom::Geometry* g2 = opArg2 == "B" ? gB : gA;
 
-            actual_result="false";
-            if ( usePrepared )
-            {
-                if ( prepare(g1)->contains(g2) ) actual_result="true";
+            actual_result = "false";
+            if(usePrepared) {
+                if(prepare(g1)->contains(g2)) {
+                    actual_result = "true";
+                }
+            }
+            else if(g1->contains(g2)) {
+                actual_result = "true";
             }
-            else if (g1->contains(g2)) actual_result="true";
 
-            if (actual_result==opRes) success=1;
+            if(actual_result == opRes) {
+                success = 1;
+            }
         }
 
-        else if (opName=="overlaps")
-        {
-            geom::Geometry *g1 = opArg1 == "B" ? gB : gA;
-            geom::Geometry *g2 = opArg2 == "B" ? gB : gA;
+        else if(opName == "overlaps") {
+            geom::Geometry* g1 = opArg1 == "B" ? gB : gA;
+            geom::Geometry* g2 = opArg2 == "B" ? gB : gA;
 
-            actual_result="false";
-            if ( usePrepared )
-            {
-                if ( prepare(g1)->overlaps(g2) ) actual_result="true";
+            actual_result = "false";
+            if(usePrepared) {
+                if(prepare(g1)->overlaps(g2)) {
+                    actual_result = "true";
+                }
+            }
+            else if(g1->overlaps(g2)) {
+                actual_result = "true";
             }
-            else if (g1->overlaps(g2)) actual_result="true";
 
-            if (actual_result==opRes) success=1;
+            if(actual_result == opRes) {
+                success = 1;
+            }
         }
 
-        else if (opName=="within")
-        {
-            geom::Geometry *g1 = opArg1 == "B" ? gB : gA;
-            geom::Geometry *g2 = opArg2 == "B" ? gB : gA;
+        else if(opName == "within") {
+            geom::Geometry* g1 = opArg1 == "B" ? gB : gA;
+            geom::Geometry* g2 = opArg2 == "B" ? gB : gA;
 
-            actual_result="false";
-            if ( usePrepared )
-            {
-                if ( prepare(g1)->within(g2) ) actual_result="true";
+            actual_result = "false";
+            if(usePrepared) {
+                if(prepare(g1)->within(g2)) {
+                    actual_result = "true";
+                }
+            }
+            else if(g1->within(g2)) {
+                actual_result = "true";
             }
-            else if (g1->within(g2)) actual_result="true";
 
-            if (actual_result==opRes) success=1;
+            if(actual_result == opRes) {
+                success = 1;
+            }
         }
 
-        else if (opName=="touches")
-        {
-            geom::Geometry *g1 = opArg1 == "B" ? gB : gA;
-            geom::Geometry *g2 = opArg2 == "B" ? gB : gA;
+        else if(opName == "touches") {
+            geom::Geometry* g1 = opArg1 == "B" ? gB : gA;
+            geom::Geometry* g2 = opArg2 == "B" ? gB : gA;
 
-            actual_result="false";
-            if ( usePrepared )
-            {
-                if ( prepare(g1)->touches(g2) ) actual_result="true";
+            actual_result = "false";
+            if(usePrepared) {
+                if(prepare(g1)->touches(g2)) {
+                    actual_result = "true";
+                }
+            }
+            else if(g1->touches(g2)) {
+                actual_result = "true";
             }
-            else if (g1->touches(g2)) actual_result="true";
 
-            if (actual_result==opRes) success=1;
+            if(actual_result == opRes) {
+                success = 1;
+            }
         }
 
-        else if (opName=="crosses")
-        {
-            geom::Geometry *g1 = opArg1 == "B" ? gB : gA;
-            geom::Geometry *g2 = opArg2 == "B" ? gB : gA;
+        else if(opName == "crosses") {
+            geom::Geometry* g1 = opArg1 == "B" ? gB : gA;
+            geom::Geometry* g2 = opArg2 == "B" ? gB : gA;
 
-            actual_result="false";
-            if ( usePrepared )
-            {
-                if ( prepare(g1)->crosses(g2) ) actual_result="true";
+            actual_result = "false";
+            if(usePrepared) {
+                if(prepare(g1)->crosses(g2)) {
+                    actual_result = "true";
+                }
+            }
+            else if(g1->crosses(g2)) {
+                actual_result = "true";
             }
-            else if (g1->crosses(g2)) actual_result="true";
 
-            if (actual_result==opRes) success=1;
+            if(actual_result == opRes) {
+                success = 1;
+            }
         }
 
-        else if (opName=="disjoint")
-        {
-            geom::Geometry *g1 = opArg1 == "B" ? gB : gA;
-            geom::Geometry *g2 = opArg2 == "B" ? gB : gA;
+        else if(opName == "disjoint") {
+            geom::Geometry* g1 = opArg1 == "B" ? gB : gA;
+            geom::Geometry* g2 = opArg2 == "B" ? gB : gA;
 
-            actual_result="false";
-            if ( usePrepared )
-            {
-                if ( prepare(g1)->disjoint(g2) ) actual_result="true";
+            actual_result = "false";
+            if(usePrepared) {
+                if(prepare(g1)->disjoint(g2)) {
+                    actual_result = "true";
+                }
+            }
+            else if(g1->disjoint(g2)) {
+                actual_result = "true";
             }
-            else if (g1->disjoint(g2)) actual_result="true";
 
-            if (actual_result==opRes) success=1;
+            if(actual_result == opRes) {
+                success = 1;
+            }
         }
 
-        else if (opName=="covers")
-        {
-            geom::Geometry *g1 = opArg1 == "B" ? gB : gA;
-            geom::Geometry *g2 = opArg2 == "B" ? gB : gA;
+        else if(opName == "covers") {
+            geom::Geometry* g1 = opArg1 == "B" ? gB : gA;
+            geom::Geometry* g2 = opArg2 == "B" ? gB : gA;
 
-            actual_result="false";
-            if ( usePrepared )
-            {
-                if ( prepare(g1)->covers(g2) ) actual_result="true";
+            actual_result = "false";
+            if(usePrepared) {
+                if(prepare(g1)->covers(g2)) {
+                    actual_result = "true";
+                }
+            }
+            else if(g1->covers(g2)) {
+                actual_result = "true";
             }
-            else if (g1->covers(g2)) actual_result="true";
 
-            if (actual_result==opRes) success=1;
+            if(actual_result == opRes) {
+                success = 1;
+            }
         }
 
         // equalsTopo() is synomym for equals() in JTS
-        else if (opName=="equalstopo")
-        {
-            geom::Geometry *g1 = opArg1 == "B" ? gB : gA;
-            geom::Geometry *g2 = opArg2 == "B" ? gB : gA;
+        else if(opName == "equalstopo") {
+            geom::Geometry* g1 = opArg1 == "B" ? gB : gA;
+            geom::Geometry* g2 = opArg2 == "B" ? gB : gA;
 
-            actual_result="false";
-            if (g1->equals(g2)) actual_result="true";
+            actual_result = "false";
+            if(g1->equals(g2)) {
+                actual_result = "true";
+            }
 
-            if (actual_result==opRes) success=1;
+            if(actual_result == opRes) {
+                success = 1;
+            }
         }
 
-        else if (opName=="equalsexact")
-        {
-            geom::Geometry *g1 = opArg1 == "B" ? gB : gA;
-            geom::Geometry *g2 = opArg2 == "B" ? gB : gA;
+        else if(opName == "equalsexact") {
+            geom::Geometry* g1 = opArg1 == "B" ? gB : gA;
+            geom::Geometry* g2 = opArg2 == "B" ? gB : gA;
 
-            actual_result="false";
-            if (g1->equalsExact(g2)) actual_result="true";
+            actual_result = "false";
+            if(g1->equalsExact(g2)) {
+                actual_result = "true";
+            }
 
-            if (actual_result==opRes) success=1;
+            if(actual_result == opRes) {
+                success = 1;
+            }
         }
 
         // rather than implementing equalsnorm in the library,
         // we just do it in this one test case for now
-        else if (opName=="equalsnorm")
-        {
-            geom::Geometry *g1 = opArg1 == "B" ? gB : gA;
-            geom::Geometry *g2 = opArg2 == "B" ? gB : gA;
+        else if(opName == "equalsnorm") {
+            geom::Geometry* g1 = opArg1 == "B" ? gB : gA;
+            geom::Geometry* g2 = opArg2 == "B" ? gB : gA;
 
             g1->normalize();
             g2->normalize();
 
-            actual_result="false";
-            if (g1->equalsExact(g2)) actual_result="true";
+            actual_result = "false";
+            if(g1->equalsExact(g2)) {
+                actual_result = "true";
+            }
 
-            if (actual_result==opRes) success=1;
+            if(actual_result == opRes) {
+                success = 1;
+            }
         }
 
 
-        else if (opName=="coveredby")
-        {
-            geom::Geometry *g1 = opArg1 == "B" ? gB : gA;
-            geom::Geometry *g2 = opArg2 == "B" ? gB : gA;
+        else if(opName == "coveredby") {
+            geom::Geometry* g1 = opArg1 == "B" ? gB : gA;
+            geom::Geometry* g2 = opArg2 == "B" ? gB : gA;
 
-            actual_result="false";
-            if ( usePrepared )
-            {
-                if ( prepare(g1)->coveredBy(g2) ) actual_result="true";
+            actual_result = "false";
+            if(usePrepared) {
+                if(prepare(g1)->coveredBy(g2)) {
+                    actual_result = "true";
+                }
+            }
+            else if(g1->coveredBy(g2)) {
+                actual_result = "true";
             }
-            else if (g1->coveredBy(g2)) actual_result="true";
 
-            if (actual_result==opRes) success=1;
+            if(actual_result == opRes) {
+                success = 1;
+            }
         }
 
-        else if (opName=="getboundary")
-        {
-            geom::Geometry *p_gT=gA;
-            if ( ( opArg1 == "B" || opArg1 == "b" ) && gB ) p_gT=gB;
+        else if(opName == "getboundary") {
+            geom::Geometry* p_gT = gA;
+            if((opArg1 == "B" || opArg1 == "b") && gB) {
+                p_gT = gB;
+            }
 
             GeomPtr gRes(parseGeometry(opRes, "expected"));
             gRes->normalize();
@@ -1129,54 +1236,73 @@ XMLTester::parseTest(const tinyxml2::XMLNode* node)
             GeomPtr gRealRes(p_gT->getBoundary());
             gRealRes->normalize();
 
-            if (gRes->compareTo(gRealRes.get())==0) success=1;
+            if(gRes->compareTo(gRealRes.get()) == 0) {
+                success = 1;
+            }
 
-            actual_result=printGeom(gRealRes.get());
-            expected_result=printGeom(gRes.get());
+            actual_result = printGeom(gRealRes.get());
+            expected_result = printGeom(gRes.get());
 
-            if ( testValidOutput )
+            if(testValidOutput) {
                 success &= int(testValid(gRealRes.get(), "result"));
+            }
         }
 
-        else if (opName=="getcentroid")
-        {
-            geom::Geometry *p_gT=gA;
-            if ( ( opArg1 == "B" || opArg1 == "b" ) && gB ) p_gT=gB;
+        else if(opName == "getcentroid") {
+            geom::Geometry* p_gT = gA;
+            if((opArg1 == "B" || opArg1 == "b") && gB) {
+                p_gT = gB;
+            }
 
             GeomPtr gRes(parseGeometry(opRes, "expected"));
             gRes->normalize();
 
             GeomPtr gRealRes(p_gT->getCentroid());
 
-            if ( gRealRes.get() ) gRealRes->normalize();
-            else gRealRes.reset(factory->createPoint());
+            if(gRealRes.get()) {
+                gRealRes->normalize();
+            }
+            else {
+                gRealRes.reset(factory->createPoint());
+            }
             gRealRes->normalize();
 
-            if (gRes->compareTo(gRealRes.get())==0) success=1;
+            if(gRes->compareTo(gRealRes.get()) == 0) {
+                success = 1;
+            }
 
-            actual_result=printGeom(gRealRes.get());
-            expected_result=printGeom(gRes.get());
+            actual_result = printGeom(gRealRes.get());
+            expected_result = printGeom(gRes.get());
 
-            if ( testValidOutput )
+            if(testValidOutput) {
                 success &= int(testValid(gRealRes.get(), "result"));
+            }
         }
 
-        else if (opName=="issimple")
-        {
-            geom::Geometry *p_gT=gA;
-            if ( ( opArg1 == "B" || opArg1 == "b" ) && gB ) p_gT=gB;
+        else if(opName == "issimple") {
+            geom::Geometry* p_gT = gA;
+            if((opArg1 == "B" || opArg1 == "b") && gB) {
+                p_gT = gB;
+            }
 
-            if (p_gT->isSimple()) actual_result="true";
-            else actual_result="false";
+            if(p_gT->isSimple()) {
+                actual_result = "true";
+            }
+            else {
+                actual_result = "false";
+            }
 
-            if (actual_result==opRes) success=1;
+            if(actual_result == opRes) {
+                success = 1;
+            }
 
         }
 
-        else if (opName=="convexhull")
-        {
-            geom::Geometry *p_gT=gA;
-            if ( ( opArg1 == "B" || opArg1 == "b" ) && gB ) p_gT=gB;
+        else if(opName == "convexhull") {
+            geom::Geometry* p_gT = gA;
+            if((opArg1 == "B" || opArg1 == "b") && gB) {
+                p_gT = gB;
+            }
 
             GeomPtr gRes(parseGeometry(opRes, "expected"));
             gRes->normalize();
@@ -1184,21 +1310,25 @@ XMLTester::parseTest(const tinyxml2::XMLNode* node)
             GeomPtr gRealRes(p_gT->convexHull());
             gRealRes->normalize();
 
-            if (gRes->compareTo(gRealRes.get())==0) success=1;
+            if(gRes->compareTo(gRealRes.get()) == 0) {
+                success = 1;
+            }
 
-            actual_result=printGeom(gRealRes.get());
-            expected_result=printGeom(gRes.get());
+            actual_result = printGeom(gRealRes.get());
+            expected_result = printGeom(gRes.get());
 
-            if ( testValidOutput )
+            if(testValidOutput) {
                 success &= int(testValid(gRealRes.get(), "result"));
+            }
         }
 
-        else if (opName=="buffer")
-        {
+        else if(opName == "buffer") {
             using namespace operation::buffer;
 
-            geom::Geometry *p_gT=gA;
-            if ( ( opArg1 == "B" || opArg1 == "b" ) && gB ) p_gT=gB;
+            geom::Geometry* p_gT = gA;
+            if((opArg1 == "B" || opArg1 == "b") && gB) {
+                p_gT = gB;
+            }
 
             GeomPtr gRes(parseGeometry(opRes, "expected"));
             gRes->normalize();
@@ -1209,7 +1339,7 @@ XMLTester::parseTest(const tinyxml2::XMLNode* node)
             double dist = std::atof(opArg2.c_str());
 
             BufferParameters params;
-            if ( opArg3 != "" ) {
+            if(opArg3 != "") {
                 params.setQuadrantSegments(std::atoi(opArg3.c_str()));
             }
 
@@ -1223,19 +1353,21 @@ XMLTester::parseTest(const tinyxml2::XMLNode* node)
             // Validate the buffer operation
             success = checkBufferSuccess(*gRes, *gRealRes, dist);
 
-            actual_result=printGeom(gRealRes.get());
-            expected_result=printGeom(gRes.get());
+            actual_result = printGeom(gRealRes.get());
+            expected_result = printGeom(gRes.get());
 
-            if ( testValidOutput )
+            if(testValidOutput) {
                 success &= int(testValid(gRealRes.get(), "result"));
+            }
         }
 
-        else if (opName=="buffersinglesided")
-        {
+        else if(opName == "buffersinglesided") {
             using namespace operation::buffer;
 
-            geom::Geometry *p_gT=gA;
-            if ( ( opArg1 == "B" || opArg1 == "b" ) && gB ) p_gT=gB;
+            geom::Geometry* p_gT = gA;
+            if((opArg1 == "B" || opArg1 == "b") && gB) {
+                p_gT = gB;
+            }
 
             GeomPtr gRes(parseGeometry(opRes, "expected"));
             gRes->normalize();
@@ -1246,20 +1378,19 @@ XMLTester::parseTest(const tinyxml2::XMLNode* node)
             double dist = std::atof(opArg2.c_str());
 
             BufferParameters params ;
-            params.setJoinStyle( BufferParameters::JOIN_ROUND ) ;
-            if ( opArg3 != "" ) {
-                params.setQuadrantSegments( std::atoi(opArg3.c_str()));
+            params.setJoinStyle(BufferParameters::JOIN_ROUND) ;
+            if(opArg3 != "") {
+                params.setQuadrantSegments(std::atoi(opArg3.c_str()));
             }
 
             bool leftSide = true ;
-            if ( opArg4 == "right" )
-            {
+            if(opArg4 == "right") {
                 leftSide = false ;
             }
 
-            BufferBuilder bufBuilder( params ) ;
-            gRealRes.reset( bufBuilder.bufferLineSingleSided(
-                                p_gT, dist, leftSide ) ) ;
+            BufferBuilder bufBuilder(params) ;
+            gRealRes.reset(bufBuilder.bufferLineSingleSided(
+                               p_gT, dist, leftSide)) ;
 
             profile.stop();
             gRealRes->normalize();
@@ -1268,19 +1399,21 @@ XMLTester::parseTest(const tinyxml2::XMLNode* node)
             success = checkSingleSidedBufferSuccess(*gRes,
                                                     *gRealRes, dist);
 
-            actual_result=printGeom(gRealRes.get());
-            expected_result=printGeom(gRes.get());
+            actual_result = printGeom(gRealRes.get());
+            expected_result = printGeom(gRes.get());
 
-            if ( testValidOutput )
+            if(testValidOutput) {
                 success &= int(testValid(gRealRes.get(), "result"));
+            }
         }
 
-        else if (opName=="buffermitredjoin")
-        {
+        else if(opName == "buffermitredjoin") {
             using namespace operation::buffer;
 
-            geom::Geometry *p_gT=gA;
-            if ( ( opArg1 == "B" || opArg1 == "b" ) && gB ) p_gT=gB;
+            geom::Geometry* p_gT = gA;
+            if((opArg1 == "B" || opArg1 == "b") && gB) {
+                p_gT = gB;
+            }
 
             GeomPtr gRes(parseGeometry(opRes, "expected"));
             gRes->normalize();
@@ -1293,7 +1426,7 @@ XMLTester::parseTest(const tinyxml2::XMLNode* node)
             BufferParameters params;
             params.setJoinStyle(BufferParameters::JOIN_MITRE);
 
-            if ( opArg3 != "" ) {
+            if(opArg3 != "") {
                 params.setQuadrantSegments(std::atoi(opArg3.c_str()));
             }
 
@@ -1306,50 +1439,60 @@ XMLTester::parseTest(const tinyxml2::XMLNode* node)
             // Validate the buffer operation
             success = checkBufferSuccess(*gRes, *gRealRes, dist);
 
-            actual_result=printGeom(gRealRes.get());
-            expected_result=printGeom(gRes.get());
+            actual_result = printGeom(gRealRes.get());
+            expected_result = printGeom(gRes.get());
 
-            if ( testValidOutput )
+            if(testValidOutput) {
                 success &= int(testValid(gRealRes.get(), "result"));
+            }
         }
 
 
-        else if (opName=="getinteriorpoint")
-        {
-            geom::Geometry *p_gT=gA;
-            if ( ( opArg1 == "B" || opArg1 == "b" ) && gB ) p_gT=gB;
+        else if(opName == "getinteriorpoint") {
+            geom::Geometry* p_gT = gA;
+            if((opArg1 == "B" || opArg1 == "b") && gB) {
+                p_gT = gB;
+            }
 
             GeomPtr gRes(parseGeometry(opRes, "expected"));
             gRes->normalize();
 
             GeomPtr gRealRes(p_gT->getInteriorPoint());
-            if ( gRealRes.get() ) gRealRes->normalize();
-            else gRealRes.reset(factory->createPoint());
+            if(gRealRes.get()) {
+                gRealRes->normalize();
+            }
+            else {
+                gRealRes.reset(factory->createPoint());
+            }
 
-            if (gRes->compareTo(gRealRes.get())==0) success=1;
+            if(gRes->compareTo(gRealRes.get()) == 0) {
+                success = 1;
+            }
 
-            actual_result=printGeom(gRealRes.get());
-            expected_result=printGeom(gRes.get());
+            actual_result = printGeom(gRealRes.get());
+            expected_result = printGeom(gRes.get());
 
-            if ( testValidOutput )
+            if(testValidOutput) {
                 success &= int(testValid(gRealRes.get(), "result"));
+            }
         }
 
-        else if (opName=="iswithindistance")
-        {
-            double dist=std::atof(opArg3.c_str());
-            if (gA->isWithinDistance(gB, dist)) {
-                actual_result="true";
-            } else {
-                actual_result="false";
+        else if(opName == "iswithindistance") {
+            double dist = std::atof(opArg3.c_str());
+            if(gA->isWithinDistance(gB, dist)) {
+                actual_result = "true";
+            }
+            else {
+                actual_result = "false";
             }
 
-            if (actual_result==opRes) success=1;
+            if(actual_result == opRes) {
+                success = 1;
+            }
 
         }
 
-        else if (opName=="polygonize")
-        {
+        else if(opName == "polygonize") {
 
             GeomPtr gRes(wktreader->read(opRes));
             gRes->normalize();
@@ -1358,65 +1501,70 @@ XMLTester::parseTest(const tinyxml2::XMLNode* node)
             plgnzr.add(gA);
 
 
-            std::vector<geos::geom::Polygon *>*polys = plgnzr.getPolygons();
-            std::vector<geom::Geometry *>*newgeoms = new std::vector<geom::Geometry *>;
-            for (unsigned int i=0; i<polys->size(); i++)
+            std::vector<geos::geom::Polygon*>* polys = plgnzr.getPolygons();
+            std::vector<geom::Geometry*>* newgeoms = new std::vector<geom::Geometry*>;
+            for(unsigned int i = 0; i < polys->size(); i++) {
                 newgeoms->push_back((*polys)[i]);
+            }
             delete polys;
 
             GeomPtr gRealRes(factory->createGeometryCollection(newgeoms));
             gRealRes->normalize();
 
 
-            if (gRes->compareTo(gRealRes.get())==0) success=1;
+            if(gRes->compareTo(gRealRes.get()) == 0) {
+                success = 1;
+            }
 
-            actual_result=printGeom(gRealRes.get());
-            expected_result=printGeom(gRes.get());
+            actual_result = printGeom(gRealRes.get());
+            expected_result = printGeom(gRes.get());
 
-            if ( testValidOutput )
+            if(testValidOutput) {
                 success &= int(testValid(gRealRes.get(), "result"));
+            }
         }
 
-        else if (opName=="linemerge")
-        {
+        else if(opName == "linemerge") {
             GeomPtr gRes(wktreader->read(opRes));
             gRes->normalize();
 
-            geom::Geometry *p_gT=gA;
+            geom::Geometry* p_gT = gA;
 
-            if ( ( opArg1 == "B" || opArg1 == "b" ) && gB ) p_gT=gB;
+            if((opArg1 == "B" || opArg1 == "b") && gB) {
+                p_gT = gB;
+            }
 
             LineMerger merger;
             merger.add(p_gT);
-            std::unique_ptr< std::vector<geom::LineString *> > lines ( merger.getMergedLineStrings() );
-            std::vector<geom::Geometry *>*newgeoms = new std::vector<geom::Geometry *>(lines->begin(),
+            std::unique_ptr< std::vector<geom::LineString*> > lines(merger.getMergedLineStrings());
+            std::vector<geom::Geometry*>* newgeoms = new std::vector<geom::Geometry*>(lines->begin(),
                     lines->end());
 
             GeomPtr gRealRes(factory->createGeometryCollection(newgeoms));
             gRealRes->normalize();
 
-            if (gRes->compareTo(gRealRes.get())==0) success=1;
+            if(gRes->compareTo(gRealRes.get()) == 0) {
+                success = 1;
+            }
 
-            actual_result=printGeom(gRealRes.get());
-            expected_result=printGeom(gRes.get());
+            actual_result = printGeom(gRealRes.get());
+            expected_result = printGeom(gRes.get());
 
-            if ( testValidOutput )
+            if(testValidOutput) {
                 success &= int(testValid(gRealRes.get(), "result"));
+            }
         }
 
-        else if (opName=="areatest")
-        {
+        else if(opName == "areatest") {
             char* rest;
             double toleratedDiff = std::strtod(opRes.c_str(), &rest);
             int validOut = 1;
 
-            if ( rest == opRes.c_str() )
-            {
+            if(rest == opRes.c_str()) {
                 throw std::runtime_error("malformed testcase: missing tolerated area difference in 'areatest' op");
             }
 
-            if ( verbose > 1 )
-            {
+            if(verbose > 1) {
                 std::cerr << "Running intersection for areatest" << std::endl;
             }
 #ifndef USE_BINARYOP
@@ -1426,13 +1574,11 @@ XMLTester::parseTest(const tinyxml2::XMLNode* node)
                                   overlayOp(OverlayOp::opINTERSECTION));
 #endif
 
-            if ( testValidOutput )
-            {
+            if(testValidOutput) {
                 validOut &= int(testValid(gI.get(), "areatest intersection"));
             }
 
-            if ( verbose > 1 )
-            {
+            if(verbose > 1) {
                 std::cerr << "Running difference(A,B) for areatest" << std::endl;
             }
 
@@ -1443,13 +1589,11 @@ XMLTester::parseTest(const tinyxml2::XMLNode* node)
                                     overlayOp(OverlayOp::opDIFFERENCE));
 #endif
 
-            if ( testValidOutput )
-            {
+            if(testValidOutput) {
                 validOut &= int(testValid(gI.get(), "areatest difference(a,b)"));
             }
 
-            if ( verbose > 1 )
-            {
+            if(verbose > 1) {
                 std::cerr << "Running difference(B,A) for areatest" << std::endl;
             }
 
@@ -1460,13 +1604,11 @@ XMLTester::parseTest(const tinyxml2::XMLNode* node)
                                     overlayOp(OverlayOp::opDIFFERENCE));
 #endif
 
-            if ( testValidOutput )
-            {
+            if(testValidOutput) {
                 validOut &= int(testValid(gI.get(), "areatest difference(b,a)"));
             }
 
-            if ( verbose > 1 )
-            {
+            if(verbose > 1) {
                 std::cerr << "Running symdifference for areatest" << std::endl;
             }
 
@@ -1477,13 +1619,11 @@ XMLTester::parseTest(const tinyxml2::XMLNode* node)
                                    overlayOp(OverlayOp::opSYMDIFFERENCE));
 #endif
 
-            if ( testValidOutput )
-            {
+            if(testValidOutput) {
                 validOut &= int(testValid(gI.get(), "areatest symdifference"));
             }
 
-            if ( verbose > 1 )
-            {
+            if(verbose > 1) {
                 std::cerr << "Running union for areatest" << std::endl;
             }
 
@@ -1511,73 +1651,68 @@ XMLTester::parseTest(const tinyxml2::XMLNode* node)
             // ^ : intersection
 
             // A == ( A ^ B ) + ( A - B )
-            double diff = std::fabs ( areaA - areaI - areaDab );
-            if ( diff > maxdiff ) {
+            double diff = std::fabs(areaA - areaI - areaDab);
+            if(diff > maxdiff) {
                 maxdiffop = "A == ( A ^ B ) + ( A - B )";
                 maxdiff = diff;
             }
 
             // B == ( A ^ B ) + ( B - A )
-            diff = std::fabs ( areaB - areaI - areaDba );
-            if ( diff > maxdiff ) {
+            diff = std::fabs(areaB - areaI - areaDba);
+            if(diff > maxdiff) {
                 maxdiffop = "B == ( A ^ B ) + ( B - A )";
                 maxdiff = diff;
             }
 
             //  ( A @ B ) == ( A - B ) + ( B - A )
-            diff = std::fabs ( areaDab + areaDba - areaSD );
-            if ( diff > maxdiff ) {
+            diff = std::fabs(areaDab + areaDba - areaSD);
+            if(diff > maxdiff) {
                 maxdiffop = "( A @ B ) == ( A - B ) + ( B - A )";
                 maxdiff = diff;
             }
 
             //  ( A u B ) == ( A ^ B ) + ( A @ B )
-            diff = std::fabs ( areaI + areaSD - areaU );
-            if ( diff > maxdiff ) {
+            diff = std::fabs(areaI + areaSD - areaU);
+            if(diff > maxdiff) {
                 maxdiffop = "( A u B ) == ( A ^ B ) + ( A @ B )";
                 maxdiff = diff;
             }
 
-            if ( maxdiff <= toleratedDiff )
-            {
+            if(maxdiff <= toleratedDiff) {
                 success = 1 && validOut;
             }
 
             std::stringstream p_tmp;
             p_tmp << maxdiffop << ": " << maxdiff;
-            actual_result=p_tmp.str();
-            expected_result=opRes;
+            actual_result = p_tmp.str();
+            expected_result = opRes;
 
         }
-        else if (opName=="distance")
-        {
+        else if(opName == "distance") {
             char* rest;
             double distE = std::strtod(opRes.c_str(), &rest);
-            if ( rest == opRes.c_str() )
-            {
+            if(rest == opRes.c_str()) {
                 throw std::runtime_error("malformed testcase: missing expected result in 'distance' op");
             }
 
-            geom::Geometry *g1 = opArg1 == "B" ? gB : gA;
-            geom::Geometry *g2 = opArg2 == "B" ? gB : gA;
+            geom::Geometry* g1 = opArg1 == "B" ? gB : gA;
+            geom::Geometry* g2 = opArg2 == "B" ? gB : gA;
             double distO = g1->distance(g2);
             std::stringstream ss;
             ss << distO;
             actual_result = ss.str();
 
             // TODO: Use a tolerance ?
-            success = ( distO == distE ) ? 1 : 0;
+            success = (distO == distE) ? 1 : 0;
         }
-        else if (opName=="minclearance")
-        {
+        else if(opName == "minclearance") {
             char* rest;
             double minclearanceE = std::strtod(opRes.c_str(), &rest);
-            if ( rest == opRes.c_str() )
-            {
+            if(rest == opRes.c_str()) {
                 throw std::runtime_error("malformed testcase: missing expected result in 'minclearance' op");
             }
 
-            geom::Geometry *g1 = opArg1 == "B" ? gB : gA;
+            geom::Geometry* g1 = opArg1 == "B" ? gB : gA;
             precision::MinimumClearance mc(g1);
 
             double minclearanceO = mc.getDistance();
@@ -1586,34 +1721,32 @@ XMLTester::parseTest(const tinyxml2::XMLNode* node)
             actual_result = ss.str();
 
             // Hack for Inf/1.7976931348623157E308 comparison
-            if (minclearanceO > 1.7976931348623157E308)
+            if(minclearanceO > 1.7976931348623157E308) {
                 minclearanceO = 1.7976931348623157E308;
+            }
 
             // TODO: Use a tolerance ?
-            success = ( minclearanceO == minclearanceE ) ? 1 : 0;
+            success = (minclearanceO == minclearanceE) ? 1 : 0;
         }
-        else if (opName=="minclearanceline")
-        {
+        else if(opName == "minclearanceline") {
 
             double tol = 0.0000001;
             GeomPtr lineE(parseGeometry(opRes, "expected"));
-            if (!lineE)
-            {
+            if(!lineE) {
                 throw std::runtime_error("malformed testcase: missing expected result in 'minclearanceline' op");
             }
 
-            geom::Geometry *g1 = opArg1 == "B" ? gB : gA;
+            geom::Geometry* g1 = opArg1 == "B" ? gB : gA;
             precision::MinimumClearance mc(g1);
             std::unique_ptr<geom::Geometry> lineO = mc.getLine();
             lineO.get()->normalize();
             lineE.get()->normalize();
 
-            actual_result=printGeom(lineO.get());
+            actual_result = printGeom(lineO.get());
             success = lineE.get()->equalsExact(lineO.get(), tol) ? 1 : 0;
         }
 
-        else
-        {
+        else {
             std::cerr << *curr_file << ":";
             std::cerr << " case" << caseCount << ":";
             std::cerr << " test" << testCount << ": "
@@ -1623,54 +1756,70 @@ XMLTester::parseTest(const tinyxml2::XMLNode* node)
         }
 
     }
-    catch (const std::exception &e)
-    {
-        std::cerr<<"EXCEPTION on case "<<caseCount
-                 <<" test "<<testCount<<": "<<e.what()
-                 <<std::endl;
+    catch(const std::exception& e) {
+        std::cerr << "EXCEPTION on case " << caseCount
+                  << " test " << testCount << ": " << e.what()
+                  << std::endl;
         actual_result = e.what();
     }
-    catch (...)
-    {
+    catch(...) {
         std::cerr << "Unknown EXEPTION on case "
                   << caseCount
                   << std::endl;
         actual_result = "Unknown exception thrown";
     }
 
-    if ( success ) ++succeeded;
-    else ++failed;
+    if(success) {
+        ++succeeded;
+    }
+    else {
+        ++failed;
+    }
 
-    if ((!success && verbose) || verbose > 1)
-    {
+    if((!success && verbose) || verbose > 1) {
         printTest(!!success, expected_result, actual_result, profile);
     }
 
-    if (test_predicates && gB && gA) {
+    if(test_predicates && gB && gA) {
         runPredicates(gA, gB);
     }
 
 }
 
 void
-XMLTester::runPredicates(const geom::Geometry *p_gA, const geom::Geometry *p_gB)
+XMLTester::runPredicates(const geom::Geometry* p_gA, const geom::Geometry* p_gB)
 {
-    std::cout << "\t    Equals:\tAB=" << (p_gA->equals(p_gB)?"T":"F") << ", BA=" << (p_gB->equals(p_gA)?"T":"F") << std::endl;
-    std::cout << "\t  Disjoint:\tAB=" << (p_gA->disjoint(p_gB)?"T":"F") << ", BA=" << (p_gB->disjoint(p_gA)?"T":"F") << std::endl;
-    std::cout << "\tIntersects:\tAB=" << (p_gA->intersects(p_gB)?"T":"F") << ", BA=" << (p_gB->intersects(p_gA)?"T":"F") << std::endl;
-    std::cout << "\t   Touches:\tAB=" << (p_gA->touches(p_gB)?"T":"F") << ", BA=" << (p_gB->touches(p_gA)?"T":"F") << std::endl;
-    std::cout << "\t   Crosses:\tAB=" << (p_gA->crosses(p_gB)?"T":"F") << ", BA=" << (p_gB->crosses(p_gA)?"T":"F") << std::endl;
-    std::cout << "\t    Within:\tAB=" << (p_gA->within(p_gB)?"T":"F") << ", BA=" << (p_gB->within(p_gA)?"T":"F") << std::endl;
-    std::cout << "\t  Contains:\tAB=" << (p_gA->contains(p_gB)?"T":"F") << ", BA=" << (p_gB->contains(p_gA)?"T":"F") << std::endl;
-    std::cout << "\t  Overlaps:\tAB=" << (p_gA->overlaps(p_gB)?"T":"F") << ", BA=" << (p_gB->overlaps(p_gA)?"T":"F") << std::endl;
-
-    std::cout << "\t  Prepared Disjoint:\tAB=" << (prepare(p_gA)->disjoint(p_gB)?"T":"F") << ", BA=" << (prepare(p_gB)->disjoint(p_gA)?"T":"F") << std::endl;
-    std::cout << "\tPrepared Intersects:\tAB=" << (prepare(p_gA)->intersects(p_gB)?"T":"F") << ", BA=" << (prepare(p_gB)->intersects(p_gA)?"T":"F") << std::endl;
-    std::cout << "\t   Prepared Touches:\tAB=" << (prepare(p_gA)->touches(p_gB)?"T":"F") << ", BA=" << (prepare(p_gB)->touches(p_gA)?"T":"F") << std::endl;
-    std::cout << "\t   Prepared Crosses:\tAB=" << (prepare(p_gA)->crosses(p_gB)?"T":"F") << ", BA=" << (prepare(p_gB)->crosses(p_gA)?"T":"F") << std::endl;
-    std::cout << "\t    Prepared Within:\tAB=" << (prepare(p_gA)->within(p_gB)?"T":"F") << ", BA=" << (prepare(p_gB)->within(p_gA)?"T":"F") << std::endl;
-    std::cout << "\t  Prepared Contains:\tAB=" << (prepare(p_gA)->contains(p_gB)?"T":"F") << ", BA=" << (prepare(p_gB)->contains(p_gA)?"T":"F") << std::endl;
-    std::cout << "\t Prepared Overlaps:\tAB=" << (prepare(p_gA)->overlaps(p_gB)?"T":"F") << ", BA=" << (prepare(p_gB)->overlaps(p_gA)?"T":"F") << std::endl;
+    std::cout << "\t    Equals:\tAB=" << (p_gA->equals(p_gB) ? "T" : "F") << ", BA=" << (p_gB->equals(
+                  p_gA) ? "T" : "F") << std::endl;
+    std::cout << "\t  Disjoint:\tAB=" << (p_gA->disjoint(p_gB) ? "T" : "F") << ", BA=" << (p_gB->disjoint(
+                  p_gA) ? "T" : "F") << std::endl;
+    std::cout << "\tIntersects:\tAB=" << (p_gA->intersects(p_gB) ? "T" : "F") << ", BA=" << (p_gB->intersects(
+                  p_gA) ? "T" : "F") << std::endl;
+    std::cout << "\t   Touches:\tAB=" << (p_gA->touches(p_gB) ? "T" : "F") << ", BA=" << (p_gB->touches(
+                  p_gA) ? "T" : "F") << std::endl;
+    std::cout << "\t   Crosses:\tAB=" << (p_gA->crosses(p_gB) ? "T" : "F") << ", BA=" << (p_gB->crosses(
+                  p_gA) ? "T" : "F") << std::endl;
+    std::cout << "\t    Within:\tAB=" << (p_gA->within(p_gB) ? "T" : "F") << ", BA=" << (p_gB->within(
+                  p_gA) ? "T" : "F") << std::endl;
+    std::cout << "\t  Contains:\tAB=" << (p_gA->contains(p_gB) ? "T" : "F") << ", BA=" << (p_gB->contains(
+                  p_gA) ? "T" : "F") << std::endl;
+    std::cout << "\t  Overlaps:\tAB=" << (p_gA->overlaps(p_gB) ? "T" : "F") << ", BA=" << (p_gB->overlaps(
+                  p_gA) ? "T" : "F") << std::endl;
+
+    std::cout << "\t  Prepared Disjoint:\tAB=" << (prepare(p_gA)->disjoint(p_gB) ? "T" : "F") << ", BA=" << (prepare(
+                  p_gB)->disjoint(p_gA) ? "T" : "F") << std::endl;
+    std::cout << "\tPrepared Intersects:\tAB=" << (prepare(p_gA)->intersects(p_gB) ? "T" : "F") << ", BA=" << (prepare(
+                  p_gB)->intersects(p_gA) ? "T" : "F") << std::endl;
+    std::cout << "\t   Prepared Touches:\tAB=" << (prepare(p_gA)->touches(p_gB) ? "T" : "F") << ", BA=" << (prepare(
+                  p_gB)->touches(p_gA) ? "T" : "F") << std::endl;
+    std::cout << "\t   Prepared Crosses:\tAB=" << (prepare(p_gA)->crosses(p_gB) ? "T" : "F") << ", BA=" << (prepare(
+                  p_gB)->crosses(p_gA) ? "T" : "F") << std::endl;
+    std::cout << "\t    Prepared Within:\tAB=" << (prepare(p_gA)->within(p_gB) ? "T" : "F") << ", BA=" << (prepare(
+                  p_gB)->within(p_gA) ? "T" : "F") << std::endl;
+    std::cout << "\t  Prepared Contains:\tAB=" << (prepare(p_gA)->contains(p_gB) ? "T" : "F") << ", BA=" << (prepare(
+                  p_gB)->contains(p_gA) ? "T" : "F") << std::endl;
+    std::cout << "\t Prepared Overlaps:\tAB=" << (prepare(p_gA)->overlaps(p_gB) ? "T" : "F") << ", BA=" << (prepare(
+                  p_gB)->overlaps(p_gA) ? "T" : "F") << std::endl;
 }
 
 XMLTester::~XMLTester()
@@ -1679,7 +1828,7 @@ XMLTester::~XMLTester()
 
 
 static void
-usage(char *me, int exitcode, std::ostream &os)
+usage(char* me, int exitcode, std::ostream& os)
 {
     os << "Usage: " << me << " [options] <test> [<test> ...]" << std::endl;
     os << "Options: " << std::endl;
@@ -1702,49 +1851,45 @@ request_interrupt(int)
 int
 main(int argC, char* argV[])
 {
-    int verbose=0;
-    bool sql_output=false;
+    int verbose = 0;
+    bool sql_output = false;
 
 #if defined(_MSC_VER) && defined(GEOS_TEST_USE_STACKWALKER)
     InitAllocCheck();
     {
 #endif
 
-        if ( argC < 2 ) usage(argV[0], 1, std::cerr);
+        if(argC < 2) {
+            usage(argV[0], 1, std::cerr);
+        }
 
         signal(15, request_interrupt);
 
         XMLTester tester;
         tester.setVerbosityLevel(verbose);
 
-        for (int i=1; i<argC; ++i)
-        {
+        for(int i = 1; i < argC; ++i) {
             // increment verbosity level
-            if ( ! std::strcmp(argV[i], "-v" ) )
-            {
+            if(! std::strcmp(argV[i], "-v")) {
                 ++verbose;
                 tester.setVerbosityLevel(verbose);
                 continue;
             }
-            if ( ! std::strcmp(argV[i], "--test-valid-output" ) )
-            {
+            if(! std::strcmp(argV[i], "--test-valid-output")) {
                 tester.testOutputValidity(true);
                 continue;
             }
-            if ( ! std::strcmp(argV[i], "--sql-output" ) )
-            {
+            if(! std::strcmp(argV[i], "--sql-output")) {
                 sql_output = true;
                 tester.setSQLOutput(sql_output);
                 continue;
             }
-            if ( ! std::strcmp(argV[i], "--wkb-output" ) )
-            {
+            if(! std::strcmp(argV[i], "--wkb-output")) {
                 sql_output = true;
                 tester.setHEXWKBOutput(sql_output);
                 continue;
             }
-            if ( ! std::strcmp(argV[i], "--test-valid-input" ) )
-            {
+            if(! std::strcmp(argV[i], "--test-valid-input")) {
                 tester.testInputValidity(true);
                 continue;
             }
@@ -1753,13 +1898,18 @@ main(int argC, char* argV[])
 
             try {
                 tester.run(source);
-            } catch (const std::exception& exc) {
-                std::cerr<<exc.what()<<std::endl;
+            }
+            catch(const std::exception& exc) {
+                std::cerr << exc.what() << std::endl;
             }
         }
 
-        if ( ! sql_output ) tester.resultSummary(std::cout);
-        else tester.resultSummary(std::cerr);
+        if(! sql_output) {
+            tester.resultSummary(std::cout);
+        }
+        else {
+            tester.resultSummary(std::cerr);
+        }
 
         io::Unload::Release();
 
diff --git a/tests/xmltester/XMLTester.h b/tests/xmltester/XMLTester.h
index 0ef03de..d4e5e5d 100644
--- a/tests/xmltester/XMLTester.h
+++ b/tests/xmltester/XMLTester.h
@@ -25,84 +25,105 @@ using namespace geos;
 class XMLTester {
 
 private:
-	enum {
-		SHOW_RUN_INFO=1,
-		SHOW_CASE,
-		SHOW_TEST,
-		SHOW_RESULT,
-		SHOW_GEOMS,
-		SHOW_GEOMS_FULL,
-		PRED
-	};
-
-	void parsePrecisionModel(const tinyxml2::XMLElement* el);
-	void parseRun(const tinyxml2::XMLNode* node);
-	void parseCase(const tinyxml2::XMLNode* node);
-	void parseTest(const tinyxml2::XMLNode* node);
-	void runPredicates(const geom::Geometry *a, const geom::Geometry *b);
-	geom::Geometry *parseGeometry(const std::string &in, const char* label="parsed");
-	static std::string trimBlanks(const std::string &in);
-	void printGeom(std::ostream& os, const geom::Geometry *g);
-	std::string printGeom(const geom::Geometry *g);
-	void printTest(bool success, const std::string& expected_result, const std::string& actual_result, const util::Profile&);
-
-	geom::Geometry *gA;
-	geom::Geometry *gB;
-
-	bool usePrepared;
-	std::unique_ptr<geom::PrecisionModel> pm;
-	geom::GeometryFactory::Ptr factory;
-	std::unique_ptr<io::WKTReader> wktreader;
-	std::unique_ptr<io::WKTWriter> wktwriter;
-	std::unique_ptr<io::WKBReader> wkbreader;
-	std::unique_ptr<io::WKBWriter> wkbwriter;
-	tinyxml2::XMLDocument xml;
-
-	int verbose;
-	int test_predicates;
-
-	int failed;
-	int succeeded;
-	int caseCount;
-	int testCount;
-	std::string opSignature;
-
-	int testFileCount;
-	int totalTestCount;
-
-	const std::string *curr_file;
-	std::string curr_case_desc;
-
-	bool testValidOutput;
-	bool testValidInput;
-	bool sqlOutput;
-	bool HEXWKB_output;
-
-	bool testValid(const geom::Geometry* g, const std::string& label);
+    enum {
+        SHOW_RUN_INFO = 1,
+        SHOW_CASE,
+        SHOW_TEST,
+        SHOW_RESULT,
+        SHOW_GEOMS,
+        SHOW_GEOMS_FULL,
+        PRED
+    };
+
+    void parsePrecisionModel(const tinyxml2::XMLElement* el);
+    void parseRun(const tinyxml2::XMLNode* node);
+    void parseCase(const tinyxml2::XMLNode* node);
+    void parseTest(const tinyxml2::XMLNode* node);
+    void runPredicates(const geom::Geometry* a, const geom::Geometry* b);
+    geom::Geometry* parseGeometry(const std::string& in, const char* label = "parsed");
+    static std::string trimBlanks(const std::string& in);
+    void printGeom(std::ostream& os, const geom::Geometry* g);
+    std::string printGeom(const geom::Geometry* g);
+    void printTest(bool success, const std::string& expected_result, const std::string& actual_result,
+                   const util::Profile&);
+
+    geom::Geometry* gA;
+    geom::Geometry* gB;
+
+    bool usePrepared;
+    std::unique_ptr<geom::PrecisionModel> pm;
+    geom::GeometryFactory::Ptr factory;
+    std::unique_ptr<io::WKTReader> wktreader;
+    std::unique_ptr<io::WKTWriter> wktwriter;
+    std::unique_ptr<io::WKBReader> wkbreader;
+    std::unique_ptr<io::WKBWriter> wkbwriter;
+    tinyxml2::XMLDocument xml;
+
+    int verbose;
+    int test_predicates;
+
+    int failed;
+    int succeeded;
+    int caseCount;
+    int testCount;
+    std::string opSignature;
+
+    int testFileCount;
+    int totalTestCount;
+
+    const std::string* curr_file;
+    std::string curr_case_desc;
+
+    bool testValidOutput;
+    bool testValidInput;
+    bool sqlOutput;
+    bool HEXWKB_output;
+
+    bool testValid(const geom::Geometry* g, const std::string& label);
 
 public:
-	XMLTester();
-	~XMLTester();
-	void run(const std::string &testFile);
-	void resultSummary(std::ostream &os) const;
-	void resetCounters();
-
-	/*
-	 * Values:
-	 *	0: Show case description, run tests, show result
-	 *	1: Show parsed geometry values
-	 *	2: Run predicates
-	 *
-	 * Return previously set verbosity level
-	 */
-	int setVerbosityLevel(int val);
-
-	int getFailuresCount() { return failed; }
-
-	void testOutputValidity(bool val) { testValidOutput=val; }
-	void testInputValidity(bool val) { testValidInput=val; }
-	void setSQLOutput(bool val) { sqlOutput=val; }
-	void setHEXWKBOutput(bool val) { HEXWKB_output=val; }
+    XMLTester();
+    ~XMLTester();
+    void run(const std::string& testFile);
+    void resultSummary(std::ostream& os) const;
+    void resetCounters();
+
+    /*
+     * Values:
+     *	0: Show case description, run tests, show result
+     *	1: Show parsed geometry values
+     *	2: Run predicates
+     *
+     * Return previously set verbosity level
+     */
+    int setVerbosityLevel(int val);
+
+    int
+    getFailuresCount()
+    {
+        return failed;
+    }
+
+    void
+    testOutputValidity(bool val)
+    {
+        testValidOutput = val;
+    }
+    void
+    testInputValidity(bool val)
+    {
+        testValidInput = val;
+    }
+    void
+    setSQLOutput(bool val)
+    {
+        sqlOutput = val;
+    }
+    void
+    setHEXWKBOutput(bool val)
+    {
+        HEXWKB_output = val;
+    }
 
 };
 

-----------------------------------------------------------------------

Summary of changes:
 .astylerc                                          |    12 +
 CMakeLists.txt                                     |     6 +-
 capi/geos_c.cpp                                    |  2500 +++--
 capi/geos_ts_c.cpp                                 | 10216 +++++++++----------
 doc/example.cpp                                    |  1729 ++--
 include/geos/algorithm/Angle.h                     |   365 +-
 include/geos/algorithm/Area.h                      |     8 +-
 include/geos/algorithm/BoundaryNodeRule.h          |    95 +-
 include/geos/algorithm/CGAlgorithmsDD.h            |    29 +-
 .../geos/algorithm/CentralEndpointIntersector.h    |   168 +-
 include/geos/algorithm/Centroid.h                  |   180 +-
 include/geos/algorithm/ConvexHull.h                |   242 +-
 include/geos/algorithm/ConvexHull.inl              |    14 +-
 include/geos/algorithm/Distance.h                  |     2 +-
 include/geos/algorithm/HCoordinate.h               |    76 +-
 include/geos/algorithm/InteriorPointArea.h         |    72 +-
 include/geos/algorithm/InteriorPointLine.h         |    34 +-
 include/geos/algorithm/InteriorPointPoint.h        |    34 +-
 include/geos/algorithm/Length.h                    |     2 +-
 include/geos/algorithm/LineIntersector.h           |   634 +-
 include/geos/algorithm/MinimumBoundingCircle.h     |     8 +-
 include/geos/algorithm/MinimumDiameter.h           |   208 +-
 include/geos/algorithm/NotRepresentableException.h |     6 +-
 include/geos/algorithm/Orientation.h               |    16 +-
 include/geos/algorithm/PointInRing.h               |    13 +-
 include/geos/algorithm/PointLocation.h             |    10 +-
 include/geos/algorithm/PointLocator.h              |    82 +-
 include/geos/algorithm/RayCrossingCounter.h        |   184 +-
 include/geos/algorithm/RayCrossingCounterDD.h      |     3 +-
 include/geos/algorithm/RobustDeterminant.h         |    18 +-
 include/geos/algorithm/SimplePointInRing.h         |    18 +-
 .../algorithm/distance/DiscreteFrechetDistance.h   |   134 +-
 .../algorithm/distance/DiscreteHausdorffDistance.h |   287 +-
 include/geos/algorithm/distance/DistanceToPoint.h  |    51 +-
 .../geos/algorithm/distance/PointPairDistance.h    |   204 +-
 .../algorithm/locate/IndexedPointInAreaLocator.h   |    31 +-
 .../geos/algorithm/locate/PointOnGeometryLocator.h |    28 +-
 .../algorithm/locate/SimplePointInAreaLocator.h    |    16 +-
 include/geos/geom/BinaryOp.h                       |   495 +-
 include/geos/geom/Coordinate.h                     |    86 +-
 include/geos/geom/Coordinate.inl                   |    90 +-
 include/geos/geom/CoordinateArraySequence.h        |   122 +-
 include/geos/geom/CoordinateArraySequenceFactory.h |    24 +-
 .../geos/geom/CoordinateArraySequenceFactory.inl   |    26 +-
 include/geos/geom/CoordinateFilter.h               |    35 +-
 include/geos/geom/CoordinateList.h                 |   268 +-
 include/geos/geom/CoordinateSequence.h             |   659 +-
 include/geos/geom/CoordinateSequenceFactory.h      |    94 +-
 include/geos/geom/CoordinateSequenceFilter.h       |   101 +-
 include/geos/geom/Dimension.h                      |    44 +-
 include/geos/geom/Envelope.h                       |   863 +-
 include/geos/geom/Envelope.inl                     |    52 +-
 include/geos/geom/Geometry.h                       |  1424 +--
 include/geos/geom/GeometryCollection.h             |   232 +-
 include/geos/geom/GeometryCollection.inl           |     6 +-
 include/geos/geom/GeometryComponentFilter.h        |    27 +-
 include/geos/geom/GeometryFactory.h                |   786 +-
 include/geos/geom/GeometryFactory.inl              |     6 +-
 include/geos/geom/GeometryFilter.h                 |    41 +-
 include/geos/geom/IntersectionMatrix.h             |   626 +-
 include/geos/geom/LineSegment.h                    |   626 +-
 include/geos/geom/LineSegment.inl                  |    79 +-
 include/geos/geom/LineString.h                     |   209 +-
 include/geos/geom/Lineal.h                         |     5 +-
 include/geos/geom/LinearRing.h                     |    94 +-
 include/geos/geom/Location.h                       |    50 +-
 include/geos/geom/MultiLineString.h                |   116 +-
 include/geos/geom/MultiLineString.inl              |    14 +-
 include/geos/geom/MultiPoint.h                     |   115 +-
 include/geos/geom/MultiPolygon.h                   |   105 +-
 include/geos/geom/MultiPolygon.inl                 |    14 +-
 include/geos/geom/Point.h                          |   207 +-
 include/geos/geom/Polygon.h                        |   183 +-
 include/geos/geom/Polygonal.h                      |     5 +-
 include/geos/geom/PrecisionModel.h                 |   458 +-
 include/geos/geom/PrecisionModel.inl               |    10 +-
 include/geos/geom/Puntal.h                         |     5 +-
 include/geos/geom/Triangle.h                       |   100 +-
 .../geom/prep/AbstractPreparedPolygonContains.h    |   125 +-
 include/geos/geom/prep/BasicPreparedGeometry.h     |   231 +-
 include/geos/geom/prep/PreparedGeometry.h          |   263 +-
 include/geos/geom/prep/PreparedGeometryFactory.h   |    61 +-
 include/geos/geom/prep/PreparedLineString.h        |    29 +-
 .../geos/geom/prep/PreparedLineStringIntersects.h  |    70 +-
 include/geos/geom/prep/PreparedPoint.h             |    25 +-
 include/geos/geom/prep/PreparedPolygon.h           |    43 +-
 include/geos/geom/prep/PreparedPolygonContains.h   |    91 +-
 .../geom/prep/PreparedPolygonContainsProperly.h    |    77 +-
 include/geos/geom/prep/PreparedPolygonCovers.h     |    95 +-
 include/geos/geom/prep/PreparedPolygonIntersects.h |    72 +-
 include/geos/geom/prep/PreparedPolygonPredicate.h  |   175 +-
 .../geos/geom/util/ComponentCoordinateExtracter.h  |    35 +-
 include/geos/geom/util/CoordinateOperation.h       |    42 +-
 include/geos/geom/util/Densifier.h                 |    33 +-
 include/geos/geom/util/GeometryCombiner.h          |    11 +-
 include/geos/geom/util/GeometryEditor.h            |    88 +-
 include/geos/geom/util/GeometryEditorOperation.h   |    41 +-
 include/geos/geom/util/GeometryExtracter.h         |    82 +-
 include/geos/geom/util/GeometryTransformer.h       |   182 +-
 include/geos/geom/util/LinearComponentExtracter.h  |    32 +-
 include/geos/geom/util/PointExtracter.h            |    30 +-
 include/geos/geom/util/PolygonExtracter.h          |    30 +-
 .../geos/geom/util/ShortCircuitedGeometryVisitor.h |    28 +-
 include/geos/geom/util/SineStarFactory.h           |   106 +-
 include/geos/geomgraph/Depth.h                     |    42 +-
 include/geos/geomgraph/DirectedEdge.h              |   192 +-
 include/geos/geomgraph/DirectedEdge.inl            |    82 +-
 include/geos/geomgraph/DirectedEdgeStar.h          |   199 +-
 include/geos/geomgraph/Edge.h                      |   402 +-
 include/geos/geomgraph/EdgeEnd.h                   |   207 +-
 include/geos/geomgraph/EdgeEndStar.h               |   153 +-
 include/geos/geomgraph/EdgeIntersection.h          |   104 +-
 include/geos/geomgraph/EdgeIntersectionList.h      |   112 +-
 include/geos/geomgraph/EdgeList.h                  |    95 +-
 include/geos/geomgraph/EdgeNodingValidator.h       |   101 +-
 include/geos/geomgraph/EdgeRing.h                  |   213 +-
 include/geos/geomgraph/GeometryGraph.h             |   298 +-
 include/geos/geomgraph/GeometryGraph.inl           |    10 +-
 include/geos/geomgraph/GraphComponent.h            |    90 +-
 include/geos/geomgraph/Label.h                     |   142 +-
 include/geos/geomgraph/Node.h                      |   182 +-
 include/geos/geomgraph/NodeFactory.h               |    21 +-
 include/geos/geomgraph/NodeMap.h                   |    98 +-
 include/geos/geomgraph/PlanarGraph.h               |   192 +-
 include/geos/geomgraph/Position.h                  |    44 +-
 include/geos/geomgraph/Quadrant.h                  |    94 +-
 include/geos/geomgraph/TopologyLocation.h          |    94 +-
 include/geos/geomgraph/index/EdgeSetIntersector.h  |    47 +-
 include/geos/geomgraph/index/MonotoneChain.h       |    32 +-
 include/geos/geomgraph/index/MonotoneChainEdge.h   |    62 +-
 .../geos/geomgraph/index/MonotoneChainIndexer.h    |    14 +-
 include/geos/geomgraph/index/SegmentIntersector.h  |   129 +-
 .../geomgraph/index/SimpleEdgeSetIntersector.h     |    26 +-
 .../geomgraph/index/SimpleMCSweepLineIntersector.h |    50 +-
 .../geomgraph/index/SimpleSweepLineIntersector.h   |    50 +-
 include/geos/geomgraph/index/SweepLineEvent.h      |   105 +-
 include/geos/geomgraph/index/SweepLineEventObj.h   |     3 +-
 include/geos/geomgraph/index/SweepLineSegment.h    |    34 +-
 include/geos/index/ItemVisitor.h                   |     5 +-
 include/geos/index/SpatialIndex.h                  |   109 +-
 include/geos/index/bintree/Bintree.h               |    98 +-
 include/geos/index/bintree/Interval.h              |    32 +-
 include/geos/index/bintree/Key.h                   |    36 +-
 include/geos/index/bintree/Node.h                  |    38 +-
 include/geos/index/bintree/NodeBase.h              |    50 +-
 include/geos/index/bintree/Root.h                  |    46 +-
 include/geos/index/chain/MonotoneChain.h           |   179 +-
 include/geos/index/chain/MonotoneChainBuilder.h    |   115 +-
 .../geos/index/chain/MonotoneChainOverlapAction.h  |    64 +-
 .../geos/index/chain/MonotoneChainSelectAction.h   |    35 +-
 .../index/intervalrtree/IntervalRTreeBranchNode.h  |    25 +-
 .../index/intervalrtree/IntervalRTreeLeafNode.h    |    31 +-
 .../geos/index/intervalrtree/IntervalRTreeNode.h   |   119 +-
 .../intervalrtree/SortedPackedIntervalRTree.h      |    68 +-
 include/geos/index/quadtree/DoubleBits.h           |    62 +-
 include/geos/index/quadtree/IntervalSize.h         |    28 +-
 include/geos/index/quadtree/Key.h                  |    50 +-
 include/geos/index/quadtree/Node.h                 |   128 +-
 include/geos/index/quadtree/NodeBase.h             |   127 +-
 include/geos/index/quadtree/Quadtree.h             |   221 +-
 include/geos/index/quadtree/Root.h                 |    52 +-
 include/geos/index/strtree/AbstractNode.h          |    76 +-
 include/geos/index/strtree/AbstractSTRtree.h       |   342 +-
 include/geos/index/strtree/Boundable.h             |    31 +-
 include/geos/index/strtree/BoundablePair.h         |   106 +-
 include/geos/index/strtree/GeometryItemDistance.h  |    20 +-
 include/geos/index/strtree/Interval.h              |    14 +-
 include/geos/index/strtree/ItemBoundable.h         |    11 +-
 include/geos/index/strtree/ItemDistance.h          |    20 +-
 include/geos/index/strtree/SIRtree.h               |   119 +-
 include/geos/index/strtree/STRtree.h               |   164 +-
 include/geos/index/sweepline/SweepLineEvent.h      |    64 +-
 include/geos/index/sweepline/SweepLineIndex.h      |    50 +-
 include/geos/index/sweepline/SweepLineInterval.h   |    12 +-
 .../geos/index/sweepline/SweepLineOverlapAction.h  |    15 +-
 include/geos/io/ByteOrderDataInStream.h            |    32 +-
 include/geos/io/ByteOrderDataInStream.inl          |    60 +-
 include/geos/io/ByteOrderValues.h                  |    15 +-
 include/geos/io/CLocalizer.h                       |     3 +-
 include/geos/io/ParseException.h                   |    15 +-
 include/geos/io/StringTokenizer.h                  |    34 +-
 include/geos/io/WKBConstants.h                     |    26 +-
 include/geos/io/WKBReader.h                        |   150 +-
 include/geos/io/WKBWriter.h                        |   240 +-
 include/geos/io/WKTReader.h                        |   112 +-
 include/geos/io/WKTReader.inl                      |    24 +-
 include/geos/io/WKTWriter.h                        |   340 +-
 include/geos/io/Writer.h                           |    12 +-
 include/geos/linearref/ExtractLineByLocation.h     |    89 +-
 include/geos/linearref/LengthIndexOfPoint.h        |    71 +-
 include/geos/linearref/LengthIndexedLine.h         |   317 +-
 include/geos/linearref/LengthLocationMap.h         |   163 +-
 include/geos/linearref/LinearGeometryBuilder.h     |   111 +-
 include/geos/linearref/LinearIterator.h            |   194 +-
 include/geos/linearref/LinearLocation.h            |   388 +-
 include/geos/linearref/LocationIndexOfLine.h       |    55 +-
 include/geos/linearref/LocationIndexOfPoint.h      |    66 +-
 include/geos/linearref/LocationIndexedLine.h       |   418 +-
 include/geos/noding/BasicSegmentString.h           |    93 +-
 include/geos/noding/FastNodingValidator.h          |   105 +-
 .../geos/noding/FastSegmentSetIntersectionFinder.h |    46 +-
 include/geos/noding/GeometryNoder.h                |    39 +-
 include/geos/noding/IntersectionAdder.h            |   258 +-
 include/geos/noding/IntersectionFinderAdder.h      |   106 +-
 include/geos/noding/IteratedNoder.h                |   106 +-
 include/geos/noding/MCIndexNoder.h                 |    80 +-
 include/geos/noding/MCIndexNoder.inl               |     8 +-
 .../noding/MCIndexSegmentSetMutualIntersector.h    |   109 +-
 include/geos/noding/NodableSegmentString.h         |    33 +-
 include/geos/noding/NodedSegmentString.h           |   236 +-
 include/geos/noding/Noder.h                        |    45 +-
 include/geos/noding/NodingIntersectionFinder.h     |   154 +-
 include/geos/noding/NodingValidator.h              |    88 +-
 include/geos/noding/Octant.h                       |    33 +-
 include/geos/noding/OrientedCoordinateArray.h      |   102 +-
 include/geos/noding/ScaledNoder.h                  |    73 +-
 include/geos/noding/SegmentIntersectionDetector.h  |   239 +-
 include/geos/noding/SegmentIntersector.h           |    61 +-
 include/geos/noding/SegmentNode.h                  |   114 +-
 include/geos/noding/SegmentNodeList.h              |   282 +-
 include/geos/noding/SegmentPointComparator.h       |   109 +-
 include/geos/noding/SegmentSetMutualIntersector.h  |    51 +-
 include/geos/noding/SegmentString.h                |   111 +-
 include/geos/noding/SegmentStringUtil.h            |    55 +-
 include/geos/noding/SimpleNoder.h                  |    28 +-
 include/geos/noding/SinglePassNoder.h              |    76 +-
 include/geos/noding/snapround/HotPixel.h           |   272 +-
 include/geos/noding/snapround/HotPixel.inl         |    12 +-
 .../geos/noding/snapround/MCIndexPointSnapper.h    |    68 +-
 include/geos/noding/snapround/MCIndexSnapRounder.h |   120 +-
 include/geos/noding/snapround/SimpleSnapRounder.h  |   130 +-
 include/geos/operation/GeometryGraphOperation.h    |    50 +-
 include/geos/operation/IsSimpleOp.h                |   268 +-
 include/geos/operation/buffer/BufferBuilder.h      |   310 +-
 .../operation/buffer/BufferInputLineSimplifier.h   |   195 +-
 include/geos/operation/buffer/BufferOp.h           |   306 +-
 include/geos/operation/buffer/BufferParameters.h   |   487 +-
 include/geos/operation/buffer/BufferSubgraph.h     |   227 +-
 include/geos/operation/buffer/OffsetCurveBuilder.h |   203 +-
 .../geos/operation/buffer/OffsetCurveSetBuilder.h  |   284 +-
 .../geos/operation/buffer/OffsetSegmentGenerator.h |   566 +-
 .../geos/operation/buffer/OffsetSegmentString.h    |   290 +-
 .../geos/operation/buffer/RightmostEdgeFinder.h    |    56 +-
 .../geos/operation/buffer/SubgraphDepthLocater.h   |   116 +-
 .../distance/ConnectedElementLocationFilter.h      |    48 +-
 .../distance/ConnectedElementPointFilter.h         |    34 +-
 include/geos/operation/distance/DistanceOp.h       |   406 +-
 include/geos/operation/distance/FacetSequence.h    |    48 +-
 .../operation/distance/FacetSequenceTreeBuilder.h  |    30 +-
 include/geos/operation/distance/GeometryLocation.h |   126 +-
 .../geos/operation/distance/IndexedFacetDistance.h |    30 +-
 include/geos/operation/intersection/Rectangle.h    |   342 +-
 .../operation/intersection/RectangleIntersection.h |   195 +-
 .../intersection/RectangleIntersectionBuilder.h    |   195 +-
 include/geos/operation/linemerge/EdgeString.h      |    58 +-
 .../operation/linemerge/LineMergeDirectedEdge.h    |    60 +-
 include/geos/operation/linemerge/LineMergeEdge.h   |    26 +-
 include/geos/operation/linemerge/LineMergeGraph.h  |    48 +-
 include/geos/operation/linemerge/LineMerger.h      |   114 +-
 include/geos/operation/linemerge/LineSequencer.h   |   386 +-
 include/geos/operation/overlay/EdgeSetNoder.h      |    37 +-
 include/geos/operation/overlay/ElevationMatrix.h   |    77 +-
 .../geos/operation/overlay/ElevationMatrixCell.h   |    24 +-
 include/geos/operation/overlay/LineBuilder.h       |   156 +-
 include/geos/operation/overlay/MaximalEdgeRing.h   |    72 +-
 include/geos/operation/overlay/MinimalEdgeRing.h   |    26 +-
 include/geos/operation/overlay/MinimalEdgeRing.inl |    12 +-
 .../geos/operation/overlay/OverlayNodeFactory.h    |    18 +-
 include/geos/operation/overlay/OverlayOp.h         |   695 +-
 include/geos/operation/overlay/PointBuilder.h      |    98 +-
 include/geos/operation/overlay/PolygonBuilder.h    |   292 +-
 .../geos/operation/overlay/snap/GeometrySnapper.h  |   164 +-
 .../operation/overlay/snap/LineStringSnapper.h     |   204 +-
 .../operation/overlay/snap/SnapIfNeededOverlayOp.h |    99 +-
 .../geos/operation/overlay/snap/SnapOverlayOp.h    |   121 +-
 .../operation/overlay/validate/FuzzyPointLocator.h |    34 +-
 .../overlay/validate/OffsetPointGenerator.h        |    30 +-
 .../overlay/validate/OverlayResultValidator.h      |    70 +-
 include/geos/operation/polygonize/EdgeRing.h       |   294 +-
 .../operation/polygonize/PolygonizeDirectedEdge.h  |   132 +-
 include/geos/operation/polygonize/PolygonizeEdge.h |    18 +-
 .../geos/operation/polygonize/PolygonizeGraph.h    |   318 +-
 include/geos/operation/polygonize/Polygonizer.h    |   284 +-
 .../geos/operation/predicate/RectangleContains.h   |   123 +-
 .../geos/operation/predicate/RectangleIntersects.h |    65 +-
 .../predicate/SegmentIntersectionTester.h          |    76 +-
 include/geos/operation/relate/EdgeEndBuilder.h     |    40 +-
 include/geos/operation/relate/EdgeEndBundle.h      |   107 +-
 include/geos/operation/relate/EdgeEndBundleStar.h  |    28 +-
 include/geos/operation/relate/RelateComputer.h     |   182 +-
 include/geos/operation/relate/RelateNode.h         |    28 +-
 include/geos/operation/relate/RelateNodeFactory.h  |    18 +-
 include/geos/operation/relate/RelateNodeGraph.h    |    42 +-
 include/geos/operation/relate/RelateOp.h           |   146 +-
 include/geos/operation/sharedpaths/SharedPathsOp.h |   181 +-
 .../geos/operation/union/CascadedPolygonUnion.h    |    64 +-
 include/geos/operation/union/CascadedUnion.h       |    50 +-
 include/geos/operation/union/GeometryListHolder.h  |    24 +-
 include/geos/operation/union/PointGeometryUnion.h  |    37 +-
 include/geos/operation/union/UnaryUnionOp.h        |   262 +-
 .../geos/operation/valid/ConnectedInteriorTester.h |   140 +-
 .../geos/operation/valid/ConsistentAreaTester.h    |   126 +-
 include/geos/operation/valid/IsValidOp.h           |    80 +-
 .../operation/valid/QuadtreeNestedRingTester.h     |    60 +-
 include/geos/operation/valid/RepeatedPointTester.h |    36 +-
 .../geos/operation/valid/SimpleNestedRingTester.h  |    67 +-
 .../operation/valid/SweeplineNestedRingTester.h    |   114 +-
 .../geos/operation/valid/TopologyValidationError.h |    48 +-
 include/geos/planargraph/DirectedEdge.h            |   348 +-
 include/geos/planargraph/DirectedEdgeStar.h        |   191 +-
 include/geos/planargraph/Edge.h                    |   142 +-
 include/geos/planargraph/GraphComponent.h          |   223 +-
 include/geos/planargraph/Node.h                    |   175 +-
 include/geos/planargraph/NodeMap.h                 |   152 +-
 include/geos/planargraph/PlanarGraph.h             |   403 +-
 include/geos/planargraph/Subgraph.h                |   207 +-
 .../algorithm/ConnectedSubgraphFinder.h            |    75 +-
 include/geos/precision/CommonBits.h                |    98 +-
 include/geos/precision/CommonBitsOp.h              |   220 +-
 include/geos/precision/CommonBitsRemover.h         |    92 +-
 include/geos/precision/EnhancedPrecisionOp.h       |   120 +-
 include/geos/precision/GeometryPrecisionReducer.h  |   215 +-
 include/geos/precision/MinimumClearance.h          |    50 +-
 .../PrecisionReducerCoordinateOperation.h          |    41 +-
 .../precision/SimpleGeometryPrecisionReducer.h     |    70 +-
 include/geos/profiler.h                            |   190 +-
 .../geos/simplify/DouglasPeuckerLineSimplifier.h   |    66 +-
 include/geos/simplify/DouglasPeuckerSimplifier.h   |    42 +-
 include/geos/simplify/LineSegmentIndex.h           |    34 +-
 include/geos/simplify/TaggedLineSegment.h          |    33 +-
 include/geos/simplify/TaggedLineString.h           |    82 +-
 include/geos/simplify/TaggedLineStringSimplifier.h |   160 +-
 include/geos/simplify/TaggedLinesSimplifier.h      |    99 +-
 .../geos/simplify/TopologyPreservingSimplifier.h   |    39 +-
 include/geos/timeval.h                             |    38 +-
 .../triangulate/DelaunayTriangulationBuilder.h     |   202 +-
 .../triangulate/IncrementalDelaunayTriangulator.h  |    71 +-
 include/geos/triangulate/VoronoiDiagramBuilder.h   |   164 +-
 .../quadedge/LastFoundQuadEdgeLocator.h            |    22 +-
 .../triangulate/quadedge/LocateFailureException.h  |     2 +-
 include/geos/triangulate/quadedge/QuadEdge.h       |   632 +-
 .../geos/triangulate/quadedge/QuadEdgeLocator.h    |     4 +-
 .../triangulate/quadedge/QuadEdgeSubdivision.h     |   816 +-
 .../geos/triangulate/quadedge/TrianglePredicate.h  |   121 +-
 .../geos/triangulate/quadedge/TriangleVisitor.h    |     2 +-
 include/geos/triangulate/quadedge/Vertex.h         |   452 +-
 include/geos/unload.h                              |     9 +-
 include/geos/util.h                                |     8 +-
 include/geos/util/Assert.h                         |    41 +-
 include/geos/util/AssertionFailedException.h       |    18 +-
 include/geos/util/CoordinateArrayFilter.h          |    36 +-
 include/geos/util/GEOSException.h                  |    24 +-
 include/geos/util/GeometricShapeFactory.h          |   255 +-
 include/geos/util/IllegalArgumentException.h       |    18 +-
 include/geos/util/IllegalStateException.h          |    18 +-
 include/geos/util/Interrupt.h                      |    72 +-
 include/geos/util/Machine.h                        |     7 +-
 include/geos/util/TopologyException.h              |    42 +-
 include/geos/util/UniqueCoordinateArrayFilter.h    |    59 +-
 include/geos/util/UnsupportedOperationException.h  |    18 +-
 include/geos/util/math.h                           |    11 +-
 src/algorithm/Angle.cpp                            |   161 +-
 src/algorithm/Area.cpp                             |    18 +-
 src/algorithm/BoundaryNodeRule.cpp                 |    65 +-
 src/algorithm/CGAlgorithmsDD.cpp                   |    55 +-
 src/algorithm/Centroid.cpp                         |   177 +-
 src/algorithm/ConvexHull.cpp                       |   497 +-
 src/algorithm/Distance.cpp                         |    82 +-
 src/algorithm/HCoordinate.cpp                      |   150 +-
 src/algorithm/InteriorPointArea.cpp                |   320 +-
 src/algorithm/InteriorPointLine.cpp                |   122 +-
 src/algorithm/InteriorPointPoint.cpp               |    64 +-
 src/algorithm/Length.cpp                           |    11 +-
 src/algorithm/LineIntersector.cpp                  |  1291 +--
 src/algorithm/MinimumBoundingCircle.cpp            |   135 +-
 src/algorithm/MinimumDiameter.cpp                  |   451 +-
 src/algorithm/NotRepresentableException.cpp        |    14 +-
 src/algorithm/Orientation.cpp                      |    35 +-
 src/algorithm/PointLocation.cpp                    |    29 +-
 src/algorithm/PointLocator.cpp                     |   224 +-
 src/algorithm/RayCrossingCounter.cpp               |   199 +-
 src/algorithm/RayCrossingCounterDD.cpp             |    46 +-
 src/algorithm/RobustDeterminant.cpp                |   470 +-
 src/algorithm/SimplePointInRing.cpp                |    20 +-
 src/algorithm/distance/DiscreteFrechetDistance.cpp |   166 +-
 .../distance/DiscreteHausdorffDistance.cpp         |    62 +-
 src/algorithm/distance/DistanceToPoint.cpp         |    99 +-
 src/algorithm/locate/IndexedPointInAreaLocator.cpp |    47 +-
 src/algorithm/locate/SimplePointInAreaLocator.cpp  |    68 +-
 src/geom/Coordinate.cpp                            |    27 +-
 src/geom/CoordinateArraySequence.cpp               |   254 +-
 src/geom/CoordinateArraySequenceFactory.cpp        |     4 +-
 src/geom/CoordinateSequence.cpp                    |   326 +-
 src/geom/Dimension.cpp                             |    84 +-
 src/geom/Envelope.cpp                              |   510 +-
 src/geom/Geometry.cpp                              |   902 +-
 src/geom/GeometryCollection.cpp                    |   383 +-
 src/geom/GeometryComponentFilter.cpp               |    14 +-
 src/geom/GeometryFactory.cpp                       |   894 +-
 src/geom/IntersectionMatrix.cpp                    |   465 +-
 src/geom/LineSegment.cpp                           |   346 +-
 src/geom/LineString.cpp                            |   415 +-
 src/geom/LinearRing.cpp                            |   110 +-
 src/geom/Location.cpp                              |    32 +-
 src/geom/MultiLineString.cpp                       |   113 +-
 src/geom/MultiPoint.cpp                            |    54 +-
 src/geom/MultiPolygon.cpp                          |   111 +-
 src/geom/Point.cpp                                 |   189 +-
 src/geom/Polygon.cpp                               |   547 +-
 src/geom/PrecisionModel.cpp                        |   170 +-
 src/geom/Triangle.cpp                              |    48 +-
 src/geom/prep/AbstractPreparedPolygonContains.cpp  |   233 +-
 src/geom/prep/BasicPreparedGeometry.cpp            |    93 +-
 src/geom/prep/PreparedGeometryFactory.cpp          |    46 +-
 src/geom/prep/PreparedLineString.cpp               |    29 +-
 src/geom/prep/PreparedLineStringIntersects.cpp     |   105 +-
 src/geom/prep/PreparedPoint.cpp                    |     8 +-
 src/geom/prep/PreparedPolygon.cpp                  |    86 +-
 src/geom/prep/PreparedPolygonContains.cpp          |    10 +-
 src/geom/prep/PreparedPolygonContainsProperly.cpp  |    64 +-
 src/geom/prep/PreparedPolygonCovers.cpp            |     6 +-
 src/geom/prep/PreparedPolygonIntersects.cpp        |    67 +-
 src/geom/prep/PreparedPolygonPredicate.cpp         |    46 +-
 src/geom/util/ComponentCoordinateExtracter.cpp     |    75 +-
 src/geom/util/CoordinateOperation.cpp              |    44 +-
 src/geom/util/Densifier.cpp                        |   130 +-
 src/geom/util/GeometryCombiner.cpp                 |    33 +-
 src/geom/util/GeometryEditor.cpp                   |   201 +-
 src/geom/util/GeometryTransformer.cpp              |   426 +-
 src/geom/util/LinearComponentExtracter.cpp         |    61 +-
 src/geom/util/PointExtracter.cpp                   |    69 +-
 src/geom/util/PolygonExtracter.cpp                 |    52 +-
 src/geom/util/ShortCircuitedGeometryVisitor.cpp    |    35 +-
 src/geom/util/SineStarFactory.cpp                  |    74 +-
 src/geomgraph/Depth.cpp                            |   135 +-
 src/geomgraph/DirectedEdge.cpp                     |   226 +-
 src/geomgraph/DirectedEdgeStar.cpp                 |   697 +-
 src/geomgraph/Edge.cpp                             |   348 +-
 src/geomgraph/EdgeEnd.cpp                          |   149 +-
 src/geomgraph/EdgeEndStar.cpp                      |   511 +-
 src/geomgraph/EdgeIntersectionList.cpp             |   197 +-
 src/geomgraph/EdgeList.cpp                         |   108 +-
 src/geomgraph/EdgeNodingValidator.cpp              |    36 +-
 src/geomgraph/EdgeRing.cpp                         |   427 +-
 src/geomgraph/GeometryGraph.cpp                    |   632 +-
 src/geomgraph/GraphComponent.cpp                   |    30 +-
 src/geomgraph/Label.cpp                            |   172 +-
 src/geomgraph/Node.cpp                             |   258 +-
 src/geomgraph/NodeFactory.cpp                      |    12 +-
 src/geomgraph/NodeMap.cpp                          |   138 +-
 src/geomgraph/PlanarGraph.cpp                      |   354 +-
 src/geomgraph/Position.cpp                         |    17 +-
 src/geomgraph/Quadrant.cpp                         |   134 +-
 src/geomgraph/TopologyLocation.cpp                 |   164 +-
 src/geomgraph/index/MonotoneChainEdge.cpp          |   138 +-
 src/geomgraph/index/MonotoneChainIndexer.cpp       |    53 +-
 src/geomgraph/index/SegmentIntersector.cpp         |   204 +-
 src/geomgraph/index/SimpleEdgeSetIntersector.cpp   |    79 +-
 .../index/SimpleMCSweepLineIntersector.cpp         |   180 +-
 src/geomgraph/index/SimpleSweepLineIntersector.cpp |   155 +-
 src/geomgraph/index/SweepLineEvent.cpp             |    71 +-
 src/geomgraph/index/SweepLineSegment.cpp           |    32 +-
 src/index/bintree/Bintree.cpp                      |   145 +-
 src/index/bintree/Interval.cpp                     |    54 +-
 src/index/bintree/Key.cpp                          |    62 +-
 src/index/bintree/Node.cpp                         |   159 +-
 src/index/bintree/NodeBase.cpp                     |   127 +-
 src/index/bintree/Root.cpp                         |    89 +-
 src/index/chain/MonotoneChain.cpp                  |    76 +-
 src/index/chain/MonotoneChainBuilder.cpp           |   131 +-
 src/index/chain/MonotoneChainOverlapAction.cpp     |     8 +-
 src/index/chain/MonotoneChainSelectAction.cpp      |     4 +-
 .../intervalrtree/IntervalRTreeBranchNode.cpp      |    17 +-
 src/index/intervalrtree/IntervalRTreeLeafNode.cpp  |     9 +-
 .../intervalrtree/SortedPackedIntervalRTree.cpp    |    94 +-
 src/index/quadtree/DoubleBits.cpp                  |    98 +-
 src/index/quadtree/IntervalSize.cpp                |    14 +-
 src/index/quadtree/Key.cpp                         |    70 +-
 src/index/quadtree/Node.cpp                        |   222 +-
 src/index/quadtree/NodeBase.cpp                    |   294 +-
 src/index/quadtree/Quadtree.cpp                    |   126 +-
 src/index/quadtree/Root.cpp                        |   128 +-
 src/index/strtree/AbstractNode.cpp                 |    36 +-
 src/index/strtree/AbstractSTRtree.cpp              |   461 +-
 src/index/strtree/BoundablePair.cpp                |   155 +-
 src/index/strtree/GeometryItemDistance.cpp         |    10 +-
 src/index/strtree/Interval.cpp                     |    27 +-
 src/index/strtree/ItemBoundable.cpp                |    11 +-
 src/index/strtree/SIRtree.cpp                      |   135 +-
 src/index/strtree/STRtree.cpp                      |   361 +-
 src/index/sweepline/SweepLineEvent.cpp             |    85 +-
 src/index/sweepline/SweepLineIndex.cpp             |    78 +-
 src/index/sweepline/SweepLineInterval.cpp          |    12 +-
 src/io/ByteOrderValues.cpp                         |   183 +-
 src/io/CLocalizer.cpp                              |     3 +-
 src/io/ParseException.cpp                          |    22 +-
 src/io/StringTokenizer.cpp                         |   260 +-
 src/io/Unload.cpp                                  |     5 +-
 src/io/WKBReader.cpp                               |   618 +-
 src/io/WKBWriter.cpp                               |   334 +-
 src/io/WKTReader.cpp                               |   738 +-
 src/io/WKTWriter.cpp                               |   632 +-
 src/io/Writer.cpp                                  |     6 +-
 src/linearref/ExtractLineByLocation.cpp            |   185 +-
 src/linearref/LengthIndexOfPoint.cpp               |   143 +-
 src/linearref/LengthIndexedLine.cpp                |   124 +-
 src/linearref/LengthLocationMap.cpp                |   211 +-
 src/linearref/LinearGeometryBuilder.cpp            |   136 +-
 src/linearref/LinearIterator.cpp                   |   159 +-
 src/linearref/LinearLocation.cpp                   |   380 +-
 src/linearref/LocationIndexOfLine.cpp              |    44 +-
 src/linearref/LocationIndexOfPoint.cpp             |   134 +-
 src/noding/BasicSegmentString.cpp                  |    18 +-
 src/noding/FastNodingValidator.cpp                 |    15 +-
 src/noding/FastSegmentSetIntersectionFinder.cpp    |    24 +-
 src/noding/GeometryNoder.cpp                       |   156 +-
 src/noding/IntersectionAdder.cpp                   |   123 +-
 src/noding/IntersectionFinderAdder.cpp             |    47 +-
 src/noding/IteratedNoder.cpp                       |    87 +-
 src/noding/MCIndexNoder.cpp                        |   146 +-
 src/noding/MCIndexSegmentSetMutualIntersector.cpp  |    55 +-
 src/noding/NodedSegmentString.cpp                  |   137 +-
 src/noding/NodingIntersectionFinder.cpp            |    72 +-
 src/noding/NodingValidator.cpp                     |   197 +-
 src/noding/Octant.cpp                              |    86 +-
 src/noding/OrientedCoordinateArray.cpp             |    55 +-
 src/noding/ScaledNoder.cpp                         |   167 +-
 src/noding/SegmentIntersectionDetector.cpp         |    97 +-
 src/noding/SegmentNode.cpp                         |    59 +-
 src/noding/SegmentNodeList.cpp                     |   342 +-
 src/noding/SegmentString.cpp                       |     9 +-
 src/noding/SimpleNoder.cpp                         |    42 +-
 src/noding/snapround/HotPixel.cpp                  |   185 +-
 src/noding/snapround/MCIndexPointSnapper.cpp       |   126 +-
 src/noding/snapround/MCIndexSnapRounder.cpp        |   114 +-
 src/noding/snapround/SimpleSnapRounder.cpp         |   204 +-
 src/operation/GeometryGraphOperation.cpp           |   111 +-
 src/operation/IsSimpleOp.cpp                       |   398 +-
 src/operation/buffer/BufferBuilder.cpp             |   882 +-
 src/operation/buffer/BufferInputLineSimplifier.cpp |   209 +-
 src/operation/buffer/BufferOp.cpp                  |   262 +-
 src/operation/buffer/BufferParameters.cpp          |   115 +-
 src/operation/buffer/BufferSubgraph.cpp            |   425 +-
 src/operation/buffer/OffsetCurveBuilder.cpp        |   363 +-
 src/operation/buffer/OffsetCurveSetBuilder.cpp     |   446 +-
 src/operation/buffer/OffsetSegmentGenerator.cpp    |   773 +-
 src/operation/buffer/RightmostEdgeFinder.cpp       |   328 +-
 src/operation/buffer/SubgraphDepthLocater.cpp      |   408 +-
 .../distance/ConnectedElementLocationFilter.cpp    |    40 +-
 .../distance/ConnectedElementPointFilter.cpp       |    23 +-
 src/operation/distance/DistanceOp.cpp              |   759 +-
 src/operation/distance/FacetSequence.cpp           |    67 +-
 .../distance/FacetSequenceTreeBuilder.cpp          |    30 +-
 src/operation/distance/GeometryLocation.cpp        |    36 +-
 src/operation/distance/IndexedFacetDistance.cpp    |    68 +-
 src/operation/intersection/Rectangle.cpp           |    47 +-
 .../intersection/RectangleIntersection.cpp         |  1049 +-
 .../intersection/RectangleIntersectionBuilder.cpp  |   724 +-
 src/operation/linemerge/EdgeString.cpp             |    64 +-
 src/operation/linemerge/LineMergeDirectedEdge.cpp  |    34 +-
 src/operation/linemerge/LineMergeEdge.cpp          |    13 +-
 src/operation/linemerge/LineMergeGraph.cpp         |   101 +-
 src/operation/linemerge/LineMerger.cpp             |   212 +-
 src/operation/linemerge/LineSequencer.cpp          |   603 +-
 src/operation/overlay/EdgeSetNoder.cpp             |    24 +-
 src/operation/overlay/ElevationMatrix.cpp          |   270 +-
 src/operation/overlay/ElevationMatrixCell.cpp      |    42 +-
 src/operation/overlay/LineBuilder.cpp              |   356 +-
 src/operation/overlay/MaximalEdgeRing.cpp          |    85 +-
 src/operation/overlay/MinimalEdgeRing.cpp          |    14 +-
 src/operation/overlay/OverlayNodeFactory.cpp       |    10 +-
 src/operation/overlay/OverlayOp.cpp                |  1408 ++-
 src/operation/overlay/PointBuilder.cpp             |    75 +-
 src/operation/overlay/PolygonBuilder.cpp           |   479 +-
 src/operation/overlay/snap/GeometrySnapper.cpp     |   191 +-
 src/operation/overlay/snap/LineStringSnapper.cpp   |   520 +-
 .../overlay/snap/SnapIfNeededOverlayOp.cpp         |    44 +-
 src/operation/overlay/snap/SnapOverlayOp.cpp       |    38 +-
 .../overlay/validate/FuzzyPointLocator.cpp         |   133 +-
 .../overlay/validate/OffsetPointGenerator.cpp      |    63 +-
 .../overlay/validate/OverlayResultValidator.cpp    |   164 +-
 src/operation/polygonize/EdgeRing.cpp              |   157 +-
 .../polygonize/PolygonizeDirectedEdge.cpp          |    40 +-
 src/operation/polygonize/PolygonizeEdge.cpp        |    12 +-
 src/operation/polygonize/PolygonizeGraph.cpp       |   659 +-
 src/operation/polygonize/Polygonizer.cpp           |   219 +-
 src/operation/predicate/RectangleContains.cpp      |   148 +-
 src/operation/predicate/RectangleIntersects.cpp    |   359 +-
 .../predicate/SegmentIntersectionTester.cpp        |   107 +-
 src/operation/relate/EdgeEndBuilder.cpp            |   135 +-
 src/operation/relate/EdgeEndBundle.cpp             |   190 +-
 src/operation/relate/EdgeEndBundleStar.cpp         |    54 +-
 src/operation/relate/RelateComputer.cpp            |   620 +-
 src/operation/relate/RelateNode.cpp                |    12 +-
 src/operation/relate/RelateNodeFactory.cpp         |    10 +-
 src/operation/relate/RelateNodeGraph.cpp           |   120 +-
 src/operation/relate/RelateOp.cpp                  |    40 +-
 src/operation/sharedpaths/SharedPathsOp.cpp        |   158 +-
 src/operation/union/CascadedPolygonUnion.cpp       |   246 +-
 src/operation/union/CascadedUnion.cpp              |    71 +-
 src/operation/union/PointGeometryUnion.cpp         |    81 +-
 src/operation/union/UnaryUnionOp.cpp               |   165 +-
 src/operation/valid/ConnectedInteriorTester.cpp    |   388 +-
 src/operation/valid/ConsistentAreaTester.cpp       |   102 +-
 src/operation/valid/IndexedNestedRingTester.cpp    |   139 +-
 src/operation/valid/IndexedNestedRingTester.h      |   109 +-
 src/operation/valid/IsValidOp.cpp                  |   422 +-
 src/operation/valid/QuadtreeNestedRingTester.cpp   |   127 +-
 src/operation/valid/RepeatedPointTester.cpp        |   158 +-
 src/operation/valid/SimpleNestedRingTester.cpp     |    56 +-
 src/operation/valid/SweeplineNestedRingTester.cpp  |    84 +-
 src/operation/valid/TopologyValidationError.cpp    |    48 +-
 src/planargraph/DirectedEdge.cpp                   |    89 +-
 src/planargraph/DirectedEdgeStar.cpp               |   135 +-
 src/planargraph/Edge.cpp                           |    72 +-
 src/planargraph/Node.cpp                           |    48 +-
 src/planargraph/NodeMap.cpp                        |    38 +-
 src/planargraph/PlanarGraph.cpp                    |   128 +-
 src/planargraph/Subgraph.cpp                       |    18 +-
 .../algorithm/ConnectedSubgraphFinder.cpp          |    73 +-
 src/precision/CommonBits.cpp                       |    74 +-
 src/precision/CommonBitsOp.cpp                     |   115 +-
 src/precision/CommonBitsRemover.cpp                |   108 +-
 src/precision/EnhancedPrecisionOp.cpp              |   327 +-
 src/precision/GeometryPrecisionReducer.cpp         |   129 +-
 src/precision/MinimumClearance.cpp                 |    98 +-
 .../PrecisionReducerCoordinateOperation.cpp        |   116 +-
 src/precision/SimpleGeometryPrecisionReducer.cpp   |   163 +-
 src/simplify/DouglasPeuckerLineSimplifier.cpp      |   104 +-
 src/simplify/DouglasPeuckerSimplifier.cpp          |   137 +-
 src/simplify/LineSegmentIndex.cpp                  |   128 +-
 src/simplify/TaggedLineSegment.cpp                 |    36 +-
 src/simplify/TaggedLineString.cpp                  |   149 +-
 src/simplify/TaggedLineStringSimplifier.cpp        |   339 +-
 src/simplify/TaggedLinesSimplifier.cpp             |    14 +-
 src/simplify/TopologyPreservingSimplifier.cpp      |   335 +-
 src/triangulate/DelaunayTriangulationBuilder.cpp   |   119 +-
 .../IncrementalDelaunayTriangulator.cpp            |    32 +-
 src/triangulate/VoronoiDiagramBuilder.cpp          |   117 +-
 .../quadedge/LastFoundQuadEdgeLocator.cpp          |    24 +-
 .../quadedge/LocateFailureException.cpp            |     4 +-
 src/triangulate/quadedge/QuadEdge.cpp              |   176 +-
 src/triangulate/quadedge/QuadEdgeSubdivision.cpp   |   470 +-
 src/triangulate/quadedge/TrianglePredicate.cpp     |    78 +-
 src/triangulate/quadedge/Vertex.cpp                |   245 +-
 src/util/Assert.cpp                                |    33 +-
 src/util/GeometricShapeFactory.cpp                 |   283 +-
 src/util/Interrupt.cpp                             |    47 +-
 src/util/Profiler.cpp                              |    93 +-
 src/util/math.cpp                                  |   131 +-
 tests/bigtest/GeometryTestFactory.cpp              |   197 +-
 tests/bigtest/TestSweepLineSpeed.cpp               |    58 +-
 tests/bigtest/bigtest.h                            |    24 +-
 tests/bigtest/bug234.cpp                           |    72 +-
 tests/perf/ClassSizes.cpp                          |    10 +-
 .../operation/buffer/IteratedBufferStressTest.cpp  |    61 +-
 .../predicate/RectangleIntersectsPerfTest.cpp      |   198 +-
 tests/unit/algorithm/AngleTest.cpp                 |   165 +-
 tests/unit/algorithm/AreaTest.cpp                  |   166 +-
 .../CGAlgorithms/computeOrientationTest.cpp        |   178 +-
 tests/unit/algorithm/CGAlgorithms/isCCWTest.cpp    |   189 +-
 .../algorithm/CGAlgorithms/isPointInRingTest.cpp   |   102 +-
 .../unit/algorithm/CGAlgorithms/signedAreaTest.cpp |   133 +-
 tests/unit/algorithm/ConvexHullTest.cpp            |   275 +-
 tests/unit/algorithm/InteriorPointAreaTest.cpp     |    76 +-
 tests/unit/algorithm/LengthTest.cpp                |   124 +-
 tests/unit/algorithm/LocatePointInRingTest.cpp     |   302 +-
 tests/unit/algorithm/MinimumBoundingCircleTest.cpp |   299 +-
 tests/unit/algorithm/MinimumDiameterTest.cpp       |   418 +-
 .../unit/algorithm/OrientationIndexFailureTest.cpp |   144 +-
 tests/unit/algorithm/PointLocatorTest.cpp          |   173 +-
 .../unit/algorithm/RobustLineIntersectionTest.cpp  |   786 +-
 tests/unit/algorithm/RobustLineIntersectorTest.cpp |   368 +-
 .../distance/DiscreteFrechetDistanceTest.cpp       |   207 +-
 .../distance/DiscreteHausdorffDistanceTest.cpp     |   207 +-
 tests/unit/capi/GEOSBufferTest.cpp                 |   791 +-
 tests/unit/capi/GEOSCAPIDefinesTest.cpp            |    77 +-
 tests/unit/capi/GEOSClipByRectTest.cpp             |   211 +-
 tests/unit/capi/GEOSContainsTest.cpp               |   382 +-
 tests/unit/capi/GEOSConvexHullTest.cpp             |   126 +-
 tests/unit/capi/GEOSCoordSeqTest.cpp               |   500 +-
 tests/unit/capi/GEOSDelaunayTriangulationTest.cpp  |   308 +-
 tests/unit/capi/GEOSDistanceTest.cpp               |   199 +-
 tests/unit/capi/GEOSEqualsTest.cpp                 |   268 +-
 tests/unit/capi/GEOSFrechetDistanceTest.cpp        |   151 +-
 tests/unit/capi/GEOSGeomFromWKBTest.cpp            |   238 +-
 tests/unit/capi/GEOSGeomToWKTTest.cpp              |   327 +-
 tests/unit/capi/GEOSGeom_create.cpp                |   230 +-
 tests/unit/capi/GEOSGeom_createCollection.cpp      |   161 +-
 tests/unit/capi/GEOSGeom_extentTest.cpp            |   106 +-
 .../unit/capi/GEOSGeom_extractUniquePointsTest.cpp |   152 +-
 tests/unit/capi/GEOSGeom_setPrecisionTest.cpp      |   325 +-
 tests/unit/capi/GEOSGetCentroidTest.cpp            |   238 +-
 tests/unit/capi/GEOSHausdorffDistanceTest.cpp      |   151 +-
 tests/unit/capi/GEOSInterpolateTest.cpp            |    90 +-
 tests/unit/capi/GEOSInterruptTest.cpp              |   280 +-
 tests/unit/capi/GEOSIntersectionTest.cpp           |   259 +-
 tests/unit/capi/GEOSIntersectsTest.cpp             |   256 +-
 tests/unit/capi/GEOSLineString_PointTest.cpp       |   219 +-
 tests/unit/capi/GEOSMinimumClearanceTest.cpp       |   215 +-
 tests/unit/capi/GEOSMinimumRectangleTest.cpp       |   130 +-
 tests/unit/capi/GEOSMinimumWidthTest.cpp           |   155 +-
 tests/unit/capi/GEOSNearestPointsTest.cpp          |   177 +-
 tests/unit/capi/GEOSNodeTest.cpp                   |   204 +-
 tests/unit/capi/GEOSOffsetCurveTest.cpp            |   441 +-
 tests/unit/capi/GEOSOrientationIndex.cpp           |   260 +-
 tests/unit/capi/GEOSPointOnSurfaceTest.cpp         |   386 +-
 .../unit/capi/GEOSPolygonizer_getCutEdgesTest.cpp  |   135 +-
 tests/unit/capi/GEOSPreparedGeometryTest.cpp       |   557 +-
 tests/unit/capi/GEOSRelateBoundaryNodeRuleTest.cpp |   265 +-
 tests/unit/capi/GEOSRelatePatternMatchTest.cpp     |   148 +-
 tests/unit/capi/GEOSReverseTest.cpp                |   220 +-
 tests/unit/capi/GEOSSTRtreeTest.cpp                |   462 +-
 tests/unit/capi/GEOSSegmentIntersectionTest.cpp    |   115 +-
 tests/unit/capi/GEOSSharedPathsTest.cpp            |   192 +-
 tests/unit/capi/GEOSSimplifyTest.cpp               |   114 +-
 tests/unit/capi/GEOSSnapTest.cpp                   |   409 +-
 tests/unit/capi/GEOSUnaryUnionTest.cpp             |   363 +-
 tests/unit/capi/GEOSUserDataTest.cpp               |   136 +-
 tests/unit/capi/GEOSVoronoiDiagramTest.cpp         |   289 +-
 tests/unit/capi/GEOSWithinTest.cpp                 |   174 +-
 tests/unit/capi/GEOSisClosedTest.cpp               |   139 +-
 tests/unit/capi/GEOSisValidDetailTest.cpp          |   278 +-
 .../geom/CoordinateArraySequenceFactoryTest.cpp    |   353 +-
 tests/unit/geom/CoordinateArraySequenceTest.cpp    |  1110 +-
 tests/unit/geom/CoordinateListTest.cpp             |   237 +-
 tests/unit/geom/CoordinateTest.cpp                 |   367 +-
 tests/unit/geom/DimensionTest.cpp                  |   243 +-
 tests/unit/geom/EnvelopeTest.cpp                   |   458 +-
 tests/unit/geom/Geometry/clone.cpp                 |   154 +-
 tests/unit/geom/Geometry/coversTest.cpp            |   115 +-
 tests/unit/geom/Geometry/equalsTest.cpp            |    45 +-
 tests/unit/geom/Geometry/isRectangleTest.cpp       |   257 +-
 tests/unit/geom/Geometry/normalize.cpp             |   252 +-
 tests/unit/geom/Geometry/touchesTest.cpp           |    59 +-
 tests/unit/geom/GeometryCollectionTest.cpp         |   128 +-
 tests/unit/geom/GeometryComponentFilterTest.cpp    |    32 +-
 tests/unit/geom/GeometryFactoryTest.cpp            |  2489 ++---
 tests/unit/geom/GeometryFilterTest.cpp             |    32 +-
 tests/unit/geom/IntersectionMatrixTest.cpp         |  1083 +-
 tests/unit/geom/LineSegmentTest.cpp                |   210 +-
 tests/unit/geom/LineStringTest.cpp                 |   977 +-
 tests/unit/geom/LinearRingTest.cpp                 |   862 +-
 tests/unit/geom/LocationTest.cpp                   |   119 +-
 tests/unit/geom/MultiLineStringTest.cpp            |    53 +-
 tests/unit/geom/MultiPointTest.cpp                 |   750 +-
 tests/unit/geom/MultiPolygonTest.cpp               |    53 +-
 tests/unit/geom/PointTest.cpp                      |  1042 +-
 tests/unit/geom/PolygonTest.cpp                    |  1130 +-
 tests/unit/geom/PrecisionModelTest.cpp             |   244 +-
 tests/unit/geom/TriangleTest.cpp                   |   320 +-
 .../geom/prep/PreparedGeometry/touchesTest.cpp     |    47 +-
 .../unit/geom/prep/PreparedGeometryFactoryTest.cpp |   787 +-
 tests/unit/geom/util/GeometryExtracterTest.cpp     |   117 +-
 tests/unit/geos_unit.cpp                           |    76 +-
 tests/unit/index/quadtree/DoubleBitsTest.cpp       |    44 +-
 tests/unit/index/strtree/SIRtreeTest.cpp           |    46 +-
 tests/unit/io/ByteOrderValuesTest.cpp              |   267 +-
 tests/unit/io/WKBReaderTest.cpp                    |   556 +-
 tests/unit/io/WKBWriterTest.cpp                    |   316 +-
 tests/unit/io/WKTReaderTest.cpp                    |   314 +-
 tests/unit/io/WKTWriterTest.cpp                    |   195 +-
 tests/unit/io/WriterTest.cpp                       |    76 +-
 tests/unit/linearref/LengthIndexedLineTest.cpp     |   218 +-
 tests/unit/noding/BasicSegmentStringTest.cpp       |   273 +-
 tests/unit/noding/NodedSegmentStringTest.cpp       |   213 +-
 tests/unit/noding/OrientedCoordinateArray.cpp      |   193 +-
 tests/unit/noding/SegmentNodeTest.cpp              |   286 +-
 tests/unit/noding/SegmentPointComparatorTest.cpp   |   258 +-
 tests/unit/noding/snapround/HotPixelTest.cpp       |    91 +-
 .../noding/snapround/MCIndexSnapRounderTest.cpp    |   192 +-
 tests/unit/operation/IsSimpleOpTest.cpp            |   151 +-
 tests/unit/operation/buffer/BufferBuilderTest.cpp  |   201 +-
 tests/unit/operation/buffer/BufferOpTest.cpp       |   556 +-
 .../unit/operation/buffer/BufferParametersTest.cpp |   384 +-
 tests/unit/operation/distance/DistanceOpTest.cpp   |   725 +-
 .../intersection/RectangleIntersectionTest.cpp     |  2246 ++--
 tests/unit/operation/linemerge/LineMergerTest.cpp  |   351 +-
 .../unit/operation/linemerge/LineSequencerTest.cpp |   366 +-
 .../unit/operation/overlay/OverlayOpUnionTest.cpp  |    75 +-
 .../operation/overlay/snap/GeometrySnapperTest.cpp |   118 +-
 .../overlay/snap/LineStringSnapperTest.cpp         |   373 +-
 .../overlay/validate/FuzzyPointLocatorTest.cpp     |   350 +-
 .../overlay/validate/OffsetPointGeneratorTest.cpp  |   275 +-
 .../validate/OverlayResultValidatorTest.cpp        |   226 +-
 tests/unit/operation/polygonize/PolygonizeTest.cpp |   245 +-
 .../operation/sharedpaths/SharedPathsOpTest.cpp    |   336 +-
 .../operation/union/CascadedPolygonUnionTest.cpp   |   201 +-
 tests/unit/operation/union/UnaryUnionOpTest.cpp    |   303 +-
 tests/unit/operation/valid/IsValidTest.cpp         |    75 +-
 tests/unit/operation/valid/ValidClosedRingTest.cpp |   236 +-
 .../valid/ValidSelfTouchingRingFormingHoleTest.cpp |   273 +-
 tests/unit/precision/CommonBitsTest.cpp            |    76 +-
 .../precision/GeometryPrecisionReducerTest.cpp     |   293 +-
 .../SimpleGeometryPrecisionReducerTest.cpp         |   211 +-
 .../unit/simplify/DouglasPeuckerSimplifierTest.cpp |   496 +-
 .../simplify/TopologyPreservingSimplifierTest.cpp  |   434 +-
 tests/unit/triangulate/DelaunayTest.cpp            |   370 +-
 tests/unit/triangulate/VoronoiTest.cpp             |   337 +-
 .../quadedge/QuadEdgeSubdivisionTest.cpp           |   220 +-
 tests/unit/triangulate/quadedge/QuadEdgeTest.cpp   |   309 +-
 tests/unit/triangulate/quadedge/VertexTest.cpp     |    79 +-
 .../unit/util/UniqueCoordinateArrayFilterTest.cpp  |   141 +-
 tests/unit/utility.h                               |    63 +-
 tests/xmltester/BufferResultMatcher.cpp            |   136 +-
 tests/xmltester/BufferResultMatcher.h              |    43 +-
 tests/xmltester/CTS.cpp                            |    18 +-
 tests/xmltester/SimpleWKTTester.cpp                |    62 +-
 tests/xmltester/SingleSidedBufferResultMatcher.cpp |    89 +-
 tests/xmltester/SingleSidedBufferResultMatcher.h   |    37 +-
 tests/xmltester/XMLTester.cpp                      |  1220 ++-
 tests/xmltester/XMLTester.h                        |   173 +-
 812 files changed, 80653 insertions(+), 77215 deletions(-)
 create mode 100644 .astylerc


hooks/post-receive
-- 
GEOS


More information about the geos-commits mailing list