Commits

Oliver Tonnhofer committed 06aa148

fixed one-off bug in grid.max_res

  • Participants
  • Parent commits 9890250
  • Branches 1.0.x

Comments (0)

Files changed (3)

 
 Fixes:
 - fixes demo on Windows (loaded static content from wrong path)
+- fixed one-off error with grid.max_res: last resolution is now < max_res
+  e.g. min_res: 1000 max_res: 300 -> now [1000, 500], before [1000, 500, 250]
 
 1.0.0 2011-03-03
 

File mapproxy/grid.py

             res = [10**(math.log10(min_res) - res_step*i) for i in range(num_levels)]
         else:
             res = [min_res]
-            while res[-1] > max_res:
-                res.append(res[-1]/res_factor)
+            while True:
+                next_res = res[-1]/res_factor
+                if max_res >= next_res:
+                    break
+                res.append(next_res)
     else:
         if not num_levels:
             num_levels = 20 if res_factor != math.sqrt(2) else 40
         res = [min_res]
         while len(res) < num_levels:
             res.append(res[-1]/res_factor)
-    
+        
     return res
 
 def grid_bbox(bbox, bbox_srs, srs):

File mapproxy/test/unit/test_grid.py

     def test_min_res_max_res(self):
         conf = dict(min_res=1000, max_res=80)
         res = resolutions(**conf)
-        eq_(res, [1000, 500.0, 250.0, 125.0, 62.5])
+        eq_(res, [1000, 500.0, 250.0, 125.0])
     
     def test_min_res_levels(self):
         conf = dict(min_res=1600, num_levels=5)