@@ -3338,8 +3338,7 @@ void QgsDxfExport::writePoint( const QgsPoint& pt, const QString& layer, QColor
3338
3338
}
3339
3339
}
3340
3340
3341
- void QgsDxfExport::writePolyline ( const QgsPolyline& line, const QString& layer, const QString& lineStyleName, QColor color,
3342
- double width, bool polygon )
3341
+ void QgsDxfExport::writePolyline ( const QgsPolyline& line, const QString& layer, const QString& lineStyleName, QColor color, double width )
3343
3342
{
3344
3343
writeGroup ( 0 , " LWPOLYLINE" );
3345
3344
writeHandle ();
@@ -3349,16 +3348,17 @@ void QgsDxfExport::writePolyline( const QgsPolyline& line, const QString& layer,
3349
3348
writeGroup ( 6 , lineStyleName );
3350
3349
writeGroup ( color );
3351
3350
3352
- writeGroup ( 90 , line.size () );
3351
+ bool polygon = line[0 ] == line[ line.size () - 1 ];
3352
+ int n = line.size ();
3353
+ if ( polygon )
3354
+ --n;
3353
3355
3356
+ writeGroup ( 90 , n );
3354
3357
writeGroup ( 70 , polygon ? 1 : 0 );
3355
3358
writeGroup ( 43 , width );
3356
3359
3357
- QgsPolyline::const_iterator lineIt = line.constBegin ();
3358
- for ( ; lineIt != line.constEnd (); ++lineIt )
3359
- {
3360
- writeGroup ( 0 , *lineIt );
3361
- }
3360
+ for ( int i = 0 ; i < n; i++ )
3361
+ writeGroup ( 0 , line[i] );
3362
3362
}
3363
3363
3364
3364
void QgsDxfExport::writePolygon ( const QgsPolygon& polygon, const QString& layer, const QString& hatchPattern, QColor color )
@@ -3405,7 +3405,7 @@ void QgsDxfExport::writeLine( const QgsPoint& pt1, const QgsPoint& pt2, const QS
3405
3405
QgsPolyline line ( 2 );
3406
3406
line[0 ] = pt1;
3407
3407
line[1 ] = pt2;
3408
- writePolyline ( line, layer, lineStyleName, color, width, false );
3408
+ writePolyline ( line, layer, lineStyleName, color, width );
3409
3409
}
3410
3410
3411
3411
void QgsDxfExport::writePoint ( const QString& layer, QColor color, const QgsPoint& pt )
@@ -3652,7 +3652,7 @@ void QgsDxfExport::addFeature( const QgsSymbolV2RenderContext& ctx, const QStrin
3652
3652
if ( !offsetLine )
3653
3653
offsetLine = nonConstGeom;
3654
3654
3655
- writePolyline ( offsetLine->asPolyline (), layer, lineStyleName, penColor, width, false );
3655
+ writePolyline ( offsetLine->asPolyline (), layer, lineStyleName, penColor, width );
3656
3656
3657
3657
if ( offsetLine != nonConstGeom )
3658
3658
delete offsetLine;
@@ -3671,7 +3671,7 @@ void QgsDxfExport::addFeature( const QgsSymbolV2RenderContext& ctx, const QStrin
3671
3671
QgsMultiPolyline::const_iterator lIt = multiLine.constBegin ();
3672
3672
for ( ; lIt != multiLine.constEnd (); ++lIt )
3673
3673
{
3674
- writePolyline ( *lIt, layer, lineStyleName, penColor, width, false );
3674
+ writePolyline ( *lIt, layer, lineStyleName, penColor, width );
3675
3675
}
3676
3676
3677
3677
if ( offsetLine != nonConstGeom )
@@ -3691,7 +3691,7 @@ void QgsDxfExport::addFeature( const QgsSymbolV2RenderContext& ctx, const QStrin
3691
3691
QgsPolygon::const_iterator polyIt = polygon.constBegin ();
3692
3692
for ( ; polyIt != polygon.constEnd (); ++polyIt ) // iterate over rings
3693
3693
{
3694
- writePolyline ( *polyIt, layer, lineStyleName, penColor, width, false );
3694
+ writePolyline ( *polyIt, layer, lineStyleName, penColor, width );
3695
3695
}
3696
3696
3697
3697
if ( offsetPolygon != nonConstGeom )
@@ -3714,7 +3714,7 @@ void QgsDxfExport::addFeature( const QgsSymbolV2RenderContext& ctx, const QStrin
3714
3714
QgsPolygon::const_iterator polyIt = mpIt->constBegin ();
3715
3715
for ( ; polyIt != mpIt->constEnd (); ++polyIt )
3716
3716
{
3717
- writePolyline ( *polyIt, layer, lineStyleName, penColor, width, true );
3717
+ writePolyline ( *polyIt, layer, lineStyleName, penColor, width );
3718
3718
}
3719
3719
}
3720
3720
0 commit comments