26QgsSimplifyAlgorithm::~QgsSimplifyAlgorithm() =
default;
28QString QgsSimplifyAlgorithm::name()
const
30 return QStringLiteral(
"simplifygeometries" );
33QString QgsSimplifyAlgorithm::displayName()
const
35 return QObject::tr(
"Simplify" );
38QStringList QgsSimplifyAlgorithm::tags()
const
40 return QObject::tr(
"simplify,generalize,douglas,peucker,visvalingam" ).split(
',' );
43QString QgsSimplifyAlgorithm::group()
const
45 return QObject::tr(
"Vector geometry" );
48QString QgsSimplifyAlgorithm::groupId()
const
50 return QStringLiteral(
"vectorgeometry" );
53QString QgsSimplifyAlgorithm::outputName()
const
55 return QObject::tr(
"Simplified" );
58QString QgsSimplifyAlgorithm::shortHelpString()
const
60 return QObject::tr(
"This algorithm simplifies the geometries in a line or polygon layer. It creates a new layer "
61 "with the same features as the ones in the input layer, but with geometries containing a lower number of vertices.\n\n"
62 "The algorithm gives a choice of simplification methods, including distance based "
63 "(the \"Douglas-Peucker\" algorithm), area based (\"Visvalingam\" algorithm) and snapping geometries to a grid." );
66QString QgsSimplifyAlgorithm::shortDescription()
const
68 return QObject::tr(
"Simplifies the geometries in a line or polygon layer by removing a number of vertices." );
71QgsSimplifyAlgorithm *QgsSimplifyAlgorithm::createInstance()
const
73 return new QgsSimplifyAlgorithm();
76QList<int> QgsSimplifyAlgorithm::inputLayerTypes()
const
81void QgsSimplifyAlgorithm::initParameters(
const QVariantMap & )
84 methods << QObject::tr(
"Distance (Douglas-Peucker)" )
85 << QObject::tr(
"Snap to grid" )
86 << QObject::tr(
"Area (Visvalingam)" );
89 QStringLiteral(
"METHOD" ),
90 QObject::tr(
"Simplification method" ),
93 auto tolerance = std::make_unique<QgsProcessingParameterDistance>( QStringLiteral(
"TOLERANCE" ), QObject::tr(
"Tolerance" ), 1.0, QStringLiteral(
"INPUT" ),
false, 0, 10000000.0 );
94 tolerance->setIsDynamic(
true );
96 tolerance->setDynamicLayerParameterName( QStringLiteral(
"INPUT" ) );
97 addParameter( tolerance.release() );
102 mTolerance = parameterAsDouble( parameters, QStringLiteral(
"TOLERANCE" ), context );
104 if ( mDynamicTolerance )
105 mToleranceProperty = parameters.value( QStringLiteral(
"TOLERANCE" ) ).value<
QgsProperty>();
123 double tolerance = mTolerance;
124 if ( mDynamicTolerance )
125 tolerance = mToleranceProperty.valueAsDouble( context.
expressionContext(), tolerance );
126 outputGeometry = inputGeometry.
simplify( tolerance );
130 if ( !mDynamicTolerance )
132 outputGeometry = mSimplifier->
simplify( inputGeometry );
136 const double tolerance = mToleranceProperty.valueAsDouble( context.
expressionContext(), mTolerance );
138 outputGeometry = simplifier.
simplify( inputGeometry );
@ VectorPolygon
Vector polygon layers.
@ VectorLine
Vector line layers.
VectorSimplificationAlgorithm
Simplification algorithms for vector features.
@ Distance
The simplification uses the distance between points to remove duplicate points.
@ 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.
QgsGeometry simplify(double tolerance) const
Returns a simplified version of this geometry using a specified tolerance value.
Implementation of a geometry simplifier using the "MapToPixel" algorithm.
@ SimplifyGeometry
The geometries can be simplified using the current map2pixel context state.
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.
An enum based parameter for processing algorithms, allowing for selection from predefined values.
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.
QList< QgsFeature > QgsFeatureList