@vesium/plot 1.0.1-beta.50 → 1.0.1-beta.52

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.cjs CHANGED
@@ -1,1465 +1,3055 @@
1
- "use strict";
1
+ //#region rolldown:runtime
2
+ var __create = Object.create;
2
3
  var __defProp = Object.defineProperty;
3
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
4
- var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
5
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
6
- const cesium = require("cesium");
7
- const vesium = require("vesium");
8
- const core = require("@vueuse/core");
9
- const vue = require("vue");
10
- const _PlotScheme = class _PlotScheme {
11
- constructor(options) {
12
- /**
13
- * 标绘类型。应当是全局唯一的字符串,会作为键名缓存
14
- */
15
- __publicField(this, "type");
16
- /**
17
- * 判断是否立即完成标绘.
18
- * 每次控制点发生变变化时,执行该回调函数,返回`true`则完成标绘
19
- */
20
- __publicField(this, "complete");
21
- /**
22
- * 判断是否允许手动完成标绘。
23
- * 每次控制点发生变变化时,执行该回调函数,返回`true`则后续左键双击即完成标绘
24
- */
25
- __publicField(this, "allowManualComplete");
26
- /**
27
- * 处于定义态时鼠标的样式
28
- * @default 'crosshair'
29
- */
30
- __publicField(this, "definingCursor");
31
- /**
32
- * 当前标绘的框架点数据
33
- */
34
- __publicField(this, "skeletons");
35
- /**
36
- * 初始化时创建`Entity`的函数,创建后的`Entity`会作为配置项传入`render`中
37
- */
38
- __publicField(this, "initEntites");
39
- /**
40
- * 初始化时创建`Primitive`的函数,创建后的`Primitive`会作为配置项传入`render`中
41
- */
42
- __publicField(this, "initPrimitives");
43
- /**
44
- * 初始化时创建贴地`Primitive`的函数,创建后的`Primitive`会作为配置项传入`render`中
45
- */
46
- __publicField(this, "initGroundPrimitives");
47
- /**
48
- * 当标绘数据变化时,会触发`render`回调,返回的数据会被添加到cesium中
49
- */
50
- __publicField(this, "render");
51
- var _a;
52
- this.type = options.type;
53
- this.complete = options.complete;
54
- this.allowManualComplete = options.allowManualComplete;
55
- this.definingCursor = options.definingCursor ?? "crosshair";
56
- this.skeletons = ((_a = options.skeletons) == null ? void 0 : _a.map((item) => item())) ?? [];
57
- this.initEntites = options.initEntites;
58
- this.initPrimitives = options.initPrimitives;
59
- this.initGroundPrimitives = options.initGroundPrimitives;
60
- this.render = options.render;
61
- }
62
- /**
63
- * 标绘方案缓存。
64
- * 每次标绘时都会将`PlotScheme.type`作为键名缓存,
65
- * 后续可用过`PlotScheme.getCache(type)`获取完整的`PlotScheme`配置。
66
- */
67
- static getCacheTypes() {
68
- return [...this._record.keys()];
69
- }
70
- /**
71
- * 通过`PlotScheme.type`获取缓存中的`PlotScheme`配置。
72
- */
73
- static getCache(type) {
74
- return _PlotScheme._record.get(type);
75
- }
76
- /**
77
- * 缓存标绘方案。
78
- */
79
- static setCache(scheme) {
80
- vesium.assertError(!scheme.type, "`scheme.type` is required");
81
- _PlotScheme._record.set(scheme.type, scheme);
82
- }
83
- /**
84
- * 解析传入的maybeScheme,maybeScheme可能是一个完整的PlotScheme,也可能是缓存中的`PlotScheme.type`,并返回 PlotScheme 实例。
85
- * 若传入的是`PlotScheme.type`字符串,并且缓存中不存在该标绘方案,则抛出错误。
86
- */
87
- static resolve(maybeScheme) {
88
- if (typeof maybeScheme === "string") {
89
- const _scheme = _PlotScheme.getCache(maybeScheme);
90
- core.assert(!!_scheme, `scheme ${maybeScheme} not found`);
91
- return _scheme;
92
- } else if (!(maybeScheme instanceof _PlotScheme)) {
93
- return new _PlotScheme(maybeScheme);
94
- } else {
95
- return maybeScheme;
96
- }
97
- }
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __copyProps = (to, from, except, desc) => {
9
+ if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
10
+ key = keys[i];
11
+ if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
12
+ get: ((k) => from[k]).bind(null, key),
13
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
14
+ });
15
+ }
16
+ return to;
98
17
  };
99
- __publicField(_PlotScheme, "_record", /* @__PURE__ */ new Map());
100
- let PlotScheme = _PlotScheme;
101
- var SampledPlotStrategy = /* @__PURE__ */ ((SampledPlotStrategy2) => {
102
- SampledPlotStrategy2[SampledPlotStrategy2["NEAR"] = 0] = "NEAR";
103
- SampledPlotStrategy2[SampledPlotStrategy2["CYCLE"] = 1] = "CYCLE";
104
- SampledPlotStrategy2[SampledPlotStrategy2["STRICT"] = 2] = "STRICT";
105
- return SampledPlotStrategy2;
106
- })(SampledPlotStrategy || {});
18
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
19
+ value: mod,
20
+ enumerable: true
21
+ }) : target, mod));
22
+
23
+ //#endregion
24
+ const cesium = __toESM(require("cesium"));
25
+ const vesium = __toESM(require("vesium"));
26
+ const __vueuse_core = __toESM(require("@vueuse/core"));
27
+ const vue = __toESM(require("vue"));
28
+ const __turf_turf = __toESM(require("@turf/turf"));
29
+
30
+ //#region usePlot/PlotScheme.ts
31
+ var PlotScheme = class PlotScheme {
32
+ constructor(options) {
33
+ this.type = options.type;
34
+ this.complete = options.complete;
35
+ this.allowManualComplete = options.allowManualComplete;
36
+ this.definingCursor = options.definingCursor ?? "crosshair";
37
+ this.skeletons = options.skeletons?.map((item) => item()) ?? [];
38
+ this.initRender = options.initRender;
39
+ this.render = options.render;
40
+ }
41
+ /**
42
+ * 标绘类型。应当是全局唯一的字符串,会作为键名缓存
43
+ */
44
+ type;
45
+ /**
46
+ * 判断是否立即完成标绘.
47
+ * 每次控制点发生变变化时,执行该回调函数,返回`true`则完成标绘
48
+ */
49
+ complete;
50
+ /**
51
+ * 判断是否允许手动完成标绘。
52
+ * 每次控制点发生变变化时,执行该回调函数,返回`true`则后续左键双击即完成标绘
53
+ */
54
+ allowManualComplete;
55
+ /**
56
+ * 处于定义态时鼠标的样式
57
+ * @default 'crosshair'
58
+ */
59
+ definingCursor;
60
+ /**
61
+ * 当前标绘的框架点数据
62
+ */
63
+ skeletons;
64
+ /**
65
+ * 初始化时创建贴地`Primitive`的函数,创建后的`Primitive`会作为配置项传入`render`中
66
+ */
67
+ initRender;
68
+ /**
69
+ * 当标绘数据变化时,会触发`render`回调,返回的数据会被添加到cesium中
70
+ */
71
+ render;
72
+ static _record = /* @__PURE__ */ new Map();
73
+ /**
74
+ * 标绘方案缓存。
75
+ * 每次标绘时都会将`PlotScheme.type`作为键名缓存,
76
+ * 后续可用过`PlotScheme.getCache(type)`获取完整的`PlotScheme`配置。
77
+ */
78
+ static getCacheTypes() {
79
+ return [...this._record.keys()];
80
+ }
81
+ /**
82
+ * 通过`PlotScheme.type`获取缓存中的`PlotScheme`配置。
83
+ */
84
+ static getCache(type) {
85
+ return PlotScheme._record.get(type);
86
+ }
87
+ /**
88
+ * 缓存标绘方案。
89
+ */
90
+ static setCache(scheme) {
91
+ (0, vesium.assertError)(!scheme.type, "`scheme.type` is required");
92
+ PlotScheme._record.set(scheme.type, scheme);
93
+ }
94
+ /**
95
+ * 解析传入的maybeScheme,maybeScheme可能是一个完整的PlotScheme,也可能是缓存中的`PlotScheme.type`,并返回 PlotScheme 实例。
96
+ * 若传入的是`PlotScheme.type`字符串,并且缓存中不存在该标绘方案,则抛出错误。
97
+ */
98
+ static resolve(maybeScheme) {
99
+ if (typeof maybeScheme === "string") {
100
+ const _scheme = PlotScheme.getCache(maybeScheme);
101
+ (0, __vueuse_core.assert)(!!_scheme, `scheme ${maybeScheme} not found`);
102
+ return _scheme;
103
+ } else if (!(maybeScheme instanceof PlotScheme)) return new PlotScheme(maybeScheme);
104
+ else return maybeScheme;
105
+ }
106
+ };
107
+
108
+ //#endregion
109
+ //#region usePlot/SampledPlotProperty.ts
110
+ let SampledPlotStrategy = /* @__PURE__ */ function(SampledPlotStrategy$1) {
111
+ SampledPlotStrategy$1[SampledPlotStrategy$1["NEAR"] = 0] = "NEAR";
112
+ SampledPlotStrategy$1[SampledPlotStrategy$1["CYCLE"] = 1] = "CYCLE";
113
+ SampledPlotStrategy$1[SampledPlotStrategy$1["STRICT"] = 2] = "STRICT";
114
+ return SampledPlotStrategy$1;
115
+ }({});
116
+ /**
117
+ * 默认插值算法
118
+ *
119
+ * @param time 时间
120
+ * @param previous 前一个数据点
121
+ * @param next 后一个数据点
122
+ * @param proportion 比例
123
+ * @returns 插值结果
124
+ */
107
125
  const defaultInterpolationAlgorithm = (time, previous, next, proportion) => {
108
- var _a, _b, _c;
109
- if (proportion === 0) {
110
- return {
111
- time,
112
- positions: (_a = previous.positions) == null ? void 0 : _a.map((item) => item.clone()),
113
- derivative: previous.derivative
114
- };
115
- } else if (proportion === 1) {
116
- return {
117
- time,
118
- positions: (_b = next.positions) == null ? void 0 : _b.map((item) => item.clone()),
119
- derivative: previous.derivative
120
- };
121
- }
122
- return {
123
- time,
124
- positions: (_c = next.positions) == null ? void 0 : _c.map((right, index) => {
125
- var _a2;
126
- const left = (_a2 = previous.positions) == null ? void 0 : _a2[index];
127
- return !left ? right : cesium.Cartesian3.lerp(left, right, proportion, new cesium.Cartesian3());
128
- }),
129
- derivative: previous.derivative
130
- };
126
+ if (proportion === 0) return {
127
+ time,
128
+ positions: previous.positions?.map((item) => item.clone()),
129
+ derivative: previous.derivative
130
+ };
131
+ else if (proportion === 1) return {
132
+ time,
133
+ positions: next.positions?.map((item) => item.clone()),
134
+ derivative: previous.derivative
135
+ };
136
+ return {
137
+ time,
138
+ positions: next.positions?.map((right, index) => {
139
+ const left = previous.positions?.[index];
140
+ return !left ? right : cesium.Cartesian3.lerp(left, right, proportion, new cesium.Cartesian3());
141
+ }),
142
+ derivative: previous.derivative
143
+ };
131
144
  };
