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

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,1462 +1,1505 @@
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
+
29
+ //#region usePlot/PlotScheme.ts
30
+ var PlotScheme = class PlotScheme {
31
+ constructor(options) {
32
+ this.type = options.type;
33
+ this.complete = options.complete;
34
+ this.allowManualComplete = options.allowManualComplete;
35
+ this.definingCursor = options.definingCursor ?? "crosshair";
36
+ this.skeletons = options.skeletons?.map((item) => item()) ?? [];
37
+ this.initEntites = options.initEntites;
38
+ this.initPrimitives = options.initPrimitives;
39
+ this.initGroundPrimitives = options.initGroundPrimitives;
40
+ this.render = options.render;
41
+ }
42
+ /**
43
+ * 标绘类型。应当是全局唯一的字符串,会作为键名缓存
44
+ */
45
+ type;
46
+ /**
47
+ * 判断是否立即完成标绘.
48
+ * 每次控制点发生变变化时,执行该回调函数,返回`true`则完成标绘
49
+ */
50
+ complete;
51
+ /**
52
+ * 判断是否允许手动完成标绘。
53
+ * 每次控制点发生变变化时,执行该回调函数,返回`true`则后续左键双击即完成标绘
54
+ */
55
+ allowManualComplete;
56
+ /**
57
+ * 处于定义态时鼠标的样式
58
+ * @default 'crosshair'
59
+ */
60
+ definingCursor;
61
+ /**
62
+ * 当前标绘的框架点数据
63
+ */
64
+ skeletons;
65
+ /**
66
+ * 初始化时创建`Entity`的函数,创建后的`Entity`会作为配置项传入`render`中
67
+ */
68
+ initEntites;
69
+ /**
70
+ * 初始化时创建`Primitive`的函数,创建后的`Primitive`会作为配置项传入`render`中
71
+ */
72
+ initPrimitives;
73
+ /**
74
+ * 初始化时创建贴地`Primitive`的函数,创建后的`Primitive`会作为配置项传入`render`中
75
+ */
76
+ initGroundPrimitives;
77
+ /**
78
+ * 当标绘数据变化时,会触发`render`回调,返回的数据会被添加到cesium中
79
+ */
80
+ render;
81
+ static _record = /* @__PURE__ */ new Map();
82
+ /**
83
+ * 标绘方案缓存。
84
+ * 每次标绘时都会将`PlotScheme.type`作为键名缓存,
85
+ * 后续可用过`PlotScheme.getCache(type)`获取完整的`PlotScheme`配置。
86
+ */
87
+ static getCacheTypes() {
88
+ return [...this._record.keys()];
89
+ }
90
+ /**
91
+ * 通过`PlotScheme.type`获取缓存中的`PlotScheme`配置。
92
+ */
93
+ static getCache(type) {
94
+ return PlotScheme._record.get(type);
95
+ }
96
+ /**
97
+ * 缓存标绘方案。
98
+ */
99
+ static setCache(scheme) {
100
+ (0, vesium.assertError)(!scheme.type, "`scheme.type` is required");
101
+ PlotScheme._record.set(scheme.type, scheme);
102
+ }
103
+ /**
104
+ * 解析传入的maybeScheme,maybeScheme可能是一个完整的PlotScheme,也可能是缓存中的`PlotScheme.type`,并返回 PlotScheme 实例。
105
+ * 若传入的是`PlotScheme.type`字符串,并且缓存中不存在该标绘方案,则抛出错误。
106
+ */
107
+ static resolve(maybeScheme) {
108
+ if (typeof maybeScheme === "string") {
109
+ const _scheme = PlotScheme.getCache(maybeScheme);
110
+ (0, __vueuse_core.assert)(!!_scheme, `scheme ${maybeScheme} not found`);
111
+ return _scheme;
112
+ } else if (!(maybeScheme instanceof PlotScheme)) return new PlotScheme(maybeScheme);
113
+ else return maybeScheme;
114
+ }
115
+ };
116
+
117
+ //#endregion
118
+ //#region usePlot/SampledPlotProperty.ts
119
+ let SampledPlotStrategy = /* @__PURE__ */ function(SampledPlotStrategy$1) {
120
+ SampledPlotStrategy$1[SampledPlotStrategy$1["NEAR"] = 0] = "NEAR";
121
+ SampledPlotStrategy$1[SampledPlotStrategy$1["CYCLE"] = 1] = "CYCLE";
122
+ SampledPlotStrategy$1[SampledPlotStrategy$1["STRICT"] = 2] = "STRICT";
123
+ return SampledPlotStrategy$1;
124
+ }({});
125
+ /**
126
+ * 默认插值算法
127
+ *
128
+ * @param time 时间
129
+ * @param previous 前一个数据点
130
+ * @param next 后一个数据点
131
+ * @param proportion 比例
132
+ * @returns 插值结果
133
+ */
107
134
  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
