geo location util.
luarocks install geo --from=http://mah0x211.github.io/rocks/
returns the geohash encoded string from specified arguments.
local geo = require('geo');
local precision = 16;
local lat = 35.673343;
local lon = 139.710388;
local hash = geo.encode( lat, lon, precision );
print( hash ); -- 'xn76gnjurcpggseg'
Parameters
lat
: number - the latitude value range must be the-90
to90
.lon
: number - the longitude value range must be the-180
to180
.precision
: uint - the hash string length range must be the1
to16
.
Returns
hash
: string.err
: string.
returns table that included of latitude and longitude values from the geohash string.
local inspect = require('util').inspect;
local geo = require('geo');
local hash = 'xn76gnjurcpggseg';
local latlon = geo.decode( hash );
print( inspect( latlon ) );
--[[
{
lat = 35.673342999935,
lon = 139.71038800008
}
--]]
Parameters
geohash
: string - geohash encoded string.
Returns
latlon
: table -{ lat = latitude:number, lon = longitude:number }
.err
: string.