@skzz/components-gis 0.0.5 → 0.0.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.
package/dist/index.es.js CHANGED
@@ -791,13 +791,14 @@ var Fe = {
791
791
  if (x.value.flyTo && o) {
792
792
  let e = !1, t = () => {
793
793
  e || l || (e = !0, s &&= (clearTimeout(s), null), F(r));
794
- };
795
- s = setTimeout(t, Number(x.value.duration || 0) * 1e3 + 800);
794
+ }, i = Number(x.value.duration ?? 1.5);
795
+ s = setTimeout(t, Math.max(i, 0) * 1e3 + 800);
796
796
  try {
797
- n.value.camera.flyTo({
798
- duration: x.value.duration,
797
+ let e = N(o);
798
+ i <= 0 ? (n.value.camera.setView({ destination: e }), n.value.scene?.requestRender?.(), t()) : n.value.camera.flyTo({
799
+ duration: i,
799
800
  easingFunction: D.EasingFunction.LINEAR_NONE,
800
- destination: N(o),
801
+ destination: e,
801
802
  complete: t
802
803
  });
803
804
  } catch (e) {
@@ -2154,7 +2155,7 @@ function We(e, t, n = {}) {
2154
2155
  }, t, n);
2155
2156
  }
2156
2157
  //#endregion
2157
- //#region ../../node_modules/.pnpm/@turf+meta@7.2.0/node_modules/@turf/meta/dist/esm/index.js
2158
+ //#region ../../node_modules/.pnpm/@turf+meta@7.3.5/node_modules/@turf/meta/dist/esm/index.js
2158
2159
  function Ge(e, t, n) {
2159
2160
  if (e !== null) for (var r, i, a, o, s, c, l, u = 0, d = 0, f, p = e.type, m = p === "FeatureCollection", h = p === "Feature", g = m ? e.features.length : 1, _ = 0; _ < g; _++) {
2160
2161
  l = m ? e.features[_].geometry : h ? e.geometry : e, f = l ? l.type === "GeometryCollection" : !1, s = f ? l.geometries.length : 1;
@@ -2210,7 +2211,7 @@ function Ge(e, t, n) {
2210
2211
  }
2211
2212
  }
2212
2213
  //#endregion
2213
- //#region ../../node_modules/.pnpm/@turf+bbox@7.2.0/node_modules/@turf/bbox/dist/esm/index.js
2214
+ //#region ../../node_modules/.pnpm/@turf+bbox@7.3.5/node_modules/@turf/bbox/dist/esm/index.js
2214
2215
  function Ke(e, t = {}) {
2215
2216
  if (e.bbox != null && !0 !== t.recompute) return e.bbox;
2216
2217
  let n = [
@@ -3678,6 +3679,7 @@ var va = {
3678
3679
  constants: tn
3679
3680
  }, Oa = [
3680
3681
  "layerId",
3682
+ "dataLayerId",
3681
3683
  "id",
3682
3684
  "dictCode",
3683
3685
  "serviceName",
@@ -3689,13 +3691,20 @@ var va = {
3689
3691
  "modelColorUrl",
3690
3692
  "opacity",
3691
3693
  "layerOpacity",
3692
- "pointSize"
3694
+ "pointSize",
3695
+ "displayRange",
3696
+ "lodCalculationRange"
3693
3697
  ];
3694
- function ka(e) {
3695
- return e == null ? "" : String(e);
3698
+ function ka(e, t) {
3699
+ return e == null ? "" : (t === "displayRange" || t === "lodCalculationRange") && typeof e == "object" ? JSON.stringify({
3700
+ longitudeWest: e.longitudeWest ?? e.west,
3701
+ latitudeSouth: e.latitudeSouth ?? e.south,
3702
+ longitudeEast: e.longitudeEast ?? e.east,
3703
+ latitudeNorth: e.latitudeNorth ?? e.north
3704
+ }) : String(e);
3696
3705
  }
3697
3706
  function Aa(e = {}) {
3698
- return Oa.map((t) => `${t}:${ka(e[t])}`).join("|");
3707
+ return Oa.map((t) => `${t}:${ka(e[t], t)}`).join("|");
3699
3708
  }
3700
3709
  function ja(e, t = {}) {
3701
3710
  let n = Aa(t);
@@ -3703,9 +3712,34 @@ function ja(e, t = {}) {
3703
3712
  }
3704
3713
  //#endregion
3705
3714
  //#region src/zz-layer/zz-layer-zzts3d/entityGrid.js
3706
- var Ma = class {
3715
+ function Ma(e) {
3716
+ if (!e) return null;
3717
+ let t = Number(e.longitudeWest ?? e.west), n = Number(e.latitudeSouth ?? e.south), r = Number(e.longitudeEast ?? e.east), i = Number(e.latitudeNorth ?? e.north);
3718
+ return ![
3719
+ t,
3720
+ n,
3721
+ r,
3722
+ i
3723
+ ].every(Number.isFinite) || t < -180 || r > 180 || n < -90 || i > 90 || t >= r || n >= i ? null : {
3724
+ west: t,
3725
+ south: n,
3726
+ east: r,
3727
+ north: i
3728
+ };
3729
+ }
3730
+ function Na(e, t) {
3731
+ if (!e || !t) return null;
3732
+ let n = {
3733
+ west: Math.max(e.west, t.west),
3734
+ south: Math.max(e.south, t.south),
3735
+ east: Math.min(e.east, t.east),
3736
+ north: Math.min(e.north, t.north)
3737
+ };
3738
+ return n.west < n.east && n.south < n.north ? n : null;
3739
+ }
3740
+ var Pa = class {
3707
3741
  constructor(e, t = !1, n = null, r = "255,255,255", i = "", a = 1, o = {}) {
3708
- this.id = e, this.isStatic = t, this.loadedTiles = /* @__PURE__ */ new Map(), this.currentTileIds = /* @__PURE__ */ new Set(), this.currentNewLevel = g(n || 15), this.gridDb = null, this.entityNum = 0, this.handlers = null, this.requestController = null, this.pendingRequests = /* @__PURE__ */ new Map(), this.fadeAnimations = /* @__PURE__ */ new Map(), this.lastTime = 0, this.serviceType = i, this.opacity = this.normalizeOpacity(a), this.layerOpacity = this.normalizeOpacity(o.layerOpacity ?? 1), this.fixedLevel = n, this.destroyed = !1, this.requestVersion = 0, this.initTimer = null, this.initPromise = null, this.dictCode = o.dictCode || "", this.serviceName = o.serviceName || "", this.enableServiceColor = o.enableServiceColor !== !1, this.modelColorUrl = o.modelColorUrl || "/v1/zzts/style/render/modelColors", this.stackIndex = o.stackIndex ?? -1, this.subStackIndex = o.subStackIndex ?? 0, this.groupKey = o.groupKey || String(this.id), this.modelColorCache = /* @__PURE__ */ new Map(), this.levels_add = window.levels_add_plus || 0, this.tileColor = r, this.tileSleepTime = window.tileSleepTime || 400;
3742
+ this.id = e, this.dataLayerId = o.dataLayerId || e, this.isStatic = t, this.loadedTiles = /* @__PURE__ */ new Map(), this.currentTileIds = /* @__PURE__ */ new Set(), this.currentNewLevel = g(n || 15), this.gridDb = null, this.entityNum = 0, this.handlers = null, this.requestController = null, this.pendingRequests = /* @__PURE__ */ new Map(), this.fadeAnimations = /* @__PURE__ */ new Map(), this.lastTime = 0, this.serviceType = i, this.opacity = this.normalizeOpacity(a), this.layerOpacity = this.normalizeOpacity(o.layerOpacity ?? 1), this.displayRange = Ma(o.displayRange), this.lodCalculationRange = Ma(o.lodCalculationRange), this.fixedLevel = n, this.destroyed = !1, this.requestVersion = 0, this.tileBatchVersion = 0, this.fallbackRenderLevel = null, this.initTimer = null, this.initPromise = null, this.dictCode = o.dictCode || "", this.serviceName = o.serviceName || "", this.enableServiceColor = o.enableServiceColor !== !1, this.modelColorUrl = o.modelColorUrl || "/v1/zzts/style/render/modelColors", this.stackIndex = o.stackIndex ?? -1, this.subStackIndex = o.subStackIndex ?? 0, this.groupKey = o.groupKey || String(this.id), this.modelColorCache = /* @__PURE__ */ new Map(), this.levels_add = window.levels_add_plus || 0, this.tileColor = r, this.tileSleepTime = window.tileSleepTime || 400;
3709
3743
  }
3710
3744
  normalizeOpacity(e) {
3711
3745
  let t = Number(e);
@@ -3777,60 +3811,106 @@ var Ma = class {
3777
3811
  if (!a[0] || e.length < 4) return;
3778
3812
  r = a[0].level + this.levels_add;
3779
3813
  }
3780
- if (this.currentNewLevel.value = r, !(e.length < 4)) {
3781
- var i = Ke(We([
3782
- [e[0].x, e[0].y],
3783
- [e[1].x, e[1].y],
3784
- [e[2].x, e[2].y],
3785
- [e[3].x, e[3].y]
3786
- ]));
3787
- this.getEntityData(i, r, e, this.requestController.signal);
3814
+ if (this.currentNewLevel.value = r, e.length < 4) return;
3815
+ let i = Ke(We([
3816
+ [e[0].x, e[0].y],
3817
+ [e[1].x, e[1].y],
3818
+ [e[2].x, e[2].y],
3819
+ [e[3].x, e[3].y]
3820
+ ])), a = {
3821
+ west: i[0],
3822
+ south: i[1],
3823
+ east: i[2],
3824
+ north: i[3]
3825
+ }, o = this.displayRange ? Na(a, this.displayRange) : a;
3826
+ if (!o) {
3827
+ this.clearAllTiles();
3828
+ return;
3788
3829
  }
3830
+ let s = this.lodCalculationRange || o, c = [
3831
+ s.west,
3832
+ s.south,
3833
+ s.east,
3834
+ s.north
3835
+ ];
3836
+ this.getEntityData(c, r, e, o, this.requestController.signal);
3789
3837
  }
3790
3838
  showDebugPoints(e) {
3791
3839
  viewer.entities.values.filter((e) => e.id && e.id.startsWith(`debug_${this.id}_`)).forEach((e) => viewer.entities.remove(e)), e.forEach((e, t) => {
3792
3840
  this.showPoint(e.x, e.y, 1, t);
3793
3841
  });
3794
3842
  }
3795
- async getEntityData(e, t, n, r) {
3796
- let i = viewer.scene.canvas, a = i.clientWidth, o = i.clientHeight;
3797
- try {
3843
+ async getEntityData(e, t, n, r, i) {
3844
+ let a = viewer.scene.canvas, o = a.clientWidth, s = a.clientHeight, c = Number(e[2]) - Number(e[0]), l = Number(e[3]) - Number(e[1]);
3845
+ if (!(c > 20 || l > 20)) try {
3798
3846
  let t = await k.request({
3799
3847
  method: "GET",
3800
- url: `/v1/zzts/layer/3d/calTiles?region=${e[0]},${e[1]},0,${e[2]},${e[3]},10&width=${a}&height=${o}`,
3848
+ url: `/v1/zzts/layer/3d/calTiles?region=${e[0]},${e[1]},0,${e[2]},${e[3]},10&width=${o}&height=${s}`,
3801
3849
  timeout: 6e4,
3802
- signal: r
3850
+ signal: i
3803
3851
  });
3804
- !r.aborted && !this.destroyed && this.render3DFaces(t.tiles, t.lodLevel);
3852
+ !i.aborted && !this.destroyed && this.render3DFaces(t.tiles, t.lodLevel, r);
3805
3853
  } catch (e) {
3806
3854
  e.name !== "AbortError" && console.error(`图层 ${this.id} 获取实体数据出错:`, e);
3807
3855
  }
3808
3856
  }
3809
- render3DFaces(e, t) {
3857
+ render3DFaces(e, t, n = null) {
3810
3858
  if (this.destroyed) return;
3811
- this.lastTime = (/* @__PURE__ */ new Date()).getTime();
3812
- let n = N.getCameraView(viewer);
3859
+ let r = ++this.tileBatchVersion;
3860
+ t === 17 && this.fallbackRenderLevel === 16 && (e = this.collapseLevel17TilesToParents(e), t = 16), this.lastTime = (/* @__PURE__ */ new Date()).getTime();
3861
+ let i = N.getCameraView(viewer);
3813
3862
  e.forEach((e) => {
3814
3863
  if (this.isStatic && this.fixedLevel) e.geoSot = e.geoSot, e.level = t;
3815
3864
  else {
3816
- let r = Cesium.Cartesian3.distance(Cesium.Cartesian3.fromDegrees((e.xmax + e.xmin) / 2, (e.ymax + e.ymin) / 2, 0), Cesium.Cartesian3.fromDegrees(n.x, n.y, n.z));
3817
- N.entityGridLevels.filter((e) => e.max >= r && e.min <= r), e.geoSot = e.geoSot, e.level = t;
3865
+ let n = Cesium.Cartesian3.distance(Cesium.Cartesian3.fromDegrees((e.xmax + e.xmin) / 2, (e.ymax + e.ymin) / 2, 0), Cesium.Cartesian3.fromDegrees(i.x, i.y, i.z));
3866
+ N.entityGridLevels.filter((e) => e.max >= n && e.min <= n), e.geoSot = e.geoSot, e.level = t;
3818
3867
  }
3819
3868
  });
3820
- let r = e, i = new Set(r.map((e) => e.geoSot)), a = [], o = [];
3869
+ let a = (Array.isArray(e) ? e : []).filter((e) => n ? !!Na({
3870
+ west: Number(e?.xmin),
3871
+ south: Number(e?.ymin),
3872
+ east: Number(e?.xmax),
3873
+ north: Number(e?.ymax)
3874
+ }, n) : !0), o = new Set(a.map((e) => e.geoSot)), s = [], c = [];
3821
3875
  this.currentTileIds.forEach((e) => {
3822
- i.has(e) || o.push(e);
3823
- }), i.forEach((e) => {
3876
+ o.has(e) || c.push(e);
3877
+ }), o.forEach((e) => {
3824
3878
  if (!this.currentTileIds.has(e)) {
3825
- let t = r.find((t) => e === t.geoSot);
3826
- t && a.push(t);
3879
+ let t = a.find((t) => e === t.geoSot);
3880
+ t && s.push(t);
3827
3881
  }
3828
- }), a.forEach((e) => {
3829
- this.addTile(e, e.level, this.requestVersion);
3830
- }), o.forEach((e) => {
3882
+ });
3883
+ let l = this.requestVersion, u = s.map((e) => this.addTile(e, e.level, l));
3884
+ t === 17 && u.length > 0 && this.fallbackRenderLevel !== 16 && Promise.all(u).then((t) => {
3885
+ !this.isActiveRequest(l) || this.tileBatchVersion !== r || this.fallbackRenderLevel === 16 || !a.some((e) => this.loadedTiles.has(e.geoSot)) && t.every((e) => e === "empty") && (this.fallbackRenderLevel = 16, this.render3DFaces(e, 17, n));
3886
+ }), c.forEach((e) => {
3831
3887
  let t = this.loadedTiles.get(e);
3832
3888
  t && this.fadeOut(t, e);
3833
- }), this.currentTileIds = i;
3889
+ }), this.currentTileIds = o;
3890
+ }
3891
+ collapseLevel17TilesToParents(e) {
3892
+ let t = /* @__PURE__ */ new Map();
3893
+ for (let n of Array.isArray(e) ? e : []) {
3894
+ let e = this.getParentGeoSot(n?.geoSot);
3895
+ if (!e) continue;
3896
+ let r = t.get(e);
3897
+ if (!r) {
3898
+ t.set(e, {
3899
+ ...n,
3900
+ geoSot: e,
3901
+ level: 16
3902
+ });
3903
+ continue;
3904
+ }
3905
+ r.xmin = Math.min(Number(r.xmin), Number(n.xmin)), r.ymin = Math.min(Number(r.ymin), Number(n.ymin)), r.xmax = Math.max(Number(r.xmax), Number(n.xmax)), r.ymax = Math.max(Number(r.ymax), Number(n.ymax));
3906
+ }
3907
+ return Array.from(t.values());
3908
+ }
3909
+ getParentGeoSot(e) {
3910
+ let t = String(e || "").replaceAll("-", "");
3911
+ if (!/^G[0-3]{17}$/.test(t)) return null;
3912
+ let n = t.slice(1, -1);
3913
+ return `G${n.slice(0, 9)}-${n.slice(9, 15)}-${n.slice(15)}`;
3834
3914
  }
3835
3915
  fadeOut(e, t) {
3836
3916
  if (this.fadeAnimations.has(t)) {
@@ -3850,7 +3930,7 @@ var Ma = class {
3850
3930
  return !this.destroyed && this.requestVersion === e && !t?.token?.reason;
3851
3931
  }
3852
3932
  async addTile(e, t, n = this.requestVersion) {
3853
- if (!this.isActiveRequest(n)) return;
3933
+ if (!this.isActiveRequest(n)) return "cancelled";
3854
3934
  let r = e.geoSot;
3855
3935
  if (this.pendingRequests.has(r)) {
3856
3936
  let e = this.pendingRequests.get(r);
@@ -3859,32 +3939,25 @@ var Ma = class {
3859
3939
  let i = M.CancelToken.source(), a = () => i.cancel("请求被取消");
3860
3940
  this.pendingRequests.set(r, { cancel: a });
3861
3941
  try {
3862
- let a = await this.gridDb.getDataById("gridEntity", r + "_" + t);
3863
- if (!this.isActiveRequest(n, i)) return;
3864
- if (a) a.data.byteLength > 0 && await this.addGridToMap(e, this.parseCompressedMeshData(a.data, e.level), e.level, n, i);
3865
- else {
3866
- let a = await k.request({
3942
+ let a = `v2_${r}_${t}`, o = await this.gridDb.getDataById("gridEntity", a);
3943
+ if (!this.isActiveRequest(n, i)) return "cancelled";
3944
+ if (o) return o.data.byteLength > 47 ? (await this.addGridToMap(e, this.parseCompressedMeshData(o.data, e.level), e.level, n, i), "hit") : "empty";
3945
+ if (!o) {
3946
+ let t = await k.request({
3867
3947
  method: "GET",
3868
- url: `/v1/zzts/layer/3d/getTileNew?layerId=${this.id}&level=${e.level}&geosot=${e.geoSot}`,
3948
+ url: `/v1/zzts/layer/3d/getTileNew?layerId=${this.dataLayerId}&level=${e.level}&geosot=${e.geoSot}`,
3869
3949
  headers: { Accept: "application/octet-stream" },
3870
3950
  responseType: "arraybuffer",
3871
3951
  timeout: 6e4,
3872
3952
  cancelToken: i.token
3873
3953
  });
3874
- if (this.isActiveRequest(n, i) && a.data.byteLength > 47) {
3875
- if (await this.gridDb.addData("gridEntity", {
3876
- id: r + "_" + t,
3877
- data: a.data
3878
- }), !this.isActiveRequest(n, i)) return;
3879
- await this.addGridToMap(e, this.parseCompressedMeshData(a.data, e.level), e.level, n, i);
3880
- }
3881
- this.isActiveRequest(n, i) && a.data.byteLength < 47 && await this.gridDb.addData("gridEntity", {
3882
- id: r + "_" + t,
3883
- data: a.data
3884
- });
3954
+ return this.isActiveRequest(n, i) && t.data.byteLength > 47 ? (await this.gridDb.addData("gridEntity", {
3955
+ id: a,
3956
+ data: t.data
3957
+ }), this.isActiveRequest(n, i) ? (await this.addGridToMap(e, this.parseCompressedMeshData(t.data, e.level), e.level, n, i), "hit") : "cancelled") : this.isActiveRequest(n, i) ? "empty" : "cancelled";
3885
3958
  }
3886
3959
  } catch (e) {
3887
- M.isCancel(e) || console.error(`图层 ${this.id} 获取瓦片数据出错:`, e);
3960
+ return M.isCancel(e) ? "cancelled" : (console.error(`图层 ${this.id} 获取瓦片数据出错:`, e), "error");
3888
3961
  } finally {
3889
3962
  this.pendingRequests.get(r)?.cancel === a && this.pendingRequests.delete(r);
3890
3963
  }
@@ -4056,7 +4129,7 @@ var Ma = class {
4056
4129
  this.fadeAnimations.set(e.geoSot, { interval: m }), this.loadedTiles.set(e.geoSot, { box: d });
4057
4130
  }
4058
4131
  updateOptions(e = {}) {
4059
- e.color && (this.tileColor = e.color), e.opacity !== void 0 && e.opacity !== null && (this.opacity = this.normalizeOpacity(e.opacity)), e.layerOpacity !== void 0 && e.layerOpacity !== null && (this.layerOpacity = this.normalizeOpacity(e.layerOpacity)), e.level !== void 0 && (this.fixedLevel = e.level, e.level && (this.currentNewLevel.value = e.level)), e.serviceType !== void 0 && (this.serviceType = e.serviceType), this.dictCode = e.dictCode || this.dictCode || "", this.serviceName = e.serviceName || this.serviceName || "", e.enableServiceColor !== void 0 && (this.enableServiceColor = !!e.enableServiceColor), this.modelColorUrl = e.modelColorUrl || this.modelColorUrl || "/v1/zzts/style/render/modelColors", this.modelColorCache.clear(), e.stackIndex !== void 0 && (this.stackIndex = e.stackIndex), e.subStackIndex !== void 0 && (this.subStackIndex = e.subStackIndex), e.groupKey !== void 0 && (this.groupKey = e.groupKey), this.applyStackIndex();
4132
+ e.color && (this.tileColor = e.color), e.opacity !== void 0 && e.opacity !== null && (this.opacity = this.normalizeOpacity(e.opacity)), e.layerOpacity !== void 0 && e.layerOpacity !== null && (this.layerOpacity = this.normalizeOpacity(e.layerOpacity)), e.level !== void 0 && (this.fixedLevel = e.level, e.level && (this.currentNewLevel.value = e.level)), e.displayRange !== void 0 && (this.displayRange = Ma(e.displayRange)), e.dataLayerId !== void 0 && (this.dataLayerId = e.dataLayerId || this.id), e.lodCalculationRange !== void 0 && (this.lodCalculationRange = Ma(e.lodCalculationRange)), e.serviceType !== void 0 && (this.serviceType = e.serviceType), this.dictCode = e.dictCode || this.dictCode || "", this.serviceName = e.serviceName || this.serviceName || "", e.enableServiceColor !== void 0 && (this.enableServiceColor = !!e.enableServiceColor), this.modelColorUrl = e.modelColorUrl || this.modelColorUrl || "/v1/zzts/style/render/modelColors", this.modelColorCache.clear(), e.stackIndex !== void 0 && (this.stackIndex = e.stackIndex), e.subStackIndex !== void 0 && (this.subStackIndex = e.subStackIndex), e.groupKey !== void 0 && (this.groupKey = e.groupKey), this.applyStackIndex();
4060
4133
  }
4061
4134
  applyStackIndex() {
4062
4135
  if (this.stackIndex < 0 || !viewer) return;
@@ -4296,7 +4369,7 @@ var Ma = class {
4296
4369
  }
4297
4370
  });
4298
4371
  }
4299
- }, Na = new class {
4372
+ }, Fa = new class {
4300
4373
  constructor() {
4301
4374
  this.layers = /* @__PURE__ */ new Map();
4302
4375
  }
@@ -4315,7 +4388,7 @@ var Ma = class {
4315
4388
  groupKey: e?.groupKey
4316
4389
  })), r && (n.renderSignature = Aa(e || {}), n.removeTilesOnly(), n.getViewportInfo()), n;
4317
4390
  }
4318
- let c = new Ma(t, i, r, n, a, o, {
4391
+ let c = new Pa(t, i, r, n, a, o, {
4319
4392
  ...e || {},
4320
4393
  layerOpacity: s
4321
4394
  });
@@ -4347,20 +4420,20 @@ var Ma = class {
4347
4420
  let t = this.layers.get(e);
4348
4421
  t && t.getViewportInfo();
4349
4422
  }
4350
- }(), Pa = async (e) => Na.createLayer(e, !1), Fa = (e) => {
4351
- Na.removeLayer(e);
4352
- }, Ia = (e) => Na.getLayer(e);
4423
+ }(), Ia = async (e) => Fa.createLayer(e, !1), La = (e) => {
4424
+ Fa.removeLayer(e);
4425
+ }, Ra = (e) => Fa.getLayer(e);
4353
4426
  t(() => {
4354
- let e = Na.getLayerIds();
4427
+ let e = Fa.getLayerIds();
4355
4428
  if (e.length > 0) {
4356
- let t = Na.getLayer(e[0]);
4429
+ let t = Fa.getLayer(e[0]);
4357
4430
  return t ? t.getCurrentLevel() : 15;
4358
4431
  }
4359
4432
  return 15;
4360
4433
  });
4361
4434
  //#endregion
4362
4435
  //#region src/zz-layer/zz-layer-zzts3d/index.vue
4363
- var La = {
4436
+ var za = {
4364
4437
  __name: "index",
4365
4438
  props: {
4366
4439
  config: {
@@ -4384,6 +4457,7 @@ var La = {
4384
4457
  c("cesiumViewer");
4385
4458
  let n = e, r = {
4386
4459
  layerId: "",
4460
+ dataLayerId: "",
4387
4461
  color: "255,255,255",
4388
4462
  isStatic: !1,
4389
4463
  level: null,
@@ -4393,7 +4467,9 @@ var La = {
4393
4467
  dictCode: "",
4394
4468
  serviceName: "",
4395
4469
  enableServiceColor: !0,
4396
- modelColorUrl: "/v1/zzts/style/render/modelColors"
4470
+ modelColorUrl: "/v1/zzts/style/render/modelColors",
4471
+ displayRange: null,
4472
+ lodCalculationRange: null
4397
4473
  }, i = t(() => ({
4398
4474
  ...r,
4399
4475
  ...n.config
@@ -4402,6 +4478,7 @@ var La = {
4402
4478
  let t = e.level ? !0 : e.isStatic;
4403
4479
  return {
4404
4480
  layerId: e.layerId,
4481
+ dataLayerId: e.dataLayerId,
4405
4482
  color: e.color,
4406
4483
  isStatic: t,
4407
4484
  level: e.level,
@@ -4412,6 +4489,8 @@ var La = {
4412
4489
  serviceName: e.serviceName,
4413
4490
  enableServiceColor: e.enableServiceColor,
4414
4491
  modelColorUrl: e.modelColorUrl,
4492
+ displayRange: e.displayRange,
4493
+ lodCalculationRange: e.lodCalculationRange,
4415
4494
  stackIndex: n.stackIndex,
4416
4495
  subStackIndex: n.subStackIndex,
4417
4496
  groupKey: n.groupKey || e.layerId
@@ -4423,14 +4502,14 @@ var La = {
4423
4502
  console.warn("[zzLayerZzts3d] 缺少 layerId,跳过初始化", e);
4424
4503
  return;
4425
4504
  }
4426
- let t = o(e), n = Ia(e.layerId);
4505
+ let t = o(e), n = Ra(e.layerId);
4427
4506
  if (n && !ja(n.renderSignature, t)) {
4428
4507
  typeof n.updateOptions == "function" && n.updateOptions(t), a = e.layerId;
4429
4508
  return;
4430
4509
  }
4431
- await Pa(t), a = e.layerId;
4510
+ await Ia(t), a = e.layerId;
4432
4511
  }, l = () => {
4433
- Fa(i.value.layerId);
4512
+ La(i.value.layerId);
4434
4513
  };
4435
4514
  return w(() => n.config, async () => {
4436
4515
  await s();
@@ -4442,7 +4521,7 @@ var La = {
4442
4521
  n.subStackIndex,
4443
4522
  n.groupKey
4444
4523
  ], () => {
4445
- let e = i.value, t = Ia(e.layerId);
4524
+ let e = i.value, t = Ra(e.layerId);
4446
4525
  if (t && typeof t.updateOptions == "function") {
4447
4526
  t.updateOptions({
4448
4527
  stackIndex: n.stackIndex,
@@ -4453,17 +4532,38 @@ var La = {
4453
4532
  }
4454
4533
  s();
4455
4534
  }), f(() => {
4456
- a ? Fa(a) : l();
4535
+ a ? La(a) : l();
4457
4536
  }), (e, t) => null;
4458
4537
  }
4459
4538
  };
4460
4539
  //#endregion
4461
4540
  //#region src/zz-layer/zz-layer-shp-zzts/shpZztsRenderer.js
4462
- function Ra() {
4463
- let e = Math.random() * 360;
4464
- return D.Color.fromHsl(e / 360, .7, .5);
4541
+ function Ba(e) {
4542
+ if (!e) return null;
4543
+ let t = Number(e.longitudeWest ?? e.west), n = Number(e.latitudeSouth ?? e.south), r = Number(e.longitudeEast ?? e.east), i = Number(e.latitudeNorth ?? e.north);
4544
+ return ![
4545
+ t,
4546
+ n,
4547
+ r,
4548
+ i
4549
+ ].every(Number.isFinite) || t < -180 || r > 180 || n < -90 || i > 90 || t >= r || n >= i ? null : {
4550
+ west: t,
4551
+ south: n,
4552
+ east: r,
4553
+ north: i
4554
+ };
4465
4555
  }
4466
- function za(e) {
4556
+ function Va(e, t) {
4557
+ if (!e || !t) return null;
4558
+ let n = {
4559
+ west: Math.max(e.west, t.west),
4560
+ south: Math.max(e.south, t.south),
4561
+ east: Math.min(e.east, t.east),
4562
+ north: Math.min(e.north, t.north)
4563
+ };
4564
+ return n.west < n.east && n.south < n.north ? n : null;
4565
+ }
4566
+ function Ha(e) {
4467
4567
  let t = performance.now(), n = [], r = new DataView(e), i = r.getInt32(0, !0);
4468
4568
  if (i <= 0 || i > 1e5) return console.warn(`[ShpZzts] tileCount 异常: ${i},跳过解析`), n;
4469
4569
  console.log(`[ShpZzts] 瓦片数量: ${i}`);
@@ -4476,67 +4576,146 @@ function za(e) {
4476
4576
  }
4477
4577
  let o = new Uint8Array(e, a, i), s = new DataView(o.buffer, o.byteOffset, o.byteLength);
4478
4578
  a += i;
4479
- let c = 0, l = s.getInt32(c, !0);
4480
- c += 4;
4481
- let u = s.getInt32(c, !0);
4482
- if (c += 4, l % 8 != 0 || u % 4 != 0) {
4483
- console.error(`[ShpZzts] 数据对齐异常 positionsByteLen=${l} indicesByteLen=${u},跳过瓦片 ${t}`);
4579
+ let c = String(t), l = 0, u = s.getInt32(0, !0), d = !1;
4580
+ if (u > 0 && u <= 128 && 4 + u + 8 <= i) {
4581
+ let e = s.getInt32(4 + u, !0), t = s.getInt32(8 + u, !0);
4582
+ e >= 0 && t >= 0 && e % 24 == 0 && t % 4 == 0 && 4 + u + 8 + e + t === i && (d = !0);
4583
+ }
4584
+ if (d) {
4585
+ try {
4586
+ c = new TextDecoder("utf-8").decode(o.slice(4, 4 + u));
4587
+ } catch {
4588
+ c = String(t);
4589
+ }
4590
+ l = 4 + u;
4591
+ }
4592
+ let f = s.getInt32(l, !0);
4593
+ l += 4;
4594
+ let p = s.getInt32(l, !0);
4595
+ if (l += 4, f % 24 != 0 || p % 4 != 0) {
4596
+ console.error(`[ShpZzts] 数据对齐异常 positionsByteLen=${f} indicesByteLen=${p},跳过瓦片 ${t}`);
4597
+ continue;
4598
+ }
4599
+ let m = f / 8 / 3, h = p / 4;
4600
+ if (h > 1e8) {
4601
+ console.error(`[ShpZzts] indexCount 异常巨大: ${h},跳过瓦片 ${t}`);
4484
4602
  continue;
4485
4603
  }
4486
- let d = l / 8 / 3, f = u / 4;
4487
- if (d === 0 || f === 0) {
4604
+ if (m === 0 || h === 0) {
4488
4605
  console.warn(`[ShpZzts] 空几何体 tile=${t},跳过`);
4489
4606
  continue;
4490
4607
  }
4491
- let p = o.slice(c, c + l), m = new Float64Array(p.buffer, p.byteOffset, d * 3);
4492
- c += l;
4493
- let h = o.slice(c, c + u), g = new Uint32Array(h.buffer, h.byteOffset, f);
4494
- c += u;
4495
- let _ = !1;
4496
- for (let e = 0; e < m.length && !_; e++) isFinite(m[e]) || (_ = !0);
4497
- if (_) {
4608
+ let g = o.slice(l, l + f), _ = new Float64Array(g.buffer, g.byteOffset, m * 3);
4609
+ l += f;
4610
+ let v = o.slice(l, l + p), y = new Uint32Array(v.buffer, v.byteOffset, h);
4611
+ l += p;
4612
+ let b = !1;
4613
+ for (let e = 0; e < _.length && !b; e++) isFinite(_[e]) || (b = !0);
4614
+ if (b) {
4498
4615
  console.error(`[ShpZzts] NaN/Inf 坐标 tile=${t},跳过`);
4499
4616
  continue;
4500
4617
  }
4501
- let v = 0;
4502
- for (let e = 0; e < g.length; e++) g[e] > v && (v = g[e]);
4503
- if (v >= d) {
4504
- console.error(`[ShpZzts] 索引越界 tile=${t} maxIdx=${v} vertexCount=${d},跳过`);
4618
+ let x = 0;
4619
+ for (let e = 0; e < y.length; e++) y[e] > x && (x = y[e]);
4620
+ if (x >= m) {
4621
+ console.error(`[ShpZzts] 索引越界 tile=${t} maxIdx=${x} vertexCount=${m},跳过`);
4505
4622
  continue;
4506
4623
  }
4507
4624
  n.push({
4508
- positions: m,
4509
- indices: g,
4510
- vertexCount: d,
4511
- indexCount: f,
4512
- featureId: String(t)
4625
+ positions: _,
4626
+ indices: y,
4627
+ vertexCount: m,
4628
+ indexCount: h,
4629
+ featureId: c
4513
4630
  });
4514
4631
  }
4515
4632
  let o = (performance.now() - t).toFixed(1);
4516
4633
  return console.log(`[ShpZzts] 解析完成: ${n.length} 要素, ${o}ms`), n;
4517
4634
  }
4518
- var Ba = class {
4635
+ var Ua = class {
4519
4636
  constructor(e, t = {}) {
4520
- this.viewer = e, this.id = t.layerId || "", this.calTilesUrl = t.calTilesUrl || "/v1/zzts/layer/shp/calTiles", this.tileUrl = t.tileUrl || "/v1/zzts/layer/3d/getVectorTile", this.opacity = this._normOpacity(t.opacity), this.batchSize = t.batchSize || 2e3, this.transitionDuration = t.transitionDuration || 50, this.currentLod = -1, this.lodPrimitives = /* @__PURE__ */ new Map(), this.transitionAnimId = null, this.requestInProgress = !1, this.debounceTimer = null, this.destroyed = !1, this.globalInstanceId = 0, this.stackIndex = t.stackIndex ?? -1, this.subStackIndex = t.subStackIndex ?? 0, this.groupKey = t.groupKey || String(this.id), this._moveHandler = null;
4637
+ this.viewer = e, this.id = t.layerId || "", this.calTilesUrl = t.calTilesUrl || "/v1/zzts/layer/shp/calTiles", this.tileUrl = t.tileUrl || "/v1/zzts/layer/3d/getVectorTile", this.opacity = this._normOpacity(t.opacity), this.batchSize = t.batchSize || 2e3, this.transitionDuration = t.transitionDuration || 50, this.displayRange = Ba(t.displayRange), this._userColor = t.color || null, this.dictCode = t.dictCode || "", this.serviceName = t.serviceName || "", this.enableServiceColor = t.enableServiceColor !== !1, this.modelColorUrl = t.modelColorUrl || "/v1/zzts/style/render/modelColors", this.modelColorCache = /* @__PURE__ */ new Map(), this.currentLod = -1, this.lodPrimitives = /* @__PURE__ */ new Map(), this.transitionAnimId = null, this.requestInProgress = !1, this.renderRequestToken = 0, this.debounceTimer = null, this.destroyed = !1, this.globalInstanceId = 0, this.stackIndex = t.stackIndex ?? -1, this.subStackIndex = t.subStackIndex ?? 0, this.groupKey = t.groupKey || String(this.id), this._moveHandler = null;
4521
4638
  }
4522
4639
  _normOpacity(e) {
4523
4640
  let t = Number(e);
4524
4641
  return Number.isFinite(t) ? Math.max(0, Math.min(1, t)) : 1;
4525
4642
  }
4643
+ _resolveColor() {
4644
+ if (!this._userColor) return D.Color.fromCssColorString("#4A90D9");
4645
+ try {
4646
+ if (typeof this._userColor == "string") return D.Color.fromCssColorString(this._userColor);
4647
+ if (typeof this._userColor == "object" && this._userColor.r !== void 0) return new D.Color(Number(this._userColor.r) / 255, Number(this._userColor.g) / 255, Number(this._userColor.b) / 255, 1);
4648
+ } catch {
4649
+ console.warn("[ShpZzts] 颜色解析失败,回退默认淡蓝色:", this._userColor);
4650
+ }
4651
+ return D.Color.fromCssColorString("#4A90D9");
4652
+ }
4653
+ isServiceColorEnabled() {
4654
+ return !!(this.enableServiceColor && this.serviceName && this.dictCode && this.modelColorUrl);
4655
+ }
4656
+ async loadModelColorsByIds(e = []) {
4657
+ if (!this.isServiceColorEnabled()) return /* @__PURE__ */ new Map();
4658
+ let t = [...new Set(e.map((e) => String(e ?? "").trim()).filter((e) => e))];
4659
+ if (t.length === 0) return /* @__PURE__ */ new Map();
4660
+ let n = /* @__PURE__ */ new Map(), r = [];
4661
+ if (t.forEach((e) => {
4662
+ this.modelColorCache.has(e) ? n.set(e, this.modelColorCache.get(e)) : r.push(e);
4663
+ }), r.length === 0) return n;
4664
+ for (let e = 0; e < r.length; e += 800) {
4665
+ let t = r.slice(e, e + 800);
4666
+ try {
4667
+ let e = await k.request({
4668
+ method: "POST",
4669
+ url: this.modelColorUrl,
4670
+ data: {
4671
+ serviceName: this.serviceName,
4672
+ dictCode: this.dictCode,
4673
+ modelIds: t
4674
+ },
4675
+ timeout: 6e4
4676
+ });
4677
+ ((e?.data ?? e)?.rows || []).forEach((e) => {
4678
+ let t = String(e.modelId || e.model_id || "").trim(), r = e.color;
4679
+ t && r && (this.modelColorCache.set(t, r), n.set(t, r));
4680
+ });
4681
+ } catch (e) {
4682
+ console.warn("[ShpZzts] 查询服务配色失败(本批回退默认色):", e);
4683
+ }
4684
+ }
4685
+ return n;
4686
+ }
4687
+ _resolveFeatureColor(e, t) {
4688
+ if (t && e.featureId !== void 0 && e.featureId !== null) {
4689
+ let n = t.get(String(e.featureId));
4690
+ if (n) try {
4691
+ let e = D.Color.fromCssColorString(n);
4692
+ if (e) return e;
4693
+ } catch {}
4694
+ }
4695
+ return this._resolveColor();
4696
+ }
4526
4697
  _getScreenBounds() {
4527
4698
  let e = this.viewer.scene.canvas, t = this.viewer.camera.computeViewRectangle();
4528
- return t ? {
4699
+ if (!t) return null;
4700
+ let n = {
4701
+ west: D.Math.toDegrees(t.west),
4702
+ south: D.Math.toDegrees(t.south),
4703
+ east: D.Math.toDegrees(t.east),
4704
+ north: D.Math.toDegrees(t.north)
4705
+ }, r = this.displayRange ? Va(n, this.displayRange) : n;
4706
+ return {
4707
+ requestBounds: r,
4529
4708
  region: [
4530
- D.Math.toDegrees(t.west),
4531
- D.Math.toDegrees(t.south),
4709
+ r?.west,
4710
+ r?.south,
4532
4711
  0,
4533
- D.Math.toDegrees(t.east),
4534
- D.Math.toDegrees(t.north),
4712
+ r?.east,
4713
+ r?.north,
4535
4714
  10
4536
4715
  ],
4537
4716
  width: e.clientWidth,
4538
4717
  height: e.clientHeight
4539
- } : null;
4718
+ };
4540
4719
  }
4541
4720
  _updatePrimitiveAlpha(e, t) {
4542
4721
  if (e) {
@@ -4556,6 +4735,10 @@ var Ba = class {
4556
4735
  this.lodPrimitives.delete(e);
4557
4736
  }
4558
4737
  }
4738
+ _clearRenderedPrimitives() {
4739
+ for (let e of [...this.lodPrimitives.keys()]) this._destroyLodPrimitives(e);
4740
+ this.currentLod = -1;
4741
+ }
4559
4742
  _crossFadeLod(e, t) {
4560
4743
  this.transitionAnimId !== null && (cancelAnimationFrame(this.transitionAnimId), this.transitionAnimId = null);
4561
4744
  let n = this.lodPrimitives.get(e) ?? void 0, r = this.lodPrimitives.get(t);
@@ -4574,20 +4757,20 @@ var Ba = class {
4574
4757
  };
4575
4758
  this.transitionAnimId = requestAnimationFrame(o);
4576
4759
  }
4577
- _renderBatched(e, t, n, r) {
4578
- let i = [], a = [];
4579
- for (let t = 0; t < e.length; t += this.batchSize) a.push(e.slice(t, t + this.batchSize));
4580
- let o = 0, s = (c) => {
4581
- if (c >= a.length) return;
4582
- let l = a[c], u = [], d = [], f = [];
4583
- for (let e of l) {
4760
+ _renderBatched(e, t, n, r, i) {
4761
+ let a = [], o = [];
4762
+ for (let t = 0; t < e.length; t += this.batchSize) o.push(e.slice(t, t + this.batchSize));
4763
+ let s = 0, c = (l) => {
4764
+ if (l >= o.length) return;
4765
+ let u = o[l], d = [], f = [], p = [];
4766
+ for (let e of u) {
4584
4767
  let t = this.globalInstanceId++;
4585
- u.push(t);
4586
- let r = Ra();
4587
- d.push(r);
4588
- let i = new D.Color(r.red, r.green, r.blue, n);
4768
+ d.push(t);
4769
+ let r = this._resolveFeatureColor(e, i);
4770
+ f.push(r);
4771
+ let a = new D.Color(r.red, r.green, r.blue, n);
4589
4772
  try {
4590
- f.push(new D.GeometryInstance({
4773
+ p.push(new D.GeometryInstance({
4591
4774
  geometry: new D.Geometry({
4592
4775
  attributes: { position: new D.GeometryAttribute({
4593
4776
  componentDatatype: D.ComponentDatatype.DOUBLE,
@@ -4600,18 +4783,18 @@ var Ba = class {
4600
4783
  boundingSphere: D.BoundingSphere.fromVertices(e.positions)
4601
4784
  }),
4602
4785
  id: t,
4603
- attributes: { color: D.ColorGeometryInstanceAttribute.fromColor(i) }
4786
+ attributes: { color: D.ColorGeometryInstanceAttribute.fromColor(a) }
4604
4787
  }));
4605
4788
  } catch (e) {
4606
- console.error(`[ShpZzts] Geometry 创建失败 instanceId=${t}`, e), u.pop(), d.pop();
4789
+ console.error(`[ShpZzts] Geometry 创建失败 instanceId=${t}`, e), d.pop(), f.pop();
4607
4790
  }
4608
4791
  }
4609
- if (f.length === 0) {
4610
- o++, o < a.length ? requestAnimationFrame(() => s(c + 1)) : (this.lodPrimitives.set(t, i), r && requestAnimationFrame(() => r()));
4792
+ if (p.length === 0) {
4793
+ s++, s < o.length ? requestAnimationFrame(() => c(l + 1)) : (this.lodPrimitives.set(t, a), r && requestAnimationFrame(() => r()));
4611
4794
  return;
4612
4795
  }
4613
- let p = new D.Primitive({
4614
- geometryInstances: f,
4796
+ let m = new D.Primitive({
4797
+ geometryInstances: p,
4615
4798
  appearance: new D.PerInstanceColorAppearance({
4616
4799
  flat: !0,
4617
4800
  translucent: !0
@@ -4620,13 +4803,13 @@ var Ba = class {
4620
4803
  compressVertices: !1,
4621
4804
  releaseGeometryInstances: !0
4622
4805
  });
4623
- this.viewer.scene.primitives.add(p), i.push({
4624
- primitive: p,
4625
- instanceIds: u,
4626
- instanceColors: d
4627
- }), o++, o < a.length ? requestAnimationFrame(() => s(c + 1)) : (this.lodPrimitives.set(t, i), console.log(`[ShpZzts] LOD ${t} 渲染完成: ${e.length} 要素 / ${a.length} 批`), r && requestAnimationFrame(() => r()));
4806
+ this.viewer.scene.primitives.add(m), a.push({
4807
+ primitive: m,
4808
+ instanceIds: d,
4809
+ instanceColors: f
4810
+ }), s++, s < o.length ? requestAnimationFrame(() => c(l + 1)) : (this.lodPrimitives.set(t, a), console.log(`[ShpZzts] LOD ${t} 渲染完成: ${e.length} 要素 / ${o.length} 批`), r && requestAnimationFrame(() => r()));
4628
4811
  };
4629
- return s(0), i;
4812
+ return c(0), a;
4630
4813
  }
4631
4814
  async _getVectorTileData(e, t) {
4632
4815
  let n = await k.request({
@@ -4648,21 +4831,25 @@ var Ba = class {
4648
4831
  };
4649
4832
  }
4650
4833
  async loadAndRender() {
4834
+ let e = this._getScreenBounds();
4835
+ if (!e) return;
4836
+ if (this.displayRange && !e.requestBounds) {
4837
+ this.renderRequestToken += 1, this._clearRenderedPrimitives(), console.log("[ShpZzts] 当前视窗与真实胶囊显示范围无交集,跳过瓦片请求");
4838
+ return;
4839
+ }
4651
4840
  if (this.requestInProgress) {
4652
4841
  console.log("[ShpZzts] 请求进行中,跳过");
4653
4842
  return;
4654
4843
  }
4655
- let e = this._getScreenBounds();
4656
- if (!e) return;
4657
- let t = Math.abs(e.region[3] - e.region[0]), n = Math.abs(e.region[4] - e.region[1]);
4658
- if (t > 20 || n > 20) {
4659
- console.warn(`[ShpZzts] 视窗范围过大,跳过请求 (lonSpan=${t.toFixed(2)}°, latSpan=${n.toFixed(2)}°, 限制=20°)`);
4844
+ let t = ++this.renderRequestToken, n = Math.abs(e.region[3] - e.region[0]), r = Math.abs(e.region[4] - e.region[1]);
4845
+ if (n > 20 || r > 20) {
4846
+ console.warn(`[ShpZzts] 视窗范围过大,跳过请求 (lonSpan=${n.toFixed(2)}°, latSpan=${r.toFixed(2)}°, 限制=20°)`);
4660
4847
  return;
4661
4848
  }
4662
4849
  this.requestInProgress = !0;
4663
- let r = performance.now();
4850
+ let i = performance.now();
4664
4851
  try {
4665
- let t = await k.request({
4852
+ let n = await k.request({
4666
4853
  method: "GET",
4667
4854
  url: this.calTilesUrl,
4668
4855
  params: {
@@ -4670,32 +4857,42 @@ var Ba = class {
4670
4857
  height: e.height,
4671
4858
  width: e.width
4672
4859
  }
4673
- }), { lodLevel: n = -1, tiles: i = [] } = t?.data ?? t ?? {};
4674
- if (console.log(`[ShpZzts] LOD ${n} | 瓦片数: ${i.length}`), !i || i.length === 0) {
4675
- console.warn("[ShpZzts] 没有需要加载的瓦片");
4860
+ });
4861
+ if (t !== this.renderRequestToken || this.destroyed) return;
4862
+ let { lodLevel: r = -1, tiles: a = [] } = n?.data ?? n ?? {};
4863
+ if (console.log(`[ShpZzts] LOD ${r} | 瓦片数: ${a.length}`), !a || a.length === 0) {
4864
+ console.warn("[ShpZzts] 没有需要加载的瓦片"), this._clearRenderedPrimitives();
4676
4865
  return;
4677
4866
  }
4678
- let a = i.map((e) => this._getVectorTileData(e.geoSot, n));
4679
- console.log(`[ShpZzts] 开始并行加载 ${a.length} 个瓦片...`);
4680
- let o = await Promise.allSettled(a), s = [];
4681
- for (let e = 0; e < o.length; e++) {
4682
- let t = o[e];
4867
+ let o = a.map((e) => this._getVectorTileData(e.geoSot, r));
4868
+ console.log(`[ShpZzts] 开始并行加载 ${o.length} 个瓦片...`);
4869
+ let s = await Promise.allSettled(o);
4870
+ if (t !== this.renderRequestToken || this.destroyed) return;
4871
+ let c = [];
4872
+ for (let e = 0; e < s.length; e++) {
4873
+ let t = s[e];
4683
4874
  if (t.status === "fulfilled") {
4684
4875
  let { geosot: e, data: n } = t.value;
4685
4876
  if (n instanceof ArrayBuffer && n.byteLength > 0 && (console.log(`[ShpZzts] 瓦片 ${e} 数据长度: ${n.byteLength}`), n.byteLength > 100)) {
4686
- let e = za(n);
4687
- e && e.length > 0 && (s = s.concat(e));
4877
+ let e = Ha(n);
4878
+ e && e.length > 0 && (c = c.concat(e));
4688
4879
  }
4689
- } else console.error(`[ShpZzts] 瓦片 ${i[e]?.geoSot} 加载失败:`, t.reason);
4880
+ } else console.error(`[ShpZzts] 瓦片 ${a[e]?.geoSot} 加载失败:`, t.reason);
4690
4881
  }
4691
- if (console.log(`[ShpZzts] 所有瓦片加载完成,总几何体数量: ${s.length}`), s.length > 0) {
4692
- let e = this.currentLod;
4693
- this.currentLod !== -1 && this.currentLod !== n ? (console.log(`[ShpZzts-SILOD] LOD 变化: ${e} → ${n}`), this._destroyLodPrimitives(n), this._renderBatched(s, n, 0, () => {
4694
- console.log(`[ShpZzts-SILOD] 新 LOD ${n} 分批渲染完成,启动交叉淡化`), this._crossFadeLod(e, n);
4695
- })) : (this._destroyLodPrimitives(n), this._renderBatched(s, n, 1)), this.currentLod = n;
4882
+ if (console.log(`[ShpZzts] 所有瓦片加载完成,总几何体数量: ${c.length}`), t !== this.renderRequestToken || this.destroyed) return;
4883
+ let l = null;
4884
+ if (c.length > 0 && this.isServiceColorEnabled()) {
4885
+ let e = [...new Set(c.map((e) => String(e.featureId ?? "").trim()).filter((e) => e))];
4886
+ l = await this.loadModelColorsByIds(e), console.log(`[ShpZzts] 服务配色命中: ${l.size}/${e.length}`);
4696
4887
  }
4697
- let c = (performance.now() - r).toFixed(0);
4698
- console.log(`[ShpZzts] 加载+渲染完成: ${s.length} 要素, ${c}ms`);
4888
+ if (c.length > 0) {
4889
+ let e = this.currentLod;
4890
+ this.currentLod !== -1 && this.currentLod !== r ? (console.log(`[ShpZzts-SILOD] LOD 变化: ${e} → ${r}`), this._destroyLodPrimitives(r), this._renderBatched(c, r, 0, () => {
4891
+ console.log(`[ShpZzts-SILOD] 新 LOD ${r} 分批渲染完成,启动交叉淡化`), this._crossFadeLod(e, r);
4892
+ }, l)) : (this._destroyLodPrimitives(r), this._renderBatched(c, r, 1, null, l)), this.currentLod = r;
4893
+ } else this._clearRenderedPrimitives();
4894
+ let u = (performance.now() - i).toFixed(0);
4895
+ console.log(`[ShpZzts] 加载+渲染完成: ${c.length} 要素, ${u}ms`);
4699
4896
  } catch (e) {
4700
4897
  console.error("[ShpZzts] 加载失败:", e);
4701
4898
  } finally {
@@ -4724,17 +4921,19 @@ var Ba = class {
4724
4921
  }, 500), console.log(`[ShpZzts] 图层 ${this.id} 初始化完成`));
4725
4922
  }
4726
4923
  remove() {
4727
- this.destroyed = !0, this.transitionAnimId !== null && (cancelAnimationFrame(this.transitionAnimId), this.transitionAnimId = null), this.debounceTimer &&= (clearTimeout(this.debounceTimer), null), this._teardownMoveHandler();
4924
+ this.destroyed = !0, this.renderRequestToken += 1, this.transitionAnimId !== null && (cancelAnimationFrame(this.transitionAnimId), this.transitionAnimId = null), this.debounceTimer &&= (clearTimeout(this.debounceTimer), null), this._teardownMoveHandler(), this.modelColorCache.clear();
4728
4925
  for (let e of this.lodPrimitives.keys()) this._destroyLodPrimitives(e);
4729
4926
  console.log(`[ShpZzts] 图层 ${this.id} 已移除`);
4730
4927
  }
4731
4928
  updateOptions(e = {}) {
4732
- e.opacity !== void 0 && (this.opacity = this._normOpacity(e.opacity)), e.stackIndex !== void 0 && (this.stackIndex = e.stackIndex), e.subStackIndex !== void 0 && (this.subStackIndex = e.subStackIndex), e.groupKey !== void 0 && (this.groupKey = e.groupKey), console.log(`[ShpZzts] 图层 ${this.id} 配置已更新`, {
4929
+ e.opacity !== void 0 && (this.opacity = this._normOpacity(e.opacity)), e.stackIndex !== void 0 && (this.stackIndex = e.stackIndex), e.subStackIndex !== void 0 && (this.subStackIndex = e.subStackIndex), e.groupKey !== void 0 && (this.groupKey = e.groupKey), e.color !== void 0 && (this._userColor = e.color || null), e.displayRange !== void 0 && (this.displayRange = Ba(e.displayRange));
4930
+ let t = !1;
4931
+ e.dictCode !== void 0 && e.dictCode !== this.dictCode && (this.dictCode = e.dictCode || "", t = !0), e.serviceName !== void 0 && e.serviceName !== this.serviceName && (this.serviceName = e.serviceName || "", t = !0), e.enableServiceColor !== void 0 && !!e.enableServiceColor !== this.enableServiceColor && (this.enableServiceColor = !!e.enableServiceColor, t = !0), e.modelColorUrl !== void 0 && e.modelColorUrl !== this.modelColorUrl && (this.modelColorUrl = e.modelColorUrl || "/v1/zzts/style/render/modelColors", t = !0), t && this.modelColorCache.clear(), console.log(`[ShpZzts] 图层 ${this.id} 配置已更新`, {
4733
4932
  opacity: this.opacity,
4734
4933
  stackIndex: this.stackIndex
4735
4934
  });
4736
4935
  }
4737
- }, Va = new class {
4936
+ }, Wa = new class {
4738
4937
  constructor() {
4739
4938
  this.layers = /* @__PURE__ */ new Map();
4740
4939
  }
@@ -4742,7 +4941,7 @@ var Ba = class {
4742
4941
  let n = t?.layerId || t?.id;
4743
4942
  if (!n) return console.error("[ShpZzts] 创建图层失败:缺少 layerId"), null;
4744
4943
  this.layers.has(n) && (console.warn(`[ShpZzts] 图层 ${n} 已存在,移除旧图层后重建`), this.removeLayer(n));
4745
- let r = new Ba(e, t);
4944
+ let r = new Ua(e, t);
4746
4945
  return await r.init(), this.layers.set(n, r), r;
4747
4946
  }
4748
4947
  removeLayer(e) {
@@ -4755,9 +4954,9 @@ var Ba = class {
4755
4954
  removeAllLayers() {
4756
4955
  this.layers.forEach((e) => e.remove()), this.layers.clear();
4757
4956
  }
4758
- }(), Ha = async (e, t) => Va.createLayer(e, t), Ua = (e) => {
4759
- Va.removeLayer(e);
4760
- }, Wa = (e) => Va.getLayer(e), Ga = {
4957
+ }(), Ga = async (e, t) => Wa.createLayer(e, t), Ka = (e) => {
4958
+ Wa.removeLayer(e);
4959
+ }, qa = (e) => Wa.getLayer(e), Ja = {
4761
4960
  __name: "index",
4762
4961
  props: {
4763
4962
  config: {
@@ -4782,6 +4981,7 @@ var Ba = class {
4782
4981
  layerId: "",
4783
4982
  calTilesUrl: "/v1/zzts/layer/shp/calTiles",
4784
4983
  tileUrl: "/v1/zzts/layer/3d/getVectorTile",
4984
+ displayRange: null,
4785
4985
  opacity: 1,
4786
4986
  batchSize: 2e3,
4787
4987
  transitionDuration: 50
@@ -4798,9 +4998,15 @@ var Ba = class {
4798
4998
  layerId: e.layerId,
4799
4999
  calTilesUrl: e.calTilesUrl,
4800
5000
  tileUrl: e.tileUrl,
5001
+ displayRange: e.displayRange,
4801
5002
  opacity: e.opacity,
4802
5003
  batchSize: e.batchSize,
4803
5004
  transitionDuration: e.transitionDuration,
5005
+ color: e.color,
5006
+ dictCode: e.dictCode,
5007
+ serviceName: e.serviceName,
5008
+ enableServiceColor: e.enableServiceColor,
5009
+ modelColorUrl: e.modelColorUrl,
4804
5010
  stackIndex: r.stackIndex,
4805
5011
  subStackIndex: r.subStackIndex,
4806
5012
  groupKey: r.groupKey || e.layerId
@@ -4810,9 +5016,9 @@ var Ba = class {
4810
5016
  calTilesUrl: t.calTilesUrl,
4811
5017
  tileUrl: t.tileUrl,
4812
5018
  opacity: t.opacity
4813
- }), await Ha(n.value, t), o = e.layerId;
5019
+ }), await Ga(n.value, t), o = e.layerId;
4814
5020
  }, l = () => {
4815
- Ua(a.value.layerId);
5021
+ Ka(a.value.layerId);
4816
5022
  };
4817
5023
  return w(() => r.config, async () => {
4818
5024
  console.log("[zzLayerShpZzts] props.config changed =", JSON.parse(JSON.stringify(r.config || {}))), await s();
@@ -4824,7 +5030,7 @@ var Ba = class {
4824
5030
  r.subStackIndex,
4825
5031
  r.groupKey
4826
5032
  ], () => {
4827
- let e = a.value, t = Wa(e.layerId);
5033
+ let e = a.value, t = qa(e.layerId);
4828
5034
  if (t && typeof t.updateOptions == "function") {
4829
5035
  t.updateOptions({
4830
5036
  stackIndex: r.stackIndex,
@@ -4837,16 +5043,16 @@ var Ba = class {
4837
5043
  }), d(() => {
4838
5044
  console.log("[zzLayerShpZzts] 组件挂载");
4839
5045
  }), f(() => {
4840
- console.log("[zzLayerShpZzts] 组件卸载,开始清理资源..."), o ? Ua(o) : l();
5046
+ console.log("[zzLayerShpZzts] 组件卸载,开始清理资源..."), o ? Ka(o) : l();
4841
5047
  }), (e, t) => null;
4842
5048
  }
4843
5049
  };
4844
5050
  //#endregion
4845
5051
  //#region src/zz-layer/zz-layer-zzts3d-point/pointTileUtils.js
4846
- function Ka(e) {
5052
+ function Ya(e) {
4847
5053
  return e instanceof ArrayBuffer ? e : ArrayBuffer.isView(e) ? e.buffer.slice(e.byteOffset, e.byteOffset + e.byteLength) : null;
4848
5054
  }
4849
- function qa(e) {
5055
+ function Xa(e) {
4850
5056
  if (!e || e.byteLength === 0) return null;
4851
5057
  let t = new Uint8Array(e), n = t.find((e) => e > 32);
4852
5058
  if (n !== 123 && n !== 91) return null;
@@ -4856,41 +5062,41 @@ function qa(e) {
4856
5062
  return null;
4857
5063
  }
4858
5064
  }
4859
- function Ja(e, t = {}) {
5065
+ function Za(e, t = {}) {
4860
5066
  return console.warn("[zzts3d-point] skip invalid tile data:", e, t), [];
4861
5067
  }
4862
- var Ya = [
5068
+ var Qa = [
4863
5069
  13,
4864
5070
  14,
4865
5071
  15,
4866
5072
  16,
4867
5073
  18
4868
- ], Xa = 16;
4869
- function Za(e, t = Xa) {
5074
+ ], $a = 16;
5075
+ function eo(e, t = $a) {
4870
5076
  let n = Number(e);
4871
- if (Number.isFinite(n) && n > 0) return Ya.find((e) => n <= e) || Ya[Ya.length - 1];
5077
+ if (Number.isFinite(n) && n > 0) return Qa.find((e) => n <= e) || Qa[Qa.length - 1];
4872
5078
  let r = Number(t);
4873
- return Number.isFinite(r) && r > 0 ? Ya.find((e) => r <= e) || Ya[Ya.length - 1] : Xa;
5079
+ return Number.isFinite(r) && r > 0 ? Qa.find((e) => r <= e) || Qa[Qa.length - 1] : $a;
4874
5080
  }
4875
- function Qa(e, t) {
5081
+ function to(e, t) {
4876
5082
  let n = (String(e ?? "").split("_")[0].match(/\d/g) || []).length;
4877
- return n > 0 ? Za(n, t) : Za(t);
5083
+ return n > 0 ? eo(n, t) : eo(t);
4878
5084
  }
4879
- function $a(e, t) {
4880
- let n = Ka(e);
4881
- if (!n || n.byteLength < 4 || qa(n)) return [];
5085
+ function no(e, t) {
5086
+ let n = Ya(e);
5087
+ if (!n || n.byteLength < 4 || Xa(n)) return [];
4882
5088
  let r = [], i = new DataView(n), a = 0, o = i.getInt32(a, !0);
4883
- if (a += 4, o < 0 || o > 1e5) return Ja("invalid entity count", {
5089
+ if (a += 4, o < 0 || o > 1e5) return Za("invalid entity count", {
4884
5090
  entityCount: o,
4885
5091
  byteLength: n.byteLength
4886
5092
  });
4887
5093
  for (let e = 0; e < o; e++) {
4888
- if (a + 4 > n.byteLength) return Ja("missing compressed chunk length", {
5094
+ if (a + 4 > n.byteLength) return Za("missing compressed chunk length", {
4889
5095
  offset: a,
4890
5096
  byteLength: n.byteLength
4891
5097
  });
4892
5098
  let e = i.getInt32(a, !0);
4893
- if (a += 4, e <= 0 || a + e > n.byteLength) return Ja("invalid compressed chunk length", {
5099
+ if (a += 4, e <= 0 || a + e > n.byteLength) return Za("invalid compressed chunk length", {
4894
5100
  compressedLength: e,
4895
5101
  offset: a,
4896
5102
  byteLength: n.byteLength
@@ -4904,11 +5110,11 @@ function $a(e, t) {
4904
5110
  } catch {
4905
5111
  s = new DataView(o.buffer, o.byteOffset, o.byteLength);
4906
5112
  }
4907
- if (s.byteLength < 12) return Ja("chunk too small", { byteLength: s.byteLength });
5113
+ if (s.byteLength < 12) return Za("chunk too small", { byteLength: s.byteLength });
4908
5114
  let c = 0, l = s.getBigInt64(c, !0);
4909
5115
  c += 8;
4910
5116
  let u = s.getInt32(c, !0);
4911
- if (c += 4, u < 0 || u % 12 != 0 || c + u > s.byteLength) return Ja("invalid positions byte length", {
5117
+ if (c += 4, u < 0 || u % 12 != 0 || c + u > s.byteLength) return Za("invalid positions byte length", {
4912
5118
  positionsByteLength: u,
4913
5119
  innerOffset: c,
4914
5120
  byteLength: s.byteLength
@@ -4924,14 +5130,46 @@ function $a(e, t) {
4924
5130
  }
4925
5131
  return r;
4926
5132
  }
4927
- function eo({ destroyed: e, currentVersion: t, requestVersion: n, cancelToken: r } = {}) {
5133
+ function ro({ destroyed: e, currentVersion: t, requestVersion: n, cancelToken: r } = {}) {
4928
5134
  return !e && t === n && !r?.token?.reason;
4929
5135
  }
4930
5136
  //#endregion
4931
5137
  //#region src/zz-layer/zz-layer-zzts3d-point/entityGrid.js
4932
- var to = class {
5138
+ function io(e) {
5139
+ if (!e) return null;
5140
+ let t = e;
5141
+ if (typeof e == "string") try {
5142
+ t = JSON.parse(e);
5143
+ } catch {
5144
+ return null;
5145
+ }
5146
+ if (!t || typeof t != "object") return null;
5147
+ let n = Number(t.longitudeWest ?? t.west), r = Number(t.latitudeSouth ?? t.south), i = Number(t.longitudeEast ?? t.east), a = Number(t.latitudeNorth ?? t.north);
5148
+ return ![
5149
+ n,
5150
+ r,
5151
+ i,
5152
+ a
5153
+ ].every(Number.isFinite) || n < -180 || i > 180 || r < -90 || a > 90 || n >= i || r >= a ? null : {
5154
+ west: n,
5155
+ south: r,
5156
+ east: i,
5157
+ north: a
5158
+ };
5159
+ }
5160
+ function ao(e, t) {
5161
+ if (!e || !t) return null;
5162
+ let n = {
5163
+ west: Math.max(e.west, t.west),
5164
+ south: Math.max(e.south, t.south),
5165
+ east: Math.min(e.east, t.east),
5166
+ north: Math.min(e.north, t.north)
5167
+ };
5168
+ return n.west < n.east && n.south < n.north ? n : null;
5169
+ }
5170
+ var oo = class {
4933
5171
  constructor(e, t = !1, n = null, r = "255,255,255", i = 5, a = 1, o = {}) {
4934
- this.id = e, this.isStatic = t, this.loadedTiles = /* @__PURE__ */ new Map(), this.currentTileIds = /* @__PURE__ */ new Set(), this.currentNewLevel = g(n || 15), this.gridDb = null, this.entityNum = 0, this.handlers = null, this.requestController = null, this.pendingRequests = /* @__PURE__ */ new Map(), this.fadeAnimations = /* @__PURE__ */ new Map(), this.lastTime = 0, this.pointSize = i, this.opacity = a, this.fixedLevel = n, this.dictCode = o.dictCode || "", this.serviceName = o.serviceName || "", this.enableServiceColor = o.enableServiceColor === !0, this.modelColorUrl = o.modelColorUrl || "/v1/zzts/style/render/modelColors", this.modelColorCache = /* @__PURE__ */ new Map(), this.requestVersion = 0, this.destroyed = !1, this.initTimer = null, this.levels_add = window.levels_add_plus || 0, this.tileColor = r, this.tileSleepTime = window.tileSleepTime || 400, this.highlightModelId = null, this.highlightColor = "255,255,0", this.highlightOpacity = 1, this.highlightPointSize = null, this.modelPointIndex = /* @__PURE__ */ new Map(), this.tilePointIndex = /* @__PURE__ */ new Map();
5172
+ this.id = e, this.isStatic = t, this.loadedTiles = /* @__PURE__ */ new Map(), this.currentTileIds = /* @__PURE__ */ new Set(), this.currentNewLevel = g(n || 15), this.gridDb = null, this.entityNum = 0, this.handlers = null, this.requestController = null, this.pendingRequests = /* @__PURE__ */ new Map(), this.fadeAnimations = /* @__PURE__ */ new Map(), this.lastTime = 0, this.pointSize = i, this.opacity = a, this.fixedLevel = n, this.dictCode = o.dictCode || "", this.serviceName = o.serviceName || "", this.enableServiceColor = o.enableServiceColor === !0, this.modelColorUrl = o.modelColorUrl || "/v1/zzts/style/render/modelColors", this.displayRange = io(o.displayRange), this.modelColorCache = /* @__PURE__ */ new Map(), this.requestVersion = 0, this.destroyed = !1, this.initTimer = null, this.levels_add = window.levels_add_plus || 0, this.tileColor = r, this.tileSleepTime = window.tileSleepTime || 400, this.highlightModelId = null, this.highlightColor = "255,255,0", this.highlightOpacity = 1, this.highlightPointSize = null, this.modelPointIndex = /* @__PURE__ */ new Map(), this.tilePointIndex = /* @__PURE__ */ new Map();
4935
5173
  }
4936
5174
  getBaseStyle() {
4937
5175
  return {
@@ -5120,15 +5358,29 @@ var to = class {
5120
5358
  if (!a[0] || e.length < 4) return;
5121
5359
  r = a[0].level + this.levels_add;
5122
5360
  }
5123
- if (this.currentNewLevel.value = r, !(e.length < 4)) {
5124
- var i = Ke(We([
5125
- [e[0].x, e[0].y],
5126
- [e[1].x, e[1].y],
5127
- [e[2].x, e[2].y],
5128
- [e[3].x, e[3].y]
5129
- ]));
5130
- this.getEntityData(i, r, e, this.requestController.signal);
5361
+ if (this.currentNewLevel.value = r, e.length < 4) return;
5362
+ let i = Ke(We([
5363
+ [e[0].x, e[0].y],
5364
+ [e[1].x, e[1].y],
5365
+ [e[2].x, e[2].y],
5366
+ [e[3].x, e[3].y]
5367
+ ])), a = {
5368
+ west: i[0],
5369
+ south: i[1],
5370
+ east: i[2],
5371
+ north: i[3]
5372
+ }, o = this.displayRange ? ao(a, this.displayRange) : a;
5373
+ if (!o) {
5374
+ this.clearAllTiles();
5375
+ return;
5131
5376
  }
5377
+ let s = [
5378
+ o.west,
5379
+ o.south,
5380
+ o.east,
5381
+ o.north
5382
+ ];
5383
+ this.getEntityData(s, r, e, this.requestController.signal);
5132
5384
  }
5133
5385
  showDebugPoints(e) {
5134
5386
  viewer.entities.values.filter((e) => e.id && e.id.startsWith(`debug_${this.id}_`)).forEach((e) => viewer.entities.remove(e)), e.forEach((e, t) => {
@@ -5152,28 +5404,33 @@ var to = class {
5152
5404
  render3DFaces(e, t) {
5153
5405
  if (this.destroyed) return;
5154
5406
  this.lastTime = (/* @__PURE__ */ new Date()).getTime();
5155
- let n = N.getCameraView(viewer);
5156
- e.forEach((e) => {
5407
+ let n = N.getCameraView(viewer), r = Array.isArray(e) ? e : [];
5408
+ r.forEach((e) => {
5157
5409
  if (this.isStatic && this.fixedLevel) e.geoSot = e.geoSot, e.level = t;
5158
5410
  else {
5159
- let r = Qa(e.geoSot, t), i = Cesium.Cartesian3.distance(Cesium.Cartesian3.fromDegrees((e.xmax + e.xmin) / 2, (e.ymax + e.ymin) / 2, 0), Cesium.Cartesian3.fromDegrees(n.x, n.y, n.z));
5411
+ let r = to(e.geoSot, t), i = Cesium.Cartesian3.distance(Cesium.Cartesian3.fromDegrees((e.xmax + e.xmin) / 2, (e.ymax + e.ymin) / 2, 0), Cesium.Cartesian3.fromDegrees(n.x, n.y, n.z));
5160
5412
  N.entityGridLevels.filter((e) => e.max >= i && e.min <= i), e.geoSot = e.geoSot, e.level = r;
5161
5413
  }
5162
5414
  });
5163
- let r = e, i = new Set(r.map((e) => e.geoSot)), a = [], o = [];
5415
+ let i = this.displayRange, a = r.filter((e) => i ? !!ao({
5416
+ west: Number(e?.xmin),
5417
+ south: Number(e?.ymin),
5418
+ east: Number(e?.xmax),
5419
+ north: Number(e?.ymax)
5420
+ }, i) : !0), o = new Set(a.map((e) => e.geoSot)), s = [], c = [];
5164
5421
  this.currentTileIds.forEach((e) => {
5165
- i.has(e) || o.push(e);
5166
- }), i.forEach((e) => {
5422
+ o.has(e) || c.push(e);
5423
+ }), o.forEach((e) => {
5167
5424
  if (!this.currentTileIds.has(e)) {
5168
- let t = r.find((t) => e === t.geoSot);
5169
- t && a.push(t);
5425
+ let t = a.find((t) => e === t.geoSot);
5426
+ t && s.push(t);
5170
5427
  }
5171
- }), a.forEach((e) => {
5428
+ }), s.forEach((e) => {
5172
5429
  this.addTile(e, e.level);
5173
- }), o.forEach((e) => {
5430
+ }), c.forEach((e) => {
5174
5431
  let t = this.loadedTiles.get(e);
5175
5432
  t && this.fadeOut(t, e);
5176
- }), this.currentTileIds = i;
5433
+ }), this.currentTileIds = o;
5177
5434
  }
5178
5435
  fadeOut(e, t) {
5179
5436
  if (this.fadeAnimations.has(t)) {
@@ -5186,7 +5443,7 @@ var to = class {
5186
5443
  this.fadeAnimations.set(t, { interval: i });
5187
5444
  }
5188
5445
  isActiveRequest(e, t) {
5189
- return eo({
5446
+ return ro({
5190
5447
  destroyed: this.destroyed,
5191
5448
  currentVersion: this.requestVersion,
5192
5449
  requestVersion: e,
@@ -5344,7 +5601,7 @@ var to = class {
5344
5601
  this.handlers &&= (viewer.camera.changed.removeEventListener(this.handlers), null), this.clearAllTiles(), this.requestController &&= (this.requestController.abort(), null);
5345
5602
  }
5346
5603
  parseCompressedMeshData(e, t) {
5347
- return $a(e, t);
5604
+ return no(e, t);
5348
5605
  }
5349
5606
  showPoint(e, t, n, r) {
5350
5607
  viewer.entities.add({
@@ -5365,7 +5622,7 @@ var to = class {
5365
5622
  }
5366
5623
  });
5367
5624
  }
5368
- }, no = new class {
5625
+ }, so = new class {
5369
5626
  constructor() {
5370
5627
  this.layers = /* @__PURE__ */ new Map();
5371
5628
  }
@@ -5375,9 +5632,9 @@ var to = class {
5375
5632
  if (this.layers.has(t)) {
5376
5633
  console.warn(`图层 ${t} 已存在`);
5377
5634
  let i = this.layers.get(t), a = ja(i.renderSignature, e || {});
5378
- return n && (i.tileColor = n), i.dictCode = e?.dictCode || i.dictCode || "", i.serviceName = e?.serviceName || i.serviceName || "", e?.enableServiceColor !== void 0 && (i.enableServiceColor = !!e.enableServiceColor), i.modelColorUrl = e?.modelColorUrl || i.modelColorUrl || "/v1/zzts/style/render/modelColors", r != null && (i.fixedLevel = r, i.currentNewLevel.value = r), a && (i.renderSignature = Aa(e || {}), i.modelColorCache.clear(), i.clearAllTiles(), i.getViewportInfo()), i;
5635
+ return n && (i.tileColor = n), i.dictCode = e?.dictCode || i.dictCode || "", i.serviceName = e?.serviceName || i.serviceName || "", e?.displayRange !== void 0 && (i.displayRange = io(e.displayRange)), e?.enableServiceColor !== void 0 && (i.enableServiceColor = !!e.enableServiceColor), i.modelColorUrl = e?.modelColorUrl || i.modelColorUrl || "/v1/zzts/style/render/modelColors", r != null && (i.fixedLevel = r, i.currentNewLevel.value = r), a && (i.renderSignature = Aa(e || {}), i.modelColorCache.clear(), i.clearAllTiles(), i.getViewportInfo()), i;
5379
5636
  }
5380
- let s = new to(t, i, r, n, a, o, e);
5637
+ let s = new oo(t, i, r, n, a, o, e);
5381
5638
  s.renderSignature = Aa(e || {}), this.layers.set(t, s);
5382
5639
  try {
5383
5640
  return await s.init(), s.destroyed ? (this.layers.delete(t), null) : s;
@@ -5406,20 +5663,20 @@ var to = class {
5406
5663
  let t = this.layers.get(e);
5407
5664
  t && t.getViewportInfo();
5408
5665
  }
5409
- }(), ro = async (e) => no.createLayer(e, !1), io = (e) => {
5410
- no.removeLayer(e);
5411
- }, ao = (e) => no.getLayer(e);
5666
+ }(), co = async (e) => so.createLayer(e, !1), lo = (e) => {
5667
+ so.removeLayer(e);
5668
+ }, uo = (e) => so.getLayer(e);
5412
5669
  t(() => {
5413
- let e = no.getLayerIds();
5670
+ let e = so.getLayerIds();
5414
5671
  if (e.length > 0) {
5415
- let t = no.getLayer(e[0]);
5672
+ let t = so.getLayer(e[0]);
5416
5673
  return t ? t.getCurrentLevel() : 15;
5417
5674
  }
5418
5675
  return 15;
5419
5676
  });
5420
5677
  //#endregion
5421
5678
  //#region src/zz-layer/zz-layer-zzts3d-point/index.vue
5422
- var oo = {
5679
+ var fo = {
5423
5680
  __name: "index",
5424
5681
  props: { config: {
5425
5682
  type: Object,
@@ -5445,7 +5702,8 @@ var oo = {
5445
5702
  dictCode: "",
5446
5703
  serviceName: "",
5447
5704
  enableServiceColor: !1,
5448
- modelColorUrl: "/v1/zzts/style/render/modelColors"
5705
+ modelColorUrl: "/v1/zzts/style/render/modelColors",
5706
+ displayRange: null
5449
5707
  }, _ = t(() => ({
5450
5708
  ...h,
5451
5709
  ...i.config
@@ -5477,14 +5735,15 @@ var oo = {
5477
5735
  dictCode: e.dictCode,
5478
5736
  serviceName: e.serviceName,
5479
5737
  enableServiceColor: e.enableServiceColor,
5480
- modelColorUrl: e.modelColorUrl
5738
+ modelColorUrl: e.modelColorUrl,
5739
+ displayRange: e.displayRange
5481
5740
  };
5482
5741
  }
5483
5742
  let S = async () => {
5484
5743
  let e = ++u, t = _.value;
5485
5744
  if (!t.layerId) return;
5486
- let n = x(t), i = ao(t.layerId);
5487
- if (i && !ja(i.renderSignature, n) ? s.value = i : s.value = await ro(n), !(m || e !== u)) {
5745
+ let n = x(t), i = uo(t.layerId);
5746
+ if (i && !ja(i.renderSignature, n) ? s.value = i : s.value = await co(n), !(m || e !== u)) {
5488
5747
  if (l.value && _.value.highlightEnabled && s.value?.setHighlight && s.value.setHighlight(l.value, {
5489
5748
  highlightColor: _.value.highlightColor,
5490
5749
  highlightOpacity: _.value.highlightOpacity,
@@ -5524,7 +5783,7 @@ var oo = {
5524
5783
  }, Cesium.ScreenSpaceEventType.LEFT_CLICK);
5525
5784
  }
5526
5785
  }, C = () => {
5527
- b(), v(), s.value = null, io(_.value.layerId || i.config.layerId);
5786
+ b(), v(), s.value = null, lo(_.value.layerId || i.config.layerId);
5528
5787
  };
5529
5788
  return w(_, () => {
5530
5789
  S();
@@ -5535,7 +5794,7 @@ var oo = {
5535
5794
  console.log("组件卸载,开始清理资源..."), m = !0, u++, d++, p?.abort(), p = null, C();
5536
5795
  }), (e, t) => null;
5537
5796
  }
5538
- }, so = {
5797
+ }, po = {
5539
5798
  __name: "queryPoint",
5540
5799
  props: {
5541
5800
  config: {
@@ -5718,7 +5977,7 @@ var oo = {
5718
5977
  C(), x([]);
5719
5978
  }), (e, t) => null;
5720
5979
  }
5721
- }, co = "__zzts3dGridPickable", lo = {
5980
+ }, mo = "__zzts3dGridPickable", ho = {
5722
5981
  __name: "index",
5723
5982
  props: { config: {
5724
5983
  type: Object,
@@ -5818,7 +6077,7 @@ var oo = {
5818
6077
  b && y.remove(b), x && y.remove(x);
5819
6078
  } catch {}
5820
6079
  try {
5821
- b && delete b[co], x && delete x[co];
6080
+ b && delete b[mo], x && delete x[mo];
5822
6081
  } catch {}
5823
6082
  b = null, x = null;
5824
6083
  }
@@ -5837,7 +6096,7 @@ var oo = {
5837
6096
  return t.startsWith("grid_outline_") ? t.slice(13) : t;
5838
6097
  }
5839
6098
  function j() {
5840
- b && (b[co] = !0), x && (x[co] = !0);
6099
+ b && (b[mo] = !0), x && (x[mo] = !0);
5841
6100
  }
5842
6101
  function M(e, t) {
5843
6102
  return Cesium.ColorGeometryInstanceAttribute.toValue(C(e, t));
@@ -5880,7 +6139,7 @@ var oo = {
5880
6139
  if (!t?.length) return null;
5881
6140
  for (let e = 0; e < t.length; e++) {
5882
6141
  let n = t[e], r = n?.primitive;
5883
- if (r && (r[co] === !0 || r === b || r === x)) return n;
6142
+ if (r && (r[mo] === !0 || r === b || r === x)) return n;
5884
6143
  }
5885
6144
  return null;
5886
6145
  }
@@ -6026,11 +6285,11 @@ var oo = {
6026
6285
  p++, m++, v.forEach((e) => e.abort()), v.clear(), _.clear(), h = "", R();
6027
6286
  }), (e, t) => null;
6028
6287
  }
6029
- }, uo = (e, t) => {
6288
+ }, go = (e, t) => {
6030
6289
  let n = e.__vccOpts || e;
6031
6290
  for (let [e, r] of t) n[e] = r;
6032
6291
  return n;
6033
- }, fo = "__zzts3dGridColorPickable", po = /* @__PURE__ */ uo({
6292
+ }, _o = "__zzts3dGridColorPickable", vo = /*#__PURE__*/ go({
6034
6293
  __name: "color",
6035
6294
  props: { config: {
6036
6295
  type: Object,
@@ -6131,7 +6390,7 @@ var oo = {
6131
6390
  D && E.remove(D), O && E.remove(O);
6132
6391
  } catch {}
6133
6392
  try {
6134
- D && delete D[fo], O && delete O[fo];
6393
+ D && delete D[_o], O && delete O[_o];
6135
6394
  } catch {}
6136
6395
  D = null, O = null;
6137
6396
  }
@@ -6161,7 +6420,7 @@ var oo = {
6161
6420
  return Number.isFinite(r) ? r : -1;
6162
6421
  }
6163
6422
  function ee() {
6164
- D && (D[fo] = !0), O && (O[fo] = !0);
6423
+ D && (D[_o] = !0), O && (O[_o] = !0);
6165
6424
  }
6166
6425
  function te(e, t) {
6167
6426
  return Cesium.ColorGeometryInstanceAttribute.toValue(j(e, t));
@@ -6209,7 +6468,7 @@ var oo = {
6209
6468
  if (!t?.length) return null;
6210
6469
  for (let e = 0; e < t.length; e++) {
6211
6470
  let n = t[e], r = n?.primitive;
6212
- if (r && (r[fo] === !0 || r === D || r === O)) return n;
6471
+ if (r && (r[_o] === !0 || r === D || r === O)) return n;
6213
6472
  }
6214
6473
  return null;
6215
6474
  }
@@ -6376,7 +6635,7 @@ var oo = {
6376
6635
  })
6377
6636
  }, null, 4)) : r("", !0);
6378
6637
  }
6379
- }, [["__scopeId", "data-v-719d18e0"]]), mo = {
6638
+ }, [["__scopeId", "data-v-c95c8119"]]), yo = {
6380
6639
  __name: "query",
6381
6640
  props: {
6382
6641
  config: {
@@ -6609,7 +6868,7 @@ var oo = {
6609
6868
  u++, h.forEach((e) => e.abort()), h.clear(), p.clear(), m.clear(), d = "", D();
6610
6869
  }), (e, t) => null;
6611
6870
  }
6612
- }, ho = {
6871
+ }, bo = {
6613
6872
  __name: "interpolation",
6614
6873
  props: { config: {
6615
6874
  type: Object,
@@ -6814,7 +7073,490 @@ var oo = {
6814
7073
  o++, u.forEach((e) => e.abort()), u.clear(), l.clear(), s = "", x();
6815
7074
  }), (e, t) => null;
6816
7075
  }
6817
- }, go = {
7076
+ }, xo = class {
7077
+ constructor(e, t = !1, n = null, r = "255,255,255", i = "", a = 1, o = "") {
7078
+ this.id = e, this.dictCode = o == null ? "" : String(o), this.isStatic = t, this.loadedTiles = /* @__PURE__ */ new Map(), this.currentTileIds = /* @__PURE__ */ new Set(), this.currentNewLevel = g(n || 15), this.gridDb = null, this.entityNum = 0, this.handlers = null, this.requestController = null, this.pendingRequests = /* @__PURE__ */ new Map(), this.fadeAnimations = /* @__PURE__ */ new Map(), this.lastTime = 0, this.serviceType = i, this.opacity = a, this.fixedLevel = n, this.levels_add = window.levels_add_plus || 0, this.tileColor = r, this.tileSleepTime = window.tileSleepTime || 400;
7079
+ }
7080
+ async init() {
7081
+ let e = this.isStatic ? "_static" : "";
7082
+ console.log("1"), this.gridDb = await new O(`gridDbs_${this.id}${e}_${this.serviceType}_v2`, 2), await this.gridDb.openDatabase("gridEntity", "id"), console.log("2"), this.isStatic || this.initHandler(), this.getViewportInfo();
7083
+ }
7084
+ getCurrentLevel() {
7085
+ return this.currentNewLevel.value;
7086
+ }
7087
+ remove() {
7088
+ this.destroyHandler(), this.clearAllTiles();
7089
+ }
7090
+ removeTilesOnly() {
7091
+ this.clearAllTiles();
7092
+ }
7093
+ clearAllTiles() {
7094
+ this.fadeAnimations.forEach((e) => {
7095
+ e.interval && clearInterval(e.interval);
7096
+ }), this.fadeAnimations.clear(), this.pendingRequests.forEach((e) => {
7097
+ e.cancel && e.cancel();
7098
+ }), this.pendingRequests.clear(), this.currentTileIds = /* @__PURE__ */ new Set();
7099
+ for (let [e, t] of this.loadedTiles) t.box && viewer.scene.primitives.contains(t.box) && viewer.scene.primitives.remove(t.box), t.line && viewer.scene.primitives.contains(t.line) && viewer.scene.primitives.remove(t.line);
7100
+ this.loadedTiles.clear();
7101
+ }
7102
+ initHandler1() {
7103
+ if (this.getViewportInfo(), this.handlers) try {
7104
+ viewer.camera.moveEnd.removeEventListener(this.handlers);
7105
+ } catch (e) {
7106
+ console.warn("移除旧的事件监听器失败:", e);
7107
+ }
7108
+ this.handlers = () => {
7109
+ this.getViewportInfo();
7110
+ }, viewer.camera.moveEnd.addEventListener(this.handlers);
7111
+ }
7112
+ initHandler() {
7113
+ if (this.getViewportInfo(), this.handlers) try {
7114
+ viewer.camera.changed.removeEventListener(this.handlers);
7115
+ } catch (e) {
7116
+ console.warn("移除旧的事件监听器失败:", e);
7117
+ }
7118
+ let e = null, t = () => {
7119
+ clearTimeout(e), e = setTimeout(() => {
7120
+ this.getViewportInfo();
7121
+ }, 250);
7122
+ };
7123
+ viewer.camera.changed.addEventListener(t), this.handlers = t;
7124
+ }
7125
+ getViewportInfo() {
7126
+ this.requestController && this.requestController.abort(), this.requestController = new AbortController(), this.entityNum = 0;
7127
+ let e = N.getFrustumGroundIntersectionPoints(viewer), t = N.getCenter(viewer), n = N.getCameraView(viewer);
7128
+ if (n.pitch > -18) return;
7129
+ let r;
7130
+ if (this.isStatic && this.fixedLevel) r = this.fixedLevel + this.levels_add;
7131
+ else {
7132
+ let i = Cesium.Cartesian3.distance(Cesium.Cartesian3.fromDegrees(t.x, t.y, 0), Cesium.Cartesian3.fromDegrees(n.x, n.y, n.z));
7133
+ console.log(N.entityGridLevels);
7134
+ let a = N.entityGridLevels.filter((e) => e.max >= i && e.min <= i);
7135
+ if (!a[0] || e.length < 4) return;
7136
+ r = a[0].level + this.levels_add;
7137
+ }
7138
+ if (this.currentNewLevel.value = r, !(e.length < 4)) {
7139
+ var i = Ke(We([
7140
+ [e[0].x, e[0].y],
7141
+ [e[1].x, e[1].y],
7142
+ [e[2].x, e[2].y],
7143
+ [e[3].x, e[3].y]
7144
+ ]));
7145
+ this.getEntityData(i, r, e, this.requestController.signal);
7146
+ }
7147
+ }
7148
+ showDebugPoints(e) {
7149
+ viewer.entities.values.filter((e) => e.id && e.id.startsWith(`debug_${this.id}_`)).forEach((e) => viewer.entities.remove(e)), e.forEach((e, t) => {
7150
+ this.showPoint(e.x, e.y, 1, t);
7151
+ });
7152
+ }
7153
+ async getEntityData(e, t, n, r) {
7154
+ let i = viewer.scene.canvas, a = i.clientWidth, o = i.clientHeight, s = Number(e[2]) - Number(e[0]), c = Number(e[3]) - Number(e[1]);
7155
+ if (!(s > 20 || c > 20)) try {
7156
+ let n = await k.request({
7157
+ method: "GET",
7158
+ url: `/v1/zzts/layer/3d/calTiles?region=${e[0]},${e[1]},0,${e[2]},${e[3]},10&width=${a}&height=${o}`,
7159
+ timeout: 6e4,
7160
+ signal: r
7161
+ });
7162
+ r.aborted || this.render3DFaces(n.tiles || [], n.lodLevel ?? t);
7163
+ } catch (e) {
7164
+ e.name === "AbortError" ? console.log(`图层 ${this.id} 请求被取消`) : console.error(`图层 ${this.id} 获取实体数据出错:`, e);
7165
+ }
7166
+ }
7167
+ render3DFaces(e, t) {
7168
+ this.lastTime = (/* @__PURE__ */ new Date()).getTime(), e.forEach((e) => {
7169
+ e.geoSot = e.geoSot, e.level = t;
7170
+ });
7171
+ let n = e, r = new Set(n.map((e) => e.geoSot)), i = [], a = [];
7172
+ this.currentTileIds.forEach((e) => {
7173
+ r.has(e) || a.push(e);
7174
+ }), r.forEach((e) => {
7175
+ if (!this.currentTileIds.has(e)) {
7176
+ let t = n.find((t) => e === t.geoSot);
7177
+ t && i.push(t);
7178
+ }
7179
+ }), i.forEach((e) => {
7180
+ this.addTile(e, e.level);
7181
+ }), a.forEach((e) => {
7182
+ let t = this.loadedTiles.get(e);
7183
+ t && this.fadeOut(t, e);
7184
+ }), this.currentTileIds = r;
7185
+ }
7186
+ fadeOut(e, t) {
7187
+ if (this.fadeAnimations.has(t)) {
7188
+ let e = this.fadeAnimations.get(t);
7189
+ e.interval && clearInterval(e.interval);
7190
+ }
7191
+ let n = 0, r = this.tileSleepTime / 100, i = setInterval(() => {
7192
+ n < r ? (e.box && e.box.appearance, n++) : (clearInterval(i), this.fadeAnimations.delete(t), e.box && viewer.scene.primitives.contains(e.box) && viewer.scene.primitives.remove(e.box), e.line && viewer.scene.primitives.contains(e.line) && viewer.scene.primitives.remove(e.line), this.loadedTiles.delete(t), this.currentTileIds.delete(t));
7193
+ }, 100);
7194
+ this.fadeAnimations.set(t, { interval: i });
7195
+ }
7196
+ async addTile(e, t) {
7197
+ let n = e.geoSot;
7198
+ if (this.pendingRequests.has(n)) {
7199
+ let e = this.pendingRequests.get(n);
7200
+ e.cancel && e.cancel();
7201
+ }
7202
+ let r = M.CancelToken.source();
7203
+ this.pendingRequests.set(n, { cancel: () => r.cancel("请求被取消") });
7204
+ let i = e.level || t, a = `${n}__L${i}`;
7205
+ try {
7206
+ let t = await this.gridDb.getDataById("gridEntity", a);
7207
+ if (t) t.data.byteLength > 47 && this.addGridToMap(e, this.parseCompressedMeshData(t.data, i));
7208
+ else {
7209
+ let t = await k.request({
7210
+ method: "GET",
7211
+ url: `/v1/zzts/layer/3d/getTilesByType?layerId=${encodeURIComponent(this.dictCode || "")}&level=${i}&geosot=${e.geoSot}&hcode=${e.highCode || 0}&serviceType=7&type=${encodeURIComponent(this.serviceType || "")}`,
7212
+ headers: { Accept: "application/octet-stream" },
7213
+ responseType: "arraybuffer",
7214
+ timeout: 6e4,
7215
+ cancelToken: r.token
7216
+ });
7217
+ !r.token.reason && t.data.byteLength > 47 && (await this.gridDb.addData("gridEntity", {
7218
+ id: a,
7219
+ data: t.data
7220
+ }), this.addGridToMap(e, this.parseCompressedMeshData(t.data, i))), !r.token.reason && t.data.byteLength < 47 && await this.gridDb.addData("gridEntity", {
7221
+ id: a,
7222
+ data: t.data
7223
+ });
7224
+ }
7225
+ } catch (e) {
7226
+ M.isCancel(e) ? console.log(`图层 ${this.id} 瓦片请求被取消:`, n) : console.error(`图层 ${this.id} 获取瓦片数据出错:`, e);
7227
+ } finally {
7228
+ this.pendingRequests.delete(n);
7229
+ }
7230
+ }
7231
+ createUniqueVertices(e, t) {
7232
+ let n = e instanceof Float64Array ? e : new Float64Array(e), r = t.length, i = new Float64Array(r * 3), a = new Uint32Array(r);
7233
+ for (let e = 0; e < t.length; e++) {
7234
+ let r = t[e] * 3;
7235
+ i[e * 3] = n[r], i[e * 3 + 1] = n[r + 1], i[e * 3 + 2] = n[r + 2], a[e] = e;
7236
+ }
7237
+ return {
7238
+ positions: i,
7239
+ indices: a
7240
+ };
7241
+ }
7242
+ calculateFlatNormalsForUniqueVertices(e, t) {
7243
+ let n = new Float32Array(e.length);
7244
+ for (let r = 0; r < t.length; r += 3) {
7245
+ let i = t[r] * 3, a = t[r + 1] * 3, o = t[r + 2] * 3, s = [
7246
+ e[i],
7247
+ e[i + 1],
7248
+ e[i + 2]
7249
+ ], c = [
7250
+ e[a],
7251
+ e[a + 1],
7252
+ e[a + 2]
7253
+ ], l = [
7254
+ e[o],
7255
+ e[o + 1],
7256
+ e[o + 2]
7257
+ ], u = [
7258
+ c[0] - s[0],
7259
+ c[1] - s[1],
7260
+ c[2] - s[2]
7261
+ ], d = [
7262
+ l[0] - s[0],
7263
+ l[1] - s[1],
7264
+ l[2] - s[2]
7265
+ ], f = [
7266
+ u[1] * d[2] - u[2] * d[1],
7267
+ u[2] * d[0] - u[0] * d[2],
7268
+ u[0] * d[1] - u[1] * d[0]
7269
+ ], p = Math.sqrt(f[0] * f[0] + f[1] * f[1] + f[2] * f[2]), m;
7270
+ m = p > 1e-10 && !isNaN(f[0]) && !isNaN(f[1]) && !isNaN(f[2]) && isFinite(f[0]) && isFinite(f[1]) && isFinite(f[2]) ? [
7271
+ f[0] / p,
7272
+ f[1] / p,
7273
+ f[2] / p
7274
+ ] : [
7275
+ 0,
7276
+ 0,
7277
+ 1
7278
+ ], n[i] = m[0], n[i + 1] = m[1], n[i + 2] = m[2], n[a] = m[0], n[a + 1] = m[1], n[a + 2] = m[2], n[o] = m[0], n[o + 1] = m[1], n[o + 2] = m[2];
7279
+ }
7280
+ return n;
7281
+ }
7282
+ addGridToMap(e, t) {
7283
+ if (!t || t.length === 0) return console.warn("没有几何数据可渲染"), null;
7284
+ let n = t.map((e) => {
7285
+ if (!e.positions || e.positions.length === 0) return console.warn("跳过无效的几何体:缺少顶点数据"), null;
7286
+ if (!e.indices || e.indices.length === 0) return console.warn("跳过无效的几何体:缺少索引数据"), null;
7287
+ let { positions: t, indices: n } = this.createUniqueVertices(e.positions, e.indices), r = this.calculateFlatNormalsForUniqueVertices(t, n), i = t.length / 3, a = new Float32Array(i * 2);
7288
+ for (let e = 0; e < i; e++) a[e * 2] = 0, a[e * 2 + 1] = 0;
7289
+ let o = new Cesium.Geometry({
7290
+ attributes: {
7291
+ position: new Cesium.GeometryAttribute({
7292
+ componentDatatype: Cesium.ComponentDatatype.DOUBLE,
7293
+ componentsPerAttribute: 3,
7294
+ values: t,
7295
+ normalize: !1
7296
+ }),
7297
+ st: new Cesium.GeometryAttribute({
7298
+ componentDatatype: Cesium.ComponentDatatype.FLOAT,
7299
+ componentsPerAttribute: 2,
7300
+ values: a
7301
+ }),
7302
+ normal: new Cesium.GeometryAttribute({
7303
+ componentDatatype: Cesium.ComponentDatatype.FLOAT,
7304
+ componentsPerAttribute: 3,
7305
+ values: r,
7306
+ normalize: !1
7307
+ })
7308
+ },
7309
+ indices: n,
7310
+ primitiveType: Cesium.PrimitiveType.TRIANGLES,
7311
+ boundingSphere: Cesium.BoundingSphere.fromVertices(t)
7312
+ });
7313
+ return o.modelId = e.modelId, o.color = e.color, o;
7314
+ }).filter((e) => e !== null).map((e, t) => {
7315
+ let n = e.color, r = null;
7316
+ if (n == "#C2D6E2FF" || n == "#00000000") r = `rgba(${this.tileColor}, ${this.opacity})`;
7317
+ else try {
7318
+ r = this.hexToRgba(n);
7319
+ } catch {
7320
+ r = `rgba(${this.tileColor || "255,255,255"}, ${this.opacity})`;
7321
+ }
7322
+ return r ||= `rgba(${this.tileColor || "255,255,255"}, ${this.opacity})`, new Cesium.GeometryInstance({
7323
+ geometry: e,
7324
+ id: e.modelId,
7325
+ attributes: {
7326
+ color: Cesium.ColorGeometryInstanceAttribute.fromColor(Cesium.Color.fromCssColorString(`${r}`)),
7327
+ show: new Cesium.ShowGeometryInstanceAttribute(!0)
7328
+ }
7329
+ });
7330
+ }), r = new Cesium.Primitive({
7331
+ geometryInstances: n,
7332
+ asynchronous: !1,
7333
+ compressVertices: !1,
7334
+ releaseGeometryInstances: !1,
7335
+ appearance: new Cesium.PerInstanceColorAppearance({
7336
+ vertexFormat: Cesium.VertexFormat.POSITION_AND_NORMAL,
7337
+ flat: !1,
7338
+ translucent: !1,
7339
+ renderState: {
7340
+ depthTest: { enabled: !0 },
7341
+ blending: Cesium.BlendingState.ALPHA_BLEND
7342
+ }
7343
+ })
7344
+ });
7345
+ r.layerId = this.id, r.geoSot = e.geoSot, viewer.scene.primitives.add(r);
7346
+ let i = 0, a = this.tileSleepTime / 100, o = setInterval(() => {
7347
+ i <= a * this.opacity ? (r && r.appearance, i++) : (clearInterval(o), this.fadeAnimations.has(e.geoSot) && this.fadeAnimations.delete(e.geoSot), this.removeOldEntities(e.geoSot));
7348
+ }, 100);
7349
+ this.fadeAnimations.set(e.geoSot, { interval: o }), this.loadedTiles.set(e.geoSot, { box: r });
7350
+ }
7351
+ hexToRgba(e) {
7352
+ e = e.replace("#", "");
7353
+ let t = 1;
7354
+ if (e.length === 8) t = parseInt(e.slice(6, 8), 16) / 255;
7355
+ else if (e.length !== 6) return console.error("Invalid hex format"), null;
7356
+ return `rgba(${parseInt(e.slice(0, 2), 16)}, ${parseInt(e.slice(2, 4), 16)}, ${parseInt(e.slice(4, 6), 16)}, ${t})`;
7357
+ }
7358
+ removeOldEntities(e) {
7359
+ viewer.scene.primitives._primitives.forEach((t) => {
7360
+ t.geoSot && t.layerId === this.id && t.geoSot.length !== e.length && viewer.scene.primitives.remove(t);
7361
+ });
7362
+ }
7363
+ destroyHandler() {
7364
+ this.handlers &&= (viewer.camera.changed.removeEventListener(this.handlers), null), this.clearAllTiles(), this.requestController &&= (this.requestController.abort(), null);
7365
+ }
7366
+ decompressMeshChunk(e) {
7367
+ try {
7368
+ return Da.ungzip(e);
7369
+ } catch {
7370
+ try {
7371
+ return Da.inflate(e);
7372
+ } catch {
7373
+ return Da.inflate(e, { windowBits: -15 });
7374
+ }
7375
+ }
7376
+ }
7377
+ parseCompressedMeshData(e, t) {
7378
+ let n = [];
7379
+ if (!(e instanceof ArrayBuffer) && !(e?.buffer instanceof ArrayBuffer)) return console.error("parseCompressedMeshData: 输入不是 ArrayBuffer"), n;
7380
+ let r = e instanceof ArrayBuffer ? e : e.buffer, i = new DataView(r), a = 0;
7381
+ if (r.byteLength < 4) return n;
7382
+ let o = i.getInt32(a, !0);
7383
+ if (a += 4, o <= 0 || o > 5e5) return console.error(`parseCompressedMeshData: tileCount 异常 ${o}`), n;
7384
+ for (let e = 0; e < o; e++) {
7385
+ if (a + 4 > r.byteLength) {
7386
+ console.error("parseCompressedMeshData: 读取 compressedLength 越界");
7387
+ break;
7388
+ }
7389
+ let o = i.getInt32(a, !0);
7390
+ if (a += 4, o <= 0 || a + o > r.byteLength) {
7391
+ console.error(`parseCompressedMeshData: compressedLength 异常 ${o}`);
7392
+ break;
7393
+ }
7394
+ let s = new Uint8Array(r, a, o);
7395
+ a += o;
7396
+ let c;
7397
+ try {
7398
+ c = this.decompressMeshChunk(s);
7399
+ } catch (t) {
7400
+ console.error(`parseCompressedMeshData: 解压失败 t=${e}`, t);
7401
+ continue;
7402
+ }
7403
+ let l = new DataView(c.buffer, c.byteOffset, c.byteLength), u = 0;
7404
+ if (c.byteLength < 16) {
7405
+ console.warn(`parseCompressedMeshData: 解压后过短 t=${e}`);
7406
+ continue;
7407
+ }
7408
+ let d = l.getBigInt64(u, !0);
7409
+ u += 8;
7410
+ let f = l.getInt32(u, !0);
7411
+ u += 4;
7412
+ let p = l.getInt32(u, !0);
7413
+ u += 4;
7414
+ let m = f / 4, h = p / 4;
7415
+ if (!Number.isInteger(m) || !Number.isInteger(h) || m < 0 || h < 0 || u + f + p > c.byteLength) {
7416
+ console.error(`parseCompressedMeshData: 长度字段异常 t=${e} pos=${f} idx=${p}`);
7417
+ continue;
7418
+ }
7419
+ let g = new Float64Array(m);
7420
+ for (let e = 0; e < m; e++) g[e] = l.getInt32(u, !0) / 100, u += 4;
7421
+ let _ = new Uint32Array(h);
7422
+ for (let e = 0; e < h; e++) _[e] = l.getUint32(u, !0), u += 4;
7423
+ n.push({
7424
+ positions: g,
7425
+ indices: _,
7426
+ positionCount: m,
7427
+ indexCount: h,
7428
+ modelId: d.toString(),
7429
+ lodLevel: t,
7430
+ color: "#C2D6E2FF"
7431
+ });
7432
+ }
7433
+ return n;
7434
+ }
7435
+ showPoint(e, t, n, r) {
7436
+ viewer.entities.add({
7437
+ position: Cesium.Cartesian3.fromDegrees(e, t, n),
7438
+ point: {
7439
+ pixelSize: 5,
7440
+ color: Cesium.Color.RED,
7441
+ outlineColor: Cesium.Color.WHITE,
7442
+ outlineWidth: 2
7443
+ },
7444
+ id: `debug_${this.id}_${r}`,
7445
+ label: {
7446
+ text: r + "",
7447
+ font: "14pt monospace",
7448
+ outlineWidth: 2,
7449
+ horizontalOrigin: Cesium.HorizontalOrigin.LEFT,
7450
+ pixelOffset: new Cesium.Cartesian2(10, 0)
7451
+ }
7452
+ });
7453
+ }
7454
+ }, So = new class {
7455
+ constructor() {
7456
+ this.layers = /* @__PURE__ */ new Map();
7457
+ }
7458
+ async createLayer(e) {
7459
+ let t = typeof e == "string" ? e : e?.id || e?.layerKey || e?.serviceType || e?.layerId, n = typeof e == "object" && e?.color != null && String(e.color).trim() ? String(e.color).trim() : void 0, r = e?.level, i = e?.isStatic, a = e?.serviceType, o = e?.opacity, s = typeof e == "object" ? e?.dictCode ?? e?.layerId ?? "" : "";
7460
+ if (!t) return console.error("创建图层失败:缺少id参数"), null;
7461
+ if (this.layers.has(t)) {
7462
+ console.warn(`图层 ${t} 已存在`);
7463
+ let e = this.layers.get(t), i = !1;
7464
+ if (n != null && n !== "" && e.tileColor !== n && (e.tileColor = n, i = !0), r != null && (e.fixedLevel = r, e.currentNewLevel.value = r), s !== void 0 && (e.dictCode = s == null ? "" : String(s)), a !== void 0 && (e.serviceType = a), o != null) {
7465
+ let t = Number(o);
7466
+ Number.isFinite(t) && e.opacity !== t && (e.opacity = t, i = !0);
7467
+ }
7468
+ return i && (typeof e.clearAllTiles == "function" && e.clearAllTiles(), typeof e.getViewportInfo == "function" && e.getViewportInfo()), this.layers.get(t);
7469
+ }
7470
+ let c = new xo(t, i, r, n, a, o, s);
7471
+ return await c.init(), this.layers.set(t, c), c;
7472
+ }
7473
+ removeLayer(e) {
7474
+ let t = this.layers.get(e);
7475
+ t && (t.remove(), this.layers.delete(e), console.log(`图层 ${e} 已移除`));
7476
+ }
7477
+ removeAllLayers() {
7478
+ this.layers.forEach((e) => e.remove()), this.layers.clear();
7479
+ }
7480
+ getLayer(e) {
7481
+ return this.layers.get(e);
7482
+ }
7483
+ getLayerIds() {
7484
+ return Array.from(this.layers.keys());
7485
+ }
7486
+ removeTilesByLayerId(e) {
7487
+ let t = this.layers.get(e);
7488
+ t && t.removeTilesOnly();
7489
+ }
7490
+ refreshLayer(e) {
7491
+ let t = this.layers.get(e);
7492
+ t && t.getViewportInfo();
7493
+ }
7494
+ }(), Co = async (e) => So.createLayer(e, !1), wo = (e) => {
7495
+ So.removeLayer(e);
7496
+ };
7497
+ t(() => {
7498
+ let e = So.getLayerIds();
7499
+ if (e.length > 0) {
7500
+ let t = So.getLayer(e[0]);
7501
+ return t ? t.getCurrentLevel() : 15;
7502
+ }
7503
+ return 15;
7504
+ });
7505
+ //#endregion
7506
+ //#region src/zz-layer/zz-layer-zzts3dtype/index.vue
7507
+ var To = {
7508
+ __name: "index",
7509
+ props: { config: {
7510
+ type: Object,
7511
+ default: () => ({})
7512
+ } },
7513
+ setup(e) {
7514
+ c("cesiumViewer");
7515
+ let n = e, r = {
7516
+ id: "",
7517
+ layerId: "",
7518
+ color: "255,255,255",
7519
+ isStatic: !1,
7520
+ level: null,
7521
+ serviceType: "",
7522
+ opacity: 1
7523
+ }, i = t(() => ({
7524
+ ...r,
7525
+ ...n.config
7526
+ }));
7527
+ function a() {
7528
+ let { id: e, layerId: t, serviceType: n } = i.value;
7529
+ return e || (n ? `${t || "_"}__${n}` : "") || n || t || "";
7530
+ }
7531
+ let o = async () => {
7532
+ i.value.level && (i.value.isStatic = !0);
7533
+ let e = a();
7534
+ if (!e) {
7535
+ console.error("创建图层失败:缺少id参数", i.value);
7536
+ return;
7537
+ }
7538
+ Co({
7539
+ id: e,
7540
+ layerId: i.value.layerId || "",
7541
+ dictCode: i.value.layerId || "",
7542
+ color: i.value.color,
7543
+ isStatic: i.value.isStatic,
7544
+ level: i.value.level,
7545
+ serviceType: i.value.serviceType,
7546
+ opacity: i.value.opacity
7547
+ });
7548
+ }, s = () => {
7549
+ wo(a());
7550
+ };
7551
+ return w(i, () => {
7552
+ o();
7553
+ }, { deep: !0 }), d(() => {
7554
+ console.log("组件挂载,开始初始化..."), o();
7555
+ }), f(() => {
7556
+ console.log("组件卸载,开始清理资源..."), s();
7557
+ }), (e, t) => null;
7558
+ }
7559
+ }, Eo = {
6818
7560
  __name: "index",
6819
7561
  props: { config: {
6820
7562
  type: Object,
@@ -6852,7 +7594,7 @@ var oo = {
6852
7594
  e && u();
6853
7595
  }), (e, t) => null;
6854
7596
  }
6855
- }, _o = {
7597
+ }, Do = {
6856
7598
  excavations: [],
6857
7599
  globalStyle: {
6858
7600
  show: !0,
@@ -6879,38 +7621,38 @@ var oo = {
6879
7621
  maxArea: 5e3 * 1e3 * 1e3,
6880
7622
  maxPerimeter: 5e3 * 1e3
6881
7623
  }
6882
- }, vo = (e = {}) => ({
6883
- ..._o,
7624
+ }, Oo = (e = {}) => ({
7625
+ ...Do,
6884
7626
  ...e,
6885
7627
  globalStyle: {
6886
- ..._o.globalStyle,
7628
+ ...Do.globalStyle,
6887
7629
  ...e.globalStyle
6888
7630
  },
6889
7631
  limits: {
6890
- ..._o.limits,
7632
+ ...Do.limits,
6891
7633
  ...e.limits
6892
7634
  },
6893
7635
  excavations: e.excavations || []
6894
- }), yo = (e, t, n = 1) => {
7636
+ }), ko = (e, t, n = 1) => {
6895
7637
  try {
6896
7638
  return D.Color.fromCssColorString(e).withAlpha(n);
6897
7639
  } catch {
6898
7640
  return D.Color.fromCssColorString(t).withAlpha(n);
6899
7641
  }
6900
- }, bo = (e, t, n, r, i) => e ? D.Material.fromType("Image", {
7642
+ }, Ao = (e, t, n, r, i) => e ? D.Material.fromType("Image", {
6901
7643
  image: e,
6902
7644
  color: D.Color.WHITE.withAlpha(n),
6903
7645
  repeat: i || new D.Cartesian2(1, 1)
6904
- }) : D.Material.fromType("Color", { color: yo(t, r, n) }), xo = (e) => {
7646
+ }) : D.Material.fromType("Color", { color: ko(t, r, n) }), jo = (e) => {
6905
7647
  if (e.length < 2) return 0;
6906
7648
  let t = 0;
6907
7649
  for (let n = 0; n < e.length - 1; n += 1) t += D.Cartesian3.distance(e[n], e[n + 1]);
6908
7650
  return t;
6909
- }, So = (e, t) => {
7651
+ }, Mo = (e, t) => {
6910
7652
  if (!e) return;
6911
- let n = xo(t), r = Math.max(Math.ceil(n / 100), 1);
7653
+ let n = jo(t), r = Math.max(Math.ceil(n / 100), 1);
6912
7654
  return new D.Cartesian2(r, 1);
6913
- }, Co = (e, t, n, r = !1) => {
7655
+ }, No = (e, t, n, r = !1) => {
6914
7656
  let i = r ? {
6915
7657
  perPositionHeight: !1,
6916
7658
  heightReference: D.HeightReference.CLAMP_TO_GROUND
@@ -6930,7 +7672,7 @@ var oo = {
6930
7672
  clampToGround: r
6931
7673
  }
6932
7674
  });
6933
- }, wo = (e, t, n = !1) => {
7675
+ }, Po = (e, t, n = !1) => {
6934
7676
  let r = n ? {
6935
7677
  perPositionHeight: !1,
6936
7678
  heightReference: D.HeightReference.CLAMP_TO_GROUND
@@ -6950,19 +7692,19 @@ var oo = {
6950
7692
  clampToGround: n
6951
7693
  }
6952
7694
  });
6953
- }, To = async (e = 260) => {
7695
+ }, Fo = async (e = 260) => {
6954
7696
  await new Promise((t) => window.setTimeout(t, e));
6955
- }, Eo = (e, t = e.height || 0) => D.Cartesian3.fromDegrees(e.lng, e.lat, t), Do = (e) => D.Cartesian3.fromDegrees(e.lng, e.lat), Oo = (e, t) => D.Math.equalsEpsilon(e.lng, t.lng, D.Math.EPSILON12) && D.Math.equalsEpsilon(e.lat, t.lat, D.Math.EPSILON12), ko = (e) => {
7697
+ }, Io = (e, t = e.height || 0) => D.Cartesian3.fromDegrees(e.lng, e.lat, t), Lo = (e) => D.Cartesian3.fromDegrees(e.lng, e.lat), Ro = (e, t) => D.Math.equalsEpsilon(e.lng, t.lng, D.Math.EPSILON12) && D.Math.equalsEpsilon(e.lat, t.lat, D.Math.EPSILON12), zo = (e) => {
6956
7698
  let t = e.reduce((e, t) => {
6957
7699
  let n = e.at(-1);
6958
- return (!n || !Oo(n, t)) && e.push(t), e;
7700
+ return (!n || !Ro(n, t)) && e.push(t), e;
6959
7701
  }, []);
6960
- return t.length > 1 && Oo(t[0], t[t.length - 1]) && t.pop(), t;
6961
- }, Ao = (e) => e <= 50 ? 5 : e <= 200 ? 10 : e <= 1e3 ? 20 : 50, jo = (e) => {
6962
- let t = Ao(e);
7702
+ return t.length > 1 && Ro(t[0], t[t.length - 1]) && t.pop(), t;
7703
+ }, Bo = (e) => e <= 50 ? 5 : e <= 200 ? 10 : e <= 1e3 ? 20 : 50, Vo = (e) => {
7704
+ let t = Bo(e);
6963
7705
  return Math.min(Math.max(Math.ceil(e / t), 1), 800);
6964
- }, Mo = (e) => e.map((t, n) => {
6965
- let r = e[(n + 1) % e.length], i = D.Cartographic.fromDegrees(t.lng, t.lat), a = D.Cartographic.fromDegrees(r.lng, r.lat), o = new D.EllipsoidGeodesic(i, a), s = jo(o.surfaceDistance), c = [t];
7706
+ }, Ho = (e) => e.map((t, n) => {
7707
+ let r = e[(n + 1) % e.length], i = D.Cartographic.fromDegrees(t.lng, t.lat), a = D.Cartographic.fromDegrees(r.lng, r.lat), o = new D.EllipsoidGeodesic(i, a), s = Vo(o.surfaceDistance), c = [t];
6966
7708
  for (let e = 1; e < s; e += 1) {
6967
7709
  let n = e / s, i = o.interpolateUsingFraction(n);
6968
7710
  c.push({
@@ -6972,10 +7714,10 @@ var oo = {
6972
7714
  });
6973
7715
  }
6974
7716
  return c.push(r), { points: c };
6975
- }), No = (e) => e.flatMap((t, n) => {
7717
+ }), Uo = (e) => e.flatMap((t, n) => {
6976
7718
  let r = n === 0 ? t.points : t.points.slice(1);
6977
- return n === e.length - 1 && r.length > 0 && Oo(r[r.length - 1], e[0].points[0]) ? r.slice(0, -1) : r;
6978
- }), Po = (e) => {
7719
+ return n === e.length - 1 && r.length > 0 && Ro(r[r.length - 1], e[0].points[0]) ? r.slice(0, -1) : r;
7720
+ }), Wo = (e) => {
6979
7721
  if (e.length < 2) return 0;
6980
7722
  let t = 0;
6981
7723
  for (let n = 0; n < e.length; n += 1) {
@@ -6983,10 +7725,10 @@ var oo = {
6983
7725
  t += s.surfaceDistance;
6984
7726
  }
6985
7727
  return t;
6986
- }, Fo = (e) => {
7728
+ }, Go = (e) => {
6987
7729
  if (e.length < 3) return 0;
6988
7730
  let t = e[0].lng, n = D.Math.toRadians(e.reduce((e, t) => e + t.lat, 0) / e.length), r = D.Ellipsoid.WGS84.maximumRadius, i = e.map((e) => {
6989
- let i = Io(e.lng, t);
7731
+ let i = Ko(e.lng, t);
6990
7732
  return {
6991
7733
  x: D.Math.toRadians(i) * r * Math.cos(n),
6992
7734
  y: D.Math.toRadians(e.lat) * r
@@ -6997,20 +7739,20 @@ var oo = {
6997
7739
  a += t.x * n.y - n.x * t.y;
6998
7740
  }
6999
7741
  return Math.abs(a) / 2;
7000
- }, Io = (e, t) => {
7742
+ }, Ko = (e, t) => {
7001
7743
  let n = e;
7002
7744
  for (; n - t > 180;) n -= 360;
7003
7745
  for (; n - t < -180;) n += 360;
7004
7746
  return n;
7005
- }, Lo = (e) => e >= 1e3 ? `${(e / 1e3).toFixed(2)}公里` : `${Math.round(e)}米`, Ro = (e) => e >= 1e3 * 1e3 ? `${(e / 1e3 / 1e3).toFixed(2)}平方公里` : `${Math.round(e)}平方米`, zo = (e, t) => {
7006
- let n = Fo(e);
7007
- if (t.maxArea > 0 && n > t.maxArea) return `绘制区域过大,面积约 ${Ro(n)},已超过 ${Ro(t.maxArea)},请缩小范围或分块开挖`;
7008
- let r = Po(e);
7009
- return t.maxPerimeter > 0 && r > t.maxPerimeter ? `绘制区域过大,周长约 ${Lo(r)},已超过 ${Lo(t.maxPerimeter)},请缩小范围或分块开挖` : "";
7010
- }, Bo = (e, t) => {
7747
+ }, qo = (e) => e >= 1e3 ? `${(e / 1e3).toFixed(2)}公里` : `${Math.round(e)}米`, Jo = (e) => e >= 1e3 * 1e3 ? `${(e / 1e3 / 1e3).toFixed(2)}平方公里` : `${Math.round(e)}平方米`, Yo = (e, t) => {
7748
+ let n = Go(e);
7749
+ if (t.maxArea > 0 && n > t.maxArea) return `绘制区域过大,面积约 ${Jo(n)},已超过 ${Jo(t.maxArea)},请缩小范围或分块开挖`;
7750
+ let r = Wo(e);
7751
+ return t.maxPerimeter > 0 && r > t.maxPerimeter ? `绘制区域过大,周长约 ${qo(r)},已超过 ${qo(t.maxPerimeter)},请缩小范围或分块开挖` : "";
7752
+ }, Xo = (e, t) => {
7011
7753
  let n = t[0], r = 0;
7012
7754
  return e.map((i, a) => {
7013
- let o = a === e.length - 1 && i.points.length > 0 && e[0].points.length > 0 && Oo(i.points[i.points.length - 1], e[0].points[0]), s = i.points.length - (a === 0 ? 0 : 1) - !!o, c = t.slice(r, r + s);
7755
+ let o = a === e.length - 1 && i.points.length > 0 && e[0].points.length > 0 && Ro(i.points[i.points.length - 1], e[0].points[0]), s = i.points.length - (a === 0 ? 0 : 1) - !!o, c = t.slice(r, r + s);
7014
7756
  if (r += s, a === 0) return o ? [...c, n] : c;
7015
7757
  let l = t[r - s - 1];
7016
7758
  return o ? [
@@ -7019,10 +7761,10 @@ var oo = {
7019
7761
  n
7020
7762
  ] : [l, ...c];
7021
7763
  });
7022
- }, Vo = (e, t) => {
7764
+ }, Zo = (e, t) => {
7023
7765
  let n = Math.min(...e);
7024
7766
  return e.map(() => n - t);
7025
- }, Ho = (e, t, n) => ({
7767
+ }, Qo = (e, t, n) => ({
7026
7768
  id: e.id || n(),
7027
7769
  positions: e.positions || [],
7028
7770
  height: e.height ?? t.height,
@@ -7039,12 +7781,12 @@ var oo = {
7039
7781
  showSide: e.showSide ?? t.showSide,
7040
7782
  showBottom: e.showBottom ?? t.showBottom,
7041
7783
  showEdge: e.showEdge ?? t.showEdge
7042
- }), Uo = (e, t) => {
7784
+ }), $o = (e, t) => {
7043
7785
  e.clippingPolygons = t;
7044
- }, Wo = (e) => new D.ClippingPolygon({ positions: e.map((e) => Do(e)) }), Go = (e) => new D.ClippingPolygonCollection({
7045
- polygons: e.filter((e) => e.length >= 3).map(Wo),
7786
+ }, es = (e) => new D.ClippingPolygon({ positions: e.map((e) => Lo(e)) }), ts = (e) => new D.ClippingPolygonCollection({
7787
+ polygons: e.filter((e) => e.length >= 3).map(es),
7046
7788
  inverse: !1
7047
- }), Ko = (e, t, n, r, i) => {
7789
+ }), ns = (e, t, n, r, i) => {
7048
7790
  let a = /* @__PURE__ */ new Map(), o = /* @__PURE__ */ new Set(), s = /* @__PURE__ */ new Map(), c = null, l = !1, u = !1, d = !1, f = () => `excavation-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`, p = async (r) => {
7049
7791
  let i = e(), a = t(), o = r.map((e) => D.Cartographic.fromDegrees(e.lng, e.lat));
7050
7792
  if (i && a.sampleTerrain && !(i.terrainProvider instanceof D.EllipsoidTerrainProvider)) try {
@@ -7056,7 +7798,7 @@ var oo = {
7056
7798
  let n = o[t], r = i?.scene.globe.getHeight(n);
7057
7799
  return e.height ?? r ?? 0;
7058
7800
  });
7059
- }, m = (e) => Ho(e, t().globalStyle, f), h = (e) => {
7801
+ }, m = (e) => Qo(e, t().globalStyle, f), h = (e) => {
7060
7802
  let n = t();
7061
7803
  return JSON.stringify({
7062
7804
  item: e,
@@ -7070,9 +7812,9 @@ var oo = {
7070
7812
  e.height ?? null
7071
7813
  ])), n = s.get(t);
7072
7814
  if (n) return n;
7073
- let r = Mo(e), i = {
7815
+ let r = Ho(e), i = {
7074
7816
  renderBoundarySegments: r,
7075
- renderBoundaryPositions: No(r),
7817
+ renderBoundaryPositions: Uo(r),
7076
7818
  clipBoundaryPositions: e,
7077
7819
  bottomBoundaryPositions: e
7078
7820
  };
@@ -7085,13 +7827,13 @@ var oo = {
7085
7827
  y();
7086
7828
  return;
7087
7829
  }
7088
- l ||= (c = n.scene.globe.clippingPolygons, !0), Uo(n.scene.globe, Go(i)), n.scene.requestRender();
7830
+ l ||= (c = n.scene.globe.clippingPolygons, !0), $o(n.scene.globe, ts(i)), n.scene.requestRender();
7089
7831
  }, v = () => {
7090
7832
  let n = e(), r = t();
7091
7833
  n && (d ||= (u = n.scene.globe.depthTestAgainstTerrain, !0), n.scene.globe.depthTestAgainstTerrain = r.depthTestAgainstTerrain, n.scene.requestRender());
7092
7834
  }, y = () => {
7093
7835
  let t = e();
7094
- t && (l &&= (Uo(t.scene.globe, c || void 0), c = null, !1), t.scene.requestRender());
7836
+ t && (l &&= ($o(t.scene.globe, c || void 0), c = null, !1), t.scene.requestRender());
7095
7837
  }, b = () => {
7096
7838
  let t = e();
7097
7839
  !t || !d || (t.scene.globe.depthTestAgainstTerrain = u, d = !1, t.scene.requestRender());
@@ -7101,10 +7843,10 @@ var oo = {
7101
7843
  }, S = async (r) => {
7102
7844
  let a = e();
7103
7845
  if (!a) return null;
7104
- let o = m(r), s = ko(o.positions);
7846
+ let o = m(r), s = zo(o.positions);
7105
7847
  if (!s || s.length < 3) return n("excavation-error", /* @__PURE__ */ Error("地形开挖至少需要 3 个多边形点位")), null;
7106
7848
  let c = (e) => {
7107
- let r = wo(a, s.map((e) => Eo(e, e.height || 0)), t().depthTestAgainstTerrain);
7849
+ let r = Po(a, s.map((e) => Io(e, e.height || 0)), t().depthTestAgainstTerrain);
7108
7850
  return r.show = o.show, a.scene.requestRender(), n("excavation-error", Error(e)), P.warning(e), {
7109
7851
  item: {
7110
7852
  ...o,
@@ -7114,14 +7856,14 @@ var oo = {
7114
7856
  primitives: [],
7115
7857
  terrainClipEnabled: !1
7116
7858
  };
7117
- }, l = zo(s, t().limits);
7859
+ }, l = Yo(s, t().limits);
7118
7860
  if (l) return c(l);
7119
- let { renderBoundarySegments: u, renderBoundaryPositions: d, bottomBoundaryPositions: f } = g(s), h = Co(a, o.id, s.map((e) => Eo(e, e.height || 0)), t().depthTestAgainstTerrain);
7861
+ let { renderBoundarySegments: u, renderBoundaryPositions: d, bottomBoundaryPositions: f } = g(s), h = No(a, o.id, s.map((e) => Io(e, e.height || 0)), t().depthTestAgainstTerrain);
7120
7862
  a.scene.requestRender();
7121
7863
  let _ = [], v = [];
7122
7864
  try {
7123
- await Promise.all([To(), i?.() || Promise.resolve()]);
7124
- let e = await p(d), t = Vo(e, o.height), n = Math.min(...e) - o.height, r = f.map((e) => Eo(e, n)), s = d.map((t, n) => Eo(t, e[n])), c = Bo(u, e), l = Bo(u, t), m = D.MaterialAppearance.MaterialSupport.TEXTURED.vertexFormat, h = {
7865
+ await Promise.all([Fo(), i?.() || Promise.resolve()]);
7866
+ let e = await p(d), t = Zo(e, o.height), n = Math.min(...e) - o.height, r = f.map((e) => Io(e, n)), s = d.map((t, n) => Io(t, e[n])), c = Xo(u, e), l = Xo(u, t), m = D.MaterialAppearance.MaterialSupport.TEXTURED.vertexFormat, h = {
7125
7867
  depthTest: { enabled: !0 },
7126
7868
  depthMask: !0
7127
7869
  };
@@ -7137,7 +7879,7 @@ var oo = {
7137
7879
  })
7138
7880
  }),
7139
7881
  appearance: new D.MaterialAppearance({
7140
- material: bo(o.bottomTexture, o.bottomColor, o.bottomOpacity, _o.globalStyle.bottomColor),
7882
+ material: Ao(o.bottomTexture, o.bottomColor, o.bottomOpacity, Do.globalStyle.bottomColor),
7141
7883
  materialSupport: D.MaterialAppearance.MaterialSupport.TEXTURED,
7142
7884
  faceForward: !0,
7143
7885
  renderState: h
@@ -7147,7 +7889,7 @@ var oo = {
7147
7889
  v.push(e);
7148
7890
  }
7149
7891
  if (o.showSide) for (let e = 0; e < u.length; e += 1) {
7150
- let t = u[e].points.map((e) => Eo(e)), n = l[e], r = c[e], i = So(o.sideTexture, t), s = a.scene.primitives.add(new D.Primitive({
7892
+ let t = u[e].points.map((e) => Io(e)), n = l[e], r = c[e], i = Mo(o.sideTexture, t), s = a.scene.primitives.add(new D.Primitive({
7151
7893
  show: !1,
7152
7894
  geometryInstances: new D.GeometryInstance({
7153
7895
  id: `${o.id}-wall-${e}`,
@@ -7159,7 +7901,7 @@ var oo = {
7159
7901
  })
7160
7902
  }),
7161
7903
  appearance: new D.MaterialAppearance({
7162
- material: bo(o.sideTexture, o.sideColor, o.sideOpacity, _o.globalStyle.bottomColor, i),
7904
+ material: Ao(o.sideTexture, o.sideColor, o.sideOpacity, Do.globalStyle.bottomColor, i),
7163
7905
  materialSupport: D.MaterialAppearance.MaterialSupport.TEXTURED,
7164
7906
  faceForward: !0,
7165
7907
  renderState: h
@@ -7175,7 +7917,7 @@ var oo = {
7175
7917
  polyline: {
7176
7918
  positions: e,
7177
7919
  width: o.edgeWidth,
7178
- material: yo(o.edgeColor, _o.globalStyle.bottomColor, o.edgeOpacity),
7920
+ material: ko(o.edgeColor, Do.globalStyle.bottomColor, o.edgeOpacity),
7179
7921
  clampToGround: !1
7180
7922
  }
7181
7923
  });
@@ -7244,7 +7986,7 @@ var oo = {
7244
7986
  for (let t of i.excavations) {
7245
7987
  let n = m(t), r = {
7246
7988
  ...n,
7247
- positions: ko(n.positions)
7989
+ positions: zo(n.positions)
7248
7990
  }, i = h(r), o = r.id;
7249
7991
  s.add(o);
7250
7992
  let c = a.get(o);
@@ -7291,7 +8033,7 @@ var oo = {
7291
8033
  restoreDepthTestAgainstTerrain: b,
7292
8034
  getMethods: A
7293
8035
  };
7294
- }, qo = /* @__PURE__ */ s({
8036
+ }, rs = /* @__PURE__ */ s({
7295
8037
  __name: "index",
7296
8038
  props: { config: {} },
7297
8039
  emits: [
@@ -7302,7 +8044,7 @@ var oo = {
7302
8044
  "excavation-error"
7303
8045
  ],
7304
8046
  setup(e, { expose: n, emit: r }) {
7305
- let i = c("cesiumViewer"), a = r, o = e, s = t(() => vo(o.config)), l = () => i?.value, u = () => {
8047
+ let i = c("cesiumViewer"), a = r, o = e, s = t(() => Oo(o.config)), l = () => i?.value, u = () => {
7306
8048
  let e = l();
7307
8049
  return e ? !(e.terrainProvider instanceof D.EllipsoidTerrainProvider) : !1;
7308
8050
  }, d = t(() => JSON.stringify({
@@ -7320,7 +8062,7 @@ var oo = {
7320
8062
  });
7321
8063
  }, b = () => {
7322
8064
  !v() || _.size === 0 || (_.forEach((e) => e()), _.clear());
7323
- }, x = Ko(l, () => s.value, p, () => m, y);
8065
+ }, x = ns(l, () => s.value, p, () => m, y);
7324
8066
  m = x.getMethods();
7325
8067
  let S = async (e) => {
7326
8068
  l() && await x.syncExcavations(e);
@@ -7348,7 +8090,7 @@ var oo = {
7348
8090
  _.clear(), h?.(), h = null, x.clearExcavations(), x.restoreDepthTestAgainstTerrain();
7349
8091
  }), n(m), (e, t) => null;
7350
8092
  }
7351
- }), Jo = {
8093
+ }), is = {
7352
8094
  __name: "index",
7353
8095
  props: {
7354
8096
  config: {
@@ -7373,11 +8115,17 @@ var oo = {
7373
8115
  ...o,
7374
8116
  ...i.config
7375
8117
  })), l = async () => {
7376
- r.value && (u(), a = await D.Cesium3DTileset.fromUrl(s.value.url), ye(r.value, a, i.stackIndex, 0, {
7377
- layerType: "tiles3d",
7378
- groupKey: i.groupKey || s.value.url || String(i.stackIndex),
7379
- subStackIndex: i.subStackIndex
7380
- }), s.value.autoFitToView && r.value.zoomTo(a), s.value.customShader && (a.customShader = customShader));
8118
+ if (r.value) {
8119
+ if (u(), a = await D.Cesium3DTileset.fromUrl(s.value.url), ye(r.value, a, i.stackIndex, 0, {
8120
+ layerType: "tiles3d",
8121
+ groupKey: i.groupKey || s.value.url || String(i.stackIndex),
8122
+ subStackIndex: i.subStackIndex
8123
+ }), s.value.autoFitToView) {
8124
+ let e = s.value.fitDuration;
8125
+ typeof e == "number" ? r.value.flyTo(a, { duration: e }) : r.value.zoomTo(a);
8126
+ }
8127
+ s.value.customShader && (a.customShader = customShader);
8128
+ }
7381
8129
  }, u = () => {
7382
8130
  r.value && (a &&= (r.value.scene.primitives.remove(a), null));
7383
8131
  };
@@ -7401,7 +8149,7 @@ var oo = {
7401
8149
  u();
7402
8150
  }), (e, t) => null;
7403
8151
  }
7404
- }, Yo = {
8152
+ }, as = {
7405
8153
  __name: "index",
7406
8154
  props: { config: {
7407
8155
  type: Object,
@@ -7465,7 +8213,7 @@ var oo = {
7465
8213
  u();
7466
8214
  }), (e, t) => null;
7467
8215
  }
7468
- }, Xo = {
8216
+ }, os = {
7469
8217
  __name: "index",
7470
8218
  props: { config: {
7471
8219
  type: Object,
@@ -7654,7 +8402,7 @@ var oo = {
7654
8402
  b();
7655
8403
  }), (e, t) => null;
7656
8404
  }
7657
- }, Zo = {
8405
+ }, ss = {
7658
8406
  __name: "index",
7659
8407
  props: { config: {
7660
8408
  type: Object,
@@ -7841,7 +8589,7 @@ var oo = {
7841
8589
  b();
7842
8590
  }), (e, t) => null;
7843
8591
  }
7844
- }, Qo = {
8592
+ }, cs = {
7845
8593
  __name: "index",
7846
8594
  props: { config: {
7847
8595
  type: Object,
@@ -8041,16 +8789,16 @@ var oo = {
8041
8789
  b();
8042
8790
  }), (e, t) => null;
8043
8791
  }
8044
- }, $o = { class: "legend-panel__header" }, es = { class: "legend-panel__title" }, ts = { class: "legend-panel__body" }, ns = {
8792
+ }, ls = { class: "legend-panel__header" }, us = { class: "legend-panel__title" }, ds = { class: "legend-panel__body" }, fs = {
8045
8793
  key: 0,
8046
8794
  class: "legend-panel__multiband"
8047
- }, rs = { class: "legend-panel__multiband-labels" }, is = { class: "legend-panel__multiband-label legend-panel__multiband-label--top" }, as = { class: "legend-panel__multiband-label legend-panel__multiband-label--bottom" }, os = {
8795
+ }, ps = { class: "legend-panel__multiband-labels" }, ms = { class: "legend-panel__multiband-label legend-panel__multiband-label--top" }, hs = { class: "legend-panel__multiband-label legend-panel__multiband-label--bottom" }, gs = {
8048
8796
  key: 1,
8049
8797
  class: "legend-panel__list"
8050
- }, ss = {
8798
+ }, _s = {
8051
8799
  key: 0,
8052
8800
  class: "legend-panel__symbol legend-panel__symbol--line"
8053
- }, cs = { class: "legend-panel__label" }, ls = /* @__PURE__ */ s({
8801
+ }, vs = { class: "legend-panel__label" }, ys = /* @__PURE__ */ s({
8054
8802
  __name: "index",
8055
8803
  props: {
8056
8804
  visible: { type: Boolean },
@@ -8136,7 +8884,7 @@ var oo = {
8136
8884
  return s.visible ? (p(), i("div", {
8137
8885
  key: 0,
8138
8886
  class: l(["legend-panel", g.value])
8139
- }, [a("div", $o, [a("span", es, x(v.value), 1), o(f, {
8887
+ }, [a("div", ls, [a("span", us, x(v.value), 1), o(f, {
8140
8888
  text: "",
8141
8889
  size: "small",
8142
8890
  class: "legend-panel__toggle",
@@ -8147,14 +8895,14 @@ var oo = {
8147
8895
  _: 1
8148
8896
  })]),
8149
8897
  _: 1
8150
- })]), a("div", ts, [c[1] ||= a("div", { class: "legend-panel__section-title" }, "图例", -1), S.value && w.value ? (p(), i("div", ns, [a("div", {
8898
+ })]), a("div", ds, [c[1] ||= a("div", { class: "legend-panel__section-title" }, "图例", -1), S.value && w.value ? (p(), i("div", fs, [a("div", {
8151
8899
  class: "legend-panel__multiband-bar",
8152
8900
  style: u(M.value)
8153
- }, null, 4), a("div", rs, [a("div", is, x(w.value.MultibandValueNameTop), 1), a("div", as, x(w.value.MultibandValueNameBot), 1)])])) : D.value.length ? (p(), i("div", os, [(p(!0), i(e, null, _(D.value, (e, t) => (p(), i("div", {
8901
+ }, null, 4), a("div", ps, [a("div", ms, x(w.value.MultibandValueNameTop), 1), a("div", hs, x(w.value.MultibandValueNameBot), 1)])])) : D.value.length ? (p(), i("div", gs, [(p(!0), i(e, null, _(D.value, (e, t) => (p(), i("div", {
8154
8902
  key: R(e, t),
8155
8903
  class: l(["legend-panel__item", { "is-item-hidden": O.value && A(e) }])
8156
8904
  }, [
8157
- P(e) === "line" ? (p(), i("div", ss, [a("span", {
8905
+ P(e) === "line" ? (p(), i("div", _s, [a("span", {
8158
8906
  class: "legend-panel__line-bar",
8159
8907
  style: u(te(e))
8160
8908
  }, null, 4)])) : (p(), i("div", {
@@ -8162,7 +8910,7 @@ var oo = {
8162
8910
  class: l(["legend-panel__symbol", N(e)]),
8163
8911
  style: u(ne(e))
8164
8912
  }, null, 6)),
8165
- a("div", cs, x(e.valueName || "-"), 1),
8913
+ a("div", vs, x(e.valueName || "-"), 1),
8166
8914
  O.value ? (p(), n(m, {
8167
8915
  key: 2,
8168
8916
  content: A(e) ? "显示" : "隐藏",
@@ -8185,8 +8933,8 @@ var oo = {
8185
8933
  }))])], 2)) : r("", !0);
8186
8934
  };
8187
8935
  }
8188
- }), us = (e) => {
8189
- e.component("zzViewer", xe), e.component("zz-viewer", xe), e.component("zzLayerWmts", Fe), e.component("zz-layer-wmts", Fe), e.component("zzLayerXyz", Ie), e.component("zz-layer-xyz", Ie), e.component("zzLayerWms", Le), e.component("zz-layer-wms", Le), e.component("zzLayerZzts", ze), e.component("zz-layer-zzts", ze), e.component("zzLayerZzts3d", La), e.component("zz-layer-zzts3d", La), e.component("zzLayerShpZzts", Ga), e.component("zz-layer-shp-zzts", Ga), e.component("zzLayerZzts3dPoint", oo), e.component("zz-layer-zzts3d-point", oo), e.component("zzLayerZzts3dPointQuery", so), e.component("zz-layer-zzts3d-point-query", so), e.component("zzLayerZzts3dGrid", lo), e.component("zz-layer-zzts3d-grid", lo), e.component("zzLayerZzts3dGridColor", po), e.component("zz-layer-zzts3d-grid-color", po), e.component("zzLayerZzts3dGridQuery", mo), e.component("zz-layer-zzts3d-grid-query", mo), e.component("zzLayerZzts3dGridInterpolation", ho), e.component("zz-layer-zzts3d-grid-interpolation", ho), e.component("zzLayerGeojson", Be), e.component("zz-layer-geojson", Be), e.component("zzLayerMvt", He), e.component("zz-layer-mvt", He), e.component("zzTerrain", go), e.component("zz-terrain", go), e.component("zzTerrainExcavation", qo), e.component("zz-terrain-excavation", qo), e.component("zz3dtiles", Jo), e.component("zz-3dtiles", Jo), e.component("zzGltf", Yo), e.component("zz-gltf", Yo), e.component("zzEntityPoint", Xo), e.component("zz-entity-point", Xo), e.component("zzEntityPolyline", Zo), e.component("zz-entity-polyline", Zo), e.component("zzEntityPolygon", Qo), e.component("zz-entity-polygon", Qo), e.component("zzLegend", ls), e.component("zz-legend", ls);
8936
+ }), bs = (e) => {
8937
+ e.component("zzViewer", xe), e.component("zz-viewer", xe), e.component("zzLayerWmts", Fe), e.component("zz-layer-wmts", Fe), e.component("zzLayerXyz", Ie), e.component("zz-layer-xyz", Ie), e.component("zzLayerWms", Le), e.component("zz-layer-wms", Le), e.component("zzLayerZzts", ze), e.component("zz-layer-zzts", ze), e.component("zzLayerZzts3d", za), e.component("zz-layer-zzts3d", za), e.component("zzLayerShpZzts", Ja), e.component("zz-layer-shp-zzts", Ja), e.component("zzLayerZzts3dPoint", fo), e.component("zz-layer-zzts3d-point", fo), e.component("zzLayerZzts3dPointQuery", po), e.component("zz-layer-zzts3d-point-query", po), e.component("zzLayerZzts3dGrid", ho), e.component("zz-layer-zzts3d-grid", ho), e.component("zzLayerZzts3dGridColor", vo), e.component("zz-layer-zzts3d-grid-color", vo), e.component("zzLayerZzts3dGridQuery", yo), e.component("zz-layer-zzts3d-grid-query", yo), e.component("zzLayerZzts3dGridInterpolation", bo), e.component("zz-layer-zzts3d-grid-interpolation", bo), e.component("zzLayerZzts3dtwintype", To), e.component("zz-layer-zzts3dtwintype", To), e.component("zzLayerGeojson", Be), e.component("zz-layer-geojson", Be), e.component("zzLayerMvt", He), e.component("zz-layer-mvt", He), e.component("zzTerrain", Eo), e.component("zz-terrain", Eo), e.component("zzTerrainExcavation", rs), e.component("zz-terrain-excavation", rs), e.component("zz3dtiles", is), e.component("zz-3dtiles", is), e.component("zzGltf", as), e.component("zz-gltf", as), e.component("zzEntityPoint", os), e.component("zz-entity-point", os), e.component("zzEntityPolyline", ss), e.component("zz-entity-polyline", ss), e.component("zzEntityPolygon", cs), e.component("zz-entity-polygon", cs), e.component("zzLegend", ys), e.component("zz-legend", ys);
8190
8938
  };
8191
8939
  //#endregion
8192
- export { R as LAYER_TYPE_BAND, ve as addImageryLayerWithStackIndex, ye as addPrimitiveWithStackIndex, he as applyImageryStackIndex, _e as applyPrimitiveStackIndex, us as default, oe as moveImageryLayerToIndex, ge as moveImageryLayersToStackIndex, ce as movePrimitiveToIndex, pe as scheduleImageryLayerStackSync, me as schedulePrimitiveStackSync, le as syncImageryLayerStack, ue as syncPrimitiveStack, B as tagImageryLayerStackMeta, ae as tagPrimitiveStackMeta, Jo as zz3dtiles, Xo as zzEntityPoint, Qo as zzEntityPolygon, Zo as zzEntityPolyline, Yo as zzGltf, Be as zzLayerGeojson, He as zzLayerMvt, Ga as zzLayerShpZzts, Le as zzLayerWms, Fe as zzLayerWmts, Ie as zzLayerXyz, ze as zzLayerZzts, ls as zzLegendPanel, go as zzTerrain, qo as zzTerrainExcavation, xe as zzViewer };
8940
+ export { R as LAYER_TYPE_BAND, ve as addImageryLayerWithStackIndex, ye as addPrimitiveWithStackIndex, he as applyImageryStackIndex, _e as applyPrimitiveStackIndex, bs as default, oe as moveImageryLayerToIndex, ge as moveImageryLayersToStackIndex, ce as movePrimitiveToIndex, pe as scheduleImageryLayerStackSync, me as schedulePrimitiveStackSync, le as syncImageryLayerStack, ue as syncPrimitiveStack, B as tagImageryLayerStackMeta, ae as tagPrimitiveStackMeta, is as zz3dtiles, os as zzEntityPoint, cs as zzEntityPolygon, ss as zzEntityPolyline, as as zzGltf, Be as zzLayerGeojson, He as zzLayerMvt, Ja as zzLayerShpZzts, Le as zzLayerWms, Fe as zzLayerWmts, Ie as zzLayerXyz, ze as zzLayerZzts, ys as zzLegendPanel, Eo as zzTerrain, rs as zzTerrainExcavation, xe as zzViewer };