CityFlow icon indicating copy to clipboard operation
CityFlow copied to clipboard

How to retrieve lane length or lane occupation

Open LucasAlegre opened this issue 3 years ago • 3 comments

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!

LucasAlegre avatar Mar 24 '21 00:03 LucasAlegre

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.

only-changer avatar Mar 25 '21 06:03 only-changer

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...

LucasAlegre avatar Mar 25 '21 15:03 LucasAlegre

  1. 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.
  2. Set the traffic light to red and count the queuing cars 🤣 image

Sheagu avatar Mar 22 '22 04:03 Sheagu