- };
135
+ if (proportion === 0) return {
136
+ time,
137
+ positions: previous.positions?.map((item) => item.clone()),
138
+ derivative: previous.derivative
139
+ };
140
+ else if (proportion === 1) return {
141
+ time,
142
+ positions: next.positions?.map((item) => item.clone()),
143
+ derivative: previous.derivative
144
+ };
145
+ return {
146
+ time,
147
+ positions: next.positions?.map((right, index) => {
148
+ const left = previous.positions?.[index];
149
+ return !left ? right : cesium.Cartesian3.lerp(left, right, proportion, new cesium.Cartesian3());
150
+ }),
151
+ derivative: previous.derivative
152
+ };
131
153
  };
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
- }
154
+ /**
155
+ * 标绘采样点数据。
156
+ * 标绘采样点数据是一个时间序列数据,包含时间、位置和附带的额外数据。
157
+ * 具体用法可参考 [Cesium.SampledProperty](https://cesium.com/learn/cesiumjs/ref-doc/SampledProperty.html)
158
+ */
159
+ var SampledPlotProperty = class SampledPlotProperty {
160
+ constructor(options) {
161
+ this.interpolationAlgorithm = options?.interpolationAlgorithm;
162
+ this.strategy = options?.strategy ?? SampledPlotStrategy.NEAR;
163
+ options?.packables?.forEach((packable) => this.setSample(packable));
164
+ if (!this._times.length) this.setSample({
165
+ time: new cesium.JulianDate(0, 0),
166
+ positions: [],
167
+ derivative: void 0
168
+ });
169
+ }
170
+ static defaultInterpolationAlgorithm = defaultInterpolationAlgorithm;
171
+ strategy;
172
+ interpolationAlgorithm;
173
+ /**
174
+ * @internal
175
+ */
176
+ _times = [];
177
+ /**
178
+ * @internal
179
+ */
180
+ _sampleds = [];
181
+ /**
182
+ * @internal
183
+ */
184
+ _derivatives = [];
185
+ get isConstant() {
186
+ return this._times.length === 0;
187
+ }
188
+ /**
189
+ * @internal
190
+ */
191
+ _definitionChanged = new cesium.Event();
192
+ get definitionChanged() {
193
+ return this._definitionChanged;
194
+ }
195
+ /**
196
+ * 获取时间数组
197
+ *
198
+ * @returns 返回包含所有时间的 JulianDate 数组
199
+ */
200
+ getTimes() {
201
+ return this._times.map((t) => t.clone());
202
+ }
203
+ /**
204
+ * 根据给定的儒略日期获取时间索引范围及比例
205
+ *
206
+ * @param time 给定的儒略日期
207
+ * @returns 返回包含前一个索引、后一个索引及时间比例的对象,若不符合条件则返回undefined
208
+ * @internal
209
+ */
210
+ getIndexScope(time) {
211
+ if (!this._times.length) return;
212
+ const start = this._times[0];
213
+ const end = this._times[this._times.length - 1];
214
+ if (cesium.JulianDate.lessThan(time, start) || cesium.JulianDate.greaterThan(time, end)) switch (this.strategy) {
215
+ case SampledPlotStrategy.STRICT: return;
216
+ case SampledPlotStrategy.NEAR: {
217
+ time = cesium.JulianDate.lessThan(time, this._times[0]) ? this._times[0].clone() : this._times[this._times.length - 1].clone();
218
+ break;
219
+ }
220
+ case SampledPlotStrategy.CYCLE: {
221
+ const startMS = cesium.JulianDate.toDate(this._times[0]).getTime();
222
+ const endMS = cesium.JulianDate.toDate(this._times[this._times.length - 1]).getTime();
223
+ const duration = endMS - startMS;
224
+ const timeMS = cesium.JulianDate.toDate(time).getTime();
225
+ const diff = (timeMS - startMS) % duration;
226
+ const dete = new Date(startMS + diff);
227
+ time = cesium.JulianDate.fromDate(dete);
228
+ break;
229
+ }
230
+ }
231
+ const prevIndex = this._times.findIndex((t) => cesium.JulianDate.lessThanOrEquals(time, t));
232
+ const nextIndex = Math.min(prevIndex, this._times.length - 1);
233
+ const prevMs = cesium.JulianDate.toDate(this._times[prevIndex]).getTime();
234
+ const nextMs = cesium.JulianDate.toDate(this._times[nextIndex]).getTime();
235
+ const ms = cesium.JulianDate.toDate(time).getTime();
236
+ return {
237
+ prevIndex,
238
+ nextIndex,
239
+ proportion: (ms - prevMs) / (nextMs - prevMs) || 0
240
+ };
241
+ }
242
+ /**
243
+ * 根据给定的儒略日期(JulianDate)获取插值后的样本点数据。
244
+ *
245
+ * @param time 指定的儒略日期(JulianDate)。
246
+ * @param result 可选参数,用于存储结果的容器。如果未提供,则创建一个新的容器。
247
+ * @returns 插值后的样本点数据,存储在提供的或新创建的result容器中。
248
+ * @template D 数据类型。
249
+ */
250
+ getValue(time, result) {
251
+ result ??= { time };
252
+ Object.assign(result, {
253
+ time: time?.clone(),
254
+ positions: void 0,
255
+ derivative: void 0
256
+ });
257
+ if (!time) {
258
+ result.time = this._times[0].clone();
259
+ result.positions = this._sampleds[0]?.map((c) => c.clone(c));
260
+ result.derivative = this._derivatives[0];
261
+ return result;
262
+ }
263
+ const scope = this.getIndexScope(time);
264
+ if (!scope) return result;
265
+ result.time = time;
266
+ const { prevIndex, nextIndex, proportion } = scope;
267
+ const previous = {
268
+ time: this._times[prevIndex],
269
+ positions: this._sampleds[prevIndex],
270
+ derivative: this._derivatives[prevIndex]
271
+ };
272
+ const next = {
273
+ time: this._times[nextIndex],
274
+ positions: this._sampleds[nextIndex],
275
+ derivative: this._derivatives[nextIndex]
276
+ };
277
+ const packable = (this.interpolationAlgorithm || SampledPlotProperty.defaultInterpolationAlgorithm)(time, previous, next, proportion);
278
+ Object.assign(result, packable);
279
+ return result;
280
+ }
281
+ /**
282
+ * 设置样本数据,如果传入的数据不含时间,则会存入时间最早的集合中
283
+ * @param value 样本数据对象,包含时间、位置和导数信息
284
+ */
285
+ setSample(value) {
286
+ const time = value.time?.clone() ?? this._times[0].clone();
287
+ const positions = value.positions?.map((item) => item.clone()) ?? [];
288
+ const derivative = value.derivative;
289
+ const index = this._times.findIndex((t) => cesium.JulianDate.equals(time, t));
290
+ if (index !== -1) {
291
+ this._times[index] = time;
292
+ this._sampleds[index] = positions;
293
+ this._derivatives[index] = value.derivative;
294
+ } else if (this._times.length === 0) {
295
+ this._times[0] = time;
296
+ this._sampleds[0] = positions;
297
+ this._derivatives[0] = value.derivative;
298
+ } else if (cesium.JulianDate.lessThan(time, this._times[0])) {
299
+ this._times.splice(0, 0, time);
300
+ this._sampleds.splice(0, 0, positions);
301
+ this._derivatives.splice(0, 0, derivative);
302
+ } else if (cesium.JulianDate.greaterThan(time, this._times[this._times.length - 1])) {
303
+ this._times.push(time);
304
+ this._sampleds.push(positions);
305
+ this._derivatives.push(derivative);
306
+ }
307
+ this.definitionChanged.raiseEvent(this);
308
+ }
309
+ /**
310
+ * 设置样本数据
311
+ *
312
+ * @param values 样本数据数组,每个元素都是类型为SampledPlotPackable<D>的对象
313
+ */
314
+ setSamples(values) {
315
+ values.forEach((value) => this.setSample(value));
316
+ }
317
+ /**
318
+ * 从样本中移除指定时间点的数据
319
+ *
320
+ * @param time 需要移除的时间点,使用儒略日期表示
321
+ * @returns 如果成功移除,则返回 true;否则返回 false
322
+ */
323
+ removeSample(time) {
324
+ const index = this._times.findIndex((t) => t.equals(time));
325
+ if (index !== -1) {
326
+ this._sampleds.splice(index, 1);
327
+ this._derivatives.splice(index, 1);
328
+ const removed = this._times.splice(index, 1);
329
+ if (removed.length) {
330
+ this._definitionChanged.raiseEvent(this);
331
+ return true;
332
+ }
333
+ }
334
+ return false;
335
+ }
336
+ /**
337
+ * 从样本中移除指定时间间隔内的样本。
338
+ *
339
+ * @param interval 要移除样本的时间间隔
340
+ */
341
+ removeSamples(interval$1) {
342
+ for (let i = 0; i < this._times.length; i++) {
343
+ const time = this._times[i];
344
+ cesium.TimeInterval.contains(interval$1, time) && this.removeSample(time);
345
+ }
346
+ }
347
+ /**
348
+ * 判断两个property是否相等
349
+ */
350
+ equals(other) {
351
+ return other === this;
352
+ }
338
353
  };
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
- }
354
+
355
+ //#endregion
356
+ //#region usePlot/PlotFeature.ts
357
+ /**
358
+ * 标绘实例
359
+ */
360
+ var PlotFeature = class {
361
+ constructor(options) {
362
+ const { id, disabled = false, sampled } = options;
363
+ this._id = id || (0, cesium.createGuid)();
364
+ this._scheme = PlotScheme.resolve(options.scheme);
365
+ this._definitionChanged = new cesium.Event();
366
+ this._defining = true;
367
+ this._disabled = disabled;
368
+ this._sampled = sampled instanceof SampledPlotProperty ? sampled : new SampledPlotProperty(sampled);
369
+ this._sampled.definitionChanged.addEventListener((property) => this._definitionChanged.raiseEvent(this, "sampled", property, property), this);
370
+ this._entities = [...this._scheme.initEntites?.() ?? []];
371
+ this._primitives = [...this._scheme.initPrimitives?.() ?? []];
372
+ this._groundPrimitives = [...this._scheme.initGroundPrimitives?.() ?? []];
373
+ this._skeletons = [];
374
+ }
375
+ /**
376
+ * @internal
377
+ */
378
+ _id;
379
+ get id() {
380
+ return this._id;
381
+ }
382
+ /**
383
+ * @internal
384
+ */
385
+ _scheme;
386
+ get scheme() {
387
+ return this._scheme;
388
+ }
389
+ /**
390
+ * @internal
391
+ */
392
+ _definitionChanged;
393
+ get definitionChanged() {
394
+ return this._definitionChanged;
395
+ }
396
+ /**
397
+ * @internal
398
+ */
399
+ _defining;
400
+ get defining() {
401
+ return this._defining;
402
+ }
403
+ /**
404
+ * @internal
405
+ */
406
+ static setDefining(plot, value) {
407
+ if (plot._defining !== value) {
408
+ plot._definitionChanged.raiseEvent(plot, "defining", value, plot._defining);
409
+ plot._defining = value;
410
+ }
411
+ }
412
+ /**
413
+ * @internal
414
+ */
415
+ _disabled;
416
+ /**
417
+ * 获取禁用状态
418
+ *
419
+ * 当为 `true` 时,标绘实例将停止响应交互和更新;
420
+ * 为 `false` 时恢复正常功能。
421
+ */
422
+ get disabled() {
423
+ return this._disabled;
424
+ }
425
+ set disabled(value) {
426
+ this.disabled = value;
427
+ }
428
+ /**
429
+ * @internal
430
+ */
431
+ _sampled;
432
+ get sampled() {
433
+ return this._sampled;
434
+ }
435
+ /**
436
+ * @internal
437
+ */
438
+ _entities;
439
+ get entities() {
440
+ return this._entities;
441
+ }
442
+ set entities(value) {
443
+ this._definitionChanged.raiseEvent(this, "entities", value, this._entities);
444
+ this._entities = value;
445
+ }
446
+ /**
447
+ * @internal
448
+ */
449
+ _primitives;
450
+ get primitives() {
451
+ return this._primitives;
452
+ }
453
+ /**
454
+ * @internal
455
+ */
456
+ set primitives(value) {
457
+ this._definitionChanged.raiseEvent(this, "primitives", value, this._primitives);
458
+ this._primitives = value;
459
+ }
460
+ /**
461
+ * @internal
462
+ */
463
+ _groundPrimitives;
464
+ get groundPrimitives() {
465
+ return this._groundPrimitives;
466
+ }
467
+ /**
468
+ * @internal
469
+ */
470
+ set groundPrimitives(value) {
471
+ this._definitionChanged.raiseEvent(this, "groundPrimitives", value, this._groundPrimitives);
472
+ this._groundPrimitives = value;
473
+ }
474
+ /**
475
+ * @internal
476
+ */
477
+ _skeletons;
478
+ get skeletons() {
479
+ return this._skeletons;
480
+ }
481
+ /**
482
+ * @internal
483
+ */
484
+ set skeletons(value) {
485
+ this._definitionChanged.raiseEvent(this, "skeletons", value, this._skeletons);
486
+ this._skeletons = value;
487
+ }
488
+ };
489
+
490
+ //#endregion
491
+ //#region usePlot/PlotSkeleton.ts
492
+ /**
493
+ * 框架点执行状态枚举
494
+ * - IDLE 空闲状态
495
+ * - HOVER 悬停状态
496
+ * - ACTIVE 激活状态
497
+ */
498
+ let PlotAction = /* @__PURE__ */ function(PlotAction$1) {
499
+ PlotAction$1[PlotAction$1["IDLE"] = 0] = "IDLE";
500
+ PlotAction$1[PlotAction$1["HOVER"] = 1] = "HOVER";
501
+ PlotAction$1[PlotAction$1["ACTIVE"] = 2] = "ACTIVE";
502
+ return PlotAction$1;
503
+ }({});
504
+ /**
505
+ * 标绘框架点 Entity
506
+ */
507
+ var PlotSkeletonEntity = class extends cesium.Entity {
508
+ constructor(options) {
509
+ super(options);
510
+ }
511
+ };
512
+
513
+ //#endregion
514
+ //#region usePlot/useRender.ts
482
515
  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
