Skip to content

Commit 092a1bf

Browse files
author
mhugent
committed
Merge linestrings together in union operation. Otherwise geos would create a multilinestring containing the linestrings
git-svn-id: http://svn.osgeo.org/qgis/trunk@10869 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent 6f8f05b commit 092a1bf

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

src/core/qgsgeometry.cpp

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5448,7 +5448,20 @@ QgsGeometry* QgsGeometry::combine( QgsGeometry* geometry )
54485448

54495449
try
54505450
{
5451-
return fromGeosGeom( GEOSUnion( mGeos, geometry->mGeos ) );
5451+
GEOSGeometry* unionGeom = GEOSUnion( mGeos, geometry->mGeos );
5452+
QGis::WkbType thisGeomType = wkbType();
5453+
QGis::WkbType otherGeomType = geometry->wkbType();
5454+
if( (thisGeomType == QGis::WKBLineString || thisGeomType == QGis::WKBLineString25D) \
5455+
&& (otherGeomType == QGis::WKBLineString || otherGeomType == QGis::WKBLineString25D) )
5456+
{
5457+
GEOSGeometry* mergedGeom = GEOSLineMerge(unionGeom);
5458+
if(mergedGeom)
5459+
{
5460+
GEOSGeom_destroy(unionGeom);
5461+
unionGeom = mergedGeom;
5462+
}
5463+
}
5464+
return fromGeosGeom(unionGeom);
54525465
}
54535466
CATCH_GEOS( new QgsGeometry( *this ) ) //return this geometry if union not possible
54545467
}

0 commit comments

Comments
 (0)