~ihabunek/triglav

015d510fab55939a35224837d68ae33972e22770 — Ivan Habunek 9 months ago 7cbad22
Show platforms in route detail view

Highlight missing gtfs stop_ids
M assets/css/app.scss => assets/css/app.scss +1 -0
@@ 170,6 170,7 @@ a.josm-remote {
.smaller { font-size: 0.9rem; }
.hidden { visibility: hidden; }
.w-full { width: 100%; }
.text-center { text-align: center; }

// Phoenix crap


M lib/triglav_web/controllers/zet/routes_controller.ex => lib/triglav_web/controllers/zet/routes_controller.ex +8 -1
@@ 65,6 65,12 @@ defmodule TriglavWeb.Zet.RoutesController do
    hierarchy = make_hierarchy(relations)
    {errors, rel_errors} = Gtfs.get_errors(id) |> group_errors_by_relation()

    platform_members =
      relations
      |> Enum.map(& &1.id)
      |> Osmosis.list_platform_members()
      |> Enum.group_by(& &1.relation_id)

    relations_by_stop_ids =
      for relation <- relations, Relation.is_route(relation), into: %{} do
        {Osmosis.list_gtfs_stop_ids(relation.id), relation}


@@ 98,7 104,8 @@ defmodule TriglavWeb.Zet.RoutesController do
      rel_errors: rel_errors,
      trips: grouped_trips,
      stops_json: stops_json,
      ways_geojson: ways_geojson
      ways_geojson: ways_geojson,
      platform_members: platform_members
    )
  end


M lib/triglav_web/templates/zet/routes/detail.html.eex => lib/triglav_web/templates/zet/routes/detail.html.eex +47 -4
@@ 18,6 18,8 @@
<main role="main" class="container-wide">
  <h1>#<%= @route.id %>: <%= @route.long_name %></h1>

  <div id="routes-map"></div>

  <h2>OSM Relations</h2>

  <section>


@@ 25,6 27,49 @@
    <%= josm_load_objects(@relations) %>
  </section>

  <section>
    <h3>Route relations</h3>

    <div style="display: flex; flex-direction: row;">
      <%= for relation <- @relations, Relation.is_route(relation) do %>
        <% members = @platform_members[relation.id] || [] %>
        <div style="margin-left: 1rem;">
          <table>
            <thead>
              <tr>
                <th colspan="4" class="text-center">
                  <%= osm_link(relation, name: true) %>
                </th>
              </tr>
              <tr>
                <th>#</th>
                <th>Name</th>
                <th>gtfs:stop_id</th>
                <th>JOSM</th>
              </tr>
            </thead>
            <tbody>
              <%= for m <- members do %>
              <tr>
                <td><%= osm_link(m.member) %></td>
                <td><%= m.member.tags["name"] %></td>
                <td class="<%= if !m.member.tags["gtfs:stop_id"], do: "bg-red" %>">
                  <%= if m.member.tags["gtfs:stop_id"] do %>
                    <%= m.member.tags["gtfs:stop_id"] %>
                  <% else %>
                    Missing
                  <% end %>
                </td>
                <td><%= josm_load_objects([m.member]) %></td>
              </tr>
              <% end %>
            </tbody>
          </table>
        </div>
      <% end %>
    </div>
  </section>

  <%= if length(@errors) > 0 or map_size(@rel_errors) > 0 do %>
    <section>
      <h3>Errors</h3>


@@ 63,8 108,6 @@
  <p>Routes extracted from GTFS data published by ZET.
  All distinct routes are shown along with the number of trips along this route. </p>

  <div id="routes-map"></div>

  <%= for {direction_id, trips} <- @trips do %>
    <h3>Direction #<%= direction_id %></h3>



@@ 76,9 119,9 @@
            <thead>
              <tr>
                <th>#</th>
                <th>ID</th>
                <th>GTFS ID</th>
                <th>Name</th>
                <th>⌖</th>
                <th>JOSM</th>
              </tr>
            </thead>
            <tbody>

M lib/triglav_web/views/osm_helpers.ex => lib/triglav_web/views/osm_helpers.ex +3 -3
@@ 121,7 121,7 @@ defmodule TriglavWeb.OsmHelpers do
  end

  def josm_load_objects(objects, opts \\ []) do
    {title, opts} = Keyword.pop(opts, :title, "Open in JOSM")
    {title, opts} = Keyword.pop(opts, :title, "Load")
    link = Triglav.Josm.load_objects(objects, opts)

    ~E"""


@@ 133,11 133,11 @@ defmodule TriglavWeb.OsmHelpers do
  end

  def josm_zoom(lat, lon, opts \\ []) do
    {title, opts} = Keyword.pop(opts, :title, "Open in JOSM")
    title = Keyword.get(opts, :title, "Zoom")
    link = Triglav.Josm.zoom(lat, lon)

    ~E"""
    <a href="<%= link %>" class="josm-remote" title="Open in JOSM" target="josm">
    <a href="<%= link %>" class="josm-remote" title="<%= title %>" target="josm">
      🜨
      <%= title %>
    </a>

M lib/triglav_web/views/zet/routes_view.ex => lib/triglav_web/views/zet/routes_view.ex +2 -0
@@ 1,6 1,8 @@
defmodule TriglavWeb.Zet.RoutesView do
  use TriglavWeb, :view

  alias Triglav.Schemas.Osmosis.Relation

  def title("index.html", _), do: "Routes"
  def title("detail.html", assigns), do: "Route ##{assigns.route.id}"