@loaders.gl/mvt 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.
Files changed (74) hide show
  1. package/dist/dist.dev.js +777 -688
  2. package/dist/dist.min.js +1 -1
  3. package/dist/index.cjs +746 -659
  4. package/dist/index.cjs.map +4 -4
  5. package/dist/index.d.ts +6 -5
  6. package/dist/index.d.ts.map +1 -1
  7. package/dist/index.js +5 -1
  8. package/dist/lib/parse-tilejson.js +1 -1
  9. package/dist/lib/utils/geometry-utils.js +1 -1
  10. package/dist/lib/vector-tiler/{clip.d.ts → features/clip-features.d.ts} +4 -4
  11. package/dist/lib/vector-tiler/features/clip-features.d.ts.map +1 -0
  12. package/dist/lib/vector-tiler/{clip.js → features/clip-features.js} +4 -4
  13. package/dist/lib/vector-tiler/{convert.d.ts → features/convert-feature.d.ts} +7 -7
  14. package/dist/lib/vector-tiler/features/convert-feature.d.ts.map +1 -0
  15. package/dist/lib/vector-tiler/features/convert-feature.js +140 -0
  16. package/dist/lib/vector-tiler/features/proto-feature.d.ts +30 -0
  17. package/dist/lib/vector-tiler/features/proto-feature.d.ts.map +1 -0
  18. package/dist/lib/vector-tiler/features/proto-feature.js +52 -0
  19. package/dist/lib/vector-tiler/{simplify.d.ts → features/simplify-path.d.ts} +2 -2
  20. package/dist/lib/vector-tiler/features/simplify-path.d.ts.map +1 -0
  21. package/dist/lib/vector-tiler/{simplify.js → features/simplify-path.js} +3 -3
  22. package/dist/lib/vector-tiler/{wrap.d.ts → features/wrap-features.d.ts} +5 -5
  23. package/dist/lib/vector-tiler/features/wrap-features.d.ts.map +1 -0
  24. package/dist/lib/vector-tiler/{wrap.js → features/wrap-features.js} +33 -26
  25. package/dist/lib/vector-tiler/proto-tile.d.ts +40 -0
  26. package/dist/lib/vector-tiler/proto-tile.d.ts.map +1 -0
  27. package/dist/lib/vector-tiler/proto-tile.js +138 -0
  28. package/dist/lib/vector-tiler/tile-to-geojson.d.ts +12 -0
  29. package/dist/lib/vector-tiler/tile-to-geojson.d.ts.map +1 -0
  30. package/dist/lib/vector-tiler/tile-to-geojson.js +81 -0
  31. package/dist/lib/vector-tiler/transform-tile.d.ts +7 -0
  32. package/dist/lib/vector-tiler/transform-tile.d.ts.map +1 -0
  33. package/dist/lib/vector-tiler/transform-tile.js +41 -0
  34. package/dist/mvt-loader.js +1 -1
  35. package/dist/mvt-source.d.ts +31 -14
  36. package/dist/mvt-source.d.ts.map +1 -1
  37. package/dist/mvt-source.js +26 -6
  38. package/dist/mvt-worker.js +4 -4
  39. package/dist/table-tile-source.d.ts +66 -36
  40. package/dist/table-tile-source.d.ts.map +1 -1
  41. package/dist/table-tile-source.js +167 -117
  42. package/dist/tilejson-loader.js +1 -1
  43. package/package.json +6 -6
  44. package/src/index.ts +13 -6
  45. package/src/lib/parse-tilejson.ts +1 -1
  46. package/src/lib/utils/geometry-utils.ts +1 -1
  47. package/src/lib/vector-tiler/{clip.ts → features/clip-features.ts} +8 -8
  48. package/src/lib/vector-tiler/{convert.ts → features/convert-feature.ts} +91 -70
  49. package/src/lib/vector-tiler/features/proto-feature.ts +104 -0
  50. package/src/lib/vector-tiler/{simplify.ts → features/simplify-path.ts} +8 -3
  51. package/src/lib/vector-tiler/{wrap.ts → features/wrap-features.ts} +44 -29
  52. package/src/lib/vector-tiler/proto-tile.ts +217 -0
  53. package/src/lib/vector-tiler/tile-to-geojson.ts +105 -0
  54. package/src/lib/vector-tiler/transform-tile.ts +57 -0
  55. package/src/mvt-source.ts +42 -18
  56. package/src/table-tile-source.ts +130 -85
  57. package/src/tilejson-loader.ts +2 -2
  58. package/dist/lib/vector-tiler/clip.d.ts.map +0 -1
  59. package/dist/lib/vector-tiler/convert.d.ts.map +0 -1
  60. package/dist/lib/vector-tiler/convert.js +0 -139
  61. package/dist/lib/vector-tiler/feature.d.ts +0 -3
  62. package/dist/lib/vector-tiler/feature.d.ts.map +0 -1
  63. package/dist/lib/vector-tiler/feature.js +0 -44
  64. package/dist/lib/vector-tiler/simplify.d.ts.map +0 -1
  65. package/dist/lib/vector-tiler/tile.d.ts +0 -38
  66. package/dist/lib/vector-tiler/tile.d.ts.map +0 -1
  67. package/dist/lib/vector-tiler/tile.js +0 -123
  68. package/dist/lib/vector-tiler/transform.d.ts +0 -7
  69. package/dist/lib/vector-tiler/transform.d.ts.map +0 -1
  70. package/dist/lib/vector-tiler/transform.js +0 -41
  71. package/dist/lib/vector-tiler/wrap.d.ts.map +0 -1
  72. package/src/lib/vector-tiler/feature.ts +0 -47
  73. package/src/lib/vector-tiler/tile.ts +0 -187
  74. package/src/lib/vector-tiler/transform.ts +0 -57
