Skip to content

Commit

Permalink
[Backport to 3.3.x][Fixes #8920] The thumbnail of a UTM proj dataset …
Browse files Browse the repository at this point in the history
…is not correctly generated (#8931)
  • Loading branch information
Alessio Fabiani authored Mar 14, 2022
1 parent 3aa0377 commit 166f598
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 12 deletions.
7 changes: 4 additions & 3 deletions geonode/base/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -1201,8 +1201,9 @@ def ll_bbox(self):
"""BBOX is in the format [x0, x1, y0, y1, "EPSG:srid"]. Provides backwards
compatibility after transition to polygons."""
if self.ll_bbox_polygon:
bbox = BBOXHelper(self.ll_bbox_polygon.extent)
return [bbox.xmin, bbox.xmax, bbox.ymin, bbox.ymax, "EPSG:4326"]
_bbox = self.ll_bbox_polygon.extent
srid = self.ll_bbox_polygon.srid
return [_bbox[0], _bbox[2], _bbox[1], _bbox[3], f"EPSG:{srid}"]
bbox = BBOXHelper.from_xy([-180, 180, -90, 90])
return [bbox.xmin, bbox.xmax, bbox.ymin, bbox.ymax, "EPSG:4326"]

Expand Down Expand Up @@ -1472,7 +1473,7 @@ def deg_len():
bbox_y0 = lat - distance_y_degrees
bbox_y1 = lat + distance_y_degrees
self.srid = 'EPSG:4326'
self.set_bbox_polygon((bbox_x0, bbox_x1, bbox_y0, bbox_y1), self.srid)
self.set_bbox_polygon((bbox_x0, bbox_y0, bbox_x1, bbox_y1), self.srid)

def set_bounds_from_bbox(self, bbox, srid):
"""
Expand Down
Binary file added geonode/thumbs/tests/data/WY_USNG.zip
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
19 changes: 10 additions & 9 deletions geonode/thumbs/thumbnails.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,17 +106,14 @@ def create_thumbnail(
target_crs = forced_crs.upper() if forced_crs is not None else "EPSG:3857"

compute_bbox_from_layers = False
is_map_with_datasets = True
is_map_with_datasets = False

if isinstance(instance, Map):
is_map_with_datasets = MapLayer.objects.filter(map=instance, visibility=True, local=True).exclude(ows_url__isnull=True).exclude(ows_url__exact='').count() > 0
if bbox:
bbox = utils.clean_bbox(bbox, target_crs)
elif instance.ll_bbox_polygon:
_bbox = instance.ll_bbox_polygon.extent
srid = instance.ll_bbox_polygon.srid
bbox = [_bbox[0], _bbox[1], _bbox[2], _bbox[3], f"EPSG:{srid}"]
bbox = utils.clean_bbox(bbox, target_crs)
bbox = utils.clean_bbox(instance.ll_bbox, target_crs)
else:
compute_bbox_from_layers = True

Expand Down Expand Up @@ -270,12 +267,14 @@ def _layers_locations(
else:
locations.append([instance.remote_service.service_url, [instance.alternate], []])
if compute_bbox:
# handle exceeding the area of use of the default thumb's CRS
if (
if instance.ll_bbox_polygon:
bbox = utils.clean_bbox(instance.ll_bbox, target_crs)
elif (
instance.bbox[-1].upper() != 'EPSG:3857'
and target_crs.upper() == 'EPSG:3857'
and utils.exceeds_epsg3857_area_of_use(instance.bbox)
):
# handle exceeding the area of use of the default thumb's CRS
bbox = utils.transform_bbox(utils.crop_to_3857_area_of_use(instance.bbox), target_crs)
else:
bbox = utils.transform_bbox(instance.bbox, target_crs)
Expand Down Expand Up @@ -348,12 +347,14 @@ def _layers_locations(
])

if compute_bbox:
# handle exceeding the area of use of the default thumb's CRS
if (
if layer.ll_bbox_polygon:
layer_bbox = utils.clean_bbox(layer.ll_bbox, target_crs)
elif (
layer.bbox[-1].upper() != 'EPSG:3857'
and target_crs.upper() == 'EPSG:3857'
and utils.exceeds_epsg3857_area_of_use(layer.bbox)
):
# handle exceeding the area of use of the default thumb's CRS
layer_bbox = utils.transform_bbox(utils.crop_to_3857_area_of_use(layer.bbox), target_crs)
else:
layer_bbox = utils.transform_bbox(layer.bbox, target_crs)
Expand Down

0 comments on commit 166f598

Please sign in to comment.