The following static helpers return a cellset, the finite-collection companion type of cell. They operate on a static cell or on a cellset and are not lifted to tcell, the temporal lift being deferred pending a tset<T> primitive.
All cells within k grid steps of the origin
gridDisk(h3index,integer) → h3indexset gridDisk(quadbin,integer) → quadbinset s2EdgeNeighbors(s2cell) → s2cellset
The disk includes the origin, which is the whole of it at k = 0. Its shape follows the grid: on the QUADBIN square grid the disk at step k is the (2k+1)×(2k+1) block of cells centred on the origin, while on the H3 hexagonal grid it is the ring of hexagons at that many steps and everything inside it. S2 states the four cells sharing an edge with the origin and takes no step count, so it answers the disk at k = 1 less the origin itself.
SELECT gridDisk(h3index '871fa44a8ffffff', 1);
/* {"871fa44a8ffffff", "871fa44a9ffffff", "871fa44aaffffff", "871fa44abffffff",
"871fa44acffffff", "871fa44adffffff", "871fa44aeffffff"} */
SELECT gridDisk(quadbin '48a6227affffffff', 1);
/* {"48a6226dffffffff", "48a6226fffffffff", "48a62278ffffffff", "48a62279ffffffff",
"48a6227affffffff", "48a6227bffffffff", "48a622c5ffffffff", "48a622d0ffffffff",
"48a622d1ffffffff"} */
SELECT s2EdgeNeighbors(s2cell '47c3c');
-- {"47c14", "47c24", "47c34", "47c44"}
All children of a cell at the given target resolution
cellToChildren(h3index,integer) → h3indexset cellToChildren(quadbin,integer) → quadbinset cellToChildren(s2cell,integer) → s2cellset
The number of children is the grid's branching factor: four for a QUADBIN or an S2 quadtree cell, seven for an H3 cell. The helper is static, children being a per-instant set whose temporal lift is deferred pending a tset<T> primitive.
SELECT cellToChildren(h3index '831c02fffffffff', 4);
/* {"841c021ffffffff", "841c023ffffffff", "841c025ffffffff", "841c027ffffffff",
"841c029ffffffff", "841c02bffffffff", "841c02dffffffff"} */
SELECT cellToChildren(quadbin '48a6227affffffff', 11);
-- {"48b6227a3fffffff", "48b6227a7fffffff", "48b6227abfffffff", "48b6227affffffff"}
SELECT cellToChildren(s2cell '47c3c', 8);
-- {"47c39", "47c3b", "47c3d", "47c3f"}
Compacted representation of a cell set, finer cells being merged into their parent whenever the parent's full set of children is present
h3CompactCells(h3indexset) → h3indexset
Compaction is stated for H3 alone: it is the one grid MobilityDB carries the kernel for, and the QUADBIN and S2 forms are not yet implemented.
SELECT h3CompactCells(cellToChildren(h3index '831c02fffffffff', 4));
-- {"831c02fffffffff"}
Uncompacted representation at the given resolution, the inverse of compactCells
h3UncompactCells(h3indexset,integer) → h3indexset
SELECT numValues(h3UncompactCells(h3CompactCells( cellToChildren(h3index '831c02fffffffff', 4)), 4)); -- 7