| 1 | # -*- perl -*- | ||
| 2 | |||
| 3 | # | ||
| 4 | # Author: Slaven Rezic | ||
| 5 | # | ||
| 6 | # Copyright (C) 2014,2015,2016,2017,2018,2019,2020,2021,2023,2024,2025 Slaven Rezic. All rights reserved. | ||
| 7 | # This package is free software; you can redistribute it and/or | ||
| 8 | # modify it under the same terms as Perl itself. | ||
| 9 | # | ||
| 10 | # Mail: srezic@cpan.org | ||
| 11 | # | ||
| 12 | |||
| 13 | package Map::Tube::Berlin; | ||
| 14 | |||
| 15 | $VERSION = '2025.1214'; | ||
| 16 | |||
| 17 | =head1 NAME | ||
| 18 | |||
| 19 | Map::Tube::Berlin - interface to the Berlin S- and U-Bahn map | ||
| 20 | |||
| 21 | =cut | ||
| 22 | |||
| 23 | 1 | ▶ | use File::Share ':all'; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 24 | |||
| 25 | 1 | ▶ | use Moo; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 26 | 1 | ▶ | use namespace::clean; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 27 | |||
| 28 | has xml => (is => 'ro', default => sub { return dist_file('Map-Tube-Berlin', 'berlin-map.xml') }); | ||
| 29 | |||
| 30 | with 'Map::Tube'; | ||
| 31 | |||
| 32 | =head1 DESCRIPTION | ||
| 33 | |||
| 34 | It currently provides functionality to find the shortest route between | ||
| 35 | the two given stations. The map contains both U-Bahn and S-Bahn stations. | ||
| 36 | |||
| 37 | =head1 CONSTRUCTOR | ||
| 38 | |||
| 39 | use Map::Tube::Berlin; | ||
| 40 | my $tube = Map::Tube::Berlin->new; | ||
| 41 | |||
| 42 | =head1 METHODS | ||
| 43 | |||
| 44 | =head2 get_shortest_route(I<START>, I<END>) | ||
| 45 | |||
| 46 | This method expects two parameters I<START> and I<END> station name. | ||
| 47 | Station names are case insensitive. The station sequence from I<START> | ||
| 48 | to I<END> is returned. | ||
| 49 | |||
| 50 | use Map::Tube::Berlin; | ||
| 51 | my $tube = Map::Tube::Berlin->new; | ||
| 52 | |||
| 53 | my $route = $tube->get_shortest_route('Zoologischer Garten', 'Alexanderplatz'); | ||
| 54 | |||
| 55 | print "Route: $route\n"; | ||
| 56 | |||
| 57 | =head1 NOTES | ||
| 58 | |||
| 59 | The XML file was generated using data from the L<BBBike | ||
| 60 | project|https://github.com/eserte/bbbike>. A Makefile rule | ||
| 61 | C<build-map> for regenerating the XML file exists (assuming that | ||
| 62 | BBBike was cloned/extracted into F<$HOME/src/bbbike>). | ||
| 63 | |||
| 64 | =head1 AUTHOR | ||
| 65 | |||
| 66 | Slaven Rezic | ||
| 67 | |||
| 68 | =head1 SEE ALSO | ||
| 69 | |||
| 70 | L<Map::Tube>. | ||
| 71 | |||
| 72 | =cut | ||
| 73 | |||
| 74 | 1; | ||