QGIS API Documentation 3.99.0-Master (357b655ed83)
Loading...
Searching...
No Matches
qgsalgorithmforcecw.cpp
Go to the documentation of this file.
1/***************************************************************************
2 qgsalgorithmforcecw.cpp
3 ---------------------
4 begin : January 2026
5 copyright : (C) 2026 by Andrea Giudiceandrea
6 email : andreaerdna at libero dot it
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
18#include "qgsalgorithmforcecw.h"
19
20#include "qgscurvepolygon.h"
22#include "qgsvectorlayer.h"
23
24#include <QString>
25
26using namespace Qt::StringLiterals;
27
29
30QString QgsForceCWAlgorithm::name() const
31{
32 return u"forcecw"_s;
33}
34
35QString QgsForceCWAlgorithm::displayName() const
36{
37 return QObject::tr( "Force polygons clockwise" );
38}
39
40QStringList QgsForceCWAlgorithm::tags() const
41{
42 return QObject::tr( "clockwise,cw,orientation,ring,repair,invalid,geometry,make,valid" ).split( ',' );
43}
44
45QString QgsForceCWAlgorithm::group() const
46{
47 return QObject::tr( "Vector geometry" );
48}
49
50QString QgsForceCWAlgorithm::groupId() const
51{
52 return u"vectorgeometry"_s;
53}
54
55Qgis::ProcessingFeatureSourceFlags QgsForceCWAlgorithm::sourceFlags() const
56{
58}
59
60QString QgsForceCWAlgorithm::outputName() const
61{
62 return QObject::tr( "Reoriented" );
63}
64
65QString QgsForceCWAlgorithm::shortHelpString() const
66{
67 return QObject::tr( "This algorithm forces polygon geometries to respect the convention where the exterior ring is oriented in a clockwise direction "
68 "and the interior rings in a counter-clockwise direction." );
69}
70
71QString QgsForceCWAlgorithm::shortDescription() const
72{
73 return QObject::tr( "Forces polygon geometries to have clockwise exterior rings and counter-clockwise interior rings." );
74}
75
76QList<int> QgsForceCWAlgorithm::inputLayerTypes() const
77{
78 return QList<int>() << static_cast<int>( Qgis::ProcessingSourceType::VectorPolygon );
79}
80
81QgsForceCWAlgorithm *QgsForceCWAlgorithm::createInstance() const
82{
83 return new QgsForceCWAlgorithm();
84}
85
86QgsFeatureList QgsForceCWAlgorithm::processFeature( const QgsFeature &feature, QgsProcessingContext &, QgsProcessingFeedback * )
87{
88 if ( !feature.hasGeometry() )
89 return QgsFeatureList() << feature;
90
91 QgsFeature outputFeature = feature;
92 outputFeature.setGeometry( feature.geometry().forcePolygonClockwise() );
93
94 return QgsFeatureList() << outputFeature;
95}
96
@ VectorPolygon
Vector polygon layers.
Definition qgis.h:3607
@ SkipGeometryValidityChecks
Invalid geometry checks should always be skipped. This flag can be useful for algorithms which always...
Definition qgis.h:3782
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.
QgsGeometry forcePolygonClockwise() const
Forces geometries to respect the exterior ring is clockwise, interior rings are counter-clockwise con...
Contains information about the context in which a processing algorithm is executed.
Base class for providing feedback from a processing algorithm.
QList< QgsFeature > QgsFeatureList