Skip to content

fix: index to ES is not setting bbox correctly #475

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Dec 9, 2024
4 changes: 3 additions & 1 deletion cumulus_lambda_functions/granules_to_es/granules_indexer.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def __get_potential_files(self):
potential_files = []
self.__input_file_list = self.__cumulus_record['files']
for each_file in self.__input_file_list:
if 'type' in each_file and each_file['type'].strip().lower() != self.__valid_filetype_name:
if 'type' in each_file and self.__valid_filetype_name not in each_file['type'].strip().lower():
LOGGER.debug(f'Not metadata. skipping {each_file}')
continue
if 'fileName' not in each_file and 'name' in each_file: # add fileName if there is only name
Expand Down Expand Up @@ -93,6 +93,8 @@ def start(self):
else:
LOGGER.warning(f'unable to find STAC JSON file in {potential_files}')
stac_item = ItemTransformer().to_stac(self.__cumulus_record)
if stac_input_meta is not None and stac_input_meta.bbox is not None:
stac_item['bbox'] = stac_input_meta.bbox
if 'bbox' in stac_item:
stac_item['bbox'] = GranulesDbIndex.to_es_bbox(stac_item['bbox'])
collection_identifier = UdsCollections.decode_identifier(self.__cumulus_record['collectionId'])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,20 @@ def __init__(self, input_stac_dict: dict):
self.__prod_dt = None
self.__insert_dt = None
self.__custom_properties = {}
self.__bbox = None

@property
def bbox(self):
return self.__bbox

@bbox.setter
def bbox(self, val):
"""
:param val:
:return: None
"""
self.__bbox = val
return

@property
def custom_properties(self):
Expand Down Expand Up @@ -132,6 +146,7 @@ def start(self) -> GranuleMetadataProps:
stac_item: Item = ItemTransformer().from_stac(self.__input_stac_dict)
self.__custom_properties = deepcopy(stac_item.properties)
self.__remove_default_keys_in_custom_props()
self.__bbox = stac_item.bbox
# self.__custom_properties['collection_id'] = stac_item.collection_id # TODO version is included
# collection_led_granule_id = stac_item.id if stac_item.id.startswith(stac_item.collection_id) else f'{stac_item.collection_id}:{stac_item.id}'
# self.__custom_properties['granule_id'] = collection_led_granule_id # This needs to be start with collection_id to be consistent with cumulus granule_id which starts with collection
Expand Down
Loading
Loading