QGIS API Documentation 4.3.0-Master (18b5e825726)
Loading...
Searching...
No Matches
qgslinestring.h
Go to the documentation of this file.
1/***************************************************************************
2 qgslinestring.h
3 -----------------
4 begin : September 2014
5 copyright : (C) 2014 by Marco Hugentobler
6 email : marco at sourcepole dot ch
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#ifndef QGSLINESTRING_H
19#define QGSLINESTRING_H
20
21
22#include "qgis_core.h"
23#include "qgis_sip.h"
24#include "qgscompoundcurve.h"
25#include "qgscurve.h"
27#include "qgssimplecurve.h"
28
29#include <QPolygonF>
30#include <QString>
31
32using namespace Qt::StringLiterals;
33
35class QgsBox3D;
36
37/***************************************************************************
38 * This class is considered CRITICAL and any change MUST be accompanied with
39 * full unit tests in testqgsgeometry.cpp.
40 * See details in QEP #17
41 ****************************************************************************/
42
48class CORE_EXPORT QgsLineString : public QgsSimpleCurve
49{
50 public:
51 // clang-format off
56 // clang-format on
57#ifndef SIP_RUN
58
64 QgsLineString( const QVector<QgsPoint> &points );
65
71 QgsLineString( const QVector<QgsPointXY> &points );
72#else
73// clang-format off
74
82 QgsLineString( SIP_PYOBJECT points SIP_TYPEHINT( Sequence[Union[QgsPoint, QgsPointXY, Sequence[float]]] ) ) SIP_HOLDGIL [( const QVector<double> &x, const QVector<double> &y, const QVector<double> &z = QVector<double>(), const QVector<double> &m = QVector<double>(), bool is25DType = false )];
83 % MethodCode
84 if ( !PySequence_Check( a0 ) )
85 {
86 PyErr_SetString( PyExc_TypeError, u"A sequence of QgsPoint, QgsPointXY or array of floats is expected"_s.toUtf8().constData() );
87 sipIsErr = 1;
88 }
89 else
90 {
91 int state;
92 const int size = PySequence_Size( a0 );
93 QVector< double > xl;
94 QVector< double > yl;
95 bool hasZ = false;
96 QVector< double > zl;
97 bool hasM = false;
98 QVector< double > ml;
99 xl.reserve( size );
100 yl.reserve( size );
101
102 bool is25D = false;
103
104 sipIsErr = 0;
105 for ( int i = 0; i < size; ++i )
106 {
107 PyObject *value = PySequence_GetItem( a0, i );
108 if ( !value )
109 {
110 PyErr_SetString( PyExc_TypeError, u"Invalid type at index %1."_s.arg( i ) .toUtf8().constData() );
111 sipIsErr = 1;
112 break;
113 }
114
115 if ( PySequence_Check( value ) )
116 {
117 const int elementSize = PySequence_Size( value );
118 if ( elementSize < 2 || elementSize > 4 )
119 {
120 sipIsErr = 1;
121 PyErr_SetString( PyExc_TypeError, u"Invalid sequence size at index %1. Expected an array of 2-4 float values, got %2."_s.arg( i ).arg( elementSize ).toUtf8().constData() );
122 Py_DECREF( value );
123 break;
124 }
125 else
126 {
127 sipIsErr = 0;
128 for ( int j = 0; j < elementSize; ++j )
129 {
130 PyObject *element = PySequence_GetItem( value, j );
131 if ( !element )
132 {
133 PyErr_SetString( PyExc_TypeError, u"Invalid type at index %1."_s.arg( i ) .toUtf8().constData() );
134 sipIsErr = 1;
135 break;
136 }
137
138 PyErr_Clear();
139 double d = PyFloat_AsDouble( element );
140 if ( PyErr_Occurred() )
141 {
142 Py_DECREF( element );
143 sipIsErr = 1;
144 break;
145 }
146 if ( j == 0 )
147 xl.append( d );
148 else if ( j == 1 )
149 yl.append( d );
150
151 if ( i == 0 && j == 2 )
152 {
153 hasZ = true;
154 zl.reserve( size );
155 zl.append( d );
156 }
157 else if ( i > 0 && j == 2 && hasZ )
158 {
159 zl.append( d );
160 }
161
162 if ( i == 0 && j == 3 )
163 {
164 hasM = true;
165 ml.reserve( size );
166 ml.append( d );
167 }
168 else if ( i > 0 && j == 3 && hasM )
169 {
170 ml.append( d );
171 }
172
173 Py_DECREF( element );
174 }
175
176 if ( hasZ && elementSize < 3 )
177 zl.append( std::numeric_limits< double >::quiet_NaN() );
178 if ( hasM && elementSize < 4 )
179 ml.append( std::numeric_limits< double >::quiet_NaN() );
180
181 Py_DECREF( value );
182 if ( sipIsErr )
183 {
184 break;
185 }
186 }
187 }
188 else
189 {
190 if ( sipCanConvertToType( value, sipType_QgsPointXY, SIP_NOT_NONE ) )
191 {
192 sipIsErr = 0;
193 QgsPointXY *p = reinterpret_cast<QgsPointXY *>( sipConvertToType( value, sipType_QgsPointXY, 0, SIP_NOT_NONE, &state, &sipIsErr ) );
194 if ( !sipIsErr )
195 {
196 xl.append( p->x() );
197 yl.append( p->y() );
198 }
199 sipReleaseType( p, sipType_QgsPointXY, state );
200 }
201 else if ( sipCanConvertToType( value, sipType_QgsPoint, SIP_NOT_NONE ) )
202 {
203 sipIsErr = 0;
204 QgsPoint *p = reinterpret_cast<QgsPoint *>( sipConvertToType( value, sipType_QgsPoint, 0, SIP_NOT_NONE, &state, &sipIsErr ) );
205 if ( !sipIsErr )
206 {
207 xl.append( p->x() );
208 yl.append( p->y() );
209
210 if ( i == 0 && p->is3D() )
211 {
212 hasZ = true;
213 zl.reserve( size );
214 zl.append( p->z() );
215 }
216 else if ( i > 0 && hasZ )
217 {
218 zl.append( p->z() );
219 }
220
221 if ( i == 0 && p->isMeasure() )
222 {
223 hasM = true;
224 ml.reserve( size );
225 ml.append( p->m() );
226 }
227 else if ( i > 0 && hasM )
228 {
229 ml.append( p->m() );
230 }
231
232 if ( i == 0 && p->wkbType() == Qgis::WkbType::Point25D )
233 is25D = true;
234 }
235 sipReleaseType( p, sipType_QgsPoint, state );
236 }
237 else
238 {
239 sipIsErr = 1;
240 }
241
242 Py_DECREF( value );
243
244 if ( sipIsErr )
245 {
246 // couldn't convert the sequence value to a QgsPoint or QgsPointXY
247 PyErr_SetString( PyExc_TypeError, u"Invalid type at index %1. Expected QgsPoint, QgsPointXY or array of floats."_s.arg( i ) .toUtf8().constData() );
248 break;
249 }
250 }
251 }
252 if ( sipIsErr == 0 )
253 sipCpp = new sipQgsLineString( QgsLineString( xl, yl, zl, ml, is25D ) );
254 }
255 % End
256// clang-format on
257#endif
258
264
282 QgsLineString( const QVector<double> &x, const QVector<double> &y,
283 const QVector<double> &z = QVector<double>(),
284 const QVector<double> &m = QVector<double>(), bool is25DType = false ) SIP_HOLDGIL;
285
290 QgsLineString( const QgsPoint &p1, const QgsPoint &p2 ) SIP_HOLDGIL;
291
302 static std::unique_ptr< QgsLineString > fromBezierCurve( const QgsPoint &start, const QgsPoint &controlPoint1, const QgsPoint &controlPoint2, const QgsPoint &end, int segments = 30 );
303
309 static std::unique_ptr< QgsLineString > fromQPolygonF( const QPolygonF &polygon );
310
311#ifndef SIP_RUN
312 using QgsSimpleCurve::setPoints; // make all setPoints() functions eligible for overload resolution
313#endif // !SIP_RUN
314
328 void setPoints( size_t size, const double *x, const double *y, const double *z = nullptr, const double *m = nullptr ) SIP_SKIP;
329
334 void addVertex( const QgsPoint &pt );
335
337 void close();
338
343 QgsCompoundCurve *toCurveType() const override SIP_FACTORY;
344
353 void extend( double startDistance, double endDistance, double startDeflection = 0, double endDeflection = 0 );
354
355#ifndef SIP_RUN
356
362 void visitPointsByRegularDistance( double distance, const std::function< bool( double x, double y, double z, double m,
363 double startSegmentX, double startSegmentY, double startSegmentZ, double startSegmentM,
364 double endSegmentX, double endSegmentY, double endSegmentZ, double endSegmentM
365 ) > &visitPoint ) const;
366#endif
367
368 //reimplemented methods
369 QString geometryType() const override SIP_HOLDGIL;
370
371 QgsLineString *clone() const override SIP_FACTORY;
372 void clear() override;
373 int indexOf( const QgsPoint &point ) const final;
374 bool isValid( QString &error SIP_OUT, Qgis::GeometryValidityFlags flags = Qgis::GeometryValidityFlags() ) const override;
375 QgsLineString *snappedToGrid( double hSpacing, double vSpacing, double dSpacing = 0, double mSpacing = 0, bool removeRedundantPoints = false ) const override SIP_FACTORY;
376 bool removeDuplicateNodes( double epsilon = 4 * std::numeric_limits<double>::epsilon(), bool useZValues = false ) override;
377 bool isClosed() const override SIP_HOLDGIL;
378 bool isClosed2D() const override SIP_HOLDGIL;
379 bool boundingBoxIntersects( const QgsRectangle &rectangle ) const override SIP_HOLDGIL;
380 bool boundingBoxIntersects( const QgsBox3D &box3d ) const override SIP_HOLDGIL;
381
389 QVector< QgsVertexId > collectDuplicateNodes( double epsilon = 4 * std::numeric_limits<double>::epsilon(), bool useZValues = false ) const;
390
391 QPolygonF asQPolygonF() const override;
392
393 QgsLineString *simplifyByDistance( double tolerance ) const override SIP_FACTORY;
394
395 QDomElement asGml2( QDomDocument &doc, int precision = 17, const QString &ns = "gml", QgsAbstractGeometry::AxisOrder axisOrder = QgsAbstractGeometry::AxisOrder::XY ) const override;
396 QDomElement asGml3( QDomDocument &doc, int precision = 17, const QString &ns = "gml", QgsAbstractGeometry::AxisOrder axisOrder = QgsAbstractGeometry::AxisOrder::XY ) const override;
397 json asJsonObject( int precision = 17, Qgis::GeoJsonProfile profile = Qgis::GeoJsonProfile::Legacy ) const override SIP_SKIP;
398 QString asKml( int precision = 17 ) const override;
399
400 //curve interface
401 double length() const override SIP_HOLDGIL;
402
403#ifndef SIP_RUN
404 std::tuple< std::unique_ptr< QgsCurve >, std::unique_ptr< QgsCurve > > splitCurveAtVertex( int index ) const final;
405#endif
406
415 QVector<QgsLineString *> splitToDisjointXYParts() const SIP_FACTORY;
416
423 double length3D() const SIP_HOLDGIL;
424
431 QgsLineString *curveToLine( double tolerance = M_PI_2 / 90, SegmentationToleranceType toleranceType = MaximumAngle ) const override SIP_FACTORY;
432
433 void draw( QPainter &p ) const override;
434
435 void addToPainterPath( QPainterPath &path ) const override;
436 void drawAsPolygon( QPainter &p ) const override;
437
438 bool insertVertex( QgsVertexId position, const QgsPoint &vertex ) override;
439 bool deleteVertex( QgsVertexId position ) override;
440 bool deleteVertices( const QSet<QgsVertexId> &positions ) override;
441
442 QgsLineString *reversed() const override SIP_FACTORY;
443 QgsPoint *interpolatePoint( double distance ) const override SIP_FACTORY;
444 QgsLineString *curveSubstring( double startDistance, double endDistance ) const override SIP_FACTORY;
445
446 double closestSegment( const QgsPoint &pt, QgsPoint &segmentPt SIP_OUT, QgsVertexId &vertexAfter SIP_OUT, int *leftOf SIP_OUT = nullptr, double epsilon = 4 * std::numeric_limits<double>::epsilon() ) const override;
447 bool pointAt( int node, QgsPoint &point, Qgis::VertexType &type ) const override;
448
449 QgsPoint centroid() const override;
450
461 void sumUpArea( double &sum SIP_OUT ) const override;
462
473 void sumUpArea3D( double &sum SIP_OUT ) const override;
474
475 double vertexAngle( QgsVertexId vertex ) const override;
476 double segmentLength( QgsVertexId startVertex ) const override;
477 double distanceBetweenVertices( QgsVertexId fromVertex, QgsVertexId toVertex ) const override;
478
479 bool convertTo( Qgis::WkbType type ) override;
480
481#ifndef SIP_RUN
490 inline static const QgsLineString *cast( const QgsAbstractGeometry *geom ) // cppcheck-suppress duplInheritedMember
491 {
492 if ( geom && QgsWkbTypes::flatType( geom->wkbType() ) == Qgis::WkbType::LineString )
493 return static_cast<const QgsLineString *>( geom );
494 return nullptr;
495 }
496
505 inline static QgsLineString *cast( QgsAbstractGeometry *geom ) // cppcheck-suppress duplInheritedMember
506 {
507 if ( geom && QgsWkbTypes::flatType( geom->wkbType() ) == Qgis::WkbType::LineString )
508 return static_cast<QgsLineString *>( geom );
509 return nullptr;
510 }
511#endif
512
514
515#ifdef SIP_RUN
516// clang-format off
517 SIP_PYOBJECT __repr__();
518 % MethodCode
519 QString wkt = sipCpp->asWkt();
520 if ( wkt.length() > 1000 )
521 wkt = wkt.left( 1000 ) + u"..."_s;
522 QString str = u"<QgsLineString: %1>"_s.arg( wkt );
523 sipRes = PyUnicode_FromString( str.toUtf8().constData() );
524 % End
525
535 SIP_PYOBJECT __getitem__( int index ) SIP_TYPEHINT( QgsPoint );
536 % MethodCode
537 const int count = sipCpp->numPoints();
538 if ( a0 < -count || a0 >= count )
539 {
540 PyErr_SetString( PyExc_IndexError, QByteArray::number( a0 ) );
541 sipIsErr = 1;
542 }
543 else
544 {
545 std::unique_ptr< QgsPoint > p;
546 if ( a0 >= 0 )
547 p = std::make_unique< QgsPoint >( sipCpp->pointN( a0 ) );
548 else
549 p = std::make_unique< QgsPoint >( sipCpp->pointN( count + a0 ) );
550 sipRes = sipConvertFromType( p.release(), sipType_QgsPoint, Py_None );
551 }
552 % End
553
563 void __setitem__( int index, const QgsPoint &point );
564 % MethodCode
565 const int count = sipCpp->numPoints();
566 if ( a0 < -count || a0 >= count )
567 {
568 PyErr_SetString( PyExc_IndexError, QByteArray::number( a0 ) );
569 sipIsErr = 1;
570 }
571 else
572 {
573 if ( a0 < 0 )
574 a0 = count + a0;
575 sipCpp->setXAt( a0, a1->x() );
576 sipCpp->setYAt( a0, a1->y() );
577 if ( sipCpp->isMeasure() )
578 sipCpp->setMAt( a0, a1->m() );
579 if ( sipCpp->is3D() )
580 sipCpp->setZAt( a0, a1->z() );
581 }
582 % End
583
584
594 void __delitem__( int index );
595 % MethodCode
596 const int count = sipCpp->numPoints();
597 if ( a0 >= 0 && a0 < count )
598 sipCpp->deleteVertex( QgsVertexId( 0, 0, a0 ) );
599 else if ( a0 < 0 && a0 >= -count )
600 sipCpp->deleteVertex( QgsVertexId( 0, 0, count + a0 ) );
601 else
602 {
603 PyErr_SetString( PyExc_IndexError, QByteArray::number( a0 ) );
604 sipIsErr = 1;
605 }
606 % End
607
608// clang-format on
609#endif
610
617 Q_DECL_DEPRECATED QgsBox3D calculateBoundingBox3d() const SIP_DEPRECATED;
618
624 QgsBox3D calculateBoundingBox3D() const override;
625
632 std::unique_ptr< QgsLineString > measuredLine( double start, double end ) const;
633
647 std::unique_ptr< QgsLineString > interpolateM( bool use3DDistance = true ) const;
648
673 bool lineLocatePointByM( double m, double &x SIP_OUT, double &y SIP_OUT, double &z SIP_OUT, double &distanceFromStart SIP_OUT, bool use3DDistance = true ) const;
674
675 private:
681 void fromWkbPoints( Qgis::WkbType type, const QgsConstWkbPtr &wkb )
682 {
683 mWkbType = type;
685 }
686
687 bool lineLocatePointByMPrivate( double m, double &x, double &y, double &z, double &distanceFromStart, bool use3DDistance, bool haveInterpolatedM ) const;
688
689 friend class QgsPolygon;
690 friend class QgsTriangle;
691 friend class TestQgsGeometry;
692
693};
694
695// clazy:excludeall=qstring-allocations
696
697#endif // QGSLINESTRING_H
QFlags< GeometryValidityFlag > GeometryValidityFlags
Geometry validity flags.
Definition qgis.h:2210
VertexType
Types of vertex.
Definition qgis.h:3260
GeoJsonProfile
GeoJson export Profile according to OGC Features and Geometries JSON - Part 1: Core https://docs....
Definition qgis.h:5045
@ Legacy
Legacy GeoJson profile used in QGIS prior to 4.2, which included some non-standard extensions and dev...
Definition qgis.h:5046
WkbType
The WKB type describes the number of dimensions a geometry has.
Definition qgis.h:294
@ LineString
LineString.
Definition qgis.h:297
@ Point25D
Point25D.
Definition qgis.h:361
virtual QgsAbstractGeometry * snappedToGrid(double hSpacing, double vSpacing, double dSpacing=0, double mSpacing=0, bool removeRedundantPoints=false) const =0
Makes a new geometry with all the points or vertices snapped to the closest point of the grid.
SegmentationToleranceType
Segmentation tolerance as maximum angle or maximum difference between approximation and circle.
@ MaximumAngle
Maximum angle between generating radii (lines from arc center to output vertices).
virtual bool convertTo(Qgis::WkbType type)
Converts the geometry to a specified type.
virtual double vertexAngle(QgsVertexId vertex) const =0
Returns approximate angle at a vertex.
virtual void draw(QPainter &p) const =0
Draws the geometry using the specified QPainter.
bool isMeasure() const
Returns true if the geometry contains m values.
virtual QgsAbstractGeometry * simplifyByDistance(double tolerance) const =0
Simplifies the geometry by applying the Douglas Peucker simplification by distance algorithm.
bool is3D() const
Returns true if the geometry is 3D and contains a z-value.
AxisOrder
Axis order for GML generation.
@ XY
X comes before Y (or lon before lat).
virtual QString geometryType() const =0
Returns a unique string representing the geometry type.
virtual QgsAbstractGeometry * createEmptyWithSameType() const =0
Creates a new geometry with the same class and same WKB type as the original and transfers ownership.
virtual bool deleteVertices(const QSet< QgsVertexId > &positions)=0
Deletes vertices within the geometry.
virtual QDomElement asGml2(QDomDocument &doc, int precision=17, const QString &ns="gml", AxisOrder axisOrder=QgsAbstractGeometry::AxisOrder::XY) const =0
Returns a GML2 representation of the geometry.
Qgis::WkbType wkbType() const
Returns the WKB type of the geometry.
virtual bool insertVertex(QgsVertexId position, const QgsPoint &vertex)=0
Inserts a vertex into the geometry.
virtual double length() const
Returns the planar, 2-dimensional length of the geometry.
virtual QDomElement asGml3(QDomDocument &doc, int precision=17, const QString &ns="gml", AxisOrder axisOrder=QgsAbstractGeometry::AxisOrder::XY) const =0
Returns a GML3 representation of the geometry.
virtual bool boundingBoxIntersects(const QgsRectangle &rectangle) const
Returns true if the bounding box of this geometry intersects with a rectangle.
virtual bool deleteVertex(QgsVertexId position)=0
Deletes a vertex within the geometry.
virtual json asJsonObject(int precision=17, Qgis::GeoJsonProfile profile=Qgis::GeoJsonProfile::Legacy) const
Returns a json object representation of the geometry with the given precision and profile.
virtual QgsPoint centroid() const
Returns the centroid of the geometry.
virtual double segmentLength(QgsVertexId startVertex) const =0
Returns the length of the segment of the geometry which begins at startVertex.
virtual bool removeDuplicateNodes(double epsilon=4 *std::numeric_limits< double >::epsilon(), bool useZValues=false)=0
Removes duplicate nodes from the geometry, wherever removing the nodes does not result in a degenerat...
QgsAbstractGeometry()=default
virtual double closestSegment(const QgsPoint &pt, QgsPoint &segmentPt, QgsVertexId &vertexAfter, int *leftOf=nullptr, double epsilon=4 *std::numeric_limits< double >::epsilon()) const =0
Searches for the closest segment of the geometry to a given point.
A 3-dimensional box composed of x, y, z coordinates.
Definition qgsbox3d.h:45
Compound curve geometry type.
virtual bool pointAt(int node, QgsPoint &point, Qgis::VertexType &type) const =0
Returns the point and vertex type of a point within the curve.
virtual QgsCurve * curveSubstring(double startDistance, double endDistance) const =0
Returns a new curve representing a substring of this curve.
virtual bool isClosed() const
Returns true if the curve is closed.
Definition qgscurve.cpp:53
bool isValid(QString &error, Qgis::GeometryValidityFlags flags=Qgis::GeometryValidityFlags()) const override
Checks validity of the geometry, and returns true if the geometry is valid.
Definition qgscurve.cpp:247
virtual bool isClosed2D() const
Returns true if the curve is closed.
Definition qgscurve.cpp:42
virtual QPolygonF asQPolygonF() const
Returns a QPolygonF representing the points.
Definition qgscurve.cpp:271
virtual void addToPainterPath(QPainterPath &path) const =0
Adds a curve to a painter path.
virtual int indexOf(const QgsPoint &point) const =0
Returns the index of the first vertex matching the given point, or -1 if a matching vertex is not fou...
QgsCurve * toCurveType() const override
Returns the geometry converted to the more generic curve type.
Definition qgscurve.cpp:206
virtual void sumUpArea(double &sum) const =0
Sums up the area of the curve by iterating over the vertices (shoelace formula).
QString asKml(int precision=17) const override
Returns a KML representation of the geometry.
Definition qgscurve.cpp:164
virtual QgsPoint * interpolatePoint(double distance) const =0
Returns an interpolated point on the curve at the specified distance.
QgsCurve * clone() const override=0
Clones the geometry by performing a deep copy.
virtual double distanceBetweenVertices(QgsVertexId fromVertex, QgsVertexId toVertex) const =0
Returns the distance along the curve between two vertices.
virtual std::tuple< std::unique_ptr< QgsCurve >, std::unique_ptr< QgsCurve > > splitCurveAtVertex(int index) const =0
Splits the curve at the specified vertex index, returning two curves which represent the portion of t...
virtual void drawAsPolygon(QPainter &p) const =0
Draws the curve as a polygon on the specified QPainter.
virtual QgsLineString * curveToLine(double tolerance=M_PI_2/90, SegmentationToleranceType toleranceType=MaximumAngle) const =0
Returns a new line string geometry corresponding to a segmentized approximation of the curve.
virtual void sumUpArea3D(double &sum) const =0
Sums up the 3d area of the curve by iterating over the vertices (shoelace formula).
Represents a single 2D line segment, consisting of a 2D start and end vertex only.
Line string geometry type, with support for z-dimension and m-values.
static std::unique_ptr< QgsLineString > fromBezierCurve(const QgsPoint &start, const QgsPoint &controlPoint1, const QgsPoint &controlPoint2, const QgsPoint &end, int segments=30)
Returns a new linestring created by segmentizing the bezier curve between start and end,...
QVector< QgsLineString * > splitToDisjointXYParts() const
Divides the linestring into parts that don't share any points or lines.
double length3D() const
Returns the length in 3D world of the line string.
static std::unique_ptr< QgsLineString > fromQPolygonF(const QPolygonF &polygon)
Returns a new linestring from a QPolygonF polygon input.
void extend(double startDistance, double endDistance, double startDeflection=0, double endDeflection=0)
Extends the line geometry by extrapolating out the start or end of the line by a specified distance.
QgsLineString()
Constructor for an empty linestring geometry.
static const QgsLineString * cast(const QgsAbstractGeometry *geom)
Cast the geom to a QgsLineString.
friend class TestQgsGeometry
friend class QgsPolygon
void close()
Closes the line string by appending the first point to the end of the line, if it is not already clos...
static QgsLineString * cast(QgsAbstractGeometry *geom)
Cast the geom to a QgsLineString.
QVector< QgsVertexId > collectDuplicateNodes(double epsilon=4 *std::numeric_limits< double >::epsilon(), bool useZValues=false) const
Returns a list of any duplicate nodes contained in the geometry, within the specified tolerance.
void addVertex(const QgsPoint &pt)
Adds a new vertex to the end of the line string.
friend class QgsTriangle
Represents a 2D point.
Definition qgspointxy.h:62
double y
Definition qgspointxy.h:66
double x
Definition qgspointxy.h:65
Point geometry type, with support for z-dimension and m-values.
Definition qgspoint.h:53
double z
Definition qgspoint.h:58
double x
Definition qgspoint.h:56
double m
Definition qgspoint.h:59
double y
Definition qgspoint.h:57
A rectangle specified with double values.
QgsSimpleCurve()=default
void points(QgsPointSequence &pts) const override
Returns a list of points within the curve.
void clear() override
Clears the geometry, ie reset it to a null geometry.
void setPoints(const QgsPointSequence &points)
Resets the simple curve to match the specified list of points.
void importVerticesFromWkb(const QgsConstWkbPtr &wkb)
Imports vertices from wkb geometry representation.
QgsSimpleCurve * reversed() const override
Returns a reversed copy of the curve, where the direction of the curve has been flipped.
static Qgis::WkbType flatType(Qgis::WkbType type)
Returns the flat type for a WKB type.
#define SIP_TYPEHINT(type)
Definition qgis_sip.h:237
#define SIP_DEPRECATED
Definition qgis_sip.h:113
#define SIP_SKIP
Definition qgis_sip.h:133
#define SIP_OUT
Definition qgis_sip.h:57
#define SIP_HOLDGIL
Definition qgis_sip.h:178
#define SIP_FACTORY
Definition qgis_sip.h:83
void visitPointsByRegularDistance(const QgsLineString *line, const QgsLineString *linePainterUnits, bool emitFirstPoint, const double distance, const double averageAngleLengthPainterUnits, const VisitPointFunction &visitPoint)
QLineF segment(int index, QRectF rect, double radius)
Utility class for identifying a unique vertex within a geometry.
Definition qgsvertexid.h:35