I have a built-in database in my application that has all the latitude and longitude of some interesting points, and I need to know my distance from these points (get my position using GPS). My problem: I just realized that SQLite cannot calculate the distance using the query that I have, because it does not calculate trigonometry functions (SIN, COS ...). I tried to avoid calculating these distances programmatically with this query:
NSLog(@"SELECT ((ACOS(SIN(%@ * PI() / 180) * SIN(lat * PI() / 180) + COS(%@ * PI() / 180) * COS(lat * PI() / 180) * COS((%@ β lon) * PI() / 180)) * 180 / PI()) * 60 * 1.1515) AS `distance` FROM `members` HAVING `distance`<='1000β² ORDER BY `distance`", Latitude,Latitude, Longitude);
Does anyone have a solution?
Hello!
source share