@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/dist.dev.js CHANGED
@@ -2,8 +2,8 @@
2
2
  if (typeof exports === 'object' && typeof module === 'object')
3
3
  module.exports = factory();
4
4
  else if (typeof define === 'function' && define.amd) define([], factory);
5
- else if (typeof exports === 'object') exports['loader'] = factory();
6
- else root['loader'] = factory();})(globalThis, function () {
5
+ else if (typeof exports === 'object') exports['loaders'] = factory();
6
+ else root['loaders'] = factory();})(globalThis, function () {
7
7
  "use strict";
8
8
  var __exports__ = (() => {
9
9
  var __create = Object.create;
@@ -27,6 +27,7 @@ var __exports__ = (() => {
27
27
  }
28
28
  return to;
29
29
  };
30
+ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
30
31
  var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
31
32
  // If the importer is in node compatibility mode or this is not an ESM
32
33
  // file that has been converted to a CommonJS file using a Babel-
@@ -37,6 +38,13 @@ var __exports__ = (() => {
37
38
  ));
38
39
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
39
40
 
41
+ // external-global-plugin:@loaders.gl/core
42
+ var require_core = __commonJS({
43
+ "external-global-plugin:@loaders.gl/core"(exports, module) {
44
+ module.exports = globalThis.loaders;
45
+ }
46
+ });
47
+
40
48
  // ../../node_modules/ieee754/index.js
41
49
  var require_ieee754 = __commonJS({
42
50
  "../../node_modules/ieee754/index.js"(exports) {
@@ -777,15 +785,16 @@ var __exports__ = (() => {
777
785
  }
778
786
  });
779
787
 
780
- // src/index.ts
781
- var src_exports = {};
782
- __export(src_exports, {
788
+ // bundle.ts
789
+ var bundle_exports = {};
790
+ __export(bundle_exports, {
783
791
  GeoJSONTiler: () => GeoJSONTiler,
784
792
  MVTLoader: () => MVTLoader,
785
793
  MVTSource: () => MVTSource,
786
794
  MVTWorkerLoader: () => MVTWorkerLoader,
787
795
  TileJSONLoader: () => TileJSONLoader
788
796
  });
797
+ __reExport(bundle_exports, __toESM(require_core(), 1));
789
798
 
790
799
  // ../../node_modules/@babel/runtime/helpers/esm/typeof.js
791
800
  function _typeof(obj) {
@@ -1350,14 +1359,18 @@ var __exports__ = (() => {
1350
1359
  function flatGeojsonToBinary(features, geometryInfo, options) {
1351
1360
  const propArrayTypes = extractNumericPropTypes(features);
1352
1361
  const numericPropKeys = Object.keys(propArrayTypes).filter((k) => propArrayTypes[k] !== Array);
1353
- return fillArrays(features, {
1354
- propArrayTypes,
1355
- ...geometryInfo
1356
- }, {
1357
- numericPropKeys: options && options.numericPropKeys || numericPropKeys,
1358
- PositionDataType: options ? options.PositionDataType : Float32Array,
1359
- triangulate: options ? options.triangulate : true
1360
- });
1362
+ return fillArrays(
1363
+ features,
1364
+ {
1365
+ propArrayTypes,
1366
+ ...geometryInfo
1367
+ },
1368
+ {
1369
+ numericPropKeys: options && options.numericPropKeys || numericPropKeys,
1370
+ PositionDataType: options ? options.PositionDataType : Float32Array,
1371
+ triangulate: options ? options.triangulate : true
1372
+ }
1373
+ );
1361
1374
  }
1362
1375
  function extractNumericPropTypes(features) {
1363
1376
  const propArrayTypes = {};
@@ -1385,11 +1398,7 @@ var __exports__ = (() => {
1385
1398
  propArrayTypes,
1386
1399
  coordLength
1387
1400
  } = geometryInfo;
1388
- const {
1389
- numericPropKeys = [],
1390
- PositionDataType = Float32Array,
1391
- triangulate = true
1392
- } = options;
1401
+ const { numericPropKeys = [], PositionDataType = Float32Array, triangulate = true } = options;
1393
1402
  const hasGlobalId = features[0] && "id" in features[0];
1394
1403
  const GlobalFeatureIdsDataType = features.length > 65535 ? Uint32Array : Uint16Array;
1395
1404
  const points = {
@@ -1454,9 +1463,7 @@ var __exports__ = (() => {
1454
1463
  handlePoint(geometry, points, indexMap, coordLength, properties);
1455
1464
  points.properties.push(keepStringProperties(properties, numericPropKeys));
1456
1465
  if (hasGlobalId) {
1457
- points.fields.push({
1458
- id: feature.id
1459
- });
1466
+ points.fields.push({ id: feature.id });
1460
1467
  }
1461
1468
  indexMap.pointFeature++;
1462
1469
  break;
@@ -1464,9 +1471,7 @@ var __exports__ = (() => {
1464
1471
  handleLineString(geometry, lines, indexMap, coordLength, properties);
1465
1472
  lines.properties.push(keepStringProperties(properties, numericPropKeys));
1466
1473
  if (hasGlobalId) {
1467
- lines.fields.push({
1468
- id: feature.id
1469
- });
1474
+ lines.fields.push({ id: feature.id });
1470
1475
  }
1471
1476
  indexMap.lineFeature++;
1472
1477
  break;
@@ -1474,9 +1479,7 @@ var __exports__ = (() => {
1474
1479
  handlePolygon(geometry, polygons, indexMap, coordLength, properties);
1475
1480
  polygons.properties.push(keepStringProperties(properties, numericPropKeys));
1476
1481
  if (hasGlobalId) {
1477
- polygons.fields.push({
1478
- id: feature.id
1479
- });
1482
+ polygons.fields.push({ id: feature.id });
1480
1483
  }
1481
1484
  indexMap.polygonFeature++;
1482
1485
  break;
@@ -1491,16 +1494,32 @@ var __exports__ = (() => {
1491
1494
  points.positions.set(geometry.data, indexMap.pointPosition * coordLength);
1492
1495
  const nPositions = geometry.data.length / coordLength;
1493
1496
  fillNumericProperties(points, properties, indexMap.pointPosition, nPositions);
1494
- points.globalFeatureIds.fill(indexMap.feature, indexMap.pointPosition, indexMap.pointPosition + nPositions);
1495
- points.featureIds.fill(indexMap.pointFeature, indexMap.pointPosition, indexMap.pointPosition + nPositions);
1497
+ points.globalFeatureIds.fill(
1498
+ indexMap.feature,
1499
+ indexMap.pointPosition,
1500
+ indexMap.pointPosition + nPositions
1501
+ );
1502
+ points.featureIds.fill(
1503
+ indexMap.pointFeature,
1504
+ indexMap.pointPosition,
1505
+ indexMap.pointPosition + nPositions
1506
+ );
1496
1507
  indexMap.pointPosition += nPositions;
1497
1508
  }
1498
1509
  function handleLineString(geometry, lines, indexMap, coordLength, properties) {
1499
1510
  lines.positions.set(geometry.data, indexMap.linePosition * coordLength);
1500
1511
  const nPositions = geometry.data.length / coordLength;
1501
1512
  fillNumericProperties(lines, properties, indexMap.linePosition, nPositions);
1502
- lines.globalFeatureIds.fill(indexMap.feature, indexMap.linePosition, indexMap.linePosition + nPositions);
1503
- lines.featureIds.fill(indexMap.lineFeature, indexMap.linePosition, indexMap.linePosition + nPositions);
1513
+ lines.globalFeatureIds.fill(
1514
+ indexMap.feature,
1515
+ indexMap.linePosition,
1516
+ indexMap.linePosition + nPositions
1517
+ );
1518
+ lines.featureIds.fill(
1519
+ indexMap.lineFeature,
1520
+ indexMap.linePosition,
1521
+ indexMap.linePosition + nPositions
1522
+ );
1504
1523
  for (let i2 = 0, il = geometry.indices.length; i2 < il; ++i2) {
1505
1524
  const start = geometry.indices[i2];
1506
1525
  const end = i2 === il - 1 ? geometry.data.length : geometry.indices[i2 + 1];
@@ -1512,8 +1531,16 @@ var __exports__ = (() => {
1512
1531
  polygons.positions.set(geometry.data, indexMap.polygonPosition * coordLength);
1513
1532
  const nPositions = geometry.data.length / coordLength;
1514
1533
  fillNumericProperties(polygons, properties, indexMap.polygonPosition, nPositions);
1515
- polygons.globalFeatureIds.fill(indexMap.feature, indexMap.polygonPosition, indexMap.polygonPosition + nPositions);
1516
- polygons.featureIds.fill(indexMap.polygonFeature, indexMap.polygonPosition, indexMap.polygonPosition + nPositions);
1534
+ polygons.globalFeatureIds.fill(
1535
+ indexMap.feature,
1536
+ indexMap.polygonPosition,
1537
+ indexMap.polygonPosition + nPositions
1538
+ );
1539
+ polygons.featureIds.fill(
1540
+ indexMap.polygonFeature,
1541
+ indexMap.polygonPosition,
1542
+ indexMap.polygonPosition + nPositions
1543
+ );
1517
1544
  for (let l = 0, ll = geometry.indices.length; l < ll; ++l) {
1518
1545
  const startPosition = indexMap.polygonPosition;
1519
1546
  polygons.polygonIndices[indexMap.polygonObject++] = startPosition;
@@ -1522,16 +1549,15 @@ var __exports__ = (() => {
1522
1549
  const nextIndices = geometry.indices[l + 1];
1523
1550
  for (let i2 = 0, il = indices.length; i2 < il; ++i2) {
1524
1551
  const start = indices[i2];
1525
- const end = i2 === il - 1 ? nextIndices === void 0 ? geometry.data.length : nextIndices[0] : indices[i2 + 1];
1552
+ const end = i2 === il - 1 ? (
1553
+ // last line, so either read to:
1554
+ nextIndices === void 0 ? geometry.data.length : nextIndices[0]
1555
+ ) : indices[i2 + 1];
1526
1556
  polygons.primitivePolygonIndices[indexMap.polygonRing++] = indexMap.polygonPosition;
1527
1557
  indexMap.polygonPosition += (end - start) / coordLength;
1528
1558
  }
1529
1559
  const endPosition = indexMap.polygonPosition;
1530
- triangulatePolygon(polygons, areas, indices, {
1531
- startPosition,
1532
- endPosition,
1533
- coordLength
1534
- });
1560
+ triangulatePolygon(polygons, areas, indices, { startPosition, endPosition, coordLength });
1535
1561
  }
1536
1562
  }
1537
1563
  function triangulatePolygon(polygons, areas, indices, {
@@ -1555,10 +1581,7 @@ var __exports__ = (() => {
1555
1581
  function wrapProps(obj, size) {
1556
1582
  const returnObj = {};
1557
1583
  for (const key in obj) {
1558
- returnObj[key] = {
1559
- value: obj[key],
1560
- size
1561
- };
1584
+ returnObj[key] = { value: obj[key], size };
1562
1585
  }
1563
1586
  return returnObj;
1564
1587
  }
@@ -1567,70 +1590,32 @@ var __exports__ = (() => {
1567
1590
  shape: "binary-feature-collection",
1568
1591
  points: {
1569
1592
  ...points,
1570
- positions: {
1571
- value: points.positions,
1572
- size: coordLength
1573
- },
1574
- globalFeatureIds: {
1575
- value: points.globalFeatureIds,
1576
- size: 1
1577
- },
1578
- featureIds: {
1579
- value: points.featureIds,
1580
- size: 1
1581
- },
1593
+ positions: { value: points.positions, size: coordLength },
1594
+ globalFeatureIds: { value: points.globalFeatureIds, size: 1 },
1595
+ featureIds: { value: points.featureIds, size: 1 },
1582
1596
  numericProps: wrapProps(points.numericProps, 1)
1583
1597
  },
1584
1598
  lines: {
1585
1599
  ...lines,
1586
- positions: {
1587
- value: lines.positions,
1588
- size: coordLength
1589
- },
1590
- pathIndices: {
1591
- value: lines.pathIndices,
1592
- size: 1
1593
- },
1594
- globalFeatureIds: {
1595
- value: lines.globalFeatureIds,
1596
- size: 1
1597
- },
1598
- featureIds: {
1599
- value: lines.featureIds,
1600
- size: 1
1601
- },
1600
+ positions: { value: lines.positions, size: coordLength },
1601
+ pathIndices: { value: lines.pathIndices, size: 1 },
1602
+ globalFeatureIds: { value: lines.globalFeatureIds, size: 1 },
1603
+ featureIds: { value: lines.featureIds, size: 1 },
1602
1604
  numericProps: wrapProps(lines.numericProps, 1)
1603
1605
  },
1604
1606
  polygons: {
1605
1607
  ...polygons,
1606
- positions: {
1607
- value: polygons.positions,
1608
- size: coordLength
1609
- },
1610
- polygonIndices: {
1611
- value: polygons.polygonIndices,
1612
- size: 1
1613
- },
1614
- primitivePolygonIndices: {
1615
- value: polygons.primitivePolygonIndices,
1616
- size: 1
1617
- },
1618
- globalFeatureIds: {
1619
- value: polygons.globalFeatureIds,
1620
- size: 1
1621
- },
1622
- featureIds: {
1623
- value: polygons.featureIds,
1624
- size: 1
1625
- },
1608
+ positions: { value: polygons.positions, size: coordLength },
1609
+ polygonIndices: { value: polygons.polygonIndices, size: 1 },
1610
+ primitivePolygonIndices: { value: polygons.primitivePolygonIndices, size: 1 },
1611
+ globalFeatureIds: { value: polygons.globalFeatureIds, size: 1 },
1612
+ featureIds: { value: polygons.featureIds, size: 1 },
1626
1613
  numericProps: wrapProps(polygons.numericProps, 1)
1627
1614
  }
1615
+ // triangles not expected
1628
1616
  };
1629
1617
  if (binaryFeatures.polygons && polygons.triangles) {
1630
- binaryFeatures.polygons.triangles = {
1631
- value: new Uint32Array(polygons.triangles),
1632
- size: 1
1633
- };
1618
+ binaryFeatures.polygons.triangles = { value: new Uint32Array(polygons.triangles), size: 1 };
1634
1619
  }
1635
1620
  return binaryFeatures;
1636
1621
  }
@@ -1718,6 +1703,14 @@ var __exports__ = (() => {
1718
1703
 
1719
1704
  // src/lib/mapbox-vector-tile/vector-tile-feature.ts
1720
1705
  var VectorTileFeature = class {
1706
+ properties;
1707
+ extent;
1708
+ type;
1709
+ id;
1710
+ _pbf;
1711
+ _geometry;
1712
+ _keys;
1713
+ _values;
1721
1714
  static get types() {
1722
1715
  return ["Unknown", "Point", "LineString", "Polygon"];
1723
1716
  }
@@ -1732,6 +1725,7 @@ var __exports__ = (() => {
1732
1725
  this._values = values;
1733
1726
  pbf.readFields(readFeature, this, end);
1734
1727
  }
1728
+ // eslint-disable-next-line complexity, max-statements
1735
1729
  loadGeometry() {
1736
1730
  const pbf = this._pbf;
1737
1731
  pbf.pos = this._geometry;
@@ -1771,6 +1765,7 @@ var __exports__ = (() => {
1771
1765
  lines.push(line);
1772
1766
  return lines;
1773
1767
  }
1768
+ // eslint-disable-next-line max-statements
1774
1769
  bbox() {
1775
1770
  const pbf = this._pbf;
1776
1771
  pbf.pos = this._geometry;
@@ -1857,11 +1852,7 @@ var __exports__ = (() => {
1857
1852
  if (typeof options === "function") {
1858
1853
  return this._toGeoJSON(options);
1859
1854
  }
1860
- const {
1861
- x: x2,
1862
- y: y2,
1863
- z
1864
- } = options;
1855
+ const { x: x2, y: y2, z } = options;
1865
1856
  const size = this.extent * Math.pow(2, z);
1866
1857
  const x0 = this.extent * x2;
1867
1858
  const y0 = this.extent * y2;
@@ -1879,6 +1870,14 @@ var __exports__ = (() => {
1879
1870
 
1880
1871
  // src/lib/mapbox-vector-tile/vector-tile-layer.ts
1881
1872
  var VectorTileLayer = class {
1873
+ version;
1874
+ name;
1875
+ extent;
1876
+ length;
1877
+ _pbf;
1878
+ _keys;
1879
+ _values;
1880
+ _features;
1882
1881
  constructor(pbf, end) {
1883
1882
  this.version = 1;
1884
1883
  this.name = "";
@@ -1891,6 +1890,11 @@ var __exports__ = (() => {
1891
1890
  pbf.readFields(readLayer, this, end);
1892
1891
  this.length = this._features.length;
1893
1892
  }
1893
+ /**
1894
+ * return feature `i` from this layer as a `VectorTileFeature`
1895
+ * @param index
1896
+ * @returns feature
1897
+ */
1894
1898
  feature(i2) {
1895
1899
  if (i2 < 0 || i2 >= this._features.length) {
1896
1900
  throw new Error("feature index out of bounds");
@@ -1928,6 +1932,7 @@ var __exports__ = (() => {
1928
1932
 
1929
1933
  // src/lib/mapbox-vector-tile/vector-tile.ts
1930
1934
  var VectorTile = class {
1935
+ layers;
1931
1936
  constructor(pbf, end) {
1932
1937
  this.layers = pbf.readFields(readTile, {}, end);
1933
1938
  }
@@ -1991,12 +1996,7 @@ var __exports__ = (() => {
1991
1996
  areas.push(ringAreas);
1992
1997
  if (polygon.length)
1993
1998
  polygons.push(polygon);
1994
- return {
1995
- type,
1996
- areas,
1997
- indices: polygons,
1998
- data: geom.data
1999
- };
1999
+ return { type, areas, indices: polygons, data: geom.data };
2000
2000
  }
2001
2001
  function project(data, x0, y0, size) {
2002
2002
  for (let j = 0, jl = data.length; j < jl; j += 2) {
@@ -2035,6 +2035,16 @@ var __exports__ = (() => {
2035
2035
  var y;
2036
2036
  var i;
2037
2037
  var VectorTileFeature2 = class {
2038
+ properties;
2039
+ extent;
2040
+ type;
2041
+ id;
2042
+ _pbf;
2043
+ _geometry;
2044
+ _keys;
2045
+ _values;
2046
+ _geometryInfo;
2047
+ // eslint-disable-next-line max-params
2038
2048
  constructor(pbf, end, extent, keys, values, geometryInfo) {
2039
2049
  this.properties = {};
2040
2050
  this.extent = extent;
@@ -2047,6 +2057,7 @@ var __exports__ = (() => {
2047
2057
  this._geometryInfo = geometryInfo;
2048
2058
  pbf.readFields(readFeature2, this, end);
2049
2059
  }
2060
+ // eslint-disable-next-line complexity, max-statements
2050
2061
  loadGeometry() {
2051
2062
  const pbf = this._pbf;
2052
2063
  pbf.pos = this._geometry;
@@ -2083,11 +2094,13 @@ var __exports__ = (() => {
2083
2094
  throw new Error(`unknown command ${cmd}`);
2084
2095
  }
2085
2096
  }
2086
- return {
2087
- data,
2088
- indices
2089
- };
2097
+ return { data, indices };
2090
2098
  }
2099
+ /**
2100
+ *
2101
+ * @param transform
2102
+ * @returns result
2103
+ */
2091
2104
  _toBinaryCoordinates(transform) {
2092
2105
  const geom = this.loadGeometry();
2093
2106
  let geometry;
@@ -2097,19 +2110,13 @@ var __exports__ = (() => {
2097
2110
  case 1:
2098
2111
  this._geometryInfo.pointFeaturesCount++;
2099
2112
  this._geometryInfo.pointPositionsCount += geom.indices.length;
2100
- geometry = {
2101
- type: "Point",
2102
- ...geom
2103
- };
2113
+ geometry = { type: "Point", ...geom };
2104
2114
  break;
2105
2115
  case 2:
2106
2116
  this._geometryInfo.lineFeaturesCount++;
2107
2117
  this._geometryInfo.linePathsCount += geom.indices.length;
2108
2118
  this._geometryInfo.linePositionsCount += geom.data.length / coordLength;
2109
- geometry = {
2110
- type: "LineString",
2111
- ...geom
2112
- };
2119
+ geometry = { type: "LineString", ...geom };
2113
2120
  break;
2114
2121
  case 3:
2115
2122
  geometry = classifyRings2(geom);
@@ -2123,11 +2130,7 @@ var __exports__ = (() => {
2123
2130
  default:
2124
2131
  throw new Error(`Invalid geometry type: ${this.type}`);
2125
2132
  }
2126
- const result = {
2127
- type: "Feature",
2128
- geometry,
2129
- properties: this.properties
2130
- };
2133
+ const result = { type: "Feature", geometry, properties: this.properties };
2131
2134
  if (this.id !== null) {
2132
2135
  result.id = this.id;
2133
2136
  }
@@ -2137,11 +2140,7 @@ var __exports__ = (() => {
2137
2140
  if (typeof options === "function") {
2138
2141
  return this._toBinaryCoordinates(options);
2139
2142
  }
2140
- const {
2141
- x: x2,
2142
- y: y2,
2143
- z
2144
- } = options;
2143
+ const { x: x2, y: y2, z } = options;
2145
2144
  const size = this.extent * Math.pow(2, z);
2146
2145
  const x0 = this.extent * x2;
2147
2146
  const y0 = this.extent * y2;
@@ -2151,6 +2150,14 @@ var __exports__ = (() => {
2151
2150
 
2152
2151
  // src/lib/binary-vector-tile/vector-tile-layer.ts
2153
2152
  var VectorTileLayer2 = class {
2153
+ version;
2154
+ name;
2155
+ extent;
2156
+ length;
2157
+ _pbf;
2158
+ _keys;
2159
+ _values;
2160
+ _features;
2154
2161
  constructor(pbf, end) {
2155
2162
  this.version = 1;
2156
2163
  this.name = "";
@@ -2163,13 +2170,27 @@ var __exports__ = (() => {
2163
2170
  pbf.readFields(readLayer2, this, end);
2164
2171
  this.length = this._features.length;
2165
2172
  }
2173
+ /**
2174
+ * return feature `i` from this layer as a `VectorTileFeature`
2175
+ *
2176
+ * @param index
2177
+ * @param geometryInfo
2178
+ * @returns {VectorTileFeature}
2179
+ */
2166
2180
  feature(i2, geometryInfo) {
2167
2181
  if (i2 < 0 || i2 >= this._features.length) {
2168
2182
  throw new Error("feature index out of bounds");
2169
2183
  }
2170
2184
  this._pbf.pos = this._features[i2];
2171
2185
  const end = this._pbf.readVarint() + this._pbf.pos;
2172
- return new VectorTileFeature2(this._pbf, end, this.extent, this._keys, this._values, geometryInfo);
2186
+ return new VectorTileFeature2(
2187
+ this._pbf,
2188
+ end,
2189
+ this.extent,
2190
+ this._keys,
2191
+ this._values,
2192
+ geometryInfo
2193
+ );
2173
2194
  }
2174
2195
  };
2175
2196
  function readLayer2(tag, layer, pbf) {
@@ -2200,6 +2221,7 @@ var __exports__ = (() => {
2200
2221
 
2201
2222
  // src/lib/binary-vector-tile/vector-tile.ts
2202
2223
  var VectorTile2 = class {
2224
+ layers;
2203
2225
  constructor(pbf, end) {
2204
2226
  this.layers = pbf.readFields(readTile2, {}, end);
2205
2227
  }
@@ -2221,10 +2243,7 @@ var __exports__ = (() => {
2221
2243
  const shape = options?.gis?.format || options?.mvt?.shape || options?.shape;
2222
2244
  switch (shape) {
2223
2245
  case "columnar-table":
2224
- return {
2225
- shape: "columnar-table",
2226
- data: parseToBinary(arrayBuffer, mvtOptions)
2227
- };
2246
+ return { shape: "columnar-table", data: parseToBinary(arrayBuffer, mvtOptions) };
2228
2247
  case "geojson-table": {
2229
2248
  const table = {
2230
2249
  shape: "geojson-table",
@@ -2306,9 +2325,7 @@ var __exports__ = (() => {
2306
2325
  throw new Error("mvt options required");
2307
2326
  }
2308
2327
  const wgs84Coordinates = options.mvt?.coordinates === "wgs84";
2309
- const {
2310
- tileIndex
2311
- } = options.mvt;
2328
+ const { tileIndex } = options.mvt;
2312
2329
  const hasTileIndex = tileIndex && Number.isFinite(tileIndex.x) && Number.isFinite(tileIndex.y) && Number.isFinite(tileIndex.z);
2313
2330
  if (wgs84Coordinates && !hasTileIndex) {
2314
2331
  throw new Error("MVT Loader: WGS84 coordinates need tileIndex property");
@@ -2316,23 +2333,27 @@ var __exports__ = (() => {
2316
2333
  return options.mvt;
2317
2334
  }
2318
2335
  function getDecodedFeature(feature, options, layerName) {
2319
- const decodedFeature = feature.toGeoJSON(options.coordinates === "wgs84" ? options.tileIndex : transformToLocalCoordinates);
2336
+ const decodedFeature = feature.toGeoJSON(
2337
+ // @ts-expect-error What is going on here?
2338
+ options.coordinates === "wgs84" ? options.tileIndex : transformToLocalCoordinates
2339
+ );
2320
2340
  if (options.layerProperty) {
2321
2341
  decodedFeature.properties[options.layerProperty] = layerName;
2322
2342
  }
2323
2343
  return decodedFeature;
2324
2344
  }
2325
2345
  function getDecodedFeatureBinary(feature, options, layerName) {
2326
- const decodedFeature = feature.toBinaryCoordinates(options.coordinates === "wgs84" ? options.tileIndex : transformToLocalCoordinatesBinary);
2346
+ const decodedFeature = feature.toBinaryCoordinates(
2347
+ // @ts-expect-error What is going on here?
2348
+ options.coordinates === "wgs84" ? options.tileIndex : transformToLocalCoordinatesBinary
2349
+ );
2327
2350
  if (options.layerProperty && decodedFeature.properties) {
2328
2351
  decodedFeature.properties[options.layerProperty] = layerName;
2329
2352
  }
2330
2353
  return decodedFeature;
2331
2354
  }
2332
2355
  function transformToLocalCoordinates(line, feature) {
2333
- const {
2334
- extent
2335
- } = feature;
2356
+ const { extent } = feature;
2336
2357
  for (let i2 = 0; i2 < line.length; i2++) {
2337
2358
  const p = line[i2];
2338
2359
  p[0] /= extent;
@@ -2340,23 +2361,27 @@ var __exports__ = (() => {
2340
2361
  }
2341
2362
  }
2342
2363
  function transformToLocalCoordinatesBinary(data, feature) {
2343
- const {
2344
- extent
2345
- } = feature;
2364
+ const { extent } = feature;
2346
2365
  for (let i2 = 0, il = data.length; i2 < il; ++i2) {
2347
2366
  data[i2] /= extent;
2348
2367
  }
2349
2368
  }
2350
2369
 
2351
2370
  // src/mvt-loader.ts
2352
- var VERSION = true ? "4.2.0-alpha.4" : "latest";
2371
+ var VERSION = typeof __VERSION__ !== "undefined" ? __VERSION__ : "latest";
2353
2372
  var MVTWorkerLoader = {
2354
2373
  name: "Mapbox Vector Tile",
2355
2374
  id: "mvt",
2356
2375
  module: "mvt",
2357
2376
  version: VERSION,
2377
+ // Note: ArcGIS uses '.pbf' extension and 'application/octet-stream'
2358
2378
  extensions: ["mvt", "pbf"],
2359
- mimeTypes: ["application/vnd.mapbox-vector-tile", "application/x-protobuf"],
2379
+ mimeTypes: [
2380
+ // https://www.iana.org/assignments/media-types/application/vnd.mapbox-vector-tile
2381
+ "application/vnd.mapbox-vector-tile",
2382
+ "application/x-protobuf"
2383
+ // 'application/octet-stream'
2384
+ ],
2360
2385
  worker: true,
2361
2386
  category: "geometry",
2362
2387
  options: {
@@ -2430,9 +2455,7 @@ var __exports__ = (() => {
2430
2455
  name: key,
2431
2456
  ...attributeTypeToFieldType(String(datatype))
2432
2457
  }));
2433
- const layer2 = {
2434
- ...layer
2435
- };
2458
+ const layer2 = { ...layer };
2436
2459
  delete layer2.fields;
2437
2460
  return {
2438
2461
  name: layer.id || "",
@@ -2474,9 +2497,7 @@ var __exports__ = (() => {
2474
2497
  return layers.map((layer) => {
2475
2498
  const tilestatsLayer = tilestatsLayers.find((tsLayer) => tsLayer.name === layer.name);
2476
2499
  const fields = tilestatsLayer?.fields || [];
2477
- const layer2 = {
2478
- ...layer
2479
- };
2500
+ const layer2 = { ...layer };
2480
2501
  delete layer2.fields;
2481
2502
  return {
2482
2503
  ...layer2,
@@ -2488,7 +2509,10 @@ var __exports__ = (() => {
2488
2509
  function parseBounds(bounds) {
2489
2510
  const result = fromArrayOrString(bounds);
2490
2511
  if (Array.isArray(result) && result.length === 4 && [result[0], result[2]].every(isLng) && [result[1], result[3]].every(isLat)) {
2491
- return [[result[0], result[1]], [result[2], result[3]]];
2512
+ return [
2513
+ [result[0], result[1]],
2514
+ [result[2], result[3]]
2515
+ ];
2492
2516
  }
2493
2517
  return void 0;
2494
2518
  }
@@ -2553,6 +2577,8 @@ var __exports__ = (() => {
2553
2577
  const fieldTypes = attributeTypeToFieldType(attribute.type);
2554
2578
  const field = {
2555
2579
  name: attribute.attribute,
2580
+ // what happens if attribute type is string...
2581
+ // filterProps: getFilterProps(fieldTypes.type, attribute),
2556
2582
  ...fieldTypes
2557
2583
  };
2558
2584
  if (typeof attribute.min === "number") {
@@ -2576,13 +2602,11 @@ var __exports__ = (() => {
2576
2602
  const type = aType.toLowerCase();
2577
2603
  if (!type || !attrTypeMap[type]) {
2578
2604
  }
2579
- return attrTypeMap[type] || {
2580
- type: "string"
2581
- };
2605
+ return attrTypeMap[type] || { type: "string" };
2582
2606
  }
2583
2607
 
2584
2608
  // src/tilejson-loader.ts
2585
- var VERSION2 = true ? "4.2.0-alpha.4" : "latest";
2609
+ var VERSION2 = typeof __VERSION__ !== "undefined" ? __VERSION__ : "latest";
2586
2610
  var TileJSONLoader = {
2587
2611
  name: "TileJSON",
2588
2612
  id: "tilejson",
@@ -2600,18 +2624,12 @@ var __exports__ = (() => {
2600
2624
  parse: async (arrayBuffer, options) => {
2601
2625
  const jsonString = new TextDecoder().decode(arrayBuffer);
2602
2626
  const json = JSON.parse(jsonString);
2603
- const tilejsonOptions = {
2604
- ...TileJSONLoader.options.tilejson,
2605
- ...options?.tilejson
2606
- };
2627
+ const tilejsonOptions = { ...TileJSONLoader.options.tilejson, ...options?.tilejson };
2607
2628
  return parseTileJSON(json, tilejsonOptions);
2608
2629
  },
2609
2630
  parseTextSync: (text, options) => {
2610
2631
  const json = JSON.parse(text);
2611
- const tilejsonOptions = {
2612
- ...TileJSONLoader.options.tilejson,
2613
- ...options?.tilejson
2614
- };
2632
+ const tilejsonOptions = { ...TileJSONLoader.options.tilejson, ...options?.tilejson };
2615
2633
  return parseTileJSON(json, tilejsonOptions);
2616
2634
  }
2617
2635
  };
@@ -2634,7 +2652,10 @@ var __exports__ = (() => {
2634
2652
  var window_ = globals.window || globals.self || globals.global || {};
2635
2653
  var global_ = globals.global || globals.self || globals.window || {};
2636
2654
  var document_ = globals.document || {};
2637
- var isBrowser = Boolean(typeof process !== "object" || String(process) !== "[object process]" || process.browser);
2655
+ var isBrowser = (
2656
+ // @ts-ignore process does not exist on browser
2657
+ Boolean(typeof process !== "object" || String(process) !== "[object process]" || process.browser)
2658
+ );
2638
2659
  var matches = typeof process !== "undefined" && process.version && /v([0-9]*)/.exec(process.version);
2639
2660
  var nodeVersion = matches && parseFloat(matches[1]) || 0;
2640
2661
 
@@ -2656,23 +2677,29 @@ var __exports__ = (() => {
2656
2677
 
2657
2678
  // ../loader-utils/src/lib/sources/data-source.ts
2658
2679
  var DataSource = class {
2680
+ /** A resolved fetch function extracted from loadOptions prop */
2681
+ fetch;
2682
+ /** The actual load options, if calling a loaders.gl loader */
2683
+ loadOptions;
2659
2684
  _needsRefresh = true;
2685
+ props;
2660
2686
  constructor(props) {
2661
- this.props = {
2662
- ...props
2663
- };
2664
- this.loadOptions = {
2665
- ...props.loadOptions
2666
- };
2687
+ this.props = { ...props };
2688
+ this.loadOptions = { ...props.loadOptions };
2667
2689
  this.fetch = getFetchFunction(this.loadOptions);
2668
2690
  }
2669
2691
  setProps(props) {
2670
2692
  this.props = Object.assign(this.props, props);
2671
2693
  this.setNeedsRefresh();
2672
2694
  }
2695
+ /** Mark this data source as needing a refresh (redraw) */
2673
2696
  setNeedsRefresh() {
2674
2697
  this._needsRefresh = true;
2675
2698
  }
2699
+ /**
2700
+ * Does this data source need refreshing?
2701
+ * @note The specifics of the refresh mechanism depends on type of data source
2702
+ */
2676
2703
  getNeedsRefresh(clear = true) {
2677
2704
  const needsRefresh = this._needsRefresh;
2678
2705
  if (clear) {
@@ -2694,7 +2721,7 @@ var __exports__ = (() => {
2694
2721
  }
2695
2722
 
2696
2723
  // ../images/src/lib/utils/version.ts
2697
- var VERSION3 = true ? "4.2.0-alpha.4" : "latest";
2724
+ var VERSION3 = typeof __VERSION__ !== "undefined" ? __VERSION__ : "latest";
2698
2725
 
2699
2726
  // ../images/src/lib/category-api/image-type.ts
2700
2727
  var parseImageNode = globalThis.loaders?.parseImageNode;
@@ -2881,10 +2908,7 @@ var __exports__ = (() => {
2881
2908
  switch (brandMajor) {
2882
2909
  case "avif":
2883
2910
  case "avis":
2884
- return {
2885
- extension: "avif",
2886
- mimeType: "image/avif"
2887
- };
2911
+ return { extension: "avif", mimeType: "image/avif" };
2888
2912
  default:
2889
2913
  return null;
2890
2914
  }
@@ -2920,6 +2944,7 @@ var __exports__ = (() => {
2920
2944
  }
2921
2945
  return {
2922
2946
  mimeType: mediaType.mimeType,
2947
+ // TODO - decode width and height
2923
2948
  width: 0,
2924
2949
  height: 0
2925
2950
  };
@@ -2966,10 +2991,7 @@ var __exports__ = (() => {
2966
2991
  if (!isJpeg) {
2967
2992
  return null;
2968
2993
  }
2969
- const {
2970
- tableMarkers,
2971
- sofMarkers
2972
- } = getJpegMarkers();
2994
+ const { tableMarkers, sofMarkers } = getJpegMarkers();
2973
2995
  let i2 = 2;
2974
2996
  while (i2 + 9 < dataView.byteLength) {
2975
2997
  const marker = dataView.getUint16(i2, BIG_ENDIAN);
@@ -2977,7 +2999,9 @@ var __exports__ = (() => {
2977
2999
  return {
2978
3000
  mimeType: "image/jpeg",
2979
3001
  height: dataView.getUint16(i2 + 5, BIG_ENDIAN),
3002
+ // Number of lines
2980
3003
  width: dataView.getUint16(i2 + 7, BIG_ENDIAN)
3004
+ // Number of pixels per line
2981
3005
  };
2982
3006
  }
2983
3007
  if (!tableMarkers.has(marker)) {
@@ -2993,11 +3017,23 @@ var __exports__ = (() => {
2993
3017
  for (let i2 = 65504; i2 < 65520; ++i2) {
2994
3018
  tableMarkers.add(i2);
2995
3019
  }
2996
- const sofMarkers = /* @__PURE__ */ new Set([65472, 65473, 65474, 65475, 65477, 65478, 65479, 65481, 65482, 65483, 65485, 65486, 65487, 65502]);
2997
- return {
2998
- tableMarkers,
2999
- sofMarkers
3000
- };
3020
+ const sofMarkers = /* @__PURE__ */ new Set([
3021
+ 65472,
3022
+ 65473,
3023
+ 65474,
3024
+ 65475,
3025
+ 65477,
3026
+ 65478,
3027
+ 65479,
3028
+ 65481,
3029
+ 65482,
3030
+ 65483,
3031
+ 65485,
3032
+ 65486,
3033
+ 65487,
3034
+ 65502
3035
+ ]);
3036
+ return { tableMarkers, sofMarkers };
3001
3037
  }
3002
3038
  function toDataView(data) {
3003
3039
  if (data instanceof DataView) {
@@ -3014,9 +3050,7 @@ var __exports__ = (() => {
3014
3050
 
3015
3051
  // ../images/src/lib/parsers/parse-to-node-image.ts
3016
3052
  async function parseToNodeImage(arrayBuffer, options) {
3017
- const {
3018
- mimeType
3019
- } = getBinaryImageMetadata(arrayBuffer) || {};
3053
+ const { mimeType } = getBinaryImageMetadata(arrayBuffer) || {};
3020
3054
  const parseImageNode2 = globalThis.loaders?.parseImageNode;
3021
3055
  assert(parseImageNode2);
3022
3056
  return await parseImageNode2(arrayBuffer, mimeType);
@@ -3027,9 +3061,7 @@ var __exports__ = (() => {
3027
3061
  options = options || {};
3028
3062
  const imageOptions = options.image || {};
3029
3063
  const imageType = imageOptions.type || "auto";
3030
- const {
3031
- url
3032
- } = context || {};
3064
+ const { url } = context || {};
3033
3065
  const loadType = getLoadableImageType(imageType);
3034
3066
  let image;
3035
3067
  switch (loadType) {
@@ -3063,12 +3095,23 @@ var __exports__ = (() => {
3063
3095
 
3064
3096
  // ../images/src/image-loader.ts
3065
3097
  var EXTENSIONS = ["png", "jpg", "jpeg", "gif", "webp", "bmp", "ico", "svg", "avif"];
3066
- var MIME_TYPES = ["image/png", "image/jpeg", "image/gif", "image/webp", "image/avif", "image/bmp", "image/vnd.microsoft.icon", "image/svg+xml"];
3098
+ var MIME_TYPES = [
3099
+ "image/png",
3100
+ "image/jpeg",
3101
+ "image/gif",
3102
+ "image/webp",
3103
+ "image/avif",
3104
+ "image/bmp",
3105
+ "image/vnd.microsoft.icon",
3106
+ "image/svg+xml"
3107
+ ];
3067
3108
  var DEFAULT_IMAGE_LOADER_OPTIONS = {
3068
3109
  image: {
3069
3110
  type: "auto",
3070
3111
  decode: true
3112
+ // if format is HTML
3071
3113
  }
3114
+ // imagebitmap: {} - passes (platform dependent) parameters to ImageBitmap constructor
3072
3115
  };
3073
3116
  var ImageLoader = {
3074
3117
  id: "image",
@@ -3078,14 +3121,20 @@ var __exports__ = (() => {
3078
3121
  mimeTypes: MIME_TYPES,
3079
3122
  extensions: EXTENSIONS,
3080
3123
  parse: parseImage,
3124
+ // TODO: byteOffset, byteLength;
3081
3125
  tests: [(arrayBuffer) => Boolean(getBinaryImageMetadata(new DataView(arrayBuffer)))],
3082
3126
  options: DEFAULT_IMAGE_LOADER_OPTIONS
3083
3127
  };
3084
3128
 
3085
3129
  // src/mvt-source.ts
3086
3130
  var MVTSource = class extends DataSource {
3131
+ props;
3132
+ url;
3087
3133
  metadataUrl = null;
3134
+ data;
3088
3135
  schema = "tms";
3136
+ metadata;
3137
+ extension;
3089
3138
  mimeType = null;
3090
3139
  constructor(props) {
3091
3140
  super(props);
@@ -3100,6 +3149,7 @@ var __exports__ = (() => {
3100
3149
  this.schema = "template";
3101
3150
  }
3102
3151
  }
3152
+ // @ts-ignore - Metadata type misalignment
3103
3153
  async getMetadata() {
3104
3154
  if (!this.metadataUrl) {
3105
3155
  return null;
@@ -3123,11 +3173,7 @@ var __exports__ = (() => {
3123
3173
  return this.mimeType;
3124
3174
  }
3125
3175
  async getTile(tileParams) {
3126
- const {
3127
- x: x2,
3128
- y: y2,
3129
- zoom: z
3130
- } = tileParams;
3176
+ const { x: x2, y: y2, zoom: z } = tileParams;
3131
3177
  const tileUrl = this.getTileURL(x2, y2, z);
3132
3178
  const response = await this.fetch(tileUrl);
3133
3179
  if (!response.ok) {
@@ -3136,18 +3182,11 @@ var __exports__ = (() => {
3136
3182
  const arrayBuffer = await response.arrayBuffer();
3137
3183
  return arrayBuffer;
3138
3184
  }
3185
+ // Tile Source interface implementation: deck.gl compatible API
3186
+ // TODO - currently only handles image tiles, not vector tiles
3139
3187
  async getTileData(tileParams) {
3140
- const {
3141
- x: x2,
3142
- y: y2,
3143
- z
3144
- } = tileParams.index;
3145
- const arrayBuffer = await this.getTile({
3146
- x: x2,
3147
- y: y2,
3148
- zoom: z,
3149
- layers: []
3150
- });
3188
+ const { x: x2, y: y2, z } = tileParams.index;
3189
+ const arrayBuffer = await this.getTile({ x: x2, y: y2, zoom: z, layers: [] });
3151
3190
  if (arrayBuffer === null) {
3152
3191
  return null;
3153
3192
  }
@@ -3155,16 +3194,12 @@ var __exports__ = (() => {
3155
3194
  this.mimeType = this.mimeType || imageMetadata?.mimeType || "application/vnd.mapbox-vector-tile";
3156
3195
  switch (this.mimeType) {
3157
3196
  case "application/vnd.mapbox-vector-tile":
3158
- return await this._parseVectorTile(arrayBuffer, {
3159
- x: x2,
3160
- y: y2,
3161
- zoom: z,
3162
- layers: []
3163
- });
3197
+ return await this._parseVectorTile(arrayBuffer, { x: x2, y: y2, zoom: z, layers: [] });
3164
3198
  default:
3165
3199
  return await this._parseImageTile(arrayBuffer);
3166
3200
  }
3167
3201
  }
3202
+ // ImageTileSource interface implementation
3168
3203
  async getImageTile(tileParams) {
3169
3204
  const arrayBuffer = await this.getTile(tileParams);
3170
3205
  return arrayBuffer ? this._parseImageTile(arrayBuffer) : null;
@@ -3172,6 +3207,7 @@ var __exports__ = (() => {
3172
3207
  async _parseImageTile(arrayBuffer) {
3173
3208
  return await ImageLoader.parse(arrayBuffer, this.loadOptions);
3174
3209
  }
3210
+ // VectorTileSource interface implementation
3175
3211
  async getVectorTile(tileParams) {
3176
3212
  const arrayBuffer = await this.getTile(tileParams);
3177
3213
  return arrayBuffer ? this._parseVectorTile(arrayBuffer, tileParams) : null;
@@ -3181,11 +3217,7 @@ var __exports__ = (() => {
3181
3217
  shape: "geojson-table",
3182
3218
  mvt: {
3183
3219
  coordinates: "wgs84",
3184
- tileIndex: {
3185
- x: tileParams.x,
3186
- y: tileParams.y,
3187
- z: tileParams.zoom
3188
- },
3220
+ tileIndex: { x: tileParams.x, y: tileParams.y, z: tileParams.zoom },
3189
3221
  ...this.loadOptions?.mvt
3190
3222
  },
3191
3223
  ...this.loadOptions
@@ -3284,6 +3316,7 @@ var __exports__ = (() => {
3284
3316
  // src/lib/geojson-tiler/feature.ts
3285
3317
  function createFeature(id, type, geom, tags) {
3286
3318
  const feature = {
3319
+ // eslint-disable-next-line
3287
3320
  id: id == null ? null : id,
3288
3321
  type,
3289
3322
  geometry: geom,
@@ -3327,9 +3360,7 @@ var __exports__ = (() => {
3327
3360
  } else if (data.type === "Feature") {
3328
3361
  convertFeature(features, data, options);
3329
3362
  } else {
3330
- convertFeature(features, {
3331
- geometry: data
3332
- }, options);
3363
+ convertFeature(features, { geometry: data }, options);
3333
3364
  }
3334
3365
  return features;
3335
3366
  }
@@ -3376,11 +3407,16 @@ var __exports__ = (() => {
3376
3407
  }
3377
3408
  } else if (type === "GeometryCollection") {
3378
3409
  for (const singleGeometry of geojson.geometry.geometries) {
3379
- convertFeature(features, {
3380
- id,
3381
- geometry: singleGeometry,
3382
- properties: geojson.properties
3383
- }, options, index);
3410
+ convertFeature(
3411
+ features,
3412
+ {
3413
+ id,
3414
+ geometry: singleGeometry,
3415
+ properties: geojson.properties
3416
+ },
3417
+ options,
3418
+ index
3419
+ );
3384
3420
  }
3385
3421
  return;
3386
3422
  } else {
@@ -3796,26 +3832,36 @@ var __exports__ = (() => {
3796
3832
  // src/lib/geojson-tiler/geojson-tiler.ts
3797
3833
  var DEFAULT_OPTIONS = {
3798
3834
  maxZoom: 14,
3835
+ // max zoom to preserve detail on
3799
3836
  indexMaxZoom: 5,
3837
+ // max zoom in the tile index
3800
3838
  indexMaxPoints: 1e5,
3839
+ // max number of points per tile in the tile index
3801
3840
  tolerance: 3,
3841
+ // simplification tolerance (higher means simpler)
3802
3842
  extent: 4096,
3843
+ // tile extent
3803
3844
  buffer: 64,
3845
+ // tile buffer on each side
3804
3846
  lineMetrics: false,
3847
+ // whether to calculate line metrics
3848
+ // @ts-expect-error Ensures all these required params have defaults
3805
3849
  promoteId: void 0,
3850
+ // name of a feature property to be promoted to feature.id
3806
3851
  generateId: false,
3852
+ // whether to generate feature ids. Cannot be used with promoteId
3807
3853
  debug: 0
3854
+ // logging level (0, 1 or 2)
3808
3855
  };
3809
3856
  var GeoJSONTiler = class {
3857
+ options;
3858
+ // tiles and tileCoords are part of the public API
3810
3859
  tiles = {};
3811
3860
  tileCoords = [];
3812
3861
  stats = {};
3813
3862
  total = 0;
3814
3863
  constructor(data, options) {
3815
- this.options = {
3816
- ...DEFAULT_OPTIONS,
3817
- ...options
3818
- };
3864
+ this.options = { ...DEFAULT_OPTIONS, ...options };
3819
3865
  options = this.options;
3820
3866
  const debug = options.debug;
3821
3867
  if (debug)
@@ -3829,7 +3875,11 @@ var __exports__ = (() => {
3829
3875
  let features = convert(data, options);
3830
3876
  if (debug) {
3831
3877
  console.timeEnd("preprocess data");
3832
- console.log("index: maxZoom: %d, maxPoints: %d", options.indexMaxZoom, options.indexMaxPoints);
3878
+ console.log(
3879
+ "index: maxZoom: %d, maxPoints: %d",
3880
+ options.indexMaxZoom,
3881
+ options.indexMaxPoints
3882
+ );
3833
3883
  console.time("generate tiles");
3834
3884
  }
3835
3885
  features = wrap(features, this.options);
@@ -3844,11 +3894,16 @@ var __exports__ = (() => {
3844
3894
  console.log("tiles generated:", this.total, JSON.stringify(this.stats));
3845
3895
  }
3846
3896
  }
3897
+ /**
3898
+ * Get a tile at the specified index
3899
+ * @param z
3900
+ * @param x
3901
+ * @param y
3902
+ * @returns
3903
+ */
3904
+ // eslint-disable-next-line complexity, max-statements
3847
3905
  getTile(z, x2, y2) {
3848
- const {
3849
- extent,
3850
- debug
3851
- } = this.options;
3906
+ const { extent, debug } = this.options;
3852
3907
  if (z < 0 || z > 24) {
3853
3908
  return null;
3854
3909
  }
@@ -3883,6 +3938,15 @@ var __exports__ = (() => {
3883
3938
  }
3884
3939
  return this.tiles[id] ? transformTile(this.tiles[id], extent) : null;
3885
3940
  }
3941
+ /**
3942
+ * splits features from a parent tile to sub-tiles.
3943
+ * @param z, x, and y are the coordinates of the parent tile
3944
+ * @param cz, cx, and cy are the coordinates of the target tile
3945
+ *
3946
+ * If no target tile is specified, splitting stops when we reach the maximum
3947
+ * zoom or the number of points is low as specified in the options.
3948
+ */
3949
+ // eslint-disable-next-line max-params, max-statements, complexity
3886
3950
  splitTile(features, z, x2, y2, cz, cx, cy) {
3887
3951
  const stack = [features, z, x2, y2];
3888
3952
  const options = this.options;
@@ -3900,14 +3964,18 @@ var __exports__ = (() => {
3900
3964
  console.time("creation");
3901
3965
  }
3902
3966
  tile = this.tiles[id] = createTile(features, z, x2, y2, options);
3903
- this.tileCoords.push({
3904
- z,
3905
- x: x2,
3906
- y: y2
3907
- });
3967
+ this.tileCoords.push({ z, x: x2, y: y2 });
3908
3968
  if (debug) {
3909
3969
  if (debug > 1) {
3910
- console.log("tile z%d-%d-%d (features: %d, points: %d, simplified: %d)", z, x2, y2, tile.numFeatures, tile.numPoints, tile.numSimplified);
3970
+ console.log(
3971
+ "tile z%d-%d-%d (features: %d, points: %d, simplified: %d)",
3972
+ z,
3973
+ x2,
3974
+ y2,
3975
+ tile.numFeatures,
3976
+ tile.numPoints,
3977
+ tile.numSimplified
3978
+ );
3911
3979
  console.timeEnd("creation");
3912
3980
  }
3913
3981
  const key = `z${z}`;
@@ -3964,7 +4032,7 @@ var __exports__ = (() => {
3964
4032
  function toID(z, x2, y2) {
3965
4033
  return ((1 << z) * y2 + x2) * 32 + z;
3966
4034
  }
3967
- return __toCommonJS(src_exports);
4035
+ return __toCommonJS(bundle_exports);
3968
4036
  })();
3969
4037
  /*! Bundled license information:
3970
4038