// the find
google/s2geometry
Computational geometry and spatial indexing on the sphere
S2 is Google's spherical geometry library — the same one powering Google Maps, BigQuery GIS, and Spanner's geospatial features. It models the Earth as a sphere rather than a flat plane, which means distance calculations and containment queries stay correct at global scale without the distortion you get from Mercator-based approaches. If you're doing geographic indexing, proximity queries, or polygon operations on real-world coordinates, this is the serious option.
The S2CellId system is the core idea worth understanding: it maps the sphere to a Hilbert curve, giving you a 64-bit integer that encodes both location and scale, with the property that nearby cells are nearby integers. That makes range queries on a B-tree index meaningful for geographic data without a dedicated geo index. The query API (S2ClosestEdgeQuery, S2RegionCoverer, S2BooleanOperation) covers what you'd actually need: nearest-neighbor search, polygon intersection, region covering for database queries. Test coverage is thorough — nearly every .h file has a corresponding _test.cc, and the library has clearly been exercised hard in production. Active maintenance: pushed yesterday, CI runs on every PR.
Still version 0.x with an explicit 'no API or ABI stability guarantees' warning, which makes it a liability in any shared library context until 1.0 lands. The Python bindings are a known weak spot — still SWIG-based, explicitly marked unstable, and pybind11 rewrite is listed as 'planned' with no timeline. The Abseil dependency is pinned to an exact LTS release (20250814), so if your project already depends on a different Abseil version, you will fight CMake. And the Apple M1 failure (6% accumulated error in s2loop_measures_test) is documented but unresolved — not a showstopper for most uses, but worth knowing if you're doing high-precision polar or antipodal calculations.