Skip to content

Commit 1f20630

Browse files
committedMay 1, 2014
Fix #9771 (fix rendering of layers with geographical CRS with OTF on)
1 parent 4f9c8c1 commit 1f20630

File tree

1 file changed

+10
-21
lines changed

1 file changed

+10
-21
lines changed
 

‎src/core/qgsmaprendererjob.cpp

Lines changed: 10 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -402,25 +402,19 @@ void QgsMapRendererJob::drawOldLabeling( const QgsMapSettings& settings, QgsRend
402402
if ( ml->hasScaleBasedVisibility() && ( settings.scale() < ml->minimumScale() || settings.scale() > ml->maximumScale() ) )
403403
continue;
404404

405-
bool split = false;
406405
const QgsCoordinateTransform* ct = 0;
407406
QgsRectangle r1 = settings.visibleExtent(), r2;
408407

409408
if ( settings.hasCrsTransformEnabled() )
410409
{
411410
ct = QgsCoordinateTransformCache::instance()->transform( ml->crs().authid(), settings.destinationCrs().authid() );
412-
split = reprojectToLayerExtent( ct, ml->crs().geographicFlag(), r1, r2 );
411+
reprojectToLayerExtent( ct, ml->crs().geographicFlag(), r1, r2 );
413412
}
414413

415414
renderContext.setCoordinateTransform( ct );
416415
renderContext.setExtent( r1 );
417416

418417
ml->drawLabels( renderContext );
419-
if ( split )
420-
{
421-
renderContext.setExtent( r2 );
422-
ml->drawLabels( renderContext );
423-
}
424418
}
425419
}
426420

@@ -498,10 +492,14 @@ bool QgsMapRendererJob::reprojectToLayerExtent( const QgsCoordinateTransform* ct
498492

499493
if ( ll.x() > ur.x() )
500494
{
501-
r2 = extent;
502-
extent.setXMinimum( splitCoord );
503-
r2.setXMaximum( splitCoord );
504-
split = true;
495+
// the coordinates projected in reverse order than what one would expect.
496+
// we are probably looking at an area that includes longitude of 180 degrees.
497+
// we need to take into account coordinates from two intervals: (-180,x1) and (x2,180)
498+
// so let's use (-180,180). This hopefully does not add too much overhead. It is
499+
// more straightforward than rendering with two separate extents and more consistent
500+
// for rendering, labeling and caching as everything is rendered just in one go
501+
extent.setXMinimum( -splitCoord );
502+
extent.setXMaximum( splitCoord );
505503
}
506504
}
507505
else // can't cross 180
@@ -574,8 +572,7 @@ LayerRenderJobs QgsMapRendererJob::prepareJobs( QPainter* painter, QgsPalLabelin
574572
{
575573
ct = QgsCoordinateTransformCache::instance()->transform( ml->crs().authid(), mSettings.destinationCrs().authid() );
576574
reprojectToLayerExtent( ct, ml->crs().geographicFlag(), r1, r2 );
577-
QgsDebugMsg( " extent 1: " + r1.toString() );
578-
QgsDebugMsg( " extent 2: " + r2.toString() );
575+
QgsDebugMsg( "extent: " + r1.toString() );
579576
if ( !r1.isFinite() || !r2.isFinite() )
580577
{
581578
mErrors.append( Error( layerId, "There was a problem transforming layer's' extent. Layer skipped." ) );
@@ -649,14 +646,6 @@ LayerRenderJobs QgsMapRendererJob::prepareJobs( QPainter* painter, QgsPalLabelin
649646
}
650647
}
651648

652-
#if 0
653-
// TODO: split extent
654-
if ( split )
655-
{
656-
mRenderContext.setExtent( r2 );
657-
ml->draw( mRenderContext );
658-
}
659-
#endif
660649
} // while (li.hasPrevious())
661650

662651
return layerJobs;

0 commit comments

Comments
 (0)
Please sign in to comment.