Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit ce271e6

Browse files
committedDec 11, 2018
Add docs and tests for decode_uri
1 parent 74e0f0f commit ce271e6

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed
 
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"name": "decode_uri",
3+
"type": "function",
4+
"description": "Takes a layer and decodes the uri of the undelying data provider. It depends on the dataprovider, which data is available.",
5+
"arguments": [ {"arg":"layer","description":"The layer for which the uri should be decoded."},
6+
{"arg":"part","description":"The part of the uri to return. If unspecified, a map with all uri parts will be returned."} ],
7+
"examples": [ { "expression":"decode_uri(@layer)", "returns":"{'layerId': '0', 'layerName': '', 'path': '/home/qgis/shapefile.shp'}"},
8+
{ "expression":"decode_uri(@layer)", "returns":"{'layerId': NULL, 'layerName': 'layer', 'path': '/home/qgis/geopackage.shp'}"},
9+
{ "expression":"decode_uri(@layer), 'path'", "returns":"'/home/qgis/geopackage.shp'"},
10+
]
11+
}
12+

‎tests/src/core/testqgsexpression.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1266,6 +1266,8 @@ class TestQgsExpression: public QObject
12661266
QTest::newRow( "layer_property storage_type" ) << QStringLiteral( "layer_property('%1','storage_type')" ).arg( mPointsLayer->name() ) << false << QVariant( "ESRI Shapefile" );
12671267
QTest::newRow( "layer_property geometry_type" ) << QStringLiteral( "layer_property('%1','geometry_type')" ).arg( mPointsLayer->name() ) << false << QVariant( "Point" );
12681268

1269+
QTest::newRow( "decode_uri shp path" ) << QStringLiteral( "array_last(string_to_array(replace(decode_uri('@layer'%1', 'path'), '\\\\', '/'), '/'))" ).arg( mPointsLayer->name() ) << false << QVariant( "points.shp" );
1270+
12691271
// raster_statistic tests
12701272
QTest::newRow( "raster_statistic no layer" ) << "raster_statistic('',1,'min')" << false << QVariant();
12711273
QTest::newRow( "raster_statistic bad layer" ) << "raster_statistic('bad',1,'min')" << false << QVariant();

0 commit comments

Comments
 (0)
Please sign in to comment.