Skip to content

Instantly share code, notes, and snippets.

@rossdrew
Last active March 12, 2024 11:41
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 rossdrew/510bcfe76aacd30a700216a02bee25eb to your computer and use it in GitHub Desktop.
Save rossdrew/510bcfe76aacd30a700216a02bee25eb to your computer and use it in GitHub Desktop.
iSki GPX Generator
import json
import datetime
import sys
'''
Steps to generate GPX file from iSki
This wont be exact in terms of timings as I have fudged the time format as I don't understand it.
Get the data...
1. Log in to iSki
2. Navigate to "Tracks"
3. Pick a track you want to export and click "Share" on it
4. Right click & inspect the HTML of that page
5. Copy out the URL at the bottom which is in a var specs object under "items"
6. Put that URL in a browser and copy or save the contents
Convert the data...
1. Save this script
2. Edit script. Set the data file name, GPX title, and timestamp date
3. run 'python gpx-file-from-iSki.py <your_data_file_name.json>'
You should have a new file output.gpx
'''
path_file_name = sys.argv[1]
output_file_name = "output.gpx"
print(f"Extracting path date from '{path_file_name}'...")
path_file = open(path_file_name, "r")
path_data = json.load(path_file)
gpx_file = open(output_file_name, "w")
gpx_title = "ENTER GPS TITLE"
# The date the GPX data will show as recorded
gpx_record_year = 2013
gpx_record_month = 3
gpx_record_day = 21
gpx_file.write("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n")
gpx_file.write("<gpx version=\"1.0\">\n")
gpx_file.write(f"\t<trk>\n\t\t<name>{gpx_title}</name>\n\t\t<number>1</number>\n\t\t<trkseg>\n")
point_count = 0
for entry in path_data['path']:
#lat, ng, time, elecation
lat = entry['lat']
lng = entry['lng']
elev = entry['elevation']
#XXX No idea what the time format is, I messed with this number till it looked right
timestamp = datetime.datetime.utcfromtimestamp(entry['time'] / 1057)
#XXX No date information in extracted data so I'm just hard coding it in per extraction
timestamp = timestamp.replace(year=gpx_record_year, month=gpx_record_month, day=gpx_record_day)
time = timestamp.strftime("%Y-%m-%dT%H:%M:%S%Z")
gpx_file.write(f"\t\t\t<trkpt lat=\"{lat}\" lon=\"{lng}\"><ele>{elev}</ele><time>{time}</time></trkpt>\n")
point_count += 1
gpx_file.write("\t\t</trkseg>\n\t</trk>\n")
gpx_file.write("</gpx>")
print(f"...GPX data ({point_count} points) generated to '{output_file_name}'")
path_file.close()
gpx_file.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment