Created
March 28, 2023 05:04
-
-
Save thehappycheese/eb2931ea86a07c5b8149908f528cb9cb to your computer and use it in GitHub Desktop.
Function to calculate approximate lane offset from carriageway and xsp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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