24QString QgsFilterVerticesAlgorithmBase::group()
const
26 return QObject::tr(
"Vector geometry" );
29QString QgsFilterVerticesAlgorithmBase::groupId()
const
31 return QStringLiteral(
"vectorgeometry" );
34QString QgsFilterVerticesAlgorithmBase::outputName()
const
36 return QObject::tr(
"Filtered" );
39QString QgsFilterVerticesAlgorithmBase::shortHelpString()
const
41 return QObject::tr(
"Filters away vertices based on their %1, returning geometries with only "
42 "vertex points that have a %1 ≥ the specified minimum value and ≤ "
43 "the maximum value.\n\n"
44 "If the minimum value is not specified then only the maximum value is tested, "
45 "and similarly if the maximum value is not specified then only the minimum value is tested.\n\n"
46 "Depending on the input geometry attributes and the filters used, "
47 "the resultant geometries created by this algorithm may no longer be valid." ).arg( componentString() );
50void QgsFilterVerticesAlgorithmBase::initParameters(
const QVariantMap & )
52 auto min = std::make_unique< QgsProcessingParameterNumber >( QStringLiteral(
"MIN" ),
54 min->setIsDynamic(
true );
56 min->setDynamicLayerParameterName( QStringLiteral(
"INPUT" ) );
57 addParameter( min.release() );
59 auto max = std::make_unique< QgsProcessingParameterNumber >( QStringLiteral(
"MAX" ),
61 max->setIsDynamic(
true );
63 max->setDynamicLayerParameterName( QStringLiteral(
"INPUT" ) );
64 addParameter( max.release() );
69 if ( parameters.contains( QStringLiteral(
"MIN" ) ) && parameters.value( QStringLiteral(
"MIN" ) ).isValid() )
70 mMin = parameterAsDouble( parameters, QStringLiteral(
"MIN" ), context );
72 mMin = std::numeric_limits<double>::quiet_NaN();
76 mMinProperty = parameters.value( QStringLiteral(
"MIN" ) ).value<
QgsProperty >();
78 if ( parameters.contains( QStringLiteral(
"MAX" ) ) && parameters.value( QStringLiteral(
"MAX" ) ).isValid() )
79 mMax = parameterAsDouble( parameters, QStringLiteral(
"MAX" ), context );
81 mMax = std::numeric_limits<double>::quiet_NaN();
85 mMaxProperty = parameters.value( QStringLiteral(
"MAX" ) ).value<
QgsProperty >();
98 min = mMinProperty.valueAsDouble( context.
expressionContext(), std::numeric_limits<double>::quiet_NaN() );
102 max = mMaxProperty.valueAsDouble( context.
expressionContext(), std::numeric_limits<double>::quiet_NaN() );
104 filter( geometry, min, max );
114QString QgsFilterVerticesByM::name()
const
116 return QStringLiteral(
"filterverticesbym" );
119QString QgsFilterVerticesByM::displayName()
const
121 return QObject::tr(
"Filter vertices by M value" );
124QStringList QgsFilterVerticesByM::tags()
const
126 return QObject::tr(
"filter,points,vertex,m" ).split(
',' );
129QgsFilterVerticesByM *QgsFilterVerticesByM::createInstance()
const
131 return new QgsFilterVerticesByM();
134bool QgsFilterVerticesByM::supportInPlaceEdit(
const QgsMapLayer *l )
const
136 const QgsVectorLayer *layer = qobject_cast< const QgsVectorLayer * >( l );
140 if ( ! QgsFilterVerticesAlgorithmBase::supportInPlaceEdit( layer ) )
145QString QgsFilterVerticesByM::componentString()
const
147 return QObject::tr(
"m-value" );
150void QgsFilterVerticesByM::filter(
QgsGeometry &geometry,
double min,
double max )
const
154 return ( std::isnan( min ) || point.
m() >= min )
155 && ( std::isnan( max ) || point.
m() <= max );
164QString QgsFilterVerticesByZ::name()
const
166 return QStringLiteral(
"filterverticesbyz" );
169QString QgsFilterVerticesByZ::displayName()
const
171 return QObject::tr(
"Filter vertices by Z value" );
174QStringList QgsFilterVerticesByZ::tags()
const
176 return QObject::tr(
"filter,points,vertex,z" ).split(
',' );
179QgsFilterVerticesByZ *QgsFilterVerticesByZ::createInstance()
const
181 return new QgsFilterVerticesByZ();
184bool QgsFilterVerticesByZ::supportInPlaceEdit(
const QgsMapLayer *l )
const
186 const QgsVectorLayer *layer = qobject_cast< const QgsVectorLayer * >( l );
190 if ( ! QgsFilterVerticesAlgorithmBase::supportInPlaceEdit( layer ) )
195QString QgsFilterVerticesByZ::componentString()
const
197 return QObject::tr(
"z-value" );
200void QgsFilterVerticesByZ::filter(
QgsGeometry &geometry,
double min,
double max )
const
204 return ( std::isnan( min ) || point.
z() >= min )
205 && ( 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 data sets.
Q_INVOKABLE Qgis::WkbType wkbType() const FINAL
Returns the WKBType or WKBUnknown in case of error.
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