s2js
    Preparing search index...

    Type Alias CellID

    CellID: bigint

    Uniquely identifies a cell in the S2 cell decomposition. The most significant 3 bits encode the face number (0-5). The remaining 61 bits encode the position of the center of this cell along the Hilbert curve on that face. The zero value and the value (1<<64)-1 are invalid cell IDs. The first compares less than any valid cell ID, the second as greater than any valid cell ID.

    Sequentially increasing cell IDs follow a continuous space-filling curve over the entire sphere. They have the following properties:

    • The ID of a cell at level k consists of a 3-bit face number followed by k bit pairs that recursively select one of the four children of each cell. The next bit is always 1, and all other bits are 0. Therefore, the level of a cell is determined by the position of its lowest-numbered bit that is turned on (for a cell at level k, this position is 2 * (MaxLevel - k)).

    • The ID of a parent cell is at the midpoint of the range of IDs spanned by its children (or by its descendants at any level).

    Leaf cells are often used to represent points on the unit sphere, and this type provides methods for converting directly between these two representations. For cells that represent 2D regions rather than discrete point, it is better to use Cells.