[QGIS Commit] r10034 - in trunk/qgis: python/core src/core
svn_qgis at osgeo.org
svn_qgis at osgeo.org
Tue Jan 27 07:44:59 EST 2009
Author: wonder
Date: 2009-01-27 07:44:59 -0500 (Tue, 27 Jan 2009)
New Revision: 10034
Modified:
trunk/qgis/python/core/qgsgeometry.sip
trunk/qgis/src/core/qgsgeometry.cpp
Log:
QgsGeometry::asCollection works also for single-part geometries
Modified: trunk/qgis/python/core/qgsgeometry.sip
===================================================================
--- trunk/qgis/python/core/qgsgeometry.sip 2009-01-27 11:06:10 UTC (rev 10033)
+++ trunk/qgis/python/core/qgsgeometry.sip 2009-01-27 12:44:59 UTC (rev 10034)
@@ -278,7 +278,8 @@
/** 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
Modified: trunk/qgis/src/core/qgsgeometry.cpp
===================================================================
--- trunk/qgis/src/core/qgsgeometry.cpp 2009-01-27 11:06:10 UTC (rev 10033)
+++ trunk/qgis/src/core/qgsgeometry.cpp 2009-01-27 12:44:59 UTC (rev 10034)
@@ -5457,20 +5457,21 @@
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 );
More information about the QGIS-commit
mailing list