24QString QgsOrthogonalizeAlgorithm::name()
const
26 return QStringLiteral(
"orthogonalize" );
29QString QgsOrthogonalizeAlgorithm::displayName()
const
31 return QObject::tr(
"Orthogonalize" );
34QStringList QgsOrthogonalizeAlgorithm::tags()
const
36 return QObject::tr(
"rectangle,perpendicular,right,angles,square,quadrilateralise" ).split(
',' );
39QString QgsOrthogonalizeAlgorithm::group()
const
41 return QObject::tr(
"Vector geometry" );
44QString QgsOrthogonalizeAlgorithm::groupId()
const
46 return QStringLiteral(
"vectorgeometry" );
49QString QgsOrthogonalizeAlgorithm::shortHelpString()
const
51 return QObject::tr(
"Takes a line or polygon layer and attempts to orthogonalize "
52 "all the geometries in the layer. This process shifts the nodes "
53 "in the geometries to try to make every angle in the geometry "
54 "either a right angle or a straight line.\n\n"
55 "The angle tolerance parameter is used to specify the maximum "
56 "deviation from a right angle or straight line a node can have "
57 "for it to be adjusted. Smaller tolerances mean that only nodes "
58 "which are already closer to right angles will be adjusted, and "
59 "larger tolerances mean that nodes which deviate further from "
60 "right angles will also be adjusted.\n\n"
61 "The algorithm is iterative. Setting a larger number for the maximum "
62 "iterations will result in a more orthogonal geometry at the cost of "
63 "extra processing time." );
66QString QgsOrthogonalizeAlgorithm::shortDescription()
const
68 return QObject::tr(
"Takes a line or polygon layer and attempts to orthogonalize "
69 "all the geometries in the layer." );
72QString QgsOrthogonalizeAlgorithm::outputName()
const
74 return QObject::tr(
"Orthogonalized" );
77QList<int> QgsOrthogonalizeAlgorithm::inputLayerTypes()
const
82QgsOrthogonalizeAlgorithm *QgsOrthogonalizeAlgorithm::createInstance()
const
84 return new QgsOrthogonalizeAlgorithm();
87void QgsOrthogonalizeAlgorithm::initParameters(
const QVariantMap & )
89 auto angleToleranceParam = std::make_unique<QgsProcessingParameterNumber>( QStringLiteral(
"ANGLE_TOLERANCE" ), QObject::tr(
"Maximum angle tolerance (degrees)" ),
Qgis::ProcessingNumberParameterType::Double, 15.0,
false, 0.0, 45.0 );
90 angleToleranceParam->setIsDynamic(
true );
92 angleToleranceParam->setDynamicLayerParameterName( QStringLiteral(
"INPUT" ) );
93 addParameter( angleToleranceParam.release() );
95 auto maxIterations = std::make_unique<QgsProcessingParameterNumber>(
96 QStringLiteral(
"MAX_ITERATIONS" ),
97 QObject::tr(
"Maximum algorithm iterations" ),
102 addParameter( maxIterations.release() );
107 mAngleTolerance = parameterAsDouble( parameters, QStringLiteral(
"ANGLE_TOLERANCE" ), context );
109 if ( mDynamicAngleTolerance )
110 mAngleToleranceProperty = parameters.value( QStringLiteral(
"ANGLE_TOLERANCE" ) ).value<
QgsProperty>();
112 mMaxIterations = parameterAsDouble( parameters, QStringLiteral(
"MAX_ITERATIONS" ), context );
123 double angleTolerance = mAngleTolerance;
124 if ( mDynamicAngleTolerance )
125 angleTolerance = mAngleToleranceProperty.valueAsDouble( context.
expressionContext(), angleTolerance );
128 if ( outputGeometry.
isNull() )
@ VectorPolygon
Vector polygon layers.
@ VectorLine
Vector line layers.
@ Advanced
Parameter is an advanced parameter which should be hidden from users by default.
@ Double
Double/float values.
The feature class encapsulates a single feature including its unique ID, geometry and a list of field...
bool hasGeometry() const
Returns true if the feature has an associated geometry.
void setGeometry(const QgsGeometry &geometry)
Set the feature's geometry.
A geometry is the spatial representation of a feature.
QgsGeometry orthogonalize(double tolerance=1.0E-8, int maxIterations=1000, double angleThreshold=15.0) const
Attempts to orthogonalize a line or polygon geometry by shifting vertices to make the geometries angl...
Contains information about the context in which a processing algorithm is executed.
QgsExpressionContext & expressionContext()
Returns the expression context.
Custom exception class for processing related exceptions.
Base class for providing feedback from a processing algorithm.
static bool isDynamic(const QVariantMap ¶meters, const QString &name)
Returns true if the parameter with matching name is a dynamic parameter, and must be evaluated once f...
Definition for a property.
@ Double
Double value (including negative values).
A store for object properties.
QList< QgsFeature > QgsFeatureList