- };
516
+ const viewer = (0, vesium.useViewer)();
517
+ const primitiveCollection = (0, vesium.usePrimitive)(new cesium.PrimitiveCollection());
518
+ const groundPrimitiveCollection = (0, vesium.usePrimitive)(new cesium.PrimitiveCollection(), { collection: "ground" });
519
+ const dataSource = (0, vesium.useDataSource)(new cesium.CustomDataSource());
520
+ const entityScope = (0, vesium.useEntityScope)({ collection: () => dataSource.value.entities });
521
+ const primitiveScope = (0, vesium.usePrimitiveScope)({ collection: () => primitiveCollection.value });
522
+ const groundPrimitiveScope = (0, vesium.usePrimitiveScope)({ collection: () => groundPrimitiveCollection.value });
523
+ const mouseCartesian = (0, vue.shallowRef)();
524
+ (0, vesium.useScreenSpaceEventHandler)(cesium.ScreenSpaceEventType.MOUSE_MOVE, (event) => {
525
+ mouseCartesian.value = (0, vesium.canvasCoordToCartesian)(event?.endPosition, viewer.value.scene);
526
+ });
527
+ (0, __vueuse_core.watchArray)(plots, (_value, _oldValue, added, removed = []) => {
528
+ removed.forEach((plot) => {
529
+ entityScope.removeWhere((item) => plot.entities.includes(item));
530
+ primitiveScope.removeWhere((item) => plot.primitives.includes(item));
531
+ groundPrimitiveScope.removeWhere((item) => plot.groundPrimitives.includes(item));
532
+ });
533
+ added.forEach((plot) => {
534
+ plot.entities.forEach((item) => entityScope.add(item));
535
+ plot.primitives.forEach((item) => primitiveScope.add(item));
536
+ plot.groundPrimitives.forEach((item) => groundPrimitiveScope.add(item));
537
+ });
538
+ }, {
539
+ immediate: true,
540
+ flush: "post"
541
+ });
542
+ (0, vesium.useCesiumEventListener)(() => plots.value.map((item) => item.definitionChanged), (_scope, key, newValue, oldValue) => {
543
+ if (key === "entities") {
544
+ const { added, removed } = (0, vesium.arrayDiff)(newValue, oldValue);
545
+ added.forEach((item) => entityScope.add(item));
546
+ removed.forEach((item) => entityScope.remove(item));
547
+ } else if (key === "primitives") {
548
+ const { added, removed } = (0, vesium.arrayDiff)(newValue, oldValue);
549
+ added.forEach((item) => primitiveScope.add(item));
550
+ removed.forEach((item) => primitiveScope.remove(item));
551
+ } else if (key === "groundPrimitives") {
552
+ const { added, removed } = (0, vesium.arrayDiff)(newValue, oldValue);
553
+ added.forEach((item) => groundPrimitiveScope.add(item));
554
+ removed.forEach((item) => groundPrimitiveScope.remove(item));
555
+ }
556
+ });
557
+ const update = async (plot) => {
558
+ const reslut = await plot.scheme.render?.({
559
+ packable: plot.sampled.getValue(getCurrentTime()),
560
+ mouse: plot.defining ? mouseCartesian.value : void 0,
561
+ defining: plot.defining,
562
+ previous: {
563
+ entities: plot.entities,
564
+ primitives: plot.primitives,
565
+ groundPrimitives: plot.groundPrimitives
566
+ }
567
+ });
568
+ plot.entities = reslut?.entities ?? [];
569
+ plot.primitives = reslut?.primitives ?? [];
570
+ plot.groundPrimitives = reslut?.groundPrimitives ?? [];
571
+ };
572
+ (0, vue.watch)(current, (plot, previous) => {
573
+ previous && update(previous);
574
+ });
575
+ (0, vesium.useCesiumEventListener)(() => plots.value.map((item) => item.definitionChanged), (plot, key) => {
576
+ if ([
577
+ "disabled",
578
+ "defining",
579
+ "scheme",
580
+ "sampled",
581
+ "time"
582
+ ].includes(key)) update(plot);
583
+ });
584
+ (0, vue.watch)(mouseCartesian, () => {
585
+ plots.value.forEach((plot) => plot.defining && update(plot));
586
+ });
587
+ return {
588
+ primitives: (0, vue.computed)(() => Array.from(primitiveScope.scope)),
589
+ groundPrimitives: (0, vue.computed)(() => Array.from(primitiveScope.scope)),
590
+ entities: (0, vue.computed)(() => Array.from(entityScope.scope))
591
+ };
565
592
  }
593
+
594
+ //#endregion
595
+ //#region usePlot/useSampled.ts
566
596
  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());
