@loaders.gl/loader-utils 4.3.0-alpha.2 → 4.3.0-alpha.4

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.
Files changed (57) hide show
  1. package/dist/index.cjs +121 -3
  2. package/dist/index.cjs.map +3 -3
  3. package/dist/index.d.ts +7 -3
  4. package/dist/index.d.ts.map +1 -1
  5. package/dist/index.js +3 -1
  6. package/dist/json-loader.js +1 -1
  7. package/dist/lib/file-provider/data-view-file.d.ts +2 -2
  8. package/dist/lib/file-provider/data-view-file.d.ts.map +1 -1
  9. package/dist/lib/file-provider/file-handle-file.d.ts +2 -2
  10. package/dist/lib/file-provider/file-handle-file.d.ts.map +1 -1
  11. package/dist/lib/file-provider/file-provider-interface.d.ts +45 -0
  12. package/dist/lib/file-provider/file-provider-interface.d.ts.map +1 -0
  13. package/dist/lib/file-provider/file-provider-interface.js +9 -0
  14. package/dist/lib/file-provider/file-provider.d.ts +28 -17
  15. package/dist/lib/file-provider/file-provider.d.ts.map +1 -1
  16. package/dist/lib/file-provider/file-provider.js +111 -7
  17. package/dist/lib/log-utils/log.js +1 -1
  18. package/dist/lib/sources/data-source.d.ts +1 -0
  19. package/dist/lib/sources/data-source.d.ts.map +1 -1
  20. package/dist/lib/sources/image-source.d.ts +11 -13
  21. package/dist/lib/sources/image-source.d.ts.map +1 -1
  22. package/dist/lib/sources/image-source.js +1 -3
  23. package/dist/lib/sources/image-tile-source.d.ts +4 -2
  24. package/dist/lib/sources/image-tile-source.d.ts.map +1 -1
  25. package/dist/lib/sources/tile-source-adapter.d.ts.map +1 -1
  26. package/dist/lib/sources/tile-source-adapter.js +1 -0
  27. package/dist/lib/sources/tile-source.d.ts +18 -14
  28. package/dist/lib/sources/tile-source.d.ts.map +1 -1
  29. package/dist/lib/sources/utils/utils.d.ts +1 -1
  30. package/dist/lib/sources/utils/utils.d.ts.map +1 -1
  31. package/dist/lib/sources/utils/utils.js +1 -1
  32. package/dist/lib/sources/vector-source.d.ts +61 -0
  33. package/dist/lib/sources/vector-source.d.ts.map +1 -0
  34. package/dist/lib/sources/vector-source.js +13 -0
  35. package/dist/lib/sources/vector-tile-source.d.ts +1 -1
  36. package/dist/lib/sources/vector-tile-source.d.ts.map +1 -1
  37. package/dist/source-types.d.ts +39 -0
  38. package/dist/source-types.d.ts.map +1 -0
  39. package/package.json +5 -4
  40. package/src/index.ts +8 -3
  41. package/src/lib/file-provider/data-view-file.ts +2 -2
  42. package/src/lib/file-provider/file-handle-file.ts +2 -2
  43. package/src/lib/file-provider/file-provider-interface.ts +56 -0
  44. package/src/lib/file-provider/file-provider.ts +98 -25
  45. package/src/lib/sources/data-source.ts +1 -0
  46. package/src/lib/sources/image-source.ts +19 -18
  47. package/src/lib/sources/image-tile-source.ts +8 -3
  48. package/src/lib/sources/tile-source-adapter.ts +1 -0
  49. package/src/lib/sources/tile-source.ts +26 -19
  50. package/src/lib/sources/utils/utils.ts +1 -1
  51. package/src/lib/sources/vector-source.ts +74 -0
  52. package/src/lib/sources/vector-tile-source.ts +4 -2
  53. package/src/source-types.ts +49 -0
  54. package/dist/service-types.d.ts +0 -10
  55. package/dist/service-types.d.ts.map +0 -1
  56. package/src/service-types.ts +0 -14
  57. /package/dist/{service-types.js → source-types.js} +0 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@loaders.gl/loader-utils",
