Changeset 6398 for cows


Ignore:
Timestamp:
25/01/10 15:04:48 (9 years ago)
Author:
pnorton
Message:

Modified the WCS code to work with the csml files in folders in the same way as the WMS code.

Location:
cows/trunk/cows
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • cows/trunk/cows/pylons/wcs_controller.py

    r5962 r6398  
    9494         
    9595        #TODO, the bounding box may include a Z dimension in WCS. 
    96         for cvgName, coverage in self.layers.items(): 
     96        for cvgName, coverage in sorted(self.layers.items()): 
    9797            log.debug('Loading coverage %s' % cvgName) 
    9898 
     
    109109            #From the ows_servers stack - allthese values should come from  the Coverage object. 
    110110            #TODO, the bounding box may include a Z dimension in WCS. 
    111             ds = WcsDatasetSummary(identifier=coverage.id, 
     111            ds = WcsDatasetSummary(identifier=coverage.name, 
    112112                                 titles=coverage.title, 
    113113                                 wgs84BoundingBoxes=[coverage.wgs84BBox], 
  • cows/trunk/cows/service/imps/csmlbackend/__init__.py

    r6394 r6398  
    77 
    88 
    9 from cows.service.imps.csmlbackend.csmlcommon import CSMLConnector 
    109 
    1110_globalCSMLConnector = None 
     
    1514     
    1615    if _globalCSMLConnector is None: 
     16        from cows.service.imps.csmlbackend.csmlcommon import CSMLConnector 
    1717        _globalCSMLConnector = CSMLConnector() 
    1818     
  • cows/trunk/cows/service/imps/csmlbackend/csmlcommon.py

    r6394 r6398  
    1616 
    1717from cows.service.imps.csmlbackend.config import config 
     18from cows.service.imps.csmlbackend import getGlobalCSMLConnector 
    1819 
    1920import ConfigParser 
     
    6869    def __init__(self): 
    6970        self.layermapcache={} 
    70         self.connector = globalCSMLConnector 
     71        self.connector = getGlobalCSMLConnector() 
    7172     
    7273    #!TODO: Should be _getInfo() as proposed in wms_csmllayer.  Should move to wfs_csmllayer as 
  • cows/trunk/cows/service/imps/csmlbackend/wcs_csmllayer.py

    r6393 r6398  
    4646        domain = feature.getDomain() 
    4747        tax= feature.getTimeAxis() 
     48         
    4849        try: 
    4950            timepositions=domain[tax] 
     
    5253            timepositions=[''] 
    5354            timelimits=['','']  
     55             
    5456        crs=feature.getNativeCRS() 
    5557        log.debug('crs %s'%crs) 
     
    6466        lat=feature.getLatitudeAxis() 
    6567        t=feature.getTimeAxis() 
     68         
    6669        if None in [lon, lat, t]: 
    6770            #TODO need to return a suitable wcs error. 
     
    103106            #we've accessed this layer map before, get it from the cache dictionary 
    104107            return self.layermapcache[fileoruri] 
    105           
    106         ds = self.connector.getCsmlDoc(fileoruri) 
    107         try: 
    108             self.datasetName=ds.name.CONTENT 
    109         except AttributeError: 
    110             self.datasetName = 'CSML WCS Service' 
    111              
    112         layermap={} 
     108         
     109        if self.connector.isGroup(fileoruri): 
     110            self.datasetName = fileoruri 
     111        else: 
     112             
     113            ds = self.connector.getCsmlDoc(fileoruri) 
     114            try: 
     115                self.datasetName=ds.name.CONTENT 
     116            except AttributeError: 
     117                self.datasetName = 'CSML WCS Service' 
     118             
     119             
    113120        self._crscat=csml.csmllibs.csmlcrs.CRSCatalogue() 
    114121         
    115         for feature in csml.csmllibs.csmlextra.listify(ds.featureCollection.featureMembers): 
    116             title, abstract, timepositions, timelimits, units, crss, axisDescriptions=self.getInfo(feature) 
    117             layermap[feature.id]=CSMLCoverage([title],[abstract], timepositions, timelimits, units, crss, axisDescriptions, feature) 
    118              
     122        if self.connector.isGroup(fileoruri): 
     123            coverages = self._getCoveragesFromFolder(folderPath=fileoruri) 
     124        else: 
     125            coverages = self._getCoveragesFromCSMLFile(fileoruri) 
     126         
     127        layermap = {} 
     128        for c in coverages: 
     129            layermap[c.name] = c 
     130         
     131#        for feature in csml.csmllibs.csmlextra.listify(ds.featureCollection.featureMembers): 
     132#            title, abstract, timepositions, timelimits, units, crss, axisDescriptions=self.getInfo(feature) 
     133#             
     134#            name = feature.id 
     135#            layermap[feature.id]=CSMLCoverage(name, [title],[abstract],  
     136#                                               timepositions, timelimits, units,  
     137#                                               crss, axisDescriptions, feature) 
     138#             
    119139        if len(layermap) > 0: 
    120140            self.layermapcache[fileoruri]=layermap 
     
    122142        else: 
    123143            raise ValueError 
    124  
     144     
     145    def _getCoveragesFromFolder(self, folderPath=None): 
     146        l = [] 
     147         
     148        for fc in self.connector.list(folder=folderPath): 
     149             
     150            if self.connector.isGroup(fc): 
     151                l += self._getCoveragesFromFolder(folderPath=fc) 
     152            else:  
     153                l += self._getCoveragesFromCSMLFile(fc) 
     154                 
     155        return l 
     156     
     157    def _getCoveragesFromCSMLFile(self, fileoruri): 
     158        l = [] 
     159        ds = self.connector.getCsmlDoc(fileoruri) 
     160         
     161        for feature in csml.csmllibs.csmlextra.listify(ds.featureCollection.featureMembers): 
     162            title, abstract, timepositions, timelimits, units, crss, axisDescriptions=self.getInfo(feature) 
     163             
     164            name = fileoruri.replace('/','_') + '_' +feature.id 
     165            c = CSMLCoverage(name, [title],[abstract], timepositions, timelimits,  
     166                             units,crss, axisDescriptions, feature) 
     167             
     168            l.append(c) 
     169     
     170        return l 
     171                           
     172         
    125173class AxisDescription(object): 
    126174    """ represents an axisDescription from the rangeSet (see wcs 1.0.0 describe coverage) """ 
     
    133181    """ represents a WCS Coverage. Implements ICoverage """ 
    134182     
    135     def __init__(self, title, abstract, timepositions, timelimits, units, crss, axisDescriptions, feature): 
     183    def __init__(self, name, title, abstract, timepositions, timelimits, units, crss, axisDescriptions, feature): 
     184        self.name = name 
    136185        self.title=title 
    137186        self.abstract=abstract 
Note: See TracChangeset for help on using the changeset viewer.