@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.d.ts CHANGED
@@ -2,12 +2,10 @@ import { Cartesian3 } from 'cesium';
2
2
  import { ComputedRef } from 'vue';
3
3
  import { CSSProperties } from 'vue';
4
4
  import { Entity } from 'cesium';
5
- import { EntityCollection } from 'cesium';
6
5
  import { Event as Event_2 } from 'cesium';
7
6
  import { JulianDate } from 'cesium';
8
7
  import { MaybeRef } from 'vue';
9
8
  import { Nullable } from 'vesium';
10
- import { PrimitiveCollection } from 'cesium';
11
9
  import { Property } from 'cesium';
12
10
  import { ScreenSpaceEventHandler } from 'cesium';
13
11
  import { ShallowRef } from 'vue';
@@ -127,21 +125,23 @@ export declare enum PlotAction {
127
125
  ACTIVE = 2
128
126
  }
129
127
 
130
- export declare type PlotCollectionChanged = (scope: PlotFeatureCollection, added: PlotFeature[], removed: PlotFeature[]) => void;
131
-
132
- export declare interface PlotCollectionConstructorOptions {
133
- id?: string;
134
- }
135
-
136
128
  export declare type PlotDefinitionChangedCallback = (scope: PlotFeature, key: keyof PlotFeature, newValue: PlotFeature[typeof key], oldValue: PlotFeature[typeof key]) => void;
137
129
 
