File: qgslinestring.sip.in

package info (click to toggle)
qgis 3.40.11%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,183,800 kB
  • sloc: cpp: 1,595,841; python: 372,637; xml: 23,474; sh: 3,761; perl: 3,664; ansic: 2,257; sql: 2,137; yacc: 1,068; lex: 577; javascript: 540; lisp: 411; makefile: 154
file content (980 lines) | stat: -rw-r--r-- 29,366 bytes parent folder | download | duplicates (12)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
/************************************************************************
 * This file has been generated automatically from                      *
 *                                                                      *
 * src/core/geometry/qgslinestring.h                                    *
 *                                                                      *
 * Do not edit manually ! Edit header and run scripts/sipify.py again   *
 ************************************************************************/








class QgsLineString: QgsCurve
{
%Docstring(signature="appended")
Line string geometry type, with support for z-dimension and m-values.
%End

%TypeHeaderCode
#include "qgslinestring.h"
%End
  public:

    QgsLineString() /HoldGIL/;
%Docstring
Constructor for an empty linestring geometry.
%End

    QgsLineString( SIP_PYOBJECT points /TypeHint="Sequence[Union[QgsPoint, QgsPointXY, Sequence[float]]]"/ ) /HoldGIL/ [( const QVector<double> &x, const QVector<double> &y, const QVector<double> &z = QVector<double>(), const QVector<double> &m = QVector<double>(), bool is25DType = false )];
%Docstring
Construct a linestring from a sequence of points (:py:class:`QgsPoint`
objects, :py:class:`QgsPointXY` objects, or sequences of float values).

The linestring Z and M type will be set based on the type of the first
point in the sequence.

.. versionadded:: 3.20
%End
%MethodCode
    if ( !PySequence_Check( a0 ) )
    {
      PyErr_SetString( PyExc_TypeError, QStringLiteral( "A sequence of QgsPoint, QgsPointXY or array of floats is expected" ).toUtf8().constData() );
      sipIsErr = 1;
    }
    else
    {
      int state;
      const int size = PySequence_Size( a0 );
      QVector< double > xl;
      QVector< double > yl;
      bool hasZ = false;
      QVector< double > zl;
      bool hasM = false;
      QVector< double > ml;
      xl.reserve( size );
      yl.reserve( size );

      bool is25D = false;

      sipIsErr = 0;
      for ( int i = 0; i < size; ++i )
      {
        PyObject *value = PySequence_GetItem( a0, i );
        if ( !value )
        {
          PyErr_SetString( PyExc_TypeError, QStringLiteral( "Invalid type at index %1." ).arg( i ) .toUtf8().constData() );
          sipIsErr = 1;
          break;
        }

        if ( PySequence_Check( value ) )
        {
          const int elementSize = PySequence_Size( value );
          if ( elementSize < 2 || elementSize > 4 )
          {
            sipIsErr = 1;
            PyErr_SetString( PyExc_TypeError, QStringLiteral( "Invalid sequence size at index %1. Expected an array of 2-4 float values, got %2." ).arg( i ).arg( elementSize ).toUtf8().constData() );
            Py_DECREF( value );
            break;
          }
          else
          {
            sipIsErr = 0;
            for ( int j = 0; j < elementSize; ++j )
            {
              PyObject *element = PySequence_GetItem( value, j );
              if ( !element )
              {
                PyErr_SetString( PyExc_TypeError, QStringLiteral( "Invalid type at index %1." ).arg( i ) .toUtf8().constData() );
                sipIsErr = 1;
                break;
              }

              PyErr_Clear();
              double d = PyFloat_AsDouble( element );
              if ( PyErr_Occurred() )
              {
                Py_DECREF( value );
                sipIsErr = 1;
                break;
              }
              if ( j == 0 )
                xl.append( d );
              else if ( j == 1 )
                yl.append( d );

              if ( i == 0 && j == 2 )
              {
                hasZ = true;
                zl.reserve( size );
                zl.append( d );
              }
              else if ( i > 0 && j == 2 && hasZ )
              {
                zl.append( d );
              }

              if ( i == 0 && j == 3 )
              {
                hasM = true;
                ml.reserve( size );
                ml.append( d );
              }
              else if ( i > 0 && j == 3 && hasM )
              {
                ml.append( d );
              }

              Py_DECREF( element );
            }

            if ( hasZ && elementSize < 3 )
              zl.append( std::numeric_limits< double >::quiet_NaN() );
            if ( hasM && elementSize < 4 )
              ml.append( std::numeric_limits< double >::quiet_NaN() );

            Py_DECREF( value );
            if ( sipIsErr )
            {
              break;
            }
          }
        }
        else
        {
          if ( sipCanConvertToType( value, sipType_QgsPointXY, SIP_NOT_NONE ) )
          {
            sipIsErr = 0;
            QgsPointXY *p = reinterpret_cast<QgsPointXY *>( sipConvertToType( value, sipType_QgsPointXY, 0, SIP_NOT_NONE, &state, &sipIsErr ) );
            if ( !sipIsErr )
            {
              xl.append( p->x() );
              yl.append( p->y() );
            }
            sipReleaseType( p, sipType_QgsPointXY, state );
          }
          else if ( sipCanConvertToType( value, sipType_QgsPoint, SIP_NOT_NONE ) )
          {
            sipIsErr = 0;
            QgsPoint *p = reinterpret_cast<QgsPoint *>( sipConvertToType( value, sipType_QgsPoint, 0, SIP_NOT_NONE, &state, &sipIsErr ) );
            if ( !sipIsErr )
            {
              xl.append( p->x() );
              yl.append( p->y() );

              if ( i == 0 && p->is3D() )
              {
                hasZ = true;
                zl.reserve( size );
                zl.append( p->z() );
              }
              else if ( i > 0 && hasZ )
              {
                zl.append( p->z() );
              }

              if ( i == 0 && p->isMeasure() )
              {
                hasM = true;
                ml.reserve( size );
                ml.append( p->m() );
              }
              else if ( i > 0 && hasM )
              {
                ml.append( p->m() );
              }

              if ( i == 0 && p->wkbType() == Qgis::WkbType::Point25D )
                is25D = true;
            }
            sipReleaseType( p, sipType_QgsPoint, state );
          }
          else
          {
            sipIsErr = 1;
          }

          Py_DECREF( value );

          if ( sipIsErr )
          {
            // couldn't convert the sequence value to a QgsPoint or QgsPointXY
            PyErr_SetString( PyExc_TypeError, QStringLiteral( "Invalid type at index %1. Expected QgsPoint, QgsPointXY or array of floats." ).arg( i ) .toUtf8().constData() );
            break;
          }
        }
      }
      if ( sipIsErr == 0 )
        sipCpp = new sipQgsLineString( QgsLineString( xl, yl, zl, ml, is25D ) );
    }
%End

