Skip to content

Commit

Permalink
prevent error from dataset missing crs
Browse files Browse the repository at this point in the history
  • Loading branch information
Ariana Barzinpour authored and Ariana-B committed Dec 6, 2022
1 parent 01775b2 commit e09884a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
4 changes: 3 additions & 1 deletion cubedash/_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -879,7 +879,9 @@ def dataset_shape(ds: Dataset) -> Tuple[Optional[Polygon], bool]:

def bbox_as_geom(dataset):
"""Get dataset bounds as to Geometry object projected to target CRS"""
return geometry.box(**dataset.bounds, crs=dataset.crs).to_crs(CRS(_TARGET_CRS))
if dataset.crs is None:
return None
return geometry.box(*dataset.bounds, crs=dataset.crs).to_crs(CRS(_TARGET_CRS))


# ######################### WARNING ############################### #
Expand Down
13 changes: 8 additions & 5 deletions cubedash/templates/dataset.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

{% set extent_geojson = dataset_footprint.__geo_interface__ %}
{% set thumbnail_url = dataset | dataset_thumbnail_url %}
{% set image_bounds = dataset_bounds.__geo_interface__ %}
{% set image_bounds = dataset_bounds.__geo_interface__ if dataset_bounds is not none else 'NONE' %}

{% block head %}
{{ super() }}
Expand Down Expand Up @@ -225,10 +225,13 @@ <h3 class="followed">
L.control.zoom({position: "bottomright"}).addTo(map);
map.fitBounds(dataset_data.getBounds(), {animate: false, maxZoom: 6});
if ("{{ thumbnail_url }}") {
L.imageOverlay(
"{{ thumbnail_url }}",
L.geoJson({{ image_bounds | torapidjson }}).getBounds()
).addTo(map);
if ("{{ image_bounds }}" != "NONE") {
bounds = L.geoJson({{ image_bounds | torapidjson }}).getBounds();
} else {
// if no image bounds, go for the next best thing
bounds = dataset_data.getBounds();
}
L.imageOverlay("{{ thumbnail_url }}", bounds).addTo(map);
}

window.MAP = map;
Expand Down

0 comments on commit e09884a

Please sign in to comment.