Might be useful to set the locale everywhere we need the web, rather than just the...
[rails.git] / app / controllers / export_controller.rb
1 class ExportController < ApplicationController
2
3   before_filter :set_locale
4
5   def start
6   end
7
8   #When the user clicks 'Export' we redirect to a URL which generates the export download
9   def finish
10     bbox = BoundingBox.new(params[:minlon], params[:minlat], params[:maxlon], params[:maxlat])
11     format = params[:format]
12
13     if format == "osm"
14       #redirect to API map get
15       redirect_to "http://api.openstreetmap.org/api/#{API_VERSION}/map?bbox=#{bbox}"
16
17     elsif format == "mapnik"
18       #redirect to a special 'export' cgi script
19       format = params[:mapnik_format]
20       scale = params[:mapnik_scale]
21
22       redirect_to "http://tile.openstreetmap.org/cgi-bin/export?bbox=#{bbox}&scale=#{scale}&format=#{format}"
23
24     elsif format == "osmarender"
25       #redirect to the t@h 'MapOf' service
26       format = params[:osmarender_format]
27       zoom = params[:osmarender_zoom].to_i
28       width = bbox.slippy_width(zoom).to_i
29       height = bbox.slippy_height(zoom).to_i
30
31       redirect_to "http://tah.openstreetmap.org/MapOf/index.php?long=#{bbox.centre_lon}&lat=#{bbox.centre_lat}&z=#{zoom}&w=#{width}&h=#{height}&format=#{format}"
32     end
33   end
34 end