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
58 return QObject::tr(
"This algorithm segmentizes a geometry by converting curved sections to linear sections.\n\n"
59 "The segmentization is performed by specifying the maximum allowed offset distance between the original "
60 "curve and the segmentized representation.\n\n"
61 "Non-curved geometries will be retained without change." );
64QString QgsSegmentizeByMaximumDistanceAlgorithm::shortDescription()
const
66 return QObject::tr(
"Segmentizes a geometry by converting curved sections to linear sections, "
67 "given the maximum allowed offset distance between the original curve and the segmentized representation." );
70QgsSegmentizeByMaximumDistanceAlgorithm *QgsSegmentizeByMaximumDistanceAlgorithm::createInstance()
const
72 return new QgsSegmentizeByMaximumDistanceAlgorithm();
75QList<int> QgsSegmentizeByMaximumDistanceAlgorithm::inputLayerTypes()
const
80void QgsSegmentizeByMaximumDistanceAlgorithm::initParameters(
const QVariantMap & )
82 auto tolerance = std::make_unique<QgsProcessingParameterDistance>( u
"DISTANCE"_s, QObject::tr(
"Maximum offset distance" ), 1.0, u
"INPUT"_s,
false, 0, 10000000.0 );
83 tolerance->setIsDynamic(
true );
85 tolerance->setDynamicLayerParameterName( u
"INPUT"_s );
86 addParameter( tolerance.release() );
89bool QgsSegmentizeByMaximumDistanceAlgorithm::supportInPlaceEdit(
const QgsMapLayer *layer )
const
97 mTolerance = parameterAsDouble( parameters, u
"DISTANCE"_s, context );
99 if ( mDynamicTolerance )
100 mToleranceProperty = parameters.value( u
"DISTANCE"_s ).value<
QgsProperty>();
111 double tolerance = mTolerance;
112 if ( mDynamicTolerance )
113 tolerance = mToleranceProperty.valueAsDouble( context.
expressionContext(), tolerance );
121QString QgsSegmentizeByMaximumAngleAlgorithm::name()
const
123 return u
"segmentizebymaxangle"_s;
126QString QgsSegmentizeByMaximumAngleAlgorithm::displayName()
const
128 return QObject::tr(
"Segmentize by maximum angle" );
131QStringList QgsSegmentizeByMaximumAngleAlgorithm::tags()
const
133 return QObject::tr(
"straighten,linearize,densify,curves,curved,circular,angle" ).split(
',' );
136QString QgsSegmentizeByMaximumAngleAlgorithm::group()
const
138 return QObject::tr(
"Vector geometry" );
141QString QgsSegmentizeByMaximumAngleAlgorithm::groupId()
const
143 return u
"vectorgeometry"_s;
146QString QgsSegmentizeByMaximumAngleAlgorithm::outputName()
const
148 return QObject::tr(
"Segmentized" );
151QString QgsSegmentizeByMaximumAngleAlgorithm::shortHelpString()
const
153 return QObject::tr(
"This algorithm segmentizes a geometry by converting curved sections to linear sections.\n\n"
154 "The segmentization is performed by specifying the maximum allowed radius angle between vertices "
155 "on the straightened geometry (e.g the angle of the arc created from the original arc center to consecutive "
156 "output vertices on the linearized geometry).\n\n"
157 "Non-curved geometries will be retained without change." );
160QString QgsSegmentizeByMaximumAngleAlgorithm::shortDescription()
const
162 return QObject::tr(
"Segmentizes a geometry by converting curved sections to linear sections, "
163 "given the maximum allowed radius angle between vertices on the straightened geometry." );
166QgsSegmentizeByMaximumAngleAlgorithm *QgsSegmentizeByMaximumAngleAlgorithm::createInstance()
const
168 return new QgsSegmentizeByMaximumAngleAlgorithm();
171QList<int> QgsSegmentizeByMaximumAngleAlgorithm::inputLayerTypes()
const
176void QgsSegmentizeByMaximumAngleAlgorithm::initParameters(
const QVariantMap & )
179 tolerance->setIsDynamic(
true );
181 tolerance->setDynamicLayerParameterName( u
"INPUT"_s );
182 addParameter( tolerance.release() );
185bool QgsSegmentizeByMaximumAngleAlgorithm::supportInPlaceEdit(
const QgsMapLayer *layer )
const
193 mTolerance = parameterAsDouble( parameters, u
"ANGLE"_s, context );
195 if ( mDynamicTolerance )
196 mToleranceProperty = parameters.value( u
"ANGLE"_s ).value<
QgsProperty>();
207 double tolerance = mTolerance;
208 if ( mDynamicTolerance )
209 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