@@ -78,16 +78,15 @@ bool QgsOgrLayerItem::setCrs( QgsCoordinateReferenceSystem crs )
78
78
// we are able to assign CRS only to shapefiles :-(
79
79
if ( driverName == " ESRI Shapefile" )
80
80
{
81
- // QString layerName = mPath.left( mPath.indexOf( ".shp", Qt::CaseInsensitive ) );
82
- QString lyrName = layerName ();
81
+ QString layerName = mPath .left ( mPath .indexOf ( " .shp" , Qt::CaseInsensitive ) );
83
82
QString wkt = crs.toWkt ();
84
83
85
84
// save ordinary .prj file
86
85
OGRSpatialReferenceH hSRS = OSRNewSpatialReference ( wkt.toLocal8Bit ().data () );
87
86
OSRMorphToESRI ( hSRS ); // this is the important stuff for shapefile .prj
88
87
char * pszOutWkt = NULL ;
89
88
OSRExportToWkt ( hSRS, &pszOutWkt );
90
- QFile prjFile ( lyrName + " .prj" );
89
+ QFile prjFile ( layerName + " .prj" );
91
90
if ( prjFile.open ( QIODevice::WriteOnly ) )
92
91
{
93
92
QTextStream prjStream ( &prjFile );
@@ -96,14 +95,14 @@ bool QgsOgrLayerItem::setCrs( QgsCoordinateReferenceSystem crs )
96
95
}
97
96
else
98
97
{
99
- QgsMessageLog::logMessage ( tr ( " Couldn't open file %1.prj" ).arg ( lyrName ), tr ( " OGR" ) );
98
+ QgsMessageLog::logMessage ( tr ( " Couldn't open file %1.prj" ).arg ( layerName ), tr ( " OGR" ) );
100
99
return false ;
101
100
}
102
101
OSRDestroySpatialReference ( hSRS );
103
102
CPLFree ( pszOutWkt );
104
103
105
104
// save qgis-specific .qpj file (maybe because of better wkt compatibility?)
106
- QFile qpjFile ( lyrName + " .qpj" );
105
+ QFile qpjFile ( layerName + " .qpj" );
107
106
if ( qpjFile.open ( QIODevice::WriteOnly ) )
108
107
{
109
108
QTextStream qpjStream ( &qpjFile );
@@ -112,7 +111,7 @@ bool QgsOgrLayerItem::setCrs( QgsCoordinateReferenceSystem crs )
112
111
}
113
112
else
114
113
{
115
- QgsMessageLog::logMessage ( tr ( " Couldn't open file %1.qpj" ).arg ( lyrName ), tr ( " OGR" ) );
114
+ QgsMessageLog::logMessage ( tr ( " Couldn't open file %1.qpj" ).arg ( layerName ), tr ( " OGR" ) );
116
115
return false ;
117
116
}
118
117
0 commit comments