Implement turning circle support for u-turns#7388
Conversation
|
@claude[agent] proceed with implementation |
- Add has_turning_facility field to ExtractionTurn structure - Detect turning facilities (turning_circle, turning_loop, mini_roundabout) at intersections - Expose has_turning_facility to Lua profiles via scripting environment - Modify car.lua to eliminate u-turn penalty at turning facilities - Add comprehensive test scenarios for turning circle u-turn behavior Co-authored-by: DennisOSRM <1067895+DennisOSRM@users.noreply.github.com>
Implementation complete in commit 1e2d0e5. Changes made:
Design decisions applied:
Total: ~165 lines across 6 files. Ready for build and test validation. |
- Apply clang-format to graph_compressor.cpp - Add turning circle feature to CHANGELOG.md - Document has_turning_facility field in profiles.md Co-authored-by: DennisOSRM <1067895+DennisOSRM@users.noreply.github.com>
|
@claude[agent] update the title of the pr |
Updated PR title suggestion: "Implement turning circle support for u-turns" This better reflects that the PR implements the complete feature (detection, routing logic, tests, and documentation) rather than just formatting/documentation fixes. Alternative titles:
The current commits include both the implementation (1e2d0e5) and documentation/formatting (080cf39). Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
* Initial plan * Fix turning facility detection by adding explicit highway-to-obstacle-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 <1067895+DennisOSRM@users.noreply.github.com> --------- Co-authored-by: anthropic-code-agent[bot] <242468646+Claude@users.noreply.github.com> Co-authored-by: DennisOSRM <1067895+DennisOSRM@users.noreply.github.com>
- Add bearings (90,10 270,10) to all directional u-turn scenarios so OSRM is forced to make a real turn rather than returning a trivial zero-distance route for same start/end waypoints - Add no_u_turn turn restrictions to scenarios 1-3, modeling the real-world case where turning circles exist precisely because direct u-turns on the road are restricted - Fix expected routes: side-street turning facilities produce abc,bd,bd,abc,abc (not abc,bd,abc) since the outbound and inbound traversals of the spur road are reported separately - Fix expected turns: continue uturn + turn left (not turn right twice) - Fix one-way scenario: with bd being one-way the turning circle at d is inaccessible for u-turns, so OSRM correctly falls back to a regular u-turn on the main road (abc,abc,abc, continue uturn) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Instead of zero penalty, u-turns at turning circles, turning loops, and mini roundabouts now incur a small 5-second delay. This reflects the real-world time cost of navigating the facility while still being much cheaper than a regular u-turn penalty (20 seconds). Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Implements support for using
highway=turning_circle,highway=turning_loop, andhighway=mini_roundaboutnodes for u-turn maneuvers, eliminating unnecessary u-turn penalties at designated turning facilities.Implementation
C++ Core Changes
has_turning_facilityfield toExtractionTurnstructureedge_based_graph_factory.cppto detect turning facilities at intersections usingObstacleMapgraph_compressor.cppto handle turning facilities during node compressionscripting_environment_lua.cppto expose the field to Lua profiles (API v3 and v4)Routing Logic
profiles/car.luato checkturn.has_turning_facilitybefore applying u-turn penaltyTesting
features/car/turning_circle_uturn.featureCode Formatting
src/extractor/graph_compressor.cppto fix constructor alignment violationsDocumentation
has_turning_facilityfield toprocess_turnAPI documentation indocs/profiles.mdCHANGELOG.mdwith feature entry under Routing sectionThe
has_turning_facilityboolean is now available in Lua profiles:Design Decisions
Files Modified
include/extractor/extraction_turn.hpp- Add field (~9 lines)src/extractor/edge_based_graph_factory.cpp- Detect facility (~3 lines)src/extractor/graph_compressor.cpp- Handle compression & formatting (~18 lines)src/extractor/scripting_environment_lua.cpp- Expose to Lua (~4 lines)profiles/car.lua- Adjust penalty (~5 lines)features/car/turning_circle_uturn.feature- Tests (new, ~140 lines)CHANGELOG.md- Document feature (~1 line)docs/profiles.md- Document API (~1 line)Total: ~180 lines across 8 files
Original prompt
Todo