1 | import { parse } from './fsw-parse';
|
2 | import { parse as parseStyle } from '../style/style-parse';
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 | const info = (fsw) => {
|
24 | let lanes = {
|
25 | "B": 0,
|
26 | "L": -1,
|
27 | "M": 0,
|
28 | "R": 1
|
29 | }
|
30 | let parsed = parse.sign(fsw);
|
31 | let width, height, segment, x1, x2, y1, y2, lane;
|
32 | if (parsed.spatials) {
|
33 | x1 = Math.min(...parsed.spatials.map(spatial => spatial.coord[0]));
|
34 | x2 = parsed.max[0];
|
35 | width = x2 - x1;
|
36 | y1 = Math.min(...parsed.spatials.map(spatial => spatial.coord[1]));
|
37 | y2 = parsed.max[1];
|
38 | height = y2 - y1;
|
39 | segment = 'sign';
|
40 | lane = parsed.box;
|
41 | } else {
|
42 | parsed = parse.symbol(fsw);
|
43 | lane = "M";
|
44 | if (parsed.coord){
|
45 | x1 = parsed.coord[0];
|
46 | width = (500 - x1) * 2;
|
47 | y1 = parsed.coord[1];
|
48 | height = (500 - y1) * 2;
|
49 | segment = 'symbol';
|
50 | } else {
|
51 | x1 = 490;
|
52 | width = 20;
|
53 | y1 = 490;
|
54 | height = 20;
|
55 | segment = 'none';
|
56 | }
|
57 | }
|
58 | let style = parseStyle(parsed.style);
|
59 | let zoom = style.zoom || 1;
|
60 | let padding = style.padding || 0;
|
61 | return {
|
62 | minX: x1,
|
63 | minY: y1,
|
64 | width: width,
|
65 | height: height,
|
66 | segment: segment,
|
67 | lane: lanes[lane],
|
68 | padding: padding,
|
69 | zoom: zoom
|
70 | };
|
71 | }
|
72 |
|
73 | export { info } |
\ | No newline at end of file |