Skip to content

Commit

Permalink
maps: conditionally display map & warning messages
Browse files Browse the repository at this point in the history
  • Loading branch information
codemacabre committed Nov 10, 2022
1 parent b249d47 commit 116e6ca
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
4 changes: 4 additions & 0 deletions cove_ofds/process.py
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,10 @@ def get_context(self):
context["download_geojson_spans_size"] = os.stat(
self.spans_file_name
).st_size
with open(self.meta_file_name) as fp:
data = json.load(fp)
context["any_nodes_with_geometry"] = data["any_nodes_with_geometry"]
context["any_spans_with_geometry"] = data["any_spans_with_geometry"]
else:
context["can_download_geojson"] = False
# done!
Expand Down
16 changes: 10 additions & 6 deletions cove_ofds/templates/cove_ofds/explore.html
Original file line number Diff line number Diff line change
Expand Up @@ -268,21 +268,25 @@ <h4 class="panel-title">
</div>

<div class="row">
<div class="panel {% if can_download_geojson%}panel-success{% else %}panel-danger{% endif %}">
<div class="panel {% if any_nodes_with_geometry == false and any_spans_with_geometry == false %}panel-warning{% elif can_download_geojson %}panel-success{% else %}panel-danger{% endif %}">
<div id="visualisation-panel" class="panel-heading pointer" role="region" aria-expanded="true"
aria-controls="validationTable" data-toggle="collapse" data-target="#mapVisualisation">
<h4 class="panel-title">
<span class="glyphicon glyphicon-collapse-up"></span>{% trans 'Visualisation' %}
</h4>
</div>
<div id="mapVisualisation" class="collapse in panel-body">
{% if can_download_geojson %}
<p>{% trans 'The GeoJSON version of your data is visualised on the map below. You should check that nodes and spans appear in the correct location. If not, you may need to ' %}<a href="https://open-fibre-data-standard.readthedocs.io/en/0.1-dev/guidance/publication.html#how-to-transform-coordinates-to-the-correct-coordinate-reference-system">{% trans 'transform your coordinates to the correct coordinate reference system' %}</a>.</p>
<div id="map" class="map" style="width: 100%; height: 600px;"></div>
{% else %}
{% if any_nodes_with_geometry == false and any_spans_with_geometry == false %}
<div>
<p>{% trans 'Your data cannot be visualised on a map because it does not contain coordinates. If you expected your data to include coordinates, you should check your mapping and data pipeline for errors. For more information, see ' %}<a href="https://open-fibre-data-standard.readthedocs.io/en/0.1-dev/reference/schema.html#geometry">{% trans 'Geometry' %}</a>.</p>
</div>
{% elif can_download_geojson == false %}
<div>
<p>{% trans 'Your data cannot be visualised because it is not available in GeoJSON format. For more information, see ' %}<a href="#download-panel">{% trans 'data conversion' %}</a>.</p>
</div>
{% else %}
<p>{% trans 'The GeoJSON version of your data is visualised on the map below. You should check that nodes and spans appear in the correct location. If not, you may need to ' %}<a href="https://open-fibre-data-standard.readthedocs.io/en/0.1-dev/guidance/publication.html#how-to-transform-coordinates-to-the-correct-coordinate-reference-system">{% trans 'transform your coordinates to the correct coordinate reference system' %}</a>.</p>
<div id="map" class="map" style="width: 100%; height: 600px;"></div>
{% endif %}
</div>
</div>
Expand All @@ -292,7 +296,7 @@ <h4 class="panel-title">

{% block extrafooterscript %}
{{ block.super }}
{% if can_download_geojson %}
{% if can_download_geojson or any_spans_with_geometry or any_nodes_with_geometry %}
<script>
var map = L.map('map').setView([9.072973, 7.481621], 6);
L.tileLayer('https://tile.openstreetmap.org/{z}/{x}/{y}.png', {
Expand Down

0 comments on commit 116e6ca

Please sign in to comment.