Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Michael Ochmann
trakr.
Commits
4771206a
Commit
4771206a
authored
Jul 15, 2018
by
Michael Ochmann
Browse files
testing new download function
parent
265fd5f9
Changes
3
Hide whitespace changes
Inline
Side-by-side
src/javascript/Std.js
View file @
4771206a
...
...
@@ -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
src/javascript/controllers/ViewController.js
View file @
4771206a
...
...
@@ -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
.
download
IOS
();
});
}
...
...
@@ -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
src/javascript/models/HeightMap.js
View file @
4771206a
...
...
@@ -35,7 +35,7 @@ class HeightMap {
if
(
geoPoint
.
altitude
===
null
)
return
;
this
.
min
=
this
.
min
===
null
?
geoPoint
.
altitude
:
this
.
min
;
let
min
=
this
.
min
;
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment