Security News
Weekly Downloads Now Available in npm Package Search Results
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
Ruby client library for the AskGeo web service. From the AskGeo website:
AskGeo provides a simple, fast, and accurate web api for finding out the time zone information for a given location (latitude and longitude). It's simple: you give latitude and longitude and the API returns a time zone ID (e.g., "America/Chicago", or "Europe/London"). We built the API because we needed it for a different project and decided to make it available because no other such tools seem to exist that are accurate and capable of returning a large number of results in a short period of time.
Unlike GeoNames, look-ups are based on an actual map of the world, rather than "closest point of interest", which ensures accuracy and that you actually get a result for all locations. And unlike EarthTools, we return an actual time zone ID (e.g., "America/Los_Angeles") rather than just an offset. The API is also very fast: when used in batch mode, it is capable of returning thousands of results in a couple seconds.
Install the gem:
gem install ask_geo
Or, if you are using bundler, add it to your Gemfile:
gem "ask_geo"
First, you will need to create an AskGeo account. Currently they only support doing this via OpenID with a gmail account. Once you have created an account, they give you an Account ID and an API Key. You will need those to make calls to their web service through this library.
From there, usage of the client library is fairly straight-forward:
# Instantiate a client
client = AskGeo.new(:account_id => 'XXXXXX', :api_key => 'XXXXXX')
# Lookup a single lat/lon
resp = client.lookup("47.62057,-122.349761")
# => {
# "timeZone" => "America/Los_Angeles",
# "currentOffsetMs" => -25200000,
# "latitude" => 47.62057,
# "longitude" => -122.349761
# }
# Lookup a batch of lat/lon points (faster than multiple calls)
resp = client.lookup(["47.62057,-122.349761", "40.748529,-73.98563"])
# => [{
# "timeZone" => "America/Los_Angeles",
# "currentOffsetMs" => -25200000,
# "latitude" => 47.62057,
# "longitude" => -122.349761
# },
# {
# "timeZone" => "America/New_York",
# "currentOffsetMs" => -14400000,
# "latitude" => 40.748529,
# "longitude" => -73.98563
# }]
# Points can be specified by Hash too...
resp = client.lookup(:lat => 47.62057, :lon => -122.349761)
resp = client.lookup(
[
{:lat => 47.62057, :lon => -122.349761},
{:lat => 40.748529, :lon => -73.98563}
]
)
In order to run the tests, you first need to edit spec/spec_helper.rb
and follow the TODO
comment to insert your AskGeo account ID and API key. Then, you should be able to run the tests with:
rake spec
Copyright (c) 2011 Scott W. Bradley. See LICENSE.txt for further details.
AskGeo, GeoNames, and EarthTools are copyright/trademark their respective owners.
FAQs
Unknown package
We found that ask_geo demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
Security News
A Stanford study reveals 9.5% of engineers contribute almost nothing, costing tech $90B annually, with remote work fueling the rise of "ghost engineers."
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.