QGIS API Documentation
4.3.0-Master (52aa6503bed)
Toggle main menu visibility
Loading...
Searching...
No Matches
src
analysis
processing
qgsalgorithmtransect.cpp
Go to the documentation of this file.
1
/***************************************************************************
2
qgsalgorithmtransect.cpp
3
-------------------------
4
begin : October 2017
5
copyright : (C) 2017 by Loïc Bartoletti
6
email : lituus at free dot fr
7
***************************************************************************/
8
9
/***************************************************************************
10
* *
11
* This program is free software; you can redistribute it and/or modify *
12
* it under the terms of the GNU General Public License as published by *
13
* the Free Software Foundation; either version 2 of the License, or *
14
* (at your option) any later version. *
15
* *
16
***************************************************************************/
17
18
#include "
qgsalgorithmtransect.h
"
19
20
#include "
qgslinestring.h
"
21
#include "
qgsmultilinestring.h
"
22
23
#include <QString>
24
25
using namespace
Qt::StringLiterals;
26
28
29
QString QgsTransectAlgorithm::name()
const
30
{
31
return
u
"transect"
_s;
32
}
33
34
QString QgsTransectAlgorithm::displayName()
const
35
{
36
return
QObject::tr(
"Transect"
);
37
}
38
39
QString QgsTransectAlgorithm::shortHelpString()
const
40
{
41
return
QObject::tr(
"This algorithm creates transects on vertices for (multi)linestrings.\n"
)
42
+ QObject::tr(
"A transect is a line oriented from an angle (by default perpendicular) to the input polylines (at vertices)."
)
43
+ u
"\n\n"
_s
44
+ QObject::tr(
"Field(s) from feature(s) are returned in the transect with these new fields:\n"
)
45
+ QObject::tr(
"- TR_FID: ID of the original feature\n"
)
46
+ QObject::tr(
"- TR_ID: ID of the transect. Each transect have an unique ID\n"
)
47
+ QObject::tr(
"- TR_SEGMENT: ID of the segment of the linestring\n"
)
48
+ QObject::tr(
"- TR_ANGLE: Angle in degrees from the original line at the vertex\n"
)
49
+ QObject::tr(
"- TR_LENGTH: Total length of the transect returned\n"
)
50
+ QObject::tr(
"- TR_ORIENT: Side of the transect (only on the left or right of the line, or both side)\n"
);
51
}
52
53
QgsTransectAlgorithm *QgsTransectAlgorithm::createInstance()
const
54
{
55
return
new
QgsTransectAlgorithm();
56
}
57
58
void
QgsTransectAlgorithm::addAlgorithmParams()
59
{
60
// No additional parameters for the basic transect algorithm (vertex-based only)
61
}
62
63
bool
QgsTransectAlgorithm::prepareAlgorithmTransectParameters(
const
QVariantMap &,
QgsProcessingContext
&,
QgsProcessingFeedback
* )
64
{
65
// No additional preparation needed for basic transect algorithm
66
return
true
;
67
}
68
69
std::vector<QgsPoint> QgsTransectAlgorithm::generateSamplingPoints(
const
QgsLineString
&line,
const
QVariantMap &,
QgsProcessingContext
& )
70
{
71
QGS_MARK_ALGORITHM_SOURCE
72
73
std::vector<QgsPoint> samplingPoints;
74
75
for
(
auto
it = line.
vertices_begin
(); it != line.
vertices_end
(); ++it )
76
samplingPoints.push_back( *it );
77
78
return
samplingPoints;
79
}
80
81
double
QgsTransectAlgorithm::calculateAzimuth(
const
QgsLineString
&line,
const
QgsPoint
&,
int
pointIndex )
82
{
83
return
line.
vertexAngle
(
QgsVertexId
( 0, 0, pointIndex ) );
84
}
85
QgsAbstractGeometry::vertices_end
vertex_iterator vertices_end() const
Returns STL-style iterator pointing to the imaginary vertex after the last vertex of the geometry.
Definition
qgsabstractgeometry.h:1089
QgsAbstractGeometry::vertices_begin
vertex_iterator vertices_begin() const
Returns STL-style iterator pointing to the first vertex of the geometry.
Definition
qgsabstractgeometry.h:1077
QgsLineString
Line string geometry type, with support for z-dimension and m-values.
Definition
qgslinestring.h:49
QgsLineString::vertexAngle
double vertexAngle(QgsVertexId vertex) const override
Returns approximate angle at a vertex.
Definition
qgslinestring.cpp:1881
QgsPoint
Point geometry type, with support for z-dimension and m-values.
Definition
qgspoint.h:53
QgsProcessingContext
Contains information about the context in which a processing algorithm is executed.
Definition
qgsprocessingcontext.h:45
QgsProcessingFeedback
Base class for providing feedback from a processing algorithm.
Definition
qgsprocessingfeedback.h:40
qgsalgorithmtransect.h
qgslinestring.h
qgsmultilinestring.h
QgsVertexId
Utility class for identifying a unique vertex within a geometry.
Definition
qgsvertexid.h:35
Generated on
for QGIS API Documentation by
1.17.0