itacart.index.normalize
- itacart.index.normalize(index)[source]
Reduce an index to its canonical form.
Two reductions are applied to a fixed point:
Completeness collapse - a node whose children are all present is replaced by the node itself (
4(1,2,3,4)becomes4), 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 isitacart.hierarchy.compact_cells().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)and4(1,2)are one region, and resolution-1 components are zero-padded to four digits, since1400/374and1400/0374are 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:
- 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 (
normalizeandcompose) and two hand it straight back (decomposeanditer_cells). Anything that answers about the cell refuses it instead, so the reach of this leniency is exactly the layer that reads index strings.