Skip to main content

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) -> UBIGINT

Parameters​

  • resolution (number) The resolution level

Return value​

  • (number) Number of cells at the given resolution

Example​

SELECT a5_get_num_cells(0); -- 12
SELECT a5_get_num_cells(1); -- 60
SELECT a5_get_num_cells(2); -- 240
SELECT a5_get_num_cells(3); -- 960

cellArea​

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) -> DOUBLE

Parameters​

  • 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) -> DOUBLE

Parameters​

  • 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 m
SELECT a5_cell_edge_length_avg(10); -- ~4,680 m

isValidCell​

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) -> BOOLEAN

Parameters​

  • 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)); -- true
SELECT a5_is_valid_cell(a5_hex_to_u64('fd00000000000000')); -- false: resolution 1 has no quintant 63