Skip to content

Fix: Turning circle u-turn test failures#7394

Merged
DennisOSRM merged 2 commits intoclaude/use-turning-circles-u-turnsfrom
claude/fix-test-failures
Mar 2, 2026
Merged

Fix: Turning circle u-turn test failures#7394
DennisOSRM merged 2 commits intoclaude/use-turning-circles-u-turnsfrom
claude/fix-test-failures

Conversation

@Claude
Copy link
Copy Markdown
Contributor

@Claude Claude AI commented Mar 2, 2026

Five cucumber tests fail where routing should prefer turning facilities (turning_circle, turning_loop, mini_roundabout) for u-turns but instead chooses direct u-turns.

Root Cause

The Lua profile code in profiles/lib/obstacles.lua was attempting to lookup obstacle types using obstacle_type[highway] where highway is a string value (e.g., "turning_circle"). However, Sol2's new_enum() function creates an enum table with named fields (e.g., obstacle_type.turning_circle) but doesn't automatically support string-indexed lookups (obstacle_type["turning_circle"]).

This caused turning facilities to never be added to the obstacle map, resulting in the routing algorithm not recognizing them and applying u-turn penalties even when using designated turning facilities.

Solution

Added an explicit mapping table highway_to_obstacle_type in profiles/lib/obstacles.lua that maps highway tag string values to their corresponding obstacle type enum values:

local highway_to_obstacle_type = {
    ["traffic_signals"] = obstacle_type.traffic_signals,
    ["stop"] = obstacle_type.stop,
    ["give_way"] = obstacle_type.give_way,
    ["crossing"] = obstacle_type.crossing,
    ["traffic_calming"] = obstacle_type.traffic_calming,
    ["mini_roundabout"] = obstacle_type.mini_roundabout,
    ["turning_loop"] = obstacle_type.turning_loop,
    ["turning_circle"] = obstacle_type.turning_circle
}

This ensures that nodes with highway=turning_circle, highway=turning_loop, or highway=mini_roundabout are correctly identified and added to the obstacle map during extraction, allowing the routing engine to recognize these facilities and avoid applying u-turn penalties when using them.

Changes Made

  • File Modified: profiles/lib/obstacles.lua
    • Added explicit highway_to_obstacle_type mapping table (lines 6-16)
    • Changed lookup from obstacle_type[highway] to highway_to_obstacle_type[highway] (line 23)

Expected Impact

All five failing cucumber test scenarios should now pass:

  • Car - Should prefer turning_circle for u-turn over direct u-turn
  • Car - U-turn at turning_loop should have no penalty
  • Car - U-turn at mini_roundabout should work
  • Car - Multiple turning facilities, use closest
  • Car - Turning circle on one-way should respect direction
Original prompt

Reference: https://github.com/Project-OSRM/osrm-backend/actions/runs/22586945171/job/65434470411#step:15:1

Inspect test failures und devise a fix

@Claude Claude AI changed the title [WIP] Inspect test failures and devise a fix Investigation: Turning circle u-turn test failures Mar 2, 2026
@DennisOSRM
Copy link
Copy Markdown
Collaborator

@claude[agent] execute the next steps

…-type mapping

The Lua profile was attempting to use obstacle_type[highway] as a table lookup,
but Sol2's new_enum() doesn't automatically create string-indexed access. Added
an explicit mapping table (highway_to_obstacle_type) to correctly map highway tag
values like "turning_circle", "turning_loop", and "mini_roundabout" to their
corresponding obstacle type enums.

This fixes the issue where turning facilities were not being recognized during
route calculation, causing u-turns to use direct u-turn penalties instead of
taking advantage of designated turning facilities.

Co-authored-by: DennisOSRM <[email protected]>
@Claude Claude AI changed the title Investigation: Turning circle u-turn test failures Fix: Turning circle u-turn test failures Mar 2, 2026
@DennisOSRM DennisOSRM marked this pull request as ready for review March 2, 2026 20:47
@DennisOSRM DennisOSRM merged commit d29ad56 into claude/use-turning-circles-u-turns Mar 2, 2026
@DennisOSRM DennisOSRM deleted the claude/fix-test-failures branch March 2, 2026 20:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants