26QString QgsConcaveHullAlgorithm::name()
 const 
   28  return QStringLiteral( 
"concavehull" );
 
   31QString QgsConcaveHullAlgorithm::displayName()
 const 
   33  return QObject::tr( 
"Concave hull (by layer)" );
 
   36QStringList QgsConcaveHullAlgorithm::tags()
 const 
   38  return QObject::tr( 
"concave,hull,bounds,bounding" ).split( 
',' );
 
   41QString QgsConcaveHullAlgorithm::group()
 const 
   43  return QObject::tr( 
"Vector geometry" );
 
   46QString QgsConcaveHullAlgorithm::groupId()
 const 
   48  return QStringLiteral( 
"vectorgeometry" );
 
   51QString QgsConcaveHullAlgorithm::shortHelpString()
 const 
   53  return QObject::tr( 
"This algorithm computes the concave hull covering all features from an input point layer." ) + QStringLiteral( 
"\n\n" )
 
   54         + QObject::tr( 
"See the 'Concave hull (by feature)' algorithm for a concave hull calculation which covers individual features from a layer." );
 
   57QString QgsConcaveHullAlgorithm::shortDescription()
 const 
   59  return QObject::tr( 
"Computes the concave hull of all features from an input point layer." );
 
   62QgsConcaveHullAlgorithm *QgsConcaveHullAlgorithm::createInstance()
 const 
   64  return new QgsConcaveHullAlgorithm();
 
   67void QgsConcaveHullAlgorithm::initAlgorithm( 
const QVariantMap & )
 
   72  addParameter( 
new QgsProcessingParameterBoolean( QStringLiteral( 
"NO_MULTIGEOMETRY" ), QObject::tr( 
"Split multipart geometry into singleparts" ), 
false ) );
 
   78  mSource.reset( parameterAsSource( parameters, QStringLiteral( 
"INPUT" ), context ) );
 
   82  if ( mSource->featureCount() < 3 )
 
   85  mStep = mSource->featureCount() > 0 ? 50.0 / mSource->featureCount() : 1;
 
   87  mPercentage = parameterAsDouble( parameters, QStringLiteral( 
"ALPHA" ), context );
 
   88  mAllowHoles = parameterAsBool( parameters, QStringLiteral( 
"HOLES" ), context );
 
   89  mSplitMultipart = parameterAsBool( parameters, QStringLiteral( 
"NO_MULTIGEOMETRY" ), context );
 
   97  std::unique_ptr<QgsFeatureSink> sink( parameterAsSink( parameters, QStringLiteral( 
"OUTPUT" ), context, dest, 
QgsFields(), 
Qgis::WkbType::Polygon, mSource->sourceCrs() ) );
 
  101#if GEOS_VERSION_MAJOR == 3 && GEOS_VERSION_MINOR < 11 
  102  concaveHullQgis( sink, parameters, context, feedback );
 
  104  concaveHullGeos( sink, parameters, feedback );
 
  110  outputs.insert( QStringLiteral( 
"OUTPUT" ), dest );
 
  114void QgsConcaveHullAlgorithm::concaveHullGeos( std::unique_ptr<QgsFeatureSink> &sink, 
const QVariantMap ¶meters, 
QgsProcessingFeedback *feedback )
 
  135      const QgsMultiPoint mp( *qgsgeometry_cast<const QgsMultiPoint *>( geom ) );
 
  136      for ( 
auto pit = mp.const_parts_begin(); pit != mp.const_parts_end(); ++pit )
 
  148  if ( mSplitMultipart && concaveHull.
isMultipart() )
 
  151    mStep = collection.length() > 0 ? 50.0 / collection.length() : 1;
 
  152    for ( 
int i = 0; i < collection.length(); i++ )
 
  191  feedback->
setProgressText( QObject::tr( 
"Creating Delaunay triangles…" ) );
 
  192  multiStepFeedback.setCurrentStep( 1 );
 
  195  params[
"INPUT"] = parameters[
"INPUT"];
 
  196  params[
"TOLERANCE"] = 0.0;
 
  197  params[
"ADD_ATTRIBUTES"] = 
false;
 
  202    throw QgsProcessingException( QObject::tr( 
"Failed to compute concave hull: Delaunay triangulation algorithm not found!" ) );
 
  205  std::unique_ptr<QgsProcessingAlgorithm> 
algorithm;
 
  207  QVariantMap results = 
algorithm->
run( params, context, &multiStepFeedback );
 
  220  feedback->
setProgressText( QObject::tr( 
"Computing edges max length…" ) );
 
  221  multiStepFeedback.setCurrentStep( 2 );
 
  223  QVector<double> length;
 
  224  QMap<long, double> edges;
 
  235    multiStepFeedback.setProgress( i * step );
 
  241    for ( 
int j = 0; j < points.size() - 1; j++ )
 
  243      length << std::sqrt( points.at( j ).sqrDist( points.at( j + 1 ) ) );
 
  245    QVector<double> vec = length.mid( length.size() - 3, -1 );
 
  246    edges[f.
id()] = *std::max_element( vec.constBegin(), vec.constEnd() );
 
  248  const double maxLength = *std::max_element( length.constBegin(), length.constEnd() );
 
  251  multiStepFeedback.setCurrentStep( 3 );
 
  253  step = edges.size() > 0 ? 100.0 / edges.size() : 1;
 
  255  QMap<long, double>::iterator edgesIt = edges.begin();
 
  256  while ( edgesIt != edges.end() )
 
  261    if ( edgesIt.value() > mPercentage * maxLength )
 
  263      toDelete << edgesIt.key();
 
  268    multiStepFeedback.setProgress( i * step );
 
  272  feedback->
