Skip to content
Permalink
Browse files

Fix reshape involving first/last vertex (fix #14443)

  • Loading branch information
nyalldawson committed Mar 9, 2016
1 parent 3b4638a commit bb0ecf427fd3c92a46bac26d7344f82381f34e8e
Showing with 16 additions and 1 deletion.
  1. +1 −1 src/core/geometry/qgsgeos.cpp
  2. +15 −0 tests/src/python/test_qgsgeometry.py
@@ -1989,7 +1989,7 @@ GEOSGeometry* QgsGeos::reshapeLine( const GEOSGeometry* line, const GEOSGeometry
currentGeomOverlapsReshapeLine = true;

//logic to decide if this part belongs to the result
if ( nEndpointsSameAsOriginalLine == 1 && nEndpointsOnOriginalLine == 2 && currentGeomOverlapsOriginalGeom )
if ( !isRing && nEndpointsSameAsOriginalLine == 1 && nEndpointsOnOriginalLine == 2 && currentGeomOverlapsOriginalGeom )
{
resultLineParts.push_back( GEOSGeom_clone_r( geosinit.ctxt, currentGeom ) );
}
@@ -1658,6 +1658,21 @@ def testRegression13274(self):
wkt = c.exportToWkt()
assert compareWkt(expWkt, wkt), "testRegression13274 failed: mismatch Expected:\n%s\nGot:\n%s\n" % (expWkt, wkt)

def testReshape(self):
""" Test geometry reshaping """
g = QgsGeometry.fromWkt('Polygon ((0 0, 1 0, 1 1, 0 1, 0 0))')
g.reshapeGeometry([QgsPoint(0, 1.5), QgsPoint(1.5, 0)])
expWkt = 'Polygon ((0.5 1, 0 1, 0 0, 1 0, 1 0.5, 0.5 1))'
wkt = g.exportToWkt()
assert compareWkt(expWkt, wkt), "testReshape failed: mismatch Expected:\n%s\nGot:\n%s\n" % (expWkt, wkt)

# Test reshape a geometry involving the first/last vertex (http://hub.qgis.org/issues/14443)
g.reshapeGeometry([QgsPoint(0.5, 1), QgsPoint(0, 0.5)])

expWkt = 'Polygon ((0 0.5, 0 0, 1 0, 1 0.5, 0.5 1, 0 0.5))'
wkt = g.exportToWkt()
assert compareWkt(expWkt, wkt), "testReshape failed: mismatch Expected:\n%s\nGot:\n%s\n" % (expWkt, wkt)

def testConvertToMultiType(self):
""" Test converting geometries to multi type """
point = QgsGeometry.fromWkt('Point (1 2)')

0 comments on commit bb0ecf4

Please sign in to comment.
You can’t perform that action at this time.