Skip to content

Commit 75f1d1f

Browse files
committed
Small fixes for crossing audit
1 parent 7bb55ea commit 75f1d1f

File tree

3 files changed

+32
-21
lines changed

3 files changed

+32
-21
lines changed

backend/src/audit.rs

Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -21,33 +21,38 @@ impl Speedwalk {
2121
.mercator
2222
.to_wgs84_gj(&graph.intersections[&junction.i].point);
2323

24-
let mut debug_arms = Vec::new();
24+
let mut arms = Vec::new();
2525
for e in junction.arms {
2626
let edge = &graph.edges[&e];
27-
debug_arms.push(self.mercator.to_wgs84_gj(&edge.linestring));
27+
arms.push(self.mercator.to_wgs84_gj(&edge.linestring));
2828
}
29-
let crossing_count = junction.crossings.len();
30-
let explicit_non_crossing_count = junction.explicit_non_crossings.len();
31-
let mut debug_crossings = Vec::new();
29+
30+
let mut crossings = Vec::new();
3231
for n in &junction.crossings {
33-
debug_crossings.push(
32+
crossings.push(
3433
self.mercator
3534
.to_wgs84_gj(&Point::from(self.derived_nodes[n].pt)),
3635
);
3736
}
38-
let mut debug_explicit_non_crossings = Vec::new();
37+
38+
let mut explicit_non_crossings = Vec::new();
3939
for n in &junction.explicit_non_crossings {
40-
debug_explicit_non_crossings.push(
40+
explicit_non_crossings.push(
4141
self.mercator
4242
.to_wgs84_gj(&Point::from(self.derived_nodes[n].pt)),
4343
);
4444
}
45-
f.set_property("complete", debug_arms.len() == crossing_count + explicit_non_crossing_count);
46-
f.set_property("arms", GeoJson::from(debug_arms));
47-
f.set_property("crossings", GeoJson::from(debug_crossings));
48-
f.set_property("explicit_non_crossings", GeoJson::from(debug_explicit_non_crossings));
49-
f.set_property("crossing_count", crossing_count);
50-
f.set_property("explicit_non_crossing_count", explicit_non_crossing_count);
45+
46+
f.set_property(
47+
"complete",
48+
arms.len() == crossings.len() + explicit_non_crossings.len(),
49+
);
50+
f.set_property("arms", GeoJson::from(arms));
51+
f.set_property("crossings", GeoJson::from(crossings));
52+
f.set_property(
53+
"explicit_non_crossings",
54+
GeoJson::from(explicit_non_crossings),
55+
);
5156

5257
features.push(f);
5358
}
@@ -89,8 +94,7 @@ impl Speedwalk {
8994
// Iterate backward from dst to src
9095
Box::new(edge.node_ids.iter().rev().skip(1))
9196
} else {
92-
// Shouldn't happen, but fallback to all nodes
93-
Box::new(edge.node_ids.iter())
97+
unreachable!()
9498
};
9599

96100
for n in node_iter {
@@ -102,6 +106,8 @@ impl Speedwalk {
102106
}
103107
if node.is_crossing() {
104108
crossings.insert(*n);
109+
// Stop iterating along this edge when we hit the first crossing
110+
break;
105111
}
106112
}
107113
}

web/src/crossings/AuditCrossingsMode.svelte

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@
3131
$: debugExplicitNonCrossings = hovered
3232
? JSON.parse(hovered.properties!.explicit_non_crossings)
3333
: emptyGeojson();
34-
$: crossingCount = hovered?.properties?.crossing_count ?? 0;
35-
$: explicitNonCrossingCount = hovered?.properties?.explicit_non_crossing_count ?? 0;
34+
$: crossingCount = debugCrossings.features.length;
35+
$: explicitNonCrossingCount = debugExplicitNonCrossings.features.length;
3636
3737
let crossingNodes = JSON.parse($backend!.getNodes()) as FeatureCollection;
3838
crossingNodes.features = crossingNodes.features.filter(
@@ -54,8 +54,13 @@
5454
{#if hovered}
5555
<p class="mt-5">
5656
Junction has {debugArms.features.length} arms,
57-
{crossingCount} crossing{#if crossingCount !== 1}s{/if}
58-
{#if explicitNonCrossingCount > 0}, {explicitNonCrossingCount} explicit non-crossing{#if explicitNonCrossingCount !== 1}s{/if}{/if}
57+
{crossingCount}
58+
{crossingCount == 1 ? "crossing" : "crossings"}
59+
{#if explicitNonCrossingCount > 0}
60+
, {explicitNonCrossingCount} explicit {explicitNonCrossingCount == 1
61+
? "non-crossing"
62+
: "non-crossings"}
63+
{/if}
5964
</p>
6065
{/if}
6166
</div>

web/src/sidewalks/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ export interface NodeProps {
66
id: number;
77
tags?: Record<string, string>;
88
is_crossing: boolean;
9-
is_explicit_crossing_no?: boolean;
9+
is_explicit_crossing_no: boolean;
1010
modified: boolean;
1111
way_ids: number[];
1212
problems: Problem[];

0 commit comments

Comments
 (0)