Skip to content

feat: add pure-Go regions (polygon/cells, multipolygon) to x/h3go#130

Open
justinhwang wants to merge 1 commit into
justinhwang/purego-phase-ffrom
justinhwang/purego-phase-g
Open

feat: add pure-Go regions (polygon/cells, multipolygon) to x/h3go#130
justinhwang wants to merge 1 commit into
justinhwang/purego-phase-ffrom
justinhwang/purego-phase-g

Conversation

@justinhwang

Copy link
Copy Markdown
Collaborator

Implements the full H3 regions API in pure Go, verified against the cgo reference:

  • PolygonToCells (legacy flood-fill polyfill) and GeoPolygon.Cells, with the GeoPolygon/GeoLoop types, bounding-box helpers, and a ray-casting point-in-polygon test.
  • PolygonToCellsExperimental with the ContainmentMode options (center, full, overlapping, overlapping-bbox): a hierarchical traversal of the cell grid exposed as a native iter.Seq, with cellToBBox (res-0, pole, and edge-length tables), bbox overlap/contains/scale/normalization, and cell-boundary intersection tests.
  • CellsToMultiPolygon via the arc/union-find outline algorithm, assembling cell sets into polygons (outer loop plus holes) ordered by area, including the eight-triangle globe representation for a fully covered set. A Go map replaces the C hash table, which only accelerates lookup without affecting the result.

Verified against the cgo reference as sets across many polygons, all containment modes, resolutions, and cell sets (blobs, rings, disjoint regions, pentagons, the whole globe), plus error parity. 100% per-package statement coverage by in-package tests.

Implements the full H3 regions API in pure Go, verified against the cgo
reference:

- PolygonToCells (legacy flood-fill polyfill) and GeoPolygon.Cells, with the
  GeoPolygon/GeoLoop types, bounding-box helpers, and a ray-casting
  point-in-polygon test.
- PolygonToCellsExperimental with the ContainmentMode options (center, full,
  overlapping, overlapping-bbox): a hierarchical traversal of the cell grid
  exposed as a native iter.Seq, with cellToBBox (res-0, pole, and edge-length
  tables), bbox overlap/contains/scale/normalization, and cell-boundary
  intersection tests.
- CellsToMultiPolygon via the arc/union-find outline algorithm, assembling
  cell sets into polygons (outer loop plus holes) ordered by area, including
  the eight-triangle globe representation for a fully covered set. A Go map
  replaces the C hash table, which only accelerates lookup without affecting
  the result.

Verified against the cgo reference as sets across many polygons, all
containment modes, resolutions, and cell sets (blobs, rings, disjoint
regions, pentagons, the whole globe), plus error parity. 100% per-package
statement coverage by in-package tests.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@coveralls

Copy link
Copy Markdown

Coverage Report for CI Build 27727545624

Coverage at 100.0% (no base build to compare)

Details

  • Coverage remained the same as the base build.
  • Patch coverage: 909 of 909 lines across 13 files are fully covered (100%).
  • No coverage regressions found.

Uncovered Changes

No uncovered changes found.

Coverage Regressions

No coverage regressions found.


Coverage Stats

Coverage Status
Relevant Lines: 4170
Covered Lines: 4170
Line Coverage: 100.0%
Coverage Strength: 2972886.6 hits per line

💛 - Coveralls

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants