cesium-mars-op-cog 0.1.5 → 0.1.7

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.
@@ -85,6 +85,15 @@ export declare class CogMarsLayer extends mars3d.layer.BaseLayer {
85
85
  * 获取 COG Provider(初始化完成后可用)
86
86
  */
87
87
  get cogProvider(): CogImageryProvider | null;
88
+ /**
89
+ * 飞行定位到 COG 影像区域
90
+ * 覆盖 BaseLayer.flyTo(),等待 readyPromise 完成后使用 bbox 定位
91
+ */
92
+ flyTo(options?: {
93
+ duration?: number;
94
+ scale?: number;
95
+ [key: string]: any;
96
+ }): Promise<boolean>;
88
97
  /** 销毁 */
89
98
  destroy(noDel?: boolean): void;
90
99
  }
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import * as u from "cesium";
2
- import { Event as N, GeographicTilingScheme as k, Rectangle as p } from "cesium";
2
+ import { Event as k, GeographicTilingScheme as _, Rectangle as p } from "cesium";
3
3
  import S from "proj4";
4
- import * as _ from "mars3d";
4
+ import * as m from "mars3d";
5
5
  import { onUnmounted as F, ref as M, shallowRef as R } from "vue";
6
6
  var L = class {
7
7
  poolSize;
@@ -176,7 +176,7 @@ var v = {
176
176
  }, G = class {
177
177
  tileWidth = 256;
178
178
  tileHeight = 256;
179
- tilingScheme = new k();
179
+ tilingScheme = new _();
180
180
  hasAlphaChannel = !0;
181
181
  ready = !0;
182
182
  maximumLevel;
@@ -220,7 +220,7 @@ var v = {
220
220
  const t = A.bbox, e = t[0], i = t[1], I = t[2], g = t[3];
221
221
  if (!isFinite(e) || !isFinite(i) || !isFinite(I) || !isFinite(g)) throw new Error("COG 元数据无效: bbox 包含非数值");
222
222
  const s = A.maxLevel ?? 17, a = A.minLevel ?? Math.max(0, s - 8), n = A.crsType ?? "4326";
223
- this._bbox = this._normalizeBbox(e, i, I, g, n), this.maximumLevel = s, this.minimumLevel = a, this.rectangle = p.fromDegrees(this._bbox[0], this._bbox[1], this._bbox[2], this._bbox[3]), this._errorEvent = new N(), this._initialized = !0, console.log(`[COG] 初始化完成, 级别 ${a}-${s}, bbox: [${this._bbox.join(", ")}]`);
223
+ this._bbox = this._normalizeBbox(e, i, I, g, n), this.maximumLevel = s, this.minimumLevel = a, this.rectangle = p.fromDegrees(this._bbox[0], this._bbox[1], this._bbox[2], this._bbox[3]), this._errorEvent = new k(), this._initialized = !0, console.log(`[COG] 初始化完成, 级别 ${a}-${s}, bbox: [${this._bbox.join(", ")}]`);
224
224
  }
225
225
  _normalizeBbox(A, t, e, i, I) {
226
226
  if (Math.abs(A) <= 360 && Math.abs(e) <= 360 && Math.abs(t) <= 90 && Math.abs(i) <= 90) return [
@@ -338,8 +338,8 @@ async function z(A, t, e) {
338
338
  i.requestImage(C, B, l).then((D) => {
339
339
  D && D.toBlob((y) => {
340
340
  if (y) {
341
- const m = h.getImage();
342
- m.src = URL.createObjectURL(y);
341
+ const N = h.getImage();
342
+ N.src = URL.createObjectURL(y);
343
343
  }
344
344
  });
345
345
  }).catch(() => {
@@ -386,7 +386,7 @@ async function H() {
386
386
  throw new Error("OpenLayers 依赖未找到,请安装: npm install ol");
387
387
  }
388
388
  }
389
- var Z = class extends _.layer.BaseLayer {
389
+ var Z = class extends m.layer.BaseLayer {
390
390
  type = "cog";
391
391
  isTile = !0;
392
392
  hasOpacity = !0;
@@ -475,6 +475,18 @@ var Z = class extends _.layer.BaseLayer {
475
475
  get cogProvider() {
476
476
  return this._cogProvider;
477
477
  }
478
+ async flyTo(A) {
479
+ if (await this.readyPromise, !this._cogProvider) return !1;
480
+ const t = this._cogProvider.bboxDegrees;
481
+ if (t[2] === t[0] || t[3] === t[1]) return !1;
482
+ const e = this._map;
483
+ if (!e) return !1;
484
+ const i = (t[2] - t[0]) * 0.3, I = (t[3] - t[1]) * 0.3;
485
+ return e.camera.flyTo({
486
+ destination: m.Cesium.Rectangle.fromDegrees(t[0] - i, t[1] - I, t[2] + i, t[3] + I),
487
+ duration: A?.duration ?? 1.5
488
+ }), !0;
489
+ }
478
490
  destroy(A) {
479
491
  this._removeImageryLayer(), super.destroy(A);
480
492
  }