Changeset 510
- Timestamp:
- 10/17/06 14:02:57
- Files:
-
- OWSLib/trunk/owslib/interfaces.py (modified) (3 diffs)
- OWSLib/trunk/owslib/wms.py (modified) (2 diffs)
- OWSLib/trunk/tests/JPLCapabilities.txt (moved) (moved from OWSLib/trunk/tests/WMSCapabilities.txt) (3 diffs)
- OWSLib/trunk/tests/TelaCapabilities.txt (added)
- OWSLib/trunk/tests/Telascience.xml (added)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
OWSLib/trunk/owslib/interfaces.py
r509 r510 63 63 operations : list 64 64 List of operation descriptors. 65 exceptions : list 66 List of exception formats. 65 67 """ 66 68 … … 72 74 name : string 73 75 "GetCapabilities", for example. 76 formatOptions : list 77 List of content types. 74 78 methods : dict 75 79 Array of method descriptors, keyed to HTTP verbs. … … 111 115 crsOptions : list 112 116 List of available coordinate/spatial reference systems. 117 styles : list 118 List of style dicts. 113 119 """ 114 120 OWSLib/trunk/owslib/wms.py
r509 r510 97 97 98 98 # operations [] 99 self.operations = [] 100 for elem in self._root.findall('Capability/Request/*'): 101 self.operations.append(OperationMetadata(elem)) 102 103 # exceptions 104 self.exceptions = [f.text for f \ 105 in self._root.findall('Capability/Exception/Format')] 99 106 100 107 # contents: our assumption is that services use a top-level layer … … 167 174 # crs options 168 175 self.crsOptions = [srs.text for srs in parent.findall('SRS')] 169 176 177 # styles 178 self.styles = dict([(s.find('Name').text, {'title': s.find('Title').text}) for s in elem.findall('Style')]) 179 180 class OperationMetadata: 181 """Abstraction for WMS metadata. 182 183 Implements IMetadata. 184 """ 185 def __init__(self, elem): 186 """.""" 187 self.name = elem.tag 188 # formatOptions 189 self.formatOptions = [f.text for f in elem.findall('Format')] 190 methods = [] 191 for verb in elem.findall('DCPType/HTTP/*'): 192 url = verb.find('OnlineResource').attrib['{http://www.w3.org/1999/xlink}href'] 193 methods.append((verb.tag, {'url': url})) 194 self.methods = dict(methods) 170 195 171 196 class WMSCapabilitiesInfoset: OWSLib/trunk/tests/JPLCapabilities.txt
r509 r510 1 # =============================================================================2 # Python Cartographic Library (C) 2006 Sean C. Gillies3 #4 # This program is free software; you can redistribute it and/or modify it5 # under the terms of the GNU General Public License as published by the Free6 # Software Foundation; either version 2 of the License, or (at your option)7 # any later version.8 #9 # This program is distributed in the hope that it will be useful, but WITHOUT10 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS11 # FOR A PARTICULAR PURPOSE. See the GNU General Public License for more12 # details.13 #14 # You should have received a copy of the GNU General Public License along with15 # this program; if not, write to the Free Software Foundation, Inc., 59 Temple16 # Place, Suite 330, Boston, MA 02111-1307 USA17 #18 # Contact email: sgillies@frii.com19 # ===========================================================================20 1 21 2 Imports … … 52 33 >>> wms.capabilities.getContentByName('global_mosaic').crsOptions 53 34 ['EPSG:4326', 'AUTO:42003'] 54 35 >>> wms.capabilities.getContentByName('global_mosaic').styles 36 {'pseudo_bright': {'title': 'Pseudo-color image (Uses IR and Visual bands, 542 mapping), gamma 1.5'}, 'pseudo': {'title': '(default) Pseudo-color image, pan sharpened (Uses IR and Visual bands, 542 mapping), gamma 1.5'}, 'visual': {'title': 'Real-color image, pan sharpened (Uses the visual bands, 321 mapping), gamma 1.5'}, 'pseudo_low': {'title': 'Pseudo-color image, pan sharpened (Uses IR and Visual bands, 542 mapping)'}, 'visual_low': {'title': 'Real-color image, pan sharpened (Uses the visual bands, 321 mapping)'}, 'visual_bright': {'title': 'Real-color image (Uses the visual bands, 321 mapping), gamma 1.5'}} 37 55 38 Expect a KeyError for invalid names 56 39 … … 60 43 KeyError: 'No content named utterly bogus' 61 44 45 Test operations 46 47 >>> [op.name for op in wms.capabilities.operations] 48 ['GetCapabilities', 'GetMap'] 49 >>> wms.capabilities.getOperationByName('GetMap').methods 50 {'Get': {'url': 'http://wms.jpl.nasa.gov/wms.cgi?'}} 51 >>> wms.capabilities.getOperationByName('GetMap').formatOptions 52 ['image/jpeg', 'image/png', 'image/geotiff', 'image/tiff'] 53 54 Test exceptions 55 56 >>> wms.capabilities.exceptions 57 ['application/vnd.ogc.se_xml'] 58
