18 #ifndef QGSLINESTRING_H
19 #define QGSLINESTRING_H
24 #include "qgis_core.h"
71 QgsLineString(
const QVector<double> &x,
const QVector<double> &y,
72 const QVector<double> &z = QVector<double>(),
73 const QVector<double> &m = QVector<double>(),
bool is25DType =
false );
133 const int count = sipCpp->numPoints();
134 if ( a0 < -count || a0 >= count )
136 PyErr_SetString( PyExc_IndexError, QByteArray::number( a0 ) );
141 std::unique_ptr< QgsPoint > p;
143 p = qgis::make_unique< QgsPoint >( sipCpp->pointN( a0 ) );
145 p = qgis::make_unique< QgsPoint >( sipCpp->pointN( count + a0 ) );
146 sipRes = sipConvertFromType( p.release(), sipType_QgsPoint, Py_None );
152 double xAt(
int index )
const override;
163 double xAt(
int index )
const override;
165 const int count = sipCpp->numPoints();
166 if ( a0 < -count || a0 >= count )
168 PyErr_SetString( PyExc_IndexError, QByteArray::number( a0 ) );
174 return PyFloat_FromDouble( sipCpp->xAt( a0 ) );
176 return PyFloat_FromDouble( sipCpp->xAt( count + a0 ) );
182 double yAt(
int index )
const override;
193 double yAt(
int index )
const override;
195 const int count = sipCpp->numPoints();
196 if ( a0 < -count || a0 >= count )
198 PyErr_SetString( PyExc_IndexError, QByteArray::number( a0 ) );
204 return PyFloat_FromDouble( sipCpp->yAt( a0 ) );
206 return PyFloat_FromDouble( sipCpp->yAt( count + a0 ) );
219 return mX.constData();
230 return mY.constData();
246 return mZ.constData();
262 return mM.constData();
274 double zAt(
int index )
const
276 if ( index >= 0 && index < mZ.size() )
277 return mZ.at( index );
279 return std::numeric_limits<double>::quiet_NaN();
293 double zAt(
int index )
const;
295 const int count = sipCpp->numPoints();
296 if ( a0 < -count || a0 >= count )
298 PyErr_SetString( PyExc_IndexError, QByteArray::number( a0 ) );
304 return PyFloat_FromDouble( sipCpp->zAt( a0 ) );
306 return PyFloat_FromDouble( sipCpp->zAt( count + a0 ) );
320 double mAt(
int index )
const
322 if ( index >= 0 && index < mM.size() )
323 return mM.at( index );
325 return std::numeric_limits<double>::quiet_NaN();
339 double mAt(
int index )
const;
341 const int count = sipCpp->numPoints();
342 if ( a0 < -count || a0 >= count )
344 PyErr_SetString( PyExc_IndexError, QByteArray::number( a0 ) );
350 return PyFloat_FromDouble( sipCpp->mAt( a0 ) );
352 return PyFloat_FromDouble( sipCpp->mAt( count + a0 ) );
366 void setXAt(
int index,
double x );
380 void setXAt(
int index,
double x );
382 const int count = sipCpp->numPoints();
383 if ( a0 < -count || a0 >= count )
385 PyErr_SetString( PyExc_IndexError, QByteArray::number( a0 ) );
391 sipCpp->setXAt( a0, a1 );
393 sipCpp->setXAt( count + a0, a1 );
407 void setYAt(
int index,
double y );
421 void setYAt(
int index,
double y );
423 const int count = sipCpp->numPoints();
424 if ( a0 < -count || a0 >= count )
426 PyErr_SetString( PyExc_IndexError, QByteArray::number( a0 ) );
432 sipCpp->setYAt( a0, a1 );
434 sipCpp->setYAt( count + a0, a1 );
450 if ( index >= 0 && index < mZ.size() )
466 void setZAt(
int index,
double z );
468 const int count = sipCpp->numPoints();
469 if ( a0 < -count || a0 >= count )
471 PyErr_SetString( PyExc_IndexError, QByteArray::number( a0 ) );
477 sipCpp->setZAt( a0, a1 );
479 sipCpp->setZAt( count + a0, a1 );
495 if ( index >= 0 && index < mM.size() )
511 void setMAt(
int index,
double m );
513 const int count = sipCpp->numPoints();
514 if ( a0 < -count || a0 >= count )
516 PyErr_SetString( PyExc_IndexError, QByteArray::number( a0 ) );
522 sipCpp->setMAt( a0, a1 );
524 sipCpp->setMAt( count + a0, a1 );
546 void addVertex(
const QgsPoint &pt );
562 void extend(
double startDistance,
double endDistance );
571 void visitPointsByRegularDistance(
double distance,
const std::function<
bool(
double x,
double y,
double z,
double m,
572 double startSegmentX,
double startSegmentY,
double startSegmentZ,
double startSegmentM,
573 double endSegmentX,
double endSegmentY,
double endSegmentZ,
double endSegmentM
574 ) > &visitPoint )
const;
582 void clear() override;
583 bool isEmpty() const override;
584 QgsLineString *snappedToGrid(
double hSpacing,
double vSpacing,
double dSpacing = 0,
double mSpacing = 0 ) const override
SIP_FACTORY;
585 bool removeDuplicateNodes(
double epsilon = 4 * std::numeric_limits<
double>::epsilon(),
bool useZValues = false ) override;
586 QPolygonF asQPolygonF() const override;
589 bool fromWkt( const QString &wkt ) override;
592 QString asWkt(
int precision = 17 ) const override;
596 QString asKml(
int precision = 17 ) const override;
599 double length() const override;
607 double length3D() const;
608 QgsPoint startPoint() const override;
616 QgsLineString *curveToLine(
double tolerance = M_PI_2 / 90, SegmentationToleranceType toleranceType = MaximumAngle ) const override
SIP_FACTORY;
618 int numPoints() const override;
619 int nCoordinates() const override;
622 void draw( QPainter &p ) const override;
625 void transform( const QTransform &t,
double zTranslate = 0.0,
double zScale = 1.0,
double mTranslate = 0.0,
double mScale = 1.0 ) override;
627 void addToPainterPath( QPainterPath &path ) const override;
628 void drawAsPolygon( QPainter &p ) const override;
632 bool deleteVertex(
QgsVertexId position ) override;
643 void sumUpArea(
double &sum
SIP_OUT ) const override;
644 double vertexAngle(
QgsVertexId vertex ) const override;
645 double segmentLength(
QgsVertexId startVertex ) const override;
646 bool addZValue(
double zValue = 0 ) override;
647 bool addMValue(
double mValue = 0 ) override;
649 bool dropZValue() override;
650 bool dropMValue() override;
651 void swapXy() override;
677 SIP_PYOBJECT __repr__();
679 QString wkt = sipCpp->asWkt();
680 if ( wkt.length() > 1000 )
681 wkt = wkt.left( 1000 ) + QStringLiteral(
"..." );
682 QString str = QStringLiteral(
"<QgsLineString: %1>" ).arg( wkt );
683 sipRes = PyUnicode_FromString( str.toUtf8().constData() );
696 const int count = sipCpp->numPoints();
697 if ( a0 < -count || a0 >= count )
699 PyErr_SetString( PyExc_IndexError, QByteArray::number( a0 ) );
704 std::unique_ptr< QgsPoint > p;
706 p = qgis::make_unique< QgsPoint >( sipCpp->pointN( a0 ) );
708 p = qgis::make_unique< QgsPoint >( sipCpp->pointN( count + a0 ) );
709 sipRes = sipConvertFromType( p.release(), sipType_QgsPoint, Py_None );
721 void __setitem__(
int index,
const QgsPoint &point );
723 const int count = sipCpp->numPoints();
724 if ( a0 < -count || a0 >= count )
726 PyErr_SetString( PyExc_IndexError, QByteArray::number( a0 ) );
733 sipCpp->setXAt( a0, a1->x() );
734 sipCpp->setYAt( a0, a1->y() );
735 if ( sipCpp->isMeasure() )
736 sipCpp->setMAt( a0, a1->m() );
737 if ( sipCpp->is3D() )
738 sipCpp->setZAt( a0, a1->z() );
751 void __delitem__(
int index );
753 const int count = sipCpp->numPoints();
754 if ( a0 >= 0 && a0 < count )
756 else if ( a0 < 0 && a0 >= -count )
757 sipCpp->deleteVertex(
QgsVertexId( -1, -1, count + a0 ) );
760 PyErr_SetString( PyExc_IndexError, QByteArray::number( a0 ) );
787 importVerticesFromWkb( wkb );
797 #endif // QGSLINESTRING_H