1 Star 0 Fork 303

脏小强/elasticsearch-definitive-guide-cn

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
40_Geohashes.asciidoc 2.46 KB
一键复制 编辑 原始数据 按行查看 历史
Looly 提交于 2014-09-22 14:58 +08:00 . First commit, finished 1.1 and 1.2

Geohashes

Geohashes are a way of encoding lat/lon points as strings. The original intention was to have a URL-friendly way of specifying geolocations, but geohashes have turned out to be a useful way of indexing geo-points and geo- shapes in databases.

Geohashes divide the world up into a grid of 32 cells — 4 rows and 8 columns — each represented by a letter or number. The g cell covers half of Greenland, all of Iceland and most of Great Britian. Each cell can be further divided into anokther 32 cells, which can be divided into another 32 cells, and so on. The gc, cell covers Ireland and England, gcp covers most of London and part of Southern England, and gcpuuz94k is the entrance to Buckingham Palace, accurate to about 5 metres.

In other words, the longer the geohash string, the more accurate it is. If two geohashes share a prefix — gcpuux and gcpuuz — then it implies that they are near to each other. The longer the shared prefix, the closer they are.

That said, two locations that are right next to each other may have completely different geohashes. For instance, the Millenium Dome in London has geohash u10hbp, because it falls into the u cell, the next top-level cell to the east of the g cell.

Geo-points can index their associated geohashes automatically, but more importantly, they can also index all geohash prefixes. Indexing the location of the entrance to Buckingham Palace — latitude 51.501568 and longitude -0.141257 — would index all of the geohashes listed in the table below, along with the approximate dimensions of each geohash cell:

Geohash Level Dimensions

g

1

~ 5,004km x 5,004km

gc

2

~ 1,251km x 625km

gcp

3

~ 156km x 156km

gcpu

4

~ 39km x 19.5km

gcpuu

5

~ 4.9km x 4.9km

gcpuuz

6

~ 1.2km x 0.61km

gcpuuz9

7

~ 152.8m x 152.8m

gcpuuz94

8

~ 38.2m x 19.1m

gcpuuz94k

9

~ 4.78m x 4.78m

gcpuuz94kk

10

~ 1.19m x 0.60m

gcpuuz94kkp

11

~ 14.9cm x 14.9cm

gcpuuz94kkp5

12

~ 3.7cm x 1.8cm

The {ref}query-dsl-geohash-cell-filter.html[geohash_cell filter] can use these geohash prefixes to find locations near a specified lat/lon point.

Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/icodes/elasticsearch-definitive-guide-cn.git
git@gitee.com:icodes/elasticsearch-definitive-guide-cn.git
icodes
elasticsearch-definitive-guide-cn
elasticsearch-definitive-guide-cn
master

搜索帮助