Skip to content
Permalink
Browse files

support ogc binary operation with more than two operands (fixes #10053)

  • Loading branch information
jef-n committed Oct 26, 2014
1 parent 7e69dbd commit c8a76f8c5c3bfd196bceeebf892c5c07c5598edb
Showing with 20 additions and 11 deletions.
  1. +20 −11 src/core/qgsogcutils.cpp
@@ -1595,25 +1595,37 @@ QgsExpression::NodeBinaryOperator* QgsOgcUtils::nodeBinaryOperatorFromOgcFilter(
}

QDomElement operandElem = element.firstChildElement();
QgsExpression::Node* opLeft = nodeFromOgcFilter( operandElem, errorMessage );
if ( !opLeft )
QgsExpression::Node *expr = nodeFromOgcFilter( operandElem, errorMessage ), *leftOp = expr;
if ( !expr )
{
if ( errorMessage.isEmpty() )
errorMessage = QString( "invalid left operand for '%1' binary operator" ).arg( element.tagName() );
return NULL;
}

operandElem = operandElem.nextSiblingElement();
QgsExpression::Node* opRight = nodeFromOgcFilter( operandElem, errorMessage );
if ( !opRight )
for( operandElem = operandElem.nextSiblingElement(); !operandElem.isNull(); operandElem = operandElem.nextSiblingElement() )
{
QgsExpression::Node* opRight = nodeFromOgcFilter( operandElem, errorMessage );
if ( !opRight )
{
if ( errorMessage.isEmpty() )
errorMessage = QString( "invalid right operand for '%1' binary operator" ).arg( element.tagName() );
delete expr;
return NULL;
}

expr = new QgsExpression::NodeBinaryOperator(( QgsExpression::BinaryOperator ) op, expr, opRight );
}

if( expr == leftOp )
{
if ( errorMessage.isEmpty() )
errorMessage = QString( "invalid right operand for '%1' binary operator" ).arg( element.tagName() );
delete opLeft;
errorMessage = QString( "only one operand for '%1' binary operator" ).arg( element.tagName() );
delete expr;
return NULL;
}

return new QgsExpression::NodeBinaryOperator(( QgsExpression::BinaryOperator ) op, opLeft, opRight );
return dynamic_cast< QgsExpression::NodeBinaryOperator * >( expr );
}


@@ -1843,7 +1855,6 @@ QgsExpression::Node* QgsOgcUtils::nodeIsBetweenFromOgcFilter( QDomElement& eleme
}



QgsExpression::NodeBinaryOperator* QgsOgcUtils::nodePropertyIsNullFromOgcFilter( QDomElement& element, QString& errorMessage )
{
// convert ogc:PropertyIsNull to IS operator with NULL right operand
@@ -1865,8 +1876,6 @@ QgsExpression::NodeBinaryOperator* QgsOgcUtils::nodePropertyIsNullFromOgcFilter(
/////////////////




QDomElement QgsOgcUtils::expressionToOgcFilter( const QgsExpression& exp, QDomDocument& doc, QString* errorMessage )
{
if ( !exp.rootNode() )

0 comments on commit c8a76f8

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