mirror of
https://github.com/publiclab/mapknitter.git
synced 2025-12-05 16:00:00 +01:00
reorganized trunk directory
This commit is contained in:
38
app/controllers/utility_controller.rb
Normal file
38
app/controllers/utility_controller.rb
Normal file
@@ -0,0 +1,38 @@
|
||||
class UtilityController < ApplicationController
|
||||
|
||||
def proxy
|
||||
url = URI.parse(params[:url])
|
||||
req = Net::HTTP::Get.new(url.path)
|
||||
res = Net::HTTP.start(url.host, url.port) {|http|
|
||||
http.request(req)
|
||||
}
|
||||
render :text => res.body
|
||||
end
|
||||
|
||||
def geocode_sites
|
||||
file = File.new("public/sites.txt", "r")
|
||||
line = file.gets.chomp!
|
||||
sites = []
|
||||
while (line) # goes through names in file until it finds one that hasn't been used yet
|
||||
begin
|
||||
geo = GeoKit::GeoLoc.geocode(line)
|
||||
rescue
|
||||
end
|
||||
if geo
|
||||
sites << [line,geo.lat,geo.lng]
|
||||
end
|
||||
line = file.gets.chomp!
|
||||
end
|
||||
file.close
|
||||
render :json => sites
|
||||
end
|
||||
|
||||
def geocode
|
||||
if params[:location]
|
||||
@geo = GeoKit::GeoLoc.geocode(params[:location])
|
||||
puts @geo.lat
|
||||
render :json => @geo if params[:format] == 'json'
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
Reference in New Issue
Block a user