itacart.topology

Neighbourhood and adjacency on the parallelogram lattice.

Completes OGC DGGS Core requirement 17. Adjacency is derived from the index strings alone; coordinates are never consulted to find a neighbour, only itacart.boundary.is_valid_cell() is asked whether the neighbour exists, and that predicate is closed form in the cosine of the latitude.

The cell is a parallelogram sheared by 45 degrees, with its base equal to its height, so a step toward the pole also moves one column toward the prime meridian. On the parallels plane the step measures dx = -10 km and dy = +10 km exactly. In index space the four edge-adjacent steps are the same arithmetic in all four quadrants, because quadrant mirroring keeps X growing away from the prime meridian and Y growing toward the pole:

N  (X - 1, Y + 1)        E  (X + 1, Y)
S  (X + 1, Y - 1)        W  (X - 1, Y)

Section 3.1 of the paper attaches the plus and minus one to Y for the vertical step. The magnitude and the sign are right; the component is not. Reading it literally returns the cell diagonally above, which shares a single vertex rather than an edge, and every symmetry test still passes because a diagonal is symmetric too.

The four vertex-adjacent steps are the sums of the edge steps, so NE is (X, Y + 1), NW is (X - 2, Y + 1), SE is (X + 2, Y - 1) and SW is (X, Y - 1).

Grid distance is measured on the lattice, not on the ellipsoid. Callers coming from H3 tend to assume otherwise; use itacart.geodesy.inverse_geodesic() on the anchors or centroids for metric separation.

Module constants

LATTICE_STEP

Lattice displacement of each direction, as (dX, dY).

GRID_STEP

In-parent displacement of each direction, as (dcolumn, drow).

EDGE_SEPARATOR

Separator between the two endpoints of a directed edge identifier.

Functions

are_neighbor_cells

Whether two cells share an edge.

cell_to_edges

Every directed edge leaving a cell.

cells_to_directed_edge

Identifier of the directed edge between two adjacent cells.

deflect

Resolve a step whose lexical target falls outside its quadrant's range.

directed_edge_to_cells

Recover the origin and destination of a directed edge.

get_neighbor

Single adjacent cell in a given direction.

grid_disk

Cells within k grid steps of the origin, the origin included.

grid_distance

Steps between two cells on the lattice.

grid_ring

Cells at exactly k grid steps, the hollow shell of a disk.