Class: TZWhere::Query
- Inherits:
-
Object
- Object
- TZWhere::Query
- Defined in:
- lib/tzwhere/query.rb
Instance Method Summary collapse
-
#initialize ⇒ Query
constructor
A new instance of Query.
- #lookup(latitude, longitude) ⇒ Object
Constructor Details
#initialize ⇒ Query
Returns a new instance of Query.
3 4 5 6 7 8 9 10 |
# File 'lib/tzwhere/query.rb', line 3 def initialize @points ||= [] @timezones ||= [] load_points @kd = Kdtree.new(@points) end |
Instance Method Details
#lookup(latitude, longitude) ⇒ Object
12 13 14 |
# File 'lib/tzwhere/query.rb', line 12 def lookup(latitude, longitude) @timezones.at(@kd.nearest(latitude, longitude)) end |