1
1
import React from 'react' ;
2
2
import { useSelector } from 'react-redux' ;
3
3
import { Layer , Source , LayerProps } from 'react-map-gl' ;
4
+ import { useTranslation } from 'react-i18next' ;
4
5
5
6
import { RootState } from 'reducers' ;
6
7
import { MAP_URL } from 'common/Map/const' ;
7
8
import { Theme } from 'types' ;
8
9
10
+ // REMOVE BEFORE PROD
11
+ import Panel from './SNCF_LPV_PANELS' ;
12
+
9
13
interface SNCF_LPVProps {
10
14
geomType : string ;
11
15
colors : Theme ;
12
16
}
13
17
14
18
export default function SNCF_LPV ( props : SNCF_LPVProps ) {
19
+ const { t } = useTranslation ( 'map-settings' ) ;
15
20
const { layersSettings } = useSelector ( ( state : RootState ) => state . map ) ;
16
21
const { infraID } = useSelector ( ( state : RootState ) => state . osrdconf ) ;
17
22
const { geomType, colors } = props ;
@@ -22,19 +27,16 @@ export default function SNCF_LPV(props: SNCF_LPVProps) {
22
27
[ '*' , 3.6 , [ 'case' , [ '!=' , [ 'get' , tag ] , null ] , [ 'get' , tag ] , [ 'get' , 'speed_limit' ] ] ] ,
23
28
] ;
24
29
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 ] ] ;
29
31
30
32
const speedValuePointParams : LayerProps = {
31
33
type : 'symbol' ,
32
- 'source-layer' : 'speed_sections ' ,
34
+ 'source-layer' : 'lpv ' ,
33
35
minzoom : 9 ,
34
36
maxzoom : 24 ,
35
37
filter : speedSectionFilter ,
36
38
layout : {
37
- visibility : 'visible ' ,
39
+ visibility : 'none ' ,
38
40
'text-font' : [ 'Roboto Bold' ] ,
39
41
'symbol-placement' : 'point' ,
40
42
'text-field' : [ 'to-string' , speedLimitByTagName ] ,
@@ -46,47 +48,72 @@ export default function SNCF_LPV(props: SNCF_LPVProps) {
46
48
'text-ignore-placement' : false ,
47
49
} ,
48
50
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 ,
52
54
'text-opacity' : 1 ,
53
55
} ,
54
56
} ;
55
57
56
58
const speedValueParams : LayerProps = {
57
59
type : 'symbol' ,
58
- 'source-layer' : 'speed_sections ' ,
60
+ 'source-layer' : 'lpv ' ,
59
61
minzoom : 9 ,
60
62
maxzoom : 24 ,
61
63
filter : speedSectionFilter ,
62
64
layout : {
63
65
visibility : 'visible' ,
64
66
'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 ,
68
76
'text-justify' : 'left' ,
69
77
'text-allow-overlap' : false ,
70
78
'text-ignore-placement' : false ,
79
+ 'text-offset' : [ 0 , - 1 ] ,
71
80
} ,
72
81
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 ,
75
84
'text-halo-width' : 1 ,
76
85
'text-opacity' : 1 ,
77
86
} ,
78
87
} ;
79
88
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
+
80
108
const speedLineParams : LayerProps = {
81
109
type : 'line' ,
82
- 'source-layer' : 'speed_sections ' ,
110
+ 'source-layer' : 'lpv ' ,
83
111
minzoom : 6 ,
84
112
maxzoom : 24 ,
85
113
filter : speedSectionFilter ,
86
114
layout : {
87
115
visibility : 'visible' ,
88
- 'line-cap' : 'round' ,
89
- 'line-join' : 'miter' ,
116
+ 'line-cap' : 'square' ,
90
117
} ,
91
118
paint : {
92
119
'line-color' : [
@@ -112,27 +139,37 @@ export default function SNCF_LPV(props: SNCF_LPVProps) {
112
139
'rgba(185, 185, 185, 1)' ,
113
140
] ,
114
141
] ,
115
- 'line-width' : 4 ,
142
+ 'line-width' : 3 ,
116
143
'line-offset' : 0 ,
117
144
'line-opacity' : 1 ,
145
+ 'line-gap-width' : 7 ,
146
+ 'line-dasharray' : [ 1 , 2 ] ,
118
147
} ,
119
148
} ;
120
149
121
150
if ( layersSettings . sncf_lpv ) {
122
151
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
+ </ >
136
173
) ;
137
174
}
138
175
return null ;
0 commit comments