Cell Info
Functions for obtaining information about A5 cells.
getNumCells
Returns the number of cells at a given resolution level.
a5_get_num_cells(resolution INTEGER) -> UBIGINTParameters
resolution(number) The resolution level
Return value
- (number) Number of cells at the given resolution
Example
SELECT a5_get_num_cells(0); -- 12SELECT a5_get_num_cells(1); -- 60SELECT a5_get_num_cells(2); -- 240SELECT a5_get_num_cells(3); -- 960cellArea
Returns the area of a cell at a given resolution in square meters. Within a resolution level, all cells have exactly the same area.
a5_cell_area(resolution INTEGER) -> DOUBLEParameters
resolution(number) The resolution level
Return value
- (number) Area of a cell in square meters
Example
SELECT a5_cell_area(20); -- ~30 m²cellEdgeLengthAvg
Returns the average edge length of a cell at a given resolution in meters. Individual edge lengths vary from the average by roughly ±10%, depending on the cell's shape and its position on the globe.
a5_cell_edge_length_avg(resolution INTEGER) -> DOUBLEParameters
resolution(number) The resolution level
Return value
- (number) Average edge length of a cell in meters
Example
SELECT a5_cell_edge_length_avg(2); -- ~1,190,000 mSELECT a5_cell_edge_length_avg(10); -- ~4,680 misValidCell
Checks whether a 64-bit value is an A5 cell. Use it to validate cell IDs from outside sources, such as a file or a database, before passing them to other A5 functions. The world cell is a valid cell: it has no boundary, but cellToParent returns it as the parent of the resolution 0 cells. A compaction marker is not a cell.
a5_is_valid_cell(cell UBIGINT) -> BOOLEANParameters
index(bigint) Value to check
Return value
- (boolean) Whether the value is an A5 cell identifier
Example
SELECT a5_is_valid_cell(a5_lonlat_to_cell(2.35, 48.85, 10)); -- trueSELECT a5_is_valid_cell(a5_hex_to_u64('fd00000000000000')); -- false: resolution 1 has no quintant 63