[geos-commits] r3440 - in branches/3.3: . src/operation/buffer tests/unit/capi

svn_geos at osgeo.org svn_geos at osgeo.org
Wed Jul 20 07:48:31 EDT 2011


Author: strk
Date: 2011-07-20 04:48:31 -0700 (Wed, 20 Jul 2011)
New Revision: 3440

Modified:
   branches/3.3/NEWS
   branches/3.3/src/operation/buffer/BufferBuilder.cpp
   branches/3.3/tests/unit/capi/GEOSOffsetCurveTest.cpp
Log:
Fix EMPTY result from GEOSOffsetCurve with distance 0 (#454)


Modified: branches/3.3/NEWS
===================================================================
--- branches/3.3/NEWS	2011-07-20 11:45:24 UTC (rev 3439)
+++ branches/3.3/NEWS	2011-07-20 11:48:31 UTC (rev 3440)
@@ -6,6 +6,7 @@
   - Enable prepared intersects operation for points
   - Fortify suspicious code found by static analisys tools
   - Fix for SOLARIS build 
+  - Fix EMPTY result from GEOSOffsetCurve with distance 0 (#454)
 
 Changes in 3.3.0
 2011-05-30

Modified: branches/3.3/src/operation/buffer/BufferBuilder.cpp
===================================================================
--- branches/3.3/src/operation/buffer/BufferBuilder.cpp	2011-07-20 11:45:24 UTC (rev 3439)
+++ branches/3.3/src/operation/buffer/BufferBuilder.cpp	2011-07-20 11:48:31 UTC (rev 3440)
@@ -141,6 +141,9 @@
    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();

Modified: branches/3.3/tests/unit/capi/GEOSOffsetCurveTest.cpp
===================================================================
--- branches/3.3/tests/unit/capi/GEOSOffsetCurveTest.cpp	2011-07-20 11:45:24 UTC (rev 3439)
+++ branches/3.3/tests/unit/capi/GEOSOffsetCurveTest.cpp	2011-07-20 11:48:31 UTC (rev 3440)
@@ -168,6 +168,26 @@
         ));
     }
 
+    // 0 distance
+    // See http://trac.osgeo.org/postgis/ticket/454
+    template<>
+    template<>
+    void object::test<6>()
+    {
+        geom1_ = GEOSGeomFromWKT("LINESTRING(0 0, 10 0)");
 
+        ensure( 0 != geom1_ );
+
+        geom2_ = GEOSOffsetCurve(geom1_, 0, 0, GEOSBUF_JOIN_ROUND, 2);
+
+        ensure( 0 != geom2_ );
+
+        wkt_ = GEOSWKTWriter_write(wktw_, geom2_);
+
+        ensure_equals(std::string(wkt_), std::string(
+          "LINESTRING (0 0, 10 0)"
+        ));
+    }
+
 } // namespace tut
 



More information about the geos-commits mailing list