23QgsSimplifyAlgorithm::~QgsSimplifyAlgorithm() =
default;
25QString QgsSimplifyAlgorithm::name()
const
27 return QStringLiteral(
"simplifygeometries" );
30QString QgsSimplifyAlgorithm::displayName()
const
32 return QObject::tr(
"Simplify" );
35QStringList QgsSimplifyAlgorithm::tags()
const
37 return QObject::tr(
"simplify,generalize,douglas,peucker,visvalingam" ).split(
',' );
40QString QgsSimplifyAlgorithm::group()
const
42 return QObject::tr(
"Vector geometry" );
45QString QgsSimplifyAlgorithm::groupId()
const
47 return QStringLiteral(
"vectorgeometry" );
50QString QgsSimplifyAlgorithm::outputName()
const
52 return QObject::tr(
"Simplified" );
55QString QgsSimplifyAlgorithm::shortHelpString()
const
57 return QObject::tr(
"This algorithm simplifies the geometries in a line or polygon layer. It creates a new layer "
58 "with the same features as the ones in the input layer, but with geometries containing a lower number of vertices.\n\n"
59 "The algorithm gives a choice of simplification methods, including distance based "
60 "(the \"Douglas-Peucker\" algorithm), area based (\"Visvalingam\" algorithm) and snapping geometries to a grid." );
63QgsSimplifyAlgorithm *QgsSimplifyAlgorithm::createInstance()
const
65 return new QgsSimplifyAlgorithm();
68QList<int> QgsSimplifyAlgorithm::inputLayerTypes()
const
73void QgsSimplifyAlgorithm::initParameters(
const QVariantMap & )
76 methods << QObject::tr(
"Distance (Douglas-Peucker)" )
77 << QObject::tr(
"Snap to grid" )
78 << QObject::tr(
"Area (Visvalingam)" );
81 QStringLiteral(
"METHOD" ),
82 QObject::tr(
"Simplification method" ),
85 std::unique_ptr<QgsProcessingParameterDistance> tolerance = std::make_unique<QgsProcessingParameterDistance>( QStringLiteral(
"TOLERANCE" ), QObject::tr(
"Tolerance" ), 1.0, QStringLiteral(
"INPUT" ),
false, 0, 10000000.0 );
86 tolerance->setIsDynamic(
true );
88 tolerance->setDynamicLayerParameterName( QStringLiteral(
"INPUT" ) );
89 addParameter( tolerance.release() );
94 mTolerance = parameterAsDouble( parameters, QStringLiteral(
"TOLERANCE" ), context );
96 if ( mDynamicTolerance )
97 mToleranceProperty = parameters.value( QStringLiteral(
"TOLERANCE" ) ).value<
QgsProperty>();
115 double tolerance = mTolerance;
116 if ( mDynamicTolerance )
117 tolerance = mToleranceProperty.valueAsDouble( context.
expressionContext(), tolerance );
118 outputGeometry = inputGeometry.
simplify( tolerance );
122 if ( !mDynamicTolerance )
124 outputGeometry = mSimplifier->
simplify( inputGeometry );
128 const double tolerance = mToleranceProperty.valueAsDouble( context.
expressionContext(), mTolerance );
130 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 GeometrySimplifier 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