Git Product home page Git Product logo

libgeoip-erlang's Introduction

who:   [email protected]
what:  erlang port for libgeoip.  supports GeoIPCity and GeoLiteCity DBs.
when:  made December 2008. published December 2008.
when2: Last updated October 2010.  Rebar-ized and added license.
where: everywhere
why:   I don't like having to do external service calls for geo lookups.

prereqs:
  - libgeoip
    - yum: yum install GeoIP GeoIP-devel
    - macports: port install libgeoip
    - freebsd: ports/net/GeoIP/
    - or download from http://www.maxmind.com/app/c
  - maxmind City data source
    - Download latest free version (updated monthly):
      http://geolite.maxmind.com/download/geoip/database/GeoLiteCity.dat.gz
    - Or, buy their slightly more accurate DB for $370:
      https://www.maxmind.com/app/cart?add_product_id=132

performance: 6600 to 7000 lookups per second
benchmark versus egeoip: 
  a typical result (+hipe) is:
      libgeoip-erlang: 7057 lookups per second
               egeoip: 5498 lookups per second
  resulting in libgeoip-erlang being about 28% faster than egeoip.

Building Instructions:
         > rebar compile
         You may need to edit rebar.config if your maxmind headers and
         objects aren't in /opt/local.

Note: You must have the libgeoip directory name *in* your path for libgeoip to
find the correct port to run.

usage [APPLICATION]:
> erl -pz ../ligeoip-erlang/ebin -pz ../libgeoip-erlang/priv

Eshell V5.6.5  (abort with ^G)
1> application:start(libgeoip_app).
ok
2> libgeoip:set_db("/usr/local/maxmind/data/GeoLiteCity.dat").
db_set
3> libgeoip:lookup(<<192,90,64,2>>).
{geoip,"US","MA","Massachusetts","Billerica","01821",
       42.54930114746094,-71.25579833984375,"drt649c5es9g"}
4> libgeoip:lookup(<<2,2,2,2>>).    
[]


usage [DIRECT]:
> erl -pz ../libgeoip-erlang/ebin -pz ../libgeoip-erlang/priv

Eshell V5.6.5  (abort with ^G)
1> libgeoip:start_link("/usr/local/maxmind/data/GeoLiteCity.dat").
{ok, (State)}
2> libgeoip:lookup(<<66,23,219,241>>).
{geoip,"US","GA","Georgia","Lawrenceville","30043",
       34.00910186767578,-84.00879669189453,"dnh32r4tmhhf"}
3> rr(libgeoip).
[geoip]
4> libgeoip:lookup(<<209,85,171,100>>).
#geoip{country = "US",region = "CA",state = "California",
       city = "Mountain View",postal = "94043",
       lat = 37.4192008972168,lng = -122.05740356445313,
       geohash = "9q9hyebw8ke7"}
5> libgeoip:lookup(<<172,16,5,20>>). 
[]


Notes:
  - You must set the DB path by:
    - libgeoip:start_link("DB Path").
      - OR -
    - libgeoip:set_db("DB Path").
  - You can change the DB path at any time.
  - If you upgrade your database in-place you must set_db to clear out
    the old DB and load the new one.
  - Failure to set the DB path results in lookup/1 timing out.

libgeoip-erlang's People

Contributors

mattsta avatar

Stargazers

 avatar Or Hiltch avatar  avatar Klaus Trainer avatar  avatar

Watchers

 avatar Gregory Oschwald avatar James Cloos avatar  avatar  avatar

libgeoip-erlang's Issues

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.