I am writing an application which has ca. 7000 european restaurants in the database and I want to show a list of the nearest ones to the user, for example all of them which are in a radius of 5km to the user.
I could do the search on the server but it then requires internet. Is it possible to save the data on the iPhone and query the database? I can't find any references for something like that in core data or iPhones SQLite.
Do I really need to program it myself with Pythagoras and stuff and calculate the distance to every restaurant on every query? Or is there some other way?
[update] I'd like to use it like I do already on the server (but to do it on the iPhone): SELECT * FROM restaurants WHERE ST_Distance_Sphere(geo, ST_GeomFromText(POINT(55.98767 57.12345), -1)) < 5000
I want the user to be able to find a restaurant even if she has no internet connection, for example when you're in a foreign country.