-
Notifications
You must be signed in to change notification settings - Fork 0
/
gdal.js
47 lines (40 loc) · 1.21 KB
/
gdal.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
// gdal.js
// Martin Pravda
/*jslint browser */
import init_gdaljs from "gdal3.js";
import parseq from "./parseq.js";
const sources = {
data: "https://cdn.jsdelivr.net/npm/[email protected]/dist/package/gdal3WebAssembly.data",
js: "https://cdn.jsdelivr.net/npm/[email protected]/dist/package/gdal3.js",
wasm: "https://cdn.jsdelivr.net/npm/[email protected]/dist/package/gdal3WebAssembly.wasm"
};
function load_worker() {
return function (callback) {
return fetch(sources.js).then(function (response) {
return response.blob();
}).then(function (blob) {
return callback(
URL.createObjectURL(blob)
);
}).catch(function (err) {
callback(undefined, err);
});
};
}
function init_gdal() {
return function (callback, worker_url) {
const paths = Object.assign({}, sources, {js: worker_url});
init_gdaljs({paths}).then(function (gdal) {
return callback(gdal);
}).catch(function (err) {
return callback(undefined, err);
});
};
}
function load() {
return parseq.sequence([
load_worker(),
init_gdal()
]);
}
export default Object.freeze({load});