QGIS API Documentation  3.26.3-Buenos Aires (65e4edfdad)
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 
18 #include "qgsalgorithmforcerhr.h"
19 #include "qgsvectorlayer.h"
20 #include "qgsgeometrycollection.h"
21 #include "qgscurvepolygon.h"
22 
24 
25 QString QgsForceRHRAlgorithm::name() const
26 {
27  return QStringLiteral( "forcerhr" );
28 }
29 
30 QString QgsForceRHRAlgorithm::displayName() const
31 {
32  return QObject::tr( "Force right-hand-rule" );
33 }
34 
35 QStringList QgsForceRHRAlgorithm::tags() const
36 {
37  return QObject::tr( "clockwise,counter,orientation,ring,repair,invalid,geometry,make,valid" ).split( ',' );
38 }
39 
40 QString QgsForceRHRAlgorithm::group() const
41 {
42  return QObject::tr( "Vector geometry" );
43 }
44 
45 QString QgsForceRHRAlgorithm::groupId() const
46 {
47  return QStringLiteral( "vectorgeometry" );
48 }
49 
50 QgsProcessingFeatureSource::Flag QgsForceRHRAlgorithm::sourceFlags() const
51 {
53 }
54 
55 QString QgsForceRHRAlgorithm::outputName() const
56 {
57  return QObject::tr( "Reoriented" );
58 }
59 
60 QString 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 
67 QString QgsForceRHRAlgorithm::shortDescription() const
68 {
69  return QObject::tr( "Forces polygon geometries to respect the Right-Hand-Rule." );
70 }
71 
72 QList<int> QgsForceRHRAlgorithm::inputLayerTypes() const
73 {
74  return QList<int>() << QgsProcessing::TypeVectorPolygon;
75 }
76 
77 QgsForceRHRAlgorithm *QgsForceRHRAlgorithm::createInstance() const
78 {
79  return new QgsForceRHRAlgorithm();
80 }
81 
82 QgsFeatureList 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 
QgsProcessingFeedback
Base class for providing feedback from a processing algorithm.
Definition: qgsprocessingfeedback.h:37
QgsProcessing::TypeVectorPolygon
@ TypeVectorPolygon
Vector polygon layers.
Definition: qgsprocessing.h:51
QgsFeature::geometry
QgsGeometry geometry
Definition: qgsfeature.h:71
QgsProcessingFeatureSource::FlagSkipGeometryValidityChecks
@ FlagSkipGeometryValidityChecks
Invalid geometry checks should always be skipped. This flag can be useful for algorithms which always...
Definition: qgsprocessingutils.h:584
QgsFeature::setGeometry
void setGeometry(const QgsGeometry &geometry)
Set the feature's geometry.
Definition: qgsfeature.cpp:170
QgsProcessingContext
Contains information about the context in which a processing algorithm is executed.
Definition: qgsprocessingcontext.h:46
QgsFeatureList
QList< QgsFeature > QgsFeatureList
Definition: qgsfeature.h:882
qgscurvepolygon.h
qgsvectorlayer.h
QgsProcessingFeatureSource::Flag
Flag
Flags controlling how QgsProcessingFeatureSource fetches features.
Definition: qgsprocessingutils.h:582
QgsFeature::hasGeometry
bool hasGeometry() const
Returns true if the feature has an associated geometry.
Definition: qgsfeature.cpp:230
QgsGeometry::forceRHR
QgsGeometry forceRHR() const
Forces geometries to respect the Right-Hand-Rule, in which the area that is bounded by a polygon is t...
Definition: qgsgeometry.cpp:2878
qgsgeometrycollection.h
QgsFeature
The feature class encapsulates a single feature including its unique ID, geometry and a list of field...
Definition: qgsfeature.h:55
qgsalgorithmforcerhr.h