alinmindroc/valhalla_traffic_poc

Generate-live-traffic

Closed this issue · 5 comments

Hi,
another question. Does valhalla_traffic_demo_utils --generate-live-traffic assign a speed to all edges in a specific tile?
Also, it seems that edges with small speeds are more preferred than ones with higher speeds.
Best regards
Adrian

Hello,

That's true, you can see the part that does it in this for loop: https://github.com/alinmindroc/valhalla_traffic_poc/blob/main/valhalla_code_overwrites/src/mjolnir/valhalla_traffic_demo_utils.cc#L128-L130

As this was intended as a demo, I never got into how to actually differentiate between the different edges in a tile, but it is possible.
Routing should prefer edges with higher speeds on average, as it's trying to optimise for duration. But of course depending on the road network and traffic levels, edges with lower speeds can be chosen if they lead to an overall lower duration.

Hi,
so I went through the code and as far I understand it all TrafficSpeeds are written in the corresponding gph file in the tar file. How are the edges differentiated inside the tile? I thought from the level/tile/id format, that the ID should be in the TrafficSpeed struct, too. But it seems that the valhalla ID corresponds to the number of record (i.e. index) inside of the gph file. Is that true?
If so, it would mean that I would have to set all the speeds for the edges in a tile to zero except for those, where I know the current traffic speeds, right?
Best regards

I'm afraid I never got that far into the details of how traffic is saved, or I can't remember at the moment as I didn't actively maintain this.
I would look on the Valhalla discussions page for the answer to this: https://github.com/valhalla/valhalla/discussions

If so, it would mean that I would have to set all the speeds for the edges in a tile to zero except for those, where I know the current traffic speeds, right?

Hi, you can't set to zero, see valid_speed() , value must be 5 < speed < 252.
Just skip edges if where no traffic.

I've set the edge where no traffic is to: UNKNOWN_TRAFFIC_SPEED_RAW
So what I've found out is that the ID of an edge corresponds to the record number in the gph tile file.
Now I am able to only set specific edges in a tile.
Thanks