line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
1
|
|
|
1
|
|
1083
|
use Map::Metro::Standard::Moops; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
12
|
|
2
|
1
|
|
|
1
|
|
3222
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
27
|
|
3
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
59
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
our $VERSION = '0.2300'; # VERSION |
6
|
|
|
|
|
|
|
# PODNAME: Map::Metro::Plugin::Hook::PrettyPrinter |
7
|
|
|
|
|
|
|
# ABSTRACT: Prints a routing |
8
|
|
|
|
|
|
|
|
9
|
1
|
|
|
1
|
|
1938
|
class Map::Metro::Plugin::Hook::PrettyPrinter { |
|
1
|
|
|
1
|
|
37
|
|
|
1
|
|
|
1
|
|
6
|
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
72
|
|
|
1
|
|
|
|
|
6
|
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
10
|
|
|
1
|
|
|
|
|
300
|
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
8
|
|
|
1
|
|
|
|
|
63
|
|
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
57
|
|
|
1
|
|
|
|
|
5
|
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
111
|
|
|
1
|
|
|
|
|
37
|
|
|
1
|
|
|
|
|
6
|
|
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
8
|
|
|
1
|
|
|
|
|
4619
|
|
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
9
|
|
|
1
|
|
|
|
|
6727
|
|
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
10
|
|
|
1
|
|
|
|
|
4573
|
|
|
1
|
|
|
|
|
469
|
|
|
1
|
|
|
|
|
14
|
|
|
1
|
|
|
|
|
81
|
|
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
16
|
|
|
1
|
|
|
|
|
238
|
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
9
|
|
|
1
|
|
|
|
|
1358
|
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
11
|
|
|
1
|
|
|
|
|
6557
|
|
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
5
|
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
27
|
|
|
1
|
|
|
|
|
7
|
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
56
|
|
|
1
|
|
|
|
|
5
|
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
160
|
|
|
1
|
|
|
|
|
9
|
|
|
1
|
|
|
|
|
5404
|
|
|
1
|
|
|
|
|
25
|
|
|
1
|
|
|
|
|
235
|
|
|
0
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
|
11
|
1
|
0
|
|
1
|
|
16898
|
method register { |
|
1
|
|
|
0
|
|
3
|
|
|
1
|
|
|
|
|
1100
|
|
|
1
|
|
|
|
|
16
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
before_add_routing => sub { |
13
|
|
|
|
|
|
|
|
14
|
0
|
|
|
0
|
|
|
my $self = shift; |
15
|
0
|
|
|
|
|
|
my $routing = shift; |
16
|
|
|
|
|
|
|
|
17
|
0
|
|
|
|
|
|
my $header = sprintf q{From %s to %s} => $routing->origin_station->name, $routing->destination_station->name; |
18
|
|
|
|
|
|
|
|
19
|
0
|
|
|
|
|
|
my @rows = ('', $header, '=' x length $header, ''); |
20
|
|
|
|
|
|
|
|
21
|
0
|
|
|
|
|
|
my $route_count = 0; |
22
|
0
|
|
|
|
|
|
my $longest_length = 0; |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
ROUTE: |
25
|
0
|
|
|
|
|
|
foreach my $route ($routing->ordered_routes) { |
26
|
|
|
|
|
|
|
|
27
|
0
|
|
|
|
|
|
my $line_name_length = $route->longest_line_name_length; |
28
|
0
|
0
|
|
|
|
|
$longest_length = $line_name_length if $line_name_length > $longest_length; |
29
|
|
|
|
|
|
|
|
30
|
0
|
|
|
|
|
|
push @rows => sprintf '-- Route %d (cost %s) ----------', ++$route_count, $route->weight; |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
STEP: |
33
|
0
|
|
|
|
|
|
foreach my $step ($route->all_steps) { |
34
|
0
|
0
|
0
|
|
|
|
push @rows => sprintf "[ %1s %-${line_name_length}s ] %s" => ($step->was_line_transfer && !$step->was_station_transfer ? '*' : ''), |
35
|
|
|
|
|
|
|
$step->origin_line_station->line->name, |
36
|
|
|
|
|
|
|
join '/' => $step->origin_line_station->station->name_with_alternative; |
37
|
0
|
0
|
|
|
|
|
if($step->is_station_transfer) { |
38
|
0
|
0
|
|
|
|
|
push @rows => sprintf "[ %1s %-${line_name_length}s ] %s" => ($step->is_station_transfer ? '+' : ''), |
39
|
|
|
|
|
|
|
' ' x length $step->origin_line_station->line->name, |
40
|
|
|
|
|
|
|
join '/' => $step->destination_line_station->station->name_with_alternative; |
41
|
|
|
|
|
|
|
} |
42
|
0
|
0
|
|
|
|
|
if(!$step->has_next_step) { |
43
|
0
|
|
|
|
|
|
push @rows => sprintf "[ %1s %-${line_name_length}s ] %s" => '', |
44
|
|
|
|
|
|
|
$step->destination_line_station->line->name, |
45
|
|
|
|
|
|
|
join '/' => $step->destination_line_station->station->name_with_alternative; |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
} |
48
|
0
|
|
|
|
|
|
push @rows => ''; |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
0
|
|
|
|
|
|
my @lines_in_routing = sort { $a->name cmp $b->name } map { $_->origin_line_station->line } map { $_->all_steps } $routing->all_routes; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
{ |
54
|
0
|
|
|
|
|
|
my %seen_lines = (); |
|
0
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
LINE: |
56
|
0
|
|
|
|
|
|
foreach my $line (@lines_in_routing) { |
57
|
0
|
0
|
|
|
|
|
next LINE if exists $seen_lines{ $line }; |
58
|
0
|
|
|
|
|
|
$seen_lines{ $line } = 1; |
59
|
0
|
|
|
|
|
|
push @rows => sprintf "%-${longest_length}s %s", $line->name, $line->description; |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
|
63
|
0
|
|
|
|
|
|
push @rows => '', '*: Transfer to other line', '+: Transfer to other station', ''; |
64
|
|
|
|
|
|
|
|
65
|
0
|
|
|
|
|
|
say join "\n" => @rows; |
66
|
|
|
|
|
|
|
|
67
|
0
|
|
|
|
|
|
}; |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
1; |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
__END__ |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
=pod |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
=encoding UTF-8 |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
=head1 NAME |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
Map::Metro::Plugin::Hook::PrettyPrinter - Prints a routing |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=head1 VERSION |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
Version 0.2300, released 2016-01-14. |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
=head1 SOURCE |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
L<https://github.com/Csson/p5-Map-Metro> |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=head1 HOMEPAGE |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
L<https://metacpan.org/release/Map-Metro> |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
=head1 AUTHOR |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
Erik Carlsson <info@code301.com> |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
This software is copyright (c) 2016 by Erik Carlsson. |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
104
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
=cut |