-
Notifications
You must be signed in to change notification settings - Fork 0
/
ipad_gps_store.py
31 lines (23 loc) · 1.04 KB
/
ipad_gps_store.py
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
import xml.etree.ElementTree as ET
import datetime as dt
from pymongo import MongoClient
import lib.analyze_util as au
import time
import pytz
gpxFile = raw_input("GPX File Name: ")
tree = ET.parse(gpxFile)
root = tree.getroot()
mongo = MongoClient(host=au.serverAddressSelector())
dbCol = au.dbColSelector(mongo)
ns = {'gpx': 'http://www.topografix.com/GPX/1/1'}
track = root.find("gpx:trk",ns).find("gpx:trkseg",ns)
for trkpt in track.findall('gpx:trkpt',ns):
data = trkpt.attrib
data["ele"] = float(trkpt.find("gpx:ele",ns).text)
timeData = dt.datetime.strptime(trkpt.find("gpx:time",ns).text, "%Y-%m-%dT%H:%M:%S.%fZ")
timeData = pytz.utc.localize(timeData).astimezone(pytz.timezone('US/Eastern'))
timeDataEpoch = time.mktime(timeData.timetuple())
timeDataHuman = timeData.strftime("%Y-%m-%dT%H:%M.%S")
dbCol.insert({"atype": "GPS", "vertype": 1.1, "itype": "ipad"
, "ts": timeDataEpoch, "hts": timeDataHuman, "param": data
, "comments": ["iPad GPS"], "tags": ["iPad", "gps"]})