@@ -16,6 +16,7 @@ import { kmhToMs, tToKg } from 'utils/physics';
16
16
import { ISO8601Duration2sec , sec2ms } from 'utils/timeManipulation' ;
17
17
18
18
import createMargin from './createMargin' ;
19
+ import { StdcmStopTypes } from '../types' ;
19
20
20
21
type ValidStdcmConfig = {
21
22
rollingStockId : number ;
@@ -139,15 +140,25 @@ export const checkStdcmConf = (
139
140
const { arrival, tolerances, stopFor, arrivalType } = step ;
140
141
const location = getStepLocation ( step ) ;
141
142
142
- const duration = stopFor ? sec2ms ( ISO8601Duration2sec ( stopFor ) || Number ( stopFor ) ) : 0 ;
143
- const timingData =
144
- arrivalType === 'preciseTime' && arrival
145
- ? {
146
- arrival_time : arrival ,
147
- arrival_time_tolerance_before : sec2ms ( tolerances ?. before ?? 0 ) ,
148
- arrival_time_tolerance_after : sec2ms ( tolerances ?. after ?? 0 ) ,
149
- }
150
- : undefined ;
143
+ let timingData : PathfindingItem [ 'timing_data' ] | undefined ;
144
+ let duration : number | undefined ;
145
+ if ( step . isVia ) {
146
+ if ( step . stopType !== StdcmStopTypes . PASSAGE_TIME ) {
147
+ duration = stopFor ? sec2ms ( ISO8601Duration2sec ( stopFor ) || Number ( stopFor ) ) : 0 ;
148
+ }
149
+ } else {
150
+ // if the step is either the origin or the destination,
151
+ // it must have a duration
152
+ duration = 0 ;
153
+ if ( arrivalType === 'preciseTime' && arrival ) {
154
+ timingData = {
155
+ arrival_time : arrival ,
156
+ arrival_time_tolerance_before : sec2ms ( tolerances ?. before ?? 0 ) ,
157
+ arrival_time_tolerance_after : sec2ms ( tolerances ?. after ?? 0 ) ,
158
+ } ;
159
+ }
160
+ }
161
+
151
162
return {
152
163
duration,
153
164
location,
0 commit comments