itacart.index.normalize

itacart.index.normalize(index)[source]

Reduce an index to its canonical form.

Two reductions are applied to a fixed point:

  1. Completeness collapse - a node whose children are all present is replaced by the node itself (4(1,2,3,4) becomes 4), except where the node absorbs the domain border. A complete alphabet under such a node is not all of its children – some are spelled under the next column’s stem – so the collapse would name cells the index does not hold. The region an index denotes never changes here; folding by the children a cell actually has is itacart.hierarchy.compact_cells().

  2. Sibling ordering - siblings are sorted by their refinement alphabet so a region has one spelling regardless of input order.

Two further rewrites are needed for the canonical form to be unique in practice: repeated siblings are merged, since 4(1),4(2) and 4(1,2) are one region, and resolution-1 components are zero-padded to four digits, since 1400/374 and 1400/0374 are one cell.

This is what makes OGC requirement 13 hold in practice: two indices whose canonical forms are equal denote the same region, and away from the border-absorbing family the converse holds as well. At that border an absorbing cell and the complete set of its children are one region with two canonical spellings, because the fold that would unify them is compaction’s, not normalization’s.

Provenance: the ASCII analogue of binary_index.recompose_to_prefix_form.

Parameters:

index (str) – Compositional index string.

Return type:

str

Returns:

The canonical index string.

The fold, and how far it reaches. A western zero-column spelling names no cell – column zero is the prime-meridian column and the meridian belongs to the eastern quadrants – and this layer takes it anyway, because analysing a spelling is not the same act as answering for a cell. Two functions rewrite it onto its eastern twin (normalize and compose) and two hand it straight back (decompose and iter_cells). Anything that answers about the cell refuses it instead, so the reach of this leniency is exactly the layer that reads index strings.