@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
|
@@ -6,7 +6,9 @@
|
|
|
6
6
|
import {Feature} from '@loaders.gl/schema';
|
|
7
7
|
import {FlatFeature, FlatIndexedGeometry, GeojsonGeometryInfo} from '@loaders.gl/schema';
|
|
8
8
|
import Protobuf from 'pbf';
|
|
9
|
-
import {classifyRings, classifyRingsFlat
|
|
9
|
+
import {classifyRings, classifyRingsFlat} from '../utils/geometry-utils';
|
|
10
|
+
import {projectToLngLat, projectToLngLatFlat} from '../utils/geometry-utils';
|
|
11
|
+
import {convertToLocalCoordinates, convertToLocalCoordinatesFlat} from '../utils/geometry-utils';
|
|
10
12
|
|
|
11
13
|
export class VectorTileFeature {
|
|
12
14
|
properties: {[x: string]: string | number | boolean | null};
|
|
@@ -48,47 +50,45 @@ export class VectorTileFeature {
|
|
|
48
50
|
pbf.readFields(readFeature, this, end);
|
|
49
51
|
}
|
|
50
52
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
+
toGeoJSONFeature(
|
|
54
|
+
coordinates: 'wgs84' | 'local',
|
|
55
|
+
tileIndex?: {x: number; y: number; z: number}
|
|
53
56
|
): Feature {
|
|
54
57
|
const coords = this.loadGeometry();
|
|
55
58
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
function project(line: number[]) {
|
|
65
|
-
for (let j = 0; j < line.length; j++) {
|
|
66
|
-
const p = line[j];
|
|
67
|
-
p[0] = ((p[0] + x0) * 360) / size - 180;
|
|
68
|
-
const y2 = 180 - ((p[1] + y0) * 360) / size;
|
|
69
|
-
p[1] = (360 / Math.PI) * Math.atan(Math.exp((y2 * Math.PI) / 180)) - 90;
|
|
70
|
-
}
|
|
59
|
+
switch (coordinates) {
|
|
60
|
+
case 'wgs84':
|
|
61
|
+
return _toGeoJSONFeature(this, coords, (line: number[][]) =>
|
|
62
|
+
projectToLngLat(line, tileIndex!, this.extent)
|
|
63
|
+
);
|
|
64
|
+
|
|
65
|
+
default:
|
|
66
|
+
return _toGeoJSONFeature(this, coords, convertToLocalCoordinates);
|
|
71
67
|
}
|
|
72
|
-
return _toGeoJSON(this, coords, project);
|
|
73
68
|
}
|
|
74
|
-
|
|
75
69
|
/**
|
|
76
70
|
*
|
|
77
71
|
* @param options
|
|
78
72
|
* @returns
|
|
79
73
|
*/
|
|
80
|
-
|
|
81
|
-
|
|
74
|
+
toBinaryFeature(
|
|
75
|
+
coordinates: 'wgs84' | 'local',
|
|
76
|
+
tileIndex?: {x: number; y: number; z: number}
|
|
82
77
|
): FlatFeature {
|
|
83
|
-
|
|
84
|
-
|
|
78
|
+
const geom = this.loadFlatGeometry();
|
|
79
|
+
|
|
80
|
+
switch (coordinates) {
|
|
81
|
+
case 'wgs84':
|
|
82
|
+
return this._toBinaryCoordinates(geom, (coords: number[]) =>
|
|
83
|
+
projectToLngLatFlat(coords, tileIndex!, this.extent)
|
|
84
|
+
);
|
|
85
|
+
|
|
86
|
+
default:
|
|
87
|
+
return this._toBinaryCoordinates(geom, convertToLocalCoordinatesFlat);
|
|
85
88
|
}
|
|
86
|
-
const tileIndex = options;
|
|
87
|
-
return this._toBinaryCoordinates((data: number[]) =>
|
|
88
|
-
projectToLngLatFlat(data, tileIndex, this.extent)
|
|
89
|
-
);
|
|
90
89
|
}
|
|
91
90
|
|
|
91
|
+
/** Read a bounding box from the feature */
|
|
92
92
|
// eslint-disable-next-line max-statements
|
|
93
93
|
bbox() {
|
|
94
94
|
const pbf = this._pbf;
|
|
@@ -135,32 +135,14 @@ export class VectorTileFeature {
|
|
|
135
135
|
* @param transform
|
|
136
136
|
* @returns result
|
|
137
137
|
*/
|
|
138
|
-
_toBinaryCoordinates(
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
// in multidimensional arrays, we have a 1D `data` with all the
|
|
143
|
-
// coordinates, and then index into this using the `indices`
|
|
144
|
-
// parameter, e.g.
|
|
145
|
-
//
|
|
146
|
-
// geometry: {
|
|
147
|
-
// type: 'Point', data: [1,2], indices: [0]
|
|
148
|
-
// }
|
|
149
|
-
// geometry: {
|
|
150
|
-
// type: 'LineString', data: [1,2,3,4,...], indices: [0]
|
|
151
|
-
// }
|
|
152
|
-
// geometry: {
|
|
153
|
-
// type: 'Polygon', data: [1,2,3,4,...], indices: [[0, 2]]
|
|
154
|
-
// }
|
|
155
|
-
// Thus the indices member lets us look up the relevant range
|
|
156
|
-
// from the data array.
|
|
157
|
-
// The Multi* versions of the above types share the same data
|
|
158
|
-
// structure, just with multiple elements in the indices array
|
|
159
|
-
const geom = this.loadFlatGeometry();
|
|
138
|
+
_toBinaryCoordinates(
|
|
139
|
+
geom: FlatIndexedGeometry,
|
|
140
|
+
transform: (data: number[], extent: number) => void
|
|
141
|
+
) {
|
|
160
142
|
let geometry;
|
|
161
143
|
|
|
162
144
|
// Apply the supplied transformation to data
|
|
163
|
-
transform(geom.data, this);
|
|
145
|
+
transform(geom.data, this.extent);
|
|
164
146
|
|
|
165
147
|
const coordLength = 2;
|
|
166
148
|
|
|
@@ -259,6 +241,28 @@ export class VectorTileFeature {
|
|
|
259
241
|
return lines;
|
|
260
242
|
}
|
|
261
243
|
|
|
244
|
+
/**
|
|
245
|
+
* Expands the protobuf data to an intermediate Flat GeoJSON
|
|
246
|
+
* data format, which maps closely to the binary data buffers.
|
|
247
|
+
* It is similar to GeoJSON, but rather than storing the coordinates
|
|
248
|
+
* in multidimensional arrays, we have a 1D `data` with all the
|
|
249
|
+
* coordinates, and then index into this using the `indices`
|
|
250
|
+
* parameter, e.g.
|
|
251
|
+
*
|
|
252
|
+
* geometry: {
|
|
253
|
+
* type: 'Point', data: [1,2], indices: [0]
|
|
254
|
+
* }
|
|
255
|
+
* geometry: {
|
|
256
|
+
* type: 'LineString', data: [1,2,3,4,...], indices: [0]
|
|
257
|
+
* }
|
|
258
|
+
* geometry: {
|
|
259
|
+
* type: 'Polygon', data: [1,2,3,4,...], indices: [[0, 2]]
|
|
260
|
+
* }
|
|
261
|
+
* Thus the indices member lets us look up the relevant range
|
|
262
|
+
* from the data array.
|
|
263
|
+
* The Multi* versions of the above types share the same data
|
|
264
|
+
* structure, just with multiple elements in the indices array
|
|
265
|
+
*/
|
|
262
266
|
// eslint-disable-next-line complexity, max-statements
|
|
263
267
|
loadFlatGeometry(): FlatIndexedGeometry {
|
|
264
268
|
const pbf = this._pbf;
|
|
@@ -315,7 +319,11 @@ export class VectorTileFeature {
|
|
|
315
319
|
}
|
|
316
320
|
}
|
|
317
321
|
|
|
318
|
-
function
|
|
322
|
+
function _toGeoJSONFeature(
|
|
323
|
+
vtFeature: VectorTileFeature,
|
|
324
|
+
coords: number[][][],
|
|
325
|
+
transform: (data: number[][], extent: number) => void
|
|
326
|
+
): Feature {
|
|
319
327
|
let type = VectorTileFeature.types[vtFeature.type];
|
|
320
328
|
let i: number;
|
|
321
329
|
let j: number;
|
|
@@ -328,13 +336,13 @@ function _toGeoJSON(vtFeature: VectorTileFeature, coords: number[][][], transfor
|
|
|
328
336
|
points[i] = coords[i][0];
|
|
329
337
|
}
|
|
330
338
|
coordinates = points;
|
|
331
|
-
transform(coordinates, vtFeature);
|
|
339
|
+
transform(coordinates, vtFeature.extent);
|
|
332
340
|
break;
|
|
333
341
|
|
|
334
342
|
case 2:
|
|
335
343
|
coordinates = coords;
|
|
336
344
|
for (i = 0; i < coordinates.length; i++) {
|
|
337
|
-
transform(coordinates[i], vtFeature);
|
|
345
|
+
transform(coordinates[i], vtFeature.extent);
|
|
338
346
|
}
|
|
339
347
|
break;
|
|
340
348
|
|
|
@@ -342,7 +350,7 @@ function _toGeoJSON(vtFeature: VectorTileFeature, coords: number[][][], transfor
|
|
|
342
350
|
coordinates = classifyRings(coords);
|
|
343
351
|
for (i = 0; i < coordinates.length; i++) {
|
|
344
352
|
for (j = 0; j < coordinates[i].length; j++) {
|
|
345
|
-
transform(coordinates[i][j], vtFeature);
|
|
353
|
+
transform(coordinates[i][j], vtFeature.extent);
|
|
346
354
|
}
|
|
347
355
|
}
|
|
348
356
|
break;
|
|
@@ -368,7 +376,8 @@ function _toGeoJSON(vtFeature: VectorTileFeature, coords: number[][][], transfor
|
|
|
368
376
|
};
|
|
369
377
|
|
|
370
378
|
if (vtFeature.id !== null) {
|
|
371
|
-
result.
|
|
379
|
+
result.properties ||= {};
|
|
380
|
+
result.properties.id = vtFeature.id;
|
|
372
381
|
}
|
|
373
382
|
|
|
374
383
|
return result;
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
// Copyright (c) vis.gl contributors
|
|
4
4
|
// Forked from https://github.com/mapbox/geojson-vt under compatible ISC license
|
|
5
5
|
|
|
6
|
-
import type {
|
|
6
|
+
import type {TableTileFeature} from './tile';
|
|
7
7
|
import {createFeature} from './feature';
|
|
8
8
|
|
|
9
9
|
/* eslint-disable no-continue */
|
|
@@ -21,7 +21,7 @@ import {createFeature} from './feature';
|
|
|
21
21
|
*/
|
|
22
22
|
// eslint-disable-next-line max-params, complexity, max-statements
|
|
23
23
|
export function clip(
|
|
24
|
-
features:
|
|
24
|
+
features: TableTileFeature[],
|
|
25
25
|
scale: number,
|
|
26
26
|
k1: number,
|
|
27
27
|
k2: number,
|
|
@@ -29,7 +29,7 @@ export function clip(
|
|
|
29
29
|
minAll: number,
|
|
30
30
|
maxAll: number,
|
|
31
31
|
options: {lineMetrics: boolean}
|
|
32
|
-
):
|
|
32
|
+
): TableTileFeature[] | null {
|
|
33
33
|
k1 /= scale;
|
|
34
34
|
k2 /= scale;
|
|
35
35
|
|
|
@@ -41,7 +41,7 @@ export function clip(
|
|
|
41
41
|
return null; // trivial reject
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
-
const clipped:
|
|
44
|
+
const clipped: TableTileFeature[] = [];
|
|
45
45
|
|
|
46
46
|
for (const feature of features) {
|
|
47
47
|
const geometry = feature.geometry;
|
|
@@ -7,14 +7,16 @@
|
|
|
7
7
|
// @ts-nocheck
|
|
8
8
|
|
|
9
9
|
import type {Feature, FeatureCollection} from '@loaders.gl/schema';
|
|
10
|
-
import type {
|
|
10
|
+
import type {TableTileFeature} from './tile';
|
|
11
11
|
|
|
12
12
|
import {simplify} from './simplify';
|
|
13
13
|
import {createFeature} from './feature';
|
|
14
14
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
15
|
+
/**
|
|
16
|
+
* converts a GeoJSON feature into an intermediate projected JSON vector format
|
|
17
|
+
* with simplification data
|
|
18
|
+
*/
|
|
19
|
+
export function convert(data: Feature | FeatureCollection, options): TableTileFeature[] {
|
|
18
20
|
const features = [];
|
|
19
21
|
if (data.type === 'FeatureCollection') {
|
|
20
22
|
for (let i = 0; i < data.features.length; i++) {
|
|
@@ -31,14 +33,22 @@ export function convert(data: Feature | FeatureCollection, options): GeoJSONTile
|
|
|
31
33
|
}
|
|
32
34
|
|
|
33
35
|
export type ConvertFeatureOptions = {
|
|
36
|
+
/** max zoom to preserve detail on */
|
|
34
37
|
maxZoom?: number;
|
|
35
|
-
tolerance
|
|
36
|
-
|
|
37
|
-
|
|
38
|
+
/** simplification tolerance (higher means simpler) */
|
|
39
|
+
tolerance?: number;
|
|
40
|
+
/** tile extent */
|
|
41
|
+
extent?: number;
|
|
42
|
+
/** whether to calculate line metrics */
|
|
43
|
+
lineMetrics?: boolean;
|
|
38
44
|
};
|
|
39
45
|
|
|
46
|
+
/**
|
|
47
|
+
* converts a GeoJSON feature into an intermediate projected JSON vector format
|
|
48
|
+
* with simplification data
|
|
49
|
+
*/
|
|
40
50
|
function convertFeature(
|
|
41
|
-
features:
|
|
51
|
+
features: TableTileFeature[],
|
|
42
52
|
geojson: Feature,
|
|
43
53
|
options: ConvertFeatureOptions,
|
|
44
54
|
index: number
|
|
@@ -3,10 +3,10 @@
|
|
|
3
3
|
// Copyright (c) vis.gl contributors
|
|
4
4
|
// Forked from https://github.com/mapbox/geojson-vt under compatible ISC license
|
|
5
5
|
|
|
6
|
-
import {
|
|
6
|
+
import {TableTileFeature} from './tile';
|
|
7
7
|
|
|
8
|
-
export function createFeature(id, type, geom, tags):
|
|
9
|
-
const feature:
|
|
8
|
+
export function createFeature(id, type, geom, tags): TableTileFeature {
|
|
9
|
+
const feature: TableTileFeature = {
|
|
10
10
|
// eslint-disable-next-line
|
|
11
11
|
id: id == null ? null : id,
|
|
12
12
|
type,
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
|
|
6
6
|
// import type {Feature} from '@loaders.gl/schema';
|
|
7
7
|
|
|
8
|
-
export type
|
|
8
|
+
export type TableTileFeature = {
|
|
9
9
|
type: any;
|
|
10
10
|
geometry: any;
|
|
11
11
|
|
|
@@ -20,8 +20,8 @@ export type GeoJSONTileFeature = {
|
|
|
20
20
|
maxY: number;
|
|
21
21
|
};
|
|
22
22
|
|
|
23
|
-
export type
|
|
24
|
-
features:
|
|
23
|
+
export type TableTile = {
|
|
24
|
+
features: TableTileFeature[]; // Feature[]; Doesn't seem JSON compatible??
|
|
25
25
|
type?: number;
|
|
26
26
|
tags?: Record<string, string>;
|
|
27
27
|
|
|
@@ -53,9 +53,9 @@ export type CreateTileOptions = {
|
|
|
53
53
|
/**
|
|
54
54
|
* Create a tile from features and tile index
|
|
55
55
|
*/
|
|
56
|
-
export function createTile(features: any[], z, tx, ty, options: CreateTileOptions):
|
|
56
|
+
export function createTile(features: any[], z, tx, ty, options: CreateTileOptions): TableTile {
|
|
57
57
|
const tolerance = z === options.maxZoom ? 0 : options.tolerance / ((1 << z) * options.extent);
|
|
58
|
-
const tile:
|
|
58
|
+
const tile: TableTile = {
|
|
59
59
|
features: [],
|
|
60
60
|
numPoints: 0,
|
|
61
61
|
numSimplified: 0,
|
|
@@ -77,7 +77,7 @@ export function createTile(features: any[], z, tx, ty, options: CreateTileOption
|
|
|
77
77
|
}
|
|
78
78
|
|
|
79
79
|
// eslint-disable-next-line complexity, max-statements
|
|
80
|
-
function addFeature(tile:
|
|
80
|
+
function addFeature(tile: TableTile, feature, tolerance: number, options: CreateTileOptions) {
|
|
81
81
|
const geom = feature.geometry;
|
|
82
82
|
const type = feature.type;
|
|
83
83
|
const simplified: number[] = [];
|
|
@@ -121,7 +121,7 @@ function addFeature(tile: GeoJSONTile, feature, tolerance: number, options: Crea
|
|
|
121
121
|
}
|
|
122
122
|
|
|
123
123
|
// @ts-expect-error TODO - create sub type?
|
|
124
|
-
const tileFeature:
|
|
124
|
+
const tileFeature: TableTileFeature = {
|
|
125
125
|
geometry: simplified,
|
|
126
126
|
type:
|
|
127
127
|
type === 'Polygon' || type === 'MultiPolygon'
|
|
@@ -142,7 +142,7 @@ function addFeature(tile: GeoJSONTile, feature, tolerance: number, options: Crea
|
|
|
142
142
|
function addLine(
|
|
143
143
|
result,
|
|
144
144
|
geom,
|
|
145
|
-
tile:
|
|
145
|
+
tile: TableTile,
|
|
146
146
|
tolerance: number,
|
|
147
147
|
isPolygon: boolean,
|
|
148
148
|
isOuter: boolean
|
|
@@ -3,13 +3,13 @@
|
|
|
3
3
|
// Copyright (c) vis.gl contributors
|
|
4
4
|
// Forked from https://github.com/mapbox/geojson-vt under compatible ISC license
|
|
5
5
|
|
|
6
|
-
import type {
|
|
6
|
+
import type {TableTile} from './tile';
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* Transforms the coordinates of each feature in the given tile from
|
|
10
10
|
* mercator-projected space into (extent x extent) tile space.
|
|
11
11
|
*/
|
|
12
|
-
export function transformTile(tile:
|
|
12
|
+
export function transformTile(tile: TableTile, extent: number): TableTile {
|
|
13
13
|
if (tile.transformed) {
|
|
14
14
|
return tile;
|
|
15
15
|
}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
// Copyright (c) vis.gl contributors
|
|
4
4
|
// Forked from https://github.com/mapbox/geojson-vt under compatible ISC license
|
|
5
5
|
|
|
6
|
-
import type {
|
|
6
|
+
import type {TableTileFeature} from './tile';
|
|
7
7
|
import {clip} from './clip';
|
|
8
8
|
import {createFeature} from './feature';
|
|
9
9
|
|
|
@@ -22,9 +22,9 @@ export type WrapOptions = {
|
|
|
22
22
|
* @param options buffer and extent
|
|
23
23
|
* @returns
|
|
24
24
|
*/
|
|
25
|
-
export function wrap(features:
|
|
25
|
+
export function wrap(features: TableTileFeature[], options: WrapOptions) {
|
|
26
26
|
const buffer = options.buffer / options.extent;
|
|
27
|
-
let merged:
|
|
27
|
+
let merged: TableTileFeature[] = features;
|
|
28
28
|
const left = clip(features, 1, -1 - buffer, buffer, 0, -1, 2, options); // left world copy
|
|
29
29
|
const right = clip(features, 1, 1 - buffer, 2 + buffer, 0, -1, 2, options); // right world copy
|
|
30
30
|
|
|
@@ -48,8 +48,8 @@ export function wrap(features: GeoJSONTileFeature[], options: WrapOptions) {
|
|
|
48
48
|
* @param offset
|
|
49
49
|
* @returns
|
|
50
50
|
*/
|
|
51
|
-
function shiftFeatureCoords(features:
|
|
52
|
-
const newFeatures:
|
|
51
|
+
function shiftFeatureCoords(features: TableTileFeature[], offset: number): TableTileFeature[] {
|
|
52
|
+
const newFeatures: TableTileFeature[] = [];
|
|
53
53
|
|
|
54
54
|
for (let i = 0; i < features.length; i++) {
|
|
55
55
|
const feature = features[i];
|
package/src/mvt-source.ts
CHANGED
|
@@ -2,8 +2,9 @@
|
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
3
|
// Copyright (c) vis.gl contributors
|
|
4
4
|
|
|
5
|
-
import type {
|
|
5
|
+
import type {ImageType, DataSourceProps} from '@loaders.gl/loader-utils';
|
|
6
6
|
import type {ImageTileSource, VectorTileSource} from '@loaders.gl/loader-utils';
|
|
7
|
+
import type {GetTileParameters, GetTileDataParameters} from '@loaders.gl/loader-utils';
|
|
7
8
|
import {DataSource, resolvePath} from '@loaders.gl/loader-utils';
|
|
8
9
|
import {ImageLoader, ImageLoaderOptions, getBinaryImageMetadata} from '@loaders.gl/images';
|
|
9
10
|
import {
|
|
@@ -14,8 +15,6 @@ import {
|
|
|
14
15
|
TileJSONLoaderOptions
|
|
15
16
|
} from '@loaders.gl/mvt';
|
|
16
17
|
|
|
17
|
-
import {TileLoadParameters} from '@loaders.gl/loader-utils';
|
|
18
|
-
|
|
19
18
|
/** Properties for a Mapbox Vector Tile Source */
|
|
20
19
|
export type MVTSourceProps = DataSourceProps & {
|
|
21
20
|
/** Root url of tileset */
|
|
@@ -101,8 +100,8 @@ export class MVTSource extends DataSource implements ImageTileSource, VectorTile
|
|
|
101
100
|
return this.mimeType;
|
|
102
101
|
}
|
|
103
102
|
|
|
104
|
-
async getTile(
|
|
105
|
-
const {x, y, z} =
|
|
103
|
+
async getTile(parameters: GetTileParameters): Promise<ArrayBuffer | null> {
|
|
104
|
+
const {x, y, z} = parameters;
|
|
106
105
|
const tileUrl = this.getTileURL(x, y, z);
|
|
107
106
|
const response = await this.fetch(tileUrl);
|
|
108
107
|
if (!response.ok) {
|
|
@@ -115,8 +114,8 @@ export class MVTSource extends DataSource implements ImageTileSource, VectorTile
|
|
|
115
114
|
// Tile Source interface implementation: deck.gl compatible API
|
|
116
115
|
// TODO - currently only handles image tiles, not vector tiles
|
|
117
116
|
|
|
118
|
-
async getTileData(
|
|
119
|
-
const {x, y, z} =
|
|
117
|
+
async getTileData(parameters: GetTileDataParameters): Promise<any> {
|
|
118
|
+
const {x, y, z} = parameters.index;
|
|
120
119
|
// const metadata = await this.metadata;
|
|
121
120
|
// mimeType = metadata?.tileMIMEType || 'application/vnd.mapbox-vector-tile';
|
|
122
121
|
|