Skip to content

Commit a589108

Browse files
committed
front: add KP to signals
1 parent 05a3705 commit a589108

File tree

6 files changed

+60
-25
lines changed

6 files changed

+60
-25
lines changed

front/src/common/Map/Layers/BufferStops.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,9 @@ const BufferStops: FC<BufferStopsProps> = ({ colors, layerOrder }) => {
6060
<OrderedLayer
6161
{...configKPLabelLayer({
6262
colors,
63+
fieldName: 'extensions_sncf_kp',
6364
minzoom: 12,
6465
sourceLayer: 'buffer_stops',
65-
fieldName: 'extensions_sncf_kp',
6666
})}
6767
id="chartis/osrd_bufferstop_kp/geo"
6868
layerOrder={layerOrder}

front/src/common/Map/Layers/Detectors.tsx

+3-3
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,9 @@ export function getDetectorsNameLayerProps(params: {
3838
'text-font': ['Roboto Condensed'],
3939
'text-size': 10,
4040
'text-anchor': 'left',
41-
'text-allow-overlap': false,
41+
'text-allow-overlap': true,
4242
'text-ignore-placement': false,
43-
'text-offset': [0.75, 0.1],
43+
'text-offset': [1, 0.2],
4444
visibility: 'visible',
4545
},
4646
paint: {
@@ -78,9 +78,9 @@ const Detectors: FC<DetectorsProps> = ({ colors, layerOrder }) => {
7878
<OrderedLayer
7979
{...configKPLabelLayer({
8080
colors,
81+
fieldName: 'extensions_sncf_kp',
8182
minzoom: 10,
8283
sourceLayer: 'detectors',
83-
fieldName: 'extensions_sncf_kp',
8484
})}
8585
id="chartis/osrd_detectors_kp/geo"
8686
layerOrder={layerOrder}

front/src/common/Map/Layers/OperationalPoints.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -146,9 +146,9 @@ export default function OperationalPoints(props: Props) {
146146
<OrderedLayer
147147
{...configKPLabelLayer({
148148
colors,
149+
fieldName: 'extensions_sncf_kp',
149150
minzoom: 9.5,
150151
sourceLayer: 'operational_points',
151-
fieldName: 'extensions_sncf_kp',
152152
})}
153153
id="chartis/osrd_operational_point_kp/geo"
154154
layerOrder={layerOrder}

front/src/common/Map/Layers/Signals.tsx

+12
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import {
2222
getSignalMatLayerProps,
2323
SignalContext,
2424
} from './geoSignalsLayers';
25+
import configKPLabelLayer from './configKPLabelLayer';
2526

2627
interface PlatformProps {
2728
colors: Theme;
@@ -158,6 +159,17 @@ function Signals(props: PlatformProps) {
158159
id="chartis/signal/point"
159160
layerOrder={layerOrder}
160161
/>
162+
<OrderedLayer
163+
{...configKPLabelLayer({
164+
colors,
165+
fieldName: 'extensions_sncf_kp',
166+
minzoom: 12,
167+
isSignalisation: true,
168+
sourceLayer: sourceTable,
169+
})}
170+
id="chartis/signal/kp"
171+
layerOrder={layerOrder}
172+
/>
161173

162174
{signalsList.map((sig) => {
163175
const layerId = `chartis/signal/geo/${sig}`;
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,61 @@
1+
import { ExpressionFilterSpecification } from 'maplibre-gl';
12
import { LayerProps } from 'react-map-gl/maplibre';
23

34
import { Theme } from 'types';
45

56
interface PlatformProps {
67
colors: Theme;
78
fieldName?: string;
8-
leftOffset?: number;
99
maxzoom?: number;
1010
minzoom?: number;
11-
rotation?: 'map' | 'viewport' | 'auto';
11+
isSignalisation?: boolean;
1212
sourceLayer: string;
1313
}
1414

15-
/*
16-
* signals
17-
OK detectors: seulement ceux sous un signal, ceux qu'on genere en sur les tiv de jonction connait pas leur pk
18-
OK buffer stops
19-
OK les panneaux des psl
20-
OK les operational point parts
21-
*/
22-
2315
export default function configKPLabelLayer(props: PlatformProps) {
2416
const {
2517
colors,
2618
fieldName = 'kp',
27-
leftOffset = -1,
2819
maxzoom = 24,
2920
minzoom = 7,
30-
rotation = 'viewport',
21+
isSignalisation,
3122
sourceLayer,
3223
} = props;
33-
const rkValue: LayerProps = {
24+
25+
// Will have to be removed when backend will be updated with consistent fieldnames
26+
const testSideExpression = (side: 'LEFT' | 'RIGHT' | 'CENTER') => [
27+
'any',
28+
['==', ['get', 'extensions_sncf_side'], side],
29+
['==', ['get', 'side'], side],
30+
];
31+
32+
const signallingLabeling: LayerProps['layout'] = isSignalisation
33+
? {
34+
'text-rotation-alignment': 'map',
35+
'text-pitch-alignment': 'map',
36+
'text-rotate': ['get', 'angle'],
37+
'text-anchor': [
38+
'case',
39+
testSideExpression('LEFT') as ExpressionFilterSpecification,
40+
'right',
41+
testSideExpression('RIGHT') as ExpressionFilterSpecification,
42+
'left',
43+
'center',
44+
],
45+
'text-offset': [
46+
'case',
47+
testSideExpression('LEFT') as ExpressionFilterSpecification,
48+
['literal', [-2.75, 0.2]],
49+
testSideExpression('RIGHT') as ExpressionFilterSpecification,
50+
['literal', [2.75, 0.2]],
51+
['literal', [0, 2.5]],
52+
],
53+
}
54+
: {
55+
'text-offset': ['literal', [-1, 0.1]],
56+
};
57+
58+
const kpValue: LayerProps = {
3459
type: 'symbol',
3560
'source-layer': sourceLayer,
3661
filter: ['all', ['!=', ['literal', null], ['get', fieldName]], ['!=', '', ['get', fieldName]]],
@@ -42,11 +67,9 @@ export default function configKPLabelLayer(props: PlatformProps) {
4267
'text-size': 9,
4368
'text-anchor': 'right',
4469
'text-allow-overlap': true,
45-
'text-ignore-placement': true,
46-
'text-offset': [leftOffset, 0.1],
47-
'text-rotation-alignment': rotation,
48-
'text-pitch-alignment': rotation,
49-
'text-rotate': rotation === 'map' ? ['get', 'angle_geo'] : 0,
70+
'text-ignore-placement': false,
71+
72+
...signallingLabeling,
5073
},
5174
paint: {
5275
'text-color': colors.kp.text,
@@ -56,5 +79,5 @@ export default function configKPLabelLayer(props: PlatformProps) {
5679
},
5780
};
5881

59-
return rkValue;
82+
return kpValue;
6083
}

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -122,8 +122,8 @@ export default function SNCF_PSL_Signs(props: SNCF_PSL_SignsProps) {
122122
{...configKPLabelLayer({
123123
colors,
124124
minzoom: 9.5,
125+
isSignalisation: true,
125126
sourceLayer: 'psl_signs',
126-
rotation: 'map',
127127
})}
128128
id="chartis/osrd_psl_signs_kp/geo"
129129
layerOrder={layerOrder}

0 commit comments

Comments
 (0)