Skip to content

Commit

Permalink
Script the translation of safety check questions from Excel
Browse files Browse the repository at this point in the history
  • Loading branch information
dabreegster committed Apr 4, 2024
1 parent 94f189e commit 051bb38
Show file tree
Hide file tree
Showing 15 changed files with 230 additions and 88 deletions.
30 changes: 30 additions & 0 deletions src/routes/route_check/safety_check/codegen.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import csv

# Manually copy from Excel, naming the columns "Metric Mode ID Description
# Critical Red Amber Green" (with tabs). This is a one-off script; the source
# of truth becomes the Svelte files, which need to be manually edited to
# improve formatting.
with open("safety_check.tsv") as tsv:
idx = 0
for row in csv.DictReader(tsv, delimiter=" "):
with open(row["ID"].lower() + "/+page.svelte", "w") as f:
f.write("""<script lang="ts">\n""")
f.write("""import Question from "../Question.svelte";\n""")
f.write("""</script>\n""")
f.write("""\n""")

f.write("""<Question\n""")
f.write(" idx={" + str(idx) + "}\n")
f.write(""" label="{}"\n""".format(row["Metric"]))

f.write(""" cases={[\n""")
f.write(""" ["C", "{}"],\n""".format(row["Critical"]))
f.write(""" ["0", "{}"],\n""".format(row["Red"]))
f.write(""" ["1", "{}"],\n""".format(row["Amber"]))
f.write(""" ["2", "{}"],\n""".format(row["Green"]))
f.write(""" ]}\n""")
f.write(""">\n""")

