[QGIS Commit] r13065 - in trunk/qgis: python/core src/core
svn_qgis at osgeo.org
svn_qgis at osgeo.org
Wed Mar 17 05:25:56 EDT 2010
Author: wonder
Date: 2010-03-17 05:25:55 -0400 (Wed, 17 Mar 2010)
New Revision: 13065
Modified:
trunk/qgis/python/core/qgsgeometry.sip
trunk/qgis/src/core/qgsgeometry.cpp
trunk/qgis/src/core/qgsgeometry.h
Log:
Added missing QgsGeometry::contains predicate.
Contributed by Jeremy Palmer (#2560).
Modified: trunk/qgis/python/core/qgsgeometry.sip
===================================================================
--- trunk/qgis/python/core/qgsgeometry.sip 2010-03-16 21:42:28 UTC (rev 13064)
+++ trunk/qgis/python/core/qgsgeometry.sip 2010-03-17 09:25:55 UTC (rev 13065)
@@ -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 */
Modified: trunk/qgis/src/core/qgsgeometry.cpp
===================================================================
--- trunk/qgis/src/core/qgsgeometry.cpp 2010-03-16 21:42:28 UTC (rev 13064)
+++ trunk/qgis/src/core/qgsgeometry.cpp 2010-03-17 09:25:55 UTC (rev 13065)
@@ -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." );
Modified: trunk/qgis/src/core/qgsgeometry.h
===================================================================
--- trunk/qgis/src/core/qgsgeometry.h 2010-03-16 21:42:28 UTC (rev 13064)
+++ trunk/qgis/src/core/qgsgeometry.h 2010-03-17 09:25:55 UTC (rev 13065)
@@ -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 );
More information about the QGIS-commit
mailing list