Skip to content

Commit 9859709

Browse files
committed
fix set crs to OGR data items (broken in 04aab29)
1 parent 149c96a commit 9859709

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

src/providers/ogr/qgsogrdataitems.cpp

+5-6
Original file line numberDiff line numberDiff line change
@@ -78,16 +78,15 @@ bool QgsOgrLayerItem::setCrs( QgsCoordinateReferenceSystem crs )
7878
// we are able to assign CRS only to shapefiles :-(
7979
if ( driverName == "ESRI Shapefile" )
8080
{
81-
// QString layerName = mPath.left( mPath.indexOf( ".shp", Qt::CaseInsensitive ) );
82-
QString lyrName = layerName();
81+
QString layerName = mPath.left( mPath.indexOf( ".shp", Qt::CaseInsensitive ) );
8382
QString wkt = crs.toWkt();
8483

8584
// save ordinary .prj file
8685
OGRSpatialReferenceH hSRS = OSRNewSpatialReference( wkt.toLocal8Bit().data() );
8786
OSRMorphToESRI( hSRS ); // this is the important stuff for shapefile .prj
8887
char* pszOutWkt = NULL;
8988
OSRExportToWkt( hSRS, &pszOutWkt );
90-
QFile prjFile( lyrName + ".prj" );
89+
QFile prjFile( layerName + ".prj" );
9190
if ( prjFile.open( QIODevice::WriteOnly ) )
9291
{
9392
QTextStream prjStream( &prjFile );
@@ -96,14 +95,14 @@ bool QgsOgrLayerItem::setCrs( QgsCoordinateReferenceSystem crs )
9695
}
9796
else
9897
{
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" ) );
10099
return false;
101100
}
102101
OSRDestroySpatialReference( hSRS );
103102
CPLFree( pszOutWkt );
104103

105104
// save qgis-specific .qpj file (maybe because of better wkt compatibility?)
106-
QFile qpjFile( lyrName + ".qpj" );
105+
QFile qpjFile( layerName + ".qpj" );
107106
if ( qpjFile.open( QIODevice::WriteOnly ) )
108107
{
109108
QTextStream qpjStream( &qpjFile );
@@ -112,7 +111,7 @@ bool QgsOgrLayerItem::setCrs( QgsCoordinateReferenceSystem crs )
112111
}
113112
else
114113
{
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" ) );
116115
return false;
117116
}
118117

0 commit comments

Comments
 (0)