3 # Resource:: imagery_layer
5 # Copyright:: 2016, OpenStreetMap Foundation
7 # Licensed under the Apache License, Version 2.0 (the "License");
8 # you may not use this file except in compliance with the License.
9 # You may obtain a copy of the License at
11 # https://www.apache.org/licenses/LICENSE-2.0
13 # Unless required by applicable law or agreed to in writing, software
14 # distributed under the License is distributed on an "AS IS" BASIS,
15 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 # See the License for the specific language governing permissions and
17 # limitations under the License.
24 default_action :create
26 property :layer, String, :name_property => true
27 property :site, String, :required => true
28 property :source, String, :required => [:create]
29 property :root_layer, [true, false], :default => false
30 property :title, String
31 property :copyright, String, :default => "Copyright"
32 property :projection, String, :default => "EPSG:3857"
33 property :palette, String
34 property :extent, String
35 property :background_colour, String
36 property :resample, String, :default => "average"
37 property :imagemode, String
38 property :extension, String, :default => "png"
39 property :max_zoom, Integer, :default => 18
40 property :url_aliases, [String, Array], :default => []
41 property :revision, Integer, :default => 0
42 property :overlay, [true, false], :default => false
43 property :default_layer, [true, false], :default => false
44 property :uses_tiler, [true, false], :default => false
47 file "/srv/imagery/layers/#{new_resource.site}/#{new_resource.layer}.yml" do
51 content YAML.dump(:name => new_resource.layer,
52 :title => new_resource.title || new_resource.layer,
53 :url => "//#{new_resource.site}/layer/#{new_resource.layer}/{z}/{x}/{y}.#{new_resource.extension}".gsub(/.*_png$/, "png"),
54 :attribution => new_resource.copyright,
55 :default => new_resource.default_layer,
56 :maxZoom => new_resource.max_zoom,
57 :overlay => new_resource.overlay)
60 template "/srv/imagery/mapserver/layer-#{new_resource.layer}.map" do
62 source "mapserver.map.erb"
66 variables new_resource.to_hash
67 not_if { new_resource.uses_tiler }
70 directory "/srv/imagery/nginx/#{new_resource.site}" do
77 template "/srv/imagery/nginx/#{new_resource.site}/layer-#{new_resource.layer}.conf" do
79 source "nginx_imagery_layer_fragment.conf.erb"
83 variables new_resource.to_hash
88 file "/srv/imagery/layers/#{new_resource.site}/#{new_resource.layer}.yml" do
92 file "/srv/imagery/mapserver/layer-#{new_resource.layer}.map" do
96 file "/srv/imagery/nginx/#{new_resource.site}/layer-#{new_resource.layer}.conf" do
102 notifies :create, "imagery_site[#{site}]"
103 notifies :restart, "service[nginx]"