Commit af07d71c authored by networkException's avatar networkException Committed by derf
Browse files

DBRIS: Support station lookup using Ril100 codes from IRIS

parent 02e36e89
Loading
Loading
Loading
Loading
+15 −0
Original line number Diff line number Diff line
@@ -12,6 +12,7 @@ use utf8;
use DateTime;
use Encode qw(decode);
use JSON;
use List::MoreUtils qw(firstval);
use Mojo::Promise;
use Mojo::UserAgent;
use Travel::Status::DE::DBRIS;
@@ -67,6 +68,20 @@ sub get_station_id_p {

	my $promise = Mojo::Promise->new;

	my $ds100_match = firstval { $station_name eq $_->[0] } Travel::Status::DE::IRIS::Stations::get_stations();

	if ($ds100_match) {
		$promise->resolve({
			eva  => $ds100_match->[2],
			id   => "A=1\@L=" . $ds100_match->[2] . "\@O=" . $ds100_match->[1] . "@",
			lat  => $ds100_match->[4],
			lon  => $ds100_match->[3],
			name => $ds100_match->[1],
		});

		return $promise;
	}

	Travel::Status::DE::DBRIS->new_p(
		locationSearch => $station_name,
		cache          => $self->{realtime_cache},