I've been looking into this and the Geocoding simply wants the long:lat + the code and accuracy (less than 3 isn't accurate enough and 200 is a result). XML bloats this a LOT.

The CSV method of the HTTP API returns a result in this for: {code},{acc},{lat},{long}

I've simply replaced the code which involved a call for a larger XML file + 3 Regex searches with a call to a small CSV (max about 25 bytes) + 1 explode/map to array. I also added a line (not 100% sure if its NECESSARY, but it feels sensible) which makes sure the results are either int or float where appropriate.

I attach a patch to update google.inc. I've tested it a little on my site - it works with correct data and when I put in incorrect data, the result was a 602 in the form 602,0,0,0 so everything still parsed into place.

Any thoughts?

Nick

CommentFileSizeAuthor
google.inc.csv.patch1.7 KBnicholasthompson

Comments

nicholasthompson’s picture

For reference, I was "inspired" by the final bullet point on this page:
http://googlemapsapi.blogspot.com/2006/07/speed-improvements-custom-curs...

yesct’s picture

Issue tags: +location geo-coding

related to
#132541: refactor google geocoding

also, I'm tagging this issue.

ayalon’s picture

@nicholasThompson
Error 620

620 G_GEO_TOO_MANY_QUERIES The given key has gone over the requests limit in the 24 hour period or has submitted too many requests in too short a period of time. If you're sending multiple requests in parallel or in a tight loop, use a timer or pause in your code to make sure you don't send the requests too quickly.

I'd prefere a jon implementation. As of php 5.2 a jscon decode is part of the php library this would be the best solution.

nicholasthompson’s picture

Heya...

1) Error 620 doesn't seem to be anything to do with this patch. It sounds more like you've over-hammered the Google API in the past 24 hours. XML, JSON or CSV wouldn't have changed this.

2) Why would you prefer a JSON request (larger than CSV) + JSON Decode (Not only causes a PHP 5.2 dependency but I cant believe a JSON Decode is more "lightweight" than a simply array explode on a delimiter).

I honestly don't mind which method is chosen as long as it works ;-) I'm just curious as to why you'd prefer the more complicated JSON method of the simpler CSV method...

ankur’s picture

Version: 5.x-3.x-dev » 7.x-4.x-dev

bump; if we change this, it should probably go to 7.x-4.x with a subsequent consideration for backporting.

podarok’s picture

Version: 7.x-4.x-dev » 7.x-3.x-dev
Status: Needs review » Active

#1931088: [META] Fixing tests tests were broken, so triggering to active

podarok’s picture

Status: Active » Needs review

bot

Status: Needs review » Needs work
Issue tags: -location geo-coding

The last submitted patch, google.inc_.csv_.patch, failed testing.