Summary
Implement the hierarchical operations CellToParent and CellToChildren which navigate up and down the H3 cell hierarchy by resolution.
Background
Part of #21 – Basic H3 Cell-Mode Support in SpatialLite.
H3 encodes hierarchy directly in the index bit structure:
CellToParent: replace child digit bits below the target resolution with the padding value (7)
CellToChildren: enumerate all valid digit combinations for the added resolution levels
Each regular hexagon has exactly 7 children per resolution step. Pentagon cells have 5 children per step due to a missing digit direction in their structure.
Tasks
- Implement
CellToParent(H3Cell cell, int parentResolution) → H3Cell
- Validate that
parentResolution is coarser (lower number) than the cell's current resolution
- Implement
CellToChildren(H3Cell cell, int childResolution) → IEnumerable<H3Cell>
- Validate that
childResolution is finer (higher number) than the cell's current resolution
- Enumerate all valid digit combinations, skipping digit 1 for pentagon cells
Acceptance Criteria
CellToParent returns the correct parent for all resolution combinations
CellToChildren returns exactly 7 children for hexagons and 5 for pentagons per resolution step
- Total child count for multi-step traversal: 7^(childRes − cellRes) for hexagons
ArgumentOutOfRangeException thrown for invalid resolution arguments
- Behavior verified against upstream H3 test vectors
Summary
Implement the hierarchical operations
CellToParentandCellToChildrenwhich navigate up and down the H3 cell hierarchy by resolution.Background
Part of #21 – Basic H3 Cell-Mode Support in SpatialLite.
H3 encodes hierarchy directly in the index bit structure:
CellToParent: replace child digit bits below the target resolution with the padding value (7)CellToChildren: enumerate all valid digit combinations for the added resolution levelsEach regular hexagon has exactly 7 children per resolution step. Pentagon cells have 5 children per step due to a missing digit direction in their structure.
Tasks
CellToParent(H3Cell cell, int parentResolution) → H3CellparentResolutionis coarser (lower number) than the cell's current resolutionCellToChildren(H3Cell cell, int childResolution) → IEnumerable<H3Cell>childResolutionis finer (higher number) than the cell's current resolutionAcceptance Criteria
CellToParentreturns the correct parent for all resolution combinationsCellToChildrenreturns exactly 7 children for hexagons and 5 for pentagons per resolution stepArgumentOutOfRangeExceptionthrown for invalid resolution arguments