@loaders.gl/loader-utils 4.0.0 → 4.0.2
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 +2 -2
- package/dist/lib/node/buffer.d.ts.map +1 -1
- package/dist/lib/node/buffer.js.map +1 -1
- package/dist/lib/sources/data-source.d.ts +1 -0
- package/dist/lib/sources/data-source.d.ts.map +1 -1
- package/dist/lib/sources/data-source.js +1 -0
- package/dist/lib/sources/data-source.js.map +1 -1
- package/dist/lib/sources/image-source.d.ts +2 -22
- package/dist/lib/sources/image-source.d.ts.map +1 -1
- package/dist/lib/sources/image-source.js.map +1 -1
- package/dist/lib/sources/tile-source-adapter.d.ts +19 -0
- package/dist/lib/sources/tile-source-adapter.d.ts.map +1 -0
- package/dist/lib/sources/tile-source-adapter.js +39 -0
- package/dist/lib/sources/tile-source-adapter.js.map +1 -0
- package/dist/lib/sources/tile-source.d.ts +3 -3
- package/dist/lib/sources/tile-source.d.ts.map +1 -1
- package/dist/lib/sources/tile-source.js.map +1 -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 +2 -2
- package/dist/lib/worker-loader-utils/create-loader-worker.js.map +1 -1
- package/dist/writer-types.d.ts.map +1 -1
- package/dist/writer-types.js.map +1 -1
- package/package.json +3 -3
- package/src/lib/node/buffer.ts +1 -0
- package/src/lib/sources/data-source.ts +1 -0
- package/src/lib/sources/image-source.ts +2 -26
- package/src/lib/sources/tile-source-adapter.ts +56 -0
- package/src/lib/sources/tile-source.ts +3 -3
- package/src/lib/worker-loader-utils/create-loader-worker.ts +2 -2
- package/src/writer-types.ts +0 -2
package/dist/index.cjs
CHANGED
|
@@ -147,8 +147,8 @@ function mergeOptionsRecursively(baseOptions, newOptions) {
|
|
|
147
147
|
// src/lib/worker-loader-utils/create-loader-worker.ts
|
|
148
148
|
var import_worker_utils = require("@loaders.gl/worker-utils");
|
|
149
149
|
var requestId = 0;
|
|
150
|
-
function createLoaderWorker(loader) {
|
|
151
|
-
if (!import_worker_utils.WorkerBody.inWorkerThread()) {
|
|
150
|
+
async function createLoaderWorker(loader) {
|
|
151
|
+
if (!await import_worker_utils.WorkerBody.inWorkerThread()) {
|
|
152
152
|
return;
|
|
153
153
|
}
|
|
154
154
|
import_worker_utils.WorkerBody.onmessage = async (type, payload) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buffer.d.ts","sourceRoot":"","sources":["../../../src/lib/node/buffer.ts"],"names":[],"mappings":";AAMA;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,MAAM,KAAA,OAOnC;AAED;;GAEG;AACH,wBAAgB,QAAQ,CAAC,UAAU,EAAE,WAAW,GAAG,MAAM,GAAG,MAAM,
|
|
1
|
+
{"version":3,"file":"buffer.d.ts","sourceRoot":"","sources":["../../../src/lib/node/buffer.ts"],"names":[],"mappings":";AAMA;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,MAAM,KAAA,OAOnC;AAED;;GAEG;AACH,wBAAgB,QAAQ,CAAC,UAAU,EAAE,WAAW,GAAG,MAAM,GAAG,MAAM,CAejE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buffer.js","names":["toArrayBuffer","buffer","Buffer","isBuffer","typedArray","Uint8Array","byteOffset","length","slice","toBuffer","binaryData","ArrayBuffer","isView","from","Error"],"sources":["../../../src/lib/node/buffer.ts"],"sourcesContent":["// loaders.gl, MIT license\n// Copyright (c) vis.gl contributors\n\n// Isolates Buffer references to ensure they are only bundled under Node.js (avoids big webpack polyfill)\n// this file is selected by the package.json \"browser\" field).\n\n/**\n * Convert Buffer to ArrayBuffer\n * Converts Node.js `Buffer` to `ArrayBuffer` (without triggering bundler to include Buffer polyfill on browser)\n * @todo better data type\n */\nexport function toArrayBuffer(buffer) {\n // TODO - per docs we should just be able to call buffer.buffer, but there are issues\n if (Buffer.isBuffer(buffer)) {\n const typedArray = new Uint8Array(buffer.buffer, buffer.byteOffset, buffer.length);\n return typedArray.slice().buffer;\n }\n return buffer;\n}\n\n/**\n * Convert (copy) ArrayBuffer to Buffer\n */\nexport function toBuffer(binaryData: ArrayBuffer | Buffer): Buffer {\n if (Buffer.isBuffer(binaryData)) {\n return binaryData;\n }\n\n if (ArrayBuffer.isView(binaryData)) {\n binaryData = binaryData.buffer;\n }\n\n if (typeof Buffer !== 'undefined' && binaryData instanceof ArrayBuffer) {\n return Buffer.from(binaryData);\n }\n\n throw new Error('toBuffer');\n}\n"],"mappings":"AAWA,OAAO,SAASA,aAAaA,CAACC,MAAM,EAAE;EAEpC,IAAIC,MAAM,CAACC,QAAQ,CAACF,MAAM,CAAC,EAAE;IAC3B,MAAMG,UAAU,GAAG,IAAIC,UAAU,CAACJ,MAAM,CAACA,MAAM,EAAEA,MAAM,CAACK,UAAU,EAAEL,MAAM,CAACM,MAAM,CAAC;IAClF,OAAOH,UAAU,CAACI,KAAK,CAAC,CAAC,CAACP,MAAM;EAClC;EACA,OAAOA,MAAM;AACf;AAKA,OAAO,SAASQ,QAAQA,CAACC,UAAgC,EAAU;EACjE,IAAIR,MAAM,CAACC,QAAQ,CAACO,UAAU,CAAC,EAAE;IAC/B,OAAOA,UAAU;EACnB;EAEA,IAAIC,WAAW,CAACC,MAAM,CAACF,UAAU,CAAC,EAAE;IAClCA,UAAU,GAAGA,UAAU,CAACT,MAAM;EAChC;
|
|
1
|
+
{"version":3,"file":"buffer.js","names":["toArrayBuffer","buffer","Buffer","isBuffer","typedArray","Uint8Array","byteOffset","length","slice","toBuffer","binaryData","ArrayBuffer","isView","from","Error"],"sources":["../../../src/lib/node/buffer.ts"],"sourcesContent":["// loaders.gl, MIT license\n// Copyright (c) vis.gl contributors\n\n// Isolates Buffer references to ensure they are only bundled under Node.js (avoids big webpack polyfill)\n// this file is selected by the package.json \"browser\" field).\n\n/**\n * Convert Buffer to ArrayBuffer\n * Converts Node.js `Buffer` to `ArrayBuffer` (without triggering bundler to include Buffer polyfill on browser)\n * @todo better data type\n */\nexport function toArrayBuffer(buffer) {\n // TODO - per docs we should just be able to call buffer.buffer, but there are issues\n if (Buffer.isBuffer(buffer)) {\n const typedArray = new Uint8Array(buffer.buffer, buffer.byteOffset, buffer.length);\n return typedArray.slice().buffer;\n }\n return buffer;\n}\n\n/**\n * Convert (copy) ArrayBuffer to Buffer\n */\nexport function toBuffer(binaryData: ArrayBuffer | Buffer): Buffer {\n if (Buffer.isBuffer(binaryData)) {\n return binaryData;\n }\n\n if (ArrayBuffer.isView(binaryData)) {\n binaryData = binaryData.buffer;\n }\n\n // TODO - move to loaders.gl/polyfills\n if (typeof Buffer !== 'undefined' && binaryData instanceof ArrayBuffer) {\n return Buffer.from(binaryData);\n }\n\n throw new Error('toBuffer');\n}\n"],"mappings":"AAWA,OAAO,SAASA,aAAaA,CAACC,MAAM,EAAE;EAEpC,IAAIC,MAAM,CAACC,QAAQ,CAACF,MAAM,CAAC,EAAE;IAC3B,MAAMG,UAAU,GAAG,IAAIC,UAAU,CAACJ,MAAM,CAACA,MAAM,EAAEA,MAAM,CAACK,UAAU,EAAEL,MAAM,CAACM,MAAM,CAAC;IAClF,OAAOH,UAAU,CAACI,KAAK,CAAC,CAAC,CAACP,MAAM;EAClC;EACA,OAAOA,MAAM;AACf;AAKA,OAAO,SAASQ,QAAQA,CAACC,UAAgC,EAAU;EACjE,IAAIR,MAAM,CAACC,QAAQ,CAACO,UAAU,CAAC,EAAE;IAC/B,OAAOA,UAAU;EACnB;EAEA,IAAIC,WAAW,CAACC,MAAM,CAACF,UAAU,CAAC,EAAE;IAClCA,UAAU,GAAGA,UAAU,CAACT,MAAM;EAChC;EAGA,IAAI,OAAOC,MAAM,KAAK,WAAW,IAAIQ,UAAU,YAAYC,WAAW,EAAE;IACtE,OAAOT,MAAM,CAACW,IAAI,CAACH,UAAU,CAAC;EAChC;EAEA,MAAM,IAAII,KAAK,CAAC,UAAU,CAAC;AAC7B"}
|
|
@@ -6,6 +6,7 @@ export type DataSourceProps = {
|
|
|
6
6
|
};
|
|
7
7
|
/** base class of all data sources */
|
|
8
8
|
export declare abstract class DataSource<PropsT extends DataSourceProps = DataSourceProps> {
|
|
9
|
+
abstract data: unknown;
|
|
9
10
|
/** A resolved fetch function extracted from loadOptions prop */
|
|
10
11
|
fetch: (url: string, options?: RequestInit) => Promise<Response>;
|
|
11
12
|
/** The actual load options, if calling a loaders.gl loader */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"data-source.d.ts","sourceRoot":"","sources":["../../../src/lib/sources/data-source.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAC,aAAa,EAAC,MAAM,0BAA0B,CAAC;AAE5D,6CAA6C;AAC7C,MAAM,MAAM,eAAe,GAAG;IAC5B,kGAAkG;IAClG,WAAW,CAAC,EAAE,aAAa,CAAC;CAC7B,CAAC;AAEF,qCAAqC;AACrC,8BAAsB,UAAU,CAAC,MAAM,SAAS,eAAe,GAAG,eAAe;IAC/E,gEAAgE;IAChE,KAAK,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,WAAW,KAAK,OAAO,CAAC,QAAQ,CAAC,CAAC;IACjE,8DAA8D;IAC9D,WAAW,EAAE,aAAa,CAAC;IAC3B,aAAa,EAAE,OAAO,CAAQ;IAE9B,KAAK,EAAE,MAAM,CAAC;gBAEF,KAAK,EAAE,MAAM;IAMzB,QAAQ,CAAC,KAAK,EAAE,MAAM;IAMtB,0DAA0D;IAC1D,eAAe,IAAI,IAAI;IAIvB;;;OAGG;IACH,eAAe,CAAC,KAAK,GAAE,OAAc;CAOtC;AAED;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,CAAC,EAAE,aAAa,SAKvC,MAAM,iBAAiB,WAAW,uBAWlD"}
|
|
1
|
+
{"version":3,"file":"data-source.d.ts","sourceRoot":"","sources":["../../../src/lib/sources/data-source.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAC,aAAa,EAAC,MAAM,0BAA0B,CAAC;AAE5D,6CAA6C;AAC7C,MAAM,MAAM,eAAe,GAAG;IAC5B,kGAAkG;IAClG,WAAW,CAAC,EAAE,aAAa,CAAC;CAC7B,CAAC;AAEF,qCAAqC;AACrC,8BAAsB,UAAU,CAAC,MAAM,SAAS,eAAe,GAAG,eAAe;IAC/E,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;IACvB,gEAAgE;IAChE,KAAK,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,WAAW,KAAK,OAAO,CAAC,QAAQ,CAAC,CAAC;IACjE,8DAA8D;IAC9D,WAAW,EAAE,aAAa,CAAC;IAC3B,aAAa,EAAE,OAAO,CAAQ;IAE9B,KAAK,EAAE,MAAM,CAAC;gBAEF,KAAK,EAAE,MAAM;IAMzB,QAAQ,CAAC,KAAK,EAAE,MAAM;IAMtB,0DAA0D;IAC1D,eAAe,IAAI,IAAI;IAIvB;;;OAGG;IACH,eAAe,CAAC,KAAK,GAAE,OAAc;CAOtC;AAED;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,CAAC,EAAE,aAAa,SAKvC,MAAM,iBAAiB,WAAW,uBAWlD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"data-source.js","names":["DataSource","constructor","props","fetch","loadOptions","_needsRefresh","getFetchFunction","setProps","Object","assign","setNeedsRefresh","getNeedsRefresh","clear","arguments","length","undefined","needsRefresh","options","fetchFunction","url","fetchOptions"],"sources":["../../../src/lib/sources/data-source.ts"],"sourcesContent":["// loaders.gl, MIT license\n// Copyright (c) vis.gl contributors\n\nimport type {LoaderOptions} from '@loaders.gl/loader-utils';\n\n/** Common properties for all data sources */\nexport type DataSourceProps = {\n /** LoaderOptions provide an option to override `fetch`. Will also be passed to any sub loaders */\n loadOptions?: LoaderOptions;\n};\n\n/** base class of all data sources */\nexport abstract class DataSource<PropsT extends DataSourceProps = DataSourceProps> {\n /** A resolved fetch function extracted from loadOptions prop */\n fetch: (url: string, options?: RequestInit) => Promise<Response>;\n /** The actual load options, if calling a loaders.gl loader */\n loadOptions: LoaderOptions;\n _needsRefresh: boolean = true;\n\n props: PropsT;\n\n constructor(props: PropsT) {\n this.props = {...props};\n this.loadOptions = {...props.loadOptions};\n this.fetch = getFetchFunction(this.loadOptions);\n }\n\n setProps(props: PropsT) {\n this.props = Object.assign(this.props, props);\n // TODO - add a shallow compare to avoid setting refresh if no change?\n this.setNeedsRefresh();\n }\n\n /** Mark this data source as needing a refresh (redraw) */\n setNeedsRefresh(): void {\n this._needsRefresh = true;\n }\n\n /**\n * Does this data source need refreshing?\n * @note The specifics of the refresh mechanism depends on type of data source\n */\n getNeedsRefresh(clear: boolean = true) {\n const needsRefresh = this._needsRefresh;\n if (clear) {\n this._needsRefresh = false;\n }\n return needsRefresh;\n }\n}\n\n/**\n * Gets the current fetch function from options\n * @todo - move to loader-utils module\n * @todo - use in core module counterpart\n * @param options\n * @param context\n */\nexport function getFetchFunction(options?: LoaderOptions) {\n const fetchFunction = options?.fetch;\n\n // options.fetch can be a function\n if (fetchFunction && typeof fetchFunction === 'function') {\n return (url: string, fetchOptions?: RequestInit) => fetchFunction(url, fetchOptions);\n }\n\n // options.fetch can be an options object, use global fetch with those options\n const fetchOptions = options?.fetch;\n if (fetchOptions && typeof fetchOptions !== 'function') {\n return (url) => fetch(url, fetchOptions);\n }\n\n // else return the global fetch function\n return (url) => fetch(url);\n}\n"],"mappings":"AAYA,OAAO,MAAeA,UAAU,CAAmD;
|
|
1
|
+
{"version":3,"file":"data-source.js","names":["DataSource","constructor","props","data","fetch","loadOptions","_needsRefresh","getFetchFunction","setProps","Object","assign","setNeedsRefresh","getNeedsRefresh","clear","arguments","length","undefined","needsRefresh","options","fetchFunction","url","fetchOptions"],"sources":["../../../src/lib/sources/data-source.ts"],"sourcesContent":["// loaders.gl, MIT license\n// Copyright (c) vis.gl contributors\n\nimport type {LoaderOptions} from '@loaders.gl/loader-utils';\n\n/** Common properties for all data sources */\nexport type DataSourceProps = {\n /** LoaderOptions provide an option to override `fetch`. Will also be passed to any sub loaders */\n loadOptions?: LoaderOptions;\n};\n\n/** base class of all data sources */\nexport abstract class DataSource<PropsT extends DataSourceProps = DataSourceProps> {\n abstract data: unknown;\n /** A resolved fetch function extracted from loadOptions prop */\n fetch: (url: string, options?: RequestInit) => Promise<Response>;\n /** The actual load options, if calling a loaders.gl loader */\n loadOptions: LoaderOptions;\n _needsRefresh: boolean = true;\n\n props: PropsT;\n\n constructor(props: PropsT) {\n this.props = {...props};\n this.loadOptions = {...props.loadOptions};\n this.fetch = getFetchFunction(this.loadOptions);\n }\n\n setProps(props: PropsT) {\n this.props = Object.assign(this.props, props);\n // TODO - add a shallow compare to avoid setting refresh if no change?\n this.setNeedsRefresh();\n }\n\n /** Mark this data source as needing a refresh (redraw) */\n setNeedsRefresh(): void {\n this._needsRefresh = true;\n }\n\n /**\n * Does this data source need refreshing?\n * @note The specifics of the refresh mechanism depends on type of data source\n */\n getNeedsRefresh(clear: boolean = true) {\n const needsRefresh = this._needsRefresh;\n if (clear) {\n this._needsRefresh = false;\n }\n return needsRefresh;\n }\n}\n\n/**\n * Gets the current fetch function from options\n * @todo - move to loader-utils module\n * @todo - use in core module counterpart\n * @param options\n * @param context\n */\nexport function getFetchFunction(options?: LoaderOptions) {\n const fetchFunction = options?.fetch;\n\n // options.fetch can be a function\n if (fetchFunction && typeof fetchFunction === 'function') {\n return (url: string, fetchOptions?: RequestInit) => fetchFunction(url, fetchOptions);\n }\n\n // options.fetch can be an options object, use global fetch with those options\n const fetchOptions = options?.fetch;\n if (fetchOptions && typeof fetchOptions !== 'function') {\n return (url) => fetch(url, fetchOptions);\n }\n\n // else return the global fetch function\n return (url) => fetch(url);\n}\n"],"mappings":"AAYA,OAAO,MAAeA,UAAU,CAAmD;EAUjFC,WAAWA,CAACC,KAAa,EAAE;IAAA,KATlBC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ACgB,GAAG,EAAEC,YAAY,CAAC;EAC1C;EAGA,OAAQD,GAAG,IAAKhB,KAAK,CAACgB,GAAG,CAAC;AAC5B"}
|
|
@@ -23,7 +23,7 @@ export type ImageSourceLayer = {
|
|
|
23
23
|
/** Coordinate systems supported by this layer */
|
|
24
24
|
crs?: string[];
|
|
25
25
|
/** layer limits in unspecified CRS:84-like lng/lat, for quick access w/o CRS calculations. */
|
|
26
|
-
|
|
26
|
+
boundingBox?: [min: [x: number, y: number], max: [x: number, y: number]];
|
|
27
27
|
/** Sub layers of this layer */
|
|
28
28
|
layers?: ImageSourceLayer[];
|
|
29
29
|
};
|
|
@@ -34,27 +34,7 @@ export type GetImageParameters = {
|
|
|
34
34
|
/** Styling */
|
|
35
35
|
styles?: unknown;
|
|
36
36
|
/** bounding box of the requested map image */
|
|
37
|
-
|
|
38
|
-
/** pixel width of returned image */
|
|
39
|
-
width: number;
|
|
40
|
-
/** pixels */
|
|
41
|
-
height: number;
|
|
42
|
-
/** crs for the image (not the bounding box) */
|
|
43
|
-
crs?: string;
|
|
44
|
-
/** requested format for the return image */
|
|
45
|
-
format?: 'image/png';
|
|
46
|
-
};
|
|
47
|
-
export type ImageFilters = {
|
|
48
|
-
/** Layers to render */
|
|
49
|
-
layers: string | string[];
|
|
50
|
-
/** Styling */
|
|
51
|
-
styles?: unknown;
|
|
52
|
-
};
|
|
53
|
-
export type ImageRegion = {
|
|
54
|
-
/** bounding box of the requested map image */
|
|
55
|
-
bbox: [number, number, number, number];
|
|
56
|
-
};
|
|
57
|
-
export type ImageFormat = {
|
|
37
|
+
boundingBox: [min: [x: number, y: number], max: [x: number, y: number]];
|
|
58
38
|
/** pixel width of returned image */
|
|
59
39
|
width: number;
|
|
60
40
|
/** pixels */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"image-source.d.ts","sourceRoot":"","sources":["../../../src/lib/sources/image-source.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAC,eAAe,EAAC,MAA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AS,CAAC;CACtE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"image-source.js","names":["DataSource","ImageSource","type","testURL","url"],"sources":["../../../src/lib/sources/image-source.ts"],"sourcesContent":["// loaders.gl, MIT license\n// Copyright (c) vis.gl contributors\n\nimport type {DataSourceProps} from './data-source';\nimport {DataSource} from './data-source';\nimport {ImageType} from './utils/image-type';\n\n/**\n * Normalized capabilities of an Image service\n * @example\n * The WMSService will normalize the response to the WMS `GetCapabilities`\n * data structure extracted from WMS XML response into an ImageSourceMetadata.\n */\nexport type ImageSourceMetadata = {\n name: string;\n title?: string;\n abstract?: string;\n keywords: string[];\n layers: ImageSourceLayer[];\n};\n\n/** Description of one data layer in the image source */\nexport type ImageSourceLayer = {\n /** Name of this layer */\n name?: string;\n /** Human readable title of this layer */\n title?: string;\n /** Coordinate systems supported by this layer */\n crs?: string[];\n /** layer limits in unspecified CRS:84-like lng/lat, for quick access w/o CRS calculations. */\n
|
|
1
|
+
{"version":3,"file":"image-source.js","names":["DataSource","ImageSource","type","testURL","url"],"sources":["../../../src/lib/sources/image-source.ts"],"sourcesContent":["// loaders.gl, MIT license\n// Copyright (c) vis.gl contributors\n\nimport type {DataSourceProps} from './data-source';\nimport {DataSource} from './data-source';\nimport {ImageType} from './utils/image-type';\n\n/**\n * Normalized capabilities of an Image service\n * @example\n * The WMSService will normalize the response to the WMS `GetCapabilities`\n * data structure extracted from WMS XML response into an ImageSourceMetadata.\n */\nexport type ImageSourceMetadata = {\n name: string;\n title?: string;\n abstract?: string;\n keywords: string[];\n layers: ImageSourceLayer[];\n};\n\n/** Description of one data layer in the image source */\nexport type ImageSourceLayer = {\n /** Name of this layer */\n name?: string;\n /** Human readable title of this layer */\n title?: string;\n /** Coordinate systems supported by this layer */\n crs?: string[];\n /** layer limits in unspecified CRS:84-like lng/lat, for quick access w/o CRS calculations. */\n boundingBox?: [min: [x: number, y: number], max: [x: number, y: number]];\n /** Sub layers of this layer */\n layers?: ImageSourceLayer[];\n};\n\n/** Generic parameters for requesting an image from an image source */\nexport type GetImageParameters = {\n /** Layers to render */\n layers: string | string[];\n /** Styling */\n styles?: unknown;\n /** bounding box of the requested map image */\n boundingBox: [min: [x: number, y: number], max: [x: number, y: number]];\n /** pixel width of returned image */\n width: number;\n /** pixels */\n height: number;\n /** crs for the image (not the bounding box) */\n crs?: string;\n /** requested format for the return image */\n format?: 'image/png';\n};\n\nexport type ImageSourceProps = DataSourceProps;\n\n/**\n * MapImageSource - data sources that allow data to be queried by (geospatial) extents\n * @note\n * - If geospatial, bounding box is expected to be in web mercator coordinates\n */\nexport abstract class ImageSource<\n PropsT extends ImageSourceProps = ImageSourceProps\n> extends DataSource<PropsT> {\n static type: string = 'template';\n static testURL = (url: string): boolean => false;\n\n abstract getMetadata(): Promise<ImageSourceMetadata>;\n abstract getImage(parameters: GetImageParameters): Promise<ImageType>;\n}\n"],"mappings":"SAIQA,UAAU;AAwDlB,OAAO,MAAeC,WAAW,SAEvBD,UAAU,CAAS;AAFPC,WAAW,CAGxBC,IAAI,GAAW,UAAU;AAHZD,WAAW,CAIxBE,OAAO,GAAIC,GAAW,IAAc,KAAK"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { TileSource, GetTileParameters } from './tile-source';
|
|
2
|
+
import { ImageSource, ImageSourceMetadata } from './image-source';
|
|
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
|
+
*/
|
|
8
|
+
export declare class TileSourceAdapter<MetadataT> implements TileSource<ImageSourceMetadata> {
|
|
9
|
+
readonly viewportSource: ImageSource;
|
|
10
|
+
constructor(source: ImageSource);
|
|
11
|
+
getMetadata(): Promise<ImageSourceMetadata>;
|
|
12
|
+
/** Flat parameters */
|
|
13
|
+
getTile(parameters: GetTileParameters): Promise<unknown>;
|
|
14
|
+
/** deck.gl style parameters */
|
|
15
|
+
/** Bounding box of tiles in this tileset `[[w, s], [e, n]]` */
|
|
16
|
+
protected getTileBoundingBox(parameters: GetTileParameters): [min: [x: number, y: number], max: [x: number, y: number]];
|
|
17
|
+
getTileLowerLeftCorner(x: number, y: number, zoom: number): [number, number];
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=tile-source-adapter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tile-source-adapter.d.ts","sourceRoot":"","sources":["../../../src/lib/sources/tile-source-adapter.ts"],"names":[],"mappings":"AAEA,OAAO,EAAC,UAAU,EAAE,iBAAiB,EAAC,MAAM,eAAe,CAAC;AAC5D,OAAO,EAAC,WAAW,EAAE,mBAAmB,EAAC,MAAM,gBAAgB,CAAC;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"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
export class TileSourceAdapter {
|
|
2
|
+
constructor(source) {
|
|
3
|
+
this.viewportSource = void 0;
|
|
4
|
+
this.viewportSource = source;
|
|
5
|
+
}
|
|
6
|
+
async getMetadata() {
|
|
7
|
+
return await this.viewportSource.getMetadata();
|
|
8
|
+
}
|
|
9
|
+
getTile(parameters) {
|
|
10
|
+
const width = 512;
|
|
11
|
+
const height = 512;
|
|
12
|
+
const boundingBox = this.getTileBoundingBox(parameters);
|
|
13
|
+
return this.viewportSource.getImage({
|
|
14
|
+
boundingBox,
|
|
15
|
+
layers: [],
|
|
16
|
+
width,
|
|
17
|
+
height
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
getTileBoundingBox(parameters) {
|
|
21
|
+
if (parameters.crs && parameters.crs !== 'ESPG3758') {
|
|
22
|
+
throw new Error('SRS not ESPG3758');
|
|
23
|
+
}
|
|
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
|
+
}
|
|
39
|
+
//# sourceMappingURL=tile-source-adapter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tile-source-adapter.js","names":["TileSourceAdapter","constructor","source","viewportSource","getMetadata","getTile","parameters","width","height","boundingBox","getTileBoundingBox","getImage","layers","crs","Error","x","y","zoom","getTileLowerLeftCorner","tiles","longitude","latitudeRadians","Math","atan","sinh","PI","latitude"],"sources":["../../../src/lib/sources/tile-source-adapter.ts"],"sourcesContent":["// loaders.gl, MIT license\n\nimport {TileSource, GetTileParameters} from './tile-source';\nimport {ImageSource, ImageSourceMetadata} from './image-source';\n\n/**\n * MapTileSource - data sources that allow data to be queried by (geospatial) extents\n * @note\n * - If geospatial, bounding box is expected to be in web mercator coordinates\n */\nexport class TileSourceAdapter<MetadataT> implements TileSource<ImageSourceMetadata> {\n readonly viewportSource: ImageSource;\n constructor(source: ImageSource) {\n this.viewportSource = source;\n }\n async getMetadata(): Promise<ImageSourceMetadata> {\n return await this.viewportSource.getMetadata();\n }\n /** Flat parameters */\n getTile(parameters: GetTileParameters): Promise<unknown> {\n const width = 512;\n const height = 512;\n const boundingBox = this.getTileBoundingBox(parameters);\n return this.viewportSource.getImage({boundingBox, layers: [], width, height});\n }\n\n /** deck.gl style parameters */\n // getTileData(parameters: TileLoadParameters): Promise<unknown | null> {\n // return this.viewportSource.getImage\n // }\n\n /** Bounding box of tiles in this tileset `[[w, s], [e, n]]` */\n protected getTileBoundingBox(\n parameters: GetTileParameters\n ): [min: [x: number, y: number], max: [x: number, y: number]] {\n if (parameters.crs && parameters.crs !== 'ESPG3758') {\n throw new Error('SRS not ESPG3758');\n }\n const {x, y, zoom} = parameters;\n\n return [\n /** Bounding box of tile in this tileset `[[w, s], ...]` */\n this.getTileLowerLeftCorner(x, y, zoom),\n /** Bounding box of tile in this tileset `[..., [e, n]]` */\n this.getTileLowerLeftCorner(x + 1, y - 1, zoom)\n ];\n }\n\n getTileLowerLeftCorner(x: number, y: number, zoom: number): [number, number] {\n const tiles = 2 ^ zoom;\n const longitude = (x / tiles) * 360.0 - 180.0;\n const latitudeRadians = Math.atan(Math.sinh(Math.PI * (1 - (2 * (y + 1)) / tiles)));\n const latitude = (180.0 * latitudeRadians) / Math.PI;\n return [longitude, latitude];\n }\n}\n"],"mappings":"AAUA,OAAO,MAAMA,iBAAiB,CAAuD;EAEnFC,WAAWA,CAACC,MAAmB,EAAE;IAAA,KADxBC,cAAc;IAErB,IAAI,CAACA,cAAc,GA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GL,eAAe,GAAIC,IAAI,CAACG,EAAE;IACpD,OAAO,CAACL,SAAS,EAAEM,QAAQ,CAAC;EAC9B;AACF"}
|
|
@@ -54,8 +54,8 @@ export type GetTileParameters = {
|
|
|
54
54
|
x: number;
|
|
55
55
|
/** tile y coordinate */
|
|
56
56
|
y: number;
|
|
57
|
-
/**
|
|
58
|
-
|
|
57
|
+
/** Coordinate reference system for the image (not the bounding box) */
|
|
58
|
+
crs?: string;
|
|
59
59
|
/** requested format for the return image */
|
|
60
60
|
format?: 'image/png';
|
|
61
61
|
};
|
|
@@ -100,6 +100,6 @@ export interface TileSource<MetadataT extends TileSourceMetadata> {
|
|
|
100
100
|
/** Flat parameters */
|
|
101
101
|
getTile(parameters: GetTileParameters): Promise<unknown>;
|
|
102
102
|
/** deck.gl style parameters */
|
|
103
|
-
getTileData(parameters: TileLoadParameters): Promise<unknown | null>;
|
|
103
|
+
getTileData?(parameters: TileLoadParameters): Promise<unknown | null>;
|
|
104
104
|
}
|
|
105
105
|
//# sourceMappingURL=tile-source.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tile-source.d.ts","sourceRoot":"","sources":["../../../src/lib/sources/tile-source.ts"],"names":[],"mappings":"AAGA;;;;;;GAMG;AACH,MAAM,MAAM,kBAAkB,GAAG;IAC/B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,YAAY,CAAC,EAAE,OAAO,CAAC;IAEvB,sEAAsE;IACtE,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;IACpB,qEAAqE;IACrE,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;IAExB,kDAAkD;IAClD,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,kDAAkD;IAClD,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,gEAAgE;IAChE,W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,CAAC,SAAS,CAAC,CAAC;IAClC,sBAAsB;IACtB,OAAO,CAAC,UAAU,EAAE,iBAAiB,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IACzD,+BAA+B;IAC/B,WAAW,CAAC,CAAC,UAAU,EAAE,kBAAkB,GAAG,OAAO,CAAC,OAAO,GAAG,IAAI,CAAC,CAAC;CACvE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tile-source.js","names":[],"sources":["../../../src/lib/sources/tile-source.ts"],"sourcesContent":["// loaders.gl, MIT license\n// Copyright (c) vis.gl contributors\n\n/**\n * Normalized capabilities of an Image service\n * Sources are expected to normalize the response to capabilities\n * @example\n * A WMS service would normalize the response to the WMS `GetCapabilities` data structure extracted from WMS XML response\n * into an TileSourceMetadata.\n */\nexport type TileSourceMetadata = {\n format?: string;\n formatHeader?: unknown;\n\n /** Name of the tileset (extracted from JSON metadata if available) */\n name?: string;\n title?: string;\n abstract?: string;\n keywords?: string[];\n /** Attribution string (extracted from JSON metadata if available) */\n attributions?: string[];\n\n /** Minimal zoom level of tiles in this tileset */\n minZoom?: number;\n /** Maximal zoom level of tiles in this tileset */\n maxZoom?: number;\n /** Bounding box of tiles in this tileset `[[w, s], [e, n]]` */\n boundingBox?: [min: [x: number, y: number], max: [x: number, y: number]];\n\n /** Layer information */\n layer?: {\n name: string;\n title?: string;\n srs?: string[];\n boundingBox?: [number, number, number, number];\n layers: TileSourceLayer[];\n };\n};\n\n/**\n * Description of one data layer in the image source\n */\nexport type TileSourceLayer = {\n name: string;\n title?: string;\n srs?: string[];\n boundingBox?: [number, number, number, number];\n layers: TileSourceLayer[];\n};\n\n/**\n * Generic parameters for requesting an image from an image source\n */\nexport type GetTileParameters = {\n /** Layers to render */\n layers: string | string[];\n /** Styling */\n styles?: unknown;\n /** bounding box of the requested map image */\n zoom: number;\n /** tile x coordinate */\n x: number;\n /** tile y coordinate */\n y: number;\n /**
|
|
1
|
+
{"version":3,"file":"tile-source.js","names":[],"sources":["../../../src/lib/sources/tile-source.ts"],"sourcesContent":["// loaders.gl, MIT license\n// Copyright (c) vis.gl contributors\n\n/**\n * Normalized capabilities of an Image service\n * Sources are expected to normalize the response to capabilities\n * @example\n * A WMS service would normalize the response to the WMS `GetCapabilities` data structure extracted from WMS XML response\n * into an TileSourceMetadata.\n */\nexport type TileSourceMetadata = {\n format?: string;\n formatHeader?: unknown;\n\n /** Name of the tileset (extracted from JSON metadata if available) */\n name?: string;\n title?: string;\n abstract?: string;\n keywords?: string[];\n /** Attribution string (extracted from JSON metadata if available) */\n attributions?: string[];\n\n /** Minimal zoom level of tiles in this tileset */\n minZoom?: number;\n /** Maximal zoom level of tiles in this tileset */\n maxZoom?: number;\n /** Bounding box of tiles in this tileset `[[w, s], [e, n]]` */\n boundingBox?: [min: [x: number, y: number], max: [x: number, y: number]];\n\n /** Layer information */\n layer?: {\n name: string;\n title?: string;\n srs?: string[];\n boundingBox?: [number, number, number, number];\n layers: TileSourceLayer[];\n };\n};\n\n/**\n * Description of one data layer in the image source\n */\nexport type TileSourceLayer = {\n name: string;\n title?: string;\n srs?: string[];\n boundingBox?: [number, number, number, number];\n layers: TileSourceLayer[];\n};\n\n/**\n * Generic parameters for requesting an image from an image source\n */\nexport type GetTileParameters = {\n /** Layers to render */\n layers: string | string[];\n /** Styling */\n styles?: unknown;\n /** bounding box of the requested map image */\n zoom: number;\n /** tile x coordinate */\n x: number;\n /** tile y coordinate */\n y: number;\n /** Coordinate reference system for the image (not the bounding box) */\n crs?: string;\n /** requested format for the return image */\n format?: 'image/png';\n};\n\nexport type TileLoadParameters = {\n index: {x: number; y: number; z: number};\n id: string;\n bbox: TileBoundingBox;\n zoom?: number;\n url?: string | null;\n signal?: AbortSignal;\n userData?: Record<string, any>;\n};\n\n/** deck.gl compatible bounding box */\nexport type TileBoundingBox = NonGeoBoundingBox | GeoBoundingBox;\nexport type GeoBoundingBox = {west: number; north: number; east: number; south: number};\nexport type NonGeoBoundingBox = {left: number; top: number; right: number; bottom: number};\n\n/**\n * Props for a TileSource\n */\nexport type TileSourceProps = {};\n\n/**\n * MapTileSource - data sources that allow data to be queried by (geospatial) extents\n * @note\n * - If geospatial, bounding box is expected to be in web mercator coordinates\n */\nexport interface TileSource<MetadataT extends TileSourceMetadata> {\n getMetadata(): Promise<MetadataT>;\n /** Flat parameters */\n getTile(parameters: GetTileParameters): Promise<unknown>;\n /** deck.gl style parameters */\n getTileData?(parameters: TileLoadParameters): Promise<unknown | null>;\n}\n"],"mappings":""}
|
|
@@ -3,5 +3,5 @@ import type { LoaderWithParser } from '../../loader-types';
|
|
|
3
3
|
* Set up a WebWorkerGlobalScope to talk with the main thread
|
|
4
4
|
* @param loader
|
|
5
5
|
*/
|
|
6
|
-
export declare function createLoaderWorker(loader: LoaderWithParser): void
|
|
6
|
+
export declare function createLoaderWorker(loader: LoaderWithParser): Promise<void>;
|
|
7
7
|
//# sourceMappingURL=create-loader-worker.d.ts.map
|
|
@@ -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,MAAM,oBAAoB,CAAC;AAMvF;;;GAGG;AACH,
|
|
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,MAAM,oBAAoB,CAAC;AAMvF;;;GAGG;AACH,wBAAsB,kBAAkB,CAAC,MAAM,EAAE,gBAAgB,iBAiChE"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { WorkerBody } from '@loaders.gl/worker-utils';
|
|
2
2
|
let requestId = 0;
|
|
3
|
-
export function createLoaderWorker(loader) {
|
|
4
|
-
if (!WorkerBody.inWorkerThread()) {
|
|
3
|
+
export async function createLoaderWorker(loader) {
|
|
4
|
+
if (!(await WorkerBody.inWorkerThread())) {
|
|
5
5
|
return;
|
|
6
6
|
}
|
|
7
7
|
WorkerBody.onmessage = async (type, payload) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-loader-worker.js","names":["WorkerBody","requestId","createLoaderWorker","loader","inWorkerThread","onmessage","type","payload","input","options","context","result","parseData","arrayBuffer","_parse","parseOnMainThread","postMessage","error","message","Error","Promise","resolve","reject","id","onMessage","removeEventListener","addEventListener","_ref","data","parser","parseSync","parse","parseTextSync","textDecoder","TextDecoder","decode","name","modules","worker"],"sources":["../../../src/lib/worker-loader-utils/create-loader-worker.ts"],"sourcesContent":["/* eslint-disable no-restricted-globals */\nimport type {LoaderWithParser, LoaderOptions, LoaderContext} from '../../loader-types';\nimport {WorkerBody} from '@loaders.gl/worker-utils';\n// import {validateLoaderVersion} from './validate-loader-version';\n\nlet requestId = 0;\n\n/**\n * Set up a WebWorkerGlobalScope to talk with the main thread\n * @param loader\n */\nexport function createLoaderWorker(loader: LoaderWithParser) {\n // Check that we are actually in a worker thread\n if (!WorkerBody.inWorkerThread()) {\n return;\n }\n\n WorkerBody.onmessage = async (type, payload) => {\n switch (type) {\n case 'process':\n try {\n // validateLoaderVersion(loader, data.source.split('@')[1]);\n\n const {input, options = {}, context = {}} = payload;\n\n const result = await parseData({\n loader,\n arrayBuffer: input,\n options,\n // @ts-expect-error fetch missing\n context: {\n ...context,\n _parse: parseOnMainThread\n }\n });\n WorkerBody.postMessage('done', {result});\n } catch (error) {\n const message = error instanceof Error ? error.message : '';\n WorkerBody.postMessage('error', {error: message});\n }\n break;\n default:\n }\n };\n}\n\nfunction parseOnMainThread(\n arrayBuffer: ArrayBuffer,\n loader: any,\n options?: LoaderOptions,\n context?: LoaderContext\n): Promise<void> {\n return new Promise((resolve, reject) => {\n const id = requestId++;\n\n /**\n */\n const onMessage = (type, payload) => {\n if (payload.id !== id) {\n // not ours\n return;\n }\n\n switch (type) {\n case 'done':\n WorkerBody.removeEventListener(onMessage);\n resolve(payload.result);\n break;\n\n case 'error':\n WorkerBody.removeEventListener(onMessage);\n reject(payload.error);\n break;\n\n default:\n // ignore\n }\n };\n\n WorkerBody.addEventListener(onMessage);\n\n // Ask the main thread to decode data\n const payload = {id, input: arrayBuffer, options};\n WorkerBody.postMessage('process', payload);\n });\n}\n\n// TODO - Support byteOffset and byteLength (enabling parsing of embedded binaries without copies)\n// TODO - Why not support async loader.parse* funcs here?\n// TODO - Why not reuse a common function instead of reimplementing loader.parse* selection logic? Keeping loader small?\n// TODO - Lack of appropriate parser functions can be detected when we create worker, no need to wait until parse\nasync function parseData({\n loader,\n arrayBuffer,\n options,\n context\n}: {\n loader: LoaderWithParser;\n arrayBuffer: ArrayBuffer;\n options: LoaderOptions;\n context: LoaderContext;\n}) {\n let data;\n let parser;\n if (loader.parseSync || loader.parse) {\n data = arrayBuffer;\n parser = loader.parseSync || loader.parse;\n } else if (loader.parseTextSync) {\n const textDecoder = new TextDecoder();\n data = textDecoder.decode(arrayBuffer);\n parser = loader.parseTextSync;\n } else {\n throw new Error(`Could not load data with ${loader.name} loader`);\n }\n\n // TODO - proper merge in of loader options...\n options = {\n ...options,\n modules: (loader && loader.options && loader.options.modules) || {},\n worker: false\n };\n\n return await parser(data, {...options}, context, loader);\n}\n"],"mappings":"AAEA,SAAQA,UAAU,QAAO,0BAA0B;AAGnD,IAAIC,SAAS,GAAG,CAAC;AAMjB,OAAO,
|
|
1
|
+
{"version":3,"file":"create-loader-worker.js","names":["WorkerBody","requestId","createLoaderWorker","loader","inWorkerThread","onmessage","type","payload","input","options","context","result","parseData","arrayBuffer","_parse","parseOnMainThread","postMessage","error","message","Error","Promise","resolve","reject","id","onMessage","removeEventListener","addEventListener","_ref","data","parser","parseSync","parse","parseTextSync","textDecoder","TextDecoder","decode","name","modules","worker"],"sources":["../../../src/lib/worker-loader-utils/create-loader-worker.ts"],"sourcesContent":["/* eslint-disable no-restricted-globals */\nimport type {LoaderWithParser, LoaderOptions, LoaderContext} from '../../loader-types';\nimport {WorkerBody} from '@loaders.gl/worker-utils';\n// import {validateLoaderVersion} from './validate-loader-version';\n\nlet requestId = 0;\n\n/**\n * Set up a WebWorkerGlobalScope to talk with the main thread\n * @param loader\n */\nexport async function createLoaderWorker(loader: LoaderWithParser) {\n // Check that we are actually in a worker thread\n if (!(await WorkerBody.inWorkerThread())) {\n return;\n }\n\n WorkerBody.onmessage = async (type, payload) => {\n switch (type) {\n case 'process':\n try {\n // validateLoaderVersion(loader, data.source.split('@')[1]);\n\n const {input, options = {}, context = {}} = payload;\n\n const result = await parseData({\n loader,\n arrayBuffer: input,\n options,\n // @ts-expect-error fetch missing\n context: {\n ...context,\n _parse: parseOnMainThread\n }\n });\n WorkerBody.postMessage('done', {result});\n } catch (error) {\n const message = error instanceof Error ? error.message : '';\n WorkerBody.postMessage('error', {error: message});\n }\n break;\n default:\n }\n };\n}\n\nfunction parseOnMainThread(\n arrayBuffer: ArrayBuffer,\n loader: any,\n options?: LoaderOptions,\n context?: LoaderContext\n): Promise<void> {\n return new Promise((resolve, reject) => {\n const id = requestId++;\n\n /**\n */\n const onMessage = (type, payload) => {\n if (payload.id !== id) {\n // not ours\n return;\n }\n\n switch (type) {\n case 'done':\n WorkerBody.removeEventListener(onMessage);\n resolve(payload.result);\n break;\n\n case 'error':\n WorkerBody.removeEventListener(onMessage);\n reject(payload.error);\n break;\n\n default:\n // ignore\n }\n };\n\n WorkerBody.addEventListener(onMessage);\n\n // Ask the main thread to decode data\n const payload = {id, input: arrayBuffer, options};\n WorkerBody.postMessage('process', payload);\n });\n}\n\n// TODO - Support byteOffset and byteLength (enabling parsing of embedded binaries without copies)\n// TODO - Why not support async loader.parse* funcs here?\n// TODO - Why not reuse a common function instead of reimplementing loader.parse* selection logic? Keeping loader small?\n// TODO - Lack of appropriate parser functions can be detected when we create worker, no need to wait until parse\nasync function parseData({\n loader,\n arrayBuffer,\n options,\n context\n}: {\n loader: LoaderWithParser;\n arrayBuffer: ArrayBuffer;\n options: LoaderOptions;\n context: LoaderContext;\n}) {\n let data;\n let parser;\n if (loader.parseSync || loader.parse) {\n data = arrayBuffer;\n parser = loader.parseSync || loader.parse;\n } else if (loader.parseTextSync) {\n const textDecoder = new TextDecoder();\n data = textDecoder.decode(arrayBuffer);\n parser = loader.parseTextSync;\n } else {\n throw new Error(`Could not load data with ${loader.name} loader`);\n }\n\n // TODO - proper merge in of loader options...\n options = {\n ...options,\n modules: (loader && loader.options && loader.options.modules) || {},\n worker: false\n };\n\n return await parser(data, {...options}, context, loader);\n}\n"],"mappings":"AAEA,SAAQA,UAAU,QAAO,0BAA0B;AAGnD,IAAIC,SAAS,GAAG,CAAC;AAMjB,OAAO,eAAeC,kBAAkBA,CAACC,MAAwB,EAAE;EAEjE,IAAI,EAAE,MAAMH,UAAU,CAACI,cAAc,CAAC,CAAC,CAAC,EAAE;IACxC;EACF;EAEAJ,UAAU,CAACK,SAAS,GAAG,OAAOC,IAAI,EAAEC,OAAO,KAAK;IAC9C,QAAQD,IAAI;MACV,KAAK,SAAS;QACZ,IAAI;UAGF,MAAM;YAACE,KAAK;YAAEC,OAAO,GAAG,CAAC,CAAC;YAAEC,OAAO,GAAG,CAAC;UAAC,CAAC,GAAGH,OAAO;UAEnD,MAAMI,MAAM,GAAG,MAAMC,SAAS,CAAC;YAC7BT,MAAM;YACNU,WAAW,EAAEL,KAAK;YAClBC,OAAO;YAEPC,OAAO,EAAE;cACP,GAAGA,OAAO;cACVI,MAAM,EAAEC;YACV;UACF,CAAC,CAAC;UACFf,UAAU,CAACgB,WAAW,CAAC,MAAM,EAAE;YAACL;UAAM,CAAC,CAAC;QAC1C,CAAC,CAAC,OAAOM,KAAK,EAAE;UACd,MAAMC,OAAO,GAAGD,KAAK,YAAYE,KAAK,GAAGF,KAAK,CAACC,OAAO,GAAG,EAAE;UAC3DlB,UAAU,CAACgB,WAAW,CAAC,OAAO,EAAE;YAACC,KAAK,EAAEC;UAAO,CAAC,CAAC;QACnD;QACA;MACF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C,CAAC,KAAK,EAAE,KAAK,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IACrE,cAAc,CAAC,CAAC,KAAK,EAAE,KAAK,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,MAAM,CAAC;IAEhE,eAAe,CAAC,CAAC,IAAI,EAAE,aAAa,CAAC,GAAG,CAAC,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,aAAa,CAAC,WAAW,CAAC,CAAC;IAEjG,cAAc,CAAC,EAAE,CACf,QAAQ,EAAE,MAAM,EAChB,SAAS,EAAE,MAAM,EACjB,OAAO,CAAC,EAAE,cAAc,KACrB,OAAO,CAAC,MAAM,CAAC,CAAC;CACtB,CAAC;AAEF,sFAAsF;AACtF,MAAM,MAAM,iBAAiB,CAAC,CAAC,GAAG,MAAM,IAAI,CAAC,SAAS,MAAM,CAAC,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC,GACzF,OAAO,GACP,KAAK,CAAC"}
|
package/dist/writer-types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"writer-types.js","names":[],"sources":["../src/writer-types.ts"],"sourcesContent":["// loaders.gl, MIT license\n// Copyright (c) vis.gl contributors\n\n// WRITERS\n\n/** Options for writers */\nexport type WriterOptions = {\n /** worker source. If is set will be used instead of loading worker from the Internet */\n source?: string | null;\n /** Force to load WASM libraries from local file system in NodeJS or from loaders.gl CDN in a web browser */\n useLocalLibraries?: boolean;\n /** writer-specific options */\n [writerId: string]: any;\n};\n\n/**\n * A writer definition that can be used with `@loaders.gl/core` functions\n */\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\nexport type Writer<DataT = unknown, BatchT = unknown, WriterOptionsT = WriterOptions> = {\n name: string;\n\n id: string;\n module: string;\n version: string;\n worker?: string | boolean;\n\n // TODO - are these are needed?\n extensions?: string[];\n mimeTypes?: string[];\n binary?: boolean;\n text?: boolean;\n\n options: WriterOptionsT;\n deprecatedOptions?: Record<string, string>;\n\n
|
|
1
|
+
{"version":3,"file":"writer-types.js","names":[],"sources":["../src/writer-types.ts"],"sourcesContent":["// loaders.gl, MIT license\n// Copyright (c) vis.gl contributors\n\n// WRITERS\n\n/** Options for writers */\nexport type WriterOptions = {\n /** worker source. If is set will be used instead of loading worker from the Internet */\n source?: string | null;\n /** Force to load WASM libraries from local file system in NodeJS or from loaders.gl CDN in a web browser */\n useLocalLibraries?: boolean;\n /** writer-specific options */\n [writerId: string]: any;\n};\n\n/**\n * A writer definition that can be used with `@loaders.gl/core` functions\n */\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\nexport type Writer<DataT = unknown, BatchT = unknown, WriterOptionsT = WriterOptions> = {\n name: string;\n\n id: string;\n module: string;\n version: string;\n worker?: string | boolean;\n\n // TODO - are these are needed?\n extensions?: string[];\n mimeTypes?: string[];\n binary?: boolean;\n text?: boolean;\n\n options: WriterOptionsT;\n deprecatedOptions?: Record<string, string>;\n\n encode?(data: DataT, options?: WriterOptionsT): Promise<ArrayBuffer>;\n encodeSync?(data: DataT, options?: WriterOptionsT): ArrayBuffer;\n\n encodeText?(table: DataT, options?: WriterOptionsT): Promise<string>;\n encodeTextSync?(table: DataT, options?: WriterOptionsT): string;\n\n encodeInBatches?(data: AsyncIterable<any>, options?: WriterOptionsT): AsyncIterable<ArrayBuffer>;\n\n encodeURLtoURL?: (\n inputUrl: string,\n outputUrl: string,\n options?: WriterOptionsT\n ) => Promise<string>;\n};\n\n/** Typescript helper to extract the writer options type from a generic writer type */\nexport type WriterOptionsType<T = Writer> = T extends Writer<unknown, unknown, infer Options>\n ? Options\n : never;\n"],"mappings":""}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@loaders.gl/loader-utils",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.2",
|
|
4
4
|
"description": "Framework-independent loaders for 3D graphics formats",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -47,8 +47,8 @@
|
|
|
47
47
|
"scripts": {},
|
|
48
48
|
"dependencies": {
|
|
49
49
|
"@babel/runtime": "^7.3.1",
|
|
50
|
-
"@loaders.gl/worker-utils": "4.0.
|
|
50
|
+
"@loaders.gl/worker-utils": "4.0.2",
|
|
51
51
|
"@probe.gl/stats": "^4.0.2"
|
|
52
52
|
},
|
|
53
|
-
"gitHead": "
|
|
53
|
+
"gitHead": "471058d109d5652f28c32c1f296fd632f9a5c806"
|
|
54
54
|
}
|
package/src/lib/node/buffer.ts
CHANGED
|
@@ -30,6 +30,7 @@ export function toBuffer(binaryData: ArrayBuffer | Buffer): Buffer {
|
|
|
30
30
|
binaryData = binaryData.buffer;
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
+
// TODO - move to loaders.gl/polyfills
|
|
33
34
|
if (typeof Buffer !== 'undefined' && binaryData instanceof ArrayBuffer) {
|
|
34
35
|
return Buffer.from(binaryData);
|
|
35
36
|
}
|
|
@@ -11,6 +11,7 @@ export type DataSourceProps = {
|
|
|
11
11
|
|
|
12
12
|
/** base class of all data sources */
|
|
13
13
|
export abstract class DataSource<PropsT extends DataSourceProps = DataSourceProps> {
|
|
14
|
+
abstract data: unknown;
|
|
14
15
|
/** A resolved fetch function extracted from loadOptions prop */
|
|
15
16
|
fetch: (url: string, options?: RequestInit) => Promise<Response>;
|
|
16
17
|
/** The actual load options, if calling a loaders.gl loader */
|
|
@@ -28,7 +28,7 @@ export type ImageSourceLayer = {
|
|
|
28
28
|
/** Coordinate systems supported by this layer */
|
|
29
29
|
crs?: string[];
|
|
30
30
|
/** layer limits in unspecified CRS:84-like lng/lat, for quick access w/o CRS calculations. */
|
|
31
|
-
|
|
31
|
+
boundingBox?: [min: [x: number, y: number], max: [x: number, y: number]];
|
|
32
32
|
/** Sub layers of this layer */
|
|
33
33
|
layers?: ImageSourceLayer[];
|
|
34
34
|
};
|
|
@@ -40,31 +40,7 @@ export type GetImageParameters = {
|
|
|
40
40
|
/** Styling */
|
|
41
41
|
styles?: unknown;
|
|
42
42
|
/** bounding box of the requested map image */
|
|
43
|
-
|
|
44
|
-
/** pixel width of returned image */
|
|
45
|
-
width: number;
|
|
46
|
-
/** pixels */
|
|
47
|
-
height: number;
|
|
48
|
-
/** crs for the image (not the bounding box) */
|
|
49
|
-
crs?: string;
|
|
50
|
-
/** requested format for the return image */
|
|
51
|
-
format?: 'image/png';
|
|
52
|
-
};
|
|
53
|
-
|
|
54
|
-
// Attempt to break down GetImageParameters
|
|
55
|
-
export type ImageFilters = {
|
|
56
|
-
/** Layers to render */
|
|
57
|
-
layers: string | string[];
|
|
58
|
-
/** Styling */
|
|
59
|
-
styles?: unknown;
|
|
60
|
-
};
|
|
61
|
-
|
|
62
|
-
export type ImageRegion = {
|
|
63
|
-
/** bounding box of the requested map image */
|
|
64
|
-
bbox: [number, number, number, number];
|
|
65
|
-
};
|
|
66
|
-
|
|
67
|
-
export type ImageFormat = {
|
|
43
|
+
boundingBox: [min: [x: number, y: number], max: [x: number, y: number]];
|
|
68
44
|
/** pixel width of returned image */
|
|
69
45
|
width: number;
|
|
70
46
|
/** pixels */
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
// loaders.gl, MIT license
|
|
2
|
+
|
|
3
|
+
import {TileSource, GetTileParameters} from './tile-source';
|
|
4
|
+
import {ImageSource, ImageSourceMetadata} from './image-source';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* MapTileSource - data sources that allow data to be queried by (geospatial) extents
|
|
8
|
+
* @note
|
|
9
|
+
* - If geospatial, bounding box is expected to be in web mercator coordinates
|
|
10
|
+
*/
|
|
11
|
+
export class TileSourceAdapter<MetadataT> implements TileSource<ImageSourceMetadata> {
|
|
12
|
+
readonly viewportSource: ImageSource;
|
|
13
|
+
constructor(source: ImageSource) {
|
|
14
|
+
this.viewportSource = source;
|
|
15
|
+
}
|
|
16
|
+
async getMetadata(): Promise<ImageSourceMetadata> {
|
|
17
|
+
return await this.viewportSource.getMetadata();
|
|
18
|
+
}
|
|
19
|
+
/** Flat parameters */
|
|
20
|
+
getTile(parameters: GetTileParameters): Promise<unknown> {
|
|
21
|
+
const width = 512;
|
|
22
|
+
const height = 512;
|
|
23
|
+
const boundingBox = this.getTileBoundingBox(parameters);
|
|
24
|
+
return this.viewportSource.getImage({boundingBox, layers: [], width, height});
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/** deck.gl style parameters */
|
|
28
|
+
// getTileData(parameters: TileLoadParameters): Promise<unknown | null> {
|
|
29
|
+
// return this.viewportSource.getImage
|
|
30
|
+
// }
|
|
31
|
+
|
|
32
|
+
/** Bounding box of tiles in this tileset `[[w, s], [e, n]]` */
|
|
33
|
+
protected getTileBoundingBox(
|
|
34
|
+
parameters: GetTileParameters
|
|
35
|
+
): [min: [x: number, y: number], max: [x: number, y: number]] {
|
|
36
|
+
if (parameters.crs && parameters.crs !== 'ESPG3758') {
|
|
37
|
+
throw new Error('SRS not ESPG3758');
|
|
38
|
+
}
|
|
39
|
+
const {x, y, zoom} = parameters;
|
|
40
|
+
|
|
41
|
+
return [
|
|
42
|
+
/** Bounding box of tile in this tileset `[[w, s], ...]` */
|
|
43
|
+
this.getTileLowerLeftCorner(x, y, zoom),
|
|
44
|
+
/** Bounding box of tile in this tileset `[..., [e, n]]` */
|
|
45
|
+
this.getTileLowerLeftCorner(x + 1, y - 1, zoom)
|
|
46
|
+
];
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
getTileLowerLeftCorner(x: number, y: number, zoom: number): [number, number] {
|
|
50
|
+
const tiles = 2 ^ zoom;
|
|
51
|
+
const longitude = (x / tiles) * 360.0 - 180.0;
|
|
52
|
+
const latitudeRadians = Math.atan(Math.sinh(Math.PI * (1 - (2 * (y + 1)) / tiles)));
|
|
53
|
+
const latitude = (180.0 * latitudeRadians) / Math.PI;
|
|
54
|
+
return [longitude, latitude];
|
|
55
|
+
}
|
|
56
|
+
}
|
|
@@ -62,8 +62,8 @@ export type GetTileParameters = {
|
|
|
62
62
|
x: number;
|
|
63
63
|
/** tile y coordinate */
|
|
64
64
|
y: number;
|
|
65
|
-
/**
|
|
66
|
-
|
|
65
|
+
/** Coordinate reference system for the image (not the bounding box) */
|
|
66
|
+
crs?: string;
|
|
67
67
|
/** requested format for the return image */
|
|
68
68
|
format?: 'image/png';
|
|
69
69
|
};
|
|
@@ -98,5 +98,5 @@ export interface TileSource<MetadataT extends TileSourceMetadata> {
|
|
|
98
98
|
/** Flat parameters */
|
|
99
99
|
getTile(parameters: GetTileParameters): Promise<unknown>;
|
|
100
100
|
/** deck.gl style parameters */
|
|
101
|
-
getTileData(parameters: TileLoadParameters): Promise<unknown | null>;
|
|
101
|
+
getTileData?(parameters: TileLoadParameters): Promise<unknown | null>;
|
|
102
102
|
}
|
|
@@ -9,9 +9,9 @@ let requestId = 0;
|
|
|
9
9
|
* Set up a WebWorkerGlobalScope to talk with the main thread
|
|
10
10
|
* @param loader
|
|
11
11
|
*/
|
|
12
|
-
export function createLoaderWorker(loader: LoaderWithParser) {
|
|
12
|
+
export async function createLoaderWorker(loader: LoaderWithParser) {
|
|
13
13
|
// Check that we are actually in a worker thread
|
|
14
|
-
if (!WorkerBody.inWorkerThread()) {
|
|
14
|
+
if (!(await WorkerBody.inWorkerThread())) {
|
|
15
15
|
return;
|
|
16
16
|
}
|
|
17
17
|
|
package/src/writer-types.ts
CHANGED
|
@@ -34,8 +34,6 @@ export type Writer<DataT = unknown, BatchT = unknown, WriterOptionsT = WriterOpt
|
|
|
34
34
|
options: WriterOptionsT;
|
|
35
35
|
deprecatedOptions?: Record<string, string>;
|
|
36
36
|
|
|
37
|
-
// encodeText?: EncodeText;
|
|
38
|
-
// encode?: Encode;
|
|
39
37
|
encode?(data: DataT, options?: WriterOptionsT): Promise<ArrayBuffer>;
|
|
40
38
|
encodeSync?(data: DataT, options?: WriterOptionsT): ArrayBuffer;
|
|
41
39
|
|