Giter VIP home page Giter VIP logo

geo_names's Introduction

GeoNames

GeoNames Ruby API Wrapper

Build Status Maintainability GitHub

This gem is a ruby API wrapper for GeoNames API's.

Security

Multifactor authentication:

Security github.com account Security rubygems.org account

Installation

Add this line to your application's Gemfile:

gem 'geo_names'

And then execute:

$ bundle

Or install it yourself as:

$ gem install geo_names

Usage

Pre-requirement

You need a valid username to use the gem. You can get it by signing up here.

If you don't set the username it will raises an exception.

Configuration

You can use add initializer for example if you're on Rails.

# config/initializers/geo_names.rb

GeoNames.configure do |config|
  config.username = ENV['GEONAMES_USERNAME']
end

Searching

How to search?

First you need a Hash with the criteria that you want to search.

# example of criteria
criteria = {
  country_code: 'US',
  name: 'New York',
  featureClass: %w[P S],
  maxRows: 1,
  style: 'short'
}

Then you can search

result = GeoNames::Search.search(criteria)

The result it will be a Hash if was successful, like this one:

{ "totalResultsCount" => 1360,
  "geonames" => [
    { "lng" => "-74.00597",
      "geonameId" => 5128581,
      "countryCode" => "US",
      "name" => "New York",
      "toponymName" => "New York City",
      "lat" => "40.71427",
      "fcl" => "P",
      "fcode" => "PPL"
    }
  ]
}

Or if something was wrong it will raise an error of this list:

GeoNames::AuthorizationExceptionError
GeoNames::DatabaseTimeoutError
GeoNames::MissingOrInvalidParameterError
GeoNames::RecordDoesNotExistError
GeoNames::OtherError
GeoNames::NoResultFoundError
GeoNames::PostalCodeNotFoundError
GeoNames::DailyLimitOfCreditsExceededError
GeoNames::HourlyLimitOfCreditsExceededError
GeoNames::WeeklyLimitOfCreditsExceededError
GeoNames::InvalidInputError
GeoNames::ServerOverloadedExceptionError
GeoNames::ServiceNotImplementedError
GeoNames::RadiusTooLargeError
GeoNames::MaxRowsTooLargeError
GeoNames::StatusCodeNotImplementedError

Search engines available

GeoNames::Address
GeoNames::Astergdem
GeoNames::Children
GeoNames::Cities
GeoNames::Configuration
GeoNames::Contains
GeoNames::CountryCode
GeoNames::CountryInfo
GeoNames::CountrySubdivision
GeoNames::Earthquakes
GeoNames::ExtendedFindNearby
GeoNames::FindNearByWeather
GeoNames::FindNearby
GeoNames::FindNearbyPOIsOSM
GeoNames::FindNearbyPlaceName
GeoNames::FindNearbyPostalCodes
GeoNames::FindNearbyStreets
GeoNames::FindNearbyStreetsOSM
GeoNames::FindNearbyWikipedia
GeoNames::FindNearestAddress
GeoNames::FindNearestIntersection
GeoNames::FindNearestIntersectionOSM
GeoNames::GeoCodeAddress
GeoNames::Get
GeoNames::Gtopo30
GeoNames::Hierarchy
GeoNames::Neighbourhood
GeoNames::Neighbours
GeoNames::Ocean
GeoNames::PostalCodeCountryInfo
GeoNames::PostalCodeLookup
GeoNames::PostalCodeSearch
GeoNames::Search
GeoNames::Siblings
GeoNames::Srtm1
GeoNames::Srtm3
GeoNames::Timezone
GeoNames::Weather
GeoNames::WeatherIcao
GeoNames::WikipediaBoundingBox
GeoNames::WikipediaSearch

Development

After checking out the repo, run bin/setup to install dependencies. Then, run rake spec to run the tests. You can also run bin/console for an interactive prompt that will allow you to experiment.

To install this gem onto your local machine, run bundle exec rake install. To release a new version, update the version number in version.rb, and then run bundle exec rake release, which will create a git tag for the version, push git commits and tags, and push the .gem file to rubygems.org.

Contributing

Bug reports and pull requests are welcome on GitHub at geo_names repository. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.

License

The gem is available as open source under the terms of the MIT License.

Code of Conduct

Everyone interacting in the GeoNames project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.

geo_names's People

Contributors

wakematta avatar dgilperez avatar renovate[bot] avatar

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.