Project-OSRM / osrm-backend

Open Source Routing Machine - C++ backend
http://map.project-osrm.org
BSD 2-Clause "Simplified" License
6.26k stars 3.31k forks source link

Profile inheritence #6154

Closed giladmaya closed 2 weeks ago

giladmaya commented 2 years ago

I want to create a new profile which is based on the existing car profile from the repo, but with some alterations, e.g. allowing access in psv edges. Currently, my solution is to apply my adjustments directly on the the car.profile. This solution is hard to maintain, since it requires manual intervention when I want to upgrade osrm.

Is there a way to create a new profile that inherits from another profile without overriding the original profile file?

mjjbell commented 2 years ago

You can create a profile that uses the functions exported by the car profile, create your own functions for the specific alterations, and then use that during osrm-extract

E.g.

Car = require('car')

function process_turn_with_alterations(profile, turn) 
    Car.process_turn(profile, turn)
    ---
    -- Your alterations
    --
end

return {
  setup = Car.setup,
  process_way = Car.process_way,
  process_node = Car.process_node,
  process_turn = process_turn_with_alterations
}
github-actions[bot] commented 1 month ago

This issue seems to be stale. It will be closed in 30 days if no further activity occurs.