itacart.topology.grid_distance
- itacart.topology.grid_distance(origin, destination, metric='chebyshev')[source]
Steps between two cells on the lattice.
Not a geodesic distance. Use
itacart.geodesy.inverse_geodesic()on the anchors or centroids for metric separation.Defined at every resolution. The lattice mirrors at the prime meridian and again at the equator, so no single basis measures both sides of either: the position is built by descent from the resolution-1 cell and read in a rectified frame, and the meridian crossing is resolved by minimising over the row at which the line is crossed.
Which side of the meridian a cell lies on comes from that descent and never from its quadrant prefix. A cell of an eastern quadrant can sit wholly west of the line, and two cells sharing a prefix can face each other across it.
- Parameters:
- Return type:
- Returns:
Step count, zero when the cells coincide.
- Raises:
NonAtomicIndexError – If either index addresses more than one cell. Checked before the identity short circuit, so that two equal non-atomic spellings are refused rather than answered with zero.
ResolutionError – If the cells sit at different resolutions, or are quadrants.
DomainError – If a path cannot be resolved across the boundary between the cells, which includes either cell being a trapezoid of the last addressable column.
ValueError – If
metricis not one of the two lattice metrics. An invalid enumerated argument is a caller mistake rather than a statement about a cell, and the package refuses that class with the built-in exception throughout; seeget_neighbor.NonExistentCellError – If any cell of the index names no cell. The predicate is the arbiter and the contract ends there: a spelling it denies is refused rather than answered for the cell it would otherwise fold onto.