fix_wrong_prj_files_qgsvecotrfilewriter.diff
src/core/qgsvectorfilewriter.cpp (Arbeitskopie) | ||
---|---|---|
98 | 98 |
QString layerName = shapefileName.left( shapefileName.indexOf( ".shp" ) ); |
99 | 99 |
OGRwkbGeometryType wkbType = static_cast<OGRwkbGeometryType>( geometryType ); |
100 | 100 |
mLayer = OGR_DS_CreateLayer( mDS, QFile::encodeName( layerName ).data(), ogrRef, wkbType, NULL ); |
101 |
|
|
102 |
|
|
103 |
//if it is a shapefile, ogr gives a wrong (esri style like) prj file back, which is missing the towgs84 parameter |
|
104 |
//so we just overwrite it with a correct one |
|
105 |
if(driverName == "ESRI Shapefile"){ |
|
106 |
QRegExp regExp( ".shp$" ); |
|
107 |
QString prjName = shapefileName; |
|
108 |
prjName.replace( regExp, QString( "" ) ); |
|
109 |
prjName.append( QString( ".prj" ) ); |
|
110 |
QFile prjFile( prjName ); |
|
111 |
|
|
112 |
if ( !prjFile.open( QIODevice::WriteOnly ) ) |
|
113 |
{ |
|
114 |
QgsDebugMsg( "Couldn't open file " + prjName ); |
|
115 |
} |
|
116 |
else{ |
|
117 |
QTextStream prjStream( & prjFile ); |
|
118 |
prjStream << srs->toWkt().toLocal8Bit().data() << endl; |
|
119 |
prjFile.close(); |
|
120 |
} |
|
121 |
} |
|
101 | 122 | |
102 | 123 |
if ( srs ) |
103 | 124 |
{ |