Skip to content

Instantly share code, notes, and snippets.

@a-voronov
a-voronov / GeoHash.swift
Last active September 15, 2021 16:58
proximity-hash
import CoreLocation
/// Geohash algorithm implementation.
///
/// It is a hierarchical spatial data structure which subdivides space into buckets of grid shape,
/// which is one of the many applications of what is known as a Z-order curve, and generally space-filling curves.
///
/// Geohashes offer properties like arbitrary precision
/// and the possibility of gradually removing characters from the end of the code to reduce its size (and gradually lose precision).
/// Geohashing guarantees that the longer a shared prefix between two geohashes is, the spatially closer they are together.