23QString QgsPoleOfInaccessibilityAlgorithm::name()
const
25 return QStringLiteral(
"poleofinaccessibility" );
28QString QgsPoleOfInaccessibilityAlgorithm::displayName()
const
30 return QObject::tr(
"Pole of inaccessibility" );
33QStringList QgsPoleOfInaccessibilityAlgorithm::tags()
const
35 return QObject::tr(
"furthest,point,distant,extreme,maximum,centroid,center,centre" ).split(
',' );
38QString QgsPoleOfInaccessibilityAlgorithm::group()
const
40 return QObject::tr(
"Vector geometry" );
43QString QgsPoleOfInaccessibilityAlgorithm::groupId()
const
45 return QStringLiteral(
"vectorgeometry" );
48QString QgsPoleOfInaccessibilityAlgorithm::shortHelpString()
const
50 return QObject::tr(
"This algorithm calculates the pole of inaccessibility for a polygon layer, which is the most "
51 "distant internal point from the boundary of the surface. This algorithm uses the 'polylabel' "
52 "algorithm (Vladimir Agafonkin, 2016), which is an iterative approach guaranteed to find the "
53 "true pole of inaccessibility within a specified tolerance (in layer units). More precise "
54 "tolerances require more iterations and will take longer to calculate." )
55 + QStringLiteral(
"\n\n" )
56 + QObject::tr(
"The distance from the calculated pole to the polygon boundary will be stored as a new "
57 "attribute in the output layer." );
60QString QgsPoleOfInaccessibilityAlgorithm::svgIconPath()
const
65QIcon QgsPoleOfInaccessibilityAlgorithm::icon()
const
70QString QgsPoleOfInaccessibilityAlgorithm::outputName()
const
72 return QObject::tr(
"Point" );
75QList<int> QgsPoleOfInaccessibilityAlgorithm::inputLayerTypes()
const
87 Q_UNUSED( inputWkbType );
92QgsFields QgsPoleOfInaccessibilityAlgorithm::outputFields(
const QgsFields &inputFields )
const
95 outputFields.
append(
QgsField( QStringLiteral(
"dist_pole" ), QVariant::Double ) );
100QgsPoleOfInaccessibilityAlgorithm *QgsPoleOfInaccessibilityAlgorithm::createInstance()
const
102 return new QgsPoleOfInaccessibilityAlgorithm();
105void QgsPoleOfInaccessibilityAlgorithm::initParameters(
const QVariantMap & )
107 auto toleranceParam = std::make_unique < QgsProcessingParameterDistance >( QStringLiteral(
"TOLERANCE" ), QObject::tr(
"Tolerance" ), 1.0, QStringLiteral(
"INPUT" ), 0.0 );
108 toleranceParam->setIsDynamic(
true );
110 toleranceParam->setDynamicLayerParameterName( QStringLiteral(
"INPUT" ) );
111 addParameter( toleranceParam.release() );
116 mTolerance = parameterAsDouble( parameters, QStringLiteral(
"TOLERANCE" ), context );
118 if ( mDynamicTolerance )
119 mToleranceProperty = parameters.value( QStringLiteral(
"TOLERANCE" ) ).value<
QgsProperty >();
129 double tolerance = mTolerance;
130 if ( mDynamicTolerance )
131 tolerance = mToleranceProperty.valueAsDouble( context.
expressionContext(), tolerance );
135 if ( outputGeom.
isNull() )
140 attrs.append( distance );
147 attrs.append( QVariant() );
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, FieldOrigin origin=OriginProvider, int originIndex=-1)
Appends a field. The field must have unique name, otherwise it is rejected (returns false)
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...
SourceType
Data source types enum.
@ TypeVectorPolygon
Vector polygon layers.
@ TypeVectorPoint
Vector point layers.
Definition for a property.
@ Double
Double value (including negative values)
A store for object properties.
Type
The WKB type describes the number of dimensions a geometry has.
QList< QgsFeature > QgsFeatureList