[QGIS-trac] Re: [Quantum GIS] #2123: wrong projection information when creating a new shapefile

Quantum GIS qgis at qgis.org
Fri Nov 20 14:51:16 EST 2009


#2123: wrong projection information when creating a new shapefile
-----------------------------------------------------+----------------------
        Reporter:  cmoe                              |         Owner:  nobody           
            Type:  bug                               |        Status:  new              
        Priority:  major: does not work as expected  |     Milestone:  Version 1.4.0    
       Component:  Data Provider                     |       Version:  HEAD             
      Resolution:                                    |      Keywords:  create shapefile;
Platform_version:                                    |      Platform:  RedHat           
        Must_fix:  Yes                               |   Status_info:  0                
-----------------------------------------------------+----------------------
Comment (by cmoe):

 I stripped the problem down to the call of OGR_DS_CreateLayer of the
 createEmptyDataSource method in qgsogrprovider.cpp (around linie 1525).

 The reference (OGRSpatialReferenceH) we are passing seems to be ok, but
 the returning layer (OGRLayerH) is missing the towgs84 part in his srs.
 This seems to be intentional of ogr because OGR_DS_CreateLayer calls
 morphToESRI() for the srs (line 568 in
 gdal/ogr/ogrsf_frmts/shape/ogrshapedatasource.cpp). morphToESRI() removes
 the towgs84 parameter.

 This does not happen, if I export a postgis layer as shapefile or an
 existing shapefile. But this is done in different way by the
 QgsVectorFileWriter::writeAsShapefile(). qgsvectorfilewriter.cpp says at
 line 397, that it doesn't strip the towgs84 parameter.

 Would it be possible, to use the QgsVectorFileWriter in the
 createEmptyDataSource method? According to comment qgsvectorfilewriter.cpp
 we are already broken with relying on ESRI style prj-files.

-- 
Ticket URL: <http://trac.osgeo.org/qgis/ticket/2123#comment:1>
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