@poor-knight/cesium-utils 0.4.8 → 0.5.2

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