132
- const _SampledPlotProperty = class _SampledPlotProperty {
133
- constructor(options) {
134
- __publicField(this, "strategy");
135
- __publicField(this, "interpolationAlgorithm");
136
- /**
137
- * @internal
138
- */
139
- __publicField(this, "_times", []);
140
- /**
141
- * @internal
142
- */
143
- __publicField(this, "_sampleds", []);
144
- /**
145
- * @internal
146
- */
147
- __publicField(this, "_derivatives", []);
148
- /**
149
- * @internal
150
- */
151
- __publicField(this, "_definitionChanged", new cesium.Event());
152
- var _a;
153
- this.interpolationAlgorithm = options == null ? void 0 : options.interpolationAlgorithm;
154
- this.strategy = (options == null ? void 0 : options.strategy) ?? 0;
155
- (_a = options == null ? void 0 : options.packables) == null ? void 0 : _a.forEach((packable) => this.setSample(packable));
156
- if (!this._times.length) {
157
- this.setSample({
158
- time: new cesium.JulianDate(0, 0),
159
- positions: [],
160
- derivative: void 0
161
- });
162
- }
163
- }
164
- get isConstant() {
165
- return this._times.length === 0;
166
- }
167
- get definitionChanged() {
168
- return this._definitionChanged;
169
- }
170
- /**
171
- * 获取时间数组
172
- *
173
- * @returns 返回包含所有时间的 JulianDate 数组
174
- */
175
- getTimes() {
176
- return this._times.map((t) => t.clone());
177
- }
178
- /**
179
- * 根据给定的儒略日期获取时间索引范围及比例
180
- *
181
- * @param time 给定的儒略日期
182
- * @returns 返回包含前一个索引、后一个索引及时间比例的对象,若不符合条件则返回undefined
183
- * @internal
184
- */
185
- getIndexScope(time) {
186
- if (!this._times.length) {
187
- return;
188
- }
189
- const start = this._times[0];
190
- const end = this._times[this._times.length - 1];
191
- if (cesium.JulianDate.lessThan(time, start) || cesium.JulianDate.greaterThan(time, end)) {
192
- switch (this.strategy) {
193
- case 2: {
194
- return;
195
- }
196
- case 0: {
197
- time = cesium.JulianDate.lessThan(time, this._times[0]) ? this._times[0].clone() : this._times[this._times.length - 1].clone();
198
- break;
199
- }
200
- case 1: {
201
- const startMS = cesium.JulianDate.toDate(this._times[0]).getTime();
202
- const endMS = cesium.JulianDate.toDate(this._times[this._times.length - 1]).getTime();
203
- const duration = endMS - startMS;
204
- const timeMS = cesium.JulianDate.toDate(time).getTime();
205
- const diff = (timeMS - startMS) % duration;
206
- const dete = new Date(startMS + diff);
207
- time = cesium.JulianDate.fromDate(dete);
208
- break;
209
- }
210
- }
211
- }
212
- const prevIndex = this._times.findIndex((t) => cesium.JulianDate.lessThanOrEquals(time, t));
213
- const nextIndex = Math.min(prevIndex, this._times.length - 1);
214
- const prevMs = cesium.JulianDate.toDate(this._times[prevIndex]).getTime();
215
- const nextMs = cesium.JulianDate.toDate(this._times[nextIndex]).getTime();
216
- const ms = cesium.JulianDate.toDate(time).getTime();
217
- return {
218
- prevIndex,
219
- nextIndex,
220
- proportion: (ms - prevMs) / (nextMs - prevMs) || 0
221
- };
222
- }
223
- /**
224
- * 根据给定的儒略日期(JulianDate)获取插值后的样本点数据。
225
- *
226
- * @param time 指定的儒略日期(JulianDate)。
227
- * @param result 可选参数,用于存储结果的容器。如果未提供,则创建一个新的容器。
228
- * @returns 插值后的样本点数据,存储在提供的或新创建的result容器中。
229
- * @template D 数据类型。
230
- */
231
- getValue(time, result) {
232
- var _a;
233
- result ?? (result = { time });
234
- Object.assign(result, {
235
- time: time == null ? void 0 : time.clone(),
236
- positions: void 0,
237
- derivative: void 0
238
- });
239
- if (!time) {
240
- result.time = this._times[0].clone();
241
- result.positions = (_a = this._sampleds[0]) == null ? void 0 : _a.map((c) => c.clone(c));
242
- result.derivative = this._derivatives[0];
243
- return result;
244
- }
245
- const scope = this.getIndexScope(time);
246
- if (!scope) {
247
- return result;
248
- }
249
- result.time = time;
250
- const { prevIndex, nextIndex, proportion } = scope;
251
- const previous = {
252
- time: this._times[prevIndex],
253
- positions: this._sampleds[prevIndex],
254
- derivative: this._derivatives[prevIndex]
255
- };
256
- const next = {
257
- time: this._times[nextIndex],
258
- positions: this._sampleds[nextIndex],
259
- derivative: this._derivatives[nextIndex]
260
- };
261
- const packable = (this.interpolationAlgorithm || _SampledPlotProperty.defaultInterpolationAlgorithm)(time, previous, next, proportion);
262
- Object.assign(result, packable);
263
- return result;
264
- }
265
- /**
266
- * 设置样本数据,如果传入的数据不含时间,则会存入时间最早的集合中
267
- * @param value 样本数据对象,包含时间、位置和导数信息
268
- */
269
- setSample(value) {
270
- var _a, _b;
271
- const time = ((_a = value.time) == null ? void 0 : _a.clone()) ?? this._times[0].clone();
272
- const positions = ((_b = value.positions) == null ? void 0 : _b.map((item) => item.clone())) ?? [];
273
- const derivative = value.derivative;
274
- const index = this._times.findIndex((t) => cesium.JulianDate.equals(time, t));
275
- if (index !== -1) {
276
- this._times[index] = time;
277
- this._sampleds[index] = positions;
278
- this._derivatives[index] = value.derivative;
279
- } else if (this._times.length === 0) {
280
- this._times[0] = time;
281
- this._sampleds[0] = positions;
282
- this._derivatives[0] = value.derivative;
283
- } else if (cesium.JulianDate.lessThan(time, this._times[0])) {
284
- this._times.splice(0, 0, time);
285
- this._sampleds.splice(0, 0, positions);
286
- this._derivatives.splice(0, 0, derivative);
287
- } else if (cesium.JulianDate.greaterThan(time, this._times[this._times.length - 1])) {
288
- this._times.push(time);
289
- this._sampleds.push(positions);
290
- this._derivatives.push(derivative);
291
- }
292
- this.definitionChanged.raiseEvent(this);
293
- }
294
- /**
295
- * 设置样本数据
296
- *
297
- * @param values 样本数据数组,每个元素都是类型为SampledPlotPackable<D>的对象
298
- */
299
- setSamples(values) {
300
- values.forEach((value) => this.setSample(value));
301
- }
302
- /**
303
- * 从样本中移除指定时间点的数据
304
- *
305
- * @param time 需要移除的时间点,使用儒略日期表示
306
- * @returns 如果成功移除,则返回 true;否则返回 false
307
- */
308
- removeSample(time) {
309
- const index = this._times.findIndex((t) => t.equals(time));
310
- if (index !== -1) {
311
- this._sampleds.splice(index, 1);
312
- this._derivatives.splice(index, 1);
313
- const removed = this._times.splice(index, 1);
314
- if (removed.length) {
315
- this._definitionChanged.raiseEvent(this);
316
- return true;
317
- }
318
- }
319
- return false;
320
- }
321
- /**
322
- * 从样本中移除指定时间间隔内的样本。
323
- *
324
- * @param interval 要移除样本的时间间隔
325
- */
326
- removeSamples(interval2) {
327
- for (let i = 0; i < this._times.length; i++) {
328
- const time = this._times[i];
329
- cesium.TimeInterval.contains(interval2, time) && this.removeSample(time);
330
- }
331
- }
332
- /**
333
- * 判断两个property是否相等
334
- */
335
- equals(other) {
336
- return other === this;
337
- }
145
+ /**
146
+ * 标绘采样点数据。
147
+ * 标绘采样点数据是一个时间序列数据,包含时间、位置和附带的额外数据。
148
+ * 具体用法可参考 [Cesium.SampledProperty](https://cesium.com/learn/cesiumjs/ref-doc/SampledProperty.html)
149
+ */
150
+ var SampledPlotProperty = class SampledPlotProperty {
151
+ constructor(options) {
152
+ this.interpolationAlgorithm = options?.interpolationAlgorithm;
153
+ this.strategy = options?.strategy ?? SampledPlotStrategy.NEAR;
154
+ options?.packables?.forEach((packable) => this.setSample(packable));
155
+ if (!this._times.length) this.setSample({
156
+ time: new cesium.JulianDate(0, 0),
157
+ positions: [],
158
+ derivative: void 0
159
+ });
160
+ }
161
+ static defaultInterpolationAlgorithm = defaultInterpolationAlgorithm;
162
+ strategy;
163
+ interpolationAlgorithm;
164
+ /**
165
+ * @internal
166
+ */
167
+ _times = [];
168
+ /**
169
+ * @internal
170
+ */
171
+ _sampleds = [];
172
+ /**
173
+ * @internal
174
+ */
175
+ _derivatives = [];
176
+ get isConstant() {
177
+ return this._times.length === 0;
178
+ }
179
+ /**
180
+ * @internal
181
+ */
182
+ _definitionChanged = new cesium.Event();
183
+ get definitionChanged() {
184
+ return this._definitionChanged;
185
+ }
186
+ /**
187
+ * 获取时间数组
188
+ *
189
+ * @returns 返回包含所有时间的 JulianDate 数组
190
+ */
191
+ getTimes() {
192
+ return this._times.map((t) => t.clone());
193
+ }
194
+ /**
195
+ * 根据给定的儒略日期获取时间索引范围及比例
196
+ *
197
+ * @param time 给定的儒略日期
198
+ * @returns 返回包含前一个索引、后一个索引及时间比例的对象,若不符合条件则返回undefined
199
+ * @internal
200
+ */
201
+ getIndexScope(time) {
202
+ if (!this._times.length) return;
203
+ const start = this._times[0];
204
+ const end = this._times[this._times.length - 1];
205
+ if (cesium.JulianDate.lessThan(time, start) || cesium.JulianDate.greaterThan(time, end)) switch (this.strategy) {
206
+ case SampledPlotStrategy.STRICT: return;
207
+ case SampledPlotStrategy.NEAR: {
208
+ time = cesium.JulianDate.lessThan(time, this._times[0]) ? this._times[0].clone() : this._times[this._times.length - 1].clone();
209
+ break;
210
+ }
211
+ case SampledPlotStrategy.CYCLE: {
212
+ const startMS = cesium.JulianDate.toDate(this._times[0]).getTime();
213
+ const endMS = cesium.JulianDate.toDate(this._times[this._times.length - 1]).getTime();
214
+ const duration = endMS - startMS;
215
+ const timeMS = cesium.JulianDate.toDate(time).getTime();
216
+ const diff = (timeMS - startMS) % duration;
217
+ const dete = new Date(startMS + diff);
218
+ time = cesium.JulianDate.fromDate(dete);
219
+ break;
220
+ }
221
+ }
222
+ const prevIndex = this._times.findIndex((t) => cesium.JulianDate.lessThanOrEquals(time, t));
223
+ const nextIndex = Math.min(prevIndex, this._times.length - 1);
224
+ const prevMs = cesium.JulianDate.toDate(this._times[prevIndex]).getTime();
225
+ const nextMs = cesium.JulianDate.toDate(this._times[nextIndex]).getTime();
226
+ const ms = cesium.JulianDate.toDate(time).getTime();
227
+ return {
228
+ prevIndex,
229
+ nextIndex,
230
+ proportion: (ms - prevMs) / (nextMs - prevMs) || 0
231
+ };
232
+ }
233
+ /**
234
+ * 根据给定的儒略日期(JulianDate)获取插值后的样本点数据。
235
+ *
236
+ * @param time 指定的儒略日期(JulianDate)。
237
+ * @param result 可选参数,用于存储结果的容器。如果未提供,则创建一个新的容器。
238
+ * @returns 插值后的样本点数据,存储在提供的或新创建的result容器中。
239
+ * @template D 数据类型。
240
+ */
241
+ getValue(time, result) {
242
+ result ??= {
243
+ time,
244
+ positions: []
245
+ };
246
+ Object.assign(result, {
247
+ time: time?.clone(),
248
+ positions: [],
249
+ derivative: void 0
250
+ });
251
+ if (!time) {
252
+ result.time = this._times[0].clone();
253
+ result.positions = this._sampleds[0]?.map((c) => c.clone(c));
254
+ result.derivative = this._derivatives[0];
255
+ return result;
256
+ }
257
+ const scope = this.getIndexScope(time);
258
+ if (!scope) return result;
259
+ result.time = time;
260
+ const { prevIndex, nextIndex, proportion } = scope;
261
+ const previous = {
262
+ time: this._times[prevIndex],
263
+ positions: this._sampleds[prevIndex],
264
+ derivative: this._derivatives[prevIndex]
265
+ };
266
+ const next = {
267
+ time: this._times[nextIndex],
268
+ positions: this._sampleds[nextIndex],
269
+ derivative: this._derivatives[nextIndex]
270
+ };
271
+ const packable = (this.interpolationAlgorithm || SampledPlotProperty.defaultInterpolationAlgorithm)(time, previous, next, proportion);
272
+ Object.assign(result, packable);
273
+ return result;
274
+ }
275
+ /**
276
+ * 设置样本数据,如果传入的数据不含时间,则会存入时间最早的集合中
277
+ * @param value 样本数据对象,包含时间、位置和导数信息
278
+ */
279
+ setSample(value) {
280
+ const time = value.time?.clone() ?? this._times[0].clone();
281
+ const positions = value.positions?.map((item) => item.clone()) ?? [];
282
+ const derivative = value.derivative;
283
+ const index = this._times.findIndex((t) => cesium.JulianDate.equals(time, t));
284
+ if (index !== -1) {
285
+ this._times[index] = time;
286
+ this._sampleds[index] = positions;
287
+ this._derivatives[index] = value.derivative;
288
+ } else if (this._times.length === 0) {
289
+ this._times[0] = time;
290
+ this._sampleds[0] = positions;
291
+ this._derivatives[0] = value.derivative;
292
+ } else if (cesium.JulianDate.lessThan(time, this._times[0])) {
293
+ this._times.splice(0, 0, time);
294
+ this._sampleds.splice(0, 0, positions);
295
+ this._derivatives.splice(0, 0, derivative);
296
+ } else if (cesium.JulianDate.greaterThan(time, this._times[this._times.length - 1])) {
297
+ this._times.push(time);
298
+ this._sampleds.push(positions);
299
+ this._derivatives.push(derivative);
300
+ }
301
+ this.definitionChanged.raiseEvent(this);
302
+ }
303
+ /**
304
+ * 设置样本数据
305
+ *
306
+ * @param values 样本数据数组,每个元素都是类型为SampledPlotPackable<D>的对象
307
+ */
308
+ setSamples(values) {
309
+ values.forEach((value) => this.setSample(value));
310
+ }
311
+ /**
312
+ * 从样本中移除指定时间点的数据
313
+ *
314
+ * @param time 需要移除的时间点,使用儒略日期表示
315
+ * @returns 如果成功移除,则返回 true;否则返回 false
316
+ */
317
+ removeSample(time) {
318
+ const index = this._times.findIndex((t) => t.equals(time));
319
+ if (index !== -1) {
320
+ this._sampleds.splice(index, 1);
321
+ this._derivatives.splice(index, 1);
322
+ const removed = this._times.splice(index, 1);
323
+ if (removed.length) {
324
+ this._definitionChanged.raiseEvent(this);
325
+ return true;
326
+ }
327
+ }
328
+ return false;
329
+ }
330
+ /**
331
+ * 从样本中移除指定时间间隔内的样本。
332
+ *
333
+ * @param interval 要移除样本的时间间隔
334
+ */
335
+ removeSamples(interval$1) {
336
+ for (let i = 0; i < this._times.length; i++) {
337
+ const time = this._times[i];
338
+ cesium.TimeInterval.contains(interval$1, time) && this.removeSample(time);
339
+ }
340
+ }
341
+ /**
342
+ * 判断两个property是否相等
343
+ */
344
+ equals(other) {
345
+ return other === this;
346
+ }
338
347
  };
339
- __publicField(_SampledPlotProperty, "defaultInterpolationAlgorithm", defaultInterpolationAlgorithm);
340
- let SampledPlotProperty = _SampledPlotProperty;
341
- class PlotFeature {
342
- constructor(options) {
343
- /**
344
- * @internal
345
- */
346
- __publicField(this, "_id");
347
- /**
348
- * @internal
349
- */
350
- __publicField(this, "_scheme");
351
- /**
352
- * @internal
353
- */
354
- __publicField(this, "_definitionChanged");
355
- /**
356
- * @internal
357
- */
358
- __publicField(this, "_defining");
359
- /**
360
- * @internal
361
- */
362
- __publicField(this, "_disabled");
363
- /**
364
- * @internal
365
- */
366
- __publicField(this, "_sampled");
367
- /**
368
- * @internal
369
- */
370
- __publicField(this, "_entities");
371
- /**
372
- * @internal
373
- */
374
- __publicField(this, "_primitives");
375
- /**
376
- * @internal
377
- */
378
- __publicField(this, "_groundPrimitives");
379
- /**
380
- * @internal
381
- */
382
- __publicField(this, "_skeletons");
383
- var _a, _b, _c, _d, _e, _f;
384
- const { id, disabled = false, sampled } = options;
385
- this._id = id || cesium.createGuid();
386
- this._scheme = PlotScheme.resolve(options.scheme);
387
- this._definitionChanged = new cesium.Event();
388
- this._defining = true;
389
- this._disabled = disabled;
390
- this._sampled = sampled instanceof SampledPlotProperty ? sampled : new SampledPlotProperty(sampled);
391
- this._sampled.definitionChanged.addEventListener((property) => this._definitionChanged.raiseEvent(this, "sampled", property, property), this);
392
- this._entities = [...((_b = (_a = this._scheme).initEntites) == null ? void 0 : _b.call(_a)) ?? []];
393
- this._primitives = [...((_d = (_c = this._scheme).initPrimitives) == null ? void 0 : _d.call(_c)) ?? []];
394
- this._groundPrimitives = [...((_f = (_e = this._scheme).initGroundPrimitives) == null ? void 0 : _f.call(_e)) ?? []];
395
- this._skeletons = [];
396
- }
397
- get id() {
398
- return this._id;
399
- }
400
- get scheme() {
401
- return this._scheme;
402
- }
403
- get definitionChanged() {
404
- return this._definitionChanged;
405
- }
406
- get defining() {
407
- return this._defining;
408
- }
409
- /**
410
- * @internal
411
- */
412
- static setDefining(plot, value) {
413
- if (plot._defining !== value) {
414
- plot._definitionChanged.raiseEvent(plot, "defining", value, plot._defining);
415
- plot._defining = value;
416
- }
417
- }
418
- /**
419
- * 获取禁用状态
420
- *
421
- * 当为 `true` 时,标绘实例将停止响应交互和更新;
422
- * 为 `false` 时恢复正常功能。
423
- */
424
- get disabled() {
425
- return this._disabled;
426
- }
427
- set disabled(value) {
428
- this.disabled = value;
429
- }
430
- get sampled() {
431
- return this._sampled;
432
- }
433
- get entities() {
434
- return this._entities;
435
- }
436
- set entities(value) {
437
- this._definitionChanged.raiseEvent(this, "entities", value, this._entities);
438
- this._entities = value;
439
- }
440
- get primitives() {
441
- return this._primitives;
442
- }
443
- /**
444
- * @internal
445
- */
446
- set primitives(value) {
447
- this._definitionChanged.raiseEvent(this, "primitives", value, this._primitives);
448
- this._primitives = value;
449
- }
450
- get groundPrimitives() {
451
- return this._groundPrimitives;
452
- }
453
- /**
454
- * @internal
455
- */
456
- set groundPrimitives(value) {
457
- this._definitionChanged.raiseEvent(this, "groundPrimitives", value, this._groundPrimitives);
458
- this._groundPrimitives = value;
459
- }
460
- get skeletons() {
461
- return this._skeletons;
462
- }
463
- /**
464
- * @internal
465
- */
466
- set skeletons(value) {
467
- this._definitionChanged.raiseEvent(this, "skeletons", value, this._skeletons);
468
- this._skeletons = value;
469
- }
470
- }
471
- var PlotAction = /* @__PURE__ */ ((PlotAction2) => {
472
- PlotAction2[PlotAction2["IDLE"] = 0] = "IDLE";
473
- PlotAction2[PlotAction2["HOVER"] = 1] = "HOVER";
474
- PlotAction2[PlotAction2["ACTIVE"] = 2] = "ACTIVE";
475
- return PlotAction2;
476
- })(PlotAction || {});
477
- class PlotSkeletonEntity extends cesium.Entity {
478
- constructor(options) {
479
- super(options);
480
- }
481
- }
348
+
349
+ //#endregion
350
+ //#region usePlot/PlotFeature.ts
351
+ /**
352
+ * 标绘实例
353
+ */
354
+ var PlotFeature = class {
355
+ constructor(options) {
356
+ const { id, disabled = false, sampled } = options;
357
+ this._id = id || (0, cesium.createGuid)();
358
+ this._scheme = PlotScheme.resolve(options.scheme);
359
+ this._definitionChanged = new cesium.Event();
360
+ this._defining = true;
361
+ this._disabled = disabled;
362
+ this._sampled = sampled instanceof SampledPlotProperty ? sampled : new SampledPlotProperty(sampled);
363
+ this._sampled.definitionChanged.addEventListener((property) => this._definitionChanged.raiseEvent(this, "sampled", property, property), this);
364
+ const init = this._scheme.initRender?.() ?? {};
365
+ this._entities = [...init.entities ?? []];
366
+ this._primitives = [...init.primitives ?? []];
367
+ this._groundPrimitives = [...init.groundPrimitives ?? []];
368
+ this._skeletons = [];
369
+ }
370
+ /**
371
+ * @internal
372
+ */
373
+ _id;
374
+ get id() {
375
+ return this._id;
376
+ }
377
+ /**
378
+ * @internal
379
+ */
380
+ _scheme;
381
+ get scheme() {
382
+ return this._scheme;
383
+ }
384
+ /**
385
+ * @internal
386
+ */
387
+ _definitionChanged;
388
+ get definitionChanged() {
389
+ return this._definitionChanged;
390
+ }
391
+ /**
392
+ * @internal
393
+ */
394
+ _defining;
395
+ get defining() {
396
+ return this._defining;
397
+ }
398
+ /**
399
+ * @internal
400
+ */
401
+ static setDefining(plot, value) {
402
+ if (plot._defining !== value) {
403
+ plot._definitionChanged.raiseEvent(plot, "defining", value, plot._defining);
404
+ plot._defining = value;
405
+ }
406
+ }
407
+ /**
408
+ * @internal
409
+ */
410
+ _disabled;
411
+ /**
412
+ * 获取禁用状态
413
+ *
414
+ * 当为 `true` 时,标绘实例将停止响应交互和更新;
415
+ * `false` 时恢复正常功能。
416
+ */
417
+ get disabled() {
418
+ return this._disabled;
419
+ }
420
+ set disabled(value) {
421
+ this.disabled = value;
422
+ }
423
+ /**
424
+ * @internal
425
+ */
426
+ _sampled;
427
+ get sampled() {
428
+ return this._sampled;
429
+ }
430
+ /**
431
+ * @internal
432
+ */
433
+ _entities;
434
+ get entities() {
435
+ return this._entities;
436
+ }
437
+ set entities(value) {
438
+ this._definitionChanged.raiseEvent(this, "entities", value, this._entities);
439
+ this._entities = value;
440
+ }
441
+ /**
442
+ * @internal
443
+ */
444
+ _primitives;
445
+ get primitives() {
446
+ return this._primitives;
447
+ }
448
+ /**
449
+ * @internal
450
+ */
451
+ set primitives(value) {
452
+ this._definitionChanged.raiseEvent(this, "primitives", value, this._primitives);
453
+ this._primitives = value;
454
+ }
455
+ /**
456
+ * @internal
457
+ */
458
+ _groundPrimitives;
459
+ get groundPrimitives() {
460
+ return this._groundPrimitives;
461
+ }
462
+ /**
463
+ * @internal
464
+ */
465
+ set groundPrimitives(value) {
466
+ this._definitionChanged.raiseEvent(this, "groundPrimitives", value, this._groundPrimitives);
467
+ this._groundPrimitives = value;
468
+ }
469
+ /**
470
+ * @internal
471
+ */
472
+ _skeletons;
473
+ get skeletons() {
474
+ return this._skeletons;
475
+ }
476
+ /**
477
+ * @internal
478
+ */
479
+ set skeletons(value) {
480
+ this._definitionChanged.raiseEvent(this, "skeletons", value, this._skeletons);
481
+ this._skeletons = value;
482
+ }
483
+ };
484
+
485
+ //#endregion
486
+ //#region usePlot/PlotSkeleton.ts
487
+ /**
488
+ * 框架点执行状态枚举
489
+ * - IDLE 空闲状态
490
+ * - HOVER 悬停状态
491
+ * - ACTIVE 激活状态
492
+ */
493
+ let PlotAction = /* @__PURE__ */ function(PlotAction$1) {
494
+ PlotAction$1[PlotAction$1["IDLE"] = 0] = "IDLE";
495
+ PlotAction$1[PlotAction$1["HOVER"] = 1] = "HOVER";
496
+ PlotAction$1[PlotAction$1["ACTIVE"] = 2] = "ACTIVE";
497
+ return PlotAction$1;
498
+ }({});
499
+ /**
500
+ * 标绘框架点 Entity
501
+ */
502
+ var PlotSkeletonEntity = class extends cesium.Entity {
503
+ constructor(options) {
504
+ super(options);
505
+ }
506
+ };
507
+
508
+ //#endregion
509
+ //#region usePlot/useRender.ts
482
510
  function useRender(plots, current, getCurrentTime) {
483
- const viewer = vesium.useViewer();
484
- const primitiveCollection = vesium.usePrimitive(new cesium.PrimitiveCollection());
485
- const groundPrimitiveCollection = vesium.usePrimitive(new cesium.PrimitiveCollection(), { collection: "ground" });
486
- const dataSource = vesium.useDataSource(new cesium.CustomDataSource());
487
- const entityScope = vesium.useEntityScope({ collection: () => dataSource.value.entities });
488
- const primitiveScope = vesium.usePrimitiveScope({ collection: () => primitiveCollection.value });
489
- const groundPrimitiveScope = vesium.usePrimitiveScope({ collection: () => groundPrimitiveCollection.value });
490
- const mouseCartesian = vue.shallowRef();
491
- vesium.useScreenSpaceEventHandler(
492
- cesium.ScreenSpaceEventType.MOUSE_MOVE,
493
- (event) => {
494
- mouseCartesian.value = vesium.canvasCoordToCartesian(event == null ? void 0 : event.endPosition, viewer.value.scene);
495
- }
496
- );
497
- core.watchArray(plots, (_value, _oldValue, added, removed = []) => {
498
- removed.forEach((plot) => {
499
- entityScope.removeWhere((item) => plot.entities.includes(item));
500
- primitiveScope.removeWhere((item) => plot.primitives.includes(item));
501
- groundPrimitiveScope.removeWhere((item) => plot.groundPrimitives.includes(item));
502
- });
503
- added.forEach((plot) => {
504
- plot.entities.forEach((item) => entityScope.add(item));
505
- plot.primitives.forEach((item) => primitiveScope.add(item));
506
- plot.groundPrimitives.forEach((item) => groundPrimitiveScope.add(item));
507
- });
508
- }, {
509
- immediate: true,
510
- flush: "post"
511
- });
512
- vesium.useCesiumEventListener(
513
- () => plots.value.map((item) => item.definitionChanged),
514
- (_scope, key, newValue, oldValue) => {
515
- if (key === "entities") {
516
- const { added, removed } = vesium.arrayDiff(newValue, oldValue);
517
- added.forEach((item) => entityScope.add(item));
518
- removed.forEach((item) => entityScope.remove(item));
519
- } else if (key === "primitives") {
520
- const { added, removed } = vesium.arrayDiff(newValue, oldValue);
521
- added.forEach((item) => primitiveScope.add(item));
522
- removed.forEach((item) => primitiveScope.remove(item));
523
- } else if (key === "groundPrimitives") {
524
- const { added, removed } = vesium.arrayDiff(newValue, oldValue);
525
- added.forEach((item) => groundPrimitiveScope.add(item));
526
- removed.forEach((item) => groundPrimitiveScope.remove(item));
527
- }
528
- }
529
- );
530
- const update = async (plot) => {
531
- var _a, _b;
532
- const reslut = await ((_b = (_a = plot.scheme).render) == null ? void 0 : _b.call(_a, {
533
- packable: plot.sampled.getValue(getCurrentTime()),
534
- mouse: plot.defining ? mouseCartesian.value : void 0,
535
- defining: plot.defining,
536
- previous: {
537
- entities: plot.entities,
538
- primitives: plot.primitives,
539
- groundPrimitives: plot.groundPrimitives
540
- }
541
- }));
542
- plot.entities = (reslut == null ? void 0 : reslut.entities) ?? [];
543
- plot.primitives = (reslut == null ? void 0 : reslut.primitives) ?? [];
544
- plot.groundPrimitives = (reslut == null ? void 0 : reslut.groundPrimitives) ?? [];
545
- };
546
- vue.watch(current, (plot, previous) => {
547
- previous && update(previous);
548
- });
549
- vesium.useCesiumEventListener(
550
- () => plots.value.map((item) => item.definitionChanged),
551
- (plot, key) => {
552
- if (["disabled", "defining", "scheme", "sampled", "time"].includes(key)) {
553
- update(plot);
554
- }
555
- }
556
- );
557
- vue.watch(mouseCartesian, () => {
558
- plots.value.forEach((plot) => plot.defining && update(plot));
559
- });
560
- return {
561
- primitives: vue.computed(() => Array.from(primitiveScope.scope)),
562
- groundPrimitives: vue.computed(() => Array.from(primitiveScope.scope)),
563
- entities: vue.computed(() => Array.from(entityScope.scope))
564
- };
511
+ const viewer = (0, vesium.useViewer)();
512
+ const primitiveCollection = (0, vesium.usePrimitive)(new cesium.PrimitiveCollection());
513
+ const groundPrimitiveCollection = (0, vesium.usePrimitive)(new cesium.PrimitiveCollection(), { collection: "ground" });
514
+ const dataSource = (0, vesium.useDataSource)(new cesium.CustomDataSource());
515
+ const entityScope = (0, vesium.useEntityScope)({ collection: () => dataSource.value.entities });
516
+ const primitiveScope = (0, vesium.usePrimitiveScope)({ collection: () => primitiveCollection.value });
517
+ const groundPrimitiveScope = (0, vesium.usePrimitiveScope)({ collection: () => groundPrimitiveCollection.value });
518
+ const mouseCartesian = (0, vue.shallowRef)();
519
+ (0, vesium.useScreenSpaceEventHandler)(cesium.ScreenSpaceEventType.MOUSE_MOVE, (event) => {
520
+ mouseCartesian.value = (0, vesium.canvasCoordToCartesian)(event?.endPosition, viewer.value.scene);
521
+ });
522
+ (0, __vueuse_core.watchArray)(plots, (_value, _oldValue, added, removed = []) => {
523
+ removed.forEach((plot) => {
524
+ entityScope.removeWhere((item) => plot.entities.includes(item));
525
+ primitiveScope.removeWhere((item) => plot.primitives.includes(item));
526
+ groundPrimitiveScope.removeWhere((item) => plot.groundPrimitives.includes(item));
527
+ });
528
+ added.forEach((plot) => {
529
+ plot.entities.forEach((item) => entityScope.add(item));
530
+ plot.primitives.forEach((item) => primitiveScope.add(item));
531
+ plot.groundPrimitives.forEach((item) => groundPrimitiveScope.add(item));
532
+ });
533
+ }, {
534
+ immediate: true,
535
+ flush: "post"
536
+ });
537
+ (0, vesium.useCesiumEventListener)(() => plots.value.map((item) => item.definitionChanged), (_scope, key, newValue, oldValue) => {
538
+ if (key === "entities") {
539
+ const { added, removed } = (0, vesium.arrayDiff)(newValue, oldValue);
540
+ added.forEach((item) => entityScope.add(item));
541
+ removed.forEach((item) => entityScope.remove(item));
542
+ } else if (key === "primitives") {
543
+ const { added, removed } = (0, vesium.arrayDiff)(newValue, oldValue);
544
+ added.forEach((item) => primitiveScope.add(item));
545
+ removed.forEach((item) => primitiveScope.remove(item));
546
+ } else if (key === "groundPrimitives") {
547
+ const { added, removed } = (0, vesium.arrayDiff)(newValue, oldValue);
548
+ added.forEach((item) => groundPrimitiveScope.add(item));
549
+ removed.forEach((item) => groundPrimitiveScope.remove(item));
550
+ }
551
+ });
552
+ const update = async (plot) => {
553
+ const reslut = await plot.scheme.render?.({
554
+ packable: plot.sampled.getValue(getCurrentTime()),
555
+ mouse: plot.defining ? mouseCartesian.value : void 0,
556
+ defining: plot.defining,
557
+ previous: {
558
+ entities: plot.entities,
559
+ primitives: plot.primitives,
560
+ groundPrimitives: plot.groundPrimitives
561
+ }
562
+ });
563
+ plot.entities = reslut?.entities ?? [];
564
+ plot.primitives = reslut?.primitives ?? [];
565
+ plot.groundPrimitives = reslut?.groundPrimitives ?? [];
566
+ };
567
+ (0, vue.watch)(current, (plot, previous) => {
568
+ previous && update(previous);
569
+ });
570
+ (0, vesium.useCesiumEventListener)(() => plots.value.map((item) => item.definitionChanged), (plot, key) => {
571
+ if ([
572
+ "disabled",
573
+ "defining",
574
+ "scheme",
575
+ "sampled",
576
+ "time"
577
+ ].includes(key)) update(plot);
578
+ });
579
+ (0, vue.watch)(mouseCartesian, () => {
580
+ plots.value.forEach((plot) => plot.defining && update(plot));
581
+ });
582
+ return {
583
+ primitives: (0, vue.computed)(() => Array.from(primitiveScope.scope)),
584
+ groundPrimitives: (0, vue.computed)(() => Array.from(primitiveScope.scope)),
585
+ entities: (0, vue.computed)(() => Array.from(entityScope.scope))
586
+ };
565
587
  }
588
+
589
+ //#endregion
590
+ //#region usePlot/useSampled.ts
566
591
  function useSampled(current, getCurrentTime) {
567
- const viewer = vesium.useViewer();
568
- const doubleClicking = vue.ref(false);
569
- const packable = vue.computed(() => {
570
- var _a;
571
- return (_a = current.value) == null ? void 0 : _a.sampled.getValue(getCurrentTime());
572
- });
573
- vesium.useScreenSpaceEventHandler(
574
- cesium.ScreenSpaceEventType.LEFT_CLICK,
575
- async (ctx) => {
576
- var _a, _b;
577
- await core.promiseTimeout(1);
578
- if (!current.value || !packable.value) {
579
- return;
580
- }
581
- if (doubleClicking.value) {
582
- return;
583
- }
584
- const { scheme, defining, sampled } = current.value;
585
- if (!defining) {
586
- return;
587
- }
588
- const position = vesium.canvasCoordToCartesian(ctx.position, viewer.value.scene);
589
- if (!position) {
590
- return;
591
- }
592
- (_a = packable.value).positions ?? (_a.positions = []);
593
- packable.value.positions.push(position);
594
- sampled.setSample(packable.value);
595
- const completed = (_b = scheme.complete) == null ? void 0 : _b.call(scheme, packable.value);
596
- completed && PlotFeature.setDefining(current.value, false);
597
- }
598
- );
599
- vesium.useScreenSpaceEventHandler(
600
- cesium.ScreenSpaceEventType.LEFT_DOUBLE_CLICK,
601
- async (ctx) => {
602
- var _a;
603
- if (!current.value || !packable.value) {
604
- return;
605
- }
606
- doubleClicking.value = true;
607
- await core.promiseTimeout(2);
608
- doubleClicking.value = false;
609
- const { scheme, defining } = current.value;
610
- if (!defining) {
611
- return;
612
- }
613
- const position = vesium.canvasCoordToCartesian(ctx.position, viewer.value.scene);
614
- if (!position) {
615
- return;
616
- }
617
- const completed = (_a = scheme.allowManualComplete) == null ? void 0 : _a.call(scheme, packable.value);
618
- completed && PlotFeature.setDefining(current.value, false);
619
- }
620
- );
621
- vesium.useScreenSpaceEventHandler(
622
- cesium.ScreenSpaceEventType.RIGHT_CLICK,
623
- async () => {
624
- var _a;
625
- if (!current.value || !packable.value) {
626
- return;
627
- }
628
- const { defining, sampled } = current.value;
629
- if (!defining) {
630
- return;
631
- }
632
- (_a = packable.value).positions ?? (_a.positions = []);
633
- if (packable.value.positions.length === 0) {
634
- return;
635
- }
636
- packable.value.positions.splice(packable.value.positions.length - 1, 1);
637
- sampled.setSample(packable.value);
638
- }
639
- );
640
- const definingCursorCss = vue.ref();
641
- const setDefiningCursorCss = () => {
642
- var _a, _b;
643
- if (!((_a = current.value) == null ? void 0 : _a.defining)) {
644
- if (definingCursorCss.value) {
645
- definingCursorCss.value = void 0;
646
- viewer.value.container.parentElement.style.removeProperty("cursor");
647
- }
648
- } else {
649
- const definingCursor = current.value.scheme.definingCursor;
650
- definingCursorCss.value = vesium.isFunction(definingCursor) ? definingCursor(packable.value) : definingCursor;
651
- if (definingCursorCss.value) {
652
- (_b = viewer.value) == null ? void 0 : _b.container.parentElement.style.setProperty("cursor", definingCursorCss.value);
653
- }
654
- }
655
- };
656
- vesium.useCesiumEventListener(() => {
657
- var _a;
658
- return (_a = current.value) == null ? void 0 : _a.definitionChanged;
659
- }, (plot, key) => {
660
- if (key === "defining" || key === "sampled") {
661
- setDefiningCursorCss();
662
- }
663
- });
664
- vue.watch(current, () => setDefiningCursorCss());
592
+ const viewer = (0, vesium.useViewer)();
593
+ const doubleClicking = (0, vue.ref)(false);
594
+ const packable = (0, vue.computed)(() => {
595
+ return current.value?.sampled.getValue(getCurrentTime());
596
+ });
597
+ (0, vesium.useScreenSpaceEventHandler)(cesium.ScreenSpaceEventType.LEFT_CLICK, async (ctx) => {
598
+ await (0, __vueuse_core.promiseTimeout)(1);
599
+ if (!current.value || !packable.value) return;
600
+ if (doubleClicking.value) return;
601
+ const { scheme, defining, sampled } = current.value;
602
+ if (!defining) return;
603
+ const position = (0, vesium.canvasCoordToCartesian)(ctx.position, viewer.value.scene);
604
+ if (!position) return;
605
+ packable.value.positions ??= [];
606
+ packable.value.positions.push(position);
607
+ sampled.setSample(packable.value);
608
+ const completed = scheme.complete?.(packable.value);
609
+ completed && PlotFeature.setDefining(current.value, false);
610
+ });
611
+ (0, vesium.useScreenSpaceEventHandler)(cesium.ScreenSpaceEventType.LEFT_DOUBLE_CLICK, async (ctx) => {
612
+ if (!current.value || !packable.value) return;
613
+ doubleClicking.value = true;
614
+ await (0, __vueuse_core.promiseTimeout)(2);
615
+ doubleClicking.value = false;
616
+ const { scheme, defining } = current.value;
617
+ if (!defining) return;
618
+ const position = (0, vesium.canvasCoordToCartesian)(ctx.position, viewer.value.scene);
619
+ if (!position) return;
620
+ const completed = scheme.allowManualComplete?.(packable.value);
621
+ completed && PlotFeature.setDefining(current.value, false);
622
+ });
623
+ (0, vesium.useScreenSpaceEventHandler)(cesium.ScreenSpaceEventType.RIGHT_CLICK, async () => {
624
+ if (!current.value || !packable.value) return;
625
+ const { defining, sampled } = current.value;
626
+ if (!defining) return;
627
+ packable.value.positions ??= [];
628
+ if (packable.value.positions.length === 0) return;
629
+ packable.value.positions.splice(packable.value.positions.length - 1, 1);
630
+ sampled.setSample(packable.value);
631
+ });
632
+ const definingCursorCss = (0, vue.ref)();
633
+ const setDefiningCursorCss = () => {
634
+ if (!current.value?.defining) {
635
+ if (definingCursorCss.value) {
636
+ definingCursorCss.value = void 0;
637
+ viewer.value.container.parentElement.style.removeProperty("cursor");
638
+ }
639
+ } else {
640
+ const definingCursor = current.value.scheme.definingCursor;
641
+ definingCursorCss.value = (0, vesium.isFunction)(definingCursor) ? definingCursor(packable.value) : definingCursor;
642
+ if (definingCursorCss.value) viewer.value?.container.parentElement.style.setProperty("cursor", definingCursorCss.value);
643
+ }
644
+ };
645
+ (0, vesium.useCesiumEventListener)(() => current.value?.definitionChanged, (plot, key) => {
646
+ if (key === "defining" || key === "sampled") setDefiningCursorCss();
647
+ });
648
+ (0, vue.watch)(current, () => setDefiningCursorCss());
665
649
  }
650
+
651
+ //#endregion
652
+ //#region usePlot/useSkeleton.ts
666
653
  function useSkeleton(plots, current, getCurrentTime) {
667
- const viewer = vesium.useViewer();
668
- const dataSource = vesium.useDataSource(new cesium.CustomDataSource());
669
- const entityScope = vesium.useEntityScope({ collection: () => dataSource.value.entities });
670
- const hoverEntity = vue.shallowRef();
671
- const activeEntity = vue.shallowRef();
672
- const getPointAction = (entity) => {
673
- var _a, _b;
674
- if (!entity) {
675
- return PlotAction.IDLE;
676
- }
677
- return ((_a = activeEntity.value) == null ? void 0 : _a.id) === entity.id ? PlotAction.ACTIVE : ((_b = hoverEntity.value) == null ? void 0 : _b.id) === entity.id ? PlotAction.HOVER : PlotAction.IDLE;
678
- };
679
- const update = (plot, destroyed) => {
680
- const oldEntities = plot.skeletons;
681
- const entities = [];
682
- if (destroyed || plot.disabled) {
683
- plot.skeletons = [];
684
- } else {
685
- const packable = plot.sampled.getValue(getCurrentTime());
686
- const defining = plot.defining;
687
- const active = current.value === plot;
688
- const skeletons = plot.scheme.skeletons;
689
- skeletons.forEach((skeleton) => {
690
- var _a;
691
- const disabled = vesium.isFunction(skeleton.disabled) ? skeleton.disabled({ active, defining }) : skeleton.disabled;
692
- if (disabled) {
693
- return;
694
- }
695
- const positions = ((_a = skeleton.format) == null ? void 0 : _a.call(skeleton, packable)) ?? (packable == null ? void 0 : packable.positions) ?? [];
696
- positions.forEach((position, index) => {
697
- var _a2;
698
- let entity = oldEntities.find((item) => item.index === index && item.skeleton === skeleton);
699
- const options = (_a2 = skeleton.render) == null ? void 0 : _a2.call(skeleton, {
700
- defining,
701
- active,
702
- index,
703
- packable,
704
- positions,
705
- position,
706
- action: getPointAction(entity)
707
- });
708
- const merge = new PlotSkeletonEntity(options ?? {});
709
- if (entity) {
710
- merge.propertyNames.forEach((key) => {
711
- if (key !== "id") {
712
- entity[key] = merge[key];
713
- }
714
- });
715
- } else {
716
- entity = merge;
717
- }
718
- entity.plot = plot;
719
- entity.skeleton = skeleton;
720
- entity.index = index;
721
- entities.push(entity);
722
- });
723
- });
724
- }
725
- plot.skeletons = entities;
726
- };
727
- const { addGraphicEvent } = vesium.useGraphicEvent();
728
- vue.watchEffect((onCleanup) => {
729
- const remove = addGraphicEvent("global", "DRAG", ({ event, pick, dragging, lockCamera }) => {
730
- var _a;
731
- if (pick.id instanceof PlotSkeletonEntity && entityScope.scope.has(pick.id)) {
732
- const entity = pick.id;
733
- const plot = entity.plot;
734
- if (plot.defining) {
735
- return;
736
- }
737
- activeEntity.value = entity;
738
- const skeleton = entity.skeleton;
739
- const index = entity.index;
740
- const packable = plot.sampled.getValue(getCurrentTime());
741
- (_a = skeleton.onDrag) == null ? void 0 : _a.call(skeleton, {
742
- viewer: viewer.value,
743
- sampled: plot.sampled,
744
- packable,
745
- active: current.value === plot,
746
- index,
747
- event,
748
- dragging,
749
- lockCamera
750
- });
751
- } else {
752
- activeEntity.value = void 0;
753
- }
754
- }, {
755
- cursor: ({ pick }) => {
756
- var _a;
757
- if (!((_a = current.value) == null ? void 0 : _a.defining) && entityScope.scope.has(pick.id)) {
758
- const skeleton = pick.id.skeleton;
759
- return vesium.isFunction(skeleton == null ? void 0 : skeleton.cursor) ? skeleton.cursor(pick) : vue.toValue(skeleton == null ? void 0 : skeleton.cursor);
760
- }
761
- },
762
- dragCursor: ({ pick }) => {
763
- var _a;
764
- if (!((_a = current.value) == null ? void 0 : _a.defining) && entityScope.scope.has(pick.id)) {
765
- const skeleton = pick.id.skeleton;
766
- return vesium.isFunction(skeleton == null ? void 0 : skeleton.dragCursor) ? skeleton.dragCursor(pick) : vue.toValue(skeleton == null ? void 0 : skeleton.dragCursor);
767
- }
768
- }
769
- });
770
- onCleanup(remove);
771
- });
772
- core.onKeyStroke((keyEvent) => {
773
- var _a;
774
- if (activeEntity.value) {
775
- const entity = activeEntity.value;
776
- const plot = entity.plot;
777
- const skeleton = entity.skeleton;
778
- const index = entity.index;
779
- const packable = plot.sampled.getValue(getCurrentTime());
780
- (_a = skeleton.onKeyPressed) == null ? void 0 : _a.call(skeleton, {
781
- viewer: viewer.value,
782
- sampled: plot.sampled,
783
- packable,
784
- index,
785
- keyEvent
786
- });
787
- }
788
- });
789
- vue.watchEffect((onCleanup) => {
790
- const remove = addGraphicEvent("global", "HOVER", ({ hovering, pick }) => {
791
- if (hovering && pick.id instanceof PlotSkeletonEntity && entityScope.scope.has(pick.id)) {
792
- const entity = pick.id;
793
- hoverEntity.value = entity;
794
- } else {
795
- hoverEntity.value = void 0;
796
- }
797
- });
798
- onCleanup(remove);
799
- });
800
- vue.watchEffect((onCleanup) => {
801
- const remove = addGraphicEvent("global", "LEFT_CLICK", ({ event, pick }) => {
802
- var _a;
803
- if (pick.id instanceof PlotSkeletonEntity && entityScope.scope.has(pick.id)) {
804
- const entity = pick.id;
805
- activeEntity.value = entity;
806
- const plot = entity.plot;
807
- const skeleton = entity.skeleton;
808
- const index = entity.index;
809
- const packable = plot.sampled.getValue(getCurrentTime());
810
- (_a = skeleton.onLeftClick) == null ? void 0 : _a.call(skeleton, {
811
- viewer: viewer.value,
812
- sampled: plot.sampled,
813
- packable,
814
- active: current.value === plot,
815
- defining: plot.defining,
816
- index,
817
- event
818
- });
819
- } else {
820
- activeEntity.value = void 0;
821
- }
822
- });
823
- onCleanup(remove);
824
- });
825
- core.watchArray(plots, (value, oldValue, added, removed = []) => {
826
- added.forEach((plot) => update(plot));
827
- removed.forEach((plot) => update(plot, true));
828
- });
829
- vesium.useCesiumEventListener(
830
- () => plots.value.map((plot) => plot.definitionChanged),
831
- (plot, key, newValue, oldValue) => {
832
- if (["disabled", "defining", "scheme", "sampled", "time"].includes(key)) {
833
- vue.nextTick(() => update(plot));
834
- } else if (key === "skeletons") {
835
- const { added, removed } = vesium.arrayDiff(newValue, oldValue);
836
- added.forEach((item) => entityScope.add(item));
837
- removed.forEach((item) => entityScope.remove(item));
838
- }
839
- }
840
- );
841
- vue.watch(current, (plot, previous) => {
842
- plot && update(plot);
843
- previous && update(previous);
844
- });
845
- return {
846
- dataSource
847
- };
654
+ const viewer = (0, vesium.useViewer)();
655
+ const dataSource = (0, vesium.useDataSource)(new cesium.CustomDataSource());
656
+ const entityScope = (0, vesium.useEntityScope)({ collection: () => dataSource.value.entities });
657
+ const hoverEntity = (0, vue.shallowRef)();
658
+ const activeEntity = (0, vue.shallowRef)();
659
+ const getPointAction = (entity) => {
660
+ if (!entity) return PlotAction.IDLE;
661
+ return activeEntity.value?.id === entity.id ? PlotAction.ACTIVE : hoverEntity.value?.id === entity.id ? PlotAction.HOVER : PlotAction.IDLE;
662
+ };
663
+ const update = (plot, destroyed) => {
664
+ const oldEntities = plot.skeletons;
665
+ const entities = [];
666
+ if (destroyed || plot.disabled) plot.skeletons = [];
667
+ else {
668
+ const packable = plot.sampled.getValue(getCurrentTime());
669
+ const defining = plot.defining;
670
+ const active = current.value === plot;
671
+ const skeletons = plot.scheme.skeletons;
672
+ skeletons.forEach((skeleton) => {
673
+ const disabled = (0, vesium.isFunction)(skeleton.disabled) ? skeleton.disabled({
674
+ active,
675
+ defining
676
+ }) : skeleton.disabled;
677
+ if (disabled) return;
678
+ const positions = skeleton.format?.(packable) ?? packable?.positions ?? [];
679
+ positions.forEach((position, index) => {
680
+ let entity = oldEntities.find((item) => item.index === index && item.skeleton === skeleton);
681
+ const options = skeleton.render?.({
682
+ defining,
683
+ active,
684
+ index,
685
+ packable,
686
+ positions,
687
+ position,
688
+ action: getPointAction(entity)
689
+ });
690
+ const merge = new PlotSkeletonEntity(options ?? {});
691
+ if (entity) merge.propertyNames.forEach((key) => {
692
+ if (key !== "id") entity[key] = merge[key];
693
+ });
694
+ else entity = merge;
695
+ entity.plot = plot;
696
+ entity.skeleton = skeleton;
697
+ entity.index = index;
698
+ entities.push(entity);
699
+ });
700
+ });
701
+ }
702
+ plot.skeletons = entities;
703
+ };
704
+ const { addGraphicEvent } = (0, vesium.useGraphicEvent)();
705
+ (0, vue.watchEffect)((onCleanup) => {
706
+ const remove = addGraphicEvent("global", "DRAG", ({ event, pick, dragging, lockCamera }) => {
707
+ if (pick.id instanceof PlotSkeletonEntity && entityScope.scope.has(pick.id)) {
708
+ const entity = pick.id;
709
+ const plot = entity.plot;
710
+ if (plot.defining) return;
711
+ activeEntity.value = entity;
712
+ const skeleton = entity.skeleton;
713
+ const index = entity.index;
714
+ const packable = plot.sampled.getValue(getCurrentTime());
715
+ skeleton.onDrag?.({
716
+ viewer: viewer.value,
717
+ sampled: plot.sampled,
718
+ packable,
719
+ active: current.value === plot,
720
+ index,
721
+ event,
722
+ dragging,
723
+ lockCamera
724
+ });
725
+ } else activeEntity.value = void 0;
726
+ }, {
727
+ cursor: ({ pick }) => {
728
+ if (!current.value?.defining && entityScope.scope.has(pick.id)) {
729
+ const skeleton = pick.id.skeleton;
730
+ return (0, vesium.isFunction)(skeleton?.cursor) ? skeleton.cursor(pick) : (0, vue.toValue)(skeleton?.cursor);
731
+ }
732
+ },
733
+ dragCursor: ({ pick }) => {
734
+ if (!current.value?.defining && entityScope.scope.has(pick.id)) {
735
+ const skeleton = pick.id.skeleton;
736
+ return (0, vesium.isFunction)(skeleton?.dragCursor) ? skeleton.dragCursor(pick) : (0, vue.toValue)(skeleton?.dragCursor);
737
+ }
738
+ }
739
+ });
740
+ onCleanup(remove);
741
+ });
742
+ (0, __vueuse_core.onKeyStroke)((keyEvent) => {
743
+ if (activeEntity.value) {
744
+ const entity = activeEntity.value;
745
+ const plot = entity.plot;
746
+ const skeleton = entity.skeleton;
747
+ const index = entity.index;
748
+ const packable = plot.sampled.getValue(getCurrentTime());
749
+ skeleton.onKeyPressed?.({
750
+ viewer: viewer.value,
751
+ sampled: plot.sampled,
752
+ packable,
753
+ index,
754
+ keyEvent
755
+ });
756
+ }
757
+ });
758
+ (0, vue.watchEffect)((onCleanup) => {
759
+ const remove = addGraphicEvent("global", "HOVER", ({ hovering, pick }) => {
760
+ if (hovering && pick.id instanceof PlotSkeletonEntity && entityScope.scope.has(pick.id)) {
761
+ const entity = pick.id;
762
+ hoverEntity.value = entity;
763
+ } else hoverEntity.value = void 0;
764
+ });
765
+ onCleanup(remove);
766
+ });
767
+ (0, vue.watchEffect)((onCleanup) => {
768
+ const remove = addGraphicEvent("global", "LEFT_CLICK", ({ event, pick }) => {
769
+ if (pick.id instanceof PlotSkeletonEntity && entityScope.scope.has(pick.id)) {
770
+ const entity = pick.id;
771
+ activeEntity.value = entity;
772
+ const plot = entity.plot;
773
+ const skeleton = entity.skeleton;
774
+ const index = entity.index;
775
+ const packable = plot.sampled.getValue(getCurrentTime());
776
+ skeleton.onLeftClick?.({
777
+ viewer: viewer.value,
778
+ sampled: plot.sampled,
779
+ packable,
780
+ active: current.value === plot,
781
+ defining: plot.defining,
782
+ index,
783
+ event
784
+ });
785
+ } else activeEntity.value = void 0;
786
+ });
787
+ onCleanup(remove);
788
+ });
789
+ (0, __vueuse_core.watchArray)(plots, (value, oldValue, added, removed = []) => {
790
+ added.forEach((plot) => update(plot));
791
+ removed.forEach((plot) => update(plot, true));
792
+ });
793
+ (0, vesium.useCesiumEventListener)(() => plots.value.map((plot) => plot.definitionChanged), (plot, key, newValue, oldValue) => {
794
+ if ([
795
+ "disabled",
796
+ "defining",
797
+ "scheme",
798
+ "sampled",
799
+ "time"
800
+ ].includes(key)) (0, vue.nextTick)(() => update(plot));
801
+ else if (key === "skeletons") {
802
+ const { added, removed } = (0, vesium.arrayDiff)(newValue, oldValue);
803
+ added.forEach((item) => entityScope.add(item));
804
+ removed.forEach((item) => entityScope.remove(item));
805
+ }
806
+ });
807
+ (0, vue.watch)(current, (plot, previous) => {
808
+ plot && update(plot);
809
+ previous && update(previous);
810
+ });
811
+ return { dataSource };
848
812
  }
813
+
814
+ //#endregion
815
+ //#region usePlot/usePlot.ts
849
816
  function usePlot(options) {
850
- const time = (options == null ? void 0 : options.time) || vue.shallowRef();
851
- const viewer = vesium.useViewer();
852
- const getCurrentTime = () => {
853
- var _a;
854
- return ((_a = time.value) == null ? void 0 : _a.clone()) || new cesium.JulianDate(0, 0);
855
- };
856
- const collection = vue.shallowReactive(/* @__PURE__ */ new Set());
857
- const plots = vue.computed(() => Array.from(collection));
858
- const current = vue.shallowRef();
859
- const packable = vue.shallowRef();
860
- vesium.useCesiumEventListener([
861
- () => {
862
- var _a;
863
- return (_a = current.value) == null ? void 0 : _a.sampled.definitionChanged;
864
- }
865
- ], () => {
866
- var _a;
867
- packable.value = (_a = current.value) == null ? void 0 : _a.sampled.getValue(getCurrentTime());
868
- });
869
- useSampled(current, getCurrentTime);
870
- useRender(plots, current, getCurrentTime);
871
- useSkeleton(plots, current, getCurrentTime);
872
- vesium.useScreenSpaceEventHandler(cesium.ScreenSpaceEventType.LEFT_CLICK, (data) => {
873
- var _a, _b, _c;
874
- if ((_a = current.value) == null ? void 0 : _a.defining) {
875
- return;
876
- }
877
- const pick = (_b = viewer.value) == null ? void 0 : _b.scene.pick(data.position.clone());
878
- if (((_c = pick == null ? void 0 : pick.id) == null ? void 0 : _c.plot) instanceof PlotFeature) {
879
- return;
880
- }
881
- if (!pick) {
882
- current.value = void 0;
883
- return;
884
- }
885
- current.value = plots.value.find((plot) => vesium.pickHitGraphic(pick, [...plot.entities, ...plot.primitives, ...plot.groundPrimitives]));
886
- });
887
- let operateResolve;
888
- let operateReject;
889
- vue.watch(current, (plot, previous) => {
890
- var _a, _b;
891
- if (previous) {
892
- if (previous.defining) {
893
- const packable2 = previous.sampled.getValue(getCurrentTime());
894
- const completed = (_b = (_a = previous.scheme).allowManualComplete) == null ? void 0 : _b.call(_a, packable2);
895
- if (completed) {
896
- PlotFeature.setDefining(previous, false);
897
- operateResolve == null ? void 0 : operateResolve(previous);
898
- } else {
899
- collection.delete(previous);
900
- }
901
- }
902
- }
903
- });
904
- const operate = async (plot) => {
905
- return new Promise((resolve, reject) => {
906
- operateResolve = resolve;
907
- operateReject = reject;
908
- const _plot = plot instanceof PlotFeature ? plot : new PlotFeature(plot);
909
- if (!collection.has(_plot)) {
910
- collection.add(_plot);
911
- }
912
- current.value = _plot;
913
- return resolve(_plot);
914
- });
915
- };
916
- const remove = (plot) => {
917
- if (plot === current.value) {
918
- current.value = void 0;
919
- }
920
- if (collection.has(plot)) {
921
- collection.delete(plot);
922
- return true;
923
- }
924
- return false;
925
- };
926
- return {
927
- plots,
928
- time,
929
- operate,
930
- remove,
931
- cancel: operateReject
932
- };
817
+ const time = options?.time || (0, vue.shallowRef)();
818
+ const viewer = (0, vesium.useViewer)();
819
+ const getCurrentTime = () => {
820
+ return time.value?.clone() || new cesium.JulianDate(0, 0);
821
+ };
822
+ const collection = (0, vue.shallowReactive)(/* @__PURE__ */ new Set());
823
+ const plots = (0, vue.computed)(() => Array.from(collection));
824
+ const current = (0, vue.shallowRef)();
825
+ const packable = (0, vue.shallowRef)();
826
+ (0, vesium.useCesiumEventListener)([() => current.value?.sampled.definitionChanged], () => {
827
+ packable.value = current.value?.sampled.getValue(getCurrentTime());
828
+ });
829
+ useSampled(current, getCurrentTime);
830
+ useRender(plots, current, getCurrentTime);
831
+ useSkeleton(plots, current, getCurrentTime);
832
+ (0, vesium.useScreenSpaceEventHandler)(cesium.ScreenSpaceEventType.LEFT_CLICK, (data) => {
833
+ if (current.value?.defining) return;
834
+ const pick = viewer.value?.scene.pick(data.position.clone());
835
+ if (pick?.id?.plot instanceof PlotFeature) return;
836
+ if (!pick) {
837
+ current.value = void 0;
838
+ return;
839
+ }
840
+ current.value = plots.value.find((plot) => (0, vesium.pickHitGraphic)(pick, [
841
+ ...plot.entities,
842
+ ...plot.primitives,
843
+ ...plot.groundPrimitives
844
+ ]));
845
+ });
846
+ let operateResolve;
847
+ let operateReject;
848
+ (0, vue.watch)(current, (plot, previous) => {
849
+ if (previous) {
850
+ if (previous.defining) {
851
+ const packable$1 = previous.sampled.getValue(getCurrentTime());
852
+ const completed = previous.scheme.allowManualComplete?.(packable$1);
853
+ if (completed) {
854
+ PlotFeature.setDefining(previous, false);
855
+ operateResolve?.(previous);
856
+ } else collection.delete(previous);
857
+ }
858
+ }
859
+ });
860
+ const operate = async (plot) => {
861
+ return new Promise((resolve, reject) => {
862
+ operateResolve = resolve;
863
+ operateReject = reject;
864
+ const _plot = plot instanceof PlotFeature ? plot : new PlotFeature(plot);
865
+ if (!collection.has(_plot)) collection.add(_plot);
866
+ current.value = _plot;
867
+ return resolve(_plot);
868
+ });
869
+ };
870
+ const remove = (plot) => {
871
+ if (plot === current.value) current.value = void 0;
872
+ if (collection.has(plot)) {
873
+ collection.delete(plot);
874
+ return true;
875
+ }
876
+ return false;
877
+ };
878
+ return {
879
+ plots,
880
+ time,
881
+ operate,
882
+ remove,
883
+ cancel: operateReject
884
+ };
933
885
  }
886
+
887
+ //#endregion
888
+ //#region skeleton/control.ts
889
+ /**
890
+ * 绘制控制的框架点,拖拽时,将更新该控制点的实时位置
891
+ */
934
892
  function control() {
935
- return {
936
- disabled: ({ active }) => !active,
937
- cursor: "pointer",
938
- dragCursor: "crosshair",
939
- onDrag({ viewer, sampled, packable, event, index, lockCamera }) {
940
- lockCamera();
941
- const position = vesium.canvasCoordToCartesian(event.endPosition, viewer.scene);
942
- if (position) {
943
- const positions = [...packable.positions ?? []];
944
- positions[index] = position;
945
- sampled.setSample({
946
- time: packable.time,
947
- derivative: packable.derivative,
948
- positions
949
- });
950
- }
951
- },
952
- onKeyPressed({ viewer, keyEvent, sampled, packable, index }) {
953
- var _a;
954
- const height = (_a = vesium.toCartographic(viewer.camera.position)) == null ? void 0 : _a.height;
955
- if (!height || !["ArrowUp", "ArrowRight", "ArrowDown", "ArrowLeft"].includes(keyEvent.key))
956
- return;
957
- keyEvent.preventDefault();
958
- let headingAdjust = 0;
959
- switch (keyEvent.key) {
960
- case "ArrowRight":
961
- headingAdjust = Math.PI / 2;
962
- break;
963
- case "ArrowDown":
964
- headingAdjust = Math.PI;
965
- break;
966
- case "ArrowLeft":
967
- headingAdjust = -Math.PI / 2;
968
- break;
969
- case "ArrowUp":
970
- headingAdjust = 0;
971
- break;
972
- }
973
- const newHeading = (viewer.camera.heading + headingAdjust) % (2 * Math.PI);
974
- const positions = [...packable.positions ?? []];
975
- const cartographic = vesium.toCartographic(positions[index]);
976
- const r = height / 1e5;
977
- const distance = r * Math.PI / 180 / 1e3;
978
- cartographic.latitude += distance * Math.cos(newHeading);
979
- cartographic.longitude += distance * Math.sin(newHeading);
980
- positions[index] = vesium.toCartesian3(cartographic);
981
- sampled.setSample({
982
- time: packable.time,
983
- derivative: packable.derivative,
984
- positions
985
- });
986
- },
987
- render: ({ position, action }) => {
988
- const colors = {
989
- [PlotAction.IDLE]: cesium.Color.BLUE.withAlpha(0.4),
990
- [PlotAction.HOVER]: cesium.Color.BLUE.withAlpha(0.6),
991
- [PlotAction.ACTIVE]: cesium.Color.AQUA.withAlpha(1)
992
- };
993
- return {
994
- position,
995
- point: {
996
- pixelSize: 8,
997
- color: colors[action],
998
- disableDepthTestDistance: Number.POSITIVE_INFINITY,
999
- outlineWidth: 1,
1000
- outlineColor: cesium.Color.WHITE.withAlpha(0.4)
1001
- }
1002
- };
1003
- }
1004
- };
893
+ return {
894
+ disabled: ({ active }) => !active,
895
+ cursor: "pointer",
896
+ dragCursor: "crosshair",
897
+ onDrag({ viewer, sampled, packable, event, index, lockCamera }) {
898
+ lockCamera();
899
+ const position = (0, vesium.canvasCoordToCartesian)(event.endPosition, viewer.scene);
900
+ if (position) {
901
+ const positions = [...packable.positions ?? []];
902
+ positions[index] = position;
903
+ sampled.setSample({
904
+ time: packable.time,
905
+ derivative: packable.derivative,
906
+ positions
907
+ });
908
+ }
909
+ },
910
+ onKeyPressed({ viewer, keyEvent, sampled, packable, index }) {
911
+ const height = (0, vesium.toCartographic)(viewer.camera.position)?.height;
912
+ if (!height || ![
913
+ "ArrowUp",
914
+ "ArrowRight",
915
+ "ArrowDown",
916
+ "ArrowLeft"
917
+ ].includes(keyEvent.key)) return;
918
+ keyEvent.preventDefault();
919
+ let headingAdjust = 0;
920
+ switch (keyEvent.key) {
921
+ case "ArrowRight":
922
+ headingAdjust = Math.PI / 2;
923
+ break;
924
+ case "ArrowDown":
925
+ headingAdjust = Math.PI;
926
+ break;
927
+ case "ArrowLeft":
928
+ headingAdjust = -Math.PI / 2;
929
+ break;
930
+ case "ArrowUp":
931
+ headingAdjust = 0;
932
+ break;
933
+ }
934
+ const newHeading = (viewer.camera.heading + headingAdjust) % (2 * Math.PI);
935
+ const positions = [...packable.positions ?? []];
936
+ const cartographic = (0, vesium.toCartographic)(positions[index]);
937
+ const r = height / 1e5;
938
+ const distance$1 = r * Math.PI / 180 / 1e3;
939
+ cartographic.latitude += distance$1 * Math.cos(newHeading);
940
+ cartographic.longitude += distance$1 * Math.sin(newHeading);
941
+ positions[index] = (0, vesium.toCartesian3)(cartographic);
942
+ sampled.setSample({
943
+ time: packable.time,
944
+ derivative: packable.derivative,
945
+ positions
946
+ });
947
+ },
948
+ render: ({ position, action }) => {
949
+ const colors = {
950
+ [PlotAction.IDLE]: cesium.Color.BLUE.withAlpha(.4),
951
+ [PlotAction.HOVER]: cesium.Color.BLUE.withAlpha(.6),
952
+ [PlotAction.ACTIVE]: cesium.Color.AQUA.withAlpha(1)
953
+ };
954
+ return {
955
+ position,
956
+ point: {
957
+ pixelSize: 8,
958
+ color: colors[action],
959
+ disableDepthTestDistance: Number.POSITIVE_INFINITY,
960
+ outlineWidth: 1,
961
+ outlineColor: cesium.Color.WHITE.withAlpha(.4)
962
+ }
963
+ };
964
+ }
965
+ };
1005
966
  }
967
+
968
+ //#endregion
969
+ //#region skeleton/interval.ts
970
+ /**
971
+ * 绘制封闭的间隔框架点,如多边形。拖拽时,会在两点之间插入一个控制点,并持续拖拽该点。
972
+ */
1006
973
  function interval() {
1007
- let dragIndex = -1;
1008
- return {
1009
- disabled: ({ active, defining }) => !active || defining,
1010
- cursor: "pointer",
1011
- dragCursor: "crosshair",
1012
- format(packable) {
1013
- const _positions = packable.positions ?? [];
1014
- if (_positions.length < 2) {
1015
- return [];
1016
- }
1017
- return _positions.map((position, i) => {
1018
- const next = i === _positions.length - 1 ? _positions[0] : _positions[i + 1];
1019
- return cesium.Cartesian3.midpoint(position, next, new cesium.Cartesian3());
1020
- });
1021
- },
1022
- onDrag({ viewer, sampled, packable, event, index, lockCamera, dragging }) {
1023
- lockCamera();
1024
- const position = vesium.canvasCoordToCartesian(event.endPosition, viewer.scene);
1025
- if (!position) {
1026
- return;
1027
- }
1028
- const positions = [...packable.positions ?? []];
1029
- if (dragIndex === -1) {
1030
- dragIndex = index;
1031
- positions.splice(index + 1, 0, position);
1032
- } else {
1033
- positions[dragIndex + 1] = position;
1034
- }
1035
- if (!dragging) {
1036
- dragIndex = -1;
1037
- }
1038
- sampled.setSample({
1039
- time: packable.time,
1040
- derivative: packable.derivative,
1041
- positions
1042
- });
1043
- },
1044
- render: ({ position, action, active }) => {
1045
- if (!active) {
1046
- return;
1047
- }
1048
- const colors = {
1049
- [PlotAction.IDLE]: cesium.Color.GREEN.withAlpha(0.4),
1050
- [PlotAction.HOVER]: cesium.Color.GREEN.withAlpha(0.6),
1051
- [PlotAction.ACTIVE]: cesium.Color.GREEN.withAlpha(1)
1052
- };
1053
- return {
1054
- position,
1055
- point: {
1056
- pixelSize: 6,
1057
- color: colors[action],
1058
- disableDepthTestDistance: Number.POSITIVE_INFINITY,
1059
- outlineWidth: 1,
1060
- outlineColor: cesium.Color.WHITE.withAlpha(0.4)
1061
- }
1062
- };
1063
- }
1064
- };
974
+ let dragIndex = -1;
975
+ return {
976
+ disabled: ({ active, defining }) => !active || defining,
977
+ cursor: "pointer",
978
+ dragCursor: "crosshair",
979
+ format(packable) {
980
+ const _positions = packable.positions ?? [];
981
+ if (_positions.length < 2) return [];
982
+ return _positions.map((position, i) => {
983
+ const next = i === _positions.length - 1 ? _positions[0] : _positions[i + 1];
984
+ return cesium.Cartesian3.midpoint(position, next, new cesium.Cartesian3());
985
+ });
986
+ },
987
+ onDrag({ viewer, sampled, packable, event, index, lockCamera, dragging }) {
988
+ lockCamera();
989
+ const position = (0, vesium.canvasCoordToCartesian)(event.endPosition, viewer.scene);
990
+ if (!position) return;
991
+ const positions = [...packable.positions ?? []];
992
+ if (dragIndex === -1) {
993
+ dragIndex = index;
994
+ positions.splice(index + 1, 0, position);
995
+ } else positions[dragIndex + 1] = position;
996
+ if (!dragging) dragIndex = -1;
997
+ sampled.setSample({
998
+ time: packable.time,
999
+ derivative: packable.derivative,
1000
+ positions
1001
+ });
1002
+ },
1003
+ render: ({ position, action, active }) => {
1004
+ if (!active) return;
1005
+ const colors = {
1006
+ [PlotAction.IDLE]: cesium.Color.GREEN.withAlpha(.4),
1007
+ [PlotAction.HOVER]: cesium.Color.GREEN.withAlpha(.6),
1008
+ [PlotAction.ACTIVE]: cesium.Color.GREEN.withAlpha(1)
1009
+ };
1010
+ return {
1011
+ position,
1012
+ point: {
1013
+ pixelSize: 6,
1014
+ color: colors[action],
1015
+ disableDepthTestDistance: Number.POSITIVE_INFINITY,
1016
+ outlineWidth: 1,
1017
+ outlineColor: cesium.Color.WHITE.withAlpha(.4)
1018
+ }
1019
+ };
1020
+ }
1021
+ };
1065
1022
  }
1023
+
1024
+ //#endregion
1025
+ //#region skeleton/intervalNonclosed.ts
1026
+ /**
1027
+ * 绘制非封闭的间隔框架点,如线段。拖拽时,会在两点之间插入一个控制点,并持续拖拽该点。
1028
+ */
1066
1029
  function intervalNonclosed() {
1067
- let dragIndex = -1;
1068
- return {
1069
- disabled: ({ active, defining }) => !active || defining,
1070
- cursor: "pointer",
1071
- dragCursor: "crosshair",
1072
- format(packable) {
1073
- const _positions = packable.positions ?? [];
1074
- if (_positions.length < 2) {
1075
- return [];
1076
- }
1077
- const midpoints = [];
1078
- for (let i = 0; i < _positions.length - 1; i++) {
1079
- midpoints.push(cesium.Cartesian3.midpoint(_positions[i], _positions[i + 1], new cesium.Cartesian3()));
1080
- }
1081
- return midpoints;
1082
- },
1083
- onDrag({ viewer, sampled, packable, event, index, lockCamera, dragging }) {
1084
- lockCamera();
1085
- const position = vesium.canvasCoordToCartesian(event.endPosition, viewer.scene);
1086
- if (!position) {
1087
- return;
1088
- }
1089
- const positions = [...packable.positions ?? []];
1090
- if (dragIndex === -1) {
1091
- dragIndex = index;
1092
- positions.splice(index + 1, 0, position);
1093
- } else {
1094
- positions[dragIndex + 1] = position;
1095
- }
1096
- if (!dragging) {
1097
- dragIndex = -1;
1098
- }
1099
- sampled.setSample({
1100
- time: packable.time,
1101
- derivative: packable.derivative,
1102
- positions
1103
- });
1104
- },
1105
- render: ({ position, action }) => {
1106
- const colors = {
1107
- [PlotAction.IDLE]: cesium.Color.GREEN.withAlpha(0.4),
1108
- [PlotAction.HOVER]: cesium.Color.GREEN.withAlpha(0.6),
1109
- [PlotAction.ACTIVE]: cesium.Color.GREEN.withAlpha(1)
1110
- };
1111
- return {
1112
- position,
1113
- point: {
1114
- pixelSize: 6,
1115
- color: colors[action],
1116
- disableDepthTestDistance: Number.POSITIVE_INFINITY,
1117
- outlineWidth: 1,
1118
- outlineColor: cesium.Color.WHITE.withAlpha(0.4)
1119
- }
1120
- };
1121
- }
1122
- };
1030
+ let dragIndex = -1;
1031
+ return {
1032
+ disabled: ({ active, defining }) => !active || defining,
1033
+ cursor: "pointer",
1034
+ dragCursor: "crosshair",
1035
+ format(packable) {
1036
+ const _positions = packable.positions ?? [];
1037
+ if (_positions.length < 2) return [];
1038
+ const midpoints = [];
1039
+ for (let i = 0; i < _positions.length - 1; i++) midpoints.push(cesium.Cartesian3.midpoint(_positions[i], _positions[i + 1], new cesium.Cartesian3()));
1040
+ return midpoints;
1041
+ },
1042
+ onDrag({ viewer, sampled, packable, event, index, lockCamera, dragging }) {
1043
+ lockCamera();
1044
+ const position = (0, vesium.canvasCoordToCartesian)(event.endPosition, viewer.scene);
1045
+ if (!position) return;
1046
+ const positions = [...packable.positions ?? []];
1047
+ if (dragIndex === -1) {
1048
+ dragIndex = index;
1049
+ positions.splice(index + 1, 0, position);
1050
+ } else positions[dragIndex + 1] = position;
1051
+ if (!dragging) dragIndex = -1;
1052
+ sampled.setSample({
1053
+ time: packable.time,
1054
+ derivative: packable.derivative,
1055
+ positions
1056
+ });
1057
+ },
1058
+ render: ({ position, action }) => {
1059
+ const colors = {
1060
+ [PlotAction.IDLE]: cesium.Color.GREEN.withAlpha(.4),
1061
+ [PlotAction.HOVER]: cesium.Color.GREEN.withAlpha(.6),
1062
+ [PlotAction.ACTIVE]: cesium.Color.GREEN.withAlpha(1)
1063
+ };
1064
+ return {
1065
+ position,
1066
+ point: {
1067
+ pixelSize: 6,
1068
+ color: colors[action],
1069
+ disableDepthTestDistance: Number.POSITIVE_INFINITY,
1070
+ outlineWidth: 1,
1071
+ outlineColor: cesium.Color.WHITE.withAlpha(.4)
1072
+ }
1073
+ };
1074
+ }
1075
+ };
1123
1076
  }
1124
- const svg = `data:image/svg+xml;utf8,${encodeURIComponent(
1125
- '<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 24 24"><path stroke="#ffffff" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="m18 9l3 3l-3 3m-3-3h6M6 9l-3 3l3 3m-3-3h6m0 6l3 3l3-3m-3-3v6m3-15l-3-3l-3 3m3-3v6"/></svg>'
1126
- )}`;
1077
+
1078
+ //#endregion
1079
+ //#region skeleton/moved.ts
1080
+ const svg = `data:image/svg+xml;utf8,${encodeURIComponent("<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"32\" height=\"32\" viewBox=\"0 0 24 24\"><path stroke=\"#ffffff\" stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" d=\"m18 9l3 3l-3 3m-3-3h6M6 9l-3 3l3 3m-3-3h6m0 6l3 3l3-3m-3-3v6m3-15l-3-3l-3 3m3-3v6\"/></svg>")}`;
1081
+ /**
1082
+ * 绘制非封闭的间隔框架点,如线段。拖拽时,会在两点之间插入一个控制点,并持续拖拽该点。
1083
+ */
1127
1084
  function moved() {
1128
- return {
1129
- disabled: ({ active, defining }) => !active || defining,
1130
- cursor: "pointer",
1131
- dragCursor: "crosshair",
1132
- format(packable) {
1133
- const positions = packable.positions ?? [];
1134
- if (positions.length === 0) {
1135
- return [];
1136
- } else if (positions.length === 1) {
1137
- return [positions[0]];
1138
- } else {
1139
- const center = cesium.Rectangle.center(cesium.Rectangle.fromCartesianArray(positions));
1140
- return [vesium.toCartesian3(center)];
1141
- }
1142
- },
1143
- onDrag({ viewer, sampled, packable, event, lockCamera, dragging }) {
1144
- dragging && lockCamera();
1145
- const startPosition = vesium.canvasCoordToCartesian(event.startPosition, viewer.scene);
1146
- const endPosition = vesium.canvasCoordToCartesian(event.endPosition, viewer.scene);
1147
- if (!startPosition || !endPosition) {
1148
- return;
1149
- }
1150
- const offset = cesium.Cartesian3.subtract(endPosition, startPosition, new cesium.Cartesian3());
1151
- const positions = [...packable.positions ?? []];
1152
- sampled.setSample({
1153
- time: packable.time,
1154
- derivative: packable.derivative,
1155
- positions: positions.map((position) => cesium.Cartesian3.add(position, offset, new cesium.Cartesian3()))
1156
- });
1157
- },
1158
- render: ({ position, action }) => {
1159
- const colors = {
1160
- [PlotAction.IDLE]: cesium.Color.WHITE,
1161
- [PlotAction.HOVER]: cesium.Color.WHITE,
1162
- [PlotAction.ACTIVE]: cesium.Color.AQUA.withAlpha(1)
1163
- };
1164
- return {
1165
- position,
1166
- billboard: {
1167
- image: svg,
1168
- width: 20,
1169
- height: 20,
1170
- color: colors[action],
1171
- pixelOffset: new cesium.Cartesian3(0, -20),
1172
- horizontalOrigin: cesium.HorizontalOrigin.CENTER,
1173
- verticalOrigin: cesium.VerticalOrigin.BOTTOM,
1174
- disableDepthTestDistance: Number.POSITIVE_INFINITY
1175
- }
1176
- };
1177
- }
1178
- };
1085
+ return {
1086
+ disabled: ({ active, defining }) => !active || defining,
1087
+ cursor: "pointer",
1088
+ dragCursor: "crosshair",
1089
+ format(packable) {
1090
+ const positions = packable.positions ?? [];
1091
+ if (positions.length === 0) return [];
1092
+ else if (positions.length === 1) return [positions[0]];
1093
+ else {
1094
+ const center = cesium.Rectangle.center(cesium.Rectangle.fromCartesianArray(positions));
1095
+ return [(0, vesium.toCartesian3)(center)];
1096
+ }
1097
+ },
1098
+ onDrag({ viewer, sampled, packable, event, lockCamera, dragging }) {
1099
+ dragging && lockCamera();
1100
+ const startPosition = (0, vesium.canvasCoordToCartesian)(event.startPosition, viewer.scene);
1101
+ const endPosition = (0, vesium.canvasCoordToCartesian)(event.endPosition, viewer.scene);
1102
+ if (!startPosition || !endPosition) return;
1103
+ const offset = cesium.Cartesian3.subtract(endPosition, startPosition, new cesium.Cartesian3());
1104
+ const positions = [...packable.positions ?? []];
1105
+ sampled.setSample({
1106
+ time: packable.time,
1107
+ derivative: packable.derivative,
1108
+ positions: positions.map((position) => cesium.Cartesian3.add(position, offset, new cesium.Cartesian3()))
1109
+ });
1110
+ },
1111
+ render: ({ position, action }) => {
1112
+ const colors = {
1113
+ [PlotAction.IDLE]: cesium.Color.WHITE,
1114
+ [PlotAction.HOVER]: cesium.Color.WHITE,
1115
+ [PlotAction.ACTIVE]: cesium.Color.AQUA.withAlpha(1)
1116
+ };
1117
+ return {
1118
+ position,
1119
+ billboard: {
1120
+ image: svg,
1121
+ width: 20,
1122
+ height: 20,
1123
+ color: colors[action],
1124
+ pixelOffset: new cesium.Cartesian3(0, -20),
1125
+ horizontalOrigin: cesium.HorizontalOrigin.CENTER,
1126
+ verticalOrigin: cesium.VerticalOrigin.BOTTOM,
1127
+ disableDepthTestDistance: Number.POSITIVE_INFINITY
1128
+ }
1129
+ };
1130
+ }
1131
+ };
1179
1132
  }
1133
+
1134
+ //#endregion
1135
+ //#region measure/utils/tesselate.ts
1136
+ /**
1137
+ * 将多个边界点组成的面切割成多个三角形
1138
+ * @param positions
1139
+ */
1180
1140
  function tesselate(positions) {
1181
- if (positions.length < 3) {
1182
- throw new Error("positions must >= 3");
1183
- }
1184
- if (positions.length === 3) {
1185
- return [[positions[0].clone(), positions[1].clone(), positions[2].clone()]];
1186
- }
1187
- const geometry = cesium.CoplanarPolygonGeometry.createGeometry(
1188
- cesium.CoplanarPolygonGeometry.fromPositions({
1189
- positions,
1190
- vertexFormat: cesium.VertexFormat.POSITION_ONLY
1191
- })
1192
- );
1193
- if (!geometry) {
1194
- throw new Error("positions无法组成有效的geometry,检查点位是否错误");
1195
- }
1196
- const values = geometry.attributes.position.values;
1197
- const indices = geometry.indices;
1198
- const result = [];
1199
- for (let i = 0; i < indices.length; i += 3) {
1200
- const a = cesium.Cartesian3.unpack(values, indices[i] * 3, new cesium.Cartesian3());
1201
- const b = cesium.Cartesian3.unpack(values, indices[i + 1] * 3, new cesium.Cartesian3());
1202
- const c = cesium.Cartesian3.unpack(values, indices[i + 2] * 3, new cesium.Cartesian3());
1203
- result.push([a, b, c]);
1204
- }
1205
- return result;
1141
+ if (positions.length < 3) throw new Error("positions must >= 3");
1142
+ if (positions.length === 3) return [[
1143
+ positions[0].clone(),
1144
+ positions[1].clone(),
1145
+ positions[2].clone()
1146
+ ]];
1147
+ const geometry = cesium.CoplanarPolygonGeometry.createGeometry(cesium.CoplanarPolygonGeometry.fromPositions({
1148
+ positions,
1149
+ vertexFormat: cesium.VertexFormat.POSITION_ONLY
1150
+ }));
1151
+ if (!geometry) throw new Error("positions无法组成有效的geometry,检查点位是否错误");
1152
+ const values = geometry.attributes.position.values;
1153
+ const indices = geometry.indices;
1154
+ const result = [];
1155
+ for (let i = 0; i < indices.length; i += 3) {
1156
+ const a = cesium.Cartesian3.unpack(values, indices[i] * 3, new cesium.Cartesian3());
1157
+ const b = cesium.Cartesian3.unpack(values, indices[i + 1] * 3, new cesium.Cartesian3());
1158
+ const c = cesium.Cartesian3.unpack(values, indices[i + 2] * 3, new cesium.Cartesian3());
1159
+ result.push([
1160
+ a,
1161
+ b,
1162
+ c
1163
+ ]);
1164
+ }
1165
+ return result;
1206
1166
  }
1167
+
1168
+ //#endregion
1169
+ //#region measure/utils/clampToGround.ts
1170
+ /**
1171
+ * 将传入的点位列表进行贴地处理,若某个点位获取高程失败则将此进行克隆返回
1172
+ * @param options - 配置项
1173
+ */
1174
+ async function clampToHeightMostDetailedByTilesetOrTerrain(options) {
1175
+ const { positions, scene, classificationType = cesium.ClassificationType.BOTH, terrainProvider = scene.terrainProvider } = options;
1176
+ const tileset = [cesium.ClassificationType.BOTH, cesium.ClassificationType.CESIUM_3D_TILE].includes(classificationType);
1177
+ const terrain = [cesium.ClassificationType.BOTH, cesium.ClassificationType.TERRAIN].includes(classificationType);
1178
+ const tilesetPromise = new Promise((resolve) => {
1179
+ if (tileset) scene.clampToHeightMostDetailed(positions.map((e) => e.clone())).then(resolve).catch((error) => {
1180
+ console.warn(error);
1181
+ resolve([]);
1182
+ });
1183
+ else resolve([]);
1184
+ });
1185
+ const terrainPromise = new Promise((resolve) => {
1186
+ if (terrain && terrainProvider) (0, cesium.sampleTerrainMostDetailed)(terrainProvider, positions.map((e) => cesium.Cartographic.fromCartesian(e))).then((e) => resolve(e)).catch((error) => {
1187
+ console.warn(error);
1188
+ resolve([]);
1189
+ });
1190
+ else resolve([]);
1191
+ });
1192
+ const [tilesetPositions, terrainPositions] = await Promise.all([tilesetPromise, terrainPromise]);
1193
+ const resluts = [];
1194
+ positions.forEach((item, index) => {
1195
+ const position = tilesetPositions[index] || terrainPositions[index] ? cesium.Ellipsoid.WGS84.cartographicToCartesian(terrainPositions[index]) : item.clone();
1196
+ resluts.push(position);
1197
+ });
1198
+ return resluts;
1199
+ }
1200
+
1201
+ //#endregion
1202
+ //#region measure/utils/triangleGrid.ts
1203
+ function defaultOptions$2(original) {
1204
+ const clampToGround = original?.clampToGround ?? false;
1205
+ const classificationType = original?.classificationType ?? cesium.ClassificationType.BOTH;
1206
+ const density = Math.floor(original?.density ?? 10);
1207
+ return {
1208
+ scene: original?.scene,
1209
+ clampToGround,
1210
+ classificationType,
1211
+ terrainProvider: original?.terrainProvider,
1212
+ density
1213
+ };
1214
+ }
1215
+ /**
1216
+ * 生成三角网数组
1217
+ * @param positions - 边界点数组
1218
+ * @param options - 配置项
1219
+ */
1220
+ async function triangleGrid(positions, options) {
1221
+ if (positions.length < 3) throw new Error("positions must >= 3");
1222
+ const { density, scene, clampToGround, classificationType, terrainProvider } = defaultOptions$2(options);
1223
+ if (density <= 0) throw new Error("options.density must > 0");
1224
+ const bbox = cesium.Rectangle.fromCartesianArray(positions);
1225
+ const vertical = bbox.north - bbox.south;
1226
+ const horizontal = bbox.east - bbox.west;
1227
+ const max = Math.max(horizontal, vertical);
1228
+ const granularity = max / density;
1229
+ const polygonGeometry = cesium.PolygonGeometry.fromPositions({
1230
+ positions,
1231
+ vertexFormat: cesium.PerInstanceColorAppearance.FLAT_VERTEX_FORMAT,
1232
+ granularity
1233
+ });
1234
+ const geometry = cesium.PolygonGeometry.createGeometry(polygonGeometry);
1235
+ const values = geometry.attributes.position.values;
1236
+ if (!geometry || !values) throw new Error("positions无法组成有效的geometry,检查点位是否错误");
1237
+ const indices = geometry.indices;
1238
+ let cartesian3List = [];
1239
+ for (let i = 0; i < indices.length; i += 3) {
1240
+ const a = cesium.Cartesian3.unpack(values, indices[i] * 3, new cesium.Cartesian3());
1241
+ const b = cesium.Cartesian3.unpack(values, indices[i + 1] * 3, new cesium.Cartesian3());
1242
+ const c = cesium.Cartesian3.unpack(values, indices[i + 2] * 3, new cesium.Cartesian3());
1243
+ cartesian3List.push(a, b, c);
1244
+ }
1245
+ if (clampToGround) {
1246
+ if (!scene) throw new Error("scene is required on `clampToGround == true`.");
1247
+ const detaileds = await clampToHeightMostDetailedByTilesetOrTerrain({
1248
+ scene,
1249
+ terrainProvider,
1250
+ positions: cartesian3List,
1251
+ classificationType
1252
+ });
1253
+ cartesian3List = detaileds;
1254
+ }
1255
+ const grid = [];
1256
+ while (cartesian3List?.length) {
1257
+ const [a, b, c] = cartesian3List.splice(0, 3);
1258
+ grid.push([
1259
+ a,
1260
+ b,
1261
+ c
1262
+ ]);
1263
+ }
1264
+ return grid;
1265
+ }
1266
+
1267
+ //#endregion
1268
+ //#region measure/utils/area.ts
1269
+ /**
1270
+ * 计算三维坐标系下三角形面积
1271
+ * @param p0 - 三角形第一个点
1272
+ * @param p1 - 三角形第二个点
1273
+ * @param p2 - 三角形第三个点
1274
+ */
1207
1275
  function triangleArea(p0, p1, p2) {
1208
- const v0 = cesium.Cartesian3.subtract(p0, p1, new cesium.Cartesian3());
1209
- const v1 = cesium.Cartesian3.subtract(p2, p1, new cesium.Cartesian3());
1210
- const cross = cesium.Cartesian3.cross(v0, v1, v0);
1211
- return cesium.Cartesian3.magnitude(cross) * 0.5;
1276
+ const v0 = cesium.Cartesian3.subtract(p0, p1, new cesium.Cartesian3());
1277
+ const v1 = cesium.Cartesian3.subtract(p2, p1, new cesium.Cartesian3());
1278
+ const cross = cesium.Cartesian3.cross(v0, v1, v0);
1279
+ return cesium.Cartesian3.magnitude(cross) * .5;
1212
1280
  }
1213
- function defaultOptions(original) {
1214
- const clampToGround = false;
1215
- const classificationType = cesium.ClassificationType.BOTH;
1216
- const density = Math.floor(10);
1217
- return {
1218
- scene: original == null ? void 0 : original.scene,
1219
- clampToGround,
1220
- classificationType,
1221
- terrainProvider: original == null ? void 0 : original.terrainProvider,
1222
- density
1223
- };
1281
+ function defaultOptions$1(original) {
1282
+ const clampToGround = original?.clampToGround ?? false;
1283
+ const classificationType = original?.classificationType ?? cesium.ClassificationType.BOTH;
1284
+ const density = Math.floor(original?.density ?? 10);
1285
+ return {
1286
+ scene: original?.scene,
1287
+ clampToGround,
1288
+ classificationType,
1289
+ terrainProvider: original?.terrainProvider,
1290
+ density
1291
+ };
1224
1292
  }
1293
+ /**
1294
+ * 计算三维坐标系下图形面积
1295
+ * @param positions - 图形各点的笛卡尔数组
1296
+ */
1225
1297
  async function area(positions, options) {
1226
- if (positions.length < 2) {
1227
- throw new Error("positions.length must >= 2");
1228
- }
1229
- const { density } = defaultOptions(options);
1230
- if (density <= 0) {
1231
- throw new Error("options.density must > 0");
1232
- }
1233
- {
1234
- const triangles2 = tesselate(positions);
1235
- return triangles2.reduce((count, current) => count += triangleArea(...current), 0);
1236
- }
1298
+ if (positions.length < 2) throw new Error("positions.length must >= 2");
1299
+ const { density, scene, clampToGround, classificationType, terrainProvider } = defaultOptions$1(options);
1300
+ if (density <= 0) throw new Error("options.density must > 0");
1301
+ if (!clampToGround) {
1302
+ const triangles$1 = tesselate(positions);
1303
+ return triangles$1.reduce((count, current) => count += triangleArea(...current), 0);
1304
+ }
1305
+ const triangles = await triangleGrid(positions, {
1306
+ density,
1307
+ scene,
1308
+ clampToGround,
1309
+ classificationType,
1310
+ terrainProvider
1311
+ });
1312
+ return triangles.reduce((count, current) => count += triangleArea(...current), 0);
1237
1313
  }
1314
+
1315
+ //#endregion
1316
+ //#region measure/utils/lerpArray.ts
1317
+ /**
1318
+ * 在起点和终点间进行插值, 返回的数组包括起点和终点,数组长度为 count+1
1319
+ */
1320
+ async function lerpArray(options) {
1321
+ const { start, end, count, scene, clampToGround, classificationType, terrainProvider } = options;
1322
+ const result = [];
1323
+ for (let i = 0; i < count; i++) {
1324
+ const position = cesium.Cartesian3.lerp(start, end, 1 / count, new cesium.Cartesian3());
1325
+ result.push(position);
1326
+ }
1327
+ result.push(end.clone());
1328
+ if (!clampToGround) return result;
1329
+ if (!scene) throw new Error("scene is required on `clampToGround == true`.");
1330
+ const detaileds = await clampToHeightMostDetailedByTilesetOrTerrain({
1331
+ scene,
1332
+ terrainProvider,
1333
+ positions: result,
1334
+ classificationType
1335
+ });
1336
+ return detaileds;
1337
+ }
1338
+
1339
+ //#endregion
1340
+ //#region measure/utils/distance.ts
1341
+ function defaultOptions(original) {
1342
+ const clampToGround = original?.clampToGround ?? false;
1343
+ const classificationType = original?.classificationType ?? cesium.ClassificationType.BOTH;
1344
+ const density = Math.floor(original?.density ?? 50);
1345
+ return {
1346
+ scene: original?.scene,
1347
+ clampToGround,
1348
+ classificationType,
1349
+ terrainProvider: original?.terrainProvider,
1350
+ density
1351
+ };
1352
+ }
1353
+ /**
1354
+ * 计算多点位之间的距离
1355
+ * @param positions
1356
+ */
1357
+ async function distance(positions, options) {
1358
+ if (positions.length < 2) throw new Error("positions.length must >= 2");
1359
+ const _options = defaultOptions(options);
1360
+ const stages = [];
1361
+ let count = 0;
1362
+ positions.forEach((position, index) => {
1363
+ if (index !== positions.length - 1) {
1364
+ const next = positions[index + 1];
1365
+ const distance$1 = cesium.Cartesian3.distance(position, next);
1366
+ stages.push(distance$1);
1367
+ count += distance$1;
1368
+ }
1369
+ });
1370
+ if (!_options.clampToGround) return {
1371
+ stages,
1372
+ count
1373
+ };
1374
+ const density = _options.density;
1375
+ if (density <= 0) throw new Error("options.density must > 0");
1376
+ const densities = stages.map((stage) => {
1377
+ return Math.floor(stage / count * density);
1378
+ });
1379
+ const diff = density - densities.reduce((count$1, current) => count$1 += current, 0);
1380
+ if (diff) densities[densities.length - 1] += diff;
1381
+ const positionListPromises = densities.map((density$1, i) => {
1382
+ return lerpArray({
1383
+ scene: _options.scene,
1384
+ start: positions[i],
1385
+ end: positions[i + 1],
1386
+ count: density$1,
1387
+ clampToGround: true,
1388
+ classificationType: _options.classificationType,
1389
+ terrainProvider: _options.terrainProvider
1390
+ });
1391
+ });
1392
+ const detaileds = await Promise.all(positionListPromises);
1393
+ const stagePromises = detaileds.map(async (positions$1) => {
1394
+ const { count: count$1 } = await distance(positions$1);
1395
+ return count$1;
1396
+ });
1397
+ const groundStages = await Promise.all(stagePromises);
1398
+ return {
1399
+ stages: groundStages,
1400
+ count: groundStages.reduce((count$1, current) => count$1 += current, 0)
1401
+ };
1402
+ }
1403
+
1404
+ //#endregion
1405
+ //#region measure/measureArea.ts
1238
1406
  const schemeMeasureArea = new PlotScheme({
1239
- type: "measureArea",
1240
- allowManualComplete: (packable) => packable.positions.length >= 3,
1241
- skeletons: [
1242
- control,
1243
- interval
1244
- ],
1245
- initEntites: () => [
1246
- new cesium.Entity({
1247
- label: {
1248
- font: "14pt"
1249
- },
1250
- polyline: {
1251
- material: cesium.Color.YELLOW.withAlpha(0.5)
1252
- },
1253
- polygon: {
1254
- material: cesium.Color.YELLOW.withAlpha(0.5)
1255
- }
1256
- })
1257
- ],
1258
- render(options) {
1259
- var _a;
1260
- const { mouse, packable } = options;
1261
- const entity = ((_a = options.previous.entities) == null ? void 0 : _a[0]) ?? new cesium.Entity({
1262
- label: {
1263
- font: "14pt"
1264
- },
1265
- polyline: {
1266
- material: cesium.Color.YELLOW.withAlpha(0.5)
1267
- },
1268
- polygon: {
1269
- material: cesium.Color.YELLOW.withAlpha(0.5)
1270
- }
1271
- });
1272
- const positions = [...packable.positions ?? []];
1273
- mouse && positions.push(mouse);
1274
- if (positions.length === 2) {
1275
- entity.position = void 0;
1276
- entity.label.text = void 0;
1277
- entity.polygon.hierarchy = void 0;
1278
- entity.polyline.positions = new cesium.CallbackProperty(() => positions, false);
1279
- } else if (positions.length >= 3) {
1280
- positions.push(positions[0]);
1281
- entity.position = new cesium.ConstantPositionProperty(
1282
- vesium.toCartesian3(
1283
- cesium.Rectangle.center(cesium.Rectangle.fromCartesianArray(positions))
1284
- )
1285
- );
1286
- entity.label.text = new cesium.ConstantProperty("");
1287
- area(positions).then((e) => {
1288
- let text = "";
1289
- if (e / 1e3 / 1e3 > 10) {
1290
- text = `${(e / 1e3 / 1e3).toFixed(2)}km²`;
1291
- } else {
1292
- text = `${(+e).toFixed(2)}m²`;
1293
- }
1294
- entity.label.text = new cesium.ConstantProperty(text);
1295
- });
1296
- entity.polyline.positions = void 0;
1297
- entity.polygon.hierarchy = new cesium.CallbackProperty(() => {
1298
- return positions.length >= 3 ? new cesium.PolygonHierarchy([...positions]) : void 0;
1299
- }, false);
1300
- } else {
1301
- entity.position = void 0;
1302
- entity.polygon.hierarchy = void 0;
1303
- entity.polyline.positions = void 0;
1304
- }
1305
- return {
1306
- entities: [entity]
1307
- };
1308
- }
1407
+ type: "MeasureArea",
1408
+ allowManualComplete: (packable) => packable.positions.length >= 3,
1409
+ skeletons: [control, interval],
1410
+ initRender() {
1411
+ return { entities: [new cesium.Entity({
1412
+ label: { font: "14pt" },
1413
+ polyline: { material: cesium.Color.YELLOW.withAlpha(.5) },
1414
+ polygon: { material: cesium.Color.YELLOW.withAlpha(.5) }
1415
+ })] };
1416
+ },
1417
+ render(context) {
1418
+ const entity = context.previous.entities[0];
1419
+ const { mouse, packable } = context;
1420
+ const positions = [...packable.positions ?? []];
1421
+ mouse && positions.push(mouse);
1422
+ if (positions.length === 2) {
1423
+ entity.position = void 0;
1424
+ entity.label.text = void 0;
1425
+ entity.polygon.hierarchy = void 0;
1426
+ entity.polyline.positions = new cesium.CallbackProperty(() => positions, false);
1427
+ } else if (positions.length >= 3) {
1428
+ positions.push(positions[0]);
1429
+ entity.position = new cesium.ConstantPositionProperty((0, vesium.toCartesian3)(cesium.Rectangle.center(cesium.Rectangle.fromCartesianArray(positions))));
1430
+ entity.label.text = new cesium.ConstantProperty("");
1431
+ area(positions).then((e) => {
1432
+ let text = "";
1433
+ if (e / 1e3 / 1e3 > 10) text = `${(e / 1e3 / 1e3).toFixed(2)}km²`;
1434
+ else text = `${(+e).toFixed(2)}m²`;
1435
+ entity.label.text = new cesium.ConstantProperty(text);
1436
+ });
1437
+ entity.polyline.positions = void 0;
1438
+ entity.polygon.hierarchy = new cesium.CallbackProperty(() => {
1439
+ return positions.length >= 3 ? new cesium.PolygonHierarchy([...positions]) : void 0;
1440
+ }, false);
1441
+ } else {
1442
+ entity.position = void 0;
1443
+ entity.polygon.hierarchy = void 0;
1444
+ entity.polyline.positions = void 0;
1445
+ }
1446
+ return { entities: [entity] };
1447
+ }
1448
+ });
1449
+
1450
+ //#endregion
1451
+ //#region measure/measureDistance.ts
1452
+ const schemeMeasureDistance = new PlotScheme({
1453
+ type: "MeasureDistance",
1454
+ allowManualComplete: (packable) => packable.positions.length >= 2,
1455
+ skeletons: [control],
1456
+ initRender() {
1457
+ return { entities: [new cesium.Entity({ polyline: {
1458
+ width: 2,
1459
+ material: cesium.Color.YELLOW.withAlpha(.5)
1460
+ } })] };
1461
+ },
1462
+ render(context) {
1463
+ const entity = context.previous.entities[0];
1464
+ const { mouse, packable, previous } = context;
1465
+ const entities = previous.entities;
1466
+ const positions = [...packable.positions ?? []];
1467
+ mouse && positions.push(mouse);
1468
+ if (positions.length < 2) return { entities };
1469
+ const pl = entities[0];
1470
+ pl.polyline ??= new cesium.PolylineGraphics();
1471
+ pl.polyline.positions = new cesium.CallbackProperty(() => positions, false);
1472
+ positions.forEach((item, index) => {
1473
+ if (!entities[index + 1]) entities[index + 1] = new cesium.Entity({
1474
+ position: item,
1475
+ label: new cesium.LabelGraphics({
1476
+ backgroundColor: cesium.Color.fromCssColorString("#fff"),
1477
+ font: "12pt sans-serif"
1478
+ })
1479
+ });
1480
+ });
1481
+ entities.splice(positions.length, entities.length - positions.length - 1);
1482
+ distance(positions).then(({ count, stages }) => {
1483
+ stages.forEach((stage, index) => {
1484
+ entities[index + 1].position = new cesium.CallbackPositionProperty(() => cesium.Cartesian3.midpoint(positions[index], positions[index + 1], new cesium.Cartesian3()), false);
1485
+ entities[index + 1].label.text = new cesium.CallbackProperty(() => `${stage.toFixed(2)} m`, false);
1486
+ });
1487
+ if (stages.length > 1) {
1488
+ entities[entities.length - 1].position = new cesium.CallbackPositionProperty(() => positions[positions.length - 1], false);
1489
+ entities[entities.length - 1].label.text = new cesium.CallbackProperty(() => `${count.toFixed(2)} m`, false);
1490
+ } else {
1491
+ entities[entities.length - 1].position = void 0;
1492
+ entities[entities.length - 1].label.text = void 0;
1493
+ }
1494
+ });
1495
+ return { entities };
1496
+ }
1497
+ });
1498
+
1499
+ //#endregion
1500
+ //#region scheme/Billboard.ts
1501
+ const PlotSchemeBillboard = new PlotScheme({
1502
+ type: "Billboard",
1503
+ complete: (packable) => packable.positions.length >= 1,
1504
+ skeletons: [moved],
1505
+ initRender: () => {
1506
+ return { entities: [new cesium.Entity({ billboard: {
1507
+ image: "/favicon.svg",
1508
+ width: 32,
1509
+ height: 32
1510
+ } })] };
1511
+ },
1512
+ render(options) {
1513
+ const { mouse, packable } = options;
1514
+ const entity = options.previous.entities?.[0] ?? new cesium.Entity({ billboard: {} });
1515
+ const position = packable.positions?.[0] ?? mouse;
1516
+ entity.position = new cesium.CallbackPositionProperty(() => position, true);
1517
+ return { entities: [entity] };
1518
+ }
1519
+ });
1520
+
1521
+ //#endregion
1522
+ //#region scheme/BillboardPinBuilder.ts
1523
+ const PlotSchemeBillboardPinBuilder = new PlotScheme({
1524
+ type: "BillboardPinBuilder",
1525
+ complete: (packable) => packable.positions.length >= 1,
1526
+ skeletons: [moved],
1527
+ initRender() {
1528
+ return { entities: [new cesium.Entity({ billboard: {} })] };
1529
+ },
1530
+ render(context) {
1531
+ const entity = context.previous.entities[0];
1532
+ const position = context.packable.positions[0] ?? context.mouse;
1533
+ entity.position = new cesium.CallbackPositionProperty(() => position, true);
1534
+ return { entities: [entity] };
1535
+ }
1536
+ });
1537
+
1538
+ //#endregion
1539
+ //#region scheme/Cylinder.ts
1540
+ const PlotSchemeCylinder = new PlotScheme({
1541
+ type: "Cylinder",
1542
+ complete: (packable) => packable.positions.length >= 2,
1543
+ skeletons: [moved, control],
1544
+ initRender() {
1545
+ return { entities: [new cesium.Entity({ cylinder: {} })] };
1546
+ },
1547
+ render(context) {
1548
+ const entity = context.previous.entities[0];
1549
+ const positions = [...context.packable.positions];
1550
+ if (positions.length === 0) return context.previous;
1551
+ if (positions.length === 1) {
1552
+ const position = context.mouse;
1553
+ position && positions.push(position);
1554
+ }
1555
+ if (positions.length < 2) return context.previous;
1556
+ entity.position = new cesium.ConstantPositionProperty(positions[0]);
1557
+ const radius = cesium.Cartesian3.distance(positions[0], positions[1]);
1558
+ entity.cylinder.bottomRadius = new cesium.CallbackProperty(() => radius, false);
1559
+ if (context.defining || !(0, vesium.toPropertyValue)(entity.cylinder.length)) entity.cylinder.length = (0, vesium.toProperty)(radius * 2);
1560
+ return { entities: [entity] };
1561
+ }
1562
+ });
1563
+
1564
+ //#endregion
1565
+ //#region scheme/Ellipse.ts
1566
+ const PlotSchemeEllipse = new PlotScheme({
1567
+ type: "Ellipse",
1568
+ complete: (packable) => packable.positions.length >= 2,
1569
+ skeletons: [moved, control],
1570
+ initRender() {
1571
+ return { entities: [new cesium.Entity({ ellipse: {} })] };
1572
+ },
1573
+ render(context) {
1574
+ const entity = context.previous.entities[0];
1575
+ const positions = [...context.packable.positions];
1576
+ if (positions.length === 0) return context.previous;
1577
+ if (positions.length === 1) {
1578
+ const position = context.mouse;
1579
+ position && positions.push(position);
1580
+ }
1581
+ if (positions.length < 2) return context.previous;
1582
+ entity.position = new cesium.ConstantPositionProperty(positions[0]);
1583
+ const radius = cesium.Cartesian3.distance(positions[0], positions[1]);
1584
+ entity.ellipse.semiMinorAxis = new cesium.CallbackProperty(() => radius || 1, false);
1585
+ entity.ellipse.semiMajorAxis = entity.ellipse.semiMinorAxis;
1586
+ return { entities: [entity] };
1587
+ }
1588
+ });
1589
+
1590
+ //#endregion
1591
+ //#region scheme/Label.ts
1592
+ const PlotSchemeLabel = new PlotScheme({
1593
+ type: "Label",
1594
+ complete: (packable) => packable.positions.length >= 1,
1595
+ skeletons: [moved],
1596
+ initRender() {
1597
+ return { entities: [new cesium.Entity({ label: { text: "Label" } })] };
1598
+ },
1599
+ render(context) {
1600
+ const entity = context.previous.entities[0];
1601
+ const position = context.packable.positions[0] ?? context.mouse;
1602
+ entity.position = new cesium.CallbackPositionProperty(() => position, true);
1603
+ return { entities: [entity] };
1604
+ }
1605
+ });
1606
+
1607
+ //#endregion
1608
+ //#region scheme/Point.ts
1609
+ const PlotSchemePoint = new PlotScheme({
1610
+ type: "Point",
1611
+ complete: (packable) => packable.positions.length >= 1,
1612
+ skeletons: [moved],
1613
+ initRender() {
1614
+ return { entities: [new cesium.Entity({ point: {
1615
+ pixelSize: 10,
1616
+ color: cesium.Color.RED
1617
+ } })] };
1618
+ },
1619
+ render(context) {
1620
+ const entity = context.previous.entities[0];
1621
+ const position = context.packable.positions[0] ?? context.mouse;
1622
+ entity.position = new cesium.CallbackPositionProperty(() => position, true);
1623
+ return { entities: [entity] };
1624
+ }
1625
+ });
1626
+
1627
+ //#endregion
1628
+ //#region scheme/Polygon.ts
1629
+ const PlotSchemePolygon = new PlotScheme({
1630
+ type: "Polygon",
1631
+ allowManualComplete: (packable) => packable.positions.length >= 2,
1632
+ skeletons: [
1633
+ moved,
1634
+ control,
1635
+ interval
1636
+ ],
1637
+ initRender: () => {
1638
+ return { entities: [new cesium.Entity({
1639
+ polyline: {},
1640
+ polygon: {}
1641
+ })] };
1642
+ },
1643
+ render(options) {
1644
+ const { mouse, packable } = options;
1645
+ const entity = options.previous.entities[0];
1646
+ const positions = [...packable.positions ?? []];
1647
+ mouse && positions.push(mouse);
1648
+ if (positions.length === 2) {
1649
+ entity.polygon.hierarchy = void 0;
1650
+ entity.polyline.positions = new cesium.CallbackProperty(() => positions, false);
1651
+ } else if (positions.length >= 3) {
1652
+ entity.polyline.positions = void 0;
1653
+ entity.polygon.hierarchy = new cesium.CallbackProperty(() => {
1654
+ positions.push(positions[0]);
1655
+ return positions.length >= 3 ? new cesium.PolygonHierarchy([...positions]) : void 0;
1656
+ }, false);
1657
+ } else {
1658
+ entity.polygon.hierarchy = void 0;
1659
+ entity.polyline.positions = void 0;
1660
+ }
1661
+ return { entities: [entity] };
1662
+ }
1663
+ });
1664
+
1665
+ //#endregion
1666
+ //#region geom/helper.ts
1667
+ const FITTING_COUNT = 100;
1668
+ const HALF_PI = Math.PI / 2;
1669
+ const ZERO_TOLERANCE = 1e-4;
1670
+ const TWO_PI = Math.PI * 2;
1671
+ /**
1672
+ * 计算两个坐标之间的距离
1673
+ * @param coord1
1674
+ * @param coord2
1675
+ */
1676
+ function mathDistance(coord1, coord2) {
1677
+ return Math.hypot(coord1[0] - coord2[0], coord1[1] - coord2[1]);
1678
+ }
1679
+ /**
1680
+ * 计算点集合的总距离
1681
+ * @param points
1682
+ */
1683
+ function wholeDistance(points) {
1684
+ let distance$1 = 0;
1685
+ if (points && Array.isArray(points) && points.length > 0) points.forEach((item, index) => {
1686
+ if (index < points.length - 1) distance$1 += mathDistance(item, points[index + 1]);
1687
+ });
1688
+ return distance$1;
1689
+ }
1690
+ /**
1691
+ * 获取基础长度
1692
+ * @param points
1693
+ */
1694
+ const getBaseLength = (points) => wholeDistance(points) ** .99;
1695
+ /**
1696
+ * 求取两个坐标的中间坐标
1697
+ * @param coord1
1698
+ * @param coord2
1699
+ */
1700
+ function mid(coord1, coord2) {
1701
+ return [(coord1[0] + coord2[0]) / 2, (coord1[1] + coord2[1]) / 2];
1702
+ }
1703
+ /**
1704
+ * 通过三个点确定一个圆的中心点
1705
+ * @param coord1
1706
+ * @param coord2
1707
+ * @param coord3
1708
+ */
1709
+ function getCircleCenterOfThreeCoords(coord1, coord2, coord3) {
1710
+ const coordA = [(coord1[0] + coord2[0]) / 2, (coord1[1] + coord2[1]) / 2];
1711
+ const coordB = [coordA[0] - coord1[1] + coord2[1], coordA[1] + coord1[0] - coord2[0]];
1712
+ const coordC = [(coord1[0] + coord3[0]) / 2, (coord1[1] + coord3[1]) / 2];
1713
+ const coordD = [coordC[0] - coord1[1] + coord3[1], coordC[1] + coord1[0] - coord3[0]];
1714
+ return getIntersectCoord(coordA, coordB, coordC, coordD);
1715
+ }
1716
+ /**
1717
+ * 获取交集的点
1718
+ * @param coordA
1719
+ * @param coordB
1720
+ * @param coordC
1721
+ * @param coordD
1722
+ */
1723
+ function getIntersectCoord(coordA, coordB, coordC, coordD) {
1724
+ if (coordA[1] === coordB[1]) {
1725
+ const f$1 = (coordD[0] - coordC[0]) / (coordD[1] - coordC[1]);
1726
+ const x$1 = f$1 * (coordA[1] - coordC[1]) + coordC[0];
1727
+ const y$1 = coordA[1];
1728
+ return [x$1, y$1];
1729
+ }
1730
+ if (coordC[1] === coordD[1]) {
1731
+ const e$1 = (coordB[0] - coordA[0]) / (coordB[1] - coordA[1]);
1732
+ const x$1 = e$1 * (coordC[1] - coordA[1]) + coordA[0];
1733
+ const y$1 = coordC[1];
1734
+ return [x$1, y$1];
1735
+ }
1736
+ const e = (coordB[0] - coordA[0]) / (coordB[1] - coordA[1]);
1737
+ const f = (coordD[0] - coordC[0]) / (coordD[1] - coordC[1]);
1738
+ const y = (e * coordA[1] - coordA[0] - f * coordC[1] + coordC[0]) / (e - f);
1739
+ const x = e * y - e * coordA[1] + coordA[0];
1740
+ return [x, y];
1741
+ }
1742
+ /**
1743
+ * 获取方位角(地平经度)
1744
+ * @param startCoord
1745
+ * @param endCoord
1746
+ */
1747
+ function getAzimuth(startCoord, endCoord) {
1748
+ let azimuth = 0;
1749
+ const angle = Math.asin(Math.abs(endCoord[1] - startCoord[1]) / mathDistance(startCoord, endCoord));
1750
+ if (endCoord[1] >= startCoord[1] && endCoord[0] >= startCoord[0]) azimuth = angle + Math.PI;
1751
+ else if (endCoord[1] >= startCoord[1] && endCoord[0] < startCoord[0]) azimuth = Math.PI * 2 - angle;
1752
+ else if (endCoord[1] < startCoord[1] && endCoord[0] < startCoord[0]) azimuth = angle;
1753
+ else if (endCoord[1] < startCoord[1] && endCoord[0] >= startCoord[0]) azimuth = Math.PI - angle;
1754
+ return azimuth;
1755
+ }
1756
+ /**
1757
+ * 通过三个点获取方位角
1758
+ * @param coordA
1759
+ * @param coordB
1760
+ * @param coordC
1761
+ */
1762
+ function getAngleOfThreeCoords(coordA, coordB, coordC) {
1763
+ const angle = getAzimuth(coordB, coordA) - getAzimuth(coordB, coordC);
1764
+ return angle < 0 ? angle + Math.PI * 2 : angle;
1765
+ }
1766
+ /**
1767
+ * 判断是否是顺时针
1768
+ * @param coord1
1769
+ * @param coord2
1770
+ * @param coord3
1771
+ */
1772
+ function isClockWise(coord1, coord2, coord3) {
1773
+ return (coord3[1] - coord1[1]) * (coord2[0] - coord1[0]) > (coord2[1] - coord1[1]) * (coord3[0] - coord1[0]);
1774
+ }
1775
+ /**
1776
+ * 获取立方值
1777
+ */
1778
+ function getCubicValue(t, startCoord, coord1, coord2, endCoord) {
1779
+ t = Math.max(Math.min(t, 1), 0);
1780
+ const [tp, t2] = [1 - t, t * t];
1781
+ const t3 = t2 * t;
1782
+ const tp2 = tp * tp;
1783
+ const tp3 = tp2 * tp;
1784
+ const x = tp3 * startCoord[0] + 3 * tp2 * t * coord1[0] + 3 * tp * t2 * coord2[0] + t3 * endCoord[0];
1785
+ const y = tp3 * startCoord[1] + 3 * tp2 * t * coord1[1] + 3 * tp * t2 * coord2[1] + t3 * endCoord[1];
1786
+ return [x, y];
1787
+ }
1788
+ /**
1789
+ * 根据起止点和旋转方向求取第三个点
1790
+ * @param startCoord
1791
+ * @param endCoord
1792
+ * @param angle
1793
+ * @param distance
1794
+ * @param clockWise
1795
+ */
1796
+ function getThirdCoord(startCoord, endCoord, angle, distance$1, clockWise) {
1797
+ const azimuth = getAzimuth(startCoord, endCoord);
1798
+ const alpha = clockWise ? azimuth + angle : azimuth - angle;
1799
+ const dx = distance$1 * Math.cos(alpha);
1800
+ const dy = distance$1 * Math.sin(alpha);
1801
+ return [endCoord[0] + dx, endCoord[1] + dy];
1802
+ }
1803
+ /**
1804
+ * 插值弓形线段点
1805
+ * @param center
1806
+ * @param radius
1807
+ * @param startAngle
1808
+ * @param endAngle
1809
+ */
1810
+ function getArcCoords(center, radius, startAngle, endAngle) {
1811
+ let [x, y, coords, angleDiff] = [
1812
+ 0,
1813
+ 0,
1814
+ [],
1815
+ endAngle - startAngle
1816
+ ];
1817
+ angleDiff = angleDiff < 0 ? angleDiff + Math.PI * 2 : angleDiff;
1818
+ for (let i = 0; i <= 100; i++) {
1819
+ const angle = startAngle + angleDiff * i / 100;
1820
+ x = center[0] + radius * Math.cos(angle);
1821
+ y = center[1] + radius * Math.sin(angle);
1822
+ coords.push([x, y]);
1823
+ }
1824
+ return coords;
1825
+ }
1826
+ /**
1827
+ * getBisectorNormals
1828
+ * @param t
1829
+ * @param coord1
1830
+ * @param coord2
1831
+ * @param coord3
1832
+ */
1833
+ function getBisectorNormals(t, coord1, coord2, coord3) {
1834
+ const normal = getNormal(coord1, coord2, coord3);
1835
+ let [bisectorNormalRight, bisectorNormalLeft, dt, x, y] = [
1836
+ [0, 0],
1837
+ [0, 0],
1838
+ 0,
1839
+ 0,
1840
+ 0
1841
+ ];
1842
+ const dist = Math.hypot(normal[0], normal[1]);
1843
+ const uX = normal[0] / dist;
1844
+ const uY = normal[1] / dist;
1845
+ const d1 = mathDistance(coord1, coord2);
1846
+ const d2 = mathDistance(coord2, coord3);
1847
+ if (dist > ZERO_TOLERANCE) if (isClockWise(coord1, coord2, coord3)) {
1848
+ dt = t * d1;
1849
+ x = coord2[0] - dt * uY;
1850
+ y = coord2[1] + dt * uX;
1851
+ bisectorNormalRight = [x, y];
1852
+ dt = t * d2;
1853
+ x = coord2[0] + dt * uY;
1854
+ y = coord2[1] - dt * uX;
1855
+ bisectorNormalLeft = [x, y];
1856
+ } else {
1857
+ dt = t * d1;
1858
+ x = coord2[0] + dt * uY;
1859
+ y = coord2[1] - dt * uX;
1860
+ bisectorNormalRight = [x, y];
1861
+ dt = t * d2;
1862
+ x = coord2[0] - dt * uY;
1863
+ y = coord2[1] + dt * uX;
1864
+ bisectorNormalLeft = [x, y];
1865
+ }
1866
+ else {
1867
+ x = coord2[0] + t * (coord1[0] - coord2[0]);
1868
+ y = coord2[1] + t * (coord1[1] - coord2[1]);
1869
+ bisectorNormalRight = [x, y];
1870
+ x = coord2[0] + t * (coord3[0] - coord2[0]);
1871
+ y = coord2[1] + t * (coord3[1] - coord2[1]);
1872
+ bisectorNormalLeft = [x, y];
1873
+ }
1874
+ return [bisectorNormalRight, bisectorNormalLeft];
1875
+ }
1876
+ /**
1877
+ * 获取默认三点的内切圆
1878
+ * @param coord1
1879
+ * @param coord2
1880
+ * @param coord3
1881
+ */
1882
+ function getNormal(coord1, coord2, coord3) {
1883
+ let dX1 = coord1[0] - coord2[0];
1884
+ let dY1 = coord1[1] - coord2[1];
1885
+ const d1 = Math.hypot(dX1, dY1);
1886
+ dX1 /= d1;
1887
+ dY1 /= d1;
1888
+ let dX2 = coord3[0] - coord2[0];
1889
+ let dY2 = coord3[1] - coord2[1];
1890
+ const d2 = Math.hypot(dX2, dY2);
1891
+ dX2 /= d2;
1892
+ dY2 /= d2;
1893
+ const uX = dX1 + dX2;
1894
+ const uY = dY1 + dY2;
1895
+ return [uX, uY];
1896
+ }
1897
+ /**
1898
+ * 贝塞尔曲线
1899
+ * @param points
1900
+ */
1901
+ function getBezierCoords(points) {
1902
+ if (points.length <= 2) return points;
1903
+ const bezierCoords = [];
1904
+ const n = points.length - 1;
1905
+ for (let t = 0; t <= 1; t += .01) {
1906
+ let [x, y] = [0, 0];
1907
+ for (let index = 0; index <= n; index++) {
1908
+ const factor = getBinomialFactor(n, index);
1909
+ const a = t ** index;
1910
+ const b = (1 - t) ** (n - index);
1911
+ x += factor * a * b * points[index][0];
1912
+ y += factor * a * b * points[index][1];
1913
+ }
1914
+ bezierCoords.push([x, y]);
1915
+ }
1916
+ bezierCoords.push(points[n]);
1917
+ return bezierCoords;
1918
+ }
1919
+ /**
1920
+ * 获取阶乘数据
1921
+ * @param n
1922
+ */
1923
+ function getFactorial(n) {
1924
+ let result = 1;
1925
+ switch (true) {
1926
+ case n <= 1:
1927
+ result = 1;
1928
+ break;
1929
+ case n === 2:
1930
+ result = 2;
1931
+ break;
1932
+ case n === 3:
1933
+ result = 6;
1934
+ break;
1935
+ case n === 24:
1936
+ result = 24;
1937
+ break;
1938
+ case n === 5:
1939
+ result = 120;
1940
+ break;
1941
+ default:
1942
+ for (let i = 1; i <= n; i++) result *= i;
1943
+ break;
1944
+ }
1945
+ return result;
1946
+ }
1947
+ /**
1948
+ * 获取二项分布
1949
+ * @param n
1950
+ * @param index
1951
+ */
1952
+ function getBinomialFactor(n, index) {
1953
+ return getFactorial(n) / (getFactorial(index) * getFactorial(n - index));
1954
+ }
1955
+ /**
1956
+ * 插值线性点
1957
+ * @param points
1958
+ */
1959
+ function getQBSplineCoords(points) {
1960
+ if (points.length <= 2) return points;
1961
+ const [n, bSplineCoords] = [2, []];
1962
+ const m = points.length - n - 1;
1963
+ bSplineCoords.push(points[0]);
1964
+ for (let i = 0; i <= m; i++) for (let t = 0; t <= 1; t += .05) {
1965
+ let [x, y] = [0, 0];
1966
+ for (let k = 0; k <= n; k++) {
1967
+ const factor = getQuadricBSplineFactor(k, t);
1968
+ x += factor * points[i + k][0];
1969
+ y += factor * points[i + k][1];
1970
+ }
1971
+ bSplineCoords.push([x, y]);
1972
+ }
1973
+ bSplineCoords.push(points.at(-1));
1974
+ return bSplineCoords;
1975
+ }
1976
+ /**
1977
+ * 得到二次线性因子
1978
+ * @param k
1979
+ * @param t
1980
+ */
1981
+ function getQuadricBSplineFactor(k, t) {
1982
+ let res = 0;
1983
+ if (k === 0) res = (t - 1) ** 2 / 2;
1984
+ else if (k === 1) res = (-2 * t ** 2 + 2 * t + 1) / 2;
1985
+ else if (k === 2) res = t ** 2 / 2;
1986
+ return res;
1987
+ }
1988
+
1989
+ //#endregion
1990
+ //#region geom/arc.ts
1991
+ /**
1992
+ * 标绘画弓形算法,继承线要素相关方法和属性
1993
+ */
1994
+ function arc(coords) {
1995
+ const coordlength = coords.length;
1996
+ if (coordlength <= 2) throw new Error("coords.length must >= 3");
1997
+ else {
1998
+ let [coord1, coord2, coord3, startAngle, endAngle] = [
1999
+ coords[0],
2000
+ coords[1],
2001
+ coords[2],
2002
+ 0,
2003
+ 0
2004
+ ];
2005
+ const center = getCircleCenterOfThreeCoords(coord1, coord2, coord3);
2006
+ const radius = mathDistance(coord1, center);
2007
+ const angle1 = getAzimuth(coord1, center);
2008
+ const angle2 = getAzimuth(coord2, center);
2009
+ if (isClockWise(coord1, coord2, coord3)) {
2010
+ startAngle = angle2;
2011
+ endAngle = angle1;
2012
+ } else {
2013
+ startAngle = angle1;
2014
+ endAngle = angle2;
2015
+ }
2016
+ return getArcCoords(center, radius, startAngle, endAngle);
2017
+ }
2018
+ }
2019
+
2020
+ //#endregion
2021
+ //#region geom/arrowAttackDirection.ts
2022
+ /**
2023
+ * 尖曲箭头
2024
+ */
2025
+ function arrowAttackDirection(coords, options = {}) {
2026
+ const coordLength = coords.length;
2027
+ if (coordLength < 3) throw new Error("coords.length must >= 3");
2028
+ else {
2029
+ let [tailLeft, tailRight] = [coords[0], coords[1]];
2030
+ if (isClockWise(coords[0], coords[1], coords[2])) {
2031
+ tailLeft = coords[1];
2032
+ tailRight = coords[0];
2033
+ }
2034
+ const midTail = mid(tailLeft, tailRight);
2035
+ const boneCoords = [midTail].concat(coords.slice(2));
2036
+ const headCoords = getArrowHeadCoords(boneCoords, {
2037
+ tailLeft,
2038
+ tailRight,
2039
+ ...options
2040
+ });
2041
+ if (headCoords && headCoords.length > 4) {
2042
+ const [neckLeft, neckRight] = [headCoords[0], headCoords[4]];
2043
+ const tailWidthFactor = mathDistance(tailLeft, tailRight) / getBaseLength(boneCoords);
2044
+ const bodyCoords = getArrowBodyCoords(boneCoords, neckLeft, neckRight, tailWidthFactor);
2045
+ const coordlength = bodyCoords.length;
2046
+ let leftCoords = [tailLeft].concat(bodyCoords.slice(0, coordlength / 2));
2047
+ leftCoords.push(neckLeft);
2048
+ let rightCoords = [tailRight].concat(bodyCoords.slice(coordlength / 2, coordlength));
2049
+ rightCoords.push(neckRight);
2050
+ leftCoords = getQBSplineCoords(leftCoords);
2051
+ rightCoords = getQBSplineCoords(rightCoords);
2052
+ return leftCoords.concat(headCoords, rightCoords.reverse());
2053
+ } else return [];
2054
+ }
2055
+ }
2056
+ /**
2057
+ * 插值头部点
2058
+ */
2059
+ function getArrowHeadCoords(points, options) {
2060
+ const { tailLeft, tailRight, headHeightFactor = .18, headWidthFactor = .3, neckHeightFactor = .85, neckWidthFactor = .15, headTailFactor = .8 } = options;
2061
+ let len = getBaseLength(points);
2062
+ let headHeight = len * headHeightFactor;
2063
+ const headCoord = points.at(-1);
2064
+ len = mathDistance(headCoord, points.at(-2));
2065
+ let tailWidth = 0;
2066
+ if (tailLeft && tailRight) tailWidth = mathDistance(tailLeft, tailRight);
2067
+ if (headHeight > tailWidth * headTailFactor) headHeight = tailWidth * headTailFactor;
2068
+ const headWidth = headHeight * headWidthFactor;
2069
+ const neckWidth = headHeight * neckWidthFactor;
2070
+ headHeight = Math.min(headHeight, len);
2071
+ const neckHeight = headHeight * neckHeightFactor;
2072
+ const headEndCoord = getThirdCoord(points.at(-2), headCoord, 0, headHeight, true);
2073
+ const neckEndCoord = getThirdCoord(points.at(-2), headCoord, 0, neckHeight, true);
2074
+ const headLeft = getThirdCoord(headCoord, headEndCoord, HALF_PI, headWidth, false);
2075
+ const headRight = getThirdCoord(headCoord, headEndCoord, HALF_PI, headWidth, true);
2076
+ const neckLeft = getThirdCoord(headCoord, neckEndCoord, HALF_PI, neckWidth, false);
2077
+ const neckRight = getThirdCoord(headCoord, neckEndCoord, HALF_PI, neckWidth, true);
2078
+ return [
2079
+ neckLeft,
2080
+ headLeft,
2081
+ headCoord,
2082
+ headRight,
2083
+ neckRight
2084
+ ];
2085
+ }
2086
+ /**
2087
+ * 插值面部分数据
2088
+ * @param points
2089
+ * @param neckLeft
2090
+ * @param neckRight
2091
+ * @param tailWidthFactor
2092
+ */
2093
+ function getArrowBodyCoords(points, neckLeft, neckRight, tailWidthFactor) {
2094
+ const allLen = wholeDistance(points);
2095
+ const len = getBaseLength(points);
2096
+ const tailWidth = len * tailWidthFactor;
2097
+ const neckWidth = mathDistance(neckLeft, neckRight);
2098
+ const widthDif = (tailWidth - neckWidth) / 2;
2099
+ let tempLen = 0;
2100
+ const leftBodyCoords = [];
2101
+ const rightBodyCoords = [];
2102
+ for (let i = 1; i < points.length - 1; i++) {
2103
+ const angle = getAngleOfThreeCoords(points[i - 1], points[i], points[i + 1]) / 2;
2104
+ tempLen += mathDistance(points[i - 1], points[i]);
2105
+ const w = (tailWidth / 2 - tempLen / allLen * widthDif) / Math.sin(angle);
2106
+ const left = getThirdCoord(points[i - 1], points[i], Math.PI - angle, w, true);
2107
+ const right = getThirdCoord(points[i - 1], points[i], angle, w, false);
2108
+ leftBodyCoords.push(left);
2109
+ rightBodyCoords.push(right);
2110
+ }
2111
+ return leftBodyCoords.concat(rightBodyCoords);
2112
+ }
2113
+
2114
+ //#endregion
2115
+ //#region geom/arrowAttackDirectionTailed.ts
2116
+ /**
2117
+ * 燕尾尖曲箭头
2118
+ */
2119
+ function arrowAttackDirectionTailed(coords, options = {}) {
2120
+ const { headHeightFactor = .18, headWidthFactor = .3, neckHeightFactor = .85, neckWidthFactor = .15, tailWidthFactor = .1, swallowTailFactor = 1 } = options;
2121
+ const coordLength = coords.length;
2122
+ if (coordLength < 3) throw new Error("coords.length must >= 3");
2123
+ let [tailLeft, tailRight] = [coords[0], coords[1]];
2124
+ if (isClockWise(coords[0], coords[1], coords[2])) {
2125
+ tailLeft = coords[1];
2126
+ tailRight = coords[0];
2127
+ }
2128
+ const midTail = mid(tailLeft, tailRight);
2129
+ const boneCoords = [midTail].concat(coords.slice(2));
2130
+ const headCoords = getArrowHeadCoords(boneCoords, {
2131
+ tailLeft,
2132
+ tailRight,
2133
+ headHeightFactor,
2134
+ headWidthFactor,
2135
+ neckWidthFactor,
2136
+ neckHeightFactor
2137
+ });
2138
+ if (headCoords && headCoords.length > 4) {
2139
+ const [neckLeft, neckRight] = [headCoords[0], headCoords[4]];
2140
+ const tailWidth = mathDistance(tailLeft, tailRight);
2141
+ const allLen = getBaseLength(boneCoords);
2142
+ const len = allLen * tailWidthFactor * swallowTailFactor;
2143
+ const swallowTailCoord = getThirdCoord(boneCoords[1], boneCoords[0], 0, len, true);
2144
+ const factor = tailWidth / allLen;
2145
+ const bodyCoords = getArrowBodyCoords(boneCoords, neckLeft, neckRight, factor);
2146
+ const coordlength = bodyCoords.length;
2147
+ let leftCoords = [tailLeft].concat(bodyCoords.slice(0, coordlength / 2));
2148
+ leftCoords.push(neckLeft);
2149
+ let rightCoords = [tailRight].concat(bodyCoords.slice(coordlength / 2, coordlength));
2150
+ rightCoords.push(neckRight);
2151
+ leftCoords = getQBSplineCoords(leftCoords);
2152
+ rightCoords = getQBSplineCoords(rightCoords);
2153
+ return leftCoords.concat(headCoords, rightCoords.reverse(), [swallowTailCoord, leftCoords[0]]);
2154
+ } else return [];
2155
+ }
2156
+
2157
+ //#endregion
2158
+ //#region geom/arrowClamped.ts
2159
+ /**
2160
+ * 钳击箭头 有效点位长度3,4,5
2161
+ */
2162
+ function arrowClamped(coords) {
2163
+ const options = {
2164
+ headHeightFactor: .25,
2165
+ headWidthFactor: .3,
2166
+ neckHeightFactor: .85,
2167
+ neckWidthFactor: .15
2168
+ };
2169
+ if (coords.length < 3) throw new Error(`coords.length must >= 3`);
2170
+ const [coord1, coord2, coord3] = coords;
2171
+ let tempCoord4, connCoord;
2172
+ if (coords.length === 3) {
2173
+ tempCoord4 = getTempCoord4(coord1, coord2, coord3);
2174
+ connCoord = mid(coord1, coord2);
2175
+ } else if (coords.length === 4) {
2176
+ tempCoord4 = coords[3];
2177
+ connCoord = mid(coord1, coord2);
2178
+ } else {
2179
+ tempCoord4 = coords[3];
2180
+ connCoord = coords[4];
2181
+ }
2182
+ let leftArrowCoords;
2183
+ let rightArrowCoords;
2184
+ if (isClockWise(coord1, coord2, coord3)) {
2185
+ leftArrowCoords = getArrowCoords(coord1, connCoord, tempCoord4, false, options);
2186
+ rightArrowCoords = getArrowCoords(connCoord, coord2, coord3, true, options);
2187
+ } else {
2188
+ leftArrowCoords = getArrowCoords(coord2, connCoord, coord3, false, options);
2189
+ rightArrowCoords = getArrowCoords(connCoord, coord1, tempCoord4, true, options);
2190
+ }
2191
+ const m = leftArrowCoords.length;
2192
+ const t = (m - 5) / 2;
2193
+ const llBodyCoords = leftArrowCoords.slice(0, t);
2194
+ const lArrowCoords = leftArrowCoords.slice(t, t + 5);
2195
+ let lrBodyCoords = leftArrowCoords.slice(t + 5, m);
2196
+ let rlBodyCoords = rightArrowCoords.slice(0, t);
2197
+ const rArrowCoords = rightArrowCoords.slice(t, t + 5);
2198
+ const rrBodyCoords = rightArrowCoords.slice(t + 5, m);
2199
+ rlBodyCoords = getBezierCoords(rlBodyCoords);
2200
+ const bodyCoords = getBezierCoords(rrBodyCoords.concat(llBodyCoords.slice(1)));
2201
+ lrBodyCoords = getBezierCoords(lrBodyCoords);
2202
+ return rlBodyCoords.concat(rArrowCoords, bodyCoords, lArrowCoords, lrBodyCoords);
2203
+ }
2204
+ /**
2205
+ * 插值箭形上的点
2206
+ * @param coord1 - Wgs84坐标
2207
+ * @param coord2 - Wgs84坐标
2208
+ * @param coord3 - Wgs84坐标
2209
+ * @param clockWise - 是否顺时针
2210
+ */
2211
+ function getArrowCoords(coord1, coord2, coord3, clockWise, options) {
2212
+ const midCoord = mid(coord1, coord2);
2213
+ const len = mathDistance(midCoord, coord3);
2214
+ let midCoord1 = getThirdCoord(coord3, midCoord, 0, len * .3, true);
2215
+ let midCoord2 = getThirdCoord(coord3, midCoord, 0, len * .5, true);
2216
+ midCoord1 = getThirdCoord(midCoord, midCoord1, HALF_PI, len / 5, clockWise);
2217
+ midCoord2 = getThirdCoord(midCoord, midCoord2, HALF_PI, len / 4, clockWise);
2218
+ const coords = [
2219
+ midCoord,
2220
+ midCoord1,
2221
+ midCoord2,
2222
+ coord3
2223
+ ];
2224
+ const arrowCoords = getArrowHeadCoords$1(coords, options);
2225
+ if (arrowCoords && Array.isArray(arrowCoords) && arrowCoords.length > 0) {
2226
+ const [neckLeftCoord, neckRightCoord] = [arrowCoords[0], arrowCoords[4]];
2227
+ const tailWidthFactor = mathDistance(coord1, coord2) / getBaseLength(coords) / 2;
2228
+ const bodyCoords = getArrowBodyCoords$1(coords, neckLeftCoord, neckRightCoord, tailWidthFactor);
2229
+ const n = bodyCoords.length;
2230
+ let lCoords = bodyCoords.slice(0, n / 2);
2231
+ let rCoords = bodyCoords.slice(n / 2, n);
2232
+ lCoords.push(neckLeftCoord);
2233
+ rCoords.push(neckRightCoord);
2234
+ lCoords = lCoords.reverse();
2235
+ lCoords.push(coord2);
2236
+ rCoords = rCoords.reverse();
2237
+ rCoords.push(coord1);
2238
+ return lCoords.reverse().concat(arrowCoords, rCoords);
2239
+ } else throw new Error("插值出错");
2240
+ }
2241
+ /**
2242
+ * 插值头部点
2243
+ * @param coords
2244
+ */
2245
+ function getArrowHeadCoords$1(coords, options) {
2246
+ const { headHeightFactor, headWidthFactor, neckWidthFactor, neckHeightFactor } = options;
2247
+ const len = getBaseLength(coords);
2248
+ const headHeight = len * headHeightFactor;
2249
+ const headCoord = coords.at(-1);
2250
+ const headWidth = headHeight * headWidthFactor;
2251
+ const neckWidth = headHeight * neckWidthFactor;
2252
+ const neckHeight = headHeight * neckHeightFactor;
2253
+ const headEndCoord = getThirdCoord(coords.at(-2), headCoord, 0, headHeight, true);
2254
+ const neckEndCoord = getThirdCoord(coords.at(-2), headCoord, 0, neckHeight, true);
2255
+ const headLeft = getThirdCoord(headCoord, headEndCoord, HALF_PI, headWidth, false);
2256
+ const headRight = getThirdCoord(headCoord, headEndCoord, HALF_PI, headWidth, true);
2257
+ const neckLeft = getThirdCoord(headCoord, neckEndCoord, HALF_PI, neckWidth, false);
2258
+ const neckRight = getThirdCoord(headCoord, neckEndCoord, HALF_PI, neckWidth, true);
2259
+ return [
2260
+ neckLeft,
2261
+ headLeft,
2262
+ headCoord,
2263
+ headRight,
2264
+ neckRight
2265
+ ];
2266
+ }
2267
+ /**
2268
+ * 插值面部分数据
2269
+ * @param coords
2270
+ * @param neckLeft
2271
+ * @param neckRight
2272
+ * @param tailWidthFactor
2273
+ */
2274
+ function getArrowBodyCoords$1(coords, neckLeft, neckRight, tailWidthFactor) {
2275
+ const allLen = wholeDistance(coords);
2276
+ const len = getBaseLength(coords);
2277
+ const tailWidth = len * tailWidthFactor;
2278
+ const neckWidth = mathDistance(neckLeft, neckRight);
2279
+ const widthDif = (tailWidth - neckWidth) / 2;
2280
+ let tempLen = 0;
2281
+ const leftBodyCoords = [];
2282
+ const rightBodyCoords = [];
2283
+ for (let i = 1; i < coords.length - 1; i++) {
2284
+ const angle = getAngleOfThreeCoords(coords[i - 1], coords[i], coords[i + 1]) / 2;
2285
+ tempLen += mathDistance(coords[i - 1], coords[i]);
2286
+ const w = (tailWidth / 2 - tempLen / allLen * widthDif) / Math.sin(angle);
2287
+ const left = getThirdCoord(coords[i - 1], coords[i], Math.PI - angle, w, true);
2288
+ const right = getThirdCoord(coords[i - 1], coords[i], angle, w, false);
2289
+ leftBodyCoords.push(left);
2290
+ rightBodyCoords.push(right);
2291
+ }
2292
+ return leftBodyCoords.concat(rightBodyCoords);
2293
+ }
2294
+ /**
2295
+ * 获取对称点
2296
+ * @param lineCoord1
2297
+ * @param lineCoord2
2298
+ * @param coord
2299
+ */
2300
+ function getTempCoord4(lineCoord1, lineCoord2, coord) {
2301
+ const midCoord = mid(lineCoord1, lineCoord2);
2302
+ const len = mathDistance(midCoord, coord);
2303
+ const angle = getAngleOfThreeCoords(lineCoord1, midCoord, coord);
2304
+ if (angle < HALF_PI) {
2305
+ const distance1 = len * Math.sin(angle);
2306
+ const distance2 = len * Math.cos(angle);
2307
+ const mid$1 = getThirdCoord(lineCoord1, midCoord, HALF_PI, distance1, false);
2308
+ return getThirdCoord(midCoord, mid$1, HALF_PI, distance2, true);
2309
+ } else if (angle >= HALF_PI && angle < Math.PI) {
2310
+ const distance1 = len * Math.sin(Math.PI - angle);
2311
+ const distance2 = len * Math.cos(Math.PI - angle);
2312
+ const mid$1 = getThirdCoord(lineCoord1, midCoord, HALF_PI, distance1, false);
2313
+ return getThirdCoord(midCoord, mid$1, HALF_PI, distance2, false);
2314
+ } else if (angle >= Math.PI && angle < Math.PI * 1.5) {
2315
+ const distance1 = len * Math.sin(angle - Math.PI);
2316
+ const distance2 = len * Math.cos(angle - Math.PI);
2317
+ const mid$1 = getThirdCoord(lineCoord1, midCoord, HALF_PI, distance1, true);
2318
+ return getThirdCoord(midCoord, mid$1, HALF_PI, distance2, true);
2319
+ } else {
2320
+ const distance1 = len * Math.sin(Math.PI * 2 - angle);
2321
+ const distance2 = len * Math.cos(Math.PI * 2 - angle);
2322
+ const mid$1 = getThirdCoord(lineCoord1, midCoord, HALF_PI, distance1, true);
2323
+ return getThirdCoord(midCoord, mid$1, HALF_PI, distance2, false);
2324
+ }
2325
+ }
2326
+
2327
+ //#endregion
2328
+ //#region geom/arrowStraightSharp.ts
2329
+ /**
2330
+ * 尖箭头
2331
+ *
2332
+ */
2333
+ function arrowStraightSharp(coords, options = {}) {
2334
+ const { tailWidthFactor = .1, neckWidthFactor = .2, headWidthFactor = .25, headAngle = Math.PI / 8.5, neckAngle = Math.PI / 13 } = options;
2335
+ const coordlength = coords.length;
2336
+ if (coordlength < 2) throw new Error("coords.length must >= 2");
2337
+ const [coord1, coord2] = [coords[0], coords[1]];
2338
+ const len = getBaseLength(coords);
2339
+ const tailWidth = len * tailWidthFactor;
2340
+ const neckWidth = len * neckWidthFactor;
2341
+ const headWidth = len * headWidthFactor;
2342
+ const tailLeft = getThirdCoord(coord2, coord1, HALF_PI, tailWidth, true);
2343
+ const tailRight = getThirdCoord(coord2, coord1, HALF_PI, tailWidth, false);
2344
+ const headLeft = getThirdCoord(coord1, coord2, headAngle, headWidth, false);
2345
+ const headRight = getThirdCoord(coord1, coord2, headAngle, headWidth, true);
2346
+ const neckLeft = getThirdCoord(coord1, coord2, neckAngle, neckWidth, false);
2347
+ const neckRight = getThirdCoord(coord1, coord2, neckAngle, neckWidth, true);
2348
+ const pList = [
2349
+ tailLeft,
2350
+ neckLeft,
2351
+ headLeft,
2352
+ coord2,
2353
+ headRight,
2354
+ neckRight,
2355
+ tailRight
2356
+ ];
2357
+ return pList;
2358
+ }
2359
+
2360
+ //#endregion
2361
+ //#region geom/arrowStraight.ts
2362
+ /**
2363
+ * 直箭头
2364
+ */
2365
+ function arrowStraight(coords) {
2366
+ const tailWidthFactor = .05;
2367
+ const neckWidthFactor = .1;
2368
+ const headWidthFactor = .15;
2369
+ const headAngle = Math.PI / 4;
2370
+ const neckAngle = Math.PI * .17741;
2371
+ return arrowStraightSharp(coords, {
2372
+ tailWidthFactor,
2373
+ neckWidthFactor,
2374
+ headWidthFactor,
2375
+ headAngle,
2376
+ neckAngle
2377
+ });
2378
+ }
2379
+
2380
+ //#endregion
2381
+ //#region geom/arrowUnitCombatOperation.ts
2382
+ /**
2383
+ * 分队战斗行动(尖曲箭头)
2384
+ */
2385
+ function arrowUnitCombatOperation(coords, options = {}) {
2386
+ const { headHeightFactor = .18, headWidthFactor = .3, neckHeightFactor = .85, neckWidthFactor = .15, tailWidthFactor = .1 } = options;
2387
+ const coordlength = coords.length;
2388
+ if (coordlength < 2) throw new Error("coords.length must >= 2");
2389
+ else {
2390
+ const allLen = getBaseLength(coords);
2391
+ const tailWidth = allLen * tailWidthFactor;
2392
+ const tailLeft = getThirdCoord(coords[1], coords[0], HALF_PI, tailWidth, false);
2393
+ const tailRight = getThirdCoord(coords[1], coords[0], HALF_PI, tailWidth, true);
2394
+ const headCoords = getArrowHeadCoords(coords, {
2395
+ tailLeft,
2396
+ tailRight,
2397
+ headHeightFactor,
2398
+ headWidthFactor,
2399
+ neckWidthFactor,
2400
+ neckHeightFactor
2401
+ });
2402
+ if (headCoords && headCoords.length > 4) {
2403
+ const neckLeft = headCoords[0];
2404
+ const neckRight = headCoords[4];
2405
+ const bodyCoords = getArrowBodyCoords(coords, neckLeft, neckRight, tailWidthFactor);
2406
+ const coordlength$1 = bodyCoords.length;
2407
+ let leftCoords = [tailLeft].concat(bodyCoords.slice(0, coordlength$1 / 2));
2408
+ leftCoords.push(neckLeft);
2409
+ let rightCoords = [tailRight].concat(bodyCoords.slice(coordlength$1 / 2, coordlength$1));
2410
+ rightCoords.push(neckRight);
2411
+ leftCoords = getQBSplineCoords(leftCoords);
2412
+ rightCoords = getQBSplineCoords(rightCoords);
2413
+ return leftCoords.concat(headCoords, rightCoords.reverse());
2414
+ } else return [];
2415
+ }
2416
+ }
2417
+
2418
+ //#endregion
2419
+ //#region geom/arrowUnitCombatOperationTailed.ts
2420
+ /**
2421
+ * 燕尾尖箭头
2422
+ */
2423
+ function arrowUnitCombatOperationTailed(coords, options = {}) {
2424
+ const { headHeightFactor = .18, headWidthFactor = .3, neckHeightFactor = .85, neckWidthFactor = .15, tailWidthFactor = .1, swallowTailFactor = 1 } = options;
2425
+ const coordlength = coords.length;
2426
+ if (coordlength < 2) throw new Error("coords.length must >= 2");
2427
+ const allLen = getBaseLength(coords);
2428
+ const tailWidth = allLen * tailWidthFactor;
2429
+ const tailLeft = getThirdCoord(coords[1], coords[0], HALF_PI, tailWidth, false);
2430
+ const tailRight = getThirdCoord(coords[1], coords[0], HALF_PI, tailWidth, true);
2431
+ const len = tailWidth * swallowTailFactor;
2432
+ const swallowTailCoord = getThirdCoord(coords[1], coords[0], 0, len, true);
2433
+ const tailCoords = [
2434
+ tailLeft,
2435
+ swallowTailCoord,
2436
+ tailRight
2437
+ ];
2438
+ const headCoords = getArrowHeadCoords(coords, {
2439
+ tailLeft: tailCoords[0],
2440
+ tailRight: tailCoords[2],
2441
+ headHeightFactor,
2442
+ headWidthFactor,
2443
+ neckWidthFactor,
2444
+ neckHeightFactor
2445
+ });
2446
+ if (headCoords && headCoords.length > 4) {
2447
+ const neckLeft = headCoords[0];
2448
+ const neckRight = headCoords[4];
2449
+ const bodyCoords = getArrowBodyCoords(coords, neckLeft, neckRight, tailWidthFactor);
2450
+ const coordlength$1 = bodyCoords.length;
2451
+ let leftCoords = [tailCoords[0]].concat(bodyCoords.slice(0, coordlength$1 / 2));
2452
+ leftCoords.push(neckLeft);
2453
+ let rightCoords = [tailCoords[2]].concat(bodyCoords.slice(coordlength$1 / 2, coordlength$1));
2454
+ rightCoords.push(neckRight);
2455
+ leftCoords = getQBSplineCoords(leftCoords);
2456
+ rightCoords = getQBSplineCoords(rightCoords);
2457
+ return leftCoords.concat(headCoords, rightCoords.reverse(), [tailCoords[1], leftCoords[0]]);
2458
+ }
2459
+ return [];
2460
+ }
2461
+
2462
+ //#endregion
2463
+ //#region geom/assemblingPlace.ts
2464
+ /**
2465
+ * 集结地
2466
+ *
2467
+ */
2468
+ function assemblingPlace(coords) {
2469
+ if (coords.length < 3) throw new Error(`coords.length must >= 3`);
2470
+ const t = .4;
2471
+ const midCoord = mid(coords[0], coords[2]);
2472
+ coords.push(midCoord, coords[0], coords[1]);
2473
+ let normals = [];
2474
+ const pList = [];
2475
+ for (let i = 0; i < coords.length - 2; i++) {
2476
+ const coord1 = coords[i];
2477
+ const coord2 = coords[i + 1];
2478
+ const coord3 = coords[i + 2];
2479
+ const normalCoords = getBisectorNormals(t, coord1, coord2, coord3);
2480
+ normals = normals.concat(normalCoords);
2481
+ }
2482
+ const count = normals.length;
2483
+ normals = [normals[count - 1]].concat(normals.slice(0, count - 1));
2484
+ for (let i = 0; i < coords.length - 2; i++) {
2485
+ const coord1 = coords[i];
2486
+ const coord2 = coords[i + 1];
2487
+ pList.push(coord1);
2488
+ for (let t$1 = 0; t$1 <= FITTING_COUNT; t$1++) {
2489
+ const coord = getCubicValue(t$1 / FITTING_COUNT, coord1, normals[i * 2], normals[i * 2 + 1], coord2);
2490
+ pList.push(coord);
2491
+ }
2492
+ pList.push(coord2);
2493
+ }
2494
+ return pList;
2495
+ }
2496
+
2497
+ //#endregion
2498
+ //#region geom/flagCurve.ts
2499
+ /**
2500
+ * 曲线旗标
2501
+ */
2502
+ function flagCurve(coords) {
2503
+ const coordlength = coords.length;
2504
+ if (coordlength < 2) throw new Error("coords.length must >= 2");
2505
+ return calculatePonits(coords);
2506
+ }
2507
+ /**
2508
+ * 插值点数据
2509
+ * @param coords
2510
+ */
2511
+ function calculatePonits(coords) {
2512
+ let components = [];
2513
+ if (coords.length > 1) {
2514
+ const startCoord = coords[0];
2515
+ const endCoord = coords.at(-1);
2516
+ const coord1 = startCoord;
2517
+ const coord2 = [(endCoord[0] - startCoord[0]) / 4 + startCoord[0], (endCoord[1] - startCoord[1]) / 8 + startCoord[1]];
2518
+ const coord3 = [(startCoord[0] + endCoord[0]) / 2, startCoord[1]];
2519
+ const coord4 = [(endCoord[0] - startCoord[0]) * 3 / 4 + startCoord[0], -(endCoord[1] - startCoord[1]) / 8 + startCoord[1]];
2520
+ const coord5 = [endCoord[0], startCoord[1]];
2521
+ const coord6 = [endCoord[0], (startCoord[1] + endCoord[1]) / 2];
2522
+ const coord7 = [(endCoord[0] - startCoord[0]) * 3 / 4 + startCoord[0], (endCoord[1] - startCoord[1]) * 3 / 8 + startCoord[1]];
2523
+ const coord8 = [(startCoord[0] + endCoord[0]) / 2, (startCoord[1] + endCoord[1]) / 2];
2524
+ const coord9 = [(endCoord[0] - startCoord[0]) / 4 + startCoord[0], (endCoord[1] - startCoord[1]) * 5 / 8 + startCoord[1]];
2525
+ const coord10 = [startCoord[0], (startCoord[1] + endCoord[1]) / 2];
2526
+ const coord11 = [startCoord[0], endCoord[1]];
2527
+ const curve1 = getBezierCoords([
2528
+ coord1,
2529
+ coord2,
2530
+ coord3,
2531
+ coord4,
2532
+ coord5
2533
+ ]);
2534
+ const curve2 = getBezierCoords([
2535
+ coord6,
2536
+ coord7,
2537
+ coord8,
2538
+ coord9,
2539
+ coord10
2540
+ ]);
2541
+ components = curve1.concat(curve2);
2542
+ components.push(coord11);
2543
+ }
2544
+ return components;
2545
+ }
2546
+
2547
+ //#endregion
2548
+ //#region geom/flagRect.ts
2549
+ /**
2550
+ * 直角旗标(使用两个控制点直接创建直角旗标)
2551
+ */
2552
+ function flagRect(coords) {
2553
+ if (coords.length < 2) throw new Error("coords.length must >= 2");
2554
+ const [startCoord, endCoord] = coords;
2555
+ const coord1 = [endCoord[0], startCoord[1]];
2556
+ const coord2 = [endCoord[0], (startCoord[1] + endCoord[1]) / 2];
2557
+ const coord3 = [startCoord[0], (startCoord[1] + endCoord[1]) / 2];
2558
+ const coord4 = [startCoord[0], endCoord[1]];
2559
+ return [
2560
+ startCoord,
2561
+ coord1,
2562
+ coord2,
2563
+ coord3,
2564
+ coord4
2565
+ ];
2566
+ }
2567
+
2568
+ //#endregion
2569
+ //#region geom/flagTriangle.ts
2570
+ /**
2571
+ * 三角旗标(使用两个控制点直接创建三角旗标)
2572
+ */
2573
+ function flagTriangle(coords) {
2574
+ const coordlength = coords.length;
2575
+ if (coordlength < 2) throw new Error("coords.length must >= 2");
2576
+ const [startCoord, endCoord] = coords;
2577
+ const coord1 = [endCoord[0], (startCoord[1] + endCoord[1]) / 2];
2578
+ const coord2 = [startCoord[0], (startCoord[1] + endCoord[1]) / 2];
2579
+ const coord3 = [startCoord[0], endCoord[1]];
2580
+ return [
2581
+ startCoord,
2582
+ coord1,
2583
+ coord2,
2584
+ coord3
2585
+ ];
2586
+ }
2587
+
2588
+ //#endregion
2589
+ //#region scheme/PolygonArc.ts
2590
+ const PlotSchemePolygonArc = new PlotScheme({
2591
+ type: "PolygonArc",
2592
+ complete: (packable) => packable.positions.length >= 3,
2593
+ skeletons: [moved, control],
2594
+ initRender() {
2595
+ return { entities: [new cesium.Entity({ polygon: {} })] };
2596
+ },
2597
+ render(context) {
2598
+ const entity = context.previous.entities[0];
2599
+ const points = context.packable.positions;
2600
+ if (points.length < 3) context.mouse && points.push(context.mouse.clone());
2601
+ const coords = points.map((e) => (0, vesium.toCoord)(e));
2602
+ if (coords.length < 3) {
2603
+ entity.polygon.hierarchy = void 0;
2604
+ return context.previous;
2605
+ }
2606
+ const positions = arc(coords).map((item) => (0, vesium.toCartesian3)(item));
2607
+ const hierarchy = new cesium.PolygonHierarchy(positions);
2608
+ entity.polygon.hierarchy = new cesium.CallbackProperty(() => hierarchy, false);
2609
+ return { entities: [entity] };
2610
+ }
2611
+ });
2612
+
2613
+ //#endregion
2614
+ //#region scheme/PolygonArrowAttackDirection.ts
2615
+ const PlotSchemePolygonArrowAttackDirection = new PlotScheme({
2616
+ type: "PolygonArrowAttackDirection",
2617
+ allowManualComplete: (packable) => packable.positions.length >= 3,
2618
+ skeletons: [
2619
+ moved,
2620
+ control,
2621
+ intervalNonclosed
2622
+ ],
2623
+ initRender() {
2624
+ return { entities: [new cesium.Entity({ polygon: {} })] };
2625
+ },
2626
+ render(context) {
2627
+ const entity = context.previous.entities[0];
2628
+ const points = context.packable.positions;
2629
+ context.mouse && points.push(context.mouse.clone());
2630
+ const coords = points.map((e) => (0, vesium.toCoord)(e));
2631
+ if (coords.length < 3) {
2632
+ entity.polygon.hierarchy = void 0;
2633
+ return context.previous;
2634
+ }
2635
+ const positions = arrowAttackDirection(coords).map((item) => (0, vesium.toCartesian3)(item));
2636
+ const hierarchy = new cesium.PolygonHierarchy(positions);
2637
+ entity.polygon.hierarchy = new cesium.CallbackProperty(() => hierarchy, false);
2638
+ return { entities: [entity] };
2639
+ }
2640
+ });
2641
+
2642
+ //#endregion
2643
+ //#region scheme/PolygonArrowAttackDirectionTailed.ts
2644
+ const PlotSchemePolygonArrowAttackDirectionTailed = new PlotScheme({
2645
+ type: "PolygonArrowAttackDirectionTailed",
2646
+ allowManualComplete: (packable) => packable.positions.length >= 3,
2647
+ skeletons: [
2648
+ moved,
2649
+ control,
2650
+ intervalNonclosed
2651
+ ],
2652
+ initRender() {
2653
+ return { entities: [new cesium.Entity({ polygon: {} })] };
2654
+ },
2655
+ render(context) {
2656
+ const entity = context.previous.entities[0];
2657
+ const points = context.packable.positions;
2658
+ context.mouse && points.push(context.mouse.clone());
2659
+ const coords = points.map((e) => (0, vesium.toCoord)(e));
2660
+ if (coords.length < 3) {
2661
+ entity.polygon.hierarchy = void 0;
2662
+ return context.previous;
2663
+ }
2664
+ const positions = arrowAttackDirectionTailed(coords).map((item) => (0, vesium.toCartesian3)(item));
2665
+ const hierarchy = new cesium.PolygonHierarchy(positions);
2666
+ entity.polygon.hierarchy = new cesium.CallbackProperty(() => hierarchy, false);
2667
+ return { entities: [entity] };
2668
+ }
2669
+ });
2670
+
2671
+ //#endregion
2672
+ //#region scheme/PolygonArrowClamped.ts
2673
+ const PlotSchemePolygonArrowClamped = new PlotScheme({
2674
+ type: "PolygonArrowClamped",
2675
+ complete: (packable) => packable.positions.length >= 5,
2676
+ skeletons: [moved, control],
2677
+ initRender() {
2678
+ return { entities: [new cesium.Entity({ polygon: {} })] };
2679
+ },
2680
+ render(context) {
2681
+ const entity = context.previous.entities[0];
2682
+ const points = context.packable.positions;
2683
+ if (points.length < 5) {
2684
+ const mouse = context.mouse;
2685
+ mouse && points.push(mouse.clone());
2686
+ }
2687
+ const coords = points.map((e) => (0, vesium.toCoord)(e));
2688
+ if (coords.length >= 3) {
2689
+ const positions = arrowClamped(coords);
2690
+ const hierarchy = new cesium.PolygonHierarchy(positions.map((item) => (0, vesium.toCartesian3)(item)));
2691
+ entity.polygon.hierarchy = new cesium.CallbackProperty(() => hierarchy, false);
2692
+ } else entity.polygon.hierarchy = void 0;
2693
+ return { entities: [entity] };
2694
+ }
2695
+ });
2696
+
2697
+ //#endregion
2698
+ //#region scheme/PolygonArrowStraight.ts
2699
+ const PlotSchemePolygonArrowStraight = new PlotScheme({
2700
+ type: "PolygonArrowStraight",
2701
+ complete: (packable) => packable.positions.length >= 2,
2702
+ skeletons: [moved, control],
2703
+ initRender() {
2704
+ return { entities: [new cesium.Entity({ polygon: {} })] };
2705
+ },
2706
+ render(context) {
2707
+ const entity = context.previous.entities[0];
2708
+ const points = context.packable.positions;
2709
+ if (points.length < 2) {
2710
+ const mouse = context.mouse;
2711
+ mouse && points.push(mouse.clone());
2712
+ }
2713
+ const coords = points.map((e) => (0, vesium.toCoord)(e));
2714
+ if (coords.length >= 2) {
2715
+ const positions = arrowStraight(coords);
2716
+ const hierarchy = new cesium.PolygonHierarchy(positions.map((item) => (0, vesium.toCartesian3)(item)));
2717
+ entity.polygon.hierarchy = new cesium.CallbackProperty(() => hierarchy, false);
2718
+ } else entity.polygon.hierarchy = void 0;
2719
+ return { entities: [entity] };
2720
+ }
2721
+ });
2722
+
2723
+ //#endregion
2724
+ //#region scheme/PolygonArrowStraightSharp.ts
2725
+ const PlotSchemePolygonArrowStraightSharp = new PlotScheme({
2726
+ type: "PolygonArrowStraightSharp",
2727
+ complete: (packable) => packable.positions.length >= 2,
2728
+ skeletons: [moved, control],
2729
+ initRender() {
2730
+ return { entities: [new cesium.Entity({ polygon: {} })] };
2731
+ },
2732
+ render(context) {
2733
+ const entity = context.previous.entities[0];
2734
+ const points = context.packable.positions;
2735
+ if (points.length < 2) {
2736
+ const mouse = context.mouse;
2737
+ mouse && points.push(mouse.clone());
2738
+ }
2739
+ const coords = points.map((e) => (0, vesium.toCoord)(e));
2740
+ if (coords.length >= 2) {
2741
+ const positions = arrowStraightSharp(coords);
2742
+ const hierarchy = new cesium.PolygonHierarchy(positions.map((item) => (0, vesium.toCartesian3)(item)));
2743
+ entity.polygon.hierarchy = new cesium.CallbackProperty(() => hierarchy, false);
2744
+ } else entity.polygon.hierarchy = void 0;
2745
+ return { entities: [entity] };
2746
+ }
2747
+ });
2748
+
2749
+ //#endregion
2750
+ //#region scheme/PolygonArrowUnitCombatOperation.ts
2751
+ const PlotSchemePolygonArrowUnitCombatOperation = new PlotScheme({
2752
+ type: "PolygonArrowUnitCombatOperation",
2753
+ allowManualComplete: (packable) => packable.positions.length >= 2,
2754
+ skeletons: [
2755
+ moved,
2756
+ control,
2757
+ intervalNonclosed
2758
+ ],
2759
+ initRender() {
2760
+ return { entities: [new cesium.Entity({ polygon: {} })] };
2761
+ },
2762
+ render(context) {
2763
+ const entity = context.previous.entities[0];
2764
+ const points = context.packable.positions;
2765
+ context.mouse && points.push(context.mouse.clone());
2766
+ const coords = points.map((e) => (0, vesium.toCoord)(e));
2767
+ if (coords.length < 2) {
2768
+ entity.polygon.hierarchy = void 0;
2769
+ return context.previous;
2770
+ }
2771
+ const positions = arrowUnitCombatOperation(coords).map((item) => (0, vesium.toCartesian3)(item));
2772
+ const hierarchy = new cesium.PolygonHierarchy(positions);
2773
+ entity.polygon.hierarchy = new cesium.CallbackProperty(() => hierarchy, false);
2774
+ return { entities: [entity] };
2775
+ }
2776
+ });
2777
+
2778
+ //#endregion
2779
+ //#region scheme/PolygonArrowUnitCombatOperationTailed.ts
2780
+ const PlotSchemePolygonArrowUnitCombatOperationTailed = new PlotScheme({
2781
+ type: "PolygonArrowUnitCombatOperationTailed",
2782
+ allowManualComplete: (packable) => packable.positions.length >= 2,
2783
+ skeletons: [
2784
+ moved,
2785
+ control,
2786
+ interval
2787
+ ],
2788
+ initRender() {
2789
+ return { entities: [new cesium.Entity({ polygon: {} })] };
2790
+ },
2791
+ render(context) {
2792
+ const entity = context.previous.entities[0];
2793
+ const points = context.packable.positions;
2794
+ context.mouse && points.push(context.mouse.clone());
2795
+ const coords = points.map((e) => (0, vesium.toCoord)(e));
2796
+ if (coords.length < 2) {
2797
+ entity.polygon.hierarchy = void 0;
2798
+ return context.previous;
2799
+ }
2800
+ const positions = arrowUnitCombatOperationTailed(coords).map((item) => (0, vesium.toCartesian3)(item));
2801
+ const hierarchy = new cesium.PolygonHierarchy(positions);
2802
+ entity.polygon.hierarchy = new cesium.CallbackProperty(() => hierarchy, false);
2803
+ return { entities: [entity] };
2804
+ }
2805
+ });
2806
+
2807
+ //#endregion
2808
+ //#region scheme/PolygonAssemblingPlace.ts
2809
+ const PlotSchemePolygonAssemblingPlace = new PlotScheme({
2810
+ type: "PolygonAssemblingPlace",
2811
+ complete: (packable) => packable.positions.length >= 3,
2812
+ skeletons: [
2813
+ moved,
2814
+ control,
2815
+ interval
2816
+ ],
2817
+ initRender() {
2818
+ return { entities: [new cesium.Entity({ polygon: {} })] };
2819
+ },
2820
+ render(context) {
2821
+ const entity = context.previous.entities[0];
2822
+ const points = context.packable.positions;
2823
+ context.mouse && points.push(context.mouse.clone());
2824
+ const coords = points.map((e) => (0, vesium.toCoord)(e));
2825
+ if (coords.length < 2) {
2826
+ entity.polygon.hierarchy = void 0;
2827
+ return context.previous;
2828
+ }
2829
+ const positions = assemblingPlace(coords).map((item) => (0, vesium.toCartesian3)(item));
2830
+ const hierarchy = new cesium.PolygonHierarchy(positions);
2831
+ entity.polygon.hierarchy = new cesium.CallbackProperty(() => hierarchy, false);
2832
+ return { entities: [entity] };
2833
+ }
2834
+ });
2835
+
2836
+ //#endregion
2837
+ //#region scheme/PolygonFlagCurve.ts
2838
+ const PlotSchemePolygonFlagCurve = new PlotScheme({
2839
+ type: "PolygonFlagCurve",
2840
+ complete: (packable) => packable.positions.length >= 2,
2841
+ skeletons: [moved, control],
2842
+ initRender() {
2843
+ return { entities: [new cesium.Entity({ polygon: {} })] };
2844
+ },
2845
+ render(context) {
2846
+ const entity = context.previous.entities[0];
2847
+ const points = context.packable.positions;
2848
+ context.mouse && points.push(context.mouse.clone());
2849
+ const coords = points.map((e) => (0, vesium.toCoord)(e));
2850
+ if (coords.length < 2) {
2851
+ entity.polygon.hierarchy = void 0;
2852
+ return context.previous;
2853
+ }
2854
+ const positions = flagCurve(coords).map((item) => (0, vesium.toCartesian3)(item));
2855
+ const hierarchy = new cesium.PolygonHierarchy(positions);
2856
+ entity.polygon.hierarchy = new cesium.CallbackProperty(() => hierarchy, false);
2857
+ return { entities: [entity] };
2858
+ }
2859
+ });
2860
+
2861
+ //#endregion
2862
+ //#region scheme/PolygonFlagRect.ts
2863
+ const PlotSchemePolygonFlagRect = new PlotScheme({
2864
+ type: "PolygonFlagRect",
2865
+ complete: (packable) => packable.positions.length >= 2,
2866
+ skeletons: [moved, control],
2867
+ initRender() {
2868
+ return { entities: [new cesium.Entity({ polygon: {} })] };
2869
+ },
2870
+ render(context) {
2871
+ const entity = context.previous.entities[0];
2872
+ const points = context.packable.positions;
2873
+ context.mouse && points.push(context.mouse.clone());
2874
+ const coords = points.map((e) => (0, vesium.toCoord)(e));
2875
+ if (coords.length < 2) {
2876
+ entity.polygon.hierarchy = void 0;
2877
+ return context.previous;
2878
+ }
2879
+ const positions = flagRect(coords).map((item) => (0, vesium.toCartesian3)(item));
2880
+ const hierarchy = new cesium.PolygonHierarchy(positions);
2881
+ entity.polygon.hierarchy = new cesium.CallbackProperty(() => hierarchy, false);
2882
+ return { entities: [entity] };
2883
+ }
2884
+ });
2885
+
2886
+ //#endregion
2887
+ //#region scheme/PolygonFlagTriangle.ts
2888
+ const PlotSchemePolygonFlagTriangle = new PlotScheme({
2889
+ type: "PolygonFlagTriangle",
2890
+ complete: (packable) => packable.positions.length >= 2,
2891
+ skeletons: [moved, control],
2892
+ initRender() {
2893
+ return { entities: [new cesium.Entity({ polygon: {} })] };
2894
+ },
2895
+ render(context) {
2896
+ const entity = context.previous.entities[0];
2897
+ const points = context.packable.positions;
2898
+ context.mouse && points.push(context.mouse.clone());
2899
+ const coords = points.map((e) => (0, vesium.toCoord)(e));
2900
+ if (coords.length < 2) {
2901
+ entity.polygon.hierarchy = void 0;
2902
+ return context.previous;
2903
+ }
2904
+ const positions = flagTriangle(coords).map((item) => (0, vesium.toCartesian3)(item));
2905
+ const hierarchy = new cesium.PolygonHierarchy(positions);
2906
+ entity.polygon.hierarchy = new cesium.CallbackProperty(() => hierarchy, false);
2907
+ return { entities: [entity] };
2908
+ }
1309
2909
  });
1310
- const schemeBillboard = new PlotScheme({
1311
- type: "billboard",
1312
- complete: (packable) => packable.positions.length >= 1,
1313
- skeletons: [
1314
- moved
1315
- ],
1316
- initEntites: () => [
1317
- new cesium.Entity({ billboard: { image: "/favicon.svg", width: 32, height: 32 } })
1318
- ],
1319
- render(options) {
1320
- var _a, _b;
1321
- const { mouse, packable } = options;
1322
- const entity = ((_a = options.previous.entities) == null ? void 0 : _a[0]) ?? new cesium.Entity({ billboard: {} });
1323
- const position = ((_b = packable.positions) == null ? void 0 : _b[0]) ?? mouse;
1324
- entity.position = new cesium.CallbackPositionProperty(() => position, true);
1325
- return {
1326
- entities: [entity]
1327
- };
1328
- }
2910
+
2911
+ //#endregion
2912
+ //#region scheme/PolygonSmooth.ts
2913
+ const PlotSchemePolygonSmooth = new PlotScheme({
2914
+ type: "PolygonSmooth",
2915
+ allowManualComplete: (packable) => packable.positions.length >= 3,
2916
+ skeletons: [
2917
+ moved,
2918
+ control,
2919
+ intervalNonclosed
2920
+ ],
2921
+ initRender() {
2922
+ return { entities: [new cesium.Entity({ polygon: {} })] };
2923
+ },
2924
+ render(context) {
2925
+ const entity = context.previous.entities[0];
2926
+ const positions = context.packable.positions;
2927
+ const mousePosition = context.mouse;
2928
+ mousePosition && positions.push(mousePosition.clone());
2929
+ if (positions.length <= 2) {
2930
+ entity.polygon.hierarchy = void 0;
2931
+ return context.previous;
2932
+ }
2933
+ const wgs84s = positions.map((e) => (0, vesium.toCoord)(e));
2934
+ wgs84s.push(wgs84s[0]);
2935
+ const { features } = __turf_turf.polygonSmooth(__turf_turf.polygon([wgs84s]), { iterations: 3 });
2936
+ const cartesians = features[0].geometry.coordinates[0].map((item) => (0, vesium.toCartesian3)(item)).filter((e) => !!e);
2937
+ const hierarchy = new cesium.PolygonHierarchy(cartesians);
2938
+ entity.polygon.hierarchy = new cesium.CallbackProperty(() => hierarchy, false);
2939
+ return { entities: [entity] };
2940
+ }
1329
2941
  });
1330
- const schemeLabel = new PlotScheme({
1331
- type: "label",
1332
- complete: (packable) => packable.positions.length >= 1,
1333
- skeletons: [
1334
- moved
1335
- ],
1336
- initEntites: () => [
1337
- new cesium.Entity({ label: { text: "Label" } })
1338
- ],
1339
- render(options) {
1340
- var _a, _b;
1341
- const { mouse, packable } = options;
1342
- const entity = ((_a = options.previous.entities) == null ? void 0 : _a[0]) ?? new cesium.Entity({ label: {} });
1343
- const position = ((_b = packable.positions) == null ? void 0 : _b[0]) ?? mouse;
1344
- entity.position = new cesium.CallbackPositionProperty(() => position, true);
1345
- return {
1346
- entities: [entity]
1347
- };
1348
- }
2942
+
2943
+ //#endregion
2944
+ //#region scheme/Polyline.ts
2945
+ const PlotSchemePolyline = new PlotScheme({
2946
+ type: "Polyline",
2947
+ allowManualComplete: (packable) => packable.positions.length > 1,
2948
+ skeletons: [
2949
+ moved,
2950
+ control,
2951
+ intervalNonclosed
2952
+ ],
2953
+ initRender() {
2954
+ return { entities: [new cesium.Entity({ polyline: {
2955
+ material: cesium.Color.RED,
2956
+ width: 2
2957
+ } })] };
2958
+ },
2959
+ render(context) {
2960
+ const entity = context.previous.entities[0];
2961
+ const positions = [...context.packable.positions];
2962
+ const mouse = context.mouse;
2963
+ mouse && positions.push(mouse.clone());
2964
+ const cache = positions.length >= 2 ? positions : [];
2965
+ entity.polyline.positions = new cesium.CallbackProperty(() => cache, false);
2966
+ return { entities: [entity] };
2967
+ }
1349
2968
  });
1350
- const schemePolygon = new PlotScheme({
1351
- type: "polygon",
1352
- allowManualComplete: (packable) => packable.positions.length >= 3,
1353
- skeletons: [
1354
- control,
1355
- interval,
1356
- moved
1357
- ],
1358
- initEntites: () => [
1359
- new cesium.Entity({
1360
- polyline: {
1361
- material: cesium.Color.YELLOW.withAlpha(0.5)
1362
- },
1363
- polygon: {
1364
- material: cesium.Color.YELLOW.withAlpha(0.5)
1365
- }
1366
- })
1367
- ],
1368
- render(options) {
1369
- var _a;
1370
- const { mouse, packable } = options;
1371
- const entity = ((_a = options.previous.entities) == null ? void 0 : _a[0]) ?? new cesium.Entity({
1372
- polyline: {
1373
- material: cesium.Color.YELLOW.withAlpha(0.5)
1374
- },
1375
- polygon: {
1376
- material: cesium.Color.YELLOW.withAlpha(0.5)
1377
- }
1378
- });
1379
- const positions = [...packable.positions ?? []];
1380
- mouse && positions.push(mouse);
1381
- if (positions.length === 2) {
1382
- entity.polygon.hierarchy = void 0;
1383
- entity.polyline.positions = new cesium.CallbackProperty(() => positions, false);
1384
- } else if (positions.length >= 3) {
1385
- entity.polyline.positions = void 0;
1386
- entity.polygon.hierarchy = new cesium.CallbackProperty(() => {
1387
- positions.push(positions[0]);
1388
- return positions.length >= 3 ? new cesium.PolygonHierarchy([...positions]) : void 0;
1389
- }, false);
1390
- } else {
1391
- entity.polygon.hierarchy = void 0;
1392
- entity.polyline.positions = void 0;
1393
- }
1394
- return {
1395
- entities: [entity]
1396
- };
1397
- }
2969
+
2970
+ //#endregion
2971
+ //#region scheme/PolylineCurve.ts
2972
+ const PlotSchemePolylineCurve = new PlotScheme({
2973
+ type: "PolylineCurve",
2974
+ allowManualComplete: (packable) => packable.positions.length > 1,
2975
+ skeletons: [
2976
+ moved,
2977
+ control,
2978
+ intervalNonclosed
2979
+ ],
2980
+ initRender() {
2981
+ return { entities: [new cesium.Entity({ polyline: {
2982
+ material: cesium.Color.RED,
2983
+ width: 2
2984
+ } })] };
2985
+ },
2986
+ render(context) {
2987
+ const entity = context.previous.entities[0];
2988
+ const positions = [...context.packable.positions];
2989
+ const mouse = context.mouse;
2990
+ mouse && positions.push(mouse.clone());
2991
+ if (positions.length < 2) {
2992
+ entity.polyline.positions = void 0;
2993
+ return context.previous;
2994
+ }
2995
+ const coords = positions.map((position) => (0, vesium.toCoord)(position));
2996
+ const { geometry: { coordinates } } = __turf_turf.bezierSpline(__turf_turf.lineString(coords));
2997
+ entity.polyline.positions = new cesium.CallbackProperty(() => coordinates.map(vesium.toCartesian3), false);
2998
+ return { entities: [entity] };
2999
+ }
1398
3000
  });
1399
- const schemePolyline = new PlotScheme(
1400
- {
1401
- type: "polyline",
1402
- allowManualComplete: (packable) => packable.positions.length >= 2,
1403
- skeletons: [
1404
- control,
1405
- intervalNonclosed,
1406
- moved
1407
- ],
1408
- initEntites: () => [
1409
- new cesium.Entity({ polyline: { width: 1 } })
1410
- ],
1411
- render(options) {
1412
- var _a;
1413
- const { mouse, packable } = options;
1414
- const entity = ((_a = options.previous.entities) == null ? void 0 : _a[0]) ?? new cesium.Entity({ polyline: {} });
1415
- entity.polyline.positions = new cesium.CallbackProperty(() => {
1416
- const positions = [...packable.positions ?? []].concat(mouse ? [mouse] : []);
1417
- return positions.length >= 2 ? positions : [];
1418
- }, false);
1419
- return {
1420
- entities: [entity]
1421
- };
1422
- }
1423
- }
1424
- );
1425
- const schemeRectangle = new PlotScheme({
1426
- type: "rectangle",
1427
- complete: (packable) => packable.positions.length >= 2,
1428
- skeletons: [
1429
- control,
1430
- interval,
1431
- moved
1432
- ],
1433
- initEntites: () => [
1434
- new cesium.Entity({
1435
- rectangle: {
1436
- material: cesium.Color.YELLOW.withAlpha(0.5)
1437
- }
1438
- })
1439
- ],
1440
- render(options) {
1441
- var _a;
1442
- const { mouse, packable } = options;
1443
- const entity = ((_a = options.previous.entities) == null ? void 0 : _a[0]) ?? new cesium.Entity({
1444
- rectangle: {
1445
- material: cesium.Color.YELLOW.withAlpha(0.5)
1446
- }
1447
- });
1448
- const positions = [...packable.positions ?? []];
1449
- mouse && positions.push(mouse);
1450
- if (positions.length >= 2) {
1451
- entity.rectangle.coordinates = new cesium.CallbackProperty(() => cesium.Rectangle.fromCartesianArray(positions), false);
1452
- } else {
1453
- entity.rectangle.coordinates = void 0;
1454
- }
1455
- return {
1456
- entities: [entity]
1457
- };
1458
- }
3001
+
3002
+ //#endregion
3003
+ //#region scheme/Rectangle.ts
3004
+ const PlotSchemeRectangle = new PlotScheme({
3005
+ type: "Rectangle",
3006
+ complete: (packable) => packable.positions.length >= 2,
3007
+ skeletons: [moved, control],
3008
+ initRender() {
3009
+ return { entities: [new cesium.Entity({ rectangle: {} })] };
3010
+ },
3011
+ render(context) {
3012
+ const entity = context.previous.entities[0];
3013
+ const positions = [...context.packable.positions];
3014
+ const mouse = context.mouse;
3015
+ mouse && positions.push(mouse.clone());
3016
+ if (positions.length < 2) {
3017
+ entity.rectangle.coordinates = void 0;
3018
+ return context.previous;
3019
+ }
3020
+ const coordinates = cesium.Rectangle.fromCartesianArray(positions ?? []);
3021
+ entity.rectangle.coordinates = new cesium.CallbackProperty(() => coordinates, false);
3022
+ return { entities: [entity] };
3023
+ }
1459
3024
  });
3025
+
3026
+ //#endregion
1460
3027
  exports.PlotAction = PlotAction;
1461
3028
  exports.PlotFeature = PlotFeature;
1462
3029
  exports.PlotScheme = PlotScheme;
3030
+ exports.PlotSchemeBillboard = PlotSchemeBillboard;
3031
+ exports.PlotSchemeBillboardPinBuilder = PlotSchemeBillboardPinBuilder;
3032
+ exports.PlotSchemeCylinder = PlotSchemeCylinder;
3033
+ exports.PlotSchemeEllipse = PlotSchemeEllipse;
3034
+ exports.PlotSchemeLabel = PlotSchemeLabel;
3035
+ exports.PlotSchemePoint = PlotSchemePoint;
3036
+ exports.PlotSchemePolygon = PlotSchemePolygon;
3037
+ exports.PlotSchemePolygonArc = PlotSchemePolygonArc;
3038
+ exports.PlotSchemePolygonArrowAttackDirection = PlotSchemePolygonArrowAttackDirection;
3039
+ exports.PlotSchemePolygonArrowAttackDirectionTailed = PlotSchemePolygonArrowAttackDirectionTailed;
3040
+ exports.PlotSchemePolygonArrowClamped = PlotSchemePolygonArrowClamped;
3041
+ exports.PlotSchemePolygonArrowStraight = PlotSchemePolygonArrowStraight;
3042
+ exports.PlotSchemePolygonArrowStraightSharp = PlotSchemePolygonArrowStraightSharp;
3043
+ exports.PlotSchemePolygonArrowUnitCombatOperation = PlotSchemePolygonArrowUnitCombatOperation;
3044
+ exports.PlotSchemePolygonArrowUnitCombatOperationTailed = PlotSchemePolygonArrowUnitCombatOperationTailed;
3045
+ exports.PlotSchemePolygonAssemblingPlace = PlotSchemePolygonAssemblingPlace;
3046
+ exports.PlotSchemePolygonFlagCurve = PlotSchemePolygonFlagCurve;
3047
+ exports.PlotSchemePolygonFlagRect = PlotSchemePolygonFlagRect;
3048
+ exports.PlotSchemePolygonFlagTriangle = PlotSchemePolygonFlagTriangle;
3049
+ exports.PlotSchemePolygonSmooth = PlotSchemePolygonSmooth;
3050
+ exports.PlotSchemePolyline = PlotSchemePolyline;
3051
+ exports.PlotSchemePolylineCurve = PlotSchemePolylineCurve;
3052
+ exports.PlotSchemeRectangle = PlotSchemeRectangle;
1463
3053
  exports.PlotSkeletonEntity = PlotSkeletonEntity;
1464
3054
  exports.SampledPlotProperty = SampledPlotProperty;
1465
3055
  exports.SampledPlotStrategy = SampledPlotStrategy;
@@ -1467,11 +3057,7 @@ exports.control = control;
1467
3057
  exports.interval = interval;
1468
3058
  exports.intervalNonclosed = intervalNonclosed;
1469
3059
  exports.moved = moved;
1470
- exports.schemeBillboard = schemeBillboard;
1471
- exports.schemeLabel = schemeLabel;
1472
3060
  exports.schemeMeasureArea = schemeMeasureArea;
1473
- exports.schemePolygon = schemePolygon;
1474
- exports.schemePolyline = schemePolyline;
1475
- exports.schemeRectangle = schemeRectangle;
3061
+ exports.schemeMeasureDistance = schemeMeasureDistance;
1476
3062
  exports.usePlot = usePlot;
1477
- //# sourceMappingURL=index.cjs.map
3063
+ //# sourceMappingURL=index.cjs.map