Skip to content

Commit 249c6fc

Browse files
committed
Densify canvas extent geometry before reprojecting for views
Makes displaying canvas extent in extra map views nice and smooth if canvas CRSes differ.
1 parent 5360b79 commit 249c6fc

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

src/app/qgsmapcanvasdockwidget.cpp

+13-8
Original file line numberDiff line numberDiff line change
@@ -428,15 +428,20 @@ void QgsMapCanvasDockWidget::updateExtentRect()
428428
// close polygon
429429
mainCanvasPoly << mainCanvasPoly.at( 0 );
430430
QgsGeometry g = QgsGeometry::fromQPolygonF( mainCanvasPoly );
431-
// reproject extent
432-
QgsCoordinateTransform ct( mMainCanvas->mapSettings().destinationCrs(),
433-
mMapCanvas->mapSettings().destinationCrs() );
434-
try
435-
{
436-
g.transform( ct );
437-
}
438-
catch ( QgsCsException & )
431+
if ( mMainCanvas->mapSettings().destinationCrs() !=
432+
mMapCanvas->mapSettings().destinationCrs() )
439433
{
434+
// reproject extent
435+
QgsCoordinateTransform ct( mMainCanvas->mapSettings().destinationCrs(),
436+
mMapCanvas->mapSettings().destinationCrs() );
437+
g = g.densifyByCount( 5 );
438+
try
439+
{
440+
g.transform( ct );
441+
}
442+
catch ( QgsCsException & )
443+
{
444+
}
440445
}
441446
mExtentRubberBand->setToGeometry( g, nullptr );
442447
}

0 commit comments

Comments
 (0)