Geofox. Helpers
(geofox_ex v0.1.1)
View Source
Helper functions for creating Geofox API data structures.
Summary
Functions
Create a bounding box from two coordinates.
Create a coordinate structure.
Create a GTI time structure.
Create a GTI time structure from an Elixir DateTime.
Create a station/location structure.
Functions
Create a bounding box from two coordinates.
Examples
iex> lower = Geofox.Helpers.coordinate(9.9, 53.5)
iex> upper = Geofox.Helpers.coordinate(10.1, 53.6)
iex> Geofox.Helpers.bounding_box(lower, upper)
%{"lowerLeft" => %{"x" => 9.9, "y" => 53.5, "type" => "EPSG_4326"}, "upperRight" => %{"x" => 10.1, "y" => 53.6, "type" => "EPSG_4326"}}
Create a coordinate structure.
Examples
iex> Geofox.Helpers.coordinate(53.5511, 9.9937)
%{"x" => 53.5511, "y" => 9.9937, "type" => "EPSG_4326"}
iex> Geofox.Helpers.coordinate(53.5511, 9.9937, "EPSG_31467")
%{"x" => 53.5511, "y" => 9.9937, "type" => "EPSG_31467"}
Create a GTI time structure.
Examples
iex> Geofox.Helpers.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.
Examples
iex> dt = ~U[2024-01-15 14:30:00Z]
iex> Geofox.Helpers.gti_time_from_datetime(dt)
%{"date" => "2024-01-15", "time" => "14:30"}
Create a station/location structure.
Examples
iex> Geofox.Helpers.station("Hauptbahnhof", "Master:1")
%{"name" => "Hauptbahnhof", "id" => "Master:1", "type" => "STATION"}
iex> Geofox.Helpers.station("Airport", nil, type: "POI")
%{"name" => "Airport", "id" => nil, "type" => "POI"}