QUADBIN is built on the slippy-map (Web-Mercator) tile scheme, so a cell maps directly to a tile coordinate triple (x,y,z) and to the base-4 quadkey string tile servers use. These conversions are the QUADBIN-specific bridge to the tiling ecosystem, and have no counterpart in a hexagonal or a spherical-quadrilateral grid.
Return whether a value is a structurally valid QUADBIN identifier
isValidIndex(quadbin) → boolean
Correct header tag and resolution field.
SELECT isValidIndex(quadbin '480fffffffffffff'); -- t SELECT isValidIndex(0::bigint::quadbin); -- f
Return the neighbouring cell at the same resolution in the given direction
quadbinCellSibling(quadbin,text) → quadbin
up / down / left / right.
SELECT quadbinCellSibling( quadbinCellSibling(quadbin '48427fffffffffff', 'right'), 'left') = quadbin '48427fffffffffff'; -- t
Emit the base-4 slippy-tile quadkey string of a cell
quadbinCellToQuadkey(quadbin) → text tquadbinCellToQuadkey(tquadbin) → ttext
One digit per zoom level, most significant first, the resolution-0 world cell mapping to the empty string. The static form takes a single quadbin, the temporal form returning the quadkey of each cell in a trajectory as a ttext.
SELECT quadbinCellToQuadkey(quadbin '480fffffffffffff'); -- (empty string) SELECT quadbinCellToQuadkey(quadbin '48427fffffffffff'); -- 0213 SELECT quadbinCellToQuadkey(quadbin '48a6227affffffff'); -- 1202021322
Decompose a cell back into its tile coordinate triple, returned as an integer array holding x, then y, then z
quadbinCellToTile(quadbin) → integer[]
It is the inverse of the tile constructor
SELECT quadbinCellToTile(quadbin '480fffffffffffff');
-- {0,0,0}
SELECT quadbinCellToTile(quadbin '48a6227affffffff');
-- {524,343,10}
Build a cell from slippy-map tile coordinates: column x, row y, and zoom z
quadbinTileToCell(integer,integer,integer) → quadbin
SELECT quadbinTileToCell(0, 0, 0) = quadbin '480fffffffffffff'; -- t SELECT quadbinTileToCell(3, 5, 4) = quadbin '48427fffffffffff'; -- t SELECT quadbinTileToCell(524, 343, 10) = quadbin '48a6227affffffff'; -- t