Skip to content

Commit

Permalink
[Fixes #12651] Wrong extent calculated for empty maps (#12652) (#12653)
Browse files Browse the repository at this point in the history
* [Fixes #12651] Wrong extent calculated for empty maps
* use iterator to iterate map layers

(cherry picked from commit e54b42c)

Co-authored-by: Giovanni Allegri <[email protected]>
  • Loading branch information
github-actions[bot] and giohappy authored Oct 15, 2024
1 parent d66464c commit 84b0207
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 27 deletions.
13 changes: 4 additions & 9 deletions geonode/maps/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,8 @@ def compute_bbox(self, target_crs="EPSG:3857"):
bbox of all the datasets
"""
epsg_bbox = bbox_utils.epsg_3857_area_of_use(target_crs="EPSG:3857")
bbox = [math.inf, -math.inf, math.inf, -math.inf]

bbox = [math.inf, -math.inf, math.inf, -math.inf]
for layer in self.maplayers.filter(visibility=True).order_by("order").iterator():
dataset = layer.dataset
if dataset is not None:
Expand All @@ -156,14 +156,9 @@ def compute_bbox(self, target_crs="EPSG:3857"):
max(bbox[3], dataset_bbox[3]),
]

if bbox[0] < epsg_bbox[0]:
bbox[0] = epsg_bbox[0]
if bbox[1] > epsg_bbox[1]:
bbox[1] = epsg_bbox[1]
if bbox[2] < epsg_bbox[2]:
bbox[2] = epsg_bbox[2]
if bbox[3] > epsg_bbox[3]:
bbox[3] = epsg_bbox[3]
# if the starting bbox is not mutated it means no bbox has been computed from layers
if bbox[0] == math.inf:
bbox = epsg_bbox

self.set_bbox_polygon([bbox[0], bbox[2], bbox[1], bbox[3]], target_crs)
return bbox
Expand Down
18 changes: 0 additions & 18 deletions geonode/maps/utils/__init__.py

This file was deleted.

0 comments on commit 84b0207

Please sign in to comment.