cesium-mars-op-cog 0.1.0

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/index.js ADDED
@@ -0,0 +1,582 @@
1
+ import * as k from "cesium";
2
+ import { Event as P, GeographicTilingScheme as z, Rectangle as T } from "cesium";
3
+ import C from "proj4";
4
+ import { onUnmounted as E, ref as x, shallowRef as S } from "vue";
5
+ var R = class {
6
+ poolSize;
7
+ maxLoadPerWorker;
8
+ workers = [];
9
+ queue = [];
10
+ taskMap = /* @__PURE__ */ new Map();
11
+ taskIdCounter = 0;
12
+ workerLoad = /* @__PURE__ */ new Map();
13
+ workerInitialized = /* @__PURE__ */ new Set();
14
+ workerInitializing = /* @__PURE__ */ new Set();
15
+ initPayload = null;
16
+ _initPromise = null;
17
+ constructor(e, t = navigator.hardwareConcurrency || 4, r = 4) {
18
+ this.poolSize = t, this.maxLoadPerWorker = r;
19
+ for (let i = 0; i < t; i++) {
20
+ const s = e();
21
+ s.onmessage = (o) => this._handleMessage(o, i), s.onerror = (o) => console.error("Worker error:", o), this.workers.push(s), this.workerLoad.set(i, 0);
22
+ }
23
+ }
24
+ async initOne(e) {
25
+ this.initPayload = e, this.workerInitialized.clear(), this.workerInitializing.clear();
26
+ const t = await new Promise((r, i) => {
27
+ const s = ++this.taskIdCounter;
28
+ this.taskMap.set(s, {
29
+ resolve: r,
30
+ reject: i
31
+ }), this.workerLoad.set(0, (this.workerLoad.get(0) || 0) + 1), this.workerInitializing.add(0), this.workers[0].postMessage({
32
+ type: "INIT",
33
+ payload: e,
34
+ taskId: s
35
+ });
36
+ });
37
+ return this._initPromise = this._initRemainingWorkers(), t;
38
+ }
39
+ async _initRemainingWorkers() {
40
+ const e = [];
41
+ for (let t = 1; t < this.poolSize; t++) !this.workerInitialized.has(t) && !this.workerInitializing.has(t) && e.push(new Promise((r) => {
42
+ this.workerInitializing.add(t);
43
+ const i = ++this.taskIdCounter;
44
+ this.taskMap.set(i, {
45
+ resolve: () => r(),
46
+ reject: () => r()
47
+ }), this.workerLoad.set(t, (this.workerLoad.get(t) || 0) + 1), this.workers[t].postMessage({
48
+ type: "LAZY_INIT",
49
+ payload: this.initPayload,
50
+ taskId: i
51
+ });
52
+ }));
53
+ await Promise.allSettled(e);
54
+ }
55
+ _getLeastLoadedWorker() {
56
+ let e = -1, t = 1 / 0;
57
+ for (const r of this.workerInitialized) {
58
+ const i = this.workerLoad.get(r) ?? 0;
59
+ i < t && (t = i, e = r);
60
+ }
61
+ if (e === -1)
62
+ for (const [r, i] of this.workerLoad.entries()) i < t && (t = i, e = r);
63
+ return e >= 0 ? e : 0;
64
+ }
65
+ _handleMessage(e, t) {
66
+ const { type: r, taskId: i, payload: s } = e.data, o = this.taskMap.get(i);
67
+ if (!o) return;
68
+ const n = this.workerLoad.get(t) || 1;
69
+ this.workerLoad.set(t, Math.max(0, n - 1)), r === "INIT_DONE" ? (this.workerInitialized.add(t), this.workerInitializing.delete(t), o.resolve(s)) : r === "TILE_DONE" ? o.resolve(s) : r === "ERROR" && (this.workerInitializing.has(t) && (this.workerInitialized.add(t), this.workerInitializing.delete(t)), o.reject(new Error(s?.error || "Worker error"))), this.taskMap.delete(i), this._processQueue();
70
+ }
71
+ _processQueue() {
72
+ if (this.queue.length === 0) return;
73
+ let e = 0;
74
+ const t = Math.min(this.queue.length, this.poolSize);
75
+ for (let r = 0; r < t; r++) {
76
+ let i = -1, s = 1 / 0;
77
+ for (const a of this.workerInitialized) {
78
+ const d = this.workerLoad.get(a) ?? 0;
79
+ d < this.maxLoadPerWorker && d < s && (s = d, i = a);
80
+ }
81
+ if (i === -1) {
82
+ for (let a = 0; a < this.poolSize; a++) if (!this.workerInitialized.has(a) && !this.workerInitializing.has(a)) {
83
+ this.workerInitializing.add(a);
84
+ const d = ++this.taskIdCounter;
85
+ this.taskMap.set(d, {
86
+ resolve: () => {
87
+ },
88
+ reject: () => {
89
+ }
90
+ }), this.workerLoad.set(a, (this.workerLoad.get(a) || 0) + 1), this.workers[a].postMessage({
91
+ type: "LAZY_INIT",
92
+ payload: this.initPayload,
93
+ taskId: d
94
+ });
95
+ break;
96
+ }
97
+ break;
98
+ }
99
+ const o = this.queue.shift();
100
+ e++;
101
+ const n = ++this.taskIdCounter;
102
+ this.taskMap.set(n, {
103
+ resolve: o.resolve,
104
+ reject: o.reject
105
+ }), this.workerLoad.set(i, (this.workerLoad.get(i) || 0) + 1), this.workers[i].postMessage({
106
+ type: o.type,
107
+ payload: o.payload,
108
+ taskId: n
109
+ });
110
+ }
111
+ }
112
+ execute(e, t) {
113
+ return new Promise((r, i) => {
114
+ this.queue.push({
115
+ type: e,
116
+ payload: t,
117
+ resolve: r,
118
+ reject: i
119
+ }), this._processQueue();
120
+ });
121
+ }
122
+ terminate() {
123
+ for (const e of this.queue) e.reject?.(/* @__PURE__ */ new Error("WorkerPool 已终止"));
124
+ for (const [, e] of this.taskMap) e.reject?.(/* @__PURE__ */ new Error("WorkerPool 已终止"));
125
+ for (const e of this.workers) e.terminate();
126
+ this.workers = [], this.queue = [], this.taskMap.clear(), this.workerInitialized.clear(), this.workerInitializing.clear();
127
+ }
128
+ };
129
+ function G(e) {
130
+ return new Worker("/assets/cogTile.worker-BmAOLWmU.js", { name: e?.name });
131
+ }
132
+ var W = class {
133
+ max;
134
+ map;
135
+ onEvict;
136
+ constructor(e = 256, t) {
137
+ this.max = e, this.map = /* @__PURE__ */ new Map(), this.onEvict = t ?? null;
138
+ }
139
+ get(e) {
140
+ if (!this.map.has(e)) return;
141
+ const t = this.map.get(e);
142
+ return this.map.delete(e), this.map.set(e, t), t;
143
+ }
144
+ set(e, t) {
145
+ if (this.map.has(e) && this.map.delete(e), this.map.set(e, t), this.map.size > this.max) {
146
+ const r = this.map.keys().next().value, i = this.map.get(r);
147
+ this.map.delete(r), this.onEvict?.(r, i);
148
+ }
149
+ }
150
+ delete(e) {
151
+ return this.map.delete(e);
152
+ }
153
+ clear() {
154
+ this.map.clear();
155
+ }
156
+ get size() {
157
+ return this.map.size;
158
+ }
159
+ };
160
+ function O() {
161
+ C.defs("EPSG:3857", "+proj=merc +a=6378137 +b=6378137 +lat_ts=0 +lon_0=0 +x_0=0 +y_0=0 +k=1 +units=m +nadgrids=@null +wktext +no_defs"), C.defs("EPSG:4326", "+proj=longlat +datum=WGS84 +no_defs"), C.defs("EPSG:4548", "+proj=tmerc +lat_0=0 +lon_0=117 +k=1 +x_0=500000 +y_0=0 +ellps=GRS80 +units=m +no_defs");
162
+ for (let e = 75; e <= 135; e += 3) {
163
+ const t = 4524 + Math.floor((e - 75) / 3);
164
+ C.defs(`EPSG:${t}`, `+proj=tmerc +lat_0=0 +lon_0=${e} +k=1 +x_0=500000 +y_0=0 +ellps=GRS80 +units=m +no_defs`);
165
+ }
166
+ }
167
+ O();
168
+ var q = {
169
+ poolSize: Math.max(2, Math.min(6, Math.floor((navigator.hardwareConcurrency || 4) / 2))),
170
+ maxLoadPerWorker: 8,
171
+ timeout: 3e4,
172
+ tileCacheSize: 512,
173
+ alpha: 1
174
+ }, I = class {
175
+ tileWidth = 256;
176
+ tileHeight = 256;
177
+ tilingScheme = new z();
178
+ hasAlphaChannel = !0;
179
+ ready = !0;
180
+ maximumLevel;
181
+ minimumLevel;
182
+ rectangle;
183
+ _errorEvent;
184
+ get errorEvent() {
185
+ return this._errorEvent;
186
+ }
187
+ get bboxDegrees() {
188
+ return this._bbox;
189
+ }
190
+ _url;
191
+ _options;
192
+ _workerPool;
193
+ _tileCache;
194
+ _inflightRequests = /* @__PURE__ */ new Map();
195
+ _emptyTile;
196
+ _destroyed = !1;
197
+ _bbox = [
198
+ 0,
199
+ 0,
200
+ 0,
201
+ 0
202
+ ];
203
+ _initialized = !1;
204
+ constructor(e, t) {
205
+ this._url = e, this._options = {
206
+ ...q,
207
+ ...t
208
+ }, this._tileCache = new W(this._options.tileCacheSize, (r, i) => {
209
+ i.close();
210
+ }), this._emptyTile = document.createElement("canvas"), this._emptyTile.width = 256, this._emptyTile.height = 256;
211
+ }
212
+ async init() {
213
+ if (this._initialized) return;
214
+ if (this._destroyed) throw new Error("CogImageryProvider 已销毁");
215
+ this._workerPool = new R(() => new G(), this._options.poolSize, this._options.maxLoadPerWorker);
216
+ const e = await Promise.race([this._workerPool.initOne({ url: this._url }), new Promise((l, c) => setTimeout(() => c(/* @__PURE__ */ new Error("COG 初始化超时")), this._options.timeout))]);
217
+ if (!e || !Array.isArray(e.bbox) || e.bbox.length !== 4) throw new Error("COG 元数据无效: bbox 格式错误");
218
+ const t = e.bbox, r = t[0], i = t[1], s = t[2], o = t[3];
219
+ if (!isFinite(r) || !isFinite(i) || !isFinite(s) || !isFinite(o)) throw new Error("COG 元数据无效: bbox 包含非数值");
220
+ const n = e.maxLevel ?? 17, a = e.minLevel ?? Math.max(0, n - 8), d = e.crsType ?? "4326";
221
+ this._bbox = this._normalizeBbox(r, i, s, o, d), this.maximumLevel = n, this.minimumLevel = a, this.rectangle = T.fromDegrees(this._bbox[0], this._bbox[1], this._bbox[2], this._bbox[3]), this._errorEvent = new P(), this._initialized = !0, console.log(`[COG] 初始化完成, 级别 ${a}-${n}, bbox: [${this._bbox.join(", ")}]`);
222
+ }
223
+ _normalizeBbox(e, t, r, i, s) {
224
+ if (Math.abs(e) <= 360 && Math.abs(r) <= 360 && Math.abs(t) <= 90 && Math.abs(i) <= 90) return [
225
+ e,
226
+ t,
227
+ r,
228
+ i
229
+ ];
230
+ try {
231
+ const o = C(`EPSG:${s}`, "EPSG:4326"), n = o.forward([e, t]), a = o.forward([r, i]);
232
+ if (isFinite(n[0]) && isFinite(n[1]) && isFinite(a[0]) && isFinite(a[1]) && Math.abs(n[0]) <= 180 && Math.abs(a[0]) <= 180 && Math.abs(n[1]) <= 90 && Math.abs(a[1]) <= 90) return [
233
+ n[0],
234
+ n[1],
235
+ a[0],
236
+ a[1]
237
+ ];
238
+ } catch {
239
+ }
240
+ throw new Error(`bbox 超出度坐标范围 [${e}, ${t}, ${r}, ${i}],CRS=${s},转换失败`);
241
+ }
242
+ isDestroyed() {
243
+ return this._destroyed;
244
+ }
245
+ async requestImage(e, t, r) {
246
+ if (this._destroyed || !this._initialized) return;
247
+ const [i, s, o, n] = this._bbox, a = Math.pow(2, r + 1), d = Math.pow(2, r), l = 360 / a, c = 180 / d, m = e * l - 180, v = m + l, p = 90 - t * c, y = p - c;
248
+ if (v <= i || m >= o || p <= s || y >= n) return this._emptyTile;
249
+ const g = `${this._url}_${e}_${t}_${r}`, _ = this._tileCache.get(g);
250
+ if (_) {
251
+ const u = document.createElement("canvas");
252
+ return u.width = _.width, u.height = _.height, u.getContext("2d").drawImage(_, 0, 0), u;
253
+ }
254
+ let f = this._inflightRequests.get(g);
255
+ f || (f = this._fetchTile(g, e, t, r, {
256
+ west: m,
257
+ south: y,
258
+ east: v,
259
+ north: p
260
+ }), this._inflightRequests.set(g, f));
261
+ const w = await f;
262
+ if (!w) return this._emptyTile;
263
+ const h = document.createElement("canvas");
264
+ return h.width = w.width, h.height = w.height, h.getContext("2d").drawImage(w, 0, 0), h;
265
+ }
266
+ async _fetchTile(e, t, r, i, s) {
267
+ try {
268
+ const o = await this._workerPool.execute("PROCESS_TILE", {
269
+ x: t,
270
+ y: r,
271
+ level: i,
272
+ tileRect: s,
273
+ alpha: this._options.alpha
274
+ });
275
+ return !o || o.empty || !o.bitmap ? null : (this._tileCache.set(e, o.bitmap), o.bitmap);
276
+ } finally {
277
+ this._inflightRequests.delete(e);
278
+ }
279
+ }
280
+ destroy() {
281
+ this._destroyed = !0, this._workerPool?.terminate(), this._tileCache.clear(), this._inflightRequests.clear(), this._initialized = !1;
282
+ }
283
+ };
284
+ function $(e, t = 0.3) {
285
+ const r = e.east - e.west, i = e.north - e.south, s = r * t, o = i * t;
286
+ return {
287
+ west: e.west - s,
288
+ south: e.south - o,
289
+ east: e.east + s,
290
+ north: e.north + o
291
+ };
292
+ }
293
+ async function N(e, t) {
294
+ const r = new I(e, t);
295
+ return await r.init(), r;
296
+ }
297
+ async function B(e, t, r) {
298
+ const i = new I(t, r);
299
+ await i.init();
300
+ const s = e.imageryLayers.addImageryProvider(i);
301
+ if (s.alpha = r?.alpha ?? 1, r?.flyTo !== !1 && e.camera) {
302
+ const o = i.bboxDegrees, n = $({
303
+ west: o[0],
304
+ south: o[1],
305
+ east: o[2],
306
+ north: o[3]
307
+ }, 0.3);
308
+ e.camera.flyTo({
309
+ destination: {
310
+ west: n.west,
311
+ south: n.south,
312
+ east: n.east,
313
+ north: n.north
314
+ },
315
+ duration: 1.5
316
+ });
317
+ }
318
+ return s;
319
+ }
320
+ async function Y(e, t, r) {
321
+ const i = new I(t, r);
322
+ await i.init();
323
+ const s = i.bboxDegrees, o = i.maximumLevel, n = i.minimumLevel, a = await j(), { TileGrid: d } = a.tilegrid, l = 256, c = [];
324
+ for (let g = 0; g <= o; g++) c.push(360 / (l * Math.pow(2, g + 1)));
325
+ const m = new d({
326
+ extent: [
327
+ -180,
328
+ -90,
329
+ 180,
330
+ 90
331
+ ],
332
+ origin: [-180, 90],
333
+ resolutions: c,
334
+ tileSize: [l, l]
335
+ }), v = new a.source.TileImage({
336
+ projection: "EPSG:4326",
337
+ tileGrid: m,
338
+ tileUrlFunction: (g) => `cog://${g[0]}/${g[1]}/${g[2]}`,
339
+ tileLoadFunction: (g, _) => {
340
+ const f = _.replace("cog://", "").split("/"), w = Number(f[0]), h = Number(f[1]), u = Number(f[2]);
341
+ i.requestImage(h, u, w).then((L) => {
342
+ L && L.toBlob((b) => {
343
+ if (b) {
344
+ const M = g.getImage();
345
+ M.src = URL.createObjectURL(b);
346
+ }
347
+ });
348
+ }).catch(() => {
349
+ });
350
+ }
351
+ }), p = new a.layer.Tile({
352
+ source: v,
353
+ opacity: r?.opacity ?? 1,
354
+ extent: [
355
+ s[0],
356
+ s[1],
357
+ s[2],
358
+ s[3]
359
+ ],
360
+ minResolution: c[Math.min(o, c.length - 1)],
361
+ maxResolution: c[Math.min(n, c.length - 1)]
362
+ });
363
+ e.addLayer(p);
364
+ const y = e.getView();
365
+ return y && y.fit([
366
+ s[0],
367
+ s[1],
368
+ s[2],
369
+ s[3]
370
+ ], {
371
+ padding: [
372
+ 50,
373
+ 50,
374
+ 50,
375
+ 50
376
+ ],
377
+ duration: 1500
378
+ }), p;
379
+ }
380
+ async function j() {
381
+ try {
382
+ const e = (await import("ol/tilegrid/TileGrid")).default, t = (await import("ol/source/TileImage")).default, r = (await import("ol/layer/Tile")).default;
383
+ return {
384
+ tilegrid: { TileGrid: e },
385
+ source: { TileImage: t },
386
+ layer: { Tile: r }
387
+ };
388
+ } catch {
389
+ throw new Error("OpenLayers 依赖未找到,请安装: npm install ol");
390
+ }
391
+ }
392
+ function A(e) {
393
+ const t = /* @__PURE__ */ new Map();
394
+ return {
395
+ async addCogLayer(r, i, s = {}) {
396
+ const o = e();
397
+ if (!o) throw new Error("Cesium Viewer 未初始化");
398
+ const n = {
399
+ alpha: 1,
400
+ flyTo: !0,
401
+ ...s
402
+ };
403
+ let a = null, d = null;
404
+ try {
405
+ a = new I(i, n), await a.init(), d = o.imageryLayers.addImageryProvider(a), d.alpha = n.alpha;
406
+ const l = a.bboxDegrees, c = {
407
+ imageryLayer: d,
408
+ layerId: r,
409
+ provider: a,
410
+ bbox: [...l]
411
+ };
412
+ if (t.set(r, c), n.flyTo !== !1) {
413
+ const [m, v, p, y] = l, g = p - m, _ = y - v, f = g * 0.3, w = _ * 0.3, h = T.fromDegrees(m - f, v - w, p + f, y + w);
414
+ o.camera.flyTo({
415
+ destination: h,
416
+ duration: 1.5
417
+ });
418
+ }
419
+ return console.log("[COG] 加载成功:", r), c;
420
+ } catch (l) {
421
+ if (a?.destroy(), d) try {
422
+ o.imageryLayers.remove(d, !0);
423
+ } catch {
424
+ }
425
+ throw l;
426
+ }
427
+ },
428
+ removeCogLayer(r) {
429
+ const i = t.get(r);
430
+ if (!i) {
431
+ console.warn("[COG] 图层不存在:", r);
432
+ return;
433
+ }
434
+ try {
435
+ i.provider.destroy();
436
+ const s = e();
437
+ s && (i.imageryLayer.show = !1, s.scene.requestRender(), requestAnimationFrame(() => {
438
+ try {
439
+ s.imageryLayers.remove(i.imageryLayer, !0), s.scene.requestRender();
440
+ } catch {
441
+ }
442
+ }));
443
+ } catch (s) {
444
+ console.warn("[COG] 移除图层时出错:", s);
445
+ }
446
+ t.delete(r);
447
+ },
448
+ flyToCogLayer(r) {
449
+ const i = t.get(r);
450
+ if (!i) {
451
+ console.warn("[COG] 图层不存在:", r);
452
+ return;
453
+ }
454
+ const s = e();
455
+ if (!s) return;
456
+ const [o, n, a, d] = i.bbox, l = (a - o) * 0.3, c = (d - n) * 0.3, m = T.fromDegrees(o - l, n - c, a + l, d + c);
457
+ s.camera.flyTo({
458
+ destination: m,
459
+ duration: 1.5
460
+ });
461
+ },
462
+ destroyCogTools() {
463
+ for (const [r] of t) this.removeCogLayer(r);
464
+ t.clear();
465
+ }
466
+ };
467
+ }
468
+ function V(e = {}) {
469
+ const { baseUrl: t = "/Cesium/", cogApiUrl: r = "http://localhost:5158/api/cog/list", cogStaticBaseUrl: i = "http://localhost:5158", viewerOptions: s = {} } = e, o = S(null), n = x([]), a = x(""), d = x(!1), l = x(null);
470
+ let c = null, m = null;
471
+ const v = async (h = "cesiumContainer") => {
472
+ try {
473
+ window.CESIUM_BASE_URL = t, k.RequestScheduler.maximumRequests = 100, k.RequestScheduler.maximumRequestsPerServer = 24, o.value = new k.Viewer(h, {
474
+ geocoder: !1,
475
+ animation: !1,
476
+ timeline: !1,
477
+ baseLayerPicker: !1,
478
+ terrainProvider: new k.EllipsoidTerrainProvider(),
479
+ imagery: !1,
480
+ sun: !1,
481
+ moon: !1,
482
+ ...s
483
+ }), o.value.imageryLayers.length > 0 ? console.log("[CogManager] 当前已有底图,不再重复清理") : o.value.imageryLayers.addImageryProvider(new k.UrlTemplateImageryProvider({
484
+ url: "https://tile.openstreetmap.org/{z}/{x}/{y}.png",
485
+ tilingScheme: new k.WebMercatorTilingScheme(),
486
+ maximumLevel: 18
487
+ }));
488
+ const u = o.value.scene;
489
+ u.fog.enabled = !1, u.highDynamicRange = !1, u.globe.depthTestAgainstTerrain = !1, u.globe.baseColor = k.Color.fromCssColorString("#1a1a2e"), u.backgroundColor = k.Color.fromCssColorString("#1a1a2e"), u.skyAtmosphere && (u.skyAtmosphere.show = !1), u.light.enabled = !1, o.value.cesiumWidget.creditContainer && (o.value.cesiumWidget.creditContainer.style.display = "none"), await new Promise((L) => requestAnimationFrame(() => L())), c = A(() => o.value), l.value = null;
490
+ } catch (u) {
491
+ throw l.value = u.message || "Viewer 初始化失败", console.error("[CogManager] 初始化失败:", u), u;
492
+ }
493
+ }, p = async () => {
494
+ try {
495
+ const h = new AbortController(), u = setTimeout(() => h.abort(), 1e4), L = await fetch(r, { signal: h.signal });
496
+ clearTimeout(u), n.value = (await L.json()).map((b) => ({
497
+ name: b.name,
498
+ url: b.staticUrl.startsWith("http") ? b.staticUrl : `${i}${b.staticUrl}`
499
+ })), n.value.length > 0 && (a.value = n.value[0].url), l.value = null;
500
+ } catch (h) {
501
+ console.error("[CogManager] 获取 COG 列表失败:", h), n.value = [], l.value = "获取 COG 列表失败: " + (h.name === "AbortError" ? "请求超时" : h.message);
502
+ }
503
+ }, y = async () => {
504
+ if (!(!a.value || d.value)) {
505
+ d.value = !0, l.value = null;
506
+ try {
507
+ if (m) {
508
+ try {
509
+ c?.removeCogLayer(m);
510
+ } catch (u) {
511
+ console.warn("[CogManager] 移除旧图层时出错(继续加载):", u);
512
+ }
513
+ m = null, await new Promise((u) => requestAnimationFrame(() => requestAnimationFrame(() => u())));
514
+ }
515
+ const h = "cog-layer-" + Date.now();
516
+ await c.addCogLayer(h, a.value, {
517
+ alpha: 1,
518
+ flyTo: !0
519
+ }), m = h, console.log("[CogManager] 加载成功:", h);
520
+ } catch (h) {
521
+ throw console.error("[CogManager] 加载失败:", h), l.value = h.message, h;
522
+ } finally {
523
+ d.value = !1;
524
+ }
525
+ }
526
+ }, g = () => {
527
+ if (!m) {
528
+ l.value = "没有可移除的图层";
529
+ return;
530
+ }
531
+ if (!c) {
532
+ l.value = "系统未初始化";
533
+ return;
534
+ }
535
+ console.log("[CogManager] 移除图层:", m), c.removeCogLayer(m), m = null, l.value = null;
536
+ }, _ = () => {
537
+ if (!m) {
538
+ l.value = "没有可飞行的图层";
539
+ return;
540
+ }
541
+ if (!c) {
542
+ l.value = "系统未初始化";
543
+ return;
544
+ }
545
+ c.flyToCogLayer(m), l.value = null;
546
+ }, f = async (h) => {
547
+ a.value = h;
548
+ try {
549
+ await y();
550
+ } catch (u) {
551
+ console.error("[CogManager] 切换 COG 失败:", u);
552
+ }
553
+ }, w = () => {
554
+ c?.destroyCogTools(), o.value?.destroy(), o.value = null, c = null, m = null;
555
+ };
556
+ return E(w), {
557
+ viewer: o,
558
+ cogList: n,
559
+ selectedCog: a,
560
+ isLoading: d,
561
+ error: l,
562
+ initViewer: v,
563
+ fetchCogList: p,
564
+ loadCOG: y,
565
+ removeCOG: g,
566
+ flyTo: _,
567
+ switchCog: f,
568
+ destroy: w
569
+ };
570
+ }
571
+ export {
572
+ I as CogImageryProvider,
573
+ W as LRUCache,
574
+ B as addCogLayerToMap,
575
+ Y as addCogLayerToOpenLayers,
576
+ N as createCogProvider,
577
+ $ as expandRectangle,
578
+ V as useCogManager,
579
+ A as useCogTif
580
+ };
581
+
582
+ //# sourceMappingURL=index.js.map