22 QString QgsRemoveNullGeometryAlgorithm::name()
const 24 return QStringLiteral(
"removenullgeometries" );
27 QString QgsRemoveNullGeometryAlgorithm::displayName()
const 29 return QObject::tr(
"Remove null geometries" );
32 QStringList QgsRemoveNullGeometryAlgorithm::tags()
const 34 return QObject::tr(
"remove,drop,delete,empty,geometry" ).split(
',' );
37 QString QgsRemoveNullGeometryAlgorithm::group()
const 39 return QObject::tr(
"Vector geometry" );
42 QString QgsRemoveNullGeometryAlgorithm::groupId()
const 44 return QStringLiteral(
"vectorgeometry" );
47 void QgsRemoveNullGeometryAlgorithm::initAlgorithm(
const QVariantMap & )
56 addParameter( nullOutput );
59 QString QgsRemoveNullGeometryAlgorithm::shortHelpString()
const 61 return QObject::tr(
"This algorithm removes any features which do not have a geometry from a vector layer. " 62 "All other features will be copied unchanged.\n\n" 63 "Optionally, the features with null geometries can be saved to a separate output." );
66 QgsRemoveNullGeometryAlgorithm *QgsRemoveNullGeometryAlgorithm::createInstance()
const 68 return new QgsRemoveNullGeometryAlgorithm();
73 std::unique_ptr< QgsProcessingFeatureSource > source( parameterAsSource( parameters, QStringLiteral(
"INPUT" ), context ) );
77 QString nonNullSinkId;
78 std::unique_ptr< QgsFeatureSink > nonNullSink( parameterAsSink( parameters, QStringLiteral(
"OUTPUT" ), context, nonNullSinkId, source->fields(),
79 source->wkbType(), source->sourceCrs() ) );
82 std::unique_ptr< QgsFeatureSink > nullSink( parameterAsSink( parameters, QStringLiteral(
"NULL_OUTPUT" ), context, nullSinkId, source->fields() ) );
84 long count = source->featureCount();
86 double step = count > 0 ? 100.0 / count : 1;
113 outputs.insert( QStringLiteral(
"OUTPUT" ), nonNullSinkId );
115 outputs.insert( QStringLiteral(
"NULL_OUTPUT" ), nullSinkId );
Wrapper for iterator of features from vector data provider or vector layer.
Use faster inserts, at the cost of updating the passed features to reflect changes made at the provid...
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...
void setProgress(double progress)
Sets the current progress for the feedback object.
The feature class encapsulates a single feature including its id, geometry and a list of field/values...
bool hasGeometry() const
Returns true if the feature has an associated geometry.
A feature sink output for processing algorithms.
This class wraps a request for features to a vector layer (or directly its vector data provider)...
Custom exception class for processing related exceptions.
void setCreateByDefault(bool createByDefault)
Sets whether the destination should be created by default.
bool isCanceled() const
Tells whether the operation has been canceled already.
An input feature source (such as vector layers) parameter for processing algorithms.
Tables (i.e. vector layers with or without geometry). When used for a sink this indicates the sink ha...
bool nextFeature(QgsFeature &f)
Contains information about the context in which a processing algorithm is executed.
Any vector layer with geometry.