From: Grant Date: Sun, 31 Jan 2016 17:35:23 +0000 (+0000) Subject: Merge pull request #50 from Firefishy/add-imagery X-Git-Url: https://git.openstreetmap.org/chef.git/commitdiff_plain/56df259055ae541d1f31b8502c549cb84f74778e?hp=67a8cd87d0d8e9bddd4a5790079101a08b9f5101 Merge pull request #50 from Firefishy/add-imagery Add imagery --- diff --git a/cookbooks/imagery/files/default/ossv-palette.txt b/cookbooks/imagery/files/default/ossv-palette.txt new file mode 100644 index 000000000..191fb60e9 --- /dev/null +++ b/cookbooks/imagery/files/default/ossv-palette.txt @@ -0,0 +1,256 @@ +255,246,238 +98,65,74 +213,230,131 +90,82,82 +255,148,131 +255,90,98 +238,246,246 +57,24,24 +222,98,98 +115,74,65 +8,16,8 +230,238,238 +0,8,0 +230,213,164 +230,238,230 +32,32,16 +139,180,189 +238,230,90 +255,255,148 +32,32,32 +222,246,164 +16,8,8 +189,180,74 +213,246,148 +8,0,0 +90,82,90 +222,197,180 +238,246,238 +246,255,246 +115,49,49 +205,230,164 +246,238,98 +213,156,98 +246,255,213 +180,164,131 +246,106,106 +230,213,213 +24,24,24 +230,238,246 +255,213,131 +65,65,57 +41,41,41 +238,255,246 +205,180,123 +156,74,65 +222,222,131 +197,139,131 +213,238,156 +172,180,172 +213,180,172 +197,230,131 +74,74,74 +205,213,197 +205,238,131 +213,238,164 +213,189,131 +106,98,98 +246,205,123 +189,131,115 +205,238,139 +106,98,106 +82,90,82 +230,255,255 +16,16,8 +156,57,41 +156,156,156 +255,246,222 +238,255,205 +205,255,139 +246,255,238 +180,106,65 +106,106,98 +180,172,98 +115,106,98 +180,213,255 +139,57,57 +98,106,98 +246,238,222 +180,106,106 +115,106,49 +164,205,164 +16,16,16 +8,16,16 +164,180,189 +49,49,49 +205,197,156 +106,106,115 +222,246,172 +65,65,65 +246,222,139 +238,230,230 +238,255,255 +238,205,131 +148,106,106 +197,230,123 +189,189,172 +213,205,98 +74,74,24 +213,106,106 +197,197,180 +238,238,222 +205,246,131 +246,222,164 +172,197,123 +8,8,8 +8,8,0 +180,180,180 +230,230,205 +123,8,8 +8,8,16 +246,255,230 +255,180,172 +0,8,8 +172,172,164 +74,32,32 +205,222,238 +106,115,123 +131,131,49 +246,246,246 +172,156,115 +246,222,148 +255,230,164 +246,246,238 +246,246,255 +139,131,115 +246,246,230 +205,205,205 +255,222,139 +246,238,246 +255,222,131 +172,172,172 +82,82,82 +74,82,98 +82,82,74 +180,180,164 +123,164,238 +16,8,16 +148,164,115 +255,238,189 +82,82,90 +98,98,98 +255,238,123 +98,98,90 +255,238,172 +98,90,90 +246,222,189 +197,197,197 +106,106,106 +98,106,106 +222,222,222 +98,98,106 +106,0,0 +123,123,115 +90,139,246 +164,164,164 +246,115,115 +222,222,205 +255,115,115 +255,106,115 +74,74,90 +156,156,164 +0,0,0 +0,0,8 +255,246,205 +115,115,106 +238,238,238 +246,238,230 +213,213,197 +255,255,189 +255,230,148 +106,115,98 +90,90,90 +90,90,82 +189,189,189 +90,90,98 +255,246,98 +255,255,246 +238,238,230 +57,57,57 +238,246,255 +222,115,115 +139,139,139 +230,246,246 +222,238,255 +246,156,148 +90,98,98 +8,0,8 +255,230,180 +180,82,74 +74,131,246 +255,246,230 +238,230,238 +197,238,131 +164,197,246 +197,230,148 +197,238,139 +189,230,139 +82,90,90 +255,238,197 +255,123,123 +230,230,230 +230,230,238 +246,98,98 +246,213,131 +246,213,139 +238,213,139 +230,246,180 +230,222,222 +255,213,139 +230,246,255 +246,205,131 +255,255,238 +255,255,230 +246,255,255 +255,246,246 +255,255,255 +0,0,0 +0,0,0 +0,0,0 +0,0,0 +0,0,0 +0,0,0 +0,0,0 +0,0,0 +0,0,0 +0,0,0 +0,0,0 +0,0,0 +0,0,0 +0,0,0 +0,0,0 +0,0,0 +0,0,0 +0,0,0 +0,0,0 +0,0,0 +0,0,0 +0,0,0 +0,0,0 +0,0,0 +0,0,0 +0,0,0 +0,0,0 +0,0,0 +0,0,0 +0,0,0 +0,0,0 +0,0,0 +0,0,0 +0,0,0 +0,0,0 +0,0,0 +0,0,0 +0,0,0 +0,0,0 +0,0,0 diff --git a/cookbooks/imagery/recipes/au_agri.rb b/cookbooks/imagery/recipes/au_agri.rb new file mode 100644 index 000000000..3474c4cda --- /dev/null +++ b/cookbooks/imagery/recipes/au_agri.rb @@ -0,0 +1,32 @@ +# +# Cookbook Name:: imagery +# Recipe:: au-agri +# +# Copyright 2016, OpenStreetMap Foundation +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +include_recipe "imagery" + +imagery_site "agri.openstreetmap.org" do + # aliases ["agri.openstreetmap.org.au"] + + imagery_layer "au_ga_agri" do + site new_resource.name + text "AGRI: The Australian Geographic Reference Image" + copyright "Commonwealth of Australia (Geoscience Australia) - Creative Commons Attribution 4.0 International Licence" + projection "EPSG:3857" + source "/data/imagery/au/agri/combine.vrt" + end +end diff --git a/cookbooks/imagery/recipes/default.rb b/cookbooks/imagery/recipes/default.rb index e12487875..7c3d186aa 100644 --- a/cookbooks/imagery/recipes/default.rb +++ b/cookbooks/imagery/recipes/default.rb @@ -47,6 +47,13 @@ directory "/var/run/mapserver-fastcgi" do mode 0755 end +directory "/srv/imagery/mapserver" do + owner "root" + group "root" + mode 0755 + recursive true +end + directory "/srv/imagery/common" do owner "root" group "root" diff --git a/cookbooks/imagery/recipes/gb_hampshire_aerial.rb b/cookbooks/imagery/recipes/gb_hampshire_aerial.rb new file mode 100644 index 000000000..8209c0d28 --- /dev/null +++ b/cookbooks/imagery/recipes/gb_hampshire_aerial.rb @@ -0,0 +1,38 @@ +# +# Cookbook Name:: imagery +# Recipe:: gb-hampshire-aerial +# +# Copyright 2016, OpenStreetMap Foundation +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +include_recipe "imagery" + +imagery_site "hampshire.aerial.openstreetmap.org.uk" do + imagery_layer "gb_hampshire_aerial-rgb" do + site new_resource.name + text "Hampshire Aerial - Summer 2013" + source "/data/imagery/gb/hampshire-aerial/hampshire-aerial-RGB.tif" + projection "EPSG:27700" + copyright "Hampshire Hub - Open Government Licence (OGL) 2014" + end + + imagery_layer "gb_hampshire_aerial_fcir" do + site new_resource.name + text "Hampshire Aerial - Summer 2013 (FCIR)" + source "/data/imagery/gb/hampshire-aerial/hampshire-aerial-FCIR.tif" + projection "EPSG:27700" + copyright "Hampshire Hub - Open Government Licence (OGL) 2014" + end +end diff --git a/cookbooks/imagery/recipes/gb_os_sv.rb b/cookbooks/imagery/recipes/gb_os_sv.rb new file mode 100644 index 000000000..0817029e7 --- /dev/null +++ b/cookbooks/imagery/recipes/gb_os_sv.rb @@ -0,0 +1,163 @@ +# +# Cookbook Name:: imagery +# Recipe:: gb-ossv +# +# Copyright 2016, OpenStreetMap Foundation +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +include_recipe "imagery" + +cookbook_file "/srv/imagery/common/ossv-palette.txt" do + source "ossv-palette.txt" + owner "root" + group "root" + mode "0644" +end + +imagery_site "os.openstreetmap.org" do + aliases ["os.openstreetmap.org.uk"] + + imagery_layer "gb_os_sv_2010_04" do + site new_resource.name + projection "EPSG:27700" + source "/data/imagery/gb/os-sv/ossv-2010-04-combined.vrt" + copyright "Contains Ordnance Survey data © Crown copyright and database right 2010" # FIXME: Correct Copyright? + background_colour "230 246 255" # OSSV Water Blue + extension "png" + palette "/srv/imagery/common/ossv-palette.txt" + extent "5000 5000 660000 1225000" + end + + imagery_layer "gb_os_sv_2010_11" do + site new_resource.name + projection "EPSG:27700" + source "/data/imagery/gb/os-sv/ossv-2010-11-combined.vrt" + copyright "Contains Ordnance Survey data © Crown copyright and database right 2010" # FIXME: Correct Copyright? + background_colour "230 246 255" # OSSV Water Blue + extension "png" + palette "/srv/imagery/common/ossv-palette.txt" + extent "5000 5000 660000 1225000" + end + + imagery_layer "gb_os_sv_2011_05" do + site new_resource.name + projection "EPSG:27700" + source "/data/imagery/gb/os-sv/ossv-2011-05-combined.vrt" + copyright "Contains Ordnance Survey data © Crown copyright and database right 2011" # FIXME: Correct Copyright? + background_colour "230 246 255" # OSSV Water Blue + extension "png" + palette "/srv/imagery/common/ossv-palette.txt" + extent "5000 5000 660000 1225000" + end + + imagery_layer "gb_os_sv_2011_11" do + site new_resource.name + projection "EPSG:27700" + source "/data/imagery/gb/os-sv/ossv-2011-11-combined.vrt" + copyright "Contains Ordnance Survey data © Crown copyright and database right 2011" # FIXME: Correct Copyright? + background_colour "230 246 255" # OSSV Water Blue + extension "png" + palette "/srv/imagery/common/ossv-palette.txt" + extent "5000 5000 660000 1225000" + end + + imagery_layer "gb_os_sv_2012_05" do + site new_resource.name + projection "EPSG:27700" + source "/data/imagery/gb/os-sv/ossv-2012-05-combined.vrt" + copyright "Contains Ordnance Survey data © Crown copyright and database right 2012" + background_colour "230 246 255" # OSSV Water Blue + extension "png" + palette "/srv/imagery/common/ossv-palette.txt" + extent "5000 5000 660000 1225000" + end + + imagery_layer "gb_os_sv_2012_11" do + site new_resource.name + projection "EPSG:27700" + source "/data/imagery/gb/os-sv/ossv-2012-11-combined.vrt" + copyright "Contains Ordnance Survey data © Crown copyright and database right 2012" + background_colour "230 246 255" # OSSV Water Blue + extension "png" + palette "/srv/imagery/common/ossv-palette.txt" + extent "5000 5000 660000 1225000" + end + + imagery_layer "gb_os_sv_2013_05" do + site new_resource.name + projection "EPSG:27700" + source "/data/imagery/gb/os-sv/ossv-2013-05-combined.vrt" + copyright "Contains Ordnance Survey data © Crown copyright and database right 2013" + background_colour "230 246 255" # OSSV Water Blue + extension "png" + palette "/srv/imagery/common/ossv-palette.txt" + extent "5000 5000 660000 1225000" + end + + imagery_layer "gb_os_sv_2013_11" do + site new_resource.name + projection "EPSG:27700" + source "/data/imagery/gb/os-sv/ossv-2013-11-combined.vrt" + copyright "Contains Ordnance Survey data © Crown copyright and database right 2013" + background_colour "230 246 255" # OSSV Water Blue + extension "png" + palette "/srv/imagery/common/ossv-palette.txt" + extent "5000 5000 660000 1225000" + end + + imagery_layer "gb_os_sv_2014_04" do + site new_resource.name + projection "EPSG:27700" + source "/data/imagery/gb/os-sv/ossv-2014-04-combined.vrt" + copyright "Contains Ordnance Survey data © Crown copyright and database right 2014" + background_colour "230 246 255" # OSSV Water Blue + extension "png" + palette "/srv/imagery/common/ossv-palette.txt" + extent "5000 5000 660000 1225000" + end + + imagery_layer "gb_os_sv_2014_10" do + site new_resource.name + projection "EPSG:27700" + source "/data/imagery/gb/os-sv/ossv-2014-10-combined.vrt" + copyright "Contains Ordnance Survey data © Crown copyright and database right 2014" + background_colour "230 246 255" # OSSV Water Blue + extension "png" + palette "/srv/imagery/common/ossv-palette.txt" + extent "5000 5000 660000 1225000" + end + + imagery_layer "gb_os_sv_2015-05" do + site new_resource.name + projection "EPSG:27700" + source "/data/imagery/gb/os-sv/ossv-2015-05-combined.vrt" + copyright "Contains Ordnance Survey data © Crown copyright and database right 2015" + background_colour "230 246 255" # OSSV Water Blue + extension "png" + palette "/srv/imagery/common/ossv-palette.txt" + extent "5000 5000 660000 1225000" + end + + imagery_layer "gb_os_sv_2015_11" do + site new_resource.name + projection "EPSG:27700" + source "/data/imagery/gb/os-sv/ossv-2015-11-combined.vrt" + copyright "Contains Ordnance Survey data © Crown copyright and database right 2015" + background_colour "230 246 255" # OSSV Water Blue + extension "png" + palette "/srv/imagery/common/ossv-palette.txt" + extent "5000 5000 660000 1225000" + end +end diff --git a/cookbooks/imagery/recipes/gb_surrey_aerial.rb b/cookbooks/imagery/recipes/gb_surrey_aerial.rb new file mode 100644 index 000000000..97bc879c9 --- /dev/null +++ b/cookbooks/imagery/recipes/gb_surrey_aerial.rb @@ -0,0 +1,28 @@ +# +# Cookbook Name:: imagery +# Recipe:: gb-surrey-aerial +# +# Copyright 2016, OpenStreetMap Foundation +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +include_recipe "imagery" + +imagery_site "surrey.aerial.openstreetmap.org.uk" do + imagery_layer "gb-surrey-aerial" do + site new_resource.name + projection "EPSG:27700" + source "/data/imagery/gb/surrey-aerial/SurreyMosaicECW.tif" + end +end diff --git a/cookbooks/imagery/resources/layer.rb b/cookbooks/imagery/resources/layer.rb new file mode 100644 index 000000000..ee6a8f1c0 --- /dev/null +++ b/cookbooks/imagery/resources/layer.rb @@ -0,0 +1,102 @@ +# +# Cookbook Name:: imagery +# Resource:: imagery_layer +# +# Copyright 2016, OpenStreetMap Foundation +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +default_action :create + +property :name, String +property :site, String, :required => true +property :source, String, :required => true +property :text, String +property :copyright, String, :default => "Copyright" +property :projection, String, :default => "EPSG:3857" +property :palette, String +property :extent, String +property :background, String +property :resample, String, :default => "average" +property :imagemode, String +property :extension, String, + :is => %w(png png8 jpeg), + :default => "png" +property :max_zoom, Fixnum, :default => 23 + +action :create do + template "/srv/imagery/mapserver/layer-#{name}.map" do + cookbook "imagery" + source "mapserver.map.erb" + owner "root" + group "root" + mode 0644 + variables new_resource.to_hash + end + + template "/etc/init/mapserv-fgi-layer-#{name}.conf" do + cookbook "imagery" + source "mapserv_fcgi.conf.erb" + owner "root" + group "root" + mode 0644 + variables new_resource.to_hash + end + + service "mapserv-fgi-layer-#{name}.conf" do + provider Chef::Provider::Service::Upstart + action [:enable, :start] + supports :status => true, :restart => true, :reload => false + subscribes :restart, "template[/srv/imagery/mapserver/layer-#{name}.map]" + subscribes :restart, "template[/etc/init/mapserv-fgi-layer-#{name}.conf]" + end + + directory "/srv/imagery/nginx/#{site}" do + owner "root" + group "root" + mode 0755 + recursive true + end + + template "/srv/imagery/nginx/#{site}/layer-#{name}.conf" do + cookbook "imagery" + source "nginx_imagery_layer_fragment.conf.erb" + owner "root" + group "root" + mode 0644 + variables new_resource.to_hash + notifies :reload, "service[nginx]", :delayed + end +end + +action :delete do + service "mapserv-fgi-layer-#{name}.conf" do + provider Chef::Provider::Service::Upstart + action [:stop, :disable] + supports :status => true, :restart => true, :reload => false + end + + file "/srv/imagery/mapserver/layer-#{name}.map" do + action :delete + end + + file "/etc/init/mapserv-fgi-layer-#{name}.conf" do + action :delete + end + + file "/srv/imagery/nginx/#{site}/layer-#{name}.conf" do + action :delete + notifies :reload, "service[nginx]", :delayed + end +end diff --git a/cookbooks/imagery/resources/site.rb b/cookbooks/imagery/resources/site.rb new file mode 100644 index 000000000..dfda20da1 --- /dev/null +++ b/cookbooks/imagery/resources/site.rb @@ -0,0 +1,36 @@ +# +# Cookbook Name:: imagery +# Resource:: imagery_site +# +# Copyright 2016, OpenStreetMap Foundation +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +default_action :create + +property :name, String + +action :create do + directory "/srv/imagery/#{name}" do + owner "root" + group "root" + mode 0755 + end + + nginx_site name do + template "nginx_imagery.conf.erb" + directory "/srv/imagery/#{name}" + variables new_resource.to_hash + end +end diff --git a/cookbooks/imagery/templates/default/mapserv_fcgi.conf.erb b/cookbooks/imagery/templates/default/mapserv_fcgi.conf.erb new file mode 100644 index 000000000..9f6e25093 --- /dev/null +++ b/cookbooks/imagery/templates/default/mapserv_fcgi.conf.erb @@ -0,0 +1,29 @@ +# DO NOT EDIT - This file is being maintained by Chef + +description "starts mapserver in daemon mode for fastcgi" + +start on (net-device-up + and local-filesystems + and runlevel [2345]) +stop on runlevel [!2345] + +respawn + +setuid imagery +setgid imagery + +limit nofile 16384 16384 + +# https://trac.osgeo.org/mapserver/wiki/EnvironmentVariables +env MS_MAPFILE="/srv/imagery/mapserver/layer-<%= @name %>.map" +env MS_MAP_PATTERN="^/srv/imagery/mapserver/" +env MS_ERRORFILE="/tmp/mapserver-layer-<%= @name %>.log" +env MS_DEBUGLEVEL="5" + +script + exec /usr/bin/spawn-fcgi \ + -n \ + -s /var/run/mapserver-fastcgi/layer-<%= @name %>.socket \ + -M 0666 \ + -f /usr/lib/cgi-bin/mapserv +end script diff --git a/cookbooks/imagery/templates/default/mapserver.map.erb b/cookbooks/imagery/templates/default/mapserver.map.erb new file mode 100644 index 000000000..29a83c27c --- /dev/null +++ b/cookbooks/imagery/templates/default/mapserver.map.erb @@ -0,0 +1,23 @@ +# DO NOT EDIT - This file is being maintained by Chef +MAP + NAME "map-<%= @name %>" + STATUS ON + SIZE 256 256 + UNITS METERS + IMAGETYPE <%= @extension %> + PROJECTION + "init=<%= @projection %>" + END + + LAYER + NAME "<%= @name %>" + DATA "<%= @source %>" + PROJECTION + "init=<%= @projection %>" + END + STATUS DEFAULT + TYPE RASTER + PROCESSING "RESAMPLE=AVERAGE" + PROCESSING "CLOSE_CONNECTION=DEFER" + END # layer +END diff --git a/cookbooks/imagery/templates/default/nginx_imagery.conf.erb b/cookbooks/imagery/templates/default/nginx_imagery.conf.erb new file mode 100644 index 000000000..e1bbed8f8 --- /dev/null +++ b/cookbooks/imagery/templates/default/nginx_imagery.conf.erb @@ -0,0 +1,7 @@ +server { + listen 80; + server_name <%= @name %>; + + # Include site imagery layers + include /srv/imagery/nginx/<%= @name %>/layer-*.conf +} diff --git a/cookbooks/imagery/templates/default/nginx_imagery_layer_fragment.conf.erb b/cookbooks/imagery/templates/default/nginx_imagery_layer_fragment.conf.erb new file mode 100644 index 000000000..9c3fbd538 --- /dev/null +++ b/cookbooks/imagery/templates/default/nginx_imagery_layer_fragment.conf.erb @@ -0,0 +1,9 @@ +# DO NOT EDIT - This file is being maintained by Chef + +location ~* "^/layer/<%= @name %>/(\d+)/(\d+)/(\d+)\.(png|jpg|jpeg)$" { + # Override QUERY_STRING to force mapserver query parameters + fastcgi_param QUERY_STRING "map=/srv/imagery/<%= @name %>.map&mode=tile&layers=<%= @name %>&tilemode=gmap&tile=$2+$3+$1"; + fastcgi_pass "unix:/var/run/mapserver-fastcgi/layer-<%= @name %>.socket"; + include fastcgi_params; + gzip off; +}