Skip to content

Commit

Permalink
Revert "Revert"
Browse files Browse the repository at this point in the history
This reverts commit ba627d5.
  • Loading branch information
jterry64 committed Sep 19, 2023
1 parent 41128fd commit a9b0b3a
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 9 deletions.
2 changes: 1 addition & 1 deletion lambdas/raster_analysis/src/lambda_function.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def handler(event, context):

if not geom_tile.geom:
LOGGER.info(f"Geometry for tile {context.aws_request_id} is empty.")
results_store.save_result({}, context.aws_request_id)
results_store.save_result(DataFrame(), context.aws_request_id)
return {}

data_environment = DataEnvironment(layers=event["environment"])
Expand Down
3 changes: 0 additions & 3 deletions raster_analysis/geometry.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,6 @@ def __init__(
f"Could not create valid tile from geom {full_geom.wkt} and tile {tile.wkt}"
)

if geom_tile.is_empty:
self.geom = {}

self.geom = geom_tile


Expand Down
12 changes: 7 additions & 5 deletions raster_analysis/tiling.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,16 +124,18 @@ def _postprocess_results(self, results):
return results

def _execute_tiles(self) -> DataFrame:
tiles = self._get_tiles(self.grid.tile_degrees)
payload: Dict[str, Any] = {
"query": self.raw_query,
"environment": self.data_environment.dict(),
}

if sys.getsizeof(json.dumps(self.raw_geom)) > LAMBDA_ASYNC_PAYLOAD_LIMIT_BYTES:
payload["encoded_geometry"] = encode_geometry(self.geom)
else:
payload["geometry"] = self.raw_geom
payload["geometry"] = self.raw_geom
if sys.getsizeof(json.dumps(payload)) > LAMBDA_ASYNC_PAYLOAD_LIMIT_BYTES:
# if payload would be too big, compress geometry
geom = shape(payload.pop("geometry"))
payload["encoded_geometry"] = encode_geometry(geom)

tiles = self._get_tiles(self.grid.tile_degrees)

results_store = AnalysisResultsStore()
tile_keys = [
Expand Down

0 comments on commit a9b0b3a

Please sign in to comment.