@yituengine/keymap 1.0.0
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/LICENSE +201 -0
- package/README.md +148 -0
- package/dist/engine.js +1 -0
- package/dist/types/core/Assets.d.ts +11 -0
- package/dist/types/core/Classification.d.ts +17 -0
- package/dist/types/core/Flatten.d.ts +74 -0
- package/dist/types/core/Status.d.ts +3 -0
- package/dist/types/core/pathAnim.d.ts +27 -0
- package/dist/types/core/transformFun.d.ts +16 -0
- package/dist/types/draw/baseDraw.d.ts +74 -0
- package/dist/types/draw/drawCircle.d.ts +44 -0
- package/dist/types/draw/drawPoint.d.ts +30 -0
- package/dist/types/draw/drawPolygon.d.ts +35 -0
- package/dist/types/draw/drawPolyline.d.ts +35 -0
- package/dist/types/draw/index.d.ts +17 -0
- package/dist/types/effect/cloud.d.ts +34 -0
- package/dist/types/effect/fog.d.ts +44 -0
- package/dist/types/effect/fogPro.d.ts +46 -0
- package/dist/types/effect/index.d.ts +32 -0
- package/dist/types/effect/lensflare.d.ts +38 -0
- package/dist/types/effect/rainy.d.ts +47 -0
- package/dist/types/effect/snowCover.d.ts +50 -0
- package/dist/types/effect/snowFall.d.ts +38 -0
- package/dist/types/event/index.d.ts +12 -0
- package/dist/types/event/menu.d.ts +110 -0
- package/dist/types/event/mousePick.d.ts +57 -0
- package/dist/types/graphic/baseGraphic.d.ts +131 -0
- package/dist/types/graphic/billboardGraphic.d.ts +75 -0
- package/dist/types/graphic/circleGraphic.d.ts +103 -0
- package/dist/types/graphic/customPopupGraphic.d.ts +75 -0
- package/dist/types/graphic/index.d.ts +32 -0
- package/dist/types/graphic/modelGraphic.d.ts +90 -0
- package/dist/types/graphic/polygonGraphic.d.ts +124 -0
- package/dist/types/graphic/polylineGraphic.d.ts +100 -0
- package/dist/types/graphic/popupGraphic.d.ts +85 -0
- package/dist/types/layer/graphicLayer.d.ts +96 -0
- package/dist/types/layer/heatmapLayer/heatmapRenderer.d.ts +39 -0
- package/dist/types/layer/heatmapLayer.d.ts +113 -0
- package/dist/types/layer/index.d.ts +14 -0
- package/dist/types/layer/tilesetLayer.d.ts +107 -0
- package/dist/types/main.d.ts +68 -0
- package/dist/types/map/defaultInteractions.d.ts +26 -0
- package/dist/types/map/index.d.ts +254 -0
- package/dist/types/material/LightingFlow.d.ts +63 -0
- package/dist/types/material/PolylineDashed.d.ts +68 -0
- package/dist/types/material/TextureFlow.d.ts +94 -0
- package/dist/types/material/Wave.d.ts +75 -0
- package/dist/types/material/index.d.ts +20 -0
- package/dist/types/measure/baseMeasure.d.ts +93 -0
- package/dist/types/measure/index.d.ts +18 -0
- package/dist/types/measure/measureArea.d.ts +46 -0
- package/dist/types/measure/measureCutFill.d.ts +69 -0
- package/dist/types/measure/measureDistance.d.ts +50 -0
- package/dist/types/measure/measureHeight.d.ts +47 -0
- package/dist/types/primitive/ClassificationPrimitive.d.ts +72 -0
- package/dist/types/primitive/Tube.d.ts +38 -0
- package/dist/types/primitive/Wall.d.ts +47 -0
- package/dist/types/primitive/basePrimitive.d.ts +42 -0
- package/dist/types/primitive/index.d.ts +16 -0
- package/dist/types/types/general.d.ts +94 -0
- package/dist/types/types/index.d.ts +2 -0
- package/dist/types/types/public.d.ts +11 -0
- package/dist/types/utils/CoordTransform.d.ts +26 -0
- package/dist/types/utils/controlPoint.d.ts +10 -0
- package/dist/types/utils/cutFillAnalysis.d.ts +38 -0
- package/dist/types/utils/graphic.d.ts +45 -0
- package/dist/types/utils/midPoint.d.ts +11 -0
- package/dist/types/utils/rightMenu.d.ts +1 -0
- package/dist/types/utils/tools.d.ts +38 -0
- package/docs/guide/draw-measure.md +97 -0
- package/docs/guide/graphic.md +136 -0
- package/docs/guide/index.md +29 -0
- package/docs/guide/menu.md +101 -0
- package/docs/guide/quick-start.md +74 -0
- package/package.json +58 -0
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import * as Cesium from 'cesium';
|
|
2
|
+
import { EMaterialName } from '../types/general';
|
|
3
|
+
/** 纹理流动材质支持的图片资源类型。 */
|
|
4
|
+
export type TextureFlowImage = string | Cesium.Resource | HTMLCanvasElement | HTMLImageElement | HTMLVideoElement;
|
|
5
|
+
/** `TextureFlow` 纹理流动材质传入 Cesium shader 的 uniforms。 */
|
|
6
|
+
export interface TextureFlowUniforms {
|
|
7
|
+
/** 纹理图片资源。 */
|
|
8
|
+
uImage: TextureFlowImage;
|
|
9
|
+
/** 纹理在 x 方向的重复次数。 */
|
|
10
|
+
uRepeatX: number;
|
|
11
|
+
/** 纹理在 y 方向的重复次数。 */
|
|
12
|
+
uRepeatY: number;
|
|
13
|
+
/** 纹理透明度,范围通常为 `0` 到 `1`。 */
|
|
14
|
+
uOpacity: number;
|
|
15
|
+
/** 与纹理混合的基础颜色。 */
|
|
16
|
+
uColor: Cesium.Color;
|
|
17
|
+
/** 纹理流动速度。 */
|
|
18
|
+
uSpeed: number;
|
|
19
|
+
}
|
|
20
|
+
/** 纹理流动材质构造参数。 */
|
|
21
|
+
export interface TextureFlowOptions {
|
|
22
|
+
/** 纹理图片资源,不传时使用 Cesium 默认图片。 */
|
|
23
|
+
image?: TextureFlowImage;
|
|
24
|
+
/** 纹理在 x 方向的重复次数,默认 `1`。 */
|
|
25
|
+
repeatX?: number;
|
|
26
|
+
/** 纹理在 y 方向的重复次数,默认 `1`。 */
|
|
27
|
+
repeatY?: number;
|
|
28
|
+
/** 透明度,默认 `1`。 */
|
|
29
|
+
opacity?: number;
|
|
30
|
+
/** 旧拼写兼容字段,等价于 `opacity`。 */
|
|
31
|
+
opcity?: number;
|
|
32
|
+
/** 基础颜色,支持 Cesium Color 或 CSS 颜色字符串。 */
|
|
33
|
+
color?: Cesium.Color | string;
|
|
34
|
+
/** 流动速度,默认 `1`。 */
|
|
35
|
+
speed?: number;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* 纹理流动材质。
|
|
39
|
+
*
|
|
40
|
+
* 实现 Cesium `MaterialProperty`,通过移动纹理采样坐标形成箭头、水流、管线流动等效果。
|
|
41
|
+
*/
|
|
42
|
+
export default class TextureFlow implements Cesium.MaterialProperty {
|
|
43
|
+
private static registered;
|
|
44
|
+
/** Cesium MaterialProperty 标识,当前材质会随 uniforms 变化。 */
|
|
45
|
+
readonly isConstant = false;
|
|
46
|
+
/** Cesium 材质类型名称。 */
|
|
47
|
+
name: EMaterialName;
|
|
48
|
+
/** 当前材质 uniforms 状态。 */
|
|
49
|
+
uniforms: TextureFlowUniforms;
|
|
50
|
+
/** uniforms 变化时通知 Cesium 重新取值。 */
|
|
51
|
+
definitionChanged: Cesium.Event<(...args: any[]) => void>;
|
|
52
|
+
/**
|
|
53
|
+
* 创建纹理流动材质。
|
|
54
|
+
*
|
|
55
|
+
* @param opt 纹理流动材质配置。
|
|
56
|
+
*/
|
|
57
|
+
constructor(opt: TextureFlowOptions);
|
|
58
|
+
private static registerMaterial;
|
|
59
|
+
private static toColor;
|
|
60
|
+
/** 纹理图片资源。赋值时会触发 `definitionChanged`。 */
|
|
61
|
+
get uImage(): TextureFlowImage;
|
|
62
|
+
set uImage(image: TextureFlowImage);
|
|
63
|
+
/** x 方向重复次数。赋值时会触发 `definitionChanged`。 */
|
|
64
|
+
get uRepeatX(): number;
|
|
65
|
+
set uRepeatX(repeatX: number);
|
|
66
|
+
/** y 方向重复次数。赋值时会触发 `definitionChanged`。 */
|
|
67
|
+
get uRepeatY(): number;
|
|
68
|
+
set uRepeatY(repeatY: number);
|
|
69
|
+
/** 透明度。赋值时会触发 `definitionChanged`。 */
|
|
70
|
+
get uOpacity(): number;
|
|
71
|
+
set uOpacity(opacity: number);
|
|
72
|
+
/** 透明度别名,兼容旧的 `uDefaultOpc` 调用。 */
|
|
73
|
+
get uDefaultOpc(): number;
|
|
74
|
+
set uDefaultOpc(opacity: number);
|
|
75
|
+
/** 基础颜色。赋值时会触发 `definitionChanged`。 */
|
|
76
|
+
get uColor(): Cesium.Color;
|
|
77
|
+
set uColor(color: Cesium.Color);
|
|
78
|
+
/** 流动速度。赋值时会触发 `definitionChanged`。 */
|
|
79
|
+
get uSpeed(): number;
|
|
80
|
+
set uSpeed(speed: number);
|
|
81
|
+
/** 返回 Cesium 材质类型名称。 */
|
|
82
|
+
getType(_time: Cesium.JulianDate): EMaterialName;
|
|
83
|
+
/**
|
|
84
|
+
* 返回当前 uniforms 值。
|
|
85
|
+
*
|
|
86
|
+
* Cesium 渲染管线会在需要材质值时调用该方法。
|
|
87
|
+
*
|
|
88
|
+
* @param _time Cesium 当前时间。
|
|
89
|
+
* @param result 可复用的结果对象。
|
|
90
|
+
*/
|
|
91
|
+
getValue(_time: Cesium.JulianDate, result?: TextureFlowUniforms): TextureFlowUniforms;
|
|
92
|
+
/** 比较另一个 Cesium Property 是否与当前材质等价。 */
|
|
93
|
+
equals(other?: Cesium.Property): boolean;
|
|
94
|
+
}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import * as Cesium from 'cesium';
|
|
2
|
+
import { EMaterialName } from '../types/general';
|
|
3
|
+
/** `Wave` 扩散波纹材质传入 Cesium shader 的 uniforms。 */
|
|
4
|
+
export interface WaveUniforms {
|
|
5
|
+
/** 波纹颜色。 */
|
|
6
|
+
uColor: Cesium.Color;
|
|
7
|
+
/** 波纹扩散速度。 */
|
|
8
|
+
uSpeed: number;
|
|
9
|
+
/** 同时显示的波纹圈数。 */
|
|
10
|
+
uCount: number;
|
|
11
|
+
/** 波纹渐变衰减系数。 */
|
|
12
|
+
uGradient: number;
|
|
13
|
+
}
|
|
14
|
+
/** 扩散波纹材质构造参数。 */
|
|
15
|
+
export interface WaveOptions {
|
|
16
|
+
/** 波纹颜色,支持 Cesium Color 或 CSS 颜色字符串。 */
|
|
17
|
+
color?: Cesium.Color | string;
|
|
18
|
+
/** 波纹扩散速度,默认 `1`。 */
|
|
19
|
+
speed?: number;
|
|
20
|
+
/** 同时显示的波纹圈数,默认 `1`。 */
|
|
21
|
+
count?: number;
|
|
22
|
+
/** 旧字段别名,等价于 `count`。 */
|
|
23
|
+
repeat?: number;
|
|
24
|
+
/** 波纹渐变衰减系数,默认 `1`。 */
|
|
25
|
+
gradient?: number;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* 扩散波纹材质。
|
|
29
|
+
*
|
|
30
|
+
* 实现 Cesium `MaterialProperty`,用于圆形、面或其他带纹理坐标的图形上生成中心向外扩散的波纹效果。
|
|
31
|
+
*/
|
|
32
|
+
export default class Wave implements Cesium.MaterialProperty {
|
|
33
|
+
private static registered;
|
|
34
|
+
/** Cesium MaterialProperty 标识,当前材质会随 uniforms 变化。 */
|
|
35
|
+
readonly isConstant = false;
|
|
36
|
+
/** Cesium 材质类型名称。 */
|
|
37
|
+
name: EMaterialName;
|
|
38
|
+
/** 当前材质 uniforms 状态。 */
|
|
39
|
+
uniforms: WaveUniforms;
|
|
40
|
+
/** uniforms 变化时通知 Cesium 重新取值。 */
|
|
41
|
+
definitionChanged: Cesium.Event<(...args: any[]) => void>;
|
|
42
|
+
/**
|
|
43
|
+
* 创建扩散波纹材质。
|
|
44
|
+
*
|
|
45
|
+
* @param opt 波纹材质配置。
|
|
46
|
+
*/
|
|
47
|
+
constructor(opt?: WaveOptions);
|
|
48
|
+
private static registerMaterial;
|
|
49
|
+
private static toColor;
|
|
50
|
+
/** 波纹颜色。赋值时会触发 `definitionChanged`。 */
|
|
51
|
+
get uColor(): Cesium.Color;
|
|
52
|
+
set uColor(color: Cesium.Color);
|
|
53
|
+
/** 波纹扩散速度。赋值时会触发 `definitionChanged`。 */
|
|
54
|
+
get uSpeed(): number;
|
|
55
|
+
set uSpeed(speed: number);
|
|
56
|
+
/** 波纹圈数。赋值时会触发 `definitionChanged`。 */
|
|
57
|
+
get uCount(): number;
|
|
58
|
+
set uCount(count: number);
|
|
59
|
+
/** 波纹渐变衰减系数。赋值时会触发 `definitionChanged`。 */
|
|
60
|
+
get uGradient(): number;
|
|
61
|
+
set uGradient(gradient: number);
|
|
62
|
+
/** 返回 Cesium 材质类型名称。 */
|
|
63
|
+
getType(_time: Cesium.JulianDate): EMaterialName;
|
|
64
|
+
/**
|
|
65
|
+
* 返回当前 uniforms 值。
|
|
66
|
+
*
|
|
67
|
+
* Cesium 渲染管线会在需要材质值时调用该方法。
|
|
68
|
+
*
|
|
69
|
+
* @param _time Cesium 当前时间。
|
|
70
|
+
* @param result 可复用的结果对象。
|
|
71
|
+
*/
|
|
72
|
+
getValue(_time: Cesium.JulianDate, result?: WaveUniforms): WaveUniforms;
|
|
73
|
+
/** 比较另一个 Cesium Property 是否与当前材质等价。 */
|
|
74
|
+
equals(other?: Cesium.Property): boolean;
|
|
75
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import LightingFlow from './LightingFlow';
|
|
2
|
+
import PolylineDashed from './PolylineDashed';
|
|
3
|
+
import TextureFlow from './TextureFlow';
|
|
4
|
+
import Wave from './Wave';
|
|
5
|
+
export { default as LightingFlow } from './LightingFlow';
|
|
6
|
+
export { default as PolylineDashed } from './PolylineDashed';
|
|
7
|
+
export { default as TextureFlow } from './TextureFlow';
|
|
8
|
+
export { default as Wave } from './Wave';
|
|
9
|
+
export type { LightingFlowUniforms } from './LightingFlow';
|
|
10
|
+
export type { PolylineDashedUniforms } from './PolylineDashed';
|
|
11
|
+
export type { TextureFlowImage, TextureFlowOptions, TextureFlowUniforms } from './TextureFlow';
|
|
12
|
+
export type { WaveOptions, WaveUniforms } from './Wave';
|
|
13
|
+
export type MaterialType = LightingFlow | PolylineDashed | TextureFlow | Wave;
|
|
14
|
+
declare const _default: {
|
|
15
|
+
LightingFlow: typeof LightingFlow;
|
|
16
|
+
PolylineDashed: typeof PolylineDashed;
|
|
17
|
+
TextureFlow: typeof TextureFlow;
|
|
18
|
+
Wave: typeof Wave;
|
|
19
|
+
};
|
|
20
|
+
export default _default;
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import type KeyMap from '../map';
|
|
2
|
+
import * as Cesium from 'cesium';
|
|
3
|
+
/**
|
|
4
|
+
* 交互式测量工具基类。
|
|
5
|
+
*
|
|
6
|
+
* 负责创建 Cesium 事件处理器和测量数据源,并统一维护测量实例在 {@link KeyMap} 中的激活、显示、清理和销毁生命周期。具体测量类型只需要实现事件注册逻辑。
|
|
7
|
+
*
|
|
8
|
+
* @typeParam TFinishCallback 测量完成时回调函数的类型。
|
|
9
|
+
*/
|
|
10
|
+
export default abstract class BaseMeasure<TFinishCallback> {
|
|
11
|
+
/** 测量实例的唯一标识。 */
|
|
12
|
+
id: string;
|
|
13
|
+
/** 测量实例名称,默认由类名和唯一标识组成。 */
|
|
14
|
+
name: string;
|
|
15
|
+
/** 资源类型标识,供地图资源管理器识别测量对象。 */
|
|
16
|
+
type: string;
|
|
17
|
+
/** 当前实例是否处于测量交互状态。 */
|
|
18
|
+
isMeasure: boolean;
|
|
19
|
+
/** 当前测量工具所属地图实例。 */
|
|
20
|
+
map: KeyMap;
|
|
21
|
+
/** 当前地图的 Cesium Viewer。 */
|
|
22
|
+
viewer: Cesium.Viewer;
|
|
23
|
+
/** 当前测量工具独占的屏幕事件处理器。 */
|
|
24
|
+
handler: Cesium.ScreenSpaceEventHandler;
|
|
25
|
+
/** 存放测量图形、标签和辅助实体的数据源。 */
|
|
26
|
+
dataSource: Cesium.CustomDataSource;
|
|
27
|
+
/** 测量完成回调;未设置时为 `null`。 */
|
|
28
|
+
finishCallback: TFinishCallback | null;
|
|
29
|
+
/**
|
|
30
|
+
* 创建测量工具实例。
|
|
31
|
+
*
|
|
32
|
+
* @param map 地图实例,测量实体会添加到该地图的 Viewer 中。
|
|
33
|
+
*/
|
|
34
|
+
constructor(map: KeyMap);
|
|
35
|
+
/**
|
|
36
|
+
* 激活当前测量工具。
|
|
37
|
+
*
|
|
38
|
+
* 激活后会注册交互事件、将鼠标样式切换为十字光标、更新地图测量状态,并将实例加入地图资源管理器。
|
|
39
|
+
*/
|
|
40
|
+
activate(): void;
|
|
41
|
+
/**
|
|
42
|
+
* 停止当前测量交互。
|
|
43
|
+
*
|
|
44
|
+
* 该方法只解除交互和状态,不会清除已经绘制到数据源中的测量结果。
|
|
45
|
+
*/
|
|
46
|
+
deactivate(): void;
|
|
47
|
+
/**
|
|
48
|
+
* 设置测量完成回调。
|
|
49
|
+
*
|
|
50
|
+
* @param callback 测量完成时调用的回调函数,具体参数由子类定义。
|
|
51
|
+
*/
|
|
52
|
+
setFinishCallback(callback: TFinishCallback): void;
|
|
53
|
+
/**
|
|
54
|
+
* 清空当前测量结果并移除测量数据源。
|
|
55
|
+
*
|
|
56
|
+
* 清理后实例会从地图资源管理器中解绑。
|
|
57
|
+
*/
|
|
58
|
+
clear(): void;
|
|
59
|
+
/** 结束测量流程并停止交互。 */
|
|
60
|
+
measureEnd(): void;
|
|
61
|
+
/** 注销测量工具注册的鼠标事件。 */
|
|
62
|
+
unRegisterEvents(): void;
|
|
63
|
+
/** 将测量数据源重新添加到 Viewer 中以显示测量结果。 */
|
|
64
|
+
show(): void;
|
|
65
|
+
/** 从 Viewer 中移除测量数据源以隐藏测量结果。 */
|
|
66
|
+
hide(): void;
|
|
67
|
+
/** 销毁测量工具,停止交互、清理实体并注销事件。 */
|
|
68
|
+
destroy(): void;
|
|
69
|
+
/**
|
|
70
|
+
* 计算一组 Cartesian3 坐标的算术中心点。
|
|
71
|
+
*
|
|
72
|
+
* @param positions 用于计算中心点的三维坐标集合。
|
|
73
|
+
* @returns 输入坐标的 Cartesian3 算术平均位置。
|
|
74
|
+
*/
|
|
75
|
+
calcCentroid(positions: Cesium.Cartesian3[]): Cesium.Cartesian3;
|
|
76
|
+
/**
|
|
77
|
+
* 从屏幕坐标拾取场景表面坐标。
|
|
78
|
+
*
|
|
79
|
+
* 优先使用 `pickPosition`,不可用时回退到地球表面射线拾取。
|
|
80
|
+
*
|
|
81
|
+
* @param windowPosition 鼠标事件中的屏幕坐标。
|
|
82
|
+
* @returns 拾取到的世界坐标;无法拾取时返回 `undefined`。
|
|
83
|
+
*/
|
|
84
|
+
protected pickSurfacePosition(windowPosition: Cesium.Cartesian2): Cesium.Cartesian3 | undefined;
|
|
85
|
+
/** 激活后的子类扩展钩子。 */
|
|
86
|
+
protected onActivate(): void;
|
|
87
|
+
/** 停止交互后的子类扩展钩子。 */
|
|
88
|
+
protected onDeactivate(): void;
|
|
89
|
+
/** 清空测量结果后的子类扩展钩子。 */
|
|
90
|
+
protected onClear(): void;
|
|
91
|
+
/** 注册当前测量工具需要的鼠标事件。 */
|
|
92
|
+
protected abstract registerEvents(): void;
|
|
93
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import MeasureDistance from './measureDistance';
|
|
2
|
+
import MeasureCutFill from './measureCutFill';
|
|
3
|
+
import MeasureHeight from './measureHeight';
|
|
4
|
+
import MeasureArea from './measureArea';
|
|
5
|
+
export { default as MeasureDistance } from './measureDistance';
|
|
6
|
+
export { default as MeasureCutFill } from './measureCutFill';
|
|
7
|
+
export { default as MeasureHeight } from './measureHeight';
|
|
8
|
+
export { default as MeasureArea } from './measureArea';
|
|
9
|
+
export type { CutFillResult } from './measureCutFill';
|
|
10
|
+
/** SDK 内置交互式测量工具实例类型。 */
|
|
11
|
+
export type MeasureType = MeasureDistance | MeasureCutFill | MeasureHeight | MeasureArea;
|
|
12
|
+
declare const _default: {
|
|
13
|
+
MeasureDistance: typeof MeasureDistance;
|
|
14
|
+
MeasureCutFill: typeof MeasureCutFill;
|
|
15
|
+
MeasureHeight: typeof MeasureHeight;
|
|
16
|
+
MeasureArea: typeof MeasureArea;
|
|
17
|
+
};
|
|
18
|
+
export default _default;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import type KeyMap from '../map';
|
|
2
|
+
import * as Cesium from 'cesium';
|
|
3
|
+
import BaseMeasure from './baseMeasure';
|
|
4
|
+
/**
|
|
5
|
+
* 面积测量工具。
|
|
6
|
+
*
|
|
7
|
+
* 左键添加多边形顶点,鼠标移动预览面和边线,右键撤销上一个顶点,中键在至少三个顶点后结束测量并显示面积标签。
|
|
8
|
+
*/
|
|
9
|
+
export default class MeasureArea extends BaseMeasure<() => void> {
|
|
10
|
+
/** 用户左键确认的多边形顶点。 */
|
|
11
|
+
positions: Cesium.Cartesian3[];
|
|
12
|
+
/** 用于最终面积计算的固定顶点副本。 */
|
|
13
|
+
cleanPositions: Cesium.Cartesian3[];
|
|
14
|
+
/** 用于鼠标移动预览的动态顶点集合。 */
|
|
15
|
+
tempPositions: Cesium.Cartesian3[];
|
|
16
|
+
/** 面积测量边线实体。 */
|
|
17
|
+
lineEntity: Cesium.Entity | null;
|
|
18
|
+
/** 面积测量面实体。 */
|
|
19
|
+
polygonEntity: Cesium.Entity | null;
|
|
20
|
+
/** 标签高度补偿值。 */
|
|
21
|
+
height: number;
|
|
22
|
+
/**
|
|
23
|
+
* 创建面积测量工具。
|
|
24
|
+
*
|
|
25
|
+
* @param map 地图实例。
|
|
26
|
+
*/
|
|
27
|
+
constructor(map: KeyMap);
|
|
28
|
+
private createPolylineEntity;
|
|
29
|
+
private createPolygonEntity;
|
|
30
|
+
private createEndEntity;
|
|
31
|
+
protected registerEvents(): void;
|
|
32
|
+
private leftClickEvent;
|
|
33
|
+
private middleClickEvent;
|
|
34
|
+
private rightClickEvent;
|
|
35
|
+
private mouseMoveEvent;
|
|
36
|
+
/**
|
|
37
|
+
* 计算多边形面积并返回带中文单位的格式化文本。
|
|
38
|
+
*
|
|
39
|
+
* 输入坐标会转换为经纬度,首尾未闭合时会自动闭合,再通过 Turf 计算面积。小于 1 平方公里时返回平方米,否则返回平方公里。
|
|
40
|
+
*
|
|
41
|
+
* @param points 多边形顶点坐标。
|
|
42
|
+
* @returns 面积文本,例如 `120.000 平方米` 或 `1.200 平方公里`。
|
|
43
|
+
*/
|
|
44
|
+
calcArea(points: Cesium.Cartesian3[]): string;
|
|
45
|
+
protected onDeactivate(): void;
|
|
46
|
+
}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import type KeyMap from '../map';
|
|
2
|
+
import * as Cesium from 'cesium';
|
|
3
|
+
import BaseMeasure from './baseMeasure';
|
|
4
|
+
/** 挖填方分析结果。 */
|
|
5
|
+
export interface CutFillResult {
|
|
6
|
+
/** 分析区域总面积,单位为平方米。 */
|
|
7
|
+
allArea: number;
|
|
8
|
+
/** 挖方面积,单位为平方米。 */
|
|
9
|
+
cutArea: number;
|
|
10
|
+
/** 挖方体积,单位为立方米。 */
|
|
11
|
+
cutVolume: number;
|
|
12
|
+
/** 填方面积,单位为平方米。 */
|
|
13
|
+
fillArea: number;
|
|
14
|
+
/** 填方体积,单位为立方米。 */
|
|
15
|
+
fillVolume: number;
|
|
16
|
+
/** 无需挖填的面积,单位为平方米。 */
|
|
17
|
+
noArea: number;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* 挖填方测量工具。
|
|
21
|
+
*
|
|
22
|
+
* 用户绘制多边形后,中键结束测量并执行挖填方体积分析。完成回调会收到当前分析结果;当测量未形成有效区域时结果为 `null`。
|
|
23
|
+
*/
|
|
24
|
+
export default class MeasureCutFill extends BaseMeasure<(result: CutFillResult | null) => void> {
|
|
25
|
+
/** 用户左键确认的分析区域顶点。 */
|
|
26
|
+
positions: Cesium.Cartesian3[];
|
|
27
|
+
/** 用于鼠标移动预览的动态区域边线顶点。 */
|
|
28
|
+
tempPositions: Cesium.Cartesian3[];
|
|
29
|
+
/** 分析基准高度,默认 100;首个拾取点有高度时会使用该高度。 */
|
|
30
|
+
height: number;
|
|
31
|
+
/** 挖填方采样精度,会根据分析区域面积动态计算。 */
|
|
32
|
+
precision: number;
|
|
33
|
+
/** 分析区域边线实体。 */
|
|
34
|
+
lineEntity: Cesium.Entity | null;
|
|
35
|
+
/** 最近一次挖填方分析结果。 */
|
|
36
|
+
result: CutFillResult | null;
|
|
37
|
+
/**
|
|
38
|
+
* 创建挖填方测量工具。
|
|
39
|
+
*
|
|
40
|
+
* @param map 地图实例。
|
|
41
|
+
*/
|
|
42
|
+
constructor(map: KeyMap);
|
|
43
|
+
private createPolylineEntity;
|
|
44
|
+
/**
|
|
45
|
+
* 根据分析区域面积计算采样精度。
|
|
46
|
+
*
|
|
47
|
+
* 面积越小采样精度越高,面积较大时降低精度以控制分析成本。
|
|
48
|
+
*
|
|
49
|
+
* @param area 分析区域面积,单位为平方米。
|
|
50
|
+
* @returns 适用于挖填方分析的采样精度。
|
|
51
|
+
*/
|
|
52
|
+
calcPrecision(area: number): number;
|
|
53
|
+
private createEndEntity;
|
|
54
|
+
protected registerEvents(): void;
|
|
55
|
+
private leftClickEvent;
|
|
56
|
+
private middleClickEvent;
|
|
57
|
+
private rightClickEvent;
|
|
58
|
+
private mouseMoveEvent;
|
|
59
|
+
/**
|
|
60
|
+
* 计算分析多边形面积。
|
|
61
|
+
*
|
|
62
|
+
* 输入坐标会转换为经纬度,首尾未闭合时会自动闭合,再通过 Turf 返回平方米面积。
|
|
63
|
+
*
|
|
64
|
+
* @param points 多边形顶点坐标。
|
|
65
|
+
* @returns 多边形面积,单位为平方米。
|
|
66
|
+
*/
|
|
67
|
+
calcArea(points: Cesium.Cartesian3[]): number;
|
|
68
|
+
protected onDeactivate(): void;
|
|
69
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import type KeyMap from '../map';
|
|
2
|
+
import * as Cesium from 'cesium';
|
|
3
|
+
import BaseMeasure from './baseMeasure';
|
|
4
|
+
/**
|
|
5
|
+
* 距离测量工具。
|
|
6
|
+
*
|
|
7
|
+
* 左键添加折线节点,鼠标移动预览下一段距离,右键撤销上一个节点,中键结束测量并固定最终折线和距离标签。
|
|
8
|
+
*/
|
|
9
|
+
export default class MeasureDistance extends BaseMeasure<() => void> {
|
|
10
|
+
/** 用户左键确认的折线节点。 */
|
|
11
|
+
positions: Cesium.Cartesian3[];
|
|
12
|
+
/** 用于鼠标移动预览的动态折线节点。 */
|
|
13
|
+
tempPositions: Cesium.Cartesian3[];
|
|
14
|
+
/** 已创建的节点标签和点实体。 */
|
|
15
|
+
vertexEntities: Cesium.Entity[];
|
|
16
|
+
/** 距离测量折线实体。 */
|
|
17
|
+
lineEntity: Cesium.Entity | null;
|
|
18
|
+
/** 鼠标移动过程中的临时节点实体。 */
|
|
19
|
+
moveVertexEntity: Cesium.Entity | null;
|
|
20
|
+
/** 当前累计测量距离,单位由内部距离计算工具决定。 */
|
|
21
|
+
measureDistance: number;
|
|
22
|
+
/**
|
|
23
|
+
* 创建距离测量工具。
|
|
24
|
+
*
|
|
25
|
+
* @param map 地图实例。
|
|
26
|
+
*/
|
|
27
|
+
constructor(map: KeyMap);
|
|
28
|
+
private createLineEntity;
|
|
29
|
+
private createVertex;
|
|
30
|
+
private createStartEntity;
|
|
31
|
+
private createEndEntity;
|
|
32
|
+
protected registerEvents(): void;
|
|
33
|
+
private leftClickEvent;
|
|
34
|
+
private mouseMoveEvent;
|
|
35
|
+
/**
|
|
36
|
+
* 更新鼠标移动时的距离预览线。
|
|
37
|
+
*
|
|
38
|
+
* 至少存在一个固定节点时,传入位置会作为临时终点加入预览坐标。
|
|
39
|
+
*
|
|
40
|
+
* @param position 当前鼠标拾取到的世界坐标。
|
|
41
|
+
*/
|
|
42
|
+
handleMoveEvent(position: Cesium.Cartesian3): void;
|
|
43
|
+
private middleClickEvent;
|
|
44
|
+
private rightClickEvent;
|
|
45
|
+
private getDistanceText;
|
|
46
|
+
private createLabelGraphics;
|
|
47
|
+
private createPointGraphics;
|
|
48
|
+
protected onActivate(): void;
|
|
49
|
+
protected onDeactivate(): void;
|
|
50
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import type KeyMap from '../map';
|
|
2
|
+
import * as Cesium from 'cesium';
|
|
3
|
+
import BaseMeasure from './baseMeasure';
|
|
4
|
+
/**
|
|
5
|
+
* 高度测量工具。
|
|
6
|
+
*
|
|
7
|
+
* 通过两个拾取点构造水平、垂直和直线三段辅助线,并分别显示距离标签。
|
|
8
|
+
*/
|
|
9
|
+
export default class MeasureHeight extends BaseMeasure<() => void> {
|
|
10
|
+
/** 用户选择的两个测量点。 */
|
|
11
|
+
positions: Cesium.Cartesian3[];
|
|
12
|
+
/** 高度测量使用的椭球体引用。 */
|
|
13
|
+
ellipsoid: Cesium.Ellipsoid | null;
|
|
14
|
+
/**
|
|
15
|
+
* 创建高度测量工具。
|
|
16
|
+
*
|
|
17
|
+
* @param map 地图实例。
|
|
18
|
+
*/
|
|
19
|
+
constructor(map: KeyMap);
|
|
20
|
+
protected registerEvents(): void;
|
|
21
|
+
private leftClickEvent;
|
|
22
|
+
private rightClickEvent;
|
|
23
|
+
/**
|
|
24
|
+
* 根据两个测量点绘制水平距离、垂直距离和直线距离辅助线及标签。
|
|
25
|
+
*
|
|
26
|
+
* 当测量点不足两个时不执行绘制。
|
|
27
|
+
*/
|
|
28
|
+
drawTriangleAndLabels(): void;
|
|
29
|
+
/**
|
|
30
|
+
* 创建一条测量辅助线实体。
|
|
31
|
+
*
|
|
32
|
+
* @param start 线段起点。
|
|
33
|
+
* @param end 线段终点。
|
|
34
|
+
* @param color 线段颜色,默认黄色。
|
|
35
|
+
*/
|
|
36
|
+
createLineEntity(start: Cesium.Cartesian3, end: Cesium.Cartesian3, color?: Cesium.Color): void;
|
|
37
|
+
/**
|
|
38
|
+
* 在指定位置添加测量标签。
|
|
39
|
+
*
|
|
40
|
+
* @param position 标签所在的世界坐标。
|
|
41
|
+
* @param text 标签显示文本。
|
|
42
|
+
*/
|
|
43
|
+
addLabel(position: Cesium.Cartesian3, text: string): void;
|
|
44
|
+
private createPointEntity;
|
|
45
|
+
private getDistanceText;
|
|
46
|
+
protected onDeactivate(): void;
|
|
47
|
+
}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import KeyMap from '../map';
|
|
2
|
+
import * as Cesium from 'cesium';
|
|
3
|
+
import { BasePrimitiveOptions } from './basePrimitive';
|
|
4
|
+
/**
|
|
5
|
+
* 3D Tiles 单体化分类图元。
|
|
6
|
+
*
|
|
7
|
+
* 根据经纬度平面坐标和上下高度创建 Cesium `ClassificationPrimitive`,用于对 3D Tiles 指定区域进行分类显示。
|
|
8
|
+
*/
|
|
9
|
+
export default class ClassificationPrimitive implements BasePrimitiveOptions {
|
|
10
|
+
/** 分类图元唯一标识。 */
|
|
11
|
+
id: string;
|
|
12
|
+
/** 分类图元名称。 */
|
|
13
|
+
name: string;
|
|
14
|
+
/** 图元类型标识。 */
|
|
15
|
+
type: string;
|
|
16
|
+
/** 经纬度平面坐标数组,格式与 `Cesium.Cartesian3.fromDegreesArray` 一致。 */
|
|
17
|
+
coordinates: number[];
|
|
18
|
+
/** 分类体顶部海拔高度。 */
|
|
19
|
+
maxHeight: number;
|
|
20
|
+
/** 分类体底部海拔高度。 */
|
|
21
|
+
minHeight: number;
|
|
22
|
+
private map;
|
|
23
|
+
/** 调用方附加的业务数据。 */
|
|
24
|
+
info: any;
|
|
25
|
+
/** 更新分类图元时使用的 CSS 颜色字符串。 */
|
|
26
|
+
color: string;
|
|
27
|
+
/** 当前 Cesium 分类图元实例。 */
|
|
28
|
+
clPrimitive: Cesium.ClassificationPrimitive | null;
|
|
29
|
+
/**
|
|
30
|
+
* 创建单体化分类图元。
|
|
31
|
+
*
|
|
32
|
+
* @param opt - 分类图元配置项。
|
|
33
|
+
* @param opt.id - 图元唯一标识。
|
|
34
|
+
* @param opt.name - 图元名称;未传入时自动生成。
|
|
35
|
+
* @param opt.coordinates - 经纬度平面坐标数组。
|
|
36
|
+
* @param opt.maxHeight - 分类体顶部海拔高度。
|
|
37
|
+
* @param opt.minHeight - 分类体底部海拔高度。
|
|
38
|
+
* @param opt.info - 调用方附加的业务数据。
|
|
39
|
+
* @param opt.color - CSS 颜色字符串。
|
|
40
|
+
*/
|
|
41
|
+
constructor(opt: {
|
|
42
|
+
id: string;
|
|
43
|
+
name?: string;
|
|
44
|
+
coordinates: number[];
|
|
45
|
+
maxHeight: number;
|
|
46
|
+
minHeight: number;
|
|
47
|
+
info?: any;
|
|
48
|
+
color?: string;
|
|
49
|
+
});
|
|
50
|
+
/**
|
|
51
|
+
* 将分类图元添加到地图场景和资源管理器中。
|
|
52
|
+
*
|
|
53
|
+
* @param map - 地图实例。
|
|
54
|
+
*/
|
|
55
|
+
add(map: KeyMap): void;
|
|
56
|
+
/** 从地图场景和资源管理器中移除当前分类图元。 */
|
|
57
|
+
destroy(): void;
|
|
58
|
+
/** 重新创建 Cesium 分类图元以应用当前坐标、高度和颜色配置。 */
|
|
59
|
+
update(): void;
|
|
60
|
+
/**
|
|
61
|
+
* 设置分类图元颜色。
|
|
62
|
+
*
|
|
63
|
+
* Cesium 不能直接修改已有 `geometryInstances`,因此会通过重建图元来应用颜色。
|
|
64
|
+
*
|
|
65
|
+
* @param c - CSS 颜色字符串,例如 `rgba(100, 101, 255, 0.8)`。
|
|
66
|
+
*/
|
|
67
|
+
setColor(c: string): void;
|
|
68
|
+
/** 显示当前 Cesium 分类图元。 */
|
|
69
|
+
show(): void;
|
|
70
|
+
/** 隐藏当前 Cesium 分类图元。 */
|
|
71
|
+
hide(): void;
|
|
72
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { GraphicLayer } from '../layer';
|
|
2
|
+
import type { WGS84Pos } from '../types';
|
|
3
|
+
import * as Cesium from 'cesium';
|
|
4
|
+
import BasePrimitive, { BasePrimitiveOptions } from './basePrimitive';
|
|
5
|
+
/** 管线图元配置项。 */
|
|
6
|
+
export interface TubePrimitiveOptions extends BasePrimitiveOptions {
|
|
7
|
+
/** 管线中心线的 WGS84 坐标点;未传入时使用空路径。 */
|
|
8
|
+
positions?: WGS84Pos[];
|
|
9
|
+
/** 管线圆形截面的半径。 */
|
|
10
|
+
radius?: number;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* 管线 Primitive 图元。
|
|
14
|
+
*
|
|
15
|
+
* 通过 Cesium `PolylineVolumeGeometry` 按路径生成圆形截面的管线体。该类在模块出口中以 `TubePrimitive` 名称导出。
|
|
16
|
+
*/
|
|
17
|
+
export default class primitive extends BasePrimitive {
|
|
18
|
+
/** 图元类型标识。 */
|
|
19
|
+
readonly type: 'tube';
|
|
20
|
+
/** 转换后的管线路径坐标。 */
|
|
21
|
+
positions: Cesium.Cartesian3[];
|
|
22
|
+
/** 管线圆形截面的半径。 */
|
|
23
|
+
radius: number | undefined;
|
|
24
|
+
/** 管线默认颜色配置;当前几何实例颜色由 Cesium 随机色生成逻辑决定。 */
|
|
25
|
+
color: string;
|
|
26
|
+
/**
|
|
27
|
+
* 创建管线图元。
|
|
28
|
+
*
|
|
29
|
+
* @param opt - 管线图元配置项。
|
|
30
|
+
*/
|
|
31
|
+
constructor(opt: TubePrimitiveOptions);
|
|
32
|
+
/**
|
|
33
|
+
* 将管线图元添加到图层和地图场景中。
|
|
34
|
+
*
|
|
35
|
+
* @param layer - 承载当前图元的图形图层。
|
|
36
|
+
*/
|
|
37
|
+
add(layer: GraphicLayer): void;
|
|
38
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import type { GraphicLayer } from '../layer';
|
|
2
|
+
import type { WGS84Pos } from '../types';
|
|
3
|
+
import * as Cesium from 'cesium';
|
|
4
|
+
import BasePrimitive, { BasePrimitiveOptions } from './basePrimitive';
|
|
5
|
+
/** 墙体图元配置项。 */
|
|
6
|
+
export interface WallPrimitiveOptions extends BasePrimitiveOptions {
|
|
7
|
+
/** 墙体路径的 WGS84 坐标点。 */
|
|
8
|
+
positions: WGS84Pos[];
|
|
9
|
+
/** 墙体顶部相对底部的高度差,默认 `50.0`。 */
|
|
10
|
+
diffHeight?: number;
|
|
11
|
+
/** 墙体材质;传入后使用 Cesium `MaterialAppearance`。 */
|
|
12
|
+
material?: Cesium.Material;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* 墙体 Primitive 图元。
|
|
16
|
+
*
|
|
17
|
+
* 通过 Cesium `WallGeometry` 按路径生成具有最小高度和最大高度的墙体。
|
|
18
|
+
*/
|
|
19
|
+
export default class WallPrimitive extends BasePrimitive {
|
|
20
|
+
/** 图元类型标识。 */
|
|
21
|
+
readonly type: 'wall';
|
|
22
|
+
/** 转换后的墙体路径坐标。 */
|
|
23
|
+
positions: Cesium.Cartesian3[];
|
|
24
|
+
/** 墙体顶部相对底部的高度差。 */
|
|
25
|
+
diffHeight: number;
|
|
26
|
+
/** 墙体底部高度,取第一个输入点的高度,缺省为 `0`。 */
|
|
27
|
+
minHeight: number;
|
|
28
|
+
/** 墙体顶部高度,等于 `minHeight + diffHeight`。 */
|
|
29
|
+
maxHeight: number;
|
|
30
|
+
/** 墙体材质;未传入时使用按实例颜色的外观。 */
|
|
31
|
+
material: Cesium.Material | null;
|
|
32
|
+
/** 墙体默认颜色配置;当前几何实例颜色由 Cesium 随机色生成逻辑决定。 */
|
|
33
|
+
color: string;
|
|
34
|
+
/**
|
|
35
|
+
* 创建墙体图元。
|
|
36
|
+
*
|
|
37
|
+
* @param opt - 墙体图元配置项。
|
|
38
|
+
*/
|
|
39
|
+
constructor(opt: WallPrimitiveOptions);
|
|
40
|
+
/**
|
|
41
|
+
* 将墙体图元添加到图层和地图场景中。
|
|
42
|
+
*
|
|
43
|
+
* @param layer - 承载当前图元的图形图层。
|
|
44
|
+
*/
|
|
45
|
+
add(layer: GraphicLayer): void;
|
|
46
|
+
private setHeightsArray;
|
|
47
|
+
}
|