Skip to content
Permalink
Browse files

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

…pefile dataset
  • Loading branch information
nirvn committed Feb 4, 2020
1 parent caf334e commit ab8622736bd4c41b9eb342a8ff50c24589ed7549
Showing with 10 additions and 2 deletions.
  1. +5 −0 src/core/providers/ogr/qgsogrprovider.cpp
  2. +5 −2 src/core/qgsvectorfilewriter.cpp
@@ -3652,6 +3652,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 );
@@ -3662,6 +3663,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 ab86227

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