24using namespace Qt::StringLiterals;
27#define EXCLUDE_CPPCHECK
28#ifdef EXCLUDE_CPPCHECK
33QString QgsFilterVerticesAlgorithmBase::group()
const
35 return QObject::tr(
"Vector geometry" );
38QString QgsFilterVerticesAlgorithmBase::groupId()
const
40 return u
"vectorgeometry"_s;
43QString QgsFilterVerticesAlgorithmBase::outputName()
const
45 return QObject::tr(
"Filtered" );
48QString QgsFilterVerticesAlgorithmBase::shortHelpString()
const
51 "Filters away vertices based on their %1, returning geometries with only "
52 "vertex points that have a %1 ≥ the specified minimum value and ≤ "
53 "the maximum value.\n\n"
54 "If the minimum value is not specified then only the maximum value is tested, "
55 "and similarly if the maximum value is not specified then only the minimum value is tested.\n\n"
56 "Depending on the input geometry attributes and the filters used, "
57 "the resultant geometries created by this algorithm may no longer be valid."
59 .arg( componentString() );
62QString QgsFilterVerticesAlgorithmBase::shortDescription()
const
64 return QObject::tr(
"Filters away vertices based on their %1 value." ).arg( componentString() );
67void QgsFilterVerticesAlgorithmBase::initParameters(
const QVariantMap & )
70 min->setIsDynamic(
true );
72 min->setDynamicLayerParameterName( u
"INPUT"_s );
73 addParameter( min.release() );
76 max->setIsDynamic(
true );
78 max->setDynamicLayerParameterName( u
"INPUT"_s );
79 addParameter( max.release() );
84 if ( parameters.contains( u
"MIN"_s ) && parameters.value( u
"MIN"_s ).isValid() )
85 mMin = parameterAsDouble( parameters, u
"MIN"_s, context );
87 mMin = std::numeric_limits<double>::quiet_NaN();
91 mMinProperty = parameters.value( u
"MIN"_s ).value<
QgsProperty>();
93 if ( parameters.contains( u
"MAX"_s ) && parameters.value( u
"MAX"_s ).isValid() )
94 mMax = parameterAsDouble( parameters, u
"MAX"_s, context );
96 mMax = std::numeric_limits<double>::quiet_NaN();
100 mMaxProperty = parameters.value( u
"MAX"_s ).value<
QgsProperty>();
113 min = mMinProperty.valueAsDouble( context.
expressionContext(), std::numeric_limits<double>::quiet_NaN() );
117 max = mMaxProperty.valueAsDouble( context.
expressionContext(), std::numeric_limits<double>::quiet_NaN() );
119 filter( geometry, min, max );
129QString QgsFilterVerticesByM::name()
const
131 return u
"filterverticesbym"_s;
134QString QgsFilterVerticesByM::displayName()
const
136 return QObject::tr(
"Filter vertices by M value" );
139QStringList QgsFilterVerticesByM::tags()
const
141 return QObject::tr(
"filter,points,vertex,m" ).split(
',' );
144QgsFilterVerticesByM *QgsFilterVerticesByM::createInstance()
const
146 return new QgsFilterVerticesByM();
149bool QgsFilterVerticesByM::supportInPlaceEdit(
const QgsMapLayer *l )
const
151 const QgsVectorLayer *layer = qobject_cast<const QgsVectorLayer *>( l );
155 if ( !QgsFilterVerticesAlgorithmBase::supportInPlaceEdit( layer ) )
160QString QgsFilterVerticesByM::componentString()
const
162 return QObject::tr(
"m-value" );
165void QgsFilterVerticesByM::filter(
QgsGeometry &geometry,
double min,
double max )
const
167 QGS_MARK_ALGORITHM_SOURCE
169 geometry.
filterVertices( [min, max](
const QgsPoint &point ) ->
bool {
return ( std::isnan( min ) || point.
m() >= min ) && ( std::isnan( max ) || point.
m() <= max ); } );
177QString QgsFilterVerticesByZ::name()
const
179 return u
"filterverticesbyz"_s;
182QString QgsFilterVerticesByZ::displayName()
const
184 return QObject::tr(
"Filter vertices by Z value" );
187QStringList QgsFilterVerticesByZ::tags()
const
189 return QObject::tr(
"filter,points,vertex,z" ).split(
',' );
192QgsFilterVerticesByZ *QgsFilterVerticesByZ::createInstance()
const
194 return new QgsFilterVerticesByZ();
197bool QgsFilterVerticesByZ::supportInPlaceEdit(
const QgsMapLayer *l )
const
199 const QgsVectorLayer *layer = qobject_cast<const QgsVectorLayer *>( l );
203 if ( !QgsFilterVerticesAlgorithmBase::supportInPlaceEdit( layer ) )
208QString QgsFilterVerticesByZ::componentString()
const
210 return QObject::tr(
"z-value" );
213void QgsFilterVerticesByZ::filter(
QgsGeometry &geometry,
double min,
double max )
const
215 QGS_MARK_ALGORITHM_SOURCE
217 geometry.
filterVertices( [min, max](
const QgsPoint &point ) ->
bool {
return ( std::isnan( min ) || point.
z() >= min ) && ( std::isnan( max ) || point.
z() <= max ); } );
@ Double
Double/float values.
The feature class encapsulates a single feature including its unique ID, geometry and a list of field...
bool hasGeometry() const
Returns true if the feature has an associated geometry.
void setGeometry(const QgsGeometry &geometry)
Set the feature's geometry.
A geometry is the spatial representation of a feature.
void filterVertices(const std::function< bool(const QgsPoint &) > &filter)
Filters the vertices from the geometry in place, removing any which do not return true for the filter...
Base class for all map layer types.
Point geometry type, with support for z-dimension and m-values.
Contains information about the context in which a processing algorithm is executed.
QgsExpressionContext & expressionContext()
Returns the expression context.
Base class for providing feedback from a processing algorithm.
static bool isDynamic(const QVariantMap ¶meters, const QString &name)
Returns true if the parameter with matching name is a dynamic parameter, and must be evaluated once f...
Definition for a property.
@ Double
Double value (including negative values).
A store for object properties.
Represents a vector layer which manages a vector based dataset.
Q_INVOKABLE Qgis::WkbType wkbType() const final
Returns the WKBType or WKBUnknown in case of error.
static Q_INVOKABLE bool hasZ(Qgis::WkbType type)
Tests whether a WKB type contains the z-dimension.
static Q_INVOKABLE bool hasM(Qgis::WkbType type)
Tests whether a WKB type contains m values.
QList< QgsFeature > QgsFeatureList