Skip to content

Commit

Permalink
asserts
Browse files Browse the repository at this point in the history
  • Loading branch information
jdroenner committed Mar 6, 2024
1 parent ad0bca8 commit db4aaac
Showing 1 changed file with 5 additions and 13 deletions.
18 changes: 5 additions & 13 deletions geoengine/raster.py
Original file line number Diff line number Diff line change
Expand Up @@ -279,20 +279,15 @@ async def tile_stream_to_stack_stream(raster_stream: AsyncIterator[RasterTile2D]

else:
# check things that should be the same for all tiles
if tile.shape != store[0].shape:
raise ValueError('Tile shapes do not match')
assert tile.shape == store[0].shape, 'Tile shapes do not match'
# TODO: geo transform should be the same for all tiles
# tiles should have a tile position or global pixel position

# if tile.geo_transform != store[0].geo_transform:
# raise ValueError('Tile geo_transforms do not match')
if tile.crs != store[0].crs:
raise ValueError('Tile crs do not match')
# assert tile.geo_transform == store[0].geo_transform, 'Tile geo_transforms do not match'
assert tile.crs == store[0].crs, 'Tile crs do not match'

if tile.band == first_band:
if tile.time.start < store[0].time.start:
# TODO: separate check for new tiles and new time intervals
raise ValueError('Tile time intervals must be equal or increasing')
assert tile.time.start >= store[0].time.start, 'Tile time intervals must be equal or increasing'

stack = [tile.data for tile in store]
tile_shape = store[0].shape
Expand All @@ -305,10 +300,7 @@ async def tile_stream_to_stack_stream(raster_stream: AsyncIterator[RasterTile2D]
yield RasterTileStack2D(tile_shape, stack, geo_transforms, crs, time, bands)

else:
if tile.time != store[0].time:
raise ValueError(
'Tile time intervals do not match. Expected: ' + str(store[0].time) + ', got: ' + str(tile.time)
)
assert tile.time == store[0].time, 'Time missmatch. ' + str(store[0].time) + ' != ' + str(tile.time)
store.append(tile)

if len(store) > 0:
Expand Down

0 comments on commit db4aaac

Please sign in to comment.