Skip to content
Permalink
Browse files
correct cloning of multi-part geometries with GEOS < 3.0
git-svn-id: http://svn.osgeo.org/qgis/trunk@9469 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
wonder committed Oct 10, 2008
1 parent bc729b3 commit afaeebabe4b5bc698b5746bd5cb815cfb7b77441
Showing with 7 additions and 2 deletions.
  1. +7 −2 src/core/qgsgeometry.cpp
@@ -142,7 +142,11 @@ static GEOSGeometry *createGeosCollection( int typeId, QVector<GEOSGeometry*> ge

static GEOSGeometry *cloneGeosGeom( const GEOSGeometry *geom )
{
if ( GEOSGeomTypeId(( GEOSGeometry * ) geom ) == GEOS_MULTIPOLYGON )
// for GEOS < 3.0 we have own cloning function
// because when cloning multipart geometries they're copied into more general geometry collection instance
int type = GEOSGeomTypeId(( GEOSGeometry * ) geom );

if (type == GEOS_MULTIPOINT || type == GEOS_MULTILINESTRING || type == GEOS_MULTIPOLYGON)
{
QVector<GEOSGeometry *> geoms;

@@ -152,7 +156,7 @@ static GEOSGeometry *cloneGeosGeom( const GEOSGeometry *geom )
for ( int i = 0; i < GEOSGetNumGeometries(( GEOSGeometry * )geom ); ++i )
geoms << GEOSGeom_clone(( GEOSGeometry * ) GEOSGetGeometryN(( GEOSGeometry * ) geom, i ) );

return createGeosCollection( GEOS_MULTIPOLYGON, geoms );
return createGeosCollection( type, geoms );
}
catch ( GEOSException &e )
{
@@ -4508,6 +4512,7 @@ bool QgsGeometry::exportGeosToWkb()
case GEOS_GEOMETRYCOLLECTION: // a collection of heterogeneus geometries
{
// TODO
QgsDebugMsg("geometry collection - not supported");
break;
} // case GEOS_GEOM::GEOS_GEOMETRYCOLLECTION

0 comments on commit afaeeba

Please sign in to comment.