@loaders.gl/mvt 4.2.1 → 4.3.0-alpha.2

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 (120) hide show
  1. package/dist/dist.dev.js +1784 -847
  2. package/dist/dist.min.js +1 -1
  3. package/dist/index.cjs +713 -640
  4. package/dist/index.cjs.map +4 -4
  5. package/dist/index.d.ts +2 -2
  6. package/dist/index.d.ts.map +1 -1
  7. package/dist/index.js +1 -1
  8. package/dist/lib/parse-mvt.d.ts +2 -1
  9. package/dist/lib/parse-mvt.d.ts.map +1 -1
  10. package/dist/lib/parse-mvt.js +15 -45
  11. package/dist/lib/parse-tilejson.d.ts +4 -4
  12. package/dist/lib/parse-tilejson.d.ts.map +1 -1
  13. package/dist/lib/types.d.ts +1 -39
  14. package/dist/lib/types.d.ts.map +1 -1
  15. package/dist/lib/utils/geometry-utils.d.ts +83 -0
  16. package/dist/lib/utils/geometry-utils.d.ts.map +1 -0
  17. package/dist/lib/utils/geometry-utils.js +206 -0
  18. package/dist/lib/vector-tile/vector-tile-feature.d.ts +72 -0
  19. package/dist/lib/vector-tile/vector-tile-feature.d.ts.map +1 -0
  20. package/dist/lib/vector-tile/vector-tile-feature.js +342 -0
  21. package/dist/lib/{mapbox-vector-tile → vector-tile}/vector-tile-layer.d.ts +10 -1
  22. package/dist/lib/vector-tile/vector-tile-layer.d.ts.map +1 -0
  23. package/dist/lib/{mapbox-vector-tile → vector-tile}/vector-tile-layer.js +16 -1
  24. package/dist/lib/vector-tile/vector-tile.d.ts.map +1 -0
  25. package/dist/lib/{geojson-tiler → vector-tiler}/clip.d.ts +3 -3
  26. package/dist/lib/vector-tiler/clip.d.ts.map +1 -0
  27. package/dist/lib/vector-tiler/convert.d.ts +18 -0
  28. package/dist/lib/vector-tiler/convert.d.ts.map +1 -0
  29. package/dist/lib/{geojson-tiler → vector-tiler}/convert.js +8 -1
  30. package/dist/lib/vector-tiler/feature.d.ts +3 -0
  31. package/dist/lib/vector-tiler/feature.d.ts.map +1 -0
  32. package/dist/lib/vector-tiler/simplify.d.ts.map +1 -0
  33. package/dist/lib/{geojson-tiler → vector-tiler}/tile.d.ts +4 -4
  34. package/dist/lib/vector-tiler/tile.d.ts.map +1 -0
  35. package/dist/lib/vector-tiler/transform.d.ts +7 -0
  36. package/dist/lib/vector-tiler/transform.d.ts.map +1 -0
  37. package/dist/lib/{geojson-tiler → vector-tiler}/wrap.d.ts +2 -2
  38. package/dist/lib/vector-tiler/wrap.d.ts.map +1 -0
  39. package/dist/mvt-loader.d.ts +19 -8
  40. package/dist/mvt-loader.d.ts.map +1 -1
  41. package/dist/mvt-loader.js +3 -2
  42. package/dist/mvt-source.d.ts +4 -4
  43. package/dist/mvt-source.d.ts.map +1 -1
  44. package/dist/mvt-source.js +7 -7
  45. package/dist/mvt-worker.js +1244 -762
  46. package/dist/table-tile-source.d.ts +118 -0
  47. package/dist/table-tile-source.d.ts.map +1 -0
  48. package/dist/table-tile-source.js +370 -0
  49. package/dist/tilejson-loader.js +1 -1
  50. package/package.json +7 -6
  51. package/src/index.ts +3 -3
  52. package/src/lib/parse-mvt.ts +28 -66
  53. package/src/lib/parse-tilejson.ts +5 -5
  54. package/src/lib/types.ts +1 -39
  55. package/src/lib/utils/geometry-utils.ts +234 -0
  56. package/src/lib/vector-tile/vector-tile-feature.ts +416 -0
  57. package/src/lib/{mapbox-vector-tile → vector-tile}/vector-tile-layer.ts +28 -2
  58. package/src/lib/{geojson-tiler → vector-tiler}/clip.ts +4 -4
  59. package/src/lib/{geojson-tiler → vector-tiler}/convert.ts +19 -9
  60. package/src/lib/{geojson-tiler → vector-tiler}/feature.ts +3 -3
  61. package/src/lib/{geojson-tiler → vector-tiler}/tile.ts +10 -10
  62. package/src/lib/{geojson-tiler → vector-tiler}/transform.ts +2 -2
  63. package/src/lib/{geojson-tiler → vector-tiler}/wrap.ts +5 -5
  64. package/src/mvt-loader.ts +14 -6
  65. package/src/mvt-source.ts +9 -10
  66. package/src/table-tile-source.ts +508 -0
  67. package/dist/helpers/binary-util-functions.d.ts +0 -35
  68. package/dist/helpers/binary-util-functions.d.ts.map +0 -1
  69. package/dist/helpers/binary-util-functions.js +0 -114
  70. package/dist/helpers/mapbox-util-functions.d.ts +0 -29
  71. package/dist/helpers/mapbox-util-functions.d.ts.map +0 -1
  72. package/dist/helpers/mapbox-util-functions.js +0 -78
  73. package/dist/lib/binary-vector-tile/vector-tile-feature.d.ts +0 -41
  74. package/dist/lib/binary-vector-tile/vector-tile-feature.d.ts.map +0 -1
  75. package/dist/lib/binary-vector-tile/vector-tile-feature.js +0 -163
  76. package/dist/lib/binary-vector-tile/vector-tile-layer.d.ts +0 -23
  77. package/dist/lib/binary-vector-tile/vector-tile-layer.d.ts.map +0 -1
  78. package/dist/lib/binary-vector-tile/vector-tile-layer.js +0 -96
  79. package/dist/lib/binary-vector-tile/vector-tile.d.ts +0 -9
  80. package/dist/lib/binary-vector-tile/vector-tile.d.ts.map +0 -1
  81. package/dist/lib/binary-vector-tile/vector-tile.js +0 -27
  82. package/dist/lib/geojson-tiler/clip.d.ts.map +0 -1
  83. package/dist/lib/geojson-tiler/convert.d.ts +0 -10
  84. package/dist/lib/geojson-tiler/convert.d.ts.map +0 -1
  85. package/dist/lib/geojson-tiler/feature.d.ts +0 -3
  86. package/dist/lib/geojson-tiler/feature.d.ts.map +0 -1
  87. package/dist/lib/geojson-tiler/geojson-tiler.d.ts +0 -44
  88. package/dist/lib/geojson-tiler/geojson-tiler.d.ts.map +0 -1
  89. package/dist/lib/geojson-tiler/geojson-tiler.js +0 -209
  90. package/dist/lib/geojson-tiler/simplify.d.ts.map +0 -1
  91. package/dist/lib/geojson-tiler/tile.d.ts.map +0 -1
  92. package/dist/lib/geojson-tiler/transform.d.ts +0 -7
  93. package/dist/lib/geojson-tiler/transform.d.ts.map +0 -1
  94. package/dist/lib/geojson-tiler/wrap.d.ts.map +0 -1
  95. package/dist/lib/mapbox-vector-tile/vector-tile-feature.d.ts +0 -27
  96. package/dist/lib/mapbox-vector-tile/vector-tile-feature.d.ts.map +0 -1
  97. package/dist/lib/mapbox-vector-tile/vector-tile-feature.js +0 -178
  98. package/dist/lib/mapbox-vector-tile/vector-tile-layer.d.ts.map +0 -1
  99. package/dist/lib/mapbox-vector-tile/vector-tile.d.ts.map +0 -1
  100. package/src/helpers/binary-util-functions.ts +0 -125
  101. package/src/helpers/mapbox-util-functions.ts +0 -82
  102. package/src/lib/binary-vector-tile/vector-tile-feature.ts +0 -203
  103. package/src/lib/binary-vector-tile/vector-tile-layer.ts +0 -113
  104. package/src/lib/binary-vector-tile/vector-tile.ts +0 -36
  105. package/src/lib/geojson-tiler/geojson-tiler.ts +0 -283
  106. package/src/lib/mapbox-vector-tile/LICENSE.txt +0 -31
  107. package/src/lib/mapbox-vector-tile/vector-tile-feature.ts +0 -207
  108. /package/dist/lib/{mapbox-vector-tile → vector-tile}/vector-tile.d.ts +0 -0
  109. /package/dist/lib/{mapbox-vector-tile → vector-tile}/vector-tile.js +0 -0
  110. /package/dist/lib/{geojson-tiler → vector-tiler}/clip.js +0 -0
  111. /package/dist/lib/{geojson-tiler → vector-tiler}/feature.js +0 -0
  112. /package/dist/lib/{geojson-tiler → vector-tiler}/simplify.d.ts +0 -0
  113. /package/dist/lib/{geojson-tiler → vector-tiler}/simplify.js +0 -0
  114. /package/dist/lib/{geojson-tiler → vector-tiler}/tile.js +0 -0
  115. /package/dist/lib/{geojson-tiler → vector-tiler}/transform.js +0 -0
  116. /package/dist/lib/{geojson-tiler → vector-tiler}/wrap.js +0 -0
  117. /package/src/lib/{binary-vector-tile → vector-tile}/LICENSE.txt +0 -0
  118. /package/src/lib/{mapbox-vector-tile → vector-tile}/vector-tile.ts +0 -0
  119. /package/src/lib/{geojson-tiler → vector-tiler}/LICENSE +0 -0
  120. /package/src/lib/{geojson-tiler → vector-tiler}/simplify.ts +0 -0
@@ -6,6 +6,7 @@
6
6
  var __getOwnPropNames = Object.getOwnPropertyNames;
7
7
  var __getProtoOf = Object.getPrototypeOf;
8
8
  var __hasOwnProp = Object.prototype.hasOwnProperty;
9
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
9
10
  var __commonJS = (cb, mod) => function __require() {
10
11
  return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
11
12
  };
@@ -25,6 +26,10 @@
25
26
  isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
27
  mod
27
28
  ));
29
+ var __publicField = (obj, key, value) => {
30
+ __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
31
+ return value;
32
+ };
28
33
 
29
34
  // ../../node_modules/ieee754/index.js
30
35
  var require_ieee754 = __commonJS({
@@ -35,19 +40,19 @@
35
40
  var eMax = (1 << eLen) - 1;
36
41
  var eBias = eMax >> 1;
37
42
  var nBits = -7;
38
- var i2 = isLE ? nBytes - 1 : 0;
43
+ var i = isLE ? nBytes - 1 : 0;
39
44
  var d = isLE ? -1 : 1;
40
- var s = buffer[offset + i2];
41
- i2 += d;
45
+ var s = buffer[offset + i];
46
+ i += d;
42
47
  e = s & (1 << -nBits) - 1;
43
48
  s >>= -nBits;
44
49
  nBits += eLen;
45
- for (; nBits > 0; e = e * 256 + buffer[offset + i2], i2 += d, nBits -= 8) {
50
+ for (; nBits > 0; e = e * 256 + buffer[offset + i], i += d, nBits -= 8) {
46
51
  }
47
52
  m = e & (1 << -nBits) - 1;
48
53
  e >>= -nBits;
49
54
  nBits += mLen;
50
- for (; nBits > 0; m = m * 256 + buffer[offset + i2], i2 += d, nBits -= 8) {
55
+ for (; nBits > 0; m = m * 256 + buffer[offset + i], i += d, nBits -= 8) {
51
56
  }
52
57
  if (e === 0) {
53
58
  e = 1 - eBias;
@@ -65,7 +70,7 @@
65
70
  var eMax = (1 << eLen) - 1;
66
71
  var eBias = eMax >> 1;
67
72
  var rt = mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0;
68
- var i2 = isLE ? 0 : nBytes - 1;
73
+ var i = isLE ? 0 : nBytes - 1;
69
74
  var d = isLE ? 1 : -1;
70
75
  var s = value < 0 || value === 0 && 1 / value < 0 ? 1 : 0;
71
76
  value = Math.abs(value);
@@ -98,13 +103,13 @@
98
103
  e = 0;
99
104
  }
100
105
  }
101
- for (; mLen >= 8; buffer[offset + i2] = m & 255, i2 += d, m /= 256, mLen -= 8) {
106
+ for (; mLen >= 8; buffer[offset + i] = m & 255, i += d, m /= 256, mLen -= 8) {
102
107
  }
103
108
  e = e << mLen | m;
104
109
  eLen += mLen;
105
- for (; eLen > 0; buffer[offset + i2] = e & 255, i2 += d, e /= 256, eLen -= 8) {
110
+ for (; eLen > 0; buffer[offset + i] = e & 255, i += d, e /= 256, eLen -= 8) {
106
111
  }
107
- buffer[offset + i2 - d] |= s * 128;
112
+ buffer[offset + i - d] |= s * 128;
108
113
  };
109
114
  }
110
115
  });
@@ -326,14 +331,14 @@
326
331
  this.writeVarint(tag << 3 | type);
327
332
  },
