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) »
  • Automatically Adding City Council District Number to a Contact
Pages: [1]

Author Topic: Automatically Adding City Council District Number to a Contact  (Read 379 times)

ldugger

  • I’m new here
  • *
  • Posts: 8
  • Karma: 0
    • LAANE
  • CiviCRM version: 4.3.4
  • CMS version: Drupal 7.8
  • MySQL version: 5.1.69
  • PHP version: 5.3.16
Automatically Adding City Council District Number to a Contact
May 15, 2014, 11:04:47 am
Hello,

I am hoping someone on this forum has had some experience with this.

DETAILS:
I need to automatically assign a city district number to contacts in our database depending on the contacts address. 
The district numbers are determined by geo-code boundaries (JSON or KML Format)
The Boundaries files are available here-->  http://boundaries.latimes.com/set/la-city-council-districts-2012/

So basically, the database would compare the contact's address with the district boundaries.  If the contact's address is within the boundary of the district, then a custom field labeled district number could be filled in with the appropriate number.

HELP! How should I approach this?  ???

Using DRUPAL 7 and Civi 4.3.7

Jeremy Proffitt

  • I post occasionally
  • **
  • Posts: 63
  • Karma: 2
    • Mobius New Media
  • CiviCRM version: 4.4.x
  • CMS version: Joomla 2.5.x/3.x / D7
  • MySQL version: 5.1.x
  • PHP version: 5.3.10+, 5.4.x
Re: Automatically Adding City Council District Number to a Contact
May 16, 2014, 07:37:33 am
If you have the geocoding turned on in Civi, then each contact address has a geo_code_1 (lat) and geo_code_2 (lng) value. You'd need to either figure out the math yourself or see if the OpenStreetMaps or Google Maps APIs have a method for determining whether something is inside a specified boundary. The GMaps API does (LatLngBounds), but it's for a rectangle.

Back in Civi, you could create an extension to act on the hook_civicrm_post or hook_civicrm_postProcess hooks when a new address is added, that will run a script executing your API call and add that value to your new contact's address record.
Jeremy Proffitt
Mobius New Media
IRC: JP_EzoD

mathieu

  • Administrator
  • Ask me questions
  • *****
  • Posts: 620
  • Karma: 36
    • Work
  • CiviCRM version: 4.7
  • CMS version: Drupal
  • MySQL version: MariaDB 10
  • PHP version: 7
Re: Automatically Adding City Council District Number to a Contact
May 27, 2014, 06:02:51 am
For what it's worth, I have written this extension that has a similar aim, but it assumes that you are using a postcode or similar code to "lookup" in a database table: https://github.com/mlutfy/ca.bidon.regionlookup

Using geocoding makes sense when drawing maps, but it seems complicated for quick lookups. Doesn't the city publish similar data for postcodes or specific addresses? The "open data" portal of L.A. seems to require a login. Worst case, municipal political parties should have access to such a list. Before the open data portal in Montreal, it was possible to get the data by asking the city clerk directly.
CiviCamp Montréal, 29 septembre 2017 | Co-founder / consultant / turn-key CiviCRM hosting for Quebec/Canada @ SymbioTIC.coop

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion (Moderator: Donald Lobo) »
  • Automatically Adding City Council District Number to a Contact

This forum was archived on 2017-11-26.