===================
EEA Geotags storage
===================

Geo tags are stored using annotations, therefore an adapter is provided to
access and modify them. We choose geojson standard (see. http://geojson.org) for
this structure. You can apply geo tagging to any content-type you want, if
annotation is enabled for it. This package enables geo tagging for all
content-types derived from Archetypes.BaseObject.


Accessing geo tags
==================

First of all let's add some content to work on

    >>> sid = folder.invokeFactory('Document', id='sandbox')
    >>> sandbox = folder._getOb(sid)

Now adapting our content, we can easily get and set geotags

    >>> from zope.component import getAdapter
    >>> from eea.geotags.interfaces import IGeoTags
    >>> geo = getAdapter(sandbox, IGeoTags)

Let's see if there are default tags

    >>> geo.tags
    {}

No, there is no tag. Let's add some:

    >>> geo.tags = {
    ...   "type":"FeatureCollection",
    ...   "features":[{
    ...     "type":"Feature",
    ...     "bbox":[50.79345,11.106916,51.120421,11.697367],
    ...     "geometry":{
    ...       "type":"Polygon",
    ...       "coordinates":[[50.79345,11.106916],[50.79345,11.697367],
    ...                      [51.120421,11.697367],[51.120421,11.106916]]},
    ...     "properties":{
    ...       "name":"",
    ...       "title":"Weimarer Land",
    ...       "description":"Weimarer Land, Germany",
    ...       "tags":["administrative_area_level_2","political"],
    ...       "center":[51.0165423,11.4454373],
    ...       "other":{}}}]}

    >>> geo = getAdapter(sandbox, IGeoTags)

    >>> geo.tags['type']
    'FeatureCollection'

    >>> geo.tags['features'][0]['type']
    'Feature'

    >>> geo.tags['features'][0]['bbox']
    [50.79345, 11.106916, 51.120421, 11.697367]


Usage in Plone
==============

A widget and 2 fields (string and lines) are provided to be used within your
Archetypes based content-types. For a demo content-type see:

    >>> from eea.geotags.content.demo import EEAGeotagsDemo

The widget can be used from:

    >>> from eea.geotags.widget.location import GeotagsWidget

and the fields from:

    >>> from eea.geotags.field.location import GeotagsStringField
    >>> from eea.geotags.field.location import GeotagsLinesField
