Skip to content

Commit bb0ecf4

Browse files
committedMar 9, 2016
Fix reshape involving first/last vertex (fix #14443)
1 parent 3b4638a commit bb0ecf4

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed
 

‎src/core/geometry/qgsgeos.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1989,7 +1989,7 @@ GEOSGeometry* QgsGeos::reshapeLine( const GEOSGeometry* line, const GEOSGeometry
19891989
currentGeomOverlapsReshapeLine = true;
19901990

19911991
//logic to decide if this part belongs to the result
1992-
if ( nEndpointsSameAsOriginalLine == 1 && nEndpointsOnOriginalLine == 2 && currentGeomOverlapsOriginalGeom )
1992+
if ( !isRing && nEndpointsSameAsOriginalLine == 1 && nEndpointsOnOriginalLine == 2 && currentGeomOverlapsOriginalGeom )
19931993
{
19941994
resultLineParts.push_back( GEOSGeom_clone_r( geosinit.ctxt, currentGeom ) );
19951995
}

‎tests/src/python/test_qgsgeometry.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1658,6 +1658,21 @@ def testRegression13274(self):
16581658
wkt = c.exportToWkt()
16591659
assert compareWkt(expWkt, wkt), "testRegression13274 failed: mismatch Expected:\n%s\nGot:\n%s\n" % (expWkt, wkt)
16601660

1661+
def testReshape(self):
1662+
""" Test geometry reshaping """
1663+
g = QgsGeometry.fromWkt('Polygon ((0 0, 1 0, 1 1, 0 1, 0 0))')
1664+
g.reshapeGeometry([QgsPoint(0, 1.5), QgsPoint(1.5, 0)])
1665+
expWkt = 'Polygon ((0.5 1, 0 1, 0 0, 1 0, 1 0.5, 0.5 1))'
1666+
wkt = g.exportToWkt()
1667+
assert compareWkt(expWkt, wkt), "testReshape failed: mismatch Expected:\n%s\nGot:\n%s\n" % (expWkt, wkt)
1668+
1669+
# Test reshape a geometry involving the first/last vertex (http://hub.qgis.org/issues/14443)
1670+
g.reshapeGeometry([QgsPoint(0.5, 1), QgsPoint(0, 0.5)])
1671+
1672+
expWkt = 'Polygon ((0 0.5, 0 0, 1 0, 1 0.5, 0.5 1, 0 0.5))'
1673+
wkt = g.exportToWkt()
1674+
assert compareWkt(expWkt, wkt), "testReshape failed: mismatch Expected:\n%s\nGot:\n%s\n" % (expWkt, wkt)
1675+
16611676
def testConvertToMultiType(self):
16621677
""" Test converting geometries to multi type """
16631678
point = QgsGeometry.fromWkt('Point (1 2)')

0 commit comments

Comments
 (0)
Please sign in to comment.