@xingm/vmap-cesium-toolbar 0.0.2-alpha.12 → 0.0.2-alpha.13
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/hooks/useDrawHelper.d.ts +5 -0
- package/dist/index.d.ts +31 -8
- package/dist/index.js +207 -159
- package/dist/index.js.map +1 -1
- package/dist/index.umd.js +6 -6
- package/dist/index.umd.js.map +1 -1
- package/dist/libs/CesiumMapDraw.d.ts +4 -0
- package/dist/libs/drawHelper/BaseDraw.d.ts +4 -0
- package/dist/package.json +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -151,13 +151,29 @@ class L {
|
|
|
151
151
|
* 添加一个点到临时位置数组并创建点实体
|
|
152
152
|
*/
|
|
153
153
|
addPoint(e) {
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
154
|
+
if (!e || !Number.isFinite(e.x) || !Number.isFinite(e.y) || !Number.isFinite(e.z))
|
|
155
|
+
return;
|
|
156
|
+
let t;
|
|
157
|
+
try {
|
|
158
|
+
t = e.clone();
|
|
159
|
+
} catch {
|
|
160
|
+
return;
|
|
161
|
+
}
|
|
162
|
+
let i;
|
|
163
|
+
try {
|
|
164
|
+
i = n.Cartographic.fromCartesian(t);
|
|
165
|
+
} catch {
|
|
166
|
+
return;
|
|
167
|
+
}
|
|
168
|
+
if (!Number.isFinite(i.longitude) || !Number.isFinite(i.latitude))
|
|
169
|
+
return;
|
|
170
|
+
this.tempPositions.push(t);
|
|
171
|
+
const r = n.Cartesian3.fromRadians(
|
|
172
|
+
i.longitude,
|
|
173
|
+
i.latitude,
|
|
174
|
+
(i.height || 0) + this.offsetHeight
|
|
175
|
+
), o = this.entities.add({
|
|
176
|
+
position: r,
|
|
161
177
|
point: {
|
|
162
178
|
pixelSize: 8,
|
|
163
179
|
color: n.Color.RED,
|
|
@@ -168,7 +184,7 @@ class L {
|
|
|
168
184
|
disableDepthTestDistance: Number.POSITIVE_INFINITY
|
|
169
185
|
}
|
|
170
186
|
});
|
|
171
|
-
this.tempEntities.push(
|
|
187
|
+
this.tempEntities.push(o);
|
|
172
188
|
}
|
|
173
189
|
/**
|
|
174
190
|
* 创建总长/面积标签图片
|
|
@@ -474,15 +490,15 @@ class V extends L {
|
|
|
474
490
|
h.latitude,
|
|
475
491
|
(h.height || 0) + this.offsetHeight
|
|
476
492
|
));
|
|
477
|
-
const m = r % 2 === 0 ? -25 : 25,
|
|
493
|
+
const m = r % 2 === 0 ? -25 : 25, b = j(a);
|
|
478
494
|
if (r < this.currentSegmentLabels.length && this.currentSegmentLabels[r].billboard) {
|
|
479
495
|
const g = this.currentSegmentLabels[r];
|
|
480
|
-
if (g.position = new n.ConstantPositionProperty(u), g.billboard.pixelOffset = new n.ConstantProperty(new n.Cartesian2(0, m)), g._groundPosition = d, g._segmentText !==
|
|
481
|
-
const f = this.createSegmentLengthBillboardImage(
|
|
482
|
-
g.billboard.image = new n.ConstantProperty(f), g._segmentText =
|
|
496
|
+
if (g.position = new n.ConstantPositionProperty(u), g.billboard.pixelOffset = new n.ConstantProperty(new n.Cartesian2(0, m)), g._groundPosition = d, g._segmentText !== b) {
|
|
497
|
+
const f = this.createSegmentLengthBillboardImage(b);
|
|
498
|
+
g.billboard.image = new n.ConstantProperty(f), g._segmentText = b;
|
|
483
499
|
}
|
|
484
500
|
} else {
|
|
485
|
-
const g = this.createSegmentLengthBillboardImage(
|
|
501
|
+
const g = this.createSegmentLengthBillboardImage(b), w = this.entities.add({
|
|
486
502
|
position: u,
|
|
487
503
|
billboard: {
|
|
488
504
|
image: g,
|
|
@@ -496,7 +512,7 @@ class V extends L {
|
|
|
496
512
|
disableDepthTestDistance: new n.ConstantProperty(Number.POSITIVE_INFINITY)
|
|
497
513
|
}
|
|
498
514
|
});
|
|
499
|
-
|
|
515
|
+
w._segmentText = b, w._groundPosition = d, this.currentSegmentLabels.push(w), this.tempLabelEntities.push(w);
|
|
500
516
|
}
|
|
501
517
|
} else if (r < this.currentSegmentLabels.length) {
|
|
502
518
|
const l = this.currentSegmentLabels[r];
|
|
@@ -639,21 +655,21 @@ class K extends L {
|
|
|
639
655
|
return;
|
|
640
656
|
}
|
|
641
657
|
const s = o.map((g) => {
|
|
642
|
-
const
|
|
658
|
+
const w = g.height || 0, f = this.offsetHeight > 0 ? this.offsetHeight : 0.1;
|
|
643
659
|
return n.Cartesian3.fromRadians(
|
|
644
660
|
g.longitude,
|
|
645
661
|
g.latitude,
|
|
646
|
-
|
|
662
|
+
w + f
|
|
647
663
|
);
|
|
648
664
|
}), a = n.HeightReference.NONE, l = this.drawOptions?.fillColor ? this.resolveColor(this.drawOptions.fillColor) : n.Color.LIGHTGREEN.withAlpha(0.3), h = this.drawOptions?.strokeColor ? this.resolveColor(this.drawOptions.strokeColor) : this.drawOptions?.outlineColor ? this.resolveColor(this.drawOptions.outlineColor) : n.Color.LIGHTGREEN, d = this.drawOptions?.strokeWidth ?? this.drawOptions?.outlineWidth ?? 2, u = this.tempEntities.filter((g) => !!g?.polygon), m = this.tempEntities.filter((g) => {
|
|
649
|
-
const
|
|
650
|
-
return !!
|
|
665
|
+
const w = g;
|
|
666
|
+
return !!w?.polyline && !w?.point && !w?.polygon;
|
|
651
667
|
});
|
|
652
668
|
(u.length > 1 || m.length > 1) && ([...u, ...m].forEach((g) => {
|
|
653
669
|
this.entities.remove(g);
|
|
654
670
|
}), this.tempEntities = this.tempEntities.filter((g) => {
|
|
655
|
-
const
|
|
656
|
-
return
|
|
671
|
+
const w = g;
|
|
672
|
+
return w?.point ? !0 : !(w?.polygon || w?.polyline && !w?.polygon);
|
|
657
673
|
}), this.currentPolygonEntity = null, this.currentBorderEntity = null), this.currentPolygonEntity && this.tempEntities.indexOf(this.currentPolygonEntity) === -1 && (this.currentPolygonEntity = null), this.currentBorderEntity && this.tempEntities.indexOf(this.currentBorderEntity) === -1 && (this.currentBorderEntity = null), this.currentPolygonEntity ? (this.currentPolygonEntity.polygon.hierarchy = new n.ConstantProperty(
|
|
658
674
|
new n.PolygonHierarchy(s)
|
|
659
675
|
), this.currentPolygonEntity.polygon.heightReference = new n.ConstantProperty(a), this.currentPolygonEntity.polygon.material = new n.ColorMaterialProperty(l), this.currentPolygonEntity.polygon.outline = new n.ConstantProperty(!1)) : (this.currentPolygonEntity = this.entities.add({
|
|
@@ -664,10 +680,10 @@ class K extends L {
|
|
|
664
680
|
heightReference: a
|
|
665
681
|
}
|
|
666
682
|
}), this.tempEntities.push(this.currentPolygonEntity));
|
|
667
|
-
const
|
|
668
|
-
|
|
683
|
+
const b = s.slice();
|
|
684
|
+
b.length >= 2 && b.push(s[0]), this.currentBorderEntity && this.currentBorderEntity.polyline ? (this.currentBorderEntity.polyline.positions = new n.ConstantProperty(b), this.currentBorderEntity.polyline.width = new n.ConstantProperty(d), this.currentBorderEntity.polyline.material = new n.ColorMaterialProperty(h), this.currentBorderEntity.polyline.clampToGround = new n.ConstantProperty(!1)) : (this.currentBorderEntity = this.entities.add({
|
|
669
685
|
polyline: {
|
|
670
|
-
positions: new n.ConstantProperty(
|
|
686
|
+
positions: new n.ConstantProperty(b),
|
|
671
687
|
width: d,
|
|
672
688
|
material: new n.ColorMaterialProperty(h),
|
|
673
689
|
clampToGround: !1
|
|
@@ -708,8 +724,8 @@ class K extends L {
|
|
|
708
724
|
let r = null, o = null;
|
|
709
725
|
const s = this.drawOptions?.fillColor ? this.resolveColor(this.drawOptions.fillColor) : n.Color.LIGHTGREEN.withAlpha(0.3), a = this.drawOptions?.strokeColor ? this.resolveColor(this.drawOptions.strokeColor) : this.drawOptions?.outlineColor ? this.resolveColor(this.drawOptions.outlineColor) : n.Color.LIGHTGREEN, l = this.drawOptions?.strokeWidth ?? this.drawOptions?.outlineWidth ?? 2;
|
|
710
726
|
if (this.offsetHeight > 0) {
|
|
711
|
-
const u = i.map((
|
|
712
|
-
const g = n.Cartographic.fromCartesian(
|
|
727
|
+
const u = i.map((b) => {
|
|
728
|
+
const g = n.Cartographic.fromCartesian(b);
|
|
713
729
|
return n.Cartesian3.fromRadians(
|
|
714
730
|
g.longitude,
|
|
715
731
|
g.latitude,
|
|
@@ -755,19 +771,19 @@ class K extends L {
|
|
|
755
771
|
}), r._groundPositions = i, r && (r._drawOptions = this.drawOptions, r._drawType = this.getDrawType(), this.drawOptions?.onClick && (r._onClick = this.drawOptions.onClick), o && (r._borderEntity = o));
|
|
756
772
|
}
|
|
757
773
|
const h = H(i, this.scene.globe.ellipsoid);
|
|
758
|
-
if (h > 0) {
|
|
759
|
-
const u = J(i), m = n.Cartographic.fromCartesian(u),
|
|
774
|
+
if (h > 0 && this.drawOptions?.showAreaLabel !== !1) {
|
|
775
|
+
const u = J(i), m = n.Cartographic.fromCartesian(u), b = n.Cartesian3.fromRadians(
|
|
760
776
|
m.longitude,
|
|
761
777
|
m.latitude,
|
|
762
778
|
m.height || 0
|
|
763
779
|
);
|
|
764
|
-
let g =
|
|
780
|
+
let g = b;
|
|
765
781
|
this.offsetHeight > 0 && (g = n.Cartesian3.fromRadians(
|
|
766
782
|
m.longitude,
|
|
767
783
|
m.latitude,
|
|
768
784
|
(m.height || 0) + this.offsetHeight
|
|
769
785
|
));
|
|
770
|
-
const
|
|
786
|
+
const w = `面积: ${R(h)}`, f = this.createTotalLengthBillboardImage(w), p = this.entities.add({
|
|
771
787
|
position: g,
|
|
772
788
|
billboard: {
|
|
773
789
|
image: f,
|
|
@@ -781,7 +797,9 @@ class K extends L {
|
|
|
781
797
|
disableDepthTestDistance: new n.ConstantProperty(Number.POSITIVE_INFINITY)
|
|
782
798
|
}
|
|
783
799
|
});
|
|
784
|
-
|
|
800
|
+
p._groundPosition = b, p._ownerEntityId = r.id;
|
|
801
|
+
const C = r;
|
|
802
|
+
C._labelEntities = [...C._labelEntities || [], p], this.tempLabelEntities.push(p);
|
|
785
803
|
}
|
|
786
804
|
this.tempEntities.forEach((u) => {
|
|
787
805
|
u && this.entities.remove(u);
|
|
@@ -860,11 +878,11 @@ class _ extends L {
|
|
|
860
878
|
if (e.length < 2)
|
|
861
879
|
return this.restoreRequestRenderModeIfNeeded(), null;
|
|
862
880
|
const t = e.map((m) => {
|
|
863
|
-
const
|
|
881
|
+
const b = n.Cartographic.fromCartesian(m);
|
|
864
882
|
return n.Cartesian3.fromRadians(
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
883
|
+
b.longitude,
|
|
884
|
+
b.latitude,
|
|
885
|
+
b.height || 0
|
|
868
886
|
);
|
|
869
887
|
}), i = W(t[0], t[1]);
|
|
870
888
|
let r = null;
|
|
@@ -892,19 +910,19 @@ class _ extends L {
|
|
|
892
910
|
}
|
|
893
911
|
}), r._groundRectangle = i), r && (r._drawOptions = this.drawOptions, r._drawType = this.getDrawType(), this.drawOptions?.onClick && (r._onClick = this.drawOptions.onClick));
|
|
894
912
|
const l = q(i);
|
|
895
|
-
if (l > 0) {
|
|
896
|
-
const m = n.Rectangle.center(i),
|
|
913
|
+
if (l > 0 && this.drawOptions?.showAreaLabel !== !1) {
|
|
914
|
+
const m = n.Rectangle.center(i), b = n.Cartesian3.fromRadians(
|
|
897
915
|
m.longitude,
|
|
898
916
|
m.latitude,
|
|
899
917
|
0
|
|
900
918
|
);
|
|
901
|
-
let g =
|
|
919
|
+
let g = b;
|
|
902
920
|
this.offsetHeight > 0 && (g = n.Cartesian3.fromRadians(
|
|
903
921
|
m.longitude,
|
|
904
922
|
m.latitude,
|
|
905
923
|
this.offsetHeight
|
|
906
924
|
));
|
|
907
|
-
const
|
|
925
|
+
const w = `面积: ${R(l)}`, f = this.createTotalLengthBillboardImage(w), p = this.entities.add({
|
|
908
926
|
position: g,
|
|
909
927
|
billboard: {
|
|
910
928
|
image: f,
|
|
@@ -918,15 +936,17 @@ class _ extends L {
|
|
|
918
936
|
disableDepthTestDistance: new n.ConstantProperty(Number.POSITIVE_INFINITY)
|
|
919
937
|
}
|
|
920
938
|
});
|
|
921
|
-
|
|
939
|
+
p._groundPosition = b, p._ownerEntityId = r.id;
|
|
940
|
+
const C = r;
|
|
941
|
+
C._labelEntities = [...C._labelEntities || [], p], this.tempLabelEntities.push(p);
|
|
922
942
|
}
|
|
923
943
|
this.tempEntities.forEach((m) => {
|
|
924
944
|
m && this.entities.remove(m);
|
|
925
945
|
}), this.tempEntities = [], this.tempPositions = [], this.currentRectangleEntity = null, this.originalDepthTestAgainstTerrain !== null && (this.scene.globe.depthTestAgainstTerrain = this.originalDepthTestAgainstTerrain, this.originalDepthTestAgainstTerrain = null);
|
|
926
946
|
const h = n.Rectangle.subsample(i, this.scene.globe.ellipsoid), d = (() => {
|
|
927
947
|
if (h.length > 1) {
|
|
928
|
-
const m = h[0],
|
|
929
|
-
if (n.Cartesian3.equalsEpsilon(m,
|
|
948
|
+
const m = h[0], b = h[h.length - 1];
|
|
949
|
+
if (n.Cartesian3.equalsEpsilon(m, b, n.Math.EPSILON9))
|
|
930
950
|
return h.slice(0, h.length - 1);
|
|
931
951
|
}
|
|
932
952
|
return h;
|
|
@@ -1004,7 +1024,7 @@ class $ extends L {
|
|
|
1004
1024
|
heightReference: n.HeightReference.NONE
|
|
1005
1025
|
}
|
|
1006
1026
|
}), this.tempEntities.push(this.currentCircleEntity)), d > 1) {
|
|
1007
|
-
const u = n.Cartographic.fromCartesian(s), m = u.height || 0,
|
|
1027
|
+
const u = n.Cartographic.fromCartesian(s), m = u.height || 0, b = 0.1, g = i, w = this.generateCirclePositions(u, g, m + b), f = [...w, w[0]];
|
|
1008
1028
|
this.currentBorderEntity && this.currentBorderEntity.polyline ? (this.currentBorderEntity.polyline.positions = new n.ConstantProperty(f), this.currentBorderEntity.polyline.material = new n.ColorMaterialProperty(h), this.currentBorderEntity.polyline.width = new n.ConstantProperty(d), this.currentBorderEntity.polyline.clampToGround = new n.ConstantProperty(!1)) : (this.currentBorderEntity = this.entities.add({
|
|
1009
1029
|
polyline: {
|
|
1010
1030
|
positions: f,
|
|
@@ -1037,8 +1057,8 @@ class $ extends L {
|
|
|
1037
1057
|
else if (this.currentCircleEntity) {
|
|
1038
1058
|
const f = this.currentCircleEntity.ellipse;
|
|
1039
1059
|
if (f) {
|
|
1040
|
-
const
|
|
1041
|
-
r = typeof
|
|
1060
|
+
const p = f.semiMajorAxis?.getValue(n.JulianDate.now());
|
|
1061
|
+
r = typeof p == "number" ? p : 0;
|
|
1042
1062
|
}
|
|
1043
1063
|
}
|
|
1044
1064
|
if (r < 1)
|
|
@@ -1062,7 +1082,7 @@ class $ extends L {
|
|
|
1062
1082
|
heightReference: n.HeightReference.NONE
|
|
1063
1083
|
}
|
|
1064
1084
|
});
|
|
1065
|
-
const f = n.Cartographic.fromCartesian(s),
|
|
1085
|
+
const f = n.Cartographic.fromCartesian(s), p = f.height || 0, C = 0.1, v = r, y = this.generateCirclePositions(f, v, p + C), x = [...y, y[0]], G = this.entities.add({
|
|
1066
1086
|
name: "绘制的圆-边框",
|
|
1067
1087
|
polyline: {
|
|
1068
1088
|
positions: x,
|
|
@@ -1088,11 +1108,11 @@ class $ extends L {
|
|
|
1088
1108
|
});
|
|
1089
1109
|
o._groundPosition = i, o._radius = r, o && (o._drawOptions = this.drawOptions, o._drawType = this.getDrawType(), this.drawOptions?.onClick && (o._onClick = this.drawOptions.onClick));
|
|
1090
1110
|
const d = Math.PI * r * r / 1e6;
|
|
1091
|
-
if (d > 0) {
|
|
1092
|
-
const f = `面积: ${R(d)}`,
|
|
1111
|
+
if (d > 0 && this.drawOptions?.showAreaLabel !== !1) {
|
|
1112
|
+
const f = `面积: ${R(d)}`, p = this.createTotalLengthBillboardImage(f), C = this.entities.add({
|
|
1093
1113
|
position: s,
|
|
1094
1114
|
billboard: {
|
|
1095
|
-
image:
|
|
1115
|
+
image: p,
|
|
1096
1116
|
pixelOffset: new n.ConstantProperty(new n.Cartesian2(0, -25)),
|
|
1097
1117
|
heightReference: new n.ConstantProperty(
|
|
1098
1118
|
this.offsetHeight > 0 ? n.HeightReference.RELATIVE_TO_GROUND : n.HeightReference.NONE
|
|
@@ -1103,9 +1123,11 @@ class $ extends L {
|
|
|
1103
1123
|
disableDepthTestDistance: new n.ConstantProperty(Number.POSITIVE_INFINITY)
|
|
1104
1124
|
}
|
|
1105
1125
|
});
|
|
1106
|
-
C._groundPosition = i,
|
|
1126
|
+
C._groundPosition = i, C._ownerEntityId = o.id;
|
|
1127
|
+
const v = o;
|
|
1128
|
+
v._labelEntities = [...v._labelEntities || [], C], this.tempLabelEntities.push(C);
|
|
1107
1129
|
}
|
|
1108
|
-
this.tempEntities.forEach((f,
|
|
1130
|
+
this.tempEntities.forEach((f, p) => {
|
|
1109
1131
|
f && this.entities.remove(f);
|
|
1110
1132
|
}), this.tempEntities = [], this.tempPositions = [], this.currentCircleEntity = null, this.currentBorderEntity = null, this.centerPosition = null, this.originalDepthTestAgainstTerrain !== null && (this.scene.globe.depthTestAgainstTerrain = this.originalDepthTestAgainstTerrain, this.originalDepthTestAgainstTerrain = null);
|
|
1111
1133
|
const u = r / this.scene.globe.ellipsoid.maximumRadius, m = new n.Rectangle(
|
|
@@ -1113,20 +1135,20 @@ class $ extends L {
|
|
|
1113
1135
|
t.latitude - u,
|
|
1114
1136
|
t.longitude + u,
|
|
1115
1137
|
t.latitude + u
|
|
1116
|
-
),
|
|
1117
|
-
if (
|
|
1118
|
-
const f =
|
|
1119
|
-
if (n.Cartesian3.equalsEpsilon(f,
|
|
1120
|
-
return
|
|
1138
|
+
), b = n.Rectangle.subsample(m, this.scene.globe.ellipsoid), g = (() => {
|
|
1139
|
+
if (b.length > 1) {
|
|
1140
|
+
const f = b[0], p = b[b.length - 1];
|
|
1141
|
+
if (n.Cartesian3.equalsEpsilon(f, p, n.Math.EPSILON9))
|
|
1142
|
+
return b.slice(0, b.length - 1);
|
|
1121
1143
|
}
|
|
1122
|
-
return
|
|
1123
|
-
})(),
|
|
1144
|
+
return b;
|
|
1145
|
+
})(), w = {
|
|
1124
1146
|
entity: o,
|
|
1125
1147
|
type: "circle",
|
|
1126
1148
|
positions: g,
|
|
1127
1149
|
areaKm2: d
|
|
1128
1150
|
};
|
|
1129
|
-
return this.callbacks.onMeasureComplete && this.callbacks.onMeasureComplete(
|
|
1151
|
+
return this.callbacks.onMeasureComplete && this.callbacks.onMeasureComplete(w), this.restoreRequestRenderModeIfNeeded(), this.callbacks.onDrawEnd && this.callbacks.onDrawEnd(o, w), w;
|
|
1130
1152
|
}
|
|
1131
1153
|
/**
|
|
1132
1154
|
* 获取绘制类型
|
|
@@ -1140,7 +1162,7 @@ class $ extends L {
|
|
|
1140
1162
|
generateCirclePositions(e, t, i, r = 128) {
|
|
1141
1163
|
const s = e.latitude, a = e.longitude, l = t / 6378137, h = [];
|
|
1142
1164
|
for (let d = 0; d < r; d++) {
|
|
1143
|
-
const u = d / r * n.Math.TWO_PI, m = Math.sin(s),
|
|
1165
|
+
const u = d / r * n.Math.TWO_PI, m = Math.sin(s), b = Math.cos(s), g = Math.sin(l), w = Math.cos(l), f = Math.sin(u), p = Math.cos(u), C = Math.asin(m * w + b * g * p), v = a + Math.atan2(f * g * b, w - m * Math.sin(C));
|
|
1144
1166
|
h.push(n.Cartesian3.fromRadians(v, C, i));
|
|
1145
1167
|
}
|
|
1146
1168
|
return h;
|
|
@@ -1590,10 +1612,36 @@ class D {
|
|
|
1590
1612
|
removeEntity(e) {
|
|
1591
1613
|
const t = this.finishedEntities.indexOf(e);
|
|
1592
1614
|
if (t > -1) {
|
|
1593
|
-
const i = e.
|
|
1594
|
-
|
|
1615
|
+
const i = e, r = i._labelEntities;
|
|
1616
|
+
if (r && r.length > 0)
|
|
1617
|
+
r.forEach((s) => {
|
|
1618
|
+
try {
|
|
1619
|
+
s && this.entities.remove(s);
|
|
1620
|
+
} catch {
|
|
1621
|
+
}
|
|
1622
|
+
}), this.finishedLabelEntities = this.finishedLabelEntities.filter((s) => !r.includes(s)), i._labelEntities = [];
|
|
1623
|
+
else {
|
|
1624
|
+
const s = e.id;
|
|
1625
|
+
if (s) {
|
|
1626
|
+
const a = this.finishedLabelEntities.filter((l) => l?._ownerEntityId === s);
|
|
1627
|
+
a.forEach((l) => {
|
|
1628
|
+
try {
|
|
1629
|
+
this.entities.remove(l);
|
|
1630
|
+
} catch {
|
|
1631
|
+
}
|
|
1632
|
+
}), a.length > 0 && (this.finishedLabelEntities = this.finishedLabelEntities.filter((l) => l?._ownerEntityId !== s));
|
|
1633
|
+
}
|
|
1634
|
+
}
|
|
1635
|
+
const o = e._borderEntity;
|
|
1636
|
+
o && this.entities.remove(o), this.entities.remove(e), this.finishedEntities.splice(t, 1), this.onEntityRemovedCallback && this.onEntityRemovedCallback(e);
|
|
1595
1637
|
}
|
|
1596
1638
|
}
|
|
1639
|
+
/**
|
|
1640
|
+
* 获取某个绘制实体关联的标签实体(例如面积标签)
|
|
1641
|
+
*/
|
|
1642
|
+
getEntityLabelEntities(e) {
|
|
1643
|
+
return [...e?._labelEntities || []];
|
|
1644
|
+
}
|
|
1597
1645
|
/**
|
|
1598
1646
|
* 获取所有已完成的实体
|
|
1599
1647
|
* @returns 实体数组
|
|
@@ -1885,22 +1933,22 @@ class te {
|
|
|
1885
1933
|
const g = t.globe.pick(h, t);
|
|
1886
1934
|
n.defined(g) && (l = n.Cartographic.fromCartesian(g));
|
|
1887
1935
|
}
|
|
1888
|
-
const d = i.positionCartographic.height, u = i.heading, m = i.pitch,
|
|
1936
|
+
const d = i.positionCartographic.height, u = i.heading, m = i.pitch, b = i.roll;
|
|
1889
1937
|
if (t.mode = o, this.onSceneModeChanged && this.onSceneModeChanged(), l) {
|
|
1890
|
-
const g = l.longitude,
|
|
1938
|
+
const g = l.longitude, w = l.latitude;
|
|
1891
1939
|
o === n.SceneMode.SCENE2D ? i.setView({
|
|
1892
|
-
destination: n.Cartesian3.fromRadians(g,
|
|
1940
|
+
destination: n.Cartesian3.fromRadians(g, w, d),
|
|
1893
1941
|
orientation: {
|
|
1894
1942
|
heading: 0,
|
|
1895
1943
|
pitch: -Math.PI / 2,
|
|
1896
1944
|
roll: 0
|
|
1897
1945
|
}
|
|
1898
1946
|
}) : i.setView({
|
|
1899
|
-
destination: n.Cartesian3.fromRadians(g,
|
|
1947
|
+
destination: n.Cartesian3.fromRadians(g, w, d),
|
|
1900
1948
|
orientation: {
|
|
1901
1949
|
heading: u,
|
|
1902
1950
|
pitch: m,
|
|
1903
|
-
roll:
|
|
1951
|
+
roll: b
|
|
1904
1952
|
}
|
|
1905
1953
|
});
|
|
1906
1954
|
}
|
|
@@ -2057,13 +2105,13 @@ class ae {
|
|
|
2057
2105
|
`, r.appendChild(o), r.appendChild(s), this.toolbarElement.insertBefore(r, e), this.searchContainer = r;
|
|
2058
2106
|
const a = r.getBoundingClientRect(), l = window.innerHeight;
|
|
2059
2107
|
if (a.bottom > l) {
|
|
2060
|
-
const f = a.bottom - l,
|
|
2108
|
+
const f = a.bottom - l, p = parseFloat(r.style.top || "0"), C = Math.max(0, p - f);
|
|
2061
2109
|
r.style.top = `${C}px`;
|
|
2062
2110
|
}
|
|
2063
2111
|
const h = r.getBoundingClientRect();
|
|
2064
2112
|
if (h.top < 0) {
|
|
2065
|
-
const f = -h.top,
|
|
2066
|
-
r.style.top = `${
|
|
2113
|
+
const f = -h.top, p = parseFloat(r.style.top || "0");
|
|
2114
|
+
r.style.top = `${p + f}px`;
|
|
2067
2115
|
}
|
|
2068
2116
|
let d;
|
|
2069
2117
|
o.addEventListener("input", () => {
|
|
@@ -2080,42 +2128,42 @@ class ae {
|
|
|
2080
2128
|
d = setTimeout(async () => {
|
|
2081
2129
|
if (this.searchCallback?.onSearch)
|
|
2082
2130
|
try {
|
|
2083
|
-
const
|
|
2084
|
-
this.displaySearchResults(
|
|
2085
|
-
} catch (
|
|
2086
|
-
console.error("搜索失败:",
|
|
2131
|
+
const p = await this.searchCallback.onSearch(f);
|
|
2132
|
+
this.displaySearchResults(p, s);
|
|
2133
|
+
} catch (p) {
|
|
2134
|
+
console.error("搜索失败:", p), s.innerHTML = '<div style="padding: 8px; color: #666;">搜索失败</div>';
|
|
2087
2135
|
}
|
|
2088
2136
|
else
|
|
2089
2137
|
try {
|
|
2090
|
-
const
|
|
2091
|
-
this.displaySearchResults(
|
|
2092
|
-
} catch (
|
|
2093
|
-
console.error("默认搜索失败:",
|
|
2138
|
+
const p = await this.performDefaultSearch(f);
|
|
2139
|
+
this.displaySearchResults(p, s);
|
|
2140
|
+
} catch (p) {
|
|
2141
|
+
console.error("默认搜索失败:", p), s.innerHTML = '<div style="padding: 8px; color: #666;">搜索失败</div>';
|
|
2094
2142
|
}
|
|
2095
2143
|
}, 300);
|
|
2096
2144
|
});
|
|
2097
2145
|
let u;
|
|
2098
2146
|
const m = (f) => {
|
|
2099
|
-
const
|
|
2100
|
-
if (
|
|
2101
|
-
clearTimeout(u), this.closeSearchContainer(), r.removeEventListener("mouseleave", m), r.removeEventListener("mouseenter",
|
|
2147
|
+
const p = f.relatedTarget;
|
|
2148
|
+
if (p && (p.closest(".cesium-toolbar-button") !== null || p.closest(".cesium-map-toolbar") !== null)) {
|
|
2149
|
+
clearTimeout(u), this.closeSearchContainer(), r.removeEventListener("mouseleave", m), r.removeEventListener("mouseenter", b), o.removeEventListener("blur", g);
|
|
2102
2150
|
return;
|
|
2103
2151
|
}
|
|
2104
2152
|
u = setTimeout(() => {
|
|
2105
2153
|
const v = r.matches(":hover"), y = e.matches(":hover"), x = this.toolbarElement.matches(":hover"), G = document.activeElement === o;
|
|
2106
|
-
!v && !y && !x && !G && (this.closeSearchContainer(), r.removeEventListener("mouseleave", m), r.removeEventListener("mouseenter",
|
|
2154
|
+
!v && !y && !x && !G && (this.closeSearchContainer(), r.removeEventListener("mouseleave", m), r.removeEventListener("mouseenter", b), o.removeEventListener("blur", g));
|
|
2107
2155
|
}, 150);
|
|
2108
|
-
},
|
|
2156
|
+
}, b = () => {
|
|
2109
2157
|
clearTimeout(u);
|
|
2110
2158
|
}, g = () => {
|
|
2111
2159
|
setTimeout(() => {
|
|
2112
|
-
const f = r.matches(":hover"),
|
|
2113
|
-
document.activeElement !== o && !f && !
|
|
2160
|
+
const f = r.matches(":hover"), p = e.matches(":hover"), C = this.toolbarElement.matches(":hover");
|
|
2161
|
+
document.activeElement !== o && !f && !p && !C && (this.closeSearchContainer(), r.removeEventListener("mouseleave", m), r.removeEventListener("mouseenter", b), o.removeEventListener("blur", g));
|
|
2114
2162
|
}, 200);
|
|
2115
|
-
},
|
|
2116
|
-
f.key === "Escape" && (this.closeSearchContainer(), r.removeEventListener("mouseleave", m), r.removeEventListener("mouseenter",
|
|
2163
|
+
}, w = (f) => {
|
|
2164
|
+
f.key === "Escape" && (this.closeSearchContainer(), r.removeEventListener("mouseleave", m), r.removeEventListener("mouseenter", b), o.removeEventListener("blur", g), document.removeEventListener("keydown", w));
|
|
2117
2165
|
};
|
|
2118
|
-
r.addEventListener("mouseleave", m), r.addEventListener("mouseenter",
|
|
2166
|
+
r.addEventListener("mouseleave", m), r.addEventListener("mouseenter", b), o.addEventListener("blur", g), document.addEventListener("keydown", w), setTimeout(() => {
|
|
2119
2167
|
o.focus();
|
|
2120
2168
|
}, 100);
|
|
2121
2169
|
}
|
|
@@ -2569,13 +2617,13 @@ class ue {
|
|
|
2569
2617
|
try {
|
|
2570
2618
|
const a = this.viewer.scene.mode === n.SceneMode.SCENE3D, l = o.extrudedHeight, h = o.height, d = typeof l == "number" ? l : l?.getValue(n.JulianDate.now()), u = typeof h == "number" ? h : h?.getValue(n.JulianDate.now()), m = d ?? u ?? 0;
|
|
2571
2619
|
if (a && m > 0) {
|
|
2572
|
-
const
|
|
2573
|
-
const f = n.Cartographic.fromCartesian(
|
|
2620
|
+
const b = r.map((w) => {
|
|
2621
|
+
const f = n.Cartographic.fromCartesian(w);
|
|
2574
2622
|
return n.Cartesian3.fromRadians(f.longitude, f.latitude, m);
|
|
2575
2623
|
}), g = this.viewer.entities.add({
|
|
2576
2624
|
name: `${t.name}_top_outline`,
|
|
2577
2625
|
polyline: {
|
|
2578
|
-
positions:
|
|
2626
|
+
positions: b,
|
|
2579
2627
|
width: 2,
|
|
2580
2628
|
material: n.Color.RED,
|
|
2581
2629
|
clampToGround: !1
|
|
@@ -3980,35 +4028,35 @@ class Me {
|
|
|
3980
4028
|
} catch {
|
|
3981
4029
|
}
|
|
3982
4030
|
r.pixelOffset && (a += r.pixelOffset.x, l -= r.pixelOffset.y);
|
|
3983
|
-
const u = this.container.getBoundingClientRect(), m = u.width,
|
|
4031
|
+
const u = this.container.getBoundingClientRect(), m = u.width, b = u.height;
|
|
3984
4032
|
i.style.visibility = "hidden", i.style.display = "block";
|
|
3985
|
-
const g = i.getBoundingClientRect(),
|
|
4033
|
+
const g = i.getBoundingClientRect(), w = g.width, f = g.height;
|
|
3986
4034
|
i.style.visibility = "", i.style.display = "none";
|
|
3987
|
-
const
|
|
4035
|
+
const p = r.positionOffset ?? "top";
|
|
3988
4036
|
let C = "translate(-50%, -100%)";
|
|
3989
|
-
|
|
4037
|
+
p === "top" ? (l = l - d, C = "translate(-50%, -100%)") : p === "bottom" ? (l = s.y + d, a = s.x, C = "translate(-50%, 0%)") : p === "left" ? (a = s.x - d, l = s.y, C = "translate(-100%, -50%)") : p === "right" ? (a = s.x + d, l = s.y, C = "translate(0%, -50%)") : p === "top-left" ? (a = s.x - d, l = s.y - d, C = "translate(-100%, -100%)") : p === "top-right" ? (a = s.x + d, l = s.y - d, C = "translate(0%, -100%)") : p === "bottom-left" ? (a = s.x - d, l = s.y + d, C = "translate(-100%, 0%)") : p === "bottom-right" ? (a = s.x + d, l = s.y + d, C = "translate(0%, 0%)") : p === "left-top" ? (a = s.x - d, l = s.y - d, C = "translate(-100%, 0%)") : p === "left-bottom" ? (a = s.x - d, l = s.y + d, C = "translate(-100%, -100%)") : p === "right-top" ? (a = s.x + d, l = s.y - d, C = "translate(0%, 0%)") : p === "right-bottom" && (a = s.x + d, l = s.y + d, C = "translate(0%, -100%)");
|
|
3990
4038
|
const v = 10;
|
|
3991
4039
|
if (this.isCameraMoving || ((G) => {
|
|
3992
|
-
G.left < v && (a += v - G.left), G.right > m - v && (a -= G.right - (m - v)), G.top < v && (l += v - G.top), G.bottom >
|
|
4040
|
+
G.left < v && (a += v - G.left), G.right > m - v && (a -= G.right - (m - v)), G.top < v && (l += v - G.top), G.bottom > b - v && (l -= G.bottom - (b - v));
|
|
3993
4041
|
})((() => {
|
|
3994
|
-
switch (
|
|
4042
|
+
switch (p) {
|
|
3995
4043
|
case "top":
|
|
3996
4044
|
return {
|
|
3997
|
-
left: a -
|
|
3998
|
-
right: a +
|
|
4045
|
+
left: a - w / 2,
|
|
4046
|
+
right: a + w / 2,
|
|
3999
4047
|
top: l - f,
|
|
4000
4048
|
bottom: l
|
|
4001
4049
|
};
|
|
4002
4050
|
case "bottom":
|
|
4003
4051
|
return {
|
|
4004
|
-
left: a -
|
|
4005
|
-
right: a +
|
|
4052
|
+
left: a - w / 2,
|
|
4053
|
+
right: a + w / 2,
|
|
4006
4054
|
top: l,
|
|
4007
4055
|
bottom: l + f
|
|
4008
4056
|
};
|
|
4009
4057
|
case "left":
|
|
4010
4058
|
return {
|
|
4011
|
-
left: a -
|
|
4059
|
+
left: a - w,
|
|
4012
4060
|
right: a,
|
|
4013
4061
|
top: l - f / 2,
|
|
4014
4062
|
bottom: l + f / 2
|
|
@@ -4016,13 +4064,13 @@ class Me {
|
|
|
4016
4064
|
case "right":
|
|
4017
4065
|
return {
|
|
4018
4066
|
left: a,
|
|
4019
|
-
right: a +
|
|
4067
|
+
right: a + w,
|
|
4020
4068
|
top: l - f / 2,
|
|
4021
4069
|
bottom: l + f / 2
|
|
4022
4070
|
};
|
|
4023
4071
|
case "top-left":
|
|
4024
4072
|
return {
|
|
4025
|
-
left: a -
|
|
4073
|
+
left: a - w,
|
|
4026
4074
|
right: a,
|
|
4027
4075
|
top: l - f,
|
|
4028
4076
|
bottom: l
|
|
@@ -4030,13 +4078,13 @@ class Me {
|
|
|
4030
4078
|
case "top-right":
|
|
4031
4079
|
return {
|
|
4032
4080
|
left: a,
|
|
4033
|
-
right: a +
|
|
4081
|
+
right: a + w,
|
|
4034
4082
|
top: l - f,
|
|
4035
4083
|
bottom: l
|
|
4036
4084
|
};
|
|
4037
4085
|
case "bottom-left":
|
|
4038
4086
|
return {
|
|
4039
|
-
left: a -
|
|
4087
|
+
left: a - w,
|
|
4040
4088
|
right: a,
|
|
4041
4089
|
top: l,
|
|
4042
4090
|
bottom: l + f
|
|
@@ -4044,20 +4092,20 @@ class Me {
|
|
|
4044
4092
|
case "bottom-right":
|
|
4045
4093
|
return {
|
|
4046
4094
|
left: a,
|
|
4047
|
-
right: a +
|
|
4095
|
+
right: a + w,
|
|
4048
4096
|
top: l,
|
|
4049
4097
|
bottom: l + f
|
|
4050
4098
|
};
|
|
4051
4099
|
case "left-top":
|
|
4052
4100
|
return {
|
|
4053
|
-
left: a -
|
|
4101
|
+
left: a - w,
|
|
4054
4102
|
right: a,
|
|
4055
4103
|
top: l,
|
|
4056
4104
|
bottom: l + f
|
|
4057
4105
|
};
|
|
4058
4106
|
case "left-bottom":
|
|
4059
4107
|
return {
|
|
4060
|
-
left: a -
|
|
4108
|
+
left: a - w,
|
|
4061
4109
|
right: a,
|
|
4062
4110
|
top: l - f,
|
|
4063
4111
|
bottom: l
|
|
@@ -4065,21 +4113,21 @@ class Me {
|
|
|
4065
4113
|
case "right-top":
|
|
4066
4114
|
return {
|
|
4067
4115
|
left: a,
|
|
4068
|
-
right: a +
|
|
4116
|
+
right: a + w,
|
|
4069
4117
|
top: l,
|
|
4070
4118
|
bottom: l + f
|
|
4071
4119
|
};
|
|
4072
4120
|
case "right-bottom":
|
|
4073
4121
|
return {
|
|
4074
4122
|
left: a,
|
|
4075
|
-
right: a +
|
|
4123
|
+
right: a + w,
|
|
4076
4124
|
top: l - f,
|
|
4077
4125
|
bottom: l
|
|
4078
4126
|
};
|
|
4079
4127
|
default:
|
|
4080
4128
|
return {
|
|
4081
|
-
left: a -
|
|
4082
|
-
right: a +
|
|
4129
|
+
left: a - w / 2,
|
|
4130
|
+
right: a + w / 2,
|
|
4083
4131
|
top: l - f,
|
|
4084
4132
|
bottom: l
|
|
4085
4133
|
};
|
|
@@ -4087,7 +4135,7 @@ class Me {
|
|
|
4087
4135
|
})()), i.style.left = `${a}px`, i.style.top = `${l}px`, i.style.transform = C, i.style.display = "block", t.arrowEl && r.showArrow) {
|
|
4088
4136
|
const y = t.arrowEl, x = (r.arrowSize ?? 8) + "px", G = i.style.background || r.backgroundColor || "#ffffff";
|
|
4089
4137
|
y.style.borderLeft = "0", y.style.borderRight = "0", y.style.borderTop = "0", y.style.borderBottom = "0", y.style.left = "", y.style.right = "", y.style.top = "", y.style.bottom = "", y.style.transform = "";
|
|
4090
|
-
const A = (O) => O.startsWith("top") ? "top" : O.startsWith("bottom") ? "bottom" : O.startsWith("left") ? "left" : O.startsWith("right") ? "right" : "top", Y = (O) => O.includes("left") ? 25 : O.includes("right") ? 75 : 50, E = A(
|
|
4138
|
+
const A = (O) => O.startsWith("top") ? "top" : O.startsWith("bottom") ? "bottom" : O.startsWith("left") ? "left" : O.startsWith("right") ? "right" : "top", Y = (O) => O.includes("left") ? 25 : O.includes("right") ? 75 : 50, E = A(p), P = Y(p);
|
|
4091
4139
|
E === "top" ? (y.style.left = `${P}%`, y.style.bottom = `-${x}`, y.style.transform = "translateX(-50%)", y.style.borderLeft = `${x} solid transparent`, y.style.borderRight = `${x} solid transparent`, y.style.borderTop = `${x} solid ${G}`) : E === "bottom" ? (y.style.left = `${P}%`, y.style.top = `-${x}`, y.style.transform = "translateX(-50%)", y.style.borderLeft = `${x} solid transparent`, y.style.borderRight = `${x} solid transparent`, y.style.borderBottom = `${x} solid ${G}`) : E === "left" ? (y.style.right = `-${x}`, y.style.top = `${P}%`, y.style.transform = "translateY(-50%)", y.style.borderTop = `${x} solid transparent`, y.style.borderBottom = `${x} solid transparent`, y.style.borderLeft = `${x} solid ${G}`) : (y.style.left = `-${x}`, y.style.top = `${P}%`, y.style.transform = "translateY(-50%)", y.style.borderTop = `${x} solid transparent`, y.style.borderBottom = `${x} solid transparent`, y.style.borderRight = `${x} solid ${G}`);
|
|
4092
4140
|
}
|
|
4093
4141
|
}
|
|
@@ -4353,8 +4401,8 @@ class Te {
|
|
|
4353
4401
|
if (i < 3) return e.slice();
|
|
4354
4402
|
const o = this.polygonArea2D(e) > 0, s = [];
|
|
4355
4403
|
for (let h = 0; h < i; h++) {
|
|
4356
|
-
const d = e[h], u = e[(h + 1) % i], m = u.x - d.x,
|
|
4357
|
-
s.push(new n.Cartesian2(-
|
|
4404
|
+
const d = e[h], u = e[(h + 1) % i], m = u.x - d.x, b = u.y - d.y, g = Math.hypot(m, b) || 1, w = m / g, f = b / g, p = o ? -f : f, C = o ? w : -w;
|
|
4405
|
+
s.push(new n.Cartesian2(-p, -C));
|
|
4358
4406
|
}
|
|
4359
4407
|
const a = [];
|
|
4360
4408
|
for (let h = 0; h < i; h++) {
|
|
@@ -4363,13 +4411,13 @@ class Te {
|
|
|
4363
4411
|
}
|
|
4364
4412
|
const l = [];
|
|
4365
4413
|
for (let h = 0; h < i; h++) {
|
|
4366
|
-
const d = (h - 1 + i) % i, u = s[d], m = a[d],
|
|
4367
|
-
if (Math.abs(
|
|
4414
|
+
const d = (h - 1 + i) % i, u = s[d], m = a[d], b = s[h], g = a[h], w = u.x * b.y - b.x * u.y;
|
|
4415
|
+
if (Math.abs(w) < 1e-8) {
|
|
4368
4416
|
const f = e[h];
|
|
4369
|
-
l.push(new n.Cartesian2(f.x +
|
|
4417
|
+
l.push(new n.Cartesian2(f.x + b.x * t, f.y + b.y * t));
|
|
4370
4418
|
} else {
|
|
4371
|
-
const f = (m *
|
|
4372
|
-
l.push(new n.Cartesian2(f,
|
|
4419
|
+
const f = (m * b.y - g * u.y) / w, p = (u.x * g - b.x * m) / w;
|
|
4420
|
+
l.push(new n.Cartesian2(f, p));
|
|
4373
4421
|
}
|
|
4374
4422
|
}
|
|
4375
4423
|
return l;
|
|
@@ -4539,11 +4587,11 @@ class Ee {
|
|
|
4539
4587
|
}
|
|
4540
4588
|
});
|
|
4541
4589
|
if (e.onClick) {
|
|
4542
|
-
const g = u,
|
|
4543
|
-
g._onClick = e.onClick,
|
|
4590
|
+
const g = u, w = m;
|
|
4591
|
+
g._onClick = e.onClick, w._onClick = e.onClick;
|
|
4544
4592
|
}
|
|
4545
|
-
const
|
|
4546
|
-
return
|
|
4593
|
+
const b = u;
|
|
4594
|
+
return b._innerEntity = m, b._isRing = !0, b._ringThickness = r, b._outerRectangle = e.coordinates, u;
|
|
4547
4595
|
}
|
|
4548
4596
|
const o = this.entities.add({
|
|
4549
4597
|
id: t,
|
|
@@ -4648,7 +4696,7 @@ class Oe {
|
|
|
4648
4696
|
add(e) {
|
|
4649
4697
|
const t = this.convertPosition(e.position), i = e.id || `circle_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`, r = this.resolveMaterial(e.material), o = e.outlineWidth && e.outlineWidth > 1 ? e.outlineWidth : 0;
|
|
4650
4698
|
if (o > 0) {
|
|
4651
|
-
const s = n.Cartographic.fromCartesian(t), a = s?.height ?? 0, l = 0.01, h = e.radius, d = Math.max(0, e.radius - o), u = this.generateCirclePositions(s, h, a + l), m = this.generateCirclePositions(s, d, a),
|
|
4699
|
+
const s = n.Cartographic.fromCartesian(t), a = s?.height ?? 0, l = 0.01, h = e.radius, d = Math.max(0, e.radius - o), u = this.generateCirclePositions(s, h, a + l), m = this.generateCirclePositions(s, d, a), b = this.entities.add({
|
|
4652
4700
|
// 使用带洞的多边形,只渲染环带区域,不填充中心
|
|
4653
4701
|
polygon: {
|
|
4654
4702
|
hierarchy: new n.PolygonHierarchy(u, [new n.PolygonHierarchy(m)]),
|
|
@@ -4669,11 +4717,11 @@ class Oe {
|
|
|
4669
4717
|
}
|
|
4670
4718
|
});
|
|
4671
4719
|
if (e.onClick) {
|
|
4672
|
-
const f =
|
|
4673
|
-
f._onClick = e.onClick,
|
|
4720
|
+
const f = b, p = g;
|
|
4721
|
+
f._onClick = e.onClick, p._onClick = e.onClick;
|
|
4674
4722
|
}
|
|
4675
|
-
const
|
|
4676
|
-
return
|
|
4723
|
+
const w = b;
|
|
4724
|
+
return w._innerEntity = g, w._isRing = !0, w._ringThickness = o, w._fillMaterial = r, w._ringHeightEpsilon = l, w._centerCartographic = s, w._outerRadius = h, w._innerRadius = d, b;
|
|
4677
4725
|
} else {
|
|
4678
4726
|
const s = this.entities.add({
|
|
4679
4727
|
id: i,
|
|
@@ -4703,7 +4751,7 @@ class Oe {
|
|
|
4703
4751
|
generateCirclePositions(e, t, i, r = 128) {
|
|
4704
4752
|
const s = e.latitude, a = e.longitude, l = t / 6378137, h = [];
|
|
4705
4753
|
for (let d = 0; d < r; d++) {
|
|
4706
|
-
const u = d / r * n.Math.TWO_PI, m = Math.sin(s),
|
|
4754
|
+
const u = d / r * n.Math.TWO_PI, m = Math.sin(s), b = Math.cos(s), g = Math.sin(l), w = Math.cos(l), f = Math.sin(u), p = Math.cos(u), C = Math.asin(m * w + b * g * p), v = a + Math.atan2(f * g * b, w - m * Math.sin(C));
|
|
4707
4755
|
h.push(n.Cartesian3.fromRadians(v, C, i));
|
|
4708
4756
|
}
|
|
4709
4757
|
return h;
|
|
@@ -4859,7 +4907,7 @@ class Le {
|
|
|
4859
4907
|
generateCirclePositions(e, t, i, r = 128) {
|
|
4860
4908
|
const s = e.latitude, a = e.longitude, l = t / 6378137, h = [];
|
|
4861
4909
|
for (let d = 0; d < r; d++) {
|
|
4862
|
-
const u = d / r * n.Math.TWO_PI, m = Math.sin(s),
|
|
4910
|
+
const u = d / r * n.Math.TWO_PI, m = Math.sin(s), b = Math.cos(s), g = Math.sin(l), w = Math.cos(l), f = Math.sin(u), p = Math.cos(u), C = Math.asin(m * w + b * g * p), v = a + Math.atan2(f * g * b, w - m * Math.sin(C));
|
|
4863
4911
|
h.push(n.Cartesian3.fromRadians(v, C, i));
|
|
4864
4912
|
}
|
|
4865
4913
|
return h.length > 0 && h.push(h[0]), h;
|
|
@@ -4876,7 +4924,7 @@ class Le {
|
|
|
4876
4924
|
dashLength: e.dashLength,
|
|
4877
4925
|
dashPattern: e.dashPattern,
|
|
4878
4926
|
gapColor: e.gapColor
|
|
4879
|
-
}),
|
|
4927
|
+
}), b = e.lineWidth ?? this.getInnerWidth(i), g = this.entities.add({
|
|
4880
4928
|
id: t,
|
|
4881
4929
|
polyline: {
|
|
4882
4930
|
positions: d,
|
|
@@ -4886,16 +4934,16 @@ class Le {
|
|
|
4886
4934
|
// clampToGround=true 时生效:保证外层在下
|
|
4887
4935
|
zIndex: 0
|
|
4888
4936
|
}
|
|
4889
|
-
}),
|
|
4937
|
+
}), w = s ? this.addInnerEntity({
|
|
4890
4938
|
outerId: t,
|
|
4891
4939
|
ringPositions: d,
|
|
4892
|
-
innerWidth:
|
|
4940
|
+
innerWidth: b,
|
|
4893
4941
|
lineMaterial: m,
|
|
4894
4942
|
clampToGround: o
|
|
4895
4943
|
}) : void 0, f = g;
|
|
4896
|
-
if (f._overlayType = "ring", f._centerCartographic = l, f._outerRadius = e.radius, f._ringSegments = r, f._ringGlowPower = n.Math.clamp(e.glowPower ?? 0.25, 0, 1), f._ringLineColor = e.lineColor ?? n.Color.WHITE, f._ringLineStyle = e.lineStyle ?? "solid", f._ringLineMaterialMode = e.lineMaterialMode ?? "stripe", f._ringStripeRepeat = e.stripeRepeat, f._ringDashLength = e.dashLength, f._ringDashPattern = e.dashPattern, f._ringGapColor = e.gapColor, f._ringShowInnerLine = s, f._innerEntity =
|
|
4897
|
-
const
|
|
4898
|
-
|
|
4944
|
+
if (f._overlayType = "ring", f._centerCartographic = l, f._outerRadius = e.radius, f._ringSegments = r, f._ringGlowPower = n.Math.clamp(e.glowPower ?? 0.25, 0, 1), f._ringLineColor = e.lineColor ?? n.Color.WHITE, f._ringLineStyle = e.lineStyle ?? "solid", f._ringLineMaterialMode = e.lineMaterialMode ?? "stripe", f._ringStripeRepeat = e.stripeRepeat, f._ringDashLength = e.dashLength, f._ringDashPattern = e.dashPattern, f._ringGapColor = e.gapColor, f._ringShowInnerLine = s, f._innerEntity = w, e.onClick && (f._onClick = e.onClick, w)) {
|
|
4945
|
+
const p = w;
|
|
4946
|
+
p._onClick = () => e.onClick?.(g);
|
|
4899
4947
|
}
|
|
4900
4948
|
return g;
|
|
4901
4949
|
}
|
|
@@ -4929,7 +4977,7 @@ class Le {
|
|
|
4929
4977
|
else if (!i._innerEntity) {
|
|
4930
4978
|
const u = this.rebuildRingPositions(e, i, { clampToGround: t.clampToGround, segments: t.segments });
|
|
4931
4979
|
if (u) {
|
|
4932
|
-
const m = t.clampToGround ?? e.polyline?.clampToGround?.getValue?.(n.JulianDate.now?.()) ?? e.polyline?.clampToGround,
|
|
4980
|
+
const m = t.clampToGround ?? e.polyline?.clampToGround?.getValue?.(n.JulianDate.now?.()) ?? e.polyline?.clampToGround, b = typeof m == "boolean" ? m : !0, g = e.polyline.width?.getValue?.(n.JulianDate.now?.()) ?? e.polyline.width ?? t.glowWidth ?? t.width ?? 8, w = typeof g == "number" ? g : t.glowWidth ?? t.width ?? 8, f = t.lineWidth ?? this.getInnerWidth(w), p = this.resolveLineMaterial({
|
|
4933
4981
|
lineColor: t.lineColor ?? i._ringLineColor,
|
|
4934
4982
|
lineStyle: t.lineStyle ?? i._ringLineStyle,
|
|
4935
4983
|
lineMaterialMode: t.lineMaterialMode ?? i._ringLineMaterialMode,
|
|
@@ -4941,8 +4989,8 @@ class Le {
|
|
|
4941
4989
|
outerId: String(e.id),
|
|
4942
4990
|
ringPositions: u,
|
|
4943
4991
|
innerWidth: f,
|
|
4944
|
-
lineMaterial:
|
|
4945
|
-
clampToGround:
|
|
4992
|
+
lineMaterial: p,
|
|
4993
|
+
clampToGround: b
|
|
4946
4994
|
});
|
|
4947
4995
|
if (i._innerEntity = C, i._onClick) {
|
|
4948
4996
|
const v = C;
|
|
@@ -4963,21 +5011,21 @@ class Le {
|
|
|
4963
5011
|
e.polyline.material = this.resolveGlowMaterial(t.color ?? n.Color.CYAN, u), i._ringGlowPower = n.Math.clamp(u, 0, 1);
|
|
4964
5012
|
}
|
|
4965
5013
|
if ((t.lineColor !== void 0 || t.lineStyle !== void 0 || t.lineMaterialMode !== void 0 || t.stripeRepeat !== void 0 || t.dashLength !== void 0 || t.dashPattern !== void 0 || t.gapColor !== void 0) && i._innerEntity?.polyline) {
|
|
4966
|
-
const u = t.lineColor ?? i._ringLineColor, m = t.lineStyle ?? i._ringLineStyle,
|
|
5014
|
+
const u = t.lineColor ?? i._ringLineColor, m = t.lineStyle ?? i._ringLineStyle, b = t.lineMaterialMode ?? i._ringLineMaterialMode, g = t.stripeRepeat ?? i._ringStripeRepeat, w = t.dashLength ?? i._ringDashLength, f = t.dashPattern ?? i._ringDashPattern, p = t.gapColor ?? i._ringGapColor;
|
|
4967
5015
|
i._innerEntity.polyline.material = this.resolveLineMaterial({
|
|
4968
5016
|
lineColor: u,
|
|
4969
5017
|
lineStyle: m,
|
|
4970
|
-
lineMaterialMode:
|
|
5018
|
+
lineMaterialMode: b,
|
|
4971
5019
|
stripeRepeat: g,
|
|
4972
|
-
dashLength:
|
|
5020
|
+
dashLength: w,
|
|
4973
5021
|
dashPattern: f,
|
|
4974
|
-
gapColor:
|
|
4975
|
-
}), i._ringLineColor = u, i._ringLineStyle = m, i._ringLineMaterialMode =
|
|
5022
|
+
gapColor: p
|
|
5023
|
+
}), i._ringLineColor = u, i._ringLineStyle = m, i._ringLineMaterialMode = b, i._ringStripeRepeat = g, i._ringDashLength = w, i._ringDashPattern = f, i._ringGapColor = p;
|
|
4976
5024
|
}
|
|
4977
5025
|
const s = i._centerCartographic, a = i._outerRadius, l = t.segments ?? i._ringSegments, h = t.segments !== void 0 && t.segments !== i._ringSegments, d = t.clampToGround !== void 0;
|
|
4978
5026
|
if (t.clampToGround !== void 0 && (e.polyline.clampToGround = new n.ConstantProperty(t.clampToGround), i._innerEntity?.polyline && (i._innerEntity.polyline.clampToGround = new n.ConstantProperty(t.clampToGround))), (h || d) && s && a !== void 0) {
|
|
4979
|
-
const m = t.clampToGround ?? !0 ? 0 : s.height ?? 0,
|
|
4980
|
-
e.polyline.positions = new n.ConstantProperty(
|
|
5027
|
+
const m = t.clampToGround ?? !0 ? 0 : s.height ?? 0, b = this.generateCirclePositions(s, a, m, l ?? 128);
|
|
5028
|
+
e.polyline.positions = new n.ConstantProperty(b), i._innerEntity?.polyline && (i._innerEntity.polyline.positions = new n.ConstantProperty(b)), i._ringSegments = l ?? 128;
|
|
4981
5029
|
}
|
|
4982
5030
|
}
|
|
4983
5031
|
/**
|
|
@@ -5502,27 +5550,27 @@ class Ie {
|
|
|
5502
5550
|
let h = this.options.minValue, d = this.options.maxValue;
|
|
5503
5551
|
if (!l) {
|
|
5504
5552
|
h = Number.POSITIVE_INFINITY, d = Number.NEGATIVE_INFINITY;
|
|
5505
|
-
for (const
|
|
5506
|
-
Number.isFinite(
|
|
5553
|
+
for (const p of e)
|
|
5554
|
+
Number.isFinite(p.value) && (p.value < h && (h = p.value), p.value > d && (d = p.value));
|
|
5507
5555
|
(!Number.isFinite(h) || !Number.isFinite(d) || h === d) && (h = 0, d = 1), i.persistMinMax && (this.options.minValue = h, this.options.maxValue = d);
|
|
5508
5556
|
}
|
|
5509
|
-
const u = n.Math.toDegrees(t.west), m = n.Math.toDegrees(t.east),
|
|
5510
|
-
for (const
|
|
5511
|
-
if (!Number.isFinite(
|
|
5512
|
-
const C = (
|
|
5557
|
+
const u = n.Math.toDegrees(t.west), m = n.Math.toDegrees(t.east), b = n.Math.toDegrees(t.south), g = n.Math.toDegrees(t.north);
|
|
5558
|
+
for (const p of e) {
|
|
5559
|
+
if (!Number.isFinite(p.lon) || !Number.isFinite(p.lat)) continue;
|
|
5560
|
+
const C = (p.value - h) / (d - h || 1);
|
|
5513
5561
|
if (C <= 0) continue;
|
|
5514
|
-
const v = (
|
|
5562
|
+
const v = (p.lon - u) / (m - u || 1) * r, y = (1 - (p.lat - b) / (g - b || 1)) * o, x = a.createRadialGradient(v, y, 0, v, y, s);
|
|
5515
5563
|
x.addColorStop(0, "rgba(0,0,0,1)"), x.addColorStop(1, "rgba(0,0,0,0)"), a.fillStyle = x, a.globalAlpha = C, a.beginPath(), a.arc(v, y, s, 0, Math.PI * 2), a.fill();
|
|
5516
5564
|
}
|
|
5517
5565
|
a.globalAlpha = 1;
|
|
5518
|
-
const
|
|
5519
|
-
for (let
|
|
5520
|
-
const C = f[
|
|
5566
|
+
const w = a.getImageData(0, 0, r, o), f = w.data;
|
|
5567
|
+
for (let p = 0; p < f.length; p += 4) {
|
|
5568
|
+
const C = f[p + 3];
|
|
5521
5569
|
if (C === 0) continue;
|
|
5522
5570
|
const y = Math.min(255, Math.max(0, C)) * 4;
|
|
5523
|
-
f[
|
|
5571
|
+
f[p] = this.gradientLUT[y], f[p + 1] = this.gradientLUT[y + 1], f[p + 2] = this.gradientLUT[y + 2], f[p + 3] = Math.round(C * this.options.opacity);
|
|
5524
5572
|
}
|
|
5525
|
-
a.putImageData(
|
|
5573
|
+
a.putImageData(w, 0, 0), this.updateImageryLayer(t);
|
|
5526
5574
|
}
|
|
5527
5575
|
/**
|
|
5528
5576
|
* 将当前 canvas 映射为 Cesium 影像图层
|