Merge branch 'develop' of https://DennisOSRM@github.com/DennisOSRM/Project-OSRM.git into develop
This commit is contained in:
commit
9b4e31c5ea
@ -39,7 +39,7 @@ When /^I preprocess data$/ do
|
|||||||
end
|
end
|
||||||
|
|
||||||
Then /^"([^"]*)" should return code (\d+)$/ do |binary, code|
|
Then /^"([^"]*)" should return code (\d+)$/ do |binary, code|
|
||||||
@process_error.class.should == OSRMError
|
@process_error.is_a?(OSRMError).should == true
|
||||||
@process_error.process.should == binary
|
@process_error.process.should == binary
|
||||||
@process_error.code.to_i.should == code.to_i
|
@process_error.code.to_i.should == code.to_i
|
||||||
end
|
end
|
||||||
|
@ -177,7 +177,7 @@ def convert_osm_to_pbf
|
|||||||
log_preprocess_info
|
log_preprocess_info
|
||||||
log "== Converting #{@osm_file}.osm to protobuffer format...", :preprocess
|
log "== Converting #{@osm_file}.osm to protobuffer format...", :preprocess
|
||||||
unless system "osmosis --read-xml #{@osm_file}.osm --write-pbf #{@osm_file}.osm.pbf omitmetadata=true 1>>#{PREPROCESS_LOG_FILE} 2>>#{PREPROCESS_LOG_FILE}"
|
unless system "osmosis --read-xml #{@osm_file}.osm --write-pbf #{@osm_file}.osm.pbf omitmetadata=true 1>>#{PREPROCESS_LOG_FILE} 2>>#{PREPROCESS_LOG_FILE}"
|
||||||
raise "Failed to convert to proto buffer format. Please see #{hash}.log for more info."
|
raise OsmosisError.new $?, "osmosis exited with code #{$?.exitstatus}"
|
||||||
end
|
end
|
||||||
log '', :preprocess
|
log '', :preprocess
|
||||||
end
|
end
|
||||||
@ -197,28 +197,17 @@ def write_timestamp
|
|||||||
File.open( "#{@osm_file}.osrm.timestamp", 'w') {|f| f.write(OSM_TIMESTAMP) }
|
File.open( "#{@osm_file}.osrm.timestamp", 'w') {|f| f.write(OSM_TIMESTAMP) }
|
||||||
end
|
end
|
||||||
|
|
||||||
def log_tail path, n
|
|
||||||
File.open(path) do |f|
|
|
||||||
return f.tail(n).map { |line| " #{line}" }.join "\n"
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def reprocess
|
def reprocess
|
||||||
Dir.chdir TEST_FOLDER do
|
Dir.chdir TEST_FOLDER do
|
||||||
write_osm
|
write_osm
|
||||||
write_timestamp
|
write_timestamp
|
||||||
convert_osm_to_pbf
|
convert_osm_to_pbf
|
||||||
|
|
||||||
log_path = 'preprocessing.log'
|
|
||||||
log_lines = 3
|
|
||||||
|
|
||||||
unless extracted?
|
unless extracted?
|
||||||
log_preprocess_info
|
log_preprocess_info
|
||||||
log "== Extracting #{@osm_file}.osm...", :preprocess
|
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/#{@profile}.lua"
|
||||||
log "*** Exited with code #{$?.exitstatus}.", :preprocess
|
log "*** Exited with code #{$?.exitstatus}.", :preprocess
|
||||||
tail = log_tail log_path,log_lines
|
raise ExtractError.new $?.exitstatus, "osrm-extract exited with code #{$?.exitstatus}."
|
||||||
raise OSRMError.new 'osrm-extract', $?.exitstatus, "*** osrm-extract exited with code #{$?.exitstatus}. Last #{log_lines} lines from #{log_path}:\n#{tail}\n"
|
|
||||||
end
|
end
|
||||||
log '', :preprocess
|
log '', :preprocess
|
||||||
end
|
end
|
||||||
@ -227,8 +216,7 @@ def reprocess
|
|||||||
log "== Preparing #{@osm_file}.osm...", :preprocess
|
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/#{@profile}.lua"
|
||||||
log "*** Exited with code #{$?.exitstatus}.", :preprocess
|
log "*** Exited with code #{$?.exitstatus}.", :preprocess
|
||||||
tail = log_tail log_path,log_lines
|
raise PrepareError.new $?.exitstatus, "osrm-prepare exited with code #{$?.exitstatus}."
|
||||||
raise OSRMError.new 'osrm-prepare', $?.exitstatus, "*** osrm-prepare exited with code #{$?.exitstatus}. Last #{log_lines} lines from #{log_path}:\n#{tail}\n"
|
|
||||||
end
|
end
|
||||||
log '', :preprocess
|
log '', :preprocess
|
||||||
end
|
end
|
||||||
|
@ -1,14 +1,49 @@
|
|||||||
|
|
||||||
class OSRMError < StandardError
|
class OSRMError < StandardError
|
||||||
attr_accessor :process, :code, :msg
|
attr_accessor :msg, :code, :process
|
||||||
|
|
||||||
def initialize process, code, msg
|
def initialize process, code, msg, log, lines
|
||||||
@process = process
|
@process = process
|
||||||
@code = code
|
@code = code
|
||||||
@msg = msg
|
@msg = msg
|
||||||
|
@lines = lines
|
||||||
|
@log = log
|
||||||
|
@extract = log_tail @log, @lines
|
||||||
end
|
end
|
||||||
|
|
||||||
def to_s
|
def to_s
|
||||||
@msg
|
"*** #{@msg}\nLast #{@lines} lines from #{@log}:\n#{@extract}\n"
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def log_tail path, n
|
||||||
|
File.open(path) do |f|
|
||||||
|
return f.tail(n).map { |line| " > #{line}" }.join "\n"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
class OsmosisError < OSRMError
|
||||||
|
def initialize code, msg
|
||||||
|
super 'osmosis', code, msg, PREPROCESS_LOG_FILE, 40
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
class ExtractError < OSRMError
|
||||||
|
def initialize code, msg
|
||||||
|
super 'osrm-extract', code, msg, PREPROCESS_LOG_FILE, 3
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
class PrepareError < OSRMError
|
||||||
|
def initialize code, msg
|
||||||
|
super 'osrm-prepare', code, msg, PREPROCESS_LOG_FILE, 3
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
class RoutedError < OSRMError
|
||||||
|
def initialize msg
|
||||||
|
super 'osrm-routed', nil, msg, OSRM_ROUTED_LOG_FILE, 3
|
||||||
|
end
|
||||||
|
end
|
||||||
|
@ -3,6 +3,7 @@ require 'open3'
|
|||||||
|
|
||||||
LAUNCH_TIMEOUT = 2
|
LAUNCH_TIMEOUT = 2
|
||||||
SHUTDOWN_TIMEOUT = 2
|
SHUTDOWN_TIMEOUT = 2
|
||||||
|
OSRM_ROUTED_LOG_FILE = 'osrm-routed.log'
|
||||||
|
|
||||||
class OSRMLauncher
|
class OSRMLauncher
|
||||||
def initialize &block
|
def initialize &block
|
||||||
@ -24,7 +25,7 @@ class OSRMLauncher
|
|||||||
wait_for_connection
|
wait_for_connection
|
||||||
end
|
end
|
||||||
rescue Timeout::Error
|
rescue Timeout::Error
|
||||||
raise "*** Launching osrm-routed timed out."
|
raise RoutedError.new "Launching osrm-routed timed out."
|
||||||
end
|
end
|
||||||
|
|
||||||
def shutdown
|
def shutdown
|
||||||
@ -33,7 +34,7 @@ class OSRMLauncher
|
|||||||
end
|
end
|
||||||
rescue Timeout::Error
|
rescue Timeout::Error
|
||||||
kill
|
kill
|
||||||
raise "*** Shutting down osrm-routed timed out."
|
raise RoutedError.new "Shutting down osrm-routed timed out."
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
@ -47,7 +48,7 @@ class OSRMLauncher
|
|||||||
|
|
||||||
def osrm_up
|
def osrm_up
|
||||||
return if osrm_up?
|
return if osrm_up?
|
||||||
@pid = Process.spawn(['../osrm-routed',''],:out=>'osrm-routed.log', :err=>'osrm-routed.log')
|
@pid = Process.spawn(['../osrm-routed',''],:out=>OSRM_ROUTED_LOG_FILE, :err=>OSRM_ROUTED_LOG_FILE)
|
||||||
end
|
end
|
||||||
|
|
||||||
def osrm_down
|
def osrm_down
|
||||||
|
@ -7,7 +7,6 @@ DESTINATION_REACHED = 15 #OSRM instruction code
|
|||||||
|
|
||||||
def request_path path
|
def request_path path
|
||||||
@query = path
|
@query = path
|
||||||
log path
|
|
||||||
uri = URI.parse "#{HOST}/#{path}"
|
uri = URI.parse "#{HOST}/#{path}"
|
||||||
Timeout.timeout(REQUEST_TIMEOUT) do
|
Timeout.timeout(REQUEST_TIMEOUT) do
|
||||||
Net::HTTP.get_response uri
|
Net::HTTP.get_response uri
|
||||||
|
Loading…
Reference in New Issue
Block a user