pub struct TileBudget {
pub max_uncompressed_size: usize,
pub max_compressed_size: usize,
pub max_feature_count: usize,
pub scorer: ImportanceScorer,
}Expand description
Tile size budget configuration
Fields§
§max_uncompressed_size: usizeMaximum uncompressed size in bytes
max_compressed_size: usizeMaximum compressed size in bytes (after compression)
max_feature_count: usizeMaximum number of features
scorer: ImportanceScorerImportance scorer to use for feature dropping
Implementations§
Source§impl TileBudget
impl TileBudget
Sourcepub fn new(
max_uncompressed_size: usize,
max_compressed_size: usize,
max_feature_count: usize,
) -> Self
pub fn new( max_uncompressed_size: usize, max_compressed_size: usize, max_feature_count: usize, ) -> Self
Create a new tile budget with custom limits
Sourcepub fn with_scorer(self, scorer: ImportanceScorer) -> Self
pub fn with_scorer(self, scorer: ImportanceScorer) -> Self
Set the importance scorer
Sourcepub fn estimate_size(features: &[Feature]) -> usize
pub fn estimate_size(features: &[Feature]) -> usize
Estimate the uncompressed size of features
Sourcepub fn enforce_indexed<S, Z>(
&self,
count: usize,
score: S,
size: Z,
) -> Vec<usize>
pub fn enforce_indexed<S, Z>( &self, count: usize, score: S, size: Z, ) -> Vec<usize>
Enforce the budget over an opaque, externally-owned collection of
count items, identified only by index.
This is the type-impedance bridge used by stt-build: the tiler’s
per-tile feature representation (TileFeature — an enum over a borrowed
ParsedFeature or an owned clipped segment) is not a Feature, and
converting it into one (and back) would be both lossy and wasteful.
Instead the caller supplies two closures over its own collection:
score(i)— importance of itemi(higher = keep). Mirror theImportanceScorersemantics for the chosen strategy.size(i)— estimated uncompressed bytes of itemi.
The drop policy is identical to Self::enforce:
- Count cap (
max_feature_count): keep the highest-scored items. - Size cap (
max_uncompressed_size): greedily keep items by descending importance-per-byte until the target (90% of the cap) is reached.
Returns the indices to KEEP, sorted ascending so the caller can preserve its original feature order. Nothing is dropped (every index is returned) when the collection already fits — guaranteeing the default-off / under-budget path is a no-op.
Sourcepub fn score_signals(&self, vertex_count: usize, property_count: usize) -> f64
pub fn score_signals(&self, vertex_count: usize, property_count: usize) -> f64
Score one opaque item for the budget’s configured scorer, given the
raw signals the tiler can cheaply produce: geometry vertex count and
property count. Mirrors ImportanceScorer::score but without needing
a Feature. Random/FeatureId are not reachable via this path
(the budget always uses a deterministic geometry/combined strategy from
stt-build), so they fall back to the combined formula.
Trait Implementations§
Source§impl Clone for TileBudget
impl Clone for TileBudget
Source§fn clone(&self) -> TileBudget
fn clone(&self) -> TileBudget
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for TileBudget
impl Debug for TileBudget
Auto Trait Implementations§
impl Freeze for TileBudget
impl RefUnwindSafe for TileBudget
impl Send for TileBudget
impl Sync for TileBudget
impl Unpin for TileBudget
impl UnsafeUnpin for TileBudget
impl UnwindSafe for TileBudget
Blanket Implementations§
impl<T> Allocation for T
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more