mln-rs-engine 0.0.23

Part of mln-rs, a MapLibre map renderer written in Rust. Depend on mln-rs instead.
Documentation
mod camera_fit;
mod ground;
mod map_events;
mod map_snapshot;
mod map_updates;
mod registered_projection;
mod style_loader;
mod style_members;
mod style_sources;
mod terrain_camera;
mod terrain_conversions;
mod terrain_gestures;
mod terrain_rest;

use std::sync::Arc;

use mln_style::time::Instant;

use crate::exec::pool::Pool;
use crate::map::{Map, MapOptions};
use crate::storage::FileSource;

/// A pool for a test's map.
fn pool() -> Pool {
    Pool::new(4)
}

/// A test's map over `file_source`, with the test registry's types, its
/// clock held ([`hold_clock`]).
fn test_map(file_source: Arc<dyn FileSource>, options: MapOptions) -> Map {
    let map = Map::with_file_source(file_source, options, crate::tests::registry(), &pool()).expect("map");
    hold_clock(&map);
    map
}

/// Holds `map`'s clock: its animations, fades and scheduled changes
/// move only when the test moves the clock ([`set_time`]), however slowly
/// the test runs. A test of how the map follows the system's clock and its
/// host's frame times lets go of it with `map.frame_clock().hold(None)`.
fn hold_clock(map: &Map) {
    crate::tests::hold_clock(&map.frame_clock());
}

/// Moves `map`'s held clock to `time`, and updates the map for a frame at
/// that time if an animation runs, as a host's frame at `time` would.
fn set_time(map: &mut Map, time: Instant) {
    map.frame_clock().hold(Some(time));
    map.sample_frame();
}