Skip to content

Commit

Permalink
Add legend_default_font_size setting
Browse files Browse the repository at this point in the history
  • Loading branch information
pka committed Dec 19, 2023
1 parent 7eb11d3 commit 358f555
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
QWC Legend Service
==================

Acts as a proxy between the client and the OGC service for GetLegendGraphic request,
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`.
Expand Down Expand Up @@ -202,4 +202,4 @@ Install requirements:

Start local service:

CONFIG_PATH=/PATH/TO/CONFIGS/ python server.py
CONFIG_PATH=/PATH/TO/CONFIGS/ python src/server.py
4 changes: 4 additions & 0 deletions schemas/qwc-legend-service.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@
"description": "Default base URL for forwarding WMS GetLegendGraphics requests",
"type": "string"
},
"legend_default_font_size": {
"description": "Default font size for GetLegendGraphic request",
"type": "number"
},
"legend_images_path": {
"description": "Path to legend images (required if using 'legend_image')",
"type": "string"
Expand Down
8 changes: 8 additions & 0 deletions src/legend_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ def __init__(self, tenant, logger):
self.qgis_server_url = config.get(
'default_qgis_server_url', 'http://localhost:8001/ows/'
).rstrip('/') + '/'
self.legend_default_font_size = config.get("legend_default_font_size")

# get path to legend images from config
self.legend_images_path = config.get('legend_images_path', 'legends/')
Expand Down Expand Up @@ -146,6 +147,13 @@ def get_legend(self, service_name, layer_param, format_param, params, type,
"style": ""
}
req_params.update(params)
if self.legend_default_font_size:
if 'layerfontsize' not in req_params:
req_params['layerfontsize'] = \
self.legend_default_font_size
if 'itemfontsize' not in req_params:
req_params['itemfontsize'] = \
self.legend_default_font_size
response = requests.get(
self.qgis_server_url + service_name, params=req_params,
timeout=30
Expand Down

0 comments on commit 358f555

Please sign in to comment.