@loaders.gl/mvt 4.3.0-alpha.1 → 4.3.0-alpha.2
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 +568 -175
- package/dist/dist.min.js +1 -1
- package/dist/index.cjs +226 -163
- package/dist/index.cjs.map +4 -4
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/lib/parse-mvt.d.ts +1 -1
- package/dist/lib/parse-mvt.js +2 -30
- package/dist/lib/parse-tilejson.d.ts +4 -4
- package/dist/lib/parse-tilejson.d.ts.map +1 -1
- package/dist/lib/utils/geometry-utils.d.ts +38 -1
- package/dist/lib/utils/geometry-utils.d.ts.map +1 -1
- package/dist/lib/utils/geometry-utils.js +65 -6
- package/dist/lib/vector-tile/vector-tile-feature.d.ts +28 -9
- package/dist/lib/vector-tile/vector-tile-feature.d.ts.map +1 -1
- package/dist/lib/vector-tile/vector-tile-feature.js +47 -50
- package/dist/lib/{geojsonvt → vector-tiler}/clip.d.ts +3 -3
- package/dist/lib/vector-tiler/clip.d.ts.map +1 -0
- package/dist/lib/vector-tiler/convert.d.ts +18 -0
- package/dist/lib/vector-tiler/convert.d.ts.map +1 -0
- package/dist/lib/{geojsonvt → vector-tiler}/convert.js +8 -1
- package/dist/lib/vector-tiler/feature.d.ts +3 -0
- package/dist/lib/vector-tiler/feature.d.ts.map +1 -0
- package/dist/lib/vector-tiler/simplify.d.ts.map +1 -0
- package/dist/lib/{geojsonvt → vector-tiler}/tile.d.ts +4 -4
- package/dist/lib/vector-tiler/tile.d.ts.map +1 -0
- package/dist/lib/vector-tiler/transform.d.ts +7 -0
- package/dist/lib/vector-tiler/transform.d.ts.map +1 -0
- package/dist/lib/{geojsonvt → vector-tiler}/wrap.d.ts +2 -2
- package/dist/lib/vector-tiler/wrap.d.ts.map +1 -0
- package/dist/mvt-loader.d.ts +1 -1
- package/dist/mvt-loader.js +1 -1
- package/dist/mvt-source.d.ts +4 -4
- package/dist/mvt-source.d.ts.map +1 -1
- package/dist/mvt-source.js +4 -4
- package/dist/mvt-worker.js +101 -56
- package/dist/table-tile-source.d.ts +118 -0
- package/dist/table-tile-source.d.ts.map +1 -0
- package/dist/{geojson-tile-source.js → table-tile-source.js} +154 -103
- package/dist/tilejson-loader.js +1 -1
- package/package.json +7 -6
- package/src/index.ts +3 -3
- package/src/lib/parse-mvt.ts +4 -33
- package/src/lib/parse-tilejson.ts +5 -5
- package/src/lib/utils/geometry-utils.ts +66 -1
- package/src/lib/vector-tile/vector-tile-feature.ts +65 -56
- package/src/lib/{geojsonvt → vector-tiler}/clip.ts +4 -4
- package/src/lib/{geojsonvt → vector-tiler}/convert.ts +18 -8
- package/src/lib/{geojsonvt → vector-tiler}/feature.ts +3 -3
- package/src/lib/{geojsonvt → vector-tiler}/tile.ts +8 -8
- package/src/lib/{geojsonvt → vector-tiler}/transform.ts +2 -2
- package/src/lib/{geojsonvt → vector-tiler}/wrap.ts +5 -5
- package/src/mvt-source.ts +6 -7
- package/src/table-tile-source.ts +508 -0
- package/dist/geojson-tile-source.d.ts +0 -79
- package/dist/geojson-tile-source.d.ts.map +0 -1
- package/dist/lib/geojsonvt/clip.d.ts.map +0 -1
- package/dist/lib/geojsonvt/convert.d.ts +0 -10
- package/dist/lib/geojsonvt/convert.d.ts.map +0 -1
- package/dist/lib/geojsonvt/feature.d.ts +0 -3
- package/dist/lib/geojsonvt/feature.d.ts.map +0 -1
- package/dist/lib/geojsonvt/simplify.d.ts.map +0 -1
- package/dist/lib/geojsonvt/tile.d.ts.map +0 -1
- package/dist/lib/geojsonvt/transform.d.ts +0 -7
- package/dist/lib/geojsonvt/transform.d.ts.map +0 -1
- package/dist/lib/geojsonvt/wrap.d.ts.map +0 -1
- package/src/geojson-tile-source.ts +0 -422
- /package/dist/lib/{geojsonvt → vector-tiler}/clip.js +0 -0
- /package/dist/lib/{geojsonvt → vector-tiler}/feature.js +0 -0
- /package/dist/lib/{geojsonvt → vector-tiler}/simplify.d.ts +0 -0
- /package/dist/lib/{geojsonvt → vector-tiler}/simplify.js +0 -0
- /package/dist/lib/{geojsonvt → vector-tiler}/tile.js +0 -0
- /package/dist/lib/{geojsonvt → vector-tiler}/transform.js +0 -0
- /package/dist/lib/{geojsonvt → vector-tiler}/wrap.js +0 -0
- /package/src/lib/{geojsonvt → vector-tiler}/LICENSE +0 -0
- /package/src/lib/{geojsonvt → vector-tiler}/simplify.ts +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wrap.d.ts","sourceRoot":"","sources":["../../../src/lib/vector-tiler/wrap.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAC,gBAAgB,EAAC,kBAAe;AAI7C;;GAEG;AACH,MAAM,MAAM,WAAW,GAAG;IACxB,MAAM,EAAE,MAAM,CAAC,8CAA8C,CAAC;IAC9D,MAAM,EAAE,MAAM,CAAC,0BAA0B,CAAC;IAC1C,WAAW,EAAE,OAAO,CAAC;CACtB,CAAC;AAEF;;;;;GAKG;AACH,wBAAgB,IAAI,CAAC,QAAQ,EAAE,gBAAgB,EAAE,EAAE,OAAO,EAAE,WAAW,sBAkBtE"}
|
package/dist/mvt-loader.d.ts
CHANGED
|
@@ -52,7 +52,7 @@ export declare const MVTWorkerLoader: {
|
|
|
52
52
|
* Loader for the Mapbox Vector Tile format
|
|
53
53
|
*/
|
|
54
54
|
export declare const MVTLoader: {
|
|
55
|
-
readonly parse: (arrayBuffer: ArrayBuffer, options?: MVTLoaderOptions) => Promise<import("@loaders.gl/schema").GeoJSONTable | import("geojson").Feature<import("geojson").Geometry, import("geojson").GeoJsonProperties>[] |
|
|
55
|
+
readonly parse: (arrayBuffer: ArrayBuffer, options?: MVTLoaderOptions) => Promise<import("@loaders.gl/schema").BinaryFeatureCollection | import("@loaders.gl/schema").GeoJSONTable | import("geojson").Feature<import("geojson").Geometry, import("geojson").GeoJsonProperties>[] | {
|
|
56
56
|
shape: string;
|
|
57
57
|
data: import("@loaders.gl/schema").BinaryFeatureCollection;
|
|
58
58
|
}>;
|
package/dist/mvt-loader.js
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
import { parseMVT } from "./lib/parse-mvt.js";
|
|
6
6
|
// __VERSION__ is injected by babel-plugin-version-inline
|
|
7
7
|
// @ts-ignore TS2304: Cannot find name '__VERSION__'.
|
|
8
|
-
const VERSION = typeof "4.
|
|
8
|
+
const VERSION = typeof "4.3.0-alpha.1" !== 'undefined' ? "4.3.0-alpha.1" : 'latest';
|
|
9
9
|
/**
|
|
10
10
|
* Worker loader for the Mapbox Vector Tile format
|
|
11
11
|
*/
|
package/dist/mvt-source.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ImageType, DataSourceProps } from '@loaders.gl/loader-utils';
|
|
2
2
|
import type { ImageTileSource, VectorTileSource } from '@loaders.gl/loader-utils';
|
|
3
|
+
import type { GetTileParameters, GetTileDataParameters } from '@loaders.gl/loader-utils';
|
|
3
4
|
import { DataSource } from '@loaders.gl/loader-utils';
|
|
4
5
|
import { ImageLoaderOptions } from '@loaders.gl/images';
|
|
5
6
|
import { MVTLoaderOptions, TileJSON, TileJSONLoaderOptions } from '@loaders.gl/mvt';
|
|
6
|
-
import { TileLoadParameters } from '@loaders.gl/loader-utils';
|
|
7
7
|
/** Properties for a Mapbox Vector Tile Source */
|
|
8
8
|
export type MVTSourceProps = DataSourceProps & {
|
|
9
9
|
/** Root url of tileset */
|
|
@@ -36,8 +36,8 @@ export declare class MVTSource extends DataSource implements ImageTileSource, Ve
|
|
|
36
36
|
constructor(props: MVTSourceProps);
|
|
37
37
|
getMetadata(): Promise<TileJSON | null>;
|
|
38
38
|
getTileMIMEType(): string | null;
|
|
39
|
-
getTile(
|
|
40
|
-
getTileData(
|
|
39
|
+
getTile(parameters: GetTileParameters): Promise<ArrayBuffer | null>;
|
|
40
|
+
getTileData(parameters: GetTileDataParameters): Promise<any>;
|
|
41
41
|
getImageTile(tileParams: GetTileParameters): Promise<ImageType | null>;
|
|
42
42
|
protected _parseImageTile(arrayBuffer: ArrayBuffer): Promise<ImageType>;
|
|
43
43
|
getVectorTile(tileParams: GetTileParameters): Promise<unknown | null>;
|
package/dist/mvt-source.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mvt-source.d.ts","sourceRoot":"","sources":["../src/mvt-source.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAC,
|
|
1
|
+
{"version":3,"file":"mvt-source.d.ts","sourceRoot":"","sources":["../src/mvt-source.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAC,SAAS,EAAE,eAAe,EAAC,MAAM,0BAA0B,CAAC;AACzE,OAAO,KAAK,EAAC,eAAe,EAAE,gBAAgB,EAAC,MAAM,0BAA0B,CAAC;AAChF,OAAO,KAAK,EAAC,iBAAiB,EAAE,qBAAqB,EAAC,MAAM,0BAA0B,CAAC;AACvF,OAAO,EAAC,UAAU,EAAc,MAAM,0BAA0B,CAAC;AACjE,OAAO,EAAc,kBAAkB,EAAyB,MAAM,oBAAoB,CAAC;AAC3F,OAAO,EAEL,gBAAgB,EAEhB,QAAQ,EACR,qBAAqB,EACtB,MAAM,iBAAiB,CAAC;AAEzB,iDAAiD;AACjD,MAAM,MAAM,cAAc,GAAG,eAAe,GAAG;IAC7C,0BAA0B;IAC1B,GAAG,EAAE,MAAM,CAAC;IACZ,2EAA2E;IAC3E,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,oDAAoD;IACpD,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,mFAAmF;IACnF,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;IACxB,+CAA+C;IAC/C,WAAW,CAAC,EAAE,qBAAqB,GAAG,gBAAgB,GAAG,kBAAkB,CAAC;CAC7E,CAAC;AAEF;;GAEG;AACH;;;GAGG;AACH,qBAAa,SAAU,SAAQ,UA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AG,MAAM,GAAG,MAAM,EAAE,CAAC;AAM5C;;;;;;;;;GASG;AACH,wBAAgB,kBAAkB,CAChC,QAAQ,EAAE,WAAW,EACrB,CAAC,EAAE,MAAM,EACT,CAAC,EAAE,MAAM,EACT,CAAC,EAAE,MAAM,EACT,EAAE,GAAE,MAAY,GACf,MAAM,CAiBR"}
|
package/dist/mvt-source.js
CHANGED
|
@@ -67,8 +67,8 @@ export class MVTSource extends DataSource {
|
|
|
67
67
|
getTileMIMEType() {
|
|
68
68
|
return this.mimeType;
|
|
69
69
|
}
|
|
70
|
-
async getTile(
|
|
71
|
-
const { x, y, z } =
|
|
70
|
+
async getTile(parameters) {
|
|
71
|
+
const { x, y, z } = parameters;
|
|
72
72
|
const tileUrl = this.getTileURL(x, y, z);
|
|
73
73
|
const response = await this.fetch(tileUrl);
|
|
74
74
|
if (!response.ok) {
|
|
@@ -79,8 +79,8 @@ export class MVTSource extends DataSource {
|
|
|
79
79
|
}
|
|
80
80
|
// Tile Source interface implementation: deck.gl compatible API
|
|
81
81
|
// TODO - currently only handles image tiles, not vector tiles
|
|
82
|
-
async getTileData(
|
|
83
|
-
const { x, y, z } =
|
|
82
|
+
async getTileData(parameters) {
|
|
83
|
+
const { x, y, z } = parameters.index;
|
|
84
84
|
// const metadata = await this.metadata;
|
|
85
85
|
// mimeType = metadata?.tileMIMEType || 'application/vnd.mapbox-vector-tile';
|
|
86
86
|
const arrayBuffer = await this.getTile({ x, y, z, layers: [] });
|
package/dist/mvt-worker.js
CHANGED
|
@@ -1649,7 +1649,7 @@
|
|
|
1649
1649
|
var navigator_ = globalThis.navigator || {};
|
|
1650
1650
|
|
|
1651
1651
|
// ../../node_modules/@probe.gl/log/node_modules/@probe.gl/env/dist/utils/globals.js
|
|
1652
|
-
var VERSION = true ? "4.
|
|
1652
|
+
var VERSION = true ? "4.3.0-alpha.1" : "untranspiled source";
|
|
1653
1653
|
var isBrowser2 = isBrowser();
|
|
1654
1654
|
|
|
1655
1655
|
// ../../node_modules/@probe.gl/log/dist/utils/local-storage.js
|
|
@@ -2147,9 +2147,18 @@
|
|
|
2147
2147
|
});
|
|
2148
2148
|
|
|
2149
2149
|
// ../loader-utils/src/lib/log-utils/log.ts
|
|
2150
|
-
var VERSION2 = true ? "4.
|
|
2150
|
+
var VERSION2 = true ? "4.3.0-alpha.1" : "latest";
|
|
2151
2151
|
var version = VERSION2[0] >= "0" && VERSION2[0] <= "9" ? `v${VERSION2}` : "";
|
|
2152
|
-
|
|
2152
|
+
function createLog() {
|
|
2153
|
+
const log2 = new Log({ id: "loaders.gl" });
|
|
2154
|
+
globalThis.loaders = globalThis.loaders || {};
|
|
2155
|
+
globalThis.loaders.log = log2;
|
|
2156
|
+
globalThis.loaders.version = version;
|
|
2157
|
+
globalThis.probe = globalThis.probe || {};
|
|
2158
|
+
globalThis.probe.loaders = log2;
|
|
2159
|
+
return log2;
|
|
2160
|
+
}
|
|
2161
|
+
var log = createLog();
|
|
2153
2162
|
|
|
2154
2163
|
// ../worker-utils/src/lib/node/worker_threads-browser.ts
|
|
2155
2164
|
var parentPort = null;
|
|
@@ -2363,6 +2372,39 @@
|
|
|
2363
2372
|
}
|
|
2364
2373
|
return sum;
|
|
2365
2374
|
}
|
|
2375
|
+
function convertToLocalCoordinates(coordinates, extent) {
|
|
2376
|
+
if (Array.isArray(coordinates[0])) {
|
|
2377
|
+
for (const subcoords of coordinates) {
|
|
2378
|
+
convertToLocalCoordinates(subcoords, extent);
|
|
2379
|
+
}
|
|
2380
|
+
return;
|
|
2381
|
+
}
|
|
2382
|
+
const p = coordinates;
|
|
2383
|
+
p[0] /= extent;
|
|
2384
|
+
p[1] /= extent;
|
|
2385
|
+
}
|
|
2386
|
+
function convertToLocalCoordinatesFlat(data, extent) {
|
|
2387
|
+
for (let i = 0, il = data.length; i < il; ++i) {
|
|
2388
|
+
data[i] /= extent;
|
|
2389
|
+
}
|
|
2390
|
+
}
|
|
2391
|
+
function projectToLngLat(line, tileIndex, extent) {
|
|
2392
|
+
if (typeof line[0][0] !== "number") {
|
|
2393
|
+
for (const point of line) {
|
|
2394
|
+
projectToLngLat(point, tileIndex, extent);
|
|
2395
|
+
}
|
|
2396
|
+
return;
|
|
2397
|
+
}
|
|
2398
|
+
const size = extent * Math.pow(2, tileIndex.z);
|
|
2399
|
+
const x0 = extent * tileIndex.x;
|
|
2400
|
+
const y0 = extent * tileIndex.y;
|
|
2401
|
+
for (let j = 0; j < line.length; j++) {
|
|
2402
|
+
const p = line[j];
|
|
2403
|
+
p[0] = (p[0] + x0) * 360 / size - 180;
|
|
2404
|
+
const y2 = 180 - (p[1] + y0) * 360 / size;
|
|
2405
|
+
p[1] = 360 / Math.PI * Math.atan(Math.exp(y2 * Math.PI / 180)) - 90;
|
|
2406
|
+
}
|
|
2407
|
+
}
|
|
2366
2408
|
function projectToLngLatFlat(data, tileIndex, extent) {
|
|
2367
2409
|
const { x, y, z } = tileIndex;
|
|
2368
2410
|
const size = extent * Math.pow(2, z);
|
|
@@ -2472,39 +2514,37 @@
|
|
|
2472
2514
|
this._geometryInfo = geometryInfo;
|
|
2473
2515
|
pbf.readFields(readFeature, this, end);
|
|
2474
2516
|
}
|
|
2475
|
-
|
|
2517
|
+
toGeoJSONFeature(coordinates, tileIndex) {
|
|
2476
2518
|
const coords = this.loadGeometry();
|
|
2477
|
-
|
|
2478
|
-
|
|
2479
|
-
|
|
2480
|
-
|
|
2481
|
-
|
|
2482
|
-
|
|
2483
|
-
|
|
2484
|
-
|
|
2485
|
-
|
|
2486
|
-
const p = line[j];
|
|
2487
|
-
p[0] = (p[0] + x0) * 360 / size - 180;
|
|
2488
|
-
const y2 = 180 - (p[1] + y0) * 360 / size;
|
|
2489
|
-
p[1] = 360 / Math.PI * Math.atan(Math.exp(y2 * Math.PI / 180)) - 90;
|
|
2490
|
-
}
|
|
2519
|
+
switch (coordinates) {
|
|
2520
|
+
case "wgs84":
|
|
2521
|
+
return _toGeoJSONFeature(
|
|
2522
|
+
this,
|
|
2523
|
+
coords,
|
|
2524
|
+
(line) => projectToLngLat(line, tileIndex, this.extent)
|
|
2525
|
+
);
|
|
2526
|
+
default:
|
|
2527
|
+
return _toGeoJSONFeature(this, coords, convertToLocalCoordinates);
|
|
2491
2528
|
}
|
|
2492
|
-
return _toGeoJSON(this, coords, project);
|
|
2493
2529
|
}
|
|
2494
2530
|
/**
|
|
2495
2531
|
*
|
|
2496
2532
|
* @param options
|
|
2497
2533
|
* @returns
|
|
2498
2534
|
*/
|
|
2499
|
-
|
|
2500
|
-
|
|
2501
|
-
|
|
2535
|
+
toBinaryFeature(coordinates, tileIndex) {
|
|
2536
|
+
const geom = this.loadFlatGeometry();
|
|
2537
|
+
switch (coordinates) {
|
|
2538
|
+
case "wgs84":
|
|
2539
|
+
return this._toBinaryCoordinates(
|
|
2540
|
+
geom,
|
|
2541
|
+
(coords) => projectToLngLatFlat(coords, tileIndex, this.extent)
|
|
2542
|
+
);
|
|
2543
|
+
default:
|
|
2544
|
+
return this._toBinaryCoordinates(geom, convertToLocalCoordinatesFlat);
|
|
2502
2545
|
}
|
|
2503
|
-
const tileIndex = options;
|
|
2504
|
-
return this._toBinaryCoordinates(
|
|
2505
|
-
(data) => projectToLngLatFlat(data, tileIndex, this.extent)
|
|
2506
|
-
);
|
|
2507
2546
|
}
|
|
2547
|
+
/** Read a bounding box from the feature */
|
|
2508
2548
|
// eslint-disable-next-line max-statements
|
|
2509
2549
|
bbox() {
|
|
2510
2550
|
const pbf = this._pbf;
|
|
@@ -2548,10 +2588,9 @@
|
|
|
2548
2588
|
* @param transform
|
|
2549
2589
|
* @returns result
|
|
2550
2590
|
*/
|
|
2551
|
-
_toBinaryCoordinates(transform) {
|
|
2552
|
-
const geom = this.loadFlatGeometry();
|
|
2591
|
+
_toBinaryCoordinates(geom, transform) {
|
|
2553
2592
|
let geometry;
|
|
2554
|
-
transform(geom.data, this);
|
|
2593
|
+
transform(geom.data, this.extent);
|
|
2555
2594
|
const coordLength = 2;
|
|
2556
2595
|
switch (this.type) {
|
|
2557
2596
|
case 1:
|
|
@@ -2628,6 +2667,28 @@
|
|
|
2628
2667
|
lines.push(line);
|
|
2629
2668
|
return lines;
|
|
2630
2669
|
}
|
|
2670
|
+
/**
|
|
2671
|
+
* Expands the protobuf data to an intermediate Flat GeoJSON
|
|
2672
|
+
* data format, which maps closely to the binary data buffers.
|
|
2673
|
+
* It is similar to GeoJSON, but rather than storing the coordinates
|
|
2674
|
+
* in multidimensional arrays, we have a 1D `data` with all the
|
|
2675
|
+
* coordinates, and then index into this using the `indices`
|
|
2676
|
+
* parameter, e.g.
|
|
2677
|
+
*
|
|
2678
|
+
* geometry: {
|
|
2679
|
+
* type: 'Point', data: [1,2], indices: [0]
|
|
2680
|
+
* }
|
|
2681
|
+
* geometry: {
|
|
2682
|
+
* type: 'LineString', data: [1,2,3,4,...], indices: [0]
|
|
2683
|
+
* }
|
|
2684
|
+
* geometry: {
|
|
2685
|
+
* type: 'Polygon', data: [1,2,3,4,...], indices: [[0, 2]]
|
|
2686
|
+
* }
|
|
2687
|
+
* Thus the indices member lets us look up the relevant range
|
|
2688
|
+
* from the data array.
|
|
2689
|
+
* The Multi* versions of the above types share the same data
|
|
2690
|
+
* structure, just with multiple elements in the indices array
|
|
2691
|
+
*/
|
|
2631
2692
|
// eslint-disable-next-line complexity, max-statements
|
|
2632
2693
|
loadFlatGeometry() {
|
|
2633
2694
|
const pbf = this._pbf;
|
|
@@ -2670,7 +2731,7 @@
|
|
|
2670
2731
|
}
|
|
2671
2732
|
};
|
|
2672
2733
|
__publicField(VectorTileFeature, "types", ["Unknown", "Point", "LineString", "Polygon"]);
|
|
2673
|
-
function
|
|
2734
|
+
function _toGeoJSONFeature(vtFeature, coords, transform) {
|
|
2674
2735
|
let type = VectorTileFeature.types[vtFeature.type];
|
|
2675
2736
|
let i;
|
|
2676
2737
|
let j;
|
|
@@ -2682,19 +2743,19 @@
|
|
|
2682
2743
|
points[i] = coords[i][0];
|
|
2683
2744
|
}
|
|
2684
2745
|
coordinates = points;
|
|
2685
|
-
transform(coordinates, vtFeature);
|
|
2746
|
+
transform(coordinates, vtFeature.extent);
|
|
2686
2747
|
break;
|
|
2687
2748
|
case 2:
|
|
2688
2749
|
coordinates = coords;
|
|
2689
2750
|
for (i = 0; i < coordinates.length; i++) {
|
|
2690
|
-
transform(coordinates[i], vtFeature);
|
|
2751
|
+
transform(coordinates[i], vtFeature.extent);
|
|
2691
2752
|
}
|
|
2692
2753
|
break;
|
|
2693
2754
|
case 3:
|
|
2694
2755
|
coordinates = classifyRings(coords);
|
|
2695
2756
|
for (i = 0; i < coordinates.length; i++) {
|
|
2696
2757
|
for (j = 0; j < coordinates[i].length; j++) {
|
|
2697
|
-
transform(coordinates[i][j], vtFeature);
|
|
2758
|
+
transform(coordinates[i][j], vtFeature.extent);
|
|
2698
2759
|
}
|
|
2699
2760
|
}
|
|
2700
2761
|
break;
|
|
@@ -2715,7 +2776,8 @@
|
|
|
2715
2776
|
properties: vtFeature.properties
|
|
2716
2777
|
};
|
|
2717
2778
|
if (vtFeature.id !== null) {
|
|
2718
|
-
result.
|
|
2779
|
+
result.properties ||= {};
|
|
2780
|
+
result.properties.id = vtFeature.id;
|
|
2719
2781
|
}
|
|
2720
2782
|
return result;
|
|
2721
2783
|
}
|
|
@@ -2938,9 +3000,9 @@
|
|
|
2938
3000
|
return options.mvt;
|
|
2939
3001
|
}
|
|
2940
3002
|
function getDecodedFeature(feature, options, layerName) {
|
|
2941
|
-
const decodedFeature = feature.
|
|
2942
|
-
|
|
2943
|
-
options.
|
|
3003
|
+
const decodedFeature = feature.toGeoJSONFeature(
|
|
3004
|
+
options.coordinates || "local",
|
|
3005
|
+
options.tileIndex
|
|
2944
3006
|
);
|
|
2945
3007
|
if (options.layerProperty) {
|
|
2946
3008
|
decodedFeature.properties ||= {};
|
|
@@ -2949,32 +3011,15 @@
|
|
|
2949
3011
|
return decodedFeature;
|
|
2950
3012
|
}
|
|
2951
3013
|
function getDecodedFeatureBinary(feature, options, layerName) {
|
|
2952
|
-
const decodedFeature = feature.
|
|
2953
|
-
// @ts-expect-error
|
|
2954
|
-
options.coordinates === "wgs84" ? options.tileIndex : transformToLocalCoordinatesBinary
|
|
2955
|
-
);
|
|
3014
|
+
const decodedFeature = feature.toBinaryFeature(options.coordinates || "local", options.tileIndex);
|
|
2956
3015
|
if (options.layerProperty && decodedFeature.properties) {
|
|
2957
3016
|
decodedFeature.properties[options.layerProperty] = layerName;
|
|
2958
3017
|
}
|
|
2959
3018
|
return decodedFeature;
|
|
2960
3019
|
}
|
|
2961
|
-
function transformToLocalCoordinates(line, feature) {
|
|
2962
|
-
const { extent } = feature;
|
|
2963
|
-
for (let i = 0; i < line.length; i++) {
|
|
2964
|
-
const p = line[i];
|
|
2965
|
-
p[0] /= extent;
|
|
2966
|
-
p[1] /= extent;
|
|
2967
|
-
}
|
|
2968
|
-
}
|
|
2969
|
-
function transformToLocalCoordinatesBinary(data, feature) {
|
|
2970
|
-
const { extent } = feature;
|
|
2971
|
-
for (let i = 0, il = data.length; i < il; ++i) {
|
|
2972
|
-
data[i] /= extent;
|
|
2973
|
-
}
|
|
2974
|
-
}
|
|
2975
3020
|
|
|
2976
3021
|
// src/mvt-loader.ts
|
|
2977
|
-
var VERSION3 = true ? "4.
|
|
3022
|
+
var VERSION3 = true ? "4.3.0-alpha.1" : "latest";
|
|
2978
3023
|
var MVTWorkerLoader = {
|
|
2979
3024
|
dataType: null,
|
|
2980
3025
|
batchType: null,
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import type { VectorTileSourceProps, GetTileDataParameters, GetTileParameters } from '@loaders.gl/loader-utils';
|
|
2
|
+
import { VectorTileSource } from '@loaders.gl/loader-utils';
|
|
3
|
+
import { Schema, GeoJSONTable, Feature, BinaryFeatureCollection } from '@loaders.gl/schema';
|
|
4
|
+
import { Stats } from '@probe.gl/stats';
|
|
5
|
+
import type { TableTile, TableTileFeature } from "./lib/vector-tiler/tile.js";
|
|
6
|
+
/** Options to configure tiling */
|
|
7
|
+
export type TableTileSourceProps = VectorTileSourceProps & {
|
|
8
|
+
coordinates: 'local' | 'wgs84' | 'EPSG:4326';
|
|
9
|
+
/** max zoom to preserve detail on */
|
|
10
|
+
maxZoom?: number;
|
|
11
|
+
/** max zoom in the tile index */
|
|
12
|
+
indexMaxZoom?: number;
|
|
13
|
+
/** max number of points per tile in the tile index */
|
|
14
|
+
maxPointsPerTile?: number;
|
|
15
|
+
/** simplification tolerance (higher means simpler) */
|
|
16
|
+
tolerance?: number;
|
|
17
|
+
/** tile extent */
|
|
18
|
+
extent?: number;
|
|
19
|
+
/** tile buffer on each side */
|
|
20
|
+
buffer?: number;
|
|
21
|
+
/** name of a feature property to be promoted to feature.id */
|
|
22
|
+
promoteId?: string;
|
|
23
|
+
/** whether to generate feature ids. Cannot be used with promoteId */
|
|
24
|
+
generateId?: boolean;
|
|
25
|
+
/** logging level (0, 1 or 2) */
|
|
26
|
+
debug?: number;
|
|
27
|
+
/** whether to calculate line metrics */
|
|
28
|
+
lineMetrics?: boolean;
|
|
29
|
+
};
|
|
30
|
+
/**
|
|
31
|
+
* Dynamically vector tiles a table (the table needs a geometry column)
|
|
32
|
+
* - Tiles are generated when requested.
|
|
33
|
+
* - Each tile contains a tables of clipped features.
|
|
34
|
+
*
|
|
35
|
+
* @note - Currently only accepts `GeoJSONTable` tables
|
|
36
|
+
* @note - Currently only outputs `GeoJSONTable`
|
|
37
|
+
* @note - (can be initialized with a promise that resolves to GeoJSONTable).
|
|
38
|
+
*
|
|
39
|
+
* @todo - metadata should scan all rows to determine schema
|
|
40
|
+
* @todo - metadata scan all rows to determine tilestats (field values[] etc).
|
|
41
|
+
* @todo - handle binary input tables
|
|
42
|
+
* @todo - generate binary output tables
|
|
43
|
+
* @todo - how does TileSourceLayer specify coordinates / decided which layer to render with
|
|
44
|
+
*/
|
|
45
|
+
export declare class TableTileSource implements VectorTileSource<any> {
|
|
46
|
+
static defaultProps: Required<TableTileSourceProps>;
|
|
47
|
+
/** Global stats for all TableTileSources */
|
|
48
|
+
static stats: Stats;
|
|
49
|
+
/** Stats for this TableTileSource */
|
|
50
|
+
stats: Stats;
|
|
51
|
+
/** MIME type of the tiles emitted by this tile source */
|
|
52
|
+
readonly mimeType = "application/vnd.mapbox-vector-tile";
|
|
53
|
+
readonly localCoordinates = true;
|
|
54
|
+
/** The props that this tile source was created with */
|
|
55
|
+
props: Required<TableTileSourceProps>;
|
|
56
|
+
schema: Schema | null;
|
|
57
|
+
/** Map of generated tiles, indexed by stringified tile coordinates */
|
|
58
|
+
tiles: Record<string, TableTile>;
|
|
59
|
+
/** Array of tile coordinates */
|
|
60
|
+
tileCoords: {
|
|
61
|
+
x: number;
|
|
62
|
+
y: number;
|
|
63
|
+
z: number;
|
|
64
|
+
}[];
|
|
65
|
+
/** Input data has loaded, initial top-level tiling is done, sync methods can now be called */
|
|
66
|
+
ready: Promise<void>;
|
|
67
|
+
/** Metadata for the tile source (generated TileJSON/tilestats */
|
|
68
|
+
metadata: Promise<unknown>;
|
|
69
|
+
constructor(table: GeoJSONTable | Promise<GeoJSONTable>, props?: TableTileSourceProps);
|
|
70
|
+
initializeTilesAsync(tablePromise: GeoJSONTable | Promise<GeoJSONTable>): Promise<void>;
|
|
71
|
+
getMetadata(): Promise<unknown>;
|
|
72
|
+
getSchema(): Promise<Schema>;
|
|
73
|
+
/**
|
|
74
|
+
* Get a tile at the specified index
|
|
75
|
+
* @param tileIndex z, x, y of tile
|
|
76
|
+
* @returns
|
|
77
|
+
*/
|
|
78
|
+
getVectorTile(tileIndex: GetTileParameters): Promise<GeoJSONTable | null>;
|
|
79
|
+
getTile(tileIndex: {
|
|
80
|
+
z: number;
|
|
81
|
+
x: number;
|
|
82
|
+
y: number;
|
|
83
|
+
}): Promise<GeoJSONTable | null>;
|
|
84
|
+
getTileData(tileParams: GetTileDataParameters): Promise<Feature[] | BinaryFeatureCollection>;
|
|
85
|
+
/**
|
|
86
|
+
* Synchronously request a tile
|
|
87
|
+
* @note Application must await `source.ready` before calling sync methods.
|
|
88
|
+
*/
|
|
89
|
+
getTileSync(tileIndex: {
|
|
90
|
+
z: number;
|
|
91
|
+
x: number;
|
|
92
|
+
y: number;
|
|
93
|
+
}): GeoJSONTable | null;
|
|
94
|
+
/**
|
|
95
|
+
* Create the initial tiles
|
|
96
|
+
* @note the tiles stores all the features together with additional data
|
|
97
|
+
*/
|
|
98
|
+
createRootTiles(table: GeoJSONTable): void;
|
|
99
|
+
/**
|
|
100
|
+
* Return geojsonvt-style "half formed" vector tile
|
|
101
|
+
* @note Application must await `source.ready` before calling sync methods.
|
|
102
|
+
*/
|
|
103
|
+
getRawTile(tileIndex: {
|
|
104
|
+
z: number;
|
|
105
|
+
x: number;
|
|
106
|
+
y: number;
|
|
107
|
+
}): TableTile | null;
|
|
108
|
+
/**
|
|
109
|
+
* splits features from a parent tile to sub-tiles.
|
|
110
|
+
* @param z, x, and y are the coordinates of the parent tile
|
|
111
|
+
* @param cz, cx, and cy are the coordinates of the target tile
|
|
112
|
+
*
|
|
113
|
+
* If no target tile is specified, splitting stops when we reach the maximum
|
|
114
|
+
* zoom or the number of points is low as specified in the props.
|
|
115
|
+
*/
|
|
116
|
+
splitTile(features: TableTileFeature[], z: number, x: number, y: number, cz?: number, cx?: number, cy?: number): void;
|
|
117
|
+
}
|
|
118
|
+
//# sourceMappingURL=table-tile-source.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"table-tile-source.d.ts","sourceRoot":"","sources":["../src/table-tile-source.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EACV,qBAAqB,EACrB,qBAAqB,EACrB,iBAAiB,EAClB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAC,gBAAgB,EAAM,MAAM,0BAA0B,CAAC;AAC/D,OAAO,EAAC,MAAM,EAAE,YAAY,EAAE,OAAO,EAAE,uBAAuB,EAAC,MAAM,oBAAoB,CAAC;AAE1F,OAAO,EAAC,KAAK,EAAO,MAAM,iBAAiB,CAAC;AAE5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