Skip to content

Conversation

kaligrafy
Copy link

@kaligrafy kaligrafy commented Sep 19, 2025

feat: Add configurable max_collapse_distance parameter to Lua profiles
Implements configurable max_collapse_distance parameter to address issue #6171.
This allows precise control over turn instruction collapsing in guidance,
particularly important for pedestrian routing where short crossings need
to be preserved for safety analysis.

Changes:

  • Add max_collapse_distance property to ProfileProperties with getter/setter
  • Expose parameter to Lua scripting environment for profile configuration
  • Add GetMaxCollapseDistance() method to DataFacade interface
  • Replace hardcoded MAX_COLLAPSE_DISTANCE constant with thread-local variable
  • Update guidance collapse functions to use configurable parameter
  • Add documentation and example profile demonstrating usage

The parameter defaults to 30.0 meters (preserving existing behavior) but can
now be customized in Lua profiles:

function setup()
  return {
    properties = {
      max_collapse_distance = 10.0,  -- Custom value in meters
    },
  }
end

This enables sepcific usages who requires precise
pedestrian routing instructions by preventing short road crossings from
being collapsed into longer segments.

#6171

Implements configurable max_collapse_distance parameter to address issue Project-OSRM#6171.
This allows precise control over turn instruction collapsing in guidance,
particularly important for pedestrian routing where short crossings need
to be preserved for safety analysis.

Changes:
* Add max_collapse_distance property to ProfileProperties with getter/setter
* Expose parameter to Lua scripting environment for profile configuration
* Add GetMaxCollapseDistance() method to DataFacade interface
* Replace hardcoded MAX_COLLAPSE_DISTANCE constant with thread-local variable
* Update guidance collapse functions to use configurable parameter
* Add documentation and example profile demonstrating usage

The parameter defaults to 30.0 meters (preserving existing behavior) but can
now be customized in Lua profiles:

```lua
function setup()
  return {
    properties = {
      max_collapse_distance = 10.0,  -- Custom value in meters
    },
  }
end
```

This enables sepcific usages who requires precise
pedestrian routing instructions by preventing short road crossings from
being collapsed into longer segments.

Fixes Project-OSRM#6171

Developed with the help of Claude Sonnet 4 from Anthropic AI.
@kaligrafy kaligrafy changed the title Issue6171 Issue 6171 Make MAX_COLLAPSE_DISTANCE configurable in the lua profile Oct 4, 2025
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.

1 participant