[geos-commits] r3885 - in trunk: src/operation/overlay/snap tests/unit/capi
svn_geos at osgeo.org
svn_geos at osgeo.org
Fri Aug 16 08:25:13 PDT 2013
Author: strk
Date: 2013-08-16 08:25:13 -0700 (Fri, 16 Aug 2013)
New Revision: 3885
Modified:
trunk/src/operation/overlay/snap/LineStringSnapper.cpp
trunk/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: trunk/src/operation/overlay/snap/LineStringSnapper.cpp
===================================================================
--- trunk/src/operation/overlay/snap/LineStringSnapper.cpp 2013-08-14 06:10:33 UTC (rev 3884)
+++ trunk/src/operation/overlay/snap/LineStringSnapper.cpp 2013-08-16 15:25:13 UTC (rev 3885)
@@ -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: trunk/tests/unit/capi/GEOSSnapTest.cpp
===================================================================
--- trunk/tests/unit/capi/GEOSSnapTest.cpp 2013-08-14 06:10:33 UTC (rev 3884)
+++ trunk/tests/unit/capi/GEOSSnapTest.cpp 2013-08-16 15:25:13 UTC (rev 3885)
@@ -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