Skip to content
ServicesPortfolioBlogAboutContactPolski

Blog5 min read

The MZK detour map. How I checked 196 routes

196

line variants that passed the automated tests

In short

For the reconstruction of Peowiaków Street I made an unofficial map of MZK bus detours in Zamość. I describe where the data came from, how I calculated the routes and how I checked all 196 line variants before showing the map to anyone.

When Peowiaków Street was closed, MZK published an announcement and a detour map. It is a good source, but it is hard to read from it which way a specific line goes and whether the bus will stop at your stop. The map at objazdy.tfagency.pl answers that once you pick a line number: it shows the detour route, the skipped stops and the departure times. It is an unofficial project, made on my own initiative, not by MZK.

Where the data comes from

  • Routes and timetables from before the works, from kiedyprzyjedzie.pl: the order of stops and the times for every trip.
  • The MZK announcement and map: how buses get around the closed section. I only changed routes where these materials said so.
  • OpenStreetMap road data and the OSRM routing engine, which turns a list of stops into a line running along real streets.

One detour model for every line

Instead of drawing each line by hand, I wrote one model. For every trip, the program looks for the stop where the bus enters the detour, the path from the MZK map, and the stop where it rejoins its route. It rejects variants that drive along the closed section, turn around in the middle of the road or go round in loops.

Which stops are served follows from the geometry: a stop must be close to the new route and on the right-hand side in the direction of travel. The only stop closed by the works itself is Peowiaków - Cmentarz.

How I checked 196 variants

A bus line is not a single route. It has trips in both directions, short trips, and trips to and from the depot. That came to 196 variants, 122 of which go through the detour. You cannot reliably check that by eye, so I wrote automated tests. For every variant they check that:

  • the route does not drive along the closed section,
  • it does not turn around in the detour area, e.g. at Plac Wolności or the Old Town,
  • it covers at least 90% of the MZK detour path, if it goes that way,
  • a stop is skipped only when the route really does not pass it,
  • every served stop has a time, and the times go up in order.

The result: 196 out of 196 variants with no errors. But tests are not everything, because a program can accept a route that looks absurd on the map. So I took screenshots of all 196 routes and looked through them. Among other things, I looked for “hooks”: detours into a side street just to touch a stop on the other side of the road.

What I do not know for sure

There is no timetable for the new sections, so those times are calculated and marked with “~”. They are an estimate, not the MZK timetable. A few “there and back” runs into villages match the order of stops but I have not checked them on the ground. I say this openly, because a map that pretends to be certain is worse than no map.

Why I am writing about it

Because the same rule applies to every website I make: looking good is not enough. The form has to actually send, the prices have to match, and data in one place must not contradict data in another. If you have an idea for a tool that calculates, collects or shows something on a map, get in touch. We can talk about what is possible.