328
333
  realloc: function(min) {
329
- var length2 = this.length || 16;
330
- while (length2 < this.pos + min)
331
- length2 *= 2;
332
- if (length2 !== this.length) {
333
- var buf = new Uint8Array(length2);
334
+ var length = this.length || 16;
335
+ while (length < this.pos + min)
336
+ length *= 2;
337
+ if (length !== this.length) {
338
+ var buf = new Uint8Array(length);
334
339
  buf.set(this.buf);
335
340
  this.buf = buf;
336
- this.length = length2;
341
+ this.length = length;
337
342
  }
338
343
  },
339
344
  finish: function() {
@@ -414,8 +419,8 @@
414
419
  var len = buffer.length;
415
420
  this.writeVarint(len);
416
421
  this.realloc(len);
417
- for (var i2 = 0; i2 < len; i2++)
418
- this.buf[this.pos++] = buffer[i2];
422
+ for (var i = 0; i < len; i++)
423
+ this.buf[this.pos++] = buffer[i];
419
424
  },
420
425
  writeRawMessage: function(fn, obj) {
421
426
  this.pos++;
@@ -604,44 +609,44 @@
604
609
  function makeRoomForExtraLength(startPos, len, pbf) {
605
610
  var extraLen = len <= 16383 ? 1 : len <= 2097151 ? 2 : len <= 268435455 ? 3 : Math.floor(Math.log(len) / (Math.LN2 * 7));
606
611
  pbf.realloc(extraLen);
607
- for (var i2 = pbf.pos - 1; i2 >= startPos; i2--)
608
- pbf.buf[i2 + extraLen] = pbf.buf[i2];
612
+ for (var i = pbf.pos - 1; i >= startPos; i--)
613
+ pbf.buf[i + extraLen] = pbf.buf[i];
609
614
  }
610
615
  function writePackedVarint(arr, pbf) {
611
- for (var i2 = 0; i2 < arr.length; i2++)
612
- pbf.writeVarint(arr[i2]);
616
+ for (var i = 0; i < arr.length; i++)
617
+ pbf.writeVarint(arr[i]);
613
618
  }
614
619
  function writePackedSVarint(arr, pbf) {
615
- for (var i2 = 0; i2 < arr.length; i2++)
616
- pbf.writeSVarint(arr[i2]);
620
+ for (var i = 0; i < arr.length; i++)
621
+ pbf.writeSVarint(arr[i]);
617
622
  }
618
623
  function writePackedFloat(arr, pbf) {
619
- for (var i2 = 0; i2 < arr.length; i2++)
620
- pbf.writeFloat(arr[i2]);
624
+ for (var i = 0; i < arr.length; i++)
625
+ pbf.writeFloat(arr[i]);
621
626
  }
622
627
  function writePackedDouble(arr, pbf) {
623
- for (var i2 = 0; i2 < arr.length; i2++)
624
- pbf.writeDouble(arr[i2]);
628
+ for (var i = 0; i < arr.length; i++)
629
+ pbf.writeDouble(arr[i]);
625
630
  }
626
631
  function writePackedBoolean(arr, pbf) {
627
- for (var i2 = 0; i2 < arr.length; i2++)
628
- pbf.writeBoolean(arr[i2]);
632
+ for (var i = 0; i < arr.length; i++)
633
+ pbf.writeBoolean(arr[i]);
629
634
  }
630
635
  function writePackedFixed32(arr, pbf) {
631
- for (var i2 = 0; i2 < arr.length; i2++)
632
- pbf.writeFixed32(arr[i2]);
636
+ for (var i = 0; i < arr.length; i++)
637
+ pbf.writeFixed32(arr[i]);
633
638
  }
634
639
  function writePackedSFixed32(arr, pbf) {
635
- for (var i2 = 0; i2 < arr.length; i2++)
636
- pbf.writeSFixed32(arr[i2]);
640
+ for (var i = 0; i < arr.length; i++)
641
+ pbf.writeSFixed32(arr[i]);
637
642
  }
638
643
  function writePackedFixed64(arr, pbf) {
639
- for (var i2 = 0; i2 < arr.length; i2++)
640
- pbf.writeFixed64(arr[i2]);
644
+ for (var i = 0; i < arr.length; i++)
645
+ pbf.writeFixed64(arr[i]);
641
646
  }
642
647
  function writePackedSFixed64(arr, pbf) {
643
- for (var i2 = 0; i2 < arr.length; i2++)
644
- pbf.writeSFixed64(arr[i2]);
648
+ for (var i = 0; i < arr.length; i++)
649
+ pbf.writeSFixed64(arr[i]);
645
650
  }
646
651
  function readUInt32(buf, pos) {
647
652
  return (buf[pos] | buf[pos + 1] << 8 | buf[pos + 2] << 16) + buf[pos + 3] * 16777216;
@@ -657,12 +662,12 @@
657
662
  }
658
663
  function readUtf8(buf, pos, end) {
659
664
  var str = "";
660
- var i2 = pos;
661
- while (i2 < end) {
662
- var b0 = buf[i2];
665
+ var i = pos;
666
+ while (i < end) {
667
+ var b0 = buf[i];
663
668
  var c = null;
664
669
  var bytesPerSequence = b0 > 239 ? 4 : b0 > 223 ? 3 : b0 > 191 ? 2 : 1;
665
- if (i2 + bytesPerSequence > end)
670
+ if (i + bytesPerSequence > end)
666
671
  break;
667
672
  var b1, b2, b3;
668
673
  if (bytesPerSequence === 1) {
@@ -670,7 +675,7 @@
670
675
  c = b0;
671
676
  }
672
677
  } else if (bytesPerSequence === 2) {
673
- b1 = buf[i2 + 1];
678
+ b1 = buf[i + 1];
674
679
  if ((b1 & 192) === 128) {
675
680
  c = (b0 & 31) << 6 | b1 & 63;
676
681
  if (c <= 127) {
@@ -678,8 +683,8 @@
678
683
  }
679
684
  }
680
685
  } else if (bytesPerSequence === 3) {
681
- b1 = buf[i2 + 1];
682
- b2 = buf[i2 + 2];
686
+ b1 = buf[i + 1];
687
+ b2 = buf[i + 2];
683
688
  if ((b1 & 192) === 128 && (b2 & 192) === 128) {
684
689
  c = (b0 & 15) << 12 | (b1 & 63) << 6 | b2 & 63;
685
690
  if (c <= 2047 || c >= 55296 && c <= 57343) {
@@ -687,9 +692,9 @@
687
692
  }
688
693
  }
689
694
  } else if (bytesPerSequence === 4) {
690
- b1 = buf[i2 + 1];
691
- b2 = buf[i2 + 2];
692
- b3 = buf[i2 + 3];
695
+ b1 = buf[i + 1];
696
+ b2 = buf[i + 2];
697
+ b3 = buf[i + 3];
693
698
  if ((b1 & 192) === 128 && (b2 & 192) === 128 && (b3 & 192) === 128) {
694
699
  c = (b0 & 15) << 18 | (b1 & 63) << 12 | (b2 & 63) << 6 | b3 & 63;
695
700
  if (c <= 65535 || c >= 1114112) {
@@ -706,7 +711,7 @@
706
711
  c = 56320 | c & 1023;
707
712
  }
708
713
  str += String.fromCharCode(c);
709
- i2 += bytesPerSequence;
714
+ i += bytesPerSequence;
710
715
  }
711
716
  return str;
712
717
  }
@@ -714,8 +719,8 @@
714
719
  return utf8TextDecoder.decode(buf.subarray(pos, end));
715
720
  }
716
721
  function writeUtf8(buf, str, pos) {
717
- for (var i2 = 0, c, lead; i2 < str.length; i2++) {
718
- c = str.charCodeAt(i2);
722
+ for (var i = 0, c, lead; i < str.length; i++) {
723
+ c = str.charCodeAt(i);
719
724
  if (c > 55295 && c < 57344) {
720
725
  if (lead) {
721
726
  if (c < 56320) {
@@ -729,7 +734,7 @@
729
734
  lead = null;
730
735
  }
731
736
  } else {
732
- if (c > 56319 || i2 + 1 === str.length) {
737
+ if (c > 56319 || i + 1 === str.length) {
733
738
  buf[pos++] = 239;
734
739
  buf[pos++] = 191;
735
740
  buf[pos++] = 189;
@@ -828,9 +833,9 @@
828
833
  let area2 = 0;
829
834
  const i0 = DimIndex[plane[0]];
830
835
  const i1 = DimIndex[plane[1]];
831
- for (let i2 = start, j = end - dim; i2 < end; i2 += dim) {
832
- area2 += (points[i2 + i0] - points[j + i0]) * (points[i2 + i1] + points[j + i1]);
833
- j = i2;
836
+ for (let i = start, j = end - dim; i < end; i += dim) {
837
+ area2 += (points[i + i0] - points[j + i0]) * (points[i + i1] + points[j + i1]);
838
+ j = i;
834
839
  }
835
840
  return area2 / 2;
836
841
  }
@@ -848,24 +853,24 @@
848
853
  let maxY;
849
854
  let minX;
850
855
  let minY;
851
- let x2;
852
- let y2;
856
+ let x;
857
+ let y;
853
858
  if (hasHoles)
854
859
  outerNode = eliminateHoles(positions, holeIndices, outerNode, dim, areas, plane);
855
860
  if (positions.length > 80 * dim) {
856
861
  minX = maxX = positions[0];
857
862
  minY = maxY = positions[1];
858
- for (let i2 = dim; i2 < outerLen; i2 += dim) {
859
- x2 = positions[i2];
860
- y2 = positions[i2 + 1];
861
- if (x2 < minX)
862
- minX = x2;
863
- if (y2 < minY)
864
- minY = y2;
865
- if (x2 > maxX)
866
- maxX = x2;
867
- if (y2 > maxY)
868
- maxY = y2;
863
+ for (let i = dim; i < outerLen; i += dim) {
864
+ x = positions[i];
865
+ y = positions[i + 1];
866
+ if (x < minX)
867
+ minX = x;
868
+ if (y < minY)
869
+ minY = y;
870
+ if (x > maxX)
871
+ maxX = x;
872
+ if (y > maxY)
873
+ maxY = y;
869
874
  }
870
875
  invSize = Math.max(maxX - minX, maxY - minY);
871
876
  invSize = invSize !== 0 ? 32767 / invSize : 0;
@@ -874,7 +879,7 @@
874
879
  return triangles;
875
880
  }
876
881
  function linkedList(data, start, end, dim, clockwise, area2, plane) {
877
- let i2;
882
+ let i;
878
883
  let last;
879
884
  if (area2 === void 0) {
880
885
  area2 = getPolygonSignedArea(data, {
@@ -887,11 +892,11 @@
887
892
  let i0 = DimIndex[plane[0]];
888
893
  let i1 = DimIndex[plane[1]];
889
894
  if (clockwise === area2 < 0) {
890
- for (i2 = start; i2 < end; i2 += dim)
891
- last = insertNode(i2, data[i2 + i0], data[i2 + i1], last);
895
+ for (i = start; i < end; i += dim)
896
+ last = insertNode(i, data[i + i0], data[i + i1], last);
892
897
  } else {
893
- for (i2 = end - dim; i2 >= start; i2 -= dim)
894
- last = insertNode(i2, data[i2 + i0], data[i2 + i1], last);
898
+ for (i = end - dim; i >= start; i -= dim)
899
+ last = insertNode(i, data[i + i0], data[i + i1], last);
895
900
  }
896
901
  if (last && equals(last, last.next)) {
897
902
  removeNode(last);
@@ -1055,22 +1060,22 @@
1055
1060
  }
1056
1061
  function eliminateHoles(data, holeIndices, outerNode, dim, areas, plane) {
1057
1062
  const queue = [];
1058
- let i2;
1063
+ let i;
1059
1064
  let len;
1060
1065
  let start;
1061
1066
  let end;
1062
1067
  let list;
1063
- for (i2 = 0, len = holeIndices.length; i2 < len; i2++) {
1064
- start = holeIndices[i2] * dim;
1065
- end = i2 < len - 1 ? holeIndices[i2 + 1] * dim : data.length;
1066
- list = linkedList(data, start, end, dim, false, areas && areas[i2 + 1], plane);
1068
+ for (i = 0, len = holeIndices.length; i < len; i++) {
1069
+ start = holeIndices[i] * dim;
1070
+ end = i < len - 1 ? holeIndices[i + 1] * dim : data.length;
1071
+ list = linkedList(data, start, end, dim, false, areas && areas[i + 1], plane);
1067
1072
  if (list === list.next)
1068
1073
  list.steiner = true;
1069
1074
  queue.push(getLeftmost(list));
1070
1075
  }
1071
1076
  queue.sort(compareX);
1072
- for (i2 = 0; i2 < queue.length; i2++) {
1073
- outerNode = eliminateHole(queue[i2], outerNode);
1077
+ for (i = 0; i < queue.length; i++) {
1078
+ outerNode = eliminateHole(queue[i], outerNode);
1074
1079
  }
1075
1080
  return outerNode;
1076
1081
  }
@@ -1094,11 +1099,11 @@
1094
1099
  let m;
1095
1100
  do {
1096
1101
  if (hy <= p.y && hy >= p.next.y && p.next.y !== p.y) {
1097
- const x2 = p.x + (hy - p.y) * (p.next.x - p.x) / (p.next.y - p.y);
1098
- if (x2 <= hx && x2 > qx) {
1099
- qx = x2;
1102
+ const x = p.x + (hy - p.y) * (p.next.x - p.x) / (p.next.y - p.y);
1103
+ if (x <= hx && x > qx) {
1104
+ qx = x;
1100
1105
  m = p.x < p.next.x ? p : p.next;
1101
- if (x2 === hx)
1106
+ if (x === hx)
1102
1107
  return m;
1103
1108
  }
1104
1109
  }
@@ -1142,7 +1147,7 @@
1142
1147
  }
1143
1148
  function sortLinked(list) {
1144
1149
  let e;
1145
- let i2;
1150
+ let i;
1146
1151
  let inSize = 1;
1147
1152
  let numMerges;
1148
1153
  let p;
@@ -1159,7 +1164,7 @@
1159
1164
  numMerges++;
1160
1165
  q = p;
1161
1166
  pSize = 0;
1162
- for (i2 = 0; i2 < inSize; i2++) {
1167
+ for (i = 0; i < inSize; i++) {
1163
1168
  pSize++;
1164
1169
  q = q.nextZ;
1165
1170
  if (!q)
@@ -1190,18 +1195,18 @@
1190
1195
  } while (numMerges > 1);
1191
1196
  return list;
1192
1197
  }
1193
- function zOrder(x2, y2, minX, minY, invSize) {
1194
- x2 = (x2 - minX) * invSize | 0;
1195
- y2 = (y2 - minY) * invSize | 0;
1196
- x2 = (x2 | x2 << 8) & 16711935;
1197
- x2 = (x2 | x2 << 4) & 252645135;
1198
- x2 = (x2 | x2 << 2) & 858993459;
1199
- x2 = (x2 | x2 << 1) & 1431655765;
1200
- y2 = (y2 | y2 << 8) & 16711935;
1201
- y2 = (y2 | y2 << 4) & 252645135;
1202
- y2 = (y2 | y2 << 2) & 858993459;
1203
- y2 = (y2 | y2 << 1) & 1431655765;
1204
- return x2 | y2 << 1;
1198
+ function zOrder(x, y, minX, minY, invSize) {
1199
+ x = (x - minX) * invSize | 0;
1200
+ y = (y - minY) * invSize | 0;
1201
+ x = (x | x << 8) & 16711935;
1202
+ x = (x | x << 4) & 252645135;
1203
+ x = (x | x << 2) & 858993459;
1204
+ x = (x | x << 1) & 1431655765;
1205
+ y = (y | y << 8) & 16711935;
1206
+ y = (y | y << 4) & 252645135;
1207
+ y = (y | y << 2) & 858993459;
1208
+ y = (y | y << 1) & 1431655765;
1209
+ return x | y << 1;
1205
1210
  }
1206
1211
  function getLeftmost(start) {
1207
1212
  let p = start;
@@ -1287,8 +1292,8 @@
1287
1292
  b2.prev = bp;
1288
1293
  return b2;
1289
1294
  }
1290
- function insertNode(i2, x2, y2, last) {
1291
- const p = new Vertex(i2, x2, y2);
1295
+ function insertNode(i, x, y, last) {
1296
+ const p = new Vertex(i, x, y);
1292
1297
  if (!last) {
1293
1298
  p.prev = p;
1294
1299
  p.next = p;
@@ -1309,7 +1314,7 @@
1309
1314
  p.nextZ.prevZ = p.prevZ;
1310
1315
  }
1311
1316
  var Vertex = class {
1312
- constructor(i2, x2, y2) {
1317
+ constructor(i, x, y) {
1313
1318
  _defineProperty(this, "i", void 0);
1314
1319
  _defineProperty(this, "x", void 0);
1315
1320
  _defineProperty(this, "y", void 0);
@@ -1319,9 +1324,9 @@
1319
1324
  _defineProperty(this, "prevZ", null);
1320
1325
  _defineProperty(this, "nextZ", null);
1321
1326
  _defineProperty(this, "steiner", false);
1322
- this.i = i2;
1323
- this.x = x2;
1324
- this.y = y2;
1327
+ this.i = i;
1328
+ this.x = x;
1329
+ this.y = y;
1325
1330
  }
1326
1331
  };
1327
1332
 
@@ -1490,9 +1495,9 @@
1490
1495
  indexMap.linePosition,
1491
1496
  indexMap.linePosition + nPositions
1492
1497
  );
1493
- for (let i2 = 0, il = geometry.indices.length; i2 < il; ++i2) {
1494
- const start = geometry.indices[i2];
1495
- const end = i2 === il - 1 ? geometry.data.length : geometry.indices[i2 + 1];
1498
+ for (let i = 0, il = geometry.indices.length; i < il; ++i) {
1499
+ const start = geometry.indices[i];
1500
+ const end = i === il - 1 ? geometry.data.length : geometry.indices[i + 1];
1496
1501
  lines.pathIndices[indexMap.linePath++] = indexMap.linePosition;
1497
1502
  indexMap.linePosition += (end - start) / coordLength;
1498
1503
  }
@@ -1517,12 +1522,12 @@
1517
1522
  const areas = geometry.areas[l];
1518
1523
  const indices = geometry.indices[l];
1519
1524
  const nextIndices = geometry.indices[l + 1];
1520
- for (let i2 = 0, il = indices.length; i2 < il; ++i2) {
1521
- const start = indices[i2];
1522
- const end = i2 === il - 1 ? (
1525
+ for (let i = 0, il = indices.length; i < il; ++i) {
1526
+ const start = indices[i];
1527
+ const end = i === il - 1 ? (
1523
1528
  // last line, so either read to:
1524
1529
  nextIndices === void 0 ? geometry.data.length : nextIndices[0]
1525
- ) : indices[i2 + 1];
1530
+ ) : indices[i + 1];
1526
1531
  polygons.primitivePolygonIndices[indexMap.polygonRing++] = indexMap.polygonPosition;
1527
1532
  indexMap.polygonPosition += (end - start) / coordLength;
1528
1533
  }
@@ -1589,11 +1594,11 @@
1589
1594
  }
1590
1595
  return binaryFeatures;
1591
1596
  }
1592
- function fillNumericProperties(object, properties, index, length2) {
1597
+ function fillNumericProperties(object, properties, index, length) {
1593
1598
  for (const numericPropName in object.numericProps) {
1594
1599
  if (numericPropName in properties) {
1595
1600
  const value = properties[numericPropName];
1596
- object.numericProps[numericPropName].fill(value, index, index + length2);
1601
+ object.numericProps[numericPropName].fill(value, index, index + length);
1597
1602
  }
1598
1603
  }
1599
1604
  }
@@ -1606,405 +1611,887 @@
1606
1611
  }
1607
1612
  return props;
1608
1613
  }
1609
- function deduceArrayType(x2, constructor) {
1610
- if (constructor === Array || !Number.isFinite(x2)) {
1614
+ function deduceArrayType(x, constructor) {
1615
+ if (constructor === Array || !Number.isFinite(x)) {
1611
1616
  return Array;
1612
1617
  }
1613
- return constructor === Float64Array || Math.fround(x2) !== x2 ? Float64Array : Float32Array;
1618
+ return constructor === Float64Array || Math.fround(x) !== x ? Float64Array : Float32Array;
1614
1619
  }
1615
1620
 
1616
- // src/lib/parse-mvt.ts
1617
- var import_pbf = __toESM(require_pbf(), 1);
1618
-
1619
- // src/helpers/mapbox-util-functions.ts
1620
- function classifyRings(rings) {
1621
- const len = rings.length;
1622
- if (len <= 1)
1623
- return [rings];
1624
- const polygons = [];
1625
- let polygon;
1626
- let ccw;
1627
- for (let i2 = 0; i2 < len; i2++) {
1628
- const area2 = signedArea(rings[i2]);
1629
- if (area2 === 0)
1630
- continue;
1631
- if (ccw === void 0)
1632
- ccw = area2 < 0;
1633
- if (ccw === area2 < 0) {
1634
- if (polygon)
1635
- polygons.push(polygon);
1636
- polygon = [rings[i2]];
1637
- } else if (polygon)
1638
- polygon.push(rings[i2]);
1621
+ // ../../node_modules/@probe.gl/log/node_modules/@probe.gl/env/dist/lib/is-electron.js
1622
+ function isElectron(mockUserAgent) {
1623
+ if (typeof window !== "undefined" && typeof window.process === "object" && window.process.type === "renderer") {
1624
+ return true;
1639
1625
  }
1640
- if (polygon)
1641
- polygons.push(polygon);
1642
- return polygons;
1643
- }
1644
- function signedArea(ring) {
1645
- let sum = 0;
1646
- for (let i2 = 0, j = ring.length - 1, p1, p2; i2 < ring.length; j = i2++) {
1647
- p1 = ring[i2];
1648
- p2 = ring[j];
1649
- sum += (p2[0] - p1[0]) * (p1[1] + p2[1]);
1626
+ if (typeof process !== "undefined" && typeof process.versions === "object" && Boolean(process.versions["electron"])) {
1627
+ return true;
1650
1628
  }
1651
- return sum;
1652
- }
1653
- function readFeature(tag, feature, pbf) {
1654
- if (feature && pbf) {
1655
- if (tag === 1)
1656
- feature.id = pbf.readVarint();
1657
- else if (tag === 2)
1658
- readTag(pbf, feature);
1659
- else if (tag === 3)
1660
- feature.type = pbf.readVarint();
1661
- else if (tag === 4)
1662
- feature._geometry = pbf.pos;
1629
+ const realUserAgent = typeof navigator === "object" && typeof navigator.userAgent === "string" && navigator.userAgent;
1630
+ const userAgent = mockUserAgent || realUserAgent;
1631
+ if (userAgent && userAgent.indexOf("Electron") >= 0) {
1632
+ return true;
1663
1633
  }
1634
+ return false;
1664
1635
  }
1665
- function readTag(pbf, feature) {
1666
- const end = pbf.readVarint() + pbf.pos;
1667
- while (pbf.pos < end) {
1668
- const key = feature._keys[pbf.readVarint()];
1669
- const value = feature._values[pbf.readVarint()];
1670
- feature.properties[key] = value;
1671
- }
1636
+
1637
+ // ../../node_modules/@probe.gl/log/node_modules/@probe.gl/env/dist/lib/is-browser.js
1638
+ function isBrowser() {
1639
+ const isNode = typeof process === "object" && String(process) === "[object process]" && !process.browser;
1640
+ return !isNode || isElectron();
1672
1641
  }
1673
1642
 
1674
- // src/lib/mapbox-vector-tile/vector-tile-feature.ts
1675
- var VectorTileFeature = class {
1676
- properties;
1677
- extent;
1678
- type;
1679
- id;
1680
- _pbf;
1681
- _geometry;
1682
- _keys;
1683
- _values;
1684
- static get types() {
1685
- return ["Unknown", "Point", "LineString", "Polygon"];
1686
- }
1687
- constructor(pbf, end, extent, keys, values) {
1688
- this.properties = {};
1689
- this.extent = extent;
1690
- this.type = 0;
1691
- this.id = null;
1692
- this._pbf = pbf;
1693
- this._geometry = -1;
1694
- this._keys = keys;
1695
- this._values = values;
1696
- pbf.readFields(readFeature, this, end);
1643
+ // ../../node_modules/@probe.gl/log/node_modules/@probe.gl/env/dist/lib/globals.js
1644
+ var self_ = globalThis.self || globalThis.window || globalThis.global;
1645
+ var window_ = globalThis.window || globalThis.self || globalThis.global;
1646
+ var document_ = globalThis.document || {};
1647
+ var process_ = globalThis.process || {};
1648
+ var console_ = globalThis.console;
1649
+ var navigator_ = globalThis.navigator || {};
1650
+
1651
+ // ../../node_modules/@probe.gl/log/node_modules/@probe.gl/env/dist/utils/globals.js
1652
+ var VERSION = true ? "4.3.0-alpha.1" : "untranspiled source";
1653
+ var isBrowser2 = isBrowser();
1654
+
1655
+ // ../../node_modules/@probe.gl/log/dist/utils/local-storage.js
1656
+ function getStorage(type) {
1657
+ try {
1658
+ const storage = window[type];
1659
+ const x = "__storage_test__";
1660
+ storage.setItem(x, x);
1661
+ storage.removeItem(x);
1662
+ return storage;
1663
+ } catch (e) {
1664
+ return null;
1697
1665
  }
1698
- // eslint-disable-next-line complexity, max-statements
1699
- loadGeometry() {
1700
- const pbf = this._pbf;
1701
- pbf.pos = this._geometry;
1702
- const end = pbf.readVarint() + pbf.pos;
1703
- let cmd2 = 1;
1704
- let length2 = 0;
1705
- let x2 = 0;
1706
- let y2 = 0;
1707
- const lines = [];
1708
- let line;
1709
- while (pbf.pos < end) {
1710
- if (length2 <= 0) {
1711
- const cmdLen2 = pbf.readVarint();
1712
- cmd2 = cmdLen2 & 7;
1713
- length2 = cmdLen2 >> 3;
1714
- }
1715
- length2--;
1716
- if (cmd2 === 1 || cmd2 === 2) {
1717
- x2 += pbf.readSVarint();
1718
- y2 += pbf.readSVarint();
1719
- if (cmd2 === 1) {
1720
- if (line)
1721
- lines.push(line);
1722
- line = [];
1723
- }
1724
- if (line)
1725
- line.push([x2, y2]);
1726
- } else if (cmd2 === 7) {
1727
- if (line) {
1728
- line.push(line[0].slice());
1729
- }
1730
- } else {
1731
- throw new Error(`unknown command ${cmd2}`);
1732
- }
1733
- }
1734
- if (line)
1735
- lines.push(line);
1736
- return lines;
1666
+ }
1667
+ var LocalStorage = class {
1668
+ constructor(id, defaultConfig) {
1669
+ let type = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : "sessionStorage";
1670
+ _defineProperty(this, "storage", void 0);
1671
+ _defineProperty(this, "id", void 0);
1672
+ _defineProperty(this, "config", void 0);
1673
+ this.storage = getStorage(type);
1674
+ this.id = id;
1675
+ this.config = defaultConfig;
1676
+ this._loadConfiguration();
1737
1677
  }
1738
- // eslint-disable-next-line max-statements
1739
- bbox() {
1740
- const pbf = this._pbf;
1741
- pbf.pos = this._geometry;
1742
- const end = pbf.readVarint() + pbf.pos;
1743
- let cmd2 = 1;
1744
- let length2 = 0;
1745
- let x2 = 0;
1746
- let y2 = 0;
1747
- let x1 = Infinity;
1748
- let x22 = -Infinity;
1749
- let y1 = Infinity;
1750
- let y22 = -Infinity;
1751
- while (pbf.pos < end) {
1752
- if (length2 <= 0) {
1753
- const cmdLen2 = pbf.readVarint();
1754
- cmd2 = cmdLen2 & 7;
1755
- length2 = cmdLen2 >> 3;
1756
- }
1757
- length2--;
1758
- if (cmd2 === 1 || cmd2 === 2) {
1759
- x2 += pbf.readSVarint();
1760
- y2 += pbf.readSVarint();
1761
- if (x2 < x1)
1762
- x1 = x2;
1763
- if (x2 > x22)
1764
- x22 = x2;
1765
- if (y2 < y1)
1766
- y1 = y2;
1767
- if (y2 > y22)
1768
- y22 = y2;
1769
- } else if (cmd2 !== 7) {
1770
- throw new Error(`unknown command ${cmd2}`);
1771
- }
1772
- }
1773
- return [x1, y1, x22, y22];
1678
+ getConfiguration() {
1679
+ return this.config;
1774
1680
  }
1775
- _toGeoJSON(transform) {
1776
- let coords = this.loadGeometry();
1777
- let type = VectorTileFeature.types[this.type];
1778
- let i2;
1779
- let j;
1780
- switch (this.type) {
1781
- case 1:
1782
- const points = [];
1783
- for (i2 = 0; i2 < coords.length; i2++) {
1784
- points[i2] = coords[i2][0];
1785
- }
1786
- coords = points;
1787
- transform(coords, this);
1788
- break;
1789
- case 2:
1790
- for (i2 = 0; i2 < coords.length; i2++) {
1791
- transform(coords[i2], this);
1792
- }
1793
- break;
1794
- case 3:
1795
- coords = classifyRings(coords);
1796
- for (i2 = 0; i2 < coords.length; i2++) {
1797
- for (j = 0; j < coords[i2].length; j++) {
1798
- transform(coords[i2][j], this);
1799
- }
1800
- }
1801
- break;
1802
- }
1803
- if (coords.length === 1) {
1804
- coords = coords[0];
1805
- } else {
1806
- type = `Multi${type}`;
1807
- }
1808
- const result = {
1809
- type: "Feature",
1810
- geometry: {
1811
- type,
1812
- coordinates: coords
1813
- },
1814
- properties: this.properties
1815
- };
1816
- if (this.id !== null) {
1817
- result.id = this.id;
1681
+ setConfiguration(configuration) {
1682
+ Object.assign(this.config, configuration);
1683
+ if (this.storage) {
1684
+ const serialized = JSON.stringify(this.config);
1685
+ this.storage.setItem(this.id, serialized);
1818
1686
  }
1819
- return result;
1820
1687
  }
1821
- toGeoJSON(options) {
1822
- if (typeof options === "function") {
1823
- return this._toGeoJSON(options);
1824
- }
1825
- const { x: x2, y: y2, z } = options;
1826
- const size = this.extent * Math.pow(2, z);
1827
- const x0 = this.extent * x2;
1828
- const y0 = this.extent * y2;
1829
- function project2(line) {
1830
- for (let j = 0; j < line.length; j++) {
1831
- const p = line[j];
1832
- p[0] = (p[0] + x0) * 360 / size - 180;
1833
- const y22 = 180 - (p[1] + y0) * 360 / size;
1834
- p[1] = 360 / Math.PI * Math.atan(Math.exp(y22 * Math.PI / 180)) - 90;
1835
- }
1688
+ _loadConfiguration() {
1689
+ let configuration = {};
1690
+ if (this.storage) {
1691
+ const serializedConfiguration = this.storage.getItem(this.id);
1692
+ configuration = serializedConfiguration ? JSON.parse(serializedConfiguration) : {};
1836
1693
  }
1837
- return this._toGeoJSON(project2);
1694
+ Object.assign(this.config, configuration);
1695
+ return this;
1838
1696
  }
1839
1697
  };
1840
1698
 
1841
- // src/lib/mapbox-vector-tile/vector-tile-layer.ts
1842
- var VectorTileLayer = class {
1843
- version;
1844
- name;
1845
- extent;
1846
- length;
1847
- _pbf;
1848
- _keys;
1849
- _values;
1850
- _features;
1851
- constructor(pbf, end) {
1852
- this.version = 1;
1853
- this.name = "";
1854
- this.extent = 4096;
1855
- this.length = 0;
1856
- this._pbf = pbf;
1857
- this._keys = [];
1858
- this._values = [];
1859
- this._features = [];
1860
- pbf.readFields(readLayer, this, end);
1861
- this.length = this._features.length;
1862
- }
1863
- /**
1864
- * return feature `i` from this layer as a `VectorTileFeature`
1865
- * @param index
1866
- * @returns feature
1867
- */
1868
- feature(i2) {
1869
- if (i2 < 0 || i2 >= this._features.length) {
1870
- throw new Error("feature index out of bounds");
1871
- }
1872
- this._pbf.pos = this._features[i2];
1873
- const end = this._pbf.readVarint() + this._pbf.pos;
1874
- return new VectorTileFeature(this._pbf, end, this.extent, this._keys, this._values);
1875
- }
1876
- };
1877
- function readLayer(tag, layer, pbf) {
1878
- if (layer && pbf) {
1879
- if (tag === 15)
1880
- layer.version = pbf.readVarint();
1881
- else if (tag === 1)
1882
- layer.name = pbf.readString();
1883
- else if (tag === 5)
1884
- layer.extent = pbf.readVarint();
1885
- else if (tag === 2)
1886
- layer._features.push(pbf.pos);
1887
- else if (tag === 3)
1888
- layer._keys.push(pbf.readString());
1889
- else if (tag === 4)
1890
- layer._values.push(readValueMessage(pbf));
1699
+ // ../../node_modules/@probe.gl/log/dist/utils/formatters.js
1700
+ function formatTime(ms) {
1701
+ let formatted;
1702
+ if (ms < 10) {
1703
+ formatted = "".concat(ms.toFixed(2), "ms");
1704
+ } else if (ms < 100) {
1705
+ formatted = "".concat(ms.toFixed(1), "ms");
1706
+ } else if (ms < 1e3) {
1707
+ formatted = "".concat(ms.toFixed(0), "ms");
1708
+ } else {
1709
+ formatted = "".concat((ms / 1e3).toFixed(2), "s");
1891
1710
  }
1711
+ return formatted;
1892
1712
  }
1893
- function readValueMessage(pbf) {
1894
- let value = null;
1895
- const end = pbf.readVarint() + pbf.pos;
1896
- while (pbf.pos < end) {
1897
- const tag = pbf.readVarint() >> 3;
1898
- 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;
1713
+ function leftPad(string) {
1714
+ let length = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 8;
1715
+ const padLength = Math.max(length - string.length, 0);
1716
+ return "".concat(" ".repeat(padLength)).concat(string);
1717
+ }
1718
+ function formatImage(image, message, scale) {
1719
+ let maxWidth = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : 600;
1720
+ const imageUrl = image.src.replace(/\(/g, "%28").replace(/\)/g, "%29");
1721
+ if (image.width > maxWidth) {
1722
+ scale = Math.min(scale, maxWidth / image.width);
1899
1723
  }
1900
- return value;
1724
+ const width = image.width * scale;
1725
+ const height = image.height * scale;
1726
+ 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("");
1727
+ return ["".concat(message, " %c+"), style];
1901
1728
  }
1902
1729
 
1903
- // src/lib/mapbox-vector-tile/vector-tile.ts
1904
- var VectorTile = class {
1905
- layers;
1906
- constructor(pbf, end) {
1907
- this.layers = pbf.readFields(readTile, {}, end);
1908
- }
1909
- };
1910
- function readTile(tag, layers, pbf) {
1911
- if (tag === 3) {
1912
- if (pbf) {
1913
- const layer = new VectorTileLayer(pbf, pbf.readVarint() + pbf.pos);
1914
- if (layer.length && layers) {
1915
- layers[layer.name] = layer;
1730
+ // ../../node_modules/@probe.gl/log/dist/utils/color.js
1731
+ var COLOR;
1732
+ (function(COLOR2) {
1733
+ COLOR2[COLOR2["BLACK"] = 30] = "BLACK";
1734
+ COLOR2[COLOR2["RED"] = 31] = "RED";
1735
+ COLOR2[COLOR2["GREEN"] = 32] = "GREEN";
1736
+ COLOR2[COLOR2["YELLOW"] = 33] = "YELLOW";
1737
+ COLOR2[COLOR2["BLUE"] = 34] = "BLUE";
1738
+ COLOR2[COLOR2["MAGENTA"] = 35] = "MAGENTA";
1739
+ COLOR2[COLOR2["CYAN"] = 36] = "CYAN";
1740
+ COLOR2[COLOR2["WHITE"] = 37] = "WHITE";
1741
+ COLOR2[COLOR2["BRIGHT_BLACK"] = 90] = "BRIGHT_BLACK";
1742
+ COLOR2[COLOR2["BRIGHT_RED"] = 91] = "BRIGHT_RED";
1743
+ COLOR2[COLOR2["BRIGHT_GREEN"] = 92] = "BRIGHT_GREEN";
1744
+ COLOR2[COLOR2["BRIGHT_YELLOW"] = 93] = "BRIGHT_YELLOW";
1745
+ COLOR2[COLOR2["BRIGHT_BLUE"] = 94] = "BRIGHT_BLUE";
1746
+ COLOR2[COLOR2["BRIGHT_MAGENTA"] = 95] = "BRIGHT_MAGENTA";
1747
+ COLOR2[COLOR2["BRIGHT_CYAN"] = 96] = "BRIGHT_CYAN";
1748
+ COLOR2[COLOR2["BRIGHT_WHITE"] = 97] = "BRIGHT_WHITE";
1749
+ })(COLOR || (COLOR = {}));
1750
+ var BACKGROUND_INCREMENT = 10;
1751
+ function getColor(color) {
1752
+ if (typeof color !== "string") {
1753
+ return color;
1754
+ }
1755
+ color = color.toUpperCase();
1756
+ return COLOR[color] || COLOR.WHITE;
1757
+ }
1758
+ function addColor(string, color, background) {
1759
+ if (!isBrowser && typeof string === "string") {
1760
+ if (color) {
1761
+ const colorCode = getColor(color);
1762
+ string = "\x1B[".concat(colorCode, "m").concat(string, "\x1B[39m");
1763
+ }
1764
+ if (background) {
1765
+ const colorCode = getColor(background);
1766
+ string = "\x1B[".concat(colorCode + BACKGROUND_INCREMENT, "m").concat(string, "\x1B[49m");
1767
+ }
1768
+ }
1769
+ return string;
1770
+ }
1771
+
1772
+ // ../../node_modules/@probe.gl/log/dist/utils/autobind.js
1773
+ function autobind(obj) {
1774
+ let predefined = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : ["constructor"];
1775
+ const proto = Object.getPrototypeOf(obj);
1776
+ const propNames = Object.getOwnPropertyNames(proto);
1777
+ const object = obj;
1778
+ for (const key of propNames) {
1779
+ const value = object[key];
1780
+ if (typeof value === "function") {
1781
+ if (!predefined.find((name) => key === name)) {
1782
+ object[key] = value.bind(obj);
1916
1783
  }
1917
1784
  }
1918
1785
  }
1919
1786
  }
1920
1787
 
1921
- // src/helpers/binary-util-functions.ts
1922
- function classifyRings2(geom) {
1923
- const len = geom.indices.length;
1924
- const type = "Polygon";
1925
- if (len <= 1) {
1926
- return {
1927
- type,
1928
- data: geom.data,
1929
- areas: [[getPolygonSignedArea(geom.data)]],
1930
- indices: [geom.indices]
1788
+ // ../../node_modules/@probe.gl/log/dist/utils/assert.js
1789
+ function assert(condition, message) {
1790
+ if (!condition) {
1791
+ throw new Error(message || "Assertion failed");
1792
+ }
1793
+ }
1794
+
1795
+ // ../../node_modules/@probe.gl/log/dist/utils/hi-res-timestamp.js
1796
+ function getHiResTimestamp() {
1797
+ let timestamp;
1798
+ if (isBrowser() && window_.performance) {
1799
+ var _window$performance, _window$performance$n;
1800
+ timestamp = window_ === null || window_ === void 0 ? void 0 : (_window$performance = window_.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);
1801
+ } else if ("hrtime" in process_) {
1802
+ var _process$hrtime;
1803
+ const timeParts = process_ === null || process_ === void 0 ? void 0 : (_process$hrtime = process_.hrtime) === null || _process$hrtime === void 0 ? void 0 : _process$hrtime.call(process_);
1804
+ timestamp = timeParts[0] * 1e3 + timeParts[1] / 1e6;
1805
+ } else {
1806
+ timestamp = Date.now();
1807
+ }
1808
+ return timestamp;
1809
+ }
1810
+
1811
+ // ../../node_modules/@probe.gl/log/dist/log.js
1812
+ var originalConsole = {
1813
+ debug: isBrowser() ? console.debug || console.log : console.log,
1814
+ log: console.log,
1815
+ info: console.info,
1816
+ warn: console.warn,
1817
+ error: console.error
1818
+ };
1819
+ var DEFAULT_LOG_CONFIGURATION = {
1820
+ enabled: true,
1821
+ level: 0
1822
+ };
1823
+ function noop() {
1824
+ }
1825
+ var cache = {};
1826
+ var ONCE = {
1827
+ once: true
1828
+ };
1829
+ var Log = class {
1830
+ constructor() {
1831
+ let {
1832
+ id
1833
+ } = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {
1834
+ id: ""
1931
1835
  };
1836
+ _defineProperty(this, "id", void 0);
1837
+ _defineProperty(this, "VERSION", VERSION);
1838
+ _defineProperty(this, "_startTs", getHiResTimestamp());
1839
+ _defineProperty(this, "_deltaTs", getHiResTimestamp());
1840
+ _defineProperty(this, "_storage", void 0);
1841
+ _defineProperty(this, "userData", {});
1842
+ _defineProperty(this, "LOG_THROTTLE_TIMEOUT", 0);
1843
+ this.id = id;
1844
+ this.userData = {};
1845
+ this._storage = new LocalStorage("__probe-".concat(this.id, "__"), DEFAULT_LOG_CONFIGURATION);
1846
+ this.timeStamp("".concat(this.id, " started"));
1847
+ autobind(this);
1848
+ Object.seal(this);
1849
+ }
1850
+ set level(newLevel) {
1851
+ this.setLevel(newLevel);
1852
+ }
1853
+ get level() {
1854
+ return this.getLevel();
1855
+ }
1856
+ isEnabled() {
1857
+ return this._storage.config.enabled;
1858
+ }
1859
+ getLevel() {
1860
+ return this._storage.config.level;
1861
+ }
1862
+ getTotal() {
1863
+ return Number((getHiResTimestamp() - this._startTs).toPrecision(10));
1864
+ }
1865
+ getDelta() {
1866
+ return Number((getHiResTimestamp() - this._deltaTs).toPrecision(10));
1867
+ }
1868
+ set priority(newPriority) {
1869
+ this.level = newPriority;
1870
+ }
1871
+ get priority() {
1872
+ return this.level;
1873
+ }
1874
+ getPriority() {
1875
+ return this.level;
1876
+ }
1877
+ enable() {
1878
+ let enabled = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : true;
1879
+ this._storage.setConfiguration({
1880
+ enabled
1881
+ });
1882
+ return this;
1932
1883
  }
1933
- const areas = [];
1934
- const polygons = [];
1935
- let ringAreas = [];
1936
- let polygon = [];
1937
- let ccw;
1938
- let offset = 0;
1939
- for (let endIndex, i2 = 0, startIndex; i2 < len; i2++) {
1940
- startIndex = geom.indices[i2] - offset;
1941
- endIndex = geom.indices[i2 + 1] - offset || geom.data.length;
1942
- const shape = geom.data.slice(startIndex, endIndex);
1943
- const area2 = getPolygonSignedArea(shape);
1944
- if (area2 === 0) {
1945
- const before = geom.data.slice(0, startIndex);
1946
- const after = geom.data.slice(endIndex);
1947
- geom.data = before.concat(after);
1948
- offset += endIndex - startIndex;
1949
- continue;
1950
- }
1951
- if (ccw === void 0)
1952
- ccw = area2 < 0;
1953
- if (ccw === area2 < 0) {
1954
- if (polygon.length) {
1955
- areas.push(ringAreas);
1956
- polygons.push(polygon);
1957
- }
1958
- polygon = [startIndex];
1959
- ringAreas = [area2];
1884
+ setLevel(level) {
1885
+ this._storage.setConfiguration({
1886
+ level
1887
+ });
1888
+ return this;
1889
+ }
1890
+ get(setting) {
1891
+ return this._storage.config[setting];
1892
+ }
1893
+ set(setting, value) {
1894
+ this._storage.setConfiguration({
1895
+ [setting]: value
1896
+ });
1897
+ }
1898
+ settings() {
1899
+ if (console.table) {
1900
+ console.table(this._storage.config);
1960
1901
  } else {
1961
- ringAreas.push(area2);
1962
- polygon.push(startIndex);
1902
+ console.log(this._storage.config);
1963
1903
  }
1964
1904
  }
1965
- if (ringAreas)
1966
- areas.push(ringAreas);
1967
- if (polygon.length)
1968
- polygons.push(polygon);
1969
- return { type, areas, indices: polygons, data: geom.data };
1970
- }
1971
- function project(data, x0, y0, size) {
1972
- for (let j = 0, jl = data.length; j < jl; j += 2) {
1973
- data[j] = (data[j] + x0) * 360 / size - 180;
1974
- const y2 = 180 - (data[j + 1] + y0) * 360 / size;
1975
- data[j + 1] = 360 / Math.PI * Math.atan(Math.exp(y2 * Math.PI / 180)) - 90;
1905
+ assert(condition, message) {
1906
+ assert(condition, message);
1976
1907
  }
1977
- }
1978
- function readFeature2(tag, feature, pbf) {
1979
- if (feature && pbf) {
1980
- if (tag === 1)
1981
- feature.id = pbf.readVarint();
1982
- else if (tag === 2)
1983
- readTag2(pbf, feature);
1984
- else if (tag === 3)
1985
- feature.type = pbf.readVarint();
1986
- else if (tag === 4)
1987
- feature._geometry = pbf.pos;
1908
+ warn(message) {
1909
+ return this._getLogFunction(0, message, originalConsole.warn, arguments, ONCE);
1910
+ }
1911
+ error(message) {
1912
+ return this._getLogFunction(0, message, originalConsole.error, arguments);
1913
+ }
1914
+ deprecated(oldUsage, newUsage) {
1915
+ return this.warn("`".concat(oldUsage, "` is deprecated and will be removed in a later version. Use `").concat(newUsage, "` instead"));
1916
+ }
1917
+ removed(oldUsage, newUsage) {
1918
+ return this.error("`".concat(oldUsage, "` has been removed. Use `").concat(newUsage, "` instead"));
1919
+ }
1920
+ probe(logLevel, message) {
1921
+ return this._getLogFunction(logLevel, message, originalConsole.log, arguments, {
1922
+ time: true,
1923
+ once: true
1924
+ });
1925
+ }
1926
+ log(logLevel, message) {
1927
+ return this._getLogFunction(logLevel, message, originalConsole.debug, arguments);
1928
+ }
1929
+ info(logLevel, message) {
1930
+ return this._getLogFunction(logLevel, message, console.info, arguments);
1931
+ }
1932
+ once(logLevel, message) {
1933
+ return this._getLogFunction(logLevel, message, originalConsole.debug || originalConsole.info, arguments, ONCE);
1934
+ }
1935
+ table(logLevel, table, columns) {
1936
+ if (table) {
1937
+ return this._getLogFunction(logLevel, table, console.table || noop, columns && [columns], {
1938
+ tag: getTableHeader(table)
1939
+ });
1940
+ }
1941
+ return noop;
1942
+ }
1943
+ image(_ref) {
1944
+ let {
1945
+ logLevel,
1946
+ priority,
1947
+ image,
1948
+ message = "",
1949
+ scale = 1
1950
+ } = _ref;
1951
+ if (!this._shouldLog(logLevel || priority)) {
1952
+ return noop;
1953
+ }
1954
+ return isBrowser() ? logImageInBrowser({
1955
+ image,
1956
+ message,
1957
+ scale
1958
+ }) : logImageInNode({
1959
+ image,
1960
+ message,
1961
+ scale
1962
+ });
1963
+ }
1964
+ time(logLevel, message) {
1965
+ return this._getLogFunction(logLevel, message, console.time ? console.time : console.info);
1966
+ }
1967
+ timeEnd(logLevel, message) {
1968
+ return this._getLogFunction(logLevel, message, console.timeEnd ? console.timeEnd : console.info);
1969
+ }
1970
+ timeStamp(logLevel, message) {
1971
+ return this._getLogFunction(logLevel, message, console.timeStamp || noop);
1972
+ }
1973
+ group(logLevel, message) {
1974
+ let opts = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {
1975
+ collapsed: false
1976
+ };
1977
+ const options = normalizeArguments({
1978
+ logLevel,
1979
+ message,
1980
+ opts
1981
+ });
1982
+ const {
1983
+ collapsed
1984
+ } = opts;
1985
+ options.method = (collapsed ? console.groupCollapsed : console.group) || console.info;
1986
+ return this._getLogFunction(options);
1987
+ }
1988
+ groupCollapsed(logLevel, message) {
1989
+ let opts = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};
1990
+ return this.group(logLevel, message, Object.assign({}, opts, {
1991
+ collapsed: true
1992
+ }));
1993
+ }
1994
+ groupEnd(logLevel) {
1995
+ return this._getLogFunction(logLevel, "", console.groupEnd || noop);
1996
+ }
1997
+ withGroup(logLevel, message, func) {
1998
+ this.group(logLevel, message)();
1999
+ try {
2000
+ func();
2001
+ } finally {
2002
+ this.groupEnd(logLevel)();
2003
+ }
2004
+ }
2005
+ trace() {
2006
+ if (console.trace) {
2007
+ console.trace();
2008
+ }
2009
+ }
2010
+ _shouldLog(logLevel) {
2011
+ return this.isEnabled() && this.getLevel() >= normalizeLogLevel(logLevel);
2012
+ }
2013
+ _getLogFunction(logLevel, message, method, args, opts) {
2014
+ if (this._shouldLog(logLevel)) {
2015
+ opts = normalizeArguments({
2016
+ logLevel,
2017
+ message,
2018
+ args,
2019
+ opts
2020
+ });
2021
+ method = method || opts.method;
2022
+ assert(method);
2023
+ opts.total = this.getTotal();
2024
+ opts.delta = this.getDelta();
2025
+ this._deltaTs = getHiResTimestamp();
2026
+ const tag = opts.tag || opts.message;
2027
+ if (opts.once && tag) {
2028
+ if (!cache[tag]) {
2029
+ cache[tag] = getHiResTimestamp();
2030
+ } else {
2031
+ return noop;
2032
+ }
2033
+ }
2034
+ message = decorateMessage(this.id, opts.message, opts);
2035
+ return method.bind(console, message, ...opts.args);
2036
+ }
2037
+ return noop;
2038
+ }
2039
+ };
2040
+ _defineProperty(Log, "VERSION", VERSION);
2041
+ function normalizeLogLevel(logLevel) {
2042
+ if (!logLevel) {
2043
+ return 0;
2044
+ }
2045
+ let resolvedLevel;
2046
+ switch (typeof logLevel) {
2047
+ case "number":
2048
+ resolvedLevel = logLevel;
2049
+ break;
2050
+ case "object":
2051
+ resolvedLevel = logLevel.logLevel || logLevel.priority || 0;
2052
+ break;
2053
+ default:
2054
+ return 0;
1988
2055
  }
2056
+ assert(Number.isFinite(resolvedLevel) && resolvedLevel >= 0);
2057
+ return resolvedLevel;
1989
2058
  }
1990
- function readTag2(pbf, feature) {
1991
- const end = pbf.readVarint() + pbf.pos;
1992
- while (pbf.pos < end) {
1993
- const key = feature._keys[pbf.readVarint()];
1994
- const value = feature._values[pbf.readVarint()];
1995
- feature.properties[key] = value;
2059
+ function normalizeArguments(opts) {
2060
+ const {
2061
+ logLevel,
2062
+ message
2063
+ } = opts;
2064
+ opts.logLevel = normalizeLogLevel(logLevel);
2065
+ const args = opts.args ? Array.from(opts.args) : [];
2066
+ while (args.length && args.shift() !== message) {
2067
+ }
2068
+ switch (typeof logLevel) {
2069
+ case "string":
2070
+ case "function":
2071
+ if (message !== void 0) {
2072
+ args.unshift(message);
2073
+ }
2074
+ opts.message = logLevel;
2075
+ break;
2076
+ case "object":
2077
+ Object.assign(opts, logLevel);
2078
+ break;
2079
+ default:
2080
+ }
2081
+ if (typeof opts.message === "function") {
2082
+ opts.message = opts.message();
2083
+ }
2084
+ const messageType = typeof opts.message;
2085
+ assert(messageType === "string" || messageType === "object");
2086
+ return Object.assign(opts, {
2087
+ args
2088
+ }, opts.opts);
2089
+ }
2090
+ function decorateMessage(id, message, opts) {
2091
+ if (typeof message === "string") {
2092
+ const time = opts.time ? leftPad(formatTime(opts.total)) : "";
2093
+ message = opts.time ? "".concat(id, ": ").concat(time, " ").concat(message) : "".concat(id, ": ").concat(message);
2094
+ message = addColor(message, opts.color, opts.background);
2095
+ }
2096
+ return message;
2097
+ }
2098
+ function logImageInNode(_ref2) {
2099
+ let {
2100
+ image,
2101
+ message = "",
2102
+ scale = 1
2103
+ } = _ref2;
2104
+ console.warn("removed");
2105
+ return noop;
2106
+ }
2107
+ function logImageInBrowser(_ref3) {
2108
+ let {
2109
+ image,
2110
+ message = "",
2111
+ scale = 1
2112
+ } = _ref3;
2113
+ if (typeof image === "string") {
2114
+ const img = new Image();
2115
+ img.onload = () => {
2116
+ const args = formatImage(img, message, scale);
2117
+ console.log(...args);
2118
+ };
2119
+ img.src = image;
2120
+ return noop;
2121
+ }
2122
+ const element = image.nodeName || "";
2123
+ if (element.toLowerCase() === "img") {
2124
+ console.log(...formatImage(image, message, scale));
2125
+ return noop;
2126
+ }
2127
+ if (element.toLowerCase() === "canvas") {
2128
+ const img = new Image();
2129
+ img.onload = () => console.log(...formatImage(img, message, scale));
2130
+ img.src = image.toDataURL();
2131
+ return noop;
2132
+ }
2133
+ return noop;
2134
+ }
2135
+ function getTableHeader(table) {
2136
+ for (const key in table) {
2137
+ for (const title in table[key]) {
2138
+ return title || "untitled";
2139
+ }
2140
+ }
2141
+ return "empty";
2142
+ }
2143
+
2144
+ // ../../node_modules/@probe.gl/log/dist/index.js
2145
+ var dist_default = new Log({
2146
+ id: "@probe.gl/log"
2147
+ });
2148
+
2149
+ // ../loader-utils/src/lib/log-utils/log.ts
2150
+ var VERSION2 = true ? "4.3.0-alpha.1" : "latest";
2151
+ var version = VERSION2[0] >= "0" && VERSION2[0] <= "9" ? `v${VERSION2}` : "";
2152
+ function createLog() {
2153
+ const log2 = new Log({ id: "loaders.gl" });
2154
+ globalThis.loaders = globalThis.loaders || {};
2155
+ globalThis.loaders.log = log2;
2156
+ globalThis.loaders.version = version;
2157
+ globalThis.probe = globalThis.probe || {};
2158
+ globalThis.probe.loaders = log2;
2159
+ return log2;
2160
+ }
2161
+ var log = createLog();
2162
+
2163
+ // ../worker-utils/src/lib/node/worker_threads-browser.ts
2164
+ var parentPort = null;
2165
+
2166
+ // ../worker-utils/src/lib/worker-utils/get-transfer-list.ts
2167
+ function getTransferList(object, recursive = true, transfers) {
2168
+ const transfersSet = transfers || /* @__PURE__ */ new Set();
2169
+ if (!object) {
2170
+ } else if (isTransferable(object)) {
2171
+ transfersSet.add(object);
2172
+ } else if (isTransferable(object.buffer)) {
2173
+ transfersSet.add(object.buffer);
2174
+ } else if (ArrayBuffer.isView(object)) {
2175
+ } else if (recursive && typeof object === "object") {
2176
+ for (const key in object) {
2177
+ getTransferList(object[key], recursive, transfersSet);
2178
+ }
2179
+ }
2180
+ return transfers === void 0 ? Array.from(transfersSet) : [];
2181
+ }
2182
+ function isTransferable(object) {
2183
+ if (!object) {
2184
+ return false;
2185
+ }
2186
+ if (object instanceof ArrayBuffer) {
2187
+ return true;
2188
+ }
2189
+ if (typeof MessagePort !== "undefined" && object instanceof MessagePort) {
2190
+ return true;
2191
+ }
2192
+ if (typeof ImageBitmap !== "undefined" && object instanceof ImageBitmap) {
2193
+ return true;
2194
+ }
2195
+ if (typeof OffscreenCanvas !== "undefined" && object instanceof OffscreenCanvas) {
2196
+ return true;
2197
+ }
2198
+ return false;
2199
+ }
2200
+
2201
+ // ../worker-utils/src/lib/worker-farm/worker-body.ts
2202
+ async function getParentPort() {
2203
+ return parentPort;
2204
+ }
2205
+ var onMessageWrapperMap = /* @__PURE__ */ new Map();
2206
+ var WorkerBody = class {
2207
+ /** Check that we are actually in a worker thread */
2208
+ static async inWorkerThread() {
2209
+ return typeof self !== "undefined" || Boolean(await getParentPort());
2210
+ }
2211
+ /*
2212
+ * (type: WorkerMessageType, payload: WorkerMessagePayload) => any
2213
+ */
2214
+ static set onmessage(onMessage) {
2215
+ async function handleMessage(message) {
2216
+ const parentPort2 = await getParentPort();
2217
+ const { type, payload } = parentPort2 ? message : message.data;
2218
+ onMessage(type, payload);
2219
+ }
2220
+ getParentPort().then((parentPort2) => {
2221
+ if (parentPort2) {
2222
+ parentPort2.on("message", (message) => {
2223
+ handleMessage(message);
2224
+ });
2225
+ parentPort2.on("exit", () => console.debug("Node worker closing"));
2226
+ } else {
2227
+ globalThis.onmessage = handleMessage;
2228
+ }
2229
+ });
2230
+ }
2231
+ static async addEventListener(onMessage) {
2232
+ let onMessageWrapper = onMessageWrapperMap.get(onMessage);
2233
+ if (!onMessageWrapper) {
2234
+ onMessageWrapper = async (message) => {
2235
+ if (!isKnownMessage(message)) {
2236
+ return;
2237
+ }
2238
+ const parentPort3 = await getParentPort();
2239
+ const { type, payload } = parentPort3 ? message : message.data;
2240
+ onMessage(type, payload);
2241
+ };
2242
+ }
2243
+ const parentPort2 = await getParentPort();
2244
+ if (parentPort2) {
2245
+ console.error("not implemented");
2246
+ } else {
2247
+ globalThis.addEventListener("message", onMessageWrapper);
2248
+ }
2249
+ }
2250
+ static async removeEventListener(onMessage) {
2251
+ const onMessageWrapper = onMessageWrapperMap.get(onMessage);
2252
+ onMessageWrapperMap.delete(onMessage);
2253
+ const parentPort2 = await getParentPort();
2254
+ if (parentPort2) {
2255
+ console.error("not implemented");
2256
+ } else {
2257
+ globalThis.removeEventListener("message", onMessageWrapper);
2258
+ }
2259
+ }
2260
+ /**
2261
+ * Send a message from a worker to creating thread (main thread)
2262
+ * @param type
2263
+ * @param payload
2264
+ */
2265
+ static async postMessage(type, payload) {
2266
+ const data = { source: "loaders.gl", type, payload };
2267
+ const transferList = getTransferList(payload);
2268
+ const parentPort2 = await getParentPort();
2269
+ if (parentPort2) {
2270
+ parentPort2.postMessage(data, transferList);
2271
+ } else {
2272
+ globalThis.postMessage(data, transferList);
2273
+ }
2274
+ }
2275
+ };
2276
+ function isKnownMessage(message) {
2277
+ const { type, data } = message;
2278
+ return type === "message" && data && typeof data.source === "string" && data.source.startsWith("loaders.gl");
2279
+ }
2280
+
2281
+ // ../loader-utils/src/lib/worker-loader-utils/create-loader-worker.ts
2282
+ var requestId = 0;
2283
+ async function createLoaderWorker(loader) {
2284
+ if (!await WorkerBody.inWorkerThread()) {
2285
+ return;
2286
+ }
2287
+ WorkerBody.onmessage = async (type, payload) => {
2288
+ switch (type) {
2289
+ case "process":
2290
+ try {
2291
+ const { input, options = {}, context = {} } = payload;
2292
+ const result = await parseData({
2293
+ loader,
2294
+ arrayBuffer: input,
2295
+ options,
2296
+ // @ts-expect-error fetch missing
2297
+ context: {
2298
+ ...context,
2299
+ _parse: parseOnMainThread
2300
+ }
2301
+ });
2302
+ WorkerBody.postMessage("done", { result });
2303
+ } catch (error) {
2304
+ const message = error instanceof Error ? error.message : "";
2305
+ WorkerBody.postMessage("error", { error: message });
2306
+ }
2307
+ break;
2308
+ default:
2309
+ }
2310
+ };
2311
+ }
2312
+ function parseOnMainThread(arrayBuffer, loader, options, context) {
2313
+ return new Promise((resolve, reject) => {
2314
+ const id = requestId++;
2315
+ const onMessage = (type, payload2) => {
2316
+ if (payload2.id !== id) {
2317
+ return;
2318
+ }
2319
+ switch (type) {
2320
+ case "done":
2321
+ WorkerBody.removeEventListener(onMessage);
2322
+ resolve(payload2.result);
2323
+ break;
2324
+ case "error":
2325
+ WorkerBody.removeEventListener(onMessage);
2326
+ reject(payload2.error);
2327
+ break;
2328
+ default:
2329
+ }
2330
+ };
2331
+ WorkerBody.addEventListener(onMessage);
2332
+ const payload = { id, input: arrayBuffer, options };
2333
+ WorkerBody.postMessage("process", payload);
2334
+ });
2335
+ }
2336
+ async function parseData({
2337
+ loader,
2338
+ arrayBuffer,
2339
+ options,
2340
+ context
2341
+ }) {
2342
+ let data;
2343
+ let parser;
2344
+ if (loader.parseSync || loader.parse) {
2345
+ data = arrayBuffer;
2346
+ parser = loader.parseSync || loader.parse;
2347
+ } else if (loader.parseTextSync) {
2348
+ const textDecoder = new TextDecoder();
2349
+ data = textDecoder.decode(arrayBuffer);
2350
+ parser = loader.parseTextSync;
2351
+ } else {
2352
+ throw new Error(`Could not load data with ${loader.name} loader`);
1996
2353
  }
2354
+ options = {
2355
+ ...options,
2356
+ modules: loader && loader.options && loader.options.modules || {},
2357
+ worker: false
2358
+ };
2359
+ return await parser(data, { ...options }, context, loader);
1997
2360
  }
1998
2361
 
1999
- // src/lib/binary-vector-tile/vector-tile-feature.ts
2000
- var endPos;
2001
- var cmd;
2002
- var cmdLen;
2003
- var length;
2004
- var x;
2005
- var y;
2006
- var i;
2007
- var BinaryVectorTileFeature = class {
2362
+ // src/lib/parse-mvt.ts
2363
+ var import_pbf = __toESM(require_pbf(), 1);
2364
+
2365
+ // src/lib/utils/geometry-utils.ts
2366
+ function signedArea(ring) {
2367
+ let sum = 0;
2368
+ for (let i = 0, j = ring.length - 1, p1, p2; i < ring.length; j = i++) {
2369
+ p1 = ring[i];
2370
+ p2 = ring[j];
2371
+ sum += (p2[0] - p1[0]) * (p1[1] + p2[1]);
2372
+ }
2373
+ return sum;
2374
+ }
2375
+ function convertToLocalCoordinates(coordinates, extent) {
2376
+ if (Array.isArray(coordinates[0])) {
2377
+ for (const subcoords of coordinates) {
2378
+ convertToLocalCoordinates(subcoords, extent);
2379
+ }
2380
+ return;
2381
+ }
2382
+ const p = coordinates;
2383
+ p[0] /= extent;
2384
+ p[1] /= extent;
2385
+ }
2386
+ function convertToLocalCoordinatesFlat(data, extent) {
2387
+ for (let i = 0, il = data.length; i < il; ++i) {
2388
+ data[i] /= extent;
2389
+ }
2390
+ }
2391
+ function projectToLngLat(line, tileIndex, extent) {
2392
+ if (typeof line[0][0] !== "number") {
2393
+ for (const point of line) {
2394
+ projectToLngLat(point, tileIndex, extent);
2395
+ }
2396
+ return;
2397
+ }
2398
+ const size = extent * Math.pow(2, tileIndex.z);
2399
+ const x0 = extent * tileIndex.x;
2400
+ const y0 = extent * tileIndex.y;
2401
+ for (let j = 0; j < line.length; j++) {
2402
+ const p = line[j];
2403
+ p[0] = (p[0] + x0) * 360 / size - 180;
2404
+ const y2 = 180 - (p[1] + y0) * 360 / size;
2405
+ p[1] = 360 / Math.PI * Math.atan(Math.exp(y2 * Math.PI / 180)) - 90;
2406
+ }
2407
+ }
2408
+ function projectToLngLatFlat(data, tileIndex, extent) {
2409
+ const { x, y, z } = tileIndex;
2410
+ const size = extent * Math.pow(2, z);
2411
+ const x0 = extent * x;
2412
+ const y0 = extent * y;
2413
+ for (let j = 0, jl = data.length; j < jl; j += 2) {
2414
+ data[j] = (data[j] + x0) * 360 / size - 180;
2415
+ const y2 = 180 - (data[j + 1] + y0) * 360 / size;
2416
+ data[j + 1] = 360 / Math.PI * Math.atan(Math.exp(y2 * Math.PI / 180)) - 90;
2417
+ }
2418
+ }
2419
+ function classifyRings(rings) {
2420
+ const len = rings.length;
2421
+ if (len <= 1)
2422
+ return [rings];
2423
+ const polygons = [];
2424
+ let polygon;
2425
+ let ccw;
2426
+ for (let i = 0; i < len; i++) {
2427
+ const area2 = signedArea(rings[i]);
2428
+ if (area2 === 0)
2429
+ continue;
2430
+ if (ccw === void 0)
2431
+ ccw = area2 < 0;
2432
+ if (ccw === area2 < 0) {
2433
+ if (polygon)
2434
+ polygons.push(polygon);
2435
+ polygon = [rings[i]];
2436
+ } else if (polygon)
2437
+ polygon.push(rings[i]);
2438
+ }
2439
+ if (polygon)
2440
+ polygons.push(polygon);
2441
+ return polygons;
2442
+ }
2443
+ function classifyRingsFlat(geom) {
2444
+ const len = geom.indices.length;
2445
+ const type = "Polygon";
2446
+ if (len <= 1) {
2447
+ return {
2448
+ type,
2449
+ data: geom.data,
2450
+ areas: [[getPolygonSignedArea(geom.data)]],
2451
+ indices: [geom.indices]
2452
+ };
2453
+ }
2454
+ const areas = [];
2455
+ const polygons = [];
2456
+ let ringAreas = [];
2457
+ let polygon = [];
2458
+ let ccw;
2459
+ let offset = 0;
2460
+ for (let endIndex, i = 0, startIndex; i < len; i++) {
2461
+ startIndex = geom.indices[i] - offset;
2462
+ endIndex = geom.indices[i + 1] - offset || geom.data.length;
2463
+ const shape = geom.data.slice(startIndex, endIndex);
2464
+ const area2 = getPolygonSignedArea(shape);
2465
+ if (area2 === 0) {
2466
+ const before = geom.data.slice(0, startIndex);
2467
+ const after = geom.data.slice(endIndex);
2468
+ geom.data = before.concat(after);
2469
+ offset += endIndex - startIndex;
2470
+ continue;
2471
+ }
2472
+ if (ccw === void 0)
2473
+ ccw = area2 < 0;
2474
+ if (ccw === area2 < 0) {
2475
+ if (polygon.length) {
2476
+ areas.push(ringAreas);
2477
+ polygons.push(polygon);
2478
+ }
2479
+ polygon = [startIndex];
2480
+ ringAreas = [area2];
2481
+ } else {
2482
+ ringAreas.push(area2);
2483
+ polygon.push(startIndex);
2484
+ }
2485
+ }
2486
+ if (ringAreas)
2487
+ areas.push(ringAreas);
2488
+ if (polygon.length)
2489
+ polygons.push(polygon);
2490
+ return { type, areas, indices: polygons, data: geom.data };
2491
+ }
2492
+
2493
+ // src/lib/vector-tile/vector-tile-feature.ts
2494
+ var VectorTileFeature = class {
2008
2495
  properties;
2009
2496
  extent;
2010
2497
  type;
@@ -2025,23 +2512,55 @@
2025
2512
  this._keys = keys;
2026
2513
  this._values = values;
2027
2514
  this._geometryInfo = geometryInfo;
2028
- pbf.readFields(readFeature2, this, end);
2515
+ pbf.readFields(readFeature, this, end);
2029
2516
  }
2030
- // eslint-disable-next-line complexity, max-statements
2031
- loadGeometry() {
2517
+ toGeoJSONFeature(coordinates, tileIndex) {
2518
+ const coords = this.loadGeometry();
2519
+ switch (coordinates) {
2520
+ case "wgs84":
2521
+ return _toGeoJSONFeature(
2522
+ this,
2523
+ coords,
2524
+ (line) => projectToLngLat(line, tileIndex, this.extent)
2525
+ );
2526
+ default:
2527
+ return _toGeoJSONFeature(this, coords, convertToLocalCoordinates);
2528
+ }
2529
+ }
2530
+ /**
2531
+ *
2532
+ * @param options
2533
+ * @returns
2534
+ */
2535
+ toBinaryFeature(coordinates, tileIndex) {
2536
+ const geom = this.loadFlatGeometry();
2537
+ switch (coordinates) {
2538
+ case "wgs84":
2539
+ return this._toBinaryCoordinates(
2540
+ geom,
2541
+ (coords) => projectToLngLatFlat(coords, tileIndex, this.extent)
2542
+ );
2543
+ default:
2544
+ return this._toBinaryCoordinates(geom, convertToLocalCoordinatesFlat);
2545
+ }
2546
+ }
2547
+ /** Read a bounding box from the feature */
2548
+ // eslint-disable-next-line max-statements
2549
+ bbox() {
2032
2550
  const pbf = this._pbf;
2033
2551
  pbf.pos = this._geometry;
2034
- endPos = pbf.readVarint() + pbf.pos;
2035
- cmd = 1;
2036
- length = 0;
2037
- x = 0;
2038
- y = 0;
2039
- i = 0;
2040
- const indices = [];
2041
- const data = [];
2042
- while (pbf.pos < endPos) {
2552
+ const end = pbf.readVarint() + pbf.pos;
2553
+ let cmd = 1;
2554
+ let length = 0;
2555
+ let x = 0;
2556
+ let y = 0;
2557
+ let x1 = Infinity;
2558
+ let x2 = -Infinity;
2559
+ let y1 = Infinity;
2560
+ let y2 = -Infinity;
2561
+ while (pbf.pos < end) {
2043
2562
  if (length <= 0) {
2044
- cmdLen = pbf.readVarint();
2563
+ const cmdLen = pbf.readVarint();
2045
2564
  cmd = cmdLen & 7;
2046
2565
  length = cmdLen >> 3;
2047
2566
  }
@@ -2049,32 +2568,29 @@
2049
2568
  if (cmd === 1 || cmd === 2) {
2050
2569
  x += pbf.readSVarint();
2051
2570
  y += pbf.readSVarint();
2052
- if (cmd === 1) {
2053
- indices.push(i);
2054
- }
2055
- data.push(x, y);
2056
- i += 2;
2057
- } else if (cmd === 7) {
2058
- if (i > 0) {
2059
- const start = indices[indices.length - 1];
2060
- data.push(data[start], data[start + 1]);
2061
- i += 2;
2062
- }
2063
- } else {
2571
+ if (x < x1)
2572
+ x1 = x;
2573
+ if (x > x2)
2574
+ x2 = x;
2575
+ if (y < y1)
2576
+ y1 = y;
2577
+ if (y > y2)
2578
+ y2 = y;
2579
+ } else if (cmd !== 7) {
2064
2580
  throw new Error(`unknown command ${cmd}`);
2065
2581
  }
2066
2582
  }
2067
- return { data, indices };
2583
+ return [x1, y1, x2, y2];
2068
2584
  }
2585
+ // BINARY HELPERS
2069
2586
  /**
2070
2587
  *
2071
2588
  * @param transform
2072
2589
  * @returns result
2073
2590
  */
2074
- _toBinaryCoordinates(transform) {
2075
- const geom = this.loadGeometry();
2591
+ _toBinaryCoordinates(geom, transform) {
2076
2592
  let geometry;
2077
- transform(geom.data, this);
2593
+ transform(geom.data, this.extent);
2078
2594
  const coordLength = 2;
2079
2595
  switch (this.type) {
2080
2596
  case 1:
@@ -2089,7 +2605,7 @@
2089
2605
  geometry = { type: "LineString", ...geom };
2090
2606
  break;
2091
2607
  case 3:
2092
- geometry = classifyRings2(geom);
2608
+ geometry = classifyRingsFlat(geom);
2093
2609
  this._geometryInfo.polygonFeaturesCount++;
2094
2610
  this._geometryInfo.polygonObjectsCount += geometry.indices.length;
2095
2611
  for (const indices of geometry.indices) {
@@ -2106,20 +2622,188 @@
2106
2622
  }
2107
2623
  return result;
2108
2624
  }
2109
- toBinaryCoordinates(options) {
2110
- if (typeof options === "function") {
2111
- return this._toBinaryCoordinates(options);
2112
- }
2113
- const { x: x2, y: y2, z } = options;
2114
- const size = this.extent * Math.pow(2, z);
2115
- const x0 = this.extent * x2;
2116
- const y0 = this.extent * y2;
2117
- return this._toBinaryCoordinates((data) => project(data, x0, y0, size));
2625
+ // GEOJSON HELPER
2626
+ // eslint-disable-next-line complexity, max-statements
2627
+ loadGeometry() {
2628
+ const pbf = this._pbf;
2629
+ pbf.pos = this._geometry;
2630
+ const end = pbf.readVarint() + pbf.pos;
2631
+ let cmd = 1;
2632
+ let length = 0;
2633
+ let x = 0;
2634
+ let y = 0;
2635
+ const lines = [];
2636
+ let line;
2637
+ while (pbf.pos < end) {
2638
+ if (length <= 0) {
2639
+ const cmdLen = pbf.readVarint();
2640
+ cmd = cmdLen & 7;
2641
+ length = cmdLen >> 3;
2642
+ }
2643
+ length--;
2644
+ switch (cmd) {
2645
+ case 1:
2646
+ case 2:
2647
+ x += pbf.readSVarint();
2648
+ y += pbf.readSVarint();
2649
+ if (cmd === 1) {
2650
+ if (line)
2651
+ lines.push(line);
2652
+ line = [];
2653
+ }
2654
+ if (line)
2655
+ line.push([x, y]);
2656
+ break;
2657
+ case 7:
2658
+ if (line) {
2659
+ line.push(line[0].slice());
2660
+ }
2661
+ break;
2662
+ default:
2663
+ throw new Error(`unknown command ${cmd}`);
2664
+ }
2665
+ }
2666
+ if (line)
2667
+ lines.push(line);
2668
+ return lines;
2669
+ }
2670
+ /**
2671
+ * Expands the protobuf data to an intermediate Flat GeoJSON
2672
+ * data format, which maps closely to the binary data buffers.
2673
+ * It is similar to GeoJSON, but rather than storing the coordinates
2674
+ * in multidimensional arrays, we have a 1D `data` with all the
2675
+ * coordinates, and then index into this using the `indices`
2676
+ * parameter, e.g.
2677
+ *
2678
+ * geometry: {
2679
+ * type: 'Point', data: [1,2], indices: [0]
2680
+ * }
2681
+ * geometry: {
2682
+ * type: 'LineString', data: [1,2,3,4,...], indices: [0]
2683
+ * }
2684
+ * geometry: {
2685
+ * type: 'Polygon', data: [1,2,3,4,...], indices: [[0, 2]]
2686
+ * }
2687
+ * Thus the indices member lets us look up the relevant range
2688
+ * from the data array.
2689
+ * The Multi* versions of the above types share the same data
2690
+ * structure, just with multiple elements in the indices array
2691
+ */
2692
+ // eslint-disable-next-line complexity, max-statements
2693
+ loadFlatGeometry() {
2694
+ const pbf = this._pbf;
2695
+ pbf.pos = this._geometry;
2696
+ const endPos = pbf.readVarint() + pbf.pos;
2697
+ let cmd = 1;
2698
+ let cmdLen;
2699
+ let length = 0;
2700
+ let x = 0;
2701
+ let y = 0;
2702
+ let i = 0;
2703
+ const indices = [];
2704
+ const data = [];
2705
+ while (pbf.pos < endPos) {
2706
+ if (length <= 0) {
2707
+ cmdLen = pbf.readVarint();
2708
+ cmd = cmdLen & 7;
2709
+ length = cmdLen >> 3;
2710
+ }
2711
+ length--;
2712
+ if (cmd === 1 || cmd === 2) {
2713
+ x += pbf.readSVarint();
2714
+ y += pbf.readSVarint();
2715
+ if (cmd === 1) {
2716
+ indices.push(i);
2717
+ }
2718
+ data.push(x, y);
2719
+ i += 2;
2720
+ } else if (cmd === 7) {
2721
+ if (i > 0) {
2722
+ const start = indices[indices.length - 1];
2723
+ data.push(data[start], data[start + 1]);
2724
+ i += 2;
2725
+ }
2726
+ } else {
2727
+ throw new Error(`unknown command ${cmd}`);
2728
+ }
2729
+ }
2730
+ return { data, indices };
2731
+ }
2732
+ };
2733
+ __publicField(VectorTileFeature, "types", ["Unknown", "Point", "LineString", "Polygon"]);
2734
+ function _toGeoJSONFeature(vtFeature, coords, transform) {
2735
+ let type = VectorTileFeature.types[vtFeature.type];
2736
+ let i;
2737
+ let j;
2738
+ let coordinates;
2739
+ switch (vtFeature.type) {
2740
+ case 1:
2741
+ const points = [];
2742
+ for (i = 0; i < coords.length; i++) {
2743
+ points[i] = coords[i][0];
2744
+ }
2745
+ coordinates = points;
2746
+ transform(coordinates, vtFeature.extent);
2747
+ break;
2748
+ case 2:
2749
+ coordinates = coords;
2750
+ for (i = 0; i < coordinates.length; i++) {
2751
+ transform(coordinates[i], vtFeature.extent);
2752
+ }
2753
+ break;
2754
+ case 3:
2755
+ coordinates = classifyRings(coords);
2756
+ for (i = 0; i < coordinates.length; i++) {
2757
+ for (j = 0; j < coordinates[i].length; j++) {
2758
+ transform(coordinates[i][j], vtFeature.extent);
2759
+ }
2760
+ }
2761
+ break;
2762
+ default:
2763
+ throw new Error("illegal vector tile type");
2764
+ }
2765
+ if (coordinates.length === 1) {
2766
+ coordinates = coordinates[0];
2767
+ } else {
2768
+ type = `Multi${type}`;
2118
2769
  }
2119
- };
2770
+ const result = {
2771
+ type: "Feature",
2772
+ geometry: {
2773
+ type,
2774
+ coordinates
2775
+ },
2776
+ properties: vtFeature.properties
2777
+ };
2778
+ if (vtFeature.id !== null) {
2779
+ result.properties ||= {};
2780
+ result.properties.id = vtFeature.id;
2781
+ }
2782
+ return result;
2783
+ }
2784
+ function readFeature(tag, feature, pbf) {
2785
+ if (feature && pbf) {
2786
+ if (tag === 1)
2787
+ feature.id = pbf.readVarint();
2788
+ else if (tag === 2)
2789
+ readTag(pbf, feature);
2790
+ else if (tag === 3)
2791
+ feature.type = pbf.readVarint();
2792
+ else if (tag === 4)
2793
+ feature._geometry = pbf.pos;
2794
+ }
2795
+ }
2796
+ function readTag(pbf, feature) {
2797
+ const end = pbf.readVarint() + pbf.pos;
2798
+ while (pbf.pos < end) {
2799
+ const key = feature._keys[pbf.readVarint()];
2800
+ const value = feature._values[pbf.readVarint()];
2801
+ feature.properties[key] = value;
2802
+ }
2803
+ }
2120
2804
 
2121
- // src/lib/binary-vector-tile/vector-tile-layer.ts
2122
- var BinaryVectorTileLayer = class {
2805
+ // src/lib/vector-tile/vector-tile-layer.ts
2806
+ var VectorTileLayer = class {
2123
2807
  version;
2124
2808
  name;
2125
2809
  extent;
@@ -2137,23 +2821,36 @@
2137
2821
  this._keys = [];
2138
2822
  this._values = [];
2139
2823
  this._features = [];
2140
- pbf.readFields(readLayer2, this, end);
2824
+ pbf.readFields(readLayer, this, end);
2141
2825
  this.length = this._features.length;
2142
2826
  }
2143
2827
  /**
2144
- * return feature `i` from this layer as a `BinaryVectorTileFeature`
2828
+ * return feature `i` from this layer as a `VectorTileFeature`
2829
+ * @param index
2830
+ * @returns feature
2831
+ */
2832
+ getGeoJSONFeature(i) {
2833
+ if (i < 0 || i >= this._features.length) {
2834
+ throw new Error("feature index out of bounds");
2835
+ }
2836
+ this._pbf.pos = this._features[i];
2837
+ const end = this._pbf.readVarint() + this._pbf.pos;
2838
+ return new VectorTileFeature(this._pbf, end, this.extent, this._keys, this._values);
2839
+ }
2840
+ /**
2841
+ * return binary feature `i` from this layer as a `VectorTileFeature`
2145
2842
  *
2146
2843
  * @param index
2147
2844
  * @param geometryInfo
2148
- * @returns {BinaryVectorTileFeature}
2845
+ * @returns binary feature
2149
2846
  */
2150
- feature(i2, geometryInfo) {
2151
- if (i2 < 0 || i2 >= this._features.length) {
2847
+ getBinaryFeature(i, geometryInfo) {
2848
+ if (i < 0 || i >= this._features.length) {
2152
2849
  throw new Error("feature index out of bounds");
2153
2850
  }
2154
- this._pbf.pos = this._features[i2];
2851
+ this._pbf.pos = this._features[i];
2155
2852
  const end = this._pbf.readVarint() + this._pbf.pos;
2156
- return new BinaryVectorTileFeature(
2853
+ return new VectorTileFeature(
2157
2854
  this._pbf,
2158
2855
  end,
2159
2856
  this.extent,
@@ -2163,7 +2860,7 @@
2163
2860
  );
2164
2861
  }
2165
2862
  };
2166
- function readLayer2(tag, layer, pbf) {
2863
+ function readLayer(tag, layer, pbf) {
2167
2864
  if (layer && pbf) {
2168
2865
  if (tag === 15)
2169
2866
  layer.version = pbf.readVarint();
@@ -2176,10 +2873,10 @@
2176
2873
  else if (tag === 3)
2177
2874
  layer._keys.push(pbf.readString());
2178
2875
  else if (tag === 4)
2179
- layer._values.push(readValueMessage2(pbf));
2876
+ layer._values.push(readValueMessage(pbf));
2180
2877
  }
2181
2878
  }
2182
- function readValueMessage2(pbf) {
2879
+ function readValueMessage(pbf) {
2183
2880
  let value = null;
2184
2881
  const end = pbf.readVarint() + pbf.pos;
2185
2882
  while (pbf.pos < end) {
@@ -2189,17 +2886,17 @@
2189
2886
  return value;
2190
2887
  }
2191
2888
 
2192
- // src/lib/binary-vector-tile/vector-tile.ts
2193
- var BinaryVectorTile = class {
2889
+ // src/lib/vector-tile/vector-tile.ts
2890
+ var VectorTile = class {
2194
2891
  layers;
2195
2892
  constructor(pbf, end) {
2196
- this.layers = pbf.readFields(readTile2, {}, end);
2893
+ this.layers = pbf.readFields(readTile, {}, end);
2197
2894
  }
2198
2895
  };
2199
- function readTile2(tag, layers, pbf) {
2896
+ function readTile(tag, layers, pbf) {
2200
2897
  if (tag === 3) {
2201
2898
  if (pbf) {
2202
- const layer = new BinaryVectorTileLayer(pbf, pbf.readVarint() + pbf.pos);
2899
+ const layer = new VectorTileLayer(pbf, pbf.readVarint() + pbf.pos);
2203
2900
  if (layer.length && layers) {
2204
2901
  layers[layer.name] = layer;
2205
2902
  }
@@ -2209,7 +2906,7 @@
2209
2906
 
2210
2907
  // src/lib/parse-mvt.ts
2211
2908
  function parseMVT(arrayBuffer, options) {
2212
- const mvtOptions = normalizeOptions(options);
2909
+ const mvtOptions = checkOptions(options);
2213
2910
  const shape = options?.gis?.format || options?.mvt?.shape || options?.shape;
2214
2911
  switch (shape) {
2215
2912
  case "columnar-table":
@@ -2255,15 +2952,15 @@
2255
2952
  if (arrayBuffer.byteLength <= 0) {
2256
2953
  return [features, geometryInfo];
2257
2954
  }
2258
- const tile = new BinaryVectorTile(new import_pbf.default(arrayBuffer));
2955
+ const tile = new VectorTile(new import_pbf.default(arrayBuffer));
2259
2956
  const selectedLayers = options && Array.isArray(options.layers) ? options.layers : Object.keys(tile.layers);
2260
2957
  selectedLayers.forEach((layerName) => {
2261
2958
  const vectorTileLayer = tile.layers[layerName];
2262
2959
  if (!vectorTileLayer) {
2263
2960
  return;
2264
2961
  }
2265
- for (let i2 = 0; i2 < vectorTileLayer.length; i2++) {
2266
- const vectorTileFeature = vectorTileLayer.feature(i2, geometryInfo);
2962
+ for (let i = 0; i < vectorTileLayer.length; i++) {
2963
+ const vectorTileFeature = vectorTileLayer.getBinaryFeature(i, geometryInfo);
2267
2964
  const decodedFeature = getDecodedFeatureBinary(vectorTileFeature, options, layerName);
2268
2965
  features.push(decodedFeature);
2269
2966
  }
@@ -2282,70 +2979,54 @@
2282
2979
  if (!vectorTileLayer) {
2283
2980
  return;
2284
2981
  }
2285
- for (let i2 = 0; i2 < vectorTileLayer.length; i2++) {
2286
- const vectorTileFeature = vectorTileLayer.feature(i2);
2982
+ for (let i = 0; i < vectorTileLayer.length; i++) {
2983
+ const vectorTileFeature = vectorTileLayer.getGeoJSONFeature(i);
2287
2984
  const decodedFeature = getDecodedFeature(vectorTileFeature, options, layerName);
2288
2985
  features.push(decodedFeature);
2289
2986
  }
2290
2987
  });
2291
2988
  return features;
2292
2989
  }
2293
- function normalizeOptions(options) {
2990
+ function checkOptions(options) {
2294
2991
  if (!options?.mvt) {
2295
2992
  throw new Error("mvt options required");
2296
2993
  }
2297
- const wgs84Coordinates = options.mvt?.coordinates === "wgs84";
2298
- const { tileIndex } = options.mvt;
2299
- const hasTileIndex = tileIndex && Number.isFinite(tileIndex.x) && Number.isFinite(tileIndex.y) && Number.isFinite(tileIndex.z);
2300
- if (wgs84Coordinates && !hasTileIndex) {
2994
+ if (options.mvt?.coordinates === "wgs84" && !options.mvt.tileIndex) {
2301
2995
  throw new Error("MVT Loader: WGS84 coordinates need tileIndex property");
2302
2996
  }
2997
+ if (options.gis) {
2998
+ log.warn('MVTLoader: "options.gis" is deprecated, use "options.mvt.shape" instead')();
2999
+ }
2303
3000
  return options.mvt;
2304
3001
  }
2305
3002
  function getDecodedFeature(feature, options, layerName) {
2306
- const decodedFeature = feature.toGeoJSON(
2307
- // @ts-expect-error What is going on here?
2308
- options.coordinates === "wgs84" ? options.tileIndex : transformToLocalCoordinates
3003
+ const decodedFeature = feature.toGeoJSONFeature(
3004
+ options.coordinates || "local",
3005
+ options.tileIndex
2309
3006
  );
2310
3007
  if (options.layerProperty) {
3008
+ decodedFeature.properties ||= {};
2311
3009
  decodedFeature.properties[options.layerProperty] = layerName;
2312
3010
  }
2313
3011
  return decodedFeature;
2314
3012
  }
2315
3013
  function getDecodedFeatureBinary(feature, options, layerName) {
2316
- const decodedFeature = feature.toBinaryCoordinates(
2317
- // @ts-expect-error
2318
- options.coordinates === "wgs84" ? options.tileIndex : transformToLocalCoordinatesBinary
2319
- );
3014
+ const decodedFeature = feature.toBinaryFeature(options.coordinates || "local", options.tileIndex);
2320
3015
  if (options.layerProperty && decodedFeature.properties) {
2321
3016
  decodedFeature.properties[options.layerProperty] = layerName;
2322
3017
  }
2323
3018
  return decodedFeature;
2324
3019
  }
2325
- function transformToLocalCoordinates(line, feature) {
2326
- const { extent } = feature;
2327
- for (let i2 = 0; i2 < line.length; i2++) {
2328
- const p = line[i2];
2329
- p[0] /= extent;
2330
- p[1] /= extent;
2331
- }
2332
- }
2333
- function transformToLocalCoordinatesBinary(data, feature) {
2334
- const { extent } = feature;
2335
- for (let i2 = 0, il = data.length; i2 < il; ++i2) {
2336
- data[i2] /= extent;
2337
- }
2338
- }
2339
3020
 
2340
3021
  // src/mvt-loader.ts
2341
- var VERSION = true ? "4.2.0" : "latest";
3022
+ var VERSION3 = true ? "4.3.0-alpha.1" : "latest";
2342
3023
  var MVTWorkerLoader = {
2343
3024
  dataType: null,
2344
3025
  batchType: null,
2345
3026
  name: "Mapbox Vector Tile",
2346
3027
  id: "mvt",
2347
3028
  module: "mvt",
2348
- version: VERSION,
3029
+ version: VERSION3,
2349
3030
  // Note: ArcGIS uses '.pbf' extension and 'application/octet-stream'
2350
3031
  extensions: ["mvt", "pbf"],
2351
3032
  mimeTypes: [
@@ -2362,7 +3043,7 @@
2362
3043
  coordinates: "local",
2363
3044
  layerProperty: "layerName",
2364
3045
  layers: void 0,
2365
- tileIndex: null
3046
+ tileIndex: void 0
2366
3047
  }
2367
3048
  }
2368
3049
  };
@@ -2373,205 +3054,6 @@
2373
3054
  binary: true
2374
3055
  };
2375
3056
 
2376
- // ../worker-utils/src/lib/node/worker_threads-browser.ts
2377
- var parentPort = null;
2378
-
2379
- // ../worker-utils/src/lib/worker-utils/get-transfer-list.ts
2380
- function getTransferList(object, recursive = true, transfers) {
2381
- const transfersSet = transfers || /* @__PURE__ */ new Set();
2382
- if (!object) {
2383
- } else if (isTransferable(object)) {
2384
- transfersSet.add(object);
2385
- } else if (isTransferable(object.buffer)) {
2386
- transfersSet.add(object.buffer);
2387
- } else if (ArrayBuffer.isView(object)) {
2388
- } else if (recursive && typeof object === "object") {
2389
- for (const key in object) {
2390
- getTransferList(object[key], recursive, transfersSet);
2391
- }
2392
- }
2393
- return transfers === void 0 ? Array.from(transfersSet) : [];
2394
- }
2395
- function isTransferable(object) {
2396
- if (!object) {
2397
- return false;
2398
- }
2399
- if (object instanceof ArrayBuffer) {
2400
- return true;
2401
- }
2402
- if (typeof MessagePort !== "undefined" && object instanceof MessagePort) {
2403
- return true;
2404
- }
2405
- if (typeof ImageBitmap !== "undefined" && object instanceof ImageBitmap) {
2406
- return true;
2407
- }
2408
- if (typeof OffscreenCanvas !== "undefined" && object instanceof OffscreenCanvas) {
2409
- return true;
2410
- }
2411
- return false;
2412
- }
2413
-
2414
- // ../worker-utils/src/lib/worker-farm/worker-body.ts
2415
- async function getParentPort() {
2416
- return parentPort;
2417
- }
2418
- var onMessageWrapperMap = /* @__PURE__ */ new Map();
2419
- var WorkerBody = class {
2420
- /** Check that we are actually in a worker thread */
2421
- static async inWorkerThread() {
2422
- return typeof self !== "undefined" || Boolean(await getParentPort());
2423
- }
2424
- /*
2425
- * (type: WorkerMessageType, payload: WorkerMessagePayload) => any
2426
- */
2427
- static set onmessage(onMessage) {
2428
- async function handleMessage(message) {
2429
- const parentPort2 = await getParentPort();
2430
- const { type, payload } = parentPort2 ? message : message.data;
2431
- onMessage(type, payload);
2432
- }
2433
- getParentPort().then((parentPort2) => {
2434
- if (parentPort2) {
2435
- parentPort2.on("message", (message) => {
2436
- handleMessage(message);
2437
- });
2438
- parentPort2.on("exit", () => console.debug("Node worker closing"));
2439
- } else {
2440
- globalThis.onmessage = handleMessage;
2441
- }
2442
- });
2443
- }
2444
- static async addEventListener(onMessage) {
2445
- let onMessageWrapper = onMessageWrapperMap.get(onMessage);
2446
- if (!onMessageWrapper) {
2447
- onMessageWrapper = async (message) => {
2448
- if (!isKnownMessage(message)) {
2449
- return;
2450
- }
2451
- const parentPort3 = await getParentPort();
2452
- const { type, payload } = parentPort3 ? message : message.data;
2453
- onMessage(type, payload);
2454
- };
2455
- }
2456
- const parentPort2 = await getParentPort();
2457
- if (parentPort2) {
2458
- console.error("not implemented");
2459
- } else {
2460
- globalThis.addEventListener("message", onMessageWrapper);
2461
- }
2462
- }
2463
- static async removeEventListener(onMessage) {
2464
- const onMessageWrapper = onMessageWrapperMap.get(onMessage);
2465
- onMessageWrapperMap.delete(onMessage);
2466
- const parentPort2 = await getParentPort();
2467
- if (parentPort2) {
2468
- console.error("not implemented");
2469
- } else {
2470
- globalThis.removeEventListener("message", onMessageWrapper);
2471
- }
2472
- }
2473
- /**
2474
- * Send a message from a worker to creating thread (main thread)
2475
- * @param type
2476
- * @param payload
2477
- */
2478
- static async postMessage(type, payload) {
2479
- const data = { source: "loaders.gl", type, payload };
2480
- const transferList = getTransferList(payload);
2481
- const parentPort2 = await getParentPort();
2482
- if (parentPort2) {
2483
- parentPort2.postMessage(data, transferList);
2484
- } else {
2485
- globalThis.postMessage(data, transferList);
2486
- }
2487
- }
2488
- };
2489
- function isKnownMessage(message) {
2490
- const { type, data } = message;
2491
- return type === "message" && data && typeof data.source === "string" && data.source.startsWith("loaders.gl");
2492
- }
2493
-
2494
- // ../loader-utils/src/lib/worker-loader-utils/create-loader-worker.ts
2495
- var requestId = 0;
2496
- async function createLoaderWorker(loader) {
2497
- if (!await WorkerBody.inWorkerThread()) {
2498
- return;
2499
- }
2500
- WorkerBody.onmessage = async (type, payload) => {
2501
- switch (type) {
2502
- case "process":
2503
- try {
2504
- const { input, options = {}, context = {} } = payload;
2505
- const result = await parseData({
2506
- loader,
2507
- arrayBuffer: input,
2508
- options,
2509
- // @ts-expect-error fetch missing
2510
- context: {
2511
- ...context,
2512
- _parse: parseOnMainThread
2513
- }
2514
- });
2515
- WorkerBody.postMessage("done", { result });
2516
- } catch (error) {
2517
- const message = error instanceof Error ? error.message : "";
2518
- WorkerBody.postMessage("error", { error: message });
2519
- }
2520
- break;
2521
- default:
2522
- }
2523
- };
2524
- }
2525
- function parseOnMainThread(arrayBuffer, loader, options, context) {
2526
- return new Promise((resolve, reject) => {
2527
- const id = requestId++;
2528
- const onMessage = (type, payload2) => {
2529
- if (payload2.id !== id) {
2530
- return;
2531
- }
2532
- switch (type) {
2533
- case "done":
2534
- WorkerBody.removeEventListener(onMessage);
2535
- resolve(payload2.result);
2536
- break;
2537
- case "error":
2538
- WorkerBody.removeEventListener(onMessage);
2539
- reject(payload2.error);
2540
- break;
2541
- default:
2542
- }
2543
- };
2544
- WorkerBody.addEventListener(onMessage);
2545
- const payload = { id, input: arrayBuffer, options };
2546
- WorkerBody.postMessage("process", payload);
2547
- });
2548
- }
2549
- async function parseData({
2550
- loader,
2551
- arrayBuffer,
2552
- options,
2553
- context
2554
- }) {
2555
- let data;
2556
- let parser;
2557
- if (loader.parseSync || loader.parse) {
2558
- data = arrayBuffer;
2559
- parser = loader.parseSync || loader.parse;
2560
- } else if (loader.parseTextSync) {
2561
- const textDecoder = new TextDecoder();
2562
- data = textDecoder.decode(arrayBuffer);
2563
- parser = loader.parseTextSync;
2564
- } else {
2565
- throw new Error(`Could not load data with ${loader.name} loader`);
2566
- }
2567
- options = {
2568
- ...options,
2569
- modules: loader && loader.options && loader.options.modules || {},
2570
- worker: false
2571
- };
2572
- return await parser(data, { ...options }, context, loader);
2573
- }
2574
-
2575
3057
  // src/workers/mvt-worker.ts
2576
3058
  createLoaderWorker(MVTLoader);
2577
3059
  })();