#1490

Mapped barriers between side-by-side ramps: one smooth line, not a zigzag

DraftS-moreowants to merge intofrom

At the I-70 loop ramps in Washington, PA (40.18375 N, 80.26211 W), a jersey barrier is mapped between two one-lane ramps that run side by side. In game it stood as a staggered double line, partly in the lanes. Where the ramps part it stepped sideways, and it kinked where one of its OSM ways meets the next. Each ramp is drawn 8.3 m wide and their centrelines are about 6 m apart, so both carriageways reach over the barrier's line. There were three separate causes.

What it does

  • Zigzag on the loop. _along_road took the nearest other aligned road segment as "the other carriageway". On a bend that is usually the same ramp's next segment, on the barrier's own side, so about a third of the modules were treated as side rails and pushed to one ramp's edge (_shift_to_edge), up to 1.8 m. Now the other carriageway is the nearest aligned segment on the far side of the barrier. This mirrors _relate, which already leaves the deck's own segments out.
  • Steps where the ramps part. Each median module went to the middle of the widening gap on its own (#1025's _to_gap), then jumped back to the mapped line once it was off the lane. Now _to_gap moves a barrier out of a lane by GAP_PUSH (2x) as far as it was on the lane, at most to the gap's middle. A barrier 1 m on a lane, as in #1025's cases, still goes to the middle. _shift_ends moves each end of a moved median as far as a module centred on that end would go, so the run bends as one line instead of stepping.
  • Kinks at way joins. This barrier is three OSM ways end to end (w498642464, w498642463, w498642462). Each way's modules were centred on that way alone, which left a gap or an angled overlap at every join. Now, at an end where another mapped line of the same kind goes on (within JOIN_M, 1 m), a module ends exactly on the join. The other line's end is looked up in the cells around this end, so every tile decides the same. A way joined at both ends spreads its modules to end on both. A free end keeps the centred margin as before, and a guard rail's end cap is no longer put on a join.

Performance

I ran forest_rows offline (best of 5, 10 calls each):

  • the loop's tile (90 modules, all moved medians): 24.8 ms -> 45 ms. The extra time is the two end probes per moved median module. Only medians that _to_gap moves pay this, and only against the road segments near the module.
  • a 300 m guard rail beside a road: 8.6 -> 9.4 ms
  • a 300 m guard rail mapped inside a lane (pushed to the edge): 9.5 -> 9.8 ms

For scale, a road tile takes 15-25 s to build here, so the worst case adds about 0.1 %.

Testing

  • New tests in test_guardrails: a barrier between two ramps on a bend stays on its line, a median leaving a lane where two ramps part stays one line (module ends meet), and a barrier mapped as a chain of ways meets at the joins with no gap anywhere. The first two fail on dev.
  • test_guardrails, test_medians, test_europe_road_details, test_determinism, test_motesfri, test_sesigns, test_road_detail_corrections and test_kantstolpar pass (191 tests).
  • In game (Linux), dev.506 against this branch at 56e6ed56, same camera spots. The loop is one smooth line, and where the ramps part the barrier stays one line between the yellow edge lines. A small jog remains about two thirds of the way down the split (dev.506 has one there too), and the barrier ends abruptly where the mapped way ends, which is the map data. I'm leaving these for now and can polish them further in a future PR.

Shots

Before (dev.506)After

Activity

2

This pull request is a draft

Merging is unavailable until it is marked ready for review.