22 void QgsSubdivideAlgorithm::initParameters(
const QVariantMap & )
24 std::unique_ptr< QgsProcessingParameterNumber> nodes = std::make_unique< QgsProcessingParameterNumber >( QStringLiteral(
"MAX_NODES" ), QObject::tr(
"Maximum nodes in parts" ),
QgsProcessingParameterNumber::Integer,
25 256,
false, 8, 100000 );
26 nodes->setIsDynamic(
true );
28 nodes->setDynamicLayerParameterName( QStringLiteral(
"INPUT" ) );
30 addParameter( nodes.release() );
33 QString QgsSubdivideAlgorithm::name()
const
35 return QStringLiteral(
"subdivide" );
38 QString QgsSubdivideAlgorithm::displayName()
const
40 return QObject::tr(
"Subdivide" );
43 QStringList QgsSubdivideAlgorithm::tags()
const
45 return QObject::tr(
"subdivide,segmentize,split,tessellate" ).split(
',' );
48 QString QgsSubdivideAlgorithm::group()
const
50 return QObject::tr(
"Vector geometry" );
53 QString QgsSubdivideAlgorithm::groupId()
const
55 return QStringLiteral(
"vectorgeometry" );
58 QString QgsSubdivideAlgorithm::shortHelpString()
const
60 return QObject::tr(
"Subdivides the geometry. The returned geometry will be a collection containing subdivided parts "
61 "from the original geometry, where no part has more then the specified maximum number of nodes.\n\n"
62 "This is useful for dividing a complex geometry into less complex parts, which are better able to be spatially "
63 "indexed and faster to perform further operations such as intersects on. The returned geometry parts may "
64 "not be valid and may contain self-intersections.\n\n"
65 "Curved geometries will be segmentized before subdivision." );
68 QgsSubdivideAlgorithm *QgsSubdivideAlgorithm::createInstance()
const
70 return new QgsSubdivideAlgorithm();
73 QString QgsSubdivideAlgorithm::outputName()
const
75 return QObject::tr(
"Subdivided" );
88 int maxNodes = mMaxNodes;
89 if ( mDynamicMaxNodes )
90 maxNodes = mMaxNodesProperty.valueAsDouble( context.
expressionContext(), maxNodes );
95 feedback->
reportError( QObject::tr(
"Error calculating subdivision for feature %1" ).arg( feature.
id() ) );
103 mMaxNodes = parameterAsInt( parameters, QStringLiteral(
"MAX_NODES" ), context );
105 if ( mDynamicMaxNodes )
106 mMaxNodesProperty = parameters.value( QStringLiteral(
"MAX_NODES" ) ).value<
QgsProperty >();