26using namespace Qt::StringLiterals;
30QString QgsCoverageUnionAlgorithm::name()
const
32 return u
"coverageunion"_s;
35QString QgsCoverageUnionAlgorithm::displayName()
const
37 return QObject::tr(
"Dissolve coverage" );
40QStringList QgsCoverageUnionAlgorithm::tags()
const
42 return QObject::tr(
"union,merge,topological,boundary" ).split(
',' );
45QString QgsCoverageUnionAlgorithm::group()
const
47 return QObject::tr(
"Vector coverage" );
50QString QgsCoverageUnionAlgorithm::groupId()
const
52 return u
"vectorcoverage"_s;
55void QgsCoverageUnionAlgorithm::initAlgorithm(
const QVariantMap & )
61QString QgsCoverageUnionAlgorithm::shortDescription()
const
63 return QObject::tr(
"Dissolves a coverage of polygon features." );
66QString QgsCoverageUnionAlgorithm::shortHelpString()
const
68 return QObject::tr(
"This algorithm operates on a coverage (represented as a set of polygon features "
69 "with exactly matching edge geometry) to dissolve (union) the geometries.\n\n"
70 "It provides a heavily optimized approach for unioning these features compared with "
71 "the standard Dissolve tools." );
74QgsCoverageUnionAlgorithm *QgsCoverageUnionAlgorithm::createInstance()
const
76 return new QgsCoverageUnionAlgorithm();
81 std::unique_ptr<QgsProcessingFeatureSource> source( parameterAsSource( parameters, u
"INPUT"_s, context ) );
86 std::unique_ptr<QgsFeatureSink> sink( parameterAsSink( parameters, u
"OUTPUT"_s, context, sinkId, source->fields(),
Qgis::WkbType::MultiPolygon, source->sourceCrs() ) );
93 const long count = source->featureCount();
99 const double step = count > 0 ? 100.0 / count : 1;
102 feedback->
pushInfo( QObject::tr(
"Collecting features" ) );
124 feedback->
pushInfo( QObject::tr(
"Dissolving coverage" ) );
129 switch ( source->invalidGeometryCheck() )
145 std::unique_ptr<QgsAbstractGeometry> dissolved =
geos.unionCoverage( &error );
149 if ( !error.isEmpty() )
157 feedback->
pushInfo( QObject::tr(
"Storing output" ) );
159 outFeature.setGeometry( std::move( dissolved ) );
166 outputs.insert( u
"OUTPUT"_s, sinkId );
@ VectorPolygon
Vector polygon layers.
@ Valid
Coverage is valid.
@ NoCheck
No invalid geometry checking.
@ AbortOnInvalid
Close iterator on encountering any features with invalid geometry. This requires a slow geometry vali...
@ SkipInvalid
Skip any features with invalid geometry. This requires a slow geometry validity check for every featu...
@ MultiPolygon
MultiPolygon.
virtual QgsAbstractGeometry * clone() const =0
Clones the geometry by performing a deep copy.
Wrapper for iterator of features from vector data provider or vector layer.
bool nextFeature(QgsFeature &f)
Fetch next feature and stores in f, returns true on success.
Wraps a request for features to a vector layer (or directly its vector data provider).
QgsFeatureRequest & setNoAttributes()
Set that no attributes will be fetched.
@ FastInsert
Use faster inserts, at the cost of updating the passed features to reflect changes made at the provid...
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.
bool isCanceled() const
Tells whether the operation has been canceled already.
void setProgress(double progress)
Sets the current progress for the feedback object.
void reserve(int size)
Attempts to allocate memory for at least size geometries.
virtual bool addGeometry(QgsAbstractGeometry *g)
Adds a geometry and takes ownership. Returns true in case of success.
const QgsAbstractGeometry * constGet() const
Returns a non-modifiable (const) reference to the underlying abstract geometry primitive.
Does vector analysis using the GEOS library and handles import, export, and exception handling.
Contains information about the context in which a processing algorithm is executed.
Custom exception class for processing related exceptions.
Base class for providing feedback from a processing algorithm.
virtual void pushInfo(const QString &info)
Pushes a general informational message from the algorithm.
A feature sink output for processing algorithms.
An input feature source (such as vector layers) parameter for processing algorithms.
Contains geos related utilities and functions.