Skip to content

Commit

Permalink
Merge pull request #269 from Living-with-machines/dev_download
Browse files Browse the repository at this point in the history
Check both upper and lower corners when finding tilesize
  • Loading branch information
rwood-97 authored Oct 12, 2023
2 parents 690172a + e852818 commit 8f15ae5
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions mapreader/download/tile_merging.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,16 @@ def _load_tile_size(self, grid_bb: GridBoundingBox):
tuple
Size of tile
"""
start_image = self._load_image_to_grid_cell(grid_bb.lower_corner)
try:
start_image = self._load_image_to_grid_cell(grid_bb.lower_corner)
except FileNotFoundError:
logger.warning("Image has missing tiles in bottom left corner.")
try:
start_image = self._load_image_to_grid_cell(grid_bb.upper_corner)
except FileNotFoundError as err:
logger.warning("Image has missing tiles in upper right corner.")
raise FileNotFoundError("[ERROR] Image is missing tiles for both lower left and upper right corners.")

img_size = start_image.size
assert (
img_size[0] == img_size[1]
Expand Down Expand Up @@ -169,7 +178,7 @@ def merge(self, grid_bb: GridBoundingBox, file_name: Union[str, None] = None) ->
try:
current_tile = Image.open(self._generate_tile_name(current_cell))
merged_image.paste(current_tile, (tile_size * i, tile_size * j))
except:
except FileNotFoundError:
logger.info(f"Cannot find tile with grid_index = {current_cell}")

logger.info("Writing file..")
Expand Down

0 comments on commit 8f15ae5

Please sign in to comment.