0

I'm creating an Android application that needs to find all the points within a given radius of the device. However these locations will be stored in a database either SQL (on a server) or SQLite (for early testing/demo), what I dont want to do is get all the locations and filter down on the device as the could potentially be thousands of points. The locations are stored as two separate fields for latitude and longitude, how could I get only the points from the database that are within a certain radius of a location?

1 Answers1

0

Use a conceptual bounding box around the circle large enough to contain all points on the circle.

For example, a simple box that might work for you:

Assuming the center of the circle is 100,100 with radus 5, you download all points within the box (95,95) (105,105)

Then on the client you can do necessary calculations to determine which subset of points are in your circle

Chris
  • 846
  • 6
  • 16
  • so something a bit like [this?](http://imgur.com/naOSB1g) Where I download everything +- 100m of the centre and then do some client side maths to get the circle? – EatBearsForBreakfast Mar 14 '16 at 19:41
  • Yes that's exactly what I was thinking of. Once you have the list of points you can filter them with a single pass by calculating their distance to the center – Chris Mar 14 '16 at 20:18