Changeset 3696 for TI05-delivery/ows_framework
- Timestamp:
- 28/03/08 11:11:21 (12 years ago)
- Location:
- TI05-delivery/ows_framework/branches/ows_framework-refactor/ows_common/ows_common
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
TI05-delivery/ows_framework/branches/ows_framework-refactor/ows_common/ows_common/model/wms.py
r3553 r3696 35 35 @ivar maxScaleDenominator 36 36 @type maxScaleDenominator: None or double 37 @ivar queryable 38 @type queryable: Boolean 37 39 38 40 """ 39 41 def __init__(self, CRSs=[], styles=[''], dimensions={}, attribution=None, authorityURLs=[], 40 42 dataURLs=[], featureListURLs=[], 41 minScaleDenominator=None, maxScaleDenominator=None, **kw): 43 minScaleDenominator=None, maxScaleDenominator=None, 44 queryable=False, **kw): 42 45 super(WmsDatasetSummary, self).__init__(**kw) 43 46 … … 51 54 self.minScaleDenominator = minScaleDenominator 52 55 self.maxScaleDenominator = maxScaleDenominator 53 56 self.queryable = queryable 54 57 55 58 class Style(object): -
TI05-delivery/ows_framework/branches/ows_framework-refactor/ows_common/ows_common/pylons/templates/wms_capabilities_1_1_1.xml
r3575 r3696 39 39 ?> 40 40 41 <Layer py:def="markupLayer(ds)" >41 <Layer py:def="markupLayer(ds)" queryable="${int(ds.queryable)}"> 42 42 <Name py:content="ds.identifier"/> 43 43 <Title py:content="ds.titles[0]"/> -
TI05-delivery/ows_framework/branches/ows_framework-refactor/ows_common/ows_common/pylons/templates/wms_capabilities_1_3_0.xml
r3688 r3696 38 38 ?> 39 39 40 <Layer py:def="markupLayer(ds)" >40 <Layer py:def="markupLayer(ds)" queryable="${int(ds.queryable)}"> 41 41 <Name py:content="ds.identifier"/> 42 42 <Title py:content="ds.titles[0]"/> -
TI05-delivery/ows_framework/branches/ows_framework-refactor/ows_common/ows_common/pylons/templates/wms_context_1_1_1.xml
r3571 r3696 19 19 <!--!TODO: Queriable if GetFeatureInfo is present --> 20 20 <Layer py:def="markupLayer(ds)" 21 queryable="false" hidden="false">21 queryable="${int(ds.queryable)}" hidden="false"> 22 22 <Server service="OGC:WMS" version="1.1.1"> 23 23 <OnlineResource xlink:type="simple" -
TI05-delivery/ows_framework/branches/ows_framework-refactor/ows_common/ows_common/pylons/wms_controller.py
r3688 r3696 6 6 7 7 from cStringIO import StringIO 8 8 from sets import Set 9 9 from matplotlib.cm import get_cmap 10 10 from pylons import request, response, c … … 43 43 44 44 service = 'WMS' 45 owsOperations = ows_controller.OWSController.owsOperations + ['GetMap', 'GetContext', 46 'GetLegend', 47 'GetInfo'] 45 owsOperations = (ows_controller.OWSController.owsOperations + 46 ['GetMap', 'GetContext', 'GetLegend', 'GetFeatureInfo', 'GetInfo']) 48 47 validVersions = ['1.1.1', '1.3.0'] 49 48 … … 87 86 formats=['image/png']) 88 87 ows_controller.addOperation('GetInfo') 88 89 featureInfoFormats = Set() 90 89 91 log.debug('Loading capabilities contents') 90 92 c.capabilities.contents = Contents() … … 106 108 possibleValues= 107 109 PossibleValues.fromAllowedValues(dim.extent)) 110 # Does the layer implement GetFeatureInfo? 111 if layer.featureInfoFormats: 112 queryable = True 113 featureInfoFormats.union_update(layer.featureInfoFormats) 114 else: 115 queryable = False 116 108 117 # Create the ows_common object 109 118 ds = WmsDatasetSummary(identifier=layerName, … … 113 122 boundingBoxes=bboxObjs, 114 123 abstracts=[layer.abstract], 115 dimensions=dims) 124 dimensions=dims, 125 queryable=queryable) 116 126 117 127 # Stuff that should go in the capabilities tree eventually … … 121 131 c.capabilities.contents.datasetSummaries.append(ds) 122 132 123 124 125 def _getLayerParam(self): 133 # Add this operation here after we have found all formats 134 ows_controller.addOperation('GetFeatureInfo', 135 formats = list(featureInfoFormats)) 136 137 138 def _getLayerParam(self, paramName='layers'): 126 139 """ 127 140 Retrieve the layers parameter enforcing the rule of only 128 141 selecting one layer. 129 142 130 """ 131 layerName = self.getOwsParam('layers') 143 @param paramName: Overrides the query string parameter name to 144 look for. This is usefull for implementing GetFeatureInfo. 145 146 """ 147 layerName = self.getOwsParam(paramName) 132 148 133 149 # Select the first layer if several are requested. … … 140 156 layerObj = self.layers[layerName] 141 157 except KeyError: 142 raise InvalidParameterValue('Layer %s not found' % layerName, 'layers') 158 raise InvalidParameterValue('Layer %s not found' % layerName, 159 paramName) 143 160 144 161 return layerName, layerObj … … 151 168 152 169 return format 153 170 154 171 #------------------------------------------------------------------------- 155 172 # OWS Operation methods … … 285 302 return t.generate(c=c).render() 286 303 304 def GetFeatureInfo(self): 305 layerName, layerObj = self._getLayerParam('query_layers') 306 format = self.getOwsParam('info_format') 307 if format not in layerObj.featureInfoFormats: 308 raise InvalidParameterValue( 309 'Layer %s does not support GetFeatureInfo in format %s' % 310 (layerName, format), 'info_format') 311 312 # Coordinate parameters 313 bbox = tuple(float(x) for x in self.getOwsParam('bbox').split(',')) 314 width = int(self.getOwsParam('width')) 315 height = int(self.getOwsParam('height')) 316 317 if version == '1.1.1': 318 srs = self.getOwsParam('srs') 319 else: 320 srs = self.getOwsParam('crs') 321 322 if srs not in layerObj.crss: 323 raise InvalidParameterValue('Layer %s does not support SRS %s' % 324 (layerName, srs)) 325 326 # Dimension handling 327 dimValues = {} 328 for dimName, dim in layerObj.dimensions.items(): 329 defaultValue = dim.extent[0] 330 dimValues[dimName] = self.getOwsParam(dimName, default=defaultValue) 331 # Get pixel location 332 i = self.getOwsParam('i') 333 j = self.getOwsParam('j') 334 335 # Translate to geo-coordinates 336 x, y = bbox_util.pixelToGeo(i, j, bbox, width, height) 337 338 # Call the layer 339 response.headers['Content-Type'] = format 340 response.write(layerObj.getFeatureInfo(format, srs, (x, y), dimValues)) 341 287 342 def GetLegend(self): 288 343 """ -
TI05-delivery/ows_framework/branches/ows_framework-refactor/ows_common/ows_common/service/wms_iface.py
r3688 r3696 48 48 ILayerMapper supports the retrieval of sets of layers according to arbitary 49 49 keyword/value pairs. 50 50 51 51 """ 52 52 def map(self, **kwargs): … … 60 60 """ 61 61 raise NotImplementedError 62 62 63 63 64 64 class ILayer(object): … … 74 74 @ivar legendSize: (width, height) in pixels of legend. 75 75 76 @ivar featureInfoFormats: A sequence of formats supported for the 77 self.getFeatureInfo method. If this is None or empty GetFeatureInfo 78 is not supported. 79 76 80 @todo: Do we need minValue/maxValue? 77 81 78 82 """ 79 83 title = abstract = dimensions = units = crss = wgs84BBox = NotImplemented 84 featureInfoFormats = NotImplemented 80 85 81 86 def getBBox(self, crs): … … 128 133 raise NotImplementedError 129 134 135 def getFeatureInfo(self, format, crs, point, dimValues): 136 """ 137 Return a response string descibing the feature at a given 138 point in a given CRS. 139 140 @param format: One of self.featureInfoFormats. Defines which 141 format the response will be in. 142 @param crs: One of self.crss 143 @param point: a tuple (x, y) in the supplied crs of the point 144 being selected. 145 @param dimValues: A mapping of dimension names to dimansion values. 146 @return: A string containing the response. 147 148 """ 149 raise NotImplementedError 150 151 130 152 class IDimension(object): 131 153 """
Note: See TracChangeset
for help on using the changeset viewer.