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 d39e8cf
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 == False %}panel-danger{% else %}panel-success{% 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>
<p>{% trans 'Your data cannot be visualised on a map because there were errors loading it. You should check your mapping and data pipeline for errors.' %}</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 should check that your coordinates are in longitude, latitude order. 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 Down

0 comments on commit d39e8cf

Please sign in to comment.