-
Notifications
You must be signed in to change notification settings - Fork 1
/
arc_data_to_geojson.sh
executable file
·60 lines (59 loc) · 1.68 KB
/
arc_data_to_geojson.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#!/bin/sh
#
#
# Take arc data downloaded from export site and translate it into geojson:
#
# {
# "entry_date" : ISODate("2018-07-20T18:51:04Z"),
# "loc" :
# {
# "type" : "Point",
# "coordinates" : [ -73.98762, 40.757194 ]
# },
# "entry_source" : "Moves API"
# }
#
# Arc data looks like:
# [
# {
# "967C0432-5B4E-4307-A69F-18580FFFE234": {
# "recordName": "967C0432-5B4E-4307-A69F-18580FFFE234",
# "recordType": "HistoryItem",
# "fields": {
# ...
# "location": {
# "value": {
# "latitude": 40.68526224086859,
# "longitude": -73.97182662706706,
# "horizontalAccuracy": 0,
# "altitude": 0,
# "verticalAccuracy": -1,
# "speed": -1,
# "course": -1,
# "timestamp": 1532281260623
# },
# "type": "LOCATION"
# },
# },
# "activityRecords": [
# [
# "783A4F5D-3438-46F6-9F1E-AF66632334B9",
# {
# "recordName": "783A4F5D-3438-46F6-9F1E-AF66632334B9",
# "recordType": "ActivityEvent",
# "fields": {
# ...
# "location": {
# "value": {
# "latitude": 40.68526224086859,
# "longitude": -73.97182662706706,
# "horizontalAccuracy": 0,
# "altitude": 0,
# ...
# ...
# },
# ... repeat
# ]
set -o errexit
set -o nounset
cat | jq '..|.location? | select(.value) | .value | { entry_date: { "$date": (.timestamp /1000 | gmtime | todate)} , loc: { type: "Point", coordinates: [ .longitude, .latitude ] }, entry_source: "Arc App"} '