@loaders.gl/mvt 4.0.0-beta.2 → 4.0.0-beta.4
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.min.js → dist.dev.js} +2258 -1731
- package/dist/helpers/binary-util-functions.js.map +1 -0
- package/dist/helpers/mapbox-util-functions.js.map +1 -0
- package/dist/index.cjs +1800 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -0
- package/dist/index.js.map +1 -0
- package/dist/{esm/lib → lib}/binary-vector-tile/vector-tile-feature.js +12 -13
- package/dist/lib/binary-vector-tile/vector-tile-feature.js.map +1 -0
- package/dist/{esm/lib → lib}/binary-vector-tile/vector-tile-layer.js +9 -10
- package/dist/lib/binary-vector-tile/vector-tile-layer.js.map +1 -0
- package/dist/{esm/lib/mapbox-vector-tile → lib/binary-vector-tile}/vector-tile.js +2 -3
- package/dist/lib/binary-vector-tile/vector-tile.js.map +1 -0
- package/dist/{esm/lib → lib}/geojson-tiler/clip.js +4 -5
- package/dist/lib/geojson-tiler/clip.js.map +1 -0
- package/dist/{esm/lib → lib}/geojson-tiler/convert.js +2 -2
- package/dist/lib/geojson-tiler/convert.js.map +1 -0
- package/dist/lib/geojson-tiler/feature.js.map +1 -0
- package/dist/{esm/lib → lib}/geojson-tiler/geojson-tiler.js +11 -12
- package/dist/lib/geojson-tiler/geojson-tiler.js.map +1 -0
- package/dist/lib/geojson-tiler/simplify.js.map +1 -0
- package/dist/lib/geojson-tiler/tile.js.map +1 -0
- package/dist/lib/geojson-tiler/transform.js.map +1 -0
- package/dist/{esm/lib → lib}/geojson-tiler/wrap.js +5 -6
- package/dist/lib/geojson-tiler/wrap.js.map +1 -0
- package/dist/{esm/lib → lib}/mapbox-vector-tile/vector-tile-feature.js +12 -13
- package/dist/lib/mapbox-vector-tile/vector-tile-feature.js.map +1 -0
- package/dist/{esm/lib → lib}/mapbox-vector-tile/vector-tile-layer.js +9 -10
- package/dist/lib/mapbox-vector-tile/vector-tile-layer.js.map +1 -0
- package/dist/{esm/lib/binary-vector-tile → lib/mapbox-vector-tile}/vector-tile.js +2 -3
- package/dist/lib/mapbox-vector-tile/vector-tile.js.map +1 -0
- package/dist/{esm/lib → lib}/parse-mvt.js +2 -2
- package/dist/lib/parse-mvt.js.map +1 -0
- package/dist/lib/parse-tilejson.js.map +1 -0
- package/dist/lib/types.js.map +1 -0
- package/dist/{esm/mvt-loader.js → mvt-loader.js} +2 -2
- package/dist/mvt-loader.js.map +1 -0
- package/dist/mvt-source.d.ts +28 -0
- package/dist/mvt-source.d.ts.map +1 -0
- package/dist/mvt-source.js +100 -0
- package/dist/mvt-source.js.map +1 -0
- package/dist/mvt-worker.js +267 -103
- package/dist/{esm/tilejson-loader.js → tilejson-loader.js} +2 -2
- package/dist/tilejson-loader.js.map +1 -0
- package/dist/{esm/workers → workers}/mvt-worker.js +1 -1
- package/dist/workers/mvt-worker.js.map +1 -0
- package/package.json +19 -10
- package/src/index.ts +2 -0
- package/src/mvt-source.ts +110 -0
- package/dist/bundle.d.ts +0 -2
- package/dist/bundle.d.ts.map +0 -1
- package/dist/es5/bundle.js +0 -6
- package/dist/es5/bundle.js.map +0 -1
- package/dist/es5/helpers/binary-util-functions.js +0 -82
- package/dist/es5/helpers/binary-util-functions.js.map +0 -1
- package/dist/es5/helpers/mapbox-util-functions.js +0 -50
- package/dist/es5/helpers/mapbox-util-functions.js.map +0 -1
- package/dist/es5/index.js +0 -33
- package/dist/es5/index.js.map +0 -1
- package/dist/es5/lib/binary-vector-tile/vector-tile-feature.js +0 -168
- package/dist/es5/lib/binary-vector-tile/vector-tile-feature.js.map +0 -1
- package/dist/es5/lib/binary-vector-tile/vector-tile-layer.js +0 -62
- package/dist/es5/lib/binary-vector-tile/vector-tile-layer.js.map +0 -1
- package/dist/es5/lib/binary-vector-tile/vector-tile.js +0 -28
- package/dist/es5/lib/binary-vector-tile/vector-tile.js.map +0 -1
- package/dist/es5/lib/geojson-tiler/clip.js +0 -237
- package/dist/es5/lib/geojson-tiler/clip.js.map +0 -1
- package/dist/es5/lib/geojson-tiler/convert.js +0 -161
- package/dist/es5/lib/geojson-tiler/convert.js.map +0 -1
- package/dist/es5/lib/geojson-tiler/feature.js +0 -62
- package/dist/es5/lib/geojson-tiler/feature.js.map +0 -1
- package/dist/es5/lib/geojson-tiler/geojson-tiler.js +0 -186
- package/dist/es5/lib/geojson-tiler/geojson-tiler.js.map +0 -1
- package/dist/es5/lib/geojson-tiler/simplify.js +0 -52
- package/dist/es5/lib/geojson-tiler/simplify.js.map +0 -1
- package/dist/es5/lib/geojson-tiler/tile.js +0 -121
- package/dist/es5/lib/geojson-tiler/tile.js.map +0 -1
- package/dist/es5/lib/geojson-tiler/transform.js +0 -50
- package/dist/es5/lib/geojson-tiler/transform.js.map +0 -1
- package/dist/es5/lib/geojson-tiler/wrap.js +0 -122
- package/dist/es5/lib/geojson-tiler/wrap.js.map +0 -1
- package/dist/es5/lib/mapbox-vector-tile/vector-tile-feature.js +0 -184
- package/dist/es5/lib/mapbox-vector-tile/vector-tile-feature.js.map +0 -1
- package/dist/es5/lib/mapbox-vector-tile/vector-tile-layer.js +0 -62
- package/dist/es5/lib/mapbox-vector-tile/vector-tile-layer.js.map +0 -1
- package/dist/es5/lib/mapbox-vector-tile/vector-tile.js +0 -28
- package/dist/es5/lib/mapbox-vector-tile/vector-tile.js.map +0 -1
- package/dist/es5/lib/parse-mvt.js +0 -144
- package/dist/es5/lib/parse-mvt.js.map +0 -1
- package/dist/es5/lib/parse-tilejson.js +0 -186
- package/dist/es5/lib/parse-tilejson.js.map +0 -1
- package/dist/es5/lib/types.js +0 -2
- package/dist/es5/lib/types.js.map +0 -1
- package/dist/es5/mvt-loader.js +0 -57
- package/dist/es5/mvt-loader.js.map +0 -1
- package/dist/es5/tilejson-loader.js +0 -50
- package/dist/es5/tilejson-loader.js.map +0 -1
- package/dist/es5/workers/mvt-worker.js +0 -6
- package/dist/es5/workers/mvt-worker.js.map +0 -1
- package/dist/esm/bundle.js +0 -4
- package/dist/esm/bundle.js.map +0 -1
- package/dist/esm/helpers/binary-util-functions.js.map +0 -1
- package/dist/esm/helpers/mapbox-util-functions.js.map +0 -1
- package/dist/esm/index.js +0 -4
- package/dist/esm/index.js.map +0 -1
- package/dist/esm/lib/binary-vector-tile/LICENSE.txt +0 -31
- package/dist/esm/lib/binary-vector-tile/vector-tile-feature.js.map +0 -1
- package/dist/esm/lib/binary-vector-tile/vector-tile-layer.js.map +0 -1
- package/dist/esm/lib/binary-vector-tile/vector-tile.js.map +0 -1
- package/dist/esm/lib/geojson-tiler/LICENSE +0 -19
- package/dist/esm/lib/geojson-tiler/clip.js.map +0 -1
- package/dist/esm/lib/geojson-tiler/convert.js.map +0 -1
- package/dist/esm/lib/geojson-tiler/feature.js.map +0 -1
- package/dist/esm/lib/geojson-tiler/geojson-tiler.js.map +0 -1
- package/dist/esm/lib/geojson-tiler/simplify.js.map +0 -1
- package/dist/esm/lib/geojson-tiler/tile.js.map +0 -1
- package/dist/esm/lib/geojson-tiler/transform.js.map +0 -1
- package/dist/esm/lib/geojson-tiler/wrap.js.map +0 -1
- package/dist/esm/lib/mapbox-vector-tile/LICENSE.txt +0 -31
- package/dist/esm/lib/mapbox-vector-tile/vector-tile-feature.js.map +0 -1
- package/dist/esm/lib/mapbox-vector-tile/vector-tile-layer.js.map +0 -1
- package/dist/esm/lib/mapbox-vector-tile/vector-tile.js.map +0 -1
- package/dist/esm/lib/parse-mvt.js.map +0 -1
- package/dist/esm/lib/parse-tilejson.js.map +0 -1
- package/dist/esm/lib/types.js.map +0 -1
- package/dist/esm/mvt-loader.js.map +0 -1
- package/dist/esm/tilejson-loader.js.map +0 -1
- package/dist/esm/workers/mvt-worker.js.map +0 -1
- package/src/bundle.ts +0 -4
- /package/dist/{esm/helpers → helpers}/binary-util-functions.js +0 -0
- /package/dist/{esm/helpers → helpers}/mapbox-util-functions.js +0 -0
- /package/dist/{es5/lib → lib}/binary-vector-tile/LICENSE.txt +0 -0
- /package/dist/{es5/lib → lib}/geojson-tiler/LICENSE +0 -0
- /package/dist/{esm/lib → lib}/geojson-tiler/feature.js +0 -0
- /package/dist/{esm/lib → lib}/geojson-tiler/simplify.js +0 -0
- /package/dist/{esm/lib → lib}/geojson-tiler/tile.js +0 -0
- /package/dist/{esm/lib → lib}/geojson-tiler/transform.js +0 -0
- /package/dist/{es5/lib → lib}/mapbox-vector-tile/LICENSE.txt +0 -0
- /package/dist/{esm/lib → lib}/parse-tilejson.js +0 -0
- /package/dist/{esm/lib → lib}/types.js +0 -0
package/dist/mvt-worker.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
(() => {
|
|
2
3
|
var __create = Object.create;
|
|
3
4
|
var __defProp = Object.defineProperty;
|
|
@@ -5,21 +6,25 @@
|
|
|
5
6
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
7
|
var __getProtoOf = Object.getPrototypeOf;
|
|
7
8
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
|
|
9
9
|
var __commonJS = (cb, mod) => function __require() {
|
|
10
|
-
return mod || (0, cb[
|
|
10
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
11
11
|
};
|
|
12
|
-
var
|
|
13
|
-
if (
|
|
14
|
-
for (let key of __getOwnPropNames(
|
|
15
|
-
if (!__hasOwnProp.call(
|
|
16
|
-
__defProp(
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
17
|
}
|
|
18
|
-
return
|
|
19
|
-
};
|
|
20
|
-
var __toModule = (module) => {
|
|
21
|
-
return __reExport(__markAsModule(__defProp(module != null ? __create(__getProtoOf(module)) : {}, "default", module && module.__esModule && "default" in module ? { get: () => module.default, enumerable: true } : { value: module, enumerable: true })), module);
|
|
18
|
+
return to;
|
|
22
19
|
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
23
28
|
|
|
24
29
|
// ../../node_modules/ieee754/index.js
|
|
25
30
|
var require_ieee754 = __commonJS({
|
|
@@ -128,6 +133,7 @@
|
|
|
128
133
|
destroy: function() {
|
|
129
134
|
this.buf = null;
|
|
130
135
|
},
|
|
136
|
+
// === READING =================================================================
|
|
131
137
|
readFields: function(readField, result, end) {
|
|
132
138
|
end = end || this.length;
|
|
133
139
|
while (this.pos < end) {
|
|
@@ -152,6 +158,7 @@
|
|
|
152
158
|
this.pos += 4;
|
|
153
159
|
return val;
|
|
154
160
|
},
|
|
161
|
+
// 64-bit int handling is based on github.com/dpw/node-buffer-more-ints (MIT-licensed)
|
|
155
162
|
readFixed64: function() {
|
|
156
163
|
var val = readUInt32(this.buf, this.pos) + readUInt32(this.buf, this.pos + 4) * SHIFT_LEFT_32;
|
|
157
164
|
this.pos += 8;
|
|
@@ -218,6 +225,7 @@
|
|
|
218
225
|
this.pos = end;
|
|
219
226
|
return buffer;
|
|
220
227
|
},
|
|
228
|
+
// verbose for performance reasons; doesn't affect gzipped size
|
|
221
229
|
readPackedVarint: function(arr, isSigned) {
|
|
222
230
|
if (this.type !== Pbf.Bytes)
|
|
223
231
|
return arr.push(this.readVarint(isSigned));
|
|
@@ -313,6 +321,7 @@
|
|
|
313
321
|
else
|
|
314
322
|
throw new Error("Unimplemented type: " + type);
|
|
315
323
|
},
|
|
324
|
+
// === WRITING =================================================================
|
|
316
325
|
writeTag: function(tag, type) {
|
|
317
326
|
this.writeVarint(tag << 3 | type);
|
|
318
327
|
},
|
|
@@ -757,26 +766,80 @@
|
|
|
757
766
|
}
|
|
758
767
|
});
|
|
759
768
|
|
|
760
|
-
// ../../node_modules/@
|
|
769
|
+
// ../../node_modules/@babel/runtime/helpers/esm/typeof.js
|
|
770
|
+
function _typeof(obj) {
|
|
771
|
+
"@babel/helpers - typeof";
|
|
772
|
+
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(obj2) {
|
|
773
|
+
return typeof obj2;
|
|
774
|
+
} : function(obj2) {
|
|
775
|
+
return obj2 && "function" == typeof Symbol && obj2.constructor === Symbol && obj2 !== Symbol.prototype ? "symbol" : typeof obj2;
|
|
776
|
+
}, _typeof(obj);
|
|
777
|
+
}
|
|
778
|
+
|
|
779
|
+
// ../../node_modules/@babel/runtime/helpers/esm/toPrimitive.js
|
|
780
|
+
function _toPrimitive(input, hint) {
|
|
781
|
+
if (_typeof(input) !== "object" || input === null)
|
|
782
|
+
return input;
|
|
783
|
+
var prim = input[Symbol.toPrimitive];
|
|
784
|
+
if (prim !== void 0) {
|
|
785
|
+
var res = prim.call(input, hint || "default");
|
|
786
|
+
if (_typeof(res) !== "object")
|
|
787
|
+
return res;
|
|
788
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
789
|
+
}
|
|
790
|
+
return (hint === "string" ? String : Number)(input);
|
|
791
|
+
}
|
|
792
|
+
|
|
793
|
+
// ../../node_modules/@babel/runtime/helpers/esm/toPropertyKey.js
|
|
794
|
+
function _toPropertyKey(arg) {
|
|
795
|
+
var key = _toPrimitive(arg, "string");
|
|
796
|
+
return _typeof(key) === "symbol" ? key : String(key);
|
|
797
|
+
}
|
|
798
|
+
|
|
799
|
+
// ../../node_modules/@babel/runtime/helpers/esm/defineProperty.js
|
|
800
|
+
function _defineProperty(obj, key, value) {
|
|
801
|
+
key = _toPropertyKey(key);
|
|
802
|
+
if (key in obj) {
|
|
803
|
+
Object.defineProperty(obj, key, {
|
|
804
|
+
value,
|
|
805
|
+
enumerable: true,
|
|
806
|
+
configurable: true,
|
|
807
|
+
writable: true
|
|
808
|
+
});
|
|
809
|
+
} else {
|
|
810
|
+
obj[key] = value;
|
|
811
|
+
}
|
|
812
|
+
return obj;
|
|
813
|
+
}
|
|
814
|
+
|
|
815
|
+
// ../../node_modules/@math.gl/polygon/dist/polygon-utils.js
|
|
816
|
+
var DimIndex = {
|
|
817
|
+
x: 0,
|
|
818
|
+
y: 1,
|
|
819
|
+
z: 2
|
|
820
|
+
};
|
|
761
821
|
function getPolygonSignedArea(points, options = {}) {
|
|
762
822
|
const {
|
|
763
823
|
start = 0,
|
|
764
|
-
end = points.length
|
|
824
|
+
end = points.length,
|
|
825
|
+
plane = "xy"
|
|
765
826
|
} = options;
|
|
766
827
|
const dim = options.size || 2;
|
|
767
828
|
let area2 = 0;
|
|
829
|
+
const i0 = DimIndex[plane[0]];
|
|
830
|
+
const i1 = DimIndex[plane[1]];
|
|
768
831
|
for (let i2 = start, j = end - dim; i2 < end; i2 += dim) {
|
|
769
|
-
area2 += (points[i2] - points[j]) * (points[i2 +
|
|
832
|
+
area2 += (points[i2 + i0] - points[j + i0]) * (points[i2 + i1] + points[j + i1]);
|
|
770
833
|
j = i2;
|
|
771
834
|
}
|
|
772
835
|
return area2 / 2;
|
|
773
836
|
}
|
|
774
837
|
|
|
775
|
-
// ../../node_modules/@math.gl/polygon/dist/
|
|
776
|
-
function earcut(positions, holeIndices, dim = 2, areas) {
|
|
838
|
+
// ../../node_modules/@math.gl/polygon/dist/earcut.js
|
|
839
|
+
function earcut(positions, holeIndices, dim = 2, areas, plane = "xy") {
|
|
777
840
|
const hasHoles = holeIndices && holeIndices.length;
|
|
778
841
|
const outerLen = hasHoles ? holeIndices[0] * dim : positions.length;
|
|
779
|
-
let outerNode = linkedList(positions, 0, outerLen, dim, true, areas && areas[0]);
|
|
842
|
+
let outerNode = linkedList(positions, 0, outerLen, dim, true, areas && areas[0], plane);
|
|
780
843
|
const triangles = [];
|
|
781
844
|
if (!outerNode || outerNode.next === outerNode.prev)
|
|
782
845
|
return triangles;
|
|
@@ -788,7 +851,7 @@
|
|
|
788
851
|
let x2;
|
|
789
852
|
let y2;
|
|
790
853
|
if (hasHoles)
|
|
791
|
-
outerNode = eliminateHoles(positions, holeIndices, outerNode, dim, areas);
|
|
854
|
+
outerNode = eliminateHoles(positions, holeIndices, outerNode, dim, areas, plane);
|
|
792
855
|
if (positions.length > 80 * dim) {
|
|
793
856
|
minX = maxX = positions[0];
|
|
794
857
|
minY = maxY = positions[1];
|
|
@@ -805,27 +868,30 @@
|
|
|
805
868
|
maxY = y2;
|
|
806
869
|
}
|
|
807
870
|
invSize = Math.max(maxX - minX, maxY - minY);
|
|
808
|
-
invSize = invSize !== 0 ?
|
|
871
|
+
invSize = invSize !== 0 ? 32767 / invSize : 0;
|
|
809
872
|
}
|
|
810
|
-
earcutLinked(outerNode, triangles, dim, minX, minY, invSize);
|
|
873
|
+
earcutLinked(outerNode, triangles, dim, minX, minY, invSize, 0);
|
|
811
874
|
return triangles;
|
|
812
875
|
}
|
|
813
|
-
function linkedList(data, start, end, dim, clockwise, area2) {
|
|
876
|
+
function linkedList(data, start, end, dim, clockwise, area2, plane) {
|
|
814
877
|
let i2;
|
|
815
878
|
let last;
|
|
816
879
|
if (area2 === void 0) {
|
|
817
880
|
area2 = getPolygonSignedArea(data, {
|
|
818
881
|
start,
|
|
819
882
|
end,
|
|
820
|
-
size: dim
|
|
883
|
+
size: dim,
|
|
884
|
+
plane
|
|
821
885
|
});
|
|
822
886
|
}
|
|
887
|
+
let i0 = DimIndex[plane[0]];
|
|
888
|
+
let i1 = DimIndex[plane[1]];
|
|
823
889
|
if (clockwise === area2 < 0) {
|
|
824
890
|
for (i2 = start; i2 < end; i2 += dim)
|
|
825
|
-
last = insertNode(i2, data[i2], data[i2 +
|
|
891
|
+
last = insertNode(i2, data[i2 + i0], data[i2 + i1], last);
|
|
826
892
|
} else {
|
|
827
893
|
for (i2 = end - dim; i2 >= start; i2 -= dim)
|
|
828
|
-
last = insertNode(i2, data[i2], data[i2 +
|
|
894
|
+
last = insertNode(i2, data[i2 + i0], data[i2 + i1], last);
|
|
829
895
|
}
|
|
830
896
|
if (last && equals(last, last.next)) {
|
|
831
897
|
removeNode(last);
|
|
@@ -866,9 +932,9 @@
|
|
|
866
932
|
prev = ear.prev;
|
|
867
933
|
next = ear.next;
|
|
868
934
|
if (invSize ? isEarHashed(ear, minX, minY, invSize) : isEar(ear)) {
|
|
869
|
-
triangles.push(prev.i / dim);
|
|
870
|
-
triangles.push(ear.i / dim);
|
|
871
|
-
triangles.push(next.i / dim);
|
|
935
|
+
triangles.push(prev.i / dim | 0);
|
|
936
|
+
triangles.push(ear.i / dim | 0);
|
|
937
|
+
triangles.push(next.i / dim | 0);
|
|
872
938
|
removeNode(ear);
|
|
873
939
|
ear = next.next;
|
|
874
940
|
stop = next.next;
|
|
@@ -894,9 +960,19 @@
|
|
|
894
960
|
const c = ear.next;
|
|
895
961
|
if (area(a, b, c) >= 0)
|
|
896
962
|
return false;
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
963
|
+
const ax = a.x;
|
|
964
|
+
const bx = b.x;
|
|
965
|
+
const cx = c.x;
|
|
966
|
+
const ay = a.y;
|
|
967
|
+
const by = b.y;
|
|
968
|
+
const cy = c.y;
|
|
969
|
+
const x0 = ax < bx ? ax < cx ? ax : cx : bx < cx ? bx : cx;
|
|
970
|
+
const y0 = ay < by ? ay < cy ? ay : cy : by < cy ? by : cy;
|
|
971
|
+
const x1 = ax > bx ? ax > cx ? ax : cx : bx > cx ? bx : cx;
|
|
972
|
+
const y1 = ay > by ? ay > cy ? ay : cy : by > cy ? by : cy;
|
|
973
|
+
let p = c.next;
|
|
974
|
+
while (p !== a) {
|
|
975
|
+
if (p.x >= x0 && p.x <= x1 && p.y >= y0 && p.y <= y1 && pointInTriangle(ax, ay, bx, by, cx, cy, p.x, p.y) && area(p.prev, p, p.next) >= 0)
|
|
900
976
|
return false;
|
|
901
977
|
p = p.next;
|
|
902
978
|
}
|
|
@@ -908,29 +984,35 @@
|
|
|
908
984
|
const c = ear.next;
|
|
909
985
|
if (area(a, b, c) >= 0)
|
|
910
986
|
return false;
|
|
911
|
-
const
|
|
912
|
-
const
|
|
913
|
-
const
|
|
914
|
-
const
|
|
915
|
-
const
|
|
916
|
-
const
|
|
987
|
+
const ax = a.x;
|
|
988
|
+
const bx = b.x;
|
|
989
|
+
const cx = c.x;
|
|
990
|
+
const ay = a.y;
|
|
991
|
+
const by = b.y;
|
|
992
|
+
const cy = c.y;
|
|
993
|
+
const x0 = ax < bx ? ax < cx ? ax : cx : bx < cx ? bx : cx;
|
|
994
|
+
const y0 = ay < by ? ay < cy ? ay : cy : by < cy ? by : cy;
|
|
995
|
+
const x1 = ax > bx ? ax > cx ? ax : cx : bx > cx ? bx : cx;
|
|
996
|
+
const y1 = ay > by ? ay > cy ? ay : cy : by > cy ? by : cy;
|
|
997
|
+
const minZ = zOrder(x0, y0, minX, minY, invSize);
|
|
998
|
+
const maxZ = zOrder(x1, y1, minX, minY, invSize);
|
|
917
999
|
let p = ear.prevZ;
|
|
918
1000
|
let n = ear.nextZ;
|
|
919
1001
|
while (p && p.z >= minZ && n && n.z <= maxZ) {
|
|
920
|
-
if (p
|
|
1002
|
+
if (p.x >= x0 && p.x <= x1 && p.y >= y0 && p.y <= y1 && p !== a && p !== c && pointInTriangle(ax, ay, bx, by, cx, cy, p.x, p.y) && area(p.prev, p, p.next) >= 0)
|
|
921
1003
|
return false;
|
|
922
1004
|
p = p.prevZ;
|
|
923
|
-
if (n
|
|
1005
|
+
if (n.x >= x0 && n.x <= x1 && n.y >= y0 && n.y <= y1 && n !== a && n !== c && pointInTriangle(ax, ay, bx, by, cx, cy, n.x, n.y) && area(n.prev, n, n.next) >= 0)
|
|
924
1006
|
return false;
|
|
925
1007
|
n = n.nextZ;
|
|
926
1008
|
}
|
|
927
1009
|
while (p && p.z >= minZ) {
|
|
928
|
-
if (p
|
|
1010
|
+
if (p.x >= x0 && p.x <= x1 && p.y >= y0 && p.y <= y1 && p !== a && p !== c && pointInTriangle(ax, ay, bx, by, cx, cy, p.x, p.y) && area(p.prev, p, p.next) >= 0)
|
|
929
1011
|
return false;
|
|
930
1012
|
p = p.prevZ;
|
|
931
1013
|
}
|
|
932
1014
|
while (n && n.z <= maxZ) {
|
|
933
|
-
if (n
|
|
1015
|
+
if (n.x >= x0 && n.x <= x1 && n.y >= y0 && n.y <= y1 && n !== a && n !== c && pointInTriangle(ax, ay, bx, by, cx, cy, n.x, n.y) && area(n.prev, n, n.next) >= 0)
|
|
934
1016
|
return false;
|
|
935
1017
|
n = n.nextZ;
|
|
936
1018
|
}
|
|
@@ -942,9 +1024,9 @@
|
|
|
942
1024
|
const a = p.prev;
|
|
943
1025
|
const b = p.next.next;
|
|
944
1026
|
if (!equals(a, b) && intersects(a, p, p.next, b) && locallyInside(a, b) && locallyInside(b, a)) {
|
|
945
|
-
triangles.push(a.i / dim);
|
|
946
|
-
triangles.push(p.i / dim);
|
|
947
|
-
triangles.push(b.i / dim);
|
|
1027
|
+
triangles.push(a.i / dim | 0);
|
|
1028
|
+
triangles.push(p.i / dim | 0);
|
|
1029
|
+
triangles.push(b.i / dim | 0);
|
|
948
1030
|
removeNode(p);
|
|
949
1031
|
removeNode(p.next);
|
|
950
1032
|
p = start = b;
|
|
@@ -962,8 +1044,8 @@
|
|
|
962
1044
|
let c = splitPolygon(a, b);
|
|
963
1045
|
a = filterPoints(a, a.next);
|
|
964
1046
|
c = filterPoints(c, c.next);
|
|
965
|
-
earcutLinked(a, triangles, dim, minX, minY, invSize);
|
|
966
|
-
earcutLinked(c, triangles, dim, minX, minY, invSize);
|
|
1047
|
+
earcutLinked(a, triangles, dim, minX, minY, invSize, 0);
|
|
1048
|
+
earcutLinked(c, triangles, dim, minX, minY, invSize, 0);
|
|
967
1049
|
return;
|
|
968
1050
|
}
|
|
969
1051
|
b = b.next;
|
|
@@ -971,7 +1053,7 @@
|
|
|
971
1053
|
a = a.next;
|
|
972
1054
|
} while (a !== start);
|
|
973
1055
|
}
|
|
974
|
-
function eliminateHoles(data, holeIndices, outerNode, dim, areas) {
|
|
1056
|
+
function eliminateHoles(data, holeIndices, outerNode, dim, areas, plane) {
|
|
975
1057
|
const queue = [];
|
|
976
1058
|
let i2;
|
|
977
1059
|
let len;
|
|
@@ -981,15 +1063,14 @@
|
|
|
981
1063
|
for (i2 = 0, len = holeIndices.length; i2 < len; i2++) {
|
|
982
1064
|
start = holeIndices[i2] * dim;
|
|
983
1065
|
end = i2 < len - 1 ? holeIndices[i2 + 1] * dim : data.length;
|
|
984
|
-
list = linkedList(data, start, end, dim, false, areas && areas[i2 + 1]);
|
|
1066
|
+
list = linkedList(data, start, end, dim, false, areas && areas[i2 + 1], plane);
|
|
985
1067
|
if (list === list.next)
|
|
986
1068
|
list.steiner = true;
|
|
987
1069
|
queue.push(getLeftmost(list));
|
|
988
1070
|
}
|
|
989
1071
|
queue.sort(compareX);
|
|
990
1072
|
for (i2 = 0; i2 < queue.length; i2++) {
|
|
991
|
-
eliminateHole(queue[i2], outerNode);
|
|
992
|
-
outerNode = filterPoints(outerNode, outerNode.next);
|
|
1073
|
+
outerNode = eliminateHole(queue[i2], outerNode);
|
|
993
1074
|
}
|
|
994
1075
|
return outerNode;
|
|
995
1076
|
}
|
|
@@ -997,12 +1078,13 @@
|
|
|
997
1078
|
return a.x - b.x;
|
|
998
1079
|
}
|
|
999
1080
|
function eliminateHole(hole, outerNode) {
|
|
1000
|
-
|
|
1001
|
-
if (
|
|
1002
|
-
|
|
1003
|
-
filterPoints(outerNode, outerNode.next);
|
|
1004
|
-
filterPoints(b, b.next);
|
|
1081
|
+
const bridge = findHoleBridge(hole, outerNode);
|
|
1082
|
+
if (!bridge) {
|
|
1083
|
+
return outerNode;
|
|
1005
1084
|
}
|
|
1085
|
+
const bridgeReverse = splitPolygon(bridge, hole);
|
|
1086
|
+
filterPoints(bridgeReverse, bridgeReverse.next);
|
|
1087
|
+
return filterPoints(bridge, bridge.next);
|
|
1006
1088
|
}
|
|
1007
1089
|
function findHoleBridge(hole, outerNode) {
|
|
1008
1090
|
let p = outerNode;
|
|
@@ -1015,21 +1097,15 @@
|
|
|
1015
1097
|
const x2 = p.x + (hy - p.y) * (p.next.x - p.x) / (p.next.y - p.y);
|
|
1016
1098
|
if (x2 <= hx && x2 > qx) {
|
|
1017
1099
|
qx = x2;
|
|
1018
|
-
if (x2 === hx) {
|
|
1019
|
-
if (hy === p.y)
|
|
1020
|
-
return p;
|
|
1021
|
-
if (hy === p.next.y)
|
|
1022
|
-
return p.next;
|
|
1023
|
-
}
|
|
1024
1100
|
m = p.x < p.next.x ? p : p.next;
|
|
1101
|
+
if (x2 === hx)
|
|
1102
|
+
return m;
|
|
1025
1103
|
}
|
|
1026
1104
|
}
|
|
1027
1105
|
p = p.next;
|
|
1028
1106
|
} while (p !== outerNode);
|
|
1029
1107
|
if (!m)
|
|
1030
1108
|
return null;
|
|
1031
|
-
if (hx === qx)
|
|
1032
|
-
return m;
|
|
1033
1109
|
const stop = m;
|
|
1034
1110
|
const mx = m.x;
|
|
1035
1111
|
const my = m.y;
|
|
@@ -1054,7 +1130,7 @@
|
|
|
1054
1130
|
function indexCurve(start, minX, minY, invSize) {
|
|
1055
1131
|
let p = start;
|
|
1056
1132
|
do {
|
|
1057
|
-
if (p.z ===
|
|
1133
|
+
if (p.z === 0)
|
|
1058
1134
|
p.z = zOrder(p.x, p.y, minX, minY, invSize);
|
|
1059
1135
|
p.prevZ = p.prev;
|
|
1060
1136
|
p.nextZ = p.next;
|
|
@@ -1115,8 +1191,8 @@
|
|
|
1115
1191
|
return list;
|
|
1116
1192
|
}
|
|
1117
1193
|
function zOrder(x2, y2, minX, minY, invSize) {
|
|
1118
|
-
x2 =
|
|
1119
|
-
y2 =
|
|
1194
|
+
x2 = (x2 - minX) * invSize | 0;
|
|
1195
|
+
y2 = (y2 - minY) * invSize | 0;
|
|
1120
1196
|
x2 = (x2 | x2 << 8) & 16711935;
|
|
1121
1197
|
x2 = (x2 | x2 << 4) & 252645135;
|
|
1122
1198
|
x2 = (x2 | x2 << 2) & 858993459;
|
|
@@ -1138,7 +1214,7 @@
|
|
|
1138
1214
|
return leftmost;
|
|
1139
1215
|
}
|
|
1140
1216
|
function pointInTriangle(ax, ay, bx, by, cx, cy, px, py) {
|
|
1141
|
-
return (cx - px) * (ay - py)
|
|
1217
|
+
return (cx - px) * (ay - py) >= (ax - px) * (cy - py) && (ax - px) * (by - py) >= (bx - px) * (ay - py) && (bx - px) * (cy - py) >= (cx - px) * (by - py);
|
|
1142
1218
|
}
|
|
1143
1219
|
function isValidDiagonal(a, b) {
|
|
1144
1220
|
return a.next.i !== b.i && a.prev.i !== b.i && !intersectsPolygon(a, b) && (locallyInside(a, b) && locallyInside(b, a) && middleInside(a, b) && (area(a.prev, a, b.prev) || area(a, b.prev, b)) || equals(a, b) && area(a.prev, a, a.next) > 0 && area(b.prev, b, b.next) > 0);
|
|
@@ -1197,8 +1273,8 @@
|
|
|
1197
1273
|
return inside;
|
|
1198
1274
|
}
|
|
1199
1275
|
function splitPolygon(a, b) {
|
|
1200
|
-
const a2 = new
|
|
1201
|
-
const b2 = new
|
|
1276
|
+
const a2 = new Vertex(a.i, a.x, a.y);
|
|
1277
|
+
const b2 = new Vertex(b.i, b.x, b.y);
|
|
1202
1278
|
const an = a.next;
|
|
1203
1279
|
const bp = b.prev;
|
|
1204
1280
|
a.next = b;
|
|
@@ -1212,7 +1288,7 @@
|
|
|
1212
1288
|
return b2;
|
|
1213
1289
|
}
|
|
1214
1290
|
function insertNode(i2, x2, y2, last) {
|
|
1215
|
-
const p = new
|
|
1291
|
+
const p = new Vertex(i2, x2, y2);
|
|
1216
1292
|
if (!last) {
|
|
1217
1293
|
p.prev = p;
|
|
1218
1294
|
p.next = p;
|
|
@@ -1232,30 +1308,39 @@
|
|
|
1232
1308
|
if (p.nextZ)
|
|
1233
1309
|
p.nextZ.prevZ = p.prevZ;
|
|
1234
1310
|
}
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1311
|
+
var Vertex = class {
|
|
1312
|
+
constructor(i2, x2, y2) {
|
|
1313
|
+
_defineProperty(this, "i", void 0);
|
|
1314
|
+
_defineProperty(this, "x", void 0);
|
|
1315
|
+
_defineProperty(this, "y", void 0);
|
|
1316
|
+
_defineProperty(this, "prev", null);
|
|
1317
|
+
_defineProperty(this, "next", null);
|
|
1318
|
+
_defineProperty(this, "z", 0);
|
|
1319
|
+
_defineProperty(this, "prevZ", null);
|
|
1320
|
+
_defineProperty(this, "nextZ", null);
|
|
1321
|
+
_defineProperty(this, "steiner", false);
|
|
1322
|
+
this.i = i2;
|
|
1323
|
+
this.x = x2;
|
|
1324
|
+
this.y = y2;
|
|
1325
|
+
}
|
|
1326
|
+
};
|
|
1246
1327
|
|
|
1247
1328
|
// ../gis/src/lib/flat-geojson-to-binary.ts
|
|
1248
1329
|
function flatGeojsonToBinary(features, geometryInfo, options) {
|
|
1249
1330
|
const propArrayTypes = extractNumericPropTypes(features);
|
|
1250
1331
|
const numericPropKeys = Object.keys(propArrayTypes).filter((k) => propArrayTypes[k] !== Array);
|
|
1251
|
-
return fillArrays(
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1332
|
+
return fillArrays(
|
|
1333
|
+
features,
|
|
1334
|
+
{
|
|
1335
|
+
propArrayTypes,
|
|
1336
|
+
...geometryInfo
|
|
1337
|
+
},
|
|
1338
|
+
{
|
|
1339
|
+
numericPropKeys: options && options.numericPropKeys || numericPropKeys,
|
|
1340
|
+
PositionDataType: options ? options.PositionDataType : Float32Array,
|
|
1341
|
+
triangulate: options ? options.triangulate : true
|
|
1342
|
+
}
|
|
1343
|
+
);
|
|
1259
1344
|
}
|
|
1260
1345
|
function extractNumericPropTypes(features) {
|
|
1261
1346
|
const propArrayTypes = {};
|
|
@@ -1379,16 +1464,32 @@
|
|
|
1379
1464
|
points.positions.set(geometry.data, indexMap.pointPosition * coordLength);
|
|
1380
1465
|
const nPositions = geometry.data.length / coordLength;
|
|
1381
1466
|
fillNumericProperties(points, properties, indexMap.pointPosition, nPositions);
|
|
1382
|
-
points.globalFeatureIds.fill(
|
|
1383
|
-
|
|
1467
|
+
points.globalFeatureIds.fill(
|
|
1468
|
+
indexMap.feature,
|
|
1469
|
+
indexMap.pointPosition,
|
|
1470
|
+
indexMap.pointPosition + nPositions
|
|
1471
|
+
);
|
|
1472
|
+
points.featureIds.fill(
|
|
1473
|
+
indexMap.pointFeature,
|
|
1474
|
+
indexMap.pointPosition,
|
|
1475
|
+
indexMap.pointPosition + nPositions
|
|
1476
|
+
);
|
|
1384
1477
|
indexMap.pointPosition += nPositions;
|
|
1385
1478
|
}
|
|
1386
1479
|
function handleLineString(geometry, lines, indexMap, coordLength, properties) {
|
|
1387
1480
|
lines.positions.set(geometry.data, indexMap.linePosition * coordLength);
|
|
1388
1481
|
const nPositions = geometry.data.length / coordLength;
|
|
1389
1482
|
fillNumericProperties(lines, properties, indexMap.linePosition, nPositions);
|
|
1390
|
-
lines.globalFeatureIds.fill(
|
|
1391
|
-
|
|
1483
|
+
lines.globalFeatureIds.fill(
|
|
1484
|
+
indexMap.feature,
|
|
1485
|
+
indexMap.linePosition,
|
|
1486
|
+
indexMap.linePosition + nPositions
|
|
1487
|
+
);
|
|
1488
|
+
lines.featureIds.fill(
|
|
1489
|
+
indexMap.lineFeature,
|
|
1490
|
+
indexMap.linePosition,
|
|
1491
|
+
indexMap.linePosition + nPositions
|
|
1492
|
+
);
|
|
1392
1493
|
for (let i2 = 0, il = geometry.indices.length; i2 < il; ++i2) {
|
|
1393
1494
|
const start = geometry.indices[i2];
|
|
1394
1495
|
const end = i2 === il - 1 ? geometry.data.length : geometry.indices[i2 + 1];
|
|
@@ -1400,8 +1501,16 @@
|
|
|
1400
1501
|
polygons.positions.set(geometry.data, indexMap.polygonPosition * coordLength);
|
|
1401
1502
|
const nPositions = geometry.data.length / coordLength;
|
|
1402
1503
|
fillNumericProperties(polygons, properties, indexMap.polygonPosition, nPositions);
|
|
1403
|
-
polygons.globalFeatureIds.fill(
|
|
1404
|
-
|
|
1504
|
+
polygons.globalFeatureIds.fill(
|
|
1505
|
+
indexMap.feature,
|
|
1506
|
+
indexMap.polygonPosition,
|
|
1507
|
+
indexMap.polygonPosition + nPositions
|
|
1508
|
+
);
|
|
1509
|
+
polygons.featureIds.fill(
|
|
1510
|
+
indexMap.polygonFeature,
|
|
1511
|
+
indexMap.polygonPosition,
|
|
1512
|
+
indexMap.polygonPosition + nPositions
|
|
1513
|
+
);
|
|
1405
1514
|
for (let l = 0, ll = geometry.indices.length; l < ll; ++l) {
|
|
1406
1515
|
const startPosition = indexMap.polygonPosition;
|
|
1407
1516
|
polygons.polygonIndices[indexMap.polygonObject++] = startPosition;
|
|
@@ -1410,7 +1519,10 @@
|
|
|
1410
1519
|
const nextIndices = geometry.indices[l + 1];
|
|
1411
1520
|
for (let i2 = 0, il = indices.length; i2 < il; ++i2) {
|
|
1412
1521
|
const start = indices[i2];
|
|
1413
|
-
const end = i2 === il - 1 ?
|
|
1522
|
+
const end = i2 === il - 1 ? (
|
|
1523
|
+
// last line, so either read to:
|
|
1524
|
+
nextIndices === void 0 ? geometry.data.length : nextIndices[0]
|
|
1525
|
+
) : indices[i2 + 1];
|
|
1414
1526
|
polygons.primitivePolygonIndices[indexMap.polygonRing++] = indexMap.polygonPosition;
|
|
1415
1527
|
indexMap.polygonPosition += (end - start) / coordLength;
|
|
1416
1528
|
}
|
|
@@ -1469,6 +1581,7 @@
|
|
|
1469
1581
|
featureIds: { value: polygons.featureIds, size: 1 },
|
|
1470
1582
|
numericProps: wrapProps(polygons.numericProps, 1)
|
|
1471
1583
|
}
|
|
1584
|
+
// triangles not expected
|
|
1472
1585
|
};
|
|
1473
1586
|
if (binaryFeatures.polygons && polygons.triangles) {
|
|
1474
1587
|
binaryFeatures.polygons.triangles = { value: new Uint32Array(polygons.triangles), size: 1 };
|
|
@@ -1500,7 +1613,7 @@
|
|
|
1500
1613
|
}
|
|
1501
1614
|
|
|
1502
1615
|
// src/lib/parse-mvt.ts
|
|
1503
|
-
var import_pbf =
|
|
1616
|
+
var import_pbf = __toESM(require_pbf(), 1);
|
|
1504
1617
|
|
|
1505
1618
|
// src/helpers/mapbox-util-functions.ts
|
|
1506
1619
|
function classifyRings(rings) {
|
|
@@ -1573,6 +1686,7 @@
|
|
|
1573
1686
|
this._values = values;
|
|
1574
1687
|
pbf.readFields(readFeature, this, end);
|
|
1575
1688
|
}
|
|
1689
|
+
// eslint-disable-next-line complexity, max-statements
|
|
1576
1690
|
loadGeometry() {
|
|
1577
1691
|
const pbf = this._pbf;
|
|
1578
1692
|
pbf.pos = this._geometry;
|
|
@@ -1612,6 +1726,7 @@
|
|
|
1612
1726
|
lines.push(line);
|
|
1613
1727
|
return lines;
|
|
1614
1728
|
}
|
|
1729
|
+
// eslint-disable-next-line max-statements
|
|
1615
1730
|
bbox() {
|
|
1616
1731
|
const pbf = this._pbf;
|
|
1617
1732
|
pbf.pos = this._geometry;
|
|
@@ -1728,6 +1843,11 @@
|
|
|
1728
1843
|
pbf.readFields(readLayer, this, end);
|
|
1729
1844
|
this.length = this._features.length;
|
|
1730
1845
|
}
|
|
1846
|
+
/**
|
|
1847
|
+
* return feature `i` from this layer as a `VectorTileFeature`
|
|
1848
|
+
* @param index
|
|
1849
|
+
* @returns feature
|
|
1850
|
+
*/
|
|
1731
1851
|
feature(i2) {
|
|
1732
1852
|
if (i2 < 0 || i2 >= this._features.length) {
|
|
1733
1853
|
throw new Error("feature index out of bounds");
|
|
@@ -1867,6 +1987,7 @@
|
|
|
1867
1987
|
var y;
|
|
1868
1988
|
var i;
|
|
1869
1989
|
var VectorTileFeature2 = class {
|
|
1990
|
+
// eslint-disable-next-line max-params
|
|
1870
1991
|
constructor(pbf, end, extent, keys, values, geometryInfo) {
|
|
1871
1992
|
this.properties = {};
|
|
1872
1993
|
this.extent = extent;
|
|
@@ -1879,6 +2000,7 @@
|
|
|
1879
2000
|
this._geometryInfo = geometryInfo;
|
|
1880
2001
|
pbf.readFields(readFeature2, this, end);
|
|
1881
2002
|
}
|
|
2003
|
+
// eslint-disable-next-line complexity, max-statements
|
|
1882
2004
|
loadGeometry() {
|
|
1883
2005
|
const pbf = this._pbf;
|
|
1884
2006
|
pbf.pos = this._geometry;
|
|
@@ -1917,6 +2039,11 @@
|
|
|
1917
2039
|
}
|
|
1918
2040
|
return { data, indices };
|
|
1919
2041
|
}
|
|
2042
|
+
/**
|
|
2043
|
+
*
|
|
2044
|
+
* @param transform
|
|
2045
|
+
* @returns result
|
|
2046
|
+
*/
|
|
1920
2047
|
_toBinaryCoordinates(transform) {
|
|
1921
2048
|
const geom = this.loadGeometry();
|
|
1922
2049
|
let geometry;
|
|
@@ -1978,13 +2105,27 @@
|
|
|
1978
2105
|
pbf.readFields(readLayer2, this, end);
|
|
1979
2106
|
this.length = this._features.length;
|
|
1980
2107
|
}
|
|
2108
|
+
/**
|
|
2109
|
+
* return feature `i` from this layer as a `VectorTileFeature`
|
|
2110
|
+
*
|
|
2111
|
+
* @param index
|
|
2112
|
+
* @param geometryInfo
|
|
2113
|
+
* @returns {VectorTileFeature}
|
|
2114
|
+
*/
|
|
1981
2115
|
feature(i2, geometryInfo) {
|
|
1982
2116
|
if (i2 < 0 || i2 >= this._features.length) {
|
|
1983
2117
|
throw new Error("feature index out of bounds");
|
|
1984
2118
|
}
|
|
1985
2119
|
this._pbf.pos = this._features[i2];
|
|
1986
2120
|
const end = this._pbf.readVarint() + this._pbf.pos;
|
|
1987
|
-
return new VectorTileFeature2(
|
|
2121
|
+
return new VectorTileFeature2(
|
|
2122
|
+
this._pbf,
|
|
2123
|
+
end,
|
|
2124
|
+
this.extent,
|
|
2125
|
+
this._keys,
|
|
2126
|
+
this._values,
|
|
2127
|
+
geometryInfo
|
|
2128
|
+
);
|
|
1988
2129
|
}
|
|
1989
2130
|
};
|
|
1990
2131
|
function readLayer2(tag, layer, pbf) {
|
|
@@ -2126,14 +2267,20 @@
|
|
|
2126
2267
|
return options.mvt;
|
|
2127
2268
|
}
|
|
2128
2269
|
function getDecodedFeature(feature, options, layerName) {
|
|
2129
|
-
const decodedFeature = feature.toGeoJSON(
|
|
2270
|
+
const decodedFeature = feature.toGeoJSON(
|
|
2271
|
+
// @ts-expect-error What is going on here?
|
|
2272
|
+
options.coordinates === "wgs84" ? options.tileIndex : transformToLocalCoordinates
|
|
2273
|
+
);
|
|
2130
2274
|
if (options.layerProperty) {
|
|
2131
2275
|
decodedFeature.properties[options.layerProperty] = layerName;
|
|
2132
2276
|
}
|
|
2133
2277
|
return decodedFeature;
|
|
2134
2278
|
}
|
|
2135
2279
|
function getDecodedFeatureBinary(feature, options, layerName) {
|
|
2136
|
-
const decodedFeature = feature.toBinaryCoordinates(
|
|
2280
|
+
const decodedFeature = feature.toBinaryCoordinates(
|
|
2281
|
+
// @ts-expect-error What is going on here?
|
|
2282
|
+
options.coordinates === "wgs84" ? options.tileIndex : transformToLocalCoordinatesBinary
|
|
2283
|
+
);
|
|
2137
2284
|
if (options.layerProperty && decodedFeature.properties) {
|
|
2138
2285
|
decodedFeature.properties[options.layerProperty] = layerName;
|
|
2139
2286
|
}
|
|
@@ -2155,16 +2302,19 @@
|
|
|
2155
2302
|
}
|
|
2156
2303
|
|
|
2157
2304
|
// src/mvt-loader.ts
|
|
2158
|
-
var VERSION = true ? "4.0.0-beta.
|
|
2305
|
+
var VERSION = true ? "4.0.0-beta.4" : "latest";
|
|
2159
2306
|
var MVTWorkerLoader = {
|
|
2160
2307
|
name: "Mapbox Vector Tile",
|
|
2161
2308
|
id: "mvt",
|
|
2162
2309
|
module: "mvt",
|
|
2163
2310
|
version: VERSION,
|
|
2311
|
+
// Note: ArcGIS uses '.pbf' extension and 'application/octet-stream'
|
|
2164
2312
|
extensions: ["mvt", "pbf"],
|
|
2165
2313
|
mimeTypes: [
|
|
2314
|
+
// https://www.iana.org/assignments/media-types/application/vnd.mapbox-vector-tile
|
|
2166
2315
|
"application/vnd.mapbox-vector-tile",
|
|
2167
2316
|
"application/x-protobuf"
|
|
2317
|
+
// 'application/octet-stream'
|
|
2168
2318
|
],
|
|
2169
2319
|
worker: true,
|
|
2170
2320
|
category: "geometry",
|
|
@@ -2187,7 +2337,7 @@
|
|
|
2187
2337
|
|
|
2188
2338
|
// ../worker-utils/src/lib/worker-utils/get-transfer-list.ts
|
|
2189
2339
|
function getTransferList(object, recursive = true, transfers) {
|
|
2190
|
-
const transfersSet = transfers || new Set();
|
|
2340
|
+
const transfersSet = transfers || /* @__PURE__ */ new Set();
|
|
2191
2341
|
if (!object) {
|
|
2192
2342
|
} else if (isTransferable(object)) {
|
|
2193
2343
|
transfersSet.add(object);
|
|
@@ -2230,11 +2380,15 @@
|
|
|
2230
2380
|
}
|
|
2231
2381
|
return parentPort;
|
|
2232
2382
|
}
|
|
2233
|
-
var onMessageWrapperMap = new Map();
|
|
2383
|
+
var onMessageWrapperMap = /* @__PURE__ */ new Map();
|
|
2234
2384
|
var WorkerBody = class {
|
|
2385
|
+
/** Check that we are actually in a worker thread */
|
|
2235
2386
|
static inWorkerThread() {
|
|
2236
2387
|
return typeof self !== "undefined" || Boolean(getParentPort());
|
|
2237
2388
|
}
|
|
2389
|
+
/*
|
|
2390
|
+
* (type: WorkerMessageType, payload: WorkerMessagePayload) => any
|
|
2391
|
+
*/
|
|
2238
2392
|
static set onmessage(onMessage) {
|
|
2239
2393
|
function handleMessage(message) {
|
|
2240
2394
|
const parentPort3 = getParentPort();
|
|
@@ -2278,6 +2432,11 @@
|
|
|
2278
2432
|
globalThis.removeEventListener("message", onMessageWrapper);
|
|
2279
2433
|
}
|
|
2280
2434
|
}
|
|
2435
|
+
/**
|
|
2436
|
+
* Send a message from a worker to creating thread (main thread)
|
|
2437
|
+
* @param type
|
|
2438
|
+
* @param payload
|
|
2439
|
+
*/
|
|
2281
2440
|
static postMessage(type, payload) {
|
|
2282
2441
|
const data = { source: "loaders.gl", type, payload };
|
|
2283
2442
|
const transferList = getTransferList(payload);
|
|
@@ -2309,6 +2468,7 @@
|
|
|
2309
2468
|
loader,
|
|
2310
2469
|
arrayBuffer: input,
|
|
2311
2470
|
options,
|
|
2471
|
+
// @ts-expect-error fetch missing
|
|
2312
2472
|
context: {
|
|
2313
2473
|
...context,
|
|
2314
2474
|
_parse: parseOnMainThread
|
|
@@ -2377,4 +2537,8 @@
|
|
|
2377
2537
|
// src/workers/mvt-worker.ts
|
|
2378
2538
|
createLoaderWorker(MVTLoader);
|
|
2379
2539
|
})();
|
|
2380
|
-
/*!
|
|
2540
|
+
/*! Bundled license information:
|
|
2541
|
+
|
|
2542
|
+
ieee754/index.js:
|
|
2543
|
+
(*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> *)
|
|
2544
|
+
*/
|