@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
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import type { Schema, GeoJSONTable, BinaryFeatureCollection } from '@loaders.gl/schema';
|
|
2
|
+
import type { DataSourceProps } from "./data-source.js";
|
|
3
|
+
import { DataSource } from "./data-source.js";
|
|
4
|
+
export type VectorSourceProps = DataSourceProps;
|
|
5
|
+
/**
|
|
6
|
+
* VectorSource - data sources that allow features to be queried by (geospatial) extents
|
|
7
|
+
* @note
|
|
8
|
+
* - If geospatial, bounding box is expected to be in web mercator coordinates
|
|
9
|
+
*/
|
|
10
|
+
export declare abstract class VectorSource<PropsT extends VectorSourceProps = VectorSourceProps> extends DataSource<PropsT> {
|
|
11
|
+
static type: string;
|
|
12
|
+
static testURL: (url: string) => boolean;
|
|
13
|
+
abstract getSchema(): Promise<Schema>;
|
|
14
|
+
abstract getMetadata(options: {
|
|
15
|
+
formatSpecificMetadata?: boolean;
|
|
16
|
+
}): Promise<VectorSourceMetadata>;
|
|
17
|
+
abstract getFeatures(parameters: GetFeaturesParameters): Promise<GeoJSONTable | BinaryFeatureCollection>;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Normalized capabilities of an Image service
|
|
21
|
+
* @example
|
|
22
|
+
* The WMSSourceLoader will normalize the response to the WMS `GetCapabilities`
|
|
23
|
+
* data structure extracted from WMS XML response into an VectorSourceMetadata.
|
|
24
|
+
*/
|
|
25
|
+
export type VectorSourceMetadata = {
|
|
26
|
+
name: string;
|
|
27
|
+
title?: string;
|
|
28
|
+
abstract?: string;
|
|
29
|
+
keywords: string[];
|
|
30
|
+
layers: VectorSourceLayer[];
|
|
31
|
+
/**
|
|
32
|
+
* Attempts to preserve the original format specific metadata from the underlying source,
|
|
33
|
+
* May be an approximate representation
|
|
34
|
+
*/
|
|
35
|
+
formatSpecificMetadata?: Record<string, any>;
|
|
36
|
+
};
|
|
37
|
+
/** Description of one data layer in the image source */
|
|
38
|
+
export type VectorSourceLayer = {
|
|
39
|
+
/** Name of this layer */
|
|
40
|
+
name?: string;
|
|
41
|
+
/** Human readable title of this layer */
|
|
42
|
+
title?: string;
|
|
43
|
+
/** Coordinate systems supported by this layer */
|
|
44
|
+
crs?: string[];
|
|
45
|
+
/** layer limits in unspecified CRS:84-like lng/lat, for quick access w/o CRS calculations. */
|
|
46
|
+
boundingBox?: [min: [x: number, y: number], max: [x: number, y: number]];
|
|
47
|
+
/** Sub layers of this layer */
|
|
48
|
+
layers?: VectorSourceLayer[];
|
|
49
|
+
};
|
|
50
|
+
/** Generic parameters for requesting an image from an image source */
|
|
51
|
+
export type GetFeaturesParameters = {
|
|
52
|
+
/** Layers to render */
|
|
53
|
+
layers: string | string[];
|
|
54
|
+
/** bounding box on the map (only return features within this bbox) */
|
|
55
|
+
boundingBox: [min: [x: number, y: number], max: [x: number, y: number]];
|
|
56
|
+
/** crs for the returned features (not the bounding box) */
|
|
57
|
+
crs?: string;
|
|
58
|
+
/** @deprecated requested format for the return image */
|
|
59
|
+
format?: 'geojson' | 'binary';
|
|
60
|
+
};
|
|
61
|
+
//# sourceMappingURL=vector-source.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vector-source.d.ts","sourceRoot":"","sources":["../../../src/lib/sources/vector-source.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAC,MAAM,EAAE,YAAY,EAAE,uBAAuB,EAAC,MAAM,oBAAoB,CAAC;AACtF,OAAO,KAAK,EAAC,eAAe,EAAC,yBAAsB;AACnD,OAAO,EAAC,UAAU,EAAC,yBAAsB;AAEzC,MAAM,MAAM,iBAAiB,GAAG,eAAe,CAAC;AAEhD;;;;GAIG;AACH,8BAAsB,YAAY,CAChC,MAAM,SAAS,iBAAiB,GAAG,iBAAiB,CACpD,SAAQ,UAAU,CAAC,MAAM,CAAC;IAC1B,MAAM,CAAC,IAAI,EAAE,MAAM,CAAc;IACjC,MAAM,CAAC,OAAO,QAAS,MAAM,KAAG,OAAO,CAAU;IAEjD,QAAQ,CAAC,SAAS,IAAI,OAAO,CAAC,MAAM,CAAC;IACrC,QAAQ,CAAC,WAAW,CAAC,OAAO,EAAE;QAAC,sBAAsB,CAAC,EAAE,OAAO,CAAA;KAAC,GAAG,OAAO,CAAC,oBAAoB,CAAC;IAChG,QAAQ,CAAC,WAAW,CAClB,UAAU,EAAE,qBAAqB,GAChC,OAAO,CAAC,YAAY,GAAG,uBAAuB,CAAC;CACnD;AAID;;;;;GAKG;AACH,MAAM,MAAM,oBAAoB,GAAG;IACjC,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,MAAM,EAAE,iBAAiB,EAAE,CAAC;IAC5B;;;OAGG;IACH,sBAAsB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;CAC9C,CAAC;AAEF,wDAAwD;AACxD,MAAM,MAAM,iBAAiB,GAAG;IAC9B,yBAAyB;IACzB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,yCAAyC;IACzC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,iDAAiD;IACjD,GAAG,CAAC,EAAE,MAAM,EAAE,CAAC;IACf,8FAA8F;IAC9F,WAAW,CAAC,EAAE,CAAC,GAAG,EAAE,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,CAAC,EAAE,GAAG,EAAE,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC;IACzE,+BAA+B;IAC/B,MAAM,CAAC,EAAE,iBAAiB,EAAE,CAAC;CAC9B,CAAC;AAEF,sEAAsE;AACtE,MAAM,MAAM,qBAAqB,GAAG;IAClC,uBAAuB;IACvB,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IAC1B,sEAAsE;IACtE,WAAW,EAAE,CAAC,GAAG,EAAE,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,CAAC,EAAE,GAAG,EAAE,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC;IACxE,2DAA2D;IAC3D,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,wDAAwD;IACxD,MAAM,CAAC,EAAE,SAAS,GAAG,QAAQ,CAAC;CAC/B,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
// loaders.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
import { DataSource } from "./data-source.js";
|
|
5
|
+
/**
|
|
6
|
+
* VectorSource - data sources that allow features to be queried by (geospatial) extents
|
|
7
|
+
* @note
|
|
8
|
+
* - If geospatial, bounding box is expected to be in web mercator coordinates
|
|
9
|
+
*/
|
|
10
|
+
export class VectorSource extends DataSource {
|
|
11
|
+
static type = 'template';
|
|
12
|
+
static testURL = (url) => false;
|
|
13
|
+
}
|
|
@@ -1,12 +1,15 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
1
|
+
import type { Schema, Feature, BinaryFeatureCollection } from '@loaders.gl/schema';
|
|
2
|
+
import { TileSource, TileSourceProps, TileSourceMetadata, GetTileParameters } from "./tile-source.js";
|
|
3
|
+
import type { GetTileDataParameters } from "./tile-source.js";
|
|
3
4
|
export type VectorTile = unknown;
|
|
4
5
|
export type VectorTileSourceProps = TileSourceProps;
|
|
5
6
|
/**
|
|
6
7
|
* VectorTileSource - data sources that allow data to be queried by (geospatial) tile
|
|
7
8
|
* @note If geospatial, bounding box is expected to be in web mercator coordinates
|
|
8
9
|
*/
|
|
9
|
-
export interface VectorTileSource<MetadataT extends TileSourceMetadata = TileSourceMetadata> extends TileSource<MetadataT> {
|
|
10
|
+
export interface VectorTileSource<PropsT extends VectorTileSourceProps = VectorTileSourceProps, MetadataT extends TileSourceMetadata = TileSourceMetadata> extends TileSource<PropsT, MetadataT> {
|
|
11
|
+
getSchema(): Promise<Schema>;
|
|
10
12
|
getVectorTile(parameters: GetTileParameters): Promise<VectorTile | null>;
|
|
13
|
+
getTileData(parameters: GetTileDataParameters): Promise<Feature[] | BinaryFeatureCollection | null>;
|
|
11
14
|
}
|
|
12
15
|
//# sourceMappingURL=vector-tile-source.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vector-tile-source.d.ts","sourceRoot":"","sources":["../../../src/lib/sources/vector-tile-source.ts"],"names":[],"mappings":"AAIA,OAAO,EAAC,UAAU,EAAE,eAAe,EAAE,kBAAkB,EAAC,yBAAsB;
|
|
1
|
+
{"version":3,"file":"vector-tile-source.d.ts","sourceRoot":"","sources":["../../../src/lib/sources/vector-tile-source.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAC,MAAM,EAAE,OAAO,EAAE,uBAAuB,EAAC,MAAM,oBAAoB,CAAC;AACjF,OAAO,EAAC,UAAU,EAAE,eAAe,EAAE,kBAAkB,EAAE,iBAAiB,EAAC,yBAAsB;AACjG,OAAO,KAAK,EAAC,qBAAqB,EAAC,yBAAsB;AAEzD,MAAM,MAAM,UAAU,GAAG,OAAO,CAAC;AAEjC,MAAM,MAAM,qBAAqB,GAAG,eAAe,CAAC;AAEpD;;;GAGG;AACH,MAAM,WAAW,gBAAgB,CAC/B,MAAM,SAAS,qBAAqB,GAAG,qBAAqB,EAC5D,SAAS,SAAS,kBAAkB,GAAG,kBAAkB,CACzD,SAAQ,UAAU,CAAC,MAAM,EAAE,SAAS,CAAC;IACrC,SAAS,IAAI,OAAO,CAAC,MAAM,CAAC,CAAC;IAC7B,aAAa,CAAC,UAAU,EAAE,iBAAiB,GAAG,OAAO,CAAC,UAAU,GAAG,IAAI,CAAC,CAAC;IACzE,WAAW,CACT,UAAU,EAAE,qBAAqB,GAChC,OAAO,CAAC,OAAO,EAAE,GAAG,uBAAuB,GAAG,IAAI,CAAC,CAAC;CACxD"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { DataSource, DataSourceProps } from "./lib/sources/data-source.js";
|
|
2
|
+
/**
|
|
3
|
+
* A `Source` contains metadata and a factory method for creating instances of a specific `DataSource`.
|
|
4
|
+
* It allows a list of `Source` objects to be passed to methods
|
|
5
|
+
* @example
|
|
6
|
+
* `createDataSource(... , [MVTSource, PMTilesSource, ...])
|
|
7
|
+
*/
|
|
8
|
+
export interface Source<DataSourceT extends DataSource = DataSource, DataSourcePropsT extends DataSourceProps = any> {
|
|
9
|
+
/** Type of source created by this service */
|
|
10
|
+
source?: DataSourceT;
|
|
11
|
+
/** Type of props used when creating sources */
|
|
12
|
+
props?: DataSourcePropsT;
|
|
13
|
+
/** Name of the service */
|
|
14
|
+
name: string;
|
|
15
|
+
id: string;
|
|
16
|
+
/** Module containing the service */
|
|
17
|
+
module: string;
|
|
18
|
+
/** Version of the loaders.gl package containing this service. */
|
|
19
|
+
version: string;
|
|
20
|
+
/** URL extensions that this service uses */
|
|
21
|
+
extensions: string[];
|
|
22
|
+
/** MIME extensions that this service uses */
|
|
23
|
+
mimeTypes: string[];
|
|
24
|
+
/** Default options */
|
|
25
|
+
options: DataSourcePropsT;
|
|
26
|
+
/** Type string identifying this service, e.g. 'wms' */
|
|
27
|
+
type: string;
|
|
28
|
+
/** Can source be created from a URL */
|
|
29
|
+
fromUrl: boolean;
|
|
30
|
+
/** Can source be created from a Blob or File */
|
|
31
|
+
fromBlob: boolean;
|
|
32
|
+
/** Check if a URL can support this service */
|
|
33
|
+
testURL: (url: string) => boolean;
|
|
34
|
+
/** Test data */
|
|
35
|
+
testData?: (data: Blob) => boolean;
|
|
36
|
+
/** Create a source */
|
|
37
|
+
createDataSource(data: string | Blob, props: DataSourcePropsT): DataSourceT;
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=source-types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"source-types.d.ts","sourceRoot":"","sources":["../src/source-types.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAC,UAAU,EAAE,eAAe,EAAC,qCAAkC;AAE3E;;;;;GAKG;AACH,MAAM,WAAW,MAAM,CACrB,WAAW,SAAS,UAAU,GAAG,UAAU,EAC3C,gBAAgB,SAAS,eAAe,GAAG,GAAG;IAE9C,6CAA6C;IAC7C,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB,+CAA+C;IAC/C,KAAK,CAAC,EAAE,gBAAgB,CAAC;IAEzB,0BAA0B;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,CAAC;IACX,oCAAoC;IACpC,MAAM,EAAE,MAAM,CAAC;IACf,iEAAiE;IACjE,OAAO,EAAE,MAAM,CAAC;IAChB,4CAA4C;IAC5C,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,6CAA6C;IAC7C,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,sBAAsB;IACtB,OAAO,EAAE,gBAAgB,CAAC;IAE1B,uDAAuD;IACvD,IAAI,EAAE,MAAM,CAAC;IACb,uCAAuC;IACvC,OAAO,EAAE,OAAO,CAAC;IACjB,gDAAgD;IAChD,QAAQ,EAAE,OAAO,CAAC;IAElB,8CAA8C;IAC9C,OAAO,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC;IAClC,gBAAgB;IAChB,QAAQ,CAAC,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,OAAO,CAAC;IACnC,uBAAuB;IACvB,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,EAAE,KAAK,EAAE,gBAAgB,GAAG,WAAW,CAAC;CAC7E"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@loaders.gl/loader-utils",
|
|
3
|
-
"version": "4.3.0-alpha.
|
|
3
|
+
"version": "4.3.0-alpha.3",
|
|
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.
|
|
49
|
-
"@loaders.gl/worker-utils": "4.3.0-alpha.
|
|
48
|
+
"@loaders.gl/schema": "4.3.0-alpha.3",
|
|
49
|
+
"@loaders.gl/worker-utils": "4.3.0-alpha.3",
|
|
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": "
|
|
56
|
+
"gitHead": "3213679d79e6ff2814d48fd3337acfa446c74099"
|
|
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 {
|
|
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 {
|
|
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,9 +150,13 @@ 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
|
-
export type {
|
|
159
|
+
export type {GetTileDataParameters} from './lib/sources/tile-source';
|
|
155
160
|
|
|
156
161
|
export type {ImageTileSource} from './lib/sources/image-tile-source';
|
|
157
162
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
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
|
|
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 {
|
|
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
|
|
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,127 @@
|
|
|
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
|
-
*
|
|
8
|
+
* Provides file data using range requests to the server
|
|
3
9
|
* @deprecated - will be replaced with ReadableFile
|
|
4
10
|
*/
|
|
5
|
-
export
|
|
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
|
+
return new FileProvider(
|
|
24
|
+
file,
|
|
25
|
+
file.bigsize > 0n
|
|
26
|
+
? file.bigsize
|
|
27
|
+
: file.size > 0n
|
|
28
|
+
? file.size
|
|
29
|
+
: (await file.stat?.())?.bigsize ?? 0n
|
|
30
|
+
);
|
|
31
|
+
}
|
|
32
|
+
|
|
6
33
|
/**
|
|
7
|
-
*
|
|
34
|
+
* Truncates the file descriptor.
|
|
35
|
+
* @param length desired file lenght
|
|
8
36
|
*/
|
|
9
|
-
|
|
37
|
+
async truncate(length: number): Promise<void> {
|
|
38
|
+
throw new Error('file loaded via range requests cannot be changed');
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Append data to a file.
|
|
43
|
+
* @param buffer data to append
|
|
44
|
+
*/
|
|
45
|
+
async append(buffer: Uint8Array): Promise<void> {
|
|
46
|
+
throw new Error('file loaded via range requests cannot be changed');
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/** Close file */
|
|
50
|
+
async destroy(): Promise<void> {
|
|
51
|
+
throw new Error('file loaded via range requests cannot be changed');
|
|
52
|
+
}
|
|
53
|
+
|
|
10
54
|
/**
|
|
11
55
|
* Gets an unsigned 8-bit integer at the specified byte offset from the start of the file.
|
|
12
56
|
* @param offset The offset, in bytes, from the start of the file where to read the data.
|
|
13
57
|
*/
|
|
14
|
-
getUint8(offset: bigint): Promise<number
|
|
58
|
+
async getUint8(offset: number | bigint): Promise<number> {
|
|
59
|
+
const arrayBuffer = await this.file.read(offset, 1);
|
|
60
|
+
const val = new Uint8Array(arrayBuffer).at(0);
|
|
61
|
+
if (val === undefined) {
|
|
62
|
+
throw new Error('something went wrong');
|
|
63
|
+
}
|
|
64
|
+
return val;
|
|
65
|
+
}
|
|
15
66
|
|
|
16
67
|
/**
|
|
17
68
|
* Gets an unsigned 16-bit integer at the specified byte offset from the start of the file.
|
|
18
69
|
* @param offset The offset, in bytes, from the start of the file where to read the data.
|
|
19
70
|
*/
|
|
20
|
-
getUint16(offset: bigint): Promise<number
|
|
71
|
+
async getUint16(offset: number | bigint): Promise<number> {
|
|
72
|
+
const arrayBuffer = await this.file.read(offset, 2);
|
|
73
|
+
const val = new Uint16Array(arrayBuffer).at(0);
|
|
74
|
+
if (val === undefined) {
|
|
75
|
+
throw new Error('something went wrong');
|
|
76
|
+
}
|
|
77
|
+
return val;
|
|
78
|
+
}
|
|
21
79
|
|
|
22
80
|
/**
|
|
23
81
|
* 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
|
|
82
|
+
* @param offset The offset, in bytes, from the start of the file where to read the data.
|
|
25
83
|
*/
|
|
26
|
-
getUint32(offset: bigint): Promise<number
|
|
84
|
+
async getUint32(offset: number | bigint): Promise<number> {
|
|
85
|
+
const arrayBuffer = await this.file.read(offset, 4);
|
|
86
|
+
const val = new Uint32Array(arrayBuffer).at(0);
|
|
87
|
+
if (val === undefined) {
|
|
88
|
+
throw new Error('something went wrong');
|
|
89
|
+
}
|
|
90
|
+
return val;
|
|
91
|
+
}
|
|
27
92
|
|
|
28
93
|
/**
|
|
29
94
|
* Gets an unsigned 32-bit integer at the specified byte offset from the start of the file.
|
|
30
|
-
* @param offset The offset, in
|
|
95
|
+
* @param offset The offset, in bytes, from the start of the file where to read the data.
|
|
31
96
|
*/
|
|
32
|
-
getBigUint64(offset: bigint): Promise<bigint
|
|
97
|
+
async getBigUint64(offset: number | bigint): Promise<bigint> {
|
|
98
|
+
const arrayBuffer = await this.file.read(offset, 8);
|
|
99
|
+
const val = new BigInt64Array(arrayBuffer).at(0);
|
|
100
|
+
if (val === undefined) {
|
|
101
|
+
throw new Error('something went wrong');
|
|
102
|
+
}
|
|
103
|
+
return val;
|
|
104
|
+
}
|
|
33
105
|
|
|
34
106
|
/**
|
|
35
107
|
* 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
|
|
108
|
+
* @param startOffset The offset, in byte, from the start of the file where to start reading the data.
|
|
37
109
|
* @param endOffset The offset, in bytes, from the start of the file where to end reading the data.
|
|
38
110
|
*/
|
|
39
|
-
slice(startOffset: bigint, endOffset: bigint): Promise<ArrayBuffer
|
|
111
|
+
async slice(startOffset: bigint | number, endOffset: bigint | number): Promise<ArrayBuffer> {
|
|
112
|
+
const bigLength = BigInt(endOffset) - BigInt(startOffset);
|
|
113
|
+
if (bigLength > Number.MAX_SAFE_INTEGER) {
|
|
114
|
+
throw new Error('too big slice');
|
|
115
|
+
}
|
|
116
|
+
const length = Number(bigLength);
|
|
117
|
+
|
|
118
|
+
return await this.file.read(startOffset, length);
|
|
119
|
+
}
|
|
40
120
|
|
|
41
121
|
/**
|
|
42
122
|
* the length (in bytes) of the data.
|
|
43
123
|
*/
|
|
44
|
-
length: bigint
|
|
124
|
+
get length(): bigint {
|
|
125
|
+
return this.size;
|
|
126
|
+
}
|
|
45
127
|
}
|
|
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
|
-
};
|
package/src/lib/log-utils/log.ts
CHANGED
|
@@ -11,5 +11,18 @@ export const VERSION = typeof __VERSION__ !== 'undefined' ? __VERSION__ : 'lates
|
|
|
11
11
|
|
|
12
12
|
const version = VERSION[0] >= '0' && VERSION[0] <= '9' ? `v${VERSION}` : '';
|
|
13
13
|
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
// Make sure we set the global variable
|
|
15
|
+
function createLog() {
|
|
16
|
+
const log = new Log({id: 'loaders.gl'});
|
|
17
|
+
|
|
18
|
+
globalThis.loaders = globalThis.loaders || {};
|
|
19
|
+
globalThis.loaders.log = log;
|
|
20
|
+
globalThis.loaders.version = version;
|
|
21
|
+
|
|
22
|
+
globalThis.probe = globalThis.probe || {};
|
|
23
|
+
globalThis.probe.loaders = log;
|
|
24
|
+
|
|
25
|
+
return log;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export const log = createLog();
|
|
@@ -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
|
|
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,14 +3,18 @@
|
|
|
3
3
|
// Copyright (c) vis.gl contributors
|
|
4
4
|
|
|
5
5
|
import type {ImageType} from './utils/image-type';
|
|
6
|
-
import type {
|
|
7
|
-
import type {
|
|
6
|
+
import type {TileSourceProps, TileSourceMetadata, GetTileParameters} from './tile-source';
|
|
7
|
+
import type {TileSource} from './tile-source';
|
|
8
|
+
|
|
9
|
+
export type ImageTileSourceProps = TileSourceProps;
|
|
8
10
|
|
|
9
11
|
/**
|
|
10
12
|
* MapTileSource - data sources that allow data to be queried by (geospatial) tile
|
|
11
13
|
* @note If geospatial, bounding box is expected to be in web mercator coordinates
|
|
12
14
|
*/
|
|
13
|
-
export interface ImageTileSource<
|
|
14
|
-
extends
|
|
15
|
+
export interface ImageTileSource<
|
|
16
|
+
PropsT extends TileSourceProps = TileSourceProps,
|
|
17
|
+
MetadataT extends TileSourceMetadata = TileSourceMetadata
|
|
18
|
+
> extends TileSource<PropsT, MetadataT> {
|
|
15
19
|
getImageTile(parameters: GetTileParameters): Promise<ImageType | null>;
|
|
16
20
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// loaders.gl
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
3
|
|
|
4
|
-
import {TileSource, GetTileParameters} from './tile-source';
|
|
4
|
+
import {TileSource, GetTileParameters, GetTileDataParameters} from './tile-source';
|
|
5
5
|
import {ImageSource, ImageSourceMetadata} from './image-source';
|
|
6
6
|
|
|
7
7
|
/**
|
|
@@ -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) {
|
|
@@ -27,9 +28,9 @@ export class TileSourceAdapter implements TileSource<ImageSourceMetadata> {
|
|
|
27
28
|
}
|
|
28
29
|
|
|
29
30
|
/** deck.gl style parameters */
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
31
|
+
getTileData(parameters: GetTileDataParameters): Promise<unknown | null> {
|
|
32
|
+
return this.getTile(parameters.index);
|
|
33
|
+
}
|
|
33
34
|
|
|
34
35
|
/** Bounding box of tiles in this tileset `[[w, s], [e, n]]` */
|
|
35
36
|
protected getTileBoundingBox(
|