use glam::{DQuat, DVec3};
use mln_style::geo::LatLngBounds;
use crate::camera::{BoundOptions, FreeCameraOptions, MapView};
use crate::tile_store::TileLodMode;
#[derive(Clone, Copy, Debug, PartialEq)]
pub struct MapSnapshot {
pub generation: u64,
pub update_generation: u64,
pub fully_loaded: bool,
pub gesture_in_progress: bool,
pub transition_in_progress: bool,
pub tile: TileSettings,
pub bounds: CameraBounds,
pub free_camera: FreeCamera,
pub view: MapView,
pub globe_rendering: bool,
}
#[derive(Clone, Copy, Debug, PartialEq)]
pub struct TileSettings {
pub prefetch_zoom_delta: u8,
pub lod_min_radius: f64,
pub lod_scale: f64,
pub lod_pitch_threshold: f64,
pub lod_zoom_shift: f64,
pub lod_mode: TileLodMode,
}
#[derive(Clone, Copy, Debug, PartialEq)]
pub struct CameraBounds {
pub bounds: Option<LatLngBounds>,
pub min_zoom: f64,
pub max_zoom: f64,
pub min_pitch: f64,
pub max_pitch: f64,
}
impl From<CameraBounds> for BoundOptions {
fn from(bounds: CameraBounds) -> Self {
BoundOptions {
bounds: Some(bounds.bounds.unwrap_or_else(LatLngBounds::infinite)),
min_zoom: Some(bounds.min_zoom),
max_zoom: Some(bounds.max_zoom),
min_pitch: Some(bounds.min_pitch),
max_pitch: Some(bounds.max_pitch),
}
}
}
#[derive(Clone, Copy, Debug, Default, PartialEq)]
pub struct FreeCamera {
pub position: DVec3,
pub orientation: DQuat,
}
impl From<FreeCamera> for FreeCameraOptions {
fn from(camera: FreeCamera) -> Self {
FreeCameraOptions { position: Some(camera.position), orientation: Some(camera.orientation) }
}
}