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

本文涉及的产品
云数据库 MongoDB,通用型 2核4GB
简介:
使用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.

相关实践学习
MongoDB数据库入门
MongoDB数据库入门实验。
快速掌握 MongoDB 数据库
本课程主要讲解MongoDB数据库的基本知识,包括MongoDB数据库的安装、配置、服务的启动、数据的CRUD操作函数使用、MongoDB索引的使用(唯一索引、地理索引、过期索引、全文索引等)、MapReduce操作实现、用户管理、Java对MongoDB的操作支持(基于2.x驱动与3.x驱动的完全讲解)。 通过学习此课程,读者将具备MongoDB数据库的开发能力,并且能够使用MongoDB进行项目开发。   相关的阿里云产品:云数据库 MongoDB版 云数据库MongoDB版支持ReplicaSet和Sharding两种部署架构,具备安全审计,时间点备份等多项企业能力。在互联网、物联网、游戏、金融等领域被广泛采用。 云数据库MongoDB版(ApsaraDB for MongoDB)完全兼容MongoDB协议,基于飞天分布式系统和高可靠存储引擎,提供多节点高可用架构、弹性扩容、容灾、备份回滚、性能优化等解决方案。 产品详情: https://www.aliyun.com/product/mongodb
相关文章
|
2月前
|
关系型数据库 MySQL
MySQL创建表出现 Specified key was too long; max key length is 767 bytes
MySQL创建表出现 Specified key was too long; max key length is 767 bytes
22 2
|
2月前
|
关系型数据库 MySQL 数据库
Specified key was too long; max key length is 767 bytes导入mysql数据库表报错
Specified key was too long; max key length is 767 bytes导入mysql数据库表报错
18 0
|
6月前
|
关系型数据库 MySQL 数据库
Mysql中key与index区别
Mysql中key与index区别
|
关系型数据库 MySQL 索引
MySQL添加索引Specified key was too long; max key length is 767 bytes
MySQL添加索引Specified key was too long; max key length is 767 bytes
139 0
|
JSON 关系型数据库 MySQL
MySQL - 数据类型 Json 中 key 随机排序解决方案
MySQL - 数据类型 Json 中 key 随机排序解决方案
559 0
MySQL - 数据类型 Json 中 key 随机排序解决方案
|
关系型数据库 MySQL
【Mysql】Key值(PRI, UNI, MUL)的含义
【Mysql】Key值(PRI, UNI, MUL)的含义
431 0
|
大数据 关系型数据库 MySQL
MYSQL中group_concat有长度限制!默认1024(转载)
在mysql中,有个函数叫“group_concat”,平常使用可能发现不了问题,在处理大数据的时候,会发现内容被截取了,其实MYSQL内部对这个是有设置的,默认不设置的长度是1024,如果我们需要更大,就需要手工去修改配置文件。
4473 0
|
关系型数据库 索引 MySQL
mysql 唯一索引与null.md
mysql 的唯一索引要求所有参与的列都不能够为 null 值,如果唯一索引中的任何一个元素含有 null 值,则唯一约束将不起作用。 示例代码 create table tb ( a int, b int, c int, unique index (a,b,c) ); inser...
2177 0