查询CouchDB以在特定半径内获取poi [英] query CouchDB to get poi within a certain radius

查看:70
本文介绍了查询CouchDB以在特定半径内获取poi的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想用一些POI创建一个CouchDB数据库。
是否可以通过某种方式/查询从给定的经纬度位置获得一定半径(例如50米)内的poi?

I want to create a CouchDB database with some POI's. Is there a way/query to get poi's within a certain radius (lets say 50 meters) from a given lat/long position?

我看到了一个扩展名 https://github.com/couchbase/geocouch ,但这意味着我必须重新编译CouchDB,但是目前,我没有管理员权限。

I saw an extension https://github.com/couchbase/geocouch , but this means I have to recompile CouchDB, but at this moment I don't have admin access to do that.

推荐答案

对于您的用例,我有另一种建议。该建议是使用 geohashes

I have an alternative proposal for your use case. The proposal is to use geohashes.

您可以将位置存储为geohash。哈希的长度取决于您要存储的精度。

You can store the position in the document as a geohash. The lenght of the geohash will depends on the precission you would like to store.

让我们考虑一下您存储的位置具有大约150米的进动。在这种情况下,您将拥有7个字符的哈希,例如 gbsukp7。检查以进行测试。

Let consider that you stored the position with around 150 meters precession. In this case, you'll have a geohash of 7 characters like 'gbsukp7'. Check this for testing.

然后可以按以下方式重新定义地图函数:

Then your map function can be redefined in this way:

function (doc) {
 emit([doc.geohash.substr(0,4), /* 39.1km × 19.5km bounding box */
      doc.geohash.substr(0,5), /* 4.89km ×  4.89km bounding box */
      doc.geohash.substr(0,6), /* 1.22km ×  0.61km bounding box */
      doc.geohash /* 153m × 153m bounding box */
      ],null)
}

使用这种方法,您可以有一种简单的机制来获取位于以下位置的文档

With this approach you can have a simple mechanism to get the documents located in the same bounding box than the point of refrence.

这不是完美的,但可以作为选择

It is not perfect but could be an option

这篇关于查询CouchDB以在特定半径内获取poi的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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