Skip to content
Permalink
Browse files

Merge pull request #39328 from elpaso/bugfix-unreported-ogr-gpkg-laye…

…rType-case

OGR decodeUri: be tolerant on layerName case
  • Loading branch information
elpaso committed Oct 12, 2020
2 parents 498bbbb + 9b99ecb commit afd474beb212d72725eb087fa6f2f6857c87c31b
Showing with 18 additions and 3 deletions.
  1. +3 −3 src/core/providers/ogr/qgsogrprovider.cpp
  2. +15 −0 tests/src/python/test_provider_ogr_gpkg.py
@@ -3473,9 +3473,9 @@ QVariantMap QgsOgrProviderMetadata::decodeUri( const QString &uri )

if ( path.contains( '|' ) )
{
const QRegularExpression geometryTypeRegex( QStringLiteral( "\\|geometrytype=([a-zA-Z0-9]*)" ) );
const QRegularExpression layerNameRegex( QStringLiteral( "\\|layername=([^|]*)" ) );
const QRegularExpression layerIdRegex( QStringLiteral( "\\|layerid=([^|]*)" ) );
const QRegularExpression geometryTypeRegex( QStringLiteral( "\\|geometrytype=([a-zA-Z0-9]*)" ), QRegularExpression::PatternOption::CaseInsensitiveOption );
const QRegularExpression layerNameRegex( QStringLiteral( "\\|layername=([^|]*)" ), QRegularExpression::PatternOption::CaseInsensitiveOption );
const QRegularExpression layerIdRegex( QStringLiteral( "\\|layerid=([^|]*)" ), QRegularExpression::PatternOption::CaseInsensitiveOption );
const QRegularExpression subsetRegex( QStringLiteral( "\\|subset=((?:.*[\r\n]*)*)\\Z" ) );
const QRegularExpression openOptionRegex( QStringLiteral( "\\|option:([^|]*)" ) );

@@ -257,11 +257,26 @@ def testDecodeUri(self):
self.assertEqual(components["path"], filename)
self.assertEqual(components["layerName"], 'test')

uri = '{}|layerName=test'.format(filename)
components = registry.decodeUri('ogr', uri)
self.assertEqual(components["path"], filename)
self.assertEqual(components["layerName"], 'test')

uri = '{}|layerid=0'.format(filename)
components = registry.decodeUri('ogr', uri)
self.assertEqual(components["path"], filename)
self.assertEqual(components["layerId"], 0)

uri = '{}|layerId=0'.format(filename)
components = registry.decodeUri('ogr', uri)
self.assertEqual(components["path"], filename)
self.assertEqual(components["layerId"], 0)

uri = '{}|geometryType=POINT'.format(filename)
components = registry.decodeUri('ogr', uri)
self.assertEqual(components["path"], filename)
self.assertEqual(components["geometryType"], 'POINT')

def testEncodeUri(self):

filename = '/home/to/path/my_file.gpkg'

0 comments on commit afd474b

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