Changeset 606
- Timestamp:
- 01/08/07 14:30:29
- Files:
-
- PCL/trunk/PCL-Core/cartography/data/georss.py (moved) (moved from PCL/trunk/PCL-Core/cartography/data/atom.py) (8 diffs)
- PCL/trunk/PCL-Core/GeoRSSFeatures.txt (moved) (moved from PCL/trunk/PCL-Core/tests/AtomFeatures.txt) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
PCL/trunk/PCL-Core/cartography/data/georss.py
r605 r606 42 42 43 43 44 # Factory for Atomfeature sources45 def atom_source(file):44 # Factory for GeoRSS feature sources 45 def georss_source(file): 46 46 """Return a feature source.""" 47 47 # Python files, filenames, or strings … … 54 54 except: 55 55 import pdb; pdb.set_trace() 56 return AtomFeatureSource(document=d)56 return GeoRSSFeatureSource(document=d) 57 57 58 58 # Factory for features 59 def atom_feature(entry):59 def georss_feature(entry): 60 60 # parse the geometry 61 61 if entry.has_key('georss_point'): … … 82 82 the_geom = None 83 83 84 return AtomFeature(84 return GeoRSSFeature( 85 85 id=entry['id'], 86 86 title=entry['title'], … … 91 91 92 92 93 class AtomFeature(Feature):93 class GeoRSSFeature(Feature): 94 94 95 95 """A feature corresponds to an Atom/RSS entry. … … 97 97 implements(IFeature) 98 98 99 __typename__ = ' AtomFeature'99 __typename__ = 'GeoRSSFeature' 100 100 __schema__ = PropertyTypeCollection([ 101 101 StringProperty('id'), … … 108 108 109 109 110 class AtomFeatureSource:110 class GeoRSSFeatureSource: 111 111 112 112 """Implements IFeatureSource. … … 119 119 """Initialize""" 120 120 self.document = document 121 self._featuretype = AtomFeature121 self._featuretype = GeoRSSFeature 122 122 #self._bbox = None 123 123 #self._maxfeatures = -1 … … 128 128 def iterfeatures(self): 129 129 for entry in self.document.entries: 130 yield atom_feature(entry)130 yield georss_feature(entry) 131 131 132 132 __call__ = iterfeatures PCL/trunk/PCL-Core/GeoRSSFeatures.txt
r605 r606 21 21 Imports 22 22 23 >>> from cartography.data. atom import atom_source, atom_feature23 >>> from cartography.data.georss import georss_source, georss_feature 24 24 25 25 Source 26 26 27 >>> source = atom_source(file("../fixtures/atom-simple.xml"))27 >>> source = georss_source(file("../fixtures/atom-simple.xml")) 28 28 29 29 Features 30 30 31 >>> fx = atom_feature(source.document.entries[0])31 >>> fx = georss_feature(source.document.entries[0]) 32 32 >>> fx.properties.title 33 33 u'Entry 1' … … 37 37 20.0 38 38 39 >>> fx = atom_feature(source.document.entries[1])39 >>> fx = georss_feature(source.document.entries[1]) 40 40 >>> fx.properties.title 41 41 u'Entry 2' … … 49 49 -110.0 50 50 51 >>> fx = atom_feature(source.document.entries[2])51 >>> fx = georss_feature(source.document.entries[2]) 52 52 >>> fx.properties.title 53 53 u'Entry 3' … … 63 63 -100.0 64 64 65 >>> fx = atom_feature(source.document.entries[3])65 >>> fx = georss_feature(source.document.entries[3]) 66 66 >>> fx.properties.title 67 67 u'Entry 4'
