@loaders.gl/mvt 4.2.0-alpha.4 → 4.2.0-alpha.6

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 (93) hide show
  1. package/dist/dist.dev.js +312 -244
  2. package/dist/dist.min.js +14 -0
  3. package/dist/helpers/binary-util-functions.d.ts +1 -1
  4. package/dist/helpers/binary-util-functions.d.ts.map +1 -1
  5. package/dist/helpers/binary-util-functions.js +99 -61
  6. package/dist/helpers/mapbox-util-functions.d.ts +2 -2
  7. package/dist/helpers/mapbox-util-functions.d.ts.map +1 -1
  8. package/dist/helpers/mapbox-util-functions.js +67 -33
  9. package/dist/index.cjs +86 -68
  10. package/dist/index.cjs.map +7 -0
  11. package/dist/index.d.ts +8 -8
  12. package/dist/index.d.ts.map +1 -1
  13. package/dist/index.js +3 -1
  14. package/dist/lib/binary-vector-tile/vector-tile-feature.d.ts +1 -1
  15. package/dist/lib/binary-vector-tile/vector-tile-feature.d.ts.map +1 -1
  16. package/dist/lib/binary-vector-tile/vector-tile-feature.js +144 -118
  17. package/dist/lib/binary-vector-tile/vector-tile-layer.d.ts +1 -1
  18. package/dist/lib/binary-vector-tile/vector-tile-layer.d.ts.map +1 -1
  19. package/dist/lib/binary-vector-tile/vector-tile-layer.js +85 -38
  20. package/dist/lib/binary-vector-tile/vector-tile.d.ts +1 -1
  21. package/dist/lib/binary-vector-tile/vector-tile.d.ts.map +1 -1
  22. package/dist/lib/binary-vector-tile/vector-tile.js +18 -12
  23. package/dist/lib/geojson-tiler/clip.d.ts +1 -1
  24. package/dist/lib/geojson-tiler/clip.d.ts.map +1 -1
  25. package/dist/lib/geojson-tiler/clip.js +180 -142
  26. package/dist/lib/geojson-tiler/convert.d.ts +1 -1
  27. package/dist/lib/geojson-tiler/convert.d.ts.map +1 -1
  28. package/dist/lib/geojson-tiler/convert.js +116 -100
  29. package/dist/lib/geojson-tiler/feature.d.ts +1 -1
  30. package/dist/lib/geojson-tiler/feature.d.ts.map +1 -1
  31. package/dist/lib/geojson-tiler/feature.js +38 -29
  32. package/dist/lib/geojson-tiler/geojson-tiler.d.ts +1 -1
  33. package/dist/lib/geojson-tiler/geojson-tiler.d.ts.map +1 -1
  34. package/dist/lib/geojson-tiler/geojson-tiler.js +198 -159
  35. package/dist/lib/geojson-tiler/simplify.js +60 -40
  36. package/dist/lib/geojson-tiler/tile.js +108 -88
  37. package/dist/lib/geojson-tiler/transform.d.ts +1 -1
  38. package/dist/lib/geojson-tiler/transform.d.ts.map +1 -1
  39. package/dist/lib/geojson-tiler/transform.js +35 -26
  40. package/dist/lib/geojson-tiler/wrap.d.ts +1 -1
  41. package/dist/lib/geojson-tiler/wrap.d.ts.map +1 -1
  42. package/dist/lib/geojson-tiler/wrap.js +74 -53
  43. package/dist/lib/mapbox-vector-tile/vector-tile-feature.d.ts +1 -1
  44. package/dist/lib/mapbox-vector-tile/vector-tile-feature.d.ts.map +1 -1
  45. package/dist/lib/mapbox-vector-tile/vector-tile-feature.js +164 -151
  46. package/dist/lib/mapbox-vector-tile/vector-tile-layer.d.ts +1 -1
  47. package/dist/lib/mapbox-vector-tile/vector-tile-layer.d.ts.map +1 -1
  48. package/dist/lib/mapbox-vector-tile/vector-tile-layer.js +83 -38
  49. package/dist/lib/mapbox-vector-tile/vector-tile.d.ts +1 -1
  50. package/dist/lib/mapbox-vector-tile/vector-tile.d.ts.map +1 -1
  51. package/dist/lib/mapbox-vector-tile/vector-tile.js +18 -12
  52. package/dist/lib/parse-mvt.d.ts +1 -1
  53. package/dist/lib/parse-mvt.d.ts.map +1 -1
  54. package/dist/lib/parse-mvt.js +142 -115
  55. package/dist/lib/parse-tilejson.js +234 -176
  56. package/dist/lib/types.js +0 -1
  57. package/dist/mvt-loader.d.ts +1 -1
  58. package/dist/mvt-loader.d.ts.map +1 -1
  59. package/dist/mvt-loader.js +42 -22
  60. package/dist/mvt-source.js +153 -139
  61. package/dist/mvt-worker.js +39 -2
  62. package/dist/tilejson-loader.d.ts +1 -1
  63. package/dist/tilejson-loader.d.ts.map +1 -1
  64. package/dist/tilejson-loader.js +32 -31
  65. package/dist/workers/mvt-worker.js +0 -1
  66. package/package.json +12 -8
  67. package/dist/helpers/binary-util-functions.js.map +0 -1
  68. package/dist/helpers/mapbox-util-functions.js.map +0 -1
  69. package/dist/index.js.map +0 -1
  70. package/dist/lib/binary-vector-tile/LICENSE.txt +0 -31
  71. package/dist/lib/binary-vector-tile/vector-tile-feature.js.map +0 -1
  72. package/dist/lib/binary-vector-tile/vector-tile-layer.js.map +0 -1
  73. package/dist/lib/binary-vector-tile/vector-tile.js.map +0 -1
  74. package/dist/lib/geojson-tiler/LICENSE +0 -19
  75. package/dist/lib/geojson-tiler/clip.js.map +0 -1
  76. package/dist/lib/geojson-tiler/convert.js.map +0 -1
  77. package/dist/lib/geojson-tiler/feature.js.map +0 -1
  78. package/dist/lib/geojson-tiler/geojson-tiler.js.map +0 -1
  79. package/dist/lib/geojson-tiler/simplify.js.map +0 -1
  80. package/dist/lib/geojson-tiler/tile.js.map +0 -1
  81. package/dist/lib/geojson-tiler/transform.js.map +0 -1
  82. package/dist/lib/geojson-tiler/wrap.js.map +0 -1
  83. package/dist/lib/mapbox-vector-tile/LICENSE.txt +0 -31
  84. package/dist/lib/mapbox-vector-tile/vector-tile-feature.js.map +0 -1
  85. package/dist/lib/mapbox-vector-tile/vector-tile-layer.js.map +0 -1
  86. package/dist/lib/mapbox-vector-tile/vector-tile.js.map +0 -1
  87. package/dist/lib/parse-mvt.js.map +0 -1
  88. package/dist/lib/parse-tilejson.js.map +0 -1
  89. package/dist/lib/types.js.map +0 -1
  90. package/dist/mvt-loader.js.map +0 -1
  91. package/dist/mvt-source.js.map +0 -1
  92. package/dist/tilejson-loader.js.map +0 -1
  93. package/dist/workers/mvt-worker.js.map +0 -1