    explicit QgsLineString( const QgsLineSegment2D &segment ) /HoldGIL/;
%Docstring
Construct a linestring from a single 2d line segment.

.. versionadded:: 3.2
%End

    QgsLineString( const QVector<double> &x, const QVector<double> &y,
                   const QVector<double> &z = QVector<double>(),
                   const QVector<double> &m = QVector<double>(), bool is25DType = false ) /HoldGIL/;
%Docstring
Construct a linestring from arrays of coordinates. If the z or m arrays
are non-empty then the resultant linestring will have z and m types
accordingly. This constructor is more efficient then calling
:py:func:`~QgsLineString.setPoints` or repeatedly calling
:py:func:`~QgsLineString.addVertex`

If the ``z`` vector is filled, then the geometry type will either be a
LineStringZ(M) or LineString25D depending on the ``is25DType`` argument.
If ``is25DType`` is ``True`` (and the ``m`` vector is unfilled) then the
created Linestring will be a LineString25D type. Otherwise, the
LineString will be LineStringZ (or LineStringZM) type.

If the sizes of ``x`` and ``y`` are non-equal then the resultant
linestring will be created using the minimum size of these arrays.
%End

    QgsLineString( const QgsPoint &p1, const QgsPoint &p2 ) /HoldGIL/;
%Docstring
Constructs a linestring with a single segment from ``p1`` to ``p2``.

.. versionadded:: 3.2
%End

    static QgsLineString *fromBezierCurve( const QgsPoint &start, const QgsPoint &controlPoint1, const QgsPoint &controlPoint2, const QgsPoint &end, int segments = 30 ) /Factory/;
%Docstring
Returns a new linestring created by segmentizing the bezier curve
between ``start`` and ``end``, with the specified control points.

The ``segments`` parameter controls how many line segments will be
present in the returned linestring.

Any z or m values present in the input coordinates will be interpolated
along with the x and y values.

.. versionadded:: 3.10
%End

