ginkgostreet / com.ginkgostreet.geofill

When CiviCRM geocodes an address, the geocoding service generally returns much more information than CiviCRM uses. This extension allows site administrators to set a policy for what to do with that information on a field-by-field basis: discard it, fill in missing data, or overwrite existing data.
Other
4 stars 2 forks source link

Some Address Components from Google not properly parsed #1

Closed ghost closed 7 years ago

ghost commented 7 years ago

Hi,

It seems Google has changed their geodata results and sometimes the address component's type is an array instead of simply being a string. This causes the parsing function to fail to catch all the address components returned.

Submitted a PR for a simple fix that worked for me.

universalhandle commented 7 years ago

Hi, thanks for contributing! Could you please provide steps to reproduce the problem so I can see it in action? Sometimes it's helpful to bring things out of the abstract.

ghost commented 7 years ago

Hi!

Oops, forget about this patch. I just realized that CRM_Geofill_Parser_Google->getAddressProperty was already parsing arrays or strings properly.

I was led on the wrong track because initially it did not work for me:

What I did

  1. Install the com.ginkgostreet.geofill extension
  2. Set all fields of the "Geodata Filler Extension Settings" to "Fill"
  3. Configure Google as the geocoder
  4. Run the "geocode" job

What I expected

For the geo_code values of contacts to be populated (by the Google geocoder), along with the missing country, state_province, city, postal code, etc (by com.ginkgostreet.geofill).

What happened

The geo_code values were populated along with the postal code, but the city fields were never updated.

What I found

CRM_Utils_Address_BatchUpdate->processContacts from CiviCRM core will disregard most fields being sent back from the geocoder (and hook). I created issue #6 to highlight this problem and created an issue/PR with CiviCRM (CRM-19977) to see if it could be resolved.

I originally thought that the issue was that CRM_Geofill_Parser_Google->getAddressProperty (from com.ginkgostreet.geofill) would fail when the geodata results would contain an array for the address component type.

My mistake, sorry. But there is still a problem with CiviCRM in handling the updated fields this extension is sending back.