@vesium/plot 1.0.1-beta.47 → 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 +67 -81
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +127 -33
- package/dist/index.iife.js +67 -81
- package/dist/index.iife.js.map +1 -1
- package/dist/index.iife.min.js +1 -1
- package/dist/index.iife.min.js.map +1 -1
- package/dist/index.min.cjs +1 -1
- package/dist/index.min.cjs.map +1 -1
- package/dist/index.min.mjs +1 -1
- package/dist/index.min.mjs.map +1 -1
- package/dist/index.mjs +67 -81
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
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, "
|
|
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.
|
|
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);
|
|
@@ -121,7 +155,7 @@ const _SampledPlotProperty = class _SampledPlotProperty {
|
|
|
121
155
|
(_a = options == null ? void 0 : options.packables) == null ? void 0 : _a.forEach((packable) => this.setSample(packable));
|
|
122
156
|
if (!this._times.length) {
|
|
123
157
|
this.setSample({
|
|
124
|
-
time: cesium.JulianDate
|
|
158
|
+
time: new cesium.JulianDate(0, 0),
|
|
125
159
|
positions: [],
|
|
126
160
|
derivative: void 0
|
|
127
161
|
});
|
|
@@ -195,7 +229,7 @@ const _SampledPlotProperty = class _SampledPlotProperty {
|
|
|
195
229
|
* @template D 数据类型。
|
|
196
230
|
*/
|
|
197
231
|
getValue(time, result) {
|
|
198
|
-
var _a
|
|
232
|
+
var _a;
|
|
199
233
|
result ?? (result = { time });
|
|
200
234
|
Object.assign(result, {
|
|
201
235
|
time: time == null ? void 0 : time.clone(),
|
|
@@ -203,8 +237,8 @@ const _SampledPlotProperty = class _SampledPlotProperty {
|
|
|
203
237
|
derivative: void 0
|
|
204
238
|
});
|
|
205
239
|
if (!time) {
|
|
206
|
-
result.time =
|
|
207
|
-
result.positions = (
|
|
240
|
+
result.time = this._times[0].clone();
|
|
241
|
+
result.positions = (_a = this._sampleds[0]) == null ? void 0 : _a.map((c) => c.clone(c));
|
|
208
242
|
result.derivative = this._derivatives[0];
|
|
209
243
|
return result;
|
|
210
244
|
}
|
|
@@ -229,14 +263,13 @@ 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) {
|
|
237
|
-
var _a, _b
|
|
238
|
-
const time = ((_a = value.time) == null ? void 0 : _a.clone()) ??
|
|
239
|
-
const positions = ((
|
|
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())) ?? [];
|
|
240
273
|
const derivative = value.derivative;
|
|
241
274
|
const index = this._times.findIndex((t) => cesium.JulianDate.equals(time, t));
|
|
242
275
|
if (index !== -1) {
|
|
@@ -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.
|
|
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
|
);
|
|
@@ -863,8 +850,8 @@ function usePlot(options) {
|
|
|
863
850
|
const time = (options == null ? void 0 : options.time) || vue.shallowRef();
|
|
864
851
|
const viewer = vesium.useViewer();
|
|
865
852
|
const getCurrentTime = () => {
|
|
866
|
-
var _a
|
|
867
|
-
return ((_a = time.value) == null ? void 0 : _a.clone()) ||
|
|
853
|
+
var _a;
|
|
854
|
+
return ((_a = time.value) == null ? void 0 : _a.clone()) || new cesium.JulianDate(0, 0);
|
|
868
855
|
};
|
|
869
856
|
const collection = vue.shallowReactive(/* @__PURE__ */ new Set());
|
|
870
857
|
const plots = vue.computed(() => Array.from(collection));
|
|
@@ -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).
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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;
|