Sfoglia il codice sorgente

Rename ViewMode -> Projection

ViewMode::Flat -> Projection::Mercator
ViewMode::Globe -> Projection::Orthografic
Johannes Hofmann 7 anni fa
parent
commit
333593ca95
2 ha cambiato i file con 19 aggiunte e 17 eliminazioni
  1. 1
    1
      src/main.rs
  2. 18
    16
      src/map_view_gl.rs

+ 1
- 1
src/main.rs Vedi File

@@ -196,7 +196,7 @@ fn handle_event(
196 196
                     },
197 197
                     VirtualKeyCode::G => {
198 198
                         if modifiers.ctrl {
199
-                            map.toggle_view_mode();
199
+                            map.toggle_projection();
200 200
                             Action::Redraw
201 201
                         } else {
202 202
                             Action::Nothing

+ 18
- 16
src/map_view_gl.rs Vedi File

@@ -23,14 +23,16 @@ pub struct MapViewGl {
23 23
     tile_layer: TileLayer,
24 24
     marker_layer: MarkerLayer,
25 25
     globe_tile_layer: GlobeTileLayer,
26
-    view_mode: ViewMode,
26
+    projection: Projection,
27 27
     last_draw_type: DrawType,
28 28
 }
29 29
 
30 30
 #[derive(Debug, Eq, PartialEq)]
31
-enum ViewMode {
32
-    Flat,
33
-    Globe,
31
+enum Projection {
32
+    // EPSG:3857: WGS 84 / Pseudo-Mercator
33
+    Mercator,
34
+    // Orthographic projection, WGS 84 coordinates mapped to the sphere
35
+    Orthografic,
34 36
 }
35 37
 
36 38
 #[derive(Debug, Eq, PartialEq)]
@@ -92,7 +94,7 @@ impl MapViewGl {
92 94
             tile_layer,
93 95
             marker_layer: MarkerLayer::new(cx),
94 96
             globe_tile_layer: GlobeTileLayer::new(cx),
95
-            view_mode: ViewMode::Flat,
97
+            projection: Projection::Mercator,
96 98
             last_draw_type: DrawType::Null,
97 99
         }
98 100
     }
@@ -108,11 +110,11 @@ impl MapViewGl {
108 110
     }
109 111
 
110 112
     pub fn map_covers_viewport(&self) -> bool {
111
-        match self.view_mode {
112
-            ViewMode::Flat => self.map_view.map_covers_viewport(),
113
+        match self.projection {
114
+            Projection::Mercator => self.map_view.map_covers_viewport(),
113 115
             //TODO uncomment
114
-            //ViewMode::Globe => self.map_view.globe_covers_viewport(),
115
-            ViewMode::Globe => false,
116
+            //Projection::Orthografic => self.map_view.globe_covers_viewport(),
117
+            Projection::Orthografic => false,
116 118
         }
117 119
     }
118 120
 
@@ -120,10 +122,10 @@ impl MapViewGl {
120 122
         self.tile_atlas.double_texture_size(cx)
121 123
     }
122 124
 
123
-    pub fn toggle_view_mode(&mut self) {
124
-        self.view_mode = match self.view_mode {
125
-            ViewMode::Flat => ViewMode::Globe,
126
-            ViewMode::Globe => ViewMode::Flat,
125
+    pub fn toggle_projection(&mut self) {
126
+        self.projection = match self.projection {
127
+            Projection::Mercator => Projection::Orthografic,
128
+            Projection::Orthografic => Projection::Mercator,
127 129
         };
128 130
     }
129 131
 
@@ -179,15 +181,15 @@ impl MapViewGl {
179 181
         // only snap to pixel grid if zoom has integral value
180 182
         let snap_to_pixel = (self.map_view.zoom - (self.map_view.zoom + 0.5).floor()).abs() < 1e-10;
181 183
 
182
-        match self.view_mode {
183
-            ViewMode::Flat => {
184
+        match self.projection {
185
+            Projection::Mercator => {
184 186
                 let ret = self.draw_flat_tiles(cx, source, snap_to_pixel);
185 187
                 if !self.marker_layer.is_empty() {
186 188
                     self.draw_marker(cx, snap_to_pixel);
187 189
                 }
188 190
                 ret
189 191
             },
190
-            ViewMode::Globe => {
192
+            Projection::Orthografic => {
191 193
                 self.draw_globe(cx, source);
192 194
                 Ok(1)
193 195
             },