浏览代码

Fix OrthograficView::covers_viewport

Johannes Hofmann 7 年前
父节点
当前提交
f0dcd3a80c
共有 2 个文件被更改,包括 5 次插入6 次删除
  1. 2
    3
      src/map_view_gl.rs
  2. 3
    3
      src/orthografic_view.rs

+ 2
- 3
src/map_view_gl.rs 查看文件

6
 use mercator_tile_layer::MercatorTileLayer;
6
 use mercator_tile_layer::MercatorTileLayer;
7
 use mercator_view::MercatorView;
7
 use mercator_view::MercatorView;
8
 use ortho_tile_layer::OrthoTileLayer;
8
 use ortho_tile_layer::OrthoTileLayer;
9
+use orthografic_view::OrthograficView;
9
 use projection::Projection;
10
 use projection::Projection;
10
 use session::Session;
11
 use session::Session;
11
 use texture::{Texture, TextureFormat};
12
 use texture::{Texture, TextureFormat};
122
     pub fn map_covers_viewport(&self) -> bool {
123
     pub fn map_covers_viewport(&self) -> bool {
123
         match self.projection {
124
         match self.projection {
124
             Projection::Mercator => MercatorView::covers_viewport(&self.map_view),
125
             Projection::Mercator => MercatorView::covers_viewport(&self.map_view),
125
-            //TODO uncomment
126
-            //Projection::Orthografic => OrthograficView::covers_viewport(&self.map_view),
127
-            Projection::Orthografic => false,
126
+            Projection::Orthografic => OrthograficView::covers_viewport(&self.map_view),
128
         }
127
         }
129
     }
128
     }
130
 
129
 

+ 3
- 3
src/orthografic_view.rs 查看文件

123
 impl OrthograficView {
123
 impl OrthograficView {
124
     /// Returns true if the rendering covers the whole viewport.
124
     /// Returns true if the rendering covers the whole viewport.
125
     pub fn covers_viewport(map_view: &MapView) -> bool {
125
     pub fn covers_viewport(map_view: &MapView) -> bool {
126
-        //TODO Add a little safety margin since the rendered globe is not a perfect sphere and its
127
-        // screen area is underestimated by the tesselation.
128
         let sphere_diameter = 2.0f64.powf(map_view.zoom) *
126
         let sphere_diameter = 2.0f64.powf(map_view.zoom) *
129
             (f64::consts::FRAC_1_PI * f64::from(map_view.tile_size));
127
             (f64::consts::FRAC_1_PI * f64::from(map_view.tile_size));
130
 
128
 
131
-        map_view.width.hypot(map_view.height) < sphere_diameter
129
+        // Add a little safety margin (the constant factor) since the rendered globe is not a
130
+        // perfect sphere and its screen area is underestimated by the tesselation.
131
+        map_view.width.hypot(map_view.height) < sphere_diameter * 0.9
132
     }
132
     }
133
 
133
 
134
     /// Returns the tile zoom value that is used for rendering with the current zoom.
134
     /// Returns the tile zoom value that is used for rendering with the current zoom.