Skip to content

Commit

Permalink
fix: restructure bbox for geoshape (#498)
Browse files Browse the repository at this point in the history
* breaking: using latest uds-lib + update docker

* feat: use latest uds-lib

* fix: restructure bbox for geoshape

* fix: update how to validate bbox

* chore: update test case
  • Loading branch information
wphyojpl authored Jan 17, 2025
1 parent 8c4537f commit a47b6b1
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 5 deletions.
24 changes: 20 additions & 4 deletions cumulus_lambda_functions/lib/uds_db/granules_db_index.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,25 @@ def __init__(self):

@staticmethod
def to_es_bbox(bbox_array):
# lon = x, lat = y
# lon, lat, lon, lat
# x can be 170 to -170
# 170, 0, -170, 10
minX, minY, maxX, maxY = bbox_array

# Ensure the values are properly sorted
# if minX > maxX:
# minX, maxX = maxX, minX
if minY > maxY:
minY, maxY = maxY, minY

return {
"type": "envelope",
"coordinates": [
[bbox_array[0], bbox_array[3]], # Top-left corner (minLon, maxLat)
[bbox_array[2], bbox_array[1]] # Bottom-right corner (maxLon, minLat)
]
"coordinates": [[minX, maxY], [maxX, minY]],
# "coordinates": [
# [bbox_array[0], bbox_array[3]], # Top-left corner (minLon, maxLat)
# [bbox_array[2], bbox_array[1]] # Bottom-right corner (maxLon, minLat)
# ]
}

@staticmethod
Expand Down Expand Up @@ -265,3 +278,6 @@ def dsl_search(self, tenant: str, tenant_venue: str, search_dsl: dict):
'hits': result
}
}



4 changes: 3 additions & 1 deletion tests/integration_tests/test_stage_out_ingestion.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,8 @@ def test_03_upload_complete_catalog_role_as_key(self):
"type": "Point",
"coordinates": [0.0, 0.0]
},
bbox=[0.0, 0.0, 0.1, 0.1],
# bbox=[0.0, 0.0, 0.1, 0.1],
bbox=[170, 25, -170, 10], # Testing invalid geo-shape
datetime=TimeUtils().parse_from_unix(0, True).get_datetime_obj(),
properties={
"start_datetime": "2016-01-31T18:00:00.009057Z",
Expand Down Expand Up @@ -336,4 +337,5 @@ def test_single_granule_get(self):
response_json = json.loads(query_result.text)
print(json.dumps(response_json, indent=4))
self.assertEqual(query_result.status_code, 200, f'wrong status code. {query_result.text}')
self.assertEqual(response_json['bbox'], [170, 10, -170, 25], 'wrong bbox')
return

0 comments on commit a47b6b1

Please sign in to comment.