GTFSRealtimeViz (gtfs_realtime_viz v0.11.0)

Copy Markdown View Source

GTFSRealtimeViz is an OTP app that can be run by itself or as part of another application. You can send it protobuf VehiclePositions.pb files, in sequence, and then output them as an HTML fragment, to either open in a browser or embed in another view.

Example usage as stand alone:

$ iex -S mix
iex(1)> proto = File.read!("filename.pb")
iex(2)> GTFSRealtimeViz.new_message(:prod, proto, "first protobuf file")
iex(3)> File.write!("output.html", GTFSRealtimeViz.visualize(:prod, %{}))

Summary

Functions

Send protobuf files to the app's GenServer. The app can handle a series of files, belonging to different groupings (e.g., test, dev, and prod). When sending the file, you must also provide a comment (perhaps a time stamp or other information about the file), which will be displayed along with the visualization.

Renders the received protobuf files and comments into an HTML fragment that can either be opened directly in a browser or embedded within the HTML layout of another app.

Renders an HTML fragment that displays the vehicle differences between two pb files.

Types

route_opts()

@type route_opts() :: %{
  required(String.t()) => [{String.t(), String.t(), String.t()}]
}

Functions

format_time_diff(base_list, diff_list)

@spec format_time_diff(time_list, time_list) :: [{time_output, time_output}]
when time_list: {String.t(), DateTime.t()} | nil,
     time_output: Phoenix.HTML.Safe.t() | nil

format_times(time_list)

@spec format_times([{String.t(), {DateTime.t(), DateTime.t()}}] | nil) :: [
  Phoenix.HTML.Safe.t()
]

new_message(group, raw, comment)

@spec new_message(term(), GTFSRealtimeViz.Proto.raw(), String.t()) :: :ok

Send protobuf files to the app's GenServer. The app can handle a series of files, belonging to different groupings (e.g., test, dev, and prod). When sending the file, you must also provide a comment (perhaps a time stamp or other information about the file), which will be displayed along with the visualization.

new_message(group, vehicle_positions, trip_updates, comment)

sort_by_time(time_list)

sort_time_diff(base_list, diff_list)

trips_we_care_about(state, routes)

vehicles_we_care_about(state, routes)

visualize(group, opts)

@spec visualize(term(), route_opts()) :: String.t()

Renders the received protobuf files and comments into an HTML fragment that can either be opened directly in a browser or embedded within the HTML layout of another app.

visualize_diff(group_1, group_2, opts)

@spec visualize_diff(term(), term(), route_opts()) :: String.t()

Renders an HTML fragment that displays the vehicle differences between two pb files.