source: cows/trunk/cows/service/imps/pywms/templates/GetCapabilities.kid @ 4808

Subversion URL: http://proj.badc.rl.ac.uk/svn/ndg/cows/trunk/cows/service/imps/pywms/templates/GetCapabilities.kid@4808
Revision 4808, 2.7 KB checked in by domlowe, 11 years ago (diff)

adding contents of pywms

Line 
1<?xml version="1.0" encoding="utf-8"?>
2<?python
3
4import urlparse
5import logging
6
7logger = logging.getLogger('pywms.templates.GetCapabilities')
8
9def strip_qs(url):
10    t = urlparse.urlparse(url)
11    return urlparse.urlunparse(list(t[:3])+['','',''])
12
13def layerFolderName(indexes):
14    """Turn a list of indexes into a layer name.
15
16    """
17    return "folder_%s" % '_'.join(str(x) for x in indexes)
18?>
19
20
21
22<WMS_Capabilities version="${version}"
23                  xmlns:py="http://purl.org/kid/ns#"
24                  xmlns="http://www.opengis.net/wms"
25                  xmlns:xlink="http://www.w3.org/1999/xlink/">
26
27  <Layer py:def="layer(name)">
28    <!--! <?python logger.info('calling layer(%s)' % name) ?> -->
29    <Name>${name}</Name>
30    <Title>${model.layers[name].title}</Title>
31    <Abstract py:content="model.layers[name].abstract"/>
32    <Dimension py:for="name, dim in model.layers[name].dimensions.items()"
33               name="${name}"
34               units="${dim.units}"
35               >${dim.extent}</Dimension>
36  </Layer>
37
38  <Layer py:def="layerFolder(lf, indexes, depth, topLevel=False)">
39    <!--! <?python logger.info('calling layerFolder(%s, %s, %s)' % (lf, indexes, depth)) ?> -->
40    <Name py:if="indexes" py:content="layerFolderName(indexes)"/>
41    <Name py:if="not indexes">toplevel</Name>
42    <Title py:content="lf.title"/>
43    <Abstract py:content="lf.abstract"/>
44    <!--! <CRS py:if="topLevel">CRS:84</CRS> -->
45    <SRS py:if="topLevel">EPSG:4326</SRS>
46    <BoundingBox py:if="topLevel" SRS="EPSG:4326"
47                 minx="-180" miny="-90" maxx="180" maxy="90"/>
48    <div py:if="depth != 0" py:for="i, item in enumerate(lf.contents)" py:strip="True">
49      <Layer py:if="type(item) == str" py:replace="layer(item)"/>
50      <Layer py:if="type(item) != str" py:replace="layerFolder(item, indexes + [i], depth-1)"/>
51    </div>
52  </Layer>
53
54  <Service>
55    <Name>WMS</Name>
56    <Title>${model.title}</Title>
57    <OnlineResource xlink:type="simple" xlink:href="${strip_qs(url)}"/>
58  </Service>
59  <Capability>
60    <Request>
61      <GetCapabilities>
62        <Format>application/vnd.ogc.wms_xml</Format>
63        <DCPType><HTTP><Get>
64          <OnlineResource xlink:type="simple" xlink:href="${strip_qs(url)}"/>
65        </Get></HTTP></DCPType>
66      </GetCapabilities>
67      <GetMap>
68        <Format py:for="format in formats">${format}</Format>
69        <DCPType><HTTP><Get>
70          <OnlineResource xlink:type="simple" xlink:href="${strip_qs(url)}"/>
71        </Get></HTTP></DCPType>
72      </GetMap>
73    </Request>
74    <Exception>
75      <Format>application/vnd.ogc.se_xml</Format>
76    </Exception>
77    <?python
78
79    if not contextFolder:
80        contextFolder = model.layerFolder
81
82    ?>
83    ${layerFolder(contextFolder, indexes, depth, topLevel=True)}
84  </Capability>
85</WMS_Capabilities>
Note: See TracBrowser for help on using the repository browser.