| 1 | package Map::Tube::Sydney; | ||
| 2 | |||
| 3 | $Map::Tube::Sydney::VERSION = '1.02'; | ||
| 4 | $Map::Tube::Sydney::AUTHORITY = 'cpan:EARLYBEAN'; | ||
| 5 | |||
| 6 | =head1 NAME | ||
| 7 | |||
| 8 | Map::Tube::Sydney - Interface to the Sydney Rail Network. | ||
| 9 | |||
| 10 | =head1 VERSION | ||
| 11 | |||
| 12 | Version 1.02 | ||
| 13 | |||
| 14 | =cut | ||
| 15 | |||
| 16 | 1 | ▶ | use 5.006; |
|
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 json => (is => 'lazy'); | ||
| 23 | has skip => (is => 'lazy'); | ||
| 24 | with 'Map::Tube'; | ||
| 25 | |||
| 26 | 0 | ▶ | sub _build_json { dist_file('Map-Tube-Sydney', 'sydney-map.json') } |
|
Subroutine
_build_json: not called CC=1 SCAR=6.9
| |||
| 27 | 0 | ▶ | sub _build_skip { |
|
Subroutine
_build_skip: not called CC=1 SCAR=6.9
| |||
| 28 | return { | ||
| 29 | 0 | 'T2' => { | |
| 30 | 'T125' => { 'T126' => 1, # Redfern <-> Strathfield express | ||
| 31 | 'T212' => 1 }, # Redfern <-> Burwood express | ||
| 32 | 'T126' => { 'T125' => 1, | ||
| 33 | 'T127' => 1 }, # Lidcombe <-> Strathfield express | ||
| 34 | 'T127' => { 'T126' => 1 }, | ||
| 35 | 'T212' => { 'T125' => 1 }, | ||
| 36 | 'T218' => { 'T219' => 1 }, # Harris Park <-> Merrylands | ||
| 37 | 'T219' => { 'T218' => 1 }, | ||
| 38 | }, | ||
| 39 | 'T3' => { | ||
| 40 | 'T125' => { 'T126' => 1, # Redfern <-> Strathfield express | ||
| 41 | 'T212' => 1 }, # Redfern <-> Burwood express | ||
| 42 | 'T126' => { 'T125' => 1, | ||
| 43 | 'T127' => 1 }, # Lidcombe <-> Strathfield express | ||
| 44 | 'T127' => { 'T126' => 1 }, | ||
| 45 | 'T212' => { 'T125' => 1 }, | ||
| 46 | }, | ||
| 47 | 'T8' => { | ||
| 48 | 'T125' => { 'T405' => 1 }, # Redfern <-> Sydenham express | ||
| 49 | 'T405' => { 'T125' => 1 }, | ||
| 50 | }, | ||
| 51 | 'T9' => { | ||
| 52 | 'T125' => { 'T126' => 1 }, # Redfern <-> Strathfield express | ||
| 53 | 'T126' => { 'T125' => 1 }, | ||
| 54 | }, | ||
| 55 | 'L2' => { | ||
| 56 | 'T122' => { 'T203' => 1, # Wynyard <-> Circular Quay by heavy rail | ||
| 57 | 'T123' => 1 }, # Wynyard <-> Town Hall by heavy rail | ||
| 58 | 'T123' => { 'T122' => 1 }, | ||
| 59 | 'T203' => { 'T122' => 1 }, | ||
| 60 | }, | ||
| 61 | 'L3' => { | ||
| 62 | 'T122' => { 'T203' => 1, # Wynyard <-> Circular Quay by heavy rail | ||
| 63 | 'T123' => 1 }, # Wynyard <-> Town Hall by heavy rail | ||
| 64 | 'T123' => { 'T122' => 1 }, | ||
| 65 | 'T203' => { 'T122' => 1 }, | ||
| 66 | }, | ||
| 67 | }; | ||
| 68 | } | ||
| 69 | |||
| 70 | =head1 DESCRIPTION | ||
| 71 | |||
| 72 | It currently provides functionality to find the shortest route between the two | ||
| 73 | given nodes. It covers the following rail lines: | ||
| 74 | |||
| 75 | =over 2 | ||
| 76 | |||
| 77 | =item * L<T1 Line|Map::Tube::Sydney::Line::T1> | ||
| 78 | |||
| 79 | =item * L<T2 Line|Map::Tube::Sydney::Line::T2> | ||
| 80 | |||
| 81 | =item * L<T3 Line|Map::Tube::Sydney::Line::T3> | ||
| 82 | |||
| 83 | =item * L<T4 Line|Map::Tube::Sydney::Line::T4> | ||
| 84 | |||
| 85 | =item * L<T5 Line|Map::Tube::Sydney::Line::T5> | ||
| 86 | |||
| 87 | =item * L<T6 Line|Map::Tube::Sydney::Line::T6> | ||
| 88 | |||
| 89 | =item * L<T7 Line|Map::Tube::Sydney::Line::T7> | ||
| 90 | |||
| 91 | =item * L<T8 Line|Map::Tube::Sydney::Line::T8> | ||
| 92 | |||
| 93 | =item * L<T9 Line|Map::Tube::Sydney::Line::T9> | ||
| 94 | |||
| 95 | =item * L<M1 Line|Map::Tube::Sydney::Line::M1> | ||
| 96 | |||
| 97 | =item * L<L1 Line|Map::Tube::Sydney::Line::L1> | ||
| 98 | |||
| 99 | =item * L<L2 Line|Map::Tube::Sydney::Line::L2> | ||
| 100 | |||
| 101 | =item * L<L3 Line|Map::Tube::Sydney::Line::L3> | ||
| 102 | |||
| 103 | =item * L<L4 Line|Map::Tube::Sydney::Line::L4> | ||
| 104 | |||
| 105 | =back | ||
| 106 | |||
| 107 | =head1 CONSTRUCTOR | ||
| 108 | |||
| 109 | The constructor DOES NOT expect parameters. This sets up the default node definitions. | ||
| 110 | |||
| 111 | use strict; use warnings; | ||
| 112 | use Map::Tube::Sydney; | ||
| 113 | |||
| 114 | my $tube = Map::Tube::Sydney->new; | ||
| 115 | |||
| 116 | =head1 METHODS | ||
| 117 | |||
| 118 | =head2 get_shortest_route($from, $to) | ||
| 119 | |||
| 120 | It expects C<$from> and C<$to> station name, required param. It returns an object | ||
| 121 | of type L<Map::Tube::Route>. On error it throws exception of type L<Map::Tube::Exception>. | ||
| 122 | |||
| 123 | use strict; use warnings; | ||
| 124 | use Map::Tube::Sydney; | ||
| 125 | |||
| 126 | my $tube = Map::Tube::Sydney->new; | ||
| 127 | |||
| 128 | my $route = $tube->get_shortest_route("Roseville", "Central"); | ||
| 129 | |||
| 130 | print "Route: $route\n"; | ||
| 131 | |||
| 132 | =head2 as_image($line_name) | ||
| 133 | |||
| 134 | It expects the plugin L<Map::Tube::Plugin::Graph> to be installed. Returns line | ||
| 135 | image as base64 encoded string if C<$line_name> passed in otherwise it returns | ||
| 136 | base64 encoded string of the entire map. | ||
| 137 | |||
| 138 | use strict; use warnings; | ||
| 139 | use MIME::Base64; | ||
| 140 | use Map::Tube::Sydney; | ||
| 141 | |||
| 142 | my $tube = Map::Tube::Sydney->new; | ||
| 143 | my $map = $tube->name; | ||
| 144 | open(my $IMAGE, ">", "$map.png") | ||
| 145 | or die "ERROR: Cannot open [$map.png]: $!"; | ||
| 146 | binmode($IMAGE); | ||
| 147 | print $IMAGE decode_base64($tube->as_image); | ||
| 148 | close($IMAGE); | ||
| 149 | |||
| 150 | The L<Sydney Tube Map|https://raw.githubusercontent.com/earlybean4/Map-Tube-Sydney/master/maps/Sydney-Rail.png> | ||
| 151 | as generated by plugin L<Map::Tube::Plugin::Graph>. | ||
| 152 | |||
| 153 | =begin html | ||
| 154 | |||
| 155 | <a href = "https://raw.githubusercontent.com/earlybean4/Map-Tube-Sydney/master/maps/Sydney-Rail.png"> | ||
| 156 | <img src = "https://raw.githubusercontent.com/earlybean4/Map-Tube-Sydney/master/maps/Sydney-Rail.png" | ||
| 157 | alt = "Sydney Rail Map" | ||
| 158 | width = "571px" | ||
| 159 | height = "830px"/> | ||
| 160 | </a> | ||
| 161 | |||
| 162 | =end html | ||
| 163 | |||
| 164 | =head1 AUTHOR | ||
| 165 | |||
| 166 | Peter Harrison, C<< <pete at 28smith.com> >> | ||
| 167 | |||
| 168 | =head1 REPOSITORY | ||
| 169 | |||
| 170 | L<https://github.com/earlybean4/Map-Tube-Sydney> | ||
| 171 | |||
| 172 | =head1 BUGS | ||
| 173 | |||
| 174 | Please report any bugs or feature requests through the web interface at L<https://github.com/earlybean4/Map-Tube-Sydney/issues>. | ||
| 175 | I will be notified and then you'll automatically be notified of progress on your | ||
| 176 | bug as I make changes. | ||
| 177 | |||
| 178 | =head1 SUPPORT | ||
| 179 | |||
| 180 | You can find documentation for this module with the perldoc command. | ||
| 181 | |||
| 182 | perldoc Map::Tube::Sydney | ||
| 183 | |||
| 184 | You can also look for information at: | ||
| 185 | |||
| 186 | =over 4 | ||
| 187 | |||
| 188 | =item * BUG Report | ||
| 189 | |||
| 190 | L<https://github.com/earlybean4/Map-Tube-Sydney/issues> | ||
| 191 | |||
| 192 | =item * AnnoCPAN: Annotated CPAN documentation | ||
| 193 | |||
| 194 | L<http://annocpan.org/dist/Map-Tube-Sydney> | ||
| 195 | |||
| 196 | =item * CPAN Ratings | ||
| 197 | |||
| 198 | L<http://cpanratings.perl.org/d/Map-Tube-Sydney> | ||
| 199 | |||
| 200 | =item * Search MetaCPAN | ||
| 201 | |||
| 202 | L<https://metacpan.org/dist/Map-Tube-Sydney> | ||
| 203 | |||
| 204 | =back | ||
| 205 | |||
| 206 | =head1 LICENSE AND COPYRIGHT | ||
| 207 | |||
| 208 | Copyright (C) 2025 Peter Harrison. | ||
| 209 | |||
| 210 | This program is free software; you can redistribute it and / or modify it under | ||
| 211 | the terms of the the Artistic License (2.0). You may obtain a copy of the full | ||
| 212 | license at: | ||
| 213 | |||
| 214 | L<http://www.perlfoundation.org/artistic_license_2_0> | ||
| 215 | |||
| 216 | Any use, modification, and distribution of the Standard or Modified Versions is | ||
| 217 | governed by this Artistic License.By using, modifying or distributing the Package, | ||
| 218 | you accept this license. Do not use, modify, or distribute the Package, if you do | ||
| 219 | not accept this license. | ||
| 220 | |||
| 221 | If your Modified Version has been derived from a Modified Version made by someone | ||
| 222 | other than you,you are nevertheless required to ensure that your Modified Version | ||
| 223 | complies with the requirements of this license. | ||
| 224 | |||
| 225 | This license does not grant you the right to use any trademark, service mark, | ||
| 226 | tradename, or logo of the Copyright Holder. | ||
| 227 | |||
| 228 | This license includes the non-exclusive, worldwide, free-of-charge patent license | ||
| 229 | to make, have made, use, offer to sell, sell, import and otherwise transfer the | ||
| 230 | Package with respect to any patent claims licensable by the Copyright Holder that | ||
| 231 | are necessarily infringed by the Package. If you institute patent litigation | ||
| 232 | (including a cross-claim or counterclaim) against any party alleging that the | ||
| 233 | Package constitutes direct or contributory patent infringement,then this Artistic | ||
| 234 | License to you shall terminate on the date that such litigation is filed. | ||
| 235 | |||
| 236 | Disclaimer of Warranty: THE PACKAGE IS PROVIDED BY THE COPYRIGHT HOLDER AND | ||
| 237 | CONTRIBUTORS "AS IS' AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES. THE IMPLIED | ||
| 238 | WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR | ||
| 239 | NON-INFRINGEMENT ARE DISCLAIMED TO THE EXTENT PERMITTED BY YOUR LOCAL LAW. UNLESS | ||
| 240 | REQUIRED BY LAW, NO COPYRIGHT HOLDER OR CONTRIBUTOR WILL BE LIABLE FOR ANY DIRECT, | ||
| 241 | INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING IN ANY WAY OUT OF THE USE | ||
| 242 | OF THE PACKAGE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
| 243 | |||
| 244 | =cut | ||
| 245 | |||
| 246 | 1; # End of Map::Tube::Sydney | ||