Skip to main content

mln_map/
map_options.rs

1use mln_map_types::{ConstrainMode, MapMode, NorthOrientation, ViewportMode};
2use mln_util::size::Size;
3
4/// What a map does with a style image once no layer uses it.
5#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
6pub enum UnusedStyleImagePolicy {
7    /// Remove it from the style, unless the image sets `keep_unused`. A
8    /// layer that uses it again reports it missing with
9    /// [`MapEvent::StyleImageMissing`](crate::MapEvent::StyleImageMissing).
10    #[default]
11    Remove,
12    /// Keep it in the style.
13    Keep,
14}
15
16/// How a map renders and lays itself out.
17#[derive(Clone, Copy, Debug)]
18pub struct MapOptions {
19    /// Continuous by default, so the map renders as data arrives from the
20    /// network and reacts immediately to state changes.
21    pub map_mode: MapMode,
22    /// Limits how far the map can move off the world. `HeightOnly` by
23    /// default.
24    pub constrain_mode: ConstrainMode,
25    /// Can flip the vertical orientation of the map, as some devices use an
26    /// inverted orientation.
27    pub viewport_mode: ViewportMode,
28    /// Which way north points on the screen. Upwards by default.
29    pub north_orientation: NorthOrientation,
30    /// Whether symbols collide across sources. On by default.
31    pub cross_source_collisions: bool,
32    /// The size of the map and its renderer backend.
33    pub size: Size,
34    /// 1 by default.
35    pub pixel_ratio: f32,
36    /// Whether MLT vector tiles decode streams encoded with FastPFOR. Off
37    /// by default.
38    pub fast_pfor_enabled: bool,
39    /// What the map does with a style image once no layer uses it. By
40    /// default, it removes the image.
41    pub unused_style_image_policy: UnusedStyleImagePolicy,
42}
43
44impl Default for MapOptions {
45    fn default() -> Self {
46        MapOptions {
47            map_mode: MapMode::Continuous,
48            constrain_mode: ConstrainMode::HeightOnly,
49            viewport_mode: ViewportMode::Default,
50            north_orientation: NorthOrientation::Upwards,
51            cross_source_collisions: true,
52            size: Size::new(64, 64),
53            pixel_ratio: 1.0,
54            fast_pfor_enabled: false,
55            unused_style_image_policy: UnusedStyleImagePolicy::Remove,
56        }
57    }
58}