Skip to content

H3: Implement CellToBoundary #26

Description

@lukaskabrt

Summary

Implement CellToBoundary which returns the geographic polygon boundary of an H3 cell, expressed as SpatialLite geometry types.

Background

Part of #21 – Basic H3 Cell-Mode Support in SpatialLite.

This is the inverse of LatLngToCell. For a given cell index:

  1. Decode the index to face-centered IJK coordinates
  2. Compute boundary vertices in IJK space (6 for hexagons, 5 for pentagons)
  3. Convert each vertex back to lat/lng

Tasks

  • Implement H3 index → face-IJK decoding (inverse of the LatLngToCell encoding)
  • Implement IJK → lat/lng vertex computation for hexagon and pentagon cells
  • Return boundary as IReadOnlyList<Coordinate> (or Polygon) compatible with SpatialLite geometry model
  • Handle pentagon cells (5 vertices)
  • Handle cells that cross the anti-meridian (180° longitude)

Acceptance Criteria

  • Returns correct boundary coordinates for hexagonal cells at all resolutions 0–15
  • Pentagon cells return 5 vertices; regular hexagons return 6 vertices
  • Anti-meridian crossing is handled correctly
  • Return type integrates with the SpatialLite geometry model
  • Behavior verified against upstream H3 test vectors

Metadata

Metadata

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions