Skip to content
Permalink
Browse files

Manually merge PR #1290 (fixes #9861)

  • Loading branch information
jef-n committed May 7, 2014
2 parents 0a82f37 + ddecf7e commit 0c6056be5b3102089aaaec517908947edab7af9d
@@ -275,7 +275,9 @@ void QgsSimpleLineSymbolLayerV2::renderPolyline( const QPolygonF& points, QgsSym
else
{
double scaledOffset = offset * QgsSymbolLayerV2Utils::lineWidthScaleFactor( context.renderContext(), mOffsetUnit, mOffsetMapUnitScale );
p->drawPolyline( ::offsetLine( points, scaledOffset ) );
QList<QPolygonF> mline = ::offsetLine( points, scaledOffset );
for ( int part = 0; part < mline.count(); ++part )
p->drawPolyline( mline[ part ] );
}
}

@@ -777,13 +779,19 @@ void QgsMarkerLineSymbolLayerV2::renderPolyline( const QPolygonF& points, QgsSym
}
else
{
QPolygonF points2 = ::offsetLine( points, offset * QgsSymbolLayerV2Utils::lineWidthScaleFactor( context.renderContext(), mOffsetUnit, mOffsetMapUnitScale ) );
if ( placement == Interval )
renderPolylineInterval( points2, context );
else if ( placement == CentralPoint )
renderPolylineCentral( points2, context );
else
renderPolylineVertex( points2, context, placement );
QList<QPolygonF> mline = ::offsetLine( points, offset * QgsSymbolLayerV2Utils::lineWidthScaleFactor( context.renderContext(), mOffsetUnit, mOffsetMapUnitScale ) );

for ( int part = 0; part < mline.count(); ++part )
{
const QPolygonF &points2 = mline[ part ];

if ( placement == Interval )
renderPolylineInterval( points2, context );
else if ( placement == CentralPoint )
renderPolylineCentral( points2, context );
else
renderPolylineVertex( points2, context, placement );
}
}
}

@@ -662,10 +662,15 @@ static QPointF linesIntersection( QPointF p1, double t1, QPointF p2, double t2 )
#endif


QPolygonF offsetLine( QPolygonF polyline, double dist )
QList<QPolygonF> offsetLine( QPolygonF polyline, double dist )
{
QList<QPolygonF> resultLine;

if ( polyline.count() < 2 )
return polyline;
{
resultLine.append( polyline );
return resultLine;
}

QPolygonF newLine;

@@ -688,22 +693,48 @@ QPolygonF offsetLine( QPolygonF polyline, double dist )
if ( offsetGeom )
{
tempGeometry->fromGeos( offsetGeom );
tempPolyline = tempGeometry->asPolyline();

pointCount = tempPolyline.count();
newLine.resize( pointCount );
if ( QGis::flatType( tempGeometry->wkbType() ) == QGis::WKBLineString )
{
tempPolyline = tempGeometry->asPolyline();

QgsPoint* tempPtr2 = tempPolyline.data();
for ( i = 0; i < pointCount; ++i, tempPtr2++ ) newLine[i] = QPointF( tempPtr2->x(), tempPtr2->y() );
pointCount = tempPolyline.count();
newLine.resize( pointCount );

delete tempGeometry;
return newLine;
QgsPoint* tempPtr2 = tempPolyline.data();
for ( i = 0; i < pointCount; ++i, tempPtr2++ ) newLine[i] = QPointF( tempPtr2->x(), tempPtr2->y() );
resultLine.append( newLine );

delete tempGeometry;
return resultLine;
}
else if ( QGis::flatType( tempGeometry->wkbType() ) == QGis::WKBMultiLineString )
{
QgsMultiPolyline tempMPolyline = tempGeometry->asMultiPolyline();

for ( int part = 0; part < tempMPolyline.count(); ++part )
{
tempPolyline = tempMPolyline[ part ];

pointCount = tempPolyline.count();
newLine.resize( pointCount );

QgsPoint* tempPtr2 = tempPolyline.data();
for ( i = 0; i < pointCount; ++i, tempPtr2++ ) newLine[i] = QPointF( tempPtr2->x(), tempPtr2->y() );
resultLine.append( newLine );

newLine = QPolygonF();
}
delete tempGeometry;
return resultLine;
}
}
delete tempGeometry;
}

// returns original polyline when 'GEOSOffsetCurve' fails!
return polyline;
resultLine.append( polyline );
return resultLine;

#else

@@ -741,7 +772,9 @@ QPolygonF offsetLine( QPolygonF polyline, double dist )
// last line segment:
pt_new = offsetPoint( p2, angle + M_PI / 2, dist );
newLine.append( pt_new );
return newLine;

resultLine.append( newLine );
return resultLine;

#endif
}
@@ -291,7 +291,7 @@ class CORE_EXPORT QgsSymbolLayerV2Utils
class QPolygonF;

//! calculate line shifted by a specified distance
QPolygonF offsetLine( QPolygonF polyline, double dist );
QList<QPolygonF> offsetLine( QPolygonF polyline, double dist );


#endif

0 comments on commit 0c6056b

Please sign in to comment.
You can’t perform that action at this time.