Changeset 1023

Show
Ignore:
Timestamp:
01/21/08 06:11:47
Author:
domlowe
Message:

reworking of wcs 1.1.0 client and wcs tests

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • OWSLib/branches/wcstemp/owslib/coverage/wcs100.py

    r1020 r1023  
    1010# ============================================================================= 
    1111 
    12 from wcsBase import WCSBase, WCSCapabilitiesReader, CoverageInfo, ServiceInfo, RereadableURL 
     12from wcsBase import WCSBase, WCSCapabilitiesReader, RereadableURL 
    1313from urllib import urlencode 
    1414from urllib2 import urlopen 
     
    3434                return self.__getattribute__('servicecontents')[name] 
    3535        #otherwise behave normally: 
    36         return self.__getattribute__(self,name) 
     36        return self.__getattribute__(name) 
    3737     
    3838    def __init__(self,url,xml): 
    3939        self.version='1.0.0' 
    4040        self.url = url    
    41         self._capabilities = None 
    4241        # initialize from saved capability document or access the server 
    4342        reader = WCSCapabilitiesReader(self.version) 
     
    4847 
    4948        #serviceIdentification metadata 
    50         self.serviceidentification =None 
    5149        subelem=self._capabilities.find(ns('Service/')) 
    5250        self.serviceidentification=ServiceIdenfication(subelem)                                
    5351                    
    5452        #serviceProvider metadata 
    55         self.serviceprovider =None 
    5653        subelem=self._capabilities.find(ns('Service/')+ns('responsibleParty')) 
    5754        self.serviceprovider=ServiceProvider(subelem)    
  • OWSLib/branches/wcstemp/owslib/coverage/wcs110.py

    r1020 r1023  
    1212##########NOTE: Does not conform to new interfaces yet ################# 
    1313 
    14 from wcsBase import WCSBase, WCSCapabilitiesReader, CoverageInfo, ServiceInfo, RereadableURL 
     14from wcsBase import WCSBase, WCSCapabilitiesReader, RereadableURL 
    1515from urllib import urlencode 
    1616from urllib2 import urlopen 
     
    2929    Implements IWebCoverageService. 
    3030    """ 
    31     def __init__(self, url, xml): 
     31     
     32    def __getitem__(self, name): 
     33        ''' check contents dictionary to allow dict like access to service layers''' 
     34        if 'servicecontents' in self.__dict__.keys(): 
     35            if name in self.__getattribute__('servicecontents').keys(): 
     36                return self.__getattribute__('servicecontents')[name] 
     37        #otherwise behave normally: 
     38        return self.__getattribute__(name) 
     39     
     40    def __init__(self,url,xml): 
    3241        self.version='1.1.0' 
    33         self.url = url         
    34         self._capabilities = None 
    35         # initialize from saved capability document 
     42        self.url = url    
     43        # initialize from saved capability document or access the server 
     44        reader = WCSCapabilitiesReader(self.version) 
    3645        if xml: 
    37             reader = WCSCapabilitiesReader(self.version) 
    38             self._capabilities = Capabilities(reader.readString(xml)) 
    39            
    40       
    41     def _getcapproperty(self): 
    42         if not self._capabilities:             
    43             reader = WCSCapabilitiesReader(self.version) 
    44             self._capabilities = Capabilities(reader.read(self.url)) 
    45         return self._capabilities 
    46     capabilities = property(_getcapproperty, None) 
    47      
    48  
    49     def getcapabilities(self): 
    50         """Request and return capabilities document from the WMS as a  
    51         file-like object.""" 
    52         reader = WCSCapabilitiesReader(self.version) 
    53         u = urlopen(reader.capabilities_url(self.url)) 
    54         # check for service exceptions, and return 
    55         if u.info().gettype() == 'application/vnd.ogc.se_xml': 
    56             se_xml = u.read() 
    57             se_tree = etree.fromstring(se_xml) 
    58             raise ServiceException, \ 
    59                 str(se_tree.find('ServiceException').text).strip() 
    60         return u 
    61  
    62     def _getSupportedCRS110(self,identifier): 
     46            self._capabilities = reader.readString(xml) 
     47        else: 
     48            self._capabilities = reader.read(self.url) 
     49             
     50        #build metadata objects: 
     51         
     52        #serviceIdentification metadata 
     53        elem=self._capabilities.find('{http://www.opengis.net/wcs/1.1/ows}ServiceIdentification') 
     54        self.serviceidentification=ServiceIdentification(elem) 
     55         
     56        #serviceProvider 
     57        elem=self._capabilities.find('{http://www.opengis.net/ows}ServiceProvider') 
     58        self.serviceprovider=ServiceProvider(elem) 
     59                 
     60        #serviceOperations 
     61        self.serviceoperations = [] 
     62        for elem in self._capabilities.findall('{http://www.opengis.net/wcs/1.1/ows}OperationsMetadata/{http://www.opengis.net/wcs/1.1/ows}Operation/'): 
     63            self.serviceoperations.append(Operation(elem)) 
     64         
     65        # exceptions - ***********TO DO ************* 
     66            self.exceptions = [f.text for f \ 
     67                in self._capabilities.findall('Capability/Exception/Format')] 
     68               
     69        # serviceContents: our assumption is that services use a top-level layer 
     70        # as a metadata organizer, nothing more. 
     71        self.servicecontents = {} 
     72        top = self._capabilities.find('{http://www.opengis.net/wcs/1.1}Contents/{http://www.opengis.net/wcs/1.1}CoverageSummary') 
     73        for elem in self._capabilities.findall('{http://www.opengis.net/wcs/1.1}Contents/{http://www.opengis.net/wcs/1.1}CoverageSummary/{http://www.opengis.net/wcs/1.1}CoverageSummary'):                     
     74            cm=ContentMetadata(elem, top) 
     75            #make the describeCoverage requests to populate the supported formats/crs attributes 
     76            cm.supportedFormats=self._getSupportedFormats(cm.id) 
     77            cm.supportedCRS=self._getSupportedCRS(cm.id) 
     78            cm.timelimits=self._getTimes(cm.id) 
     79            self.servicecontents[cm.id]=cm 
     80             
     81        if self.servicecontents=={}: 
     82            #non-hierarchical. 
     83            top=None 
     84            for elem in self._capabilities.findall('{http://www.opengis.net/wcs/1.1}Contents/{http://www.opengis.net/wcs/1.1}CoverageSummary'):      
     85                cm=ContentMetadata(elem, top) 
     86                #make the describeCoverage requests to populate the supported formats/crs attributes 
     87                cm.supportedFormats=self._getSupportedFormats(cm.id) 
     88                cm.supportedCRS=self._getSupportedCRS(cm.id) 
     89                cm.timelimits=self._getTimes(cm.id) 
     90                self.servicecontents[cm.id]=cm 
     91 
     92    def items(self): 
     93        '''supports dict-like items() access''' 
     94        items=[] 
     95        for item in self.servicecontents: 
     96            items.append((item,self.servicecontents[item])) 
     97        return items 
     98         
     99     
     100    def _getSupportedCRS(self,identifier): 
    63101                # version specific method 
    64102        crss=[] 
     
    68106       
    69107     
    70     def _getSupportedFormats110(self,identifier): #maybe can get this from the capabilites doc? 
     108    def _getSupportedFormats(self,identifier): #maybe can get this from the capabilites doc? 
    71109            # version specific method 
    72110        frmts=[] 
     
    82120         return timelimits 
    83121          
    84     def _buildGenericCoverages(self): 
    85         genericCoverageList=[] 
    86         for item in self.capabilities.contents: 
    87             ci = CoverageInfo(identifier=item.identifier, labelordescription=item.title, wgs84bbox=item.WGS84BoundingBox) 
    88             ci._supCRS=self._getSupportedCRS110 # version specific method 
    89             ci._supFormats=self._getSupportedFormats110 
    90             ci._times=self._getTimes 
    91             genericCoverageList.append(ci) 
    92         return genericCoverageList 
    93       
    94     def _buildGenericProviderInfo(self): 
    95         pn=self.capabilities.serviceProvider.providerName 
    96         cn=self.capabilities.serviceProvider.contactName 
    97         #cp= 
    98         #ad= 
    99         #ph= 
    100         #fx= 
    101         #em= 
    102          
    103         return ProviderInfo(providerName=pn, contactName=cn) 
    104      
    105     def _getaddressString(self): 
    106         #todo 
    107         address=self.capabilities.serviceProvider.serviceContact.contactInfo.address.deliveryPoint 
    108         return address 
    109          
    110     def _buildGenericServiceInfo(self): 
    111         ''' enables generic interface''' 
    112         _fees=self.capabilities.serviceIdentification.fees 
    113         _accessConstraints=self.capabilities.serviceIdentification.accessConstraints 
    114         _providerName=self.capabilities.serviceProvider.providerName                
    115         _contactName=self.capabilities.serviceProvider.serviceContact.individualName 
    116         _contactPosition=self.capabilities.serviceProvider.serviceContact.positionName 
    117         _addressString=self._getaddressString() 
    118         _phone=self.capabilities.serviceProvider.serviceContact.contactInfo.phone.voice 
    119         _fax=self.capabilities.serviceProvider.serviceContact.contactInfo.phone.facsimile 
    120         _email=self.capabilities.serviceProvider.serviceContact.contactInfo.address.email 
    121         return ServiceInfo(fees=_fees, accessConstraints=_accessConstraints ,providerName=_providerName, contactName=_contactName,contactPosition=_contactPosition, addressString=_addressString, phone=_phone, fax=_fax, email=_email) 
    122      
    123     def getData(self, directory='outputdir', outputfile='coverage.nc',  **kwargs): 
    124         u=self.getCoverageRequest(**kwargs) 
    125         #create the directory if it doesn't exist: 
    126         try: 
    127             os.mkdir(directory) 
    128         except OSError, e: 
    129             # Ignore directory exists error 
    130             if e.errno <> errno.EEXIST: 
    131                 raise           
    132         #elif wcs.version=='1.1.0': 
    133         #Could be multipart mime or XML Coverages document, need to use the decoder... 
    134         decoder=wcsdecoder.WCSDecoder(u) 
    135         x=decoder.getCoverages() 
    136         if type(x) is wcsdecoder.MpartMime: 
    137             filenames=x.unpackToDir(directory) 
    138             #print 'Files from 1.1.0 service written to %s directory'%(directory) 
    139         else: 
    140             filenames=x 
    141         return filenames 
    142      
    143      
    144     def getCoverageRequest(self, identifier=None, bbox=None, timeSequence=None, format = None, store=None, method='Get',**kwargs): 
     122    #def _getaddressString(self): 
     123        ##todo 
     124        #address=self.capabilities.serviceProvider.serviceContact.contactInfo.address.deliveryPoint 
     125        #return address 
     126         
     127    #def _buildGenericServiceInfo(self): 
     128        #''' enables generic interface''' 
     129        #_fees=self.capabilities.serviceIdentification.fees 
     130        #_accessConstraints=self.capabilities.serviceIdentification.accessConstraints 
     131        #_providerName=self.capabilities.serviceProvider.providerName                
     132        #_contactName=self.capabilities.serviceProvider.serviceContact.individualName 
     133        #_contactPosition=self.capabilities.serviceProvider.serviceContact.positionName 
     134        #_addressString=self._getaddressString() 
     135        #_phone=self.capabilities.serviceProvider.serviceContact.contactInfo.phone.voice 
     136        #_fax=self.capabilities.serviceProvider.serviceContact.contactInfo.phone.facsimile 
     137        #_email=self.capabilities.serviceProvider.serviceContact.contactInfo.address.email 
     138        #return ServiceInfo(fees=_fees, accessConstraints=_accessConstraints ,providerName=_providerName, contactName=_contactName,contactPosition=_contactPosition, addressString=_addressString, phone=_phone, fax=_fax, email=_email) 
     139     
     140    #repackage? 
     141    #def getData(self, directory='outputdir', outputfile='coverage.nc',  **kwargs): 
     142        #u=self.getCoverageRequest(**kwargs) 
     143        ##create the directory if it doesn't exist: 
     144        #try: 
     145            #os.mkdir(directory) 
     146        #except OSError, e: 
     147            ## Ignore directory exists error 
     148            #if e.errno <> errno.EEXIST: 
     149                #raise           
     150        ##elif wcs.version=='1.1.0': 
     151        ##Could be multipart mime or XML Coverages document, need to use the decoder... 
     152        #decoder=wcsdecoder.WCSDecoder(u) 
     153        #x=decoder.getCoverages() 
     154        #if type(x) is wcsdecoder.MpartMime: 
     155            #filenames=x.unpackToDir(directory) 
     156            ##print 'Files from 1.1.0 service written to %s directory'%(directory) 
     157        #else: 
     158            #filenames=x 
     159        #return filenames 
     160     
     161     
     162    def getCoverage(self, identifier=None, bbox=None, timeSequence=None, format = None, store=None, method='Get',**kwargs): 
    145163        """Request and return a coverage from the WCS as a file-like object 
    146164        note: additional **kwargs helps with multi-version implementation 
     
    154172        if store = true, returns a coverages XML file 
    155173        if store = false, returns a multipart mime 
    156          
    157  
    158174        """ 
    159         #use fully qualified namespace 
     175 
    160176        if method == 'Get': 
    161177            method='{http://www.opengis.net/wcs/1.1/ows}Get' 
    162         md = self.capabilities 
    163         base_url = md.getOperationByName('GetCoverage').methods[method]['url'] 
     178        base_url = self.__getOperationByName('GetCoverage').methods[method]['url'] 
    164179 
    165180 
     
    193208        return u 
    194209         
    195 class OperationMetadata(object): 
     210         
     211    def __getOperationByName(self, name): 
     212        """Return a named operation item.""" 
     213        for item in self.serviceoperations: 
     214            if item.name == name: 
     215                return item 
     216        raise KeyError, "No operation named %s" % name 
     217         
     218class Operation(object): 
    196219    """Abstraction for operation metadata     
    197220    Implements IOperationMetadata. 
     
    206229        self.methods = dict(methods) 
    207230 
    208 class ServiceIdentificationMetadata(object): 
     231class ServiceIdentification(object): 
    209232    """ Abstraction for ServiceIdentification Metadata  
    210233    implements IServiceIdentificationMetadata""" 
     
    215238        self.abstract = elem.find('{http://www.opengis.net/ows}Abstract').text 
    216239        self.keywords = [f.text for f in elem.findall('{http://www.opengis.net/ows}Keywords/{http://www.opengis.net/ows}Keyword')] 
    217         self.rights='' #TODO 
    218240        #self.link = elem.find('{http://www.opengis.net/wcs/1.1}Service/{http://www.opengis.net/wcs/1.1}OnlineResource').attrib.get('{http://www.w3.org/1999/xlink}href', '') 
    219241                
     
    223245        
    224246        
    225 class ServiceProviderMetadata(object): 
     247class ServiceProvider(object): 
    226248    """ Abstraction for ServiceProvider metadata  
    227249    implements IServiceProviderMetadata """ 
     
    229251        self.provider=elem.find('{http://www.opengis.net/ows}ProviderName').text 
    230252        self.contact=ServiceContact(elem.find('{http://www.opengis.net/ows}ServiceContact')) 
    231         self.url='' #URL for provider's web site (string) 
     253        self.contact='How to contact the service provider (string).' 
     254        self.url="URL for provider's web site (string)." 
    232255 
    233256class Address(object): 
     
    266289         
    267290   
    268 class CoverageSummary(object): 
     291class ContentMetadata(object): 
    269292    """Abstraction for WCS CoverageSummary 
    270293    """ 
     
    275298        self._elem=elem 
    276299        self._parent=parent 
    277         self.identifier=self._checkChildAndParent('{http://www.opengis.net/wcs/1.1}Identifier') 
     300        self.id=self._checkChildAndParent('{http://www.opengis.net/wcs/1.1}Identifier') 
    278301        self.description =self._checkChildAndParent('{http://www.opengis.net/wcs/1.1}Description')            
    279302        self.title =self._checkChildAndParent('{http://www.opengis.net/ows}Title') 
     
    293316             
    294317         
    295         self.WGS84BoundingBox = None 
     318        self.boundingBoxWGS84 = None 
    296319        b = elem.find('{http://www.opengis.net/ows}WGS84BoundingBox') 
    297320        if b is not None: 
    298321            lc=b.find('{http://www.opengis.net/ows}LowerCorner').text 
    299322            uc=b.find('{http://www.opengis.net/ows}UpperCorner').text 
    300             self.WGS84BoundingBox = ( 
     323            self.boundingBoxWGS84 = ( 
    301324                    float(lc.split()[0]),float(lc.split()[1]), 
    302325                    float(uc.split()[0]), float(uc.split()[1]), 
     
    335358                value = None 
    336359        return value   
    337              
    338  
    339 class Capabilities(object): 
    340     """Abstraction for WCS metadata. 
    341      
    342     Implements ICapabilities. 
    343     """ 
    344     def __init__(self, infoset): 
    345         """Initialize from an element tree root element.""" 
    346         self._root = infoset 
    347         #need to handle exception report 
    348         #print infoset.tag 
    349         #print infoset.text 
    350         #serviceIdentification 
    351         elem=self._root.find('{http://www.opengis.net/wcs/1.1/ows}ServiceIdentification') 
    352         self.serviceIdentification=ServiceIdentification(elem) 
    353          
    354         #serviceProvider 
    355         elem=self._root.find('{http://www.opengis.net/ows}ServiceProvider') 
    356         self.serviceProvider=ServiceProvider(elem) 
    357          
    358          
    359         # operations [] 
    360         self.operations = [] 
    361         for elem in self._root.findall('{http://www.opengis.net/wcs/1.1/ows}OperationsMetadata/{http://www.opengis.net/wcs/1.1/ows}Operation/'): 
    362             self.operations.append(OperationMetadata(elem)) 
    363          
    364         # exceptions - ***********TO DO ************* 
    365         self.exceptions = [f.text for f \ 
    366                 in self._root.findall('Capability/Exception/Format')] 
    367          
    368         # contents: our assumption is that services use a top-level layer 
    369         # as a metadata organizer, nothing more. 
    370         self.contents = [] 
    371         top = self._root.find('{http://www.opengis.net/wcs/1.1}Contents/{http://www.opengis.net/wcs/1.1}CoverageSummary') 
    372         for elem in self._root.findall('{http://www.opengis.net/wcs/1.1}Contents/{http://www.opengis.net/wcs/1.1}CoverageSummary/{http://www.opengis.net/wcs/1.1}CoverageSummary'):                     
    373             self.contents.append(CoverageSummary(elem, top)) 
    374         if self.contents==[]: 
    375             #non-hierarchical. 
    376             top=None 
    377             for elem in self._root.findall('{http://www.opengis.net/wcs/1.1}Contents/{http://www.opengis.net/wcs/1.1}CoverageSummary'):      
    378                 self.contents.append(CoverageSummary(elem, top))                              
    379                  
    380         # contact person TODO 
    381         #self.provider = ContactMetadata(self._root.find('Service/ContactInformation')) 
    382  
    383      
    384     def getOperationByName(self, name): 
    385         """Return a named operation item.""" 
    386         for item in self.operations: 
    387             if item.name == name: 
    388                 return item 
    389         raise KeyError, "No operation named %s" % name 
     360 
     361     
     362 
  • OWSLib/branches/wcstemp/owslib/coverage/wcsBase.py

    r1019 r1023  
    3232    def __init__(self): 
    3333        pass     
    34      
    35     def _getGenCovListProperty(self): 
    36         '''genericCoverages attribute is used to hold a list of CoverageInfo objects which are generic and independent of the WCS version. As a result of this they may be lossy compared to interrogating the version specific capabilities document, but they serve the purpose of providing a uniform view of different WCS versions ''' 
    37         if not hasattr(self, '_genericCoverages'): 
    38             self._genericCoverages=self._buildGenericCoverages() 
    39         return self._genericCoverages 
    40     genericCoverages=property(_getGenCovListProperty, None) 
    41      
    42      
    43     def _getGenServiceProperty(self): 
    44         '''genericService attribute is used to hold a list of non-version specific info about the service ''' 
    45         if not hasattr(self, '_genericService'): 
    46             self._genericService=self._buildGenericServiceInfo() 
    47         return self._genericService 
    48     serviceInfo=property(_getGenServiceProperty, None) 
    49      
    50     def _buildGenericCoverages(self): 
    51         ''' must be overridden to provide enable generic interface'''         
    52         return [] 
    53      
    54     def _buildGenericProviderInfo(self): 
    55         ''' must be overridden to provide enable generic interface''' 
    56         return ProviderInfo() 
    57      
    58      
    59     def _buildGenericServiceInfo(self): 
    60         ''' must be overridden to provide enable generic interface''' 
    61         return ServiceInfo() 
    62       
    63      
    64     #def listCoverages(self): 
    65         #''' returns a dictionary contining the {id, name} values for each coverageSummary''' 
    66         #coverages={} 
    67         #for item in self.genericCoverages: 
    68             #coverages[item.identifier]=item.labelordescription 
    69         #return coverages 
    70  
    71     def getCvgByIdentifier(self,identifier): 
    72         ''' returns a version independent coverage object ''' 
    73         for item in self.genericCoverages: 
    74             if item.identifier == identifier: 
    75                 return item 
    76         raise KeyError, "No coverage summary with identifier %s" %identifier 
    77      
    78     def getCvgByLabel(self,label): 
    79         ''' returns a version independent coverage object ''' 
    80         for item in self.genericCoverages: 
    81             if item.labelordescription == label: 
    82                 return item 
    83         raise KeyError, "No coverage summary with label %s" %label 
    84          
     34            
    8535    def getDescribeCoverage(self,identifier): 
    8636         reader = DescribeCoverageReader(self.version, identifier) 
     
    203153        u = urlopen(request) 
    204154        return etree.fromstring(u.read()) 
    205            
    206155     
    207      
    208 class CoverageInfo(object): 
    209     '''' Information about a coverage, not tied to any particular WCS version ''' 
    210     def __init__(self, identifier= None, labelordescription=None, wgs84bbox=None, otherbbox=None, _timeLimits=None): 
    211         self.identifier=identifier 
    212         self.labelordescription=labelordescription 
    213         self.wgs84bbox=wgs84bbox 
    214         self.otherbbox=otherbbox 
    215         self._timeLimits=_timeLimits 
    216         self._supCRS=lambda(i):None 
    217         self._supFormats=lambda(i):None 
    218          
    219     def getSupportedCRS(self): 
    220          '''the supCRS method should be altered by the calling object so that the correct value is returned. This will probably require a DescribeCoverage request, which is version specific ''' 
    221          return self._supCRS(self.identifier) 
    222       
    223     def getSupportedFormats(self): 
    224          '''the supFormats method should be altered by the calling object so that the correct value is returned. This will probably require a DescribeCoverage request, which is version specific ''' 
    225          return self._supFormats(self.identifier) 
    226      
    227     def getTimeLimits(self): 
    228         if not self._timeLimits: 
    229             try: 
    230                 return self._times(self.identifier) #some versions (eg 1.1.0) may require a describe coverage request to get time limits 
    231             except: 
    232                 return None 
    233         else: 
    234             return self._timeLimits#others (eg 1.0.0) may have retrieved it from the original getcapabilites requests 
    235       
    236     supportedCRS=property(getSupportedCRS, None) 
    237     supportedFormats=property(getSupportedFormats, None) 
    238     timeLimits=property(getTimeLimits, None) 
    239  
    240          
    241 class ServiceInfo(object): 
    242     '''' Information about the service available and the provider, not tied to any particular WCS version ''' 
    243     def __init__(self, fees=None, accessConstraints=None, providerName=None,contactName=None,contactPosition=None,addressString=None,phone=None,fax=None,email=None): 
    244         self.fees=fees 
    245         self.accessConstraints=accessConstraints 
    246         self.providerName=providerName 
    247         self.contactName=contactName 
    248         self.contactPosition=contactPosition 
    249         self.addressString=addressString 
    250         self.phone=phone 
    251         self.fax=fax 
    252         self.email=email 
    253156        
    254157class RereadableURL(StringIO, object): 
  • OWSLib/branches/wcstemp/owslib/coverage/wcsdecoder.py

    r1019 r1023  
    1212#u=wcs.getcoverage(identifier=['TuMYrRQ4'], timeSequence=['2792-06-01T00:00:00.0'], bbox=(-112,36,-106,41),format='application/netcdf', store='true') 
    1313#decoder=wcsdecoder.WCSDecoder(u) 
    14 #print  decoder.getCoveragePaths() 
     14#decoder.getCoverages() 
    1515 
    1616import os 
     
    1818import email 
    1919import errno 
    20  
    21  
    2220 
    2321class WCSDecoder(object): 
     
    3937         
    4038       
    41     def getCoverages(self): 
     39    def getCoverages(self, unpackdir='./unpacked'): 
    4240        if self.urlType=='XML':  
    4341            paths=[]               
     
    4644            for ref in u_tree.findall('{http://www.opengis.net/wcs/1.1}Coverage/{http://www.opengis.net/wcs/1.1}Reference'): 
    4745                path = ref.attrib['{http://www.w3.org/1999/xlink}href'] 
    48                 paths.append(path)      
    49             return paths     
     46                paths.append(path)          
    5047        elif self.urlType=='Multipart': 
    5148            #Decode multipart mime and return fileobjects 
    5249            u_mpart=self.u.read() 
    53             return MpartMime(u_mpart) 
    54          
     50            mpart =MpartMime(u_mpart) 
     51            paths= mpart.unpackToDir(unpackdir) 
     52        return paths 
    5553 
    5654class MpartMime(object): 
  • OWSLib/branches/wcstemp/owslib/interfaces.py

    r954 r1023  
    1010    version = property("""Protocol version (string)""") 
    1111    capabilities = property("""Implementation of IServiceMetadata (object)""") 
    12  
    13  
     12    #remove capabilities? 
     13     
    1414class IWebMapService(IService): 
    1515    """Abstraction for an OGC Web Map Service (WMS). 
     
    6161    abstract = property("""Text describing the service (string).""") 
    6262    keywords = property("""Keyword list (list).""") 
    63     rights = property("""Explanation of rights associated with service (string).""") 
     63    accessconstraints = property("""Explanation of access constraints associated with service (string).""") 
     64    fees = property("""Explanation of fees associated with service (string).""") 
    6465     
    6566 
  • OWSLib/branches/wcstemp/tests/wcs_newiface.txt

    r1020 r1023  
    22==================== 
    33 
     4Version 1.0.0 
     5======== 
     6 
    47    >>> from owslib.wcs import WebCoverageService 
    58    >>> wcs=WebCoverageService('http://ndgbeta.badc.rl.ac.uk/wcs/badc.nerc.ac.uk__NDG-A0__AWQX8gTc', version='1.0.0') 
     9    >>> wcs.url 
     10    'http://ndgbeta.badc.rl.ac.uk/wcs/badc.nerc.ac.uk__NDG-A0__AWQX8gTc' 
     11    >>> wcs.version 
     12    '1.0.0' 
     13    >>> wcs.serviceidentification.service 
     14    'WCS' 
     15    >>> wcs.serviceidentification.version 
     16    '1.0.0' 
     17    >>> wcs.serviceidentification.title 
     18    'BADC OGC WCS Server' 
     19    >>> wcs.serviceidentification.abstract 
     20    '\n      Web Map Server maintained by BADC\n      Contact: webmaster@badc.nerc.ac.uk ' 
     21    >>> wcs.serviceidentification.keywords 
     22    ['atmospheric', 'climate'] 
     23    >>> wcs.serviceidentification.fees 
     24    'NONE' 
     25    >>> wcs.serviceidentification.accessConstraints 
     26    'NONE' 
    627    >>> wcs.serviceprovider.provider 
    728    'British Atmospheric Data Centre' 
     
    3354    >>> f.write(output.read()) 
    3455    >>> f.close() 
     56 
     57Version 1.1.0 
     58======== 
     59    >>> from owslib.coverage import wcsdecoder 
     60    >>> wcs=WebCoverageService('http://ndgbeta.badc.rl.ac.uk/wcs/badc.nerc.ac.uk__NDG-A0__AWQX8gTc', version='1.1.0') 
     61    >>> wcs.url 
     62    'http://ndgbeta.badc.rl.ac.uk/wcs/badc.nerc.ac.uk__NDG-A0__AWQX8gTc' 
     63    >>> wcs.version 
     64    '1.1.0' 
     65    >>> wcs.serviceidentification.service 
     66    'WCS' 
     67    >>> wcs.serviceidentification.version 
     68    '1.1.0' 
     69    >>> wcs.serviceidentification.title 
     70    'BADC OGC WCS Server' 
     71    >>> wcs.serviceidentification.abstract 
     72    '\n      Web Map Server maintained by BADC\n      Contact: webmaster@badc.nerc.ac.uk ' 
     73    >>> wcs.serviceidentification.keywords 
     74    ['atmospheric', 'climate'] 
     75    >>> wcs.serviceidentification.fees 
     76    'NONE' 
     77    >>> wcs.serviceidentification.accessConstraints 
     78    'NONE' 
     79    >>> wcs.serviceprovider.provider 
     80    'British Atmospheric Data Centre' 
     81    >>> wcs.serviceprovider.url 
     82    "URL for provider's web site (string)." 
     83    >>> wcs.serviceprovider.contact 
     84    'How to contact the service provider (string).' 
     85    >>> type(wcs.items()) 
     86    <type 'list'> 
     87    >>> cvg=wcs['ZI4al0r8'] 
     88    >>> cvg.title 
     89    'Vapour pressure' 
     90    >>> cvg.keywords 
     91    ['NONE', 'NONE'] 
     92    >>> wcs.serviceidentification.accessConstraints 
     93    'NONE' 
     94    >>> wcs.serviceidentification.fees 
     95    'NONE' 
     96    >>> cvg.boundingBoxWGS84 
     97    (1.875, -88.767123287700002, 358.125, 88.767123287700002) 
     98    >>> cvg.timelimits 
     99    ['2024-01-15', '2054-12-15'] 
     100    >>> cvg.supportedFormats 
     101    ['cf-netcdf'] 
     102    >>> cvg.supportedCRS 
     103    ['srstba'] 
     104 
     105GetCoverage returning Multipart Mime: 
     106    >>> output=wcs.getCoverage(identifier='ZI4al0r8',timeSequence=['2024-01-15T00:00:00.0'],bbox=(-80,30,50,60), format='cf-netcdf', store='false') 
     107     
     108Need to use the decoder class to handle 1.1.0 type outputs  
     109(coverages xml docs or multipart mime) 
     110-------------------------------------------------------------------------------------------- 
     111    >>> decoder=wcsdecoder.WCSDecoder(output) 
     112    >>> decoder.getCoverages(unpackdir='mydir')      
     113    ['mydir/coverage.xml', 'mydir/coverage.nc'] 
     114 
     115GetCoverage returning Coverages.xml: 
     116    >>> output=wcs.getCoverage(identifier='ZI4al0r8',timeSequence=['2024-01-15T00:00:00.0'],bbox=(-80,30,50,60), format='cf-netcdf', store='true') 
     117 
     118Use the decoder class to extract the url from the coverages doc. 
     119-------------------------------------------------------------------------------------------- 
     120 
     121    >>> decoder2=wcsdecoder.WCSDecoder(output) 
     122    >>> outputurl= decoder2.getCoverages() 
     123    >>> outputurl[0][:7] 
     124    'http://' 
     125     
     126 
     127 
     128 
     129