Merge branch 'develop' of https://github.com/DennisOSRM/Project-OSRM into develop
This commit is contained in:
commit
438c6e616c
16
Rakefile
16
Rakefile
@ -102,8 +102,8 @@ desc "Download OSM data."
|
|||||||
task :download => :setup do
|
task :download => :setup do
|
||||||
Dir.mkdir "#{DATA_FOLDER}" unless File.exist? "#{DATA_FOLDER}"
|
Dir.mkdir "#{DATA_FOLDER}" unless File.exist? "#{DATA_FOLDER}"
|
||||||
puts "Downloading..."
|
puts "Downloading..."
|
||||||
puts "curl http://download.geofabrik.de/openstreetmap/europe/#{osm_data_country}.osm.pbf -o #{DATA_FOLDER}/#{osm_data_country}.osm.pbf"
|
puts "curl http://download.geofabrik.de/europe/#{osm_data_country}-latest.osm.pbf -o #{DATA_FOLDER}/#{osm_data_country}.osm.pbf"
|
||||||
raise "Error while downloading data." unless system "curl http://download.geofabrik.de/openstreetmap/europe/#{osm_data_country}.osm.pbf -o #{DATA_FOLDER}/#{osm_data_country}.osm.pbf"
|
raise "Error while downloading data." unless system "curl http://download.geofabrik.de/europe/#{osm_data_country}-latest.osm.pbf -o #{DATA_FOLDER}/#{osm_data_country}.osm.pbf"
|
||||||
if osm_data_area_bbox
|
if osm_data_area_bbox
|
||||||
puts "Cropping and converting to protobuffer..."
|
puts "Cropping and converting to protobuffer..."
|
||||||
raise "Error while cropping data." unless system "osmosis --read-pbf file=#{DATA_FOLDER}/#{osm_data_country}.osm.pbf --bounding-box #{osm_data_area_bbox} --write-pbf file=#{DATA_FOLDER}/#{osm_data_area_name}.osm.pbf omitmetadata=true"
|
raise "Error while cropping data." unless system "osmosis --read-pbf file=#{DATA_FOLDER}/#{osm_data_country}.osm.pbf --bounding-box #{osm_data_area_bbox} --write-pbf file=#{DATA_FOLDER}/#{osm_data_area_name}.osm.pbf omitmetadata=true"
|
||||||
@ -120,9 +120,9 @@ end
|
|||||||
desc "Reprocess OSM data."
|
desc "Reprocess OSM data."
|
||||||
task :process => :setup do
|
task :process => :setup do
|
||||||
Dir.chdir DATA_FOLDER do
|
Dir.chdir DATA_FOLDER do
|
||||||
raise "Error while extracting data." unless system "../osrm-extract #{osm_data_area_name}.osm.pbf #{PROFILES_FOLDER}/#{PROFILE}.lua"
|
raise "Error while extracting data." unless system "../#{BUILD_FOLDER}/osrm-extract #{osm_data_area_name}.osm.pbf #{PROFILES_FOLDER}/#{PROFILE}.lua"
|
||||||
puts
|
puts
|
||||||
raise "Error while preparing data." unless system "../osrm-prepare #{osm_data_area_name}.osrm #{osm_data_area_name}.osrm.restrictions #{PROFILES_FOLDER}/#{PROFILE}.lua"
|
raise "Error while preparing data." unless system "../#{BUILD_FOLDER}/osrm-prepare #{osm_data_area_name}.osrm #{osm_data_area_name}.osrm.restrictions #{PROFILES_FOLDER}/#{PROFILE}.lua"
|
||||||
puts
|
puts
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -130,14 +130,14 @@ end
|
|||||||
desc "Extract OSM data."
|
desc "Extract OSM data."
|
||||||
task :extract => :setup do
|
task :extract => :setup do
|
||||||
Dir.chdir DATA_FOLDER do
|
Dir.chdir DATA_FOLDER do
|
||||||
raise "Error while extracting data." unless system "../osrm-extract #{osm_data_area_name}.osm.pbf ../profiles/#{PROFILE}.lua"
|
raise "Error while extracting data." unless system "../#{BUILD_FOLDER}/osrm-extract #{osm_data_area_name}.osm.pbf ../profiles/#{PROFILE}.lua"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
desc "Prepare OSM data."
|
desc "Prepare OSM data."
|
||||||
task :prepare => :setup do
|
task :prepare => :setup do
|
||||||
Dir.chdir DATA_FOLDER do
|
Dir.chdir DATA_FOLDER do
|
||||||
raise "Error while preparing data." unless system "../osrm-prepare #{osm_data_area_name}.osrm #{osm_data_area_name}.osrm.restrictions ../profiles/#{PROFILE}.lua"
|
raise "Error while preparing data." unless system "../#{BUILD_FOLDER}/osrm-prepare #{osm_data_area_name}.osrm #{osm_data_area_name}.osrm.restrictions ../profiles/#{PROFILE}.lua"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -157,7 +157,7 @@ desc "Run the routing server in the terminal. Press Ctrl-C to stop."
|
|||||||
task :run => :setup do
|
task :run => :setup do
|
||||||
Dir.chdir DATA_FOLDER do
|
Dir.chdir DATA_FOLDER do
|
||||||
write_server_ini osm_data_area_name
|
write_server_ini osm_data_area_name
|
||||||
system "../osrm-routed"
|
system "../#{BUILD_FOLDER}/osrm-routed"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -166,7 +166,7 @@ task :up => :setup do
|
|||||||
Dir.chdir DATA_FOLDER do
|
Dir.chdir DATA_FOLDER do
|
||||||
abort("Already up.") if up?
|
abort("Already up.") if up?
|
||||||
write_server_ini osm_data_area_name
|
write_server_ini osm_data_area_name
|
||||||
pipe = IO.popen('../osrm-routed 1>>osrm-routed.log 2>>osrm-routed.log')
|
pipe = IO.popen("../#{BUILD_FOLDER}/osrm-routed 1>>osrm-routed.log 2>>osrm-routed.log")
|
||||||
timeout = 5
|
timeout = 5
|
||||||
(timeout*10).times do
|
(timeout*10).times do
|
||||||
begin
|
begin
|
||||||
|
@ -41,14 +41,14 @@ Feature: Bike - Squares and other areas
|
|||||||
|
|
||||||
When I route I should get
|
When I route I should get
|
||||||
| from | to | route |
|
| from | to | route |
|
||||||
| a | b | |
|
| a | b | xa |
|
||||||
| a | d | |
|
| a | d | xa |
|
||||||
| b | c | |
|
| b | c | xa |
|
||||||
| c | b | |
|
| c | b | xa |
|
||||||
| c | d | |
|
| c | d | xa |
|
||||||
| d | c | |
|
| d | c | xa |
|
||||||
| d | a | |
|
| d | a | xa |
|
||||||
| a | d | |
|
| a | d | xa |
|
||||||
|
|
||||||
@parking
|
@parking
|
||||||
Scenario: Bike - parking areas
|
Scenario: Bike - parking areas
|
||||||
|
41
features/bicycle/ref.feature
Normal file
41
features/bicycle/ref.feature
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
@routing @bicycle @ref @name
|
||||||
|
Feature: Bike - Way ref
|
||||||
|
|
||||||
|
Background:
|
||||||
|
Given the profile "bicycle"
|
||||||
|
|
||||||
|
Scenario: Bike - Way with both name and ref
|
||||||
|
Given the node map
|
||||||
|
| a | b |
|
||||||
|
|
||||||
|
And the ways
|
||||||
|
| nodes | name | ref |
|
||||||
|
| ab | Utopia Drive | E7 |
|
||||||
|
|
||||||
|
When I route I should get
|
||||||
|
| from | to | route |
|
||||||
|
| a | b | Utopia Drive / E7 |
|
||||||
|
|
||||||
|
Scenario: Bike - Way with only ref
|
||||||
|
Given the node map
|
||||||
|
| a | b |
|
||||||
|
|
||||||
|
And the ways
|
||||||
|
| nodes | name | ref |
|
||||||
|
| ab | | E7 |
|
||||||
|
|
||||||
|
When I route I should get
|
||||||
|
| from | to | route |
|
||||||
|
| a | b | E7 |
|
||||||
|
|
||||||
|
Scenario: Bike - Way with only name
|
||||||
|
Given the node map
|
||||||
|
| a | b |
|
||||||
|
|
||||||
|
And the ways
|
||||||
|
| nodes | name |
|
||||||
|
| ab | Utopia Drive |
|
||||||
|
|
||||||
|
When I route I should get
|
||||||
|
| from | to | route |
|
||||||
|
| a | b | Utopia Drive |
|
@ -12,9 +12,13 @@ Then /^routability should be$/ do |table|
|
|||||||
['forw','backw','bothw'].each do |direction|
|
['forw','backw','bothw'].each do |direction|
|
||||||
if table.headers.include? direction
|
if table.headers.include? direction
|
||||||
if direction == 'forw' || direction == 'bothw'
|
if direction == 'forw' || direction == 'bothw'
|
||||||
response = request_route("#{ORIGIN[1]},#{ORIGIN[0]+(1+WAY_SPACING*i)*@zoom}","#{ORIGIN[1]},#{ORIGIN[0]+(3+WAY_SPACING*i)*@zoom}")
|
a = Location.new ORIGIN[0]+(1+WAY_SPACING*i)*@zoom, ORIGIN[1]
|
||||||
|
b = Location.new ORIGIN[0]+(3+WAY_SPACING*i)*@zoom, ORIGIN[1]
|
||||||
|
response = request_route [a,b]
|
||||||
elsif direction == 'backw' || direction == 'bothw'
|
elsif direction == 'backw' || direction == 'bothw'
|
||||||
response = request_route("#{ORIGIN[1]},#{ORIGIN[0]+(3+WAY_SPACING*i)*@zoom}","#{ORIGIN[1]},#{ORIGIN[0]+(1+WAY_SPACING*i)*@zoom}")
|
a = Location.new ORIGIN[0]+(3+WAY_SPACING*i)*@zoom, ORIGIN[1]
|
||||||
|
b = Location.new ORIGIN[0]+(1+WAY_SPACING*i)*@zoom, ORIGIN[1]
|
||||||
|
response = request_route [a,b]
|
||||||
end
|
end
|
||||||
want = shortcuts_hash[row[direction]] || row[direction] #expand shortcuts
|
want = shortcuts_hash[row[direction]] || row[direction] #expand shortcuts
|
||||||
got[direction] = route_status response
|
got[direction] = route_status response
|
||||||
|
@ -3,12 +3,27 @@ When /^I route I should get$/ do |table|
|
|||||||
actual = []
|
actual = []
|
||||||
OSRMLauncher.new do
|
OSRMLauncher.new do
|
||||||
table.hashes.each_with_index do |row,ri|
|
table.hashes.each_with_index do |row,ri|
|
||||||
from_node = find_node_by_name row['from']
|
waypoints = []
|
||||||
raise "*** unknown from-node '#{row['from']}" unless from_node
|
if row['from'] and row['to']
|
||||||
to_node = find_node_by_name row['to']
|
node = find_node_by_name(row['from'])
|
||||||
raise "*** unknown to-node '#{row['to']}" unless to_node
|
raise "*** unknown from-node '#{row['from']}" unless node
|
||||||
|
waypoints << node
|
||||||
|
|
||||||
got = {'from' => row['from'], 'to' => row['to'] }
|
node = find_node_by_name(row['to'])
|
||||||
|
raise "*** unknown to-node '#{row['to']}" unless node
|
||||||
|
waypoints << node
|
||||||
|
|
||||||
|
got = {'from' => row['from'], 'to' => row['to'] }
|
||||||
|
elsif row['waypoints']
|
||||||
|
row['waypoints'].split(',').each do |n|
|
||||||
|
node = find_node_by_name(n.strip)
|
||||||
|
raise "*** unknown waypoint node '#{n.strip}" unless node
|
||||||
|
waypoints << node
|
||||||
|
end
|
||||||
|
got = {'waypoints' => row['waypoints'] }
|
||||||
|
else
|
||||||
|
raise "*** no waypoints"
|
||||||
|
end
|
||||||
|
|
||||||
params = {}
|
params = {}
|
||||||
row.each_pair do |k,v|
|
row.each_pair do |k,v|
|
||||||
@ -22,7 +37,7 @@ When /^I route I should get$/ do |table|
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
response = request_route("#{from_node.lat},#{from_node.lon}", "#{to_node.lat},#{to_node.lon}", params)
|
response = request_route(waypoints, params)
|
||||||
if response.code == "200" && response.body.empty? == false
|
if response.code == "200" && response.body.empty? == false
|
||||||
json = JSON.parse response.body
|
json = JSON.parse response.body
|
||||||
if json['status'] == 0
|
if json['status'] == 0
|
||||||
|
@ -8,16 +8,15 @@ class Hash
|
|||||||
def to_param(namespace = nil)
|
def to_param(namespace = nil)
|
||||||
collect do |key, value|
|
collect do |key, value|
|
||||||
"#{key}=#{value}"
|
"#{key}=#{value}"
|
||||||
end.sort * '&'
|
end.sort
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def request_path path, params={}
|
def request_path path, waypoints=[], options={}
|
||||||
if params.any?
|
locs = waypoints.compact.map { |w| "loc=#{w.lat},#{w.lon}" }
|
||||||
uri = URI.parse ["#{HOST}/#{path}",params.to_param].join('&')
|
params = (locs + options.to_param).join('&')
|
||||||
else
|
params = nil if params==""
|
||||||
uri = URI.parse "#{HOST}/#{path}"
|
uri = URI.parse ["#{HOST}/#{path}", params].compact.join('?')
|
||||||
end
|
|
||||||
Timeout.timeout(REQUEST_TIMEOUT) do
|
Timeout.timeout(REQUEST_TIMEOUT) do
|
||||||
Net::HTTP.get_response uri
|
Net::HTTP.get_response uri
|
||||||
end
|
end
|
||||||
@ -27,9 +26,9 @@ rescue Timeout::Error
|
|||||||
raise "*** osrm-routed did not respond."
|
raise "*** osrm-routed did not respond."
|
||||||
end
|
end
|
||||||
|
|
||||||
def request_route a,b, params={}
|
def request_route waypoints, params={}
|
||||||
defaults = { 'output' => 'json', 'instructions' => true, 'alt' => true }
|
defaults = { 'output' => 'json', 'instructions' => true, 'alt' => false }
|
||||||
request_path "viaroute?loc=#{a}&loc=#{b}", defaults.merge(params)
|
request_path "viaroute", waypoints, defaults.merge(params)
|
||||||
end
|
end
|
||||||
|
|
||||||
def parse_response response
|
def parse_response response
|
||||||
|
@ -27,6 +27,7 @@ Feature: Handle bad data in a graceful manner
|
|||||||
| from | to | route |
|
| from | to | route |
|
||||||
| a | b | ab |
|
| a | b | ab |
|
||||||
|
|
||||||
|
@todo
|
||||||
Scenario: Start/end point at the same location
|
Scenario: Start/end point at the same location
|
||||||
Given the node map
|
Given the node map
|
||||||
| a | b |
|
| a | b |
|
||||||
|
52
features/testbot/via.feature
Normal file
52
features/testbot/via.feature
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
@routing @testbot @via
|
||||||
|
Feature: Via points
|
||||||
|
|
||||||
|
Background:
|
||||||
|
Given the profile "testbot"
|
||||||
|
|
||||||
|
Scenario: Simple via point
|
||||||
|
Given the node map
|
||||||
|
| a | b | c |
|
||||||
|
|
||||||
|
And the ways
|
||||||
|
| nodes |
|
||||||
|
| abc |
|
||||||
|
|
||||||
|
When I route I should get
|
||||||
|
| waypoints | route |
|
||||||
|
| a,b,c | abc |
|
||||||
|
| c,b,a | abc |
|
||||||
|
|
||||||
|
Scenario: Via point at a dead end
|
||||||
|
Given the node map
|
||||||
|
| a | b | c |
|
||||||
|
| | d | |
|
||||||
|
|
||||||
|
And the ways
|
||||||
|
| nodes |
|
||||||
|
| abc |
|
||||||
|
| bd |
|
||||||
|
|
||||||
|
When I route I should get
|
||||||
|
| waypoints | route |
|
||||||
|
| a,d,c | abc,bd,bd,abc |
|
||||||
|
| c,d,a | abc,bd,bd,abc |
|
||||||
|
|
||||||
|
Scenario: Multiple via points
|
||||||
|
Given the node map
|
||||||
|
| a | | c | | e | |
|
||||||
|
| | b | | d | | f |
|
||||||
|
|
||||||
|
And the ways
|
||||||
|
| nodes |
|
||||||
|
| ace |
|
||||||
|
| bdf |
|
||||||
|
| ab |
|
||||||
|
| bc |
|
||||||
|
| cd |
|
||||||
|
| de |
|
||||||
|
| ef |
|
||||||
|
|
||||||
|
When I route I should get
|
||||||
|
| waypoints | route |
|
||||||
|
| a,b,c,d,e,f | ab,bc,cd,de,ef |
|
@ -65,6 +65,24 @@ route_speeds = {
|
|||||||
["ferry"] = 5
|
["ferry"] = 5
|
||||||
}
|
}
|
||||||
|
|
||||||
|
surface_speeds = {
|
||||||
|
["cobblestone:flattened"] = 10,
|
||||||
|
["paving_stones"] = 10,
|
||||||
|
["compacted"] = 10,
|
||||||
|
["cobblestone"] = 6,
|
||||||
|
["unpaved"] = 6,
|
||||||
|
["fine_gravel"] = 6,
|
||||||
|
["gravel"] = 6,
|
||||||
|
["fine_gravel"] = 6,
|
||||||
|
["pebbelstone"] = 6,
|
||||||
|
["ground"] = 6,
|
||||||
|
["dirt"] = 6,
|
||||||
|
["earth"] = 6,
|
||||||
|
["grass"] = 6,
|
||||||
|
["mud"] = 3,
|
||||||
|
["sand"] = 3
|
||||||
|
}
|
||||||
|
|
||||||
take_minimum_of_speeds = true
|
take_minimum_of_speeds = true
|
||||||
obey_oneway = true
|
obey_oneway = true
|
||||||
obey_bollards = false
|
obey_bollards = false
|
||||||
@ -158,10 +176,13 @@ function way_function (way)
|
|||||||
local service = way.tags:Find("service")
|
local service = way.tags:Find("service")
|
||||||
local area = way.tags:Find("area")
|
local area = way.tags:Find("area")
|
||||||
local foot = way.tags:Find("foot")
|
local foot = way.tags:Find("foot")
|
||||||
|
local surface = way.tags:Find("surface")
|
||||||
|
|
||||||
-- name
|
-- name
|
||||||
if "" ~= ref then
|
if "" ~= ref and "" ~= name then
|
||||||
way.name = ref
|
way.name = name .. ' / ' .. ref
|
||||||
|
elseif "" ~= ref then
|
||||||
|
way.name = ref
|
||||||
elseif "" ~= name then
|
elseif "" ~= name then
|
||||||
way.name = name
|
way.name = name
|
||||||
else
|
else
|
||||||
@ -287,6 +308,15 @@ function way_function (way)
|
|||||||
way.speed = bicycle_speeds["cycleway"]
|
way.speed = bicycle_speeds["cycleway"]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- surfaces
|
||||||
|
if surface then
|
||||||
|
surface_speed = surface_speeds[surface]
|
||||||
|
if surface_speed then
|
||||||
|
way.speed = math.min(way.speed, surface_speed)
|
||||||
|
way.backward_speed = math.min(way.backward_speed, surface_speed)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
-- maxspeed
|
-- maxspeed
|
||||||
-- TODO: maxspeed of backward direction
|
-- TODO: maxspeed of backward direction
|
||||||
if take_minimum_of_speeds then
|
if take_minimum_of_speeds then
|
||||||
|
Loading…
Reference in New Issue
Block a user