[geos-commits] r3823 - in trunk: include/geos/operation/buffer src/operation/buffer tests/unit/operation/buffer

svn_geos at osgeo.org svn_geos at osgeo.org
Wed Jun 12 09:08:01 PDT 2013


Author: mloskot
Date: 2013-06-12 09:08:00 -0700 (Wed, 12 Jun 2013)
New Revision: 3823

Modified:
   trunk/include/geos/operation/buffer/BufferBuilder.h
   trunk/src/operation/buffer/BufferBuilder.cpp
   trunk/tests/unit/operation/buffer/BufferBuilderTest.cpp
Log:
Final clarification of BufferBuilder::bufferLineSingleSided behaviour (ticket #633)
* Ignore BufferParameters::setSingleSided() parameter as it is specific to areal geometries.
* Document semantic of input parameters.
* Document order of coordinates in generated output (conforms to PostGIS behaviour).
* Add test for coordinates order assumptions.

Modified: trunk/include/geos/operation/buffer/BufferBuilder.h
===================================================================
--- trunk/include/geos/operation/buffer/BufferBuilder.h	2013-06-12 14:06:44 UTC (rev 3822)
+++ trunk/include/geos/operation/buffer/BufferBuilder.h	2013-06-12 16:08:00 UTC (rev 3823)
@@ -138,7 +138,24 @@
 	geom::Geometry* buffer(const geom::Geometry *g, double distance);
 		// throw (GEOSException);
 
-	/// Not in JTS: this is a GEOS extension
+	/**
+     * Generates offset curve for linear geometry.
+     *
+	 * @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.
+     *
+     * @note For left-side offset curve, the offset will be at the left side
+     *       of the input line and retain the same direction.
+     *       For right-side offset curve, it'll be at the right side
+     *       and in the opposite direction.
+     *
+     * @note BufferParameters::setSingleSided parameter, which is specific to
+     *       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);

Modified: trunk/src/operation/buffer/BufferBuilder.cpp
===================================================================
--- trunk/src/operation/buffer/BufferBuilder.cpp	2013-06-12 14:06:44 UTC (rev 3822)
+++ trunk/src/operation/buffer/BufferBuilder.cpp	2013-06-12 16:08:00 UTC (rev 3823)
@@ -150,6 +150,7 @@
    // 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
    Geometry* buf = 0;
 
    // This is a (temp?) hack to workaround the fact that

Modified: trunk/tests/unit/operation/buffer/BufferBuilderTest.cpp
===================================================================
--- trunk/tests/unit/operation/buffer/BufferBuilderTest.cpp	2013-06-12 14:06:44 UTC (rev 3822)
+++ trunk/tests/unit/operation/buffer/BufferBuilderTest.cpp	2013-06-12 16:08:00 UTC (rev 3823)
@@ -101,6 +101,8 @@
             // 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(
                 CGAlgorithms::isCCW(dynamic_cast<LineString*>(g0.get())->getCoordinatesRO()),
                 CGAlgorithms::isCCW(dynamic_cast<LineString*>(gB.get())->getCoordinatesRO()));
@@ -114,11 +116,11 @@
             // Right-side offset curve expected with 5+ vertices
             ensure(gB->getNumPoints() >= g0->getNumPoints());
 
-            // FIXME: this check if failing
-            // We need to decide if bufferLineSingleSided should take care of reversing coords order --mloskot
-            //ensure_equals(
-            //    CGAlgorithms::isCCW(dynamic_cast<LineString*>(g0.get())->getCoordinatesRO()),
-            //    CGAlgorithms::isCCW(dynamic_cast<LineString*>(gB.get())->getCoordinatesRO()));
+            // For right-side offset curve, it'll be at the right side
+            // and in the opposite direction.
+            ensure_equals(
+                CGAlgorithms::isCCW(dynamic_cast<LineString*>(g0.get())->getCoordinatesRO()),
+                !CGAlgorithms::isCCW(dynamic_cast<LineString*>(gB.get())->getCoordinatesRO()));
         }
     }
 



More information about the geos-commits mailing list