Changeset 3622 for TI05-delivery


Ignore:
Timestamp:
17/03/08 11:55:54 (11 years ago)
Author:
domlowe
Message:

more on wms

File:
1 edited

Legend:

Unmodified
Added
Removed
  • TI05-delivery/ows_framework/branches/ows_framework-refactor/ows_common/ows_common/service/imps/wms_csmllayer.py

    r3620 r3622  
    33 
    44""" 
     5import os 
    56import csml 
    67import cdms 
     
    1011from matplotlib import cm 
    1112import genutil 
     13from pylons import config  #config must have tmpfilebuffer and csmlstore values 
    1214 
    1315class CSMLLayerMapper(object): 
     
    5557        """ 
    5658        fileoruri=kwargs['fileoruri'] 
     59        #print config['tmpfilebuffer'] 
    5760         
    5861        #TODO - handle file paths/directories URIs in config 
    59         #For testing purposes...: 
    60         filename='/home/dom/hadgem/%s.csml'%fileoruri 
     62        #.xml or .csml extensions are supported: 
     63        filename='%s/%s.csml'%(config['csmlstore'],fileoruri) 
     64        if not os.path.exists(filename): 
     65           filename='%s/%s.xml'%(config['csmlstore'],fileoruri) 
     66        if not os.path.exists(filename): 
     67            raise Exception(str('CSML File could not be found: %s')%filename) 
     68             
    6169        ds=csml.parser.Dataset(filename) 
    62         
    63          
     70             
    6471        layermap={} 
    6572        self._crscat=csml.csmllibs.csmlcrs.CRSCatalogue() 
     
    122129        """ 
    123130        if type(self._feature) == csml.parser.GridSeriesFeature: 
    124             randomname='tmp' + csml.csmllibs.csmlextra.getRandomID() + '.nc' 
    125             result= self._feature.subsetToGridSeries(outputdir='./', ncname=randomname, **dimValues) 
    126             #for now have to read netcdf back from disk. 
     131            randomname= csml.csmllibs.csmlextra.getRandomID() + '.nc' 
     132            result= self._feature.subsetToGridSeries(config['tmpfilebuffer'], ncname=randomname, **dimValues) 
     133            #for now have to read netcdf back from disk (limitiation of CSML api) 
    127134            netcdf=cdms.open(result[1]) 
     135            #and then delete the temporary file 
     136            os.system('rm %s'%result[1]) 
    128137            bbox=self.getBBox(crs) 
    129138            return CSMLLayerSlab(netcdf, self, crs, dimValues, renderOpts, bbox) 
     
    193202 
    194203        @ivar bbox: A bbox 4-tuple. 
    195         @ivar width: width in pixels. 
     204        @ivar width: width in pixels. 
    196205        @ivar height: height in pixels. 
    197206        @return: A PIL Image object. 
Note: See TracChangeset for help on using the changeset viewer.