Skip to content

Instantly share code, notes, and snippets.

@thehappycheese
Created March 28, 2023 05:04
Show Gist options
  • Save thehappycheese/eb2931ea86a07c5b8149908f528cb9cb to your computer and use it in GitHub Desktop.
Save thehappycheese/eb2931ea86a07c5b8149908f528cb9cb to your computer and use it in GitHub Desktop.
Function to calculate approximate lane offset from carriageway and xsp
def calculate_nickmapbi_offset(carriageway, xsp):
return {
"L":{
f"L{num+1}": +3.5/2 - 3.5*num for num in range(0,7)
},
"R":{
f"R{num+1}": -3.5/2 + 3.5*num for num in range(0,7)
},
"S":{
f"L{num+1}": -3.5/2 - 3.5*num for num in range(0,7)
}|{
f"R{num+1}": +3.5/2 + 3.5*num for num in range(0,7)
}
}.get(carriageway,{}).get(xsp,0)
tests = [
["L","L1"],
["L","L2"],
["R","R1"],
["R","R2"],
["S","L1"],
["S","R1"],
]
for [cwy, xsp] in tests:
print(f"{cwy},{xsp} = {calculate_nickmapbi_offset(cwy,xsp)}")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment