diff --git a/extractor/extractor.cpp b/extractor/extractor.cpp index 87cfb4d88..b1978c9d8 100644 --- a/extractor/extractor.cpp +++ b/extractor/extractor.cpp @@ -436,7 +436,7 @@ void extractor::FindComponents(unsigned max_edge_id, component_search.get_component_id(node.reverse_edge_based_node_id)); const unsigned component_size = component_search.get_component_size(forward_component); - node.component.is_tiny = component_size < 1000; + node.component.is_tiny = component_size < config.small_component_size; node.component.id = 1 + forward_component; } } diff --git a/extractor/extractor_options.cpp b/extractor/extractor_options.cpp index f15f64409..b607dca95 100644 --- a/extractor/extractor_options.cpp +++ b/extractor/extractor_options.cpp @@ -64,7 +64,11 @@ ExtractorOptions::ParseArguments(int argc, char *argv[], ExtractorConfig &extrac "Number of threads to use")( "generate-edge-lookup",boost::program_options::value( &extractor_config.generate_edge_lookup)->implicit_value(true)->default_value(false), - "Generate a lookup table for internal edge-expanded-edge IDs to OSM node pairs"); + "Generate a lookup table for internal edge-expanded-edge IDs to OSM node pairs")( + "small-component-size", + boost::program_options::value(&extractor_config.small_component_size) + ->default_value(1000), + "Number of nodes required before a strongly-connected-componennt is considered big (affects nearest neighbor snapping)"); #ifdef DEBUG_GEOMETRY config_options.add_options()("debug-turns", diff --git a/extractor/extractor_options.hpp b/extractor/extractor_options.hpp index 905430513..00d6f84b8 100644 --- a/extractor/extractor_options.hpp +++ b/extractor/extractor_options.hpp @@ -58,6 +58,7 @@ struct ExtractorConfig std::string rtree_leafs_output_path; unsigned requested_num_threads; + unsigned small_component_size; bool generate_edge_lookup; std::string edge_penalty_path; diff --git a/features/step_definitions/data.rb b/features/step_definitions/data.rb index 13ed209bc..3e4ccc91c 100644 --- a/features/step_definitions/data.rb +++ b/features/step_definitions/data.rb @@ -6,6 +6,10 @@ Given(/^the import format "(.*?)"$/) do |format| set_input_format format end +Given /^the extract extra arguments "(.*?)"$/ do |args| + set_extract_args args +end + Given /^a grid size of (\d+) meters$/ do |meters| set_grid_size meters end diff --git a/features/support/config.rb b/features/support/config.rb index e61c9fc74..434b4ec9b 100644 --- a/features/support/config.rb +++ b/features/support/config.rb @@ -10,3 +10,7 @@ end def set_profile profile @profile = profile end + +def set_extract_args args + @extract_args = args +end diff --git a/features/support/data.rb b/features/support/data.rb index 253fe6044..62ed7d370 100644 --- a/features/support/data.rb +++ b/features/support/data.rb @@ -274,7 +274,7 @@ def extract_data Dir.chdir TEST_FOLDER do log_preprocess_info log "== Extracting #{osm_file}.osm...", :preprocess - unless system "#{BIN_PATH}/osrm-extract #{osm_file}.osm#{'.pbf' if pbf?} --profile #{PROFILES_PATH}/#{@profile}.lua >>#{PREPROCESS_LOG_FILE} 2>&1" + unless system "#{BIN_PATH}/osrm-extract #{osm_file}.osm#{'.pbf' if pbf?} #{@extract_args} --profile #{PROFILES_PATH}/#{@profile}.lua >>#{PREPROCESS_LOG_FILE} 2>&1" log "*** Exited with code #{$?.exitstatus}.", :preprocess raise ExtractError.new $?.exitstatus, "osrm-extract exited with code #{$?.exitstatus}." end diff --git a/features/testbot/distance_matrix.feature b/features/testbot/distance_matrix.feature index 9875056b7..4f5d5d120 100644 --- a/features/testbot/distance_matrix.feature +++ b/features/testbot/distance_matrix.feature @@ -135,3 +135,30 @@ Feature: Basic Distance Matrix | | b | e | f | | a | 100 | 200 | 300 | | b | 0 | 100 | 200 | + + # There is a 1100m limit when searching for nearest neighbours + # so we set the grid size to something that makes it easy to + # put nodes inside/outside that limit + Scenario: Testbog - Check snapping on on small components + Given a grid size of 300 meters + Given the extract extra arguments "--small-component-size 4" + Given the node map + | a | b | | | m | | x | + | d | e | | | n | | y | + + And the ways + | nodes | + | ab | + | be | + | ed | + | da | + | xy | + + When I request a travel time matrix I should get + | | a | b | x | y | m | n | + | a | 0 | 300 | | | 300 | 600 | + | b | 300 | 0 | | | 0 | 300 | + | x | | | 0 | 300 | | | + | y | | | 300 | 0 | | | + | m | 300 | 0 | | | 0 | 300 | + | n | 600 | 300 | | | 300 | 0 |