Ignore:
Timestamp:
03/04/08 15:43:09 (12 years ago)
Author:
cbyrom
Message:

Fix Con Terra integration of web client:
Added new template, conterra_xmlconfig.kid to do the creation of
the xmlConfig data to POST.
Changed conterra_aggregate to contain a form which automatically
POSTs a request with the xmlConfig data, when the template is rendered.
Extended selectedItems to include conterra_aggegrage.kid - so that
the selections page is redrawn following a POST to the conterra client.
Also updated the wms_util and WMC python scripts to extract the
required data for the new Con Terra input formats.

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

Legend:

Unmodified
Added
Removed
  • TI05-delivery/ows_framework/trunk/ows_server/ows_server/lib/wmc_util.py

    r3661 r3747  
    1919def getConTerraDoc(wmcURLs): 
    2020    """ 
    21     Construct an aggregated XML file and POST this data to the Con Terra mapClient to visualise 
     21    Construct an aggregated XML file and display this as a temporary webpage; this will automatically be 
     22    POSTED so that the data is sent via POST to the Con Terra mapClient to visualise (as required by this client) 
    2223    @param wmcURLS: An array of URLs pointing to WMC docs to visualise 
    2324    """ 
    24     c.wmcDocs = [] 
     25    # firstly, retrieve each WMC doc 
     26    wmcDocs = [] 
    2527    for wmcURL in wmcURLs: 
    26         c.wmcDocs.append(WMC(wmcURL))  
    27  
    28         # need to send the aggregated data as POST data - so change the request method 
    29     request.method = "POST" 
    30  
    31     # now add the required data, using the aggregate template    
    32     logger.info('Creating XML Config doc for use with Con Terra mapClient') 
    33     request.POST.add('xmlConfig', "<?xml version='1.0' encoding='UTF-8'?><pos:IMCPostConfig SRS='EPSG:4326' xmlns:pos='http://www.conterra.de/mapclient/businesstier/configuration/postinit'><pos:Map ImageFormat='image/png'><pos:WMService url='http://ogc.bgs.ac.uk/cgi-bin/GBR_625k_BGS_Bedrock_and_Superficial_Geology/wms?'></pos:WMService><pos:InitialExtent MinX='-100' MinY='-50' MaxX='100' MaxY='50'></pos:InitialExtent></pos:Map><pos:OverviewMap ImageFormat='image/png'><pos:WMService url='http://www.geographynetwork.com/servlet/com.esri.wms.Esrimap'><pos:AddLayer visible='true'>Continents</pos:AddLayer></pos:WMService></pos:OverviewMap></pos:IMCPostConfig>")#render('conterra_aggregate', format='xml')) 
    34     logger.info('Posting request to mapClient for visualisation') 
    35     h.redirect_to('http://www.gis.bgs.ac.uk:8080/mapClient/postInit.do')#http://www.conterra.de/mapclient/businesstier/configuration/postinit')  
     28        wmcDocs.append(WMC(wmcURL)) 
    3629     
    37 #    response.headers['Content-Type'] = 'text/xml' 
    38 #    response.headers['Content-Disposition'] = 'attachment;filename=wmcAggregate.xml' 
    39 #    return render('conterra_aggregate', format='xml') 
     30    # now create a dictionary of WMS/layer from these docs - to avoid duplicate layers 
     31    c.wms = {} 
     32    for wmcDoc in wmcDocs: 
     33        for layer in wmcDoc.layers: 
     34            if layer.wmsURL not in c.wms: 
     35                c.wms[layer.wmsURL] = [layer.name] 
     36            else: 
     37                if layer.name not in c.wms[layer.wmsURL]: 
     38                    c.wms[layer.wmsURL].append(layer.name) 
     39     
     40    # now create the form to post this data 
     41    logger.info('Creating form doc with data to post to Con Terra mapClient') 
     42    c.redirectToConterra = True; 
     43    response.write(render('selectedItems')) 
     44     
    4045 
    4146     
     
    4550    """ 
    4651    # retrieve context data from the specifiled url 
    47     endpoint = self.inputs['ENDPOINT'] 
    48     if not endpoint: 
    49         raise exceptions.MissingParameterValue, "ENDPOINT parameter required" 
    50     logger.info('Getting WebMapContext from endpoint: ' + endpoint) 
    51  
    52     try: 
    53         filehandle = urllib2.urlopen(endpoint) 
    54     except IOError: 
    55         raise exceptions.URLUnavailable, "Could not access WMC endpoint: %s" % endpoint 
    56          
     52    wmcDoc = RetrieveWebMapContext(self, self.inputs['ENDPOINT']) 
     53     
    5754    response.headers['Content-Type'] = 'text/xml' 
    58     response.write(filehandle.read()) 
     55    response.write(wmcDoc) 
    5956     
    6057 
     
    7673    response.headers['Content-Type'] = 'text/xml' 
    7774    response.write(filehandle.read()) 
     75     
     76def RetrieveWebMapContext(self, endpoint): 
     77    """ 
     78    Get a WMC doc from a specified endpoint 
     79    @param endpoint: endpoint to retrieve WMC doc from 
     80    """ 
     81    if not endpoint: 
     82        raise exceptions.MissingParameterValue, "ENDPOINT parameter required" 
     83    logger.info('Getting WebMapContext from endpoint: ' + endpoint) 
     84 
     85    try: 
     86        filehandle = urllib2.urlopen(endpoint) 
     87    except IOError: 
     88        raise exceptions.URLUnavailable, "Could not access WMC endpoint: %s" % endpoint 
     89 
     90    return filehandle.read() 
    7891         
  • TI05-delivery/ows_framework/trunk/ows_server/ows_server/models/WMC.py

    r3648 r3747  
    5757        helper=nsdumb(self.xml) 
    5858        self.name = helper.getText(self.xml, 'Name') 
    59          
     59        # NB, there may be a better way of getting the href, but the nsdumb doesn't currently 
     60        # support XPATH attribute functionality 
     61        elem = helper.find(self.xml, 'Server/OnlineResource') 
     62        for attribute in elem.attrib: 
     63            if attribute.find('href') > -1: 
     64                self.wmsURL = elem.attrib.get(attribute) 
     65             
    6066 
    6167 
  • TI05-delivery/ows_framework/trunk/ows_server/ows_server/templates/selectedItems.kid

    r3700 r3747  
    44      <script src="$g.server/js/ndgJavascript.js"/> 
    55    </head> 
    6     <body> 
     6    <?python 
     7        onloadAttribute = "" 
     8        if c.redirectToConterra: 
     9                onloadAttribute = "document.forms.ConTerraForm.submit();" 
     10    ?> 
     11    <body onload="${onloadAttribute}"> 
     12    <div id="redirectForm" py:if="c.redirectToConterra"> 
     13        <div py:replace="XML(render('conterra_aggregate',fragment=True, format='xml'))"/> 
     14    </div> 
    715    <div id="entirepage"> 
    816        <div py:replace="header()"/> 
Note: See TracChangeset for help on using the changeset viewer.