@loaders.gl/loader-utils 4.2.0-alpha.3 → 4.2.0-alpha.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +66 -84
- package/dist/index.cjs.map +7 -0
- package/dist/index.d.ts +46 -46
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +18 -1
- package/dist/json-loader.d.ts +1 -1
- package/dist/json-loader.d.ts.map +1 -1
- package/dist/json-loader.js +20 -14
- package/dist/lib/binary-utils/array-buffer-utils.js +75 -46
- package/dist/lib/binary-utils/dataview-copy-utils.d.ts +1 -1
- package/dist/lib/binary-utils/dataview-copy-utils.d.ts.map +1 -1
- package/dist/lib/binary-utils/dataview-copy-utils.js +75 -34
- package/dist/lib/binary-utils/get-first-characters.js +39 -21
- package/dist/lib/binary-utils/memory-conversion-utils.js +38 -23
- package/dist/lib/binary-utils/memory-copy-utils.js +49 -20
- package/dist/lib/env-utils/assert.js +7 -4
- package/dist/lib/env-utils/globals.js +15 -7
- package/dist/lib/file-provider/data-view-file.d.ts +1 -1
- package/dist/lib/file-provider/data-view-file.d.ts.map +1 -1
- package/dist/lib/file-provider/data-view-file.js +58 -29
- package/dist/lib/file-provider/file-handle-file.d.ts +1 -1
- package/dist/lib/file-provider/file-handle-file.d.ts.map +1 -1
- package/dist/lib/file-provider/file-handle-file.js +96 -58
- package/dist/lib/file-provider/file-provider.js +8 -3
- package/dist/lib/files/blob-file.d.ts +1 -1
- package/dist/lib/files/blob-file.d.ts.map +1 -1
- package/dist/lib/files/blob-file.js +24 -23
- package/dist/lib/files/file.js +3 -1
- package/dist/lib/files/http-file.d.ts +1 -1
- package/dist/lib/files/http-file.d.ts.map +1 -1
- package/dist/lib/files/http-file.js +91 -71
- package/dist/lib/files/node-file-facade.d.ts +1 -1
- package/dist/lib/files/node-file-facade.d.ts.map +1 -1
- package/dist/lib/files/node-file-facade.js +37 -29
- package/dist/lib/files/sources.js +150 -1
- package/dist/lib/filesystems/filesystem.d.ts +1 -1
- package/dist/lib/filesystems/filesystem.d.ts.map +1 -1
- package/dist/lib/filesystems/filesystem.js +3 -1
- package/dist/lib/filesystems/node-filesystem-facade.d.ts +3 -3
- package/dist/lib/filesystems/node-filesystem-facade.d.ts.map +1 -1
- package/dist/lib/filesystems/node-filesystem-facade.js +41 -31
- package/dist/lib/iterators/async-iteration.js +39 -24
- package/dist/lib/iterators/text-iterators.js +46 -39
- package/dist/lib/node/buffer.browser.js +15 -3
- package/dist/lib/node/buffer.js +30 -16
- package/dist/lib/node/fs.browser.js +0 -1
- package/dist/lib/node/promisify.js +10 -4
- package/dist/lib/node/stream.browser.js +0 -1
- package/dist/lib/node/stream.js +4 -1
- package/dist/lib/option-utils/merge-loader-options.d.ts +1 -1
- package/dist/lib/option-utils/merge-loader-options.d.ts.map +1 -1
- package/dist/lib/option-utils/merge-loader-options.js +25 -17
- package/dist/lib/parser-utils/parse-json.js +9 -6
- package/dist/lib/path-utils/file-aliases.js +29 -13
- package/dist/lib/path-utils/get-cwd.js +6 -7
- package/dist/lib/path-utils/path.js +149 -105
- package/dist/lib/request-utils/request-scheduler.d.ts +2 -1
- package/dist/lib/request-utils/request-scheduler.d.ts.map +1 -1
- package/dist/lib/request-utils/request-scheduler.js +130 -102
- package/dist/lib/sources/data-source.js +48 -38
- package/dist/lib/sources/image-source.d.ts +3 -3
- package/dist/lib/sources/image-source.d.ts.map +1 -1
- package/dist/lib/sources/image-source.js +11 -3
- package/dist/lib/sources/image-tile-source.d.ts +3 -3
- package/dist/lib/sources/image-tile-source.d.ts.map +1 -1
- package/dist/lib/sources/image-tile-source.js +3 -1
- package/dist/lib/sources/tile-source-adapter.d.ts +2 -2
- package/dist/lib/sources/tile-source-adapter.d.ts.map +1 -1
- package/dist/lib/sources/tile-source-adapter.js +43 -36
- package/dist/lib/sources/tile-source.js +3 -1
- package/dist/lib/sources/utils/image-type.js +0 -1
- package/dist/lib/sources/utils/utils.js +31 -17
- package/dist/lib/sources/vector-tile-source.d.ts +2 -2
- package/dist/lib/sources/vector-tile-source.d.ts.map +1 -1
- package/dist/lib/sources/vector-tile-source.js +3 -1
- package/dist/lib/worker-loader-utils/create-loader-worker.d.ts +1 -1
- package/dist/lib/worker-loader-utils/create-loader-worker.d.ts.map +1 -1
- package/dist/lib/worker-loader-utils/create-loader-worker.js +87 -87
- package/dist/lib/worker-loader-utils/encode-with-worker.d.ts +1 -1
- package/dist/lib/worker-loader-utils/encode-with-worker.d.ts.map +1 -1
- package/dist/lib/worker-loader-utils/encode-with-worker.js +13 -8
- package/dist/lib/worker-loader-utils/parse-with-worker.d.ts +1 -1
- package/dist/lib/worker-loader-utils/parse-with-worker.d.ts.map +1 -1
- package/dist/lib/worker-loader-utils/parse-with-worker.js +68 -55
- package/dist/loader-types.d.ts +2 -2
- package/dist/loader-types.d.ts.map +1 -1
- package/dist/loader-types.js +26 -10
- package/dist/service-types.d.ts +1 -1
- package/dist/service-types.d.ts.map +1 -1
- package/dist/service-types.js +3 -1
- package/dist/types.js +1 -1
- package/dist/workers/json-worker.js +0 -1
- package/dist/writer-types.js +3 -1
- package/package.json +6 -4
- package/src/lib/request-utils/request-scheduler.ts +17 -8
- package/dist/index.js.map +0 -1
- package/dist/json-loader.js.map +0 -1
- package/dist/lib/binary-utils/array-buffer-utils.js.map +0 -1
- package/dist/lib/binary-utils/dataview-copy-utils.js.map +0 -1
- package/dist/lib/binary-utils/get-first-characters.js.map +0 -1
- package/dist/lib/binary-utils/memory-conversion-utils.js.map +0 -1
- package/dist/lib/binary-utils/memory-copy-utils.js.map +0 -1
- package/dist/lib/env-utils/assert.js.map +0 -1
- package/dist/lib/env-utils/globals.js.map +0 -1
- package/dist/lib/file-provider/data-view-file.js.map +0 -1
- package/dist/lib/file-provider/file-handle-file.js.map +0 -1
- package/dist/lib/file-provider/file-provider.js.map +0 -1
- package/dist/lib/files/blob-file.js.map +0 -1
- package/dist/lib/files/file.js.map +0 -1
- package/dist/lib/files/http-file.js.map +0 -1
- package/dist/lib/files/node-file-facade.js.map +0 -1
- package/dist/lib/files/sources.js.map +0 -1
- package/dist/lib/filesystems/filesystem.js.map +0 -1
- package/dist/lib/filesystems/node-filesystem-facade.js.map +0 -1
- package/dist/lib/iterators/async-iteration.js.map +0 -1
- package/dist/lib/iterators/text-iterators.js.map +0 -1
- package/dist/lib/node/buffer.browser.js.map +0 -1
- package/dist/lib/node/buffer.js.map +0 -1
- package/dist/lib/node/fs.browser.js.map +0 -1
- package/dist/lib/node/promisify.js.map +0 -1
- package/dist/lib/node/stream.browser.js.map +0 -1
- package/dist/lib/node/stream.js.map +0 -1
- package/dist/lib/option-utils/merge-loader-options.js.map +0 -1
- package/dist/lib/parser-utils/parse-json.js.map +0 -1
- package/dist/lib/path-utils/file-aliases.js.map +0 -1
- package/dist/lib/path-utils/get-cwd.js.map +0 -1
- package/dist/lib/path-utils/path.js.map +0 -1
- package/dist/lib/request-utils/request-scheduler.js.map +0 -1
- package/dist/lib/sources/data-source.js.map +0 -1
- package/dist/lib/sources/image-source.js.map +0 -1
- package/dist/lib/sources/image-tile-source.js.map +0 -1
- package/dist/lib/sources/tile-source-adapter.js.map +0 -1
- package/dist/lib/sources/tile-source.js.map +0 -1
- package/dist/lib/sources/utils/image-type.js.map +0 -1
- package/dist/lib/sources/utils/utils.js.map +0 -1
- package/dist/lib/sources/vector-tile-source.js.map +0 -1
- package/dist/lib/worker-loader-utils/create-loader-worker.js.map +0 -1
- package/dist/lib/worker-loader-utils/encode-with-worker.js.map +0 -1
- package/dist/lib/worker-loader-utils/parse-with-worker.js.map +0 -1
- package/dist/loader-types.js.map +0 -1
- package/dist/service-types.js.map +0 -1
- package/dist/types.js.map +0 -1
- package/dist/workers/json-worker.js.map +0 -1
- package/dist/writer-types.js.map +0 -1
|
@@ -1,43 +1,53 @@
|
|
|
1
|
+
// loaders.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
/** base class of all data sources */
|
|
1
5
|
export class DataSource {
|
|
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
|
-
this._needsRefresh = false;
|
|
6
|
+
constructor(props) {
|
|
7
|
+
this._needsRefresh = true;
|
|
8
|
+
this.props = { ...props };
|
|
9
|
+
this.loadOptions = { ...props.loadOptions };
|
|
10
|
+
this.fetch = getFetchFunction(this.loadOptions);
|
|
11
|
+
}
|
|
12
|
+
setProps(props) {
|
|
13
|
+
this.props = Object.assign(this.props, props);
|
|
14
|
+
// TODO - add a shallow compare to avoid setting refresh if no change?
|
|
15
|
+
this.setNeedsRefresh();
|
|
16
|
+
}
|
|
17
|
+
/** Mark this data source as needing a refresh (redraw) */
|
|
18
|
+
setNeedsRefresh() {
|
|
19
|
+
this._needsRefresh = true;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Does this data source need refreshing?
|
|
23
|
+
* @note The specifics of the refresh mechanism depends on type of data source
|
|
24
|
+
*/
|
|
25
|
+
getNeedsRefresh(clear = true) {
|
|
26
|
+
const needsRefresh = this._needsRefresh;
|
|
27
|
+
if (clear) {
|
|
28
|
+
this._needsRefresh = false;
|
|
29
|
+
}
|
|
30
|
+
return needsRefresh;
|
|
28
31
|
}
|
|
29
|
-
return needsRefresh;
|
|
30
|
-
}
|
|
31
32
|
}
|
|
33
|
+
/**
|
|
34
|
+
* Gets the current fetch function from options
|
|
35
|
+
* @todo - move to loader-utils module
|
|
36
|
+
* @todo - use in core module counterpart
|
|
37
|
+
* @param options
|
|
38
|
+
* @param context
|
|
39
|
+
*/
|
|
32
40
|
export function getFetchFunction(options) {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
41
|
+
const fetchFunction = options?.fetch;
|
|
42
|
+
// options.fetch can be a function
|
|
43
|
+
if (fetchFunction && typeof fetchFunction === 'function') {
|
|
44
|
+
return (url, fetchOptions) => fetchFunction(url, fetchOptions);
|
|
45
|
+
}
|
|
46
|
+
// options.fetch can be an options object, use global fetch with those options
|
|
47
|
+
const fetchOptions = options?.fetch;
|
|
48
|
+
if (fetchOptions && typeof fetchOptions !== 'function') {
|
|
49
|
+
return (url) => fetch(url, fetchOptions);
|
|
50
|
+
}
|
|
51
|
+
// else return the global fetch function
|
|
52
|
+
return (url) => fetch(url);
|
|
42
53
|
}
|
|
43
|
-
//# sourceMappingURL=data-source.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { DataSourceProps } from
|
|
2
|
-
import { DataSource } from
|
|
3
|
-
import { ImageType } from
|
|
1
|
+
import type { DataSourceProps } from "./data-source.js";
|
|
2
|
+
import { DataSource } from "./data-source.js";
|
|
3
|
+
import { ImageType } from "./utils/image-type.js";
|
|
4
4
|
/**
|
|
5
5
|
* Normalized capabilities of an Image service
|
|
6
6
|
* @example
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"image-source.d.ts","sourceRoot":"","sources":["../../../src/lib/sources/image-source.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAC,eAAe,EAAC,
|
|
1
|
+
{"version":3,"file":"image-source.d.ts","sourceRoot":"","sources":["../../../src/lib/sources/image-source.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAC,eAAe,EAAC,yBAAsB;AACnD,OAAO,EAAC,UAAU,EAAC,yBAAsB;AACzC,OAAO,EAAC,SAAS,EAAC,8BAA2B;AAE7C;;;;;GAKG;AACH,MAAM,MAAM,mBAAmB,GAAG;IAChC,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,MAAM,EAAE,gBAAgB,EAAE,CAAC;CAC5B,CAAC;AAEF,wDAAwD;AACxD,MAAM,MAAM,gBAAgB,GAAG;IAC7B,yBAAyB;IACzB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,yCAAyC;IACzC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,iDAAiD;IACjD,GAAG,CAAC,EAAE,MAAM,EAAE,CAAC;IACf,8FAA8F;IAC9F,WAAW,CAAC,EAAE,CAAC,GAAG,EAAE,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,CAAC,EAAE,GAAG,EAAE,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC;IACzE,+BAA+B;IAC/B,MAAM,CAAC,EAAE,gBAAgB,EAAE,CAAC;CAC7B,CAAC;AAEF,sEAAsE;AACtE,MAAM,MAAM,kBAAkB,GAAG;IAC/B,uBAAuB;IACvB,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IAC1B,cAAc;IACd,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,8CAA8C;IAC9C,WAAW,EAAE,CAAC,GAAG,EAAE,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,CAAC,EAAE,GAAG,EAAE,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC;IACxE,kCAAkC;IAClC,IAAI,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;IACxC,oCAAoC;IACpC,KAAK,EAAE,MAAM,CAAC;IACd,aAAa;IACb,MAAM,EAAE,MAAM,CAAC;IACf,+CAA+C;IAC/C,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,4CAA4C;IAC5C,MAAM,CAAC,EAAE,WAAW,CAAC;CACtB,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG,eAAe,CAAC;AAE/C;;;;GAIG;AACH,8BAAsB,WAAW,CAC/B,MAAM,SAAS,gBAAgB,GAAG,gBAAgB,CAClD,SAAQ,UAAU,CAAC,MAAM,CAAC;IAC1B,MAAM,CAAC,IAAI,EAAE,MAAM,CAAc;IACjC,MAAM,CAAC,OAAO,QAAS,MAAM,KAAG,OAAO,CAAU;IAEjD,QAAQ,CAAC,WAAW,IAAI,OAAO,CAAC,mBAAmB,CAAC;IACpD,QAAQ,CAAC,QAAQ,CAAC,UAAU,EAAE,kBAAkB,GAAG,OAAO,CAAC,SAAS,CAAC;CACtE"}
|
|
@@ -1,5 +1,13 @@
|
|
|
1
|
+
// loaders.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
1
4
|
import { DataSource } from "./data-source.js";
|
|
2
|
-
|
|
5
|
+
/**
|
|
6
|
+
* MapImageSource - data sources that allow data to be queried by (geospatial) extents
|
|
7
|
+
* @note
|
|
8
|
+
* - If geospatial, bounding box is expected to be in web mercator coordinates
|
|
9
|
+
*/
|
|
10
|
+
export class ImageSource extends DataSource {
|
|
11
|
+
}
|
|
3
12
|
ImageSource.type = 'template';
|
|
4
|
-
ImageSource.testURL = url => false;
|
|
5
|
-
//# sourceMappingURL=image-source.js.map
|
|
13
|
+
ImageSource.testURL = (url) => false;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { ImageType } from
|
|
2
|
-
import type { TileSource, TileSourceMetadata } from
|
|
3
|
-
import type { GetTileParameters } from
|
|
1
|
+
import type { ImageType } from "./utils/image-type.js";
|
|
2
|
+
import type { TileSource, TileSourceMetadata } from "./tile-source.js";
|
|
3
|
+
import type { GetTileParameters } from "./tile-source.js";
|
|
4
4
|
/**
|
|
5
5
|
* MapTileSource - data sources that allow data to be queried by (geospatial) tile
|
|
6
6
|
* @note If geospatial, bounding box is expected to be in web mercator coordinates
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"image-tile-source.d.ts","sourceRoot":"","sources":["../../../src/lib/sources/image-tile-source.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAC,SAAS,EAAC,
|
|
1
|
+
{"version":3,"file":"image-tile-source.d.ts","sourceRoot":"","sources":["../../../src/lib/sources/image-tile-source.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAC,SAAS,EAAC,8BAA2B;AAClD,OAAO,KAAK,EAAC,UAAU,EAAE,kBAAkB,EAAC,yBAAsB;AAClE,OAAO,KAAK,EAAC,iBAAiB,EAAC,yBAAsB;AAErD;;;GAGG;AACH,MAAM,WAAW,eAAe,CAAC,SAAS,SAAS,kBAAkB,GAAG,kBAAkB,CACxF,SAAQ,UAAU,CAAC,SAAS,CAAC;IAC7B,YAAY,CAAC,UAAU,EAAE,iBAAiB,GAAG,OAAO,CAAC,SAAS,GAAG,IAAI,CAAC,CAAC;CACxE"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { TileSource, GetTileParameters } from
|
|
2
|
-
import { ImageSource, ImageSourceMetadata } from
|
|
1
|
+
import { TileSource, GetTileParameters } from "./tile-source.js";
|
|
2
|
+
import { ImageSource, ImageSourceMetadata } from "./image-source.js";
|
|
3
3
|
/**
|
|
4
4
|
* MapTileSource - data sources that allow data to be queried by (geospatial) extents
|
|
5
5
|
* @note
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tile-source-adapter.d.ts","sourceRoot":"","sources":["../../../src/lib/sources/tile-source-adapter.ts"],"names":[],"mappings":"AAGA,OAAO,EAAC,UAAU,EAAE,iBAAiB,EAAC,
|
|
1
|
+
{"version":3,"file":"tile-source-adapter.d.ts","sourceRoot":"","sources":["../../../src/lib/sources/tile-source-adapter.ts"],"names":[],"mappings":"AAGA,OAAO,EAAC,UAAU,EAAE,iBAAiB,EAAC,yBAAsB;AAC5D,OAAO,EAAC,WAAW,EAAE,mBAAmB,EAAC,0BAAuB;AAEhE;;;;GAIG;AACH,qBAAa,iBAAiB,CAAC,SAAS,CAAE,YAAW,UAAU,CAAC,mBAAmB,CAAC;IAClF,QAAQ,CAAC,cAAc,EAAE,WAAW,CAAC;gBACzB,MAAM,EAAE,WAAW;IAGzB,WAAW,IAAI,OAAO,CAAC,mBAAmB,CAAC;IAGjD,sBAAsB;IACtB,OAAO,CAAC,UAAU,EAAE,iBAAiB,GAAG,OAAO,CAAC,OAAO,CAAC;IAOxD,+BAA+B;IAK/B,gEAAgE;IAChE,SAAS,CAAC,kBAAkB,CAC1B,UAAU,EAAE,iBAAiB,GAC5B,CAAC,GAAG,EAAE,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,CAAC,EAAE,GAAG,EAAE,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,CAAC,CAAC;IAc7D,sBAAsB,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC;CAO7E"}
|
|
@@ -1,39 +1,46 @@
|
|
|
1
|
+
// loaders.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
/**
|
|
4
|
+
* MapTileSource - data sources that allow data to be queried by (geospatial) extents
|
|
5
|
+
* @note
|
|
6
|
+
* - If geospatial, bounding box is expected to be in web mercator coordinates
|
|
7
|
+
*/
|
|
1
8
|
export class TileSourceAdapter {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
9
|
+
constructor(source) {
|
|
10
|
+
this.viewportSource = source;
|
|
11
|
+
}
|
|
12
|
+
async getMetadata() {
|
|
13
|
+
return await this.viewportSource.getMetadata();
|
|
14
|
+
}
|
|
15
|
+
/** Flat parameters */
|
|
16
|
+
getTile(parameters) {
|
|
17
|
+
const width = 512;
|
|
18
|
+
const height = 512;
|
|
19
|
+
const boundingBox = this.getTileBoundingBox(parameters);
|
|
20
|
+
return this.viewportSource.getImage({ boundingBox, layers: [], width, height });
|
|
21
|
+
}
|
|
22
|
+
/** deck.gl style parameters */
|
|
23
|
+
// getTileData(parameters: TileLoadParameters): Promise<unknown | null> {
|
|
24
|
+
// return this.viewportSource.getImage
|
|
25
|
+
// }
|
|
26
|
+
/** Bounding box of tiles in this tileset `[[w, s], [e, n]]` */
|
|
27
|
+
getTileBoundingBox(parameters) {
|
|
28
|
+
if (parameters.crs && parameters.crs !== 'ESPG3758') {
|
|
29
|
+
throw new Error('SRS not ESPG3758');
|
|
30
|
+
}
|
|
31
|
+
const { x, y, zoom } = parameters;
|
|
32
|
+
return [
|
|
33
|
+
/** Bounding box of tile in this tileset `[[w, s], ...]` */
|
|
34
|
+
this.getTileLowerLeftCorner(x, y, zoom),
|
|
35
|
+
/** Bounding box of tile in this tileset `[..., [e, n]]` */
|
|
36
|
+
this.getTileLowerLeftCorner(x + 1, y - 1, zoom)
|
|
37
|
+
];
|
|
38
|
+
}
|
|
39
|
+
getTileLowerLeftCorner(x, y, zoom) {
|
|
40
|
+
const tiles = 2 ^ zoom;
|
|
41
|
+
const longitude = (x / tiles) * 360.0 - 180.0;
|
|
42
|
+
const latitudeRadians = Math.atan(Math.sinh(Math.PI * (1 - (2 * (y + 1)) / tiles)));
|
|
43
|
+
const latitude = (180.0 * latitudeRadians) / Math.PI;
|
|
44
|
+
return [longitude, latitude];
|
|
23
45
|
}
|
|
24
|
-
const {
|
|
25
|
-
x,
|
|
26
|
-
y,
|
|
27
|
-
zoom
|
|
28
|
-
} = parameters;
|
|
29
|
-
return [this.getTileLowerLeftCorner(x, y, zoom), this.getTileLowerLeftCorner(x + 1, y - 1, zoom)];
|
|
30
|
-
}
|
|
31
|
-
getTileLowerLeftCorner(x, y, zoom) {
|
|
32
|
-
const tiles = 2 ^ zoom;
|
|
33
|
-
const longitude = x / tiles * 360.0 - 180.0;
|
|
34
|
-
const latitudeRadians = Math.atan(Math.sinh(Math.PI * (1 - 2 * (y + 1) / tiles)));
|
|
35
|
-
const latitude = 180.0 * latitudeRadians / Math.PI;
|
|
36
|
-
return [longitude, latitude];
|
|
37
|
-
}
|
|
38
46
|
}
|
|
39
|
-
//# sourceMappingURL=tile-source-adapter.js.map
|
|
@@ -1,21 +1,35 @@
|
|
|
1
|
+
// loaders.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
/**
|
|
5
|
+
* Gets the current fetch function from options
|
|
6
|
+
* @todo - move to loader-utils module
|
|
7
|
+
* @todo - use in core module counterpart
|
|
8
|
+
* @param options
|
|
9
|
+
* @param context
|
|
10
|
+
*/
|
|
1
11
|
export function getFetchFunction(options) {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
12
|
+
const fetchFunction = options?.fetch;
|
|
13
|
+
// options.fetch can be a function
|
|
14
|
+
if (fetchFunction && typeof fetchFunction === 'function') {
|
|
15
|
+
return (url, fetchOptions) => fetchFunction(url, fetchOptions);
|
|
16
|
+
}
|
|
17
|
+
// options.fetch can be an options object, use global fetch with those options
|
|
18
|
+
const fetchOptions = options?.fetch;
|
|
19
|
+
if (fetchOptions && typeof fetchOptions !== 'function') {
|
|
20
|
+
return (url) => fetch(url, fetchOptions);
|
|
21
|
+
}
|
|
22
|
+
// else return the global fetch function
|
|
23
|
+
return (url) => fetch(url);
|
|
11
24
|
}
|
|
12
25
|
export function mergeImageServiceProps(props) {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
26
|
+
// @ts-expect-error
|
|
27
|
+
return {
|
|
28
|
+
// Default fetch
|
|
29
|
+
...props,
|
|
30
|
+
loadOptions: {
|
|
31
|
+
...props.loadOptions,
|
|
32
|
+
fetch: getFetchFunction(props.loadOptions)
|
|
33
|
+
}
|
|
34
|
+
};
|
|
20
35
|
}
|
|
21
|
-
//# sourceMappingURL=utils.js.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { TileSource, TileSourceMetadata } from
|
|
2
|
-
import { GetTileParameters } from
|
|
1
|
+
import { TileSource, TileSourceMetadata } from "./tile-source.js";
|
|
2
|
+
import { GetTileParameters } from "./tile-source.js";
|
|
3
3
|
/**
|
|
4
4
|
* MapTileSource - data sources that allow data to be queried by (geospatial) tile
|
|
5
5
|
* @note If geospatial, bounding box is expected to be in web mercator coordinates
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vector-tile-source.d.ts","sourceRoot":"","sources":["../../../src/lib/sources/vector-tile-source.ts"],"names":[],"mappings":"AAIA,OAAO,EAAC,UAAU,EAAE,kBAAkB,EAAC,
|
|
1
|
+
{"version":3,"file":"vector-tile-source.d.ts","sourceRoot":"","sources":["../../../src/lib/sources/vector-tile-source.ts"],"names":[],"mappings":"AAIA,OAAO,EAAC,UAAU,EAAE,kBAAkB,EAAC,yBAAsB;AAC7D,OAAO,EAAC,iBAAiB,EAAC,yBAAsB;AAEhD;;;GAGG;AACH,MAAM,WAAW,gBAAgB,CAAC,SAAS,SAAS,kBAAkB,GAAG,kBAAkB,CACzF,SAAQ,UAAU,CAAC,SAAS,CAAC;IAC7B,aAAa,CAAC,UAAU,EAAE,iBAAiB,GAAG,OAAO,CAAC,OAAO,GAAG,IAAI,CAAC,CAAC;CACvE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-loader-worker.d.ts","sourceRoot":"","sources":["../../../src/lib/worker-loader-utils/create-loader-worker.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAC,gBAAgB,EAA+B,
|
|
1
|
+
{"version":3,"file":"create-loader-worker.d.ts","sourceRoot":"","sources":["../../../src/lib/worker-loader-utils/create-loader-worker.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAC,gBAAgB,EAA+B,8BAA2B;AAMvF;;;GAGG;AACH,wBAAsB,kBAAkB,CAAC,MAAM,EAAE,gBAAgB,iBAiChE"}
|
|
@@ -1,95 +1,95 @@
|
|
|
1
1
|
import { WorkerBody } from '@loaders.gl/worker-utils';
|
|
2
|
+
// import {validateLoaderVersion} from './validate-loader-version';
|
|
2
3
|
let requestId = 0;
|
|
4
|
+
/**
|
|
5
|
+
* Set up a WebWorkerGlobalScope to talk with the main thread
|
|
6
|
+
* @param loader
|
|
7
|
+
*/
|
|
3
8
|
export async function createLoaderWorker(loader) {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
WorkerBody.onmessage = async (type, payload) => {
|
|
8
|
-
switch (type) {
|
|
9
|
-
case 'process':
|
|
10
|
-
try {
|
|
11
|
-
const {
|
|
12
|
-
input,
|
|
13
|
-
options = {},
|
|
14
|
-
context = {}
|
|
15
|
-
} = payload;
|
|
16
|
-
const result = await parseData({
|
|
17
|
-
loader,
|
|
18
|
-
arrayBuffer: input,
|
|
19
|
-
options,
|
|
20
|
-
context: {
|
|
21
|
-
...context,
|
|
22
|
-
_parse: parseOnMainThread
|
|
23
|
-
}
|
|
24
|
-
});
|
|
25
|
-
WorkerBody.postMessage('done', {
|
|
26
|
-
result
|
|
27
|
-
});
|
|
28
|
-
} catch (error) {
|
|
29
|
-
const message = error instanceof Error ? error.message : '';
|
|
30
|
-
WorkerBody.postMessage('error', {
|
|
31
|
-
error: message
|
|
32
|
-
});
|
|
33
|
-
}
|
|
34
|
-
break;
|
|
35
|
-
default:
|
|
9
|
+
// Check that we are actually in a worker thread
|
|
10
|
+
if (!(await WorkerBody.inWorkerThread())) {
|
|
11
|
+
return;
|
|
36
12
|
}
|
|
37
|
-
|
|
13
|
+
WorkerBody.onmessage = async (type, payload) => {
|
|
14
|
+
switch (type) {
|
|
15
|
+
case 'process':
|
|
16
|
+
try {
|
|
17
|
+
// validateLoaderVersion(loader, data.source.split('@')[1]);
|
|
18
|
+
const { input, options = {}, context = {} } = payload;
|
|
19
|
+
const result = await parseData({
|
|
20
|
+
loader,
|
|
21
|
+
arrayBuffer: input,
|
|
22
|
+
options,
|
|
23
|
+
// @ts-expect-error fetch missing
|
|
24
|
+
context: {
|
|
25
|
+
...context,
|
|
26
|
+
_parse: parseOnMainThread
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
WorkerBody.postMessage('done', { result });
|
|
30
|
+
}
|
|
31
|
+
catch (error) {
|
|
32
|
+
const message = error instanceof Error ? error.message : '';
|
|
33
|
+
WorkerBody.postMessage('error', { error: message });
|
|
34
|
+
}
|
|
35
|
+
break;
|
|
36
|
+
default:
|
|
37
|
+
}
|
|
38
|
+
};
|
|
38
39
|
}
|
|
39
40
|
function parseOnMainThread(arrayBuffer, loader, options, context) {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
41
|
+
return new Promise((resolve, reject) => {
|
|
42
|
+
const id = requestId++;
|
|
43
|
+
/**
|
|
44
|
+
*/
|
|
45
|
+
const onMessage = (type, payload) => {
|
|
46
|
+
if (payload.id !== id) {
|
|
47
|
+
// not ours
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
switch (type) {
|
|
51
|
+
case 'done':
|
|
52
|
+
WorkerBody.removeEventListener(onMessage);
|
|
53
|
+
resolve(payload.result);
|
|
54
|
+
break;
|
|
55
|
+
case 'error':
|
|
56
|
+
WorkerBody.removeEventListener(onMessage);
|
|
57
|
+
reject(payload.error);
|
|
58
|
+
break;
|
|
59
|
+
default:
|
|
60
|
+
// ignore
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
WorkerBody.addEventListener(onMessage);
|
|
64
|
+
// Ask the main thread to decode data
|
|
65
|
+
const payload = { id, input: arrayBuffer, options };
|
|
66
|
+
WorkerBody.postMessage('process', payload);
|
|
67
|
+
});
|
|
66
68
|
}
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
...options
|
|
93
|
-
}, context, loader);
|
|
69
|
+
// TODO - Support byteOffset and byteLength (enabling parsing of embedded binaries without copies)
|
|
70
|
+
// TODO - Why not support async loader.parse* funcs here?
|
|
71
|
+
// TODO - Why not reuse a common function instead of reimplementing loader.parse* selection logic? Keeping loader small?
|
|
72
|
+
// TODO - Lack of appropriate parser functions can be detected when we create worker, no need to wait until parse
|
|
73
|
+
async function parseData({ loader, arrayBuffer, options, context }) {
|
|
74
|
+
let data;
|
|
75
|
+
let parser;
|
|
76
|
+
if (loader.parseSync || loader.parse) {
|
|
77
|
+
data = arrayBuffer;
|
|
78
|
+
parser = loader.parseSync || loader.parse;
|
|
79
|
+
}
|
|
80
|
+
else if (loader.parseTextSync) {
|
|
81
|
+
const textDecoder = new TextDecoder();
|
|
82
|
+
data = textDecoder.decode(arrayBuffer);
|
|
83
|
+
parser = loader.parseTextSync;
|
|
84
|
+
}
|
|
85
|
+
else {
|
|
86
|
+
throw new Error(`Could not load data with ${loader.name} loader`);
|
|
87
|
+
}
|
|
88
|
+
// TODO - proper merge in of loader options...
|
|
89
|
+
options = {
|
|
90
|
+
...options,
|
|
91
|
+
modules: (loader && loader.options && loader.options.modules) || {},
|
|
92
|
+
worker: false
|
|
93
|
+
};
|
|
94
|
+
return await parser(data, { ...options }, context, loader);
|
|
94
95
|
}
|
|
95
|
-
//# sourceMappingURL=create-loader-worker.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"encode-with-worker.d.ts","sourceRoot":"","sources":["../../../src/lib/worker-loader-utils/encode-with-worker.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,MAAM,EAAE,aAAa,EAAC,
|
|
1
|
+
{"version":3,"file":"encode-with-worker.d.ts","sourceRoot":"","sources":["../../../src/lib/worker-loader-utils/encode-with-worker.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,MAAM,EAAE,aAAa,EAAC,8BAA2B;AAGzD;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,aAAa,OAW1E"}
|
|
@@ -1,12 +1,17 @@
|
|
|
1
1
|
import { WorkerFarm } from '@loaders.gl/worker-utils';
|
|
2
2
|
import { isBrowser } from "../env-utils/globals.js";
|
|
3
|
+
/**
|
|
4
|
+
* Determines if a loader can parse with worker
|
|
5
|
+
* @param loader
|
|
6
|
+
* @param options
|
|
7
|
+
*/
|
|
3
8
|
export function canEncodeWithWorker(writer, options) {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
if (!WorkerFarm.isSupported()) {
|
|
10
|
+
return false;
|
|
11
|
+
}
|
|
12
|
+
// Node workers are still experimental
|
|
13
|
+
if (!isBrowser && !options?._nodeWorkers) {
|
|
14
|
+
return false;
|
|
15
|
+
}
|
|
16
|
+
return writer.worker && options?.worker;
|
|
11
17
|
}
|
|
12
|
-
//# sourceMappingURL=encode-with-worker.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parse-with-worker.d.ts","sourceRoot":"","sources":["../../../src/lib/worker-loader-utils/parse-with-worker.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAC,MAAM,EAAE,aAAa,EAAE,aAAa,EAAC,
|
|
1
|
+
{"version":3,"file":"parse-with-worker.d.ts","sourceRoot":"","sources":["../../../src/lib/worker-loader-utils/parse-with-worker.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAC,MAAM,EAAE,aAAa,EAAE,aAAa,EAAC,8BAA2B;AAG7E;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,aAAa,4BAWzE;AAED;;;GAGG;AACH,wBAAsB,eAAe,CACnC,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,GAAG,EACT,OAAO,CAAC,EAAE,aAAa,EACvB,OAAO,CAAC,EAAE,aAAa,EACvB,iBAAiB,CAAC,EAAE,CAAC,WAAW,EAAE,WAAW,EAAE,OAAO,EAAE;IAAC,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;CAAC,KAAK,OAAO,CAAC,OAAO,CAAC,gBA8BlG"}
|