22QString QgsSegmentizeByMaximumDistanceAlgorithm::name()
const
24 return QStringLiteral(
"segmentizebymaxdistance" );
27QString QgsSegmentizeByMaximumDistanceAlgorithm::displayName()
const
29 return QObject::tr(
"Segmentize by maximum distance" );
32QStringList QgsSegmentizeByMaximumDistanceAlgorithm::tags()
const
34 return QObject::tr(
"straighten,linearize,densify,curves,curved,circular" ).split(
',' );
37QString QgsSegmentizeByMaximumDistanceAlgorithm::group()
const
39 return QObject::tr(
"Vector geometry" );
42QString QgsSegmentizeByMaximumDistanceAlgorithm::groupId()
const
44 return QStringLiteral(
"vectorgeometry" );
47QString QgsSegmentizeByMaximumDistanceAlgorithm::outputName()
const
49 return QObject::tr(
"Segmentized" );
52QString 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." );
60QgsSegmentizeByMaximumDistanceAlgorithm *QgsSegmentizeByMaximumDistanceAlgorithm::createInstance()
const
62 return new QgsSegmentizeByMaximumDistanceAlgorithm();
65QList<int> QgsSegmentizeByMaximumDistanceAlgorithm::inputLayerTypes()
const
70void QgsSegmentizeByMaximumDistanceAlgorithm::initParameters(
const QVariantMap & )
72 std::unique_ptr<QgsProcessingParameterDistance> tolerance = std::make_unique<QgsProcessingParameterDistance>( QStringLiteral(
"DISTANCE" ), QObject::tr(
"Maximum offset distance" ), 1.0, QStringLiteral(
"INPUT" ),
false, 0, 10000000.0 );
73 tolerance->setIsDynamic(
true );
75 tolerance->setDynamicLayerParameterName( QStringLiteral(
"INPUT" ) );
76 addParameter( tolerance.release() );
79bool QgsSegmentizeByMaximumDistanceAlgorithm::supportInPlaceEdit(
const QgsMapLayer *layer )
const
87 mTolerance = parameterAsDouble( parameters, QStringLiteral(
"DISTANCE" ), context );
89 if ( mDynamicTolerance )
90 mToleranceProperty = parameters.value( QStringLiteral(
"DISTANCE" ) ).value<
QgsProperty>();
101 double tolerance = mTolerance;
102 if ( mDynamicTolerance )
103 tolerance = mToleranceProperty.valueAsDouble( context.
expressionContext(), tolerance );
111QString QgsSegmentizeByMaximumAngleAlgorithm::name()
const
113 return QStringLiteral(
"segmentizebymaxangle" );
116QString QgsSegmentizeByMaximumAngleAlgorithm::displayName()
const
118 return QObject::tr(
"Segmentize by maximum angle" );
121QStringList QgsSegmentizeByMaximumAngleAlgorithm::tags()
const
123 return QObject::tr(
"straighten,linearize,densify,curves,curved,circular,angle" ).split(
',' );
126QString QgsSegmentizeByMaximumAngleAlgorithm::group()
const
128 return QObject::tr(
"Vector geometry" );
131QString QgsSegmentizeByMaximumAngleAlgorithm::groupId()
const
133 return QStringLiteral(
"vectorgeometry" );
136QString QgsSegmentizeByMaximumAngleAlgorithm::outputName()
const
138 return QObject::tr(
"Segmentized" );
141QString QgsSegmentizeByMaximumAngleAlgorithm::shortHelpString()
const
143 return QObject::tr(
"This algorithm segmentizes a geometry by converting curved sections to linear sections.\n\n"
144 "The segmentization is performed by specifying the maximum allowed radius angle between vertices "
145 "on the straightened geometry (e.g the angle of the arc created from the original arc center to consecutive "
146 "output vertices on the linearized geometry).\n\n"
147 "Non-curved geometries will be retained without change." );
150QgsSegmentizeByMaximumAngleAlgorithm *QgsSegmentizeByMaximumAngleAlgorithm::createInstance()
const
152 return new QgsSegmentizeByMaximumAngleAlgorithm();
155QList<int> QgsSegmentizeByMaximumAngleAlgorithm::inputLayerTypes()
const
160void QgsSegmentizeByMaximumAngleAlgorithm::initParameters(
const QVariantMap & )
162 std::unique_ptr<QgsProcessingParameterNumber> tolerance = std::make_unique<QgsProcessingParameterNumber>( QStringLiteral(
"ANGLE" ), QObject::tr(
"Maximum angle between vertices (degrees)" ),
Qgis::ProcessingNumberParameterType::Double, 5.0,
false, 0, 360.0 );
163 tolerance->setIsDynamic(
true );
165 tolerance->setDynamicLayerParameterName( QStringLiteral(
"INPUT" ) );
166 addParameter( tolerance.release() );
169bool QgsSegmentizeByMaximumAngleAlgorithm::supportInPlaceEdit(
const QgsMapLayer *layer )
const
177 mTolerance = parameterAsDouble( parameters, QStringLiteral(
"ANGLE" ), context );
179 if ( mDynamicTolerance )
180 mToleranceProperty = parameters.value( QStringLiteral(
"ANGLE" ) ).value<
QgsProperty>();
191 double tolerance = mTolerance;
192 if ( mDynamicTolerance )
193 tolerance = mToleranceProperty.valueAsDouble( context.
expressionContext(), tolerance );
@ VectorPolygon
Vector polygon layers.
@ VectorLine
Vector line layers.
@ Double
Double/float values.
@ MaximumDifference
Maximum distance between an arbitrary point on the original curve and closest point on its approximat...
@ MaximumAngle
Maximum angle between generating radii (lines from arc center to output vertices)
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.
void convertToStraightSegment(double tolerance=M_PI/180., QgsAbstractGeometry::SegmentationToleranceType toleranceType=QgsAbstractGeometry::MaximumAngle)
Converts the geometry to straight line segments, if it is a curved geometry type.
Base class for all map layer types.
Contains information about the context in which a processing algorithm is executed.
QgsExpressionContext & expressionContext()
Returns the expression context.
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.
@ DoublePositive
Positive double value (including 0)
A store for object properties.
QList< QgsFeature > QgsFeatureList