Skip to content

Commit

Permalink
adding utils
Browse files Browse the repository at this point in the history
  • Loading branch information
geospatial-jeff committed Jun 19, 2019
1 parent b858d61 commit d919208
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions stac_updater/utils.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import json


def stac_to_sns(stac_item):
"""Convert a STAC item to SNS message (with attributes)"""

try:
collection = stac_item['collection']
except KeyError:
collection = stac_item['properties']['collection']

attributes = {
'bbox.xmin': {
"DataType": "Number",
"StringValue": str(stac_item['bbox'][0])
},
'bbox.ymin': {
"DataType": "Number",
"StringValue": str(stac_item['bbox'][1])
},
'bbox.xmax': {
"DataType": "Number",
"StringValue": str(stac_item['bbox'][2])
},
'bbox.ymax': {
"DataType": "Number",
"StringValue": str(stac_item['bbox'][3])
},
'collection': {
"DataType": "String",
"StringValue": collection
},
}

return {
"Message": json.dumps(stac_item),
"MessageAttributes": attributes
}

0 comments on commit d919208

Please sign in to comment.