Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fix reshape involving first/last vertex (fix #14443)
  • Loading branch information
nyalldawson committed Mar 9, 2016
1 parent 3b4638a commit bb0ecf4
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/core/geometry/qgsgeos.cpp
Expand Up @@ -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 ) );
}
Expand Down
15 changes: 15 additions & 0 deletions tests/src/python/test_qgsgeometry.py
Expand Up @@ -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)')
Expand Down

0 comments on commit bb0ecf4

Please sign in to comment.