22 QString QgsAlgorithmRemoveDuplicateVertices::name()
const
24 return QStringLiteral(
"removeduplicatevertices" );
27 QString QgsAlgorithmRemoveDuplicateVertices::displayName()
const
29 return QObject::tr(
"Remove duplicate vertices" );
32 QStringList QgsAlgorithmRemoveDuplicateVertices::tags()
const
34 return QObject::tr(
"points,valid,overlapping,vertex,nodes" ).split(
',' );
37 QString QgsAlgorithmRemoveDuplicateVertices::group()
const
39 return QObject::tr(
"Vector geometry" );
42 QString QgsAlgorithmRemoveDuplicateVertices::groupId()
const
44 return QStringLiteral(
"vectorgeometry" );
47 QString QgsAlgorithmRemoveDuplicateVertices::outputName()
const
49 return QObject::tr(
"Cleaned" );
52 QString QgsAlgorithmRemoveDuplicateVertices::shortHelpString()
const
54 return QObject::tr(
"This algorithm removes duplicate vertices from features, wherever removing the vertices does "
55 "not result in a degenerate geometry.\n\n"
56 "The tolerance parameter specifies the tolerance for coordinates when determining whether "
57 "vertices are identical.\n\n"
58 "By default, z values are not considered when detecting duplicate vertices. E.g. two vertices "
59 "with the same x and y coordinate but different z values will still be considered "
60 "duplicate and one will be removed. If the Use Z Value parameter is true, then the z values are "
61 "also tested and vertices with the same x and y but different z will be maintained.\n\n"
62 "Note that duplicate vertices are not tested between different parts of a multipart geometry. E.g. "
63 "a multipoint geometry with overlapping points will not be changed by this method." );
66 QgsAlgorithmRemoveDuplicateVertices *QgsAlgorithmRemoveDuplicateVertices::createInstance()
const
68 return new QgsAlgorithmRemoveDuplicateVertices();
71 void QgsAlgorithmRemoveDuplicateVertices::initParameters(
const QVariantMap & )
73 std::unique_ptr< QgsProcessingParameterDistance> tolerance = qgis::make_unique< QgsProcessingParameterDistance >( QStringLiteral(
"TOLERANCE" ),
74 QObject::tr(
"Tolerance" ), 0.000001, QStringLiteral(
"INPUT" ),
false, 0, 10000000.0 );
75 tolerance->setIsDynamic(
true );
77 tolerance->setDynamicLayerParameterName( QStringLiteral(
"INPUT" ) );
78 addParameter( tolerance.release() );
80 std::unique_ptr< QgsProcessingParameterBoolean > useZ = qgis::make_unique< QgsProcessingParameterBoolean >( QStringLiteral(
"USE_Z_VALUE" ),
81 QObject::tr(
"Use Z Value" ),
false );
82 useZ->setIsDynamic(
true );
84 useZ->setDynamicLayerParameterName( QStringLiteral(
"INPUT" ) );
85 addParameter( useZ.release() );
96 mTolerance = parameterAsDouble( parameters, QStringLiteral(
"TOLERANCE" ), context );
98 if ( mDynamicTolerance )
99 mToleranceProperty = parameters.value( QStringLiteral(
"TOLERANCE" ) ).value<
QgsProperty >();
101 mUseZValues = parameterAsBoolean( parameters, QStringLiteral(
"USE_Z_VALUE" ), context );
104 mUseZProperty = parameters.value( QStringLiteral(
"USE_Z_VALUE" ) ).value<
QgsProperty >();
115 double tolerance = mTolerance;
116 if ( mDynamicTolerance )
117 tolerance = mToleranceProperty.valueAsDouble( context.
expressionContext(), tolerance );
119 bool useZValue = mUseZValues;