24using namespace Qt::StringLiterals;
29QString QgsFilterVerticesAlgorithmBase::group()
const
31 return QObject::tr(
"Vector geometry" );
34QString QgsFilterVerticesAlgorithmBase::groupId()
const
36 return u
"vectorgeometry"_s;
39QString QgsFilterVerticesAlgorithmBase::outputName()
const
41 return QObject::tr(
"Filtered" );
44QString QgsFilterVerticesAlgorithmBase::shortHelpString()
const
47 "Filters away vertices based on their %1, returning geometries with only "
48 "vertex points that have a %1 ≥ the specified minimum value and ≤ "
49 "the maximum value.\n\n"
50 "If the minimum value is not specified then only the maximum value is tested, "
51 "and similarly if the maximum value is not specified then only the minimum value is tested.\n\n"
52 "Depending on the input geometry attributes and the filters used, "
53 "the resultant geometries created by this algorithm may no longer be valid."
55 .arg( componentString() );
58QString QgsFilterVerticesAlgorithmBase::shortDescription()
const
60 return QObject::tr(
"Filters away vertices based on their %1 value." ).arg( componentString() );
63void QgsFilterVerticesAlgorithmBase::initParameters(
const QVariantMap & )
66 min->setIsDynamic(
true );
68 min->setDynamicLayerParameterName( u
"INPUT"_s );
69 addParameter( min.release() );
72 max->setIsDynamic(
true );
74 max->setDynamicLayerParameterName( u
"INPUT"_s );
75 addParameter( max.release() );
80 if ( parameters.contains( u
"MIN"_s ) && parameters.value( u
"MIN"_s ).isValid() )
81 mMin = parameterAsDouble( parameters, u
"MIN"_s, context );
83 mMin = std::numeric_limits<double>::quiet_NaN();
87 mMinProperty = parameters.value( u
"MIN"_s ).value<
QgsProperty>();
89 if ( parameters.contains( u
"MAX"_s ) && parameters.value( u
"MAX"_s ).isValid() )
90 mMax = parameterAsDouble( parameters, u
"MAX"_s, context );
92 mMax = std::numeric_limits<double>::quiet_NaN();
96 mMaxProperty = parameters.value( u
"MAX"_s ).value<
QgsProperty>();
109 min = mMinProperty.valueAsDouble( context.
expressionContext(), std::numeric_limits<double>::quiet_NaN() );
113 max = mMaxProperty.valueAsDouble( context.
expressionContext(), std::numeric_limits<double>::quiet_NaN() );
115 filter( geometry, min, max );
125QString QgsFilterVerticesByM::name()
const
127 return u
"filterverticesbym"_s;
130QString QgsFilterVerticesByM::displayName()
const
132 return QObject::tr(
"Filter vertices by M value" );
135QStringList QgsFilterVerticesByM::tags()
const
137 return QObject::tr(
"filter,points,vertex,m" ).split(
',' );
140QgsFilterVerticesByM *QgsFilterVerticesByM::createInstance()
const
142 return new QgsFilterVerticesByM();
145bool QgsFilterVerticesByM::supportInPlaceEdit(
const QgsMapLayer *l )
const
147 const QgsVectorLayer *layer = qobject_cast<const QgsVectorLayer *>( l );
151 if ( !QgsFilterVerticesAlgorithmBase::supportInPlaceEdit( layer ) )
156QString QgsFilterVerticesByM::componentString()
const
158 return QObject::tr(
"m-value" );
161void QgsFilterVerticesByM::filter(
QgsGeometry &geometry,
double min,
double max )
const
163 geometry.
filterVertices( [min, max](
const QgsPoint &point ) ->
bool {
return ( std::isnan( min ) || point.
m() >= min ) && ( std::isnan( max ) || point.
m() <= max ); } );
171QString QgsFilterVerticesByZ::name()
const
173 return u
"filterverticesbyz"_s;
176QString QgsFilterVerticesByZ::displayName()
const
178 return QObject::tr(
"Filter vertices by Z value" );
181QStringList QgsFilterVerticesByZ::tags()
const
183 return QObject::tr(
"filter,points,vertex,z" ).split(
',' );
186QgsFilterVerticesByZ *QgsFilterVerticesByZ::createInstance()
const
188 return new QgsFilterVerticesByZ();
191bool QgsFilterVerticesByZ::supportInPlaceEdit(
const QgsMapLayer *l )
const
193 const QgsVectorLayer *layer = qobject_cast<const QgsVectorLayer *>( l );
197 if ( !QgsFilterVerticesAlgorithmBase::supportInPlaceEdit( layer ) )
202QString QgsFilterVerticesByZ::componentString()
const
204 return QObject::tr(
"z-value" );
207void QgsFilterVerticesByZ::filter(
QgsGeometry &geometry,
double min,
double max )
const
209 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