mirror of
https://github.com/qgis/QGIS.git
synced 2025-02-28 00:17:30 -05:00
Handle windows path in gdal provider's decodeUri function
This commit is contained in:
parent
b97037038c
commit
7d4a4eb5ca
@ -1994,9 +1994,17 @@ QGISEXTERN QVariantMap decodeUri( const QString &uri )
|
||||
if ( path.indexOf( ':' ) != -1 )
|
||||
{
|
||||
QStringList parts = path.split( ':' );
|
||||
path = parts[1];
|
||||
if ( parts.count() > 2 )
|
||||
layerName = parts[2];
|
||||
if ( parts[0].toLower() == QStringLiteral( "gpkg" ) )
|
||||
{
|
||||
parts.removeFirst();
|
||||
// Handle windows paths - which has an extra colon - and unix paths
|
||||
if ( ( parts[0].length() > 1 && parts.count() > 1 ) || parts.count() > 2 )
|
||||
{
|
||||
layerName = parts[parts.length() - 1];
|
||||
parts.removeLast();
|
||||
}
|
||||
path = parts.join( ':' );
|
||||
}
|
||||
}
|
||||
|
||||
QVariantMap uriComponents;
|
||||
|
@ -95,6 +95,12 @@ void TestQgsGdalProvider::decodeUri()
|
||||
components = QgsProviderRegistry::instance()->decodeUri( QStringLiteral( "gdal" ), uri );
|
||||
QCOMPARE( components[QStringLiteral( "path" )].toString(), QStringLiteral( "/home/to/path/my_file.gpkg" ) );
|
||||
QCOMPARE( components[QStringLiteral( "layerName" )].toString(), QStringLiteral( "layer_name" ) );
|
||||
|
||||
//test windows path
|
||||
uri = QStringLiteral( "gpkg:c:/home/to/path/my_file.gpkg:layer_name" );
|
||||
components = QgsProviderRegistry::instance()->decodeUri( QStringLiteral( "gdal" ), uri );
|
||||
QCOMPARE( components[QStringLiteral( "path" )].toString(), QStringLiteral( "c:/home/to/path/my_file.gpkg" ) );
|
||||
QCOMPARE( components[QStringLiteral( "layerName" )].toString(), QStringLiteral( "layer_name" ) );
|
||||
}
|
||||
|
||||
void TestQgsGdalProvider::scaleDataType()
|
||||
|
Loading…
x
Reference in New Issue
Block a user