@loaders.gl/mvt 4.2.0 → 4.3.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 (108) hide show
  1. package/dist/dist.dev.js +1311 -767
  2. package/dist/dist.min.js +1 -1
  3. package/dist/geojson-tile-source.d.ts +79 -0
  4. package/dist/geojson-tile-source.d.ts.map +1 -0
  5. package/dist/{lib/geojson-tiler/geojson-tiler.js → geojson-tile-source.js} +137 -27
  6. package/dist/index.cjs +570 -560
  7. package/dist/index.cjs.map +4 -4
  8. package/dist/index.d.ts +2 -2
  9. package/dist/index.d.ts.map +1 -1
  10. package/dist/index.js +1 -1
  11. package/dist/lib/geojsonvt/clip.d.ts.map +1 -0
  12. package/dist/lib/geojsonvt/convert.d.ts +10 -0
  13. package/dist/lib/geojsonvt/convert.d.ts.map +1 -0
  14. package/dist/lib/geojsonvt/feature.d.ts.map +1 -0
  15. package/dist/lib/geojsonvt/simplify.d.ts.map +1 -0
  16. package/dist/lib/geojsonvt/tile.d.ts.map +1 -0
  17. package/dist/lib/geojsonvt/transform.d.ts.map +1 -0
  18. package/dist/lib/geojsonvt/wrap.d.ts.map +1 -0
  19. package/dist/lib/parse-mvt.d.ts +3 -2
  20. package/dist/lib/parse-mvt.d.ts.map +1 -1
  21. package/dist/lib/parse-mvt.js +13 -15
  22. package/dist/lib/types.d.ts +1 -39
  23. package/dist/lib/types.d.ts.map +1 -1
  24. package/dist/lib/utils/geometry-utils.d.ts +46 -0
  25. package/dist/lib/utils/geometry-utils.d.ts.map +1 -0
  26. package/dist/{helpers/binary-util-functions.js → lib/utils/geometry-utils.js} +79 -46
  27. package/dist/lib/{binary-vector-tile → vector-tile}/vector-tile-feature.d.ts +27 -15
  28. package/dist/lib/vector-tile/vector-tile-feature.d.ts.map +1 -0
  29. package/dist/lib/vector-tile/vector-tile-feature.js +345 -0
  30. package/dist/lib/{mapbox-vector-tile → vector-tile}/vector-tile-layer.d.ts +10 -1
  31. package/dist/lib/vector-tile/vector-tile-layer.d.ts.map +1 -0
  32. package/dist/lib/{mapbox-vector-tile → vector-tile}/vector-tile-layer.js +16 -1
  33. package/dist/lib/vector-tile/vector-tile.d.ts.map +1 -0
  34. package/dist/mvt-loader.d.ts +20 -9
  35. package/dist/mvt-loader.d.ts.map +1 -1
  36. package/dist/mvt-loader.js +3 -2
  37. package/dist/mvt-source.js +4 -4
  38. package/dist/mvt-worker.js +1172 -735
  39. package/dist/tilejson-loader.js +1 -1
  40. package/package.json +6 -6
  41. package/src/{lib/geojson-tiler/geojson-tiler.ts → geojson-tile-source.ts} +172 -33
  42. package/src/index.ts +3 -3
  43. package/src/lib/{geojson-tiler → geojsonvt}/convert.ts +2 -2
  44. package/src/lib/{geojson-tiler → geojsonvt}/tile.ts +2 -2
  45. package/src/lib/parse-mvt.ts +24 -33
  46. package/src/lib/types.ts +1 -39
  47. package/src/{helpers/binary-util-functions.ts → lib/utils/geometry-utils.ts} +92 -48
  48. package/src/lib/vector-tile/vector-tile-feature.ts +407 -0
  49. package/src/lib/{mapbox-vector-tile → vector-tile}/vector-tile-layer.ts +28 -2
  50. package/src/mvt-loader.ts +14 -6
  51. package/src/mvt-source.ts +4 -4
  52. package/dist/helpers/binary-util-functions.d.ts +0 -35
  53. package/dist/helpers/binary-util-functions.d.ts.map +0 -1
  54. package/dist/helpers/mapbox-util-functions.d.ts +0 -29
  55. package/dist/helpers/mapbox-util-functions.d.ts.map +0 -1
  56. package/dist/helpers/mapbox-util-functions.js +0 -78
  57. package/dist/lib/binary-vector-tile/vector-tile-feature.d.ts.map +0 -1
  58. package/dist/lib/binary-vector-tile/vector-tile-feature.js +0 -163
  59. package/dist/lib/binary-vector-tile/vector-tile-layer.d.ts +0 -23
  60. package/dist/lib/binary-vector-tile/vector-tile-layer.d.ts.map +0 -1
  61. package/dist/lib/binary-vector-tile/vector-tile-layer.js +0 -96
  62. package/dist/lib/binary-vector-tile/vector-tile.d.ts +0 -9
  63. package/dist/lib/binary-vector-tile/vector-tile.d.ts.map +0 -1
  64. package/dist/lib/binary-vector-tile/vector-tile.js +0 -27
  65. package/dist/lib/geojson-tiler/clip.d.ts.map +0 -1
  66. package/dist/lib/geojson-tiler/convert.d.ts +0 -10
  67. package/dist/lib/geojson-tiler/convert.d.ts.map +0 -1
  68. package/dist/lib/geojson-tiler/feature.d.ts.map +0 -1
  69. package/dist/lib/geojson-tiler/geojson-tiler.d.ts +0 -44
  70. package/dist/lib/geojson-tiler/geojson-tiler.d.ts.map +0 -1
  71. package/dist/lib/geojson-tiler/simplify.d.ts.map +0 -1
  72. package/dist/lib/geojson-tiler/tile.d.ts.map +0 -1
  73. package/dist/lib/geojson-tiler/transform.d.ts.map +0 -1
  74. package/dist/lib/geojson-tiler/wrap.d.ts.map +0 -1
  75. package/dist/lib/mapbox-vector-tile/vector-tile-feature.d.ts +0 -27
  76. package/dist/lib/mapbox-vector-tile/vector-tile-feature.d.ts.map +0 -1
  77. package/dist/lib/mapbox-vector-tile/vector-tile-feature.js +0 -178
  78. package/dist/lib/mapbox-vector-tile/vector-tile-layer.d.ts.map +0 -1
  79. package/dist/lib/mapbox-vector-tile/vector-tile.d.ts.map +0 -1
  80. package/src/helpers/mapbox-util-functions.ts +0 -82
  81. package/src/lib/binary-vector-tile/vector-tile-feature.ts +0 -203
  82. package/src/lib/binary-vector-tile/vector-tile-layer.ts +0 -113
  83. package/src/lib/binary-vector-tile/vector-tile.ts +0 -36
  84. package/src/lib/mapbox-vector-tile/LICENSE.txt +0 -31
  85. package/src/lib/mapbox-vector-tile/vector-tile-feature.ts +0 -207
  86. /package/dist/lib/{geojson-tiler → geojsonvt}/clip.d.ts +0 -0
  87. /package/dist/lib/{geojson-tiler → geojsonvt}/clip.js +0 -0
  88. /package/dist/lib/{geojson-tiler → geojsonvt}/convert.js +0 -0
  89. /package/dist/lib/{geojson-tiler → geojsonvt}/feature.d.ts +0 -0
  90. /package/dist/lib/{geojson-tiler → geojsonvt}/feature.js +0 -0
  91. /package/dist/lib/{geojson-tiler → geojsonvt}/simplify.d.ts +0 -0
  92. /package/dist/lib/{geojson-tiler → geojsonvt}/simplify.js +0 -0
  93. /package/dist/lib/{geojson-tiler → geojsonvt}/tile.d.ts +0 -0
  94. /package/dist/lib/{geojson-tiler → geojsonvt}/tile.js +0 -0
  95. /package/dist/lib/{geojson-tiler → geojsonvt}/transform.d.ts +0 -0
  96. /package/dist/lib/{geojson-tiler → geojsonvt}/transform.js +0 -0
  97. /package/dist/lib/{geojson-tiler → geojsonvt}/wrap.d.ts +0 -0
  98. /package/dist/lib/{geojson-tiler → geojsonvt}/wrap.js +0 -0
  99. /package/dist/lib/{mapbox-vector-tile → vector-tile}/vector-tile.d.ts +0 -0
  100. /package/dist/lib/{mapbox-vector-tile → vector-tile}/vector-tile.js +0 -0
  101. /package/src/lib/{geojson-tiler → geojsonvt}/LICENSE +0 -0
  102. /package/src/lib/{geojson-tiler → geojsonvt}/clip.ts +0 -0
  103. /package/src/lib/{geojson-tiler → geojsonvt}/feature.ts +0 -0
  104. /package/src/lib/{geojson-tiler → geojsonvt}/simplify.ts +0 -0
  105. /package/src/lib/{geojson-tiler → geojsonvt}/transform.ts +0 -0
  106. /package/src/lib/{geojson-tiler → geojsonvt}/wrap.ts +0 -0
  107. /package/src/lib/{binary-vector-tile → vector-tile}/LICENSE.txt +0 -0
  108. /package/src/lib/{mapbox-vector-tile → vector-tile}/vector-tile.ts +0 -0
