获取随后的N最接近地球点 [英] Get next N nearest Geo-Points

查看:163
本文介绍了获取随后的N最接近地球点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的Andr​​oid应用程序与地理pointes的(纬度和经度是十进制度值),约1000个数据库表。我需要选择最接近20点的一些特定的地理点。

I have in my android application a database table with geo pointes (lat and lon are decimal degree values), about 1000 points. And I need to select 20 nearest point to some given geo point.

我在#1找到了答案如何计算两个地理点之间的距离,很开心,直到我试着写我的查询。我发现了,它不可能在Android系统内置的SQLite使用trignometrical功能。

I've found at Stackoverflow the answer how to compute distance between two geo points and was very happy, till I tried to write my query. I've found out, that it's not possible to use trignometrical functions in built-in sqlite of android.

但后来我有一个想法。我并不真的需要计算的距离。近一个点到另一个在他们的地理坐标较小的差异应该是。

But then I've got an Idea. I don't really need to compute a distance. The near a point is to another one the smaller difference in their geo coordinates should be.

我怎么能利用这一点?难道是足够订购保存点由(lat_0 - lat_n)?^ 2 +(lon0-lon_n)^ 2,其中lat_0和lon_0是给定点的地理坐标

How could I use this fact? Would it be enough to order saved points by (lat_0 - lat_n)^2 + (lon0-lon_n)^2, where lat_0 and lon_0 are geo coordinates of a given point?

感谢您,

穆尔

UPD

因此​​,要获得我的问题的答案的最好方法是测试方法,我上面描述。

So, the best way to get an answer for my question was to test approach I describe above.

它的工作原理pretty的很好,但没有真正完全比较精确的距离。

It works pretty well but not really exactly compared to exact distance.

因此​​,如果您只需要计算距离,该解决方案是好的,但在我的情况我还需要订餐站距离和不能使用此解决方案。

So if you just need to compute a distance, this solution is ok, but in my case I also needed to order stations by distance and couldn't use this solution.

我要感谢约翰在CashCommons和菲利普。谢谢你们

My thanks go on John at CashCommons and Philip. Thank you guys

推荐答案

如果你点一个城市内的分隔(或多或少),这近似将正常工作。近似​​分崩离析,如果你去世界各地,虽然。

If your points are separated within a city (more or less), that approximation will work fine. The approximation falls apart if you go worldwide, though.

编辑:基于以下菲利普的评论,你应该扩展的组件之一。德约50度,北纬,因此通过(COS 50度)会做的更好乘以经度。

Based on Philip's comment below, you should scale one of the components. Germany is about 50 degrees north latitude, so multiplying the longitude by (cos 50 deg) will do better.

这篇关于获取随后的N最接近地球点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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