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
56 "This algorithm calculates the pole of inaccessibility for a polygon layer, which is the most "
57 "distant internal point from the boundary of the surface. This algorithm uses the 'polylabel' "
58 "algorithm (Vladimir Agafonkin, 2016), which is an iterative approach guaranteed to find the "
59 "true pole of inaccessibility within a specified tolerance (in layer units). More precise "
60 "tolerances require more iterations and will take longer to calculate."
64 "The distance from the calculated pole to the polygon boundary will be stored as a new "
65 "attribute in the output layer."
69QString QgsPoleOfInaccessibilityAlgorithm::shortDescription()
const
72 "Creates a point layer with features representing the most "
73 "distant internal point from the boundary of the surface for a polygon layer."
77QString QgsPoleOfInaccessibilityAlgorithm::svgIconPath()
const
82QIcon QgsPoleOfInaccessibilityAlgorithm::icon()
const
87QString QgsPoleOfInaccessibilityAlgorithm::outputName()
const
89 return QObject::tr(
"Point" );
92QList<int> QgsPoleOfInaccessibilityAlgorithm::inputLayerTypes()
const
104 Q_UNUSED( inputWkbType );
109QgsFields QgsPoleOfInaccessibilityAlgorithm::outputFields(
const QgsFields &inputFields )
const
112 newFields.
append(
QgsField( u
"dist_pole"_s, QMetaType::Type::Double ) );
117QgsPoleOfInaccessibilityAlgorithm *QgsPoleOfInaccessibilityAlgorithm::createInstance()
const
119 return new QgsPoleOfInaccessibilityAlgorithm();
122void QgsPoleOfInaccessibilityAlgorithm::initParameters(
const QVariantMap & )
124 auto toleranceParam = std::make_unique<QgsProcessingParameterDistance>( u
"TOLERANCE"_s, QObject::tr(
"Tolerance" ), 1.0, u
"INPUT"_s, 0.0 );
125 toleranceParam->setIsDynamic(
true );
127 toleranceParam->setDynamicLayerParameterName( u
"INPUT"_s );
128 addParameter( toleranceParam.release() );
133 mTolerance = parameterAsDouble( parameters, u
"TOLERANCE"_s, context );
135 if ( mDynamicTolerance )
136 mToleranceProperty = parameters.value( u
"TOLERANCE"_s ).value<
QgsProperty>();
146 double tolerance = mTolerance;
147 if ( mDynamicTolerance )
148 tolerance = mToleranceProperty.valueAsDouble( context.
expressionContext(), tolerance );
152 if ( outputGeom.
isNull() )
157 attrs.append( distance );
164 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