Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Quick and easy geocoding using data and TokyoCabinet.
branch: master

Initial commit.

latest commit 097146e532
Norman Clarke authored
Failed to load latest commit information.
lib Initial commit.
test Initial commit.
History.txt Initial commit.
Manifest.txt Initial commit.
README.rdoc Initial commit.
Rakefile Initial commit.
nearby.gemspec Initial commit.



A mashup of TokyoCabinet and for quick and easy Geocoding and proximity searches.

It runs fairly fast with the GeoNames cities1000 database, and perhaps with larger datasets too. It works with Ruby 1.8 and 1.9. Ruby 1.9 is significantly faster.


Create a database

First, download a database from the download server. Then:

Nearby::Database::create("my_db.tct", "cities1000.txt")

Simple Geocode

db ="my_db.tct")
db.get_place(:name => "Seattle", :region => "WA", :country => "US")

Get nearby places

db ="my_db.tct")
result = db.get_place(:name => "Seattle", :region => "WA", :country => "US").first
# Find all places within 100km of Seattle
db.get_nearby(result, 100)

Full example

require 'rubygems'
require 'nearby'

# Use the database from
Nearby::Database::create("argentina.tct", "AR.txt")
db ="argentina.tct")
buenos_aires = db.get_place(:name => "Buenos Aires").first
db.get_nearby(buenos_aires, 10).each do |r|
  puts r["asciiname"]


  • Perform arbitrary queries

  • Allow distances in miles

  • Better approximate matching for place names.

  • Improve performance.

  • Make the code somewhat presentable - the first checkin is about 3 hours worth of code. :-)


Created by Norman Clarke

Copyright © 2008 Norman Clarke released under the MIT license.

Something went wrong with that request. Please try again.