Skip to content
Permalink
Browse files

Fix first range when exporting graduated renderer to sld (fix #15212)

  • Loading branch information
nyalldawson committed Jul 4, 2016
1 parent e102111 commit 5c270ebeb0aaaaaf03c24e7d2379c89ebee7b895
@@ -29,7 +29,14 @@ class QgsRendererRangeV2
// debugging
QString dump() const;

void toSld( QDomDocument& doc, QDomElement &element, QgsStringMap props ) const;
/** Creates a DOM element representing the range in SLD format.
* @param doc DOM document
* @param element destination DOM element
* @param props graduated renderer properties
* @param firstRange set to true if the range is the first range, where the lower value uses a <= test
* rather than a < test.
*/
void toSld( QDomDocument& doc, QDomElement &element, QgsStringMap props, bool firstRange = false ) const;

protected:
// for cpy+swap idiom
@@ -141,7 +141,7 @@ QString QgsRendererRangeV2::dump() const
return QString( "%1 - %2::%3::%4\n" ).arg( mLowerValue ).arg( mUpperValue ).arg( mLabel, mSymbol.data() ? mSymbol->dump() : "(no symbol)" );
}

void QgsRendererRangeV2::toSld( QDomDocument &doc, QDomElement &element, QgsStringMap props ) const
void QgsRendererRangeV2::toSld( QDomDocument &doc, QDomElement &element, QgsStringMap props, bool firstRange ) const
{
if ( !mSymbol.data() || props.value( "attribute", "" ).isEmpty() )
return;
@@ -163,8 +163,9 @@ void QgsRendererRangeV2::toSld( QDomDocument &doc, QDomElement &element, QgsStri
ruleElem.appendChild( descrElem );

// create the ogc:Filter for the range
QString filterFunc = QString( "%1 > %2 AND %1 <= %3" )
QString filterFunc = QString( "%1 %2 %3 AND %1 <= %4" )
.arg( attrName.replace( '\"', "\"\"" ),
firstRange ? ">=" : ">",
qgsDoubleToString( mLowerValue ),
qgsDoubleToString( mUpperValue ) );
QgsSymbolLayerV2Utils::createFunctionElement( doc, ruleElem, filterFunc );
@@ -569,10 +570,12 @@ void QgsGraduatedSymbolRendererV2::toSld( QDomDocument& doc, QDomElement &elemen
props[ "scale" ] = mSizeScale->expression();

// create a Rule for each range
bool first = true;
for ( QgsRangeList::const_iterator it = mRanges.constBegin(); it != mRanges.constEnd(); ++it )
{
QgsStringMap catProps( props );
it->toSld( doc, element, catProps );
it->toSld( doc, element, catProps, first );
first = false;
}
}

@@ -56,7 +56,14 @@ class CORE_EXPORT QgsRendererRangeV2
// debugging
QString dump() const;

void toSld( QDomDocument& doc, QDomElement &element, QgsStringMap props ) const;
/** Creates a DOM element representing the range in SLD format.
* @param doc DOM document
* @param element destination DOM element
* @param props graduated renderer properties
* @param firstRange set to true if the range is the first range, where the lower value uses a <= test
* rather than a < test.
*/
void toSld( QDomDocument& doc, QDomElement &element, QgsStringMap props, bool firstRange = false ) const;

protected:
double mLowerValue, mUpperValue;

0 comments on commit 5c270eb

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