597
+ const viewer = (0, vesium.useViewer)();
598
+ const doubleClicking = (0, vue.ref)(false);
599
+ const packable = (0, vue.computed)(() => {
600
+ return current.value?.sampled.getValue(getCurrentTime());
601
+ });
602
+ (0, vesium.useScreenSpaceEventHandler)(cesium.ScreenSpaceEventType.LEFT_CLICK, async (ctx) => {
603
+ await (0, __vueuse_core.promiseTimeout)(1);
604
+ if (!current.value || !packable.value) return;
605
+ if (doubleClicking.value) return;
606
+ const { scheme, defining, sampled } = current.value;
607
+ if (!defining) return;
608
+ const position = (0, vesium.canvasCoordToCartesian)(ctx.position, viewer.value.scene);
609
+ if (!position) return;
610
+ packable.value.positions ??= [];
611
+ packable.value.positions.push(position);
612
+ sampled.setSample(packable.value);
613
+ const completed = scheme.complete?.(packable.value);
614
+ completed && PlotFeature.setDefining(current.value, false);
615
+ });
616
+ (0, vesium.useScreenSpaceEventHandler)(cesium.ScreenSpaceEventType.LEFT_DOUBLE_CLICK, async (ctx) => {
617
+ if (!current.value || !packable.value) return;
618
+ doubleClicking.value = true;
619
+ await (0, __vueuse_core.promiseTimeout)(2);
620
+ doubleClicking.value = false;
621
+ const { scheme, defining } = current.value;
622
+ if (!defining) return;
623
+ const position = (0, vesium.canvasCoordToCartesian)(ctx.position, viewer.value.scene);
624
+ if (!position) return;
625
+ const completed = scheme.allowManualComplete?.(packable.value);
626
+ completed && PlotFeature.setDefining(current.value, false);
627
+ });
628
+ (0, vesium.useScreenSpaceEventHandler)(cesium.ScreenSpaceEventType.RIGHT_CLICK, async () => {
629
+ if (!current.value || !packable.value) return;
630
+ const { defining, sampled } = current.value;
631
+ if (!defining) return;
632
+ packable.value.positions ??= [];
633
+ if (packable.value.positions.length === 0) return;
634
+ packable.value.positions.splice(packable.value.positions.length - 1, 1);
635
+ sampled.setSample(packable.value);
636
+ });
637
+ const definingCursorCss = (0, vue.ref)();
638
+ const setDefiningCursorCss = () => {
639
+ if (!current.value?.defining) {
640
+ if (definingCursorCss.value) {
641
+ definingCursorCss.value = void 0;
642
+ viewer.value.container.parentElement.style.removeProperty("cursor");
643
+ }
644
+ } else {
645
+ const definingCursor = current.value.scheme.definingCursor;
646
+ definingCursorCss.value = (0, vesium.isFunction)(definingCursor) ? definingCursor(packable.value) : definingCursor;
647
+ if (definingCursorCss.value) viewer.value?.container.parentElement.style.setProperty("cursor", definingCursorCss.value);
648
+ }
649
+ };
650
+ (0, vesium.useCesiumEventListener)(() => current.value?.definitionChanged, (plot, key) => {
651
+ if (key === "defining" || key === "sampled") setDefiningCursorCss();
652
+ });
653
+ (0, vue.watch)(current, () => setDefiningCursorCss());
665
654
  }
655
+
656
+ //#endregion
657
+ //#region usePlot/useSkeleton.ts
666
658
  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
- };
659
+ const viewer = (0, vesium.useViewer)();
660
+ const dataSource = (0, vesium.useDataSource)(new cesium.CustomDataSource());
661
+ const entityScope = (0, vesium.useEntityScope)({ collection: () => dataSource.value.entities });
662
+ const hoverEntity = (0, vue.shallowRef)();
663
+ const activeEntity = (0, vue.shallowRef)();
664
+ const getPointAction = (entity) => {
665
+ if (!entity) return PlotAction.IDLE;
666
+ return activeEntity.value?.id === entity.id ? PlotAction.ACTIVE : hoverEntity.value?.id === entity.id ? PlotAction.HOVER : PlotAction.IDLE;
667
+ };
668
+ const update = (plot, destroyed) => {
669
+ const oldEntities = plot.skeletons;
670
+ const entities = [];
671
+ if (destroyed || plot.disabled) plot.skeletons = [];
672
+ else {
673
+ const packable = plot.sampled.getValue(getCurrentTime());
674
+ const defining = plot.defining;
675
+ const active = current.value === plot;
676
+ const skeletons = plot.scheme.skeletons;
677
+ skeletons.forEach((skeleton) => {
678
+ const disabled = (0, vesium.isFunction)(skeleton.disabled) ? skeleton.disabled({
679
+ active,
680
+ defining
681
+ }) : skeleton.disabled;
682
+ if (disabled) return;
683
+ const positions = skeleton.format?.(packable) ?? packable?.positions ?? [];
684
+ positions.forEach((position, index) => {
685
+ let entity = oldEntities.find((item) => item.index === index && item.skeleton === skeleton);
686
+ const options = skeleton.render?.({
687
+ defining,
688
+ active,
689
+ index,
690
+ packable,
691
+ positions,
692
+ position,
693
+ action: getPointAction(entity)
694
+ });
695
+ const merge = new PlotSkeletonEntity(options ?? {});
696
+ if (entity) merge.propertyNames.forEach((key) => {
697
+ if (key !== "id") entity[key] = merge[key];
698
+ });
699
+ else entity = merge;
700
+ entity.plot = plot;
701
+ entity.skeleton = skeleton;
702
+ entity.index = index;
703
+ entities.push(entity);
704
+ });
705
+ });
706
+ }
707
+ plot.skeletons = entities;
708
+ };
709
+ const { addGraphicEvent } = (0, vesium.useGraphicEvent)();
710
+ (0, vue.watchEffect)((onCleanup) => {
711
+ const remove = addGraphicEvent("global", "DRAG", ({ event, pick, dragging, lockCamera }) => {
712
+ if (pick.id instanceof PlotSkeletonEntity && entityScope.scope.has(pick.id)) {
713
+ const entity = pick.id;
714
+ const plot = entity.plot;
715
+ if (plot.defining) return;
716
+ activeEntity.value = entity;
717
+ const skeleton = entity.skeleton;
718
+ const index = entity.index;
719
+ const packable = plot.sampled.getValue(getCurrentTime());
720
+ skeleton.onDrag?.({
721
+ viewer: viewer.value,
722
+ sampled: plot.sampled,
723
+ packable,
724
+ active: current.value === plot,
725
+ index,
726
+ event,
727
+ dragging,
728
+ lockCamera
729
+ });
730
+ } else activeEntity.value = void 0;
731
+ }, {
732
+ cursor: ({ pick }) => {
733
+ if (!current.value?.defining && entityScope.scope.has(pick.id)) {
734
+ const skeleton = pick.id.skeleton;
735
+ return (0, vesium.isFunction)(skeleton?.cursor) ? skeleton.cursor(pick) : (0, vue.toValue)(skeleton?.cursor);
736
+ }
737
+ },
738
+ dragCursor: ({ pick }) => {
739
+ if (!current.value?.defining && entityScope.scope.has(pick.id)) {
740
+ const skeleton = pick.id.skeleton;
741
+ return (0, vesium.isFunction)(skeleton?.dragCursor) ? skeleton.dragCursor(pick) : (0, vue.toValue)(skeleton?.dragCursor);
742
+ }
743
+ }
744
+ });
745
+ onCleanup(remove);
746
+ });
747
+ (0, __vueuse_core.onKeyStroke)((keyEvent) => {
748
+ if (activeEntity.value) {
749
+ const entity = activeEntity.value;
750
+ const plot = entity.plot;
751
+ const skeleton = entity.skeleton;
752
+ const index = entity.index;
753
+ const packable = plot.sampled.getValue(getCurrentTime());
754
+ skeleton.onKeyPressed?.({
755
+ viewer: viewer.value,
756
+ sampled: plot.sampled,
757
+ packable,
758
+ index,
759
+ keyEvent
760
+ });
761
+ }
762
+ });
763
+ (0, vue.watchEffect)((onCleanup) => {
764
+ const remove = addGraphicEvent("global", "HOVER", ({ hovering, pick }) => {
765
+ if (hovering && pick.id instanceof PlotSkeletonEntity && entityScope.scope.has(pick.id)) {
766
+ const entity = pick.id;
767
+ hoverEntity.value = entity;
768
+ } else hoverEntity.value = void 0;
769
+ });
770
+ onCleanup(remove);
771
+ });
772
+ (0, vue.watchEffect)((onCleanup) => {
773
+ const remove = addGraphicEvent("global", "LEFT_CLICK", ({ event, pick }) => {
774
+ if (pick.id instanceof PlotSkeletonEntity && entityScope.scope.has(pick.id)) {
775
+ const entity = pick.id;
776
+ activeEntity.value = entity;
777
+ const plot = entity.plot;
778
+ const skeleton = entity.skeleton;
779
+ const index = entity.index;
780
+ const packable = plot.sampled.getValue(getCurrentTime());
781
+ skeleton.onLeftClick?.({
782
+ viewer: viewer.value,
783
+ sampled: plot.sampled,
784
+ packable,
785
+ active: current.value === plot,
786
+ defining: plot.defining,
787
+ index,
788
+ event
789
+ });
790
+ } else activeEntity.value = void 0;
791
+ });
792
+ onCleanup(remove);
793
+ });
794
+ (0, __vueuse_core.watchArray)(plots, (value, oldValue, added, removed = []) => {
795
+ added.forEach((plot) => update(plot));
796
+ removed.forEach((plot) => update(plot, true));
797
+ });
798
+ (0, vesium.useCesiumEventListener)(() => plots.value.map((plot) => plot.definitionChanged), (plot, key, newValue, oldValue) => {
799
+ if ([
800
+ "disabled",
801
+ "defining",
802
+ "scheme",
803
+ "sampled",
804
+ "time"
805
+ ].includes(key)) (0, vue.nextTick)(() => update(plot));
806
+ else if (key === "skeletons") {
807
+ const { added, removed } = (0, vesium.arrayDiff)(newValue, oldValue);
808
+ added.forEach((item) => entityScope.add(item));
809
+ removed.forEach((item) => entityScope.remove(item));
810
+ }
811
+ });
812
+ (0, vue.watch)(current, (plot, previous) => {
813
+ plot && update(plot);
814
+ previous && update(previous);
815
+ });
816
+ return { dataSource };
848
817
  }
