Skip to content

Commit 1fc2747

Browse files
uclarosuclaros
uclaros
authored and
uclaros
committed
Quick fix for a bug in QgsGeos::reshapeLine that causes QGIS to crash because of an unhandled geos exception.
1 parent b20e80a commit 1fc2747

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

src/core/geometry/qgsgeos.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -2382,7 +2382,7 @@ static geos::unique_ptr _mergeLinestrings( const GEOSGeometry *line1, const GEOS
23822382
return nullptr;
23832383

23842384
bool intersectionAtOrigLineEndpoint =
2385-
( intersectionPoint.x() == x1 && intersectionPoint.y() == y1 ) ||
2385+
( intersectionPoint.x() == x1 && intersectionPoint.y() == y1 ) !=
23862386
( intersectionPoint.x() == x2 && intersectionPoint.y() == y2 );
23872387
bool intersectionAtReshapeLineEndpoint =
23882388
( intersectionPoint.x() == rx1 && intersectionPoint.y() == ry1 ) ||

tests/src/python/test_qgsgeometry.py

+12
Original file line numberDiff line numberDiff line change
@@ -2334,6 +2334,18 @@ def testReshape(self):
23342334
wkt = g.asWkt()
23352335
assert compareWkt(expWkt, wkt), "testReshape failed: mismatch Expected:\n%s\nGot:\n%s\n" % (expWkt, wkt)
23362336

2337+
# Test reshape a polygon with a line starting or ending at the polygon's first vertex, no change expexted
2338+
g = QgsGeometry.fromWkt('Polygon ((0 0, 1 0, 1 1, 0 1, 0 0))')
2339+
expWkt = g.asWkt()
2340+
g.reshapeGeometry(QgsLineString([QgsPoint(0, 0), QgsPoint(-1, -1)]))
2341+
assert compareWkt(g.asWkt(), expWkt), "testReshape failed: mismatch Expected:\n%s\nGot:\n%s\n" % (expWkt, wkt)
2342+
2343+
# Test reshape a polygon with a line starting or ending at the polygon's first vertex
2344+
g = QgsGeometry.fromWkt('Polygon ((0 0, 1 0, 1 1, 0 1, 0 0))')
2345+
g.reshapeGeometry(QgsLineString([QgsPoint(0, 0), QgsPoint(0.5, 0.5), QgsPoint(0, 1)]))
2346+
expWkt = 'Polygon ((0 0, 1 0, 1 1, 0 1, 0.5 0.5, 0 0))'
2347+
assert compareWkt(g.asWkt(), expWkt), "testReshape failed: mismatch Expected:\n%s\nGot:\n%s\n" % (expWkt, wkt)
2348+
23372349
# Test reshape a line from first/last vertex
23382350
g = QgsGeometry.fromWkt('LineString (0 0, 5 0, 5 1)')
23392351
# extend start

0 commit comments

Comments
 (0)