setProgressText( QObject::tr( 
"Dissolving Delaunay triangles…" ) );
 
  273  multiStepFeedback.setCurrentStep( 4 );
 
  275  params[
"INPUT"] = layer->
source();
 
  280    throw QgsProcessingException( QObject::tr( 
"Failed to compute concave hull: Dissolve algorithm not found!" ) );
 
  283  results = 
algorithm->
run( params, context, &multiStepFeedback );
 
  298  multiStepFeedback.setCurrentStep( 5 );
 
  300  if ( mSplitMultipart && concaveHull.
isMultipart() )
 
  303    step = collection.length() > 0 ? 50.0 / collection.length() : 1;
 
  304    for ( 
int i = 0; i < collection.length(); i++ )
 
  321      multiStepFeedback.setProgress( i * step );
 
  335    multiStepFeedback.setProgress( 100 );
 
@ VectorPoint
Vector point layers.
 
@ VectorPolygon
Vector polygon layers.
 
@ SkipGeometryValidityChecks
Invalid geometry checks should always be skipped. This flag can be useful for algorithms which always...
 
@ Double
Double/float values.
 
Abstract base class for all geometries.
 
Qgis::WkbType wkbType() const
Returns the WKB type of the geometry.
 
static QgsProcessingRegistry * processingRegistry()
Returns the application's processing registry, used for managing processing providers,...
 
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.
 
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.
 
A geometry is the spatial representation of a feature.
 
QgsPolygonXY asPolygon() const
Returns the contents of the geometry as a polygon.
 
QVector< QgsGeometry > asGeometryCollection() const
Returns contents of the geometry as a list of geometries.
 
const QgsAbstractGeometry * constGet() const
Returns a non-modifiable (const) reference to the underlying abstract geometry primitive.
 
bool isMultipart() const
Returns true if WKB of the geometry is of WKBMulti* type.
 
QgsGeometry concaveHull(double targetPercent, bool allowHoles=false) const
Returns a possibly concave polygon that contains all the points in the geometry.
 
Qgis::GeometryOperationResult addPartV2(const QVector< QgsPointXY > &points, Qgis::WkbType wkbType=Qgis::WkbType::Unknown)
Adds a new part to a the geometry.
 
QgsGeometry removeInteriorRings(double minimumAllowedArea=-1) const
Removes the interior rings from a (multi)polygon geometry.
 
QString source() const
Returns the source for the layer.
 
Multi point geometry collection.
 
Abstract base class for processing algorithms.
 
QVariantMap run(const QVariantMap ¶meters, QgsProcessingContext &context, QgsProcessingFeedback *feedback, bool *ok=nullptr, const QVariantMap &configuration=QVariantMap(), bool catchExceptions=true) const
Executes the algorithm using the specified parameters.
 
QgsProcessingAlgorithm * create(const QVariantMap &configuration=QVariantMap()) const
Creates a copy of the algorithm, ready for execution.
 
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 setProgressText(const QString &text)
Sets a progress report text string.
 
Processing feedback object for multi-step operations.
 
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.
 
A numeric parameter for processing algorithms.
 
const QgsProcessingAlgorithm * algorithmById(const QString &id) const
Finds an algorithm by its ID.
 
static QgsMapLayer * mapLayerFromString(const QString &string, QgsProcessingContext &context, bool allowLoadingNewLayers=true, QgsProcessingUtils::LayerHint typeHint=QgsProcessingUtils::LayerHint::UnknownType, QgsProcessing::LayerOptionsFlags flags=QgsProcessing::LayerOptionsFlags())
Interprets a string as a map layer within the supplied context.
 
static const QString TEMPORARY_OUTPUT
Constant used to indicate that a Processing algorithm output should be a temporary layer/file.
 
virtual bool deleteFeatures(const QgsFeatureIds &id)
Deletes one or more features from the provider.
 
Represents a vector layer which manages a vector based dataset.
 
long long featureCount(const QString &legendKey) const
Number of features rendered with specified legend key.
 
QgsFeatureIterator getFeatures(const QgsFeatureRequest &request=QgsFeatureRequest()) const FINAL
Queries the layer for features specified in request.
 
QgsVectorDataProvider * dataProvider() FINAL
Returns the layer's data provider, it may be nullptr.
 
static Q_INVOKABLE bool isMultiType(Qgis::WkbType type)
Returns true if the WKB type is a multi type.
 
As part of the API refactoring and improvements which landed in the Processing API was substantially reworked from the x version This was done in order to allow much of the underlying Processing framework to be ported into allowing algorithms to be written in pure substantial changes are required in order to port existing x Processing algorithms for QGIS x The most significant changes are outlined not GeoAlgorithm For algorithms which operate on features one by consider subclassing the QgsProcessingFeatureBasedAlgorithm class This class allows much of the boilerplate code for looping over features from a vector layer to be bypassed and instead requires implementation of a processFeature method Ensure that your algorithm(or algorithm 's parent class) implements the new pure virtual createInstance(self) call
 
QSet< QgsFeatureId > QgsFeatureIds