QGIS API Documentation 3.41.0-Master (45a0abf3bec)
|
QgsClassificationMethod is an abstract class for implementations of classification methods. More...
#include <qgsclassificationmethod.h>
Public Types | |
enum | ClassPosition { LowerBound , Inner , UpperBound } |
Defines the class position. More... | |
typedef QFlags< MethodProperty > | MethodProperties |
enum | MethodProperty { NoFlag = 0 , ValuesNotRequired = 1 << 1 , SymmetricModeAvailable = 1 << 2 , IgnoresClassCount = 1 << 3 } |
Flags for the classification method. More... | |
Public Member Functions | |
QgsClassificationMethod (MethodProperties properties=NoFlag, int codeComplexity=1) | |
Creates a classification method. | |
virtual | ~QgsClassificationMethod () |
Q_DECL_DEPRECATED QList< QgsClassificationRange > | classes (const QgsVectorLayer *layer, const QString &expression, int nclasses) |
This will calculate the classes for a given layer to define the classes. | |
QList< QgsClassificationRange > | classes (const QList< double > &values, int nclasses) |
This will calculate the classes for a list of values. | |
QList< QgsClassificationRange > | classes (double minimum, double maximum, int nclasses) |
This will calculate the classes for defined bounds without any values. | |
QList< QgsClassificationRange > | classesV2 (const QgsVectorLayer *layer, const QString &expression, int nclasses, QString &error) |
This will calculate the classes for a given layer to define the classes. | |
virtual QgsClassificationMethod * | clone () const =0 |
Returns a clone of the method. | |
int | codeComplexity () const |
Code complexity as the exponent in Big O notation. | |
QgsClassificationMethod::MethodProperties | flags () const |
Returns the classification flags. | |
virtual QIcon | icon () const |
The icon of the method. | |
virtual QString | id () const =0 |
The id of the method as saved in the project, must be unique in registry. | |
QString | labelFormat () const |
Returns the format of the label for the classes. | |
QString | labelForRange (const QgsRendererRange &range, ClassPosition position=Inner) const |
Returns the label for a range. | |
virtual QString | labelForRange (double lowerValue, double upperValue, ClassPosition position=Inner) const |
Returns the label for a range. | |
int | labelPrecision () const |
Returns the precision for the formatting of the labels. | |
bool | labelTrimTrailingZeroes () const |
Returns if the trailing 0 are trimmed in the label. | |
virtual QString | name () const =0 |
The readable and translate name of the method. | |
const QgsProcessingParameterDefinition * | parameterDefinition (const QString ¶meterName) const |
Returns the parameter from its name. | |
QgsProcessingParameterDefinitions | parameterDefinitions () const |
Returns the list of parameters. | |
QVariantMap | parameterValues () const |
Returns the values of the processing parameters. | |
virtual void | readXml (const QDomElement &element, const QgsReadWriteContext &context) |
Reads extra information to apply it to the method. | |
QDomElement | save (QDomDocument &doc, const QgsReadWriteContext &context) const |
Saves the method to a DOM element and return it. | |
void | setLabelFormat (const QString &format) |
Defines the format of the labels for the classes, using %1 and %2 for the bounds. | |
void | setLabelPrecision (int labelPrecision) |
Defines the precision for the formatting of the labels. | |
void | setLabelTrimTrailingZeroes (bool trimTrailingZeroes) |
Defines if the trailing 0 are trimmed in the label. | |
void | setParameterValues (const QVariantMap &values) |
Defines the values of the additional parameters. | |
void | setSymmetricMode (bool enabled, double symmetryPoint=0, bool symmetryAstride=false) |
Defines if the symmetric mode is enables and configures its parameters. | |
bool | symmetricModeAvailable () const |
Returns if the method supports symmetric calculation. | |
bool | symmetricModeEnabled () const |
Returns if the symmetric mode is enabled. | |
bool | symmetryAstride () const |
Returns if the symmetric mode is astride if true , it will remove the symmetry point break so that the 2 classes form only one. | |
double | symmetryPoint () const |
Returns the symmetry point for symmetric mode. | |
virtual bool | valuesRequired () const |
Returns if the method requires values to calculate the classes If not, bounds are sufficient. | |
virtual void | writeXml (QDomElement &element, const QgsReadWriteContext &context) const |
Writes extra information about the method. | |
Static Public Member Functions | |
static QgsClassificationMethod * | create (const QDomElement &element, const QgsReadWriteContext &context) |
Reads the DOM element and return a new classification method from it. | |
static void | makeBreaksSymmetric (QList< double > &breaks, double symmetryPoint, bool astride) |
Remove the breaks that are above the existing opposite sign classes to keep colors symmetrically balanced around symmetryPoint Does not put a break on the symmetryPoint. | |
static QList< double > | rangesToBreaks (const QList< QgsClassificationRange > &classes) |
Transforms a list of classes to a list of breaks. | |
Static Public Attributes | |
static const int | MAX_PRECISION = 15 |
static const int | MIN_PRECISION = -6 |
Protected Member Functions | |
void | addParameter (QgsProcessingParameterDefinition *definition) |
Add a parameter to the method. | |
void | copyBase (QgsClassificationMethod *c) const |
Copy the parameters (shall be used in clone implementation) | |
QString | formatNumber (double value) const |
Format the number according to label properties. | |
QgsClassificationMethod is an abstract class for implementations of classification methods.
Definition at line 88 of file qgsclassificationmethod.h.
typedef QFlags< MethodProperty > QgsClassificationMethod::MethodProperties |
Definition at line 120 of file qgsclassificationmethod.h.
Defines the class position.
Enumerator | |
---|---|
LowerBound | The class is at the lower bound. |
Inner | The class is not at a bound. |
UpperBound | The class is at the upper bound. |
Definition at line 124 of file qgsclassificationmethod.h.
Flags for the classification method.
Definition at line 113 of file qgsclassificationmethod.h.
|
explicit |
Creates a classification method.
properties | The properties of the implemented method |
codeComplexity | as the exponent in the big O notation |
Definition at line 41 of file qgsclassificationmethod.cpp.
|
virtual |
Definition at line 48 of file qgsclassificationmethod.cpp.
|
protected |
Add a parameter to the method.
The paramaeter is a processing parameter which will allow its configuration in the GUI.
Definition at line 182 of file qgsclassificationmethod.cpp.
QList< QgsClassificationRange > QgsClassificationMethod::classes | ( | const QgsVectorLayer * | layer, |
const QString & | expression, | ||
int | nclasses | ||
) |
This will calculate the classes for a given layer to define the classes.
layer | The vector layer |
expression | The name of the field on which the classes are calculated |
nclasses | The number of classes to be returned |
Definition at line 210 of file qgsclassificationmethod.cpp.
QList< QgsClassificationRange > QgsClassificationMethod::classes | ( | const QList< double > & | values, |
int | nclasses | ||
) |
This will calculate the classes for a list of values.
values | The list of values |
nclasses | The number of classes to be returned |
Definition at line 258 of file qgsclassificationmethod.cpp.
QList< QgsClassificationRange > QgsClassificationMethod::classes | ( | double | minimum, |
double | maximum, | ||
int | nclasses | ||
) |
This will calculate the classes for defined bounds without any values.
minimum | The minimum value for the breaks |
maximum | The maximum value for the breaks |
nclasses | The number of classes to be returned |
Definition at line 274 of file qgsclassificationmethod.cpp.
QList< QgsClassificationRange > QgsClassificationMethod::classesV2 | ( | const QgsVectorLayer * | layer, |
const QString & | expression, | ||
int | nclasses, | ||
QString & | error | ||
) |
This will calculate the classes for a given layer to define the classes.
layer | The vector layer |
expression | The name of the field on which the classes are calculated |
nclasses | The number of classes to be returned |
error | will be set to error string if an error occurred while generating the classes |
Definition at line 216 of file qgsclassificationmethod.cpp.
|
pure virtual |
Returns a clone of the method.
Implementation can take advantage of copyBase method which copies the parameters of the base class
Implemented in QgsClassificationCustom, QgsClassificationEqualInterval, QgsClassificationFixedInterval, QgsClassificationJenks, QgsClassificationLogarithmic, QgsClassificationPrettyBreaks, QgsClassificationQuantile, and QgsClassificationStandardDeviation.
|
inline |
Code complexity as the exponent in Big O notation.
Definition at line 184 of file qgsclassificationmethod.h.
|
protected |
Copy the parameters (shall be used in clone implementation)
Definition at line 53 of file qgsclassificationmethod.cpp.
|
static |
Reads the DOM element and return a new classification method from it.
element | the DOM element |
context | the read/write context |
Definition at line 62 of file qgsclassificationmethod.cpp.
|
inline |
Returns the classification flags.
Definition at line 160 of file qgsclassificationmethod.h.
|
protected |
Format the number according to label properties.
Definition at line 158 of file qgsclassificationmethod.cpp.
|
inlinevirtual |
The icon of the method.
Reimplemented in QgsClassificationEqualInterval, QgsClassificationFixedInterval, QgsClassificationJenks, QgsClassificationLogarithmic, QgsClassificationPrettyBreaks, QgsClassificationQuantile, and QgsClassificationStandardDeviation.
Definition at line 153 of file qgsclassificationmethod.h.
|
pure virtual |
The id of the method as saved in the project, must be unique in registry.
Implemented in QgsClassificationCustom, QgsClassificationEqualInterval, QgsClassificationFixedInterval, QgsClassificationJenks, QgsClassificationLogarithmic, QgsClassificationPrettyBreaks, QgsClassificationQuantile, and QgsClassificationStandardDeviation.
|
inline |
Returns the format of the label for the classes.
Definition at line 218 of file qgsclassificationmethod.h.
QString QgsClassificationMethod::labelForRange | ( | const QgsRendererRange & | range, |
QgsClassificationMethod::ClassPosition | position = Inner |
||
) | const |
Returns the label for a range.
Definition at line 347 of file qgsclassificationmethod.cpp.
|
virtual |
Returns the label for a range.
Reimplemented in QgsClassificationLogarithmic, and QgsClassificationStandardDeviation.
Definition at line 352 of file qgsclassificationmethod.cpp.
|
inline |
Returns the precision for the formatting of the labels.
Definition at line 222 of file qgsclassificationmethod.h.
|
inline |
Returns if the trailing 0 are trimmed in the label.
Definition at line 226 of file qgsclassificationmethod.h.
|
static |
Remove the breaks that are above the existing opposite sign classes to keep colors symmetrically balanced around symmetryPoint Does not put a break on the symmetryPoint.
This is done before.
breaks | The breaks of an already-done classification |
symmetryPoint | The point around which we want a symmetry |
astride | A bool indicating if the symmetry is made astride the symmetryPoint or not ( [-1,1] vs. [-1,0][0,1] ) |
Definition at line 314 of file qgsclassificationmethod.cpp.
|
pure virtual |
The readable and translate name of the method.
Implemented in QgsClassificationCustom, QgsClassificationEqualInterval, QgsClassificationFixedInterval, QgsClassificationJenks, QgsClassificationLogarithmic, QgsClassificationPrettyBreaks, QgsClassificationQuantile, and QgsClassificationStandardDeviation.
const QgsProcessingParameterDefinition * QgsClassificationMethod::parameterDefinition | ( | const QString & | parameterName | ) | const |
Returns the parameter from its name.
Definition at line 187 of file qgsclassificationmethod.cpp.
|
inline |
Returns the list of parameters.
Definition at line 311 of file qgsclassificationmethod.h.
|
inline |
Returns the values of the processing parameters.
One could use QgsProcessingParameters::parameterAsXxxx to retrieve the actual value of a parameter.
Definition at line 324 of file qgsclassificationmethod.h.
|
static |
Transforms a list of classes to a list of breaks.
Definition at line 32 of file qgsclassificationmethod.cpp.
|
inlinevirtual |
Reads extra information to apply it to the method.
Reimplemented in QgsClassificationStandardDeviation.
Definition at line 171 of file qgsclassificationmethod.h.
QDomElement QgsClassificationMethod::save | ( | QDomDocument & | doc, |
const QgsReadWriteContext & | context | ||
) | const |
Saves the method to a DOM element and return it.
doc | the DOM document |
context | the read/write context |
Definition at line 102 of file qgsclassificationmethod.cpp.
|
inline |
Defines the format of the labels for the classes, using %1 and %2 for the bounds.
Definition at line 220 of file qgsclassificationmethod.h.
void QgsClassificationMethod::setLabelPrecision | ( | int | labelPrecision | ) |
Defines the precision for the formatting of the labels.
Definition at line 143 of file qgsclassificationmethod.cpp.
|
inline |
Defines if the trailing 0 are trimmed in the label.
Definition at line 228 of file qgsclassificationmethod.h.
void QgsClassificationMethod::setParameterValues | ( | const QVariantMap & | values | ) |
Defines the values of the additional parameters.
Definition at line 198 of file qgsclassificationmethod.cpp.
void QgsClassificationMethod::setSymmetricMode | ( | bool | enabled, |
double | symmetryPoint = 0 , |
||
bool | symmetryAstride = false |
||
) |
Defines if the symmetric mode is enables and configures its parameters.
If the symmetric mode is not available in the current implementation, calling this method has no effect.
enabled | if the symmetric mode is enabled |
symmetryPoint | the value of the symmetry point |
symmetryAstride | if true , it will remove the symmetry point break so that the 2 classes form only one |
Definition at line 136 of file qgsclassificationmethod.cpp.
|
inline |
Returns if the method supports symmetric calculation.
Definition at line 189 of file qgsclassificationmethod.h.
|
inline |
Returns if the symmetric mode is enabled.
Definition at line 194 of file qgsclassificationmethod.h.
|
inline |
Returns if the symmetric mode is astride if true
, it will remove the symmetry point break so that the 2 classes form only one.
Definition at line 205 of file qgsclassificationmethod.h.
|
inline |
Returns the symmetry point for symmetric mode.
Definition at line 199 of file qgsclassificationmethod.h.
|
inlinevirtual |
Returns if the method requires values to calculate the classes If not, bounds are sufficient.
Reimplemented in QgsClassificationCustom, QgsClassificationEqualInterval, QgsClassificationFixedInterval, QgsClassificationLogarithmic, and QgsClassificationPrettyBreaks.
Definition at line 177 of file qgsclassificationmethod.h.
|
inlinevirtual |
Writes extra information about the method.
Reimplemented in QgsClassificationStandardDeviation.
Definition at line 169 of file qgsclassificationmethod.h.
|
static |
Definition at line 326 of file qgsclassificationmethod.h.
|
static |
Definition at line 327 of file qgsclassificationmethod.h.