mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-17 00:04:02 -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
|
/** return contents of the geometry as a list of geometries
|
||||||
@note added in version 1.1 */
|
@note added in version 1.1 */
|
||||||
QList<QgsGeometry*> asGeometryCollection();
|
// TODO: destruction of created geometries??
|
||||||
|
QList<QgsGeometry*> asGeometryCollection() /Factory/;
|
||||||
|
|
||||||
}; // class QgsGeometry
|
}; // class QgsGeometry
|
||||||
|
|
||||||
|
@ -5457,20 +5457,21 @@ QList<QgsGeometry*> QgsGeometry::asGeometryCollection()
|
|||||||
int type = GEOSGeomTypeId( mGeos );
|
int type = GEOSGeomTypeId( mGeos );
|
||||||
QgsDebugMsg("geom type: "+QString::number(type));
|
QgsDebugMsg("geom type: "+QString::number(type));
|
||||||
|
|
||||||
|
QList<QgsGeometry*> geomCollection;
|
||||||
|
|
||||||
if ( type != GEOS_MULTIPOINT &&
|
if ( type != GEOS_MULTIPOINT &&
|
||||||
type != GEOS_MULTILINESTRING &&
|
type != GEOS_MULTILINESTRING &&
|
||||||
type != GEOS_MULTIPOLYGON &&
|
type != GEOS_MULTIPOLYGON &&
|
||||||
type != GEOS_GEOMETRYCOLLECTION )
|
type != GEOS_GEOMETRYCOLLECTION )
|
||||||
{
|
{
|
||||||
// we have a single-part geometry
|
// we have a single-part geometry - put there a copy of this one
|
||||||
return QList<QgsGeometry*>();
|
geomCollection.append( new QgsGeometry(*this) );
|
||||||
|
return geomCollection;
|
||||||
}
|
}
|
||||||
|
|
||||||
int count = GEOSGetNumGeometries( mGeos );
|
int count = GEOSGetNumGeometries( mGeos );
|
||||||
QgsDebugMsg("geom count: "+QString::number(count));
|
QgsDebugMsg("geom count: "+QString::number(count));
|
||||||
|
|
||||||
QList<QgsGeometry*> geomCollection;
|
|
||||||
|
|
||||||
for ( int i = 0; i < count; ++i )
|
for ( int i = 0; i < count; ++i )
|
||||||
{
|
{
|
||||||
const GEOSGeometry * geometry = GEOSGetGeometryN( mGeos, i );
|
const GEOSGeometry * geometry = GEOSGetGeometryN( mGeos, i );
|
||||||
|
Loading…
x
Reference in New Issue
Block a user