818
+
819
+ //#endregion
820
+ //#region usePlot/usePlot.ts
849
821
  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
- };
822
+ const time = options?.time || (0, vue.shallowRef)();
823
+ const viewer = (0, vesium.useViewer)();
824
+ const getCurrentTime = () => {
825
+ return time.value?.clone() || new cesium.JulianDate(0, 0);
826
+ };
827
+ const collection = (0, vue.shallowReactive)(/* @__PURE__ */ new Set());
828
+ const plots = (0, vue.computed)(() => Array.from(collection));
829
+ const current = (0, vue.shallowRef)();
830
+ const packable = (0, vue.shallowRef)();
831
+ (0, vesium.useCesiumEventListener)([() => current.value?.sampled.definitionChanged], () => {
832
+ packable.value = current.value?.sampled.getValue(getCurrentTime());
833
+ });
834
+ useSampled(current, getCurrentTime);
835
+ useRender(plots, current, getCurrentTime);
836
+ useSkeleton(plots, current, getCurrentTime);
837
+ (0, vesium.useScreenSpaceEventHandler)(cesium.ScreenSpaceEventType.LEFT_CLICK, (data) => {
838
+ if (current.value?.defining) return;
839
+ const pick = viewer.value?.scene.pick(data.position.clone());
840
+ if (pick?.id?.plot instanceof PlotFeature) return;
841
+ if (!pick) {
842
+ current.value = void 0;
843
+ return;
844
+ }
845
+ current.value = plots.value.find((plot) => (0, vesium.pickHitGraphic)(pick, [
846
+ ...plot.entities,
847
+ ...plot.primitives,
848
+ ...plot.groundPrimitives
849
+ ]));
850
+ });
851
+ let operateResolve;
852
+ let operateReject;
853
+ (0, vue.watch)(current, (plot, previous) => {
854
+ if (previous) {
855
+ if (previous.defining) {
856
+ const packable$1 = previous.sampled.getValue(getCurrentTime());
857
+ const completed = previous.scheme.allowManualComplete?.(packable$1);
858
+ if (completed) {
859
+ PlotFeature.setDefining(previous, false);
860
+ operateResolve?.(previous);
861
+ } else collection.delete(previous);
862
+ }
863
+ }
864
+ });
865
+ const operate = async (plot) => {
866
+ return new Promise((resolve, reject) => {
867
+ operateResolve = resolve;
868
+ operateReject = reject;
869
+ const _plot = plot instanceof PlotFeature ? plot : new PlotFeature(plot);
870
+ if (!collection.has(_plot)) collection.add(_plot);
871
+ current.value = _plot;
872
+ return resolve(_plot);
873
+ });
874
+ };
875
+ const remove = (plot) => {
876
+ if (plot === current.value) current.value = void 0;
877
+ if (collection.has(plot)) {
878
+ collection.delete(plot);
879
+ return true;
880
+ }
881
+ return false;
882
+ };
883
+ return {
884
+ plots,
885
+ time,
886
+ operate,
887
+ remove,
888
+ cancel: operateReject
889
+ };
933
890
  }
891
+
892
+ //#endregion
893
+ //#region skeleton/control.ts
894
+ /**
895
+ * 绘制控制的框架点,拖拽时,将更新该控制点的实时位置
896
+ */
934
897
  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
- };
898
+ return {
899
+ disabled: ({ active }) => !active,
900
+ cursor: "pointer",
901
+ dragCursor: "crosshair",
902
+ onDrag({ viewer, sampled, packable, event, index, lockCamera }) {
903
+ lockCamera();
904
+ const position = (0, vesium.canvasCoordToCartesian)(event.endPosition, viewer.scene);
905
+ if (position) {
906
+ const positions = [...packable.positions ?? []];
907
+ positions[index] = position;
908
+ sampled.setSample({
909
+ time: packable.time,
910
+ derivative: packable.derivative,
911
+ positions
912
+ });
913
+ }
914
+ },
915
+ onKeyPressed({ viewer, keyEvent, sampled, packable, index }) {
916
+ const height = (0, vesium.toCartographic)(viewer.camera.position)?.height;
917
+ if (!height || ![
918
+ "ArrowUp",
919
+ "ArrowRight",
920
+ "ArrowDown",
921
+ "ArrowLeft"
922
+ ].includes(keyEvent.key)) return;
923
+ keyEvent.preventDefault();
924
+ let headingAdjust = 0;
925
+ switch (keyEvent.key) {
926
+ case "ArrowRight":
927
+ headingAdjust = Math.PI / 2;
928
+ break;
929
+ case "ArrowDown":
930
+ headingAdjust = Math.PI;
931
+ break;
932
+ case "ArrowLeft":
933
+ headingAdjust = -Math.PI / 2;
934
+ break;
935
+ case "ArrowUp":
936
+ headingAdjust = 0;
937
+ break;
938
+ }
939
+ const newHeading = (viewer.camera.heading + headingAdjust) % (2 * Math.PI);
940
+ const positions = [...packable.positions ?? []];
941
+ const cartographic = (0, vesium.toCartographic)(positions[index]);
942
+ const r = height / 1e5;
943
+ const distance = r * Math.PI / 180 / 1e3;
944
+ cartographic.latitude += distance * Math.cos(newHeading);
945
+ cartographic.longitude += distance * Math.sin(newHeading);
946
+ positions[index] = (0, vesium.toCartesian3)(cartographic);
947
+ sampled.setSample({
948
+ time: packable.time,
949
+ derivative: packable.derivative,
950
+ positions
951
+ });
952
+ },
953
+ render: ({ position, action }) => {
954
+ const colors = {
955
+ [PlotAction.IDLE]: cesium.Color.BLUE.withAlpha(.4),
956
+ [PlotAction.HOVER]: cesium.Color.BLUE.withAlpha(.6),
957
+ [PlotAction.ACTIVE]: cesium.Color.AQUA.withAlpha(1)
958
+ };
959
+ return {
960
+ position,
961
+ point: {
962
+ pixelSize: 8,
963
+ color: colors[action],
964
+ disableDepthTestDistance: Number.POSITIVE_INFINITY,
965
+ outlineWidth: 1,
966
+ outlineColor: cesium.Color.WHITE.withAlpha(.4)
967
+ }
968
+ };
969
+ }
970
+ };
1005
971
  }
972
+
973
+ //#endregion
974
+ //#region skeleton/interval.ts
975
+ /**
976
+ * 绘制封闭的间隔框架点,如多边形。拖拽时,会在两点之间插入一个控制点,并持续拖拽该点。
977
+ */
1006
978
  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
