Map-Metro
view release on metacpan or search on metacpan
lib/Map/Metro.pm view on Meta::CPAN
}
}
# Borrowed from Mojo::Util
sub decamelize {
my $self = shift;
my $string = shift;
return $string if $string !~ m{[A-Z]};
return join '_' => map {
join ('_' => map { lc } grep { length } split m{([A-Z]{1}[^A-Z]*)})
} split '::' => $string;
}
sub parse {
my $self = shift;
my %args = @_;
return Map::Metro::Graph->new(filepath => $self->get_mapclass(0)->maplocation,
do_undiacritic => $self->get_mapclass(0)->do_undiacritic,
wanted_hook_plugins => [$self->all_hooks],
lib/Map/Metro/Cmd/Graphviz.pm view on Meta::CPAN
if($self->customlens) {
my $customlens = path($self->customlens)->exists ? do {
my $settings = path($self->customlens)->slurp;
$settings =~ s{^#.*$}{}g;
$settings =~ s{\n}{ }g;
$settings;
}
: $self->customlens
;
foreach my $custom (split m/ +/ => $customlens) {
if($custom =~ m{^(\d+)->(\d+):([\d\.]+)$}) {
my $origin_station_id = $1;
my $destination_station_id = $2;
my $len = $3;
$self->set_len(sprintf ('%s-%s', $origin_station_id, $destination_station_id), $len);
$self->set_len(sprintf ('%s-%s', $destination_station_id, $origin_station_id), $len);
}
elsif($custom =~ m{^!(\d+)->(\d+):([\d\.]+)$}) {
my $origin_station_id = $1;
lib/Map/Metro/Graph.pm view on Meta::CPAN
;
}
}
around add_station => sub {
my $next = shift;
my $self = shift;
my $text = shift;
$text = trim $text;
my @names = split m{\h*%\h*} => $text;
my $name = shift @names;
if(my $station = $self->get_station_by_name($name, check => 0)) {
return $station;
}
my $id = $self->station_count + 1;
my $station = Map::Metro::Graph::Station->new(original_name => $name, do_undiacritic => $self->do_undiacritic, eh $name, $id);
foreach my $another_name (@names) {
lib/Map/Metro/Graph.pm view on Meta::CPAN
$self->$next($line);
};
around add_segment => sub {
my $next = shift;
my $self = shift;
my $text = shift;
$text = trim $text;
my($linestring, $start, $end, $option_string) = split /\|/ => $text;
my @line_ids_with_dir = split m/,/ => $linestring;
my @clean_line_ids = map { (my $clean = $_) =~ s{[^a-z0-9]}{}gi; $clean } @line_ids_with_dir;
my $options = defined $option_string ? $self->make_options($option_string, keys => [qw/dir/]) : {};
#* Check that lines and stations in segments exist in the other lists
my($origin_station, $destination_station);
try {
$self->get_line_by_id($_) foreach @clean_line_ids;
$origin_station = $self->get_station_by_name($start);
( run in 0.765 second using v1.01-cache-2.11-cpan-71847e10f99 )