NAME

Travel::Status::DE::HAFAS::Journey - Information about a single journey received by Travel::Status::DE::HAFAS

SYNOPSIS

	for my $departure ($status->results) {
		printf(
			"At %s: %s to %s from platform %s\n",
			$departure->datetime->strftime('%H:%M'),
			$departure->line,
			$departure->destination,
			$departure->platform,
		);
	}

	# or (depending on module setup)
	for my $arrival ($status->results) {
		printf(
			"At %s: %s from %s on platform %s\n",
			$arrival->datetime->strftime('%H:%M'),
			$arrival->line,
			$arrival->origin,
			$arrival->platform,
		);
	}

VERSION

version 4.02

DESCRIPTION

Travel::Status::DE::HAFAS::Journey describes a single journey. It is either a station-specific arrival/departure obtained by a stationboard query, or a train journey that does not belong to a specific station.

stationboard-specific accessors are annotated with "(station only)" and return undef for non-station journeys.

METHODS

ACCESSORS

$journey->name

Returns the journey or line name, either in a format like "Bus SB16" (Bus line SB16) or "RE 10111" (RegionalExpress train 10111, no line information). May contain extraneous whitespace characters.

$journey->type

Returns the type of this journey, e.g. "S" for S-Bahn, "RE" for Regional Express or "STR" for tram / Straßenbahn.

$journey->type_long

Returns the long type of this journey, e.g. "S-Bahn" or "Regional-Express".

$journey->class

Returns an integer identifying the the mode of transport class. Semantics depend on backend, e.g. "1" and "2" for long-distance trains and "4" and "8" for region trains.

$journey->line

Returns the line identifier, or undef if it is unknown. The line identifier may be a single number such as "11" (underground train line U 11), a single word (e.g. "AIR") or a combination (e.g. "SB16").

$journey->number

Returns the journey number (e.g. train number), or undef if it is unknown.

$journey->id

Returns tha HAFAS-internal journey ID.

$journey->rt_datetime (station only)

DateTime object indicating the actual arrival/departure date and time. undef if no real-time data is available.

$journey->sched_datetime (station only)

DateTime object indicating the scheduled arrival/departure date and time. undef if no schedule data is available.

$journey->datetime (station only)

DateTime object indicating the arrival/departure date and time. Real-time data if available, schedule data otherwise. undef if neither is available.

$journey->delay (station only)

Returns the delay in minutes, or undef if it is unknown. Also returns undef if the arrival/departure has been cancelled.

$journey->is_cancelled

True if the journey was cancelled, false otherwise.

$journey->is_partially_cancelled

True if part of the journey was cancelled, false otherwise.

$journey->rt_platform (station only)

Actual arrival/departure platform. undef if no real-time data is available.

$journey->sched_platform (station only)

Scheduled arrival/departure platform. undef if no scheduled platform is available.

$journey->platform (station only)

Arrival/Departure platform. Real-time data if available, schedule data otherwise. May be undef.

$journey->is_changed_platform (station only)

True if the real-time platform is known and it is not the scheduled one.

$journey->load (station only)

Expected passenger load (i.e., how full the vehicle is) at the requested stop. If known, returns a hashref that maps classes (typically FIRST/SECOND) to load estimation numbers. The DB backend uses 1 (low to medium), 2 (high), 3 (very high), and 4 (exceptionally high, train is booked out). Undef if unknown.

$journey->messages

Returns a list of message strings related to this journey. Messages usually are service notices (e.g. "missing carriage") or detailed delay reasons (e.g. "switch damage between X and Y, expect delays").

$journey->operator

Returns the operator responsible for this journey. Returns undef if the backend does not provide an operator.

$journey->route

Returns a list of hashes; each hash describes a single journey stop. In stationboard mode, it only contains arrivals prior to the requested station or departures after the requested station. In journey mode, it contains the entire route. Each hash contains the following keys:

* name (name
* eva (EVA ID)
* lon (longitude)
* lat (latitude)
* rt_arr (DateTime object for actual arrival)
* sched_arr (DateTime object for scheduled arrival)
* arr (DateTime object for actual or scheduled arrival)
* arr_delay (arrival delay in minutes)
* arr_cancelled (arrival is cancelled)
* rt_dep (DateTime object for actual departure)
* sched_dep (DateTime object for scheduled departure)
* dep (DateTIme object for actual or scheduled departure)
* dep_delay (departure delay in minutes)
* dep_cancelled (departure is cancelled)
* delay (departure or arrival delay in minutes)
* direction (direction signage from this stop on, undef if unchanged)
* load (expected utilization / passenger load from this stop on)

Individual entries may be undef.

$journey->route_end

Name of the last route station. In arrival mode, this is where the train started; in all other cases, it is the terminus.

$journey->destination

Alias for route_end; only set when requesting departures in station mode.

$journey->origin

Alias for route_end; only set when requesting arrivals in station mode.

$journey->direction

Train direction; this is typically the text printed on the train itself. May be different from destination / route_end and may change along the route, see above.

$journey->polyline (journey only)

List of geocoordinates that describe the train's route. Each list entry is a hash with the following keys.

* lon (longitude)
* lat (latitude)
* name (name of stop at this location, if any. undef otherwise)
* eva (EVA ID of stop at this location, if any. undef otherwise)

Note that stop locations in polyline may differ from the coordinates returned in route. This is a backend issue; Travel::Status::DE::HAFAS simply passes the returned coordinates on.

DIAGNOSTICS

None.

DEPENDENCIES

Class::Accessor(3pm)

BUGS AND LIMITATIONS

None known.

SEE ALSO

Travel::Status::DE::HAFAS(3pm).

AUTHOR

Copyright (C) 2015-2022 by Daniel Friesel <derf@finalrewind.org>

LICENSE

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