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: platform layer is enabled only when OSM is #5757

Merged
merged 1 commit into from
Nov 22, 2023
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
2 changes: 1 addition & 1 deletion front/public/locales/en/map-settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@
},
"noSpeedLimitByTag": "No composition code",
"operationalpoints": "Operational points",
"platforms":"Platforms",
"routes": "Train blocks",
"signals": "Signals",
"signalingtype": "Signalling block type",
"signalisation": "Signaling",
"signals": "Light signals",
"showIGNBDORTHO": "BD Ortho photo ©IGN",
"showIGNSCAN25": "SCAN PLAN/25/100 ©IGN",
"showIGNCadastre": "Cadastre ©IGN",
Expand Down
5 changes: 3 additions & 2 deletions front/public/locales/en/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,8 @@
"signals": "Signals",
"switches": "Switches",
"track_sections": "Track sections",
"speed_sections": "Speed limits"
"speed_sections": "Speed limits",
"platforms": "Platforms"
},
"layers-modal": {
"frozen-layer": "needed for the active tool",
Expand All @@ -185,7 +186,7 @@
"recenter": "Recenter the map",
"select-infra": "Select the infrastructure to edit",
"toggle-layers": "Choose the types of elements to display",
"osrd-layers": "OSRD data layers",
"osrd-layers": "Data layers",
"speed-limits": "Speed limits",
"map-layers": "Map layers"
},
Expand Down
2 changes: 1 addition & 1 deletion front/public/locales/fr/map-settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@
},
"noSpeedLimitByTag": "Aucun code de composition",
"operationalpoints": "Points remarquables",
"platforms":"Quais",
"routes": "Cantons",
"signals": "Signals",
"signalingtype": "Type de block",
"signalisation": "Signalisation",
"signals": "Signaux lumineux",
"showIGNBDORTHO": "BD Ortho photo ©IGN",
"showIGNSCAN25": "SCAN PLAN/25/100 ©IGN",
"showIGNCadastre": "Cadastre ©IGN",
Expand Down
5 changes: 3 additions & 2 deletions front/public/locales/fr/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,8 @@
"signals": "Signaux",
"switches": "Aiguillages",
"track_sections": "Sections de lignes",
"speed_sections": "Vitesses limites"
"speed_sections": "Vitesses limites",
"Platforms": "Quais"
},
"layers-modal": {
"frozen-layer": "nécessaire pour l'outil actif",
Expand All @@ -185,7 +186,7 @@
"recenter": "Recentrer la carte",
"select-infra": "Choisir l'infrastructure à éditer",
"toggle-layers": "Choisir les types d'éléments à afficher",
"osrd-layers": "Couches de données OSRD",
"osrd-layers": "Couches de données",
"speed-limits": "Limitations de vitesse",
"map-layers": "Couches cartographiques"
},
Expand Down
5 changes: 3 additions & 2 deletions front/src/applications/editor/Map.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import Terrain from 'common/Map/Layers/Terrain';
import Background from 'common/Map/Layers/Background';
import OSM from 'common/Map/Layers/OSM';
import Hillshade from 'common/Map/Layers/Hillshade';
import Platforms from 'common/Map/Layers/Platforms';
import PlatformsLayer from 'common/Map/Layers/Platforms';
import { useMapBlankStyle } from 'common/Map/Layers/blankStyle';
import IGN_BD_ORTHO from 'common/Map/Layers/IGN_BD_ORTHO';
import { getInfraID } from 'reducers/osrdconf/selectors';
Expand Down Expand Up @@ -288,7 +288,8 @@ const MapUnplugged: FC<PropsWithChildren<MapProps>> = ({
/>
</>
)}
<Platforms

<PlatformsLayer
colors={colors[mapStyle]}
layerOrder={LAYER_GROUPS_ORDER[LAYERS.PLATFORMS.GROUP]}
/>
Expand Down
5 changes: 5 additions & 0 deletions front/src/applications/editor/components/LayersModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { useDispatch, useSelector } from 'react-redux';
import { groupBy, mapKeys, mapValues, sum, isString, isArray, uniq } from 'lodash';
import { useTranslation } from 'react-i18next';
import { MdSpeed } from 'react-icons/md';
import { TbRectangleVerticalFilled } from 'react-icons/tb';

