23 QString QgsOrthogonalizeAlgorithm::name()
const
25 return QStringLiteral(
"orthogonalize" );
28 QString QgsOrthogonalizeAlgorithm::displayName()
const
30 return QObject::tr(
"Orthogonalize" );
33 QStringList QgsOrthogonalizeAlgorithm::tags()
const
35 return QObject::tr(
"rectangle,perpendicular,right,angles,square,quadrilateralise" ).split(
',' );
38 QString QgsOrthogonalizeAlgorithm::group()
const
40 return QObject::tr(
"Vector geometry" );
43 QString QgsOrthogonalizeAlgorithm::groupId()
const
45 return QStringLiteral(
"vectorgeometry" );
48 QString QgsOrthogonalizeAlgorithm::shortHelpString()
const
50 return QObject::tr(
"Takes a line or polygon layer and attempts to orthogonalize "
51 "all the geometries in the layer. This process shifts the nodes "
52 "in the geometries to try to make every angle in the geometry "
53 "either a right angle or a straight line.\n\n"
54 "The angle tolerance parameter is used to specify the maximum "
55 "deviation from a right angle or straight line a node can have "
56 "for it to be adjusted. Smaller tolerances mean that only nodes "
57 "which are already closer to right angles will be adjusted, and "
58 "larger tolerances mean that nodes which deviate further from "
59 "right angles will also be adjusted.\n\n"
60 "The algorithm is iterative. Setting a larger number for the maximum "
61 "iterations will result in a more orthogonal geometry at the cost of "
62 "extra processing time." );
65 QString QgsOrthogonalizeAlgorithm::outputName()
const
67 return QObject::tr(
"Orthogonalized" );
70 QList<int> QgsOrthogonalizeAlgorithm::inputLayerTypes()
const
75 QgsOrthogonalizeAlgorithm *QgsOrthogonalizeAlgorithm::createInstance()
const
77 return new QgsOrthogonalizeAlgorithm();
80 void QgsOrthogonalizeAlgorithm::initParameters(
const QVariantMap & )
82 auto angleToleranceParam = std::make_unique < QgsProcessingParameterNumber >( QStringLiteral(
"ANGLE_TOLERANCE" ), QObject::tr(
"Maximum angle tolerance (degrees)" ),
84 angleToleranceParam->setIsDynamic(
true );
86 angleToleranceParam->setDynamicLayerParameterName( QStringLiteral(
"INPUT" ) );
87 addParameter( angleToleranceParam.release() );
89 std::unique_ptr< QgsProcessingParameterNumber> maxIterations = std::make_unique< QgsProcessingParameterNumber >(
90 QStringLiteral(
"MAX_ITERATIONS" ),
91 QObject::tr(
"Maximum algorithm iterations" ),
93 1000,
false, 1, 10000 );
95 addParameter( maxIterations.release() );
100 mAngleTolerance = parameterAsDouble( parameters, QStringLiteral(
"ANGLE_TOLERANCE" ), context );
102 if ( mDynamicAngleTolerance )
103 mAngleToleranceProperty = parameters.value( QStringLiteral(
"ANGLE_TOLERANCE" ) ).value<
QgsProperty >();
105 mMaxIterations = parameterAsDouble( parameters, QStringLiteral(
"MAX_ITERATIONS" ), context );
116 double angleTolerance = mAngleTolerance;
117 if ( mDynamicAngleTolerance )
118 angleTolerance = mAngleToleranceProperty.valueAsDouble( context.
expressionContext(), angleTolerance );
121 if ( outputGeometry.
isNull() )