- };
979
+ let dragIndex = -1;
980
+ return {
981
+ disabled: ({ active, defining }) => !active || defining,
982
+ cursor: "pointer",
983
+ dragCursor: "crosshair",
984
+ format(packable) {
985
+ const _positions = packable.positions ?? [];
986
+ if (_positions.length < 2) return [];
987
+ return _positions.map((position, i) => {
988
+ const next = i === _positions.length - 1 ? _positions[0] : _positions[i + 1];
989
+ return cesium.Cartesian3.midpoint(position, next, new cesium.Cartesian3());
990
+ });
991
+ },
992
+ onDrag({ viewer, sampled, packable, event, index, lockCamera, dragging }) {
993
+ lockCamera();
994
+ const position = (0, vesium.canvasCoordToCartesian)(event.endPosition, viewer.scene);
995
+ if (!position) return;
996
+ const positions = [...packable.positions ?? []];
997
+ if (dragIndex === -1) {
998
+ dragIndex = index;
999
+ positions.splice(index + 1, 0, position);
1000
+ } else positions[dragIndex + 1] = position;
1001
+ if (!dragging) dragIndex = -1;
1002
+ sampled.setSample({
1003
+ time: packable.time,
1004
+ derivative: packable.derivative,
1005
+ positions
1006
+ });
1007
+ },
1008
+ render: ({ position, action, active }) => {
1009
+ if (!active) return;
1010
+ const colors = {
1011
+ [PlotAction.IDLE]: cesium.Color.GREEN.withAlpha(.4),
1012
+ [PlotAction.HOVER]: cesium.Color.GREEN.withAlpha(.6),
1013
+ [PlotAction.ACTIVE]: cesium.Color.GREEN.withAlpha(1)
1014
+ };
1015
+ return {
1016
+ position,
1017
+ point: {
1018
+ pixelSize: 6,
1019
+ color: colors[action],
1020
+ disableDepthTestDistance: Number.POSITIVE_INFINITY,
1021
+ outlineWidth: 1,
1022
+ outlineColor: cesium.Color.WHITE.withAlpha(.4)
1023
+ }
1024
+ };
1025
+ }
1026
+ };
1065
1027
  }
1028
+
1029
+ //#endregion
1030
+ //#region skeleton/intervalNonclosed.ts
1031
+ /**
1032
+ * 绘制非封闭的间隔框架点,如线段。拖拽时,会在两点之间插入一个控制点,并持续拖拽该点。
1033
+ */
1066
1034
  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
- };
1035
+ let dragIndex = -1;
1036
+ return {
1037
+ disabled: ({ active, defining }) => !active || defining,
1038
+ cursor: "pointer",
1039
+ dragCursor: "crosshair",
1040
+ format(packable) {
1041
+ const _positions = packable.positions ?? [];
1042
+ if (_positions.length < 2) return [];
1043
+ const midpoints = [];
1044
+ for (let i = 0; i < _positions.length - 1; i++) midpoints.push(cesium.Cartesian3.midpoint(_positions[i], _positions[i + 1], new cesium.Cartesian3()));
1045
+ return midpoints;
1046
+ },
1047
+ onDrag({ viewer, sampled, packable, event, index, lockCamera, dragging }) {
1048
+ lockCamera();
1049
+ const position = (0, vesium.canvasCoordToCartesian)(event.endPosition, viewer.scene);
1050
+ if (!position) return;
1051
+ const positions = [...packable.positions ?? []];
1052
+ if (dragIndex === -1) {
1053
+ dragIndex = index;
1054
+ positions.splice(index + 1, 0, position);
1055
+ } else positions[dragIndex + 1] = position;
1056
+ if (!dragging) dragIndex = -1;
1057
+ sampled.setSample({
1058
+ time: packable.time,
1059
+ derivative: packable.derivative,
1060
+ positions
1061
+ });
1062
+ },
1063
+ render: ({ position, action }) => {
1064
+ const colors = {
1065
+ [PlotAction.IDLE]: cesium.Color.GREEN.withAlpha(.4),
1066
+ [PlotAction.HOVER]: cesium.Color.GREEN.withAlpha(.6),
1067
+ [PlotAction.ACTIVE]: cesium.Color.GREEN.withAlpha(1)
1068
+ };
1069
+ return {
1070
+ position,
1071
+ point: {
1072
+ pixelSize: 6,
1073
+ color: colors[action],
1074
+ disableDepthTestDistance: Number.POSITIVE_INFINITY,
1075
+ outlineWidth: 1,
1076
+ outlineColor: cesium.Color.WHITE.withAlpha(.4)
1077
+ }
1078
+ };
1079
+ }
1080
+ };
1123
1081
  }
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
- )}`;
1082
+
1083
+ //#endregion
1084
+ //#region skeleton/moved.ts
1085
+ 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>")}`;
1086
+ /**
1087
+ * 绘制非封闭的间隔框架点,如线段。拖拽时,会在两点之间插入一个控制点,并持续拖拽该点。
1088
+ */
1127
1089
  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
- };
1090
+ return {
1091
+ disabled: ({ active, defining }) => !active || defining,
1092
+ cursor: "pointer",
1093
+ dragCursor: "crosshair",
1094
+ format(packable) {
1095
+ const positions = packable.positions ?? [];
1096
+ if (positions.length === 0) return [];
1097
+ else if (positions.length === 1) return [positions[0]];
1098
+ else {
1099
+ const center = cesium.Rectangle.center(cesium.Rectangle.fromCartesianArray(positions));
1100
+ return [(0, vesium.toCartesian3)(center)];
1101
+ }
1102
+ },
1103
+ onDrag({ viewer, sampled, packable, event, lockCamera, dragging }) {
1104
+ dragging && lockCamera();
1105
+ const startPosition = (0, vesium.canvasCoordToCartesian)(event.startPosition, viewer.scene);
1106
+ const endPosition = (0, vesium.canvasCoordToCartesian)(event.endPosition, viewer.scene);
1107
+ if (!startPosition || !endPosition) return;
1108
+ const offset = cesium.Cartesian3.subtract(endPosition, startPosition, new cesium.Cartesian3());
1109
+ const positions = [...packable.positions ?? []];
1110
+ sampled.setSample({
1111
+ time: packable.time,
1112
+ derivative: packable.derivative,
1113
+ positions: positions.map((position) => cesium.Cartesian3.add(position, offset, new cesium.Cartesian3()))
1114
+ });
1115
+ },
1116
+ render: ({ position, action }) => {
1117
+ const colors = {
1118
+ [PlotAction.IDLE]: cesium.Color.WHITE,
1119
+ [PlotAction.HOVER]: cesium.Color.WHITE,
1120
+ [PlotAction.ACTIVE]: cesium.Color.AQUA.withAlpha(1)
1121
+ };
1122
+ return {
1123
+ position,
1124
+ billboard: {
1125
+ image: svg,
1126
+ width: 20,
1127
+ height: 20,
1128
+ color: colors[action],
1129
+ pixelOffset: new cesium.Cartesian3(0, -20),
1130
+ horizontalOrigin: cesium.HorizontalOrigin.CENTER,
1131
+ verticalOrigin: cesium.VerticalOrigin.BOTTOM,
1132
+ disableDepthTestDistance: Number.POSITIVE_INFINITY
1133
+ }
1134
+ };
1135
+ }
1136
+ };
1179
1137
  }
1138
+
1139
+ //#endregion
1140
+ //#region measure/utils/tesselate.ts
1141
+ /**
1142
+ * 将多个边界点组成的面切割成多个三角形
1143
+ * @param positions
1144
+ */
1180
1145
  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;
1146
+ if (positions.length < 3) throw new Error("positions must >= 3");
1147
+ if (positions.length === 3) return [[
1148
+ positions[0].clone(),
1149
+ positions[1].clone(),
1150
+ positions[2].clone()
1151
+ ]];
1152
+ const geometry = cesium.CoplanarPolygonGeometry.createGeometry(cesium.CoplanarPolygonGeometry.fromPositions({
1153
+ positions,
1154
+ vertexFormat: cesium.VertexFormat.POSITION_ONLY
1155
+ }));
1156
+ if (!geometry) throw new Error("positions无法组成有效的geometry,检查点位是否错误");
1157
+ const values = geometry.attributes.position.values;
1158
+ const indices = geometry.indices;
1159
+ const result = [];
1160
+ for (let i = 0; i < indices.length; i += 3) {
1161
+ const a = cesium.Cartesian3.unpack(values, indices[i] * 3, new cesium.Cartesian3());
1162
+ const b = cesium.Cartesian3.unpack(values, indices[i + 1] * 3, new cesium.Cartesian3());
1163
+ const c = cesium.Cartesian3.unpack(values, indices[i + 2] * 3, new cesium.Cartesian3());
1164
+ result.push([
1165
+ a,
1166
+ b,
1167
+ c
1168
+ ]);
1169
+ }
1170
+ return result;
1206
1171
  }