130
+ /**
131
+ * 标绘实例
132
+ */
138
133
  export declare class PlotFeature {
139
134
  constructor(options: PlotFeatureConstructorOptions);
140
135
  get id(): string;
141
136
  get scheme(): PlotScheme;
142
137
  get definitionChanged(): Event_2<PlotDefinitionChangedCallback>;
143
138
  get defining(): boolean;
144
- private _disabled;
139
+ /**
140
+ * 获取禁用状态
141
+ *
142
+ * 当为 `true` 时,标绘实例将停止响应交互和更新;
143
+ * 为 `false` 时恢复正常功能。
144
+ */
145
145
  get disabled(): boolean;
146
146
  set disabled(value: string);
147
147
  get sampled(): SampledPlotProperty;
@@ -152,32 +152,52 @@ export declare class PlotFeature {
152
152
  get skeletons(): PlotSkeletonEntity[];
153
153
  }
154
154
 
155
- export declare class PlotFeatureCollection {
156
- constructor(options?: PlotCollectionConstructorOptions);
157
- get id(): string;
158
- get collectionChanged(): Event_2<PlotCollectionChanged>;
159
- get values(): PlotFeature[];
160
- add(value: PlotFeature): boolean;
161
- remove(value: PlotFeature): boolean;
162
- get entities(): EntityCollection;
163
- get primitives(): PrimitiveCollection;
164
- get groundPrimitives(): PrimitiveCollection;
165
- get skeletons(): EntityCollection;
166
- isDestroyed(): boolean;
167
- destroy(): void;
168
- }
169
-
155
+ /**
156
+ * 标绘实例构造参数
157
+ */
170
158
  export declare interface PlotFeatureConstructorOptions {
159
+ /**
160
+ * 唯一标识符
161
+ *
162
+ * 未指定时将自动生成GUID
163
+ */
171
164
  id?: string;
165
+ /**
166
+ * 标绘方案配置
167
+ *
168
+ * 支持直接传入字符串方案名称、方案实例或构造参数
169
+ */
172
170
  scheme: string | PlotScheme | PlotSchemeConstructorOptions;
171
+ /**
172
+ * 采样属性配置
173
+ *
174
+ * 控制标绘对象的动态属性采样行为
175
+ */
173
176
  sampled?: SampledPlotProperty | SampledPlotPropertyConstructorOptions;
177
+ /**
178
+ * 禁用状态标志
179
+ *
180
+ * @default false
181
+ */
174
182
  disabled?: boolean;
175
183
  }
176
184
 
177
185
  export declare interface PlotRenderOptions<D = any> {
186
+ /**
187
+ * 当前标绘点位数据
188
+ */
178
189
  packable: SampledPlotPackable<D>;
190
+ /**
191
+ * 当前是否处于定义态
192
+ */
179
193
  defining: boolean;
194
+ /**
195
+ * 当前鼠标位置,若当前标绘不处于定义态时,`mouse`为`undefined`
196
+ */
180
197
  mouse?: Cartesian3;
198
+ /**
199
+ * 上一次的渲染结果
200
+ */
181
201
  previous: PlotRenderResult;
182
202
  }
183
203
 
@@ -189,45 +209,106 @@ export declare interface PlotRenderResult {
189
209
 
190
210
  export declare class PlotScheme {
191
211
  constructor(options: PlotSchemeConstructorOptions);
212
+ /**
213
+ * 标绘类型。应当是全局唯一的字符串,会作为键名缓存
214
+ */
192
215
  type: string;
193
216
  /**
194
- * 是否立即执行完成标绘操作
195
- *
196
- * 每次控制点发生变变化时,执行该回调函数,如果返回`true`则标绘完成
217
+ * 判断是否立即完成标绘.
218
+ * 每次控制点发生变变化时,执行该回调函数,返回`true`则完成标绘
197
219
  */
198
220
  complete?: (packable: SampledPlotPackable) => boolean;
199
221
  /**
200
- * 双击时,是否执行完成标绘操作
222
+ * 判断是否允许手动完成标绘。
223
+ * 每次控制点发生变变化时,执行该回调函数,返回`true`则后续左键双击即完成标绘
201
224
  */
202
- forceComplete?: (packable: SampledPlotPackable) => boolean;
225
+ allowManualComplete?: (packable: SampledPlotPackable) => boolean;
203
226
  /**
227
+ * 处于定义态时鼠标的样式
204
228
  * @default 'crosshair'
205
229
  */
206
230
  definingCursor?: Nullable<CSSProperties['cursor']> | ((packable: SampledPlotPackable) => Nullable<CSSProperties['cursor']>);
231
+ /**
232
+ * 当前标绘的框架点数据
233
+ */
207
234
  skeletons: PlotSkeleton[];
235
+ /**
236
+ * 初始化时创建`Entity`的函数,创建后的`Entity`会作为配置项传入`render`中
237
+ */
208
238
  initEntites?: () => (Entity[] | undefined);
239
+ /**
240
+ * 初始化时创建`Primitive`的函数,创建后的`Primitive`会作为配置项传入`render`中
241
+ */
209
242
  initPrimitives?: () => (any[] | undefined);
243
+ /**
244
+ * 初始化时创建贴地`Primitive`的函数,创建后的`Primitive`会作为配置项传入`render`中
245
+ */
210
246
  initGroundPrimitives?: () => (any[] | undefined);
247
+ /**
248
+ * 当标绘数据变化时,会触发`render`回调,返回的数据会被添加到cesium中
249
+ */
211
250
  render?: (options: PlotRenderOptions) => PlotRenderResult | Promise<PlotRenderResult>;
212
251
  private static _record;
252
+ /**
253
+ * 标绘方案缓存。
254
+ * 每次标绘时都会将`PlotScheme.type`作为键名缓存,
255
+ * 后续可用过`PlotScheme.getCache(type)`获取完整的`PlotScheme`配置。
256
+ */
213
257
  static getCacheTypes(): string[];
258
+ /**
259
+ * 通过`PlotScheme.type`获取缓存中的`PlotScheme`配置。
260
+ */
214
261
  static getCache(type: string): PlotScheme | undefined;
262
+ /**
263
+ * 缓存标绘方案。
264
+ */
215
265
  static setCache(scheme: PlotScheme): void;
266
+ /**
267
+ * 解析传入的maybeScheme,maybeScheme可能是一个完整的PlotScheme,也可能是缓存中的`PlotScheme.type`,并返回 PlotScheme 实例。
268
+ * 若传入的是`PlotScheme.type`字符串,并且缓存中不存在该标绘方案,则抛出错误。
269
+ */
216
270
  static resolve(maybeScheme: string | PlotScheme | PlotSchemeConstructorOptions): PlotScheme;
217
271
  }
218
272
 
219
273
  export declare interface PlotSchemeConstructorOptions {
274
+ /**
275
+ * 标绘类型。应当是全局唯一的字符串,会作为键名缓存
276
+ */
220
277
  type: string;
278
+ /**
279
+ * 判断是否立即完成标绘.
280
+ * 每次控制点发生变变化时,执行该回调函数,返回`true`则完成标绘
281
+ */
221
282
  complete?: (packable: SampledPlotPackable) => boolean;
222
- forceComplete?: (packable: SampledPlotPackable) => boolean;
223
283
  /**
284
+ * 判断是否允许手动完成标绘。
285
+ * 每次控制点发生变变化时,执行该回调函数,返回`true`则后续左键双击即完成标绘
286
+ */
287
+ allowManualComplete?: (packable: SampledPlotPackable) => boolean;
288
+ /**
289
+ * 处于定义态时鼠标的样式
224
290
  * @default 'crosshair'
225
291
  */
226
292
  definingCursor?: Nullable<CSSProperties['cursor']> | ((packable: SampledPlotPackable) => Nullable<CSSProperties['cursor']>);
293
+ /**
294
+ * 当前标绘的框架点数据
295
+ */
227
296
  skeletons?: (() => PlotSkeleton)[];
297
+ /**
298
+ * 初始化时创建`Entity`的函数,创建后的`Entity`会作为配置项传入`render`中
299
+ */
228
300
  initEntites?: () => (Entity[] | undefined);
301
+ /**
302
+ * 初始化时创建贴地`Primitive`的函数,创建后的`Primitive`会作为配置项传入`render`中
303
+ */
229
304
  initPrimitives?: () => (any[] | undefined);
305
+ /**
306
+ * 初始化时创建贴地`Primitive`的函数,创建后的`Primitive`会作为配置项传入`render`中
307
+ */
230
308
  initGroundPrimitives?: () => (any[] | undefined);
309
+ /**
310
+ * 当标绘数据变化时,会触发`render`回调,返回的数据会被添加到cesium中
311
+ */
231
312
  render?: (options: PlotRenderOptions) => PlotRenderResult | Promise<PlotRenderResult>;
232
313
  }
233
314
 
@@ -287,13 +368,24 @@ export declare type SampledPlotInterpolationAlgorithm<D = any> = (time: JulianDa
287
368
  * 标绘采集到的数据
288
369
  */
289
370
  export declare interface SampledPlotPackable<D = any> {
371
+ /**
372
+ * 当前标绘所属于的时间节点
373
+ */
290
374
  time?: JulianDate;
375
+ /**
376
+ * 采样点位数据
377
+ */
291
378
  positions?: Cartesian3[];
379
+ /**
380
+ * 附带的额外自定义数据
381
+ */
292
382
  derivative?: D;
293
383
  }
294
384
 
295
385
  /**
296
- * 标绘属性数据
386
+ * 标绘采样点数据。
387
+ * 标绘采样点数据是一个时间序列数据,包含时间、位置和附带的额外数据。
388
+ * 具体用法可参考 [Cesium.SampledProperty](https://cesium.com/learn/cesiumjs/ref-doc/SampledProperty.html)
297
389
  */
298
390
  export declare class SampledPlotProperty<D = any> {
299
391
  constructor(options?: SampledPlotPropertyConstructorOptions<D>);
@@ -318,8 +410,7 @@ export declare class SampledPlotProperty<D = any> {
318
410
  */
319
411
  getValue(time?: JulianDate, result?: SampledPlotPackable): SampledPlotPackable<D>;
320
412
  /**
321
- * 设置样本数据
322
- *
413
+ * 设置样本数据,如果传入的数据不含时间,则会存入时间最早的集合中
323
414
  * @param value 样本数据对象,包含时间、位置和导数信息
324
415
  */
325
416
  setSample(value: SampledPlotPackable<D>): void;
@@ -342,6 +433,9 @@ export declare class SampledPlotProperty<D = any> {
342
433
  * @param interval 要移除样本的时间间隔
343
434
  */
344
435
  removeSamples(interval: TimeInterval): void;
436
+ /**
437
+ * 判断两个property是否相等
438
+ */
345
439
  equals(other?: Property): boolean;
346
440
  }
347
441
 
@@ -5,30 +5,49 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
5
5
 
6
6
  const _PlotScheme = class _PlotScheme {
7
7
  constructor(options) {
8
+ /**
9
+ * 标绘类型。应当是全局唯一的字符串,会作为键名缓存
10
+ */
8
11
  __publicField(this, "type");
9
12
  /**
10
- * 是否立即执行完成标绘操作
11
- *
12
- * 每次控制点发生变变化时,执行该回调函数,如果返回`true`则标绘完成
13
+ * 判断是否立即完成标绘.
14
+ * 每次控制点发生变变化时,执行该回调函数,返回`true`则完成标绘
13
15
  */
14
16
  __publicField(this, "complete");
15
17
  /**
16
- * 双击时,是否执行完成标绘操作
18
+ * 判断是否允许手动完成标绘。
19
+ * 每次控制点发生变变化时,执行该回调函数,返回`true`则后续左键双击即完成标绘
17
20
  */
18
- __publicField(this, "forceComplete");
21
+ __publicField(this, "allowManualComplete");
19
22
  /**
23
+ * 处于定义态时鼠标的样式
20
24
  * @default 'crosshair'
21
25
  */
22
26
  __publicField(this, "definingCursor");
27
+ /**
28
+ * 当前标绘的框架点数据
29
+ */
23
30
  __publicField(this, "skeletons");
31
+ /**
32
+ * 初始化时创建`Entity`的函数,创建后的`Entity`会作为配置项传入`render`中
33
+ */
24
34
  __publicField(this, "initEntites");
35
+ /**
36
+ * 初始化时创建`Primitive`的函数,创建后的`Primitive`会作为配置项传入`render`中
37
+ */
25
38
  __publicField(this, "initPrimitives");
39
+ /**
40
+ * 初始化时创建贴地`Primitive`的函数,创建后的`Primitive`会作为配置项传入`render`中
41
+ */
26
42
  __publicField(this, "initGroundPrimitives");
43
+ /**
44
+ * 当标绘数据变化时,会触发`render`回调,返回的数据会被添加到cesium中
45
+ */
27
46
  __publicField(this, "render");
28
47
  var _a;
29
48
  this.type = options.type;
30
49
  this.complete = options.complete;
31
- this.forceComplete = options.forceComplete;
50
+ this.allowManualComplete = options.allowManualComplete;
32
51
  this.definingCursor = options.definingCursor ?? "crosshair";
33
52
  this.skeletons = ((_a = options.skeletons) == null ? void 0 : _a.map((item) => item())) ?? [];
34
53
  this.initEntites = options.initEntites;
@@ -36,16 +55,31 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
36
55
  this.initGroundPrimitives = options.initGroundPrimitives;
37
56
  this.render = options.render;
38
57
  }
58
+ /**
59
+ * 标绘方案缓存。
60
+ * 每次标绘时都会将`PlotScheme.type`作为键名缓存,
61
+ * 后续可用过`PlotScheme.getCache(type)`获取完整的`PlotScheme`配置。
62
+ */
39
63
  static getCacheTypes() {
40
64
  return [...this._record.keys()];
41
65
  }
66
+ /**
67
+ * 通过`PlotScheme.type`获取缓存中的`PlotScheme`配置。
68
+ */
42
69
  static getCache(type) {
43
70
  return _PlotScheme._record.get(type);
44
71
  }
72
+ /**
73
+ * 缓存标绘方案。
74
+ */
45
75
  static setCache(scheme) {
46
76
  vesium.assertError(!scheme.type, "`scheme.type` is required");
47
77
  _PlotScheme._record.set(scheme.type, scheme);
48
78
  }
79
+ /**
80
+ * 解析传入的maybeScheme,maybeScheme可能是一个完整的PlotScheme,也可能是缓存中的`PlotScheme.type`,并返回 PlotScheme 实例。
81
+ * 若传入的是`PlotScheme.type`字符串,并且缓存中不存在该标绘方案,则抛出错误。
82
+ */
49
83
  static resolve(maybeScheme) {
50
84
  if (typeof maybeScheme === "string") {
51
85
  const _scheme = _PlotScheme.getCache(maybeScheme);
@@ -225,8 +259,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
225
259
  return result;
226
260
  }
227
261
  /**
228
- * 设置样本数据
229
- *
262
+ * 设置样本数据,如果传入的数据不含时间,则会存入时间最早的集合中
230
263
  * @param value 样本数据对象,包含时间、位置和导数信息
231
264
  */
232
265
  setSample(value) {
@@ -292,6 +325,9 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
292
325
  cesium.TimeInterval.contains(interval2, time) && this.removeSample(time);
293
326
  }
294
327
  }
328
+ /**
329
+ * 判断两个property是否相等
330
+ */
295
331
  equals(other) {
296
332
  return other === this;
297
333
  }
@@ -316,6 +352,9 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
316
352
  * @internal
317
353
  */
318
354
  __publicField(this, "_defining");
355
+ /**
356
+ * @internal
357
+ */
319
358
  __publicField(this, "_disabled");
320
359
  /**
321
360
  * @internal
@@ -372,6 +411,12 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
372
411
  plot._defining = value;
373
412
  }
374
413
  }
414
+ /**
415
+ * 获取禁用状态
416
+ *
417
+ * 当为 `true` 时,标绘实例将停止响应交互和更新;
418
+ * 为 `false` 时恢复正常功能。
419
+ */
375
420
  get disabled() {
376
421
  return this._disabled;
377
422
  }
@@ -419,64 +464,6 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
419
464
  this._skeletons = value;
420
465
  }
421
466
  }
422
- class PlotFeatureCollection {
423
- constructor(options = {}) {
424
- /**
425
- * @internal
426
- */
427
- __publicField(this, "_id");
428
- /**
429
- * @internal
430
- */
431
- __publicField(this, "_isDestroyed");
432
- const { id } = options;
433
- this._id = id || cesium.createGuid();
434
- this._isDestroyed = false;
435
- }
436
- get id() {
437
- return this._id;
438
- }
439
- get collectionChanged() {
440
- return this._collectionChanged;
441
- }
442
- get values() {
443
- return Array.from(this._values);
444
- }
445
- add(value) {
446
- if (this._isDestroyed) {
447
- throw new Error(`PlotFeatureCollection is isDestroyed`);
448
- }
449
- return this._values.has(value) ? false : !!this._values.add(value);
450
- }
451
- remove(value) {
452
- return this._values.delete(value);
453
- }
454
- get entities() {
455
- return this._dataSource.entities;
456
- }
457
- get primitives() {
458
- return this._primitives;
459
- }
460
- get groundPrimitives() {
461
- return this._groundPrimitives;
462
- }
463
- get skeletons() {
464
- return this._skeletonDataSource.entities;
465
- }
466
- isDestroyed() {
467
- return this._isDestroyed;
468
- }
469
- destroy() {
470
- if (!this._isDestroyed) {
471
- this._viewer.dataSources.remove(this._dataSource);
472
- this._viewer.dataSources.remove(this._skeletonDataSource);
473
- this._viewer.scene.primitives.remove(this._primitives);
474
- this._viewer.scene.groundPrimitives.remove(this._groundPrimitives);
475
- this._viewer.dataSources.remove(this._skeletonDataSource);
476
- this._isDestroyed = true;
477
- }
478
- }
479
- }
480
467
  var PlotAction = /* @__PURE__ */ ((PlotAction2) => {
481
468
  PlotAction2[PlotAction2["IDLE"] = 0] = "IDLE";
482
469
  PlotAction2[PlotAction2["HOVER"] = 1] = "HOVER";
@@ -623,7 +610,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
623
610
  if (!position) {
624
611
  return;
625
612
  }
626
- const completed = (_a = scheme.forceComplete) == null ? void 0 : _a.call(scheme, packable.value);
613
+ const completed = (_a = scheme.allowManualComplete) == null ? void 0 : _a.call(scheme, packable.value);
627
614
  completed && PlotFeature.setDefining(current.value, false);
628
615
  }
629
616
  );
@@ -900,7 +887,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
900
887
  if (previous) {
901
888
  if (previous.defining) {
902
889
  const packable2 = previous.sampled.getValue(getCurrentTime());
903
- const completed = (_b = (_a = previous.scheme).forceComplete) == null ? void 0 : _b.call(_a, packable2);
890
+ const completed = (_b = (_a = previous.scheme).allowManualComplete) == null ? void 0 : _b.call(_a, packable2);
904
891
  if (completed) {
905
892
  PlotFeature.setDefining(previous, false);
906
893
  operateResolve == null ? void 0 : operateResolve(previous);
@@ -1246,7 +1233,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
1246
1233
  }
1247
1234
  const schemeMeasureArea = new PlotScheme({
1248
1235
  type: "measureArea",
1249
- forceComplete: (packable) => packable.positions.length >= 3,
1236
+ allowManualComplete: (packable) => packable.positions.length >= 3,
1250
1237
  skeletons: [
1251
1238
  control,
1252
1239
  interval
@@ -1358,7 +1345,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
1358
1345
  });
1359
1346
  const schemePolygon = new PlotScheme({
1360
1347
  type: "polygon",
1361
- forceComplete: (packable) => packable.positions.length >= 3,
1348
+ allowManualComplete: (packable) => packable.positions.length >= 3,
1362
1349
  skeletons: [
1363
1350
  control,
1364
1351
  interval,
@@ -1408,7 +1395,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
1408
1395
  const schemePolyline = new PlotScheme(
1409
1396
  {
1410
1397
  type: "polyline",
1411
- forceComplete: (packable) => packable.positions.length >= 2,
1398
+ allowManualComplete: (packable) => packable.positions.length >= 2,
1412
1399
  skeletons: [
1413
1400
  control,
1414
1401
  intervalNonclosed,
@@ -1468,7 +1455,6 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
1468
1455
  });
1469
1456
  exports.PlotAction = PlotAction;
1470
1457
  exports.PlotFeature = PlotFeature;
1471
- exports.PlotFeatureCollection = PlotFeatureCollection;
1472
1458
  exports.PlotScheme = PlotScheme;
1473
1459
  exports.PlotSkeletonEntity = PlotSkeletonEntity;
1474
1460
  exports.SampledPlotProperty = SampledPlotProperty;