burin.coverage¶
The equal-area coverage engine: an aperture-9 rHEALPix SpatialMerkleTree with a canonical Poseidon
(BN254) commitment, plus membership / non-membership proofs, space-time and value-bearing variants,
signed attestations with fraud proofs, and the polygon → fingerprint pipeline.
Everything below is the public surface (burin.coverage.__all__).
burin.coverage: the equal-area coverage engine.
An aperture-9 rHEALPix coverage tree with a canonical Poseidon (BN254) commitment. The same set of equal-area cells always produces the same 32-byte root, regardless of insertion order or roll-up (deterministic, MOC-invariant). Dual EMPTY/FULL default-hash ladders give the roll-up, and the tree carries membership, non-membership, and uniform-coverage proofs. A canonicalizing SUID encoding for rHEALPix cell sets turns a polygon into a compact fingerprint.
See docs/coverage/SYNTHESIS.md for architecture, theory, and proof semantics.
AllenProof
dataclass
¶
Authenticated: a temporal cell (order,index) proven covered in a temporal
coverage root stands in Allen relation relation to the public query interval
[query_lo, query_hi). Verifiable from proof + root alone.
Source code in burin/coverage/allen.py
HierarchicalCoverageTree ¶
Sparse aperture-N Merkle tree over a canonical hierarchical cell set.
Node := _FULL | dict[int, node] (a missing child => EMPTY subtree).
Root is a pure function of the set (order-independent) and MOC-invariant.
Source code in burin/coverage/coverage_tree.py
218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 | |
add_interval ¶
Cover a half-open time interval [lo, hi) (dyadic tree only). Returns the canonical cell set added. Domain is [0, 2**max_depth).
Source code in burin/coverage/coverage_tree.py
Attestation
dataclass
¶
One entry in a witness's append-only attestation log (ATTESTATION_MODEL §2).
Source code in burin/coverage/fraud.py
BackdatingFraud
dataclass
¶
A later epoch carries an earlier issuance time. The witness's own epoch order
says later came after earlier; its own clock says before — self-contradiction,
no trusted clock needed. (Absorbs Roughtime: the epoch sequence is the ordering proof.)
Requires both attestations to carry a time: a time-agnostic witness (issued_at is
None) binds no when, so Rule 3 does not apply and no backdating proof can exist.
Source code in burin/coverage/fraud.py
CoverageMonotonicityFraud
dataclass
¶
Under a declared APPEND_ONLY_COVERAGE policy, a later epoch un-covers a
(region, time) an earlier epoch covered. covered proves region R covered at
temporal cell T; uncovered (a later epoch) proves R′ ⊆ R absent at the SAME T.
Since R covered at T implies every descendant covered at T (ST inheritance), R′
absent later means coverage shrank — the bird demo's 'claimed the whole valley,
denied this nest.'
Source code in burin/coverage/fraud.py
EquivocationFraud
dataclass
¶
Same witness, same epoch, two DISTINCT signed attestations — a provable fork. Rule 1 is
one attestation per epoch, so any divergence in the signed message (root, issued_at, subject,
policy, prev_hash) at a shared (witness_pk, epoch) is a fork — not only a divergent root.
The comparison is on the signed message, never the signature, so a re-broadcast of the
identical attestation is NOT a fork even under a randomized scheme (SM2/ECDSA give two distinct
signatures for one message). Sound because the epoch is the context: different epochs are
legitimate evolution, never flagged; one attestation per epoch ⇒ no false positive on any honest
witness. Catching the whole message (not just the root) closes two cross-rule evasions — an
issued_at fork that would otherwise let a witness escape backdating detection (Rule 3), and a
policy fork that would let it selectively disclaim the APPEND_ONLY_COVERAGE behind Rule 4.
Source code in burin/coverage/fraud.py
CoverageProof
dataclass
¶
Membership (present=True) or non-membership (present=False) proof
for a cell at (base_idx, children). Self-verifying against a root.
Source code in burin/coverage/spatial_merkle.py
SpatialMerkleTree ¶
Sparse aperture-9 Merkle tree over a canonical rHEALPix cell set.
Build from canonical SUIDs (mixed levels, MOC-rolled). Root is a pure
function of the set (order-independent) and MOC-invariant. Cells deeper
than max_depth are rejected.
Source code in burin/coverage/spatial_merkle.py
149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 | |
SpatioTemporalCoverageTree ¶
Nested STMOC commitment. Space = aperture-9/n_base-6; each covered spatial
leaf carries a dyadic (aperture-2) temporal coverage tree of depth temporal_depth.
Overlapping nested facts merge by push-down union (see module docstring).
Source code in burin/coverage/st_coverage.py
229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 | |
temporal_tree ¶
temporal_tree(suid) -> HierarchicalCoverageTree | None
The temporal coverage tree at an exactly-covered spatial cell, else None.
Source code in burin/coverage/st_coverage.py
st_uniform_membership_proof ¶
st_uniform_membership_proof(
suid, order: int, index: int
) -> STUniformProof | None
Prove ALL of spatial cell suid is covered at temporal cell (order, index).
Source code in burin/coverage/st_coverage.py
STMembershipProof
dataclass
¶
A chain of proofs: (spatial path to a covered cell) ∘ (temporal proof that the queried temporal cell is covered in that cell's sub-tree).
Source code in burin/coverage/st_coverage.py
STNonMembershipProof
dataclass
¶
Proof that (suid, temporal cell) is NOT covered. Two kinds:
spatial_absent — the spatial cell's subtree is EMPTY (no coverage at any
time); temporal_absent — the cell is covered (carries temporal_root)
but the queried temporal cell is absent in that sub-tree.
Source code in burin/coverage/st_coverage.py
STUniformProof
dataclass
¶
Proves EVERY leaf of spatial cell (base_idx, children) is covered at temporal
cell (order, index) — i.e. 'all of region R covered at T'. Sound against the
existing root (no commitment change); size = O(distinct leaves under R), reducing to
a single temporal proof when R is a uniform leaf. (If R is covered only via a
coarser ancestor leaf, prove that ancestor — the natural coarsest claim.)
Source code in burin/coverage/st_coverage.py
ValuedCoverageTree ¶
Aperture-9 / n_base-6 spatial commitment whose covered leaves carry an opaque VALUE (a field
element) instead of a FULL bit. node := None (EMPTY) | int (value_fe) | dict[int, node].
Roll-up is gated on value-equality: nine children with the identical value collapse to one valued leaf (canonical coarsest form); mixed values do not. A finer value fact inside a coarser valued cell expands that cell (children inherit its value) then sets the finer child (last-write-wins on a single cell). For a slide the cells are at one resolution, so it is just place + uniform roll-up.
Source code in burin/coverage/value_coverage.py
132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 | |
from_cells
classmethod
¶
Build from an iterable of (suid, value). Later values overwrite earlier at the same cell.
Source code in burin/coverage/value_coverage.py
value_at ¶
The value field element at an exactly-valued cell, else None (absent, partial, or valued only via a coarser ancestor — query at that granularity).
Source code in burin/coverage/value_coverage.py
value_proof ¶
value_proof(suid) -> ValueProof | None
Open the value at an exactly-valued cell (None if absent/partial/coarser-valued).
Source code in burin/coverage/value_coverage.py
non_membership_proof ¶
non_membership_proof(
suid,
) -> ValueNonMembershipProof | None
Prove a cell carries no value (None if it is valued, or valued via a coarser ancestor).
Source code in burin/coverage/value_coverage.py
ValueNonMembershipProof
dataclass
¶
Proves cell (base_idx, children) carries NO value — the absent fact g = EMPTY[d],
local (no neighbours, no ordering): Cor 4.4's empty sandwich class.
Source code in burin/coverage/value_coverage.py
ValueProof
dataclass
¶
Opens cell (base_idx, children) to the value field element value_fe against the root
(the 'this cell holds value V' proof). The disclosed value_fe is encode_value(value).
Source code in burin/coverage/value_coverage.py
allen_classify ¶
Allen relation of A=[a_start,a_end) relative to B=[b_start,b_end). Branch-free.
Source code in burin/coverage/allen.py
prove_allen ¶
prove_allen(
temporal_tree: HierarchicalCoverageTree,
order: int,
index: int,
query_lo: int,
query_hi: int,
) -> AllenProof | None
Build an AllenProof for a committed cell vs. a query interval, or None if the
cell is not covered in temporal_tree.
Source code in burin/coverage/allen.py
canonical_fingerprint ¶
canonical_fingerprint(
suids: list[SUID],
n_side: int = 3,
resolution: int | None = None,
) -> bytes
Compute the canonical fingerprint for a set of cells.
Full pipeline
cells → canonicalize → spatial aperture-9 Merkle tree → root hash
Same coverage always produces the same 32-byte hash, regardless of input resolution or insertion order (the root is MOC-invariant: rolled-up and expanded inputs canonicalize to the same set → same root).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
suids
|
list[SUID]
|
List of SUID tuples. |
required |
resolution
|
int | None
|
tree depth (resolution). If None, inferred from the deepest
cell in the canonicalized set — which makes rolled/expanded inputs
agree. Pass an explicit resolution to match |
None
|
Returns:
| Type | Description |
|---|---|
bytes
|
32-byte Merkle root hash. |
Note (v2.3 cutover): the canonical structure is SpatialMerkleTree.
Roots differ from ≤v2.2.0.
Source code in burin/coverage/canonicalize.py
canonical_fingerprint_hex ¶
canonicalize_keys ¶
Reduce a set of burin keys to canonical form.
When all N_side² children of a parent are present, replace them with the parent key. Cascade upward until stable.
Processes from finest resolution to coarsest, so each coalescence naturally feeds into the next level — no repeated passes needed.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
keys
|
list[bytes]
|
List of resolution-first byte keys (from suid_to_bytes) |
required |
n_side
|
int
|
N_side parameter (default 3, giving 9 children per parent) |
3
|
Returns:
| Type | Description |
|---|---|
list[bytes]
|
Sorted list of canonical burin keys |
Source code in burin/coverage/canonicalize.py
canonicalize_suids ¶
Canonicalize a list of rHEALPix SUIDs.
Convenience wrapper — converts to keys, canonicalizes, converts back.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
suids
|
list[SUID]
|
List of SUID tuples like [('Q', 4, 5, 0), ('Q', 4, 5, 1), ...] |
required |
Returns:
| Type | Description |
|---|---|
list[SUID]
|
Sorted list of canonical SUIDs |
Source code in burin/coverage/canonicalize.py
fingerprint_polygon ¶
fingerprint_polygon(
geometry: object,
resolution: int,
plane: bool = False,
n_side: int = 3,
dggs: object = None,
) -> bytes
Compute a canonical fingerprint for a polygon's rHEALPix coverage.
Full pipeline (v2.3): Shapely polygon → vectorised int64 polyfill → stride-9 coalesce → SpatialMerkleTree (depth = resolution) → root hash
The guarantee: same polygon + same resolution = same 32-byte hash. Two independent providers produce identical fingerprints without coordinating; the root is also MOC-invariant. v2.3 cutover: the canonical structure is the spatial aperture-9 Merkle tree, so roots differ from ≤v2.2.0.
Resolution is part of the standard — different resolutions produce different fingerprints (finer resolution captures more boundary detail).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
geometry
|
object
|
Shapely Polygon or MultiPolygon (lon/lat). |
required |
resolution
|
int
|
rHEALPix resolution (0-15). Part of the fingerprint identity. |
required |
plane
|
bool
|
Reserved for forward compatibility; the v2.1 fast path
operates on lon/lat coordinates and ignores this argument.
Pass-through callers using |
False
|
n_side
|
int
|
N_side parameter (default 3). Only N_side=3 is supported
in the v2.1 fast path; other values raise |
3
|
dggs
|
object
|
Reserved for forward compatibility; the v2.1 fast path uses the WGS84 N_side=3 DGGS implicitly via the spatial-id encoding. |
None
|
Returns:
| Type | Description |
|---|---|
bytes
|
32-byte Merkle root hash. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If polyfill returns no cells (polygon strictly
smaller than a cell at the requested resolution), if
|
Source code in burin/coverage/canonicalize.py
fingerprint_polygon_hex ¶
fingerprint_polygon_hex(
geometry: object,
resolution: int,
plane: bool = False,
n_side: int = 3,
dggs: object = None,
) -> str
Hex string version of fingerprint_polygon().
Source code in burin/coverage/canonicalize.py
parent_key ¶
Get the burin key of a cell's parent.
Pure byte operation via SUID roundtrip.
Returns None for base cells (resolution 0).
Source code in burin/coverage/canonicalize.py
sibling_keys ¶
Get all N_side² sibling keys (including the key itself), sorted.
For N_side=3, returns 9 keys — the complete set of children sharing the same parent.
Source code in burin/coverage/canonicalize.py
attestation_message ¶
attestation_message(
witness_pk: bytes,
epoch: int,
prev_hash: bytes,
root: bytes,
issued_at: int | None,
subject: tuple[int, int] | None,
policy: int,
) -> bytes
Canonical, domain-separated message a witness signs for one attestation. issued_at
(when) and subject are optional dimensions, each length-prefixed by a presence byte so
'absent' is distinct from any concrete value (a time-agnostic witness omits issued_at).
Source code in burin/coverage/fraud.py
decode_spatial ¶
Inverse of :func:to_spatial_id.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
spatial_id
|
int
|
64-bit canonical spatial id. |
required |
Returns:
| Type | Description |
|---|---|
tuple[int, int, int]
|
|
Source code in burin/coverage/spatial.py
from_crypto_bytes ¶
Inverse of :func:to_crypto_bytes.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
crypto_bytes
|
bytes
|
bytes in burin's resolution-first format. |
required |
Returns:
| Type | Description |
|---|---|
int
|
Canonical 64-bit |
Raises:
| Type | Description |
|---|---|
ValueError
|
if the input is too short or fields are out of range. |
Source code in burin/coverage/spatial.py
spatial_id_from_suid ¶
Convert an rHEALPix SUID tuple to a canonical spatial_id.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
suid
|
tuple[str | int, ...]
|
SUID tuple like |
required |
Returns:
| Type | Description |
|---|---|
int
|
Canonical |
Source code in burin/coverage/spatial.py
suid_from_spatial_id ¶
Inverse of :func:spatial_id_from_suid.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
spatial_id
|
int
|
canonical 64-bit |
required |
Returns:
| Type | Description |
|---|---|
str | int
|
SUID tuple of the form |
...
|
suitable for cross-checking against |
Source code in burin/coverage/spatial.py
to_crypto_bytes ¶
Translate spatial_id to the resolution-first crypto byte layout.
Output is bit-identical to suid_to_bytes(suid) for the cell
that spatial_id represents — the compatibility invariant, verified
exhaustively through resolution 4.
Format::
[level_byte][face_byte][packed digits, 2 per byte, hi-nibble first]
The last nibble is padded with 0 if level is odd.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
spatial_id
|
int
|
64-bit canonical spatial id. |
required |
Returns:
| Type | Description |
|---|---|
bytes
|
Crypto bytes consumable by burin's hashing / canonicalisation. |
Source code in burin/coverage/spatial.py
to_spatial_id ¶
Pack (face, peano_position, level) into the 64-bit canonical layout.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
face
|
int
|
rHEALPix base cell index in |
required |
peano_position
|
int
|
Peano traversal position within the face, in
|
required |
level
|
int
|
cell resolution in |
required |
Returns:
| Type | Description |
|---|---|
int
|
64-bit |
int
|
|
Raises:
| Type | Description |
|---|---|
ValueError
|
if any input is out of range. |
Source code in burin/coverage/spatial.py
verify_proof ¶
verify_proof(
proof: CoverageProof,
root_hash: bytes,
max_depth: int,
hasher: HashFn | str = POSEIDON,
) -> bool
Stateless verification — needs only the proof, root, max_depth, hasher.
Source code in burin/coverage/spatial_merkle.py
encode_value ¶
Canonical opaque value -> one field element (the leaf payload v). A scalar binds directly
(dual-mode + ZK-ready: the leaf poseidon([5, v]) is the only hash and the circuit stays cheap).
A vector/tuple reduces to one field element via the SAME hasher as the tree — Poseidon on the
proof path, keccak/blake on the compute path — so neither path silently depends on the other. Any
future type (quantized float, nested commitment) lands here. Pure function of the value (no nonce).
Source code in burin/coverage/value_coverage.py
bytes_to_suid ¶
Convert byte encoding back to rHEALPix SUID.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
bytes
|
Byte encoding from suid_to_bytes() |
required |
Returns:
| Type | Description |
|---|---|
SUID
|
SUID tuple |
Example
bytes_to_suid(b'\x03\x00\x32\x10') ('N', 3, 2, 1)
Source code in burin/coverage/suid_encoding.py
nuniq_to_suid ¶
Convert NUNIQ-style integer back to SUID.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
nuniq
|
int
|
Integer NUNIQ encoding |
required |
n_side
|
int
|
N_side parameter (default 3) |
3
|
Returns:
| Type | Description |
|---|---|
SUID
|
SUID tuple |
Source code in burin/coverage/suid_encoding.py
string_to_suid ¶
Convert string representation back to SUID.
Example
string_to_suid('N321') ('N', 3, 2, 1)
Source code in burin/coverage/suid_encoding.py
suid_to_bytes ¶
Convert a rHEALPix SUID to canonical byte encoding.
Format: - Byte 0: resolution (0-255) - Byte 1: base cell index (0-5) - Bytes 2+: packed child indices (4 bits each, 2 per byte)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
suid
|
SUID | list
|
SUID tuple like ('N', 3, 2, 1) or list ['N', 3, 2, 1] |
required |
n_side
|
int
|
N_side parameter (default 3) |
3
|
Returns:
| Type | Description |
|---|---|
bytes
|
Canonical byte encoding |
Example
suid_to_bytes(('N', 3, 2, 1)) b'\x03\x00\x32\x10' # res=3, base=N(0), children=3,2,1,0(pad)
Source code in burin/coverage/suid_encoding.py
suid_to_nuniq ¶
Convert SUID to NUNIQ-style single integer encoding.
Formula: nuniq = 6 * n_side^(2*res) * base_index + position
Where position is the cell's position within its base cell subtree, computed by treating child indices as base-(n_side²) digits.
This encoding has the property that cells are ordered by: 1. Resolution (lower resolutions first) 2. Base cell (N < O < P < Q < R < S) 3. Position within base cell
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
suid
|
SUID | list
|
SUID tuple like ('N', 3, 2, 1) |
required |
n_side
|
int
|
N_side parameter (default 3) |
3
|
Returns:
| Type | Description |
|---|---|
int
|
Integer NUNIQ encoding |
Source code in burin/coverage/suid_encoding.py
suid_to_string ¶
Convert SUID to canonical string representation.
Simple and human-readable, good for debugging.
Example
suid_to_string(('N', 3, 2, 1)) 'N321'
Source code in burin/coverage/suid_encoding.py
coalesce_ids ¶
Coalesce complete 9-sibling groups up the rHEALPix hierarchy.
Parameters¶
spatial_ids
Sorted uint64 array of spatial_id values at one or more
levels (also accepts int64; we cast to uint64 to make
the bit-field arithmetic well-defined for face indices >= 4 whose
high-bit gets set in the layout). Input from
:func:torus.polyfill.polyfill is already sorted at a single
level; this function also accepts mixed-level input (we sort
defensively) for use as a generic canonicalisation step.
Returns¶
numpy.ndarray
Sorted uint64 array of canonical spatial_id values. Any
complete sibling group of 9 cells is collapsed to its parent;
the cascade runs to convergence.
Notes¶
The crypto-bytes set obtained via
[to_crypto_bytes(int(s)) for s in canonicalize(...)] is identical
to burin.coverage.canonicalize.canonicalize_keys([to_crypto_bytes(int(s)) for s in spatial_ids]),
which is the gate enforced by the M4 fingerprint-parity test.
Source code in burin/coverage/_coalesce.py
cell_ij_from_peano ¶
Map a Peano position at level to the integer grid coordinates
(i, j) of the corresponding leaf cell, with i the column index in
[0, 3**level) and j the row index measured from the bottom.
This is what prototype/scripts/render_peano.py uses to plot the
curve. It is a pure function of the state machine -- no rHEALPix
geometry involved.
The relationship between rHEALPix's row-from-top index r and our
bottom-up j at level L is r = (3**L - 1) - j.
Source code in burin/coverage/_peano.py
digits_from_peano_position ¶
Convert a Peano traversal position into a list of rHEALPix child digits.
Inverse of peano_position_from_digits.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
peano
|
int
|
Peano position, must satisfy |
required |
level
|
int
|
tree depth. |
required |
Returns:
| Type | Description |
|---|---|
list[int]
|
List of |
list[int]
|
most-significant (level-1) first. |
Source code in burin/coverage/_peano.py
peano_position_from_digits ¶
Convert a sequence of rHEALPix child digits into a Peano traversal
position in [0, 9**level).
digits[k] is the rHEALPix child digit (0..8 in row-major top-down
order; see module docstring) chosen at depth k+1 inside the face. The
most significant choice is digits[0].
The starting state at the face root is ROOT_STATE (== P). Cross-face
stitching that varies the per-face starting state is deferred to
sub-task M2-cross-face.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
digits
|
list[int]
|
list of |
required |
level
|
int
|
number of digits / tree depth. Must equal |
required |
Returns:
| Type | Description |
|---|---|
int
|
Peano traversal position in |
int
|
returns 0. |
Source code in burin/coverage/_peano.py
polyfill ¶
Compute every cell whose centroid lies inside polygon.
Parameters¶
polygon
A Shapely Polygon (lon/lat). Other geometries that expose
the same .contains / .intersects API also work.
resolution
Target rHEALPix resolution in [0, 15]. Must match the
resolution argument used by rhp_wrappers.polyfill.
Returns¶
numpy.ndarray
uint64 array of spatial_id values for every cell at
resolution whose ellipsoidal centroid lies inside polygon.
The array is sorted in natural uint64 order, which for a
fixed level is equivalent to sorting first by face index
then by Peano position within the face.
Notes¶
The output set is bit-identical to::
suid_strings = rhp_wrappers.polyfill(polygon, resolution, plane=False)
i.e. the same set of cells the upstream centroid-in-polygon polyfill
would return, just packed as spatial_id integers and sorted.