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: Rank the map layers in the right order #2187 #2199

Merged
merged 41 commits into from
Nov 4, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
56c859e
reorder & remove unnecessary layers
anisometropie Oct 26, 2022
3d887c3
ordered layer
anisometropie Oct 27, 2022
68154f4
eslint rule
anisometropie Oct 27, 2022
b7c7d15
clean up imports
anisometropie Oct 27, 2022
79ff08b
add ordered virtual layers
anisometropie Oct 27, 2022
cbf1724
ordered layer optional layer order prop
anisometropie Oct 27, 2022
f7bddda
Platform order
anisometropie Oct 27, 2022
23041eb
TracksGeographic
anisometropie Oct 27, 2022
aea3595
TrackOSM
anisometropie Oct 27, 2022
ebbc3b7
Routes
anisometropie Oct 27, 2022
02aef8d
OperationalPoints
anisometropie Oct 27, 2022
0dd8a6c
Catenaries
anisometropie Oct 27, 2022
52998d4
Reducer consolidated simulation type
anisometropie Oct 27, 2022
98a32d5
fix types
anisometropie Oct 27, 2022
2f02113
Signals order
anisometropie Oct 27, 2022
2325401
SpeedLimits order
anisometropie Oct 27, 2022
d16fb40
Train layer order
anisometropie Oct 27, 2022
563bd7e
add one extra virtual layer and last one doesn’t have a beforeId
anisometropie Oct 27, 2022
fe08004
Buffer stops layer order
anisometropie Oct 27, 2022
de1f739
detectors layer order
anisometropie Oct 27, 2022
8801e55
imports
anisometropie Oct 27, 2022
81e4c52
Switches layer order
anisometropie Oct 27, 2022
53bf511
Merge remote-tracking branch 'origin/dev' into vcs/layer-order
anisometropie Oct 27, 2022
d9a002c
Itinerary layer order
anisometropie Oct 27, 2022
8061cec
tracks schematics layer order
anisometropie Oct 27, 2022
152c9f6
reorder
anisometropie Oct 27, 2022
8179828
Background layer order
anisometropie Oct 27, 2022
af26fb9
layer order config file
anisometropie Oct 27, 2022
cb5f5cd
remove unused
anisometropie Oct 27, 2022
73a52de
render itinerary layer order
anisometropie Oct 27, 2022
0796f49
set Signals optional prop
anisometropie Oct 27, 2022
08332b2
unused import
anisometropie Oct 27, 2022
98de5af
OSRD config map layer order
anisometropie Oct 27, 2022
d0b5bb4
fix routes constant layer name
anisometropie Oct 27, 2022
814599c
carto map layer order
anisometropie Oct 27, 2022
8f04d4f
Hillshap & OSM layer order
anisometropie Oct 28, 2022
2fd7eb6
yarn
anisometropie Oct 28, 2022
c42a0fc
virtual layer key
anisometropie Oct 28, 2022
9412490
hillshade layer order
anisometropie Oct 28, 2022
f86d7c8
fix layer 0
anisometropie Oct 28, 2022
313aeb9
refacto
anisometropie Oct 28, 2022
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/.eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@
}
],
"no-use-before-define": "off",
"@typescript-eslint/no-use-before-define": ["error"]
"@typescript-eslint/no-use-before-define": ["error"],
"react/jsx-no-useless-fragment": ["error", { "allowExpressions": true }]
},
"settings": {
"import/resolver": {
Expand Down
2 changes: 1 addition & 1 deletion front/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@
"classnames": "^2.3.2",
"d3": "^5.16.0",
"d3-brush": "^3.0.0",
"d3-drag": "^3.0.0",
"d3-selection": "^3.0.0",
"d3-zoom": "^3.0.0",
"d3-drag": "^3.0.0",
"fast-json-patch": "^3.1.1",
"geojson": "^0.5.0",
"history": "^5.3.0",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
import 'common/Map/Map.scss';

import React, { useCallback, useEffect, useState } from 'react';
import { useParams } from 'react-router-dom';
import ReactMapGL, { AttributionControl, FlyToInterpolator, ScaleControl } from 'react-map-gl';
import { useDispatch, useSelector } from 'react-redux';

import { updateViewport } from 'reducers/map';
import { RootState } from 'reducers';

import { LAYER_GROUPS_ORDER, LAYERS } from 'config/layerOrder';

/* Main data & layers */
import Background from 'common/Map/Layers/Background';
import BufferStops from 'common/Map/Layers/BufferStops';
Expand All @@ -18,7 +22,6 @@ import OperationalPoints from 'common/Map/Layers/OperationalPoints';
import Platform from 'common/Map/Layers/Platform';
import Routes from 'common/Map/Layers/Routes';
import SearchMarker from 'common/Map/Layers/SearchMarker';
import SignalingType from 'common/Map/Layers/SignalingType';
import Signals from 'common/Map/Layers/Signals';
import SpeedLimits from 'common/Map/Layers/SpeedLimits';
import SNCF_LPV from 'common/Map/Layers/extensions/SNCF/SNCF_LPV';
Expand All @@ -28,15 +31,15 @@ import TracksOSM from 'common/Map/Layers/TracksOSM';
import TracksSchematic from 'common/Map/Layers/TracksSchematic';
import colors from 'common/Map/Consts/colors';
import osmBlankStyle from 'common/Map/Layers/osmBlankStyle';
import { updateViewport } from 'reducers/map';
import { useParams } from 'react-router-dom';

import 'common/Map/Map.scss';

function Map() {
const { viewport, mapSearchMarker, mapStyle, mapTrackSources, showOSM, layersSettings } =
useSelector((state) => state.map);
const [idHover, setIdHover] = useState(undefined);
useSelector((state: RootState) => state.map);
const [idHover, setIdHover] = useState('');
const { urlLat, urlLon, urlZoom, urlBearing, urlPitch } = useParams();
const { fullscreen } = useSelector((state) => state.main);
const { fullscreen } = useSelector((state: RootState) => state.main);
const dispatch = useDispatch();
const updateViewportChange = useCallback(
(value) => dispatch(updateViewport(value, '/carto')),
Expand All @@ -51,8 +54,8 @@ function Map() {
const resetPitchBearing = () => {
updateViewportChange({
...viewport,
bearing: parseFloat(0),
pitch: parseFloat(0),
bearing: parseFloat('0'),
pitch: parseFloat('0'),
transitionDuration: 1000,
transitionInterpolator: new FlyToInterpolator(),
});
Expand Down Expand Up @@ -116,44 +119,130 @@ function Map() {
/>
<ScaleControl maxWidth={100} unit="metric" style={scaleControlStyle} />

<Background colors={colors[mapStyle]} />
<Background
colors={colors[mapStyle]}
layerOrder={LAYER_GROUPS_ORDER[LAYERS.BACKGROUND.GROUP]}
/>

{!showOSM ? null : (
<>
<OSM mapStyle={mapStyle} />
<Hillshade mapStyle={mapStyle} />
<OSM mapStyle={mapStyle} layerOrder={LAYER_GROUPS_ORDER[LAYERS.BACKGROUND.GROUP]} />
<Hillshade
mapStyle={mapStyle}
layerOrder={LAYER_GROUPS_ORDER[LAYERS.BACKGROUND.GROUP]}
/>
</>
)}

{/* Have to duplicate objects with sourceLayer to avoid cache problems in mapbox */}
{mapTrackSources === 'geographic' ? (
<>
<Platform colors={colors[mapStyle]} />
<TracksGeographic colors={colors[mapStyle]} />
<Catenaries geomType="geo" colors={colors[mapStyle]} />
<TracksOSM colors={colors[mapStyle]} />
<OperationalPoints geomType="geo" colors={colors[mapStyle]} />
<SignalingType geomType="geo" />
<Routes geomType="geo" colors={colors[mapStyle]} />
<SpeedLimits geomType="geo" colors={colors[mapStyle]} />
<Platform
colors={colors[mapStyle]}
layerOrder={LAYER_GROUPS_ORDER[LAYERS.PLATFORM.GROUP]}
/>

<TracksGeographic
colors={colors[mapStyle]}
layerOrder={LAYER_GROUPS_ORDER[LAYERS.TRACKS_GEOGRAPHIC.GROUP]}
/>
<TracksOSM
colors={colors[mapStyle]}
layerOrder={LAYER_GROUPS_ORDER[LAYERS.TRACKS_OSM.GROUP]}
/>

<Routes
geomType="geo"
colors={colors[mapStyle]}
layerOrder={LAYER_GROUPS_ORDER[LAYERS.ROUTES.GROUP]}
/>
<OperationalPoints
geomType="geo"
colors={colors[mapStyle]}
layerOrder={LAYER_GROUPS_ORDER[LAYERS.OPERATIONAL_POINTS.GROUP]}
/>
<Catenaries
geomType="geo"
colors={colors[mapStyle]}
layerOrder={LAYER_GROUPS_ORDER[LAYERS.CATENARIES.GROUP]}
/>
<BufferStops
geomType="geo"
colors={colors[mapStyle]}
layerOrder={LAYER_GROUPS_ORDER[LAYERS.BUFFER_STOPS.GROUP]}
/>
<Detectors
geomType="geo"
colors={colors[mapStyle]}
layerOrder={LAYER_GROUPS_ORDER[LAYERS.DETECTORS.GROUP]}
/>
<Switches
geomType="geo"
colors={colors[mapStyle]}
layerOrder={LAYER_GROUPS_ORDER[LAYERS.SWITCHES.GROUP]}
/>

<SpeedLimits
geomType="geo"
colors={colors[mapStyle]}
layerOrder={LAYER_GROUPS_ORDER[LAYERS.SPEED_LIMITS.GROUP]}
/>
<SNCF_LPV geomType="geo" colors={colors[mapStyle]} />
<Signals sourceLayer="geo" sourceTable="signals" colors={colors[mapStyle]} />
<BufferStops geomType="geo" colors={colors[mapStyle]} />
<Detectors geomType="geo" colors={colors[mapStyle]} />
<Switches geomType="geo" colors={colors[mapStyle]} />

<Signals
sourceTable="signals"
colors={colors[mapStyle]}
sourceLayer="geo"
layerOrder={LAYER_GROUPS_ORDER[LAYERS.SIGNALS.GROUP]}
/>
</>
) : (
<>
<TracksSchematic colors={colors[mapStyle]} idHover={idHover} />
<Catenaries geomType="sch" colors={colors[mapStyle]} />
<OperationalPoints geomType="sch" colors={colors[mapStyle]} />
<Routes geomType="sch" colors={colors[mapStyle]} />
<SpeedLimits geomType="sch" colors={colors[mapStyle]} />
<TracksSchematic
colors={colors[mapStyle]}
idHover={idHover}
layerOrder={LAYER_GROUPS_ORDER[LAYERS.TRACKS_SCHEMATIC.GROUP]}
/>

<Routes
geomType="sch"
colors={colors[mapStyle]}
layerOrder={LAYER_GROUPS_ORDER[LAYERS.ROUTES.GROUP]}
/>
<OperationalPoints
geomType="sch"
colors={colors[mapStyle]}
layerOrder={LAYER_GROUPS_ORDER[LAYERS.OPERATIONAL_POINTS.GROUP]}
/>
<BufferStops
geomType="sch"
colors={colors[mapStyle]}
layerOrder={LAYER_GROUPS_ORDER[LAYERS.BUFFER_STOPS.GROUP]}
/>
<Detectors
geomType="sch"
colors={colors[mapStyle]}
layerOrder={LAYER_GROUPS_ORDER[LAYERS.DETECTORS.GROUP]}
/>
<Switches
geomType="sch"
colors={colors[mapStyle]}
layerOrder={LAYER_GROUPS_ORDER[LAYERS.SWITCHES.GROUP]}
/>

<SpeedLimits
geomType="sch"
colors={colors[mapStyle]}
layerOrder={LAYER_GROUPS_ORDER[LAYERS.SPEED_LIMITS.GROUP]}
/>
<SNCF_LPV geomType="sch" colors={colors[mapStyle]} />
<Signals sourceLayer="sch" sourceTable="signals" colors={colors[mapStyle]} />
<BufferStops geomType="sch" colors={colors[mapStyle]} />
<Detectors geomType="sch" colors={colors[mapStyle]} />
<Switches geomType="sch" colors={colors[mapStyle]} />

<Signals
sourceTable="signals"
colors={colors[mapStyle]}
sourceLayer="sch"
layerOrder={LAYER_GROUPS_ORDER[LAYERS.SIGNALS.GROUP]}
/>
</>
)}

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import React from 'react';
import { Source, Layer } from 'react-map-gl';
import { useSelector } from 'react-redux';

import { RootState } from 'reducers';

import OrderedLayer from 'common/Map/Layers/OrderedLayer';

interface RenderItineraryProps {
layerOrder: number;
}

export default function RenderItinerary(props: RenderItineraryProps) {
const { layerOrder } = props;
const { geojson, origin, destination } = useSelector((state: RootState) => state.osrdconf);
const { mapTrackSources } = useSelector((state: RootState) => state.map);
if (geojson && geojson[mapTrackSources] && origin !== undefined && destination !== undefined) {
return (
<Source type="geojson" data={geojson[mapTrackSources]}>
<OrderedLayer
type="line"
paint={{
'line-width': 5,
'line-color': 'rgba(210, 225, 0, 0.75)',
}}
layerOrder={layerOrder}
/>
</Source>
);
}
return null;
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import * as d3 from 'd3';
import { select as d3select } from 'd3-selection';

import { Chart } from 'reducers/osrdsimulation';
import { Chart, SimulationTrain } from 'reducers/osrdsimulation';
import { defineLinear, defineTime } from 'applications/osrd/components/Helpers/ChartHelpers';
import defineChart from 'applications/osrd/components/Simulation/defineChart';
import { SimulationTrain } from './createTrain';

export default function createChart(
chart: Chart,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,34 +7,10 @@ import {
formatStepsWithTime,
formatStepsWithTimeMulti,
mergeDatasArea,
MergedDataPoint,
} from 'applications/osrd/components/Helpers/ChartHelpers';

import { setFailure } from 'reducers/main';
import { Train, Position, RouteAspect, SignalAspect, PositionSpeed } from 'reducers/osrdsimulation';

export interface SimulationTrain {
id: number;
isStdcm: boolean;
name: string;
trainNumber: number;
headPosition: Position<Date | null>[][];
tailPosition: Position<Date | null>[][];
routeEndOccupancy: Position<Date | null>[][];
routeBeginOccupancy: Position<Date | null>[][];
routeAspects: RouteAspect<Date | null, string>[];
signalAspects: SignalAspect<Date | null, string>[];
areaBlock: MergedDataPoint<Date | null>[][];
speed: PositionSpeed<Date | null>[];
eco_headPosition?: Position<Date | null>[][];
eco_tailPosition?: Position<Date | null>[][];
eco_routeEndOccupancy?: Position<Date | null>[][];
eco_routeBeginOccupancy?: Position<Date | null>[][];
eco_routeAspects?: RouteAspect<Date | null, string>[];
eco_signalAspects?: SignalAspect<Date | null, string>[];
eco_areaBlock?: MergedDataPoint<Date | null>[][];
eco_speed?: PositionSpeed<Date | null>[];
}
import { Train, SimulationTrain } from 'reducers/osrdsimulation';

/**
* Will do some formating & computation to get a trains to be displayed. Stored then with currentSimulation splitted reducer
Expand All @@ -49,7 +25,7 @@ export default function createTrain(
keyValues: string[],
simulationTrains: Train[],
t: TFunction
) {
): SimulationTrain[] {
// Prepare data
const dataSimulation = simulationTrains.map((train: Train, trainNumber: number) => {
const routeEndOccupancy = formatStepsWithTimeMulti(train.base.route_end_occupancy);
Expand Down

This file was deleted.

Loading