@@ -81,17 +81,52 @@ Construct a linestring from a single 2d line segment.
81
81
virtual bool equals( const QgsCurve &other ) const;
82
82
83
83
84
- QgsPoint pointN( int i ) const;
84
+ SIP_PYOBJECT pointN( int i ) const;
85
85
%Docstring
86
86
Returns the specified point from inside the line string.
87
87
88
88
:param i: index of point, starting at 0 for the first point
89
+ %End
90
+ %MethodCode
91
+ if ( a0 < 0 || a0 >= sipCpp->numPoints() )
92
+ {
93
+ PyErr_SetString( PyExc_IndexError, QByteArray::number( a0 ) );
94
+ sipIsErr = 1;
95
+ }
96
+ else
97
+ {
98
+ std::unique_ptr< QgsPoint > p = qgis::make_unique< QgsPoint >( sipCpp->pointN( a0 ) );
99
+ sipRes = sipConvertFromType( p.release(), sipType_QgsPoint, Py_None );
100
+ }
89
101
%End
90
102
91
103
virtual double xAt( int index ) const;
92
104
105
+ %MethodCode
106
+ if ( a0 < 0 || a0 >= sipCpp->numPoints() )
107
+ {
108
+ PyErr_SetString( PyExc_IndexError, QByteArray::number( a0 ) );
109
+ sipIsErr = 1;
110
+ }
111
+ else
112
+ {
113
+ return PyFloat_FromDouble( sipCpp->xAt( a0 ) );
114
+ }
115
+ %End
116
+
93
117
virtual double yAt( int index ) const;
94
118
119
+ %MethodCode
120
+ if ( a0 < 0 || a0 >= sipCpp->numPoints() )
121
+ {
122
+ PyErr_SetString( PyExc_IndexError, QByteArray::number( a0 ) );
123
+ sipIsErr = 1;
124
+ }
125
+ else
126
+ {
127
+ return PyFloat_FromDouble( sipCpp->yAt( a0 ) );
128
+ }
129
+ %End
95
130
96
131
97
132
@@ -107,6 +142,17 @@ Returns the z-coordinate of the specified node in the line string.
107
142
does not have a z dimension
108
143
109
144
.. seealso:: :py:func:`setZAt`
145
+ %End
146
+ %MethodCode
147
+ if ( a0 < 0 || a0 >= sipCpp->numPoints() )
148
+ {
149
+ PyErr_SetString( PyExc_IndexError, QByteArray::number( a0 ) );
150
+ sipIsErr = 1;
151
+ }
152
+ else
153
+ {
154
+ return PyFloat_FromDouble( sipCpp->zAt( a0 ) );
155
+ }
110
156
%End
111
157
112
158
double mAt( int index ) const;
@@ -119,6 +165,17 @@ Returns the m value of the specified node in the line string.
119
165
does not have m values
120
166
121
167
.. seealso:: :py:func:`setMAt`
168
+ %End
169
+ %MethodCode
170
+ if ( a0 < 0 || a0 >= sipCpp->numPoints() )
171
+ {
172
+ PyErr_SetString( PyExc_IndexError, QByteArray::number( a0 ) );
173
+ sipIsErr = 1;
174
+ }
175
+ else
176
+ {
177
+ return PyFloat_FromDouble( sipCpp->mAt( a0 ) );
178
+ }
122
179
%End
123
180
124
181
void setXAt( int index, double x );
@@ -130,6 +187,17 @@ Sets the x-coordinate of the specified node in the line string.
130
187
:param x: x-coordinate of node
131
188
132
189
.. seealso:: :py:func:`xAt`
190
+ %End
191
+ %MethodCode
192
+ if ( a0 < 0 || a0 >= sipCpp->numPoints() )
193
+ {
194
+ PyErr_SetString( PyExc_IndexError, QByteArray::number( a0 ) );
195
+ sipIsErr = 1;
196
+ }
197
+ else
198
+ {
199
+ sipCpp->setXAt( a0, a1 );
200
+ }
133
201
%End
134
202
135
203
void setYAt( int index, double y );
@@ -141,6 +209,17 @@ Sets the y-coordinate of the specified node in the line string.
141
209
:param y: y-coordinate of node
142
210
143
211
.. seealso:: :py:func:`yAt`
212
+ %End
213
+ %MethodCode
214
+ if ( a0 < 0 || a0 >= sipCpp->numPoints() )
215
+ {
216
+ PyErr_SetString( PyExc_IndexError, QByteArray::number( a0 ) );
217
+ sipIsErr = 1;
218
+ }
219
+ else
220
+ {
221
+ sipCpp->setYAt( a0, a1 );
222
+ }
144
223
%End
145
224
146
225
void setZAt( int index, double z );
@@ -152,6 +231,17 @@ Sets the z-coordinate of the specified node in the line string.
152
231
:param z: z-coordinate of node
153
232
154
233
.. seealso:: :py:func:`zAt`
234
+ %End
235
+ %MethodCode
236
+ if ( a0 < 0 || a0 >= sipCpp->numPoints() )
237
+ {
238
+ PyErr_SetString( PyExc_IndexError, QByteArray::number( a0 ) );
239
+ sipIsErr = 1;
240
+ }
241
+ else
242
+ {
243
+ sipCpp->setZAt( a0, a1 );
244
+ }
155
245
%End
156
246
157
247
void setMAt( int index, double m );
@@ -163,6 +253,17 @@ Sets the m value of the specified node in the line string.
163
253
:param m: m value of node
164
254
165
255
.. seealso:: :py:func:`mAt`
256
+ %End
257
+ %MethodCode
258
+ if ( a0 < 0 || a0 >= sipCpp->numPoints() )
259
+ {
260
+ PyErr_SetString( PyExc_IndexError, QByteArray::number( a0 ) );
261
+ sipIsErr = 1;
262
+ }
263
+ else
264
+ {
265
+ sipCpp->setMAt( a0, a1 );
266
+ }
166
267
%End
167
268
168
269
void setPoints( const QgsPointSequence &points );
@@ -333,6 +434,65 @@ of the curve.
333
434
sipRes = PyUnicode_FromString( str.toUtf8().constData() );
334
435
%End
335
436
437
+ SIP_PYOBJECT __getitem__( int index );
438
+ %Docstring
439
+ Returns the point at the specified ``index``. An IndexError will be raised if no point with the specified ``index`` exists.
440
+
441
+ .. versionadded:: 3.6
442
+ %End
443
+ %MethodCode
444
+ if ( a0 < 0 || a0 >= sipCpp->numPoints() )
445
+ {
446
+ PyErr_SetString( PyExc_IndexError, QByteArray::number( a0 ) );
447
+ sipIsErr = 1;
448
+ }
449
+ else
450
+ {
451
+ std::unique_ptr< QgsPoint > p = qgis::make_unique< QgsPoint >( sipCpp->pointN( a0 ) );
452
+ sipRes = sipConvertFromType( p.release(), sipType_QgsPoint, Py_None );
453
+ }
454
+ %End
455
+
456
+ void __setitem__( int index, const QgsPoint &point );
457
+ %Docstring
458
+ Sets the point at the specified ``index``. A point at the ``index`` must already exist or an IndexError will be raised.
459
+
460
+ .. versionadded:: 3.6
461
+ %End
462
+ %MethodCode
463
+ if ( a0 < 0 || a0 >= sipCpp->numPoints() )
464
+ {
465
+ PyErr_SetString( PyExc_IndexError, QByteArray::number( a0 ) );
466
+ sipIsErr = 1;
467
+ }
468
+ else
469
+ {
470
+ sipCpp->setXAt( a0, a1->x() );
471
+ sipCpp->setYAt( a0, a1->y() );
472
+ if ( sipCpp->isMeasure() )
473
+ sipCpp->setMAt( a0, a1->m() );
474
+ if ( sipCpp->is3D() )
475
+ sipCpp->setZAt( a0, a1->z() );
476
+ }
477
+ %End
478
+
479
+ void __delitem__( int index );
480
+ %Docstring
481
+ Deletes the vertex at the specified ``index``. A point at the ``index`` must already exist or an IndexError will be raised.
482
+
483
+ .. versionadded:: 3.6
484
+ %End
485
+ %MethodCode
486
+ if ( a0 >= 0 && a0 < sipCpp->numPoints() )
487
+ sipCpp->deleteVertex( QgsVertexId( -1, -1, a0 ) );
488
+ else
489
+ {
490
+ PyErr_SetString( PyExc_IndexError, QByteArray::number( a0 ) );
491
+ sipIsErr = 1;
492
+ }
493
+ %End
494
+
495
+
336
496
protected:
337
497
338
498
virtual QgsRectangle calculateBoundingBox() const;
0 commit comments