GithubHelp home page GithubHelp logo

collectiveidea / graticule Goto Github PK

View Code? Open in Web Editor NEW
300.0 15.0 53.0 316 KB

Graticule is a geocoding API for looking up address coordinates and performing distance calculations, supporting many popular APIs.

Home Page: http://rdoc.info/github/collectiveidea/graticule

License: Other

Ruby 90.20% CSS 0.95% HTML 8.86%

graticule's Issues

missing ssl for google map api

I made the following request:

location = Geocode.geocoder.locate "61 East 9th Street, Holland, MI"

And i got the following error message:

"{\n   \"error_message\" : \"Requests to this API must be over SSL.\",\n   \"results\" : [],\n   \"status\" : \"REQUEST_DENIED\"\n}\n"

I modified graticule to make requests with https and now i am getting:

"error_message\" : \"This site is not authorized to use this API key.\",\n   \"results\" : [],\n   \"status\" : \"REQUEST_DENIED\"\n}

I am using graticule 2.3.0.

thx!

Cut a new gem?

What's the status on cutting a new release? I need the fix in commit 5a2b604. Can you release a 2.4.1?

encoding error UTF-8 and ACSII-8BIT

When my params ( street => "street", locality => "Zürich") I have the following error message : incompatible character encodings: UTF-8 and ASCII-8BIT

if I put locality => Züriche (unexistant city), it's work.

For information, the problem may be in methode create_from_location (geocode.rb line 32). Remplace

create geocoder.locate(location).attributes.merge(:query => location.to_s)

by

create geocoder.locate(location).attributes.merge(:query => location.to_s.parameterize) #Replace accentutate chars by non-accentuate chars and it's works

I don't know if is the best way to fix this.

Consistency of naming

Elsewhere in the plugin you're using :postal_code, but for the :precision option, it seems to be US-centric values(:zip, :street, :state, etc.)

For example:

#<Graticule::Location:0x106326188 @street=nil, @postal_code="49423", @longitude=-86.0733498, @region="MI", @precision=:zip, @latitude=42.7381514, @locality="Holland", @country="US">

error when loading Bogus

I get this error when it treis to load the Bogus class:
undefined method `class_attribute' for Graticule::Geocoder::Bogus:Class

What am I missin?. If I comment out the require statement for Bogus it seems to work fine.

SQL generated by Distance::Spherical.to_sql fails on Postgres

More specifically it fails when calculating distance between similar locations and can be repeated by executing following code:

ActiveRecord::Base.connection.select_value "SELECT #{Graticule::Distance::Spherical.to_sql(:latitude => 51.550249, :latitude_column => 51.550249, :longitude => -0.132918, :longitude_column => -0.132918)}"

returns

ActiveRecord::StatementInvalid: PGError: ERROR: input is out of range

The problem is actually ages old http://rubyforge.org/tracker/index.php?func=detail&aid=17922&group_id=2643&atid=10191 but probably too edge case to be taken care of?

Needs further error checking from Google Response

When sending a request to Google it passes back a 200 response of an HTML error message. Graticule assumes the OK status and continues on.

When it gets to Happy Mapper it fails all of the tests for XML locations but still assumes it is XML and falls back to

node = XML::Parser.string(xml).parse.root

This raises an exception and fails the entire process.

[2] (pry) Graticule::Geocoder::Google::Response: 0> exit
Fatal error: AttValue: " or ' expected at :1.
Fatal error: attributes construct error at :1.
Fatal error: Couldn't find end of Start Tag font line 1 at :1.
Fatal error: Opening and ending tag mismatch: b line 1 and font at :1.
Fatal error: AttValue: " or ' expected at :1.
Fatal error: attributes construct error at :1.
Fatal error: Couldn't find end of Start Tag font line 1 at :1.
Fatal error: Opening and ending tag mismatch: td line 1 and font at :1.
Fatal error: AttValue: " or ' expected at :1.
Fatal error: attributes construct error at :1.
Fatal error: Couldn't find end of Start Tag font line 1 at :1.
Fatal error: Opening and ending tag mismatch: tr line 1 and font at :1.
Fatal error: AttValue: " or ' expected at :1.
Fatal error: attributes construct error at :1.
Fatal error: Couldn't find end of Start Tag font line 1 at :1.
Fatal error: Opening and ending tag mismatch: table line 1 and font at :1.
Fatal error: AttValue: " or ' expected at :1.
Fatal error: attributes construct error at :1.
Fatal error: Couldn't find end of Start Tag font line 1 at :1.
Fatal error: Opening and ending tag mismatch: div line 1 and font at :1.
Fatal error: AttValue: " or ' expected at :1.
Fatal error: attributes construct error at :1.
Fatal error: Couldn't find end of Start Tag font line 1 at :1.
Fatal error: Opening and ending tag mismatch: body line 1 and font at :1.
Fatal error: Opening and ending tag mismatch: html line 1 and b at :1.
Fatal error: Extra content at the end of the document at :1.
LibXML::XML::Error: Fatal error: Extra content at the end of the document at /Users/travis/.rvm/gems/[email protected]/gems/happymapper-0.4.0/lib/happymapper.rb:95.
from /Users/travis/.rvm/gems/[email protected]/gems/happymapper-0.4.0/lib/happymapper.rb:95:in `parse'

