Let's say I have an android app that frequently sends current GPS location of the user. If person is driving with bus, I can easily get GPS location of the bus and display it on the map and update it accordingly every 30 seconds.

Let's say that instead of one bus there are 3 buses driving along same route. My problem is to display real time location of every bus on the route. In this case there are X users on every bus all having my android application installed on their phones. Here is the picture that could represent the problem: enter image description here

As you can see, every mobile application will send GPS location of the user to my server. Server receives and saves data.

Based on the server data I should create a web app that should display map whith position of every bus in real time.

One possible way to do this is to to try to cluster GPS data and based on clusters to conclude where is position of every bus. This approach has few problems:

  • This algorithm could be slow if there is lot of data (then I can't update position of every bus every 30 seconds)
  • Second problem is that I don't know number of clusters (buses). There might be 2, 3, 4 or N buses

Is there any other better approach to this problem?


Have the app record the GPS location once per second, save it, and once every 30 seconds, update that trace of the locations over the past 30 seconds. Or, just upload the location every second. The bandwidth requirements for that are small. Then, if you have multiple users in the same location (within a fixed radius, say within 100 ft of each other), and with a velocity within some fixed range (say, between 20-60 mph), declare them to be on a bus together. That should be fast, and doesn't require knowing the number of buses.

This problem doesn't need a solution with a fancy algorithm; straightforward solutions should suffice.

  • $\begingroup$ I'm not quite sure I understand exactly how you would do it. Could you please elaborate a bit? $\endgroup$ – MrD Jul 22 '18 at 15:11
  • $\begingroup$ @MrD, ok, see updated answer. $\endgroup$ – D.W. Jul 22 '18 at 15:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.