Software · Nº 004

UrbanetricLive product

A traffic simulator for Cork, for councils, engineers and consultants who need to know what a road change will do before it is built.

Testing a road change usually needs expensive software and a specialist. This puts all of Cork in a web app.

Software I built and run myself, not a demo. Its site, urbanetric.com, is being relaunched, so for now you can see it in the recording and screenshots here.

The public demo: Cork’s road network exactly as the simulator sees it, which anyone can pan and zoom. This is the map, not a simulation. Running simulations on top of it is the full product, behind a sign-in. Map data © OpenStreetMap contributors.

The problem

Close a street, add a lane or build a new estate, and the traffic goes somewhere else. Working out where usually takes expensive desktop modelling software, licensed per seat, and a specialist consultant to run it. So smaller changes, like a one-way system on a few back streets or a diversion for roadworks, often don't get modelled at all.

What I built

A web app with the whole of Cork's road network in it, taken from OpenStreetMap: the streets, junctions, lane counts, speed limits and turn restrictions. You open a scenario, change the map, and run a simulated day.

  • Change the roads. Close a road, change its speed or the number of lanes each way, choose whether cars, buses or bikes can use it, split a road in two, or join two junctions with a new one.
  • Add what makes traffic. Drop a housing development or an event venue on the map and it connects itself to the nearest junction.
  • Run the day. About 140,000 simulated people, built from census figures on where people live and how they get to work, each take their own route. The simulator replays the same day over and over, letting people change route, until the traffic settles the way it would once a change has bedded in.
  • Watch and compare. Play the day back on the map with queues building along the roads, then put two scenarios side by side.

There is nothing to install. You use it in a web browser, and the simulation itself runs on the server.

The Urbanetric landing page: “Test a road change on Cork before it’s built”, beside a map of Cork’s road network.
The landing page.
A section of the landing page in three steps: build the network, generate demand, run and compare.
How it works, from the landing page.
The landing page’s list of edits: close a street, add or remove a lane, build a new link, roadworks and weather, with signal retiming and bus lanes marked planned.
The edits you can make. Signal retiming and dedicated bus and cycle lanes are marked as planned.
The public demo: a map of Cork city centre with the simulator’s road network drawn over it.
The public demo, with no sign-in. Map data © OpenStreetMap contributors.
The Urbanetric landing page on a phone.
The landing page on a phone.
The public demo map of Cork on a phone.
The public demo on a phone.

Under the hood

For anyone curious about how it works:

  • Rust on the server. The simulation engine, the web server (built on Axum and Tokio) and the workers that run simulations are all Rust. Each run is picked up by its own worker process, so several can run at once without slowing the site down.
  • A queue-based simulation. The engine works in the style of MATSim, the research simulator transport planners use. Each road is a queue with a capacity, cars move from one road to the next in short, fixed time steps, and traffic signals hold them at junctions.
  • Fast route finding. Routes are found with customizable contraction hierarchies, a technique that prepares the road network in advance so that 140,000 people's routes can be worked out again quickly after every edit, in parallel across the processor's cores.
  • Real data underneath. The road network and the population are stored in PostgreSQL with PostGIS. The network comes from OpenStreetMap, and the people come from the CSO's census small-area statistics, including how people in each area travel.
  • The map in the browser. While a simulation runs, the server streams it to the browser over a WebSocket. The front end is TypeScript with Lit, and the map is drawn with MapLibre from a single file of vector map tiles.

What's next

  • Traffic light sequencing: setting the signal timings at individual junctions.
  • More ways of getting around, simulated alongside cars.
  • Real-time public transport data.

Why it's in a portfolio for small businesses

A café doesn't need a traffic simulator. It's here because it's the hardest thing I've built, and it does the job properly. If I can build this, I can build the booking system, quote calculator or internal tool your business has been putting off.

Want one like it?

I'm in Cork, Ireland. Send me an email and I'll reply the same day. If it's easier to talk it through, we'll pick a time for a call. Or write out what you need.