From: Tom Hughes Date: Mon, 1 Jul 2013 20:43:54 +0000 (+0100) Subject: Make the maximum zoom level configurable X-Git-Url: https://git.openstreetmap.org/chef.git/commitdiff_plain/d8fc1ec5f984b7ab6a7886e054c9dd272d3678b1?hp=3b9afa09fa710d6845058d1befe1d75587992a53 Make the maximum zoom level configurable --- diff --git a/cookbooks/tile/files/default/ruby/expire.rb b/cookbooks/tile/files/default/ruby/expire.rb index ec0a59860..917b75747 100755 --- a/cookbooks/tile/files/default/ruby/expire.rb +++ b/cookbooks/tile/files/default/ruby/expire.rb @@ -20,11 +20,6 @@ module Expire METATILE = 8 # the directory root for meta tiles HASH_ROOT = "/tiles/default/" - # lowest zoom that we want to expire - # MIN_ZOOM=12 - MIN_ZOOM=13 - # highest zoom that we want to expire - MAX_ZOOM=18 # database parameters DBNAME="gis" DBHOST="" @@ -72,8 +67,8 @@ module Expire File.utime(EXPIRY_TIME, EXPIRY_TIME, meta) end - def Expire.expire(change_file, tile_dirs) - do_expire(change_file) do |set| + def Expire.expire(change_file, min_zoom, max_zoom, tile_dirs) + do_expire(change_file, min_zoom, max_zoom) do |set| new_set = Set.new meta_set = Set.new @@ -102,7 +97,7 @@ module Expire end end - def Expire.do_expire(change_file, &block) + def Expire.do_expire(change_file, min_zoom, max_zoom, &block) # read in the osm change file doc = XML::Document.file(change_file) @@ -121,7 +116,7 @@ module Expire end 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) + nodes[node['id'].to_i] = tile_from_latlon(point, max_zoom) end # now we look for all the ways that have changed and put all of their nodes into @@ -143,7 +138,7 @@ module Expire # loop over results, adding tiles to the change set res.each do |row| point = Proj4::Point.new(row[0].to_f / 100.0, row[1].to_f / 100.0) - nodes[node_id] = tile_from_merc(point, MAX_ZOOM) + nodes[node_id] = tile_from_merc(point, max_zoom) end # Discard results @@ -157,7 +152,7 @@ module Expire set = Set.new nodes.values # expire tiles and shrink to the set of parents - (MAX_ZOOM).downto(MIN_ZOOM) do |z| + (max_zoom).downto(min_zoom) do |z| # allow the block to work on the set, returning the set at the next # zoom level set = yield set diff --git a/cookbooks/tile/templates/default/expire-tiles.erb b/cookbooks/tile/templates/default/expire-tiles.erb index beea05dd9..2c0e7406e 100644 --- a/cookbooks/tile/templates/default/expire-tiles.erb +++ b/cookbooks/tile/templates/default/expire-tiles.erb @@ -8,8 +8,10 @@ tile_dirs = [ <% node[:tile][:styles].each do |name,details| -%> "/srv/tile.openstreetmap.org/tiles/<%= name %>", <% end -%> -]; +] + +max_zoom = <%= node[:tile][:styles].collect { |n,d| d[:max_zoom] }.max %> ARGV.each do |f| - Expire::expire(f, tile_dirs) + Expire::expire(f, 13, max_zoom, tile_dirs) end diff --git a/cookbooks/tile/templates/default/renderd.conf.erb b/cookbooks/tile/templates/default/renderd.conf.erb index ebd8c14eb..f4abb6e3c 100644 --- a/cookbooks/tile/templates/default/renderd.conf.erb +++ b/cookbooks/tile/templates/default/renderd.conf.erb @@ -16,4 +16,6 @@ font_dir_recurse=true URI=/<%= name %>/ XML=/srv/tile.openstreetmap.org/styles/<%= name %>/project.xml HOST=tile.openstreetmap.org +MINZOOM=0 +MAXZOOM=<%= details[:max_zoom] %> <% end -%> diff --git a/roles/tile.rb b/roles/tile.rb index cc5a1ba56..c9338173a 100644 --- a/roles/tile.rb +++ b/roles/tile.rb @@ -64,7 +64,8 @@ default_attributes( :styles => { :default => { :repository => "git://github.com/gravitystorm/openstreetmap-carto.git", - :revision => "v2.2.0" + :revision => "v2.2.0", + :max_zoom => 19 } } }