Changeset 1026

Show
Ignore:
Timestamp:
01/23/08 02:45:10
Author:
domlowe
Message:

changed supportedFormats and supportedCRS to use property(). Describecoverages requests now only made when required

Files:

Legend:

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

    r1025 r1026  
    6262        self.servicecontents={} 
    6363        for elem in self._capabilities.findall(ns('ContentMetadata/')+ns('CoverageOfferingBrief')):  
    64             cm=ContentMetadata(elem) 
    65             #make the describeCoverage requests to populate the supported formats/crs attributes 
    66             cm.supportedFormats=self._getSupportedFormats(cm.id) 
    67             cm.supportedCRS=self._getSupportedCRS(cm.id) 
     64            cm=ContentMetadata(elem, self) 
    6865            self.servicecontents[cm.id]=cm 
    6966         
     
    134131            u.seek(0) 
    135132        return u 
    136          
    137     def _getSupportedCRS(self,identifier): 
    138         # gets supported crs info 
    139         crss=[] 
    140         for elem in self.getDescribeCoverage(identifier).findall(ns('CoverageOffering/')+ns('supportedCRSs/')+ns('responseCRSs')): 
    141             crss.append(elem.text) 
    142         return crss 
    143  
    144     def _getSupportedFormats(self,identifier): 
    145         # gets supported formats info 
    146         frmts =[] 
    147         for elem in self.getDescribeCoverage(identifier).findall(ns('CoverageOffering/')+ns('supportedFormats/')+ns('formats')): 
    148             frmts.append(elem.text) 
    149         return frmts 
    150          
     133                
    151134    def _getOperationByName(self, name): 
    152135        """Return a named operation item.""" 
     
    257240    Implements IContentMetadata 
    258241    """ 
    259     def __init__(self, elem): 
    260         """Initialize.""" 
     242    def __init__(self, elem, service): 
     243        """Initialize. service is required so that describeCoverage requests may be made""" 
    261244        #TODO - examine the parent for bounding box info. 
    262245         
    263246        #self._parent=parent 
     247        self._service=service 
    264248        self.id=elem.find(ns('name')).text 
    265249        self.title =elem.find(ns('label')).text        
     
    295279         
    296280        #SupportedCRS, SupportedFormats 
    297         #these require a seperate describeCoverage request...      for now set to None 
    298         self.supportedCRS=None 
    299         self.supportedFormats=None 
     281        #these require a seperate describeCoverage request...      only resolve when requested 
     282     
     283    def _getSupportedCRSProperty(self): 
     284        # gets supported crs info 
     285        crss=[] 
     286        for elem in self._service.getDescribeCoverage(self.id).findall(ns('CoverageOffering/')+ns('supportedCRSs/')+ns('responseCRSs')): 
     287            crss.append(elem.text) 
     288        return crss 
     289    supportedCRS=property(_getSupportedCRSProperty, None) 
     290        
     291        
     292    def _getSupportedFormatsProperty(self): 
     293        # gets supported formats info 
     294        frmts =[] 
     295        for elem in self._service.getDescribeCoverage(self.id).findall(ns('CoverageOffering/')+ns('supportedFormats/')+ns('formats')): 
     296            frmts.append(elem.text) 
     297        return frmts 
     298    supportedFormats=property(_getSupportedFormatsProperty, None) 
     299         
     300         
  • OWSLib/branches/wcstemp/owslib/coverage/wcs110.py

    r1025 r1026  
    7272        top = self._capabilities.find('{http://www.opengis.net/wcs/1.1}Contents/{http://www.opengis.net/wcs/1.1}CoverageSummary') 
    7373        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) 
     74            cm=ContentMetadata(elem, top, self) 
    7975            self.servicecontents[cm.id]=cm 
    8076             
     
    8581                cm=ContentMetadata(elem, top) 
    8682                #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) 
    8983                cm.timelimits=self._getTimes(cm.id) 
    9084                self.servicecontents[cm.id]=cm 
     
    113107        return frmts  
    114108              
    115     def _getTimes(self, identifier): 
    116          timelimits=[] 
    117          for elem in self.getDescribeCoverage(identifier).findall(ns('CoverageDescription/')+ns('Domain/')+ns('TemporalDomain/')+ns('TimePeriod/')): 
    118              subelems=elem.getchildren() 
    119              timelimits=[subelems[0].text,subelems[1].text] 
    120          return timelimits 
     109 
    121110          
    122111    #TO DECIDE: May need something like this 
     
    283272    """Abstraction for WCS CoverageSummary 
    284273    """ 
    285     def __init__(self, elem, parent): 
     274    def __init__(self, elem, parent, service): 
    286275        """Initialize.""" 
    287276        #TODO - examine the parent for bounding box info. 
    288277         
     278        self._service=service 
    289279        self._elem=elem 
    290280        self._parent=parent 
     
    339329            self.supportedFormats.append(format.text) 
    340330             
     331             
     332    #time limits requires a describeCoverage request therefore only resolve when requested 
     333    def _getTimes(self): 
     334         timelimits=[] 
     335         for elem in self._service.getDescribeCoverage(self.id).findall(ns('CoverageDescription/')+ns('Domain/')+ns('TemporalDomain/')+ns('TimePeriod/')): 
     336             subelems=elem.getchildren() 
     337             timelimits=[subelems[0].text,subelems[1].text] 
     338         return timelimits 
     339    timelimits=property(_getTimes, None) 
     340     
    341341    def _checkChildAndParent(self, path): 
    342342        ''' checks child coverage  summary, and if item not found checks higher level coverage summary''' 
  • OWSLib/branches/wcstemp/tests/wcs_newiface.txt

    r1025 r1026  
    9999    ['2024-01-15', '2054-12-15'] 
    100100    >>> cvg.supportedFormats 
    101     ['cf-netcdf'] 
     101    ['application/cf-netcdf'] 
    102102    >>> cvg.supportedCRS 
    103     ['srstba'] 
     103    ['WGS84'] 
    104104 
    105105GetCoverage returning Multipart Mime: