Created
February 5, 2016 15:31
-
-
Save cynddl/d09f9937c0f344e6c22e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from __future__ import division | |
import bandicoot as bc | |
import datetime | |
import json | |
def load_google_gps(json_path, name='me'): | |
""" | |
Loads history from https://google.com/maps/timeline into | |
a bandicoot User object. | |
""" | |
with open(json_path) as f: | |
j = json.load(f) | |
def yield_record(): | |
for loc in j['locations']: | |
lat = loc['latitudeE7'] / 10000000 | |
lon = loc['longitudeE7'] / 10000000 | |
p = bc.core.Position(location=(lat, lon)) | |
d = datetime.datetime.fromtimestamp(float(loc['timestampMs']) / 1000) | |
yield bc.core.Record(position=p, datetime=d) | |
U, _ = bc.io.load(name, yield_record(), None, warnings=True) | |
return U |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment