27QString QgsCoverageValidateAlgorithm::name()
const
29 return QStringLiteral(
"coveragevalidate" );
32QString QgsCoverageValidateAlgorithm::displayName()
const
34 return QObject::tr(
"Validate coverage" );
37QStringList QgsCoverageValidateAlgorithm::tags()
const
39 return QObject::tr(
"validity,overlaps,gaps,topological,boundary" ).split(
',' );
42QString QgsCoverageValidateAlgorithm::group()
const
44 return QObject::tr(
"Vector coverage" );
47QString QgsCoverageValidateAlgorithm::groupId()
const
49 return QStringLiteral(
"vectorcoverage" );
52void QgsCoverageValidateAlgorithm::initAlgorithm(
const QVariantMap & )
55 std::unique_ptr< QgsProcessingParameterDistance> gapWidthParam = std::make_unique< QgsProcessingParameterDistance >( QStringLiteral(
"GAP_WIDTH" ),
56 QObject::tr(
"Gap width" ), 0.0, QStringLiteral(
"INPUT" ),
false, 0, 10000000.0 );
57 gapWidthParam->setHelp( QObject::tr(
"The maximum width of gaps to detect" ) );
58 addParameter( gapWidthParam.release() );
64QString QgsCoverageValidateAlgorithm::shortDescription()
const
66 return QObject::tr(
"Analyzes a coverage of polygon features to find places where the assumption of exactly matching edges is not met" );
69QString QgsCoverageValidateAlgorithm::shortHelpString()
const
71 return QObject::tr(
"This algorithm analyzes a coverage (represented as a set of polygon features "
72 "with exactly matching edge geometry) to find places where the "
73 "assumption of exactly matching edges is not met.\n\n"
74 "Invalidity includes polygons that overlap "
75 "or that have gaps smaller than the specified gap width." );
78QgsCoverageValidateAlgorithm *QgsCoverageValidateAlgorithm::createInstance()
const
80 return new QgsCoverageValidateAlgorithm();
85 std::unique_ptr< QgsProcessingFeatureSource > source( parameterAsSource( parameters, QStringLiteral(
"INPUT" ), context ) );
89 const double gapWidth = parameterAsDouble( parameters, QStringLiteral(
"GAP_WIDTH" ), context );
92 std::unique_ptr< QgsFeatureSink > sink( parameterAsSink( parameters, QStringLiteral(
"INVALID_EDGES" ), context, sinkId,
QgsFields(),
Qgis::WkbType::LineString, source->sourceCrs() ) );
93 if ( !sink && parameters.value( QStringLiteral(
"INVALID_EDGES" ) ).isValid() )
98 const long count = source->featureCount();
104 const double step = count > 0 ? 100.0 / count : 1;
107 feedback->
pushInfo( QObject::tr(
"Collecting features" ) );
127 feedback->
pushInfo( QObject::tr(
"Validating coverage" ) );
131 std::unique_ptr< QgsAbstractGeometry > invalidEdges;
135 result =
geos.validateCoverage( gapWidth, &invalidEdges, &error ) ;
145 feedback->
reportError( QObject::tr(
"Coverage is not valid" ) );
150 for (
auto partsIt = invalidEdges->const_parts_begin(); partsIt != invalidEdges->const_parts_end(); ++partsIt )
161 feedback->
pushInfo( QObject::tr(
"Coverage is valid" ) );
164 if ( !error.isEmpty() )
173 outputs.insert( QStringLiteral(
"OUTPUT" ), sinkId );
@ VectorPolygon
Vector polygon layers.
@ VectorLine
Vector line layers.
CoverageValidityResult
Coverage validity results.
@ Valid
Coverage is valid.
@ Invalid
Coverage is invalid. Invalidity includes polygons that overlap, that have gaps smaller than the gap w...
@ Error
An exception occurred while determining validity.
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.
@ 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.
void setGeometry(const QgsGeometry &geometry)
Set the feature's geometry.
bool isCanceled() const
Tells whether the operation has been canceled already.
void setProgress(double progress)
Sets the current progress for the feedback object.
Container of fields for a vector layer.
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.
A geometry is the spatial representation of a feature.
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, exception handling*.
Custom exception class which is raised when an operation is not supported.
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.
virtual void reportError(const QString &error, bool fatalError=false)
Reports that the algorithm encountered an error while executing.
A boolean output for processing algorithms.
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.