summaryrefslogtreecommitdiff
path: root/lib/Travel/Status/DE
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Travel/Status/DE')
-rw-r--r--lib/Travel/Status/DE/IRIS.pm11
1 files changed, 9 insertions, 2 deletions
diff --git a/lib/Travel/Status/DE/IRIS.pm b/lib/Travel/Status/DE/IRIS.pm
index 937bb65..36237c9 100644
--- a/lib/Travel/Status/DE/IRIS.pm
+++ b/lib/Travel/Status/DE/IRIS.pm
@@ -12,6 +12,8 @@ use Carp qw(confess cluck);
use DateTime;
use Encode qw(encode decode);
use List::Util qw(first);
+use List::MoreUtils qw(uniq);
+use List::UtilsBy qw(uniq_by);
use LWP::UserAgent;
use Travel::Status::DE::IRIS::Result;
use XML::LibXML;
@@ -197,11 +199,14 @@ sub get_station {
printf( " -> %s (%s / %s)\n", @{ $ret[0] }{qw{name uic ds100}} );
}
+ # TODO this approach is flawed, iterative is probably better
+
if ( $opt{recursive} and $station_node->hasAttribute('meta') ) {
my @recursion_blacklist = @{ $opt{recursion_blacklist} // [] };
- my @refs = split( m{ \| }x, $station_node->getAttribute('meta') );
+ my @refs = uniq(split( m{ \| }x, $station_node->getAttribute('meta') ));
+
+ push( @recursion_blacklist, map { $_->{uic} } @ret );
- push( @recursion_blacklist, $ret[0]{uic} );
for my $ref (@refs) {
if ( not( $ref ~~ \@recursion_blacklist ) ) {
push(
@@ -217,6 +222,8 @@ sub get_station {
}
}
+ @ret = uniq_by { $_->{uic} } @ret;
+
return @ret;
}