Skip to content

Commit 4c448e3

Browse files
Akctarusflomonster
authored andcommitted
front: handle new signaling system
1 parent 863ea5a commit 4c448e3

File tree

18 files changed

+126
-4350
lines changed

18 files changed

+126
-4350
lines changed

front/src/applications/editor/Map.tsx

+12-4
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,19 @@ import Background from '../../common/Map/Layers/Background';
2020
import OSM from '../../common/Map/Layers/OSM';
2121
import Hillshade from '../../common/Map/Layers/Hillshade';
2222
import Platforms from '../../common/Map/Layers/Platforms';
23-
import osmBlankStyle from '../../common/Map/Layers/osmBlankStyle';
23+
import { blankStyle } from '../../common/Map/Layers/blankStyle';
2424
import IGN_BD_ORTHO from '../../common/Map/Layers/IGN_BD_ORTHO';
2525
import { Viewport } from '../../reducers/map';
2626
import { getMapMouseEventNearestFeature } from '../../utils/mapHelper';
2727
import EditorContext from './context';
2828
import { EditorState, LAYER_TO_EDITOAST_DICT, LAYERS_SET, LayerType } from './tools/types';
2929
import { getEntity } from './data/api';
3030
import { getInfraID, getSwitchTypes } from '../../reducers/osrdconf/selectors';
31-
import { getShowOSM, getTerrain3DExaggeration } from '../../reducers/map/selectors';
31+
import {
32+
getShowOSM,
33+
getSignalingSystems,
34+
getTerrain3DExaggeration,
35+
} from '../../reducers/map/selectors';
3236
import { CommonToolState } from './tools/commonToolState';
3337
import { EditorContextType, ExtendedEditorContextType, Tool } from './tools/editorContextTypes';
3438

@@ -70,6 +74,8 @@ const MapUnplugged: FC<PropsWithChildren<MapProps>> = ({
7074
const editorState = useSelector((state: { editor: EditorState }) => state.editor);
7175
const showOSM = useSelector(getShowOSM);
7276
const terrain3DExaggeration = useSelector(getTerrain3DExaggeration);
77+
const signalingSystems = useSelector(getSignalingSystems);
78+
7379
const extendedContext = useMemo<ExtendedEditorContextType<CommonToolState>>(
7480
() => ({
7581
...context,
@@ -94,6 +100,8 @@ const MapUnplugged: FC<PropsWithChildren<MapProps>> = ({
94100
[activeTool, extendedContext, mapState]
95101
);
96102

103+
const spritesStyle = useMemo(() => blankStyle(signalingSystems), [signalingSystems]);
104+
97105
return (
98106
<>
99107
<div
@@ -109,7 +117,7 @@ const MapUnplugged: FC<PropsWithChildren<MapProps>> = ({
109117
{...viewport}
110118
ref={mapRef}
111119
style={{ width: '100%', height: '100%' }}
112-
mapStyle={osmBlankStyle}
120+
mapStyle={spritesStyle}
113121
onMove={(e) => setViewport(e.viewState)}
114122
onMoveStart={() => setMapState((prev) => ({ ...prev, isDragging: true }))}
115123
onMoveEnd={() => {
@@ -282,7 +290,7 @@ const MapUnplugged: FC<PropsWithChildren<MapProps>> = ({
282290
)}
283291
</ReactMapGL>
284292
</div>
285-
{children}
293+
;{children}
286294
</>
287295
);
288296
};

front/src/applications/referenceMap/Map.tsx

+7-4
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
import { isNil } from 'lodash';
2-
import React, { useCallback, useEffect, useRef } from 'react';
2+
import React, { useCallback, useEffect, useMemo, useRef } from 'react';
33
import { useParams } from 'react-router-dom';
44
import ReactMapGL, { AttributionControl, ScaleControl, MapRef } from 'react-map-gl/maplibre';
55
import { useDispatch, useSelector } from 'react-redux';
66
import { updateViewport, Viewport } from 'reducers/map';
77
import { RootState } from 'reducers';
88

99
import { LAYER_GROUPS_ORDER, LAYERS } from 'config/layerOrder';
10-
import { getTerrain3DExaggeration } from 'reducers/map/selectors';
10+
import { getSignalingSystems, getTerrain3DExaggeration } from 'reducers/map/selectors';
1111

1212
/* Main data & layers */
1313
import Background from 'common/Map/Layers/Background';
@@ -36,7 +36,7 @@ import Switches from 'common/Map/Layers/Switches';
3636
import TracksGeographic from 'common/Map/Layers/TracksGeographic';
3737
import TracksOSM from 'common/Map/Layers/TracksOSM';
3838
import colors from 'common/Map/Consts/colors';
39-
import osmBlankStyle from 'common/Map/Layers/osmBlankStyle';
39+
import { blankStyle } from 'common/Map/Layers/blankStyle';
4040
import { CUSTOM_ATTRIBUTION } from 'common/Map/const';
4141
import LineSearchLayer from 'common/Map/Layers/LineSearchLayer';
4242

@@ -47,6 +47,7 @@ function Map() {
4747
(state: RootState) => state.map
4848
);
4949
const terrain3DExaggeration = useSelector(getTerrain3DExaggeration);
50+
const signalingSystems = useSelector(getSignalingSystems);
5051
const mapRef = useRef<MapRef | null>(null);
5152
const { urlLat, urlLon, urlZoom, urlBearing, urlPitch } = useParams();
5253
const dispatch = useDispatch();
@@ -95,6 +96,8 @@ function Map() {
9596
// eslint-disable-next-line react-hooks/exhaustive-deps
9697
}, []);
9798

99+
const spritesStyle = useMemo(() => blankStyle(signalingSystems), [signalingSystems]);
100+
98101
return (
99102
<main className="mastcontainer mastcontainer-map">
100103
<MapButtons
@@ -108,7 +111,7 @@ function Map() {
108111
ref={mapRef}
109112
cursor="normal"
110113
style={{ width: '100%', height: '100%' }}
111-
mapStyle={osmBlankStyle}
114+
mapStyle={spritesStyle}
112115
onMove={(e) => updateViewportChange(e.viewState)}
113116
onMoveEnd={(e) => updateViewportChange(e.viewState, true)}
114117
attributionControl={false} // Defined below

front/src/assets/mapstyles/style_osrd_blank.json

-18
This file was deleted.

front/src/assets/mapstyles/style_osrd_empty.json

-151
This file was deleted.

0 commit comments

Comments
 (0)