Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
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 afaeeba
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/core/qgsgeometry.cpp
Expand Up @@ -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;

Expand All @@ -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 )
{
Expand Down Expand Up @@ -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

Expand Down

0 comments on commit afaeeba

Please sign in to comment.