Skip to content
Permalink
Browse files

[afs] Implemented decodeUri for AFS provider

Allows retrieval of the web URL for an AFS layer
  • Loading branch information
nyalldawson committed Nov 7, 2018
1 parent 9489670 commit 4b32e7cc786bf9a28c826e6e94338e7ee2f7ad9e
@@ -96,12 +96,12 @@ Returns the provider capabilities

QVariantMap decodeUri( const QString &providerKey, const QString &uri );
%Docstring
Returns the components (e.g. file path, layer name) of a provider uri
Breaks a provider data source URI into its component paths (e.g. file path, layer name).

:param providerKey: identifier of the provider
:param uri: uri string

:return: map containing components
:return: map containing components. Standard components include "path", "layerName", "url".

.. note::

@@ -108,12 +108,12 @@ class CORE_EXPORT QgsProviderRegistry
int providerCapabilities( const QString &providerKey ) const;

/**
* Returns the components (e.g. file path, layer name) of a provider uri
\param providerKey identifier of the provider
\param uri uri string
\returns map containing components
\note this function may not be supported by all providers, an empty map will be returned in such case
\since QGIS 3.4
* Breaks a provider data source URI into its component paths (e.g. file path, layer name).
* \param providerKey identifier of the provider
* \param uri uri string
* \returns map containing components. Standard components include "path", "layerName", "url".
* \note this function may not be supported by all providers, an empty map will be returned in such case
* \since QGIS 3.4
*/
QVariantMap decodeUri( const QString &providerKey, const QString &uri );

@@ -59,3 +59,12 @@ QGISEXTERN int dataCapabilities()
{
return QgsDataProvider::Net;
}

QGISEXTERN QVariantMap decodeUri( const QString &uri )
{
QgsDataSourceUri dsUri = QgsDataSourceUri( uri );

QVariantMap components;
components.insert( QStringLiteral( "url" ), dsUri.param( QStringLiteral( "url" ) ) );
return components;
}
@@ -28,7 +28,8 @@
QgsApplication,
QgsSettings,
QgsRectangle,
QgsCategorizedSymbolRenderer
QgsCategorizedSymbolRenderer,
QgsProviderRegistry
)
from qgis.testing import (start_app,
unittest
@@ -417,6 +418,14 @@ def testGetFeaturesNoGeometry(self):
"""
pass

def testDecodeUri(self):
"""
Test decoding an AFS uri
"""
uri = self.vl.source()
parts = QgsProviderRegistry.instance().decodeUri(self.vl.dataProvider().name(), uri)
self.assertEqual(parts, {'url': 'http://' + self.basetestpath + '/fake_qgis_http_endpoint'})

def testObjectIdDifferentName(self):
""" Test that object id fields not named OBJECTID work correctly """

0 comments on commit 4b32e7c

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