More work on export tab.
[rails.git] / app / controllers / export_controller.rb
1 class ExportController < ApplicationController
2   def start
3     render :update do |page|
4       page.replace_html :sidebar_title, 'Export'
5       page.replace_html :sidebar_content, :partial => 'start'
6       page.call "openSidebar"
7     end
8   end
9
10   def finish
11     bbox = BoundingBox.new(params[:minlon], params[:minlat], params[:maxlon], params[:maxlat])
12     format = params[:format]
13
14     if format == "osm"
15       redirect_to "http://api.openstreetmap.org/api/#{API_VERSION}/map?bbox=#{bbox}"
16     elsif format == "mapnik"
17       format = params[:mapnik_format]
18       scale = params[:mapnik_scale]
19
20       redirect_to "http://tile.openstreetmap.org/cgi-bin/export?bbox=#{bbox}&scale=#{scale}&format=#{format}"
21     elsif format == "osmarender"
22       format = params[:osmarender_format]
23       zoom = params[:osmarender_zoom].to_i
24       width = bbox.slippy_width(zoom).to_i
25       height = bbox.slippy_height(zoom).to_i
26
27       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}"
28     end
29   end
30 end