Now in many cities there are services that show the movement of public transport on the map. Our mound is no exception. That's just one problem: to see where the buses are going, you need a computer or at least a powerful smartphone that can load the entire map. If you move a lot around the city, then the maximum that you have at hand is a regular phone, on which there can be no talk of a map.
Therefore, last year we created a
service that turns information about the movement of buses into a plain text format that is quite accessible to any average phone or smartphone. Under the cut, I'll tell you about the main stages of development.
Dream
It all starts with a dream. Many (including myself) would not like to waste their time at bus stops, looking for their favorite bus. Especially in the 30-degree frost. Especially when two of the five buses on the route suddenly (!!) broke down.
')
How good it would be at such a moment to look at the phone where your bus is traveling. Maybe it is not worth waiting and it is easier to travel with a transfer? Or, on the contrary, do not jump into the first bus, but wait a bit, but leave on the one that will pass as needed. Or (aerobatics) plan to leave the house so as not to stand at all at the bus stop.
Action plan
Of course, in our city there is a map on which buses ride in real time. But attempts to open it in my (rather old) smartphone ended in nothing - it does not pull it. Then a sensible thought occurred to me - what if the data from the card was converted into plain text? Like this:
b. Sunny -> 1st Neighborhood
537 : -> --- Deli Sunday
1st microdistrict -> b. Solar
446 : â„–6> ---- 5th microdistrict
at the end
X 442 KE: 1st microdistrict final
After all, all we really need to know is the direction of the buses, between which stops each is located, and, perhaps, the state number is also useful. It turns out that not so much information - will pull any phone. Naturally, an important factor is the volume of mobile traffic - in this case it is also minimal.
Thus, we need a service that would be able to transform the position of buses on the map into text.
Algorithms
To develop the algorithm, of course, we need the initial data: stops (coordinates, names) and the routes themselves (coordinates of all segments). Connections were made to stops with routes, segments with driving directions, etc. All put in MySQL tables.
In the beta version, the algorithm was the simplest: we take the geo-point corresponding to the bus, we find the sql-query, to which of the segments of the route it is closest. Further along the segment we restore the stops between which the bus is traveling and the direction of its movement. The idea is good, but practice has shown that it works only for cubic buses in a vacuum. In reality, buses begin to "jump" from one direction to the opposite and the opposite. It is connected, as you might guess, with real traffic - detours, crossroads, turns and the like.
After about a month, the algorithm was finalized. We noticed that gps trackers, in addition to the coordinates, also give the current direction of movement (azimuth). Roughly speaking, azimuth is the angle between the direction to the north and the arrow characterizing the location of the bus. If we add this information to our first algorithm, then we’ll get much better. Indeed, even taking into account all the “wiggles” of the bus, its azimuth can not change more than 50-60 degrees from the real direction of movement. Now we can quite accurately determine where and where each bus goes.
Bus azimuth determination:
Check accuracy
Naturally, we could not help but check the accuracy of our algorithm. Generally speaking, for a perfect test, we would have to travel on buses, and immediately look on the phone, correctly or not determined by the direction. Therefore, we went a little indirect way.
Suppose that two people after a short period of time made one request for the same route. It is obvious that for such a small period no bus will have time to change the direction to the opposite (we exclude those that are on the final ones). If our algorithm shows that some of the buses suddenly changed direction, then this is a calculation error.
Based on this logic, we made a script that went through all the accumulated data. Were taken data pairs, separated from each other by no more than 2 minutes. On different routes such pairs turned out from three hundred to several thousand. The calculated accuracy (number of errors / total number of pairs) turned out to be quite good - 94-98%. Apparently, the algorithm sometimes fails, but for the current level it is quite enough. In addition, we recommend users to make 2-3 requests to eliminate such anomalies.
Interface
In terms of interface, the recommendations are quite typical. After some time, we transferred everything to twitter botstrap, so that it was readable on any device - from the simplest phones to powerful tablets.
The route number is driven directly into the address bar, or you can choose a link on the page where all the routes are listed in a row (for someone it’s more convenient). On the page itself, only the update button. Nothing extra.
Interface (view on the desktop):
In addition, there is an ICQ-bot that produces similar answers. It is enough to send him the number of the route of interest.
Statistics
Currently, service attendance is 100-150 people per day, each of which makes 6-8 requests. Perhaps, these figures will seem small to some, but they have been achieved without any investment in advertising. In addition, many moments still require “file finishing” to make the service as useful as possible to people. In the first place we put quality, not attendance.
Development plan
About the most delicious in the end ...
Now "mobile buses" formed the basis of a diploma that makes us one of the students. The essence of the diploma is quite interesting: to calculate traffic jams arising in the city from traffic information, and based on traffic jams, to give recommendations on which route is best to get from point A to point B. It seems to me that at the present time it is extremely important, and not only for passengers, but also for motorists, and all those who strongly depend on the traffic situation (taxi, food delivery, official vehicles, etc.). Closer to May, let's see what we can do - try to unsubscribe at Habré.
Morning traffic jams in Kurgan (data February 14):
Well and, of course, we
are open for discussion if you want to introduce something similar in your city. Enough to spend your time at stops, let's better spend it on something more useful! :-)
PS Frequently asked question
-
Why not make an android application?
- Make the application - it is possible, but it is secondary. The main task we solve is to learn how to convert geodata to text format. As soon as we learn to do this, the output format information will become a matter of technique. It is possible through the browser, it is possible through the ICQ bot, it is possible through the jabber, it is possible through the application ...