Loading lib/DBInfoscreen/Controller/Map.pm +36 −14 Original line number Diff line number Diff line Loading @@ -80,6 +80,7 @@ sub route { my @route; my @markers; my $next_stop; my $now = DateTime->now( time_zone => 'Europe/Berlin' ); my $strp = DateTime::Format::Strptime->new( Loading Loading @@ -149,6 +150,7 @@ sub route { dep => $dep, arr_delay => $arr_delay, dep_delay => $dep_delay, platform => $platform, } ); Loading Loading @@ -177,30 +179,30 @@ sub route { my $geo = Geo::Distance->new; my ( $from_index, $to_index ); for my $i ( 0 .. $#{ $pl->{raw}{polyline}{features} } ) { my $this_point = $pl->{raw}{polyline}{features}[$i]; for my $j ( 0 .. $#{ $pl->{raw}{polyline}{features} } ) { my $this_point = $pl->{raw}{polyline}{features}[$j]; if ( not defined $from_index and $this_point->{properties}{type} and $this_point->{properties}{type} eq 'stop' and $this_point->{properties}{name} eq $from_name ) { $from_index = $i; $from_index = $j; } elsif ( $this_point->{properties}{type} and $this_point->{properties}{type} eq 'stop' and $this_point->{properties}{name} eq $to_name ) { $to_index = $i; $to_index = $j; last; } } if ( $from_index and $to_index ) { my $total_distance = 0; for my $i ( $from_index + 1 .. $to_index ) { my $prev = $pl->{raw}{polyline}{features}[ $i - 1 ] for my $j ( $from_index + 1 .. $to_index ) { my $prev = $pl->{raw}{polyline}{features}[ $j - 1 ] {geometry}{coordinates}; my $this = $pl->{raw}{polyline}{features}[$i]{geometry} = $pl->{raw}{polyline}{features}[$j]{geometry} {coordinates}; if ( $prev and $this ) { $total_distance += $geo->distance( Loading @@ -212,11 +214,11 @@ sub route { my $marker_distance = $total_distance * $route_part_completion_ratio; $total_distance = 0; for my $i ( $from_index + 1 .. $to_index ) { my $prev = $pl->{raw}{polyline}{features}[ $i - 1 ] for my $j ( $from_index + 1 .. $to_index ) { my $prev = $pl->{raw}{polyline}{features}[ $j - 1 ] {geometry}{coordinates}; my $this = $pl->{raw}{polyline}{features}[$i]{geometry} = $pl->{raw}{polyline}{features}[$j]{geometry} {coordinates}; if ( $prev and $this ) { $total_distance += $geo->distance( Loading @@ -233,6 +235,10 @@ sub route { title => $title } ); $next_stop = { type => 'next', station => $route[$i], }; last; } } Loading @@ -252,6 +258,10 @@ sub route { title => $title } ); $next_stop = { type => 'next', station => $route[$i], }; } last; } Loading @@ -268,6 +278,10 @@ sub route { title => $title } ); $next_stop = { type => 'present', station => $route[ $i - 1 ], }; last; } } Loading @@ -280,6 +294,10 @@ sub route { title => $route[-1]{name} . ' - Endstation', } ); $next_stop = { type => 'present', station => $route[-1] }; } $self->render( Loading @@ -299,6 +317,8 @@ sub route { ? scalar $strp->parse_datetime( $pl->{raw}{arrival} ) : undef, }, train_no => scalar $pl->{raw}{line}{additionalName}, next_stop => $next_stop, polyline_groups => [ { polylines => [@line_pairs], Loading @@ -320,6 +340,8 @@ sub route { hide_opts => 1, with_map => 1, error => $err, origin => undef, destination => undef, ); } Loading templates/route_map.html.ep +56 −4 Original line number Diff line number Diff line % if ($origin and $destination) { <div class="container" style="margin-top: 1ex; margin-bottom: 1ex;"> Fahrt von <strong><%= $origin->{name} %></strong> Fahrt % if (stash('train_no')) { <strong><%= stash('train_no') %></strong> % } von <strong><%= $origin->{name} %></strong> nach <strong><%= $destination->{name} %></strong> % if (my $next = stash('next_stop')) { <br/> % if ($next->{type} eq 'present' and $next->{station}{dep} and $next->{station}{arr}) { Aufenthalt in <strong><%= $next->{station}{name} %></strong> an Gleis <strong><%= $next->{station}{platform} %></strong> bis <strong><%= $next->{station}{dep}->strftime('%H:%M') %></strong> % if ($next->{station}{dep_delay}) { %= sprintf('(%+d)', $next->{station}{dep_delay}) % } % } % if ($next->{type} eq 'present' and $next->{station}{dep}) { Abfahrt in <strong><%= $next->{station}{name} %></strong> von Gleis <strong><%= $next->{station}{platform} %></strong> um <strong><%= $next->{station}{dep}->strftime('%H:%M') %></strong> % if ($next->{station}{dep_delay}) { %= sprintf('(%+d)', $next->{station}{dep_delay}) % } % } % elsif ($next->{type} eq 'present' and $next->{station}{arr}) { Endstation erreicht um <strong><%= $next->{station}{arr}->strftime('%H:%M') %></strong> auf Gleis <strong><%= $next->{station}{platform} %></strong> % if ($next->{station}{arr_delay}) { %= sprintf('(%+d)', $next->{station}{arr_delay}) % } % } % elsif ($next->{type} eq 'present') { Zug steht in <strong><%= $next->{station}{arr}->strftime('%H:%M') %></strong> auf Gleis <strong><%= $next->{station}{platform} %></strong> % } % elsif ($next->{type} eq 'next' and $next->{station}{arr}) { Nächster Halt: <strong><%= $next->{station}{name} %></strong> um <strong><%= $next->{station}{arr}->strftime('%H:%M') %></strong> % if ($next->{station}{arr_delay}) { %= sprintf('(%+d)', $next->{station}{arr_delay}) % } auf Gleis <strong><%= $next->{station}{platform} %></strong> % } % elsif ($next->{type} eq 'next') { Nächster Halt: <strong><%= $next->{station}{name} %></strong> auf Gleis <strong><%= $next->{station}{platform} %></strong> % } % } </div> % } <div class="container"> <div id="map" style="height: 500px;"> Loading Loading
lib/DBInfoscreen/Controller/Map.pm +36 −14 Original line number Diff line number Diff line Loading @@ -80,6 +80,7 @@ sub route { my @route; my @markers; my $next_stop; my $now = DateTime->now( time_zone => 'Europe/Berlin' ); my $strp = DateTime::Format::Strptime->new( Loading Loading @@ -149,6 +150,7 @@ sub route { dep => $dep, arr_delay => $arr_delay, dep_delay => $dep_delay, platform => $platform, } ); Loading Loading @@ -177,30 +179,30 @@ sub route { my $geo = Geo::Distance->new; my ( $from_index, $to_index ); for my $i ( 0 .. $#{ $pl->{raw}{polyline}{features} } ) { my $this_point = $pl->{raw}{polyline}{features}[$i]; for my $j ( 0 .. $#{ $pl->{raw}{polyline}{features} } ) { my $this_point = $pl->{raw}{polyline}{features}[$j]; if ( not defined $from_index and $this_point->{properties}{type} and $this_point->{properties}{type} eq 'stop' and $this_point->{properties}{name} eq $from_name ) { $from_index = $i; $from_index = $j; } elsif ( $this_point->{properties}{type} and $this_point->{properties}{type} eq 'stop' and $this_point->{properties}{name} eq $to_name ) { $to_index = $i; $to_index = $j; last; } } if ( $from_index and $to_index ) { my $total_distance = 0; for my $i ( $from_index + 1 .. $to_index ) { my $prev = $pl->{raw}{polyline}{features}[ $i - 1 ] for my $j ( $from_index + 1 .. $to_index ) { my $prev = $pl->{raw}{polyline}{features}[ $j - 1 ] {geometry}{coordinates}; my $this = $pl->{raw}{polyline}{features}[$i]{geometry} = $pl->{raw}{polyline}{features}[$j]{geometry} {coordinates}; if ( $prev and $this ) { $total_distance += $geo->distance( Loading @@ -212,11 +214,11 @@ sub route { my $marker_distance = $total_distance * $route_part_completion_ratio; $total_distance = 0; for my $i ( $from_index + 1 .. $to_index ) { my $prev = $pl->{raw}{polyline}{features}[ $i - 1 ] for my $j ( $from_index + 1 .. $to_index ) { my $prev = $pl->{raw}{polyline}{features}[ $j - 1 ] {geometry}{coordinates}; my $this = $pl->{raw}{polyline}{features}[$i]{geometry} = $pl->{raw}{polyline}{features}[$j]{geometry} {coordinates}; if ( $prev and $this ) { $total_distance += $geo->distance( Loading @@ -233,6 +235,10 @@ sub route { title => $title } ); $next_stop = { type => 'next', station => $route[$i], }; last; } } Loading @@ -252,6 +258,10 @@ sub route { title => $title } ); $next_stop = { type => 'next', station => $route[$i], }; } last; } Loading @@ -268,6 +278,10 @@ sub route { title => $title } ); $next_stop = { type => 'present', station => $route[ $i - 1 ], }; last; } } Loading @@ -280,6 +294,10 @@ sub route { title => $route[-1]{name} . ' - Endstation', } ); $next_stop = { type => 'present', station => $route[-1] }; } $self->render( Loading @@ -299,6 +317,8 @@ sub route { ? scalar $strp->parse_datetime( $pl->{raw}{arrival} ) : undef, }, train_no => scalar $pl->{raw}{line}{additionalName}, next_stop => $next_stop, polyline_groups => [ { polylines => [@line_pairs], Loading @@ -320,6 +340,8 @@ sub route { hide_opts => 1, with_map => 1, error => $err, origin => undef, destination => undef, ); } Loading
templates/route_map.html.ep +56 −4 Original line number Diff line number Diff line % if ($origin and $destination) { <div class="container" style="margin-top: 1ex; margin-bottom: 1ex;"> Fahrt von <strong><%= $origin->{name} %></strong> Fahrt % if (stash('train_no')) { <strong><%= stash('train_no') %></strong> % } von <strong><%= $origin->{name} %></strong> nach <strong><%= $destination->{name} %></strong> % if (my $next = stash('next_stop')) { <br/> % if ($next->{type} eq 'present' and $next->{station}{dep} and $next->{station}{arr}) { Aufenthalt in <strong><%= $next->{station}{name} %></strong> an Gleis <strong><%= $next->{station}{platform} %></strong> bis <strong><%= $next->{station}{dep}->strftime('%H:%M') %></strong> % if ($next->{station}{dep_delay}) { %= sprintf('(%+d)', $next->{station}{dep_delay}) % } % } % if ($next->{type} eq 'present' and $next->{station}{dep}) { Abfahrt in <strong><%= $next->{station}{name} %></strong> von Gleis <strong><%= $next->{station}{platform} %></strong> um <strong><%= $next->{station}{dep}->strftime('%H:%M') %></strong> % if ($next->{station}{dep_delay}) { %= sprintf('(%+d)', $next->{station}{dep_delay}) % } % } % elsif ($next->{type} eq 'present' and $next->{station}{arr}) { Endstation erreicht um <strong><%= $next->{station}{arr}->strftime('%H:%M') %></strong> auf Gleis <strong><%= $next->{station}{platform} %></strong> % if ($next->{station}{arr_delay}) { %= sprintf('(%+d)', $next->{station}{arr_delay}) % } % } % elsif ($next->{type} eq 'present') { Zug steht in <strong><%= $next->{station}{arr}->strftime('%H:%M') %></strong> auf Gleis <strong><%= $next->{station}{platform} %></strong> % } % elsif ($next->{type} eq 'next' and $next->{station}{arr}) { Nächster Halt: <strong><%= $next->{station}{name} %></strong> um <strong><%= $next->{station}{arr}->strftime('%H:%M') %></strong> % if ($next->{station}{arr_delay}) { %= sprintf('(%+d)', $next->{station}{arr_delay}) % } auf Gleis <strong><%= $next->{station}{platform} %></strong> % } % elsif ($next->{type} eq 'next') { Nächster Halt: <strong><%= $next->{station}{name} %></strong> auf Gleis <strong><%= $next->{station}{platform} %></strong> % } % } </div> % } <div class="container"> <div id="map" style="height: 500px;"> Loading