source: cows/trunk/cows/pylons/templates/wfs_capabilities_1_1_0.xml @ 4274

Subversion URL: http://proj.badc.rl.ac.uk/svn/ndg/cows/trunk/cows/pylons/templates/wfs_capabilities_1_1_0.xml@4274
Revision 4274, 5.0 KB checked in by domlowe, 12 years ago (diff)

Adding initial WFS code. Plus further separation of CSML code and service specific code.

Line 
1<?xml version="1.0"?>
2
3<?python
4
5from cows.pylons.genshi_util import RenameElementFilter
6from genshi import QName
7import webhelpers as h
8
9?>
10
11<WFS_Capabilities xmlns:py="http://genshi.edgewall.org/"
12                  xmlns="http://www.opengis.net/wfs"
13                  xmlns:xlink="http://www.w3.org/1999/xlink"
14                  xmlns:ows="http://www.opengis.net/ows"
15                  xmlns:gml="http://www.opengis.net/gml" version="1.3.0">
16
17  <!--! ====================================================================== -->
18  <!--!
19      To change the tag name we need to wrap a markup macro in a python
20      function
21  -->
22
23  <Operation py:def="_opContent(op)">
24    <Format py:for="f in op.parameters['Format'].possibleValues.allowedValues" py:content="f"/>
25    <DCPType><HTTP>
26      <Get>
27        <OnlineResource xlink:type="simple" xlink:href="${op.get.href}"/>
28      </Get>
29    </HTTP></DCPType>
30  </Operation>
31  <?python
32 
33  def markupOperation(opName, op):
34    """Render an OWS operation description for the Capabilities section.
35    """
36
37    return RenameElementFilter(QName(opName))(_opContent(op))
38
39  ?>
40  <FeatureTypeList>
41          <FeatureType py:def="markupLayer(ds)">
42                <Name py:content="ds.identifier"/>
43                <Title py:content="ds.titles[0]"/>
44                <Abstract py:if="len(ds.abstracts)>0" py:content="ds.abstracts[0]"/>
45                <CRS py:for="crs in ds.CRSs" py:content="crs"/>
46                <?python exBBox = ds.wgs84BoundingBoxes[0]?>
47                <ows:WGS84BoundingBox>
48                  <ows:LowerCorner py:content="str(exBBox.lowerCorner[0]) + ' ' + str(exBBox.lowerCorner[1])" />
49                  <ows:UpperCorner py:content="str(exBBox.upperCorner[0]) + ' ' + str(exBBox.upperCorner[1])" />
50                </ows:WGS84BoundingBox>
51          </FeatureType>
52  </FeatureTypeList>
53  <!--! ====================================================================== -->
54
55
56  <ows:ServiceIdentification py:with="sm=c.capabilities; si=c.capabilities.serviceIdentification">
57    <ows:Name>BADC WFS</ows:Name>
58    <ows:Title py:content="si.titles[0]"/>
59    <ows:Abstract py:if="len(si.abstracts)>0" py:content="si.abstracts[0]"/>
60    <ows:Keywords>
61      <ows:Keyword py:for="kw in si.keywords"
62               py:content="kw"/>
63    </ows:Keywords>
64    <!--! <OnlineResource xlink:type="simple" xlink:href="${h.url_for(qualified=True, action='index')}?"/> -->
65   
66    <ows:ServiceProvider py:if="sm.serviceProvider is not None"
67                        py:with="rp=sm.serviceProvider.serviceContact">
68      <ows:ProviderName py:content="sm.serviceProvider.providerName"/>
69      <ows:ServiceContact>
70                <ows:IndividualName py:if="rp is not None" py:content="rp.individualName"/>
71                <ows:PositionName py:content="rp.positionName"/>
72                <py:with vars="cn=rp.contactInfo" py:if="cn is not None">
73                <ows:ContactInfo py:if="cn.phone is not None">
74                        <ows:Voice py:content="cn.phone.voice"/>
75                        <ows:Facsimile py:content="cn.phone.facsimile"/>       
76                </ows:ContactInfo>
77                <ows:Address py:if="cn.address is not None">
78                        <ows:DeliveryPoint><py:for each="d in cn.address.deliveryPoints">${d}</py:for>
79                        </ows:DeliveryPoint>
80                        <ows:City py:content="cn.address.city"/>
81                        <ows:AdministrativeArea py:content="cn.address.administrativeArea"/>
82                        <ows:PostalCode py:content="cn.address.postalCode"/>
83                        <ows:Country py:content="cn.address.country"/>
84                        <ows:ElectronicMailAddress py:content="cn.address.electronicMailAddress"/>
85                </ows:Address>
86        </py:with>     
87      </ows:ServiceContact>
88    </ows:ServiceProvider>
89    <ows:Fees py:content="si.fees"/>
90    <ows:AccessConstraints py:content="si.accessConstraints"/>
91  </ows:ServiceIdentification>
92  <!--! These fields are represented in ows_common as service constraints -->
93 
94  <ows:OperationsMetadata py:with="sm=c.capabilities; om=sm.operationsMetadata">
95    <py:if test="om is not None">
96      <?python
97        ops = ['GetCapabilities', 'DescribeFeature', 'GetFeature']
98        eops = [x for x in om.operationDict.keys() if x not in ops]
99      ?>
100      <ows:OperationsMetadata>
101      <py:for each="opName in ops" py:if="opName in om.operationDict.keys()">
102          <ows:Operation name="${opName}">
103                <ows:DCP>
104                        <ows:HTTP>
105                                <ows:Get  xlink:type="simple" xlink:href="${om.operationDict[opName].get.href}"/>
106                        </ows:HTTP>
107                </ows:DCP>
108          </ows:Operation>
109      </py:for>
110      </ows:OperationsMetadata> 
111      <_ExtendedCapabilities>     
112      <Request>
113        <py:for each="opName in eops">
114          <span py:content="markupOperation(opName, om.operationDict[opName])" py:strip="True"/>
115        </py:for>
116        <py:for each="opName in eops">
117          <?python exceptions = om.operationDict[opName].parameters.get('ExceptionFormat') ?>
118          <Exception py:if="exceptions is not None">
119            <Format py:for="e in exceptions.possibleValues.allowedValues"
120                    py:content="e"/>
121          </Exception>
122        </py:for>
123      </Request>
124      </_ExtendedCapabilities>
125    </py:if>
126    </ows:OperationsMetadata>
127   
128    <!-- COMMENTED OUT FOR NOW
129    <Exception><Format>text/xml</Format></Exception>
130                -->
131        <!-- Layers need to be featuretypes: -->
132    <Layer py:if="c.capabilities.contents is not None">
133      <Title>Contents</Title>
134      <Layer py:for="ds in c.capabilities.contents.datasetSummaries"
135             py:replace="markupLayer(ds)">
136      </Layer>
137    </Layer> 
138
139</WFS_Capabilities>
Note: See TracBrowser for help on using the repository browser.