QGIS API Documentation 3.28.0-Firenze (ed3ad0430f)
qgsalgorithmforcerhr.cpp
Go to the documentation of this file.
1/***************************************************************************
2 qgsalgorithmforcerhr.cpp
3 ---------------------
4 begin : November 2018
5 copyright : (C) 2018 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#include "qgsvectorlayer.h"
21#include "qgscurvepolygon.h"
22
24
25QString QgsForceRHRAlgorithm::name() const
26{
27 return QStringLiteral( "forcerhr" );
28}
29
30QString QgsForceRHRAlgorithm::displayName() const
31{
32 return QObject::tr( "Force right-hand-rule" );
33}
34
35QStringList QgsForceRHRAlgorithm::tags() const
36{
37 return QObject::tr( "clockwise,counter,orientation,ring,repair,invalid,geometry,make,valid" ).split( ',' );
38}
39
40QString QgsForceRHRAlgorithm::group() const
41{
42 return QObject::tr( "Vector geometry" );
43}
44
45QString QgsForceRHRAlgorithm::groupId() const
46{
47 return QStringLiteral( "vectorgeometry" );
48}
49
50QgsProcessingFeatureSource::Flag QgsForceRHRAlgorithm::sourceFlags() const
51{
53}
54
55QString QgsForceRHRAlgorithm::outputName() const
56{
57 return QObject::tr( "Reoriented" );
58}
59
60QString QgsForceRHRAlgorithm::shortHelpString() const
61{
62 return QObject::tr( "This algorithm forces polygon geometries to respect the Right-Hand-Rule, in which the area that is bounded by a polygon "
63 "is to the right of the boundary. In particular, the exterior ring is oriented in a clockwise direction and the interior "
64 "rings in a counter-clockwise direction." );
65}
66
67QString QgsForceRHRAlgorithm::shortDescription() const
68{
69 return QObject::tr( "Forces polygon geometries to respect the Right-Hand-Rule." );
70}
71
72QList<int> QgsForceRHRAlgorithm::inputLayerTypes() const
73{
74 return QList<int>() << QgsProcessing::TypeVectorPolygon;
75}
76
77QgsForceRHRAlgorithm *QgsForceRHRAlgorithm::createInstance() const
78{
79 return new QgsForceRHRAlgorithm();
80}
81
82QgsFeatureList QgsForceRHRAlgorithm::processFeature( const QgsFeature &feature, QgsProcessingContext &, QgsProcessingFeedback * )
83{
84 if ( !feature.hasGeometry() )
85 return QgsFeatureList() << feature;
86
87 QgsFeature outputFeature = feature;
88 outputFeature.setGeometry( feature.geometry().forceRHR() );
89
90 return QgsFeatureList() << outputFeature;
91}
92
The feature class encapsulates a single feature including its unique ID, geometry and a list of field...
Definition: qgsfeature.h:56
QgsGeometry geometry
Definition: qgsfeature.h:67
bool hasGeometry() const
Returns true if the feature has an associated geometry.
Definition: qgsfeature.cpp:233
void setGeometry(const QgsGeometry &geometry)
Set the feature's geometry.
Definition: qgsfeature.cpp:170
QgsGeometry forceRHR() const
Forces geometries to respect the Right-Hand-Rule, in which the area that is bounded by a polygon is t...
Contains information about the context in which a processing algorithm is executed.
Flag
Flags controlling how QgsProcessingFeatureSource fetches features.
@ FlagSkipGeometryValidityChecks
Invalid geometry checks should always be skipped. This flag can be useful for algorithms which always...
Base class for providing feedback from a processing algorithm.
@ TypeVectorPolygon
Vector polygon layers.
Definition: qgsprocessing.h:51
QList< QgsFeature > QgsFeatureList
Definition: qgsfeature.h:922