@loaders.gl/mvt 4.3.1 → 4.4.0-alpha.1

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 (51) hide show
  1. package/dist/dist.dev.js +151 -93
  2. package/dist/dist.min.js +1 -1
  3. package/dist/index.cjs +74 -78
  4. package/dist/index.cjs.map +4 -4
  5. package/dist/index.d.ts +2 -2
  6. package/dist/index.d.ts.map +1 -1
  7. package/dist/index.js +0 -1
  8. package/dist/lib/parse-mvt.d.ts.map +1 -1
  9. package/dist/lib/pojo-parser/mvt-constants.d.ts +116 -0
  10. package/dist/lib/pojo-parser/mvt-constants.d.ts.map +1 -0
  11. package/dist/lib/pojo-parser/mvt-constants.js +126 -0
  12. package/dist/lib/pojo-parser/mvt-types.d.ts +17 -0
  13. package/dist/lib/pojo-parser/mvt-types.d.ts.map +1 -0
  14. package/dist/lib/pojo-parser/mvt-types.js +4 -0
  15. package/dist/lib/pojo-parser/parse-geometry-from-pbf.d.ts +77 -0
  16. package/dist/lib/pojo-parser/parse-geometry-from-pbf.d.ts.map +1 -0
  17. package/dist/lib/pojo-parser/parse-geometry-from-pbf.js +234 -0
  18. package/dist/lib/pojo-parser/parse-mvt-from-pbf.d.ts +25 -0
  19. package/dist/lib/pojo-parser/parse-mvt-from-pbf.d.ts.map +1 -0
  20. package/dist/lib/pojo-parser/parse-mvt-from-pbf.js +262 -0
  21. package/dist/lib/vector-tile/vector-tile-feature.d.ts +2 -1
  22. package/dist/lib/vector-tile/vector-tile-feature.d.ts.map +1 -1
  23. package/dist/lib/vector-tile/vector-tile-layer.d.ts +1 -1
  24. package/dist/lib/vector-tile/vector-tile-layer.d.ts.map +1 -1
  25. package/dist/mvt-format.d.ts +12 -0
  26. package/dist/mvt-format.d.ts.map +1 -0
  27. package/dist/mvt-format.js +20 -0
  28. package/dist/mvt-loader.d.ts +12 -12
  29. package/dist/mvt-loader.d.ts.map +1 -1
  30. package/dist/mvt-loader.js +3 -13
  31. package/dist/mvt-source.d.ts +22 -24
  32. package/dist/mvt-source.d.ts.map +1 -1
  33. package/dist/mvt-source.js +14 -23
  34. package/dist/mvt-worker.js +20 -15
  35. package/dist/table-tile-source.d.ts +38 -38
  36. package/dist/table-tile-source.d.ts.map +1 -1
  37. package/dist/table-tile-source.js +54 -53
  38. package/dist/tilejson-loader.js +1 -1
  39. package/package.json +7 -7
  40. package/src/index.ts +2 -2
  41. package/src/lib/parse-mvt.ts +2 -8
  42. package/src/lib/pojo-parser/mvt-constants.ts +135 -0
  43. package/src/lib/pojo-parser/mvt-types.ts +22 -0
  44. package/src/lib/pojo-parser/parse-geometry-from-pbf.ts +285 -0
  45. package/src/lib/pojo-parser/parse-mvt-from-pbf.ts +310 -0
  46. package/src/lib/vector-tile/vector-tile-feature.ts +2 -6
  47. package/src/lib/vector-tile/vector-tile-layer.ts +1 -1
  48. package/src/mvt-format.ts +23 -0
  49. package/src/mvt-loader.ts +2 -13
  50. package/src/mvt-source.ts +33 -38
  51. package/src/table-tile-source.ts +116 -96
@@ -1275,8 +1275,8 @@
1275
1275
  }
1276
1276
  };
1277
1277
 