package/dist/index.cjs CHANGED
@@ -27,22 +27,22 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
27
27
  ));
28
28
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
29
 
30
- // src/index.ts
31
- var src_exports = {};
32
- __export(src_exports, {
30
+ // dist/index.js
31
+ var dist_exports = {};
32
+ __export(dist_exports, {
33
33
  GeoJSONTiler: () => GeoJSONTiler,
34
34
  MVTLoader: () => MVTLoader,
35
35
  MVTSource: () => MVTSource,
36
36
  MVTWorkerLoader: () => MVTWorkerLoader,
37
37
  TileJSONLoader: () => TileJSONLoader
38
38
  });
39
- module.exports = __toCommonJS(src_exports);
39
+ module.exports = __toCommonJS(dist_exports);
40
40
 
41
- // src/lib/parse-mvt.ts
41
+ // dist/lib/parse-mvt.js
42
42
  var import_gis = require("@loaders.gl/gis");
43
43
  var import_pbf = __toESM(require("pbf"), 1);
44
44
 
45
- // src/helpers/mapbox-util-functions.ts
45
+ // dist/helpers/mapbox-util-functions.js
46
46
  function classifyRings(rings) {
47
47
  const len = rings.length;
48
48
  if (len <= 1)
@@ -97,8 +97,16 @@ function readTag(pbf, feature) {
97
97
  }
98
98
  }
99
99
 
100
- // src/lib/mapbox-vector-tile/vector-tile-feature.ts
100
+ // dist/lib/mapbox-vector-tile/vector-tile-feature.js
101
101
  var VectorTileFeature = class {
102
+ properties;
103
+ extent;
104
+ type;
105
+ id;
106
+ _pbf;
107
+ _geometry;
108
+ _keys;
109
+ _values;
102
110
  static get types() {
103
111
  return ["Unknown", "Point", "LineString", "Polygon"];
104
112
  }
@@ -256,8 +264,16 @@ var VectorTileFeature = class {
256
264
  }
257
265
  };
258
266
 
259
- // src/lib/mapbox-vector-tile/vector-tile-layer.ts
267
+ // dist/lib/mapbox-vector-tile/vector-tile-layer.js
260
268
  var VectorTileLayer = class {
269
+ version;
270
+ name;
271
+ extent;
272
+ length;
273
+ _pbf;
274
+ _keys;
275
+ _values;
276
+ _features;
261
277
  constructor(pbf, end) {
262
278
  this.version = 1;
263
279
  this.name = "";
@@ -310,8 +326,9 @@ function readValueMessage(pbf) {
310
326
  return value;
311
327
  }
312
328
 
313
- // src/lib/mapbox-vector-tile/vector-tile.ts
329
+ // dist/lib/mapbox-vector-tile/vector-tile.js
314
330
  var VectorTile = class {
331
+ layers;
315
332
  constructor(pbf, end) {
316
333
  this.layers = pbf.readFields(readTile, {}, end);
317
334
  }
@@ -327,7 +344,7 @@ function readTile(tag, layers, pbf) {
327
344
  }
328
345
  }
329
346
 
330
- // src/helpers/binary-util-functions.ts
347
+ // dist/helpers/binary-util-functions.js
331
348
  var import_polygon = require("@math.gl/polygon");
332
349
  function classifyRings2(geom) {
333
350
  const len = geom.indices.length;
@@ -406,7 +423,7 @@ function readTag2(pbf, feature) {
406
423
  }
407
424
  }
408
425
 
409
- // src/lib/binary-vector-tile/vector-tile-feature.ts
426
+ // dist/lib/binary-vector-tile/vector-tile-feature.js
410
427
  var endPos;
411
428
  var cmd;
412
429
  var cmdLen;
@@ -415,6 +432,15 @@ var x;
415
432
  var y;
416
433
  var i;
417
434
  var VectorTileFeature2 = class {
435
+ properties;
436
+ extent;
437
+ type;
438
+ id;
439
+ _pbf;
440
+ _geometry;
441
+ _keys;
442
+ _values;
443
+ _geometryInfo;
418
444
  // eslint-disable-next-line max-params
419
445
  constructor(pbf, end, extent, keys, values, geometryInfo) {
420
446
  this.properties = {};
@@ -519,8 +545,16 @@ var VectorTileFeature2 = class {
519
545
  }
520
546
  };
521
547
 
522
- // src/lib/binary-vector-tile/vector-tile-layer.ts
548
+ // dist/lib/binary-vector-tile/vector-tile-layer.js
523
549
  var VectorTileLayer2 = class {
550
+ version;
551
+ name;
552
+ extent;
553
+ length;
554
+ _pbf;
555
+ _keys;
556
+ _values;
557
+ _features;
524
558
  constructor(pbf, end) {
525
559
  this.version = 1;
526
560
  this.name = "";
@@ -546,14 +580,7 @@ var VectorTileLayer2 = class {
546
580
  }
547
581
  this._pbf.pos = this._features[i2];
548
582
  const end = this._pbf.readVarint() + this._pbf.pos;
549
- return new VectorTileFeature2(
550
- this._pbf,
551
- end,
552
- this.extent,
553
- this._keys,
554
- this._values,
555
- geometryInfo
556
- );
583
+ return new VectorTileFeature2(this._pbf, end, this.extent, this._keys, this._values, geometryInfo);
557
584
  }
558
585
  };
559
586
  function readLayer2(tag, layer, pbf) {
@@ -582,8 +609,9 @@ function readValueMessage2(pbf) {
582
609
  return value;
583
610
  }
584
611
 
585
- // src/lib/binary-vector-tile/vector-tile.ts
612
+ // dist/lib/binary-vector-tile/vector-tile.js
586
613
  var VectorTile2 = class {
614
+ layers;
587
615
  constructor(pbf, end) {
588
616
  this.layers = pbf.readFields(readTile2, {}, end);
589
617
  }
@@ -599,7 +627,7 @@ function readTile2(tag, layers, pbf) {
599
627
  }
600
628
  }
601
629
 
602
- // src/lib/parse-mvt.ts
630
+ // dist/lib/parse-mvt.js
603
631
  function parseMVT(arrayBuffer, options) {
604
632
  var _a, _b;
605
633
  const mvtOptions = normalizeOptions(options);
@@ -731,8 +759,8 @@ function transformToLocalCoordinatesBinary(data, feature) {
731
759
  }
732
760
  }
733
761
 
734
- // src/mvt-loader.ts
735
- var VERSION = typeof __VERSION__ !== "undefined" ? __VERSION__ : "latest";
762
+ // dist/mvt-loader.js
763
+ var VERSION = true ? "4.2.0-alpha.5" : "latest";
736
764
  var MVTWorkerLoader = {
737
765
  name: "Mapbox Vector Tile",
738
766
  id: "mvt",
@@ -765,7 +793,7 @@ var MVTLoader = {
765
793
  binary: true
766
794
  };
767
795
 
768
- // src/lib/parse-tilejson.ts
796
+ // dist/lib/parse-tilejson.js
769
797
  var isObject = (x2) => x2 !== null && typeof x2 === "object";
770
798
  function parseTileJSON(jsonMetadata, options) {
771
799
  var _a;
@@ -971,8 +999,8 @@ function attributeTypeToFieldType(aType) {
971
999
  return attrTypeMap[type] || { type: "string" };
972
1000
  }
973
1001
 
974
- // src/tilejson-loader.ts
975
- var VERSION2 = typeof __VERSION__ !== "undefined" ? __VERSION__ : "latest";
1002
+ // dist/tilejson-loader.js
1003
+ var VERSION2 = true ? "4.2.0-alpha.5" : "latest";
976
1004
  var TileJSONLoader = {
977
1005
  name: "TileJSON",
978
1006
  id: "tilejson",
@@ -1000,16 +1028,21 @@ var TileJSONLoader = {
1000
1028
  }
1001
1029
  };
1002
1030
 
1003
- // src/mvt-source.ts
1031
+ // dist/mvt-source.js
1004
1032
  var import_loader_utils = require("@loaders.gl/loader-utils");
1005
1033
  var import_images = require("@loaders.gl/images");
1006
1034
  var import_mvt = require("@loaders.gl/mvt");
1007
1035
  var MVTSource = class extends import_loader_utils.DataSource {
1036
+ props;
1037
+ url;
1038
+ metadataUrl = null;
1039
+ data;
1040
+ schema = "tms";
1041
+ metadata;
1042
+ extension;
1043
+ mimeType = null;
1008
1044
  constructor(props) {
1009
1045
  super(props);
1010
- this.metadataUrl = null;
1011
- this.schema = "tms";
1012
- this.mimeType = null;
1013
1046
  this.props = props;
1014
1047
  this.url = (0, import_loader_utils.resolvePath)(props.url);
1015
1048
  this.metadataUrl = props.metadataUrl === void 0 ? `${this.url}/tilejson.json` : props.metadataUrl;
@@ -1138,7 +1171,7 @@ function stringHash(s) {
1138
1171
  return Math.abs(s.split("").reduce((a, b) => (a << 5) - a + b.charCodeAt(0) | 0, 0));
1139
1172
  }
1140
1173
 
1141
- // src/lib/geojson-tiler/simplify.ts
1174
+ // dist/lib/geojson-tiler/simplify.js
1142
1175
  function simplify(coords, first, last, sqTolerance) {
1143
1176
  let maxSqDist = sqTolerance;
1144
1177
  const mid = last - first >> 1;
@@ -1187,7 +1220,7 @@ function getSqSegDist(px, py, x2, y2, bx, by) {
1187
1220
  return dx * dx + dy * dy;
1188
1221
  }
1189
1222
 
1190
- // src/lib/geojson-tiler/feature.ts
1223
+ // dist/lib/geojson-tiler/feature.js
1191
1224
  function createFeature(id, type, geom, tags) {
1192
1225
  const feature = {
1193
1226
  // eslint-disable-next-line
@@ -1224,7 +1257,7 @@ function calcLineBBox(feature, geom) {
1224
1257
  }
1225
1258
  }
1226
1259
 
1227
- // src/lib/geojson-tiler/convert.ts
1260
+ // dist/lib/geojson-tiler/convert.js
1228
1261
  function convert(data, options) {
1229
1262
  const features = [];
1230
1263
  if (data.type === "FeatureCollection") {
@@ -1281,16 +1314,11 @@ function convertFeature(features, geojson, options, index) {
1281
1314
  }
1282
1315
  } else if (type === "GeometryCollection") {
1283
1316
  for (const singleGeometry of geojson.geometry.geometries) {
1284
- convertFeature(
1285
- features,
1286
- {
1287
- id,
1288
- geometry: singleGeometry,
1289
- properties: geojson.properties
1290
- },
1291
- options,
1292
- index
1293
- );
1317
+ convertFeature(features, {
1318
+ id,
1319
+ geometry: singleGeometry,
1320
+ properties: geojson.properties
1321
+ }, options, index);
1294
1322
  }
1295
1323
  return;
1296
1324
  } else {
@@ -1342,7 +1370,7 @@ function projectY(y2) {
1342
1370
  return y22 < 0 ? 0 : y22 > 1 ? 1 : y22;
1343
1371
  }
1344
1372
 
1345
- // src/lib/geojson-tiler/clip.ts
1373
+ // dist/lib/geojson-tiler/clip.js
1346
1374
  function clip(features, scale, k1, k2, axis, minAll, maxAll, options) {
1347
1375
  k1 /= scale;
1348
1376
  k2 /= scale;
@@ -1507,7 +1535,7 @@ function intersectY(out, ax, ay, bx, by, y2) {
1507
1535
  return t;
1508
1536
  }
1509
1537
 
1510
- // src/lib/geojson-tiler/wrap.ts
1538
+ // dist/lib/geojson-tiler/wrap.js
1511
1539
  function wrap(features, options) {
1512
1540
  const buffer = options.buffer / options.extent;
1513
1541
  let merged = features;
@@ -1564,7 +1592,7 @@ function shiftCoords(points, offset) {
1564
1592
  return newPoints;
1565
1593
  }
1566
1594
 
1567
- // src/lib/geojson-tiler/transform.ts
1595
+ // dist/lib/geojson-tiler/transform.js
1568
1596
  function transformTile(tile, extent) {
1569
1597
  if (tile.transformed) {
1570
1598
  return tile;
@@ -1597,7 +1625,7 @@ function transformPoint(x2, y2, extent, z2, tx, ty) {
1597
1625
  return [Math.round(extent * (x2 * z2 - tx)), Math.round(extent * (y2 * z2 - ty))];
1598
1626
  }
1599
1627
 
1600
- // src/lib/geojson-tiler/tile.ts
1628
+ // dist/lib/geojson-tiler/tile.js
1601
1629
  function createTile(features, z, tx, ty, options) {
1602
1630
  const tolerance = z === options.maxZoom ? 0 : options.tolerance / ((1 << z) * options.extent);
1603
1631
  const tile = {
@@ -1703,7 +1731,7 @@ function rewind(ring, clockwise) {
1703
1731
  }
1704
1732
  }
1705
1733
 
1706
- // src/lib/geojson-tiler/geojson-tiler.ts
1734
+ // dist/lib/geojson-tiler/geojson-tiler.js
1707
1735
  var DEFAULT_OPTIONS = {
1708
1736
  maxZoom: 14,
1709
1737
  // max zoom to preserve detail on
@@ -1728,12 +1756,13 @@ var DEFAULT_OPTIONS = {
1728
1756
  // logging level (0, 1 or 2)
1729
1757
  };
1730
1758
  var GeoJSONTiler = class {
1759
+ options;
1760
+ // tiles and tileCoords are part of the public API
1761
+ tiles = {};
1762
+ tileCoords = [];
1763
+ stats = {};
1764
+ total = 0;
1731
1765
  constructor(data, options) {
1732
- // tiles and tileCoords are part of the public API
1733
- this.tiles = {};
1734
- this.tileCoords = [];
1735
- this.stats = {};
1736
- this.total = 0;
1737
1766
  this.options = { ...DEFAULT_OPTIONS, ...options };
1738
1767
  options = this.options;
1739
1768
  const debug = options.debug;
@@ -1748,11 +1777,7 @@ var GeoJSONTiler = class {
1748
1777
  let features = convert(data, options);
1749
1778
  if (debug) {
1750
1779
  console.timeEnd("preprocess data");
1751
- console.log(
1752
- "index: maxZoom: %d, maxPoints: %d",
1753
- options.indexMaxZoom,
1754
- options.indexMaxPoints
1755
- );
1780
+ console.log("index: maxZoom: %d, maxPoints: %d", options.indexMaxZoom, options.indexMaxPoints);
1756
1781
  console.time("generate tiles");
1757
1782
  }
1758
1783
  features = wrap(features, this.options);
@@ -1840,15 +1865,7 @@ var GeoJSONTiler = class {
1840
1865
  this.tileCoords.push({ z, x: x2, y: y2 });
1841
1866
  if (debug) {
1842
1867
  if (debug > 1) {
1843
- console.log(
1844
- "tile z%d-%d-%d (features: %d, points: %d, simplified: %d)",
1845
- z,
1846
- x2,
1847
- y2,
1848
- tile.numFeatures,
1849
- tile.numPoints,
1850
- tile.numSimplified
1851
- );
1868
+ console.log("tile z%d-%d-%d (features: %d, points: %d, simplified: %d)", z, x2, y2, tile.numFeatures, tile.numPoints, tile.numSimplified);
1852
1869
  console.timeEnd("creation");
1853
1870
  }
1854
1871
  const key = `z${z}`;
@@ -1905,3 +1922,4 @@ var GeoJSONTiler = class {
1905
1922
  function toID(z, x2, y2) {
1906
1923
  return ((1 << z) * y2 + x2) * 32 + z;
1907
1924
  }
1925
+ //# sourceMappingURL=index.cjs.map