Changeset 1068
- Timestamp:
- 04/02/08 05:15:42
- Files:
-
- OWSLib/branches/wcstemp/owslib/wms.py (modified) (2 diffs)
- OWSLib/branches/wcstemp/tests/TelaCapabilities.txt (moved) (moved from OWSLib/branches/wcstemp/tests/oldtests/TelaCapabilities.txt) (3 diffs)
- OWSLib/branches/wcstemp/tests/Telascience.xml (moved) (moved from OWSLib/branches/wcstemp/tests/oldtests/Telascience.xml)
- OWSLib/branches/wcstemp/tests/wms_JPLCapabilities.txt (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
OWSLib/branches/wcstemp/owslib/wms.py
r1042 r1068 209 209 self.abstract = None 210 210 self.keywords = [f.text for f in self._root.findall('KeywordList/Keyword')] 211 self.accessconstraints = self._root.find('AccessConstraints').text 212 self.fees = self._root.find('Fees').text 211 accessconstraints=self._root.find('AccessConstraints') 212 if accessconstraints is not None: 213 self.accessconstraints = accessconstraints.text 214 fees = self._root.find('Fees') 215 if fees is not None: 216 self.fees = fees.text 213 217 214 218 class ServiceProvider(object): … … 218 222 self.name=self._root.find('ContactInformation/ContactPersonPrimary/ContactOrganization').text 219 223 self.url=self._root.find('OnlineResource').attrib.get('{http://www.w3.org/1999/xlink}href', '') 220 self.contact=self._root.find('ContactInformation/ContactElectronicMailAddress').text 221 224 #contact metadata 225 contact = self._root.find('ContactInformation') 226 ## sometimes there is a contact block that is empty, so make 227 ## sure there are children to parse 228 if contact is not None and contact.getchildren(): 229 self.contact = ContactMetadata(contact) 230 else: 231 self.contact = None 232 222 233 class ContentMetadata: 223 234 """ OWSLib/branches/wcstemp/tests/TelaCapabilities.txt
r1061 r1068 12 12 Test capabilities 13 13 14 >>> wms. capabilities.service14 >>> wms.identification.type 15 15 'OGC:WMS' 16 16 17 >>> wms. capabilities.title17 >>> wms.identification.title 18 18 'BM' 19 19 20 >>> wms. capabilities.abstract20 >>> wms.identification.abstract 21 21 'Blue Marble 200409' 22 22 23 >>> wms. capabilities.link23 >>> wms.provider.url 24 24 'http://wms.telascience.org/cgi-bin/ngBM_wms?' 25 25 26 >>> wms. capabilities.keywords26 >>> wms.identification.keywords 27 27 [] 28 28 29 >>> p = wms. capabilities.provider29 >>> p = wms.provider.contact 30 30 >>> p.name 31 31 'Norman Vine' … … 35 35 Test available content layers 36 36 37 >>> [layer.name for layer in wms.capabilities.contents] 38 ['world.topo.bathy.200409', 'USGS_1ft_San_Diego'] 37 >>> wms.contents.keys() 38 ['USGS_1ft_San_Diego', 'world.topo.bathy.200409', 'ngBM'] 39 39 40 40 >>> [layer.title for layer in wms.capabilities.contents] 41 ['world.topo.bathy.200409', 'USGS 1ft San Diego'] 41 >>> [wms[layer].title for layer in wms.contents] 42 ['USGS 1ft San Diego', 'world.topo.bathy.200409', 'BM'] 43 42 44 43 45 Test single item accessor 44 46 45 >>> wms .capabilities.getContentByName('world.topo.bathy.200409').title47 >>> wms['world.topo.bathy.200409'].title 46 48 'world.topo.bathy.200409' 47 49 48 >>> wms .capabilities.getContentByName('world.topo.bathy.200409').boundingBox50 >>> wms['world.topo.bathy.200409'].boundingBox 49 51 (-180.0, -90.0, 180.0, 90.0, 'EPSG:4326') 50 52 51 >>> wms .capabilities.getContentByName('world.topo.bathy.200409').boundingBoxWGS8453 >>> wms['world.topo.bathy.200409'].boundingBoxWGS84 52 54 (-180.0, -90.0, 180.0, 90.0) 53 55 54 >>> wms .capabilities.getContentByName('world.topo.bathy.200409').crsOptions55 [' EPSG:4326']56 >>> wms['world.topo.bathy.200409'].crsOptions 57 ['init=epsg:4326'] 56 58 57 >>> wms .capabilities.getContentByName('world.topo.bathy.200409').styles59 >>> wms['world.topo.bathy.200409'].styles 58 60 {} 59 61 60 62 Expect a KeyError for invalid names 61 63 62 >>> wms .capabilities.getContentByName('utterly bogus').title64 >>> wms['utterly bogus'].title 63 65 Traceback (most recent call last): 64 66 ... … … 67 69 Test operations 68 70 69 >>> [op.name for op in wms. capabilities.operations]71 >>> [op.name for op in wms.operations] 70 72 ['GetCapabilities', 'GetMap', 'GetFeatureInfo', 'DescribeLayer', 'GetLegendGraphic'] 71 73 72 >>> wms. capabilities.getOperationByName('GetMap').methods74 >>> wms.getOperationByName('GetMap').methods 73 75 {'Post': {'url': 'http://wms.telascience.org/cgi-bin/ngBM_wms?'}, 'Get': {'url': 'http://wms.telascience.org/cgi-bin/ngBM_wms?'}} 74 76 75 >>> wms. capabilities.getOperationByName('GetMap').formatOptions77 >>> wms.getOperationByName('GetMap').formatOptions 76 78 ['image/gif', 'image/png', 'image/jpeg', 'image/wbmp', 'image/tiff', 'image/png; mode=24bit'] 77 79 78 80 Test exceptions 79 81 80 >>> wms. capabilities.exceptions82 >>> wms.exceptions 81 83 ['application/vnd.ogc.se_xml', 'application/vnd.ogc.se_inimage', 'application/vnd.ogc.se_blank'] 82 84 OWSLib/branches/wcstemp/tests/wms_JPLCapabilities.txt
r1042 r1068 31 31 >>> wms.provider.url 32 32 'http://OnEarth.jpl.nasa.gov/index.html' 33 >>> wms.provider.contact 33 34 Check contact info (some of it is missing) 35 >>> wms.provider.contact.name 36 'Lucian Plesea' 37 >>> wms.provider.contact.email 34 38 'lucian.plesea@jpl.nasa.gov' 39 >>> wms.provider.contact.address 40 >>> wms.provider.contact.city 41 >>> wms.provider.contact.country 42 >>> wms.provider.contact.region 43 >>> wms.provider.contact.postcode 44 >>> wms.provider.contact.organization 45 'JPL' 46 >>> wms.provider.contact.position 35 47 36 48
