浏览代码

Rename tile_layer -> mercator_tile_layer

and TileLayer -> MercatorTileLayer
Johannes Hofmann 7 年前
父节点
当前提交
7a3a12aa68
共有 3 个文件被更改,包括 19 次插入15 次删除
  1. 2
    2
      src/main.rs
  2. 13
    9
      src/map_view_gl.rs
  3. 4
    4
      src/mercator_tile_layer.rs

+ 2
- 2
src/main.rs 查看文件

23
 #[macro_use]
23
 #[macro_use]
24
 pub mod context;
24
 pub mod context;
25
 pub mod coord;
25
 pub mod coord;
26
-pub mod ortho_tile_layer;
27
 pub mod map_view;
26
 pub mod map_view;
28
 pub mod map_view_gl;
27
 pub mod map_view_gl;
29
 pub mod marker_layer;
28
 pub mod marker_layer;
29
+pub mod mercator_tile_layer;
30
 pub mod mercator_view;
30
 pub mod mercator_view;
31
+pub mod ortho_tile_layer;
31
 pub mod orthografic_view;
32
 pub mod orthografic_view;
32
 pub mod program;
33
 pub mod program;
33
 pub mod search;
34
 pub mod search;
36
 pub mod tile;
37
 pub mod tile;
37
 pub mod tile_atlas;
38
 pub mod tile_atlas;
38
 pub mod tile_cache;
39
 pub mod tile_cache;
39
-pub mod tile_layer;
40
 pub mod tile_loader;
40
 pub mod tile_loader;
41
 pub mod tile_source;
41
 pub mod tile_source;
42
 pub mod url_template;
42
 pub mod url_template;

+ 13
- 9
src/map_view_gl.rs 查看文件

8
 use texture::{Texture, TextureFormat};
8
 use texture::{Texture, TextureFormat};
9
 use tile_atlas::TileAtlas;
9
 use tile_atlas::TileAtlas;
10
 use tile_cache::TileCache;
10
 use tile_cache::TileCache;
11
-use tile_layer::TileLayer;
11
+use mercator_tile_layer::MercatorTileLayer;
12
 use tile_source::TileSource;
12
 use tile_source::TileSource;
13
 
13
 
14
 
14
 
23
     dpi_factor: f64,
23
     dpi_factor: f64,
24
     tile_cache: TileCache,
24
     tile_cache: TileCache,
25
     tile_atlas: TileAtlas,
25
     tile_atlas: TileAtlas,
26
-    tile_layer: TileLayer,
26
+    mercator_tile_layer: MercatorTileLayer,
27
     marker_layer: MarkerLayer,
27
     marker_layer: MarkerLayer,
28
     ortho_tile_layer: OrthoTileLayer,
28
     ortho_tile_layer: OrthoTileLayer,
29
     projection: Projection,
29
     projection: Projection,
