26 QString QgsPolygonsToLinesAlgorithm::name()
const
28 return QStringLiteral(
"polygonstolines" );
31 QString QgsPolygonsToLinesAlgorithm::displayName()
const
33 return QObject::tr(
"Polygons to lines" );
36 QStringList QgsPolygonsToLinesAlgorithm::tags()
const
38 return QObject::tr(
"line,polygon,convert" ).split(
',' );
41 QString QgsPolygonsToLinesAlgorithm::group()
const
43 return QObject::tr(
"Vector creation" );
46 QString QgsPolygonsToLinesAlgorithm::groupId()
const
48 return QStringLiteral(
"vectorgeometry" );
51 QString QgsPolygonsToLinesAlgorithm::outputName()
const
53 return QObject::tr(
"Lines" );
78 QString QgsPolygonsToLinesAlgorithm::shortHelpString()
const
80 return QObject::tr(
"Converts polygons to lines" );
83 QString QgsPolygonsToLinesAlgorithm::shortDescription()
const
85 return QObject::tr(
"Converts polygons to lines." );
88 QgsPolygonsToLinesAlgorithm *QgsPolygonsToLinesAlgorithm::createInstance()
const
90 return new QgsPolygonsToLinesAlgorithm();
93 QList<int> QgsPolygonsToLinesAlgorithm::inputLayerTypes()
const
113 auto rings = extractRings( geometry.
constGet() );
117 std::unique_ptr<QgsMultiCurve> lineGeometry;
120 lineGeometry = qgis::make_unique<QgsMultiLineString>();
122 lineGeometry = qgis::make_unique<QgsMultiCurve>();
124 lineGeometry->reserve( rings.size() );
125 for (
auto ring : qgis::as_const( rings ) )
126 lineGeometry->addGeometry( ring );
131 QList<QgsCurve *> QgsPolygonsToLinesAlgorithm::extractRings(
const QgsAbstractGeometry *geom )
const
133 QList<QgsCurve *> rings;
139 rings.append( extractRings( parts.
next() ) );
141 else if (
QgsCurvePolygon *polygon = qgsgeometry_cast<QgsCurvePolygon *>( geom ) )
143 if (
auto exteriorRing = polygon->exteriorRing() )
144 rings.append( exteriorRing->clone() );
145 for (
int i = 0; i < polygon->numInteriorRings(); ++i )
147 rings.append( polygon->interiorRing( i )->clone() );