Skip to content
Permalink
Browse files

restore behavior of QgsGeometry::combine on line strings (fixes #13274)

  • Loading branch information
jef-n committed Oct 5, 2015
1 parent 52e7628 commit ac3f390dfe0c809e97b4b6b795f70c364659f372
Showing with 28 additions and 5 deletions.
  1. +0 −3 src/core/geometry/qgsgeometry.cpp
  2. +16 −2 src/core/geometry/qgsgeos.cpp
  3. +12 −0 tests/src/python/test_qgsgeometry.py
@@ -2297,6 +2297,3 @@ QDataStream& operator>>( QDataStream& in, QgsGeometry& geometry )
geometry.fromWkb(( unsigned char* )data, byteArray.size() );
return in;
}



@@ -1083,8 +1083,22 @@ QgsAbstractGeometryV2* QgsGeos::overlay( const QgsAbstractGeometryV2& geom, Over
opGeom.reset( GEOSDifference_r( geosinit.ctxt, mGeos, geosGeom.get() ) );
break;
case UNION:
opGeom.reset( GEOSUnion_r( geosinit.ctxt, mGeos, geosGeom.get() ) );
break;
{
GEOSGeometry *unionGeometry = GEOSUnion_r( geosinit.ctxt, mGeos, geosGeom.get() );

if ( unionGeometry && GEOSGeomTypeId_r( geosinit.ctxt, unionGeometry ) == GEOS_MULTILINESTRING )
{
GEOSGeometry *mergedLines = GEOSLineMerge_r( geosinit.ctxt, unionGeometry );
if ( mergedLines )
{
GEOSGeom_destroy_r( geosinit.ctxt, unionGeometry );
unionGeometry = mergedLines;
}
}

opGeom.reset( unionGeometry );
}
break;
case SYMDIFFERENCE:
opGeom.reset( GEOSSymDifference_r( geosinit.ctxt, mGeos, geosGeom.get() ) );
break;
@@ -1377,5 +1377,17 @@ def testRegression13055(self):
wkt = p.exportToWkt()
assert compareWkt(expWkt, wkt), "testRegression13055 failed: mismatch Expected:\n%s\nGot:\n%s\n" % (expWkt, wkt)

def testRegression13274(self):
""" See http://hub.qgis.org/issues/13274
Testing that two combined linestrings produce another line string if possible
"""
a = QgsGeometry.fromWkt('LineString (0 0, 1 0)')
b = QgsGeometry.fromWkt('LineString (1 0, 2 0)')
c = a.combine(b)

expWkt = 'LineString (0 0, 1 0, 2 0)'
wkt = c.exportToWkt()
assert compareWkt(expWkt, wkt), "testRegression13274 failed: mismatch Expected:\n%s\nGot:\n%s\n" % (expWkt, wkt)

if __name__ == '__main__':
unittest.main()

0 comments on commit ac3f390

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