23 QString QgsPolygonizeAlgorithm::name()
const
25 return QStringLiteral(
"polygonize" );
28 QString QgsPolygonizeAlgorithm::displayName()
const
30 return QObject::tr(
"Polygonize" );
33 QString QgsPolygonizeAlgorithm::shortHelpString()
const
35 return QObject::tr(
"Creates a polygon layer from the input lines layer." );
38 QStringList QgsPolygonizeAlgorithm::tags()
const
40 return QObject::tr(
"create,lines,polygons,convert" ).split(
',' );
43 QString QgsPolygonizeAlgorithm::group()
const
45 return QObject::tr(
"Vector geometry" );
48 QString QgsPolygonizeAlgorithm::groupId()
const
50 return QStringLiteral(
"vectorgeometry" );
53 void QgsPolygonizeAlgorithm::initAlgorithm(
const QVariantMap & )
58 QObject::tr(
"Keep table structure of line layer" ),
false,
true ) );
64 QgsPolygonizeAlgorithm *QgsPolygonizeAlgorithm::createInstance()
const
66 return new QgsPolygonizeAlgorithm();
71 std::unique_ptr< QgsProcessingFeatureSource > source( parameterAsSource( parameters, QStringLiteral(
"INPUT" ), context ) );
76 if ( parameterAsBoolean( parameters, QStringLiteral(
"KEEP_FIELDS" ), context ) )
77 fields = source->fields();
80 std::unique_ptr< QgsFeatureSink > sink( parameterAsSink( parameters, QStringLiteral(
"OUTPUT" ), context, dest, fields,
QgsWkbTypes::Polygon, source->sourceCrs() ) );
86 feedback->
pushInfo( QObject::tr(
"Collecting lines…" ) );
88 double step = source->featureCount() > 0 ? 40.0 / source->featureCount() : 1;
91 QVector<QgsGeometry> linesList;
92 linesList.reserve( source->featureCount() );
105 feedback->
pushInfo( QObject::tr(
"Noding lines…" ) );
108 return QVariantMap();
111 feedback->
pushInfo( QObject::tr(
"Polygonizing…" ) );
114 feedback->
reportError( QObject::tr(
"No polygons were created." ) );
122 for (
int part = 0; part < collection->
numGeometries(); ++part )
137 outputs.insert( QStringLiteral(
"OUTPUT" ), dest );
138 outputs.insert( QStringLiteral(
"NUM_POLYGONS" ), polygonCount );