Leipzig.pm

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