[geos-commits] r3845 - in trunk: src/operation/buffer tests/unit/capi
svn_geos at osgeo.org
svn_geos at osgeo.org
Wed Jul 17 08:58:31 PDT 2013
Author: strk
Date: 2013-07-17 08:58:30 -0700 (Wed, 17 Jul 2013)
New Revision: 3845
Modified:
trunk/src/operation/buffer/BufferInputLineSimplifier.cpp
trunk/src/operation/buffer/OffsetSegmentGenerator.cpp
trunk/tests/unit/capi/GEOSOffsetCurveTest.cpp
Log:
Fix OffsetCurve op in presence of duplicated vertices (#602)
Modified: trunk/src/operation/buffer/BufferInputLineSimplifier.cpp
===================================================================
--- trunk/src/operation/buffer/BufferInputLineSimplifier.cpp 2013-07-17 13:05:36 UTC (rev 3844)
+++ trunk/src/operation/buffer/BufferInputLineSimplifier.cpp 2013-07-17 15:58:30 UTC (rev 3845)
@@ -80,7 +80,6 @@
* This ensures that end caps are generated consistently.
*/
unsigned int index = 1;
- //int maxIndex = inputLine.size() - 1;
unsigned int midIndex = findNextNonDeletedIndex(index);
unsigned int lastIndex = findNextNonDeletedIndex(midIndex);
@@ -130,7 +129,7 @@
for (size_t i=0, n=inputLine.size(); i<n; ++i)
{
if (isDeleted[i] != DELETE)
- coordList->add(inputLine[i]);
+ coordList->add(inputLine[i], false);
}
return coordList;
Modified: trunk/src/operation/buffer/OffsetSegmentGenerator.cpp
===================================================================
--- trunk/src/operation/buffer/OffsetSegmentGenerator.cpp 2013-07-17 13:05:36 UTC (rev 3844)
+++ trunk/src/operation/buffer/OffsetSegmentGenerator.cpp 2013-07-17 15:58:30 UTC (rev 3845)
@@ -133,6 +133,10 @@
void
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;
@@ -143,9 +147,6 @@
seg1.setCoordinates(s1, s2);
computeOffsetSegment(seg1, side, distance, offset1);
- // do nothing if points are equal
- if (s1==s2) return;
-
int orientation=CGAlgorithms::computeOrientation(s0, s1, s2);
bool outsideTurn =
(orientation==CGAlgorithms::CLOCKWISE
Modified: trunk/tests/unit/capi/GEOSOffsetCurveTest.cpp
===================================================================
--- trunk/tests/unit/capi/GEOSOffsetCurveTest.cpp 2013-07-17 13:05:36 UTC (rev 3844)
+++ trunk/tests/unit/capi/GEOSOffsetCurveTest.cpp 2013-07-17 15:58:30 UTC (rev 3845)
@@ -230,5 +230,43 @@
}
}
+ // 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( 0 != geom1_ );
+
+ geom2_ = GEOSOffsetCurve(geom1_, width, 8, GEOSBUF_JOIN_ROUND, 0);
+ ensure( "Unexpected exception", 0 != geom2_ );
+ wkt_ = GEOSWKTWriter_write(wktw_, geom2_);
+ GEOSGeom_destroy(geom2_); geom2_ = 0;
+ ensure_equals(std::string(wkt_), "LINESTRING (10 9, 1 9, 1 0)");
+ GEOSFree(wkt_); wkt_ = 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( 0 != geom1_ );
+
+ geom2_ = GEOSOffsetCurve(geom1_, width, 8, GEOSBUF_JOIN_ROUND, 0);
+ ensure( "Unexpected exception", 0 != geom2_ );
+ wkt_ = GEOSWKTWriter_write(wktw_, geom2_);
+ GEOSGeom_destroy(geom2_); geom2_ = 0;
+ ensure_equals(std::string(wkt_), "LINESTRING (1 10, 1 0)");
+ GEOSFree(wkt_); wkt_ = 0;
+ }
+
} // namespace tut
More information about the geos-commits
mailing list