Geofox (geofox_ex v0.1.0)
View SourcePublic API for interacting with the HVV Geofox API.
This module provides an interface to all Geofox API functionality including:
- Route planning and individual routing
- Station and line information
- Real-time departures and announcements
- Tariff calculation and ticket optimization
- Vehicle tracking and map data
Summary
Functions
Create a bounding box from two coordinates.
Search for stations, addresses, or points of interest by name.
Check if a postal code is within the HVV service area.
Create a coordinate structure.
Get the complete course/schedule of a specific departure.
Get departure information for a station.
Get service announcements and disruption information.
Get individual routes (walking, cycling) between multiple start and destination points.
Get public transport routes between two locations.
Get detailed information about a station including elevators and accessibility.
Calculate tariff information for a given route.
Get track coordinates for specific stop points.
Get vehicle positions and movements within a bounding box.
Create a GTI time structure.
Create a GTI time structure from an Elixir DateTime.
Initialize a session with the Geofox API to get service information and validate connectivity.
List all available lines with optional subline information.
List all available stations.
Get list of available tickets.
Create a new Geofox client.
Optimize ticket selection for a single journey.
Create a station/location structure.
Get tariff metadata including available zones, counties, and tariff types.
Get information about neighboring tariff zones.
Functions
Create a bounding box from two coordinates.
@spec check_name(Geofox.Client.t(), Geofox.Types.sd_name(), keyword()) :: {:ok, map()} | {:error, term()}
Search for stations, addresses, or points of interest by name.
@spec check_postal_code(Geofox.Client.t(), integer(), keyword()) :: {:ok, map()} | {:error, term()}
Check if a postal code is within the HVV service area.
Create a coordinate structure.
Examples
iex> Geofox.coordinate(53.5511, 9.9937)
%{"x" => 53.5511, "y" => 9.9937, "type" => "EPSG_4326"}
@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.
@spec departure_list( Geofox.Client.t(), Geofox.Types.sd_name(), Geofox.Types.gti_time(), keyword() ) :: {:ok, map()} | {:error, term()}
Get departure information for a station.
Examples
station = Geofox.station("Hauptbahnhof", "Master:1")
time = Geofox.gti_time("2024-01-15", "14:30")
{:ok, departures} = Geofox.departure_list(client, station, time)
@spec get_announcements( Geofox.Client.t(), keyword() ) :: {:ok, map()} | {:error, term()}
Get service announcements and disruption information.
@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.
@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.
Examples
start = Geofox.station("Hauptbahnhof", "Master:1")
dest = Geofox.station("Flughafen", "Master:3690")
time = Geofox.gti_time("2024-01-15", "14:30")
{:ok, routes} = Geofox.get_route(client, start, dest, time)
@spec get_station_information(Geofox.Client.t(), Geofox.Types.sd_name(), keyword()) :: {:ok, map()} | {:error, term()}
Get detailed information about a station including elevators and accessibility.
@spec get_tariff( Geofox.Client.t(), [map()], Geofox.Types.gti_time(), Geofox.Types.gti_time(), keyword() ) :: {:ok, map()} | {:error, term()}
Calculate tariff information for a given route.
@spec get_track_coordinates(Geofox.Client.t(), [String.t()], keyword()) :: {:ok, map()} | {:error, term()}
Get track coordinates for specific stop points.
@spec get_vehicle_map(Geofox.Client.t(), Geofox.Types.bounding_box(), keyword()) :: {:ok, map()} | {:error, term()}
Get vehicle positions and movements within a bounding box.
Create a GTI time structure.
Examples
iex> Geofox.gti_time("2024-01-15", "14:30")
%{"date" => "2024-01-15", "time" => "14:30"}
@spec gti_time_from_datetime(DateTime.t()) :: map()
Create a GTI time structure from an Elixir DateTime.
@spec init( Geofox.Client.t(), keyword() ) :: {:ok, map()} | {:error, term()}
Initialize a session with the Geofox API to get service information and validate connectivity.
@spec list_lines( Geofox.Client.t(), keyword() ) :: {:ok, map()} | {:error, term()}
List all available lines with optional subline information.
@spec list_stations( Geofox.Client.t(), keyword() ) :: {:ok, map()} | {:error, term()}
List all available stations.
@spec list_tickets( Geofox.Client.t(), keyword() ) :: {:ok, map()} | {:error, term()}
Get list of available tickets.
@spec new(keyword()) :: Geofox.Client.t()
Create a new Geofox client.
Options
:base_url- Base URL for the API (default: "https://gti.geofox.de"):timeout- Request timeout in milliseconds (default: 30000):headers- Additional headers to include in requests:user- Username for authentication (if required):password- Password for authentication (if required)
Examples
iex> client = Geofox.new()
iex> client = Geofox.new(timeout: 60000)
@spec single_ticket_optimizer(Geofox.Client.t(), map(), keyword()) :: {:ok, map()} | {:error, term()}
Optimize ticket selection for a single journey.
Create a station/location structure.
Examples
iex> Geofox.station("Hauptbahnhof", "Master:1")
%{"name" => "Hauptbahnhof", "id" => "Master:1", "type" => "STATION"}
@spec tariff_meta_data( Geofox.Client.t(), keyword() ) :: {:ok, map()} | {:error, term()}
Get tariff metadata including available zones, counties, and tariff types.
@spec tariff_zone_neighbours( Geofox.Client.t(), keyword() ) :: {:ok, map()} | {:error, term()}
Get information about neighboring tariff zones.