package/dist/dist.dev.js CHANGED
@@ -12,6 +12,7 @@ var __exports__ = (() => {
12
12
  var __getOwnPropNames = Object.getOwnPropertyNames;
13
13
  var __getProtoOf = Object.getPrototypeOf;
14
14
  var __hasOwnProp = Object.prototype.hasOwnProperty;
15
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
15
16
  var __commonJS = (cb, mod) => function __require() {
16
17
  return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
17
18
  };
@@ -37,6 +38,10 @@ var __exports__ = (() => {
37
38
  mod
38
39
  ));
39
40
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
41
+ var __publicField = (obj, key, value) => {
42
+ __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
43
+ return value;
44
+ };
40
45
 
41
46
  // external-global-plugin:@loaders.gl/core
42
47
  var require_core = __commonJS({
@@ -54,19 +59,19 @@ var __exports__ = (() => {
54
59
  var eMax = (1 << eLen) - 1;
55
60
  var eBias = eMax >> 1;
56
61
  var nBits = -7;
57
- var i2 = isLE ? nBytes - 1 : 0;
62
+ var i = isLE ? nBytes - 1 : 0;
58
63
  var d = isLE ? -1 : 1;
59
- var s = buffer[offset + i2];
60
- i2 += d;
64
+ var s = buffer[offset + i];
65
+ i += d;
61
66
  e = s & (1 << -nBits) - 1;
62
67
  s >>= -nBits;
63
68
  nBits += eLen;
64
- for (; nBits > 0; e = e * 256 + buffer[offset + i2], i2 += d, nBits -= 8) {
69
+ for (; nBits > 0; e = e * 256 + buffer[offset + i], i += d, nBits -= 8) {
65
70
  }
66
71
  m = e & (1 << -nBits) - 1;
67
72
  e >>= -nBits;
68
73
  nBits += mLen;
69
- for (; nBits > 0; m = m * 256 + buffer[offset + i2], i2 += d, nBits -= 8) {
74
+ for (; nBits > 0; m = m * 256 + buffer[offset + i], i += d, nBits -= 8) {
70
75
  }
71
76
  if (e === 0) {
72
77
  e = 1 - eBias;
@@ -84,7 +89,7 @@ var __exports__ = (() => {
84
89
  var eMax = (1 << eLen) - 1;
85
90
  var eBias = eMax >> 1;
86
91
  var rt = mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0;
87
- var i2 = isLE ? 0 : nBytes - 1;
92
+ var i = isLE ? 0 : nBytes - 1;
88
93
  var d = isLE ? 1 : -1;
89
94
  var s = value < 0 || value === 0 && 1 / value < 0 ? 1 : 0;
90
95
  value = Math.abs(value);
@@ -117,13 +122,13 @@ var __exports__ = (() => {
117
122
  e = 0;
118
123
  }
119
124
  }
120
- for (; mLen >= 8; buffer[offset + i2] = m & 255, i2 += d, m /= 256, mLen -= 8) {
125
+ for (; mLen >= 8; buffer[offset + i] = m & 255, i += d, m /= 256, mLen -= 8) {
121
126
  }
122
127
  e = e << mLen | m;
123
128
  eLen += mLen;
124
- for (; eLen > 0; buffer[offset + i2] = e & 255, i2 += d, e /= 256, eLen -= 8) {
129
+ for (; eLen > 0; buffer[offset + i] = e & 255, i += d, e /= 256, eLen -= 8) {
125
130
  }
126
- buffer[offset + i2 - d] |= s * 128;
131
+ buffer[offset + i - d] |= s * 128;
127
132
  };
128
133
  }
129
134
  });
@@ -345,14 +350,14 @@ var __exports__ = (() => {
345
350
  this.writeVarint(tag << 3 | type);
346
351
  },
347
352
  realloc: function(min) {
348
- var length2 = this.length || 16;
349
- while (length2 < this.pos + min)
350
- length2 *= 2;
351
- if (length2 !== this.length) {
352
- var buf = new Uint8Array(length2);
353
+ var length = this.length || 16;
354
+ while (length < this.pos + min)
355
+ length *= 2;
356
+ if (length !== this.length) {
357
+ var buf = new Uint8Array(length);
353
358
  buf.set(this.buf);
354
359
  this.buf = buf;
355
- this.length = length2;
360
+ this.length = length;
356
361
  }
357
362
  },
358
363
  finish: function() {
@@ -433,8 +438,8 @@ var __exports__ = (() => {
433
438
  var len = buffer.length;
434
439
  this.writeVarint(len);
435
440
  this.realloc(len);
436
- for (var i2 = 0; i2 < len; i2++)
437
- this.buf[this.pos++] = buffer[i2];
441
+ for (var i = 0; i < len; i++)
442
+ this.buf[this.pos++] = buffer[i];
438
443
  },
439
444
  writeRawMessage: function(fn, obj) {
440
445
  this.pos++;
@@ -623,44 +628,44 @@ var __exports__ = (() => {
623
628
  function makeRoomForExtraLength(startPos, len, pbf) {
624
629
  var extraLen = len <= 16383 ? 1 : len <= 2097151 ? 2 : len <= 268435455 ? 3 : Math.floor(Math.log(len) / (Math.LN2 * 7));
625
630
  pbf.realloc(extraLen);
626
- for (var i2 = pbf.pos - 1; i2 >= startPos; i2--)
627
- pbf.buf[i2 + extraLen] = pbf.buf[i2];
631
+ for (var i = pbf.pos - 1; i >= startPos; i--)
632
+ pbf.buf[i + extraLen] = pbf.buf[i];
628
633
  }
629
634
  function writePackedVarint(arr, pbf) {
630
- for (var i2 = 0; i2 < arr.length; i2++)
631
- pbf.writeVarint(arr[i2]);
635
+ for (var i = 0; i < arr.length; i++)
636
+ pbf.writeVarint(arr[i]);
632
637
  }
633
638
  function writePackedSVarint(arr, pbf) {
634
- for (var i2 = 0; i2 < arr.length; i2++)
635
- pbf.writeSVarint(arr[i2]);
639
+ for (var i = 0; i < arr.length; i++)
640
+ pbf.writeSVarint(arr[i]);
636
641
  }
637
642
  function writePackedFloat(arr, pbf) {
638
- for (var i2 = 0; i2 < arr.length; i2++)
639
- pbf.writeFloat(arr[i2]);
643
+ for (var i = 0; i < arr.length; i++)
644
+ pbf.writeFloat(arr[i]);
640
645
  }
641
646
  function writePackedDouble(arr, pbf) {
642
- for (var i2 = 0; i2 < arr.length; i2++)
643
- pbf.writeDouble(arr[i2]);
647
+ for (var i = 0; i < arr.length; i++)
648
+ pbf.writeDouble(arr[i]);
644
649
  }
645
650
  function writePackedBoolean(arr, pbf) {
646
- for (var i2 = 0; i2 < arr.length; i2++)
647
- pbf.writeBoolean(arr[i2]);
651
+ for (var i = 0; i < arr.length; i++)
652
+ pbf.writeBoolean(arr[i]);
648
653
  }
649
654
  function writePackedFixed32(arr, pbf) {
650
- for (var i2 = 0; i2 < arr.length; i2++)
651
- pbf.writeFixed32(arr[i2]);
655
+ for (var i = 0; i < arr.length; i++)
656
+ pbf.writeFixed32(arr[i]);
652
657
  }
653
658
  function writePackedSFixed32(arr, pbf) {
654
- for (var i2 = 0; i2 < arr.length; i2++)
655
- pbf.writeSFixed32(arr[i2]);
659
+ for (var i = 0; i < arr.length; i++)
660
+ pbf.writeSFixed32(arr[i]);
656
661
  }
657
662
  function writePackedFixed64(arr, pbf) {
658
- for (var i2 = 0; i2 < arr.length; i2++)
659
- pbf.writeFixed64(arr[i2]);
663
+ for (var i = 0; i < arr.length; i++)
664
+ pbf.writeFixed64(arr[i]);
660
665
  }
661
666
  function writePackedSFixed64(arr, pbf) {
662
- for (var i2 = 0; i2 < arr.length; i2++)
663
- pbf.writeSFixed64(arr[i2]);
667
+ for (var i = 0; i < arr.length; i++)
668
+ pbf.writeSFixed64(arr[i]);
664
669
  }
665
670
  function readUInt32(buf, pos) {
666
671
  return (buf[pos] | buf[pos + 1] << 8 | buf[pos + 2] << 16) + buf[pos + 3] * 16777216;
@@ -676,12 +681,12 @@ var __exports__ = (() => {
676
681
  }
677
682
  function readUtf8(buf, pos, end) {
678
683
  var str = "";
679
- var i2 = pos;
680
- while (i2 < end) {
681
- var b0 = buf[i2];
684
+ var i = pos;
685
+ while (i < end) {
686
+ var b0 = buf[i];
682
687
  var c = null;
683
688
  var bytesPerSequence = b0 > 239 ? 4 : b0 > 223 ? 3 : b0 > 191 ? 2 : 1;
684
- if (i2 + bytesPerSequence > end)
689
+ if (i + bytesPerSequence > end)
685
690
  break;
686
691
  var b1, b2, b3;
687
692
  if (bytesPerSequence === 1) {
@@ -689,7 +694,7 @@ var __exports__ = (() => {
689
694
  c = b0;
690
695
  }
691
696
  } else if (bytesPerSequence === 2) {
692
- b1 = buf[i2 + 1];
697
+ b1 = buf[i + 1];
693
698
  if ((b1 & 192) === 128) {
694
699
  c = (b0 & 31) << 6 | b1 & 63;
695
700
  if (c <= 127) {
@@ -697,8 +702,8 @@ var __exports__ = (() => {
697
702
  }
698
703
  }
699
704
  } else if (bytesPerSequence === 3) {
700
- b1 = buf[i2 + 1];
701
- b2 = buf[i2 + 2];
705
+ b1 = buf[i + 1];
706
+ b2 = buf[i + 2];
702
707
  if ((b1 & 192) === 128 && (b2 & 192) === 128) {
703
708
  c = (b0 & 15) << 12 | (b1 & 63) << 6 | b2 & 63;
704
709
  if (c <= 2047 || c >= 55296 && c <= 57343) {
@@ -706,9 +711,9 @@ var __exports__ = (() => {
706
711
  }
707
712
  }
708
713
  } else if (bytesPerSequence === 4) {
709
- b1 = buf[i2 + 1];
710
- b2 = buf[i2 + 2];
711
- b3 = buf[i2 + 3];
714
+ b1 = buf[i + 1];
715
+ b2 = buf[i + 2];
716
+ b3 = buf[i + 3];
712
717
  if ((b1 & 192) === 128 && (b2 & 192) === 128 && (b3 & 192) === 128) {
713
718
  c = (b0 & 15) << 18 | (b1 & 63) << 12 | (b2 & 63) << 6 | b3 & 63;
714
719
  if (c <= 65535 || c >= 1114112) {
@@ -725,7 +730,7 @@ var __exports__ = (() => {
725
730
  c = 56320 | c & 1023;
726
731
  }
727
732
  str += String.fromCharCode(c);
728
- i2 += bytesPerSequence;
733
+ i += bytesPerSequence;
729
734
  }
730
735
  return str;
731
736
  }
@@ -733,8 +738,8 @@ var __exports__ = (() => {
733
738
  return utf8TextDecoder.decode(buf.subarray(pos, end));
734
739
  }
735
740
  function writeUtf8(buf, str, pos) {
736
- for (var i2 = 0, c, lead; i2 < str.length; i2++) {
737
- c = str.charCodeAt(i2);
741
+ for (var i = 0, c, lead; i < str.length; i++) {
742
+ c = str.charCodeAt(i);
738
743
  if (c > 55295 && c < 57344) {
739
744
  if (lead) {
740
745
  if (c < 56320) {
@@ -748,7 +753,7 @@ var __exports__ = (() => {
748
753
  lead = null;
749
754
  }
750
755
  } else {
751
- if (c > 56319 || i2 + 1 === str.length) {
756
+ if (c > 56319 || i + 1 === str.length) {
752
757
  buf[pos++] = 239;
753
758
  buf[pos++] = 191;
754
759
  buf[pos++] = 189;
@@ -788,7 +793,7 @@ var __exports__ = (() => {
788
793
  // bundle.ts
789
794
  var bundle_exports = {};
790
795
  __export(bundle_exports, {
791
- GeoJSONTiler: () => GeoJSONTiler,
796
+ GeoJSONTileSource: () => GeoJSONTileSource,
792
797
  MVTLoader: () => MVTLoader,
793
798
  MVTSource: () => MVTSource,
794
799
  MVTWorkerLoader: () => MVTWorkerLoader,
@@ -858,9 +863,9 @@ var __exports__ = (() => {
858
863
  let area2 = 0;
859
864
  const i0 = DimIndex[plane[0]];
860
865
  const i1 = DimIndex[plane[1]];
861
- for (let i2 = start, j = end - dim; i2 < end; i2 += dim) {
862
- area2 += (points[i2 + i0] - points[j + i0]) * (points[i2 + i1] + points[j + i1]);
863
- j = i2;
866
+ for (let i = start, j = end - dim; i < end; i += dim) {
867
+ area2 += (points[i + i0] - points[j + i0]) * (points[i + i1] + points[j + i1]);
868
+ j = i;
864
869
  }
865
870
  return area2 / 2;
866
871
  }
@@ -878,24 +883,24 @@ var __exports__ = (() => {
878
883
  let maxY;
879
884
  let minX;
880
885
  let minY;
881
- let x2;
882
- let y2;
886
+ let x;
887
+ let y;
883
888
  if (hasHoles)
884
889
  outerNode = eliminateHoles(positions, holeIndices, outerNode, dim, areas, plane);
885
890
  if (positions.length > 80 * dim) {
886
891
  minX = maxX = positions[0];
887
892
  minY = maxY = positions[1];
888
- for (let i2 = dim; i2 < outerLen; i2 += dim) {
889
- x2 = positions[i2];
890
- y2 = positions[i2 + 1];
891
- if (x2 < minX)
892
- minX = x2;
893
- if (y2 < minY)
894
- minY = y2;
895
- if (x2 > maxX)
896
- maxX = x2;
897
- if (y2 > maxY)
898
- maxY = y2;
893
+ for (let i = dim; i < outerLen; i += dim) {
894
+ x = positions[i];
895
+ y = positions[i + 1];
896
+ if (x < minX)
897
+ minX = x;
898
+ if (y < minY)
899
+ minY = y;
900
+ if (x > maxX)
901
+ maxX = x;
902
+ if (y > maxY)
903
+ maxY = y;
899
904
  }
900
905
  invSize = Math.max(maxX - minX, maxY - minY);
901
906
  invSize = invSize !== 0 ? 32767 / invSize : 0;
@@ -904,7 +909,7 @@ var __exports__ = (() => {
904
909
  return triangles;
905
910
  }
906
911
  function linkedList(data, start, end, dim, clockwise, area2, plane) {
907
- let i2;
912
+ let i;
908
913
  let last;
909
914
  if (area2 === void 0) {
910
915
  area2 = getPolygonSignedArea(data, {
@@ -917,11 +922,11 @@ var __exports__ = (() => {
917
922
  let i0 = DimIndex[plane[0]];
918
923
  let i1 = DimIndex[plane[1]];
919
924
  if (clockwise === area2 < 0) {
920
- for (i2 = start; i2 < end; i2 += dim)
921
- last = insertNode(i2, data[i2 + i0], data[i2 + i1], last);
925
+ for (i = start; i < end; i += dim)
926
+ last = insertNode(i, data[i + i0], data[i + i1], last);
922
927
  } else {
923
- for (i2 = end - dim; i2 >= start; i2 -= dim)
924
- last = insertNode(i2, data[i2 + i0], data[i2 + i1], last);
928
+ for (i = end - dim; i >= start; i -= dim)
929
+ last = insertNode(i, data[i + i0], data[i + i1], last);
925
930
  }
926
931
  if (last && equals(last, last.next)) {
927
932
  removeNode(last);
@@ -1085,22 +1090,22 @@ var __exports__ = (() => {
1085
1090
  }
1086
1091
  function eliminateHoles(data, holeIndices, outerNode, dim, areas, plane) {
1087
1092
  const queue = [];
1088
- let i2;
1093
+ let i;
1089
1094
  let len;
1090
1095
  let start;
1091
1096
  let end;
1092
1097
  let list;
1093
- for (i2 = 0, len = holeIndices.length; i2 < len; i2++) {
1094
- start = holeIndices[i2] * dim;
1095
- end = i2 < len - 1 ? holeIndices[i2 + 1] * dim : data.length;
1096
- list = linkedList(data, start, end, dim, false, areas && areas[i2 + 1], plane);
1098
+ for (i = 0, len = holeIndices.length; i < len; i++) {
1099
+ start = holeIndices[i] * dim;
1100
+ end = i < len - 1 ? holeIndices[i + 1] * dim : data.length;
1101
+ list = linkedList(data, start, end, dim, false, areas && areas[i + 1], plane);
1097
1102
  if (list === list.next)
1098
1103
  list.steiner = true;
1099
1104
  queue.push(getLeftmost(list));
1100
1105
  }
1101
1106
  queue.sort(compareX);
1102
- for (i2 = 0; i2 < queue.length; i2++) {
1103
- outerNode = eliminateHole(queue[i2], outerNode);
1107
+ for (i = 0; i < queue.length; i++) {
1108
+ outerNode = eliminateHole(queue[i], outerNode);
1104
1109
  }
1105
1110
  return outerNode;
1106
1111
  }
@@ -1124,11 +1129,11 @@ var __exports__ = (() => {
1124
1129
  let m;
1125
1130
  do {
1126
1131
  if (hy <= p.y && hy >= p.next.y && p.next.y !== p.y) {
1127
- const x2 = p.x + (hy - p.y) * (p.next.x - p.x) / (p.next.y - p.y);
1128
- if (x2 <= hx && x2 > qx) {
1129
- qx = x2;
1132
+ const x = p.x + (hy - p.y) * (p.next.x - p.x) / (p.next.y - p.y);
1133
+ if (x <= hx && x > qx) {
1134
+ qx = x;
1130
1135
  m = p.x < p.next.x ? p : p.next;
1131
- if (x2 === hx)
1136
+ if (x === hx)
1132
1137
  return m;
1133
1138
  }
1134
1139
  }
@@ -1172,7 +1177,7 @@ var __exports__ = (() => {
1172
1177
  }
1173
1178
  function sortLinked(list) {
1174
1179
  let e;
1175
- let i2;
1180
+ let i;
1176
1181
  let inSize = 1;
1177
1182
  let numMerges;
1178
1183
  let p;
@@ -1189,7 +1194,7 @@ var __exports__ = (() => {
1189
1194
  numMerges++;
1190
1195
  q = p;
1191
1196
  pSize = 0;
1192
- for (i2 = 0; i2 < inSize; i2++) {
1197
+ for (i = 0; i < inSize; i++) {
1193
1198
  pSize++;
1194
1199
  q = q.nextZ;
1195
1200
  if (!q)
@@ -1220,18 +1225,18 @@ var __exports__ = (() => {
1220
1225
  } while (numMerges > 1);
1221
1226
  return list;
1222
1227
  }
1223
- function zOrder(x2, y2, minX, minY, invSize) {
1224
- x2 = (x2 - minX) * invSize | 0;
1225
- y2 = (y2 - minY) * invSize | 0;
1226
- x2 = (x2 | x2 << 8) & 16711935;
1227
- x2 = (x2 | x2 << 4) & 252645135;
1228
- x2 = (x2 | x2 << 2) & 858993459;
1229
- x2 = (x2 | x2 << 1) & 1431655765;
1230
- y2 = (y2 | y2 << 8) & 16711935;
1231
- y2 = (y2 | y2 << 4) & 252645135;
1232
- y2 = (y2 | y2 << 2) & 858993459;
1233
- y2 = (y2 | y2 << 1) & 1431655765;
1234
- return x2 | y2 << 1;
1228
+ function zOrder(x, y, minX, minY, invSize) {
1229
+ x = (x - minX) * invSize | 0;
1230
+ y = (y - minY) * invSize | 0;
1231
+ x = (x | x << 8) & 16711935;
1232
+ x = (x | x << 4) & 252645135;
1233
+ x = (x | x << 2) & 858993459;
1234
+ x = (x | x << 1) & 1431655765;
1235
+ y = (y | y << 8) & 16711935;
1236
+ y = (y | y << 4) & 252645135;
1237
+ y = (y | y << 2) & 858993459;
1238
+ y = (y | y << 1) & 1431655765;
1239
+ return x | y << 1;
1235
1240
  }
1236
1241
  function getLeftmost(start) {
1237
1242
  let p = start;
@@ -1317,8 +1322,8 @@ var __exports__ = (() => {
1317
1322
  b2.prev = bp;
1318
1323
  return b2;
1319
1324
  }
1320
- function insertNode(i2, x2, y2, last) {
1321
- const p = new Vertex(i2, x2, y2);
1325
+ function insertNode(i, x, y, last) {
1326
+ const p = new Vertex(i, x, y);
1322
1327
  if (!last) {
1323
1328
  p.prev = p;
1324
1329
  p.next = p;
@@ -1339,7 +1344,7 @@ var __exports__ = (() => {
1339
1344
  p.nextZ.prevZ = p.prevZ;
1340
1345
  }
1341
1346
  var Vertex = class {
1342
- constructor(i2, x2, y2) {
1347
+ constructor(i, x, y) {
1343
1348
  _defineProperty(this, "i", void 0);
1344
1349
  _defineProperty(this, "x", void 0);
1345
1350
  _defineProperty(this, "y", void 0);
@@ -1349,9 +1354,9 @@ var __exports__ = (() => {
1349
1354
  _defineProperty(this, "prevZ", null);
1350
1355
  _defineProperty(this, "nextZ", null);
1351
1356
  _defineProperty(this, "steiner", false);
1352
- this.i = i2;
1353
- this.x = x2;
1354
- this.y = y2;
1357
+ this.i = i;
1358
+ this.x = x;
1359
+ this.y = y;
1355
1360
  }
1356
1361
  };
1357
1362
 
@@ -1520,9 +1525,9 @@ var __exports__ = (() => {
1520
1525
  indexMap.linePosition,
1521
1526
  indexMap.linePosition + nPositions
1522
1527
  );
1523
- for (let i2 = 0, il = geometry.indices.length; i2 < il; ++i2) {
1524
- const start = geometry.indices[i2];
1525
- const end = i2 === il - 1 ? geometry.data.length : geometry.indices[i2 + 1];
1528
+ for (let i = 0, il = geometry.indices.length; i < il; ++i) {
1529
+ const start = geometry.indices[i];
1530
+ const end = i === il - 1 ? geometry.data.length : geometry.indices[i + 1];
1526
1531
  lines.pathIndices[indexMap.linePath++] = indexMap.linePosition;
1527
1532
  indexMap.linePosition += (end - start) / coordLength;
1528
1533
  }
@@ -1547,12 +1552,12 @@ var __exports__ = (() => {
1547
1552
  const areas = geometry.areas[l];
1548
1553
  const indices = geometry.indices[l];
1549
1554
  const nextIndices = geometry.indices[l + 1];
1550
- for (let i2 = 0, il = indices.length; i2 < il; ++i2) {
1551
- const start = indices[i2];
1552
- const end = i2 === il - 1 ? (
1555
+ for (let i = 0, il = indices.length; i < il; ++i) {
1556
+ const start = indices[i];
1557
+ const end = i === il - 1 ? (
1553
1558
  // last line, so either read to:
1554
1559
  nextIndices === void 0 ? geometry.data.length : nextIndices[0]
1555
- ) : indices[i2 + 1];
1560
+ ) : indices[i + 1];
1556
1561
  polygons.primitivePolygonIndices[indexMap.polygonRing++] = indexMap.polygonPosition;
1557
1562
  indexMap.polygonPosition += (end - start) / coordLength;
1558
1563
  }
@@ -1619,11 +1624,11 @@ var __exports__ = (() => {
1619
1624
  }
1620
1625
  return binaryFeatures;
1621
1626
  }
1622
- function fillNumericProperties(object, properties, index, length2) {
1627
+ function fillNumericProperties(object, properties, index, length) {
1623
1628
  for (const numericPropName in object.numericProps) {
1624
1629
  if (numericPropName in properties) {
1625
1630
  const value = properties[numericPropName];
1626
- object.numericProps[numericPropName].fill(value, index, index + length2);
1631
+ object.numericProps[numericPropName].fill(value, index, index + length);
1627
1632
  }
1628
1633
  }
1629
1634
  }
@@ -1636,320 +1641,681 @@ var __exports__ = (() => {
1636
1641
  }
1637
1642
  return props;
1638
1643
  }
1639
- function deduceArrayType(x2, constructor) {
1640
- if (constructor === Array || !Number.isFinite(x2)) {
1644
+ function deduceArrayType(x, constructor) {
1645
+ if (constructor === Array || !Number.isFinite(x)) {
1641
1646
  return Array;
1642
1647
  }
1643
- return constructor === Float64Array || Math.fround(x2) !== x2 ? Float64Array : Float32Array;
1648
+ return constructor === Float64Array || Math.fround(x) !== x ? Float64Array : Float32Array;
1644
1649
  }
1645
1650
 
1646
- // src/lib/parse-mvt.ts
1647
- var import_pbf = __toESM(require_pbf(), 1);
1651
+ // ../loader-utils/src/lib/env-utils/assert.ts
1652
+ function assert(condition, message) {
1653
+ if (!condition) {
1654
+ throw new Error(message || "loader assertion failed.");
1655
+ }
1656
+ }
1648
1657
 
1649
- // src/helpers/mapbox-util-functions.ts
1650
- function classifyRings(rings) {
1651
- const len = rings.length;
1652
- if (len <= 1)
1653
- return [rings];
1654
- const polygons = [];
1655
- let polygon;
1656
- let ccw;
1657
- for (let i2 = 0; i2 < len; i2++) {
1658
- const area2 = signedArea(rings[i2]);
1659
- if (area2 === 0)
1660
- continue;
1661
- if (ccw === void 0)
1662
- ccw = area2 < 0;
1663
- if (ccw === area2 < 0) {
1664
- if (polygon)
1665
- polygons.push(polygon);
1666
- polygon = [rings[i2]];
1667
- } else if (polygon)
1668
- polygon.push(rings[i2]);
1658
+ // ../loader-utils/src/lib/env-utils/globals.ts
1659
+ var globals = {
1660
+ self: typeof self !== "undefined" && self,
1661
+ window: typeof window !== "undefined" && window,
1662
+ global: typeof global !== "undefined" && global,
1663
+ document: typeof document !== "undefined" && document
1664
+ };
1665
+ var self_ = globals.self || globals.window || globals.global || {};
1666
+ var window_ = globals.window || globals.self || globals.global || {};
1667
+ var global_ = globals.global || globals.self || globals.window || {};
1668
+ var document_ = globals.document || {};
1669
+ var isBrowser = (
1670
+ // @ts-ignore process does not exist on browser
1671
+ Boolean(typeof process !== "object" || String(process) !== "[object process]" || process.browser)
1672
+ );
1673
+ var matches = typeof process !== "undefined" && process.version && /v([0-9]*)/.exec(process.version);
1674
+ var nodeVersion = matches && parseFloat(matches[1]) || 0;
1675
+
1676
+ // ../../node_modules/@probe.gl/log/node_modules/@probe.gl/env/dist/lib/is-electron.js
1677
+ function isElectron(mockUserAgent) {
1678
+ if (typeof window !== "undefined" && typeof window.process === "object" && window.process.type === "renderer") {
1679
+ return true;
1669
1680
  }
1670
- if (polygon)
1671
- polygons.push(polygon);
1672
- return polygons;
1681
+ if (typeof process !== "undefined" && typeof process.versions === "object" && Boolean(process.versions["electron"])) {
1682
+ return true;
1683
+ }
1684
+ const realUserAgent = typeof navigator === "object" && typeof navigator.userAgent === "string" && navigator.userAgent;
1685
+ const userAgent = mockUserAgent || realUserAgent;
1686
+ if (userAgent && userAgent.indexOf("Electron") >= 0) {
1687
+ return true;
1688
+ }
1689
+ return false;
1673
1690
  }
1674
- function signedArea(ring) {
1675
- let sum = 0;
1676
- for (let i2 = 0, j = ring.length - 1, p1, p2; i2 < ring.length; j = i2++) {
1677
- p1 = ring[i2];
1678
- p2 = ring[j];
1679
- sum += (p2[0] - p1[0]) * (p1[1] + p2[1]);
1691
+
1692
+ // ../../node_modules/@probe.gl/log/node_modules/@probe.gl/env/dist/lib/is-browser.js
1693
+ function isBrowser2() {
1694
+ const isNode = typeof process === "object" && String(process) === "[object process]" && !process.browser;
1695
+ return !isNode || isElectron();
1696
+ }
1697
+
1698
+ // ../../node_modules/@probe.gl/log/node_modules/@probe.gl/env/dist/lib/globals.js
1699
+ var self_2 = globalThis.self || globalThis.window || globalThis.global;
1700
+ var window_2 = globalThis.window || globalThis.self || globalThis.global;
1701
+ var document_2 = globalThis.document || {};
1702
+ var process_ = globalThis.process || {};
1703
+ var console_ = globalThis.console;
1704
+ var navigator_ = globalThis.navigator || {};
1705
+
1706
+ // ../../node_modules/@probe.gl/log/node_modules/@probe.gl/env/dist/utils/globals.js
1707
+ var VERSION = typeof __VERSION__ !== "undefined" ? __VERSION__ : "untranspiled source";
1708
+ var isBrowser3 = isBrowser2();
1709
+
1710
+ // ../../node_modules/@probe.gl/log/dist/utils/local-storage.js
1711
+ function getStorage(type) {
1712
+ try {
1713
+ const storage = window[type];
1714
+ const x = "__storage_test__";
1715
+ storage.setItem(x, x);
1716
+ storage.removeItem(x);
1717
+ return storage;
1718
+ } catch (e) {
1719
+ return null;
1680
1720
  }
1681
- return sum;
1682
1721
  }
1683
- function readFeature(tag, feature, pbf) {
1684
- if (feature && pbf) {
1685
- if (tag === 1)
1686
- feature.id = pbf.readVarint();
1687
- else if (tag === 2)
1688
- readTag(pbf, feature);
1689
- else if (tag === 3)
1690
- feature.type = pbf.readVarint();
1691
- else if (tag === 4)
1692
- feature._geometry = pbf.pos;
1722
+ var LocalStorage = class {
1723
+ constructor(id, defaultConfig) {
1724
+ let type = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : "sessionStorage";
1725
+ _defineProperty(this, "storage", void 0);
1726
+ _defineProperty(this, "id", void 0);
1727
+ _defineProperty(this, "config", void 0);
1728
+ this.storage = getStorage(type);
1729
+ this.id = id;
1730
+ this.config = defaultConfig;
1731
+ this._loadConfiguration();
1732
+ }
1733
+ getConfiguration() {
1734
+ return this.config;
1735
+ }
1736
+ setConfiguration(configuration) {
1737
+ Object.assign(this.config, configuration);
1738
+ if (this.storage) {
1739
+ const serialized = JSON.stringify(this.config);
1740
+ this.storage.setItem(this.id, serialized);
1741
+ }
1742
+ }
1743
+ _loadConfiguration() {
1744
+ let configuration = {};
1745
+ if (this.storage) {
1746
+ const serializedConfiguration = this.storage.getItem(this.id);
1747
+ configuration = serializedConfiguration ? JSON.parse(serializedConfiguration) : {};
1748
+ }
1749
+ Object.assign(this.config, configuration);
1750
+ return this;
1751
+ }
1752
+ };
1753
+
1754
+ // ../../node_modules/@probe.gl/log/dist/utils/formatters.js
1755
+ function formatTime(ms) {
1756
+ let formatted;
1757
+ if (ms < 10) {
1758
+ formatted = "".concat(ms.toFixed(2), "ms");
1759
+ } else if (ms < 100) {
1760
+ formatted = "".concat(ms.toFixed(1), "ms");
1761
+ } else if (ms < 1e3) {
1762
+ formatted = "".concat(ms.toFixed(0), "ms");
1763
+ } else {
1764
+ formatted = "".concat((ms / 1e3).toFixed(2), "s");
1693
1765
  }
1766
+ return formatted;
1694
1767
  }
1695
- function readTag(pbf, feature) {
1696
- const end = pbf.readVarint() + pbf.pos;
1697
- while (pbf.pos < end) {
1698
- const key = feature._keys[pbf.readVarint()];
1699
- const value = feature._values[pbf.readVarint()];
1700
- feature.properties[key] = value;
1768
+ function leftPad(string) {
1769
+ let length = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 8;
1770
+ const padLength = Math.max(length - string.length, 0);
1771
+ return "".concat(" ".repeat(padLength)).concat(string);
1772
+ }
1773
+ function formatImage(image, message, scale) {
1774
+ let maxWidth = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : 600;
1775
+ const imageUrl = image.src.replace(/\(/g, "%28").replace(/\)/g, "%29");
1776
+ if (image.width > maxWidth) {
1777
+ scale = Math.min(scale, maxWidth / image.width);
1701
1778
  }
1779
+ const width = image.width * scale;
1780
+ const height = image.height * scale;
1781
+ const style = ["font-size:1px;", "padding:".concat(Math.floor(height / 2), "px ").concat(Math.floor(width / 2), "px;"), "line-height:".concat(height, "px;"), "background:url(".concat(imageUrl, ");"), "background-size:".concat(width, "px ").concat(height, "px;"), "color:transparent;"].join("");
1782
+ return ["".concat(message, " %c+"), style];
1702
1783
  }
1703
1784
 
1704
- // src/lib/mapbox-vector-tile/vector-tile-feature.ts
1705
- var VectorTileFeature = class {
1706
- properties;
1707
- extent;
1708
- type;
1709
- id;
1710
- _pbf;
1711
- _geometry;
1712
- _keys;
1713
- _values;
1714
- static get types() {
1715
- return ["Unknown", "Point", "LineString", "Polygon"];
1716
- }
1717
- constructor(pbf, end, extent, keys, values) {
1718
- this.properties = {};
1719
- this.extent = extent;
1720
- this.type = 0;
1721
- this.id = null;
1722
- this._pbf = pbf;
1723
- this._geometry = -1;
1724
- this._keys = keys;
1725
- this._values = values;
1726
- pbf.readFields(readFeature, this, end);
1785
+ // ../../node_modules/@probe.gl/log/dist/utils/color.js
1786
+ var COLOR;
1787
+ (function(COLOR2) {
1788
+ COLOR2[COLOR2["BLACK"] = 30] = "BLACK";
1789
+ COLOR2[COLOR2["RED"] = 31] = "RED";
1790
+ COLOR2[COLOR2["GREEN"] = 32] = "GREEN";
1791
+ COLOR2[COLOR2["YELLOW"] = 33] = "YELLOW";
1792
+ COLOR2[COLOR2["BLUE"] = 34] = "BLUE";
1793
+ COLOR2[COLOR2["MAGENTA"] = 35] = "MAGENTA";
1794
+ COLOR2[COLOR2["CYAN"] = 36] = "CYAN";
1795
+ COLOR2[COLOR2["WHITE"] = 37] = "WHITE";
1796
+ COLOR2[COLOR2["BRIGHT_BLACK"] = 90] = "BRIGHT_BLACK";
1797
+ COLOR2[COLOR2["BRIGHT_RED"] = 91] = "BRIGHT_RED";
1798
+ COLOR2[COLOR2["BRIGHT_GREEN"] = 92] = "BRIGHT_GREEN";
1799
+ COLOR2[COLOR2["BRIGHT_YELLOW"] = 93] = "BRIGHT_YELLOW";
1800
+ COLOR2[COLOR2["BRIGHT_BLUE"] = 94] = "BRIGHT_BLUE";
1801
+ COLOR2[COLOR2["BRIGHT_MAGENTA"] = 95] = "BRIGHT_MAGENTA";
1802
+ COLOR2[COLOR2["BRIGHT_CYAN"] = 96] = "BRIGHT_CYAN";
1803
+ COLOR2[COLOR2["BRIGHT_WHITE"] = 97] = "BRIGHT_WHITE";
1804
+ })(COLOR || (COLOR = {}));
1805
+ var BACKGROUND_INCREMENT = 10;
1806
+ function getColor(color) {
1807
+ if (typeof color !== "string") {
1808
+ return color;
1809
+ }
1810
+ color = color.toUpperCase();
1811
+ return COLOR[color] || COLOR.WHITE;
1812
+ }
1813
+ function addColor(string, color, background) {
1814
+ if (!isBrowser2 && typeof string === "string") {
1815
+ if (color) {
1816
+ const colorCode = getColor(color);
1817
+ string = "\x1B[".concat(colorCode, "m").concat(string, "\x1B[39m");
1818
+ }
1819
+ if (background) {
1820
+ const colorCode = getColor(background);
1821
+ string = "\x1B[".concat(colorCode + BACKGROUND_INCREMENT, "m").concat(string, "\x1B[49m");
1822
+ }
1727
1823
  }
1728
- // eslint-disable-next-line complexity, max-statements
1729
- loadGeometry() {
1730
- const pbf = this._pbf;
1731
- pbf.pos = this._geometry;
1732
- const end = pbf.readVarint() + pbf.pos;
1733
- let cmd2 = 1;
1734
- let length2 = 0;
1735
- let x2 = 0;
1736
- let y2 = 0;
1737
- const lines = [];
1738
- let line;
1739
- while (pbf.pos < end) {
1740
- if (length2 <= 0) {
1741
- const cmdLen2 = pbf.readVarint();
1742
- cmd2 = cmdLen2 & 7;
1743
- length2 = cmdLen2 >> 3;
1744
- }
1745
- length2--;
1746
- if (cmd2 === 1 || cmd2 === 2) {
1747
- x2 += pbf.readSVarint();
1748
- y2 += pbf.readSVarint();
1749
- if (cmd2 === 1) {
1750
- if (line)
1751
- lines.push(line);
1752
- line = [];
1753
- }
1754
- if (line)
1755
- line.push([x2, y2]);
1756
- } else if (cmd2 === 7) {
1757
- if (line) {
1758
- line.push(line[0].slice());
1759
- }
1760
- } else {
1761
- throw new Error(`unknown command ${cmd2}`);
1824
+ return string;
1825
+ }
1826
+
1827
+ // ../../node_modules/@probe.gl/log/dist/utils/autobind.js
1828
+ function autobind(obj) {
1829
+ let predefined = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : ["constructor"];
1830
+ const proto = Object.getPrototypeOf(obj);
1831
+ const propNames = Object.getOwnPropertyNames(proto);
1832
+ const object = obj;
1833
+ for (const key of propNames) {
1834
+ const value = object[key];
1835
+ if (typeof value === "function") {
1836
+ if (!predefined.find((name) => key === name)) {
1837
+ object[key] = value.bind(obj);
1762
1838
  }
1763
1839
  }
1764
- if (line)
1765
- lines.push(line);
1766
- return lines;
1767
1840
  }
1768
- // eslint-disable-next-line max-statements
1769
- bbox() {
1770
- const pbf = this._pbf;
1771
- pbf.pos = this._geometry;
1772
- const end = pbf.readVarint() + pbf.pos;
1773
- let cmd2 = 1;
1774
- let length2 = 0;
1775
- let x2 = 0;
1776
- let y2 = 0;
1777
- let x1 = Infinity;
1778
- let x22 = -Infinity;
1779
- let y1 = Infinity;
1780
- let y22 = -Infinity;
1781
- while (pbf.pos < end) {
1782
- if (length2 <= 0) {
1783
- const cmdLen2 = pbf.readVarint();
1784
- cmd2 = cmdLen2 & 7;
1785
- length2 = cmdLen2 >> 3;
1786
- }
1787
- length2--;
1788
- if (cmd2 === 1 || cmd2 === 2) {
1789
- x2 += pbf.readSVarint();
1790
- y2 += pbf.readSVarint();
1791
- if (x2 < x1)
1792
- x1 = x2;
1793
- if (x2 > x22)
1794
- x22 = x2;
1795
- if (y2 < y1)
1796
- y1 = y2;
1797
- if (y2 > y22)
1798
- y22 = y2;
1799
- } else if (cmd2 !== 7) {
1800
- throw new Error(`unknown command ${cmd2}`);
1801
- }
1841
+ }
1842
+
1843
+ // ../../node_modules/@probe.gl/log/dist/utils/assert.js
1844
+ function assert2(condition, message) {
1845
+ if (!condition) {
1846
+ throw new Error(message || "Assertion failed");
1847
+ }
1848
+ }
1849
+
1850
+ // ../../node_modules/@probe.gl/log/dist/utils/hi-res-timestamp.js
1851
+ function getHiResTimestamp() {
1852
+ let timestamp;
1853
+ if (isBrowser2() && window_2.performance) {
1854
+ var _window$performance, _window$performance$n;
1855
+ timestamp = window_2 === null || window_2 === void 0 ? void 0 : (_window$performance = window_2.performance) === null || _window$performance === void 0 ? void 0 : (_window$performance$n = _window$performance.now) === null || _window$performance$n === void 0 ? void 0 : _window$performance$n.call(_window$performance);
1856
+ } else if ("hrtime" in process_) {
1857
+ var _process$hrtime;
1858
+ const timeParts = process_ === null || process_ === void 0 ? void 0 : (_process$hrtime = process_.hrtime) === null || _process$hrtime === void 0 ? void 0 : _process$hrtime.call(process_);
1859
+ timestamp = timeParts[0] * 1e3 + timeParts[1] / 1e6;
1860
+ } else {
1861
+ timestamp = Date.now();
1862
+ }
1863
+ return timestamp;
1864
+ }
1865
+
1866
+ // ../../node_modules/@probe.gl/log/dist/log.js
1867
+ var originalConsole = {
1868
+ debug: isBrowser2() ? console.debug || console.log : console.log,
1869
+ log: console.log,
1870
+ info: console.info,
1871
+ warn: console.warn,
1872
+ error: console.error
1873
+ };
1874
+ var DEFAULT_LOG_CONFIGURATION = {
1875
+ enabled: true,
1876
+ level: 0
1877
+ };
1878
+ function noop() {
1879
+ }
1880
+ var cache = {};
1881
+ var ONCE = {
1882
+ once: true
1883
+ };
1884
+ var Log = class {
1885
+ constructor() {
1886
+ let {
1887
+ id
1888
+ } = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {
1889
+ id: ""
1890
+ };
1891
+ _defineProperty(this, "id", void 0);
1892
+ _defineProperty(this, "VERSION", VERSION);
1893
+ _defineProperty(this, "_startTs", getHiResTimestamp());
1894
+ _defineProperty(this, "_deltaTs", getHiResTimestamp());
1895
+ _defineProperty(this, "_storage", void 0);
1896
+ _defineProperty(this, "userData", {});
1897
+ _defineProperty(this, "LOG_THROTTLE_TIMEOUT", 0);
1898
+ this.id = id;
1899
+ this.userData = {};
1900
+ this._storage = new LocalStorage("__probe-".concat(this.id, "__"), DEFAULT_LOG_CONFIGURATION);
1901
+ this.timeStamp("".concat(this.id, " started"));
1902
+ autobind(this);
1903
+ Object.seal(this);
1904
+ }
1905
+ set level(newLevel) {
1906
+ this.setLevel(newLevel);
1907
+ }
1908
+ get level() {
1909
+ return this.getLevel();
1910
+ }
1911
+ isEnabled() {
1912
+ return this._storage.config.enabled;
1913
+ }
1914
+ getLevel() {
1915
+ return this._storage.config.level;
1916
+ }
1917
+ getTotal() {
1918
+ return Number((getHiResTimestamp() - this._startTs).toPrecision(10));
1919
+ }
1920
+ getDelta() {
1921
+ return Number((getHiResTimestamp() - this._deltaTs).toPrecision(10));
1922
+ }
1923
+ set priority(newPriority) {
1924
+ this.level = newPriority;
1925
+ }
1926
+ get priority() {
1927
+ return this.level;
1928
+ }
1929
+ getPriority() {
1930
+ return this.level;
1931
+ }
1932
+ enable() {
1933
+ let enabled = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : true;
1934
+ this._storage.setConfiguration({
1935
+ enabled
1936
+ });
1937
+ return this;
1938
+ }
1939
+ setLevel(level) {
1940
+ this._storage.setConfiguration({
1941
+ level
1942
+ });
1943
+ return this;
1944
+ }
1945
+ get(setting) {
1946
+ return this._storage.config[setting];
1947
+ }
1948
+ set(setting, value) {
1949
+ this._storage.setConfiguration({
1950
+ [setting]: value
1951
+ });
1952
+ }
1953
+ settings() {
1954
+ if (console.table) {
1955
+ console.table(this._storage.config);
1956
+ } else {
1957
+ console.log(this._storage.config);
1802
1958
  }
1803
- return [x1, y1, x22, y22];
1804
1959
  }
1805
- _toGeoJSON(transform) {
1806
- let coords = this.loadGeometry();
1807
- let type = VectorTileFeature.types[this.type];
1808
- let i2;
1809
- let j;
1810
- switch (this.type) {
1811
- case 1:
1812
- const points = [];
1813
- for (i2 = 0; i2 < coords.length; i2++) {
1814
- points[i2] = coords[i2][0];
1815
- }
1816
- coords = points;
1817
- transform(coords, this);
1818
- break;
1819
- case 2:
1820
- for (i2 = 0; i2 < coords.length; i2++) {
1821
- transform(coords[i2], this);
1822
- }
1823
- break;
1824
- case 3:
1825
- coords = classifyRings(coords);
1826
- for (i2 = 0; i2 < coords.length; i2++) {
1827
- for (j = 0; j < coords[i2].length; j++) {
1828
- transform(coords[i2][j], this);
1829
- }
1830
- }
1831
- break;
1960
+ assert(condition, message) {
1961
+ assert2(condition, message);
1962
+ }
1963
+ warn(message) {
1964
+ return this._getLogFunction(0, message, originalConsole.warn, arguments, ONCE);
1965
+ }
1966
+ error(message) {
1967
+ return this._getLogFunction(0, message, originalConsole.error, arguments);
1968
+ }
1969
+ deprecated(oldUsage, newUsage) {
1970
+ return this.warn("`".concat(oldUsage, "` is deprecated and will be removed in a later version. Use `").concat(newUsage, "` instead"));
1971
+ }
1972
+ removed(oldUsage, newUsage) {
1973
+ return this.error("`".concat(oldUsage, "` has been removed. Use `").concat(newUsage, "` instead"));
1974
+ }
1975
+ probe(logLevel, message) {
1976
+ return this._getLogFunction(logLevel, message, originalConsole.log, arguments, {
1977
+ time: true,
1978
+ once: true
1979
+ });
1980
+ }
1981
+ log(logLevel, message) {
1982
+ return this._getLogFunction(logLevel, message, originalConsole.debug, arguments);
1983
+ }
1984
+ info(logLevel, message) {
1985
+ return this._getLogFunction(logLevel, message, console.info, arguments);
1986
+ }
1987
+ once(logLevel, message) {
1988
+ return this._getLogFunction(logLevel, message, originalConsole.debug || originalConsole.info, arguments, ONCE);
1989
+ }
1990
+ table(logLevel, table, columns) {
1991
+ if (table) {
1992
+ return this._getLogFunction(logLevel, table, console.table || noop, columns && [columns], {
1993
+ tag: getTableHeader(table)
1994
+ });
1832
1995
  }
1833
- if (coords.length === 1) {
1834
- coords = coords[0];
1835
- } else {
1836
- type = `Multi${type}`;
1996
+ return noop;
1997
+ }
1998
+ image(_ref) {
1999
+ let {
2000
+ logLevel,
2001
+ priority,
2002
+ image,
2003
+ message = "",
2004
+ scale = 1
2005
+ } = _ref;
2006
+ if (!this._shouldLog(logLevel || priority)) {
2007
+ return noop;
1837
2008
  }
1838
- const result = {
1839
- type: "Feature",
1840
- geometry: {
1841
- type,
1842
- coordinates: coords
1843
- },
1844
- properties: this.properties
2009
+ return isBrowser2() ? logImageInBrowser({
2010
+ image,
2011
+ message,
2012
+ scale
2013
+ }) : logImageInNode({
2014
+ image,
2015
+ message,
2016
+ scale
2017
+ });
2018
+ }
2019
+ time(logLevel, message) {
2020
+ return this._getLogFunction(logLevel, message, console.time ? console.time : console.info);
2021
+ }
2022
+ timeEnd(logLevel, message) {
2023
+ return this._getLogFunction(logLevel, message, console.timeEnd ? console.timeEnd : console.info);
2024
+ }
2025
+ timeStamp(logLevel, message) {
2026
+ return this._getLogFunction(logLevel, message, console.timeStamp || noop);
2027
+ }
2028
+ group(logLevel, message) {
2029
+ let opts = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {
2030
+ collapsed: false
1845
2031
  };
1846
- if (this.id !== null) {
1847
- result.id = this.id;
2032
+ const options = normalizeArguments({
2033
+ logLevel,
2034
+ message,
2035
+ opts
2036
+ });
2037
+ const {
2038
+ collapsed
2039
+ } = opts;
2040
+ options.method = (collapsed ? console.groupCollapsed : console.group) || console.info;
2041
+ return this._getLogFunction(options);
2042
+ }
2043
+ groupCollapsed(logLevel, message) {
2044
+ let opts = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};
2045
+ return this.group(logLevel, message, Object.assign({}, opts, {
2046
+ collapsed: true
2047
+ }));
2048
+ }
2049
+ groupEnd(logLevel) {
2050
+ return this._getLogFunction(logLevel, "", console.groupEnd || noop);
2051
+ }
2052
+ withGroup(logLevel, message, func) {
2053
+ this.group(logLevel, message)();
2054
+ try {
2055
+ func();
2056
+ } finally {
2057
+ this.groupEnd(logLevel)();
1848
2058
  }
1849
- return result;
1850
2059
  }
1851
- toGeoJSON(options) {
1852
- if (typeof options === "function") {
1853
- return this._toGeoJSON(options);
2060
+ trace() {
2061
+ if (console.trace) {
2062
+ console.trace();
1854
2063
  }
1855
- const { x: x2, y: y2, z } = options;
1856
- const size = this.extent * Math.pow(2, z);
1857
- const x0 = this.extent * x2;
1858
- const y0 = this.extent * y2;
1859
- function project2(line) {
1860
- for (let j = 0; j < line.length; j++) {
1861
- const p = line[j];
1862
- p[0] = (p[0] + x0) * 360 / size - 180;
1863
- const y22 = 180 - (p[1] + y0) * 360 / size;
1864
- p[1] = 360 / Math.PI * Math.atan(Math.exp(y22 * Math.PI / 180)) - 90;
2064
+ }
2065
+ _shouldLog(logLevel) {
2066
+ return this.isEnabled() && this.getLevel() >= normalizeLogLevel(logLevel);
2067
+ }
2068
+ _getLogFunction(logLevel, message, method, args, opts) {
2069
+ if (this._shouldLog(logLevel)) {
2070
+ opts = normalizeArguments({
2071
+ logLevel,
2072
+ message,
2073
+ args,
2074
+ opts
2075
+ });
2076
+ method = method || opts.method;
2077
+ assert2(method);
2078
+ opts.total = this.getTotal();
2079
+ opts.delta = this.getDelta();
2080
+ this._deltaTs = getHiResTimestamp();
2081
+ const tag = opts.tag || opts.message;
2082
+ if (opts.once && tag) {
2083
+ if (!cache[tag]) {
2084
+ cache[tag] = getHiResTimestamp();
2085
+ } else {
2086
+ return noop;
2087
+ }
1865
2088
  }
2089
+ message = decorateMessage(this.id, opts.message, opts);
2090
+ return method.bind(console, message, ...opts.args);
1866
2091
  }
1867
- return this._toGeoJSON(project2);
2092
+ return noop;
1868
2093
  }
1869
2094
  };
2095
+ _defineProperty(Log, "VERSION", VERSION);
2096
+ function normalizeLogLevel(logLevel) {
2097
+ if (!logLevel) {
2098
+ return 0;
2099
+ }
2100
+ let resolvedLevel;
2101
+ switch (typeof logLevel) {
2102
+ case "number":
2103
+ resolvedLevel = logLevel;
2104
+ break;
2105
+ case "object":
2106
+ resolvedLevel = logLevel.logLevel || logLevel.priority || 0;
2107
+ break;
2108
+ default:
2109
+ return 0;
2110
+ }
2111
+ assert2(Number.isFinite(resolvedLevel) && resolvedLevel >= 0);
2112
+ return resolvedLevel;
2113
+ }
2114
+ function normalizeArguments(opts) {
2115
+ const {
2116
+ logLevel,
2117
+ message
2118
+ } = opts;
2119
+ opts.logLevel = normalizeLogLevel(logLevel);
2120
+ const args = opts.args ? Array.from(opts.args) : [];
2121
+ while (args.length && args.shift() !== message) {
2122
+ }
2123
+ switch (typeof logLevel) {
2124
+ case "string":
2125
+ case "function":
2126
+ if (message !== void 0) {
2127
+ args.unshift(message);
2128
+ }
2129
+ opts.message = logLevel;
2130
+ break;
2131
+ case "object":
2132
+ Object.assign(opts, logLevel);
2133
+ break;
2134
+ default:
2135
+ }
2136
+ if (typeof opts.message === "function") {
2137
+ opts.message = opts.message();
2138
+ }
2139
+ const messageType = typeof opts.message;
2140
+ assert2(messageType === "string" || messageType === "object");
2141
+ return Object.assign(opts, {
2142
+ args
2143
+ }, opts.opts);
2144
+ }
2145
+ function decorateMessage(id, message, opts) {
2146
+ if (typeof message === "string") {
2147
+ const time = opts.time ? leftPad(formatTime(opts.total)) : "";
2148
+ message = opts.time ? "".concat(id, ": ").concat(time, " ").concat(message) : "".concat(id, ": ").concat(message);
2149
+ message = addColor(message, opts.color, opts.background);
2150
+ }
2151
+ return message;
2152
+ }
2153
+ function logImageInNode(_ref2) {
2154
+ let {
2155
+ image,
2156
+ message = "",
2157
+ scale = 1
2158
+ } = _ref2;
2159
+ console.warn("removed");
2160
+ return noop;
2161
+ }
2162
+ function logImageInBrowser(_ref3) {
2163
+ let {
2164
+ image,
2165
+ message = "",
2166
+ scale = 1
2167
+ } = _ref3;
2168
+ if (typeof image === "string") {
2169
+ const img = new Image();
2170
+ img.onload = () => {
2171
+ const args = formatImage(img, message, scale);
2172
+ console.log(...args);
2173
+ };
2174
+ img.src = image;
2175
+ return noop;
2176
+ }
2177
+ const element = image.nodeName || "";
2178
+ if (element.toLowerCase() === "img") {
2179
+ console.log(...formatImage(image, message, scale));
2180
+ return noop;
2181
+ }
2182
+ if (element.toLowerCase() === "canvas") {
2183
+ const img = new Image();
2184
+ img.onload = () => console.log(...formatImage(img, message, scale));
2185
+ img.src = image.toDataURL();
2186
+ return noop;
2187
+ }
2188
+ return noop;
2189
+ }
2190
+ function getTableHeader(table) {
2191
+ for (const key in table) {
2192
+ for (const title in table[key]) {
2193
+ return title || "untitled";
2194
+ }
2195
+ }
2196
+ return "empty";
2197
+ }
1870
2198
 
1871
- // src/lib/mapbox-vector-tile/vector-tile-layer.ts
1872
- var VectorTileLayer = class {
1873
- version;
1874
- name;
1875
- extent;
1876
- length;
1877
- _pbf;
1878
- _keys;
1879
- _values;
1880
- _features;
1881
- constructor(pbf, end) {
1882
- this.version = 1;
1883
- this.name = "";
1884
- this.extent = 4096;
1885
- this.length = 0;
1886
- this._pbf = pbf;
1887
- this._keys = [];
1888
- this._values = [];
1889
- this._features = [];
1890
- pbf.readFields(readLayer, this, end);
1891
- this.length = this._features.length;
2199
+ // ../../node_modules/@probe.gl/log/dist/index.js
2200
+ var dist_default = new Log({
2201
+ id: "@probe.gl/log"
2202
+ });
2203
+
2204
+ // ../loader-utils/src/lib/log-utils/log.ts
2205
+ var VERSION2 = typeof __VERSION__ !== "undefined" ? __VERSION__ : "latest";
2206
+ var version = VERSION2[0] >= "0" && VERSION2[0] <= "9" ? `v${VERSION2}` : "";
2207
+ var log = new Log({ id: `loaders.gl ${version}` });
2208
+
2209
+ // ../loader-utils/src/lib/path-utils/file-aliases.ts
2210
+ var pathPrefix = "";
2211
+ var fileAliases = {};
2212
+ function resolvePath(filename) {
2213
+ for (const alias in fileAliases) {
2214
+ if (filename.startsWith(alias)) {
2215
+ const replacement = fileAliases[alias];
2216
+ filename = filename.replace(alias, replacement);
2217
+ }
2218
+ }
2219
+ if (!filename.startsWith("http://") && !filename.startsWith("https://")) {
2220
+ filename = `${pathPrefix}${filename}`;
2221
+ }
2222
+ return filename;
2223
+ }
2224
+
2225
+ // ../loader-utils/src/lib/sources/data-source.ts
2226
+ var DataSource = class {
2227
+ /** A resolved fetch function extracted from loadOptions prop */
2228
+ fetch;
2229
+ /** The actual load options, if calling a loaders.gl loader */
2230
+ loadOptions;
2231
+ _needsRefresh = true;
2232
+ props;
2233
+ constructor(props) {
2234
+ this.props = { ...props };
2235
+ this.loadOptions = { ...props.loadOptions };
2236
+ this.fetch = getFetchFunction(this.loadOptions);
2237
+ }
2238
+ setProps(props) {
2239
+ this.props = Object.assign(this.props, props);
2240
+ this.setNeedsRefresh();
2241
+ }
2242
+ /** Mark this data source as needing a refresh (redraw) */
2243
+ setNeedsRefresh() {
2244
+ this._needsRefresh = true;
1892
2245
  }
1893
2246
  /**
1894
- * return feature `i` from this layer as a `VectorTileFeature`
1895
- * @param index
1896
- * @returns feature
2247
+ * Does this data source need refreshing?
2248
+ * @note The specifics of the refresh mechanism depends on type of data source
1897
2249
  */
1898
- feature(i2) {
1899
- if (i2 < 0 || i2 >= this._features.length) {
1900
- throw new Error("feature index out of bounds");
2250
+ getNeedsRefresh(clear = true) {
2251
+ const needsRefresh = this._needsRefresh;
2252
+ if (clear) {
2253
+ this._needsRefresh = false;
1901
2254
  }
1902
- this._pbf.pos = this._features[i2];
1903
- const end = this._pbf.readVarint() + this._pbf.pos;
1904
- return new VectorTileFeature(this._pbf, end, this.extent, this._keys, this._values);
2255
+ return needsRefresh;
1905
2256
  }
1906
2257
  };
1907
- function readLayer(tag, layer, pbf) {
1908
- if (layer && pbf) {
1909
- if (tag === 15)
1910
- layer.version = pbf.readVarint();
1911
- else if (tag === 1)
1912
- layer.name = pbf.readString();
1913
- else if (tag === 5)
1914
- layer.extent = pbf.readVarint();
1915
- else if (tag === 2)
1916
- layer._features.push(pbf.pos);
1917
- else if (tag === 3)
1918
- layer._keys.push(pbf.readString());
1919
- else if (tag === 4)
1920
- layer._values.push(readValueMessage(pbf));
2258
+ function getFetchFunction(options) {
2259
+ const fetchFunction = options?.fetch;
2260
+ if (fetchFunction && typeof fetchFunction === "function") {
2261
+ return (url, fetchOptions2) => fetchFunction(url, fetchOptions2);
1921
2262
  }
1922
- }
1923
- function readValueMessage(pbf) {
1924
- let value = null;
1925
- const end = pbf.readVarint() + pbf.pos;
1926
- while (pbf.pos < end) {
1927
- const tag = pbf.readVarint() >> 3;
1928
- value = tag === 1 ? pbf.readString() : tag === 2 ? pbf.readFloat() : tag === 3 ? pbf.readDouble() : tag === 4 ? pbf.readVarint64() : tag === 5 ? pbf.readVarint() : tag === 6 ? pbf.readSVarint() : tag === 7 ? pbf.readBoolean() : null;
2263
+ const fetchOptions = options?.fetch;
2264
+ if (fetchOptions && typeof fetchOptions !== "function") {
2265
+ return (url) => fetch(url, fetchOptions);
1929
2266
  }
1930
- return value;
2267
+ return (url) => fetch(url);
1931
2268
  }
1932
2269
 
1933
- // src/lib/mapbox-vector-tile/vector-tile.ts
1934
- var VectorTile = class {
1935
- layers;
1936
- constructor(pbf, end) {
1937
- this.layers = pbf.readFields(readTile, {}, end);
2270
+ // src/lib/parse-mvt.ts
2271
+ var import_pbf = __toESM(require_pbf(), 1);
2272
+
2273
+ // src/lib/utils/geometry-utils.ts
2274
+ function signedArea(ring) {
2275
+ let sum = 0;
2276
+ for (let i = 0, j = ring.length - 1, p1, p2; i < ring.length; j = i++) {
2277
+ p1 = ring[i];
2278
+ p2 = ring[j];
2279
+ sum += (p2[0] - p1[0]) * (p1[1] + p2[1]);
1938
2280
  }
1939
- };
1940
- function readTile(tag, layers, pbf) {
1941
- if (tag === 3) {
1942
- if (pbf) {
1943
- const layer = new VectorTileLayer(pbf, pbf.readVarint() + pbf.pos);
1944
- if (layer.length && layers) {
1945
- layers[layer.name] = layer;
1946
- }
1947
- }
2281
+ return sum;
2282
+ }
2283
+ function projectToLngLatFlat(data, tileIndex, extent) {
2284
+ const { x, y, z } = tileIndex;
2285
+ const size = extent * Math.pow(2, z);
2286
+ const x0 = extent * x;
2287
+ const y0 = extent * y;
2288
+ for (let j = 0, jl = data.length; j < jl; j += 2) {
2289
+ data[j] = (data[j] + x0) * 360 / size - 180;
2290
+ const y2 = 180 - (data[j + 1] + y0) * 360 / size;
2291
+ data[j + 1] = 360 / Math.PI * Math.atan(Math.exp(y2 * Math.PI / 180)) - 90;
1948
2292
  }
1949
2293
  }
1950
-
1951
- // src/helpers/binary-util-functions.ts
1952
- function classifyRings2(geom) {
2294
+ function classifyRings(rings) {
2295
+ const len = rings.length;
2296
+ if (len <= 1)
2297
+ return [rings];
2298
+ const polygons = [];
2299
+ let polygon;
2300
+ let ccw;
2301
+ for (let i = 0; i < len; i++) {
2302
+ const area2 = signedArea(rings[i]);
2303
+ if (area2 === 0)
2304
+ continue;
2305
+ if (ccw === void 0)
2306
+ ccw = area2 < 0;
2307
+ if (ccw === area2 < 0) {
2308
+ if (polygon)
2309
+ polygons.push(polygon);
2310
+ polygon = [rings[i]];
2311
+ } else if (polygon)
2312
+ polygon.push(rings[i]);
2313
+ }
2314
+ if (polygon)
2315
+ polygons.push(polygon);
2316
+ return polygons;
2317
+ }
2318
+ function classifyRingsFlat(geom) {
1953
2319
  const len = geom.indices.length;
1954
2320
  const type = "Polygon";
1955
2321
  if (len <= 1) {
@@ -1966,9 +2332,9 @@ var __exports__ = (() => {
1966
2332
  let polygon = [];
1967
2333
  let ccw;
1968
2334
  let offset = 0;
1969
- for (let endIndex, i2 = 0, startIndex; i2 < len; i2++) {
1970
- startIndex = geom.indices[i2] - offset;
1971
- endIndex = geom.indices[i2 + 1] - offset || geom.data.length;
2335
+ for (let endIndex, i = 0, startIndex; i < len; i++) {
2336
+ startIndex = geom.indices[i] - offset;
2337
+ endIndex = geom.indices[i + 1] - offset || geom.data.length;
1972
2338
  const shape = geom.data.slice(startIndex, endIndex);
1973
2339
  const area2 = getPolygonSignedArea(shape);
1974
2340
  if (area2 === 0) {
@@ -1998,43 +2364,9 @@ var __exports__ = (() => {
1998
2364
  polygons.push(polygon);
1999
2365
  return { type, areas, indices: polygons, data: geom.data };
2000
2366
  }
2001
- function project(data, x0, y0, size) {
2002
- for (let j = 0, jl = data.length; j < jl; j += 2) {
2003
- data[j] = (data[j] + x0) * 360 / size - 180;
2004
- const y2 = 180 - (data[j + 1] + y0) * 360 / size;
2005
- data[j + 1] = 360 / Math.PI * Math.atan(Math.exp(y2 * Math.PI / 180)) - 90;
2006
- }
2007
- }
2008
- function readFeature2(tag, feature, pbf) {
2009
- if (feature && pbf) {
2010
- if (tag === 1)
2011
- feature.id = pbf.readVarint();
2012
- else if (tag === 2)
2013
- readTag2(pbf, feature);
2014
- else if (tag === 3)
2015
- feature.type = pbf.readVarint();
2016
- else if (tag === 4)
2017
- feature._geometry = pbf.pos;
2018
- }
2019
- }
2020
- function readTag2(pbf, feature) {
2021
- const end = pbf.readVarint() + pbf.pos;
2022
- while (pbf.pos < end) {
2023
- const key = feature._keys[pbf.readVarint()];
2024
- const value = feature._values[pbf.readVarint()];
2025
- feature.properties[key] = value;
2026
- }
2027
- }
2028
2367
 
2029
- // src/lib/binary-vector-tile/vector-tile-feature.ts
2030
- var endPos;
2031
- var cmd;
2032
- var cmdLen;
2033
- var length;
2034
- var x;
2035
- var y;
2036
- var i;
2037
- var BinaryVectorTileFeature = class {
2368
+ // src/lib/vector-tile/vector-tile-feature.ts
2369
+ var VectorTileFeature = class {
2038
2370
  properties;
2039
2371
  extent;
2040
2372
  type;
@@ -2055,23 +2387,57 @@ var __exports__ = (() => {
2055
2387
  this._keys = keys;
2056
2388
  this._values = values;
2057
2389
  this._geometryInfo = geometryInfo;
2058
- pbf.readFields(readFeature2, this, end);
2390
+ pbf.readFields(readFeature, this, end);
2059
2391
  }
2060
- // eslint-disable-next-line complexity, max-statements
2061
- loadGeometry() {
2392
+ toGeoJSON(options) {
2393
+ const coords = this.loadGeometry();
2394
+ if (typeof options === "function") {
2395
+ return _toGeoJSON(this, coords, options);
2396
+ }
2397
+ const { x, y, z } = options;
2398
+ const size = this.extent * Math.pow(2, z);
2399
+ const x0 = this.extent * x;
2400
+ const y0 = this.extent * y;
2401
+ function project(line) {
2402
+ for (let j = 0; j < line.length; j++) {
2403
+ const p = line[j];
2404
+ p[0] = (p[0] + x0) * 360 / size - 180;
2405
+ const y2 = 180 - (p[1] + y0) * 360 / size;
2406
+ p[1] = 360 / Math.PI * Math.atan(Math.exp(y2 * Math.PI / 180)) - 90;
2407
+ }
2408
+ }
2409
+ return _toGeoJSON(this, coords, project);
2410
+ }
2411
+ /**
2412
+ *
2413
+ * @param options
2414
+ * @returns
2415
+ */
2416
+ toBinaryCoordinates(options) {
2417
+ if (typeof options === "function") {
2418
+ return this._toBinaryCoordinates(options);
2419
+ }
2420
+ const tileIndex = options;
2421
+ return this._toBinaryCoordinates(
2422
+ (data) => projectToLngLatFlat(data, tileIndex, this.extent)
2423
+ );
2424
+ }
2425
+ // eslint-disable-next-line max-statements
2426
+ bbox() {
2062
2427
  const pbf = this._pbf;
2063
2428
  pbf.pos = this._geometry;
2064
- endPos = pbf.readVarint() + pbf.pos;
2065
- cmd = 1;
2066
- length = 0;
2067
- x = 0;
2068
- y = 0;
2069
- i = 0;
2070
- const indices = [];
2071
- const data = [];
2072
- while (pbf.pos < endPos) {
2429
+ const end = pbf.readVarint() + pbf.pos;
2430
+ let cmd = 1;
2431
+ let length = 0;
2432
+ let x = 0;
2433
+ let y = 0;
2434
+ let x1 = Infinity;
2435
+ let x2 = -Infinity;
2436
+ let y1 = Infinity;
2437
+ let y2 = -Infinity;
2438
+ while (pbf.pos < end) {
2073
2439
  if (length <= 0) {
2074
- cmdLen = pbf.readVarint();
2440
+ const cmdLen = pbf.readVarint();
2075
2441
  cmd = cmdLen & 7;
2076
2442
  length = cmdLen >> 3;
2077
2443
  }
@@ -2079,30 +2445,28 @@ var __exports__ = (() => {
2079
2445
  if (cmd === 1 || cmd === 2) {
2080
2446
  x += pbf.readSVarint();
2081
2447
  y += pbf.readSVarint();
2082
- if (cmd === 1) {
2083
- indices.push(i);
2084
- }
2085
- data.push(x, y);
2086
- i += 2;
2087
- } else if (cmd === 7) {
2088
- if (i > 0) {
2089
- const start = indices[indices.length - 1];
2090
- data.push(data[start], data[start + 1]);
2091
- i += 2;
2092
- }
2093
- } else {
2448
+ if (x < x1)
2449
+ x1 = x;
2450
+ if (x > x2)
2451
+ x2 = x;
2452
+ if (y < y1)
2453
+ y1 = y;
2454
+ if (y > y2)
2455
+ y2 = y;
2456
+ } else if (cmd !== 7) {
2094
2457
  throw new Error(`unknown command ${cmd}`);
2095
2458
  }
2096
2459
  }
2097
- return { data, indices };
2460
+ return [x1, y1, x2, y2];
2098
2461
  }
2462
+ // BINARY HELPERS
2099
2463
  /**
2100
2464
  *
2101
2465
  * @param transform
2102
2466
  * @returns result
2103
2467
  */
2104
2468
  _toBinaryCoordinates(transform) {
2105
- const geom = this.loadGeometry();
2469
+ const geom = this.loadFlatGeometry();
2106
2470
  let geometry;
2107
2471
  transform(geom.data, this);
2108
2472
  const coordLength = 2;
@@ -2119,37 +2483,182 @@ var __exports__ = (() => {
2119
2483
  geometry = { type: "LineString", ...geom };
2120
2484
  break;
2121
2485
  case 3:
2122
- geometry = classifyRings2(geom);
2486
+ geometry = classifyRingsFlat(geom);
2123
2487
  this._geometryInfo.polygonFeaturesCount++;
2124
2488
  this._geometryInfo.polygonObjectsCount += geometry.indices.length;
2125
2489
  for (const indices of geometry.indices) {
2126
2490
  this._geometryInfo.polygonRingsCount += indices.length;
2127
2491
  }
2128
- this._geometryInfo.polygonPositionsCount += geometry.data.length / coordLength;
2129
- break;
2130
- default:
2131
- throw new Error(`Invalid geometry type: ${this.type}`);
2132
- }
2133
- const result = { type: "Feature", geometry, properties: this.properties };
2134
- if (this.id !== null) {
2135
- result.id = this.id;
2136
- }
2137
- return result;
2138
- }
2139
- toBinaryCoordinates(options) {
2140
- if (typeof options === "function") {
2141
- return this._toBinaryCoordinates(options);
2492
+ this._geometryInfo.polygonPositionsCount += geometry.data.length / coordLength;
2493
+ break;
2494
+ default:
2495
+ throw new Error(`Invalid geometry type: ${this.type}`);
2496
+ }
2497
+ const result = { type: "Feature", geometry, properties: this.properties };
2498
+ if (this.id !== null) {
2499
+ result.id = this.id;
2500
+ }
2501
+ return result;
2502
+ }
2503
+ // GEOJSON HELPER
2504
+ // eslint-disable-next-line complexity, max-statements
2505
+ loadGeometry() {
2506
+ const pbf = this._pbf;
2507
+ pbf.pos = this._geometry;
2508
+ const end = pbf.readVarint() + pbf.pos;
2509
+ let cmd = 1;
2510
+ let length = 0;
2511
+ let x = 0;
2512
+ let y = 0;
2513
+ const lines = [];
2514
+ let line;
2515
+ while (pbf.pos < end) {
2516
+ if (length <= 0) {
2517
+ const cmdLen = pbf.readVarint();
2518
+ cmd = cmdLen & 7;
2519
+ length = cmdLen >> 3;
2520
+ }
2521
+ length--;
2522
+ switch (cmd) {
2523
+ case 1:
2524
+ case 2:
2525
+ x += pbf.readSVarint();
2526
+ y += pbf.readSVarint();
2527
+ if (cmd === 1) {
2528
+ if (line)
2529
+ lines.push(line);
2530
+ line = [];
2531
+ }
2532
+ if (line)
2533
+ line.push([x, y]);
2534
+ break;
2535
+ case 7:
2536
+ if (line) {
2537
+ line.push(line[0].slice());
2538
+ }
2539
+ break;
2540
+ default:
2541
+ throw new Error(`unknown command ${cmd}`);
2542
+ }
2543
+ }
2544
+ if (line)
2545
+ lines.push(line);
2546
+ return lines;
2547
+ }
2548
+ // eslint-disable-next-line complexity, max-statements
2549
+ loadFlatGeometry() {
2550
+ const pbf = this._pbf;
2551
+ pbf.pos = this._geometry;
2552
+ const endPos = pbf.readVarint() + pbf.pos;
2553
+ let cmd = 1;
2554
+ let cmdLen;
2555
+ let length = 0;
2556
+ let x = 0;
2557
+ let y = 0;
2558
+ let i = 0;
2559
+ const indices = [];
2560
+ const data = [];
2561
+ while (pbf.pos < endPos) {
2562
+ if (length <= 0) {
2563
+ cmdLen = pbf.readVarint();
2564
+ cmd = cmdLen & 7;
2565
+ length = cmdLen >> 3;
2566
+ }
2567
+ length--;
2568
+ if (cmd === 1 || cmd === 2) {
2569
+ x += pbf.readSVarint();
2570
+ y += pbf.readSVarint();
2571
+ if (cmd === 1) {
2572
+ indices.push(i);
2573
+ }
2574
+ data.push(x, y);
2575
+ i += 2;
2576
+ } else if (cmd === 7) {
2577
+ if (i > 0) {
2578
+ const start = indices[indices.length - 1];
2579
+ data.push(data[start], data[start + 1]);
2580
+ i += 2;
2581
+ }
2582
+ } else {
2583
+ throw new Error(`unknown command ${cmd}`);
2584
+ }
2142
2585
  }
2143
- const { x: x2, y: y2, z } = options;
2144
- const size = this.extent * Math.pow(2, z);
2145
- const x0 = this.extent * x2;
2146
- const y0 = this.extent * y2;
2147
- return this._toBinaryCoordinates((data) => project(data, x0, y0, size));
2586
+ return { data, indices };
2148
2587
  }
2149
2588
  };
2589
+ __publicField(VectorTileFeature, "types", ["Unknown", "Point", "LineString", "Polygon"]);
2590
+ function _toGeoJSON(vtFeature, coords, transform) {
2591
+ let type = VectorTileFeature.types[vtFeature.type];
2592
+ let i;
2593
+ let j;
2594
+ let coordinates;
2595
+ switch (vtFeature.type) {
2596
+ case 1:
2597
+ const points = [];
2598
+ for (i = 0; i < coords.length; i++) {
2599
+ points[i] = coords[i][0];
2600
+ }
2601
+ coordinates = points;
2602
+ transform(coordinates, vtFeature);
2603
+ break;
2604
+ case 2:
2605
+ coordinates = coords;
2606
+ for (i = 0; i < coordinates.length; i++) {
2607
+ transform(coordinates[i], vtFeature);
2608
+ }
2609
+ break;
2610
+ case 3:
2611
+ coordinates = classifyRings(coords);
2612
+ for (i = 0; i < coordinates.length; i++) {
2613
+ for (j = 0; j < coordinates[i].length; j++) {
2614
+ transform(coordinates[i][j], vtFeature);
2615
+ }
2616
+ }
2617
+ break;
2618
+ default:
2619
+ throw new Error("illegal vector tile type");
2620
+ }
2621
+ if (coordinates.length === 1) {
2622
+ coordinates = coordinates[0];
2623
+ } else {
2624
+ type = `Multi${type}`;
2625
+ }
2626
+ const result = {
2627
+ type: "Feature",
2628
+ geometry: {
2629
+ type,
2630
+ coordinates
2631
+ },
2632
+ properties: vtFeature.properties
2633
+ };
2634
+ if (vtFeature.id !== null) {
2635
+ result.id = vtFeature.id;
2636
+ }
2637
+ return result;
2638
+ }
2639
+ function readFeature(tag, feature, pbf) {
2640
+ if (feature && pbf) {
2641
+ if (tag === 1)
2642
+ feature.id = pbf.readVarint();
2643
+ else if (tag === 2)
2644
+ readTag(pbf, feature);
2645
+ else if (tag === 3)
2646
+ feature.type = pbf.readVarint();
2647
+ else if (tag === 4)
2648
+ feature._geometry = pbf.pos;
2649
+ }
2650
+ }
2651
+ function readTag(pbf, feature) {
2652
+ const end = pbf.readVarint() + pbf.pos;
2653
+ while (pbf.pos < end) {
2654
+ const key = feature._keys[pbf.readVarint()];
2655
+ const value = feature._values[pbf.readVarint()];
2656
+ feature.properties[key] = value;
2657
+ }
2658
+ }
2150
2659
 
2151
- // src/lib/binary-vector-tile/vector-tile-layer.ts
2152
- var BinaryVectorTileLayer = class {
2660
+ // src/lib/vector-tile/vector-tile-layer.ts
2661
+ var VectorTileLayer = class {
2153
2662
  version;
2154
2663
  name;
2155
2664
  extent;
@@ -2167,23 +2676,36 @@ var __exports__ = (() => {
2167
2676
  this._keys = [];
2168
2677
  this._values = [];
2169
2678
  this._features = [];
2170
- pbf.readFields(readLayer2, this, end);
2679
+ pbf.readFields(readLayer, this, end);
2171
2680
  this.length = this._features.length;
2172
2681
  }
2173
2682
  /**
2174
- * return feature `i` from this layer as a `BinaryVectorTileFeature`
2683
+ * return feature `i` from this layer as a `VectorTileFeature`
2684
+ * @param index
2685
+ * @returns feature
2686
+ */
2687
+ getGeoJSONFeature(i) {
2688
+ if (i < 0 || i >= this._features.length) {
2689
+ throw new Error("feature index out of bounds");
2690
+ }
2691
+ this._pbf.pos = this._features[i];
2692
+ const end = this._pbf.readVarint() + this._pbf.pos;
2693
+ return new VectorTileFeature(this._pbf, end, this.extent, this._keys, this._values);
2694
+ }
2695
+ /**
2696
+ * return binary feature `i` from this layer as a `VectorTileFeature`
2175
2697
  *
2176
2698
  * @param index
2177
2699
  * @param geometryInfo
2178
- * @returns {BinaryVectorTileFeature}
2700
+ * @returns binary feature
2179
2701
  */
2180
- feature(i2, geometryInfo) {
2181
- if (i2 < 0 || i2 >= this._features.length) {
2702
+ getBinaryFeature(i, geometryInfo) {
2703
+ if (i < 0 || i >= this._features.length) {
2182
2704
  throw new Error("feature index out of bounds");
2183
2705
  }
2184
- this._pbf.pos = this._features[i2];
2706
+ this._pbf.pos = this._features[i];
2185
2707
  const end = this._pbf.readVarint() + this._pbf.pos;
2186
- return new BinaryVectorTileFeature(
2708
+ return new VectorTileFeature(
2187
2709
  this._pbf,
2188
2710
  end,
2189
2711
  this.extent,
@@ -2193,7 +2715,7 @@ var __exports__ = (() => {
2193
2715
  );
2194
2716
  }
2195
2717
  };
2196
- function readLayer2(tag, layer, pbf) {
2718
+ function readLayer(tag, layer, pbf) {
2197
2719
  if (layer && pbf) {
2198
2720
  if (tag === 15)
2199
2721
  layer.version = pbf.readVarint();
@@ -2206,10 +2728,10 @@ var __exports__ = (() => {
2206
2728
  else if (tag === 3)
2207
2729
  layer._keys.push(pbf.readString());
2208
2730
  else if (tag === 4)
2209
- layer._values.push(readValueMessage2(pbf));
2731
+ layer._values.push(readValueMessage(pbf));
2210
2732
  }
2211
2733
  }
2212
- function readValueMessage2(pbf) {
2734
+ function readValueMessage(pbf) {
2213
2735
  let value = null;
2214
2736
  const end = pbf.readVarint() + pbf.pos;
2215
2737
  while (pbf.pos < end) {
@@ -2219,17 +2741,17 @@ var __exports__ = (() => {
2219
2741
  return value;
2220
2742
  }
2221
2743
 
2222
- // src/lib/binary-vector-tile/vector-tile.ts
2223
- var BinaryVectorTile = class {
2744
+ // src/lib/vector-tile/vector-tile.ts
2745
+ var VectorTile = class {
2224
2746
  layers;
2225
2747
  constructor(pbf, end) {
2226
- this.layers = pbf.readFields(readTile2, {}, end);
2748
+ this.layers = pbf.readFields(readTile, {}, end);
2227
2749
  }
2228
2750
  };
2229
- function readTile2(tag, layers, pbf) {
2751
+ function readTile(tag, layers, pbf) {
2230
2752
  if (tag === 3) {
2231
2753
  if (pbf) {
2232
- const layer = new BinaryVectorTileLayer(pbf, pbf.readVarint() + pbf.pos);
2754
+ const layer = new VectorTileLayer(pbf, pbf.readVarint() + pbf.pos);
2233
2755
  if (layer.length && layers) {
2234
2756
  layers[layer.name] = layer;
2235
2757
  }
@@ -2239,7 +2761,7 @@ var __exports__ = (() => {
2239
2761
 
2240
2762
  // src/lib/parse-mvt.ts
2241
2763
  function parseMVT(arrayBuffer, options) {
2242
- const mvtOptions = normalizeOptions(options);
2764
+ const mvtOptions = checkOptions(options);
2243
2765
  const shape = options?.gis?.format || options?.mvt?.shape || options?.shape;
2244
2766
  switch (shape) {
2245
2767
  case "columnar-table":
@@ -2285,15 +2807,15 @@ var __exports__ = (() => {
2285
2807
  if (arrayBuffer.byteLength <= 0) {
2286
2808
  return [features, geometryInfo];
2287
2809
  }
2288
- const tile = new BinaryVectorTile(new import_pbf.default(arrayBuffer));
2810
+ const tile = new VectorTile(new import_pbf.default(arrayBuffer));
2289
2811
  const selectedLayers = options && Array.isArray(options.layers) ? options.layers : Object.keys(tile.layers);
2290
2812
  selectedLayers.forEach((layerName) => {
2291
2813
  const vectorTileLayer = tile.layers[layerName];
2292
2814
  if (!vectorTileLayer) {
2293
2815
  return;
2294
2816
  }
2295
- for (let i2 = 0; i2 < vectorTileLayer.length; i2++) {
2296
- const vectorTileFeature = vectorTileLayer.feature(i2, geometryInfo);
2817
+ for (let i = 0; i < vectorTileLayer.length; i++) {
2818
+ const vectorTileFeature = vectorTileLayer.getBinaryFeature(i, geometryInfo);
2297
2819
  const decodedFeature = getDecodedFeatureBinary(vectorTileFeature, options, layerName);
2298
2820
  features.push(decodedFeature);
2299
2821
  }
@@ -2312,24 +2834,24 @@ var __exports__ = (() => {
2312
2834
  if (!vectorTileLayer) {
2313
2835
  return;
2314
2836
  }
2315
- for (let i2 = 0; i2 < vectorTileLayer.length; i2++) {
2316
- const vectorTileFeature = vectorTileLayer.feature(i2);
2837
+ for (let i = 0; i < vectorTileLayer.length; i++) {
2838
+ const vectorTileFeature = vectorTileLayer.getGeoJSONFeature(i);
2317
2839
  const decodedFeature = getDecodedFeature(vectorTileFeature, options, layerName);
2318
2840
  features.push(decodedFeature);
2319
2841
  }
2320
2842
  });
2321
2843
  return features;
2322
2844
  }
2323
- function normalizeOptions(options) {
2845
+ function checkOptions(options) {
2324
2846
  if (!options?.mvt) {
2325
2847
  throw new Error("mvt options required");
2326
2848
  }
2327
- const wgs84Coordinates = options.mvt?.coordinates === "wgs84";
2328
- const { tileIndex } = options.mvt;
2329
- const hasTileIndex = tileIndex && Number.isFinite(tileIndex.x) && Number.isFinite(tileIndex.y) && Number.isFinite(tileIndex.z);
2330
- if (wgs84Coordinates && !hasTileIndex) {
2849
+ if (options.mvt?.coordinates === "wgs84" && !options.mvt.tileIndex) {
2331
2850
  throw new Error("MVT Loader: WGS84 coordinates need tileIndex property");
2332
2851
  }
2852
+ if (options.gis) {
2853
+ log.warn('MVTLoader: "options.gis" is deprecated, use "options.mvt.shape" instead')();
2854
+ }
2333
2855
  return options.mvt;
2334
2856
  }
2335
2857
  function getDecodedFeature(feature, options, layerName) {
@@ -2338,6 +2860,7 @@ var __exports__ = (() => {
2338
2860
  options.coordinates === "wgs84" ? options.tileIndex : transformToLocalCoordinates
2339
2861
  );
2340
2862
  if (options.layerProperty) {
2863
+ decodedFeature.properties ||= {};
2341
2864
  decodedFeature.properties[options.layerProperty] = layerName;
2342
2865
  }
2343
2866
  return decodedFeature;
@@ -2354,28 +2877,28 @@ var __exports__ = (() => {
2354
2877
  }
2355
2878
  function transformToLocalCoordinates(line, feature) {
2356
2879
  const { extent } = feature;
2357
- for (let i2 = 0; i2 < line.length; i2++) {
2358
- const p = line[i2];
2880
+ for (let i = 0; i < line.length; i++) {
2881
+ const p = line[i];
2359
2882
  p[0] /= extent;
2360
2883
  p[1] /= extent;
2361
2884
  }
2362
2885
  }
2363
2886
  function transformToLocalCoordinatesBinary(data, feature) {
2364
2887
  const { extent } = feature;
2365
- for (let i2 = 0, il = data.length; i2 < il; ++i2) {
2366
- data[i2] /= extent;
2888
+ for (let i = 0, il = data.length; i < il; ++i) {
2889
+ data[i] /= extent;
2367
2890
  }
2368
2891
  }
2369
2892
 
2370
2893
  // src/mvt-loader.ts
2371
- var VERSION = typeof __VERSION__ !== "undefined" ? __VERSION__ : "latest";
2894
+ var VERSION3 = typeof __VERSION__ !== "undefined" ? __VERSION__ : "latest";
2372
2895
  var MVTWorkerLoader = {
2373
2896
  dataType: null,
2374
2897
  batchType: null,
2375
2898
  name: "Mapbox Vector Tile",
2376
2899
  id: "mvt",
2377
2900
  module: "mvt",
2378
- version: VERSION,
2901
+ version: VERSION3,
2379
2902
  // Note: ArcGIS uses '.pbf' extension and 'application/octet-stream'
2380
2903
  extensions: ["mvt", "pbf"],
2381
2904
  mimeTypes: [
@@ -2392,7 +2915,7 @@ var __exports__ = (() => {
2392
2915
  coordinates: "local",
2393
2916
  layerProperty: "layerName",
2394
2917
  layers: void 0,
2395
- tileIndex: null
2918
+ tileIndex: void 0
2396
2919
  }
2397
2920
  }
2398
2921
  };
@@ -2404,7 +2927,7 @@ var __exports__ = (() => {
2404
2927
  };
2405
2928
 
2406
2929
  // src/lib/parse-tilejson.ts
2407
- var isObject = (x2) => x2 !== null && typeof x2 === "object";
2930
+ var isObject = (x) => x !== null && typeof x === "object";
2408
2931
  function parseTileJSON(jsonMetadata, options) {
2409
2932
  if (!jsonMetadata || !isObject(jsonMetadata)) {
2410
2933
  return null;
@@ -2608,14 +3131,14 @@ var __exports__ = (() => {
2608
3131
  }
2609
3132
 
2610
3133
  // src/tilejson-loader.ts
2611
- var VERSION2 = typeof __VERSION__ !== "undefined" ? __VERSION__ : "latest";
3134
+ var VERSION4 = typeof __VERSION__ !== "undefined" ? __VERSION__ : "latest";
2612
3135
  var TileJSONLoader = {
2613
3136
  dataType: null,
2614
3137
  batchType: null,
2615
3138
  name: "TileJSON",
2616
3139
  id: "tilejson",
2617
3140
  module: "pmtiles",
2618
- version: VERSION2,
3141
+ version: VERSION4,
2619
3142
  worker: true,
2620
3143
  extensions: ["json"],
2621
3144
  mimeTypes: ["application/json"],
@@ -2638,94 +3161,8 @@ var __exports__ = (() => {
2638
3161
  }
2639
3162
  };
2640
3163
 
2641
- // ../loader-utils/src/lib/env-utils/assert.ts
2642
- function assert(condition, message) {
2643
- if (!condition) {
2644
- throw new Error(message || "loader assertion failed.");
2645
- }
2646
- }
2647
-
2648
- // ../loader-utils/src/lib/env-utils/globals.ts
2649
- var globals = {
2650
- self: typeof self !== "undefined" && self,
2651
- window: typeof window !== "undefined" && window,
2652
- global: typeof global !== "undefined" && global,
2653
- document: typeof document !== "undefined" && document
2654
- };
2655
- var self_ = globals.self || globals.window || globals.global || {};
2656
- var window_ = globals.window || globals.self || globals.global || {};
2657
- var global_ = globals.global || globals.self || globals.window || {};
2658
- var document_ = globals.document || {};
2659
- var isBrowser = (
2660
- // @ts-ignore process does not exist on browser
2661
- Boolean(typeof process !== "object" || String(process) !== "[object process]" || process.browser)
2662
- );
2663
- var matches = typeof process !== "undefined" && process.version && /v([0-9]*)/.exec(process.version);
2664
- var nodeVersion = matches && parseFloat(matches[1]) || 0;
2665
-
2666
- // ../loader-utils/src/lib/path-utils/file-aliases.ts
2667
- var pathPrefix = "";
2668
- var fileAliases = {};
2669
- function resolvePath(filename) {
2670
- for (const alias in fileAliases) {
2671
- if (filename.startsWith(alias)) {
2672
- const replacement = fileAliases[alias];
2673
- filename = filename.replace(alias, replacement);
2674
- }
2675
- }
2676
- if (!filename.startsWith("http://") && !filename.startsWith("https://")) {
2677
- filename = `${pathPrefix}${filename}`;
2678
- }
2679
- return filename;
2680
- }
2681
-
2682
- // ../loader-utils/src/lib/sources/data-source.ts
2683
- var DataSource = class {
2684
- /** A resolved fetch function extracted from loadOptions prop */
2685
- fetch;
2686
- /** The actual load options, if calling a loaders.gl loader */
2687
- loadOptions;
2688
- _needsRefresh = true;
2689
- props;
2690
- constructor(props) {
2691
- this.props = { ...props };
2692
- this.loadOptions = { ...props.loadOptions };
2693
- this.fetch = getFetchFunction(this.loadOptions);
2694
- }
2695
- setProps(props) {
2696
- this.props = Object.assign(this.props, props);
2697
- this.setNeedsRefresh();
2698
- }
2699
- /** Mark this data source as needing a refresh (redraw) */
2700
- setNeedsRefresh() {
2701
- this._needsRefresh = true;
2702
- }
2703
- /**
2704
- * Does this data source need refreshing?
2705
- * @note The specifics of the refresh mechanism depends on type of data source
2706
- */
2707
- getNeedsRefresh(clear = true) {
2708
- const needsRefresh = this._needsRefresh;
2709
- if (clear) {
2710
- this._needsRefresh = false;
2711
- }
2712
- return needsRefresh;
2713
- }
2714
- };
2715
- function getFetchFunction(options) {
2716
- const fetchFunction = options?.fetch;
2717
- if (fetchFunction && typeof fetchFunction === "function") {
2718
- return (url, fetchOptions2) => fetchFunction(url, fetchOptions2);
2719
- }
2720
- const fetchOptions = options?.fetch;
2721
- if (fetchOptions && typeof fetchOptions !== "function") {
2722
- return (url) => fetch(url, fetchOptions);
2723
- }
2724
- return (url) => fetch(url);
2725
- }
2726
-
2727
3164
  // ../images/src/lib/utils/version.ts
2728
- var VERSION3 = typeof __VERSION__ !== "undefined" ? __VERSION__ : "latest";
3165
+ var VERSION5 = typeof __VERSION__ !== "undefined" ? __VERSION__ : "latest";
2729
3166
 
2730
3167
  // ../images/src/lib/category-api/image-type.ts
2731
3168
  var parseImageNode = globalThis.loaders?.parseImageNode;
@@ -2925,8 +3362,8 @@ var __exports__ = (() => {
2925
3362
  }
2926
3363
  function checkString(buffer, header, offset = 0) {
2927
3364
  const headerBytes = stringToBytes(header);
2928
- for (let i2 = 0; i2 < headerBytes.length; ++i2) {
2929
- if (headerBytes[i2] !== buffer[i2 + offset]) {
3365
+ for (let i = 0; i < headerBytes.length; ++i) {
3366
+ if (headerBytes[i] !== buffer[i + offset]) {
2930
3367
  return false;
2931
3368
  }
2932
3369
  }
@@ -2996,30 +3433,30 @@ var __exports__ = (() => {
2996
3433
  return null;
2997
3434
  }
2998
3435
  const { tableMarkers, sofMarkers } = getJpegMarkers();
2999
- let i2 = 2;
3000
- while (i2 + 9 < dataView.byteLength) {
3001
- const marker = dataView.getUint16(i2, BIG_ENDIAN);
3436
+ let i = 2;
3437
+ while (i + 9 < dataView.byteLength) {
3438
+ const marker = dataView.getUint16(i, BIG_ENDIAN);
3002
3439
  if (sofMarkers.has(marker)) {
3003
3440
  return {
3004
3441
  mimeType: "image/jpeg",
3005
- height: dataView.getUint16(i2 + 5, BIG_ENDIAN),
3442
+ height: dataView.getUint16(i + 5, BIG_ENDIAN),
3006
3443
  // Number of lines
3007
- width: dataView.getUint16(i2 + 7, BIG_ENDIAN)
3444
+ width: dataView.getUint16(i + 7, BIG_ENDIAN)
3008
3445
  // Number of pixels per line
3009
3446
  };
3010
3447
  }
3011
3448
  if (!tableMarkers.has(marker)) {
3012
3449
  return null;
3013
3450
  }
3014
- i2 += 2;
3015
- i2 += dataView.getUint16(i2, BIG_ENDIAN);
3451
+ i += 2;
3452
+ i += dataView.getUint16(i, BIG_ENDIAN);
3016
3453
  }
3017
3454
  return null;
3018
3455
  }
3019
3456
  function getJpegMarkers() {
3020
3457
  const tableMarkers = /* @__PURE__ */ new Set([65499, 65476, 65484, 65501, 65534]);
3021
- for (let i2 = 65504; i2 < 65520; ++i2) {
3022
- tableMarkers.add(i2);
3458
+ for (let i = 65504; i < 65520; ++i) {
3459
+ tableMarkers.add(i);
3023
3460
  }
3024
3461
  const sofMarkers = /* @__PURE__ */ new Set([
3025
3462
  65472,
@@ -3123,7 +3560,7 @@ var __exports__ = (() => {
3123
3560
  id: "image",
3124
3561
  module: "images",
3125
3562
  name: "Images",
3126
- version: VERSION3,
3563
+ version: VERSION5,
3127
3564
  mimeTypes: MIME_TYPES,
3128
3565
  extensions: EXTENSIONS,
3129
3566
  parse: parseImage,
@@ -3179,8 +3616,8 @@ var __exports__ = (() => {
3179
3616
  return this.mimeType;
3180
3617
  }
3181
3618
  async getTile(tileParams) {
3182
- const { x: x2, y: y2, zoom: z } = tileParams;
3183
- const tileUrl = this.getTileURL(x2, y2, z);
3619
+ const { x, y, z } = tileParams;
3620
+ const tileUrl = this.getTileURL(x, y, z);
3184
3621
  const response = await this.fetch(tileUrl);
3185
3622
  if (!response.ok) {
3186
3623
  return null;
@@ -3191,8 +3628,8 @@ var __exports__ = (() => {
3191
3628
  // Tile Source interface implementation: deck.gl compatible API
3192
3629
  // TODO - currently only handles image tiles, not vector tiles
3193
3630
  async getTileData(tileParams) {
3194
- const { x: x2, y: y2, z } = tileParams.index;
3195
- const arrayBuffer = await this.getTile({ x: x2, y: y2, zoom: z, layers: [] });
3631
+ const { x, y, z } = tileParams.index;
3632
+ const arrayBuffer = await this.getTile({ x, y, z, layers: [] });
3196
3633
  if (arrayBuffer === null) {
3197
3634
  return null;
3198
3635
  }
@@ -3200,7 +3637,7 @@ var __exports__ = (() => {
3200
3637
  this.mimeType = this.mimeType || imageMetadata?.mimeType || "application/vnd.mapbox-vector-tile";
3201
3638
  switch (this.mimeType) {
3202
3639
  case "application/vnd.mapbox-vector-tile":
3203
- return await this._parseVectorTile(arrayBuffer, { x: x2, y: y2, zoom: z, layers: [] });
3640
+ return await this._parseVectorTile(arrayBuffer, { x, y, z, layers: [] });
3204
3641
  default:
3205
3642
  return await this._parseImageTile(arrayBuffer);
3206
3643
  }
@@ -3223,7 +3660,7 @@ var __exports__ = (() => {
3223
3660
  shape: "geojson-table",
3224
3661
  mvt: {
3225
3662
  coordinates: "wgs84",
3226
- tileIndex: { x: tileParams.x, y: tileParams.y, z: tileParams.zoom },
3663
+ tileIndex: { x: tileParams.x, y: tileParams.y, z: tileParams.z },
3227
3664
  ...this.loadOptions?.mvt
3228
3665
  },
3229
3666
  ...this.loadOptions
@@ -3233,14 +3670,14 @@ var __exports__ = (() => {
3233
3670
  getMetadataUrl() {
3234
3671
  return this.metadataUrl;
3235
3672
  }
3236
- getTileURL(x2, y2, z) {
3673
+ getTileURL(x, y, z) {
3237
3674
  switch (this.schema) {
3238
3675
  case "xyz":
3239
- return `${this.url}/${x2}/${y2}/${z}${this.extension}`;
3676
+ return `${this.url}/${x}/${y}/${z}${this.extension}`;
3240
3677
  case "tms":
3241
- return `${this.url}/${z}/${x2}/${y2}${this.extension}`;
3678
+ return `${this.url}/${z}/${x}/${y}${this.extension}`;
3242
3679
  case "template":
3243
- return getURLFromTemplate(this.url, x2, y2, z, "0");
3680
+ return getURLFromTemplate(this.url, x, y, z, "0");
3244
3681
  default:
3245
3682
  throw new Error(this.schema);
3246
3683
  }
@@ -3252,17 +3689,17 @@ var __exports__ = (() => {
3252
3689
  var xRegex = new RegExp("{x}", "g");
3253
3690
  var yRegex = new RegExp("{y}", "g");
3254
3691
  var zRegex = new RegExp("{z}", "g");
3255
- function getURLFromTemplate(template, x2, y2, z, id = "0") {
3692
+ function getURLFromTemplate(template, x, y, z, id = "0") {
3256
3693
  if (Array.isArray(template)) {
3257
- const i2 = stringHash(id) % template.length;
3258
- template = template[i2];
3694
+ const i = stringHash(id) % template.length;
3695
+ template = template[i];
3259
3696
  }
3260
3697
  let url = template;
3261
- url = url.replace(xRegex, String(x2));
3262
- url = url.replace(yRegex, String(y2));
3698
+ url = url.replace(xRegex, String(x));
3699
+ url = url.replace(yRegex, String(y));
3263
3700
  url = url.replace(zRegex, String(z));
3264
- if (Number.isInteger(y2) && Number.isInteger(z)) {
3265
- url = url.replace(/\{-y\}/g, String(Math.pow(2, z) - y2 - 1));
3701
+ if (Number.isInteger(y) && Number.isInteger(z)) {
3702
+ url = url.replace(/\{-y\}/g, String(Math.pow(2, z) - y - 1));
3266
3703
  }
3267
3704
  return url;
3268
3705
  }
@@ -3270,7 +3707,7 @@ var __exports__ = (() => {
3270
3707
  return Math.abs(s.split("").reduce((a, b) => (a << 5) - a + b.charCodeAt(0) | 0, 0));
3271
3708
  }
3272
3709
 
3273
- // src/lib/geojson-tiler/simplify.ts
3710
+ // src/lib/geojsonvt/simplify.ts
3274
3711
  function simplify(coords, first, last, sqTolerance) {
3275
3712
  let maxSqDist = sqTolerance;
3276
3713
  const mid = last - first >> 1;
@@ -3280,15 +3717,15 @@ var __exports__ = (() => {
3280
3717
  const ay = coords[first + 1];
3281
3718
  const bx = coords[last];
3282
3719
  const by = coords[last + 1];
3283
- for (let i2 = first + 3; i2 < last; i2 += 3) {
3284
- const d = getSqSegDist(coords[i2], coords[i2 + 1], ax, ay, bx, by);
3720
+ for (let i = first + 3; i < last; i += 3) {
3721
+ const d = getSqSegDist(coords[i], coords[i + 1], ax, ay, bx, by);
3285
3722
  if (d > maxSqDist) {
3286
- index = i2;
3723
+ index = i;
3287
3724
  maxSqDist = d;
3288
3725
  } else if (d === maxSqDist) {
3289
- const posToMid = Math.abs(i2 - mid);
3726
+ const posToMid = Math.abs(i - mid);
3290
3727
  if (posToMid < minPosToMid) {
3291
- index = i2;
3728
+ index = i;
3292
3729
  minPosToMid = posToMid;
3293
3730
  }
3294
3731
  }
@@ -3301,25 +3738,25 @@ var __exports__ = (() => {
3301
3738
  simplify(coords, index, last, sqTolerance);
3302
3739
  }
3303
3740
  }
3304
- function getSqSegDist(px, py, x2, y2, bx, by) {
3305
- let dx = bx - x2;
3306
- let dy = by - y2;
3741
+ function getSqSegDist(px, py, x, y, bx, by) {
3742
+ let dx = bx - x;
3743
+ let dy = by - y;
3307
3744
  if (dx !== 0 || dy !== 0) {
3308
- const t = ((px - x2) * dx + (py - y2) * dy) / (dx * dx + dy * dy);
3745
+ const t = ((px - x) * dx + (py - y) * dy) / (dx * dx + dy * dy);
3309
3746
  if (t > 1) {
3310
- x2 = bx;
3311
- y2 = by;
3747
+ x = bx;
3748
+ y = by;
3312
3749
  } else if (t > 0) {
3313
- x2 += dx * t;
3314
- y2 += dy * t;
3750
+ x += dx * t;
3751
+ y += dy * t;
3315
3752
  }
3316
3753
  }
3317
- dx = px - x2;
3318
- dy = py - y2;
3754
+ dx = px - x;
3755
+ dy = py - y;
3319
3756
  return dx * dx + dy * dy;
3320
3757
  }
3321
3758
 
3322
- // src/lib/geojson-tiler/feature.ts
3759
+ // src/lib/geojsonvt/feature.ts
3323
3760
  function createFeature(id, type, geom, tags) {
3324
3761
  const feature = {
3325
3762
  // eslint-disable-next-line
@@ -3348,20 +3785,20 @@ var __exports__ = (() => {
3348
3785
  return feature;
3349
3786
  }
3350
3787
  function calcLineBBox(feature, geom) {
3351
- for (let i2 = 0; i2 < geom.length; i2 += 3) {
3352
- feature.minX = Math.min(feature.minX, geom[i2]);
3353
- feature.minY = Math.min(feature.minY, geom[i2 + 1]);
3354
- feature.maxX = Math.max(feature.maxX, geom[i2]);
3355
- feature.maxY = Math.max(feature.maxY, geom[i2 + 1]);
3788
+ for (let i = 0; i < geom.length; i += 3) {
3789
+ feature.minX = Math.min(feature.minX, geom[i]);
3790
+ feature.minY = Math.min(feature.minY, geom[i + 1]);
3791
+ feature.maxX = Math.max(feature.maxX, geom[i]);
3792
+ feature.maxY = Math.max(feature.maxY, geom[i + 1]);
3356
3793
  }
3357
3794
  }
3358
3795
 
3359
- // src/lib/geojson-tiler/convert.ts
3796
+ // src/lib/geojsonvt/convert.ts
3360
3797
  function convert(data, options) {
3361
3798
  const features = [];
3362
3799
  if (data.type === "FeatureCollection") {
3363
- for (let i2 = 0; i2 < data.features.length; i2++) {
3364
- convertFeature(features, data.features[i2], options, i2);
3800
+ for (let i = 0; i < data.features.length; i++) {
3801
+ convertFeature(features, data.features[i], options, i);
3365
3802
  }
3366
3803
  } else if (data.type === "Feature") {
3367
3804
  convertFeature(features, data, options);
@@ -3437,18 +3874,18 @@ var __exports__ = (() => {
3437
3874
  let x0, y0;
3438
3875
  let size = 0;
3439
3876
  for (let j = 0; j < ring.length; j++) {
3440
- const x2 = projectX(ring[j][0]);
3441
- const y2 = projectY(ring[j][1]);
3442
- out.push(x2, y2, 0);
3877
+ const x = projectX(ring[j][0]);
3878
+ const y = projectY(ring[j][1]);
3879
+ out.push(x, y, 0);
3443
3880
  if (j > 0) {
3444
3881
  if (isPolygon) {
3445
- size += (x0 * y2 - x2 * y0) / 2;
3882
+ size += (x0 * y - x * y0) / 2;
3446
3883
  } else {
3447
- size += Math.sqrt(Math.pow(x2 - x0, 2) + Math.pow(y2 - y0, 2));
3884
+ size += Math.sqrt(Math.pow(x - x0, 2) + Math.pow(y - y0, 2));
3448
3885
  }
3449
3886
  }
3450
- x0 = x2;
3451
- y0 = y2;
3887
+ x0 = x;
3888
+ y0 = y;
3452
3889
  }
3453
3890
  const last = out.length - 3;
3454
3891
  out[2] = 1;
@@ -3459,22 +3896,22 @@ var __exports__ = (() => {
3459
3896
  out.end = out.size;
3460
3897
  }
3461
3898
  function convertLines(rings, out, tolerance, isPolygon) {
3462
- for (let i2 = 0; i2 < rings.length; i2++) {
3899
+ for (let i = 0; i < rings.length; i++) {
3463
3900
  const geom = [];
3464
- convertLine(rings[i2], geom, tolerance, isPolygon);
3901
+ convertLine(rings[i], geom, tolerance, isPolygon);
3465
3902
  out.push(geom);
3466
3903
  }
3467
3904
  }
3468
- function projectX(x2) {
3469
- return x2 / 360 + 0.5;
3905
+ function projectX(x) {
3906
+ return x / 360 + 0.5;
3470
3907
  }
3471
- function projectY(y2) {
3472
- const sin = Math.sin(y2 * Math.PI / 180);
3473
- const y22 = 0.5 - 0.25 * Math.log((1 + sin) / (1 - sin)) / Math.PI;
3474
- return y22 < 0 ? 0 : y22 > 1 ? 1 : y22;
3908
+ function projectY(y) {
3909
+ const sin = Math.sin(y * Math.PI / 180);
3910
+ const y2 = 0.5 - 0.25 * Math.log((1 + sin) / (1 - sin)) / Math.PI;
3911
+ return y2 < 0 ? 0 : y2 > 1 ? 1 : y2;
3475
3912
  }
3476
3913
 
3477
- // src/lib/geojson-tiler/clip.ts
3914
+ // src/lib/geojsonvt/clip.ts
3478
3915
  function clip(features, scale, k1, k2, axis, minAll, maxAll, options) {
3479
3916
  k1 /= scale;
3480
3917
  k2 /= scale;
@@ -3537,10 +3974,10 @@ var __exports__ = (() => {
3537
3974
  return clipped.length ? clipped : null;
3538
3975
  }
3539
3976
  function clipPoints(geom, newGeom, k1, k2, axis) {
3540
- for (let i2 = 0; i2 < geom.length; i2 += 3) {
3541
- const a = geom[i2 + axis];
3977
+ for (let i = 0; i < geom.length; i += 3) {
3978
+ const a = geom[i + axis];
3542
3979
  if (a >= k1 && a <= k2) {
3543
- addPoint(newGeom, geom[i2], geom[i2 + 1], geom[i2 + 2]);
3980
+ addPoint(newGeom, geom[i], geom[i + 1], geom[i + 2]);
3544
3981
  }
3545
3982
  }
3546
3983
  }
@@ -3550,12 +3987,12 @@ var __exports__ = (() => {
3550
3987
  let len = geom.start;
3551
3988
  let segLen;
3552
3989
  let t;
3553
- for (let i2 = 0; i2 < geom.length - 3; i2 += 3) {
3554
- const ax2 = geom[i2];
3555
- const ay2 = geom[i2 + 1];
3556
- const az2 = geom[i2 + 2];
3557
- const bx = geom[i2 + 3];
3558
- const by = geom[i2 + 4];
3990
+ for (let i = 0; i < geom.length - 3; i += 3) {
3991
+ const ax2 = geom[i];
3992
+ const ay2 = geom[i + 1];
3993
+ const az2 = geom[i + 2];
3994
+ const bx = geom[i + 3];
3995
+ const by = geom[i + 4];
3559
3996
  const a2 = axis === 0 ? ax2 : ay2;
3560
3997
  const b = axis === 0 ? bx : by;
3561
3998
  let exited = false;
@@ -3625,21 +4062,21 @@ var __exports__ = (() => {
3625
4062
  clipLine(line, newGeom, k1, k2, axis, isPolygon, false);
3626
4063
  }
3627
4064
  }
3628
- function addPoint(out, x2, y2, z) {
3629
- out.push(x2, y2, z);
4065
+ function addPoint(out, x, y, z) {
4066
+ out.push(x, y, z);
3630
4067
  }
3631
- function intersectX(out, ax, ay, bx, by, x2) {
3632
- const t = (x2 - ax) / (bx - ax);
3633
- addPoint(out, x2, ay + (by - ay) * t, 1);
4068
+ function intersectX(out, ax, ay, bx, by, x) {
4069
+ const t = (x - ax) / (bx - ax);
4070
+ addPoint(out, x, ay + (by - ay) * t, 1);
3634
4071
  return t;
3635
4072
  }
3636
- function intersectY(out, ax, ay, bx, by, y2) {
3637
- const t = (y2 - ay) / (by - ay);
3638
- addPoint(out, ax + (bx - ax) * t, y2, 1);
4073
+ function intersectY(out, ax, ay, bx, by, y) {
4074
+ const t = (y - ay) / (by - ay);
4075
+ addPoint(out, ax + (bx - ax) * t, y, 1);
3639
4076
  return t;
3640
4077
  }
3641
4078
 
3642
- // src/lib/geojson-tiler/wrap.ts
4079
+ // src/lib/geojsonvt/wrap.ts
3643
4080
  function wrap(features, options) {
3644
4081
  const buffer = options.buffer / options.extent;
3645
4082
  let merged = features;
@@ -3658,8 +4095,8 @@ var __exports__ = (() => {
3658
4095
  }
3659
4096
  function shiftFeatureCoords(features, offset) {
3660
4097
  const newFeatures = [];
3661
- for (let i2 = 0; i2 < features.length; i2++) {
3662
- const feature = features[i2];
4098
+ for (let i = 0; i < features.length; i++) {
4099
+ const feature = features[i];
3663
4100
  const type = feature.type;
3664
4101
  let newGeometry;
3665
4102
  if (type === "Point" || type === "MultiPoint" || type === "LineString") {
@@ -3690,13 +4127,13 @@ var __exports__ = (() => {
3690
4127
  newPoints.start = points.start;
3691
4128
  newPoints.end = points.end;
3692
4129
  }
3693
- for (let i2 = 0; i2 < points.length; i2 += 3) {
3694
- newPoints.push(points[i2] + offset, points[i2 + 1], points[i2 + 2]);
4130
+ for (let i = 0; i < points.length; i += 3) {
4131
+ newPoints.push(points[i] + offset, points[i + 1], points[i + 2]);
3695
4132
  }
3696
4133
  return newPoints;
3697
4134
  }
3698
4135
 
3699
- // src/lib/geojson-tiler/transform.ts
4136
+ // src/lib/geojsonvt/transform.ts
3700
4137
  function transformTile(tile, extent) {
3701
4138
  if (tile.transformed) {
3702
4139
  return tile;
@@ -3725,11 +4162,11 @@ var __exports__ = (() => {
3725
4162
  tile.transformed = true;
3726
4163
  return tile;
3727
4164
  }
3728
- function transformPoint(x2, y2, extent, z2, tx, ty) {
3729
- return [Math.round(extent * (x2 * z2 - tx)), Math.round(extent * (y2 * z2 - ty))];
4165
+ function transformPoint(x, y, extent, z2, tx, ty) {
4166
+ return [Math.round(extent * (x * z2 - tx)), Math.round(extent * (y * z2 - ty))];
3730
4167
  }
3731
4168
 
3732
- // src/lib/geojson-tiler/tile.ts
4169
+ // src/lib/geojsonvt/tile.ts
3733
4170
  function createTile(features, z, tx, ty, options) {
3734
4171
  const tolerance = z === options.maxZoom ? 0 : options.tolerance / ((1 << z) * options.extent);
3735
4172
  const tile = {
@@ -3761,22 +4198,22 @@ var __exports__ = (() => {
3761
4198
  tile.maxX = Math.max(tile.maxX, feature.maxX);
3762
4199
  tile.maxY = Math.max(tile.maxY, feature.maxY);
3763
4200
  if (type === "Point" || type === "MultiPoint") {
3764
- for (let i2 = 0; i2 < geom.length; i2 += 3) {
3765
- simplified.push(geom[i2], geom[i2 + 1]);
4201
+ for (let i = 0; i < geom.length; i += 3) {
4202
+ simplified.push(geom[i], geom[i + 1]);
3766
4203
  tile.numPoints++;
3767
4204
  tile.numSimplified++;
3768
4205
  }
3769
4206
  } else if (type === "LineString") {
3770
4207
  addLine(simplified, geom, tile, tolerance, false, false);
3771
4208
  } else if (type === "MultiLineString" || type === "Polygon") {
3772
- for (let i2 = 0; i2 < geom.length; i2++) {
3773
- addLine(simplified, geom[i2], tile, tolerance, type === "Polygon", i2 === 0);
4209
+ for (let i = 0; i < geom.length; i++) {
4210
+ addLine(simplified, geom[i], tile, tolerance, type === "Polygon", i === 0);
3774
4211
  }
3775
4212
  } else if (type === "MultiPolygon") {
3776
4213
  for (let k = 0; k < geom.length; k++) {
3777
4214
  const polygon = geom[k];
3778
- for (let i2 = 0; i2 < polygon.length; i2++) {
3779
- addLine(simplified, polygon[i2], tile, tolerance, true, i2 === 0);
4215
+ for (let i = 0; i < polygon.length; i++) {
4216
+ addLine(simplified, polygon[i], tile, tolerance, true, i === 0);
3780
4217
  }
3781
4218
  }
3782
4219
  }
@@ -3807,10 +4244,10 @@ var __exports__ = (() => {
3807
4244
  return;
3808
4245
  }
3809
4246
  const ring = [];
3810
- for (let i2 = 0; i2 < geom.length; i2 += 3) {
3811
- if (tolerance === 0 || geom[i2 + 2] > sqTolerance) {
4247
+ for (let i = 0; i < geom.length; i += 3) {
4248
+ if (tolerance === 0 || geom[i + 2] > sqTolerance) {
3812
4249
  tile.numSimplified++;
3813
- ring.push(geom[i2], geom[i2 + 1]);
4250
+ ring.push(geom[i], geom[i + 1]);
3814
4251
  }
3815
4252
  tile.numPoints++;
3816
4253
  }
@@ -3820,55 +4257,43 @@ var __exports__ = (() => {
3820
4257
  }
3821
4258
  function rewind(ring, clockwise) {
3822
4259
  let area2 = 0;
3823
- for (let i2 = 0, j = ring.length - 2; i2 < ring.length; j = i2, i2 += 2) {
3824
- area2 += (ring[i2] - ring[j]) * (ring[i2 + 1] + ring[j + 1]);
4260
+ for (let i = 0, j = ring.length - 2; i < ring.length; j = i, i += 2) {
4261
+ area2 += (ring[i] - ring[j]) * (ring[i + 1] + ring[j + 1]);
3825
4262
  }
3826
4263
  if (area2 > 0 === clockwise) {
3827
- for (let i2 = 0, len = ring.length; i2 < len / 2; i2 += 2) {
3828
- const x2 = ring[i2];
3829
- const y2 = ring[i2 + 1];
3830
- ring[i2] = ring[len - 2 - i2];
3831
- ring[i2 + 1] = ring[len - 1 - i2];
3832
- ring[len - 2 - i2] = x2;
3833
- ring[len - 1 - i2] = y2;
4264
+ for (let i = 0, len = ring.length; i < len / 2; i += 2) {
4265
+ const x = ring[i];
4266
+ const y = ring[i + 1];
4267
+ ring[i] = ring[len - 2 - i];
4268
+ ring[i + 1] = ring[len - 1 - i];
4269
+ ring[len - 2 - i] = x;
4270
+ ring[len - 1 - i] = y;
3834
4271
  }
3835
4272
  }
3836
4273
  }
3837
4274
 
3838
- // src/lib/geojson-tiler/geojson-tiler.ts
3839
- var DEFAULT_OPTIONS = {
3840
- maxZoom: 14,
3841
- // max zoom to preserve detail on
3842
- indexMaxZoom: 5,
3843
- // max zoom in the tile index
3844
- indexMaxPoints: 1e5,
3845
- // max number of points per tile in the tile index
3846
- tolerance: 3,
3847
- // simplification tolerance (higher means simpler)
3848
- extent: 4096,
3849
- // tile extent
3850
- buffer: 64,
3851
- // tile buffer on each side
3852
- lineMetrics: false,
3853
- // whether to calculate line metrics
3854
- // @ts-expect-error Ensures all these required params have defaults
3855
- promoteId: void 0,
3856
- // name of a feature property to be promoted to feature.id
3857
- generateId: false,
3858
- // whether to generate feature ids. Cannot be used with promoteId
3859
- debug: 0
3860
- // logging level (0, 1 or 2)
3861
- };
3862
- var GeoJSONTiler = class {
4275
+ // src/geojson-tile-source.ts
4276
+ var _GeoJSONTileSource = class {
4277
+ mimeType = "application/vnd.mapbox-vector-tile";
3863
4278
  options;
3864
4279
  // tiles and tileCoords are part of the public API
3865
4280
  tiles = {};
3866
4281
  tileCoords = [];
3867
4282
  stats = {};
3868
4283
  total = 0;
4284
+ /** Sync methods can be called: the input data promise has been resolved and initial top-level tiling is done */
4285
+ ready;
3869
4286
  constructor(data, options) {
3870
- this.options = { ...DEFAULT_OPTIONS, ...options };
3871
- options = this.options;
4287
+ this.options = { ..._GeoJSONTileSource.defaultOptions, ...options };
4288
+ this.getTileData = this.getTileData.bind(this);
4289
+ this.ready = this.initializeTilesAsync(data);
4290
+ }
4291
+ async initializeTilesAsync(dataPromise) {
4292
+ const data = await dataPromise;
4293
+ this.initializeTilesSync(data);
4294
+ }
4295
+ initializeTilesSync(data) {
4296
+ const options = this.options;
3872
4297
  const debug = options.debug;
3873
4298
  if (debug)
3874
4299
  console.time("preprocess data");
@@ -3900,30 +4325,62 @@ var __exports__ = (() => {
3900
4325
  console.log("tiles generated:", this.total, JSON.stringify(this.stats));
3901
4326
  }
3902
4327
  }
4328
+ async getMetadata() {
4329
+ return {};
4330
+ }
3903
4331
  /**
3904
4332
  * Get a tile at the specified index
3905
- * @param z
3906
- * @param x
3907
- * @param y
4333
+ * @param tileIndex z, x, y of tile
3908
4334
  * @returns
3909
4335
  */
4336
+ async getVectorTile(tileIndex) {
4337
+ await this.ready;
4338
+ const table = this.getTileSync(tileIndex);
4339
+ return table;
4340
+ }
4341
+ async getTile(tileIndex) {
4342
+ await this.ready;
4343
+ return this.getTileSync(tileIndex);
4344
+ }
4345
+ async getTileData(tileParams) {
4346
+ const { x, y, z } = tileParams.index;
4347
+ return await this.getVectorTile({ x, y, z });
4348
+ }
4349
+ // Implementation
4350
+ /**
4351
+ * Synchronously request a tile
4352
+ * @note Application must await `source.ready` before calling sync methods.
4353
+ */
4354
+ getTileSync(tileIndex) {
4355
+ const rawTile = this.getRawTile(tileIndex);
4356
+ if (!rawTile) {
4357
+ return null;
4358
+ }
4359
+ return convertToGeoJSONTable(rawTile, this.options.extent);
4360
+ }
4361
+ /**
4362
+ * Return geojsonvt-style "half formed" vector tile
4363
+ * @note Application must await `source.ready` before calling sync methods.
4364
+ */
3910
4365
  // eslint-disable-next-line complexity, max-statements
3911
- getTile(z, x2, y2) {
4366
+ getRawTile(tileIndex) {
4367
+ const { z, y } = tileIndex;
4368
+ let { x } = tileIndex;
3912
4369
  const { extent, debug } = this.options;
3913
4370
  if (z < 0 || z > 24) {
3914
4371
  return null;
3915
4372
  }
3916
4373
  const z2 = 1 << z;
3917
- x2 = x2 + z2 & z2 - 1;
3918
- const id = toID(z, x2, y2);
4374
+ x = x + z2 & z2 - 1;
4375
+ const id = toID(z, x, y);
3919
4376
  if (this.tiles[id]) {
3920
4377
  return transformTile(this.tiles[id], extent);
3921
4378
  }
3922
4379
  if (debug > 1)
3923
- console.log("drilling down to z%d-%d-%d", z, x2, y2);
4380
+ console.log("drilling down to z%d-%d-%d", z, x, y);
3924
4381
  let z0 = z;
3925
- let x0 = x2;
3926
- let y0 = y2;
4382
+ let x0 = x;
4383
+ let y0 = y;
3927
4384
  let parent;
3928
4385
  while (!parent && z0 > 0) {
3929
4386
  z0--;
@@ -3938,7 +4395,7 @@ var __exports__ = (() => {
3938
4395
  console.log("found parent tile z%d-%d-%d", z0, x0, y0);
3939
4396
  console.time("drilling down");
3940
4397
  }
3941
- this.splitTile(parent.source, z0, x0, y0, z, x2, y2);
4398
+ this.splitTile(parent.source, z0, x0, y0, z, x, y);
3942
4399
  if (debug > 1) {
3943
4400
  console.timeEnd("drilling down");
3944
4401
  }
@@ -3953,31 +4410,31 @@ var __exports__ = (() => {
3953
4410
  * zoom or the number of points is low as specified in the options.
3954
4411
  */
3955
4412
  // eslint-disable-next-line max-params, max-statements, complexity
3956
- splitTile(features, z, x2, y2, cz, cx, cy) {
3957
- const stack = [features, z, x2, y2];
4413
+ splitTile(features, z, x, y, cz, cx, cy) {
4414
+ const stack = [features, z, x, y];
3958
4415
  const options = this.options;
3959
4416
  const debug = options.debug;
3960
4417
  while (stack.length) {
3961
- y2 = stack.pop();
3962
- x2 = stack.pop();
4418
+ y = stack.pop();
4419
+ x = stack.pop();
3963
4420
  z = stack.pop();
3964
4421
  features = stack.pop();
3965
4422
  const z2 = 1 << z;
3966
- const id = toID(z, x2, y2);
4423
+ const id = toID(z, x, y);
3967
4424
  let tile = this.tiles[id];
3968
4425
  if (!tile) {
3969
4426
  if (debug > 1) {
3970
4427
  console.time("creation");
3971
4428
  }
3972
- tile = this.tiles[id] = createTile(features, z, x2, y2, options);
3973
- this.tileCoords.push({ z, x: x2, y: y2 });
4429
+ tile = this.tiles[id] = createTile(features, z, x, y, options);
4430
+ this.tileCoords.push({ z, x, y });
3974
4431
  if (debug) {
3975
4432
  if (debug > 1) {
3976
4433
  console.log(
3977
4434
  "tile z%d-%d-%d (features: %d, points: %d, simplified: %d)",
3978
4435
  z,
3979
- x2,
3980
- y2,
4436
+ x,
4437
+ y,
3981
4438
  tile.numFeatures,
3982
4439
  tile.numPoints,
3983
4440
  tile.numSimplified
@@ -3997,7 +4454,7 @@ var __exports__ = (() => {
3997
4454
  continue;
3998
4455
  } else if (cz !== void 0) {
3999
4456
  const zoomSteps = cz - z;
4000
- if (x2 !== cx >> zoomSteps || y2 !== cy >> zoomSteps)
4457
+ if (x !== cx >> zoomSteps || y !== cy >> zoomSteps)
4001
4458
  continue;
4002
4459
  }
4003
4460
  tile.source = null;
@@ -4013,30 +4470,117 @@ var __exports__ = (() => {
4013
4470
  let bl = null;
4014
4471
  let tr = null;
4015
4472
  let br = null;
4016
- let left = clip(features, z2, x2 - k1, x2 + k3, 0, tile.minX, tile.maxX, options);
4017
- let right = clip(features, z2, x2 + k2, x2 + k4, 0, tile.minX, tile.maxX, options);
4473
+ let left = clip(features, z2, x - k1, x + k3, 0, tile.minX, tile.maxX, options);
4474
+ let right = clip(features, z2, x + k2, x + k4, 0, tile.minX, tile.maxX, options);
4018
4475
  features = null;
4019
4476
  if (left) {
4020
- tl = clip(left, z2, y2 - k1, y2 + k3, 1, tile.minY, tile.maxY, options);
4021
- bl = clip(left, z2, y2 + k2, y2 + k4, 1, tile.minY, tile.maxY, options);
4477
+ tl = clip(left, z2, y - k1, y + k3, 1, tile.minY, tile.maxY, options);
4478
+ bl = clip(left, z2, y + k2, y + k4, 1, tile.minY, tile.maxY, options);
4022
4479
  left = null;
4023
4480
  }
4024
4481
  if (right) {
4025
- tr = clip(right, z2, y2 - k1, y2 + k3, 1, tile.minY, tile.maxY, options);
4026
- br = clip(right, z2, y2 + k2, y2 + k4, 1, tile.minY, tile.maxY, options);
4482
+ tr = clip(right, z2, y - k1, y + k3, 1, tile.minY, tile.maxY, options);
4483
+ br = clip(right, z2, y + k2, y + k4, 1, tile.minY, tile.maxY, options);
4027
4484
  right = null;
4028
4485
  }
4029
4486
  if (debug > 1)
4030
4487
  console.timeEnd("clipping");
4031
- stack.push(tl || [], z + 1, x2 * 2, y2 * 2);
4032
- stack.push(bl || [], z + 1, x2 * 2, y2 * 2 + 1);
4033
- stack.push(tr || [], z + 1, x2 * 2 + 1, y2 * 2);
4034
- stack.push(br || [], z + 1, x2 * 2 + 1, y2 * 2 + 1);
4488
+ stack.push(tl || [], z + 1, x * 2, y * 2);
4489
+ stack.push(bl || [], z + 1, x * 2, y * 2 + 1);
4490
+ stack.push(tr || [], z + 1, x * 2 + 1, y * 2);
4491
+ stack.push(br || [], z + 1, x * 2 + 1, y * 2 + 1);
4035
4492
  }
4036
4493
  }
4037
4494
  };
4038
- function toID(z, x2, y2) {
4039
- return ((1 << z) * y2 + x2) * 32 + z;
4495
+ var GeoJSONTileSource = _GeoJSONTileSource;
4496
+ __publicField(GeoJSONTileSource, "defaultOptions", {
4497
+ maxZoom: 14,
4498
+ // max zoom to preserve detail on
4499
+ indexMaxZoom: 5,
4500
+ // max zoom in the tile index
4501
+ indexMaxPoints: 1e5,
4502
+ // max number of points per tile in the tile index
4503
+ tolerance: 3,
4504
+ // simplification tolerance (higher means simpler)
4505
+ extent: 4096,
4506
+ // tile extent
4507
+ buffer: 64,
4508
+ // tile buffer on each side
4509
+ lineMetrics: false,
4510
+ // whether to calculate line metrics
4511
+ // @ts-expect-error
4512
+ promoteId: void 0,
4513
+ // name of a feature property to be promoted to feature.id
4514
+ generateId: false,
4515
+ // whether to generate feature ids. Cannot be used with promoteId
4516
+ debug: 0
4517
+ // logging level (0, 1 or 2)
4518
+ });
4519
+ function toID(z, x, y) {
4520
+ return ((1 << z) * y + x) * 32 + z;
4521
+ }
4522
+ function convertToGeoJSONTable(vtTile, extent) {
4523
+ const features = [];
4524
+ for (const rawFeature of vtTile.features) {
4525
+ if (!rawFeature || !rawFeature.geometry) {
4526
+ continue;
4527
+ }
4528
+ let type;
4529
+ let coordinates;
4530
+ switch (rawFeature.type) {
4531
+ case 1:
4532
+ if (rawFeature.geometry.length === 1) {
4533
+ type = "Point";
4534
+ coordinates = rawFeature.geometry[0];
4535
+ } else {
4536
+ type = "MultiPoint";
4537
+ coordinates = rawFeature.geometry;
4538
+ }
4539
+ break;
4540
+ case 2:
4541
+ if (rawFeature.geometry.length === 1) {
4542
+ type = "LineString";
4543
+ coordinates = rawFeature.geometry[0];
4544
+ } else {
4545
+ type = "MultiLineString";
4546
+ coordinates = rawFeature.geometry;
4547
+ }
4548
+ break;
4549
+ case 3:
4550
+ if (rawFeature.geometry.length > 1) {
4551
+ type = "MultiPolygon";
4552
+ coordinates = [rawFeature.geometry];
4553
+ } else {
4554
+ type = "Polygon";
4555
+ coordinates = rawFeature.geometry;
4556
+ }
4557
+ break;
4558
+ default:
4559
+ continue;
4560
+ }
4561
+ coordinates = toLngLat(coordinates, extent);
4562
+ const feature = {
4563
+ type: "Feature",
4564
+ geometry: {
4565
+ type,
4566
+ coordinates
4567
+ },
4568
+ properties: rawFeature.tags || {}
4569
+ };
4570
+ features.push(feature);
4571
+ }
4572
+ const table = {
4573
+ shape: "geojson-table",
4574
+ type: "FeatureCollection",
4575
+ features
4576
+ };
4577
+ return table;
4578
+ }
4579
+ function toLngLat(coords, extent) {
4580
+ if (Array.isArray(coords[0])) {
4581
+ return coords.map((c) => toLngLat(c, extent));
4582
+ }
4583
+ return [coords[0] / extent, coords[1] / extent];
4040
4584
  }
4041
4585
  return __toCommonJS(bundle_exports);
4042
4586
  })();