Commit cc9c1b06 authored by Birte Kristina Friesel's avatar Birte Kristina Friesel
Browse files

support trains with incomplete route data

parent a113484f
Loading
Loading
Loading
Loading
+5 −1
Original line number Diff line number Diff line
@@ -107,6 +107,7 @@ sub get_timetable {
			$data{arrival_ts} = $e_ar->getAttribute('pt');
			$data{platform}   = $e_ar->getAttribute('pp'); # string, not number!
			$data{route_pre}     = $e_ar->getAttribute('ppth');
			$data{route_start}   = $e_ar->getAttribute('pde');
			$data{arrival_wings} = $e_ar->getAttribute('wings');
		}

@@ -114,6 +115,7 @@ sub get_timetable {
			$data{departure_ts} = $e_dp->getAttribute('pt');
			$data{platform} = $e_dp->getAttribute('pp');   # string, not number!
			$data{route_post}      = $e_dp->getAttribute('ppth');
			$data{route_end}       = $e_dp->getAttribute('pde');
			$data{departure_wings} = $e_dp->getAttribute('wings');
		}

@@ -190,13 +192,15 @@ sub get_realtime {
				arrival_ts => $e_ar->getAttribute('ct'),
				platform   => $e_ar->getAttribute('cp'),
				route_pre  => $e_ar->getAttribute('cpth'),
				status     => $e_ar->getAttribute('cs'),
			);
		}
		if ($e_dp) {
			$result->add_dp(
				departure_ts => $e_dp->getAttribute('ct'),
				platform     => $e_dp->getAttribute('cp'),
				route_pre    => $e_dp->getAttribute('cpth'),
				route_post   => $e_dp->getAttribute('cpth'),
				status       => $e_dp->getAttribute('cs'),
			);
		}

+13 −3
Original line number Diff line number Diff line
@@ -118,9 +118,18 @@ sub new {
	$ref->{route_post} = $ref->{sched_route_post}
	  = [ split( qr{\|}, $ref->{route_post} // q{} ) ];

	$ref->{route_end} = $ref->{sched_route_end} = $ref->{route_post}[-1]
	$ref->{route_pre_incomplete}  = $ref->{route_end}  ? 1 : 0;
	$ref->{route_post_incomplete} = $ref->{route_post} ? 1 : 0;

	$ref->{route_end}
	  = $ref->{sched_route_end}
	  = $ref->{route_end}
	  || $ref->{route_post}[-1]
	  || $ref->{station};
	$ref->{route_start} = $ref->{sched_route_start} = $ref->{route_pre}[0]
	$ref->{route_start}
	  = $ref->{sched_route_start}
	  = $ref->{route_start}
	  || $ref->{route_pre}[0]
	  || $ref->{station};

	return bless( $ref, $obj );
@@ -244,7 +253,8 @@ sub route_interesting {
			push( @via_main, $stop );
		}
	}
	$last_stop = pop(@via);
	$last_stop
	  = $self->{route_post_incomplete} ? $self->{route_end} : pop(@via);

	if ( @via_main and $via_main[-1] eq $last_stop ) {
		pop(@via_main);