3 ms·
Library also available in Java[0] and to an extent in Golang[1], though the latter is incomplete. S2 is fantastic for geofencing. Arbitrary regions can be cove
by gfrangakis 9y ago
Library also available in Java[0] and to an extent in Golang[1], though the latter is incomplete.
S2 is fantastic for geofencing. Arbitrary regions can be covered by a set of S2 cells of varying level. A point (lat/lon) can be converted to a S2 cell of the smallest level (around a cm^2 of area on the sphere). Checking to see if one S2 cell is contained in another amounts to searching an integer range, since all children of a given S2 cell have IDs that fall within a fixed ranged. See also [2]
[0] https://github.com/google/s2-geometry-library-java https://github.com/google/s2-geometry-library-java
[1] https://github.com/golang/geo https://github.com/golang/geo
[2] http://blog.christianperone.com/2015/08/googles-s2-geometry-on-the-sphere-cells-and-hilbert-curve/ http://blog.christianperone.com/2015/08/googles-s2-geometry-...