@teeechina/teee-map 0.0.6 → 0.0.7

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/index.d.ts CHANGED
@@ -1,91 +1,403 @@
1
- import type { Map as MaplibreMap, LngLat, MapGeoJSONFeature, LngLatLike } from 'maplibre-gl';
2
- import type { LayerSpecification, SourceSpecification } from 'maplibre-gl';
3
-
4
- export type MapType = 'graph' | 'geom' | 'ctc' | 'raster';
5
-
6
- export type LayerType = 'background' | 'signal' | 'track' | 'track_circuit' | 'bumper' | 'switch' | 'switch_loc' | 'insulation' | 'label' | 'prevention';
7
-
8
- export interface MapForgeConfig {
9
- id: string;
10
- subSourceId?: string;
11
- sourceUrl?: string;
12
- geojsonData?: object | string;
13
- layers?: LayerType[];
14
- sourceLayers?: string[];
15
- center?: LngLatLike;
16
- zoom?: number;
17
- }
18
-
19
- export interface MapParams {
20
- id: string;
21
- source: SourceSpecification;
22
- subSourceId?: string;
23
- subSource?: SourceSpecification;
24
- layers?: LayerSpecification[];
25
- }
26
-
27
- export interface IconType {
28
- id: string;
29
- image: HTMLImageElement;
30
- }
31
-
32
- export interface stateType {
33
- state?: string;
34
- select?: boolean;
35
- visiable?: boolean;
36
- subState1?: any;
37
- subState2?: any;
38
- subState3?: any;
39
- }
40
-
41
- export interface layerSettingItem {
42
- key: string;
43
- label: string;
44
- checked: boolean;
45
- disabled: boolean;
46
- }
47
-
48
- export interface FeatureInteractionPayload {
49
- type: LayerType;
50
- code: string;
51
- state: stateType;
52
- }
53
-
54
- export interface AppEvents {
55
- 'map:feature-click': FeatureInteractionPayload;
56
- }
57
-
58
- export declare class TeeeMap {
59
- public map: MaplibreMap;
60
- public mapConfigs: MapForgeConfig;
61
- public stashFeatures: Map<any, any>;
62
-
63
- constructor(container: string | HTMLElement);
64
-
65
- addGeoJsonSource(id: string, data?: any): void;
66
- removeSource(id: string): void;
67
- updateGeoJsonSource(id: string, data: any): void;
68
- addVectorTileSource(id: string, url: string): void;
69
- addRasterTileSource(id: string, url: string): void;
70
- addGeoJsonLayer(layerId: string, sourceId: string, type?: 'fill' | 'line' | 'circle' | 'symbol', paint?: any, layout?: any): void;
71
- updateLayerStyle(id: string, paint: any): void;
72
- removeLayer(id: string): void;
73
- onFeatureClick(layerIds: string | string[], callback: (feature: MapGeoJSONFeature, lngLat: LngLat) => void): void;
74
-
75
- destroy(): void;
76
- initState(): void;
77
-
78
- initMap(mapParams: MapParams): void;
79
- createCTCMap(stcode: string, url: string, layers: LayerType[]): void;
80
- createRSWPMap(url: string): void;
81
- createGraphMap(stcode: string, url: string, layers: LayerType[]): void;
82
- createGeomMap(stcode: string, url: string, layers: LayerType[]): void;
83
- createMbtilesMap(mbtileDBClient: any, url: string, layers: LayerType[]): void;
84
- createRasterMap(url: string): void;
85
- getMap(): MaplibreMap;
86
- getMapConfigs(): MapForgeConfig;
87
- stashAllFeature(): void;
88
- updateFeatureState(code: string | number, state: any): void;
89
- }
90
-
91
- export default TeeeMap;
1
+ import type { Map as MaplibreMap, LngLat, GeoJSONFeature, LngLatLike } from 'maplibre-gl';
2
+ import type { LayerSpecification, SourceSpecification } from 'maplibre-gl';
3
+
4
+ // ─────────────────────────────────────────────
5
+ // 基础枚举 & 联合类型
6
+ // ─────────────────────────────────────────────
7
+
8
+ export type MapType = 'graph' | 'geom' | 'ctc' | 'raster';
9
+
10
+ export type LayerType =
11
+ | 'background'
12
+ | 'signal'
13
+ | 'track'
14
+ | 'track_circuit'
15
+ | 'bumper'
16
+ | 'switch'
17
+ | 'switch_loc'
18
+ | 'insulation'
19
+ | 'label'
20
+ | 'prevention';
21
+
22
+ // ─────────────────────────────────────────────
23
+ // 联锁枚举
24
+ // ─────────────────────────────────────────────
25
+
26
+ /** 联锁信号机状态 */
27
+ export enum InterLockSignal {
28
+ RedLight = 1,
29
+ GreenLight = 2,
30
+ WhiteLight = 3,
31
+ BlueLight = 4,
32
+ Unknown = 5,
33
+ }
34
+
35
+ /** 联锁电路区段状态 */
36
+ export enum InterLockCircuit {
37
+ RedCircuit = 1,
38
+ WhiteCircuit = 2,
39
+ EqualRedCircuit = 3,
40
+ GreyCircuit = 4,
41
+ GreenCircuit = 5,
42
+ }
43
+
44
+ /** 联锁道岔状态 */
45
+ export enum InterLockSwitchloc {
46
+ NormalPosition = 2,
47
+ ReversePosition = 3,
48
+ NeutralPosition = 4,
49
+ }
50
+
51
+ /** 闭塞信号 */
52
+ export enum BsSignal {
53
+ COME_GREEN = 0,
54
+ COME_YELLOW = 1,
55
+ COME_RED = 2,
56
+ GO_GREEN = 3,
57
+ GO_YELLOW = 4,
58
+ GO_RED = 5,
59
+ LOCK = 6,
60
+ EMERGENCY = 7,
61
+ RESET = 8,
62
+ }
63
+
64
+ /** 防控点类型枚举 */
65
+ export enum PreventionTypes {
66
+ NULL = 0,
67
+ BUMPER = 1,
68
+ CONTACTLINEEND = 2,
69
+ FIXEDDERAILER = 3,
70
+ CONTACTLINENOSTOP = 4,
71
+ CONTACTLINENOSTOPIN = 5,
72
+ OTHERPROMPT = 6,
73
+ OTHERBRAKE = 7,
74
+ ONESTOP = 8,
75
+ SPEEDLIMITED = 9,
76
+ SPEEDNOTICE = 10,
77
+ CROSSSPEEDLIMITED = 11,
78
+ CONTACTLINEPSS = 12,
79
+ SSG = 13,
80
+ CONTACTLINEPSSIN = 14,
81
+ CONTACTLINENOAREA = 15,
82
+ HIGHPOSTSIGNAL = 16,
83
+ RESCUEVEHICLE = 17,
84
+ RAILWAYCROSS = 18,
85
+ TRAIN = 19,
86
+ STATIONBOUND = 20,
87
+ SHORTPOSTSIGNAL = 21,
88
+ BRIDGE = 22,
89
+ WHITE = 23,
90
+ WHITEBLUE = 24,
91
+ BLUE = 25,
92
+ BLUEWHITE = 26,
93
+ SLOPE = 27,
94
+ PEOPLE = 28,
95
+ TUNNEL = 29,
96
+ DANGER = 30,
97
+ SIGNAL = 31,
98
+ SWERVE = 32,
99
+ SWITCH = 33,
100
+ ISOLATE = 35,
101
+ TGQ = 47,
102
+ BLOCKLINE = 50,
103
+ WORKAREA = 51,
104
+ ROUTELINE = 52,
105
+ PARK = 53,
106
+ WORKBUOND = 54,
107
+ WORKBUONDCROSS = 55,
108
+ LEFTHIGHPLATFORM = 61,
109
+ RIGHTHIGHPLATFORM = 62,
110
+ BOTHSIDEHIGHPLATFORM = 63,
111
+ DOOR = 87,
112
+ ISOLATESWITCH = 100,
113
+ OTHER = 95,
114
+ SIDE = 253,
115
+ NONE = 254,
116
+ MAX = 255,
117
+ FOULINGPOST = 38,
118
+ CUNCHE = 39,
119
+ STATIONBOUNDEXTEND = 40,
120
+ RED = 41,
121
+ GREEN = 42,
122
+ YELLOW = 43,
123
+ }
124
+
125
+ // ─────────────────────────────────────────────
126
+ // 地图配置接口
127
+ // ─────────────────────────────────────────────
128
+
129
+ /** MapForge 生成的地图初始化配置 */
130
+ export interface MapForgeConfig {
131
+ id: string;
132
+ sourceUrl?: string;
133
+ subSourceId?: string;
134
+ subSourceUrl?: string;
135
+ layers?: LayerType[];
136
+ sourceLayers?: string[];
137
+ subLayers?: LayerType[];
138
+ subSourceLayers?: string[];
139
+ geojsonData?: object | string;
140
+ center?: LngLatLike;
141
+ zoom?: number;
142
+ }
143
+
144
+ /** 传递给 initMap 的参数结构 */
145
+ export interface MapParams {
146
+ id: string;
147
+ source: SourceSpecification;
148
+ subSourceId?: string;
149
+ subSource?: SourceSpecification;
150
+ layers?: LayerSpecification[];
151
+ subLayers?: LayerSpecification[];
152
+ }
153
+
154
+ /** 图标配置 */
155
+ export interface IconType {
156
+ id: string;
157
+ image: HTMLImageElement;
158
+ }
159
+
160
+ /** 要素状态配置 */
161
+ export interface stateType {
162
+ /** 股道:封锁(1) / 停电(2) / 无接触网(3) */
163
+ state?: string;
164
+ /** 选中状态 */
165
+ select?: boolean;
166
+ /** 是否可见 */
167
+ visiable?: boolean;
168
+ /** 信号机(钮封) / 道岔:占用(3) / 锁闭(2) */
169
+ subState1?: any;
170
+ /** 信号机(灭灯) / 道岔:单锁(1) / 解锁 */
171
+ subState2?: any;
172
+ /** 信号机(暂无) / 道岔:单封(1) / 解封 */
173
+ subState3?: any;
174
+ }
175
+
176
+ export interface layerSettingItem {
177
+ key: string;
178
+ label: string;
179
+ checked: boolean;
180
+ disabled: boolean;
181
+ }
182
+
183
+ export interface FeatureInteractionPayload {
184
+ type: LayerType;
185
+ code: string;
186
+ state: stateType;
187
+ }
188
+
189
+ export interface AppEvents {
190
+ 'map:inited': any;
191
+ 'map:feature-click': FeatureInteractionPayload;
192
+ 'map:path-selected': any;
193
+ }
194
+
195
+ // ─────────────────────────────────────────────
196
+ // 绘图工具
197
+ // ─────────────────────────────────────────────
198
+
199
+ export type DrawMode =
200
+ | 'point'
201
+ | 'linestring'
202
+ | 'polygon'
203
+ | 'rectangle'
204
+ | 'angled-rectangle'
205
+ | 'sensor'
206
+ | 'sector'
207
+ | 'circle'
208
+ | 'freehand'
209
+ | 'freehand-linestring'
210
+ | 'select'
211
+ | 'render';
212
+
213
+ export interface ModeStyles {
214
+ filledColor?: string;
215
+ outlineColor?: string;
216
+ outlineWidth?: number;
217
+ markerColor?: string;
218
+ markerWidth?: number;
219
+ markerOutlineColor?: string;
220
+ }
221
+
222
+ export type DrawEventCallback = (features: GeoJSON.FeatureCollection) => void;
223
+ export type SelectEventCallback = (id: string | null) => void;
224
+
225
+ export declare class DrawTool {
226
+ constructor(mapSdk: TeeeMap);
227
+
228
+ addToMap(isOpen?: boolean): Promise<void>;
229
+ removeFromMap(): void;
230
+ changeMode(mode: DrawMode | 'undo' | 'redo' | 'download', styles?: ModeStyles): void;
231
+ setForcedCoordinate(coord: [number, number] | null): void;
232
+ setOnFinish(cb: DrawEventCallback): void;
233
+ setOnChange(cb: DrawEventCallback): void;
234
+ setOnDelete(cb: DrawEventCallback): void;
235
+ setOnSelect(cb: SelectEventCallback): void;
236
+ getFeatures(): GeoJSON.FeatureCollection;
237
+ addFeatures(features: GeoJSON.FeatureCollection): void;
238
+ clearFeatures(): void;
239
+ }
240
+
241
+ // ─────────────────────────────────────────────
242
+ // 联锁协议 & 可视化
243
+ // ─────────────────────────────────────────────
244
+
245
+ export interface InterlockItem {
246
+ name: string;
247
+ state: string;
248
+ }
249
+
250
+ export interface InterlockData {
251
+ signalInterlock: InterlockItem[];
252
+ switchInterlock: InterlockItem[];
253
+ circuitInterlock: InterlockItem[];
254
+ }
255
+
256
+ export declare class InterlockProtocol {
257
+ signalExist: boolean;
258
+ productInfo?: string;
259
+ stationCode?: string;
260
+ time?: string;
261
+
262
+ getProductInfo(): string | undefined;
263
+ getStCode(): string | undefined;
264
+ getInterlockInfo(): Map<string, InterlockData>;
265
+ isSignalExist(): boolean;
266
+ setYardSignal(signal: string): void;
267
+ }
268
+
269
+ export interface InsulationSignals {
270
+ upsignal: string | null;
271
+ downsignal: string | null;
272
+ }
273
+
274
+ export declare class InterLockInsulation {
275
+ setInsulation(features: GeoJSONFeature[]): void;
276
+ getSignalsByInsulation(id: string): InsulationSignals | undefined;
277
+ getInsulationBySignal(signalId: string): string | undefined;
278
+ }
279
+
280
+ export interface InterlockVisualizationGraphOptions {
281
+ mode: 'graph';
282
+ map: MaplibreMap;
283
+ sourceId: string;
284
+ sourceLayers: {
285
+ signal: string;
286
+ switch: string;
287
+ switch_loc: string;
288
+ track_circuit: string;
289
+ track: string;
290
+ insulation: string;
291
+ };
292
+ firstSwitches?: string[];
293
+ updateFeatureState?: (code: string | number, state: any) => void;
294
+ }
295
+
296
+ export interface InterlockVisualizationGeoJsonOptions {
297
+ mode: 'geojson';
298
+ map: MaplibreMap;
299
+ sourceIds: {
300
+ signal: string;
301
+ switch: string;
302
+ switch_loc: string;
303
+ track_circuit: string;
304
+ track: string;
305
+ insulation: string;
306
+ };
307
+ firstSwitches?: string[];
308
+ updateFeatureState?: (code: string | number, state: any) => void;
309
+ }
310
+
311
+ export interface InterlockVisualizationLegacyOptions {
312
+ map: MaplibreMap;
313
+ sourceId: string;
314
+ sourceLayers: {
315
+ signal: string;
316
+ switch: string;
317
+ switch_loc: string;
318
+ track_circuit: string;
319
+ track: string;
320
+ insulation: string;
321
+ };
322
+ firstSwitches?: string[];
323
+ updateFeatureState?: (code: string | number, state: any) => void;
324
+ }
325
+
326
+ export type InterlockVisualizationOptions =
327
+ | InterlockVisualizationGraphOptions
328
+ | InterlockVisualizationGeoJsonOptions
329
+ | InterlockVisualizationLegacyOptions;
330
+
331
+ export declare class InterLockVisualization {
332
+ constructor(options: InterlockVisualizationOptions);
333
+ setInterlockData(protocol: InterlockProtocol): void;
334
+ clear(): void;
335
+ }
336
+
337
+ // ─────────────────────────────────────────────
338
+ // TeeeMap 主类
339
+ // ─────────────────────────────────────────────
340
+
341
+ export declare class TeeeMap {
342
+ public map: MaplibreMap;
343
+ public mapConfigs: MapForgeConfig;
344
+ public stashFeatures: Map<any, any>;
345
+ /** 绘图工具(地图 load 事件后可用) */
346
+ public drawTool: DrawTool;
347
+
348
+ constructor(container: string | HTMLElement, mbtileDBClient?: any);
349
+
350
+ // ── 数据源管理 ──
351
+ addGeoJsonSource(id: string, data?: any): void;
352
+ removeSource(id: string): void;
353
+ updateGeoJsonSource(id: string, data: any): void;
354
+ addVectorTileSource(id: string, url: string): void;
355
+ addRasterTileSource(id: string, url: string): void;
356
+
357
+ // ── 图层管理 ──
358
+ addGeoJsonLayer(
359
+ layerId: string,
360
+ sourceId: string,
361
+ type?: 'fill' | 'line' | 'circle' | 'symbol',
362
+ paint?: any,
363
+ layout?: any,
364
+ ): void;
365
+ updateLayerStyle(id: string, paint: any): void;
366
+ removeLayer(id: string): void;
367
+
368
+ // ── 交互事件 ──
369
+ onFeatureClick(
370
+ layerIds: string | string[],
371
+ callback: (feature: GeoJSONFeature, lngLat: LngLat) => void,
372
+ ): void;
373
+
374
+ // ── 生命周期 ──
375
+ destroy(): void;
376
+ initState(): void;
377
+ initMap(mapParams: MapParams): void;
378
+
379
+ // ── 要素状态 ──
380
+ initCTCFeatureState(f: GeoJSONFeature): void;
381
+ initGraphFeatureState(f: GeoJSONFeature): void;
382
+ initGeoJsonFeatureState(f: GeoJSONFeature, layerType: string): void;
383
+ initGeoJsonState(): void;
384
+ stashAllFeature(): void;
385
+ updateFeatureState(code: string | number, state: any): void;
386
+
387
+ // ── 地图创建方法 ──
388
+ createCTCMap(stcode: string, url: string, layers: LayerType[]): void;
389
+ createRSWPMap(url: string): void;
390
+ createGraphMap(stcode: string, url: string, layers: LayerType[]): void;
391
+ createGeomMap(stcode: string, url: string, layers: LayerType[]): void;
392
+ createMbtilesMap(mbtileDBClient: any, url: string, layers: LayerType[]): void;
393
+ createRasterMap(url: string): void;
394
+ createGraphEncryptedMap(stcode: string, url: string, layers: LayerType[]): void;
395
+ createGeomEncryptedMap(stcode: string, url: string, layers: LayerType[]): void;
396
+ createCTCEncryptedMap(stcode: string, url: string, layers: LayerType[]): void;
397
+
398
+ // ── 其他工具方法 ──
399
+ getMap(): MaplibreMap;
400
+ getMapConfigs(): MapForgeConfig;
401
+ }
402
+
403
+ export default TeeeMap;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@teeechina/teee-map",
3
- "version": "0.0.6",
3
+ "version": "0.0.7",
4
4
  "description": "",
5
5
  "main": "dist/teee-map.umd.js",
6
6
  "module": "dist/teee-map.mjs",