f.write(""" <p>{}</p>\n""".format(row["Description"]))
f.write("""</Question>\n""")
idx += 1
2 changes: 1 addition & 1 deletion src/routes/route_check/safety_check/sa01/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
],
[
"1",
"<2,500vpd cut across main walking, wheeling or cycling streams and side roads and priority junctions have entry treatments.",
"<2,500vpd cut across main walking, wheeling or cycling streams and side roads and priority junctions have entry treatments. ",
],
[
"2",
Expand Down
6 changes: 3 additions & 3 deletions src/routes/route_check/safety_check/sa03/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@
cases={[
[
"C",
"Cyclists are mixed with traffic in lanes between 3.25m and 3.9m wide. Or, cyclists are in unprotected cycle lanes and the combined width of the cycle lane and adjacent traffic lane is between 3.25m and 3.9m.",
"Cyclists are mixed with traffic in lanes between 3.25m and 3.9m wide. Or, cyclists are in unprotected cycle lanes and the combined width of the cycle lane and adjacent traffic lane is between 3.25m and 3.9m.",
],
[
"0",
"Cyclists are mixed with traffic in lanes less than 3.25m wide or over 3.9m wide. Or, cyclists are in unprotected cycle lanes and the combined width of the cycle lane and adjacent traffic lane is under 3.25m or over 3.9m. Or cyclists are mixed with traffic on busy urban streets with no centre line. Or, there are speed cushions present.",
"Cyclists are mixed with traffic in lanes less than 3.25m wide or over 3.9m wide. Or, cyclists are in unprotected cycle lanes and the combined width of the cycle lane and adjacent traffic lane is under 3.25m or over 3.9m. Or cyclists are mixed with traffic on busy urban streets with no centre line. Or, there are speed cushions present.",
],
[
"1",
"Cyclists are in cycle lanes with light protection or stepped cycle tracks under 1.8m wide (single direction). Or, cyclists are in a protected bidirectional cycle facility under 2.5m wide. Or, cyclists are mixed with traffic on quiet urban streets with no centre line.",
"Cyclists are in cycle lanes with light protection or stepped cycle tracks under 1.8m wide (single direction). Or, cyclists are in a protected bidirectional cycle facility under 2.5m wide. Or, cyclists are mixed with traffic on quiet urban streets with no centre line.",
],
["2", "Cyclists are protected from motor traffic or off-road entirely."],
]}
Expand Down
26 changes: 19 additions & 7 deletions src/routes/route_check/safety_check/sa05/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,26 @@
</script>

<Question
idx={0}
label=""
idx={4}
label="Kerbside Activity"
cases={[
["C", ""],
["0", ""],
["1", ""],
["2", ""],
[
"C",
"Cycle facility next to parking/loading facility, without a buffer of at least 0.5m. Or, an unprotected cycle lane is next to a frequently-used bus layby.",
],
[
"0",
"Frequent kerbside activity for cyclists to contend with. Conflict with cyclists is not well-managed.",
],
[
"1",
"Less frequent kerbside activity, and conflict with cyclists is well-managed.",
],
[
"2",
"Kerbside activity is well-managed with no or minimal conflict with cyclists. ",
],
]}
>
<p></p>
<p>Cyclist conflict with kerbside activity, including risk of 'dooring'</p>
</Question>
26 changes: 19 additions & 7 deletions src/routes/route_check/safety_check/sa06/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,26 @@
</script>

<Question
idx={0}
label=""
idx={5}
label="Provision of Crossings"
cases={[
["C", ""],
["0", ""],
["1", ""],
["2", ""],
[
"C",
"On very busy streets (>8,000vpd) controlled crossings (including zebra crossings) are not present or more than 400m apart. On quieter streets (<8,000vpd), desire lines are blocked by parking and loading. ",
],
[
"0",
"On very busy streets (>8,000vpd), controlled crossings (including zebra crossings) are provided every 200-400m. On quieter streets (<8,000vpd), loading/parking is formalised with gaps for pedestrians to cross.",
],
[
"1",
"On very busy streets (>8,000vpd), controlled crossings (including zebra crossings) are provided every 100-200m. On quieter streets (<8,000vpd), loading/parking is formalised with gaps for pedestrians to cross on desire lines.",
],
[
"2",
"On very busy streets (>8,000vpd), controlled crossings (including zebra crossings) are provided every 50-100m. On quieter streets (<8,000vpd), there are controlled crossings or only one lane of traffic to cross.",
],
]}
>
<p></p>
<p>Ability of pedestrians to cross the street safely on desire lines</p>
</Question>
26 changes: 19 additions & 7 deletions src/routes/route_check/safety_check/sa07/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,26 @@
</script>

<Question
idx={0}
label=""
idx={6}
label="Standard of Crossings"
cases={[
["C", ""],
["0", ""],
["1", ""],
["2", ""],
[
"C",
"On very busy streets (>8,000vpd), there are uncontrolled crossings of two or more lanes with no gaps in traffic. At signal junctions there are arms with dropped kerbs and tactile paving but no green pedestrian symbol.",
],
[
"0",
"On very busy streets (>8,000vpd), there are uncontrolled crossings or zebra/parallel crossings. On quieter streets (<8,000vpd), crossing points have no implied priority or there are no crossing points.",
],
[
"1",
"On very busy streets (>8,000vpd), signal crossings are provided for pedestrians. On quieter streets (<8,000vpd), crossing points have effective implied priority for pedestrians.",
],
[
"2",
"On very busy streets (>8,000vpd), signal crossings rest on green for pedestrians or have rapid response. On quieter streets (<8,000vpd), crossing points are controlled crossings.",
],
]}
>
<p></p>
<p>Suitability of pedestrian crossings in context</p>
</Question>
20 changes: 13 additions & 7 deletions src/routes/route_check/safety_check/sa08/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,20 @@
</script>

<Question
idx={0}
label=""
idx={7}
label="Motor Traffic Speed"
cases={[
["C", ""],
["0", ""],
["1", ""],
["2", ""],
["C", "85th percentile speed is over 30mph."],
["0", "85th percentile speed is over 25mph."],
["1", "85th percentile speed is between 20mph and 25mph."],
[
"2",
"85th percentile speed is under 20mph. Or, cyclists are protected from motor traffic or off-road entirely and controlled crossings are provided for pedestrians wherever needed.",
],
]}
>
<p></p>
<p>
85th percentile speed of motor traffic (where cyclists are not protected or
pedestrians are crossing uncontrolled)
</p>
</Question>
29 changes: 22 additions & 7 deletions src/routes/route_check/safety_check/sa09/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,29 @@
</script>

<Question
idx={0}
label=""
idx={8}
label="Motor Traffic Volume"
cases={[
["C", ""],
["0", ""],
["1", ""],
["2", ""],
[
"C",
">1,000 vehicles in the busiest hour. Or, over 5% of traffic is HGVs where there are over 500 vehicles in the busiest hour.",
],
[
"0",
"500-1,000 vehicles in the busiest hour. Or, 2-5% of traffic is HGVs where there are 200-499 vehicles in the busiest hour.",
],
[
"1",
"200-499 vehicles in the busiest hour. And, less than 2% of traffic is HGVs.",
],
[
"2",
"<200 vehicles in the busiest hour. Or, cyclists are protected from motor traffic or off-road entirely and controlled crossings are provided for pedestrians wherever needed.",
],
]}
>
<p></p>
<p>
Volume of motor traffic at the busiest hour (where cyclists are not
protected or pedestrians cross uncontrolled)
</p>
</Question>
29 changes: 22 additions & 7 deletions src/routes/route_check/safety_check/sa10/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,29 @@
</script>

<Question
idx={0}
label=""
idx={9}
label="Pedestrian Crossing Speed"
cases={[
["C", ""],
["0", ""],
["1", ""],
["2", ""],
[
"C",
"Pedestrians who start crossing at the end of the 'invitation to cross' must cross at a speed of over 1.2m/s to get across the whole crossing in time.",
],
[
"0",
"There are no detectors to extend crossing times, but pedestrians who start crossing at the end of the 'invitation to cross' can cross at a speed of 1.2m/s and get across the whole crossing in time.",
],
[
"1",
"There are detectors present on the crossing which extend crossing times based on a crossing speed of 1.2m/s.",
],
[
"2",
"There are detectors present on the crossing which extend crossing times based on a crossing speed of 1m/s.",
],
]}
>
<p></p>
<p>
Required crossing speed at signal crossings (risk of pedestrians coming into
conflict with traffic).
</p>
</Question>
29 changes: 22 additions & 7 deletions src/routes/route_check/safety_check/sa11/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,29 @@
</script>

<Question
idx={0}
label=""
idx={10}
label="Footway Widths"
cases={[
["C", ""],
["0", ""],
["1", ""],
["2", ""],
[
"C",
"Where the footway is next to the carriageway, there is: • <1m clear footway width on any footway • <1.5m clear footway width for over 6m • 1m-2m clear footway width with a Pedestrian Comfort Level of D-E Or there is no footway.",
],
[
"0",
"Where the footway is next to the carriageway, there is: • <2m clear footway width but pedestrian comfort is good (PCL of A-C) • 2m-3m clear footway width and pedestrian comfort is poor (PCL of D-E). Where the footway is not next to the carriageway, the clear footway width is <1.5m.",
],
[
"1",
"Where the footway is next to the carriageway, there is: • 2m-3m clear footway width and pedestrian comfort is good (PCL of A-C). • >3m clear footway width and pedestrian comfort is poor (PCL of D-E). Where the footway is not next to the carriageway, the clear footway width is 1.5m-3m.",
],
[
"2",
">3m clear footway width and pedestrian comfort is good (PCL of A-C).",
],
]}
>
<p></p>
<p>
Clear walking and wheeling spaces free of permanent obstructions and
furniture, reducing risk of pedestrians walking in the carriageway.
</p>
</Question>
17 changes: 10 additions & 7 deletions src/routes/route_check/safety_check/sa12/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,17 @@
</script>

<Question
idx={0}
label=""
idx={11}
label="Effective Width next to Tram Lines"
cases={[
["C", ""],
["0", ""],
["1", ""],
["2", ""],
[
"C",
"<2.4m from tramline edge to kerb on a straight run. Insufficient clearance on a curve.",
],
["0", "2.4m from tramline edge to kerb."],
["1", ">2.4m from tramline edge to kerb."],
["2", "Physical protection is provided for cyclists."],
]}
>
<p></p>
<p>Effective width next to tram line on a straight run or a curve</p>
</Question>
20 changes: 13 additions & 7 deletions src/routes/route_check/safety_check/sa13/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,20 @@
</script>

<Question
idx={0}
label=""
idx={12}
label="Crossing Angle of Tram/Train Rails"
cases={[
["C", ""],
["0", ""],
["1", ""],
["2", ""],
["C", "Crossing angle less than 60 degrees."],
["0", "Crossing angle between 60 and 80 degrees."],
[
"1",
"Crossing angle between 80 and 90 degrees (or between 60 and 80 degrees with track filler creating a smooth crossing for cyclists).",
],
[
"2",
"Crossing angle between 80 and 90 degrees with track filler creating a smooth crossing for cyclists.",
],
]}
>
<p></p>
<p>Crossing angle (between cyclist desire line and tram or train rails).</p>
</Question>
18 changes: 11 additions & 7 deletions src/routes/route_check/safety_check/sa14/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,18 @@
</script>

<Question
idx={0}
label=""
idx={13}
label="Cycling Surface and Maintenance Defects"
cases={[
["C", ""],
["0", ""],
["1", ""],
["2", ""],
["C", "Major defects."],
["0", "Many minor defects."],
["1", "Few minor defects."],
["2", "No defects."],
]}
>
<p></p>
<p>
Cycling surface and maintenance defects: • sharp gradients (≥12.5%) • non
cycle friendly ironworks • raised/sunken covers or gullies • potholes •
loose/cracked surfaces • poor drainage or slip risks • overgrown vegetation
</p>
</Question>
Loading

0 comments on commit 051bb38

Please sign in to comment.