Index: python/core/qgsgeometry.sip =================================================================== --- python/core/qgsgeometry.sip (revision 13049) +++ python/core/qgsgeometry.sip (working copy) @@ -238,6 +238,10 @@ /** Test for containment of a point (uses GEOS) */ bool contains(QgsPoint* p); + + /** Test for containment with a geometry (uses GEOS) + * @note added in 1.5 */ + bool contains( QgsGeometry* geometry ); /** Returns a buffer region around this geometry having the given width and with a specified number of segments used to approximate curves */ Index: src/core/qgsgeometry.cpp =================================================================== --- src/core/qgsgeometry.cpp (revision 13049) +++ src/core/qgsgeometry.cpp (working copy) @@ -3751,7 +3751,24 @@ return returnval; } +bool QgsGeometry::contains( QgsGeometry* geometry ) +{ + try // geos might throw exception on error + { + // ensure that both geometries have geos geometry + exportWkbToGeos(); + geometry->exportWkbToGeos(); + if ( !mGeos || !geometry->mGeos ) + { + QgsDebugMsg( "GEOS geometry not available!" ); + return false; + } + return GEOSContains( mGeos, geometry->mGeos ); + } + CATCH_GEOS( false ) +} + QString QgsGeometry::exportToWkt() { QgsDebugMsg( "entered." ); Index: src/core/qgsgeometry.h =================================================================== --- src/core/qgsgeometry.h (revision 13049) +++ src/core/qgsgeometry.h (working copy) @@ -276,12 +276,16 @@ /** Test for intersection with a rectangle (uses GEOS) */ bool intersects( const QgsRectangle& r ); - /** Test for intersection with a geoemetry (uses GEOS) */ + /** Test for intersection with a geometry (uses GEOS) */ bool intersects( QgsGeometry* geometry ); /** Test for containment of a point (uses GEOS) */ bool contains( QgsPoint* p ); + /** Test for containment with a geometry (uses GEOS) + * @note added in 1.5 */ + bool contains( QgsGeometry* geometry ); + /** Returns a buffer region around this geometry having the given width and with a specified number of segments used to approximate curves */ QgsGeometry* buffer( double distance, int segments );