Changeset 606

Show
Ignore:
Timestamp:
01/08/07 14:30:29
Author:
seang
Message:

Use GeoRSS instead of Atom since feedparser should handle all flavors (#95)

Files:

Legend:

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

    r605 r606  
    4242 
    4343 
    44 # Factory for Atom feature sources 
    45 def atom_source(file): 
     44# Factory for GeoRSS feature sources 
     45def georss_source(file): 
    4646    """Return a feature source.""" 
    4747    # Python files, filenames, or strings 
     
    5454    except: 
    5555        import pdb; pdb.set_trace() 
    56     return AtomFeatureSource(document=d) 
     56    return GeoRSSFeatureSource(document=d) 
    5757 
    5858# Factory for features 
    59 def atom_feature(entry): 
     59def georss_feature(entry): 
    6060    # parse the geometry 
    6161    if entry.has_key('georss_point'): 
     
    8282        the_geom = None 
    8383 
    84     return AtomFeature( 
     84    return GeoRSSFeature( 
    8585        id=entry['id'], 
    8686        title=entry['title'], 
     
    9191 
    9292 
    93 class AtomFeature(Feature): 
     93class GeoRSSFeature(Feature): 
    9494 
    9595    """A feature corresponds to an Atom/RSS entry. 
     
    9797    implements(IFeature) 
    9898 
    99     __typename__ = 'AtomFeature' 
     99    __typename__ = 'GeoRSSFeature' 
    100100    __schema__ = PropertyTypeCollection([ 
    101101                    StringProperty('id'), 
     
    108108 
    109109 
    110 class AtomFeatureSource: 
     110class GeoRSSFeatureSource: 
    111111 
    112112    """Implements IFeatureSource. 
     
    119119        """Initialize""" 
    120120        self.document = document 
    121         self._featuretype = AtomFeature 
     121        self._featuretype = GeoRSSFeature 
    122122        #self._bbox = None 
    123123        #self._maxfeatures = -1 
     
    128128    def iterfeatures(self): 
    129129        for entry in self.document.entries: 
    130             yield atom_feature(entry) 
     130            yield georss_feature(entry) 
    131131 
    132132    __call__ = iterfeatures 
  • PCL/trunk/PCL-Core/GeoRSSFeatures.txt

    r605 r606  
    2121Imports 
    2222 
    23     >>> from cartography.data.atom import atom_source, atom_feature 
     23    >>> from cartography.data.georss import georss_source, georss_feature 
    2424 
    2525Source 
    2626 
    27     >>> source = atom_source(file("../fixtures/atom-simple.xml")) 
     27    >>> source = georss_source(file("../fixtures/atom-simple.xml")) 
    2828 
    2929Features 
    3030 
    31     >>> fx = atom_feature(source.document.entries[0]) 
     31    >>> fx = georss_feature(source.document.entries[0]) 
    3232    >>> fx.properties.title 
    3333    u'Entry 1' 
     
    3737    20.0 
    3838 
    39     >>> fx = atom_feature(source.document.entries[1]) 
     39    >>> fx = georss_feature(source.document.entries[1]) 
    4040    >>> fx.properties.title 
    4141    u'Entry 2' 
     
    4949    -110.0 
    5050 
    51     >>> fx = atom_feature(source.document.entries[2]) 
     51    >>> fx = georss_feature(source.document.entries[2]) 
    5252    >>> fx.properties.title 
    5353    u'Entry 3' 
     
    6363    -100.0 
    6464 
    65     >>> fx = atom_feature(source.document.entries[3]) 
     65    >>> fx = georss_feature(source.document.entries[3]) 
    6666    >>> fx.properties.title 
    6767    u'Entry 4'