@loaders.gl/loader-utils 4.3.0-alpha.1 → 4.3.0-alpha.3
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 +122 -4
- package/dist/index.cjs.map +4 -4
- package/dist/index.d.ts +8 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -1
- package/dist/json-loader.js +1 -1
- package/dist/lib/file-provider/data-view-file.d.ts +2 -2
- package/dist/lib/file-provider/data-view-file.d.ts.map +1 -1
- package/dist/lib/file-provider/file-handle-file.d.ts +2 -2
- package/dist/lib/file-provider/file-handle-file.d.ts.map +1 -1
- package/dist/lib/file-provider/file-provider-interface.d.ts +45 -0
- package/dist/lib/file-provider/file-provider-interface.d.ts.map +1 -0
- package/dist/lib/file-provider/file-provider-interface.js +9 -0
- package/dist/lib/file-provider/file-provider.d.ts +28 -17
- package/dist/lib/file-provider/file-provider.d.ts.map +1 -1
- package/dist/lib/file-provider/file-provider.js +104 -7
- package/dist/lib/log-utils/log.d.ts +0 -1
- package/dist/lib/log-utils/log.d.ts.map +1 -1
- package/dist/lib/log-utils/log.js +12 -3
- 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/image-source.d.ts +11 -13
- package/dist/lib/sources/image-source.d.ts.map +1 -1
- package/dist/lib/sources/image-source.js +1 -3
- package/dist/lib/sources/image-tile-source.d.ts +4 -3
- package/dist/lib/sources/image-tile-source.d.ts.map +1 -1
- package/dist/lib/sources/tile-source-adapter.d.ts +2 -1
- package/dist/lib/sources/tile-source-adapter.d.ts.map +1 -1
- package/dist/lib/sources/tile-source-adapter.js +4 -3
- package/dist/lib/sources/tile-source.d.ts +30 -25
- package/dist/lib/sources/tile-source.d.ts.map +1 -1
- package/dist/lib/sources/utils/utils.d.ts +1 -1
- package/dist/lib/sources/utils/utils.d.ts.map +1 -1
- package/dist/lib/sources/utils/utils.js +1 -1
- package/dist/lib/sources/vector-source.d.ts +61 -0
- package/dist/lib/sources/vector-source.d.ts.map +1 -0
- package/dist/lib/sources/vector-source.js +13 -0
- package/dist/lib/sources/vector-tile-source.d.ts +6 -3
- package/dist/lib/sources/vector-tile-source.d.ts.map +1 -1
- package/dist/source-types.d.ts +39 -0
- package/dist/source-types.d.ts.map +1 -0
- package/package.json +5 -4
- package/src/index.ts +9 -4
- package/src/lib/file-provider/data-view-file.ts +2 -2
- package/src/lib/file-provider/file-handle-file.ts +2 -2
- package/src/lib/file-provider/file-provider-interface.ts +56 -0
- package/src/lib/file-provider/file-provider.ts +95 -25
- package/src/lib/log-utils/log.ts +15 -2
- package/src/lib/sources/data-source.ts +1 -0
- package/src/lib/sources/image-source.ts +19 -18
- package/src/lib/sources/image-tile-source.ts +8 -4
- package/src/lib/sources/tile-source-adapter.ts +5 -4
- package/src/lib/sources/tile-source.ts +38 -30
- package/src/lib/sources/utils/utils.ts +1 -1
- package/src/lib/sources/vector-source.ts +74 -0
- package/src/lib/sources/vector-tile-source.ts +11 -4
- package/src/source-types.ts +49 -0
- package/dist/service-types.d.ts +0 -10
- package/dist/service-types.d.ts.map +0 -1
- package/src/service-types.ts +0 -14
- /package/dist/{service-types.js → source-types.js} +0 -0
|
@@ -2,15 +2,36 @@
|
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
3
|
// Copyright (c) vis.gl contributors
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
import type {DataSourceProps} from './data-source';
|
|
6
|
+
import {DataSource} from './data-source';
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
|
-
*
|
|
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
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Normalized capabilities of an tile service
|
|
10
34
|
* Sources are expected to normalize the response to capabilities
|
|
11
|
-
* @example
|
|
12
|
-
* A WMS service would normalize the response to the WMS `GetCapabilities` data structure extracted from WMS XML response
|
|
13
|
-
* into an TileSourceMetadata.
|
|
14
35
|
*/
|
|
15
36
|
export type TileSourceMetadata = {
|
|
16
37
|
format?: string;
|
|
@@ -53,7 +74,7 @@ export type TileSourceLayer = {
|
|
|
53
74
|
};
|
|
54
75
|
|
|
55
76
|
/**
|
|
56
|
-
* Generic parameters for requesting an
|
|
77
|
+
* Generic parameters for requesting an tile from an tile source
|
|
57
78
|
*/
|
|
58
79
|
export type GetTileParameters = {
|
|
59
80
|
/** bounding box of the requested map image */
|
|
@@ -62,46 +83,33 @@ export type GetTileParameters = {
|
|
|
62
83
|
x: number;
|
|
63
84
|
/** tile y coordinate */
|
|
64
85
|
y: number;
|
|
65
|
-
/** Coordinate reference system for the
|
|
86
|
+
/** Coordinate reference system for the tile */
|
|
66
87
|
crs?: string;
|
|
67
88
|
/** Layers to render */
|
|
68
89
|
layers?: string | string[];
|
|
69
90
|
/** Styling */
|
|
70
91
|
styles?: unknown;
|
|
71
|
-
/** requested format for the return image */
|
|
92
|
+
/** requested format for the return image (in case of bitmap tiles) */
|
|
72
93
|
format?: 'image/png';
|
|
73
94
|
};
|
|
74
95
|
|
|
75
|
-
|
|
96
|
+
/** deck.gl compatibility: parameters for TileSource.getTileData() */
|
|
97
|
+
export type GetTileDataParameters = {
|
|
98
|
+
/** Tile index */
|
|
76
99
|
index: {x: number; y: number; z: number};
|
|
77
100
|
id: string;
|
|
101
|
+
/** Bounding Box */
|
|
78
102
|
bbox: TileBoundingBox;
|
|
103
|
+
/** Zoom level */
|
|
79
104
|
zoom?: number;
|
|
80
105
|
url?: string | null;
|
|
81
106
|
signal?: AbortSignal;
|
|
82
107
|
userData?: Record<string, any>;
|
|
83
108
|
};
|
|
84
109
|
|
|
85
|
-
/** deck.gl
|
|
110
|
+
/** deck.gl compatibility: bounding box */
|
|
86
111
|
export type TileBoundingBox = NonGeoBoundingBox | GeoBoundingBox;
|
|
112
|
+
/** deck.gl compatibility: bounding box */
|
|
87
113
|
export type GeoBoundingBox = {west: number; north: number; east: number; south: number};
|
|
114
|
+
/** deck.gl compatibility: bounding box */
|
|
88
115
|
export type NonGeoBoundingBox = {left: number; top: number; right: number; bottom: number};
|
|
89
|
-
|
|
90
|
-
/**
|
|
91
|
-
* Props for a TileSource
|
|
92
|
-
*/
|
|
93
|
-
export type TileSourceProps = {}; // DataSourceProps;
|
|
94
|
-
|
|
95
|
-
/**
|
|
96
|
-
* MapTileSource - data sources that allow data to be queried by (geospatial) extents
|
|
97
|
-
* @note
|
|
98
|
-
* - If geospatial, bounding box is expected to be in web mercator coordinates
|
|
99
|
-
*/
|
|
100
|
-
export interface TileSource<MetadataT extends TileSourceMetadata> {
|
|
101
|
-
// extends DataSource {
|
|
102
|
-
getMetadata(): Promise<MetadataT>;
|
|
103
|
-
/** Flat parameters */
|
|
104
|
-
getTile(parameters: GetTileParameters): Promise<unknown | null>;
|
|
105
|
-
/** deck.gl style parameters */
|
|
106
|
-
getTileData?(parameters: TileLoadParameters): Promise<unknown | null>;
|
|
107
|
-
}
|
|
@@ -29,7 +29,7 @@ export function getFetchFunction(options?: LoaderOptions) {
|
|
|
29
29
|
return (url) => fetch(url);
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
-
export function
|
|
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
|
+
};
|
|
@@ -2,8 +2,9 @@
|
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
3
|
// Copyright (c) vis.gl contributors
|
|
4
4
|
|
|
5
|
-
import {
|
|
6
|
-
import
|
|
5
|
+
import type {Schema, Feature, BinaryFeatureCollection} from '@loaders.gl/schema';
|
|
6
|
+
import {TileSource, TileSourceProps, TileSourceMetadata, GetTileParameters} from './tile-source';
|
|
7
|
+
import type {GetTileDataParameters} from './tile-source';
|
|
7
8
|
|
|
8
9
|
export type VectorTile = unknown;
|
|
9
10
|
|
|
@@ -13,7 +14,13 @@ export type VectorTileSourceProps = TileSourceProps;
|
|
|
13
14
|
* VectorTileSource - data sources that allow data to be queried by (geospatial) tile
|
|
14
15
|
* @note If geospatial, bounding box is expected to be in web mercator coordinates
|
|
15
16
|
*/
|
|
16
|
-
export interface VectorTileSource<
|
|
17
|
-
extends
|
|
17
|
+
export interface VectorTileSource<
|
|
18
|
+
PropsT extends VectorTileSourceProps = VectorTileSourceProps,
|
|
19
|
+
MetadataT extends TileSourceMetadata = TileSourceMetadata
|
|
20
|
+
> extends TileSource<PropsT, MetadataT> {
|
|
21
|
+
getSchema(): Promise<Schema>;
|
|
18
22
|
getVectorTile(parameters: GetTileParameters): Promise<VectorTile | null>;
|
|
23
|
+
getTileData(
|
|
24
|
+
parameters: GetTileDataParameters
|
|
25
|
+
): Promise<Feature[] | BinaryFeatureCollection | null>;
|
|
19
26
|
}
|
|
@@ -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
|
+
}
|
package/dist/service-types.d.ts
DELETED
|
@@ -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"}
|
package/src/service-types.ts
DELETED
|
@@ -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
|