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

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

Merging in qesdi changes to cows trunk - still need to merge new backend.

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