QGIS API Documentation 3.99.0-Master (2fe06baccd8)
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
25
26QString QgsForceRHRAlgorithm::name() const
27{
28 return QStringLiteral( "forcerhr" );
29}
30
31QString QgsForceRHRAlgorithm::displayName() const
32{
33 return QObject::tr( "Force right-hand-rule" );
34}
35
36QStringList QgsForceRHRAlgorithm::tags() const
37{
38 return QObject::tr( "clockwise,counter,orientation,ring,repair,invalid,geometry,make,valid" ).split( ',' );
39}
40
41QString QgsForceRHRAlgorithm::group() const
42{
43 return QObject::tr( "Vector geometry" );
44}
45
46QString QgsForceRHRAlgorithm::groupId() const
47{
48 return QStringLiteral( "vectorgeometry" );
49}
50
51Qgis::ProcessingFeatureSourceFlags QgsForceRHRAlgorithm::sourceFlags() const
52{
54}
55
56QString QgsForceRHRAlgorithm::outputName() const
57{
58 return QObject::tr( "Reoriented" );
59}
60
61QString QgsForceRHRAlgorithm::shortHelpString() const
62{
63 return QObject::tr( "This algorithm forces polygon geometries to respect the Right-Hand-Rule, in which the area that is bounded by a polygon "
64 "is to the right of the boundary. In particular, the exterior ring is oriented in a clockwise direction and the interior "
65 "rings in a counter-clockwise direction." );
66}
67
68QString QgsForceRHRAlgorithm::shortDescription() const
69{
70 return QObject::tr( "Forces polygon geometries to respect the Right-Hand-Rule." );
71}
72
73QList<int> QgsForceRHRAlgorithm::inputLayerTypes() const
74{
75 return QList<int>() << static_cast<int>( Qgis::ProcessingSourceType::VectorPolygon );
76}
77
78QgsForceRHRAlgorithm *QgsForceRHRAlgorithm::createInstance() const
79{
80 return new QgsForceRHRAlgorithm();
81}
82
83QgsFeatureList QgsForceRHRAlgorithm::processFeature( const QgsFeature &feature, QgsProcessingContext &, QgsProcessingFeedback * )
84{
85 if ( !feature.hasGeometry() )
86 return QgsFeatureList() << feature;
87
88 QgsFeature outputFeature = feature;
89 outputFeature.setGeometry( feature.geometry().forceRHR() );
90
91 return QgsFeatureList() << outputFeature;
92}
93
@ VectorPolygon
Vector polygon layers.
Definition qgis.h:3536
@ SkipGeometryValidityChecks
Invalid geometry checks should always be skipped. This flag can be useful for algorithms which always...
Definition qgis.h:3711
QFlags< ProcessingFeatureSourceFlag > ProcessingFeatureSourceFlags
Flags which control how QgsProcessingFeatureSource fetches features.
Definition qgis.h:3722
The feature class encapsulates a single feature including its unique ID, geometry and a list of field...
Definition qgsfeature.h:58
QgsGeometry geometry
Definition qgsfeature.h:69
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