Skip to content

Commit

Permalink
Add flag to allow skipping calling node function for nodes with no tags.
Browse files Browse the repository at this point in the history
  • Loading branch information
danpat committed Jun 12, 2017
1 parent 9e6a226 commit 8d91351
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
4 changes: 3 additions & 1 deletion include/extractor/profile_properties.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ struct ProfileProperties
: traffic_signal_penalty(0), u_turn_penalty(0),
max_speed_for_map_matching(DEFAULT_MAX_SPEED), continue_straight_at_waypoint(true),
use_turn_restrictions(false), left_hand_driving(false), fallback_to_duration(true),
weight_name{"duration"}
weight_name{"duration"}, call_tagless_node_function(true)
{
BOOST_ASSERT(weight_name[MAX_WEIGHT_NAME_LENGTH] == '\0');
}
Expand Down Expand Up @@ -88,6 +88,8 @@ struct ProfileProperties
char weight_name[MAX_WEIGHT_NAME_LENGTH + 1];
unsigned weight_precision = 1;
bool force_split_edges = false;

bool call_tagless_node_function = true;
};
}
}
Expand Down
6 changes: 6 additions & 0 deletions profiles/car.lua
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@ properties.weight_name = 'routability'
-- For shortest distance without penalties for accessibility
--properties.weight_name = 'distance'

-- Set to true if you need to call the node_function for every node.
-- Generally can be left as false to avoid unnecessary Lua calls
-- (which slow down pre-processing).
properties.call_tagless_node_function = false


local profile = {
default_mode = mode.driving,
default_speed = 10,
Expand Down
8 changes: 6 additions & 2 deletions src/extractor/scripting_environment_lua.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,9 @@ void Sol2ScriptingEnvironment::InitContext(LuaScriptingContext &context)
"max_turn_weight",
sol::property(&ProfileProperties::GetMaxTurnWeight),
"force_split_edges",
&ProfileProperties::force_split_edges);
&ProfileProperties::force_split_edges,
"call_tagless_node_function",
&ProfileProperties::call_tagless_node_function);

context.state.new_usertype<std::vector<std::string>>(
"vector",
Expand Down Expand Up @@ -510,7 +512,9 @@ void Sol2ScriptingEnvironment::ProcessElements(
{
case osmium::item_type::node:
result_node.clear();
if (local_context.has_node_function)
if (local_context.has_node_function &&
(!static_cast<const osmium::Node &>(*entity).tags().empty() ||
local_context.properties.call_tagless_node_function))
{
local_context.ProcessNode(static_cast<const osmium::Node &>(*entity),
result_node);
Expand Down

0 comments on commit 8d91351

Please sign in to comment.