Changeset 687
- Timestamp:
- 03/15/07 16:04:42 (2 years ago)
- Files:
-
- PleiadesOpenLayers/trunk/browser/configure.zcml (modified) (1 diff)
- PleiadesOpenLayers/trunk/browser/feature.py (modified) (3 diffs)
- PleiadesOpenLayers/trunk/configure.zcml (modified) (1 diff)
- PleiadesOpenLayers/trunk/tests/MapFeature.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
PleiadesOpenLayers/trunk/browser/configure.zcml
r347 r687 23 23 /> 24 24 25 <browser:page 26 for="Products.PleiadesOpenLayers.interfaces.feature.IMapFeature" 27 name="js" 28 class=".feature.MapFeatureView" 29 attribute="toJS" 30 permission="zope.Public" 31 allowed_interface=".feature.IMapFeatureView" 32 /> 33 25 34 </configure> 26 35 PleiadesOpenLayers/trunk/browser/feature.py
r347 r687 34 34 from Products.Five import BrowserView 35 35 36 from Products.PleiadesGeocoder.interfaces import IGeoItemSimple 36 from Products.PleiadesGeocoder.interfaces import IGeoItemSimple \ 37 , IGeoCollectionSimple 37 38 38 39 … … 40 41 41 42 def toJSON(): 43 """Return context as JSON data.""" 44 45 def toJS(): 42 46 """Return context as JSON data.""" 43 47 … … 62 66 return simplejson.dumps(m) 63 67 68 def toJS(self): 69 collection = IGeoCollectionSimple(self.context) 70 infos = [] 71 for item in collection.geoItems(): 72 info = item.getInfo() 73 m = {'geometryType': item.getGeometryType(), 74 'spatialCoordinates': item.getSpatialCoordinates(), 75 'srs': item.getSRS(), 76 'id': info['id'], 77 'title': info['title']} 78 try: 79 m['center'] = item.getSpatialCoordinates()[0] 80 except: 81 m['center'] = None 82 infos.append(m) 83 return simplejson.dumps({'features': infos}) 64 84 PleiadesOpenLayers/trunk/configure.zcml
r352 r687 15 15 16 16 <five:implements 17 class="Products.ATContentTypes.content.folder.ATFolder" 18 interface=".interfaces.feature.IMapFeature" 19 /> 20 21 <five:implements 22 class="Products.ATContentTypes.content.topic.ATTopic" 23 interface=".interfaces.feature.IMapFeature" 24 /> 25 26 <five:implements 17 27 class=".content.MapContext.MapContext" 18 28 interface=".interfaces.ows.IMapContext" PleiadesOpenLayers/trunk/tests/MapFeature.txt
r352 r687 18 18 Add a doc and georeference it 19 19 20 >>> id = folder.invokeFactory('Folder', id='docs') 21 >>> folder = folder.docs 20 22 >>> id = folder.invokeFactory('Document', id='aaa') 21 23 >>> document = getattr(folder, id) … … 47 49 '{"center": [37.71446, 28.72886, 0.0], "title": "AAA", "spatialCoordinates": [[37.71446, 28.72886, 0.0]], "srs": "EPSG:4326", "geometryType": "point", "id": "aaa"}' 48 50 51 >>> folder_url = folder.absolute_url() 52 >>> browser.open("%s/js" % folder_url) 53 >>> browser.contents 54 '{"features": [{"center": [37.71446, 28.72886, 0.0], "title": "AAA", "spatialCoordinates": [[37.71446, 28.72886, 0.0]], "srs": "EPSG:4326", "geometryType": "point", "id": "aaa"}]}' 55
