Merge branch 'develop' of https://github.com/DennisOSRM/Project-OSRM into develop
This commit is contained in:
commit
b6303626b5
59
Rakefile
59
Rakefile
@ -4,8 +4,8 @@ require 'digest/sha1'
|
|||||||
require 'cucumber/rake/task'
|
require 'cucumber/rake/task'
|
||||||
require 'sys/proctable'
|
require 'sys/proctable'
|
||||||
|
|
||||||
SANDBOX = 'sandbox'
|
DATA_FOLDER = 'sandbox'
|
||||||
DATA_FOLDER = 'osm_data'
|
PROFILE = 'bicycle'
|
||||||
|
|
||||||
Cucumber::Rake::Task.new do |t|
|
Cucumber::Rake::Task.new do |t|
|
||||||
t.cucumber_opts = %w{--format pretty}
|
t.cucumber_opts = %w{--format pretty}
|
||||||
@ -62,12 +62,12 @@ def write_server_ini osm_file
|
|||||||
IP = 0.0.0.0
|
IP = 0.0.0.0
|
||||||
Port = 5000
|
Port = 5000
|
||||||
|
|
||||||
hsgrData=#{DATA_FOLDER}/#{osm_file}.osrm.hsgr
|
hsgrData=#{osm_file}.osrm.hsgr
|
||||||
nodesData=#{DATA_FOLDER}/#{osm_file}.osrm.nodes
|
nodesData=#{osm_file}.osrm.nodes
|
||||||
edgesData=#{DATA_FOLDER}/#{osm_file}.osrm.edges
|
edgesData=#{osm_file}.osrm.edges
|
||||||
ramIndex=#{DATA_FOLDER}/#{osm_file}.osrm.ramIndex
|
ramIndex=#{osm_file}.osrm.ramIndex
|
||||||
fileIndex=#{DATA_FOLDER}/#{osm_file}.osrm.fileIndex
|
fileIndex=#{osm_file}.osrm.fileIndex
|
||||||
namesData=#{DATA_FOLDER}/#{osm_file}.osrm.names
|
namesData=#{osm_file}.osrm.names
|
||||||
EOF
|
EOF
|
||||||
File.open( 'server.ini', 'w') {|f| f.write( s ) }
|
File.open( 'server.ini', 'w') {|f| f.write( s ) }
|
||||||
end
|
end
|
||||||
@ -83,46 +83,48 @@ end
|
|||||||
|
|
||||||
desc "Setup config files."
|
desc "Setup config files."
|
||||||
task :setup do
|
task :setup do
|
||||||
Dir.mkdir "#{SANDBOX}/#{DATA_FOLDER}" unless File.exist? "#{SANDBOX}/#{DATA_FOLDER}"
|
Dir.mkdir "#{DATA_FOLDER}" unless File.exist? "#{DATA_FOLDER}"
|
||||||
['server.ini','speedprofile.ini','extractor.ini','contractor.ini'].each do |file|
|
['server.ini','extractor.ini','contractor.ini'].each do |file|
|
||||||
unless File.exist? "#{SANDBOX}/#{file}"
|
unless File.exist? "#{DATA_FOLDER}/#{file}"
|
||||||
puts "Copying #{file} template to sandbox/#{file}"
|
puts "Copying #{file} template to #{DATA_FOLDER}/#{file}"
|
||||||
FileUtils.cp file, "#{SANDBOX}/#{file}"
|
FileUtils.cp file, "#{DATA_FOLDER}/#{file}"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
desc "Download OSM data."
|
desc "Download OSM data."
|
||||||
task :download => :setup do
|
task :download => :setup do
|
||||||
|
Dir.mkdir "#{DATA_FOLDER}" unless File.exist? "#{DATA_FOLDER}"
|
||||||
puts "Downloading..."
|
puts "Downloading..."
|
||||||
raise "Error while downloading data." unless system "curl http://download.geofabrik.de/osm/europe/#{osm_data_country}.osm.pbf -o #{SANDBOX}/#{DATA_FOLDER}/#{osm_data_country}.osm.pbf"
|
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"
|
||||||
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=#{SANDBOX}/#{DATA_FOLDER}/#{osm_data_country}.osm.pbf --bounding-box #{osm_data_area_bbox} --write-pbf file=#{SANDBOX}/#{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"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
desc "Crop OSM data"
|
desc "Crop OSM data"
|
||||||
task :crop do
|
task :crop do
|
||||||
if osm_data_area_bbox
|
if osm_data_area_bbox
|
||||||
raise "Error while cropping data." unless system "osmosis --read-pbf file=#{SANDBOX}/#{DATA_FOLDER}/#{osm_data_country}.osm.pbf --bounding-box #{osm_data_area_bbox} --write-pbf file=#{SANDBOX}/#{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"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
desc "Reprocess OSM data."
|
desc "Reprocess OSM data."
|
||||||
task :process => :setup do
|
task :process => :setup do
|
||||||
Dir.chdir SANDBOX do
|
Dir.chdir DATA_FOLDER do
|
||||||
raise "Error while extracting data." unless system "../osrm-extract #{DATA_FOLDER}/#{osm_data_area_name}.osm.pbf"
|
raise "Error while extracting data." unless system "../osrm-extract #{osm_data_area_name}.osm.pbf ../profiles/#{PROFILE}.lua"
|
||||||
puts
|
puts
|
||||||
raise "Error while preparing data." unless system "../osrm-prepare #{DATA_FOLDER}/#{osm_data_area_name}.osrm #{DATA_FOLDER}/#{osm_data_area_name}.osrm.restrictions"
|
raise "Error while preparing data." unless system "../osrm-prepare #{osm_data_area_name}.osrm #{osm_data_area_name}.osrm.restrictions ../profiles/#{PROFILE}.lua"
|
||||||
puts
|
puts
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
desc "Delete preprocessing files."
|
desc "Delete preprocessing files."
|
||||||
task :clean do
|
task :clean do
|
||||||
File.delete *Dir.glob("#{SANDBOX}/#{DATA_FOLDER}/*.osrm")
|
File.delete *Dir.glob("#{DATA_FOLDER}/*.osrm")
|
||||||
File.delete *Dir.glob("#{SANDBOX}/#{DATA_FOLDER}/*.osrm.*")
|
File.delete *Dir.glob("#{DATA_FOLDER}/*.osrm.*")
|
||||||
end
|
end
|
||||||
|
|
||||||
desc "Run all cucumber test"
|
desc "Run all cucumber test"
|
||||||
@ -133,7 +135,7 @@ end
|
|||||||
|
|
||||||
desc "Run the routing server in the terminal. Press Ctrl-C to stop."
|
desc "Run the routing server in the terminal. Press Ctrl-C to stop."
|
||||||
task :run => :setup do
|
task :run => :setup do
|
||||||
Dir.chdir SANDBOX do
|
Dir.chdir DATA_FOLDER do
|
||||||
write_server_ini osm_data_area_name
|
write_server_ini osm_data_area_name
|
||||||
system "../osrm-routed"
|
system "../osrm-routed"
|
||||||
end
|
end
|
||||||
@ -141,7 +143,7 @@ end
|
|||||||
|
|
||||||
desc "Launch the routing server in the background. Use rake:down to stop it."
|
desc "Launch the routing server in the background. Use rake:down to stop it."
|
||||||
task :up => :setup do
|
task :up => :setup do
|
||||||
Dir.chdir SANDBOX 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('../osrm-routed 1>>osrm-routed.log 2>>osrm-routed.log')
|
||||||
@ -160,8 +162,11 @@ end
|
|||||||
desc "Stop the routing server."
|
desc "Stop the routing server."
|
||||||
task :down do
|
task :down do
|
||||||
pid = find_pid 'osrm-routed'
|
pid = find_pid 'osrm-routed'
|
||||||
abort("Already down.") unless pid
|
if pid
|
||||||
Process.kill 'TERM', pid
|
Process.kill 'TERM', pid
|
||||||
|
else
|
||||||
|
puts "Already down."
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
desc "Kill all osrm-extract, osrm-prepare and osrm-routed processes."
|
desc "Kill all osrm-extract, osrm-prepare and osrm-routed processes."
|
||||||
@ -180,3 +185,7 @@ task :pid do
|
|||||||
puts "#{pid}\t#{state}"
|
puts "#{pid}\t#{state}"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
desc "Stop, reprocess and restart."
|
||||||
|
task :update => [:down,:process,:up] do
|
||||||
|
end
|
||||||
|
@ -72,6 +72,8 @@ conf = Configure(env, custom_tests = { 'CheckBoost' : CheckBoost, 'CheckProtobuf
|
|||||||
|
|
||||||
if GetOption('cxx') is None:
|
if GetOption('cxx') is None:
|
||||||
#default Compiler
|
#default Compiler
|
||||||
|
if sys.platform == 'darwin': #Mac OS X
|
||||||
|
env['CXX'] = 'clang++'
|
||||||
print 'Using default C++ Compiler: ', env['CXX'].strip()
|
print 'Using default C++ Compiler: ', env['CXX'].strip()
|
||||||
else:
|
else:
|
||||||
env.Replace(CXX = GetOption('cxx'))
|
env.Replace(CXX = GetOption('cxx'))
|
||||||
|
@ -3,7 +3,8 @@ Feature: Bike - Squares and other areas
|
|||||||
|
|
||||||
Background:
|
Background:
|
||||||
Given the speedprofile "bicycle"
|
Given the speedprofile "bicycle"
|
||||||
|
|
||||||
|
@square
|
||||||
Scenario: Bike - Route along edge of a squares
|
Scenario: Bike - Route along edge of a squares
|
||||||
Given the node map
|
Given the node map
|
||||||
| x | |
|
| x | |
|
||||||
@ -25,7 +26,8 @@ Feature: Bike - Squares and other areas
|
|||||||
| d | c | abcda |
|
| d | c | abcda |
|
||||||
| d | a | abcda |
|
| d | a | abcda |
|
||||||
| a | d | abcda |
|
| a | d | abcda |
|
||||||
|
|
||||||
|
@building
|
||||||
Scenario: Bike - Don't route on buildings
|
Scenario: Bike - Don't route on buildings
|
||||||
Given the node map
|
Given the node map
|
||||||
| x | |
|
| x | |
|
||||||
@ -47,3 +49,55 @@ Feature: Bike - Squares and other areas
|
|||||||
| d | c | |
|
| d | c | |
|
||||||
| d | a | |
|
| d | a | |
|
||||||
| a | d | |
|
| a | d | |
|
||||||
|
|
||||||
|
@parking
|
||||||
|
Scenario: Bike - parking areas
|
||||||
|
Given the node map
|
||||||
|
| e | | | f |
|
||||||
|
| x | a | b | y |
|
||||||
|
| | d | c | |
|
||||||
|
|
||||||
|
And the ways
|
||||||
|
| nodes | highway | amenity |
|
||||||
|
| xa | primary | |
|
||||||
|
| by | primary | |
|
||||||
|
| xefy | primary | |
|
||||||
|
| abcda | (nil) | parking |
|
||||||
|
|
||||||
|
When I route I should get
|
||||||
|
| from | to | route |
|
||||||
|
| x | y | xa,abcda,by |
|
||||||
|
| y | x | by,abcda,xa |
|
||||||
|
| a | b | abcda |
|
||||||
|
| a | d | abcda |
|
||||||
|
| b | c | abcda |
|
||||||
|
| c | b | abcda |
|
||||||
|
| c | d | abcda |
|
||||||
|
| d | c | abcda |
|
||||||
|
| d | a | abcda |
|
||||||
|
| a | d | abcda |
|
||||||
|
|
||||||
|
@train @platform
|
||||||
|
Scenario: Bike - railway platforms
|
||||||
|
Given the node map
|
||||||
|
| x | a | b | y |
|
||||||
|
| | d | c | |
|
||||||
|
|
||||||
|
And the ways
|
||||||
|
| nodes | highway | railway |
|
||||||
|
| xa | primary | |
|
||||||
|
| by | primary | |
|
||||||
|
| abcda | (nil) | platform |
|
||||||
|
|
||||||
|
When I route I should get
|
||||||
|
| from | to | route |
|
||||||
|
| x | y | xa,abcda,by |
|
||||||
|
| y | x | by,abcda,xa |
|
||||||
|
| a | b | abcda |
|
||||||
|
| a | d | abcda |
|
||||||
|
| b | c | abcda |
|
||||||
|
| c | b | abcda |
|
||||||
|
| c | d | abcda |
|
||||||
|
| d | c | abcda |
|
||||||
|
| d | a | abcda |
|
||||||
|
| a | d | abcda |
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
@routing @bicycle @train @todo
|
@routing @bicycle @train
|
||||||
Feature: Bike - Handle ferry routes
|
Feature: Bike - Handle ferry routes
|
||||||
Bringing bikes on trains and subways
|
Bringing bikes on trains and subways
|
||||||
|
|
||||||
@ -7,17 +7,26 @@ Bringing bikes on trains and subways
|
|||||||
|
|
||||||
Scenario: Bike - Bringing bikes on trains
|
Scenario: Bike - Bringing bikes on trains
|
||||||
Then routability should be
|
Then routability should be
|
||||||
| highway | railway | bicycle | bothw |
|
| highway | railway | bicycle | bothw |
|
||||||
| primary | | | x |
|
| primary | | | x |
|
||||||
| (nil) | train | | |
|
| (nil) | train | | |
|
||||||
| (nil) | train | no | |
|
| (nil) | train | no | |
|
||||||
| (nil) | train | yes | x |
|
| (nil) | train | yes | x |
|
||||||
| (nil) | railway | | |
|
| (nil) | railway | | |
|
||||||
| (nil) | railway | no | |
|
| (nil) | railway | no | |
|
||||||
| (nil) | railway | yes | x |
|
| (nil) | railway | yes | x |
|
||||||
| (nil) | subway | | |
|
| (nil) | subway | | |
|
||||||
| (nil) | subway | no | |
|
| (nil) | subway | no | |
|
||||||
| (nil) | subway | yes | x |
|
| (nil) | subway | yes | x |
|
||||||
| (nil) | some_tag | | |
|
| (nil) | tram | | |
|
||||||
| (nil) | some_tag | no | |
|
| (nil) | tram | no | |
|
||||||
| (nil) | some_tag | yes | x |
|
| (nil) | tram | yes | x |
|
||||||
|
| (nil) | light_rail | | |
|
||||||
|
| (nil) | light_rail | no | |
|
||||||
|
| (nil) | light_rail | yes | x |
|
||||||
|
| (nil) | monorail | | |
|
||||||
|
| (nil) | monorail | no | |
|
||||||
|
| (nil) | monorail | yes | x |
|
||||||
|
| (nil) | some_tag | | |
|
||||||
|
| (nil) | some_tag | no | |
|
||||||
|
| (nil) | some_tag | yes | x |
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
@routing @bicycle @destination @todo
|
@routing @car @destination @todo
|
||||||
Feature: Car - Destination only, no passing through
|
Feature: Car - Destination only, no passing through
|
||||||
|
|
||||||
Background:
|
Background:
|
||||||
|
@ -240,7 +240,7 @@ When /^I route I should get$/ do |table|
|
|||||||
margin = 1 - $2.to_f*0.01
|
margin = 1 - $2.to_f*0.01
|
||||||
from = $1.to_f*margin
|
from = $1.to_f*margin
|
||||||
to = $1.to_f/margin
|
to = $1.to_f/margin
|
||||||
if (from..to).cover? got[key].to_f
|
if got[key].to_f >= from && got[key].to_f <= to
|
||||||
got[key] = row[key]
|
got[key] = row[key]
|
||||||
else
|
else
|
||||||
ok = false
|
ok = false
|
||||||
@ -249,7 +249,7 @@ When /^I route I should get$/ do |table|
|
|||||||
margin = $2.to_f
|
margin = $2.to_f
|
||||||
from = $1.to_f-margin
|
from = $1.to_f-margin
|
||||||
to = $1.to_f+margin
|
to = $1.to_f+margin
|
||||||
if (from..to).cover? got[key].to_f
|
if got[key].to_f >= from && got[key].to_f <= to
|
||||||
got[key] = row[key]
|
got[key] = row[key]
|
||||||
else
|
else
|
||||||
ok = false
|
ok = false
|
||||||
|
@ -11,10 +11,6 @@ def read_speedprofile profile
|
|||||||
@speedprofile = profile
|
@speedprofile = profile
|
||||||
end
|
end
|
||||||
|
|
||||||
def write_speedprofile
|
|
||||||
FileUtils.copy_file "../profiles/#{@speedprofile}.lua", "profile.lua"
|
|
||||||
end
|
|
||||||
|
|
||||||
def write_server_ini
|
def write_server_ini
|
||||||
s=<<-EOF
|
s=<<-EOF
|
||||||
Threads = 1
|
Threads = 1
|
||||||
|
@ -200,13 +200,12 @@ end
|
|||||||
|
|
||||||
def reprocess
|
def reprocess
|
||||||
Dir.chdir TEST_FOLDER do
|
Dir.chdir TEST_FOLDER do
|
||||||
write_speedprofile
|
|
||||||
write_osm
|
write_osm
|
||||||
convert_osm_to_pbf
|
convert_osm_to_pbf
|
||||||
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}"
|
unless system "../osrm-extract #{@osm_file}.osm.pbf 1>>#{PREPROCESS_LOG_FILE} 2>>#{PREPROCESS_LOG_FILE} ../profiles/#{@speedprofile}.lua"
|
||||||
log "*** Exited with code #{$?.exitstatus}.", :preprocess
|
log "*** Exited with code #{$?.exitstatus}.", :preprocess
|
||||||
raise OSRMError.new 'osrm-extract', $?.exitstatus, "*** osrm-extract exited with code #{$?.exitstatus}. The file preprocess.log might contain more info."
|
raise OSRMError.new 'osrm-extract', $?.exitstatus, "*** osrm-extract exited with code #{$?.exitstatus}. The file preprocess.log might contain more info."
|
||||||
end
|
end
|
||||||
@ -215,7 +214,7 @@ def reprocess
|
|||||||
unless prepared?
|
unless prepared?
|
||||||
log_preprocess_info
|
log_preprocess_info
|
||||||
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}"
|
unless system "../osrm-prepare #{@osm_file}.osrm #{@osm_file}.osrm.restrictions 1>>#{PREPROCESS_LOG_FILE} 2>>#{PREPROCESS_LOG_FILE} ../profiles/#{@speedprofile}.lua"
|
||||||
log "*** Exited with code #{$?.exitstatus}.", :preprocess
|
log "*** Exited with code #{$?.exitstatus}.", :preprocess
|
||||||
raise OSRMError.new 'osrm-prepare', $?.exitstatus, "*** osrm-prepare exited with code #{$?.exitstatus}. The file preprocess.log might contain more info."
|
raise OSRMError.new 'osrm-prepare', $?.exitstatus, "*** osrm-prepare exited with code #{$?.exitstatus}. The file preprocess.log might contain more info."
|
||||||
end
|
end
|
||||||
|
@ -12,7 +12,7 @@ def hash_of_file path
|
|||||||
end
|
end
|
||||||
|
|
||||||
def speedprofile_hash
|
def speedprofile_hash
|
||||||
@speedprofile_hash ||= hash_of_file "profile.lua"
|
@speedprofile_hash ||= hash_of_file "../profiles/#{@speedprofile}.lua"
|
||||||
end
|
end
|
||||||
|
|
||||||
def osm_hash
|
def osm_hash
|
||||||
|
@ -5,7 +5,7 @@ Testbot uses a signal penalty of 7s.
|
|||||||
Background:
|
Background:
|
||||||
Given the speedprofile "testbot"
|
Given the speedprofile "testbot"
|
||||||
|
|
||||||
Scenario: Passing a traffic signal should incur a delay
|
Scenario: Traffic signals should incur a delay, without changing distance
|
||||||
Given the node map
|
Given the node map
|
||||||
| a | b | c |
|
| a | b | c |
|
||||||
| d | e | f |
|
| d | e | f |
|
||||||
@ -20,9 +20,9 @@ Testbot uses a signal penalty of 7s.
|
|||||||
| def |
|
| def |
|
||||||
|
|
||||||
When I route I should get
|
When I route I should get
|
||||||
| from | to | route | time |
|
| from | to | route | time | distance |
|
||||||
| a | c | abc | 20s +-1 |
|
| a | c | abc | 20s +-1 | 200m +-1 |
|
||||||
| d | f | def | 27s +-1 |
|
| d | f | def | 27s +-1 | 200m +-1 |
|
||||||
|
|
||||||
Scenario: Signal penalty should not depend on way type
|
Scenario: Signal penalty should not depend on way type
|
||||||
Given the node map
|
Given the node map
|
||||||
|
@ -6,9 +6,10 @@ access_tag_restricted = { ["destination"] = true, ["delivery"] = true }
|
|||||||
access_tags_hierachy = { "bicycle", "vehicle", "access" }
|
access_tags_hierachy = { "bicycle", "vehicle", "access" }
|
||||||
cycleway_tags = {["track"]=true,["lane"]=true,["opposite"]=true,["opposite_lane"]=true,["opposite_track"]=true,["share_busway"]=true,["sharrow"]=true,["shared"]=true }
|
cycleway_tags = {["track"]=true,["lane"]=true,["opposite"]=true,["opposite_lane"]=true,["opposite_track"]=true,["share_busway"]=true,["sharrow"]=true,["shared"]=true }
|
||||||
service_tag_restricted = { ["parking_aisle"] = true }
|
service_tag_restricted = { ["parking_aisle"] = true }
|
||||||
ignore_in_grid = { ["ferry"] = true }
|
|
||||||
|
|
||||||
speed_profile = {
|
default_speed = 16
|
||||||
|
|
||||||
|
main_speeds = {
|
||||||
["cycleway"] = 18,
|
["cycleway"] = 18,
|
||||||
["primary"] = 17,
|
["primary"] = 17,
|
||||||
["primary_link"] = 17,
|
["primary_link"] = 17,
|
||||||
@ -23,11 +24,38 @@ speed_profile = {
|
|||||||
["service"] = 16,
|
["service"] = 16,
|
||||||
["track"] = 13,
|
["track"] = 13,
|
||||||
["path"] = 13,
|
["path"] = 13,
|
||||||
|
["footway"] = 12,
|
||||||
|
["pedestrian"] = 12,
|
||||||
|
["pier"] = 12,
|
||||||
|
["steps"] = 2
|
||||||
|
}
|
||||||
|
|
||||||
|
pedestrian_speeds = {
|
||||||
["footway"] = 5,
|
["footway"] = 5,
|
||||||
["pedestrian"] = 5,
|
["pedestrian"] = 5,
|
||||||
["pier"] = 5,
|
["pier"] = 5,
|
||||||
["steps"] = 1,
|
["steps"] = 2
|
||||||
["default"] = 18,
|
}
|
||||||
|
|
||||||
|
railway_speeds = {
|
||||||
|
["train"] = 10,
|
||||||
|
["railway"] = 10,
|
||||||
|
["subway"] = 10,
|
||||||
|
["light_rail"] = 10,
|
||||||
|
["monorail"] = 10,
|
||||||
|
["tram"] = 10
|
||||||
|
}
|
||||||
|
|
||||||
|
platform_speeds = {
|
||||||
|
["platform"] = 5
|
||||||
|
}
|
||||||
|
|
||||||
|
amenity_speeds = {
|
||||||
|
["parking"] = 10,
|
||||||
|
["parking_entrance"] = 10
|
||||||
|
}
|
||||||
|
|
||||||
|
route_speeds = {
|
||||||
["ferry"] = 5
|
["ferry"] = 5
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -92,6 +120,7 @@ function way_function (way, numberOfNodesInWay)
|
|||||||
local ref = way.tags:Find("ref")
|
local ref = way.tags:Find("ref")
|
||||||
local junction = way.tags:Find("junction")
|
local junction = way.tags:Find("junction")
|
||||||
local route = way.tags:Find("route")
|
local route = way.tags:Find("route")
|
||||||
|
local railway = way.tags:Find("railway")
|
||||||
local maxspeed = parseMaxspeed(way.tags:Find ( "maxspeed") )
|
local maxspeed = parseMaxspeed(way.tags:Find ( "maxspeed") )
|
||||||
local man_made = way.tags:Find("man_made")
|
local man_made = way.tags:Find("man_made")
|
||||||
local barrier = way.tags:Find("barrier")
|
local barrier = way.tags:Find("barrier")
|
||||||
@ -103,10 +132,14 @@ function way_function (way, numberOfNodesInWay)
|
|||||||
local duration = way.tags:Find("duration")
|
local duration = way.tags:Find("duration")
|
||||||
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 amenity = way.tags:Find("amenity")
|
||||||
local access = find_access_tag(way)
|
local access = find_access_tag(way)
|
||||||
|
|
||||||
-- only route on things with highway tag set (not buildings, boundaries, etc)
|
-- only route on things with highway tag set (not buildings, boundaries, etc)
|
||||||
if (not highway or highway == '') and (not route or route == '') then
|
if (not highway or highway == '') and
|
||||||
|
(not route or route == '') and
|
||||||
|
(not railway or railway=='') and
|
||||||
|
(not amenity or amenity=='') then
|
||||||
return 0
|
return 0
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -124,27 +157,43 @@ function way_function (way, numberOfNodesInWay)
|
|||||||
way.name = highway -- if no name exists, use way type
|
way.name = highway -- if no name exists, use way type
|
||||||
end
|
end
|
||||||
|
|
||||||
if (speed_profile[route] and speed_profile[route] > 0) or (speed_profile[man_made] and speed_profile[man_made] > 0) then
|
if route_speeds[route] then
|
||||||
-- ferries and piers
|
-- ferries
|
||||||
|
way.direction = Way.bidirectional
|
||||||
|
way.ignore_in_grid = true
|
||||||
if durationIsValid(duration) then
|
if durationIsValid(duration) then
|
||||||
way.speed = math.max( duration / math.max(1, numberOfNodesInWay-1) )
|
way.speed = math.max( parseDuration(duration) / math.max(1, numberOfNodesInWay-1) )
|
||||||
way.is_duration_set = true;
|
way.is_duration_set = true
|
||||||
|
else
|
||||||
|
way.speed = route_speeds[route]
|
||||||
end
|
end
|
||||||
way.direction = Way.bidirectional;
|
elseif railway and platform_speeds[railway] then
|
||||||
if speed_profile[route] ~= nil then
|
-- railway platforms
|
||||||
highway = route;
|
way.speed = platform_speeds[railway]
|
||||||
elseif speed_profile[man_made] ~= nil then
|
elseif railway and railway_speeds[railway] then
|
||||||
highway = man_made;
|
-- railways
|
||||||
|
if access and access_tag_whitelist[access] then
|
||||||
|
way.speed = railway_speeds[railway]
|
||||||
|
way.direction = Way.bidirectional
|
||||||
end
|
end
|
||||||
if not way.is_duration_set then
|
elseif pedestrian_speeds[highway] and main_speeds[highway] then
|
||||||
way.speed = speed_profile[highway]
|
-- pedestrian areas
|
||||||
|
if access_tag_whitelist[access] then
|
||||||
|
way.speed = main_speeds[highway] -- biking
|
||||||
|
else
|
||||||
|
way.speed = pedestrian_speeds[highway] -- pushing bikes
|
||||||
end
|
end
|
||||||
else
|
elseif amenity and amenity_speeds[amenity] then
|
||||||
-- ways
|
-- parking areas
|
||||||
if speed_profile[highway] then
|
way.speed = amenity_speeds[amenity]
|
||||||
way.speed = speed_profile[highway]
|
else
|
||||||
elseif access_tag_whitelist[access] then
|
-- regular ways
|
||||||
way.speed = speed_profile["default"]
|
if main_speeds[highway] then
|
||||||
|
way.speed = main_speeds[highway]
|
||||||
|
elseif main_speeds[man_made] then
|
||||||
|
way.speed = main_speeds[man_made]
|
||||||
|
elseif access_tag_whitelist[access] then
|
||||||
|
way.speed = default_speed
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -199,11 +248,11 @@ function way_function (way, numberOfNodesInWay)
|
|||||||
|
|
||||||
-- cycleways
|
-- cycleways
|
||||||
if cycleway and cycleway_tags[cycleway] then
|
if cycleway and cycleway_tags[cycleway] then
|
||||||
way.speed = speed_profile["cycleway"]
|
way.speed = main_speeds["cycleway"]
|
||||||
elseif cycleway_left and cycleway_tags[cycleway_left] then
|
elseif cycleway_left and cycleway_tags[cycleway_left] then
|
||||||
way.speed = speed_profile["cycleway"]
|
way.speed = main_speeds["cycleway"]
|
||||||
elseif cycleway_right and cycleway_tags[cycleway_right] then
|
elseif cycleway_right and cycleway_tags[cycleway_right] then
|
||||||
way.speed = speed_profile["cycleway"]
|
way.speed = main_speeds["cycleway"]
|
||||||
end
|
end
|
||||||
|
|
||||||
way.type = 1
|
way.type = 1
|
||||||
|
@ -7,7 +7,7 @@ access_tag_restricted = { ["destination"] = true, ["delivery"] = true }
|
|||||||
access_tags = { "motorcar", "motor_vehicle", "vehicle" }
|
access_tags = { "motorcar", "motor_vehicle", "vehicle" }
|
||||||
access_tags_hierachy = { "motorcar", "motor_vehicle", "vehicle", "access" }
|
access_tags_hierachy = { "motorcar", "motor_vehicle", "vehicle", "access" }
|
||||||
service_tag_restricted = { ["parking_aisle"] = true }
|
service_tag_restricted = { ["parking_aisle"] = true }
|
||||||
ignore_in_grid = { ["ferry"] = true, ["pier"] = true }
|
ignore_in_grid = { ["ferry"] = true }
|
||||||
|
|
||||||
speed_profile = {
|
speed_profile = {
|
||||||
["motorway"] = 90,
|
["motorway"] = 90,
|
||||||
@ -26,7 +26,7 @@ speed_profile = {
|
|||||||
["service"] = 15,
|
["service"] = 15,
|
||||||
-- ["track"] = 5,
|
-- ["track"] = 5,
|
||||||
["ferry"] = 5,
|
["ferry"] = 5,
|
||||||
["pier"] = 5,
|
-- ["pier"] = 5,
|
||||||
["default"] = 50
|
["default"] = 50
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -93,7 +93,7 @@ function way_function (way, numberOfNodesInWay)
|
|||||||
local junction = way.tags:Find("junction")
|
local junction = way.tags:Find("junction")
|
||||||
local route = way.tags:Find("route")
|
local route = way.tags:Find("route")
|
||||||
local maxspeed = parseMaxspeed(way.tags:Find ( "maxspeed") )
|
local maxspeed = parseMaxspeed(way.tags:Find ( "maxspeed") )
|
||||||
local man_made = way.tags:Find("man_made")
|
--local man_made = way.tags:Find("man_made")
|
||||||
local barrier = way.tags:Find("barrier")
|
local barrier = way.tags:Find("barrier")
|
||||||
local oneway = way.tags:Find("oneway")
|
local oneway = way.tags:Find("oneway")
|
||||||
local cycleway = way.tags:Find("cycleway")
|
local cycleway = way.tags:Find("cycleway")
|
||||||
@ -138,8 +138,8 @@ function way_function (way, numberOfNodesInWay)
|
|||||||
|
|
||||||
-- Handling ferries and piers
|
-- Handling ferries and piers
|
||||||
|
|
||||||
if (speed_profile[route] ~= nil and speed_profile[route] > 0) or
|
if (speed_profile[route] ~= nil and speed_profile[route] > 0) --or
|
||||||
(speed_profile[man_made] ~= nil and speed_profile[man_made] > 0)
|
--(speed_profile[man_made] ~= nil and speed_profile[man_made] > 0)
|
||||||
then
|
then
|
||||||
if durationIsValid(duration) then
|
if durationIsValid(duration) then
|
||||||
way.speed = math.max( parseDuration(duration) / math.max(1, numberOfNodesInWay-1) );
|
way.speed = math.max( parseDuration(duration) / math.max(1, numberOfNodesInWay-1) );
|
||||||
@ -148,8 +148,8 @@ function way_function (way, numberOfNodesInWay)
|
|||||||
way.direction = Way.bidirectional;
|
way.direction = Way.bidirectional;
|
||||||
if speed_profile[route] ~= nil then
|
if speed_profile[route] ~= nil then
|
||||||
highway = route;
|
highway = route;
|
||||||
elseif speed_profile[man_made] ~= nil then
|
--elseif speed_profile[man_made] ~= nil then
|
||||||
highway = man_made;
|
-- highway = man_made;
|
||||||
end
|
end
|
||||||
if not way.is_duration_set then
|
if not way.is_duration_set then
|
||||||
way.speed = speed_profile[highway]
|
way.speed = speed_profile[highway]
|
||||||
@ -166,7 +166,7 @@ function way_function (way, numberOfNodesInWay)
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- Set the avg speed on ways that are marked accessible
|
-- Set the avg speed on ways that are marked accessible
|
||||||
if speed_profile[highway] and access_tag_whitelist[access] and way.speed == -1 then
|
if "" ~= highway and access_tag_whitelist[access] and way.speed == -1 then
|
||||||
if (0 < maxspeed and not take_minimum_of_speeds) or maxspeed == 0 then
|
if (0 < maxspeed and not take_minimum_of_speeds) or maxspeed == 0 then
|
||||||
maxspeed = math.huge
|
maxspeed = math.huge
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user