github
Advanced Search
  • Home
  • Pricing and Signup
  • Explore GitHub
  • Blog
  • Login

elecnix / ruby-geonames

  • Admin
  • Watch Unwatch
  • Fork
  • Your Fork
  • Pull Request
  • Download Source
    • 21
    • 5
  • Source
  • Commits
  • Network (5)
  • Issues (0)
  • Downloads (0)
  • Wiki (1)
  • Graphs
  • Branch: master

click here to add a description

click here to add a homepage

  • Branches (1)
    • master ✓
  • Tags (0)
Sending Request…
Enable Donations

Pledgie Donations

Once activated, we'll place the following badge in your repository's detail box:
Pledgie_example
This service is courtesy of Pledgie.

SVN clone of http://www.tbcn.ca/geonames — Read more

  cancel

http://code.google.com/p/ruby-geonames/

  cancel
  • Private
  • Read-Only
  • HTTP Read-Only

This URL has Read+Write access

Merge branch 'master' of git://github.com/sermoa/ruby-geonames 
elecnix (author)
Tue Sep 29 17:34:57 -0700 2009
commit  523edf5c01563d00f4e6f38fb6dcef13392d475a
tree    256c1cd1b01de5c2085313d1c34525452ac01fd7
parent  d000accce3cf40137600378e129cea95f7d59e13 parent  cc401daa702a247192a68d4b7548ae7d2da4ae38
ruby-geonames /
name age
history
message
file README.markdown Thu May 07 21:02:55 -0700 2009 Link to home page, adding example output [elecnix]
directory lib/ Tue Jul 07 08:02:45 -0700 2009 Enable commercial service api key to work by us... [sermoa]
directory nbproject/ Sat Feb 24 23:09:46 -0800 2007 adding netbeans project info git-svn-id: http:... [adamw523]
file ruby-geonames.gemspec Tue Jul 07 08:02:46 -0700 2009 Change version number and date. Signed-off-by:... [sermoa]
README.markdown

Geonames Ruby API

Ruby library for Geonames Web Services

Created by TouchBase Counsulting to support GIS processes for Carpool Connect. Inspired by the Geonames Java Client API library.

Installing ruby-geonames

Install from the command line:

sudo gem install elecnix-ruby-geonames

Examples

The following exercises several of the Geonames web services, full list of services.

Load the the geonames API

require 'geonames'

get list of places near by longitude/longitude location

places_nearby = Geonames::WebService.find_nearby_place_name 43.900120387, -78.882869834
p places_nearby

outputs:

[#<Geonames::Toponym:0x6c8c98 @population=nil, @geoname_id='6094578', @longitude=-78.849568878, @feature_class_name=nil, @country_name='Canada', @latitude=43.900120387, @feature_class='P', @country_code='CA', @name='Oshawa', @feature_code_name=nil, @elevation=nil, @distance=2.6679930307932, @alternate_names=nil, @feature_code='PPL'>]

get timezone for longitude/longitude location

timezone = Geonames::WebService.timezone 43.900120387, -78.882869834
p timezone

get country code for longitude/longitude location

country_code = Geonames::WebService.country_code 43.900120387, -78.882869834
p country_code

get country sub-division info for longitude/longitude location

country_subdivision = Geonames::WebService.country_subdivision 43.900120387, -78.882869834
p country_subdivision

get postal codes for a given location

postal_code_sc = Geonames::PostalCodeSearchCriteria.new
postal_code_sc.place_name = "Oshawa"
postal_codes = Geonames::WebService.postal_code_search postal_code_sc
p postal_codes

get nearby postal codes for a place name

postal_code_sc = Geonames::PostalCodeSearchCriteria.new
postal_code_sc.place_name = "Oshawa"
postal_codes_nearby = Geonames::WebService.find_nearby_postal_codes postal_code_sc
p postal_codes_nearby

Commercial Service Support

If you use the commercial service, you should put something like this in your configuration:

Geonames::username = 'username'
Geonames::base_url = 'http://ws.geonames.net'

In a Rails application, this would go in the config/environment.rb file.

Contributors

1. Adam Wisniewski
2. Nicolas Marchildon (elecnix)
Blog | Support | Training | Contact | API | Status | Twitter | Help | Security
© 2010 GitHub Inc. All rights reserved. | Terms of Service | Privacy Policy
Powered by the Dedicated Servers and
Cloud Computing of Rackspace Hosting®
Dedicated Server