Skip to content
Permalink
Browse files

Merge pull request #1975 from rduivenvoorde/sldfix_11863

Fixes #11863 (invalid SLD with negative values)
  • Loading branch information
wonder-sk committed May 4, 2015
2 parents 72eb1aa + 51c5931 commit f800ac635b9f98d53becb721a1fd8f27c233a55c
Showing with 18 additions and 6 deletions.
  1. +18 −6 src/core/qgsogcutils.cpp
@@ -1931,27 +1931,39 @@ 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
{
errorMessage = QString( "This use of unary operator not implemented yet" );
return QDomElement();
}
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 f800ac6

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