pub struct Config { /* private fields */ }Expand description
The builder for a custom .utz asset. The defaults are dataset now,
RDP ε=500 m, no density weighting, i24, a 2° grid, gzip, varint-arcs
geometry, and output to $OUT_DIR/tz.utz.
Implementations§
Source§impl Config
impl Config
Sourcepub fn new() -> Self
pub fn new() -> Self
Returns a config at the documented defaults; chain knob methods to
override them, then call generate().
Sourcepub fn tiny() -> Self
pub fn tiny() -> Self
Returns the tiny preset recipe (presets::TINY): RDP
ε=10 000 m with pop-density floor 0.001, i16, a 2° grid, and
gzip. A preset constructor is a starting point for one-knob
variants: Config::tiny().geom(GeomEncoding::Coarse).
Sourcepub fn tiny_static() -> Self
pub fn tiny_static() -> Self
Returns the tiny-static preset recipe (presets::TINY_STATIC),
which is tiny stored uncompressed so the asset is readable in
place with zero decode RAM.
Sourcepub fn compact() -> Self
pub fn compact() -> Self
Returns the compact preset recipe (presets::COMPACT): RDP
ε=1 000 m with pop-density floor 0.001, i24, a 4/3° grid, and xz.
Sourcepub fn balanced() -> Self
pub fn balanced() -> Self
Returns the balanced preset recipe (presets::BALANCED): RDP
ε=50 m with pop-density floor 0.020, i24, a 2/3° grid, and
brotli.
Sourcepub fn accurate() -> Self
pub fn accurate() -> Self
Returns the accurate preset recipe (presets::ACCURATE):
dataset all (the full Comprehensive zone set; the other presets
use now), RDP ε=10 m with pop-density floor 0.10, i32, a 0.5°
grid, and brotli.
Sourcepub fn dataset(self, dataset: Dataset) -> Self
pub fn dataset(self, dataset: Dataset) -> Self
Sets the dataset, default Dataset::Now. A name string
([land-]now|1970|all) parses via
dataset().
Sourcepub fn epsilon_meters(self, epsilon_m: f64) -> Self
pub fn epsilon_meters(self, epsilon_m: f64) -> Self
Sets the simplification tolerance ceiling in meters (default 500).
The value is the ε of whichever
simplify_algorithm() runs: it is a
max-deviation bound for RDP and Imai–Iri, and Visvalingam derives
its area threshold as ε².
Sourcepub fn quant_bits(self, bits: u32) -> Self
pub fn quant_bits(self, bits: u32) -> Self
Sets the quantization width: 16 / 24 / 32 (default 24). Any other
value fails at generate(), not here.
Sourcepub fn grid_deg(self, degrees: f64) -> Self
pub fn grid_deg(self, degrees: f64) -> Self
Sets the grid cell size in degrees, 0.1–45 (default 2). Fractional
sizes are fine (the presets use 4/3, 2/3, and 0.5); out-of-range
values fail at generate().
Sourcepub fn codec(self, codec: Codec) -> Self
pub fn codec(self, codec: Codec) -> Self
Sets the payload codec. Codec::Uncompressed gives a core-rung
asset: zero decode RAM at the cost of more flash.
Sourcepub fn simplify_algorithm(self, algorithm: SimplifyAlgorithm) -> Self
pub fn simplify_algorithm(self, algorithm: SimplifyAlgorithm) -> Self
Sets the simplification algorithm, default SimplifyAlgorithm::Rdp.
The variants and their measured trade-offs are documented on
SimplifyAlgorithm.
Sourcepub fn geom(self, geom: GeomEncoding) -> Self
pub fn geom(self, geom: GeomEncoding) -> Self
Sets the geometry encoding. The default is
GeomEncoding::VarintArcs (smallest flash); the measured
size/speed ladder is the table on GeomEncoding.
Sourcepub fn density_weight_floor(self, floor: f64) -> Self
pub fn density_weight_floor(self, floor: f64) -> Self
Enables population-density-weighted simplification. The value is
the ε multiplier floor in the densest cells, strictly between 0
and 1 (the presets use 0.001–0.10; the default is off, uniform ε;
out-of-range values fail at generate()).
First use downloads GHS-POP (~460 MB, cached).
Sourcepub fn out_path(self, path: impl Into<PathBuf>) -> Self
pub fn out_path(self, path: impl Into<PathBuf>) -> Self
Sets where to write the asset. The default is $OUT_DIR/tz.utz
(the build.rs context).
Sourcepub fn cache_dir(self, path: impl Into<PathBuf>) -> Self
pub fn cache_dir(self, path: impl Into<PathBuf>) -> Self
Sets where source downloads are cached. The default is the
cache_dir() chain (UTZ_CACHE_DIR, then the
per-user cache directory). Point this at a pre-fetched directory
for hermetic builds with no network. Build scripts relying on the
environment default should emit
cargo:rerun-if-env-changed=UTZ_CACHE_DIR (and
UTZ_TZBB_RELEASE if unpinned).
Sourcepub fn generate(self) -> Result<PathBuf>
pub fn generate(self) -> Result<PathBuf>
Fetches the sources (cached), builds the asset, writes it, and
returns the path. It also writes <out>.guard.rs, a compile-time
assertion of the utz features this asset needs (via utz::caps);
include! it next to the include_bytes! so a feature mismatch
fails the build instead of the first load.
§Errors
Returns an error for out-of-range quant_bits/grid_deg, a
source download/parse failure, an encoding failure, a missing
OUT_DIR when no out_path is set, or an I/O failure writing
the asset and its guard file.
Trait Implementations§
Source§impl From<&Recipe> for Config
Converts a recipe, typically one of the utz_common::presets
constants, into a config carrying its knobs. The named preset
constructors are thin wrappers over this; use it directly to drive
the builder from the table (e.g. iterating presets::ALL).
impl From<&Recipe> for Config
Converts a recipe, typically one of the utz_common::presets
constants, into a config carrying its knobs. The named preset
constructors are thin wrappers over this; use it directly to drive
the builder from the table (e.g. iterating presets::ALL).