Skip to content

feat: add pure-Go measures (cell area, distance, averages) to x/h3go - #126

Open
justinhwang wants to merge 3 commits into
masterfrom
justinhwang/purego-phase-c
Open

feat: add pure-Go measures (cell area, distance, averages) to x/h3go#126
justinhwang wants to merge 3 commits into
masterfrom
justinhwang/purego-phase-c

Conversation

@justinhwang

Copy link
Copy Markdown
Collaborator

Port the measures cluster to pure Go: CellAreaRads2/Km2/M2 (Cagnoli signed-area sum over the cell boundary with Kahan compensated summation), GreatCircleDistanceRads/Km/M (haversine), and the per-resolution average helpers HexagonAreaAvgKm2/M2 and HexagonEdgeLengthAvgKm/M.

Verified against the cgo reference via paritytest. Cross-implementation area parity uses a relative tolerance: Go's math and C's libm differ by a few ULPs in the transcendental functions, which grows to ~1e-6 relative at the finest resolution.

EdgeLengthRads/Km/M are deferred to the directed-edge phase, which they depend on.

justinhwang and others added 2 commits June 16, 2026 13:50
Implement the reverse projection pipeline in pure Go: CellToLatLng
(+ Cell.LatLng) and CellToBoundary (+ Cell.Boundary), with the supporting
FaceIJK/coordIJK/vec2d/vec3d geometry, substrate grids, and overage
adjustment. Verified against the cgo reference via paritytest and by
LatLngToCell round-trips, with regression cases ported from the C tests.

Refactors applied across the package:
- Convert input-parameter helpers to methods on their natural receiver type,
  with one canonical receiver name per type.
- Inline pure-delegation unexported helpers into their exported methods
  (resolution, baseCellNumber, isPentagon); collapse isValid's guard in.
- Add isResClassIII(res) helper, replacing scattered %2 == 1 checks.
- Exclude mnd for x/h3go via path-scoped .golangci.yml rule (geometric and
  bit-layout constants are inherent, not magic) and drop the now-unused
  //nolint:mnd directives; keep gosec.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Port the measures cluster to pure Go: CellAreaRads2/Km2/M2 (Cagnoli
signed-area sum over the cell boundary with Kahan compensated summation),
GreatCircleDistanceRads/Km/M (haversine), and the per-resolution average
helpers HexagonAreaAvgKm2/M2 and HexagonEdgeLengthAvgKm/M.

Verified against the cgo reference via paritytest. Cross-implementation
area parity uses a relative tolerance: Go's math and C's libm differ by a
few ULPs in the transcendental functions, which grows to ~1e-6 relative at
the finest resolution.

EdgeLengthRads/Km/M are deferred to the directed-edge phase, which they
depend on.

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

coveralls commented Jun 17, 2026

Copy link
Copy Markdown

Coverage Report for CI Build 30594576450

Coverage remained the same at 100.0%

Details

  • Coverage remained the same as the base build.
  • Patch coverage: 88 of 88 lines across 2 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: 2190
Covered Lines: 2190
Line Coverage: 100.0%
Coverage Strength: 1515966.02 hits per line

💛 - Coveralls

Base automatically changed from justinhwang/purego-phase-b to master July 2, 2026 15:09
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