地理索引:根据纬度/经度有效计算邻近度
我的简单 Web 应用程序(WSGI、Python)支持文本查询以查找数据库中的项目。 现在我想扩展它以允许诸如“查找 {lat,long} 1 英里内的所有项目”之类的查询。
当然,如果考虑效率的话,这是一项复杂的工作,所以我正在考虑一个专用的外部模块来为地理坐标建立索引 - 有点像 Lucene 对文本的索引。
我假设这样的通用组件已经存在,但到目前为止还没有找到任何东西。任何帮助将不胜感激。
My simple web app (WSGI, Python) supports text queries to find items in the database.
Now I'd like to extend this to allow for queries like "find all items within 1 mile of {lat,long}".
Of course that's a complex job if efficiency is a concern, so I'm thinking of a dedicated external module that does indexing for geo-coordinates - sort of like Lucene would for text.
I assume a generic component like this already exists, but haven't been able to find anything so far. Any help would be greatly appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您检查过 mongo db 吗,它们有地理索引功能。 http://www.mongodb.org/display/DOCS/Geospatial+Indexing
Have you checked out mongo db, they have a geo indexing feature. http://www.mongodb.org/display/DOCS/Geospatial+Indexing
如果你打算直接用Python实现的话,我只能想到半暴力攻击,我已经出于类似的目的这样做了:
对于距离点的筛选,你可以首先找到“x”和“的候选点” y" 坐标位于以测试位置为中心的正方形内(速度更快),然后测试实际的测地距离。
希望有帮助!
I could only think of a semi-brute-force attack if you plan to implement it directly with Python, which I already did with similar purposes:
For the screening of points for distance, you can first find candidate points whose "x" and "y" coordinates are inside a square centered on your testing position (much faster) and just then test for actual geodesic distance.
Hope it helps!