def test_get_res0_indexes(): out = h3.get_res0_indexes() assert len(out) == 122 # subset pentagons = h3.get_pentagon_indexes(0) assert pentagons < out # all valid assert all(map(h3.h3_is_valid, out)) # resolution assert all(map( lambda h: h3.h3_get_resolution(h) == 0, out )) # verify a few concrete cells sub = { '8001fffffffffff', '8003fffffffffff', '8005fffffffffff', } assert sub < out
def test_cell_perimiter_calculations(): resolutions = [0, 1] for r in resolutions: cells = h3.uncompact(h3.get_res0_indexes(), r) for h in cells: for unit in ['rads', 'm', 'km']: v1 = cell_perimiter1(h, unit) v2 = cell_perimiter2(h, unit) assert v1 == pytest.approx(v2)
#!/usr/bin/env python3 import h3 base_cells = h3.get_res0_indexes() all_cells = [] for base_cell in base_cells: res5_cells = h3.h3_to_children(base_cell, 4) all_cells += res5_cells with open("h3_4_index.txt", "w") as fd: for cell in all_cells: fd.write(f"{cell}\n")