@loaders.gl/pmtiles 4.3.0-alpha.2 → 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/dist.dev.js +258 -242
- package/dist/dist.min.js +1 -1
- package/dist/index.cjs +20 -4
- package/dist/index.cjs.map +2 -2
- package/dist/index.d.ts +3 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/pmtiles-source.d.ts +29 -23
- package/dist/pmtiles-source.d.ts.map +1 -1
- package/dist/pmtiles-source.js +13 -8
- package/package.json +6 -6
- package/src/index.ts +4 -2
- package/src/pmtiles-source.ts +30 -33
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pmtiles-source.d.ts","sourceRoot":"","sources":["../src/pmtiles-source.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAC,MAAM,EAAC,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"pmtiles-source.d.ts","sourceRoot":"","sources":["../src/pmtiles-source.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAC,MAAM,EAAC,MAAM,oBAAoB,CAAC;AAE/C,OAAO,KAAK,EACV,gBAAgB,EAChB,iBAAiB,EACjB,qBAAqB,EACtB,MAAM,0BAA0B,CAAC;AAClC,OAAO,KAAK,EAAC,eAAe,EAAE,SAAS,EAAC,MAAM,0BAA0B,CAAC;AACzE,OAAO,EAAC,UAAU,EAAE,eAAe,EAAc,MAAM,0BAA0B,CAAC;AAClF,OAAO,EAAc,kBAAkB,EAAC,MAAM,oBAAoB,CAAC;AACnE,OAAO,EAAY,gBAAgB,EAAE,qBAAqB,EAAC,MAAM,iBAAiB,CAAC;AAEnF,OAAO,KAAK,OAAO,MAAM,SAAS,CAAC;AAGnC,OAAO,KAAK,EAAC,eAAe,EAAC,+BAA4B;AAMzD;;GAEG;AACH,eAAO,MAAM,aAAa;;;;;;;;;;;;;;4BAYT,MAAM;qCACG,MAAM,GAAG,IAAI,SAAS,sBAAsB;CAEA,CAAC;AAEvE,MAAM,MAAM,sBAAsB,GAAG,eAAe,GAAG;IACrD,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;IACnB,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;IACxB,OAAO,CAAC,EAAE;QACR,WAAW,CAAC,EAAE,qBAAqB,GAAG,gBAAgB,GAAG,kBAAkB,CAAC;KAE7E,CAAC;CACH,CAAC;AAEF;;;GAGG;AACH,qBAAa,iBAAkB,SAAQ,UAAW,YAAW,eAAe,EAAE,gBAAgB;IAC5F,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IACpB,KAAK,EAAE,sBAAsB,CAAC;IAC9B,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAQ;IAC/B,OAAO,EAAE,OAAO,CAAC,OAAO,CAAC;IACzB,QAAQ,EAAE,OAAO,CAAC,eAAe,CAAC,CAAC;gBAEvB,IAAI,EAAE,MAAM,GAAG,IAAI,EAAE,KAAK,EAAE,sBAAsB;IAUxD,SAAS,IAAI,OAAO,CAAC,MAAM,CAAC;IAI5B,WAAW,IAAI,OAAO,CAAC,eAAe,CAAC;IAoBvC,OAAO,CAAC,UAAU,EAAE,iBAAiB,GAAG,OAAO,CAAC,WAAW,GAAG,IAAI,CAAC;IAcnE,WAAW,CAAC,UAAU,EAAE,qBAAqB,GAAG,OAAO,CAAC,GAAG,CAAC;IAa5D,YAAY,CAAC,UAAU,EAAE,iBAAiB,GAAG,OAAO,CAAC,SAAS,GAAG,IAAI,CAAC;IAOtE,aAAa,CAAC,UAAU,EAAE,iBAAiB,GAAG,OAAO,CAAC,OAAO,GAAG,IAAI,CAAC;CAc5E"}
|
package/dist/pmtiles-source.js
CHANGED
|
@@ -9,32 +9,37 @@ const { PMTiles } = pmtiles;
|
|
|
9
9
|
import { parsePMTilesHeader } from "./lib/parse-pmtiles.js";
|
|
10
10
|
import { BlobSource } from "./lib/blob-source.js";
|
|
11
11
|
const VERSION = '1.0.0';
|
|
12
|
-
|
|
12
|
+
/**
|
|
13
|
+
* Creates vector tile data sources for PMTiles urls or blobs
|
|
14
|
+
*/
|
|
15
|
+
export const PMTilesSource = {
|
|
13
16
|
name: 'PMTiles',
|
|
14
17
|
id: 'pmtiles',
|
|
15
18
|
module: 'pmtiles',
|
|
16
19
|
version: VERSION,
|
|
17
20
|
extensions: ['pmtiles'],
|
|
18
21
|
mimeTypes: ['application/octet-stream'],
|
|
19
|
-
options: {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
22
|
+
options: { url: undefined, pmtiles: {} },
|
|
23
|
+
type: 'pmtiles',
|
|
24
|
+
fromUrl: true,
|
|
25
|
+
fromBlob: true,
|
|
26
|
+
testURL: (url) => url.endsWith('.pmtiles'),
|
|
27
|
+
createDataSource: (url, props) => new PMTilesTileSource(url, props)
|
|
23
28
|
};
|
|
24
29
|
/**
|
|
25
30
|
* A PMTiles data source
|
|
26
31
|
* @note Can be either a raster or vector tile source depending on the contents of the PMTiles file.
|
|
27
32
|
*/
|
|
28
|
-
export class
|
|
33
|
+
export class PMTilesTileSource extends DataSource {
|
|
29
34
|
data;
|
|
30
35
|
props;
|
|
31
36
|
mimeType = null;
|
|
32
37
|
pmtiles;
|
|
33
38
|
metadata;
|
|
34
|
-
constructor(props) {
|
|
39
|
+
constructor(data, props) {
|
|
35
40
|
super(props);
|
|
36
41
|
this.props = props;
|
|
37
|
-
const url = typeof
|
|
42
|
+
const url = typeof data === 'string' ? resolvePath(data) : new BlobSource(data, 'pmtiles');
|
|
38
43
|
this.data = props.url;
|
|
39
44
|
this.pmtiles = new PMTiles(url);
|
|
40
45
|
this.getTileData = this.getTileData.bind(this);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@loaders.gl/pmtiles",
|
|
3
|
-
"version": "4.3.0-alpha.
|
|
3
|
+
"version": "4.3.0-alpha.3",
|
|
4
4
|
"description": "Framework-independent loader for the pmtiles format",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -46,14 +46,14 @@
|
|
|
46
46
|
"build-bundle-dev": "ocular-bundle ./bundle.ts --env=dev --output=dist/dist.dev.js"
|
|
47
47
|
},
|
|
48
48
|
"dependencies": {
|
|
49
|
-
"@loaders.gl/images": "4.3.0-alpha.
|
|
50
|
-
"@loaders.gl/loader-utils": "4.3.0-alpha.
|
|
51
|
-
"@loaders.gl/mvt": "4.3.0-alpha.
|
|
52
|
-
"@loaders.gl/schema": "4.3.0-alpha.
|
|
49
|
+
"@loaders.gl/images": "4.3.0-alpha.3",
|
|
50
|
+
"@loaders.gl/loader-utils": "4.3.0-alpha.3",
|
|
51
|
+
"@loaders.gl/mvt": "4.3.0-alpha.3",
|
|
52
|
+
"@loaders.gl/schema": "4.3.0-alpha.3",
|
|
53
53
|
"pmtiles": "^3.0.4"
|
|
54
54
|
},
|
|
55
55
|
"peerDependencies": {
|
|
56
56
|
"@loaders.gl/core": "^4.0.0"
|
|
57
57
|
},
|
|
58
|
-
"gitHead": "
|
|
58
|
+
"gitHead": "3213679d79e6ff2814d48fd3337acfa446c74099"
|
|
59
59
|
}
|
package/src/index.ts
CHANGED
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
3
|
// Copyright (c) vis.gl contributors
|
|
4
4
|
|
|
5
|
-
export type {PMTilesMetadata} from './lib/parse-pmtiles';
|
|
6
|
-
export type {PMTilesSourceProps} from './pmtiles-source';
|
|
7
5
|
export {PMTilesSource} from './pmtiles-source';
|
|
6
|
+
|
|
7
|
+
export type {PMTilesMetadata} from './lib/parse-pmtiles';
|
|
8
|
+
export type {PMTilesTileSourceProps} from './pmtiles-source';
|
|
9
|
+
export {PMTilesTileSource} from './pmtiles-source';
|
package/src/pmtiles-source.ts
CHANGED
|
@@ -3,10 +3,14 @@
|
|
|
3
3
|
// Copyright (c) vis.gl contributors
|
|
4
4
|
|
|
5
5
|
import type {Schema} from '@loaders.gl/schema';
|
|
6
|
-
import type {
|
|
7
|
-
import type {
|
|
8
|
-
|
|
9
|
-
|
|
6
|
+
import type {Source} from '@loaders.gl/loader-utils';
|
|
7
|
+
import type {
|
|
8
|
+
VectorTileSource,
|
|
9
|
+
GetTileParameters,
|
|
10
|
+
GetTileDataParameters
|
|
11
|
+
} from '@loaders.gl/loader-utils';
|
|
12
|
+
import type {ImageTileSource, ImageType} from '@loaders.gl/loader-utils';
|
|
13
|
+
import {DataSource, DataSourceProps, resolvePath} from '@loaders.gl/loader-utils';
|
|
10
14
|
import {ImageLoader, ImageLoaderOptions} from '@loaders.gl/images';
|
|
11
15
|
import {MVTLoader, MVTLoaderOptions, TileJSONLoaderOptions} from '@loaders.gl/mvt';
|
|
12
16
|
|
|
@@ -19,57 +23,50 @@ import {BlobSource} from './lib/blob-source';
|
|
|
19
23
|
|
|
20
24
|
const VERSION = '1.0.0';
|
|
21
25
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
version: string;
|
|
27
|
-
extensions: string[];
|
|
28
|
-
mimeTypes: string[];
|
|
29
|
-
options: Record<string, unknown>;
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
export type ServiceWithSource<SourceT, SourcePropsT> = Service & {
|
|
33
|
-
_source?: SourceT;
|
|
34
|
-
_sourceProps?: SourcePropsT;
|
|
35
|
-
createSource: (props: SourcePropsT) => SourceT;
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
export const PMTilesService: ServiceWithSource<PMTilesSource, PMTilesSourceProps> = {
|
|
26
|
+
/**
|
|
27
|
+
* Creates vector tile data sources for PMTiles urls or blobs
|
|
28
|
+
*/
|
|
29
|
+
export const PMTilesSource = {
|
|
39
30
|
name: 'PMTiles',
|
|
40
31
|
id: 'pmtiles',
|
|
41
32
|
module: 'pmtiles',
|
|
42
33
|
version: VERSION,
|
|
43
34
|
extensions: ['pmtiles'],
|
|
44
35
|
mimeTypes: ['application/octet-stream'],
|
|
45
|
-
options: {
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
36
|
+
options: {url: undefined!, pmtiles: {}},
|
|
37
|
+
type: 'pmtiles',
|
|
38
|
+
fromUrl: true,
|
|
39
|
+
fromBlob: true,
|
|
40
|
+
|
|
41
|
+
testURL: (url: string) => url.endsWith('.pmtiles'),
|
|
42
|
+
createDataSource: (url: string | Blob, props: PMTilesTileSourceProps) =>
|
|
43
|
+
new PMTilesTileSource(url, props)
|
|
44
|
+
} as const satisfies Source<PMTilesTileSource, PMTilesTileSourceProps>;
|
|
50
45
|
|
|
51
|
-
export type
|
|
46
|
+
export type PMTilesTileSourceProps = DataSourceProps & {
|
|
52
47
|
url: string | Blob;
|
|
53
48
|
attributions?: string[];
|
|
54
|
-
|
|
49
|
+
pmtiles?: {
|
|
50
|
+
loadOptions?: TileJSONLoaderOptions & MVTLoaderOptions & ImageLoaderOptions;
|
|
51
|
+
// TODO - add options here
|
|
52
|
+
};
|
|
55
53
|
};
|
|
56
54
|
|
|
57
55
|
/**
|
|
58
56
|
* A PMTiles data source
|
|
59
57
|
* @note Can be either a raster or vector tile source depending on the contents of the PMTiles file.
|
|
60
58
|
*/
|
|
61
|
-
export class
|
|
59
|
+
export class PMTilesTileSource extends DataSource implements ImageTileSource, VectorTileSource {
|
|
62
60
|
data: string | Blob;
|
|
63
|
-
props:
|
|
61
|
+
props: PMTilesTileSourceProps;
|
|
64
62
|
mimeType: string | null = null;
|
|
65
63
|
pmtiles: pmtiles.PMTiles;
|
|
66
64
|
metadata: Promise<PMTilesMetadata>;
|
|
67
65
|
|
|
68
|
-
constructor(props:
|
|
66
|
+
constructor(data: string | Blob, props: PMTilesTileSourceProps) {
|
|
69
67
|
super(props);
|
|
70
68
|
this.props = props;
|
|
71
|
-
const url =
|
|
72
|
-
typeof props.url === 'string' ? resolvePath(props.url) : new BlobSource(props.url, 'pmtiles');
|
|
69
|
+
const url = typeof data === 'string' ? resolvePath(data) : new BlobSource(data, 'pmtiles');
|
|
73
70
|
this.data = props.url;
|
|
74
71
|
this.pmtiles = new PMTiles(url);
|
|
75
72
|
this.getTileData = this.getTileData.bind(this);
|