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