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