Bug report #14392

QGIS 2.14 has a wrong projection with rasters which are not in 4326

Added by Etienne Trimaille about 4 years ago. Updated about 4 years ago.

Status:Closed
Priority:Severe/Regression
Assignee:-
Category:Projection Support
Affected QGIS version:2.14.0 Regression?:No
Operating System: Easy fix?:No
Pull Request or Patch supplied:No Resolution:
Crashes QGIS or corrupts data:No Copied to github as #:22373

Description

With 2.14, if I try to open a raster which is not in EPSG:4326 (the raster in 3857 enclosed for instance), the EPSG displayed in QGIS is wrong.
It displays EPSG:4326, with OTF off.

I put a screenshot with 2.14 and 2.8 :
2.14 : https://files.gitter.im/qgis/QGIS/mfWy/Selection_004.png
2.8 : https://files.gitter.im/qgis/QGIS/BOiU/Selection_005.png

We can see the map canvas is in 4326, but my coordinates are not in 4326 (both in GUI and console).
With QGIS 2.8, everything works fine.

raster-3857.tif (247 KB) Etienne Trimaille, 2016-02-29 11:57 PM

Sélection_048.png (162 KB) Etienne Trimaille, 2016-02-29 11:57 PM

issue-14392.zip - QGIS Project (20.5 KB) Etienne Trimaille, 2016-03-02 12:24 AM

wrong_coordinates.png - QGIS Gui (141 KB) Etienne Trimaille, 2016-03-02 12:24 AM

Associated revisions

Revision 15d2be26
Added by Nyall Dawson about 4 years ago

Fix incorrect projection if raster or plugin layer is first layer
loaded into an empty project (fix #14392)

Revision 8ca6cc79
Added by Nyall Dawson about 4 years ago

Fix incorrect projection if raster or plugin layer is first layer
loaded into an empty project (fix #14392)

(cherry-picked from 15d2be26f1235d9ec18b48f09376390c3a6e2d00)

History

#1 Updated by Nyall Dawson about 4 years ago

  • Status changed from Open to Feedback

I can't reproduce. Can you attach a self contained project which demonstrates this issue?

#2 Updated by Etienne Trimaille about 4 years ago

I've added a zip. For me, I just have to open the raster provided in an empty project to reproduce the bug.
Tim and Nathan could replicate the issue too.

#3 Updated by Nyall Dawson about 4 years ago

So it seems like to me that it's just the initial state of the EPSG display in the status bar which is wrong. It's showing 4326, but the project is actually in 3857. You can confirm this by opening project properties and checking the CRS - the status bar should switch back to correctly show 3857.

Can you confirm?

#4 Updated by Etienne Trimaille about 4 years ago

You can confirm this by opening project properties and checking the CRS - the status bar should switch back to correctly show 3857.

The status bar doesn't update to 3857 here when I'm checking in the project properties.
What do you do to update the status bar ?

#5 Updated by Nyall Dawson about 4 years ago

Just open project properties and flip to the projection tab

#6 Updated by Etienne Trimaille about 4 years ago

Ah yes, it updates the status bar and in pyqgis too.
Will you fix the initial EPSG state ?

#7 Updated by Nyall Dawson about 4 years ago

It's not on my personal list of stuff to fix. Maybe someone else will volunteer to look at this one.

#8 Updated by Maximilian Krambach about 4 years ago

I'm fairly new to bughunting, so excuse me if it is a red herring and/or wrong code.
https://github.com/qgis/QGIS/blob/master/src/gui/layertree/qgslayertreemapcanvasbridge.cpp#L146

it checks, at loading of first layers, if the layer's crs has changed. It just checks for it is vector data and if those are valid.
Including something like (see below) may resolve the issue.

        QgsRasterLayer *rl = qobject_cast<QgsRasterLayer *>( layerNode->layer()

        if ( rl ) 
        { 
          mCanvas->setDestinationCrs( rl->crs() );
          mCanvas->setMapUnits( rl->crs().mapUnits() );
          break;  
        }

#9 Updated by Nyall Dawson about 4 years ago

  • Status changed from Feedback to In Progress

Maximilian -- good catch, I can see where the regression occurred now. Fix in progress.

#10 Updated by Nyall Dawson about 4 years ago

  • Status changed from In Progress to Closed

Also available in: Atom PDF