26QString QgsKeepNBiggestPartsAlgorithm::name()
 const 
   28  return QStringLiteral( 
"keepnbiggestparts" );
 
   31QString QgsKeepNBiggestPartsAlgorithm::displayName()
 const 
   33  return QObject::tr( 
"Keep N biggest parts" );
 
   36QStringList QgsKeepNBiggestPartsAlgorithm::tags()
 const 
   38  return QObject::tr( 
"remove,delete,drop,largest,area,filter" ).split( 
',' );
 
   41QString QgsKeepNBiggestPartsAlgorithm::group()
 const 
   43  return QObject::tr( 
"Vector geometry" );
 
   46QString QgsKeepNBiggestPartsAlgorithm::groupId()
 const 
   48  return QStringLiteral( 
"vectorgeometry" );
 
   51QString QgsKeepNBiggestPartsAlgorithm::outputName()
 const 
   53  return QObject::tr( 
"Parts" );
 
   56QList<int> QgsKeepNBiggestPartsAlgorithm::inputLayerTypes()
 const 
   66QString QgsKeepNBiggestPartsAlgorithm::shortHelpString()
 const 
   68  return QObject::tr( 
"This algorithm takes a polygon layer and creates a new polygon layer in which multipart " 
   69                      "geometries have been removed, leaving only the n largest (in terms of area) parts." );
 
   72QString QgsKeepNBiggestPartsAlgorithm::shortDescription()
 const 
   74  return QObject::tr( 
"Creates a polygon layer in which multipart geometries have been removed, " 
   75                      "leaving only the n largest (in terms of area) parts." );
 
   78QgsKeepNBiggestPartsAlgorithm *QgsKeepNBiggestPartsAlgorithm::createInstance()
 const 
   80  return new QgsKeepNBiggestPartsAlgorithm();
 
   89void QgsKeepNBiggestPartsAlgorithm::initParameters( 
const QVariantMap & )
 
   92  partsToKeep->setIsDynamic( 
true );
 
   94  partsToKeep->setDynamicLayerParameterName( QStringLiteral( 
"POLYGONS" ) );
 
   95  addParameter( partsToKeep.release() );
 
   98QString QgsKeepNBiggestPartsAlgorithm::inputParameterName()
 const 
  100  return QStringLiteral( 
"POLYGONS" );
 
  105  mPartsToKeep = parameterAsInt( parameters, QStringLiteral( 
"PARTS" ), context );
 
  107  if ( mDynamicPartsToKeep )
 
  108    mPartsToKeepProperty = parameters.value( QStringLiteral( 
"PARTS" ) ).value<
QgsProperty>();
 
  124      int nPartsToKeep = mPartsToKeep;
 
  125      if ( mDynamicPartsToKeep )
 
  126        nPartsToKeep = mPartsToKeepProperty.valueAsInt( context.
expressionContext(), nPartsToKeep );
 
  128      const int numParts = collection->numGeometries();
 
  129      if ( nPartsToKeep >= numParts )
 
  132        outputGeometry = geometry;
 
  136        struct GreaterThanByArea
 
  145        std::priority_queue<const QgsAbstractGeometry *, std::vector<const QgsAbstractGeometry *>, GreaterThanByArea> areaQueue;
 
  146        for ( 
int i = 0; i < numParts; ++i )
 
  148          areaQueue.push( collection->geometryN( i ) );
 
  151        for ( 
int i = 0; i < nPartsToKeep; ++i )
 
  155          res->addGeometry( part->
clone() );
 
  163      outputGeometry = geometry;
 
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.
 
Abstract base class for all geometries.
 
virtual double area() const
Returns the planar, 2-dimensional area of the geometry.
 
virtual QgsAbstractGeometry * clone() const =0
Clones the geometry by performing a deep copy.
 
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.
 
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.
 
bool convertToMultiType()
Converts single type geometry into multitype geometry e.g.
 
Multi polygon geometry collection.
 
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.
 
@ IntegerPositive
Positive integer values (including 0)
 
A store for object properties.
 
static Q_INVOKABLE bool isCurvedType(Qgis::WkbType type)
Returns true if the WKB type is a curved type or can contain curved geometries.
 
QList< QgsFeature > QgsFeatureList