26 : mLowerValue( range.lowerBound() )
27 , mUpperValue( range.upperBound() )
29 , mLabel( range.label() )
32 mUuid = !
uuid.isEmpty() ?
uuid : QUuid::createUuid().toString();
36 : mLowerValue( lowerValue )
37 , mUpperValue( upperValue )
42 mUuid = !
uuid.isEmpty() ?
uuid : QUuid::createUuid().toString();
46 : mLowerValue( range.mLowerValue )
47 , mUpperValue( range.mUpperValue )
48 , mSymbol( range.mSymbol ? range.mSymbol->clone() : nullptr )
49 , mLabel( range.mLabel )
50 , mRender( range.mRender )
51 , mUuid( range.mUuid )
138 toSld( doc, element, props.value( QStringLiteral(
"attribute" ), QString() ).toString(), context, firstRange );
143 if ( !
mSymbol || classAttribute.isEmpty() )
146 QString attrName = classAttribute;
148 QDomElement ruleElem = doc.createElement( QStringLiteral(
"se:Rule" ) );
150 QDomElement nameElem = doc.createElement( QStringLiteral(
"se:Name" ) );
151 nameElem.appendChild( doc.createTextNode(
mLabel ) );
152 ruleElem.appendChild( nameElem );
154 QDomElement descrElem = doc.createElement( QStringLiteral(
"se:Description" ) );
155 QDomElement titleElem = doc.createElement( QStringLiteral(
"se:Title" ) );
157 titleElem.appendChild( doc.createTextNode( !
mLabel.isEmpty() ?
mLabel : descrStr ) );
158 descrElem.appendChild( titleElem );
159 ruleElem.appendChild( descrElem );
162 QString filterFunc = QStringLiteral(
"\"%1\" %2 %3 AND \"%1\" <= %4" )
163 .arg( attrName.replace(
'\"', QLatin1String(
"\"\"" ) ),
164 firstRange ? QStringLiteral(
">=" ) : QStringLiteral(
">" ),
169 mSymbol->toSld( doc, ruleElem, context );
177 element.appendChild( ruleElem );
188 : mFormat( QStringLiteral(
"%1 - %2" ) )
189 , mReTrailingZeroes(
"[.,]?0*$" )
190 , mReNegativeZero(
"^\\-0(?:[.,]0*)?$" )
195 : mReTrailingZeroes(
"[.,]?0*$" )
196 , mReNegativeZero(
"^\\-0(?:[.,]0*)?$" )
214 return !( *
this == other );
241 QString valueStr = QLocale().toString( value,
'f',
mPrecision );
245 valueStr = valueStr.mid( 1 );
250 QString valueStr = QLocale().toString( value *
mNumberScale,
'f', 0 );
251 if ( valueStr == QLatin1String(
"-0" ) )
253 if ( valueStr != QLatin1String(
"0" ) )
265 return legend.replace( QLatin1String(
"%1" ), lowerStr ).replace( QLatin1String(
"%2" ), upperStr );
270 mFormat = element.attribute( QStringLiteral(
"format" ),
271 element.attribute( QStringLiteral(
"prefix" ), QStringLiteral(
" " ) ) +
"%1" +
272 element.attribute( QStringLiteral(
"separator" ), QStringLiteral(
" - " ) ) +
"%2" +
273 element.attribute( QStringLiteral(
"suffix" ), QStringLiteral(
" " ) )
275 setPrecision( element.attribute( QStringLiteral(
"decimalplaces" ), QStringLiteral(
"4" ) ).toInt() );
276 mTrimTrailingZeroes = element.attribute( QStringLiteral(
"trimtrailingzeroes" ), QStringLiteral(
"false" ) ) == QLatin1String(
"true" );
281 element.setAttribute( QStringLiteral(
"format" ),
mFormat );
282 element.setAttribute( QStringLiteral(
"decimalplaces" ),
mPrecision );
283 element.setAttribute( QStringLiteral(
"trimtrailingzeroes" ),
mTrimTrailingZeroes ? QStringLiteral(
"true" ) : QStringLiteral(
"false" ) );
Contains the information about a classification range.
Represents a value range for a QgsGraduatedSymbolRenderer.
void setUpperValue(double upperValue)
Sets the upper bound of the range.
QgsRendererRange()=default
QString label() const
Returns the label used for the range.
void setSymbol(QgsSymbol *s)
Sets the symbol used for the range.
std::unique_ptr< QgsSymbol > mSymbol
Q_DECL_DEPRECATED void toSld(QDomDocument &doc, QDomElement &element, QVariantMap props, bool firstRange=false) const
Creates a DOM element representing the range in SLD format.
QgsRendererRange & operator=(QgsRendererRange range)
QgsSymbol * symbol() const
Returns the symbol used for the range.
void setLabel(const QString &label)
Sets the label used for the range.
bool renderState() const
Returns true if the range should be rendered.
void setRenderState(bool render)
Sets whether the range should be rendered.
QString dump() const
Dumps a string representation of the range.
double upperValue() const
Returns the upper bound of the range.
void setLowerValue(double lowerValue)
Sets the lower bound of the range.
QString uuid() const
Returns the unique identifier for this range.
double lowerValue() const
Returns the lower bound of the range.
bool operator<(const QgsRendererRange &other) const
Holds SLD export options and other information related to SLD export of a QGIS layer style.
void setExtraProperties(const QVariantMap &properties)
Sets the open ended set of properties that can drive/inform the SLD encoding.
static Q_DECL_DEPRECATED bool createFunctionElement(QDomDocument &doc, QDomElement &element, const QString &function)
Creates an OGC function element.
static bool hasSldSymbolizer(const QDomElement &element)
Returns true if a DOM element contains an SLD Symbolizer element.
Abstract base class for all rendered symbols.
QString qgsDoubleToString(double a, int precision=17)
Returns a string representation of a double.
bool qgsDoubleNear(double a, double b, double epsilon=4 *std::numeric_limits< double >::epsilon())
Compare two doubles (but allow some difference)