steve8x8 / geotoad

Geocaching query tool written in Ruby
https://buymeacoffee.com/steve8x8
Other
28 stars 8 forks source link

Switch to Geocode API v3 (May need a new API key for Geotoad's geocoding feature) #279

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
[Please include the relevant parts of your command line, if applicable.
Don't send your password though!]
1. Attempting to search Geotoad via address (option "location" in search type)
2.
3.

What is the expected output? What do you see instead?
[If possible, include the last ~10--20 lines of verbose output.]

Expected output is Google Maps pulling correct geocoded location.  What is 
instead happening is that the URL used for geocoding (with Google Maps) is 
hitting the "too many queries at once" wall; this can easily be seen at 
http://maps.google.com/maps/geo?q=205+Ski+Mountain+Road,+Gatlinburg,+TN&output=c
sv&oe=utf8&sensor=false&key=ABQIAAAAfYtme_pyDnFOuJLGZiXvPxRuVmV2GDBxlUzS4Tl93rTy
ZWZiOBRL7BgtHIJc12HxIcS5teMAlIPzw (yes, I picked a random hotel in Gatlinburg, 
TN to demonstrate).  Actually visiting the Google Maps page in question notes 
an error about repeated access from the computer or network, typical of when an 
app goes above its API limits.

What version of the product are you using? On what operating system?
[Did you check you're using the latest version?]

Able to reproduce on both Windows 7 (3.7.11 devel) and Mint Linux (3.7.11 devel 
branch).

Please provide any additional information below.

Coordinate searches ARE working, so this is definitely a GMaps issue (and 
specifically an issue with the API key in geocode.rb; going to 
http://maps.google.com/maps/geo shows the expected 610 code, and tools using a 
different Google Maps API are working correctly).

Original issue reported on code.google.com by windigo...@gmail.com on 16 Sep 2013 at 7:04

GoogleCodeExporter commented 9 years ago
- Confirmed.
- It's even worse: while lib/geocode.rb refers to 
http://code.google.com/apis/maps/documentation/geocoding/, that URL redirects 
to https://developers.google.com/maps/documentation/geocoding/?csw=1 now which 
lists a completely different query URL: 
http://maps.googleapis.com/maps/api/geocode/output?parameters instead of 
http://maps.google.com/maps/geo?q=...
- The document says "Note that the Geocoding API v2 has been turned down and is 
no longer available." and apparently that's exactly what happened. (When? Is 
there an official announcement?)

I admit I have no idea how to fix this (except throwing an error if "-q 
location" is used), I have never ever worked with the GMaps API. Checking the 
SVN log for geocode.rb, it's a feature that got implemented by helixblue in 
2010 and never maintained thereafter.

If someone can come up with a rewrite, I'd be happy to implement it, but I'm 
afraid the issue will have to wait until after 3.18.0.

Somewhat inappropriately tagging as InfoNeeded (as there's no matching tag 
available)

-S

Original comment by Steve8x8 on 17 Sep 2013 at 7:25

GoogleCodeExporter commented 9 years ago
Citing https://developers.google.com/maps/articles/geocodingupgrade:
"Version 2 ("v2") of the Geocoding API was officially deprecated on 8 March 
2010 and has now been turned down. As of 9 September 2013 the v2 API will no 
longer work."

As if there were no other problems ;)

Actually, there's no mention of an API key in the v3 document anymore but still 
a daily access limit: "2,500 requests per day" - but somehow I don't understand 
whether this is measured per IP address or whatever.

Apparently, a URL like 
  http://maps.googleapis.com/maps/api/geocode/json?sensor=false&address=205+Ski+Mountain+Road,+Gatlinburg,+TN
_does_ return something useful (JSON parser, anyone?), and asking for "The 
house of the rising sun" even returns multiple results. "Milliways" seems to be 
unknown to GMaps though ;)

So if someone comes up with a rewritten geocode.rb by Friday, it might get into 
3.18.0 - any takers?

Original comment by Steve8x8 on 17 Sep 2013 at 7:45

GoogleCodeExporter commented 9 years ago
Oh well. As the leopard can't change its spots, here we go.

Attached is a drop-in for lib/geocode.rb which will return the first match (if 
there is any). Could be extended to warn the user about possible ambiguities, 
but I guess if you're searching for Paris in Kentucky you'll enter "Paris, KY" 
not to end up with the much bigger one in France, right? ;)

