@tileflow/core 0.1.0-alpha.21 → 0.1.0-alpha.22
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/README.md +197 -72
- package/THIRD_PARTY_NOTICES.md +60 -2
- package/dist/browser.d.ts +82 -16
- package/dist/browser.js +1234 -267
- package/dist/build.d.ts +19 -56
- package/dist/build.js +10915 -8333
- package/dist/config-reference.json +31882 -0
- package/dist/index.d.ts +476 -13
- package/dist/index.js +12409 -8832
- package/dist/{types-DlUGI6LC.d.ts → manifest-B5GKVMFE.d.ts} +252 -20
- package/dist/manifest.d.ts +1 -2
- package/dist/manifest.js +18 -2
- package/dist/map-BHL_0Mkx.d.ts +1145 -0
- package/dist/runtime.d.ts +1 -2
- package/dist/runtime.js +60 -5
- package/package.json +5 -8
- package/dist/domains-CPSrdTik.d.ts +0 -4
- package/dist/recipe.d.ts +0 -66
- package/dist/recipe.js +0 -577
- package/dist/requirements-BV77ZVhR.d.ts +0 -491
- package/dist/runtime-C4MtSzkB.d.ts +0 -223
- package/dist/visual-semantics-DTC-8Hsb.d.ts +0 -479
package/dist/browser.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
var __defProp = Object.defineProperty;
|
|
2
2
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
3
|
-
var __esm = (fn, res,
|
|
4
|
-
if (
|
|
3
|
+
var __esm = (fn, res, err2) => function __init() {
|
|
4
|
+
if (err2) throw err2[0];
|
|
5
5
|
try {
|
|
6
6
|
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
7
7
|
} catch (e) {
|
|
8
|
-
throw
|
|
8
|
+
throw err2 = [e], e;
|
|
9
9
|
}
|
|
10
10
|
};
|
|
11
11
|
var __export = (target, all) => {
|
|
@@ -34,7 +34,7 @@ var dist_exports = {};
|
|
|
34
34
|
__export(dist_exports, {
|
|
35
35
|
default: () => mlcontour$1
|
|
36
36
|
});
|
|
37
|
-
function define(
|
|
37
|
+
function define(_2, chunk) {
|
|
38
38
|
if (!shared) {
|
|
39
39
|
shared = chunk;
|
|
40
40
|
} else if (!worker) {
|
|
@@ -65,11 +65,11 @@ var init_dist = __esm({
|
|
|
65
65
|
this.append = this.append.bind(this);
|
|
66
66
|
this.prepend = this.prepend.bind(this);
|
|
67
67
|
}
|
|
68
|
-
append(
|
|
69
|
-
this.points.push(Math.round(
|
|
68
|
+
append(x3, y) {
|
|
69
|
+
this.points.push(Math.round(x3), Math.round(y));
|
|
70
70
|
}
|
|
71
|
-
prepend(
|
|
72
|
-
this.points.splice(0, 0, Math.round(
|
|
71
|
+
prepend(x3, y) {
|
|
72
|
+
this.points.splice(0, 0, Math.round(x3), Math.round(y));
|
|
73
73
|
}
|
|
74
74
|
lineString() {
|
|
75
75
|
return this.toArray();
|
|
@@ -181,13 +181,13 @@ var init_dist = __esm({
|
|
|
181
181
|
],
|
|
182
182
|
[]
|
|
183
183
|
];
|
|
184
|
-
function index(width,
|
|
185
|
-
|
|
184
|
+
function index(width, x3, y, point) {
|
|
185
|
+
x3 = x3 * 2 + point[0];
|
|
186
186
|
y = y * 2 + point[1];
|
|
187
|
-
return
|
|
187
|
+
return x3 + y * (width + 1) * 2;
|
|
188
188
|
}
|
|
189
|
-
function ratio(a,
|
|
190
|
-
return (
|
|
189
|
+
function ratio(a, b2, c) {
|
|
190
|
+
return (b2 - a) / (c - a);
|
|
191
191
|
}
|
|
192
192
|
function generateIsolines(interval, tile, extent = 4096, buffer = 1) {
|
|
193
193
|
if (!interval) {
|
|
@@ -228,9 +228,9 @@ var init_dist = __esm({
|
|
|
228
228
|
continue;
|
|
229
229
|
}
|
|
230
230
|
const min = Math.min(minL, minR);
|
|
231
|
-
const
|
|
231
|
+
const max2 = Math.max(maxL, maxR);
|
|
232
232
|
const start = Math.ceil(min / interval) * interval;
|
|
233
|
-
const end = Math.floor(
|
|
233
|
+
const end = Math.floor(max2 / interval) * interval;
|
|
234
234
|
for (let threshold = start; threshold <= end; threshold += interval) {
|
|
235
235
|
const tl = tld > threshold;
|
|
236
236
|
const tr = trd > threshold;
|
|
@@ -247,12 +247,12 @@ var init_dist = __esm({
|
|
|
247
247
|
const end2 = segment[1];
|
|
248
248
|
const startIndex = index(tile.width, c, r, start2);
|
|
249
249
|
const endIndex = index(tile.width, c, r, end2);
|
|
250
|
-
let f,
|
|
250
|
+
let f, g2;
|
|
251
251
|
if (f = fragmentByEnd.get(startIndex)) {
|
|
252
252
|
fragmentByEnd.delete(startIndex);
|
|
253
|
-
if (
|
|
253
|
+
if (g2 = fragmentByStart.get(endIndex)) {
|
|
254
254
|
fragmentByStart.delete(endIndex);
|
|
255
|
-
if (f ===
|
|
255
|
+
if (f === g2) {
|
|
256
256
|
interpolate(end2, threshold, f.append);
|
|
257
257
|
if (!f.isEmpty()) {
|
|
258
258
|
let list = segments[threshold];
|
|
@@ -262,8 +262,8 @@ var init_dist = __esm({
|
|
|
262
262
|
list.push(f.lineString());
|
|
263
263
|
}
|
|
264
264
|
} else {
|
|
265
|
-
f.appendFragment(
|
|
266
|
-
fragmentByEnd.set(f.end =
|
|
265
|
+
f.appendFragment(g2);
|
|
266
|
+
fragmentByEnd.set(f.end = g2.end, f);
|
|
267
267
|
}
|
|
268
268
|
} else {
|
|
269
269
|
interpolate(end2, threshold, f.append);
|
|
@@ -302,19 +302,19 @@ var init_dist = __esm({
|
|
|
302
302
|
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
303
303
|
t[p] = s[p];
|
|
304
304
|
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
305
|
-
for (var
|
|
306
|
-
if (e.indexOf(p[
|
|
307
|
-
t[p[
|
|
305
|
+
for (var i2 = 0, p = Object.getOwnPropertySymbols(s); i2 < p.length; i2++) {
|
|
306
|
+
if (e.indexOf(p[i2]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i2]))
|
|
307
|
+
t[p[i2]] = s[p[i2]];
|
|
308
308
|
}
|
|
309
309
|
return t;
|
|
310
310
|
}
|
|
311
|
-
function __awaiter(thisArg, _arguments,
|
|
311
|
+
function __awaiter(thisArg, _arguments, P2, generator) {
|
|
312
312
|
function adopt(value) {
|
|
313
|
-
return value instanceof
|
|
313
|
+
return value instanceof P2 ? value : new P2(function(resolve) {
|
|
314
314
|
resolve(value);
|
|
315
315
|
});
|
|
316
316
|
}
|
|
317
|
-
return new (
|
|
317
|
+
return new (P2 || (P2 = Promise))(function(resolve, reject) {
|
|
318
318
|
function fulfilled(value) {
|
|
319
319
|
try {
|
|
320
320
|
step(generator.next(value));
|
|
@@ -337,7 +337,7 @@ var init_dist = __esm({
|
|
|
337
337
|
}
|
|
338
338
|
function sortedEntries(object) {
|
|
339
339
|
const entries = Object.entries(object);
|
|
340
|
-
entries.sort(([a], [
|
|
340
|
+
entries.sort(([a], [b2]) => a < b2 ? -1 : a > b2 ? 1 : 0);
|
|
341
341
|
return entries;
|
|
342
342
|
}
|
|
343
343
|
function encodeThresholds(thresholds) {
|
|
@@ -346,30 +346,30 @@ var init_dist = __esm({
|
|
|
346
346
|
function decodeThresholds(thresholds) {
|
|
347
347
|
return Object.fromEntries(thresholds.split("~").map((part) => part.split("*").map(Number)).map(([key, ...values]) => [key, values]));
|
|
348
348
|
}
|
|
349
|
-
function encodeOptions(
|
|
350
|
-
var { thresholds } =
|
|
349
|
+
function encodeOptions(_a2) {
|
|
350
|
+
var { thresholds } = _a2, rest = __rest(_a2, ["thresholds"]);
|
|
351
351
|
return sortedEntries(Object.assign({ thresholds: encodeThresholds(thresholds) }, rest)).map(([key, value]) => `${encodeURIComponent(key)}=${encodeURIComponent(value)}`).join("&");
|
|
352
352
|
}
|
|
353
353
|
function decodeOptions(options) {
|
|
354
354
|
return Object.fromEntries(options.replace(/^.*\?/, "").split("&").map((part) => {
|
|
355
355
|
const parts = part.split("=").map(decodeURIComponent);
|
|
356
|
-
const
|
|
357
|
-
let
|
|
358
|
-
switch (
|
|
356
|
+
const k2 = parts[0];
|
|
357
|
+
let v2 = parts[1];
|
|
358
|
+
switch (k2) {
|
|
359
359
|
case "thresholds":
|
|
360
|
-
|
|
360
|
+
v2 = decodeThresholds(v2);
|
|
361
361
|
break;
|
|
362
362
|
case "extent":
|
|
363
363
|
case "multiplier":
|
|
364
364
|
case "overzoom":
|
|
365
365
|
case "buffer":
|
|
366
|
-
|
|
366
|
+
v2 = Number(v2);
|
|
367
367
|
}
|
|
368
|
-
return [
|
|
368
|
+
return [k2, v2];
|
|
369
369
|
}));
|
|
370
370
|
}
|
|
371
371
|
function encodeIndividualOptions(options) {
|
|
372
|
-
return sortedEntries(options).map(([
|
|
372
|
+
return sortedEntries(options).map(([k2, v2]) => `${encodeURIComponent(k2)}=${encodeURIComponent(v2)}`).join(",");
|
|
373
373
|
}
|
|
374
374
|
function getOptionsForZoom(options, zoom) {
|
|
375
375
|
const { thresholds } = options, rest = __rest(options, ["thresholds"]);
|
|
@@ -390,8 +390,8 @@ var init_dist = __esm({
|
|
|
390
390
|
return dst;
|
|
391
391
|
}
|
|
392
392
|
function prepareDemTile(promise, copy2) {
|
|
393
|
-
return promise.then((
|
|
394
|
-
var { data } =
|
|
393
|
+
return promise.then((_a2) => {
|
|
394
|
+
var { data } = _a2, rest = __rest(_a2, ["data"]);
|
|
395
395
|
let newData = data;
|
|
396
396
|
if (copy2) {
|
|
397
397
|
newData = new Float32Array(data.length);
|
|
@@ -425,14 +425,14 @@ var init_dist = __esm({
|
|
|
425
425
|
const canvas2 = new OffscreenCanvas(5, 5);
|
|
426
426
|
const context = canvas2.getContext("2d", { willReadFrequently: true });
|
|
427
427
|
if (context) {
|
|
428
|
-
for (let
|
|
429
|
-
const base =
|
|
428
|
+
for (let i2 = 0; i2 < size * size; i2++) {
|
|
429
|
+
const base = i2 * 4;
|
|
430
430
|
context.fillStyle = `rgb(${base},${base + 1},${base + 2})`;
|
|
431
|
-
context.fillRect(
|
|
431
|
+
context.fillRect(i2 % size, Math.floor(i2 / size), 1, 1);
|
|
432
432
|
}
|
|
433
433
|
const data = context.getImageData(0, 0, size, size).data;
|
|
434
|
-
for (let
|
|
435
|
-
if (
|
|
434
|
+
for (let i2 = 0; i2 < size * size * 4; i2++) {
|
|
435
|
+
if (i2 % 4 !== 3 && data[i2] !== i2) {
|
|
436
436
|
useVideoFrame = true;
|
|
437
437
|
break;
|
|
438
438
|
}
|
|
@@ -453,7 +453,7 @@ var init_dist = __esm({
|
|
|
453
453
|
reject(new Error("aborted"));
|
|
454
454
|
clearTimeout(timeout);
|
|
455
455
|
});
|
|
456
|
-
const cancelPromise = new Promise((
|
|
456
|
+
const cancelPromise = new Promise((_2, rej) => {
|
|
457
457
|
reject = rej;
|
|
458
458
|
});
|
|
459
459
|
return Promise.race([
|
|
@@ -467,8 +467,8 @@ var init_dist = __esm({
|
|
|
467
467
|
}
|
|
468
468
|
}
|
|
469
469
|
function isAborted(abortController) {
|
|
470
|
-
var
|
|
471
|
-
return Boolean((
|
|
470
|
+
var _a2;
|
|
471
|
+
return Boolean((_a2 = abortController === null || abortController === void 0 ? void 0 : abortController.signal) === null || _a2 === void 0 ? void 0 : _a2.aborted);
|
|
472
472
|
}
|
|
473
473
|
let num = 0;
|
|
474
474
|
class AsyncCache {
|
|
@@ -498,11 +498,11 @@ var init_dist = __esm({
|
|
|
498
498
|
});
|
|
499
499
|
let canceled = false;
|
|
500
500
|
onAbort(abortController, () => {
|
|
501
|
-
var
|
|
501
|
+
var _a2;
|
|
502
502
|
if (result && result.abortController && !canceled) {
|
|
503
503
|
canceled = true;
|
|
504
504
|
if (--result.waiting <= 0) {
|
|
505
|
-
(
|
|
505
|
+
(_a2 = result.abortController) === null || _a2 === void 0 ? void 0 : _a2.abort();
|
|
506
506
|
items.delete(key);
|
|
507
507
|
}
|
|
508
508
|
}
|
|
@@ -552,13 +552,13 @@ var init_dist = __esm({
|
|
|
552
552
|
}
|
|
553
553
|
function decodeImageVideoFrame(blob, encoding, abortController) {
|
|
554
554
|
return __awaiter(this, void 0, void 0, function* () {
|
|
555
|
-
var
|
|
555
|
+
var _a2, _b2, _c;
|
|
556
556
|
const img = yield createImageBitmap(blob);
|
|
557
557
|
if (isAborted(abortController))
|
|
558
558
|
return null;
|
|
559
559
|
const vf = new VideoFrame(img, { timestamp: 0 });
|
|
560
560
|
try {
|
|
561
|
-
const valid = ((
|
|
561
|
+
const valid = ((_a2 = vf === null || vf === void 0 ? void 0 : vf.format) === null || _a2 === void 0 ? void 0 : _a2.startsWith("BGR")) || ((_b2 = vf === null || vf === void 0 ? void 0 : vf.format) === null || _b2 === void 0 ? void 0 : _b2.startsWith("RGB"));
|
|
562
562
|
if (!valid) {
|
|
563
563
|
throw new Error(`Unrecognized format: ${vf === null || vf === void 0 ? void 0 : vf.format}`);
|
|
564
564
|
}
|
|
@@ -567,14 +567,14 @@ var init_dist = __esm({
|
|
|
567
567
|
const data = new Uint8ClampedArray(size);
|
|
568
568
|
yield vf.copyTo(data);
|
|
569
569
|
if (swapBR) {
|
|
570
|
-
for (let
|
|
571
|
-
const tmp = data[
|
|
572
|
-
data[
|
|
573
|
-
data[
|
|
570
|
+
for (let i2 = 0; i2 < data.length; i2 += 4) {
|
|
571
|
+
const tmp = data[i2];
|
|
572
|
+
data[i2] = data[i2 + 2];
|
|
573
|
+
data[i2 + 2] = tmp;
|
|
574
574
|
}
|
|
575
575
|
}
|
|
576
576
|
return decodeParsedImage(img.width, img.height, encoding, data);
|
|
577
|
-
} catch (
|
|
577
|
+
} catch (_2) {
|
|
578
578
|
if (isAborted(abortController))
|
|
579
579
|
return null;
|
|
580
580
|
return decodeImageUsingOffscreenCanvas(img, encoding);
|
|
@@ -627,10 +627,10 @@ var init_dist = __esm({
|
|
|
627
627
|
return decodeParsedImage(img.width, img.height, encoding, rgba);
|
|
628
628
|
}
|
|
629
629
|
function decodeParsedImage(width, height, encoding, input) {
|
|
630
|
-
const decoder = encoding === "mapbox" ? (r,
|
|
630
|
+
const decoder = encoding === "mapbox" ? (r, g2, b2) => -1e4 + (r * 256 * 256 + g2 * 256 + b2) * 0.1 : (r, g2, b2) => r * 256 + g2 + b2 / 256 - 32768;
|
|
631
631
|
const data = new Float32Array(width * height);
|
|
632
|
-
for (let
|
|
633
|
-
data[
|
|
632
|
+
for (let i2 = 0; i2 < input.length; i2 += 4) {
|
|
633
|
+
data[i2 / 4] = decoder(input[i2], input[i2 + 1], input[i2 + 2]);
|
|
634
634
|
}
|
|
635
635
|
return { width, height, data };
|
|
636
636
|
}
|
|
@@ -647,53 +647,53 @@ var init_dist = __esm({
|
|
|
647
647
|
const by = 1 << subz;
|
|
648
648
|
const dx = subx * this.width / by;
|
|
649
649
|
const dy = suby * this.height / by;
|
|
650
|
-
return new HeightTile(this.width / by, this.height / by, (
|
|
650
|
+
return new HeightTile(this.width / by, this.height / by, (x3, y) => this.get(x3 + dx, y + dy));
|
|
651
651
|
};
|
|
652
652
|
this.subsamplePixelCenters = (factor) => {
|
|
653
|
-
const lerp = (a,
|
|
653
|
+
const lerp = (a, b2, f) => isNaN(a) ? b2 : isNaN(b2) ? a : a + (b2 - a) * f;
|
|
654
654
|
if (factor <= 1)
|
|
655
655
|
return this;
|
|
656
656
|
const sub = 0.5 - 1 / (2 * factor);
|
|
657
|
-
const blerper = (
|
|
658
|
-
const dx =
|
|
657
|
+
const blerper = (x3, y) => {
|
|
658
|
+
const dx = x3 / factor - sub;
|
|
659
659
|
const dy = y / factor - sub;
|
|
660
660
|
const ox = Math.floor(dx);
|
|
661
661
|
const oy = Math.floor(dy);
|
|
662
662
|
const a = this.get(ox, oy);
|
|
663
|
-
const
|
|
663
|
+
const b2 = this.get(ox + 1, oy);
|
|
664
664
|
const c = this.get(ox, oy + 1);
|
|
665
665
|
const d = this.get(ox + 1, oy + 1);
|
|
666
666
|
const fx = dx - ox;
|
|
667
667
|
const fy = dy - oy;
|
|
668
|
-
const top = lerp(a,
|
|
668
|
+
const top = lerp(a, b2, fx);
|
|
669
669
|
const bottom = lerp(c, d, fx);
|
|
670
670
|
return lerp(top, bottom, fy);
|
|
671
671
|
};
|
|
672
672
|
return new HeightTile(this.width * factor, this.height * factor, blerper);
|
|
673
673
|
};
|
|
674
|
-
this.averagePixelCentersToGrid = (radius = 1) => new HeightTile(this.width + 1, this.height + 1, (
|
|
675
|
-
let sum = 0, count = 0,
|
|
676
|
-
for (let newX =
|
|
674
|
+
this.averagePixelCentersToGrid = (radius = 1) => new HeightTile(this.width + 1, this.height + 1, (x3, y) => {
|
|
675
|
+
let sum = 0, count = 0, v2 = 0;
|
|
676
|
+
for (let newX = x3 - radius; newX < x3 + radius; newX++) {
|
|
677
677
|
for (let newY = y - radius; newY < y + radius; newY++) {
|
|
678
|
-
if (!isNaN(
|
|
678
|
+
if (!isNaN(v2 = this.get(newX, newY))) {
|
|
679
679
|
count++;
|
|
680
|
-
sum +=
|
|
680
|
+
sum += v2;
|
|
681
681
|
}
|
|
682
682
|
}
|
|
683
683
|
}
|
|
684
684
|
return count === 0 ? NaN : sum / count;
|
|
685
685
|
});
|
|
686
|
-
this.scaleElevation = (multiplier) => multiplier === 1 ? this : new HeightTile(this.width, this.height, (
|
|
686
|
+
this.scaleElevation = (multiplier) => multiplier === 1 ? this : new HeightTile(this.width, this.height, (x3, y) => this.get(x3, y) * multiplier);
|
|
687
687
|
this.materialize = (buffer = 2) => {
|
|
688
688
|
const stride = this.width + 2 * buffer;
|
|
689
689
|
const data = new Float32Array(stride * (this.height + 2 * buffer));
|
|
690
690
|
let idx = 0;
|
|
691
691
|
for (let y = -buffer; y < this.height + buffer; y++) {
|
|
692
|
-
for (let
|
|
693
|
-
data[idx++] = this.get(
|
|
692
|
+
for (let x3 = -buffer; x3 < this.width + buffer; x3++) {
|
|
693
|
+
data[idx++] = this.get(x3, y);
|
|
694
694
|
}
|
|
695
695
|
}
|
|
696
|
-
return new HeightTile(this.width, this.height, (
|
|
696
|
+
return new HeightTile(this.width, this.height, (x3, y) => data[(y + buffer) * stride + x3 + buffer]);
|
|
697
697
|
};
|
|
698
698
|
this.get = get;
|
|
699
699
|
this.width = width;
|
|
@@ -701,8 +701,8 @@ var init_dist = __esm({
|
|
|
701
701
|
}
|
|
702
702
|
/** Construct a height tile from raw DEM pixel values */
|
|
703
703
|
static fromRawDem(demTile) {
|
|
704
|
-
return new HeightTile(demTile.width, demTile.height, (
|
|
705
|
-
const value = demTile.data[y * demTile.width +
|
|
704
|
+
return new HeightTile(demTile.width, demTile.height, (x3, y) => {
|
|
705
|
+
const value = demTile.data[y * demTile.width + x3];
|
|
706
706
|
return defaultIsValid(value) ? value : NaN;
|
|
707
707
|
});
|
|
708
708
|
}
|
|
@@ -722,7 +722,7 @@ var init_dist = __esm({
|
|
|
722
722
|
}
|
|
723
723
|
const width = mainTile.width;
|
|
724
724
|
const height = mainTile.height;
|
|
725
|
-
return new HeightTile(width, height, (
|
|
725
|
+
return new HeightTile(width, height, (x3, y) => {
|
|
726
726
|
let gridIdx = 0;
|
|
727
727
|
if (y < 0) {
|
|
728
728
|
y += height;
|
|
@@ -732,16 +732,16 @@ var init_dist = __esm({
|
|
|
732
732
|
y -= height;
|
|
733
733
|
gridIdx += 6;
|
|
734
734
|
}
|
|
735
|
-
if (
|
|
736
|
-
|
|
737
|
-
} else if (
|
|
735
|
+
if (x3 < 0) {
|
|
736
|
+
x3 += width;
|
|
737
|
+
} else if (x3 < width) {
|
|
738
738
|
gridIdx += 1;
|
|
739
739
|
} else {
|
|
740
|
-
|
|
740
|
+
x3 -= width;
|
|
741
741
|
gridIdx += 2;
|
|
742
742
|
}
|
|
743
743
|
const grid = neighbors[gridIdx];
|
|
744
|
-
return grid ? grid.get(
|
|
744
|
+
return grid ? grid.get(x3, y) : NaN;
|
|
745
745
|
});
|
|
746
746
|
}
|
|
747
747
|
}
|
|
@@ -824,21 +824,21 @@ var init_dist = __esm({
|
|
|
824
824
|
*/
|
|
825
825
|
readVarint(isSigned) {
|
|
826
826
|
const buf = this.buf;
|
|
827
|
-
let val,
|
|
828
|
-
|
|
829
|
-
val =
|
|
830
|
-
if (
|
|
831
|
-
|
|
832
|
-
val |= (
|
|
833
|
-
if (
|
|
834
|
-
|
|
835
|
-
val |= (
|
|
836
|
-
if (
|
|
837
|
-
|
|
838
|
-
val |= (
|
|
839
|
-
if (
|
|
840
|
-
|
|
841
|
-
val |= (
|
|
827
|
+
let val, b2;
|
|
828
|
+
b2 = buf[this.pos++];
|
|
829
|
+
val = b2 & 127;
|
|
830
|
+
if (b2 < 128) return val;
|
|
831
|
+
b2 = buf[this.pos++];
|
|
832
|
+
val |= (b2 & 127) << 7;
|
|
833
|
+
if (b2 < 128) return val;
|
|
834
|
+
b2 = buf[this.pos++];
|
|
835
|
+
val |= (b2 & 127) << 14;
|
|
836
|
+
if (b2 < 128) return val;
|
|
837
|
+
b2 = buf[this.pos++];
|
|
838
|
+
val |= (b2 & 127) << 21;
|
|
839
|
+
if (b2 < 128) return val;
|
|
840
|
+
b2 = buf[this.pos];
|
|
841
|
+
val |= (b2 & 15) << 28;
|
|
842
842
|
return readVarintRemainder(val, isSigned, this);
|
|
843
843
|
}
|
|
844
844
|
readVarint64() {
|
|
@@ -1041,7 +1041,7 @@ var init_dist = __esm({
|
|
|
1041
1041
|
const len = buffer.length;
|
|
1042
1042
|
this.writeVarint(len);
|
|
1043
1043
|
this.realloc(len);
|
|
1044
|
-
for (let
|
|
1044
|
+
for (let i2 = 0; i2 < len; i2++) this.buf[this.pos++] = buffer[i2];
|
|
1045
1045
|
}
|
|
1046
1046
|
/**
|
|
1047
1047
|
* @template T
|
|
@@ -1219,27 +1219,27 @@ var init_dist = __esm({
|
|
|
1219
1219
|
this.writeVarintField(tag, +val);
|
|
1220
1220
|
}
|
|
1221
1221
|
}
|
|
1222
|
-
function readVarintRemainder(
|
|
1222
|
+
function readVarintRemainder(l2, s, p) {
|
|
1223
1223
|
const buf = p.buf;
|
|
1224
|
-
let h,
|
|
1225
|
-
|
|
1226
|
-
h = (
|
|
1227
|
-
if (
|
|
1228
|
-
|
|
1229
|
-
h |= (
|
|
1230
|
-
if (
|
|
1231
|
-
|
|
1232
|
-
h |= (
|
|
1233
|
-
if (
|
|
1234
|
-
|
|
1235
|
-
h |= (
|
|
1236
|
-
if (
|
|
1237
|
-
|
|
1238
|
-
h |= (
|
|
1239
|
-
if (
|
|
1240
|
-
|
|
1241
|
-
h |= (
|
|
1242
|
-
if (
|
|
1224
|
+
let h, b2;
|
|
1225
|
+
b2 = buf[p.pos++];
|
|
1226
|
+
h = (b2 & 112) >> 4;
|
|
1227
|
+
if (b2 < 128) return toNum(l2, h, s);
|
|
1228
|
+
b2 = buf[p.pos++];
|
|
1229
|
+
h |= (b2 & 127) << 3;
|
|
1230
|
+
if (b2 < 128) return toNum(l2, h, s);
|
|
1231
|
+
b2 = buf[p.pos++];
|
|
1232
|
+
h |= (b2 & 127) << 10;
|
|
1233
|
+
if (b2 < 128) return toNum(l2, h, s);
|
|
1234
|
+
b2 = buf[p.pos++];
|
|
1235
|
+
h |= (b2 & 127) << 17;
|
|
1236
|
+
if (b2 < 128) return toNum(l2, h, s);
|
|
1237
|
+
b2 = buf[p.pos++];
|
|
1238
|
+
h |= (b2 & 127) << 24;
|
|
1239
|
+
if (b2 < 128) return toNum(l2, h, s);
|
|
1240
|
+
b2 = buf[p.pos++];
|
|
1241
|
+
h |= (b2 & 1) << 31;
|
|
1242
|
+
if (b2 < 128) return toNum(l2, h, s);
|
|
1243
1243
|
throw new Error("Expected varint not more than 10 bytes");
|
|
1244
1244
|
}
|
|
1245
1245
|
function toNum(low, high, isSigned) {
|
|
@@ -1295,50 +1295,50 @@ var init_dist = __esm({
|
|
|
1295
1295
|
function makeRoomForExtraLength(startPos, len, pbf) {
|
|
1296
1296
|
const extraLen = len <= 16383 ? 1 : len <= 2097151 ? 2 : len <= 268435455 ? 3 : Math.floor(Math.log(len) / (Math.LN2 * 7));
|
|
1297
1297
|
pbf.realloc(extraLen);
|
|
1298
|
-
for (let
|
|
1298
|
+
for (let i2 = pbf.pos - 1; i2 >= startPos; i2--) pbf.buf[i2 + extraLen] = pbf.buf[i2];
|
|
1299
1299
|
}
|
|
1300
1300
|
function writePackedVarint(arr, pbf) {
|
|
1301
|
-
for (let
|
|
1301
|
+
for (let i2 = 0; i2 < arr.length; i2++) pbf.writeVarint(arr[i2]);
|
|
1302
1302
|
}
|
|
1303
1303
|
function writePackedSVarint(arr, pbf) {
|
|
1304
|
-
for (let
|
|
1304
|
+
for (let i2 = 0; i2 < arr.length; i2++) pbf.writeSVarint(arr[i2]);
|
|
1305
1305
|
}
|
|
1306
1306
|
function writePackedFloat(arr, pbf) {
|
|
1307
|
-
for (let
|
|
1307
|
+
for (let i2 = 0; i2 < arr.length; i2++) pbf.writeFloat(arr[i2]);
|
|
1308
1308
|
}
|
|
1309
1309
|
function writePackedDouble(arr, pbf) {
|
|
1310
|
-
for (let
|
|
1310
|
+
for (let i2 = 0; i2 < arr.length; i2++) pbf.writeDouble(arr[i2]);
|
|
1311
1311
|
}
|
|
1312
1312
|
function writePackedBoolean(arr, pbf) {
|
|
1313
|
-
for (let
|
|
1313
|
+
for (let i2 = 0; i2 < arr.length; i2++) pbf.writeBoolean(arr[i2]);
|
|
1314
1314
|
}
|
|
1315
1315
|
function writePackedFixed32(arr, pbf) {
|
|
1316
|
-
for (let
|
|
1316
|
+
for (let i2 = 0; i2 < arr.length; i2++) pbf.writeFixed32(arr[i2]);
|
|
1317
1317
|
}
|
|
1318
1318
|
function writePackedSFixed32(arr, pbf) {
|
|
1319
|
-
for (let
|
|
1319
|
+
for (let i2 = 0; i2 < arr.length; i2++) pbf.writeSFixed32(arr[i2]);
|
|
1320
1320
|
}
|
|
1321
1321
|
function writePackedFixed64(arr, pbf) {
|
|
1322
|
-
for (let
|
|
1322
|
+
for (let i2 = 0; i2 < arr.length; i2++) pbf.writeFixed64(arr[i2]);
|
|
1323
1323
|
}
|
|
1324
1324
|
function writePackedSFixed64(arr, pbf) {
|
|
1325
|
-
for (let
|
|
1325
|
+
for (let i2 = 0; i2 < arr.length; i2++) pbf.writeSFixed64(arr[i2]);
|
|
1326
1326
|
}
|
|
1327
1327
|
function readUtf8(buf, pos, end) {
|
|
1328
1328
|
let str = "";
|
|
1329
|
-
let
|
|
1330
|
-
while (
|
|
1331
|
-
const b0 = buf[
|
|
1329
|
+
let i2 = pos;
|
|
1330
|
+
while (i2 < end) {
|
|
1331
|
+
const b0 = buf[i2];
|
|
1332
1332
|
let c = null;
|
|
1333
1333
|
let bytesPerSequence = b0 > 239 ? 4 : b0 > 223 ? 3 : b0 > 191 ? 2 : 1;
|
|
1334
|
-
if (
|
|
1334
|
+
if (i2 + bytesPerSequence > end) break;
|
|
1335
1335
|
let b1, b2, b3;
|
|
1336
1336
|
if (bytesPerSequence === 1) {
|
|
1337
1337
|
if (b0 < 128) {
|
|
1338
1338
|
c = b0;
|
|
1339
1339
|
}
|
|
1340
1340
|
} else if (bytesPerSequence === 2) {
|
|
1341
|
-
b1 = buf[
|
|
1341
|
+
b1 = buf[i2 + 1];
|
|
1342
1342
|
if ((b1 & 192) === 128) {
|
|
1343
1343
|
c = (b0 & 31) << 6 | b1 & 63;
|
|
1344
1344
|
if (c <= 127) {
|
|
@@ -1346,8 +1346,8 @@ var init_dist = __esm({
|
|
|
1346
1346
|
}
|
|
1347
1347
|
}
|
|
1348
1348
|
} else if (bytesPerSequence === 3) {
|
|
1349
|
-
b1 = buf[
|
|
1350
|
-
b2 = buf[
|
|
1349
|
+
b1 = buf[i2 + 1];
|
|
1350
|
+
b2 = buf[i2 + 2];
|
|
1351
1351
|
if ((b1 & 192) === 128 && (b2 & 192) === 128) {
|
|
1352
1352
|
c = (b0 & 15) << 12 | (b1 & 63) << 6 | b2 & 63;
|
|
1353
1353
|
if (c <= 2047 || c >= 55296 && c <= 57343) {
|
|
@@ -1355,9 +1355,9 @@ var init_dist = __esm({
|
|
|
1355
1355
|
}
|
|
1356
1356
|
}
|
|
1357
1357
|
} else if (bytesPerSequence === 4) {
|
|
1358
|
-
b1 = buf[
|
|
1359
|
-
b2 = buf[
|
|
1360
|
-
b3 = buf[
|
|
1358
|
+
b1 = buf[i2 + 1];
|
|
1359
|
+
b2 = buf[i2 + 2];
|
|
1360
|
+
b3 = buf[i2 + 3];
|
|
1361
1361
|
if ((b1 & 192) === 128 && (b2 & 192) === 128 && (b3 & 192) === 128) {
|
|
1362
1362
|
c = (b0 & 15) << 18 | (b1 & 63) << 12 | (b2 & 63) << 6 | b3 & 63;
|
|
1363
1363
|
if (c <= 65535 || c >= 1114112) {
|
|
@@ -1374,13 +1374,13 @@ var init_dist = __esm({
|
|
|
1374
1374
|
c = 56320 | c & 1023;
|
|
1375
1375
|
}
|
|
1376
1376
|
str += String.fromCharCode(c);
|
|
1377
|
-
|
|
1377
|
+
i2 += bytesPerSequence;
|
|
1378
1378
|
}
|
|
1379
1379
|
return str;
|
|
1380
1380
|
}
|
|
1381
1381
|
function writeUtf8(buf, str, pos) {
|
|
1382
|
-
for (let
|
|
1383
|
-
c = str.charCodeAt(
|
|
1382
|
+
for (let i2 = 0, c, lead; i2 < str.length; i2++) {
|
|
1383
|
+
c = str.charCodeAt(i2);
|
|
1384
1384
|
if (c > 55295 && c < 57344) {
|
|
1385
1385
|
if (lead) {
|
|
1386
1386
|
if (c < 56320) {
|
|
@@ -1394,7 +1394,7 @@ var init_dist = __esm({
|
|
|
1394
1394
|
lead = null;
|
|
1395
1395
|
}
|
|
1396
1396
|
} else {
|
|
1397
|
-
if (c > 56319 ||
|
|
1397
|
+
if (c > 56319 || i2 + 1 === str.length) {
|
|
1398
1398
|
buf[pos++] = 239;
|
|
1399
1399
|
buf[pos++] = 191;
|
|
1400
1400
|
buf[pos++] = 189;
|
|
@@ -1521,7 +1521,7 @@ var init_dist = __esm({
|
|
|
1521
1521
|
throw new Error();
|
|
1522
1522
|
const geometry = feature.geometry;
|
|
1523
1523
|
const type = feature.type;
|
|
1524
|
-
let
|
|
1524
|
+
let x3 = 0;
|
|
1525
1525
|
let y = 0;
|
|
1526
1526
|
for (const ring of geometry) {
|
|
1527
1527
|
let count = 1;
|
|
@@ -1531,15 +1531,15 @@ var init_dist = __esm({
|
|
|
1531
1531
|
pbf.writeVarint(command(1, count));
|
|
1532
1532
|
const length = ring.length / 2;
|
|
1533
1533
|
const lineCount = type === GeomType.POLYGON ? length - 1 : length;
|
|
1534
|
-
for (let
|
|
1535
|
-
if (
|
|
1534
|
+
for (let i2 = 0; i2 < lineCount; i2++) {
|
|
1535
|
+
if (i2 === 1 && type !== 1) {
|
|
1536
1536
|
pbf.writeVarint(command(2, lineCount - 1));
|
|
1537
1537
|
}
|
|
1538
|
-
const dx = ring[
|
|
1539
|
-
const dy = ring[
|
|
1538
|
+
const dx = ring[i2 * 2] - x3;
|
|
1539
|
+
const dy = ring[i2 * 2 + 1] - y;
|
|
1540
1540
|
pbf.writeVarint(zigzag(dx));
|
|
1541
1541
|
pbf.writeVarint(zigzag(dy));
|
|
1542
|
-
|
|
1542
|
+
x3 += dx;
|
|
1543
1543
|
y += dy;
|
|
1544
1544
|
}
|
|
1545
1545
|
if (type === GeomType.POLYGON) {
|
|
@@ -1567,8 +1567,8 @@ var init_dist = __esm({
|
|
|
1567
1567
|
const perf = typeof performance !== "undefined" ? performance : void 0;
|
|
1568
1568
|
const timeOrigin = perf ? perf.timeOrigin || (/* @__PURE__ */ new Date()).getTime() - perf.now() : (/* @__PURE__ */ new Date()).getTime();
|
|
1569
1569
|
function getResourceTiming(url) {
|
|
1570
|
-
var
|
|
1571
|
-
return JSON.parse(JSON.stringify(((
|
|
1570
|
+
var _a2;
|
|
1571
|
+
return JSON.parse(JSON.stringify(((_a2 = perf === null || perf === void 0 ? void 0 : perf.getEntriesByName) === null || _a2 === void 0 ? void 0 : _a2.call(perf, url)) || []));
|
|
1572
1572
|
}
|
|
1573
1573
|
function now() {
|
|
1574
1574
|
return perf ? perf.now() : (/* @__PURE__ */ new Date()).getTime();
|
|
@@ -1592,9 +1592,9 @@ var init_dist = __esm({
|
|
|
1592
1592
|
this.markFinish();
|
|
1593
1593
|
const get = (type) => {
|
|
1594
1594
|
const all = this.marks[type] || [];
|
|
1595
|
-
const
|
|
1595
|
+
const max2 = Math.max(...all.map((ns) => Math.max(...ns)));
|
|
1596
1596
|
const min = Math.min(...all.map((ns) => Math.min(...ns)));
|
|
1597
|
-
return Number.isFinite(
|
|
1597
|
+
return Number.isFinite(max2) ? max2 - min : void 0;
|
|
1598
1598
|
};
|
|
1599
1599
|
const duration = get("main") || 0;
|
|
1600
1600
|
const fetch2 = get("fetch");
|
|
@@ -1618,12 +1618,12 @@ var init_dist = __esm({
|
|
|
1618
1618
|
};
|
|
1619
1619
|
this.error = (url) => Object.assign(Object.assign({}, this.finish(url)), { error: true });
|
|
1620
1620
|
this.marker = (category) => {
|
|
1621
|
-
var
|
|
1621
|
+
var _a2;
|
|
1622
1622
|
if (!this.marks[category]) {
|
|
1623
1623
|
this.marks[category] = [];
|
|
1624
1624
|
}
|
|
1625
1625
|
const marks = [now()];
|
|
1626
|
-
(
|
|
1626
|
+
(_a2 = this.marks[category]) === null || _a2 === void 0 ? void 0 : _a2.push(marks);
|
|
1627
1627
|
return () => marks.push(now());
|
|
1628
1628
|
};
|
|
1629
1629
|
this.useTile = (url) => {
|
|
@@ -1638,13 +1638,13 @@ var init_dist = __esm({
|
|
|
1638
1638
|
}
|
|
1639
1639
|
};
|
|
1640
1640
|
this.addAll = (timings) => {
|
|
1641
|
-
var
|
|
1641
|
+
var _a2;
|
|
1642
1642
|
this.tilesFetched += timings.tilesUsed;
|
|
1643
1643
|
const offset = timings.origin - this.timeOrigin;
|
|
1644
1644
|
for (const category in timings.marks) {
|
|
1645
1645
|
const key = category;
|
|
1646
1646
|
const ourList = this.marks[key] || (this.marks[key] = []);
|
|
1647
|
-
ourList.push(...((
|
|
1647
|
+
ourList.push(...((_a2 = timings.marks[key]) === null || _a2 === void 0 ? void 0 : _a2.map((ns) => ns.map((n) => n + offset))) || []);
|
|
1648
1648
|
}
|
|
1649
1649
|
this.resources.push(...timings.resources.map((rt) => applyOffset(rt, offset)));
|
|
1650
1650
|
};
|
|
@@ -1680,12 +1680,12 @@ var init_dist = __esm({
|
|
|
1680
1680
|
class LocalDemManager {
|
|
1681
1681
|
constructor(options) {
|
|
1682
1682
|
this.loaded = Promise.resolve();
|
|
1683
|
-
this.fetchAndParseTile = (z,
|
|
1683
|
+
this.fetchAndParseTile = (z, x3, y, abortController, timer) => {
|
|
1684
1684
|
const self2 = this;
|
|
1685
|
-
const url = this.demUrlPattern.replace("{z}", z.toString()).replace("{x}",
|
|
1685
|
+
const url = this.demUrlPattern.replace("{z}", z.toString()).replace("{x}", x3.toString()).replace("{y}", y.toString());
|
|
1686
1686
|
timer === null || timer === void 0 ? void 0 : timer.useTile(url);
|
|
1687
|
-
return this.parsedCache.get(url, (
|
|
1688
|
-
const response = yield self2.fetchTile(z,
|
|
1687
|
+
return this.parsedCache.get(url, (_2, childAbortController) => __awaiter(this, void 0, void 0, function* () {
|
|
1688
|
+
const response = yield self2.fetchTile(z, x3, y, childAbortController, timer);
|
|
1689
1689
|
if (isAborted(childAbortController))
|
|
1690
1690
|
throw new Error("canceled");
|
|
1691
1691
|
const promise = self2.decodeImage(response.data, self2.encoding, childAbortController);
|
|
@@ -1705,38 +1705,38 @@ var init_dist = __esm({
|
|
|
1705
1705
|
this.decodeImage = options.decodeImage || defaultDecoder;
|
|
1706
1706
|
this.getTile = options.getTile || defaultGetTile;
|
|
1707
1707
|
}
|
|
1708
|
-
fetchTile(z,
|
|
1709
|
-
const url = this.demUrlPattern.replace("{z}", z.toString()).replace("{x}",
|
|
1708
|
+
fetchTile(z, x3, y, parentAbortController, timer) {
|
|
1709
|
+
const url = this.demUrlPattern.replace("{z}", z.toString()).replace("{x}", x3.toString()).replace("{y}", y.toString());
|
|
1710
1710
|
timer === null || timer === void 0 ? void 0 : timer.useTile(url);
|
|
1711
|
-
return this.tileCache.get(url, (
|
|
1711
|
+
return this.tileCache.get(url, (_2, childAbortController) => {
|
|
1712
1712
|
timer === null || timer === void 0 ? void 0 : timer.fetchTile(url);
|
|
1713
1713
|
const mark = timer === null || timer === void 0 ? void 0 : timer.marker("fetch");
|
|
1714
1714
|
return withTimeout(this.timeoutMs, this.getTile(url, childAbortController).finally(() => mark === null || mark === void 0 ? void 0 : mark()), childAbortController);
|
|
1715
1715
|
}, parentAbortController);
|
|
1716
1716
|
}
|
|
1717
|
-
fetchDem(z,
|
|
1717
|
+
fetchDem(z, x3, y, options, abortController, timer) {
|
|
1718
1718
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1719
1719
|
const zoom = Math.min(z - (options.overzoom || 0), this.maxzoom);
|
|
1720
1720
|
const subZ = z - zoom;
|
|
1721
1721
|
const div = 1 << subZ;
|
|
1722
|
-
const newX = Math.floor(
|
|
1722
|
+
const newX = Math.floor(x3 / div);
|
|
1723
1723
|
const newY = Math.floor(y / div);
|
|
1724
1724
|
const tile = yield this.fetchAndParseTile(zoom, newX, newY, abortController, timer);
|
|
1725
|
-
return HeightTile.fromRawDem(tile).split(subZ,
|
|
1725
|
+
return HeightTile.fromRawDem(tile).split(subZ, x3 % div, y % div);
|
|
1726
1726
|
});
|
|
1727
1727
|
}
|
|
1728
|
-
fetchContourTile(z,
|
|
1728
|
+
fetchContourTile(z, x3, y, options, parentAbortController, timer) {
|
|
1729
1729
|
const { levels, multiplier = 1, buffer = 1, extent = 4096, contourLayer = "contours", elevationKey = "ele", levelKey = "level", subsampleBelow = 100 } = options;
|
|
1730
1730
|
if (!levels || levels.length === 0) {
|
|
1731
1731
|
return Promise.resolve({ arrayBuffer: new ArrayBuffer(0) });
|
|
1732
1732
|
}
|
|
1733
|
-
const key = [z,
|
|
1734
|
-
return this.contourCache.get(key, (
|
|
1735
|
-
const
|
|
1733
|
+
const key = [z, x3, y, encodeIndividualOptions(options)].join("/");
|
|
1734
|
+
return this.contourCache.get(key, (_2, childAbortController) => __awaiter(this, void 0, void 0, function* () {
|
|
1735
|
+
const max2 = 1 << z;
|
|
1736
1736
|
const neighborPromises = [];
|
|
1737
1737
|
for (let iy = y - 1; iy <= y + 1; iy++) {
|
|
1738
|
-
for (let ix =
|
|
1739
|
-
neighborPromises.push(iy < 0 || iy >=
|
|
1738
|
+
for (let ix = x3 - 1; ix <= x3 + 1; ix++) {
|
|
1739
|
+
neighborPromises.push(iy < 0 || iy >= max2 ? void 0 : this.fetchDem(z, (ix + max2) % max2, iy, options, childAbortController, timer));
|
|
1740
1740
|
}
|
|
1741
1741
|
}
|
|
1742
1742
|
const neighbors = yield Promise.all(neighborPromises);
|
|
@@ -1766,7 +1766,7 @@ var init_dist = __esm({
|
|
|
1766
1766
|
geometry: geom,
|
|
1767
1767
|
properties: {
|
|
1768
1768
|
[elevationKey]: ele,
|
|
1769
|
-
[levelKey]: Math.max(...levels.map((
|
|
1769
|
+
[levelKey]: Math.max(...levels.map((l2, i2) => ele % l2 === 0 ? i2 : 0))
|
|
1770
1770
|
}
|
|
1771
1771
|
};
|
|
1772
1772
|
})
|
|
@@ -1785,7 +1785,7 @@ var init_dist = __esm({
|
|
|
1785
1785
|
this.cancels = {};
|
|
1786
1786
|
this.dest = dest;
|
|
1787
1787
|
this.timeoutMs = timeoutMs;
|
|
1788
|
-
this.dest.onmessage = (
|
|
1788
|
+
this.dest.onmessage = (_a2) => __awaiter(this, [_a2], void 0, function* ({ data }) {
|
|
1789
1789
|
const message = data;
|
|
1790
1790
|
if (message.type === "cancel") {
|
|
1791
1791
|
const cancel = this.cancels[message.id];
|
|
@@ -1874,26 +1874,26 @@ var init_dist = __esm({
|
|
|
1874
1874
|
class WorkerDispatch {
|
|
1875
1875
|
constructor() {
|
|
1876
1876
|
this.managers = {};
|
|
1877
|
-
this.init = (message,
|
|
1877
|
+
this.init = (message, _2) => {
|
|
1878
1878
|
this.managers[message.managerId] = new actor.L(message);
|
|
1879
1879
|
return Promise.resolve();
|
|
1880
1880
|
};
|
|
1881
|
-
this.fetchTile = (managerId, z,
|
|
1882
|
-
var
|
|
1883
|
-
return ((
|
|
1881
|
+
this.fetchTile = (managerId, z, x3, y, abortController, timer) => {
|
|
1882
|
+
var _a2;
|
|
1883
|
+
return ((_a2 = this.managers[managerId]) === null || _a2 === void 0 ? void 0 : _a2.fetchTile(z, x3, y, abortController, timer)) || noManager(managerId);
|
|
1884
1884
|
};
|
|
1885
|
-
this.fetchAndParseTile = (managerId, z,
|
|
1886
|
-
var
|
|
1887
|
-
return actor.p(((
|
|
1885
|
+
this.fetchAndParseTile = (managerId, z, x3, y, abortController, timer) => {
|
|
1886
|
+
var _a2;
|
|
1887
|
+
return actor.p(((_a2 = this.managers[managerId]) === null || _a2 === void 0 ? void 0 : _a2.fetchAndParseTile(z, x3, y, abortController, timer)) || noManager(managerId), true);
|
|
1888
1888
|
};
|
|
1889
|
-
this.fetchContourTile = (managerId, z,
|
|
1890
|
-
var
|
|
1891
|
-
return actor.f(((
|
|
1889
|
+
this.fetchContourTile = (managerId, z, x3, y, options, abortController, timer) => {
|
|
1890
|
+
var _a2;
|
|
1891
|
+
return actor.f(((_a2 = this.managers[managerId]) === null || _a2 === void 0 ? void 0 : _a2.fetchContourTile(z, x3, y, options, abortController, timer)) || noManager(managerId));
|
|
1892
1892
|
};
|
|
1893
1893
|
}
|
|
1894
1894
|
}
|
|
1895
|
-
const
|
|
1896
|
-
|
|
1895
|
+
const g2 = typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : global;
|
|
1896
|
+
g2.actor = new actor.A(g2, new WorkerDispatch());
|
|
1897
1897
|
}));
|
|
1898
1898
|
define(["./shared"], (function(actor) {
|
|
1899
1899
|
"use strict";
|
|
@@ -1915,9 +1915,9 @@ var init_dist = __esm({
|
|
|
1915
1915
|
}
|
|
1916
1916
|
class RemoteDemManager {
|
|
1917
1917
|
constructor(options) {
|
|
1918
|
-
this.fetchTile = (z,
|
|
1919
|
-
this.fetchAndParseTile = (z,
|
|
1920
|
-
this.fetchContourTile = (z,
|
|
1918
|
+
this.fetchTile = (z, x3, y, abortController, timer) => this.actor.send("fetchTile", [], abortController, timer, this.managerId, z, x3, y);
|
|
1919
|
+
this.fetchAndParseTile = (z, x3, y, abortController, timer) => this.actor.send("fetchAndParseTile", [], abortController, timer, this.managerId, z, x3, y);
|
|
1920
|
+
this.fetchContourTile = (z, x3, y, options2, abortController, timer) => this.actor.send("fetchContourTile", [], abortController, timer, this.managerId, z, x3, y, options2);
|
|
1921
1921
|
const managerId = this.managerId = ++id;
|
|
1922
1922
|
this.actor = options.actor || defaultActor();
|
|
1923
1923
|
this.loaded = this.actor.send("init", [], new AbortController(), void 0, Object.assign(Object.assign({}, options), { managerId }));
|
|
@@ -1928,8 +1928,8 @@ var init_dist = __esm({
|
|
|
1928
1928
|
return new Promise((resolve, reject) => {
|
|
1929
1929
|
const fileReader = new FileReader();
|
|
1930
1930
|
fileReader.onload = (event) => {
|
|
1931
|
-
var
|
|
1932
|
-
return resolve((
|
|
1931
|
+
var _a2;
|
|
1932
|
+
return resolve((_a2 = event.target) === null || _a2 === void 0 ? void 0 : _a2.result);
|
|
1933
1933
|
};
|
|
1934
1934
|
fileReader.onerror = reject;
|
|
1935
1935
|
fileReader.readAsArrayBuffer(this);
|
|
@@ -1941,7 +1941,7 @@ var init_dist = __esm({
|
|
|
1941
1941
|
return v4(requestParameters, arg2);
|
|
1942
1942
|
} else {
|
|
1943
1943
|
const abortController = new AbortController();
|
|
1944
|
-
v4(requestParameters, abortController).then((result) => arg2(void 0, result.data, result.cacheControl, result.expires), (
|
|
1944
|
+
v4(requestParameters, abortController).then((result) => arg2(void 0, result.data, result.cacheControl, result.expires), (err2) => arg2(err2)).catch((err2) => arg2(err2));
|
|
1945
1945
|
return { cancel: () => abortController.abort() };
|
|
1946
1946
|
}
|
|
1947
1947
|
};
|
|
@@ -1957,11 +1957,11 @@ var init_dist = __esm({
|
|
|
1957
1957
|
maplibre.addProtocol(this.contourProtocolId, this.contourProtocol);
|
|
1958
1958
|
};
|
|
1959
1959
|
this.sharedDemProtocolV4 = (request, abortController) => actor._(this, void 0, void 0, function* () {
|
|
1960
|
-
const [z,
|
|
1960
|
+
const [z, x3, y] = this.parseUrl(request.url);
|
|
1961
1961
|
const timer = new actor.T("main");
|
|
1962
1962
|
let timing;
|
|
1963
1963
|
try {
|
|
1964
|
-
const data = yield this.manager.fetchTile(z,
|
|
1964
|
+
const data = yield this.manager.fetchTile(z, x3, y, abortController, timer);
|
|
1965
1965
|
timing = timer.finish(request.url);
|
|
1966
1966
|
const arrayBuffer = yield data.data.arrayBuffer();
|
|
1967
1967
|
return {
|
|
@@ -1980,9 +1980,9 @@ var init_dist = __esm({
|
|
|
1980
1980
|
const timer = new actor.T("main");
|
|
1981
1981
|
let timing;
|
|
1982
1982
|
try {
|
|
1983
|
-
const [z,
|
|
1983
|
+
const [z, x3, y] = this.parseUrl(request.url);
|
|
1984
1984
|
const options = actor.a(request.url);
|
|
1985
|
-
const data = yield this.manager.fetchContourTile(z,
|
|
1985
|
+
const data = yield this.manager.fetchContourTile(z, x3, y, actor.g(options, z), abortController, timer);
|
|
1986
1986
|
timing = timer.finish(request.url);
|
|
1987
1987
|
return { data: data.arrayBuffer };
|
|
1988
1988
|
} catch (error) {
|
|
@@ -1995,14 +1995,14 @@ var init_dist = __esm({
|
|
|
1995
1995
|
this.contourProtocol = v3compat(this.contourProtocolV4);
|
|
1996
1996
|
this.sharedDemProtocol = v3compat(this.sharedDemProtocolV4);
|
|
1997
1997
|
this.contourProtocolUrl = (options) => `${this.contourProtocolUrlBase}?${actor.e(options)}`;
|
|
1998
|
-
let
|
|
1999
|
-
let
|
|
2000
|
-
while (used.has(
|
|
2001
|
-
|
|
1998
|
+
let protocolPrefix2 = id2;
|
|
1999
|
+
let i2 = 1;
|
|
2000
|
+
while (used.has(protocolPrefix2)) {
|
|
2001
|
+
protocolPrefix2 = id2 + i2++;
|
|
2002
2002
|
}
|
|
2003
|
-
used.add(
|
|
2004
|
-
this.sharedDemProtocolId = `${
|
|
2005
|
-
this.contourProtocolId = `${
|
|
2003
|
+
used.add(protocolPrefix2);
|
|
2004
|
+
this.sharedDemProtocolId = `${protocolPrefix2}-shared`;
|
|
2005
|
+
this.contourProtocolId = `${protocolPrefix2}-contour`;
|
|
2006
2006
|
this.sharedDemProtocolUrl = `${this.sharedDemProtocolId}://{z}/{x}/{y}`;
|
|
2007
2007
|
this.contourProtocolUrlBase = `${this.contourProtocolId}://{z}/{x}/{y}`;
|
|
2008
2008
|
const ManagerClass = worker2 ? RemoteDemManager : actor.L;
|
|
@@ -2015,12 +2015,12 @@ var init_dist = __esm({
|
|
|
2015
2015
|
actor: actor$1
|
|
2016
2016
|
});
|
|
2017
2017
|
}
|
|
2018
|
-
getDemTile(z,
|
|
2019
|
-
return this.manager.fetchAndParseTile(z,
|
|
2018
|
+
getDemTile(z, x3, y, abortController) {
|
|
2019
|
+
return this.manager.fetchAndParseTile(z, x3, y, abortController || new AbortController());
|
|
2020
2020
|
}
|
|
2021
2021
|
parseUrl(url) {
|
|
2022
|
-
const [, z,
|
|
2023
|
-
return [Number(z), Number(
|
|
2022
|
+
const [, z, x3, y] = /\/\/(\d+)\/(\d+)\/(\d+)/.exec(url) || [];
|
|
2023
|
+
return [Number(z), Number(x3), Number(y)];
|
|
2024
2024
|
}
|
|
2025
2025
|
}
|
|
2026
2026
|
const exported = {
|
|
@@ -2052,6 +2052,10 @@ var defaultTileflowRuntimeView = Object.freeze({
|
|
|
2052
2052
|
pitch: 0,
|
|
2053
2053
|
zoom: 2
|
|
2054
2054
|
});
|
|
2055
|
+
var tileflowSurfaceIdPattern = /^[a-z0-9](?:[a-z0-9._-]{0,62}[a-z0-9])?$/u;
|
|
2056
|
+
function normalizeTileflowSurfaceId(value) {
|
|
2057
|
+
return typeof value === "string" && tileflowSurfaceIdPattern.test(value) ? value : "default";
|
|
2058
|
+
}
|
|
2055
2059
|
var tileflowStyleFontFacesMetadataKey = "tileflow:fontFaces";
|
|
2056
2060
|
var tileflowStyleFontFaceLimits = Object.freeze({
|
|
2057
2061
|
maximumCount: 16,
|
|
@@ -2147,6 +2151,7 @@ function startTileflowSession(analytics, input) {
|
|
|
2147
2151
|
sessionId: input.sessionId,
|
|
2148
2152
|
source: analytics.source ?? input.source,
|
|
2149
2153
|
styleId: input.styleId,
|
|
2154
|
+
surfaceId: normalizeTileflowSurfaceId(analytics.surfaceId),
|
|
2150
2155
|
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
2151
2156
|
});
|
|
2152
2157
|
const blob = new Blob([payload], { type: "application/json" });
|
|
@@ -2207,7 +2212,7 @@ function isTileflowWorldReleaseId(value) {
|
|
|
2207
2212
|
|
|
2208
2213
|
// src/fair-use-browser.ts
|
|
2209
2214
|
var protocol = "tileflow-world";
|
|
2210
|
-
var defaultHelpUrl = "https://tileflow.dev/world/
|
|
2215
|
+
var defaultHelpUrl = "https://tileflow.dev/world/connect";
|
|
2211
2216
|
var ownerAction = "Site owner: manage this map with Tileflow.";
|
|
2212
2217
|
var maximumWorldTileBytes = 16 * 1024 * 1024;
|
|
2213
2218
|
var oversizedWorldTileMessage = "Tileflow World tile exceeds the maximum response size";
|
|
@@ -2242,7 +2247,7 @@ function registerTileflowWorldRequestBridge(input) {
|
|
|
2242
2247
|
});
|
|
2243
2248
|
}
|
|
2244
2249
|
function tileflowFairUseNoticeMessage(state) {
|
|
2245
|
-
return state === "
|
|
2250
|
+
return state === "MANAGED_REQUIRED" ? "Map usage is temporarily limited." : "Map usage is approaching its temporary limit.";
|
|
2246
2251
|
}
|
|
2247
2252
|
function attachTileflowFairUseNotice(container) {
|
|
2248
2253
|
let element = null;
|
|
@@ -2265,7 +2270,7 @@ function attachTileflowFairUseNotice(container) {
|
|
|
2265
2270
|
remove();
|
|
2266
2271
|
return;
|
|
2267
2272
|
}
|
|
2268
|
-
if (current?.state === "
|
|
2273
|
+
if (current?.state === "MANAGED_REQUIRED" && notice.state === "GRACE") return;
|
|
2269
2274
|
if (element && current?.state !== notice.state) {
|
|
2270
2275
|
element.remove();
|
|
2271
2276
|
element = null;
|
|
@@ -2284,7 +2289,7 @@ function attachTileflowFairUseNotice(container) {
|
|
|
2284
2289
|
element.replaceChildren();
|
|
2285
2290
|
const indicator = container.ownerDocument.createElement("span");
|
|
2286
2291
|
indicator.setAttribute("aria-hidden", "true");
|
|
2287
|
-
indicator.textContent = notice.state === "
|
|
2292
|
+
indicator.textContent = notice.state === "MANAGED_REQUIRED" ? "!" : "";
|
|
2288
2293
|
Object.assign(indicator.style, noticeIndicatorStyles(notice.state));
|
|
2289
2294
|
element.append(indicator);
|
|
2290
2295
|
const copy = container.ownerDocument.createElement("span");
|
|
@@ -2331,9 +2336,9 @@ async function loadTileflowWorldRequest(request, abortController) {
|
|
|
2331
2336
|
registration.currentNoticeState = null;
|
|
2332
2337
|
registration.onNotice(null);
|
|
2333
2338
|
}
|
|
2334
|
-
} else if (fairUse === "
|
|
2339
|
+
} else if (fairUse === "MANAGED_REQUIRED" || fairUse === "GRACE" && (ownerNotice || response.status === 429)) {
|
|
2335
2340
|
registration.lastNoticeSequence = requestSequence;
|
|
2336
|
-
if (!(registration.currentNoticeState === "
|
|
2341
|
+
if (!(registration.currentNoticeState === "MANAGED_REQUIRED" && fairUse === "GRACE")) {
|
|
2337
2342
|
registration.currentNoticeState = fairUse;
|
|
2338
2343
|
registration.onNotice(
|
|
2339
2344
|
Object.freeze({
|
|
@@ -2346,13 +2351,13 @@ async function loadTileflowWorldRequest(request, abortController) {
|
|
|
2346
2351
|
}
|
|
2347
2352
|
} else if (fairUse === "GRACE" && response.ok) {
|
|
2348
2353
|
registration.lastNoticeSequence = requestSequence;
|
|
2349
|
-
if (registration.currentNoticeState !== "
|
|
2354
|
+
if (registration.currentNoticeState !== "MANAGED_REQUIRED") {
|
|
2350
2355
|
registration.currentNoticeState = null;
|
|
2351
2356
|
registration.onNotice(null);
|
|
2352
2357
|
}
|
|
2353
2358
|
}
|
|
2354
2359
|
}
|
|
2355
|
-
if (response.status === 404 || response.status === 429 && (fairUse === "GRACE" || fairUse === "
|
|
2360
|
+
if (response.status === 404 || response.status === 429 && (fairUse === "GRACE" || fairUse === "MANAGED_REQUIRED")) {
|
|
2356
2361
|
await cancelResponseBody(response.body);
|
|
2357
2362
|
return Object.freeze({
|
|
2358
2363
|
cacheControl: "private, no-store",
|
|
@@ -2451,7 +2456,7 @@ function abortReason(signal) {
|
|
|
2451
2456
|
function parseFairUseState(value) {
|
|
2452
2457
|
if (value === "open") return "OPEN";
|
|
2453
2458
|
if (value === "grace") return "GRACE";
|
|
2454
|
-
if (value === "
|
|
2459
|
+
if (value === "managed-required") return "MANAGED_REQUIRED";
|
|
2455
2460
|
return null;
|
|
2456
2461
|
}
|
|
2457
2462
|
function noticeContainerStyles(state) {
|
|
@@ -2618,7 +2623,7 @@ function parseTileflowContourProtocolRequest(value) {
|
|
|
2618
2623
|
const tile = contourTilePathPattern.exec(url.pathname);
|
|
2619
2624
|
if (!tile) throw new Error("Invalid Tileflow contour tile coordinates.");
|
|
2620
2625
|
const z = Number(tile[1]);
|
|
2621
|
-
const
|
|
2626
|
+
const x3 = Number(tile[2]);
|
|
2622
2627
|
const y = Number(tile[3]);
|
|
2623
2628
|
const config = {
|
|
2624
2629
|
demMaxzoom: parseBoundedInteger(url.searchParams.get("demMaxzoom"), 0, 24),
|
|
@@ -2632,10 +2637,10 @@ function parseTileflowContourProtocolRequest(value) {
|
|
|
2632
2637
|
assertTileflowContourProtocolConfig(config);
|
|
2633
2638
|
const axisLimit = 2 ** z;
|
|
2634
2639
|
const minimumThresholdZoom = Math.min(...Object.keys(config.thresholds).map(Number));
|
|
2635
|
-
if (z < minimumThresholdZoom || z > config.maxzoom ||
|
|
2640
|
+
if (z < minimumThresholdZoom || z > config.maxzoom || x3 >= axisLimit || y >= axisLimit) {
|
|
2636
2641
|
throw new Error("Invalid Tileflow contour tile coordinates.");
|
|
2637
2642
|
}
|
|
2638
|
-
return { config, x, y, z };
|
|
2643
|
+
return { config, x: x3, y, z };
|
|
2639
2644
|
}
|
|
2640
2645
|
function isSafeTileflowDemUrlTemplate(value) {
|
|
2641
2646
|
if (value.length === 0 || value.length > maximumDemUrlLength || value.startsWith("//") || value.includes("#") || /[\\\p{Cc}]/u.test(value)) {
|
|
@@ -2773,7 +2778,7 @@ function createTileflowContourProtocolHandler(loadModule) {
|
|
|
2773
2778
|
const sources = /* @__PURE__ */ new Map();
|
|
2774
2779
|
return async (request, abortController) => {
|
|
2775
2780
|
if (abortController.signal.aborted) throw new Error("Tileflow contour request aborted.");
|
|
2776
|
-
const { config, x, y, z } = parseTileflowContourProtocolRequest(request.url);
|
|
2781
|
+
const { config, x: x3, y, z } = parseTileflowContourProtocolRequest(request.url);
|
|
2777
2782
|
const sourceKey = JSON.stringify([config.demUrl, config.encoding, config.demMaxzoom]);
|
|
2778
2783
|
let source = sources.get(sourceKey);
|
|
2779
2784
|
if (!source) {
|
|
@@ -2805,7 +2810,7 @@ function createTileflowContourProtocolHandler(loadModule) {
|
|
|
2805
2810
|
multiplier: config.multiplier,
|
|
2806
2811
|
overzoom: config.overzoom,
|
|
2807
2812
|
thresholds: mutableThresholds(config.thresholds)
|
|
2808
|
-
}).replace("{z}", String(z)).replace("{x}", String(
|
|
2813
|
+
}).replace("{z}", String(z)).replace("{x}", String(x3)).replace("{y}", String(y));
|
|
2809
2814
|
return contourSource.contourProtocolV4({ url: contourUrl }, abortController);
|
|
2810
2815
|
};
|
|
2811
2816
|
}
|
|
@@ -2828,6 +2833,1011 @@ function mutableThresholds(thresholds) {
|
|
|
2828
2833
|
);
|
|
2829
2834
|
}
|
|
2830
2835
|
|
|
2836
|
+
// ../../node_modules/.pnpm/fflate@0.8.2/node_modules/fflate/esm/browser.js
|
|
2837
|
+
var u8 = Uint8Array;
|
|
2838
|
+
var u16 = Uint16Array;
|
|
2839
|
+
var i32 = Int32Array;
|
|
2840
|
+
var fleb = new u8([
|
|
2841
|
+
0,
|
|
2842
|
+
0,
|
|
2843
|
+
0,
|
|
2844
|
+
0,
|
|
2845
|
+
0,
|
|
2846
|
+
0,
|
|
2847
|
+
0,
|
|
2848
|
+
0,
|
|
2849
|
+
1,
|
|
2850
|
+
1,
|
|
2851
|
+
1,
|
|
2852
|
+
1,
|
|
2853
|
+
2,
|
|
2854
|
+
2,
|
|
2855
|
+
2,
|
|
2856
|
+
2,
|
|
2857
|
+
3,
|
|
2858
|
+
3,
|
|
2859
|
+
3,
|
|
2860
|
+
3,
|
|
2861
|
+
4,
|
|
2862
|
+
4,
|
|
2863
|
+
4,
|
|
2864
|
+
4,
|
|
2865
|
+
5,
|
|
2866
|
+
5,
|
|
2867
|
+
5,
|
|
2868
|
+
5,
|
|
2869
|
+
0,
|
|
2870
|
+
/* unused */
|
|
2871
|
+
0,
|
|
2872
|
+
0,
|
|
2873
|
+
/* impossible */
|
|
2874
|
+
0
|
|
2875
|
+
]);
|
|
2876
|
+
var fdeb = new u8([
|
|
2877
|
+
0,
|
|
2878
|
+
0,
|
|
2879
|
+
0,
|
|
2880
|
+
0,
|
|
2881
|
+
1,
|
|
2882
|
+
1,
|
|
2883
|
+
2,
|
|
2884
|
+
2,
|
|
2885
|
+
3,
|
|
2886
|
+
3,
|
|
2887
|
+
4,
|
|
2888
|
+
4,
|
|
2889
|
+
5,
|
|
2890
|
+
5,
|
|
2891
|
+
6,
|
|
2892
|
+
6,
|
|
2893
|
+
7,
|
|
2894
|
+
7,
|
|
2895
|
+
8,
|
|
2896
|
+
8,
|
|
2897
|
+
9,
|
|
2898
|
+
9,
|
|
2899
|
+
10,
|
|
2900
|
+
10,
|
|
2901
|
+
11,
|
|
2902
|
+
11,
|
|
2903
|
+
12,
|
|
2904
|
+
12,
|
|
2905
|
+
13,
|
|
2906
|
+
13,
|
|
2907
|
+
/* unused */
|
|
2908
|
+
0,
|
|
2909
|
+
0
|
|
2910
|
+
]);
|
|
2911
|
+
var clim = new u8([16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15]);
|
|
2912
|
+
var freb = function(eb, start) {
|
|
2913
|
+
var b2 = new u16(31);
|
|
2914
|
+
for (var i2 = 0; i2 < 31; ++i2) {
|
|
2915
|
+
b2[i2] = start += 1 << eb[i2 - 1];
|
|
2916
|
+
}
|
|
2917
|
+
var r = new i32(b2[30]);
|
|
2918
|
+
for (var i2 = 1; i2 < 30; ++i2) {
|
|
2919
|
+
for (var j2 = b2[i2]; j2 < b2[i2 + 1]; ++j2) {
|
|
2920
|
+
r[j2] = j2 - b2[i2] << 5 | i2;
|
|
2921
|
+
}
|
|
2922
|
+
}
|
|
2923
|
+
return { b: b2, r };
|
|
2924
|
+
};
|
|
2925
|
+
var _a = freb(fleb, 2);
|
|
2926
|
+
var fl = _a.b;
|
|
2927
|
+
var revfl = _a.r;
|
|
2928
|
+
fl[28] = 258, revfl[258] = 28;
|
|
2929
|
+
var _b = freb(fdeb, 0);
|
|
2930
|
+
var fd = _b.b;
|
|
2931
|
+
var revfd = _b.r;
|
|
2932
|
+
var rev = new u16(32768);
|
|
2933
|
+
for (i = 0; i < 32768; ++i) {
|
|
2934
|
+
x = (i & 43690) >> 1 | (i & 21845) << 1;
|
|
2935
|
+
x = (x & 52428) >> 2 | (x & 13107) << 2;
|
|
2936
|
+
x = (x & 61680) >> 4 | (x & 3855) << 4;
|
|
2937
|
+
rev[i] = ((x & 65280) >> 8 | (x & 255) << 8) >> 1;
|
|
2938
|
+
}
|
|
2939
|
+
var x;
|
|
2940
|
+
var i;
|
|
2941
|
+
var hMap = (function(cd, mb, r) {
|
|
2942
|
+
var s = cd.length;
|
|
2943
|
+
var i2 = 0;
|
|
2944
|
+
var l2 = new u16(mb);
|
|
2945
|
+
for (; i2 < s; ++i2) {
|
|
2946
|
+
if (cd[i2])
|
|
2947
|
+
++l2[cd[i2] - 1];
|
|
2948
|
+
}
|
|
2949
|
+
var le = new u16(mb);
|
|
2950
|
+
for (i2 = 1; i2 < mb; ++i2) {
|
|
2951
|
+
le[i2] = le[i2 - 1] + l2[i2 - 1] << 1;
|
|
2952
|
+
}
|
|
2953
|
+
var co;
|
|
2954
|
+
if (r) {
|
|
2955
|
+
co = new u16(1 << mb);
|
|
2956
|
+
var rvb = 15 - mb;
|
|
2957
|
+
for (i2 = 0; i2 < s; ++i2) {
|
|
2958
|
+
if (cd[i2]) {
|
|
2959
|
+
var sv = i2 << 4 | cd[i2];
|
|
2960
|
+
var r_1 = mb - cd[i2];
|
|
2961
|
+
var v2 = le[cd[i2] - 1]++ << r_1;
|
|
2962
|
+
for (var m2 = v2 | (1 << r_1) - 1; v2 <= m2; ++v2) {
|
|
2963
|
+
co[rev[v2] >> rvb] = sv;
|
|
2964
|
+
}
|
|
2965
|
+
}
|
|
2966
|
+
}
|
|
2967
|
+
} else {
|
|
2968
|
+
co = new u16(s);
|
|
2969
|
+
for (i2 = 0; i2 < s; ++i2) {
|
|
2970
|
+
if (cd[i2]) {
|
|
2971
|
+
co[i2] = rev[le[cd[i2] - 1]++] >> 15 - cd[i2];
|
|
2972
|
+
}
|
|
2973
|
+
}
|
|
2974
|
+
}
|
|
2975
|
+
return co;
|
|
2976
|
+
});
|
|
2977
|
+
var flt = new u8(288);
|
|
2978
|
+
for (i = 0; i < 144; ++i)
|
|
2979
|
+
flt[i] = 8;
|
|
2980
|
+
var i;
|
|
2981
|
+
for (i = 144; i < 256; ++i)
|
|
2982
|
+
flt[i] = 9;
|
|
2983
|
+
var i;
|
|
2984
|
+
for (i = 256; i < 280; ++i)
|
|
2985
|
+
flt[i] = 7;
|
|
2986
|
+
var i;
|
|
2987
|
+
for (i = 280; i < 288; ++i)
|
|
2988
|
+
flt[i] = 8;
|
|
2989
|
+
var i;
|
|
2990
|
+
var fdt = new u8(32);
|
|
2991
|
+
for (i = 0; i < 32; ++i)
|
|
2992
|
+
fdt[i] = 5;
|
|
2993
|
+
var i;
|
|
2994
|
+
var flrm = /* @__PURE__ */ hMap(flt, 9, 1);
|
|
2995
|
+
var fdrm = /* @__PURE__ */ hMap(fdt, 5, 1);
|
|
2996
|
+
var max = function(a) {
|
|
2997
|
+
var m2 = a[0];
|
|
2998
|
+
for (var i2 = 1; i2 < a.length; ++i2) {
|
|
2999
|
+
if (a[i2] > m2)
|
|
3000
|
+
m2 = a[i2];
|
|
3001
|
+
}
|
|
3002
|
+
return m2;
|
|
3003
|
+
};
|
|
3004
|
+
var bits = function(d, p, m2) {
|
|
3005
|
+
var o = p / 8 | 0;
|
|
3006
|
+
return (d[o] | d[o + 1] << 8) >> (p & 7) & m2;
|
|
3007
|
+
};
|
|
3008
|
+
var bits16 = function(d, p) {
|
|
3009
|
+
var o = p / 8 | 0;
|
|
3010
|
+
return (d[o] | d[o + 1] << 8 | d[o + 2] << 16) >> (p & 7);
|
|
3011
|
+
};
|
|
3012
|
+
var shft = function(p) {
|
|
3013
|
+
return (p + 7) / 8 | 0;
|
|
3014
|
+
};
|
|
3015
|
+
var slc = function(v2, s, e) {
|
|
3016
|
+
if (s == null || s < 0)
|
|
3017
|
+
s = 0;
|
|
3018
|
+
if (e == null || e > v2.length)
|
|
3019
|
+
e = v2.length;
|
|
3020
|
+
return new u8(v2.subarray(s, e));
|
|
3021
|
+
};
|
|
3022
|
+
var ec = [
|
|
3023
|
+
"unexpected EOF",
|
|
3024
|
+
"invalid block type",
|
|
3025
|
+
"invalid length/literal",
|
|
3026
|
+
"invalid distance",
|
|
3027
|
+
"stream finished",
|
|
3028
|
+
"no stream handler",
|
|
3029
|
+
,
|
|
3030
|
+
"no callback",
|
|
3031
|
+
"invalid UTF-8 data",
|
|
3032
|
+
"extra field too long",
|
|
3033
|
+
"date not in range 1980-2099",
|
|
3034
|
+
"filename too long",
|
|
3035
|
+
"stream finishing",
|
|
3036
|
+
"invalid zip data"
|
|
3037
|
+
// determined by unknown compression method
|
|
3038
|
+
];
|
|
3039
|
+
var err = function(ind, msg, nt) {
|
|
3040
|
+
var e = new Error(msg || ec[ind]);
|
|
3041
|
+
e.code = ind;
|
|
3042
|
+
if (Error.captureStackTrace)
|
|
3043
|
+
Error.captureStackTrace(e, err);
|
|
3044
|
+
if (!nt)
|
|
3045
|
+
throw e;
|
|
3046
|
+
return e;
|
|
3047
|
+
};
|
|
3048
|
+
var inflt = function(dat, st, buf, dict) {
|
|
3049
|
+
var sl = dat.length, dl = dict ? dict.length : 0;
|
|
3050
|
+
if (!sl || st.f && !st.l)
|
|
3051
|
+
return buf || new u8(0);
|
|
3052
|
+
var noBuf = !buf;
|
|
3053
|
+
var resize = noBuf || st.i != 2;
|
|
3054
|
+
var noSt = st.i;
|
|
3055
|
+
if (noBuf)
|
|
3056
|
+
buf = new u8(sl * 3);
|
|
3057
|
+
var cbuf = function(l3) {
|
|
3058
|
+
var bl = buf.length;
|
|
3059
|
+
if (l3 > bl) {
|
|
3060
|
+
var nbuf = new u8(Math.max(bl * 2, l3));
|
|
3061
|
+
nbuf.set(buf);
|
|
3062
|
+
buf = nbuf;
|
|
3063
|
+
}
|
|
3064
|
+
};
|
|
3065
|
+
var final = st.f || 0, pos = st.p || 0, bt = st.b || 0, lm = st.l, dm = st.d, lbt = st.m, dbt = st.n;
|
|
3066
|
+
var tbts = sl * 8;
|
|
3067
|
+
do {
|
|
3068
|
+
if (!lm) {
|
|
3069
|
+
final = bits(dat, pos, 1);
|
|
3070
|
+
var type = bits(dat, pos + 1, 3);
|
|
3071
|
+
pos += 3;
|
|
3072
|
+
if (!type) {
|
|
3073
|
+
var s = shft(pos) + 4, l2 = dat[s - 4] | dat[s - 3] << 8, t = s + l2;
|
|
3074
|
+
if (t > sl) {
|
|
3075
|
+
if (noSt)
|
|
3076
|
+
err(0);
|
|
3077
|
+
break;
|
|
3078
|
+
}
|
|
3079
|
+
if (resize)
|
|
3080
|
+
cbuf(bt + l2);
|
|
3081
|
+
buf.set(dat.subarray(s, t), bt);
|
|
3082
|
+
st.b = bt += l2, st.p = pos = t * 8, st.f = final;
|
|
3083
|
+
continue;
|
|
3084
|
+
} else if (type == 1)
|
|
3085
|
+
lm = flrm, dm = fdrm, lbt = 9, dbt = 5;
|
|
3086
|
+
else if (type == 2) {
|
|
3087
|
+
var hLit = bits(dat, pos, 31) + 257, hcLen = bits(dat, pos + 10, 15) + 4;
|
|
3088
|
+
var tl = hLit + bits(dat, pos + 5, 31) + 1;
|
|
3089
|
+
pos += 14;
|
|
3090
|
+
var ldt = new u8(tl);
|
|
3091
|
+
var clt = new u8(19);
|
|
3092
|
+
for (var i2 = 0; i2 < hcLen; ++i2) {
|
|
3093
|
+
clt[clim[i2]] = bits(dat, pos + i2 * 3, 7);
|
|
3094
|
+
}
|
|
3095
|
+
pos += hcLen * 3;
|
|
3096
|
+
var clb = max(clt), clbmsk = (1 << clb) - 1;
|
|
3097
|
+
var clm = hMap(clt, clb, 1);
|
|
3098
|
+
for (var i2 = 0; i2 < tl; ) {
|
|
3099
|
+
var r = clm[bits(dat, pos, clbmsk)];
|
|
3100
|
+
pos += r & 15;
|
|
3101
|
+
var s = r >> 4;
|
|
3102
|
+
if (s < 16) {
|
|
3103
|
+
ldt[i2++] = s;
|
|
3104
|
+
} else {
|
|
3105
|
+
var c = 0, n = 0;
|
|
3106
|
+
if (s == 16)
|
|
3107
|
+
n = 3 + bits(dat, pos, 3), pos += 2, c = ldt[i2 - 1];
|
|
3108
|
+
else if (s == 17)
|
|
3109
|
+
n = 3 + bits(dat, pos, 7), pos += 3;
|
|
3110
|
+
else if (s == 18)
|
|
3111
|
+
n = 11 + bits(dat, pos, 127), pos += 7;
|
|
3112
|
+
while (n--)
|
|
3113
|
+
ldt[i2++] = c;
|
|
3114
|
+
}
|
|
3115
|
+
}
|
|
3116
|
+
var lt = ldt.subarray(0, hLit), dt = ldt.subarray(hLit);
|
|
3117
|
+
lbt = max(lt);
|
|
3118
|
+
dbt = max(dt);
|
|
3119
|
+
lm = hMap(lt, lbt, 1);
|
|
3120
|
+
dm = hMap(dt, dbt, 1);
|
|
3121
|
+
} else
|
|
3122
|
+
err(1);
|
|
3123
|
+
if (pos > tbts) {
|
|
3124
|
+
if (noSt)
|
|
3125
|
+
err(0);
|
|
3126
|
+
break;
|
|
3127
|
+
}
|
|
3128
|
+
}
|
|
3129
|
+
if (resize)
|
|
3130
|
+
cbuf(bt + 131072);
|
|
3131
|
+
var lms = (1 << lbt) - 1, dms = (1 << dbt) - 1;
|
|
3132
|
+
var lpos = pos;
|
|
3133
|
+
for (; ; lpos = pos) {
|
|
3134
|
+
var c = lm[bits16(dat, pos) & lms], sym = c >> 4;
|
|
3135
|
+
pos += c & 15;
|
|
3136
|
+
if (pos > tbts) {
|
|
3137
|
+
if (noSt)
|
|
3138
|
+
err(0);
|
|
3139
|
+
break;
|
|
3140
|
+
}
|
|
3141
|
+
if (!c)
|
|
3142
|
+
err(2);
|
|
3143
|
+
if (sym < 256)
|
|
3144
|
+
buf[bt++] = sym;
|
|
3145
|
+
else if (sym == 256) {
|
|
3146
|
+
lpos = pos, lm = null;
|
|
3147
|
+
break;
|
|
3148
|
+
} else {
|
|
3149
|
+
var add = sym - 254;
|
|
3150
|
+
if (sym > 264) {
|
|
3151
|
+
var i2 = sym - 257, b2 = fleb[i2];
|
|
3152
|
+
add = bits(dat, pos, (1 << b2) - 1) + fl[i2];
|
|
3153
|
+
pos += b2;
|
|
3154
|
+
}
|
|
3155
|
+
var d = dm[bits16(dat, pos) & dms], dsym = d >> 4;
|
|
3156
|
+
if (!d)
|
|
3157
|
+
err(3);
|
|
3158
|
+
pos += d & 15;
|
|
3159
|
+
var dt = fd[dsym];
|
|
3160
|
+
if (dsym > 3) {
|
|
3161
|
+
var b2 = fdeb[dsym];
|
|
3162
|
+
dt += bits16(dat, pos) & (1 << b2) - 1, pos += b2;
|
|
3163
|
+
}
|
|
3164
|
+
if (pos > tbts) {
|
|
3165
|
+
if (noSt)
|
|
3166
|
+
err(0);
|
|
3167
|
+
break;
|
|
3168
|
+
}
|
|
3169
|
+
if (resize)
|
|
3170
|
+
cbuf(bt + 131072);
|
|
3171
|
+
var end = bt + add;
|
|
3172
|
+
if (bt < dt) {
|
|
3173
|
+
var shift = dl - dt, dend = Math.min(dt, end);
|
|
3174
|
+
if (shift + bt < 0)
|
|
3175
|
+
err(3);
|
|
3176
|
+
for (; bt < dend; ++bt)
|
|
3177
|
+
buf[bt] = dict[shift + bt];
|
|
3178
|
+
}
|
|
3179
|
+
for (; bt < end; ++bt)
|
|
3180
|
+
buf[bt] = buf[bt - dt];
|
|
3181
|
+
}
|
|
3182
|
+
}
|
|
3183
|
+
st.l = lm, st.p = lpos, st.b = bt, st.f = final;
|
|
3184
|
+
if (lm)
|
|
3185
|
+
final = 1, st.m = lbt, st.d = dm, st.n = dbt;
|
|
3186
|
+
} while (!final);
|
|
3187
|
+
return bt != buf.length && noBuf ? slc(buf, 0, bt) : buf.subarray(0, bt);
|
|
3188
|
+
};
|
|
3189
|
+
var et = /* @__PURE__ */ new u8(0);
|
|
3190
|
+
var gzs = function(d) {
|
|
3191
|
+
if (d[0] != 31 || d[1] != 139 || d[2] != 8)
|
|
3192
|
+
err(6, "invalid gzip data");
|
|
3193
|
+
var flg = d[3];
|
|
3194
|
+
var st = 10;
|
|
3195
|
+
if (flg & 4)
|
|
3196
|
+
st += (d[10] | d[11] << 8) + 2;
|
|
3197
|
+
for (var zs = (flg >> 3 & 1) + (flg >> 4 & 1); zs > 0; zs -= !d[st++])
|
|
3198
|
+
;
|
|
3199
|
+
return st + (flg & 2);
|
|
3200
|
+
};
|
|
3201
|
+
var gzl = function(d) {
|
|
3202
|
+
var l2 = d.length;
|
|
3203
|
+
return (d[l2 - 4] | d[l2 - 3] << 8 | d[l2 - 2] << 16 | d[l2 - 1] << 24) >>> 0;
|
|
3204
|
+
};
|
|
3205
|
+
var zls = function(d, dict) {
|
|
3206
|
+
if ((d[0] & 15) != 8 || d[0] >> 4 > 7 || (d[0] << 8 | d[1]) % 31)
|
|
3207
|
+
err(6, "invalid zlib data");
|
|
3208
|
+
if ((d[1] >> 5 & 1) == +!dict)
|
|
3209
|
+
err(6, "invalid zlib data: " + (d[1] & 32 ? "need" : "unexpected") + " dictionary");
|
|
3210
|
+
return (d[1] >> 3 & 4) + 2;
|
|
3211
|
+
};
|
|
3212
|
+
function inflateSync(data, opts) {
|
|
3213
|
+
return inflt(data, { i: 2 }, opts && opts.out, opts && opts.dictionary);
|
|
3214
|
+
}
|
|
3215
|
+
function gunzipSync(data, opts) {
|
|
3216
|
+
var st = gzs(data);
|
|
3217
|
+
if (st + 8 > data.length)
|
|
3218
|
+
err(6, "invalid gzip data");
|
|
3219
|
+
return inflt(data.subarray(st, -8), { i: 2 }, opts && opts.out || new u8(gzl(data)), opts && opts.dictionary);
|
|
3220
|
+
}
|
|
3221
|
+
function unzlibSync(data, opts) {
|
|
3222
|
+
return inflt(data.subarray(zls(data, opts && opts.dictionary), -4), { i: 2 }, opts && opts.out, opts && opts.dictionary);
|
|
3223
|
+
}
|
|
3224
|
+
function decompressSync(data, opts) {
|
|
3225
|
+
return data[0] == 31 && data[1] == 139 && data[2] == 8 ? gunzipSync(data, opts) : (data[0] & 15) != 8 || data[0] >> 4 > 7 || (data[0] << 8 | data[1]) % 31 ? inflateSync(data, opts) : unzlibSync(data, opts);
|
|
3226
|
+
}
|
|
3227
|
+
var td = typeof TextDecoder != "undefined" && /* @__PURE__ */ new TextDecoder();
|
|
3228
|
+
var tds = 0;
|
|
3229
|
+
try {
|
|
3230
|
+
td.decode(et, { stream: true });
|
|
3231
|
+
tds = 1;
|
|
3232
|
+
} catch (e) {
|
|
3233
|
+
}
|
|
3234
|
+
|
|
3235
|
+
// ../../node_modules/.pnpm/pmtiles@4.4.0/node_modules/pmtiles/dist/esm/index.js
|
|
3236
|
+
var j = Object.defineProperty;
|
|
3237
|
+
var B = Math.pow;
|
|
3238
|
+
var l = (o, t) => j(o, "name", { value: t, configurable: true });
|
|
3239
|
+
var m = (o, t, e) => new Promise((r, n) => {
|
|
3240
|
+
var s = (c) => {
|
|
3241
|
+
try {
|
|
3242
|
+
a(e.next(c));
|
|
3243
|
+
} catch (u) {
|
|
3244
|
+
n(u);
|
|
3245
|
+
}
|
|
3246
|
+
}, i2 = (c) => {
|
|
3247
|
+
try {
|
|
3248
|
+
a(e.throw(c));
|
|
3249
|
+
} catch (u) {
|
|
3250
|
+
n(u);
|
|
3251
|
+
}
|
|
3252
|
+
}, a = (c) => c.done ? r(c.value) : Promise.resolve(c.value).then(s, i2);
|
|
3253
|
+
a((e = e.apply(o, t)).next());
|
|
3254
|
+
});
|
|
3255
|
+
var re = l((o, t) => {
|
|
3256
|
+
let e = false, r = "", n = L.GridLayer.extend({ createTile: l((s, i2) => {
|
|
3257
|
+
let a = document.createElement("img"), c = new AbortController(), u = c.signal;
|
|
3258
|
+
return a.cancel = () => {
|
|
3259
|
+
c.abort();
|
|
3260
|
+
}, e || (o.getHeader().then((d) => {
|
|
3261
|
+
d.tileType === 1 ? console.error("Error: archive contains MVT vector tiles, but leafletRasterLayer is for displaying raster tiles. See https://github.com/protomaps/PMTiles/tree/main/js for details.") : d.tileType === 2 ? r = "image/png" : d.tileType === 3 ? r = "image/jpeg" : d.tileType === 4 ? r = "image/webp" : d.tileType === 5 && (r = "image/avif");
|
|
3262
|
+
}), e = true), o.getZxy(s.z, s.x, s.y, u).then((d) => {
|
|
3263
|
+
if (d) {
|
|
3264
|
+
let h = new Blob([d.data], { type: r }), p = window.URL.createObjectURL(h);
|
|
3265
|
+
a.src = p;
|
|
3266
|
+
} else a.style.display = "none";
|
|
3267
|
+
a.cancel = void 0, i2(void 0, a);
|
|
3268
|
+
}).catch((d) => {
|
|
3269
|
+
if (d.name !== "AbortError") throw d;
|
|
3270
|
+
}), a;
|
|
3271
|
+
}, "createTile"), _removeTile: l(function(s) {
|
|
3272
|
+
let i2 = this._tiles[s];
|
|
3273
|
+
i2 && (i2.el.cancel && i2.el.cancel(), i2.el.width = 0, i2.el.height = 0, i2.el.deleted = true, L.DomUtil.remove(i2.el), delete this._tiles[s], this.fire("tileunload", { tile: i2.el, coords: this._keyToTileCoords(s) }));
|
|
3274
|
+
}, "_removeTile") });
|
|
3275
|
+
return new n(t);
|
|
3276
|
+
}, "leafletRasterLayer");
|
|
3277
|
+
var W = l((o) => (t, e) => {
|
|
3278
|
+
if (e instanceof AbortController) return o(t, e);
|
|
3279
|
+
let r = new AbortController();
|
|
3280
|
+
return o(t, r).then((n) => e(void 0, n.data, n.cacheControl || "", n.expires || ""), (n) => e(n)).catch((n) => e(n)), { cancel: l(() => r.abort(), "cancel") };
|
|
3281
|
+
}, "v3compat");
|
|
3282
|
+
var E = class E2 {
|
|
3283
|
+
constructor(t) {
|
|
3284
|
+
this.tilev4 = l((t2, e) => m(this, null, function* () {
|
|
3285
|
+
if (t2.type === "json") {
|
|
3286
|
+
let p = t2.url.substr(10), y = this.tiles.get(p);
|
|
3287
|
+
if (y || (y = new w(p), this.tiles.set(p, y)), this.metadata) {
|
|
3288
|
+
let z = yield y.getTileJson(t2.url);
|
|
3289
|
+
return e.signal.throwIfAborted(), { data: z };
|
|
3290
|
+
}
|
|
3291
|
+
let f = yield y.getHeader();
|
|
3292
|
+
return e.signal.throwIfAborted(), (f.minLon >= f.maxLon || f.minLat >= f.maxLat) && console.error(`Bounds of PMTiles archive ${f.minLon},${f.minLat},${f.maxLon},${f.maxLat} are not valid.`), { data: { tiles: [`${t2.url}/{z}/{x}/{y}`], minzoom: f.minZoom, maxzoom: f.maxZoom, bounds: [f.minLon, f.minLat, f.maxLon, f.maxLat] } };
|
|
3293
|
+
}
|
|
3294
|
+
let r = new RegExp(/pmtiles:\/\/(.+)\/(\d+)\/(\d+)\/(\d+)/), n = t2.url.match(r);
|
|
3295
|
+
if (!n) throw new Error("Invalid PMTiles protocol URL");
|
|
3296
|
+
let s = n[1], i2 = this.tiles.get(s);
|
|
3297
|
+
i2 || (i2 = new w(s), this.tiles.set(s, i2));
|
|
3298
|
+
let a = n[2], c = n[3], u = n[4], d = yield i2.getHeader(), h = yield i2 == null ? void 0 : i2.getZxy(+a, +c, +u, e.signal);
|
|
3299
|
+
if (e.signal.throwIfAborted(), h) return { data: new Uint8Array(h.data), cacheControl: h.cacheControl, expires: h.expires };
|
|
3300
|
+
if (d.tileType === 1) {
|
|
3301
|
+
if (this.errorOnMissingTile) throw new Error("Tile not found.");
|
|
3302
|
+
return { data: new Uint8Array() };
|
|
3303
|
+
}
|
|
3304
|
+
return { data: null };
|
|
3305
|
+
}), "tilev4");
|
|
3306
|
+
this.tile = W(this.tilev4);
|
|
3307
|
+
this.tiles = /* @__PURE__ */ new Map(), this.metadata = (t == null ? void 0 : t.metadata) || false, this.errorOnMissingTile = (t == null ? void 0 : t.errorOnMissingTile) || false;
|
|
3308
|
+
}
|
|
3309
|
+
add(t) {
|
|
3310
|
+
this.tiles.set(t.source.getKey(), t);
|
|
3311
|
+
}
|
|
3312
|
+
get(t) {
|
|
3313
|
+
return this.tiles.get(t);
|
|
3314
|
+
}
|
|
3315
|
+
};
|
|
3316
|
+
l(E, "Protocol");
|
|
3317
|
+
function b(o, t) {
|
|
3318
|
+
return (t >>> 0) * 4294967296 + (o >>> 0);
|
|
3319
|
+
}
|
|
3320
|
+
l(b, "toNum");
|
|
3321
|
+
function N(o, t) {
|
|
3322
|
+
let e = t.buf, r = e[t.pos++], n = (r & 112) >> 4;
|
|
3323
|
+
if (r < 128 || (r = e[t.pos++], n |= (r & 127) << 3, r < 128) || (r = e[t.pos++], n |= (r & 127) << 10, r < 128) || (r = e[t.pos++], n |= (r & 127) << 17, r < 128) || (r = e[t.pos++], n |= (r & 127) << 24, r < 128) || (r = e[t.pos++], n |= (r & 1) << 31, r < 128)) return b(o, n);
|
|
3324
|
+
throw new Error("Expected varint not more than 10 bytes");
|
|
3325
|
+
}
|
|
3326
|
+
l(N, "readVarintRemainder");
|
|
3327
|
+
function x2(o) {
|
|
3328
|
+
let t = o.buf, e = t[o.pos++], r = e & 127;
|
|
3329
|
+
return e < 128 || (e = t[o.pos++], r |= (e & 127) << 7, e < 128) || (e = t[o.pos++], r |= (e & 127) << 14, e < 128) || (e = t[o.pos++], r |= (e & 127) << 21, e < 128) ? r : (e = t[o.pos], r |= (e & 15) << 28, N(r, o));
|
|
3330
|
+
}
|
|
3331
|
+
l(x2, "readVarint");
|
|
3332
|
+
function k(o, t, e, r, n) {
|
|
3333
|
+
return n === 0 ? r !== 0 ? [o - 1 - e, o - 1 - t] : [e, t] : [t, e];
|
|
3334
|
+
}
|
|
3335
|
+
l(k, "rotate");
|
|
3336
|
+
function q(o, t, e) {
|
|
3337
|
+
if (o > 26) throw new Error("Tile zoom level exceeds max safe number limit (26)");
|
|
3338
|
+
if (t >= 1 << o || e >= 1 << o) throw new Error("tile x/y outside zoom level bounds");
|
|
3339
|
+
let r = ((1 << o) * (1 << o) - 1) / 3, n = o - 1, [s, i2] = [t, e];
|
|
3340
|
+
for (let a = 1 << n; a > 0; a >>= 1) {
|
|
3341
|
+
let c = s & a, u = i2 & a;
|
|
3342
|
+
r += (3 * c ^ u) * (1 << n), [s, i2] = k(a, s, i2, c, u), n--;
|
|
3343
|
+
}
|
|
3344
|
+
return r;
|
|
3345
|
+
}
|
|
3346
|
+
l(q, "zxyToTileId");
|
|
3347
|
+
function G(o) {
|
|
3348
|
+
let t = 3 * o + 1;
|
|
3349
|
+
return t < 4294967296 ? 31 - Math.clz32(t) : 63 - Math.clz32(t / 4294967296);
|
|
3350
|
+
}
|
|
3351
|
+
l(G, "tileIdToZ");
|
|
3352
|
+
function ie(o) {
|
|
3353
|
+
let t = G(o) >> 1;
|
|
3354
|
+
if (t > 26) throw new Error("Tile zoom level exceeds max safe number limit (26)");
|
|
3355
|
+
let e = ((1 << t) * (1 << t) - 1) / 3, r = o - e, n = 0, s = 0, i2 = 1 << t;
|
|
3356
|
+
for (let a = 1; a < i2; a <<= 1) {
|
|
3357
|
+
let c = a & r / 2, u = a & (r ^ c);
|
|
3358
|
+
[n, s] = k(a, n, s, c, u), r = r / 2, n += c, s += u;
|
|
3359
|
+
}
|
|
3360
|
+
return [t, n, s];
|
|
3361
|
+
}
|
|
3362
|
+
l(ie, "tileIdToZxy");
|
|
3363
|
+
var J = ((s) => (s[s.Unknown = 0] = "Unknown", s[s.None = 1] = "None", s[s.Gzip = 2] = "Gzip", s[s.Brotli = 3] = "Brotli", s[s.Zstd = 4] = "Zstd", s))(J || {});
|
|
3364
|
+
function D(o, t) {
|
|
3365
|
+
return m(this, null, function* () {
|
|
3366
|
+
if (t === 1 || t === 0) return o;
|
|
3367
|
+
if (t === 2) {
|
|
3368
|
+
if (typeof globalThis.DecompressionStream == "undefined") return decompressSync(new Uint8Array(o));
|
|
3369
|
+
let e = new Response(o).body;
|
|
3370
|
+
if (!e) throw new Error("Failed to read response stream");
|
|
3371
|
+
let r = e.pipeThrough(new globalThis.DecompressionStream("gzip"));
|
|
3372
|
+
return new Response(r).arrayBuffer();
|
|
3373
|
+
}
|
|
3374
|
+
throw new Error("Compression method not supported");
|
|
3375
|
+
});
|
|
3376
|
+
}
|
|
3377
|
+
l(D, "defaultDecompress");
|
|
3378
|
+
var O = ((a) => (a[a.Unknown = 0] = "Unknown", a[a.Mvt = 1] = "Mvt", a[a.Png = 2] = "Png", a[a.Jpeg = 3] = "Jpeg", a[a.Webp = 4] = "Webp", a[a.Avif = 5] = "Avif", a[a.Mlt = 6] = "Mlt", a))(O || {});
|
|
3379
|
+
function _(o) {
|
|
3380
|
+
return o === 1 ? ".mvt" : o === 2 ? ".png" : o === 3 ? ".jpg" : o === 4 ? ".webp" : o === 5 ? ".avif" : o === 6 ? ".mlt" : "";
|
|
3381
|
+
}
|
|
3382
|
+
l(_, "tileTypeExt");
|
|
3383
|
+
var Y = 127;
|
|
3384
|
+
function Q(o, t) {
|
|
3385
|
+
let e = 0, r = o.length - 1;
|
|
3386
|
+
for (; e <= r; ) {
|
|
3387
|
+
let n = r + e >> 1, s = t - o[n].tileId;
|
|
3388
|
+
if (s > 0) e = n + 1;
|
|
3389
|
+
else if (s < 0) r = n - 1;
|
|
3390
|
+
else return o[n];
|
|
3391
|
+
}
|
|
3392
|
+
return r >= 0 && (o[r].runLength === 0 || t - o[r].tileId < o[r].runLength) ? o[r] : null;
|
|
3393
|
+
}
|
|
3394
|
+
l(Q, "findTile");
|
|
3395
|
+
var A = class A2 {
|
|
3396
|
+
constructor(t) {
|
|
3397
|
+
this.file = t;
|
|
3398
|
+
}
|
|
3399
|
+
getKey() {
|
|
3400
|
+
return this.file.name;
|
|
3401
|
+
}
|
|
3402
|
+
getBytes(t, e) {
|
|
3403
|
+
return m(this, null, function* () {
|
|
3404
|
+
return { data: yield this.file.slice(t, t + e).arrayBuffer() };
|
|
3405
|
+
});
|
|
3406
|
+
}
|
|
3407
|
+
};
|
|
3408
|
+
l(A, "FileSource");
|
|
3409
|
+
var C = class C2 {
|
|
3410
|
+
constructor(t, e = new Headers()) {
|
|
3411
|
+
var i2, a;
|
|
3412
|
+
this.url = t, this.customHeaders = e, this.mustReload = false;
|
|
3413
|
+
let r = "";
|
|
3414
|
+
"navigator" in globalThis && (r = (a = (i2 = globalThis.navigator) == null ? void 0 : i2.userAgent) != null ? a : "");
|
|
3415
|
+
let n = r.indexOf("Windows") > -1, s = /Chrome|Chromium|Edg|OPR|Brave/.test(r);
|
|
3416
|
+
this.chromeWindowsNoCache = false, n && s && (this.chromeWindowsNoCache = true);
|
|
3417
|
+
}
|
|
3418
|
+
getKey() {
|
|
3419
|
+
return this.url;
|
|
3420
|
+
}
|
|
3421
|
+
setHeaders(t) {
|
|
3422
|
+
this.customHeaders = t;
|
|
3423
|
+
}
|
|
3424
|
+
getBytes(t, e, r, n) {
|
|
3425
|
+
return m(this, null, function* () {
|
|
3426
|
+
let s, i2;
|
|
3427
|
+
r ? i2 = r : (s = new AbortController(), i2 = s.signal);
|
|
3428
|
+
let a = new Headers(this.customHeaders);
|
|
3429
|
+
a.set("range", `bytes=${t}-${t + e - 1}`);
|
|
3430
|
+
let c;
|
|
3431
|
+
this.mustReload ? c = "reload" : this.chromeWindowsNoCache && (c = "no-store");
|
|
3432
|
+
let u = yield fetch(this.url, { signal: i2, cache: c, headers: a });
|
|
3433
|
+
if (t === 0 && u.status === 416) {
|
|
3434
|
+
let y = u.headers.get("Content-Range");
|
|
3435
|
+
if (!y || !y.startsWith("bytes */")) throw new Error("Missing content-length on 416 response");
|
|
3436
|
+
let f = +y.substr(8);
|
|
3437
|
+
u = yield fetch(this.url, { signal: i2, cache: "reload", headers: { range: `bytes=0-${f - 1}` } });
|
|
3438
|
+
}
|
|
3439
|
+
let d = u.headers.get("Etag");
|
|
3440
|
+
if (d != null && d.startsWith("W/") && (d = null), u.status === 416 || n && d && d !== n) throw this.mustReload = true, new v(`Server returned non-matching ETag ${n} after one retry. Check browser extensions and servers for issues that may affect correct ETag headers.`);
|
|
3441
|
+
if (u.status >= 300) throw new Error(`Bad response code: ${u.status}`);
|
|
3442
|
+
let h = u.headers.get("Content-Length");
|
|
3443
|
+
if (u.status === 200 && (!h || +h > e)) throw s && s.abort(), new Error("Server returned no content-length header or content-length exceeding request. Check that your storage backend supports HTTP Byte Serving.");
|
|
3444
|
+
return { data: yield u.arrayBuffer(), etag: d || void 0, cacheControl: u.headers.get("Cache-Control") || void 0, expires: u.headers.get("Expires") || void 0 };
|
|
3445
|
+
});
|
|
3446
|
+
}
|
|
3447
|
+
};
|
|
3448
|
+
l(C, "FetchSource");
|
|
3449
|
+
var T = C;
|
|
3450
|
+
function g(o, t) {
|
|
3451
|
+
let e = o.getUint32(t + 4, true), r = o.getUint32(t + 0, true);
|
|
3452
|
+
return e * B(2, 32) + r;
|
|
3453
|
+
}
|
|
3454
|
+
l(g, "getUint64");
|
|
3455
|
+
function X(o, t) {
|
|
3456
|
+
let e = new DataView(o), r = e.getUint8(7);
|
|
3457
|
+
if (r > 3) throw new Error(`Archive is spec version ${r} but this library supports up to spec version 3`);
|
|
3458
|
+
return { specVersion: r, rootDirectoryOffset: g(e, 8), rootDirectoryLength: g(e, 16), jsonMetadataOffset: g(e, 24), jsonMetadataLength: g(e, 32), leafDirectoryOffset: g(e, 40), leafDirectoryLength: g(e, 48), tileDataOffset: g(e, 56), tileDataLength: g(e, 64), numAddressedTiles: g(e, 72), numTileEntries: g(e, 80), numTileContents: g(e, 88), clustered: e.getUint8(96) === 1, internalCompression: e.getUint8(97), tileCompression: e.getUint8(98), tileType: e.getUint8(99), minZoom: e.getUint8(100), maxZoom: e.getUint8(101), minLon: e.getInt32(102, true) / 1e7, minLat: e.getInt32(106, true) / 1e7, maxLon: e.getInt32(110, true) / 1e7, maxLat: e.getInt32(114, true) / 1e7, centerZoom: e.getUint8(118), centerLon: e.getInt32(119, true) / 1e7, centerLat: e.getInt32(123, true) / 1e7, etag: t };
|
|
3459
|
+
}
|
|
3460
|
+
l(X, "bytesToHeader");
|
|
3461
|
+
function Z(o) {
|
|
3462
|
+
let t = { buf: new Uint8Array(o), pos: 0 }, e = x2(t), r = [], n = 0;
|
|
3463
|
+
for (let s = 0; s < e; s++) {
|
|
3464
|
+
let i2 = x2(t);
|
|
3465
|
+
r.push({ tileId: n + i2, offset: 0, length: 0, runLength: 1 }), n += i2;
|
|
3466
|
+
}
|
|
3467
|
+
for (let s = 0; s < e; s++) r[s].runLength = x2(t);
|
|
3468
|
+
for (let s = 0; s < e; s++) r[s].length = x2(t);
|
|
3469
|
+
for (let s = 0; s < e; s++) {
|
|
3470
|
+
let i2 = x2(t);
|
|
3471
|
+
i2 === 0 && s > 0 ? r[s].offset = r[s - 1].offset + r[s - 1].length : r[s].offset = i2 - 1;
|
|
3472
|
+
}
|
|
3473
|
+
return r;
|
|
3474
|
+
}
|
|
3475
|
+
l(Z, "deserializeIndex");
|
|
3476
|
+
var U = class U2 extends Error {
|
|
3477
|
+
};
|
|
3478
|
+
l(U, "EtagMismatch");
|
|
3479
|
+
var v = U;
|
|
3480
|
+
function I(o, t) {
|
|
3481
|
+
return m(this, null, function* () {
|
|
3482
|
+
let e = yield o.getBytes(0, 16384);
|
|
3483
|
+
if (new DataView(e.data).getUint16(0, true) !== 19792) throw new Error("Wrong magic number for PMTiles archive");
|
|
3484
|
+
let n = e.data.slice(0, Y), s = X(n, e.etag), i2 = e.data.slice(s.rootDirectoryOffset, s.rootDirectoryOffset + s.rootDirectoryLength), a = `${o.getKey()}|${s.etag || ""}|${s.rootDirectoryOffset}|${s.rootDirectoryLength}`, c = Z(yield t(i2, s.internalCompression));
|
|
3485
|
+
return [s, [a, c.length, c]];
|
|
3486
|
+
});
|
|
3487
|
+
}
|
|
3488
|
+
l(I, "getHeaderAndRoot");
|
|
3489
|
+
function K(o, t, e, r, n) {
|
|
3490
|
+
return m(this, null, function* () {
|
|
3491
|
+
let s = yield o.getBytes(e, r, void 0, n.etag), i2 = yield t(s.data, n.internalCompression), a = Z(i2);
|
|
3492
|
+
if (a.length === 0) throw new Error("Empty directory is invalid");
|
|
3493
|
+
return a;
|
|
3494
|
+
});
|
|
3495
|
+
}
|
|
3496
|
+
l(K, "getDirectory");
|
|
3497
|
+
var R = class R2 {
|
|
3498
|
+
constructor(t = 100, e = true, r = D) {
|
|
3499
|
+
this.cache = /* @__PURE__ */ new Map(), this.maxCacheEntries = t, this.counter = 1, this.decompress = r;
|
|
3500
|
+
}
|
|
3501
|
+
getHeader(t) {
|
|
3502
|
+
return m(this, null, function* () {
|
|
3503
|
+
let e = t.getKey(), r = this.cache.get(e);
|
|
3504
|
+
if (r) return r.lastUsed = this.counter++, r.data;
|
|
3505
|
+
let n = yield I(t, this.decompress);
|
|
3506
|
+
return n[1] && this.cache.set(n[1][0], { lastUsed: this.counter++, data: n[1][2] }), this.cache.set(e, { lastUsed: this.counter++, data: n[0] }), this.prune(), n[0];
|
|
3507
|
+
});
|
|
3508
|
+
}
|
|
3509
|
+
getDirectory(t, e, r, n) {
|
|
3510
|
+
return m(this, null, function* () {
|
|
3511
|
+
let s = `${t.getKey()}|${n.etag || ""}|${e}|${r}`, i2 = this.cache.get(s);
|
|
3512
|
+
if (i2) return i2.lastUsed = this.counter++, i2.data;
|
|
3513
|
+
let a = yield K(t, this.decompress, e, r, n);
|
|
3514
|
+
return this.cache.set(s, { lastUsed: this.counter++, data: a }), this.prune(), a;
|
|
3515
|
+
});
|
|
3516
|
+
}
|
|
3517
|
+
prune() {
|
|
3518
|
+
if (this.cache.size > this.maxCacheEntries) {
|
|
3519
|
+
let t = 1 / 0, e;
|
|
3520
|
+
this.cache.forEach((r, n) => {
|
|
3521
|
+
r.lastUsed < t && (t = r.lastUsed, e = n);
|
|
3522
|
+
}), e && this.cache.delete(e);
|
|
3523
|
+
}
|
|
3524
|
+
}
|
|
3525
|
+
invalidate(t) {
|
|
3526
|
+
return m(this, null, function* () {
|
|
3527
|
+
this.cache.delete(t.getKey());
|
|
3528
|
+
});
|
|
3529
|
+
}
|
|
3530
|
+
};
|
|
3531
|
+
l(R, "ResolvedValueCache");
|
|
3532
|
+
var M = class M2 {
|
|
3533
|
+
constructor(t = 100, e = true, r = D) {
|
|
3534
|
+
this.cache = /* @__PURE__ */ new Map(), this.invalidations = /* @__PURE__ */ new Map(), this.maxCacheEntries = t, this.counter = 1, this.decompress = r;
|
|
3535
|
+
}
|
|
3536
|
+
getHeader(t) {
|
|
3537
|
+
return m(this, null, function* () {
|
|
3538
|
+
let e = t.getKey(), r = this.cache.get(e);
|
|
3539
|
+
if (r) return r.lastUsed = this.counter++, yield r.data;
|
|
3540
|
+
let n = new Promise((s, i2) => {
|
|
3541
|
+
I(t, this.decompress).then((a) => {
|
|
3542
|
+
a[1] && this.cache.set(a[1][0], { lastUsed: this.counter++, data: Promise.resolve(a[1][2]) }), s(a[0]), this.prune();
|
|
3543
|
+
}).catch((a) => {
|
|
3544
|
+
i2(a);
|
|
3545
|
+
});
|
|
3546
|
+
});
|
|
3547
|
+
return this.cache.set(e, { lastUsed: this.counter++, data: n }), n;
|
|
3548
|
+
});
|
|
3549
|
+
}
|
|
3550
|
+
getDirectory(t, e, r, n) {
|
|
3551
|
+
return m(this, null, function* () {
|
|
3552
|
+
let s = `${t.getKey()}|${n.etag || ""}|${e}|${r}`, i2 = this.cache.get(s);
|
|
3553
|
+
if (i2) return i2.lastUsed = this.counter++, yield i2.data;
|
|
3554
|
+
let a = new Promise((c, u) => {
|
|
3555
|
+
K(t, this.decompress, e, r, n).then((d) => {
|
|
3556
|
+
c(d), this.prune();
|
|
3557
|
+
}).catch((d) => {
|
|
3558
|
+
u(d);
|
|
3559
|
+
});
|
|
3560
|
+
});
|
|
3561
|
+
return this.cache.set(s, { lastUsed: this.counter++, data: a }), a;
|
|
3562
|
+
});
|
|
3563
|
+
}
|
|
3564
|
+
prune() {
|
|
3565
|
+
if (this.cache.size >= this.maxCacheEntries) {
|
|
3566
|
+
let t = 1 / 0, e;
|
|
3567
|
+
this.cache.forEach((r, n) => {
|
|
3568
|
+
r.lastUsed < t && (t = r.lastUsed, e = n);
|
|
3569
|
+
}), e && this.cache.delete(e);
|
|
3570
|
+
}
|
|
3571
|
+
}
|
|
3572
|
+
invalidate(t) {
|
|
3573
|
+
return m(this, null, function* () {
|
|
3574
|
+
let e = t.getKey();
|
|
3575
|
+
if (this.invalidations.get(e)) return yield this.invalidations.get(e);
|
|
3576
|
+
this.cache.delete(t.getKey());
|
|
3577
|
+
let r = new Promise((n, s) => {
|
|
3578
|
+
this.getHeader(t).then((i2) => {
|
|
3579
|
+
n(), this.invalidations.delete(e);
|
|
3580
|
+
}).catch((i2) => {
|
|
3581
|
+
s(i2);
|
|
3582
|
+
});
|
|
3583
|
+
});
|
|
3584
|
+
this.invalidations.set(e, r);
|
|
3585
|
+
});
|
|
3586
|
+
}
|
|
3587
|
+
};
|
|
3588
|
+
l(M, "SharedPromiseCache");
|
|
3589
|
+
var P = M;
|
|
3590
|
+
var H = class H2 {
|
|
3591
|
+
constructor(t, e, r) {
|
|
3592
|
+
typeof t == "string" ? this.source = new T(t) : this.source = t, r ? this.decompress = r : this.decompress = D, e ? this.cache = e : this.cache = new P();
|
|
3593
|
+
}
|
|
3594
|
+
getHeader() {
|
|
3595
|
+
return m(this, null, function* () {
|
|
3596
|
+
return yield this.cache.getHeader(this.source);
|
|
3597
|
+
});
|
|
3598
|
+
}
|
|
3599
|
+
getZxyAttempt(t, e, r, n) {
|
|
3600
|
+
return m(this, null, function* () {
|
|
3601
|
+
let s = q(t, e, r), i2 = yield this.cache.getHeader(this.source);
|
|
3602
|
+
if (t < i2.minZoom || t > i2.maxZoom) return;
|
|
3603
|
+
let a = i2.rootDirectoryOffset, c = i2.rootDirectoryLength;
|
|
3604
|
+
for (let u = 0; u <= 3; u++) {
|
|
3605
|
+
let d = yield this.cache.getDirectory(this.source, a, c, i2), h = Q(d, s);
|
|
3606
|
+
if (h) {
|
|
3607
|
+
if (h.runLength > 0) {
|
|
3608
|
+
let p = yield this.source.getBytes(i2.tileDataOffset + h.offset, h.length, n, i2.etag);
|
|
3609
|
+
return { data: yield this.decompress(p.data, i2.tileCompression), cacheControl: p.cacheControl, expires: p.expires };
|
|
3610
|
+
}
|
|
3611
|
+
a = i2.leafDirectoryOffset + h.offset, c = h.length;
|
|
3612
|
+
} else return;
|
|
3613
|
+
}
|
|
3614
|
+
throw new Error("Maximum directory depth exceeded");
|
|
3615
|
+
});
|
|
3616
|
+
}
|
|
3617
|
+
getZxy(t, e, r, n) {
|
|
3618
|
+
return m(this, null, function* () {
|
|
3619
|
+
try {
|
|
3620
|
+
return yield this.getZxyAttempt(t, e, r, n);
|
|
3621
|
+
} catch (s) {
|
|
3622
|
+
if (s instanceof v) return this.cache.invalidate(this.source), yield this.getZxyAttempt(t, e, r, n);
|
|
3623
|
+
throw s;
|
|
3624
|
+
}
|
|
3625
|
+
});
|
|
3626
|
+
}
|
|
3627
|
+
getMetadataAttempt() {
|
|
3628
|
+
return m(this, null, function* () {
|
|
3629
|
+
let t = yield this.cache.getHeader(this.source), e = yield this.source.getBytes(t.jsonMetadataOffset, t.jsonMetadataLength, void 0, t.etag), r = yield this.decompress(e.data, t.internalCompression), n = new TextDecoder("utf-8");
|
|
3630
|
+
return JSON.parse(n.decode(r));
|
|
3631
|
+
});
|
|
3632
|
+
}
|
|
3633
|
+
getMetadata() {
|
|
3634
|
+
return m(this, null, function* () {
|
|
3635
|
+
try {
|
|
3636
|
+
return yield this.getMetadataAttempt();
|
|
3637
|
+
} catch (t) {
|
|
3638
|
+
if (t instanceof v) return this.cache.invalidate(this.source), yield this.getMetadataAttempt();
|
|
3639
|
+
throw t;
|
|
3640
|
+
}
|
|
3641
|
+
});
|
|
3642
|
+
}
|
|
3643
|
+
getTileJson(t) {
|
|
3644
|
+
return m(this, null, function* () {
|
|
3645
|
+
let e = yield this.getHeader(), r = yield this.getMetadata(), n = _(e.tileType);
|
|
3646
|
+
return { tilejson: "3.0.0", scheme: "xyz", tiles: [`${t}/{z}/{x}/{y}${n}`], vector_layers: r.vector_layers, attribution: r.attribution, description: r.description, name: r.name, version: r.version, bounds: [e.minLon, e.minLat, e.maxLon, e.maxLat], center: [e.centerLon, e.centerLat, e.centerZoom], minzoom: e.minZoom, maxzoom: e.maxZoom };
|
|
3647
|
+
});
|
|
3648
|
+
}
|
|
3649
|
+
};
|
|
3650
|
+
l(H, "PMTiles");
|
|
3651
|
+
var w = H;
|
|
3652
|
+
|
|
3653
|
+
// src/pmtiles-browser.ts
|
|
3654
|
+
var registeredPmtilesProtocols = /* @__PURE__ */ new WeakSet();
|
|
3655
|
+
var maximumSectionBytes = 16 * 1024 * 1024;
|
|
3656
|
+
var maximumParserBytes = 32 * 1024 * 1024;
|
|
3657
|
+
var estimatedEntryBytes = 128;
|
|
3658
|
+
var tileflowPmtilesMaximumDirectoryDepth = 32;
|
|
3659
|
+
var tileflowPmtilesProtocol = "tileflow-pmtiles";
|
|
3660
|
+
var protocolPrefix = `${tileflowPmtilesProtocol}://`;
|
|
3661
|
+
function registerTileflowPmtilesProtocol(registry, options = {}) {
|
|
3662
|
+
if (registeredPmtilesProtocols.has(registry.addProtocol)) return;
|
|
3663
|
+
const maximumDirectoryDepth = normalizeMaximumDirectoryDepth(options.maximumDirectoryDepth);
|
|
3664
|
+
registry.addProtocol(
|
|
3665
|
+
tileflowPmtilesProtocol,
|
|
3666
|
+
new TileflowPmtilesProtocol(maximumDirectoryDepth).tile
|
|
3667
|
+
);
|
|
3668
|
+
registeredPmtilesProtocols.add(registry.addProtocol);
|
|
3669
|
+
}
|
|
3670
|
+
var TileflowPmtilesProtocol = class {
|
|
3671
|
+
constructor(maximumDirectoryDepth) {
|
|
3672
|
+
this.maximumDirectoryDepth = maximumDirectoryDepth;
|
|
3673
|
+
}
|
|
3674
|
+
maximumDirectoryDepth;
|
|
3675
|
+
#archives = /* @__PURE__ */ new Map();
|
|
3676
|
+
tilev4 = async (request, abortController) => {
|
|
3677
|
+
if (request.type === "json") {
|
|
3678
|
+
const archive2 = this.#archive(parseArchiveTarget(request.url));
|
|
3679
|
+
const header2 = await archive2.getHeader();
|
|
3680
|
+
const tileJson = await archive2.getTileJson(request.url);
|
|
3681
|
+
const data = header2.tileType === O.Mlt && isRecord2(tileJson) ? { ...tileJson, encoding: "mlt" } : tileJson;
|
|
3682
|
+
abortController.signal.throwIfAborted();
|
|
3683
|
+
return { data };
|
|
3684
|
+
}
|
|
3685
|
+
const parsed = parseTileTarget(request.url);
|
|
3686
|
+
const archive = this.#archive(parsed.archive);
|
|
3687
|
+
const header = await archive.getHeader();
|
|
3688
|
+
const response = await archive.getZxy(parsed.z, parsed.x, parsed.y, abortController.signal);
|
|
3689
|
+
abortController.signal.throwIfAborted();
|
|
3690
|
+
if (response) {
|
|
3691
|
+
return {
|
|
3692
|
+
data: new Uint8Array(response.data),
|
|
3693
|
+
...response.cacheControl ? { cacheControl: response.cacheControl } : {},
|
|
3694
|
+
...response.expires ? { expires: response.expires } : {}
|
|
3695
|
+
};
|
|
3696
|
+
}
|
|
3697
|
+
return {
|
|
3698
|
+
data: header.tileType === O.Mvt || header.tileType === O.Mlt ? new Uint8Array() : null
|
|
3699
|
+
};
|
|
3700
|
+
};
|
|
3701
|
+
tile = protocolCompatibility(this.tilev4);
|
|
3702
|
+
#archive(target) {
|
|
3703
|
+
let archive = this.#archives.get(target);
|
|
3704
|
+
if (!archive) {
|
|
3705
|
+
archive = new TileflowPmtilesArchive(target, this.maximumDirectoryDepth);
|
|
3706
|
+
this.#archives.set(target, archive);
|
|
3707
|
+
}
|
|
3708
|
+
return archive;
|
|
3709
|
+
}
|
|
3710
|
+
};
|
|
3711
|
+
var TileflowPmtilesArchive = class extends w {
|
|
3712
|
+
constructor(source, maximumDirectoryDepth) {
|
|
3713
|
+
super(source, void 0, boundedDecompress);
|
|
3714
|
+
this.maximumDirectoryDepth = maximumDirectoryDepth;
|
|
3715
|
+
}
|
|
3716
|
+
maximumDirectoryDepth;
|
|
3717
|
+
async getZxyAttempt(z, x3, y, signal) {
|
|
3718
|
+
const tileId = q(z, x3, y);
|
|
3719
|
+
const header = await this.cache.getHeader(this.source);
|
|
3720
|
+
signal?.throwIfAborted();
|
|
3721
|
+
if (z < header.minZoom || z > header.maxZoom) return void 0;
|
|
3722
|
+
let offset = header.rootDirectoryOffset;
|
|
3723
|
+
let length = header.rootDirectoryLength;
|
|
3724
|
+
const ancestors = /* @__PURE__ */ new Set();
|
|
3725
|
+
let entriesRead = 0;
|
|
3726
|
+
for (let depth = 0; depth <= this.maximumDirectoryDepth; depth += 1) {
|
|
3727
|
+
const key = `${offset}:${length}`;
|
|
3728
|
+
if (ancestors.has(key)) throw new Error("Tileflow PMTiles directory cycle is invalid.");
|
|
3729
|
+
ancestors.add(key);
|
|
3730
|
+
const directory = await this.cache.getDirectory(this.source, offset, length, header);
|
|
3731
|
+
signal?.throwIfAborted();
|
|
3732
|
+
entriesRead += directory.length;
|
|
3733
|
+
if (entriesRead * estimatedEntryBytes > maximumParserBytes) {
|
|
3734
|
+
throw new Error("Tileflow PMTiles traversal exceeded its memory budget.");
|
|
3735
|
+
}
|
|
3736
|
+
const entry = Q(directory, tileId);
|
|
3737
|
+
if (!entry) return void 0;
|
|
3738
|
+
if (entry.runLength > 0) {
|
|
3739
|
+
assertRelativeRange(entry.offset, entry.length, header.tileDataLength ?? 0);
|
|
3740
|
+
const response = await this.source.getBytes(
|
|
3741
|
+
header.tileDataOffset + entry.offset,
|
|
3742
|
+
entry.length,
|
|
3743
|
+
signal,
|
|
3744
|
+
header.etag
|
|
3745
|
+
);
|
|
3746
|
+
return {
|
|
3747
|
+
data: await this.decompress(response.data, header.tileCompression),
|
|
3748
|
+
cacheControl: response.cacheControl,
|
|
3749
|
+
expires: response.expires
|
|
3750
|
+
};
|
|
3751
|
+
}
|
|
3752
|
+
assertRelativeRange(entry.offset, entry.length, header.leafDirectoryLength ?? 0);
|
|
3753
|
+
offset = header.leafDirectoryOffset + entry.offset;
|
|
3754
|
+
length = entry.length;
|
|
3755
|
+
}
|
|
3756
|
+
throw new Error("Tileflow PMTiles directory depth exceeds its operational limit.");
|
|
3757
|
+
}
|
|
3758
|
+
};
|
|
3759
|
+
async function boundedDecompress(buffer, compression) {
|
|
3760
|
+
if (buffer.byteLength > maximumSectionBytes) {
|
|
3761
|
+
throw new Error("Tileflow PMTiles section exceeds its operational limit.");
|
|
3762
|
+
}
|
|
3763
|
+
if (compression === J.None) return buffer;
|
|
3764
|
+
if (compression !== J.Gzip) {
|
|
3765
|
+
throw new Error("Tileflow PMTiles compression is unsupported.");
|
|
3766
|
+
}
|
|
3767
|
+
const stream = new Blob([buffer]).stream().pipeThrough(new DecompressionStream("gzip"));
|
|
3768
|
+
const reader = stream.getReader();
|
|
3769
|
+
const chunks = [];
|
|
3770
|
+
let byteLength = 0;
|
|
3771
|
+
try {
|
|
3772
|
+
while (true) {
|
|
3773
|
+
const result = await reader.read();
|
|
3774
|
+
if (result.done) break;
|
|
3775
|
+
byteLength += result.value.byteLength;
|
|
3776
|
+
if (byteLength > maximumSectionBytes) {
|
|
3777
|
+
await reader.cancel();
|
|
3778
|
+
throw new Error("Tileflow PMTiles decompression exceeds its operational limit.");
|
|
3779
|
+
}
|
|
3780
|
+
chunks.push(result.value);
|
|
3781
|
+
}
|
|
3782
|
+
} finally {
|
|
3783
|
+
reader.releaseLock();
|
|
3784
|
+
}
|
|
3785
|
+
const output = new Uint8Array(byteLength);
|
|
3786
|
+
let offset = 0;
|
|
3787
|
+
for (const chunk of chunks) {
|
|
3788
|
+
output.set(chunk, offset);
|
|
3789
|
+
offset += chunk.byteLength;
|
|
3790
|
+
}
|
|
3791
|
+
return output.buffer;
|
|
3792
|
+
}
|
|
3793
|
+
function parseArchiveTarget(url) {
|
|
3794
|
+
if (!url.startsWith(protocolPrefix)) throw new Error("Invalid Tileflow PMTiles protocol URL.");
|
|
3795
|
+
const target = url.slice(protocolPrefix.length);
|
|
3796
|
+
if (!target) throw new Error("Invalid Tileflow PMTiles archive URL.");
|
|
3797
|
+
return target;
|
|
3798
|
+
}
|
|
3799
|
+
function parseTileTarget(url) {
|
|
3800
|
+
const target = parseArchiveTarget(url);
|
|
3801
|
+
const match = /^(.*)\/(\d+)\/(\d+)\/(\d+)(?:\.[A-Za-z0-9]+)?$/u.exec(target);
|
|
3802
|
+
if (!match?.[1] || !match[2] || !match[3] || !match[4]) {
|
|
3803
|
+
throw new Error("Invalid Tileflow PMTiles tile URL.");
|
|
3804
|
+
}
|
|
3805
|
+
return { archive: match[1], x: Number(match[3]), y: Number(match[4]), z: Number(match[2]) };
|
|
3806
|
+
}
|
|
3807
|
+
function assertRelativeRange(offset, length, sectionLength) {
|
|
3808
|
+
if (!Number.isSafeInteger(offset) || !Number.isSafeInteger(length) || length < 1 || offset < 0 || offset > sectionLength - length || length > maximumSectionBytes) {
|
|
3809
|
+
throw new Error("Tileflow PMTiles directory range is invalid.");
|
|
3810
|
+
}
|
|
3811
|
+
}
|
|
3812
|
+
function normalizeMaximumDirectoryDepth(value) {
|
|
3813
|
+
const depth = value ?? tileflowPmtilesMaximumDirectoryDepth;
|
|
3814
|
+
if (!Number.isInteger(depth) || depth < 1 || depth > 64) {
|
|
3815
|
+
throw new Error("Tileflow PMTiles maximumDirectoryDepth must be an integer from 1 to 64.");
|
|
3816
|
+
}
|
|
3817
|
+
return depth;
|
|
3818
|
+
}
|
|
3819
|
+
function isRecord2(value) {
|
|
3820
|
+
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
3821
|
+
}
|
|
3822
|
+
function protocolCompatibility(handler) {
|
|
3823
|
+
return (request, controllerOrCallback) => {
|
|
3824
|
+
if (controllerOrCallback instanceof AbortController) {
|
|
3825
|
+
return handler(request, controllerOrCallback);
|
|
3826
|
+
}
|
|
3827
|
+
const controller = new AbortController();
|
|
3828
|
+
void handler(request, controller).then(
|
|
3829
|
+
(response) => controllerOrCallback(
|
|
3830
|
+
void 0,
|
|
3831
|
+
response.data,
|
|
3832
|
+
response.cacheControl ?? "",
|
|
3833
|
+
response.expires ?? ""
|
|
3834
|
+
),
|
|
3835
|
+
(error) => controllerOrCallback(error instanceof Error ? error : new Error("PMTiles request failed."))
|
|
3836
|
+
);
|
|
3837
|
+
return { cancel: () => controller.abort() };
|
|
3838
|
+
};
|
|
3839
|
+
}
|
|
3840
|
+
|
|
2831
3841
|
// src/browser.ts
|
|
2832
3842
|
var systemColorSchemeListeners = /* @__PURE__ */ new Set();
|
|
2833
3843
|
var systemColorSchemeQuery;
|
|
@@ -3332,36 +4342,6 @@ function createTileflowTransformRequest(options) {
|
|
|
3332
4342
|
);
|
|
3333
4343
|
};
|
|
3334
4344
|
}
|
|
3335
|
-
function createTileflowMarkerController(options) {
|
|
3336
|
-
let markers = [];
|
|
3337
|
-
const clear = () => {
|
|
3338
|
-
const previousMarkers = markers;
|
|
3339
|
-
markers = [];
|
|
3340
|
-
removeMarkers(previousMarkers, options.remove);
|
|
3341
|
-
};
|
|
3342
|
-
return {
|
|
3343
|
-
clear,
|
|
3344
|
-
dispose: clear,
|
|
3345
|
-
replace(map, definitions) {
|
|
3346
|
-
clear();
|
|
3347
|
-
const nextMarkers = [];
|
|
3348
|
-
try {
|
|
3349
|
-
for (const definition of definitions) {
|
|
3350
|
-
const marker = options.create(definition);
|
|
3351
|
-
nextMarkers.push(marker);
|
|
3352
|
-
options.attach(marker, map, definition);
|
|
3353
|
-
}
|
|
3354
|
-
} catch (error) {
|
|
3355
|
-
try {
|
|
3356
|
-
removeMarkers(nextMarkers, options.remove);
|
|
3357
|
-
} catch {
|
|
3358
|
-
}
|
|
3359
|
-
throw error;
|
|
3360
|
-
}
|
|
3361
|
-
markers = nextMarkers;
|
|
3362
|
-
}
|
|
3363
|
-
};
|
|
3364
|
-
}
|
|
3365
4345
|
function applyTileflowRequest(url, request, analytics, sessionId, sessionController, worldRequestBridge) {
|
|
3366
4346
|
const requestUrl = request?.url ?? url;
|
|
3367
4347
|
if (sessionController) {
|
|
@@ -3411,35 +4391,22 @@ function disposeFunctions(disposers) {
|
|
|
3411
4391
|
function isPromiseLike(value) {
|
|
3412
4392
|
return Boolean(value && typeof value.then === "function");
|
|
3413
4393
|
}
|
|
3414
|
-
function removeMarkers(markers, remove) {
|
|
3415
|
-
let firstError;
|
|
3416
|
-
let failed = false;
|
|
3417
|
-
for (const marker of markers) {
|
|
3418
|
-
try {
|
|
3419
|
-
remove(marker);
|
|
3420
|
-
} catch (error) {
|
|
3421
|
-
if (!failed) firstError = error;
|
|
3422
|
-
failed = true;
|
|
3423
|
-
}
|
|
3424
|
-
}
|
|
3425
|
-
if (failed) {
|
|
3426
|
-
throw firstError;
|
|
3427
|
-
}
|
|
3428
|
-
}
|
|
3429
4394
|
export {
|
|
3430
4395
|
attachTileflowFairUseNotice,
|
|
3431
4396
|
attachTileflowMapLifecycle,
|
|
3432
|
-
createTileflowMarkerController,
|
|
3433
4397
|
createTileflowSessionStarter,
|
|
3434
4398
|
createTileflowThemeController,
|
|
3435
4399
|
createTileflowTransformRequest,
|
|
3436
4400
|
getTileflowSystemColorScheme,
|
|
3437
4401
|
loadTileflowStyleFonts,
|
|
3438
4402
|
registerTileflowContourProtocol,
|
|
4403
|
+
registerTileflowPmtilesProtocol,
|
|
3439
4404
|
registerTileflowWorldRequestBridge,
|
|
3440
4405
|
subscribeTileflowSystemColorScheme,
|
|
3441
4406
|
tileflowFairUseNoticeMessage,
|
|
3442
|
-
tileflowMaplibreContourVersion
|
|
4407
|
+
tileflowMaplibreContourVersion,
|
|
4408
|
+
tileflowPmtilesMaximumDirectoryDepth,
|
|
4409
|
+
tileflowPmtilesProtocol
|
|
3443
4410
|
};
|
|
3444
4411
|
/*! Bundled license information:
|
|
3445
4412
|
|