NAME

Travel::Status::DE::IRIS::Stations - Station name to station code mapping

SYNOPSIS

use Travel::Status::DE::IRIS::Stations;

my $name = 'Essen Hbf';
my @stations = Travel::Status::DE::IRIS::Stations::get_station_by_name(
  $name);

if (@stations < 1) {
  # no matching stations
}
elsif (@stations > 1) {
  # too many matches
}
else {
  printf("Input '%s' matched station code %s (as '%s')\n",
    $name, @{$stations[0]});
}

VERSION

version 1.96

DESCRIPTION

This module contains a list of Deutsche Bahn stations, and also some stations outside of Germany which are served by Deutsche Bahn trains. It offers several accessors to look up stations based on names or geolocation data and can also simply dump all known stations.

Each of the following methods returns a list of array references. Each array reference describes a single station and contains either two or five elements:

  • Station code (also known as DS100 / "Druckschrift 100" / "Richtlinie 100"). A short string used exclusively by Deutsche Bahn APIs. Note that it may contain space characters.

  • Station name

  • EVA station number (often, but not always, same as UIC station number)

  • Station longitude, if available

  • Station latitude, if available

Note that station names are not unique. A single station may be present multiple times with different EVA numbers and DS100 codes. At the moment, EVA numbers and DS100 codes are unique.

METHODS

Travel::Status::DE::IRIS::Stations::get_stations

Returns a list of all known stations, lexically sorted by station name.

Travel::Status::DE::IRIS::Stations::get_station($in)

Returns a list of stations matching $in.

If a $in is a valid station identifier (either DS100 code or EVA number), a single array reference describing the station is returned. Otherwise, $in is passed to get_station_by_name($in) (see below).

Note that DS100 code matching is case sensitive.

Travel::Status::DE::IRIS::Stations::get_station_by_location($lon, $lat, $num_matches)

Looks for stations which are close to longitude/latitude $lon/$lat and returns the closest $num_matches (defaults to 10) matches. Note that stations which are located more than 70 kilometers away from $lon/$lat may be ignored when computing the closest matches.

Travel::Status::DE::IRIS::Stations::get_station_by_name($name)

Returns a list of stations where the station name matches $name.

Matching happens in two steps: If a case-insensitive exact match exists, only this one is returned. For station names that correspond to several EVA/DS100 codes, the match with the lowest EVA number is returned.

Otherwise, all stations whose name contains $name as a substring (also case-insensitive) and all stations whose name has a low Levenshtein distance to $name are returned.

This two-step behaviour makes sure that not-prefix-free stations can still be matched directly. For instance, both "Essen-Steele" and "Essen-Steele Ost" are valid station names, but "essen-steele" will only return "Essen-Steele".

DIAGNOSTICS

None.

DEPENDENCIES

  • GIS::Distance(3pm)

  • List::MoreUtils(3pm)

  • List::Util(3pm)

  • Text::LevenshteinXS(3pm)

BUGS AND LIMITATIONS

There is no support for intelligent whitespaces (to also match "-" and similar) yet.

SEE ALSO

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

AUTHOR

Station data: Copyright (C) 2016 by DB Station&Service AG, Europaplatz 1, 10557 Berlin, Germany

Lookup code: Copyright (C) 2014-2024 by Birte Kristina Friesel <derf@finalrewind.org>

LICENSE

This module is licensed under the same terms as Perl itself. Note that the station data used by this module is also available under a CC-BY 4.0 license on http://data.deutschebahn.com/dataset/data-haltestellen.