@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.
- package/dist/dist.dev.js +1784 -847
- package/dist/dist.min.js +1 -1
- package/dist/index.cjs +713 -640
- package/dist/index.cjs.map +4 -4
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/lib/parse-mvt.d.ts +2 -1
- package/dist/lib/parse-mvt.d.ts.map +1 -1
- package/dist/lib/parse-mvt.js +15 -45
- package/dist/lib/parse-tilejson.d.ts +4 -4
- package/dist/lib/parse-tilejson.d.ts.map +1 -1
- package/dist/lib/types.d.ts +1 -39
- package/dist/lib/types.d.ts.map +1 -1
- package/dist/lib/utils/geometry-utils.d.ts +83 -0
- package/dist/lib/utils/geometry-utils.d.ts.map +1 -0
- package/dist/lib/utils/geometry-utils.js +206 -0
- package/dist/lib/vector-tile/vector-tile-feature.d.ts +72 -0
- package/dist/lib/vector-tile/vector-tile-feature.d.ts.map +1 -0
- package/dist/lib/vector-tile/vector-tile-feature.js +342 -0
- package/dist/lib/{mapbox-vector-tile → vector-tile}/vector-tile-layer.d.ts +10 -1
- package/dist/lib/vector-tile/vector-tile-layer.d.ts.map +1 -0
- package/dist/lib/{mapbox-vector-tile → vector-tile}/vector-tile-layer.js +16 -1
- package/dist/lib/vector-tile/vector-tile.d.ts.map +1 -0
- package/dist/lib/{geojson-tiler → vector-tiler}/clip.d.ts +3 -3
- package/dist/lib/vector-tiler/clip.d.ts.map +1 -0
- package/dist/lib/vector-tiler/convert.d.ts +18 -0
- package/dist/lib/vector-tiler/convert.d.ts.map +1 -0
- package/dist/lib/{geojson-tiler → vector-tiler}/convert.js +8 -1
- package/dist/lib/vector-tiler/feature.d.ts +3 -0
- package/dist/lib/vector-tiler/feature.d.ts.map +1 -0
- package/dist/lib/vector-tiler/simplify.d.ts.map +1 -0
- package/dist/lib/{geojson-tiler → vector-tiler}/tile.d.ts +4 -4
- package/dist/lib/vector-tiler/tile.d.ts.map +1 -0
- package/dist/lib/vector-tiler/transform.d.ts +7 -0
- package/dist/lib/vector-tiler/transform.d.ts.map +1 -0
- package/dist/lib/{geojson-tiler → vector-tiler}/wrap.d.ts +2 -2
- package/dist/lib/vector-tiler/wrap.d.ts.map +1 -0
- package/dist/mvt-loader.d.ts +19 -8
- package/dist/mvt-loader.d.ts.map +1 -1
- package/dist/mvt-loader.js +3 -2
- package/dist/mvt-source.d.ts +4 -4
- package/dist/mvt-source.d.ts.map +1 -1
- package/dist/mvt-source.js +7 -7
- package/dist/mvt-worker.js +1244 -762
- package/dist/table-tile-source.d.ts +118 -0
- package/dist/table-tile-source.d.ts.map +1 -0
- package/dist/table-tile-source.js +370 -0
- package/dist/tilejson-loader.js +1 -1
- package/package.json +7 -6
- package/src/index.ts +3 -3
- package/src/lib/parse-mvt.ts +28 -66
- package/src/lib/parse-tilejson.ts +5 -5
- package/src/lib/types.ts +1 -39
- package/src/lib/utils/geometry-utils.ts +234 -0
- package/src/lib/vector-tile/vector-tile-feature.ts +416 -0
- package/src/lib/{mapbox-vector-tile → vector-tile}/vector-tile-layer.ts +28 -2
- package/src/lib/{geojson-tiler → vector-tiler}/clip.ts +4 -4
- package/src/lib/{geojson-tiler → vector-tiler}/convert.ts +19 -9
- package/src/lib/{geojson-tiler → vector-tiler}/feature.ts +3 -3
- package/src/lib/{geojson-tiler → vector-tiler}/tile.ts +10 -10
- package/src/lib/{geojson-tiler → vector-tiler}/transform.ts +2 -2
- package/src/lib/{geojson-tiler → vector-tiler}/wrap.ts +5 -5
- package/src/mvt-loader.ts +14 -6
- package/src/mvt-source.ts +9 -10
- package/src/table-tile-source.ts +508 -0
- package/dist/helpers/binary-util-functions.d.ts +0 -35
- package/dist/helpers/binary-util-functions.d.ts.map +0 -1
- package/dist/helpers/binary-util-functions.js +0 -114
- package/dist/helpers/mapbox-util-functions.d.ts +0 -29
- package/dist/helpers/mapbox-util-functions.d.ts.map +0 -1
- package/dist/helpers/mapbox-util-functions.js +0 -78
- package/dist/lib/binary-vector-tile/vector-tile-feature.d.ts +0 -41
- package/dist/lib/binary-vector-tile/vector-tile-feature.d.ts.map +0 -1
- package/dist/lib/binary-vector-tile/vector-tile-feature.js +0 -163
- package/dist/lib/binary-vector-tile/vector-tile-layer.d.ts +0 -23
- package/dist/lib/binary-vector-tile/vector-tile-layer.d.ts.map +0 -1
- package/dist/lib/binary-vector-tile/vector-tile-layer.js +0 -96
- package/dist/lib/binary-vector-tile/vector-tile.d.ts +0 -9
- package/dist/lib/binary-vector-tile/vector-tile.d.ts.map +0 -1
- package/dist/lib/binary-vector-tile/vector-tile.js +0 -27
- package/dist/lib/geojson-tiler/clip.d.ts.map +0 -1
- package/dist/lib/geojson-tiler/convert.d.ts +0 -10
- package/dist/lib/geojson-tiler/convert.d.ts.map +0 -1
- package/dist/lib/geojson-tiler/feature.d.ts +0 -3
- package/dist/lib/geojson-tiler/feature.d.ts.map +0 -1
- package/dist/lib/geojson-tiler/geojson-tiler.d.ts +0 -44
- package/dist/lib/geojson-tiler/geojson-tiler.d.ts.map +0 -1
- package/dist/lib/geojson-tiler/geojson-tiler.js +0 -209
- package/dist/lib/geojson-tiler/simplify.d.ts.map +0 -1
- package/dist/lib/geojson-tiler/tile.d.ts.map +0 -1
- package/dist/lib/geojson-tiler/transform.d.ts +0 -7
- package/dist/lib/geojson-tiler/transform.d.ts.map +0 -1
- package/dist/lib/geojson-tiler/wrap.d.ts.map +0 -1
- package/dist/lib/mapbox-vector-tile/vector-tile-feature.d.ts +0 -27
- package/dist/lib/mapbox-vector-tile/vector-tile-feature.d.ts.map +0 -1
- package/dist/lib/mapbox-vector-tile/vector-tile-feature.js +0 -178
- package/dist/lib/mapbox-vector-tile/vector-tile-layer.d.ts.map +0 -1
- package/dist/lib/mapbox-vector-tile/vector-tile.d.ts.map +0 -1
- package/src/helpers/binary-util-functions.ts +0 -125
- package/src/helpers/mapbox-util-functions.ts +0 -82
- package/src/lib/binary-vector-tile/vector-tile-feature.ts +0 -203
- package/src/lib/binary-vector-tile/vector-tile-layer.ts +0 -113
- package/src/lib/binary-vector-tile/vector-tile.ts +0 -36
- package/src/lib/geojson-tiler/geojson-tiler.ts +0 -283
- package/src/lib/mapbox-vector-tile/LICENSE.txt +0 -31
- package/src/lib/mapbox-vector-tile/vector-tile-feature.ts +0 -207
- /package/dist/lib/{mapbox-vector-tile → vector-tile}/vector-tile.d.ts +0 -0
- /package/dist/lib/{mapbox-vector-tile → vector-tile}/vector-tile.js +0 -0
- /package/dist/lib/{geojson-tiler → vector-tiler}/clip.js +0 -0
- /package/dist/lib/{geojson-tiler → vector-tiler}/feature.js +0 -0
- /package/dist/lib/{geojson-tiler → vector-tiler}/simplify.d.ts +0 -0
- /package/dist/lib/{geojson-tiler → vector-tiler}/simplify.js +0 -0
- /package/dist/lib/{geojson-tiler → vector-tiler}/tile.js +0 -0
- /package/dist/lib/{geojson-tiler → vector-tiler}/transform.js +0 -0
- /package/dist/lib/{geojson-tiler → vector-tiler}/wrap.js +0 -0
- /package/src/lib/{binary-vector-tile → vector-tile}/LICENSE.txt +0 -0
- /package/src/lib/{mapbox-vector-tile → vector-tile}/vector-tile.ts +0 -0
- /package/src/lib/{geojson-tiler → vector-tiler}/LICENSE +0 -0
- /package/src/lib/{geojson-tiler → vector-tiler}/simplify.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
|
|
62
|
+
var i = isLE ? nBytes - 1 : 0;
|
|
58
63
|
var d = isLE ? -1 : 1;
|
|
59
|
-
var s = buffer[offset +
|
|
60
|
-
|
|
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 +
|
|
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 +
|
|
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
|
|
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 +
|
|
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 +
|
|
129
|
+
for (; eLen > 0; buffer[offset + i] = e & 255, i += d, e /= 256, eLen -= 8) {
|
|
125
130
|
}
|
|
126
|
-
buffer[offset +
|
|
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
|
|
349
|
-
while (
|
|
350
|
-
|
|
351
|
-
if (
|
|
352
|
-
var buf = new Uint8Array(
|
|
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 =
|
|
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
|
|
437
|
-
this.buf[this.pos++] = buffer[
|
|
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
|
|
627
|
-
pbf.buf[
|
|
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
|
|
631
|
-
pbf.writeVarint(arr[
|
|
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
|
|
635
|
-
pbf.writeSVarint(arr[
|
|
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
|
|
639
|
-
pbf.writeFloat(arr[
|
|
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
|
|
643
|
-
pbf.writeDouble(arr[
|
|
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
|
|
647
|
-
pbf.writeBoolean(arr[
|
|
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
|
|
651
|
-
pbf.writeFixed32(arr[
|
|
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
|
|
655
|
-
pbf.writeSFixed32(arr[
|
|
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
|
|
659
|
-
pbf.writeFixed64(arr[
|
|
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
|
|
663
|
-
pbf.writeSFixed64(arr[
|
|
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
|
|
680
|
-
while (
|
|
681
|
-
var b0 = buf[
|
|
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 (
|
|
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[
|
|
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[
|
|
701
|
-
b2 = buf[
|
|
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[
|
|
710
|
-
b2 = buf[
|
|
711
|
-
b3 = buf[
|
|
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
|
-
|
|
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
|
|
737
|
-
c = str.charCodeAt(
|
|
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 ||
|
|
756
|
+
if (c > 56319 || i + 1 === str.length) {
|
|
752
757
|
buf[pos++] = 239;
|
|
753
758
|
buf[pos++] = 191;
|
|
754
759
|
buf[pos++] = 189;
|
|
@@ -788,14 +793,142 @@ var __exports__ = (() => {
|
|
|
788
793
|
// bundle.ts
|
|
789
794
|
var bundle_exports = {};
|
|
790
795
|
__export(bundle_exports, {
|
|
791
|
-
GeoJSONTiler: () => GeoJSONTiler,
|
|
792
796
|
MVTLoader: () => MVTLoader,
|
|
793
797
|
MVTSource: () => MVTSource,
|
|
794
798
|
MVTWorkerLoader: () => MVTWorkerLoader,
|
|
799
|
+
TableTileSource: () => TableTileSource,
|
|
795
800
|
TileJSONLoader: () => TileJSONLoader
|
|
796
801
|
});
|
|
797
802
|
__reExport(bundle_exports, __toESM(require_core(), 1));
|
|
798
803
|
|
|
804
|
+
// ../schema/src/lib/table/simple-table/data-type.ts
|
|
805
|
+
function getDataTypeFromValue(value, defaultNumberType = "float32") {
|
|
806
|
+
if (value instanceof Date) {
|
|
807
|
+
return "date-millisecond";
|
|
808
|
+
}
|
|
809
|
+
if (value instanceof Number) {
|
|
810
|
+
return defaultNumberType;
|
|
811
|
+
}
|
|
812
|
+
if (typeof value === "string") {
|
|
813
|
+
return "utf8";
|
|
814
|
+
}
|
|
815
|
+
if (value === null || value === "undefined") {
|
|
816
|
+
return "null";
|
|
817
|
+
}
|
|
818
|
+
return "null";
|
|
819
|
+
}
|
|
820
|
+
function getDataTypeFromArray(array) {
|
|
821
|
+
let type = getDataTypeFromTypedArray(array);
|
|
822
|
+
if (type !== "null") {
|
|
823
|
+
return { type, nullable: false };
|
|
824
|
+
}
|
|
825
|
+
if (array.length > 0) {
|
|
826
|
+
type = getDataTypeFromValue(array[0]);
|
|
827
|
+
return { type, nullable: true };
|
|
828
|
+
}
|
|
829
|
+
return { type: "null", nullable: true };
|
|
830
|
+
}
|
|
831
|
+
function getDataTypeFromTypedArray(array) {
|
|
832
|
+
switch (array.constructor) {
|
|
833
|
+
case Int8Array:
|
|
834
|
+
return "int8";
|
|
835
|
+
case Uint8Array:
|
|
836
|
+
case Uint8ClampedArray:
|
|
837
|
+
return "uint8";
|
|
838
|
+
case Int16Array:
|
|
839
|
+
return "int16";
|
|
840
|
+
case Uint16Array:
|
|
841
|
+
return "uint16";
|
|
842
|
+
case Int32Array:
|
|
843
|
+
return "int32";
|
|
844
|
+
case Uint32Array:
|
|
845
|
+
return "uint32";
|
|
846
|
+
case Float32Array:
|
|
847
|
+
return "float32";
|
|
848
|
+
case Float64Array:
|
|
849
|
+
return "float64";
|
|
850
|
+
default:
|
|
851
|
+
return "null";
|
|
852
|
+
}
|
|
853
|
+
}
|
|
854
|
+
|
|
855
|
+
// ../schema/src/lib/table/simple-table/table-schema.ts
|
|
856
|
+
function deduceTableSchema(table) {
|
|
857
|
+
switch (table.shape) {
|
|
858
|
+
case "array-row-table":
|
|
859
|
+
case "object-row-table":
|
|
860
|
+
return deduceSchemaFromRows(table.data);
|
|
861
|
+
case "geojson-table":
|
|
862
|
+
return deduceSchemaFromGeoJSON(table.features);
|
|
863
|
+
case "columnar-table":
|
|
864
|
+
return deduceSchemaFromColumns(table.data);
|
|
865
|
+
case "arrow-table":
|
|
866
|
+
default:
|
|
867
|
+
throw new Error("Deduce schema");
|
|
868
|
+
}
|
|
869
|
+
}
|
|
870
|
+
function deduceSchemaFromColumns(columnarTable) {
|
|
871
|
+
const fields = [];
|
|
872
|
+
for (const [columnName, column] of Object.entries(columnarTable)) {
|
|
873
|
+
const field = deduceFieldFromColumn(column, columnName);
|
|
874
|
+
fields.push(field);
|
|
875
|
+
}
|
|
876
|
+
return { fields, metadata: {} };
|
|
877
|
+
}
|
|
878
|
+
function deduceSchemaFromRows(rowTable) {
|
|
879
|
+
if (!rowTable.length) {
|
|
880
|
+
throw new Error("deduce from empty table");
|
|
881
|
+
}
|
|
882
|
+
const fields = [];
|
|
883
|
+
const row0 = rowTable[0];
|
|
884
|
+
for (const [columnName, value] of Object.entries(row0)) {
|
|
885
|
+
fields.push(deduceFieldFromValue(value, columnName));
|
|
886
|
+
}
|
|
887
|
+
return { fields, metadata: {} };
|
|
888
|
+
}
|
|
889
|
+
function deduceSchemaFromGeoJSON(features) {
|
|
890
|
+
if (!features.length) {
|
|
891
|
+
throw new Error("deduce from empty table");
|
|
892
|
+
}
|
|
893
|
+
const fields = [];
|
|
894
|
+
const row0 = features[0].properties || {};
|
|
895
|
+
for (const [columnName, value] of Object.entries(row0)) {
|
|
896
|
+
fields.push(deduceFieldFromValue(value, columnName));
|
|
897
|
+
}
|
|
898
|
+
return { fields, metadata: {} };
|
|
899
|
+
}
|
|
900
|
+
function deduceFieldFromColumn(column, name) {
|
|
901
|
+
if (ArrayBuffer.isView(column)) {
|
|
902
|
+
const type = getDataTypeFromArray(column);
|
|
903
|
+
return {
|
|
904
|
+
name,
|
|
905
|
+
type: type.type || "null",
|
|
906
|
+
nullable: type.nullable
|
|
907
|
+
// metadata: {}
|
|
908
|
+
};
|
|
909
|
+
}
|
|
910
|
+
if (Array.isArray(column) && column.length > 0) {
|
|
911
|
+
const value = column[0];
|
|
912
|
+
const type = getDataTypeFromValue(value);
|
|
913
|
+
return {
|
|
914
|
+
name,
|
|
915
|
+
type,
|
|
916
|
+
nullable: true
|
|
917
|
+
// metadata: {},
|
|
918
|
+
};
|
|
919
|
+
}
|
|
920
|
+
throw new Error("empty table");
|
|
921
|
+
}
|
|
922
|
+
function deduceFieldFromValue(value, name) {
|
|
923
|
+
const type = getDataTypeFromValue(value);
|
|
924
|
+
return {
|
|
925
|
+
name,
|
|
926
|
+
type,
|
|
927
|
+
nullable: true
|
|
928
|
+
// metadata: {}
|
|
929
|
+
};
|
|
930
|
+
}
|
|
931
|
+
|
|
799
932
|
// ../../node_modules/@babel/runtime/helpers/esm/typeof.js
|
|
800
933
|
function _typeof(obj) {
|
|
801
934
|
"@babel/helpers - typeof";
|
|
@@ -858,9 +991,9 @@ var __exports__ = (() => {
|
|
|
858
991
|
let area2 = 0;
|
|
859
992
|
const i0 = DimIndex[plane[0]];
|
|
860
993
|
const i1 = DimIndex[plane[1]];
|
|
861
|
-
for (let
|
|
862
|
-
area2 += (points[
|
|
863
|
-
j =
|
|
994
|
+
for (let i = start, j = end - dim; i < end; i += dim) {
|
|
995
|
+
area2 += (points[i + i0] - points[j + i0]) * (points[i + i1] + points[j + i1]);
|
|
996
|
+
j = i;
|
|
864
997
|
}
|
|
865
998
|
return area2 / 2;
|
|
866
999
|
}
|
|
@@ -878,24 +1011,24 @@ var __exports__ = (() => {
|
|
|
878
1011
|
let maxY;
|
|
879
1012
|
let minX;
|
|
880
1013
|
let minY;
|
|
881
|
-
let
|
|
882
|
-
let
|
|
1014
|
+
let x;
|
|
1015
|
+
let y;
|
|
883
1016
|
if (hasHoles)
|
|
884
1017
|
outerNode = eliminateHoles(positions, holeIndices, outerNode, dim, areas, plane);
|
|
885
1018
|
if (positions.length > 80 * dim) {
|
|
886
1019
|
minX = maxX = positions[0];
|
|
887
1020
|
minY = maxY = positions[1];
|
|
888
|
-
for (let
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
if (
|
|
892
|
-
minX =
|
|
893
|
-
if (
|
|
894
|
-
minY =
|
|
895
|
-
if (
|
|
896
|
-
maxX =
|
|
897
|
-
if (
|
|
898
|
-
maxY =
|
|
1021
|
+
for (let i = dim; i < outerLen; i += dim) {
|
|
1022
|
+
x = positions[i];
|
|
1023
|
+
y = positions[i + 1];
|
|
1024
|
+
if (x < minX)
|
|
1025
|
+
minX = x;
|
|
1026
|
+
if (y < minY)
|
|
1027
|
+
minY = y;
|
|
1028
|
+
if (x > maxX)
|
|
1029
|
+
maxX = x;
|
|
1030
|
+
if (y > maxY)
|
|
1031
|
+
maxY = y;
|
|
899
1032
|
}
|
|
900
1033
|
invSize = Math.max(maxX - minX, maxY - minY);
|
|
901
1034
|
invSize = invSize !== 0 ? 32767 / invSize : 0;
|
|
@@ -904,7 +1037,7 @@ var __exports__ = (() => {
|
|
|
904
1037
|
return triangles;
|
|
905
1038
|
}
|
|
906
1039
|
function linkedList(data, start, end, dim, clockwise, area2, plane) {
|
|
907
|
-
let
|
|
1040
|
+
let i;
|
|
908
1041
|
let last;
|
|
909
1042
|
if (area2 === void 0) {
|
|
910
1043
|
area2 = getPolygonSignedArea(data, {
|
|
@@ -917,11 +1050,11 @@ var __exports__ = (() => {
|
|
|
917
1050
|
let i0 = DimIndex[plane[0]];
|
|
918
1051
|
let i1 = DimIndex[plane[1]];
|
|
919
1052
|
if (clockwise === area2 < 0) {
|
|
920
|
-
for (
|
|
921
|
-
last = insertNode(
|
|
1053
|
+
for (i = start; i < end; i += dim)
|
|
1054
|
+
last = insertNode(i, data[i + i0], data[i + i1], last);
|
|
922
1055
|
} else {
|
|
923
|
-
for (
|
|
924
|
-
last = insertNode(
|
|
1056
|
+
for (i = end - dim; i >= start; i -= dim)
|
|
1057
|
+
last = insertNode(i, data[i + i0], data[i + i1], last);
|
|
925
1058
|
}
|
|
926
1059
|
if (last && equals(last, last.next)) {
|
|
927
1060
|
removeNode(last);
|
|
@@ -1085,22 +1218,22 @@ var __exports__ = (() => {
|
|
|
1085
1218
|
}
|
|
1086
1219
|
function eliminateHoles(data, holeIndices, outerNode, dim, areas, plane) {
|
|
1087
1220
|
const queue = [];
|
|
1088
|
-
let
|
|
1221
|
+
let i;
|
|
1089
1222
|
let len;
|
|
1090
1223
|
let start;
|
|
1091
1224
|
let end;
|
|
1092
1225
|
let list;
|
|
1093
|
-
for (
|
|
1094
|
-
start = holeIndices[
|
|
1095
|
-
end =
|
|
1096
|
-
list = linkedList(data, start, end, dim, false, areas && areas[
|
|
1226
|
+
for (i = 0, len = holeIndices.length; i < len; i++) {
|
|
1227
|
+
start = holeIndices[i] * dim;
|
|
1228
|
+
end = i < len - 1 ? holeIndices[i + 1] * dim : data.length;
|
|
1229
|
+
list = linkedList(data, start, end, dim, false, areas && areas[i + 1], plane);
|
|
1097
1230
|
if (list === list.next)
|
|
1098
1231
|
list.steiner = true;
|
|
1099
1232
|
queue.push(getLeftmost(list));
|
|
1100
1233
|
}
|
|
1101
1234
|
queue.sort(compareX);
|
|
1102
|
-
for (
|
|
1103
|
-
outerNode = eliminateHole(queue[
|
|
1235
|
+
for (i = 0; i < queue.length; i++) {
|
|
1236
|
+
outerNode = eliminateHole(queue[i], outerNode);
|
|
1104
1237
|
}
|
|
1105
1238
|
return outerNode;
|
|
1106
1239
|
}
|
|
@@ -1124,11 +1257,11 @@ var __exports__ = (() => {
|
|
|
1124
1257
|
let m;
|
|
1125
1258
|
do {
|
|
1126
1259
|
if (hy <= p.y && hy >= p.next.y && p.next.y !== p.y) {
|
|
1127
|
-
const
|
|
1128
|
-
if (
|
|
1129
|
-
qx =
|
|
1260
|
+
const x = p.x + (hy - p.y) * (p.next.x - p.x) / (p.next.y - p.y);
|
|
1261
|
+
if (x <= hx && x > qx) {
|
|
1262
|
+
qx = x;
|
|
1130
1263
|
m = p.x < p.next.x ? p : p.next;
|
|
1131
|
-
if (
|
|
1264
|
+
if (x === hx)
|
|
1132
1265
|
return m;
|
|
1133
1266
|
}
|
|
1134
1267
|
}
|
|
@@ -1172,7 +1305,7 @@ var __exports__ = (() => {
|
|
|
1172
1305
|
}
|
|
1173
1306
|
function sortLinked(list) {
|
|
1174
1307
|
let e;
|
|
1175
|
-
let
|
|
1308
|
+
let i;
|
|
1176
1309
|
let inSize = 1;
|
|
1177
1310
|
let numMerges;
|
|
1178
1311
|
let p;
|
|
@@ -1189,7 +1322,7 @@ var __exports__ = (() => {
|
|
|
1189
1322
|
numMerges++;
|
|
1190
1323
|
q = p;
|
|
1191
1324
|
pSize = 0;
|
|
1192
|
-
for (
|
|
1325
|
+
for (i = 0; i < inSize; i++) {
|
|
1193
1326
|
pSize++;
|
|
1194
1327
|
q = q.nextZ;
|
|
1195
1328
|
if (!q)
|
|
@@ -1220,18 +1353,18 @@ var __exports__ = (() => {
|
|
|
1220
1353
|
} while (numMerges > 1);
|
|
1221
1354
|
return list;
|
|
1222
1355
|
}
|
|
1223
|
-
function zOrder(
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
return
|
|
1356
|
+
function zOrder(x, y, minX, minY, invSize) {
|
|
1357
|
+
x = (x - minX) * invSize | 0;
|
|
1358
|
+
y = (y - minY) * invSize | 0;
|
|
1359
|
+
x = (x | x << 8) & 16711935;
|
|
1360
|
+
x = (x | x << 4) & 252645135;
|
|
1361
|
+
x = (x | x << 2) & 858993459;
|
|
1362
|
+
x = (x | x << 1) & 1431655765;
|
|
1363
|
+
y = (y | y << 8) & 16711935;
|
|
1364
|
+
y = (y | y << 4) & 252645135;
|
|
1365
|
+
y = (y | y << 2) & 858993459;
|
|
1366
|
+
y = (y | y << 1) & 1431655765;
|
|
1367
|
+
return x | y << 1;
|
|
1235
1368
|
}
|
|
1236
1369
|
function getLeftmost(start) {
|
|
1237
1370
|
let p = start;
|
|
@@ -1317,8 +1450,8 @@ var __exports__ = (() => {
|
|
|
1317
1450
|
b2.prev = bp;
|
|
1318
1451
|
return b2;
|
|
1319
1452
|
}
|
|
1320
|
-
function insertNode(
|
|
1321
|
-
const p = new Vertex(
|
|
1453
|
+
function insertNode(i, x, y, last) {
|
|
1454
|
+
const p = new Vertex(i, x, y);
|
|
1322
1455
|
if (!last) {
|
|
1323
1456
|
p.prev = p;
|
|
1324
1457
|
p.next = p;
|
|
@@ -1339,7 +1472,7 @@ var __exports__ = (() => {
|
|
|
1339
1472
|
p.nextZ.prevZ = p.prevZ;
|
|
1340
1473
|
}
|
|
1341
1474
|
var Vertex = class {
|
|
1342
|
-
constructor(
|
|
1475
|
+
constructor(i, x, y) {
|
|
1343
1476
|
_defineProperty(this, "i", void 0);
|
|
1344
1477
|
_defineProperty(this, "x", void 0);
|
|
1345
1478
|
_defineProperty(this, "y", void 0);
|
|
@@ -1349,9 +1482,9 @@ var __exports__ = (() => {
|
|
|
1349
1482
|
_defineProperty(this, "prevZ", null);
|
|
1350
1483
|
_defineProperty(this, "nextZ", null);
|
|
1351
1484
|
_defineProperty(this, "steiner", false);
|
|
1352
|
-
this.i =
|
|
1353
|
-
this.x =
|
|
1354
|
-
this.y =
|
|
1485
|
+
this.i = i;
|
|
1486
|
+
this.x = x;
|
|
1487
|
+
this.y = y;
|
|
1355
1488
|
}
|
|
1356
1489
|
};
|
|
1357
1490
|
|
|
@@ -1520,9 +1653,9 @@ var __exports__ = (() => {
|
|
|
1520
1653
|
indexMap.linePosition,
|
|
1521
1654
|
indexMap.linePosition + nPositions
|
|
1522
1655
|
);
|
|
1523
|
-
for (let
|
|
1524
|
-
const start = geometry.indices[
|
|
1525
|
-
const end =
|
|
1656
|
+
for (let i = 0, il = geometry.indices.length; i < il; ++i) {
|
|
1657
|
+
const start = geometry.indices[i];
|
|
1658
|
+
const end = i === il - 1 ? geometry.data.length : geometry.indices[i + 1];
|
|
1526
1659
|
lines.pathIndices[indexMap.linePath++] = indexMap.linePosition;
|
|
1527
1660
|
indexMap.linePosition += (end - start) / coordLength;
|
|
1528
1661
|
}
|
|
@@ -1547,12 +1680,12 @@ var __exports__ = (() => {
|
|
|
1547
1680
|
const areas = geometry.areas[l];
|
|
1548
1681
|
const indices = geometry.indices[l];
|
|
1549
1682
|
const nextIndices = geometry.indices[l + 1];
|
|
1550
|
-
for (let
|
|
1551
|
-
const start = indices[
|
|
1552
|
-
const end =
|
|
1683
|
+
for (let i = 0, il = indices.length; i < il; ++i) {
|
|
1684
|
+
const start = indices[i];
|
|
1685
|
+
const end = i === il - 1 ? (
|
|
1553
1686
|
// last line, so either read to:
|
|
1554
1687
|
nextIndices === void 0 ? geometry.data.length : nextIndices[0]
|
|
1555
|
-
) : indices[
|
|
1688
|
+
) : indices[i + 1];
|
|
1556
1689
|
polygons.primitivePolygonIndices[indexMap.polygonRing++] = indexMap.polygonPosition;
|
|
1557
1690
|
indexMap.polygonPosition += (end - start) / coordLength;
|
|
1558
1691
|
}
|
|
@@ -1619,11 +1752,11 @@ var __exports__ = (() => {
|
|
|
1619
1752
|
}
|
|
1620
1753
|
return binaryFeatures;
|
|
1621
1754
|
}
|
|
1622
|
-
function fillNumericProperties(object, properties, index,
|
|
1755
|
+
function fillNumericProperties(object, properties, index, length) {
|
|
1623
1756
|
for (const numericPropName in object.numericProps) {
|
|
1624
1757
|
if (numericPropName in properties) {
|
|
1625
1758
|
const value = properties[numericPropName];
|
|
1626
|
-
object.numericProps[numericPropName].fill(value, index, index +
|
|
1759
|
+
object.numericProps[numericPropName].fill(value, index, index + length);
|
|
1627
1760
|
}
|
|
1628
1761
|
}
|
|
1629
1762
|
}
|
|
@@ -1636,320 +1769,723 @@ var __exports__ = (() => {
|
|
|
1636
1769
|
}
|
|
1637
1770
|
return props;
|
|
1638
1771
|
}
|
|
1639
|
-
function deduceArrayType(
|
|
1640
|
-
if (constructor === Array || !Number.isFinite(
|
|
1772
|
+
function deduceArrayType(x, constructor) {
|
|
1773
|
+
if (constructor === Array || !Number.isFinite(x)) {
|
|
1641
1774
|
return Array;
|
|
1642
1775
|
}
|
|
1643
|
-
return constructor === Float64Array || Math.fround(
|
|
1776
|
+
return constructor === Float64Array || Math.fround(x) !== x ? Float64Array : Float32Array;
|
|
1644
1777
|
}
|
|
1645
1778
|
|
|
1646
|
-
// src/lib/
|
|
1647
|
-
|
|
1779
|
+
// ../loader-utils/src/lib/env-utils/assert.ts
|
|
1780
|
+
function assert(condition, message) {
|
|
1781
|
+
if (!condition) {
|
|
1782
|
+
throw new Error(message || "loader assertion failed.");
|
|
1783
|
+
}
|
|
1784
|
+
}
|
|
1648
1785
|
|
|
1649
|
-
// src/
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
|
|
1653
|
-
|
|
1654
|
-
|
|
1655
|
-
|
|
1656
|
-
|
|
1657
|
-
|
|
1658
|
-
|
|
1659
|
-
|
|
1660
|
-
|
|
1661
|
-
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
|
|
1665
|
-
|
|
1666
|
-
|
|
1667
|
-
|
|
1668
|
-
|
|
1786
|
+
// ../loader-utils/src/lib/env-utils/globals.ts
|
|
1787
|
+
var globals = {
|
|
1788
|
+
self: typeof self !== "undefined" && self,
|
|
1789
|
+
window: typeof window !== "undefined" && window,
|
|
1790
|
+
global: typeof global !== "undefined" && global,
|
|
1791
|
+
document: typeof document !== "undefined" && document
|
|
1792
|
+
};
|
|
1793
|
+
var self_ = globals.self || globals.window || globals.global || {};
|
|
1794
|
+
var window_ = globals.window || globals.self || globals.global || {};
|
|
1795
|
+
var global_ = globals.global || globals.self || globals.window || {};
|
|
1796
|
+
var document_ = globals.document || {};
|
|
1797
|
+
var isBrowser = (
|
|
1798
|
+
// @ts-ignore process does not exist on browser
|
|
1799
|
+
Boolean(typeof process !== "object" || String(process) !== "[object process]" || process.browser)
|
|
1800
|
+
);
|
|
1801
|
+
var matches = typeof process !== "undefined" && process.version && /v([0-9]*)/.exec(process.version);
|
|
1802
|
+
var nodeVersion = matches && parseFloat(matches[1]) || 0;
|
|
1803
|
+
|
|
1804
|
+
// ../../node_modules/@probe.gl/log/node_modules/@probe.gl/env/dist/lib/is-electron.js
|
|
1805
|
+
function isElectron(mockUserAgent) {
|
|
1806
|
+
if (typeof window !== "undefined" && typeof window.process === "object" && window.process.type === "renderer") {
|
|
1807
|
+
return true;
|
|
1669
1808
|
}
|
|
1670
|
-
if (
|
|
1671
|
-
|
|
1672
|
-
|
|
1809
|
+
if (typeof process !== "undefined" && typeof process.versions === "object" && Boolean(process.versions["electron"])) {
|
|
1810
|
+
return true;
|
|
1811
|
+
}
|
|
1812
|
+
const realUserAgent = typeof navigator === "object" && typeof navigator.userAgent === "string" && navigator.userAgent;
|
|
1813
|
+
const userAgent = mockUserAgent || realUserAgent;
|
|
1814
|
+
if (userAgent && userAgent.indexOf("Electron") >= 0) {
|
|
1815
|
+
return true;
|
|
1816
|
+
}
|
|
1817
|
+
return false;
|
|
1673
1818
|
}
|
|
1674
|
-
|
|
1675
|
-
|
|
1676
|
-
|
|
1677
|
-
|
|
1678
|
-
|
|
1679
|
-
|
|
1819
|
+
|
|
1820
|
+
// ../../node_modules/@probe.gl/log/node_modules/@probe.gl/env/dist/lib/is-browser.js
|
|
1821
|
+
function isBrowser2() {
|
|
1822
|
+
const isNode = typeof process === "object" && String(process) === "[object process]" && !process.browser;
|
|
1823
|
+
return !isNode || isElectron();
|
|
1824
|
+
}
|
|
1825
|
+
|
|
1826
|
+
// ../../node_modules/@probe.gl/log/node_modules/@probe.gl/env/dist/lib/globals.js
|
|
1827
|
+
var self_2 = globalThis.self || globalThis.window || globalThis.global;
|
|
1828
|
+
var window_2 = globalThis.window || globalThis.self || globalThis.global;
|
|
1829
|
+
var document_2 = globalThis.document || {};
|
|
1830
|
+
var process_ = globalThis.process || {};
|
|
1831
|
+
var console_ = globalThis.console;
|
|
1832
|
+
var navigator_ = globalThis.navigator || {};
|
|
1833
|
+
|
|
1834
|
+
// ../../node_modules/@probe.gl/log/node_modules/@probe.gl/env/dist/utils/globals.js
|
|
1835
|
+
var VERSION = typeof __VERSION__ !== "undefined" ? __VERSION__ : "untranspiled source";
|
|
1836
|
+
var isBrowser3 = isBrowser2();
|
|
1837
|
+
|
|
1838
|
+
// ../../node_modules/@probe.gl/log/dist/utils/local-storage.js
|
|
1839
|
+
function getStorage(type) {
|
|
1840
|
+
try {
|
|
1841
|
+
const storage = window[type];
|
|
1842
|
+
const x = "__storage_test__";
|
|
1843
|
+
storage.setItem(x, x);
|
|
1844
|
+
storage.removeItem(x);
|
|
1845
|
+
return storage;
|
|
1846
|
+
} catch (e) {
|
|
1847
|
+
return null;
|
|
1680
1848
|
}
|
|
1681
|
-
return sum;
|
|
1682
1849
|
}
|
|
1683
|
-
|
|
1684
|
-
|
|
1685
|
-
|
|
1686
|
-
|
|
1687
|
-
|
|
1688
|
-
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
|
|
1692
|
-
|
|
1850
|
+
var LocalStorage = class {
|
|
1851
|
+
constructor(id, defaultConfig) {
|
|
1852
|
+
let type = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : "sessionStorage";
|
|
1853
|
+
_defineProperty(this, "storage", void 0);
|
|
1854
|
+
_defineProperty(this, "id", void 0);
|
|
1855
|
+
_defineProperty(this, "config", void 0);
|
|
1856
|
+
this.storage = getStorage(type);
|
|
1857
|
+
this.id = id;
|
|
1858
|
+
this.config = defaultConfig;
|
|
1859
|
+
this._loadConfiguration();
|
|
1860
|
+
}
|
|
1861
|
+
getConfiguration() {
|
|
1862
|
+
return this.config;
|
|
1863
|
+
}
|
|
1864
|
+
setConfiguration(configuration) {
|
|
1865
|
+
Object.assign(this.config, configuration);
|
|
1866
|
+
if (this.storage) {
|
|
1867
|
+
const serialized = JSON.stringify(this.config);
|
|
1868
|
+
this.storage.setItem(this.id, serialized);
|
|
1869
|
+
}
|
|
1870
|
+
}
|
|
1871
|
+
_loadConfiguration() {
|
|
1872
|
+
let configuration = {};
|
|
1873
|
+
if (this.storage) {
|
|
1874
|
+
const serializedConfiguration = this.storage.getItem(this.id);
|
|
1875
|
+
configuration = serializedConfiguration ? JSON.parse(serializedConfiguration) : {};
|
|
1876
|
+
}
|
|
1877
|
+
Object.assign(this.config, configuration);
|
|
1878
|
+
return this;
|
|
1879
|
+
}
|
|
1880
|
+
};
|
|
1881
|
+
|
|
1882
|
+
// ../../node_modules/@probe.gl/log/dist/utils/formatters.js
|
|
1883
|
+
function formatTime(ms) {
|
|
1884
|
+
let formatted;
|
|
1885
|
+
if (ms < 10) {
|
|
1886
|
+
formatted = "".concat(ms.toFixed(2), "ms");
|
|
1887
|
+
} else if (ms < 100) {
|
|
1888
|
+
formatted = "".concat(ms.toFixed(1), "ms");
|
|
1889
|
+
} else if (ms < 1e3) {
|
|
1890
|
+
formatted = "".concat(ms.toFixed(0), "ms");
|
|
1891
|
+
} else {
|
|
1892
|
+
formatted = "".concat((ms / 1e3).toFixed(2), "s");
|
|
1693
1893
|
}
|
|
1894
|
+
return formatted;
|
|
1694
1895
|
}
|
|
1695
|
-
function
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
|
-
|
|
1700
|
-
|
|
1896
|
+
function leftPad(string) {
|
|
1897
|
+
let length = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 8;
|
|
1898
|
+
const padLength = Math.max(length - string.length, 0);
|
|
1899
|
+
return "".concat(" ".repeat(padLength)).concat(string);
|
|
1900
|
+
}
|
|
1901
|
+
function formatImage(image, message, scale) {
|
|
1902
|
+
let maxWidth = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : 600;
|
|
1903
|
+
const imageUrl = image.src.replace(/\(/g, "%28").replace(/\)/g, "%29");
|
|
1904
|
+
if (image.width > maxWidth) {
|
|
1905
|
+
scale = Math.min(scale, maxWidth / image.width);
|
|
1701
1906
|
}
|
|
1907
|
+
const width = image.width * scale;
|
|
1908
|
+
const height = image.height * scale;
|
|
1909
|
+
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("");
|
|
1910
|
+
return ["".concat(message, " %c+"), style];
|
|
1702
1911
|
}
|
|
1703
1912
|
|
|
1704
|
-
//
|
|
1705
|
-
var
|
|
1706
|
-
|
|
1707
|
-
|
|
1708
|
-
|
|
1709
|
-
|
|
1710
|
-
|
|
1711
|
-
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
|
|
1718
|
-
|
|
1719
|
-
|
|
1720
|
-
|
|
1721
|
-
|
|
1722
|
-
|
|
1723
|
-
|
|
1724
|
-
|
|
1725
|
-
|
|
1726
|
-
|
|
1913
|
+
// ../../node_modules/@probe.gl/log/dist/utils/color.js
|
|
1914
|
+
var COLOR;
|
|
1915
|
+
(function(COLOR2) {
|
|
1916
|
+
COLOR2[COLOR2["BLACK"] = 30] = "BLACK";
|
|
1917
|
+
COLOR2[COLOR2["RED"] = 31] = "RED";
|
|
1918
|
+
COLOR2[COLOR2["GREEN"] = 32] = "GREEN";
|
|
1919
|
+
COLOR2[COLOR2["YELLOW"] = 33] = "YELLOW";
|
|
1920
|
+
COLOR2[COLOR2["BLUE"] = 34] = "BLUE";
|
|
1921
|
+
COLOR2[COLOR2["MAGENTA"] = 35] = "MAGENTA";
|
|
1922
|
+
COLOR2[COLOR2["CYAN"] = 36] = "CYAN";
|
|
1923
|
+
COLOR2[COLOR2["WHITE"] = 37] = "WHITE";
|
|
1924
|
+
COLOR2[COLOR2["BRIGHT_BLACK"] = 90] = "BRIGHT_BLACK";
|
|
1925
|
+
COLOR2[COLOR2["BRIGHT_RED"] = 91] = "BRIGHT_RED";
|
|
1926
|
+
COLOR2[COLOR2["BRIGHT_GREEN"] = 92] = "BRIGHT_GREEN";
|
|
1927
|
+
COLOR2[COLOR2["BRIGHT_YELLOW"] = 93] = "BRIGHT_YELLOW";
|
|
1928
|
+
COLOR2[COLOR2["BRIGHT_BLUE"] = 94] = "BRIGHT_BLUE";
|
|
1929
|
+
COLOR2[COLOR2["BRIGHT_MAGENTA"] = 95] = "BRIGHT_MAGENTA";
|
|
1930
|
+
COLOR2[COLOR2["BRIGHT_CYAN"] = 96] = "BRIGHT_CYAN";
|
|
1931
|
+
COLOR2[COLOR2["BRIGHT_WHITE"] = 97] = "BRIGHT_WHITE";
|
|
1932
|
+
})(COLOR || (COLOR = {}));
|
|
1933
|
+
var BACKGROUND_INCREMENT = 10;
|
|
1934
|
+
function getColor(color) {
|
|
1935
|
+
if (typeof color !== "string") {
|
|
1936
|
+
return color;
|
|
1937
|
+
}
|
|
1938
|
+
color = color.toUpperCase();
|
|
1939
|
+
return COLOR[color] || COLOR.WHITE;
|
|
1940
|
+
}
|
|
1941
|
+
function addColor(string, color, background) {
|
|
1942
|
+
if (!isBrowser2 && typeof string === "string") {
|
|
1943
|
+
if (color) {
|
|
1944
|
+
const colorCode = getColor(color);
|
|
1945
|
+
string = "\x1B[".concat(colorCode, "m").concat(string, "\x1B[39m");
|
|
1946
|
+
}
|
|
1947
|
+
if (background) {
|
|
1948
|
+
const colorCode = getColor(background);
|
|
1949
|
+
string = "\x1B[".concat(colorCode + BACKGROUND_INCREMENT, "m").concat(string, "\x1B[49m");
|
|
1950
|
+
}
|
|
1727
1951
|
}
|
|
1728
|
-
|
|
1729
|
-
|
|
1730
|
-
|
|
1731
|
-
|
|
1732
|
-
|
|
1733
|
-
|
|
1734
|
-
|
|
1735
|
-
|
|
1736
|
-
|
|
1737
|
-
|
|
1738
|
-
|
|
1739
|
-
|
|
1740
|
-
if (
|
|
1741
|
-
|
|
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}`);
|
|
1952
|
+
return string;
|
|
1953
|
+
}
|
|
1954
|
+
|
|
1955
|
+
// ../../node_modules/@probe.gl/log/dist/utils/autobind.js
|
|
1956
|
+
function autobind(obj) {
|
|
1957
|
+
let predefined = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : ["constructor"];
|
|
1958
|
+
const proto = Object.getPrototypeOf(obj);
|
|
1959
|
+
const propNames = Object.getOwnPropertyNames(proto);
|
|
1960
|
+
const object = obj;
|
|
1961
|
+
for (const key of propNames) {
|
|
1962
|
+
const value = object[key];
|
|
1963
|
+
if (typeof value === "function") {
|
|
1964
|
+
if (!predefined.find((name) => key === name)) {
|
|
1965
|
+
object[key] = value.bind(obj);
|
|
1762
1966
|
}
|
|
1763
1967
|
}
|
|
1764
|
-
if (line)
|
|
1765
|
-
lines.push(line);
|
|
1766
|
-
return lines;
|
|
1767
1968
|
}
|
|
1768
|
-
|
|
1769
|
-
|
|
1770
|
-
|
|
1771
|
-
|
|
1772
|
-
|
|
1773
|
-
|
|
1774
|
-
|
|
1775
|
-
|
|
1776
|
-
|
|
1777
|
-
|
|
1778
|
-
|
|
1779
|
-
|
|
1780
|
-
|
|
1781
|
-
|
|
1782
|
-
|
|
1783
|
-
|
|
1784
|
-
|
|
1785
|
-
|
|
1786
|
-
|
|
1787
|
-
|
|
1788
|
-
|
|
1789
|
-
|
|
1790
|
-
|
|
1791
|
-
|
|
1792
|
-
|
|
1793
|
-
|
|
1794
|
-
|
|
1795
|
-
|
|
1796
|
-
|
|
1797
|
-
|
|
1798
|
-
|
|
1799
|
-
|
|
1800
|
-
|
|
1801
|
-
|
|
1969
|
+
}
|
|
1970
|
+
|
|
1971
|
+
// ../../node_modules/@probe.gl/log/dist/utils/assert.js
|
|
1972
|
+
function assert2(condition, message) {
|
|
1973
|
+
if (!condition) {
|
|
1974
|
+
throw new Error(message || "Assertion failed");
|
|
1975
|
+
}
|
|
1976
|
+
}
|
|
1977
|
+
|
|
1978
|
+
// ../../node_modules/@probe.gl/log/dist/utils/hi-res-timestamp.js
|
|
1979
|
+
function getHiResTimestamp() {
|
|
1980
|
+
let timestamp;
|
|
1981
|
+
if (isBrowser2() && window_2.performance) {
|
|
1982
|
+
var _window$performance, _window$performance$n;
|
|
1983
|
+
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);
|
|
1984
|
+
} else if ("hrtime" in process_) {
|
|
1985
|
+
var _process$hrtime;
|
|
1986
|
+
const timeParts = process_ === null || process_ === void 0 ? void 0 : (_process$hrtime = process_.hrtime) === null || _process$hrtime === void 0 ? void 0 : _process$hrtime.call(process_);
|
|
1987
|
+
timestamp = timeParts[0] * 1e3 + timeParts[1] / 1e6;
|
|
1988
|
+
} else {
|
|
1989
|
+
timestamp = Date.now();
|
|
1990
|
+
}
|
|
1991
|
+
return timestamp;
|
|
1992
|
+
}
|
|
1993
|
+
|
|
1994
|
+
// ../../node_modules/@probe.gl/log/dist/log.js
|
|
1995
|
+
var originalConsole = {
|
|
1996
|
+
debug: isBrowser2() ? console.debug || console.log : console.log,
|
|
1997
|
+
log: console.log,
|
|
1998
|
+
info: console.info,
|
|
1999
|
+
warn: console.warn,
|
|
2000
|
+
error: console.error
|
|
2001
|
+
};
|
|
2002
|
+
var DEFAULT_LOG_CONFIGURATION = {
|
|
2003
|
+
enabled: true,
|
|
2004
|
+
level: 0
|
|
2005
|
+
};
|
|
2006
|
+
function noop() {
|
|
2007
|
+
}
|
|
2008
|
+
var cache = {};
|
|
2009
|
+
var ONCE = {
|
|
2010
|
+
once: true
|
|
2011
|
+
};
|
|
2012
|
+
var Log = class {
|
|
2013
|
+
constructor() {
|
|
2014
|
+
let {
|
|
2015
|
+
id
|
|
2016
|
+
} = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {
|
|
2017
|
+
id: ""
|
|
2018
|
+
};
|
|
2019
|
+
_defineProperty(this, "id", void 0);
|
|
2020
|
+
_defineProperty(this, "VERSION", VERSION);
|
|
2021
|
+
_defineProperty(this, "_startTs", getHiResTimestamp());
|
|
2022
|
+
_defineProperty(this, "_deltaTs", getHiResTimestamp());
|
|
2023
|
+
_defineProperty(this, "_storage", void 0);
|
|
2024
|
+
_defineProperty(this, "userData", {});
|
|
2025
|
+
_defineProperty(this, "LOG_THROTTLE_TIMEOUT", 0);
|
|
2026
|
+
this.id = id;
|
|
2027
|
+
this.userData = {};
|
|
2028
|
+
this._storage = new LocalStorage("__probe-".concat(this.id, "__"), DEFAULT_LOG_CONFIGURATION);
|
|
2029
|
+
this.timeStamp("".concat(this.id, " started"));
|
|
2030
|
+
autobind(this);
|
|
2031
|
+
Object.seal(this);
|
|
2032
|
+
}
|
|
2033
|
+
set level(newLevel) {
|
|
2034
|
+
this.setLevel(newLevel);
|
|
2035
|
+
}
|
|
2036
|
+
get level() {
|
|
2037
|
+
return this.getLevel();
|
|
2038
|
+
}
|
|
2039
|
+
isEnabled() {
|
|
2040
|
+
return this._storage.config.enabled;
|
|
2041
|
+
}
|
|
2042
|
+
getLevel() {
|
|
2043
|
+
return this._storage.config.level;
|
|
2044
|
+
}
|
|
2045
|
+
getTotal() {
|
|
2046
|
+
return Number((getHiResTimestamp() - this._startTs).toPrecision(10));
|
|
2047
|
+
}
|
|
2048
|
+
getDelta() {
|
|
2049
|
+
return Number((getHiResTimestamp() - this._deltaTs).toPrecision(10));
|
|
2050
|
+
}
|
|
2051
|
+
set priority(newPriority) {
|
|
2052
|
+
this.level = newPriority;
|
|
2053
|
+
}
|
|
2054
|
+
get priority() {
|
|
2055
|
+
return this.level;
|
|
2056
|
+
}
|
|
2057
|
+
getPriority() {
|
|
2058
|
+
return this.level;
|
|
2059
|
+
}
|
|
2060
|
+
enable() {
|
|
2061
|
+
let enabled = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : true;
|
|
2062
|
+
this._storage.setConfiguration({
|
|
2063
|
+
enabled
|
|
2064
|
+
});
|
|
2065
|
+
return this;
|
|
2066
|
+
}
|
|
2067
|
+
setLevel(level) {
|
|
2068
|
+
this._storage.setConfiguration({
|
|
2069
|
+
level
|
|
2070
|
+
});
|
|
2071
|
+
return this;
|
|
2072
|
+
}
|
|
2073
|
+
get(setting) {
|
|
2074
|
+
return this._storage.config[setting];
|
|
2075
|
+
}
|
|
2076
|
+
set(setting, value) {
|
|
2077
|
+
this._storage.setConfiguration({
|
|
2078
|
+
[setting]: value
|
|
2079
|
+
});
|
|
2080
|
+
}
|
|
2081
|
+
settings() {
|
|
2082
|
+
if (console.table) {
|
|
2083
|
+
console.table(this._storage.config);
|
|
2084
|
+
} else {
|
|
2085
|
+
console.log(this._storage.config);
|
|
1802
2086
|
}
|
|
1803
|
-
return [x1, y1, x22, y22];
|
|
1804
2087
|
}
|
|
1805
|
-
|
|
1806
|
-
|
|
1807
|
-
|
|
1808
|
-
|
|
1809
|
-
|
|
1810
|
-
|
|
1811
|
-
|
|
1812
|
-
|
|
1813
|
-
|
|
1814
|
-
|
|
1815
|
-
|
|
1816
|
-
|
|
1817
|
-
|
|
1818
|
-
|
|
1819
|
-
|
|
1820
|
-
|
|
1821
|
-
|
|
1822
|
-
|
|
1823
|
-
|
|
1824
|
-
|
|
1825
|
-
|
|
1826
|
-
|
|
1827
|
-
|
|
1828
|
-
|
|
1829
|
-
|
|
1830
|
-
|
|
1831
|
-
|
|
2088
|
+
assert(condition, message) {
|
|
2089
|
+
assert2(condition, message);
|
|
2090
|
+
}
|
|
2091
|
+
warn(message) {
|
|
2092
|
+
return this._getLogFunction(0, message, originalConsole.warn, arguments, ONCE);
|
|
2093
|
+
}
|
|
2094
|
+
error(message) {
|
|
2095
|
+
return this._getLogFunction(0, message, originalConsole.error, arguments);
|
|
2096
|
+
}
|
|
2097
|
+
deprecated(oldUsage, newUsage) {
|
|
2098
|
+
return this.warn("`".concat(oldUsage, "` is deprecated and will be removed in a later version. Use `").concat(newUsage, "` instead"));
|
|
2099
|
+
}
|
|
2100
|
+
removed(oldUsage, newUsage) {
|
|
2101
|
+
return this.error("`".concat(oldUsage, "` has been removed. Use `").concat(newUsage, "` instead"));
|
|
2102
|
+
}
|
|
2103
|
+
probe(logLevel, message) {
|
|
2104
|
+
return this._getLogFunction(logLevel, message, originalConsole.log, arguments, {
|
|
2105
|
+
time: true,
|
|
2106
|
+
once: true
|
|
2107
|
+
});
|
|
2108
|
+
}
|
|
2109
|
+
log(logLevel, message) {
|
|
2110
|
+
return this._getLogFunction(logLevel, message, originalConsole.debug, arguments);
|
|
2111
|
+
}
|
|
2112
|
+
info(logLevel, message) {
|
|
2113
|
+
return this._getLogFunction(logLevel, message, console.info, arguments);
|
|
2114
|
+
}
|
|
2115
|
+
once(logLevel, message) {
|
|
2116
|
+
return this._getLogFunction(logLevel, message, originalConsole.debug || originalConsole.info, arguments, ONCE);
|
|
2117
|
+
}
|
|
2118
|
+
table(logLevel, table, columns) {
|
|
2119
|
+
if (table) {
|
|
2120
|
+
return this._getLogFunction(logLevel, table, console.table || noop, columns && [columns], {
|
|
2121
|
+
tag: getTableHeader(table)
|
|
2122
|
+
});
|
|
1832
2123
|
}
|
|
1833
|
-
|
|
1834
|
-
|
|
1835
|
-
|
|
1836
|
-
|
|
2124
|
+
return noop;
|
|
2125
|
+
}
|
|
2126
|
+
image(_ref) {
|
|
2127
|
+
let {
|
|
2128
|
+
logLevel,
|
|
2129
|
+
priority,
|
|
2130
|
+
image,
|
|
2131
|
+
message = "",
|
|
2132
|
+
scale = 1
|
|
2133
|
+
} = _ref;
|
|
2134
|
+
if (!this._shouldLog(logLevel || priority)) {
|
|
2135
|
+
return noop;
|
|
1837
2136
|
}
|
|
1838
|
-
|
|
1839
|
-
|
|
1840
|
-
|
|
1841
|
-
|
|
1842
|
-
|
|
1843
|
-
|
|
1844
|
-
|
|
2137
|
+
return isBrowser2() ? logImageInBrowser({
|
|
2138
|
+
image,
|
|
2139
|
+
message,
|
|
2140
|
+
scale
|
|
2141
|
+
}) : logImageInNode({
|
|
2142
|
+
image,
|
|
2143
|
+
message,
|
|
2144
|
+
scale
|
|
2145
|
+
});
|
|
2146
|
+
}
|
|
2147
|
+
time(logLevel, message) {
|
|
2148
|
+
return this._getLogFunction(logLevel, message, console.time ? console.time : console.info);
|
|
2149
|
+
}
|
|
2150
|
+
timeEnd(logLevel, message) {
|
|
2151
|
+
return this._getLogFunction(logLevel, message, console.timeEnd ? console.timeEnd : console.info);
|
|
2152
|
+
}
|
|
2153
|
+
timeStamp(logLevel, message) {
|
|
2154
|
+
return this._getLogFunction(logLevel, message, console.timeStamp || noop);
|
|
2155
|
+
}
|
|
2156
|
+
group(logLevel, message) {
|
|
2157
|
+
let opts = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {
|
|
2158
|
+
collapsed: false
|
|
1845
2159
|
};
|
|
1846
|
-
|
|
1847
|
-
|
|
2160
|
+
const options = normalizeArguments({
|
|
2161
|
+
logLevel,
|
|
2162
|
+
message,
|
|
2163
|
+
opts
|
|
2164
|
+
});
|
|
2165
|
+
const {
|
|
2166
|
+
collapsed
|
|
2167
|
+
} = opts;
|
|
2168
|
+
options.method = (collapsed ? console.groupCollapsed : console.group) || console.info;
|
|
2169
|
+
return this._getLogFunction(options);
|
|
2170
|
+
}
|
|
2171
|
+
groupCollapsed(logLevel, message) {
|
|
2172
|
+
let opts = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};
|
|
2173
|
+
return this.group(logLevel, message, Object.assign({}, opts, {
|
|
2174
|
+
collapsed: true
|
|
2175
|
+
}));
|
|
2176
|
+
}
|
|
2177
|
+
groupEnd(logLevel) {
|
|
2178
|
+
return this._getLogFunction(logLevel, "", console.groupEnd || noop);
|
|
2179
|
+
}
|
|
2180
|
+
withGroup(logLevel, message, func) {
|
|
2181
|
+
this.group(logLevel, message)();
|
|
2182
|
+
try {
|
|
2183
|
+
func();
|
|
2184
|
+
} finally {
|
|
2185
|
+
this.groupEnd(logLevel)();
|
|
1848
2186
|
}
|
|
1849
|
-
return result;
|
|
1850
2187
|
}
|
|
1851
|
-
|
|
1852
|
-
if (
|
|
1853
|
-
|
|
1854
|
-
}
|
|
1855
|
-
|
|
1856
|
-
|
|
1857
|
-
|
|
1858
|
-
|
|
1859
|
-
|
|
1860
|
-
|
|
1861
|
-
|
|
1862
|
-
|
|
1863
|
-
|
|
1864
|
-
|
|
2188
|
+
trace() {
|
|
2189
|
+
if (console.trace) {
|
|
2190
|
+
console.trace();
|
|
2191
|
+
}
|
|
2192
|
+
}
|
|
2193
|
+
_shouldLog(logLevel) {
|
|
2194
|
+
return this.isEnabled() && this.getLevel() >= normalizeLogLevel(logLevel);
|
|
2195
|
+
}
|
|
2196
|
+
_getLogFunction(logLevel, message, method, args, opts) {
|
|
2197
|
+
if (this._shouldLog(logLevel)) {
|
|
2198
|
+
opts = normalizeArguments({
|
|
2199
|
+
logLevel,
|
|
2200
|
+
message,
|
|
2201
|
+
args,
|
|
2202
|
+
opts
|
|
2203
|
+
});
|
|
2204
|
+
method = method || opts.method;
|
|
2205
|
+
assert2(method);
|
|
2206
|
+
opts.total = this.getTotal();
|
|
2207
|
+
opts.delta = this.getDelta();
|
|
2208
|
+
this._deltaTs = getHiResTimestamp();
|
|
2209
|
+
const tag = opts.tag || opts.message;
|
|
2210
|
+
if (opts.once && tag) {
|
|
2211
|
+
if (!cache[tag]) {
|
|
2212
|
+
cache[tag] = getHiResTimestamp();
|
|
2213
|
+
} else {
|
|
2214
|
+
return noop;
|
|
2215
|
+
}
|
|
1865
2216
|
}
|
|
2217
|
+
message = decorateMessage(this.id, opts.message, opts);
|
|
2218
|
+
return method.bind(console, message, ...opts.args);
|
|
1866
2219
|
}
|
|
1867
|
-
return
|
|
2220
|
+
return noop;
|
|
1868
2221
|
}
|
|
1869
2222
|
};
|
|
1870
|
-
|
|
1871
|
-
|
|
1872
|
-
|
|
1873
|
-
|
|
1874
|
-
|
|
1875
|
-
|
|
1876
|
-
|
|
1877
|
-
|
|
1878
|
-
|
|
1879
|
-
|
|
1880
|
-
|
|
1881
|
-
|
|
1882
|
-
|
|
1883
|
-
|
|
1884
|
-
|
|
1885
|
-
|
|
1886
|
-
|
|
1887
|
-
|
|
1888
|
-
|
|
1889
|
-
|
|
1890
|
-
|
|
1891
|
-
|
|
2223
|
+
_defineProperty(Log, "VERSION", VERSION);
|
|
2224
|
+
function normalizeLogLevel(logLevel) {
|
|
2225
|
+
if (!logLevel) {
|
|
2226
|
+
return 0;
|
|
2227
|
+
}
|
|
2228
|
+
let resolvedLevel;
|
|
2229
|
+
switch (typeof logLevel) {
|
|
2230
|
+
case "number":
|
|
2231
|
+
resolvedLevel = logLevel;
|
|
2232
|
+
break;
|
|
2233
|
+
case "object":
|
|
2234
|
+
resolvedLevel = logLevel.logLevel || logLevel.priority || 0;
|
|
2235
|
+
break;
|
|
2236
|
+
default:
|
|
2237
|
+
return 0;
|
|
2238
|
+
}
|
|
2239
|
+
assert2(Number.isFinite(resolvedLevel) && resolvedLevel >= 0);
|
|
2240
|
+
return resolvedLevel;
|
|
2241
|
+
}
|
|
2242
|
+
function normalizeArguments(opts) {
|
|
2243
|
+
const {
|
|
2244
|
+
logLevel,
|
|
2245
|
+
message
|
|
2246
|
+
} = opts;
|
|
2247
|
+
opts.logLevel = normalizeLogLevel(logLevel);
|
|
2248
|
+
const args = opts.args ? Array.from(opts.args) : [];
|
|
2249
|
+
while (args.length && args.shift() !== message) {
|
|
2250
|
+
}
|
|
2251
|
+
switch (typeof logLevel) {
|
|
2252
|
+
case "string":
|
|
2253
|
+
case "function":
|
|
2254
|
+
if (message !== void 0) {
|
|
2255
|
+
args.unshift(message);
|
|
2256
|
+
}
|
|
2257
|
+
opts.message = logLevel;
|
|
2258
|
+
break;
|
|
2259
|
+
case "object":
|
|
2260
|
+
Object.assign(opts, logLevel);
|
|
2261
|
+
break;
|
|
2262
|
+
default:
|
|
2263
|
+
}
|
|
2264
|
+
if (typeof opts.message === "function") {
|
|
2265
|
+
opts.message = opts.message();
|
|
2266
|
+
}
|
|
2267
|
+
const messageType = typeof opts.message;
|
|
2268
|
+
assert2(messageType === "string" || messageType === "object");
|
|
2269
|
+
return Object.assign(opts, {
|
|
2270
|
+
args
|
|
2271
|
+
}, opts.opts);
|
|
2272
|
+
}
|
|
2273
|
+
function decorateMessage(id, message, opts) {
|
|
2274
|
+
if (typeof message === "string") {
|
|
2275
|
+
const time = opts.time ? leftPad(formatTime(opts.total)) : "";
|
|
2276
|
+
message = opts.time ? "".concat(id, ": ").concat(time, " ").concat(message) : "".concat(id, ": ").concat(message);
|
|
2277
|
+
message = addColor(message, opts.color, opts.background);
|
|
2278
|
+
}
|
|
2279
|
+
return message;
|
|
2280
|
+
}
|
|
2281
|
+
function logImageInNode(_ref2) {
|
|
2282
|
+
let {
|
|
2283
|
+
image,
|
|
2284
|
+
message = "",
|
|
2285
|
+
scale = 1
|
|
2286
|
+
} = _ref2;
|
|
2287
|
+
console.warn("removed");
|
|
2288
|
+
return noop;
|
|
2289
|
+
}
|
|
2290
|
+
function logImageInBrowser(_ref3) {
|
|
2291
|
+
let {
|
|
2292
|
+
image,
|
|
2293
|
+
message = "",
|
|
2294
|
+
scale = 1
|
|
2295
|
+
} = _ref3;
|
|
2296
|
+
if (typeof image === "string") {
|
|
2297
|
+
const img = new Image();
|
|
2298
|
+
img.onload = () => {
|
|
2299
|
+
const args = formatImage(img, message, scale);
|
|
2300
|
+
console.log(...args);
|
|
2301
|
+
};
|
|
2302
|
+
img.src = image;
|
|
2303
|
+
return noop;
|
|
2304
|
+
}
|
|
2305
|
+
const element = image.nodeName || "";
|
|
2306
|
+
if (element.toLowerCase() === "img") {
|
|
2307
|
+
console.log(...formatImage(image, message, scale));
|
|
2308
|
+
return noop;
|
|
2309
|
+
}
|
|
2310
|
+
if (element.toLowerCase() === "canvas") {
|
|
2311
|
+
const img = new Image();
|
|
2312
|
+
img.onload = () => console.log(...formatImage(img, message, scale));
|
|
2313
|
+
img.src = image.toDataURL();
|
|
2314
|
+
return noop;
|
|
2315
|
+
}
|
|
2316
|
+
return noop;
|
|
2317
|
+
}
|
|
2318
|
+
function getTableHeader(table) {
|
|
2319
|
+
for (const key in table) {
|
|
2320
|
+
for (const title in table[key]) {
|
|
2321
|
+
return title || "untitled";
|
|
2322
|
+
}
|
|
2323
|
+
}
|
|
2324
|
+
return "empty";
|
|
2325
|
+
}
|
|
2326
|
+
|
|
2327
|
+
// ../../node_modules/@probe.gl/log/dist/index.js
|
|
2328
|
+
var dist_default = new Log({
|
|
2329
|
+
id: "@probe.gl/log"
|
|
2330
|
+
});
|
|
2331
|
+
|
|
2332
|
+
// ../loader-utils/src/lib/log-utils/log.ts
|
|
2333
|
+
var VERSION2 = typeof __VERSION__ !== "undefined" ? __VERSION__ : "latest";
|
|
2334
|
+
var version = VERSION2[0] >= "0" && VERSION2[0] <= "9" ? `v${VERSION2}` : "";
|
|
2335
|
+
function createLog() {
|
|
2336
|
+
const log2 = new Log({ id: "loaders.gl" });
|
|
2337
|
+
globalThis.loaders = globalThis.loaders || {};
|
|
2338
|
+
globalThis.loaders.log = log2;
|
|
2339
|
+
globalThis.loaders.version = version;
|
|
2340
|
+
globalThis.probe = globalThis.probe || {};
|
|
2341
|
+
globalThis.probe.loaders = log2;
|
|
2342
|
+
return log2;
|
|
2343
|
+
}
|
|
2344
|
+
var log = createLog();
|
|
2345
|
+
|
|
2346
|
+
// ../loader-utils/src/lib/path-utils/file-aliases.ts
|
|
2347
|
+
var pathPrefix = "";
|
|
2348
|
+
var fileAliases = {};
|
|
2349
|
+
function resolvePath(filename) {
|
|
2350
|
+
for (const alias in fileAliases) {
|
|
2351
|
+
if (filename.startsWith(alias)) {
|
|
2352
|
+
const replacement = fileAliases[alias];
|
|
2353
|
+
filename = filename.replace(alias, replacement);
|
|
2354
|
+
}
|
|
2355
|
+
}
|
|
2356
|
+
if (!filename.startsWith("http://") && !filename.startsWith("https://")) {
|
|
2357
|
+
filename = `${pathPrefix}${filename}`;
|
|
2358
|
+
}
|
|
2359
|
+
return filename;
|
|
2360
|
+
}
|
|
2361
|
+
|
|
2362
|
+
// ../loader-utils/src/lib/sources/data-source.ts
|
|
2363
|
+
var DataSource = class {
|
|
2364
|
+
/** A resolved fetch function extracted from loadOptions prop */
|
|
2365
|
+
fetch;
|
|
2366
|
+
/** The actual load options, if calling a loaders.gl loader */
|
|
2367
|
+
loadOptions;
|
|
2368
|
+
_needsRefresh = true;
|
|
2369
|
+
props;
|
|
2370
|
+
constructor(props) {
|
|
2371
|
+
this.props = { ...props };
|
|
2372
|
+
this.loadOptions = { ...props.loadOptions };
|
|
2373
|
+
this.fetch = getFetchFunction(this.loadOptions);
|
|
2374
|
+
}
|
|
2375
|
+
setProps(props) {
|
|
2376
|
+
this.props = Object.assign(this.props, props);
|
|
2377
|
+
this.setNeedsRefresh();
|
|
2378
|
+
}
|
|
2379
|
+
/** Mark this data source as needing a refresh (redraw) */
|
|
2380
|
+
setNeedsRefresh() {
|
|
2381
|
+
this._needsRefresh = true;
|
|
1892
2382
|
}
|
|
1893
2383
|
/**
|
|
1894
|
-
*
|
|
1895
|
-
* @
|
|
1896
|
-
* @returns feature
|
|
2384
|
+
* Does this data source need refreshing?
|
|
2385
|
+
* @note The specifics of the refresh mechanism depends on type of data source
|
|
1897
2386
|
*/
|
|
1898
|
-
|
|
1899
|
-
|
|
1900
|
-
|
|
2387
|
+
getNeedsRefresh(clear = true) {
|
|
2388
|
+
const needsRefresh = this._needsRefresh;
|
|
2389
|
+
if (clear) {
|
|
2390
|
+
this._needsRefresh = false;
|
|
1901
2391
|
}
|
|
1902
|
-
|
|
1903
|
-
const end = this._pbf.readVarint() + this._pbf.pos;
|
|
1904
|
-
return new VectorTileFeature(this._pbf, end, this.extent, this._keys, this._values);
|
|
2392
|
+
return needsRefresh;
|
|
1905
2393
|
}
|
|
1906
2394
|
};
|
|
1907
|
-
function
|
|
1908
|
-
|
|
1909
|
-
|
|
1910
|
-
|
|
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));
|
|
2395
|
+
function getFetchFunction(options) {
|
|
2396
|
+
const fetchFunction = options?.fetch;
|
|
2397
|
+
if (fetchFunction && typeof fetchFunction === "function") {
|
|
2398
|
+
return (url, fetchOptions2) => fetchFunction(url, fetchOptions2);
|
|
1921
2399
|
}
|
|
1922
|
-
|
|
1923
|
-
|
|
1924
|
-
|
|
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;
|
|
2400
|
+
const fetchOptions = options?.fetch;
|
|
2401
|
+
if (fetchOptions && typeof fetchOptions !== "function") {
|
|
2402
|
+
return (url) => fetch(url, fetchOptions);
|
|
1929
2403
|
}
|
|
1930
|
-
return
|
|
2404
|
+
return (url) => fetch(url);
|
|
1931
2405
|
}
|
|
1932
2406
|
|
|
1933
|
-
// src/lib/
|
|
1934
|
-
var
|
|
1935
|
-
|
|
1936
|
-
|
|
1937
|
-
|
|
2407
|
+
// src/lib/parse-mvt.ts
|
|
2408
|
+
var import_pbf = __toESM(require_pbf(), 1);
|
|
2409
|
+
|
|
2410
|
+
// src/lib/utils/geometry-utils.ts
|
|
2411
|
+
function signedArea(ring) {
|
|
2412
|
+
let sum = 0;
|
|
2413
|
+
for (let i = 0, j = ring.length - 1, p1, p2; i < ring.length; j = i++) {
|
|
2414
|
+
p1 = ring[i];
|
|
2415
|
+
p2 = ring[j];
|
|
2416
|
+
sum += (p2[0] - p1[0]) * (p1[1] + p2[1]);
|
|
1938
2417
|
}
|
|
1939
|
-
|
|
1940
|
-
|
|
1941
|
-
|
|
1942
|
-
|
|
1943
|
-
|
|
1944
|
-
|
|
1945
|
-
layers[layer.name] = layer;
|
|
1946
|
-
}
|
|
2418
|
+
return sum;
|
|
2419
|
+
}
|
|
2420
|
+
function convertToLocalCoordinates(coordinates, extent) {
|
|
2421
|
+
if (Array.isArray(coordinates[0])) {
|
|
2422
|
+
for (const subcoords of coordinates) {
|
|
2423
|
+
convertToLocalCoordinates(subcoords, extent);
|
|
1947
2424
|
}
|
|
2425
|
+
return;
|
|
1948
2426
|
}
|
|
2427
|
+
const p = coordinates;
|
|
2428
|
+
p[0] /= extent;
|
|
2429
|
+
p[1] /= extent;
|
|
1949
2430
|
}
|
|
1950
|
-
|
|
1951
|
-
|
|
1952
|
-
|
|
2431
|
+
function convertToLocalCoordinatesFlat(data, extent) {
|
|
2432
|
+
for (let i = 0, il = data.length; i < il; ++i) {
|
|
2433
|
+
data[i] /= extent;
|
|
2434
|
+
}
|
|
2435
|
+
}
|
|
2436
|
+
function projectToLngLat(line, tileIndex, extent) {
|
|
2437
|
+
if (typeof line[0][0] !== "number") {
|
|
2438
|
+
for (const point of line) {
|
|
2439
|
+
projectToLngLat(point, tileIndex, extent);
|
|
2440
|
+
}
|
|
2441
|
+
return;
|
|
2442
|
+
}
|
|
2443
|
+
const size = extent * Math.pow(2, tileIndex.z);
|
|
2444
|
+
const x0 = extent * tileIndex.x;
|
|
2445
|
+
const y0 = extent * tileIndex.y;
|
|
2446
|
+
for (let j = 0; j < line.length; j++) {
|
|
2447
|
+
const p = line[j];
|
|
2448
|
+
p[0] = (p[0] + x0) * 360 / size - 180;
|
|
2449
|
+
const y2 = 180 - (p[1] + y0) * 360 / size;
|
|
2450
|
+
p[1] = 360 / Math.PI * Math.atan(Math.exp(y2 * Math.PI / 180)) - 90;
|
|
2451
|
+
}
|
|
2452
|
+
}
|
|
2453
|
+
function projectToLngLatFlat(data, tileIndex, extent) {
|
|
2454
|
+
const { x, y, z } = tileIndex;
|
|
2455
|
+
const size = extent * Math.pow(2, z);
|
|
2456
|
+
const x0 = extent * x;
|
|
2457
|
+
const y0 = extent * y;
|
|
2458
|
+
for (let j = 0, jl = data.length; j < jl; j += 2) {
|
|
2459
|
+
data[j] = (data[j] + x0) * 360 / size - 180;
|
|
2460
|
+
const y2 = 180 - (data[j + 1] + y0) * 360 / size;
|
|
2461
|
+
data[j + 1] = 360 / Math.PI * Math.atan(Math.exp(y2 * Math.PI / 180)) - 90;
|
|
2462
|
+
}
|
|
2463
|
+
}
|
|
2464
|
+
function classifyRings(rings) {
|
|
2465
|
+
const len = rings.length;
|
|
2466
|
+
if (len <= 1)
|
|
2467
|
+
return [rings];
|
|
2468
|
+
const polygons = [];
|
|
2469
|
+
let polygon;
|
|
2470
|
+
let ccw;
|
|
2471
|
+
for (let i = 0; i < len; i++) {
|
|
2472
|
+
const area2 = signedArea(rings[i]);
|
|
2473
|
+
if (area2 === 0)
|
|
2474
|
+
continue;
|
|
2475
|
+
if (ccw === void 0)
|
|
2476
|
+
ccw = area2 < 0;
|
|
2477
|
+
if (ccw === area2 < 0) {
|
|
2478
|
+
if (polygon)
|
|
2479
|
+
polygons.push(polygon);
|
|
2480
|
+
polygon = [rings[i]];
|
|
2481
|
+
} else if (polygon)
|
|
2482
|
+
polygon.push(rings[i]);
|
|
2483
|
+
}
|
|
2484
|
+
if (polygon)
|
|
2485
|
+
polygons.push(polygon);
|
|
2486
|
+
return polygons;
|
|
2487
|
+
}
|
|
2488
|
+
function classifyRingsFlat(geom) {
|
|
1953
2489
|
const len = geom.indices.length;
|
|
1954
2490
|
const type = "Polygon";
|
|
1955
2491
|
if (len <= 1) {
|
|
@@ -1966,9 +2502,9 @@ var __exports__ = (() => {
|
|
|
1966
2502
|
let polygon = [];
|
|
1967
2503
|
let ccw;
|
|
1968
2504
|
let offset = 0;
|
|
1969
|
-
for (let endIndex,
|
|
1970
|
-
startIndex = geom.indices[
|
|
1971
|
-
endIndex = geom.indices[
|
|
2505
|
+
for (let endIndex, i = 0, startIndex; i < len; i++) {
|
|
2506
|
+
startIndex = geom.indices[i] - offset;
|
|
2507
|
+
endIndex = geom.indices[i + 1] - offset || geom.data.length;
|
|
1972
2508
|
const shape = geom.data.slice(startIndex, endIndex);
|
|
1973
2509
|
const area2 = getPolygonSignedArea(shape);
|
|
1974
2510
|
if (area2 === 0) {
|
|
@@ -1998,43 +2534,9 @@ var __exports__ = (() => {
|
|
|
1998
2534
|
polygons.push(polygon);
|
|
1999
2535
|
return { type, areas, indices: polygons, data: geom.data };
|
|
2000
2536
|
}
|
|
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
2537
|
|
|
2029
|
-
// src/lib/
|
|
2030
|
-
var
|
|
2031
|
-
var cmd;
|
|
2032
|
-
var cmdLen;
|
|
2033
|
-
var length;
|
|
2034
|
-
var x;
|
|
2035
|
-
var y;
|
|
2036
|
-
var i;
|
|
2037
|
-
var BinaryVectorTileFeature = class {
|
|
2538
|
+
// src/lib/vector-tile/vector-tile-feature.ts
|
|
2539
|
+
var VectorTileFeature = class {
|
|
2038
2540
|
properties;
|
|
2039
2541
|
extent;
|
|
2040
2542
|
type;
|
|
@@ -2055,23 +2557,55 @@ var __exports__ = (() => {
|
|
|
2055
2557
|
this._keys = keys;
|
|
2056
2558
|
this._values = values;
|
|
2057
2559
|
this._geometryInfo = geometryInfo;
|
|
2058
|
-
pbf.readFields(
|
|
2560
|
+
pbf.readFields(readFeature, this, end);
|
|
2059
2561
|
}
|
|
2060
|
-
|
|
2061
|
-
|
|
2562
|
+
toGeoJSONFeature(coordinates, tileIndex) {
|
|
2563
|
+
const coords = this.loadGeometry();
|
|
2564
|
+
switch (coordinates) {
|
|
2565
|
+
case "wgs84":
|
|
2566
|
+
return _toGeoJSONFeature(
|
|
2567
|
+
this,
|
|
2568
|
+
coords,
|
|
2569
|
+
(line) => projectToLngLat(line, tileIndex, this.extent)
|
|
2570
|
+
);
|
|
2571
|
+
default:
|
|
2572
|
+
return _toGeoJSONFeature(this, coords, convertToLocalCoordinates);
|
|
2573
|
+
}
|
|
2574
|
+
}
|
|
2575
|
+
/**
|
|
2576
|
+
*
|
|
2577
|
+
* @param options
|
|
2578
|
+
* @returns
|
|
2579
|
+
*/
|
|
2580
|
+
toBinaryFeature(coordinates, tileIndex) {
|
|
2581
|
+
const geom = this.loadFlatGeometry();
|
|
2582
|
+
switch (coordinates) {
|
|
2583
|
+
case "wgs84":
|
|
2584
|
+
return this._toBinaryCoordinates(
|
|
2585
|
+
geom,
|
|
2586
|
+
(coords) => projectToLngLatFlat(coords, tileIndex, this.extent)
|
|
2587
|
+
);
|
|
2588
|
+
default:
|
|
2589
|
+
return this._toBinaryCoordinates(geom, convertToLocalCoordinatesFlat);
|
|
2590
|
+
}
|
|
2591
|
+
}
|
|
2592
|
+
/** Read a bounding box from the feature */
|
|
2593
|
+
// eslint-disable-next-line max-statements
|
|
2594
|
+
bbox() {
|
|
2062
2595
|
const pbf = this._pbf;
|
|
2063
2596
|
pbf.pos = this._geometry;
|
|
2064
|
-
|
|
2065
|
-
cmd = 1;
|
|
2066
|
-
length = 0;
|
|
2067
|
-
x = 0;
|
|
2068
|
-
y = 0;
|
|
2069
|
-
|
|
2070
|
-
|
|
2071
|
-
|
|
2072
|
-
|
|
2597
|
+
const end = pbf.readVarint() + pbf.pos;
|
|
2598
|
+
let cmd = 1;
|
|
2599
|
+
let length = 0;
|
|
2600
|
+
let x = 0;
|
|
2601
|
+
let y = 0;
|
|
2602
|
+
let x1 = Infinity;
|
|
2603
|
+
let x2 = -Infinity;
|
|
2604
|
+
let y1 = Infinity;
|
|
2605
|
+
let y2 = -Infinity;
|
|
2606
|
+
while (pbf.pos < end) {
|
|
2073
2607
|
if (length <= 0) {
|
|
2074
|
-
cmdLen = pbf.readVarint();
|
|
2608
|
+
const cmdLen = pbf.readVarint();
|
|
2075
2609
|
cmd = cmdLen & 7;
|
|
2076
2610
|
length = cmdLen >> 3;
|
|
2077
2611
|
}
|
|
@@ -2079,32 +2613,29 @@ var __exports__ = (() => {
|
|
|
2079
2613
|
if (cmd === 1 || cmd === 2) {
|
|
2080
2614
|
x += pbf.readSVarint();
|
|
2081
2615
|
y += pbf.readSVarint();
|
|
2082
|
-
if (
|
|
2083
|
-
|
|
2084
|
-
|
|
2085
|
-
|
|
2086
|
-
|
|
2087
|
-
|
|
2088
|
-
if (
|
|
2089
|
-
|
|
2090
|
-
|
|
2091
|
-
i += 2;
|
|
2092
|
-
}
|
|
2093
|
-
} else {
|
|
2616
|
+
if (x < x1)
|
|
2617
|
+
x1 = x;
|
|
2618
|
+
if (x > x2)
|
|
2619
|
+
x2 = x;
|
|
2620
|
+
if (y < y1)
|
|
2621
|
+
y1 = y;
|
|
2622
|
+
if (y > y2)
|
|
2623
|
+
y2 = y;
|
|
2624
|
+
} else if (cmd !== 7) {
|
|
2094
2625
|
throw new Error(`unknown command ${cmd}`);
|
|
2095
2626
|
}
|
|
2096
2627
|
}
|
|
2097
|
-
return
|
|
2628
|
+
return [x1, y1, x2, y2];
|
|
2098
2629
|
}
|
|
2630
|
+
// BINARY HELPERS
|
|
2099
2631
|
/**
|
|
2100
2632
|
*
|
|
2101
2633
|
* @param transform
|
|
2102
2634
|
* @returns result
|
|
2103
2635
|
*/
|
|
2104
|
-
_toBinaryCoordinates(transform) {
|
|
2105
|
-
const geom = this.loadGeometry();
|
|
2636
|
+
_toBinaryCoordinates(geom, transform) {
|
|
2106
2637
|
let geometry;
|
|
2107
|
-
transform(geom.data, this);
|
|
2638
|
+
transform(geom.data, this.extent);
|
|
2108
2639
|
const coordLength = 2;
|
|
2109
2640
|
switch (this.type) {
|
|
2110
2641
|
case 1:
|
|
@@ -2119,7 +2650,7 @@ var __exports__ = (() => {
|
|
|
2119
2650
|
geometry = { type: "LineString", ...geom };
|
|
2120
2651
|
break;
|
|
2121
2652
|
case 3:
|
|
2122
|
-
geometry =
|
|
2653
|
+
geometry = classifyRingsFlat(geom);
|
|
2123
2654
|
this._geometryInfo.polygonFeaturesCount++;
|
|
2124
2655
|
this._geometryInfo.polygonObjectsCount += geometry.indices.length;
|
|
2125
2656
|
for (const indices of geometry.indices) {
|
|
@@ -2136,20 +2667,188 @@ var __exports__ = (() => {
|
|
|
2136
2667
|
}
|
|
2137
2668
|
return result;
|
|
2138
2669
|
}
|
|
2139
|
-
|
|
2140
|
-
|
|
2141
|
-
|
|
2670
|
+
// GEOJSON HELPER
|
|
2671
|
+
// eslint-disable-next-line complexity, max-statements
|
|
2672
|
+
loadGeometry() {
|
|
2673
|
+
const pbf = this._pbf;
|
|
2674
|
+
pbf.pos = this._geometry;
|
|
2675
|
+
const end = pbf.readVarint() + pbf.pos;
|
|
2676
|
+
let cmd = 1;
|
|
2677
|
+
let length = 0;
|
|
2678
|
+
let x = 0;
|
|
2679
|
+
let y = 0;
|
|
2680
|
+
const lines = [];
|
|
2681
|
+
let line;
|
|
2682
|
+
while (pbf.pos < end) {
|
|
2683
|
+
if (length <= 0) {
|
|
2684
|
+
const cmdLen = pbf.readVarint();
|
|
2685
|
+
cmd = cmdLen & 7;
|
|
2686
|
+
length = cmdLen >> 3;
|
|
2687
|
+
}
|
|
2688
|
+
length--;
|
|
2689
|
+
switch (cmd) {
|
|
2690
|
+
case 1:
|
|
2691
|
+
case 2:
|
|
2692
|
+
x += pbf.readSVarint();
|
|
2693
|
+
y += pbf.readSVarint();
|
|
2694
|
+
if (cmd === 1) {
|
|
2695
|
+
if (line)
|
|
2696
|
+
lines.push(line);
|
|
2697
|
+
line = [];
|
|
2698
|
+
}
|
|
2699
|
+
if (line)
|
|
2700
|
+
line.push([x, y]);
|
|
2701
|
+
break;
|
|
2702
|
+
case 7:
|
|
2703
|
+
if (line) {
|
|
2704
|
+
line.push(line[0].slice());
|
|
2705
|
+
}
|
|
2706
|
+
break;
|
|
2707
|
+
default:
|
|
2708
|
+
throw new Error(`unknown command ${cmd}`);
|
|
2709
|
+
}
|
|
2142
2710
|
}
|
|
2143
|
-
|
|
2144
|
-
|
|
2145
|
-
|
|
2146
|
-
|
|
2147
|
-
|
|
2711
|
+
if (line)
|
|
2712
|
+
lines.push(line);
|
|
2713
|
+
return lines;
|
|
2714
|
+
}
|
|
2715
|
+
/**
|
|
2716
|
+
* Expands the protobuf data to an intermediate Flat GeoJSON
|
|
2717
|
+
* data format, which maps closely to the binary data buffers.
|
|
2718
|
+
* It is similar to GeoJSON, but rather than storing the coordinates
|
|
2719
|
+
* in multidimensional arrays, we have a 1D `data` with all the
|
|
2720
|
+
* coordinates, and then index into this using the `indices`
|
|
2721
|
+
* parameter, e.g.
|
|
2722
|
+
*
|
|
2723
|
+
* geometry: {
|
|
2724
|
+
* type: 'Point', data: [1,2], indices: [0]
|
|
2725
|
+
* }
|
|
2726
|
+
* geometry: {
|
|
2727
|
+
* type: 'LineString', data: [1,2,3,4,...], indices: [0]
|
|
2728
|
+
* }
|
|
2729
|
+
* geometry: {
|
|
2730
|
+
* type: 'Polygon', data: [1,2,3,4,...], indices: [[0, 2]]
|
|
2731
|
+
* }
|
|
2732
|
+
* Thus the indices member lets us look up the relevant range
|
|
2733
|
+
* from the data array.
|
|
2734
|
+
* The Multi* versions of the above types share the same data
|
|
2735
|
+
* structure, just with multiple elements in the indices array
|
|
2736
|
+
*/
|
|
2737
|
+
// eslint-disable-next-line complexity, max-statements
|
|
2738
|
+
loadFlatGeometry() {
|
|
2739
|
+
const pbf = this._pbf;
|
|
2740
|
+
pbf.pos = this._geometry;
|
|
2741
|
+
const endPos = pbf.readVarint() + pbf.pos;
|
|
2742
|
+
let cmd = 1;
|
|
2743
|
+
let cmdLen;
|
|
2744
|
+
let length = 0;
|
|
2745
|
+
let x = 0;
|
|
2746
|
+
let y = 0;
|
|
2747
|
+
let i = 0;
|
|
2748
|
+
const indices = [];
|
|
2749
|
+
const data = [];
|
|
2750
|
+
while (pbf.pos < endPos) {
|
|
2751
|
+
if (length <= 0) {
|
|
2752
|
+
cmdLen = pbf.readVarint();
|
|
2753
|
+
cmd = cmdLen & 7;
|
|
2754
|
+
length = cmdLen >> 3;
|
|
2755
|
+
}
|
|
2756
|
+
length--;
|
|
2757
|
+
if (cmd === 1 || cmd === 2) {
|
|
2758
|
+
x += pbf.readSVarint();
|
|
2759
|
+
y += pbf.readSVarint();
|
|
2760
|
+
if (cmd === 1) {
|
|
2761
|
+
indices.push(i);
|
|
2762
|
+
}
|
|
2763
|
+
data.push(x, y);
|
|
2764
|
+
i += 2;
|
|
2765
|
+
} else if (cmd === 7) {
|
|
2766
|
+
if (i > 0) {
|
|
2767
|
+
const start = indices[indices.length - 1];
|
|
2768
|
+
data.push(data[start], data[start + 1]);
|
|
2769
|
+
i += 2;
|
|
2770
|
+
}
|
|
2771
|
+
} else {
|
|
2772
|
+
throw new Error(`unknown command ${cmd}`);
|
|
2773
|
+
}
|
|
2774
|
+
}
|
|
2775
|
+
return { data, indices };
|
|
2148
2776
|
}
|
|
2149
2777
|
};
|
|
2778
|
+
__publicField(VectorTileFeature, "types", ["Unknown", "Point", "LineString", "Polygon"]);
|
|
2779
|
+
function _toGeoJSONFeature(vtFeature, coords, transform) {
|
|
2780
|
+
let type = VectorTileFeature.types[vtFeature.type];
|
|
2781
|
+
let i;
|
|
2782
|
+
let j;
|
|
2783
|
+
let coordinates;
|
|
2784
|
+
switch (vtFeature.type) {
|
|
2785
|
+
case 1:
|
|
2786
|
+
const points = [];
|
|
2787
|
+
for (i = 0; i < coords.length; i++) {
|
|
2788
|
+
points[i] = coords[i][0];
|
|
2789
|
+
}
|
|
2790
|
+
coordinates = points;
|
|
2791
|
+
transform(coordinates, vtFeature.extent);
|
|
2792
|
+
break;
|
|
2793
|
+
case 2:
|
|
2794
|
+
coordinates = coords;
|
|
2795
|
+
for (i = 0; i < coordinates.length; i++) {
|
|
2796
|
+
transform(coordinates[i], vtFeature.extent);
|
|
2797
|
+
}
|
|
2798
|
+
break;
|
|
2799
|
+
case 3:
|
|
2800
|
+
coordinates = classifyRings(coords);
|
|
2801
|
+
for (i = 0; i < coordinates.length; i++) {
|
|
2802
|
+
for (j = 0; j < coordinates[i].length; j++) {
|
|
2803
|
+
transform(coordinates[i][j], vtFeature.extent);
|
|
2804
|
+
}
|
|
2805
|
+
}
|
|
2806
|
+
break;
|
|
2807
|
+
default:
|
|
2808
|
+
throw new Error("illegal vector tile type");
|
|
2809
|
+
}
|
|
2810
|
+
if (coordinates.length === 1) {
|
|
2811
|
+
coordinates = coordinates[0];
|
|
2812
|
+
} else {
|
|
2813
|
+
type = `Multi${type}`;
|
|
2814
|
+
}
|
|
2815
|
+
const result = {
|
|
2816
|
+
type: "Feature",
|
|
2817
|
+
geometry: {
|
|
2818
|
+
type,
|
|
2819
|
+
coordinates
|
|
2820
|
+
},
|
|
2821
|
+
properties: vtFeature.properties
|
|
2822
|
+
};
|
|
2823
|
+
if (vtFeature.id !== null) {
|
|
2824
|
+
result.properties ||= {};
|
|
2825
|
+
result.properties.id = vtFeature.id;
|
|
2826
|
+
}
|
|
2827
|
+
return result;
|
|
2828
|
+
}
|
|
2829
|
+
function readFeature(tag, feature, pbf) {
|
|
2830
|
+
if (feature && pbf) {
|
|
2831
|
+
if (tag === 1)
|
|
2832
|
+
feature.id = pbf.readVarint();
|
|
2833
|
+
else if (tag === 2)
|
|
2834
|
+
readTag(pbf, feature);
|
|
2835
|
+
else if (tag === 3)
|
|
2836
|
+
feature.type = pbf.readVarint();
|
|
2837
|
+
else if (tag === 4)
|
|
2838
|
+
feature._geometry = pbf.pos;
|
|
2839
|
+
}
|
|
2840
|
+
}
|
|
2841
|
+
function readTag(pbf, feature) {
|
|
2842
|
+
const end = pbf.readVarint() + pbf.pos;
|
|
2843
|
+
while (pbf.pos < end) {
|
|
2844
|
+
const key = feature._keys[pbf.readVarint()];
|
|
2845
|
+
const value = feature._values[pbf.readVarint()];
|
|
2846
|
+
feature.properties[key] = value;
|
|
2847
|
+
}
|
|
2848
|
+
}
|
|
2150
2849
|
|
|
2151
|
-
// src/lib/
|
|
2152
|
-
var
|
|
2850
|
+
// src/lib/vector-tile/vector-tile-layer.ts
|
|
2851
|
+
var VectorTileLayer = class {
|
|
2153
2852
|
version;
|
|
2154
2853
|
name;
|
|
2155
2854
|
extent;
|
|
@@ -2167,23 +2866,36 @@ var __exports__ = (() => {
|
|
|
2167
2866
|
this._keys = [];
|
|
2168
2867
|
this._values = [];
|
|
2169
2868
|
this._features = [];
|
|
2170
|
-
pbf.readFields(
|
|
2869
|
+
pbf.readFields(readLayer, this, end);
|
|
2171
2870
|
this.length = this._features.length;
|
|
2172
2871
|
}
|
|
2173
2872
|
/**
|
|
2174
|
-
* return feature `i` from this layer as a `
|
|
2873
|
+
* return feature `i` from this layer as a `VectorTileFeature`
|
|
2874
|
+
* @param index
|
|
2875
|
+
* @returns feature
|
|
2876
|
+
*/
|
|
2877
|
+
getGeoJSONFeature(i) {
|
|
2878
|
+
if (i < 0 || i >= this._features.length) {
|
|
2879
|
+
throw new Error("feature index out of bounds");
|
|
2880
|
+
}
|
|
2881
|
+
this._pbf.pos = this._features[i];
|
|
2882
|
+
const end = this._pbf.readVarint() + this._pbf.pos;
|
|
2883
|
+
return new VectorTileFeature(this._pbf, end, this.extent, this._keys, this._values);
|
|
2884
|
+
}
|
|
2885
|
+
/**
|
|
2886
|
+
* return binary feature `i` from this layer as a `VectorTileFeature`
|
|
2175
2887
|
*
|
|
2176
2888
|
* @param index
|
|
2177
2889
|
* @param geometryInfo
|
|
2178
|
-
* @returns
|
|
2890
|
+
* @returns binary feature
|
|
2179
2891
|
*/
|
|
2180
|
-
|
|
2181
|
-
if (
|
|
2892
|
+
getBinaryFeature(i, geometryInfo) {
|
|
2893
|
+
if (i < 0 || i >= this._features.length) {
|
|
2182
2894
|
throw new Error("feature index out of bounds");
|
|
2183
2895
|
}
|
|
2184
|
-
this._pbf.pos = this._features[
|
|
2896
|
+
this._pbf.pos = this._features[i];
|
|
2185
2897
|
const end = this._pbf.readVarint() + this._pbf.pos;
|
|
2186
|
-
return new
|
|
2898
|
+
return new VectorTileFeature(
|
|
2187
2899
|
this._pbf,
|
|
2188
2900
|
end,
|
|
2189
2901
|
this.extent,
|
|
@@ -2193,7 +2905,7 @@ var __exports__ = (() => {
|
|
|
2193
2905
|
);
|
|
2194
2906
|
}
|
|
2195
2907
|
};
|
|
2196
|
-
function
|
|
2908
|
+
function readLayer(tag, layer, pbf) {
|
|
2197
2909
|
if (layer && pbf) {
|
|
2198
2910
|
if (tag === 15)
|
|
2199
2911
|
layer.version = pbf.readVarint();
|
|
@@ -2206,10 +2918,10 @@ var __exports__ = (() => {
|
|
|
2206
2918
|
else if (tag === 3)
|
|
2207
2919
|
layer._keys.push(pbf.readString());
|
|
2208
2920
|
else if (tag === 4)
|
|
2209
|
-
layer._values.push(
|
|
2921
|
+
layer._values.push(readValueMessage(pbf));
|
|
2210
2922
|
}
|
|
2211
2923
|
}
|
|
2212
|
-
function
|
|
2924
|
+
function readValueMessage(pbf) {
|
|
2213
2925
|
let value = null;
|
|
2214
2926
|
const end = pbf.readVarint() + pbf.pos;
|
|
2215
2927
|
while (pbf.pos < end) {
|
|
@@ -2219,17 +2931,17 @@ var __exports__ = (() => {
|
|
|
2219
2931
|
return value;
|
|
2220
2932
|
}
|
|
2221
2933
|
|
|
2222
|
-
// src/lib/
|
|
2223
|
-
var
|
|
2934
|
+
// src/lib/vector-tile/vector-tile.ts
|
|
2935
|
+
var VectorTile = class {
|
|
2224
2936
|
layers;
|
|
2225
2937
|
constructor(pbf, end) {
|
|
2226
|
-
this.layers = pbf.readFields(
|
|
2938
|
+
this.layers = pbf.readFields(readTile, {}, end);
|
|
2227
2939
|
}
|
|
2228
2940
|
};
|
|
2229
|
-
function
|
|
2941
|
+
function readTile(tag, layers, pbf) {
|
|
2230
2942
|
if (tag === 3) {
|
|
2231
2943
|
if (pbf) {
|
|
2232
|
-
const layer = new
|
|
2944
|
+
const layer = new VectorTileLayer(pbf, pbf.readVarint() + pbf.pos);
|
|
2233
2945
|
if (layer.length && layers) {
|
|
2234
2946
|
layers[layer.name] = layer;
|
|
2235
2947
|
}
|
|
@@ -2239,7 +2951,7 @@ var __exports__ = (() => {
|
|
|
2239
2951
|
|
|
2240
2952
|
// src/lib/parse-mvt.ts
|
|
2241
2953
|
function parseMVT(arrayBuffer, options) {
|
|
2242
|
-
const mvtOptions =
|
|
2954
|
+
const mvtOptions = checkOptions(options);
|
|
2243
2955
|
const shape = options?.gis?.format || options?.mvt?.shape || options?.shape;
|
|
2244
2956
|
switch (shape) {
|
|
2245
2957
|
case "columnar-table":
|
|
@@ -2285,15 +2997,15 @@ var __exports__ = (() => {
|
|
|
2285
2997
|
if (arrayBuffer.byteLength <= 0) {
|
|
2286
2998
|
return [features, geometryInfo];
|
|
2287
2999
|
}
|
|
2288
|
-
const tile = new
|
|
3000
|
+
const tile = new VectorTile(new import_pbf.default(arrayBuffer));
|
|
2289
3001
|
const selectedLayers = options && Array.isArray(options.layers) ? options.layers : Object.keys(tile.layers);
|
|
2290
3002
|
selectedLayers.forEach((layerName) => {
|
|
2291
3003
|
const vectorTileLayer = tile.layers[layerName];
|
|
2292
3004
|
if (!vectorTileLayer) {
|
|
2293
3005
|
return;
|
|
2294
3006
|
}
|
|
2295
|
-
for (let
|
|
2296
|
-
const vectorTileFeature = vectorTileLayer.
|
|
3007
|
+
for (let i = 0; i < vectorTileLayer.length; i++) {
|
|
3008
|
+
const vectorTileFeature = vectorTileLayer.getBinaryFeature(i, geometryInfo);
|
|
2297
3009
|
const decodedFeature = getDecodedFeatureBinary(vectorTileFeature, options, layerName);
|
|
2298
3010
|
features.push(decodedFeature);
|
|
2299
3011
|
}
|
|
@@ -2312,70 +3024,54 @@ var __exports__ = (() => {
|
|
|
2312
3024
|
if (!vectorTileLayer) {
|
|
2313
3025
|
return;
|
|
2314
3026
|
}
|
|
2315
|
-
for (let
|
|
2316
|
-
const vectorTileFeature = vectorTileLayer.
|
|
3027
|
+
for (let i = 0; i < vectorTileLayer.length; i++) {
|
|
3028
|
+
const vectorTileFeature = vectorTileLayer.getGeoJSONFeature(i);
|
|
2317
3029
|
const decodedFeature = getDecodedFeature(vectorTileFeature, options, layerName);
|
|
2318
3030
|
features.push(decodedFeature);
|
|
2319
3031
|
}
|
|
2320
3032
|
});
|
|
2321
3033
|
return features;
|
|
2322
3034
|
}
|
|
2323
|
-
function
|
|
3035
|
+
function checkOptions(options) {
|
|
2324
3036
|
if (!options?.mvt) {
|
|
2325
3037
|
throw new Error("mvt options required");
|
|
2326
3038
|
}
|
|
2327
|
-
|
|
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) {
|
|
3039
|
+
if (options.mvt?.coordinates === "wgs84" && !options.mvt.tileIndex) {
|
|
2331
3040
|
throw new Error("MVT Loader: WGS84 coordinates need tileIndex property");
|
|
2332
3041
|
}
|
|
3042
|
+
if (options.gis) {
|
|
3043
|
+
log.warn('MVTLoader: "options.gis" is deprecated, use "options.mvt.shape" instead')();
|
|
3044
|
+
}
|
|
2333
3045
|
return options.mvt;
|
|
2334
3046
|
}
|
|
2335
3047
|
function getDecodedFeature(feature, options, layerName) {
|
|
2336
|
-
const decodedFeature = feature.
|
|
2337
|
-
|
|
2338
|
-
options.
|
|
3048
|
+
const decodedFeature = feature.toGeoJSONFeature(
|
|
3049
|
+
options.coordinates || "local",
|
|
3050
|
+
options.tileIndex
|
|
2339
3051
|
);
|
|
2340
3052
|
if (options.layerProperty) {
|
|
3053
|
+
decodedFeature.properties ||= {};
|
|
2341
3054
|
decodedFeature.properties[options.layerProperty] = layerName;
|
|
2342
3055
|
}
|
|
2343
3056
|
return decodedFeature;
|
|
2344
3057
|
}
|
|
2345
3058
|
function getDecodedFeatureBinary(feature, options, layerName) {
|
|
2346
|
-
const decodedFeature = feature.
|
|
2347
|
-
// @ts-expect-error
|
|
2348
|
-
options.coordinates === "wgs84" ? options.tileIndex : transformToLocalCoordinatesBinary
|
|
2349
|
-
);
|
|
3059
|
+
const decodedFeature = feature.toBinaryFeature(options.coordinates || "local", options.tileIndex);
|
|
2350
3060
|
if (options.layerProperty && decodedFeature.properties) {
|
|
2351
3061
|
decodedFeature.properties[options.layerProperty] = layerName;
|
|
2352
3062
|
}
|
|
2353
3063
|
return decodedFeature;
|
|
2354
3064
|
}
|
|
2355
|
-
function transformToLocalCoordinates(line, feature) {
|
|
2356
|
-
const { extent } = feature;
|
|
2357
|
-
for (let i2 = 0; i2 < line.length; i2++) {
|
|
2358
|
-
const p = line[i2];
|
|
2359
|
-
p[0] /= extent;
|
|
2360
|
-
p[1] /= extent;
|
|
2361
|
-
}
|
|
2362
|
-
}
|
|
2363
|
-
function transformToLocalCoordinatesBinary(data, feature) {
|
|
2364
|
-
const { extent } = feature;
|
|
2365
|
-
for (let i2 = 0, il = data.length; i2 < il; ++i2) {
|
|
2366
|
-
data[i2] /= extent;
|
|
2367
|
-
}
|
|
2368
|
-
}
|
|
2369
3065
|
|
|
2370
3066
|
// src/mvt-loader.ts
|
|
2371
|
-
var
|
|
3067
|
+
var VERSION3 = typeof __VERSION__ !== "undefined" ? __VERSION__ : "latest";
|
|
2372
3068
|
var MVTWorkerLoader = {
|
|
2373
3069
|
dataType: null,
|
|
2374
3070
|
batchType: null,
|
|
2375
3071
|
name: "Mapbox Vector Tile",
|
|
2376
3072
|
id: "mvt",
|
|
2377
3073
|
module: "mvt",
|
|
2378
|
-
version:
|
|
3074
|
+
version: VERSION3,
|
|
2379
3075
|
// Note: ArcGIS uses '.pbf' extension and 'application/octet-stream'
|
|
2380
3076
|
extensions: ["mvt", "pbf"],
|
|
2381
3077
|
mimeTypes: [
|
|
@@ -2392,7 +3088,7 @@ var __exports__ = (() => {
|
|
|
2392
3088
|
coordinates: "local",
|
|
2393
3089
|
layerProperty: "layerName",
|
|
2394
3090
|
layers: void 0,
|
|
2395
|
-
tileIndex:
|
|
3091
|
+
tileIndex: void 0
|
|
2396
3092
|
}
|
|
2397
3093
|
}
|
|
2398
3094
|
};
|
|
@@ -2404,7 +3100,7 @@ var __exports__ = (() => {
|
|
|
2404
3100
|
};
|
|
2405
3101
|
|
|
2406
3102
|
// src/lib/parse-tilejson.ts
|
|
2407
|
-
var isObject = (
|
|
3103
|
+
var isObject = (x) => x !== null && typeof x === "object";
|
|
2408
3104
|
function parseTileJSON(jsonMetadata, options) {
|
|
2409
3105
|
if (!jsonMetadata || !isObject(jsonMetadata)) {
|
|
2410
3106
|
return null;
|
|
@@ -2608,14 +3304,14 @@ var __exports__ = (() => {
|
|
|
2608
3304
|
}
|
|
2609
3305
|
|
|
2610
3306
|
// src/tilejson-loader.ts
|
|
2611
|
-
var
|
|
3307
|
+
var VERSION4 = typeof __VERSION__ !== "undefined" ? __VERSION__ : "latest";
|
|
2612
3308
|
var TileJSONLoader = {
|
|
2613
3309
|
dataType: null,
|
|
2614
3310
|
batchType: null,
|
|
2615
3311
|
name: "TileJSON",
|
|
2616
3312
|
id: "tilejson",
|
|
2617
3313
|
module: "pmtiles",
|
|
2618
|
-
version:
|
|
3314
|
+
version: VERSION4,
|
|
2619
3315
|
worker: true,
|
|
2620
3316
|
extensions: ["json"],
|
|
2621
3317
|
mimeTypes: ["application/json"],
|
|
@@ -2638,94 +3334,8 @@ var __exports__ = (() => {
|
|
|
2638
3334
|
}
|
|
2639
3335
|
};
|
|
2640
3336
|
|
|
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
3337
|
// ../images/src/lib/utils/version.ts
|
|
2728
|
-
var
|
|
3338
|
+
var VERSION5 = typeof __VERSION__ !== "undefined" ? __VERSION__ : "latest";
|
|
2729
3339
|
|
|
2730
3340
|
// ../images/src/lib/category-api/image-type.ts
|
|
2731
3341
|
var parseImageNode = globalThis.loaders?.parseImageNode;
|
|
@@ -2925,8 +3535,8 @@ var __exports__ = (() => {
|
|
|
2925
3535
|
}
|
|
2926
3536
|
function checkString(buffer, header, offset = 0) {
|
|
2927
3537
|
const headerBytes = stringToBytes(header);
|
|
2928
|
-
for (let
|
|
2929
|
-
if (headerBytes[
|
|
3538
|
+
for (let i = 0; i < headerBytes.length; ++i) {
|
|
3539
|
+
if (headerBytes[i] !== buffer[i + offset]) {
|
|
2930
3540
|
return false;
|
|
2931
3541
|
}
|
|
2932
3542
|
}
|
|
@@ -2996,30 +3606,30 @@ var __exports__ = (() => {
|
|
|
2996
3606
|
return null;
|
|
2997
3607
|
}
|
|
2998
3608
|
const { tableMarkers, sofMarkers } = getJpegMarkers();
|
|
2999
|
-
let
|
|
3000
|
-
while (
|
|
3001
|
-
const marker = dataView.getUint16(
|
|
3609
|
+
let i = 2;
|
|
3610
|
+
while (i + 9 < dataView.byteLength) {
|
|
3611
|
+
const marker = dataView.getUint16(i, BIG_ENDIAN);
|
|
3002
3612
|
if (sofMarkers.has(marker)) {
|
|
3003
3613
|
return {
|
|
3004
3614
|
mimeType: "image/jpeg",
|
|
3005
|
-
height: dataView.getUint16(
|
|
3615
|
+
height: dataView.getUint16(i + 5, BIG_ENDIAN),
|
|
3006
3616
|
// Number of lines
|
|
3007
|
-
width: dataView.getUint16(
|
|
3617
|
+
width: dataView.getUint16(i + 7, BIG_ENDIAN)
|
|
3008
3618
|
// Number of pixels per line
|
|
3009
3619
|
};
|
|
3010
3620
|
}
|
|
3011
3621
|
if (!tableMarkers.has(marker)) {
|
|
3012
3622
|
return null;
|
|
3013
3623
|
}
|
|
3014
|
-
|
|
3015
|
-
|
|
3624
|
+
i += 2;
|
|
3625
|
+
i += dataView.getUint16(i, BIG_ENDIAN);
|
|
3016
3626
|
}
|
|
3017
3627
|
return null;
|
|
3018
3628
|
}
|
|
3019
3629
|
function getJpegMarkers() {
|
|
3020
3630
|
const tableMarkers = /* @__PURE__ */ new Set([65499, 65476, 65484, 65501, 65534]);
|
|
3021
|
-
for (let
|
|
3022
|
-
tableMarkers.add(
|
|
3631
|
+
for (let i = 65504; i < 65520; ++i) {
|
|
3632
|
+
tableMarkers.add(i);
|
|
3023
3633
|
}
|
|
3024
3634
|
const sofMarkers = /* @__PURE__ */ new Set([
|
|
3025
3635
|
65472,
|
|
@@ -3123,7 +3733,7 @@ var __exports__ = (() => {
|
|
|
3123
3733
|
id: "image",
|
|
3124
3734
|
module: "images",
|
|
3125
3735
|
name: "Images",
|
|
3126
|
-
version:
|
|
3736
|
+
version: VERSION5,
|
|
3127
3737
|
mimeTypes: MIME_TYPES,
|
|
3128
3738
|
extensions: EXTENSIONS,
|
|
3129
3739
|
parse: parseImage,
|
|
@@ -3178,9 +3788,9 @@ var __exports__ = (() => {
|
|
|
3178
3788
|
getTileMIMEType() {
|
|
3179
3789
|
return this.mimeType;
|
|
3180
3790
|
}
|
|
3181
|
-
async getTile(
|
|
3182
|
-
const { x
|
|
3183
|
-
const tileUrl = this.getTileURL(
|
|
3791
|
+
async getTile(parameters) {
|
|
3792
|
+
const { x, y, z } = parameters;
|
|
3793
|
+
const tileUrl = this.getTileURL(x, y, z);
|
|
3184
3794
|
const response = await this.fetch(tileUrl);
|
|
3185
3795
|
if (!response.ok) {
|
|
3186
3796
|
return null;
|
|
@@ -3190,9 +3800,9 @@ var __exports__ = (() => {
|
|
|
3190
3800
|
}
|
|
3191
3801
|
// Tile Source interface implementation: deck.gl compatible API
|
|
3192
3802
|
// TODO - currently only handles image tiles, not vector tiles
|
|
3193
|
-
async getTileData(
|
|
3194
|
-
const { x
|
|
3195
|
-
const arrayBuffer = await this.getTile({ x
|
|
3803
|
+
async getTileData(parameters) {
|
|
3804
|
+
const { x, y, z } = parameters.index;
|
|
3805
|
+
const arrayBuffer = await this.getTile({ x, y, z, layers: [] });
|
|
3196
3806
|
if (arrayBuffer === null) {
|
|
3197
3807
|
return null;
|
|
3198
3808
|
}
|
|
@@ -3200,7 +3810,7 @@ var __exports__ = (() => {
|
|
|
3200
3810
|
this.mimeType = this.mimeType || imageMetadata?.mimeType || "application/vnd.mapbox-vector-tile";
|
|
3201
3811
|
switch (this.mimeType) {
|
|
3202
3812
|
case "application/vnd.mapbox-vector-tile":
|
|
3203
|
-
return await this._parseVectorTile(arrayBuffer, { x
|
|
3813
|
+
return await this._parseVectorTile(arrayBuffer, { x, y, z, layers: [] });
|
|
3204
3814
|
default:
|
|
3205
3815
|
return await this._parseImageTile(arrayBuffer);
|
|
3206
3816
|
}
|
|
@@ -3223,7 +3833,7 @@ var __exports__ = (() => {
|
|
|
3223
3833
|
shape: "geojson-table",
|
|
3224
3834
|
mvt: {
|
|
3225
3835
|
coordinates: "wgs84",
|
|
3226
|
-
tileIndex: { x: tileParams.x, y: tileParams.y, z: tileParams.
|
|
3836
|
+
tileIndex: { x: tileParams.x, y: tileParams.y, z: tileParams.z },
|
|
3227
3837
|
...this.loadOptions?.mvt
|
|
3228
3838
|
},
|
|
3229
3839
|
...this.loadOptions
|
|
@@ -3233,14 +3843,14 @@ var __exports__ = (() => {
|
|
|
3233
3843
|
getMetadataUrl() {
|
|
3234
3844
|
return this.metadataUrl;
|
|
3235
3845
|
}
|
|
3236
|
-
getTileURL(
|
|
3846
|
+
getTileURL(x, y, z) {
|
|
3237
3847
|
switch (this.schema) {
|
|
3238
3848
|
case "xyz":
|
|
3239
|
-
return `${this.url}/${
|
|
3849
|
+
return `${this.url}/${x}/${y}/${z}${this.extension}`;
|
|
3240
3850
|
case "tms":
|
|
3241
|
-
return `${this.url}/${z}/${
|
|
3851
|
+
return `${this.url}/${z}/${x}/${y}${this.extension}`;
|
|
3242
3852
|
case "template":
|
|
3243
|
-
return getURLFromTemplate(this.url,
|
|
3853
|
+
return getURLFromTemplate(this.url, x, y, z, "0");
|
|
3244
3854
|
default:
|
|
3245
3855
|
throw new Error(this.schema);
|
|
3246
3856
|
}
|
|
@@ -3252,17 +3862,17 @@ var __exports__ = (() => {
|
|
|
3252
3862
|
var xRegex = new RegExp("{x}", "g");
|
|
3253
3863
|
var yRegex = new RegExp("{y}", "g");
|
|
3254
3864
|
var zRegex = new RegExp("{z}", "g");
|
|
3255
|
-
function getURLFromTemplate(template,
|
|
3865
|
+
function getURLFromTemplate(template, x, y, z, id = "0") {
|
|
3256
3866
|
if (Array.isArray(template)) {
|
|
3257
|
-
const
|
|
3258
|
-
template = template[
|
|
3867
|
+
const i = stringHash(id) % template.length;
|
|
3868
|
+
template = template[i];
|
|
3259
3869
|
}
|
|
3260
3870
|
let url = template;
|
|
3261
|
-
url = url.replace(xRegex, String(
|
|
3262
|
-
url = url.replace(yRegex, String(
|
|
3871
|
+
url = url.replace(xRegex, String(x));
|
|
3872
|
+
url = url.replace(yRegex, String(y));
|
|
3263
3873
|
url = url.replace(zRegex, String(z));
|
|
3264
|
-
if (Number.isInteger(
|
|
3265
|
-
url = url.replace(/\{-y\}/g, String(Math.pow(2, z) -
|
|
3874
|
+
if (Number.isInteger(y) && Number.isInteger(z)) {
|
|
3875
|
+
url = url.replace(/\{-y\}/g, String(Math.pow(2, z) - y - 1));
|
|
3266
3876
|
}
|
|
3267
3877
|
return url;
|
|
3268
3878
|
}
|
|
@@ -3270,7 +3880,200 @@ var __exports__ = (() => {
|
|
|
3270
3880
|
return Math.abs(s.split("").reduce((a, b) => (a << 5) - a + b.charCodeAt(0) | 0, 0));
|
|
3271
3881
|
}
|
|
3272
3882
|
|
|
3273
|
-
//
|
|
3883
|
+
// node_modules/@probe.gl/stats/dist/utils/hi-res-timestamp.js
|
|
3884
|
+
function getHiResTimestamp2() {
|
|
3885
|
+
let timestamp;
|
|
3886
|
+
if (typeof window !== "undefined" && window.performance) {
|
|
3887
|
+
timestamp = window.performance.now();
|
|
3888
|
+
} else if (typeof process !== "undefined" && process.hrtime) {
|
|
3889
|
+
const timeParts = process.hrtime();
|
|
3890
|
+
timestamp = timeParts[0] * 1e3 + timeParts[1] / 1e6;
|
|
3891
|
+
} else {
|
|
3892
|
+
timestamp = Date.now();
|
|
3893
|
+
}
|
|
3894
|
+
return timestamp;
|
|
3895
|
+
}
|
|
3896
|
+
|
|
3897
|
+
// node_modules/@probe.gl/stats/dist/lib/stat.js
|
|
3898
|
+
var Stat = class {
|
|
3899
|
+
constructor(name, type) {
|
|
3900
|
+
this.sampleSize = 1;
|
|
3901
|
+
this.time = 0;
|
|
3902
|
+
this.count = 0;
|
|
3903
|
+
this.samples = 0;
|
|
3904
|
+
this.lastTiming = 0;
|
|
3905
|
+
this.lastSampleTime = 0;
|
|
3906
|
+
this.lastSampleCount = 0;
|
|
3907
|
+
this._count = 0;
|
|
3908
|
+
this._time = 0;
|
|
3909
|
+
this._samples = 0;
|
|
3910
|
+
this._startTime = 0;
|
|
3911
|
+
this._timerPending = false;
|
|
3912
|
+
this.name = name;
|
|
3913
|
+
this.type = type;
|
|
3914
|
+
this.reset();
|
|
3915
|
+
}
|
|
3916
|
+
reset() {
|
|
3917
|
+
this.time = 0;
|
|
3918
|
+
this.count = 0;
|
|
3919
|
+
this.samples = 0;
|
|
3920
|
+
this.lastTiming = 0;
|
|
3921
|
+
this.lastSampleTime = 0;
|
|
3922
|
+
this.lastSampleCount = 0;
|
|
3923
|
+
this._count = 0;
|
|
3924
|
+
this._time = 0;
|
|
3925
|
+
this._samples = 0;
|
|
3926
|
+
this._startTime = 0;
|
|
3927
|
+
this._timerPending = false;
|
|
3928
|
+
return this;
|
|
3929
|
+
}
|
|
3930
|
+
setSampleSize(samples) {
|
|
3931
|
+
this.sampleSize = samples;
|
|
3932
|
+
return this;
|
|
3933
|
+
}
|
|
3934
|
+
/** Call to increment count (+1) */
|
|
3935
|
+
incrementCount() {
|
|
3936
|
+
this.addCount(1);
|
|
3937
|
+
return this;
|
|
3938
|
+
}
|
|
3939
|
+
/** Call to decrement count (-1) */
|
|
3940
|
+
decrementCount() {
|
|
3941
|
+
this.subtractCount(1);
|
|
3942
|
+
return this;
|
|
3943
|
+
}
|
|
3944
|
+
/** Increase count */
|
|
3945
|
+
addCount(value) {
|
|
3946
|
+
this._count += value;
|
|
3947
|
+
this._samples++;
|
|
3948
|
+
this._checkSampling();
|
|
3949
|
+
return this;
|
|
3950
|
+
}
|
|
3951
|
+
/** Decrease count */
|
|
3952
|
+
subtractCount(value) {
|
|
3953
|
+
this._count -= value;
|
|
3954
|
+
this._samples++;
|
|
3955
|
+
this._checkSampling();
|
|
3956
|
+
return this;
|
|
3957
|
+
}
|
|
3958
|
+
/** Add an arbitrary timing and bump the count */
|
|
3959
|
+
addTime(time) {
|
|
3960
|
+
this._time += time;
|
|
3961
|
+
this.lastTiming = time;
|
|
3962
|
+
this._samples++;
|
|
3963
|
+
this._checkSampling();
|
|
3964
|
+
return this;
|
|
3965
|
+
}
|
|
3966
|
+
/** Start a timer */
|
|
3967
|
+
timeStart() {
|
|
3968
|
+
this._startTime = getHiResTimestamp2();
|
|
3969
|
+
this._timerPending = true;
|
|
3970
|
+
return this;
|
|
3971
|
+
}
|
|
3972
|
+
/** End a timer. Adds to time and bumps the timing count. */
|
|
3973
|
+
timeEnd() {
|
|
3974
|
+
if (!this._timerPending) {
|
|
3975
|
+
return this;
|
|
3976
|
+
}
|
|
3977
|
+
this.addTime(getHiResTimestamp2() - this._startTime);
|
|
3978
|
+
this._timerPending = false;
|
|
3979
|
+
this._checkSampling();
|
|
3980
|
+
return this;
|
|
3981
|
+
}
|
|
3982
|
+
getSampleAverageCount() {
|
|
3983
|
+
return this.sampleSize > 0 ? this.lastSampleCount / this.sampleSize : 0;
|
|
3984
|
+
}
|
|
3985
|
+
/** Calculate average time / count for the previous window */
|
|
3986
|
+
getSampleAverageTime() {
|
|
3987
|
+
return this.sampleSize > 0 ? this.lastSampleTime / this.sampleSize : 0;
|
|
3988
|
+
}
|
|
3989
|
+
/** Calculate counts per second for the previous window */
|
|
3990
|
+
getSampleHz() {
|
|
3991
|
+
return this.lastSampleTime > 0 ? this.sampleSize / (this.lastSampleTime / 1e3) : 0;
|
|
3992
|
+
}
|
|
3993
|
+
getAverageCount() {
|
|
3994
|
+
return this.samples > 0 ? this.count / this.samples : 0;
|
|
3995
|
+
}
|
|
3996
|
+
/** Calculate average time / count */
|
|
3997
|
+
getAverageTime() {
|
|
3998
|
+
return this.samples > 0 ? this.time / this.samples : 0;
|
|
3999
|
+
}
|
|
4000
|
+
/** Calculate counts per second */
|
|
4001
|
+
getHz() {
|
|
4002
|
+
return this.time > 0 ? this.samples / (this.time / 1e3) : 0;
|
|
4003
|
+
}
|
|
4004
|
+
_checkSampling() {
|
|
4005
|
+
if (this._samples === this.sampleSize) {
|
|
4006
|
+
this.lastSampleTime = this._time;
|
|
4007
|
+
this.lastSampleCount = this._count;
|
|
4008
|
+
this.count += this._count;
|
|
4009
|
+
this.time += this._time;
|
|
4010
|
+
this.samples += this._samples;
|
|
4011
|
+
this._time = 0;
|
|
4012
|
+
this._count = 0;
|
|
4013
|
+
this._samples = 0;
|
|
4014
|
+
}
|
|
4015
|
+
}
|
|
4016
|
+
};
|
|
4017
|
+
|
|
4018
|
+
// node_modules/@probe.gl/stats/dist/lib/stats.js
|
|
4019
|
+
var Stats = class {
|
|
4020
|
+
constructor(options) {
|
|
4021
|
+
this.stats = {};
|
|
4022
|
+
this.id = options.id;
|
|
4023
|
+
this.stats = {};
|
|
4024
|
+
this._initializeStats(options.stats);
|
|
4025
|
+
Object.seal(this);
|
|
4026
|
+
}
|
|
4027
|
+
/** Acquire a stat. Create if it doesn't exist. */
|
|
4028
|
+
get(name, type = "count") {
|
|
4029
|
+
return this._getOrCreate({ name, type });
|
|
4030
|
+
}
|
|
4031
|
+
get size() {
|
|
4032
|
+
return Object.keys(this.stats).length;
|
|
4033
|
+
}
|
|
4034
|
+
/** Reset all stats */
|
|
4035
|
+
reset() {
|
|
4036
|
+
for (const stat of Object.values(this.stats)) {
|
|
4037
|
+
stat.reset();
|
|
4038
|
+
}
|
|
4039
|
+
return this;
|
|
4040
|
+
}
|
|
4041
|
+
forEach(fn) {
|
|
4042
|
+
for (const stat of Object.values(this.stats)) {
|
|
4043
|
+
fn(stat);
|
|
4044
|
+
}
|
|
4045
|
+
}
|
|
4046
|
+
getTable() {
|
|
4047
|
+
const table = {};
|
|
4048
|
+
this.forEach((stat) => {
|
|
4049
|
+
table[stat.name] = {
|
|
4050
|
+
time: stat.time || 0,
|
|
4051
|
+
count: stat.count || 0,
|
|
4052
|
+
average: stat.getAverageTime() || 0,
|
|
4053
|
+
hz: stat.getHz() || 0
|
|
4054
|
+
};
|
|
4055
|
+
});
|
|
4056
|
+
return table;
|
|
4057
|
+
}
|
|
4058
|
+
_initializeStats(stats = []) {
|
|
4059
|
+
stats.forEach((stat) => this._getOrCreate(stat));
|
|
4060
|
+
}
|
|
4061
|
+
_getOrCreate(stat) {
|
|
4062
|
+
const { name, type } = stat;
|
|
4063
|
+
let result = this.stats[name];
|
|
4064
|
+
if (!result) {
|
|
4065
|
+
if (stat instanceof Stat) {
|
|
4066
|
+
result = stat;
|
|
4067
|
+
} else {
|
|
4068
|
+
result = new Stat(name, type);
|
|
4069
|
+
}
|
|
4070
|
+
this.stats[name] = result;
|
|
4071
|
+
}
|
|
4072
|
+
return result;
|
|
4073
|
+
}
|
|
4074
|
+
};
|
|
4075
|
+
|
|
4076
|
+
// src/lib/vector-tiler/simplify.ts
|
|
3274
4077
|
function simplify(coords, first, last, sqTolerance) {
|
|
3275
4078
|
let maxSqDist = sqTolerance;
|
|
3276
4079
|
const mid = last - first >> 1;
|
|
@@ -3280,15 +4083,15 @@ var __exports__ = (() => {
|
|
|
3280
4083
|
const ay = coords[first + 1];
|
|
3281
4084
|
const bx = coords[last];
|
|
3282
4085
|
const by = coords[last + 1];
|
|
3283
|
-
for (let
|
|
3284
|
-
const d = getSqSegDist(coords[
|
|
4086
|
+
for (let i = first + 3; i < last; i += 3) {
|
|
4087
|
+
const d = getSqSegDist(coords[i], coords[i + 1], ax, ay, bx, by);
|
|
3285
4088
|
if (d > maxSqDist) {
|
|
3286
|
-
index =
|
|
4089
|
+
index = i;
|
|
3287
4090
|
maxSqDist = d;
|
|
3288
4091
|
} else if (d === maxSqDist) {
|
|
3289
|
-
const posToMid = Math.abs(
|
|
4092
|
+
const posToMid = Math.abs(i - mid);
|
|
3290
4093
|
if (posToMid < minPosToMid) {
|
|
3291
|
-
index =
|
|
4094
|
+
index = i;
|
|
3292
4095
|
minPosToMid = posToMid;
|
|
3293
4096
|
}
|
|
3294
4097
|
}
|
|
@@ -3301,25 +4104,25 @@ var __exports__ = (() => {
|
|
|
3301
4104
|
simplify(coords, index, last, sqTolerance);
|
|
3302
4105
|
}
|
|
3303
4106
|
}
|
|
3304
|
-
function getSqSegDist(px, py,
|
|
3305
|
-
let dx = bx -
|
|
3306
|
-
let dy = by -
|
|
4107
|
+
function getSqSegDist(px, py, x, y, bx, by) {
|
|
4108
|
+
let dx = bx - x;
|
|
4109
|
+
let dy = by - y;
|
|
3307
4110
|
if (dx !== 0 || dy !== 0) {
|
|
3308
|
-
const t = ((px -
|
|
4111
|
+
const t = ((px - x) * dx + (py - y) * dy) / (dx * dx + dy * dy);
|
|
3309
4112
|
if (t > 1) {
|
|
3310
|
-
|
|
3311
|
-
|
|
4113
|
+
x = bx;
|
|
4114
|
+
y = by;
|
|
3312
4115
|
} else if (t > 0) {
|
|
3313
|
-
|
|
3314
|
-
|
|
4116
|
+
x += dx * t;
|
|
4117
|
+
y += dy * t;
|
|
3315
4118
|
}
|
|
3316
4119
|
}
|
|
3317
|
-
dx = px -
|
|
3318
|
-
dy = py -
|
|
4120
|
+
dx = px - x;
|
|
4121
|
+
dy = py - y;
|
|
3319
4122
|
return dx * dx + dy * dy;
|
|
3320
4123
|
}
|
|
3321
4124
|
|
|
3322
|
-
// src/lib/
|
|
4125
|
+
// src/lib/vector-tiler/feature.ts
|
|
3323
4126
|
function createFeature(id, type, geom, tags) {
|
|
3324
4127
|
const feature = {
|
|
3325
4128
|
// eslint-disable-next-line
|
|
@@ -3348,20 +4151,20 @@ var __exports__ = (() => {
|
|
|
3348
4151
|
return feature;
|
|
3349
4152
|
}
|
|
3350
4153
|
function calcLineBBox(feature, geom) {
|
|
3351
|
-
for (let
|
|
3352
|
-
feature.minX = Math.min(feature.minX, geom[
|
|
3353
|
-
feature.minY = Math.min(feature.minY, geom[
|
|
3354
|
-
feature.maxX = Math.max(feature.maxX, geom[
|
|
3355
|
-
feature.maxY = Math.max(feature.maxY, geom[
|
|
4154
|
+
for (let i = 0; i < geom.length; i += 3) {
|
|
4155
|
+
feature.minX = Math.min(feature.minX, geom[i]);
|
|
4156
|
+
feature.minY = Math.min(feature.minY, geom[i + 1]);
|
|
4157
|
+
feature.maxX = Math.max(feature.maxX, geom[i]);
|
|
4158
|
+
feature.maxY = Math.max(feature.maxY, geom[i + 1]);
|
|
3356
4159
|
}
|
|
3357
4160
|
}
|
|
3358
4161
|
|
|
3359
|
-
// src/lib/
|
|
4162
|
+
// src/lib/vector-tiler/convert.ts
|
|
3360
4163
|
function convert(data, options) {
|
|
3361
4164
|
const features = [];
|
|
3362
4165
|
if (data.type === "FeatureCollection") {
|
|
3363
|
-
for (let
|
|
3364
|
-
convertFeature(features, data.features[
|
|
4166
|
+
for (let i = 0; i < data.features.length; i++) {
|
|
4167
|
+
convertFeature(features, data.features[i], options, i);
|
|
3365
4168
|
}
|
|
3366
4169
|
} else if (data.type === "Feature") {
|
|
3367
4170
|
convertFeature(features, data, options);
|
|
@@ -3437,18 +4240,18 @@ var __exports__ = (() => {
|
|
|
3437
4240
|
let x0, y0;
|
|
3438
4241
|
let size = 0;
|
|
3439
4242
|
for (let j = 0; j < ring.length; j++) {
|
|
3440
|
-
const
|
|
3441
|
-
const
|
|
3442
|
-
out.push(
|
|
4243
|
+
const x = projectX(ring[j][0]);
|
|
4244
|
+
const y = projectY(ring[j][1]);
|
|
4245
|
+
out.push(x, y, 0);
|
|
3443
4246
|
if (j > 0) {
|
|
3444
4247
|
if (isPolygon) {
|
|
3445
|
-
size += (x0 *
|
|
4248
|
+
size += (x0 * y - x * y0) / 2;
|
|
3446
4249
|
} else {
|
|
3447
|
-
size += Math.sqrt(Math.pow(
|
|
4250
|
+
size += Math.sqrt(Math.pow(x - x0, 2) + Math.pow(y - y0, 2));
|
|
3448
4251
|
}
|
|
3449
4252
|
}
|
|
3450
|
-
x0 =
|
|
3451
|
-
y0 =
|
|
4253
|
+
x0 = x;
|
|
4254
|
+
y0 = y;
|
|
3452
4255
|
}
|
|
3453
4256
|
const last = out.length - 3;
|
|
3454
4257
|
out[2] = 1;
|
|
@@ -3459,22 +4262,22 @@ var __exports__ = (() => {
|
|
|
3459
4262
|
out.end = out.size;
|
|
3460
4263
|
}
|
|
3461
4264
|
function convertLines(rings, out, tolerance, isPolygon) {
|
|
3462
|
-
for (let
|
|
4265
|
+
for (let i = 0; i < rings.length; i++) {
|
|
3463
4266
|
const geom = [];
|
|
3464
|
-
convertLine(rings[
|
|
4267
|
+
convertLine(rings[i], geom, tolerance, isPolygon);
|
|
3465
4268
|
out.push(geom);
|
|
3466
4269
|
}
|
|
3467
4270
|
}
|
|
3468
|
-
function projectX(
|
|
3469
|
-
return
|
|
4271
|
+
function projectX(x) {
|
|
4272
|
+
return x / 360 + 0.5;
|
|
3470
4273
|
}
|
|
3471
|
-
function projectY(
|
|
3472
|
-
const sin = Math.sin(
|
|
3473
|
-
const
|
|
3474
|
-
return
|
|
4274
|
+
function projectY(y) {
|
|
4275
|
+
const sin = Math.sin(y * Math.PI / 180);
|
|
4276
|
+
const y2 = 0.5 - 0.25 * Math.log((1 + sin) / (1 - sin)) / Math.PI;
|
|
4277
|
+
return y2 < 0 ? 0 : y2 > 1 ? 1 : y2;
|
|
3475
4278
|
}
|
|
3476
4279
|
|
|
3477
|
-
// src/lib/
|
|
4280
|
+
// src/lib/vector-tiler/clip.ts
|
|
3478
4281
|
function clip(features, scale, k1, k2, axis, minAll, maxAll, options) {
|
|
3479
4282
|
k1 /= scale;
|
|
3480
4283
|
k2 /= scale;
|
|
@@ -3537,10 +4340,10 @@ var __exports__ = (() => {
|
|
|
3537
4340
|
return clipped.length ? clipped : null;
|
|
3538
4341
|
}
|
|
3539
4342
|
function clipPoints(geom, newGeom, k1, k2, axis) {
|
|
3540
|
-
for (let
|
|
3541
|
-
const a = geom[
|
|
4343
|
+
for (let i = 0; i < geom.length; i += 3) {
|
|
4344
|
+
const a = geom[i + axis];
|
|
3542
4345
|
if (a >= k1 && a <= k2) {
|
|
3543
|
-
addPoint(newGeom, geom[
|
|
4346
|
+
addPoint(newGeom, geom[i], geom[i + 1], geom[i + 2]);
|
|
3544
4347
|
}
|
|
3545
4348
|
}
|
|
3546
4349
|
}
|
|
@@ -3550,12 +4353,12 @@ var __exports__ = (() => {
|
|
|
3550
4353
|
let len = geom.start;
|
|
3551
4354
|
let segLen;
|
|
3552
4355
|
let t;
|
|
3553
|
-
for (let
|
|
3554
|
-
const ax2 = geom[
|
|
3555
|
-
const ay2 = geom[
|
|
3556
|
-
const az2 = geom[
|
|
3557
|
-
const bx = geom[
|
|
3558
|
-
const by = geom[
|
|
4356
|
+
for (let i = 0; i < geom.length - 3; i += 3) {
|
|
4357
|
+
const ax2 = geom[i];
|
|
4358
|
+
const ay2 = geom[i + 1];
|
|
4359
|
+
const az2 = geom[i + 2];
|
|
4360
|
+
const bx = geom[i + 3];
|
|
4361
|
+
const by = geom[i + 4];
|
|
3559
4362
|
const a2 = axis === 0 ? ax2 : ay2;
|
|
3560
4363
|
const b = axis === 0 ? bx : by;
|
|
3561
4364
|
let exited = false;
|
|
@@ -3625,21 +4428,21 @@ var __exports__ = (() => {
|
|
|
3625
4428
|
clipLine(line, newGeom, k1, k2, axis, isPolygon, false);
|
|
3626
4429
|
}
|
|
3627
4430
|
}
|
|
3628
|
-
function addPoint(out,
|
|
3629
|
-
out.push(
|
|
4431
|
+
function addPoint(out, x, y, z) {
|
|
4432
|
+
out.push(x, y, z);
|
|
3630
4433
|
}
|
|
3631
|
-
function intersectX(out, ax, ay, bx, by,
|
|
3632
|
-
const t = (
|
|
3633
|
-
addPoint(out,
|
|
4434
|
+
function intersectX(out, ax, ay, bx, by, x) {
|
|
4435
|
+
const t = (x - ax) / (bx - ax);
|
|
4436
|
+
addPoint(out, x, ay + (by - ay) * t, 1);
|
|
3634
4437
|
return t;
|
|
3635
4438
|
}
|
|
3636
|
-
function intersectY(out, ax, ay, bx, by,
|
|
3637
|
-
const t = (
|
|
3638
|
-
addPoint(out, ax + (bx - ax) * t,
|
|
4439
|
+
function intersectY(out, ax, ay, bx, by, y) {
|
|
4440
|
+
const t = (y - ay) / (by - ay);
|
|
4441
|
+
addPoint(out, ax + (bx - ax) * t, y, 1);
|
|
3639
4442
|
return t;
|
|
3640
4443
|
}
|
|
3641
4444
|
|
|
3642
|
-
// src/lib/
|
|
4445
|
+
// src/lib/vector-tiler/wrap.ts
|
|
3643
4446
|
function wrap(features, options) {
|
|
3644
4447
|
const buffer = options.buffer / options.extent;
|
|
3645
4448
|
let merged = features;
|
|
@@ -3658,8 +4461,8 @@ var __exports__ = (() => {
|
|
|
3658
4461
|
}
|
|
3659
4462
|
function shiftFeatureCoords(features, offset) {
|
|
3660
4463
|
const newFeatures = [];
|
|
3661
|
-
for (let
|
|
3662
|
-
const feature = features[
|
|
4464
|
+
for (let i = 0; i < features.length; i++) {
|
|
4465
|
+
const feature = features[i];
|
|
3663
4466
|
const type = feature.type;
|
|
3664
4467
|
let newGeometry;
|
|
3665
4468
|
if (type === "Point" || type === "MultiPoint" || type === "LineString") {
|
|
@@ -3690,13 +4493,13 @@ var __exports__ = (() => {
|
|
|
3690
4493
|
newPoints.start = points.start;
|
|
3691
4494
|
newPoints.end = points.end;
|
|
3692
4495
|
}
|
|
3693
|
-
for (let
|
|
3694
|
-
newPoints.push(points[
|
|
4496
|
+
for (let i = 0; i < points.length; i += 3) {
|
|
4497
|
+
newPoints.push(points[i] + offset, points[i + 1], points[i + 2]);
|
|
3695
4498
|
}
|
|
3696
4499
|
return newPoints;
|
|
3697
4500
|
}
|
|
3698
4501
|
|
|
3699
|
-
// src/lib/
|
|
4502
|
+
// src/lib/vector-tiler/transform.ts
|
|
3700
4503
|
function transformTile(tile, extent) {
|
|
3701
4504
|
if (tile.transformed) {
|
|
3702
4505
|
return tile;
|
|
@@ -3725,11 +4528,11 @@ var __exports__ = (() => {
|
|
|
3725
4528
|
tile.transformed = true;
|
|
3726
4529
|
return tile;
|
|
3727
4530
|
}
|
|
3728
|
-
function transformPoint(
|
|
3729
|
-
return [Math.round(extent * (
|
|
4531
|
+
function transformPoint(x, y, extent, z2, tx, ty) {
|
|
4532
|
+
return [Math.round(extent * (x * z2 - tx)), Math.round(extent * (y * z2 - ty))];
|
|
3730
4533
|
}
|
|
3731
4534
|
|
|
3732
|
-
// src/lib/
|
|
4535
|
+
// src/lib/vector-tiler/tile.ts
|
|
3733
4536
|
function createTile(features, z, tx, ty, options) {
|
|
3734
4537
|
const tolerance = z === options.maxZoom ? 0 : options.tolerance / ((1 << z) * options.extent);
|
|
3735
4538
|
const tile = {
|
|
@@ -3761,22 +4564,22 @@ var __exports__ = (() => {
|
|
|
3761
4564
|
tile.maxX = Math.max(tile.maxX, feature.maxX);
|
|
3762
4565
|
tile.maxY = Math.max(tile.maxY, feature.maxY);
|
|
3763
4566
|
if (type === "Point" || type === "MultiPoint") {
|
|
3764
|
-
for (let
|
|
3765
|
-
simplified.push(geom[
|
|
4567
|
+
for (let i = 0; i < geom.length; i += 3) {
|
|
4568
|
+
simplified.push(geom[i], geom[i + 1]);
|
|
3766
4569
|
tile.numPoints++;
|
|
3767
4570
|
tile.numSimplified++;
|
|
3768
4571
|
}
|
|
3769
4572
|
} else if (type === "LineString") {
|
|
3770
4573
|
addLine(simplified, geom, tile, tolerance, false, false);
|
|
3771
4574
|
} else if (type === "MultiLineString" || type === "Polygon") {
|
|
3772
|
-
for (let
|
|
3773
|
-
addLine(simplified, geom[
|
|
4575
|
+
for (let i = 0; i < geom.length; i++) {
|
|
4576
|
+
addLine(simplified, geom[i], tile, tolerance, type === "Polygon", i === 0);
|
|
3774
4577
|
}
|
|
3775
4578
|
} else if (type === "MultiPolygon") {
|
|
3776
4579
|
for (let k = 0; k < geom.length; k++) {
|
|
3777
4580
|
const polygon = geom[k];
|
|
3778
|
-
for (let
|
|
3779
|
-
addLine(simplified, polygon[
|
|
4581
|
+
for (let i = 0; i < polygon.length; i++) {
|
|
4582
|
+
addLine(simplified, polygon[i], tile, tolerance, true, i === 0);
|
|
3780
4583
|
}
|
|
3781
4584
|
}
|
|
3782
4585
|
}
|
|
@@ -3807,10 +4610,10 @@ var __exports__ = (() => {
|
|
|
3807
4610
|
return;
|
|
3808
4611
|
}
|
|
3809
4612
|
const ring = [];
|
|
3810
|
-
for (let
|
|
3811
|
-
if (tolerance === 0 || geom[
|
|
4613
|
+
for (let i = 0; i < geom.length; i += 3) {
|
|
4614
|
+
if (tolerance === 0 || geom[i + 2] > sqTolerance) {
|
|
3812
4615
|
tile.numSimplified++;
|
|
3813
|
-
ring.push(geom[
|
|
4616
|
+
ring.push(geom[i], geom[i + 1]);
|
|
3814
4617
|
}
|
|
3815
4618
|
tile.numPoints++;
|
|
3816
4619
|
}
|
|
@@ -3820,110 +4623,147 @@ var __exports__ = (() => {
|
|
|
3820
4623
|
}
|
|
3821
4624
|
function rewind(ring, clockwise) {
|
|
3822
4625
|
let area2 = 0;
|
|
3823
|
-
for (let
|
|
3824
|
-
area2 += (ring[
|
|
4626
|
+
for (let i = 0, j = ring.length - 2; i < ring.length; j = i, i += 2) {
|
|
4627
|
+
area2 += (ring[i] - ring[j]) * (ring[i + 1] + ring[j + 1]);
|
|
3825
4628
|
}
|
|
3826
4629
|
if (area2 > 0 === clockwise) {
|
|
3827
|
-
for (let
|
|
3828
|
-
const
|
|
3829
|
-
const
|
|
3830
|
-
ring[
|
|
3831
|
-
ring[
|
|
3832
|
-
ring[len - 2 -
|
|
3833
|
-
ring[len - 1 -
|
|
4630
|
+
for (let i = 0, len = ring.length; i < len / 2; i += 2) {
|
|
4631
|
+
const x = ring[i];
|
|
4632
|
+
const y = ring[i + 1];
|
|
4633
|
+
ring[i] = ring[len - 2 - i];
|
|
4634
|
+
ring[i + 1] = ring[len - 1 - i];
|
|
4635
|
+
ring[len - 2 - i] = x;
|
|
4636
|
+
ring[len - 1 - i] = y;
|
|
3834
4637
|
}
|
|
3835
4638
|
}
|
|
3836
4639
|
}
|
|
3837
4640
|
|
|
3838
|
-
// src/
|
|
3839
|
-
var
|
|
3840
|
-
|
|
3841
|
-
|
|
3842
|
-
|
|
3843
|
-
|
|
3844
|
-
|
|
3845
|
-
|
|
3846
|
-
|
|
3847
|
-
|
|
3848
|
-
|
|
3849
|
-
|
|
3850
|
-
|
|
3851
|
-
|
|
3852
|
-
|
|
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 {
|
|
3863
|
-
options;
|
|
3864
|
-
// tiles and tileCoords are part of the public API
|
|
4641
|
+
// src/table-tile-source.ts
|
|
4642
|
+
var _TableTileSource = class {
|
|
4643
|
+
/** Stats for this TableTileSource */
|
|
4644
|
+
stats = new Stats({
|
|
4645
|
+
id: "table-tile-source",
|
|
4646
|
+
stats: [new Stat("tiles", "count"), new Stat("features", "count")]
|
|
4647
|
+
});
|
|
4648
|
+
/** MIME type of the tiles emitted by this tile source */
|
|
4649
|
+
mimeType = "application/vnd.mapbox-vector-tile";
|
|
4650
|
+
localCoordinates = true;
|
|
4651
|
+
/** The props that this tile source was created with */
|
|
4652
|
+
props;
|
|
4653
|
+
/* Schema of the data */
|
|
4654
|
+
schema = null;
|
|
4655
|
+
/** Map of generated tiles, indexed by stringified tile coordinates */
|
|
3865
4656
|
tiles = {};
|
|
4657
|
+
/** Array of tile coordinates */
|
|
3866
4658
|
tileCoords = [];
|
|
3867
|
-
|
|
3868
|
-
|
|
3869
|
-
|
|
3870
|
-
|
|
3871
|
-
|
|
3872
|
-
|
|
3873
|
-
|
|
3874
|
-
|
|
3875
|
-
|
|
4659
|
+
/** Input data has loaded, initial top-level tiling is done, sync methods can now be called */
|
|
4660
|
+
ready;
|
|
4661
|
+
/** Metadata for the tile source (generated TileJSON/tilestats */
|
|
4662
|
+
metadata;
|
|
4663
|
+
constructor(table, props) {
|
|
4664
|
+
this.props = { ..._TableTileSource.defaultProps, ...props };
|
|
4665
|
+
this.getTileData = this.getTileData.bind(this);
|
|
4666
|
+
this.ready = this.initializeTilesAsync(table);
|
|
4667
|
+
this.metadata = this.getMetadata();
|
|
4668
|
+
}
|
|
4669
|
+
async initializeTilesAsync(tablePromise) {
|
|
4670
|
+
const table = await tablePromise;
|
|
4671
|
+
this.schema = deduceTableSchema(table);
|
|
4672
|
+
this.createRootTiles(table);
|
|
4673
|
+
}
|
|
4674
|
+
async getMetadata() {
|
|
4675
|
+
await this.ready;
|
|
4676
|
+
return { schema: this.schema, minZoom: 0, maxZoom: this.props.maxZoom };
|
|
4677
|
+
}
|
|
4678
|
+
async getSchema() {
|
|
4679
|
+
await this.ready;
|
|
4680
|
+
return this.schema;
|
|
4681
|
+
}
|
|
4682
|
+
/**
|
|
4683
|
+
* Get a tile at the specified index
|
|
4684
|
+
* @param tileIndex z, x, y of tile
|
|
4685
|
+
* @returns
|
|
4686
|
+
*/
|
|
4687
|
+
async getVectorTile(tileIndex) {
|
|
4688
|
+
await this.ready;
|
|
4689
|
+
const table = this.getTileSync(tileIndex);
|
|
4690
|
+
log.info(2, "getVectorTile", tileIndex, table)();
|
|
4691
|
+
return table;
|
|
4692
|
+
}
|
|
4693
|
+
async getTile(tileIndex) {
|
|
4694
|
+
await this.ready;
|
|
4695
|
+
return this.getTileSync(tileIndex);
|
|
4696
|
+
}
|
|
4697
|
+
async getTileData(tileParams) {
|
|
4698
|
+
const { x, y, z } = tileParams.index;
|
|
4699
|
+
const tile = await this.getVectorTile({ x, y, z });
|
|
4700
|
+
return tile?.features || [];
|
|
4701
|
+
}
|
|
4702
|
+
// Implementation
|
|
4703
|
+
/**
|
|
4704
|
+
* Synchronously request a tile
|
|
4705
|
+
* @note Application must await `source.ready` before calling sync methods.
|
|
4706
|
+
*/
|
|
4707
|
+
getTileSync(tileIndex) {
|
|
4708
|
+
const rawTile = this.getRawTile(tileIndex);
|
|
4709
|
+
if (!rawTile) {
|
|
4710
|
+
return null;
|
|
4711
|
+
}
|
|
4712
|
+
return convertToGeoJSONTable(rawTile, {
|
|
4713
|
+
coordinates: this.props.coordinates,
|
|
4714
|
+
tileIndex,
|
|
4715
|
+
extent: this.props.extent
|
|
4716
|
+
});
|
|
4717
|
+
}
|
|
4718
|
+
/**
|
|
4719
|
+
* Create the initial tiles
|
|
4720
|
+
* @note the tiles stores all the features together with additional data
|
|
4721
|
+
*/
|
|
4722
|
+
createRootTiles(table) {
|
|
4723
|
+
if (this.props.maxZoom < 0 || this.props.maxZoom > 24) {
|
|
3876
4724
|
throw new Error("maxZoom should be in the 0-24 range");
|
|
3877
4725
|
}
|
|
3878
|
-
if (
|
|
4726
|
+
if (this.props.promoteId && this.props.generateId) {
|
|
3879
4727
|
throw new Error("promoteId and generateId cannot be used together.");
|
|
3880
4728
|
}
|
|
3881
|
-
|
|
3882
|
-
|
|
3883
|
-
|
|
3884
|
-
|
|
3885
|
-
|
|
3886
|
-
|
|
3887
|
-
|
|
3888
|
-
);
|
|
3889
|
-
|
|
3890
|
-
}
|
|
3891
|
-
features = wrap(features, this.options);
|
|
3892
|
-
if (features.length) {
|
|
3893
|
-
this.splitTile(features, 0, 0, 0);
|
|
3894
|
-
}
|
|
3895
|
-
if (debug) {
|
|
3896
|
-
if (features.length) {
|
|
3897
|
-
console.log("features: %d, points: %d", this.tiles[0].numFeatures, this.tiles[0].numPoints);
|
|
3898
|
-
}
|
|
3899
|
-
console.timeEnd("generate tiles");
|
|
3900
|
-
console.log("tiles generated:", this.total, JSON.stringify(this.stats));
|
|
4729
|
+
log.log(1, "TableTileSource creating root tiles", this.props)();
|
|
4730
|
+
log.time(1, "preprocess table")();
|
|
4731
|
+
let features = convert(table, this.props);
|
|
4732
|
+
log.timeEnd(1, "preprocess table")();
|
|
4733
|
+
log.time(1, "generate tiles")();
|
|
4734
|
+
features = wrap(features, this.props);
|
|
4735
|
+
if (features.length === 0) {
|
|
4736
|
+
log.log(1, "TableTileSource: no features generated")();
|
|
4737
|
+
return;
|
|
3901
4738
|
}
|
|
4739
|
+
this.splitTile(features, 0, 0, 0);
|
|
4740
|
+
const rootTile = this.tiles[0];
|
|
4741
|
+
log.log(1, `root tile features: ${rootTile.numFeatures}, points: ${rootTile.numPoints}`)();
|
|
4742
|
+
log.timeEnd(1, "generate tiles")();
|
|
4743
|
+
log.log(1, `TableTileSource: tiles generated: ${this.stats.get("total").count}`, this.stats)();
|
|
3902
4744
|
}
|
|
3903
4745
|
/**
|
|
3904
|
-
*
|
|
3905
|
-
* @
|
|
3906
|
-
* @param x
|
|
3907
|
-
* @param y
|
|
3908
|
-
* @returns
|
|
4746
|
+
* Return geojsonvt-style "half formed" vector tile
|
|
4747
|
+
* @note Application must await `source.ready` before calling sync methods.
|
|
3909
4748
|
*/
|
|
3910
4749
|
// eslint-disable-next-line complexity, max-statements
|
|
3911
|
-
|
|
3912
|
-
const {
|
|
4750
|
+
getRawTile(tileIndex) {
|
|
4751
|
+
const { z, y } = tileIndex;
|
|
4752
|
+
let { x } = tileIndex;
|
|
4753
|
+
const { extent } = this.props;
|
|
3913
4754
|
if (z < 0 || z > 24) {
|
|
3914
4755
|
return null;
|
|
3915
4756
|
}
|
|
3916
4757
|
const z2 = 1 << z;
|
|
3917
|
-
|
|
3918
|
-
const id = toID(z,
|
|
4758
|
+
x = x + z2 & z2 - 1;
|
|
4759
|
+
const id = toID(z, x, y);
|
|
3919
4760
|
if (this.tiles[id]) {
|
|
3920
4761
|
return transformTile(this.tiles[id], extent);
|
|
3921
4762
|
}
|
|
3922
|
-
|
|
3923
|
-
console.log("drilling down to z%d-%d-%d", z, x2, y2);
|
|
4763
|
+
log.log(log, "drilling down to z%d-%d-%d", z, x, y)();
|
|
3924
4764
|
let z0 = z;
|
|
3925
|
-
let x0 =
|
|
3926
|
-
let y0 =
|
|
4765
|
+
let x0 = x;
|
|
4766
|
+
let y0 = y;
|
|
3927
4767
|
let parent;
|
|
3928
4768
|
while (!parent && z0 > 0) {
|
|
3929
4769
|
z0--;
|
|
@@ -3934,14 +4774,10 @@ var __exports__ = (() => {
|
|
|
3934
4774
|
if (!parent || !parent.source) {
|
|
3935
4775
|
return null;
|
|
3936
4776
|
}
|
|
3937
|
-
|
|
3938
|
-
|
|
3939
|
-
|
|
3940
|
-
|
|
3941
|
-
this.splitTile(parent.source, z0, x0, y0, z, x2, y2);
|
|
3942
|
-
if (debug > 1) {
|
|
3943
|
-
console.timeEnd("drilling down");
|
|
3944
|
-
}
|
|
4777
|
+
log.log(1, "found parent tile z%d-%d-%d", z0, x0, y0)();
|
|
4778
|
+
log.time(1, "drilling down")();
|
|
4779
|
+
this.splitTile(parent.source, z0, x0, y0, z, x, y);
|
|
4780
|
+
log.timeEnd(1, "drilling down")();
|
|
3945
4781
|
return this.tiles[id] ? transformTile(this.tiles[id], extent) : null;
|
|
3946
4782
|
}
|
|
3947
4783
|
/**
|
|
@@ -3950,62 +4786,62 @@ var __exports__ = (() => {
|
|
|
3950
4786
|
* @param cz, cx, and cy are the coordinates of the target tile
|
|
3951
4787
|
*
|
|
3952
4788
|
* If no target tile is specified, splitting stops when we reach the maximum
|
|
3953
|
-
* zoom or the number of points is low as specified in the
|
|
4789
|
+
* zoom or the number of points is low as specified in the props.
|
|
3954
4790
|
*/
|
|
3955
4791
|
// eslint-disable-next-line max-params, max-statements, complexity
|
|
3956
|
-
splitTile(features, z,
|
|
3957
|
-
const stack = [features, z,
|
|
3958
|
-
const options = this.options;
|
|
3959
|
-
const debug = options.debug;
|
|
4792
|
+
splitTile(features, z, x, y, cz, cx, cy) {
|
|
4793
|
+
const stack = [features, z, x, y];
|
|
3960
4794
|
while (stack.length) {
|
|
3961
|
-
|
|
3962
|
-
|
|
4795
|
+
y = stack.pop();
|
|
4796
|
+
x = stack.pop();
|
|
3963
4797
|
z = stack.pop();
|
|
3964
4798
|
features = stack.pop();
|
|
3965
4799
|
const z2 = 1 << z;
|
|
3966
|
-
const id = toID(z,
|
|
4800
|
+
const id = toID(z, x, y);
|
|
3967
4801
|
let tile = this.tiles[id];
|
|
3968
4802
|
if (!tile) {
|
|
3969
|
-
|
|
3970
|
-
|
|
3971
|
-
}
|
|
3972
|
-
|
|
3973
|
-
this.
|
|
3974
|
-
|
|
3975
|
-
|
|
3976
|
-
|
|
3977
|
-
|
|
3978
|
-
|
|
3979
|
-
|
|
3980
|
-
|
|
3981
|
-
|
|
3982
|
-
|
|
3983
|
-
|
|
3984
|
-
|
|
3985
|
-
|
|
3986
|
-
|
|
3987
|
-
|
|
3988
|
-
|
|
3989
|
-
|
|
3990
|
-
|
|
4803
|
+
log.time(2, "tile creation")();
|
|
4804
|
+
tile = this.tiles[id] = createTile(features, z, x, y, this.props);
|
|
4805
|
+
this.tileCoords.push({ z, x, y });
|
|
4806
|
+
const key = `z${z}`;
|
|
4807
|
+
let stat = this.stats.get(key, "count");
|
|
4808
|
+
stat.incrementCount();
|
|
4809
|
+
stat = this.stats.get("total");
|
|
4810
|
+
stat.incrementCount();
|
|
4811
|
+
stat = _TableTileSource.stats.get(key, "count");
|
|
4812
|
+
stat.incrementCount();
|
|
4813
|
+
stat = _TableTileSource.stats.get("total");
|
|
4814
|
+
stat.incrementCount();
|
|
4815
|
+
log.log(
|
|
4816
|
+
2,
|
|
4817
|
+
"tile z%d-%d-%d (features: %d, points: %d, simplified: %d)",
|
|
4818
|
+
z,
|
|
4819
|
+
x,
|
|
4820
|
+
y,
|
|
4821
|
+
tile.numFeatures,
|
|
4822
|
+
tile.numPoints,
|
|
4823
|
+
tile.numSimplified
|
|
4824
|
+
)();
|
|
4825
|
+
log.timeEnd(2, "tile creation")();
|
|
3991
4826
|
}
|
|
3992
4827
|
tile.source = features;
|
|
3993
4828
|
if (cz === void 0) {
|
|
3994
|
-
if (z ===
|
|
4829
|
+
if (z === this.props.indexMaxZoom || tile.numPoints <= this.props.maxPointsPerTile) {
|
|
3995
4830
|
continue;
|
|
3996
|
-
|
|
4831
|
+
}
|
|
4832
|
+
} else if (z === this.props.maxZoom || z === cz) {
|
|
3997
4833
|
continue;
|
|
3998
4834
|
} else if (cz !== void 0) {
|
|
3999
4835
|
const zoomSteps = cz - z;
|
|
4000
|
-
if (
|
|
4836
|
+
if (x !== cx >> zoomSteps || y !== cy >> zoomSteps) {
|
|
4001
4837
|
continue;
|
|
4838
|
+
}
|
|
4002
4839
|
}
|
|
4003
4840
|
tile.source = null;
|
|
4004
4841
|
if (features.length === 0)
|
|
4005
4842
|
continue;
|
|
4006
|
-
|
|
4007
|
-
|
|
4008
|
-
const k1 = 0.5 * options.buffer / options.extent;
|
|
4843
|
+
log.time(2, "clipping tile")();
|
|
4844
|
+
const k1 = 0.5 * this.props.buffer / this.props.extent;
|
|
4009
4845
|
const k2 = 0.5 - k1;
|
|
4010
4846
|
const k3 = 0.5 + k1;
|
|
4011
4847
|
const k4 = 1 + k1;
|
|
@@ -4013,30 +4849,131 @@ var __exports__ = (() => {
|
|
|
4013
4849
|
let bl = null;
|
|
4014
4850
|
let tr = null;
|
|
4015
4851
|
let br = null;
|
|
4016
|
-
let left = clip(features, z2,
|
|
4017
|
-
let right = clip(features, z2,
|
|
4852
|
+
let left = clip(features, z2, x - k1, x + k3, 0, tile.minX, tile.maxX, this.props);
|
|
4853
|
+
let right = clip(features, z2, x + k2, x + k4, 0, tile.minX, tile.maxX, this.props);
|
|
4018
4854
|
features = null;
|
|
4019
4855
|
if (left) {
|
|
4020
|
-
tl = clip(left, z2,
|
|
4021
|
-
bl = clip(left, z2,
|
|
4856
|
+
tl = clip(left, z2, y - k1, y + k3, 1, tile.minY, tile.maxY, this.props);
|
|
4857
|
+
bl = clip(left, z2, y + k2, y + k4, 1, tile.minY, tile.maxY, this.props);
|
|
4022
4858
|
left = null;
|
|
4023
4859
|
}
|
|
4024
4860
|
if (right) {
|
|
4025
|
-
tr = clip(right, z2,
|
|
4026
|
-
br = clip(right, z2,
|
|
4861
|
+
tr = clip(right, z2, y - k1, y + k3, 1, tile.minY, tile.maxY, this.props);
|
|
4862
|
+
br = clip(right, z2, y + k2, y + k4, 1, tile.minY, tile.maxY, this.props);
|
|
4027
4863
|
right = null;
|
|
4028
4864
|
}
|
|
4029
|
-
|
|
4030
|
-
|
|
4031
|
-
stack.push(
|
|
4032
|
-
stack.push(
|
|
4033
|
-
stack.push(
|
|
4034
|
-
stack.push(br || [], z + 1, x2 * 2 + 1, y2 * 2 + 1);
|
|
4865
|
+
log.timeEnd(2, "clipping tile")();
|
|
4866
|
+
stack.push(tl || [], z + 1, x * 2, y * 2);
|
|
4867
|
+
stack.push(bl || [], z + 1, x * 2, y * 2 + 1);
|
|
4868
|
+
stack.push(tr || [], z + 1, x * 2 + 1, y * 2);
|
|
4869
|
+
stack.push(br || [], z + 1, x * 2 + 1, y * 2 + 1);
|
|
4035
4870
|
}
|
|
4036
4871
|
}
|
|
4037
4872
|
};
|
|
4038
|
-
|
|
4039
|
-
|
|
4873
|
+
var TableTileSource = _TableTileSource;
|
|
4874
|
+
__publicField(TableTileSource, "defaultProps", {
|
|
4875
|
+
coordinates: "wgs84",
|
|
4876
|
+
// coordinates in tile coordinates or lng/lat
|
|
4877
|
+
maxZoom: 14,
|
|
4878
|
+
// max zoom to preserve detail on
|
|
4879
|
+
indexMaxZoom: 5,
|
|
4880
|
+
// max zoom in the tile index
|
|
4881
|
+
maxPointsPerTile: 1e5,
|
|
4882
|
+
// max number of points per tile in the tile index
|
|
4883
|
+
tolerance: 3,
|
|
4884
|
+
// simplification tolerance (higher means simpler)
|
|
4885
|
+
extent: 4096,
|
|
4886
|
+
// tile extent
|
|
4887
|
+
buffer: 64,
|
|
4888
|
+
// tile buffer on each side
|
|
4889
|
+
lineMetrics: false,
|
|
4890
|
+
// whether to calculate line metrics
|
|
4891
|
+
// @ts-expect-error
|
|
4892
|
+
promoteId: void 0,
|
|
4893
|
+
// name of a feature property to be promoted to feature.id
|
|
4894
|
+
generateId: false,
|
|
4895
|
+
// whether to generate feature ids. Cannot be used with promoteId
|
|
4896
|
+
debug: 0
|
|
4897
|
+
// logging level (0, 1 or 2)
|
|
4898
|
+
});
|
|
4899
|
+
/** Global stats for all TableTileSources */
|
|
4900
|
+
__publicField(TableTileSource, "stats", new Stats({
|
|
4901
|
+
id: "table-tile-source-all",
|
|
4902
|
+
stats: [new Stat("count", "tiles"), new Stat("count", "features")]
|
|
4903
|
+
}));
|
|
4904
|
+
function toID(z, x, y) {
|
|
4905
|
+
return ((1 << z) * y + x) * 32 + z;
|
|
4906
|
+
}
|
|
4907
|
+
function convertToGeoJSONTable(vtTile, props) {
|
|
4908
|
+
const features = [];
|
|
4909
|
+
for (const rawFeature of vtTile.features) {
|
|
4910
|
+
if (!rawFeature || !rawFeature.geometry) {
|
|
4911
|
+
continue;
|
|
4912
|
+
}
|
|
4913
|
+
let type;
|
|
4914
|
+
let coordinates;
|
|
4915
|
+
switch (rawFeature.type) {
|
|
4916
|
+
case 1:
|
|
4917
|
+
if (rawFeature.geometry.length === 1) {
|
|
4918
|
+
type = "Point";
|
|
4919
|
+
coordinates = rawFeature.geometry[0];
|
|
4920
|
+
} else {
|
|
4921
|
+
type = "MultiPoint";
|
|
4922
|
+
coordinates = rawFeature.geometry;
|
|
4923
|
+
}
|
|
4924
|
+
break;
|
|
4925
|
+
case 2:
|
|
4926
|
+
if (rawFeature.geometry.length === 1) {
|
|
4927
|
+
type = "LineString";
|
|
4928
|
+
coordinates = rawFeature.geometry[0];
|
|
4929
|
+
} else {
|
|
4930
|
+
type = "MultiLineString";
|
|
4931
|
+
coordinates = rawFeature.geometry;
|
|
4932
|
+
}
|
|
4933
|
+
break;
|
|
4934
|
+
case 3:
|
|
4935
|
+
if (rawFeature.geometry.length > 1) {
|
|
4936
|
+
type = "MultiPolygon";
|
|
4937
|
+
coordinates = [rawFeature.geometry];
|
|
4938
|
+
} else {
|
|
4939
|
+
type = "Polygon";
|
|
4940
|
+
coordinates = rawFeature.geometry;
|
|
4941
|
+
}
|
|
4942
|
+
break;
|
|
4943
|
+
default:
|
|
4944
|
+
continue;
|
|
4945
|
+
}
|
|
4946
|
+
switch (props.coordinates) {
|
|
4947
|
+
case "EPSG:4326":
|
|
4948
|
+
case "wgs84":
|
|
4949
|
+
projectToLngLat(coordinates, props.tileIndex, props.extent);
|
|
4950
|
+
break;
|
|
4951
|
+
case "local":
|
|
4952
|
+
convertToLocalCoordinates(coordinates, props.extent);
|
|
4953
|
+
break;
|
|
4954
|
+
default:
|
|
4955
|
+
throw new Error(`Unsupported CRS ${props.coordinates}`);
|
|
4956
|
+
}
|
|
4957
|
+
const feature = {
|
|
4958
|
+
type: "Feature",
|
|
4959
|
+
geometry: {
|
|
4960
|
+
type,
|
|
4961
|
+
coordinates
|
|
4962
|
+
},
|
|
4963
|
+
properties: rawFeature.tags || {},
|
|
4964
|
+
id: rawFeature.id
|
|
4965
|
+
};
|
|
4966
|
+
features.push(feature);
|
|
4967
|
+
}
|
|
4968
|
+
if (features.length === 0) {
|
|
4969
|
+
return null;
|
|
4970
|
+
}
|
|
4971
|
+
const table = {
|
|
4972
|
+
shape: "geojson-table",
|
|
4973
|
+
type: "FeatureCollection",
|
|
4974
|
+
features
|
|
4975
|
+
};
|
|
4976
|
+
return table;
|
|
4040
4977
|
}
|
|
4041
4978
|
return __toCommonJS(bundle_exports);
|
|
4042
4979
|
})();
|