Project-OSRM / osrm-backend

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

Question: Is there any reasons to handle restriction in C++ instead of in profile (lua) #5763

Closed hellotechx closed 1 month ago

hellotechx commented 4 years ago

Hi there, I am working on non-osm data by using OSRM engine recently. Since the format/keywords of restrictions are different with osm data, I am trying to modify the code/profile to fit into the engine.

In extractor/scripting_environment_lua.cpp

void Sol2ScriptingEnvironment::ProcessElements(...) {
case osmium::item_type::node:
        {
               ...
               local_context.ProcessNode(node, result_node, relations);
               ...
        }
        break;
        case osmium::item_type::way:
        {
                ...
                local_context.ProcessWay(way, result_way, relations);
                ...
        }
        break;
        case osmium::item_type::relation:
        {
            ...
            if (auto result_res = restriction_parser.TryParse(relation))
            {
                resulting_restrictions.push_back(*result_res);
            }
            ...
        }
}

ProcessWay and ProcessNode to be addressed by calling Lua script, it's easy to modify non-osm data to fit into the engine. But for restrictions, it's handled in C++ in TryParse.

My question is, is there any reasons/advantages/thoughts that we use different methods to handle restrictions? Why not to deal with it in Lua script similar with ProcessWay?

Thanks so much for your help.

github-actions[bot] commented 3 months ago

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