Skip to content

Commit 043c86b

Browse files
rouaultm-kuhn
authored andcommitted
[OGR provider] Use FORCE_SRS_DETECTION=YES open option for GML datasets
1 parent 867c678 commit 043c86b

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

src/providers/ogr/qgsogrprovider.cpp

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3166,8 +3166,25 @@ void QgsOgrProvider::forceReload()
31663166
GDALDatasetH QgsOgrProviderUtils::GDALOpenWrapper( const char *pszPath, bool bUpdate, GDALDriverH *phDriver )
31673167
{
31683168
CPLErrorReset();
3169+
3170+
char **papszOpenOptions = nullptr;
3171+
#if GDAL_VERSION_NUM >= GDAL_COMPUTE_VERSION(2,2,0)
3172+
const char *apszAllowedDrivers[] = { "GML", nullptr };
3173+
GDALDriverH hIdentifiedDriver =
3174+
GDALIdentifyDriverEx( pszPath, GDAL_OF_VECTOR, apszAllowedDrivers, nullptr );
3175+
#else
3176+
GDALDriverH hIdentifiedDriver =
3177+
GDALIdentifyDriver( pszPath, nullptr );
3178+
#endif
3179+
if ( hIdentifiedDriver &&
3180+
strcmp( GDALGetDriverShortName( hIdentifiedDriver ), "GML" ) == 0 )
3181+
{
3182+
papszOpenOptions = CSLSetNameValue( papszOpenOptions, "FORCE_SRS_DETECTION", "YES" );
3183+
}
3184+
31693185
const int nOpenFlags = GDAL_OF_VECTOR | ( bUpdate ? GDAL_OF_UPDATE : 0 );
3170-
GDALDatasetH hDS = GDALOpenEx( pszPath, nOpenFlags, nullptr, nullptr, nullptr );
3186+
GDALDatasetH hDS = GDALOpenEx( pszPath, nOpenFlags, nullptr, papszOpenOptions, nullptr );
3187+
CSLDestroy( papszOpenOptions );
31713188
if ( !hDS )
31723189
{
31733190
if ( phDriver )

0 commit comments

Comments
 (0)