Mixed aperture "4/3" grids: cell_to_index(), get_parent(), get_children() use the wrong numbering scheme and error on every call
Defect
lonlat_to_cell() (R/grid_helpers.R:71-94) and cell_to_lonlat() (:112-134) both special-case g@aperture == "4/3" and call the dedicated cpp_lonlat_to_cell_ap43/cpp_cell_to_lonlat_ap43 C++ entry points, which use calc_grid_params_ap43() — a distinct cell-ID numbering scheme for mixed grids (src/rcpp_cell.cpp:1209).
cell_to_index() (R/grid_helpers.R:653-674), get_parent() (:692-731), and get_children() (:745-780) have no such special case: they always call aperture_to_int(g@aperture) (returns 3L for "4/3", R/constants.R:257-259) and feed that into the generic cpp_cell_to_quad_ij/cpp_cell_to_index/cpp_get_parent_index/cpp_get_children_indices, which use the pure aperture-3 numbering (calc_grid_params(), not the ap43 variant).
Reproduction
grid <- hex_grid(resolution = 6, aperture = "4/3")
cells <- lonlat_to_cell(c(0, 30, -60), c(10, 45, -30), grid) # 3629 5216 10420
get_parent(cells, grid)
# Error: cell_id must be a finite value in [1, 7292] for resolution 6, aperture 3
cell_to_index(cells, grid)
# same error
7292 is 10*3^6+2 (the pure aperture-3 cell count), not the actual ap43 cell space for this grid — a documented, first-class hex_grid(aperture = "4/3") option throws on every call to these three functions.
Impact
tests/testthat/test-hierarchical-index.R only exercises apertures 3, 4, 7 — never "4/3" — so this is completely uncovered by CI.
Fix
Add the same g@aperture == "4/3" special-casing to cell_to_index(), get_parent(), and get_children() that lonlat_to_cell()/cell_to_lonlat() already have, routing through the ap43-aware C++ entry points.
Mixed aperture "4/3" grids:
cell_to_index(),get_parent(),get_children()use the wrong numbering scheme and error on every callDefect
lonlat_to_cell()(R/grid_helpers.R:71-94) andcell_to_lonlat()(:112-134) both special-caseg@aperture == "4/3"and call the dedicatedcpp_lonlat_to_cell_ap43/cpp_cell_to_lonlat_ap43C++ entry points, which usecalc_grid_params_ap43()— a distinct cell-ID numbering scheme for mixed grids (src/rcpp_cell.cpp:1209).cell_to_index()(R/grid_helpers.R:653-674),get_parent()(:692-731), andget_children()(:745-780) have no such special case: they always callaperture_to_int(g@aperture)(returns3Lfor"4/3",R/constants.R:257-259) and feed that into the genericcpp_cell_to_quad_ij/cpp_cell_to_index/cpp_get_parent_index/cpp_get_children_indices, which use the pure aperture-3 numbering (calc_grid_params(), not the ap43 variant).Reproduction
7292is10*3^6+2(the pure aperture-3 cell count), not the actual ap43 cell space for this grid — a documented, first-classhex_grid(aperture = "4/3")option throws on every call to these three functions.Impact
tests/testthat/test-hierarchical-index.Ronly exercises apertures 3, 4, 7 — never"4/3"— so this is completely uncovered by CI.Fix
Add the same
g@aperture == "4/3"special-casing tocell_to_index(),get_parent(), andget_children()thatlonlat_to_cell()/cell_to_lonlat()already have, routing through the ap43-aware C++ entry points.