23 QString QgsPoleOfInaccessibilityAlgorithm::name()
const
25 return QStringLiteral(
"poleofinaccessibility" );
28 QString QgsPoleOfInaccessibilityAlgorithm::displayName()
const
30 return QObject::tr(
"Pole of inaccessibility" );
33 QStringList QgsPoleOfInaccessibilityAlgorithm::tags()
const
35 return QObject::tr(
"furthest,point,distant,extreme,maximum,centroid,center,centre" ).split(
',' );
38 QString QgsPoleOfInaccessibilityAlgorithm::group()
const
40 return QObject::tr(
"Vector geometry" );
43 QString QgsPoleOfInaccessibilityAlgorithm::groupId()
const
45 return QStringLiteral(
"vectorgeometry" );
48 QString 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." );
60 QString QgsPoleOfInaccessibilityAlgorithm::svgIconPath()
const
65 QIcon QgsPoleOfInaccessibilityAlgorithm::icon()
const
70 QString QgsPoleOfInaccessibilityAlgorithm::outputName()
const
72 return QObject::tr(
"Point" );
75 QList<int> QgsPoleOfInaccessibilityAlgorithm::inputLayerTypes()
const
87 Q_UNUSED( inputWkbType );
92 QgsFields QgsPoleOfInaccessibilityAlgorithm::outputFields(
const QgsFields &inputFields )
const
95 outputFields.
append(
QgsField( QStringLiteral(
"dist_pole" ), QVariant::Double ) );
100 QgsPoleOfInaccessibilityAlgorithm *QgsPoleOfInaccessibilityAlgorithm::createInstance()
const
102 return new QgsPoleOfInaccessibilityAlgorithm();
105 void QgsPoleOfInaccessibilityAlgorithm::initParameters(
const QVariantMap & )
107 auto toleranceParam = qgis::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() );