当前位置:   article > 正文

mongoDB geohash index - use prefix base 2bit spilted 2D

geo values must be 'legacy coordinate pairs' for 2d indexes
使用2个比特位, 表示一个坐标的4个象限(例如00, 01, 10, 11). 一个2维坐标会落在其中的一个象限, 对这个象限继续划分成4个象限, 这个坐标又会落在一个象限, 继续分割提高精度. 
相近的两个2D点, 应该会有很多prefix重叠部分, prefix重叠越多, 越相近.

http://docs.mongodb.org/manual/core/geospatial-indexes/#geospatial-indexes-geohash

Calculation of Geohash Values for 2d Indexes

When you create a geospatial index on legacy coordinate pairs, MongoDB computes geohash values for the coordinate pairs within the specified location range and then indexes the geohash values.

To calculate a geohash value, recursively divide a two-dimensional map into quadrants. Then assign each quadrant a two-bit value. For example, a two-bit representation of four quadrants would be:

01  11

00  10

These two-bit values (00, 01, 10, and 11) represent each of the quadrants and all points within each quadrant. For a geohash with two bits of resolution, all points in the bottom left quadrant would have a geohash of 00. The top left quadrant would have the geohash of 01. The bottom right and top right would have a geohash of 10 and 11, respectively.

To provide additional precision, continue dividing each quadrant into sub-quadrants. Each sub-quadrant would have the geohash value of the containing quadrant concatenated with the value of the sub-quadrant. The geohash for the upper-right quadrant is 11, and the geohash for the sub-quadrants would be (clockwise from the top left): 1101, 1111, 1110, and 1100, respectively.

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/Gausst松鼠会/article/detail/504016
推荐阅读
相关标签
  

闽ICP备14008679号