Skip to content

Commit b0d3c65

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

File tree

6 files changed

+58
-15
lines changed

6 files changed

+58
-15
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}`;

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

+40-9
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
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

@@ -24,12 +24,45 @@ export default function configKPLabelLayer(props: PlatformProps) {
2424
const {
2525
colors,
2626
fieldName = 'kp',
27-
leftOffset = -1,
2827
maxzoom = 24,
2928
minzoom = 7,
30-
rotation = 'viewport',
29+
isSignalisation,
3130
sourceLayer,
3231
} = props;
32+
33+
// Will have to be removed when backend will be updated with consistent fieldname
34+
const testSideExpression = (side: 'LEFT' | 'RIGHT' | 'CENTER') => [
35+
'any',
36+
['==', ['get', 'extensions_sncf_side'], side],
37+
['==', ['get', 'side'], side],
38+
];
39+
40+
const signallingLabeling: LayerProps['layout'] = isSignalisation
41+
? {
42+
'text-rotation-alignment': 'map',
43+
'text-pitch-alignment': 'map',
44+
'text-rotate': ['get', 'angle'],
45+
'text-anchor': [
46+
'case',
47+
testSideExpression('LEFT') as ExpressionFilterSpecification,
48+
'right',
49+
testSideExpression('RIGHT') as ExpressionFilterSpecification,
50+
'left',
51+
'center',
52+
],
53+
'text-offset': [
54+
'case',
55+
testSideExpression('LEFT') as ExpressionFilterSpecification,
56+
['literal', [-2.75, 0.2]],
57+
testSideExpression('RIGHT') as ExpressionFilterSpecification,
58+
['literal', [2.75, 0.2]],
59+
['literal', [0, 2.5]],
60+
],
61+
}
62+
: {
63+
'text-offset': ['literal', [-1, 0.1]],
64+
};
65+
3366
const rkValue: LayerProps = {
3467
type: 'symbol',
3568
'source-layer': sourceLayer,
@@ -42,11 +75,9 @@ export default function configKPLabelLayer(props: PlatformProps) {
4275
'text-size': 9,
4376
'text-anchor': 'right',
4477
'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,
78+
'text-ignore-placement': false,
79+
80+
...signallingLabeling,
5081
},
5182
paint: {
5283
'text-color': colors.kp.text,

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)