File tree Expand file tree Collapse file tree 3 files changed +26
-1
lines changed
Expand file tree Collapse file tree 3 files changed +26
-1
lines changed Original file line number Diff line number Diff line change @@ -238,6 +238,10 @@ not disjoint with existing polygons of the feature*/
238238
239239 /** Test for containment of a point (uses GEOS) */
240240 bool contains(QgsPoint* p);
241+
242+ /** Test for containment with a geometry (uses GEOS)
243+ * @note added in 1.5 */
244+ bool contains( QgsGeometry* geometry );
241245
242246 /** Returns a buffer region around this geometry having the given width and with a specified number
243247 of segments used to approximate curves */
Original file line number Diff line number Diff line change @@ -3751,6 +3751,23 @@ bool QgsGeometry::contains( QgsPoint* p )
37513751 return returnval;
37523752}
37533753
3754+ bool QgsGeometry::contains ( QgsGeometry* geometry )
3755+ {
3756+ try // geos might throw exception on error
3757+ {
3758+ // ensure that both geometries have geos geometry
3759+ exportWkbToGeos ();
3760+ geometry->exportWkbToGeos ();
3761+
3762+ if ( !mGeos || !geometry->mGeos )
3763+ {
3764+ QgsDebugMsg ( " GEOS geometry not available!" );
3765+ return false ;
3766+ }
3767+ return GEOSContains ( mGeos , geometry->mGeos );
3768+ }
3769+ CATCH_GEOS ( false )
3770+ }
37543771
37553772QString QgsGeometry::exportToWkt ()
37563773{
Original file line number Diff line number Diff line change @@ -276,12 +276,16 @@ class CORE_EXPORT QgsGeometry
276276
277277 /* * Test for intersection with a rectangle (uses GEOS) */
278278 bool intersects ( const QgsRectangle& r );
279- /* * Test for intersection with a geoemetry (uses GEOS) */
279+ /* * Test for intersection with a geometry (uses GEOS) */
280280 bool intersects ( QgsGeometry* geometry );
281281
282282 /* * Test for containment of a point (uses GEOS) */
283283 bool contains ( QgsPoint* p );
284284
285+ /* * Test for containment with a geometry (uses GEOS)
286+ * @note added in 1.5 */
287+ bool contains ( QgsGeometry* geometry );
288+
285289 /* * Returns a buffer region around this geometry having the given width and with a specified number
286290 of segments used to approximate curves */
287291 QgsGeometry* buffer ( double distance, int segments );
You can’t perform that action at this time.
0 commit comments