24 QString QgsFilterVerticesAlgorithmBase::group()
const
26 return QObject::tr(
"Vector geometry" );
29 QString QgsFilterVerticesAlgorithmBase::groupId()
const
31 return QStringLiteral(
"vectorgeometry" );
34 QString QgsFilterVerticesAlgorithmBase::outputName()
const
36 return QObject::tr(
"Filtered" );
39 QString 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() );
50 QList<int> QgsFilterVerticesAlgorithmBase::inputLayerTypes()
const
55 void QgsFilterVerticesAlgorithmBase::initParameters(
const QVariantMap & )
57 auto min = std::make_unique< QgsProcessingParameterNumber >( QStringLiteral(
"MIN" ),
59 min->setIsDynamic(
true );
61 min->setDynamicLayerParameterName( QStringLiteral(
"INPUT" ) );
62 addParameter( min.release() );
64 auto max = std::make_unique< QgsProcessingParameterNumber >( QStringLiteral(
"MAX" ),
66 max->setIsDynamic(
true );
68 max->setDynamicLayerParameterName( QStringLiteral(
"INPUT" ) );
69 addParameter( max.release() );
74 if ( parameters.contains( QStringLiteral(
"MIN" ) ) && parameters.value( QStringLiteral(
"MIN" ) ).isValid() )
75 mMin = parameterAsDouble( parameters, QStringLiteral(
"MIN" ), context );
77 mMin = std::numeric_limits<double>::quiet_NaN();
81 mMinProperty = parameters.value( QStringLiteral(
"MIN" ) ).value<
QgsProperty >();
83 if ( parameters.contains( QStringLiteral(
"MAX" ) ) && parameters.value( QStringLiteral(
"MAX" ) ).isValid() )
84 mMax = parameterAsDouble( parameters, QStringLiteral(
"MAX" ), context );
86 mMax = std::numeric_limits<double>::quiet_NaN();
90 mMaxProperty = parameters.value( QStringLiteral(
"MAX" ) ).value<
QgsProperty >();
103 min = mMinProperty.valueAsDouble( context.
expressionContext(), std::numeric_limits<double>::quiet_NaN() );
107 max = mMaxProperty.valueAsDouble( context.
expressionContext(), std::numeric_limits<double>::quiet_NaN() );
109 filter( geometry, min, max );
119 QString QgsFilterVerticesByM::name()
const
121 return QStringLiteral(
"filterverticesbym" );
124 QString QgsFilterVerticesByM::displayName()
const
126 return QObject::tr(
"Filter vertices by M value" );
129 QStringList QgsFilterVerticesByM::tags()
const
131 return QObject::tr(
"filter,points,vertex,m" ).split(
',' );
134 QgsFilterVerticesByM *QgsFilterVerticesByM::createInstance()
const
136 return new QgsFilterVerticesByM();
139 bool QgsFilterVerticesByM::supportInPlaceEdit(
const QgsMapLayer *l )
const
141 const QgsVectorLayer *layer = qobject_cast< const QgsVectorLayer * >( l );
145 if ( ! QgsFilterVerticesAlgorithmBase::supportInPlaceEdit( layer ) )
150 QString QgsFilterVerticesByM::componentString()
const
152 return QObject::tr(
"m-value" );
155 void QgsFilterVerticesByM::filter(
QgsGeometry &geometry,
double min,
double max )
const
159 return ( std::isnan( min ) || point.
m() >= min )
160 && ( std::isnan( max ) || point.
m() <= max );
169 QString QgsFilterVerticesByZ::name()
const
171 return QStringLiteral(
"filterverticesbyz" );
174 QString QgsFilterVerticesByZ::displayName()
const
176 return QObject::tr(
"Filter vertices by Z value" );
179 QStringList QgsFilterVerticesByZ::tags()
const
181 return QObject::tr(
"filter,points,vertex,z" ).split(
',' );
184 QgsFilterVerticesByZ *QgsFilterVerticesByZ::createInstance()
const
186 return new QgsFilterVerticesByZ();
189 bool QgsFilterVerticesByZ::supportInPlaceEdit(
const QgsMapLayer *l )
const
191 const QgsVectorLayer *layer = qobject_cast< const QgsVectorLayer * >( l );
195 if ( ! QgsFilterVerticesAlgorithmBase::supportInPlaceEdit( layer ) )
200 QString QgsFilterVerticesByZ::componentString()
const
202 return QObject::tr(
"z-value" );
205 void QgsFilterVerticesByZ::filter(
QgsGeometry &geometry,
double min,
double max )
const
209 return ( std::isnan( min ) || point.
z() >= min )
210 && ( std::isnan( max ) || point.
z() <= max );