我有一个包含兴趣点的数据库,所有兴趣点都有一个地址。
我想知道从给定位置获取所有附近 POI 的方法/名称/调用是什么。
我知道我至少需要将所有地址转换为 LAT / LON 坐标,但我的问题是:
对于给定的 LAT / LONG,我如何从数据库/数组中获取距离附近的 POI,例如:
您是这里 0,0
2 公里半径内最近的兴趣点有:
- POI A(1.1 公里处)
- POI C(1.3 公里处)
- POI F(1.9 公里处)
我不知道应该查看什么才能得到我想要的东西:-(
非常感谢任何帮助。
谢谢
I have a database with Points of Interest that all have an address.
I want to know what is the method/name/call to get all nearby POIs from a given position.
I understand that I need to convert all my addresses to LAT / LON coordinates at least, but my question is:
for a given LAT / LONG how do I get from the database/array what POIs are nearby by distance, for example:
You are here 0,0
nearest POIs in a 2km radius are:
- POI A (at 1.1 Km)
- POI C (at 1.3 Km)
- POI F (at 1.9 Km)
I have no idea what should I look into to get what I want :-(
Any help is greatly appreciated.
Thank you
发布评论
评论(1)
使用 大圆距离 href="http://en.wikipedia.org/wiki/Haversine_formula" rel="nofollow noreferrer">haversine 公式。您可能需要进一步阅读并查看计算距离、方位等的实现纬度/经度点之间,作者:Chris Veness。
如果您只有少数 POI,您可以简单地计算从您的点到每个 POI 的大圆距离。然后简单地按距离对结果列表进行排序。
但是,如果您将拥有许多 POI,则应考虑使用具有空间索引功能的数据库。 MySQL,PostgreSQL 和 SQL Server 2008 都具有地理空间功能(本机或通过扩展),其中包括空间索引和半正弦公式的实现。
Calculating the great-circle distance between two latitude/longitude coordinates is easy with the haversine formula. You may want to read further and check out the implementation at Calculate distance, bearing and more between Latitude/Longitude points by Chris Veness.
If you will only have a handful of POIs, you can simply calculate the great-circle distance from your point to each POI. Then simply sort the result list by the distance.
However, if you will be having many POIs, you should consider using a database with spatial indexing capabilities. MySQL, PostgreSQL and SQL Server 2008 all have geo-spatial features (either natively or via extensions), which include spatial indexing and implementations of the haversine formula.