25using namespace Qt::StringLiterals;
29QString QgsPoleOfInaccessibilityAlgorithm::name()
const
31 return u
"poleofinaccessibility"_s;
34QString QgsPoleOfInaccessibilityAlgorithm::displayName()
const
36 return QObject::tr(
"Pole of inaccessibility" );
39QStringList QgsPoleOfInaccessibilityAlgorithm::tags()
const
41 return QObject::tr(
"furthest,point,distant,extreme,maximum,centroid,center,centre" ).split(
',' );
44QString QgsPoleOfInaccessibilityAlgorithm::group()
const
46 return QObject::tr(
"Vector geometry" );
49QString QgsPoleOfInaccessibilityAlgorithm::groupId()
const
51 return u
"vectorgeometry"_s;
54QString QgsPoleOfInaccessibilityAlgorithm::shortHelpString()
const
57 "This algorithm calculates the pole of inaccessibility for a polygon layer, which is the most "
58 "distant internal point from the boundary of the surface. This algorithm uses the 'polylabel' "
59 "algorithm (Vladimir Agafonkin, 2016), which is an iterative approach guaranteed to find the "
60 "true pole of inaccessibility within a specified tolerance (in layer units). More precise "
61 "tolerances require more iterations and will take longer to calculate."
65 "The distance from the calculated pole to the polygon boundary will be stored as a new "
66 "attribute in the output layer."
70QString QgsPoleOfInaccessibilityAlgorithm::shortDescription()
const
73 "Creates a point layer with features representing the most "
74 "distant internal point from the boundary of the surface for a polygon layer."
78QList<QgsAcademicReference> QgsPoleOfInaccessibilityAlgorithm::academicReferences()
const
81 createWebPage( { u
"Agafonkin, V."_s }, 2016, u
"A new algorithm for finding a visual center of a polygon"_s, u
"https://medium.com/mapbox/a-new-algorithm-for-finding-a-visual-center-of-a-polygon-7c77e6492fbc"_s );
82 return { agafonkinReference };
85QString QgsPoleOfInaccessibilityAlgorithm::svgIconPath()
const
90QIcon QgsPoleOfInaccessibilityAlgorithm::icon()
const
95QString QgsPoleOfInaccessibilityAlgorithm::outputName()
const
97 return QObject::tr(
"Point" );
100QList<int> QgsPoleOfInaccessibilityAlgorithm::inputLayerTypes()
const
112 Q_UNUSED( inputWkbType );
117QgsFields QgsPoleOfInaccessibilityAlgorithm::outputFields(
const QgsFields &inputFields )
const
120 newFields.
append(
QgsField( u
"dist_pole"_s, QMetaType::Type::Double ) );
125QgsPoleOfInaccessibilityAlgorithm *QgsPoleOfInaccessibilityAlgorithm::createInstance()
const
127 return new QgsPoleOfInaccessibilityAlgorithm();
130void QgsPoleOfInaccessibilityAlgorithm::initParameters(
const QVariantMap & )
132 auto toleranceParam = std::make_unique<QgsProcessingParameterDistance>( u
"TOLERANCE"_s, QObject::tr(
"Tolerance" ), 1.0, u
"INPUT"_s, 0.0 );
133 toleranceParam->setIsDynamic(
true );
135 toleranceParam->setDynamicLayerParameterName( u
"INPUT"_s );
136 addParameter( toleranceParam.release() );
141 mTolerance = parameterAsDouble( parameters, u
"TOLERANCE"_s, context );
143 if ( mDynamicTolerance )
144 mToleranceProperty = parameters.value( u
"TOLERANCE"_s ).value<
QgsProperty>();
151 QGS_MARK_ALGORITHM_SOURCE
154 if ( outFeature.hasGeometry() )
156 double tolerance = mTolerance;
157 if ( mDynamicTolerance )
158 tolerance = mToleranceProperty.valueAsDouble( context.
expressionContext(), tolerance );
162 if ( outputGeom.
isNull() )
167 attrs.append( distance );
168 outFeature.setAttributes( attrs );
169 outFeature.setGeometry( outputGeom );
174 attrs.append( QVariant() );
175 outFeature.setAttributes( attrs );
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.
Encapsulates an academic reference and formats it according to style guidelines.
static QgsAcademicReference createWebPage(const QStringList &authors, int year, const QString &title, const QString &url)
Creates a web page or online resource reference.
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...
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