import bufferStopIcon from 'assets/pictures/layersicons/bufferstop.svg';
import switchesIcon from 'assets/pictures/layersicons/switches.svg';
Expand Down Expand Up @@ -32,6 +33,10 @@ export const LAYERS: Array<{ layers: LayerType[]; icon: string | JSX.Element }>
{ layers: ['speed_sections'], icon: <MdSpeed style={{ width: '20px' }} className="mx-2" /> },
{ layers: ['psl', 'psl_signs'], icon: pslsIcon },
{ layers: ['catenaries'], icon: <GiElectric style={{ width: '20px' }} className="mx-2" /> },
{
layers: ['platforms'],
icon: <TbRectangleVerticalFilled style={{ width: '20px' }} className="mx-2" />,
},
];

const NO_SPEED_LIMIT_TAG = 'undefined';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React, { FC, useContext } from 'react';
import { useSelector } from 'react-redux';
import { useTranslation } from 'react-i18next';

import { compact, isEmpty } from 'lodash';
import { compact } from 'lodash';
import EditorContext from 'applications/editor/context';
import colors from 'common/Map/Consts/colors';
import GeoJSONs from 'common/Map/Layers/GeoJSONs';
Expand Down
1 change: 1 addition & 0 deletions front/src/applications/editor/tools/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export const LAYERS = [
'speed_sections',
'switches',
'track_sections',
'platforms',
] as const;
export const LAYERS_SET: Set<string> = new Set(LAYERS);
export type LayerType = (typeof LAYERS)[number];
Expand Down
4 changes: 2 additions & 2 deletions front/src/applications/referenceMap/Map.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import IGN_CADASTRE from 'common/Map/Layers/IGN_CADASTRE';
import OSM from 'common/Map/Layers/OSM';
/* Objects & various */
import OperationalPoints from 'common/Map/Layers/OperationalPoints';
import Platforms from 'common/Map/Layers/Platforms';
import PlatformsLayer from 'common/Map/Layers/Platforms';
import Routes from 'common/Map/Layers/Routes';
import SearchMarker from 'common/Map/Layers/SearchMarker';
import Signals from 'common/Map/Layers/Signals';
Expand Down Expand Up @@ -154,7 +154,7 @@ function Map() {
</>
)}

<Platforms
<PlatformsLayer
colors={colors[mapStyle]}
layerOrder={LAYER_GROUPS_ORDER[LAYERS.PLATFORMS.GROUP]}
/>
Expand Down
9 changes: 7 additions & 2 deletions front/src/common/Map/Layers/GeoJSONs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { LayerType } from 'applications/editor/tools/types';
import { RootState } from 'reducers';
import { MapState } from 'reducers/map';
import { getInfraID } from 'reducers/osrdconf/selectors';
import { LAYER_ENTITIES_ORDERS } from 'config/layerOrder';
import { LAYERS, LAYER_ENTITIES_ORDERS, LAYER_GROUPS_ORDER } from 'config/layerOrder';
import { Theme } from 'types';
import { geoMainLayer, geoServiceLayer } from './geographiclayers';
import {
Expand Down Expand Up @@ -46,6 +46,7 @@ import { LayerContext } from './types';
import { getCatenariesProps, getCatenariesTextParams } from './Catenaries';
import configKPLabelLayer from './configKPLabelLayer';
import OrderedLayer from './OrderedLayer';
import { Platforms } from './Platforms';

const POINT_ENTITIES_MIN_ZOOM = 12;

Expand Down Expand Up @@ -465,7 +466,6 @@ const GeoJSONs: FC<{
if (skipSources) {
return null;
}

return (
<>
{sources.map((source) => (
Expand All @@ -481,6 +481,11 @@ const GeoJSONs: FC<{
))}
</Source>
))}

{/* platform's data are not managed by OSRD, that's why they are here */}
{layers?.has('platforms') && (
<Platforms colors={colors} layerOrder={LAYER_GROUPS_ORDER[LAYERS.PLATFORMS.GROUP]} />
)}
</>
);
};
Expand Down
11 changes: 9 additions & 2 deletions front/src/common/Map/Layers/Platforms.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,15 @@ import OrderedLayer from 'common/Map/Layers/OrderedLayer';
import { OSM_URL } from 'common/Map/const';

import { Theme } from 'types';
import { useSelector } from 'react-redux';
import { RootState } from 'reducers';

interface PlatformsProps {
colors: Theme;
layerOrder?: number;
}

