Current section

Files

Jump to
gtfs_realtime_viz lib templates single_file.eex
Raw

lib/templates/single_file.eex

<%= for {{comment, vehicles_by_stop}, i} <- Enum.with_index(@vehicle_archive) do %>
<% trip_updates = Enum.at(@trip_update_archive, i) %>
<div id="viz-<%= i %>" class="viz-tool viz-hidden">
<div class="viz-comment"><%= comment %></div>
<h2>Routes</h2>
<%= for {route_name, stops} <- @routes do %>
<h3><%= route_name %></h3>
<table class="viz-ladder">
<tr>
<th class="viz-position">Next Train Arrives in:</th>
<th class="viz-position">Transit</th>
<th class="viz-position">Incoming</th>
<th class="viz-position">At</th>
<th>Station</th>
<th class="viz-position">At</th>
<th class="viz-position">Incoming</th>
<th class="viz-position">Transit</th>
<th class="viz-position">Next Train Arrives in:</th>
</tr>
<%= for {stop_name, stop_id_0, stop_id_1} <- stops do %>
<% stop_id_0 = {stop_id_0, 0} %>
<% stop_id_1 = {stop_id_1, 1} %>
<% vs0 = vehicles_by_stop[stop_id_0] || [] %>
<% vs1 = vehicles_by_stop[stop_id_1] || [] %>
<tr>
<td>
<%= for prediction <- format_times(trip_updates[stop_id_0]) do %>
<%= prediction %><br>
<% end %>
</td>
<td><%= trainify(vs0, :IN_TRANSIT_TO, "πŸš‚") %></td>
<td><%= trainify(vs0, :INCOMING_AT, "πŸš‚") %></td>
<td><%= trainify(vs0, :STOPPED_AT, "πŸš‚") %></td>
<td>
<%= stop_name %>
</td>
<td><%= trainify(vs1, :STOPPED_AT, "πŸš‚") %></td>
<td><%= trainify(vs1, :INCOMING_AT, "πŸš‚") %></td>
<td><%= trainify(vs1, :IN_TRANSIT_TO, "πŸš‚") %></td>
<td>
<%= for prediction <- format_times(trip_updates[stop_id_1]) do %>
<%= prediction %><br>
<% end %>
</td>
</tr>
<% end %>
</table>
<% end %>
<h2>All Vehicles</h2>
<div>
<table class="viz-all-vehicles">
<thead>
<tr>
<th>Veh. ID</th>
<th>Veh. Label</th>
<th>Route ID</th>
<th>Trip ID</th>
<th>Sched. Rel.</th>
<th>Stop ID</th>
<th>Status</th>
<th>Stop Seq.</th>
<th>Position</th>
</tr>
</thead>
<tbody>
<%= for {_id, vehicles} <- vehicles_by_stop, vehicle <- vehicles do %>
<tr>
<%= if (veh = vehicle.vehicle) do %>
<td><%= veh.id %></td>
<td><%= veh.label %></td>
<% else %>
<td>n/a</td>
<td>n/a</td>
<% end %>
<%= if (trip = vehicle.trip) do %>
<td><%= trip.route_id %></td>
<td><%= trip.trip_id %></td>
<td><%= trip.schedule_relationship %></td>
<% else %>
<td>n/a</td>
<td>n/a</td>
<td>n/a</td>
<% end %>
<td><%= vehicle.stop_id %></td>
<td><%= vehicle.current_status %></td>
<td><%= vehicle.current_stop_sequence %></td>
<%= if (pos = vehicle.position) do %>
<td><%= "(#{Float.round(pos.latitude, 5)}, #{Float.round(pos.longitude, 5)})" %></td>
<% else %>
<td>n/a</td>
<% end %>
</tr>
<% end %>
</tbody>
</table>
</div>
</div>
<% end %>