source: cows/trunk/cows/pylons/templates/wms_capabilities_1_3_0.xml @ 6393

Subversion URL: http://proj.badc.rl.ac.uk/svn/ndg/cows/trunk/cows/pylons/templates/wms_capabilities_1_3_0.xml@6393
Revision 6393, 8.8 KB checked in by pnorton, 10 years ago (diff)

First attempt at trying to implement a folder structure for the csml files.

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<?python
42
43    def showAtt(obj, attname):
44        if not hasattr(obj,attname) or getattr(obj, attname) == None:
45            return ''
46           
47        return getattr(obj, attname)
48         
49
50?>
51
52    <py:def function="markupLegendURL(l)">
53      <LegendURL width="${l.width}" height="${l.height}">
54         <Format>${l.format}</Format>
55         <OnlineResource xlink:type="simple" xlink:href="${l.onlineResource.href}"/>
56      </LegendURL>
57    </py:def>
58
59
60    <py:def function="markupStyle(s)">
61      <Style>
62        <Name>${s.name}</Name>
63        <Title>${s.title}</Title>
64        <py:for each="l in s.legendURLs" py:if="getattr(s, 'legendURLs', None) != None">
65          ${markupLegendURL(l)}
66        </py:for>
67      </Style>
68    </py:def>
69   
70    <py:def function="markupMetadataURL(l)">
71      <MetadataURL type="${showAtt(l, 'type')}" >
72         <Format>${l.format}</Format>
73         <OnlineResource xlink:type="simple" xlink:href="${l.onlineResource.href}"/>
74      </MetadataURL>
75    </py:def>   
76
77  <Layer py:def="markupLayer(ds)" queryable="${int(ds.queryable)}">
78 
79    <py:if test="ds.identifier is not None">
80            <Name py:content="ds.identifier"/>
81    </py:if>
82   
83    <Title py:content="ds.titles[0]"/>
84    <Abstract py:if="len(ds.abstracts)>0" py:content="ds.abstracts[0]"/>
85   
86
87    <py:if test="ds.CRSs is not None">   
88        <CRS py:for="crs in ds.CRSs" py:content="crs"/>
89    </py:if>
90   
91    <py:if test="ds.wgs84BoundingBoxes[0] is not None">
92   
93            <?python exBBox = ds.wgs84BoundingBoxes[0] ?>
94            <EX_GeographicBoundingBox>
95              <westBoundLongitude py:content="exBBox.lowerCorner[0]"/>
96              <eastBoundLongitude py:content="exBBox.upperCorner[0]"/>
97              <southBoundLatitude py:content="exBBox.lowerCorner[1]"/>
98              <northBoundLatitude py:content="exBBox.upperCorner[1]"/>
99            </EX_GeographicBoundingBox>
100    </py:if>
101
102    <py:for each="bb in ds.boundingBoxes">
103      <BoundingBox CRS="${bb.crs}"
104           minx="${'%.2f'%bb.lowerCorner[0]}"
105           miny="${'%.2f'%bb.lowerCorner[1]}"
106           maxx="${'%.2f'%bb.upperCorner[0]}"
107           maxy="${'%.2f'%bb.upperCorner[1]}"/>
108    </py:for>
109
110    <!--!TODO Attribution from metadata -->
111    <!--!TODO AuthorityURL from metadata -->
112    <!--!TODO FeatureListURL from metadata -->
113    <!--!TODO Identifier from metadata -->
114    <!--!TODO DataURL from metadata -->
115    <!--!TODO MetadataURL from metadata -->
116   
117    <!--!NOTE: this is an ad-hoc implementation not using the ows_common.model classes
118         TODO: fixme -->
119    <!--!TODO ScaleHint -->
120
121    <Dimension py:for="d_n, d in ds.dimensions.iteritems()"
122           name="${d_n}" units="${d.valuesUnit}"
123           unitSymbol="${d.unitSymbol}"
124           default="${d.defaultValue}" 
125           py:content="','.join(d.possibleValues.allowedValues)"/>
126<!--! nearestValue="${int(d.nearestValue)}" -->
127
128    <!--!NOTE: if there is no identifier then the layer can never be selected
129               so don't need to bother with styles or metadata urls -->
130    <py:if test="ds.identifier is not None">
131   
132            <py:choose test="ds.styles">
133       
134                <py:when test="['']">
135                    <Style>
136                        <Name>default</Name>
137                        <Title>Default</Title>
138                        <LegendURL width="${ds.legendSize[0]}" height="${ds.legendSize[1]}">
139                            <Format py:for="f in ds.legendFormats" py:content="f"/>
140                            <OnlineResource xlink:type="simple" xlink:href="${url_for(qualified=True, action='index')}?request=GetLegend&amp;layers=${ds.identifier}"/>
141                        </LegendURL>
142                    </Style>
143                </py:when>
144       
145                <py:otherwise>
146                    <py:for each="s in ds.styles" py:if="getattr(ds, 'styles', None) != None">
147                        ${markupStyle(s)}
148                    </py:for>
149                </py:otherwise>
150       
151            </py:choose>
152           
153            <py:if test="len(ds.metadataURLs) > 0">
154                <py:for each="url in ds.metadataURLs">
155                    ${markupMetadataURL(url)}
156                </py:for>
157            </py:if>
158           
159    </py:if>
160
161
162    <Layer py:for="c in ds.children" py:replace="markupLayer(c)"></Layer>
163
164  </Layer>
165
166  <!--! ====================================================================== -->
167
168
169  <Service py:with="sm=c.capabilities; si=c.capabilities.serviceIdentification">
170    <Name>WMS</Name>
171    <Title py:content="si.titles[0]"/>
172    <Abstract py:if="len(si.abstracts)>0" py:content="si.abstracts[0]"/>
173    <KeywordList>
174      <Keyword py:for="kw in si.keywords"
175           py:content="kw"/>
176    </KeywordList>
177    <OnlineResource xlink:type="simple" xlink:href="${url_for(qualified=True, action='index')}?"/>
178   
179    <ContactInformation py:if="sm.serviceProvider is not None"
180            py:with="rp=sm.serviceProvider.serviceContact">
181      <ContactPersonPrimary>
182    <ContactPerson py:if="rp is not None" py:content="rp.individualName"/>
183    <ContactOrganization py:content="sm.serviceProvider.providerName"/>
184      </ContactPersonPrimary>
185      <ContactPosition py:content="rp.positionName"/>
186
187      <py:with vars="cn=rp.contactInfo" py:if="rp.contactInfo is not None">
188    <ContactAddress py:if="cn.address is not None">
189      <AddressType>postal</AddressType>
190      <Address>
191        <py:for each="d in cn.address.deliveryPoints">${d}</py:for>
192      </Address>
193      <City py:content="cn.address.city"/>
194      <StateOrProvince py:content="cn.address.administrativeArea"/>
195      <PostCode py:content="cn.address.postalCode"/>
196      <Country py:content="cn.address.country"/>
197    </ContactAddress>
198    <ContactVoiceTelephone py:if="cn.phone is not None"
199                   py:content="cn.phone.voice"/>
200    <ContactFacsimileTelephone py:if="cn.phone is not None"
201                   py:content="cn.phone.facsimile"/>
202    <ContactElectronicMailAddress py:if="cn.address is not None"
203                      py:content="cn.address.electronicMailAddress"/>
204      </py:with>
205    </ContactInformation>
206   
207    <Fees py:content="si.fees"/>
208    <AccessConstraints py:content="si.accessConstraints"/>
209
210    <!--!TODO: These are hardcoded for Jon Blower's WMS->KML service.  Make generic.-->
211    <LayerLimit>1</LayerLimit>
212    <MaxWidth>640</MaxWidth>
213    <MaxHeight>640</MaxHeight>
214
215  </Service>
216  <!--! These fields are represented in ows_common as service constraints -->
217  <Capability py:with="sm=c.capabilities; om=sm.operationsMetadata">
218    <py:if test="om is not None">
219      <?python
220    ops = ['GetCapabilities', 'GetMap', 'GetFeatureInfo']
221    eops = [x for x in om.operationDict.keys() if x not in ops]
222      ?>
223      <Request>
224     
225    <py:for each="opName in ops" py:if="opName in om.operationDict.keys()">
226      <span py:content="markupOperation(opName, om.operationDict[opName])" py:strip="True"/>
227    </py:for>
228   
229    <py:for each="opName in ops" py:if="opName in om.operationDict.keys()">
230      <?python exceptions = om.operationDict[opName].parameters.get('ExceptionFormat') ?>
231      <Exception py:if="exceptions is not None">
232        <Format py:for="e in exceptions.possibleValues.allowedValues"
233            py:content="e"/>
234      </Exception>
235    </py:for>
236      </Request>
237
238      <!--!TODO:  capability exceptions -->
239      <Exception><Format>text/xml</Format></Exception>     
240     
241      <_ExtendedCapabilities>
242      <Request>
243    <py:for each="opName in eops">
244      <span py:content="markupOperation(opName, om.operationDict[opName])" py:strip="True"/>
245    </py:for>
246    <py:for each="opName in eops">
247      <?python exceptions = om.operationDict[opName].parameters.get('ExceptionFormat') ?>
248      <Exception py:if="exceptions is not None">
249        <Format py:for="e in exceptions.possibleValues.allowedValues"
250            py:content="e"/>
251      </Exception>
252    </py:for>
253      </Request>
254      </_ExtendedCapabilities>
255    </py:if>
256   
257    <Layer py:if="sm.contents is not None">
258      <Title>Contents</Title>
259      <Layer py:for="ds in sm.contents.datasetSummaries"
260         py:replace="markupLayer(ds)">
261      </Layer>
262    </Layer>
263  </Capability>
264</WMS_Capabilities>
Note: See TracBrowser for help on using the repository browser.