Skip to content

Commit be6d269

Browse files
nicolaswurtzTguisnet
authored andcommitted
front: lpv: add design
1 parent 58d0186 commit be6d269

File tree

3 files changed

+96
-34
lines changed

3 files changed

+96
-34
lines changed

front/public/locales/fr/map-settings.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -29,5 +29,6 @@
2929
"geographic": "Géographique",
3030
"schematic": "Schématique"
3131
},
32-
"tvds": "Circuits de voie"
32+
"tvds": "Circuits de voie",
33+
"zone": "Zone"
3334
}

front/src/common/Map/Consts/colors.ts

+25-1
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,14 @@ const colors: Record<string, Theme> = {
3636
text: '#555555',
3737
halo: '#eee',
3838
},
39+
lpv: {
40+
pointtext: '#5b5b5b',
41+
pointhalo: '#ffffff',
42+
detailtext: '#555555',
43+
detailhalo: '#ffffff',
44+
text: '#4d4f53',
45+
halo: '#ffffff',
46+
},
3947
mapmarker: {
4048
text: '#0088ce',
4149
circle: '#0088ce',
@@ -98,7 +106,7 @@ const colors: Record<string, Theme> = {
98106
pointhalo: '#5b5b5b',
99107
detailtext: '#555555',
100108
detailhalo: '#ffffff',
101-
text: '#555555',
109+
text: '#4d4f53',
102110
halo: '#ffffff',
103111
},
104112
station: {
@@ -164,6 +172,14 @@ const colors: Record<string, Theme> = {
164172
text: '#4895ef',
165173
halo: '#0b011d',
166174
},
175+
lpv: {
176+
pointtext: '#eeeeee',
177+
pointhalo: '#3a86ff',
178+
detailtext: '#3a86ff',
179+
detailhalo: '#0b011d',
180+
text: '#3a86ff',
181+
halo: '#000000',
182+
},
167183
mapmarker: {
168184
text: '#ffaa39',
169185
circle: '#ffaa39',
@@ -292,6 +308,14 @@ const colors: Record<string, Theme> = {
292308
text: bpLight,
293309
halo: bpBg,
294310
},
311+
lpv: {
312+
pointtext: bpLight,
313+
pointhalo: bpBg,
314+
detailtext: bpLight,
315+
detailhalo: bpBg,
316+
text: bpLight,
317+
halo: bpBg,
318+
},
295319
mapmarker: {
296320
text: bpMedium,
297321
circle: bpLight,

front/src/common/Map/Layers/extensions/SNCF/SNCF_LPV.tsx

+69-32
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,22 @@
11
import React from 'react';
22
import { useSelector } from 'react-redux';
33
import { Layer, Source, LayerProps } from 'react-map-gl';
4+
import { useTranslation } from 'react-i18next';
45

56
import { RootState } from 'reducers';
67
import { MAP_URL } from 'common/Map/const';
78
import { Theme } from 'types';
89

10+
// REMOVE BEFORE PROD
11+
import Panel from './SNCF_LPV_PANELS';
12+
913
interface SNCF_LPVProps {
1014
geomType: string;
1115
colors: Theme;
1216
}
1317

1418
export default function SNCF_LPV(props: SNCF_LPVProps) {
19+
const { t } = useTranslation('map-settings');
1520
const { layersSettings } = useSelector((state: RootState) => state.map);
1621
const { infraID } = useSelector((state: RootState) => state.osrdconf);
1722
const { geomType, colors } = props;
@@ -22,19 +27,16 @@ export default function SNCF_LPV(props: SNCF_LPVProps) {
2227
['*', 3.6, ['case', ['!=', ['get', tag], null], ['get', tag], ['get', 'speed_limit']]],
2328
];
2429

25-
const speedSectionFilter =
26-
layersSettings.speedlimittag === 'undefined'
27-
? ['all', ['has', 'speed_limit']]
28-
: ['all', ['has', tag]];
30+
const speedSectionFilter = ['any', ['has', 'speed_limit'], ['has', tag]];
2931

3032
const speedValuePointParams: LayerProps = {
3133
type: 'symbol',
32-
'source-layer': 'speed_sections',
34+
'source-layer': 'lpv',
3335
minzoom: 9,
3436
maxzoom: 24,
3537
filter: speedSectionFilter,
3638
layout: {
37-
visibility: 'visible',
39+
visibility: 'none',
3840
'text-font': ['Roboto Bold'],
3941
'symbol-placement': 'point',
4042
'text-field': ['to-string', speedLimitByTagName],
@@ -46,47 +48,72 @@ export default function SNCF_LPV(props: SNCF_LPVProps) {
4648
'text-ignore-placement': false,
4749
},
4850
paint: {
49-
'text-color': colors.speed.pointtext,
50-
'text-halo-color': colors.speed.pointhalo,
51-
'text-halo-width': 5,
51+
'text-color': colors.lpv.pointtext,
52+
'text-halo-color': colors.lpv.pointhalo,
53+
'text-halo-width': 7,
5254
'text-opacity': 1,
5355
},
5456
};
5557

5658
const speedValueParams: LayerProps = {
5759
type: 'symbol',
58-
'source-layer': 'speed_sections',
60+
'source-layer': 'lpv',
5961
minzoom: 9,
6062
maxzoom: 24,
6163
filter: speedSectionFilter,
6264
layout: {
6365
visibility: 'visible',
6466
'text-font': ['Roboto Bold'],
65-
'symbol-placement': 'line',
66-
'text-field': ['concat', ['to-string', speedLimitByTagName], 'km/h'],
67-
'text-size': 9,
67+
'symbol-placement': 'line-center',
68+
'text-field': [
69+
'concat',
70+
t('zone').toUpperCase(),
71+
' ',
72+
['to-string', speedLimitByTagName],
73+
'km/h',
74+
],
75+
'text-size': 10,
6876
'text-justify': 'left',
6977
'text-allow-overlap': false,
7078
'text-ignore-placement': false,
79+
'text-offset': [0, -1],
7180
},
7281
paint: {
73-
'text-color': colors.speed.text,
74-
'text-halo-color': colors.speed.halo,
82+
'text-color': colors.lpv.text,
83+
'text-halo-color': colors.lpv.halo,
7584
'text-halo-width': 1,
7685
'text-opacity': 1,
7786
},
7887
};
7988

89+
const speedLineBGParams: LayerProps = {
90+
type: 'line',
91+
'source-layer': 'lpv',
92+
minzoom: 6,
93+
maxzoom: 24,
94+
filter: speedSectionFilter,
95+
layout: {
96+
visibility: 'visible',
97+
'line-cap': 'square',
98+
},
99+
paint: {
100+
'line-color': '#747678',
101+
'line-width': 3,
102+
'line-offset': 0,
103+
'line-opacity': 1,
104+
'line-gap-width': 7,
105+
},
106+
};
107+
80108
const speedLineParams: LayerProps = {
81109
type: 'line',
82-
'source-layer': 'speed_sections',
110+
'source-layer': 'lpv',
83111
minzoom: 6,
84112
maxzoom: 24,
85113
filter: speedSectionFilter,
86114
layout: {
87115
visibility: 'visible',
88-
'line-cap': 'round',
89-
'line-join': 'miter',
116+
'line-cap': 'square',
90117
},
91118
paint: {
92119
'line-color': [
@@ -112,27 +139,37 @@ export default function SNCF_LPV(props: SNCF_LPVProps) {
112139
'rgba(185, 185, 185, 1)',
113140
],
114141
],
115-
'line-width': 4,
142+
'line-width': 3,
116143
'line-offset': 0,
117144
'line-opacity': 1,
145+
'line-gap-width': 7,
146+
'line-dasharray': [1, 2],
118147
},
119148
};
120149

121150
if (layersSettings.sncf_lpv) {
122151
return (
123-
<Source
124-
id={`osrd_speed_limit_${geomType}`}
125-
type="vector"
126-
url={`${MAP_URL}/layer/speed_sections/mvt/${geomType}/?infra=${infraID}`}
127-
>
128-
<Layer {...speedValuePointParams} id={`chartis/osrd_speed_limit_points/${geomType}`} />
129-
<Layer {...speedValueParams} id={`chartis/osrd_speed_limit_value/${geomType}`} />
130-
<Layer
131-
{...speedLineParams}
132-
id={`chartis/osrd_speed_limit_colors/${geomType}`}
133-
beforeId={`chartis/osrd_speed_limit_points/${geomType}`}
134-
/>
135-
</Source>
152+
<>
153+
<Source
154+
id={`osrd_sncf_lpv_${geomType}`}
155+
type="vector"
156+
url={`${MAP_URL}/layer/lpv/mvt/${geomType}/?infra=${infraID}`}
157+
>
158+
<Layer {...speedValuePointParams} id={`chartis/osrd_sncf_lpv_points/${geomType}`} />
159+
<Layer {...speedValueParams} id={`chartis/osrd_sncf_lpv_value/${geomType}`} />
160+
<Layer
161+
{...speedLineBGParams}
162+
id={`chartis/osrd_sncf_lpv_colors_bg/${geomType}`}
163+
beforeId={`chartis/osrd_sncf_lpv_points/${geomType}`}
164+
/>
165+
<Layer
166+
{...speedLineParams}
167+
id={`chartis/osrd_sncf_lpv_colors/${geomType}`}
168+
beforeId={`chartis/osrd_sncf_lpv_points/${geomType}`}
169+
/>
170+
</Source>
171+
<Panel />
172+
</>
136173
);
137174
}
138175
return null;

0 commit comments

Comments
 (0)