Changeset 3280


Ignore:
Timestamp:
28/01/08 16:19:32 (12 years ago)
Author:
mkochan
Message:

Changed the dummy GeoServer? web service to return a GML element. This will normally be either a GML feature or a GML feature collection. The elements are stored in the Pylons stack xml/gml directory.

Location:
DPPP/kml/csml2kml/python/pylonsstack
Files:
10 added
2 edited

Legend:

Unmodified
Added
Removed
  • DPPP/kml/csml2kml/python/pylonsstack/development.ini

    r3273 r3280  
    2222beaker.session.key = pylonsstack 
    2323beaker.session.secret = somesecret 
    24 csml_dir = %(here)s/xml/csml 
     24xml_dir = %(here)s/xml 
    2525 
    2626# If you'd like to fine-tune the individual locations of the cache data dirs 
  • DPPP/kml/csml2kml/python/pylonsstack/pylonsstack/controllers/dummyGeoServer.py

    r3278 r3280  
    22 
    33from pylonsstack.lib.base import * 
    4 from paste.httpexceptions import HTTPBadRequest 
     4from paste.httpexceptions import HTTPBadRequest, HTTPNotFound 
    55 
    66log = logging.getLogger(__name__) 
     
    1111    A mock up GeoServer that we use simply to make sure we are getting the CSML from a URL. 
    1212    The action names and parameters format is completely made up and for temporary development purposes only. 
    13     [NOTE] Concerning GeoServer definition of the term "feature". In GeoServer, any physical "thing" is 
    14            a feature. Therefore a station is *also* a GeoServer feature. In the next iteration, 
    15            dummyGeoServer will only have a feature_id parameter, and this will return either 
    16            whole station CSML or csmlfeature CSML. 
     13    Returns a GML element. This will normally be either a GML feature, or a GML feature collection. 
    1714    ''' 
    1815 
    1916    def GetStationCSMLFeatures(self): 
    2017        ''' 
    21         Return content of an example CSML file (however, with a "wfs" namespace, as supposed to be returned by GeoServer). 
    22         Return the same content -- a feature collection. Supposedly, this would be different for each station, 
    23         i.e. there would be a 'station_id' parameter in GeoServer. 
     18        Return a GML element with unique id specified by the "gml_id" WSGI parameter.  
     19        The returned element will normally be either a GML feature, or a GML feature collection. 
    2420        ''' 
     21        f = None  # a file with GML 
    2522        try: 
    26             station_id = request.params['station_id'] 
    27         except KeyError: 
    28             raise HTTPBadRequest('The "station_id" parameter not supplied') 
    29         csmlDir = (config['app_conf'])['csml_dir'] 
    30         csmlFile = open(csmlDir + '/wfs_featurecollection.xml', 'r') 
    31         csml = csmlFile.read() 
    32         csmlFile.close() 
    33         response.content = csml 
    34         response.content_type = 'text/xml' 
     23            try: 
     24                gml_id = request.params['gml_id'] 
     25            except KeyError: 
     26                raise HTTPBadRequest('GML element not specified (no "gml_id" parameter)') 
     27            else: 
     28                xmlDir = (config['app_conf'])['xml_dir'] 
     29                f = open(xmlDir + '/gml/' + gml_id + '.gml', 'r') 
     30                gml = f.read() 
     31                response.content = gml 
     32                response.content_type = 'text/xml' 
     33        finally: 
     34            if f: 
     35                f.close() 
     36 
Note: See TracChangeset for help on using the changeset viewer.