1172
+
1173
+ //#endregion
1174
+ //#region measure/utils/clampToGround.ts
1175
+ /**
1176
+ * 将传入的点位列表进行贴地处理,若某个点位获取高程失败则将此进行克隆返回
1177
+ * @param options - 配置项
1178
+ */
1179
+ async function clampToHeightMostDetailedByTilesetOrTerrain(options) {
1180
+ const { positions, scene, classificationType = cesium.ClassificationType.BOTH, terrainProvider = scene.terrainProvider } = options;
1181
+ const tileset = [cesium.ClassificationType.BOTH, cesium.ClassificationType.CESIUM_3D_TILE].includes(classificationType);
1182
+ const terrain = [cesium.ClassificationType.BOTH, cesium.ClassificationType.TERRAIN].includes(classificationType);
1183
+ const tilesetPromise = new Promise((resolve) => {
1184
+ if (tileset) scene.clampToHeightMostDetailed(positions.map((e) => e.clone())).then(resolve).catch((error) => {
1185
+ console.warn(error);
1186
+ resolve([]);
1187
+ });
1188
+ else resolve([]);
1189
+ });
1190
+ const terrainPromise = new Promise((resolve) => {
1191
+ if (terrain && terrainProvider) (0, cesium.sampleTerrainMostDetailed)(terrainProvider, positions.map((e) => cesium.Cartographic.fromCartesian(e))).then((e) => resolve(e)).catch((error) => {
1192
+ console.warn(error);
1193
+ resolve([]);
1194
+ });
1195
+ else resolve([]);
1196
+ });
1197
+ const [tilesetPositions, terrainPositions] = await Promise.all([tilesetPromise, terrainPromise]);
1198
+ const resluts = [];
1199
+ positions.forEach((item, index) => {
1200
+ const position = tilesetPositions[index] || terrainPositions[index] ? cesium.Ellipsoid.WGS84.cartographicToCartesian(terrainPositions[index]) : item.clone();
1201
+ resluts.push(position);
1202
+ });
1203
+ return resluts;
1204
+ }
1205
+
1206
+ //#endregion
1207
+ //#region measure/utils/triangleGrid.ts
1208
+ function defaultOptions$1(original) {
1209
+ const clampToGround = original?.clampToGround ?? false;
1210
+ const classificationType = original?.classificationType ?? cesium.ClassificationType.BOTH;
1211
+ const density = Math.floor(original?.density ?? 10);
1212
+ return {
1213
+ scene: original?.scene,
1214
+ clampToGround,
1215
+ classificationType,
1216
+ terrainProvider: original?.terrainProvider,
1217
+ density
1218
+ };
1219
+ }
1220
+ /**
1221
+ * 生成三角网数组
1222
+ * @param positions - 边界点数组
1223
+ * @param options - 配置项
1224
+ */
1225
+ async function triangleGrid(positions, options) {
1226
+ if (positions.length < 3) throw new Error("positions must >= 3");
1227
+ const { density, scene, clampToGround, classificationType, terrainProvider } = defaultOptions$1(options);
1228
+ if (density <= 0) throw new Error("options.density must > 0");
1229
+ const bbox = cesium.Rectangle.fromCartesianArray(positions);
1230
+ const vertical = bbox.north - bbox.south;
1231
+ const horizontal = bbox.east - bbox.west;
1232
+ const max = Math.max(horizontal, vertical);
1233
+ const granularity = max / density;
1234
+ const polygonGeometry = cesium.PolygonGeometry.fromPositions({
1235
+ positions,
1236
+ vertexFormat: cesium.PerInstanceColorAppearance.FLAT_VERTEX_FORMAT,
1237
+ granularity
1238
+ });
1239
+ const geometry = cesium.PolygonGeometry.createGeometry(polygonGeometry);
1240
+ const values = geometry.attributes.position.values;
1241
+ if (!geometry || !values) throw new Error("positions无法组成有效的geometry,检查点位是否错误");
1242
+ const indices = geometry.indices;
1243
+ let cartesian3List = [];
1244
+ for (let i = 0; i < indices.length; i += 3) {
1245
+ const a = cesium.Cartesian3.unpack(values, indices[i] * 3, new cesium.Cartesian3());
1246
+ const b = cesium.Cartesian3.unpack(values, indices[i + 1] * 3, new cesium.Cartesian3());
1247
+ const c = cesium.Cartesian3.unpack(values, indices[i + 2] * 3, new cesium.Cartesian3());
1248
+ cartesian3List.push(a, b, c);
1249
+ }
1250
+ if (clampToGround) {
1251
+ if (!scene) throw new Error("scene is required on `clampToGround == true`.");
1252
+ const detaileds = await clampToHeightMostDetailedByTilesetOrTerrain({
1253
+ scene,
1254
+ terrainProvider,
1255
+ positions: cartesian3List,
1256
+ classificationType
1257
+ });
1258
+ cartesian3List = detaileds;
1259
+ }
1260
+ const grid = [];
1261
+ while (cartesian3List?.length) {
1262
+ const [a, b, c] = cartesian3List.splice(0, 3);
1263
+ grid.push([
1264
+ a,
1265
+ b,
1266
+ c
1267
+ ]);
1268
+ }
1269
+ return grid;
1270
+ }
1271
+
1272
+ //#endregion
1273
+ //#region measure/utils/area.ts
1274
+ /**
1275
+ * 计算三维坐标系下三角形面积
1276
+ * @param p0 - 三角形第一个点
1277
+ * @param p1 - 三角形第二个点
1278
+ * @param p2 - 三角形第三个点
1279
+ */
1207
1280
  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;
1281
+ const v0 = cesium.Cartesian3.subtract(p0, p1, new cesium.Cartesian3());
1282
+ const v1 = cesium.Cartesian3.subtract(p2, p1, new cesium.Cartesian3());
1283
+ const cross = cesium.Cartesian3.cross(v0, v1, v0);
1284
+ return cesium.Cartesian3.magnitude(cross) * .5;
1212
1285
  }
1213
1286
  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
- };
1287
+ const clampToGround = original?.clampToGround ?? false;
1288
+ const classificationType = original?.classificationType ?? cesium.ClassificationType.BOTH;
1289
+ const density = Math.floor(original?.density ?? 10);
1290
+ return {
1291
+ scene: original?.scene,
1292
+ clampToGround,
1293
+ classificationType,
1294
+ terrainProvider: original?.terrainProvider,
1295
+ density
1296
+ };
1224
1297
  }
1298
+ /**
1299
+ * 计算三维坐标系下图形面积
1300
+ * @param positions - 图形各点的笛卡尔数组
1301
+ */
1225
1302
  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
- }
1303
+ if (positions.length < 2) throw new Error("positions.length must >= 2");
1304
+ const { density, scene, clampToGround, classificationType, terrainProvider } = defaultOptions(options);
1305
+ if (density <= 0) throw new Error("options.density must > 0");
1306
+ if (!clampToGround) {
1307
+ const triangles$1 = tesselate(positions);
1308
+ return triangles$1.reduce((count, current) => count += triangleArea(...current), 0);
1309
+ }
1310
+ const triangles = await triangleGrid(positions, {
1311
+ density,
1312
+ scene,
1313
+ clampToGround,
1314
+ classificationType,
1315
+ terrainProvider
1316
+ });
1317
+ return triangles.reduce((count, current) => count += triangleArea(...current), 0);
1237
1318
  }
1319
+
1320
+ //#endregion
1321
+ //#region measure/measureArea.ts
1238
1322
  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
