Skip to content

Rails plugin for providing useful geography related classes and data.

License

Notifications You must be signed in to change notification settings

welike/geography

Repository files navigation

Geography Rails Plugin

Description

This is a plugin for Rails that provides common geography-related classes, helpers, and up-to-date data, such as Continent, Country, State, and ZipCode. I found that so many of my projects required these basic geography classes that it made sense to pluginify it and share it with the world.

It has been written to install as a gem (or installed plugin if you choose), and features a generator for dynamically generating the classes and migrations. This allows customization before it hits the database, in case you have particular needs for your geography classes/migrations. A collection of rake tasks have been included to parse and import standardized data from various sources. Additionally, there are helpers to assist with common needs in your applications.

Where possible, I have chosen data sources with the most up to date information. However, if you require an extreme level of accuracy, you might wish to purchase databases from the many overly priced companies that provide it.

Installation

Install the gem:

$ sudo gem install welike-geography --source http://gems.github.com

Edit your app’s config/environment.rb and add the gem requirement:

config.gem "welike-geography", :lib => "geography", :source => "http://gems.github.com"

Generate all of the required classes, migrations, etc:

$ script/generate geography all

Configuration

You can now customize the migration that is generated, and any of the classes that have been copied into your project. Once you’re satisfied, it is time to migrate!

$ rake db:migrate

Now, load in all the data:

$ rake geo:load:all

This will load in all the data. Some of the data will be loaded from the internet, so you will want to be connected. We will need to rethink how to manage this moving forward (perhaps with older fallback data in case you do not wish to load anything from the net).

You can also load in the data for just particular classes:

$ rake geo:load:continents
$ rake geo:load:countries

That’s it!

Classes

  • Continent

  • Country

  • State

  • Region (common population areas, loosely tied to metropolitan areas)

  • County

Data Sources

All of the data sources (including some that are not currently in use) are listed on the [[Data Sources]] page on the wiki. The decision on which data sources to use were solely based on simplicity of data retrieval and parsing. In the future, based on user feedback, we can use alternative data sources that might be more precise or more up-to-date.

Continent

  • Wikipedia

Country

  • Wikipedia, OpenConcepts

Author

Kevin Elliott is the President of WeLike LLC, a company building web and phone applications that help people find the things they’ll love. Besides spending a lot of time making his company successful and learning new technologies, Kevin likes to give back to the community that gave him so much.

Kevin Elliott - kevin@welikeinc.com or kevin@phunc.com

Company - www.welikeinc.com

Blog - kevinelliott.net/blogs/entrepreneurial

twitter.com/kevinelliott

Copyright © 2009 WeLike, LLC, released under the MIT license

About

Rails plugin for providing useful geography related classes and data.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages