Changeset 2630 for TI05-delivery


Ignore:
Timestamp:
21/06/07 15:05:06 (12 years ago)
Author:
spascoe
Message:

Added cache code but performance is still sluggish. Need to work out
exactly what's going on.

Location:
TI05-delivery/ows_framework/trunk/ows_server
Files:
2 added
5 edited

Legend:

Unmodified
Added
Removed
  • TI05-delivery/ows_framework/trunk/ows_server/ows_server/controllers/csml_wms.py

    r2629 r2630  
    1212from ows_server.lib.decorators import * 
    1313from ows_server.lib import grid_util, render 
    14 from ows_server.lib.csml_util import get_csml_doc, extractToVariable 
     14from ows_server.lib.csml_util import get_csml_doc, extract_cache 
    1515import ows_server.lib.validators as V 
    1616 
     
    141141        # render.render_variable() 
    142142        #!TODO: This could be done better. 
    143         x1 = max(-180., min(180., bbox[0])) 
    144         x2 = max(-180., min(180., bbox[2])) 
    145         y1 = max(-90., min(90., bbox[1])) 
    146         y2 = max(-90., min(90., bbox[3])) 
     143        #x1 = max(-180., min(180., bbox[0])) 
     144        #x2 = max(-180., min(180., bbox[2])) 
     145        #y1 = max(-90., min(90., bbox[1])) 
     146        #y2 = max(-90., min(90., bbox[3])) 
    147147 
    148148        # Define the extraction selector 
    149         sel = dict(latitude=(y1, y2), longitude=(x1, x2)) 
     149        #sel = dict(latitude=(y1, y2), longitude=(x1, x2)) 
    150150 
    151151        # Parse dimensions. 
     152        sel = {} 
    152153        for dim in self._iterDimensions(feature): 
    153154            # For the moment hard-code time in.  We don't support any other dimension yet. 
     
    160161                raise OWS_E.MissingParameterValue('%s dimension not specified' % dim, dim) 
    161162 
    162          
     163        # Get the entire lat/lon slice from the extract_cache 
     164        var = extract_cache[feature, sel] 
    163165 
    164         try: 
    165             # Extract via CSML.subsetToGridSeries() 
    166             var = extractToVariable(feature, sel) 
     166        # Do geographical subsetting in cdms 
     167        var = var(latitude=(bbox[1], bbox[3]), longitude=(bbox[0], bbox[2]), squeeze=1) 
    167168 
    168             # Deduce min and max 
    169             varmin = MA.minimum(var, None) 
    170             varmax = MA.maximum(var, None) 
     169        # Deduce min and max 
     170        #!TODO: How do we get the min/max? 
     171        #varmin = MA.minimum(var, None) 
     172        #varmax = MA.maximum(var, None) 
     173        varmin=0; varmax=100 
    171174 
    172             # Render variable to a PIL image 
    173             img = render.render_variable(var, bbox, width, height, 0, 100) # varmin, varmax 
     175        # Render variable to a PIL image 
     176        img = render.render_variable(var, bbox, width, height, varmin, varmax) 
    174177 
    175             # Serialise it to PNG 
    176             buf = StringIO() 
    177             img.save(buf, 'PNG') 
    178         except Exception, e: 
    179             import pdb; pdb.post_mortem(sys.exc_info()[2]) 
    180             if isinstance(e, OWS_E.OwsError): 
    181                 raise e 
    182             else: 
    183                 raise OWS_E.NoApplicableCode(e) 
     178        # Serialise it to PNG 
     179        buf = StringIO() 
     180        img.save(buf, 'PNG') 
    184181 
    185182        return Response(content=buf.getvalue(), mimetype='image/png') 
  • TI05-delivery/ows_framework/trunk/ows_server/ows_server/lib/csml_util.py

    r2613 r2630  
    1414import zipfile 
    1515import tempfile 
     16 
     17from ows_server.lib import csml_cache 
     18extract_cache = csml_cache.CSMLCache(request.environ['paste.config']['app_conf']['tmp_dir'], max_size=3) 
     19 
    1620 
    1721def get_csml_doc(file): 
  • TI05-delivery/ows_framework/trunk/ows_server/ows_server/tests/functional/test_csml_wms.py

    r2596 r2630  
    66wms_ns = 'http://www.opengis.net/wms' 
    77 
    8 # This depends on the value randomly generated by csmlscan. 
    9 # However make_data.py sets the random seed so this should work. 
    10 test_feature_id = 'DVVhDIq2' 
     8# Test id is hard coded for now until I work out how to get it dynamically within 
     9# the test harness. 
     10test_feature_id = 'QGYylL9h' 
    1111 
    1212class TestGetCapabilities(TestController): 
    1313    def setUp(self): 
    1414        url = url_for(controller='csml_wms', 
    15                       file='test', 
     15                      file='clim_10', 
    1616                      request='GetCapabilities', 
    1717                      service='WMS', 
     
    3535        # With 4 sub-layers 
    3636        layers = layers[0].findall('./{%(ns)s}Layer' % dict(ns=wms_ns)) 
    37         assert len(layers) == 4 
     37        assert len(layers) == 9 
    3838 
    3939class TestGetMap(TestController): 
    4040    def setUp(self): 
    41         url = url_for(controller='csml_wms', file='test', 
     41        url = url_for(controller='csml_wms', file='clim_10', 
    4242                      request='GetMap', 
    4343                      layers=test_feature_id, 
  • TI05-delivery/ows_framework/trunk/ows_server/test.ini

    r2629 r2630  
    1717[app:main] 
    1818use = config:development.ini#main_app 
    19 csml_dir = %(here)s/ows_server/tests/data 
    2019 
    2120# Add additional test specific configuration options as necessary. 
Note: See TracChangeset for help on using the changeset viewer.