support lua require()
This commit is contained in:
@@ -13,7 +13,7 @@ OSM_TIMESTAMP = '2000-00-00T00:00:00Z'
|
||||
DEFAULT_SPEEDPROFILE = 'bicycle'
|
||||
WAY_SPACING = 100
|
||||
DEFAULT_GRID_SIZE = 100 #meters
|
||||
|
||||
PROFILES_PATH = '../profiles'
|
||||
|
||||
ORIGIN = [1,1]
|
||||
|
||||
@@ -205,7 +205,7 @@ def reprocess
|
||||
unless extracted?
|
||||
log_preprocess_info
|
||||
log "== Extracting #{@osm_file}.osm...", :preprocess
|
||||
unless system "../osrm-extract #{@osm_file}.osm.pbf 1>>#{PREPROCESS_LOG_FILE} 2>>#{PREPROCESS_LOG_FILE} ../profiles/#{@profile}.lua"
|
||||
unless system "../osrm-extract #{@osm_file}.osm.pbf 1>>#{PREPROCESS_LOG_FILE} 2>>#{PREPROCESS_LOG_FILE} #{PROFILES_PATH}/#{@profile}.lua"
|
||||
log "*** Exited with code #{$?.exitstatus}.", :preprocess
|
||||
raise ExtractError.new $?.exitstatus, "osrm-extract exited with code #{$?.exitstatus}."
|
||||
end
|
||||
@@ -214,7 +214,7 @@ def reprocess
|
||||
unless prepared?
|
||||
log_preprocess_info
|
||||
log "== Preparing #{@osm_file}.osm...", :preprocess
|
||||
unless system "../osrm-prepare #{@osm_file}.osrm #{@osm_file}.osrm.restrictions 1>>#{PREPROCESS_LOG_FILE} 2>>#{PREPROCESS_LOG_FILE} ../profiles/#{@profile}.lua"
|
||||
unless system "../osrm-prepare #{@osm_file}.osrm #{@osm_file}.osrm.restrictions 1>>#{PREPROCESS_LOG_FILE} 2>>#{PREPROCESS_LOG_FILE} #{PROFILES_PATH}/#{@profile}.lua"
|
||||
log "*** Exited with code #{$?.exitstatus}.", :preprocess
|
||||
raise PrepareError.new $?.exitstatus, "osrm-prepare exited with code #{$?.exitstatus}."
|
||||
end
|
||||
|
||||
+18
-10
@@ -1,39 +1,47 @@
|
||||
require 'digest/sha1'
|
||||
|
||||
def hash_of_file path
|
||||
def hash_of_files paths
|
||||
paths = [paths] unless paths.is_a? Array
|
||||
hash = Digest::SHA1.new
|
||||
open(path,'r') do |io|
|
||||
while !io.eof
|
||||
buf = io.readpartial 1024
|
||||
hash.update buf
|
||||
for path in paths do
|
||||
open(path,'r') do |io|
|
||||
while !io.eof
|
||||
buf = io.readpartial 1024
|
||||
hash.update buf
|
||||
end
|
||||
end
|
||||
end
|
||||
return hash.hexdigest
|
||||
end
|
||||
|
||||
|
||||
def profile_hash
|
||||
@@profile_hashes ||= {}
|
||||
@@profile_hashes[@profile] ||= hash_of_file "../profiles/#{@profile}.lua"
|
||||
@@profile_hashes[@profile] ||= hash_of_files "#{PROFILES_PATH}/#{@profile}.lua"
|
||||
end
|
||||
|
||||
def osm_hash
|
||||
@osm_hash ||= Digest::SHA1.hexdigest osm_str
|
||||
end
|
||||
|
||||
def lua_lib_hash
|
||||
@lua_lib_hash ||= hash_of_files Dir.glob("../profiles/lib/*.lua")
|
||||
end
|
||||
|
||||
def bin_extract_hash
|
||||
@@bin_extract_hash ||= hash_of_file '../osrm-extract'
|
||||
@@bin_extract_hash ||= hash_of_files '../osrm-extract'
|
||||
end
|
||||
|
||||
def bin_prepare_hash
|
||||
@@bin_prepare_hash ||= hash_of_file '../osrm-prepare'
|
||||
@@bin_prepare_hash ||= hash_of_files '../osrm-prepare'
|
||||
end
|
||||
|
||||
def bin_routed_hash
|
||||
@@bin_routed_hash ||= hash_of_file '../osrm-routed'
|
||||
@@bin_routed_hash ||= hash_of_files '../osrm-routed'
|
||||
end
|
||||
|
||||
#combine state of data, profile and binaries into a hash that identifies the exact test scenario
|
||||
def fingerprint
|
||||
@fingerprint ||= Digest::SHA1.hexdigest "#{bin_extract_hash}-#{bin_prepare_hash}-#{bin_routed_hash}-#{profile_hash}-#{osm_hash}"
|
||||
@fingerprint ||= Digest::SHA1.hexdigest "#{bin_extract_hash}-#{bin_prepare_hash}-#{bin_routed_hash}-#{profile_hash}-#{lua_lib_hash}-#{osm_hash}"
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user