Skip to content

Commit bef4059

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 37171dc commit bef4059

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

src/gui/qgsmapcanvas.cpp

+11
Original file line numberDiff line numberDiff line change
@@ -418,6 +418,7 @@ void QgsMapCanvas::setLayerSet( QList<QgsMapCanvasLayer> &layers )
418418
if ( !currentLayer )
419419
continue;
420420
disconnect( currentLayer, SIGNAL( repaintRequested() ), this, SLOT( refresh() ) );
421+
disconnect( currentLayer, SIGNAL( layerCrsChanged() ), this, SLOT( layerCrsChange() ) );
421422
QgsVectorLayer *isVectLyr = qobject_cast<QgsVectorLayer *>( currentLayer );
422423
if ( isVectLyr )
423424
{
@@ -433,6 +434,7 @@ void QgsMapCanvas::setLayerSet( QList<QgsMapCanvasLayer> &layers )
433434
// Ticket #811 - racicot
434435
QgsMapLayer *currentLayer = layer( i );
435436
connect( currentLayer, SIGNAL( repaintRequested() ), this, SLOT( refresh() ) );
437+
connect( currentLayer, SIGNAL( layerCrsChanged() ), this, SLOT( layerCrsChange() ) );
436438
QgsVectorLayer *isVectLyr = qobject_cast<QgsVectorLayer *>( currentLayer );
437439
if ( isVectLyr )
438440
{
@@ -1579,6 +1581,15 @@ void QgsMapCanvas::layerStateChange()
15791581

15801582
} // layerStateChange
15811583

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

15831594

15841595
void QgsMapCanvas::freeze( bool frz )

src/gui/qgsmapcanvas.h

+3
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)