File tree 1 file changed +39
-0
lines changed
1 file changed +39
-0
lines changed Original file line number Diff line number Diff line change
1
+ import json
2
+
3
+
4
+ def stac_to_sns (stac_item ):
5
+ """Convert a STAC item to SNS message (with attributes)"""
6
+
7
+ try :
8
+ collection = stac_item ['collection' ]
9
+ except KeyError :
10
+ collection = stac_item ['properties' ]['collection' ]
11
+
12
+ attributes = {
13
+ 'bbox.xmin' : {
14
+ "DataType" : "Number" ,
15
+ "StringValue" : str (stac_item ['bbox' ][0 ])
16
+ },
17
+ 'bbox.ymin' : {
18
+ "DataType" : "Number" ,
19
+ "StringValue" : str (stac_item ['bbox' ][1 ])
20
+ },
21
+ 'bbox.xmax' : {
22
+ "DataType" : "Number" ,
23
+ "StringValue" : str (stac_item ['bbox' ][2 ])
24
+ },
25
+ 'bbox.ymax' : {
26
+ "DataType" : "Number" ,
27
+ "StringValue" : str (stac_item ['bbox' ][3 ])
28
+ },
29
+ 'collection' : {
30
+ "DataType" : "String" ,
31
+ "StringValue" : collection
32
+ },
33
+ }
34
+
35
+ return {
36
+ "Message" : json .dumps (stac_item ),
37
+ "MessageAttributes" : attributes
38
+ }
39
+
You can’t perform that action at this time.
0 commit comments