From b3e9ed7afdb264b959f5e22769cc29c6251b0988 Mon Sep 17 00:00:00 2001 From: wonder Date: Fri, 7 May 2010 08:39:37 +0000 Subject: [PATCH] Added optional geometry parameter when evaluating predicates git-svn-id: http://svn.osgeo.org/qgis/trunk@13433 c8812cc2-4d05-0410-92ff-de0c093fc19c --- python/core/qgssearchtreenode.sip | 4 +++- src/core/qgssearchtreenode.cpp | 20 ++++++++++---------- src/core/qgssearchtreenode.h | 4 +++- 3 files changed, 16 insertions(+), 12 deletions(-) diff --git a/python/core/qgssearchtreenode.sip b/python/core/qgssearchtreenode.sip index 0fd384a25927..a8e093c76dc3 100644 --- a/python/core/qgssearchtreenode.sip +++ b/python/core/qgssearchtreenode.sip @@ -90,7 +90,8 @@ class QgsSearchTreeNode QString makeSearchString(); //! checks whether the node tree is valid against supplied attributes - bool checkAgainst( const QMap& fields, const QMap& attributes ); + //! @note optional geom parameter added in 1.5 + bool checkAgainst( const QMap& fields, const QMap& attributes, QgsGeometry* geom = 0 ); //! checks if there were errors during evaluation bool hasError(); @@ -99,6 +100,7 @@ class QgsSearchTreeNode const QString& errorMsg(); //! wrapper around valueAgainst() + //! @note added in 1.4 bool getValue( QgsSearchTreeValue& value /Out/, QgsSearchTreeNode* node, const QMap& fields, const QMap& attributes, QgsGeometry* geom = 0 ); diff --git a/src/core/qgssearchtreenode.cpp b/src/core/qgssearchtreenode.cpp index c438d9cdba0f..8d58a2346b8b 100644 --- a/src/core/qgssearchtreenode.cpp +++ b/src/core/qgssearchtreenode.cpp @@ -250,7 +250,7 @@ QStringList QgsSearchTreeNode::referencedColumns() } -bool QgsSearchTreeNode::checkAgainst( const QgsFieldMap& fields, const QgsAttributeMap& attributes ) +bool QgsSearchTreeNode::checkAgainst( const QgsFieldMap& fields, const QgsAttributeMap& attributes, QgsGeometry* geom ) { QgsDebugMsgLevel( "checkAgainst: " + makeSearchString(), 2 ); @@ -269,21 +269,21 @@ bool QgsSearchTreeNode::checkAgainst( const QgsFieldMap& fields, const QgsAttrib switch ( mOp ) { case opNOT: - return !mLeft->checkAgainst( fields, attributes ); + return !mLeft->checkAgainst( fields, attributes, geom ); case opAND: - if ( !mLeft->checkAgainst( fields, attributes ) ) + if ( !mLeft->checkAgainst( fields, attributes, geom ) ) return false; - return mRight->checkAgainst( fields, attributes ); + return mRight->checkAgainst( fields, attributes, geom ); case opOR: - if ( mLeft->checkAgainst( fields, attributes ) ) + if ( mLeft->checkAgainst( fields, attributes, geom ) ) return true; - return mRight->checkAgainst( fields, attributes ); + return mRight->checkAgainst( fields, attributes, geom ); case opISNULL: case opISNOTNULL: - if ( !getValue( value1, mLeft, fields, attributes ) ) + if ( !getValue( value1, mLeft, fields, attributes, geom ) ) return false; if ( mOp == opISNULL ) @@ -302,7 +302,7 @@ bool QgsSearchTreeNode::checkAgainst( const QgsFieldMap& fields, const QgsAttrib case opGE: case opLE: - if ( !getValue( value1, mLeft, fields, attributes ) || !getValue( value2, mRight, fields, attributes ) ) + if ( !getValue( value1, mLeft, fields, attributes, geom ) || !getValue( value2, mRight, fields, attributes, geom ) ) return false; if ( value1.isNull() || value2.isNull() ) @@ -329,8 +329,8 @@ bool QgsSearchTreeNode::checkAgainst( const QgsFieldMap& fields, const QgsAttrib case opRegexp: case opLike: { - if ( !getValue( value1, mLeft, fields, attributes ) || - !getValue( value2, mRight, fields, attributes ) ) + if ( !getValue( value1, mLeft, fields, attributes, geom ) || + !getValue( value2, mRight, fields, attributes, geom ) ) return false; // value1 is string to be matched diff --git a/src/core/qgssearchtreenode.h b/src/core/qgssearchtreenode.h index 26e641dc022a..d94b92d07f06 100644 --- a/src/core/qgssearchtreenode.h +++ b/src/core/qgssearchtreenode.h @@ -127,7 +127,8 @@ class CORE_EXPORT QgsSearchTreeNode QString makeSearchString(); //! checks whether the node tree is valid against supplied attributes - bool checkAgainst( const QgsFieldMap& fields, const QgsAttributeMap& attributes ); + //! @note optional geom parameter added in 1.5 + bool checkAgainst( const QgsFieldMap& fields, const QgsAttributeMap& attributes, QgsGeometry* geom = 0 ); //! checks if there were errors during evaluation bool hasError() { return ( !mError.isEmpty() ); } @@ -136,6 +137,7 @@ class CORE_EXPORT QgsSearchTreeNode const QString& errorMsg() { return mError; } //! wrapper around valueAgainst() + //! @note added in 1.4 bool getValue( QgsSearchTreeValue& value, QgsSearchTreeNode* node, const QgsFieldMap& fields, const QgsAttributeMap& attributes, QgsGeometry* geom = 0 );