Travel::Status::DE::HAFAS::StopFinder - Interface to HAFAS-based online stop finder services
use Travel::Status::DE::HAFAS::StopFinder; my $sf = Travel::Status::DE::HAFAS::StopFinder->new( url => 'https://reiseauskunft.bahn.de/bin/ajax-getstop.exe', input => 'Borbeck', ); if (my $err = $sf->errstr) { die("Request error: ${err}\n"); } for my $candidate ($sf->results) { printf("%s (%s)\n", $candidate->{name}, $candidate->{id}); }
version 6.14
Travel::Status::DE::HAFAS::StopFinder is an interface to the stop finder service of HAFAS based arrival/departure monitors, for instance the one available at https://reiseauskunft.bahn.de/bin/ajax-getstop.exe/dn.
It takes a string (usually a location or station name) and reports all stations and stops which are lexically similar to it.
StopFinder typically gives less coarse results than Travel::Status::DE::HAFAS(3pm)'s locationSearch method. However, it is unclear whether HAFAS instances will continue supporting it in the future.
Looks up stops as specified by opts and teruns a new Travel::Status::DE::HAFAS::StopFinder element with the results. Dies if the wrong opts were passed.
Supported opts are:
string to look up, e.g. "Borbeck" or "Koeln Bonn Flughafen". Mandatory.
Base url of the stop finder service, without the language and mode suffix ("/dn" and similar). Mandatory. See Travel::Status::DE::HAFAS(3pm)'s get_services method for a list of URLs.
Set language. Accepted arguments are deutsch, english, italian and n (dutch), depending on the used service.
It is unknown if this option has any effect.
Passed on to LWP::UserAgent->new
. Defaults to { timeout => 10 }
,
you can use an empty hashref to override it.
Return a promise that resolves into a list of Travel::Status::DE::HAFAS::StopFinder results ($stopfinder->results) on success and rejects with an error message ($stopfinder->errstr) on failure. In addition to the arguments of new, the following mandatory arguments must be set.
Promises implementation to use for internal promises as well as new_p return value. Recommended: Mojo::Promise(3pm).
User agent instance to use for asynchronous requests. The object must implement a post_p function. Recommended: Mojo::UserAgent(3pm).
In case of an error in the HTTP request, returns a string describing it. If no error occurred, returns undef.
Returns a list of stop candidates. Each list element is a hash reference. The hash keys are id (IBNR / EVA / UIC station code) and name (stop name). Both can be used as input for the Travel::Status::DE::HAFAS(3pm) constructor.
If no matching results were found or the parser / HTTP request failed, returns the empty list.
None.
Unknown.
Travel::Status::DE::HAFAS(3pm).
Copyright (C) 2015-2023 by Birte Kristina Friesel <derf@finalrewind.org>
This module is licensed under the same terms as Perl itself.