    static QgsLineString *fromQPolygonF( const QPolygonF &polygon ) /Factory/;
%Docstring
Returns a new linestring from a QPolygonF ``polygon`` input.

.. versionadded:: 3.10
%End

  public:
    virtual bool fuzzyEqual( const QgsAbstractGeometry &other, double epsilon = 1e-8 ) const /HoldGIL/;

    virtual bool fuzzyDistanceEqual( const QgsAbstractGeometry &other, double epsilon = 1e-8 ) const /HoldGIL/;

    virtual bool equals( const QgsCurve &other ) const;



    SIP_PYOBJECT pointN( int i ) const /TypeHint="QgsPoint"/;
%Docstring
Returns the point at the specified index.

Indexes can be less than 0, in which case they correspond to positions
from the end of the line. E.g. an index of -1 corresponds to the last
point in the line.

:raises IndexError: if no point with the specified index exists.
%End
%MethodCode
    const int count = sipCpp->numPoints();
    if ( a0 < -count || a0 >= count )
    {
      PyErr_SetString( PyExc_IndexError, QByteArray::number( a0 ) );
      sipIsErr = 1;
    }
    else
    {
      std::unique_ptr< QgsPoint > p;
      if ( a0 >= 0 )
        p = std::make_unique< QgsPoint >( sipCpp->pointN( a0 ) );
      else // negative index, count backwards from end
        p = std::make_unique< QgsPoint >( sipCpp->pointN( count + a0 ) );
      sipRes = sipConvertFromType( p.release(), sipType_QgsPoint, Py_None );
    }
%End


    virtual double xAt( int index ) const;

%Docstring
Returns the x-coordinate of the specified node in the line string.

Indexes can be less than 0, in which case they correspond to positions
from the end of the line. E.g. an index of -1 corresponds to the last
point in the line.

:raises IndexError: if no point with the specified index exists.
%End
%MethodCode
    const int count = sipCpp->numPoints();
    if ( a0 < -count || a0 >= count )
    {
      PyErr_SetString( PyExc_IndexError, QByteArray::number( a0 ) );
      sipIsErr = 1;
    }
    else
    {
      if ( a0 >= 0 )
        return PyFloat_FromDouble( sipCpp->xAt( a0 ) );
      else
        return PyFloat_FromDouble( sipCpp->xAt( count + a0 ) );
    }
%End


    virtual double yAt( int index ) const;

%Docstring
Returns the y-coordinate of the specified node in the line string.

Indexes can be less than 0, in which case they correspond to positions
from the end of the line. E.g. an index of -1 corresponds to the last
point in the line.

:raises IndexError: if no point with the specified index exists.
%End
%MethodCode
    const int count = sipCpp->numPoints();
    if ( a0 < -count || a0 >= count )
    {
      PyErr_SetString( PyExc_IndexError, QByteArray::number( a0 ) );
      sipIsErr = 1;
    }
    else
    {
      if ( a0 >= 0 )
        return PyFloat_FromDouble( sipCpp->yAt( a0 ) );
      else
        return PyFloat_FromDouble( sipCpp->yAt( count + a0 ) );
    }
%End











    virtual double zAt( int index ) const;

%Docstring
Returns the z-coordinate of the specified node in the line string.

If the LineString does not have a z-dimension then ``NaN`` will be
returned.

Indexes can be less than 0, in which case they correspond to positions
from the end of the line. E.g. an index of -1 corresponds to the last
point in the line.

:raises IndexError: if no point with the specified index exists.
%End
%MethodCode
    const int count = sipCpp->numPoints();
    if ( a0 < -count || a0 >= count )
    {
      PyErr_SetString( PyExc_IndexError, QByteArray::number( a0 ) );
      sipIsErr = 1;
    }
    else
    {
      if ( a0 >= 0 )
        return PyFloat_FromDouble( sipCpp->zAt( a0 ) );
      else
        return PyFloat_FromDouble( sipCpp->zAt( count + a0 ) );
    }
%End


