CityFlow
CityFlow copied to clipboard
How to retrieve lane length or lane occupation
I need to compute the lane occupation, and for it, I need to retrieve the maximum number of vehicles that a lane can have at a given time. The roadnet.json files only store the lane width, which is not useful.
Is there a way to get this value using the API?
Thanks!
You can calculate it by the lane width, vehicle width, and min vehicle gap, which are given in the roadnet.json and flow.json. For now, we don't have such an API, you can modify "src/cityflow.cpp" and re-compile the C++ code to add one.
I believe I should calculate with lane length, vehicle length and min vehicle gap. However, the lanes only have the width attribute in the roadnet.json files. The workaround seems to be computing the lane length calculating the distance between the two points (x,y) of the road...
- In Roadnet.json, you can find the point of the intersection and the road, and compute the distance. The actual lane length = this distance - the width of the intersection. For example, the intersection point is (0,0) and the road points are (0,-150) and (0,0), then the distance is 150m. If the intersection width (half of the intersection's edge) is 15m, then the lane length is 135m.
- Set the traffic light to red and count the queuing cars 🤣