22using namespace Qt::StringLiterals;
26void QgsSubdivideAlgorithm::initParameters(
const QVariantMap & )
29 nodes->setIsDynamic(
true );
31 nodes->setDynamicLayerParameterName( u
"INPUT"_s );
33 addParameter( nodes.release() );
36QString QgsSubdivideAlgorithm::name()
const
38 return u
"subdivide"_s;
41QString QgsSubdivideAlgorithm::displayName()
const
43 return QObject::tr(
"Subdivide" );
46QStringList QgsSubdivideAlgorithm::tags()
const
48 return QObject::tr(
"subdivide,segmentize,split,tessellate" ).split(
',' );
51QString QgsSubdivideAlgorithm::group()
const
53 return QObject::tr(
"Vector geometry" );
56QString QgsSubdivideAlgorithm::groupId()
const
58 return u
"vectorgeometry"_s;
61QString QgsSubdivideAlgorithm::shortHelpString()
const
63 return QObject::tr(
"This algorithm subdivides the geometry. The returned geometry will be a collection containing subdivided parts "
64 "from the original geometry, where no part has more than the specified maximum number of nodes.\n\n"
65 "This is useful for dividing a complex geometry into less complex parts, which are better able to be spatially "
66 "indexed and faster to perform further operations such as intersects on. The returned geometry parts may "
67 "not be valid and may contain self-intersections.\n\n"
68 "Curved geometries will be segmentized before subdivision." );
71QString QgsSubdivideAlgorithm::shortDescription()
const
73 return QObject::tr(
"Subdivides the geometry into parts that have less than a specified maximum number of nodes." );
76QgsSubdivideAlgorithm *QgsSubdivideAlgorithm::createInstance()
const
78 return new QgsSubdivideAlgorithm();
81QString QgsSubdivideAlgorithm::outputName()
const
83 return QObject::tr(
"Subdivided" );
96 int maxNodes = mMaxNodes;
97 if ( mDynamicMaxNodes )
98 maxNodes = mMaxNodesProperty.valueAsDouble( context.
expressionContext(), maxNodes );
103 feedback->
reportError( QObject::tr(
"Error calculating subdivision for feature %1" ).arg( feature.
id() ) );
111 mMaxNodes = parameterAsInt( parameters, u
"MAX_NODES"_s, context );
113 if ( mDynamicMaxNodes )
114 mMaxNodesProperty = parameters.value( u
"MAX_NODES"_s ).value<
QgsProperty>();
WkbType
The WKB type describes the number of dimensions a geometry has.
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.
QgsGeometry subdivide(int maxNodes=256, const QgsGeometryParameters ¶meters=QgsGeometryParameters()) const
Subdivides the geometry.
Contains information about the context in which a processing algorithm is executed.
QgsExpressionContext & expressionContext()
Returns the expression context.
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.
@ Integer
Integer value (including negative values).
A store for object properties.
static Qgis::WkbType multiType(Qgis::WkbType type)
Returns the multi type for a WKB type.
QList< QgsFeature > QgsFeatureList