Skip to content

GitLab

  • Projects
  • Groups
  • Snippets
  • Help
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in
C
Core
  • Project overview
    • Project overview
    • Details
    • Activity
    • Releases
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 1,011
    • Issues 1,011
    • List
    • Boards
    • Labels
    • Service Desk
    • Milestones
  • Operations
    • Operations
    • Incidents
  • Analytics
    • Analytics
    • Repository
    • Value Stream
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Members
    • Members
  • Activity
  • Graph
  • Create a new issue
  • Commits
  • Issue Boards
Collapse sidebar
  • Development
  • Core
  • Issues
  • #732

Closed
Open
Created Feb 18, 2019 by jaapjansma@jaapjansmaDeveloper

Parsing of addresses in the format of different countries

CiviCRM has the ability to parse addresses into a street name, house number and street unit. This parsing is based on I assume US address formats.

E.g. an address like 799 E DRAGRAM SUITE 5A is parsed into house number: 799, street name: E Dragram, and Street unit Suite 5a.

In the Netherlands and Belgium the adresses are formatted in a different way, first it is the street name, then the house number and then the street unit.

Some examples:

  • Grote straat 1a, which should be parsed to Street name: Grote straat, house number 1, and street unit a
  • Grote straat 2-3, which should be parsed to Street name: Grote straat, House number 2, and street unit 3
  • Plein 40-45 60-II, which should be parsed to Street name: Plein 40-45, house number 60 and street unit II

What I think CiviCRM should be capable of (either with an extension or in core):

  1. Parse addresses based on the country of the address
  2. Format addresses based on the country of the address, meaning glue the individual address (Street name, house number, street unit) parts into one address

How does it work currently?

When I enable Address Parsing I can enther a full address into CiviCRM.

If I enter Grote straat 1a it gets parsed into Address name: Grote straat 1a, House number: empty and street unit empty If I enter Plein 40-45 60-II it gets parsed into Address name: Plein 40-45 60-II, House number: empty and street unit empty

If I enter the individual parts, street name: Grote straat, house number: 1 and street unit a, it gets formatted to 1 Grote straat a

As you can see the formatting and parsing of Dutch and Belgium addresses does not work.

Proposed solution

I do think it will be good when the address parsing functionality could be made in such way that extensions could hook into it.

I am thinking of a hook which provides callback functions for address parsing based on the country ID of the address.

Example code


$callbacks[1020] = array('CRM_Address_BAO_Address', 'parseBelgiumAddress');
$callbacks['default'] = array('CRM_Address_BAO_Address', 'parseAddress');

/**
 * Alter the callbacks for address parsing
 * 
 * @param array $callbacks
 */
hook_civicrm_alter_address_parser_callbacks(&$callbacks) {
  // Add a custom address parser
  // For example the dutch one:
  $callbakcs[1152] = array('CRM_MyExtension_DutchAddressParser', 'parseDutchAddress');
}

This way CiviCRM core could provide a default address parser, and a set of address parser for certain countries and if one is missing an extension developer could write the missing parser.

What do you think of this? If everyone is happy I am happy to implement this.

Edited Feb 18, 2019 by jaapjansma
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Assignee
Assign to
None
Milestone
None
Assign milestone
Time tracking
None
Due date
None