Class: SoraGeocoding::Geohash
- Defined in:
- lib/sora_geocoding/geohash.rb
Overview
Constant Summary collapse
- BASE32 =
'0123456789bcdefghjkmnpqrstuvwxyz'.freeze
- REFINED_RANGE =
[[-90, 90], [-180, 180]].freeze
Instance Method Summary collapse
- #encode ⇒ Object
-
#initialize(lat, lon) ⇒ Geohash
constructor
A new instance of Geohash.
Methods inherited from Base
#configuration, #handle, #raise_error
Constructor Details
#initialize(lat, lon) ⇒ Geohash
Returns a new instance of Geohash.
13 14 15 16 |
# File 'lib/sora_geocoding/geohash.rb', line 13 def initialize(lat, lon) @lat = lat.to_s @lon = lon.to_s end |
Instance Method Details
#encode ⇒ Object
18 19 20 21 22 23 |
# File 'lib/sora_geocoding/geohash.rb', line 18 def encode calc_geohash( convert_byte(@lat, REFINED_RANGE[0][0], REFINED_RANGE[0][1], range(@lat)), convert_byte(@lon, REFINED_RANGE[1][0], REFINED_RANGE[1][1], range(@lon)) ) end |