module Geohash

Overview

Geohash encoding/decoding and associated functions

https://en.wikipedia.org/wiki/Geohash

Based on https://github.com/davetroy/geohash-js/blob/master/geohash.js

Extended Modules

Defined in:

geohash.cr

Constant Summary

VERSION = {{ (`shards version /srv/crystaldoc.info/github-geocrystal-geohash-v0.1.1/src`).chomp.stringify }}

Instance Method Summary

Instance Method Detail

def bounds(geohash) : NamedTuple(sw: NamedTuple(lat: Float64, lng: Float64), ne: NamedTuple(lat: Float64, lng: Float64)) #

Returns SW/NE latitude/longitude bounds of specified geohash.


[View source]
def decode(geohash : String) : NamedTuple(lat: Float64, lng: Float64) #

Decode geohash to latitude/longitude (location is approximate center of geohash cell, to reasonable precision).

Geohash.decode('u120fxw') # => {lat: 52.205, lng: 0.1188}

[View source]
def encode(latitude : Float64, longitude : Float64, precision : Int32 | Nil = nil) #

Encodes latitude/longitude to geohash, either to specified precision or to automatically evaluated precision.

Geohash.encode(52.205, 0.119, 7) # => "u120fxw"
Geohash.encode(48.669, -4.329)   # => "gbsuv"

[View source]
def neighbors(geohash : String) : NamedTuple(n: String, ne: String, e: String, se: String, s: String, sw: String, w: String, nw: String) #

Returns all 8 adjacent cells to specified geohash.


[View source]