Add flag to allow skipping calling node function for nodes with no tags.

This commit is contained in:
Daniel Patterson 2017-06-12 23:46:29 +02:00 committed by Patrick Niklaus
parent 5c8e2b6f78
commit cd8fb82215
9 changed files with 41 additions and 3 deletions

View File

@ -12,6 +12,7 @@
- Features
- Added conditional restriction support with `parse-conditional-restrictions=true|false` to osrm-extract. This option saves conditional turn restrictions to the .restrictions file for parsing by contract later. Added `parse-conditionals-from-now=utc time stamp` and `--time-zone-file=/path/to/file` to osrm-contract
- Command-line tools (osrm-extract, osrm-contract, osrm-routed, etc) now return error codes and legible error messages for common problem scenarios, rather than ugly C++ crashes
- Speed up pre-processing by only running the Lua `node_function` for nodes that have tags. Cuts OSM file parsing time in half.
- Files
- .osrm.nodes file was renamed to .nbg_nodes and .ebg_nodes was added
- Guidance

View File

@ -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');
}
@ -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;
};
}
}

View File

@ -15,6 +15,11 @@ properties.continue_straight_at_waypoint = false
properties.weight_name = 'duration'
--properties.weight_name = 'cyclability'
-- 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 default_speed = 15
local walking_speed = 6

View File

@ -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,

View File

@ -14,6 +14,11 @@ properties.continue_straight_at_waypoint = false
properties.weight_name = 'duration'
--properties.weight_name = 'routability'
-- 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 walking_speed = 5
local profile = {

View File

@ -3,6 +3,11 @@ api_version = 1
properties.force_split_edges = true
-- 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
-- Minimalist node_ and way_functions in order to test source_ and segment_functions
function node_function (node, result)

View File

@ -1,6 +1,11 @@
api_version = 1
-- Rasterbot profile
-- 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
-- Minimalist node_ and way_functions in order to test source_ and segment_functions
function node_function (node, result)

View File

@ -22,6 +22,11 @@ properties.use_turn_restrictions = true
properties.max_speed_for_map_matching = 30/3.6 --km -> m/s
properties.weight_name = 'duration'
-- 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 uturn_penalty = 20
local traffic_light_penalty = 7 -- seconds

View File

@ -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",
@ -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);