~ihabunek/triglav

ref: f66c43139d76b7a26925de4e29498ff1473c0950 triglav/lib/triglav_web/templates/zet/routes/detail.html.eex -rw-r--r-- 5.2 KiB
f66c4313Ivan Habunek Store sample trip ID in derived data, simplify schemas 4 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
<link rel="stylesheet" type="text/css" href="<%= Routes.static_path(@conn, "/css/routes.css") %>">

<style type="text/css">
  #routes-map {
    height: 600px;
    max-width:  1024px;
    margin: 1rem 0;
  }
</style>

<script id="stops-json" type="application/json">
  <%= raw(@stops_json) %>
</script>

<script id="routes-geojson" type="application/json">
  <%= raw(@routes_geojson) %>
</script>

<main role="main" class="container-wide">
  <ul class="breadcrumbs">
    <li><a href="<%= Routes.zet_routes_path(@conn, :index) %>">Rotues</a></li>
    <li>#<%= @route.id %></li>
  </ul>

  <h1>#<%= @route.id %>: <%= @route.long_name %></h1>

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

  <h2>OSM Relations</h2>

  <section>
    <%= render_relation_hierarchy(@hierarchy) %>
    <%= josm_load_objects(@relations) %>
  </section>

  <%= if length(@route_errors) > 0 or map_size(@relation_errors) > 0 do %>
    <section>
      <h3>Errors</h3>
      <%= if length(@route_errors) > 0 do %>
        <ul>
          <%= for error <- @route_errors do %>
            <li>
              <span class="text-red"><%= render_error(error) %></span>
            </li>
          <% end %>
        </ul>
      <% end %>
      <%= if map_size(@relation_errors) > 0 do %>
        <ul>
          <%= for {relation_id, errors} <- @relation_errors do %>
            <li>
              <% relation = Enum.find(@relations, & &1.id == relation_id) %>
              <%= osm_link(relation, tags: ["type"], name: true) %>
              <ul>
                <%= for error <- errors do %>
                  <li><span class="text-red"><%= render_error(error) %></span></li>
                <% end %>
              </ul>
            </li>
          <% end %>
        </ul>
      <% end %>
    </section>
  <% else %>
    <p class="text-green">No errors found.</p>
  <% end %>

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

    <div style="display: flex; flex-direction: row; flex-wrap: wrap;">
      <%= 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>

          <%= if relation.matched_trip do %>
            <div class="callout">
              <span class="text-green"> Matches a GTFS trip</span>
            </div>
          <% else %>
            <div class="callout error">
               No GTFS trip matched.
              <a href="<%= Routes.zet_routes_path(TriglavWeb.Endpoint, :match, @route.id, relation.id) %>">
                Find a match
              </a>
            </div>
          <% end %>
        </div>
      <% end %>
    </div>
  </section>

  <hr />

  <h2>ZET GTFS trips</h2>

  <p>Trips extracted from GTFS data published by ZET.<br/>
  All distinct trips are shown along with the number of departures along this route. </p>

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

    <div style="display: flex; flex-direction: row; flex-wrap: wrap">
      <%= for trip <- trips do %>
        <div style="margin-left: 1rem;">
          <p><b><%= trip.trip_count %> departures</b></p>
          <table>
            <thead>
              <tr>
                <th>#</th>
                <th>GTFS ID</th>
                <th>Name</th>
                <th>JOSM</th>
              </tr>
            </thead>
            <tbody>
              <%= for {stop_id, index} <- Enum.with_index(trip.stops) do %>
              <% stop = Map.get(@stops, stop_id) %>
              <tr>
                <td><%= index %>.</td>
                <td><%= stop.id %></td>
                <td><%= stop.name %></td>
                <td><%= josm_zoom(stop.lat, stop.lon) %></td>
              </tr>
              <% end %>
            </tbody>
          </table>

          <%= if trip.matched_relation do %>
            <div class="callout">
              <span class="text-green"> Matched relation</span><br />
              <%= osm_link(trip.matched_relation, [josm: true]) %>
            </div>
          <% else %>
            <div class="callout error">
               No relation matched.
            </div>
          <% end %>
        </div>
      <% end %>
    </div>
  <% end %>
</main>

<script defer type="text/javascript" src="<%= Routes.static_path(@conn, "/js/routes.js") %>"></script>