@loaders.gl/loader-utils 4.0.0 → 4.0.1

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.
@@ -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,5 +1,6 @@
1
1
  export class DataSource {
2
2
  constructor(props) {
3
+ this.data = void 0;
3
4
  this.fetch = void 0;
4
5
  this.loadOptions = void 0;
5
6
  this._needsRefresh = true;
@@ -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;EASjFC,WAAWA,CAACC,KAAa,EAAE;IAAA,KAP3BC,KAAK;IAAA,KAELC,WAAW;IAAA,KACXC,aAAa,GAAY,IAAI;IAA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GAAG,CAAC;AAC5B"}
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,IAAI;IAAA,KAEbC,KAAK;IAAA,KAELC,WAAW;IAAA,KACXC,aAAa,GAAY,IAAI;IAAA,KAE7BJ,KAAK;IAGH,IAAI,CAACA,KAAK,GAAG;MAAC,GAAGA;IAAK,CAAC;IACvB,IAAI,CAACG,WAAW,GAAG;MAAC,GAAGH,KAAK,CAACG;IAAW,CAAC;IACzC,IAAI,CAACD,KAAK,GAAGG,gBAAgB,CAAC,IAAI,CAACF,WAAW,CAAC;EACjD;EAEAG,QAAQA,CAACN,KAAa,EAAE;IACtB,IAAI,CAACA,KAAK,GAAGO,MAAM,CAACC,MAAM,CAAC,IAAI,CAACR,KAAK,EAAEA,KAAK,CAAC;IAE7C,IAAI,CAACS,eAAe,CAAC,CAAC;EACxB;EAGAA,eAAeA,CAAA,EAAS;IACtB,IAAI,CAACL,aAAa,GAAG,IAAI;EAC3B;EAMAM,eAAeA,CAAA,EAAwB;IAAA,IAAvBC,KAAc,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,IAAI;IACnC,MAAMG,YAAY,GAAG,IAAI,CAACX,aAAa;IACvC,IAAIO,KAAK,EAAE;MACT,IAAI,CAACP,aAAa,GAAG,KAAK;IAC5B;IACA,OAAOW,YAAY;EACrB;AACF;AASA,OAAO,SAASV,gBAAgBA,CAACW,OAAuB,EAAE;EACxD,MAAMC,aAAa,GAAGD,OAAO,aAAPA,OAAO,uBAAPA,OAAO,CAAEd,KAAK;EAGpC,IAAIe,aAAa,IAAI,OAAOA,aAAa,KAAK,UAAU,EAAE;IACxD,OAAO,CAACC,GAAW,EAAEC,YAA0B,KAAKF,aAAa,CAACC,GAAG,EAAEC,YAAY,CAAC;EACtF;EAGA,MAAMA,YAAY,GAAGH,OAAO,aAAPA,OAAO,uBAAPA,OAAO,CAAEd,KAAK;EACnC,IAAIiB,YAAY,IAAI,OAAOA,YAAY,KAAK,UAAU,EAAE;IACtD,OAAQD,GAAG,IAAKhB,KAAK,CAACgB,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
- geographicBoundingBox?: [min: [x: number, y: number], max: [x: number, y: number]];
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
- bbox: [number, number, number, number];
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,EA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;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 +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 geographicBoundingBox?: [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 bbox: [number, number, number, 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\n// Attempt to break down GetImageParameters\nexport type ImageFilters = {\n /** Layers to render */\n layers: string | string[];\n /** Styling */\n styles?: unknown;\n};\n\nexport type ImageRegion = {\n /** bounding box of the requested map image */\n bbox: [number, number, number, number];\n};\n\nexport type ImageFormat = {\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;AAgFlB,OAAO,MAAeC,WAAW,SAEvBD,UAAU,CAAS;AAFPC,WAAW,CAGxBC,IAAI,GAAW,UAAU;AAHZD,WAAW,CAIxBE,OAAO,GAAIC,GAAW,IAAc,KAAK"}
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,GAAGD,MAAM;EAC9B;EACA,MAAME,WAAWA,CAAA,EAAiC;IAChD,OAAO,MAAM,IAAI,CAACD,cAAc,CAACC,WAAW,CAAC,CAAC;EAChD;EAEAC,OAAOA,CAACC,UAA6B,EAAoB;IACvD,MAAMC,KAAK,GAAG,GAAG;IACjB,MAAMC,MAAM,GAAG,GAAG;IAClB,MAAMC,WAAW,GAAG,IAAI,CAACC,kBAAkB,CAACJ,UAAU,CAAC;IACvD,OAAO,IAAI,CAACH,cAAc,CAACQ,QAAQ,CAAC;MAACF,WAAW;MAAEG,MAAM,EAAE,EAAE;MAAEL,KAAK;MAAEC;IAAM,CAAC,CAAC;EAC/E;EAQUE,kBAAkBA,CAC1BJ,UAA6B,EAC+B;IAC5D,IAAIA,UAAU,CAACO,GAAG,IAAIP,UAAU,CAACO,GAAG,KAAK,UAAU,EAAE;MACnD,MAAM,IAAIC,KAAK,CAAC,kBAAkB,CAAC;IACrC;IACA,MAAM;MAACC,CAAC;MAAEC,CAAC;MAAEC;IAAI,CAAC,GAAGX,UAAU;IAE/B,OAAO,CAEL,IAAI,CAACY,sBAAsB,CAACH,CAAC,EAAEC,CAAC,EAAEC,IAAI,CAAC,EAEvC,IAAI,CAACC,sBAAsB,CAACH,CAAC,GAAG,CAAC,EAAEC,CAAC,GAAG,CAAC,EAAEC,IAAI,CAAC,CAChD;EACH;EAEAC,sBAAsBA,CAACH,CAAS,EAAEC,CAAS,EAAEC,IAAY,EAAoB;IAC3E,MAAME,KAAK,GAAG,CAAC,GAAGF,IAAI;IACtB,MAAMG,SAAS,GAAIL,CAAC,GAAGI,KAAK,GAAI,KAAK,GAAG,KAAK;IAC7C,MAAME,eAAe,GAAGC,IAAI,CAACC,IAAI,CAACD,IAAI,CAACE,IAAI,CAACF,IAAI,CAACG,EAAE,IAAI,CAAC,GAAI,CAAC,IAAIT,CAAC,GAAG,CAAC,CAAC,GAAIG,KAAK,CAAC,CAAC,CAAC;IACnF,MAAMO,QAAQ,GAAI,KAAK,GAAGL,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
- /** srs for the image (not the bounding box) */
58
- srs?: string;
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,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;IAEzE,wBAAwB;IACxB,KAAK,CAAC,EAAE;QACN,IAAI,EAAE,MAAM,CAAC;QACb,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,GAAG,CAAC,EAAE,MAAM,EAAE,CAAC;QACf,WAAW,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;QAC/C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;QAAC,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAA;KAAC,CAAC;IACzC,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,eAAe,CAAC;IACtB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,GAAG,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACpB,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;CAChC,CAAC;AAEF,sCAAsC;AACtC,MAAM,MAAM,eAAe,GAAG,iBAAiB,GAAG,cAAc,CAAC;AACjE,MAAM,MAAM,cAAc,GAAG;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAC,CAAC;AACxF,MAAM,MAAM,iBAAiB,GAAG;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAC,CAAC;AAE3F;;GAEG;AACH,MAAM,MAAM,eAAe,GAAG,EAAE,CAAC;AAEjC;;;;GAIG;AACH,MAAM,WAAW,UAAU,CAAC,SAAS,SAAS,kBAAkB;IAC9D,WAAW,IAAI,OAAO,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 /** srs for the image (not the bounding box) */\n srs?: 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":""}
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":""}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@loaders.gl/loader-utils",
3
- "version": "4.0.0",
3
+ "version": "4.0.1",
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.0",
50
+ "@loaders.gl/worker-utils": "4.0.1",
51
51
  "@probe.gl/stats": "^4.0.2"
52
52
  },
53
- "gitHead": "9b4211dc0ecd4134a1638ac0a29c5ea9008fd971"
53
+ "gitHead": "765e5a26a6bf3f2cc02cabffc4a1e3665ec92a53"
54
54
  }
@@ -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
- geographicBoundingBox?: [min: [x: number, y: number], max: [x: number, y: number]];
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
- bbox: [number, number, number, number];
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
- /** srs for the image (not the bounding box) */
66
- srs?: string;
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
  }