Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I represent a road system in software?

I'm looking to do some traffic simulation as a side project but I'm having trouble coming up with ideas for how I should represent the road itself. I like the idea of using a series of waypoints (straight lines using lat/long coords) but it seems difficult to represent different lanes of traffic using this method. I've also been looking at some of the other traffic-simulation questions and one of them mentions using a bitmap but I'm having trouble deciding how this would allow me to easily assign real world lengths to road segments and lane widths, etc. Does anyone have any helpful hints or other ideas that would allow a car to exist at a specific point on a road and be able to switch lanes, etc?

like image 999
Joe Phillips Avatar asked Dec 28 '25 21:12

Joe Phillips


1 Answers

I would start with a grid of connected nodes. A node would represent a change in the road condition like a crossing, a beginning or ending lane, a widening of the road itself etc. Either you do complex connections that store all information (lanes in both directions? how many lanes per direction? lane properties etc) or you save one connection for each lane. To be sure that 2 connections on different sides of a node are related to the same lane, you can use lane-ids on a per node base.

This way you have a graph you can run calculations on and you have all data to visualize the whole net.

like image 176
marsbear Avatar answered Dec 31 '25 00:12

marsbear