{
"info": {
"author": "4teamwork AG",
"author_email": "mailto:info@4teamwork.ch",
"bugtrack_url": null,
"classifiers": [
"Framework :: Plone",
"Framework :: Plone :: 4.3",
"Framework :: Plone :: 5.1",
"Intended Audience :: Developers",
"License :: OSI Approved :: GNU General Public License (GPL)",
"Programming Language :: Python",
"Topic :: Software Development"
],
"description": "Introduction\n============\n\nThis product helps integrating the ``collective.geo.*`` packages and aims to\nprovide some sensible defaults. Besides some integration glue it defines a new\ninterface ``IGeocodableLocation`` that can be used to create adapters that knows\nhow to represent the location of a content type with address-like fields as a\nstring suitable for passing to a geocoding API.\n\n\nPurpose\n========\n\n- Automatic geocoding of ``IGeoreferenceable`` content types via an\n ``IGeocodableLocation`` adapter\n- Caching of geocoding responses\n- Only trigger geocoding lookups if location related fields on the content item\n changed\n- Facilitate doing automatic geocoding based on location fields and still allow\n for manually setting custom coordinates\n\n\nUsage\n=====\n\n\nAutomatically geocoding your content types\n------------------------------------------\n\nIn order for your content types to be automatically geocoded on ``ObjectEdited``\nor ``ObjectInitialized`` events, you need to create an adapter for your content\ntype that implements ``IGeocodableLocation`` and knows how to build a geocodable\nlocation string from the content type's location related fields.\n\nIn order to implement the interface you need to define a ``getLocationString``\nmethod on your adapter that returns the complete location as a comma separated\nstring, with the location parts getting less specific from left to right.\n\nFor example::\n\n '1600 Amphitheatre Parkway, Mountain View, CA, US'\n 'Engehaldestr. 53, 3012 Bern, Switzerland'\n\nIf the ``getLocationString`` method returns the empty string or ``None``, the\nevent handler won't attempt to do a geocode lookup, so this is the suggested way\nto abort geocoding if not enough location information is available.\n\nExample code::\n\n from ftw.geo.interfaces import IGeocodableLocation\n from zope.component import adapts\n from zope.interface import implements\n\n\n class MyTypeLocationAdapter(object):\n \"\"\"Adapter that is able to represent the location of an MyType in\n a geocodable string form.\n \"\"\"\n implements(IGeocodableLocation)\n adapts(IMyType)\n\n def __init__(self, context):\n self.context = context\n\n def getLocationString(self):\n \"\"\"Build a geocodable location string from the MyType's address\n related fields.\n \"\"\"\n street = self.context.getAddress()\n zip_code = self.context.getZip()\n city = self.context.getCity()\n country = self.context.getCountry()\n\n location = ', '.join([street, zip_code, city, country])\n return location\n\n\nRegister the adapter with ZCML::\n\n