Skip to content

Commit a47b6b1

Browse files
authored
fix: restructure bbox for geoshape (#498)
* 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
1 parent 8c4537f commit a47b6b1

File tree

2 files changed

+23
-5
lines changed

2 files changed

+23
-5
lines changed

cumulus_lambda_functions/lib/uds_db/granules_db_index.py

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,25 @@ def __init__(self):
3434

3535
@staticmethod
3636
def to_es_bbox(bbox_array):
37+
# lon = x, lat = y
38+
# lon, lat, lon, lat
39+
# x can be 170 to -170
40+
# 170, 0, -170, 10
41+
minX, minY, maxX, maxY = bbox_array
42+
43+
# Ensure the values are properly sorted
44+
# if minX > maxX:
45+
# minX, maxX = maxX, minX
46+
if minY > maxY:
47+
minY, maxY = maxY, minY
48+
3749
return {
3850
"type": "envelope",
39-
"coordinates": [
40-
[bbox_array[0], bbox_array[3]], # Top-left corner (minLon, maxLat)
41-
[bbox_array[2], bbox_array[1]] # Bottom-right corner (maxLon, minLat)
42-
]
51+
"coordinates": [[minX, maxY], [maxX, minY]],
52+
# "coordinates": [
53+
# [bbox_array[0], bbox_array[3]], # Top-left corner (minLon, maxLat)
54+
# [bbox_array[2], bbox_array[1]] # Bottom-right corner (maxLon, minLat)
55+
# ]
4356
}
4457

4558
@staticmethod
@@ -265,3 +278,6 @@ def dsl_search(self, tenant: str, tenant_venue: str, search_dsl: dict):
265278
'hits': result
266279
}
267280
}
281+
282+
283+

tests/integration_tests/test_stage_out_ingestion.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,8 @@ def test_03_upload_complete_catalog_role_as_key(self):
232232
"type": "Point",
233233
"coordinates": [0.0, 0.0]
234234
},
235-
bbox=[0.0, 0.0, 0.1, 0.1],
235+
# bbox=[0.0, 0.0, 0.1, 0.1],
236+
bbox=[170, 25, -170, 10], # Testing invalid geo-shape
236237
datetime=TimeUtils().parse_from_unix(0, True).get_datetime_obj(),
237238
properties={
238239
"start_datetime": "2016-01-31T18:00:00.009057Z",
@@ -336,4 +337,5 @@ def test_single_granule_get(self):
336337
response_json = json.loads(query_result.text)
337338
print(json.dumps(response_json, indent=4))
338339
self.assertEqual(query_result.status_code, 200, f'wrong status code. {query_result.text}')
340+
self.assertEqual(response_json['bbox'], [170, 10, -170, 25], 'wrong bbox')
339341
return

0 commit comments

Comments
 (0)