QGIS API Documentation 3.99.0-Master (357b655ed83)
Loading...
Searching...
No Matches
qgsalgorithmpromotetomultipart.cpp
Go to the documentation of this file.
1/***************************************************************************
2 qgsalgorithmpromotetomultipart.cpp
3 ---------------------
4 begin : April 2017
5 copyright : (C) 2017 by Nyall Dawson
6 email : nyall dot dawson at gmail dot com
7 ***************************************************************************/
8
9/***************************************************************************
10 * *
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
15 * *
16 ***************************************************************************/
17
19
20#include "qgsvectorlayer.h"
21
22#include <QString>
23
24using namespace Qt::StringLiterals;
25
27
28QString QgsPromoteToMultipartAlgorithm::name() const
29{
30 return u"promotetomulti"_s;
31}
32
33QString QgsPromoteToMultipartAlgorithm::displayName() const
34{
35 return QObject::tr( "Promote to multipart" );
36}
37
38QStringList QgsPromoteToMultipartAlgorithm::tags() const
39{
40 return QObject::tr( "multi,single,multiple,convert,force,parts" ).split( ',' );
41}
42
43QString QgsPromoteToMultipartAlgorithm::group() const
44{
45 return QObject::tr( "Vector geometry" );
46}
47
48QString QgsPromoteToMultipartAlgorithm::groupId() const
49{
50 return u"vectorgeometry"_s;
51}
52
53QString QgsPromoteToMultipartAlgorithm::outputName() const
54{
55 return QObject::tr( "Multiparts" );
56}
57
58QString QgsPromoteToMultipartAlgorithm::shortHelpString() const
59{
60 return QObject::tr( "This algorithm takes a vector layer with singlepart geometries and generates a new one in which all geometries are "
61 "multipart. Input features which are already multipart features will remain unchanged." )
62 + u"\n\n"_s + QObject::tr( "This algorithm can be used to force geometries to multipart types in order to be compatible with data providers "
63 "with strict singlepart/multipart compatibility checks." )
64 + u"\n\n"_s + QObject::tr( "See the 'Collect geometries' or 'Aggregate' algorithms for alternative options." );
65}
66
67QString QgsPromoteToMultipartAlgorithm::shortDescription() const
68{
69 return QObject::tr( "Generates a vector layer in which all geometries are multipart." );
70}
71
72QgsPromoteToMultipartAlgorithm *QgsPromoteToMultipartAlgorithm::createInstance() const
73{
74 return new QgsPromoteToMultipartAlgorithm();
75}
76
77bool QgsPromoteToMultipartAlgorithm::supportInPlaceEdit( const QgsMapLayer *l ) const
78{
79 const QgsVectorLayer *layer = qobject_cast<const QgsVectorLayer *>( l );
80 if ( !layer )
81 return false;
82
84 return false;
85 return QgsWkbTypes::isMultiType( layer->wkbType() );
86}
87
88Qgis::WkbType QgsPromoteToMultipartAlgorithm::outputWkbType( Qgis::WkbType inputWkbType ) const
89{
90 return QgsWkbTypes::multiType( inputWkbType );
91}
92
93Qgis::ProcessingFeatureSourceFlags QgsPromoteToMultipartAlgorithm::sourceFlags() const
94{
96}
97
98QgsFeatureList QgsPromoteToMultipartAlgorithm::processFeature( const QgsFeature &feature, QgsProcessingContext &, QgsProcessingFeedback * )
99{
100 QgsFeature f = feature;
101 if ( f.hasGeometry() && !f.geometry().isMultipart() )
102 {
103 QgsGeometry g = f.geometry();
105 f.setGeometry( g );
106 }
107 return QgsFeatureList() << f;
108}
109
@ SkipGeometryValidityChecks
Invalid geometry checks should always be skipped. This flag can be useful for algorithms which always...
Definition qgis.h:3782
WkbType
The WKB type describes the number of dimensions a geometry has.
Definition qgis.h:280
QFlags< ProcessingFeatureSourceFlag > ProcessingFeatureSourceFlags
Flags which control how QgsProcessingFeatureSource fetches features.
Definition qgis.h:3793
The feature class encapsulates a single feature including its unique ID, geometry and a list of field...
Definition qgsfeature.h:60
QgsGeometry geometry
Definition qgsfeature.h:71
bool hasGeometry() const
Returns true if the feature has an associated geometry.
void setGeometry(const QgsGeometry &geometry)
Set the feature's geometry.
A geometry is the spatial representation of a feature.
bool isMultipart() const
Returns true if WKB of the geometry is of WKBMulti* type.
bool convertToMultiType()
Converts single type geometry into multitype geometry e.g.
Base class for all map layer types.
Definition qgsmaplayer.h:83
Contains information about the context in which a processing algorithm is executed.
bool supportInPlaceEdit(const QgsMapLayer *layer) const override
Checks whether this algorithm supports in-place editing on the given layer Default implementation for...
Base class for providing feedback from a processing algorithm.
Represents a vector layer which manages a vector based dataset.
Q_INVOKABLE Qgis::WkbType wkbType() const final
Returns the WKBType or WKBUnknown in case of error.
static Qgis::WkbType multiType(Qgis::WkbType type)
Returns the multi type for a WKB type.
static Q_INVOKABLE bool isMultiType(Qgis::WkbType type)
Returns true if the WKB type is a multi type.
QList< QgsFeature > QgsFeatureList