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
|
||||
Dir.mkdir "#{DATA_FOLDER}" unless File.exist? "#{DATA_FOLDER}"
|
||||
puts "Downloading..."
|
||||
puts "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/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/europe/#{osm_data_country}-latest.osm.pbf -o #{DATA_FOLDER}/#{osm_data_country}.osm.pbf"
|
||||
if osm_data_area_bbox
|
||||
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"
|
||||
@ -120,9 +120,9 @@ end
|
||||
desc "Reprocess OSM data."
|
||||
task :process => :setup 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
|
||||
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
|
||||
end
|
||||
end
|
||||
@ -130,14 +130,14 @@ end
|
||||
desc "Extract OSM data."
|
||||
task :extract => :setup 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
|
||||
|
||||
desc "Prepare OSM data."
|
||||
task :prepare => :setup 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
|
||||
|
||||
@ -157,7 +157,7 @@ desc "Run the routing server in the terminal. Press Ctrl-C to stop."
|
||||
task :run => :setup do
|
||||
Dir.chdir DATA_FOLDER do
|
||||
write_server_ini osm_data_area_name
|
||||
system "../osrm-routed"
|
||||
system "../#{BUILD_FOLDER}/osrm-routed"
|
||||
end
|
||||
end
|
||||
|
||||
@ -166,7 +166,7 @@ task :up => :setup do
|
||||
Dir.chdir DATA_FOLDER do
|
||||
abort("Already up.") if up?
|
||||
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*10).times do
|
||||
begin
|
||||
|
@ -41,14 +41,14 @@ Feature: Bike - Squares and other areas
|
||||
|
||||
When I route I should get
|
||||
| from | to | route |
|
||||
| a | b | |
|
||||
| a | d | |
|
||||
| b | c | |
|
||||
| c | b | |
|
||||
| c | d | |
|
||||
| d | c | |
|
||||
| d | a | |
|
||||
| a | d | |
|
||||
| a | b | xa |
|
||||
| a | d | xa |
|
||||
| b | c | xa |
|
||||
| c | b | xa |
|
||||
| c | d | xa |
|
||||
| d | c | xa |
|
||||
| d | a | xa |
|
||||
| a | d | xa |
|
||||
|
||||
@parking
|
||||
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|
|
||||
if table.headers.include? direction
|
||||
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'
|
||||
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
|
||||
want = shortcuts_hash[row[direction]] || row[direction] #expand shortcuts
|
||||
got[direction] = route_status response
|
||||
|
@ -3,13 +3,28 @@ When /^I route I should get$/ do |table|
|
||||
actual = []
|
||||
OSRMLauncher.new do
|
||||
table.hashes.each_with_index do |row,ri|
|
||||
from_node = find_node_by_name row['from']
|
||||
raise "*** unknown from-node '#{row['from']}" unless from_node
|
||||
to_node = find_node_by_name row['to']
|
||||
raise "*** unknown to-node '#{row['to']}" unless to_node
|
||||
|
||||
got = {'from' => row['from'], 'to' => row['to'] }
|
||||
|
||||
waypoints = []
|
||||
if row['from'] and row['to']
|
||||
node = find_node_by_name(row['from'])
|
||||
raise "*** unknown from-node '#{row['from']}" unless node
|
||||
waypoints << node
|
||||
|
||||
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 = {}
|
||||
row.each_pair do |k,v|
|
||||
if k =~ /param:(.*)/
|
||||
@ -22,7 +37,7 @@ When /^I route I should get$/ do |table|
|
||||
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
|
||||
json = JSON.parse response.body
|
||||
if json['status'] == 0
|
||||
|
@ -8,16 +8,15 @@ class Hash
|
||||
def to_param(namespace = nil)
|
||||
collect do |key, value|
|
||||
"#{key}=#{value}"
|
||||
end.sort * '&'
|
||||
end.sort
|
||||
end
|
||||
end
|
||||
|
||||
def request_path path, params={}
|
||||
if params.any?
|
||||
uri = URI.parse ["#{HOST}/#{path}",params.to_param].join('&')
|
||||
else
|
||||
uri = URI.parse "#{HOST}/#{path}"
|
||||
end
|
||||
def request_path path, waypoints=[], options={}
|
||||
locs = waypoints.compact.map { |w| "loc=#{w.lat},#{w.lon}" }
|
||||
params = (locs + options.to_param).join('&')
|
||||
params = nil if params==""
|
||||
uri = URI.parse ["#{HOST}/#{path}", params].compact.join('?')
|
||||
Timeout.timeout(REQUEST_TIMEOUT) do
|
||||
Net::HTTP.get_response uri
|
||||
end
|
||||
@ -27,9 +26,9 @@ rescue Timeout::Error
|
||||
raise "*** osrm-routed did not respond."
|
||||
end
|
||||
|
||||
def request_route a,b, params={}
|
||||
defaults = { 'output' => 'json', 'instructions' => true, 'alt' => true }
|
||||
request_path "viaroute?loc=#{a}&loc=#{b}", defaults.merge(params)
|
||||
def request_route waypoints, params={}
|
||||
defaults = { 'output' => 'json', 'instructions' => true, 'alt' => false }
|
||||
request_path "viaroute", waypoints, defaults.merge(params)
|
||||
end
|
||||
|
||||
def parse_response response
|
||||
|
@ -26,7 +26,8 @@ Feature: Handle bad data in a graceful manner
|
||||
When I route I should get
|
||||
| from | to | route |
|
||||
| a | b | ab |
|
||||
|
||||
|
||||
@todo
|
||||
Scenario: Start/end point at the same location
|
||||
Given the node map
|
||||
| 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
|
||||
}
|
||||
|
||||
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
|
||||
obey_oneway = true
|
||||
obey_bollards = false
|
||||
@ -158,10 +176,13 @@ function way_function (way)
|
||||
local service = way.tags:Find("service")
|
||||
local area = way.tags:Find("area")
|
||||
local foot = way.tags:Find("foot")
|
||||
local surface = way.tags:Find("surface")
|
||||
|
||||
-- name
|
||||
if "" ~= ref then
|
||||
way.name = ref
|
||||
if "" ~= ref and "" ~= name then
|
||||
way.name = name .. ' / ' .. ref
|
||||
elseif "" ~= ref then
|
||||
way.name = ref
|
||||
elseif "" ~= name then
|
||||
way.name = name
|
||||
else
|
||||
@ -286,6 +307,15 @@ function way_function (way)
|
||||
elseif cycleway_right and cycleway_tags[cycleway_right] then
|
||||
way.speed = bicycle_speeds["cycleway"]
|
||||
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
|
||||
-- TODO: maxspeed of backward direction
|
||||
|
Loading…
Reference in New Issue
Block a user