22 QString QgsSimplifyAlgorithm::name()
const 24 return QStringLiteral(
"simplifygeometries" );
27 QString QgsSimplifyAlgorithm::displayName()
const 29 return QObject::tr(
"Simplify" );
32 QStringList QgsSimplifyAlgorithm::tags()
const 34 return QObject::tr(
"simplify,generalize,douglas,peucker,visvalingam" ).split(
',' );
37 QString QgsSimplifyAlgorithm::group()
const 39 return QObject::tr(
"Vector geometry" );
42 QString QgsSimplifyAlgorithm::groupId()
const 44 return QStringLiteral(
"vectorgeometry" );
47 QString QgsSimplifyAlgorithm::outputName()
const 49 return QObject::tr(
"Simplified" );
52 QString QgsSimplifyAlgorithm::shortHelpString()
const 54 return QObject::tr(
"This algorithm simplifies the geometries in a line or polygon layer. It creates a new layer " 55 "with the same features as the ones in the input layer, but with geometries containing a lower number of vertices.\n\n" 56 "The algorithm gives a choice of simplification methods, including distance based " 57 "(the \"Douglas-Peucker\" algorithm), area based (\"Visvalingam\" algorithm) and snapping geometries to a grid." );
60 QgsSimplifyAlgorithm *QgsSimplifyAlgorithm::createInstance()
const 62 return new QgsSimplifyAlgorithm();
65 QList<int> QgsSimplifyAlgorithm::inputLayerTypes()
const 70 void QgsSimplifyAlgorithm::initParameters(
const QVariantMap & )
73 methods << QObject::tr(
"Distance (Douglas-Peucker)" )
74 << QObject::tr(
"Snap to grid" )
75 << QObject::tr(
"Area (Visvalingam)" );
78 QStringLiteral(
"METHOD" ),
79 QObject::tr(
"Simplification method" ),
80 methods,
false, 0 ) );
81 std::unique_ptr< QgsProcessingParameterDistance > tolerance = qgis::make_unique< QgsProcessingParameterDistance >( QStringLiteral(
"TOLERANCE" ),
82 QObject::tr(
"Tolerance" ), 1.0, QStringLiteral(
"INPUT" ),
false, 0, 10000000.0 );
83 tolerance->setIsDynamic(
true );
85 tolerance->setDynamicLayerParameterName( QStringLiteral(
"INPUT" ) );
86 addParameter( tolerance.release() );
91 mTolerance = parameterAsDouble( parameters, QStringLiteral(
"TOLERANCE" ), context );
93 if ( mDynamicTolerance )
94 mToleranceProperty = parameters.value( QStringLiteral(
"TOLERANCE" ) ).value<
QgsProperty >();
112 double tolerance = mTolerance;
113 if ( mDynamicTolerance )
114 tolerance = mToleranceProperty.valueAsDouble( context.
expressionContext(), tolerance );
115 outputGeometry = inputGeometry.
simplify( tolerance );
119 if ( !mDynamicTolerance )
121 outputGeometry = mSimplifier->
simplify( inputGeometry );
125 double tolerance = mToleranceProperty.valueAsDouble( context.
expressionContext(), mTolerance );
127 outputGeometry = simplifier.
simplify( inputGeometry );
Base class for providing feedback from a processing algorithm.
Invalid geometry checks should always be skipped. This flag can be useful for algorithms which always...
QList< QgsFeature > QgsFeatureList
A geometry is the spatial representation of a feature.
The feature class encapsulates a single feature including its id, geometry and a list of field/values...
Positive double value (including 0)
SimplifyAlgorithm
Types of simplification algorithms that can be used.
bool hasGeometry() const
Returns true if the feature has an associated geometry.
An enum based parameter for processing algorithms, allowing for selection from predefined values...
A store for object properties.
Implementation of GeometrySimplifier using the "MapToPixel" algorithm.
QgsExpressionContext & expressionContext()
Returns the expression context.
Definition for a property.
Flag
Flags controlling how QgsProcessingFeatureSource fetches features.
QgsGeometry simplify(double tolerance) const
Returns a simplified version of this geometry using a specified tolerance value.
void setGeometry(const QgsGeometry &geometry)
Set the feature's geometry.
The geometries can be simplified using the current map2pixel context state.
Contains information about the context in which a processing algorithm is executed.
The simplification uses the distance between points to remove duplicate points.
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...