Geofox.Core.Route (geofox_ex v0.1.1)

View Source

Route planning functions for the Geofox API.

This module provides functions for finding public transport routes and individual routes (walking, cycling) between locations.

Summary

Functions

Get individual routes (walking, cycling) between multiple start and destination points.

Get public transport routes between two locations.

Functions

get_individual_route(client, starts, dests, opts \\ [])

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

Get individual routes (walking, cycling) between multiple start and destination points.

This function is used for non-public transport routing, such as walking or cycling paths.

Parameters

  • client - The Geofox client
  • starts - List of start locations as t:Types.sd_name/0
  • dests - List of destination locations as t:Types.sd_name/0
  • opts - Optional parameters

Options

  • :language - Language code (default: "de")
  • :version - API version (default: 1)
  • :filter_type - Filter type (default: "NO_FILTER")
  • :max_length - Maximum route length in meters
  • :max_results - Maximum number of results
  • :type - Coordinate type (default: "EPSG_4326")
  • :service_type - Service type: "FOOTPATH", "BICYCLE" (default: "FOOTPATH")
  • :profile - Routing profile (default: "FOOT_NORMAL")
    • For walking: "FOOT_NORMAL"
    • For cycling: "BICYCLE_NORMAL", "BICYCLE_RACING", "BICYCLE_QUIET_ROADS", "BICYCLE_MAIN_ROADS", "BICYCLE_BAD_WEATHER"
  • :speed - Speed setting (default: "NORMAL")

Examples

starts = [Geofox.station("Hauptbahnhof", "Master:1")]
dests = [Geofox.station("Rathaus", "Master:2")]

# Walking route
{:ok, routes} = Geofox.Core.Route.get_individual_route(client, starts, dests)

# Cycling route
{:ok, routes} = Geofox.Core.Route.get_individual_route(client, starts, dests,
  service_type: "BICYCLE",
  profile: "BICYCLE_NORMAL",
  max_length: 5000
)

get_route(client, start, dest, time, opts \\ [])

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

Get public transport routes between two locations.

Parameters

  • client - The Geofox client
  • start - Start location as t:Types.sd_name/0
  • dest - Destination location as t:Types.sd_name/0
  • time - Journey 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")
  • :time_is_departure - Whether time is departure (true) or arrival (false) (default: true)
  • :with_paths - Include path coordinates (default: false)
  • :number_of_schedules - Number of route alternatives (default: 3)
  • :realtime - Realtime mode: "PLANDATA", "REALTIME", "AUTO" (default: "AUTO")
  • :intermediate_stops - Include intermediate stops (default: false)
  • :tariff_details - Include tariff information (default: false)
  • :return_reduced - Return reduced fare information (default: false)
  • :return_partial_tickets - Return partial ticket information (default: true)
  • :via - Via location for routing
  • :penalties - List of penalty configurations
  • :schedules_before - Number of earlier schedules (default: 0)
  • :schedules_after - Number of later schedules (default: 0)
  • :coordinate_type - Coordinate system (default: "EPSG_4326")
  • :use_bike_and_ride - Enable bike and ride options (default: false)

Examples

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

# Basic route search
{:ok, routes} = Geofox.Core.Route.get_route(client, start, dest, time)

# Route search with options
{:ok, routes} = Geofox.Core.Route.get_route(client, start, dest, time,
  with_paths: true,
  number_of_schedules: 5,
  realtime: "REALTIME",
  tariff_details: true
)