IPhone - 按纬度和经度的SQLite距离 [英] IPhone - SQLite distance by Latitude and Longitude

查看:141
本文介绍了IPhone - 按纬度和经度的SQLite距离的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的应用程序中有一个嵌入式数据库,它具有所有纬度和经度的一些感兴趣的点,我需要知道我与这些点的距离(使用GPS获取我的位置)。
我的问题是:我刚刚发现SQLite无法使用我有的查询计算距离,因为它不计算三角函数(SIN,COS ...)。我尝试避免使用此查询以编程方式计算这些距离:

  NSLog(@SELECT((ACOS(SIN(% *(PI *)/ 180)* SIN(lat * PI()/ 180)+ COS(%@ * PI()/ 180)* COS(lat * PI()/ 180)* COS *距离`'1000''ORDER BY`distance`,纬度,经度,纬度); 

有人有解决方案吗?

问候!

解决方案

在Objective C中做到这一点。



有同样的问题: http://www.thismuchiknow.co.uk/?p=71


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

这篇关于IPhone - 按纬度和经度的SQLite距离的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