Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

Generate a heatmap from GPS tracks.

Drag and drop one or more GPX/TCX/FIT/IGC files or JPEG images into the browser
Drag and drop one or more GPX/TCX/FIT/IGC/SKIZ files or JPEG images into the browser
window. No data is ever uploaded, everything is done client side.

Loosely inspired by [The Passage Ride](http://thepassageride.com), which you
Expand Down
53 changes: 51 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"leaflet-providers": "^1.3.1",
"pako": "^1.0.6",
"picomodal": "^3.0.0",
"skiz-parser": "^1.4.0",
"xml2js": "^0.4.19"
},
"devDependencies": {
Expand Down
30 changes: 30 additions & 0 deletions src/track.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import xml2js from 'xml2js';
import FitParser from 'fit-file-parser';
import Pako from 'pako';
import IGCParser from 'igc-parser';
import { parseSkizFile } from 'skiz-parser';

const parser = new xml2js.Parser();

Expand Down Expand Up @@ -144,6 +145,23 @@ function extractIGCTracks(igc) {
return points.length > 0 ? [{timestamp, points, name}] : [];
}

function extractSKIZTracks(skiz) {
const points = [];
let timestamp = null;

for (const node of skiz.trackNodes) {
points.push({
lat: node.latitude,
lng: node.longitude,
});

node.timestamp && (timestamp = node.timestamp);
}

const name = 'skiz';
return points.length > 0 ? [{timestamp, points, name}] : [];
}

function readFile(file, encoding, isGzipped) {
return new Promise((resolve, reject) => {
const reader = new FileReader();
Expand Down Expand Up @@ -215,6 +233,18 @@ export default function extractTracks(file) {
}
}));

case 'skiz':
return readFile(file, 'binary', isGzipped)
.then(contents => new Promise((resolve, reject) => {
parseSkizFile(contents, (err, result) => {
if (err) {
reject(err);
} else {
resolve(extractSKIZTracks(result));
}
});
}));

default:
throw `Unsupported file format: ${format}`;
}
Expand Down
2 changes: 1 addition & 1 deletion src/ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const AVAILABLE_THEMES = [
const MODAL_CONTENT = {
help: `
<h1>dérive</h1>
<h4>Drag and drop one or more GPX/TCX/FIT/IGC files or JPEG images here.</h4>
<h4>Drag and drop one or more GPX/TCX/FIT/IGC/SKIZ files or JPEG images here.</h4>
<p>If you use Strava, go to your
<a href="https://www.strava.com/athlete/delete_your_account">account download
page</a> and click "Request your archive". You'll get an email containing a ZIP
Expand Down
3 changes: 3 additions & 0 deletions webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,8 @@ module.exports = {
}
}
]
},
node: {
fs: 'empty'
}
};