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.



15
16
17
18
# File 'lib/git_fit/geo/reverse_geocode.rb', line 15

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)


20
21
22
# File 'lib/git_fit/geo/reverse_geocode.rb', line 20

def amap_available?
  !@amap.nil?
end

#lookup(lat, lng) ⇒ Object



24
25
26
# File 'lib/git_fit/geo/reverse_geocode.rb', line 24

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