22 QString QgsSegmentizeByMaximumDistanceAlgorithm::name()
const
24 return QStringLiteral(
"segmentizebymaxdistance" );
27 QString QgsSegmentizeByMaximumDistanceAlgorithm::displayName()
const
29 return QObject::tr(
"Segmentize by maximum distance" );
32 QStringList QgsSegmentizeByMaximumDistanceAlgorithm::tags()
const
34 return QObject::tr(
"straighten,linearize,densify,curves,curved,circular" ).split(
',' );
37 QString QgsSegmentizeByMaximumDistanceAlgorithm::group()
const
39 return QObject::tr(
"Vector geometry" );
42 QString QgsSegmentizeByMaximumDistanceAlgorithm::groupId()
const
44 return QStringLiteral(
"vectorgeometry" );
47 QString QgsSegmentizeByMaximumDistanceAlgorithm::outputName()
const
49 return QObject::tr(
"Segmentized" );
52 QString QgsSegmentizeByMaximumDistanceAlgorithm::shortHelpString()
const
54 return QObject::tr(
"This algorithm segmentizes a geometry by converting curved sections to linear sections.\n\n"
55 "The segmentization is performed by specifying the maximum allowed offset distance between the original"
56 "curve and the segmentized representation.\n\n"
57 "Non-curved geometries will be retained without change." );
60 QgsSegmentizeByMaximumDistanceAlgorithm *QgsSegmentizeByMaximumDistanceAlgorithm::createInstance()
const
62 return new QgsSegmentizeByMaximumDistanceAlgorithm();
65 QList<int> QgsSegmentizeByMaximumDistanceAlgorithm::inputLayerTypes()
const
70 void QgsSegmentizeByMaximumDistanceAlgorithm::initParameters(
const QVariantMap & )
72 std::unique_ptr< QgsProcessingParameterDistance > tolerance = qgis::make_unique< QgsProcessingParameterDistance >( QStringLiteral(
"DISTANCE" ),
73 QObject::tr(
"Maximum offset distance" ),
74 1.0, QStringLiteral(
"INPUT" ),
false, 0, 10000000.0 );
75 tolerance->setIsDynamic(
true );
77 tolerance->setDynamicLayerParameterName( QStringLiteral(
"INPUT" ) );
78 addParameter( tolerance.release() );
81 bool QgsSegmentizeByMaximumDistanceAlgorithm::supportInPlaceEdit(
const QgsMapLayer *layer )
const
89 mTolerance = parameterAsDouble( parameters, QStringLiteral(
"DISTANCE" ), context );
91 if ( mDynamicTolerance )
92 mToleranceProperty = parameters.value( QStringLiteral(
"DISTANCE" ) ).value<
QgsProperty >();
103 double tolerance = mTolerance;
104 if ( mDynamicTolerance )
105 tolerance = mToleranceProperty.valueAsDouble( context.
expressionContext(), tolerance );
116 QString QgsSegmentizeByMaximumAngleAlgorithm::name()
const
118 return QStringLiteral(
"segmentizebymaxangle" );
121 QString QgsSegmentizeByMaximumAngleAlgorithm::displayName()
const
123 return QObject::tr(
"Segmentize by maximum angle" );
126 QStringList QgsSegmentizeByMaximumAngleAlgorithm::tags()
const
128 return QObject::tr(
"straighten,linearize,densify,curves,curved,circular,angle" ).split(
',' );
131 QString QgsSegmentizeByMaximumAngleAlgorithm::group()
const
133 return QObject::tr(
"Vector geometry" );
136 QString QgsSegmentizeByMaximumAngleAlgorithm::groupId()
const
138 return QStringLiteral(
"vectorgeometry" );
141 QString QgsSegmentizeByMaximumAngleAlgorithm::outputName()
const
143 return QObject::tr(
"Segmentized" );
146 QString QgsSegmentizeByMaximumAngleAlgorithm::shortHelpString()
const
148 return QObject::tr(
"This algorithm segmentizes a geometry by converting curved sections to linear sections.\n\n"
149 "The segmentization is performed by specifying the maximum allowed radius angle between vertices "
150 "on the straightened geometry (e.g the angle of the arc created from the original arc center to consecutive "
151 "output vertices on the linearized geometry).\n\n"
152 "Non-curved geometries will be retained without change." );
155 QgsSegmentizeByMaximumAngleAlgorithm *QgsSegmentizeByMaximumAngleAlgorithm::createInstance()
const
157 return new QgsSegmentizeByMaximumAngleAlgorithm();
160 QList<int> QgsSegmentizeByMaximumAngleAlgorithm::inputLayerTypes()
const
165 void QgsSegmentizeByMaximumAngleAlgorithm::initParameters(
const QVariantMap & )
167 std::unique_ptr< QgsProcessingParameterNumber > tolerance = qgis::make_unique< QgsProcessingParameterNumber >( QStringLiteral(
"ANGLE" ),
169 5.0,
false, 0, 360.0 );
170 tolerance->setIsDynamic(
true );
172 tolerance->setDynamicLayerParameterName( QStringLiteral(
"INPUT" ) );
173 addParameter( tolerance.release() );
176 bool QgsSegmentizeByMaximumAngleAlgorithm::supportInPlaceEdit(
const QgsMapLayer *layer )
const
184 mTolerance = parameterAsDouble( parameters, QStringLiteral(
"ANGLE" ), context );
186 if ( mDynamicTolerance )
187 mToleranceProperty = parameters.value( QStringLiteral(
"ANGLE" ) ).value<
QgsProperty >();
198 double tolerance = mTolerance;
199 if ( mDynamicTolerance )
200 tolerance = mToleranceProperty.valueAsDouble( context.
expressionContext(), tolerance );