    virtual double mAt( int index ) const;

%Docstring
Returns the m-coordinate of the specified node in the line string.

If the LineString does not have a m-dimension then ``NaN`` will be
returned.

Indexes can be less than 0, in which case they correspond to positions
from the end of the line. E.g. an index of -1 corresponds to the last
point in the line.

:raises IndexError: if no point with the specified index exists.
%End
%MethodCode
    const int count = sipCpp->numPoints();
    if ( a0 < -count || a0 >= count )
    {
      PyErr_SetString( PyExc_IndexError, QByteArray::number( a0 ) );
      sipIsErr = 1;
    }
    else
    {
      if ( a0 >= 0 )
        return PyFloat_FromDouble( sipCpp->mAt( a0 ) );
      else
        return PyFloat_FromDouble( sipCpp->mAt( count + a0 ) );
    }
%End


    void setXAt( int index, double x );
%Docstring
Sets the x-coordinate of the specified node in the line string. The
corresponding node must already exist in line string.

Indexes can be less than 0, in which case they correspond to positions
from the end of the line. E.g. an index of -1 corresponds to the last
point in the line.

:raises IndexError: if no point with the specified index exists.

.. seealso:: :py:func:`xAt`
%End
%MethodCode
    const int count = sipCpp->numPoints();
    if ( a0 < -count || a0 >= count )
    {
      PyErr_SetString( PyExc_IndexError, QByteArray::number( a0 ) );
      sipIsErr = 1;
    }
    else
    {
      if ( a0 >= 0 )
        sipCpp->setXAt( a0, a1 );
      else
        sipCpp->setXAt( count + a0, a1 );
    }
%End


    void setYAt( int index, double y );
%Docstring
Sets the y-coordinate of the specified node in the line string. The
corresponding node must already exist in line string.

Indexes can be less than 0, in which case they correspond to positions
from the end of the line. E.g. an index of -1 corresponds to the last
point in the line.

:raises IndexError: if no point with the specified index exists.

.. seealso:: :py:func:`yAt`
%End
%MethodCode
    const int count = sipCpp->numPoints();
    if ( a0 < -count || a0 >= count )
    {
      PyErr_SetString( PyExc_IndexError, QByteArray::number( a0 ) );
      sipIsErr = 1;
    }
    else
    {
      if ( a0 >= 0 )
        sipCpp->setYAt( a0, a1 );
      else
        sipCpp->setYAt( count + a0, a1 );
    }
%End


    void setZAt( int index, double z );
%Docstring
Sets the z-coordinate of the specified node in the line string. The
corresponding node must already exist in line string and the line string
must have z-dimension.

Indexes can be less than 0, in which case they correspond to positions
from the end of the line. E.g. an index of -1 corresponds to the last
point in the line.

:raises IndexError: if no point with the specified index exists.

.. seealso:: :py:func:`zAt`
%End
%MethodCode
    const int count = sipCpp->numPoints();
    if ( a0 < -count || a0 >= count )
    {
      PyErr_SetString( PyExc_IndexError, QByteArray::number( a0 ) );
      sipIsErr = 1;
    }
    else
    {
      if ( a0 >= 0 )
        sipCpp->setZAt( a0, a1 );
      else
        sipCpp->setZAt( count + a0, a1 );
    }
%End


    void setMAt( int index, double m );
%Docstring
Sets the m-coordinate of the specified node in the line string. The
corresponding node must already exist in line string and the line string
must have m-dimension.

Indexes can be less than 0, in which case they correspond to positions
from the end of the line. E.g. an index of -1 corresponds to the last
point in the line.

:raises IndexError: if no point with the specified index exists.

.. seealso:: :py:func:`mAt`
%End
%MethodCode
    const int count = sipCpp->numPoints();
    if ( a0 < -count || a0 >= count )
    {
      PyErr_SetString( PyExc_IndexError, QByteArray::number( a0 ) );
      sipIsErr = 1;
    }
    else
    {
      if ( a0 >= 0 )
        sipCpp->setMAt( a0, a1 );
      else
        sipCpp->setMAt( count + a0, a1 );
    }
%End


    void setPoints( const QgsPointSequence &points );
%Docstring
Resets the line string to match the specified list of points. The line
string will inherit the dimensionality of the first point in the list.

:param points: new points for line string. If empty, line string will be
               cleared.
%End

    void append( const QgsLineString *line );
%Docstring
Appends the contents of another line string to the end of this line
string.

:param line: line to append. Ownership is not transferred.
%End

    void addVertex( const QgsPoint &pt );
%Docstring
Adds a new vertex to the end of the line string.

:param pt: vertex to add
%End

