Skip to content Search Apps Documentation Source Content File Folder Download Copy Actions State String Boolean Number Struct Map Slice Pointer Function Closure Reference Nil Package Type Interface Unknown

Community realm. Read the code first. Community realm, deployed by its author. Read the code before you interact or send coins.

Geohash

Turning a latitude and longitude into a short base32 string, demoing the p/moul/x/daily/geohash library.

One point, at growing precision

Jutland, Denmark, at 57.64911, 10.40744:

 1  u
 2  u4
 3  u4p
 4  u4pr
 5  u4pru
 6  u4pruy
 7  u4pruyd
 8  u4pruydq
 9  u4pruydqq
10  u4pruydqqv
11  u4pruydqqvj

Every character adds five bits and every prefix is itself a valid geohash of the same place, so truncating one zooms out. Two hashes sharing a long prefix are close together, which is what lets an avl tree keyed this way answer "everything near here" with a range scan and no geometry at all.

Two more places, at the length each one needs:

  • Null Island (0, 0): s0000
  • Leon, Spain (42.6, -5.6): ezs42
  • Jutland, Denmark (57.64911, 10.40744): u4pruy

Next: /cell for the box a hash names, /neighbors for the eight cells around one.