The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

Travel::Status::DE::DBWagenreihung - Interface to Deutsche Bahn carriage formation API.

SYNOPSIS

    use Travel::Status::DE::DBWagenreihung;

    my $wr = Travel::Status::DE::DBWagenreihung->new(
        departure => 'DateTime or YYYYMMDDhhmm',
        train_number => 1234,
    );

    for my $carriage ( $wr->carriages ) {
        printf("Wagen %s: Abschnitt %s\n", $carriage->number // '?', $carriage->section);
    }

VERSION

version 0.14

This is beta software. The API may change without notice.

DESCRIPTION

Travel:Status:DE::DBWagenreihung is an unofficial interface to the Deutsche Bahn carriage formation (API at https://ist-wr.noncd.db.de/wagenreihung/1.0. It returns station-specific carriage formations (also kwnown as coach sequences) for a variety of trains in the rail network associated with Deutsche Bahn. Data includes carriage positions on the platform, train type (e.g. ICE series), carriage-specific attributes such as first/second class, and the internal type and number of each carriage.

Positions on the platform are given both in meters and percent (relative to platform length).

Note that carriage formation data reported by the API is known to be bogus from time to time. This module does not perform thorough sanity checking.

METHODS

my $wr = Travel::Status::DE::DBWagenreihung->new(%opts)

Requests carriage formation for a specific train at a specific scheduled departure time and date, which implicitly encodes the requested station. Use Travel::Status::DE::IRIS or similar to map station name and train number to scheduled departure.

Arguments:

departure => datetime-obj | YYYYMMDDhhmm

Scheduled departure at the station of interest. Must be either a DateTime object or a string in YYYYMMDDhhmm format. Mandatory.

train_number => number

Train number. Do not include the train type: Use "8" for "EC 8" or "100" for "ICE 100".

$wr->errstr

In case of a fatal HTTP or backend error, returns a string describing it. Returns undef otherwise.

$wr->groups

Returns a list of Travel::Status::DE::DBWagenreihung::Group(3pm) objects which describe the groups making up the carriage formation. Typically, each group has a distinct origin, destination, or train number. Each group contains a set of carriages.

$wr->carriages

Describes the individual carriages the train consists of. Returns a list of Travel::Status::DE::DBWagenreihung::Wagon objects.

$wr->direction

Gives the train's direction of travel. Returns 0 if the train will depart towards position 0 and 100 if the train will depart towards the other platform end (mnemonic: towards the 100% position).

$wr->origins

Returns a list describing the unique origins of this train's carriage groups. Each origin is a hashref that contains its name, a groups arrayref to the corresponding Travel::Status::DE::DBWagenreihung::Group(3pm) objects, and a sections arrayref to section identifiers (subject to change).

$wr->destinations

Returns a list describing the unique destinations of this train's carriage groups. Each origin is a hashref that contains its name, a groups arrayref to the corresponding Travel::Status::DE::DBWagenreihung::Group(3pm) objects, and a sections arrayref to section identifiers (subject to change).

$wr->platform

Returns the platform name.

$wr->sections

Describes the sections of the platform this train will depart from. Returns a list of Travel::Status::DE::DBWagenreihung::Section objects.

$wr->station

Returns a hashref describing the requested station. The hashref contains three entries: ds100 (DS100 / Ril100 identifier), eva (EVA ID, related to but not necessarily identical with UIC station ID), and name (station name).

$wr->train_numbers

Returns the list of train numbers for this departure. In most cases, this is just one element. For trains consisting of multiple wings (which typically have different numbers), it contains one element for each wing.

$wr->train_nos

Returns a list describing the unique train numbers associated with this train's carriage groups. Each train number is a hashref that contains its name (i.e., number), a groups arrayref to the corresponding Travel::Status::DE::DBWagenreihung::Group(3pm) objects, and a sections arrayref to section identifiers (subject to change).

$wr->train_type

Returns a string describing the train type, e.g. "ICE" or "IC".

DEPENDENCIES

BUGS AND LIMITATIONS

Many. This is beta software.

REPOSITORY

https://github.com/derf/Travel-Status-DE-DBWagenreihung

AUTHOR

Copyright (C) 2018-2024 by Birte Kristina Friesel <derf@finalrewind.org>

LICENSE

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