25 : mLowerValue( range.lowerBound() )
26 , mUpperValue( range.upperBound() )
28 , mLabel( range.label() )
31 mUuid = !
uuid.isEmpty() ?
uuid : QUuid::createUuid().toString();
35 : mLowerValue( lowerValue )
36 , mUpperValue( upperValue )
41 mUuid = !
uuid.isEmpty() ?
uuid : QUuid::createUuid().toString();
45 : mLowerValue( range.mLowerValue )
46 , mUpperValue( range.mUpperValue )
47 , mSymbol( range.mSymbol ? range.mSymbol->clone() : nullptr )
48 , mLabel( range.mLabel )
49 , mRender( range.mRender )
50 , mUuid( range.mUuid )
135 if ( !
mSymbol || props.value( QStringLiteral(
"attribute" ), QString() ).toString().isEmpty() )
138 QString attrName = props[ QStringLiteral(
"attribute" )].toString();
140 QDomElement ruleElem = doc.createElement( QStringLiteral(
"se:Rule" ) );
142 QDomElement nameElem = doc.createElement( QStringLiteral(
"se:Name" ) );
143 nameElem.appendChild( doc.createTextNode(
mLabel ) );
144 ruleElem.appendChild( nameElem );
146 QDomElement descrElem = doc.createElement( QStringLiteral(
"se:Description" ) );
147 QDomElement titleElem = doc.createElement( QStringLiteral(
"se:Title" ) );
149 titleElem.appendChild( doc.createTextNode( !
mLabel.isEmpty() ?
mLabel : descrStr ) );
150 descrElem.appendChild( titleElem );
151 ruleElem.appendChild( descrElem );
154 QString filterFunc = QStringLiteral(
"\"%1\" %2 %3 AND \"%1\" <= %4" )
155 .arg( attrName.replace(
'\"', QLatin1String(
"\"\"" ) ),
156 firstRange ? QStringLiteral(
">=" ) : QStringLiteral(
">" ),
161 mSymbol->toSld( doc, ruleElem, props );
169 element.appendChild( ruleElem );
179 : mFormat( QStringLiteral(
"%1 - %2" ) )
180 , mReTrailingZeroes(
"[.,]?0*$" )
181 , mReNegativeZero(
"^\\-0(?:[.,]0*)?$" )
186 : mReTrailingZeroes(
"[.,]?0*$" )
187 , mReNegativeZero(
"^\\-0(?:[.,]0*)?$" )
205 return !( *
this == other );
232 QString valueStr = QLocale().toString( value,
'f',
mPrecision );
236 valueStr = valueStr.mid( 1 );
241 QString valueStr = QLocale().toString( value *
mNumberScale,
'f', 0 );
242 if ( valueStr == QLatin1String(
"-0" ) )
244 if ( valueStr != QLatin1String(
"0" ) )
256 return legend.replace( QLatin1String(
"%1" ), lowerStr ).replace( QLatin1String(
"%2" ), upperStr );
261 mFormat = element.attribute( QStringLiteral(
"format" ),
262 element.attribute( QStringLiteral(
"prefix" ), QStringLiteral(
" " ) ) +
"%1" +
263 element.attribute( QStringLiteral(
"separator" ), QStringLiteral(
" - " ) ) +
"%2" +
264 element.attribute( QStringLiteral(
"suffix" ), QStringLiteral(
" " ) )
266 setPrecision( element.attribute( QStringLiteral(
"decimalplaces" ), QStringLiteral(
"4" ) ).toInt() );
267 mTrimTrailingZeroes = element.attribute( QStringLiteral(
"trimtrailingzeroes" ), QStringLiteral(
"false" ) ) == QLatin1String(
"true" );
272 element.setAttribute( QStringLiteral(
"format" ),
mFormat );
273 element.setAttribute( QStringLiteral(
"decimalplaces" ),
mPrecision );
274 element.setAttribute( QStringLiteral(
"trimtrailingzeroes" ),
mTrimTrailingZeroes ? QStringLiteral(
"true" ) : QStringLiteral(
"false" ) );
QgsClassificationRange contains the information about a classification range.
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
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
static bool createFunctionElement(QDomDocument &doc, QDomElement &element, const QString &function)
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)