Skip to content
Permalink
Browse files

SLD support: try to convert OGC Literal to number before using it as …

…string, fix parser error check
  • Loading branch information
brushtyler committed Aug 27, 2012
1 parent 86a20e9 commit 7feb1c3b2ba116cef309a2000f9f53e50f5bac45
Showing with 16 additions and 8 deletions.
  1. +13 −5 src/core/qgsexpression.cpp
  2. +3 −3 src/core/symbology-ng/qgssymbollayerv2utils.cpp
@@ -1948,12 +1948,20 @@ QgsExpression::Node* QgsExpression::NodeLiteral::createFromOgcFilter( QDomElemen
}
else
{
// probably a text/CDATA node, convert its content to string
operand = new QgsExpression::NodeLiteral( childNode.nodeValue() );
}
// probably a text/CDATA node
QVariant value = childNode.nodeValue();

if ( !operand )
continue;
// try to convert the node content to number if possible,
// otherwise let's use it as string
bool ok;
double d = value.toDouble( &ok );
if ( ok )
value = d;

operand = new QgsExpression::NodeLiteral( value );
if ( !operand )
continue;
}

// use the concat operator to merge the ogc:Literal children
if ( !root )
@@ -1922,7 +1922,7 @@ bool QgsSymbolLayerV2Utils::rotationFromSldElement( QDomElement &element, QStrin
QDomElement rotationElem = element.firstChildElement( "Rotation" );
if ( !rotationElem.isNull() )
{
functionFromSldElement( rotationElem, rotationFunc );
return functionFromSldElement( rotationElem, rotationFunc );
}
return true;
}
@@ -1943,7 +1943,7 @@ bool QgsSymbolLayerV2Utils::opacityFromSldElement( QDomElement &element, QString
QDomElement opacityElem = element.firstChildElement( "Opacity" );
if ( !opacityElem.isNull() )
{
functionFromSldElement( opacityElem, alphaFunc );
return functionFromSldElement( opacityElem, alphaFunc );
}
return true;
}
@@ -2086,7 +2086,7 @@ bool QgsSymbolLayerV2Utils::functionFromSldElement( QDomElement &element, QStrin
if ( !expr )
return false;

bool valid = expr->hasParserError();
bool valid = !expr->hasParserError();
if ( !valid )
{
QgsDebugMsg( "parser error: " + expr->parserErrorString() );

0 comments on commit 7feb1c3

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