Updateing how the access hierarchy is parsed in the car profile. Thx
@EmilTin
This commit is contained in:
		
							parent
							
								
									8e31b8860c
								
							
						
					
					
						commit
						bcddc10b6b
					
				@ -5,6 +5,7 @@ access_tag_whitelist = { ["yes"] = true, ["motorcar"] = true, ["motor_vehicle"]
 | 
				
			|||||||
access_tag_blacklist = { ["no"] = true, ["private"] = true, ["agricultural"] = true, ["forestery"] = true }
 | 
					access_tag_blacklist = { ["no"] = true, ["private"] = true, ["agricultural"] = true, ["forestery"] = true }
 | 
				
			||||||
access_tag_restricted = { ["destination"] = true, ["delivery"] = true }
 | 
					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" }
 | 
				
			||||||
service_tag_restricted = { ["parking_aisle"] = true }
 | 
					service_tag_restricted = { ["parking_aisle"] = true }
 | 
				
			||||||
ignore_in_grid = { ["ferry"] = true, ["pier"] = true }
 | 
					ignore_in_grid = { ["ferry"] = true, ["pier"] = true }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -39,9 +40,20 @@ u_turn_penalty 			= 20
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
-- End of globals
 | 
					-- End of globals
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					--find first tag in access hierachy which is set
 | 
				
			||||||
 | 
					function find_access_tag(source)
 | 
				
			||||||
 | 
						for i,v in ipairs(access_tags_hierachy) do 
 | 
				
			||||||
 | 
							local tag = source.tags:Find(v)
 | 
				
			||||||
 | 
							if tag ~= '' then --and tag ~= "" then
 | 
				
			||||||
 | 
								return tag
 | 
				
			||||||
 | 
							end
 | 
				
			||||||
 | 
						end
 | 
				
			||||||
 | 
						return nil
 | 
				
			||||||
 | 
					end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
function node_function (node)
 | 
					function node_function (node)
 | 
				
			||||||
  local barrier = node.tags:Find ("barrier")
 | 
					  local barrier = node.tags:Find ("barrier")
 | 
				
			||||||
  local access = node.tags:Find ("access")
 | 
					  local access = find_access_tag(node)
 | 
				
			||||||
  local traffic_signal = node.tags:Find("highway")
 | 
					  local traffic_signal = node.tags:Find("highway")
 | 
				
			||||||
  
 | 
					  
 | 
				
			||||||
  --flag node if it carries a traffic light
 | 
					  --flag node if it carries a traffic light
 | 
				
			||||||
@ -50,22 +62,23 @@ function node_function (node)
 | 
				
			|||||||
	node.traffic_light = true;
 | 
						node.traffic_light = true;
 | 
				
			||||||
  end
 | 
					  end
 | 
				
			||||||
  
 | 
					  
 | 
				
			||||||
  if "" ~= barrier and obey_bollards then
 | 
						-- parse access and barrier tags
 | 
				
			||||||
    node.bollard = true; -- flag as unpassable and then check
 | 
						if access  and access ~= "" then
 | 
				
			||||||
 | 
							if access_tag_blacklist[access] then
 | 
				
			||||||
    if "yes" == access then
 | 
								node.bollard = true
 | 
				
			||||||
      node.bollard = false;
 | 
							end
 | 
				
			||||||
 | 
						elseif barrier and barrier ~= "" then
 | 
				
			||||||
 | 
							if barrier_whitelist[barrier] then
 | 
				
			||||||
			return
 | 
								return
 | 
				
			||||||
 | 
							else
 | 
				
			||||||
 | 
								node.bollard = true
 | 
				
			||||||
 | 
							end
 | 
				
			||||||
	end
 | 
						end
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
    --reverse the previous flag if there is an access tag specifying entrance
 | 
						return 1
 | 
				
			||||||
	if node.bollard and (barrier_whitelist[barrier] or access_tag_whitelist[access]) then
 | 
					 | 
				
			||||||
	  node.bollard = false;
 | 
					 | 
				
			||||||
	  return
 | 
					 | 
				
			||||||
	end
 | 
					 | 
				
			||||||
  end
 | 
					 | 
				
			||||||
end
 | 
					end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
function way_function (way, numberOfNodesInWay)
 | 
					function way_function (way, numberOfNodesInWay)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  -- A way must have two nodes or more
 | 
					  -- A way must have two nodes or more
 | 
				
			||||||
@ -87,26 +100,27 @@ 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 access = way.tags:Find("access")
 | 
					    local access = find_access_tag(way)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  -- Second parse the way according to these properties
 | 
					  -- Second, parse the way according to these properties
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if ignore_areas and ("yes" == area) then
 | 
						if ignore_areas and ("yes" == area) then
 | 
				
			||||||
		return 0
 | 
							return 0
 | 
				
			||||||
	end
 | 
						end
 | 
				
			||||||
		
 | 
							
 | 
				
			||||||
  	-- Check if we are allowed to access the way
 | 
					  	-- Check if we are allowed to access the way
 | 
				
			||||||
    if access_tag_blacklist[access] ~=nil and access_tag_blacklist[access] then
 | 
					    if access_tag_blacklist[access] then
 | 
				
			||||||
		return 0;
 | 
							return 0
 | 
				
			||||||
    end
 | 
					    end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
  -- Check if our vehicle types are forbidden
 | 
					  -- Check if our vehicle types are forbidden
 | 
				
			||||||
    for i,v in ipairs(access_tags) do 
 | 
					--    for i,v in ipairs(access_tags) do 
 | 
				
			||||||
      local mode_value = way.tags:Find(v)
 | 
					--      local mode_value = way.tags:Find(v)
 | 
				
			||||||
      if nil ~= mode_value and "no" == mode_value then
 | 
					--      if nil ~= mode_value and "no" == mode_value then
 | 
				
			||||||
	    return 0;
 | 
					--	    return 0;
 | 
				
			||||||
      end
 | 
					--      end
 | 
				
			||||||
    end
 | 
					--    end
 | 
				
			||||||
  
 | 
					  
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
  -- Set the name that will be used for instructions  
 | 
					  -- Set the name that will be used for instructions  
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user