18 #ifndef QGSLINESTRING_H
19 #define QGSLINESTRING_H
24 #include "qgis_core.h"
75 QgsLineString(
const QVector<double> &x,
const QVector<double> &y,
76 const QVector<double> &z = QVector<double>(),
77 const QVector<double> &m = QVector<double>(),
bool is25DType =
false )
SIP_HOLDGIL;
137 const int count = sipCpp->numPoints();
138 if ( a0 < -count || a0 >= count )
140 PyErr_SetString( PyExc_IndexError, QByteArray::number( a0 ) );
145 std::unique_ptr< QgsPoint > p;
147 p = qgis::make_unique< QgsPoint >( sipCpp->pointN( a0 ) );
149 p = qgis::make_unique< QgsPoint >( sipCpp->pointN( count + a0 ) );
150 sipRes = sipConvertFromType( p.release(), sipType_QgsPoint, Py_None );
156 double xAt(
int index )
const override;
167 double xAt(
int index )
const override;
169 const int count = sipCpp->numPoints();
170 if ( a0 < -count || a0 >= count )
172 PyErr_SetString( PyExc_IndexError, QByteArray::number( a0 ) );
178 return PyFloat_FromDouble( sipCpp->xAt( a0 ) );
180 return PyFloat_FromDouble( sipCpp->xAt( count + a0 ) );
186 double yAt(
int index )
const override;
197 double yAt(
int index )
const override;
199 const int count = sipCpp->numPoints();
200 if ( a0 < -count || a0 >= count )
202 PyErr_SetString( PyExc_IndexError, QByteArray::number( a0 ) );
208 return PyFloat_FromDouble( sipCpp->yAt( a0 ) );
210 return PyFloat_FromDouble( sipCpp->yAt( count + a0 ) );
223 return mX.constData();
234 return mY.constData();
250 return mZ.constData();
266 return mM.constData();
278 double zAt(
int index )
const
280 if ( index >= 0 && index < mZ.size() )
281 return mZ.at( index );
283 return std::numeric_limits<double>::quiet_NaN();
297 double zAt(
int index )
const;
299 const int count = sipCpp->numPoints();
300 if ( a0 < -count || a0 >= count )
302 PyErr_SetString( PyExc_IndexError, QByteArray::number( a0 ) );
308 return PyFloat_FromDouble( sipCpp->zAt( a0 ) );
310 return PyFloat_FromDouble( sipCpp->zAt( count + a0 ) );
324 double mAt(
int index )
const
326 if ( index >= 0 && index < mM.size() )
327 return mM.at( index );
329 return std::numeric_limits<double>::quiet_NaN();
343 double mAt(
int index )
const;
345 const int count = sipCpp->numPoints();
346 if ( a0 < -count || a0 >= count )
348 PyErr_SetString( PyExc_IndexError, QByteArray::number( a0 ) );
354 return PyFloat_FromDouble( sipCpp->mAt( a0 ) );
356 return PyFloat_FromDouble( sipCpp->mAt( count + a0 ) );
370 void setXAt(
int index,
double x );
384 void setXAt(
int index,
double x );
386 const int count = sipCpp->numPoints();
387 if ( a0 < -count || a0 >= count )
389 PyErr_SetString( PyExc_IndexError, QByteArray::number( a0 ) );
395 sipCpp->setXAt( a0, a1 );
397 sipCpp->setXAt( count + a0, a1 );
411 void setYAt(
int index,
double y );
425 void setYAt(
int index,
double y );
427 const int count = sipCpp->numPoints();
428 if ( a0 < -count || a0 >= count )
430 PyErr_SetString( PyExc_IndexError, QByteArray::number( a0 ) );
436 sipCpp->setYAt( a0, a1 );
438 sipCpp->setYAt( count + a0, a1 );
454 if ( index >= 0 && index < mZ.size() )
470 void setZAt(
int index,
double z );
472 const int count = sipCpp->numPoints();
473 if ( a0 < -count || a0 >= count )
475 PyErr_SetString( PyExc_IndexError, QByteArray::number( a0 ) );
481 sipCpp->setZAt( a0, a1 );
483 sipCpp->setZAt( count + a0, a1 );
499 if ( index >= 0 && index < mM.size() )
515 void setMAt(
int index,
double m );
517 const int count = sipCpp->numPoints();
518 if ( a0 < -count || a0 >= count )
520 PyErr_SetString( PyExc_IndexError, QByteArray::number( a0 ) );
526 sipCpp->setMAt( a0, a1 );
528 sipCpp->setMAt( count + a0, a1 );
550 void addVertex(
const QgsPoint &pt );
567 void extend(
double startDistance,
double endDistance );
576 void visitPointsByRegularDistance(
double distance,
const std::function<
bool(
double x,
double y,
double z,
double m,
577 double startSegmentX,
double startSegmentY,
double startSegmentZ,
double startSegmentM,
578 double endSegmentX,
double endSegmentY,
double endSegmentZ,
double endSegmentM
579 ) > &visitPoint )
const;
587 void clear() override;
589 QgsLineString *snappedToGrid(
double hSpacing,
double vSpacing,
double dSpacing = 0,
double mSpacing = 0 ) const override
SIP_FACTORY;
590 bool removeDuplicateNodes(
double epsilon = 4 * std::numeric_limits<
double>::epsilon(),
bool useZValues = false ) override;
599 QVector<
QgsVertexId > collectDuplicateNodes(
double epsilon = 4 * std::numeric_limits<
double>::epsilon(),
bool useZValues = false ) const;
601 QPolygonF asQPolygonF() const override;
604 bool fromWkt( const QString &wkt ) override;
608 QString asWkt(
int precision = 17 ) const override;
612 QString asKml(
int precision = 17 ) const override;
633 QgsLineString *curveToLine(
double tolerance = M_PI_2 / 90, SegmentationToleranceType toleranceType = MaximumAngle ) const override
SIP_FACTORY;
639 void draw( QPainter &p ) const override;
642 void transform( const QTransform &t,
double zTranslate = 0.0,
double zScale = 1.0,
double mTranslate = 0.0,
double mScale = 1.0 ) override;
644 void addToPainterPath( QPainterPath &path ) const override;
645 void drawAsPolygon( QPainter &p ) const override;
649 bool deleteVertex(
QgsVertexId position ) override;
660 void sumUpArea(
double &sum
SIP_OUT ) const override;
661 double vertexAngle(
QgsVertexId vertex ) const override;
662 double segmentLength(
QgsVertexId startVertex ) const override;
663 bool addZValue(
double zValue = 0 ) override;
664 bool addMValue(
double mValue = 0 ) override;
666 bool dropZValue() override;
667 bool dropMValue() override;
668 void swapXy() override;
694 SIP_PYOBJECT __repr__();
696 QString wkt = sipCpp->asWkt();
697 if ( wkt.length() > 1000 )
698 wkt = wkt.left( 1000 ) + QStringLiteral(
"..." );
699 QString str = QStringLiteral(
"<QgsLineString: %1>" ).arg( wkt );
700 sipRes = PyUnicode_FromString( str.toUtf8().constData() );
713 const int count = sipCpp->numPoints();
714 if ( a0 < -count || a0 >= count )
716 PyErr_SetString( PyExc_IndexError, QByteArray::number( a0 ) );
721 std::unique_ptr< QgsPoint > p;
723 p = qgis::make_unique< QgsPoint >( sipCpp->pointN( a0 ) );
725 p = qgis::make_unique< QgsPoint >( sipCpp->pointN( count + a0 ) );
726 sipRes = sipConvertFromType( p.release(), sipType_QgsPoint, Py_None );
738 void __setitem__(
int index,
const QgsPoint &point );
740 const int count = sipCpp->numPoints();
741 if ( a0 < -count || a0 >= count )
743 PyErr_SetString( PyExc_IndexError, QByteArray::number( a0 ) );
750 sipCpp->setXAt( a0, a1->x() );
751 sipCpp->setYAt( a0, a1->y() );
752 if ( sipCpp->isMeasure() )
753 sipCpp->setMAt( a0, a1->m() );
754 if ( sipCpp->is3D() )
755 sipCpp->setZAt( a0, a1->z() );
768 void __delitem__(
int index );
770 const int count = sipCpp->numPoints();
771 if ( a0 >= 0 && a0 < count )
773 else if ( a0 < 0 && a0 >= -count )
774 sipCpp->deleteVertex(
QgsVertexId( -1, -1, count + a0 ) );
777 PyErr_SetString( PyExc_IndexError, QByteArray::number( a0 ) );
804 importVerticesFromWkb( wkb );
814 #endif // QGSLINESTRING_H