diff --git a/cubedash/_utils.py b/cubedash/_utils.py index f21c759b3..5ceba6e8f 100644 --- a/cubedash/_utils.py +++ b/cubedash/_utils.py @@ -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 ############################### # diff --git a/cubedash/templates/dataset.html b/cubedash/templates/dataset.html index 7476b0bf3..628b264cb 100644 --- a/cubedash/templates/dataset.html +++ b/cubedash/templates/dataset.html @@ -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() }} @@ -225,10 +225,13 @@

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;