Skip to content
Permalink
Browse files

Add `path` to `layer_property` expression function

  • Loading branch information
m-kuhn committed Dec 18, 2018
1 parent 7b876d8 commit 65e60d17aafce7f3177f94cbcd926574bc87375b
Showing with 9 additions and 1 deletion.
  1. +1 −1 resources/function_help/json/layer_property
  2. +8 −0 src/core/expression/qgsexpressionfunction.cpp
@@ -4,7 +4,7 @@
"description": "Returns a matching layer property or metadata value.",
"arguments": [
{"arg":"layer", "description":"a string, representing either a layer name or layer ID"},
{"arg":"property", "description":"a string corresponding to the property to return. Valid options are:<br /><ul><li>name: layer name</li><li>id: layer ID</li><li>title: metadata title string</li><li>abstract: metadata abstract string</li><li>keywords: metadata keywords</li><li>data_url: metadata URL</li><li>attribution: metadata attribution string</li><li>attribution_url: metadata attribution URL</li><li>source: layer source</li><li>min_scale: minimum display scale for layer</li><li>max_scale: maximum display scale for layer</li><li>crs: layer CRS</li><li>crs_definition: layer CRS full definition</li><li>crs_description: layer CRS description</li><li>extent: layer extent (as a geometry object)</li><li>type: layer type, e.g., Vector or Raster</li><li>storage_type: storage format (vector layers only)</li><li>geometry_type: geometry type, e.g., Point (vector layers only)</li><li>feature_count: approximate feature count for layer (vector layers only)</li></ul>"}
{"arg":"property", "description":"a string corresponding to the property to return. Valid options are:<br /><ul><li>name: layer name</li><li>id: layer ID</li><li>title: metadata title string</li><li>abstract: metadata abstract string</li><li>keywords: metadata keywords</li><li>data_url: metadata URL</li><li>attribution: metadata attribution string</li><li>attribution_url: metadata attribution URL</li><li>source: layer source</li><li>min_scale: minimum display scale for layer</li><li>max_scale: maximum display scale for layer</li><li>crs: layer CRS</li><li>crs_definition: layer CRS full definition</li><li>crs_description: layer CRS description</li><li>extent: layer extent (as a geometry object)</li><li>type: layer type, e.g., Vector or Raster</li><li>storage_type: storage format (vector layers only)</li><li>geometry_type: geometry type, e.g., Point (vector layers only)</li><li>feature_count: approximate feature count for layer (vector layers only)</li><li>path: File path to the layer data source. Only available for file based layers.</li></ul>"}
],
"examples": [
{ "expression":"layer_property('streets','title')", "returns":"'Basemap Streets'"},
@@ -4025,6 +4025,14 @@ static QVariant fcnGetLayerProperty( const QVariantList &values, const QgsExpres
return QgsWkbTypes::geometryDisplayString( vLayer->geometryType() );
else if ( QString::compare( layerProperty, QStringLiteral( "feature_count" ), Qt::CaseInsensitive ) == 0 )
return QVariant::fromValue( vLayer->featureCount() );
else if ( QString::compare( layerProperty, QStringLiteral( "path" ), Qt::CaseInsensitive ) == 0 )
{
if ( vLayer->dataProvider() )
{
const QVariantMap decodedUri = QgsProviderRegistry::instance()->decodeUri( layer->providerType(), layer->dataProvider()->dataSourceUri() );
return decodedUri.value( QStringLiteral( "path" ) );
}
}
}
}

0 comments on commit 65e60d1

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