The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

Map::Tube::Rome - Interface to the Rome tube map

VERSION

version 1.00

SYNOPSIS

    use Map::Tube::Rome;
    my $tube = Map::Tube::Rome->new();
 
    my $route = $tube->get_shortest_route('Colosseo', 'Anagnina');
 
    print "Route: $route\n";

DESCRIPTION

This module allows to find the shortest route between any two given tube stations in Rome. All interesting methods are provided by the role Map::Tube.

METHODS

CONSTRUCTOR

    use Map::Tube::Rome;
    my $tube = Map::Tube::Rome->new();

The only argument, json, is optional; if specified, it should be a code ref to a function that returns either the path the JSON map file, or a string containing this JSON content. The default is the path to rome.json that is a part of this distribution. For further information see Map::Tube.

json()

This read-only accessor returns whatever was specified as the JSON source at construction.

get_shortest_route($from, $to)

It expects $from and $to station name, required param. It returns an object of type Map::Tube::Route. On error it throws exception of type Map::Tube::Exception.

    use strict; use warnings;
    use Map::Tube::Rome;
 
    my $tube  = Map::Tube::Rome->new;
    my $route = $tube->get_shortest_route('Colosseo', 'Anagnina');
 
    print "Route: $route\n";
 

as_image($line_name)

It expects the plugin Map::Tube::Plugin::Graph to be installed. Returns line image as base64 encoded string if $line_name passed in otherwise it returns base64 encoded string of the entire map.

    use strict; use warnings;
    use MIME::Base64;
    use Map::Tube::Rome;
 
    my $tube = Map::Tube::Rome->new;
    my $map  = $tube->name;
    open(my $IMAGE, ">", "$map.png");
       or die "ERROR: Can't open [$map.png]: $!";
    binmode($IMAGE);
    print $IMAGE decode_base64($tube->as_image);
    close($IMAGE);
 

The Rome Tube Map as generated by plugin Map::Tube::Plugin::Graph.

Rome Tube Map

ERRORS

If something goes wrong, maybe because the map information file was corrupted, the constructor will die.

SEE ALSO

Map::Tube, Map::Tube::GraphViz.

SUPPORT

Bugs / Feature Requests

Please report any bugs or feature requests through the issue tracker at https://github.com/giterlizzi/perl-Map-Tube-Rome/issues. You will be notified automatically of any progress on your issue.

Source Code

This is open source software. The code repository is available for public review and contribution under the terms of the license.

https://github.com/giterlizzi/perl-Map-Tube-Rome

    git clone https://github.com/giterlizzi/perl-Map-Tube-Rome.git

AUTHOR

Giuseppe Di Terlizzi <gdt@cpan.org>

COPYRIGHT AND LICENSE

This software is copyright (c) 2024 by Giuseppe Di Terlizzi <gdt@cpan.org>.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.