forked from mapsme/subways
-
Notifications
You must be signed in to change notification settings - Fork 0
/
v2h_templates.py
297 lines (287 loc) · 6.84 KB
/
v2h_templates.py
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
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
validator_osm_wiki_url = (
"https://wiki.openstreetmap.org/wiki/Quality_assurance#subway-preprocessor"
)
github_url = "https://github.com/alexey-zakharenkov/subways"
produced_by = f"""Produced by
<a href="{github_url}">Subway Preprocessor</a> on {{date}}"""
metro_mapping_osm_article = "https://wiki.openstreetmap.org/wiki/Metro_Mapping"
list_of_metro_systems_url = (
"https://en.wikipedia.org/wiki/List_of_metro_systems#List"
)
# These are templates for validation_to_html.py
# Variables should be in curly braces
STYLE = """
<style>
body {
font-family: sans-serif;
font-size: 12pt;
margin: 0px;
}
main {
margin: 10px;
}
main {
margin: 0 auto;
max-width: 900px;
}
th {
font-size: 10pt;
}
.errors {
font-size: 10pt;
color: #ED0000;
}
.warnings {
font-size: 10pt;
color: saddlebrown;
}
.notices {
font-size: 10pt;
color: darkblue;
}
.bold {
font-weight: bold;
}
.color0 {
background: pink;
}
.color1 {
background: lightgreen;
}
.hlink {
color: #888;
opacity: 0.5;
}
table {
max-width: 900px;
}
tr:hover td:nth-child(n+2) {
filter: hue-rotate(-50deg);
}
td {
border-radius: 2px;
}
td > div {
margin-bottom: 0.8em;
}
.tooltip {
font-weight: bold;
position: relative;
text-align: left;
}
.tooltip div {
display: inline-block;
width: 19px;
}
.tooltip:before {
content: attr(data-text);
position: absolute;
top: 100%;
left: 0;
margin-top: 14px;
width: 200px;
padding: 10px;
border-radius: 10px;
background: lightblue;
color: black;
text-align: center;
opacity: 0;
transition: .3s opacity;
visibility: hidden;
z-index: 10
}
.tooltip:after {
content: "";
position: absolute;
margin-top: -5px;
top: 100%;
left: 30px;
border: 10px solid #000;
border-color: transparent transparent lightblue transparent;
visibility: hidden;
opacity: 0;
transition: .3s opacity
}
.tooltip:hover {
text-decoration: none
}
.tooltip:hover:before,.tooltip:hover:after {
opacity: 1;
visibility: visible
}
footer {
background: white;
border-top: 1px solid grey;
bottom: 0px;
padding: 10px;
position: sticky;
}
</style>
"""
INDEX_HEADER = f"""
<!doctype html>
<html>
<head>
<title>Subway Validator</title>
<meta charset="utf-8">
{STYLE}
</head>
<body>
<main>
<h1>Subway Validation Results</h1>
<p><b>{{good_cities}}</b> of <b>{{total_cities}}</b> networks validated without
errors. To make a network validate successfully please follow the
<a href="{metro_mapping_osm_article}">metro mapping
instructions</a>. Commit your changes to the OSM and then check back to the
updated validation results after the next validation cycle, please.
See <a href="{validator_osm_wiki_url}">the validator instance(s)
description</a> for the schedule and capabilities.</p>
<p><a href="render.html">View networks on a map</a></p>
<table cellspacing="3" cellpadding="2" style="margin-bottom: 1em;">
"""
INDEX_CONTINENT = """
<tr><td colspan="9"> </td></tr>
<tr>
<th>Continent</th>
<th>Country</th>
<th>Good Cities</th>
<th>Subway Lines</th>
<th>Light Rail Lines</th>
<th>Stations</th>
<th>Interchanges</th>
<th>Errors</th>
<th>Warnings</th>
<th>Notices</th>
</tr>
<tr>
<td colspan="2" class="bold color{=cities}">{continent}</td>
<td class="color{=cities}">{good_cities} / {total_cities}</td>
<td class="color{=subwayl}">{subwayl_found} / {subwayl_expected}</td>
<td class="color{=lightrl}">{lightrl_found} / {lightrl_expected}</td>
<td class="color{=stations}">{stations_found} / {stations_expected}</td>
<td class="color{=transfers}">{transfers_found} / {transfers_expected}</td>
<td class="color{=errors}">{num_errors}</td>
<td class="color{=warnings}">{num_warnings}</td>
<td class="color{=notices}">{num_notices}</td>
</tr>
{content}
"""
INDEX_COUNTRY = """
<tr>
<td> </td>
<td class="bold color{=cities}"><a href="{file}">{country}</a></td>
<td class="color{=cities}">{good_cities} / {total_cities}</td>
<td class="color{=subwayl}">{subwayl_found} / {subwayl_expected}</td>
<td class="color{=lightrl}">{lightrl_found} / {lightrl_expected}</td>
<td class="color{=stations}">{stations_found} / {stations_expected}</td>
<td class="color{=transfers}">{transfers_found} / {transfers_expected}</td>
<td class="color{=errors}">{num_errors}</td>
<td class="color{=warnings}">{num_warnings}</td>
<td class="color{=notices}">{num_notices}</td>
</tr>
"""
INDEX_FOOTER = f"""
</table>
</main>
<footer>{produced_by}
from <a href="{{cities_info_url}}">this reference metro statistics</a>. See
<a href="{list_of_metro_systems_url}">
this wiki page</a> for a list of all metro systems.</footer>
</body>
</html>
"""
COUNTRY_HEADER = f"""
<!doctype html>
<html>
<head>
<title>Subway Validator: {{country}}</title>
<meta charset="utf-8">
{STYLE}
</head>
<body>
<main>
<h1>Subway Validation Results for {{country}}</h1>
<p><a href="index.html">Return to the countries list</a>.</p>
<table cellspacing="3" cellpadding="2">
<tr>
<th>City</th>
{{?subways}}
<th>Subway Lines</th>
<th>Light Rail Lines</th>
{{end}}{{?overground}}
<th>Tram Lines</th>
<th>Bus Lines</th>
<th>T-Bus Lines</th>
<th>Other Lines</th>
{{end}}
<th>Stations</th>
<th>Interchanges</th>
<th>Unused Entrances</th>
</tr>
"""
COUNTRY_CITY = """
<tr id="{slug}">
<td class="bold color{good_cities}">
{city}
{?yaml}<a href="{yaml}" class="hlink" title="Download YAML">Y</a>{end}
{?json}<a href="{json}" class="hlink" title="Download GeoJSON">J</a>{end}
{?json}<a href="render.html#{slug}" class="hlink" title="View map"
target="_blank">M</a>{end}
</td>
{?subways}
<td class="color{=subwayl}">sub: {subwayl_found} / {subwayl_expected}</td>
<td class="color{=lightrl}">lr: {lightrl_found} / {lightrl_expected}</td>
{end}{?overground}
<td class="color{=traml}">t: {traml_found} / {traml_expected}</td>
<td class="color{=busl}">b: {busl_found} / {busl_expected}</td>
<td class="color{=trolleybusl}">
tb: {trolleybusl_found} / {trolleybusl_expected}
</td>
<td class="color{=otherl}">o: {otherl_found} / {otherl_expected}</td>
{end}
<td class="color{=stations}">st: {stations_found} / {stations_expected}</td>
<td class="color{=transfers}">
int: {transfers_found} / {transfers_expected}
</td>
<td class="color{=entrances}">ent: {unused_entrances}</td>
</tr>
<tr><td colspan="{?subways}6{end}{?overground}8{end}">
{?errors}
<div class="errors">
<div
data-text="Network is invalid and not suitable for routing."
class="tooltip">
🛑 Errors
</div>
{errors}
</div>
{end}
{?warnings}
<div class="warnings">
<div
data-text="Problematic data but it's still possible to build routes."
class="tooltip">
⚠️ Warnings
</div>
{warnings}
</div>
{end}
{?notices}
<div class="notices">
<div
data-text="Suspicious condition but not necessarily an error."
class="tooltip">
ℹ️ Notices
</div>
{notices}
{end}
</div>
</td></tr>
"""
COUNTRY_FOOTER = f"""
</table>
</main>
<footer>{produced_by}.</footer>
</body>
</html>
"""