59
     {
59
     {
60
         let tile_size = 256;
60
         let tile_size = 256;
61
 
61
 
62
-        let mut map_view = MercatorView::initial_map_view(f64::from(initial_size.0), f64::from(initial_size.1), tile_size);
62
+        let mut map_view = MercatorView::initial_map_view(
63
+            f64::from(initial_size.0),
64
+            f64::from(initial_size.1),
65
+            tile_size,
66
+        );
63
 
67
 
64
         if map_view.zoom < MIN_ZOOM_LEVEL {
68
         if map_view.zoom < MIN_ZOOM_LEVEL {
65
             map_view.zoom = MIN_ZOOM_LEVEL;
69
             map_view.zoom = MIN_ZOOM_LEVEL;
88
         tile_atlas.double_texture_size(cx);
92
         tile_atlas.double_texture_size(cx);
89
         tile_atlas.double_texture_size(cx);
93
         tile_atlas.double_texture_size(cx);
90
 
94
 
91
-        let tile_layer = TileLayer::new(cx, &tile_atlas);
95
+        let mercator_tile_layer = MercatorTileLayer::new(cx, &tile_atlas);
92
 
96
 
93
         MapViewGl {
97
         MapViewGl {
94
             map_view,
98
             map_view,
96
             dpi_factor,
100
             dpi_factor,
97
             tile_cache: TileCache::new(move |_tile| update_func(), use_network),
101
             tile_cache: TileCache::new(move |_tile| update_func(), use_network),
98
             tile_atlas,
102
             tile_atlas,
99
-            tile_layer,
103
+            mercator_tile_layer,
100
             marker_layer: MarkerLayer::new(cx),
104
             marker_layer: MarkerLayer::new(cx),
101
             ortho_tile_layer: OrthoTileLayer::new(cx),
105
             ortho_tile_layer: OrthoTileLayer::new(cx),
102
             projection: Projection::Mercator,
106
             projection: Projection::Mercator,
138
         };
142
         };
139
     }
143
     }
140
 
144
 
141
-    fn draw_flat_tiles(&mut self, cx: &mut Context, source: &TileSource, snap_to_pixel: bool)
145
+    fn draw_mercator_tiles(&mut self, cx: &mut Context, source: &TileSource, snap_to_pixel: bool)
142
         -> Result<usize, usize>
146
         -> Result<usize, usize>
143
     {
147
     {
144
         if self.last_draw_type != DrawType::Tiles {
148
         if self.last_draw_type != DrawType::Tiles {
145
             self.last_draw_type = DrawType::Tiles;
149
             self.last_draw_type = DrawType::Tiles;
146
-            self.tile_layer.prepare_draw(cx, &self.tile_atlas);
150
+            self.mercator_tile_layer.prepare_draw(cx, &self.tile_atlas);
147
         }
151
         }
148
 
152
 
149
         //TODO remove viewport_size parameter
153
         //TODO remove viewport_size parameter
150
-        self.tile_layer.draw(
154
+        self.mercator_tile_layer.draw(
151
             cx,
155
             cx,
152
             &self.map_view,
156
             &self.map_view,
153
             source,
157
             source,
198
 
202
 
199
         match self.projection {
203
         match self.projection {
200
             Projection::Mercator => {
204
             Projection::Mercator => {
201
-                let ret = self.draw_flat_tiles(cx, source, snap_to_pixel);
205
+                let ret = self.draw_mercator_tiles(cx, source, snap_to_pixel);
202
                 if !self.marker_layer.is_empty() {
206
                 if !self.marker_layer.is_empty() {
203
                     self.draw_marker(cx, snap_to_pixel);
207
                     self.draw_marker(cx, snap_to_pixel);
204
                 }
208
                 }

src/tile_layer.rs → src/mercator_tile_layer.rs 查看文件

12
 
12
 
13
 
13
 
14
 #[derive(Debug)]
14
 #[derive(Debug)]
15
-pub struct TileLayer {
15
+pub struct MercatorTileLayer {
16
     program: Program,
16
     program: Program,
17
     buffer: Buffer,
17
     buffer: Buffer,
18
 }
18
 }
19
 
19
 
20
 
20
 
21
-impl TileLayer {
21
+impl MercatorTileLayer {
22
     pub fn new(
22
     pub fn new(
23
         cx: &mut Context,
23
         cx: &mut Context,
24
         atlas: &TileAtlas,
24
         atlas: &TileAtlas,
25
-    ) -> TileLayer
25
+    ) -> MercatorTileLayer
26
     {
26
     {
27
         let buffer = Buffer::new(cx, &[], 0);
27
         let buffer = Buffer::new(cx, &[], 0);
28
         check_gl_errors!(cx);
28
         check_gl_errors!(cx);
55
         );
55
         );
56
         check_gl_errors!(cx);
56
         check_gl_errors!(cx);
57
 
57
 
58
-        TileLayer {
58
+        MercatorTileLayer {
59
             program,
59
             program,
60
             buffer,
60
             buffer,
61
         }
61
         }