Download and store Geonames.org data. Making every Geoname API operation possible on your servers. No hit limit, fast as possible.
To use the adapter, install the corresponding gem:
PostgreSQL => pg MongoDB => mongodb (optional: mongo_ext) Tokyo => tokyocabinet
Don’t forget to install unzip and curl.
Be sure to use a database based on the PostGIS template.
MongoDB 2D support is new, only mongo >= 1.3.3 mongodb gem >= 0.19.2 github.com/mongodb/mongo-ruby-driver
geonames conf
Will generate a “geonames.yml” file on your folder. The file is self explanatory.
geonames -c geonames.yml
Work. Use -v for verbose.
If you are not sure your country code, use:
geonames list <search>
When using PG, this gem will (try) to relational map Geonames data on your scheme. Postgresql done, tokyo still need heavy work.
So, supposing ActiveRecord, something like this is possible:
City.first.province.country.abbr => "BR"
Default PG migration:
create_table :cities do |t| t.references :country, :null => false t.references :province t.string :name, :null => false t.point :geom, :srid => 4326 t.integer :gid, :zip end create_table :provinces do |t| t.references :country, :null => false t.string :name, :null => false t.string :abbr, :limit => 2, :null => false t.integer :gid end create_table :countries do |t| t.string :name, :limit => 30, :null => false t.string :abbr, :limit => 2, :null => false end add_index :cities, :name add_index :cities, :gid add_index :cities, :zip add_index :cities, :country_id add_index :cities, :province_id add_index :cities, :geom, :spatial => true add_index :provinces, :name add_index :provinces, :abbr add_index :provinces, :gid add_index :provinces, :country_id
-
Local relational mapping of geonames data
-
Map geonames fields to your db scheme UNDONE
-
Countries are a static yml file :/
-
Fork the project.
-
Make your feature addition or bug fix.
-
Add tests for it. This is important so I don’t break it in a future version unintentionally.
-
Commit, do not mess with rakefile, version, or history. (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
-
Send me a pull request. Bonus points for topic branches.
Copyright © 2009 Marcos Piccinini. See LICENSE for details.