@@ -132,7 +132,7 @@ QDomElement QgsLineStringV2::asGML3( QDomDocument& doc, int precision, const QSt
132
132
133
133
QDomElement elemCurve = doc.createElementNS ( ns, " Curve" );
134
134
QDomElement elemSegments = doc.createElementNS ( ns, " segments" );
135
- QDomElement elemArcString = doc.createElementNS ( ns, " LineString " );
135
+ QDomElement elemArcString = doc.createElementNS ( ns, " LineStringSegment " );
136
136
elemArcString.appendChild ( QgsGeometryUtils::pointsToGML3 ( pts, doc, precision, ns, is3D () ) );
137
137
elemSegments.appendChild ( elemArcString );
138
138
elemCurve.appendChild ( elemSegments );
@@ -303,11 +303,7 @@ void QgsLineStringV2::setPoints( const QList<QgsPointV2>& points )
303
303
304
304
if ( points.isEmpty () )
305
305
{
306
- mWkbType = QgsWKBTypes::Unknown;
307
- mX .clear ();
308
- mY .clear ();
309
- mZ .clear ();
310
- mM .clear ();
306
+ clear ();
311
307
return ;
312
308
}
313
309
@@ -366,8 +362,26 @@ void QgsLineStringV2::append( const QgsLineStringV2* line )
366
362
367
363
mX += line->mX ;
368
364
mY += line->mY ;
369
- mZ += line->mZ ;
370
- mM += line->mM ;
365
+
366
+ if ( line->is3D () )
367
+ {
368
+ mZ += line->mZ ;
369
+ }
370
+ else
371
+ {
372
+ // if append line does not have z coordinates, fill with 0 to match number of points in final line
373
+ mZ .insert ( mZ .count (), mX .size () - mZ .size (), 0 );
374
+ }
375
+
376
+ if ( line->is3D () )
377
+ {
378
+ mM += line->mM ;
379
+ }
380
+ else
381
+ {
382
+ // if append line does not have m values, fill with 0 to match number of points in final line
383
+ mM .insert ( mM .count (), mX .size () - mM .size (), 0 );
384
+ }
371
385
372
386
mBoundingBox = QgsRectangle (); // set bounding box invalid
373
387
}
@@ -524,7 +538,7 @@ bool QgsLineStringV2::deleteVertex( const QgsVertexId& position )
524
538
525
539
void QgsLineStringV2::addVertex ( const QgsPointV2& pt )
526
540
{
527
- if ( mWkbType == QgsWKBTypes::Unknown )
541
+ if ( mWkbType == QgsWKBTypes::Unknown || mX . isEmpty () )
528
542
{
529
543
setZMTypeFromSubGeometry ( &pt, QgsWKBTypes::LineString );
530
544
}
0 commit comments