3
- "version": "4.3.0-alpha.2",
3
+ "version": "4.3.0-alpha.4",
4
4
  "description": "Framework-independent loaders for 3D graphics formats",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -45,12 +45,13 @@
45
45
  "stream": false
46
46
  },
47
47
  "dependencies": {
48
- "@loaders.gl/schema": "4.3.0-alpha.2",
49
- "@loaders.gl/worker-utils": "4.3.0-alpha.2",
48
+ "@loaders.gl/schema": "4.3.0-alpha.4",
49
+ "@loaders.gl/worker-utils": "4.3.0-alpha.4",
50
+ "@probe.gl/log": "^4.0.2",
50
51
  "@probe.gl/stats": "^4.0.2"
51
52
  },
52
53
  "peerDependencies": {
53
54
  "@loaders.gl/core": "^4.0.0"
54
55
  },
55
- "gitHead": "77a3cb538ab7a1fbf74245f25590210451689f5c"
56
+ "gitHead": "4900ac4c4de20366c050b80cef04dc5b52d167af"
56
57
  }
package/src/index.ts CHANGED
@@ -133,13 +133,14 @@ export type {FileSystem, RandomAccessFileSystem} from './lib/filesystems/filesys
133
133
  export {NodeFileSystemFacade as NodeFilesystem} from './lib/filesystems/node-filesystem-facade';
134
134
 
135
135
  // TODO - replace with ReadableFile
136
- export type {FileProvider} from './lib/file-provider/file-provider';
137
- export {isFileProvider} from './lib/file-provider/file-provider';
136
+ export type {FileProviderInterface} from './lib/file-provider/file-provider-interface';
137
+ export {isFileProvider} from './lib/file-provider/file-provider-interface';
138
+ export {FileProvider} from './lib/file-provider/file-provider';
138
139
  export {FileHandleFile} from './lib/file-provider/file-handle-file';
139
140
  export {DataViewFile} from './lib/file-provider/data-view-file';
140
141
 
141
142
  // EXPERIMENTAL: DATA SOURCES
142
- export type {Service} from './service-types';
143
+ export type {Source} from './source-types';
143
144
 
144
145
  export type {DataSourceProps} from './lib/sources/data-source';
145
146
  export {DataSource} from './lib/sources/data-source';
@@ -149,6 +150,10 @@ export type {ImageType} from './lib/sources/utils/image-type';
149
150
  export type {ImageSourceProps, ImageSourceMetadata} from './lib/sources/image-source';
150
151
  export type {GetImageParameters} from './lib/sources/image-source';
151
152
 
153
+ export {VectorSource} from './lib/sources/vector-source';
154
+ export type {VectorSourceProps, VectorSourceMetadata} from './lib/sources/vector-source';
155
+ export type {GetFeaturesParameters} from './lib/sources/vector-source';
156
+
152
157
  export type {TileSource, TileSourceProps} from './lib/sources/tile-source';
153
158
  export type {TileSourceMetadata, GetTileParameters} from './lib/sources/tile-source';
154
159
  export type {GetTileDataParameters} from './lib/sources/tile-source';
@@ -1,4 +1,4 @@
1
- import {FileProvider} from './file-provider';
1
+ import {FileProviderInterface} from './file-provider-interface';
2
2
 
3
3
  /**
4
4
  * Checks if bigint can be converted to number and convert it if possible
@@ -16,7 +16,7 @@ const toNumber = (bigint: bigint) => {
16
16
  * Provides file data using DataView
17
17
  * @deprecated - will be replaced with ReadableFile
18
18
  */
