[QGIS-trac] [Quantum GIS] #2567: Reprojection on the fly doesn't work if layers have different projections

Quantum GIS qgis at qgis.org
Sat Mar 20 09:27:58 EDT 2010


#2567: Reprojection on  the fly doesn't work if layers have different projections
--------------------------------------------------+-------------------------
   Reporter:  sowelu                              |              Owner:  nobody       
       Type:  bug                                 |             Status:  new          
   Priority:  major: does not work as expected    |          Milestone:  Version 1.5.0
  Component:  MapCanvas                           |            Version:  HEAD         
   Keywords:  reprojection, coordinate transform  |   Platform_version:  Kubuntu 9.10 
   Platform:  Linux                               |           Must_fix:  No           
Status_info:  0                                   |  
--------------------------------------------------+-------------------------
 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

-- 
Ticket URL: <https://trac.osgeo.org/qgis/ticket/2567>
Quantum GIS <http://qgis.org>
Quantum GIS is an Open Source GIS viewer/editor supporting OGR, PostGIS, and GRASS formats


More information about the QGIS-trac mailing list