Skip to content
Permalink
Browse files

[OGR provider] Use FORCE_SRS_DETECTION=YES open option for GML datasets

  • Loading branch information
rouault committed Sep 15, 2017
1 parent 78591b7 commit c26584cc13a15ef0626c3fd4ad3b01743d2c570b
Showing with 18 additions and 1 deletion.
  1. +18 −1 src/providers/ogr/qgsogrprovider.cpp
@@ -3166,8 +3166,25 @@ void QgsOgrProvider::forceReload()
GDALDatasetH QgsOgrProviderUtils::GDALOpenWrapper( const char *pszPath, bool bUpdate, GDALDriverH *phDriver )
{
CPLErrorReset();

char **papszOpenOptions = nullptr;
#if GDAL_VERSION_NUM >= GDAL_COMPUTE_VERSION(2,2,0)
const char *apszAllowedDrivers[] = { "GML", nullptr };
GDALDriverH hIdentifiedDriver =
GDALIdentifyDriverEx( pszPath, GDAL_OF_VECTOR, apszAllowedDrivers, nullptr );
#else
GDALDriverH hIdentifiedDriver =
GDALIdentifyDriver( pszPath, nullptr );
#endif
if ( hIdentifiedDriver &&
strcmp( GDALGetDriverShortName( hIdentifiedDriver ), "GML" ) == 0 )
{
papszOpenOptions = CSLSetNameValue( papszOpenOptions, "FORCE_SRS_DETECTION", "YES" );
}

const int nOpenFlags = GDAL_OF_VECTOR | ( bUpdate ? GDAL_OF_UPDATE : 0 );
GDALDatasetH hDS = GDALOpenEx( pszPath, nOpenFlags, nullptr, nullptr, nullptr );
GDALDatasetH hDS = GDALOpenEx( pszPath, nOpenFlags, nullptr, papszOpenOptions, nullptr );
CSLDestroy( papszOpenOptions );
if ( !hDS )
{
if ( phDriver )

0 comments on commit c26584c

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