    void close();
%Docstring
Closes the line string by appending the first point to the end of the
line, if it is not already closed.
%End

    virtual QgsCompoundCurve *toCurveType() const /Factory/;

%Docstring
Returns the geometry converted to the more generic curve type
:py:class:`QgsCompoundCurve`

:return: the converted geometry. Caller takes ownership
%End

    void extend( double startDistance, double endDistance );
%Docstring
Extends the line geometry by extrapolating out the start or end of the
line by a specified distance. Lines are extended using the bearing of
the first or last segment in the line.
%End


    virtual QString geometryType() const /HoldGIL/;

    virtual int dimension() const /HoldGIL/;

    virtual QgsLineString *clone() const /Factory/;

    virtual void clear();

    virtual bool isEmpty() const /HoldGIL/;

    int indexOf( const QgsPoint &point ) const final;
    virtual bool isValid( QString &error /Out/, Qgis::GeometryValidityFlags flags = Qgis::GeometryValidityFlags() ) const;

    virtual QgsLineString *snappedToGrid( double hSpacing, double vSpacing, double dSpacing = 0, double mSpacing = 0, bool removeRedundantPoints = false ) const /Factory/;

    virtual bool removeDuplicateNodes( double epsilon = 4 * DBL_EPSILON, bool useZValues = false );

    virtual bool isClosed() const /HoldGIL/;

    virtual bool isClosed2D() const /HoldGIL/;

    virtual bool boundingBoxIntersects( const QgsRectangle &rectangle ) const /HoldGIL/;

    virtual bool boundingBoxIntersects( const QgsBox3D &box3d ) const /HoldGIL/;


    QVector< QgsVertexId > collectDuplicateNodes( double epsilon = 4 * DBL_EPSILON, bool useZValues = false ) const;
%Docstring
Returns a list of any duplicate nodes contained in the geometry, within
the specified tolerance.

If ``useZValues`` is ``True`` then z values will also be considered when
testing for duplicates.

.. versionadded:: 3.16
%End

    virtual QPolygonF asQPolygonF() const;


    virtual QgsLineString *simplifyByDistance( double tolerance ) const /Factory/;

    virtual bool fromWkb( QgsConstWkbPtr &wkb );

    virtual bool fromWkt( const QString &wkt );


    virtual int wkbSize( QgsAbstractGeometry::WkbFlags flags = QgsAbstractGeometry::WkbFlags() ) const;

    virtual QByteArray asWkb( QgsAbstractGeometry::WkbFlags flags = QgsAbstractGeometry::WkbFlags() ) const;

    virtual QString asWkt( int precision = 17 ) const;

    virtual QDomElement asGml2( QDomDocument &doc, int precision = 17, const QString &ns = "gml", QgsAbstractGeometry::AxisOrder axisOrder = QgsAbstractGeometry::AxisOrder::XY ) const;

    virtual QDomElement asGml3( QDomDocument &doc, int precision = 17, const QString &ns = "gml", QgsAbstractGeometry::AxisOrder axisOrder = QgsAbstractGeometry::AxisOrder::XY ) const;

    virtual QString asKml( int precision = 17 ) const;


    virtual double length() const /HoldGIL/;



    QVector<QgsLineString *> splitToDisjointXYParts() const /Factory/;
%Docstring
Divides the linestring into parts that don't share any points or lines.

This method throws away Z and M coordinates.

The ownership of returned pointers is transferred to the caller.

.. versionadded:: 3.40
%End

    double length3D() const /HoldGIL/;
%Docstring
Returns the length in 3D world of the line string. If it is not a 3D
line string, return its 2D length.

.. seealso:: :py:func:`length`

.. versionadded:: 3.10
%End
    virtual QgsPoint startPoint() const /HoldGIL/;

    virtual QgsPoint endPoint() const /HoldGIL/;


    virtual QgsLineString *curveToLine( double tolerance = M_PI_2 / 90, SegmentationToleranceType toleranceType = MaximumAngle ) const  /Factory/;

%Docstring
Returns a new line string geometry corresponding to a segmentized
approximation of the curve.

:param tolerance: segmentation tolerance
:param toleranceType: maximum segmentation angle or maximum difference
                      between approximation and curve
%End

    virtual int numPoints() const /HoldGIL/;

    virtual int nCoordinates() const /HoldGIL/;

