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