Geofox.Core.Departures (geofox_ex v0.1.1)

View Source

Functions for retrieving departure information and departure courses from the Geofox API.

Summary

Functions

Get the complete course/schedule of a specific departure.

Get departure list for a station at a specific time.

Get departure list for multiple stations at a specific time.

Functions

departure_course(client, line_key, station, time, opts \\ [])

@spec departure_course(
  Geofox.Client.t(),
  String.t(),
  Geofox.Types.sd_name(),
  String.t(),
  keyword()
) ::
  {:ok, map()} | {:error, term()}

Get the complete course/schedule of a specific departure.

Parameters

  • client - The Geofox client
  • line_key - Unique identifier for the line
  • station - Station information as t:Types.sd_name/0
  • time - Departure time as ISO 8601 datetime string
  • opts - Optional parameters

Options

  • :language - Language code (default: "de")
  • :version - API version (default: 1)
  • :filter_type - Filter type (default: "NO_FILTER")
  • :direction - Direction of travel
  • :origin - Origin station name
  • :service_id - Service ID (default: -1)
  • :segments - Which segments to show: "BEFORE", "AFTER", "ALL" (default: "ALL")
  • :show_path - Include path coordinates (default: false)
  • :coordinate_type - Coordinate system (default: "EPSG_4326")

Examples

station = Geofox.station("Hauptbahnhof", "Master:1")

{:ok, course} = Geofox.Core.Departures.departure_course(
  client,
  "HVV:21001:H",
  station,
  "2024-01-15T14:30:00"
)

departure_list(client, station, time, opts \\ [])

@spec departure_list(
  Geofox.Client.t(),
  Geofox.Types.sd_name(),
  Geofox.Types.gti_time(),
  keyword()
) ::
  {:ok, map()} | {:error, term()}

Get departure list for a station at a specific time.

Parameters

  • client - The Geofox client
  • station - Station information as t:Types.sd_name/0
  • time - Departure time as t:Types.gti_time/0
  • opts - Optional parameters

Options

  • :language - Language code (default: "de")
  • :version - API version (default: 1)
  • :filter_type - Filter type (default: "NO_FILTER")
  • :stations - List of stations to query (alternative to single station)
  • :max_list - Maximum number of departures to return
  • :max_time_offset - Maximum time offset in minutes (default: 120)
  • :all_stations_in_changing_node - Include all stations in changing node (default: true)
  • :use_realtime - Use realtime data (default: false)
  • :return_filters - Return available filters (default: false)
  • :filter - List of filter entries to apply
  • :service_types - List of service types to include
  • :departure - Whether to show departures (default: true)
  • :coordinate_type - Coordinate system to use (default: "EPSG_4326")

Examples

station = Geofox.station("Hauptbahnhof", "Master:1")
time = Geofox.gti_time("2024-01-15", "14:30")

{:ok, departures} = Geofox.Core.Departures.departure_list(client, station, time)

# With options
{:ok, departures} = Geofox.Core.Departures.departure_list(client, station, time,
  max_list: 20,
  use_realtime: true,
  service_types: ["U_BAHN", "S_BAHN"]
)

departure_list_multi(client, stations, time, opts \\ [])

@spec departure_list_multi(
  Geofox.Client.t(),
  [Geofox.Types.sd_name()],
  Geofox.Types.gti_time(),
  keyword()
) :: {:ok, map()} | {:error, term()}

Get departure list for multiple stations at a specific time.

Similar to departure_list/4 but accepts a list of stations instead of a single station.

Examples

stations = [
  Geofox.station("Hauptbahnhof", "Master:1"),
  Geofox.station("Dammtor", "Master:2")
]
time = Geofox.gti_time("2024-01-15", "14:30")

{:ok, departures} = Geofox.Core.Departures.departure_list_multi(client, stations, time)