- }
1323
+ type: "measureArea",
1324
+ allowManualComplete: (packable) => packable.positions.length >= 3,
1325
+ skeletons: [control, interval],
1326
+ initEntites: () => [new cesium.Entity({
1327
+ label: { font: "14pt" },
1328
+ polyline: { material: cesium.Color.YELLOW.withAlpha(.5) },
1329
+ polygon: { material: cesium.Color.YELLOW.withAlpha(.5) }
1330
+ })],
1331
+ render(options) {
1332
+ const { mouse, packable } = options;
1333
+ const entity = options.previous.entities?.[0] ?? new cesium.Entity({
1334
+ label: { font: "14pt" },
1335
+ polyline: { material: cesium.Color.YELLOW.withAlpha(.5) },
1336
+ polygon: { material: cesium.Color.YELLOW.withAlpha(.5) }
1337
+ });
1338
+ const positions = [...packable.positions ?? []];
1339
+ mouse && positions.push(mouse);
1340
+ if (positions.length === 2) {
1341
+ entity.position = void 0;
1342
+ entity.label.text = void 0;
1343
+ entity.polygon.hierarchy = void 0;
1344
+ entity.polyline.positions = new cesium.CallbackProperty(() => positions, false);
1345
+ } else if (positions.length >= 3) {
1346
+ positions.push(positions[0]);
1347
+ entity.position = new cesium.ConstantPositionProperty((0, vesium.toCartesian3)(cesium.Rectangle.center(cesium.Rectangle.fromCartesianArray(positions))));
1348
+ entity.label.text = new cesium.ConstantProperty("");
1349
+ area(positions).then((e) => {
1350
+ let text = "";
1351
+ if (e / 1e3 / 1e3 > 10) text = `${(e / 1e3 / 1e3).toFixed(2)}km²`;
1352
+ else text = `${(+e).toFixed(2)}m²`;
1353
+ entity.label.text = new cesium.ConstantProperty(text);
1354
+ });
1355
+ entity.polyline.positions = void 0;
1356
+ entity.polygon.hierarchy = new cesium.CallbackProperty(() => {
1357
+ return positions.length >= 3 ? new cesium.PolygonHierarchy([...positions]) : void 0;
1358
+ }, false);
1359
+ } else {
1360
+ entity.position = void 0;
1361
+ entity.polygon.hierarchy = void 0;
1362
+ entity.polyline.positions = void 0;
1363
+ }
1364
+ return { entities: [entity] };
1365
+ }
1309
1366
  });
1367
+
1368
+ //#endregion
1369
+ //#region scheme/billboard.ts
1370
+ /**
1371
+ * 广告牌标绘方案
1372
+ */
1310
1373
  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
- }
1374
+ type: "billboard",
1375
+ complete: (packable) => packable.positions.length >= 1,
1376
+ skeletons: [moved],
1377
+ initEntites: () => [new cesium.Entity({ billboard: {
1378
+ image: "/favicon.svg",
1379
+ width: 32,
1380
+ height: 32
1381
+ } })],
1382
+ render(options) {
1383
+ const { mouse, packable } = options;
1384
+ const entity = options.previous.entities?.[0] ?? new cesium.Entity({ billboard: {} });
1385
+ const position = packable.positions?.[0] ?? mouse;
1386
+ entity.position = new cesium.CallbackPositionProperty(() => position, true);
1387
+ return { entities: [entity] };
1388
+ }
1329
1389
  });
1390
+
1391
+ //#endregion
1392
+ //#region scheme/label.ts
1393
+ /**
1394
+ * 标签文字标绘方案
1395
+ */
1330
1396
  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
- }
1397
+ type: "label",
1398
+ complete: (packable) => packable.positions.length >= 1,
1399
+ skeletons: [moved],
1400
+ initEntites: () => [new cesium.Entity({ label: { text: "Label" } })],
1401
+ render(options) {
1402
+ const { mouse, packable } = options;
1403
+ const entity = options.previous.entities?.[0] ?? new cesium.Entity({ label: {} });
1404
+ const position = packable.positions?.[0] ?? mouse;
1405
+ entity.position = new cesium.CallbackPositionProperty(() => position, true);
1406
+ return { entities: [entity] };
1407
+ }
1349
1408
  });
1409
+
1410
+ //#endregion
1411
+ //#region scheme/polygon.ts
1412
+ /**
1413
+ * 内置的多边形标绘方案
1414
+ */
1350
1415
  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
- }
1416
+ type: "polygon",
1417
+ allowManualComplete: (packable) => packable.positions.length >= 3,
1418
+ skeletons: [
1419
+ control,
1420
+ interval,
1421
+ moved
1422
+ ],
1423
+ initEntites: () => [new cesium.Entity({
1424
+ polyline: { material: cesium.Color.YELLOW.withAlpha(.5) },
1425
+ polygon: { material: cesium.Color.YELLOW.withAlpha(.5) }
1426
+ })],
1427
+ render(options) {
1428
+ const { mouse, packable } = options;
1429
+ const entity = options.previous.entities?.[0] ?? new cesium.Entity({
1430
+ polyline: { material: cesium.Color.YELLOW.withAlpha(.5) },
1431
+ polygon: { material: cesium.Color.YELLOW.withAlpha(.5) }
1432
+ });
1433
+ const positions = [...packable.positions ?? []];
1434
+ mouse && positions.push(mouse);
1435
+ if (positions.length === 2) {
1436
+ entity.polygon.hierarchy = void 0;
1437
+ entity.polyline.positions = new cesium.CallbackProperty(() => positions, false);
1438
+ } else if (positions.length >= 3) {
1439
+ entity.polyline.positions = void 0;
1440
+ entity.polygon.hierarchy = new cesium.CallbackProperty(() => {
1441
+ positions.push(positions[0]);
1442
+ return positions.length >= 3 ? new cesium.PolygonHierarchy([...positions]) : void 0;
1443
+ }, false);
1444
+ } else {
1445
+ entity.polygon.hierarchy = void 0;
1446
+ entity.polyline.positions = void 0;
1447
+ }
1448
+ return { entities: [entity] };
1449
+ }
1450
+ });
1451
+
1452
+ //#endregion
1453
+ //#region scheme/polyline.ts
1454
+ /**
1455
+ * 内置的线段标绘方案
1456
+ */
1457
+ const schemePolyline = new PlotScheme({
1458
+ type: "polyline",
1459
+ allowManualComplete: (packable) => packable.positions.length >= 2,
1460
+ skeletons: [
1461
+ control,
1462
+ intervalNonclosed,
1463
+ moved
1464
+ ],
1465
+ initEntites: () => [new cesium.Entity({ polyline: { width: 1 } })],
1466
+ render(options) {
1467
+ const { mouse, packable } = options;
1468
+ const entity = options.previous.entities?.[0] ?? new cesium.Entity({ polyline: {} });
1469
+ entity.polyline.positions = new cesium.CallbackProperty(() => {
1470
+ const positions = [...packable.positions ?? []].concat(mouse ? [mouse] : []);
1471
+ return positions.length >= 2 ? positions : [];
1472
+ }, false);
1473
+ return { entities: [entity] };
1474
+ }
1398
1475
  });
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
- );
1476
+
1477
+ //#endregion
1478
+ //#region scheme/rectangle.ts
1479
+ /**
1480
+ * 内置的多边形标绘方案
1481
+ */
1425
1482
  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
- }
1483
+ type: "rectangle",
1484
+ complete: (packable) => packable.positions.length >= 2,
1485
+ skeletons: [
1486
+ control,
1487
+ interval,
1488
+ moved
1489
+ ],
1490
+ initEntites: () => [new cesium.Entity({ rectangle: { material: cesium.Color.YELLOW.withAlpha(.5) } })],
1491
+ render(options) {
1492
+ const { mouse, packable } = options;
1493
+ const entity = options.previous.entities?.[0] ?? new cesium.Entity({ rectangle: { material: cesium.Color.YELLOW.withAlpha(.5) } });
1494
+ const positions = [...packable.positions ?? []];
1495
+ mouse && positions.push(mouse);
1496
+ if (positions.length >= 2) entity.rectangle.coordinates = new cesium.CallbackProperty(() => cesium.Rectangle.fromCartesianArray(positions), false);
1497
+ else entity.rectangle.coordinates = void 0;
1498
+ return { entities: [entity] };
1499
+ }
1459
1500
  });
1501
+
1502
+ //#endregion
1460
1503
  exports.PlotAction = PlotAction;
1461
1504
  exports.PlotFeature = PlotFeature;
1462
1505
  exports.PlotScheme = PlotScheme;
@@ -1474,4 +1517,4 @@ exports.schemePolygon = schemePolygon;
1474
1517
  exports.schemePolyline = schemePolyline;
1475
1518
  exports.schemeRectangle = schemeRectangle;
1476
1519
  exports.usePlot = usePlot;
1477
- //# sourceMappingURL=index.cjs.map
1520
+ //# sourceMappingURL=index.cjs.map