Skip to content

Commit

Permalink
[Fixes #9363] Split thumbnail creation method (#9368)
Browse files Browse the repository at this point in the history
* split thumbnail create method

* [Fixes #9363] Split thumbnail creation method

* [Fixes #9363] Fix flake8 issues

Co-authored-by: giohappy <[email protected]>
  • Loading branch information
mattiagiupponi and giohappy authored May 16, 2022
1 parent 0aa6b19 commit 9505d24
Showing 1 changed file with 19 additions and 3 deletions.
22 changes: 19 additions & 3 deletions geonode/thumbs/thumbnails.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,6 @@ def create_thumbnail(
instance.refresh_from_db()

default_thumbnail_name = _generate_thumbnail_name(instance)
mime_type = "image/png"
width = settings.THUMBNAIL_SIZE["width"]
height = settings.THUMBNAIL_SIZE["height"]

if default_thumbnail_name is None:
# instance is Map and has no layers defined
Expand Down Expand Up @@ -119,6 +116,25 @@ def create_thumbnail(
# --- define layer locations ---
locations, layers_bbox = _layers_locations(instance, compute_bbox=compute_bbox_from_layers, target_crs=target_crs)

return create_thumbnail_from_locations(instance, locations, layers_bbox, default_thumbnail_name, compute_bbox_from_layers, is_map_with_datasets, bbox, wms_version, styles, background_zoom)


def create_thumbnail_from_locations(
instance,
locations,
layers_bbox,
default_thumbnail_name,
compute_bbox_from_layers,
is_map_with_datasets,
bbox,
wms_version=settings.OGC_SERVER["default"].get("WMS_VERSION", "1.1.1"),
styles=None,
background_zoom=None
):

mime_type = "image/png"
width = settings.THUMBNAIL_SIZE["width"]
height = settings.THUMBNAIL_SIZE["height"]
if compute_bbox_from_layers and is_map_with_datasets:
if not layers_bbox:
raise ThumbnailError(f"Thumbnail generation couldn't determine a BBOX for: {instance}.")
Expand Down

0 comments on commit 9505d24

Please sign in to comment.