Bug report #2567
Reprojection on the fly doesn't work if layers have different projections
|Affected QGIS version:||Regression?:||No|
|Operating System:||Linux||Easy fix?:||No|
|Pull Request or Patch supplied:||Resolution:||invalid|
|Crashes QGIS or corrupts data:||Copied to github as #:||12627|
I have found a problem with vectors being misplaced if there are multiple layers with different projections. I would expect that if you have On The Fly Reprojection set and a valid CRS for each layer, then they should each be reprojected correctly onto the map.
Looking through the code it appears that the problem is that all layers use the same QgsRenderContext as this is a member of QqsMapRenderer. The QgsMapRenderer loops through each layer calling its draw() function and passing the same QgsRenderContext to each layer. The QgsCoordinateTransform is a member of the QgsRenderContext and so doesn't change as the layer list is iterated. As this contains the data and functions to reproject points then the same transform gets applied to each layer (not sure how it is defined, maybe that of the first layer?), when in fact each layer may require different co-ordinate transforms as they may have different SourceCRS.
Attached are some files to illustrate. The RenderContextTest.qgs project will set the map to AGD84 Zone 55 and load two shapefiles. The shapefiles each contain the same line with the same co-ordinates (ie the easting and northing numbers are the same) but they are in different projections - AGD84 Zone 55 and GDA94 Zone 55. With On The Fly reprojection turned off they overlay each other. With it turned on they should be shifted by 200m in a NE-SW direction (tested with MapInfo) - instead they remain the same (well almost, there may also be a problem with confusing AGD84 and AGD66 indicated in the debug messages).
I have compiled trunk (13071M) with Debug on and there does not appear to be a problem with invalid CRS.
This is the most I have examined the QGIS code, so please correct me if I have misunderstood it. Even if I have misunderstood the problem of not reprojecting remains.
#1 Updated by sowelu - over 11 years ago
- Resolution set to invalid
- Status changed from Open to Closed