23 const std::vector< QgsStatisticalSummary::Statistic > STATS
43 QString QgsExtractZMValuesAlgorithmBase::group()
const
45 return QObject::tr(
"Vector geometry" );
48 QString QgsExtractZMValuesAlgorithmBase::groupId()
const
50 return QStringLiteral(
"vectorgeometry" );
53 QString QgsExtractZMValuesAlgorithmBase::outputName()
const
55 return QObject::tr(
"Extracted" );
58 QList<int> QgsExtractZMValuesAlgorithmBase::inputLayerTypes()
const
68 void 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 ) );
84 QgsFields QgsExtractZMValuesAlgorithmBase::outputFields(
const QgsFields &inputFields )
const
91 mPrefix = parameterAsString( parameters, QStringLiteral(
"COLUMN_PREFIX" ), context );
93 const QList< int > stats = parameterAsEnums( parameters, QStringLiteral(
"SUMMARIES" ), context );
94 mStats = QgsStatisticalSummary::Statistics();
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 ) );
138 bool QgsExtractZMValuesAlgorithmBase::supportInPlaceEdit(
const QgsMapLayer *layer )
const
148 QgsExtractZValuesAlgorithm::QgsExtractZValuesAlgorithm()
150 mExtractValFunc = [](
const QgsPoint & p ) ->
double
154 mTestGeomFunc = [](
const QgsGeometry & g ) ->
bool
158 mDefaultFieldPrefix = QStringLiteral(
"z_" );
161 QString QgsExtractZValuesAlgorithm::name()
const
163 return QStringLiteral(
"extractzvalues" );
166 QString QgsExtractZValuesAlgorithm::displayName()
const
168 return QObject::tr(
"Extract Z values" );
173 return new QgsExtractZValuesAlgorithm();
176 QStringList QgsExtractZValuesAlgorithm::tags()
const
178 return QObject::tr(
"add,z,value,elevation,height,attribute,statistics,stats" ).split(
',' );
181 QString 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" );
188 QString QgsExtractZValuesAlgorithm::shortDescription()
const
190 return QObject::tr(
"Extracts z values (or z value statistics) from geometries into feature attributes." );
198 QgsExtractMValuesAlgorithm::QgsExtractMValuesAlgorithm()
200 mExtractValFunc = [](
const QgsPoint & p ) ->
double
204 mTestGeomFunc = [](
const QgsGeometry & g ) ->
bool
208 mDefaultFieldPrefix = QStringLiteral(
"m_" );
211 QString QgsExtractMValuesAlgorithm::name()
const
213 return QStringLiteral(
"extractmvalues" );
216 QString QgsExtractMValuesAlgorithm::displayName()
const
218 return QObject::tr(
"Extract M values" );
223 return new QgsExtractMValuesAlgorithm();
226 QStringList QgsExtractMValuesAlgorithm::tags()
const
228 return QObject::tr(
"add,m,value,measure,attribute,statistics,stats" ).split(
',' );
231 QString 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" );
238 QString QgsExtractMValuesAlgorithm::shortDescription()
const
240 return QObject::tr(
"Extracts m values (or m value statistics) from geometries into feature attributes." );