Skip to content

Commit

Permalink
Add docs and tests for decode_uri
Browse files Browse the repository at this point in the history
  • Loading branch information
m-kuhn committed Dec 11, 2018
1 parent 74e0f0f commit ce271e6
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
12 changes: 12 additions & 0 deletions resources/function_help/json/decode_uri
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"name": "decode_uri",
"type": "function",
"description": "Takes a layer and decodes the uri of the undelying data provider. It depends on the dataprovider, which data is available.",
"arguments": [ {"arg":"layer","description":"The layer for which the uri should be decoded."},
{"arg":"part","description":"The part of the uri to return. If unspecified, a map with all uri parts will be returned."} ],
"examples": [ { "expression":"decode_uri(@layer)", "returns":"{'layerId': '0', 'layerName': '', 'path': '/home/qgis/shapefile.shp'}"},
{ "expression":"decode_uri(@layer)", "returns":"{'layerId': NULL, 'layerName': 'layer', 'path': '/home/qgis/geopackage.shp'}"},
{ "expression":"decode_uri(@layer), 'path'", "returns":"'/home/qgis/geopackage.shp'"},
]
}

2 changes: 2 additions & 0 deletions tests/src/core/testqgsexpression.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1266,6 +1266,8 @@ class TestQgsExpression: public QObject
QTest::newRow( "layer_property storage_type" ) << QStringLiteral( "layer_property('%1','storage_type')" ).arg( mPointsLayer->name() ) << false << QVariant( "ESRI Shapefile" );
QTest::newRow( "layer_property geometry_type" ) << QStringLiteral( "layer_property('%1','geometry_type')" ).arg( mPointsLayer->name() ) << false << QVariant( "Point" );

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" );

// raster_statistic tests
QTest::newRow( "raster_statistic no layer" ) << "raster_statistic('',1,'min')" << false << QVariant();
QTest::newRow( "raster_statistic bad layer" ) << "raster_statistic('bad',1,'min')" << false << QVariant();
Expand Down

0 comments on commit ce271e6

Please sign in to comment.