Ignore:
Timestamp:
25/04/08 14:15:01 (12 years ago)
Author:
spascoe
Message:

Added GetFeatureInfo? for CSMLGridSeries WMS

Location:
TI05-delivery/ows_framework/branches/ows_framework-refactor/ows_common/ows_common
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • TI05-delivery/ows_framework/branches/ows_framework-refactor/ows_common/ows_common/pylons/wms_controller.py

    r3811 r3822  
    424424        format = self.getOwsParam('info_format') 
    425425        for layerName, layerObj in layers.iteritems(): 
     426            print format 
     427            print layerObj.title 
     428            print layerObj.featureInfoFormats 
    426429            if format not in layerObj.featureInfoFormats: 
    427430                raise InvalidParameterValue('Layer %s does not support GetFeatureInfo in format %s' %(layerName, format), 'info_format') 
  • TI05-delivery/ows_framework/branches/ows_framework-refactor/ows_common/ows_common/service/imps/wms_csmllayer.py

    r3769 r3822  
    6666        @raise ValueError: If no layers are available for these keywords.  
    6767        """ 
     68        print "hello" 
     69        #print kwargs 
    6870        fileoruri=kwargs['fileoruri'] 
    69          
     71          
    7072        #TODO - handle file paths/directories URIs in config 
    7173        #.xml or .csml extensions are supported: 
     
    7577        if not os.path.exists(filename): 
    7678            raise Exception(str('CSML File could not be found: %s')%filename) 
    77              
     79        print filename     
    7880        ds=csml.parser.Dataset(filename) 
    7981             
     
    102104 
    103105    """ 
    104  
     106     
    105107    def __init__(self, title, abstract, dimensions, units, crss, feature): 
    106108        self.featureInfoFormats=None #NotImplemented 
     
    112114        self._feature=feature 
    113115        self.legendSize=(30,100) 
     116<<<<<<< .mine 
     117        bb= self._feature.getCSMLBoundingBox().getBox() 
     118        #convert 0 - 360 to -180, 180 as per common WMS convention 
     119        if abs(bb[2]-bb[0]) >= 359 and abs(bb[2]-bb[0]) < 361: 
     120            bb[0], bb[2]=-180, 180 
     121        self.wgs84BBox = bb 
     122        self.featureInfoFormats = ['text/html'] 
     123======= 
    114124        try: 
    115125            self.wgs84BBox = self.getBBox('EPSG:4326') 
     
    118128                             "coordinates for compatibility with WMS-1.3.0") 
    119129 
     130>>>>>>> .r3821 
    120131    def getBBox(self, crs): 
    121132        """ 
     
    123134            reference system. 
    124135        """ 
    125         bb= self._feature.getCSMLBoundingBox().getBox() 
     136        #bb= self._feature.getCSMLBoundingBox().getBox() 
    126137        #convert 0 - 360 to -180, 180 as per common WMS convention 
    127         if abs(bb[2]-bb[0]) >= 359 and abs(bb[2]-bb[0]) < 361: 
    128             bb[0], bb[2]=-180, 180 
    129         return bb 
     138        #if abs(bb[2]-bb[0]) >= 359 and abs(bb[2]-bb[0]) < 361: 
     139        #    bb[0], bb[2]=-180, 180 
     140        #self.wgs84BBox = bb 
     141        return self.wgs84BBox 
    130142        #raise NotImplementedError 
    131143         
     
    158170            result= self._feature.subsetToGridSeries(config['tmpfilebuffer'], ncname=randomname, **dimValues) 
    159171            #for now have to read netcdf back from disk (limitiation of CSML api) 
     172            print ['h', result[1]] 
    160173            netcdf=cdms.open(result[1]) 
    161174            #and then delete the temporary file 
     
    181194        return '%s:%s' % (crs, dimList) 
    182195 
     196    def getFeatureInfo(self, format, crs, point, dimValues): 
     197        """ 
     198        Return a response string descibing the feature at a given 
     199        point in a given CRS. 
     200 
     201        Currently only "html" is supported as output format 
     202 
     203        @param format: One of self.featureInfoFormats.  Defines which 
     204            format the response will be in. 
     205        @param crs: One of self.crss 
     206        @param point: a tuple (x, y) in the supplied crs of the point 
     207            being selected. 
     208        @param dimValues: A mapping of dimension names to dimansion values. 
     209        @return: A string containing the response. 
     210 
     211        """ 
     212        print point 
     213        randomname= csml.csmllibs.csmlextra.getRandomID() + '.nc' 
     214        result= self._feature.subsetToGridSeries(config['tmpfilebuffer'], ncname=randomname, **dimValues) 
     215        #for now have to read netcdf back from disk (limitiation of CSML api) 
     216         
     217        f=cdms.open(result[1]) 
     218        #and then delete the temporary file 
     219        os.system('rm %s'%result[1]) 
     220        netcdf = f(self.title) 
     221        #Now grab the netCDF object for the point specified. 
     222        #The reason for the 'cob' option is so that if the grid the data  
     223        #is defined on does not have a grid point at the point specified,  
     224        #we should  still get the nearest location 
     225         
     226        t_point = netcdf(latitude=(point[1], point[1], 'cob'), longitude=(point[0], point[0], 'cob')) 
     227        #now get the value recorded at this location 
     228        value = t_point.getValue().tolist() 
     229        print value 
     230        print t_point.fill_value() 
     231        #and the fill_value too 
     232        fill_value = t_point.fill_value() 
     233        #value is actually embedded in a multi dimensional list,  
     234        #so we need to extract the actual value from the list 
     235        while type(value) is list: 
     236                value = value[0] 
     237 
     238        #now check if the value is actually the fill_value rather than  
     239        #a value recorded at the point specified 
     240        print [value, fill_value] 
     241        if (2*fill_value) == value: 
     242                value = "No value found at position: "+str(point[1])+", "+str(point[0]) 
     243        else: 
     244                value = "Value found at position: "+str(point[1])+", "+str(point[0])+" is: "+str(value) 
     245        # finally return the value 
     246        return value 
    183247 
    184248 
     
    290354    def __init__(self, layer, netcdf, bbox, width, height): 
    291355        #we know the axes are called latitude and longitude as the CSML code has written it: 
    292  
     356        #print netcdf 
    293357        v=netcdf(layer.title) 
     358        #print v 
    294359        tvar=v(latitude=(bbox[1], bbox[3]), longitude=(bbox[0],bbox[2]),squeeze=1) 
    295360        order=tvar.getOrder() 
    296361        #array of data 
    297362        self.value=tvar.getValue() 
     363        #print self.value 
    298364        #order of axes 
    299365        if order == 'xy': 
     
    309375        self.dx=abs(lon[0]-lon[1]) 
    310376        self.dy=abs(lat[0]-lat[1]) 
     377        #print [lon, len(lon)] 
     378        #print len(self.value) 
     379        print len(lon) 
     380        print len(lat) 
     381 
     382     
     383 
     384         
     385 
    311386        self.nx=len(lon) 
    312387        self.ny=len(lat) 
Note: See TracChangeset for help on using the changeset viewer.