Expand description
The μTZ encoder crate covers everything between loaded features and a
.utz container: shared-arc topology and simplification (topo),
quantization, the grid prefilter (grid), and the delta+varint container
serializer with its generic-compression codecs (encode).
The crate was split out of utz_build so it compiles for
wasm32-unknown-unknown: the webdist viewer runs this exact pipeline live
for size stats (the wasm surface lives in utz_viz).
Everything here is pure Rust with no filesystem or network access; the
one C-backed codec (zstd) sits behind the zstd cargo feature.
Modules§
- clean
- Post-quantization cleanup of the shared arcs. Snapping arc vertices to a coarse grid (especially i16, ~611 m cells) collapses nearby vertices and folds thin features onto themselves, leaving consecutive duplicates, zero-area spurs where the path reverses over itself (“spikes”), and rings whose area vanishes entirely. Left in, the spurs self-overlap and flip the runtime’s even-odd PIP parity inside the fold.
- encode
- The self-describing container serializer.
- grid
- The grid and interned-CSR builder.
- topo
- 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.
- validate
- Ring-geometry validation, which finds where assembled rings
self-cross, overlap themselves collinearly, self-touch, or collapse
entirely. It is shared by the
utz_dev_cli quant-cleanreport and the viewer’s live problems panel (wasm.rs), so both agree on what “problematic geometry” means.
Structs§
- Feat
- One timezone feature as loaded from the source
GeoJSON: it carries the polygons plus the tzid and UTC offset metadata.
Enums§
Constants§
- KM_
PER_ DEG - Kilometers per degree,
METERS_PER_DEGscaled; area math usesKM_PER_DEG²(with a latitude cosine) for km² per square degree. - METERS_
PER_ DEG - Meters per degree of latitude (and of longitude at the equator):
the workspace’s one flat conversion between tolerances in meters
(
epsilon_m) and coordinate degrees. - QMAX_
I24
Functions§
- dq_lat
- Dequantizes a latitude from a grid with half-range
qmax, the inverse ofq_lat(). - dq_lon
- Dequantizes a longitude from a grid with half-range
qmax, the inverse ofq_lon(). The input isf64so fractional grid positions (e.g. ring intersection points) dequantize too; stored coordinates pass throughf64::from. - push_
i24 - Appends
value’s low three little-endian bytes, the stored form of an i24-quantized coordinate. - q24_lat
- q24_lon
- q_lat
- Quantizes a latitude onto a grid with half-range
qmax. - q_lon
- Quantizes a longitude onto a grid with half-range
qmax(seeqmax_for()). - qmax_
for - The half-range of an
i{bits}quantization grid (2^(bits-1) - 1). - read_
i24