Changeset 607
- Timestamp:
- 01/08/07 20:54:43
- Files:
-
- PCL/trunk/PCL-Core/cartography/data/georss.py (modified) (3 diffs)
- PCL/trunk/PCL-Core/tests/GeoRSSFeatures.txt (moved) (moved from PCL/trunk/PCL-Core/GeoRSSFeatures.txt)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
PCL/trunk/PCL-Core/cartography/data/georss.py
r606 r607 34 34 import feedparser 35 35 36 from cartography.styles import Layer 36 37 from cartography.geometry import * 37 38 from cartography.data.feature import * 38 39 from cartography.proj import SpatialReference 39 from cartography.data.interfaces import IFeature, IFeatureSource 40 from cartography.data.interfaces import IFeature, IFeatureSource, IFeatureStore 40 41 41 42 from zope.interface import implements … … 90 91 ) 91 92 93 def source_layer(source): 94 """Factory for a cartographic Layer.""" 95 typename = source.document.feed.title 96 ds = GeoRSSFeatureStore(sources={typename: source}) 97 return Layer(ds, typename) 98 92 99 93 100 class GeoRSSFeature(Feature): … … 131 138 132 139 __call__ = iterfeatures 133 140 141 142 class GeoRSSFeatureStore: 143 144 """Implements IFeatureStore. 145 146 A store corresponds to an Atom service document. 147 """ 148 implements(IFeatureStore) 149 150 def __init__(self, sources): 151 self.sources = sources.copy() 152 153 def featuretype(self, typename): 154 return GeoRSSFeature 155 156 def source(self, typename, maxfeatures=-1): 157 return self.sources[typename] 158 159 def count(self, typename): 160 """Returns the feature count.""" 161 return len(self.sources[typename].document.entries) 162 163 def typenames(self): 164 """Returns the typenames available in this store.""" 165 return tuple(self.sources.keys()) 134 166 135 167
