lua: Set and Sequence
This commit is contained in:
parent
24c2708d1e
commit
5d564ee510
200
profiles/car.lua
200
profiles/car.lua
@ -3,48 +3,100 @@ local find_access_tag = require("lib/access").find_access_tag
|
|||||||
local get_destination = require("lib/destination").get_destination
|
local get_destination = require("lib/destination").get_destination
|
||||||
local set_classification = require("lib/guidance").set_classification
|
local set_classification = require("lib/guidance").set_classification
|
||||||
local get_turn_lanes = require("lib/guidance").get_turn_lanes
|
local get_turn_lanes = require("lib/guidance").get_turn_lanes
|
||||||
|
local Set = require('lib/set')
|
||||||
|
local Sequence = require('lib/sequence')
|
||||||
|
|
||||||
-- Begin of globals
|
-- Begin of globals
|
||||||
barrier_whitelist = { ["cattle_grid"] = true, ["border_control"] = true, ["checkpoint"] = true, ["toll_booth"] = true, ["sally_port"] = true, ["gate"] = true, ["lift_gate"] = true, ["no"] = true, ["entrance"] = true }
|
barrier_whitelist = Set {
|
||||||
access_tag_whitelist = { ["yes"] = true, ["motorcar"] = true, ["motor_vehicle"] = true, ["vehicle"] = true, ["permissive"] = true, ["designated"] = true, ["destination"] = true }
|
'cattle_grid',
|
||||||
access_tag_blacklist = { ["no"] = true, ["private"] = true, ["agricultural"] = true, ["forestry"] = true, ["emergency"] = true, ["psv"] = true, ["delivery"] = true }
|
'border_control',
|
||||||
access_tag_restricted = { ["destination"] = true, ["delivery"] = true }
|
'checkpoint',
|
||||||
access_tags_hierarchy = { "motorcar", "motor_vehicle", "vehicle", "access" }
|
'toll_booth',
|
||||||
service_tag_restricted = { ["parking_aisle"] = true, ["parking"] = true }
|
'sally_port',
|
||||||
service_tag_forbidden = { ["emergency_access"] = true }
|
'gate',
|
||||||
restrictions = { "motorcar", "motor_vehicle", "vehicle" }
|
'lift_gate',
|
||||||
|
'no',
|
||||||
|
'entrance'
|
||||||
|
}
|
||||||
|
|
||||||
|
access_tag_whitelist = Set {
|
||||||
|
'yes',
|
||||||
|
'motorcar',
|
||||||
|
'motor_vehicle',
|
||||||
|
'vehicle',
|
||||||
|
'permissive',
|
||||||
|
'designated',
|
||||||
|
'destination'
|
||||||
|
}
|
||||||
|
|
||||||
|
access_tag_blacklist = Set {
|
||||||
|
'no',
|
||||||
|
'private',
|
||||||
|
'agricultural',
|
||||||
|
'forestry',
|
||||||
|
'emergency',
|
||||||
|
'psv',
|
||||||
|
'delivery'
|
||||||
|
}
|
||||||
|
|
||||||
|
access_tag_restricted = Set {
|
||||||
|
'destination',
|
||||||
|
'delivery'
|
||||||
|
}
|
||||||
|
|
||||||
|
access_tags_hierarchy = Sequence {
|
||||||
|
'motorcar',
|
||||||
|
'motor_vehicle',
|
||||||
|
'vehicle',
|
||||||
|
'access'
|
||||||
|
}
|
||||||
|
|
||||||
|
service_tag_restricted = Set {
|
||||||
|
'parking_aisle',
|
||||||
|
'parking'
|
||||||
|
}
|
||||||
|
|
||||||
|
service_tag_forbidden = Set {
|
||||||
|
'emergency_access'
|
||||||
|
}
|
||||||
|
|
||||||
|
restrictions = Sequence {
|
||||||
|
'motorcar', "motor_vehicle", "vehicle" }
|
||||||
|
|
||||||
-- A list of suffixes to suppress in name change instructions
|
-- A list of suffixes to suppress in name change instructions
|
||||||
suffix_list = { "N", "NE", "E", "SE", "S", "SW", "W", "NW", "North", "South", "West", "East" }
|
-- Note: a Set does not work here because it's read from C++
|
||||||
|
suffix_list = {
|
||||||
|
'N', 'NE', 'E', 'SE', 'S', 'SW', 'W', 'NW', 'North', 'South', 'West', 'East'
|
||||||
|
}
|
||||||
|
|
||||||
speed_profile = {
|
speed_profile = {
|
||||||
["motorway"] = 90,
|
motorway = 90,
|
||||||
["motorway_link"] = 45,
|
motorway_link = 45,
|
||||||
["trunk"] = 85,
|
trunk = 85,
|
||||||
["trunk_link"] = 40,
|
trunk_link = 40,
|
||||||
["primary"] = 65,
|
primary = 65,
|
||||||
["primary_link"] = 30,
|
primary_link = 30,
|
||||||
["secondary"] = 55,
|
secondary = 55,
|
||||||
["secondary_link"] = 25,
|
secondary_link = 25,
|
||||||
["tertiary"] = 40,
|
tertiary = 40,
|
||||||
["tertiary_link"] = 20,
|
tertiary_link = 20,
|
||||||
["unclassified"] = 25,
|
unclassified = 25,
|
||||||
["residential"] = 25,
|
residential = 25,
|
||||||
["living_street"] = 10,
|
living_street = 10,
|
||||||
["service"] = 15,
|
service = 15,
|
||||||
-- ["track"] = 5,
|
--track = 5,
|
||||||
["ferry"] = 5,
|
ferry = 5,
|
||||||
["movable"] = 5,
|
movable = 5,
|
||||||
["shuttle_train"] = 10,
|
shuttle_train = 10,
|
||||||
["default"] = 10
|
default = 10
|
||||||
}
|
}
|
||||||
|
|
||||||
-- service speeds
|
-- service speeds
|
||||||
service_speeds = {
|
service_speeds = {
|
||||||
["alley"] = 5,
|
alley = 5,
|
||||||
["parking"] = 5,
|
parking = 5,
|
||||||
["parking_aisle"] = 5,
|
parking_aisle = 5,
|
||||||
["driveway"] = 5,
|
driveway = 5,
|
||||||
["drive-through"] = 5
|
["drive-through"] = 5
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -53,67 +105,67 @@ service_speeds = {
|
|||||||
|
|
||||||
-- max speed for surfaces
|
-- max speed for surfaces
|
||||||
surface_speeds = {
|
surface_speeds = {
|
||||||
["asphalt"] = nil, -- nil mean no limit. removing the line has the same effect
|
asphalt = nil, -- nil mean no limit. removing the line has the same effect
|
||||||
["concrete"] = nil,
|
concrete = nil,
|
||||||
["concrete:plates"] = nil,
|
["concrete:plates"] = nil,
|
||||||
["concrete:lanes"] = nil,
|
["concrete:lanes"] = nil,
|
||||||
["paved"] = nil,
|
paved = nil,
|
||||||
|
|
||||||
["cement"] = 80,
|
cement = 80,
|
||||||
["compacted"] = 80,
|
compacted = 80,
|
||||||
["fine_gravel"] = 80,
|
fine_gravel = 80,
|
||||||
|
|
||||||
["paving_stones"] = 60,
|
paving_stones = 60,
|
||||||
["metal"] = 60,
|
metal = 60,
|
||||||
["bricks"] = 60,
|
bricks = 60,
|
||||||
|
|
||||||
["grass"] = 40,
|
grass = 40,
|
||||||
["wood"] = 40,
|
wood = 40,
|
||||||
["sett"] = 40,
|
sett = 40,
|
||||||
["grass_paver"] = 40,
|
grass_paver = 40,
|
||||||
["gravel"] = 40,
|
gravel = 40,
|
||||||
["unpaved"] = 40,
|
unpaved = 40,
|
||||||
["ground"] = 40,
|
ground = 40,
|
||||||
["dirt"] = 40,
|
dirt = 40,
|
||||||
["pebblestone"] = 40,
|
pebblestone = 40,
|
||||||
["tartan"] = 40,
|
tartan = 40,
|
||||||
|
|
||||||
["cobblestone"] = 30,
|
cobblestone = 30,
|
||||||
["clay"] = 30,
|
clay = 30,
|
||||||
|
|
||||||
["earth"] = 20,
|
earth = 20,
|
||||||
["stone"] = 20,
|
stone = 20,
|
||||||
["rocky"] = 20,
|
rocky = 20,
|
||||||
["sand"] = 20,
|
sand = 20,
|
||||||
|
|
||||||
["mud"] = 10
|
mud = 10
|
||||||
}
|
}
|
||||||
|
|
||||||
-- max speed for tracktypes
|
-- max speed for tracktypes
|
||||||
tracktype_speeds = {
|
tracktype_speeds = {
|
||||||
["grade1"] = 60,
|
grade1 = 60,
|
||||||
["grade2"] = 40,
|
grade2 = 40,
|
||||||
["grade3"] = 30,
|
grade3 = 30,
|
||||||
["grade4"] = 25,
|
grade4 = 25,
|
||||||
["grade5"] = 20
|
grade5 = 20
|
||||||
}
|
}
|
||||||
|
|
||||||
-- max speed for smoothnesses
|
-- max speed for smoothnesses
|
||||||
smoothness_speeds = {
|
smoothness_speeds = {
|
||||||
["intermediate"] = 80,
|
intermediate = 80,
|
||||||
["bad"] = 40,
|
bad = 40,
|
||||||
["very_bad"] = 20,
|
very_bad = 20,
|
||||||
["horrible"] = 10,
|
horrible = 10,
|
||||||
["very_horrible"] = 5,
|
very_horrible = 5,
|
||||||
["impassable"] = 0
|
impassable = 0
|
||||||
}
|
}
|
||||||
|
|
||||||
-- http://wiki.openstreetmap.org/wiki/Speed_limits
|
-- http://wiki.openstreetmap.org/wiki/Speed_limits
|
||||||
maxspeed_table_default = {
|
maxspeed_table_default = {
|
||||||
["urban"] = 50,
|
urban = 50,
|
||||||
["rural"] = 90,
|
rural = 90,
|
||||||
["trunk"] = 110,
|
trunk = 110,
|
||||||
["motorway"] = 130
|
motorway = 130
|
||||||
}
|
}
|
||||||
|
|
||||||
-- List only exceptions
|
-- List only exceptions
|
||||||
@ -676,7 +728,7 @@ function way_function(way, result)
|
|||||||
if handle_default_mode(way,result) == false then return end
|
if handle_default_mode(way,result) == false then return end
|
||||||
if handle_blocking(way,result) == false then return end
|
if handle_blocking(way,result) == false then return end
|
||||||
if handle_access(way,result,data) == false then return end
|
if handle_access(way,result,data) == false then return end
|
||||||
if handle_hov(way,result) == false then return false end
|
if handle_hov(way,result) == false then return end
|
||||||
if handle_ferries(way,result) == false then return end
|
if handle_ferries(way,result) == false then return end
|
||||||
if handle_movables(way,result) == false then return end
|
if handle_movables(way,result) == false then return end
|
||||||
if handle_service(way,result) == false then return end
|
if handle_service(way,result) == false then return end
|
||||||
|
10
profiles/lib/sequence.lua
Normal file
10
profiles/lib/sequence.lua
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
-- Sequence of items
|
||||||
|
-- Ordered, but no have to loop through items to check for inclusion.
|
||||||
|
-- Currently the same as a table.
|
||||||
|
|
||||||
|
|
||||||
|
function Sequence(source)
|
||||||
|
return source
|
||||||
|
end
|
||||||
|
|
||||||
|
return Sequence
|
23
profiles/lib/set.lua
Normal file
23
profiles/lib/set.lua
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
-- Set of items
|
||||||
|
-- Fast check for inclusion, but unordered.
|
||||||
|
--
|
||||||
|
-- Instead of having to do:
|
||||||
|
-- whitelist = { 'apple'=true, 'cherries'=true, 'melons'=true }
|
||||||
|
--
|
||||||
|
-- you can do:
|
||||||
|
-- whitelist = Set { 'apple', 'cherries', 'melons' }
|
||||||
|
--
|
||||||
|
-- and then use it as:
|
||||||
|
-- print( whitelist['cherries'] ) => true
|
||||||
|
|
||||||
|
function Set(source)
|
||||||
|
set = {}
|
||||||
|
if source then
|
||||||
|
for i,v in ipairs(source) do
|
||||||
|
set[v] = true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return set
|
||||||
|
end
|
||||||
|
|
||||||
|
return Set
|
Loading…
Reference in New Issue
Block a user