| 1 | package Map::Tube::Leipzig; | ||
| 2 | |||
| 3 | 5 | ▶ | use version; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 4 | |||
| 5 | our $VERSION = qv('v1.0.0'); | ||
| 6 | our $AUTHORITY = 'cpan:MANWAR'; | ||
| 7 | |||
| 8 | =head1 NAME | ||
| 9 | |||
| 10 | Map::Tube::Leipzig - Interface to the Leipzig/Halle S-Bahn and Tram Map. | ||
| 11 | |||
| 12 | =head1 VERSION | ||
| 13 | |||
| 14 | Version v1.0.0 | ||
| 15 | |||
| 16 | =cut | ||
| 17 | |||
| 18 | 5 | ▶ | use v5.14; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 19 | 5 | ▶ | use File::ShareDir ':ALL'; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 20 | |||
| 21 | 5 | ▶ | use Moo; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 22 | 5 | ▶ | use namespace::autoclean; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 23 | |||
| 24 | has xml => (is => 'ro', default => sub { return dist_file('Map-Tube-Leipzig', 'leipzig-map.xml') }); | ||
| 25 | |||
| 26 | with 'Map::Tube'; | ||
| 27 | |||
| 28 | =encoding utf8 | ||
| 29 | |||
| 30 | =head1 DESCRIPTION | ||
| 31 | |||
| 32 | This was created and published while participating in the B<Perl Toolchain Summit 2025> in Leipzip, Germany. | ||
| 33 | It was later expanded for more coverage. | ||
| 34 | |||
| 35 | It currently provides functionality to find the shortest route between the two | ||
| 36 | given nodes. | ||
| 37 | |||
| 38 | =head1 MAP DATA | ||
| 39 | |||
| 40 | The map data collected from local websites showing rail maps and schedules. | ||
| 41 | |||
| 42 | =head1 CONSTRUCTOR | ||
| 43 | |||
| 44 | The constructor DOES NOT expect parameters. This sets up the default node (stations and lines) definitions. | ||
| 45 | |||
| 46 | use strict; | ||
| 47 | use warnings; | ||
| 48 | use Map::Tube::Leipzig; | ||
| 49 | |||
| 50 | my $rail = Map::Tube::Leipzig->new; | ||
| 51 | |||
| 52 | =head1 METHODS | ||
| 53 | |||
| 54 | See L<Map::Tube> for the full documentation of the methods provided. | ||
| 55 | |||
| 56 | =head2 get_shortest_route($from, $to) | ||
| 57 | |||
| 58 | It expects C<$from> and C<$to> station name, required param. It returns an object | ||
| 59 | of type L<Map::Tube::Route>. On error it throws exception of type L<Map::Tube::Exception>. | ||
| 60 | |||
| 61 | use strict; | ||
| 62 | use warnings; | ||
| 63 | use Map::Tube::Leipzig; | ||
| 64 | |||
| 65 | my $rail = Map::Tube::Leipzig->new; | ||
| 66 | my $route= $rail->get_shortest_route('Trotha', 'Halle Messe'); | ||
| 67 | |||
| 68 | print "Route: $route\n";; | ||
| 69 | |||
| 70 | =head2 as_image($line_name) | ||
| 71 | |||
| 72 | It expects the plugin L<Map::Tube::Plugin::Graph> to be installed. Returns line | ||
| 73 | image as base64 encoded string if C<$line_name> passed in otherwise it returns | ||
| 74 | base64 encoded string of the entire map. | ||
| 75 | |||
| 76 | use strict; | ||
| 77 | use warnings; | ||
| 78 | use MIME::Base64; | ||
| 79 | use Map::Tube::Leipzig; | ||
| 80 | |||
| 81 | my $rail = Map::Tube::Leipzig->new; | ||
| 82 | my $map = $rail->name; | ||
| 83 | open(my $IMAGE, ">", "$map.png") | ||
| 84 | or die "ERROR: Can't open [$map.png]: $!"; | ||
| 85 | binmode($IMAGE); | ||
| 86 | print $IMAGE decode_base64($subway->as_image); | ||
| 87 | close($IMAGE); | ||
| 88 | |||
| 89 | =head1 AUTHOR | ||
| 90 | |||
| 91 | Mohammad Sajid Anwar, C<< <mohammad.anwar at yahoo.com> >> | ||
| 92 | |||
| 93 | =head1 CONTRIBUTORS | ||
| 94 | |||
| 95 | =over 2 | ||
| 96 | |||
| 97 | =item * Gisbert W. Selke, C<< <gws at cpan.org> >> | ||
| 98 | |||
| 99 | =back | ||
| 100 | |||
| 101 | =head1 REPOSITORY | ||
| 102 | |||
| 103 | L<https://github.com/manwar/Map-Tube-Leipzig> | ||
| 104 | |||
| 105 | =head1 BUGS | ||
| 106 | |||
| 107 | Please report any bugs or feature requests through the web interface at L<https://github.com/manwar/Map-Tube-Leipzig/issues>. | ||
| 108 | I will be notified and then you'll automatically be notified of progress on your | ||
| 109 | bug as I make changes. | ||
| 110 | |||
| 111 | =head1 SUPPORT | ||
| 112 | |||
| 113 | You can find documentation for this module with the perldoc command. | ||
| 114 | |||
| 115 | perldoc Map::Tube::Leipzig | ||
| 116 | |||
| 117 | You can also look for information at: | ||
| 118 | |||
| 119 | =over 4 | ||
| 120 | |||
| 121 | =item * BUG Report | ||
| 122 | |||
| 123 | L<https://github.com/manwar/Map-Tube-Leipzig/issues> | ||
| 124 | |||
| 125 | =item * Search MetaCPAN | ||
| 126 | |||
| 127 | L<https://metacpan.org/dist/Map-Tube-Leipzig> | ||
| 128 | |||
| 129 | =back | ||
| 130 | |||
| 131 | =head1 LICENSE AND COPYRIGHT | ||
| 132 | |||
| 133 | Copyright (C) 2026 Mohammad Sajid Anwar. | ||
| 134 | |||
| 135 | This program is free software; you can redistribute it and/or modify it under | ||
| 136 | the terms of the the Artistic License (2.0). You may obtain a copy of the full | ||
| 137 | license at: | ||
| 138 | |||
| 139 | L<http://www.perlfoundation.org/artistic_license_2_0> | ||
| 140 | |||
| 141 | Any use, modification, and distribution of the Standard or Modified Versions is | ||
| 142 | governed by this Artistic License.By using, modifying or distributing the Package, | ||
| 143 | you accept this license. Do not use, modify, or distribute the Package, if you do | ||
| 144 | not accept this license. | ||
| 145 | |||
| 146 | If your Modified Version has been derived from a Modified Version made by someone | ||
| 147 | other than you,you are nevertheless required to ensure that your Modified Version | ||
| 148 | complies with the requirements of this license. | ||
| 149 | |||
| 150 | This license does not grant you the right to use any trademark, service mark, | ||
| 151 | tradename, or logo of the Copyright Holder. | ||
| 152 | |||
| 153 | This license includes the non-exclusive, worldwide, free-of-charge patent license | ||
| 154 | to make, have made, use, offer to sell, sell, import and otherwise transfer the | ||
| 155 | Package with respect to any patent claims licensable by the Copyright Holder that | ||
| 156 | are necessarily infringed by the Package. If you institute patent litigation | ||
| 157 | (including a cross-claim or counterclaim) against any party alleging that the | ||
| 158 | Package constitutes direct or contributory patent infringement,then this Artistic | ||
| 159 | License to you shall terminate on the date that such litigation is filed. | ||
| 160 | |||
| 161 | Disclaimer of Warranty: THE PACKAGE IS PROVIDED BY THE COPYRIGHT HOLDER AND | ||
| 162 | CONTRIBUTORS "AS IS' AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES. THE IMPLIED | ||
| 163 | WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR | ||
| 164 | NON-INFRINGEMENT ARE DISCLAIMED TO THE EXTENT PERMITTED BY YOUR LOCAL LAW. UNLESS | ||
| 165 | REQUIRED BY LAW, NO COPYRIGHT HOLDER OR CONTRIBUTOR WILL BE LIABLE FOR ANY DIRECT, | ||
| 166 | INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING IN ANY WAY OUT OF THE USE | ||
| 167 | OF THE PACKAGE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
| 168 | |||
| 169 | =cut | ||
| 170 | |||
| 171 | 1; # End of Map::Tube::Leipzig | ||