zgeo.wfs.geoitem Readme
=========================

Overview
--------
GeoItem is an adapter class to provide a Georeferenceable behaviour to an AT class and
allow it to be handle in a IWebFeatureServiceable folder


Your tests here
---------------

IGeoreferenceable (from zgeo.geographer) is a marker interface for objects contained
in a IWebFeatureServiceable object (they can be immediate children or not), they are supposed to be AT

    >>> from zope.interface import implements
    >>> from Products.ATContentTypes.content.folder import ATFolder
    >>> from Products.zgeo.wfs.interfaces import IWebFeatureServiceable
    >>> class MyGeoFolder(ATFolder):
    ...    implements(IWebFeatureServiceable)
    
    >>> from Products.ATContentTypes.content.document import ATDocument
    >>> from Products.zgeo.geographer.interfaces import IGeoreferenceable
    
    >>> class MyGeoObject(ATDocument):
    ...    implements(IGeoreferenceable)
    
IGeoreferenceable objects can be adapted as a GeoItem
    >>> from Products.zgeo.geographer.interfaces import IGeoItem
    >>> f=MyGeoFolder('f')
    >>> f.item1=MyGeoObject('o')
    >>> f.item1.setTitle('My title')
    >>> o=f.item1
    >>> geoitem=IGeoItem(o)
    >>> type(geoitem)
    <class 'Products.zgeo.wfs.geoitem.GeoItem'>
    >>> o.Title()
    'My title'
    
The geoitem's feature type is set to 'default'
    >>> geoitem.featureType
    'default'

unless it defined its own feature type
    >>> class MyCityGeoObject(ATDocument):
    ...    implements(IGeoreferenceable)
    ...    @property
    ...    def featureType(self):
    ...       return 'Cities'
    >>> from Products.zgeo.wfs.interfaces import IWebFeatureService
    >>> IWebFeatureService(f).addFeatureType('Cities')
    >>> f.item2=MyCityGeoObject('o2')
    >>> f.item2.setTitle('Bamako')
    >>> o2=f.item2
    >>> geoitem2=IGeoItem(o2)
    >>> geoitem2.featureType
    'Cities'
    
GeoItem can store a Geometry in its context
    >>> geoitem.storeGeometryFromWKT('POINT (10 10)')
    >>> type(geoitem.geometry)
    <class 'shapely.geometry.point.Point'>
    >>> geoitem2.storeGeometryFromWKT('LINESTRING (20 20, 30 60, 100 80, 20 20)')
    >>> type(geoitem2.geometry)
    <class 'shapely.geometry.linestring.LineString'>
    
GeoItem can return its bounding box:
	>>> from Products.zgeo.wfs.geoitem import bboxAsTuple
    >>> bboxAsTuple(geoitem2.geometry)
    (20.0, 20.0, 100.0, 80.0)
    
A GeoItem can find its IWebFeatureServiceable nearest ancestor:
    >>> geoitem2.getWFSParent().context.id
    'f'
    >>> f.subfolder=ATFolder('subfolder')
    >>> f.subfolder.item3=MyCityGeoObject('o3')
    >>> geoitem3=IGeoItem(f.subfolder.item3)
    >>> geoitem3.getWFSParent().context.id
    'f'



    

 
