@poor-knight/cesium-utils 0.4.7 → 0.5.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.
@@ -1,3 +1,4 @@
1
+ import { Cartesian3 } from 'cesium';
1
2
  import * as Cesium from 'cesium';
2
3
  import { default as default_2 } from 'eventemitter3';
3
4
  import { EventEmitter } from 'eventemitter3';
@@ -64,6 +65,144 @@ export declare function ListenLeftClick(viewer: Cesium.Viewer): default_2<{
64
65
 
65
66
  declare type Matrix4Like = Cesium.Matrix4 | Record<string, number> | number[];
66
67
 
68
+ export declare class PolygonDrawer {
69
+ private _viewer;
70
+ private _callBack;
71
+ private _posChange;
72
+ private _pointGeometry;
73
+ private _activePoint;
74
+ private _polygon;
75
+ private _positions;
76
+ private _status;
77
+ private _mouseDelta;
78
+ private _lastClickPosition;
79
+ private _options;
80
+ private _subscriber;
81
+ private _events;
82
+ private _labels;
83
+ private _tips;
84
+ private _hoveredPoint;
85
+ get status(): "INIT" | "START" | "END" | "EDITING" | "DESTROY";
86
+ get isDestroy(): boolean;
87
+ /**
88
+ * Create a PolygonDrawer Class
89
+ * @param viewer cesium viewer
90
+ * @param [options.accuracy] lonlat number accuracy.
91
+ * @param [options.once] If continue to draw the next polygon.
92
+ * @param [options.retainGeo] If retain polygon geo after drawing complete.
93
+ * @param [options.positions] The object onto which to store the position Array.
94
+ * @param [options.callback] callback funciton after drawing complete.
95
+ * @param [options.posChange] callback funciton after position array changed.
96
+ * @param [options.tips] tip labels text config.
97
+ * @example
98
+ * const DrawTool = new PolygonDrawer(viewer, {
99
+ callback: (result) => {
100
+ console.log(result);
101
+ },
102
+ posChange: (coors) => {
103
+ console.log(coors)
104
+ },
105
+ tips: {
106
+ leftClick: intl.formatMessage({ id: 'drawer.leftClick' }),
107
+ rightClick: intl.formatMessage({ id: 'drawer.rightClick' }),
108
+ doubleClick: intl.formatMessage({ id: 'drawer.doubleClick' }),
109
+ edit: intl.formatMessage({ id: 'drawer.edit' }),
110
+ }
111
+ })
112
+ */
113
+ constructor(viewer: Viewer, options?: PolygonDrawerOptions);
114
+ /**
115
+ * 更新标签信息
116
+ * @param options 标签位置、标签文字, 不填则按照默认逻辑更新
117
+ */
118
+ private updateLabel;
119
+ /**
120
+ * positions数组改变后调用回调函数
121
+ */
122
+ private handlePosChange;
123
+ protected drawPoint(position: Cartesian3): Cesium.Entity;
124
+ private updatePointSize;
125
+ /**
126
+ * 点Entity的左键点击事件
127
+ */
128
+ private onMouseClickPoint;
129
+ /**
130
+ * 绘制多边形
131
+ */
132
+ private drawShape;
133
+ /**
134
+ * 鼠标移动时改变活动点的位置和position坐标串
135
+ */
136
+ private handleMouseMove;
137
+ /**
138
+ * 鼠标左键监听事件,点击添加点和坐标,并设置新的活动点
139
+ */
140
+ private handleMouseLeftClick;
141
+ /**
142
+ * 添加一个点
143
+ * @param index 点的下标
144
+ * @param pos 点的经纬度
145
+ */
146
+ addOnePosition: (index: number, pos: number[]) => boolean;
147
+ /**
148
+ * 改变一个点的坐标信息
149
+ * @param index 点下标
150
+ * @param pos 位置[经纬度]
151
+ * @returns boolean
152
+ */
153
+ changeOnePosition: (index: number, pos: number[]) => boolean;
154
+ /**
155
+ * 移除一个点
156
+ * @param index 点的下标
157
+ * @returns {boolean} 是否移除成功
158
+ */
159
+ removeOnePosition: (index: number) => boolean;
160
+ /**
161
+ * 将一个点设置为活动点
162
+ * @param index 点的下标
163
+ */
164
+ activeOnePosition: (index: number) => void;
165
+ private handleMouseRightClick;
166
+ /**
167
+ * 开始绘制多边形
168
+ */
169
+ start(): void;
170
+ private removePolygon;
171
+ /**
172
+ * 停止绘制多边形
173
+ * @param removePoint 是否移除控制点,默认true
174
+ */
175
+ private stop;
176
+ /**
177
+ * cesium坐标转经纬度
178
+ * @param cartesian
179
+ * @returns [lon, lat]
180
+ */
181
+ cartesian2lonlat: (cartesian: Cartesian3) => number[];
182
+ /**
183
+ * 结束绘制
184
+ * @returns boolean
185
+ */
186
+ private endDraw;
187
+ clear(): void;
188
+ destory(): void;
189
+ }
190
+
191
+ declare type PolygonDrawerOptions = {
192
+ accuracy?: number;
193
+ once?: boolean;
194
+ retainGeo?: boolean;
195
+ positions?: Cartesian3[];
196
+ callback?: (coors: number[][]) => void;
197
+ posChange?: (coors: number[][]) => void;
198
+ tips?: {
199
+ leftClick?: string;
200
+ rightClick?: string;
201
+ doubleClick?: string;
202
+ edit?: string;
203
+ };
204
+ };
205
+
67
206
  /** 弹窗控制器 */
68
207
  export declare class PopupCtrl extends default_2<{
69
208
  onMount: (id: string | number) => void;