Changeset 3567 for DPPP


Ignore:
Timestamp:
07/03/08 16:40:22 (11 years ago)
Author:
mkochan
Message:

Changes to CSML grapher (unfinished)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • DPPP/kml/csml2kml/python/pylonsstack/pylonsstack/controllers/csmlGrapher.py

    r3566 r3567  
    108108            response.content = buf.getvalue() 
    109109             
    110         #------------------------------------------------------------------------------------------------------------------- 
     110        #---------------------- 
    111111 
    112112        # Get parameters from the request object 
     
    120120        lowerTimeBoundary = '1-JAN-2003'  # hard-coded for now 
    121121        upperTimeBoundary = '1-FEB-2004'  # hard-coded for now 
    122         geoServerRequestUrl = 'http://130.246.76.98:8084/geoserver/wfs?request=getfeature&service=wfs&version=1.1.0&typename=%20csml:PointSeriesFeature&filter=%3Cogc:Filter%20xmlns:ogc=%22http://www.opengis.net/ogc%22%20xmlns:gml=%22http://www.opengis.net/gml%22%3E%3Cogc:And%3E%3Cogc:PropertyIsEqualTo%3E%3Cogc:PropertyName%3Egml:description%3C/ogc:PropertyName%3E%3Cogc:Literal%3E%s%3C/ogc:Literal%3E%3C/ogc:PropertyIsEqualTo%3E%3Cogc:PropertyIsEqualTo%3E%3Cogc:PropertyName%3Ecsml:parameter/swe:Phenomenon/gml:name%3C/ogc:PropertyName%3E%3Cogc:Literal%3E%s%3C/ogc:Literal%3E%3C/ogc:PropertyIsEqualTo%3E%3Cogc:PropertyIsBetween%3E%3Cogc:PropertyName%3Ecsml:value/csml:PointSeriesCoverage/csml:pointSeriesDomain/csml:TimeSeries/csml:timePositionList%3C/ogc:PropertyName%3E%3Cogc:LowerBoundary%3E%3Cogc:Literal%3E%s%3C/ogc:Literal%3E%3C/ogc:LowerBoundary%3E%3Cogc:UpperBoundary%3E%3Cogc:Literal%3E%s%3C/ogc:Literal%3E%3C/ogc:UpperBoundary%3E%3C/ogc:PropertyIsBetween%3E%3C/ogc:And%3E%3C/ogc:Filter%3E' % (station_name, feature_id, lowerTimeBoundary, upperTimeBoundary) 
     122        geoServerRequestUrl = 'http://130.246.76.98:8084/geoserver/wfs?request=getfeature&service=wfs&version=1.1.0&typename=%20csml:PointSeriesFeature&filter=<ogc:Filter%20xmlns:ogc="http://www.opengis.net/ogc"%20xmlns:gml="http://www.opengis.net/gml"><ogc:And><ogc:PropertyIsEqualTo><ogc:PropertyName>gml:description</ogc:PropertyName><ogc:Literal>'+ station_name +'</ogc:Literal></ogc:PropertyIsEqualTo><ogc:PropertyIsEqualTo><ogc:PropertyName>csml:parameter/swe:Phenomenon/gml:name</ogc:PropertyName><ogc:Literal>'+ feature_id +'</ogc:Literal></ogc:PropertyIsEqualTo><ogc:PropertyIsBetween><ogc:PropertyName>csml:value/csml:PointSeriesCoverage/csml:pointSeriesDomain/csml:TimeSeries/csml:timePositionList</ogc:PropertyName><ogc:LowerBoundary><ogc:Literal>'+ lowerTimeBoundary +'</ogc:Literal></ogc:LowerBoundary><ogc:UpperBoundary><ogc:Literal>'+ upperTimeBoundary +'</ogc:Literal></ogc:UpperBoundary></ogc:PropertyIsBetween></ogc:And></ogc:Filter>' 
     123 
     124        # [NOTE] Need to experiment with encoding for this request -- this one does not work. Maybe 
     125        #        return back to using URL escape characters, and play around with it? 
     126        #geoServerRequestUrl = 'http://130.246.76.98:8084/geoserver/wfs?request=getfeature&service=wfs&version=1.1.0&typename=%20csml:PointSeriesFeature&filter=%3Cogc:Filter%20xmlns:ogc=%22http://www.opengis.net/ogc%22%20xmlns:gml=%22http://www.opengis.net/gml%22%3E%3Cogc:And%3E%3Cogc:PropertyIsEqualTo%3E%3Cogc:PropertyName%3Egml:description%3C/ogc:PropertyName%3E%3Cogc:Literal%3E' + station_name + '%3C/ogc:Literal%3E%3C/ogc:PropertyIsEqualTo%3E%3Cogc:PropertyIsEqualTo%3E%3Cogc:PropertyName%3Ecsml:parameter/swe:Phenomenon/gml:name%3C/ogc:PropertyName%3E%3Cogc:Literal%3E' + feature_id + '%3C/ogc:Literal%3E%3C/ogc:PropertyIsEqualTo%3E%3Cogc:PropertyIsBetween%3E%3Cogc:PropertyName%3Ecsml:value/csml:PointSeriesCoverage/csml:pointSeriesDomain/csml:TimeSeries/csml:timePositionList%3C/ogc:PropertyName%3E%3Cogc:LowerBoundary%3E%3Cogc:Literal%3E' + lowerTimeBoundary + '%3C/ogc:Literal%3E%3C/ogc:LowerBoundary%3E%3Cogc:UpperBoundary%3E%3Cogc:Literal%3E' + upperTimeBoundary + '%3C/ogc:Literal%3E%3C/ogc:UpperBoundary%3E%3C/ogc:PropertyIsBetween%3E%3C/ogc:And%3E%3C/ogc:Filter%3E' 
     127 
     128        # Get the GeoServer response and parse it in as a CSML PointSeriesFeature 
    123129        geoServerResponse = wget(geoServerRequestUrl) 
    124         tree = ElementTree(XML(geoServerResponse)) 
     130        fc = csml.parser.CSMLFeatureCollection() 
     131        fc.fromXML( XML(geoServerResponse) ) 
     132        raise ValueError('Oops') 
    125133 
    126         # [TODO] Split this code into two separate service calls -- one for listing features per station 
    127         #        and another the actual grapher. 
    128         if station_id: 
    129  
    130             # --- [NOTE] Keeping until ruled as obsolete --- 
    131  
    132             # Parse in the feature collection 
    133             fc = csml.parser.CSMLFeatureCollection() 
    134             fc.fromXML(tree.getroot()) 
    135  
    136         else: 
    137              
    138             # Parse in the feature directly 
    139             feature = csml.parser.PointSeriesFeature() 
    140             feature.fromXML(tree.getroot()) 
    141  
     134        # If there was a parsing error, raise an exception 
    142135        if not feature: 
    143136            raise HTTPNotFound('Feature not found') 
    144137             
    145         # Try to plot the feature into a temporary file, and put the contents of that file into the WSGI response 
     138        # Try to plot the feature into a temporary file, and put the contents of that file into the response 
    146139        try: 
    147140            tempFile = _plot_feature(feature)              # plot the feature into a temporary file 
    148             _set_response(tempFile)                        # set WSGI response as an image containing the plot 
     141            _set_response(tempFile)                        # set the response as an image containing the plot 
    149142        finally: 
    150143            try: 
     
    155148    def list(self): 
    156149        '''Handler for generating a list of CSML features per station, with dynamic links to the plot service.''' 
    157         pass 
     150 
     151        # Get parameters from the request object 
     152        try: 
     153            feature_id = request.params['feature_id'] 
     154            station_name = request.params['station_name'] 
     155        except KeyError: 
     156            raise HTTPBadRequest('Parameters "feature_id" and "station_id" must be supplied.') 
     157 
     158        # [NOTE] Should use: fc = csml.parser.CSMLFeatureCollection() 
Note: See TracChangeset for help on using the changeset viewer.