Changeset 509
- Timestamp:
- 10/17/06 12:49:59
- Files:
-
- OWSLib/trunk/owslib/interfaces.py (modified) (1 diff)
- OWSLib/trunk/owslib/wms.py (modified) (2 diffs)
- OWSLib/trunk/tests/WMSCapabilities.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
OWSLib/trunk/owslib/interfaces.py
r508 r509 109 109 boundingBoxWGS84 : 4-tuple 110 110 Four bounding values in WGS coordinates. 111 formatOptions : list112 List of available formats, each a string.113 111 crsOptions : list 114 112 List of available coordinate/spatial reference systems. OWSLib/trunk/owslib/wms.py
r508 r509 95 95 self.service = self._root.find('Service/Name').text 96 96 self.title = self._root.find('Service/Title').text 97 97 98 # operations [] 98 # contents [] 99 100 # contents: our assumption is that services use a top-level layer 101 # as a metadata organizer, nothing more. 99 102 self.contents = [] 103 top = self._root.find('Capability/Layer') 100 104 for elem in self._root.findall('Capability/Layer/Layer'): 101 self.contents.append(ContentMetadata(elem ))105 self.contents.append(ContentMetadata(elem, top)) 102 106 107 def getContentByName(self, name): 108 """Return a named content item.""" 109 for item in self.contents: 110 if item.name == name: 111 return item 112 raise KeyError, "No content named %s" % name 113 114 def getOperationByName(self, name): 115 """Return a named content item.""" 116 for item in self.operations: 117 if item.name == name: 118 return item 119 raise KeyError, "No operation named %s" % name 103 120 104 121 #def toXML(self): … … 116 133 """ 117 134 118 def __init__(self, elem ent):135 def __init__(self, elem, parent): 119 136 """.""" 120 self.name = element.find('Name').text 121 self.title = element.find('Title').text 122 123 137 self.name = elem.find('Name').text 138 self.title = elem.find('Title').text 139 # bboxes 140 self.boundingBox = None 141 b = elem.find('BoundingBox') 142 if b is not None: 143 self.boundingBox = (float(b.attrib['minx']),float(b.attrib['miny']), 144 float(b.attrib['maxx']), float(b.attrib['maxy']), 145 b.attrib['SRS']) 146 else: 147 b = parent.find('BoundingBox') 148 if b is not None: 149 self.boundingBox = ( 150 float(b.attrib['minx']), float(b.attrib['miny']), 151 float(b.attrib['maxx']), float(b.attrib['maxy']), 152 b.attrib['SRS']) 153 self.boundingBoxWGS84 = None 154 b = elem.find('LatLonBoundingBox') 155 if b is not None: 156 self.boundingBoxWGS84 = ( 157 float(b.attrib['minx']),float(b.attrib['miny']), 158 float(b.attrib['maxx']), float(b.attrib['maxy']), 159 ) 160 else: 161 b = parent.find('LatLonBoundingBox') 162 if b is not None: 163 self.boundingBoxWGS84 = ( 164 float(b.attrib['minx']), float(b.attrib['miny']), 165 float(b.attrib['maxx']), float(b.attrib['maxy']), 166 ) 167 # crs options 168 self.crsOptions = [srs.text for srs in parent.findall('SRS')] 169 170 124 171 class WMSCapabilitiesInfoset: 125 172 """High-level container for WMS Capabilities based on lxml.etree OWSLib/trunk/tests/WMSCapabilities.txt
r508 r509 36 36 'JPL Global Imagery Service' 37 37 38 Test available layers38 Test available content layers 39 39 40 40 >>> [layer.name for layer in wms.capabilities.contents] … … 43 43 ['WMS Global Mosaic, pan sharpened', 'WMS Global Mosaic, not pan sharpened', 'CONUS mosaic of 1990 MRLC dataset', 'SRTM reflectance magnitude, 30m', 'Daily composite of MODIS-TERRA 721 pseudocolor', 'Daily composite of MODIS-AQUA 721 pseudocolor', 'Daily composite of MODIS-TERRA images, NDVI processing', 'Daily composite of MODIS-AQUA images, NDVI processing', 'Daily composite of MODIS-TERRA images', 'Daily composite of MODIS-AQUA images', 'Blue Marble Next Generation, Global MODIS derived image', 'Blue Marble, Global MODIS derived image', 'SRTM derived global elevation, 3 arc-second, hue mapped', 'Global 1km elevation, seamless SRTM land elevation and ocean depth', 'SRTM derived global elevation, 3 arc-second', 'United States elevation, 30m', 'Digital Elevation Map of the United States, DTED dataset, 3 second resolution, grayscale', 'Digital Elevation Map of the United States, DTED dataset, 3 second resolution, hue mapped'] 44 44 45 45 Test single item accessor 46 47 >>> wms.capabilities.getContentByName('global_mosaic').title 48 'WMS Global Mosaic, pan sharpened' 49 >>> wms.capabilities.getContentByName('global_mosaic').boundingBox 50 >>> wms.capabilities.getContentByName('global_mosaic').boundingBoxWGS84 51 (-180.0, -60.0, 180.0, 84.0) 52 >>> wms.capabilities.getContentByName('global_mosaic').crsOptions 53 ['EPSG:4326', 'AUTO:42003'] 54 55 Expect a KeyError for invalid names 56 57 >>> wms.capabilities.getContentByName('utterly bogus').title 58 Traceback (most recent call last): 59 ... 60 KeyError: 'No content named utterly bogus' 61
