Skip to content

Instantly share code, notes, and snippets.

@cynddl
Created February 5, 2016 15:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cynddl/d09f9937c0f344e6c22e to your computer and use it in GitHub Desktop.
Save cynddl/d09f9937c0f344e6c22e to your computer and use it in GitHub Desktop.
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