    virtual void points( QgsPointSequence &pt /Out/ ) const;


    virtual void draw( QPainter &p ) const;


    virtual void transform( const QgsCoordinateTransform &ct, Qgis::TransformDirection d = Qgis::TransformDirection::Forward, bool transformZ = false )  throw( QgsCsException );

    virtual void transform( const QTransform &t, double zTranslate = 0.0, double zScale = 1.0, double mTranslate = 0.0, double mScale = 1.0 );


    virtual void addToPainterPath( QPainterPath &path ) const;

    virtual void drawAsPolygon( QPainter &p ) const;


    virtual bool insertVertex( QgsVertexId position, const QgsPoint &vertex );

    virtual bool moveVertex( QgsVertexId position, const QgsPoint &newPos );

    virtual bool deleteVertex( QgsVertexId position );


    virtual QgsLineString *reversed() const /Factory/;

    virtual QgsPoint *interpolatePoint( double distance ) const /Factory/;

    virtual QgsLineString *curveSubstring( double startDistance, double endDistance ) const /Factory/;


    virtual double closestSegment( const QgsPoint &pt, QgsPoint &segmentPt /Out/, QgsVertexId &vertexAfter /Out/, int *leftOf /Out/ = 0, double epsilon = 4 * DBL_EPSILON ) const;

    virtual bool pointAt( int node, QgsPoint &point, Qgis::VertexType &type ) const;


    virtual QgsPoint centroid() const;


    virtual void sumUpArea( double &sum /Out/ ) const;

%Docstring
Calculates the shoelace/triangle formula sum for the points in the
linestring. If the linestring is closed (i.e. a polygon) then the
polygon area is equal to the absolute value of the sum. Please note that
the sum will be negative if the points are defined in clockwise order.
Therefore, if you want to use the sum as an area (as the method name
indicates) then you probably should use the absolute value, since
otherwise a bug can be introduced (such as the bug fixed for github
issue 49578)

.. seealso:: https://en.wikipedia.org/wiki/Shoelace_formula#Triangle_formula
%End

    virtual double vertexAngle( QgsVertexId vertex ) const;

    virtual double segmentLength( QgsVertexId startVertex ) const;

    virtual bool addZValue( double zValue = 0 );

    virtual bool addMValue( double mValue = 0 );


    virtual bool dropZValue();

    virtual bool dropMValue();

    virtual void swapXy();


    virtual bool convertTo( Qgis::WkbType type );


    virtual bool transform( QgsAbstractGeometryTransformer *transformer, QgsFeedback *feedback = 0 );

    void scroll( int firstVertexIndex ) final;


    virtual QgsLineString *createEmptyWithSameType() const /Factory/;


    SIP_PYOBJECT __repr__();
%MethodCode
    QString wkt = sipCpp->asWkt();
    if ( wkt.length() > 1000 )
      wkt = wkt.left( 1000 ) + QStringLiteral( "..." );
    QString str = QStringLiteral( "<QgsLineString: %1>" ).arg( wkt );
    sipRes = PyUnicode_FromString( str.toUtf8().constData() );
%End

    SIP_PYOBJECT __getitem__( int index ) /TypeHint="QgsPoint"/;
%Docstring
Returns the point at the specified ``index``.

Indexes can be less than 0, in which case they correspond to positions
from the end of the line. E.g. an index of -1 corresponds to the last
point in the line.

:raises IndexError: if no point with the specified ``index`` exists.

.. versionadded:: 3.6
%End
%MethodCode
    const int count = sipCpp->numPoints();
    if ( a0 < -count || a0 >= count )
    {
      PyErr_SetString( PyExc_IndexError, QByteArray::number( a0 ) );
      sipIsErr = 1;
    }
    else
    {
      std::unique_ptr< QgsPoint > p;
      if ( a0 >= 0 )
        p = std::make_unique< QgsPoint >( sipCpp->pointN( a0 ) );
      else
        p = std::make_unique< QgsPoint >( sipCpp->pointN( count + a0 ) );
      sipRes = sipConvertFromType( p.release(), sipType_QgsPoint, Py_None );
    }
%End

    void __setitem__( int index, const QgsPoint &point );
%Docstring
Sets the point at the specified ``index``.

Indexes can be less than 0, in which case they correspond to positions
from the end of the line. E.g. an index of -1 corresponds to the last
point in the line.

:raises IndexError: if no point with the specified ``index`` exists.

.. versionadded:: 3.6
%End
%MethodCode
    const int count = sipCpp->numPoints();
    if ( a0 < -count || a0 >= count )
    {
      PyErr_SetString( PyExc_IndexError, QByteArray::number( a0 ) );
      sipIsErr = 1;
    }
    else
    {
      if ( a0 < 0 )
        a0 = count + a0;
      sipCpp->setXAt( a0, a1->x() );
      sipCpp->setYAt( a0, a1->y() );
      if ( sipCpp->isMeasure() )
        sipCpp->setMAt( a0, a1->m() );
      if ( sipCpp->is3D() )
        sipCpp->setZAt( a0, a1->z() );
    }
%End


    void __delitem__( int index );
%Docstring
Deletes the vertex at the specified ``index``.

Indexes can be less than 0, in which case they correspond to positions
from the end of the line. E.g. an index of -1 corresponds to the last
point in the line.

:raises IndexError: if no point with the specified ``index`` exists.

.. versionadded:: 3.6
%End
%MethodCode
    const int count = sipCpp->numPoints();
    if ( a0 >= 0 && a0 < count )
      sipCpp->deleteVertex( QgsVertexId( -1, -1, a0 ) );
    else if ( a0 < 0 && a0 >= -count )
      sipCpp->deleteVertex( QgsVertexId( -1, -1, count + a0 ) );
    else
    {
      PyErr_SetString( PyExc_IndexError, QByteArray::number( a0 ) );
      sipIsErr = 1;
    }
%End


 QgsBox3D calculateBoundingBox3d() const /Deprecated/;
%Docstring
Calculates the minimal 3D bounding box for the geometry. Deprecated: use
calculateBoundingBox3D instead

.. seealso:: :py:func:`calculateBoundingBox`

.. versionadded:: 3.26

.. deprecated:: 3.34
%End

    virtual QgsBox3D calculateBoundingBox3D() const;

%Docstring
Calculates the minimal 3D bounding box for the geometry.

.. seealso:: :py:func:`calculateBoundingBox`

.. versionadded:: 3.34
%End

    QgsLineString *measuredLine( double start, double end ) const /Factory/;
%Docstring
Re-write the measure ordinate (or add one, if it isn't already there)
interpolating the measure between the supplied ``start`` and ``end``
values.

.. versionadded:: 3.36
%End

    QgsLineString *interpolateM( bool use3DDistance = true ) const /Factory/;
%Docstring
Returns a copy of this line with all missing (NaN) m values interpolated
from m values of surrounding vertices.

If the line does not contain m values, ``None`` is returned.

The ``use3DDistance`` controls whether 2D or 3D distances between
vertices should be used during interpolation. This option is only
considered for lines with z values.

.. seealso:: :py:func:`lineLocatePointByM`

.. versionadded:: 3.38
%End

    bool lineLocatePointByM( double m, double &x /Out/, double &y /Out/, double &z /Out/, double &distanceFromStart /Out/, bool use3DDistance = true ) const;
%Docstring
Attempts to locate a point on the linestring by m value.

This method will linearly interpolate along line segments to find the
point which corresponds to the specified m value.

If the linestring contains sections with constant m values matching
``m``, then the interpolated point will be located at the center of
these sections.

Any missing (NaN) values in the linestring will be linearly interpolated
from the m values of surrounding vertices (see
:py:func:`~QgsLineString.interpolateM`).

:param m: target m value
:param use3DDistance: controls whether 2D or 3D distances between
                      vertices should be used during interpolation. This
                      option is only considered for lines with z values.

:return: - ``True`` if a matching point was found, or ``False`` if it
           could not be found
         - x: interpolated x coordinate
         - y: interpolated y coordinate
         - z: interpolated z coordinate (for 3D lines only)
         - distanceFromStart: calculated distance from the start of the
           linestring to the located point

.. seealso:: :py:func:`interpolateM`

.. versionadded:: 3.40
%End

  protected:

    int compareToSameClass( const QgsAbstractGeometry *other ) const final;

};


/************************************************************************
 * This file has been generated automatically from                      *
 *                                                                      *
 * src/core/geometry/qgslinestring.h                                    *
 *                                                                      *
 * Do not edit manually ! Edit header and run scripts/sipify.py again   *
 ************************************************************************/