line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Map::Tube::NYC; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
$Map::Tube::NYC::VERSION = '0.46'; |
4
|
|
|
|
|
|
|
$Map::Tube::NYC::AUTHORITY = 'cpan:MANWAR'; |
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
=head1 NAME |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
Map::Tube::NYC - Interface to the NYC Subway Map. |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
=head1 VERSION |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
Version 0.46 |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
=cut |
15
|
|
|
|
|
|
|
|
16
|
1
|
|
|
1
|
|
59957
|
use 5.006; |
|
1
|
|
|
|
|
3
|
|
17
|
1
|
|
|
1
|
|
365
|
use Data::Dumper; |
|
1
|
|
|
|
|
4844
|
|
|
1
|
|
|
|
|
61
|
|
18
|
1
|
|
|
1
|
|
219
|
use File::Share ':all'; |
|
1
|
|
|
|
|
5132
|
|
|
1
|
|
|
|
|
166
|
|
19
|
|
|
|
|
|
|
|
20
|
1
|
|
|
1
|
|
367
|
use Moo; |
|
1
|
|
|
|
|
7667
|
|
|
1
|
|
|
|
|
5
|
|
21
|
1
|
|
|
1
|
|
1224
|
use namespace::clean; |
|
1
|
|
|
|
|
7680
|
|
|
1
|
|
|
|
|
5
|
|
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
has xml => (is => 'ro', default => sub { return dist_file('Map-Tube-NYC', 'nyc-map.xml') }); |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
with 'Map::Tube'; |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
=encoding utf8 |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
=head1 DESCRIPTION |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
It currently provides functionality to find the shortest route between the two |
32
|
|
|
|
|
|
|
given nodes. It covers the following subway lines just yet: |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
=over 2 |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
=item * L |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
=item * L |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
=item * L |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
=item * L |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
=item * L |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
=item * L |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
=item * L |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
=back |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
=head1 TODO (Subway Lines) |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
=over 2 |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
=item * BMT Broadway Line |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
=item * IRT Broadway Line |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
=back |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
=head1 CONSTRUCTOR |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
The constructor DO NOT expects parameters.This setup the default node definitions. |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
use strict; use warnings; |
67
|
|
|
|
|
|
|
use Map::Tube::NYC; |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
my $subway = Map::Tube::NYC->new; |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
=head1 METHODS |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
=head2 get_shortest_route($from, $to) |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
It expects C<$from> and C<$to> station name, required param. It returns an object |
76
|
|
|
|
|
|
|
of type L. On error it throws exception of type L. |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
use strict; use warnings; |
79
|
|
|
|
|
|
|
use Map::Tube::NYC; |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
my $subway = Map::Tube::NYC->new; |
82
|
|
|
|
|
|
|
my $route = $subway->get_shortest_route('Canal Street', 'High Street'); |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
print "Route: $route\n";; |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=head2 as_image($line_name) |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
It expects the plugin L to be installed. Returns line |
89
|
|
|
|
|
|
|
image as base64 encoded string if C<$line_name> passed in otherwise it returns |
90
|
|
|
|
|
|
|
base64 encoded string of the entire map. |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
use strict; use warnings; |
93
|
|
|
|
|
|
|
use MIME::Base64; |
94
|
|
|
|
|
|
|
use Map::Tube::NYC; |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
my $subway = Map::Tube::NYC->new; |
97
|
|
|
|
|
|
|
my $map = $subway->name; |
98
|
|
|
|
|
|
|
open(my $IMAGE, ">$map.png"); |
99
|
|
|
|
|
|
|
binmode($IMAGE); |
100
|
|
|
|
|
|
|
print $IMAGE decode_base64($subway->as_image); |
101
|
|
|
|
|
|
|
close($IMAGE); |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
The L |
104
|
|
|
|
|
|
|
map as generated by plugin L. |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
=begin html |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
alt = "NYC Subway Map" |
111
|
|
|
|
|
|
|
width = "500px" |
112
|
|
|
|
|
|
|
height = "700px"/> |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
=end html |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
=head1 AUTHOR |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
Mohammad S Anwar, C<< >> |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
=head1 REPOSITORY |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
L |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
=head1 BUGS |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
Please report any bugs/feature requests to C, or |
128
|
|
|
|
|
|
|
through the web interface at L. |
129
|
|
|
|
|
|
|
I will be notified, and then you'll automatically be notified of progress on your |
130
|
|
|
|
|
|
|
bug as I make changes. |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
=head1 SUPPORT |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
You can find documentation for this module with the perldoc command. |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
perldoc Map::Tube::NYC |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
You can also look for information at: |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
=over 4 |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
=item * RT: CPAN's request tracker (report bugs here) |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
L |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
=item * AnnoCPAN: Annotated CPAN documentation |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
L |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
=item * CPAN Ratings |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
L |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
=item * Search CPAN |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
L |
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
=back |
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
=head1 LICENSE AND COPYRIGHT |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
Copyright (C) 2014 - 2016 Mohammad S Anwar. |
163
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it under |
165
|
|
|
|
|
|
|
the terms of the the Artistic License (2.0). You may obtain a copy of the full |
166
|
|
|
|
|
|
|
license at: |
167
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
L |
169
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
Any use, modification, and distribution of the Standard or Modified Versions is |
171
|
|
|
|
|
|
|
governed by this Artistic License.By using, modifying or distributing the Package, |
172
|
|
|
|
|
|
|
you accept this license. Do not use, modify, or distribute the Package, if you do |
173
|
|
|
|
|
|
|
not accept this license. |
174
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
If your Modified Version has been derived from a Modified Version made by someone |
176
|
|
|
|
|
|
|
other than you,you are nevertheless required to ensure that your Modified Version |
177
|
|
|
|
|
|
|
complies with the requirements of this license. |
178
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
This license does not grant you the right to use any trademark, service mark, |
180
|
|
|
|
|
|
|
tradename, or logo of the Copyright Holder. |
181
|
|
|
|
|
|
|
|
182
|
|
|
|
|
|
|
This license includes the non-exclusive, worldwide, free-of-charge patent license |
183
|
|
|
|
|
|
|
to make, have made, use, offer to sell, sell, import and otherwise transfer the |
184
|
|
|
|
|
|
|
Package with respect to any patent claims licensable by the Copyright Holder that |
185
|
|
|
|
|
|
|
are necessarily infringed by the Package. If you institute patent litigation |
186
|
|
|
|
|
|
|
(including a cross-claim or counterclaim) against any party alleging that the |
187
|
|
|
|
|
|
|
Package constitutes direct or contributory patent infringement,then this Artistic |
188
|
|
|
|
|
|
|
License to you shall terminate on the date that such litigation is filed. |
189
|
|
|
|
|
|
|
|
190
|
|
|
|
|
|
|
Disclaimer of Warranty: THE PACKAGE IS PROVIDED BY THE COPYRIGHT HOLDER AND |
191
|
|
|
|
|
|
|
CONTRIBUTORS "AS IS' AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES. THE IMPLIED |
192
|
|
|
|
|
|
|
WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR |
193
|
|
|
|
|
|
|
NON-INFRINGEMENT ARE DISCLAIMED TO THE EXTENT PERMITTED BY YOUR LOCAL LAW. UNLESS |
194
|
|
|
|
|
|
|
REQUIRED BY LAW, NO COPYRIGHT HOLDER OR CONTRIBUTOR WILL BE LIABLE FOR ANY DIRECT, |
195
|
|
|
|
|
|
|
INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING IN ANY WAY OUT OF THE USE |
196
|
|
|
|
|
|
|
OF THE PACKAGE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
197
|
|
|
|
|
|
|
|
198
|
|
|
|
|
|
|
=cut |
199
|
|
|
|
|
|
|
|
200
|
|
|
|
|
|
|
1; # End of Map::Tube::NYC |