Original comment by Steve8x8 on 17 Sep 2013 at 8:53

Attachments:

GoogleCodeExporter commented 9 years ago
Re the New API--this IS per IP address, not per app (otherwise there would be 
Windows apps using the new API that would commit suicide VERY quickly because 
of larger user bases--much less a lot of Android apps :D).  So we'll try this 
fix and see if it works out.

(If it doesn't, I do know Mapquest is apparently doing unlimited geocoding via 
OSM databases, but I'd prefer to stick with GMaps if we can :D)

Original comment by windigo...@gmail.com on 17 Sep 2013 at 5:48

GoogleCodeExporter commented 9 years ago
And the good news is--it's definitely working now.  (Even did a test build with 
the new library on Windows 7 just to be sure--things DO seem to be behaving 
better.)

Original comment by windigo...@gmail.com on 17 Sep 2013 at 6:10

GoogleCodeExporter commented 9 years ago
Thanks for sharing some good news - it looks like we can get this into 3.18.0 
by next week. (I have slightly enhanced the code, to return the matching 
location and the match count, and will run some more tests.)

Original comment by Steve8x8 on 17 Sep 2013 at 7:05

GoogleCodeExporter commented 9 years ago
Test results, with some fictional locations :)

( o ) Performing location search for 205 Ski Mountain Road, Gatlinburg, TN 
(constraining to 0.01 miles)
 ***  No closing HTML tag found (this is OK for Google Maps)
( o ) Google Maps found "205 Ski Mountain Road, Gatlinburg, TN"
( o ) Using result 1 of 1: "205 Ski Mountain Road, Gatlinburg, TN 37738, USA"
( o ) Accuracy level ROOFTOP, will use coordinates 35.7069020, -83.5241280
( o ) No geocaches were found.

( o ) Performing location search for Milliways, End of the universe 
(constraining to 0.01 miles)
 ***  No closing HTML tag found (this is OK for Google Maps)
 ***  Google Maps failed to determine the location of Milliways, End of the universe
 ***  Could not determine search type for location "Milliways, End of the universe"
 ***  You may want to remove special characters or try a "coord" search instead

( o ) Performing location search for Paris (constraining to 0.01 miles)
 ***  No closing HTML tag found (this is OK for Google Maps)
( o ) Google Maps found "Paris"
( o ) Using result 1 of 5: "Paris, France"
( o ) Accuracy level APPROXIMATE, will use coordinates 48.8566140, 2.3522219
( o ) No geocaches were found.

( o ) Performing location search for Paris, Kentucky (constraining to 0.01 
miles)
 ***  No closing HTML tag found (this is OK for Google Maps)
( o ) Google Maps found "Paris, Kentucky"
( o ) Using result 1 of 1: "Paris, KY 40361, USA"
( o ) Accuracy level APPROXIMATE, will use coordinates 38.2097987, -84.2529869
( o ) No geocaches were found.

( o ) Performing location search for Dark side of the moon (constraining to 
0.01 miles)
 ***  No closing HTML tag found (this is OK for Google Maps)
 ***  Google Maps failed to determine the location of Dark side of the moon
 ***  Could not determine search type for location "Dark side of the moon"
 ***  You may want to remove special characters or try a "coord" search instead

( o ) Performing location search for Nuclear plant Springfield (constraining to 
0.01 miles)
 ***  No closing HTML tag found (this is OK for Google Maps)
( o ) Google Maps found "Nuclear plant Springfield"
( o ) Using result 1 of 4: "Power Plant, Gill, MA 01354, USA"
( o ) Accuracy level APPROXIMATE, will use coordinates 42.6681293, -72.4803948
( o ) No geocaches were found.

Committing to trunk now.

Original comment by Steve8x8 on 18 Sep 2013 at 9:40

GoogleCodeExporter commented 9 years ago
committed to trunk

Original comment by Steve8x8 on 19 Sep 2013 at 6:54

GoogleCodeExporter commented 9 years ago
Closing.

Original comment by Steve8x8 on 24 Sep 2013 at 10:08