]> git.openstreetmap.org Git - rails.git/blob - app/controllers/export_controller.rb
Merge remote-tracking branch 'upstream/pull/5353'
[rails.git] / app / controllers / export_controller.rb
1 class ExportController < ApplicationController
2   before_action :authorize_web
3   before_action :set_locale
4   before_action :update_totp, :only => [:finish]
5   authorize_resource :class => false
6
7   content_security_policy(:only => :embed) do |policy|
8     policy.frame_ancestors("*")
9   end
10
11   caches_page :embed
12
13   # When the user clicks 'Export' we redirect to a URL which generates the export download
14   def finish
15     bbox = BoundingBox.from_lon_lat_params(params)
16     style = params[:format]
17     format = params[:mapnik_format]
18
19     case style
20     when "osm"
21       # redirect to API map get
22       redirect_to :controller => "api/map", :action => "index", :bbox => bbox
23
24     when "mapnik"
25       # redirect to a special 'export' cgi script
26       scale = params[:mapnik_scale]
27
28       redirect_to "https://render.openstreetmap.org/cgi-bin/export?bbox=#{bbox}&scale=#{scale}&format=#{format}", :allow_other_host => true
29     when "cyclemap", "transportmap"
30       zoom = params[:zoom]
31       lat = params[:lat]
32       lon = params[:lon]
33       width = params[:width]
34       height = params[:height]
35
36       redirect_to "https://tile.thunderforest.com/static/#{style[..-4]}/#{lon},#{lat},#{zoom}/#{width}x#{height}.#{format}?apikey=#{Settings.thunderforest_key}", :allow_other_host => true
37     end
38   end
39
40   def embed; end
41 end