earthsdk3-cesium 3.7.0-beta.18 → 3.7.0-beta.20
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/earthsdk3-cesium.iife.js +1480 -85
- package/dist/earthsdk3-cesium.js +13650 -12250
- package/dist/earthsdk3-cesium.umd.cjs +1493 -98
- package/dist/types/ESCesiumViewer/ViewerExtensions/VectorTilesManager/WorkerPool.d.ts +1 -1
- package/dist/types/ESCesiumViewer/ViewerExtensions/VectorTilesManager/vectorTilesWorker.inline.d.ts +2 -0
- package/package.json +3 -2
|
@@ -3,7 +3,7 @@ export declare class WorkerPool extends Destroyable {
|
|
|
3
3
|
private workers;
|
|
4
4
|
private queue;
|
|
5
5
|
private destroyed;
|
|
6
|
-
constructor(
|
|
6
|
+
constructor(createWorker: () => Worker, workerCount?: number);
|
|
7
7
|
/**
|
|
8
8
|
* 获取空闲 worker,如果都被占用,则等待
|
|
9
9
|
*/
|
package/dist/types/ESCesiumViewer/ViewerExtensions/VectorTilesManager/vectorTilesWorker.inline.d.ts
ADDED
|
@@ -0,0 +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";
|
|
2
|
+
export default _default;
|
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.20",
|
|
4
4
|
"description": "地球可视化实验室 (EarthSDK&CesiumLab) https://www.bjxbsj.cn",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/earthsdk3-cesium.umd.cjs",
|
|
@@ -21,7 +21,8 @@
|
|
|
21
21
|
"license": "ISC",
|
|
22
22
|
"scripts": {
|
|
23
23
|
"typecheck": "tsc --noEmit",
|
|
24
|
-
"build": "
|
|
24
|
+
"build:worker": "node ./tools/buildWorker.js",
|
|
25
|
+
"build": "npm run build:worker && npm run typecheck && vite build && tsc-alias",
|
|
25
26
|
"push:beta": "npm publish --registry https://registry.npmjs.org --tag beta",
|
|
26
27
|
"login": "npm login --registry https://registry.npmjs.org",
|
|
27
28
|
"push": "npm publish --registry https://registry.npmjs.org",
|