Changeset 647 for PCL/branches/PCL-newfeatureapi/PCL-GeoRSS
- Timestamp:
- 03/24/07 22:13:41 (3 years ago)
- Location:
- PCL/branches/PCL-newfeatureapi/PCL-GeoRSS
- Files:
-
- 2 modified
-
cartography/data/georss.py (modified) (3 diffs)
-
tests/Features.txt (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
PCL/branches/PCL-newfeatureapi/PCL-GeoRSS/cartography/data/georss.py
r645 r647 228 228 self._document = feedparser.parse(s.read()) 229 229 230 def featuretype(self, typename=' feed'):230 def featuretype(self, typename='entries'): 231 231 if not self._featuretype: 232 232 if not self._document: … … 234 234 self._featuretype = type("%sFeature" % str(self._document.feed.id), 235 235 (GeoRSSFeature,), 236 dict(__typename__=' feed',236 dict(__typename__='entries', 237 237 __srs__ = SpatialReference(epsg=4326), 238 238 _storage = self, … … 251 251 def typenames(self): 252 252 """Returns the typenames available in this store.""" 253 return [' feed']253 return ['entries'] 254 254 255 255 -
PCL/branches/PCL-newfeatureapi/PCL-GeoRSS/tests/Features.txt
r645 r647 12 12 >>> store = GeoRSSFeatureStore("file://%s" % path) 13 13 >>> store.typenames() 14 [' feed']14 ['entries'] 15 15 16 >>> Feed = store.featuretype('feed')17 >>> print Feed16 >>> Entry = store.featuretype('entries') 17 >>> print Entry 18 18 <class 'cartography.data.georss.http://gispython.org/testingFeature'> 19 >>> Feed.features.count19 >>> Entry.features.count 20 20 4 21 21 22 >>> features = [f for f in Feed.features.all()]22 >>> features = [f for f in Entry.features.all()] 23 23 >>> len(features) 24 24 4 … … 31 31 >>> store = GeoRSSFeatureStore('http://pleiades.stoa.org/places/archaic.atom') 32 32 >>> store.typenames() 33 [' feed']33 ['entries'] 34 34 35 >>> Feed = store.featuretype('feed')36 >>> print Feed35 >>> Entry = store.featuretype('entries') 36 >>> print Entry 37 37 <class 'cartography.data.georss.http://pleiades.stoa.org/places/archaicFeature'> 38 >>> Feed.features.count38 >>> Entry.features.count 39 39 3 40 40 41 >>> features = [f for f in Feed.features.all()]41 >>> features = [f for f in Entry.features.all()] 42 42 >>> len(features) 43 43 3 … … 48 48 ------------------------- 49 49 50 >>> store = GeoRSSFeatureStore('http://pleiades.stoa.org/places/settlement.atom') 51 >>> Feed = store.featuretype('feed') 52 >>> Feed.features.count 50 >>> url = 'http://pleiades.stoa.org/places/settlement.atom' 51 >>> store = GeoRSSFeatureStore(url) 52 >>> Entry = store.featuretype('entries') 53 >>> Entry.features.count 53 54 230 54 55 55 56 Filter for intersection with a (29dE, 36dN, 30dE, 37dN) bounding box 56 57 57 >>> features = [f for f in Feed.features.filter(bbox=(29.0,36.0,30.0,37.0))] 58 >>> features = [f for f in Entry.features.filter( 59 ... bbox=(29.0, 36.0, 30.0, 37.0) 60 ... ) 61 ... ] 58 62 >>> len(features) 59 63 62 60 >>> print features[0].info() 61 {'srs': 'None', 'properties': {'updated': u'', 'summary': u'An ancient settlement, attested during the Classical, Hellenistic (Roman Republic), Roman and Late Antique periods (modern location: Ka\u015f). It was known in antiquity by the names: Antiphellos and Habesos.', 'tags': [], 'title': u'Antiphellos/Habesos'}, 'id': 'http://pleiades.stoa.org/places/638749', 'bounds': [29.637, 36.193199999999997, 29.637, 36.193199999999997]} 64 >>> from pprint import pprint 65 >>> pprint(features[0].info()) 66 {'bounds': [29.637, 36.193199999999997, 29.637, 36.193199999999997], 67 'id': 'http://pleiades.stoa.org/places/638749', 68 'properties': {'summary': u'An ancient settlement, attested during the Classical, Hellenistic (Roman Republic), Roman and Late Antique periods (modern location: Ka\u015f). It was known in antiquity by the names: Antiphellos and Habesos.', 69 'tags': [], 70 'title': u'Antiphellos/Habesos', 71 'updated': u''}, 72 'srs': 'None'} 73 >>> f = features[0] 74 >>> f.id 75 'http://pleiades.stoa.org/places/638749' 76 >>> f.properties.title 77 u'Antiphellos/Habesos' 78 >>> f.properties.the_geom.toWKT() 79 'POINT (29.6370000000000005 36.1931999999999974)' 80 >>> type(f.context) 81 <class 'feedparser.FeedParserDict'> 62 82 63 83 With property equals filter … … 66 86 >>> path = os.path.abspath('../fixtures/atom-tagged.xml') 67 87 >>> store = GeoRSSFeatureStore("file://%s" % path) 68 >>> Feed = store.featuretype('feed')69 >>> Feed.features.count88 >>> Entry = store.featuretype('entries') 89 >>> Entry.features.count 70 90 31 71 91 72 >>> features = [f for f in Feed.features.filter(properties="'web' in f.tags")]92 >>> features = [f for f in Entry.features.filter(properties="'web' in f.tags")] 73 93 >>> len(features) 74 94 12 75 95 >>> print features[0].info() 76 96 {'srs': 'None', 'properties': {'updated': u'2007-03-23T08:28:33-06:00', 'summary': u'Sam Ruby finds GeoRSS and finds it a bit confusing. My blog entries feed validates perfectly,\nunlike the slashgeo feed Google references.', 'tags': [u'web'], 'title': u'GeoRSS and Validation'}, 'id': 'http://zcologia.com/news/entries/412', 'bounds': [-105.09583000000001, 40.58699, -105.09583000000001, 40.58699]} 97 >>> f = features[0] 98 >>> f.id 99 'http://zcologia.com/news/entries/412' 100 >>> f.properties.title 101 u'GeoRSS and Validation' 102 >>> f.properties.tags 103 [u'web'] 104 >>> f.properties.the_geom.toWKT() 105 'POINT (-105.0958300000000065 40.5869900000000001)' 106 >>> type(f.context) 107 <class 'feedparser.FeedParserDict'> 108 >>> f.context.tags 109 [{'term': u'web', 'scheme': u'http://zcologia.com/news/categories/', 'label': u'Web'}] 77 110
