Search code examples
androidserverlocationproximity

Proximity alert for locations saved at server


I did some search but could not find a suitable answer.

My App should compare with multiple locations for proximity. This means I will not be able to save all the locations into my app to confirm the proximity using locationManager. I want the proximity confirmation to be done in the server

What would be the best way to implement this?

Would it be sensible if the app asks for proximity confirmation every time the devices moves around?


Solution

  • I would try a different approach, since location updates from GPS are made once per second, and I don't think it's a good idea to ask the server each second for proximity if you have a large amount of devices.
    Think of this idea -

    1. Get the device's initial location and send it to the server.
    2. Decide on a sensible radius that the device will stay within it for the next 5-10 minutes. Also make sure that you don't have "too many" points in that radius, or you can narrow the radius in that case. It's up to you to decide the radius and the number of points, depending on your usage, number of points etc.
    3. Send form the server all the locations within that radius to the device.
    4. Let the device calculate the proximity by itself.
    5. When the device moves out of the initial radius - update the server and get the new relevant locations. This can be done easily - call the radius r. Save the initial location of the device, and calculate the distance between the current and initail location. When it is "close enough" to r - update the server.