Expand description
Geohash encoding/decoding for spatial indexing.
Geohash is an interleaved Z-order curve over (longitude, latitude) that maps 2D coordinates to a 1D string using base-32 encoding. Nearby points share common prefixes, enabling fast proximity queries via string prefix matching on standard B-tree indexes.
Properties:
- Precision 1: ~5,000 km cells
- Precision 6: ~1.2 km × 0.6 km cells (default)
- Precision 8: ~19 m × 19 m cells
- Precision 12: ~3.7 cm × 1.9 cm cells (maximum practical)
References:
- Gustavo Niemeyer, geohash.org (2008)
- Wikipedia: Geohash
Enums§
- Direction
- Direction for neighbor computation.
Functions§
- geohash_
cover - Compute the set of geohash cells that cover a bounding box at the given precision. Useful for range queries: “find all geohash prefixes that overlap this region.”
- geohash_
decode - Decode a geohash string to its bounding box.
- geohash_
decode_ center - Decode a geohash to its center point (longitude, latitude).
- geohash_
encode - Encode a (longitude, latitude) coordinate to a geohash string.
- geohash_
neighbor - Compute the geohash of a neighbor cell in the given direction.
- geohash_
neighbors - Compute all 8 neighbor geohashes.