Skip to content

Commit

Permalink
fix: use a version string for the wmts legend_url
Browse files Browse the repository at this point in the history
  • Loading branch information
simonseyock committed Jul 17, 2024
1 parent 396176f commit ff36f70
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
8 changes: 7 additions & 1 deletion mapproxy/config/loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -1950,14 +1950,20 @@ def tile_layers(self, grid_name_as_path=False):
md['format'] = self.context.caches[cache_name].image_opts().format
md['cache_name'] = cache_name
md['extent'] = extent
legend_version = None
if 'legendurl' in self.conf:
wms_conf = self.context.services.conf.get('wms', None)
# GetLegendGraphic with legendurl does not seem to work in non 1.3.0 versions
if wms_conf is not None and '1.3.0' in wms_conf.get('versions', ['1.3.0']):
legend_version = '1.3.0'
tile_layers.append(
TileLayer(
self.conf['name'], self.conf['title'],
info_sources=fi_sources,
md=md,
tile_manager=cache_source,
dimensions=dimensions,
legend='legendurl' in self.conf and 'wms' in self.context.services.conf
legend_version=legend_version
)
)

Expand Down
4 changes: 2 additions & 2 deletions mapproxy/service/templates/wmts100capabilities.xml
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,10 @@
<ows:Identifier>{{layer.name}}</ows:Identifier>
<Style>
<ows:Identifier>default</ows:Identifier>
{{if layer.legend}}
{{if layer.legend_version}}
<LegendURL
format="image/png"
xlink:href="{{service.url}}?service=WMS&amp;request=GetLegendGraphic&amp;version=1.3.0&amp;format=image%2Fpng&amp;layer={{layer.name}}"
xlink:href="{{service.url}}?service=WMS&amp;request=GetLegendGraphic&amp;version={{layer.legend_version}}&amp;format=image%2Fpng&amp;layer={{layer.name}}"
/>
{{endif}}
</Style>
Expand Down
4 changes: 2 additions & 2 deletions mapproxy/service/tile.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ def _render_root_resource_template(self, service):


class TileLayer(object):
def __init__(self, name, title, md, tile_manager, info_sources=[], dimensions=None, legend=False):
def __init__(self, name, title, md, tile_manager, info_sources=[], dimensions=None, legend_version=None):
"""
:param md: the layer metadata
:param tile_manager: the layer tile manager
Expand All @@ -220,7 +220,7 @@ def __init__(self, name, title, md, tile_manager, info_sources=[], dimensions=No
self._empty_tile = None
self._mixed_format = True if self.md.get('format', False) == 'mixed' else False
self.empty_response_as_png = True
self.legend = legend
self.legend_version = legend_version

@property
def bbox(self):
Expand Down

0 comments on commit ff36f70

Please sign in to comment.