@vesium/plot 1.0.1-beta.48 → 1.0.1-beta.49

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.mjs CHANGED
@@ -7,30 +7,49 @@ import { assert, watchArray, promiseTimeout, onKeyStroke } from "@vueuse/core";
7
7
  import { shallowRef, watch, computed, ref, watchEffect, toValue, nextTick, shallowReactive } from "vue";
8
8
  const _PlotScheme = class _PlotScheme {
9
9
  constructor(options) {
10
+ /**
11
+ * 标绘类型。应当是全局唯一的字符串,会作为键名缓存
12
+ */
10
13
  __publicField(this, "type");
11
14
  /**
12
- * 是否立即执行完成标绘操作
13
- *
14
- * 每次控制点发生变变化时,执行该回调函数,如果返回`true`则标绘完成
15
+ * 判断是否立即完成标绘.
16
+ * 每次控制点发生变变化时,执行该回调函数,返回`true`则完成标绘
15
17
  */
16
18
  __publicField(this, "complete");
17
19
  /**
18
- * 双击时,是否执行完成标绘操作
20
+ * 判断是否允许手动完成标绘。
21
+ * 每次控制点发生变变化时,执行该回调函数,返回`true`则后续左键双击即完成标绘
19
22
  */
20
- __publicField(this, "forceComplete");
23
+ __publicField(this, "allowManualComplete");
21
24
  /**
25
+ * 处于定义态时鼠标的样式
22
26
  * @default 'crosshair'
23
27
  */
24
28
  __publicField(this, "definingCursor");
29
+ /**
30
+ * 当前标绘的框架点数据
31
+ */
25
32
  __publicField(this, "skeletons");
33
+ /**
34
+ * 初始化时创建`Entity`的函数,创建后的`Entity`会作为配置项传入`render`中
35
+ */
26
36
  __publicField(this, "initEntites");
37
+ /**
38
+ * 初始化时创建`Primitive`的函数,创建后的`Primitive`会作为配置项传入`render`中
39
+ */
27
40
  __publicField(this, "initPrimitives");
41
+ /**
42
+ * 初始化时创建贴地`Primitive`的函数,创建后的`Primitive`会作为配置项传入`render`中
43
+ */
28
44
  __publicField(this, "initGroundPrimitives");
45
+ /**
46
+ * 当标绘数据变化时,会触发`render`回调,返回的数据会被添加到cesium中
47
+ */
29
48
  __publicField(this, "render");
30
49
  var _a;
31
50
  this.type = options.type;
32
51
  this.complete = options.complete;
33
- this.forceComplete = options.forceComplete;
52
+ this.allowManualComplete = options.allowManualComplete;
34
53
  this.definingCursor = options.definingCursor ?? "crosshair";
35
54
  this.skeletons = ((_a = options.skeletons) == null ? void 0 : _a.map((item) => item())) ?? [];
36
55
  this.initEntites = options.initEntites;
@@ -38,16 +57,31 @@ const _PlotScheme = class _PlotScheme {
38
57
  this.initGroundPrimitives = options.initGroundPrimitives;
39
58
  this.render = options.render;
40
59
  }
60
+ /**
61
+ * 标绘方案缓存。
62
+ * 每次标绘时都会将`PlotScheme.type`作为键名缓存,
63
+ * 后续可用过`PlotScheme.getCache(type)`获取完整的`PlotScheme`配置。
64
+ */
41
65
  static getCacheTypes() {
42
66
  return [...this._record.keys()];
43
67
  }
68
+ /**
69
+ * 通过`PlotScheme.type`获取缓存中的`PlotScheme`配置。
70
+ */
44
71
  static getCache(type) {
45
72
  return _PlotScheme._record.get(type);
46
73
  }
74
+ /**
75
+ * 缓存标绘方案。
76
+ */
47
77
  static setCache(scheme) {
48
78
  assertError(!scheme.type, "`scheme.type` is required");
49
79
  _PlotScheme._record.set(scheme.type, scheme);
50
80
  }
81
+ /**
82
+ * 解析传入的maybeScheme,maybeScheme可能是一个完整的PlotScheme,也可能是缓存中的`PlotScheme.type`,并返回 PlotScheme 实例。
83
+ * 若传入的是`PlotScheme.type`字符串,并且缓存中不存在该标绘方案,则抛出错误。
84
+ */
51
85
  static resolve(maybeScheme) {
52
86
  if (typeof maybeScheme === "string") {
53
87
  const _scheme = _PlotScheme.getCache(maybeScheme);
@@ -227,8 +261,7 @@ const _SampledPlotProperty = class _SampledPlotProperty {
227
261
  return result;
228
262
  }
229
263
  /**
230
- * 设置样本数据
231
- *
264
+ * 设置样本数据,如果传入的数据不含时间,则会存入时间最早的集合中
232
265
  * @param value 样本数据对象,包含时间、位置和导数信息
233
266
  */
234
267
  setSample(value) {
@@ -294,6 +327,9 @@ const _SampledPlotProperty = class _SampledPlotProperty {
294
327
  TimeInterval.contains(interval2, time) && this.removeSample(time);
295
328
  }
296
329
  }
330
+ /**
331
+ * 判断两个property是否相等
332
+ */
297
333
  equals(other) {
298
334
  return other === this;
299
335
  }
@@ -318,6 +354,9 @@ class PlotFeature {
318
354
  * @internal
319
355
  */
320
356
  __publicField(this, "_defining");
357
+ /**
358
+ * @internal
359
+ */
321
360
  __publicField(this, "_disabled");
322
361
  /**
323
362
  * @internal
@@ -374,6 +413,12 @@ class PlotFeature {
374
413
  plot._defining = value;
375
414
  }
376
415
  }
416
+ /**
417
+ * 获取禁用状态
418
+ *
419
+ * 当为 `true` 时,标绘实例将停止响应交互和更新;
420
+ * 为 `false` 时恢复正常功能。
421
+ */
377
422
  get disabled() {
378
423
  return this._disabled;
379
424
  }
@@ -421,64 +466,6 @@ class PlotFeature {
421
466
  this._skeletons = value;
422
467
  }
423
468
  }
424
- class PlotFeatureCollection {
425
- constructor(options = {}) {
426
- /**
427
- * @internal
428
- */
429
- __publicField(this, "_id");
430
- /**
431
- * @internal
432
- */
433
- __publicField(this, "_isDestroyed");
434
- const { id } = options;
435
- this._id = id || createGuid();
436
- this._isDestroyed = false;
437
- }
438
- get id() {
439
- return this._id;
440
- }
441
- get collectionChanged() {
442
- return this._collectionChanged;
443
- }
444
- get values() {
445
- return Array.from(this._values);
446
- }
447
- add(value) {
448
- if (this._isDestroyed) {
449
- throw new Error(`PlotFeatureCollection is isDestroyed`);
450
- }
451
- return this._values.has(value) ? false : !!this._values.add(value);
452
- }
453
- remove(value) {
454
- return this._values.delete(value);
455
- }
456
- get entities() {
457
- return this._dataSource.entities;
458
- }
459
- get primitives() {
460
- return this._primitives;
461
- }
462
- get groundPrimitives() {
463
- return this._groundPrimitives;
464
- }
465
- get skeletons() {
466
- return this._skeletonDataSource.entities;
467
- }
468
- isDestroyed() {
469
- return this._isDestroyed;
470
- }
471
- destroy() {
472
- if (!this._isDestroyed) {
473
- this._viewer.dataSources.remove(this._dataSource);
474
- this._viewer.dataSources.remove(this._skeletonDataSource);
475
- this._viewer.scene.primitives.remove(this._primitives);
476
- this._viewer.scene.groundPrimitives.remove(this._groundPrimitives);
477
- this._viewer.dataSources.remove(this._skeletonDataSource);
478
- this._isDestroyed = true;
479
- }
480
- }
481
- }
482
469
  var PlotAction = /* @__PURE__ */ ((PlotAction2) => {
483
470
  PlotAction2[PlotAction2["IDLE"] = 0] = "IDLE";
484
471
  PlotAction2[PlotAction2["HOVER"] = 1] = "HOVER";
@@ -625,7 +612,7 @@ function useSampled(current, getCurrentTime) {
625
612
  if (!position) {
626
613
  return;
627
614
  }
628
- const completed = (_a = scheme.forceComplete) == null ? void 0 : _a.call(scheme, packable.value);
615
+ const completed = (_a = scheme.allowManualComplete) == null ? void 0 : _a.call(scheme, packable.value);
629
616
  completed && PlotFeature.setDefining(current.value, false);
630
617
  }
631
618
  );
@@ -902,7 +889,7 @@ function usePlot(options) {
902
889
  if (previous) {
903
890
  if (previous.defining) {
904
891
  const packable2 = previous.sampled.getValue(getCurrentTime());
905
- const completed = (_b = (_a = previous.scheme).forceComplete) == null ? void 0 : _b.call(_a, packable2);
892
+ const completed = (_b = (_a = previous.scheme).allowManualComplete) == null ? void 0 : _b.call(_a, packable2);
906
893
  if (completed) {
907
894
  PlotFeature.setDefining(previous, false);
908
895
  operateResolve == null ? void 0 : operateResolve(previous);
@@ -1248,7 +1235,7 @@ async function area(positions, options) {
1248
1235
  }
1249
1236
  const schemeMeasureArea = new PlotScheme({
1250
1237
  type: "measureArea",
1251
- forceComplete: (packable) => packable.positions.length >= 3,
1238
+ allowManualComplete: (packable) => packable.positions.length >= 3,
1252
1239
  skeletons: [
1253
1240
  control,
1254
1241
  interval
@@ -1360,7 +1347,7 @@ const schemeLabel = new PlotScheme({
1360
1347
  });
1361
1348
  const schemePolygon = new PlotScheme({
1362
1349
  type: "polygon",
1363
- forceComplete: (packable) => packable.positions.length >= 3,
1350
+ allowManualComplete: (packable) => packable.positions.length >= 3,
1364
1351
  skeletons: [
1365
1352
  control,
1366
1353
  interval,
@@ -1410,7 +1397,7 @@ const schemePolygon = new PlotScheme({
1410
1397
  const schemePolyline = new PlotScheme(
1411
1398
  {
1412
1399
  type: "polyline",
1413
- forceComplete: (packable) => packable.positions.length >= 2,
1400
+ allowManualComplete: (packable) => packable.positions.length >= 2,
1414
1401
  skeletons: [
1415
1402
  control,
1416
1403
  intervalNonclosed,
@@ -1471,7 +1458,6 @@ const schemeRectangle = new PlotScheme({
1471
1458
  export {
1472
1459
  PlotAction,
1473
1460
  PlotFeature,
1474
- PlotFeatureCollection,
1475
1461
  PlotScheme,
1476
1462
  PlotSkeletonEntity,
1477
1463
  SampledPlotProperty,