| 1 | package Map::Tube::London; | ||
| 2 | |||
| 3 | 1 | ▶ | use strict; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 4 | 1 | ▶ | use warnings; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 5 | 1 | ▶ | use version; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 6 | |||
| 7 | our $VERSION = qv('v2.1.0'); | ||
| 8 | our $AUTHORITY = 'cpan:MANWAR'; | ||
| 9 | |||
| 10 | =head1 NAME | ||
| 11 | |||
| 12 | Map::Tube::London - Interface to the London Tube Map. | ||
| 13 | |||
| 14 | =head1 VERSION | ||
| 15 | |||
| 16 | Version v2.1.0 | ||
| 17 | |||
| 18 | =cut | ||
| 19 | |||
| 20 | 1 | ▶ | use 5.006; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 21 | 1 | ▶ | use Data::Dumper; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 22 | 1 | ▶ | use File::ShareDir ':ALL'; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 23 | |||
| 24 | 1 | ▶ | use Moo; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 25 | 1 | ▶ | use namespace::autoclean; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 26 | |||
| 27 | has json => (is => 'lazy'); | ||
| 28 | has skip => (is => 'lazy'); | ||
| 29 | with 'Map::Tube'; | ||
| 30 | |||
| 31 | 0 | ▶ | sub _build_json { dist_file('Map-Tube-London', 'london-map.json') } |
|
Subroutine
_build_json: not called CC=1 SCAR=6.9
| |||
| 32 | 0 | ▶ | sub _build_skip { |
|
Subroutine
_build_skip: not called CC=1 SCAR=6.9
| |||
| 33 | return { | ||
| 34 | 0 | 'Jubilee' => { | |
| 35 | 'Baker Street' => { 'Finchley Road' => 1 }, | ||
| 36 | 'Finchley Road' => { 'Wembley Park' => 1 }, | ||
| 37 | }, | ||
| 38 | 'Bakerloo' => { | ||
| 39 | 'Edgware Road' => { 'Baker Street' => 1 }, | ||
| 40 | 'Finchley Road' => { 'Baker Street' => 1 }, | ||
| 41 | }, | ||
| 42 | 'Circle' => { | ||
| 43 | 'Wood Lane' => { 'White City' => 1 }, | ||
| 44 | }, | ||
| 45 | 'District' => { | ||
| 46 | "Earl's Court" => { 'Barons Court' => 1 }, | ||
| 47 | 'Hammersmith' => { 'Turnham Green' => 1 }, | ||
| 48 | 'Acton Town' => { 'Turnham Green' => 1 }, | ||
| 49 | }, | ||
| 50 | 'Northern' => { | ||
| 51 | 'Waterloo' => { 'Bank' => 1 }, | ||
| 52 | }, | ||
| 53 | 'DLR' => { | ||
| 54 | 'West Ham' => { 'Stratford' => 1 }, | ||
| 55 | }, | ||
| 56 | }; | ||
| 57 | } | ||
| 58 | |||
| 59 | =head1 DESCRIPTION | ||
| 60 | |||
| 61 | It currently provides functionality to find the shortest route between the two | ||
| 62 | given nodes. It covers the following tube lines: | ||
| 63 | |||
| 64 | =over 2 | ||
| 65 | |||
| 66 | =item * L<Bakerloo Line|Map::Tube::London::Line::Bakerloo> | ||
| 67 | |||
| 68 | =item * L<Central Line|Map::Tube::London::Line::Central> | ||
| 69 | |||
| 70 | =item * L<Circle Line|Map::Tube::London::Line::Circle> | ||
| 71 | |||
| 72 | =item * L<District Line|Map::Tube::London::Line::District> | ||
| 73 | |||
| 74 | =item * L<Dockland Light Railway Line|Map::Tube::London::Line::DLR> | ||
| 75 | |||
| 76 | =item * L<Hammersmith & City Line|Map::Tube::London::Line::HammersmithCity> | ||
| 77 | |||
| 78 | =item * L<Jubilee Line|Map::Tube::London::Line::Jubilee> | ||
| 79 | |||
| 80 | =item * L<Metropolitan Line|Map::Tube::London::Line::Metropolitan> | ||
| 81 | |||
| 82 | =item * L<Northern Line|Map::Tube::London::Line::Northern> | ||
| 83 | |||
| 84 | =item * L<London Overground Line|Map::Tube::London::Line::Overground> | ||
| 85 | |||
| 86 | =item * L<Piccadilly Line|Map::Tube::London::Line::Piccadilly> | ||
| 87 | |||
| 88 | =item * L<Victoria Line|Map::Tube::London::Line::Victoria> | ||
| 89 | |||
| 90 | =item * L<Waterloo & City Line|Map::Tube::London::Line::WaterlooCity> | ||
| 91 | |||
| 92 | =back | ||
| 93 | |||
| 94 | =head1 CONSTRUCTOR | ||
| 95 | |||
| 96 | The constructor DO NOT expects parameters.This setup the default node definitions. | ||
| 97 | |||
| 98 | use strict; use warnings; | ||
| 99 | use Map::Tube::London; | ||
| 100 | |||
| 101 | my $tube = Map::Tube::London->new; | ||
| 102 | |||
| 103 | =head1 METHODS | ||
| 104 | |||
| 105 | =head2 get_shortest_route($from, $to) | ||
| 106 | |||
| 107 | It expects C<$from> and C<$to> station name, required param. It returns an object | ||
| 108 | of type L<Map::Tube::Route>. On error it throws exception of type L<Map::Tube::Exception>. | ||
| 109 | |||
| 110 | use strict; use warnings; | ||
| 111 | use Map::Tube::London; | ||
| 112 | |||
| 113 | my $tube = Map::Tube::London->new; | ||
| 114 | my $route = $tube->get_shortest_route('Baker Street', 'Farringdon'); | ||
| 115 | |||
| 116 | print "Route: $route\n";; | ||
| 117 | |||
| 118 | =head2 as_image($line_name) | ||
| 119 | |||
| 120 | It expects the plugin L<Map::Tube::Plugin::Graph> to be installed. Returns line | ||
| 121 | image as base64 encoded string if C<$line_name> passed in otherwise it returns | ||
| 122 | base64 encoded string of the entire map. | ||
| 123 | |||
| 124 | use strict; use warnings; | ||
| 125 | use MIME::Base64; | ||
| 126 | use Map::Tube::London; | ||
| 127 | |||
| 128 | my $tube = Map::Tube::London->new; | ||
| 129 | my $map = $tube->name; | ||
| 130 | open(my $IMAGE, ">", "$map.png"); | ||
| 131 | or die "ERROR: Can't open [$map.png]: $!"; | ||
| 132 | binmode($IMAGE); | ||
| 133 | print $IMAGE decode_base64($tube->as_image); | ||
| 134 | close($IMAGE); | ||
| 135 | |||
| 136 | The L<London Tube Map|https://raw.githubusercontent.com/manwar/Map-Tube-London/master/maps/London-Tube.png> | ||
| 137 | as generated by plugin L<Map::Tube::Plugin::Graph>. | ||
| 138 | |||
| 139 | =begin html | ||
| 140 | |||
| 141 | <a href = "https://raw.githubusercontent.com/manwar/Map-Tube-London/master/maps/London-Tube.png"> | ||
| 142 | <img src = "https://raw.githubusercontent.com/manwar/Map-Tube-London/master/maps/London-Tube.png" | ||
| 143 | alt = "London Tube Map" | ||
| 144 | width = "740px" | ||
| 145 | height = "780px"/> | ||
| 146 | </a> | ||
| 147 | |||
| 148 | =end html | ||
| 149 | |||
| 150 | =head1 AUTHOR | ||
| 151 | |||
| 152 | Mohammad Sajid Anwar, C<< <mohammad.anwar at yahoo.com> >> | ||
| 153 | |||
| 154 | =head1 REPOSITORY | ||
| 155 | |||
| 156 | L<https://github.com/manwar/Map-Tube-London> | ||
| 157 | |||
| 158 | =head1 CONTRIBUTORS | ||
| 159 | |||
| 160 | =over 2 | ||
| 161 | |||
| 162 | =item * Ed J | ||
| 163 | |||
| 164 | =back | ||
| 165 | |||
| 166 | =head1 BUGS | ||
| 167 | |||
| 168 | Please report any bugs or feature requests through the web interface at L<https://github.com/manwar/Map-Tube-London/issues>. | ||
| 169 | I will be notified and then you'll automatically be notified of progress on your | ||
| 170 | bug as I make changes. | ||
| 171 | |||
| 172 | =head1 SUPPORT | ||
| 173 | |||
| 174 | You can find documentation for this module with the perldoc command. | ||
| 175 | |||
| 176 | perldoc Map::Tube::London | ||
| 177 | |||
| 178 | You can also look for information at: | ||
| 179 | |||
| 180 | =over 4 | ||
| 181 | |||
| 182 | =item * BUG Report | ||
| 183 | |||
| 184 | L<https://github.com/manwar/Map-Tube-London/issues> | ||
| 185 | |||
| 186 | =item * Search MetaCPAN | ||
| 187 | |||
| 188 | L<https://metacpan.org/dist/Map-Tube-London> | ||
| 189 | |||
| 190 | =back | ||
| 191 | |||
| 192 | =head1 LICENSE AND COPYRIGHT | ||
| 193 | |||
| 194 | Copyright (C) 2014 - 2026 Mohammad Sajid Anwar. | ||
| 195 | |||
| 196 | This program is free software; you can redistribute it and/or modify it under | ||
| 197 | the terms of the Artistic License (2.0). | ||
| 198 | |||
| 199 | =cut | ||
| 200 | |||
| 201 | 1; # End of Map::Tube::London | ||