getEdgeLaneConfig
Definition
-- @/lua/vehicle/ai.lua:1257
-- Returns the lane configuration of an edge as traversed in the fromNode -> toNode direction
-- if an edge does not have lane data they are deduced from the node radii
local function getEdgeLaneConfig(fromNode, toNode)
local lanes
local edge = mapData.graph[fromNode][toNode]
if edge.lanes then
lanes = edge.lanes
else -- make up some lane data in case they don't exist
if edge.oneWay then
local numOfLanes = numOfLanesFromRadius(mapData.radius[fromNode], mapData.radius[toNode])
lanes = string.rep("+", numOfLanes)
else
local numOfLanes = max(1, math.floor(numOfLanesFromRadius(mapData.radius[fromNode], mapData.radius[toNode]) * 0.5))
if mapmgr.rules.rightHandDrive then
lanes = string.rep("+", numOfLanes)..string.rep("-", numOfLanes)
else
lanes = string.rep("-", numOfLanes)..string.rep("+", numOfLanes)
end
end
end
return edge.inNode == fromNode and lanes or flipLanes(lanes) -- flip lanes string based on inNode data
end
Callers
@/lua/ge/map.lua
-- if an edge does not have lane data they are deduced from the node radii
local function getEdgeLaneConfig(node1, node2)
local lanes
if not data.lanes then
data.lanes = getEdgeLaneConfig(prevName, nodeName)
end
if not data.lanes then
data.lanes = getEdgeLaneConfig(prevName, nodeName)
end
if not data.lanes then
data.lanes = getEdgeLaneConfig(wp1, wp2)
end
@/lua/vehicle/ai.lua
local function roadNaturalContinuation(wp1, wp2)
local inLaneConfig = getEdgeLaneConfig(wp1, wp2)
local inRadiuswp2, inRadiuswp1 = mapData:getEdgeRadii(wp2, wp1)
if k ~= wp1 then
local outLaneConfig = getEdgeLaneConfig(wp2, k)
local numOfOutLanes = numOfLanesInDirection(outLaneConfig, '+')
if nodeId ~= newNode.nextNodeInPath and nodeId ~= prevNodeInPath then -- and not mapmgr.signalsData.nodes[newNode.id]
local lanes = getEdgeLaneConfig(nodeId, newNode.id)
local thisEdgeInLanes = numOfLanesInDirection(lanes, '+')
if link then
newNode.inEdgeLanes = getEdgeLaneConfig(newNode.prevNodeInPath, newNode.id)
end
newNode.prevNodeInPath = plan[1].wp
newNode.inEdgeLanes = getEdgeLaneConfig(newNode.prevNodeInPath, newNode.id)
end
if k ~= newNode.prevNodeInPath then
if numOfLanesInDirection(getEdgeLaneConfig(newNode.id, k), '+') > 0 then
if nextPosibleNode then
if link then
newNode.outEdgeLanes = getEdgeLaneConfig(newNode.id, newNode.nextNodeInPath)
end
if n1.name then
local lanes = getEdgeLaneConfig(n1.name, n2.name)
rangeLeft, rangeRight = laneRange(lanes)
local normal = (pos2-pos1):cross(biNormal); normal:normalize()
local laneConfig = getEdgeLaneConfig(path[i], path[i+1])
local laneRangeLimLeft, laneRangeLimRight = laneRange(laneConfig)
if opt.driveInLaneFlag then
lanes = getEdgeLaneConfig(wp2, wp1)
rangeLeft, rangeRight = laneRange(lanes)
if opt.driveInLaneFlag then
lanes = getEdgeLaneConfig(wp2, wp1)
rangeLeft, rangeRight = laneRange(lanes)
if route.lastLaneChangeIdx < #route.path then
if numOfLanesInDirection(getEdgeLaneConfig(wp1, wp2), '+') > 1 then
local minNode = roadNaturalContinuation(wp1, wp2)
@/lua/vehicle/controller/tech/roadsSensor.lua
local function getEdgeLaneConfig(inNode, outNode)
local lanes
local p1, p2, p3, p4 = coords[path[1]], coords[path[2]], coords[path[3]], coords[path[4]]
local inLaneConfig = getEdgeLaneConfig(path[2], path[3])
numlane = numOfLanesInDirection(inLaneConfig, '+') local left1, right1 = computeRoadEdgePoints(path[1], p2 - p1)
local p1, p2, p3 = coords[path[1]], coords[path[2]], coords[path[3]]
local inLaneConfig = getEdgeLaneConfig(path[2], path[3])
numlane = numOfLanesInDirection(inLaneConfig, '+') local left1, right1 = computeRoadEdgePoints(path[1], p2 - p1)
local p1, p2 = coords[path[1]], coords[path[2]]
local inLaneConfig = getEdgeLaneConfig(path[1], path[2])
numlane = numOfLanesInDirection(inLaneConfig, '+')