journey details: show route on map if available
This commit is contained in:
parent
82f043e734
commit
5c05ed609f
3 changed files with 57 additions and 39 deletions
|
@ -3726,16 +3726,7 @@ sub startup {
|
|||
= map { [ $location->{ $_->[0] }, $location->{ $_->[1] } ] }
|
||||
@station_pairs;
|
||||
|
||||
my @routes;
|
||||
|
||||
my @lats = map { $_->[0][0] } @station_coordinates;
|
||||
my @lons = map { $_->[0][1] } @station_coordinates;
|
||||
my $min_lat = List::Util::min @lats;
|
||||
my $max_lat = List::Util::max @lats;
|
||||
my $min_lon = List::Util::min @lons;
|
||||
my $max_lon = List::Util::max @lons;
|
||||
|
||||
return {
|
||||
my $ret = {
|
||||
skipped_journeys => \@skipped_journeys,
|
||||
station_coordinates => \@station_coordinates,
|
||||
polyline_groups => [
|
||||
|
@ -3750,8 +3741,20 @@ sub startup {
|
|||
opacity => 0.8,
|
||||
}
|
||||
],
|
||||
bounds => [ [ $min_lat, $min_lon ], [ $max_lat, $max_lon ] ],
|
||||
};
|
||||
|
||||
if (@station_coordinates) {
|
||||
my @lats = map { $_->[0][0] } @station_coordinates;
|
||||
my @lons = map { $_->[0][1] } @station_coordinates;
|
||||
my $min_lat = List::Util::min @lats;
|
||||
my $max_lat = List::Util::max @lats;
|
||||
my $min_lon = List::Util::min @lons;
|
||||
my $max_lon = List::Util::max @lons;
|
||||
$ret->{bounds}
|
||||
= [ [ $min_lat, $min_lon ], [ $max_lat, $max_lon ] ];
|
||||
}
|
||||
|
||||
return $ret;
|
||||
}
|
||||
);
|
||||
|
||||
|
|
|
@ -119,12 +119,18 @@ sub user_status {
|
|||
if ( not $user->{public_level} & 0x04 ) {
|
||||
delete $journey->{user_data}{comment};
|
||||
}
|
||||
my $map_data = $self->journeys_to_map_data(
|
||||
journeys => [$journey],
|
||||
include_manual => 1,
|
||||
);
|
||||
$self->render(
|
||||
'journey',
|
||||
error => undef,
|
||||
with_map => 1,
|
||||
readonly => 1,
|
||||
journey => $journey,
|
||||
twitter => \%tw_data,
|
||||
%{$map_data},
|
||||
);
|
||||
}
|
||||
else {
|
||||
|
@ -665,10 +671,16 @@ sub journey_details {
|
|||
);
|
||||
|
||||
if ($journey) {
|
||||
my $map_data = $self->journeys_to_map_data(
|
||||
journeys => [$journey],
|
||||
include_manual => 1,
|
||||
);
|
||||
$self->render(
|
||||
'journey',
|
||||
error => undef,
|
||||
journey => $journey,
|
||||
error => undef,
|
||||
journey => $journey,
|
||||
with_map => 1,
|
||||
%{$map_data},
|
||||
);
|
||||
}
|
||||
else {
|
||||
|
|
|
@ -166,6 +166,32 @@
|
|||
</td>
|
||||
</tr>
|
||||
% }
|
||||
% if ($journey->{user_data} and $journey->{user_data}{wagongroups} and not exists $journey->{user_data}{wagons}) {
|
||||
<tr>
|
||||
<th scope="row">Rollmaterial</th>
|
||||
<td class="wagons">
|
||||
%= include '_wagons', wagongroups => $journey->{user_data}{wagongroups};
|
||||
</td>
|
||||
</tr>
|
||||
% }
|
||||
% elsif ($journey->{user_data} and $journey->{user_data}{wagons}) {
|
||||
<tr>
|
||||
<th scope="row">Rollmaterial</th>
|
||||
<td class="wagons">
|
||||
% for my $wagongroup (@{$journey->{user_data}{wagongroups} // []}) {
|
||||
Wagenverbund <%= $wagongroup %><br/>
|
||||
% }
|
||||
% for my $wagon (@{$journey->{user_data}{wagons}}) {
|
||||
<span><%= substr($wagon->{id}, 0, 2) %></span><span><%= substr($wagon->{id}, 2, 2) %></span><span><%= substr($wagon->{id}, 4, 1) %></span><span class="wagonclass"><%= substr($wagon->{id}, 5, 3) %></span><span class="wagonnum"><%= substr($wagon->{id}, 8, 3) %></span><span class="checksum"><%= substr($wagon->{id}, 11) %></span>
|
||||
%= $wagon->{type}
|
||||
% if ($wagon->{number}) {
|
||||
– Wagen <%= $wagon->{number} %>
|
||||
% }
|
||||
<br/>
|
||||
% }
|
||||
</td>
|
||||
</tr>
|
||||
% }
|
||||
<tr>
|
||||
<th scope="row">Route</th>
|
||||
<td>
|
||||
|
@ -194,35 +220,12 @@
|
|||
% }
|
||||
</td>
|
||||
</tr>
|
||||
% if ($journey->{user_data} and $journey->{user_data}{wagongroups} and not exists $journey->{user_data}{wagons}) {
|
||||
<tr>
|
||||
<th scope="row">Rollmaterial</th>
|
||||
<td class="wagons">
|
||||
%= include '_wagons', wagongroups => $journey->{user_data}{wagongroups};
|
||||
</td>
|
||||
</tr>
|
||||
% }
|
||||
% elsif ($journey->{user_data} and $journey->{user_data}{wagons}) {
|
||||
<tr>
|
||||
<th scope="row">Rollmaterial</th>
|
||||
<td class="wagons">
|
||||
% for my $wagongroup (@{$journey->{user_data}{wagongroups} // []}) {
|
||||
Wagenverbund <%= $wagongroup %><br/>
|
||||
% }
|
||||
% for my $wagon (@{$journey->{user_data}{wagons}}) {
|
||||
<span><%= substr($wagon->{id}, 0, 2) %></span><span><%= substr($wagon->{id}, 2, 2) %></span><span><%= substr($wagon->{id}, 4, 1) %></span><span class="wagonclass"><%= substr($wagon->{id}, 5, 3) %></span><span class="wagonnum"><%= substr($wagon->{id}, 8, 3) %></span><span class="checksum"><%= substr($wagon->{id}, 11) %></span>
|
||||
%= $wagon->{type}
|
||||
% if ($wagon->{number}) {
|
||||
– Wagen <%= $wagon->{number} %>
|
||||
% }
|
||||
<br/>
|
||||
% }
|
||||
</td>
|
||||
</tr>
|
||||
% }
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
% if (stash('polyline_groups')) {
|
||||
%= include '_map', station_coordinates => stash('station_coordinates'), polyline_groups => stash('polyline_groups')
|
||||
% }
|
||||
% if (not stash('readonly')) {
|
||||
<div class="row hide-on-small-only">
|
||||
<div class="col s12 m6 l6 center-align">
|
||||
|
|
Loading…
Reference in a new issue