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 QgsFeatureSink::SinkFlags QgsPointOnSurfaceAlgorithm::sinkFlags()
 const 
   61 QString QgsPointOnSurfaceAlgorithm::shortHelpString()
 const 
   63   return QObject::tr( 
"Returns a point guaranteed to lie on the surface of a geometry." );
 
   66 QgsPointOnSurfaceAlgorithm *QgsPointOnSurfaceAlgorithm::createInstance()
 const 
   68   return new QgsPointOnSurfaceAlgorithm();
 
   71 void QgsPointOnSurfaceAlgorithm::initParameters( 
const QVariantMap & )
 
   73   std::unique_ptr< QgsProcessingParameterBoolean> allParts = std::make_unique< QgsProcessingParameterBoolean >(
 
   74         QStringLiteral( 
"ALL_PARTS" ),
 
   75         QObject::tr( 
"Create point on surface for each part" ),
 
   77   allParts->setIsDynamic( 
true );
 
   79   allParts->setDynamicLayerParameterName( QStringLiteral( 
"INPUT" ) );
 
   80   addParameter( allParts.release() );
 
   85   mAllParts = parameterAsBoolean( parameters, QStringLiteral( 
"ALL_PARTS" ), context );
 
   87   if ( mDynamicAllParts )
 
   88     mAllPartsProperty = parameters.value( QStringLiteral( 
"ALL_PARTS" ) ).value< 
QgsProperty >();
 
  101     bool allParts = mAllParts;
 
  102     if ( mDynamicAllParts )
 
  103       allParts = mAllPartsProperty.valueAsBool( context.
expressionContext(), allParts );
 
  109       const int partCount = geomCollection->
partCount();
 
  110       list.reserve( partCount );
 
  111       for ( 
int i = 0; i < partCount; ++i )
 
  115         if ( outputGeometry.
isNull() )
 
  117           feedback->
reportError( QObject::tr( 
"Error calculating point on surface for feature %1 part %2: %3" ).arg( feature.
id() ).arg( i ).arg( outputGeometry.
lastError() ) );
 
  126       if ( outputGeometry.
isNull() )
 
  128         feedback->
reportError( QObject::tr( 
"Error calculating point on surface for feature %1: %2" ).arg( feature.
id() ).arg( outputGeometry.
lastError() ) );
 
virtual QgsAbstractGeometry * clone() const =0
Clones the geometry by performing a deep copy.
@ RegeneratePrimaryKey
This flag indicates, that a primary key field cannot be guaranteed to be unique and the sink should i...
The feature class encapsulates a single feature including its unique ID, geometry and a list of field...
bool hasGeometry() const
Returns true if the feature has an associated geometry.
void setGeometry(const QgsGeometry &geometry)
Set the feature's geometry.
const QgsAbstractGeometry * geometryN(int n) const
Returns a const reference to a geometry from within the collection.
int partCount() const override
Returns count of parts contained in the geometry.
A geometry is the spatial representation of a feature.
const QgsAbstractGeometry * constGet() const SIP_HOLDGIL
Returns a non-modifiable (const) reference to the underlying abstract geometry primitive.
QgsGeometry pointOnSurface() const
Returns a point guaranteed to lie on the surface of a geometry.
bool isMultipart() const SIP_HOLDGIL
Returns true if WKB of the geometry is of WKBMulti* type.
QString lastError() const SIP_HOLDGIL
Returns an error string referring to the last error encountered either when this geometry was created...
bool isEmpty() const
Returns true if the geometry is empty (eg a linestring with no vertices, or a collection with no geom...
Contains information about the context in which a processing algorithm is executed.
QgsExpressionContext & expressionContext()
Returns the expression context.
virtual QgsFeatureSink::SinkFlags sinkFlags() const
Returns the feature sink flags to be used for the output.
Base class for providing feedback from a processing algorithm.
virtual void reportError(const QString &error, bool fatalError=false)
Reports that the algorithm encountered an error while executing.
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...
Definition for a property.
A store for object properties.
QList< QgsFeature > QgsFeatureList