source: qesdi/wms_ddc_vis/trunk/lib/wms_ddc_vis/templates/wms_capabilities_1_3_0.xml @ 5483

Subversion URL: http://proj.badc.rl.ac.uk/svn/ndg/qesdi/wms_ddc_vis/trunk/lib/wms_ddc_vis/templates/wms_capabilities_1_3_0.xml@5483
Revision 5483, 7.2 KB checked in by pnorton, 11 years ago (diff)

Modified the GetCapabilities? response so that the styles are added to the data summary and picked up by the genshi template.

Line 
1<?xml version="1.0"?>
2
3<?python
4
5from cows.pylons.genshi_util import RenameElementFilter
6from genshi import QName
7from routes import url_for
8
9?>
10
11<WMS_Capabilities xmlns:py="http://genshi.edgewall.org/"
12                  xmlns="http://www.opengis.net/wms"
13                  xmlns:xlink="http://www.w3.org/1999/xlink"
14                  version="1.3.0">
15
16  <!--! ====================================================================== -->
17  <!--!
18      To change the tag name we need to wrap a markup macro in a python
19      function
20  -->
21
22  <Operation py:def="_opContent(op)">
23    <Format py:for="f in op.parameters['Format'].possibleValues.allowedValues" py:content="f"/>
24    <DCPType><HTTP>
25      <Get>
26        <OnlineResource xlink:type="simple" xlink:href="${op.get.href}"/>
27      </Get>
28    </HTTP></DCPType>
29  </Operation>
30  <?python
31 
32  def markupOperation(opName, op):
33    """Render an OWS operation description for the Capabilities section.
34    """
35
36    return RenameElementFilter(QName(opName))(_opContent(op))
37
38  ?>
39
40
41    <py:def function="markupLegendURL(l)">
42      <LegendURL width="${l.width}" height="${l.height}">
43         <Format>${l.format}</Format>
44         <OnlineResource xlink:type="simple" xlink:href="${l.onlineResource.href}"/>
45      </LegendURL>
46    </py:def>
47
48
49    <py:def function="markupStyle(s)">
50      <Style>
51        <Name>${s.name}</Name>
52        <Title>${s.title}</Title>
53        <py:for each="l in s.legendURLs" py:if="getattr(s, 'legendURLs', None) != None">
54          ${markupLegendURL(l)}
55        </py:for>
56      </Style>
57    </py:def>
58
59  <Layer py:def="markupLayer(ds)" queryable="${int(ds.queryable)}">
60    <Name py:content="ds.identifier"/>
61    <Title py:content="ds.titles[0]"/>
62    <Abstract py:if="len(ds.abstracts)>0" py:content="ds.abstracts[0]"/>
63    <CRS py:for="crs in ds.CRSs" py:content="crs"/>
64    <?python exBBox = ds.wgs84BoundingBoxes[0] ?>
65    <EX_GeographicBoundingBox>
66      <westBoundLongitude py:content="exBBox.lowerCorner[0]"/>
67      <eastBoundLongitude py:content="exBBox.upperCorner[0]"/>
68      <southBoundLatitude py:content="exBBox.lowerCorner[1]"/>
69      <northBoundLatitude py:content="exBBox.upperCorner[1]"/>
70    </EX_GeographicBoundingBox>
71
72    <py:for each="bb in ds.boundingBoxes">
73      <BoundingBox CRS="${bb.crs}"
74                   minx="${'%.2f'%bb.lowerCorner[0]}"
75                   miny="${'%.2f'%bb.lowerCorner[1]}"
76                   maxx="${'%.2f'%bb.upperCorner[0]}"
77                   maxy="${'%.2f'%bb.upperCorner[1]}"/>
78    </py:for>
79
80    <!--!TODO Attribution from metadata -->
81    <!--!TODO AuthorityURL from metadata -->
82    <!--!TODO FeatureListURL from metadata -->
83    <!--!TODO Identifier from metadata -->
84    <!--!TODO DataURL from metadata -->
85    <!--!TODO MetadataURL from metadata -->
86   
87    <!--!NOTE: this is an ad-hoc implementation not using the ows_common.model classes
88         TODO: fixme -->
89    <!-- TODO ScaleHint -->
90
91    <Dimension py:for="d_n, d in ds.dimensions.iteritems()"
92               name="${d_n}" units="${d.valuesUnit}"
93               unitSymbol="${d.unitSymbol}"
94               default="${d.defaultValue}" 
95               py:content="','.join(d.possibleValues.allowedValues)"/>
96<!--! nearestValue="${int(d.nearestValue)}" -->
97
98
99    <py:for each="s in ds.styles" py:if="getattr(ds, 'styles', None) != None">
100      ${markupStyle(s)}
101    </py:for>
102
103    <!-- Style>
104      <Name>default</Name>
105      <Title>Default</Title>
106      <LegendURL width="${ds.legendSize[0]}" height="${ds.legendSize[1]}">
107        <Format py:for="f in ds.legendFormats" py:content="f"/>
108        <OnlineResource xlink:type="simple" xlink:href="${url_for(qualified=True, action='index')}?request=GetLegend&amp;layers=${ds.identifier}"/>
109      </LegendURL>
110    </Style -->
111
112
113  </Layer>
114
115  <!--! ====================================================================== -->
116
117
118  <Service py:with="sm=c.capabilities; si=c.capabilities.serviceIdentification">
119    <Name>WMS</Name>
120    <Title py:content="si.titles[0]"/>
121    <Abstract py:if="len(si.abstracts)>0" py:content="si.abstracts[0]"/>
122    <KeywordList>
123      <Keyword py:for="kw in si.keywords"
124               py:content="kw"/>
125    </KeywordList>
126    <OnlineResource xlink:type="simple" xlink:href="${url_for(qualified=True, action='index')}?"/>
127   
128    <ContactInformation py:if="sm.serviceProvider is not None"
129                        py:with="rp=sm.serviceProvider.serviceContact">
130      <ContactPersonPrimary>
131        <ContactPerson py:if="rp is not None" py:content="rp.individualName"/>
132        <ContactOrganization py:content="sm.serviceProvider.providerName"/>
133      </ContactPersonPrimary>
134      <ContactPosition py:content="rp.positionName"/>
135
136      <py:with vars="cn=rp.contactInfo" py:if="rp.contactInfo is not None">
137        <ContactAddress py:if="cn.address is not None">
138          <AddressType>postal</AddressType>
139          <Address>
140            <py:for each="d in cn.address.deliveryPoints">${d}</py:for>
141          </Address>
142          <City py:content="cn.address.city"/>
143          <StateOrProvince py:content="cn.address.administrativeArea"/>
144          <PostCode py:content="cn.address.postalCode"/>
145          <Country py:content="cn.address.country"/>
146        </ContactAddress>
147        <ContactVoiceTelephone py:if="cn.phone is not None"
148                               py:content="cn.phone.voice"/>
149        <ContactFacsimileTelephone py:if="cn.phone is not None"
150                                   py:content="cn.phone.facsimile"/>
151        <ContactElectronicMailAddress py:if="cn.address is not None"
152                                      py:content="cn.address.electronicMailAddress"/>
153      </py:with>
154    </ContactInformation>
155   
156    <Fees py:content="si.fees"/>
157    <AccessConstraints py:content="si.accessConstraints"/>
158
159    <!--!TODO: These are hardcoded for Jon Blower's WMS->KML service.  Make generic.-->
160    <LayerLimit>1</LayerLimit>
161    <MaxWidth>640</MaxWidth>
162    <MaxHeight>640</MaxHeight>
163
164  </Service>
165  <!--! These fields are represented in ows_common as service constraints -->
166  <Capability py:with="sm=c.capabilities; om=sm.operationsMetadata">
167    <py:if test="om is not None">
168      <?python
169        ops = ['GetCapabilities', 'GetMap', 'GetFeatureInfo']
170        eops = [x for x in om.operationDict.keys() if x not in ops]
171      ?>
172      <Request>
173        <py:for each="opName in ops" py:if="opName in om.operationDict.keys()">
174          <span py:content="markupOperation(opName, om.operationDict[opName])" py:strip="True"/>
175        </py:for>
176        <py:for each="opName in ops" py:if="opName in om.operationDict.keys()">
177          <?python exceptions = om.operationDict[opName].parameters.get('ExceptionFormat') ?>
178          <Exception py:if="exceptions is not None">
179            <Format py:for="e in exceptions.possibleValues.allowedValues"
180                    py:content="e"/>
181          </Exception>
182        </py:for>
183      </Request>
184
185      <!--!TODO:  capability exceptions -->
186      <Exception><Format>text/xml</Format></Exception>     
187     
188      <_ExtendedCapabilities>
189      <Request>
190        <py:for each="opName in eops">
191          <span py:content="markupOperation(opName, om.operationDict[opName])" py:strip="True"/>
192        </py:for>
193        <py:for each="opName in eops">
194          <?python exceptions = om.operationDict[opName].parameters.get('ExceptionFormat') ?>
195          <Exception py:if="exceptions is not None">
196            <Format py:for="e in exceptions.possibleValues.allowedValues"
197                    py:content="e"/>
198          </Exception>
199        </py:for>
200      </Request>
201      </_ExtendedCapabilities>
202    </py:if>
203   
204    <Layer py:if="sm.contents is not None">
205      <Title>Contents</Title>
206      <Layer py:for="ds in sm.contents.datasetSummaries"
207             py:replace="markupLayer(ds)">
208      </Layer>
209    </Layer>
210  </Capability>
211</WMS_Capabilities>
Note: See TracBrowser for help on using the repository browser.