QGIS API Documentation 4.1.0-Master (5bf3c20f3c9)
Loading...
Searching...
No Matches
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
20#include "qgscurvepolygon.h"
22#include "qgsvectorlayer.h"
23
24#include <QString>
25
26using namespace Qt::StringLiterals;
27
29
30QString QgsForceRHRAlgorithm::name() const
31{
32 return u"forcerhr"_s;
33}
34
35QString QgsForceRHRAlgorithm::displayName() const
36{
37 return QObject::tr( "Force right-hand-rule" );
38}
39
40QStringList QgsForceRHRAlgorithm::tags() const
41{
42 return QObject::tr( "clockwise,counter,orientation,ring,repair,invalid,geometry,make,valid" ).split( ',' );
43}
44
45QString QgsForceRHRAlgorithm::group() const
46{
47 return QObject::tr( "Vector geometry" );
48}
49
50QString QgsForceRHRAlgorithm::groupId() const
51{
52 return u"vectorgeometry"_s;
53}
54
55Qgis::ProcessingFeatureSourceFlags QgsForceRHRAlgorithm::sourceFlags() const
56{
58}
59
60QString QgsForceRHRAlgorithm::outputName() const
61{
62 return QObject::tr( "Reoriented" );
63}
64
65QString QgsForceRHRAlgorithm::shortHelpString() const
66{
67 return QObject::tr(
68 "This algorithm forces polygon geometries to respect the Right-Hand-Rule, in which the area that is bounded by a polygon "
69 "is to the right of the boundary. In particular, the exterior ring is oriented in a clockwise direction and the interior "
70 "rings in a counter-clockwise direction.\n\n"
71 "Due to the inconsistency in the definition of the Right-Hand-Rule in some contexts, it is recommended to use the "
72 "explicit \"Force polygons clockwise\" processing algorithm instead."
73 );
74}
75
76QString QgsForceRHRAlgorithm::shortDescription() const
77{
78 return QObject::tr( "Forces polygon geometries to respect the Right-Hand-Rule." );
79}
80
81QList<int> QgsForceRHRAlgorithm::inputLayerTypes() const
82{
83 return QList<int>() << static_cast<int>( Qgis::ProcessingSourceType::VectorPolygon );
84}
85
86QgsForceRHRAlgorithm *QgsForceRHRAlgorithm::createInstance() const
87{
88 return new QgsForceRHRAlgorithm();
89}
90
91QgsFeatureList QgsForceRHRAlgorithm::processFeature( const QgsFeature &feature, QgsProcessingContext &, QgsProcessingFeedback * )
92{
93 if ( !feature.hasGeometry() )
94 return QgsFeatureList() << feature;
95
96 QgsFeature outputFeature = feature;
97 outputFeature.setGeometry( feature.geometry().forceRHR() );
98
99 return QgsFeatureList() << outputFeature;
100}
101
@ VectorPolygon
Vector polygon layers.
Definition qgis.h:3650
@ SkipGeometryValidityChecks
Invalid geometry checks should always be skipped. This flag can be useful for algorithms which always...
Definition qgis.h:3828
QFlags< ProcessingFeatureSourceFlag > ProcessingFeatureSourceFlags
Flags which control how QgsProcessingFeatureSource fetches features.
Definition qgis.h:3839
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 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.
Base class for providing feedback from a processing algorithm.
QList< QgsFeature > QgsFeatureList