Giter VIP home page Giter VIP logo

geonum's Introduction

GeoNum

A NIF based geonum module implementation for Erlang.

GeoNum is an encoding of geolocation, similar to geohash (http://en.wikipedia.org/wiki/Geohash), the difference being that it's encoded as integer value, and allows more granular precision (by 1-bit, as opposed to geohash that uses 5-bit encoded characters; the maximum precision for geohash is 60 bits, whereas geonum allows 62 bits). The implementation based on http://karussell.wordpress.com/2012/05/23/spatial-keys-memory-efficient-geohashes/, with some modifications.

Example Usage

In the example, we encode lat/lon coordinates of the Statue of Liberty to the geonum value with 62-bit precision (1), then decode (2) (note the precision being preserved) and calculate a bounding box (3) of the area that is represented by the geonum value. We can also request adjacent geonums in 3x3 extension area in order to use them for proximity searches (4) (more on it at http://en.wikipedia.org/wiki/Geohash#Limitations).

$ erl -pa ebin        
Erlang R15B01 (erts-5.9.1) [source] [64-bit] [smp:4:4] [async-threads:0] [hipe] [kernel-poll:false]

Eshell V5.9.1  (abort with ^G)
1>{ok, Hash} = geonum:encode(40.689167, -74.044444, 62).
{ok,6445456962182867325}

2> geonum:decode(Hash).                                           
{ok,{40.68916704040021,-74.04444406740367}}

3> geonum:decode_bbox(Hash).      
{ok,{{40.68916708230972,-74.0444441512227},
     {40.68916699849069,-74.04444398358464}}}
4> geonum:neighbors(Hash).
   {ok,[6445456962182867319,6445456962182867327,
	     6445456962182868008,6445456962182867324,6445456962182868002,
	     6445456962182868010,6445456962182867318,
	     6445456962182867326]}



geonum's People

Contributors

bokner avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.