Skip to main content

Config

Struct Config 

Source
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

Source

pub fn new() -> Self

Returns a config at the documented defaults; chain knob methods to override them, then call generate().

Source

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).

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn dataset(self, dataset: Dataset) -> Self

Sets the dataset, default Dataset::Now. A name string ([land-]now|1970|all) parses via dataset().

Source

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 ε².

Source

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.

Source

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().

Source

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.

Source

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.

Source

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.

Source

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).

Source

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).

Source

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).

Source

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 Clone for Config

Source§

fn clone(&self) -> Config

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Config

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Config

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
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).

Source§

fn from(recipe: &Recipe) -> Config

Converts to this type from the input type.
Source§

impl From<Recipe> for Config

Converts an owned recipe into a config; see From<&Recipe>.

Source§

fn from(recipe: Recipe) -> Config

Converts to this type from the input type.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.