function Platforms(props: PlatformsProps) {
export function Platforms(props: PlatformsProps) {
const { colors, layerOrder } = props;

const platformsParams: LayerProps = {
Expand All @@ -37,4 +39,9 @@ function Platforms(props: PlatformsProps) {
);
}

export default Platforms;
function PlatformsState(props: PlatformsProps) {
const { layersSettings } = useSelector((state: RootState) => state.map);
return layersSettings.platforms ? <Platforms {...props} /> : null;
}

export default PlatformsState;
4 changes: 4 additions & 0 deletions front/src/common/Map/Settings/MapSettingsLayers.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { useSelector, useDispatch } from 'react-redux';
import { useTranslation } from 'react-i18next';
import { updateLayersSettings } from 'reducers/map';
import { GiElectric, GiUnplugged } from 'react-icons/gi';
import { TbRectangleVerticalFilled } from 'react-icons/tb';

import SignalsSVGFile from 'assets/pictures/layersicons/layer_signal.svg';
import BufferStopSVGFile from 'assets/pictures/layersicons/bufferstop.svg';
Expand Down Expand Up @@ -93,6 +94,9 @@ const MapSettingsLayers: FC<unknown> = () => (
icon={<Icon2SVG file={DetectorsSVGFile} altName="Detectors circles svg" />}
/>
</div>
<div className="col-md-6">
<FormatSwitch name="platforms" icon={<TbRectangleVerticalFilled />} />
</div>
</div>
);

Expand Down
1 change: 1 addition & 0 deletions front/src/config/layerOrder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,4 +69,5 @@ export const LAYER_ENTITIES_ORDERS: Record<LayerType, number> = Object.freeze({
psl: LAYER_GROUPS_ORDER[LAYERS.SIGNALS.GROUP],
psl_signs: LAYER_GROUPS_ORDER[LAYERS.SIGNALS.GROUP],
errors: LAYER_GROUPS_ORDER[LAYERS.ERRORS.GROUP],
platforms: LAYER_GROUPS_ORDER[LAYERS.PLATFORMS.GROUP],
});
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import NeutralSections from 'common/Map/Layers/NeutralSections';
import Hillshade from 'common/Map/Layers/Hillshade';
import OSM from 'common/Map/Layers/OSM';
import OperationalPoints from 'common/Map/Layers/OperationalPoints';
import Platforms from 'common/Map/Layers/Platforms';
import PlatformsLayer from 'common/Map/Layers/Platforms';
import RenderItinerary from 'modules/simulationResult/components/SimulationResultsMap/RenderItinerary';
import Routes from 'common/Map/Layers/Routes';
import SearchMarker from 'common/Map/Layers/SearchMarker';
Expand Down Expand Up @@ -279,7 +279,7 @@ const Map: FC<MapProps> = ({ setExtViewport }) => {
</>
)}

<Platforms
<PlatformsLayer
colors={colors[mapStyle]}
layerOrder={LAYER_GROUPS_ORDER[LAYERS.PLATFORMS.GROUP]}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import NeutralSections from 'common/Map/Layers/NeutralSections';
import Hillshade from 'common/Map/Layers/Hillshade';
import OSM from 'common/Map/Layers/OSM';
import OperationalPoints from 'common/Map/Layers/OperationalPoints';
import Platforms from 'common/Map/Layers/Platforms';
import PlatformsLayer from 'common/Map/Layers/Platforms';
import RenderItinerary from 'modules/trainschedule/components/ManageTrainSchedule/ManageTrainScheduleMap/RenderItinerary';
import RenderItineraryMarkers from 'modules/trainschedule/components/ManageTrainSchedule/ManageTrainScheduleMap/RenderItineraryMarkers';
/* Interactions */
Expand Down Expand Up @@ -201,7 +201,7 @@ function Map() {
</>
)}

<Platforms
<PlatformsLayer
colors={colors[mapStyle]}
layerOrder={LAYER_GROUPS_ORDER[LAYERS.PLATFORMS.GROUP]}
/>
Expand Down
2 changes: 2 additions & 0 deletions front/src/reducers/map/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ export interface MapState {
speedlimits: boolean;
switches: boolean;
tvds: boolean;
platforms: boolean;
};
issuesSettings?: {
types: Array<InfraErrorType>;
Expand Down Expand Up @@ -83,6 +84,7 @@ export const mapInitialState: MapState = {
speedlimits: false,
switches: false,
tvds: false,
platforms: true,
},
mapSearchMarker: undefined,
lineSearchCode: undefined,
Expand Down
1 change: 1 addition & 0 deletions front/src/reducers/map/mapReducer.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ describe('mapReducer', () => {
switches: true,
tvds: true,
errors: true,
platforms: true,
};
store.dispatch(updateLayersSettings(layersSettings));
const mapState = store.getState().map;
Expand Down
Loading