| 1 | # -*- perl -*- | ||
| 2 | # | ||
| 3 | # Author: Gisbert W. Selke, TapirSoft Selke & Selke GbR. | ||
| 4 | # | ||
| 5 | # Copyright (C) 2025--2026 Gisbert W. Selke. All rights reserved. | ||
| 6 | # This package is free software; you can redistribute it and/or | ||
| 7 | # modify it under the same terms as Perl itself. | ||
| 8 | # | ||
| 9 | # Mail: gws@cpan.org | ||
| 10 | # | ||
| 11 | package Map::Tube::Stockholm; | ||
| 12 | 1 | ▶ | use 5.14.0; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 13 | 1 | ▶ | use version 0.77 ( ); |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 14 | 1 | ▶ | use strict; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 15 | 1 | ▶ | use warnings; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 16 | |||
| 17 | our $VERSION = version->declare('v0.1.4'); | ||
| 18 | |||
| 19 | =encoding utf8 | ||
| 20 | |||
| 21 | =head1 NAME | ||
| 22 | |||
| 23 | Map::Tube::Stockholm - Interface to the Stockholm tube and tram map | ||
| 24 | |||
| 25 | =cut | ||
| 26 | |||
| 27 | 1 | ▶ | use File::Share ':all'; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 28 | 1 | ▶ | use Moo; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 29 | 1 | ▶ | use namespace::clean; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 30 | |||
| 31 | has xml => ( is => 'ro', default => sub { return dist_file('Map-Tube-Stockholm', 'stockholm-map.xml') } ); | ||
| 32 | |||
| 33 | with 'Map::Tube'; | ||
| 34 | |||
| 35 | =head1 SYNOPSIS | ||
| 36 | |||
| 37 | use Map::Tube::Stockholm; | ||
| 38 | my $tube = Map::Tube::Stockholm->new(); | ||
| 39 | |||
| 40 | my $route = $tube->get_shortest_route( 'Slussen', 'Solna strand'); | ||
| 41 | |||
| 42 | print "Route: $route\n"; | ||
| 43 | |||
| 44 | =head1 DESCRIPTION | ||
| 45 | |||
| 46 | This module allows to find the shortest route between any two given tube or tram | ||
| 47 | stations in Stockholm. All interesting methods are provided by the role L<Map::Tube>. | ||
| 48 | |||
| 49 | =head1 METHODS | ||
| 50 | |||
| 51 | =head2 CONSTRUCTOR | ||
| 52 | |||
| 53 | use Map::Tube::Stockholm; | ||
| 54 | my $tube = Map::Tube::Stockholm->new(); | ||
| 55 | |||
| 56 | The only argument, C<xml>, is optional; if specified, it should be a code ref | ||
| 57 | to a function that returns either the path the XML map file, or a string | ||
| 58 | containing this XML content. The default is the path to F<stockholm-map.xml> | ||
| 59 | that is a part of this distribution. For further information see L<Map::Tube>. | ||
| 60 | |||
| 61 | =head2 xml() | ||
| 62 | |||
| 63 | This read-only accessor returns whatever was specified as the XML source at | ||
| 64 | construction. | ||
| 65 | |||
| 66 | =head1 NOTE CONCERNING DIAGRAM CREATION | ||
| 67 | |||
| 68 | This note concerns only those who want to produce network diagrams using | ||
| 69 | L<Map::Tube::Plugin::Graph> (also pertaining to L<Map::Tube::CLI>) or | ||
| 70 | L<Map::Tube::GraphViz>. | ||
| 71 | |||
| 72 | There is a potential conflict between an advanced feature of the (excellent) L<GraphViz2> | ||
| 73 | module and the Swedish station names, which may lead to an exception being thrown. | ||
| 74 | |||
| 75 | Users of L<Map::Tube::Plugin::Graph> are encouraged to upgrade to at least version 0.48, | ||
| 76 | which solves the issue cleanly. This also applies to indirect use of this module | ||
| 77 | through L<Map::Tube::CLI> and the corresponding command line programme. | ||
| 78 | |||
| 79 | Users of L<Map::Tube::GraphViz> can prevent any issue cleanly by defining a function | ||
| 80 | as follows: | ||
| 81 | |||
| 82 | sub mynode_id { | ||
| 83 | my ($self, $node) = @_; | ||
| 84 | return $node->id; | ||
| 85 | }; | ||
| 86 | |||
| 87 | and supplying this as a callback function when creating the diagram: | ||
| 88 | |||
| 89 | my $g = Map::Tube::GraphViz->new( 'tube' => $tube, | ||
| 90 | callback_node_id => \&mynode_id, ); | ||
| 91 | |||
| 92 | |||
| 93 | =head1 ERRORS | ||
| 94 | |||
| 95 | If something goes wrong, maybe because the map information file was corrupted, | ||
| 96 | the constructor will die. | ||
| 97 | |||
| 98 | =head1 BUGS | ||
| 99 | |||
| 100 | Please report any bugs or feature requests through the web interface at | ||
| 101 | L<https://github.com/gwselke/Map-Tube-Stockholm/issues>. I will be | ||
| 102 | notified and then you'll automatically be notified of progress on your | ||
| 103 | bug when (and if) I make changes. | ||
| 104 | |||
| 105 | =head1 AUTHOR | ||
| 106 | |||
| 107 | Gisbert W. Selke, TapirSoft Selke & Selke GbR. | ||
| 108 | |||
| 109 | =head1 COPYRIGHT AND LICENCE | ||
| 110 | |||
| 111 | The data for the XML file were taken from https://tunnelbanakarta.se/ | ||
| 112 | The module itself is free software; you may redistribute and/or modify | ||
| 113 | it under the same terms as Perl itself. | ||
| 114 | |||
| 115 | =head1 SEE ALSO | ||
| 116 | |||
| 117 | L<Map::Tube>, L<Map::Tube::GraphViz>, L<Map::Tube::Plugin::Graph>. | ||
| 118 | |||
| 119 | =cut | ||
| 120 | |||
| 121 | 1; | ||