1278
- // ../gis/src/lib/binary-features/flat-geojson-to-binary.ts
1279
- function flatGeojsonToBinary(features, geometryInfo, options) {
1278
+ // ../gis/src/lib/feature-collection-converters/convert-flat-geojson-to-binary-features.ts
1279
+ function convertFlatGeojsonToBinaryFeatureCollection(features, geometryInfo, options) {
1280
1280
  const propArrayTypes = extractNumericPropTypes(features);
1281
1281
  const numericPropKeys = Object.keys(propArrayTypes).filter((k) => propArrayTypes[k] !== Array);
1282
1282
  return fillArrays(
@@ -1563,14 +1563,14 @@
1563
1563
  return constructor === Float64Array || Math.fround(x) !== x ? Float64Array : Float32Array;
1564
1564
  }
1565
1565
 
1566
- // ../../node_modules/@probe.gl/log/node_modules/@probe.gl/env/dist/lib/globals.js
1566
+ // ../../node_modules/@probe.gl/env/dist/lib/globals.js
1567
1567
  var window_ = globalThis;
1568
1568
  var document_ = globalThis.document || {};
1569
1569
  var process_ = globalThis.process || {};
1570
1570
  var console_ = globalThis.console;
1571
1571
  var navigator_ = globalThis.navigator || {};
1572
1572
 
1573
- // ../../node_modules/@probe.gl/log/node_modules/@probe.gl/env/dist/lib/is-electron.js
1573
+ // ../../node_modules/@probe.gl/env/dist/lib/is-electron.js
1574
1574
  function isElectron(mockUserAgent) {
1575
1575
  if (typeof window !== "undefined" && window.process?.type === "renderer") {
1576
1576
  return true;
@@ -1583,7 +1583,7 @@
1583
1583
  return Boolean(userAgent && userAgent.indexOf("Electron") >= 0);
1584
1584
  }
1585
1585
 
1586
- // ../../node_modules/@probe.gl/log/node_modules/@probe.gl/env/dist/lib/is-browser.js
1586
+ // ../../node_modules/@probe.gl/env/dist/lib/is-browser.js
1587
1587
  function isBrowser() {
1588
1588
  const isNode = (
1589
1589
  // @ts-expect-error
@@ -1592,7 +1592,7 @@
1592
1592
  return !isNode || isElectron();
1593
1593
  }
1594
1594
 
1595
- // ../../node_modules/@probe.gl/log/node_modules/@probe.gl/env/dist/index.js
1595
+ // ../../node_modules/@probe.gl/env/dist/index.js
1596
1596
  var VERSION = true ? "4.0.7" : "untranspiled source";
1597
1597
 
1598
1598
  // ../../node_modules/@probe.gl/log/dist/utils/local-storage.js
@@ -1995,7 +1995,7 @@
1995
1995
  var dist_default = new Log({ id: "@probe.gl/log" });
1996
1996
 
1997
1997
  // ../loader-utils/src/lib/log-utils/log.ts
1998
- var VERSION2 = true ? "4.3.0" : "latest";
1998
+ var VERSION2 = true ? "4.4.0-alpha.0" : "latest";
1999
1999
  var version = VERSION2[0] >= "0" && VERSION2[0] <= "9" ? `v${VERSION2}` : "";
2000
2000
  function createLog() {
2001
2001
  const log2 = new Log({ id: "loaders.gl" });
@@ -2779,7 +2779,7 @@
2779
2779
  }
2780
2780
  function parseToBinary(arrayBuffer, options) {
2781
2781
  const [flatGeoJsonFeatures, geometryInfo] = parseToFlatGeoJson(arrayBuffer, options);
2782
- const binaryData = flatGeojsonToBinary(flatGeoJsonFeatures, geometryInfo);
2782
+ const binaryData = convertFlatGeojsonToBinaryFeatureCollection(flatGeoJsonFeatures, geometryInfo);
2783
2783
  binaryData.byteLength = arrayBuffer.byteLength;
2784
2784
  return binaryData;
2785
2785
  }
@@ -2866,15 +2866,11 @@
2866
2866
  return decodedFeature;
2867
2867
  }
2868
2868
 
2869
- // src/mvt-loader.ts
2870
- var VERSION3 = true ? "4.3.0" : "latest";
2871
- var MVTWorkerLoader = {
2872
- dataType: null,
2873
- batchType: null,
2869
+ // src/mvt-format.ts
2870
+ var MVTFormat = {
2874
2871
  name: "Mapbox Vector Tile",
2875
2872
  id: "mvt",
2876
2873
  module: "mvt",
2877
- version: VERSION3,
2878
2874
  // Note: ArcGIS uses '.pbf' extension and 'application/octet-stream'
2879
2875
  extensions: ["mvt", "pbf"],
2880
2876
  mimeTypes: [
@@ -2883,8 +2879,17 @@
2883
2879
  "application/x-protobuf"
2884
2880
  // 'application/octet-stream'
2885
2881
  ],
2882
+ category: "geometry"
2883
+ };
2884
+
2885
+ // src/mvt-loader.ts
2886
+ var VERSION3 = true ? "4.4.0-alpha.0" : "latest";
2887
+ var MVTWorkerLoader = {
2888
+ ...MVTFormat,
2889
+ dataType: null,
2890
+ batchType: null,
2891
+ version: VERSION3,
2886
2892
  worker: true,
2887
- category: "geometry",
2888
2893
  options: {
2889
2894
  mvt: {
2890
2895
  shape: "geojson",
@@ -1,37 +1,13 @@
1
- import { VectorTileSource, TileSourceMetadata } from '@loaders.gl/loader-utils';
2
- import type { VectorTileSourceProps, GetTileDataParameters, GetTileParameters, LoaderWithParser } from '@loaders.gl/loader-utils';
3
- import { Schema, GeoJSONTable, Feature, BinaryFeatureCollection } from '@loaders.gl/schema';
1
+ import type { DataSourceOptions, VectorTileSource, TileSourceMetadata, GetTileDataParameters, GetTileParameters } from '@loaders.gl/loader-utils';
2
+ import { DataSource } from '@loaders.gl/loader-utils';
3
+ import type { Schema, GeoJSONTable, Feature, BinaryFeatureCollection } from '@loaders.gl/schema';
4
4
  import { Stats } from '@probe.gl/stats';
5
5
  import type { ProtoFeature } from "./lib/vector-tiler/features/proto-feature.js";
6
6
  import type { ProtoTile } from "./lib/vector-tiler/proto-tile.js";
7
7
  /** Options to configure tiling */
8
- export declare const TableTileSource: {
9
- readonly name: "TableTiler";
10
- readonly id: "table-tiler";
11
- readonly version: "0.0.0";
12
- readonly extensions: ["mvt"];
13
- readonly mimeTypes: ["application/octet-stream"];
14
- readonly options: {
15
- readonly table: {
16
- readonly coordinates: "local";
17
- readonly promoteId: never;
18
- readonly maxZoom: 14;
19
- readonly indexMaxZoom: 5;
20
- readonly maxPointsPerTile: 10000;
21
- readonly tolerance: 3;
22
- readonly extent: 4096;
23
- readonly buffer: 64;
24
- readonly generateId: undefined;
25
- };
26
- };
27
- readonly type: "table";
28
- readonly testURL: (url: string) => boolean;
29
- readonly createDataSource: (url: string | Blob | GeoJSONTable | Promise<GeoJSONTable>, options: DynamicVectorTileSourceProps) => DynamicVectorTileSource;
30
- };
31
- /** Options to configure tiling */
32
- export type DynamicVectorTileSourceProps = VectorTileSourceProps & {
33
- table: {
34
- coordinates: 'local' | 'wgs84' | 'EPSG:4326';
8
+ export type TableTileSourceOptions = DataSourceOptions & {
9
+ table?: {
10
+ coordinates?: 'local' | 'wgs84' | 'EPSG:4326';
35
11
  /** max zoom to preserve detail on */
36
12
  maxZoom?: number;
37
13
  /** max zoom in the tile index */
@@ -52,10 +28,35 @@ export type DynamicVectorTileSourceProps = VectorTileSourceProps & {
52
28
  debug?: number;
53
29
  /** whether to calculate line metrics */
54
30
  lineMetrics?: boolean;
55
- /** table loders */
56
- loaders?: LoaderWithParser[];
57
31
  };
58
32
  };
33
+ /** Options to configure tiling */
34
+ export declare const TableTileSource: {
35
+ readonly name: "TableTiler";
36
+ readonly id: "table-tiler";
37
+ readonly module: "mvt";
38
+ readonly version: "0.0.0";
39
+ readonly extensions: ["mvt"];
40
+ readonly mimeTypes: ["application/octet-stream"];
41
+ readonly type: "table";
42
+ readonly fromUrl: false;
43
+ readonly fromBlob: false;
44
+ readonly defaultOptions: {
45
+ readonly table: {
46
+ readonly coordinates: "local";
47
+ readonly promoteId: never;
48
+ readonly maxZoom: 14;
49
+ readonly indexMaxZoom: 5;
50
+ readonly maxPointsPerTile: 10000;
51
+ readonly tolerance: 3;
52
+ readonly extent: 4096;
53
+ readonly buffer: 64;
54
+ readonly generateId: undefined;
55
+ };
56
+ };
57
+ readonly testURL: (url: string) => boolean;
58
+ readonly createDataSource: (url: string | Blob | GeoJSONTable | Promise<GeoJSONTable>, options: TableTileSourceOptions) => TableVectorTileSource;
59
+ };
59
60
  /**
60
61
  * Dynamically vector tiles a table (the table needs a geometry column)
61
62
  * - Tiles are generated when requested.
@@ -71,16 +72,15 @@ export type DynamicVectorTileSourceProps = VectorTileSourceProps & {
71
72
  * @todo - generate binary output tables
72
73
  * @todo - how does TileSourceLayer specify coordinates / decided which layer to render with
73
74
  */
74
- export declare class DynamicVectorTileSource implements VectorTileSource<DynamicVectorTileSourceProps, TileSourceMetadata> {
75
+ export declare class TableVectorTileSource extends DataSource<GeoJSONTable | Promise<GeoJSONTable>, TableTileSourceOptions> implements VectorTileSource {
75
76
  /** Global stats for all DynamicVectorTileSources */
76
77
  static stats: Stats;
77
- /** Stats for this DynamicVectorTileSource */
78
+ /** Stats for this TableVectorTileSource */
78
79
  stats: Stats;
79
80
  /** MIME type of the tiles emitted by this tile source */
80
81
  readonly mimeType = "application/vnd.mapbox-vector-tile";
81
82
  readonly localCoordinates = true;
82
- /** The props that this tile source was created with */
83
- props: Required<DynamicVectorTileSourceProps['table']>;
83
+ readonly tableOptions: Required<Required<TableTileSourceOptions>['table']>;
84
84
  schema: Schema | null;
85
85
  /** Map of generated tiles, indexed by stringified tile coordinates */
86
86
  tiles: Record<string, ProtoTile>;
@@ -94,7 +94,7 @@ export declare class DynamicVectorTileSource implements VectorTileSource<Dynamic
94
94
  ready: Promise<void>;
95
95
  /** Metadata for the tile source (generated TileJSON/tilestats */
96
96
  metadata: Promise<unknown>;
97
- constructor(table: GeoJSONTable | Promise<GeoJSONTable>, props?: DynamicVectorTileSourceProps);
97
+ constructor(table: GeoJSONTable | Promise<GeoJSONTable>, options: TableTileSourceOptions);
98
98
  initializeTilesAsync(tablePromise: GeoJSONTable | Promise<GeoJSONTable>): Promise<void>;
99
99
  getMetadata(): Promise<TileSourceMetadata & {
100
100
  schema: Schema | null;
@@ -141,7 +141,7 @@ export declare class DynamicVectorTileSource implements VectorTileSource<Dynamic
141
141
  * @param cz, cx, and cy are the coordinates of the target tile
142
142
  *
143
143
  * If no target tile is specified, splitting stops when we reach the maximum
144
- * zoom or the number of points is low as specified in the props.
144
+ * zoom or the number of points is low as specified in the options.
145
145
  */
146
146
  splitTile(features: ProtoFeature[], z: number, x: number, y: number, cz?: number, cx?: number, cy?: number): void;
147
147
  }
@@ -1 +1 @@
1
- {"version":3,"file":"table-tile-source.d.ts","sourceRoot":"","sources":["../src/table-tile-source.ts"],"names":[],"mappings":"AAKA,OAAO,EAAS,gBAAgB,EAAE,kBAAkB,EAAM,MAAM,0BAA0B,CAAC;AAC3F,OAAO,KAAK,EACV,qBAAqB,EACrB,qBAAqB,EACrB,iBAAiB,EACjB,gBAAgB,EACjB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EACL,MAAM,EACN,YAAY,EACZ,OAAO,EACP,uBAAuB,EAExB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAC,KAAK,EAAO,MAAM,iBAAiB,CAAC;AAE5C,OAAO,KAAK,EAAC,YAAY,EAAC,qDAAkD;AAC5E,OAAO,KAAK,EAAC,SAAS,EAAC,yCAAsC;AAQ7D,kCAAkC;AAClC,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;4BAoBX,MAAM,KAAG,OAAO;qCAExB,MAAM,GAAG,IAAI,GAAG,YAAY,GAAG,OAAO,CAAC,YAAY,CAAC,WAChD,4BAA4B,KACpC,uBAAuB;CAOsD,CAAC;AAanF,kCA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EAAE,MAAM,EACX,EAAE,CAAC,EAAE,MAAM,EACX,EAAE,CAAC,EAAE,MAAM,GACV,IAAI;CAuIR"}
@@ -2,8 +2,8 @@
2
2
  // SPDX-License-Identifier: MIT AND ISC
3
3
  // Copyright (c) vis.gl contributors
4
4
  // Based on https://github.com/mapbox/geojson-vt under compatible ISC license
5
- import { log } from '@loaders.gl/loader-utils';
6
- import { deduceTableSchema } from '@loaders.gl/schema';
5
+ import { DataSource, getRequiredOptions, log } from '@loaders.gl/loader-utils';
6
+ import { deduceTableSchema } from '@loaders.gl/schema-utils';
7
7
  import { Stats, Stat } from '@probe.gl/stats';
8
8
  import { createProtoTile } from "./lib/vector-tiler/proto-tile.js";
9
9
  import { transformTile } from "./lib/vector-tiler/transform-tile.js"; // coordinate transformation
@@ -15,10 +15,14 @@ import { wrapFeatures } from "./lib/vector-tiler/features/wrap-features.js"; //
15
15
  export const TableTileSource = {
16
16
  name: 'TableTiler',
17
17
  id: 'table-tiler',
18
+ module: 'mvt',
18
19
  version: '0.0.0',
19
20
  extensions: ['mvt'],
20
21
  mimeTypes: ['application/octet-stream'],
21
- options: {
22
+ type: 'table',
23
+ fromUrl: false,
24
+ fromBlob: false,
25
+ defaultOptions: {
22
26
  table: {
23
27
  coordinates: 'local',
24
28
  promoteId: undefined,
@@ -31,25 +35,14 @@ export const TableTileSource = {
31
35
  generateId: undefined
32
36
  }
33
37
  },
34
- type: 'table',
35
38
  testURL: (url) => url.endsWith('.geojson'),
36
39
  createDataSource(url, options) {
37
40
  const needsLoading = typeof url === 'string' || url instanceof Blob;
38
- const loader = options?.table?.loaders?.[0];
41
+ const loader = options?.core?.loaders?.[0];
39
42
  const tablePromise = needsLoading ? loadTable(url, loader) : url;
40
- return new DynamicVectorTileSource(tablePromise, options);
43
+ return new TableVectorTileSource(tablePromise, options);
41
44
  }
42
- // @ts-expect-error
43
45
  };
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
- }
53
46
  /**
54
47
  * Dynamically vector tiles a table (the table needs a geometry column)
55
48
  * - Tiles are generated when requested.
@@ -65,13 +58,13 @@ async function loadTable(url, loader) {
65
58
  * @todo - generate binary output tables
66
59
  * @todo - how does TileSourceLayer specify coordinates / decided which layer to render with
67
60
  */
68
- export class DynamicVectorTileSource {
61
+ export class TableVectorTileSource extends DataSource {
69
62
  /** Global stats for all DynamicVectorTileSources */
70
63
  static stats = new Stats({
71
64
  id: 'table-tile-source-all',
72
65
  stats: [new Stat('count', 'tiles'), new Stat('count', 'features')]
73
66
  });
74
- /** Stats for this DynamicVectorTileSource */
67
+ /** Stats for this TableVectorTileSource */
75
68
  stats = new Stats({
76
69
  id: 'table-tile-source',
77
70
  stats: [new Stat('tiles', 'count'), new Stat('features', 'count')]
@@ -79,9 +72,7 @@ export class DynamicVectorTileSource {
79
72
  /** MIME type of the tiles emitted by this tile source */
80
73
  mimeType = 'application/vnd.mapbox-vector-tile';
81
74
  localCoordinates = true;
82
- /** The props that this tile source was created with */
83
- // @ts-expect-error
84
- props;
75
+ tableOptions;
85
76
  /* Schema of the data */
86
77
  schema = null;
87
78
  /** Map of generated tiles, indexed by stringified tile coordinates */
@@ -92,9 +83,9 @@ export class DynamicVectorTileSource {
92
83
  ready;
93
84
  /** Metadata for the tile source (generated TileJSON/tilestats */
94
85
  metadata;
95
- constructor(table, props) {
96
- // @ts-expect-error
97
- this.props = { ...TableTileSource.options.table, ...props?.table };
86
+ constructor(table, options) {
87
+ super(table, options, TableTileSource.defaultOptions);
88
+ this.tableOptions = getRequiredOptions(this.options).table;
98
89
  this.getTileData = this.getTileData.bind(this);
99
90
  this.ready = this.initializeTilesAsync(table);
100
91
  this.metadata = this.getMetadata();
@@ -106,7 +97,7 @@ export class DynamicVectorTileSource {
106
97
  }
107
98
  async getMetadata() {
108
99
  await this.ready;
109
- return { schema: this.schema, minZoom: 0, maxZoom: this.props.maxZoom };
100
+ return { schema: this.schema, minZoom: 0, maxZoom: this.tableOptions.maxZoom };
110
101
  }
111
102
  async getSchema() {
112
103
  await this.ready;
@@ -143,9 +134,9 @@ export class DynamicVectorTileSource {
143
134
  return null;
144
135
  }
145
136
  return convertTileToGeoJSON(protoTile, {
146
- coordinates: this.props.coordinates,
137
+ coordinates: this.tableOptions.coordinates,
147
138
  tileIndex,
148
- extent: this.props.extent
139
+ extent: this.tableOptions.extent
149
140
  });
150
141
  }
151
142
  /**
@@ -153,30 +144,30 @@ export class DynamicVectorTileSource {
153
144
  * @note the tiles stores all the features together with additional data
154
145
  */
155
146
  createRootTiles(table) {
156
- if (this.props.maxZoom < 0 || this.props.maxZoom > 24) {
147
+ if (this.tableOptions.maxZoom < 0 || this.tableOptions.maxZoom > 24) {
157
148
  throw new Error('maxZoom should be in the 0-24 range');
158
149
  }
159
- if (this.props.promoteId && this.props.generateId) {
150
+ if (this.tableOptions.promoteId && this.tableOptions.generateId) {
160
151
  throw new Error('promoteId and generateId cannot be used together.');
161
152
  }
162
- log.log(1, 'DynamicVectorTileSource creating root tiles', this.props)();
153
+ log.log(1, 'TableVectorTileSource creating root tiles', this.tableOptions)();
163
154
  // projects and adds simplification info
164
155
  log.time(1, 'preprocess table')();
165
- let features = convertFeaturesToProtoFeature(table, this.props);
156
+ let features = convertFeaturesToProtoFeature(table, this.tableOptions);
166
157
  log.timeEnd(1, 'preprocess table')();
167
158
  // wraps features (ie extreme west and extreme east)
168
159
  log.time(1, 'generate tiles')();
169
- features = wrapFeatures(features, this.props);
160
+ features = wrapFeatures(features, this.tableOptions);
170
161
  // start slicing from the top tile down
171
162
  if (features.length === 0) {
172
- log.log(1, 'DynamicVectorTileSource: no features generated')();
163
+ log.log(1, 'TableVectorTileSource: no features generated')();
173
164
  return;
174
165
  }
175
166
  this.splitTile(features, 0, 0, 0);
176
167
  const rootTile = this.tiles[0];
177
168
  log.log(1, `root tile features: ${rootTile.numFeatures}, points: ${rootTile.numPoints}`)();
178
169
  log.timeEnd(1, 'generate tiles')();
179
- log.log(1, `DynamicVectorTileSource: tiles generated: ${this.stats.get('total').count}`, this.stats)();
170
+ log.log(1, `TableVectorTileSource: tiles generated: ${this.stats.get('total').count}`, this.stats)();
180
171
  }
181
172
  /**
182
173
  * Return geojsonvt-style "half formed" vector tile
@@ -189,7 +180,7 @@ export class DynamicVectorTileSource {
189
180
  // z = +z;
190
181
  // x = +x;
191
182
  // y = +y;
192
- const { extent } = this.props;
183
+ const { extent } = this.tableOptions;
193
184
  if (z < 0 || z > 24) {
194
185
  return null;
195
186
  }
@@ -226,7 +217,7 @@ export class DynamicVectorTileSource {
226
217
  * @param cz, cx, and cy are the coordinates of the target tile
227
218
  *
228
219
  * If no target tile is specified, splitting stops when we reach the maximum
229
- * zoom or the number of points is low as specified in the props.
220
+ * zoom or the number of points is low as specified in the options.
230
221
  */
231
222
  // eslint-disable-next-line max-params, max-statements, complexity
232
223
  splitTile(features, z, x, y, cz, cx, cy) {
@@ -242,16 +233,16 @@ export class DynamicVectorTileSource {
242
233
  let tile = this.tiles[id];
243
234
  if (!tile) {
244
235
  log.time(2, 'tile creation')();
245
- tile = this.tiles[id] = createProtoTile(features, z, x, y, this.props);
236
+ tile = this.tiles[id] = createProtoTile(features, z, x, y, this.tableOptions);
246
237
  this.tileCoords.push({ z, x, y });
247
238
  const key = `z${z}`;
248
239
  let stat = this.stats.get(key, 'count');
249
240
  stat.incrementCount();
250
241
  stat = this.stats.get('total');
251
242
  stat.incrementCount();
252
- stat = DynamicVectorTileSource.stats.get(key, 'count');
243
+ stat = TableVectorTileSource.stats.get(key, 'count');
253
244
  stat.incrementCount();
254
- stat = DynamicVectorTileSource.stats.get('total');
245
+ stat = TableVectorTileSource.stats.get('total');
255
246
  stat.incrementCount();
256
247
  log.log(2, 'tile z%d-%d-%d (features: %d, points: %d, simplified: %d)', z, x, y, tile.numFeatures, tile.numPoints, tile.numSimplified)();
257
248
  log.timeEnd(2, 'tile creation')();
@@ -262,12 +253,13 @@ export class DynamicVectorTileSource {
262
253
  // if it's the first-pass tiling
263
254
  if (cz === undefined) {
264
255
  // stop tiling if we reached max zoom, or if the tile is too simple
265
- if (z === this.props.indexMaxZoom || tile.numPoints <= this.props.maxPointsPerTile) {
256
+ if (z === this.tableOptions.indexMaxZoom ||
257
+ tile.numPoints <= this.tableOptions.maxPointsPerTile) {
266
258
  continue;
267
259
  }
268
260
  // if a drilldown to a specific tile
269
261
  }
270
- else if (z === this.props.maxZoom || z === cz) {
262
+ else if (z === this.tableOptions.maxZoom || z === cz) {
271
263
  // stop tiling if we reached base zoom or our target tile zoom
272
264
  continue;
273
265
  }
@@ -285,7 +277,7 @@ export class DynamicVectorTileSource {
285
277
  continue;
286
278
  log.time(2, 'clipping tile')();
287
279
  // values we'll use for clipping
288
- const k1 = (0.5 * this.props.buffer) / this.props.extent;
280
+ const k1 = (0.5 * this.tableOptions.buffer) / this.tableOptions.extent;
289
281
  const k2 = 0.5 - k1;
290
282
  const k3 = 0.5 + k1;
291
283
  const k4 = 1 + k1;
@@ -293,18 +285,18 @@ export class DynamicVectorTileSource {
293
285
  let bl = null;
294
286
  let tr = null;
295
287
  let br = null;
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);
288
+ let left = clipFeatures(features, z2, x - k1, x + k3, 0, tile.minX, tile.maxX, this.tableOptions);
289
+ let right = clipFeatures(features, z2, x + k2, x + k4, 0, tile.minX, tile.maxX, this.tableOptions);
298
290
  // @ts-expect-error - unclear why this is needed?
299
291
  features = null;
300
292
  if (left) {
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);
293
+ tl = clipFeatures(left, z2, y - k1, y + k3, 1, tile.minY, tile.maxY, this.tableOptions);
294
+ bl = clipFeatures(left, z2, y + k2, y + k4, 1, tile.minY, tile.maxY, this.tableOptions);
303
295
  left = null;
304
296
  }
305
297
  if (right) {
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);
298
+ tr = clipFeatures(right, z2, y - k1, y + k3, 1, tile.minY, tile.maxY, this.tableOptions);
299
+ br = clipFeatures(right, z2, y + k2, y + k4, 1, tile.minY, tile.maxY, this.tableOptions);
308
300
  right = null;
309
301
  }
310
302
  log.timeEnd(2, 'clipping tile')();
@@ -318,12 +310,21 @@ export class DynamicVectorTileSource {
318
310
  function toID(z, x, y) {
319
311
  return ((1 << z) * y + x) * 32 + z;
320
312
  }
313
+ async function loadTable(url, loader) {
314
+ if (typeof url === 'string') {
315
+ const response = await fetch(url);
316
+ const data = await response.arrayBuffer();
317
+ return (await loader.parse(data));
318
+ }
319
+ const data = await url.arrayBuffer();
320
+ return (await loader.parse(data)); // options.loaders, options.loadOptions)
321
+ }
321
322
  /*
322
323
 
323
324
  // eslint-disable-next-line max-statements, complexity
324
325
  function convertToGeoJSONTable(
325
326
  vtTile: ProtoTile,
326
- props: {
327
+ options: {
327
328
  coordinates: 'local' | 'wgs84' | 'EPSG:4326';
328
329
  tileIndex: {x: number; y: number; z: number};
329
330
  extent: number;
@@ -378,18 +379,18 @@ function convertToGeoJSONTable(
378
379
  continue;
379
380
  }
380
381
 
381
- switch (props.coordinates) {
382
+ switch (options.coordinates) {
382
383
  case 'EPSG:4326':
383
384
  case 'wgs84':
384
- projectToLngLat(coordinates, props.tileIndex, props.extent);
385
+ projectToLngLat(coordinates, options.tileIndex, options.extent);
385
386
  break;
386
387
 
387
388
  case 'local':
388
- convertToLocalCoordinates(coordinates, props.extent);
389
+ convertToLocalCoordinates(coordinates, options.extent);
389
390
  break;
390
391
 
391
392
  default:
392
- throw new Error(`Unsupported CRS ${props.coordinates}`);
393
+ throw new Error(`Unsupported CRS ${options.coordinates}`);
393
394
  }
394
395
 
395
396
  const feature: Feature = {
@@ -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" !== 'undefined' ? "4.3.0" : 'latest';
7
+ const VERSION = typeof "4.4.0-alpha.0" !== 'undefined' ? "4.4.0-alpha.0" : '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.1",
4
+ "version": "4.4.0-alpha.1",
5
5
  "license": "MIT",
6
6
  "type": "module",
7
7
  "publishConfig": {
@@ -44,10 +44,10 @@
44
44
  "build-worker": "esbuild src/workers/mvt-worker.ts --bundle --outfile=dist/mvt-worker.js --define:__VERSION__=\\\"$npm_package_version\\\""
45
45
  },
46
46
  "dependencies": {
47
- "@loaders.gl/gis": "4.3.1",
48
- "@loaders.gl/images": "4.3.1",
49
- "@loaders.gl/loader-utils": "4.3.1",
50
- "@loaders.gl/schema": "4.3.1",
47
+ "@loaders.gl/gis": "4.4.0-alpha.1",
48
+ "@loaders.gl/images": "4.4.0-alpha.1",
49
+ "@loaders.gl/loader-utils": "4.4.0-alpha.1",
50
+ "@loaders.gl/schema": "4.4.0-alpha.1",
51
51
  "@math.gl/polygon": "^4.1.0",
52
52
  "@probe.gl/stats": "^4.0.0",
53
53
  "pbf": "^3.2.1"
@@ -56,7 +56,7 @@
56
56
  "@types/pbf": "^3.0.2"
57
57
  },
58
58
  "peerDependencies": {
59
- "@loaders.gl/core": "^4.3.0"
59
+ "@loaders.gl/core": "4.4.0-alpha.0"
60
60
  },
61
- "gitHead": "70a883ab6bc84647c49963215dd6ff62d4d61de3"
61
+ "gitHead": "f1732de45907bd500bf4eedb4803beca8bf4bfb0"
62
62
  }
package/src/index.ts CHANGED
@@ -16,9 +16,9 @@ export type {MVTLoaderOptions} from './mvt-loader';
16
16
  // MVTSource
17
17
 
18
18
  export {MVTSource} from './mvt-source';
19
- export type {MVTTileSource, MVTTileSourceProps} from './mvt-source';
19
+ export type {MVTTileSource, MVTSourceOptions} from './mvt-source';
20
20
 
21
21
  // TableTileSource (dynamically tiles a table)
22
22
 
23
+ export type {TableTileSourceOptions, TableVectorTileSource} from './table-tile-source';
23
24
  export {TableTileSource} from './table-tile-source';
24
- export type {DynamicVectorTileSource, DynamicVectorTileSourceProps} from './table-tile-source';
@@ -2,14 +2,8 @@
2
2
  // SPDX-License-Identifier: MIT
3
3
  // Copyright vis.gl contributors
4
4
 
5
- import type {
6
- FlatFeature,
7
- Feature,
8
- GeojsonGeometryInfo,
9
- GeoJSONTable,
10
- BinaryFeatureCollection
11
- } from '@loaders.gl/schema';
12
- import {flatGeojsonToBinary} from '@loaders.gl/gis';
5
+ import type {FlatFeature, Feature, GeoJSONTable, BinaryFeatureCollection} from '@loaders.gl/schema';
6
+ import {flatGeojsonToBinary, GeojsonGeometryInfo} from '@loaders.gl/gis';
13
7
  import {log} from '@loaders.gl/loader-utils';
14
8
  import Protobuf from 'pbf';
15
9