Changeset 908

Show
Ignore:
Timestamp:
10/13/07 10:55:35
Author:
seang
Message:

Features provide geo interface, with tests (#125)

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • PCL/trunk/PCL-Core/cartography/data/feature.py

    r544 r908  
    269269                'srs': str(b.srs), 'properties': dict(prop_items)} 
    270270 
     271    def _provideGeoInterface(self): 
     272        info = self.info() 
     273        return { 
     274            'id': info['id'], 
     275            'properties': info['properties'], 
     276            'geometry': self.properties[self.defaultgeometry().name].__geo_interface__ 
     277            } 
     278    __geo_interface__ = property(_provideGeoInterface) 
     279 
  • PCL/trunk/PCL-Core/tests/DataFeature.txt

    r544 r908  
    6868    >>> source.addfeature(ExampleFeature('tf:4', name='Union', the_geom=union, center=union.centroid())) 
    6969 
     70Geo interface provision 
     71----------------------- 
     72 
     73    >>> f = ExampleFeature('tf:1', name='A Polygon', the_geom=tri_a, center=tri_a.centroid()) 
     74    >>> f.__geo_interface__ 
     75    {'geometry': {'type': 'Polygon', 'coordinates': (((-1.0, 50.5, 1.7000000000000002e-308), (-0.5, 51.200000000000003, 1.7000000000000002e-308), (0.29999999999999999, 50.899999999999999, 1.7000000000000002e-308), (-1.0, 50.5, 1.7000000000000002e-308)),)}, 'id': 'tf:1', 'properties': {'name': 'A Polygon'}} 
     76