-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Hua
committed
Mar 1, 2020
0 parents
commit 0975f9f
Showing
4 changed files
with
97 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# Adidas-Runtastic-Map-Convertor | ||
|
||
Map data exported from Adidas Runtastic is using Unix timestamp which is non-readable by human being. | ||
|
||
This script convert them into datetime so users can pick the correct data file for their own purposes. | ||
|
||
## Download the Map data | ||
|
||
1. login to your Runtastic account in your browser | ||
|
||
2. Click your profile icon on the top right corner and select `Settings` | ||
|
||
3. Switch to `Export` tab and click `Export` | ||
|
||
4. Wait and then download | ||
|
||
## Use this script | ||
|
||
1. extract `Sport-sessions/*.json` into `maps` folder in this project | ||
|
||
2. run `npm run dev` | ||
|
||
3. the result will save to `summary.json` of this project | ||
|
||
4. open `summary.json` and look for the date and filename | ||
|
||
5. find the gpx file in `GPS-data` folder | ||
|
||
6. enjoy |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
'use strict'; | ||
|
||
const fs = require('fs'); | ||
|
||
listFiles() | ||
.then(summary => { | ||
//console.log(summary); | ||
writeSummary(summary); | ||
}); | ||
|
||
function listFiles() { | ||
return new Promise((resolve, reject) => { | ||
let summary = []; | ||
fs.readdir('maps', (err, maps) => { | ||
let promises = maps.map(map => { | ||
return new Promise((resolve, reject) => { | ||
return readFile(`maps/${map}`) | ||
.then(mapObj => { | ||
console.log(`Processing ${map}`); | ||
let mapInfo = JSON.parse(mapObj.toString()); | ||
summary.push({ | ||
name: map, | ||
start_time: new Date(mapInfo.start_time), | ||
end_time: new Date(mapInfo.end_time) | ||
}); | ||
return resolve(summary); | ||
}, err => { | ||
return reject(err); | ||
}); | ||
}); | ||
}); | ||
Promise.all(promises) | ||
.then(() => { | ||
summary.sort((a, b) => { | ||
return (a.start_time > b.start_time ? 1 : -1); | ||
}) | ||
return resolve(summary); | ||
}); | ||
}); | ||
}); | ||
} | ||
|
||
function readFile(path) { | ||
return new Promise((resolve, reject) => { | ||
fs.readFile(path, (err, data) => { | ||
if (err) return reject(err); | ||
return resolve(data); | ||
}); | ||
}); | ||
} | ||
|
||
function writeSummary(summary, path) { | ||
fs.writeFile('summary.json', JSON.stringify(summary), err => { | ||
if (err) console.log(err); | ||
console.log('summary done'); | ||
}); | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"name": "adidas-runtastic-map-convertor", | ||
"version": "1.0.0", | ||
"description": "", | ||
"main": "app.js", | ||
"scripts": { | ||
"dev": "node app.js" | ||
}, | ||
"author": "Wahackr" | ||
} |
Oops, something went wrong.