22using namespace Qt::StringLiterals;
26QString QgsAlgorithmRemoveDuplicateVertices::name()
const
28 return u
"removeduplicatevertices"_s;
31QString QgsAlgorithmRemoveDuplicateVertices::displayName()
const
33 return QObject::tr(
"Remove duplicate vertices" );
36QStringList QgsAlgorithmRemoveDuplicateVertices::tags()
const
38 return QObject::tr(
"points,valid,overlapping,vertex,nodes,invalid,error,repair" ).split(
',' );
41QString QgsAlgorithmRemoveDuplicateVertices::group()
const
43 return QObject::tr(
"Vector geometry" );
46QString QgsAlgorithmRemoveDuplicateVertices::groupId()
const
48 return u
"vectorgeometry"_s;
51QString QgsAlgorithmRemoveDuplicateVertices::outputName()
const
53 return QObject::tr(
"Cleaned" );
56QString QgsAlgorithmRemoveDuplicateVertices::shortHelpString()
const
58 return QObject::tr(
"This algorithm removes duplicate vertices from features, wherever removing the vertices does "
59 "not result in a degenerate geometry.\n\n"
60 "The tolerance parameter specifies the tolerance for coordinates when determining whether "
61 "vertices are identical.\n\n"
62 "By default, z values are not considered when detecting duplicate vertices. E.g. two vertices "
63 "with the same x and y coordinate but different z values will still be considered "
64 "duplicate and one will be removed. If the Use Z Value parameter is true, then the z values are "
65 "also tested and vertices with the same x and y but different z will be maintained.\n\n"
66 "Note that duplicate vertices are not tested between different parts of a multipart geometry. E.g. "
67 "a multipoint geometry with overlapping points will not be changed by this method." );
70QString QgsAlgorithmRemoveDuplicateVertices::shortDescription()
const
72 return QObject::tr(
"Removes duplicate vertices from features, wherever removing the vertices does "
73 "not result in a degenerate geometry." );
76QgsAlgorithmRemoveDuplicateVertices *QgsAlgorithmRemoveDuplicateVertices::createInstance()
const
78 return new QgsAlgorithmRemoveDuplicateVertices();
81void QgsAlgorithmRemoveDuplicateVertices::initParameters(
const QVariantMap & )
83 auto tolerance = std::make_unique<QgsProcessingParameterDistance>( u
"TOLERANCE"_s, QObject::tr(
"Tolerance" ), 0.000001, u
"INPUT"_s,
false, 0, 10000000.0 );
84 tolerance->setIsDynamic(
true );
86 tolerance->setDynamicLayerParameterName( u
"INPUT"_s );
87 addParameter( tolerance.release() );
89 auto useZ = std::make_unique<QgsProcessingParameterBoolean>( u
"USE_Z_VALUE"_s, QObject::tr(
"Use Z Value" ),
false );
90 useZ->setIsDynamic(
true );
92 useZ->setDynamicLayerParameterName( u
"INPUT"_s );
93 addParameter( useZ.release() );
104 mTolerance = parameterAsDouble( parameters, u
"TOLERANCE"_s, context );
106 if ( mDynamicTolerance )
107 mToleranceProperty = parameters.value( u
"TOLERANCE"_s ).value<
QgsProperty>();
109 mUseZValues = parameterAsBoolean( parameters, u
"USE_Z_VALUE"_s, context );
112 mUseZProperty = parameters.value( u
"USE_Z_VALUE"_s ).value<
QgsProperty>();
123 double tolerance = mTolerance;
124 if ( mDynamicTolerance )
125 tolerance = mToleranceProperty.valueAsDouble( context.
expressionContext(), tolerance );
127 bool useZValue = mUseZValues;
@ SkipGeometryValidityChecks
Invalid geometry checks should always be skipped. This flag can be useful for algorithms which always...
QFlags< ProcessingFeatureSourceFlag > ProcessingFeatureSourceFlags
Flags which control how QgsProcessingFeatureSource fetches features.
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.
bool removeDuplicateNodes(double epsilon=4 *std::numeric_limits< double >::epsilon(), bool useZValues=false)
Removes duplicate nodes from the geometry, wherever removing the nodes does not result in a degenerat...
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.
@ DoublePositive
Positive double value (including 0).
A store for object properties.
bool valueAsBool(const QgsExpressionContext &context, bool defaultValue=false, bool *ok=nullptr) const
Calculates the current value of the property and interprets it as an boolean.
QList< QgsFeature > QgsFeatureList