Given a database that contains three fields:
Latitude
Longitude
Proximity
Where Lat and Long are GPS coordinates, and Proximity is (some unit – feet? Seconds? Minutes?)
And given the user’s current GPS lat/long…
I want to write a SQL query that will retrieve all rows where the user is within “Proximity” of those rows.
And the trick: This has to work in SQLite, which only supports fairly primitive data types. No cheating and relying on SQL Server (or some other product that provides better geospace functions).
Any suggestions?
Here is a C-based custom function for sqlite [copied from links noted below]. This can be used within an iOS app. It assumes you have columns named latitude and longitude, and calculates the difference between them and any lat/long coordinates you provide. Excellent write-up, works as-is.
EDIT :
Original link http://www.thismuchiknow.co.uk/?p=71 is dead, so as someone mentioned in comment, you can use this link : https://web.archive.org/web/20160808122817/http://www.thismuchiknow.co.uk/?p=71 to get that webpage