Geofield + geocoder + addressfield + openlayers is a great combination!

However, I'm getting some unsatisfactory results when users fail to enter anything besides the country in the addressfield - a single point somewhere inside the country is geocoded and stored in the geofield.

I'd rather it failed to geocode anything and just left the geofield empty.

Is this behaviour possible currently?

(Apologies if this should be in geocoder's queue, its hard to know exactly where the best place is sometimes)

Comments

phayes’s picture

Project: Geofield » Geocoder
Version: 7.x-2.x-dev » 7.x-1.x-dev
Category: support » feature

This indeed should be in the geocoder queue - moving it there.

This is really a feature request to be able to "reject" geocoding if certain accuracy requirements are not met

Shadlington’s picture

Title: Any way to prevent geocoding from addressfield if only country is entered? » Reject geocoding if accuracy requirements are not met

Thanks for the clarification!

petsagouris’s picture

I believe that this is a duplicate to this: #1295262: Accuracy from google geocode

michaelfavia’s picture

Status: Active » Closed (duplicate)

It is a duplicate but i would like to fix it. Its nontrivial feature to add but maybe i can spend some time this weekend on this.

phayes’s picture

Status: Closed (duplicate) » Active

So this is almost ready. I suppose the last thing we need for this to work is that we need some sort of form integration so that the form fails if the geocoding fails. This might be tricky now that we've moved the processing to the entity save, not the form submit.

phayes’s picture

Does anyone have any ideas on how this might be accomplished?

michaelfavia’s picture

I dont know of a mechanism to prevent this to be honest.

Perhaps we could geocode in hook validate/submit and return an error or statically save then in entity save either recapture the static result or reprocess if none exists.

Otherwise youre stuck with a drupal_redirect() + $form_state and set a form error without storing the geofield but that just seems janky and error prone for bulk operations and the like.

miahon’s picture

Hi! Is this ready for testing? I have a similar problem to what Shadlington told

I'm doing the calendar of events and some events do not have the address information at all, but the addressfield module always sends country value to geocoder and and this false information is displayed on the map

ptmkenny’s picture

As an alternate approach, there is a patch to improve accuracy of geocoding the country if using the countries module: http://drupal.org/node/1871962

basvredeling’s picture

Issue summary: View changes
Status: Active » Closed (won't fix)

Honestly I think this is no longer reliably implementable over all geocoding services. In Google Geocoding API v2 there was an "Accuracy" property returned for the geocoded values. In API v3 this is no longer the case and replaced by a "Location Type" property instead. Which only returns "interpolated" or "approximate" as a value instead of a numeric rating. See this discussion for more info: http://stackoverflow.com/questions/3015370/how-to-get-the-equivalent-of-the-accuracy-in-google-map-geocoder-v3 and for the API documentation: https://developers.google.com/maps/documentation/geocoding/intro#Results.

Regarding other Geocoding services, I've checked both Bing and Yahoo. Bing has a "confidence" value, returning either "low", "medium" or "high" as an accuracy value. See: https://msdn.microsoft.com/en-us/library/jj735477.aspx. Yahoo returns a "Quality" property for it's geocoded values. But this is both contextual (to the search) and non-linear. See: https://developer.yahoo.com/boss/geo/docs/pfrequests.html#result-sub-elements for the documentation.

In either case I believe this should not be a geocoder functionality. Also considering the age of this issue I'm marking this won't fix. I hope the above mentioned documentation will help someone to come up with use-case specific submodules.