Class: TZWhere::Query

Inherits:
Object
  • Object
show all
Defined in:
lib/tzwhere/query.rb

Instance Method Summary collapse

Constructor Details

#initializeQuery

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