[geos-commits] r3886 - in branches/3.4: . src/operation/overlay/snap tests/unit/capi

svn_geos at osgeo.org svn_geos at osgeo.org
Fri Aug 16 08:26:51 PDT 2013


Author: strk
Date: 2013-08-16 08:26:51 -0700 (Fri, 16 Aug 2013)
New Revision: 3886

Modified:
   branches/3.4/NEWS
   branches/3.4/src/operation/overlay/snap/LineStringSnapper.cpp
   branches/3.4/tests/unit/capi/GEOSSnapTest.cpp
Log:
Fix assertion failure in snapping code (#649)

The bug affected attempts to snapping lines to the points
of a rectangle with a side smaller than the tolerance.

Modified: branches/3.4/NEWS
===================================================================
--- branches/3.4/NEWS	2013-08-16 15:25:13 UTC (rev 3885)
+++ branches/3.4/NEWS	2013-08-16 15:26:51 UTC (rev 3886)
@@ -1,3 +1,10 @@
+Changes in 3.4.1
+2013-08-DD
+
+- Bug fixes / improvements
+  - Assertion failure snapping line to points of rectangle
+    smaller than tolerance (#649)
+
 Changes in 3.4.0
 2013-08-11
 

Modified: branches/3.4/src/operation/overlay/snap/LineStringSnapper.cpp
===================================================================
--- branches/3.4/src/operation/overlay/snap/LineStringSnapper.cpp	2013-08-16 15:25:13 UTC (rev 3885)
+++ branches/3.4/src/operation/overlay/snap/LineStringSnapper.cpp	2013-08-16 15:26:51 UTC (rev 3886)
@@ -262,7 +262,7 @@
     CoordinateList::iterator to = segpos; ++to;
     LineSegment seg(*segpos, *to);
     double pf = seg.projectionFactor(snapPt);
-    if ( pf > 1.0 ) {
+    if ( pf >= 1.0 ) {
 #if GEOS_DEBUG
       cerr << " Segment to be snapped is closer on his end point" << endl;
 #endif
@@ -301,7 +301,7 @@
         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;
 #endif
@@ -346,7 +346,7 @@
       }
     }
     else {
-      assert(pf != 0.0);
+      //assert(pf != 0.0);
 #if GEOS_DEBUG
 cerr << " Segment to be snapped found, projection factor is " << pf << ", inserting point" << endl;
 #endif

Modified: branches/3.4/tests/unit/capi/GEOSSnapTest.cpp
===================================================================
--- branches/3.4/tests/unit/capi/GEOSSnapTest.cpp	2013-08-16 15:25:13 UTC (rev 3885)
+++ branches/3.4/tests/unit/capi/GEOSSnapTest.cpp	2013-08-16 15:26:51 UTC (rev 3886)
@@ -42,6 +42,7 @@
             initGEOS(notice, notice);
             w_ = GEOSWKTWriter_create();
             GEOSWKTWriter_setTrim(w_, 1);
+            GEOSWKTWriter_setRoundingPrecision(w_, 8);
         }       
 
         ~test_capigeossnap_data()
@@ -216,5 +217,21 @@
         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);
+
+        ensure_equals(out, "LINESTRING (-71.1257 42.2703, -71.1261 42.2703, -71.1261 42.2702, -71.1317 42.2509)");
+    }
+
 } // namespace tut
 



More information about the geos-commits mailing list