25using namespace Qt::StringLiterals;
29QString QgsTransectFixedDistanceAlgorithm::name()
const
31 return u
"transectfixeddistance"_s;
34QString QgsTransectFixedDistanceAlgorithm::displayName()
const
36 return QObject::tr(
"Transect (fixed distance)" );
39QStringList QgsTransectFixedDistanceAlgorithm::tags()
const
41 return QObject::tr(
"transect,station,lines,extend,fixed,interval,distance" ).split(
',' );
44QString QgsTransectFixedDistanceAlgorithm::shortHelpString()
const
46 return QObject::tr(
"This algorithm creates transects at fixed distance intervals along (multi)linestrings.\n" )
47 + QObject::tr(
"A transect is a line oriented from an angle (by default perpendicular) to the input polylines at regular intervals." )
49 + QObject::tr(
"Field(s) from feature(s) are returned in the transect with these new fields:\n" )
50 + QObject::tr(
"- TR_FID: ID of the original feature\n" )
51 + QObject::tr(
"- TR_ID: ID of the transect. Each transect have an unique ID\n" )
52 + QObject::tr(
"- TR_SEGMENT: ID of the segment of the linestring\n" )
53 + QObject::tr(
"- TR_ANGLE: Angle in degrees from the original line at the vertex\n" )
54 + QObject::tr(
"- TR_LENGTH: Total length of the transect returned\n" )
55 + QObject::tr(
"- TR_ORIENT: Side of the transect (only on the left or right of the line, or both side)\n" );
58QString QgsTransectFixedDistanceAlgorithm::shortDescription()
const
60 return QObject::tr(
"Creates transects at fixed distance intervals along (multi)linestrings." );
63QgsTransectFixedDistanceAlgorithm *QgsTransectFixedDistanceAlgorithm::createInstance()
const
65 return new QgsTransectFixedDistanceAlgorithm();
68void QgsTransectFixedDistanceAlgorithm::addAlgorithmParams()
76 mInterval = parameterAsDouble( parameters, u
"INTERVAL"_s, context );
77 mIncludeStartPoint = parameterAsBool( parameters, u
"INCLUDE_START"_s, context );
83 std::vector<QgsPoint> samplingPoints;
91 if ( mIncludeStartPoint )
96 line.
visitPointsByRegularDistance( mInterval, [&](
double x,
double y,
double z,
double m,
double,
double,
double,
double,
double,
double,
double,
double ) ->
bool {
97 samplingPoints.emplace_back( pointType, x, y, z, m );
101 return samplingPoints;
104double QgsTransectFixedDistanceAlgorithm::calculateAzimuth(
const QgsLineString &line,
const QgsPoint &point,
int )
112 if ( sqrDist < 0 || vid.
vertex < 1 )
static const double DEFAULT_SEGMENT_EPSILON
Default snapping tolerance for segments.
WkbType
The WKB type describes the number of dimensions a geometry has.
bool isMeasure() const
Returns true if the geometry contains m values.
bool is3D() const
Returns true if the geometry is 3D and contains a z-value.
QgsPoint vertexAt(QgsVertexId id) const override
Returns the point corresponding to a specified vertex id.
Line string geometry type, with support for z-dimension and m-values.
QgsPoint startPoint() const override
Returns the starting point of the curve.
int numPoints() const override
Returns the number of points in the curve.
QgsPoint pointN(int i) const
Returns the specified point from inside the line string.
void visitPointsByRegularDistance(double distance, const std::function< bool(double x, double y, double z, double m, double startSegmentX, double startSegmentY, double startSegmentZ, double startSegmentM, double endSegmentX, double endSegmentY, double endSegmentZ, double endSegmentM) > &visitPoint) const
Visits regular points along the linestring, spaced by distance.
double closestSegment(const QgsPoint &pt, QgsPoint &segmentPt, QgsVertexId &vertexAfter, int *leftOf=nullptr, double epsilon=4 *std::numeric_limits< double >::epsilon()) const override
Searches for the closest segment of the geometry to a given point.
Point geometry type, with support for z-dimension and m-values.
double azimuth(const QgsPoint &other) const
Calculates Cartesian azimuth between this point and other one (clockwise in degree,...
Contains information about the context in which a processing algorithm is executed.
Base class for providing feedback from a processing algorithm.
A boolean parameter for processing algorithms.
A double numeric parameter for distance values.
static Qgis::WkbType addM(Qgis::WkbType type)
Adds the m dimension to a WKB type and returns the new type.
Utility class for identifying a unique vertex within a geometry.