Skip to content

Closing a segment incorrectly removes turn permissions at non-adjacent intersections #7332

@samarchie

Description

@samarchie

Summary

When using --segment-speed-file to close a road segment, OSRM removes turn permissions at intersections that are not directly connected to the closed segment. This prevents routing from open segments, even when those segments are separated from the closed segment by intermediate nodes.

Environment

Problem Description

Consider a linear road arrangement with two consecutive segments that are a part of the same way:

            |
            |
            | 
-------  Node A: -----------
         Intersection 
            |
            |
         Segment A: 
         Normal speed (40 km/h)
            |
            |
         Node B
            |
            |
         Segment B: 
         Closed segment (0 km/h)
            |
            |
         Node C:
-------  Intersection -------
Closed                 Closed

Consider a house located on Segment A (the open segment between Node A and Node B). We request a route from this house to a destination to the north.

Expected Behaviour

  • Segment B: Should be avoided by routing due to prohibitive speed (✓ expected)
  • Segment A: Should be fully routable with normal turn permissions at Node A (✓ expected)
  • Node A: Turn permissions should be unaffected since the closed segment doesn't connect to it
  • A route from the house on Segment A should successfully navigate to Node A and turn onto other roads

Actual Behaviour

When requesting a route from the house on Segment A:

  • Segment A still shows 40 km/h in debug mode (correct ✓)
  • Segment B correctly shows 0 km/h in debug mode (correct ✓)
  • The vehicle can travel along Segment A
  • However, at Node A (the intersection), turn permissions are removed or blocked
  • In osrm-frontend debug mode, when approaching Node A from Segment A, the turn indicators (left/straight/right arrows) are missing
  • No route can be found because the vehicle cannot execute any turn at Node A to leave Segment A

This is particularly unexpected because Node A and the closed Segment B are not directly connected - they are separated by Node B.

Visual Debug Evidence

Using osrm-frontend with debug mode enabled:

  1. Segment A shows correct 40 km/h speed ✓
  2. Segment B shows 0 km/h and is correctly avoided ✓
  3. Traveling along Segment A toward Node A: movement is allowed ✓
  4. At Node A (intersection): turn arrows are completely missing
  5. Result: No route possible from Segment A because the vehicle cannot leave Node A
Image

Minimal Reproduction

# Download necessary files, such as the car profile and New Zealand OSM data
mkdir data
wget https://raw.githubusercontent.com/Project-OSRM/osrm-backend/refs/heads/master/profiles/car.lua -O data/car.lua
wget https://download.geofabrik.de/australia-oceania/new-zealand-latest.osm.pbf -O data/nz-latest.osm.pbf 

# Create a segment speed file to close a specific segment by setting the 3 segments connecting to Node B in both directions to 0 km/h
cat > data/segment_speeds.csv << EOF
5552089703,104536666,0
104536666,5552089703,0
5785426394,104536666,0
104536666,5785426394,0
5552089702,104536666,0
104536666,5552089702,0
EOF

# Extract, partition, and customize the OSRM data with the segment speed file
docker run -t -v ./data:/data --user $(id -u):$(id -g) ghcr.io/project-osrm/osrm-backend:v6.0.0 osrm-extract -p /data/car.lua /data/nz-latest.osm.pbf

docker run -t -v ./data:/data --user $(id -u):$(id -g) ghcr.io/project-osrm/osrm-backend:v6.0.0 osrm-partition /data/nz-latest.osrm

docker run -t -v ./data:/data --user $(id -u):$(id -g) ghcr.io/project-osrm/osrm-backend:v6.0.0 osrm-customize /data/nz-latest.osrm --segment-speed-file /data/segment_speeds.csv

# Start the OSRM routing server with MLD algorithm
docker run -d -it --cpus=1 -p 54781:5000 -v ./data:/data ghcr.io/project-osrm/osrm-backend:v6.0.0 osrm-routed --algorithm mld --max-table-size 100000 /data/nz-latest.osrm --threads 1

# Test a route that should be possible from Segment A to a destination north of Node A
curl "http://localhost:54781/route/v1/driving/172.73786544799805,-43.53516385006154;172.7371519804001,-43.533526582257004?overview=false&alternatives=true&steps=true"
# Response: {"message":"No route found between points","code":"NoRoute"}

# Run osrm-frontend to visualise and debug
docker run -p 9966:9966 -e OSRM_BACKEND='http://localhost:54781' ghcr.io/project-osrm/osrm-frontend:latest

Location and Real World Context

I am trying to route from 351 Estuary Road, Christchurch, New Zealand 43.535075,172.735684 (lon,lat) to a random point north of it.

Image Image

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions