Make forward/reverse weight/offset calculated at query time,

rather than being cached in the StaticRTree.  This means we
can freely apply traffic data and not have stale values lying
around.  It reduces the size of the RTree on disk, at the expense
of some additional data in RAM.
This commit is contained in:
Daniel Patterson
2016-01-29 17:52:20 -08:00
parent 03d360b7bf
commit 49441fe204
24 changed files with 760 additions and 175 deletions
+47
View File
@@ -0,0 +1,47 @@
@routing @speed @traffic
Feature: Traffic - speeds
Background: Use specific speeds
Given the node locations
| node | lat | lon |
| a | 0.1 | 0.1 |
| b | .05 | 0.1 |
| c | 0.0 | 0.1 |
| d | .05 | .03 |
| e | .05 | .066 |
| f | .075 | .066 |
| g | .075 | 0.1 |
And the ways
| nodes | highway |
| ab | primary |
| ad | primary |
| bc | primary |
| dc | primary |
| de | primary |
| eb | primary |
| df | primary |
| fb | primary |
And the speed file
"""
1,2,27
2,1,27
2,3,27
3,2,27
1,4,27
4,1,27
"""
Scenario: Weighting not based on raster sources
Given the profile "testbot"
Given the extract extra arguments "--generate-edge-lookup"
Given the prepare extra arguments "--segment-speed-file speeds.csv"
And I route I should get
| from | to | route | speed |
| a | b | ab | 27 km/h |
| a | c | ab,bc | 27 km/h |
| b | c | bc | 27 km/h |
| a | d | ad | 27 km/h |
| d | c | dc | 36 km/h |
| g | b | ab | 27 km/h |
| a | g | ab | 27 km/h |
+10
View File
@@ -10,6 +10,10 @@ Given /^the extract extra arguments "(.*?)"$/ do |args|
set_extract_args args
end
Given /^the prepare extra arguments "(.*?)"$/ do |args|
set_prepare_args args
end
Given /^a grid size of (\d+) meters$/ do |meters|
set_grid_size meters
end
@@ -146,6 +150,12 @@ Given /^the raster source$/ do |data|
end
end
Given /^the speed file$/ do |data|
Dir.chdir TEST_FOLDER do
File.open("speeds.csv", "w") {|f| f.write(data)}
end
end
Given /^the data has been saved to disk$/ do
begin
write_input_data
+4
View File
@@ -14,3 +14,7 @@ end
def set_extract_args args
@extract_args = args
end
def set_prepare_args args
@prepare_args = args
end
+13 -1
View File
@@ -258,6 +258,7 @@ def extract_data
Dir.chdir TEST_FOLDER do
log_preprocess_info
log "== Extracting #{osm_file}.osm...", :preprocess
log "#{LOAD_LIBRARIES}#{BIN_PATH}/osrm-extract #{osm_file}.osm #{@extract_args} --profile #{PROFILES_PATH}/#{@profile}.lua >>#{PREPROCESS_LOG_FILE} 2>&1"
unless system "#{LOAD_LIBRARIES}#{BIN_PATH}/osrm-extract #{osm_file}.osm #{@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}."
@@ -270,6 +271,16 @@ def extract_data
rescue Exception => e
raise FileError.new nil, "failed to rename data file after extracting."
end
begin
["osrm.edge_segment_lookup","osrm.edge_penalties"].each do |file|
if File.exists?("#{osm_file}.#{file}")
log "Renaming #{osm_file}.#{file} to #{extracted_file}.#{file}", :preprocess
File.rename "#{osm_file}.#{file}", "#{extracted_file}.#{file}"
end
end
rescue Exception => e
raise FileError.new nil, "failed to rename data file after extracting."
end
end
end
@@ -277,7 +288,8 @@ def prepare_data
Dir.chdir TEST_FOLDER do
log_preprocess_info
log "== Preparing #{extracted_file}.osm...", :preprocess
unless system "#{LOAD_LIBRARIES}#{BIN_PATH}/osrm-contract #{extracted_file}.osrm >>#{PREPROCESS_LOG_FILE} 2>&1"
log "#{LOAD_LIBRARIES}#{BIN_PATH}/osrm-contract #{@prepare_args} #{extracted_file}.osrm >>#{PREPROCESS_LOG_FILE} 2>&1"
unless system "#{LOAD_LIBRARIES}#{BIN_PATH}/osrm-contract #{@prepare_args} #{extracted_file}.osrm >>#{PREPROCESS_LOG_FILE} 2>&1"
log "*** Exited with code #{$?.exitstatus}.", :preprocess
raise PrepareError.new $?.exitstatus, "osrm-contract exited with code #{$?.exitstatus}."
end