The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Travel::Status::DE::URA - unofficial departure monitor for "Unified Realtime API" data providers (e.g. ASEAG)

SYNOPSIS

    use Travel::Status::DE::URA;

    my $status = Travel::Status::DE::URA->new(
        ura_base => 'http://ivu.aseag.de/interfaces/ura',
        ura_version => '1',
        stop => 'Aachen Bushof'
    );

    for my $d ($status->results) {
        printf(
            "%s  %-5s %25s (in %d min)\n",
            $d->time, $d->line, $d->destination, $d->countdown
        );
    }

VERSION

version 2.01

DESCRIPTION

Travel::Status::DE::URA is an unofficial interface to URA-based realtime departure monitors (as used e.g. by the ASEAG). It reports all upcoming departures at a given place in real-time. Schedule information is not included.

METHODS

my $status = Travel::Status::DE::URA->new(%opt)

Requests the departures as specified by opts and returns a new Travel::Status::DE::URA object.

The following two parameters are mandatory:

ura_base => ura_base

The URA base url.

ura_version => version

The version, may be any string.

The request URL is ura_base/instant_Vversion, so for http://ivu.aseag.de/interfaces/ura, 1 this module will send requests to http://ivu.aseag.de/interfaces/ura/instant_V1.

All remaining parameters are optional.

lwp_options => \%hashref

Passed on to LWP::UserAgent->new. Defaults to { timeout => 10 }, you can use an empty hashref to override it.

circle => lon,lat,dist

Only request departures for stops which are located up to dist meters away from the location specified by lon and lat. Example parameter: "50.78496,6.10897,100".

with_messages => 0|1

When set to 1 (or any other true value): Also requests stop messages from the URA service. Thene can include texts such as "Expect delays due to snow and ice" or "stop closed, use replacement stop X instead". Use $status->messages to access them.

with_stops => 0|1

When set to 1 (or any other true value): Also request all stops satisfying the specified parameters. They can be accessed with get_stops. Defaults to 0.

Additionally, all options supported by $status->results may be specified here, causing them to be used as defaults. Note that while they can be overridden later, they may limit the set of departures requested from the server.

$status->errstr

In case of an HTTP request error, returns a string describing it. If none occured, returns undef.

$status->get_stop_by_name($stopname)

Returns a list of stops matching $stopname. For instance, if the stops "Aachen Bushof", "Eupen Bushof", "Brand" and "Brandweiher" exist, the parameter "bushof" will return "Aachen Bushof" and "Eupen Bushof", while "brand" will only return "Brand".

$status->get_stops

Returns a hash reference describing all distinct stops returned by the request. Each key is the unique ID of a stop and contains a Travel::Status::DE::URA::Stop(3pm) object describing it.

Only works when $status was created with with_stops set to a true value. Otherwise, undef is returned.

$status->messages_by_stop_id($stop_id)

Returns a list of messages for the stop with the ID $stop_id. At the moment, each message is a simple string. This may change in the future.

$status->messages_by_stop_name($stop_id)

Returns a list of messages for the stop with the name $stop_name. At the moment, each message is a simple string. This may change in the future.

$status->results(%opt)

Returns a list of Travel::Status::DE::URA::Result(3pm) objects, each describing one departure.

Accepted parameters (all are optional):

calculate_routes => bool (default 0)

When set to a true value: Compute routes for all results, enabling use of their route_ accessors. Otherwise, those will just return nothing (undef / empty list, depending on context).

hide_past => bool (default 1)

Do not include past departures in the result list and the computed timetables.

line_id => ID

Only return departures of line ID.

stop => name

Only return departures at stop name.

stop_id => ID

Only return departures at stop ID.

via => vianame

Only return departures containing vianame in their route after their corresponding stop. Implies calculate_routes=1.

via_id => ID

Only return departures containing ID in their route after their corresponding stop. Implies calculate_routes=1.

DIAGNOSTICS

None.

DEPENDENCIES

  • Class::Accessor(3pm)

  • DateTime(3pm)

  • List::MoreUtils(3pm)

  • LWP::UserAgent(3pm)

  • Text::CSV(3pm)

BUGS AND LIMITATIONS

Many.

SEE ALSO

Travel::Status::DE::URA::Result(3pm).

AUTHOR

Copyright (C) 2013-2016 by Daniel Friesel <derf@finalrewind.org>

LICENSE

This module is licensed under the same terms as Perl itself.