23 QString QgsPointOnSurfaceAlgorithm::name()
const 25 return QStringLiteral(
"pointonsurface" );
28 QString QgsPointOnSurfaceAlgorithm::displayName()
const 30 return QObject::tr(
"Point on surface" );
33 QStringList QgsPointOnSurfaceAlgorithm::tags()
const 35 return QObject::tr(
"centroid,inside,within" ).split(
',' );
38 QString QgsPointOnSurfaceAlgorithm::group()
const 40 return QObject::tr(
"Vector geometry" );
43 QString QgsPointOnSurfaceAlgorithm::groupId()
const 45 return QStringLiteral(
"vectorgeometry" );
48 QString QgsPointOnSurfaceAlgorithm::outputName()
const 50 return QObject::tr(
"Point" );
53 QString QgsPointOnSurfaceAlgorithm::shortHelpString()
const 55 return QObject::tr(
"Returns a point guaranteed to lie on the surface of a geometry." );
58 QgsPointOnSurfaceAlgorithm *QgsPointOnSurfaceAlgorithm::createInstance()
const 60 return new QgsPointOnSurfaceAlgorithm();
63 void QgsPointOnSurfaceAlgorithm::initParameters(
const QVariantMap & )
65 std::unique_ptr< QgsProcessingParameterBoolean> allParts = qgis::make_unique< QgsProcessingParameterBoolean >(
66 QStringLiteral(
"ALL_PARTS" ),
67 QObject::tr(
"Create point on surface for each part" ),
69 allParts->setIsDynamic(
true );
71 allParts->setDynamicLayerParameterName( QStringLiteral(
"INPUT" ) );
72 addParameter( allParts.release() );
77 mAllParts = parameterAsBool( parameters, QStringLiteral(
"ALL_PARTS" ), context );
79 if ( mDynamicAllParts )
80 mAllPartsProperty = parameters.value( QStringLiteral(
"ALL_PARTS" ) ).value<
QgsProperty >();
93 bool allParts = mAllParts;
94 if ( mDynamicAllParts )
95 allParts = mAllPartsProperty.valueAsBool( context.
expressionContext(), allParts );
101 for (
int i = 0; i < geomCollection->
partCount(); ++i )
105 if ( outputGeometry.isNull() )
107 feedback->
pushInfo( QObject::tr(
"Error calculating point on surface for feature %1 part %2: %3" ).arg( feature.
id() ).arg( i ).arg( outputGeometry.lastError() ) );
116 if ( outputGeometry.
isNull() )
118 feedback->
pushInfo( QObject::tr(
"Error calculating point on surface for feature %1: %2" ).arg( feature.
id() ).arg( outputGeometry.
lastError() ) );
QgsGeometry pointOnSurface() const
Returns a point guaranteed to lie on the surface of a geometry.
Base class for providing feedback from a processing algorithm.
bool isNull() const
Returns true if the geometry is null (ie, contains no underlying geometry accessible via geometry() )...
QList< QgsFeature > QgsFeatureList
A geometry is the spatial representation of a feature.
const QgsAbstractGeometry * geometryN(int n) const
Returns a const reference to a geometry from within the collection.
The feature class encapsulates a single feature including its id, geometry and a list of field/values...
virtual QgsAbstractGeometry * clone() const =0
Clones the geometry by performing a deep copy.
const QgsAbstractGeometry * constGet() const
Returns a non-modifiable (const) reference to the underlying abstract geometry primitive.
QString lastError() const
Returns an error string referring to the last error encountered either when this geometry was created...
A store for object properties.
QgsExpressionContext & expressionContext()
Returns the expression context.
Definition for a property.
int partCount() const override
Returns count of parts contained in the geometry.
bool isMultipart() const
Returns true if WKB of the geometry is of WKBMulti* type.
void setGeometry(const QgsGeometry &geometry)
Set the feature's geometry.
bool hasGeometry() const
Returns true if the feature has an associated geometry.
Contains information about the context in which a processing algorithm is executed.
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...
virtual void pushInfo(const QString &info)
Pushes a general informational message from the algorithm.