@@ -102,15 +102,21 @@ class CORE_EXPORT QgsLineString: public QgsCurve
102
102
* \see yData()
103
103
* \since QGIS 3.2
104
104
*/
105
- const double *xData () const SIP_SKIP;
105
+ const double *xData () const SIP_SKIP
106
+ {
107
+ return mX .constData ();
108
+ }
106
109
107
110
/* *
108
111
* Returns a const pointer to the y vertex data.
109
112
* \note Not available in Python bindings
110
113
* \see xData()
111
114
* \since QGIS 3.2
112
115
*/
113
- const double *yData () const SIP_SKIP;
116
+ const double *yData () const SIP_SKIP
117
+ {
118
+ return mY .constData ();
119
+ }
114
120
115
121
/* *
116
122
* Returns a const pointer to the z vertex data, or a nullptr if the linestring does
@@ -120,7 +126,13 @@ class CORE_EXPORT QgsLineString: public QgsCurve
120
126
* \see yData()
121
127
* \since QGIS 3.2
122
128
*/
123
- const double *zData () const SIP_SKIP;
129
+ const double *zData () const SIP_SKIP
130
+ {
131
+ if ( mZ .empty () )
132
+ return nullptr ;
133
+ else
134
+ return mZ .constData ();
135
+ }
124
136
125
137
/* *
126
138
* Returns a const pointer to the m vertex data, or a nullptr if the linestring does
@@ -130,7 +142,13 @@ class CORE_EXPORT QgsLineString: public QgsCurve
130
142
* \see yData()
131
143
* \since QGIS 3.2
132
144
*/
133
- const double *mData () const SIP_SKIP;
145
+ const double *mData () const SIP_SKIP
146
+ {
147
+ if ( mM .empty () )
148
+ return nullptr ;
149
+ else
150
+ return mM .constData ();
151
+ }
134
152
135
153
/* *
136
154
* Returns the z-coordinate of the specified node in the line string.
@@ -139,7 +157,13 @@ class CORE_EXPORT QgsLineString: public QgsCurve
139
157
* does not have a z dimension
140
158
* \see setZAt()
141
159
*/
142
- double zAt ( int index ) const ;
160
+ double zAt ( int index ) const
161
+ {
162
+ if ( index >= 0 && index < mZ .size () )
163
+ return mZ .at ( index );
164
+ else
165
+ return std::numeric_limits<double >::quiet_NaN ();
166
+ }
143
167
144
168
/* *
145
169
* Returns the m value of the specified node in the line string.
@@ -148,7 +172,13 @@ class CORE_EXPORT QgsLineString: public QgsCurve
148
172
* does not have m values
149
173
* \see setMAt()
150
174
*/
151
- double mAt ( int index ) const ;
175
+ double mAt ( int index ) const
176
+ {
177
+ if ( index >= 0 && index < mM .size () )
178
+ return mM .at ( index );
179
+ else
180
+ return std::numeric_limits<double >::quiet_NaN ();
181
+ }
152
182
153
183
/* *
154
184
* Sets the x-coordinate of the specified node in the line string.
@@ -175,7 +205,11 @@ class CORE_EXPORT QgsLineString: public QgsCurve
175
205
* \param z z-coordinate of node
176
206
* \see zAt()
177
207
*/
178
- void setZAt ( int index, double z );
208
+ void setZAt ( int index, double z )
209
+ {
210
+ if ( index >= 0 && index < mZ .size () )
211
+ mZ [ index ] = z;
212
+ }
179
213
180
214
/* *
181
215
* Sets the m value of the specified node in the line string.
@@ -184,7 +218,11 @@ class CORE_EXPORT QgsLineString: public QgsCurve
184
218
* \param m m value of node
185
219
* \see mAt()
186
220
*/
187
- void setMAt ( int index, double m );
221
+ void setMAt ( int index, double m )
222
+ {
223
+ if ( index >= 0 && index < mM .size () )
224
+ mM [ index ] = m;
225
+ }
188
226
189
227
/* *
190
228
* Resets the line string to match the specified list of points. The line string will
@@ -325,7 +363,11 @@ class CORE_EXPORT QgsLineString: public QgsCurve
325
363
* \param type WKB type
326
364
* \param wkb WKB representation of line geometry
327
365
*/
328
- void fromWkbPoints ( QgsWkbTypes::Type type, const QgsConstWkbPtr &wkb );
366
+ void fromWkbPoints ( QgsWkbTypes::Type type, const QgsConstWkbPtr &wkb )
367
+ {
368
+ mWkbType = type;
369
+ importVerticesFromWkb ( wkb );
370
+ }
329
371
330
372
friend class QgsPolygon ;
331
373
friend class QgsTriangle ;
0 commit comments