24using namespace Qt::StringLiterals;
28QString QgsPoleOfInaccessibilityAlgorithm::name()
const
30 return u
"poleofinaccessibility"_s;
33QString QgsPoleOfInaccessibilityAlgorithm::displayName()
const
35 return QObject::tr(
"Pole of inaccessibility" );
38QStringList QgsPoleOfInaccessibilityAlgorithm::tags()
const
40 return QObject::tr(
"furthest,point,distant,extreme,maximum,centroid,center,centre" ).split(
',' );
43QString QgsPoleOfInaccessibilityAlgorithm::group()
const
45 return QObject::tr(
"Vector geometry" );
48QString QgsPoleOfInaccessibilityAlgorithm::groupId()
const
50 return u
"vectorgeometry"_s;
53QString QgsPoleOfInaccessibilityAlgorithm::shortHelpString()
const
55 return QObject::tr(
"This algorithm calculates the pole of inaccessibility for a polygon layer, which is the most "
56 "distant internal point from the boundary of the surface. This algorithm uses the 'polylabel' "
57 "algorithm (Vladimir Agafonkin, 2016), which is an iterative approach guaranteed to find the "
58 "true pole of inaccessibility within a specified tolerance (in layer units). More precise "
59 "tolerances require more iterations and will take longer to calculate." )
61 + QObject::tr(
"The distance from the calculated pole to the polygon boundary will be stored as a new "
62 "attribute in the output layer." );
65QString QgsPoleOfInaccessibilityAlgorithm::shortDescription()
const
67 return QObject::tr(
"Creates a point layer with features representing the most "
68 "distant internal point from the boundary of the surface for a polygon layer." );
71QString QgsPoleOfInaccessibilityAlgorithm::svgIconPath()
const
76QIcon QgsPoleOfInaccessibilityAlgorithm::icon()
const
81QString QgsPoleOfInaccessibilityAlgorithm::outputName()
const
83 return QObject::tr(
"Point" );
86QList<int> QgsPoleOfInaccessibilityAlgorithm::inputLayerTypes()
const
98 Q_UNUSED( inputWkbType );
103QgsFields QgsPoleOfInaccessibilityAlgorithm::outputFields(
const QgsFields &inputFields )
const
106 newFields.
append(
QgsField( u
"dist_pole"_s, QMetaType::Type::Double ) );
111QgsPoleOfInaccessibilityAlgorithm *QgsPoleOfInaccessibilityAlgorithm::createInstance()
const
113 return new QgsPoleOfInaccessibilityAlgorithm();
116void QgsPoleOfInaccessibilityAlgorithm::initParameters(
const QVariantMap & )
118 auto toleranceParam = std::make_unique<QgsProcessingParameterDistance>( u
"TOLERANCE"_s, QObject::tr(
"Tolerance" ), 1.0, u
"INPUT"_s, 0.0 );
119 toleranceParam->setIsDynamic(
true );
121 toleranceParam->setDynamicLayerParameterName( u
"INPUT"_s );
122 addParameter( toleranceParam.release() );
127 mTolerance = parameterAsDouble( parameters, u
"TOLERANCE"_s, context );
129 if ( mDynamicTolerance )
130 mToleranceProperty = parameters.value( u
"TOLERANCE"_s ).value<
QgsProperty>();
140 double tolerance = mTolerance;
141 if ( mDynamicTolerance )
142 tolerance = mToleranceProperty.valueAsDouble( context.
expressionContext(), tolerance );
146 if ( outputGeom.
isNull() )
151 attrs.append( distance );
158 attrs.append( QVariant() );
ProcessingSourceType
Processing data source types.
@ VectorPoint
Vector point layers.
@ VectorPolygon
Vector polygon layers.
WkbType
The WKB type describes the number of dimensions a geometry has.
static QIcon getThemeIcon(const QString &name, const QColor &fillColor=QColor(), const QColor &strokeColor=QColor())
Helper to get a theme icon.
static QString iconPath(const QString &iconFile)
Returns path to the desired icon file.
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.
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.
A geometry is the spatial representation of a feature.
QgsGeometry poleOfInaccessibility(double precision, double *distanceToBoundary=nullptr) const
Calculates the approximate pole of inaccessibility for a surface, which is the most distant internal ...
Contains information about the context in which a processing algorithm is executed.
QgsExpressionContext & expressionContext()
Returns the expression context.
Custom exception class for processing related exceptions.
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...
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).
Definition for a property.
@ Double
Double value (including negative values).
A store for object properties.
QList< QgsFeature > QgsFeatureList