| 1 | package Map::Tube::Barcelona; | ||
| 2 | |||
| 3 | 1 | ▶ | use version; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 4 | |||
| 5 | our $VERSION = qv('v1.0.1'); | ||
| 6 | our $AUTHORITY = 'cpan:MANWAR'; | ||
| 7 | |||
| 8 | =head1 NAME | ||
| 9 | |||
| 10 | Map::Tube::Barcelona - Interface to the Barcelona Metro Map. | ||
| 11 | |||
| 12 | =head1 VERSION | ||
| 13 | |||
| 14 | Version v1.0.1 | ||
| 15 | |||
| 16 | =cut | ||
| 17 | |||
| 18 | 1 | ▶ | use 5.006; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 19 | 1 | ▶ | use Data::Dumper; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 20 | 1 | ▶ | use File::ShareDir ':ALL'; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 21 | |||
| 22 | 1 | ▶ | use Moo; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 23 | 1 | ▶ | use namespace::autoclean; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 24 | |||
| 25 | has xml => (is => 'lazy'); | ||
| 26 | with 'Map::Tube'; | ||
| 27 | |||
| 28 | 0 | ▶ | sub _build_xml { dist_file('Map-Tube-Barcelona', 'barcelona-map.xml') } |
|
Subroutine
_build_xml: not called CC=1 SCAR=6.9
| |||
| 29 | |||
| 30 | =head1 DESCRIPTION | ||
| 31 | |||
| 32 | It currently provides functionality to find the shortest route between the two | ||
| 33 | given stations. It covers the following Barcelona Metro Lines: | ||
| 34 | |||
| 35 | =over 2 | ||
| 36 | |||
| 37 | =item * L<L1 Line|Map::Tube::Barcelona::Line::L1> | ||
| 38 | |||
| 39 | =item * L<L2 Line|Map::Tube::Barcelona::Line::L2> | ||
| 40 | |||
| 41 | =item * L<L3 Line|Map::Tube::Barcelona::Line::L3> | ||
| 42 | |||
| 43 | =item * L<L4 Line|Map::Tube::Barcelona::Line::L4> | ||
| 44 | |||
| 45 | =item * L<L5 Line|Map::Tube::Barcelona::Line::L5> | ||
| 46 | |||
| 47 | =item * L<L6 Line|Map::Tube::Barcelona::Line::L6> | ||
| 48 | |||
| 49 | =item * L<L7 Line|Map::Tube::Barcelona::Line::L7> | ||
| 50 | |||
| 51 | =item * L<L8 Line|Map::Tube::Barcelona::Line::L8> | ||
| 52 | |||
| 53 | =item * L<L9 Line|Map::Tube::Barcelona::Line::L9> | ||
| 54 | |||
| 55 | =item * L<L10 Line|Map::Tube::Barcelona::Line::L10> | ||
| 56 | |||
| 57 | =item * L<L11 Line|Map::Tube::Barcelona::Line::L11> | ||
| 58 | |||
| 59 | =back | ||
| 60 | |||
| 61 | There is a very handy tool provided by L<Map::Tube::CLI> called C<map-tube> which | ||
| 62 | exposes the map (and all other maps) from command line. Please refer to its pod | ||
| 63 | document for more details. | ||
| 64 | |||
| 65 | =head1 MAP DATA | ||
| 66 | |||
| 67 | The map data collected from L<this website|https://www.barcelona-tourist-guide.com/en/maps/barcelona-metro-map.html>. | ||
| 68 | |||
| 69 | =head1 CONSTRUCTOR | ||
| 70 | |||
| 71 | The constructor DO NOT expects parameters.This setup the default node definitions. | ||
| 72 | |||
| 73 | use strict; use warnings; | ||
| 74 | use Map::Tube::Barcelona; | ||
| 75 | |||
| 76 | my $metro = Map::Tube::Barcelona->new; | ||
| 77 | |||
| 78 | =head1 METHODS | ||
| 79 | |||
| 80 | =head2 get_shortest_route($from, $to) | ||
| 81 | |||
| 82 | It expects C<$from> and C<$to> station name, required param. It returns an object | ||
| 83 | of type L<Map::Tube::Route>. On error it throws exception of type L<Map::Tube::Exception>. | ||
| 84 | |||
| 85 | use strict; use warnings; | ||
| 86 | use Map::Tube::Barcelona; | ||
| 87 | |||
| 88 | my $metro = Map::Tube::Barcelona->new; | ||
| 89 | my $route = $metro->get_shortest_route('Roquetes', 'Maragall'); | ||
| 90 | |||
| 91 | print "Route: $route\n"; | ||
| 92 | |||
| 93 | =head2 as_image($line_name) | ||
| 94 | |||
| 95 | It expects the plugin L<Map::Tube::Plugin::Graph> to be installed. Returns line | ||
| 96 | image as base64 encoded string if C<$line_name> passed in otherwise it returns | ||
| 97 | base64 encoded string of the entire map. | ||
| 98 | |||
| 99 | use strict; use warnings; | ||
| 100 | use MIME::Base64; | ||
| 101 | use Map::Tube::Barcelona; | ||
| 102 | |||
| 103 | my $metro = Map::Tube::Barcelona->new; | ||
| 104 | my $map = $metro->name; | ||
| 105 | open(my $IMAGE, ">", "$map.png") | ||
| 106 | or die "ERROR: Can't open [$map.png]: $!"; | ||
| 107 | binmode($IMAGE); | ||
| 108 | print $IMAGE decode_base64($metro->as_image); | ||
| 109 | close($IMAGE); | ||
| 110 | |||
| 111 | The L<Barcelona Metro Map|https://raw.githubusercontent.com/manwar/Map-Tube-Barcelona/master/maps/Barcelona-Metro.png> | ||
| 112 | map as generated by plugin L<Map::Tube::Plugin::Graph>. | ||
| 113 | |||
| 114 | =begin html | ||
| 115 | |||
| 116 | <a href = "https://raw.githubusercontent.com/manwar/Map-Tube-Barcelona/master/maps/Barcelona-Metro.png"> | ||
| 117 | <img src = "https://raw.githubusercontent.com/manwar/Map-Tube-Barcelona/master/maps/Barcelona-Metro.png" | ||
| 118 | alt = "Barcelona Metro Map" | ||
| 119 | width = "600px" | ||
| 120 | height = "800px"/> | ||
| 121 | </a> | ||
| 122 | |||
| 123 | =end html | ||
| 124 | |||
| 125 | =head1 AUTHOR | ||
| 126 | |||
| 127 | Mohammad Sajid Anwar, C<< <mohammad.anwar at yahoo.com> >> | ||
| 128 | |||
| 129 | =head1 REPOSITORY | ||
| 130 | |||
| 131 | L<https://github.com/manwar/Map-Tube-Barcelona> | ||
| 132 | |||
| 133 | =head1 SEE ALSO | ||
| 134 | |||
| 135 | =over 2 | ||
| 136 | |||
| 137 | =item * L<Map::Tube> | ||
| 138 | |||
| 139 | =item * L<Map::Tube::CLI> | ||
| 140 | |||
| 141 | =back | ||
| 142 | |||
| 143 | =head1 BUGS | ||
| 144 | |||
| 145 | Please report any bugs or feature requests through the web interface at L<https://github.com/manwar/Map-Tube-Barcelona/issues>. | ||
| 146 | I will be notified and then you'll automatically be notified of progress on your | ||
| 147 | bug as I make changes. | ||
| 148 | |||
| 149 | =head1 SUPPORT | ||
| 150 | |||
| 151 | You can find documentation for this module with the perldoc command. | ||
| 152 | |||
| 153 | perldoc Map::Tube::Barcelona | ||
| 154 | |||
| 155 | You can also look for information at: | ||
| 156 | |||
| 157 | =over 4 | ||
| 158 | |||
| 159 | =item * BUG Report | ||
| 160 | |||
| 161 | L<https://github.com/manwar/Map-Tube-Barcelona/issues> | ||
| 162 | |||
| 163 | =item * CPAN Ratings | ||
| 164 | |||
| 165 | L<http://cpanratings.perl.org/d/Map-Tube-Barcelona> | ||
| 166 | |||
| 167 | =item * Search MetaCPAN | ||
| 168 | |||
| 169 | L<https://metacpan.org/dist/Map-Tube-Barcelona/> | ||
| 170 | |||
| 171 | =back | ||
| 172 | |||
| 173 | =head1 LICENSE AND COPYRIGHT | ||
| 174 | |||
| 175 | Copyright (C) 2014 - 2026 Mohammad Sajid Anwar. | ||
| 176 | |||
| 177 | This program is free software; you can redistribute it and / or modify it under | ||
| 178 | the terms of the the Artistic License (2.0). You may obtain a copy of the full | ||
| 179 | license at: | ||
| 180 | |||
| 181 | L<http://www.perlfoundation.org/artistic_license_2_0> | ||
| 182 | |||
| 183 | Any use, modification, and distribution of the Standard or Modified Versions is | ||
| 184 | governed by this Artistic License.By using, modifying or distributing the Package, | ||
| 185 | you accept this license. Do not use, modify, or distribute the Package, if you do | ||
| 186 | not accept this license. | ||
| 187 | |||
| 188 | If your Modified Version has been derived from a Modified Version made by someone | ||
| 189 | other than you,you are nevertheless required to ensure that your Modified Version | ||
| 190 | complies with the requirements of this license. | ||
| 191 | |||
| 192 | This license does not grant you the right to use any trademark, service mark, | ||
| 193 | tradename, or logo of the Copyright Holder. | ||
| 194 | |||
| 195 | This license includes the non-exclusive, worldwide, free-of-charge patent license | ||
| 196 | to make, have made, use, offer to sell, sell, import and otherwise transfer the | ||
| 197 | Package with respect to any patent claims licensable by the Copyright Holder that | ||
| 198 | are necessarily infringed by the Package. If you institute patent litigation | ||
| 199 | (including a cross-claim or counterclaim) against any party alleging that the | ||
| 200 | Package constitutes direct or contributory patent infringement,then this Artistic | ||
| 201 | License to you shall terminate on the date that such litigation is filed. | ||
| 202 | |||
| 203 | Disclaimer of Warranty: THE PACKAGE IS PROVIDED BY THE COPYRIGHT HOLDER AND | ||
| 204 | CONTRIBUTORS "AS IS' AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES. THE IMPLIED | ||
| 205 | WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR | ||
| 206 | NON-INFRINGEMENT ARE DISCLAIMED TO THE EXTENT PERMITTED BY YOUR LOCAL LAW. UNLESS | ||
| 207 | REQUIRED BY LAW, NO COPYRIGHT HOLDER OR CONTRIBUTOR WILL BE LIABLE FOR ANY DIRECT, | ||
| 208 | INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING IN ANY WAY OUT OF THE USE | ||
| 209 | OF THE PACKAGE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
| 210 | |||
| 211 | =cut | ||
| 212 | |||
| 213 | 1; # End of Map::Tube::Barcelona | ||