Skip to content

Commit 70b33f0

Browse files
authored
- filtering collections by provider to create a fcm['tile'] that can be passed to Jinja (#1950)
- showing the TMS endpoints on the landing page, only when fcm['tile'] exists
1 parent d78a8f3 commit 70b33f0

File tree

2 files changed

+18
-19
lines changed

2 files changed

+18
-19
lines changed

pygeoapi/api/__init__.py

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,8 @@
6464

6565
from pygeoapi.util import (
6666
CrsTransformSpec, TEMPLATES, UrlPrefetcher, dategetter,
67-
filter_dict_by_key_value, get_api_rules, get_base_url,
68-
get_provider_by_type, get_provider_default, get_typed_value,
67+
filter_dict_by_key_value, filter_providers_by_type, get_api_rules,
68+
get_base_url, get_provider_by_type, get_provider_default, get_typed_value,
6969
get_crs_from_uri, get_supported_crs_list, render_j2_template, to_json
7070
)
7171

@@ -815,21 +815,18 @@ def landing_page(api: API,
815815
headers = request.get_response_headers(**api.api_headers)
816816
if request.format == F_HTML: # render
817817

818-
fcm['processes'] = False
819-
fcm['stac'] = False
820-
fcm['collection'] = False
821-
822-
if filter_dict_by_key_value(api.config['resources'],
823-
'type', 'process'):
824-
fcm['processes'] = True
825-
826-
if filter_dict_by_key_value(api.config['resources'],
827-
'type', 'stac-collection'):
828-
fcm['stac'] = True
829-
830-
if filter_dict_by_key_value(api.config['resources'],
831-
'type', 'collection'):
832-
fcm['collection'] = True
818+
for resource_type in ['collection', 'process', 'stac-collection']:
819+
fcm[resource_type] = False
820+
821+
found = filter_dict_by_key_value(api.config['resources'],
822+
'type', resource_type)
823+
if found:
824+
fcm[resource_type] = True
825+
if resource_type == 'collection': # check for tiles
826+
for key, value in found.items():
827+
if filter_providers_by_type(value['providers'],
828+
'tile'):
829+
fcm['tile'] = True
833830

834831
content = render_j2_template(
835832
api.tpl_config, api.config['server']['templates'],

pygeoapi/templates/landing_page.html

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,15 +60,15 @@ <h2>{% trans %}Collections{% endtrans %}</h2>
6060
</p>
6161
</section>
6262
{% endif %}
63-
{% if data['stac'] %}
63+
{% if data['stac-collection'] %}
6464
<section id="collections">
6565
<h2>{% trans %}SpatioTemporal Assets{% endtrans %}</h2>
6666
<p>
6767
<a href="{{ config['server']['url'] }}/stac?f=html">{% trans %}View the SpatioTemporal Assets in this service{% endtrans %}</a>
6868
</p>
6969
</section>
7070
{% endif %}
71-
{% if data['processes'] %}
71+
{% if data['process'] %}
7272
<section id="processes">
7373
<h2>{% trans %}Processes{% endtrans %}</h2>
7474
<p>
@@ -97,12 +97,14 @@ <h2>{% trans %}Conformance{% endtrans %}</h2>
9797
<a href="{{ config['server']['url'] }}/conformance?f=html">{% trans %}View the conformance classes of this service{% endtrans %}</a>
9898
</p>
9999
</section>
100+
{% if data['tile'] %}
100101
<section id="tilematrixsets">
101102
<h2>{% trans %}Tile Matrix Sets{% endtrans %}</h2>
102103
<p>
103104
<a href="{{ config['server']['url'] }}/TileMatrixSets?f=html">{% trans %}View the Tile Matrix Sets available on this service{% endtrans %}</a>
104105
</p>
105106
</section>
107+
{% endif %}
106108
</div>
107109
<div class="col-md-4 col-sm-12">
108110
<div class="card mb-3">

0 commit comments

Comments
 (0)