Search code examples
androidparse-platformgeolocationpubnub

What logic is involved when comparing a location to multiple users


Using Android Studio, what sort of things are needed when trying to compare a specific user's location to every other user. For example if there are 1000 simultaneous users, and I want to find the closest one(or farthest) to any given user, what sort of calculations need to be done?

If each user's locations were saved to a DB, where do I start? Is it necessary to compare one location against the 1000 (or more) users to find the closest, or would it make more sense to make some type of cut-off (i.e. only compare users who are within 50km).

It seems overwhelming and I am new to android, so I am unsure where to even start. Parse.com and Pubnub are being used in this project.


Solution

  • Geohashing by User Proximity Tutorial

    I'll reference for you here the geohashing tutorial that walks you through how to build a realtime app that connects users based on relative location. Note that this example is written in JavaScript and not Java/Android. However you can still use this design pattern to determine proximity.

    App Geo Location: https://www.pubnub.com/blog/2014-05-07-geohashing-chat-by-proximity/

    There is also a short video which discusses the Geohasing concept.

    Comparing a Location with Multiple Users

    Adding in Parse SDK and Location Comparison

    Also you can add in this link: Parse reference guide. And a Parse Connector SDK if needed.