@@ -2,6 +2,7 @@ import { useCallback, useMemo } from 'react';
2
2
3
3
import type { Position } from '@turf/helpers' ;
4
4
import cx from 'classnames' ;
5
+ import { compact } from 'lodash' ;
5
6
import type { Map } from 'maplibre-gl' ;
6
7
import { Marker } from 'react-map-gl/maplibre' ;
7
8
import { useSelector } from 'react-redux' ;
@@ -13,17 +14,27 @@ import stdcmOrigin from 'assets/pictures/mapMarkers/start.svg';
13
14
import originSVG from 'assets/pictures/origin.svg' ;
14
15
import viaSVG from 'assets/pictures/via.svg' ;
15
16
import { useOsrdConfSelectors } from 'common/osrdContext' ;
16
- import type { PathStep } from 'reducers/osrdconf/types' ;
17
17
import { getNearestTrack } from 'utils/mapHelper' ;
18
18
19
+ export type MarkerInformation = {
20
+ name ?: string ;
21
+ coordinates ?: number [ ] | Position ;
22
+ metadata ?: {
23
+ lineCode : number ;
24
+ lineName : string ;
25
+ trackName : string ;
26
+ trackNumber : number ;
27
+ } ;
28
+ } ;
29
+
19
30
enum MARKER_TYPE {
20
31
ORIGIN = 'origin' ,
21
32
VIA = 'via' ,
22
33
DESTINATION = 'destination' ,
23
34
}
24
35
25
- type MarkerInformation = {
26
- marker : PathStep ;
36
+ type MarkerProps = {
37
+ marker : MarkerInformation ;
27
38
coordinates : number [ ] | Position ;
28
39
imageSource : string ;
29
40
} & (
@@ -38,15 +49,15 @@ type MarkerInformation = {
38
49
39
50
type ItineraryMarkersProps = {
40
51
map : Map ;
41
- simulationPathSteps ?: PathStep [ ] ;
52
+ simulationPathSteps ?: MarkerInformation [ ] ;
42
53
showStdcmAssets : boolean ;
43
54
} ;
44
55
45
56
const formatPointWithNoName = (
46
57
lineCode : number ,
47
58
lineName : string ,
48
59
trackName : string ,
49
- markerType : MarkerInformation [ 'type' ]
60
+ markerType : MarkerProps [ 'type' ]
50
61
) => (
51
62
< >
52
63
< div className = "main-line" >
@@ -57,7 +68,7 @@ const formatPointWithNoName = (
57
68
</ >
58
69
) ;
59
70
60
- const extractMarkerInformation = ( pathSteps : ( PathStep | null ) [ ] , showStdcmAssets : boolean ) =>
71
+ const extractMarkerInformation = ( pathSteps : MarkerInformation [ ] , showStdcmAssets : boolean ) =>
61
72
pathSteps . reduce ( ( acc , cur , index ) => {
62
73
if ( cur && cur . coordinates ) {
63
74
if ( index === 0 ) {
@@ -85,19 +96,19 @@ const extractMarkerInformation = (pathSteps: (PathStep | null)[], showStdcmAsset
85
96
}
86
97
}
87
98
return acc ;
88
- } , [ ] as MarkerInformation [ ] ) ;
99
+ } , [ ] as MarkerProps [ ] ) ;
89
100
90
101
const ItineraryMarkers = ( { map, simulationPathSteps, showStdcmAssets } : ItineraryMarkersProps ) => {
91
102
const { getPathSteps } = useOsrdConfSelectors ( ) ;
92
103
const pathSteps = useSelector ( getPathSteps ) ;
93
104
94
105
const markersInformation = useMemo (
95
- ( ) => extractMarkerInformation ( simulationPathSteps || pathSteps , showStdcmAssets ) ,
106
+ ( ) => extractMarkerInformation ( simulationPathSteps || compact ( pathSteps ) , showStdcmAssets ) ,
96
107
[ simulationPathSteps , pathSteps , showStdcmAssets ]
97
108
) ;
98
109
99
110
const getMarkerDisplayInformation = useCallback (
100
- ( markerInfo : MarkerInformation ) => {
111
+ ( markerInfo : MarkerProps ) => {
101
112
const {
102
113
marker : { coordinates : markerCoordinates , metadata : markerMetadata } ,
103
114
type : markerType ,
0 commit comments