diff --git a/hazard_workflow.cwl b/hazard_workflow.cwl index 279a9c5..5e892bc 100644 --- a/hazard_workflow.cwl +++ b/hazard_workflow.cwl @@ -92,7 +92,7 @@ $graph: hints: DockerRequirement: - dockerPull: public.ecr.aws/c9k5s3u3/os-hazard-indicator:cb86f35 + dockerPull: public.ecr.aws/c9k5s3u3/os-hazard-indicator:ed6f5d1 requirements: ResourceRequirement: diff --git a/src/hazard/inventory.py b/src/hazard/inventory.py index 577012d..729aa00 100644 --- a/src/hazard/inventory.py +++ b/src/hazard/inventory.py @@ -1,11 +1,14 @@ import datetime import itertools import json +from copy import deepcopy from typing import Any, Dict, Iterable, List, Optional, Sequence, Tuple, Union import pystac +import shapely from pydantic import BaseModel, Field + # region HazardModel @@ -186,7 +189,12 @@ def to_stac_item( rel="collection", media_type="application/json", target="./collection.json" ) - coordinates = self.map.bounds if self.map else None + coordinates = deepcopy(self.map.bounds) if self.map else None + + # GeoJSON requires the coordinates of a LineRing to have the same beginning and end + if coordinates: + coordinates.append(coordinates[0]) + bbox = self.map.bbox if self.map else None stac_item = pystac.Item( id=item_id, @@ -204,6 +212,12 @@ def to_stac_item( stac_item.validate() + is_valid_response = shapely.is_valid_reason( + shapely.from_geojson(json.dumps(stac_item.to_dict())) + ) + if is_valid_response != "Valid Geometry": + raise Exception(f"STAC Item is not valid: {is_valid_response}") + templated_out_item = self._expand_template_values_for_stac_record( combined_parameters, stac_item )