23const std::vector<Qgis::Statistic> STATS {
42QString QgsExtractZMValuesAlgorithmBase::group()
const
44 return QObject::tr(
"Vector geometry" );
47QString QgsExtractZMValuesAlgorithmBase::groupId()
const
49 return QStringLiteral(
"vectorgeometry" );
52QString QgsExtractZMValuesAlgorithmBase::outputName()
const
54 return QObject::tr(
"Extracted" );
57QList<int> QgsExtractZMValuesAlgorithmBase::inputLayerTypes()
const
67void QgsExtractZMValuesAlgorithmBase::initParameters(
const QVariantMap & )
69 QStringList statChoices;
70 statChoices.reserve( STATS.size() );
76 addParameter(
new QgsProcessingParameterEnum( QStringLiteral(
"SUMMARIES" ), QObject::tr(
"Summaries to calculate" ), statChoices,
true, QVariantList() << 0 ) );
78 addParameter(
new QgsProcessingParameterString( QStringLiteral(
"COLUMN_PREFIX" ), QObject::tr(
"Output column prefix" ), mDefaultFieldPrefix,
false,
true ) );
81QgsFields QgsExtractZMValuesAlgorithmBase::outputFields(
const QgsFields &inputFields )
const
88 mPrefix = parameterAsString( parameters, QStringLiteral(
"COLUMN_PREFIX" ), context );
90 const QList<int> stats = parameterAsEnums( parameters, QStringLiteral(
"SUMMARIES" ), context );
94 mStats |= STATS.at( s );
95 mSelectedStats << STATS.at( s );
106 attrs.reserve( attrs.count() + mSelectedStats.count() );
109 attrs.resize( attrs.count() + mNewFields.size() );
117 stat.addValue( mExtractValFunc( *it ) );
128 attrs.append( stat.statistic( s ) );
135bool QgsExtractZMValuesAlgorithmBase::supportInPlaceEdit(
const QgsMapLayer *layer )
const
145QgsExtractZValuesAlgorithm::QgsExtractZValuesAlgorithm()
147 mExtractValFunc = [](
const QgsPoint &p ) ->
double {
150 mTestGeomFunc = [](
const QgsGeometry &g ) ->
bool {
153 mDefaultFieldPrefix = QStringLiteral(
"z_" );
156QString QgsExtractZValuesAlgorithm::name()
const
158 return QStringLiteral(
"extractzvalues" );
161QString QgsExtractZValuesAlgorithm::displayName()
const
163 return QObject::tr(
"Extract Z values" );
168 return new QgsExtractZValuesAlgorithm();
171QStringList QgsExtractZValuesAlgorithm::tags()
const
173 return QObject::tr(
"add,z,value,elevation,height,attribute,statistics,stats" ).split(
',' );
176QString QgsExtractZValuesAlgorithm::shortHelpString()
const
178 return QObject::tr(
"Extracts z values from geometries into feature attributes.\n\n"
179 "By default only the z value from the first vertex of each feature is extracted, however the algorithm "
180 "can optionally calculate statistics on all of the geometry's z values, including sums, means, and minimums and maximums" );
183QString QgsExtractZValuesAlgorithm::shortDescription()
const
185 return QObject::tr(
"Extracts z values (or z value statistics) from geometries into feature attributes." );
193QgsExtractMValuesAlgorithm::QgsExtractMValuesAlgorithm()
195 mExtractValFunc = [](
const QgsPoint &p ) ->
double {
198 mTestGeomFunc = [](
const QgsGeometry &g ) ->
bool {
201 mDefaultFieldPrefix = QStringLiteral(
"m_" );
204QString QgsExtractMValuesAlgorithm::name()
const
206 return QStringLiteral(
"extractmvalues" );
209QString QgsExtractMValuesAlgorithm::displayName()
const
211 return QObject::tr(
"Extract M values" );
216 return new QgsExtractMValuesAlgorithm();
219QStringList QgsExtractMValuesAlgorithm::tags()
const
221 return QObject::tr(
"add,m,value,measure,attribute,statistics,stats" ).split(
',' );
224QString QgsExtractMValuesAlgorithm::shortHelpString()
const
226 return QObject::tr(
"Extracts m values from geometries into feature attributes.\n\n"
227 "By default only the m value from the first vertex of each feature is extracted, however the algorithm "
228 "can optionally calculate statistics on all of the geometry's m values, including sums, means, and minimums and maximums" );
231QString QgsExtractMValuesAlgorithm::shortDescription()
const
233 return QObject::tr(
"Extracts m values (or m value statistics) from geometries into feature attributes." );
@ VectorAnyGeometry
Any vector layer with geometry.
Statistic
Available generic statistics.
@ StDev
Standard deviation of values.
@ FirstQuartile
First quartile.
@ Median
Median of values.
@ Range
Range of values (max - min)
@ Minority
Minority of values.
@ Majority
Majority of values.
@ Variety
Variety (count of distinct) values.
@ ThirdQuartile
Third quartile.
@ InterQuartileRange
Inter quartile range (IQR)
QFlags< Statistic > Statistics
Statistics to be calculated for generic values.
@ SkipGeometryValidityChecks
Invalid geometry checks should always be skipped. This flag can be useful for algorithms which always...
QFlags< ProcessingFeatureSourceFlag > ProcessingFeatureSourceFlags
Flags which control how QgsProcessingFeatureSource fetches features.
The feature class encapsulates a single feature including its unique ID, geometry and a list of field...
void setAttributes(const QgsAttributes &attrs)
Sets the feature's attributes.
bool hasGeometry() const
Returns true if the feature has an associated geometry.
Encapsulate a field in an attribute table or data source.
Container of fields for a vector layer.
A geometry is the spatial representation of a feature.
bool isEmpty() const
Returns true if the geometry is empty (eg a linestring with no vertices, or a collection with no geom...
QgsAbstractGeometry::vertex_iterator vertices_begin() const
Returns STL-style iterator pointing to the first vertex of the geometry.
Qgis::WkbType wkbType() const
Returns type of the geometry as a WKB type (point / linestring / polygon etc.)
QgsAbstractGeometry::vertex_iterator vertices_end() const
Returns STL-style iterator pointing to the imaginary vertex after the last vertex of the geometry.
Base class for all map layer types.
Point geometry type, with support for z-dimension and m-values.
Abstract base class for processing algorithms.
Contains information about the context in which a processing algorithm is executed.
Base class for providing feedback from a processing algorithm.
An enum based parameter for processing algorithms, allowing for selection from predefined values.
A string parameter for processing algorithms.
static QgsFields combineFields(const QgsFields &fieldsA, const QgsFields &fieldsB, const QString &fieldsBPrefix=QString())
Combines two field lists, avoiding duplicate field names (in a case-insensitive manner).
Calculator for summary statistics for a list of doubles.
static QString displayName(Qgis::Statistic statistic)
Returns the friendly display name for a statistic.
static QString shortName(Qgis::Statistic statistic)
Returns a short, friendly display name for a statistic, suitable for use in a field name.
static bool hasZ(Qgis::WkbType type)
Tests whether a WKB type contains the z-dimension.
static bool hasM(Qgis::WkbType type)
Tests whether a WKB type contains m values.
QList< QgsFeature > QgsFeatureList