@@ -799,24 +799,15 @@ QString QgsMapLayer::baseURI( PropertyType type ) const
799
799
{
800
800
QString myURI = publicSource ();
801
801
802
- // if file is using the VSIFILE mechanism, remove the prefix
803
- if ( myURI.startsWith ( QLatin1String ( " /vsigzip/" ), Qt::CaseInsensitive ) )
804
- {
805
- myURI.remove ( 0 , 9 );
806
- }
807
- else if ( myURI.startsWith ( QLatin1String ( " /vsizip/" ), Qt::CaseInsensitive ) &&
808
- myURI.endsWith ( QLatin1String ( " .zip" ), Qt::CaseInsensitive ) )
809
- {
810
- // ideally we should look for .qml file inside zip file
811
- myURI.remove ( 0 , 8 );
812
- }
813
- else if ( myURI.startsWith ( QLatin1String ( " /vsitar/" ), Qt::CaseInsensitive ) &&
814
- ( myURI.endsWith ( QLatin1String ( " .tar" ), Qt::CaseInsensitive ) ||
815
- myURI.endsWith ( QLatin1String ( " .tar.gz" ), Qt::CaseInsensitive ) ||
816
- myURI.endsWith ( QLatin1String ( " .tgz" ), Qt::CaseInsensitive ) ) )
817
- {
818
- // ideally we should look for .qml file inside tar file
819
- myURI.remove ( 0 , 8 );
802
+ // first get base path for delimited text, spatialite and OGR layers,
803
+ // as in these cases URI may contain layer name and/or additional
804
+ // information. This also strips prefix in case if VSIFILE mechanism
805
+ // is used
806
+ if ( providerType () == QLatin1String ( " ogr" ) || providerType () == QLatin1String ( " delimitedtext" ) ||
807
+ providerType () == QLatin1String ( " spatialite" ) )
808
+ {
809
+ QVariantMap components = QgsProviderRegistry::instance ()->decodeUri ( providerType (), myURI );
810
+ myURI = components[" path" ].toString ();
820
811
}
821
812
822
813
QFileInfo myFileInfo ( myURI );
0 commit comments