19
- export class DataViewFile implements FileProvider {
19
+ export class DataViewFile implements FileProviderInterface {
20
20
  /** The DataView from which data is provided */
21
21
  private file: DataView;
22
22
 
@@ -2,14 +2,14 @@
2
2
  // SPDX-License-Identifier: MIT
3
3
  // Copyright (c) vis.gl contributors
4
4
 
5
- import {FileProvider} from './file-provider';
5
+ import {FileProviderInterface} from './file-provider-interface';
6
6
  import {NodeFileFacade as NodeFile} from '../files/node-file-facade';
7
7
 
8
8
  /**
9
9
  * Provides file data using node fs library
10
10
  * @deprecated - will be replaced with ReadableFile
11
11
  */
12
- export class FileHandleFile implements FileProvider {
12
+ export class FileHandleFile implements FileProviderInterface {
13
13
  /** The FileHandle from which data is provided */
14
14
  private file: NodeFile;
15
15
 
@@ -0,0 +1,56 @@
1
+ /**
2
+ * Interface for providing file data
3
+ */
4
+ export interface FileProviderInterface {
5
+ /**
6
+ * Cleanup class data
7
+ */
8
+ destroy(): Promise<void>;
9
+ /**
10
+ * Gets an unsigned 8-bit integer at the specified byte offset from the start of the file.
11
+ * @param offset The offset, in bytes, from the start of the file where to read the data.
12
+ */
13
+ getUint8(offset: bigint): Promise<number>;
14
+
15
+ /**
16
+ * Gets an unsigned 16-bit integer at the specified byte offset from the start of the file.
17
+ * @param offset The offset, in bytes, from the start of the file where to read the data.
18
+ */
19
+ getUint16(offset: bigint): Promise<number>;
20
+
21
+ /**
22
+ * Gets an unsigned 32-bit integer at the specified byte offset from the start of the file.
23
+ * @param offset The offset, in bytes, from the file of the view where to read the data.
24
+ */
25
+ getUint32(offset: bigint): Promise<number>;
26
+
27
+ /**
28
+ * Gets an unsigned 32-bit integer at the specified byte offset from the start of the file.
29
+ * @param offset The offset, in byte, from the file of the view where to read the data.
30
+ */
31
+ getBigUint64(offset: bigint): Promise<bigint>;
32
+
33
+ /**
34
+ * returns an ArrayBuffer whose contents are a copy of this file bytes from startOffset, inclusive, up to endOffset, exclusive.
35
+ * @param startOffset The offset, in bytes, from the start of the file where to start reading the data.
36
+ * @param endOffset The offset, in bytes, from the start of the file where to end reading the data.
37
+ */
38
+ slice(startOffset: bigint, endOffset: bigint): Promise<ArrayBuffer>;
39
+
40
+ /**
41
+ * the length (in bytes) of the data.
42
+ */
43
+ length: bigint;
44
+ }
45
+
46
+ /**
47
+ * Check is the object has FileProvider members
48
+ * @param fileProvider - tested object
49
+ */
50
+ export const isFileProvider = (fileProvider: unknown) => {
51
+ return (
52
+ (fileProvider as FileProviderInterface)?.getUint8 &&
53
+ (fileProvider as FileProviderInterface)?.slice &&
54
+ (fileProvider as FileProviderInterface)?.length
55
+ );
56
+ };
@@ -1,57 +1,130 @@
1
+ // loaders.gl
2
+ // SPDX-License-Identifier: MIT
3
+ // Copyright (c) vis.gl contributors
4
+ import {ReadableFile} from '../files/file';
5
+ import {FileProviderInterface} from './file-provider-interface';
6
+
1
7
  /**
2
- * Interface for providing file data
8
+ * Provides file data using range requests to the server
3
9
  * @deprecated - will be replaced with ReadableFile
4
10
  */
5
- export interface FileProvider {
11
+ export class FileProvider implements FileProviderInterface {
12
+ /** The File object from which data is provided */
13
+ private file: ReadableFile;
14
+ private size: bigint;
15
+
16
+ /** Create a new BrowserFile */
17
+ private constructor(file: ReadableFile, size: bigint | number) {
18
+ this.file = file;
19
+ this.size = BigInt(size);
20
+ }
21
+
22
+ static async create(file: ReadableFile): Promise<FileProvider> {
23
+ let size: bigint | number = 0n;
24
+ if (file.bigsize > 0n) {
25
+ size = file.bigsize;
26
+ } else if (file.size > 0) {
27
+ size = file.size;
28
+ } else {
29
+ const stats = await file.stat?.();
30
+ size = stats?.bigsize ?? 0n;
31
+ }
32
+
33
+ return new FileProvider(file, size);
34
+ }
35
+
36
+ /**
37
+ * Truncates the file descriptor.
38
+ * @param length desired file lenght
39
+ */
40
+ async truncate(length: number): Promise<void> {
41
+ throw new Error('file loaded via range requests cannot be changed');
42
+ }
43
+
6
44
  /**
7
- * Cleanup class data
45
+ * Append data to a file.
46
+ * @param buffer data to append
8
47
  */
9
- destroy(): Promise<void>;
48
+ async append(buffer: Uint8Array): Promise<void> {
49
+ throw new Error('file loaded via range requests cannot be changed');
50
+ }
51
+
52
+ /** Close file */
53
+ async destroy(): Promise<void> {
54
+ throw new Error('file loaded via range requests cannot be changed');
55
+ }
56
+
10
57
  /**
11
58
  * Gets an unsigned 8-bit integer at the specified byte offset from the start of the file.
12
59
  * @param offset The offset, in bytes, from the start of the file where to read the data.
13
60
  */
14
- getUint8(offset: bigint): Promise<number>;
61
+ async getUint8(offset: number | bigint): Promise<number> {
62
+ const arrayBuffer = await this.file.read(offset, 1);
63
+ const val = new Uint8Array(arrayBuffer).at(0);
64
+ if (val === undefined) {
65
+ throw new Error('something went wrong');
66
+ }
67
+ return val;
68
+ }
15
69
 
16
70
  /**
17
71
  * Gets an unsigned 16-bit integer at the specified byte offset from the start of the file.
18
72
  * @param offset The offset, in bytes, from the start of the file where to read the data.
19
73
  */
20
- getUint16(offset: bigint): Promise<number>;
74
+ async getUint16(offset: number | bigint): Promise<number> {
75
+ const arrayBuffer = await this.file.read(offset, 2);
76
+ const val = new Uint16Array(arrayBuffer).at(0);
77
+ if (val === undefined) {
78
+ throw new Error('something went wrong');
79
+ }
80
+ return val;
81
+ }
21
82
 
22
83
  /**
23
84
  * Gets an unsigned 32-bit integer at the specified byte offset from the start of the file.
24
- * @param offset The offset, in bytes, from the file of the view where to read the data.
85
+ * @param offset The offset, in bytes, from the start of the file where to read the data.
25
86
  */
26
- getUint32(offset: bigint): Promise<number>;
87
+ async getUint32(offset: number | bigint): Promise<number> {
88
+ const arrayBuffer = await this.file.read(offset, 4);
89
+ const val = new Uint32Array(arrayBuffer).at(0);
90
+ if (val === undefined) {
91
+ throw new Error('something went wrong');
92
+ }
93
+ return val;
94
+ }
27
95
 
28
96
  /**
29
97
  * Gets an unsigned 32-bit integer at the specified byte offset from the start of the file.
30
- * @param offset The offset, in byte, from the file of the view where to read the data.
98
+ * @param offset The offset, in bytes, from the start of the file where to read the data.
31
99
  */
32
- getBigUint64(offset: bigint): Promise<bigint>;
100
+ async getBigUint64(offset: number | bigint): Promise<bigint> {
101
+ const arrayBuffer = await this.file.read(offset, 8);
102
+ const val = new BigInt64Array(arrayBuffer).at(0);
103
+ if (val === undefined) {
104
+ throw new Error('something went wrong');
105
+ }
106
+ return val;
107
+ }
33
108
 
34
109
  /**
35
110
  * returns an ArrayBuffer whose contents are a copy of this file bytes from startOffset, inclusive, up to endOffset, exclusive.
36
- * @param startOffset The offset, in bytes, from the start of the file where to start reading the data.
111
+ * @param startOffset The offset, in byte, from the start of the file where to start reading the data.
37
112
  * @param endOffset The offset, in bytes, from the start of the file where to end reading the data.
38
113
  */
39
- slice(startOffset: bigint, endOffset: bigint): Promise<ArrayBuffer>;
114
+ async slice(startOffset: bigint | number, endOffset: bigint | number): Promise<ArrayBuffer> {
115
+ const bigLength = BigInt(endOffset) - BigInt(startOffset);
116
+ if (bigLength > Number.MAX_SAFE_INTEGER) {
117
+ throw new Error('too big slice');
118
+ }
119
+ const length = Number(bigLength);
120
+
121
+ return await this.file.read(startOffset, length);
122
+ }
40
123
 
41
124
  /**
42
125
  * the length (in bytes) of the data.
43
126
  */
44
- length: bigint;
127
+ get length(): bigint {
128
+ return this.size;
129
+ }
45
130
  }
46
-
47
- /**
48
- * Check is the object has FileProvider members
49
- * @param fileProvider - tested object
50
- */
51
- export const isFileProvider = (fileProvider: unknown) => {
52
- return (
53
- (fileProvider as FileProvider)?.getUint8 &&
54
- (fileProvider as FileProvider)?.slice &&
55
- (fileProvider as FileProvider)?.length
56
- );
57
- };
@@ -6,6 +6,7 @@ import type {LoaderOptions} from '@loaders.gl/loader-utils';
6
6
 
7
7
  /** Common properties for all data sources */
8
8
  export type DataSourceProps = {
9
+ url?: string | Blob;
9
10
  /** LoaderOptions provide an option to override `fetch`. Will also be passed to any sub loaders */
10
11
  loadOptions?: LoaderOptions;
11
12
  };
@@ -4,12 +4,30 @@
4
4
 
5
5
  import type {DataSourceProps} from './data-source';
6
6
  import {DataSource} from './data-source';
7
+ // TODO - can we import from schema?
7
8
  import {ImageType} from './utils/image-type';
8
9
 
10
+ export type ImageSourceProps = DataSourceProps;
11
+
12
+ /**
13
+ * ImageSource - data sources that allow images to be queried by (geospatial) extents
14
+ */
15
+ export abstract class ImageSource<
16
+ PropsT extends ImageSourceProps = ImageSourceProps
17
+ > extends DataSource<PropsT> {
18
+ static type: string = 'template';
19
+ static testURL = (url: string): boolean => false;
20
+
21
+ abstract getMetadata(): Promise<ImageSourceMetadata>;
22
+ abstract getImage(parameters: GetImageParameters): Promise<ImageType>;
23
+ }
24
+
25
+ // PARAMETER TYPES
26
+
9
27
  /**
10
28
  * Normalized capabilities of an Image service
11
29
  * @example
12
- * The WMSService will normalize the response to the WMS `GetCapabilities`
30
+ * The WMSSourceLoader will normalize the response to the WMS `GetCapabilities`
13
31
  * data structure extracted from WMS XML response into an ImageSourceMetadata.
14
32
  */
15
33
  export type ImageSourceMetadata = {
@@ -53,20 +71,3 @@ export type GetImageParameters = {
53
71
  /** requested format for the return image */
54
72
  format?: 'image/png';
55
73
  };
56
-
57
- export type ImageSourceProps = DataSourceProps;
58
-
59
- /**
60
- * MapImageSource - data sources that allow data to be queried by (geospatial) extents
61
- * @note
62
- * - If geospatial, bounding box is expected to be in web mercator coordinates
63
- */
64
- export abstract class ImageSource<
65
- PropsT extends ImageSourceProps = ImageSourceProps
66
- > extends DataSource<PropsT> {
67
- static type: string = 'template';
68
- static testURL = (url: string): boolean => false;
69
-
70
- abstract getMetadata(): Promise<ImageSourceMetadata>;
71
- abstract getImage(parameters: GetImageParameters): Promise<ImageType>;
72
- }
@@ -3,13 +3,18 @@
3
3
  // Copyright (c) vis.gl contributors
4
4
 
5
5
  import type {ImageType} from './utils/image-type';
6
- import type {TileSource, TileSourceMetadata, GetTileParameters} from './tile-source';
6
+ import type {TileSourceProps, TileSourceMetadata, GetTileParameters} from './tile-source';
7
+ import type {TileSource} from './tile-source';
8
+
9
+ export type ImageTileSourceProps = TileSourceProps;
7
10
 
8
11
  /**
9
12
  * MapTileSource - data sources that allow data to be queried by (geospatial) tile
10
13
  * @note If geospatial, bounding box is expected to be in web mercator coordinates
11
14
  */
12
- export interface ImageTileSource<MetadataT extends TileSourceMetadata = TileSourceMetadata>
13
- extends TileSource<MetadataT> {
15
+ export interface ImageTileSource<
16
+ PropsT extends TileSourceProps = TileSourceProps,
17
+ MetadataT extends TileSourceMetadata = TileSourceMetadata
18
+ > extends TileSource<PropsT, MetadataT> {
14
19
  getImageTile(parameters: GetTileParameters): Promise<ImageType | null>;
15
20
  }
@@ -9,6 +9,7 @@ import {ImageSource, ImageSourceMetadata} from './image-source';
9
9
  * @note
10
10
  * - If geospatial, bounding box is expected to be in web mercator coordinates
11
11
  */
12
+ // @ts-expect-error TODO - does not implement all DataSource members
12
13
  export class TileSourceAdapter implements TileSource<ImageSourceMetadata> {
13
14
  readonly viewportSource: ImageSource;
14
15
  constructor(source: ImageSource) {
@@ -2,8 +2,32 @@
2
2
  // SPDX-License-Identifier: MIT
3
3
  // Copyright (c) vis.gl contributors
4
4
 
5
- // import type {DataSourceProps} from './data-source';
6
- // import {DataSource} from './data-source';
5
+ import type {DataSourceProps} from './data-source';
6
+ import {DataSource} from './data-source';
7
+
8
+ /**
9
+ * Props for a TileSource
10
+ */
11
+ export type TileSourceProps = DataSourceProps;
12
+
13
+ /**
14
+ * MapTileSource - data sources that allow data to be queried by (geospatial) extents
15
+ * @note
16
+ * - If geospatial, bounding box is expected to be in web mercator coordinates
17
+ */
18
+ export interface TileSource<
19
+ PropsT extends TileSourceProps = TileSourceProps,
20
+ MetadataT extends TileSourceMetadata = TileSourceMetadata
21
+ > extends DataSource<PropsT> {
22
+ // extends DataSource {
23
+ getMetadata(): Promise<MetadataT>;
24
+ /** Flat parameters */
25
+ getTile(parameters: GetTileParameters): Promise<unknown | null>;
26
+ /** deck.gl compatibility: TileLayer and MTVLayer */
27
+ getTileData(parameters: GetTileDataParameters): Promise<unknown | null>;
28
+ }
29
+
30
+ // HELPER TYPES
7
31
 
8
32
  /**
9
33
  * Normalized capabilities of an tile service
@@ -89,20 +113,3 @@ export type TileBoundingBox = NonGeoBoundingBox | GeoBoundingBox;
89
113
  export type GeoBoundingBox = {west: number; north: number; east: number; south: number};
90
114
  /** deck.gl compatibility: bounding box */
91
115
  export type NonGeoBoundingBox = {left: number; top: number; right: number; bottom: number};
92
-
93
- /** Props for a TileSource */
94
- export type TileSourceProps = {}; // DataSourceProps;
95
-
96
- /**
97
- * MapTileSource - data sources that allow data to be queried by (geospatial) extents
98
- * @note
99
- * - If geospatial, bounding box is expected to be in web mercator coordinates
100
- */
101
- export interface TileSource<MetadataT extends TileSourceMetadata> {
102
- // extends DataSource {
103
- getMetadata(): Promise<MetadataT>;
104
- /** Flat parameters */
105
- getTile(parameters: GetTileParameters): Promise<unknown | null>;
106
- /** deck.gl compatibility: TileLayer and MTVLayer */
107
- getTileData(parameters: GetTileDataParameters): Promise<unknown | null>;
108
- }
@@ -29,7 +29,7 @@ export function getFetchFunction(options?: LoaderOptions) {
29
29
  return (url) => fetch(url);
30
30
  }
31
31
 
32
- export function mergeImageServiceProps<Props extends {loadOptions?: any}>(
32
+ export function mergeImageSourceLoaderProps<Props extends {loadOptions?: any}>(
33
33
  props: Props
34
34
  ): Required<Props> {
35
35
  // @ts-expect-error
@@ -0,0 +1,74 @@
1
+ // loaders.gl
2
+ // SPDX-License-Identifier: MIT
3
+ // Copyright (c) vis.gl contributors
4
+
5
+ import type {Schema, GeoJSONTable, BinaryFeatureCollection} from '@loaders.gl/schema';
6
+ import type {DataSourceProps} from './data-source';
7
+ import {DataSource} from './data-source';
8
+
9
+ export type VectorSourceProps = DataSourceProps;
10
+
11
+ /**
12
+ * VectorSource - data sources that allow features to be queried by (geospatial) extents
13
+ * @note
14
+ * - If geospatial, bounding box is expected to be in web mercator coordinates
15
+ */
16
+ export abstract class VectorSource<
17
+ PropsT extends VectorSourceProps = VectorSourceProps
18
+ > extends DataSource<PropsT> {
19
+ static type: string = 'template';
20
+ static testURL = (url: string): boolean => false;
21
+
22
+ abstract getSchema(): Promise<Schema>;
23
+ abstract getMetadata(options: {formatSpecificMetadata?: boolean}): Promise<VectorSourceMetadata>;
24
+ abstract getFeatures(
25
+ parameters: GetFeaturesParameters
26
+ ): Promise<GeoJSONTable | BinaryFeatureCollection>;
27
+ }
28
+
29
+ // PARAMETER TYPES
30
+
31
+ /**
32
+ * Normalized capabilities of an Image service
33
+ * @example
34
+ * The WMSSourceLoader will normalize the response to the WMS `GetCapabilities`
35
+ * data structure extracted from WMS XML response into an VectorSourceMetadata.
36
+ */
37
+ export type VectorSourceMetadata = {
38
+ name: string;
39
+ title?: string;
40
+ abstract?: string;
41
+ keywords: string[];
42
+ layers: VectorSourceLayer[];
43
+ /**
44
+ * Attempts to preserve the original format specific metadata from the underlying source,
45
+ * May be an approximate representation
46
+ */
47
+ formatSpecificMetadata?: Record<string, any>;
48
+ };
49
+
50
+ /** Description of one data layer in the image source */
51
+ export type VectorSourceLayer = {
52
+ /** Name of this layer */
53
+ name?: string;
54
+ /** Human readable title of this layer */
55
+ title?: string;
56
+ /** Coordinate systems supported by this layer */
57
+ crs?: string[];
58
+ /** layer limits in unspecified CRS:84-like lng/lat, for quick access w/o CRS calculations. */
59
+ boundingBox?: [min: [x: number, y: number], max: [x: number, y: number]];
60
+ /** Sub layers of this layer */
61
+ layers?: VectorSourceLayer[];
62
+ };
63
+
64
+ /** Generic parameters for requesting an image from an image source */
65
+ export type GetFeaturesParameters = {
66
+ /** Layers to render */
67
+ layers: string | string[];
68
+ /** bounding box on the map (only return features within this bbox) */
69
+ boundingBox: [min: [x: number, y: number], max: [x: number, y: number]];
70
+ /** crs for the returned features (not the bounding box) */
71
+ crs?: string;
72
+ /** @deprecated requested format for the return image */
73
+ format?: 'geojson' | 'binary';
74
+ };
@@ -14,8 +14,10 @@ export type VectorTileSourceProps = TileSourceProps;
14
14
  * VectorTileSource - data sources that allow data to be queried by (geospatial) tile
15
15
  * @note If geospatial, bounding box is expected to be in web mercator coordinates
16
16
  */
17
- export interface VectorTileSource<MetadataT extends TileSourceMetadata = TileSourceMetadata>
18
- extends TileSource<MetadataT> {
17
+ export interface VectorTileSource<
18
+ PropsT extends VectorTileSourceProps = VectorTileSourceProps,
19
+ MetadataT extends TileSourceMetadata = TileSourceMetadata
20
+ > extends TileSource<PropsT, MetadataT> {
19
21
  getSchema(): Promise<Schema>;
20
22
  getVectorTile(parameters: GetTileParameters): Promise<VectorTile | null>;
21
23
  getTileData(
@@ -0,0 +1,49 @@
1
+ // loaders.gl
2
+ // SPDX-License-Identifier: MIT
3
+ // Copyright (c) vis.gl contributors
4
+
5
+ import type {DataSource, DataSourceProps} from './lib/sources/data-source';
6
+
7
+ /**
8
+ * A `Source` contains metadata and a factory method for creating instances of a specific `DataSource`.
9
+ * It allows a list of `Source` objects to be passed to methods
10
+ * @example
11
+ * `createDataSource(... , [MVTSource, PMTilesSource, ...])
12
+ */
13
+ export interface Source<
14
+ DataSourceT extends DataSource = DataSource,
15
+ DataSourcePropsT extends DataSourceProps = any
16
+ > {
17
+ /** Type of source created by this service */
18
+ source?: DataSourceT;
19
+ /** Type of props used when creating sources */
20
+ props?: DataSourcePropsT;
21
+
22
+ /** Name of the service */
23
+ name: string;
24
+ id: string;
25
+ /** Module containing the service */
26
+ module: string;
27
+ /** Version of the loaders.gl package containing this service. */
28
+ version: string;
29
+ /** URL extensions that this service uses */
30
+ extensions: string[];
31
+ /** MIME extensions that this service uses */
32
+ mimeTypes: string[];
33
+ /** Default options */
34
+ options: DataSourcePropsT;
35
+
36
+ /** Type string identifying this service, e.g. 'wms' */
37
+ type: string;
38
+ /** Can source be created from a URL */
39
+ fromUrl: boolean;
40
+ /** Can source be created from a Blob or File */
41
+ fromBlob: boolean;
42
+
43
+ /** Check if a URL can support this service */
44
+ testURL: (url: string) => boolean;
45
+ /** Test data */
46
+ testData?: (data: Blob) => boolean;
47
+ /** Create a source */
48
+ createDataSource(data: string | Blob, props: DataSourcePropsT): DataSourceT;
49
+ }
@@ -1,10 +0,0 @@
1
- import type { ImageSource, ImageSourceProps } from "./lib/sources/image-source.js";
2
- /** Export interface source */
3
- export interface Service<SourceT = ImageSource, SourcePropsT = ImageSourceProps> {
4
- source?: SourceT;
5
- props?: SourcePropsT;
6
- type: string;
7
- testURL: (url: string) => boolean;
8
- create(props: SourcePropsT): SourceT;
9
- }
10
- //# sourceMappingURL=service-types.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"service-types.d.ts","sourceRoot":"","sources":["../src/service-types.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAC,WAAW,EAAE,gBAAgB,EAAC,sCAAmC;AAE9E,8BAA8B;AAC9B,MAAM,WAAW,OAAO,CAAC,OAAO,GAAG,WAAW,EAAE,YAAY,GAAG,gBAAgB;IAC7E,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,KAAK,CAAC,EAAE,YAAY,CAAC;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC;IAClC,MAAM,CAAC,KAAK,EAAE,YAAY,GAAG,OAAO,CAAC;CACtC"}
@@ -1,14 +0,0 @@
1
- // loaders.gl
2
- // SPDX-License-Identifier: MIT
3
- // Copyright (c) vis.gl contributors
4
-
5
- import type {ImageSource, ImageSourceProps} from './lib/sources/image-source';
6
-
7
- /** Export interface source */
8
- export interface Service<SourceT = ImageSource, SourcePropsT = ImageSourceProps> {
9
- source?: SourceT;
10
- props?: SourcePropsT;
11
- type: string;
12
- testURL: (url: string) => boolean;
13
- create(props: SourcePropsT): SourceT;
14
- }
File without changes