Class: Sunspot::Query::Geo

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

Constant Summary collapse

MAX_PRECISION =
12
DEFAULT_PRECISION =
7
DEFAULT_PRECISION_FACTOR =
16.0

Instance Method Summary collapse

Constructor Details

#initialize(field, lat, lng, options) ⇒ Geo

Returns a new instance of Geo.



14
15
16
17
# File 'lib/sunspot/query/geo.rb', line 14

def initialize(field, lat, lng, options)
  @field, @options = field, options
  @geohash = GeoHash.encode(lat.to_f, lng.to_f, MAX_PRECISION)
end

Instance Method Details

#to_paramsObject



19
20
21
# File 'lib/sunspot/query/geo.rb', line 19

def to_params
  { :q => to_boolean_query }
end

#to_subqueryObject



23
24
25
# File 'lib/sunspot/query/geo.rb', line 23

def to_subquery
  "(#{to_boolean_query})"
end