pub struct PathSampler<'l, PS, AS> { /* private fields */ }Expand description
Performs fast sample queries on a path with cached measurements.
This object contains the mutable state necessary for speeding up the queries, this allows the path measurements to be immutable and accessible concurrently from multiple threads if needed.
Reusing a sampler over multiple queries saves a memory allocation if there are custom attributes, And speeds up queries if they are sequentially ordered along the path.
Implementations§
Source§impl<'l, PS: PositionStore, AS: AttributeStore> PathSampler<'l, PS, AS>
impl<'l, PS: PositionStore, AS: AttributeStore> PathSampler<'l, PS, AS>
Sourcepub fn new(
measurements: &'l PathMeasurements,
positions: &'l PS,
attributes: &'l AS,
sample_type: SampleType,
) -> Self
pub fn new( measurements: &'l PathMeasurements, positions: &'l PS, attributes: &'l AS, sample_type: SampleType, ) -> Self
Create a sampler.
The provided positions must be the ones used when initializing the path measurements.
Sourcepub fn sample(&mut self, dist: f32) -> PathSample<'_>
pub fn sample(&mut self, dist: f32) -> PathSample<'_>
Sample at a given distance along the path.
If the path is empty, the produced sample will contain NaNs.
Sourcepub fn split_range(&mut self, range: Range<f32>, output: &mut dyn PathBuilder)
pub fn split_range(&mut self, range: Range<f32>, output: &mut dyn PathBuilder)
Construct a path for a specific sub-range of the measured path.
The path measurements must have been initialized with the same path. The distance is clamped to the beginning and end of the path. Panics if the path is empty.