Skip to main content

Module topo

Module topo 

Source
Expand description

The TopoJSON-style shared-arc topology builder. Shared borders are cut into arcs at junctions, each arc is stored ONCE as i24 delta+varint, and every ring is a list of signed arc references. Optional topology-aware Ramer–Douglas–Peucker (RDP) line simplification runs on each arc a single time (endpoints fixed), so neighbouring polygons stay stitched. Other open-polyline simplifiers could slot into the same per-arc pass.

Structs§

TopoOut
A serialized topology plus the counts and reconstructed geometry the measurement tools report on.
Topology
The shared-arc topology itself, before any serialization: this is what the container encoder (encode.rs) consumes. Arc coords are f64 and already RDP-simplified.

Enums§

Simplify
The algorithm choice and its parameter, for callers that thread the choice through knobs.

Functions§

build_topology
Builds the topology: vertices are deduped, shared arcs are cut at junctions, and topology-aware RDP runs on each arc exactly once with endpoints fixed.
build_topology_algorithm
This is build_topology() with the simplification algorithm as a knob (the utz_simplify menu: RDP, Visvalingam–Whyatt, Imai–Iri, or None).
build_topology_weighted
This is build_topology_algorithm() with spatially varying tolerance: edge_weight(a, b) returns the tolerance multiplier for one arc edge (in practice DensityWeight::weight(DensityGrid::max_along(a, b))), and each vertex simplifies under the smallest multiplier of its incident edges, so a long edge crossing a dense area pins both flanking vertices. Weights are a pure function of arc geometry and every shared arc is simplified exactly once, so neighbouring zones stay stitched by construction.
encode_topology
Builds and serializes the shared-arc topology at the default i24 quantization: build_topology() runs first, followed by arc-store serialization.
encode_topology_q
qbits selects the absolute grid: 16 gives i16 (~611 m lon), 24 gives i24 (~2.4 m), and 32 gives cm precision.
encode_topology_qm
abs_fixed stores arc vertices as fixed-width absolute ints (random-access) instead of the default delta + zigzag-varint stream.
put_varint
Appends value as a varint, low 7 bits per byte with the high bit as continuation; the reader’s inverse is utz::format::read_varint().
simplify
Dispatches on Simplify.
zigzag
Zigzag-encodes a signed delta for put_varint(); the reader’s inverse is utz::format::unzigzag().

Type Aliases§

EdgeWeightFn
The tolerance multiplier for the edge a–b (see build_topology_weighted()).