1use mln_map_types::{ConstrainMode, MapMode, NorthOrientation, ViewportMode};
7use mln_util::size::Size;
8
9#[derive(Clone, Debug)]
11pub struct MapOptions {
12 map_mode: MapMode,
13 constrain_mode: ConstrainMode,
14 viewport_mode: ViewportMode,
15 orientation: NorthOrientation,
16 cross_source_collisions: bool,
17 capture_rendered_features: bool,
18 size: Size,
19 pixel_ratio: f32,
20 fast_pfor_enabled: bool,
21}
22
23impl Default for MapOptions {
24 fn default() -> Self {
25 MapOptions {
26 map_mode: MapMode::Continuous,
27 constrain_mode: ConstrainMode::HeightOnly,
28 viewport_mode: ViewportMode::Default,
29 orientation: NorthOrientation::Upwards,
30 cross_source_collisions: true,
31 capture_rendered_features: false,
32 size: Size::new(64, 64),
33 pixel_ratio: 1.0,
34 fast_pfor_enabled: false,
35 }
36 }
37}
38
39impl MapOptions {
40 pub fn new() -> Self {
42 Self::default()
43 }
44
45 pub fn with_map_mode(mut self, mode: MapMode) -> Self {
49 self.map_mode = mode;
50 self
51 }
52
53 pub fn map_mode(&self) -> MapMode {
54 self.map_mode
55 }
56
57 pub fn with_constrain_mode(mut self, mode: ConstrainMode) -> Self {
61 self.constrain_mode = mode;
62 self
63 }
64
65 pub fn constrain_mode(&self) -> ConstrainMode {
66 self.constrain_mode
67 }
68
69 pub fn with_viewport_mode(mut self, mode: ViewportMode) -> Self {
72 self.viewport_mode = mode;
73 self
74 }
75
76 pub fn viewport_mode(&self) -> ViewportMode {
77 self.viewport_mode
78 }
79
80 pub fn with_cross_source_collisions(mut self, enable_collisions: bool) -> Self {
83 self.cross_source_collisions = enable_collisions;
84 self
85 }
86
87 pub fn cross_source_collisions(&self) -> bool {
88 self.cross_source_collisions
89 }
90
91 pub fn with_north_orientation(mut self, orientation: NorthOrientation) -> Self {
93 self.orientation = orientation;
94 self
95 }
96
97 pub fn north_orientation(&self) -> NorthOrientation {
98 self.orientation
99 }
100
101 pub fn with_size(mut self, size: Size) -> Self {
103 self.size = size;
104 self
105 }
106
107 pub fn size(&self) -> Size {
108 self.size
109 }
110
111 pub fn with_pixel_ratio(mut self, ratio: f32) -> Self {
113 self.pixel_ratio = ratio;
114 self
115 }
116
117 pub fn pixel_ratio(&self) -> f32 {
118 self.pixel_ratio
119 }
120
121 pub fn with_rendered_feature_info(mut self, capture: bool) -> Self {
123 self.capture_rendered_features = capture;
124 self
125 }
126
127 pub fn rendered_feature_info(&self) -> bool {
128 self.capture_rendered_features
129 }
130
131 pub fn with_fast_pfor_enabled(mut self, enable: bool) -> Self {
132 self.fast_pfor_enabled = enable;
133 self
134 }
135
136 pub fn fast_pfor_enabled(&self) -> bool {
137 self.fast_pfor_enabled
138 }
139}