Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Cannot retrieve contributors at this time

46 lines (34 sloc) 0.824 kb
require 'geo-distance'
class EarthquakesController < ApplicationController
def index
@quakes = Quake.all
@current_time = Time.new.utc
on = params[:on]
if on
@on_param = Time.at(on.to_i)
@quakes.keep_if { |q|
@on_param.to_date == q.q_date.to_date
}
end
over = params[:over]
if over
@over_param = over.to_f
@quakes.keep_if { |q|
@over_param < q.magnitude
}
end
near = params[:near]
if near
lat, long = near.split(',')
@near_param = [lat, long]
@quakes.keep_if { |q|
dist = GeoDistance::Haversine.geo_distance(lat, long, q.latitude, q.longtitude).miles
dist <= 5
}
end
respond_to do |format|
format.html
format.json { render :json => @quakes }
end
end
end
Jump to Line
Something went wrong with that request. Please try again.