23QString QgsConcaveHullByFeatureAlgorithm::name()
const
25 return QStringLiteral(
"concavehullbyfeature" );
28QString QgsConcaveHullByFeatureAlgorithm::displayName()
const
30 return QObject::tr(
"Concave hull (by feature)" );
33QStringList QgsConcaveHullByFeatureAlgorithm::tags()
const
35 return QObject::tr(
"concave,hull,bounds,bounding,convex" ).split(
',' );
38QString QgsConcaveHullByFeatureAlgorithm::group()
const
40 return QObject::tr(
"Vector geometry" );
43QString QgsConcaveHullByFeatureAlgorithm::groupId()
const
45 return QStringLiteral(
"vectorgeometry" );
48QString QgsConcaveHullByFeatureAlgorithm::outputName()
const
50 return QObject::tr(
"Concave hulls" );
53QString QgsConcaveHullByFeatureAlgorithm::shortHelpString()
const
55 return QObject::tr(
"This algorithm calculates the concave hull for each feature in an input layer." ) + QStringLiteral(
"\n\n" )
56 + QObject::tr(
"A concave hull is a polygon which contains all the points of the input geometries, but is a better approximation than the convex hull to the area occupied by the input." ) + QStringLiteral(
"\n\n" )
57 + QObject::tr(
"It is frequently used to convert a multi-point into a polygonal area which contains all the points from the input geometry." ) + QStringLiteral(
"\n\n" )
58 + QObject::tr(
"See the 'Concave hull (by layer)' algorithm for a concave hull calculation which covers the whole layer or grouped subsets of features." );
61QString QgsConcaveHullByFeatureAlgorithm::shortDescription()
const
63 return QObject::tr(
"Calculates the concave hull for each feature in an input layer." );
66QgsConcaveHullByFeatureAlgorithm *QgsConcaveHullByFeatureAlgorithm::createInstance()
const
68 return new QgsConcaveHullByFeatureAlgorithm();
71void QgsConcaveHullByFeatureAlgorithm::initParameters(
const QVariantMap & )
77QList<int> QgsConcaveHullByFeatureAlgorithm::inputLayerTypes()
const
82QgsFields QgsConcaveHullByFeatureAlgorithm::outputFields(
const QgsFields &inputFields )
const
85 newFields.
append(
QgsField( QStringLiteral(
"area" ), QMetaType::Type::Double, QString(), 20, 6 ) );
86 newFields.
append(
QgsField( QStringLiteral(
"perimeter" ), QMetaType::Type::Double, QString(), 20, 6 ) );
92#if GEOS_VERSION_MAJOR == 3 && GEOS_VERSION_MINOR < 11
93 throw QgsProcessingException( QObject::tr(
"This algorithm requires a QGIS build based on GEOS 3.11 or later" ) );
95 mPercentage = parameterAsDouble( parameters, QStringLiteral(
"ALPHA" ), context );
96 mAllowHoles = parameterAsBool( parameters, QStringLiteral(
"HOLES" ), context );
107 const QgsGeometryCollection *collection = qgsgeometry_cast< const QgsGeometryCollection * >( inputGeometry );
110 feedback->
reportError( QObject::tr(
"Cannot calculate convex hull for a single point feature (%1) (try 'Concave hull (by layer)' algorithm instead)." ).arg( f.
id() ) );
116 if ( outputGeometry.
isNull() )
131 feedback->
pushWarning( QObject::tr(
"Concave hull for feature %1 resulted in a linestring, ignoring" ).arg( f.
id() ) );
135 feedback->
pushWarning( QObject::tr(
"Concave hull for feature %1 resulted in a point, ignoring" ).arg( f.
id() ) );
@ VectorPoint
Vector point layers.
@ Double
Double/float values.
Abstract base class for all geometries.
virtual double perimeter() const
Returns the planar, 2-dimensional perimeter of the geometry.
virtual double area() const
Returns the planar, 2-dimensional area of the geometry.
The feature class encapsulates a single feature including its unique ID, geometry and a list of field...
void setAttributes(const QgsAttributes &attrs)
Sets the feature's attributes.
void clearGeometry()
Removes any geometry associated with the feature.
bool hasGeometry() const
Returns true if the feature has an associated geometry.
void setGeometry(const QgsGeometry &geometry)
Set the feature's geometry.
Encapsulate a field in an attribute table or data source.
Container of fields for a vector layer.
bool append(const QgsField &field, Qgis::FieldOrigin origin=Qgis::FieldOrigin::Provider, int originIndex=-1)
Appends a field.
int numGeometries() const
Returns the number of geometries within the collection.
A geometry is the spatial representation of a feature.
QString lastError() const
Returns an error string referring to the last error encountered either when this geometry was created...
const QgsAbstractGeometry * constGet() const
Returns a non-modifiable (const) reference to the underlying abstract geometry primitive.
QgsGeometry concaveHull(double targetPercent, bool allowHoles=false) const
Returns a possibly concave polygon that contains all the points in the geometry.
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 pushWarning(const QString &warning)
Pushes a warning informational message from the algorithm.
virtual void reportError(const QString &error, bool fatalError=false)
Reports that the algorithm encountered an error while executing.
A boolean parameter for processing algorithms.
A numeric parameter for processing algorithms.
static QgsFields combineFields(const QgsFields &fieldsA, const QgsFields &fieldsB, const QString &fieldsBPrefix=QString())
Combines two field lists, avoiding duplicate field names (in a case-insensitive manner).
QList< QgsFeature > QgsFeatureList