@@ -5,13 +5,51 @@
5
5
  import { log } from '@loaders.gl/loader-utils';
6
6
  import { deduceTableSchema } from '@loaders.gl/schema';
7
7
  import { Stats, Stat } from '@probe.gl/stats';
8
- import { convert } from "./lib/vector-tiler/convert.js"; // GeoJSON conversion and preprocessing
9
- import { clip } from "./lib/vector-tiler/clip.js"; // stripe clipping algorithm
10
- import { wrap } from "./lib/vector-tiler/wrap.js"; // date line processing
11
- import { transformTile } from "./lib/vector-tiler/transform.js"; // coordinate transformation
12
- import { createTile } from "./lib/vector-tiler/tile.js"; // final simplified tile generation
13
- import { projectToLngLat } from "./lib/utils/geometry-utils.js";
14
- import { convertToLocalCoordinates } from "./lib/utils/geometry-utils.js";
8
+ import { createProtoTile } from "./lib/vector-tiler/proto-tile.js";
9
+ import { transformTile } from "./lib/vector-tiler/transform-tile.js"; // coordinate transformation
10
+ import { convertTileToGeoJSON } from "./lib/vector-tiler/tile-to-geojson.js"; // tile clipping and wrapping
11
+ import { convertFeaturesToProtoFeature } from "./lib/vector-tiler/features/convert-feature.js";
12
+ import { clipFeatures } from "./lib/vector-tiler/features/clip-features.js"; // stripe clipping algorithm
13
+ import { wrapFeatures } from "./lib/vector-tiler/features/wrap-features.js"; // date line processing
14
+ /** Options to configure tiling */
15
+ export const TableTileSource = {
16
+ name: 'TableTiler',
17
+ id: 'table-tiler',
18
+ version: '0.0.0',
19
+ extensions: ['mvt'],
20
+ mimeTypes: ['application/octet-stream'],
21
+ options: {
22
+ table: {
23
+ coordinates: 'local',
24
+ promoteId: undefined,
25
+ maxZoom: 14,
26
+ indexMaxZoom: 5,
27
+ maxPointsPerTile: 10000,
28
+ tolerance: 3,
29
+ extent: 4096,
30
+ buffer: 64,
31
+ generateId: undefined
32
+ }
33
+ },
34
+ type: 'table',
35
+ testURL: (url) => url.endsWith('.geojson'),
36
+ createDataSource(url, options) {
37
+ const needsLoading = typeof url === 'string' || url instanceof Blob;
38
+ const loader = options?.table?.loaders?.[0];
39
+ const tablePromise = needsLoading ? loadTable(url, loader) : url;
40
+ return new DynamicVectorTileSource(tablePromise, options);
41
+ }
42
+ // @ts-expect-error
43
+ };
44
+ async function loadTable(url, loader) {
45
+ if (typeof url === 'string') {
46
+ const response = await fetch(url);
47
+ const data = await response.arrayBuffer();
48
+ return (await loader.parse(data));
49
+ }
50
+ const data = await url.arrayBuffer();
51
+ return (await loader.parse(data)); // options.loaders, options.loadOptions)
52
+ }
15
53
  /**
16
54
  * Dynamically vector tiles a table (the table needs a geometry column)
17
55
  * - Tiles are generated when requested.
@@ -27,27 +65,13 @@ import { convertToLocalCoordinates } from "./lib/utils/geometry-utils.js";
27
65
  * @todo - generate binary output tables
28
66
  * @todo - how does TileSourceLayer specify coordinates / decided which layer to render with
29
67
  */
