mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-14 00:07:35 -04:00
QgsGeometry::asCollection works also for single-part geometries
git-svn-id: http://svn.osgeo.org/qgis/trunk@10034 c8812cc2-4d05-0410-92ff-de0c093fc19c
This commit is contained in:
parent
59f2eb3879
commit
3ac50201b5
@ -278,7 +278,8 @@ not disjoint with existing polygons of the feature*/
|
||||
|
||||
/** return contents of the geometry as a list of geometries
|
||||
@note added in version 1.1 */
|
||||
QList<QgsGeometry*> asGeometryCollection();
|
||||
// TODO: destruction of created geometries??
|
||||
QList<QgsGeometry*> asGeometryCollection() /Factory/;
|
||||
|
||||
}; // class QgsGeometry
|
||||
|
||||
|
@ -5457,20 +5457,21 @@ QList<QgsGeometry*> QgsGeometry::asGeometryCollection()
|
||||
int type = GEOSGeomTypeId( mGeos );
|
||||
QgsDebugMsg("geom type: "+QString::number(type));
|
||||
|
||||
QList<QgsGeometry*> geomCollection;
|
||||
|
||||
if ( type != GEOS_MULTIPOINT &&
|
||||
type != GEOS_MULTILINESTRING &&
|
||||
type != GEOS_MULTIPOLYGON &&
|
||||
type != GEOS_GEOMETRYCOLLECTION )
|
||||
{
|
||||
// we have a single-part geometry
|
||||
return QList<QgsGeometry*>();
|
||||
// we have a single-part geometry - put there a copy of this one
|
||||
geomCollection.append( new QgsGeometry(*this) );
|
||||
return geomCollection;
|
||||
}
|
||||
|
||||
int count = GEOSGetNumGeometries( mGeos );
|
||||
QgsDebugMsg("geom count: "+QString::number(count));
|
||||
|
||||
QList<QgsGeometry*> geomCollection;
|
||||
|
||||
for ( int i = 0; i < count; ++i )
|
||||
{
|
||||
const GEOSGeometry * geometry = GEOSGetGeometryN( mGeos, i );
|
||||
|
Loading…
x
Reference in New Issue
Block a user