24QString QgsRemovePartsByAreaAlgorithm::name()
 const 
   26  return QStringLiteral( 
"removepartsbyarea" );
 
   29QString QgsRemovePartsByAreaAlgorithm::displayName()
 const 
   31  return QObject::tr( 
"Remove parts by area" );
 
   34QStringList QgsRemovePartsByAreaAlgorithm::tags()
 const 
   36  return QObject::tr( 
"remove,delete,drop,filter,polygon,size" ).split( 
',' );
 
   39QString QgsRemovePartsByAreaAlgorithm::group()
 const 
   41  return QObject::tr( 
"Vector geometry" );
 
   44QString QgsRemovePartsByAreaAlgorithm::groupId()
 const 
   46  return QStringLiteral( 
"vectorgeometry" );
 
   49QString QgsRemovePartsByAreaAlgorithm::outputName()
 const 
   51  return QObject::tr( 
"Cleaned" );
 
   54QList<int> QgsRemovePartsByAreaAlgorithm::inputLayerTypes()
 const 
   64QString QgsRemovePartsByAreaAlgorithm::shortDescription()
 const 
   66  return QObject::tr( 
"Removes polygons which are smaller than a specified area." );
 
   69QString QgsRemovePartsByAreaAlgorithm::shortHelpString()
 const 
   71  return QObject::tr( 
"This algorithm takes a polygon layer and removes polygons which are smaller than a specified area.\n\n" 
   72                      "If the input geometry is a multipart geometry, then the parts will be filtered by their individual areas. If no parts match the " 
   73                      "required minimum area, then the feature will be skipped and omitted from the output layer.\n\n" 
   74                      "If the input geometry is a singlepart geometry, then the feature will be skipped if the geometry's " 
   75                      "area is below the required size and omitted from the output layer.\n\n" 
   76                      "The area will be calculated using Cartesian calculations in the source layer's coordinate reference system.\n\n" 
   77                      "Attributes are not modified." );
 
   80QgsRemovePartsByAreaAlgorithm *QgsRemovePartsByAreaAlgorithm::createInstance()
 const 
   82  return new QgsRemovePartsByAreaAlgorithm();
 
   91void QgsRemovePartsByAreaAlgorithm::initParameters( 
const QVariantMap & )
 
   93  std::unique_ptr< QgsProcessingParameterArea > minArea = std::make_unique< QgsProcessingParameterArea >( QStringLiteral( 
"MIN_AREA" ), QObject::tr( 
"Remove parts with area less than" ), 0.0, QStringLiteral( 
"INPUT" ), 
false, 0 );
 
   94  minArea->setIsDynamic( 
true );
 
   96  minArea->setDynamicLayerParameterName( QStringLiteral( 
"INPUT" ) );
 
   97  addParameter( minArea.release() );
 
  102  mMinArea = parameterAsDouble( parameters, QStringLiteral( 
"MIN_AREA" ), context );
 
  104  if ( mDynamicMinArea )
 
  105    mMinAreaProperty = parameters.value( QStringLiteral( 
"MIN_AREA" ) ).value< 
QgsProperty >();
 
  115    double minArea = mMinArea;
 
  116    if ( mDynamicMinArea )
 
  117      minArea = mMinAreaProperty.valueAsDouble( context.
expressionContext(), minArea );
 
  124      QgsGeometryCollection *collection = qgsgeometry_cast< QgsGeometryCollection * >( filteredGeometry.get() );
 
  125      const int size = inputCollection->numGeometries();
 
  127      for ( 
int i = 0; i < size; ++i )
 
  129        if ( 
const QgsSurface *surface = qgsgeometry_cast< const QgsSurface * >( inputCollection->geometryN( i ) ) )
 
  131          if ( surface->area() >= minArea )
 
  142      outputGeometry = 
QgsGeometry( std::move( filteredGeometry ) );
 
  145    else if ( 
const QgsSurface *surface = qgsgeometry_cast< const QgsSurface * >( geometry.
constGet() ) )
 
  147      if ( surface->area() < minArea )
 
ProcessingSourceType
Processing data source types.
 
@ VectorPolygon
Vector polygon layers.
 
@ SkipGeometryValidityChecks
Invalid geometry checks should always be skipped. This flag can be useful for algorithms which always...
 
QFlags< ProcessingFeatureSourceFlag > ProcessingFeatureSourceFlags
Flags which control how QgsProcessingFeatureSource fetches features.
 
virtual QgsAbstractGeometry * createEmptyWithSameType() const =0
Creates a new geometry with the same class and same WKB type as the original and transfers ownership.
 
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.
 
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.
 
int numGeometries() const
Returns the number of geometries within the collection.
 
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.
 
Contains information about the context in which a processing algorithm is executed.
 
QgsExpressionContext & expressionContext()
Returns the expression context.
 
Base class for providing feedback from a processing algorithm.
 
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...
 
Definition for a property.
 
@ DoublePositive
Positive double value (including 0)
 
A store for object properties.
 
QList< QgsFeature > QgsFeatureList