Ignore:
Timestamp:
21/02/08 11:50:46 (12 years ago)
Author:
cbyrom
Message:

Create new object, WMC, which retrieves a WMC doc, given a valid URL, and then
extracts required info for the kid templates to produce the Con Terra input
file. Adjust these templates + the selectedItems controller to interface
with new object. NB, the templates are not fully implemented, pending updates
from Con Terra on new input format.

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

Legend:

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

    r3472 r3483  
    229229                                                 action='index'))) 
    230230                             
    231                 return render_response('results') 
     231                return Response(render('results')) 
    232232                 
    233233        except ValueError,e: 
  • TI05-delivery/ows_framework/trunk/ows_server/ows_server/controllers/selectedItems.py

    r3472 r3483  
    3434 
    3535        elif 'PlotSelectedInConTerra' in self.inputs: 
    36             # TODO: not yet implemented 
     36            # get all selected selections 
    3737            self.getSelectedItems() 
     38 
     39            # ensure selections have been made 
     40            if 'selectedItems' in session: 
     41                wmcURLs = [] 
     42                for item in session['selectedItems']: 
     43                    if (item.wmcURL): 
     44                        wmcURLs.append(item.wmcURL) 
     45                return getConTerraDoc(wmcURLs) 
    3846         
    3947        else: 
     48            # Check to see if individual con terra plots have been requested 
    4049            for input in self.inputs: 
    4150                if str(input).startswith('PlotConTerra____'): 
    4251                    # if here a WMC has been requested to be plotted 
    4352                    # - get the URL and plot 
    44                     dummy, url = str(input).split('____') 
     53                    dummy, wmcURL = str(input).split('____') 
    4554                    # NB, the image key that we're parsing has either .x or .y at the end 
    46                     url = url[0:len(url)-2] 
    47                     urls = [url] 
    48                     return getConTerraDoc(urls) 
     55                    wmcURL = wmcURL[0:len(wmcURL)-2] 
     56                    wmcURLs = [wmcURL] 
     57                    return getConTerraDoc(wmcURLs) 
    4958             
    5059        return Response(render('selectedItems'), code=200) 
     
    7079                    if selection.entryID in entryID: 
    7180                        newSelection = copy.deepcopy(selection) 
     81                        # NB, cope with multiple WMC/KML urls by splitting these 
     82                        # into multiple rows and redefining the selection item URL appropriately 
    7283                        url = None 
    7384                        if len(selection.kmlList) > i: 
  • TI05-delivery/ows_framework/trunk/ows_server/ows_server/lib/wmc_util.py

    r3473 r3483  
    1212from ows_server.models.DocumentRetrieve import genericHTTP 
    1313from ows_server.models.ETxmlView import loadET,et2text, nsdumb 
    14 #import urllib2 
    15  
    16 try: #python 2.5 
    17     from xml.etree import ElementTree as ET 
    18 except ImportError: 
    19     try: 
    20         # if you've installed it yourself it comes this way 
    21         import ElementTree as ET 
    22     except ImportError: 
    23         # if you've egged it this is the way it comes 
    24         from elementtree import ElementTree as ET 
     14from ows_server.models.WMC import WMC 
    2515 
    2616def getWMCDocLayer(url): 
     
    5242    x=genericHTTP(proxyServer='http://wwwcache3.rl.ac.uk:8080/') 
    5343    wmcDoc = x.get(url) #urllib2.urlopen(url) 
    54 #    wmcTree = loadET(wmcDoc)  
    55     wmcTree = ET.fromstring(wmcDoc) 
    56 #    wmcTree = nsdumb(wmcTree) 
    57 #        self.metadataType='DIF' 
    58 #        if helper.strip(self.tree.tag)!=self.metadataType:  
    59 #            self.tree=helper.find(self.tree,self.metadataType) 
    60 #            if self.tree is None:  
    61 #                raise ValueError, 'DIF input does not include a DIF element:\n%s'%self.xml 
     44    wmcTree = loadET(wmcDoc)  
    6245 
    6346    return wmcTree 
    6447 
    65 def getConTerraDoc(urls): 
     48def getConTerraDoc(wmcURLs): 
    6649    """ 
    6750    Uses an array of WMC URLs to construct an aggregation to allow the data 
    6851    to be plotted in Con Terra 
    6952    """ 
    70     session['wmcURLs'] = urls 
     53    c.wmcDocs = [] 
     54    for wmcURL in wmcURLs: 
     55        c.wmcDocs.append(WMC(wmcURL))  
    7156    session.save() 
    7257 
  • TI05-delivery/ows_framework/trunk/ows_server/ows_server/templates/conterra_aggregate.kid

    r3472 r3483  
    1 <?xml version="1.0" encoding="UTF-8" py:extends="'icmap_elements.kid'" standalone="yes"?> 
     1<?xml version="1.0" encoding="UTF-8" ?> 
    22<?python 
    33        from ows_server.lib.wmc_util import * 
    44?> 
    5 <ViewContext id="Conterra_MapClient" version="1.1.0" xmlns="http://www.opengis.net/context" xmlns:py="http://purl.org/kid/ns#"> 
     5<ViewContext id="Conterra_MapClient" version="1.1.0" xmlns="http://www.opengis.net/context" xmlns:py="http://purl.org/kid/ns#" py:extends="'icmap_elements.kid'"> 
    66    <General> 
    77        <Window height="570" width="714"/> 
     
    2323                    </ns2:node> 
    2424                </ns2:tcHierarchy>             
    25                 <ns3:IMCMapLayerConfig xmlns:ns2="http://www.conterra.de/mapclient/businesstier/configuration/layer"> 
    26                     <!-- NB, don't forget to include the following: 
    27                             <ns3:IMCDatasource ClassName="de.conterra.suite.adapter.wms.WMSDatasource" ID="1" PooledConnections="0"> 
    28                             <ns3:IMC_URL_Connection URL="http://www2.demis.nl/mapserver/Request.asp?"/> 
    29                             </ns3:IMCDatasource> 
    30                         --> 
    31                     <span py:for="i,d in enumerate(c.difs)" py:replace="createICMAPElement(i,d)"/> 
     25                <ns3:IMCMapLayerConfig xmlns:ns3="http://www.conterra.de/mapclient/businesstier/configuration/layer"> 
     26                        <span py:for="i, wmc in enumerate(c.wmcDocs)" py:replace="createIMCDatasourceElement(i,wmc)" py:strip="True"/> 
    3227 
    33                                         <!-- not sure if we need to get the SRS value here --> 
     28                                        <!-- not sure if we need to get the correct SRS value here --> 
    3429                    <ns3:IMCMap ImageFormat="image/png" SRS="EPSG:4326" SRSList="EPSG:4326"> 
     30                            <!-- NB, don't forget to include the following: 
     31                                    <ns3:IMCDatasource ClassName="de.conterra.suite.adapter.wms.WMSDatasource" ID="1" PooledConnections="0"> 
     32                                    <ns3:IMC_URL_Connection URL="http://www2.demis.nl/mapserver/Request.asp?"/> 
     33                                    </ns3:IMCDatasource> 
     34                            --> 
     35                            <for py:for="i,wmc in enumerate(c.wmcDocs)" py:strip="True"> 
     36                                <span py:for="j,layer in enumerate(wmc.layers)" py:replace="createICMAPContentElement(i,layer)" py:strip="True"/> 
     37                        </for> 
     38                                        </ns3:IMCMap> 
    3539 
    36                         <ns2:IMCMapContentElement ID="1" NameKey="Countries " canSetVisible="true" legendGraphic="" legendVisible="false" persistentToWMC="false" showInContent="true" showInLegend="true" visible="true"> 
    37                             <ns2:IMCLayer ClassName="de.conterra.suite.adapter.wms.WMSLayer" CoverFileWorkerID="-1" ID="1" LayerID="Countries" LegendVisibility="false" MapServiceID="1" Visibility="true"/> 
    38                         </ns2:IMCMapContentElement> 
    39                         <ns2:IMCMapContentElement ID="2" NameKey="Great Britain" canSetVisible="true" legendGraphic="" legendVisible="false" persistentToWMC="false" showInContent="true" showInLegend="true" visible="true"> 
    40                             <ns2:IMCLayer ClassName="de.conterra.suite.adapter.wms.WMSLayer" CoverFileWorkerID="-1" ID="2" LayerID="GreatBritain" LegendVisibility="false" MapServiceID="1" Visibility="true"/> 
    41                         </ns2:IMCMapContentElement> 
    42                         <ns2:IMCMapContentElement ID="4" NameKey="Settlements" canSetVisible="true" legendGraphic="" legendVisible="false" persistentToWMC="false" showInContent="true" showInLegend="true" visible="true"> 
    43                             <ns2:IMCLayer ClassName="de.conterra.suite.adapter.wms.WMSLayer" CoverFileWorkerID="-1" ID="4" LayerID="Settlements" LegendVisibility="false" MapServiceID="1" Visibility="true"/> 
    44                         </ns2:IMCMapContentElement> 
    45                         <ns2:IMCInitialExtent MaxX="5.704144788849584" MaxY="62.34738779056453" MinX="-12.465118369045149" MinY="47.8425138409847"/> 
    46                         <ns2:IMCFullExtent MaxX="180.0" MaxY="85.0" MinX="-184.0" MinY="-90.0"/> 
    47                     </ns2:IMCMap> 
    48                     <ns2:IMCOverviewMap visible="true" ImageFormat="image/png" SRS="EPSG:4326" SRSList="EPSG:4326,EPSG:27700"> 
    49                         <ns2:IMCMapContentElement ID="5" NameKey="Countries " canSetVisible="true" legendVisible="false" persistentToWMC="false" showInContent="true" showInLegend="true" visible="true"> 
    50                             <ns2:IMCLayer ClassName="de.conterra.suite.adapter.wms.WMSLayer" CoverFileWorkerID="-1" ID="5" LayerID="Countries" LegendVisibility="true" MapServiceID="1" Visibility="true"/> 
    51                         </ns2:IMCMapContentElement> 
    52                         <ns2:IMCMapContentElement ID="6" NameKey="Great Britain" canSetVisible="true" legendVisible="false" persistentToWMC="false" showInContent="true" showInLegend="true" visible="true"> 
    53                             <ns2:IMCLayer ClassName="de.conterra.suite.adapter.wms.WMSLayer" CoverFileWorkerID="-1" ID="6" LayerID="GreatBritain" LegendVisibility="true" MapServiceID="1" Visibility="true"/> 
    54                         </ns2:IMCMapContentElement> 
    55                         <ns2:IMCInitialExtent MaxX="180.0" MaxY="143.61267605633805" MinX="-184.0" MinY="-148.61267605633805"/> 
    56                         <ns2:IMCFullExtent MaxX="180.0" MaxY="85.0" MinX="-184.0" MinY="-90.0"/> 
    57                     </ns2:IMCOverviewMap> 
    58                 </ns2:IMCMapLayerConfig> 
     40                    <ns3:IMCOverviewMap visible="true" ImageFormat="image/png" SRS="EPSG:4326" SRSList="EPSG:4326"> 
     41                        <ns3:IMCMapContentElement ID="3" NameKey="Countries " canSetVisible="true" legendVisible="false" persistentToWMC="false" showInContent="true" showInLegend="true" visible="true"> 
     42                            <ns3:IMCLayer ClassName="de.conterra.suite.adapter.wms.WMSLayer" CoverFileWorkerID="-1" ID="3" LayerID="Countries" LegendVisibility="true" MapServiceID="1" Visibility="true"/> 
     43                        </ns3:IMCMapContentElement> 
     44                        <ns3:IMCInitialExtent MaxX="180.0" MaxY="115.37564766839378" MinX="-184.0" MinY="-120.37564766839378"/> 
     45                        <ns3:IMCFullExtent MaxX="180.0" MaxY="85.0" MinX="-184.0" MinY="-90.0"/> 
     46                    </ns3:IMCOverviewMap> 
     47                                </ns3:IMCMapLayerConfig> 
    5948            </ns1:IMCWmcExtension> 
    6049        </Extension> 
    6150    </General> 
    6251    <LayerList> 
    63             <for py:for="url in session['wmcURLs']" py:strip="True" > 
    64                 ${XML(getWMCDocLayer(url))} 
     52        <for py:for="i,wmc in enumerate(c.wmcDocs)" py:strip="True"> 
     53                <span py:for="j,layer in enumerate(wmc.layers)" py:replace="layer" py:strip="True"/> 
    6554        </for> 
    6655    </LayerList> 
  • TI05-delivery/ows_framework/trunk/ows_server/ows_server/templates/icmap_elements.kid

    r3472 r3483  
    11<!-- This is a bunch of named functions for use when creating input files for Con Terra --> 
    2 <html xmlns="http://www.w3.org/1999/xhtml" xmlns:py="http://purl.org/kid/ns#"> 
     2<html xmlns="http://www.w3.org/1999/xhtml" xmlns:py="http://purl.org/kid/ns#"  
     3        xmlns:ns3="http://www.conterra.de/mapclient/businesstier/configuration/layer" 
     4        xmlns:ns2="http://www.conterra.de/mapclient/businesstier/configuration/hierarchy"> 
    35 
    4     <span py:def="createICMAPElement(i,d)"> 
    5         <ns2:IMCMapContentElement ID="${i}" NameKey="BGS Bedrock Lithostratigraphy" canSetVisible="true" showInLegend="true" visible="false"> 
    6                 <ns2:IMCLayer ClassName="de.conterra.suite.adapter.wms.WMSLayer" ID="4" LayerID="bedrock_lithostratigraphy" LegendVisibility="true" MapServiceID="2" Visibility="true"/> 
    7                         <ns2:IMCIdentify ChainID="0" ClassName="de.conterra.mapclient.businesstier.mapprocessing.query.IMCMapQueryElement" DatasourceID="2" IMCLayerID="4" MaxResults="10" NameKey="BGS Bedrock Lithostratigraphy" action="IdentifyResultClick"> 
     6    <span py:def="createIMCDatasourceElement(i,wmc)" py:strip="True"> 
     7        <ns3:IMCDatasource ClassName="de.conterra.suite.adapter.wms.WMSDatasource" ID="${i}" PooledConnections="0"> 
     8                <ns3:IMC_URL_Connection URL="${wmc.url}" /> 
     9        </ns3:IMCDatasource> 
     10        <ns3:IMCMapService Alias="${wmc.title}" DatasourceID="${i}" ID="${i}" Name="${wmc.title}" Opacity="100" RGBTranscolor="255,255,255" Type="Image" showInContent="true" treeNodeID="32807" visible="true"/> 
     11        </span>     
     12 
     13    <span py:def="createICMAPContentElement(i,layer)" py:strip="True"> 
     14        <ns2:IMCMapContentElement ID="${i}" NameKey="layer.title" canSetVisible="true" showInLegend="true" visible="false"> 
     15                <ns2:IMCLayer ClassName="de.conterra.suite.adapter.wms.WMSLayer" ID="${i}" LayerID="layer.name" LegendVisibility="true" MapServiceID="${i}" Visibility="true"/> 
     16                        <ns2:IMCIdentify ChainID="0" ClassName="de.conterra.mapclient.businesstier.mapprocessing.query.IMCMapQueryElement" DatasourceID="${i}" IMCLayerID="${i}" MaxResults="10" NameKey="layer.title" action="IdentifyResultClick"> 
    817                <ns2:IMCDataBaseKeyField OperatorList="0" AliasKey="dummy" Name="dummy" Type="String"> 
    918                        <ns2:IMCDataBaseResultField AliasKey="dummy" Name="dummy" Type="String"/> 
     
    1221                </ns2:IMCMapContentElement> 
    1322        </span>     
    14  
    15     <span py:def="createIMCDatasourceElement(i,j,url,name)"> 
    16         <ns3:IMCDatasource ClassName="de.conterra.suite.adapter.wms.WMSDatasource" ID="${i}" PooledConnections="0"> 
    17                 <ns3:${url}"/> 
    18         </ns3:IMCDatasource> 
    19         <ns3:IMCMapService Alias="${name}" DatasourceID="${i}" ID="${j}" Name="${name}" Opacity="100" RGBTranscolor="255,255,255" Type="Image" showInContent="true" treeNodeID="32807" visible="true"/> 
    20         </span>     
    21          
    22          
    2323         
    2424</html> 
Note: See TracChangeset for help on using the changeset viewer.