Changeset 2707


Ignore:
Timestamp:
04/07/07 17:16:13 (12 years ago)
Author:
spascoe
Message:

Basic WMS serving pre-generated images is working. Most of
the configuration stuff is in models/ddp_data.py for now.

Location:
TI05-delivery/ows_framework/branches/ows_framework-ddp/ows_server
Files:
1 added
2 edited
1 copied

Legend:

Unmodified
Added
Removed
  • TI05-delivery/ows_framework/branches/ows_framework-ddp/ows_server/development.ini

    r2695 r2707  
    1414use = egg:Paste#http 
    1515host = 0.0.0.0 
    16 port = 8080 
     16port = 8440 
    1717 
    1818[pipeline:main] 
     
    2727session_key = ows_server 
    2828session_secret = somesecret 
    29 csml_dir = /research/home/spascoe/host/saturn/data/ddc_data/obs 
     29#csml_dir = /research/home/spascoe/host/saturn/data/ddc_data/obs 
    3030tmp_dir = %(here)s/data/tmp 
    3131#used for wcs "store": 
    32 publish_dir=%(here)s/ows_server/private/filestore   
     32#publish_dir=%(here)s/ows_server/private/filestore   
    3333ows_common_config = %(here)s/eg_ows_capabilities.xml 
    34  
     34ddp_image_dir = %(here)s/../../data/afixaa.pei3aug 
    3535 
    3636# If you'd like to fine-tune the individual locations of the cache data dirs 
  • TI05-delivery/ows_framework/branches/ows_framework-ddp/ows_server/ows_server/config/routing.py

    r2681 r2707  
    2020    #map.connect(':controller/:action/:id') 
    2121    #map.connect('*url', controller='template', action='view') 
     22 
     23######################################################################################### 
     24## NDG Configuration.  Not being used in this application 
     25#########################################################################################     
     26##    # These should conform to http://proj.badc.rl.ac.uk/ndg/wiki/PasteStack 
     27##    # ... but don't ... yet ... 
     28 
     29##    # the NDG OGC services 
     30##    # change these when security layer is present and not before 
     31##    #to 
     32##    #map.connect('wms/:uri',controller='csml_wms') 
     33##    #map.connect('wcs/:uri',controller='csml_wcs') 
    2234     
    23     # These should conform to http://proj.badc.rl.ac.uk/ndg/wiki/PasteStack 
    24     # ... but don't ... yet ... 
     35## 
     36##     map.connect(':file/wms', controller='csml_wms') 
     37##     map.connect('wcs/:fileoruri', controller='csml_wcs') 
     38##     map.connect(':fileoruri/wcs', controller='csml_wcs') 
     39##     map.connect(':file/status/:jobID', controller='status', action='getStatus') 
     40     
     41##     # following is the shell for the rest of the ndg  
     42##     map.connect('login', controller='login') 
     43##     map.connect('wayf', controller='login', action='wayf') 
     44##     map.connect('logout', controller='logout') 
     45##     map.connect('view/:uri', controller = 'retrieve', action='view') 
     46##     map.connect('askCorrect/:uri', controller='retrieve', action='askCorrect') 
     47##     map.connect('correct/:uri', controller='retrieve', action='correct') 
     48##     map.connect('retrieve/:uri', controller = 'retrieve') 
    2549 
    26     # the NDG OGC services 
    27     # change these when security layer is present and not before 
    28     #to 
    29     #map.connect('wms/:uri',controller='csml_wms') 
    30     #map.connect('wcs/:uri',controller='csml_wcs') 
    31      
    32     map.connect(':file/wms', controller='csml_wms') 
    33     map.connect('wcs/:fileoruri', controller='csml_wcs') 
    34     map.connect(':fileoruri/wcs', controller='csml_wcs') 
    35     map.connect(':file/status/:jobID', controller='status', action='getStatus') 
    36      
    37     # following is the shell for the rest of the ndg  
    38     map.connect('login', controller='login') 
    39     map.connect('wayf', controller='login', action='wayf') 
    40     map.connect('logout', controller='logout') 
    41     map.connect('view/:uri', controller = 'retrieve', action='view') 
    42     map.connect('askCorrect/:uri', controller='retrieve', action='askCorrect') 
    43     map.connect('correct/:uri', controller='retrieve', action='correct') 
    44     map.connect('retrieve/:uri', controller = 'retrieve') 
     50##     # This route doesn't match the controller's parameters. 
     51##     #map.connect('csml/:uri', controller='csml_api') 
     52##     # Below is the way it worked before with added 
     53##     # "csml" path component 
     54##     map.connect('csml/:file.:format', controller='csml_api', action='index', 
     55##                 format='html') 
     56##     map.connect('csml/:file/:(feature).:format', action='getFeature', 
     57##                 controller='csml_api', format='html') 
     58##     map.connect('csml/:file/:feature/:action', controller='csml_api') 
    4559 
    46     # This route doesn't match the controller's parameters. 
    47     #map.connect('csml/:uri', controller='csml_api') 
    48     # Below is the way it worked before with added 
    49     # "csml" path component 
    50     map.connect('csml/:file.:format', controller='csml_api', action='index', 
    51                 format='html') 
    52     map.connect('csml/:file/:(feature).:format', action='getFeature', 
    53                 controller='csml_api', format='html') 
    54     map.connect('csml/:file/:feature/:action', controller='csml_api') 
     60##     map.connect('trackback/:uri', controller='trackback') 
     61##     map.connect('discovery',controller='discovery') 
     62##     map.connect('updatetab/:value',controller='tabs',action='update') 
     63##     map.connect('addSelection/:uri/:name',controller='tabs',action='addSelection') 
     64##     map.connect('clear/:value',controller='tabs',action='clear') 
    5565 
    56     map.connect('trackback/:uri', controller='trackback') 
    57     map.connect('discovery',controller='discovery') 
    58     map.connect('updatetab/:value',controller='tabs',action='update') 
    59     map.connect('addSelection/:uri/:name',controller='tabs',action='addSelection') 
    60     map.connect('clear/:value',controller='tabs',action='clear') 
     66    # Channel all WMS requests to one controller 
     67    map.connect('wms', controller='ddp_wms') 
    6168   
    6269    return map 
  • TI05-delivery/ows_framework/branches/ows_framework-ddp/ows_server/ows_server/controllers/ddp_wms.py

    r2693 r2707  
    1212from ows_server.lib.decorators import * 
    1313from ows_server.lib import grid_util, render 
    14 from ows_server.lib.csml_cache import csmlCache, extractCache 
    1514import ows_server.lib.validators as V 
    16  
    17 from elementtree import ElementTree as ET 
    1815 
    1916from ows_common import exceptions as OWS_E 
     
    2219from ows_common.domain import ValuesUnit, PossibleValues 
    2320 
    24 import cdms 
     21from ows_server.models import ddp_data 
     22 
     23#import cdms 
    2524import os, sys 
    2625from cStringIO import StringIO 
    27 import MA 
     26#import MA 
    2827 
    29 class CsmlWmsController(OwsController): 
     28class DdpWmsController(OwsController): 
    3029 
    3130    _ows_parameters = { 
     
    4039    #    } 
    4140 
    42  
    43     def _iterDimensions(self, feature): 
    44         """ 
    45         Retrieve the non-geospatial dimensions of a feature. 
    46  
    47         @return: generator of dimension names 
    48  
    49         """ 
    50         # Waiting for this feature to be implemented 
    51         #lat = feature.getLatitude() 
    52         #lon = feature.getLongitude() 
    53         lat = 'latitude'; lon = 'longitude' 
    54          
    55         for axis_name in feature.getDomain(): 
    56             if axis_name not in [lat, lon]: 
    57                 yield axis_name 
    58  
    59     def _loadFeatureDimensions(self, feature): 
    60         dims = {} 
    61         domain = feature.getDomain() 
    62         for axis_name in self._iterDimensions(feature): 
    63             axis = domain[axis_name] 
    64             dims[axis_name] = Dimension(possibleValues=PossibleValues.fromAllowedValues(axis), 
    65                                         #!TODO: see ticket:770 for how to populate this 
    66                                         valuesUnit=ValuesUnit(uoms=[''], 
    67                                                               referenceSystems=[''])) 
    68         return dims 
    69  
    70     def _loadFeatureSummary(self, feature): 
    71         dims = self._loadFeatureDimensions(feature) 
    72          
    73         return WmsDatasetSummary(identifier=feature.id, 
    74                                  titles=[feature.description.CONTENT], 
    75                                  boundingBoxes=[BoundingBox([-180,-90], [180,90], 
    76                                                             crs='CRS:84')], 
    77                                  dimensions=dims,                
    78                                  ) 
    79  
    8041    def _loadCapabilities(self): 
    8142        """ 
     
    8445        """ 
    8546        # Get default capabilities from superclass 
    86         sm = super(CsmlWmsController, self)._loadCapabilities() 
     47        sm = super(DdpWmsController, self)._loadCapabilities() 
    8748 
    8849        # For WMS 1.3.0 compatibility we need a single root DatasetSummary 
    89         ds = WmsDatasetSummary(titles=['Root Dataset'], datasetSummaries=[], 
     50        ds = WmsDatasetSummary(titles=['DDP Test dataset (afixaa.pei3aug.pp)'], 
     51                               datasetSummaries=[], 
    9052                               CRSs=['CRS:84']) 
    9153        # Add a DatasetSummary for each feature         
    92         for f_n in c.dataset.getFeatureList(): 
    93             feature_ds = self._loadFeatureSummary(c.dataset.getFeature(f_n)) 
    94             ds.datasetSummaries.append(feature_ds) 
     54        #for f_n in c.dataset.getFeatureList(): 
     55        #    feature_ds = self._loadFeatureSummary(c.dataset.getFeature(f_n)) 
     56        #    ds.datasetSummaries.append(feature_ds) 
    9557 
    9658        sm.contents = Contents(datasetSummaries=[ds]) 
     
    12789    @parameter('Exceptions') 
    12890    # Dimension parameters Time, Elevation, etc. are handled separately 
    129     def GetMap(self, file, version, layers, styles, crs, bbox, width, height, format, 
     91    def GetMap(self, version, layers, styles, crs, bbox, width, height, format, 
    13092               transparent=False, bgcolor=None, exceptions=None): 
    13193 
    132         # Retrieve dataset and selected feature 
    133         dataset = csmlCache[file] 
    134         feature = dataset.getFeature(layers) 
    135         if feature is None: 
    136             raise OWS_E.InvalidParameterValue('Layer not found', 'layers') 
     94        variable = layers 
     95         
     96        # Check the layer refers to an available variable 
     97        if variable not in ddp_data.variables: 
     98            raise OWS_E.InvalidParameterValue('Layer not found', 'layers')       
    13799 
    138         # Clean up bbox.  Openlayers can request some very strange bboxes.  It is trimmed 
    139         # here and the implications for the image's aspect ratio is calculated in 
    140         # render.render_variable() 
    141         #!TODO: This could be done better. 
    142         #x1 = max(-180., min(180., bbox[0])) 
    143         #x2 = max(-180., min(180., bbox[2])) 
    144         #y1 = max(-90., min(90., bbox[1])) 
    145         #y2 = max(-90., min(90., bbox[3])) 
     100        # Parse time dimension. 
     101        try: 
     102            time = self.ows_params['time'] 
     103        except KeyError: 
     104            raise OWS_E.MissingParameterValue('time dimension not specified', 'time') 
    146105 
    147         # Define the extraction selector 
    148         #sel = dict(latitude=(y1, y2), longitude=(x1, x2)) 
    149  
    150         # Parse dimensions. 
    151         sel = {} 
    152         for dim in self._iterDimensions(feature): 
    153             # For the moment hard-code time in.  We don't support any other dimension yet. 
    154             if dim.lower() != 'time': 
    155                 raise ValueError('Only lat, lon and time are supported domain axes') 
     106        if time not in ddp_data.time_domain: 
     107            raise OWS_E.InvaludParameterValue('time dimension value incorrect', 'time') 
    156108             
    157             try: 
    158                 sel[dim] = self.ows_params[dim] 
    159             except KeyError: 
    160                 raise OWS_E.MissingParameterValue('%s dimension not specified' % dim, dim) 
    161  
    162         # Get the entire lat/lon slice from the extractCache 
    163         var = extractCache[feature, sel] 
    164  
    165         # Do geographical subsetting in cdms 
    166         var = var(latitude=(bbox[1], bbox[3]), longitude=(bbox[0], bbox[2]), squeeze=1) 
    167  
    168         # Deduce min and max 
    169         #!TODO: How do we get the min/max? 
    170         #varmin = MA.minimum(var, None) 
    171         #varmax = MA.maximum(var, None) 
    172         varmin=0; varmax=100 
    173  
    174         # Render variable to a PIL image 
    175         img = render.render_variable(var, bbox, width, height, varmin, varmax) 
     109        # Get the PIL image for this variable/time 
     110        img = ddp_data.get_image_subset(variable, time, bbox, width, height) 
    176111 
    177112        # Serialise it to PNG 
Note: See TracChangeset for help on using the changeset viewer.