Skip to content

Commit 38db0d5

Browse files
committed
feat(tools_qgis): handle zoom_to_layer errors
1 parent 0bb5ee7 commit 38db0d5

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

tools_qgis.py

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1544,12 +1544,17 @@ def zoom_to_layer(layer):
15441544

15451545
# Transform extent from layer CRS to canvas CRS if needed
15461546
if layer.crs() != iface.mapCanvas().mapSettings().destinationCrs():
1547-
transform = QgsCoordinateTransform(
1548-
layer.crs(),
1549-
iface.mapCanvas().mapSettings().destinationCrs(),
1550-
QgsProject.instance()
1551-
)
1552-
extent = transform.transformBoundingBox(extent)
1547+
try:
1548+
transform = QgsCoordinateTransform(
1549+
layer.crs(),
1550+
iface.mapCanvas().mapSettings().destinationCrs(),
1551+
QgsProject.instance()
1552+
)
1553+
extent = transform.transformBoundingBox(extent)
1554+
except Exception as e:
1555+
msg = f"Failed to transform coordinates for layer '{layer.name()}': {str(e)}"
1556+
show_warning(msg)
1557+
return
15531558

15541559
# Set canvas extent
15551560
iface.mapCanvas().setExtent(extent)

0 commit comments

Comments
 (0)