22using namespace Qt::StringLiterals;
26QString QgsSegmentizeByMaximumDistanceAlgorithm::name()
const
28 return u
"segmentizebymaxdistance"_s;
31QString QgsSegmentizeByMaximumDistanceAlgorithm::displayName()
const
33 return QObject::tr(
"Segmentize by maximum distance" );
36QStringList QgsSegmentizeByMaximumDistanceAlgorithm::tags()
const
38 return QObject::tr(
"straighten,linearize,densify,curves,curved,circular" ).split(
',' );
41QString QgsSegmentizeByMaximumDistanceAlgorithm::group()
const
43 return QObject::tr(
"Vector geometry" );
46QString QgsSegmentizeByMaximumDistanceAlgorithm::groupId()
const
48 return u
"vectorgeometry"_s;
51QString QgsSegmentizeByMaximumDistanceAlgorithm::outputName()
const
53 return QObject::tr(
"Segmentized" );
56QString QgsSegmentizeByMaximumDistanceAlgorithm::shortHelpString()
const
59 "This algorithm segmentizes a geometry by converting curved sections to linear sections.\n\n"
60 "The segmentization is performed by specifying the maximum allowed offset distance between the original "
61 "curve and the segmentized representation.\n\n"
62 "Non-curved geometries will be retained without change."
66QString QgsSegmentizeByMaximumDistanceAlgorithm::shortDescription()
const
69 "Segmentizes a geometry by converting curved sections to linear sections, "
70 "given the maximum allowed offset distance between the original curve and the segmentized representation."
74QgsSegmentizeByMaximumDistanceAlgorithm *QgsSegmentizeByMaximumDistanceAlgorithm::createInstance()
const
76 return new QgsSegmentizeByMaximumDistanceAlgorithm();
79QList<int> QgsSegmentizeByMaximumDistanceAlgorithm::inputLayerTypes()
const
84void QgsSegmentizeByMaximumDistanceAlgorithm::initParameters(
const QVariantMap & )
86 auto tolerance = std::make_unique<QgsProcessingParameterDistance>( u
"DISTANCE"_s, QObject::tr(
"Maximum offset distance" ), 1.0, u
"INPUT"_s,
false, 0, 10000000.0 );
87 tolerance->setIsDynamic(
true );
89 tolerance->setDynamicLayerParameterName( u
"INPUT"_s );
90 addParameter( tolerance.release() );
93bool QgsSegmentizeByMaximumDistanceAlgorithm::supportInPlaceEdit(
const QgsMapLayer *layer )
const
101 mTolerance = parameterAsDouble( parameters, u
"DISTANCE"_s, context );
103 if ( mDynamicTolerance )
104 mToleranceProperty = parameters.value( u
"DISTANCE"_s ).value<
QgsProperty>();
115 double tolerance = mTolerance;
116 if ( mDynamicTolerance )
117 tolerance = mToleranceProperty.valueAsDouble( context.
expressionContext(), tolerance );
125QString QgsSegmentizeByMaximumAngleAlgorithm::name()
const
127 return u
"segmentizebymaxangle"_s;
130QString QgsSegmentizeByMaximumAngleAlgorithm::displayName()
const
132 return QObject::tr(
"Segmentize by maximum angle" );
135QStringList QgsSegmentizeByMaximumAngleAlgorithm::tags()
const
137 return QObject::tr(
"straighten,linearize,densify,curves,curved,circular,angle" ).split(
',' );
140QString QgsSegmentizeByMaximumAngleAlgorithm::group()
const
142 return QObject::tr(
"Vector geometry" );
145QString QgsSegmentizeByMaximumAngleAlgorithm::groupId()
const
147 return u
"vectorgeometry"_s;
150QString QgsSegmentizeByMaximumAngleAlgorithm::outputName()
const
152 return QObject::tr(
"Segmentized" );
155QString QgsSegmentizeByMaximumAngleAlgorithm::shortHelpString()
const
158 "This algorithm segmentizes a geometry by converting curved sections to linear sections.\n\n"
159 "The segmentization is performed by specifying the maximum allowed radius angle between vertices "
160 "on the straightened geometry (e.g the angle of the arc created from the original arc center to consecutive "
161 "output vertices on the linearized geometry).\n\n"
162 "Non-curved geometries will be retained without change."
166QString QgsSegmentizeByMaximumAngleAlgorithm::shortDescription()
const
169 "Segmentizes a geometry by converting curved sections to linear sections, "
170 "given the maximum allowed radius angle between vertices on the straightened geometry."
174QgsSegmentizeByMaximumAngleAlgorithm *QgsSegmentizeByMaximumAngleAlgorithm::createInstance()
const
176 return new QgsSegmentizeByMaximumAngleAlgorithm();
179QList<int> QgsSegmentizeByMaximumAngleAlgorithm::inputLayerTypes()
const
184void QgsSegmentizeByMaximumAngleAlgorithm::initParameters(
const QVariantMap & )
187 tolerance->setIsDynamic(
true );
189 tolerance->setDynamicLayerParameterName( u
"INPUT"_s );
190 addParameter( tolerance.release() );
193bool QgsSegmentizeByMaximumAngleAlgorithm::supportInPlaceEdit(
const QgsMapLayer *layer )
const
201 mTolerance = parameterAsDouble( parameters, u
"ANGLE"_s, context );
203 if ( mDynamicTolerance )
204 mToleranceProperty = parameters.value( u
"ANGLE"_s ).value<
QgsProperty>();
215 double tolerance = mTolerance;
216 if ( mDynamicTolerance )
217 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