]> git.openstreetmap.org Git - chef.git/blobdiff - cookbooks/tile/files/default/ruby/expire.rb
Fix rubocop warnings
[chef.git] / cookbooks / tile / files / default / ruby / expire.rb
index d695a0bc53de611f3a752fe424292ee1dc3bf560..3d693ad5b225d3fa9d1a525cd329e97672de0f46 100755 (executable)
@@ -18,9 +18,9 @@ module Expire
   # the size of the meta tile blocks
   METATILE = 8
   # the directory root for meta tiles
-  HASH_ROOT = "/tiles/default/"
+  HASH_ROOT = "/tiles/default/".freeze
   # node cache file
-  NODE_CACHE_FILE = "/store/database/nodes"
+  NODE_CACHE_FILE = "/store/database/nodes".freeze
 
   # turns a spherical mercator coord into a tile coord
   def self.tile_from_merc(point, zoom)
@@ -103,12 +103,8 @@ module Expire
     # added, deleted or modified - the tile will need updating anyway.
     doc.find("//node").each do |node|
       lat = node["lat"].to_f
-      if lat < -85
-        lat = -85
-      end
-      if lat > 85
-        lat = 85
-      end
+      lat = -85 if lat < -85
+      lat = 85 if lat > 85
       point = Proj4::Point.new(Math::PI * node["lon"].to_f / 180,
                                Math::PI * lat / 180)
       nodes[node["id"].to_i] = tile_from_latlon(point, max_zoom)
@@ -143,7 +139,7 @@ module Expire
     set = Set.new nodes.values
 
     # expire tiles and shrink to the set of parents
-    (max_zoom).downto(min_zoom) do |_|
+    max_zoom.downto(min_zoom) do |_|
       # allow the block to work on the set, returning the set at the next
       # zoom level
       set = yield set
@@ -186,9 +182,7 @@ module Expire
 
         lon, lat = @cache.sysread(8).unpack("ll")
 
-        if lon != -2147483648 && lat != -2147483648
-          node = Node.new(lon, lat)
-        end
+        node = Node.new(lon, lat) if lon != -2147483648 && lat != -2147483648
       end
 
       node