Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

front: display bpcc in infra editor #7329

Merged
merged 1 commit into from
May 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion front/public/locales/en/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,8 @@
"switches": "Switches",
"track_sections": "Track sections",
"speed_sections": "Speed limits",
"platforms": "Platforms"
"platforms": "Platforms",
"neutral_sections": "Dead sections"
},
"layers-modal": {
"frozen-layer": "needed for the active tool",
Expand Down
3 changes: 2 additions & 1 deletion front/public/locales/fr/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,8 @@
"switches": "Aiguillages",
"track_sections": "Sections de lignes",
"speed_sections": "Vitesses limites",
"platforms": "Quais"
"platforms": "Quais",
"neutral_sections": "BP/CC"
},
"layers-modal": {
"frozen-layer": "nécessaire pour l'outil actif",
Expand Down
9 changes: 9 additions & 0 deletions front/src/applications/editor/Map.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import { CUSTOM_ATTRIBUTION } from 'common/Map/const';
import colors from 'common/Map/Consts/colors';
import Background from 'common/Map/Layers/Background';
import { useMapBlankStyle } from 'common/Map/Layers/blankStyle';
import NeutralSections from 'common/Map/Layers/extensions/SNCF/NeutralSections';
import Hillshade from 'common/Map/Layers/Hillshade';
import IGN_BD_ORTHO from 'common/Map/Layers/IGN_BD_ORTHO';
import IGN_CADASTRE from 'common/Map/Layers/IGN_CADASTRE';
Expand Down Expand Up @@ -325,6 +326,14 @@ const MapUnplugged = ({
layerOrder={LAYER_GROUPS_ORDER[LAYERS.PLATFORMS.GROUP]}
/>

{editorState.editorLayers.has('neutral_sections') && (
<NeutralSections
colors={colors[mapStyle]}
layerOrder={LAYER_GROUPS_ORDER[LAYERS.DEAD_SECTIONS.GROUP]}
infraID={infraID}
/>
)}

{/* Tool specific layers */}
{!isNil(infraID) && activeTool.layersComponent && mapRef.current && (
<activeTool.layersComponent map={mapRef.current.getMap()} />
Expand Down
6 changes: 5 additions & 1 deletion front/src/applications/editor/components/LayersModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React, { type FC, useEffect, useMemo, useState } from 'react';

import { groupBy, mapKeys, mapValues, sum, isString, isArray, uniq, isNil } from 'lodash';
import { useTranslation } from 'react-i18next';
import { GiElectric } from 'react-icons/gi';
import { GiElectric, GiUnplugged } from 'react-icons/gi';
import { MdSpeed } from 'react-icons/md';
import { TbRectangleVerticalFilled } from 'react-icons/tb';
import { useSelector } from 'react-redux';
Expand Down Expand Up @@ -40,6 +40,10 @@ export const LAYERS: Array<{ layers: Layer[]; icon: string | JSX.Element }> = [
layers: ['platforms'],
icon: <TbRectangleVerticalFilled style={{ width: '20px' }} className="mx-2" />,
},
{
layers: ['neutral_sections'],
icon: <GiUnplugged style={{ width: '20px' }} className="mx-2" />,
},
];

interface LayersModalProps {
Expand Down
3 changes: 3 additions & 0 deletions front/src/applications/editor/consts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ const INFRA_EDITOR_LAYERS = [
'switches',
'track_sections',
'platforms',
'neutral_sections',
] as const;
export const LAYERS_SET: Set<string> = new Set(INFRA_EDITOR_LAYERS);
export type Layer = (typeof INFRA_EDITOR_LAYERS)[number];
Expand All @@ -28,6 +29,7 @@ export const EDITOAST_TYPES = [
'SpeedSection',
'Switch',
'TrackSection',
'NeutralSection',
] as const;
export type EditoastType = (typeof EDITOAST_TYPES)[number];

Expand All @@ -40,6 +42,7 @@ export const EDITOAST_TO_LAYER_DICT: Record<EditoastType, Layer[]> = {
SpeedSection: ['speed_sections', 'psl', 'psl_signs'],
Switch: ['switches'],
TrackSection: ['track_sections'],
NeutralSection: ['neutral_sections'],
};
export const LAYER_TO_EDITOAST_DICT = flatMap(EDITOAST_TO_LAYER_DICT, (values, key) =>
values.map((value) => [value, key])
Expand Down
12 changes: 7 additions & 5 deletions front/src/applications/referenceMap/Map.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -199,11 +199,13 @@ function Map() {
layerOrder={LAYER_GROUPS_ORDER[LAYERS.ELECTRIFICATIONS.GROUP]}
infraID={infraID}
/>
<NeutralSections
colors={colors[mapStyle]}
layerOrder={LAYER_GROUPS_ORDER[LAYERS.DEAD_SECTIONS.GROUP]}
infraID={infraID}
/>
{layersSettings.neutral_sections && (
<NeutralSections
colors={colors[mapStyle]}
layerOrder={LAYER_GROUPS_ORDER[LAYERS.DEAD_SECTIONS.GROUP]}
infraID={infraID}
/>
)}
<BufferStops
colors={colors[mapStyle]}
layerOrder={LAYER_GROUPS_ORDER[LAYERS.BUFFER_STOPS.GROUP]}
Expand Down
38 changes: 16 additions & 22 deletions front/src/common/Map/Layers/extensions/SNCF/NeutralSections.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
import React from 'react';

import { type LayerProps, Source } from 'react-map-gl/maplibre';
import { useSelector } from 'react-redux';

import { MAP_URL } from 'common/Map/const';
import NeutralSectionSigns from 'common/Map/Layers/extensions/SNCF/NeutralSectionSigns';
import OrderedLayer from 'common/Map/Layers/OrderedLayer';
import type { RootState } from 'reducers';
import type { Theme } from 'types';

type NeutralSectionsProps = {
Expand All @@ -16,7 +14,6 @@ type NeutralSectionsProps = {
};

export default ({ colors, layerOrder, infraID }: NeutralSectionsProps) => {
const { layersSettings } = useSelector((state: RootState) => state.map);
const neutralSectionsParams: LayerProps = {
type: 'line',
'source-layer': 'neutral_sections',
Expand All @@ -39,23 +36,20 @@ export default ({ colors, layerOrder, infraID }: NeutralSectionsProps) => {
},
};

if (layersSettings.neutral_sections) {
return (
<>
<Source
id="neutral_sections_geo"
type="vector"
url={`${MAP_URL}/layer/neutral_sections/mvt/geo/?infra=${infraID}`}
>
<OrderedLayer
{...neutralSectionsParams}
id="chartis/neutral_sections/geo"
layerOrder={layerOrder}
/>
</Source>
<NeutralSectionSigns colors={colors} layerOrder={layerOrder} infraID={infraID} />
</>
);
}
return <div />;
return (
<>
<Source
id="neutral_sections_geo"
type="vector"
url={`${MAP_URL}/layer/neutral_sections/mvt/geo/?infra=${infraID}`}
>
<OrderedLayer
{...neutralSectionsParams}
id="chartis/neutral_sections/geo"
layerOrder={layerOrder}
/>
</Source>
<NeutralSectionSigns colors={colors} layerOrder={layerOrder} infraID={infraID} />
</>
);
};
1 change: 1 addition & 0 deletions front/src/config/layerOrder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,4 +71,5 @@ export const LAYER_ENTITIES_ORDERS: Record<Layer, number> = Object.freeze({
neutral_signs: LAYER_GROUPS_ORDER[LAYERS.SIGNALS.GROUP],
errors: LAYER_GROUPS_ORDER[LAYERS.ERRORS.GROUP],
platforms: LAYER_GROUPS_ORDER[LAYERS.PLATFORMS.GROUP],
neutral_sections: LAYER_GROUPS_ORDER[LAYERS.DEAD_SECTIONS.GROUP],
});
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ import VirtualLayers from 'modules/simulationResult/components/SimulationResults
import type { RootState } from 'reducers';
import { updateViewport } from 'reducers/map';
import type { Viewport } from 'reducers/map';
import { getTerrain3DExaggeration } from 'reducers/map/selectors';
import { getLayersSettings, getTerrain3DExaggeration } from 'reducers/map/selectors';
import { getPresentSimulation, getSelectedTrain } from 'reducers/osrdsimulation/selectors';
import type { Train } from 'reducers/osrdsimulation/types';
import { useAppDispatch } from 'store';
Expand All @@ -86,6 +86,7 @@ const Map: FC<MapProps> = () => {
const trains = useMemo(() => keyBy(simulation.trains, 'id'), [simulation.trains]);
const selectedTrain = useSelector(getSelectedTrain);
const terrain3DExaggeration = useSelector(getTerrain3DExaggeration);
const layersSettings = useSelector(getLayersSettings);

const [geojsonPath, setGeojsonPath] = useState<Feature<LineString>>();
const [selectedTrainHoverPosition, setTrainHoverPosition] = useState<TrainPosition>();
Expand Down Expand Up @@ -316,11 +317,13 @@ const Map: FC<MapProps> = () => {
layerOrder={LAYER_GROUPS_ORDER[LAYERS.ELECTRIFICATIONS.GROUP]}
infraID={infraID}
/>
<NeutralSections
colors={colors[mapStyle]}
layerOrder={LAYER_GROUPS_ORDER[LAYERS.DEAD_SECTIONS.GROUP]}
infraID={infraID}
/>
{layersSettings.neutral_sections && (
<NeutralSections
colors={colors[mapStyle]}
layerOrder={LAYER_GROUPS_ORDER[LAYERS.DEAD_SECTIONS.GROUP]}
infraID={infraID}
/>
)}
<BufferStops
colors={colors[mapStyle]}
layerOrder={LAYER_GROUPS_ORDER[LAYERS.BUFFER_STOPS.GROUP]}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -277,11 +277,13 @@ const Map = ({ geometry, pathProperties }: MapProps) => {
layerOrder={LAYER_GROUPS_ORDER[LAYERS.ELECTRIFICATIONS.GROUP]}
infraID={infraID}
/>
<NeutralSections
colors={colors[mapStyle]}
layerOrder={LAYER_GROUPS_ORDER[LAYERS.DEAD_SECTIONS.GROUP]}
infraID={infraID}
/>
{layersSettings.neutral_sections && (
<NeutralSections
colors={colors[mapStyle]}
layerOrder={LAYER_GROUPS_ORDER[LAYERS.DEAD_SECTIONS.GROUP]}
infraID={infraID}
/>
)}
<BufferStops
colors={colors[mapStyle]}
layerOrder={LAYER_GROUPS_ORDER[LAYERS.BUFFER_STOPS.GROUP]}
Expand Down
Loading