cesium-pocket 0.3.2-alpha → 0.3.6-alpha

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.
@@ -0,0 +1,498 @@
1
+ import { Cartographic as M, EllipsoidGeodesic as I, Cartesian3 as b, BoundingSphere as Y, Transforms as y, Matrix4 as G, CustomDataSource as L, ConstantPositionProperty as d, ConstantProperty as u, Color as o, Cartesian2 as v, VerticalOrigin as S, HorizontalOrigin as f, LabelStyle as C, Math as O } from "cesium";
2
+ import { a as N, R as j, P as U, C as P, b as W } from "./CircleDrawer-DotSQduG.js";
3
+ const A = (r, t) => {
4
+ const n = M.fromCartesian(r), e = M.fromCartesian(t);
5
+ return new I(n, e).surfaceDistance;
6
+ }, B = (r, t) => {
7
+ const n = new b();
8
+ return b.add(r, t, n), b.divideByScalar(n, 2, n), n;
9
+ }, g = (r) => {
10
+ let t = "";
11
+ return r > 1e3 * 100 ? t = (r / 1e3).toFixed(0) + " 公里" : r > 1e3 ? t = (r / 1e3).toFixed(2) + " 公里" : t = r.toFixed(2) + " 米", t;
12
+ }, m = (r) => {
13
+ if (!r || r.length === 0) return null;
14
+ let t = 0, n = 0, e = 0;
15
+ const i = r.length;
16
+ return r.forEach((a) => {
17
+ t += a.x, n += a.y, e += a.z;
18
+ }), new b(
19
+ t / i,
20
+ n / i,
21
+ e / i
22
+ );
23
+ }, F = (r) => {
24
+ if (r.length < 3) return "0平方米";
25
+ const n = Y.fromPoints(r).center, e = y.eastNorthUpToFixedFrame(n), i = G.inverse(e, new G()), s = r.map(
26
+ (l) => G.multiplyByPoint(i, l, new b())
27
+ );
28
+ let a = 0;
29
+ for (let l = 0; l < s.length; l++) {
30
+ const c = (l + 1) % s.length;
31
+ a += s[l].x * s[c].y, a -= s[c].x * s[l].y;
32
+ }
33
+ return a = Math.abs(a / 2), k(a);
34
+ }, k = (r) => {
35
+ let t = "";
36
+ return r > 1e3 * 1e3 * 1e3 ? t = (r / 1e3 / 1e3 / 1e4).toFixed(2) + "万平方公里" : r > 1e3 * 100 ? t = (r / 1e3 / 1e3).toFixed(2) + "平方公里" : t = r.toFixed(0) + "平方米", t;
37
+ };
38
+ class X {
39
+ constructor(t, n = null) {
40
+ this.tmpDistanceLabel = null, this.tmpAreaLabel = null, this.distanceLabel = null, this.areaLabel = null, this.dataSource = new L("gagugerDataSource"), this.assistDataSource = new L("assistDataSource"), this.circleEditFun = (e, i) => {
41
+ let s = 0;
42
+ if (this.distanceLabel) {
43
+ s = A(e, i);
44
+ const a = g(s);
45
+ this.distanceLabel.position = new d(i), this.distanceLabel.label && (this.distanceLabel.label.text = new u(a));
46
+ }
47
+ if (this.areaLabel) {
48
+ const a = window.Math.PI * s * s, l = k(a);
49
+ this.areaLabel.position = new d(e), this.areaLabel.label && (this.areaLabel.label.text = new u(l));
50
+ }
51
+ }, this.circleMovingFun = (e, i) => {
52
+ let s = 0;
53
+ if (this.tmpDistanceLabel) {
54
+ s = A(e, i);
55
+ const a = g(s);
56
+ this.tmpDistanceLabel.show = !0, this.tmpDistanceLabel.position = new d(i), this.tmpDistanceLabel.label && (this.tmpDistanceLabel.label.text = new u(a));
57
+ }
58
+ if (this.tmpAreaLabel) {
59
+ const a = window.Math.PI * s * s, l = k(a);
60
+ this.tmpAreaLabel.position = new d(e), this.tmpAreaLabel.label && (this.tmpAreaLabel.label.text = new u(l));
61
+ }
62
+ }, this.circleOverFun = (e, i) => {
63
+ this.tmpDistanceLabel.show = !1, this.tmpAreaLabel.show = !1;
64
+ const s = this.createTextLabel(new b(), "", o.DARKRED), a = this.createTextLabel(new b(), "", o.BLACK);
65
+ this.distanceLabel = this.assistDataSource.entities.add(s), this.areaLabel = this.assistDataSource.entities.add(a), this.circleEditFun(e, i);
66
+ }, this.createTextLabel = (e, i, s = o.DARKRED, a = -20) => {
67
+ const l = {
68
+ text: i,
69
+ font: "12px sans-serif bold",
70
+ fillColor: o.WHITE,
71
+ showBackground: !0,
72
+ backgroundColor: s,
73
+ style: C.FILL_AND_OUTLINE,
74
+ horizontalOrigin: f.CENTER,
75
+ verticalOrigin: S.CENTER,
76
+ pixelOffset: new v(0, a),
77
+ //偏移量
78
+ zIndex: 20
79
+ };
80
+ return {
81
+ position: e,
82
+ label: l
83
+ };
84
+ }, this.viewer = t, this.viewer.dataSources.add(this.dataSource), this.viewer.dataSources.add(this.assistDataSource), this.init(n);
85
+ }
86
+ start() {
87
+ var e;
88
+ (e = this.circleDrawer) == null || e.start();
89
+ const t = this.createTextLabel(new b(), "", o.DARKRED.withAlpha(0.6)), n = this.createTextLabel(new b(), "", o.BLACK.withAlpha(0.6));
90
+ this.tmpDistanceLabel = this.assistDataSource.entities.add(t), this.tmpAreaLabel = this.assistDataSource.entities.add(n);
91
+ }
92
+ getStatus() {
93
+ var t;
94
+ (t = this.circleDrawer) == null || t.getStatus();
95
+ }
96
+ setEditStatus() {
97
+ var t;
98
+ (t = this.circleDrawer) == null || t.setEditStatus();
99
+ }
100
+ clearAll() {
101
+ var t;
102
+ (t = this.circleDrawer) == null || t.clearAll(), this.dataSource.entities.removeAll(), this.assistDataSource.entities.removeAll();
103
+ }
104
+ init(t) {
105
+ let e = { ...{
106
+ circleEditFun: this.circleEditFun,
107
+ circleMovingFun: this.circleMovingFun,
108
+ circleOverFun: this.circleOverFun
109
+ }, ...t };
110
+ this.circleDrawer = new N(this.viewer, e);
111
+ }
112
+ }
113
+ class V {
114
+ constructor(t, n = null) {
115
+ this.tmpLabel = null, this.totalLabel = null, this.dataSource = new L("gagugerDataSource"), this.assistDataSource = new L("assistDataSource"), this.rectEditFun = (e) => {
116
+ if (this.totalLabel) {
117
+ const i = m(e), s = F(e);
118
+ i && (this.totalLabel.show = !0, this.totalLabel.position = new d(i), this.totalLabel.label && (this.totalLabel.label.text = new u(s)));
119
+ }
120
+ }, this.rectMovingFun = (e) => {
121
+ if (this.tmpLabel) {
122
+ const i = m(e), s = F(e);
123
+ i && (this.tmpLabel.show = !0, this.tmpLabel.position = new d(i), this.tmpLabel.label && (this.tmpLabel.label.text = new u(s)));
124
+ }
125
+ }, this.rectOverFun = (e) => {
126
+ if (this.tmpLabel && (this.tmpLabel.show = !1), !this.totalLabel) {
127
+ const i = m(e), s = F(e);
128
+ if (i) {
129
+ const a = this.createTextlabel(i, s, o.BLACK);
130
+ this.totalLabel = this.assistDataSource.entities.add(a);
131
+ }
132
+ }
133
+ }, this.createTextlabel = (e, i, s = o.DARKRED, a = 0) => {
134
+ const l = {
135
+ text: i,
136
+ font: "12px sans-serif bold",
137
+ fillColor: o.WHITE,
138
+ showBackground: !0,
139
+ backgroundColor: s,
140
+ style: C.FILL_AND_OUTLINE,
141
+ horizontalOrigin: f.CENTER,
142
+ verticalOrigin: S.CENTER,
143
+ pixelOffset: new v(0, a)
144
+ //偏移量
145
+ };
146
+ return {
147
+ position: e,
148
+ label: l
149
+ };
150
+ }, this.createTmplabel = () => {
151
+ let i = {
152
+ position: new b(),
153
+ label: {
154
+ text: "",
155
+ font: "12px sans-serif bold",
156
+ fillColor: o.WHITE,
157
+ showBackground: !0,
158
+ backgroundColor: o.BLACK.withAlpha(0.6),
159
+ style: C.FILL_AND_OUTLINE,
160
+ horizontalOrigin: f.LEFT,
161
+ verticalOrigin: S.BOTTOM
162
+ },
163
+ show: !1
164
+ };
165
+ return this.assistDataSource.entities.add(i);
166
+ }, this.viewer = t, this.viewer.dataSources.add(this.dataSource), this.viewer.dataSources.add(this.assistDataSource), this.init(n);
167
+ }
168
+ start() {
169
+ var t;
170
+ (t = this.rectDrawer) == null || t.start(), this.tmpLabel = this.createTmplabel();
171
+ }
172
+ getStatus() {
173
+ var t;
174
+ (t = this.rectDrawer) == null || t.getStatus();
175
+ }
176
+ setEditStatus() {
177
+ var t;
178
+ (t = this.rectDrawer) == null || t.setEditStatus();
179
+ }
180
+ clearAll() {
181
+ var t;
182
+ (t = this.rectDrawer) == null || t.clearAll(), this.dataSource.entities.removeAll(), this.assistDataSource.entities.removeAll();
183
+ }
184
+ init(t) {
185
+ let e = { ...{
186
+ rectEditFun: this.rectEditFun,
187
+ rectMovingFun: this.rectMovingFun,
188
+ rectOverFun: this.rectOverFun
189
+ }, ...t };
190
+ this.rectDrawer = new j(this.viewer, e);
191
+ }
192
+ }
193
+ const Z = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACwAAAMgCAYAAABYroDnAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAyFpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuNi1jMTQ4IDc5LjE2NDAzNiwgMjAxOS8wOC8xMy0wMTowNjo1NyAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIgeG1sbnM6eG1wTU09Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9tbS8iIHhtbG5zOnN0UmVmPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvc1R5cGUvUmVzb3VyY2VSZWYjIiB4bWxuczp4bXA9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC8iIHhtcE1NOkRvY3VtZW50SUQ9InhtcC5kaWQ6QjA4Mzk1OTQ3QjdBMTFGMTg1RDM4RDA3NDg0RTQwNjEiIHhtcE1NOkluc3RhbmNlSUQ9InhtcC5paWQ6QjA4Mzk1OTM3QjdBMTFGMTg1RDM4RDA3NDg0RTQwNjEiIHhtcDpDcmVhdG9yVG9vbD0iQWRvYmUgUGhvdG9zaG9wIENDIChXaW5kb3dzKSI+IDx4bXBNTTpE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shfkv4ucDxDp4KcXwfczj+gI+kuB/ixxB/zALHh/DZlIPL3ObHgXoxxK0QP+S78Bwcc+z8Drm2rOtMmtxX0kT9b2kuF4ydLLAW1wNZ5iP89C6wMeeeDPFCiOfT5Dwb4lQqccdTBYgz/26I39OEuhri2xA/z5E6R5Pxapnu+LE5oBH5ZohXp+R6XSFONiZxfsUafSnE5yF+avF9o/GXUXWxOBf+8kSLL4gl7p0Qr7UoWaM5Jl+8zZchPgvx54zb/lqmGjvrij/Q+9uM6Eax9eDCasoPsFJsPfAz/9zrIS6E+CiipjhOraRldtb1XoYdN5bW+nTQyTb4/PjI+iTRtfS168XmUZR1RXh3VkvQdmk+33iIqxYP826u822WxrVU66ZdsQ6+lB6+/GzW5jmWzR8oP/s1T4eddjrfzXCsraT1e9b1yXbLZLF5+Gx96OyxFMdT1B/XHV05BRtXtU9nOO7GL77RAhzr5wchvupoRbsc4sMZEy5eN8rUaNxsUYvjCHycuqo3QrySSt1ur1sJ+kWIay1uH433Yx2uc/nCnKtdfHTOpSblubTKnU1lskypsJYqwZ200sX4Pq101+dYvmNF+TreV5mVqitz9hMbaWSuFd1e68k2bj4vUf8Utw9Qt3Y7mdZ36ofHqbScTj3DiSVB76X+4n+V6R8BBgDKRo2v+bLvIgAAAABJRU5ErkJggg==";
194
+ class K {
195
+ constructor(t, n) {
196
+ this.editCallback = (e, i) => {
197
+ const s = this.getLonLatStr(e);
198
+ i.label && i.label.text && (i.label.text = new u(s));
199
+ }, this.billboardCallback = (e) => {
200
+ console.log(e);
201
+ const i = this.getLonLatStr(e);
202
+ return console.log(i), this.viewer.entities.add({
203
+ position: e,
204
+ label: {
205
+ text: i,
206
+ font: "500 14px Helvetica",
207
+ style: C.FILL,
208
+ fillColor: o.WHITE,
209
+ outlineColor: o.BLACK,
210
+ pixelOffset: new v(0, -90),
211
+ //偏移量
212
+ showBackground: !0,
213
+ backgroundColor: o.ORANGERED,
214
+ horizontalOrigin: f.LEFT
215
+ },
216
+ billboard: {
217
+ image: Z,
218
+ width: 30,
219
+ height: 100,
220
+ scale: 1,
221
+ verticalOrigin: S.BOTTOM
222
+ },
223
+ show: !0
224
+ });
225
+ }, this.viewer = t, n ? (this.addPointFun = n.addBillboardFun, this.editPointFun = n.editPointFun) : (this.addPointFun = this.billboardCallback, this.editPointFun = this.editCallback), this.init();
226
+ }
227
+ start() {
228
+ var t;
229
+ (t = this.pointDrawer) == null || t.start();
230
+ }
231
+ getStatus() {
232
+ var t;
233
+ (t = this.pointDrawer) == null || t.getStatus();
234
+ }
235
+ setEditStatus() {
236
+ var t;
237
+ (t = this.pointDrawer) == null || t.setEditStatus();
238
+ }
239
+ setDelStatus() {
240
+ var t;
241
+ (t = this.pointDrawer) == null || t.setDelStatus();
242
+ }
243
+ clearAll() {
244
+ var t;
245
+ (t = this.pointDrawer) == null || t.clearAll();
246
+ }
247
+ getEntities() {
248
+ var t;
249
+ return (t = this.pointDrawer) == null ? void 0 : t.getEntities();
250
+ }
251
+ init() {
252
+ let t = {
253
+ addPointFun: this.addPointFun,
254
+ editPointFun: this.editPointFun
255
+ };
256
+ this.pointDrawer = new U(this.viewer, t);
257
+ }
258
+ getLonLatStr(t) {
259
+ const n = M.fromCartesian(t), e = O.toDegrees(n.longitude), i = O.toDegrees(n.latitude);
260
+ return `${e.toFixed(2)}, ${i.toFixed(2)}`;
261
+ }
262
+ }
263
+ class J {
264
+ constructor(t, n) {
265
+ this.tmpLabel = null, this.totalLabel = null, this.dataSource = new L("gagugerDataSource"), this.assistDataSource = new L("assistDataSource"), this.afterAddPointFun = (e) => {
266
+ const i = this.lineDrawer.getPositions();
267
+ let s = i.length;
268
+ if (s > 1) {
269
+ const a = B(i[s - 2], e), l = A(i[s - 2], e), c = g(l);
270
+ let w = this.createTextlabel(a, c);
271
+ this.dataSource.entities.add(w);
272
+ }
273
+ }, this.movingCallbackFun = (e) => {
274
+ if (this.tmpLabel) {
275
+ const i = this.lineDrawer.getPositions(), s = i[i.length - 1];
276
+ let a = A(s, e), l = g(a);
277
+ this.tmpLabel.show = !0, this.tmpLabel.position = new d(e), this.tmpLabel.label && (this.tmpLabel.label.text = new u(l));
278
+ }
279
+ }, this.editCallbackFun = (e, i) => {
280
+ const s = this.lineDrawer.getPositions();
281
+ let a = -1, l = -1, c = 0, w = 0;
282
+ if (i > 0) {
283
+ a = i;
284
+ const h = this.dataSource.entities.values[i - 1], p = s[i - 1], x = B(p, e);
285
+ c = A(p, e);
286
+ const T = g(c);
287
+ h.position = new d(x), h.label.text = new u(T);
288
+ }
289
+ if (i < s.length - 1) {
290
+ l = i + 1;
291
+ const h = this.dataSource.entities.values[i], p = s[i + 1], x = B(e, p);
292
+ w = A(e, p);
293
+ const T = g(w);
294
+ h.position = new d(x), h.label.text = new u(T);
295
+ }
296
+ i == s.length - 1 && this.totalLabel && (this.totalLabel.position = new d(e));
297
+ let D = 0;
298
+ for (let h = 1, p = s.length; h < p; h++) {
299
+ if (a == h || l == h)
300
+ continue;
301
+ const x = s[h - 1], T = s[h], R = A(x, T);
302
+ D += R;
303
+ }
304
+ D += c, D += w;
305
+ let E = "共:" + g(D);
306
+ this.totalLabel && (this.totalLabel.label.text = new u(E));
307
+ }, this.overCallbackFun = () => {
308
+ if (this.tmpLabel && (this.tmpLabel.show = !1), !this.totalLabel) {
309
+ const e = this.lineDrawer.getPositions();
310
+ let i = 0, s = e.length;
311
+ for (let c = 1; c < s; c++) {
312
+ const w = e[c - 1], D = e[c], E = A(w, D);
313
+ i += E;
314
+ }
315
+ let a = "共:" + g(i), l = this.createTextlabel(e[s - 1], a, o.BLACK, -20);
316
+ this.totalLabel = this.assistDataSource.entities.add(l);
317
+ }
318
+ }, this.createTextlabel = (e, i, s = o.DARKRED, a = 0) => {
319
+ const l = {
320
+ text: i,
321
+ font: "12px sans-serif bold",
322
+ fillColor: o.WHITE,
323
+ showBackground: !0,
324
+ backgroundColor: s,
325
+ style: C.FILL_AND_OUTLINE,
326
+ horizontalOrigin: f.CENTER,
327
+ verticalOrigin: S.CENTER,
328
+ pixelOffset: new v(0, a)
329
+ //偏移量
330
+ };
331
+ return {
332
+ position: e,
333
+ label: l
334
+ };
335
+ }, this.createTmplabel = () => {
336
+ let i = {
337
+ position: new b(),
338
+ label: {
339
+ text: "",
340
+ font: "12px sans-serif bold",
341
+ fillColor: o.WHITE,
342
+ showBackground: !0,
343
+ backgroundColor: o.RED.withAlpha(0.6),
344
+ style: C.FILL_AND_OUTLINE,
345
+ horizontalOrigin: f.LEFT,
346
+ verticalOrigin: S.BOTTOM
347
+ },
348
+ show: !1
349
+ };
350
+ return this.assistDataSource.entities.add(i);
351
+ }, this.reCreateAll = () => {
352
+ this.dataSource.entities.removeAll(), this.assistDataSource.entities.removeAll();
353
+ const e = this.lineDrawer.getPositions();
354
+ let i = 0, s = e.length;
355
+ for (let c = 1; c < s; c++) {
356
+ const w = e[c - 1], D = e[c], E = B(w, D), h = A(w, D);
357
+ i += h;
358
+ let p = g(h), x = this.createTextlabel(E, p);
359
+ this.dataSource.entities.add(x);
360
+ }
361
+ let a = "共:" + g(i), l = this.createTextlabel(e[s - 1], a, o.BLACK, -20);
362
+ this.totalLabel = this.assistDataSource.entities.add(l);
363
+ }, this.viewer = t, this.viewer.dataSources.add(this.dataSource), this.viewer.dataSources.add(this.assistDataSource), this.init(n);
364
+ }
365
+ start() {
366
+ var t;
367
+ (t = this.lineDrawer) == null || t.start(), this.tmpLabel = this.createTmplabel();
368
+ }
369
+ getStatus() {
370
+ var t;
371
+ (t = this.lineDrawer) == null || t.getStatus();
372
+ }
373
+ setEditStatus() {
374
+ var t;
375
+ (t = this.lineDrawer) == null || t.setEditStatus(), this.overCallbackFun();
376
+ }
377
+ setDelStatus() {
378
+ var t;
379
+ (t = this.lineDrawer) == null || t.setDelStatus(), this.overCallbackFun();
380
+ }
381
+ clearAll() {
382
+ var t;
383
+ (t = this.lineDrawer) == null || t.clearAll(), this.dataSource.entities.removeAll(), this.assistDataSource.entities.removeAll();
384
+ }
385
+ init(t) {
386
+ let e = { ...{
387
+ afterAddPointFun: this.afterAddPointFun,
388
+ movingCallbackFun: this.movingCallbackFun,
389
+ editCallbackFun: this.editCallbackFun,
390
+ overCallbackFun: this.overCallbackFun,
391
+ delCallbackFun: this.reCreateAll
392
+ }, ...t };
393
+ this.lineDrawer = new P(this.viewer, e);
394
+ }
395
+ }
396
+ class Q {
397
+ constructor(t, n = null) {
398
+ this.tmpLabel = null, this.totalLabel = null, this.openTmpLabel = !1, this.dataSource = new L("gagugerDataSource"), this.assistDataSource = new L("assistDataSource"), this.afterAddPointFun = () => {
399
+ this.polygonDrawer.getPositions().length > 1 && (this.openTmpLabel = !0);
400
+ }, this.movingCallbackFun = (e) => {
401
+ if (this.openTmpLabel && this.tmpLabel) {
402
+ const s = [...this.polygonDrawer.getPositions(), e], a = m(s), l = F(s);
403
+ a && (this.tmpLabel.show = !0, this.tmpLabel.position = new d(a), this.tmpLabel.label && (this.tmpLabel.label.text = new u(l)));
404
+ }
405
+ }, this.editCallbackFun = (e) => {
406
+ if (this.openTmpLabel && this.totalLabel) {
407
+ const s = [...this.polygonDrawer.getPositions(), e], a = m(s), l = F(s);
408
+ a && (this.totalLabel.show = !0, this.totalLabel.position = new d(a), this.totalLabel.label && (this.totalLabel.label.text = new u(l)));
409
+ }
410
+ }, this.overCallbackFun = () => {
411
+ if (this.tmpLabel && (this.tmpLabel.show = !1), !this.totalLabel) {
412
+ const e = this.polygonDrawer.getPositions(), i = m(e), s = F(e);
413
+ if (i) {
414
+ const a = this.createTextlabel(i, s, o.BLACK);
415
+ this.totalLabel = this.assistDataSource.entities.add(a);
416
+ }
417
+ }
418
+ }, this.createTextlabel = (e, i, s = o.DARKRED, a = 0) => {
419
+ const l = {
420
+ text: i,
421
+ font: "12px sans-serif bold",
422
+ fillColor: o.WHITE,
423
+ showBackground: !0,
424
+ backgroundColor: s,
425
+ style: C.FILL_AND_OUTLINE,
426
+ horizontalOrigin: f.CENTER,
427
+ verticalOrigin: S.CENTER,
428
+ pixelOffset: new v(0, a)
429
+ //偏移量
430
+ };
431
+ return {
432
+ position: e,
433
+ label: l
434
+ };
435
+ }, this.createTmplabel = () => {
436
+ let i = {
437
+ position: new b(),
438
+ label: {
439
+ text: "",
440
+ font: "12px sans-serif bold",
441
+ fillColor: o.WHITE,
442
+ showBackground: !0,
443
+ backgroundColor: o.BLACK.withAlpha(0.6),
444
+ style: C.FILL_AND_OUTLINE,
445
+ horizontalOrigin: f.LEFT,
446
+ verticalOrigin: S.BOTTOM
447
+ },
448
+ show: !1
449
+ };
450
+ return this.assistDataSource.entities.add(i);
451
+ }, this.reCreateAll = () => {
452
+ this.dataSource.entities.removeAll(), this.assistDataSource.entities.removeAll();
453
+ const e = this.polygonDrawer.getPositions(), i = m(e), s = F(e);
454
+ if (i) {
455
+ const a = this.createTextlabel(i, s, o.BLACK);
456
+ this.totalLabel = this.assistDataSource.entities.add(a);
457
+ }
458
+ }, this.viewer = t, this.viewer.dataSources.add(this.dataSource), this.viewer.dataSources.add(this.assistDataSource), this.init(n);
459
+ }
460
+ start() {
461
+ var t;
462
+ (t = this.polygonDrawer) == null || t.start(), this.tmpLabel = this.createTmplabel();
463
+ }
464
+ getStatus() {
465
+ var t;
466
+ (t = this.polygonDrawer) == null || t.getStatus();
467
+ }
468
+ setEditStatus() {
469
+ var t;
470
+ (t = this.polygonDrawer) == null || t.setEditStatus(), this.overCallbackFun();
471
+ }
472
+ setDelStatus() {
473
+ var t;
474
+ (t = this.polygonDrawer) == null || t.setDelStatus(), this.overCallbackFun();
475
+ }
476
+ clearAll() {
477
+ var t;
478
+ (t = this.polygonDrawer) == null || t.clearAll(), this.dataSource.entities.removeAll(), this.assistDataSource.entities.removeAll();
479
+ }
480
+ init(t) {
481
+ let e = { ...{
482
+ drawerMode: W.POLYGON,
483
+ afterAddPointFun: this.afterAddPointFun,
484
+ movingCallbackFun: this.movingCallbackFun,
485
+ editCallbackFun: this.editCallbackFun,
486
+ overCallbackFun: this.overCallbackFun,
487
+ delCallbackFun: this.reCreateAll
488
+ }, ...t };
489
+ this.polygonDrawer = new P(this.viewer, e);
490
+ }
491
+ }
492
+ export {
493
+ X as C,
494
+ J as L,
495
+ K as P,
496
+ V as R,
497
+ Q as a
498
+ };
package/README.md CHANGED
@@ -1,8 +1,8 @@
1
1
 
