| 
									
										
										
										
											2024-12-07 16:16:31 +00:00
										 |  |  | import {parseRemarks, isStopCancelled} from './remarks.js'; | 
					
						
							| 
									
										
										
										
											2018-06-11 11:29:32 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-10-20 00:19:11 +02:00
										 |  |  | const parseStopover = (ctx, st, date) => { // st = raw stopover
 | 
					
						
							| 
									
										
										
										
											2024-02-06 22:58:49 +01:00
										 |  |  | 	const {profile, opt} = ctx; | 
					
						
							| 
									
										
										
										
											2019-10-20 00:19:11 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-12-07 16:16:31 +00:00
										 |  |  | 	const cancelled = isStopCancelled(st); | 
					
						
							|  |  |  | 	const arr = profile.parseWhen(ctx, date, st.ankunftsZeitpunkt, st.ezAnkunftsZeitpunkt, cancelled); | 
					
						
							|  |  |  | 	const arrPl = profile.parsePlatform(ctx, st.gleis, st.ezGleis); | 
					
						
							|  |  |  | 	const dep = profile.parseWhen(ctx, date, st.abfahrtsZeitpunkt, st.ezAbfahrtsZeitpunkt, cancelled); | 
					
						
							|  |  |  | 	const depPl = profile.parsePlatform(ctx, st.gleis, st.ezGleis); | 
					
						
							| 
									
										
										
										
											2019-10-20 00:19:11 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	const res = { | 
					
						
							|  |  |  | 		stop: st.location || null, | 
					
						
							|  |  |  | 		arrival: arr.when, | 
					
						
							|  |  |  | 		plannedArrival: arr.plannedWhen, | 
					
						
							|  |  |  | 		arrivalDelay: arr.delay, | 
					
						
							|  |  |  | 		arrivalPlatform: arrPl.platform, | 
					
						
							| 
									
										
										
										
											2024-12-07 16:16:31 +00:00
										 |  |  | 		arrivalPrognosisType: null, // TODO
 | 
					
						
							| 
									
										
										
										
											2019-10-20 00:19:11 +02:00
										 |  |  | 		plannedArrivalPlatform: arrPl.plannedPlatform, | 
					
						
							|  |  |  | 		departure: dep.when, | 
					
						
							|  |  |  | 		plannedDeparture: dep.plannedWhen, | 
					
						
							|  |  |  | 		departureDelay: dep.delay, | 
					
						
							|  |  |  | 		departurePlatform: depPl.platform, | 
					
						
							| 
									
										
										
										
											2024-12-07 16:16:31 +00:00
										 |  |  | 		departurePrognosisType: null, // TODO
 | 
					
						
							| 
									
										
										
										
											2024-02-06 22:58:49 +01:00
										 |  |  | 		plannedDeparturePlatform: depPl.plannedPlatform, | 
					
						
							|  |  |  | 	}; | 
					
						
							| 
									
										
										
										
											2017-11-11 22:35:41 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-02-06 22:58:49 +01:00
										 |  |  | 	if (arr.prognosedWhen) { | 
					
						
							|  |  |  | 		res.prognosedArrival = arr.prognosedWhen; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	if (arrPl.prognosedPlatform) { | 
					
						
							|  |  |  | 		res.prognosedArrivalPlatform = arrPl.prognosedPlatform; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	if (dep.prognosedWhen) { | 
					
						
							|  |  |  | 		res.prognosedDeparture = dep.prognosedWhen; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	if (depPl.prognosedPlatform) { | 
					
						
							|  |  |  | 		res.prognosedDeparturePlatform = depPl.prognosedPlatform; | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2019-10-20 00:19:11 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-12-07 16:16:31 +00:00
										 |  |  | 	res.loadFactor = profile.parseLoadFactor(opt, st.auslastungsmeldungen); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-10-20 00:19:11 +02:00
										 |  |  | 	// mark stations the train passes without stopping
 | 
					
						
							| 
									
										
										
										
											2024-12-07 16:16:31 +00:00
										 |  |  | 	// TODO risNotizen key text.realtime.stop.exit.disabled?
 | 
					
						
							| 
									
										
										
										
											2019-10-20 00:19:11 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-12-07 16:16:31 +00:00
										 |  |  | 	if (cancelled) { | 
					
						
							| 
									
										
										
										
											2024-02-06 22:58:49 +01:00
										 |  |  | 		res.cancelled = true; | 
					
						
							|  |  |  | 		Object.defineProperty(res, 'canceled', {value: true}); | 
					
						
							| 
									
										
										
										
											2019-10-20 00:19:11 +02:00
										 |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-12-07 16:16:31 +00:00
										 |  |  | 	// TODO res.additional = true;
 | 
					
						
							| 
									
										
										
										
											2023-11-25 16:58:31 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-12-07 16:16:31 +00:00
										 |  |  | 	if (opt.remarks) { | 
					
						
							|  |  |  | 		res.remarks = parseRemarks(ctx, st); | 
					
						
							| 
									
										
										
										
											2019-10-20 00:19:11 +02:00
										 |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-02-06 22:58:49 +01:00
										 |  |  | 	return res; | 
					
						
							|  |  |  | }; | 
					
						
							| 
									
										
										
										
											2017-11-11 22:35:41 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-05-07 16:17:37 +02:00
										 |  |  | export { | 
					
						
							|  |  |  | 	parseStopover, | 
					
						
							| 
									
										
										
										
											2024-02-06 22:58:49 +01:00
										 |  |  | }; |