Skip to content
Permalink
Browse files

Added missing QgsGeometry::contains predicate.

Contributed by Jeremy Palmer (#2560).


git-svn-id: http://svn.osgeo.org/qgis/trunk@13065 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
wonder
wonder committed Mar 17, 2010
1 parent 74141c9 commit 24b1c0b14e7123d1fd8c04f3a07c439c2b640451
Showing with 26 additions and 1 deletion.
  1. +4 −0 python/core/qgsgeometry.sip
  2. +17 −0 src/core/qgsgeometry.cpp
  3. +5 −1 src/core/qgsgeometry.h
@@ -238,6 +238,10 @@ not disjoint with existing polygons of the feature*/

/** 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 */
@@ -3751,6 +3751,23 @@ bool QgsGeometry::contains( QgsPoint* p )
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()
{
@@ -276,12 +276,16 @@ class CORE_EXPORT QgsGeometry

/** 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 );

0 comments on commit 24b1c0b

Please sign in to comment.
You can’t perform that action at this time.