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 6.15

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. All date and time entries refer to the backend time zone (Europe/Berlin in most cases) and do not take local time into account; see tz_offset for the latter.

METHODS

ACCESSORS

$journey->name

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

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

$journey->type_long

Long type of this journey, e.g. "S-Bahn" or "Regional-Express".

$journey->class

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 regional trains.

$journey->line

Journey or line name, either in a format like "Bus SB16" (Bus line SB16), "RE 42" (RegionalExpress train 42) or "IC 2901" (InterCity train 2901, no line information). May contain extraneous whitespace characters. Note that this accessor does not return line information for IC/ICE/EC services, even if it is available. Use line_no for those.

$journey->line_no

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"). May also provide line numbers of IC/ICE services.

$journey->number

Journey number (e.g. train number), or undef if it is unknown.

$journey->id

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->tz_offset

Offset between backend time zone (default: Europe/Berlin) and this journey's time zone in minutes, if any. For instance, if the backend uses UTC+2 (CEST) and the journey uses UTC+1 (IST), tz_offset is -60. Returns undef if both use the same time zone (or rather, the same UTC offset).

$journey->delay (station only)

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

$journey->is_additional (station only)

True if the journey's stop at the requested station is an unscheduled addition to its route.

$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->product

Travel::Status::DE::HAFAS::Product(3pm) instance describing the product (mode of transport, line number / ID, operator, ...) associated with this journey. Note that journeys may be associated with multiple products -- see also $journey->route and $stop->product.

$journey->product_at(stop)

Travel::Status::DE::HAFAS::Product(3pm) instance describing the product associated with stop (name or EVA ID). Returns undef if product or stop are unknown.

$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

List of Travel::Status::DE::HAFAS::Message(3pm) instances 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

The operator responsible for this journey. Returns undef if the backend does not provide an operator. Note that the operator may change along the journey -- in this case, the returned operator depends on the backend and appears to be the first one in most cases.

$journey->operators

List of all operators observed along the journey.

$journey->station (station only)

Name of the station at which this journey was requested.

$journey->station_eva (station only)

UIC/EVA ID of the station at which this journey was requested.

$journey->route

List of Travel::Status::DE::HAFAS::Stop(3pm) objects that describe individual stops along the journey. In stationboard mode, the list only contains arrivals prior to the requested station or departures after the requested station. In journey mode, it contains the entire route.

$journey->route_interesting([count])

Up to count (default: 3) parts of $journey->route that may be particularly helpful, e.g. main stations or airports.

$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. Only available if the HAFAS object constructor was passed a true with_polyline value. 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-2023 by Birte Kristina Friesel <derf@finalrewind.org>

LICENSE

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