Commit 4771206a authored by Michael Ochmann's avatar Michael Ochmann
Browse files

testing new download function

parent 265fd5f9
......@@ -29,6 +29,15 @@ class Std {
static Map(n, start1, stop1, start2, stop2) {
return (((n - start1) / (stop1 - start1)) * (stop2 - start2)) + start2;
}
static StringToBinary(string) {
let byteCharacters = string;
let byteNumbers = new Array(byteCharacters.length);
for (let i = 0; i < byteCharacters.length; i++)
byteNumbers[i] = byteCharacters.charCodeAt(i);
return new Uint8Array(byteNumbers);
};
}
export default Std;
\ No newline at end of file
......@@ -6,6 +6,7 @@ import TracksListController from "./TracksListController.js";
import HeightMap from "../models/HeightMap.js";
import Tracks from "../models/Tracks.js";
import Std from "../Std.js";
import Settings from "../Settings.js";
import $ from "../smallQ.js";
import GeoJSONCollection from "../GeoJSONCollection.js";
......@@ -72,7 +73,7 @@ class ViewController extends UIViewController {
this.changeState(States.TRACKLIST);
});
$("#download").click(element => {
this.download();
this.downloadIOS();
});
}
......@@ -152,6 +153,21 @@ class ViewController extends UIViewController {
document.body.removeChild(element);
}
downloadIOS() {
let track = this.tracks.get(this.track);
let mediaType = "application/json";
let link = document.createElement("a");
let blob = new Blob([Std.StringToBinary(new GeoJSONCollection(track).toString())], { type: mediaType });
let blobUrl = URL.createObjectURL(blob);
document.body.appendChild(link);
link.download = `${track.name.toLowerCase().replace(new RegExp(" ", "g"), '_')}.json`;
link.href = blobUrl;
link.click();
document.body.removeChild(link);
}
}
export default ViewController;
\ No newline at end of file
......@@ -35,7 +35,7 @@ class HeightMap {
if (geoPoint.altitude === null)
return;
this.min = this.min === null ? geoPoint.altitude : this.min;
let min = this.min;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment