I have a embedded database in my app that has all Latitude and Longitude of some interested points and I need to know my distance from these points(get my position using GPS). My problem is: I've just figured out that SQLite can't calculate distance using the query that I have because it doesn't calculate trigonometry functions(SIN, COS...). I was trying to avoid calculating these distances programatically using 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 anybody has a solution?
Regards!
Do it in Objective C.
this guy had the same problem: http://www.thismuchiknow.co.uk/?p=71
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With