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." );
60QString QgsSegmentizeByMaximumDistanceAlgorithm::shortDescription()
const
62 return QObject::tr(
"Segmentizes a geometry by converting curved sections to linear sections, "
63 "given the maximum allowed offset distance between the original curve and the segmentized representation." );
66QgsSegmentizeByMaximumDistanceAlgorithm *QgsSegmentizeByMaximumDistanceAlgorithm::createInstance()
const
68 return new QgsSegmentizeByMaximumDistanceAlgorithm();
71QList<int> QgsSegmentizeByMaximumDistanceAlgorithm::inputLayerTypes()
const
76void QgsSegmentizeByMaximumDistanceAlgorithm::initParameters(
const QVariantMap & )
78 auto tolerance = std::make_unique<QgsProcessingParameterDistance>( QStringLiteral(
"DISTANCE" ), QObject::tr(
"Maximum offset distance" ), 1.0, QStringLiteral(
"INPUT" ),
false, 0, 10000000.0 );
79 tolerance->setIsDynamic(
true );
81 tolerance->setDynamicLayerParameterName( QStringLiteral(
"INPUT" ) );
82 addParameter( tolerance.release() );
85bool QgsSegmentizeByMaximumDistanceAlgorithm::supportInPlaceEdit(
const QgsMapLayer *layer )
const
93 mTolerance = parameterAsDouble( parameters, QStringLiteral(
"DISTANCE" ), context );
95 if ( mDynamicTolerance )
96 mToleranceProperty = parameters.value( QStringLiteral(
"DISTANCE" ) ).value<
QgsProperty>();
107 double tolerance = mTolerance;
108 if ( mDynamicTolerance )
109 tolerance = mToleranceProperty.valueAsDouble( context.
expressionContext(), tolerance );
117QString QgsSegmentizeByMaximumAngleAlgorithm::name()
const
119 return QStringLiteral(
"segmentizebymaxangle" );
122QString QgsSegmentizeByMaximumAngleAlgorithm::displayName()
const
124 return QObject::tr(
"Segmentize by maximum angle" );
127QStringList QgsSegmentizeByMaximumAngleAlgorithm::tags()
const
129 return QObject::tr(
"straighten,linearize,densify,curves,curved,circular,angle" ).split(
',' );
132QString QgsSegmentizeByMaximumAngleAlgorithm::group()
const
134 return QObject::tr(
"Vector geometry" );
137QString QgsSegmentizeByMaximumAngleAlgorithm::groupId()
const
139 return QStringLiteral(
"vectorgeometry" );
142QString QgsSegmentizeByMaximumAngleAlgorithm::outputName()
const
144 return QObject::tr(
"Segmentized" );
147QString QgsSegmentizeByMaximumAngleAlgorithm::shortHelpString()
const
149 return QObject::tr(
"This algorithm segmentizes a geometry by converting curved sections to linear sections.\n\n"
150 "The segmentization is performed by specifying the maximum allowed radius angle between vertices "
151 "on the straightened geometry (e.g the angle of the arc created from the original arc center to consecutive "
152 "output vertices on the linearized geometry).\n\n"
153 "Non-curved geometries will be retained without change." );
156QString QgsSegmentizeByMaximumAngleAlgorithm::shortDescription()
const
158 return QObject::tr(
"Segmentizes a geometry by converting curved sections to linear sections, "
159 "given the maximum allowed radius angle between vertices on the straightened geometry." );
162QgsSegmentizeByMaximumAngleAlgorithm *QgsSegmentizeByMaximumAngleAlgorithm::createInstance()
const
164 return new QgsSegmentizeByMaximumAngleAlgorithm();
167QList<int> QgsSegmentizeByMaximumAngleAlgorithm::inputLayerTypes()
const
172void QgsSegmentizeByMaximumAngleAlgorithm::initParameters(
const QVariantMap & )
174 auto tolerance = std::make_unique<QgsProcessingParameterNumber>( QStringLiteral(
"ANGLE" ), QObject::tr(
"Maximum angle between vertices (degrees)" ),
Qgis::ProcessingNumberParameterType::Double, 5.0,
false, 0, 360.0 );
175 tolerance->setIsDynamic(
true );
177 tolerance->setDynamicLayerParameterName( QStringLiteral(
"INPUT" ) );
178 addParameter( tolerance.release() );
181bool QgsSegmentizeByMaximumAngleAlgorithm::supportInPlaceEdit(
const QgsMapLayer *layer )
const
189 mTolerance = parameterAsDouble( parameters, QStringLiteral(
"ANGLE" ), context );
191 if ( mDynamicTolerance )
192 mToleranceProperty = parameters.value( QStringLiteral(
"ANGLE" ) ).value<
QgsProperty>();
203 double tolerance = mTolerance;
204 if ( mDynamicTolerance )
205 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