Reprojection on the fly doesn't work if layers have different projections #12627
Labels
Bug
Either a bug report, or a bug fix. Let's hope for the latter!
Map and Legend
Related to map or legend rendering
Milestone
Author Name: sowelu - (sowelu -)
Original Redmine Issue: 2567
Redmine category:map_canvas
Assignee: nobody -
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]].
It may be better to store the [[QgsCoordinateTransform]] in the layer, rather than the [[QgsRenderContext]].
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.
Regards,
Roland
The text was updated successfully, but these errors were encountered: