Skip to content
Permalink
Browse files

Follow up 012ee83: delete .qpj file when overwriting pre-existing sha…

…pefile dataset
  • Loading branch information
github-actions authored and nirvn committed Feb 4, 2020
1 parent b4142c3 commit 445de78ced989452cad0a3413be9fc4269419d28
Showing with 10 additions and 2 deletions.
  1. +5 −0 src/core/providers/ogr/qgsogrprovider.cpp
  2. +5 −2 src/core/qgsvectorfilewriter.cpp
@@ -3635,6 +3635,7 @@ bool QgsOgrProviderUtils::createEmptyDataSource( const QString &uri,
{
QString layerName = uri.left( index );
QFile prjFile( layerName + ".qpj" );
#if PROJ_VERSION_MAJOR<6
if ( prjFile.open( QIODevice::WriteOnly | QIODevice::Truncate ) )
{
QTextStream prjStream( &prjFile );
@@ -3645,6 +3646,10 @@ bool QgsOgrProviderUtils::createEmptyDataSource( const QString &uri,
{
QgsMessageLog::logMessage( QObject::tr( "Couldn't create file %1.qpj" ).arg( layerName ), QObject::tr( "OGR" ) );
}
#else
if ( prjFile.exists() )
prjFile.remove();
#endif
}
}

@@ -503,13 +503,13 @@ void QgsVectorFileWriter::init( QString vectorFileName,
CPLSetConfigOption( "SHAPE_ENCODING", nullptr );
}

#if PROJ_VERSION_MAJOR<6
if ( srs.isValid() )
{
if ( mOgrDriverName == QLatin1String( "ESRI Shapefile" ) )
{
QString layerName = vectorFileName.left( vectorFileName.indexOf( QLatin1String( ".shp" ), Qt::CaseInsensitive ) );
QFile prjFile( layerName + ".qpj" );
#if PROJ_VERSION_MAJOR<6
if ( prjFile.open( QIODevice::WriteOnly | QIODevice::Truncate ) )
{
QTextStream prjStream( &prjFile );
@@ -520,9 +520,12 @@ void QgsVectorFileWriter::init( QString vectorFileName,
{
QgsDebugMsg( "Couldn't open file " + layerName + ".qpj" );
}
#else
if ( prjFile.exists() )
prjFile.remove();
#endif
}
}
#endif

if ( !mLayer )
{

0 comments on commit 445de78

Please sign in to comment.
You can’t perform that action at this time.