Skip to content
Permalink
Browse files

fix for #11863

when a unary-minus is encountered, add a minus to the operand
  • Loading branch information
rduivenvoorde committed Apr 3, 2015
1 parent 6122a9f commit a2a7a82e0c5ddfd26885d52c4d12bf4f68777c6c
Showing with 17 additions and 6 deletions.
  1. +17 −6 src/core/qgsogcutils.cpp
@@ -1931,27 +1931,38 @@ QDomElement QgsOgcUtils::expressionNodeToOgcFilter( const QgsExpression::Node* n

QDomElement QgsOgcUtils::expressionUnaryOperatorToOgcFilter( const QgsExpression::NodeUnaryOperator* node, QDomDocument& doc, QString& errorMessage )
{

QDomElement operandElem = expressionNodeToOgcFilter( node->operand(), doc, errorMessage );
if ( !errorMessage.isEmpty() )
return QDomElement();

QDomElement uoElem;
switch ( node->op() )
{
case QgsExpression::uoMinus:
uoElem = doc.createElement( "ogc:Literal" );
uoElem.appendChild( doc.createTextNode( "-" ) );
if ( node->operand()->nodeType() == QgsExpression::ntLiteral )
{
// operand expression already created a Literal node:
// take the literal value, prepend - and remove old literal node
uoElem.appendChild( doc.createTextNode( "-" + operandElem.text() ) );
doc.removeChild(operandElem);
}
else // not sure if this will ever happen
{
uoElem.appendChild( doc.createTextNode( "-" ) );
}
break;
case QgsExpression::uoNot:
uoElem = doc.createElement( "ogc:Not" );
uoElem.appendChild( operandElem );
break;

default:
errorMessage = QString( "Unary operator %1 not implemented yet" ).arg( QgsExpression::UnaryOperatorText[node->op()] );
return QDomElement();
}

QDomElement operandElem = expressionNodeToOgcFilter( node->operand(), doc, errorMessage );
if ( !errorMessage.isEmpty() )
return QDomElement();

uoElem.appendChild( operandElem );
return uoElem;
}

0 comments on commit a2a7a82

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