cmap-core 0.0.1 → 0.0.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,12 +1,14 @@
1
1
  import { BBox } from 'rbush';
2
2
  import { default as default_2 } from 'rbush';
3
3
  import { default as default_3 } from 'eventemitter3';
4
+ import { Feature } from 'geojson';
4
5
  import type * as GeoJSON_2 from 'geojson';
5
6
  import { LayerSpecification } from 'mapbox-gl';
6
7
  import { LngLat } from 'mapbox-gl';
7
8
  import { Map as Map_2 } from 'mapbox-gl';
8
9
  import { MapMouseEvent } from 'mapbox-gl';
9
10
  import { MapOptions } from 'mapbox-gl';
11
+ import { MultiLineString } from 'geojson';
10
12
  import { Point } from 'mapbox-gl';
11
13
  import { Source } from 'mapbox-gl';
12
14
  import { SourceSpecification } from 'mapbox-gl';
@@ -20,6 +22,7 @@ export declare class AisShip extends BaseShip<IAisShipOptions> {
20
22
  onRemove(): void;
21
23
  get id(): string | number;
22
24
  get updateStatus(): UPDATE_STATUS;
25
+ getIconName(): string;
23
26
  position(): LngLat;
24
27
  get direction(): number;
25
28
  get orientation(): Orientation;
@@ -28,6 +31,8 @@ export declare class AisShip extends BaseShip<IAisShipOptions> {
28
31
  remove(): void;
29
32
  setTooltip(): void;
30
33
  update(options: IAisShipOptions): void;
34
+ select(): void;
35
+ unselect(): void;
31
36
  focus(): void;
32
37
  unfocus(): void;
33
38
  icon(): GeoJSON_2.Feature<GeoJSON_2.Point, IAisShipOptions>;
@@ -58,10 +63,12 @@ export declare abstract class BaseShip<T extends IBaseShipOptions> extends Modul
58
63
  visible: boolean;
59
64
  protected constructor(map: Map_2, options: T);
60
65
  destroy(): void;
66
+ get isFocus(): boolean;
61
67
  abstract onAdd(): void;
62
68
  abstract onRemove(): void;
63
69
  abstract get id(): IBaseShipOptions['id'];
64
70
  abstract get updateStatus(): UPDATE_STATUS;
71
+ abstract getIconName(): string;
65
72
  abstract position(): IBaseShipOptions['position'];
66
73
  abstract get direction(): IBaseShipOptions['direction'];
67
74
  abstract get orientation(): Orientation;
@@ -70,6 +77,8 @@ export declare abstract class BaseShip<T extends IBaseShipOptions> extends Modul
70
77
  abstract remove(): void;
71
78
  abstract setTooltip(): void;
72
79
  abstract update(options: IAisShipOptions): void;
80
+ abstract select(): void;
81
+ abstract unselect(): void;
73
82
  abstract focus(): void;
74
83
  abstract unfocus(): void;
75
84
  abstract icon(): GeoJSON_2.Feature<GeoJSON_2.Point, T>;
@@ -203,20 +212,74 @@ export declare class Context {
203
212
  readonly events: default_3;
204
213
  readonly register: ResourceRegister;
205
214
  readonly iconManage: IconManager;
215
+ readonly focus: Focus;
206
216
  constructor(options: IContextOptions);
207
217
  destroy(): void;
208
218
  }
209
219
 
210
220
  declare abstract class EventState extends Module {
221
+ private status;
222
+ static ON: EventStatus;
223
+ static OFF: EventStatus;
211
224
  protected constructor(map: Map_2);
212
225
  abstract onAdd(): void;
213
226
  abstract onRemove(): void;
227
+ switch(): EventStatus;
228
+ abstract on(): void;
229
+ abstract off(): void;
230
+ }
231
+
232
+ declare enum EventStatus {
233
+ ON = "On",
234
+ OFF = "Off"
235
+ }
236
+
237
+ declare class Focus extends default_3 {
238
+ private readonly map;
239
+ focusItems: FocusItem[];
240
+ zoomendFunc: () => void;
241
+ constructor(map: Map_2);
242
+ get features(): FocusItem['feature'][];
243
+ onAdd(): void;
244
+ onRemove(): void;
245
+ set(feature: Feature, options?: IFocusOptions): string | number;
246
+ get(id: string): FocusItem | undefined;
247
+ remove(id: string): void;
248
+ removeAll(): void;
249
+ render(): void;
250
+ private _zoomend;
251
+ private _onHandle;
252
+ /**
253
+ * 通用聚焦边框生成方法
254
+ * @param feature 目标要素 (Point | LineString | Polygon)
255
+ * @param options 配置项
256
+ * @returns 聚焦框 Feature
257
+ */
258
+ getFocusBorder(feature: Feature, options?: IFocusOptions): Feature<MultiLineString, {
259
+ id: string;
260
+ }>;
261
+ /**
262
+ * 辅助:向外扩展 BBox (米 -> 经纬度)
263
+ */
264
+ private _expandBBox;
265
+ /**
266
+ * 核心绘制:根据 BBox 和 手臂物理长度 生成括号坐标
267
+ * (这是你原来那个方法的纯净版,去掉了业务逻辑,只负责画图)
268
+ */
269
+ private _createBracketGeometry;
270
+ }
271
+
272
+ declare interface FocusItem {
273
+ id: string | number;
274
+ border: Feature<MultiLineString>;
275
+ feature: Feature;
276
+ options?: IFocusOptions;
214
277
  }
215
278
 
216
279
  declare interface IAisShipOptions extends IBaseShipOptions {
217
280
  outLine?: boolean;
218
281
  readonly type: 'Ais';
219
- updateStatus: UPDATE_STATUS;
282
+ updateStatus?: UPDATE_STATUS;
220
283
  }
221
284
 
222
285
  declare interface IBaseShipOptions {
@@ -267,7 +330,7 @@ export declare class IconManager {
267
330
  addSvg(icon: SvgIcon): Promise<void>;
268
331
  add(icon: Icon): Promise<result>;
269
332
  has(name: Icon['name']): boolean;
270
- getImage(name: string): Image_2;
333
+ getImage(name: string): Image_2 | undefined;
271
334
  update(icon: Icon): Promise<result>;
272
335
  delete(name: string): void;
273
336
  success(icon: Icon): result;
@@ -278,6 +341,12 @@ declare interface IContextOptions {
278
341
  map: Map_2;
279
342
  }
280
343
 
344
+ declare interface IFocusOptions {
345
+ size?: number;
346
+ padding?: number;
347
+ armLength?: number;
348
+ }
349
+
281
350
  declare interface Image_2 {
282
351
  width: number;
283
352
  height: number;
@@ -323,6 +392,8 @@ declare class ResidentEvent extends EventState {
323
392
  protected _leave: OmitThisParameter<(e: MapMouseEvent) => void>;
324
393
  protected _zoomEnd: () => void;
325
394
  constructor(map: Map_2, ships?: AisShip[]);
395
+ on(): void;
396
+ off(): void;
326
397
  onAdd(): void;
327
398
  onRemove(): void;
328
399
  add(ship: AisShip): void;
@@ -410,6 +481,9 @@ export declare class Ship extends Module {
410
481
  remove(id: IAisShipOptions['id']): void;
411
482
  removeAll(): void;
412
483
  render(): void;
484
+ get(id: IAisShipOptions['id']): AisShip | undefined;
485
+ select(id: IAisShipOptions['id']): void;
486
+ unselect(id: IAisShipOptions['id']): void;
413
487
  }
414
488
 
415
489
  declare interface StyleImageMetadata {