Skip to content

Commit 62a0819

Browse files
committed
Set max_turn_weight as a profile property
1 parent 6e056e1 commit 62a0819

File tree

2 files changed

+7
-8
lines changed

2 files changed

+7
-8
lines changed

profiles/car.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,7 @@ function way_function(way, result)
318318
}
319319

320320
-- perform an quick initial check and abort if the way is
321-
-- obviously not routable.
321+
-- obviously not routable.
322322
-- highway or route tags must be in data table, bridge is optional
323323
if (not data.highway or data.highway == '') and
324324
(not data.route or data.route == '')
@@ -412,7 +412,7 @@ function turn_function (turn)
412412
if profile.weight_name == 'routability' then
413413
-- penalize turns from non-local access only segments onto local access only tags
414414
if not turn.source_restricted and turn.target_restricted then
415-
turn.weight = constants.max_turn_weight
415+
turn.weight = profile.max_turn_weight
416416
end
417417
end
418418
end

src/extractor/scripting_environment_lua.cpp

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -401,12 +401,6 @@ void Sol2ScriptingEnvironment::InitContext(LuaScriptingContext &context)
401401

402402
context.state.script_file(file_name);
403403

404-
405-
// set constants in 'constants' table
406-
context.state["constants"] = context.state.create_table_with(
407-
"max_turn_weight", std::numeric_limits<TurnPenalty>::max()
408-
);
409-
410404
// read properties from 'profile' table
411405
sol::optional<std::string> weight_name = context.state["profile"]["weight_name"];
412406
if( weight_name != sol::nullopt)
@@ -444,6 +438,11 @@ void Sol2ScriptingEnvironment::InitContext(LuaScriptingContext &context)
444438
if( force_split_edges != sol::nullopt)
445439
context.properties.force_split_edges = force_split_edges.value();
446440

441+
if(auto profile = context.state["profile"])
442+
{ // set computed profile properties
443+
profile["max_turn_weight"] = context.properties.GetMaxTurnWeight();
444+
}
445+
447446
sol::function turn_function = context.state["turn_function"];
448447
sol::function node_function = context.state["node_function"];
449448
sol::function way_function = context.state["way_function"];

0 commit comments

Comments
 (0)