Is there any way to make the google geocode return an accuracy parameter, if it gets the values from another field? The geocoder seems to always have a return value, even if it's just random characters entered as input.

Marking as major, I feel.

Comments

michaelfavia’s picture

This is a full response form a google geocode request:
http://maps.googleapis.com/maps/api/geocode/xml?address=78704&sensor=false

And here are the various location_type codes that refer to the type of geocoding that was done and googles level of accuracy/calculation:

  • "ROOFTOP" indicates that the returned result is a precise geocode for
    which we have location information accurate down to street address precision.
  • "RANGE_INTERPOLATED" indicates
    that the returned result reflects an
    approximation (usually on a road) interpolated between two precise points (such as intersections).
    Interpolated results are generally returned when rooftop geocodes are unavailable for a street
    address.
  • "GEOMETRIC_CENTER" indicates that
    the returned result is the geometric center of
    a result such as a polyline (for example, a street) or polygon (region).
  • "APPROXIMATE" indicates that the
    returned result is approximate.

You want the geocoder() function to return an object/associative array with this information in some fashion?

michaelfavia’s picture

Looked into this one as well for you and determined that pulling in the location_type (or a generic version of that value that is cross geocoder compatible) into the Point() class would be trivial if phayes sees value in having it there but having a hard time determining your usecase. Mind elaborating?

Here is the reference doc from bing geocode results:
http://msdn.microsoft.com/en-us/library/cc980950.aspx

They seem to have confidence interval but not location type field in their results.

nagiek’s picture

I only want to geocode fields which are 100% the spot (I guess ROOFTOP). Otherwise, I don't want the result. So if the geocoder can tell me what Google thinks of the result in an obj/array, that would be helpful.

Thanks Michael

michaelfavia’s picture

Status: Active » Postponed

This sounds like a reasonable feature. If someone else needs it (mark it back active) and ill consider writing it up myself, and i'll of course accept patches if you want to take a hack yourself.

I think it might best be implemented as a setting on the geocoder widget that each plugin can offer options for because each geocoder has different values (google, bing, yahoo).

We need the accuracy to be stored with the point or passed along with the geocoding result.

Im going to open another case to discuss this and other information we can glean off of our geocoding requests with phayes. If like to be able to offer address verification, bounding boxes, etc.

phayes’s picture

Category: bug » feature
Status: Postponed » Active

Okay, I'm going to start working on this.

I've already migrated away from using geoPHP for google-geocoding. Next step is to allow plugins to define config forms so we can add config for rejecting geocoding below a certain accuracy etc.

phayes’s picture

Done!

Check out the geocoder settings for google. You now have tons of additional options including the ability to reject geocodes based on accuracy. You can also also get the bounds (instead of the centroid) if you want.

As a bonus, I had to built a generalized system for geocoder-handlers to define settings forms. So now all geocoder-handlers can be configurable.

phayes’s picture

Status: Active » Fixed
michaelfavia’s picture

Implied in phayes comments is that this is in the 7.x-1.x dev branch if you want it not the beta release. It is also the only change at this point. We'll roll it into a release as soon as we get positive feedback and test it thoroughly.

phayes’s picture

Also implied is we need testing and code review. :-)

nagiek’s picture

Awesome!! Glad to hear.

I hope to give it a test tomorrow.

Shadlington’s picture

Is it at all possible to use this to reject results when just a country is entered in an addressfield (that you are geocoding from)?

From the description it seems like that level of control is not possible.

My request at #1380570: Reject geocoding if accuracy requirements are not met asking for this feature was closed as a duplicate of this one so if this is not available yet should I re-open it?

phayes’s picture

Oh yes, please do re-open

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.