Skip to content

Instantly share code, notes, and snippets.

@lambdaupb
Created January 22, 2017 13:00
Show Gist options
  • Select an option

  • Save lambdaupb/21bfa917292d45c9b4fef4964799b3d4 to your computer and use it in GitHub Desktop.

Select an option

Save lambdaupb/21bfa917292d45c9b4fef4964799b3d4 to your computer and use it in GitHub Desktop.
read gps_track.dat from recent track feature of MapsWithMe app
from collections import namedtuple
import struct
import sys
from enum import Enum
class PointSource(Enum):
EAppleNative=0
EWindowsNative=1
EAndroidNative=2
EGoogle=3
ETizen=4
EPredictor=5
Point = namedtuple("Point", "timestamp latitude longitude altitude speed bearing horizontalAccuracy verticalAccuracy source")
PointPattern = '<ddddddddB'
PointPackSize = struct.calcsize(PointPattern)
HeaderSize = 4
with open(sys.argv[1], 'rb') as f:
data_input = f.read()
print("PointPackSize",PointPackSize)
raw_points = data_input[HeaderSize:HeaderSize+PointPackSize*((len(data_input)-4)//PointPackSize)]
print("data len: ", len(data_input), len(data_input)%PointPackSize)
for rawPoint in struct.iter_unpack(PointPattern, raw_points):
point = Point(*rawPoint[:-1], PointSource(rawPoint[-1]))
print(point)
@bjmc
Copy link

bjmc commented May 24, 2017

Hi, would you mind if I adapted this to convert to a GPX file? Did you license it?

@lambdaupb
Copy link
Author

@bjmc Please feel free! Consider it MIT licensed.
Sorry for answering so late, I did not get a Notification.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment