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
46 return QObject::tr(
"Filters away vertices based on their %1, returning geometries with only "
47 "vertex points that have a %1 ≥ the specified minimum value and ≤ "
48 "the maximum value.\n\n"
49 "If the minimum value is not specified then only the maximum value is tested, "
50 "and similarly if the maximum value is not specified then only the minimum value is tested.\n\n"
51 "Depending on the input geometry attributes and the filters used, "
52 "the resultant geometries created by this algorithm may no longer be valid." )
53 .arg( componentString() );
56QString QgsFilterVerticesAlgorithmBase::shortDescription()
const
58 return QObject::tr(
"Filters away vertices based on their %1 value." )
59 .arg( componentString() );
62void QgsFilterVerticesAlgorithmBase::initParameters(
const QVariantMap & )
65 min->setIsDynamic(
true );
67 min->setDynamicLayerParameterName( u
"INPUT"_s );
68 addParameter( min.release() );
71 max->setIsDynamic(
true );
73 max->setDynamicLayerParameterName( u
"INPUT"_s );
74 addParameter( max.release() );
79 if ( parameters.contains( u
"MIN"_s ) && parameters.value( u
"MIN"_s ).isValid() )
80 mMin = parameterAsDouble( parameters, u
"MIN"_s, context );
82 mMin = std::numeric_limits<double>::quiet_NaN();
86 mMinProperty = parameters.value( u
"MIN"_s ).value<
QgsProperty>();
88 if ( parameters.contains( u
"MAX"_s ) && parameters.value( u
"MAX"_s ).isValid() )
89 mMax = parameterAsDouble( parameters, u
"MAX"_s, context );
91 mMax = std::numeric_limits<double>::quiet_NaN();
95 mMaxProperty = parameters.value( u
"MAX"_s ).value<
QgsProperty>();
108 min = mMinProperty.valueAsDouble( context.
expressionContext(), std::numeric_limits<double>::quiet_NaN() );
112 max = mMaxProperty.valueAsDouble( context.
expressionContext(), std::numeric_limits<double>::quiet_NaN() );
114 filter( geometry, min, max );
124QString QgsFilterVerticesByM::name()
const
126 return u
"filterverticesbym"_s;
129QString QgsFilterVerticesByM::displayName()
const
131 return QObject::tr(
"Filter vertices by M value" );
134QStringList QgsFilterVerticesByM::tags()
const
136 return QObject::tr(
"filter,points,vertex,m" ).split(
',' );
139QgsFilterVerticesByM *QgsFilterVerticesByM::createInstance()
const
141 return new QgsFilterVerticesByM();
144bool QgsFilterVerticesByM::supportInPlaceEdit(
const QgsMapLayer *l )
const
146 const QgsVectorLayer *layer = qobject_cast<const QgsVectorLayer *>( l );
150 if ( !QgsFilterVerticesAlgorithmBase::supportInPlaceEdit( layer ) )
155QString QgsFilterVerticesByM::componentString()
const
157 return QObject::tr(
"m-value" );
160void QgsFilterVerticesByM::filter(
QgsGeometry &geometry,
double min,
double max )
const
163 return ( std::isnan( min ) || point.
m() >= min )
164 && ( std::isnan( max ) || point.
m() <= max );
173QString QgsFilterVerticesByZ::name()
const
175 return u
"filterverticesbyz"_s;
178QString QgsFilterVerticesByZ::displayName()
const
180 return QObject::tr(
"Filter vertices by Z value" );
183QStringList QgsFilterVerticesByZ::tags()
const
185 return QObject::tr(
"filter,points,vertex,z" ).split(
',' );
188QgsFilterVerticesByZ *QgsFilterVerticesByZ::createInstance()
const
190 return new QgsFilterVerticesByZ();
193bool QgsFilterVerticesByZ::supportInPlaceEdit(
const QgsMapLayer *l )
const
195 const QgsVectorLayer *layer = qobject_cast<const QgsVectorLayer *>( l );
199 if ( !QgsFilterVerticesAlgorithmBase::supportInPlaceEdit( layer ) )
204QString QgsFilterVerticesByZ::componentString()
const
206 return QObject::tr(
"z-value" );
209void QgsFilterVerticesByZ::filter(
QgsGeometry &geometry,
double min,
double max )
const
212 return ( std::isnan( min ) || point.
z() >= min )
213 && ( 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