Skip to content

Add step parameter to boundaries() and mort2polygon()#19

Merged
espg merged 1 commit into
mainfrom
feature/boundaries-step
Feb 26, 2026
Merged

Add step parameter to boundaries() and mort2polygon()#19
espg merged 1 commit into
mainfrom
feature/boundaries-step

Conversation

@espg
Copy link
Copy Markdown
Owner

@espg espg commented Feb 26, 2026

Summary

  • Add configurable boundary resolution via the healpix crate's path_along_cell_edge() method
  • step=1 (default) returns the original 4 corners; step=32 returns 128 boundary points that accurately trace curved cell edges
  • Fixes polygon distortion near the poles where 4-corner projections to EPSG:3031 underestimate the true HEALPix cell area by ~3.5km

Changes

Rust (geo2mort.rs): New boundaries_step_scalar() function using Layer::path_along_cell_edge(pixel, Cardinal::S, true, n_segments_by_side), with vertex ordering rolled to match healpy convention.

PyO3 (lib.rs): rust_boundaries() gains a step parameter (default 1). Step=1 takes the fast original path; step>1 dispatches to the new function. Output shape: (3, 4*step) scalar, (N, 3, 4*step) array.

Python (_healpix.py, tools.py): boundaries(nside, pixel, step=1) and mort2polygon(morton, step=1) pass through the parameter.

@codspeed-hq
Copy link
Copy Markdown
Contributor

codspeed-hq Bot commented Feb 26, 2026

Merging this PR will not alter performance

✅ 14 untouched benchmarks


Comparing feature/boundaries-step (3a422cd) with main (9763868)

Open in CodSpeed

@espg espg merged commit 0075f65 into main Feb 26, 2026
21 of 22 checks passed
@codecov
Copy link
Copy Markdown

codecov Bot commented Feb 26, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 85.82%. Comparing base (9763868) to head (3a422cd).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main      #19      +/-   ##
==========================================
- Coverage   86.49%   85.82%   -0.67%     
==========================================
  Files          13       13              
  Lines        1770     1771       +1     
==========================================
- Hits         1531     1520      -11     
- Misses        239      251      +12     
Flag Coverage Δ
unittests 85.82% <100.00%> (-0.67%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
mortie/_healpix.py 97.05% <100.00%> (ø)
mortie/tools.py 77.24% <100.00%> (-3.54%) ⬇️

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 9763868...3a422cd. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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.

1 participant