earthsdk3-cesium 3.7.0-beta.20 → 3.7.0-beta.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/vectorTilesWorker-DiivsDgI.js +1 -0
- package/dist/earthsdk3-cesium.iife.js +124 -1519
- package/dist/earthsdk3-cesium.js +12736 -14119
- package/dist/earthsdk3-cesium.umd.cjs +119 -1514
- package/dist/types/CzmObjects/general/CzmESMVTLayer/index.d.ts +1 -5
- package/dist/types/ESCesiumViewer/ViewerExtensions/ScreenManager/ScreenLayer.d.ts +1 -1
- package/dist/types/ESCesiumViewer/ViewerExtensions/ScreenManager/ScreenObjectPool.d.ts +4 -4
- package/dist/types/ESCesiumViewer/ViewerExtensions/VectorTilesManager/StyleManager.d.ts +1 -1
- package/dist/types/ESCesiumViewer/ViewerExtensions/VectorTilesManager/TileLoader.d.ts +6 -9
- package/dist/types/ESCesiumViewer/ViewerExtensions/VectorTilesManager/TileNode.d.ts +5 -7
- package/dist/types/ESCesiumViewer/ViewerExtensions/VectorTilesManager/TileRenderer.d.ts +3 -2
- package/dist/types/ESCesiumViewer/ViewerExtensions/VectorTilesManager/TilesCache.d.ts +0 -1
- package/dist/types/ESCesiumViewer/ViewerExtensions/VectorTilesManager/index.d.ts +13 -9
- package/dist/types/ESCesiumViewer/ViewerExtensions/VectorTilesManager/utils.d.ts +19 -3
- package/dist/types/ESCesiumViewer/ViewerExtensions/VectorTilesManager/vectorTilesWorker.d.ts +4 -1
- package/dist/types/ESCesiumViewer/ViewerExtensions/VectorTilesManager/vectorTilesWorker.inline.d.ts +1 -1
- package/dist/types/utils/base/index.d.ts +1 -0
- package/dist/types/utils/base/normalizeTileURL.d.ts +1 -0
- package/package.json +2 -2
|
@@ -6,13 +6,9 @@ export declare class CzmESMVTLayer extends CzmESVisualObject<ESMVTLayer> {
|
|
|
6
6
|
static readonly type: string;
|
|
7
7
|
private _czmImagery;
|
|
8
8
|
get czmImagery(): any;
|
|
9
|
-
/**
|
|
10
|
-
* 三部分组成,去除Layer的完整JSON,点Layer,其余Layer
|
|
11
|
-
*/
|
|
12
9
|
mvtLayerJson: {
|
|
13
10
|
mainJson: any;
|
|
14
|
-
|
|
15
|
-
otherJson: any[];
|
|
11
|
+
layersJson: any[];
|
|
16
12
|
};
|
|
17
13
|
mvtLayerJsonChanged: Event<[]>;
|
|
18
14
|
constructor(sceneObject: ESMVTLayer, czmViewer: ESCesiumViewer);
|
|
@@ -10,7 +10,7 @@ import { ScreenObject, ScreenObjectKey, ScreenObjectType } from "./ScreenObject"
|
|
|
10
10
|
*/
|
|
11
11
|
export declare class ScreenLayer extends Destroyable {
|
|
12
12
|
protected screenManager: ScreenManager;
|
|
13
|
-
|
|
13
|
+
screenManagerLayerName: string;
|
|
14
14
|
objects: Map<ScreenObjectKey, ScreenObject>;
|
|
15
15
|
czmViewer: ESCesiumViewer;
|
|
16
16
|
viewer: Cesium.Viewer;
|
|
@@ -9,10 +9,10 @@ export declare class ScreenObjectPool<T extends Cesium.Label | Cesium.Billboard>
|
|
|
9
9
|
private _minPoolRatio;
|
|
10
10
|
private _initialSize;
|
|
11
11
|
constructor(_collection: Cesium.LabelCollection | Cesium.BillboardCollection, initialSize?: number, options?: ScreenObjectPoolOptions);
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
12
|
+
add(style?: Partial<T>): T;
|
|
13
|
+
add(count: number, style?: Partial<T>): T[];
|
|
14
|
+
remove(obj: T): void;
|
|
15
|
+
remove(obj: T[]): void;
|
|
16
16
|
/** 更新对象样式 */
|
|
17
17
|
update(p: T, style?: Partial<T>): void;
|
|
18
18
|
/** 当前池中可用对象数量 */
|
|
@@ -9,7 +9,7 @@ export type LayerStyle = Exclude<LayerSpecification, BackgroundLayerSpecificatio
|
|
|
9
9
|
polylineStyle?: any;
|
|
10
10
|
};
|
|
11
11
|
export type mapboxLabel = CzmLabel & {
|
|
12
|
-
'text-transform'?: string;
|
|
12
|
+
'text-transform'?: (s: string) => string;
|
|
13
13
|
"maxWidth"?: number;
|
|
14
14
|
};
|
|
15
15
|
export declare const textTransform: {
|
|
@@ -3,6 +3,7 @@ import { Destroyable, SceneObjectKey } from "earthsdk3";
|
|
|
3
3
|
import { CzmESMVTLayer } from "../../../CzmObjects";
|
|
4
4
|
import { TileNode } from './TileNode';
|
|
5
5
|
import { TilesCache } from "./TilesCache";
|
|
6
|
+
import { StyleManager } from "./StyleManager";
|
|
6
7
|
/**
|
|
7
8
|
* 瓦片加载器
|
|
8
9
|
* 只负责加载瓦片数据并解析为GeoJson格式
|
|
@@ -12,7 +13,7 @@ export declare class TileLoader extends Destroyable {
|
|
|
12
13
|
/**
|
|
13
14
|
* 等待请求的瓦片服务
|
|
14
15
|
*/
|
|
15
|
-
pendingRequests: Map<SceneObjectKey, Set<string>>;
|
|
16
|
+
static pendingRequests: Map<SceneObjectKey, Set<string>>;
|
|
16
17
|
/**
|
|
17
18
|
* 数据源
|
|
18
19
|
*/
|
|
@@ -23,15 +24,11 @@ export declare class TileLoader extends Destroyable {
|
|
|
23
24
|
maxzoom?: number;
|
|
24
25
|
}>>;
|
|
25
26
|
tilesCache: TilesCache;
|
|
26
|
-
|
|
27
|
-
* 切片方案
|
|
28
|
-
* xyz: 谷歌瓦片方案
|
|
29
|
-
* tms: 瓦片服务方案
|
|
30
|
-
*/
|
|
31
|
-
tileSchemes: Map<SceneObjectKey, "xyz" | "tms">;
|
|
27
|
+
styleManager: StyleManager;
|
|
32
28
|
constructor(vectorTilesManager: VectorTilesManager);
|
|
33
|
-
add(czmESMVTLayer: CzmESMVTLayer): void
|
|
29
|
+
add(czmESMVTLayer: CzmESMVTLayer): Promise<void>;
|
|
34
30
|
remove(czmESMVTLayer: CzmESMVTLayer): void;
|
|
35
|
-
fetchTile(sceneObjectId: SceneObjectKey, tileKey: string): Promise<TileNode
|
|
31
|
+
fetchTile(sceneObjectId: SceneObjectKey, tileKey: string): Promise<TileNode>;
|
|
32
|
+
cancelTile(SceneObjectId: SceneObjectKey, tileKey: string): void;
|
|
36
33
|
private fetchUrl;
|
|
37
34
|
}
|
|
@@ -6,19 +6,17 @@ export declare class TileNode extends Destroyable {
|
|
|
6
6
|
z: number;
|
|
7
7
|
tileKey: TileKey;
|
|
8
8
|
parent: TileNode | null;
|
|
9
|
-
children:
|
|
9
|
+
children: Array<TileNode>;
|
|
10
10
|
data: Map<sourceName, Map<layerName, Set<GeoJSON.Feature<Exclude<GeoJSON.Geometry, GeoJSON.GeometryCollection>>>>>;
|
|
11
11
|
private _state;
|
|
12
12
|
get state(): TileNodeState;
|
|
13
13
|
set state(value: TileNodeState);
|
|
14
14
|
get stateChanged(): import("earthsdk3").Listener<[TileNodeState, TileNodeState]>;
|
|
15
|
-
refCount: number;
|
|
16
|
-
lastUsedFrame: number;
|
|
17
|
-
screenIds: Set<string> | null;
|
|
18
15
|
/** 瓦片渲染结果,可以是 Canvas 或 ImageBitmap(优先 ImageBitmap,减少主线程绘制开销) */
|
|
19
|
-
image:
|
|
20
|
-
|
|
21
|
-
|
|
16
|
+
image: Map<sourceName, {
|
|
17
|
+
"polygon": ImageBitmap;
|
|
18
|
+
"polyline": ImageBitmap;
|
|
19
|
+
}>;
|
|
22
20
|
constructor(tileCache: Map<string, TileNode | undefined>, tileKey: TileKey);
|
|
23
21
|
attachToParent(tileCache: Map<string, TileNode | undefined>): void;
|
|
24
22
|
getParentTileKey(): string | undefined;
|
|
@@ -1,20 +1,21 @@
|
|
|
1
1
|
import { ScreenManager } from "../../../ESCesiumViewer";
|
|
2
2
|
import { Destroyable, SceneObjectKey } from "earthsdk3";
|
|
3
3
|
import { StyleManager } from "./StyleManager";
|
|
4
|
-
import { TileKey } from "./index";
|
|
4
|
+
import { TileKey, VectorTilesManager } from "./index";
|
|
5
5
|
import { TileNode } from "./TileNode";
|
|
6
6
|
/**
|
|
7
7
|
* 瓦片渲染器
|
|
8
8
|
* 将解析后的GeoJson点数据通过屏幕管理器渲染到屏幕上
|
|
9
9
|
*/
|
|
10
10
|
export declare class TileRenderer extends Destroyable {
|
|
11
|
+
vectorTilesManager: VectorTilesManager;
|
|
11
12
|
screenManager: ScreenManager;
|
|
12
13
|
styleManager: StyleManager;
|
|
13
14
|
/**
|
|
14
15
|
* 加载的瓦片对应的屏幕对象id
|
|
15
16
|
*/
|
|
16
17
|
renderedTiles: Map<SceneObjectKey, Map<TileKey, Set<string>>>;
|
|
17
|
-
constructor(screenManager: ScreenManager, styleManager: StyleManager);
|
|
18
|
+
constructor(vectorTilesManager: VectorTilesManager, screenManager: ScreenManager, styleManager: StyleManager);
|
|
18
19
|
renderTile(sceneObjectId: SceneObjectKey, tileNode: TileNode): void;
|
|
19
20
|
update(sceneObjectId: SceneObjectKey, screenObjectIds: Set<string>, show: boolean): void;
|
|
20
21
|
update(sceneObjectId: SceneObjectKey, tileKey: string, show: boolean): void;
|
|
@@ -25,5 +25,4 @@ export declare class TilesCache extends Destroyable {
|
|
|
25
25
|
remove(sceneObject: SceneObjectKey, tileKey: TileKey): void;
|
|
26
26
|
remove(sceneObject: CzmESMVTLayer, tileKey: TileKey): void;
|
|
27
27
|
requestImage(sceneObjectId: SceneObjectKey, x: number, y: number, z: number): Promise<HTMLCanvasElement | ImageBitmap>;
|
|
28
|
-
private _requestImageWorker;
|
|
29
28
|
}
|
|
@@ -7,6 +7,7 @@ import { EventManager } from "./EventManager";
|
|
|
7
7
|
import { CzmESMVTLayer } from "../../../index";
|
|
8
8
|
import * as Cesium from 'cesium';
|
|
9
9
|
import { WorkerPool } from "./WorkerPool";
|
|
10
|
+
export declare function createWorker(): Worker;
|
|
10
11
|
/**
|
|
11
12
|
* Viewer Camera/LOD
|
|
12
13
|
* ↓
|
|
@@ -34,21 +35,24 @@ export declare const enum TileNodeState {
|
|
|
34
35
|
export declare class VectorTilesManager extends Destroyable {
|
|
35
36
|
viewer: Cesium.Viewer;
|
|
36
37
|
czmESMVTLayers: Map<SceneObjectKey, CzmESMVTLayer>;
|
|
38
|
+
styleManager: StyleManager;
|
|
39
|
+
eventManager: EventManager;
|
|
37
40
|
tilesCache: TilesCache;
|
|
38
41
|
tileLoader: TileLoader;
|
|
39
42
|
tileRenderer: TileRenderer;
|
|
40
|
-
styleManager: StyleManager;
|
|
41
|
-
eventManager: EventManager;
|
|
42
43
|
lastImageryTileMap: Map<SceneObjectKey, Set<TileKey>>;
|
|
43
|
-
workerPool
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
44
|
+
workerPool?: WorkerPool;
|
|
45
|
+
textDimensionsCache: Map<string, {
|
|
46
|
+
width: number;
|
|
47
|
+
minx: number;
|
|
48
|
+
}>;
|
|
48
49
|
/**
|
|
49
|
-
*
|
|
50
|
+
* 切片方案
|
|
51
|
+
* xyz: 谷歌瓦片方案
|
|
52
|
+
* tms: 瓦片服务方案
|
|
50
53
|
*/
|
|
51
|
-
|
|
54
|
+
tileSchemes: Map<SceneObjectKey, "xyz" | "tms">;
|
|
55
|
+
tileSize: Map<SceneObjectKey, number>;
|
|
52
56
|
constructor(viewer: Cesium.Viewer);
|
|
53
57
|
add(czmESMVTLayer: CzmESMVTLayer): Promise<void>;
|
|
54
58
|
remove(czmESMVTLayer: CzmESMVTLayer): void;
|
|
@@ -1,6 +1,22 @@
|
|
|
1
1
|
import * as Cesium from "cesium";
|
|
2
|
+
import { VectorTilesManager } from ".";
|
|
2
3
|
export declare function getMapboxTextField(textField: any, zoom: number): string | string[] | null;
|
|
3
4
|
export declare function tileDataToGeoJSON(tileData: Record<string, any>): Map<string, Set<any>>;
|
|
4
|
-
export declare function interpolateTextAlongPath(viewer: Cesium.Viewer, positions: Cesium.Cartesian3[], text: string, font: string): Map<Cesium.Cartesian3, Cesium.Cartesian3[]>;
|
|
5
|
-
export declare function wrapByPixel(
|
|
6
|
-
export declare function
|
|
5
|
+
export declare function interpolateTextAlongPath(vectorTilesManager: VectorTilesManager, viewer: Cesium.Viewer, positions: Cesium.Cartesian3[], text: string, font: string): Map<Cesium.Cartesian3, Cesium.Cartesian3[]>;
|
|
6
|
+
export declare function wrapByPixel(vectorTilesManager: VectorTilesManager, text: string | undefined, font: string, maxWidth: number): string;
|
|
7
|
+
export declare function getColorRgba(color: string, opacity?: number, toString?: boolean): string | number[];
|
|
8
|
+
export declare function evalStops(stops: [number, number][] | [number, string][]): ((z: number) => number | undefined) | ((z: number) => string | undefined) | undefined;
|
|
9
|
+
export declare function compileExpression(expr: any): ((z: number, properties: any) => any) | undefined;
|
|
10
|
+
export declare function getMapboxEval(mapboxStyle: any): ((z: number, properties: any) => any) | undefined;
|
|
11
|
+
export declare function getParentTileKey(tileKey: string): string;
|
|
12
|
+
export declare function getParentTileKey(x: number, y: number, z: number): {
|
|
13
|
+
x: number;
|
|
14
|
+
y: number;
|
|
15
|
+
z: number;
|
|
16
|
+
};
|
|
17
|
+
export declare function getChildTileKey(tileKey: string): string[];
|
|
18
|
+
export declare function getChildTileKey(x: number, y: number, z: number): {
|
|
19
|
+
x: number;
|
|
20
|
+
y: number;
|
|
21
|
+
z: number;
|
|
22
|
+
}[];
|
package/dist/types/ESCesiumViewer/ViewerExtensions/VectorTilesManager/vectorTilesWorker.inline.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const _default: "\"use strict\";\n(() => {\n // ../../node_modules/.pnpm/pbf@4.0.1/node_modules/pbf/index.js\n var SHIFT_LEFT_32 = (1 << 16) * (1 << 16);\n var SHIFT_RIGHT_32 = 1 / SHIFT_LEFT_32;\n var TEXT_DECODER_MIN_LENGTH = 12;\n var utf8TextDecoder = typeof TextDecoder === \"undefined\" ? null : new TextDecoder(\"utf-8\");\n var PBF_VARINT = 0;\n var PBF_FIXED64 = 1;\n var PBF_BYTES = 2;\n var PBF_FIXED32 = 5;\n var Pbf = class {\n /**\n * @param {Uint8Array | ArrayBuffer} [buf]\n */\n constructor(buf = new Uint8Array(16)) {\n this.buf = ArrayBuffer.isView(buf) ? buf : new Uint8Array(buf);\n this.dataView = new DataView(this.buf.buffer);\n this.pos = 0;\n this.type = 0;\n this.length = this.buf.length;\n }\n // === READING =================================================================\n /**\n * @template T\n * @param {(tag: number, result: T, pbf: Pbf) => void} readField\n * @param {T} result\n * @param {number} [end]\n */\n readFields(readField, result, end = this.length) {\n while (this.pos < end) {\n const val = this.readVarint(), tag = val >> 3, startPos = this.pos;\n this.type = val & 7;\n readField(tag, result, this);\n if (this.pos === startPos) this.skip(val);\n }\n return result;\n }\n /**\n * @template T\n * @param {(tag: number, result: T, pbf: Pbf) => void} readField\n * @param {T} result\n */\n readMessage(readField, result) {\n return this.readFields(readField, result, this.readVarint() + this.pos);\n }\n readFixed32() {\n const val = this.dataView.getUint32(this.pos, true);\n this.pos += 4;\n return val;\n }\n readSFixed32() {\n const val = this.dataView.getInt32(this.pos, true);\n this.pos += 4;\n return val;\n }\n // 64-bit int handling is based on github.com/dpw/node-buffer-more-ints (MIT-licensed)\n readFixed64() {\n const val = this.dataView.getUint32(this.pos, true) + this.dataView.getUint32(this.pos + 4, true) * SHIFT_LEFT_32;\n this.pos += 8;\n return val;\n }\n readSFixed64() {\n const val = this.dataView.getUint32(this.pos, true) + this.dataView.getInt32(this.pos + 4, true) * SHIFT_LEFT_32;\n this.pos += 8;\n return val;\n }\n readFloat() {\n const val = this.dataView.getFloat32(this.pos, true);\n this.pos += 4;\n return val;\n }\n readDouble() {\n const val = this.dataView.getFloat64(this.pos, true);\n this.pos += 8;\n return val;\n }\n /**\n * @param {boolean} [isSigned]\n */\n readVarint(isSigned) {\n const buf = this.buf;\n let val, b;\n b = buf[this.pos++];\n val = b & 127;\n if (b < 128) return val;\n b = buf[this.pos++];\n val |= (b & 127) << 7;\n if (b < 128) return val;\n b = buf[this.pos++];\n val |= (b & 127) << 14;\n if (b < 128) return val;\n b = buf[this.pos++];\n val |= (b & 127) << 21;\n if (b < 128) return val;\n b = buf[this.pos];\n val |= (b & 15) << 28;\n return readVarintRemainder(val, isSigned, this);\n }\n readVarint64() {\n return this.readVarint(true);\n }\n readSVarint() {\n const num = this.readVarint();\n return num % 2 === 1 ? (num + 1) / -2 : num / 2;\n }\n readBoolean() {\n return Boolean(this.readVarint());\n }\n readString() {\n const end = this.readVarint() + this.pos;\n const pos = this.pos;\n this.pos = end;\n if (end - pos >= TEXT_DECODER_MIN_LENGTH && utf8TextDecoder) {\n return utf8TextDecoder.decode(this.buf.subarray(pos, end));\n }\n return readUtf8(this.buf, pos, end);\n }\n readBytes() {\n const end = this.readVarint() + this.pos, buffer = this.buf.subarray(this.pos, end);\n this.pos = end;\n return buffer;\n }\n // verbose for performance reasons; doesn't affect gzipped size\n /**\n * @param {number[]} [arr]\n * @param {boolean} [isSigned]\n */\n readPackedVarint(arr = [], isSigned) {\n const end = this.readPackedEnd();\n while (this.pos < end) arr.push(this.readVarint(isSigned));\n return arr;\n }\n /** @param {number[]} [arr] */\n readPackedSVarint(arr = []) {\n const end = this.readPackedEnd();\n while (this.pos < end) arr.push(this.readSVarint());\n return arr;\n }\n /** @param {boolean[]} [arr] */\n readPackedBoolean(arr = []) {\n const end = this.readPackedEnd();\n while (this.pos < end) arr.push(this.readBoolean());\n return arr;\n }\n /** @param {number[]} [arr] */\n readPackedFloat(arr = []) {\n const end = this.readPackedEnd();\n while (this.pos < end) arr.push(this.readFloat());\n return arr;\n }\n /** @param {number[]} [arr] */\n readPackedDouble(arr = []) {\n const end = this.readPackedEnd();\n while (this.pos < end) arr.push(this.readDouble());\n return arr;\n }\n /** @param {number[]} [arr] */\n readPackedFixed32(arr = []) {\n const end = this.readPackedEnd();\n while (this.pos < end) arr.push(this.readFixed32());\n return arr;\n }\n /** @param {number[]} [arr] */\n readPackedSFixed32(arr = []) {\n const end = this.readPackedEnd();\n while (this.pos < end) arr.push(this.readSFixed32());\n return arr;\n }\n /** @param {number[]} [arr] */\n readPackedFixed64(arr = []) {\n const end = this.readPackedEnd();\n while (this.pos < end) arr.push(this.readFixed64());\n return arr;\n }\n /** @param {number[]} [arr] */\n readPackedSFixed64(arr = []) {\n const end = this.readPackedEnd();\n while (this.pos < end) arr.push(this.readSFixed64());\n return arr;\n }\n readPackedEnd() {\n return this.type === PBF_BYTES ? this.readVarint() + this.pos : this.pos + 1;\n }\n /** @param {number} val */\n skip(val) {\n const type = val & 7;\n if (type === PBF_VARINT) while (this.buf[this.pos++] > 127) {\n }\n else if (type === PBF_BYTES) this.pos = this.readVarint() + this.pos;\n else if (type === PBF_FIXED32) this.pos += 4;\n else if (type === PBF_FIXED64) this.pos += 8;\n else throw new Error(`Unimplemented type: ${type}`);\n }\n // === WRITING =================================================================\n /**\n * @param {number} tag\n * @param {number} type\n */\n writeTag(tag, type) {\n this.writeVarint(tag << 3 | type);\n }\n /** @param {number} min */\n realloc(min) {\n let length = this.length || 16;\n while (length < this.pos + min) length *= 2;\n if (length !== this.length) {\n const buf = new Uint8Array(length);\n buf.set(this.buf);\n this.buf = buf;\n this.dataView = new DataView(buf.buffer);\n this.length = length;\n }\n }\n finish() {\n this.length = this.pos;\n this.pos = 0;\n return this.buf.subarray(0, this.length);\n }\n /** @param {number} val */\n writeFixed32(val) {\n this.realloc(4);\n this.dataView.setInt32(this.pos, val, true);\n this.pos += 4;\n }\n /** @param {number} val */\n writeSFixed32(val) {\n this.realloc(4);\n this.dataView.setInt32(this.pos, val, true);\n this.pos += 4;\n }\n /** @param {number} val */\n writeFixed64(val) {\n this.realloc(8);\n this.dataView.setInt32(this.pos, val & -1, true);\n this.dataView.setInt32(this.pos + 4, Math.floor(val * SHIFT_RIGHT_32), true);\n this.pos += 8;\n }\n /** @param {number} val */\n writeSFixed64(val) {\n this.realloc(8);\n this.dataView.setInt32(this.pos, val & -1, true);\n this.dataView.setInt32(this.pos + 4, Math.floor(val * SHIFT_RIGHT_32), true);\n this.pos += 8;\n }\n /** @param {number} val */\n writeVarint(val) {\n val = +val || 0;\n if (val > 268435455 || val < 0) {\n writeBigVarint(val, this);\n return;\n }\n this.realloc(4);\n this.buf[this.pos++] = val & 127 | (val > 127 ? 128 : 0);\n if (val <= 127) return;\n this.buf[this.pos++] = (val >>>= 7) & 127 | (val > 127 ? 128 : 0);\n if (val <= 127) return;\n this.buf[this.pos++] = (val >>>= 7) & 127 | (val > 127 ? 128 : 0);\n if (val <= 127) return;\n this.buf[this.pos++] = val >>> 7 & 127;\n }\n /** @param {number} val */\n writeSVarint(val) {\n this.writeVarint(val < 0 ? -val * 2 - 1 : val * 2);\n }\n /** @param {boolean} val */\n writeBoolean(val) {\n this.writeVarint(+val);\n }\n /** @param {string} str */\n writeString(str) {\n str = String(str);\n this.realloc(str.length * 4);\n this.pos++;\n const startPos = this.pos;\n this.pos = writeUtf8(this.buf, str, this.pos);\n const len = this.pos - startPos;\n if (len >= 128) makeRoomForExtraLength(startPos, len, this);\n this.pos = startPos - 1;\n this.writeVarint(len);\n this.pos += len;\n }\n /** @param {number} val */\n writeFloat(val) {\n this.realloc(4);\n this.dataView.setFloat32(this.pos, val, true);\n this.pos += 4;\n }\n /** @param {number} val */\n writeDouble(val) {\n this.realloc(8);\n this.dataView.setFloat64(this.pos, val, true);\n this.pos += 8;\n }\n /** @param {Uint8Array} buffer */\n writeBytes(buffer) {\n const len = buffer.length;\n this.writeVarint(len);\n this.realloc(len);\n for (let i = 0; i < len; i++) this.buf[this.pos++] = buffer[i];\n }\n /**\n * @template T\n * @param {(obj: T, pbf: Pbf) => void} fn\n * @param {T} obj\n */\n writeRawMessage(fn, obj) {\n this.pos++;\n const startPos = this.pos;\n fn(obj, this);\n const len = this.pos - startPos;\n if (len >= 128) makeRoomForExtraLength(startPos, len, this);\n this.pos = startPos - 1;\n this.writeVarint(len);\n this.pos += len;\n }\n /**\n * @template T\n * @param {number} tag\n * @param {(obj: T, pbf: Pbf) => void} fn\n * @param {T} obj\n */\n writeMessage(tag, fn, obj) {\n this.writeTag(tag, PBF_BYTES);\n this.writeRawMessage(fn, obj);\n }\n /**\n * @param {number} tag\n * @param {number[]} arr\n */\n writePackedVarint(tag, arr) {\n if (arr.length) this.writeMessage(tag, writePackedVarint, arr);\n }\n /**\n * @param {number} tag\n * @param {number[]} arr\n */\n writePackedSVarint(tag, arr) {\n if (arr.length) this.writeMessage(tag, writePackedSVarint, arr);\n }\n /**\n * @param {number} tag\n * @param {boolean[]} arr\n */\n writePackedBoolean(tag, arr) {\n if (arr.length) this.writeMessage(tag, writePackedBoolean, arr);\n }\n /**\n * @param {number} tag\n * @param {number[]} arr\n */\n writePackedFloat(tag, arr) {\n if (arr.length) this.writeMessage(tag, writePackedFloat, arr);\n }\n /**\n * @param {number} tag\n * @param {number[]} arr\n */\n writePackedDouble(tag, arr) {\n if (arr.length) this.writeMessage(tag, writePackedDouble, arr);\n }\n /**\n * @param {number} tag\n * @param {number[]} arr\n */\n writePackedFixed32(tag, arr) {\n if (arr.length) this.writeMessage(tag, writePackedFixed32, arr);\n }\n /**\n * @param {number} tag\n * @param {number[]} arr\n */\n writePackedSFixed32(tag, arr) {\n if (arr.length) this.writeMessage(tag, writePackedSFixed32, arr);\n }\n /**\n * @param {number} tag\n * @param {number[]} arr\n */\n writePackedFixed64(tag, arr) {\n if (arr.length) this.writeMessage(tag, writePackedFixed64, arr);\n }\n /**\n * @param {number} tag\n * @param {number[]} arr\n */\n writePackedSFixed64(tag, arr) {\n if (arr.length) this.writeMessage(tag, writePackedSFixed64, arr);\n }\n /**\n * @param {number} tag\n * @param {Uint8Array} buffer\n */\n writeBytesField(tag, buffer) {\n this.writeTag(tag, PBF_BYTES);\n this.writeBytes(buffer);\n }\n /**\n * @param {number} tag\n * @param {number} val\n */\n writeFixed32Field(tag, val) {\n this.writeTag(tag, PBF_FIXED32);\n this.writeFixed32(val);\n }\n /**\n * @param {number} tag\n * @param {number} val\n */\n writeSFixed32Field(tag, val) {\n this.writeTag(tag, PBF_FIXED32);\n this.writeSFixed32(val);\n }\n /**\n * @param {number} tag\n * @param {number} val\n */\n writeFixed64Field(tag, val) {\n this.writeTag(tag, PBF_FIXED64);\n this.writeFixed64(val);\n }\n /**\n * @param {number} tag\n * @param {number} val\n */\n writeSFixed64Field(tag, val) {\n this.writeTag(tag, PBF_FIXED64);\n this.writeSFixed64(val);\n }\n /**\n * @param {number} tag\n * @param {number} val\n */\n writeVarintField(tag, val) {\n this.writeTag(tag, PBF_VARINT);\n this.writeVarint(val);\n }\n /**\n * @param {number} tag\n * @param {number} val\n */\n writeSVarintField(tag, val) {\n this.writeTag(tag, PBF_VARINT);\n this.writeSVarint(val);\n }\n /**\n * @param {number} tag\n * @param {string} str\n */\n writeStringField(tag, str) {\n this.writeTag(tag, PBF_BYTES);\n this.writeString(str);\n }\n /**\n * @param {number} tag\n * @param {number} val\n */\n writeFloatField(tag, val) {\n this.writeTag(tag, PBF_FIXED32);\n this.writeFloat(val);\n }\n /**\n * @param {number} tag\n * @param {number} val\n */\n writeDoubleField(tag, val) {\n this.writeTag(tag, PBF_FIXED64);\n this.writeDouble(val);\n }\n /**\n * @param {number} tag\n * @param {boolean} val\n */\n writeBooleanField(tag, val) {\n this.writeVarintField(tag, +val);\n }\n };\n function readVarintRemainder(l, s, p) {\n const buf = p.buf;\n let h, b;\n b = buf[p.pos++];\n h = (b & 112) >> 4;\n if (b < 128) return toNum(l, h, s);\n b = buf[p.pos++];\n h |= (b & 127) << 3;\n if (b < 128) return toNum(l, h, s);\n b = buf[p.pos++];\n h |= (b & 127) << 10;\n if (b < 128) return toNum(l, h, s);\n b = buf[p.pos++];\n h |= (b & 127) << 17;\n if (b < 128) return toNum(l, h, s);\n b = buf[p.pos++];\n h |= (b & 127) << 24;\n if (b < 128) return toNum(l, h, s);\n b = buf[p.pos++];\n h |= (b & 1) << 31;\n if (b < 128) return toNum(l, h, s);\n throw new Error(\"Expected varint not more than 10 bytes\");\n }\n function toNum(low, high, isSigned) {\n return isSigned ? high * 4294967296 + (low >>> 0) : (high >>> 0) * 4294967296 + (low >>> 0);\n }\n function writeBigVarint(val, pbf) {\n let low, high;\n if (val >= 0) {\n low = val % 4294967296 | 0;\n high = val / 4294967296 | 0;\n } else {\n low = ~(-val % 4294967296);\n high = ~(-val / 4294967296);\n if (low ^ 4294967295) {\n low = low + 1 | 0;\n } else {\n low = 0;\n high = high + 1 | 0;\n }\n }\n if (val >= 18446744073709552e3 || val < -18446744073709552e3) {\n throw new Error(\"Given varint doesn't fit into 10 bytes\");\n }\n pbf.realloc(10);\n writeBigVarintLow(low, high, pbf);\n writeBigVarintHigh(high, pbf);\n }\n function writeBigVarintLow(low, high, pbf) {\n pbf.buf[pbf.pos++] = low & 127 | 128;\n low >>>= 7;\n pbf.buf[pbf.pos++] = low & 127 | 128;\n low >>>= 7;\n pbf.buf[pbf.pos++] = low & 127 | 128;\n low >>>= 7;\n pbf.buf[pbf.pos++] = low & 127 | 128;\n low >>>= 7;\n pbf.buf[pbf.pos] = low & 127;\n }\n function writeBigVarintHigh(high, pbf) {\n const lsb = (high & 7) << 4;\n pbf.buf[pbf.pos++] |= lsb | ((high >>>= 3) ? 128 : 0);\n if (!high) return;\n pbf.buf[pbf.pos++] = high & 127 | ((high >>>= 7) ? 128 : 0);\n if (!high) return;\n pbf.buf[pbf.pos++] = high & 127 | ((high >>>= 7) ? 128 : 0);\n if (!high) return;\n pbf.buf[pbf.pos++] = high & 127 | ((high >>>= 7) ? 128 : 0);\n if (!high) return;\n pbf.buf[pbf.pos++] = high & 127 | ((high >>>= 7) ? 128 : 0);\n if (!high) return;\n pbf.buf[pbf.pos++] = high & 127;\n }\n function makeRoomForExtraLength(startPos, len, pbf) {\n const extraLen = len <= 16383 ? 1 : len <= 2097151 ? 2 : len <= 268435455 ? 3 : Math.floor(Math.log(len) / (Math.LN2 * 7));\n pbf.realloc(extraLen);\n for (let i = pbf.pos - 1; i >= startPos; i--) pbf.buf[i + extraLen] = pbf.buf[i];\n }\n function writePackedVarint(arr, pbf) {\n for (let i = 0; i < arr.length; i++) pbf.writeVarint(arr[i]);\n }\n function writePackedSVarint(arr, pbf) {\n for (let i = 0; i < arr.length; i++) pbf.writeSVarint(arr[i]);\n }\n function writePackedFloat(arr, pbf) {\n for (let i = 0; i < arr.length; i++) pbf.writeFloat(arr[i]);\n }\n function writePackedDouble(arr, pbf) {\n for (let i = 0; i < arr.length; i++) pbf.writeDouble(arr[i]);\n }\n function writePackedBoolean(arr, pbf) {\n for (let i = 0; i < arr.length; i++) pbf.writeBoolean(arr[i]);\n }\n function writePackedFixed32(arr, pbf) {\n for (let i = 0; i < arr.length; i++) pbf.writeFixed32(arr[i]);\n }\n function writePackedSFixed32(arr, pbf) {\n for (let i = 0; i < arr.length; i++) pbf.writeSFixed32(arr[i]);\n }\n function writePackedFixed64(arr, pbf) {\n for (let i = 0; i < arr.length; i++) pbf.writeFixed64(arr[i]);\n }\n function writePackedSFixed64(arr, pbf) {\n for (let i = 0; i < arr.length; i++) pbf.writeSFixed64(arr[i]);\n }\n function readUtf8(buf, pos, end) {\n let str = \"\";\n let i = pos;\n while (i < end) {\n const b0 = buf[i];\n let c = null;\n let bytesPerSequence = b0 > 239 ? 4 : b0 > 223 ? 3 : b0 > 191 ? 2 : 1;\n if (i + bytesPerSequence > end) break;\n let b1, b2, b3;\n if (bytesPerSequence === 1) {\n if (b0 < 128) {\n c = b0;\n }\n } else if (bytesPerSequence === 2) {\n b1 = buf[i + 1];\n if ((b1 & 192) === 128) {\n c = (b0 & 31) << 6 | b1 & 63;\n if (c <= 127) {\n c = null;\n }\n }\n } else if (bytesPerSequence === 3) {\n b1 = buf[i + 1];\n b2 = buf[i + 2];\n if ((b1 & 192) === 128 && (b2 & 192) === 128) {\n c = (b0 & 15) << 12 | (b1 & 63) << 6 | b2 & 63;\n if (c <= 2047 || c >= 55296 && c <= 57343) {\n c = null;\n }\n }\n } else if (bytesPerSequence === 4) {\n b1 = buf[i + 1];\n b2 = buf[i + 2];\n b3 = buf[i + 3];\n if ((b1 & 192) === 128 && (b2 & 192) === 128 && (b3 & 192) === 128) {\n c = (b0 & 15) << 18 | (b1 & 63) << 12 | (b2 & 63) << 6 | b3 & 63;\n if (c <= 65535 || c >= 1114112) {\n c = null;\n }\n }\n }\n if (c === null) {\n c = 65533;\n bytesPerSequence = 1;\n } else if (c > 65535) {\n c -= 65536;\n str += String.fromCharCode(c >>> 10 & 1023 | 55296);\n c = 56320 | c & 1023;\n }\n str += String.fromCharCode(c);\n i += bytesPerSequence;\n }\n return str;\n }\n function writeUtf8(buf, str, pos) {\n for (let i = 0, c, lead; i < str.length; i++) {\n c = str.charCodeAt(i);\n if (c > 55295 && c < 57344) {\n if (lead) {\n if (c < 56320) {\n buf[pos++] = 239;\n buf[pos++] = 191;\n buf[pos++] = 189;\n lead = c;\n continue;\n } else {\n c = lead - 55296 << 10 | c - 56320 | 65536;\n lead = null;\n }\n } else {\n if (c > 56319 || i + 1 === str.length) {\n buf[pos++] = 239;\n buf[pos++] = 191;\n buf[pos++] = 189;\n } else {\n lead = c;\n }\n continue;\n }\n } else if (lead) {\n buf[pos++] = 239;\n buf[pos++] = 191;\n buf[pos++] = 189;\n lead = null;\n }\n if (c < 128) {\n buf[pos++] = c;\n } else {\n if (c < 2048) {\n buf[pos++] = c >> 6 | 192;\n } else {\n if (c < 65536) {\n buf[pos++] = c >> 12 | 224;\n } else {\n buf[pos++] = c >> 18 | 240;\n buf[pos++] = c >> 12 & 63 | 128;\n }\n buf[pos++] = c >> 6 & 63 | 128;\n }\n buf[pos++] = c & 63 | 128;\n }\n }\n return pos;\n }\n\n // ../../node_modules/.pnpm/@mapbox+point-geometry@1.1.0/node_modules/@mapbox/point-geometry/index.js\n function Point(x, y) {\n this.x = x;\n this.y = y;\n }\n Point.prototype = {\n /**\n * Clone this point, returning a new point that can be modified\n * without affecting the old one.\n * @return {Point} the clone\n */\n clone() {\n return new Point(this.x, this.y);\n },\n /**\n * Add this point's x & y coordinates to another point,\n * yielding a new point.\n * @param {Point} p the other point\n * @return {Point} output point\n */\n add(p) {\n return this.clone()._add(p);\n },\n /**\n * Subtract this point's x & y coordinates to from point,\n * yielding a new point.\n * @param {Point} p the other point\n * @return {Point} output point\n */\n sub(p) {\n return this.clone()._sub(p);\n },\n /**\n * Multiply this point's x & y coordinates by point,\n * yielding a new point.\n * @param {Point} p the other point\n * @return {Point} output point\n */\n multByPoint(p) {\n return this.clone()._multByPoint(p);\n },\n /**\n * Divide this point's x & y coordinates by point,\n * yielding a new point.\n * @param {Point} p the other point\n * @return {Point} output point\n */\n divByPoint(p) {\n return this.clone()._divByPoint(p);\n },\n /**\n * Multiply this point's x & y coordinates by a factor,\n * yielding a new point.\n * @param {number} k factor\n * @return {Point} output point\n */\n mult(k) {\n return this.clone()._mult(k);\n },\n /**\n * Divide this point's x & y coordinates by a factor,\n * yielding a new point.\n * @param {number} k factor\n * @return {Point} output point\n */\n div(k) {\n return this.clone()._div(k);\n },\n /**\n * Rotate this point around the 0, 0 origin by an angle a,\n * given in radians\n * @param {number} a angle to rotate around, in radians\n * @return {Point} output point\n */\n rotate(a) {\n return this.clone()._rotate(a);\n },\n /**\n * Rotate this point around p point by an angle a,\n * given in radians\n * @param {number} a angle to rotate around, in radians\n * @param {Point} p Point to rotate around\n * @return {Point} output point\n */\n rotateAround(a, p) {\n return this.clone()._rotateAround(a, p);\n },\n /**\n * Multiply this point by a 4x1 transformation matrix\n * @param {[number, number, number, number]} m transformation matrix\n * @return {Point} output point\n */\n matMult(m) {\n return this.clone()._matMult(m);\n },\n /**\n * Calculate this point but as a unit vector from 0, 0, meaning\n * that the distance from the resulting point to the 0, 0\n * coordinate will be equal to 1 and the angle from the resulting\n * point to the 0, 0 coordinate will be the same as before.\n * @return {Point} unit vector point\n */\n unit() {\n return this.clone()._unit();\n },\n /**\n * Compute a perpendicular point, where the new y coordinate\n * is the old x coordinate and the new x coordinate is the old y\n * coordinate multiplied by -1\n * @return {Point} perpendicular point\n */\n perp() {\n return this.clone()._perp();\n },\n /**\n * Return a version of this point with the x & y coordinates\n * rounded to integers.\n * @return {Point} rounded point\n */\n round() {\n return this.clone()._round();\n },\n /**\n * Return the magnitude of this point: this is the Euclidean\n * distance from the 0, 0 coordinate to this point's x and y\n * coordinates.\n * @return {number} magnitude\n */\n mag() {\n return Math.sqrt(this.x * this.x + this.y * this.y);\n },\n /**\n * Judge whether this point is equal to another point, returning\n * true or false.\n * @param {Point} other the other point\n * @return {boolean} whether the points are equal\n */\n equals(other) {\n return this.x === other.x && this.y === other.y;\n },\n /**\n * Calculate the distance from this point to another point\n * @param {Point} p the other point\n * @return {number} distance\n */\n dist(p) {\n return Math.sqrt(this.distSqr(p));\n },\n /**\n * Calculate the distance from this point to another point,\n * without the square root step. Useful if you're comparing\n * relative distances.\n * @param {Point} p the other point\n * @return {number} distance\n */\n distSqr(p) {\n const dx = p.x - this.x, dy = p.y - this.y;\n return dx * dx + dy * dy;\n },\n /**\n * Get the angle from the 0, 0 coordinate to this point, in radians\n * coordinates.\n * @return {number} angle\n */\n angle() {\n return Math.atan2(this.y, this.x);\n },\n /**\n * Get the angle from this point to another point, in radians\n * @param {Point} b the other point\n * @return {number} angle\n */\n angleTo(b) {\n return Math.atan2(this.y - b.y, this.x - b.x);\n },\n /**\n * Get the angle between this point and another point, in radians\n * @param {Point} b the other point\n * @return {number} angle\n */\n angleWith(b) {\n return this.angleWithSep(b.x, b.y);\n },\n /**\n * Find the angle of the two vectors, solving the formula for\n * the cross product a x b = |a||b|sin(\u03B8) for \u03B8.\n * @param {number} x the x-coordinate\n * @param {number} y the y-coordinate\n * @return {number} the angle in radians\n */\n angleWithSep(x, y) {\n return Math.atan2(\n this.x * y - this.y * x,\n this.x * x + this.y * y\n );\n },\n /** @param {[number, number, number, number]} m */\n _matMult(m) {\n const x = m[0] * this.x + m[1] * this.y, y = m[2] * this.x + m[3] * this.y;\n this.x = x;\n this.y = y;\n return this;\n },\n /** @param {Point} p */\n _add(p) {\n this.x += p.x;\n this.y += p.y;\n return this;\n },\n /** @param {Point} p */\n _sub(p) {\n this.x -= p.x;\n this.y -= p.y;\n return this;\n },\n /** @param {number} k */\n _mult(k) {\n this.x *= k;\n this.y *= k;\n return this;\n },\n /** @param {number} k */\n _div(k) {\n this.x /= k;\n this.y /= k;\n return this;\n },\n /** @param {Point} p */\n _multByPoint(p) {\n this.x *= p.x;\n this.y *= p.y;\n return this;\n },\n /** @param {Point} p */\n _divByPoint(p) {\n this.x /= p.x;\n this.y /= p.y;\n return this;\n },\n _unit() {\n this._div(this.mag());\n return this;\n },\n _perp() {\n const y = this.y;\n this.y = this.x;\n this.x = -y;\n return this;\n },\n /** @param {number} angle */\n _rotate(angle) {\n const cos = Math.cos(angle), sin = Math.sin(angle), x = cos * this.x - sin * this.y, y = sin * this.x + cos * this.y;\n this.x = x;\n this.y = y;\n return this;\n },\n /**\n * @param {number} angle\n * @param {Point} p\n */\n _rotateAround(angle, p) {\n const cos = Math.cos(angle), sin = Math.sin(angle), x = p.x + cos * (this.x - p.x) - sin * (this.y - p.y), y = p.y + sin * (this.x - p.x) + cos * (this.y - p.y);\n this.x = x;\n this.y = y;\n return this;\n },\n _round() {\n this.x = Math.round(this.x);\n this.y = Math.round(this.y);\n return this;\n },\n constructor: Point\n };\n Point.convert = function(p) {\n if (p instanceof Point) {\n return (\n /** @type {Point} */\n p\n );\n }\n if (Array.isArray(p)) {\n return new Point(+p[0], +p[1]);\n }\n if (p.x !== void 0 && p.y !== void 0) {\n return new Point(+p.x, +p.y);\n }\n throw new Error(\"Expected [x, y] or {x, y} point format\");\n };\n\n // ../../node_modules/.pnpm/@mapbox+vector-tile@2.0.4/node_modules/@mapbox/vector-tile/index.js\n var VectorTileFeature = class {\n /**\n * @param {Pbf} pbf\n * @param {number} end\n * @param {number} extent\n * @param {string[]} keys\n * @param {(number | string | boolean)[]} values\n */\n constructor(pbf, end, extent, keys, values) {\n this.properties = {};\n this.extent = extent;\n this.type = 0;\n this.id = void 0;\n this._pbf = pbf;\n this._geometry = -1;\n this._keys = keys;\n this._values = values;\n pbf.readFields(readFeature, this, end);\n }\n loadGeometry() {\n const pbf = this._pbf;\n pbf.pos = this._geometry;\n const end = pbf.readVarint() + pbf.pos;\n const lines = [];\n let line;\n let cmd = 1;\n let length = 0;\n let x = 0;\n let y = 0;\n while (pbf.pos < end) {\n if (length <= 0) {\n const cmdLen = pbf.readVarint();\n cmd = cmdLen & 7;\n length = cmdLen >> 3;\n }\n length--;\n if (cmd === 1 || cmd === 2) {\n x += pbf.readSVarint();\n y += pbf.readSVarint();\n if (cmd === 1) {\n if (line) lines.push(line);\n line = [];\n }\n if (line) line.push(new Point(x, y));\n } else if (cmd === 7) {\n if (line) {\n line.push(line[0].clone());\n }\n } else {\n throw new Error(`unknown command ${cmd}`);\n }\n }\n if (line) lines.push(line);\n return lines;\n }\n bbox() {\n const pbf = this._pbf;\n pbf.pos = this._geometry;\n const end = pbf.readVarint() + pbf.pos;\n let cmd = 1, length = 0, x = 0, y = 0, x1 = Infinity, x2 = -Infinity, y1 = Infinity, y2 = -Infinity;\n while (pbf.pos < end) {\n if (length <= 0) {\n const cmdLen = pbf.readVarint();\n cmd = cmdLen & 7;\n length = cmdLen >> 3;\n }\n length--;\n if (cmd === 1 || cmd === 2) {\n x += pbf.readSVarint();\n y += pbf.readSVarint();\n if (x < x1) x1 = x;\n if (x > x2) x2 = x;\n if (y < y1) y1 = y;\n if (y > y2) y2 = y;\n } else if (cmd !== 7) {\n throw new Error(`unknown command ${cmd}`);\n }\n }\n return [x1, y1, x2, y2];\n }\n /**\n * @param {number} x\n * @param {number} y\n * @param {number} z\n * @return {Feature}\n */\n toGeoJSON(x, y, z) {\n const size = this.extent * Math.pow(2, z), x0 = this.extent * x, y0 = this.extent * y, vtCoords = this.loadGeometry();\n function projectPoint(p) {\n return [\n (p.x + x0) * 360 / size - 180,\n 360 / Math.PI * Math.atan(Math.exp((1 - (p.y + y0) * 2 / size) * Math.PI)) - 90\n ];\n }\n function projectLine(line) {\n return line.map(projectPoint);\n }\n let geometry;\n if (this.type === 1) {\n const points = [];\n for (const line of vtCoords) {\n points.push(line[0]);\n }\n const coordinates = projectLine(points);\n geometry = points.length === 1 ? { type: \"Point\", coordinates: coordinates[0] } : { type: \"MultiPoint\", coordinates };\n } else if (this.type === 2) {\n const coordinates = vtCoords.map(projectLine);\n geometry = coordinates.length === 1 ? { type: \"LineString\", coordinates: coordinates[0] } : { type: \"MultiLineString\", coordinates };\n } else if (this.type === 3) {\n const polygons = classifyRings(vtCoords);\n const coordinates = [];\n for (const polygon of polygons) {\n coordinates.push(polygon.map(projectLine));\n }\n geometry = coordinates.length === 1 ? { type: \"Polygon\", coordinates: coordinates[0] } : { type: \"MultiPolygon\", coordinates };\n } else {\n throw new Error(\"unknown feature type\");\n }\n const result = {\n type: \"Feature\",\n geometry,\n properties: this.properties\n };\n if (this.id != null) {\n result.id = this.id;\n }\n return result;\n }\n };\n VectorTileFeature.types = [\"Unknown\", \"Point\", \"LineString\", \"Polygon\"];\n function readFeature(tag, feature, pbf) {\n if (tag === 1) feature.id = pbf.readVarint();\n else if (tag === 2) readTag(pbf, feature);\n else if (tag === 3) feature.type = /** @type {0 | 1 | 2 | 3} */\n pbf.readVarint();\n else if (tag === 4) feature._geometry = pbf.pos;\n }\n function readTag(pbf, feature) {\n const end = pbf.readVarint() + pbf.pos;\n while (pbf.pos < end) {\n const key = feature._keys[pbf.readVarint()];\n const value = feature._values[pbf.readVarint()];\n feature.properties[key] = value;\n }\n }\n function classifyRings(rings) {\n const len = rings.length;\n if (len <= 1) return [rings];\n const polygons = [];\n let polygon, ccw;\n for (let i = 0; i < len; i++) {\n const area = signedArea(rings[i]);\n if (area === 0) continue;\n if (ccw === void 0) ccw = area < 0;\n if (ccw === area < 0) {\n if (polygon) polygons.push(polygon);\n polygon = [rings[i]];\n } else if (polygon) {\n polygon.push(rings[i]);\n }\n }\n if (polygon) polygons.push(polygon);\n return polygons;\n }\n function signedArea(ring) {\n let sum = 0;\n for (let i = 0, len = ring.length, j = len - 1, p1, p2; i < len; j = i++) {\n p1 = ring[i];\n p2 = ring[j];\n sum += (p2.x - p1.x) * (p1.y + p2.y);\n }\n return sum;\n }\n var VectorTileLayer = class {\n /**\n * @param {Pbf} pbf\n * @param {number} [end]\n */\n constructor(pbf, end) {\n this.version = 1;\n this.name = \"\";\n this.extent = 4096;\n this.length = 0;\n this._pbf = pbf;\n this._keys = [];\n this._values = [];\n this._features = [];\n pbf.readFields(readLayer, this, end);\n this.length = this._features.length;\n }\n /** return feature `i` from this layer as a `VectorTileFeature`\n * @param {number} i\n */\n feature(i) {\n if (i < 0 || i >= this._features.length) throw new Error(\"feature index out of bounds\");\n this._pbf.pos = this._features[i];\n const end = this._pbf.readVarint() + this._pbf.pos;\n return new VectorTileFeature(this._pbf, end, this.extent, this._keys, this._values);\n }\n };\n function readLayer(tag, layer, pbf) {\n if (tag === 15) layer.version = pbf.readVarint();\n else if (tag === 1) layer.name = pbf.readString();\n else if (tag === 5) layer.extent = pbf.readVarint();\n else if (tag === 2) layer._features.push(pbf.pos);\n else if (tag === 3) layer._keys.push(pbf.readString());\n else if (tag === 4) layer._values.push(readValueMessage(pbf));\n }\n function readValueMessage(pbf) {\n let value = null;\n const end = pbf.readVarint() + pbf.pos;\n while (pbf.pos < end) {\n const tag = pbf.readVarint() >> 3;\n value = tag === 1 ? pbf.readString() : tag === 2 ? pbf.readFloat() : tag === 3 ? pbf.readDouble() : tag === 4 ? pbf.readVarint64() : tag === 5 ? pbf.readVarint() : tag === 6 ? pbf.readSVarint() : tag === 7 ? pbf.readBoolean() : null;\n }\n if (value == null) {\n throw new Error(\"unknown feature value\");\n }\n return value;\n }\n var VectorTile = class {\n /**\n * @param {Pbf} pbf\n * @param {number} [end]\n */\n constructor(pbf, end) {\n this.layers = pbf.readFields(readTile, {}, end);\n }\n };\n function readTile(tag, layers, pbf) {\n if (tag === 3) {\n const layer = new VectorTileLayer(pbf, pbf.readVarint() + pbf.pos);\n if (layer.length) layers[layer.name] = layer;\n }\n }\n\n // src/ESCesiumViewer/ViewerExtensions/VectorTilesManager/vectorTilesWorker.ts\n self.onmessage = async (e) => {\n if (e.data.type == \"requestImage\") {\n const { style, size, tileData, x, y, z } = e.data;\n const screenCanvas = new OffscreenCanvas(size, size);\n const ctx = screenCanvas.getContext(\"2d\");\n ctx.translate(0, screenCanvas.height);\n ctx.scale(1, -1);\n const tileKey = `${z}-${x}-${y}`;\n if (!tileData) {\n const bitmap2 = screenCanvas.transferToImageBitmap();\n self.postMessage({ bitmap: bitmap2, tileKey }, [bitmap2]);\n return;\n }\n style.forEach((layer) => {\n var _a;\n const layerData = (_a = tileData == null ? void 0 : tileData.get(layer.source)) == null ? void 0 : _a.get(layer[\"source-layer\"]);\n layerData == null ? void 0 : layerData.forEach((f) => {\n var _a2, _b, _c, _d, _e, _f, _g, _h, _i;\n const g = f.geometry;\n if (g.type === \"Polygon\") {\n if (!((_a2 = layer == null ? void 0 : layer.polygonStyle) == null ? void 0 : _a2.visibility) || ((_b = layer == null ? void 0 : layer.polygonStyle) == null ? void 0 : _b.visibility) === \"visible\") {\n if (layer == null ? void 0 : layer.polygonStyle) {\n ctx.fillStyle = ((_c = layer == null ? void 0 : layer.polygonStyle) == null ? void 0 : _c.color) || \"#000000\";\n if (layer.polygonStyle.outlineColor) {\n ctx.strokeStyle = layer.polygonStyle.outlineColor;\n }\n }\n g.coordinates.forEach((ring) => {\n var _a3;\n ctx.beginPath();\n ring.forEach((pt, i) => {\n const [tileX, tileY] = lngLatToTilePixel(pt[0], pt[1], z, x, y);\n if (i === 0) ctx.moveTo(tileX, tileY);\n else ctx.lineTo(tileX, tileY);\n });\n ctx.closePath();\n ctx.fill();\n if ((_a3 = layer == null ? void 0 : layer.polygonStyle) == null ? void 0 : _a3.outlineColor)\n ctx.stroke();\n });\n }\n }\n if (g.type === \"LineString\") {\n if (!((_d = layer == null ? void 0 : layer.polylineStyle) == null ? void 0 : _d.visibility) || ((_e = layer == null ? void 0 : layer.polylineStyle) == null ? void 0 : _e.visibility) === \"visible\") {\n if (layer == null ? void 0 : layer.polylineStyle) {\n ctx.strokeStyle = ((_f = layer.polylineStyle) == null ? void 0 : _f.color) || \"#000000\";\n ctx.lineWidth = ((_g = layer.polylineStyle) == null ? void 0 : _g.width) || 1;\n ctx.lineCap = ((_h = layer.polylineStyle) == null ? void 0 : _h.cap) || \"butt\";\n ctx.lineJoin = ((_i = layer.polylineStyle) == null ? void 0 : _i.join) || \"miter\";\n }\n ctx.beginPath();\n g.coordinates.forEach((pt, i) => {\n const [tileX, tileY] = lngLatToTilePixel(pt[0], pt[1], z, x, y);\n if (i === 0) ctx.moveTo(tileX, tileY);\n else ctx.lineTo(tileX, tileY);\n });\n ctx.stroke();\n }\n }\n });\n });\n const bitmap = screenCanvas.transferToImageBitmap();\n self.postMessage({ bitmap, tileKey }, [bitmap]);\n } else if (e.data.type == \"fetch\") {\n const { type, url, x, y, z } = e.data;\n try {\n const buffer = await (await fetch(url)).arrayBuffer();\n const tile = new VectorTile(new Pbf(buffer));\n const tileData = {};\n for (const layerName in tile.layers) {\n const layer = tile.layers[layerName];\n const extent = layer.extent || 4096;\n const points = [];\n const pointProps = [];\n const lines = [];\n const lineOffsets = [];\n const lineProps = [];\n const polygons = [];\n const polygonOffsets = [];\n const polygonProps = [];\n for (let i = 0; i < layer.length; i++) {\n const f = layer.feature(i);\n let geom;\n try {\n geom = f.loadGeometry();\n } catch (e2) {\n console.warn(\n \"Invalid geometry, skip feature\",\n \"type=\",\n f.type,\n \"layer=\",\n layerName,\n e2\n );\n continue;\n }\n const t = f.type;\n const properties = f.properties || {};\n if (t === 1) {\n let sx = 0, sy = 0, cnt = 0;\n for (const ring of geom)\n for (const p of ring) {\n sx += p.x;\n sy += p.y;\n cnt++;\n }\n if (cnt === 0) continue;\n const { lon, lat } = tilePixelToLonLat(sx / cnt, sy / cnt, extent, x, y, z);\n points.push(lon, lat, 0);\n pointProps.push(properties);\n } else if (t === 2) {\n lineOffsets.push(lines.length / 3);\n for (const ring of geom)\n for (const p of ring) {\n const { lon, lat } = tilePixelToLonLat(p.x, p.y, extent, x, y, z);\n lines.push(lon, lat, 0);\n }\n lineProps.push(properties);\n } else if (t === 3) {\n polygonOffsets.push(polygons.length / 3);\n for (const ring of geom)\n for (const p of ring) {\n const { lon, lat } = tilePixelToLonLat(p.x, p.y, extent, x, y, z);\n polygons.push(lon, lat, 0);\n }\n polygonProps.push(properties);\n }\n }\n tileData[layerName] = {\n points: new Float32Array(points),\n pointProps,\n lines: new Float32Array(lines),\n lineOffsets: new Uint32Array(lineOffsets),\n lineProps,\n polygons: new Float32Array(polygons),\n polygonOffsets: new Uint32Array(polygonOffsets),\n polygonProps\n };\n }\n const transfers = [];\n for (const layerName in tileData) {\n const layer = tileData[layerName];\n transfers.push(\n layer.points.buffer,\n layer.lines.buffer,\n layer.lineOffsets.buffer,\n layer.polygons.buffer,\n layer.polygonOffsets.buffer\n );\n }\n self.postMessage({ url, tileData }, transfers);\n } catch (err) {\n self.postMessage({ url, error: err.message });\n }\n }\n ;\n };\n function tilePixelToLonLat(px, py, extent, tileX, tileY, z) {\n const n = Math.pow(2, z);\n const xNorm = (tileX + px / extent) / n;\n const yNorm = (tileY + py / extent) / n;\n const lon = xNorm * 360 - 180;\n const lat = Math.atan(Math.sinh(Math.PI * (1 - 2 * yNorm))) * 180 / Math.PI;\n return { lon, lat };\n }\n function lngLatToTilePixel(lon, lat, z, xTile, yTile, tileSize = 256, extent = 4096) {\n const mx = lon / 360 + 0.5;\n const sin = Math.sin(lat * Math.PI / 180);\n const my = 0.5 - 0.25 * Math.log((1 + sin) / (1 - sin)) / Math.PI;\n const scale = 1 << z;\n const localX = (mx - xTile / scale) * scale;\n const localY = (my - yTile / scale) * scale;\n const ex = localX * extent;\n const ey = localY * extent;\n return [\n ex / extent * tileSize,\n ey / extent * tileSize\n ];\n }\n})();\n";
|
|
1
|
+
declare const _default: "\"use strict\";\n(() => {\n // ../../node_modules/.pnpm/pbf@4.0.1/node_modules/pbf/index.js\n var SHIFT_LEFT_32 = (1 << 16) * (1 << 16);\n var SHIFT_RIGHT_32 = 1 / SHIFT_LEFT_32;\n var TEXT_DECODER_MIN_LENGTH = 12;\n var utf8TextDecoder = typeof TextDecoder === \"undefined\" ? null : new TextDecoder(\"utf-8\");\n var PBF_VARINT = 0;\n var PBF_FIXED64 = 1;\n var PBF_BYTES = 2;\n var PBF_FIXED32 = 5;\n var Pbf = class {\n /**\n * @param {Uint8Array | ArrayBuffer} [buf]\n */\n constructor(buf = new Uint8Array(16)) {\n this.buf = ArrayBuffer.isView(buf) ? buf : new Uint8Array(buf);\n this.dataView = new DataView(this.buf.buffer);\n this.pos = 0;\n this.type = 0;\n this.length = this.buf.length;\n }\n // === READING =================================================================\n /**\n * @template T\n * @param {(tag: number, result: T, pbf: Pbf) => void} readField\n * @param {T} result\n * @param {number} [end]\n */\n readFields(readField, result, end = this.length) {\n while (this.pos < end) {\n const val = this.readVarint(), tag = val >> 3, startPos = this.pos;\n this.type = val & 7;\n readField(tag, result, this);\n if (this.pos === startPos) this.skip(val);\n }\n return result;\n }\n /**\n * @template T\n * @param {(tag: number, result: T, pbf: Pbf) => void} readField\n * @param {T} result\n */\n readMessage(readField, result) {\n return this.readFields(readField, result, this.readVarint() + this.pos);\n }\n readFixed32() {\n const val = this.dataView.getUint32(this.pos, true);\n this.pos += 4;\n return val;\n }\n readSFixed32() {\n const val = this.dataView.getInt32(this.pos, true);\n this.pos += 4;\n return val;\n }\n // 64-bit int handling is based on github.com/dpw/node-buffer-more-ints (MIT-licensed)\n readFixed64() {\n const val = this.dataView.getUint32(this.pos, true) + this.dataView.getUint32(this.pos + 4, true) * SHIFT_LEFT_32;\n this.pos += 8;\n return val;\n }\n readSFixed64() {\n const val = this.dataView.getUint32(this.pos, true) + this.dataView.getInt32(this.pos + 4, true) * SHIFT_LEFT_32;\n this.pos += 8;\n return val;\n }\n readFloat() {\n const val = this.dataView.getFloat32(this.pos, true);\n this.pos += 4;\n return val;\n }\n readDouble() {\n const val = this.dataView.getFloat64(this.pos, true);\n this.pos += 8;\n return val;\n }\n /**\n * @param {boolean} [isSigned]\n */\n readVarint(isSigned) {\n const buf = this.buf;\n let val, b;\n b = buf[this.pos++];\n val = b & 127;\n if (b < 128) return val;\n b = buf[this.pos++];\n val |= (b & 127) << 7;\n if (b < 128) return val;\n b = buf[this.pos++];\n val |= (b & 127) << 14;\n if (b < 128) return val;\n b = buf[this.pos++];\n val |= (b & 127) << 21;\n if (b < 128) return val;\n b = buf[this.pos];\n val |= (b & 15) << 28;\n return readVarintRemainder(val, isSigned, this);\n }\n readVarint64() {\n return this.readVarint(true);\n }\n readSVarint() {\n const num = this.readVarint();\n return num % 2 === 1 ? (num + 1) / -2 : num / 2;\n }\n readBoolean() {\n return Boolean(this.readVarint());\n }\n readString() {\n const end = this.readVarint() + this.pos;\n const pos = this.pos;\n this.pos = end;\n if (end - pos >= TEXT_DECODER_MIN_LENGTH && utf8TextDecoder) {\n return utf8TextDecoder.decode(this.buf.subarray(pos, end));\n }\n return readUtf8(this.buf, pos, end);\n }\n readBytes() {\n const end = this.readVarint() + this.pos, buffer = this.buf.subarray(this.pos, end);\n this.pos = end;\n return buffer;\n }\n // verbose for performance reasons; doesn't affect gzipped size\n /**\n * @param {number[]} [arr]\n * @param {boolean} [isSigned]\n */\n readPackedVarint(arr = [], isSigned) {\n const end = this.readPackedEnd();\n while (this.pos < end) arr.push(this.readVarint(isSigned));\n return arr;\n }\n /** @param {number[]} [arr] */\n readPackedSVarint(arr = []) {\n const end = this.readPackedEnd();\n while (this.pos < end) arr.push(this.readSVarint());\n return arr;\n }\n /** @param {boolean[]} [arr] */\n readPackedBoolean(arr = []) {\n const end = this.readPackedEnd();\n while (this.pos < end) arr.push(this.readBoolean());\n return arr;\n }\n /** @param {number[]} [arr] */\n readPackedFloat(arr = []) {\n const end = this.readPackedEnd();\n while (this.pos < end) arr.push(this.readFloat());\n return arr;\n }\n /** @param {number[]} [arr] */\n readPackedDouble(arr = []) {\n const end = this.readPackedEnd();\n while (this.pos < end) arr.push(this.readDouble());\n return arr;\n }\n /** @param {number[]} [arr] */\n readPackedFixed32(arr = []) {\n const end = this.readPackedEnd();\n while (this.pos < end) arr.push(this.readFixed32());\n return arr;\n }\n /** @param {number[]} [arr] */\n readPackedSFixed32(arr = []) {\n const end = this.readPackedEnd();\n while (this.pos < end) arr.push(this.readSFixed32());\n return arr;\n }\n /** @param {number[]} [arr] */\n readPackedFixed64(arr = []) {\n const end = this.readPackedEnd();\n while (this.pos < end) arr.push(this.readFixed64());\n return arr;\n }\n /** @param {number[]} [arr] */\n readPackedSFixed64(arr = []) {\n const end = this.readPackedEnd();\n while (this.pos < end) arr.push(this.readSFixed64());\n return arr;\n }\n readPackedEnd() {\n return this.type === PBF_BYTES ? this.readVarint() + this.pos : this.pos + 1;\n }\n /** @param {number} val */\n skip(val) {\n const type = val & 7;\n if (type === PBF_VARINT) while (this.buf[this.pos++] > 127) {\n }\n else if (type === PBF_BYTES) this.pos = this.readVarint() + this.pos;\n else if (type === PBF_FIXED32) this.pos += 4;\n else if (type === PBF_FIXED64) this.pos += 8;\n else throw new Error(`Unimplemented type: ${type}`);\n }\n // === WRITING =================================================================\n /**\n * @param {number} tag\n * @param {number} type\n */\n writeTag(tag, type) {\n this.writeVarint(tag << 3 | type);\n }\n /** @param {number} min */\n realloc(min) {\n let length = this.length || 16;\n while (length < this.pos + min) length *= 2;\n if (length !== this.length) {\n const buf = new Uint8Array(length);\n buf.set(this.buf);\n this.buf = buf;\n this.dataView = new DataView(buf.buffer);\n this.length = length;\n }\n }\n finish() {\n this.length = this.pos;\n this.pos = 0;\n return this.buf.subarray(0, this.length);\n }\n /** @param {number} val */\n writeFixed32(val) {\n this.realloc(4);\n this.dataView.setInt32(this.pos, val, true);\n this.pos += 4;\n }\n /** @param {number} val */\n writeSFixed32(val) {\n this.realloc(4);\n this.dataView.setInt32(this.pos, val, true);\n this.pos += 4;\n }\n /** @param {number} val */\n writeFixed64(val) {\n this.realloc(8);\n this.dataView.setInt32(this.pos, val & -1, true);\n this.dataView.setInt32(this.pos + 4, Math.floor(val * SHIFT_RIGHT_32), true);\n this.pos += 8;\n }\n /** @param {number} val */\n writeSFixed64(val) {\n this.realloc(8);\n this.dataView.setInt32(this.pos, val & -1, true);\n this.dataView.setInt32(this.pos + 4, Math.floor(val * SHIFT_RIGHT_32), true);\n this.pos += 8;\n }\n /** @param {number} val */\n writeVarint(val) {\n val = +val || 0;\n if (val > 268435455 || val < 0) {\n writeBigVarint(val, this);\n return;\n }\n this.realloc(4);\n this.buf[this.pos++] = val & 127 | (val > 127 ? 128 : 0);\n if (val <= 127) return;\n this.buf[this.pos++] = (val >>>= 7) & 127 | (val > 127 ? 128 : 0);\n if (val <= 127) return;\n this.buf[this.pos++] = (val >>>= 7) & 127 | (val > 127 ? 128 : 0);\n if (val <= 127) return;\n this.buf[this.pos++] = val >>> 7 & 127;\n }\n /** @param {number} val */\n writeSVarint(val) {\n this.writeVarint(val < 0 ? -val * 2 - 1 : val * 2);\n }\n /** @param {boolean} val */\n writeBoolean(val) {\n this.writeVarint(+val);\n }\n /** @param {string} str */\n writeString(str) {\n str = String(str);\n this.realloc(str.length * 4);\n this.pos++;\n const startPos = this.pos;\n this.pos = writeUtf8(this.buf, str, this.pos);\n const len = this.pos - startPos;\n if (len >= 128) makeRoomForExtraLength(startPos, len, this);\n this.pos = startPos - 1;\n this.writeVarint(len);\n this.pos += len;\n }\n /** @param {number} val */\n writeFloat(val) {\n this.realloc(4);\n this.dataView.setFloat32(this.pos, val, true);\n this.pos += 4;\n }\n /** @param {number} val */\n writeDouble(val) {\n this.realloc(8);\n this.dataView.setFloat64(this.pos, val, true);\n this.pos += 8;\n }\n /** @param {Uint8Array} buffer */\n writeBytes(buffer) {\n const len = buffer.length;\n this.writeVarint(len);\n this.realloc(len);\n for (let i = 0; i < len; i++) this.buf[this.pos++] = buffer[i];\n }\n /**\n * @template T\n * @param {(obj: T, pbf: Pbf) => void} fn\n * @param {T} obj\n */\n writeRawMessage(fn, obj) {\n this.pos++;\n const startPos = this.pos;\n fn(obj, this);\n const len = this.pos - startPos;\n if (len >= 128) makeRoomForExtraLength(startPos, len, this);\n this.pos = startPos - 1;\n this.writeVarint(len);\n this.pos += len;\n }\n /**\n * @template T\n * @param {number} tag\n * @param {(obj: T, pbf: Pbf) => void} fn\n * @param {T} obj\n */\n writeMessage(tag, fn, obj) {\n this.writeTag(tag, PBF_BYTES);\n this.writeRawMessage(fn, obj);\n }\n /**\n * @param {number} tag\n * @param {number[]} arr\n */\n writePackedVarint(tag, arr) {\n if (arr.length) this.writeMessage(tag, writePackedVarint, arr);\n }\n /**\n * @param {number} tag\n * @param {number[]} arr\n */\n writePackedSVarint(tag, arr) {\n if (arr.length) this.writeMessage(tag, writePackedSVarint, arr);\n }\n /**\n * @param {number} tag\n * @param {boolean[]} arr\n */\n writePackedBoolean(tag, arr) {\n if (arr.length) this.writeMessage(tag, writePackedBoolean, arr);\n }\n /**\n * @param {number} tag\n * @param {number[]} arr\n */\n writePackedFloat(tag, arr) {\n if (arr.length) this.writeMessage(tag, writePackedFloat, arr);\n }\n /**\n * @param {number} tag\n * @param {number[]} arr\n */\n writePackedDouble(tag, arr) {\n if (arr.length) this.writeMessage(tag, writePackedDouble, arr);\n }\n /**\n * @param {number} tag\n * @param {number[]} arr\n */\n writePackedFixed32(tag, arr) {\n if (arr.length) this.writeMessage(tag, writePackedFixed32, arr);\n }\n /**\n * @param {number} tag\n * @param {number[]} arr\n */\n writePackedSFixed32(tag, arr) {\n if (arr.length) this.writeMessage(tag, writePackedSFixed32, arr);\n }\n /**\n * @param {number} tag\n * @param {number[]} arr\n */\n writePackedFixed64(tag, arr) {\n if (arr.length) this.writeMessage(tag, writePackedFixed64, arr);\n }\n /**\n * @param {number} tag\n * @param {number[]} arr\n */\n writePackedSFixed64(tag, arr) {\n if (arr.length) this.writeMessage(tag, writePackedSFixed64, arr);\n }\n /**\n * @param {number} tag\n * @param {Uint8Array} buffer\n */\n writeBytesField(tag, buffer) {\n this.writeTag(tag, PBF_BYTES);\n this.writeBytes(buffer);\n }\n /**\n * @param {number} tag\n * @param {number} val\n */\n writeFixed32Field(tag, val) {\n this.writeTag(tag, PBF_FIXED32);\n this.writeFixed32(val);\n }\n /**\n * @param {number} tag\n * @param {number} val\n */\n writeSFixed32Field(tag, val) {\n this.writeTag(tag, PBF_FIXED32);\n this.writeSFixed32(val);\n }\n /**\n * @param {number} tag\n * @param {number} val\n */\n writeFixed64Field(tag, val) {\n this.writeTag(tag, PBF_FIXED64);\n this.writeFixed64(val);\n }\n /**\n * @param {number} tag\n * @param {number} val\n */\n writeSFixed64Field(tag, val) {\n this.writeTag(tag, PBF_FIXED64);\n this.writeSFixed64(val);\n }\n /**\n * @param {number} tag\n * @param {number} val\n */\n writeVarintField(tag, val) {\n this.writeTag(tag, PBF_VARINT);\n this.writeVarint(val);\n }\n /**\n * @param {number} tag\n * @param {number} val\n */\n writeSVarintField(tag, val) {\n this.writeTag(tag, PBF_VARINT);\n this.writeSVarint(val);\n }\n /**\n * @param {number} tag\n * @param {string} str\n */\n writeStringField(tag, str) {\n this.writeTag(tag, PBF_BYTES);\n this.writeString(str);\n }\n /**\n * @param {number} tag\n * @param {number} val\n */\n writeFloatField(tag, val) {\n this.writeTag(tag, PBF_FIXED32);\n this.writeFloat(val);\n }\n /**\n * @param {number} tag\n * @param {number} val\n */\n writeDoubleField(tag, val) {\n this.writeTag(tag, PBF_FIXED64);\n this.writeDouble(val);\n }\n /**\n * @param {number} tag\n * @param {boolean} val\n */\n writeBooleanField(tag, val) {\n this.writeVarintField(tag, +val);\n }\n };\n function readVarintRemainder(l, s, p) {\n const buf = p.buf;\n let h, b;\n b = buf[p.pos++];\n h = (b & 112) >> 4;\n if (b < 128) return toNum(l, h, s);\n b = buf[p.pos++];\n h |= (b & 127) << 3;\n if (b < 128) return toNum(l, h, s);\n b = buf[p.pos++];\n h |= (b & 127) << 10;\n if (b < 128) return toNum(l, h, s);\n b = buf[p.pos++];\n h |= (b & 127) << 17;\n if (b < 128) return toNum(l, h, s);\n b = buf[p.pos++];\n h |= (b & 127) << 24;\n if (b < 128) return toNum(l, h, s);\n b = buf[p.pos++];\n h |= (b & 1) << 31;\n if (b < 128) return toNum(l, h, s);\n throw new Error(\"Expected varint not more than 10 bytes\");\n }\n function toNum(low, high, isSigned) {\n return isSigned ? high * 4294967296 + (low >>> 0) : (high >>> 0) * 4294967296 + (low >>> 0);\n }\n function writeBigVarint(val, pbf) {\n let low, high;\n if (val >= 0) {\n low = val % 4294967296 | 0;\n high = val / 4294967296 | 0;\n } else {\n low = ~(-val % 4294967296);\n high = ~(-val / 4294967296);\n if (low ^ 4294967295) {\n low = low + 1 | 0;\n } else {\n low = 0;\n high = high + 1 | 0;\n }\n }\n if (val >= 18446744073709552e3 || val < -18446744073709552e3) {\n throw new Error(\"Given varint doesn't fit into 10 bytes\");\n }\n pbf.realloc(10);\n writeBigVarintLow(low, high, pbf);\n writeBigVarintHigh(high, pbf);\n }\n function writeBigVarintLow(low, high, pbf) {\n pbf.buf[pbf.pos++] = low & 127 | 128;\n low >>>= 7;\n pbf.buf[pbf.pos++] = low & 127 | 128;\n low >>>= 7;\n pbf.buf[pbf.pos++] = low & 127 | 128;\n low >>>= 7;\n pbf.buf[pbf.pos++] = low & 127 | 128;\n low >>>= 7;\n pbf.buf[pbf.pos] = low & 127;\n }\n function writeBigVarintHigh(high, pbf) {\n const lsb = (high & 7) << 4;\n pbf.buf[pbf.pos++] |= lsb | ((high >>>= 3) ? 128 : 0);\n if (!high) return;\n pbf.buf[pbf.pos++] = high & 127 | ((high >>>= 7) ? 128 : 0);\n if (!high) return;\n pbf.buf[pbf.pos++] = high & 127 | ((high >>>= 7) ? 128 : 0);\n if (!high) return;\n pbf.buf[pbf.pos++] = high & 127 | ((high >>>= 7) ? 128 : 0);\n if (!high) return;\n pbf.buf[pbf.pos++] = high & 127 | ((high >>>= 7) ? 128 : 0);\n if (!high) return;\n pbf.buf[pbf.pos++] = high & 127;\n }\n function makeRoomForExtraLength(startPos, len, pbf) {\n const extraLen = len <= 16383 ? 1 : len <= 2097151 ? 2 : len <= 268435455 ? 3 : Math.floor(Math.log(len) / (Math.LN2 * 7));\n pbf.realloc(extraLen);\n for (let i = pbf.pos - 1; i >= startPos; i--) pbf.buf[i + extraLen] = pbf.buf[i];\n }\n function writePackedVarint(arr, pbf) {\n for (let i = 0; i < arr.length; i++) pbf.writeVarint(arr[i]);\n }\n function writePackedSVarint(arr, pbf) {\n for (let i = 0; i < arr.length; i++) pbf.writeSVarint(arr[i]);\n }\n function writePackedFloat(arr, pbf) {\n for (let i = 0; i < arr.length; i++) pbf.writeFloat(arr[i]);\n }\n function writePackedDouble(arr, pbf) {\n for (let i = 0; i < arr.length; i++) pbf.writeDouble(arr[i]);\n }\n function writePackedBoolean(arr, pbf) {\n for (let i = 0; i < arr.length; i++) pbf.writeBoolean(arr[i]);\n }\n function writePackedFixed32(arr, pbf) {\n for (let i = 0; i < arr.length; i++) pbf.writeFixed32(arr[i]);\n }\n function writePackedSFixed32(arr, pbf) {\n for (let i = 0; i < arr.length; i++) pbf.writeSFixed32(arr[i]);\n }\n function writePackedFixed64(arr, pbf) {\n for (let i = 0; i < arr.length; i++) pbf.writeFixed64(arr[i]);\n }\n function writePackedSFixed64(arr, pbf) {\n for (let i = 0; i < arr.length; i++) pbf.writeSFixed64(arr[i]);\n }\n function readUtf8(buf, pos, end) {\n let str = \"\";\n let i = pos;\n while (i < end) {\n const b0 = buf[i];\n let c = null;\n let bytesPerSequence = b0 > 239 ? 4 : b0 > 223 ? 3 : b0 > 191 ? 2 : 1;\n if (i + bytesPerSequence > end) break;\n let b1, b2, b3;\n if (bytesPerSequence === 1) {\n if (b0 < 128) {\n c = b0;\n }\n } else if (bytesPerSequence === 2) {\n b1 = buf[i + 1];\n if ((b1 & 192) === 128) {\n c = (b0 & 31) << 6 | b1 & 63;\n if (c <= 127) {\n c = null;\n }\n }\n } else if (bytesPerSequence === 3) {\n b1 = buf[i + 1];\n b2 = buf[i + 2];\n if ((b1 & 192) === 128 && (b2 & 192) === 128) {\n c = (b0 & 15) << 12 | (b1 & 63) << 6 | b2 & 63;\n if (c <= 2047 || c >= 55296 && c <= 57343) {\n c = null;\n }\n }\n } else if (bytesPerSequence === 4) {\n b1 = buf[i + 1];\n b2 = buf[i + 2];\n b3 = buf[i + 3];\n if ((b1 & 192) === 128 && (b2 & 192) === 128 && (b3 & 192) === 128) {\n c = (b0 & 15) << 18 | (b1 & 63) << 12 | (b2 & 63) << 6 | b3 & 63;\n if (c <= 65535 || c >= 1114112) {\n c = null;\n }\n }\n }\n if (c === null) {\n c = 65533;\n bytesPerSequence = 1;\n } else if (c > 65535) {\n c -= 65536;\n str += String.fromCharCode(c >>> 10 & 1023 | 55296);\n c = 56320 | c & 1023;\n }\n str += String.fromCharCode(c);\n i += bytesPerSequence;\n }\n return str;\n }\n function writeUtf8(buf, str, pos) {\n for (let i = 0, c, lead; i < str.length; i++) {\n c = str.charCodeAt(i);\n if (c > 55295 && c < 57344) {\n if (lead) {\n if (c < 56320) {\n buf[pos++] = 239;\n buf[pos++] = 191;\n buf[pos++] = 189;\n lead = c;\n continue;\n } else {\n c = lead - 55296 << 10 | c - 56320 | 65536;\n lead = null;\n }\n } else {\n if (c > 56319 || i + 1 === str.length) {\n buf[pos++] = 239;\n buf[pos++] = 191;\n buf[pos++] = 189;\n } else {\n lead = c;\n }\n continue;\n }\n } else if (lead) {\n buf[pos++] = 239;\n buf[pos++] = 191;\n buf[pos++] = 189;\n lead = null;\n }\n if (c < 128) {\n buf[pos++] = c;\n } else {\n if (c < 2048) {\n buf[pos++] = c >> 6 | 192;\n } else {\n if (c < 65536) {\n buf[pos++] = c >> 12 | 224;\n } else {\n buf[pos++] = c >> 18 | 240;\n buf[pos++] = c >> 12 & 63 | 128;\n }\n buf[pos++] = c >> 6 & 63 | 128;\n }\n buf[pos++] = c & 63 | 128;\n }\n }\n return pos;\n }\n\n // ../../node_modules/.pnpm/@mapbox+point-geometry@1.1.0/node_modules/@mapbox/point-geometry/index.js\n function Point(x, y) {\n this.x = x;\n this.y = y;\n }\n Point.prototype = {\n /**\n * Clone this point, returning a new point that can be modified\n * without affecting the old one.\n * @return {Point} the clone\n */\n clone() {\n return new Point(this.x, this.y);\n },\n /**\n * Add this point's x & y coordinates to another point,\n * yielding a new point.\n * @param {Point} p the other point\n * @return {Point} output point\n */\n add(p) {\n return this.clone()._add(p);\n },\n /**\n * Subtract this point's x & y coordinates to from point,\n * yielding a new point.\n * @param {Point} p the other point\n * @return {Point} output point\n */\n sub(p) {\n return this.clone()._sub(p);\n },\n /**\n * Multiply this point's x & y coordinates by point,\n * yielding a new point.\n * @param {Point} p the other point\n * @return {Point} output point\n */\n multByPoint(p) {\n return this.clone()._multByPoint(p);\n },\n /**\n * Divide this point's x & y coordinates by point,\n * yielding a new point.\n * @param {Point} p the other point\n * @return {Point} output point\n */\n divByPoint(p) {\n return this.clone()._divByPoint(p);\n },\n /**\n * Multiply this point's x & y coordinates by a factor,\n * yielding a new point.\n * @param {number} k factor\n * @return {Point} output point\n */\n mult(k) {\n return this.clone()._mult(k);\n },\n /**\n * Divide this point's x & y coordinates by a factor,\n * yielding a new point.\n * @param {number} k factor\n * @return {Point} output point\n */\n div(k) {\n return this.clone()._div(k);\n },\n /**\n * Rotate this point around the 0, 0 origin by an angle a,\n * given in radians\n * @param {number} a angle to rotate around, in radians\n * @return {Point} output point\n */\n rotate(a) {\n return this.clone()._rotate(a);\n },\n /**\n * Rotate this point around p point by an angle a,\n * given in radians\n * @param {number} a angle to rotate around, in radians\n * @param {Point} p Point to rotate around\n * @return {Point} output point\n */\n rotateAround(a, p) {\n return this.clone()._rotateAround(a, p);\n },\n /**\n * Multiply this point by a 4x1 transformation matrix\n * @param {[number, number, number, number]} m transformation matrix\n * @return {Point} output point\n */\n matMult(m) {\n return this.clone()._matMult(m);\n },\n /**\n * Calculate this point but as a unit vector from 0, 0, meaning\n * that the distance from the resulting point to the 0, 0\n * coordinate will be equal to 1 and the angle from the resulting\n * point to the 0, 0 coordinate will be the same as before.\n * @return {Point} unit vector point\n */\n unit() {\n return this.clone()._unit();\n },\n /**\n * Compute a perpendicular point, where the new y coordinate\n * is the old x coordinate and the new x coordinate is the old y\n * coordinate multiplied by -1\n * @return {Point} perpendicular point\n */\n perp() {\n return this.clone()._perp();\n },\n /**\n * Return a version of this point with the x & y coordinates\n * rounded to integers.\n * @return {Point} rounded point\n */\n round() {\n return this.clone()._round();\n },\n /**\n * Return the magnitude of this point: this is the Euclidean\n * distance from the 0, 0 coordinate to this point's x and y\n * coordinates.\n * @return {number} magnitude\n */\n mag() {\n return Math.sqrt(this.x * this.x + this.y * this.y);\n },\n /**\n * Judge whether this point is equal to another point, returning\n * true or false.\n * @param {Point} other the other point\n * @return {boolean} whether the points are equal\n */\n equals(other) {\n return this.x === other.x && this.y === other.y;\n },\n /**\n * Calculate the distance from this point to another point\n * @param {Point} p the other point\n * @return {number} distance\n */\n dist(p) {\n return Math.sqrt(this.distSqr(p));\n },\n /**\n * Calculate the distance from this point to another point,\n * without the square root step. Useful if you're comparing\n * relative distances.\n * @param {Point} p the other point\n * @return {number} distance\n */\n distSqr(p) {\n const dx = p.x - this.x, dy = p.y - this.y;\n return dx * dx + dy * dy;\n },\n /**\n * Get the angle from the 0, 0 coordinate to this point, in radians\n * coordinates.\n * @return {number} angle\n */\n angle() {\n return Math.atan2(this.y, this.x);\n },\n /**\n * Get the angle from this point to another point, in radians\n * @param {Point} b the other point\n * @return {number} angle\n */\n angleTo(b) {\n return Math.atan2(this.y - b.y, this.x - b.x);\n },\n /**\n * Get the angle between this point and another point, in radians\n * @param {Point} b the other point\n * @return {number} angle\n */\n angleWith(b) {\n return this.angleWithSep(b.x, b.y);\n },\n /**\n * Find the angle of the two vectors, solving the formula for\n * the cross product a x b = |a||b|sin(\u03B8) for \u03B8.\n * @param {number} x the x-coordinate\n * @param {number} y the y-coordinate\n * @return {number} the angle in radians\n */\n angleWithSep(x, y) {\n return Math.atan2(\n this.x * y - this.y * x,\n this.x * x + this.y * y\n );\n },\n /** @param {[number, number, number, number]} m */\n _matMult(m) {\n const x = m[0] * this.x + m[1] * this.y, y = m[2] * this.x + m[3] * this.y;\n this.x = x;\n this.y = y;\n return this;\n },\n /** @param {Point} p */\n _add(p) {\n this.x += p.x;\n this.y += p.y;\n return this;\n },\n /** @param {Point} p */\n _sub(p) {\n this.x -= p.x;\n this.y -= p.y;\n return this;\n },\n /** @param {number} k */\n _mult(k) {\n this.x *= k;\n this.y *= k;\n return this;\n },\n /** @param {number} k */\n _div(k) {\n this.x /= k;\n this.y /= k;\n return this;\n },\n /** @param {Point} p */\n _multByPoint(p) {\n this.x *= p.x;\n this.y *= p.y;\n return this;\n },\n /** @param {Point} p */\n _divByPoint(p) {\n this.x /= p.x;\n this.y /= p.y;\n return this;\n },\n _unit() {\n this._div(this.mag());\n return this;\n },\n _perp() {\n const y = this.y;\n this.y = this.x;\n this.x = -y;\n return this;\n },\n /** @param {number} angle */\n _rotate(angle) {\n const cos = Math.cos(angle), sin = Math.sin(angle), x = cos * this.x - sin * this.y, y = sin * this.x + cos * this.y;\n this.x = x;\n this.y = y;\n return this;\n },\n /**\n * @param {number} angle\n * @param {Point} p\n */\n _rotateAround(angle, p) {\n const cos = Math.cos(angle), sin = Math.sin(angle), x = p.x + cos * (this.x - p.x) - sin * (this.y - p.y), y = p.y + sin * (this.x - p.x) + cos * (this.y - p.y);\n this.x = x;\n this.y = y;\n return this;\n },\n _round() {\n this.x = Math.round(this.x);\n this.y = Math.round(this.y);\n return this;\n },\n constructor: Point\n };\n Point.convert = function(p) {\n if (p instanceof Point) {\n return (\n /** @type {Point} */\n p\n );\n }\n if (Array.isArray(p)) {\n return new Point(+p[0], +p[1]);\n }\n if (p.x !== void 0 && p.y !== void 0) {\n return new Point(+p.x, +p.y);\n }\n throw new Error(\"Expected [x, y] or {x, y} point format\");\n };\n\n // ../../node_modules/.pnpm/@mapbox+vector-tile@2.0.4/node_modules/@mapbox/vector-tile/index.js\n var VectorTileFeature = class {\n /**\n * @param {Pbf} pbf\n * @param {number} end\n * @param {number} extent\n * @param {string[]} keys\n * @param {(number | string | boolean)[]} values\n */\n constructor(pbf, end, extent, keys, values) {\n this.properties = {};\n this.extent = extent;\n this.type = 0;\n this.id = void 0;\n this._pbf = pbf;\n this._geometry = -1;\n this._keys = keys;\n this._values = values;\n pbf.readFields(readFeature, this, end);\n }\n loadGeometry() {\n const pbf = this._pbf;\n pbf.pos = this._geometry;\n const end = pbf.readVarint() + pbf.pos;\n const lines = [];\n let line;\n let cmd = 1;\n let length = 0;\n let x = 0;\n let y = 0;\n while (pbf.pos < end) {\n if (length <= 0) {\n const cmdLen = pbf.readVarint();\n cmd = cmdLen & 7;\n length = cmdLen >> 3;\n }\n length--;\n if (cmd === 1 || cmd === 2) {\n x += pbf.readSVarint();\n y += pbf.readSVarint();\n if (cmd === 1) {\n if (line) lines.push(line);\n line = [];\n }\n if (line) line.push(new Point(x, y));\n } else if (cmd === 7) {\n if (line) {\n line.push(line[0].clone());\n }\n } else {\n throw new Error(`unknown command ${cmd}`);\n }\n }\n if (line) lines.push(line);\n return lines;\n }\n bbox() {\n const pbf = this._pbf;\n pbf.pos = this._geometry;\n const end = pbf.readVarint() + pbf.pos;\n let cmd = 1, length = 0, x = 0, y = 0, x1 = Infinity, x2 = -Infinity, y1 = Infinity, y2 = -Infinity;\n while (pbf.pos < end) {\n if (length <= 0) {\n const cmdLen = pbf.readVarint();\n cmd = cmdLen & 7;\n length = cmdLen >> 3;\n }\n length--;\n if (cmd === 1 || cmd === 2) {\n x += pbf.readSVarint();\n y += pbf.readSVarint();\n if (x < x1) x1 = x;\n if (x > x2) x2 = x;\n if (y < y1) y1 = y;\n if (y > y2) y2 = y;\n } else if (cmd !== 7) {\n throw new Error(`unknown command ${cmd}`);\n }\n }\n return [x1, y1, x2, y2];\n }\n /**\n * @param {number} x\n * @param {number} y\n * @param {number} z\n * @return {Feature}\n */\n toGeoJSON(x, y, z) {\n const size = this.extent * Math.pow(2, z), x0 = this.extent * x, y0 = this.extent * y, vtCoords = this.loadGeometry();\n function projectPoint2(p) {\n return [\n (p.x + x0) * 360 / size - 180,\n 360 / Math.PI * Math.atan(Math.exp((1 - (p.y + y0) * 2 / size) * Math.PI)) - 90\n ];\n }\n function projectLine(line) {\n return line.map(projectPoint2);\n }\n let geometry;\n if (this.type === 1) {\n const points = [];\n for (const line of vtCoords) {\n points.push(line[0]);\n }\n const coordinates = projectLine(points);\n geometry = points.length === 1 ? { type: \"Point\", coordinates: coordinates[0] } : { type: \"MultiPoint\", coordinates };\n } else if (this.type === 2) {\n const coordinates = vtCoords.map(projectLine);\n geometry = coordinates.length === 1 ? { type: \"LineString\", coordinates: coordinates[0] } : { type: \"MultiLineString\", coordinates };\n } else if (this.type === 3) {\n const polygons = classifyRings(vtCoords);\n const coordinates = [];\n for (const polygon of polygons) {\n coordinates.push(polygon.map(projectLine));\n }\n geometry = coordinates.length === 1 ? { type: \"Polygon\", coordinates: coordinates[0] } : { type: \"MultiPolygon\", coordinates };\n } else {\n throw new Error(\"unknown feature type\");\n }\n const result = {\n type: \"Feature\",\n geometry,\n properties: this.properties\n };\n if (this.id != null) {\n result.id = this.id;\n }\n return result;\n }\n };\n VectorTileFeature.types = [\"Unknown\", \"Point\", \"LineString\", \"Polygon\"];\n function readFeature(tag, feature, pbf) {\n if (tag === 1) feature.id = pbf.readVarint();\n else if (tag === 2) readTag(pbf, feature);\n else if (tag === 3) feature.type = /** @type {0 | 1 | 2 | 3} */\n pbf.readVarint();\n else if (tag === 4) feature._geometry = pbf.pos;\n }\n function readTag(pbf, feature) {\n const end = pbf.readVarint() + pbf.pos;\n while (pbf.pos < end) {\n const key = feature._keys[pbf.readVarint()];\n const value = feature._values[pbf.readVarint()];\n feature.properties[key] = value;\n }\n }\n function classifyRings(rings) {\n const len = rings.length;\n if (len <= 1) return [rings];\n const polygons = [];\n let polygon, ccw;\n for (let i = 0; i < len; i++) {\n const area = signedArea(rings[i]);\n if (area === 0) continue;\n if (ccw === void 0) ccw = area < 0;\n if (ccw === area < 0) {\n if (polygon) polygons.push(polygon);\n polygon = [rings[i]];\n } else if (polygon) {\n polygon.push(rings[i]);\n }\n }\n if (polygon) polygons.push(polygon);\n return polygons;\n }\n function signedArea(ring) {\n let sum = 0;\n for (let i = 0, len = ring.length, j = len - 1, p1, p2; i < len; j = i++) {\n p1 = ring[i];\n p2 = ring[j];\n sum += (p2.x - p1.x) * (p1.y + p2.y);\n }\n return sum;\n }\n var VectorTileLayer = class {\n /**\n * @param {Pbf} pbf\n * @param {number} [end]\n */\n constructor(pbf, end) {\n this.version = 1;\n this.name = \"\";\n this.extent = 4096;\n this.length = 0;\n this._pbf = pbf;\n this._keys = [];\n this._values = [];\n this._features = [];\n pbf.readFields(readLayer, this, end);\n this.length = this._features.length;\n }\n /** return feature `i` from this layer as a `VectorTileFeature`\n * @param {number} i\n */\n feature(i) {\n if (i < 0 || i >= this._features.length) throw new Error(\"feature index out of bounds\");\n this._pbf.pos = this._features[i];\n const end = this._pbf.readVarint() + this._pbf.pos;\n return new VectorTileFeature(this._pbf, end, this.extent, this._keys, this._values);\n }\n };\n function readLayer(tag, layer, pbf) {\n if (tag === 15) layer.version = pbf.readVarint();\n else if (tag === 1) layer.name = pbf.readString();\n else if (tag === 5) layer.extent = pbf.readVarint();\n else if (tag === 2) layer._features.push(pbf.pos);\n else if (tag === 3) layer._keys.push(pbf.readString());\n else if (tag === 4) layer._values.push(readValueMessage(pbf));\n }\n function readValueMessage(pbf) {\n let value = null;\n const end = pbf.readVarint() + pbf.pos;\n while (pbf.pos < end) {\n const tag = pbf.readVarint() >> 3;\n value = tag === 1 ? pbf.readString() : tag === 2 ? pbf.readFloat() : tag === 3 ? pbf.readDouble() : tag === 4 ? pbf.readVarint64() : tag === 5 ? pbf.readVarint() : tag === 6 ? pbf.readSVarint() : tag === 7 ? pbf.readBoolean() : null;\n }\n if (value == null) {\n throw new Error(\"unknown feature value\");\n }\n return value;\n }\n var VectorTile = class {\n /**\n * @param {Pbf} pbf\n * @param {number} [end]\n */\n constructor(pbf, end) {\n this.layers = pbf.readFields(readTile, {}, end);\n }\n };\n function readTile(tag, layers, pbf) {\n if (tag === 3) {\n const layer = new VectorTileLayer(pbf, pbf.readVarint() + pbf.pos);\n if (layer.length) layers[layer.name] = layer;\n }\n }\n\n // src/ESCesiumViewer/ViewerExtensions/VectorTilesManager/vectorTilesWorker.ts\n self.onmessage = async (e) => {\n var _a, _b, _c, _d, _e, _f, _g, _h, _i;\n if (e.data.type === \"fetch\") {\n const { url, x, y, z, style, tileSize: size } = e.data;\n const polygonMap = /* @__PURE__ */ new Map();\n const lineMap = /* @__PURE__ */ new Map();\n try {\n const buffer = await (await fetch(url)).arrayBuffer();\n const tile = new VectorTile(new Pbf(buffer));\n const tileData = {};\n for (const layerName in tile.layers) {\n const layer = tile.layers[layerName];\n const extent = layer.extent || 4096;\n const points = [];\n const pointProps = [];\n const lines = [];\n const lineOffsets = [];\n const lineProps = [];\n const polygons = [];\n const polygonOffsets = [];\n const polygonProps = [];\n let polygonFeatures = polygonMap.get(layerName), lineFeatures = lineMap.get(layerName);\n if (!polygonFeatures) {\n polygonFeatures = {\n extent,\n features: []\n };\n polygonMap.set(layerName, polygonFeatures);\n }\n if (!lineFeatures) {\n lineFeatures = {\n extent,\n features: []\n };\n lineMap.set(layerName, lineFeatures);\n }\n for (let i = 0; i < layer.length; i++) {\n const feature = layer.feature(i);\n let geometry;\n try {\n geometry = feature.loadGeometry();\n } catch (e2) {\n continue;\n }\n const type = feature.type;\n const properties = feature.properties || {};\n if (type === 1) {\n let sx = 0, sy = 0, cnt = 0;\n for (const ring of geometry) {\n for (const p of ring) {\n if (p.x < 0 || p.y < 0 || p.x > extent || p.y > extent)\n continue;\n sx += p.x;\n sy += p.y;\n cnt++;\n }\n }\n if (!cnt) continue;\n const [px, py] = [sx / cnt, sy / cnt];\n const [lon, lat] = projectPoint(px, py, x, y, z, extent);\n points.push(lon, lat, 0);\n pointProps.push(properties);\n } else if (type === 2) {\n lineFeatures.features.push(geometry);\n lineOffsets.push(lines.length / 3);\n for (const ring of geometry)\n for (const p of ring) {\n const [lon, lat] = projectPoint(p.x, p.y, x, y, z, extent);\n lines.push(lon, lat, 0);\n }\n lineProps.push(properties);\n } else if (type === 3) {\n polygonFeatures.features.push({\n geometry,\n area: featureArea(geometry)\n });\n polygonOffsets.push(polygons.length / 3);\n for (const ring of geometry)\n for (const p of ring) {\n const [lon, lat] = projectPoint(p.x, p.y, x, y, z, extent);\n polygons.push(lon, lat, 0);\n }\n polygonProps.push(properties);\n }\n }\n tileData[layerName] = {\n points: new Float32Array(points),\n pointProps,\n lines: new Float32Array(lines),\n lineOffsets: new Uint32Array(lineOffsets),\n lineProps,\n polygons: new Float32Array(polygons),\n polygonOffsets: new Uint32Array(polygonOffsets),\n polygonProps\n };\n }\n const transfers = [];\n for (const layerName in tileData) {\n const layer = tileData[layerName];\n transfers.push(\n layer.points.buffer,\n layer.lines.buffer,\n layer.lineOffsets.buffer,\n layer.polygons.buffer,\n layer.polygonOffsets.buffer\n );\n }\n const screenCanvasPolygon = new OffscreenCanvas(size, size);\n const screenCanvasPolyline = new OffscreenCanvas(size, size);\n const ctxPolygon = screenCanvasPolygon.getContext(\"2d\");\n const ctxPolyline = screenCanvasPolyline.getContext(\"2d\");\n ctxPolygon.clearRect(0, 0, size, size);\n ctxPolyline.clearRect(0, 0, size, size);\n if (style) {\n for (const layer of style) {\n const polygonData = (_a = polygonMap.get(layer[\"source-layer\"])) != null ? _a : { extent: 4096, features: [] };\n const lineData = (_b = lineMap.get(layer[\"source-layer\"])) != null ? _b : { extent: 4096, features: [] };\n const polygonExtentFactor = size / polygonData.extent;\n const lineExtentFactor = size / lineData.extent;\n for (let index = 0; index < lineData.features.length; index++) {\n ctxPolyline.beginPath();\n const coordinates = lineData.features[index];\n if (layer.polylineStyle && (!layer.polylineStyle.visibility || layer.polylineStyle.visibility === \"visible\")) {\n ctxPolyline.strokeStyle = ((_c = layer.polylineStyle) == null ? void 0 : _c.color) || \"#000000\";\n ctxPolyline.lineWidth = ((_d = layer.polylineStyle) == null ? void 0 : _d.width) || 1;\n ctxPolyline.lineCap = ((_e = layer.polylineStyle) == null ? void 0 : _e.cap) || \"butt\";\n ctxPolyline.lineJoin = ((_f = layer.polylineStyle) == null ? void 0 : _f.join) || \"miter\";\n coordinates.forEach((coordinate, i) => {\n coordinate.forEach((pt, i2) => {\n const [tileX, tileY] = [pt.x * lineExtentFactor, pt.y * lineExtentFactor];\n i2 === 0 ? ctxPolyline.moveTo(tileX, tileY) : ctxPolyline.lineTo(tileX, tileY);\n });\n });\n }\n ctxPolyline.stroke();\n }\n polygonData.features.sort((a, b) => b.area - a.area);\n if (layer.polygonStyle && (!layer.polygonStyle.visibility || layer.polygonStyle.visibility === \"visible\")) {\n const fillColor = ((_g = layer.polygonStyle) == null ? void 0 : _g.color) || \"#000000\";\n const strokeColor = (_h = layer.polygonStyle) == null ? void 0 : _h.outlineColor;\n const lineWidth = ((_i = layer.polygonStyle) == null ? void 0 : _i.outlineWidth) || 1;\n ctxPolygon.fillStyle = fillColor;\n if (strokeColor) {\n ctxPolygon.strokeStyle = strokeColor;\n ctxPolygon.lineWidth = lineWidth;\n }\n polygonData.features.forEach(({ geometry }) => {\n const polygons = classifyRings2(geometry);\n polygons.forEach((polygon) => {\n ctxPolygon.beginPath();\n polygon.forEach((ring) => {\n ring.forEach((pt, i) => {\n const x2 = pt.x * polygonExtentFactor;\n const y2 = pt.y * polygonExtentFactor;\n if (i === 0) ctxPolygon.moveTo(x2, y2);\n else ctxPolygon.lineTo(x2, y2);\n });\n ctxPolygon.closePath();\n });\n ctxPolygon.fill(\"evenodd\");\n if (strokeColor) {\n ctxPolygon.stroke();\n }\n });\n });\n }\n }\n }\n const bitmapPolygon = screenCanvasPolygon.transferToImageBitmap();\n const bitmapPolyline = screenCanvasPolyline.transferToImageBitmap();\n self.postMessage({ url, tileData, bitmapPolygon, bitmapPolyline }, [...transfers, bitmapPolygon, bitmapPolyline]);\n } catch (err) {\n self.postMessage({ url, error: err.message });\n }\n }\n };\n function projectPoint(px, py, x, y, z, extent = 4096) {\n const size = extent * Math.pow(2, z), x0 = x * extent, y0 = y * extent;\n return [\n (px + x0) * 360 / size - 180,\n 360 / Math.PI * Math.atan(Math.exp((1 - (py + y0) * 2 / size) * Math.PI)) - 90\n ];\n }\n function classifyRings2(rings) {\n const len = rings.length;\n if (len <= 1) return [rings];\n const polygons = [];\n let polygon, ccw;\n for (let i = 0; i < len; i++) {\n const area = signedArea2(rings[i]);\n if (area === 0) continue;\n if (ccw === void 0) ccw = area < 0;\n if (ccw === area < 0) {\n if (polygon) polygons.push(polygon);\n polygon = [rings[i]];\n } else if (polygon) {\n polygon.push(rings[i]);\n }\n }\n if (polygon) polygons.push(polygon);\n return polygons;\n }\n function featureArea(rings) {\n const polygons = classifyRings2(rings);\n let total = 0;\n for (const polygon of polygons) {\n let polyArea = 0;\n for (const ring of polygon) {\n polyArea += Math.abs(signedArea2(ring));\n }\n total += polyArea;\n }\n return total;\n }\n function signedArea2(ring) {\n let sum = 0;\n for (let i = 0, len = ring.length, j = len - 1, p1, p2; i < len; j = i++) {\n p1 = ring[i];\n p2 = ring[j];\n sum += (p2.x - p1.x) * (p1.y + p2.y);\n }\n return sum;\n }\n})();\n";
|
|
2
2
|
export default _default;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function normalizeTileURL(url: string, accessToken: string): string | undefined;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "earthsdk3-cesium",
|
|
3
|
-
"version": "3.7.0-beta.
|
|
3
|
+
"version": "3.7.0-beta.21",
|
|
4
4
|
"description": "地球可视化实验室 (EarthSDK&CesiumLab) https://www.bjxbsj.cn",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/earthsdk3-cesium.umd.cjs",
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
},
|
|
40
40
|
"peerDependencies": {
|
|
41
41
|
"cesium": "1.134.1",
|
|
42
|
-
"earthsdk3": "3.7.0-beta.
|
|
42
|
+
"earthsdk3": "3.7.0-beta.18"
|
|
43
43
|
},
|
|
44
44
|
"dependencies": {
|
|
45
45
|
"@types/delaunator": "^5.0.2",
|