Changeset 909

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

Add FeatureCollectionProvider? class from which feature sources should derive, provides geo interface

Files:

Legend:

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

    r908 r909  
    278278    __geo_interface__ = property(_provideGeoInterface) 
    279279 
     280 
     281class FeatureCollectionProvider: 
     282 
     283    def _provideGeoInterface(self): 
     284        return { 
     285            'type': 'FeatureCollection', 
     286            'features': [f._geo_interface for f in self.iterfeatures()] 
     287            } 
     288    __geo_interface__ = property(_provideGeoInterface) 
     289 
  • PCL/trunk/PCL-Core/cartography/data/interfaces.py

    r544 r909  
    103103                           "(dict)") 
    104104    bounds = Attribute("Bounding box of the feature (IBoundingBox)") 
     105    __geo_interface__ = Attribute('Provide the Python geo interface') 
    105106 
    106107    def info(): 
     
    120121 
    121122    featuretype = Attribute("The source's feature type") 
     123    __geo_interface__ = Attribute('Provide the Python geo interface') 
    122124 
    123125    def iterfeatures(filter): 
  • PCL/trunk/PCL-Core/cartography/data/memory.py

    r573 r909  
    3030import sys 
    3131 
    32 from cartography.data.feature import Feature 
     32from cartography.data.feature import Feature, FeatureCollectionProvider 
    3333from cartography.geometry import BoundingBox 
    3434from cartography.data.interfaces import IFeatureStore, IFeatureSource 
     
    122122                'bounds': b} 
    123123 
    124 class MemoryFeatureSource
     124class MemoryFeatureSource(FeatureCollectionProvider)
    125125 
    126126    """Implements IFeatureSource. 
  • PCL/trunk/PCL-Core/cartography/data/postgis.py

    r744 r909  
    9191 
    9292from cartography.data.feature import Feature, isgeometry, \ 
    93     PropertyTypeCollection 
     93    PropertyTypeCollection, FeatureCollectionProvider 
    9494from cartography.data.feature import BooleanProperty, IntegerProperty \ 
    9595    , RealProperty, StringProperty, GeometryProperty, ArrayProperty 
     
    656656 
    657657 
    658 class PGFeatureSource
     658class PGFeatureSource(FeatureCollectionProvider)
    659659 
    660660    """A read-only source for features of a single type from a store.