30
- export class TableTileSource {
31
- static defaultProps = {
32
- coordinates: 'wgs84', // coordinates in tile coordinates or lng/lat
33
- maxZoom: 14, // max zoom to preserve detail on
34
- indexMaxZoom: 5, // max zoom in the tile index
35
- maxPointsPerTile: 100000, // max number of points per tile in the tile index
36
- tolerance: 3, // simplification tolerance (higher means simpler)
37
- extent: 4096, // tile extent
38
- buffer: 64, // tile buffer on each side
39
- lineMetrics: false, // whether to calculate line metrics
40
- // @ts-expect-error
41
- promoteId: undefined, // name of a feature property to be promoted to feature.id
42
- generateId: false, // whether to generate feature ids. Cannot be used with promoteId
43
- debug: 0 // logging level (0, 1 or 2)
44
- };
45
- /** Global stats for all TableTileSources */
68
+ export class DynamicVectorTileSource {
69
+ /** Global stats for all DynamicVectorTileSources */
46
70
  static stats = new Stats({
47
71
  id: 'table-tile-source-all',
48
72
  stats: [new Stat('count', 'tiles'), new Stat('count', 'features')]
49
73
  });
50
- /** Stats for this TableTileSource */
74
+ /** Stats for this DynamicVectorTileSource */
51
75
  stats = new Stats({
52
76
  id: 'table-tile-source',
53
77
  stats: [new Stat('tiles', 'count'), new Stat('features', 'count')]
@@ -56,6 +80,7 @@ export class TableTileSource {
56
80
  mimeType = 'application/vnd.mapbox-vector-tile';
57
81
  localCoordinates = true;
58
82
  /** The props that this tile source was created with */
83
+ // @ts-expect-error
59
84
  props;
60
85
  /* Schema of the data */
61
86
  schema = null;
@@ -68,7 +93,8 @@ export class TableTileSource {
68
93
  /** Metadata for the tile source (generated TileJSON/tilestats */
69
94
  metadata;
70
95
  constructor(table, props) {
71
- this.props = { ...TableTileSource.defaultProps, ...props };
96
+ // @ts-expect-error
97
+ this.props = { ...TableTileSource.options.table, ...props?.table };
72
98
  this.getTileData = this.getTileData.bind(this);
73
99
  this.ready = this.initializeTilesAsync(table);
74
100
  this.metadata = this.getMetadata();
@@ -112,11 +138,11 @@ export class TableTileSource {
112
138
  * @note Application must await `source.ready` before calling sync methods.
113
139
  */
114
140
  getTileSync(tileIndex) {
115
- const rawTile = this.getRawTile(tileIndex);
116
- if (!rawTile) {
141
+ const protoTile = this.getProtoTile(tileIndex);
142
+ if (!protoTile) {
117
143
  return null;
118
144
  }
119
- return convertToGeoJSONTable(rawTile, {
145
+ return convertTileToGeoJSON(protoTile, {
120
146
  coordinates: this.props.coordinates,
121
147
  tileIndex,
122
148
  extent: this.props.extent
@@ -133,31 +159,31 @@ export class TableTileSource {
133
159
  if (this.props.promoteId && this.props.generateId) {
134
160
  throw new Error('promoteId and generateId cannot be used together.');
135
161
  }
136
- log.log(1, 'TableTileSource creating root tiles', this.props)();
162
+ log.log(1, 'DynamicVectorTileSource creating root tiles', this.props)();
137
163
  // projects and adds simplification info
138
164
  log.time(1, 'preprocess table')();
139
- let features = convert(table, this.props);
165
+ let features = convertFeaturesToProtoFeature(table, this.props);
140
166
  log.timeEnd(1, 'preprocess table')();
141
167
  // wraps features (ie extreme west and extreme east)
142
168
  log.time(1, 'generate tiles')();
143
- features = wrap(features, this.props);
169
+ features = wrapFeatures(features, this.props);
144
170
  // start slicing from the top tile down
145
171
  if (features.length === 0) {
146
- log.log(1, 'TableTileSource: no features generated')();
172
+ log.log(1, 'DynamicVectorTileSource: no features generated')();
147
173
  return;
148
174
  }
149
175
  this.splitTile(features, 0, 0, 0);
150
176
  const rootTile = this.tiles[0];
151
177
  log.log(1, `root tile features: ${rootTile.numFeatures}, points: ${rootTile.numPoints}`)();
152
178
  log.timeEnd(1, 'generate tiles')();
153
- log.log(1, `TableTileSource: tiles generated: ${this.stats.get('total').count}`, this.stats)();
179
+ log.log(1, `DynamicVectorTileSource: tiles generated: ${this.stats.get('total').count}`, this.stats)();
154
180
  }
155
181
  /**
156
182
  * Return geojsonvt-style "half formed" vector tile
157
183
  * @note Application must await `source.ready` before calling sync methods.
158
184
  */
159
185
  // eslint-disable-next-line complexity, max-statements
160
- getRawTile(tileIndex) {
186
+ getProtoTile(tileIndex) {
161
187
  const { z, y } = tileIndex;
162
188
  let { x } = tileIndex;
163
189
  // z = +z;
@@ -168,7 +194,7 @@ export class TableTileSource {
168
194
  return null;
169
195
  }
170
196
  const z2 = 1 << z;
171
- x = (x + z2) & (z2 - 1); // wrap tile x coordinate
197
+ x = (x + z2) & (z2 - 1); // wrapFeatures tile x coordinate
172
198
  const id = toID(z, x, y);
173
199
  if (this.tiles[id]) {
174
200
  return transformTile(this.tiles[id], extent);
@@ -184,13 +210,13 @@ export class TableTileSource {
184
210
  y0 = y0 >> 1;
185
211
  parent = this.tiles[toID(z0, x0, y0)];
186
212
  }
187
- if (!parent || !parent.source) {
213
+ if (!parent || !parent.sourceFeatures) {
188
214
  return null;
189
215
  }
190
216
  // if we found a parent tile containing the original geometry, we can drill down from it
191
217
  log.log(1, 'found parent tile z%d-%d-%d', z0, x0, y0)();
192
218
  log.time(1, 'drilling down')();
193
- this.splitTile(parent.source, z0, x0, y0, z, x, y);
219
+ this.splitTile(parent.sourceFeatures, z0, x0, y0, z, x, y);
194
220
  log.timeEnd(1, 'drilling down')();
195
221
  return this.tiles[id] ? transformTile(this.tiles[id], extent) : null;
196
222
  }
@@ -216,23 +242,23 @@ export class TableTileSource {
216
242
  let tile = this.tiles[id];
217
243
  if (!tile) {
218
244
  log.time(2, 'tile creation')();
219
- tile = this.tiles[id] = createTile(features, z, x, y, this.props);
245
+ tile = this.tiles[id] = createProtoTile(features, z, x, y, this.props);
220
246
  this.tileCoords.push({ z, x, y });
221
247
  const key = `z${z}`;
222
248
  let stat = this.stats.get(key, 'count');
223
249
  stat.incrementCount();
224
250
  stat = this.stats.get('total');
225
251
  stat.incrementCount();
226
- stat = TableTileSource.stats.get(key, 'count');
252
+ stat = DynamicVectorTileSource.stats.get(key, 'count');
227
253
  stat.incrementCount();
228
- stat = TableTileSource.stats.get('total');
254
+ stat = DynamicVectorTileSource.stats.get('total');
229
255
  stat.incrementCount();
230
256
  log.log(2, 'tile z%d-%d-%d (features: %d, points: %d, simplified: %d)', z, x, y, tile.numFeatures, tile.numPoints, tile.numSimplified)();
231
257
  log.timeEnd(2, 'tile creation')();
232
258
  }
233
259
  // save reference to original geometry in tile so that we can drill down later if we stop now
234
- tile.source = features;
235
- /** eslint-disable no-continue */
260
+ tile.sourceFeatures = features;
261
+ /* eslint-disable no-continue */
236
262
  // if it's the first-pass tiling
237
263
  if (cz === undefined) {
238
264
  // stop tiling if we reached max zoom, or if the tile is too simple
@@ -254,7 +280,7 @@ export class TableTileSource {
254
280
  }
255
281
  }
256
282
  // if we slice further down, no need to keep source geometry
257
- tile.source = null;
283
+ tile.sourceFeatures = null;
258
284
  if (features.length === 0)
259
285
  continue;
260
286
  log.time(2, 'clipping tile')();
@@ -267,18 +293,18 @@ export class TableTileSource {
267
293
  let bl = null;
268
294
  let tr = null;
269
295
  let br = null;
270
- let left = clip(features, z2, x - k1, x + k3, 0, tile.minX, tile.maxX, this.props);
271
- let right = clip(features, z2, x + k2, x + k4, 0, tile.minX, tile.maxX, this.props);
296
+ let left = clipFeatures(features, z2, x - k1, x + k3, 0, tile.minX, tile.maxX, this.props);
297
+ let right = clipFeatures(features, z2, x + k2, x + k4, 0, tile.minX, tile.maxX, this.props);
272
298
  // @ts-expect-error - unclear why this is needed?
273
299
  features = null;
274
300
  if (left) {
275
- tl = clip(left, z2, y - k1, y + k3, 1, tile.minY, tile.maxY, this.props);
276
- bl = clip(left, z2, y + k2, y + k4, 1, tile.minY, tile.maxY, this.props);
301
+ tl = clipFeatures(left, z2, y - k1, y + k3, 1, tile.minY, tile.maxY, this.props);
302
+ bl = clipFeatures(left, z2, y + k2, y + k4, 1, tile.minY, tile.maxY, this.props);
277
303
  left = null;
278
304
  }
279
305
  if (right) {
280
- tr = clip(right, z2, y - k1, y + k3, 1, tile.minY, tile.maxY, this.props);
281
- br = clip(right, z2, y + k2, y + k4, 1, tile.minY, tile.maxY, this.props);
306
+ tr = clipFeatures(right, z2, y - k1, y + k3, 1, tile.minY, tile.maxY, this.props);
307
+ br = clipFeatures(right, z2, y + k2, y + k4, 1, tile.minY, tile.maxY, this.props);
282
308
  right = null;
283
309
  }
284
310
  log.timeEnd(2, 'clipping tile')();
@@ -292,79 +318,103 @@ export class TableTileSource {
292
318
  function toID(z, x, y) {
293
319
  return ((1 << z) * y + x) * 32 + z;
294
320
  }
321
+ /*
322
+
295
323
  // eslint-disable-next-line max-statements, complexity
296
- function convertToGeoJSONTable(vtTile, props) {
297
- const features = [];
298
- for (const rawFeature of vtTile.features) {
299
- if (!rawFeature || !rawFeature.geometry) {
300
- continue;
324
+ function convertToGeoJSONTable(
325
+ vtTile: ProtoTile,
326
+ props: {
327
+ coordinates: 'local' | 'wgs84' | 'EPSG:4326';
328
+ tileIndex: {x: number; y: number; z: number};
329
+ extent: number;
330
+ }
331
+ ): GeoJSONTable | null {
332
+ const features: Feature[] = [];
333
+ for (const rawFeature of vtTile.features) {
334
+ if (!rawFeature || !rawFeature.geometry) {
335
+ continue;
336
+ }
337
+
338
+ let type:
339
+ | 'Point'
340
+ | 'MultiPoint'
341
+ | 'LineString'
342
+ | 'MultiLineString'
343
+ | 'Polygon'
344
+ | 'MultiPolygon';
345
+
346
+ let coordinates: any;
347
+
348
+ // raw geometry
349
+ switch (rawFeature.type) {
350
+ case 1:
351
+ if (rawFeature.geometry.length === 1) {
352
+ type = 'Point';
353
+ coordinates = rawFeature.geometry[0];
354
+ } else {
355
+ type = 'MultiPoint';
356
+ coordinates = rawFeature.geometry;
301
357
  }
302
- let type;
303
- let coordinates;
304
- // raw geometry
305
- switch (rawFeature.type) {
306
- case 1:
307
- if (rawFeature.geometry.length === 1) {
308
- type = 'Point';
309
- coordinates = rawFeature.geometry[0];
310
- }
311
- else {
312
- type = 'MultiPoint';
313
- coordinates = rawFeature.geometry;
314
- }
315
- break;
316
- case 2:
317
- if (rawFeature.geometry.length === 1) {
318
- type = 'LineString';
319
- coordinates = rawFeature.geometry[0];
320
- }
321
- else {
322
- type = 'MultiLineString';
323
- coordinates = rawFeature.geometry;
324
- }
325
- break;
326
- case 3:
327
- if (rawFeature.geometry.length > 1) {
328
- type = 'MultiPolygon';
329
- coordinates = [rawFeature.geometry];
330
- }
331
- else {
332
- type = 'Polygon';
333
- coordinates = rawFeature.geometry;
334
- }
335
- break;
336
- default:
337
- continue;
358
+ break;
359
+ case 2:
360
+ if (rawFeature.geometry.length === 1) {
361
+ type = 'LineString';
362
+ coordinates = rawFeature.geometry[0];
363
+ } else {
364
+ type = 'MultiLineString';
365
+ coordinates = rawFeature.geometry;
338
366
  }
339
- switch (props.coordinates) {
340
- case 'EPSG:4326':
341
- case 'wgs84':
342
- projectToLngLat(coordinates, props.tileIndex, props.extent);
343
- break;
344
- case 'local':
345
- convertToLocalCoordinates(coordinates, props.extent);
346
- break;
347
- default:
348
- throw new Error(`Unsupported CRS ${props.coordinates}`);
367
+ break;
368
+ case 3:
369
+ if (rawFeature.geometry.length > 1) {
370
+ type = 'MultiPolygon';
371
+ coordinates = [rawFeature.geometry];
372
+ } else {
373
+ type = 'Polygon';
374
+ coordinates = rawFeature.geometry;
349
375
  }
350
- const feature = {
351
- type: 'Feature',
352
- geometry: {
353
- type,
354
- coordinates
355
- },
356
- properties: rawFeature.tags || {},
357
- id: rawFeature.id
358
- };
359
- features.push(feature);
376
+ break;
377
+ default:
378
+ continue;
360
379
  }
361
- if (features.length === 0) {
362
- return null;
380
+
381
+ switch (props.coordinates) {
382
+ case 'EPSG:4326':
383
+ case 'wgs84':
384
+ projectToLngLat(coordinates, props.tileIndex, props.extent);
385
+ break;
386
+
387
+ case 'local':
388
+ convertToLocalCoordinates(coordinates, props.extent);
389
+ break;
390
+
391
+ default:
392
+ throw new Error(`Unsupported CRS ${props.coordinates}`);
363
393
  }
364
- const table = {
365
- shape: 'geojson-table',
366
- type: 'FeatureCollection',
367
- features
394
+
395
+ const feature: Feature = {
396
+ type: 'Feature',
397
+ geometry: {
398
+ type,
399
+ coordinates
400
+ },
401
+ properties: rawFeature.tags || {},
402
+ id: rawFeature.id
368
403
  };
369
- return table;
404
+
405
+ features.push(feature);
406
+ }
407
+
408
+ if (features.length === 0) {
409
+ return null;
410
+ }
411
+
412
+ const table: GeoJSONTable = {
413
+ shape: 'geojson-table',
414
+ type: 'FeatureCollection',
415
+ features
416
+ };
417
+
418
+ return table;
370
419
  }
420
+ */
@@ -4,7 +4,7 @@
4
4
  import { parseTileJSON } from "./lib/parse-tilejson.js";
5
5
  // __VERSION__ is injected by babel-plugin-version-inline
6
6
  // @ts-ignore TS2304: Cannot find name '__VERSION__'.
7
- const VERSION = typeof "4.3.0-alpha.1" !== 'undefined' ? "4.3.0-alpha.1" : 'latest';
7
+ const VERSION = typeof "4.3.0-alpha.2" !== 'undefined' ? "4.3.0-alpha.2" : 'latest';
8
8
  /**
9
9
  * Loader for TileJSON metadata
10
10
  */
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@loaders.gl/mvt",
3
3
  "description": "Loader for Mapbox Vector Tiles",
4
- "version": "4.3.0-alpha.2",
4
+ "version": "4.3.0-alpha.3",
5
5
  "license": "MIT",
6
6
  "type": "module",
7
7
  "publishConfig": {
@@ -41,10 +41,10 @@
41
41
  "build-worker": "esbuild src/workers/mvt-worker.ts --bundle --outfile=dist/mvt-worker.js --define:__VERSION__=\\\"$npm_package_version\\\""
42
42
  },
43
43
  "dependencies": {
44
- "@loaders.gl/gis": "4.3.0-alpha.2",
45
- "@loaders.gl/images": "4.3.0-alpha.2",
46
- "@loaders.gl/loader-utils": "4.3.0-alpha.2",
47
- "@loaders.gl/schema": "4.3.0-alpha.2",
44
+ "@loaders.gl/gis": "4.3.0-alpha.3",
45
+ "@loaders.gl/images": "4.3.0-alpha.3",
46
+ "@loaders.gl/loader-utils": "4.3.0-alpha.3",
47
+ "@loaders.gl/schema": "4.3.0-alpha.3",
48
48
  "@math.gl/polygon": "^4.0.0",
49
49
  "@probe.gl/stats": "^4.0.0",
50
50
  "pbf": "^3.2.1"
@@ -55,5 +55,5 @@
55
55
  "peerDependencies": {
56
56
  "@loaders.gl/core": "^4.0.0"
57
57
  },
58
- "gitHead": "77a3cb538ab7a1fbf74245f25590210451689f5c"
58
+ "gitHead": "3213679d79e6ff2814d48fd3337acfa446c74099"
59
59
  }
package/src/index.ts CHANGED
@@ -2,16 +2,23 @@
2
2
  // SPDX-License-Identifier: MIT
3
3
  // Copyright (c) vis.gl contributors
4
4
 
5
- export type {MVTLoaderOptions} from './mvt-loader';
6
- export {MVTLoader, MVTWorkerLoader} from './mvt-loader';
5
+ // TileJSONLoader
7
6
 
8
- export type {TileJSON} from './lib/parse-tilejson';
9
- export type {TileJSONLoaderOptions} from './tilejson-loader';
10
7
  export {TileJSONLoader} from './tilejson-loader';
8
+ export type {TileJSONLoaderOptions} from './tilejson-loader';
9
+ export type {TileJSON} from './lib/parse-tilejson';
10
+
11
+ // MVTLoader
12
+
13
+ export {MVTLoader, MVTWorkerLoader} from './mvt-loader';
14
+ export type {MVTLoaderOptions} from './mvt-loader';
15
+
16
+ // MVTSource
11
17
 
12
18
  export {MVTSource} from './mvt-source';
19
+ export type {MVTTileSource, MVTTileSourceProps} from './mvt-source';
13
20
 
14
- // TableTileSource
21
+ // TableTileSource (dynamically tiles a table)
15
22
 
16
- export type {TableTileSourceProps} from './table-tile-source';
17
23
  export {TableTileSource} from './table-tile-source';
24
+ export type {DynamicVectorTileSource, DynamicVectorTileSourceProps} from './table-tile-source';
@@ -419,7 +419,7 @@ function attributeTypeToFieldType(aType: string): {type: string} {
419
419
  const type = aType.toLowerCase();
420
420
  if (!type || !attrTypeMap[type]) {
421
421
  // console.warn(
422
- // `cannot convert attribute type ${type} to loaders.gl data type, use string by default`
422
+ // `cannot convert feature type ${type} to loaders.gl data type, use string by default`
423
423
  // );
424
424
  }
425
425
  return attrTypeMap[type] || {type: 'string'};
@@ -52,7 +52,7 @@ export function convertToLocalCoordinates(
52
52
  * @param feature
53
53
  */
54
54
  export function convertToLocalCoordinatesFlat(data: number[], extent: number): void {
55
- for (let i = 0, il = data.length; i < il; ++i) {
55
+ for (let i = 0; i < data.length; ++i) {
56
56
  data[i] /= extent;
57
57
  }
58
58
  }
@@ -3,8 +3,8 @@
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 {TableTileFeature} from './tile';
7
- import {createFeature} from './feature';
6
+ import type {ProtoFeature} from './proto-feature';
7
+ import {createProtoFeature} from './proto-feature';
8
8
 
9
9
  /* eslint-disable no-continue */
10
10
 
@@ -20,8 +20,8 @@ import {createFeature} from './feature';
20
20
  * @param minAll and maxAll: minimum and maximum coordinate value for all features
21
21
  */
22
22
  // eslint-disable-next-line max-params, complexity, max-statements
23
- export function clip(
24
- features: TableTileFeature[],
23
+ export function clipFeatures(
24
+ features: ProtoFeature[],
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
- ): TableTileFeature[] | null {
32
+ ): ProtoFeature[] | 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: TableTileFeature[] = [];
44
+ const clipped: ProtoFeature[] = [];
45
45
 
46
46
  for (const feature of features) {
47
47
  const geometry = feature.geometry;
@@ -82,7 +82,7 @@ export function clip(
82
82
  if (newGeometry.length) {
83
83
  if (options.lineMetrics && type === 'LineString') {
84
84
  for (const line of newGeometry) {
85
- clipped.push(createFeature(feature.id, type, line, feature.tags));
85
+ clipped.push(createProtoFeature(feature.id, type, line, feature.tags));
86
86
  }
87
87
  continue;
88
88
  }
@@ -100,7 +100,7 @@ export function clip(
100
100
  type = newGeometry.length === 3 ? 'Point' : 'MultiPoint';
101
101
  }
102
102
 
103
- clipped.push(createFeature(feature.id, type, newGeometry, feature.tags));
103
+ clipped.push(createProtoFeature(feature.id, type, newGeometry, feature.tags));
104
104
  }
105
105
  }
106
106