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
This commit is contained in:
wonder 2010-03-17 09:25:55 +00:00
parent 74141c9288
commit 24b1c0b14e
3 changed files with 26 additions and 1 deletions

View File

@ -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 */

View File

@ -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()
{

View File

@ -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 );