26using namespace Qt::StringLiterals;
35 mUuid = !
uuid.isEmpty() ?
uuid : QUuid::createUuid().toString();
45 mUuid = !
uuid.isEmpty() ?
uuid : QUuid::createUuid().toString();
144 toSld( doc, element, props.value( u
"attribute"_s, QString() ).toString(), context, firstRange );
149 if ( !
mSymbol || classAttribute.isEmpty() )
152 QString attrName = classAttribute;
154 QDomElement ruleElem = doc.createElement( u
"se:Rule"_s );
156 QDomElement nameElem = doc.createElement( u
"se:Name"_s );
157 nameElem.appendChild( doc.createTextNode(
mLabel ) );
158 ruleElem.appendChild( nameElem );
160 QDomElement descrElem = doc.createElement( u
"se:Description"_s );
161 QDomElement titleElem = doc.createElement( u
"se:Title"_s );
163 titleElem.appendChild( doc.createTextNode( !
mLabel.isEmpty() ?
mLabel : descrStr ) );
164 descrElem.appendChild( titleElem );
165 ruleElem.appendChild( descrElem );
168 QString filterFunc = u
"\"%1\" %2 %3 AND \"%1\" <= %4"_s
169 .arg( attrName.replace(
'\"',
"\"\""_L1 ),
170 firstRange ? u
">="_s : u
">"_s,
175 mSymbol->toSld( doc, ruleElem, context );
183 element.appendChild( ruleElem );
220 return !( *
this == other );
247 QString valueStr = QLocale().toString( value,
'f',
mPrecision );
251 valueStr = valueStr.mid( 1 );
256 QString valueStr = QLocale().toString( value *
mNumberScale,
'f', 0 );
257 if ( valueStr ==
"-0"_L1 )
259 if ( valueStr !=
"0"_L1 )
271 return legend.replace(
"%1"_L1, lowerStr ).replace(
"%2"_L1, upperStr );
276 mFormat = element.attribute( u
"format"_s,
277 element.attribute( u
"prefix"_s, u
" "_s ) +
"%1" +
278 element.attribute( u
"separator"_s, u
" - "_s ) +
"%2" +
279 element.attribute( u
"suffix"_s, u
" "_s )
281 setPrecision( element.attribute( u
"decimalplaces"_s, u
"4"_s ).toInt() );
282 mTrimTrailingZeroes = element.attribute( u
"trimtrailingzeroes"_s, u
"false"_s ) ==
"true"_L1;
287 element.setAttribute( u
"format"_s,
mFormat );
288 element.setAttribute( u
"decimalplaces"_s,
mPrecision );
289 element.setAttribute( u
"trimtrailingzeroes"_s,
mTrimTrailingZeroes ? u
"true"_s : u
"false"_s );
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).