Skip to content
Permalink
Browse files

fix export from Graduated renderingV2 to SLD, generate valid SLD docs (

…fix #5795):

Description tag must have a child tag,
OnlineResource tag and its child Format tag must have SE namespace,
Filter tag created and never appended to the Rule element exporting from a Graduated rendering,
fix convertion between PropertyIsBetween tag and QgsExpression
  • Loading branch information
brushtyler committed Jun 19, 2012
1 parent 1d6943d commit 6e855d8c1a6d7dac345465520c4b86a7321a3ebe
@@ -689,31 +689,38 @@ QgsExpression::Node* QgsExpression::Node::createFromOgcFilter( QDomElement &elem
else if ( element.localName() == "PropertyIsBetween" )
{
// <ogc:PropertyIsBetween> encode a Range check
QgsExpression::Node *operand = 0, *lowerBound = 0, *upperBound = 0;
QgsExpression::Node *operand = 0, *lowerBound = 0;
QgsExpression::Node *operand2 = 0, *upperBound = 0;

QDomElement operandElem = element.firstChildElement( "LowerBoundary" );
if ( !operandElem.isNull() )
lowerBound = createFromOgcFilter( operandElem, errorMessage );

operandElem = element.firstChildElement( "UpperBoundary" );
if ( !operandElem.isNull() )
upperBound = createFromOgcFilter( operandElem, errorMessage );

// <ogc:expression>
operandElem = element.firstChildElement();
while ( !operandElem.isNull() )
QDomElement operandElem = element.firstChildElement();
while( !operandElem.isNull() )
{
if ( operandElem.localName() != "LowerBoundary" &&
operandElem.localName() != "UpperBoundary" )
if ( operandElem.localName() == "LowerBoundary" )
{
QDomElement lowerBoundElem = operandElem.firstChildElement();
lowerBound = createFromOgcFilter( lowerBoundElem, errorMessage );
}
else if ( operandElem.localName() == "UpperBoundary" )
{
QDomElement upperBoundElem = operandElem.firstChildElement();
upperBound = createFromOgcFilter( upperBoundElem, errorMessage );
}
else
{
// <ogc:expression>
// both operand and operand2 contain the same expression,
// they are respectively compared to lower bound and upper bound
operand = createFromOgcFilter( operandElem, errorMessage );
break;
operand2 = createFromOgcFilter( operandElem, errorMessage );
}

if ( operand && lowerBound && operand2 && upperBound )
break;

operandElem = operandElem.nextSiblingElement();
}

if ( !operand || !lowerBound || !upperBound )
if ( !operand || !lowerBound || !operand2 || !upperBound )
{
if ( operand )
delete operand;
@@ -729,7 +736,7 @@ QgsExpression::Node* QgsExpression::Node::createFromOgcFilter( QDomElement &elem
}

QgsExpression::Node *geOperator = new QgsExpression::NodeBinaryOperator( boGE, operand, lowerBound );
QgsExpression::Node *leOperator = new QgsExpression::NodeBinaryOperator( boLE, operand, upperBound );
QgsExpression::Node *leOperator = new QgsExpression::NodeBinaryOperator( boLE, operand2, upperBound );
return new QgsExpression::NodeBinaryOperator( boAnd, geOperator, leOperator );
}

@@ -97,8 +97,10 @@ void QgsRendererCategoryV2::toSld( QDomDocument &doc, QDomElement &element, QgsS
ruleElem.appendChild( nameElem );

QDomElement descrElem = doc.createElement( "se:Description" );
QDomElement abstractElem = doc.createElement( "se:Abstract" );
QString descrStr = QString( "%1 is '%2'" ).arg( attrName ).arg( mValue.toString() );
descrElem.appendChild( doc.createTextNode( !mLabel.isEmpty() ? mLabel : descrStr ) );
abstractElem.appendChild( doc.createTextNode( !mLabel.isEmpty() ? mLabel : descrStr ) );
descrElem.appendChild( abstractElem );
ruleElem.appendChild( descrElem );

// create the ogc:Filter for the range
@@ -114,8 +114,10 @@ void QgsRendererRangeV2::toSld( QDomDocument &doc, QDomElement &element, QgsStri
ruleElem.appendChild( nameElem );

QDomElement descrElem = doc.createElement( "se:Description" );
QDomElement abstractElem = doc.createElement( "se:Abstract" );
QString descrStr = QString( "range: %1 - %2" ).arg( mLowerValue ).arg( mUpperValue );
descrElem.appendChild( doc.createTextNode( !mLabel.isEmpty() ? mLabel : descrStr ) );
abstractElem.appendChild( doc.createTextNode( !mLabel.isEmpty() ? mLabel : descrStr ) );
descrElem.appendChild( abstractElem );
ruleElem.appendChild( descrElem );

// create the ogc:Filter for the range
@@ -124,6 +126,7 @@ void QgsRendererRangeV2::toSld( QDomDocument &doc, QDomElement &element, QgsStri
.arg( attrName.replace( "\"", "\"\"" ) )
.arg( mLowerValue ).arg( mUpperValue );
QgsSymbolLayerV2Utils::createFunctionElement( doc, filterElem, filterFunc );
ruleElem.appendChild( filterElem );

mSymbol->toSld( doc, ruleElem, props );
}
@@ -2057,12 +2057,12 @@ bool QgsSymbolLayerV2Utils::functionFromSldElement( QDomElement &element, QStrin
void QgsSymbolLayerV2Utils::createOnlineResourceElement( QDomDocument &doc, QDomElement &element,
QString path, QString format )
{
QDomElement onlineResourceElem = doc.createElement( "OnlineResource" );
QDomElement onlineResourceElem = doc.createElement( "se:OnlineResource" );
onlineResourceElem.setAttribute( "xlink:type", "simple" );
onlineResourceElem.setAttribute( "xlink:href", path );
element.appendChild( onlineResourceElem );

QDomElement formatElem = doc.createElement( "Format" );
QDomElement formatElem = doc.createElement( "se:Format" );
formatElem.appendChild( doc.createTextNode( format ) );
element.appendChild( formatElem );
}

0 comments on commit 6e855d8

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