22QString QgsRemoveNullGeometryAlgorithm::name()
 const 
   24  return QStringLiteral( 
"removenullgeometries" );
 
   27QString QgsRemoveNullGeometryAlgorithm::displayName()
 const 
   29  return QObject::tr( 
"Remove null geometries" );
 
   32QStringList QgsRemoveNullGeometryAlgorithm::tags()
 const 
   34  return QObject::tr( 
"remove,drop,delete,empty,geometry" ).split( 
',' );
 
   37QString QgsRemoveNullGeometryAlgorithm::group()
 const 
   39  return QObject::tr( 
"Vector geometry" );
 
   42QString QgsRemoveNullGeometryAlgorithm::groupId()
 const 
   44  return QStringLiteral( 
"vectorgeometry" );
 
   47void QgsRemoveNullGeometryAlgorithm::initAlgorithm( 
const QVariantMap & )
 
   55  addParameter( nullOutput );
 
   58QString QgsRemoveNullGeometryAlgorithm::shortHelpString()
 const 
   60  return QObject::tr( 
"This algorithm removes any features which do not have a geometry from a vector layer. " 
   61                      "All other features will be copied unchanged.\n\n" 
   62                      "Optionally, the features with null geometries can be saved to a separate output.\n\n" 
   63                      "If 'Also remove empty geometries' is checked, the algorithm removes features whose geometries " 
   64                      "have no coordinates, i.e., geometries that are empty. In that case, also the null " 
   65                      "output will reflect this option, containing both null and empty geometries." );
 
   68QString QgsRemoveNullGeometryAlgorithm::shortDescription()
 const 
   70  return QObject::tr( 
"Removes any features which do not have a geometry from a vector layer." );
 
   73QgsRemoveNullGeometryAlgorithm *QgsRemoveNullGeometryAlgorithm::createInstance()
 const 
   75  return new QgsRemoveNullGeometryAlgorithm();
 
   80  std::unique_ptr<QgsProcessingFeatureSource> source( parameterAsSource( parameters, QStringLiteral( 
"INPUT" ), context ) );
 
   84  const bool removeEmpty = parameterAsBoolean( parameters, QStringLiteral( 
"REMOVE_EMPTY" ), context );
 
   86  QString nonNullSinkId;
 
   87  std::unique_ptr<QgsFeatureSink> nonNullSink( parameterAsSink( parameters, QStringLiteral( 
"OUTPUT" ), context, nonNullSinkId, source->fields(), source->wkbType(), source->sourceCrs() ) );
 
   90  std::unique_ptr<QgsFeatureSink> nullSink( parameterAsSink( parameters, QStringLiteral( 
"NULL_OUTPUT" ), context, nullSinkId, source->fields() ) );
 
   92  const long count = source->featureCount();
 
   94  const double step = count > 0 ? 100.0 / count : 1;
 
  109        throw QgsProcessingException( writeFeatureError( nonNullSink.get(), parameters, QStringLiteral( 
"OUTPUT" ) ) );
 
  114        throw QgsProcessingException( writeFeatureError( nullSink.get(), parameters, QStringLiteral( 
"NULL_OUTPUT" ) ) );
 
  124    nonNullSink->finalize();
 
  125    outputs.insert( QStringLiteral( 
"OUTPUT" ), nonNullSinkId );
 
  129    nullSink->finalize();
 
  130    outputs.insert( QStringLiteral( 
"NULL_OUTPUT" ), nullSinkId );
 
@ Vector
Tables (i.e. vector layers with or without geometry). When used for a sink this indicates the sink ha...
 
@ VectorAnyGeometry
Any vector layer with geometry.
 
@ SkipGeometryValidityChecks
Invalid geometry checks should always be skipped. This flag can be useful for algorithms which always...
 
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).
 
@ 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.
 
bool isEmpty() const
Returns true if the geometry is empty (eg a linestring with no vertices, or a collection with no geom...
 
Contains information about the context in which a processing algorithm is executed.
 
void setCreateByDefault(bool createByDefault)
Sets whether the destination should be created by default.
 
Custom exception class for processing related exceptions.
 
Base class for providing feedback from a processing algorithm.
 
A boolean parameter for processing algorithms.
 
A feature sink output for processing algorithms.
 
An input feature source (such as vector layers) parameter for processing algorithms.