2
- # <img src="/logo.svg" width="28px" alt="示例图"/>cesium-pocket
2
+ # <img src="http://cesium-pocket.com/logo.svg" width="28px" alt="示例图"/>cesium-pocket
3
3
  Cesium + Vue3 + Vite 的口袋式轻量级组件工具库。服务于webGIS开发人员,面向三维数字孪生,可视化大屏业务场景。
4
4
  作者联系方式 微信:brilliant201306
5
- 官方网站:<a href="https://cesium-pocket.com">cesium-pocket官网</a>
5
+ 官方网站:<a href="http://cesium-pocket.com">cesium-pocket官网</a>
6
6
 
7
7
 
8
8
 
@@ -58,7 +58,6 @@ app.use(CesiumPocket)
58
58
  ```
59
59
 
60
60
 
61
-
62
61
  ## 4. 参考资料:
63
62
  <p>cesium相关内容请参考 <a href="https://cesium.com">cesium官网</a></p>
64
63
  <p>cesium相关内容请参考 <a href="https://threejs.org/">threejs官网</a></p>
package/drawer.d.ts CHANGED
@@ -2,6 +2,6 @@ import { PointDrawer } from './src/drawer/PointDrawer.ts';
2
2
  import { CP2dDrawer, CP2dOptions, DRAWER_MODE, DRAWER_MODE_TYPE } from './src/drawer/CP2dDrawer.ts';
3
3
  import { RectDrawer, RectOptions } from './src/drawer/RectDrawer.ts';
4
4
  import { CircleDrawer, CircleOptions } from './src/drawer/CircleDrawer.ts';
5
- import { DelCallbackFn } from './src/drawer/DataCenter.ts';
5
+ import { DelConfirmFn } from './src/drawer/DataCenter.ts';
6
6
  import { DRAW_STATUS, DRAW_STATUS_TYPE } from './src/drawer/DrawerStatus.ts';
7
- export { PointDrawer, CP2dDrawer, RectDrawer, CircleDrawer, DRAW_STATUS, type DRAW_STATUS_TYPE, DRAWER_MODE, type DRAWER_MODE_TYPE, type CircleOptions, type RectOptions, type CP2dOptions, type DelCallbackFn };
7
+ export { PointDrawer, CP2dDrawer, RectDrawer, CircleDrawer, DRAW_STATUS, type DRAW_STATUS_TYPE, DRAWER_MODE, type DRAWER_MODE_TYPE, type CircleOptions, type RectOptions, type CP2dOptions, type DelConfirmFn };
package/drawer.js CHANGED
@@ -1,4 +1,4 @@
1
- import { C as D, a as e, b as s, D as R, P as w, R as o } from "./CircleDrawer-RdBslwFS.js";
1
+ import { C as D, a as e, b as s, D as R, P as w, R as o } from "./CircleDrawer-DotSQduG.js";
2
2
  export {
3
3
  D as CP2dDrawer,
4
4
  e as CircleDrawer,
package/gauger.d.ts ADDED
@@ -0,0 +1,6 @@
1
+ import { CircleGaguger, CircleGaugerOptions } from './src/gauger/CircleGaguger.ts';
2
+ import { RectGaguger, RectGaugerOptions } from './src/gauger/RectGaguger.ts';
3
+ import { PointGauger, PointGaugerOptions } from './src/gauger/PointGaguger.ts';
4
+ import { LineGaguger, LineGaugerOptions } from './src/gauger/LineGaguger.ts';
5
+ import { PolygonGaguger, PolygonGaugerOptions } from './src/gauger/PolygonGaguger.ts';
6
+ export { CircleGaguger, RectGaguger, PointGauger, LineGaguger, PolygonGaguger, type CircleGaugerOptions, type RectGaugerOptions, type PointGaugerOptions, type LineGaugerOptions, type PolygonGaugerOptions };
package/gauger.js ADDED
@@ -0,0 +1,8 @@
1
+ import { C as e, L as r, P as o, a as s, R as u } from "./PolygonGaguger-HRGTFdqB.js";
2
+ export {
3
+ e as CircleGaguger,
4
+ r as LineGaguger,
5
+ o as PointGauger,
6
+ s as PolygonGaguger,
7
+ u as RectGaguger
8
+ };
package/index.d.ts CHANGED
@@ -13,3 +13,4 @@ export { cpCompass, cpRuler, cpCoord, cpOverlay, cpPin, cpTianmap };
13
13
  export * from './pin.ts';
14
14
  export * from './tianmap.ts';
15
15
  export * from './drawer.ts';
16
+ export * from './gauger.ts';
package/index.js CHANGED
@@ -3,7 +3,8 @@ import * as PA from "three";
3
3
  import { TrianglesDrawMode as tP, TriangleFanDrawMode as EA, TriangleStripDrawMode as SA, Loader as sP, LoaderUtils as F, FileLoader as qA, Color as S, LinearSRGBColorSpace as H, SpotLight as BP, PointLight as rP, DirectionalLight as vP, MeshBasicMaterial as W, SRGBColorSpace as R, MeshPhysicalMaterial as y, Vector2 as VA, Matrix4 as tA, Vector3 as K, Quaternion as hA, InstancedMesh as gP, InstancedBufferAttribute as CP, Object3D as JA, TextureLoader as DP, ImageBitmapLoader as wP, BufferAttribute as BA, InterleavedBuffer as QP, InterleavedBufferAttribute as cP, LinearMipmapLinearFilter as YA, NearestMipmapLinearFilter as IP, LinearMipmapNearestFilter as EP, NearestMipmapNearestFilter as zP, LinearFilter as zA, NearestFilter as NA, RepeatWrapping as TA, MirroredRepeatWrapping as TP, ClampToEdgeWrapping as lP, PointsMaterial as oP, Material as rA, LineBasicMaterial as aP, MeshStandardMaterial as KA, DoubleSide as MP, PropertyBinding as uP, BufferGeometry as pP, SkinnedMesh as bP, Mesh as iP, LineSegments as fP, Line as UP, LineLoop as yP, Points as dP, Group as vA, PerspectiveCamera as jP, MathUtils as HP, OrthographicCamera as mP, Skeleton as kP, AnimationClip as LP, Bone as OP, InterpolateDiscrete as SP, InterpolateLinear as XA, ColorManagement as MA, Texture as uA, VectorKeyframeTrack as pA, NumberKeyframeTrack as bA, QuaternionKeyframeTrack as iA, FrontSide as qP, Interpolant as VP, Box3 as hP, Sphere as JP } from "three";
4
4
  import { Viewer as h, Math as _, Cartesian2 as eA, Cartesian3 as L, Cartographic as ZA, SceneTransforms as YP, Ray as NP, Color as KP, ScreenSpaceEventType as gA, ScreenSpaceEventHandler as XP, createWorldTerrainAsync as ZP, EllipsoidTerrainProvider as GP, WebMapTileServiceImageryProvider as Y, Credit as N } from "cesium";
5
5
  import { P as G, a as fA, b as xP, c as WP, d as FP, C as UA } from "./index-CcaLwHv1.js";
6
- import { C as Mn, a as un, b as pn, D as bn, P as fn, R as Un } from "./CircleDrawer-RdBslwFS.js";
6
+ import { C as Mn, a as un, b as pn, D as bn, P as fn, R as Un } from "./CircleDrawer-DotSQduG.js";
7
+ import { C as dn, L as jn, P as Hn, a as mn, R as kn } from "./PolygonGaguger-HRGTFdqB.js";
7
8
  function yA(D, A) {
8
9
  if (A === tP)
9
10
  return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."), D;
@@ -2399,12 +2400,17 @@ const He = /* @__PURE__ */ q({
2399
2400
  export {
2400
2401
  Mn as CP2dDrawer,
2401
2402
  un as CircleDrawer,
2403
+ dn as CircleGaguger,
2402
2404
  pn as DRAWER_MODE,
2403
2405
  bn as DRAW_STATUS,
2406
+ jn as LineGaguger,
2404
2407
  fA as PIN_CATEGORY,
2405
2408
  G as PIN_MODE,
2406
2409
  fn as PointDrawer,
2410
+ Hn as PointGauger,
2411
+ mn as PolygonGaguger,
2407
2412
  Un as RectDrawer,
2413
+ kn as RectGaguger,
2408
2414
  me as cpCompass,
2409
2415
  Ve as cpCoord,
2410
2416
  Fe as cpOverlay,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cesium-pocket",
3
- "version": "0.3.2-alpha",
3
+ "version": "0.3.6-alpha",
4
4
  "description": "cesium的插件库;基于vue3的开发",
5
5
  "module": "./index.js",
6
6
  "types": "./index.d.ts",
@@ -20,6 +20,10 @@
20
20
  "./drawer": {
21
21
  "import": "./drawer.js",
22
22
  "types": "./drawer.d.ts"
23
+ },
24
+ "./gauger": {
25
+ "import": "./gauger.js",
26
+ "types": "./gauger.d.ts"
23
27
  },
24
28
  "./*": "./*"
25
29
  },
@@ -1,5 +1,5 @@
1
- import { Viewer, PolylineGraphics, PolygonGraphics, PointGraphics } from 'cesium';
2
- import { DataCenter, DelCallbackFn } from './DataCenter.ts';
1
+ import { Cartesian3, Viewer, PolylineGraphics, PolygonGraphics, PointGraphics } from 'cesium';
2
+ import { DataCenter, VoidCallbackFn, DelConfirmFn, NoPropCallbackFn, EditCallbackFn } from './DataCenter.ts';
3
3
  export declare const DRAWER_MODE: {
4
4
  readonly LINE: symbol;
5
5
  readonly POLYGON: symbol;
@@ -11,7 +11,12 @@ export type CP2dOptions = {
11
11
  polygon?: PolygonGraphics.ConstructorOptions;
12
12
  polyline?: PolylineGraphics.ConstructorOptions;
13
13
  deshline?: PolylineGraphics.ConstructorOptions;
14
- delCallbackFun?: DelCallbackFn;
14
+ afterAddPointFun?: VoidCallbackFn;
15
+ movingCallbackFun?: VoidCallbackFn;
16
+ editCallbackFun?: EditCallbackFn;
17
+ delConfirmFun?: DelConfirmFn;
18
+ delCallbackFun?: NoPropCallbackFn;
19
+ overCallbackFun?: NoPropCallbackFn;
15
20
  } | null;
16
21
  export declare class CP2dDrawer extends DataCenter {
17
22
  private handler?;
@@ -23,14 +28,18 @@ export declare class CP2dDrawer extends DataCenter {
23
28
  private polygon;
24
29
  private deshline;
25
30
  private drawerMode;
31
+ private overCallbackFun;
26
32
  constructor(viewer: Viewer, options?: CP2dOptions);
27
33
  start(): void;
28
34
  getEntity(): any;
35
+ getPositions(): Cartesian3[];
29
36
  clearAll(): void;
30
- private line_L_ClickEvent;
31
- private line_L_DownEvent;
32
- private line_L_UpEvent;
33
- private line_moveEvent;
37
+ private r_ClickEvent;
38
+ private l_ClickEvent;
39
+ private l_DownEvent;
40
+ private l_UpEvent;
41
+ private moveEvent;
42
+ protected editMoveFun(event: any, cartesian: Cartesian3): void;
34
43
  private createMainLine;
35
44
  private createMainPolygon;
36
45
  private createDashline;