New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

geosack

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

geosack

  • 1.0
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

== Geosack On Rails

This plugin enables you to utilize geosack.com unique geocode caching service. Geosack provides a persistent api that caches google-map/geocode lookups - enabling you to re-request the same information any number of times you like without exceeding your quota's or rate-limits from google.

To install the plugin, extract the files from the archive to a directory named "geosack" in your vendors/plugin directory.

Using the plugin is straightforward:

To use the geocoding service you will need a google API key, obtained from here:

http://code.google.com/apis/maps/signup.html

Once you have this key, you can create your Geosack object:

geosack = Geosack::Base.new(:api_key => YOUR_API_KEY)

Then you are free to start making geocode requests.

result, location = geosack.geo(:q => 'San Jose')

The placename to be looked is specified by the :q parameter. The only other parameter is :output which is the response format - KML/XML/JSON. The default response format is XML.

You don't need to worry about the 2 second delay that google requires - geosack takes care of that for you.

The result object is a reflection of the response returned by google to your request. Anything other than a 200 (G_GEO_SUCCESS) is a failure.

You will also need to check for 610 (G_GEO_TOO_MANY_QUERIES) responses which indicate you have reached your limit for the 24 period. Note that this limit only applies to new requests sent to google - if you send a request that has already been cached by geosack, the response will come from geosack, not from google, and your daily limit will be unaffected.

Heres an example to get your started:

geosack = Geosack::Base.new(:key => API_KEY) result, resp = geosack.geo(:q => lookup) if result == Geosack::StatusCodes::G_GEO_SUCCESS doc = REXML::Document.new(resp) doc.root.each_element('//Response') do |response| response.each_element('//Placemark') do |place| longitude,latitude = place.elements['//coordinates'].text.split(',') end end else # failed end

Have fun, and feel free to contact us at mailto:info@packetnode.com with any questions or suggestions.

FAQs

Package last updated on 25 Jul 2009

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc