Skip to content

Commit c3321e5

Browse files
committed
[BUGFIX] Update DatumTransformInfo on layerCrsChanged
The QgsMapCanvas datumTransformInfo is not updated after a layerCrsChanged. This causes a bug in QGIS-Server which does not use the right srcAuthId. To update QgsMapCanvas datumTransformInfo, the user had to change the map canvas CRS or to disable/enable transform. This patch add a SLOT to the QgsMapLayer layerCrs Changed SIGNAL to update QgsMapCanvas datumTransformInfo.
1 parent ba73048 commit c3321e5

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

src/gui/qgsmapcanvas.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -417,6 +417,7 @@ void QgsMapCanvas::setLayerSet( QList<QgsMapCanvasLayer> &layers )
417417
if ( !currentLayer )
418418
continue;
419419
disconnect( currentLayer, SIGNAL( repaintRequested() ), this, SLOT( refresh() ) );
420+
disconnect( currentLayer, SIGNAL( layerCrsChanged() ), this, SLOT( layerCrsChange() ) );
420421
QgsVectorLayer *isVectLyr = qobject_cast<QgsVectorLayer *>( currentLayer );
421422
if ( isVectLyr )
422423
{
@@ -432,6 +433,7 @@ void QgsMapCanvas::setLayerSet( QList<QgsMapCanvasLayer> &layers )
432433
// Ticket #811 - racicot
433434
QgsMapLayer *currentLayer = layer( i );
434435
connect( currentLayer, SIGNAL( repaintRequested() ), this, SLOT( refresh() ) );
436+
connect( currentLayer, SIGNAL( layerCrsChanged() ), this, SLOT( layerCrsChange() ) );
435437
QgsVectorLayer *isVectLyr = qobject_cast<QgsVectorLayer *>( currentLayer );
436438
if ( isVectLyr )
437439
{
@@ -1578,6 +1580,15 @@ void QgsMapCanvas::layerStateChange()
15781580

15791581
} // layerStateChange
15801582

1583+
void QgsMapCanvas::layerCrsChange()
1584+
{
1585+
// called when a layer's CRS has been changed
1586+
QObject *theSender = sender();
1587+
QgsMapLayer *layer = qobject_cast<QgsMapLayer *>( theSender );
1588+
QString destAuthId = mSettings.destinationCrs().authid();
1589+
getDatumTransformInfo( layer, layer->crs().authid(), destAuthId );
1590+
1591+
} // layerCrsChange
15811592

15821593

15831594
void QgsMapCanvas::freeze( bool frz )

src/gui/qgsmapcanvas.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -409,6 +409,9 @@ class GUI_EXPORT QgsMapCanvas : public QGraphicsView
409409

410410
//! This slot is connected to the visibility change of one or more layers
411411
void layerStateChange();
412+
413+
//! This slot is connected to the layer's CRS change
414+
void layerCrsChange();
412415

413416
//! Whether to suppress rendering or not
414417
void setRenderFlag( bool theFlag );

0 commit comments

Comments
 (0)