File tree 3 files changed +26
-1
lines changed
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*/
238
238
239
239
/** Test for containment of a point (uses GEOS) */
240
240
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 );
241
245
242
246
/** Returns a buffer region around this geometry having the given width and with a specified number
243
247
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 )
3751
3751
return returnval;
3752
3752
}
3753
3753
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
+ }
3754
3771
3755
3772
QString QgsGeometry::exportToWkt ()
3756
3773
{
Original file line number Diff line number Diff line change @@ -276,12 +276,16 @@ class CORE_EXPORT QgsGeometry
276
276
277
277
/* * Test for intersection with a rectangle (uses GEOS) */
278
278
bool intersects ( const QgsRectangle& r );
279
- /* * Test for intersection with a geoemetry (uses GEOS) */
279
+ /* * Test for intersection with a geometry (uses GEOS) */
280
280
bool intersects ( QgsGeometry* geometry );
281
281
282
282
/* * Test for containment of a point (uses GEOS) */
283
283
bool contains ( QgsPoint* p );
284
284
285
+ /* * Test for containment with a geometry (uses GEOS)
286
+ * @note added in 1.5 */
287
+ bool contains ( QgsGeometry* geometry );
288
+
285
289
/* * Returns a buffer region around this geometry having the given width and with a specified number
286
290
of segments used to approximate curves */
287
291
QgsGeometry* buffer ( double distance, int segments );
You can’t perform that action at this time.
0 commit comments