23const std::vector< Qgis::Statistic > STATS
43QString QgsExtractZMValuesAlgorithmBase::group()
const
45 return QObject::tr(
"Vector geometry" );
48QString QgsExtractZMValuesAlgorithmBase::groupId()
const
50 return QStringLiteral(
"vectorgeometry" );
53QString QgsExtractZMValuesAlgorithmBase::outputName()
const
55 return QObject::tr(
"Extracted" );
58QList<int> QgsExtractZMValuesAlgorithmBase::inputLayerTypes()
const
68void QgsExtractZMValuesAlgorithmBase::initParameters(
const QVariantMap & )
70 QStringList statChoices;
71 statChoices.reserve( STATS.size() );
78 QObject::tr(
"Summaries to calculate" ),
79 statChoices,
true, QVariantList() << 0 ) );
81 addParameter(
new QgsProcessingParameterString( QStringLiteral(
"COLUMN_PREFIX" ), QObject::tr(
"Output column prefix" ), mDefaultFieldPrefix,
false,
true ) );
84QgsFields QgsExtractZMValuesAlgorithmBase::outputFields(
const QgsFields &inputFields )
const
91 mPrefix = parameterAsString( parameters, QStringLiteral(
"COLUMN_PREFIX" ), context );
93 const QList< int > stats = parameterAsEnums( parameters, QStringLiteral(
"SUMMARIES" ), context );
97 mStats |= STATS.at( s );
98 mSelectedStats << STATS.at( s );
109 attrs.reserve( attrs.count() + mSelectedStats.count() );
112 attrs.resize( attrs.count() + mNewFields.size() );
120 stat.addValue( mExtractValFunc( *it ) );
131 attrs.append( stat.statistic( s ) );
138bool QgsExtractZMValuesAlgorithmBase::supportInPlaceEdit(
const QgsMapLayer *layer )
const
148QgsExtractZValuesAlgorithm::QgsExtractZValuesAlgorithm()
150 mExtractValFunc = [](
const QgsPoint & p ) ->
double
154 mTestGeomFunc = [](
const QgsGeometry & g ) ->
bool
158 mDefaultFieldPrefix = QStringLiteral(
"z_" );
161QString QgsExtractZValuesAlgorithm::name()
const
163 return QStringLiteral(
"extractzvalues" );
166QString QgsExtractZValuesAlgorithm::displayName()
const
168 return QObject::tr(
"Extract Z values" );
173 return new QgsExtractZValuesAlgorithm();
176QStringList QgsExtractZValuesAlgorithm::tags()
const
178 return QObject::tr(
"add,z,value,elevation,height,attribute,statistics,stats" ).split(
',' );
181QString QgsExtractZValuesAlgorithm::shortHelpString()
const
183 return QObject::tr(
"Extracts z values from geometries into feature attributes.\n\n"
184 "By default only the z value from the first vertex of each feature is extracted, however the algorithm "
185 "can optionally calculate statistics on all of the geometry's z values, including sums, means, and minimums and maximums" );
188QString QgsExtractZValuesAlgorithm::shortDescription()
const
190 return QObject::tr(
"Extracts z values (or z value statistics) from geometries into feature attributes." );
198QgsExtractMValuesAlgorithm::QgsExtractMValuesAlgorithm()
200 mExtractValFunc = [](
const QgsPoint & p ) ->
double
204 mTestGeomFunc = [](
const QgsGeometry & g ) ->
bool
208 mDefaultFieldPrefix = QStringLiteral(
"m_" );
211QString QgsExtractMValuesAlgorithm::name()
const
213 return QStringLiteral(
"extractmvalues" );
216QString QgsExtractMValuesAlgorithm::displayName()
const
218 return QObject::tr(
"Extract M values" );
223 return new QgsExtractMValuesAlgorithm();
226QStringList QgsExtractMValuesAlgorithm::tags()
const
228 return QObject::tr(
"add,m,value,measure,attribute,statistics,stats" ).split(
',' );
231QString QgsExtractMValuesAlgorithm::shortHelpString()
const
233 return QObject::tr(
"Extracts m values from geometries into feature attributes.\n\n"
234 "By default only the m value from the first vertex of each feature is extracted, however the algorithm "
235 "can optionally calculate statistics on all of the geometry's m values, including sums, means, and minimums and maximums" );
238QString QgsExtractMValuesAlgorithm::shortDescription()
const
240 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.
@ First
First value (since QGIS 3.6)
@ Range
Range of values (max - min)
@ Minority
Minority of values.
@ Majority
Majority of values.
@ Variety
Variety (count of distinct) values.
@ Last
Last value (since QGIS 3.6)
@ 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