Class: GitFit::Geo::ReverseGeocode

Inherits:
Object
  • Object
show all
Defined in:
lib/git_fit/geo/reverse_geocode.rb

Constant Summary collapse

CHINA_BBOX =
{
  min_lng: 73, max_lng: 135,
  min_lat: 18, max_lat: 54,
}.freeze

Instance Method Summary collapse

Constructor Details

#initialize(amap_key: nil) ⇒ ReverseGeocode

Returns a new instance of ReverseGeocode.



13
14
15
16
# File 'lib/git_fit/geo/reverse_geocode.rb', line 13

def initialize(amap_key: nil)
  @amap = amap_key ? AMapClient.new(api_key: amap_key) : nil
  @nominatim = NominatimClient.new
end

Instance Method Details

#amap_available?Boolean

Returns:

  • (Boolean)


18
19
20
# File 'lib/git_fit/geo/reverse_geocode.rb', line 18

def amap_available?
  !@amap.nil?
end

#lookup(lat, lng) ⇒ Object



22
23
24
# File 'lib/git_fit/geo/reverse_geocode.rb', line 22

def lookup(lat, lng)
  in_china?(lat, lng) ? lookup_china(lat, lng) : lookup_intl(lat, lng)
end