~ihabunek/triglav

ref: 3a62b8feb3be418cf9f3fb176ac6c84a36e66a2f triglav/lib/triglav_web/templates/zet/routes/detail.html.eex -rw-r--r-- 7.1 KiB
3a62b8feIvan Habunek Validate tags on platforms 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
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
<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;
  }

  .bl { border-left: 10px solid lightgray }
</style>

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

<script id="zet-stops-geojson" type="application/json">
  <%= raw(@zet_stops_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>
    <%= for trip <- @trips do %>
      <% has_platform_errors = Enum.any?(trip.platforms, &Map.has_key?(@platform_errors, &1.id)) %>
      <h3 style="margin-top: 1rem"><%= osm_link(trip.relation, name: true) %></h3>
      <div style="margin-left: 1rem;">
        <%= if length(trip.platforms) > 0 do %>
          <table>
            <thead>
              <tr>
                <th colspan="6" class="text-center">OSM Platform</th>
                <th colspan="2" class="text-center bl">GTFS Stop</th>
                <%= if has_platform_errors do %>
                  <th colspan="1" rowspan="2" class="text-center bl">Errors</th>
                <% end %>
              </tr>
              <tr>
                <th>#</th>
                <th>Platform</th>
                <th>Name</th>
                <th>Stop ID</th>
                <th>From route</th>
                <th>JOSM</th>
                <th class="bl">ID</th>
                <th>Name</th>
              </tr>
            </thead>
            <tbody>
              <%= for platform <- trip.platforms do %>
              <% member = platform.node || platform.way %>
              <% errors = Map.get(@platform_errors, platform.id, []) %>
              <tr>
                <td><%= platform.sequence_id %></td>
                <td><%= osm_link(member) %></td>
                <td><%= member.tags["name"] %></td>
                <td class="<%= if !platform.stop_id, do: "error" %>">
                  <%= platform.stop_id || "Missing" %>
                </td>
                <td class="text-right <%= if platform.distance_from_route > 20, do: "error" %>">
                  <%= platform.distance_from_route %>m
                </td>
                <td><%= josm_load_objects([member]) %></td>
                <%= if platform.stop do %>
                  <td class="bl"><%= platform.stop.id %></td>
                  <td><%= platform.stop.name %></td>
                <% else %>
                  <td class="bl"></td>
                  <td></td>
                <% end %>
                <%= if has_platform_errors do %>
                  <td class="bl">
                    <%= if length(errors) > 0 do %>
                      <ul class="no-margin text-red">
                        <%= for error <- errors do %>
                          <li><%= render_error(error) %></li>
                        <% end %>
                      </ul>
                    <% end %>
                  </td>
                <% end %>
              </tr>
              <% end %>
            </tbody>
            <tfoot>
              <% colspan = if has_platform_errors, do: 9, else: 8 %>
              <%= if trip.sample_trip_id do %>
                <tr>
                  <td colspan="<%= colspan %>" class="success text-green text-center">
                     Matches ZET trip <b><%= trip.sample_trip_id %></b>
                  </td>
                </tr>
              <% else %>
                <tr>
                  <td class="error text-center" colspan="<%= colspan %>">
                     No GTFS trip matched.
                    <a href="<%= Routes.zet_routes_path(TriglavWeb.Endpoint, :match, @route.id, trip.relation.id) %>">
                      Find a match
                    </a>
                  </td>
                </tr>
              <% end %>
            </tfoot>
          </table>
        <% else %>
          <div class="callout error">This relation does not have any platforms</div>
        <% end %>
      </div>
    <% end %>
  </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} <- @zet_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.sample_trip_id %></b> (<%= trip.trip_count %> departures)</p>
          <table>
            <thead>
              <tr>
                <th>#</th>
                <th>GTFS ID</th>
                <th>Name</th>
                <th>JOSM</th>
              </tr>
            </thead>
            <tbody>
              <%= for {stop, index} <- Enum.with_index(trip.stops) do %>
              <tr>
                <td><%= index %>.</td>
                <td><%= stop.id %></td>
                <td><%= stop.name %></td>
                <td><%= josm_zoom(stop.lat, stop.lon) %></td>
              </tr>
              <% end %>
            </tbody>
            <tfoot>
              <tr>
                <%= if trip.matched_relation do %>
                  <td class="success text-center" colspan="4">
                    <span class="text-green"> Matches relation</span>
                    <%= osm_link(trip.matched_relation) %>
                  </td>
                <% else %>
                  <td class="error text-center" colspan="4">
                     No relation matched.
                  </td>
                <% end %>
              </tr>
            </tfoot>
          </table>

        </div>
      <% end %>
    </div>
  <% end %>
</main>

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