mirror of
https://github.com/qgis/QGIS.git
synced 2025-06-19 00:02:48 -04:00
implemented QgsGeometry::asGeometryCollection()
git-svn-id: http://svn.osgeo.org/qgis/trunk@10026 c8812cc2-4d05-0410-92ff-de0c093fc19c
This commit is contained in:
parent
071f3cc5cd
commit
55d52f76ff
@ -276,5 +276,9 @@ not disjoint with existing polygons of the feature*/
|
|||||||
if wkbType is WKBPolygon, otherwise an empty list */
|
if wkbType is WKBPolygon, otherwise an empty list */
|
||||||
QgsMultiPolygon asMultiPolygon();
|
QgsMultiPolygon asMultiPolygon();
|
||||||
|
|
||||||
|
/** return contents of the geometry as a list of geometries
|
||||||
|
@note added in version 1.1 */
|
||||||
|
QList<QgsGeometry*> asGeometryCollection();
|
||||||
|
|
||||||
}; // class QgsGeometry
|
}; // class QgsGeometry
|
||||||
|
|
||||||
|
@ -5443,3 +5443,39 @@ QgsGeometry* QgsGeometry::symDifference( QgsGeometry* geometry )
|
|||||||
}
|
}
|
||||||
CATCH_GEOS( 0 )
|
CATCH_GEOS( 0 )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QList<QgsGeometry*> QgsGeometry::asGeometryCollection()
|
||||||
|
{
|
||||||
|
if ( mGeos == NULL )
|
||||||
|
{
|
||||||
|
exportWkbToGeos();
|
||||||
|
if ( mGeos == NULL )
|
||||||
|
return QList<QgsGeometry*>();
|
||||||
|
}
|
||||||
|
|
||||||
|
int type = GEOSGeomTypeId( mGeos );
|
||||||
|
QgsDebugMsg("geom type: "+QString::number(type));
|
||||||
|
|
||||||
|
if ( type != GEOS_MULTIPOINT &&
|
||||||
|
type != GEOS_MULTILINESTRING &&
|
||||||
|
type != GEOS_MULTIPOLYGON &&
|
||||||
|
type != GEOS_GEOMETRYCOLLECTION )
|
||||||
|
{
|
||||||
|
// we have a single-part geometry
|
||||||
|
return QList<QgsGeometry*>();
|
||||||
|
}
|
||||||
|
|
||||||
|
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 );
|
||||||
|
geomCollection.append( fromGeosGeom( GEOSGeom_clone(geometry) ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
return geomCollection;
|
||||||
|
}
|
||||||
|
@ -318,6 +318,10 @@ class CORE_EXPORT QgsGeometry
|
|||||||
if wkbType is WKBPolygon, otherwise an empty list */
|
if wkbType is WKBPolygon, otherwise an empty list */
|
||||||
QgsMultiPolygon asMultiPolygon();
|
QgsMultiPolygon asMultiPolygon();
|
||||||
|
|
||||||
|
/** return contents of the geometry as a list of geometries
|
||||||
|
@note added in version 1.1 */
|
||||||
|
QList<QgsGeometry*> asGeometryCollection();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// Private variables
|
// Private variables
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user