From f59532afd14abd84dd84d0d0f5dc20947a7181c3 Mon Sep 17 00:00:00 2001 From: Aimee Barciauskas Date: Thu, 6 Jun 2024 22:57:09 -0700 Subject: [PATCH] Error message should match x, y, z arguments (#712) * Error message should match x, y, z arguments * Update xarray.py * lint * change other readers * update changelog --------- Co-authored-by: vincentsarago --- CHANGES.md | 4 ++++ rio_tiler/io/base.py | 4 ++-- rio_tiler/io/rasterio.py | 2 +- rio_tiler/io/xarray.py | 4 +++- 4 files changed, 10 insertions(+), 4 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 23327ecd..b27c12e2 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,3 +1,7 @@ +# unreleased + +* better error message for `TileOutsideBounds` errors (author @abarciauskas-bgse, https://github.com/cogeotiff/rio-tiler/pull/712) + # 6.6.1 (2024-05-17) * fix/support `scale/offset` indexes selection (author @jddeal, https://github.com/cogeotiff/rio-tiler/pull/709) diff --git a/rio_tiler/io/base.py b/rio_tiler/io/base.py index 07d11a04..94839c3d 100644 --- a/rio_tiler/io/base.py +++ b/rio_tiler/io/base.py @@ -480,7 +480,7 @@ def tile( """ if not self.tile_exists(tile_x, tile_y, tile_z): raise TileOutsideBounds( - f"Tile {tile_z}/{tile_x}/{tile_y} is outside image bounds" + f"Tile(x={tile_x}, y={tile_y}, z={tile_z}) is outside bounds" ) if isinstance(assets, str): @@ -1036,7 +1036,7 @@ def tile( """ if not self.tile_exists(tile_x, tile_y, tile_z): raise TileOutsideBounds( - f"Tile {tile_z}/{tile_x}/{tile_y} is outside image bounds" + f"Tile(x={tile_x}, y={tile_y}, z={tile_z}) is outside bounds" ) if isinstance(bands, str): diff --git a/rio_tiler/io/rasterio.py b/rio_tiler/io/rasterio.py index 066a4fce..6a397ae4 100644 --- a/rio_tiler/io/rasterio.py +++ b/rio_tiler/io/rasterio.py @@ -343,7 +343,7 @@ def tile( """ if not self.tile_exists(tile_x, tile_y, tile_z): raise TileOutsideBounds( - f"Tile {tile_z}/{tile_x}/{tile_y} is outside {self.input} bounds" + f"Tile(x={tile_x}, y={tile_y}, z={tile_z}) is outside bounds" ) tile_bounds = self.tms.xy_bounds(Tile(x=tile_x, y=tile_y, z=tile_z)) diff --git a/rio_tiler/io/xarray.py b/rio_tiler/io/xarray.py index fa6c9f3a..c4bb323b 100644 --- a/rio_tiler/io/xarray.py +++ b/rio_tiler/io/xarray.py @@ -232,7 +232,9 @@ def tile( reproject_method = resampling_method if not self.tile_exists(tile_x, tile_y, tile_z): - raise TileOutsideBounds(f"Tile {tile_z}/{tile_x}/{tile_y} is outside bounds") + raise TileOutsideBounds( + f"Tile(x={tile_x}, y={tile_y}, z={tile_z}) is outside bounds" + ) ds = self.input if nodata is not None: