Function S2CellId.toToken

Methods to encode and decode cell ids to compact text strings suitable for display or indexing. Cells at lower levels (i.e. larger cells) are encoded into fewer characters. The maximum token length is 16.

string toToken() const;

Tokens preserve ordering, i.e. ToToken(x) < ToToken(y) iff x < y.

ToToken() returns a string by value for convenience; the compiler does this without intermediate copying in most cases.

These methods guarantee that FromToken(ToToken(x)) == x even when "x" is an invalid cell id. All tokens are alphanumeric strings. FromToken() returns S2CellId::None() for malformed inputs.