CiviCRM Community Forums (archive)

*

News:

Have a question about CiviCRM?
Get it answered quickly at the new
CiviCRM Stack Exchange Q+A site

This forum was archived on 25 November 2017. Learn more.
How to get involved.
What to do if you think you've found a bug.



  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion (Moderator: Donald Lobo) »
  • Address Standardisation
Pages: [1]

Author Topic: Address Standardisation  (Read 625 times)

Eileen

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4195
  • Karma: 218
    • Fuzion
Address Standardisation
July 06, 2013, 03:27:57 pm
We have had several recent requests for address standardization in one form or another. The requests take 3 main forms

1) Autofill - looking up an api on data entry
2) Validation
3) Flagging addresses that don't validate for manual checking

Autofill, especially on front end forms could potentially use  google. I looked into how far Google would get us as there there is no suitable nz specific provider I could find. Autofill is not going to be a quick fix however as there are multiple forms that would need fixing.

It is clear that even with Google or another provider there is always going to be a need to enter data that cannot be found. And to validate that data or existing data. It seems this is an easier mountain to climb. I found that although we are not currently using it Google Geocoding provides a lot of other address details which we could use. I had a play and found I could fairly easily
 
1) check if we have a street_number, street_address, locality (google field) match.
2) if we have the above & no post code put in the post code
3) if no match then mark the address

https://github.com/eileenmcnaughton/civicrm-core/commit/a4e9945ea0c2edbfffb8448bdf6392a0eed35d13

However, I used a field we don't use (postal_code_suffix) as a stand-in for having an address status field (if we did have one then we could flag as 'requiring review' & 'reviewed'. We could also use it to mark 'bad' addresses - our customers don't always want to remove bounced addresses from the system straight away or might only post some things to 'verified' addresses - which could be home or work).

So, if we look at how this could go further we probably need 2 things

1) I need to be able to hook into the data returned by google & make some validation calls. Google has a daily limit so I don't want to be retrieving the same data multiple times. By the same token the rules that I come up with to define a match may not be universally suitable.

2) I need a way to mark which addresses need review & which have been reviewed (and shouldn't subsequently be marked as needing review).

I guess as long as a hook once called once google had it's results (and any changes I made from that hook to any field were retained & saved) I could use a custom field to denote status. Or else I could create a separate location type (for each location type?) where I store the google returned address so people can choose to make that the home address or whatever.

Alternatively the result returned from google could be stored (either by my hook or by core job) as an array in a field 'standardized_address' attached to the address if if differs from the recorded one. I could search for addresses with data in that array & perhaps have a checkbox to switch address over if I prefer it)

http://stackoverflow.com/questions/1555253/how-to-make-an-autocomplete-address-field-with-google-maps-api
Make today the day you step up to support CiviCRM and all the amazing organisations that are using it to improve our world - http://civicrm.org/contribute

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion (Moderator: Donald Lobo) »
  • Address Standardisation

This forum was archived on 2017-11-26.