Przeglądaj źródła

Fix OrthograficView::covers_viewport

Johannes Hofmann 7 lat temu
rodzic
commit
f0dcd3a80c
2 zmienionych plików z 5 dodań i 6 usunięć
  1. 2
    3
      src/map_view_gl.rs
  2. 3
    3
      src/orthografic_view.rs

+ 2
- 3
src/map_view_gl.rs Wyświetl plik

@@ -6,6 +6,7 @@ use marker_layer::MarkerLayer;
6 6
 use mercator_tile_layer::MercatorTileLayer;
7 7
 use mercator_view::MercatorView;
8 8
 use ortho_tile_layer::OrthoTileLayer;
9
+use orthografic_view::OrthograficView;
9 10
 use projection::Projection;
10 11
 use session::Session;
11 12
 use texture::{Texture, TextureFormat};
@@ -122,9 +123,7 @@ impl MapViewGl {
122 123
     pub fn map_covers_viewport(&self) -> bool {
123 124
         match self.projection {
124 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 Wyświetl plik

@@ -123,12 +123,12 @@ pub struct OrthograficView {
123 123
 impl OrthograficView {
124 124
     /// Returns true if the rendering covers the whole viewport.
125 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 126
         let sphere_diameter = 2.0f64.powf(map_view.zoom) *
129 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 134
     /// Returns the tile zoom value that is used for rendering with the current zoom.