HTML Response from google

<html>
   <head>
      <meta http-equiv="content-type" content="text/html; charset=utf-8"/>
      <title>Sorry...</title>
      <style> body { font-family: verdana, arial, sans-serif; background-color: #fff; color: #000; }</style>
   </head>
   <body>
      <div>
         <table>
            <tr>
               <td>
                 <b>
                   <font face=times color=#0039b6 size=10>G</font>
                   <font face=times color=#c41200 size=10>o</font>
                   <font face=times color=#f3c518 size=10>o</font>
                   <font face=times color=#0039b6 size=10>g</font>
                   <font face=times color=#30a72f size=10>l</font>
                   <font face=times color=#c41200 size=10>e</font>
                 </b>
               </td>
               <td style="text-align: left; vertical-align: bottom; padding-bottom: 15px; width: 50%">
                  <div style="border-bottom: 1px solid #dfdfdf;">Sorry...</div>
               </td>
            </tr>
         </table>
      </div>
      <div style="margin-left: 4em;">
         <h1>We're sorry...</h1>
         <p>... but your computer or network may be sending automated queries. To protect our users, we can't process your request right now.</p>
      </div>
      <div style="margin-left: 4em;">See <a href="https://support.google.com/websearch/answer/86640">Google Help</a> for more information.<br/><br/></div>
      <div style="text-align: center; border-top: 1px solid #dfdfdf;">&copy; 2013 Google - <a href="https://www.google.com">Google Home</a></div>
   </body>
</html>

Rescue Timeout error in multi geocoder

A timeout during geocoding results in the following backtrace, as we discussed:

rake aborted!
execution expired
/usr/lib/ruby/1.8/timeout.rb:60:in `open'
/usr/lib/ruby/1.8/net/http.rb:560:in `connect'
/usr/lib/ruby/1.8/timeout.rb:53:in `timeout'
/usr/lib/ruby/1.8/timeout.rb:93:in `timeout'
/usr/lib/ruby/1.8/net/http.rb:560:in `connect'
/usr/lib/ruby/1.8/net/http.rb:553:in `do_start'
/usr/lib/ruby/1.8/net/http.rb:542:in `start'
/usr/lib/ruby/1.8/open-uri.rb:242:in `open_http'
/usr/lib/ruby/1.8/open-uri.rb:616:in `buffer_open'
/usr/lib/ruby/1.8/open-uri.rb:164:in `open_loop'
/usr/lib/ruby/1.8/open-uri.rb:162:in `catch'
/usr/lib/ruby/1.8/open-uri.rb:162:in `open_loop'
/usr/lib/ruby/1.8/open-uri.rb:132:in `open_uri'
/usr/lib/ruby/1.8/open-uri.rb:518:in `open'
/home/hov/.bundle/ruby/1.8/gems/graticule-1.0.0.pre2/lib/graticule/geocoder/base.rb:79:in `get'
/home/hov/.bundle/ruby/1.8/gems/graticule-1.0.0.pre2/lib/graticule/geocoder/yahoo.rb:43:in `locate'
/home/hov/.bundle/ruby/1.8/gems/graticule-1.0.0.pre2/lib/graticule/geocoder/multi.rb:45
/home/hov/.bundle/ruby/1.8/gems/graticule-1.0.0.pre2/lib/graticule/geocoder/multi.rb:44
/home/hov/.bundle/ruby/1.8/gems/graticule-1.0.0.pre2/lib/graticule/geocoder/multi.rb:69:in `call'
/home/hov/.bundle/ruby/1.8/gems/graticule-1.0.0.pre2/lib/graticule/geocoder/multi.rb:69:in `result'
/usr/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/callbacks.rb:180:in `detect'
/home/hov/.bundle/ruby/1.8/gems/graticule-1.0.0.pre2/lib/graticule/geocoder/multi.rb:68:in `each'
/home/hov/.bundle/ruby/1.8/gems/graticule-1.0.0.pre2/lib/graticule/geocoder/multi.rb:68:in `detect'
/home/hov/.bundle/ruby/1.8/gems/graticule-1.0.0.pre2/lib/graticule/geocoder/multi.rb:68:in `result'
/home/hov/.bundle/ruby/1.8/gems/graticule-1.0.0.pre2/lib/graticule/geocoder/multi.rb:54:in `locate'
/home/hov/.bundle/ruby/1.8/gems/acts_as_geocodable-1.0.3/lib/acts_as_geocodable/geocode.rb:31:in `create_from_location'
/home/hov/.bundle/ruby/1.8/gems/acts_as_geocodable-1.0.3/lib/acts_as_geocodable/geocode.rb:27:in `find_or_create_by_location'
/home/hov/.bundle/ruby/1.8/gems/acts_as_geocodable-1.0.3/lib/acts_as_geocodable.rb:262:in `attach_geocode'
/data/hov/releases/20100408191329/lib/tasks/geocode.rake:5:in `send'
/data/hov/releases/20100408191329/lib/tasks/geocode.rake:5
/usr/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/batches.rb:26:in `find_each'
/usr/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/batches.rb:26:in `each'

Return Full Country Name

When using Google as the selected geocoder, it would be nice if we could somehow retrieve the full country name instead of just the two letter abbreviation.

gemspec includes invalid file

graticule did not have a valid gemspec.
This prevents bundler from installing bins or native extensions, but that may not affect its functionality.
The validation message from Rubygems was:
["test/config.yml"] are not files

Error with Ruby 1.9.2pre3 & Rails 3 beta4

I'm getting the following error when trying to use Graticule with Ruby 1.9.2pre3 & Rails 3 beta4:

/Users/foo/.rvm/gems/ruby-1.9.2-preview3/gems/graticule-1.0.0.pre2/lib/graticule/geocoder/google.rb:57:in <class:Placemark>': undefined methodwith_options' for Graticule::Geocoder::Google::Placemark:Class (NoMethodError)
from /Users/foo/.rvm/gems/ruby-1.9.2-preview3/gems/graticule-1.0.0.pre2/lib/graticule/geocoder/google.rb:48:in <class:Google>' from /Users/foo/.rvm/gems/ruby-1.9.2-preview3/gems/graticule-1.0.0.pre2/lib/graticule/geocoder/google.rb:12:inmodule:Geocoder'
from /Users/foo/.rvm/gems/ruby-1.9.2-preview3/gems/graticule-1.0.0.pre2/lib/graticule/geocoder/google.rb:2:in <module:Graticule>' from /Users/foo/.rvm/gems/ruby-1.9.2-preview3/gems/graticule-1.0.0.pre2/lib/graticule/geocoder/google.rb:1:in<top (required)>'
from /Users/foo/.rvm/gems/ruby-1.9.2-preview3/gems/graticule-1.0.0.pre2/lib/graticule.rb:11:in require' from /Users/foo/.rvm/gems/ruby-1.9.2-preview3/gems/graticule-1.0.0.pre2/lib/graticule.rb:11:in<top (required)>'
from /Users/foo/.rvm/gems/ruby-1.9.2-preview3/gems/bundler-0.9.26/lib/bundler/runtime.rb:46:in require' from /Users/foo/.rvm/gems/ruby-1.9.2-preview3/gems/bundler-0.9.26/lib/bundler/runtime.rb:46:inblock (2 levels) in require'
from /Users/foo/.rvm/gems/ruby-1.9.2-preview3/gems/bundler-0.9.26/lib/bundler/runtime.rb:41:in each' from /Users/foo/.rvm/gems/ruby-1.9.2-preview3/gems/bundler-0.9.26/lib/bundler/runtime.rb:41:inblock in require'
from /Users/foo/.rvm/gems/ruby-1.9.2-preview3/gems/bundler-0.9.26/lib/bundler/runtime.rb:40:in each' from /Users/foo/.rvm/gems/ruby-1.9.2-preview3/gems/bundler-0.9.26/lib/bundler/runtime.rb:40:inrequire'
from /Users/foo/.rvm/gems/ruby-1.9.2-preview3/gems/bundler-0.9.26/lib/bundler.rb:89:in gem_require' from /Users/foo/apps/bar/config/application.rb:7:in<top (required)>'
from /Users/foo/.rvm/gems/ruby-1.9.2-preview3/gems/railties-3.0.0.beta4/lib/rails/commands.rb:28:in require' from /Users/foo/.rvm/gems/ruby-1.9.2-preview3/gems/railties-3.0.0.beta4/lib/rails/commands.rb:28:inblock in <top (required)>'
from /Users/foo/.rvm/gems/ruby-1.9.2-preview3/gems/railties-3.0.0.beta4/lib/rails/commands.rb:27:in tap' from /Users/foo/.rvm/gems/ruby-1.9.2-preview3/gems/railties-3.0.0.beta4/lib/rails/commands.rb:27:in<top (required)>'
from script/rails:6:in require' from script/rails:6:in

'

First I though "with_options" had been removed in Rails 3 but it seems to still be there (at least in beta3): http://apidock.com/rails/v3.0.0.beta3/Object/with_options

Any idea what's going on?

REXML::ParseException: missing attribute quote, when Google blocks requests

Hello,
I use graticule 0.2.12 (unfortunately I cannot update to Rails3). When I try to locate some addresses that Google doesn't recognize, graticule raises an exception:

A REXML::ParseException occurred in :
 #<REXML::ParseException: missing attribute quote
Line: 
Position: 
Last 80 unconsumed characters:
<font face=times color=#0039b6 size=10>G</font><font face=times color=#c41200 siz>
/opt/ruby-enterprise-1.8.7-20090928/lib/ruby/1.8/rexml/parsers/baseparser.rb:355:in `pull'
/opt/ruby-enterprise-1.8.7-20090928/lib/ruby/1.8/rexml/parsers/treeparser.rb:22:in `parse'
/opt/ruby-enterprise-1.8.7-20090928/lib/ruby/1.8/rexml/document.rb:227:in `build'
/opt/ruby-enterprise-1.8.7-20090928/lib/ruby/1.8/rexml/document.rb:43:in `initialize'
/opt/ruby-enterprise-1.8.7-20090928/lib/ruby/gems/1.8/gems/graticule-0.2.12/lib/graticule/geocoder/rest.rb:13:in `new'
/opt/ruby-enterprise-1.8.7-20090928/lib/ruby/gems/1.8/gems/graticule-0.2.12/lib/graticule/geocoder/rest.rb:13:in `prepare_response'
/opt/ruby-enterprise-1.8.7-20090928/lib/ruby/gems/1.8/gems/graticule-0.2.12/lib/graticule/geocoder/base.rb:83:in `get'
/opt/ruby-enterprise-1.8.7-20090928/lib/ruby/gems/1.8/gems/graticule-0.2.12/lib/graticule/geocoder/google.rb:37:in `locate'
/opt/ruby-enterprise-1.8.7-20090928/lib/ruby/gems/1.8/gems/acts_as_geocodable-1.0.0/lib/acts_as_geocodable/geocode.rb:31:in `create_from_location'
/opt/ruby-enterprise-1.8.7-20090928/lib/ruby/gems/1.8/gems/acts_as_geocodable-1.0.0/lib/acts_as_geocodable/geocode.rb:27:in `find_or_create_by_location'
/opt/ruby-enterprise-1.8.7-20090928/lib/ruby/gems/1.8/gems/acts_as_geocodable-1.0.0/lib/acts_as_geocodable.rb:242:in `attach_geocode'

It seems that sometimes Google blocks requests. This is an example:

$ irb
irb(main):001:0> require 'rubygems'
=> true
irb(main):002:0> require 'graticule'
=> true
irb(main):003:0> g = Graticule.service(:google).new "MY_API_KEY"
=> #<Graticule::Geocoder::Google:0x9665b08 @key="MY_APY_KEY", @url=#<URI::HTTP:0x9665978 URL:http://maps.google.com/maps/geo>>
irb(main):004:0> g.locate "Via Ausonia Nuova km 1, 03043 cassino, italy"

And this is the response:

"<html><head><meta http-equiv=\"content-type\" content=\"text/html; charset=utf-8\"/><title>Sorry...</title><style> body { font-family: verdana, arial, sans-serif; background-color: #fff; color: #000; }</style></head><body><div><table><tr><td><b><font face=times color=#0039b6 size=10>G</font><font face=times color=#c41200 size=10>o</font><font face=times color=#f3c518 size=10>o</font><font face=times color=#0039b6 size=10>g</font><font face=times color=#30a72f size=10>l</font><font face=times color=#c41200 size=10>e</font></b></td><td style=\"text-align: left; vertical-align: bottom; padding-bottom: 15px; width: 50%\"><div style=\"border-bottom: 1px solid #dfdfdf;\">Sorry...</div></td></tr></table></div><div style=\"margin-left: 4em;\"><h1>We're sorry...</h1><p>... but your computer or network may be sending automated queries. To protect our users, we can't process your request right now.</p></div><div style=\"margin-left: 4em;\">See <a href=\"http://www.google.com/support/bin/answer.py?answer=86640\">Google Help</a> for more information.<br/><br/></div><div style=\"text-align: center; border-top: 1px solid #dfdfdf;\">&copy; 2009 Google - <a href=\"http://www.google.com\">Google Home</a></div></body></html>"

How can I prevent that exception?

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.