Skip to content
Permalink
Browse files

Add docs and tests for decode_uri

  • Loading branch information
m-kuhn committed Dec 18, 2018
1 parent 47fe506 commit 84584012ecb109a9d26a86c01d8de234fe11b628
Showing with 14 additions and 0 deletions.
  1. +12 −0 resources/function_help/json/decode_uri
  2. +2 −0 tests/src/core/testqgsexpression.cpp
@@ -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'"},
]
}

@@ -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();

0 comments on commit 8458401

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