From 94378e689dd3e3fd61f3a584c43af5952daccee4 Mon Sep 17 00:00:00 2001 From: baloola Date: Mon, 2 Dec 2024 20:15:44 +0100 Subject: [PATCH] complete getLegendGraphic document adding formats --- eoxserver/services/ows/wms/basehandlers.py | 2 +- eoxserver/services/ows/wms/v10/encoders.py | 15 ++++++++++++++- eoxserver/services/ows/wms/v11/encoders.py | 8 +++++++- eoxserver/services/ows/wms/v13/encoders.py | 14 +++++++------- 4 files changed, 29 insertions(+), 10 deletions(-) diff --git a/eoxserver/services/ows/wms/basehandlers.py b/eoxserver/services/ows/wms/basehandlers.py index 800458a07..324f71b6b 100644 --- a/eoxserver/services/ows/wms/basehandlers.py +++ b/eoxserver/services/ows/wms/basehandlers.py @@ -129,7 +129,7 @@ def handle(self, request): encoder.encode_capabilities( conf, request.build_absolute_uri(reverse('ows')), crss.getSupportedCRS_WMS(format_function=crss.asShortCode), - map_renderer.get_supported_formats(), [], + map_renderer.get_supported_formats(), [], get_legend_renderer().get_supported_formats(), layer_descriptions ), pretty_print=settings.DEBUG diff --git a/eoxserver/services/ows/wms/v10/encoders.py b/eoxserver/services/ows/wms/v10/encoders.py index 21a23a349..5dd4ce10e 100644 --- a/eoxserver/services/ows/wms/v10/encoders.py +++ b/eoxserver/services/ows/wms/v10/encoders.py @@ -32,7 +32,7 @@ class WMS10Encoder(XMLEncoder): - def encode_capabilities(self, config, ows_url, srss, formats, info_formats, + def encode_capabilities(self, config, ows_url, srss, formats, info_formats, legend_formats, layer_descriptions): mime_to_name = { @@ -88,6 +88,19 @@ def encode_capabilities(self, config, ows_url, srss, formats, info_formats, ) ) ), + E("LegendGraphic", + E("Format", *[ + E(mime_to_name[frmt.mimeType]) + for frmt in legend_formats + if frmt.mimeType in mime_to_name + ] + ), + E("DCPType", + E("HTTP", + E("Get", onlineResource=ows_url) + ) + ) + ), ), E("Exception", E("Format", diff --git a/eoxserver/services/ows/wms/v11/encoders.py b/eoxserver/services/ows/wms/v11/encoders.py index 009073bc7..05896528a 100644 --- a/eoxserver/services/ows/wms/v11/encoders.py +++ b/eoxserver/services/ows/wms/v11/encoders.py @@ -36,7 +36,7 @@ class WMS11Encoder(XMLEncoder): - def encode_capabilities(self, config, ows_url, srss, formats, info_formats, + def encode_capabilities(self, config, ows_url, srss, formats, info_formats, legend_formats, layer_descriptions): return E("WMT_MS_Capabilities", E("Service", @@ -91,6 +91,12 @@ def encode_capabilities(self, config, ows_url, srss, formats, info_formats, ), self.encode_dcptype(ows_url) ), + E("GetLegendGraphic",*[ + E("Format", frmt.mimeType) + for frmt in legend_formats + ] + [ + self.encode_dcptype(ows_url) + ]), # TODO: describe layer? ), E("Exception", diff --git a/eoxserver/services/ows/wms/v13/encoders.py b/eoxserver/services/ows/wms/v13/encoders.py index 893f95b6f..bd049b527 100644 --- a/eoxserver/services/ows/wms/v13/encoders.py +++ b/eoxserver/services/ows/wms/v13/encoders.py @@ -38,7 +38,7 @@ class WMS13Encoder(XMLEncoder): - def encode_capabilities(self, config, ows_url, srss, formats, info_formats, + def encode_capabilities(self, config, ows_url, srss, formats, info_formats, legend_formats, layer_descriptions): return WMS("WMS_Capabilities", WMS("Service", @@ -98,12 +98,12 @@ def encode_capabilities(self, config, ows_url, srss, formats, info_formats, ), self.encode_dcptype(ows_url) ), - WMS("GetLegendGraphic", - WMS("Format", - # TODO - ), - self.encode_dcptype(ows_url) - ), + WMS("GetLegendGraphic",*[ + WMS("Format", frmt.mimeType) + for frmt in legend_formats + ] + [ + self.encode_dcptype(ows_url) + ]), # TODO: describe layer? ), WMS("Exception",