Class: GitFit::Geo::ReverseGeocode
- Inherits:
-
Object
- Object
- GitFit::Geo::ReverseGeocode
- 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
- #amap_available? ⇒ Boolean
-
#initialize(amap_key: nil) ⇒ ReverseGeocode
constructor
A new instance of ReverseGeocode.
- #lookup(lat, lng) ⇒ Object
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
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 |