Changeset 3573 for TI05-delivery/ows_framework
- Timestamp:
- 10/03/08 16:40:33 (13 years ago)
- Location:
- TI05-delivery/ows_framework/branches/ows_framework-refactor/ows_common/ows_common
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
TI05-delivery/ows_framework/branches/ows_framework-refactor/ows_common/ows_common/pylons/templates/wms_capabilities_1_1_1.xml
r3571 r3573 58 58 <!-- TODO DataURL from metadata --> 59 59 <!-- TODO MetadataURL from metadata --> 60 <!-- TODO Style --> 60 61 <!--!NOTE: this is an ad-hoc implementation not using the ows_common.model classes 62 TODO: fixme --> 63 <Style> 64 <Name>default</Name> 65 <Title>Default</Title> 66 <LegendURL width="${ds.legendSize[0]}" height="${ds.legendSize[1]}"> 67 <Format py:for="f in ds.legendFormats" py:content="f"/> 68 <OnlineResource xmlns:xlink="http://www.w3.org/1999/xlink" xlink:type="simple" 69 xlink:href="${h.url_for(qualified=True, action='index')}?request=GetLegend&layers=${ds.identifier}"/> 70 </LegendURL> 71 </Style> 72 61 73 <!-- TODO ScaleHint --> 62 74 -
TI05-delivery/ows_framework/branches/ows_framework-refactor/ows_common/ows_common/pylons/wms_controller.py
r3571 r3573 44 44 service = 'WMS' 45 45 owsOperations = ows_controller.OWSController.owsOperations + ['GetMap', 'GetContext', 46 'GetLegend', 46 47 'GetInfo'] 47 48 validVersions = ['1.1.1'] … … 75 76 """ 76 77 ows_controller.addOperation('GetMap', formats=self._pilImageFormats.keys()) 78 ows_controller.addOperation('GetContext') 79 ows_controller.addOperation('GetLegend', 80 formats=self._pilImageFormats.keys()) 77 81 ows_controller.addOperation('GetInfo') 78 82 log.debug('Loading capabilities contents') … … 101 105 dimensions=dims) 102 106 107 # Stuff that should go in the capabilities tree eventually 108 ds.legendSize = layer.legendSize 109 ds.legendFormats = self._pilImageFormats.keys() 110 103 111 c.capabilities.contents.datasetSummaries.append(ds) 104 112 113 114 115 def _getLayerParam(self): 116 """ 117 Retrieve the layers parameter enforcing the rule of only 118 selecting one layer. 119 120 """ 121 layerName = self.getOwsParam('layers') 122 123 # Select the first layer if several are requested. 124 # This plays nicer with mapClient. 125 if ',' in layerName: 126 layerName = layerName.split(',')[0] 127 #raise InvalidParameterValue( 128 # 'Multi-layer GetMap requests are not supported', 'layers') 129 try: 130 layerObj = self.layers[layerName] 131 except KeyError: 132 raise InvalidParameterValue('Layer %s not found' % layerName, 'layers') 133 134 return layerName, layerObj 135 136 def _getFormatParam(self): 137 format = self.getOwsParam('format', default='image/png') 138 if format not in self._pilImageFormats: 139 raise InvalidParameterValue( 140 'Format %s not supported' % format, 'format') 141 142 return format 143 105 144 #------------------------------------------------------------------------- 106 145 # OWS Operation methods … … 118 157 119 158 # Layer handling 120 layerName = self.getOwsParam('layers') 121 if ',' in layerName: 122 raise InvalidParameterValue( 123 'Multi-layer GetMap requests are not supported', 'layers') 124 try: 125 layerObj = self.layers[layerName] 126 except KeyError: 127 raise InvalidParameterValue('Layer %s not found' % layerName, 'layers') 128 159 layerName, layerObj = self._getLayerParam() 129 160 130 161 # Coordinate parameters … … 239 270 return t.generate(c=c).render() 240 271 272 def GetLegend(self): 273 """ 274 Return an image of the legend. 275 276 """ 277 # Parameters 278 layerName, layerObj = self._getLayerParam() 279 format = self._getFormatParam() 280 281 img = layerObj.getLegendImage() 282 283 buf = StringIO() 284 img.save(buf, self._pilImageFormats[format]) 285 286 response.headers['Content-Type'] = format 287 response.write(buf.getvalue()) 288 241 289 242 290 def GetInfo(self): -
TI05-delivery/ows_framework/branches/ows_framework-refactor/ows_common/ows_common/service/wms_iface.py
r3554 r3573 40 40 @ivar units: A string describing the units. 41 41 @ivar crss: A sequence of SRS/CRSs supported by this layer. 42 @ivar legendSize: (width, height) in pixels of legend. 42 43 43 44 @todo: Do we need minValue/maxValue? … … 82 83 raise NotImplementedError 83 84 85 def getLegendImage(self, orientation='vertical', renderOpts={}): 86 """ 87 Create an image of the colourbar for this layer. 88 89 @param orientation: Either 'vertical' or 'horizontal' 90 @return: A PIL image 91 92 """ 93 raise NotImplementedError 84 94 85 95 class IDimension(object):
Note: See TracChangeset
for help on using the changeset viewer.