MongoDB中的地理空间索引的内部机制

MongoDB中的地理空间索引的内部机制

问题描述:

任何人知道如何在地理空间索引的工作,我的意思是算法来计算最近点?

Anyone knows how the geospatial indexing works, i mean the algorithm to calculate nearest points?

在SQL,我们可以做这样的事情:
SELECT ID,(XA)*(XA)+(YB)*(YB)作为距离表1 ORDER BY距离ASC
当然用MongoDB的地理空间索引相比,这是不是足够有效的,但如何做MongoDB的计算和排序?

In SQL we may do things like this:
SELECT id, (x-a)*(x-a)+(y-b)*(y-b) as distance FROM table1 ORDER by distance ASC
Sure this is not efficient enough compared with mongodb's geospatial indexing, but how does mongodb calculate and sort?

在预先感谢。

MongoDB的地理空间之心是 Geohashes 一>。 Geohash是

Heart of mongodb geospatial is Geohashes. Geohash is a

分层空间数据结构,空间细分成   网格状的桶。

Hierarchical spatial data structure which subdivides space into buckets of grid shape.

我找不到合适的链接在蒙戈的geohash实现,但这种的可能会给一些启发。

I couldn't find the appropriate links for the geohash implementations in mongo, but this thread might give some insights.