Skip to content

Commit e54b42c

Browse files
authored
[Fixes #12651] Wrong extent calculated for empty maps (#12652)
* [Fixes #12651] Wrong extent calculated for empty maps * use iterator to iterate map layers
1 parent 677c578 commit e54b42c

File tree

2 files changed

+4
-27
lines changed

2 files changed

+4
-27
lines changed

geonode/maps/models.py

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -135,8 +135,8 @@ def compute_bbox(self, target_crs="EPSG:3857"):
135135
bbox of all the datasets
136136
"""
137137
epsg_bbox = bbox_utils.epsg_3857_area_of_use(target_crs="EPSG:3857")
138-
bbox = [math.inf, -math.inf, math.inf, -math.inf]
139138

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

159-
if bbox[0] < epsg_bbox[0]:
160-
bbox[0] = epsg_bbox[0]
161-
if bbox[1] > epsg_bbox[1]:
162-
bbox[1] = epsg_bbox[1]
163-
if bbox[2] < epsg_bbox[2]:
164-
bbox[2] = epsg_bbox[2]
165-
if bbox[3] > epsg_bbox[3]:
166-
bbox[3] = epsg_bbox[3]
159+
# if the starting bbox is not mutated it means no bbox has been computed from layers
160+
if bbox[0] == math.inf:
161+
bbox = epsg_bbox
167162

168163
self.set_bbox_polygon([bbox[0], bbox[2], bbox[1], bbox[3]], target_crs)
169164
return bbox

geonode/maps/utils/__init__.py

Lines changed: 0 additions & 18 deletions
This file was deleted.

0 commit comments

Comments
 (0)