Acts as a proxy between the client and QGIS server for GetLegendGraphic request, allowing to return custom legend graphics instead of the ones generated by the WMS server.
Note: Requires a QGIS server running on default_qgis_server_url.
Configure legend_images_path in the service configuration (see below). Then, legend images will be searched for in this order (the first one found is used):
- A
<legend_images_path>/<service_name>/<layername><suffix>.pngfile, whereservice_nameis the name of the WMS servicelayernameis the WMS layer namesuffix: empty, or one of_thumbnail,_tooltip, seetypequery-parameter below.
- A
<legend_images_path>/default<suffix>.pngfile. - According to the
legend_imagepaths set in the layer resource configurations of the legend service configuration.
The static config and permission files are stored as JSON files in $CONFIG_PATH with subdirectories for each tenant,
e.g. $CONFIG_PATH/default/*.json. The default tenant name is default.
- JSON schema
- File location:
$CONFIG_PATH/<tenant>/legendConfig.json
Example:
Note: the legend_image path for custom legend graphics is relative to legend_images_path and may contain subdirectories
- JSON schema
- File location:
$CONFIG_PATH/<tenant>/permissions.json
Example:
{
"$schema": "https://raw.githubusercontent.com/qwc-services/qwc-services-core/master/schemas/qwc-services-permissions.json",
"users": [
{
"name": "demo",
"groups": ["demo"],
"roles": []
}
],
"groups": [
{
"name": "demo",
"roles": ["demo"]
}
],
"roles": [
{
"role": "public",
"permissions": {
"wms_services": [
{
"name": "qwc_demo",
"layers": [
{
"name": "qwc_demo"
},
{
"name": "edit_demo"
},
{
"name": "edit_points"
},
{
"name": "edit_lines"
},
{
"name": "edit_polygons"
},
{
"name": "geographic_lines"
},
{
"name": "country_names"
},
{
"name": "states_provinces"
},
{
"name": "countries"
}
]
}
]
}
}
]
}The legend service be configured to accept password authentication using Basic authentication.
Example:
"config": {
"basic_auth_login_url": ["http://qwc-auth-service:9090/verify_login"]
},Set the CONFIG_PATH environment variable to the path containing the service config and permission files when starting this service (default: config).
Set the QWC2_PATH environment variable to the path containing your QWC2 production build.
Base URL:
http://localhost:5014/
API documentation:
http://localhost:5014/api/
Sample request:
http://localhost:5014/qwc_demo?SERVICE=WMS&REQUEST=GetLegendGraphic&LAYER=qwc_demo&format=image/png
See sample docker-compose.yml of qwc-docker.
Install dependencies and run service:
uv run src/server.py
With config path:
CONFIG_PATH=/PATH/TO/CONFIGS/ uv run src/server.py
{ "$schema": "https://raw.githubusercontent.com/qwc-services/qwc-legend-service/v2/schemas/qwc-legend-service.json", "service": "legend", "config": { // QGIS Server URL "default_qgis_server_url": "http://localhost:8001/ows/", // base path to legend images (required if using 'legend_image') "legend_images_path": "/PATH/TO/LEGENDS/" }, "resources": { "wms_services": [ { "name": "qwc_demo", "root_layer": { "name": "qwc_demo", "layers": [ { "name": "edit_demo", "layers": [ { "name": "edit_points", // using custom legend image "legend_image": "edit_points.png" }, { "name": "edit_lines", // using custom legend image in Base64 encoding "legend_image_base64": "iVBORw0KGgoAAAANSUhEUgAAAAgAAAAICAIAAABLbSncAAAAHUlEQVQI12NgwAEYGRgY/tdjiDYyMOHSQQ8JnAAAUUoCDCaibn8AAAAASUVORK5CYII=" }, { // using WMS GetLegendGraphics by default "name": "edit_polygons" } ] }, { "name": "geographic_lines" }, { "name": "country_names" }, { "name": "states_provinces" }, { "name": "countries" } ] } } ] } }