Skip to main content

Module grid

Module grid 

Source
Expand description

The grid and interned-CSR builder.

The builder makes two passes over the geometry:

  1. The edge walk: every cell a ring passes through collects that feature id into its candidate set, and a cell with ≥2 candidates is a border cell needing PIP.
  2. The scanline fill on a subdivision-finer grid: an even-odd span fill per polygon gives per-subcell ownership, aggregated to a dominant zone per cell (the interior fill for the primary array and the lookup_coarse answer).

Structs§

CellGrid
Cell arrays are [row, col]-indexed and iterate row-major, the same order the primary table serializes in.
Csr
The serializable grid prefilter: it stores one u16 per cell plus the interned candidate lists in compressed-sparse-row form.

Enums§

Order
The candidate-list ordering inside the interned CSR.

Functions§

build
Rasterizes feats onto a deg-cell grid, with ownership sampled on a grid subdivision× finer (subdivision = 8 at 2° gives 0.25° subcells).
feat_areas
Approximates the global area per feature (an equirectangular shoelace with cos-lat correction; exteriors minus holes, clamped ≥ 0). The values serve ranking only.
grid_dims
The grid dimensions for a cell size, (ncols, nrows) = ceil(360/deg) × ceil(180/deg). The sweep tools share this with the encoder so their cell counts measure exactly the grid it builds.
intern_csr
Builds the interned CSR. areas (global zone area, in any consistent unit) is used by AreaDesc and CellDominantFirst.
walk_edge
Walks the segment start→end in deg-sized steps at 2× oversampling (the rasterizer’s edge density), visiting every interpolated point including both endpoints. Cell membership per point is utz_common::grid_cell(); the sweep tools share this walk so a change to the sampling density cannot leave them measuring a different rasterization than the encoder’s.